@petrarca/sonnet-schema-designer 0.8.0 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -0
- package/dist/chunk-MVPNMAVL.js +3178 -0
- package/dist/chunk-MVPNMAVL.js.map +1 -0
- package/dist/index-Cu6JZdYj.d.ts +875 -0
- package/dist/index.d.ts +126 -355
- package/dist/index.js +2506 -1761
- package/dist/index.js.map +1 -1
- package/dist/questionnaire/index.d.ts +3 -0
- package/dist/questionnaire/index.js +153 -0
- package/dist/questionnaire/index.js.map +1 -0
- package/package.json +14 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,122 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { P as PropertyPath, S as SlotKind, U as UiSchemaMap, N as NewPropertyKind, C as ConditionCombinator, a as PropertyTypeChoice, D as DesignerModel, E as EnumChoice, T as TableHints, V as ValueTypeAnswer, Q as QuestionnaireDesignerCapabilities } from './index-Cu6JZdYj.js';
|
|
2
|
+
export { A as ABSENT_KEY, b as ABSENT_WIDGET, c as ANSWER_TYPE_LABELS, d as ANSWER_TYPE_LIMITS, e as AnswerFragment, f as AnswerType, g as AnswerTypeChange, B as BuiltinAnswerType, h as CHOICE_WITH_TEXT_WIDGET, i as CODEABLE_CONCEPT_ANSWER, j as CODING_ANSWER, k as ChildSlot, l as ChoiceOption, m as Completion, n as Condition, o as ConditionalItems, p as DEFAULT_VALUE_TYPES, F as FieldType, L as LIMIT_LABELS, q as LimitKeyword, r as Limits, s as LockedItem, t as NewItem, O as OTHER_OPTION, u as PathSegment, v as PathSlot, w as QUANTITY_ANSWER, x as QuestionItem, y as QuestionnaireItem, z as QuestionnaireView, R as RecognizedAnswer, G as ResolvedQuestionnaireCapabilities, H as SectionItem, I as ShowIf, J as TextItem, K as ValueTypeSettings, M as absentProperty, W as addBranch, X as addConditional, Y as addDefinition, Z as addElse, _ as addItem, $ as addLayoutGroup, a0 as addProperty, a1 as answerTypeFragment, a2 as answerTypeLabel, a3 as answeredOrExcused, a4 as branch, a5 as changeAnswerType, a6 as changePropertyType, a7 as childContainer, a8 as childSlots, a9 as choiceTextWhen, aa as classifyQuestionnaire, ab as codingBindingOf, ac as condition, ad as containerFields, ae as containerOrder, af as declaredReasons, ag as def, ah as definitionUsageCount, ai as definitionsOf, aj as deleteItem, ak as deleteProperty, al as embeddedHints, am as getProperty, an as getScopedLayout, ao as getUiEntryAtPath, ap as isAsked, aq as isBuiltinAnswerType, ar as isComplete, as as isContainer, at as isContainerType, au as isReservedKey, av as isValidKey, aw as itemsOf, ax as keyFromText, ay as limitsFor, az as limitsOf, aA as moveBranch, aB as moveItem, aC as moveLayoutGroup, aD as moveProperty, aE as newBranch, aF as newCondition, aG as newProperty, aH as optionsOf, aI as otherTextMember, aJ as parsePathKey, aK as pathKey, aL as placeFieldInGroup, aM as prop, aN as questionnaireCapabilitiesSchema, aO as rawChoiceAndText, aP as readConditional, aQ as readEnumChoices, aR as readReasons, aS as readTableHints, aT as recognizeAnswerType, aU as removeBranch, aV as removeConditional, aW as removeDefinition, aX as removeElse, aY as removeLayoutGroup, aZ as renameDefinition, a_ as renameLayoutGroup, a$ as renameProperty, b0 as reorderItem, b1 as resolveQuestionnaireCapabilities, b2 as samePath, b3 as sameSegment, b4 as schemaAsRootProp, b5 as sectionPathOf, b6 as setChoiceTextWhen, b7 as setCondition, b8 as setConditionalBehavior, b9 as setDefaultAnswer, ba as setEnum, bb as setGlobalOptions, bc as setHelp, bd as setItemText, be as setKey, bf as setKeywords, bg as setLayoutGroupRule, bh as setLimit, bi as setOptions, bj as setPlaceholder, bk as setPresentation, bl as setPropertyLayout, bm as setQuestionRequired, bn as setQuestionnaireText, bo as setReadOnly, bp as setReasons, bq as setReference, br as setRequired, bs as setRootLayout, bt as setRootLayoutRows, bu as setScopedGroupRows, bv as setScopedLayoutGroups, bw as setScopedLayoutMode, bx as setScopedLayoutOptions, by as setScopedLayoutRows, bz as setScopedLayoutVariant, bA as setSectionRepeats, bB as setShowIf, bC as setTableHints, bD as setUiEntry, bE as setValueTypeSettings, bF as showIfToIf, bG as slot, bH as unlessReasonKey, bI as unlessReasonMember, bJ as updateProperty, bK as validateQuestionnaireCapabilities, bL as valueTypeAnswer, bM as valueTypeOf } from './index-Cu6JZdYj.js';
|
|
3
|
+
import { JsonSchemaProperty, JsonSchema, RefResolver, UISchema, UILayoutConfig, UILayoutRowConfig, UILayoutGroupConfig, UISchemaOptions } from '@petrarca/sonnet-core/schema';
|
|
2
4
|
import { z } from 'zod';
|
|
3
|
-
import React from 'react';
|
|
5
|
+
import * as React from 'react';
|
|
6
|
+
import React__default from 'react';
|
|
4
7
|
import { WidgetOptionDef } from '@petrarca/sonnet-forms/widget-options';
|
|
8
|
+
import * as lucide_react from 'lucide-react';
|
|
9
|
+
import { LucideIcon } from 'lucide-react';
|
|
10
|
+
import { WidgetRegistry } from '@petrarca/sonnet-forms';
|
|
5
11
|
import { TableUiSchema } from '@petrarca/sonnet-ui';
|
|
6
12
|
|
|
7
|
-
/**
|
|
8
|
-
* Path navigation over a JsonSchema tree.
|
|
9
|
-
*
|
|
10
|
-
* A path is a list of typed segments from the root down to a property. Most
|
|
11
|
-
* segments are property keys (`{kind:"prop"}`) -- object children nest through
|
|
12
|
-
* `properties`, array-of-object children through `items.properties`, and the
|
|
13
|
-
* navigator descends through `items` transparently so an array and its item
|
|
14
|
-
* object share one editing surface.
|
|
15
|
-
*
|
|
16
|
-
* Logic constructs introduce non-property segments: `{kind:"branch"}` for a
|
|
17
|
-
* `oneOf`/`allOf` element, and `{kind:"slot"}` for a fixed schema slot
|
|
18
|
-
* (`then`/`else`/`items`). The discriminated union keeps the distinction
|
|
19
|
-
* explicit and type-checked; a single codec (pathKey/parsePathKey) owns all
|
|
20
|
-
* conversion to/from strings.
|
|
21
|
-
*/
|
|
22
|
-
|
|
23
|
-
/** A fixed schema slot that holds a single sub-schema. */
|
|
24
|
-
type PathSlot = "then" | "else" | "items";
|
|
25
|
-
/**
|
|
26
|
-
* The array a conditional (if/then/else) member lives in. `allOf` = every
|
|
27
|
-
* condition must hold (AND); `anyOf` = any condition suffices (OR). Maps to
|
|
28
|
-
* FHIR `enableBehavior` "all" / "any".
|
|
29
|
-
*/
|
|
30
|
-
type ConditionCombinator = "allOf" | "anyOf";
|
|
31
|
-
/** One step in a property path. */
|
|
32
|
-
type PathSegment = {
|
|
33
|
-
kind: "prop";
|
|
34
|
-
key: string;
|
|
35
|
-
} | {
|
|
36
|
-
kind: "branch";
|
|
37
|
-
index: number;
|
|
38
|
-
} | {
|
|
39
|
-
kind: "condition";
|
|
40
|
-
combinator: ConditionCombinator;
|
|
41
|
-
index: number;
|
|
42
|
-
} | {
|
|
43
|
-
kind: "slot";
|
|
44
|
-
slot: PathSlot;
|
|
45
|
-
} | {
|
|
46
|
-
kind: "def";
|
|
47
|
-
name: string;
|
|
48
|
-
};
|
|
49
|
-
type PropertyPath = PathSegment[];
|
|
50
|
-
/**
|
|
51
|
-
* Whether a property key is reserved by the path codec. Keys matching
|
|
52
|
-
* `/^#(branch|condition|def|slot):/` would corrupt the pathKey/parsePathKey
|
|
53
|
-
* round-trip. The designer guards against these at rename/add time.
|
|
54
|
-
*/
|
|
55
|
-
declare function isReservedKey(key: string): boolean;
|
|
56
|
-
/** Construct a property-key segment. */
|
|
57
|
-
declare function prop(key: string): PathSegment;
|
|
58
|
-
/** Construct a branch (oneOf element) segment. */
|
|
59
|
-
declare function branch(index: number): PathSegment;
|
|
60
|
-
/** Construct a condition (if/then/else member) segment for a combinator array. */
|
|
61
|
-
declare function condition(index: number, combinator?: ConditionCombinator): PathSegment;
|
|
62
|
-
/** Construct a fixed-slot segment. */
|
|
63
|
-
declare function slot(name: PathSlot): PathSegment;
|
|
64
|
-
/** Construct a definition ($defs entry) segment. Root-only in practice. */
|
|
65
|
-
declare function def(name: string): PathSegment;
|
|
66
|
-
/** Serialize a path to a stable string (React key, selection id, scope value). */
|
|
67
|
-
declare function pathKey(path: PropertyPath): string;
|
|
68
|
-
/** Parse a string produced by {@link pathKey} back into a path. */
|
|
69
|
-
declare function parsePathKey(key: string): PropertyPath;
|
|
70
|
-
/** Whether two path segments refer to the same position. */
|
|
71
|
-
declare function sameSegment(a: PathSegment, b: PathSegment): boolean;
|
|
72
|
-
/** Whether two paths refer to the same node (structural comparison). */
|
|
73
|
-
declare function samePath(a: PropertyPath | null, b: PropertyPath | null): boolean;
|
|
74
|
-
/** How a child slot is presented and mutated. */
|
|
75
|
-
type SlotKind = "property" | "branch" | "conditional" | "definition";
|
|
76
|
-
/** A single editable child of a property (or the root). */
|
|
77
|
-
interface ChildSlot {
|
|
78
|
-
/** Segment appended to the parent path to reach this child. */
|
|
79
|
-
segment: PathSegment;
|
|
80
|
-
/** Display label for the tree row. */
|
|
81
|
-
label: string;
|
|
82
|
-
/** The child schema. */
|
|
83
|
-
property: JsonSchemaProperty;
|
|
84
|
-
kind: SlotKind;
|
|
85
|
-
removable: boolean;
|
|
86
|
-
reorderable: boolean;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* The properties map that holds a property's named children, or undefined when
|
|
90
|
-
* it has none. Object children live in `properties`; array-of-object children
|
|
91
|
-
* live in `items.properties`. (Logic constructs use branch/slot children and
|
|
92
|
-
* are surfaced via {@link childSlots}, not here.)
|
|
93
|
-
*/
|
|
94
|
-
declare function childContainer(prop: JsonSchemaProperty): Record<string, JsonSchemaProperty> | undefined;
|
|
95
|
-
/**
|
|
96
|
-
* The reusable definitions map of a schema. Canonically 2020-12 `$defs`; also
|
|
97
|
-
* reads Draft-7 `definitions` so both dialects surface as editable nodes. New
|
|
98
|
-
* definitions are always authored into `$defs` (see mutate.addDefinition).
|
|
99
|
-
*/
|
|
100
|
-
declare function definitionsOf(property: JsonSchemaProperty): Record<string, JsonSchemaProperty> | undefined;
|
|
101
|
-
/**
|
|
102
|
-
* The ordered child slots of a property (the single extension point for the
|
|
103
|
-
* tree/inspector/mutations). Surfaces object/array property children, oneOf
|
|
104
|
-
* branches, if/then/else conditionals (allOf/anyOf members), and $defs
|
|
105
|
-
* definitions (root-only in practice).
|
|
106
|
-
*/
|
|
107
|
-
declare function childSlots(property: JsonSchemaProperty): ChildSlot[];
|
|
108
|
-
/**
|
|
109
|
-
* Wrap a JsonSchema root as an object-shaped JsonSchemaProperty so the path
|
|
110
|
-
* navigation machinery can traverse it with the same stepInto logic as any
|
|
111
|
-
* nested property. Pass the keys needed by the caller; unused fields default
|
|
112
|
-
* to undefined.
|
|
113
|
-
*/
|
|
114
|
-
declare function schemaAsRootProp(schema: JsonSchema): JsonSchemaProperty;
|
|
115
|
-
/** Resolve a path to its property definition, or undefined if not found. */
|
|
116
|
-
declare function getProperty(schema: JsonSchema, path: PropertyPath): JsonSchemaProperty | undefined;
|
|
117
|
-
/** Whether a property has (or can have) child slots (properties, branches, conditionals). */
|
|
118
|
-
declare function isContainer(prop: JsonSchemaProperty): boolean;
|
|
119
|
-
|
|
120
13
|
/**
|
|
121
14
|
* Read-shaping: turn a JsonSchema into a property tree for the designer UI.
|
|
122
15
|
*
|
|
@@ -175,230 +68,6 @@ interface LayoutScope {
|
|
|
175
68
|
/** Enumerate all layout scopes: the root form plus every object/array container. */
|
|
176
69
|
declare function layoutScopes(schema: JsonSchema): LayoutScope[];
|
|
177
70
|
|
|
178
|
-
/**
|
|
179
|
-
* Pure edit operations over { schema, uiSchema }.
|
|
180
|
-
*
|
|
181
|
-
* Every function returns a new pair; nothing mutates in place. Operations keep
|
|
182
|
-
* the schema and uiSchema consistent -- renaming a property rewrites the property
|
|
183
|
-
* key, the uiSchema entry, the required entry, and any x-ui-order reference at
|
|
184
|
-
* the same level. Mirrors the graph-model/mutate.ts discipline.
|
|
185
|
-
*/
|
|
186
|
-
|
|
187
|
-
type UiSchemaMap = Record<string, UISchema>;
|
|
188
|
-
interface DesignerModel {
|
|
189
|
-
schema: JsonSchema;
|
|
190
|
-
uiSchema: UiSchemaMap;
|
|
191
|
-
}
|
|
192
|
-
/** Kinds that can be created as a new property. */
|
|
193
|
-
type NewPropertyKind = "scalar" | "object" | "array" | "oneOf";
|
|
194
|
-
/** A default property for a newly created property of a given kind. */
|
|
195
|
-
declare function newProperty(kind: NewPropertyKind): JsonSchemaProperty;
|
|
196
|
-
/** A default oneOf branch: an object with a const-valued `kind` discriminator. */
|
|
197
|
-
declare function newBranch(value: string): JsonSchemaProperty;
|
|
198
|
-
/** Add a property under a parent path (root when empty). Returns the new model. */
|
|
199
|
-
declare function addProperty(model: DesignerModel, parentPath: PropertyPath, kind: NewPropertyKind): {
|
|
200
|
-
model: DesignerModel;
|
|
201
|
-
path: PropertyPath;
|
|
202
|
-
};
|
|
203
|
-
/** Add a branch to the oneOf property at `path`. Returns the new model + branch path. */
|
|
204
|
-
declare function addBranch(model: DesignerModel, path: PropertyPath): {
|
|
205
|
-
model: DesignerModel;
|
|
206
|
-
path: PropertyPath;
|
|
207
|
-
};
|
|
208
|
-
/** Remove the branch at `path` (a branch segment). Returns the new model. */
|
|
209
|
-
declare function removeBranch(model: DesignerModel, path: PropertyPath): DesignerModel;
|
|
210
|
-
/** Move the branch at `path` up (-1) or down (+1) among its siblings. */
|
|
211
|
-
declare function moveBranch(model: DesignerModel, path: PropertyPath, direction: -1 | 1): DesignerModel;
|
|
212
|
-
/**
|
|
213
|
-
* A seed conditional member: an empty `if` (no field yet) plus an empty `then`.
|
|
214
|
-
* The condition is filled in by setCondition; `then` fields are added like any
|
|
215
|
-
* object's properties.
|
|
216
|
-
*/
|
|
217
|
-
declare function newCondition(): JsonSchemaProperty;
|
|
218
|
-
/**
|
|
219
|
-
* Add a conditional (if/then/else) to the object at `objectPath` (root when
|
|
220
|
-
* empty), appended to the given combinator array (`allOf` = AND, default;
|
|
221
|
-
* `anyOf` = OR). Returns the new model + the condition path.
|
|
222
|
-
*/
|
|
223
|
-
declare function addConditional(model: DesignerModel, objectPath: PropertyPath, combinator?: ConditionCombinator): {
|
|
224
|
-
model: DesignerModel;
|
|
225
|
-
path: PropertyPath;
|
|
226
|
-
};
|
|
227
|
-
/** Remove the conditional at `path` (a condition segment). Returns the new model. */
|
|
228
|
-
declare function removeConditional(model: DesignerModel, path: PropertyPath): DesignerModel;
|
|
229
|
-
/** Write the `if` of the conditional at `path` from a condition triple. */
|
|
230
|
-
declare function setCondition(model: DesignerModel, path: PropertyPath, ifSchema: JsonSchemaProperty): DesignerModel;
|
|
231
|
-
/** Add an empty `else` branch to the conditional at `path`. */
|
|
232
|
-
declare function addElse(model: DesignerModel, path: PropertyPath): DesignerModel;
|
|
233
|
-
/** Remove the `else` branch from the conditional at `path`. */
|
|
234
|
-
declare function removeElse(model: DesignerModel, path: PropertyPath): DesignerModel;
|
|
235
|
-
/**
|
|
236
|
-
* Switch the combinator (AND/OR) for the conditionals of the object at
|
|
237
|
-
* `objectPath`. Migrates every conditional member from the current combinator
|
|
238
|
-
* array to `next`. Non-conditional members (structural allOf/anyOf entries)
|
|
239
|
-
* stay put. No-op when already using `next` or when there are no conditionals.
|
|
240
|
-
*/
|
|
241
|
-
declare function setConditionalBehavior(model: DesignerModel, objectPath: PropertyPath, next: ConditionCombinator): DesignerModel;
|
|
242
|
-
/** Delete the property at path. Returns the new model. */
|
|
243
|
-
declare function deleteProperty(model: DesignerModel, path: PropertyPath): DesignerModel;
|
|
244
|
-
/** Rename the property at path. Rewrites key, order, required, and uiSchema. */
|
|
245
|
-
declare function renameProperty(model: DesignerModel, path: PropertyPath, nextKey: string): {
|
|
246
|
-
model: DesignerModel;
|
|
247
|
-
path: PropertyPath;
|
|
248
|
-
};
|
|
249
|
-
/** Move the property at path up (-1) or down (+1) among its siblings. */
|
|
250
|
-
declare function moveProperty(model: DesignerModel, path: PropertyPath, direction: -1 | 1): DesignerModel;
|
|
251
|
-
/** Toggle whether the property at path is required among its siblings. */
|
|
252
|
-
declare function setRequired(model: DesignerModel, path: PropertyPath, required: boolean): DesignerModel;
|
|
253
|
-
/** Replace the property definition at path (merges the given partial). */
|
|
254
|
-
declare function updateProperty(model: DesignerModel, path: PropertyPath, patch: Partial<JsonSchemaProperty>): DesignerModel;
|
|
255
|
-
/** The kind a property can be changed to: a JSON Schema type, or a "oneOf" union. */
|
|
256
|
-
type PropertyTypeChoice = NonNullable<JsonSchemaProperty["type"]> | "oneOf";
|
|
257
|
-
/**
|
|
258
|
-
* Change the kind of the property at path, reshaping structural keys: object
|
|
259
|
-
* adds an empty `properties`; array adds `items`; oneOf adds branches + a
|
|
260
|
-
* discriminator; leaving a kind strips its keys. Type-specific validation keys
|
|
261
|
-
* that no longer apply are dropped.
|
|
262
|
-
*/
|
|
263
|
-
declare function changePropertyType(model: DesignerModel, path: PropertyPath, next: PropertyTypeChoice): DesignerModel;
|
|
264
|
-
/**
|
|
265
|
-
* Point the property at path to a definition by name, writing a local `$ref`
|
|
266
|
-
* (`#/$defs/<name>`) and stripping type-specific keys. Turns a plain property
|
|
267
|
-
* into a reference usage. No-op for the root or an unknown target.
|
|
268
|
-
*/
|
|
269
|
-
declare function setReference(model: DesignerModel, path: PropertyPath, name: string): DesignerModel;
|
|
270
|
-
/**
|
|
271
|
-
* Add a new empty object definition under `$defs`. Returns the new model and the
|
|
272
|
-
* path to the created definition for selection.
|
|
273
|
-
*/
|
|
274
|
-
declare function addDefinition(model: DesignerModel, name?: string): {
|
|
275
|
-
model: DesignerModel;
|
|
276
|
-
path: PropertyPath;
|
|
277
|
-
};
|
|
278
|
-
/**
|
|
279
|
-
* Rename a `$defs` entry, preserving order, and rewrite every local `$ref` that
|
|
280
|
-
* targets it (both `#/$defs/` and `#/definitions/` forms) to the new pointer.
|
|
281
|
-
* No-op on collision, reserved, or empty names.
|
|
282
|
-
*/
|
|
283
|
-
declare function renameDefinition(model: DesignerModel, oldName: string, newName: string): {
|
|
284
|
-
model: DesignerModel;
|
|
285
|
-
path: PropertyPath;
|
|
286
|
-
};
|
|
287
|
-
/**
|
|
288
|
-
* Remove a `$defs` entry. Blocked (no-op) while any local `$ref` still targets
|
|
289
|
-
* it; the UI surfaces the usage count. Drops the `$defs` map when it empties.
|
|
290
|
-
*/
|
|
291
|
-
declare function removeDefinition(model: DesignerModel, name: string): DesignerModel;
|
|
292
|
-
/** Whether a definition is referenced anywhere (for UI delete-guard messaging). */
|
|
293
|
-
declare function definitionUsageCount(schema: JsonSchema, name: string): number;
|
|
294
|
-
/** One enum choice: a value and an optional display label. */
|
|
295
|
-
interface EnumChoice {
|
|
296
|
-
value: string;
|
|
297
|
-
label?: string;
|
|
298
|
-
}
|
|
299
|
-
declare function setEnum(model: DesignerModel, path: PropertyPath, choices: EnumChoice[]): DesignerModel;
|
|
300
|
-
/** Read the current enum choices for a property + its uiSchema entry. */
|
|
301
|
-
declare function readEnumChoices(prop: JsonSchemaProperty, uiEntry: UISchema | undefined): EnumChoice[];
|
|
302
|
-
/** Table presentation hints for a property (embedded in the schema). */
|
|
303
|
-
interface TableHints {
|
|
304
|
-
cell?: string;
|
|
305
|
-
cellOptions?: Record<string, unknown>;
|
|
306
|
-
column?: NonNullable<JsonSchemaProperty["x-ui-column"]>;
|
|
307
|
-
}
|
|
308
|
-
/**
|
|
309
|
-
* Set (or clear) a property's table hints: x-ui-cell, x-ui-cell-options, and
|
|
310
|
-
* x-ui-column. These live embedded on the property (EntityTable reads them
|
|
311
|
-
* there). Empty values clear the corresponding key.
|
|
312
|
-
*/
|
|
313
|
-
declare function setTableHints(model: DesignerModel, path: PropertyPath, hints: TableHints): DesignerModel;
|
|
314
|
-
/** Read a property's current table hints. */
|
|
315
|
-
declare function readTableHints(prop: JsonSchemaProperty): TableHints;
|
|
316
|
-
/** Read the UISchema entry for a property path, or undefined. */
|
|
317
|
-
declare function getUiEntryAtPath(uiSchema: UiSchemaMap, path: PropertyPath): UISchema | undefined;
|
|
318
|
-
/** Set (or clear) the UISchema entry at a property path (any nesting depth). */
|
|
319
|
-
declare function setUiEntry(model: DesignerModel, path: PropertyPath, entry: UISchema | undefined): DesignerModel;
|
|
320
|
-
/**
|
|
321
|
-
* Set (or clear) the x-ui-layout of an object/array property at path. Object
|
|
322
|
-
* layout lives on the property; array layout lives on `items`.
|
|
323
|
-
*/
|
|
324
|
-
declare function setPropertyLayout(model: DesignerModel, path: PropertyPath, layout: UILayoutConfig | undefined): DesignerModel;
|
|
325
|
-
/** Set (or clear) the root form layout (uiSchema["x-ui-layout"]). */
|
|
326
|
-
declare function setRootLayout(model: DesignerModel, layout: UILayoutConfig | undefined): DesignerModel;
|
|
327
|
-
/**
|
|
328
|
-
* Set (or clear) the root layout rows (uiSchema["x-ui-layout"].rows),
|
|
329
|
-
* preserving other x-ui-layout keys. Clearing rows to empty removes the key;
|
|
330
|
-
* if x-ui-layout then has no keys, it is removed entirely.
|
|
331
|
-
*/
|
|
332
|
-
declare function setRootLayoutRows(model: DesignerModel, rows: UILayoutConfig["rows"]): DesignerModel;
|
|
333
|
-
/**
|
|
334
|
-
* Set the layout rows for a scope: the root form (path []) or an object/array
|
|
335
|
-
* container (its property path). Root rows live in uiSchema["x-ui-layout"];
|
|
336
|
-
* a container's rows live on the property's x-ui-layout (array -> items).
|
|
337
|
-
* Preserves other x-ui-layout keys.
|
|
338
|
-
*/
|
|
339
|
-
declare function setScopedLayoutRows(model: DesignerModel, scopePath: PropertyPath, rows: UILayoutConfig["rows"]): DesignerModel;
|
|
340
|
-
/** Read the current x-ui-layout for a scope (root or a container property). */
|
|
341
|
-
declare function getScopedLayout(schema: JsonSchema, uiSchema: UiSchemaMap, scopePath: PropertyPath): UILayoutConfig | undefined;
|
|
342
|
-
/**
|
|
343
|
-
* Merge scalar layout options (direction/gap/labels/compact) into a scope's
|
|
344
|
-
* x-ui-layout, preserving rows and other keys. Undefined values clear the key.
|
|
345
|
-
*/
|
|
346
|
-
declare function setScopedLayoutOptions(model: DesignerModel, scopePath: PropertyPath, options: Pick<UILayoutConfig, "direction" | "gap" | "labels" | "compact">): DesignerModel;
|
|
347
|
-
/**
|
|
348
|
-
* Set the group definitions for a scope, preserving other x-ui-layout keys.
|
|
349
|
-
* Passing an empty list (or undefined) clears groups, returning the scope to the
|
|
350
|
-
* flat row layout. Root groups live in uiSchema["x-ui-layout"]; a container's
|
|
351
|
-
* live on the property's x-ui-layout (array -> items).
|
|
352
|
-
*
|
|
353
|
-
* Groups and flat rows are mutually exclusive (the renderer gives groups
|
|
354
|
-
* precedence), so setting groups drops `rows` -- otherwise the orphaned list
|
|
355
|
-
* would be invisible in both the form and the designer.
|
|
356
|
-
*/
|
|
357
|
-
declare function setScopedLayoutGroups(model: DesignerModel, scopePath: PropertyPath, groups: UILayoutConfig["groups"]): DesignerModel;
|
|
358
|
-
/** Append an empty group. The label defaults to the next ordinal ("Group 3"). */
|
|
359
|
-
declare function addLayoutGroup(model: DesignerModel, scopePath: PropertyPath, label?: string): DesignerModel;
|
|
360
|
-
/** Rename one group. No-op for an unknown index or a blank label. */
|
|
361
|
-
declare function renameLayoutGroup(model: DesignerModel, scopePath: PropertyPath, groupIndex: number, label: string): DesignerModel;
|
|
362
|
-
/**
|
|
363
|
-
* Place a property into one group's row, removing it from wherever it currently
|
|
364
|
-
* sits across *all* groups. Passing a null target returns it to the pool.
|
|
365
|
-
*
|
|
366
|
-
* Needed because each group owns its own rows: without a cross-group operation a
|
|
367
|
-
* field could only be moved between groups by visiting its old group first.
|
|
368
|
-
*/
|
|
369
|
-
declare function placeFieldInGroup(model: DesignerModel, scopePath: PropertyPath, key: string, target: {
|
|
370
|
-
groupIndex: number;
|
|
371
|
-
rowIndex: number;
|
|
372
|
-
} | null): DesignerModel;
|
|
373
|
-
/** Move one group left (-1) or right (+1). No-op at the ends. */
|
|
374
|
-
declare function moveLayoutGroup(model: DesignerModel, scopePath: PropertyPath, groupIndex: number, direction: -1 | 1): DesignerModel;
|
|
375
|
-
/**
|
|
376
|
-
* Set (or clear) a group's show/hide rule. Passing undefined makes the group
|
|
377
|
-
* unconditional.
|
|
378
|
-
*/
|
|
379
|
-
declare function setLayoutGroupRule(model: DesignerModel, scopePath: PropertyPath, groupIndex: number, rule: UILayoutGroupConfig["rule"]): DesignerModel;
|
|
380
|
-
/**
|
|
381
|
-
* Set the group presentation for a scope ("groups", "stepper", or a custom
|
|
382
|
-
* template name). Passing undefined restores the default group presentation.
|
|
383
|
-
*/
|
|
384
|
-
declare function setScopedLayoutVariant(model: DesignerModel, scopePath: PropertyPath, variant: UILayoutConfig["variant"]): DesignerModel;
|
|
385
|
-
/**
|
|
386
|
-
* Remove one group. Its rows are not discarded: removing the last remaining group
|
|
387
|
-
* flattens them back into the scope's flat row layout, so a single click can
|
|
388
|
-
* never destroy every field placement.
|
|
389
|
-
*/
|
|
390
|
-
declare function removeLayoutGroup(model: DesignerModel, scopePath: PropertyPath, groupIndex: number): DesignerModel;
|
|
391
|
-
/** Replace the rows of one group in a scope. No-op for an unknown group index. */
|
|
392
|
-
declare function setScopedGroupRows(model: DesignerModel, scopePath: PropertyPath, groupIndex: number, rows: UILayoutRowConfig[]): DesignerModel;
|
|
393
|
-
/**
|
|
394
|
-
* Switch a scope between flat rows and groups, carrying the existing layout over
|
|
395
|
-
* so no field placement is lost: rows become the first group's rows, and leaving
|
|
396
|
-
* group mode flattens every group's rows back into one list.
|
|
397
|
-
*/
|
|
398
|
-
declare function setScopedLayoutMode(model: DesignerModel, scopePath: PropertyPath, mode: "rows" | "groups"): DesignerModel;
|
|
399
|
-
/** Set (or clear) the root global options (uiSchema["x-ui-globalOptions"]). */
|
|
400
|
-
declare function setGlobalOptions(model: DesignerModel, options: UISchemaOptions | undefined): DesignerModel;
|
|
401
|
-
|
|
402
71
|
/**
|
|
403
72
|
* Type -> compatible form widgets for the inspector's widget dropdown.
|
|
404
73
|
*
|
|
@@ -466,8 +135,8 @@ type PreviewKind = z.infer<typeof previewKindSchema>;
|
|
|
466
135
|
*/
|
|
467
136
|
declare const capabilitiesSchema: z.ZodObject<{
|
|
468
137
|
mode: z.ZodDefault<z.ZodEnum<{
|
|
469
|
-
full: "full";
|
|
470
138
|
data: "data";
|
|
139
|
+
full: "full";
|
|
471
140
|
}>>;
|
|
472
141
|
previews: z.ZodOptional<z.ZodArray<z.ZodEnum<{
|
|
473
142
|
form: "form";
|
|
@@ -593,6 +262,12 @@ interface DesignerState {
|
|
|
593
262
|
replaceSchema: (schema: JsonSchema) => void;
|
|
594
263
|
/** Replace the whole UI Schema map (from the editable UI Schema source tab). */
|
|
595
264
|
replaceUiSchema: (uiSchema: UiSchemaMap) => void;
|
|
265
|
+
/**
|
|
266
|
+
* Apply one edit to the current model -- schema and uiSchema together, in one
|
|
267
|
+
* commit. For editors built on the pure model operations (the questionnaire
|
|
268
|
+
* designer). Gated by capabilities.locked; keeps the selection.
|
|
269
|
+
*/
|
|
270
|
+
applyEdit: (edit: (model: DesignerModel) => DesignerModel) => void;
|
|
596
271
|
setEnum: (path: PropertyPath, choices: EnumChoice[]) => void;
|
|
597
272
|
setUiEntry: (path: PropertyPath, entry: UISchema | undefined) => void;
|
|
598
273
|
setTableHints: (path: PropertyPath, hints: TableHints) => void;
|
|
@@ -631,9 +306,10 @@ declare function useDesignerState(args: UseDesignerStateArgs): DesignerState;
|
|
|
631
306
|
/**
|
|
632
307
|
* SchemaDesigner -- visual, controlled designer for a JsonSchema (+ uiSchema).
|
|
633
308
|
*
|
|
634
|
-
* Layout: Tree | Preview | Inspector
|
|
635
|
-
*
|
|
636
|
-
*
|
|
309
|
+
* Layout: Tree | Preview | Inspector, in the DesignerFrame the package's
|
|
310
|
+
* designers share. The preview (the live form) is the hero and takes the
|
|
311
|
+
* flexible center, matching visual-builder convention; the inspector is the
|
|
312
|
+
* resizable/collapsible right pane. Controlled via `schema` +
|
|
637
313
|
* `uiSchema` + `onChange`, or uncontrolled via `initialSchema`. Read-only is a
|
|
638
314
|
* mode of the same component.
|
|
639
315
|
*
|
|
@@ -670,7 +346,101 @@ interface SchemaDesignerProps {
|
|
|
670
346
|
*/
|
|
671
347
|
refResolver?: RefResolver;
|
|
672
348
|
}
|
|
673
|
-
declare function SchemaDesigner(props: SchemaDesignerProps):
|
|
349
|
+
declare function SchemaDesigner(props: SchemaDesignerProps): React__default.ReactElement;
|
|
350
|
+
|
|
351
|
+
/** A value type as the questionnaire designer offers it. */
|
|
352
|
+
interface QuestionnaireValueType extends ValueTypeAnswer {
|
|
353
|
+
/** Its icon in the question list; a generic one when omitted. */
|
|
354
|
+
icon?: LucideIcon;
|
|
355
|
+
/** The widgets its form entry needs, when they are not the renderer's own. */
|
|
356
|
+
widgets?: WidgetRegistry;
|
|
357
|
+
}
|
|
358
|
+
/** The quantity, as sonnet contributes it. */
|
|
359
|
+
declare const QUANTITY_VALUE_TYPE: QuestionnaireValueType;
|
|
360
|
+
/** The coded value, as sonnet contributes it. */
|
|
361
|
+
declare const CODING_VALUE_TYPE: QuestionnaireValueType;
|
|
362
|
+
/** The value types the designer offers when it is handed none: the core types. */
|
|
363
|
+
declare const DEFAULT_QUESTIONNAIRE_VALUE_TYPES: readonly QuestionnaireValueType[];
|
|
364
|
+
/** The icon of a contributed value type when it names none. */
|
|
365
|
+
declare const VALUE_TYPE_ICON: React.ForwardRefExoticComponent<Omit<lucide_react.LucideProps, "ref"> & React.RefAttributes<SVGSVGElement>>;
|
|
366
|
+
|
|
367
|
+
/**
|
|
368
|
+
* QuestionnaireDesigner -- a questionnaire designer for people who author
|
|
369
|
+
* forms, not schemas. It edits the same JSON Schema (+ uiSchema) as the schema
|
|
370
|
+
* designer, in the same frame: the questions on the left, the live form in the
|
|
371
|
+
* centre, the selected question on the right, in the author's words.
|
|
372
|
+
*
|
|
373
|
+
* It never loses information: every part of a schema is shown, the parts it
|
|
374
|
+
* does not understand are kept as they are (classifyQuestionnaire), and every
|
|
375
|
+
* edit changes only what it touches (edit.ts). A capability profile limits
|
|
376
|
+
* what may be built; the way to the schema designer is the application's to
|
|
377
|
+
* offer. See docs/design/questionnaires.md.
|
|
378
|
+
*/
|
|
379
|
+
|
|
380
|
+
interface QuestionnaireDesignerProps {
|
|
381
|
+
/** Controlled schema. Provide with onChange. */
|
|
382
|
+
schema?: JsonSchema;
|
|
383
|
+
/** Controlled uiSchema map (form presentation hints). */
|
|
384
|
+
uiSchema?: Record<string, UISchema>;
|
|
385
|
+
/** Uncontrolled seed schema (used when `schema` is omitted). */
|
|
386
|
+
initialSchema?: JsonSchema;
|
|
387
|
+
/** Uncontrolled seed uiSchema. */
|
|
388
|
+
initialUiSchema?: Record<string, UISchema>;
|
|
389
|
+
/** Called on every edit with the new schema + uiSchema. */
|
|
390
|
+
onChange?: (schema: JsonSchema, uiSchema: Record<string, UISchema>) => void;
|
|
391
|
+
/** View-only: no edit affordances, onChange never fires. */
|
|
392
|
+
readOnly?: boolean;
|
|
393
|
+
/** What the author may build; every capability on when omitted. */
|
|
394
|
+
capabilities?: QuestionnaireDesignerCapabilities;
|
|
395
|
+
/**
|
|
396
|
+
* Open the same schema in the schema designer -- for what this designer does
|
|
397
|
+
* not offer. The application switches; nothing is converted. Without it, or
|
|
398
|
+
* with the profile's `switchToDesigner` off, no way is shown.
|
|
399
|
+
*/
|
|
400
|
+
onOpenSchemaDesigner?: () => void;
|
|
401
|
+
/**
|
|
402
|
+
* The value types offered as answer types, beside the built-in ones -- the
|
|
403
|
+
* core types when omitted. An application adds its own here; see
|
|
404
|
+
* docs/design/value-types.md (workspace).
|
|
405
|
+
*/
|
|
406
|
+
valueTypes?: readonly QuestionnaireValueType[];
|
|
407
|
+
/**
|
|
408
|
+
* Keywords a question keeps when its answer type changes -- an application's
|
|
409
|
+
* annotations that do not depend on the type, such as a converter's
|
|
410
|
+
* (sonnet-fhir: `FHIR_TYPE_INDEPENDENT_ANNOTATIONS`). Any other keyword the
|
|
411
|
+
* question carries beyond its type is dropped, and named first.
|
|
412
|
+
*/
|
|
413
|
+
keptOnTypeChange?: readonly string[];
|
|
414
|
+
}
|
|
415
|
+
declare function QuestionnaireDesigner(props: QuestionnaireDesignerProps): React__default.ReactElement;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* DesignerFrame -- the frame the designers of this package share: a list pane
|
|
419
|
+
* on the left, the hero in the centre, a details pane on the right, in one
|
|
420
|
+
* box. Both side panes resize and collapse; the left one grows to fill when
|
|
421
|
+
* there is no centre. One frame, so the schema designer and the questionnaire
|
|
422
|
+
* designer look and behave as one family.
|
|
423
|
+
*/
|
|
424
|
+
|
|
425
|
+
interface DesignerFrameProps {
|
|
426
|
+
/** The left pane's content; given the function that collapses the pane. */
|
|
427
|
+
left: (collapse: () => void) => React__default.ReactNode;
|
|
428
|
+
/** The label of the button that brings the collapsed left pane back. */
|
|
429
|
+
leftExpandLabel: string;
|
|
430
|
+
/** The centre; none hides it, and the left pane fills its place. */
|
|
431
|
+
center?: React__default.ReactNode;
|
|
432
|
+
/** The right pane's heading. */
|
|
433
|
+
rightHeading: string;
|
|
434
|
+
/** Actions beside the right pane's heading -- shown on its collapsed rail too. */
|
|
435
|
+
rightActions?: React__default.ReactNode;
|
|
436
|
+
/** The right pane's content. */
|
|
437
|
+
right: React__default.ReactNode;
|
|
438
|
+
/** What the right pane is called in its collapse and expand labels. */
|
|
439
|
+
rightName: string;
|
|
440
|
+
/** Rendered inside the frame, after the panes (a sheet, a dialog). */
|
|
441
|
+
children?: React__default.ReactNode;
|
|
442
|
+
}
|
|
443
|
+
declare function DesignerFrame({ left, leftExpandLabel, center, rightHeading, rightActions, right, rightName, children, }: DesignerFrameProps): React__default.ReactElement;
|
|
674
444
|
|
|
675
445
|
/**
|
|
676
446
|
* PropertyTree -- the left pane. Renders the schema's properties as a
|
|
@@ -683,7 +453,7 @@ interface PropertyTreeProps {
|
|
|
683
453
|
/** When provided, renders a collapse button in the header. */
|
|
684
454
|
onCollapse?: () => void;
|
|
685
455
|
}
|
|
686
|
-
declare function PropertyTree({ state, onCollapse, }: PropertyTreeProps):
|
|
456
|
+
declare function PropertyTree({ state, onCollapse, }: PropertyTreeProps): React__default.ReactElement;
|
|
687
457
|
|
|
688
458
|
/**
|
|
689
459
|
* PreviewPane -- the center pane. Tabs: Form (live rendered form), JSON Schema
|
|
@@ -701,7 +471,7 @@ interface PreviewPaneProps {
|
|
|
701
471
|
/** Apply an edited profile (from the Capabilities tab). */
|
|
702
472
|
onCapabilitiesChange?: (next: SchemaDesignerCapabilities) => void;
|
|
703
473
|
}
|
|
704
|
-
declare function PreviewPane({ state, capabilities, onCapabilitiesChange, }: PreviewPaneProps):
|
|
474
|
+
declare function PreviewPane({ state, capabilities, onCapabilitiesChange, }: PreviewPaneProps): React__default.ReactElement;
|
|
705
475
|
|
|
706
476
|
/**
|
|
707
477
|
* TablePreview -- renders the schema as an EntityTable using auto-generated
|
|
@@ -713,7 +483,7 @@ interface TablePreviewProps {
|
|
|
713
483
|
schema: JsonSchema;
|
|
714
484
|
uiSchema?: TableUiSchema;
|
|
715
485
|
}
|
|
716
|
-
declare function TablePreview({ schema, uiSchema, }: TablePreviewProps):
|
|
486
|
+
declare function TablePreview({ schema, uiSchema, }: TablePreviewProps): React__default.ReactElement;
|
|
717
487
|
|
|
718
488
|
/**
|
|
719
489
|
* Generate plausible sample rows from a JsonSchema, for the table preview.
|
|
@@ -742,7 +512,7 @@ declare function sampleRows(schema: JsonSchema, count?: number): Row[];
|
|
|
742
512
|
interface FormLayoutDesignerProps {
|
|
743
513
|
state: DesignerState;
|
|
744
514
|
}
|
|
745
|
-
declare function FormLayoutDesigner({ state, }: FormLayoutDesignerProps):
|
|
515
|
+
declare function FormLayoutDesigner({ state, }: FormLayoutDesignerProps): React__default.ReactElement;
|
|
746
516
|
|
|
747
517
|
/**
|
|
748
518
|
* Inspector -- the right pane. Resolves the selected property and hosts the tabbed
|
|
@@ -755,7 +525,7 @@ interface InspectorProps {
|
|
|
755
525
|
/** Option descriptors for custom widgets (merged over built-ins). */
|
|
756
526
|
widgetOptions?: Record<string, WidgetOptionDef[]>;
|
|
757
527
|
}
|
|
758
|
-
declare function Inspector({ state, widgetOptions, }: InspectorProps):
|
|
528
|
+
declare function Inspector({ state, widgetOptions, }: InspectorProps): React__default.ReactElement;
|
|
759
529
|
|
|
760
530
|
/**
|
|
761
531
|
* DataTab -- edits a property's data definition (type, title, description,
|
|
@@ -768,7 +538,7 @@ interface DataTabProps {
|
|
|
768
538
|
node: PropertyNode;
|
|
769
539
|
state: DesignerState;
|
|
770
540
|
}
|
|
771
|
-
declare function DataTab({ node, state }: DataTabProps):
|
|
541
|
+
declare function DataTab({ node, state }: DataTabProps): React__default.ReactElement;
|
|
772
542
|
|
|
773
543
|
/**
|
|
774
544
|
* UITab -- edits a property's form presentation hints: the widget (x-ui-widget)
|
|
@@ -787,7 +557,7 @@ interface UITabProps {
|
|
|
787
557
|
/** Consumer-supplied option descriptors for custom widgets (merged over built-ins). */
|
|
788
558
|
widgetOptions?: Record<string, WidgetOptionDef[]>;
|
|
789
559
|
}
|
|
790
|
-
declare function UITab({ node, state, widgetOptions, }: UITabProps):
|
|
560
|
+
declare function UITab({ node, state, widgetOptions, }: UITabProps): React__default.ReactElement;
|
|
791
561
|
|
|
792
562
|
/**
|
|
793
563
|
* EnumEditor -- edits a scalar property's allowed values (enum) and optional
|
|
@@ -803,7 +573,7 @@ interface EnumEditorProps {
|
|
|
803
573
|
node: PropertyNode;
|
|
804
574
|
state: DesignerState;
|
|
805
575
|
}
|
|
806
|
-
declare function EnumEditor({ node, state, }: EnumEditorProps):
|
|
576
|
+
declare function EnumEditor({ node, state, }: EnumEditorProps): React__default.ReactElement;
|
|
807
577
|
|
|
808
578
|
/**
|
|
809
579
|
* TableHintsTab -- edits a property's table presentation hints (x-ui-cell,
|
|
@@ -819,7 +589,7 @@ interface TableHintsTabProps {
|
|
|
819
589
|
node: PropertyNode;
|
|
820
590
|
state: DesignerState;
|
|
821
591
|
}
|
|
822
|
-
declare function TableHintsTab({ node, state, }: TableHintsTabProps):
|
|
592
|
+
declare function TableHintsTab({ node, state, }: TableHintsTabProps): React__default.ReactElement;
|
|
823
593
|
|
|
824
594
|
/**
|
|
825
595
|
* FormSettingsSheet -- form-level (root) settings in a right-side Sheet, opened
|
|
@@ -836,6 +606,7 @@ interface FormSettingsSheetProps {
|
|
|
836
606
|
onOpenChange: (open: boolean) => void;
|
|
837
607
|
state: DesignerState;
|
|
838
608
|
}
|
|
839
|
-
declare function FormSettingsSheet({ open, onOpenChange, state, }: FormSettingsSheetProps):
|
|
609
|
+
declare function FormSettingsSheet({ open, onOpenChange, state, }: FormSettingsSheetProps): React__default.ReactElement;
|
|
840
610
|
|
|
841
|
-
export {
|
|
611
|
+
export { CODING_VALUE_TYPE, ConditionCombinator, DEFAULT_QUESTIONNAIRE_VALUE_TYPES, DataTab, DesignerFrame, DesignerModel, EnumChoice, EnumEditor, FormLayoutDesigner, FormSettingsSheet, Inspector, NewPropertyKind, PreviewPane, PropertyPath, PropertyTree, PropertyTypeChoice, QUANTITY_VALUE_TYPE, QuestionnaireDesigner, QuestionnaireDesignerCapabilities, SchemaDesigner, SlotKind, TableHints, TableHintsTab, TablePreview, UITab, UiSchemaMap, VALUE_TYPE_ICON, ValueTypeAnswer, buildPropertyTree, capabilitiesSchema, compatibleWidgets, embedUiSchema, layoutScopes, orderedKeys, propertyKind, resolveCapabilities, sampleRows, useDesignerState, validateCapabilities };
|
|
612
|
+
export type { CapabilitiesValidation, DesignerFrameProps, DesignerState, LayoutScope, PreviewKind, PropertyKind, PropertyNode, QuestionnaireDesignerProps, QuestionnaireValueType, ResolvedCapabilities, SchemaDesignerCapabilities, SchemaDesignerProps, UseDesignerStateArgs, WidgetChoice };
|