@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.
@@ -0,0 +1,531 @@
1
+ import { JsonSchemaProperty, JsonSchema, UISchema, UILayoutConfig, UISchemaOptions } from '@petrarca/sonnet-core/schema';
2
+ import { z } from 'zod';
3
+ import React from 'react';
4
+ import { WidgetOptionDef } from '@petrarca/sonnet-forms/widget-options';
5
+ import { TableUiSchema } from '@petrarca/sonnet-ui';
6
+
7
+ /**
8
+ * Path navigation over a JsonSchema tree.
9
+ *
10
+ * A property path is an array of property keys from the root down to a
11
+ * property, e.g. ["address", "city"]. Object children nest through
12
+ * `properties`; array children nest through `items.properties`. The path names
13
+ * the property and the navigator descends through `items` transparently, so an
14
+ * array-of-objects and its item object share one editing surface.
15
+ */
16
+
17
+ type PropertyPath = string[];
18
+ /** Serialize a path for use as a stable React key or selection id. */
19
+ declare function pathKey(path: PropertyPath): string;
20
+ /** Whether two paths refer to the same property. */
21
+ declare function samePath(a: PropertyPath | null, b: PropertyPath | null): boolean;
22
+ /** The container that holds a property's children, or undefined for scalars. */
23
+ declare function childContainer(prop: JsonSchemaProperty): Record<string, JsonSchemaProperty> | undefined;
24
+ /** Resolve a path to its property definition, or undefined if not found. */
25
+ declare function getProperty(schema: JsonSchema, path: PropertyPath): JsonSchemaProperty | undefined;
26
+ /** Whether a property has (or can have) child properties. */
27
+ declare function isContainer(prop: JsonSchemaProperty): boolean;
28
+ /** The child properties of a property, or an empty map for scalars. */
29
+ declare function childrenOf(prop: JsonSchemaProperty): Record<string, JsonSchemaProperty>;
30
+
31
+ /**
32
+ * Read-shaping: turn a JsonSchema into a property tree for the designer UI.
33
+ *
34
+ * Pure, no React. Ordering follows the renderer's rule: an explicit x-ui-order
35
+ * first, then remaining keys in declaration order.
36
+ */
37
+
38
+ type PropertyKind = "scalar" | "enum" | "object" | "array";
39
+ interface PropertyNode {
40
+ path: PropertyPath;
41
+ key: string;
42
+ property: JsonSchemaProperty;
43
+ kind: PropertyKind;
44
+ required: boolean;
45
+ /** Short type descriptor for the tree row, e.g. "string", "object[]". */
46
+ typeLabel: string;
47
+ /** Resolved widget override (x-ui-widget) if any. */
48
+ widget?: string;
49
+ children: PropertyNode[];
50
+ }
51
+ /** Classify a property into a tree kind. */
52
+ declare function propertyKind(prop: JsonSchemaProperty): PropertyKind;
53
+ /** Order keys by explicit x-ui-order, then remaining declaration order. */
54
+ declare function orderedKeys(properties: Record<string, JsonSchemaProperty>, order: string[] | undefined): string[];
55
+ /** Build the full property tree for a schema. */
56
+ declare function buildPropertyTree(schema: JsonSchema): PropertyNode[];
57
+ /**
58
+ * A layout scope: a container whose fields can be arranged into rows. Root is
59
+ * the form itself (path []); nested scopes are object/array containers.
60
+ */
61
+ interface LayoutScope {
62
+ /** Empty for root, otherwise the property path to the container. */
63
+ path: string[];
64
+ /** Human label, e.g. "Form (root)" or "contact" or "addresses (items)". */
65
+ label: string;
66
+ }
67
+ /** Enumerate all layout scopes: the root form plus every object/array container. */
68
+ declare function layoutScopes(schema: JsonSchema): LayoutScope[];
69
+
70
+ /**
71
+ * Pure edit operations over { schema, uiSchema }.
72
+ *
73
+ * Every function returns a new pair; nothing mutates in place. Operations keep
74
+ * the schema and uiSchema consistent -- renaming a property rewrites the property
75
+ * key, the uiSchema entry, the required entry, and any x-ui-order reference at
76
+ * the same level. Mirrors the graph-model/mutate.ts discipline.
77
+ */
78
+
79
+ type UiSchemaMap = Record<string, UISchema>;
80
+ interface DesignerModel {
81
+ schema: JsonSchema;
82
+ uiSchema: UiSchemaMap;
83
+ }
84
+ /** A default property for a newly created property of a given kind. */
85
+ declare function newProperty(kind: "scalar" | "object" | "array"): JsonSchemaProperty;
86
+ /** Add a property under a parent path (root when empty). Returns the new model. */
87
+ declare function addProperty(model: DesignerModel, parentPath: PropertyPath, kind: "scalar" | "object" | "array"): {
88
+ model: DesignerModel;
89
+ path: PropertyPath;
90
+ };
91
+ /** Delete the property at path. Returns the new model. */
92
+ declare function deleteProperty(model: DesignerModel, path: PropertyPath): DesignerModel;
93
+ /** Rename the property at path. Rewrites key, order, required, and uiSchema. */
94
+ declare function renameProperty(model: DesignerModel, path: PropertyPath, nextKey: string): {
95
+ model: DesignerModel;
96
+ path: PropertyPath;
97
+ };
98
+ /** Move the property at path up (-1) or down (+1) among its siblings. */
99
+ declare function moveProperty(model: DesignerModel, path: PropertyPath, direction: -1 | 1): DesignerModel;
100
+ /** Toggle whether the property at path is required among its siblings. */
101
+ declare function setRequired(model: DesignerModel, path: PropertyPath, required: boolean): DesignerModel;
102
+ /** Replace the property definition at path (merges the given partial). */
103
+ declare function updateProperty(model: DesignerModel, path: PropertyPath, patch: Partial<JsonSchemaProperty>): DesignerModel;
104
+ /**
105
+ * Change the type of the property at path, reshaping structural keys: switching to
106
+ * object adds an empty `properties`; to array adds `items`; leaving them strips
107
+ * those keys. Type-specific validation keys that no longer apply are dropped.
108
+ */
109
+ declare function changePropertyType(model: DesignerModel, path: PropertyPath, nextType: JsonSchemaProperty["type"]): DesignerModel;
110
+ /** One enum choice: a value and an optional display label. */
111
+ interface EnumChoice {
112
+ value: string;
113
+ label?: string;
114
+ }
115
+ declare function setEnum(model: DesignerModel, path: PropertyPath, choices: EnumChoice[]): DesignerModel;
116
+ /** Read the current enum choices for a property + its uiSchema entry. */
117
+ declare function readEnumChoices(prop: JsonSchemaProperty, uiEntry: UISchema | undefined): EnumChoice[];
118
+ /** Table presentation hints for a property (embedded in the schema). */
119
+ interface TableHints {
120
+ cell?: string;
121
+ cellOptions?: Record<string, unknown>;
122
+ column?: NonNullable<JsonSchemaProperty["x-ui-column"]>;
123
+ }
124
+ /**
125
+ * Set (or clear) a property's table hints: x-ui-cell, x-ui-cell-options, and
126
+ * x-ui-column. These live embedded on the property (EntityTable reads them
127
+ * there). Empty values clear the corresponding key.
128
+ */
129
+ declare function setTableHints(model: DesignerModel, path: PropertyPath, hints: TableHints): DesignerModel;
130
+ /** Read a property's current table hints. */
131
+ declare function readTableHints(prop: JsonSchemaProperty): TableHints;
132
+ /** Read the UISchema entry for a property path, or undefined. */
133
+ declare function getUiEntryAtPath(uiSchema: UiSchemaMap, path: PropertyPath): UISchema | undefined;
134
+ /** Set (or clear) the UISchema entry at a property path (any nesting depth). */
135
+ declare function setUiEntry(model: DesignerModel, path: PropertyPath, entry: UISchema | undefined): DesignerModel;
136
+ /**
137
+ * Set (or clear) the x-ui-layout of an object/array property at path. Object
138
+ * layout lives on the property; array layout lives on `items`.
139
+ */
140
+ declare function setPropertyLayout(model: DesignerModel, path: PropertyPath, layout: UILayoutConfig | undefined): DesignerModel;
141
+ /** Set (or clear) the root form layout (uiSchema["x-ui-layout"]). */
142
+ declare function setRootLayout(model: DesignerModel, layout: UILayoutConfig | undefined): DesignerModel;
143
+ /**
144
+ * Set (or clear) the root layout rows (uiSchema["x-ui-layout"].rows),
145
+ * preserving other x-ui-layout keys. Clearing rows to empty removes the key;
146
+ * if x-ui-layout then has no keys, it is removed entirely.
147
+ */
148
+ declare function setRootLayoutRows(model: DesignerModel, rows: UILayoutConfig["rows"]): DesignerModel;
149
+ /**
150
+ * Set the layout rows for a scope: the root form (path []) or an object/array
151
+ * container (its property path). Root rows live in uiSchema["x-ui-layout"];
152
+ * a container's rows live on the property's x-ui-layout (array -> items).
153
+ * Preserves other x-ui-layout keys.
154
+ */
155
+ declare function setScopedLayoutRows(model: DesignerModel, scopePath: PropertyPath, rows: UILayoutConfig["rows"]): DesignerModel;
156
+ /** Read the current x-ui-layout for a scope (root or a container property). */
157
+ declare function getScopedLayout(schema: JsonSchema, uiSchema: UiSchemaMap, scopePath: PropertyPath): UILayoutConfig | undefined;
158
+ /**
159
+ * Merge scalar layout options (direction/gap/labels/compact) into a scope's
160
+ * x-ui-layout, preserving rows and other keys. Undefined values clear the key.
161
+ */
162
+ declare function setScopedLayoutOptions(model: DesignerModel, scopePath: PropertyPath, options: Pick<UILayoutConfig, "direction" | "gap" | "labels" | "compact">): DesignerModel;
163
+ /** Set (or clear) the root global options (uiSchema["x-ui-globalOptions"]). */
164
+ declare function setGlobalOptions(model: DesignerModel, options: UISchemaOptions | undefined): DesignerModel;
165
+
166
+ /**
167
+ * Type -> compatible form widgets for the inspector's widget dropdown.
168
+ *
169
+ * Mirrors the renderer's resolution vocabulary (sonnet-forms widgetResolver):
170
+ * the dropdown offers widgets that make sense for a property's type, plus an
171
+ * "Auto" choice (value null) that clears x-ui-widget and lets the renderer
172
+ * resolve from structure/type. Keep aligned with DEFAULT_WIDGETS.
173
+ */
174
+
175
+ interface WidgetChoice {
176
+ /** x-ui-widget value (lowercase alias), or null for Auto (no override). */
177
+ value: string | null;
178
+ label: string;
179
+ }
180
+ /** Widgets offered for a property, Auto first. */
181
+ declare function compatibleWidgets(prop: JsonSchemaProperty): WidgetChoice[];
182
+
183
+ /**
184
+ * Output shaping: merge a separate uiSchema map's form hints into the JSON
185
+ * schema as embedded x-ui-* keys, for consumers that want a single
186
+ * self-contained schema.
187
+ *
188
+ * The designer edits the two artifacts separately (clean data/presentation
189
+ * split); embedding is applied only at the emit boundary when outputMode is
190
+ * "embedded". Only top-level form hints are embedded in v1 (x-ui-widget,
191
+ * x-ui-options, x-ui-title, x-ui-placeholder, x-ui-description), matching what
192
+ * uiSchema carries for top-level properties.
193
+ */
194
+
195
+ /**
196
+ * Return a new schema with each top-level property's uiSchema form hints copied
197
+ * onto the corresponding property as x-ui-* keys. The input schema/uiSchema are
198
+ * not mutated. uiSchema hints win over any pre-existing embedded key.
199
+ */
200
+ declare function embedUiSchema(schema: JsonSchema, uiSchema: Record<string, UISchema>): JsonSchema;
201
+
202
+ /**
203
+ * SchemaDesigner capabilities -- a small profile that gates what a consumer can
204
+ * author. Mirrors the discipline of GraphModelEditor's capabilities: the Zod
205
+ * schema below is the single source of truth, the TypeScript types are inferred
206
+ * from it, and `resolveCapabilities` applies defaults (with `readOnly` as a
207
+ * fully-locked shorthand). Every field is optional and defaults to the most
208
+ * permissive value, so adding a capability never tightens an existing profile.
209
+ *
210
+ * Design: docs/design/schema-designer.md, section "Capability gating".
211
+ */
212
+
213
+ /**
214
+ * A tab the center pane can offer. "form" / "table" / "json" preview the
215
+ * schema; "capabilities" is a meta-editor for the profile itself (a dev /
216
+ * power-user affordance), not a preview -- it is opt-in and never in a default.
217
+ */
218
+ type PreviewKind = "form" | "table" | "json" | "capabilities";
219
+ /**
220
+ * The capabilities schema. Small by design -- it covers the real consumer needs
221
+ * (sestina's audit-event and terminology schema editors) without a per-area
222
+ * matrix we do not use yet.
223
+ */
224
+ declare const capabilitiesSchema: z.ZodObject<{
225
+ mode: z.ZodDefault<z.ZodEnum<{
226
+ full: "full";
227
+ data: "data";
228
+ }>>;
229
+ previews: z.ZodOptional<z.ZodArray<z.ZodEnum<{
230
+ form: "form";
231
+ table: "table";
232
+ json: "json";
233
+ capabilities: "capabilities";
234
+ }>>>;
235
+ editablePaths: z.ZodOptional<z.ZodArray<z.ZodString>>;
236
+ }, z.core.$strip>;
237
+ /**
238
+ * The capabilities a consumer may pass. Inferred from the schema, with all
239
+ * fields optional on input (defaults are applied by resolveCapabilities).
240
+ */
241
+ type SchemaDesignerCapabilities = z.input<typeof capabilitiesSchema>;
242
+ /** The fully-resolved capabilities, plus the derived flags used for gating. */
243
+ interface ResolvedCapabilities {
244
+ mode: "data" | "full";
245
+ /** Effective preview list (defaulted by mode when not provided). */
246
+ previews: PreviewKind[];
247
+ /** JSON Pointer paths whose children are editable; empty = no scoping. */
248
+ editablePaths: string[];
249
+ /** No structural edits at all (readOnly shorthand). */
250
+ locked: boolean;
251
+ /** editablePaths is non-empty -- only designated subtrees are editable. */
252
+ scoped: boolean;
253
+ /** The Capabilities editor tab is listed in previews. */
254
+ showCapabilities: boolean;
255
+ /** Whether the center pane renders at all (previews non-empty). */
256
+ showPreview: boolean;
257
+ }
258
+ /**
259
+ * Resolve the effective capabilities: readOnly wins (fully locked), otherwise
260
+ * parse the provided capabilities (applying per-field defaults). Invalid input
261
+ * falls back to permissive defaults rather than throwing.
262
+ */
263
+ declare function resolveCapabilities(capabilities: SchemaDesignerCapabilities | undefined, readOnly: boolean | undefined): ResolvedCapabilities;
264
+ /** Result of validating an untrusted capabilities object. */
265
+ type CapabilitiesValidation = {
266
+ ok: true;
267
+ value: SchemaDesignerCapabilities;
268
+ } | {
269
+ ok: false;
270
+ errors: string[];
271
+ };
272
+ /**
273
+ * Validate a hand-authored / external capabilities object. Returns the parsed
274
+ * value or a list of readable error messages. Does not throw.
275
+ */
276
+ declare function validateCapabilities(input: unknown): CapabilitiesValidation;
277
+
278
+ /**
279
+ * useDesignerState -- owns the designer's { schema, uiSchema, selection } and
280
+ * exposes bound mutation operations.
281
+ *
282
+ * Controlled: pass `schema` + `uiSchema` + `onChange`; the hook holds no schema
283
+ * state and every op calls `onChange`. Uncontrolled: pass `initialSchema`
284
+ * (+ optional `initialUiSchema`); the hook manages the schema internally.
285
+ * Selection (the active property path) is always internal UI state.
286
+ */
287
+
288
+ interface UseDesignerStateArgs {
289
+ schema?: JsonSchema;
290
+ uiSchema?: UiSchemaMap;
291
+ initialSchema?: JsonSchema;
292
+ initialUiSchema?: UiSchemaMap;
293
+ onChange?: (schema: JsonSchema, uiSchema: UiSchemaMap) => void;
294
+ readOnly?: boolean;
295
+ capabilities?: SchemaDesignerCapabilities;
296
+ }
297
+ interface DesignerState {
298
+ schema: JsonSchema;
299
+ uiSchema: UiSchemaMap;
300
+ selection: PropertyPath | null;
301
+ readOnly: boolean;
302
+ /** Resolved capability profile (readOnly + editablePaths applied). */
303
+ capabilities: ResolvedCapabilities;
304
+ /** Whether the property at path may be renamed / deleted / retyped / reordered. */
305
+ canEditProperty: (path: PropertyPath) => boolean;
306
+ /** Whether a child property may be added to the container at path (root = []). */
307
+ canAddChild: (path: PropertyPath) => boolean;
308
+ select: (path: PropertyPath | null) => void;
309
+ addProperty: (parentPath: PropertyPath, kind: "scalar" | "object" | "array") => void;
310
+ deleteProperty: (path: PropertyPath) => void;
311
+ renameProperty: (path: PropertyPath, nextKey: string) => void;
312
+ moveProperty: (path: PropertyPath, direction: -1 | 1) => void;
313
+ setRequired: (path: PropertyPath, required: boolean) => void;
314
+ updateProperty: (path: PropertyPath, patch: Partial<JsonSchemaProperty>) => void;
315
+ changePropertyType: (path: PropertyPath, nextType: JsonSchemaProperty["type"]) => void;
316
+ setEnum: (path: PropertyPath, choices: EnumChoice[]) => void;
317
+ setUiEntry: (path: PropertyPath, entry: UISchema | undefined) => void;
318
+ setTableHints: (path: PropertyPath, hints: TableHints) => void;
319
+ setPropertyLayout: (path: PropertyPath, layout: UILayoutConfig | undefined) => void;
320
+ setRootLayout: (layout: UILayoutConfig | undefined) => void;
321
+ setRootLayoutRows: (rows: UILayoutConfig["rows"]) => void;
322
+ setScopedLayoutRows: (scopePath: PropertyPath, rows: UILayoutConfig["rows"]) => void;
323
+ setScopedLayoutOptions: (scopePath: PropertyPath, options: Pick<UILayoutConfig, "direction" | "gap" | "labels" | "compact">) => void;
324
+ setGlobalOptions: (options: UISchemaOptions | undefined) => void;
325
+ }
326
+ declare function useDesignerState(args: UseDesignerStateArgs): DesignerState;
327
+
328
+ /**
329
+ * SchemaDesigner -- visual, controlled designer for a JsonSchema (+ uiSchema).
330
+ *
331
+ * Layout: Tree | Preview | Inspector. The preview (the live form) is the hero
332
+ * and takes the flexible center, matching visual-builder convention; the
333
+ * inspector is the resizable/collapsible right pane. Controlled via `schema` +
334
+ * `uiSchema` + `onChange`, or uncontrolled via `initialSchema`. Read-only is a
335
+ * mode of the same component.
336
+ *
337
+ * This is the assembly shell; the tree, preview, and inspector are built up
338
+ * incrementally.
339
+ */
340
+
341
+ interface SchemaDesignerProps {
342
+ /** Controlled schema. Provide with onChange. */
343
+ schema?: JsonSchema;
344
+ /** Controlled uiSchema map (form presentation hints). */
345
+ uiSchema?: Record<string, UISchema>;
346
+ /** Uncontrolled seed schema (used when `schema` is omitted). */
347
+ initialSchema?: JsonSchema;
348
+ /** Uncontrolled seed uiSchema. */
349
+ initialUiSchema?: Record<string, UISchema>;
350
+ /**
351
+ * Called on every edit with the new schema + uiSchema (always the separate
352
+ * form: schema is the data model, form hints live in uiSchema). Use the
353
+ * exported `embedUiSchema` helper if a single self-contained schema is wanted.
354
+ */
355
+ onChange?: (schema: JsonSchema, uiSchema: Record<string, UISchema>) => void;
356
+ /** View-only: no edit affordances, onChange never fires. Shorthand for a fully-locked profile. */
357
+ readOnly?: boolean;
358
+ /** Capability profile: gates data/full mode, preview renderers, and scoped editing. */
359
+ capabilities?: SchemaDesignerCapabilities;
360
+ /** Option descriptors for custom widgets, keyed by widget name (merged over built-ins). */
361
+ widgetOptions?: Record<string, WidgetOptionDef[]>;
362
+ }
363
+ declare function SchemaDesigner(props: SchemaDesignerProps): React.ReactElement;
364
+
365
+ /**
366
+ * PropertyTree -- the left pane. Renders the schema's properties as a
367
+ * hierarchical list with select / add / delete / reorder. Row idiom matches
368
+ * graph-model/TypeDetailPanel for cross-editor consistency.
369
+ */
370
+
371
+ interface PropertyTreeProps {
372
+ state: DesignerState;
373
+ /** When provided, renders a collapse button in the header. */
374
+ onCollapse?: () => void;
375
+ }
376
+ declare function PropertyTree({ state, onCollapse, }: PropertyTreeProps): React.ReactElement;
377
+
378
+ /**
379
+ * PreviewPane -- the center pane. Tabs: Form (live rendered form), JSON Schema
380
+ * (the data model), and UI Schema (the presentation map). The form is the
381
+ * universal sanity check; the two JSON views are read-only.
382
+ *
383
+ * Additional renderers (table, tree, detail) plug in as more tabs without
384
+ * touching this contract -- each takes the same schema + uiSchema + data.
385
+ */
386
+
387
+ interface PreviewPaneProps {
388
+ state: DesignerState;
389
+ /** The current (editable) capabilities profile. */
390
+ capabilities?: SchemaDesignerCapabilities;
391
+ /** Apply an edited profile (from the Capabilities tab). */
392
+ onCapabilitiesChange?: (next: SchemaDesignerCapabilities) => void;
393
+ }
394
+ declare function PreviewPane({ state, capabilities, onCapabilitiesChange, }: PreviewPaneProps): React.ReactElement;
395
+
396
+ /**
397
+ * TablePreview -- renders the schema as an EntityTable using auto-generated
398
+ * sample rows. Columns and cells come from the resolver's defaults plus any
399
+ * x-ui-column / x-ui-cell hints embedded in the schema.
400
+ */
401
+
402
+ interface TablePreviewProps {
403
+ schema: JsonSchema;
404
+ uiSchema?: TableUiSchema;
405
+ }
406
+ declare function TablePreview({ schema, uiSchema, }: TablePreviewProps): React.ReactElement;
407
+
408
+ /**
409
+ * Generate plausible sample rows from a JsonSchema, for the table preview.
410
+ *
411
+ * Pure. Produces a few rows with a value per top-level property, chosen by
412
+ * type / format / enum so the table shows realistic content. Nested objects and
413
+ * arrays get simple placeholders (tables typically show scalar columns; the
414
+ * cell renderer decides how to display the rest).
415
+ */
416
+
417
+ type Row = Record<string, unknown>;
418
+ /** Build `count` sample rows for a schema's top-level properties. */
419
+ declare function sampleRows(schema: JsonSchema, count?: number): Row[];
420
+
421
+ /**
422
+ * FormLayoutDesigner -- visual editor for the form's row layout
423
+ * (x-ui-layout.rows). Two columns: an "Available" pool of unassigned top-level
424
+ * properties (left) and the row designer (right). Properties are dragged
425
+ * (native HTML5 DnD) between the pool and rows; rows can be added, removed,
426
+ * reordered, and given a CSS grid-template-columns value.
427
+ *
428
+ * This is a bespoke visual designer (not a meta-schema form) -- the first of a
429
+ * planned family of "*Designer" surfaces for spatial authoring tasks.
430
+ */
431
+
432
+ interface FormLayoutDesignerProps {
433
+ state: DesignerState;
434
+ }
435
+ declare function FormLayoutDesigner({ state, }: FormLayoutDesignerProps): React.ReactElement;
436
+
437
+ /**
438
+ * Inspector -- the right pane. Resolves the selected property and hosts the tabbed
439
+ * editors (Data now; UI and Layout added incrementally). Empty state when no
440
+ * property is selected.
441
+ */
442
+
443
+ interface InspectorProps {
444
+ state: DesignerState;
445
+ /** Option descriptors for custom widgets (merged over built-ins). */
446
+ widgetOptions?: Record<string, WidgetOptionDef[]>;
447
+ }
448
+ declare function Inspector({ state, widgetOptions, }: InspectorProps): React.ReactElement;
449
+
450
+ /**
451
+ * DataTab -- edits a property's data definition (type, title, description,
452
+ * default, required, validation) via a meta-schema rendered with
453
+ * JsonSchemaFormRenderer. Type and required are routed to dedicated mutations
454
+ * (they reshape structure / live on the parent); the rest is a property patch.
455
+ */
456
+
457
+ interface DataTabProps {
458
+ node: PropertyNode;
459
+ state: DesignerState;
460
+ }
461
+ declare function DataTab({ node, state }: DataTabProps): React.ReactElement;
462
+
463
+ /**
464
+ * UITab -- edits a property's form presentation hints: the widget (x-ui-widget)
465
+ * and its options (x-ui-options).
466
+ *
467
+ * The widget dropdown offers widgets compatible with the property's type (Auto
468
+ * clears the override). The options editor is a JsonSchemaFormRenderer over a
469
+ * schema derived from the selected widget's WidgetOptionDef[] (from the
470
+ * design-time @petrarca/sonnet-forms/widget-options layer). Widgets with no
471
+ * descriptor fall back to a raw JSON editor for x-ui-options.
472
+ */
473
+
474
+ interface UITabProps {
475
+ node: PropertyNode;
476
+ state: DesignerState;
477
+ /** Consumer-supplied option descriptors for custom widgets (merged over built-ins). */
478
+ widgetOptions?: Record<string, WidgetOptionDef[]>;
479
+ }
480
+ declare function UITab({ node, state, widgetOptions, }: UITabProps): React.ReactElement;
481
+
482
+ /**
483
+ * EnumEditor -- edits a scalar property's allowed values (enum) and optional
484
+ * display labels, as a row list.
485
+ *
486
+ * Each choice is a row: [value] [label] [remove]. An Add button appends a row.
487
+ * Values write to property.enum; labels write to x-ui-options.enumNames (only
488
+ * for top-level properties). All changes route through setEnum, which normalizes,
489
+ * dedupes, and clears when empty.
490
+ */
491
+
492
+ interface EnumEditorProps {
493
+ node: PropertyNode;
494
+ state: DesignerState;
495
+ }
496
+ declare function EnumEditor({ node, state, }: EnumEditorProps): React.ReactElement;
497
+
498
+ /**
499
+ * TableHintsTab -- edits a property's table presentation hints (x-ui-cell,
500
+ * x-ui-column, x-ui-cell-options), which EntityTable reads. These are embedded
501
+ * on the schema property (not the uiSchema map). Live in the Table preview.
502
+ *
503
+ * The cell renderer list is derived from sonnet-ui's exported CELL_RENDERERS,
504
+ * so it stays in sync with the actual table renderers. Cell options are edited
505
+ * as raw JSON (varies per renderer).
506
+ */
507
+
508
+ interface TableHintsTabProps {
509
+ node: PropertyNode;
510
+ state: DesignerState;
511
+ }
512
+ declare function TableHintsTab({ node, state, }: TableHintsTabProps): React.ReactElement;
513
+
514
+ /**
515
+ * FormSettingsSheet -- form-level (root) settings in a right-side Sheet, opened
516
+ * from a gear button. Holds settings that are not tied to a single property:
517
+ * the root form layout (x-ui-layout) and global options (x-ui-globalOptions).
518
+ *
519
+ * Uses the house-standard Sheet pattern (as in graph-model's PropertyFormSheet).
520
+ * Kept out of the inspector's per-property tabs, which do not scale to
521
+ * form-wide concerns.
522
+ */
523
+
524
+ interface FormSettingsSheetProps {
525
+ open: boolean;
526
+ onOpenChange: (open: boolean) => void;
527
+ state: DesignerState;
528
+ }
529
+ declare function FormSettingsSheet({ open, onOpenChange, state, }: FormSettingsSheetProps): React.ReactElement;
530
+
531
+ export { type CapabilitiesValidation, DataTab, type DesignerModel, type DesignerState, type EnumChoice, EnumEditor, FormLayoutDesigner, FormSettingsSheet, Inspector, type LayoutScope, PreviewPane, type PropertyKind, type PropertyNode, type PropertyPath, PropertyTree, type ResolvedCapabilities, SchemaDesigner, type SchemaDesignerCapabilities, type SchemaDesignerProps, type TableHints, TableHintsTab, TablePreview, UITab, type UiSchemaMap, type UseDesignerStateArgs, type WidgetChoice, addProperty, buildPropertyTree, capabilitiesSchema, changePropertyType, childContainer, childrenOf, compatibleWidgets, deleteProperty, embedUiSchema, getProperty, getScopedLayout, getUiEntryAtPath, isContainer, layoutScopes, moveProperty, newProperty, orderedKeys, pathKey, propertyKind, readEnumChoices, readTableHints, renameProperty, resolveCapabilities, samePath, sampleRows, setEnum, setGlobalOptions, setPropertyLayout, setRequired, setRootLayout, setRootLayoutRows, setScopedLayoutOptions, setScopedLayoutRows, setTableHints, setUiEntry, updateProperty, useDesignerState, validateCapabilities };