@niscorp/loom 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/DESIGN.md +253 -0
- package/LICENSE +202 -0
- package/README.md +101 -0
- package/dist/chunk-A3UOFGL4.js +29 -0
- package/dist/chunk-A3UOFGL4.js.map +1 -0
- package/dist/chunk-D743DI5J.js +17 -0
- package/dist/chunk-D743DI5J.js.map +1 -0
- package/dist/chunk-DWQWPBBV.js +63 -0
- package/dist/chunk-DWQWPBBV.js.map +1 -0
- package/dist/chunk-LWY5TG7M.js +208 -0
- package/dist/chunk-LWY5TG7M.js.map +1 -0
- package/dist/chunk-MIRMQPUE.js +132 -0
- package/dist/chunk-MIRMQPUE.js.map +1 -0
- package/dist/chunk-PTXRAWJX.js +58 -0
- package/dist/chunk-PTXRAWJX.js.map +1 -0
- package/dist/chunk-TV4U22MY.js +176 -0
- package/dist/chunk-TV4U22MY.js.map +1 -0
- package/dist/chunk-X7PCPONB.js +380 -0
- package/dist/chunk-X7PCPONB.js.map +1 -0
- package/dist/chunk-XTY7XO5C.js +61 -0
- package/dist/chunk-XTY7XO5C.js.map +1 -0
- package/dist/index.cjs +630 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +40 -0
- package/dist/index.d.ts +40 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/loom-editor-CQ_GI4IA.d.cts +27 -0
- package/dist/loom-editor-D5SBQ4_F.d.ts +27 -0
- package/dist/plugins/nova/index.cjs +81 -0
- package/dist/plugins/nova/index.cjs.map +1 -0
- package/dist/plugins/nova/index.d.cts +14 -0
- package/dist/plugins/nova/index.d.ts +14 -0
- package/dist/plugins/nova/index.js +5 -0
- package/dist/plugins/nova/index.js.map +1 -0
- package/dist/plugins/nova/react/index.cjs +107 -0
- package/dist/plugins/nova/react/index.cjs.map +1 -0
- package/dist/plugins/nova/react/index.d.cts +17 -0
- package/dist/plugins/nova/react/index.d.ts +17 -0
- package/dist/plugins/nova/react/index.js +36 -0
- package/dist/plugins/nova/react/index.js.map +1 -0
- package/dist/plugins/prism/index.cjs +48 -0
- package/dist/plugins/prism/index.cjs.map +1 -0
- package/dist/plugins/prism/index.d.cts +18 -0
- package/dist/plugins/prism/index.d.ts +18 -0
- package/dist/plugins/prism/index.js +4 -0
- package/dist/plugins/prism/index.js.map +1 -0
- package/dist/plugins/prism/react/index.cjs +744 -0
- package/dist/plugins/prism/react/index.cjs.map +1 -0
- package/dist/plugins/prism/react/index.d.cts +12 -0
- package/dist/plugins/prism/react/index.d.ts +12 -0
- package/dist/plugins/prism/react/index.js +419 -0
- package/dist/plugins/prism/react/index.js.map +1 -0
- package/dist/plugins/vex/index.cjs +67 -0
- package/dist/plugins/vex/index.cjs.map +1 -0
- package/dist/plugins/vex/index.d.cts +25 -0
- package/dist/plugins/vex/index.d.ts +25 -0
- package/dist/plugins/vex/index.js +4 -0
- package/dist/plugins/vex/index.js.map +1 -0
- package/dist/plugins/vex/react/index.cjs +432 -0
- package/dist/plugins/vex/react/index.cjs.map +1 -0
- package/dist/plugins/vex/react/index.d.cts +13 -0
- package/dist/plugins/vex/react/index.d.ts +13 -0
- package/dist/plugins/vex/react/index.js +296 -0
- package/dist/plugins/vex/react/index.js.map +1 -0
- package/dist/react/index.cjs +1076 -0
- package/dist/react/index.cjs.map +1 -0
- package/dist/react/index.d.cts +82 -0
- package/dist/react/index.d.ts +82 -0
- package/dist/react/index.js +120 -0
- package/dist/react/index.js.map +1 -0
- package/dist/schema--OhtatTX.d.cts +10 -0
- package/dist/schema--OhtatTX.d.ts +10 -0
- package/dist/types-BonjN3CB.d.cts +144 -0
- package/dist/types-BonjN3CB.d.ts +144 -0
- package/package.json +144 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../src/editor/view.ts","../../../../src/plugins/vex/widgets.ts","../../../../src/plugins/vex/preview.layout.ts","../../../../src/plugins/vex/preview.action.ts","../../../../src/plugins/vex/index.ts","../../../../src/plugins/vex/react/preview.tsx","../../../../src/react/hooks/model.ts","../../../../src/react/hooks/document.ts","../../../../src/plugins/vex/react/columns.ts","../../../../src/plugins/vex/react/styles.ts","../../../../src/plugins/vex/react/combobox.tsx","../../../../src/plugins/vex/react/operands.tsx","../../../../src/compile/parse.ts","../../../../src/react/kit/shared.ts","../../../../src/react/kit/json-editor.tsx","../../../../src/react/kit/variant.tsx","../../../../src/react/kit/menu.tsx","../../../../src/plugins/vex/react/records.tsx","../../../../src/plugins/vex/react/index.ts"],"names":["QuerySchema","useState","useRef","useEffect","jsx","jsxs","useNovaDispatch","createContext","useContext","getPath","matches","Fragment"],"mappings":";;;;;;;;;;;AAQO,IAAM,SAAA,GAAY,CACvB,MAAA,EACA,MAAA,EACA,IAAA,KACS;AACT,EAAA,MAAM,EAAE,OAAM,GAAI,MAAA;AAClB,EAAA,KAAA,CAAM,eAAe,MAAM,CAAA;AAC3B,EAAA,KAAA,CAAM,SAAA,CAAU,EAAE,EAAA,EAAI,MAAA,CAAO,IAAI,OAAA,EAAS,MAAA,CAAO,IAAI,CAAA;AACrD,EAAA,MAAM,WAAW,KAAA,CAAM,cAAA,CAAe,MAAA,CAAO,EAAE,EAAE,MAAA,EAAQ,EAAA;AACzD,EAAA,IAAI,aAAa,MAAA,EAAW;AAC5B,EAAA,MAAM,OAAO,MAAY;AACvB,IAAA,KAAA,CAAM,WAAW,QAAQ,CAAA,EAAG,OAAA,CAAQ,IAAA,CAAK,MAAM,CAAC,CAAA;AAAA,EAClD,CAAA;AACA,EAAA,MAAA,CAAO,EAAA,CAAG,UAAU,IAAI,CAAA;AACxB,EAAA,IAAA,EAAK;AACP,CAAA;;;ACfO,IAAM,cAAA,GAAiB,gBAAA;AACvB,IAAM,cAAA,GAAiB,gBAAA;AACvB,IAAM,aAAA,GAAgB,eAAA;AACtB,IAAM,WAAA,GAAc,aAAA;AAE3B,IAAM,cAAA,mBAAiB,IAAI,GAAA,CAAI,CAAC,IAAA,EAAM,K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AAA,OAAO,EAAE,IAAA,EAAM,SAAA,EAAW,KAAA,EAAO,SAAS,UAAA,EAAW;AACvD","file":"index.cjs","sourcesContent":["import type { ActionDefinition } from '@niscorp/nova';\nimport type { LoomEditor } from './types.js';\n\n// Mount a view canvas: register `action`, add a canvas that renders it, and keep\n// its data in sync with the editor's live state — `read(editor)` is pushed onto\n// the canvas on every `change`. The canvas id is the action id. Used by the\n// default plugins (jsonviewer, validation) and any domain preview; the contributor\n// owns the canvas, so a later plugin can `shell.removeCanvas(action.id)` to drop it.\nexport const mountView = (\n editor: LoomEditor,\n action: ActionDefinition,\n read: (editor: LoomEditor) => Record<string, unknown>,\n): void => {\n const { shell } = editor;\n shell.registerAction(action);\n shell.addCanvas({ id: action.id, initial: action.id });\n const instance = shell.getCanvasState(action.id).active?.id;\n if (instance === undefined) return;\n const sync = (): void => {\n shell.getRuntime(instance)?.setData(read(editor));\n };\n editor.on('change', sync);\n sync();\n};\n","import type { DatabaseSchema, NormalizedType } from '@niscorp/vex';\nimport type { WidgetBinding } from '@editor/types';\n\n// The vex widgets — framework-free. Each is a role (the component name its render\n// registers under) plus a matcher that claims fields by the tail of their path,\n// so a rule works at any depth (a comparison operand is `…eq` whether top-level or\n// nested). The render components live in ./react and close over the catalog.\n\nexport const VEX_COMPARISON = 'vex:comparison';\nexport const VEX_FIELD_PATH = 'vex:field-path';\nexport const VEX_AGGREGATE = 'vex:aggregate';\nexport const VEX_COMPUTE = 'vex:compute';\n\nconst COMPARISON_OPS = new Set(['eq', 'neq', 'gt', 'gte', 'lt', 'lte', 'like', 'ilike']);\nconst FIELD_KEYS = new Set(['field', 'isNull', 'isNotNull']);\n\nexport const leaf = (path: string): string => path.slice(path.lastIndexOf('.') + 1);\n// An item of the `fields` / `groupBy` arrays (path tail `fields.*` / `groupBy.*`).\nexport const isColumnListItem = (path: string): boolean => /(?:^|\\.)(?:fields|groupBy)\\.\\*$/.test(path);\n\n// The matchers, by where each field sits in the query. The compiler renders a\n// matched field with the role's component instead of the type default.\nexport const vexWidgets: WidgetBinding[] = [\n // A comparison `[left, right]`: a field-path picker + a typed operand.\n { role: VEX_COMPARISON, match: (field) => field.kind === 'unknown' && COMPARISON_OPS.has(leaf(field.path)) },\n // A standalone field path: a sort key, `isNull`/`isNotNull`, or a `fields` / `groupBy` item.\n { role: VEX_FIELD_PATH, match: (field) => field.kind === 'string' && (FIELD_KEYS.has(leaf(field.path)) || isColumnListItem(field.path)) },\n // `aggregate` / `compute` records (alias -> expression): keyed-entry editors.\n { role: VEX_AGGREGATE, match: (field) => field.kind === 'unknown' && leaf(field.path) === 'aggregate' },\n { role: VEX_COMPUTE, match: (field) => field.kind === 'unknown' && leaf(field.path) === 'compute' },\n];\n\n// The database's columns and their types, narrowed by the render widgets. Built\n// from the introspected schema; gives the field-path pickers their column list.\nexport type Catalog = { columns: string[]; typeOf: (column: string) => NormalizedType | undefined };\n\nexport const catalogOf = (db: DatabaseSchema): Catalog => {\n const types = new Map<string, NormalizedType>();\n const columns: string[] = [];\n for (const entity of db.entities) {\n for (const field of entity.fields) {\n const column = `${entity.name}.${field.name}`;\n columns.push(column);\n types.set(column, field.normalizedType);\n }\n }\n return { columns, typeOf: (column) => types.get(column) };\n};\n","import type { LayoutNode } from '@niscorp/nova';\n\n// The preview view's id — one string for one view: the name its component\n// registers under, the id of its action, and the id of its canvas. The plugin\n// owns it; the editor host defines no view ids of its own.\nexport const PREVIEW = 'vex:preview';\n\n// The preview layout: one component bound to the live `query` document. The\n// component runs the query and shows the rows.\nexport const previewLayout: LayoutNode = {\n component: PREVIEW,\n props: { query: '$.query' },\n};\n","import type { ActionDefinition } from '@niscorp/nova';\nimport { previewLayout, PREVIEW } from './preview.layout.js';\n\n// The preview canvas's action: the layout over a `query` slot the mount keeps\n// synced with the live query document. Canvas id equals the action id (PREVIEW).\nexport const previewAction: ActionDefinition = {\n id: PREVIEW,\n layout: previewLayout,\n data: { query: null },\n};\n","import type { ZodType } from 'zod';\nimport { QuerySchema, type DatabaseSchema, type Query } from '@niscorp/vex';\nimport { mountView } from '@editor/view';\nimport type { LoomPlugin } from '@editor/types';\nimport { vexWidgets } from './widgets.js';\nimport { previewAction } from './preview.action.js';\n\n// @niscorp/loom/plugins/vex — the Vex plugin (framework-free).\n//\n// Loom edits one document — a Vex query, from Vex's QuerySchema. The plugin\n// declares that document, contributes the preview canvas (which runs the query),\n// and — when given a database schema — the field-path widgets. The per-framework\n// surface (./react) supplies the preview component and the widget renders; this\n// core supplies the schema, the widget matchers, and the mount.\n\nexport { PREVIEW } from './preview.layout.js';\nexport type { Query };\n\nexport type VexRunResult = {\n rows: unknown[];\n warnings?: string[];\n errors?: string[];\n};\n\nexport type VexPluginConfig = {\n /** Run an edited query and return its rows (plus any warnings / errors). */\n run: (query: Query) => Promise<VexRunResult>;\n /** The introspected database schema — gives the field-path widgets their\n * column list. Omit to fall back to plain inputs. */\n db?: DatabaseSchema;\n /** Override the edited schema; defaults to Vex's `QuerySchema`. */\n schema?: ZodType;\n};\n\nexport const vexPlugin = (config: VexPluginConfig): LoomPlugin => ({\n name: 'vex',\n documents: { query: config.schema ?? (QuerySchema as ZodType) },\n // Widgets only matter with a schema to scope columns against; without `db` the\n // query edits as plain inputs.\n ...(config.db !== undefined ? { widgets: vexWidgets } : {}),\n mount: (editor) =>\n mountView(editor, previewAction, (e) => ({ query: (e.documents as Record<string, unknown>)['query'] })),\n});\n","import { useEffect, useRef, useState, type CSSProperties, type FC } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\nimport type { Query, VexRunResult } from '../index.js';\n\n// The preview component: re-runs the query whenever it changes, debounced, with a\n// sequence guard so a slow run can't overwrite a newer one. Registered under\n// PREVIEW; the plugin's mount binds the live query to it. Closes over the host's\n// `run`.\n\ntype State =\n | { status: 'empty' }\n | { status: 'running' }\n | { status: 'ok'; result: VexRunResult }\n | { status: 'error'; message: string };\n\nexport const makePreview = (run: (query: Query) => Promise<VexRunResult>): NovaComponent<{ query?: Query }> => {\n const Preview: FC<{ query?: Query }> = ({ query }) => {\n const [state, setState] = useState<State>({ status: 'empty' });\n const seq = useRef(0);\n const key = query == null ? '' : JSON.stringify(query);\n\n useEffect(() => {\n if (query == null) {\n setState({ status: 'empty' });\n return;\n }\n const mine = ++seq.current;\n setState({ status: 'running' });\n const handle = setTimeout(() => {\n run(query)\n .then((result) => {\n if (mine === seq.current) setState({ status: 'ok', result });\n })\n .catch((err: unknown) => {\n if (mine === seq.current) {\n setState({ status: 'error', message: err instanceof Error ? err.message : String(err) });\n }\n });\n }, 250);\n return () => clearTimeout(handle);\n // `key` is the query's content; re-run only when it actually changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [key]);\n\n return <PreviewView state={state} />;\n };\n return Preview;\n};\n\nconst PreviewView: FC<{ state: State }> = ({ state }) => {\n if (state.status === 'empty') return <Note>Edit the query to preview its results.</Note>;\n if (state.status === 'running') return <Note>Running…</Note>;\n if (state.status === 'error') return <Banner tone=\"error\" lines={[state.message]} />;\n const { rows, warnings, errors } = state.result;\n if (errors !== undefined && errors.length > 0) return <Banner tone=\"error\" lines={errors} />;\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: 10 }}>\n {warnings !== undefined && warnings.length > 0 ? <Banner tone=\"warn\" lines={warnings} /> : null}\n <RowsTable rows={rows} />\n </div>\n );\n};\n\nconst mono = 'ui-monospace, SFMono-Regular, Menlo, monospace';\n\nconst Note: FC<{ children: string }> = ({ children }) => (\n <div style={{ fontSize: 13, color: '#6b7280', padding: 12 }}>{children}</div>\n);\n\nconst TONES: Record<'error' | 'warn', { fg: string; bg: string; border: string }> = {\n error: { fg: '#991b1b', bg: '#fef2f2', border: '#fecaca' },\n warn: { fg: '#92400e', bg: '#fffbeb', border: '#fde68a' },\n};\n\nconst Banner: FC<{ tone: 'error' | 'warn'; lines: string[] }> = ({ tone, lines }) => {\n const c = TONES[tone];\n return (\n <pre style={{ margin: 0, padding: 12, background: c.bg, color: c.fg, border: `1px solid ${c.border}`, borderRadius: 6, fontSize: 12, fontFamily: mono, whiteSpace: 'pre-wrap', wordBreak: 'break-word' }}>\n {lines.join('\\n')}\n </pre>\n );\n};\n\nconst th: CSSProperties = { textAlign: 'left', padding: '6px 10px', background: '#f9fafb', borderBottom: '1px solid #e5e7eb', color: '#6b7280', fontWeight: 600, whiteSpace: 'nowrap' };\nconst td: CSSProperties = { padding: '6px 10px', borderBottom: '1px solid #f1f5f9', fontFamily: mono, whiteSpace: 'nowrap' };\n\nconst cell = (value: unknown): string =>\n value === null ? '∅' : typeof value === 'object' ? JSON.stringify(value) : String(value);\n\nconst RowsTable: FC<{ rows: unknown[] }> = ({ rows }) => {\n if (rows.length === 0) return <Note>No rows.</Note>;\n const first = rows[0];\n if (first === null || typeof first !== 'object') {\n return <Banner tone=\"warn\" lines={[JSON.stringify(rows, null, 2)]} />;\n }\n const cols = Object.keys(first as Record<string, unknown>);\n return (\n <div style={{ overflow: 'auto', border: '1px solid #e5e7eb', borderRadius: 6 }}>\n <table style={{ borderCollapse: 'collapse', width: '100%', fontSize: 12 }}>\n <thead>\n <tr>{cols.map((c) => <th key={c} style={th}>{c}</th>)}</tr>\n </thead>\n <tbody>\n {(rows as Record<string, unknown>[]).map((row, i) => (\n <tr key={i}>{cols.map((c) => <td key={c} style={td}>{cell(row[c])}</td>)}</tr>\n ))}\n </tbody>\n </table>\n </div>\n );\n};\n","import { useNovaDispatch, type NovaModelBinding } from '@niscorp/nova/adapters/react';\n\n// Returns a function that writes a new value to the field's bound path, through\n// the same `ui:model` pipeline the built-in controls use. A control or a plugin\n// widget calls it with its edited value.\nexport const useModelWrite = (model: NovaModelBinding | undefined): ((value: unknown) => void) => {\n const dispatch = useNovaDispatch();\n return (value) => {\n if (model !== undefined) dispatch({ type: 'ui:model', ref: model.ref, payload: value });\n };\n};\n","import { createContext, useContext } from 'react';\n\n// The document the editor is currently editing, available to widgets. A widget\n// gets its own field value as a prop; useLoomDocument gives it the whole\n// document, for widgets that need other fields (e.g. a Vex field-path picker\n// reading the query's `from`).\n\nexport type LoomDocument = Record<string, unknown> | undefined;\n\nexport const LoomDocumentContext = createContext<LoomDocument>(undefined);\n\nexport const useLoomDocument = (): LoomDocument => useContext(LoomDocumentContext);\n","import { getPath } from '@niscorp/nova';\nimport { useLoomDocument } from '@react/hooks/document';\nimport type { Catalog } from '../widgets.js';\n\n// The columns narrowed to the entities in the query's `from`, read from the live\n// document (`{ query: … }`, so the path is `query.from`). Returns the full list\n// when `from` is empty or names no known entity, so the pickers always offer\n// something.\nexport const useScopedColumns = (catalog: Catalog): string[] => {\n const document = useLoomDocument();\n const from = document === undefined ? undefined : getPath(document, 'query.from');\n const entities = Array.isArray(from) ? from.filter((source): source is string => typeof source === 'string') : [];\n if (entities.length === 0) return catalog.columns;\n const allowed = new Set(entities);\n const scoped = catalog.columns.filter((column) => allowed.has(column.slice(0, column.indexOf('.'))));\n return scoped.length > 0 ? scoped : catalog.columns;\n};\n","import type { CSSProperties } from 'react';\n\n// Theme-neutral styles shared by the vex widget editors.\nexport const fieldStyle: CSSProperties = { padding: '6px 10px', border: '1px solid #d1d5db', borderRadius: 6, fontSize: 14, boxSizing: 'border-box' };\nexport const controlBtn: CSSProperties = { padding: '6px 10px', border: '1px solid #d1d5db', borderRadius: 6, background: '#f3f4f6', cursor: 'pointer', fontSize: 13 };\n","import { useState, type CSSProperties, type FC } from 'react';\nimport { fieldStyle } from './styles.js';\n\nconst comboListStyle: CSSProperties = { position: 'absolute', top: '100%', left: 0, right: 0, zIndex: 20, marginTop: 2, maxHeight: 200, overflowY: 'auto', background: '#fff', border: '1px solid #d1d5db', borderRadius: 6, boxShadow: '0 6px 16px rgba(0,0,0,0.12)' };\nconst comboItemStyle: CSSProperties = { padding: '6px 10px', fontSize: 13, cursor: 'pointer', fontFamily: 'ui-monospace, Menlo, monospace' };\n\n// A combobox: shows all options on focus, filters as you type, commits a pick on\n// mousedown (before the input blurs). Replaces <datalist>, which shows only the\n// exact match once a value is set.\nexport const Combo: FC<{\n value: string;\n placeholder?: string;\n options: string[];\n onPick: (value: string) => void;\n style?: CSSProperties;\n}> = ({ value, placeholder, options, onPick, style }) => {\n const [open, setOpen] = useState(false);\n const needle = value.toLowerCase();\n const matches = options.filter((option) => option.toLowerCase().includes(needle));\n return (\n <div style={{ position: 'relative', ...style }}>\n <input\n value={value}\n placeholder={placeholder}\n onChange={(event) => onPick(event.target.value)}\n onFocus={() => setOpen(true)}\n onBlur={() => window.setTimeout(() => setOpen(false), 120)}\n style={{ ...fieldStyle, width: '100%' }}\n />\n {open && matches.length > 0 ? (\n <div style={comboListStyle}>\n {matches.slice(0, 50).map((option) => (\n <div\n key={option}\n // mousedown fires before the input's blur, so the pick lands.\n onMouseDown={(event) => {\n event.preventDefault();\n onPick(option);\n setOpen(false);\n }}\n style={comboItemStyle}\n >\n {option}\n </div>\n ))}\n </div>\n ) : null}\n </div>\n );\n};\n","import type { CSSProperties, FC } from 'react';\nimport type { NormalizedType } from '@niscorp/vex';\nimport type { NovaComponent, NovaModelBinding } from '@niscorp/nova/adapters/react';\nimport { useModelWrite } from '@react/hooks/model';\nimport type { Catalog } from '../widgets.js';\nimport { useScopedColumns } from './columns.js';\nimport { Combo } from './combobox.js';\nimport { fieldStyle } from './styles.js';\nimport type { WidgetProps } from './widget.js';\n\n// A standalone field path: a sort key, `isNull`/`isNotNull`, or a `fields` /\n// `groupBy` item. A combobox that autocompletes against the scoped columns.\nconst FieldPath: FC<{ value: unknown; catalog: Catalog; model: NovaModelBinding | undefined }> = ({ value, catalog, model }) => {\n const set = useModelWrite(model);\n const columns = useScopedColumns(catalog);\n return <Combo value={String(value ?? '')} placeholder=\"entity.field\" options={columns} onPick={set} style={{ width: '100%' }} />;\n};\n\n// The right operand, typed by the left column: a number box for numeric columns,\n// a true/false select for booleans, a text box otherwise.\nconst Operand: FC<{ type: NormalizedType | undefined; value: unknown; onChange: (value: unknown) => void }> = ({ type, value, onChange }) => {\n const style: CSSProperties = { ...fieldStyle, flex: 1, minWidth: 0 };\n if (type === 'number') {\n return (\n <input\n type=\"number\"\n value={typeof value === 'number' ? value : ''}\n placeholder=\"value\"\n onChange={(event) => onChange(event.target.value === '' ? null : Number(event.target.value))}\n style={style}\n />\n );\n }\n if (type === 'boolean') {\n return (\n <select\n value={value === true ? 'true' : value === false ? 'false' : ''}\n onChange={(event) => onChange(event.target.value === '' ? null : event.target.value === 'true')}\n style={style}\n >\n <option value=\"\">—</option>\n <option value=\"true\">true</option>\n <option value=\"false\">false</option>\n </select>\n );\n }\n return (\n <input\n value={value === null || value === undefined ? '' : String(value)}\n placeholder=\"value\"\n onChange={(event) => onChange(event.target.value)}\n style={style}\n />\n );\n};\n\n// A comparison `[left, right]`: a field-path picker + an operand typed by the\n// chosen column, instead of editing the tuple as raw JSON.\nconst Comparison: FC<{ value: unknown; catalog: Catalog; model: NovaModelBinding | undefined }> = ({ value, catalog, model }) => {\n const set = useModelWrite(model);\n const columns = useScopedColumns(catalog);\n const tuple = Array.isArray(value) ? value : [];\n const left = tuple[0];\n const right = tuple[1];\n const type = typeof left === 'string' ? catalog.typeOf(left) : undefined;\n return (\n <div style={{ display: 'flex', gap: 6, alignItems: 'center' }}>\n <Combo\n value={String(left ?? '')}\n placeholder=\"entity.field\"\n options={columns}\n onPick={(next) => set([next, right ?? null])}\n style={{ flex: 2, minWidth: 0 }}\n />\n <Operand type={type} value={right} onChange={(next) => set([left ?? '', next])} />\n </div>\n );\n};\n\n// The role components — closures over the catalog, registered under the widget\n// roles. Each receives `{ value, novaModel }` from the compiler.\nexport const fieldPathWidget = (catalog: Catalog): NovaComponent<WidgetProps> =>\n ({ value, novaModel }) => <FieldPath value={value} catalog={catalog} model={novaModel} />;\n\nexport const comparisonWidget = (catalog: Catalog): NovaComponent<WidgetProps> =>\n ({ value, novaModel }) => <Comparison value={value} catalog={catalog} model={novaModel} />;\n","import type { ZodType } from 'zod';\nimport type {\n CompileOptions,\n EmptyValue,\n EnumOption,\n Field,\n FieldKind,\n FieldMeta,\n ObjectField,\n Pattern,\n Variant,\n} from './types.js';\n\n// parse — turn a Zod schema into Loom's field model (IR). The only Zod-aware\n// code in the package, and pure data in / pure data out: no Nova. `parseByType`\n// is keyed by Zod's own `def.type` tag, so the type vocabulary lives as table\n// keys, not scattered checks.\n//\n// A recursive schema (`z.lazy`, or an object whose getter returns itself) would\n// expand forever. The walk carries the set of schemas it is currently inside;\n// re-entering one is a back-edge, emitted as a `self` marker and recorded so\n// the object it points back to can be tagged `recursive`. Expansion stops at\n// the cycle — the document, not the schema, decides how deep an editor goes.\n\n// The slice of a Zod schema's internal definition that parsing reads.\ntype ZodDef = {\n type: string;\n innerType?: ZodType;\n element?: ZodType;\n shape?: Record<string, ZodType>;\n entries?: Record<string, unknown>;\n defaultValue?: unknown;\n format?: string;\n checks?: ReadonlyArray<{ def?: { format?: string } }>;\n discriminator?: string;\n options?: readonly ZodType[];\n items?: readonly ZodType[];\n values?: readonly unknown[];\n getter?: () => ZodType;\n};\n\n// Zod types every schema's `.def` as the base `$ZodTypeDef` (just the `type`\n// discriminant); the per-type fields we read live on the concrete defs. This\n// views `.def` through the structural slice above — the single place the\n// parser depends on Zod's internal shape.\nconst defOf = (schema: ZodType): ZodDef => schema.def as ZodDef;\n\n// While walking, the schemas currently on the stack (cycle detection) and the\n// schemas a `self` pointed back to (so the matching object is tagged recursive).\n// Keyed by def, not instance: `.describe()`/`.meta()` clone the wrapper but\n// share the def, so a described alias of a recursive schema must read as the\n// schema itself — or every back-edge re-expands the whole thing one more level.\ntype Walk = { stack: Set<ZodDef>; targets: Set<ZodDef> };\n\n// ─── Reading Zod ─────────────────────────────────────────────\n\n// `safeint` is Zod's format tag for an integer-constrained number — the one\n// Zod-vocabulary token this file matches on.\nconst INTEGER_FORMAT = 'safeint';\n\nconst stringFormat = (schema: ZodType): string | undefined => {\n const def = defOf(schema);\n if (def.format !== undefined) return def.format;\n for (const check of def.checks ?? []) {\n if (check.def?.format !== undefined) return check.def.format;\n }\n return undefined;\n};\n\nconst isInteger = (schema: ZodType): boolean => {\n const def = defOf(schema);\n if (def.format === INTEGER_FORMAT) return true;\n return (def.checks ?? []).some((check) => check.def?.format === INTEGER_FORMAT);\n};\n\nconst enumOptions = (schema: ZodType): EnumOption[] =>\n Object.values(defOf(schema).entries ?? {}).map((value) => ({ value, label: String(value) }));\n\nconst objectFields = (schema: ZodType, walk: Walk): ObjectField[] =>\n Object.entries(defOf(schema).shape ?? {}).map(([key, value]) => ({\n key,\n // A property is optional when the schema accepts `undefined` for it\n // (covers `.optional()` and `.default()`) — asked of Zod, not inferred.\n required: !value.safeParse(undefined).success,\n field: parseField(value, walk),\n }));\n\n// ─── Union discrimination ────────────────────────────────────\n// For each branch, the cheapest fact that tells it apart from its siblings: the\n// declared tag's value, else a key only it carries, else a JS type only it is.\n// One function covers tagged, structural, and mixed unions; a branch that none\n// of these distinguish makes the whole union fall back to the raw editor.\n\nconst branchKeys = (branch: ZodType): string[] => Object.keys(defOf(branch).shape ?? {});\n\n// The branch's JS type, when it's one the runtime matcher checks (Zod names\n// these the same as `typeof`/`Array.isArray` do); otherwise undefined.\nconst JSON_TYPES = new Set(['string', 'number', 'boolean', 'object', 'array', 'null']);\nconst jsonType = (branch: ZodType): string | undefined => {\n const type = defOf(branch).type;\n return JSON_TYPES.has(type) ? type : undefined;\n};\n\nconst distinguish = (branch: ZodType, siblings: readonly ZodType[], tag: string | undefined): Pattern | undefined => {\n if (tag !== undefined) {\n const literal = (defOf(branch).shape ?? {})[tag];\n return { kind: 'tag', key: tag, value: literal !== undefined ? defOf(literal).values?.[0] : undefined };\n }\n const elsewhere = new Set(siblings.flatMap(branchKeys));\n const key = branchKeys(branch).find((k) => !elsewhere.has(k));\n if (key !== undefined) return { kind: 'key', key };\n const type = jsonType(branch);\n if (type !== undefined && siblings.every((s) => jsonType(s) !== type)) return { kind: 'type', type };\n return undefined;\n};\n\nconst patternLabel = (pattern: Pattern): string =>\n pattern.kind === 'tag'\n ? String(pattern.value)\n : pattern.kind === 'key'\n ? pattern.key\n : pattern.kind === 'type'\n ? pattern.type\n : 'other';\n\n// A union may nest unions (`z.union([...primitives, ...ops])` where the\n// primitives are themselves a `z.union`). The branches of a nested union are\n// siblings of the outer ones for discrimination, so inline them. Each branch is\n// unwrapped first (a described/optional sub-union still flattens); a non-union\n// branch passes through untouched. Unwrapping resolves lazies, so `seen` guards\n// a union that nests back into itself: once a union core is being flattened,\n// re-encountering it keeps the branch as a leaf rather than recursing forever.\nconst flattenBranches = (branches: readonly ZodType[], seen: Set<ZodDef> = new Set()): ZodType[] =>\n branches.flatMap((branch) => {\n const { core } = unwrap(branch);\n const def = defOf(core);\n if (def.type !== 'union' || seen.has(def)) return [branch];\n return flattenBranches(def.options ?? [], new Set(seen).add(def));\n });\n\n// A branch's editor. A tagged union owns its discriminant in the chooser, so it\n// is dropped from the fields; every other branch is edited whole — including a\n// `string` or `array` branch, which is just its own field, not a group.\nconst branchField = (branch: ZodType, walk: Walk, tag: string | undefined): Field =>\n tag === undefined\n ? parseField(branch, walk)\n : { kind: 'object', fields: objectFields(branch, walk).filter((f) => f.key !== tag) };\n\nconst parseByType: Record<string, (schema: ZodType, walk: Walk) => Field> = {\n string: (schema) => {\n const format = stringFormat(schema);\n return format !== undefined ? { kind: 'string', format } : { kind: 'string' };\n },\n number: (schema) => (isInteger(schema) ? { kind: 'number', integer: true } : { kind: 'number' }),\n boolean: () => ({ kind: 'boolean' }),\n enum: (schema) => ({ kind: 'enum', options: enumOptions(schema) }),\n object: (schema, walk) => {\n // On the stack while its fields parse, so a self-reference re-entering it\n // is caught as a cycle. If one was, the object is a recursion anchor.\n const def = defOf(schema);\n walk.stack.add(def);\n const fields = objectFields(schema, walk);\n walk.stack.delete(def);\n return walk.targets.has(def) ? { kind: 'object', fields, recursive: true } : { kind: 'object', fields };\n },\n array: (schema, walk) => {\n const element = defOf(schema).element;\n return { kind: 'array', item: element !== undefined ? parseField(element, walk) : { kind: 'unknown' } };\n },\n tuple: (schema, walk) => ({ kind: 'tuple', items: (defOf(schema).items ?? []).map((item) => parseField(item, walk)) }),\n union: (schema, walk) => {\n // Flatten nested unions into sibling branches, then dedup by identity — a\n // self-referential union resolves the same cached member instances twice, so\n // the same schema can appear more than once.\n const branches = [...new Set(flattenBranches(defOf(schema).options ?? []))];\n const tag = defOf(schema).discriminator;\n // Patterns don't need the stack — compute them first.\n const patterns = branches.map((b) => distinguish(b, branches.filter((x) => x !== b), tag));\n // A branch nothing distinguishes is the catch-all: allow exactly one, as the\n // fallback the widget picks when no other pattern matches. Two such branches\n // are ambiguous (which catches a plain value?), so the union still falls back\n // to the raw editor whole.\n const open = patterns.reduce<number[]>((acc, p, i) => (p === undefined ? [...acc, i] : acc), []);\n if (branches.length === 0 || open.length > 1) return { kind: 'unknown' };\n if (open.length === 1) patterns[open[0]!] = { kind: 'fallback' };\n // Parse the branch fields with the union on the stack, so a child that\n // re-enters it (a `children: LayoutNode[]`) is caught as a cycle.\n const def = defOf(schema);\n walk.stack.add(def);\n const variants: Variant[] = branches.map((branch, i) => ({\n label: readMeta(branch).title ?? patternLabel(patterns[i]!),\n field: branchField(branch, walk, tag),\n pattern: patterns[i]!,\n }));\n walk.stack.delete(def);\n return walk.targets.has(def) ? { kind: 'union', variants, recursive: true } : { kind: 'union', variants };\n },\n};\n\nconst unknownField = (): Field => ({ kind: 'unknown' });\n\n// Modifier wrappers that don't change the editing shape — peeled to reach the\n// core type, capturing any default along the way. `lazy` is peeled too: it is\n// the deferral that makes a schema recursive, resolved here to the schema it\n// guards (whose identity the cycle check then recognizes).\nconst WRAPPERS = new Set(['optional', 'nullable', 'default', 'readonly']);\n\n// A `lazy` is a deferred reference to one schema, but its getter may *build* a\n// fresh instance on every call (`z.lazy(() => z.union([...]))`) rather than\n// close over a stable const. Cycle detection needs the same resolution each\n// time, so resolve each lazy once and reuse it. Keyed by the lazy's def — the\n// def owns the getter, and a `.describe()` alias of the lazy shares it, so the\n// alias resolves to the same instance instead of a second copy of the tree.\nconst lazyResolved = new WeakMap<ZodDef, ZodType>();\nconst resolveLazy = (lazy: ZodType): ZodType | undefined => {\n const def = defOf(lazy);\n const cached = lazyResolved.get(def);\n if (cached !== undefined) return cached;\n const resolved = def.getter?.();\n if (resolved !== undefined) lazyResolved.set(def, resolved);\n return resolved;\n};\n\nconst unwrap = (schema: ZodType): { core: ZodType; default?: unknown } => {\n let core = schema;\n let fallback: unknown;\n let def = defOf(core);\n while (WRAPPERS.has(def.type) || def.type === 'lazy') {\n // `lazy` reaches its schema through a memoized getter; the other wrappers\n // through `innerType`. Either may be absent on a malformed def — stop if so.\n const inner = def.type === 'lazy' ? resolveLazy(core) : def.innerType;\n if (inner === undefined) break;\n if ('defaultValue' in def) fallback = def.defaultValue;\n core = inner;\n def = defOf(core);\n }\n return fallback !== undefined ? { core, default: fallback } : { core };\n};\n\nconst readMeta = (schema: ZodType): FieldMeta => {\n const meta: FieldMeta = {};\n const title = (schema.meta() as { title?: unknown } | undefined)?.title;\n if (typeof title === 'string') meta.title = title;\n if (schema.description !== undefined) meta.description = schema.description;\n return meta;\n};\n\nconst parseField = (schema: ZodType, walk: Walk): Field => {\n const { core, default: fallback } = unwrap(schema);\n // A schema already on the stack is a recursion back-edge: stop and record\n // it, so the object it cycles to is tagged when its parse unwinds.\n if (walk.stack.has(defOf(core))) {\n walk.targets.add(defOf(core));\n return { kind: 'self' };\n }\n const body = (parseByType[defOf(core).type] ?? unknownField)(core, walk);\n // Read metadata from both the core and the original, so a `.describe()` on\n // either the type or a wrapper is picked up; the outer one wins.\n const meta = { ...readMeta(core), ...readMeta(schema) };\n return { ...body, ...meta, ...(fallback !== undefined ? { default: fallback } : {}) };\n};\n\nexport const parse = (schema: ZodType): Field =>\n parseField(schema, { stack: new Set(), targets: new Set() });\n\n// ─── buildDocument: IR → default document ────────────────────\n// The default value of a field, by kind. Pure JSON — a model concern, not a\n// rendering one. Recursion bottoms out naturally: a recursive object's array\n// of itself defaults to empty, so no `self` is ever expanded into a default.\n\n// Each entry takes the whole field; the scalar kinds ignore it, and the two that\n// read their own shape (`object`, `union`) narrow with a guard rather than a\n// cast — the guard never fires (dispatch keys on `kind`), but it keeps the\n// types honest without a type assertion.\nconst EMPTY: Record<FieldKind, EmptyValue> = {\n string: () => '',\n number: () => 0,\n boolean: () => false,\n // No neutral in-domain value: \"no selection\" is absence (undefined), which\n // an optional enum accepts and a required one flags — unlike null, which a\n // Zod enum rejects outright. Defaults drop undefined, so no stray key.\n enum: () => undefined,\n array: () => [],\n // Each slot built from its own field; a fixed-length list, so no growth.\n tuple: (field, options) => (field.kind === 'tuple' ? field.items.map((item) => buildDocument(item, options)) : []),\n // A recursion point has no value of its own; the array holding it defaults to [].\n self: () => undefined,\n unknown: () => null,\n object: (field, options) => {\n if (field.kind !== 'object') return {};\n const includeOptional = options.includeOptional ?? true;\n const document: Record<string, unknown> = {};\n for (const child of field.fields) {\n if (!child.required && !includeOptional) continue;\n const value = buildDocument(child.field, options);\n if (value !== undefined) document[child.key] = value; // no stray undefined keys\n }\n return document;\n },\n // An empty union defaults to its first variant (tag + branch defaults).\n union: (field) => {\n if (field.kind !== 'union') return {};\n const first = field.variants[0];\n return first === undefined ? {} : variantDefaults(first);\n },\n};\n\nexport const buildDocument = (field: Field, options: CompileOptions): unknown => {\n if (field.default !== undefined) return field.default;\n return (options.empty?.[field.kind] ?? EMPTY[field.kind])(field, options);\n};\n\n// A plain object — not an array or null. Guards the spread of a built default\n// document, whose static type is `unknown` (so we check rather than assert).\nexport const isRecord = (value: unknown): value is Record<string, unknown> =>\n typeof value === 'object' && value !== null && !Array.isArray(value);\n\n// A branch's default value: whatever its field builds — an object, but also a\n// bare `''` or `[]` for a scalar/array branch. A tagged union additionally sets\n// its discriminant alongside. Used as an empty union's value and to reshape the\n// document when the chooser switches branches.\nexport const variantDefaults = (variant: Variant): unknown => {\n const defaults = buildDocument(variant.field, {});\n if (variant.pattern.kind !== 'tag') return defaults;\n return { [variant.pattern.key]: variant.pattern.value, ...(isRecord(defaults) ? defaults : {}) };\n};\n","import type { CSSProperties } from 'react';\nimport { isRecord } from '@compile/parse';\nimport type { Pattern } from '@compile/types';\n\n// Shared by the kit's controls and structural editors.\n\nexport const inputStyle: CSSProperties = { padding: '6px 10px', border: '1px solid #d1d5db', borderRadius: 6, fontSize: 14, width: '100%', boxSizing: 'border-box' };\n\n// The value's own JS type, in the vocabulary the compiler's patterns use.\nexport const jsType = (value: unknown): string =>\n Array.isArray(value) ? 'array' : value === null ? 'null' : typeof value;\n\n// Decode a JSON-encoded literal prop (see `literal` in to-nova). The compiler\n// passes static `$`-bearing metadata (a variant's branches, a list's containers,\n// an \"add\" default) as a JSON string so Nova's resolver leaves it intact; the\n// component parses it back. Tolerates an already-decoded value or absence.\nexport const decodeLiteral = <T>(value: unknown): T | undefined =>\n typeof value === 'string' ? (JSON.parse(value) as T) : (value as T | undefined);\n\n// Does a value belong to a branch? `===` for a tag, `in` for a key, `typeof`\n// for a type — the whole of union discrimination, in plain JS. A `fallback`\n// branch never matches positively; the widget selects it only when nothing else\n// does, so it answers false here.\nexport const matches = (value: unknown, pattern: Pattern): boolean => {\n if (pattern.kind === 'tag') return isRecord(value) && value[pattern.key] === pattern.value;\n if (pattern.kind === 'key') return isRecord(value) && pattern.key in value;\n if (pattern.kind === 'type') return jsType(value) === pattern.type;\n return false;\n};\n","import { useEffect, useState, type CSSProperties, type FC } from 'react';\nimport { inputStyle } from './shared.js';\n\n// A controlled JSON editor: a textarea with pretty-printed JSON that commits only\n// when the text parses, so mid-edit invalid JSON doesn't fight the keystrokes. An\n// external change to the value reloads the buffer; the serialized-value dep makes\n// that fire on real content changes only, not on our own commits. Exported so\n// plugins can reuse it as the fallback editor for values they don't structure.\n\nconst rawStyle: CSSProperties = {\n ...inputStyle,\n margin: 0,\n fontFamily: 'ui-monospace, SFMono-Regular, Menlo, monospace',\n fontSize: 13,\n minHeight: 64,\n resize: 'vertical',\n width: '100%',\n boxSizing: 'border-box',\n};\n\nconst showJson = (value: unknown): string => JSON.stringify(value ?? null, null, 2);\n\nexport const JsonEditor: FC<{ value: unknown; onChange: (value: unknown) => void }> = ({ value, onChange }) => {\n const [text, setText] = useState(() => showJson(value));\n const [valid, setValid] = useState(true);\n const serialized = JSON.stringify(value ?? null);\n\n useEffect(() => {\n // Adopt the value only when it differs from what the buffer already holds,\n // so an external edit reloads it but our own committed edits don't churn it.\n let mine: unknown;\n try {\n mine = JSON.parse(text);\n } catch {\n setText(showJson(value));\n setValid(true);\n return;\n }\n if (JSON.stringify(mine ?? null) !== serialized) {\n setText(showJson(value));\n setValid(true);\n }\n // Keyed on the serialized value: runs only when the value's content changes.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [serialized]);\n\n return (\n <textarea\n value={text}\n spellCheck={false}\n onChange={(event) => {\n const next = event.target.value;\n setText(next);\n try {\n const parsed: unknown = JSON.parse(next);\n setValid(true);\n onChange(parsed);\n } catch {\n setValid(false);\n }\n }}\n style={valid ? rawStyle : { ...rawStyle, borderColor: '#dc2626', background: '#fef2f2' }}\n />\n );\n};\n","import { createContext, useContext, type CSSProperties } from 'react';\nimport type { NovaComponent } from '@niscorp/nova/adapters/react';\nimport { isRecord } from '@compile/parse';\nimport type { Pattern } from '@compile/types';\nimport { useModelWrite } from '../hooks/model.js';\nimport { decodeLiteral, inputStyle, matches } from './shared.js';\n\n// The union editor and its branch wrappers.\n\nconst variantStyle: CSSProperties = { display: 'flex', flexDirection: 'column', gap: 12 };\n\ntype Branch = { label: string; pattern: Pattern; defaults: unknown; childrenKey?: string };\n\n// The active branch index, shared from the variant down to its branch wrappers.\nconst ActiveBranch = createContext(0);\n\n// One branch of a variant — renders its editor only when it is the active one.\nexport const LoomBranch: NovaComponent<{ index?: number }> = ({ index, children }) =>\n useContext(ActiveBranch) === index ? <>{children}</> : null;\n\n// A union editor: a type chooser plus the active branch. It matches the current\n// value to a branch in JS, tells the branches which is active (via context), and\n// each shows or hides itself; on change it writes the chosen branch's default,\n// reshaping the value. Tagged, structural, and mixed unions are the same code —\n// only the pattern differs.\nexport const LoomVariant: NovaComponent<{ value?: unknown; branches?: unknown }> = ({\n value,\n branches,\n children,\n novaModel,\n}) => {\n const set = useModelWrite(novaModel);\n const options = decodeLiteral<Branch[]>(branches) ?? [];\n // The first branch whose pattern matches the value; failing that, the open\n // `fallback` branch (which never matches positively), else the first branch.\n const matched = options.findIndex((branch) => matches(value, branch.pattern));\n const fallback = options.findIndex((branch) => branch.pattern.kind === 'fallback');\n const active = matched >= 0 ? matched : Math.max(0, fallback);\n // Switching between two container variants carries the children over; switching\n // to one without a child-list drops them (after a confirm).\n const switchTo = (chosen: Branch): void => {\n const activeKey = options[active]?.childrenKey;\n const oldChildren = activeKey !== undefined && isRecord(value) ? value[activeKey] : undefined;\n if (chosen.childrenKey !== undefined && Array.isArray(oldChildren)) {\n set({ ...(isRecord(chosen.defaults) ? chosen.defaults : {}), [chosen.childrenKey]: oldChildren });\n return;\n }\n if (Array.isArray(oldChildren) && oldChildren.length > 0 && !window.confirm('This type has no children. Discard them?')) return;\n set(chosen.defaults);\n };\n return (\n <div style={variantStyle}>\n <select\n value={active}\n onChange={(event) => {\n const chosen = options[Number(event.target.value)];\n if (chosen !== undefined) switchTo(chosen);\n }}\n style={inputStyle}\n >\n {options.map((branch, index) => (\n <option key={index} value={index}>\n {branch.label}\n </option>\n ))}\n </select>\n <ActiveBranch.Provider value={active}>{children}</ActiveBranch.Provider>\n </div>\n );\n};\n","import { createContext, useContext, useState, type CSSProperties, type FC, type ReactNode } from 'react';\n\n// A small actions-menu primitive: a `⋯` trigger that opens a popover of items,\n// with optional fly-out submenus. Shared by the array row menu and the Prism\n// node editor so both look and behave the same. Presentational only — callers\n// supply the items and what they do.\n\nconst trigger: CSSProperties = { padding: '4px 8px', border: '1px solid #d1d5db', borderRadius: 6, background: '#fff', cursor: 'pointer', fontSize: 13, lineHeight: 1 };\nconst base: CSSProperties = { position: 'absolute', zIndex: 30, minWidth: 170, display: 'flex', flexDirection: 'column', background: '#fff', border: '1px solid #d1d5db', borderRadius: 6, boxShadow: '0 6px 16px rgba(0,0,0,0.12)', padding: 4 };\nconst menuRight: CSSProperties = { ...base, top: '100%', right: 0, marginTop: 4 };\nconst menuLeft: CSSProperties = { ...base, top: '100%', left: 0, marginTop: 4 };\n// A submenu flies away from the menu's anchored edge (and scrolls): out to the\n// left for a right-anchored menu, out to the right for a left-anchored one. No\n// gap (flush `100%`) so the pointer can cross into it without leaving the row.\nconst flyLeft: CSSProperties = { ...base, top: 0, right: '100%', maxHeight: 280, overflowY: 'auto' };\nconst flyRight: CSSProperties = { ...base, top: 0, left: '100%', maxHeight: 280, overflowY: 'auto' };\nconst itemStyle: CSSProperties = { width: '100%', boxSizing: 'border-box', textAlign: 'left', padding: '6px 10px', cursor: 'pointer', fontSize: 13, borderRadius: 4, whiteSpace: 'nowrap', display: 'flex', justifyContent: 'space-between', gap: 12 };\nconst itemDisabled: CSSProperties = { ...itemStyle, color: '#9ca3af', cursor: 'default' };\n// Hover highlight (inline styles can't express `:hover`); the class is on every\n// item, the rule injected once with the open menu.\nconst MENU_CSS = '.loom-menu-item{background:transparent;border:none;}.loom-menu-item:hover:not(:disabled){background:#f3f4f6;}';\n\ntype Anchor = 'left' | 'right';\nconst MenuContext = createContext<{ close: () => void; anchor: Anchor }>({ close: () => {}, anchor: 'right' });\n\n// The trigger plus the popover. `anchor` is which edge the popover and its\n// submenus hang from. Children are `MenuItem` / `SubMenu`.\nexport const ActionMenu: FC<{ label?: ReactNode; ariaLabel?: string; anchor?: Anchor; children: ReactNode }> = ({\n label = '⋯',\n ariaLabel = 'Actions',\n anchor = 'right',\n children,\n}) => {\n const [open, setOpen] = useState(false);\n return (\n <div style={{ position: 'relative' }}>\n <button type=\"button\" aria-label={ariaLabel} onClick={() => setOpen((was) => !was)} style={trigger}>\n {label}\n </button>\n {open ? (\n <>\n <div onMouseDown={() => setOpen(false)} style={{ position: 'fixed', inset: 0, zIndex: 29 }} />\n <div style={anchor === 'right' ? menuRight : menuLeft}>\n <style>{MENU_CSS}</style>\n <MenuContext.Provider value={{ close: () => setOpen(false), anchor }}>{children}</MenuContext.Provider>\n </div>\n </>\n ) : null}\n </div>\n );\n};\n\n// A menu row: runs its action then closes the whole menu.\nexport const MenuItem: FC<{ label: ReactNode; onSelect: () => void; disabled?: boolean }> = ({ label, onSelect, disabled }) => {\n const { close } = useContext(MenuContext);\n return (\n <button\n type=\"button\"\n className=\"loom-menu-item\"\n disabled={disabled}\n onClick={() => {\n onSelect();\n close();\n }}\n style={disabled ? itemDisabled : itemStyle}\n >\n {typeof label === 'string' ? <span>{label}</span> : label}\n </button>\n );\n};\n\n// A row that flies out a submenu of its children on hover.\nexport const SubMenu: FC<{ label: ReactNode; children: ReactNode }> = ({ label, children }) => {\n const { anchor } = useContext(MenuContext);\n const [open, setOpen] = useState(false);\n return (\n <div style={{ position: 'relative' }} onMouseEnter={() => setOpen(true)} onMouseLeave={() => setOpen(false)}>\n <button type=\"button\" className=\"loom-menu-item\" onClick={() => setOpen((was) => !was)} style={itemStyle}>\n <span>{label}</span>\n <span>▸</span>\n </button>\n {open ? <div style={anchor === 'right' ? flyLeft : flyRight}>{children}</div> : null}\n </div>\n );\n};\n","import type { FC, ReactNode } from 'react';\nimport type { NovaComponent, NovaModelBinding } from '@niscorp/nova/adapters/react';\nimport { useModelWrite } from '@react/hooks/model';\nimport { JsonEditor } from '@react/kit';\nimport { isRecord } from '@compile/parse';\nimport type { Catalog } from '../widgets.js';\nimport { useScopedColumns } from './columns.js';\nimport { Combo } from './combobox.js';\nimport { fieldStyle, controlBtn } from './styles.js';\nimport type { WidgetProps } from './widget.js';\n\n// The alias -> value rows shared by `compute` and `aggregate`: one row per entry\n// (alias input + value editor + remove), plus add. Rows are keyed by index so\n// renaming an alias doesn't remount the value editor. Writes the whole object on\n// any change. `renderValue` is the per-entry value editor; `newEntry` is the\n// value an added row starts from.\nconst RecordRows: FC<{\n value: unknown;\n model: NovaModelBinding | undefined;\n newEntry: unknown;\n renderValue: (value: unknown, onChange: (value: unknown) => void) => ReactNode;\n}> = ({ value, model, newEntry, renderValue }) => {\n const set = useModelWrite(model);\n const entries = isRecord(value) ? Object.entries(value) : [];\n const write = (next: [string, unknown][]): void => set(Object.fromEntries(next));\n return (\n <div style={{ display: 'flex', flexDirection: 'column', gap: 6, padding: 12, border: '1px dashed #d1d5db', borderRadius: 6 }}>\n {entries.map(([key, val], index) => (\n <div key={index} style={{ display: 'flex', gap: 6, alignItems: 'flex-start' }}>\n <input\n value={key}\n placeholder=\"alias\"\n onChange={(event) => write(entries.map((entry, i) => (i === index ? [event.target.value, entry[1]] : entry)))}\n style={{ ...fieldStyle, width: 110 }}\n />\n <div style={{ flex: 1, minWidth: 0 }}>\n {renderValue(val, (next) => write(entries.map((entry, i) => (i === index ? [entry[0], next] : entry))))}\n </div>\n <button type=\"button\" onClick={() => write(entries.filter((_, i) => i !== index))} style={controlBtn}>✕</button>\n </div>\n ))}\n <button type=\"button\" onClick={() => write([...entries, [`field_${entries.length + 1}`, newEntry]])} style={{ ...controlBtn, alignSelf: 'flex-start' }}>Add</button>\n </div>\n );\n};\n\n// A field-or-literal operand: a column picker that also takes a typed literal\n// (numbers and booleans are coerced; everything else stays a string — a column\n// path or a string literal).\nconst coerceLiteral = (text: string): unknown => {\n if (text === '') return '';\n if (text === 'true') return true;\n if (text === 'false') return false;\n const n = Number(text);\n return text.trim() !== '' && Number.isFinite(n) ? n : text;\n};\n\nconst ValueInput: FC<{ value: unknown; columns: string[]; onChange: (value: unknown) => void }> = ({ value, columns, onChange }) => (\n <Combo\n value={value === null || value === undefined ? '' : String(value)}\n placeholder=\"field or value\"\n options={columns}\n onPick={(text) => onChange(coerceLiteral(text))}\n style={{ flex: 1, minWidth: 120 }}\n />\n);\n\n// aggregate value: count | sum | avg | min | max, applied to a column.\nconst AGG_OPS = ['count', 'sum', 'avg', 'min', 'max'];\n\nconst AggregateValue: FC<{ value: unknown; onChange: (value: unknown) => void; catalog: Catalog }> = ({ value, onChange, catalog }) => {\n const columns = useScopedColumns(catalog);\n const record = isRecord(value) ? value : {};\n const op = AGG_OPS.find((candidate) => candidate in record) ?? 'count';\n const operand = typeof record[op] === 'string' ? (record[op] as string) : '';\n const options = op === 'count' ? ['*', ...columns] : columns;\n const switchOp = (next: string): void => {\n let carried = operand;\n if (next === 'count' && carried === '') carried = '*';\n if (next !== 'count' && carried === '*') carried = '';\n onChange({ [next]: carried });\n };\n return (\n <div style={{ display: 'flex', gap: 6, alignItems: 'center' }}>\n <select value={op} onChange={(event) => switchOp(event.target.value)} style={{ ...fieldStyle, width: 90 }}>\n {AGG_OPS.map((candidate) => <option key={candidate} value={candidate}>{candidate}</option>)}\n </select>\n <Combo value={operand} placeholder=\"entity.field\" options={options} onPick={(next) => onChange({ [op]: next })} style={{ flex: 1, minWidth: 0 }} />\n </div>\n );\n};\n\n// compute value: arithmetic (two operands), concat/coalesce (operand list), or\n// case (the recursive filter, edited as JSON via Loom's editor).\nconst ARITHMETIC = new Set(['add', 'subtract', 'multiply', 'divide']);\nconst LISTS = new Set(['concat', 'coalesce']);\nconst COMPUTE_OPS = ['add', 'subtract', 'multiply', 'divide', 'concat', 'coalesce', 'case'];\n\nconst ComputeValue: FC<{ value: unknown; onChange: (value: unknown) => void; catalog: Catalog }> = ({ value, onChange, catalog }) => {\n const columns = useScopedColumns(catalog);\n const record = isRecord(value) ? value : {};\n const op = COMPUTE_OPS.find((candidate) => candidate in record) ?? 'add';\n const operands = Array.isArray(record[op]) ? (record[op] as unknown[]) : [];\n\n const switchOp = (next: string): void => {\n if (next === 'case') {\n onChange({ case: { when: [{ condition: { eq: ['', ''] }, then: '' }], else: '' } });\n } else if (ARITHMETIC.has(next)) {\n onChange({ [next]: [operands[0] ?? '', operands[1] ?? ''] });\n } else {\n onChange({ [next]: operands.length >= 2 ? operands : ['', ''] });\n }\n };\n\n return (\n <div style={{ display: 'flex', gap: 6, alignItems: 'flex-start', flexWrap: 'wrap' }}>\n <select value={op} onChange={(event) => switchOp(event.target.value)} style={{ ...fieldStyle, width: 90 }}>\n {COMPUTE_OPS.map((candidate) => <option key={candidate} value={candidate}>{candidate}</option>)}\n </select>\n {ARITHMETIC.has(op) ? (\n <>\n <ValueInput value={operands[0]} columns={columns} onChange={(next) => onChange({ [op]: [next, operands[1] ?? ''] })} />\n <ValueInput value={operands[1]} columns={columns} onChange={(next) => onChange({ [op]: [operands[0] ?? '', next] })} />\n </>\n ) : null}\n {LISTS.has(op) ? (\n <OperandList values={operands} columns={columns} onChange={(list) => onChange({ [op]: list })} />\n ) : null}\n {op === 'case' ? (\n <div style={{ flex: 1, minWidth: 200 }}>\n <JsonEditor value={record.case} onChange={(next) => onChange({ case: next })} />\n </div>\n ) : null}\n </div>\n );\n};\n\n// concat / coalesce: a list of operands (min 2), with add and remove.\nconst OperandList: FC<{ values: unknown[]; columns: string[]; onChange: (values: unknown[]) => void }> = ({ values, columns, onChange }) => (\n <div style={{ display: 'flex', flexDirection: 'column', gap: 4, flex: 1, minWidth: 160 }}>\n {values.map((operand, index) => (\n <div key={index} style={{ display: 'flex', gap: 4 }}>\n <ValueInput value={operand} columns={columns} onChange={(next) => onChange(values.map((current, i) => (i === index ? next : current)))} />\n <button type=\"button\" disabled={values.length <= 2} onClick={() => onChange(values.filter((_, i) => i !== index))} style={controlBtn}>✕</button>\n </div>\n ))}\n <button type=\"button\" onClick={() => onChange([...values, ''])} style={{ ...controlBtn, alignSelf: 'flex-start' }}>+</button>\n </div>\n);\n\n// The role components — closures over the catalog, registered under the widget\n// roles. Each receives `{ value, novaModel }` from the compiler.\nexport const aggregateWidget = (catalog: Catalog): NovaComponent<WidgetProps> =>\n ({ value, novaModel }) => (\n <RecordRows value={value} model={novaModel} newEntry={{ count: '*' }} renderValue={(v, onChange) => <AggregateValue value={v} onChange={onChange} catalog={catalog} />} />\n );\n\nexport const computeWidget = (catalog: Catalog): NovaComponent<WidgetProps> =>\n ({ value, novaModel }) => (\n <RecordRows value={value} model={novaModel} newEntry={{ add: ['', ''] }} renderValue={(v, onChange) => <ComputeValue value={v} onChange={onChange} catalog={catalog} />} />\n );\n","import type { NovaComponent } from '@niscorp/nova/adapters/react';\nimport type { LoomEditorPlugin } from '@react/editor/loom-editor';\nimport { vexPlugin, type VexPluginConfig } from '../index.js';\nimport { PREVIEW } from '../preview.layout.js';\nimport { catalogOf, VEX_COMPARISON, VEX_FIELD_PATH, VEX_AGGREGATE, VEX_COMPUTE } from '../widgets.js';\nimport { makePreview } from './preview.js';\nimport { comparisonWidget, fieldPathWidget } from './operands.js';\nimport { aggregateWidget, computeWidget } from './records.js';\n\n// @niscorp/loom/plugins/vex/react — the React surface for the Vex plugin.\n//\n// `vex(config)` assembles the core plugin with its components: the preview (which\n// runs `config.run`) and, when `config.db` is given, the field-path widget renders\n// (closures over the column catalog). The widget matchers live in the core; these\n// fill their roles.\n\nexport type { VexPluginConfig, VexRunResult } from '../index.js';\n\nexport const vex = (config: VexPluginConfig): LoomEditorPlugin => {\n const { name, documents, mount, widgets } = vexPlugin(config);\n const components: Record<string, NovaComponent> = { [PREVIEW]: makePreview(config.run) };\n if (config.db !== undefined) {\n const catalog = catalogOf(config.db);\n components[VEX_COMPARISON] = comparisonWidget(catalog);\n components[VEX_FIELD_PATH] = fieldPathWidget(catalog);\n components[VEX_AGGREGATE] = aggregateWidget(catalog);\n components[VEX_COMPUTE] = computeWidget(catalog);\n }\n return { name, documents, mount, widgets, components };\n};\n"]}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { L as LoomEditorPlugin } from '../../../loom-editor-CQ_GI4IA.cjs';
|
|
2
|
+
import { VexPluginConfig } from '../index.cjs';
|
|
3
|
+
export { VexRunResult } from '../index.cjs';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '@niscorp/nova';
|
|
7
|
+
import '@niscorp/nova/adapters/react';
|
|
8
|
+
import '../../../types-BonjN3CB.cjs';
|
|
9
|
+
import '@niscorp/vex';
|
|
10
|
+
|
|
11
|
+
declare const vex: (config: VexPluginConfig) => LoomEditorPlugin;
|
|
12
|
+
|
|
13
|
+
export { VexPluginConfig, vex };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { L as LoomEditorPlugin } from '../../../loom-editor-D5SBQ4_F.js';
|
|
2
|
+
import { VexPluginConfig } from '../index.js';
|
|
3
|
+
export { VexRunResult } from '../index.js';
|
|
4
|
+
import 'react';
|
|
5
|
+
import 'zod';
|
|
6
|
+
import '@niscorp/nova';
|
|
7
|
+
import '@niscorp/nova/adapters/react';
|
|
8
|
+
import '../../../types-BonjN3CB.js';
|
|
9
|
+
import '@niscorp/vex';
|
|
10
|
+
|
|
11
|
+
declare const vex: (config: VexPluginConfig) => LoomEditorPlugin;
|
|
12
|
+
|
|
13
|
+
export { VexPluginConfig, vex };
|
|
@@ -0,0 +1,296 @@
|
|
|
1
|
+
import { useLoomDocument } from '../../../chunk-LWY5TG7M.js';
|
|
2
|
+
import '../../../chunk-PTXRAWJX.js';
|
|
3
|
+
import { vexPlugin, PREVIEW, catalogOf, VEX_COMPARISON, VEX_FIELD_PATH, VEX_AGGREGATE, VEX_COMPUTE } from '../../../chunk-XTY7XO5C.js';
|
|
4
|
+
import { useModelWrite, JsonEditor } from '../../../chunk-MIRMQPUE.js';
|
|
5
|
+
import { isRecord } from '../../../chunk-TV4U22MY.js';
|
|
6
|
+
import '../../../chunk-D743DI5J.js';
|
|
7
|
+
import { useState, useRef, useEffect } from 'react';
|
|
8
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
9
|
+
import { getPath } from '@niscorp/nova';
|
|
10
|
+
|
|
11
|
+
var makePreview = (run) => {
|
|
12
|
+
const Preview = ({ query }) => {
|
|
13
|
+
const [state, setState] = useState({ status: "empty" });
|
|
14
|
+
const seq = useRef(0);
|
|
15
|
+
const key = query == null ? "" : JSON.stringify(query);
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
if (query == null) {
|
|
18
|
+
setState({ status: "empty" });
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
const mine = ++seq.current;
|
|
22
|
+
setState({ status: "running" });
|
|
23
|
+
const handle = setTimeout(() => {
|
|
24
|
+
run(query).then((result) => {
|
|
25
|
+
if (mine === seq.current) setState({ status: "ok", result });
|
|
26
|
+
}).catch((err) => {
|
|
27
|
+
if (mine === seq.current) {
|
|
28
|
+
setState({ status: "error", message: err instanceof Error ? err.message : String(err) });
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}, 250);
|
|
32
|
+
return () => clearTimeout(handle);
|
|
33
|
+
}, [key]);
|
|
34
|
+
return /* @__PURE__ */ jsx(PreviewView, { state });
|
|
35
|
+
};
|
|
36
|
+
return Preview;
|
|
37
|
+
};
|
|
38
|
+
var PreviewView = ({ state }) => {
|
|
39
|
+
if (state.status === "empty") return /* @__PURE__ */ jsx(Note, { children: "Edit the query to preview its results." });
|
|
40
|
+
if (state.status === "running") return /* @__PURE__ */ jsx(Note, { children: "Running\u2026" });
|
|
41
|
+
if (state.status === "error") return /* @__PURE__ */ jsx(Banner, { tone: "error", lines: [state.message] });
|
|
42
|
+
const { rows, warnings, errors } = state.result;
|
|
43
|
+
if (errors !== void 0 && errors.length > 0) return /* @__PURE__ */ jsx(Banner, { tone: "error", lines: errors });
|
|
44
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 10 }, children: [
|
|
45
|
+
warnings !== void 0 && warnings.length > 0 ? /* @__PURE__ */ jsx(Banner, { tone: "warn", lines: warnings }) : null,
|
|
46
|
+
/* @__PURE__ */ jsx(RowsTable, { rows })
|
|
47
|
+
] });
|
|
48
|
+
};
|
|
49
|
+
var mono = "ui-monospace, SFMono-Regular, Menlo, monospace";
|
|
50
|
+
var Note = ({ children }) => /* @__PURE__ */ jsx("div", { style: { fontSize: 13, color: "#6b7280", padding: 12 }, children });
|
|
51
|
+
var TONES = {
|
|
52
|
+
error: { fg: "#991b1b", bg: "#fef2f2", border: "#fecaca" },
|
|
53
|
+
warn: { fg: "#92400e", bg: "#fffbeb", border: "#fde68a" }
|
|
54
|
+
};
|
|
55
|
+
var Banner = ({ tone, lines }) => {
|
|
56
|
+
const c = TONES[tone];
|
|
57
|
+
return /* @__PURE__ */ jsx("pre", { style: { margin: 0, padding: 12, background: c.bg, color: c.fg, border: `1px solid ${c.border}`, borderRadius: 6, fontSize: 12, fontFamily: mono, whiteSpace: "pre-wrap", wordBreak: "break-word" }, children: lines.join("\n") });
|
|
58
|
+
};
|
|
59
|
+
var th = { textAlign: "left", padding: "6px 10px", background: "#f9fafb", borderBottom: "1px solid #e5e7eb", color: "#6b7280", fontWeight: 600, whiteSpace: "nowrap" };
|
|
60
|
+
var td = { padding: "6px 10px", borderBottom: "1px solid #f1f5f9", fontFamily: mono, whiteSpace: "nowrap" };
|
|
61
|
+
var cell = (value) => value === null ? "\u2205" : typeof value === "object" ? JSON.stringify(value) : String(value);
|
|
62
|
+
var RowsTable = ({ rows }) => {
|
|
63
|
+
if (rows.length === 0) return /* @__PURE__ */ jsx(Note, { children: "No rows." });
|
|
64
|
+
const first = rows[0];
|
|
65
|
+
if (first === null || typeof first !== "object") {
|
|
66
|
+
return /* @__PURE__ */ jsx(Banner, { tone: "warn", lines: [JSON.stringify(rows, null, 2)] });
|
|
67
|
+
}
|
|
68
|
+
const cols = Object.keys(first);
|
|
69
|
+
return /* @__PURE__ */ jsx("div", { style: { overflow: "auto", border: "1px solid #e5e7eb", borderRadius: 6 }, children: /* @__PURE__ */ jsxs("table", { style: { borderCollapse: "collapse", width: "100%", fontSize: 12 }, children: [
|
|
70
|
+
/* @__PURE__ */ jsx("thead", { children: /* @__PURE__ */ jsx("tr", { children: cols.map((c) => /* @__PURE__ */ jsx("th", { style: th, children: c }, c)) }) }),
|
|
71
|
+
/* @__PURE__ */ jsx("tbody", { children: rows.map((row, i) => /* @__PURE__ */ jsx("tr", { children: cols.map((c) => /* @__PURE__ */ jsx("td", { style: td, children: cell(row[c]) }, c)) }, i)) })
|
|
72
|
+
] }) });
|
|
73
|
+
};
|
|
74
|
+
var useScopedColumns = (catalog) => {
|
|
75
|
+
const document = useLoomDocument();
|
|
76
|
+
const from = document === void 0 ? void 0 : getPath(document, "query.from");
|
|
77
|
+
const entities = Array.isArray(from) ? from.filter((source) => typeof source === "string") : [];
|
|
78
|
+
if (entities.length === 0) return catalog.columns;
|
|
79
|
+
const allowed = new Set(entities);
|
|
80
|
+
const scoped = catalog.columns.filter((column) => allowed.has(column.slice(0, column.indexOf("."))));
|
|
81
|
+
return scoped.length > 0 ? scoped : catalog.columns;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
// src/plugins/vex/react/styles.ts
|
|
85
|
+
var fieldStyle = { padding: "6px 10px", border: "1px solid #d1d5db", borderRadius: 6, fontSize: 14, boxSizing: "border-box" };
|
|
86
|
+
var controlBtn = { padding: "6px 10px", border: "1px solid #d1d5db", borderRadius: 6, background: "#f3f4f6", cursor: "pointer", fontSize: 13 };
|
|
87
|
+
var comboListStyle = { position: "absolute", top: "100%", left: 0, right: 0, zIndex: 20, marginTop: 2, maxHeight: 200, overflowY: "auto", background: "#fff", border: "1px solid #d1d5db", borderRadius: 6, boxShadow: "0 6px 16px rgba(0,0,0,0.12)" };
|
|
88
|
+
var comboItemStyle = { padding: "6px 10px", fontSize: 13, cursor: "pointer", fontFamily: "ui-monospace, Menlo, monospace" };
|
|
89
|
+
var Combo = ({ value, placeholder, options, onPick, style }) => {
|
|
90
|
+
const [open, setOpen] = useState(false);
|
|
91
|
+
const needle = value.toLowerCase();
|
|
92
|
+
const matches = options.filter((option) => option.toLowerCase().includes(needle));
|
|
93
|
+
return /* @__PURE__ */ jsxs("div", { style: { position: "relative", ...style }, children: [
|
|
94
|
+
/* @__PURE__ */ jsx(
|
|
95
|
+
"input",
|
|
96
|
+
{
|
|
97
|
+
value,
|
|
98
|
+
placeholder,
|
|
99
|
+
onChange: (event) => onPick(event.target.value),
|
|
100
|
+
onFocus: () => setOpen(true),
|
|
101
|
+
onBlur: () => window.setTimeout(() => setOpen(false), 120),
|
|
102
|
+
style: { ...fieldStyle, width: "100%" }
|
|
103
|
+
}
|
|
104
|
+
),
|
|
105
|
+
open && matches.length > 0 ? /* @__PURE__ */ jsx("div", { style: comboListStyle, children: matches.slice(0, 50).map((option) => /* @__PURE__ */ jsx(
|
|
106
|
+
"div",
|
|
107
|
+
{
|
|
108
|
+
onMouseDown: (event) => {
|
|
109
|
+
event.preventDefault();
|
|
110
|
+
onPick(option);
|
|
111
|
+
setOpen(false);
|
|
112
|
+
},
|
|
113
|
+
style: comboItemStyle,
|
|
114
|
+
children: option
|
|
115
|
+
},
|
|
116
|
+
option
|
|
117
|
+
)) }) : null
|
|
118
|
+
] });
|
|
119
|
+
};
|
|
120
|
+
var FieldPath = ({ value, catalog, model }) => {
|
|
121
|
+
const set = useModelWrite(model);
|
|
122
|
+
const columns = useScopedColumns(catalog);
|
|
123
|
+
return /* @__PURE__ */ jsx(Combo, { value: String(value ?? ""), placeholder: "entity.field", options: columns, onPick: set, style: { width: "100%" } });
|
|
124
|
+
};
|
|
125
|
+
var Operand = ({ type, value, onChange }) => {
|
|
126
|
+
const style = { ...fieldStyle, flex: 1, minWidth: 0 };
|
|
127
|
+
if (type === "number") {
|
|
128
|
+
return /* @__PURE__ */ jsx(
|
|
129
|
+
"input",
|
|
130
|
+
{
|
|
131
|
+
type: "number",
|
|
132
|
+
value: typeof value === "number" ? value : "",
|
|
133
|
+
placeholder: "value",
|
|
134
|
+
onChange: (event) => onChange(event.target.value === "" ? null : Number(event.target.value)),
|
|
135
|
+
style
|
|
136
|
+
}
|
|
137
|
+
);
|
|
138
|
+
}
|
|
139
|
+
if (type === "boolean") {
|
|
140
|
+
return /* @__PURE__ */ jsxs(
|
|
141
|
+
"select",
|
|
142
|
+
{
|
|
143
|
+
value: value === true ? "true" : value === false ? "false" : "",
|
|
144
|
+
onChange: (event) => onChange(event.target.value === "" ? null : event.target.value === "true"),
|
|
145
|
+
style,
|
|
146
|
+
children: [
|
|
147
|
+
/* @__PURE__ */ jsx("option", { value: "", children: "\u2014" }),
|
|
148
|
+
/* @__PURE__ */ jsx("option", { value: "true", children: "true" }),
|
|
149
|
+
/* @__PURE__ */ jsx("option", { value: "false", children: "false" })
|
|
150
|
+
]
|
|
151
|
+
}
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
return /* @__PURE__ */ jsx(
|
|
155
|
+
"input",
|
|
156
|
+
{
|
|
157
|
+
value: value === null || value === void 0 ? "" : String(value),
|
|
158
|
+
placeholder: "value",
|
|
159
|
+
onChange: (event) => onChange(event.target.value),
|
|
160
|
+
style
|
|
161
|
+
}
|
|
162
|
+
);
|
|
163
|
+
};
|
|
164
|
+
var Comparison = ({ value, catalog, model }) => {
|
|
165
|
+
const set = useModelWrite(model);
|
|
166
|
+
const columns = useScopedColumns(catalog);
|
|
167
|
+
const tuple = Array.isArray(value) ? value : [];
|
|
168
|
+
const left = tuple[0];
|
|
169
|
+
const right = tuple[1];
|
|
170
|
+
const type = typeof left === "string" ? catalog.typeOf(left) : void 0;
|
|
171
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
|
|
172
|
+
/* @__PURE__ */ jsx(
|
|
173
|
+
Combo,
|
|
174
|
+
{
|
|
175
|
+
value: String(left ?? ""),
|
|
176
|
+
placeholder: "entity.field",
|
|
177
|
+
options: columns,
|
|
178
|
+
onPick: (next) => set([next, right ?? null]),
|
|
179
|
+
style: { flex: 2, minWidth: 0 }
|
|
180
|
+
}
|
|
181
|
+
),
|
|
182
|
+
/* @__PURE__ */ jsx(Operand, { type, value: right, onChange: (next) => set([left ?? "", next]) })
|
|
183
|
+
] });
|
|
184
|
+
};
|
|
185
|
+
var fieldPathWidget = (catalog) => ({ value, novaModel }) => /* @__PURE__ */ jsx(FieldPath, { value, catalog, model: novaModel });
|
|
186
|
+
var comparisonWidget = (catalog) => ({ value, novaModel }) => /* @__PURE__ */ jsx(Comparison, { value, catalog, model: novaModel });
|
|
187
|
+
var RecordRows = ({ value, model, newEntry, renderValue }) => {
|
|
188
|
+
const set = useModelWrite(model);
|
|
189
|
+
const entries = isRecord(value) ? Object.entries(value) : [];
|
|
190
|
+
const write = (next) => set(Object.fromEntries(next));
|
|
191
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 6, padding: 12, border: "1px dashed #d1d5db", borderRadius: 6 }, children: [
|
|
192
|
+
entries.map(([key, val], index) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, alignItems: "flex-start" }, children: [
|
|
193
|
+
/* @__PURE__ */ jsx(
|
|
194
|
+
"input",
|
|
195
|
+
{
|
|
196
|
+
value: key,
|
|
197
|
+
placeholder: "alias",
|
|
198
|
+
onChange: (event) => write(entries.map((entry, i) => i === index ? [event.target.value, entry[1]] : entry)),
|
|
199
|
+
style: { ...fieldStyle, width: 110 }
|
|
200
|
+
}
|
|
201
|
+
),
|
|
202
|
+
/* @__PURE__ */ jsx("div", { style: { flex: 1, minWidth: 0 }, children: renderValue(val, (next) => write(entries.map((entry, i) => i === index ? [entry[0], next] : entry))) }),
|
|
203
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => write(entries.filter((_, i) => i !== index)), style: controlBtn, children: "\u2715" })
|
|
204
|
+
] }, index)),
|
|
205
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => write([...entries, [`field_${entries.length + 1}`, newEntry]]), style: { ...controlBtn, alignSelf: "flex-start" }, children: "Add" })
|
|
206
|
+
] });
|
|
207
|
+
};
|
|
208
|
+
var coerceLiteral = (text) => {
|
|
209
|
+
if (text === "") return "";
|
|
210
|
+
if (text === "true") return true;
|
|
211
|
+
if (text === "false") return false;
|
|
212
|
+
const n = Number(text);
|
|
213
|
+
return text.trim() !== "" && Number.isFinite(n) ? n : text;
|
|
214
|
+
};
|
|
215
|
+
var ValueInput = ({ value, columns, onChange }) => /* @__PURE__ */ jsx(
|
|
216
|
+
Combo,
|
|
217
|
+
{
|
|
218
|
+
value: value === null || value === void 0 ? "" : String(value),
|
|
219
|
+
placeholder: "field or value",
|
|
220
|
+
options: columns,
|
|
221
|
+
onPick: (text) => onChange(coerceLiteral(text)),
|
|
222
|
+
style: { flex: 1, minWidth: 120 }
|
|
223
|
+
}
|
|
224
|
+
);
|
|
225
|
+
var AGG_OPS = ["count", "sum", "avg", "min", "max"];
|
|
226
|
+
var AggregateValue = ({ value, onChange, catalog }) => {
|
|
227
|
+
const columns = useScopedColumns(catalog);
|
|
228
|
+
const record = isRecord(value) ? value : {};
|
|
229
|
+
const op = AGG_OPS.find((candidate) => candidate in record) ?? "count";
|
|
230
|
+
const operand = typeof record[op] === "string" ? record[op] : "";
|
|
231
|
+
const options = op === "count" ? ["*", ...columns] : columns;
|
|
232
|
+
const switchOp = (next) => {
|
|
233
|
+
let carried = operand;
|
|
234
|
+
if (next === "count" && carried === "") carried = "*";
|
|
235
|
+
if (next !== "count" && carried === "*") carried = "";
|
|
236
|
+
onChange({ [next]: carried });
|
|
237
|
+
};
|
|
238
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, alignItems: "center" }, children: [
|
|
239
|
+
/* @__PURE__ */ jsx("select", { value: op, onChange: (event) => switchOp(event.target.value), style: { ...fieldStyle, width: 90 }, children: AGG_OPS.map((candidate) => /* @__PURE__ */ jsx("option", { value: candidate, children: candidate }, candidate)) }),
|
|
240
|
+
/* @__PURE__ */ jsx(Combo, { value: operand, placeholder: "entity.field", options, onPick: (next) => onChange({ [op]: next }), style: { flex: 1, minWidth: 0 } })
|
|
241
|
+
] });
|
|
242
|
+
};
|
|
243
|
+
var ARITHMETIC = /* @__PURE__ */ new Set(["add", "subtract", "multiply", "divide"]);
|
|
244
|
+
var LISTS = /* @__PURE__ */ new Set(["concat", "coalesce"]);
|
|
245
|
+
var COMPUTE_OPS = ["add", "subtract", "multiply", "divide", "concat", "coalesce", "case"];
|
|
246
|
+
var ComputeValue = ({ value, onChange, catalog }) => {
|
|
247
|
+
const columns = useScopedColumns(catalog);
|
|
248
|
+
const record = isRecord(value) ? value : {};
|
|
249
|
+
const op = COMPUTE_OPS.find((candidate) => candidate in record) ?? "add";
|
|
250
|
+
const operands = Array.isArray(record[op]) ? record[op] : [];
|
|
251
|
+
const switchOp = (next) => {
|
|
252
|
+
if (next === "case") {
|
|
253
|
+
onChange({ case: { when: [{ condition: { eq: ["", ""] }, then: "" }], else: "" } });
|
|
254
|
+
} else if (ARITHMETIC.has(next)) {
|
|
255
|
+
onChange({ [next]: [operands[0] ?? "", operands[1] ?? ""] });
|
|
256
|
+
} else {
|
|
257
|
+
onChange({ [next]: operands.length >= 2 ? operands : ["", ""] });
|
|
258
|
+
}
|
|
259
|
+
};
|
|
260
|
+
return /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 6, alignItems: "flex-start", flexWrap: "wrap" }, children: [
|
|
261
|
+
/* @__PURE__ */ jsx("select", { value: op, onChange: (event) => switchOp(event.target.value), style: { ...fieldStyle, width: 90 }, children: COMPUTE_OPS.map((candidate) => /* @__PURE__ */ jsx("option", { value: candidate, children: candidate }, candidate)) }),
|
|
262
|
+
ARITHMETIC.has(op) ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
263
|
+
/* @__PURE__ */ jsx(ValueInput, { value: operands[0], columns, onChange: (next) => onChange({ [op]: [next, operands[1] ?? ""] }) }),
|
|
264
|
+
/* @__PURE__ */ jsx(ValueInput, { value: operands[1], columns, onChange: (next) => onChange({ [op]: [operands[0] ?? "", next] }) })
|
|
265
|
+
] }) : null,
|
|
266
|
+
LISTS.has(op) ? /* @__PURE__ */ jsx(OperandList, { values: operands, columns, onChange: (list) => onChange({ [op]: list }) }) : null,
|
|
267
|
+
op === "case" ? /* @__PURE__ */ jsx("div", { style: { flex: 1, minWidth: 200 }, children: /* @__PURE__ */ jsx(JsonEditor, { value: record.case, onChange: (next) => onChange({ case: next }) }) }) : null
|
|
268
|
+
] });
|
|
269
|
+
};
|
|
270
|
+
var OperandList = ({ values, columns, onChange }) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "column", gap: 4, flex: 1, minWidth: 160 }, children: [
|
|
271
|
+
values.map((operand, index) => /* @__PURE__ */ jsxs("div", { style: { display: "flex", gap: 4 }, children: [
|
|
272
|
+
/* @__PURE__ */ jsx(ValueInput, { value: operand, columns, onChange: (next) => onChange(values.map((current, i) => i === index ? next : current)) }),
|
|
273
|
+
/* @__PURE__ */ jsx("button", { type: "button", disabled: values.length <= 2, onClick: () => onChange(values.filter((_, i) => i !== index)), style: controlBtn, children: "\u2715" })
|
|
274
|
+
] }, index)),
|
|
275
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: () => onChange([...values, ""]), style: { ...controlBtn, alignSelf: "flex-start" }, children: "+" })
|
|
276
|
+
] });
|
|
277
|
+
var aggregateWidget = (catalog) => ({ value, novaModel }) => /* @__PURE__ */ jsx(RecordRows, { value, model: novaModel, newEntry: { count: "*" }, renderValue: (v, onChange) => /* @__PURE__ */ jsx(AggregateValue, { value: v, onChange, catalog }) });
|
|
278
|
+
var computeWidget = (catalog) => ({ value, novaModel }) => /* @__PURE__ */ jsx(RecordRows, { value, model: novaModel, newEntry: { add: ["", ""] }, renderValue: (v, onChange) => /* @__PURE__ */ jsx(ComputeValue, { value: v, onChange, catalog }) });
|
|
279
|
+
|
|
280
|
+
// src/plugins/vex/react/index.ts
|
|
281
|
+
var vex = (config) => {
|
|
282
|
+
const { name, documents, mount, widgets } = vexPlugin(config);
|
|
283
|
+
const components = { [PREVIEW]: makePreview(config.run) };
|
|
284
|
+
if (config.db !== void 0) {
|
|
285
|
+
const catalog = catalogOf(config.db);
|
|
286
|
+
components[VEX_COMPARISON] = comparisonWidget(catalog);
|
|
287
|
+
components[VEX_FIELD_PATH] = fieldPathWidget(catalog);
|
|
288
|
+
components[VEX_AGGREGATE] = aggregateWidget(catalog);
|
|
289
|
+
components[VEX_COMPUTE] = computeWidget(catalog);
|
|
290
|
+
}
|
|
291
|
+
return { name, documents, mount, widgets, components };
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
export { vex };
|
|
295
|
+
//# sourceMappingURL=index.js.map
|
|
296
|
+
//# sourceMappingURL=index.js.map
|