Other Frameworks
Install
Section titled “Install”npm install @updog/data-editor-wcpnpm add @updog/data-editor-wcyarn add @updog/data-editor-wcRegister the custom element once, typically in your app’s entry point:
import "@updog/data-editor-wc";import "@updog/data-editor-wc/styles.css";This defines <updog-editor> globally. Both imports are required. Without the stylesheet the
editor renders unstyled.
Framework setup
Section titled “Framework setup”Vue and Angular try to resolve updog- tags as their own components. Tell each of them that
these tags are custom elements.
vue({ template: { compilerOptions: { isCustomElement: (tag) => tag.startsWith("updog-"), }, },})Without this, Vue logs Failed to resolve component: updog-editor and renders nothing.
@Component({ schemas: [CUSTOM_ELEMENTS_SCHEMA], // ...})Register the stylesheet in angular.json instead of importing it in the component:
"styles": ["@updog/data-editor-wc/styles.css", "src/styles.css"]No setup required. Svelte passes unknown tags straight through to the DOM.
No setup required.
What goes where
Section titled “What goes where”<updog-editor> is the same element in every framework and takes its configuration one way.
Write simple values as HTML attributes and pass everything else to configure().
| How to set it | Works in | |
|---|---|---|
api-key, primary-key, variant, mode, locale |
HTML attribute | every framework |
open, rtl, readonly |
HTML attribute (presence means true) | every framework |
columns, loadData, translations, remoteSources, synonyms, … |
configure() |
every framework |
onComplete, onError, onColumnMatch, onValueMatch |
configure() |
every framework |
| closing the modal | close event |
every framework |
The primary-key attribute carries a single column. A key built from several
columns goes through the primaryKey property or configure(), like every
other non-primitive prop.
Set the key one way or the other, never both. The attribute and the property write to the same place, so the later write replaces the earlier one, and a framework template can rewrite the attribute on any re-render.
Minimal example
Section titled “Minimal example”<button id="open-btn">Open Editor</button><updog-editor id="editor"></updog-editor>
<script type="module"> import "@updog/data-editor-wc"; import "@updog/data-editor-wc/styles.css";
const editor = document.getElementById("editor");
editor.configure({ apiKey: "your-license-key", columns: [ { id: "name", title: "Full Name", size: 200, validators: [{ type: "required", message: "Name is required" }] }, { id: "email", title: "Email", size: 250, validators: [{ type: "required", message: "Email is required" }, { type: "email", message: "Invalid email" }] }, { id: "role", title: "Role", editor: { type: "select", options: ["Admin", "Editor", "Viewer"] } }, ], primaryKey: "id", loadData: async (onChunk) => { const res = await fetch("/api/employees"); const rows = await res.json(); onChunk(rows); }, onComplete: async (result) => { console.log("Sources:", result.sources); console.log("Counts:", result.counts); }, });
document.getElementById("open-btn").addEventListener("click", () => editor.show()); editor.addEventListener("close", () => console.log("Editor closed"));</script>configure() accepts the same props as the React component, minus open and onClose. Use show(), hide(), and the close event for those.
