@petrarca/sonnet-schema-designer 0.4.2
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/dist/index.d.ts +531 -0
- package/dist/index.js +2826 -0
- package/dist/index.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/model/paths.ts","../src/model/view.ts","../src/model/mutate.ts","../src/model/compatibleWidgets.ts","../src/model/embed.ts","../src/hooks/useDesignerState.ts","../src/capabilities.ts","../src/model/scoping.ts","../src/SchemaDesigner.tsx","../src/FormSettingsSheet.tsx","../src/inspector/layoutMetaSchemas.ts","../src/tree/PropertyTree.tsx","../src/preview/PreviewPane.tsx","../src/preview/TablePreview.tsx","../src/preview/sampleRows.ts","../src/designers/FormLayoutDesigner.tsx","../src/preview/CapabilitiesPanel.tsx","../src/inspector/Inspector.tsx","../src/inspector/DataTab.tsx","../src/inspector/metaSchemas.ts","../src/inspector/UITab.tsx","../src/inspector/EnumEditor.tsx","../src/inspector/TableHintsTab.tsx"],"sourcesContent":["/**\n * Path navigation over a JsonSchema tree.\n *\n * A property path is an array of property keys from the root down to a\n * property, e.g. [\"address\", \"city\"]. Object children nest through\n * `properties`; array children nest through `items.properties`. The path names\n * the property and the navigator descends through `items` transparently, so an\n * array-of-objects and its item object share one editing surface.\n */\n\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n} from \"@petrarca/sonnet-core/schema\";\n\nexport type PropertyPath = string[];\n\n/** Serialize a path for use as a stable React key or selection id. */\nexport function pathKey(path: PropertyPath): string {\n return path.join(\".\");\n}\n\n/** Whether two paths refer to the same property. */\nexport function samePath(\n a: PropertyPath | null,\n b: PropertyPath | null,\n): boolean {\n if (a === null || b === null) return a === b;\n return a.length === b.length && a.every((seg, i) => seg === b[i]);\n}\n\n/** The container that holds a property's children, or undefined for scalars. */\nexport function childContainer(\n prop: JsonSchemaProperty,\n): Record<string, JsonSchemaProperty> | undefined {\n if (prop.type === \"object\" && prop.properties) return prop.properties;\n if (prop.type === \"array\" && prop.items?.type === \"object\") {\n return prop.items.properties;\n }\n return undefined;\n}\n\n/** Resolve a path to its property definition, or undefined if not found. */\nexport function getProperty(\n schema: JsonSchema,\n path: PropertyPath,\n): JsonSchemaProperty | undefined {\n if (path.length === 0) return undefined;\n let container: Record<string, JsonSchemaProperty> | undefined =\n schema.properties;\n let prop: JsonSchemaProperty | undefined;\n for (const seg of path) {\n if (!container) return undefined;\n prop = container[seg];\n if (!prop) return undefined;\n container = childContainer(prop);\n }\n return prop;\n}\n\n/** Whether a property has (or can have) child properties. */\nexport function isContainer(prop: JsonSchemaProperty): boolean {\n return childContainer(prop) !== undefined;\n}\n\n/** The child properties of a property, or an empty map for scalars. */\nexport function childrenOf(\n prop: JsonSchemaProperty,\n): Record<string, JsonSchemaProperty> {\n return childContainer(prop) ?? {};\n}\n","/**\n * Read-shaping: turn a JsonSchema into a property tree for the designer UI.\n *\n * Pure, no React. Ordering follows the renderer's rule: an explicit x-ui-order\n * first, then remaining keys in declaration order.\n */\n\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n} from \"@petrarca/sonnet-core/schema\";\nimport { childrenOf, isContainer, type PropertyPath } from \"./paths\";\n\nexport type PropertyKind = \"scalar\" | \"enum\" | \"object\" | \"array\";\n\nexport interface PropertyNode {\n path: PropertyPath;\n key: string;\n property: JsonSchemaProperty;\n kind: PropertyKind;\n required: boolean;\n /** Short type descriptor for the tree row, e.g. \"string\", \"object[]\". */\n typeLabel: string;\n /** Resolved widget override (x-ui-widget) if any. */\n widget?: string;\n children: PropertyNode[];\n}\n\n/** Classify a property into a tree kind. */\nexport function propertyKind(prop: JsonSchemaProperty): PropertyKind {\n if (prop.type === \"object\" && prop.properties) return \"object\";\n if (prop.type === \"array\") return \"array\";\n if (Array.isArray(prop.enum) && prop.enum.length > 0) return \"enum\";\n return \"scalar\";\n}\n\n// Cardinality inside the brackets, standard multiplicity notation:\n// [] -- unconstrained\n// [3] -- exactly 3 (min == max)\n// [1..5] -- between 1 and 5\n// [1..] -- at least 1\n// [..5] -- at most 5\nfunction arrayCardinality(\n min: number | undefined,\n max: number | undefined,\n): string {\n if (min == null && max == null) return \"\";\n if (min != null && min === max) return `${min}`;\n return `${min ?? \"\"}..${max ?? \"\"}`;\n}\n\nfunction typeLabelOf(prop: JsonSchemaProperty): string {\n if (prop.type === \"array\") {\n const itemType = prop.items?.type ?? \"any\";\n // Compact array indicator (e.g. \"object[]\", \"object[1..5]\") so the type\n // descriptor stays short and does not crowd out the property name.\n return `${itemType}[${arrayCardinality(prop.minItems, prop.maxItems)}]`;\n }\n return prop.type ?? \"any\";\n}\n\n/** Order keys by explicit x-ui-order, then remaining declaration order. */\nexport function orderedKeys(\n properties: Record<string, JsonSchemaProperty>,\n order: string[] | undefined,\n): string[] {\n const keys = Object.keys(properties);\n if (!order || order.length === 0) return keys;\n const inOrder = order.filter((k) => k in properties);\n const rest = keys.filter((k) => !inOrder.includes(k));\n return [...inOrder, ...rest];\n}\n\nfunction buildNode(\n key: string,\n prop: JsonSchemaProperty,\n parentPath: PropertyPath,\n requiredKeys: string[] | undefined,\n): PropertyNode {\n const path = [...parentPath, key];\n const widget =\n typeof prop[\"x-ui-widget\"] === \"string\" ? prop[\"x-ui-widget\"] : undefined;\n const node: PropertyNode = {\n path,\n key,\n property: prop,\n kind: propertyKind(prop),\n required: !!requiredKeys?.includes(key),\n typeLabel: typeLabelOf(prop),\n widget,\n children: [],\n };\n if (isContainer(prop)) {\n const kids = childrenOf(prop);\n const childRequired =\n prop.type === \"object\" ? prop.required : prop.items?.required;\n const childOrder =\n prop.type === \"object\" ? prop[\"x-ui-order\"] : prop.items?.[\"x-ui-order\"];\n node.children = orderedKeys(kids, childOrder).map((k) =>\n buildNode(k, kids[k], path, childRequired),\n );\n }\n return node;\n}\n\n/** Build the full property tree for a schema. */\nexport function buildPropertyTree(schema: JsonSchema): PropertyNode[] {\n return orderedKeys(schema.properties, schema[\"x-ui-order\"]).map((key) =>\n buildNode(key, schema.properties[key], [], schema.required),\n );\n}\n\n/**\n * A layout scope: a container whose fields can be arranged into rows. Root is\n * the form itself (path []); nested scopes are object/array containers.\n */\nexport interface LayoutScope {\n /** Empty for root, otherwise the property path to the container. */\n path: string[];\n /** Human label, e.g. \"Form (root)\" or \"contact\" or \"addresses (items)\". */\n label: string;\n}\n\n/** Enumerate all layout scopes: the root form plus every object/array container. */\nexport function layoutScopes(schema: JsonSchema): LayoutScope[] {\n const scopes: LayoutScope[] = [{ path: [], label: \"Form (root)\" }];\n const walk = (nodes: PropertyNode[]) => {\n for (const node of nodes) {\n if (node.kind === \"object\" || node.kind === \"array\") {\n const suffix = node.kind === \"array\" ? \" (items)\" : \"\";\n scopes.push({\n path: node.path,\n label: node.path.join(\" \\u203a \") + suffix,\n });\n walk(node.children);\n }\n }\n };\n walk(buildPropertyTree(schema));\n return scopes;\n}\n","/**\n * Pure edit operations over { schema, uiSchema }.\n *\n * Every function returns a new pair; nothing mutates in place. Operations keep\n * the schema and uiSchema consistent -- renaming a property rewrites the property\n * key, the uiSchema entry, the required entry, and any x-ui-order reference at\n * the same level. Mirrors the graph-model/mutate.ts discipline.\n */\n\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n UISchema,\n UILayoutConfig,\n UISchemaOptions,\n} from \"@petrarca/sonnet-core/schema\";\nimport { childContainer, getProperty, type PropertyPath } from \"./paths\";\n\nexport type UiSchemaMap = Record<string, UISchema>;\n\nexport interface DesignerModel {\n schema: JsonSchema;\n uiSchema: UiSchemaMap;\n}\n\n// Deep clone via structuredClone (available in the runtime targets).\nfunction clone<T>(v: T): T {\n return structuredClone(v);\n}\n\n/** A default property for a newly created property of a given kind. */\nexport function newProperty(\n kind: \"scalar\" | \"object\" | \"array\",\n): JsonSchemaProperty {\n switch (kind) {\n case \"object\":\n return { type: \"object\", properties: {} };\n case \"array\":\n return { type: \"array\", items: { type: \"object\", properties: {} } };\n default:\n return { type: \"string\" };\n }\n}\n\n// Resolve the properties container + order-owner for a parent path. Root when\n// path is empty. Returns the mutable container inside a cloned schema.\nfunction resolveContainer(\n schema: JsonSchema,\n parentPath: PropertyPath,\n): {\n properties: Record<string, JsonSchemaProperty>;\n getOrder: () => string[] | undefined;\n setOrder: (order: string[] | undefined) => void;\n getRequired: () => string[] | undefined;\n setRequired: (req: string[] | undefined) => void;\n} | null {\n if (parentPath.length === 0) {\n return {\n properties: schema.properties,\n getOrder: () => schema[\"x-ui-order\"],\n setOrder: (o) => {\n if (o) schema[\"x-ui-order\"] = o;\n else delete schema[\"x-ui-order\"];\n },\n getRequired: () => schema.required,\n setRequired: (r) => {\n if (r && r.length) schema.required = r;\n else delete schema.required;\n },\n };\n }\n const owner = getProperty(schema, parentPath);\n if (!owner) return null;\n const properties = childContainer(owner);\n if (!properties) return null;\n // For arrays, order/required live on items; for objects, on the property.\n const target = owner.type === \"array\" ? owner.items! : owner;\n return {\n properties,\n getOrder: () => target[\"x-ui-order\"],\n setOrder: (o) => {\n if (o) target[\"x-ui-order\"] = o;\n else delete target[\"x-ui-order\"];\n },\n getRequired: () => target.required,\n setRequired: (r) => {\n if (r && r.length) target.required = r;\n else delete target.required;\n },\n };\n}\n\n// Unique key like \"property\", \"property_2\" within a container.\nfunction uniqueKey(\n base: string,\n properties: Record<string, JsonSchemaProperty>,\n): string {\n if (!(base in properties)) return base;\n let i = 2;\n while (`${base}_${i}` in properties) i++;\n return `${base}_${i}`;\n}\n\n/** Add a property under a parent path (root when empty). Returns the new model. */\nexport function addProperty(\n model: DesignerModel,\n parentPath: PropertyPath,\n kind: \"scalar\" | \"object\" | \"array\",\n): { model: DesignerModel; path: PropertyPath } {\n const schema = clone(model.schema);\n const container = resolveContainer(schema, parentPath);\n if (!container) return { model, path: parentPath };\n const key = uniqueKey(\"property\", container.properties);\n container.properties[key] = newProperty(kind);\n const order = container.getOrder();\n if (order) container.setOrder([...order, key]);\n return {\n model: { schema, uiSchema: model.uiSchema },\n path: [...parentPath, key],\n };\n}\n\n/** Delete the property at path. Returns the new model. */\nexport function deleteProperty(\n model: DesignerModel,\n path: PropertyPath,\n): DesignerModel {\n if (path.length === 0) return model;\n const schema = clone(model.schema);\n const parentPath = path.slice(0, -1);\n const key = path[path.length - 1];\n const container = resolveContainer(schema, parentPath);\n if (!container || !(key in container.properties)) return model;\n delete container.properties[key];\n const order = container.getOrder();\n if (order) container.setOrder(order.filter((k) => k !== key));\n const required = container.getRequired();\n if (required) container.setRequired(required.filter((k) => k !== key));\n\n // Drop the uiSchema entry only for top-level properties (uiSchema is keyed by\n // top-level property name; nested UI lives under x-ui-fields, handled elsewhere).\n let uiSchema = model.uiSchema;\n if (parentPath.length === 0 && key in uiSchema) {\n uiSchema = { ...uiSchema };\n delete uiSchema[key];\n }\n return { schema, uiSchema };\n}\n\n// Rewrite one key to another within a properties map, preserving position.\nfunction renameKeyInPlace(\n properties: Record<string, JsonSchemaProperty>,\n prevKey: string,\n nextKey: string,\n): void {\n const rebuilt: Record<string, JsonSchemaProperty> = {};\n for (const [k, v] of Object.entries(properties)) {\n rebuilt[k === prevKey ? nextKey : k] = v;\n }\n for (const k of Object.keys(properties)) delete properties[k];\n Object.assign(properties, rebuilt);\n}\n\n// Move a top-level uiSchema entry to a new key (returns a new map if changed).\nfunction renameUiEntry(\n uiSchema: UiSchemaMap,\n parentPath: PropertyPath,\n prevKey: string,\n nextKey: string,\n): UiSchemaMap {\n if (parentPath.length !== 0 || !(prevKey in uiSchema)) return uiSchema;\n const next = { ...uiSchema };\n next[nextKey] = next[prevKey];\n delete next[prevKey];\n return next;\n}\n\n/** Rename the property at path. Rewrites key, order, required, and uiSchema. */\nexport function renameProperty(\n model: DesignerModel,\n path: PropertyPath,\n nextKey: string,\n): { model: DesignerModel; path: PropertyPath } {\n if (path.length === 0) return { model, path };\n const parentPath = path.slice(0, -1);\n const prevKey = path[path.length - 1];\n if (nextKey === prevKey || !nextKey) return { model, path };\n\n const schema = clone(model.schema);\n const container = resolveContainer(schema, parentPath);\n if (!container || !(prevKey in container.properties)) return { model, path };\n if (nextKey in container.properties) return { model, path }; // collision: no-op\n\n renameKeyInPlace(container.properties, prevKey, nextKey);\n\n const rename = (k: string) => (k === prevKey ? nextKey : k);\n const order = container.getOrder();\n if (order) container.setOrder(order.map(rename));\n const required = container.getRequired();\n if (required) container.setRequired(required.map(rename));\n\n const uiSchema = renameUiEntry(model.uiSchema, parentPath, prevKey, nextKey);\n return {\n model: { schema, uiSchema },\n path: [...parentPath, nextKey],\n };\n}\n\n/** Move the property at path up (-1) or down (+1) among its siblings. */\nexport function moveProperty(\n model: DesignerModel,\n path: PropertyPath,\n direction: -1 | 1,\n): DesignerModel {\n if (path.length === 0) return model;\n const schema = clone(model.schema);\n const parentPath = path.slice(0, -1);\n const key = path[path.length - 1];\n const container = resolveContainer(schema, parentPath);\n if (!container) return model;\n\n const keys = Object.keys(container.properties);\n const order = container.getOrder() ?? keys;\n // Normalize order to include every key.\n const full = [...order.filter((k) => keys.includes(k))];\n for (const k of keys) if (!full.includes(k)) full.push(k);\n\n const idx = full.indexOf(key);\n const swap = idx + direction;\n if (idx < 0 || swap < 0 || swap >= full.length) return model;\n [full[idx], full[swap]] = [full[swap], full[idx]];\n container.setOrder(full);\n return { schema, uiSchema: model.uiSchema };\n}\n\n/** Toggle whether the property at path is required among its siblings. */\nexport function setRequired(\n model: DesignerModel,\n path: PropertyPath,\n required: boolean,\n): DesignerModel {\n if (path.length === 0) return model;\n const schema = clone(model.schema);\n const parentPath = path.slice(0, -1);\n const key = path[path.length - 1];\n const container = resolveContainer(schema, parentPath);\n if (!container) return model;\n const current = new Set(container.getRequired() ?? []);\n if (required) current.add(key);\n else current.delete(key);\n container.setRequired([...current]);\n return { schema, uiSchema: model.uiSchema };\n}\n\n/** Replace the property definition at path (merges the given partial). */\nexport function updateProperty(\n model: DesignerModel,\n path: PropertyPath,\n patch: Partial<JsonSchemaProperty>,\n): DesignerModel {\n if (path.length === 0) return model;\n const schema = clone(model.schema);\n const prop = getProperty(schema, path);\n if (!prop) return model;\n Object.assign(prop, patch);\n return { schema, uiSchema: model.uiSchema };\n}\n\n/**\n * Change the type of the property at path, reshaping structural keys: switching to\n * object adds an empty `properties`; to array adds `items`; leaving them strips\n * those keys. Type-specific validation keys that no longer apply are dropped.\n */\nexport function changePropertyType(\n model: DesignerModel,\n path: PropertyPath,\n nextType: JsonSchemaProperty[\"type\"],\n): DesignerModel {\n if (path.length === 0 || !nextType) return model;\n const schema = clone(model.schema);\n const prop = getProperty(schema, path);\n if (!prop || prop.type === nextType) return model;\n\n // Strip structural + type-specific validation keys from the previous type.\n delete prop.properties;\n delete prop.items;\n delete prop.enum;\n delete prop.minLength;\n delete prop.maxLength;\n delete prop.pattern;\n delete prop.format;\n delete prop.minimum;\n delete prop.maximum;\n delete prop.minItems;\n delete prop.maxItems;\n\n prop.type = nextType;\n if (nextType === \"object\") prop.properties = {};\n if (nextType === \"array\") prop.items = { type: \"string\" };\n return { schema, uiSchema: model.uiSchema };\n}\n\n/** One enum choice: a value and an optional display label. */\nexport interface EnumChoice {\n value: string;\n label?: string;\n}\n\n/**\n * Set the enum choices for the property at path. Values write to `property.enum`;\n * labels write to the property's `x-ui-options.enumNames` in the uiSchema (only\n * for top-level properties, where the uiSchema map is keyed). An empty list clears\n * both. Deduplicates and drops empty values.\n */\n// Normalize choices: trim, drop empties, dedupe by value (first wins).\nfunction normalizeChoices(choices: EnumChoice[]): EnumChoice[] {\n const seen = new Set<string>();\n const clean: EnumChoice[] = [];\n for (const c of choices) {\n const value = c.value.trim();\n if (!value || seen.has(value)) continue;\n seen.add(value);\n clean.push({ value, label: c.label?.trim() || undefined });\n }\n return clean;\n}\n\n// Update a UISchema entry's x-ui-options.enumNames from labelled choices,\n// returning the new entry (or undefined if empty).\nfunction withEnumNames(\n entry: UISchema | undefined,\n choices: EnumChoice[],\n): UISchema | undefined {\n const enumNames: Record<string, string> = {};\n for (const c of choices) if (c.label) enumNames[c.value] = c.label;\n\n const next: UISchema = { ...(entry ?? {}) };\n const options = {\n ...((next[\"x-ui-options\"] as Record<string, unknown>) ?? {}),\n };\n if (Object.keys(enumNames).length) options.enumNames = enumNames;\n else delete options.enumNames;\n if (Object.keys(options).length) next[\"x-ui-options\"] = options;\n else delete next[\"x-ui-options\"];\n\n return Object.keys(next).length ? next : undefined;\n}\n\nexport function setEnum(\n model: DesignerModel,\n path: PropertyPath,\n choices: EnumChoice[],\n): DesignerModel {\n if (path.length === 0) return model;\n const schema = clone(model.schema);\n const prop = getProperty(schema, path);\n if (!prop) return model;\n\n const clean = normalizeChoices(choices);\n if (clean.length === 0) delete prop.enum;\n else prop.enum = clean.map((c) => c.value);\n\n // enumNames lives in the property's uiSchema entry (at any nesting depth).\n const nextEntry = withEnumNames(\n getUiEntryAtPath(model.uiSchema, path),\n clean,\n );\n const uiSchema = setEntryIn(model.uiSchema, path, nextEntry);\n\n return { schema, uiSchema };\n}\n\n/** Read the current enum choices for a property + its uiSchema entry. */\nexport function readEnumChoices(\n prop: JsonSchemaProperty,\n uiEntry: UISchema | undefined,\n): EnumChoice[] {\n if (!Array.isArray(prop.enum)) return [];\n const enumNames =\n (uiEntry?.[\"x-ui-options\"] as { enumNames?: Record<string, string> })\n ?.enumNames ?? {};\n return prop.enum.map((v) => {\n const value = String(v);\n return { value, label: enumNames[value] };\n });\n}\n\n/** Table presentation hints for a property (embedded in the schema). */\nexport interface TableHints {\n cell?: string;\n cellOptions?: Record<string, unknown>;\n column?: NonNullable<JsonSchemaProperty[\"x-ui-column\"]>;\n}\n\n/**\n * Set (or clear) a property's table hints: x-ui-cell, x-ui-cell-options, and\n * x-ui-column. These live embedded on the property (EntityTable reads them\n * there). Empty values clear the corresponding key.\n */\nexport function setTableHints(\n model: DesignerModel,\n path: PropertyPath,\n hints: TableHints,\n): DesignerModel {\n if (path.length === 0) return model;\n const schema = clone(model.schema);\n const prop = getProperty(schema, path);\n if (!prop) return model;\n\n if (hints.cell) prop[\"x-ui-cell\"] = hints.cell;\n else delete prop[\"x-ui-cell\"];\n\n if (hints.cellOptions && Object.keys(hints.cellOptions).length > 0) {\n prop[\"x-ui-cell-options\"] = hints.cellOptions;\n } else {\n delete prop[\"x-ui-cell-options\"];\n }\n\n if (hints.column && Object.keys(hints.column).length > 0) {\n prop[\"x-ui-column\"] = hints.column;\n } else {\n delete prop[\"x-ui-column\"];\n }\n\n return { schema, uiSchema: model.uiSchema };\n}\n\n/** Read a property's current table hints. */\nexport function readTableHints(prop: JsonSchemaProperty): TableHints {\n return {\n cell: typeof prop[\"x-ui-cell\"] === \"string\" ? prop[\"x-ui-cell\"] : undefined,\n cellOptions: prop[\"x-ui-cell-options\"] as\n | Record<string, unknown>\n | undefined,\n column: prop[\"x-ui-column\"],\n };\n}\n\n/** Set (or clear) the top-level uiSchema entry for a property name. */\n// -- Path-aware uiSchema navigation --------------------------------------\n//\n// The uiSchema map is keyed by top-level property name. A nested property's\n// UISchema entry lives under its ancestor's `x-ui-fields` sub-map: the first\n// path segment indexes the top-level map, each subsequent segment indexes\n// through `x-ui-fields`. This mirrors how ObjectWidget/ArrayWidget read it.\n\ntype UiFieldsMap = Record<string, UISchema>;\n\n/** Read the UISchema entry for a property path, or undefined. */\nexport function getUiEntryAtPath(\n uiSchema: UiSchemaMap,\n path: PropertyPath,\n): UISchema | undefined {\n if (path.length === 0) return undefined;\n let entry: UISchema | undefined = uiSchema[path[0]];\n for (let i = 1; i < path.length && entry; i++) {\n const fields = entry[\"x-ui-fields\"] as UiFieldsMap | undefined;\n entry = fields?.[path[i]];\n }\n return entry;\n}\n\n// Recursively set `entry` at `path` within a fields map, pruning empties on the\n// way back up (empty entry -> removed; empty x-ui-fields -> removed).\nfunction setEntryIn(\n map: UiFieldsMap,\n path: PropertyPath,\n entry: UISchema | undefined,\n): UiFieldsMap {\n const [head, ...rest] = path;\n const next: UiFieldsMap = { ...map };\n\n if (rest.length === 0) {\n if (entry && Object.keys(entry).length > 0) next[head] = entry;\n else delete next[head];\n return next;\n }\n\n const current: UISchema = { ...(next[head] ?? {}) };\n const childFields = (current[\"x-ui-fields\"] as UiFieldsMap | undefined) ?? {};\n const updatedFields = setEntryIn(childFields, rest, entry);\n\n if (Object.keys(updatedFields).length > 0) {\n current[\"x-ui-fields\"] = updatedFields;\n } else {\n delete current[\"x-ui-fields\"];\n }\n\n if (Object.keys(current).length > 0) next[head] = current;\n else delete next[head];\n return next;\n}\n\n/** Set (or clear) the UISchema entry at a property path (any nesting depth). */\nexport function setUiEntry(\n model: DesignerModel,\n path: PropertyPath,\n entry: UISchema | undefined,\n): DesignerModel {\n if (path.length === 0) return model;\n const uiSchema = setEntryIn(model.uiSchema, path, entry);\n return { schema: model.schema, uiSchema };\n}\n\n/**\n * Set (or clear) the x-ui-layout of an object/array property at path. Object\n * layout lives on the property; array layout lives on `items`.\n */\nexport function setPropertyLayout(\n model: DesignerModel,\n path: PropertyPath,\n layout: UILayoutConfig | undefined,\n): DesignerModel {\n if (path.length === 0) return model;\n const schema = clone(model.schema);\n const prop = getProperty(schema, path);\n if (!prop) return model;\n const target = prop.type === \"array\" ? prop.items : prop;\n if (!target) return model;\n if (layout) target[\"x-ui-layout\"] = layout;\n else delete target[\"x-ui-layout\"];\n return { schema, uiSchema: model.uiSchema };\n}\n\n// The uiSchema map is keyed by property name (UISchema values) but also carries\n// special top-level keys (x-ui-layout, x-ui-globalOptions) whose values are not\n// UISchema. Read/write them through this looser view.\ntype RootUiSchema = UiSchemaMap & {\n \"x-ui-layout\"?: UILayoutConfig;\n \"x-ui-globalOptions\"?: UISchemaOptions;\n};\n\n/** Set (or clear) the root form layout (uiSchema[\"x-ui-layout\"]). */\nexport function setRootLayout(\n model: DesignerModel,\n layout: UILayoutConfig | undefined,\n): DesignerModel {\n const uiSchema = { ...model.uiSchema } as RootUiSchema;\n if (layout) uiSchema[\"x-ui-layout\"] = layout;\n else delete uiSchema[\"x-ui-layout\"];\n return { schema: model.schema, uiSchema };\n}\n\n/**\n * Set (or clear) the root layout rows (uiSchema[\"x-ui-layout\"].rows),\n * preserving other x-ui-layout keys. Clearing rows to empty removes the key;\n * if x-ui-layout then has no keys, it is removed entirely.\n */\nexport function setRootLayoutRows(\n model: DesignerModel,\n rows: UILayoutConfig[\"rows\"],\n): DesignerModel {\n const uiSchema = { ...model.uiSchema } as RootUiSchema;\n const layout: UILayoutConfig = { ...(uiSchema[\"x-ui-layout\"] ?? {}) };\n if (rows && rows.length > 0) layout.rows = rows;\n else delete layout.rows;\n if (Object.keys(layout).length > 0) uiSchema[\"x-ui-layout\"] = layout;\n else delete uiSchema[\"x-ui-layout\"];\n return { schema: model.schema, uiSchema };\n}\n\n/**\n * Set the layout rows for a scope: the root form (path []) or an object/array\n * container (its property path). Root rows live in uiSchema[\"x-ui-layout\"];\n * a container's rows live on the property's x-ui-layout (array -> items).\n * Preserves other x-ui-layout keys.\n */\nexport function setScopedLayoutRows(\n model: DesignerModel,\n scopePath: PropertyPath,\n rows: UILayoutConfig[\"rows\"],\n): DesignerModel {\n if (scopePath.length === 0) return setRootLayoutRows(model, rows);\n\n const schema = clone(model.schema);\n const prop = getProperty(schema, scopePath);\n if (!prop) return model;\n const target = prop.type === \"array\" ? prop.items : prop;\n if (!target) return model;\n\n const layout: UILayoutConfig = { ...(target[\"x-ui-layout\"] ?? {}) };\n if (rows && rows.length > 0) layout.rows = rows;\n else delete layout.rows;\n if (Object.keys(layout).length > 0) target[\"x-ui-layout\"] = layout;\n else delete target[\"x-ui-layout\"];\n return { schema, uiSchema: model.uiSchema };\n}\n\n/** Read the current x-ui-layout for a scope (root or a container property). */\nexport function getScopedLayout(\n schema: JsonSchema,\n uiSchema: UiSchemaMap,\n scopePath: PropertyPath,\n): UILayoutConfig | undefined {\n if (scopePath.length === 0) {\n return (uiSchema as RootUiSchema)[\"x-ui-layout\"];\n }\n const prop = getProperty(schema, scopePath);\n const target = prop?.type === \"array\" ? prop.items : prop;\n return target?.[\"x-ui-layout\"];\n}\n\n/**\n * Merge scalar layout options (direction/gap/labels/compact) into a scope's\n * x-ui-layout, preserving rows and other keys. Undefined values clear the key.\n */\nexport function setScopedLayoutOptions(\n model: DesignerModel,\n scopePath: PropertyPath,\n options: Pick<UILayoutConfig, \"direction\" | \"gap\" | \"labels\" | \"compact\">,\n): DesignerModel {\n const current =\n getScopedLayout(model.schema, model.uiSchema, scopePath) ?? {};\n const merged: UILayoutConfig = { ...current };\n for (const key of [\"direction\", \"gap\", \"labels\", \"compact\"] as const) {\n const v = options[key];\n if (v === undefined || (typeof v === \"number\" && Number.isNaN(v)))\n delete merged[key];\n else (merged as Record<string, unknown>)[key] = v;\n }\n const layout = Object.keys(merged).length > 0 ? merged : undefined;\n if (scopePath.length === 0) return setRootLayout(model, layout);\n return setPropertyLayout(model, scopePath, layout);\n}\n\n/** Set (or clear) the root global options (uiSchema[\"x-ui-globalOptions\"]). */\nexport function setGlobalOptions(\n model: DesignerModel,\n options: UISchemaOptions | undefined,\n): DesignerModel {\n const uiSchema = { ...model.uiSchema } as RootUiSchema;\n if (options) uiSchema[\"x-ui-globalOptions\"] = options;\n else delete uiSchema[\"x-ui-globalOptions\"];\n return { schema: model.schema, uiSchema };\n}\n","/**\n * Type -> compatible form widgets for the inspector's widget dropdown.\n *\n * Mirrors the renderer's resolution vocabulary (sonnet-forms widgetResolver):\n * the dropdown offers widgets that make sense for a property's type, plus an\n * \"Auto\" choice (value null) that clears x-ui-widget and lets the renderer\n * resolve from structure/type. Keep aligned with DEFAULT_WIDGETS.\n */\n\nimport type { JsonSchemaProperty } from \"@petrarca/sonnet-core/schema\";\n\nexport interface WidgetChoice {\n /** x-ui-widget value (lowercase alias), or null for Auto (no override). */\n value: string | null;\n label: string;\n}\n\nconst AUTO: WidgetChoice = { value: null, label: \"Auto (resolve from schema)\" };\n\nconst STRING_WIDGETS: WidgetChoice[] = [\n { value: \"text\", label: \"Text input\" },\n { value: \"textarea\", label: \"Textarea\" },\n { value: \"select\", label: \"Select\" },\n { value: \"tags\", label: \"Tags\" },\n { value: \"entity-select\", label: \"Entity select\" },\n { value: \"json-editor\", label: \"JSON editor\" },\n];\n\nconst NUMBER_WIDGETS: WidgetChoice[] = [\n { value: \"number\", label: \"Number\" },\n { value: \"select\", label: \"Select\" },\n { value: \"quantity\", label: \"Quantity\" },\n];\n\nconst BOOLEAN_WIDGETS: WidgetChoice[] = [\n { value: \"checkbox\", label: \"Checkbox\" },\n];\n\nconst OBJECT_WIDGETS: WidgetChoice[] = [\n { value: \"object\", label: \"Object (sub-form)\" },\n { value: \"json-editor\", label: \"JSON editor\" },\n];\n\nconst ARRAY_WIDGETS: WidgetChoice[] = [\n { value: \"array\", label: \"Array (repeatable)\" },\n { value: \"select\", label: \"Multi-select\" },\n { value: \"tags\", label: \"Tags\" },\n];\n\n/** Widgets offered for a property, Auto first. */\nexport function compatibleWidgets(prop: JsonSchemaProperty): WidgetChoice[] {\n switch (prop.type) {\n case \"string\":\n return [AUTO, ...STRING_WIDGETS];\n case \"number\":\n case \"integer\":\n return [AUTO, ...NUMBER_WIDGETS];\n case \"boolean\":\n return [AUTO, ...BOOLEAN_WIDGETS];\n case \"object\":\n return [AUTO, ...OBJECT_WIDGETS];\n case \"array\":\n return [AUTO, ...ARRAY_WIDGETS];\n default:\n return [AUTO];\n }\n}\n","/**\n * Output shaping: merge a separate uiSchema map's form hints into the JSON\n * schema as embedded x-ui-* keys, for consumers that want a single\n * self-contained schema.\n *\n * The designer edits the two artifacts separately (clean data/presentation\n * split); embedding is applied only at the emit boundary when outputMode is\n * \"embedded\". Only top-level form hints are embedded in v1 (x-ui-widget,\n * x-ui-options, x-ui-title, x-ui-placeholder, x-ui-description), matching what\n * uiSchema carries for top-level properties.\n */\n\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n UISchema,\n} from \"@petrarca/sonnet-core/schema\";\n\nconst EMBEDDABLE_KEYS = [\n \"x-ui-widget\",\n \"x-ui-options\",\n \"x-ui-title\",\n \"x-ui-placeholder\",\n \"x-ui-description\",\n] as const;\n\n/**\n * Return a new schema with each top-level property's uiSchema form hints copied\n * onto the corresponding property as x-ui-* keys. The input schema/uiSchema are\n * not mutated. uiSchema hints win over any pre-existing embedded key.\n */\nexport function embedUiSchema(\n schema: JsonSchema,\n uiSchema: Record<string, UISchema>,\n): JsonSchema {\n const next = structuredClone(schema);\n for (const [fieldName, entry] of Object.entries(uiSchema)) {\n const prop: JsonSchemaProperty | undefined = next.properties[fieldName];\n if (!prop || !entry) continue;\n for (const key of EMBEDDABLE_KEYS) {\n if (entry[key] !== undefined) {\n (prop as Record<string, unknown>)[key] = entry[key];\n }\n }\n }\n return next;\n}\n","/**\n * useDesignerState -- owns the designer's { schema, uiSchema, selection } and\n * exposes bound mutation operations.\n *\n * Controlled: pass `schema` + `uiSchema` + `onChange`; the hook holds no schema\n * state and every op calls `onChange`. Uncontrolled: pass `initialSchema`\n * (+ optional `initialUiSchema`); the hook manages the schema internally.\n * Selection (the active property path) is always internal UI state.\n */\n\nimport { useCallback, useMemo, useRef, useState } from \"react\";\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n UISchema,\n UILayoutConfig,\n UISchemaOptions,\n} from \"@petrarca/sonnet-core/schema\";\nimport {\n addProperty,\n deleteProperty,\n moveProperty,\n renameProperty,\n setRequired,\n updateProperty,\n changePropertyType,\n setEnum,\n setUiEntry,\n setTableHints,\n type TableHints,\n setPropertyLayout,\n setRootLayout,\n setRootLayoutRows,\n setScopedLayoutRows,\n setScopedLayoutOptions,\n setGlobalOptions,\n type DesignerModel,\n type UiSchemaMap,\n type EnumChoice,\n} from \"../model/mutate\";\nimport { samePath, type PropertyPath } from \"../model/paths\";\nimport {\n resolveCapabilities,\n type SchemaDesignerCapabilities,\n type ResolvedCapabilities,\n} from \"../capabilities\";\nimport { isPropertyEditable, canAddChildTo } from \"../model/scoping\";\n\nexport interface UseDesignerStateArgs {\n schema?: JsonSchema;\n uiSchema?: UiSchemaMap;\n initialSchema?: JsonSchema;\n initialUiSchema?: UiSchemaMap;\n onChange?: (schema: JsonSchema, uiSchema: UiSchemaMap) => void;\n readOnly?: boolean;\n capabilities?: SchemaDesignerCapabilities;\n}\n\nexport interface DesignerState {\n schema: JsonSchema;\n uiSchema: UiSchemaMap;\n selection: PropertyPath | null;\n readOnly: boolean;\n /** Resolved capability profile (readOnly + editablePaths applied). */\n capabilities: ResolvedCapabilities;\n /** Whether the property at path may be renamed / deleted / retyped / reordered. */\n canEditProperty: (path: PropertyPath) => boolean;\n /** Whether a child property may be added to the container at path (root = []). */\n canAddChild: (path: PropertyPath) => boolean;\n select: (path: PropertyPath | null) => void;\n addProperty: (\n parentPath: PropertyPath,\n kind: \"scalar\" | \"object\" | \"array\",\n ) => void;\n deleteProperty: (path: PropertyPath) => void;\n renameProperty: (path: PropertyPath, nextKey: string) => void;\n moveProperty: (path: PropertyPath, direction: -1 | 1) => void;\n setRequired: (path: PropertyPath, required: boolean) => void;\n updateProperty: (\n path: PropertyPath,\n patch: Partial<JsonSchemaProperty>,\n ) => void;\n changePropertyType: (\n path: PropertyPath,\n nextType: JsonSchemaProperty[\"type\"],\n ) => void;\n setEnum: (path: PropertyPath, choices: EnumChoice[]) => void;\n setUiEntry: (path: PropertyPath, entry: UISchema | undefined) => void;\n setTableHints: (path: PropertyPath, hints: TableHints) => void;\n setPropertyLayout: (\n path: PropertyPath,\n layout: UILayoutConfig | undefined,\n ) => void;\n setRootLayout: (layout: UILayoutConfig | undefined) => void;\n setRootLayoutRows: (rows: UILayoutConfig[\"rows\"]) => void;\n setScopedLayoutRows: (\n scopePath: PropertyPath,\n rows: UILayoutConfig[\"rows\"],\n ) => void;\n setScopedLayoutOptions: (\n scopePath: PropertyPath,\n options: Pick<UILayoutConfig, \"direction\" | \"gap\" | \"labels\" | \"compact\">,\n ) => void;\n setGlobalOptions: (options: UISchemaOptions | undefined) => void;\n}\n\nconst EMPTY_SCHEMA: JsonSchema = {\n title: \"\",\n type: \"object\",\n properties: {},\n};\n\nexport function useDesignerState(args: UseDesignerStateArgs): DesignerState {\n const { onChange, readOnly = false } = args;\n const controlled = args.schema !== undefined;\n\n const [internal, setInternal] = useState<DesignerModel>(() => ({\n schema: args.initialSchema ?? EMPTY_SCHEMA,\n uiSchema: args.initialUiSchema ?? {},\n }));\n const [selection, setSelection] = useState<PropertyPath | null>(null);\n\n // The live model: controlled props win; otherwise internal state.\n const model: DesignerModel = controlled\n ? { schema: args.schema!, uiSchema: args.uiSchema ?? {} }\n : internal;\n\n // Keep a ref so the mutation callbacks are stable but read the latest model.\n const modelRef = useRef(model);\n modelRef.current = model;\n\n const commit = useCallback(\n (next: DesignerModel) => {\n if (!controlled) setInternal(next);\n onChange?.(next.schema, next.uiSchema);\n },\n [controlled, onChange],\n );\n\n const select = useCallback((path: PropertyPath | null) => {\n setSelection((prev) => (samePath(prev, path) ? prev : path));\n }, []);\n\n const capabilities = useMemo(\n () => resolveCapabilities(args.capabilities, readOnly),\n [args.capabilities, readOnly],\n );\n\n // Structural gating: readOnly locks everything; scoped restricts edits to the\n // children of editablePaths. Read the latest model via the ref so callbacks\n // stay stable.\n const canEditProperty = useCallback(\n (path: PropertyPath) => {\n if (capabilities.locked) return false;\n return isPropertyEditable(\n modelRef.current.schema,\n path,\n capabilities.editablePaths,\n );\n },\n [capabilities.locked, capabilities.editablePaths],\n );\n const canAddChild = useCallback(\n (path: PropertyPath) => {\n if (capabilities.locked) return false;\n return canAddChildTo(\n modelRef.current.schema,\n path,\n capabilities.editablePaths,\n );\n },\n [capabilities.locked, capabilities.editablePaths],\n );\n\n const ops = useMemo(\n () => ({\n addProperty(\n parentPath: PropertyPath,\n kind: \"scalar\" | \"object\" | \"array\",\n ) {\n if (!canAddChild(parentPath)) return;\n const res = addProperty(modelRef.current, parentPath, kind);\n commit(res.model);\n setSelection(res.path);\n },\n deleteProperty(path: PropertyPath) {\n if (!canEditProperty(path)) return;\n commit(deleteProperty(modelRef.current, path));\n setSelection((prev) => (samePath(prev, path) ? null : prev));\n },\n renameProperty(path: PropertyPath, nextKey: string) {\n if (!canEditProperty(path)) return;\n const res = renameProperty(modelRef.current, path, nextKey);\n commit(res.model);\n setSelection(res.path);\n },\n moveProperty(path: PropertyPath, direction: -1 | 1) {\n if (!canEditProperty(path)) return;\n commit(moveProperty(modelRef.current, path, direction));\n },\n setRequired(path: PropertyPath, required: boolean) {\n if (!canEditProperty(path)) return;\n commit(setRequired(modelRef.current, path, required));\n },\n updateProperty(path: PropertyPath, patch: Partial<JsonSchemaProperty>) {\n if (!canEditProperty(path)) return;\n commit(updateProperty(modelRef.current, path, patch));\n },\n changePropertyType(\n path: PropertyPath,\n nextType: JsonSchemaProperty[\"type\"],\n ) {\n if (!canEditProperty(path)) return;\n commit(changePropertyType(modelRef.current, path, nextType));\n },\n setEnum(path: PropertyPath, choices: EnumChoice[]) {\n if (!canEditProperty(path)) return;\n commit(setEnum(modelRef.current, path, choices));\n },\n // UI-schema / presentation ops use `readOnly` (not `capabilities.locked`)\n // because they are not subject to scoped-path gating: presentation hints\n // are always either fully editable or fully locked.\n setUiEntry(path: PropertyPath, entry: UISchema | undefined) {\n if (readOnly) return;\n commit(setUiEntry(modelRef.current, path, entry));\n },\n setTableHints(path: PropertyPath, hints: TableHints) {\n if (readOnly) return;\n commit(setTableHints(modelRef.current, path, hints));\n },\n setPropertyLayout(\n path: PropertyPath,\n layout: UILayoutConfig | undefined,\n ) {\n if (readOnly) return;\n commit(setPropertyLayout(modelRef.current, path, layout));\n },\n setRootLayout(layout: UILayoutConfig | undefined) {\n if (readOnly) return;\n commit(setRootLayout(modelRef.current, layout));\n },\n setRootLayoutRows(rows: UILayoutConfig[\"rows\"]) {\n if (readOnly) return;\n commit(setRootLayoutRows(modelRef.current, rows));\n },\n setScopedLayoutRows(\n scopePath: PropertyPath,\n rows: UILayoutConfig[\"rows\"],\n ) {\n if (readOnly) return;\n commit(setScopedLayoutRows(modelRef.current, scopePath, rows));\n },\n setScopedLayoutOptions(\n scopePath: PropertyPath,\n options: Pick<\n UILayoutConfig,\n \"direction\" | \"gap\" | \"labels\" | \"compact\"\n >,\n ) {\n if (readOnly) return;\n commit(setScopedLayoutOptions(modelRef.current, scopePath, options));\n },\n setGlobalOptions(options: UISchemaOptions | undefined) {\n if (readOnly) return;\n commit(setGlobalOptions(modelRef.current, options));\n },\n }),\n [commit, readOnly, canEditProperty, canAddChild],\n );\n\n return {\n schema: model.schema,\n uiSchema: model.uiSchema,\n selection,\n readOnly,\n capabilities,\n canEditProperty,\n canAddChild,\n select,\n ...ops,\n };\n}\n","/**\n * SchemaDesigner capabilities -- a small profile that gates what a consumer can\n * author. Mirrors the discipline of GraphModelEditor's capabilities: the Zod\n * schema below is the single source of truth, the TypeScript types are inferred\n * from it, and `resolveCapabilities` applies defaults (with `readOnly` as a\n * fully-locked shorthand). Every field is optional and defaults to the most\n * permissive value, so adding a capability never tightens an existing profile.\n *\n * Design: docs/design/schema-designer.md, section \"Capability gating\".\n */\n\nimport { z } from \"zod\";\nimport { warnLog } from \"@petrarca/sonnet-core\";\n\n/**\n * A tab the center pane can offer. \"form\" / \"table\" / \"json\" preview the\n * schema; \"capabilities\" is a meta-editor for the profile itself (a dev /\n * power-user affordance), not a preview -- it is opt-in and never in a default.\n */\nexport type PreviewKind = \"form\" | \"table\" | \"json\" | \"capabilities\";\n\n/**\n * The capabilities schema. Small by design -- it covers the real consumer needs\n * (sestina's audit-event and terminology schema editors) without a per-area\n * matrix we do not use yet.\n */\nexport const capabilitiesSchema = z\n .object({\n mode: z.enum([\"data\", \"full\"]).default(\"full\").meta({\n description:\n \"What the designer authors. 'full' (default): JSON Schema + uiSchema (form presentation hints). 'data': JSON Schema only -- the UI Schema tab, Combined tab, and the inspector's per-field UI tab are hidden (pure data schemas: audit events, terminology).\",\n }),\n previews: z\n .array(z.enum([\"form\", \"table\", \"json\", \"capabilities\"]))\n .optional()\n .meta({\n description:\n \"Which tabs the center pane offers, in order. 'form'/'table'/'json' preview the schema; 'capabilities' is a JSON editor for this profile (opt-in, never in a default). When omitted, defaults to ['form','table','json'] in 'full' mode and ['json'] in 'data' mode. An empty list hides the center pane entirely.\",\n }),\n editablePaths: z.array(z.string()).optional().meta({\n description:\n \"Scoped editing. When set, the passed-in schema is fixed EVERYWHERE except the children of these JSON Pointer (RFC 6901) paths, which the user may add / delete / edit. Absent = fully editable. readOnly overrides this to fully locked.\",\n }),\n })\n .meta({\n id: \"SchemaDesignerCapabilities\",\n title: \"SchemaDesignerCapabilities\",\n description:\n \"Capability profile for SchemaDesigner. Gates what a consumer can author. Every field is optional and defaults to the most permissive value (forward-compatible). Passing readOnly to the designer overrides this object to a fully-locked profile.\",\n });\n\n/**\n * The capabilities a consumer may pass. Inferred from the schema, with all\n * fields optional on input (defaults are applied by resolveCapabilities).\n */\nexport type SchemaDesignerCapabilities = z.input<typeof capabilitiesSchema>;\n\n/** The fully-resolved capabilities, plus the derived flags used for gating. */\nexport interface ResolvedCapabilities {\n mode: \"data\" | \"full\";\n /** Effective preview list (defaulted by mode when not provided). */\n previews: PreviewKind[];\n /** JSON Pointer paths whose children are editable; empty = no scoping. */\n editablePaths: string[];\n /** No structural edits at all (readOnly shorthand). */\n locked: boolean;\n /** editablePaths is non-empty -- only designated subtrees are editable. */\n scoped: boolean;\n /** The Capabilities editor tab is listed in previews. */\n showCapabilities: boolean;\n /** Whether the center pane renders at all (previews non-empty). */\n showPreview: boolean;\n}\n\n/** Default preview lists per mode. */\nfunction defaultPreviews(mode: \"data\" | \"full\"): PreviewKind[] {\n return mode === \"data\" ? [\"json\"] : [\"form\", \"table\", \"json\"];\n}\n\n/**\n * Resolve the effective capabilities: readOnly wins (fully locked), otherwise\n * parse the provided capabilities (applying per-field defaults). Invalid input\n * falls back to permissive defaults rather than throwing.\n */\nexport function resolveCapabilities(\n capabilities: SchemaDesignerCapabilities | undefined,\n readOnly: boolean | undefined,\n): ResolvedCapabilities {\n const parsed = capabilitiesSchema.safeParse(capabilities ?? {});\n const value = parsed.success ? parsed.data : capabilitiesSchema.parse({});\n if (!parsed.success) {\n warnLog(\n \"[SchemaDesigner] Invalid capabilities — falling back to defaults.\",\n parsed.error.issues,\n );\n }\n const mode = value.mode;\n const previews = value.previews ?? defaultPreviews(mode);\n const editablePaths = value.editablePaths ?? [];\n return {\n mode,\n previews,\n editablePaths,\n locked: !!readOnly,\n scoped: !readOnly && editablePaths.length > 0,\n showCapabilities: previews.includes(\"capabilities\"),\n showPreview: previews.length > 0,\n };\n}\n\n/** Result of validating an untrusted capabilities object. */\nexport type CapabilitiesValidation =\n | { ok: true; value: SchemaDesignerCapabilities }\n | { ok: false; errors: string[] };\n\n/**\n * Validate a hand-authored / external capabilities object. Returns the parsed\n * value or a list of readable error messages. Does not throw.\n */\nexport function validateCapabilities(input: unknown): CapabilitiesValidation {\n const parsed = capabilitiesSchema.safeParse(input);\n if (parsed.success) return { ok: true, value: parsed.data };\n const errors = parsed.error.issues.map((i) => {\n const path = i.path.length ? i.path.join(\".\") : \"(root)\";\n return `${path}: ${i.message}`;\n });\n return { ok: false, errors };\n}\n","/**\n * Scoped-editing helpers. When capabilities carry `editablePaths` (JSON Pointer,\n * RFC 6901), the schema is fixed everywhere except the *children* of those\n * paths. This module maps the designer's key-array PropertyPath to the JSON\n * Pointer of the container that holds a property, and decides whether a given\n * property (or the root) is editable.\n *\n * A property's own pointer is built by walking the schema from the root:\n * each segment contributes `/properties/<key>`, and an array crossing inserts\n * `/items` before descending (mirroring childContainer navigation). The\n * *parent container* pointer is the property pointer with the trailing\n * `/<key>` removed -- this is what `editablePaths` names (e.g.\n * `/properties/metadata/properties`).\n */\n\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n} from \"@petrarca/sonnet-core/schema\";\nimport { childContainer } from \"./paths\";\nimport type { PropertyPath } from \"./paths\";\n\ntype PropMap = Record<string, JsonSchemaProperty>;\n\n/** RFC 6901 escape for a single reference token. */\nfunction escapeToken(token: string): string {\n return token.replace(/~/g, \"~0\").replace(/\\//g, \"~1\");\n}\n\n/**\n * The JSON Pointer of the container object that holds the property at `path`\n * (i.e. the `...properties` pointer the property lives under). Returns\n * `/properties` for a top-level property. Returns undefined if the path does\n * not resolve.\n */\nexport function parentContainerPointer(\n schema: JsonSchema,\n path: PropertyPath,\n): string | undefined {\n if (path.length === 0) return undefined;\n let container: PropMap | undefined = schema.properties;\n let pointer = \"/properties\";\n for (let i = 0; i < path.length; i++) {\n if (!container) return undefined;\n const seg = path[i];\n const prop = container[seg];\n if (!prop) return undefined;\n // The container holding this segment is `pointer`. For the last segment we\n // are done -- that pointer is the parent container.\n if (i === path.length - 1) return pointer;\n // Descend: cross `/items` for array-of-object, then into `/properties`.\n const next = childContainer(prop);\n if (!next) return undefined;\n pointer =\n prop.type === \"array\"\n ? `${pointer}/${escapeToken(seg)}/items/properties`\n : `${pointer}/${escapeToken(seg)}/properties`;\n container = next;\n }\n return pointer;\n}\n\n/**\n * Whether the property at `path` is editable (rename / delete / retype /\n * reorder). In scoped mode a property is editable only when its parent\n * container is one of the editablePaths (i.e. it is a user-added member of a\n * designated area). Without editablePaths, everything is editable.\n */\nexport function isPropertyEditable(\n schema: JsonSchema,\n path: PropertyPath,\n editablePaths: string[],\n): boolean {\n if (editablePaths.length === 0) return true;\n const parent = parentContainerPointer(schema, path);\n if (parent === undefined) return false;\n return editablePaths.includes(parent);\n}\n\n/**\n * Whether children may be added to the container at `path` (or the root when\n * path is empty). Adding is allowed when the container's own children pointer\n * is a designated editable path. Without editablePaths, always true.\n */\nexport function canAddChildTo(\n schema: JsonSchema,\n path: PropertyPath,\n editablePaths: string[],\n): boolean {\n if (editablePaths.length === 0) return true;\n if (path.length === 0) return editablePaths.includes(\"/properties\");\n const own = ownChildContainerPointer(schema, path);\n return own !== undefined && editablePaths.includes(own);\n}\n\n/** The `.../properties` pointer of a container property (array-aware). */\nexport function ownChildContainerPointer(\n schema: JsonSchema,\n path: PropertyPath,\n): string | undefined {\n const parent = parentContainerPointer(schema, path);\n if (parent === undefined) return undefined;\n // Resolve the property to know if it is an array (crosses /items).\n let container: PropMap | undefined = schema.properties;\n for (let i = 0; i < path.length; i++) {\n const prop = container?.[path[i]];\n if (!prop) return undefined;\n if (i === path.length - 1) {\n const seg = escapeToken(path[i]);\n return prop.type === \"array\"\n ? `${parent}/${seg}/items/properties`\n : `${parent}/${seg}/properties`;\n }\n container = childContainer(prop);\n }\n return undefined;\n}\n","/**\n * SchemaDesigner -- visual, controlled designer for a JsonSchema (+ uiSchema).\n *\n * Layout: Tree | Preview | Inspector. The preview (the live form) is the hero\n * and takes the flexible center, matching visual-builder convention; the\n * inspector is the resizable/collapsible right pane. Controlled via `schema` +\n * `uiSchema` + `onChange`, or uncontrolled via `initialSchema`. Read-only is a\n * mode of the same component.\n *\n * This is the assembly shell; the tree, preview, and inspector are built up\n * incrementally.\n */\n\nimport React, { useEffect, useState } from \"react\";\nimport { ResizeHandle, IconButton } from \"@petrarca/sonnet-ui\";\nimport { useResizablePanel } from \"@petrarca/sonnet-core/hooks\";\nimport {\n Settings,\n PanelRightClose,\n PanelRightOpen,\n PanelLeftOpen,\n} from \"lucide-react\";\nimport type { JsonSchema, UISchema } from \"@petrarca/sonnet-core/schema\";\nimport type { WidgetOptionDef } from \"@petrarca/sonnet-forms/widget-options\";\nimport { useDesignerState } from \"./hooks/useDesignerState\";\nimport type { SchemaDesignerCapabilities } from \"./capabilities\";\nimport { FormSettingsSheet } from \"./FormSettingsSheet\";\nimport { PropertyTree } from \"./tree/PropertyTree\";\nimport { PreviewPane } from \"./preview/PreviewPane\";\nimport { Inspector } from \"./inspector/Inspector\";\n\nexport interface SchemaDesignerProps {\n /** Controlled schema. Provide with onChange. */\n schema?: JsonSchema;\n /** Controlled uiSchema map (form presentation hints). */\n uiSchema?: Record<string, UISchema>;\n /** Uncontrolled seed schema (used when `schema` is omitted). */\n initialSchema?: JsonSchema;\n /** Uncontrolled seed uiSchema. */\n initialUiSchema?: Record<string, UISchema>;\n /**\n * Called on every edit with the new schema + uiSchema (always the separate\n * form: schema is the data model, form hints live in uiSchema). Use the\n * exported `embedUiSchema` helper if a single self-contained schema is wanted.\n */\n onChange?: (schema: JsonSchema, uiSchema: Record<string, UISchema>) => void;\n /** View-only: no edit affordances, onChange never fires. Shorthand for a fully-locked profile. */\n readOnly?: boolean;\n /** Capability profile: gates data/full mode, preview renderers, and scoped editing. */\n capabilities?: SchemaDesignerCapabilities;\n /** Option descriptors for custom widgets, keyed by widget name (merged over built-ins). */\n widgetOptions?: Record<string, WidgetOptionDef[]>;\n}\n\nexport function SchemaDesigner(props: SchemaDesignerProps): React.ReactElement {\n // Editable capabilities: seeded from the prop, live-editable via the\n // Capabilities tab (when previews include \"capabilities\"). Re-seeds via\n // useEffect when the prop identity changes (avoids a render-phase update).\n const [capabilities, setCapabilities] = useState<\n SchemaDesignerCapabilities | undefined\n >(props.capabilities);\n useEffect(() => {\n setCapabilities(props.capabilities);\n }, [props.capabilities]);\n\n const state = useDesignerState({ ...props, capabilities });\n\n const {\n panelWidth: inspectorWidth,\n handlePointerDown: startInspectorResize,\n handleDoubleClick: resetInspectorWidth,\n separatorProps: inspectorSepProps,\n } = useResizablePanel({\n defaultWidth: 360,\n minWidth: 300,\n maxWidth: 640,\n direction: \"left-edge\",\n });\n\n const {\n panelWidth: treeWidth,\n handlePointerDown: startTreeResize,\n handleDoubleClick: resetTreeWidth,\n separatorProps: treeSepProps,\n } = useResizablePanel({\n defaultWidth: 288,\n minWidth: 220,\n maxWidth: 520,\n direction: \"right-edge\",\n });\n\n const [inspectorCollapsed, setInspectorCollapsed] = useState(false);\n const [treeCollapsed, setTreeCollapsed] = useState(false);\n const [settingsOpen, setSettingsOpen] = useState(false);\n\n return (\n <div className=\"flex w-full h-full overflow-hidden border rounded-lg bg-background\">\n {/* Left: property tree (resizable/collapsible). Grows to fill when the\n center preview pane is hidden (tree + inspector only). */}\n {!treeCollapsed && (\n <>\n <div\n style={\n state.capabilities.showPreview ? { width: treeWidth } : undefined\n }\n className={\n state.capabilities.showPreview\n ? \"shrink-0 overflow-auto p-3\"\n : \"flex-1 min-w-0 overflow-auto p-3\"\n }\n >\n <PropertyTree\n state={state}\n onCollapse={() => setTreeCollapsed(true)}\n />\n </div>\n {state.capabilities.showPreview && (\n <ResizeHandle\n orientation=\"vertical\"\n {...treeSepProps}\n onPointerDown={startTreeResize}\n onDoubleClick={resetTreeWidth}\n />\n )}\n </>\n )}\n {treeCollapsed && (\n <div className=\"shrink-0 border-r flex flex-col items-center gap-1 p-1\">\n <IconButton\n label=\"Expand properties\"\n onClick={() => setTreeCollapsed(false)}\n >\n <PanelLeftOpen />\n </IconButton>\n </div>\n )}\n\n {/* Center: preview (the hero -- live form + JSON). Hidden when the\n capability profile lists no previews (structure-editing only). */}\n {state.capabilities.showPreview && (\n <div className=\"flex-1 min-w-0 overflow-hidden p-4 flex flex-col min-h-0\">\n <PreviewPane\n state={state}\n capabilities={capabilities}\n onCapabilitiesChange={setCapabilities}\n />\n </div>\n )}\n\n {/* Right: inspector (resizable/collapsible) */}\n {!inspectorCollapsed && (\n <>\n <ResizeHandle\n orientation=\"vertical\"\n {...inspectorSepProps}\n onPointerDown={startInspectorResize}\n onDoubleClick={resetInspectorWidth}\n />\n <div\n style={{ width: inspectorWidth }}\n className=\"shrink-0 border-l overflow-auto p-4 bg-card\"\n >\n <div className=\"flex items-center gap-1 mb-2\">\n <p className=\"heading-meta\">Inspector</p>\n <span className=\"ml-auto flex gap-0.5\">\n <IconButton\n label=\"Form settings\"\n onClick={() => setSettingsOpen(true)}\n >\n <Settings />\n </IconButton>\n <IconButton\n label=\"Collapse inspector\"\n onClick={() => setInspectorCollapsed(true)}\n >\n <PanelRightClose />\n </IconButton>\n </span>\n </div>\n <Inspector state={state} widgetOptions={props.widgetOptions} />\n </div>\n </>\n )}\n {inspectorCollapsed && (\n <div className=\"shrink-0 border-l flex flex-col items-center gap-1 p-1\">\n <IconButton\n label=\"Expand inspector\"\n onClick={() => setInspectorCollapsed(false)}\n >\n <PanelRightOpen />\n </IconButton>\n <IconButton\n label=\"Form settings\"\n onClick={() => setSettingsOpen(true)}\n >\n <Settings />\n </IconButton>\n </div>\n )}\n\n <FormSettingsSheet\n open={settingsOpen}\n onOpenChange={setSettingsOpen}\n state={state}\n />\n </div>\n );\n}\n\nexport default SchemaDesigner;\n","/**\n * FormSettingsSheet -- form-level (root) settings in a right-side Sheet, opened\n * from a gear button. Holds settings that are not tied to a single property:\n * the root form layout (x-ui-layout) and global options (x-ui-globalOptions).\n *\n * Uses the house-standard Sheet pattern (as in graph-model's PropertyFormSheet).\n * Kept out of the inspector's per-property tabs, which do not scale to\n * form-wide concerns.\n */\n\nimport React from \"react\";\nimport {\n Sheet,\n SheetContent,\n SheetHeader,\n SheetBody,\n SheetTitle,\n SheetDescription,\n} from \"@petrarca/sonnet-ui\";\nimport { JsonSchemaFormRenderer, FormSelect } from \"@petrarca/sonnet-forms\";\nimport type {\n UISchemaOptions,\n UILayoutConfig,\n} from \"@petrarca/sonnet-core/schema\";\nimport type { DesignerState } from \"./hooks/useDesignerState\";\nimport {\n buildGlobalOptionsMetaSchema,\n globalOptionsToValues,\n valuesToGlobalOptions,\n type GlobalOptionsFormValues,\n} from \"./inspector/layoutMetaSchemas\";\n\nexport interface FormSettingsSheetProps {\n open: boolean;\n onOpenChange: (open: boolean) => void;\n state: DesignerState;\n}\n\nexport function FormSettingsSheet({\n open,\n onOpenChange,\n state,\n}: FormSettingsSheetProps): React.ReactElement {\n const globalOptions = state.uiSchema[\"x-ui-globalOptions\"] as\n | UISchemaOptions\n | undefined;\n\n const optionValues = globalOptionsToValues(globalOptions);\n\n const rootLayout = state.uiSchema[\"x-ui-layout\"] as\n | UILayoutConfig\n | undefined;\n const labelPlacement = rootLayout?.labelPlacement ?? \"top\";\n\n // \"top\" is the default -- omit it (and prune an emptied layout) so the\n // uiSchema stays clean.\n const setLabelPlacement = (value: \"top\" | \"start\") => {\n const next: UILayoutConfig = { ...(rootLayout ?? {}) };\n if (value === \"start\") next.labelPlacement = \"start\";\n else delete next.labelPlacement;\n state.setRootLayout(Object.keys(next).length ? next : undefined);\n };\n\n return (\n <Sheet open={open} onOpenChange={onOpenChange}>\n <SheetContent>\n <SheetHeader>\n <SheetTitle>Form settings</SheetTitle>\n <SheetDescription>\n Options applied to every field in the form.\n </SheetDescription>\n </SheetHeader>\n <SheetBody className=\"space-y-6\">\n <section className=\"space-y-2\">\n <p className=\"heading-meta\">Layout</p>\n <FormSelect\n id=\"root-labelPlacement\"\n name=\"labelPlacement\"\n label=\"Label placement\"\n value={labelPlacement}\n options={[\n { value: \"top\", label: \"Above\" },\n { value: \"start\", label: \"Inline (start)\" },\n ]}\n onChange={(v) =>\n setLabelPlacement(v === \"start\" ? \"start\" : \"top\")\n }\n disabled={state.readOnly}\n clearable={false}\n />\n </section>\n <section className=\"space-y-2\">\n <p className=\"heading-meta\">Global options</p>\n <JsonSchemaFormRenderer\n schema={buildGlobalOptionsMetaSchema()}\n data={optionValues as unknown as Record<string, unknown>}\n onChange={(data) =>\n state.setGlobalOptions(\n valuesToGlobalOptions(data as GlobalOptionsFormValues),\n )\n }\n showActions={false}\n showExtraProperties={false}\n readOnly={state.readOnly}\n />\n </section>\n </SheetBody>\n </SheetContent>\n </Sheet>\n );\n}\n","/**\n * Meta-schemas for layout (x-ui-layout) and global options (x-ui-globalOptions),\n * rendered by JsonSchemaFormRenderer. Covers the scalar array-item layout\n * options (direction / gap / labels / compact); the visual row builder lives in\n * FormLayoutDesigner.\n */\n\nimport type {\n JsonSchema,\n UILayoutConfig,\n UISchemaOptions,\n} from \"@petrarca/sonnet-core/schema\";\n\n/** Tier-1 layout meta-schema (no row builder). */\nexport function buildLayoutMetaSchema(): JsonSchema {\n return {\n title: \"\",\n type: \"object\",\n properties: {\n direction: {\n type: \"string\",\n title: \"Direction\",\n enum: [\"vertical\", \"horizontal\"],\n description: \"Stack fields vertically or lay them out horizontally.\",\n },\n gap: {\n type: \"integer\",\n title: \"Gap (px)\",\n minimum: 0,\n description: \"Space between fields.\",\n },\n labels: {\n type: \"boolean\",\n title: \"Show labels\",\n },\n compact: {\n type: \"boolean\",\n title: \"Compact\",\n description: \"Smaller control sizing.\",\n },\n },\n };\n}\n\n/** Flat form values for the layout meta-schema. */\nexport interface LayoutFormValues {\n direction?: string;\n gap?: number;\n labels?: boolean;\n compact?: boolean;\n}\n\n/** Read tier-1 layout values from a UILayoutConfig. */\nexport function layoutToValues(\n layout: UILayoutConfig | undefined,\n): LayoutFormValues {\n return {\n direction: layout?.direction,\n gap: layout?.gap,\n labels: layout?.labels,\n compact: layout?.compact,\n };\n}\n\n/**\n * Merge tier-1 form values back into an existing layout, preserving keys the\n * tier-1 form does not manage (e.g. rows, columns). Empty/undefined clears the\n * managed key. Returns undefined when the result is empty.\n */\nexport function valuesToLayout(\n values: LayoutFormValues,\n existing: UILayoutConfig | undefined,\n): UILayoutConfig | undefined {\n const next: UILayoutConfig = { ...(existing ?? {}) };\n\n if (values.direction === \"vertical\" || values.direction === \"horizontal\") {\n next.direction = values.direction;\n } else {\n delete next.direction;\n }\n if (typeof values.gap === \"number\" && !Number.isNaN(values.gap)) {\n next.gap = values.gap;\n } else {\n delete next.gap;\n }\n if (typeof values.labels === \"boolean\") next.labels = values.labels;\n else delete next.labels;\n if (typeof values.compact === \"boolean\") next.compact = values.compact;\n else delete next.compact;\n\n return Object.keys(next).length > 0 ? next : undefined;\n}\n\n/** Global options meta-schema (x-ui-globalOptions -- applies to all fields). */\nexport function buildGlobalOptionsMetaSchema(): JsonSchema {\n return {\n title: \"\",\n type: \"object\",\n properties: {\n disabled: { type: \"boolean\", title: \"Disable all fields\" },\n readonly: { type: \"boolean\", title: \"Read-only all fields\" },\n hideLabels: {\n type: \"boolean\",\n title: \"Hide all labels\",\n description: \"Sets label: false on every field.\",\n },\n compact: { type: \"boolean\", title: \"Compact all fields\" },\n },\n };\n}\n\n/** Flat form values for the global-options meta-schema. */\nexport interface GlobalOptionsFormValues {\n disabled?: boolean;\n readonly?: boolean;\n hideLabels?: boolean;\n compact?: boolean;\n}\n\n/** Read global-options form values from a UISchemaOptions object. */\nexport function globalOptionsToValues(\n options: UISchemaOptions | undefined,\n): GlobalOptionsFormValues {\n return {\n disabled: options?.disabled,\n readonly: options?.readonly,\n hideLabels: options?.label === false,\n compact: options?.compact,\n };\n}\n\n/** Merge global-options form values into a UISchemaOptions; undefined if empty. */\nexport function valuesToGlobalOptions(\n values: GlobalOptionsFormValues,\n): UISchemaOptions | undefined {\n const next: UISchemaOptions = {};\n if (values.disabled) next.disabled = true;\n if (values.readonly) next.readonly = true;\n if (values.hideLabels) next.label = false;\n if (values.compact) next.compact = true;\n return Object.keys(next).length > 0 ? next : undefined;\n}\n","/**\n * PropertyTree -- the left pane. Renders the schema's properties as a\n * hierarchical list with select / add / delete / reorder. Row idiom matches\n * graph-model/TypeDetailPanel for cross-editor consistency.\n */\n\nimport React, { useEffect, useRef, useState } from \"react\";\nimport { cn } from \"@petrarca/sonnet-core\";\nimport { IconButton, Input } from \"@petrarca/sonnet-ui\";\nimport {\n Plus,\n Trash2,\n ChevronUp,\n ChevronDown,\n PanelLeftClose,\n Lock,\n} from \"lucide-react\";\nimport type { DesignerState } from \"../hooks/useDesignerState\";\nimport { buildPropertyTree, type PropertyNode } from \"../model/view\";\nimport { pathKey, samePath } from \"../model/paths\";\n\nexport interface PropertyTreeProps {\n state: DesignerState;\n /** When provided, renders a collapse button in the header. */\n onCollapse?: () => void;\n}\n\nexport function PropertyTree({\n state,\n onCollapse,\n}: PropertyTreeProps): React.ReactElement {\n const nodes = buildPropertyTree(state.schema);\n\n return (\n <div>\n <div className=\"mb-2 flex items-center gap-2\">\n <span className=\"heading-meta\">Properties</span>\n <span className=\"ml-auto flex gap-1\">\n {state.canAddChild([]) && (\n <IconButton\n label=\"Add property\"\n onClick={() => state.addProperty([], \"scalar\")}\n >\n <Plus />\n </IconButton>\n )}\n {onCollapse && (\n <IconButton label=\"Collapse properties\" onClick={onCollapse}>\n <PanelLeftClose />\n </IconButton>\n )}\n </span>\n </div>\n\n {nodes.length === 0 ? (\n <p className=\"text-xs text-muted-foreground\">No properties yet.</p>\n ) : (\n <div className=\"rounded-lg border divide-y\">\n {nodes.map((node) => (\n <PropertyRow\n key={pathKey(node.path)}\n node={node}\n state={state}\n depth={0}\n />\n ))}\n </div>\n )}\n </div>\n );\n}\n\n// Inline key editor: an input seeded with the current key, committing on Enter\n// or blur and cancelling on Escape.\nfunction NameEditor({\n initial,\n onCommit,\n onCancel,\n}: {\n initial: string;\n onCommit: (next: string) => void;\n onCancel: () => void;\n}): React.ReactElement {\n const [value, setValue] = useState(initial);\n const ref = useRef<HTMLInputElement>(null);\n useEffect(() => {\n ref.current?.focus();\n ref.current?.select();\n }, []);\n const commit = () => {\n const trimmed = value.trim();\n if (trimmed && trimmed !== initial) onCommit(trimmed);\n else onCancel();\n };\n return (\n <Input\n ref={ref}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onClick={(e) => e.stopPropagation()}\n onBlur={commit}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n commit();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n onCancel();\n }\n }}\n className=\"h-6 text-sm py-0\"\n />\n );\n}\n\n// The property name + optional lock/required markers + type label.\nfunction RowLabel({\n node,\n editable,\n onStartRename,\n}: {\n node: PropertyNode;\n editable: boolean;\n onStartRename: (e: React.MouseEvent) => void;\n}): React.ReactElement {\n const title = editable\n ? `${node.key}${node.required ? \" (required)\" : \"\"} -- double-click to rename`\n : `${node.key} -- fixed (not editable)`;\n return (\n <>\n <span\n className=\"flex-1 min-w-0 truncate text-sm font-medium\"\n onDoubleClick={onStartRename}\n title={title}\n >\n {node.key}\n {node.required && (\n <span className=\"ml-0.5 text-destructive\" aria-label=\"required\">\n *\n </span>\n )}\n </span>\n {!editable && (\n <Lock\n className=\"h-3 w-3 shrink-0 text-muted-foreground/50\"\n aria-label=\"fixed\"\n />\n )}\n <span\n className=\"shrink-0 max-w-[45%] truncate font-mono text-[11px] text-muted-foreground/70 group-hover/row:hidden\"\n title={node.typeLabel}\n >\n {node.typeLabel}\n </span>\n </>\n );\n}\n\n// Hover-revealed row actions (move / add child / delete), gated by editability.\nfunction RowActions({\n node,\n state,\n editable,\n canAddHere,\n}: {\n node: PropertyNode;\n state: DesignerState;\n editable: boolean;\n canAddHere: boolean;\n}): React.ReactElement {\n return (\n <>\n {editable && (\n <>\n <IconButton\n label=\"Move up\"\n revealOnHover\n onClick={(e) => {\n e.stopPropagation();\n state.moveProperty(node.path, -1);\n }}\n >\n <ChevronUp />\n </IconButton>\n <IconButton\n label=\"Move down\"\n revealOnHover\n onClick={(e) => {\n e.stopPropagation();\n state.moveProperty(node.path, 1);\n }}\n >\n <ChevronDown />\n </IconButton>\n </>\n )}\n {canAddHere && (\n <IconButton\n label=\"Add child property\"\n revealOnHover\n onClick={(e) => {\n e.stopPropagation();\n state.addProperty(node.path, \"scalar\");\n }}\n >\n <Plus />\n </IconButton>\n )}\n {editable && (\n <IconButton\n label=\"Delete property\"\n tone=\"destructive\"\n revealOnHover\n onClick={(e) => {\n e.stopPropagation();\n state.deleteProperty(node.path);\n }}\n >\n <Trash2 />\n </IconButton>\n )}\n </>\n );\n}\n\nfunction PropertyRow({\n node,\n state,\n depth,\n}: {\n node: PropertyNode;\n state: DesignerState;\n depth: number;\n}): React.ReactElement {\n const selected = samePath(state.selection, node.path);\n const [editing, setEditing] = useState(false);\n\n // Scoped/readOnly gating: a fixed property shows no edit affordances (and a\n // lock indicator); \"add child\" follows canAddChild for containers.\n const editable = state.canEditProperty(node.path);\n const canAddHere =\n (node.kind === \"object\" || node.kind === \"array\") &&\n state.canAddChild(node.path);\n const showActions = editable || canAddHere;\n\n const startRename = (e: React.MouseEvent) => {\n e.stopPropagation();\n if (editable) setEditing(true);\n };\n\n return (\n <>\n <div\n className={cn(\n \"group/row relative flex items-center gap-2 px-3 py-2 cursor-pointer\",\n selected && \"bg-accent\",\n )}\n style={{ paddingLeft: 12 + depth * 16 }}\n onClick={() => state.select(node.path)}\n >\n {editing ? (\n <NameEditor\n initial={node.key}\n onCommit={(next) => {\n setEditing(false);\n state.renameProperty(node.path, next);\n }}\n onCancel={() => setEditing(false)}\n />\n ) : (\n <RowLabel\n node={node}\n editable={editable}\n onStartRename={startRename}\n />\n )}\n {showActions && !editing && (\n // Absolutely positioned so the buttons do not reserve row width at\n // rest -- the name/type use the full row. The actions overlay the\n // right edge; each button reveals on hover via revealOnHover. The\n // background is applied only on hover so it does not cover the type\n // label at rest (accent for the selected row, background otherwise).\n <span\n className={cn(\n \"absolute right-2 flex gap-0.5 rounded-md pl-2\",\n selected\n ? \"group-hover/row:bg-accent\"\n : \"group-hover/row:bg-background\",\n )}\n >\n <RowActions\n node={node}\n state={state}\n editable={editable}\n canAddHere={canAddHere}\n />\n </span>\n )}\n </div>\n {node.children.map((child) => (\n <PropertyRow\n key={pathKey(child.path)}\n node={child}\n state={state}\n depth={depth + 1}\n />\n ))}\n </>\n );\n}\n","/**\n * PreviewPane -- the center pane. Tabs: Form (live rendered form), JSON Schema\n * (the data model), and UI Schema (the presentation map). The form is the\n * universal sanity check; the two JSON views are read-only.\n *\n * Additional renderers (table, tree, detail) plug in as more tabs without\n * touching this contract -- each takes the same schema + uiSchema + data.\n */\n\nimport React, { useMemo, useState } from \"react\";\nimport { Check, Copy } from \"lucide-react\";\nimport {\n Button,\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n TabsSeparator,\n} from \"@petrarca/sonnet-ui\";\nimport { JsonEditor } from \"@petrarca/sonnet-ui/json-editor\";\nimport { JsonSchemaFormRenderer } from \"@petrarca/sonnet-forms\";\nimport { extractSchemaDefaults } from \"@petrarca/sonnet-core/schema\";\nimport { copyTextToClipboard } from \"@petrarca/sonnet-core\";\nimport { embedUiSchema } from \"../model/embed\";\nimport type { DesignerState } from \"../hooks/useDesignerState\";\nimport { TablePreview } from \"./TablePreview\";\nimport { FormLayoutDesigner } from \"../designers/FormLayoutDesigner\";\nimport { CapabilitiesPanel } from \"./CapabilitiesPanel\";\nimport type { SchemaDesignerCapabilities } from \"../capabilities\";\n\nexport interface PreviewPaneProps {\n state: DesignerState;\n /** The current (editable) capabilities profile. */\n capabilities?: SchemaDesignerCapabilities;\n /** Apply an edited profile (from the Capabilities tab). */\n onCapabilitiesChange?: (next: SchemaDesignerCapabilities) => void;\n}\n\n// Read-only, scrollable JSON view with a copy-to-clipboard button. Bounds the\n// CodeMirror height so it scrolls internally instead of growing to content.\nfunction ReadonlyJson({ value }: { value: string }): React.ReactElement {\n const [copied, setCopied] = useState(false);\n\n const handleCopy = () => {\n void copyTextToClipboard(value).then(() => {\n setCopied(true);\n setTimeout(() => setCopied(false), 1500);\n });\n };\n\n return (\n <div className=\"absolute inset-0 rounded-md border overflow-hidden\">\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={handleCopy}\n className=\"absolute right-2 top-2 z-10 gap-1.5\"\n >\n {copied ? (\n <Check className=\"h-3.5 w-3.5\" />\n ) : (\n <Copy className=\"h-3.5 w-3.5\" />\n )}\n {copied ? \"Copied\" : \"Copy\"}\n </Button>\n <JsonEditor key={value} value={value} editablePaths={[]} fillContainer />\n </div>\n );\n}\n\ninterface TabFlags {\n isFull: boolean;\n showForm: boolean;\n showTable: boolean;\n showJson: boolean;\n showCapabilities: boolean;\n}\n\nfunction PreviewTabList({ flags }: { flags: TabFlags }): React.ReactElement {\n return (\n <TabsList className=\"mb-3\">\n {flags.showForm && <TabsTrigger value=\"form\">Form</TabsTrigger>}\n {flags.isFull && flags.showForm && (\n <TabsTrigger value=\"layout\">Form Layout</TabsTrigger>\n )}\n {flags.showTable && <TabsTrigger value=\"table\">Table</TabsTrigger>}\n <TabsSeparator />\n {flags.showJson && <TabsTrigger value=\"schema\">JSON Schema</TabsTrigger>}\n {flags.isFull && <TabsTrigger value=\"ui\">UI Schema</TabsTrigger>}\n {flags.isFull && <TabsTrigger value=\"combined\">Combined</TabsTrigger>}\n {flags.showCapabilities && (\n <>\n <TabsSeparator />\n <TabsTrigger value=\"capabilities\">Capabilities</TabsTrigger>\n </>\n )}\n </TabsList>\n );\n}\n\nexport function PreviewPane({\n state,\n capabilities,\n onCapabilitiesChange,\n}: PreviewPaneProps): React.ReactElement {\n const { schema, uiSchema } = state;\n const caps = state.capabilities;\n const flags: TabFlags = {\n isFull: caps.mode === \"full\",\n showForm: caps.previews.includes(\"form\"),\n showTable: caps.previews.includes(\"table\"),\n showJson: caps.previews.includes(\"json\"),\n showCapabilities: caps.showCapabilities,\n };\n\n const [data, setData] = useState<Record<string, unknown>>(() =>\n extractSchemaDefaults(schema),\n );\n\n const schemaText = useMemo(() => JSON.stringify(schema, null, 2), [schema]);\n const uiSchemaText = useMemo(\n () => JSON.stringify(uiSchema ?? {}, null, 2),\n [uiSchema],\n );\n const embeddedText = useMemo(\n () => JSON.stringify(embedUiSchema(schema, uiSchema ?? {}), null, 2),\n [schema, uiSchema],\n );\n\n // Default to the first available tab so it always resolves to something shown.\n const defaultTab = flags.showForm\n ? \"form\"\n : flags.showTable\n ? \"table\"\n : \"schema\";\n\n return (\n <Tabs defaultValue={defaultTab} className=\"flex flex-col h-full min-h-0\">\n <PreviewTabList flags={flags} />\n {flags.showForm && (\n <TabsContent value=\"form\" className=\"flex-1 min-h-0 overflow-auto\">\n <JsonSchemaFormRenderer\n schema={schema}\n data={data}\n uiSchema={uiSchema}\n onChange={setData}\n showActions={false}\n showExtraProperties={false}\n />\n </TabsContent>\n )}\n {flags.isFull && flags.showForm && (\n <TabsContent value=\"layout\" className=\"flex-1 min-h-0 overflow-hidden\">\n <FormLayoutDesigner state={state} />\n </TabsContent>\n )}\n {flags.showTable && (\n <TabsContent value=\"table\" className=\"flex-1 min-h-0 overflow-auto\">\n <TablePreview schema={schema} />\n </TabsContent>\n )}\n <SourceTabPanels\n flags={flags}\n schemaText={schemaText}\n uiSchemaText={uiSchemaText}\n embeddedText={embeddedText}\n capabilities={capabilities}\n onCapabilitiesChange={onCapabilitiesChange}\n />\n </Tabs>\n );\n}\n\n// The source-artifact panels (JSON Schema / UI Schema / Combined) plus the\n// optional Capabilities editor. Split out to keep PreviewPane's complexity low.\nfunction SourceTabPanels({\n flags,\n schemaText,\n uiSchemaText,\n embeddedText,\n capabilities,\n onCapabilitiesChange,\n}: {\n flags: TabFlags;\n schemaText: string;\n uiSchemaText: string;\n embeddedText: string;\n capabilities?: SchemaDesignerCapabilities;\n onCapabilitiesChange?: (next: SchemaDesignerCapabilities) => void;\n}): React.ReactElement {\n return (\n <>\n {flags.showJson && (\n <TabsContent value=\"schema\" className=\"flex-1 min-h-0 relative\">\n <ReadonlyJson value={schemaText} />\n </TabsContent>\n )}\n {flags.isFull && (\n <TabsContent value=\"ui\" className=\"flex-1 min-h-0 relative\">\n <ReadonlyJson value={uiSchemaText} />\n </TabsContent>\n )}\n {flags.isFull && (\n <TabsContent value=\"combined\" className=\"flex-1 min-h-0 relative\">\n <ReadonlyJson value={embeddedText} />\n </TabsContent>\n )}\n {flags.showCapabilities && (\n <TabsContent value=\"capabilities\" className=\"flex-1 min-h-0 relative\">\n <CapabilitiesPanel\n capabilities={capabilities}\n onApply={onCapabilitiesChange}\n />\n </TabsContent>\n )}\n </>\n );\n}\n","/**\n * TablePreview -- renders the schema as an EntityTable using auto-generated\n * sample rows. Columns and cells come from the resolver's defaults plus any\n * x-ui-column / x-ui-cell hints embedded in the schema.\n */\n\nimport React, { useMemo } from \"react\";\nimport { EntityTable, type TableUiSchema } from \"@petrarca/sonnet-ui\";\nimport { toPageResult } from \"@petrarca/sonnet-core\";\nimport type { JsonSchema } from \"@petrarca/sonnet-core/schema\";\nimport { sampleRows } from \"./sampleRows\";\n\nexport interface TablePreviewProps {\n schema: JsonSchema;\n uiSchema?: TableUiSchema;\n}\n\nexport function TablePreview({\n schema,\n uiSchema,\n}: TablePreviewProps): React.ReactElement {\n const data = useMemo(() => toPageResult(sampleRows(schema)), [schema]);\n\n return (\n <EntityTable\n schema={schema}\n uiSchema={uiSchema}\n data={data}\n isLoading={false}\n isError={false}\n entityLabel=\"rows\"\n />\n );\n}\n","/**\n * Generate plausible sample rows from a JsonSchema, for the table preview.\n *\n * Pure. Produces a few rows with a value per top-level property, chosen by\n * type / format / enum so the table shows realistic content. Nested objects and\n * arrays get simple placeholders (tables typically show scalar columns; the\n * cell renderer decides how to display the rest).\n */\n\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n} from \"@petrarca/sonnet-core/schema\";\n\ntype Row = Record<string, unknown>;\n\nfunction sampleString(\n prop: JsonSchemaProperty,\n key: string,\n i: number,\n): string {\n switch (prop.format) {\n case \"email\":\n return `user${i + 1}@example.com`;\n case \"date\":\n return `2024-0${(i % 9) + 1}-15`;\n case \"date-time\":\n return `2024-0${(i % 9) + 1}-15T09:30:00Z`;\n case \"uri\":\n case \"url\":\n return `https://example.com/${key}/${i + 1}`;\n case \"uuid\":\n return `00000000-0000-4000-8000-00000000000${i + 1}`;\n default:\n return `${titleCase(key)} ${i + 1}`;\n }\n}\n\nfunction titleCase(key: string): string {\n const s = key.replace(/[_-]+/g, \" \").trim();\n return s.charAt(0).toUpperCase() + s.slice(1);\n}\n\nfunction sampleValue(\n prop: JsonSchemaProperty,\n key: string,\n i: number,\n): unknown {\n if (Array.isArray(prop.enum) && prop.enum.length > 0) {\n return prop.enum[i % prop.enum.length];\n }\n switch (prop.type) {\n case \"string\":\n return sampleString(prop, key, i);\n case \"number\":\n return Math.round((i + 1) * 1.5 * 100) / 100;\n case \"integer\":\n return i + 1;\n case \"boolean\":\n return i % 2 === 0;\n case \"array\":\n return [];\n case \"object\":\n return {};\n default:\n return null;\n }\n}\n\n/** Build `count` sample rows for a schema's top-level properties. */\nexport function sampleRows(schema: JsonSchema, count = 3): Row[] {\n const entries = Object.entries(schema.properties);\n return Array.from({ length: count }, (_, i) => {\n const row: Row = {};\n for (const [key, prop] of entries) {\n row[key] = sampleValue(prop, key, i);\n }\n return row;\n });\n}\n","/**\n * FormLayoutDesigner -- visual editor for the form's row layout\n * (x-ui-layout.rows). Two columns: an \"Available\" pool of unassigned top-level\n * properties (left) and the row designer (right). Properties are dragged\n * (native HTML5 DnD) between the pool and rows; rows can be added, removed,\n * reordered, and given a CSS grid-template-columns value.\n *\n * This is a bespoke visual designer (not a meta-schema form) -- the first of a\n * planned family of \"*Designer\" surfaces for spatial authoring tasks.\n */\n\nimport React, { useMemo, useState } from \"react\";\nimport { Input, IconButton, Button } from \"@petrarca/sonnet-ui\";\nimport { FormSelect, JsonSchemaFormRenderer } from \"@petrarca/sonnet-forms\";\nimport {\n Plus,\n Trash2,\n ChevronUp,\n ChevronDown,\n GripVertical,\n} from \"lucide-react\";\nimport {\n buildLayoutMetaSchema,\n layoutToValues,\n valuesToLayout,\n type LayoutFormValues,\n} from \"../inspector/layoutMetaSchemas\";\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n UILayoutConfig,\n UILayoutRowConfig,\n WidthToken,\n} from \"@petrarca/sonnet-core/schema\";\nimport type { DesignerState } from \"../hooks/useDesignerState\";\nimport { layoutScopes } from \"../model/view\";\nimport { getProperty } from \"../model/paths\";\n\nexport interface FormLayoutDesignerProps {\n state: DesignerState;\n}\n\nconst DRAG_MIME = \"application/x-sonnet-property\";\n\n// Ordered keys of a properties map, honoring x-ui-order.\nfunction orderedKeysOf(\n properties: Record<string, JsonSchemaProperty>,\n order: string[] | undefined,\n): string[] {\n const keys = Object.keys(properties);\n if (!order || order.length === 0) return keys;\n const inOrder = order.filter((k) => k in properties);\n return [...inOrder, ...keys.filter((k) => !inOrder.includes(k))];\n}\n\n// Resolve a scope path to its editable keys + current rows. Root (path []) uses\n// the schema + uiSchema[\"x-ui-layout\"]; a property scope uses the object (or\n// array items) property and its x-ui-layout.\n// The container property for a scope path: the object, or an array's items.\nfunction scopeTarget(\n schema: JsonSchema,\n scopePath: string[],\n): JsonSchemaProperty | undefined {\n const prop = getProperty(schema, scopePath);\n if (!prop) return undefined;\n return prop.type === \"array\" ? prop.items : prop;\n}\n\ninterface ResolvedScope {\n keys: string[];\n rows: UILayoutRowConfig[];\n layout: UILayoutConfig | undefined;\n /** True when the scope is an array property (scalar options apply). */\n isArray: boolean;\n}\n\nfunction resolveScope(\n schema: JsonSchema,\n uiSchema: DesignerState[\"uiSchema\"],\n scopePath: string[],\n): ResolvedScope {\n // Container source: the schema itself (root) or the scope's object/items.\n const container: JsonSchema | JsonSchemaProperty | undefined =\n scopePath.length === 0 ? schema : scopeTarget(schema, scopePath);\n const layout = (\n scopePath.length === 0\n ? uiSchema[\"x-ui-layout\"]\n : container?.[\"x-ui-layout\"]\n ) as UILayoutConfig | undefined;\n const isArray = scopeIsArray(schema, scopePath);\n return {\n keys: orderedKeysOf(container?.properties ?? {}, container?.[\"x-ui-order\"]),\n rows: layout?.rows ?? [],\n layout,\n isArray,\n };\n}\n\n// Whether the scope path points at an array property.\nfunction scopeIsArray(schema: JsonSchema, scopePath: string[]): boolean {\n if (scopePath.length === 0) return false;\n return getProperty(schema, scopePath)?.type === \"array\";\n}\n\n// Array item layout options (direction/gap/labels/compact), laid out on one\n// row via the renderer's own x-ui-layout so it matches form styling.\nconst SCALAR_META_SCHEMA = buildLayoutMetaSchema();\nconst SCALAR_UI_SCHEMA = {\n \"x-ui-layout\": {\n labelPlacement: \"start\" as const,\n // Flow row: controls sit left-to-right at their natural width (label hugs\n // control via horizontal labelPlacement), wrapping as needed.\n rows: [\n {\n fields: [\"direction\", \"gap\", \"labels\", \"compact\"],\n arrange: \"flow\" as const,\n gap: 16,\n },\n ],\n compact: true,\n },\n // Per-field widths for the toolbar. Top-level fields take their per-field\n // uiSchema directly under the field name. Direction (a select) gets more\n // room; the numeric Gap input stays narrow.\n direction: { \"x-ui-width\": \"lg\" as const },\n gap: { \"x-ui-width\": \"sm\" as const },\n};\n\nfunction scalarsFrom(\n values: LayoutFormValues,\n): Pick<UILayoutConfig, \"direction\" | \"gap\" | \"labels\" | \"compact\"> {\n const full = valuesToLayout(values, undefined) ?? {};\n return {\n direction: full.direction,\n gap: full.gap,\n labels: full.labels,\n compact: full.compact,\n };\n}\n\n// The array item layout options bar -- a horizontally-laid-out rendered form.\nfunction ArrayItemLayoutBar({\n layout,\n readOnly,\n onChange,\n}: {\n layout: UILayoutConfig | undefined;\n readOnly: boolean;\n onChange: (\n opts: Pick<UILayoutConfig, \"direction\" | \"gap\" | \"labels\" | \"compact\">,\n ) => void;\n}): React.ReactElement {\n return (\n <div className=\"shrink-0 rounded-lg border p-3\">\n <p className=\"heading-meta mb-2\">Array item layout</p>\n <JsonSchemaFormRenderer\n schema={SCALAR_META_SCHEMA}\n uiSchema={SCALAR_UI_SCHEMA}\n data={layoutToValues(layout) as unknown as Record<string, unknown>}\n onChange={(data) => onChange(scalarsFrom(data as LayoutFormValues))}\n showActions={false}\n showExtraProperties={false}\n readOnly={readOnly}\n />\n </div>\n );\n}\n\nexport function FormLayoutDesigner({\n state,\n}: FormLayoutDesignerProps): React.ReactElement {\n const scopes = useMemo(() => layoutScopes(state.schema), [state.schema]);\n const [scopePath, setScopePath] = useState<string[]>([]);\n\n // Fall back to root if the selected scope no longer exists.\n const scopeKey = scopePath.join(\".\");\n const activeScope =\n scopes.find((s) => s.path.join(\".\") === scopeKey) ?? scopes[0];\n const effectivePath = activeScope.path;\n\n const {\n keys: allKeys,\n rows,\n layout,\n isArray,\n } = resolveScope(state.schema, state.uiSchema, effectivePath);\n\n const assigned = new Set(rows.flatMap((r) => r.fields));\n const available = allKeys.filter((k) => !assigned.has(k));\n\n const [dragKey, setDragKey] = useState<string | null>(null);\n\n const commit = (next: UILayoutRowConfig[]) =>\n state.setScopedLayoutRows(effectivePath, next);\n\n // Move a property into row `rowIndex` (or to the pool when rowIndex is null),\n // removing it from wherever it currently is. Empty rows are kept (they are\n // valid drop targets; the user removes rows explicitly).\n const place = (key: string, rowIndex: number | null) => {\n if (!key) return;\n const next = rows.map((r) => ({\n ...r,\n fields: r.fields.filter((f) => f !== key),\n }));\n if (rowIndex !== null && next[rowIndex]) {\n next[rowIndex] = {\n ...next[rowIndex],\n fields: [...next[rowIndex].fields, key],\n };\n }\n commit(next);\n };\n\n const addRow = () => commit([...rows, { fields: [] }]);\n const removeRow = (i: number) => commit(rows.filter((_, idx) => idx !== i));\n const moveRow = (i: number, dir: -1 | 1) => {\n const j = i + dir;\n if (j < 0 || j >= rows.length) return;\n const next = [...rows];\n [next[i], next[j]] = [next[j], next[i]];\n commit(next);\n };\n const setColumns = (i: number, columns: string) => {\n const next = rows.map((r, idx) =>\n idx === i ? { ...r, columns: columns.trim() ? columns : undefined } : r,\n );\n commit(next);\n };\n const setGroup = (i: number, group: string) => {\n const next = rows.map((r, idx) =>\n idx === i ? { ...r, group: group.trim() ? group : undefined } : r,\n );\n commit(next);\n };\n const setArrange = (i: number, arrange: \"grid\" | \"flow\") => {\n const next: UILayoutRowConfig[] = rows.map((r, idx) =>\n // \"grid\" is the default -- omit it to keep the config clean.\n idx === i\n ? { ...r, arrange: arrange === \"flow\" ? (\"flow\" as const) : undefined }\n : r,\n );\n commit(next);\n };\n const setWidth = (i: number, cell: number, width: WidthToken) => {\n const next = rows.map((r, idx) => {\n if (idx !== i) return r;\n const widths = [...(r.widths ?? [])];\n while (widths.length < r.fields.length) widths.push(\"full\");\n widths[cell] = width;\n // Drop the array entirely when every cell is the default \"full\".\n const allFull = widths.every((w) => w === \"full\");\n return { ...r, widths: allFull ? undefined : widths };\n });\n commit(next);\n };\n\n const readOnly = state.readOnly;\n\n return (\n <div className=\"flex flex-col gap-3 h-full min-h-0\">\n {/* Scope selector -- root form or a nested object/array container. */}\n <div className=\"flex items-center gap-2 shrink-0\">\n <label className=\"heading-meta\">Scope</label>\n <div className=\"w-64\">\n <FormSelect\n id=\"layout-scope\"\n name=\"scope\"\n value={effectivePath.join(\".\")}\n options={scopes.map((s) => ({\n value: s.path.join(\".\"),\n label: s.label,\n }))}\n onChange={(v: string | null) =>\n setScopePath(v ? v.split(\".\").filter(Boolean) : [])\n }\n clearable={false}\n />\n </div>\n </div>\n\n {/* Array-only layout options in a single compact row. The renderer honors\n these only for array-of-object layout, so they show only when the\n scope is an array. */}\n {isArray && (\n <ArrayItemLayoutBar\n layout={layout}\n readOnly={readOnly}\n onChange={(opts) => state.setScopedLayoutOptions(effectivePath, opts)}\n />\n )}\n\n <div className=\"flex gap-4 flex-1 min-h-0\">\n {/* Available pool */}\n <div className=\"w-56 shrink-0 flex flex-col min-h-0\">\n <p className=\"heading-meta mb-2\">Available</p>\n <div\n className=\"flex-1 min-h-0 overflow-auto rounded-lg border p-2 space-y-1 bg-muted/20\"\n onDragOver={(e) => {\n if (dragKey) e.preventDefault();\n }}\n onDrop={(e) => {\n const key = e.dataTransfer.getData(DRAG_MIME) || dragKey;\n if (key) place(key, null);\n }}\n >\n {available.length === 0 ? (\n <p className=\"text-xs text-muted-foreground p-1\">\n All properties are placed in rows.\n </p>\n ) : (\n available.map((key) => (\n <Chip\n key={key}\n label={key}\n readOnly={readOnly}\n onDragStart={() => setDragKey(key)}\n onDragEnd={() => setDragKey(null)}\n />\n ))\n )}\n </div>\n <p className=\"text-xs text-muted-foreground mt-2\">\n Unplaced properties render stacked below the rows.\n </p>\n </div>\n\n {/* Row designer */}\n <div className=\"flex-1 min-w-0 flex flex-col min-h-0\">\n <div className=\"mb-2 flex items-center gap-2\">\n <p className=\"heading-meta\">Rows</p>\n {!readOnly && (\n <span className=\"ml-auto\">\n <Button\n size=\"sm\"\n variant=\"outline\"\n className=\"gap-1.5\"\n onClick={addRow}\n >\n <Plus className=\"h-4 w-4\" />\n Add row\n </Button>\n </span>\n )}\n </div>\n <div className=\"flex-1 min-h-0 overflow-auto space-y-3\">\n {rows.length === 0 ? (\n <p className=\"text-sm text-muted-foreground\">\n No rows yet. Add a row, then drag properties into it.\n </p>\n ) : (\n rows.map((row, i) => (\n <RowCard\n key={i}\n row={row}\n index={i}\n total={rows.length}\n readOnly={readOnly}\n dragActive={!!dragKey}\n onDropKey={(key) => place(key ?? dragKey ?? \"\", i)}\n onRemoveKey={(key) => place(key, null)}\n onDragStartKey={(key) => setDragKey(key)}\n onDragEndKey={() => setDragKey(null)}\n onMoveUp={() => moveRow(i, -1)}\n onMoveDown={() => moveRow(i, 1)}\n onDelete={() => removeRow(i)}\n onColumns={(v) => setColumns(i, v)}\n onGroup={(v) => setGroup(i, v)}\n onWidth={(cell, w) => setWidth(i, cell, w)}\n onArrange={(a) => setArrange(i, a)}\n />\n ))\n )}\n </div>\n </div>\n </div>\n </div>\n );\n}\n\nconst WIDTH_LABELS: Record<WidthToken, string> = {\n full: \"Full\",\n sm: \"Small\",\n md: \"Medium\",\n lg: \"Large\",\n};\n\n// Compact single-letter labels for the inline per-property width selector.\nconst WIDTH_SHORT: Record<WidthToken, string> = {\n full: \"F\",\n sm: \"S\",\n md: \"M\",\n lg: \"L\",\n};\n\nfunction Chip({\n label,\n readOnly,\n onRemove,\n onDragStart,\n onDragEnd,\n width,\n onWidth,\n widthDisabled,\n}: {\n label: string;\n readOnly: boolean;\n onRemove?: () => void;\n onDragStart: () => void;\n onDragEnd: () => void;\n // When provided, the chip shows an inline width selector (row members only).\n width?: WidthToken;\n onWidth?: (width: WidthToken) => void;\n widthDisabled?: boolean;\n}): React.ReactElement {\n return (\n <div\n draggable={!readOnly}\n onDragStart={(e) => {\n e.dataTransfer.setData(DRAG_MIME, label);\n e.dataTransfer.effectAllowed = \"move\";\n onDragStart();\n }}\n onDragEnd={onDragEnd}\n className=\"group/chip flex items-center gap-1 rounded-md border bg-background px-2 py-1 text-sm cursor-grab active:cursor-grabbing\"\n >\n <GripVertical className=\"h-3.5 w-3.5 text-muted-foreground/60 shrink-0\" />\n <span className=\"truncate\">{label}</span>\n {onWidth && (\n <select\n value={width ?? \"full\"}\n onChange={(e) => onWidth(e.target.value as WidthToken)}\n disabled={readOnly || widthDisabled}\n title={\n widthDisabled ? \"Overridden by raw CSS columns\" : \"Column width\"\n }\n className=\"h-6 rounded border bg-background px-1 text-xs text-muted-foreground disabled:opacity-50\"\n >\n {([\"full\", \"sm\", \"md\", \"lg\"] as WidthToken[]).map((w) => (\n <option key={w} value={w} title={WIDTH_LABELS[w]}>\n {WIDTH_SHORT[w]}\n </option>\n ))}\n </select>\n )}\n {onRemove && !readOnly && (\n <IconButton label=\"Remove from row\" onClick={onRemove}>\n <Trash2 />\n </IconButton>\n )}\n </div>\n );\n}\n\nfunction RowCard({\n row,\n index,\n total,\n readOnly,\n dragActive,\n onDropKey,\n onRemoveKey,\n onDragStartKey,\n onDragEndKey,\n onMoveUp,\n onMoveDown,\n onDelete,\n onColumns,\n onGroup,\n onWidth,\n onArrange,\n}: {\n row: UILayoutRowConfig;\n index: number;\n total: number;\n readOnly: boolean;\n dragActive: boolean;\n onDropKey: (key: string | null) => void;\n onRemoveKey: (key: string) => void;\n onDragStartKey: (key: string) => void;\n onDragEndKey: () => void;\n onMoveUp: () => void;\n onMoveDown: () => void;\n onDelete: () => void;\n onColumns: (v: string) => void;\n onGroup: (v: string) => void;\n onWidth: (cell: number, width: WidthToken) => void;\n onArrange: (arrange: \"grid\" | \"flow\") => void;\n}): React.ReactElement {\n const [over, setOver] = useState(false);\n const isFlow = row.arrange === \"flow\";\n return (\n <div className=\"rounded-lg border p-3\">\n <div className=\"flex items-center gap-2 mb-2\">\n <span className=\"heading-meta\">Row {index + 1}</span>\n {!readOnly && (\n <span className=\"ml-auto flex gap-0.5\">\n <IconButton\n label=\"Move row up\"\n disabled={index === 0}\n onClick={onMoveUp}\n >\n <ChevronUp />\n </IconButton>\n <IconButton\n label=\"Move row down\"\n disabled={index === total - 1}\n onClick={onMoveDown}\n >\n <ChevronDown />\n </IconButton>\n <IconButton\n label=\"Delete row\"\n tone=\"destructive\"\n onClick={onDelete}\n >\n <Trash2 />\n </IconButton>\n </span>\n )}\n </div>\n\n <div className=\"mb-2 flex items-center gap-2\">\n <label className=\"text-xs text-muted-foreground w-16\">Group</label>\n <Input\n value={row.group ?? \"\"}\n onChange={(e) => onGroup(e.target.value)}\n placeholder=\"Section title (optional)\"\n disabled={readOnly}\n className=\"h-7 text-sm flex-1\"\n />\n </div>\n\n <div className=\"mb-2 flex items-center gap-2\">\n <label className=\"text-xs text-muted-foreground w-16\">Arrange</label>\n <select\n value={isFlow ? \"flow\" : \"grid\"}\n onChange={(e) => onArrange(e.target.value as \"grid\" | \"flow\")}\n disabled={readOnly}\n title=\"Grid: sized columns. Inline: fields at natural width, wrapping.\"\n className=\"h-7 rounded-md border bg-background px-2 text-sm text-foreground disabled:opacity-50\"\n >\n <option value=\"grid\">Grid (columns)</option>\n <option value=\"flow\">Inline (natural width)</option>\n </select>\n </div>\n\n <div\n className={`min-h-10 rounded-md border border-dashed p-2 flex flex-wrap gap-1 ${\n over && dragActive ? \"border-primary bg-accent\" : \"border-border\"\n }`}\n onDragOver={(e) => {\n if (dragActive) {\n e.preventDefault();\n setOver(true);\n }\n }}\n onDragLeave={() => setOver(false)}\n onDrop={(e) => {\n setOver(false);\n onDropKey(e.dataTransfer.getData(DRAG_MIME) || null);\n }}\n >\n {row.fields.length === 0 ? (\n <span className=\"text-xs text-muted-foreground p-1\">\n Drop properties here\n </span>\n ) : (\n row.fields.map((key, cell) => (\n <Chip\n key={key}\n label={key}\n readOnly={readOnly}\n onRemove={() => onRemoveKey(key)}\n onDragStart={() => onDragStartKey(key)}\n onDragEnd={onDragEndKey}\n width={row.widths?.[cell] ?? \"full\"}\n onWidth={isFlow ? undefined : (w) => onWidth(cell, w)}\n widthDisabled={!!row.columns}\n />\n ))\n )}\n </div>\n\n {/* Advanced: raw CSS grid columns. Grid mode only -- ignored in flow. */}\n {!isFlow && (\n <details className=\"mt-2\">\n <summary className=\"cursor-pointer text-xs text-muted-foreground\">\n Advanced: raw CSS columns\n </summary>\n <div className=\"mt-2 flex items-center gap-2\">\n <label className=\"text-xs text-muted-foreground w-16\">\n Columns\n </label>\n <Input\n value={row.columns ?? \"\"}\n onChange={(e) => onColumns(e.target.value)}\n placeholder=\"e.g. 1fr 1fr\"\n disabled={readOnly}\n className=\"h-7 text-sm flex-1\"\n />\n </div>\n <p className=\"mt-1 pl-[4.5rem] text-xs text-muted-foreground\">\n Raw <span className=\"font-mono\">grid-template-columns</span>. When\n set, it overrides the per-property widths. Blank = use widths.\n </p>\n </details>\n )}\n </div>\n );\n}\n","/**\n * CapabilitiesPanel -- edits the SchemaDesignerCapabilities profile as JSON and\n * applies it live. A dev / power-user affordance shown only when the profile\n * lists \"capabilities\" in previews. Validates via `validateCapabilities` before\n * applying; invalid JSON or an invalid profile surfaces an inline error.\n */\n\nimport React, { useEffect, useState } from \"react\";\nimport { Button } from \"@petrarca/sonnet-ui\";\nimport { JsonEditor } from \"@petrarca/sonnet-ui/json-editor\";\nimport {\n validateCapabilities,\n type SchemaDesignerCapabilities,\n} from \"../capabilities\";\n\nexport interface CapabilitiesPanelProps {\n capabilities?: SchemaDesignerCapabilities;\n onApply?: (next: SchemaDesignerCapabilities) => void;\n}\n\nexport function CapabilitiesPanel({\n capabilities,\n onApply,\n}: CapabilitiesPanelProps): React.ReactElement {\n const [text, setText] = useState(() =>\n JSON.stringify(capabilities ?? {}, null, 2),\n );\n const [error, setError] = useState<string | null>(null);\n\n // Re-sync text when the parent changes capabilities (e.g. profile switcher).\n useEffect(() => {\n setText(JSON.stringify(capabilities ?? {}, null, 2));\n }, [capabilities]);\n\n const handleApply = () => {\n let parsed: unknown;\n try {\n parsed = JSON.parse(text || \"{}\");\n } catch {\n setError(\"Invalid JSON.\");\n return;\n }\n const result = validateCapabilities(parsed);\n if (!result.ok) {\n setError(result.errors.join(\"; \"));\n return;\n }\n setError(null);\n onApply?.(result.value);\n };\n\n return (\n <div className=\"absolute inset-0 flex flex-col gap-2\">\n <div className=\"flex items-center gap-2\">\n <p className=\"text-sm text-muted-foreground\">\n Edit the capability profile and apply it live.\n </p>\n <Button\n type=\"button\"\n size=\"sm\"\n onClick={handleApply}\n className=\"ml-auto\"\n >\n Apply\n </Button>\n </div>\n {error && <p className=\"text-sm font-medium text-destructive\">{error}</p>}\n <div className=\"relative flex-1 min-h-0 rounded-md border overflow-hidden\">\n <JsonEditor\n value={text}\n editablePaths={[\"/\"]}\n fillContainer\n onChange={setText}\n />\n </div>\n </div>\n );\n}\n","/**\n * Inspector -- the right pane. Resolves the selected property and hosts the tabbed\n * editors (Data now; UI and Layout added incrementally). Empty state when no\n * property is selected.\n */\n\nimport React, { useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n Tabs,\n TabsList,\n TabsTrigger,\n TabsContent,\n Input,\n IconButton,\n} from \"@petrarca/sonnet-ui\";\nimport { Pencil, Check, X } from \"lucide-react\";\nimport type { WidgetOptionDef } from \"@petrarca/sonnet-forms/widget-options\";\nimport type { DesignerState } from \"../hooks/useDesignerState\";\nimport { buildPropertyTree, type PropertyNode } from \"../model/view\";\nimport { samePath, type PropertyPath } from \"../model/paths\";\nimport { DataTab } from \"./DataTab\";\nimport { UITab } from \"./UITab\";\nimport { EnumEditor } from \"./EnumEditor\";\nimport { TableHintsTab } from \"./TableHintsTab\";\n\n// Property types for which a fixed enum makes sense.\nconst ENUM_CAPABLE_TYPES = new Set([\"string\", \"number\", \"integer\"]);\n\nexport interface InspectorProps {\n state: DesignerState;\n /** Option descriptors for custom widgets (merged over built-ins). */\n widgetOptions?: Record<string, WidgetOptionDef[]>;\n}\n\n// Property key display + explicit edit affordance. Shows the key as static text\n// with a small pencil button (matching the graph-model rename pattern). Clicking\n// edit reveals an input with confirm/cancel; commit routes to renameProperty.\nfunction KeyField({\n fieldKey,\n onRename,\n readOnly,\n}: {\n fieldKey: string;\n onRename: (next: string) => void;\n readOnly: boolean;\n}): React.ReactElement {\n const [editing, setEditing] = useState(false);\n const [value, setValue] = useState(fieldKey);\n const ref = useRef<HTMLInputElement>(null);\n\n // Re-seed and exit edit mode when the selected property changes.\n useEffect(() => {\n setValue(fieldKey);\n setEditing(false);\n }, [fieldKey]);\n\n useEffect(() => {\n if (editing) {\n ref.current?.focus();\n ref.current?.select();\n }\n }, [editing]);\n\n const commit = () => {\n const trimmed = value.trim();\n if (trimmed && trimmed !== fieldKey) onRename(trimmed);\n setEditing(false);\n };\n const cancel = () => {\n setValue(fieldKey);\n setEditing(false);\n };\n\n if (!editing) {\n return (\n <div className=\"flex items-center gap-1\">\n <span className=\"text-sm font-semibold truncate\">{fieldKey}</span>\n {!readOnly && (\n <IconButton label=\"Rename property\" onClick={() => setEditing(true)}>\n <Pencil />\n </IconButton>\n )}\n </div>\n );\n }\n\n return (\n <div className=\"flex items-center gap-1\">\n <Input\n ref={ref}\n value={value}\n onChange={(e) => setValue(e.target.value)}\n onKeyDown={(e) => {\n if (e.key === \"Enter\") {\n e.preventDefault();\n commit();\n } else if (e.key === \"Escape\") {\n e.preventDefault();\n cancel();\n }\n }}\n className=\"h-7 text-sm font-medium\"\n />\n <IconButton label=\"Confirm rename\" onClick={commit}>\n <Check />\n </IconButton>\n <IconButton label=\"Cancel rename\" onClick={cancel}>\n <X />\n </IconButton>\n </div>\n );\n}\n\n// Find the node for a path in the built tree.\nfunction findNode(\n nodes: PropertyNode[],\n path: PropertyPath,\n): PropertyNode | undefined {\n for (const node of nodes) {\n if (samePath(node.path, path)) return node;\n const inChild = findNode(node.children, path);\n if (inChild) return inChild;\n }\n return undefined;\n}\n\nexport function Inspector({\n state,\n widgetOptions,\n}: InspectorProps): React.ReactElement {\n const tree = useMemo(() => buildPropertyTree(state.schema), [state.schema]);\n const node = state.selection ? findNode(tree, state.selection) : undefined;\n\n if (!node) {\n return (\n <p className=\"text-sm text-muted-foreground\">\n Select a property to edit.\n </p>\n );\n }\n\n const enumCapable = ENUM_CAPABLE_TYPES.has(node.property.type ?? \"\");\n\n return (\n <div>\n <div className=\"mb-3 space-y-1\">\n <KeyField\n key={node.path.join(\".\")}\n fieldKey={node.key}\n readOnly={state.readOnly}\n onRename={(next) => state.renameProperty(node.path, next)}\n />\n <p className=\"font-mono text-xs text-muted-foreground\">\n {node.typeLabel}\n </p>\n </div>\n\n <Tabs key={`${node.path.join(\".\")}:${enumCapable}`} defaultValue=\"data\">\n <TabsList className=\"mb-3\">\n <TabsTrigger value=\"data\">Data</TabsTrigger>\n {enumCapable && <TabsTrigger value=\"enum\">Enum</TabsTrigger>}\n <TabsTrigger value=\"ui\">UI</TabsTrigger>\n <TabsTrigger value=\"table\">Table</TabsTrigger>\n </TabsList>\n <TabsContent value=\"data\">\n <DataTab node={node} state={state} />\n </TabsContent>\n {enumCapable && (\n <TabsContent value=\"enum\">\n <EnumEditor node={node} state={state} />\n </TabsContent>\n )}\n <TabsContent value=\"ui\">\n <UITab node={node} state={state} widgetOptions={widgetOptions} />\n </TabsContent>\n <TabsContent value=\"table\">\n <TableHintsTab node={node} state={state} />\n </TabsContent>\n </Tabs>\n </div>\n );\n}\n","/**\n * DataTab -- edits a property's data definition (type, title, description,\n * default, required, validation) via a meta-schema rendered with\n * JsonSchemaFormRenderer. Type and required are routed to dedicated mutations\n * (they reshape structure / live on the parent); the rest is a property patch.\n */\n\nimport React, { useMemo, useRef } from \"react\";\nimport { JsonSchemaFormRenderer } from \"@petrarca/sonnet-forms\";\nimport type { JsonSchemaProperty } from \"@petrarca/sonnet-core/schema\";\nimport type { DesignerState } from \"../hooks/useDesignerState\";\nimport type { PropertyNode } from \"../model/view\";\nimport {\n buildDataMetaSchema,\n dataValuesToPatch,\n propertyToDataValues,\n type DataFormValues,\n} from \"./metaSchemas\";\n\nexport interface DataTabProps {\n node: PropertyNode;\n state: DesignerState;\n}\n\nexport function DataTab({ node, state }: DataTabProps): React.ReactElement {\n const type = node.property.type ?? \"string\";\n const schema = useMemo(() => buildDataMetaSchema(type), [type]);\n const values = useMemo(\n () => propertyToDataValues(node.property, node.required),\n [node.property, node.required],\n );\n\n // Track previous values to detect which attribute changed.\n const prevRef = useRef<DataFormValues>(values);\n prevRef.current = values;\n\n const handleChange = (data: Record<string, unknown>) => {\n const next = data as unknown as DataFormValues;\n const prev = prevRef.current;\n\n // Each renderer onChange reflects a single attribute edit; route it to exactly\n // one mutation. Firing two mutations here would double-commit against the\n // same (pre-render) model and the second would clobber the first.\n\n // Type change reshapes the property.\n if (next.type !== prev.type) {\n state.changePropertyType(\n node.path,\n next.type as JsonSchemaProperty[\"type\"],\n );\n return;\n }\n // Required lives on the parent's required[], not on the property.\n if (next.required !== prev.required) {\n state.setRequired(node.path, !!next.required);\n return;\n }\n // Otherwise it is a property attribute change.\n state.updateProperty(node.path, dataValuesToPatch(next));\n };\n\n return (\n <JsonSchemaFormRenderer\n key={node.path.join(\".\") + \":\" + type}\n schema={schema}\n data={values as unknown as Record<string, unknown>}\n onChange={handleChange}\n showActions={false}\n showExtraProperties={false}\n readOnly={state.readOnly}\n />\n );\n}\n","/**\n * Meta-schemas -- JsonSchemas that describe a property definition, rendered by\n * JsonSchemaFormRenderer to produce the inspector's Data tab. Recomputed per\n * property type so only relevant validation constraints appear.\n *\n * This is the property-definition meta-schema (cf.\n * graph-model/PropertyFormSheet's buildSchema), kept in the designer for now.\n */\n\nimport type {\n JsonSchema,\n JsonSchemaProperty,\n} from \"@petrarca/sonnet-core/schema\";\n\nexport const PROPERTY_TYPES = [\n \"string\",\n \"number\",\n \"integer\",\n \"boolean\",\n \"object\",\n \"array\",\n] as const;\n\n/** The editable data-attributes of a property, as flat form data. */\nexport interface DataFormValues {\n type: string;\n title?: string;\n description?: string;\n default?: unknown;\n required: boolean;\n // validation\n minLength?: number;\n maxLength?: number;\n pattern?: string;\n format?: string;\n minimum?: number;\n maximum?: number;\n minItems?: number;\n maxItems?: number;\n}\n\nconst STRING_FORMATS = [\n \"\",\n \"email\",\n \"uri\",\n \"url\",\n \"date\",\n \"date-time\",\n \"time\",\n \"uuid\",\n];\n\n// Validation properties available per type.\nfunction validationProps(type: string): Record<string, JsonSchemaProperty> {\n switch (type) {\n case \"string\":\n return {\n format: { type: \"string\", title: \"Format\", enum: STRING_FORMATS },\n minLength: { type: \"integer\", title: \"Min length\", minimum: 0 },\n maxLength: { type: \"integer\", title: \"Max length\", minimum: 0 },\n pattern: { type: \"string\", title: \"Pattern (regex)\" },\n };\n case \"number\":\n case \"integer\":\n return {\n minimum: { type: \"number\", title: \"Minimum\" },\n maximum: { type: \"number\", title: \"Maximum\" },\n };\n case \"array\":\n return {\n minItems: { type: \"integer\", title: \"Min items\", minimum: 0 },\n maxItems: { type: \"integer\", title: \"Max items\", minimum: 0 },\n };\n default:\n return {};\n }\n}\n\n/**\n * Build the Data-tab meta-schema for a property of the given type. `isContainer`\n * (object/array) hides `default`, which is not meaningful there.\n */\nexport function buildDataMetaSchema(type: string): JsonSchema {\n const isContainer = type === \"object\" || type === \"array\";\n const properties: Record<string, JsonSchemaProperty> = {\n type: { type: \"string\", title: \"Type\", enum: [...PROPERTY_TYPES] },\n title: { type: \"string\", title: \"Label (title)\" },\n description: {\n type: \"string\",\n title: \"Description\",\n \"x-ui-widget\": \"textarea\",\n },\n required: { type: \"boolean\", title: \"Required\" },\n ...(isContainer ? {} : { default: { type: \"string\", title: \"Default\" } }),\n ...validationProps(type),\n };\n return { title: \"\", type: \"object\", properties };\n}\n\n/** Extract flat Data-tab form values from a property + its required flag. */\nexport function propertyToDataValues(\n prop: JsonSchemaProperty,\n required: boolean,\n): DataFormValues {\n return {\n type: prop.type ?? \"string\",\n title: prop.title,\n description: prop.description,\n default: prop.default,\n required,\n minLength: prop.minLength,\n maxLength: prop.maxLength,\n pattern: prop.pattern,\n format: prop.format,\n minimum: prop.minimum,\n maximum: prop.maximum,\n minItems: prop.minItems,\n maxItems: prop.maxItems,\n };\n}\n\n/**\n * Produce the property patch (excluding `type` and `required`, which are\n * handled separately) from Data-tab form values. Empty strings/undefined clear\n * the corresponding key.\n */\nexport function dataValuesToPatch(\n values: DataFormValues,\n): Partial<JsonSchemaProperty> {\n const patch: Partial<JsonSchemaProperty> = {};\n const setStr = (k: keyof JsonSchemaProperty, v: unknown) => {\n if (typeof v === \"string\" && v.length > 0)\n (patch as Record<string, unknown>)[k] = v;\n else (patch as Record<string, unknown>)[k] = undefined;\n };\n const setNum = (k: keyof JsonSchemaProperty, v: unknown) => {\n if (typeof v === \"number\" && !Number.isNaN(v))\n (patch as Record<string, unknown>)[k] = v;\n else (patch as Record<string, unknown>)[k] = undefined;\n };\n setStr(\"title\", values.title);\n setStr(\"description\", values.description);\n setStr(\"default\", values.default);\n setStr(\"format\", values.format);\n setStr(\"pattern\", values.pattern);\n setNum(\"minLength\", values.minLength);\n setNum(\"maxLength\", values.maxLength);\n setNum(\"minimum\", values.minimum);\n setNum(\"maximum\", values.maximum);\n setNum(\"minItems\", values.minItems);\n setNum(\"maxItems\", values.maxItems);\n return patch;\n}\n","/**\n * UITab -- edits a property's form presentation hints: the widget (x-ui-widget)\n * and its options (x-ui-options).\n *\n * The widget dropdown offers widgets compatible with the property's type (Auto\n * clears the override). The options editor is a JsonSchemaFormRenderer over a\n * schema derived from the selected widget's WidgetOptionDef[] (from the\n * design-time @petrarca/sonnet-forms/widget-options layer). Widgets with no\n * descriptor fall back to a raw JSON editor for x-ui-options.\n */\n\nimport React, { useMemo } from \"react\";\nimport { JsonSchemaFormRenderer } from \"@petrarca/sonnet-forms\";\nimport { JsonEditor } from \"@petrarca/sonnet-ui/json-editor\";\nimport {\n WIDGET_OPTION_DEFS,\n optionDefsToSchema,\n type WidgetOptionDef,\n} from \"@petrarca/sonnet-forms/widget-options\";\nimport { FormSelect } from \"@petrarca/sonnet-forms\";\nimport type {\n JsonSchema,\n UISchema,\n UISchemaOptions,\n UILayoutConfig,\n} from \"@petrarca/sonnet-core/schema\";\nimport type { DesignerState } from \"../hooks/useDesignerState\";\nimport type { PropertyNode } from \"../model/view\";\nimport { compatibleWidgets } from \"../model/compatibleWidgets\";\nimport { getUiEntryAtPath } from \"../model/mutate\";\n\nexport interface UITabProps {\n node: PropertyNode;\n state: DesignerState;\n /** Consumer-supplied option descriptors for custom widgets (merged over built-ins). */\n widgetOptions?: Record<string, WidgetOptionDef[]>;\n}\n\n// Meta-schema for the form presentation-text overrides. Keys are the actual\n// x-ui-* uiSchema keys so form data maps 1:1 to the entry.\nconst PRESENTATION_META_SCHEMA: JsonSchema = {\n title: \"\",\n type: \"object\",\n properties: {\n \"x-ui-title\": {\n type: \"string\",\n title: \"Label override\",\n description: \"Overrides the property title in the form.\",\n },\n \"x-ui-placeholder\": { type: \"string\", title: \"Placeholder\" },\n \"x-ui-description\": {\n type: \"string\",\n title: \"Help text\",\n \"x-ui-widget\": \"textarea\",\n },\n \"x-ui-width\": {\n type: \"string\",\n title: \"Field width\",\n description: \"Constrain the field's slot width in the form.\",\n enum: [\"full\", \"sm\", \"md\", \"lg\"],\n \"x-ui-options\": {\n enumNames: {\n full: \"Full width\",\n sm: \"Small\",\n md: \"Medium\",\n lg: \"Large\",\n },\n },\n },\n },\n};\n\n// Form presentation-text overrides (x-ui-title / x-ui-placeholder /\n// x-ui-description), written into the property's uiSchema entry.\nfunction PresentationEditor({\n fieldName,\n uiEntry,\n readOnly,\n onChange,\n}: {\n fieldName: string;\n uiEntry: UISchema;\n readOnly: boolean;\n onChange: (entry: UISchema) => void;\n}): React.ReactElement {\n const values = {\n \"x-ui-title\":\n typeof uiEntry[\"x-ui-title\"] === \"string\" ? uiEntry[\"x-ui-title\"] : \"\",\n \"x-ui-placeholder\": uiEntry[\"x-ui-placeholder\"] ?? \"\",\n \"x-ui-description\": uiEntry[\"x-ui-description\"] ?? \"\",\n \"x-ui-width\": uiEntry[\"x-ui-width\"] ?? \"full\",\n };\n\n const handleChange = (data: Record<string, unknown>) => {\n const next: UISchema = { ...uiEntry };\n for (const key of [\n \"x-ui-title\",\n \"x-ui-placeholder\",\n \"x-ui-description\",\n ] as const) {\n const v = data[key];\n if (typeof v === \"string\" && v.length > 0) next[key] = v;\n else delete next[key];\n }\n // Width: \"full\" is the default -- omit it to keep the uiSchema clean.\n const width = data[\"x-ui-width\"];\n if (width === \"sm\" || width === \"md\" || width === \"lg\") {\n next[\"x-ui-width\"] = width;\n } else {\n delete next[\"x-ui-width\"];\n }\n onChange(next);\n };\n\n return (\n <div>\n <p className=\"heading-meta mb-2\">Presentation (form overrides)</p>\n <JsonSchemaFormRenderer\n key={`${fieldName}:text`}\n schema={PRESENTATION_META_SCHEMA}\n data={values as Record<string, unknown>}\n onChange={handleChange}\n showActions={false}\n showExtraProperties={false}\n readOnly={readOnly}\n />\n </div>\n );\n}\n\n// Options editor: a generated form when the widget has descriptors, else a raw\n// JSON fallback. Kept separate to bound UITab's complexity.\nfunction OptionsEditor({\n widget,\n optionsSchema,\n currentOptions,\n readOnly,\n onChange,\n}: {\n widget: string;\n optionsSchema: JsonSchema | null;\n currentOptions: UISchemaOptions;\n readOnly: boolean;\n onChange: (opts: Record<string, unknown>) => void;\n}): React.ReactElement {\n if (optionsSchema) {\n return (\n <div>\n <p className=\"heading-meta mb-2\">Options</p>\n <JsonSchemaFormRenderer\n key={widget}\n schema={optionsSchema}\n data={currentOptions as Record<string, unknown>}\n onChange={onChange}\n showActions={false}\n showExtraProperties={false}\n readOnly={readOnly}\n />\n </div>\n );\n }\n return (\n <div>\n <p className=\"heading-meta mb-2\">Options (raw JSON)</p>\n <JsonEditor\n value={JSON.stringify(currentOptions ?? {}, null, 2)}\n editablePaths={readOnly ? [] : [\"/\"]}\n height=\"180px\"\n className=\"rounded-md border overflow-hidden\"\n onChange={(text) => {\n try {\n onChange(JSON.parse(text) as Record<string, unknown>);\n } catch {\n // ignore invalid JSON while typing\n }\n }}\n />\n </div>\n );\n}\n\nexport function UITab({\n node,\n state,\n widgetOptions,\n}: UITabProps): React.ReactElement {\n const pathKey = node.path.join(\".\");\n const uiEntry: UISchema = getUiEntryAtPath(state.uiSchema, node.path) ?? {};\n const currentWidget =\n typeof uiEntry[\"x-ui-widget\"] === \"string\"\n ? (uiEntry[\"x-ui-widget\"] as string)\n : null;\n const currentOptions = (uiEntry[\"x-ui-options\"] as UISchemaOptions) ?? {};\n\n // The form-level default this field inherits when it has no own override.\n const rootLayout = state.uiSchema[\"x-ui-layout\"] as\n | UILayoutConfig\n | undefined;\n const inheritedLabelPlacement = rootLayout?.labelPlacement ?? \"top\";\n\n const widgetChoices = useMemo(\n () => compatibleWidgets(node.property),\n [node.property],\n );\n\n const optionsSchema: JsonSchema | null = useMemo(() => {\n if (!currentWidget) return null;\n const merged = { ...WIDGET_OPTION_DEFS, ...(widgetOptions ?? {}) };\n const descriptors = merged[currentWidget];\n return descriptors && descriptors.length\n ? optionDefsToSchema(descriptors)\n : null;\n }, [currentWidget, widgetOptions]);\n\n const setWidget = (value: string | null) => {\n const next: UISchema = { ...uiEntry };\n if (value) next[\"x-ui-widget\"] = value;\n else delete next[\"x-ui-widget\"];\n state.setUiEntry(node.path, next);\n };\n\n const setOptions = (opts: Record<string, unknown>) => {\n const next: UISchema = { ...uiEntry };\n const cleaned = Object.fromEntries(\n Object.entries(opts).filter(([, v]) => v !== undefined && v !== \"\"),\n );\n if (Object.keys(cleaned).length) next[\"x-ui-options\"] = cleaned;\n else delete next[\"x-ui-options\"];\n state.setUiEntry(node.path, next);\n };\n\n // Label placement lives on x-ui-options. Three states in the UI:\n // \"__inherit__\" -> no key set; the field inherits the form-level default.\n // \"top\" / \"start\" -> an explicit per-field override.\n // Only an explicit value writes the key (and prunes an emptied x-ui-options).\n const setLabelPlacement = (value: string) => {\n const opts: UISchemaOptions = { ...currentOptions };\n if (value === \"top\" || value === \"start\") {\n opts.labelPlacement = value;\n } else {\n delete opts.labelPlacement;\n }\n const next: UISchema = { ...uiEntry };\n if (Object.keys(opts).length) next[\"x-ui-options\"] = opts;\n else delete next[\"x-ui-options\"];\n state.setUiEntry(node.path, next);\n };\n\n return (\n <div className=\"space-y-4\">\n <FormSelect\n id={`${pathKey}-widget`}\n name=\"widget\"\n label=\"Widget\"\n value={currentWidget ?? \"__auto__\"}\n options={widgetChoices.map((c) => ({\n value: c.value ?? \"__auto__\",\n label: c.label,\n }))}\n onChange={(v) => setWidget(v === \"__auto__\" ? null : (v ?? null))}\n disabled={state.readOnly}\n clearable={false}\n />\n\n {currentWidget && (\n <OptionsEditor\n widget={`${pathKey}:${currentWidget}`}\n optionsSchema={optionsSchema}\n currentOptions={currentOptions}\n readOnly={state.readOnly}\n onChange={setOptions}\n />\n )}\n\n <PresentationEditor\n fieldName={pathKey}\n uiEntry={uiEntry}\n readOnly={state.readOnly}\n onChange={(entry) => state.setUiEntry(node.path, entry)}\n />\n\n <FormSelect\n id={`${pathKey}-labelPlacement`}\n name=\"labelPlacement\"\n label=\"Label placement\"\n value={currentOptions.labelPlacement ?? \"__inherit__\"}\n options={[\n {\n value: \"__inherit__\",\n label: `Inherit (${inheritedLabelPlacement === \"start\" ? \"inline\" : \"above\"})`,\n },\n { value: \"top\", label: \"Above\" },\n { value: \"start\", label: \"Inline (start)\" },\n ]}\n onChange={(v) => setLabelPlacement(v ?? \"__inherit__\")}\n disabled={state.readOnly}\n clearable={false}\n />\n </div>\n );\n}\n","/**\n * EnumEditor -- edits a scalar property's allowed values (enum) and optional\n * display labels, as a row list.\n *\n * Each choice is a row: [value] [label] [remove]. An Add button appends a row.\n * Values write to property.enum; labels write to x-ui-options.enumNames (only\n * for top-level properties). All changes route through setEnum, which normalizes,\n * dedupes, and clears when empty.\n */\n\nimport React, { useEffect, useState } from \"react\";\nimport { Input, IconButton, Button } from \"@petrarca/sonnet-ui\";\nimport { Plus, Trash2 } from \"lucide-react\";\nimport type { DesignerState } from \"../hooks/useDesignerState\";\nimport type { PropertyNode } from \"../model/view\";\nimport {\n readEnumChoices,\n getUiEntryAtPath,\n type EnumChoice,\n} from \"../model/mutate\";\n\nexport interface EnumEditorProps {\n node: PropertyNode;\n state: DesignerState;\n}\n\nexport function EnumEditor({\n node,\n state,\n}: EnumEditorProps): React.ReactElement {\n // Local draft so typing an empty/duplicate value mid-edit is not dropped by\n // the normalizing mutation. Re-seed when the selected property changes.\n const [rows, setRows] = useState<EnumChoice[]>(() =>\n readEnumChoices(node.property, getUiEntryAtPath(state.uiSchema, node.path)),\n );\n useEffect(() => {\n setRows(\n readEnumChoices(\n node.property,\n getUiEntryAtPath(state.uiSchema, node.path),\n ),\n );\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [node.path.join(\".\")]);\n\n const canEditLabels = true;\n\n const commit = (next: EnumChoice[]) => {\n setRows(next);\n state.setEnum(node.path, next);\n };\n\n const updateRow = (i: number, patch: Partial<EnumChoice>) => {\n commit(rows.map((r, idx) => (idx === i ? { ...r, ...patch } : r)));\n };\n const removeRow = (i: number) => commit(rows.filter((_, idx) => idx !== i));\n const addRow = () => setRows([...rows, { value: \"\", label: \"\" }]);\n\n return (\n <div className=\"space-y-3\">\n <div>\n <p className=\"text-sm font-medium\">Allowed values</p>\n <p className=\"text-xs text-muted-foreground\">\n Define a fixed set of choices. Leave empty for free input.\n </p>\n </div>\n\n {rows.length === 0 ? (\n <p className=\"text-xs text-muted-foreground\">No choices yet.</p>\n ) : (\n <div className=\"space-y-2\">\n {canEditLabels && (\n <div className=\"flex items-center gap-2 px-1\">\n <span className=\"heading-meta flex-1\">Value</span>\n <span className=\"heading-meta flex-1\">Label (optional)</span>\n <span className=\"w-7\" />\n </div>\n )}\n {rows.map((row, i) => (\n <div key={i} className=\"flex items-center gap-2\">\n <Input\n value={row.value}\n onChange={(e) => updateRow(i, { value: e.target.value })}\n placeholder=\"value\"\n disabled={state.readOnly}\n className=\"h-8 text-sm flex-1\"\n />\n {canEditLabels && (\n <Input\n value={row.label ?? \"\"}\n onChange={(e) => updateRow(i, { label: e.target.value })}\n placeholder={row.value || \"label\"}\n disabled={state.readOnly}\n className=\"h-8 text-sm flex-1\"\n />\n )}\n {!state.readOnly && (\n <IconButton\n label=\"Remove value\"\n tone=\"destructive\"\n onClick={() => removeRow(i)}\n >\n <Trash2 />\n </IconButton>\n )}\n </div>\n ))}\n </div>\n )}\n\n {!state.readOnly && (\n <Button\n variant=\"outline\"\n size=\"sm\"\n className=\"gap-1.5\"\n onClick={addRow}\n >\n <Plus className=\"h-4 w-4\" />\n Add value\n </Button>\n )}\n </div>\n );\n}\n","/**\n * TableHintsTab -- edits a property's table presentation hints (x-ui-cell,\n * x-ui-column, x-ui-cell-options), which EntityTable reads. These are embedded\n * on the schema property (not the uiSchema map). Live in the Table preview.\n *\n * The cell renderer list is derived from sonnet-ui's exported CELL_RENDERERS,\n * so it stays in sync with the actual table renderers. Cell options are edited\n * as raw JSON (varies per renderer).\n */\n\nimport React, { useMemo } from \"react\";\nimport { CELL_RENDERERS } from \"@petrarca/sonnet-ui\";\nimport { JsonEditor } from \"@petrarca/sonnet-ui/json-editor\";\nimport { FormSelect, JsonSchemaFormRenderer } from \"@petrarca/sonnet-forms\";\nimport type { JsonSchema } from \"@petrarca/sonnet-core/schema\";\nimport type { DesignerState } from \"../hooks/useDesignerState\";\nimport type { PropertyNode } from \"../model/view\";\nimport { readTableHints, type TableHints } from \"../model/mutate\";\n\nexport interface TableHintsTabProps {\n node: PropertyNode;\n state: DesignerState;\n}\n\nconst CELL_NAMES = Object.keys(CELL_RENDERERS);\n\n// Column meta-schema (flat fields; recomposed into x-ui-column on write).\nconst COLUMN_META_SCHEMA: JsonSchema = {\n title: \"\",\n type: \"object\",\n properties: {\n hidden: { type: \"boolean\", title: \"Hide column\" },\n order: { type: \"integer\", title: \"Column order\" },\n width: { type: \"integer\", title: \"Width (px)\", minimum: 0 },\n minWidth: { type: \"integer\", title: \"Min width (px)\", minimum: 0 },\n },\n};\n\ninterface ColumnFormValues {\n hidden?: boolean;\n order?: number;\n width?: number;\n minWidth?: number;\n}\n\nexport function TableHintsTab({\n node,\n state,\n}: TableHintsTabProps): React.ReactElement {\n const hints = readTableHints(node.property);\n\n const cellOptions = useMemo(\n () => JSON.stringify(hints.cellOptions ?? {}, null, 2),\n [hints.cellOptions],\n );\n\n const commit = (patch: Partial<TableHints>) =>\n state.setTableHints(node.path, { ...hints, ...patch });\n\n const columnValues: ColumnFormValues = {\n hidden: hints.column?.hidden,\n order: hints.column?.order,\n width: hints.column?.width,\n minWidth: hints.column?.minWidth,\n };\n\n const onColumnChange = (data: Record<string, unknown>) => {\n const v = data as ColumnFormValues;\n const column: NonNullable<TableHints[\"column\"]> = {};\n if (typeof v.hidden === \"boolean\") column.hidden = v.hidden;\n if (typeof v.order === \"number\" && !Number.isNaN(v.order))\n column.order = v.order;\n if (typeof v.width === \"number\" && !Number.isNaN(v.width))\n column.width = v.width;\n if (typeof v.minWidth === \"number\" && !Number.isNaN(v.minWidth))\n column.minWidth = v.minWidth;\n commit({ column });\n };\n\n return (\n <div className=\"space-y-4\">\n <FormSelect\n id={`${node.key}-cell`}\n name=\"cell\"\n label=\"Cell renderer\"\n value={hints.cell ?? \"__auto__\"}\n options={[\n { value: \"__auto__\", label: \"Auto (infer from type)\" },\n ...CELL_NAMES.map((n) => ({ value: n, label: n })),\n ]}\n onChange={(v: string | null) =>\n commit({ cell: !v || v === \"__auto__\" ? undefined : v })\n }\n disabled={state.readOnly}\n clearable={false}\n />\n\n <div>\n <p className=\"heading-meta mb-2\">Column</p>\n <JsonSchemaFormRenderer\n key={node.path.join(\".\")}\n schema={COLUMN_META_SCHEMA}\n data={columnValues as Record<string, unknown>}\n onChange={onColumnChange}\n showActions={false}\n showExtraProperties={false}\n readOnly={state.readOnly}\n />\n </div>\n\n <div>\n <p className=\"heading-meta mb-2\">Cell options (JSON)</p>\n <JsonEditor\n value={cellOptions}\n editablePaths={state.readOnly ? [] : [\"/\"]}\n height=\"160px\"\n className=\"rounded-md border overflow-hidden\"\n onChange={(text) => {\n try {\n commit({\n cellOptions: JSON.parse(text) as Record<string, unknown>,\n });\n } catch {\n // ignore invalid JSON while typing\n }\n }}\n />\n </div>\n </div>\n );\n}\n"],"mappings":";AAkBO,SAAS,QAAQ,MAA4B;AAClD,SAAO,KAAK,KAAK,GAAG;AACtB;AAGO,SAAS,SACd,GACA,GACS;AACT,MAAI,MAAM,QAAQ,MAAM,KAAM,QAAO,MAAM;AAC3C,SAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,CAAC,KAAK,MAAM,QAAQ,EAAE,CAAC,CAAC;AAClE;AAGO,SAAS,eACd,MACgD;AAChD,MAAI,KAAK,SAAS,YAAY,KAAK,WAAY,QAAO,KAAK;AAC3D,MAAI,KAAK,SAAS,WAAW,KAAK,OAAO,SAAS,UAAU;AAC1D,WAAO,KAAK,MAAM;AAAA,EACpB;AACA,S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AAe;AAAA;AAAA,MAClB;AAAA,MACA,gBAAAA;AAAA,QAACI;AAAA,QAAA;AAAA,UACC,OAAM;AAAA,UACN,SAAS,MAAM,gBAAgB,IAAI;AAAA,UAEnC,0BAAAJ,MAAC,YAAS;AAAA;AAAA,MACZ;AAAA,OACF;AAAA,IAGF,gBAAAA;AAAA,MAAC;AAAA;AAAA,QACC,MAAM;AAAA,QACN,cAAc;AAAA,QACd;AAAA;AAAA,IACF;AAAA,KACF;AAEJ;","names":["useEffect","useState","IconButton","useRef","useState","jsx","jsxs","useState","useRef","useMemo","useState","Button","JsonEditor","JsonSchemaFormRenderer","useMemo","jsx","useMemo","useMemo","useState","Input","IconButton","FormSelect","JsonSchemaFormRenderer","Plus","Trash2","ChevronUp","ChevronDown","jsx","jsxs","JsonSchemaFormRenderer","useMemo","useState","FormSelect","Plus","IconButton","Trash2","ChevronUp","ChevronDown","Input","useEffect","useState","Button","jsx","jsxs","useState","useEffect","Button","Fragment","jsx","jsxs","useState","Button","JsonEditor","useMemo","JsonSchemaFormRenderer","useEffect","useMemo","useRef","useState","Tabs","TabsList","TabsTrigger","TabsContent","Input","IconButton","Check","useMemo","useRef","JsonSchemaFormRenderer","isContainer","jsx","useMemo","useRef","JsonSchemaFormRenderer","useMemo","JsonSchemaFormRenderer","JsonEditor","FormSelect","jsx","jsxs","JsonSchemaFormRenderer","JsonEditor","pathKey","useMemo","FormSelect","useEffect","useState","Input","IconButton","Button","Plus","Trash2","jsx","jsxs","useState","useEffect","Input","IconButton","Trash2","Button","Plus","useMemo","JsonEditor","FormSelect","JsonSchemaFormRenderer","jsx","jsxs","useMemo","FormSelect","JsonSchemaFormRenderer","JsonEditor","jsx","jsxs","useState","useRef","useEffect","IconButton","Input","Check","useMemo","Tabs","TabsList","TabsTrigger","TabsContent","Fragment","jsx","jsxs","useState","useEffect","IconButton"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@petrarca/sonnet-schema-designer",
|
|
3
|
+
"version": "0.4.2",
|
|
4
|
+
"description": "Visual designer for authoring JSON Schema (and UI Schema presentation hints) for the Petrarca Sonnet component library",
|
|
5
|
+
"license": "Apache-2.0",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"type": "module",
|
|
10
|
+
"main": "./dist/index.js",
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"exports": {
|
|
13
|
+
".": {
|
|
14
|
+
"types": "./dist/index.d.ts",
|
|
15
|
+
"import": "./dist/index.js"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist"
|
|
20
|
+
],
|
|
21
|
+
"scripts": {
|
|
22
|
+
"build": "tsup",
|
|
23
|
+
"dev": "tsup --watch",
|
|
24
|
+
"typecheck": "tsc --noEmit",
|
|
25
|
+
"lint": "tsc --noEmit",
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"clean": "rm -rf dist *.tsbuildinfo"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@petrarca/sonnet-core": "workspace:*",
|
|
31
|
+
"@petrarca/sonnet-ui": "workspace:*",
|
|
32
|
+
"@petrarca/sonnet-forms": "workspace:*",
|
|
33
|
+
"lucide-react": "^0.553.0",
|
|
34
|
+
"zod": "^4.3.6"
|
|
35
|
+
},
|
|
36
|
+
"peerDependencies": {
|
|
37
|
+
"react": ">=19",
|
|
38
|
+
"react-dom": ">=19",
|
|
39
|
+
"tailwindcss": ">=3"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/react": "^19.0.0",
|
|
43
|
+
"@types/react-dom": "^19.0.0",
|
|
44
|
+
"tsup": "^8.4.0",
|
|
45
|
+
"typescript": "^5.9.2"
|
|
46
|
+
}
|
|
47
|
+
}
|