@kerfjs/ui 5.0.0-beta.125 → 5.0.0-beta.127
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 +5 -0
- package/ai/application-ui-diagnostic-ids-v1.json +1 -0
- package/ai/component-catalog.json +77 -6
- package/ai/component-catalog.schema.json +14 -1
- package/ai/component-composition.json +27 -6
- package/ai/component-props.json +265 -40
- package/ai/components/combobox.md +1 -1
- package/ai/components/surface-scaffold.md +19 -5
- package/ai/components/tab-bar.md +2 -0
- package/ai/components/toolbar.md +1 -0
- package/ai/public-api-signatures-v1.md +251 -298
- package/ai/skill.md +10 -4
- package/ai/view-document.schema.json +55 -2
- package/ai/webawesome-jsx-signatures-v1.md +1 -1
- package/analyzer/cli.mjs +60 -24
- package/analyzer/index.mjs +331 -58
- package/catalog-projection-cli.mjs +86 -50
- package/dist/anchored-surface.js +2 -1
- package/dist/browser/editor.js +12 -7
- package/dist/catalog-resources.d.ts +1 -1
- package/dist/catalog.d.ts +1 -1
- package/dist/catalog.js +6 -6
- package/dist/{chunk-VX3YF2UD.js → chunk-3K5V3ZSD.js} +3 -3
- package/dist/{chunk-VX3YF2UD.js.map → chunk-3K5V3ZSD.js.map} +1 -1
- package/dist/{chunk-NHQOX7T4.js → chunk-3ZKUXWAV.js} +4 -4
- package/dist/chunk-3ZKUXWAV.js.map +1 -0
- package/dist/{chunk-ADMWT7FX.js → chunk-3ZWYGGEC.js} +136 -8
- package/dist/chunk-3ZWYGGEC.js.map +1 -0
- package/dist/{chunk-KLR3DCHH.js → chunk-4L5ZIKDZ.js} +1 -1
- package/dist/chunk-4L5ZIKDZ.js.map +1 -0
- package/dist/{chunk-2E7S5C4D.js → chunk-4UWLHKNU.js} +5 -5
- package/dist/chunk-4UWLHKNU.js.map +1 -0
- package/dist/{chunk-EXGDKG7B.js → chunk-5A2DN3LR.js} +5 -5
- package/dist/chunk-5A2DN3LR.js.map +1 -0
- package/dist/{chunk-DJ65XFVN.js → chunk-63TJH2RF.js} +4 -4
- package/dist/chunk-63TJH2RF.js.map +1 -0
- package/dist/{chunk-Q2CLQ3IJ.js → chunk-6PHG2DMG.js} +1 -1
- package/dist/chunk-6PHG2DMG.js.map +1 -0
- package/dist/{chunk-SPI6VMIY.js → chunk-6T7AX365.js} +4 -4
- package/dist/chunk-6T7AX365.js.map +1 -0
- package/dist/{chunk-GVII4JSD.js → chunk-6V6UHPJD.js} +4 -4
- package/dist/chunk-6V6UHPJD.js.map +1 -0
- package/dist/{chunk-NR3ZO4LK.js → chunk-7U65KLDL.js} +1 -1
- package/dist/chunk-7U65KLDL.js.map +1 -0
- package/dist/chunk-BMOZSNDU.js +133 -0
- package/dist/chunk-BMOZSNDU.js.map +1 -0
- package/dist/{chunk-2LM3PYHA.js → chunk-C2TY5DJC.js} +11 -8
- package/dist/chunk-C2TY5DJC.js.map +1 -0
- package/dist/{chunk-3WYREXW4.js → chunk-COMEWURO.js} +8 -6
- package/dist/chunk-COMEWURO.js.map +1 -0
- package/dist/{chunk-VPDSPD76.js → chunk-DB64I3DB.js} +4 -3
- package/dist/chunk-DB64I3DB.js.map +1 -0
- package/dist/{chunk-SBCXWGNP.js → chunk-DBCDYBZP.js} +2 -2
- package/dist/{chunk-SBCXWGNP.js.map → chunk-DBCDYBZP.js.map} +1 -1
- package/dist/{chunk-CNM6ZWP2.js → chunk-DJWBXEF4.js} +4 -2
- package/dist/chunk-DJWBXEF4.js.map +1 -0
- package/dist/{chunk-SVUJIVMR.js → chunk-E2MTHHLS.js} +3 -3
- package/dist/{chunk-SVUJIVMR.js.map → chunk-E2MTHHLS.js.map} +1 -1
- package/dist/{chunk-JG4ONAOI.js → chunk-EI55KWHP.js} +2 -2
- package/dist/chunk-EI55KWHP.js.map +1 -0
- package/dist/{chunk-MVKHSAKE.js → chunk-GE2BQXB3.js} +41 -4
- package/dist/chunk-GE2BQXB3.js.map +1 -0
- package/dist/chunk-GHV36C6I.js +94 -0
- package/dist/chunk-GHV36C6I.js.map +1 -0
- package/dist/{chunk-BCO673YW.js → chunk-GQUDCWOD.js} +10 -4
- package/dist/chunk-GQUDCWOD.js.map +1 -0
- package/dist/chunk-HD7ZLISK.js +808 -0
- package/dist/chunk-HD7ZLISK.js.map +1 -0
- package/dist/{chunk-KELWWCMX.js → chunk-I2K4OQKB.js} +4 -4
- package/dist/chunk-I2K4OQKB.js.map +1 -0
- package/dist/chunk-IFDTSVE6.js +9 -0
- package/dist/chunk-IFDTSVE6.js.map +1 -0
- package/dist/{chunk-TPLVC5BE.js → chunk-IR32NI2O.js} +336 -247
- package/dist/chunk-IR32NI2O.js.map +1 -0
- package/dist/{chunk-ZKKO4MHC.js → chunk-JYKP7TBZ.js} +4 -2
- package/dist/chunk-JYKP7TBZ.js.map +1 -0
- package/dist/{chunk-6OT7FOSA.js → chunk-K3C35KGR.js} +4 -4
- package/dist/chunk-K3C35KGR.js.map +1 -0
- package/dist/{chunk-4RECPEHI.js → chunk-KBS3GP6S.js} +4 -3
- package/dist/chunk-KBS3GP6S.js.map +1 -0
- package/dist/{chunk-YHRJNKD5.js → chunk-KS7EXW4P.js} +6 -4
- package/dist/chunk-KS7EXW4P.js.map +1 -0
- package/dist/{chunk-V6N3YLTM.js → chunk-LTOTL5AS.js} +3 -3
- package/dist/chunk-LTOTL5AS.js.map +1 -0
- package/dist/chunk-M64TAGZY.js +590 -0
- package/dist/chunk-M64TAGZY.js.map +1 -0
- package/dist/{chunk-JZZVWTUB.js → chunk-MMOQR426.js} +2 -2
- package/dist/chunk-MMOQR426.js.map +1 -0
- package/dist/{chunk-SJBMKA4X.js → chunk-OHT2AXER.js} +11 -10
- package/dist/chunk-OHT2AXER.js.map +1 -0
- package/dist/{chunk-TTFW6E6C.js → chunk-OZKBIPXU.js} +2 -2
- package/dist/chunk-OZKBIPXU.js.map +1 -0
- package/dist/{chunk-Q2SLOMN6.js → chunk-RHMY45DK.js} +4 -4
- package/dist/chunk-RHMY45DK.js.map +1 -0
- package/dist/{chunk-BZXA5SSA.js → chunk-S7QB5KMM.js} +2 -2
- package/dist/{chunk-BZXA5SSA.js.map → chunk-S7QB5KMM.js.map} +1 -1
- package/dist/{chunk-HDXUHLTQ.js → chunk-SHECA2N4.js} +8 -2
- package/dist/chunk-SHECA2N4.js.map +1 -0
- package/dist/{chunk-R6FIXYAE.js → chunk-SJEPM5ZU.js} +2 -2
- package/dist/{chunk-R6FIXYAE.js.map → chunk-SJEPM5ZU.js.map} +1 -1
- package/dist/{chunk-FJMABKKV.js → chunk-UQ4FRQ6M.js} +35 -17
- package/dist/chunk-UQ4FRQ6M.js.map +1 -0
- package/dist/{chunk-S4ZGTDSG.js → chunk-UU37OR3D.js} +2 -2
- package/dist/chunk-UU37OR3D.js.map +1 -0
- package/dist/{chunk-SWXWLSUD.js → chunk-WEQNPYVA.js} +1 -1
- package/dist/{chunk-SWXWLSUD.js.map → chunk-WEQNPYVA.js.map} +1 -1
- package/dist/{chunk-5SFHBYEY.js → chunk-WUVHP3UC.js} +97 -24
- package/dist/chunk-WUVHP3UC.js.map +1 -0
- package/dist/{chunk-3S3WXAZ5.js → chunk-X43QQWVC.js} +3 -2
- package/dist/chunk-X43QQWVC.js.map +1 -0
- package/dist/{chunk-Z3T24FX3.js → chunk-YE6KCAIN.js} +3 -2
- package/dist/chunk-YE6KCAIN.js.map +1 -0
- package/dist/{chunk-KQZIC5CA.js → chunk-ZC4KSRAF.js} +7 -7
- package/dist/chunk-ZC4KSRAF.js.map +1 -0
- package/dist/collapsible-panel.d.ts +2 -2
- package/dist/collapsible-panel.js +2 -2
- package/dist/collapsible-panel.js.map +1 -1
- package/dist/column-explorer.d.ts +3 -3
- package/dist/column-explorer.js +16 -138
- package/dist/column-explorer.js.map +1 -1
- package/dist/dialog-surface-controller-BeKZ3e8Z.d.ts +251 -0
- package/dist/editor-frame.d.ts +1 -1
- package/dist/editor-frame.js +1 -1
- package/dist/editor.d.ts +38 -20
- package/dist/editor.js +11651 -7052
- package/dist/editor.js.map +1 -1
- package/dist/file-picker.js +1 -1
- package/dist/help-tags-register.js +2 -1
- package/dist/help-tags-register.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +24 -23
- package/dist/list-action-row.d.ts +1 -1
- package/dist/list-action-row.js +1 -1
- package/dist/list-detail-dialog.d.ts +7 -7
- package/dist/list-detail-dialog.js +6 -5
- package/dist/list-detail-dialog.js.map +1 -1
- package/dist/list-header.d.ts +1 -1
- package/dist/list-header.js +1 -1
- package/dist/list-item.d.ts +1 -1
- package/dist/list-item.js +1 -1
- package/dist/message-composer.js +1 -1
- package/dist/nav-stack.d.ts +6 -6
- package/dist/nav-stack.js +1 -1
- package/dist/popup-menu-register.js +1 -7
- package/dist/popup-menu-register.js.map +1 -1
- package/dist/popup-menu.d.ts +2 -2
- package/dist/popup-menu.js +1 -1
- package/dist/resizable-region.js +1 -1
- package/dist/segmented-control.d.ts +1 -1
- package/dist/segmented-control.js +1 -1
- package/dist/select-register.js +17 -23
- package/dist/select-register.js.map +1 -1
- package/dist/split-view.d.ts +6 -6
- package/dist/split-view.js +1 -1
- package/dist/styles/collapsible-panel.css +34 -25
- package/dist/styles/components/actions/popup-menu/popup-menu.css +4 -4
- package/dist/styles/components/actions/toolbar/toolbar.css +34 -1
- package/dist/styles/components/actions/toolbar-control-group/toolbar-control-group.css +1 -1
- package/dist/styles/components/forms/segmented-control/segmented-control.css +1 -1
- package/dist/styles/components/layout/collapsible-panel/collapsible-panel.css +34 -25
- package/dist/styles/components/layout/split-view/split-view.css +19 -33
- package/dist/styles/components/navigation/nav-stack/nav-stack.css +15 -19
- package/dist/styles/components/navigation/tab-navigator/tab-navigator.css +30 -29
- package/dist/styles/components/surfaces/editor-frame/editor-frame.css +10 -3
- package/dist/styles/components/surfaces/surface-scaffold/surface-scaffold.css +291 -4
- package/dist/styles/editor/editor.css +78 -0
- package/dist/styles/editor-frame.css +10 -3
- package/dist/styles/nav-stack.css +15 -19
- package/dist/styles/popup-menu.css +4 -4
- package/dist/styles/segmented-control.css +1 -1
- package/dist/styles/split-view.css +19 -33
- package/dist/styles/surface-scaffold.css +291 -4
- package/dist/styles/tab-navigator.css +30 -29
- package/dist/styles/toolbar-control-group.css +1 -1
- package/dist/styles/toolbar.css +34 -1
- package/dist/styles/webawesome.css +4 -5
- package/dist/surface-scaffold-register.js +2 -1
- package/dist/surface-scaffold-register.js.map +1 -1
- package/dist/surface-scaffold.d.ts +155 -246
- package/dist/surface-scaffold.js +3 -2
- package/dist/toolbar-control-group.d.ts +2 -2
- package/dist/toolbar-control-group.js +1 -1
- package/dist/toolbar.d.ts +6 -1
- package/dist/toolbar.js +1 -1
- package/dist/tree-list.d.ts +4 -4
- package/dist/tree-list.js +2 -2
- package/dist/{tree-rows-eHnnGLGM.d.ts → tree-rows-Bms5QJvG.d.ts} +3 -0
- package/dist/wire-catalog.d.ts +1 -1
- package/dist/wire-catalog.js +3 -2
- package/dist/wire-catalog.js.map +1 -1
- package/dist/wire-checkboxes.js +2 -1
- package/dist/wire-choice-chips.js +2 -1
- package/dist/wire-color-fields.js +2 -1
- package/dist/wire-color-pickers.js +2 -1
- package/dist/wire-column-explorer.js +1 -92
- package/dist/wire-column-explorer.js.map +1 -1
- package/dist/wire-comboboxes.d.ts +2 -0
- package/dist/wire-comboboxes.js +2 -1
- package/dist/wire-content-items.js +2 -1
- package/dist/wire-corner-status.js +2 -1
- package/dist/wire-nav-stack.js +2 -1
- package/dist/wire-overlay-sheets.js +2 -1
- package/dist/wire-paged-views.js +2 -2
- package/dist/wire-paged-views.js.map +1 -1
- package/dist/wire-resizable-regions.js +2 -1
- package/dist/wire-scroll-dividers.js +1 -1
- package/dist/wire-search-fields.js +2 -1
- package/dist/wire-sidebar.js +2 -1
- package/dist/wire-tab-bars.d.ts +41 -2
- package/dist/wire-tab-bars.js +1 -1
- package/dist/wire-tab-navigator.js +2 -1
- package/dist/wire-tag-fields.js +2 -1
- package/dist/wire-workbench.js +2 -1
- package/dist/workbench-dialog.d.ts +7 -7
- package/dist/workbench-dialog.js +5 -4
- package/dist/workbench-dialog.js.map +1 -1
- package/dist/workbench.d.ts +1 -1
- package/dist/workbench.js +1 -1
- package/docs/accessibility.md +3 -6
- package/docs/component-contract.md +47 -7
- package/docs/component-selection.md +90 -80
- package/docs/design/templates.md +5 -4
- package/docs/editor-frame.md +1 -1
- package/docs/editor-host.md +15 -2
- package/docs/overlay-tooltip.md +1 -1
- package/docs/recipes.md +1 -1
- package/docs/surface-scaffold.md +63 -2
- package/docs/ui-analyzer.md +42 -0
- package/docs/ui-doctor.md +45 -1
- package/docs/ui-evaluator.md +35 -0
- package/docs/ux-demo.md +1 -1
- package/docs/view.md +314 -0
- package/docs/webawesome-theme.md +16 -0
- package/doctor/cli.mjs +36 -31
- package/doctor/index.mjs +349 -162
- package/evaluator/cli.mjs +36 -30
- package/llms.txt +17 -4
- package/package.json +6 -2
- package/props/cli.mjs +47 -21
- package/scripts/lib/cli-args.mjs +98 -0
- package/ux-demo/recipes/app-shell.tsx +48 -141
- package/ux-demo/recipes/collapsible-sidebar.tsx +43 -169
- package/ux-demo/recipes/compact-toolbar.tsx +22 -114
- package/ux-demo/recipes/composer-form.tsx +14 -104
- package/ux-demo/recipes/list-detail-dialog.tsx +38 -84
- package/ux-demo/recipes/list-workspace-states.tsx +29 -152
- package/ux-demo/recipes/loading-inspector.tsx +30 -174
- package/ux-demo/recipes/media-detail.tsx +29 -146
- package/ux-demo/recipes/navigation-sidebar.tsx +24 -113
- package/ux-demo/recipes/navigation-stack.tsx +7 -43
- package/ux-demo/recipes/workspace-header.tsx +2 -66
- package/view/catalog.mjs +229 -0
- package/view/child-kind.mjs +22 -0
- package/view/cli.mjs +142 -119
- package/view/contract.mjs +84 -11
- package/view/css-grammar.mjs +93 -0
- package/view/generate.d.mts +16 -0
- package/view/generate.mjs +155 -56
- package/view/index.d.mts +80 -14
- package/view/index.mjs +5 -9
- package/view/interpret.mjs +104 -36
- package/view/types.mjs +161 -0
- package/view/validate-move.mjs +66 -30
- package/view/validate.mjs +420 -654
- package/vite-editor.d.mts +16 -1
- package/vite-editor.mjs +74 -4
- package/dist/chunk-2E7S5C4D.js.map +0 -1
- package/dist/chunk-2LM3PYHA.js.map +0 -1
- package/dist/chunk-3S3WXAZ5.js.map +0 -1
- package/dist/chunk-3WYREXW4.js.map +0 -1
- package/dist/chunk-4RECPEHI.js.map +0 -1
- package/dist/chunk-5SFHBYEY.js.map +0 -1
- package/dist/chunk-6OT7FOSA.js.map +0 -1
- package/dist/chunk-ADMWT7FX.js.map +0 -1
- package/dist/chunk-BCO673YW.js.map +0 -1
- package/dist/chunk-CNM6ZWP2.js.map +0 -1
- package/dist/chunk-DJ65XFVN.js.map +0 -1
- package/dist/chunk-EXGDKG7B.js.map +0 -1
- package/dist/chunk-FJMABKKV.js.map +0 -1
- package/dist/chunk-GVII4JSD.js.map +0 -1
- package/dist/chunk-HDXUHLTQ.js.map +0 -1
- package/dist/chunk-JG4ONAOI.js.map +0 -1
- package/dist/chunk-JZZVWTUB.js.map +0 -1
- package/dist/chunk-KELWWCMX.js.map +0 -1
- package/dist/chunk-KLR3DCHH.js.map +0 -1
- package/dist/chunk-KQZIC5CA.js.map +0 -1
- package/dist/chunk-LD6A6PYB.js +0 -268
- package/dist/chunk-LD6A6PYB.js.map +0 -1
- package/dist/chunk-MVKHSAKE.js.map +0 -1
- package/dist/chunk-NHQOX7T4.js.map +0 -1
- package/dist/chunk-NR3ZO4LK.js.map +0 -1
- package/dist/chunk-Q2CLQ3IJ.js.map +0 -1
- package/dist/chunk-Q2SLOMN6.js.map +0 -1
- package/dist/chunk-S4ZGTDSG.js.map +0 -1
- package/dist/chunk-SJBMKA4X.js.map +0 -1
- package/dist/chunk-SPI6VMIY.js.map +0 -1
- package/dist/chunk-TPLVC5BE.js.map +0 -1
- package/dist/chunk-TTFW6E6C.js.map +0 -1
- package/dist/chunk-V6N3YLTM.js.map +0 -1
- package/dist/chunk-VNT4MXR5.js +0 -548
- package/dist/chunk-VNT4MXR5.js.map +0 -1
- package/dist/chunk-VPDSPD76.js.map +0 -1
- package/dist/chunk-YHRJNKD5.js.map +0 -1
- package/dist/chunk-Z3T24FX3.js.map +0 -1
- package/dist/chunk-ZKKO4MHC.js.map +0 -1
- package/dist/{nav-stack-DwxpXxqJ.d.ts → nav-stack-vQ3ieerq.d.ts} +3 -3
package/view/index.d.mts
CHANGED
|
@@ -48,13 +48,41 @@ export interface ViewNode {
|
|
|
48
48
|
readonly src?: string;
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
+
/**
|
|
52
|
+
* A row design chosen per item: every branch is one keyable node, and `else`
|
|
53
|
+
* is required, so each item yields exactly one row.
|
|
54
|
+
*/
|
|
55
|
+
export interface ViewTemplateChain {
|
|
56
|
+
readonly $if: ViewValue;
|
|
57
|
+
readonly then: ViewNode;
|
|
58
|
+
readonly else: ViewTemplate;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/** An `$each` template: one node, or an `$if` chain of them. */
|
|
62
|
+
export type ViewTemplate = ViewNode | ViewTemplateChain;
|
|
63
|
+
|
|
51
64
|
export type ViewChild =
|
|
52
65
|
| ViewNode
|
|
53
66
|
| {
|
|
54
67
|
readonly $each: ViewValue;
|
|
55
68
|
readonly as: string;
|
|
56
69
|
readonly key: string;
|
|
57
|
-
|
|
70
|
+
/** One node, or a `ViewTemplateChain` that picks one per item. */
|
|
71
|
+
readonly template: ViewTemplate;
|
|
72
|
+
}
|
|
73
|
+
| {
|
|
74
|
+
readonly $each: ViewValue;
|
|
75
|
+
readonly as: string;
|
|
76
|
+
readonly key: string;
|
|
77
|
+
/**
|
|
78
|
+
* One row node per item kind; `kind` picks one, and an item of any
|
|
79
|
+
* other kind takes `default`, which is required.
|
|
80
|
+
*/
|
|
81
|
+
readonly templates: Readonly<Record<string, ViewNode>> & {
|
|
82
|
+
readonly default: ViewNode;
|
|
83
|
+
};
|
|
84
|
+
/** A string in the item's scope, such as `{ "$bind": "item.kind" }`. */
|
|
85
|
+
readonly kind: ViewValue;
|
|
58
86
|
}
|
|
59
87
|
| {
|
|
60
88
|
readonly $if: ViewValue;
|
|
@@ -66,6 +94,28 @@ export type ViewChild =
|
|
|
66
94
|
readonly input?: Readonly<Record<string, ViewValue>>;
|
|
67
95
|
};
|
|
68
96
|
|
|
97
|
+
/** An `$each` list child: one template, or per-kind `templates`. */
|
|
98
|
+
export type ViewEachChild = Extract<ViewChild, { readonly $each: ViewValue }>;
|
|
99
|
+
/** An `$if` branch child. */
|
|
100
|
+
export type ViewIfChild = Extract<ViewChild, { readonly $if: ViewValue }>;
|
|
101
|
+
/** A `$slot` placement child. */
|
|
102
|
+
export type ViewSlotChild = Extract<ViewChild, { readonly $slot: string }>;
|
|
103
|
+
|
|
104
|
+
/** A view child's kind; `view` is a composed `#view` node. */
|
|
105
|
+
export type ViewChildKind = 'each' | 'if' | 'slot' | 'view' | 'node';
|
|
106
|
+
|
|
107
|
+
/** A view child paired with its kind, narrowed by a switch on `kind`. */
|
|
108
|
+
export type ClassifiedViewChild =
|
|
109
|
+
| { readonly kind: 'each'; readonly child: ViewEachChild }
|
|
110
|
+
| { readonly kind: 'if'; readonly child: ViewIfChild }
|
|
111
|
+
| { readonly kind: 'slot'; readonly child: ViewSlotChild }
|
|
112
|
+
| { readonly kind: 'view' | 'node'; readonly child: ViewNode };
|
|
113
|
+
|
|
114
|
+
/** The kind of a view child: the one shared child-kind dispatch. */
|
|
115
|
+
export function childKind(child: ViewChild): ViewChildKind;
|
|
116
|
+
/** The child with its kind; switching on `.kind` narrows `.child`. */
|
|
117
|
+
export function classifyChild(child: ViewChild): ClassifiedViewChild;
|
|
118
|
+
|
|
69
119
|
export interface ViewDocument {
|
|
70
120
|
readonly $schema?: string;
|
|
71
121
|
readonly schema: typeof VIEW_DOCUMENT_SCHEMA_ID;
|
|
@@ -81,6 +131,11 @@ export interface ViewDocument {
|
|
|
81
131
|
* a `$bind` path that starts at this param.
|
|
82
132
|
*/
|
|
83
133
|
readonly default?: unknown;
|
|
134
|
+
/**
|
|
135
|
+
* `true` makes the input optional with no default, so an omitted
|
|
136
|
+
* value reads as `undefined`. A param with a default does not take it.
|
|
137
|
+
*/
|
|
138
|
+
readonly optional?: true;
|
|
84
139
|
readonly description?: string;
|
|
85
140
|
}
|
|
86
141
|
>
|
|
@@ -141,12 +196,24 @@ export interface ViewValidation {
|
|
|
141
196
|
readonly actions: ReadonlyMap<string, 'row' | 'view'>;
|
|
142
197
|
}
|
|
143
198
|
|
|
199
|
+
/**
|
|
200
|
+
* Where a `#view`'s `src` points relative to the top document's folder, from
|
|
201
|
+
* the composing document at `from` (undefined for the top document): each
|
|
202
|
+
* `src` resolves from the folder of the document that contains it. The
|
|
203
|
+
* `path` every `resolveView(src, path)` receives.
|
|
204
|
+
*/
|
|
205
|
+
export function composedViewPath(from: string | undefined, src: string): string;
|
|
206
|
+
|
|
144
207
|
export function validateView(
|
|
145
208
|
document: unknown,
|
|
146
209
|
catalog: ViewCatalog,
|
|
147
210
|
options?: {
|
|
148
|
-
/**
|
|
149
|
-
|
|
211
|
+
/**
|
|
212
|
+
* Loads a `#view` node's document; without it, `#view` is shape-checked
|
|
213
|
+
* only. `path` is where `src` points relative to the top document's
|
|
214
|
+
* folder: each `src` resolves from the document that contains it.
|
|
215
|
+
*/
|
|
216
|
+
resolveView?: (src: string, path: string) => unknown;
|
|
150
217
|
/** Known Lucide icon names; with it, an unknown `$icon` is `KUI-V013`. */
|
|
151
218
|
icons?: Iterable<string>;
|
|
152
219
|
},
|
|
@@ -255,10 +322,15 @@ export interface ViewContract {
|
|
|
255
322
|
}
|
|
256
323
|
>
|
|
257
324
|
>;
|
|
325
|
+
/**
|
|
326
|
+
* The kinds each `templates` repeat names, by its item name, sorted.
|
|
327
|
+
* Absent when the document has none.
|
|
328
|
+
*/
|
|
329
|
+
readonly kinds?: Readonly<Record<string, readonly string[]>>;
|
|
258
330
|
}
|
|
259
331
|
|
|
260
332
|
export interface ViewContractChange {
|
|
261
|
-
readonly member: 'input' | 'action' | 'slot' | 'ref';
|
|
333
|
+
readonly member: 'input' | 'action' | 'slot' | 'ref' | 'kind';
|
|
262
334
|
readonly name: string;
|
|
263
335
|
readonly change: string;
|
|
264
336
|
readonly breaking: boolean;
|
|
@@ -275,7 +347,7 @@ export function typeText(type: ViewType): string;
|
|
|
275
347
|
export function contractOf(
|
|
276
348
|
document: unknown,
|
|
277
349
|
catalog: ViewCatalog,
|
|
278
|
-
options?: { resolveView?: (src: string) => unknown },
|
|
350
|
+
options?: { resolveView?: (src: string, path: string) => unknown },
|
|
279
351
|
): ViewContract;
|
|
280
352
|
/** The layout-independent contract digest. */
|
|
281
353
|
export function contractDigest(contract: ViewContract): string;
|
|
@@ -310,7 +382,7 @@ export function generateView(
|
|
|
310
382
|
options?: {
|
|
311
383
|
/** The document file name recorded in the header. */
|
|
312
384
|
source?: string;
|
|
313
|
-
resolveView?: (src: string) => unknown;
|
|
385
|
+
resolveView?: (src: string, path: string) => unknown;
|
|
314
386
|
target?: 'ts' | 'js';
|
|
315
387
|
declarationsOnly?: boolean;
|
|
316
388
|
/** The generated module's folder; absolute component imports become relative to it. */
|
|
@@ -336,9 +408,6 @@ export function viewModulePath(
|
|
|
336
408
|
target?: 'ts' | 'js',
|
|
337
409
|
): string;
|
|
338
410
|
|
|
339
|
-
/** Layout printer for generated expressions. */
|
|
340
|
-
export function printDoc(doc: unknown, indent?: number): string;
|
|
341
|
-
|
|
342
411
|
/** A parsed `$css` call: `{ name, args }`, each argument a literal or nested call. */
|
|
343
412
|
export interface CssCallTree {
|
|
344
413
|
readonly name: string;
|
|
@@ -372,7 +441,7 @@ export function interpretView(
|
|
|
372
441
|
/** The generated `<name>Contract` the application compiled against. */
|
|
373
442
|
readonly contract: string;
|
|
374
443
|
readonly onMismatch?: (error: KuiContractMismatch) => SafeHtmlLike;
|
|
375
|
-
readonly resolveView?: (src: string) => unknown;
|
|
444
|
+
readonly resolveView?: (src: string, path: string) => unknown;
|
|
376
445
|
/** Lucide icon name → icon data, for every `$icon` the document uses. */
|
|
377
446
|
readonly icons?: Readonly<Record<string, unknown>>;
|
|
378
447
|
},
|
|
@@ -399,13 +468,10 @@ export function previewView(
|
|
|
399
468
|
readonly inputs?: object;
|
|
400
469
|
readonly slots?: object;
|
|
401
470
|
readonly icons?: Readonly<Record<string, unknown>>;
|
|
402
|
-
readonly resolveView?: (src: string) => unknown;
|
|
471
|
+
readonly resolveView?: (src: string, path: string) => unknown;
|
|
403
472
|
/** Ids of nodes the caller's validation flagged. */
|
|
404
473
|
readonly broken?: ReadonlySet<string>;
|
|
405
474
|
/** Renders in place of a broken node; `reason` is `problem` or the thrown message. */
|
|
406
475
|
readonly placeholder: (node: ViewNode, reason: string) => SafeHtmlLike;
|
|
407
476
|
},
|
|
408
477
|
): SafeHtmlLike;
|
|
409
|
-
|
|
410
|
-
/** A component import as the generated module writes it, relative to `importFrom` when absolute. */
|
|
411
|
-
export function moduleSpecifier(specifier: string, importFrom?: string): string;
|
package/view/index.mjs
CHANGED
|
@@ -1,15 +1,13 @@
|
|
|
1
1
|
// @kerfjs/ui/view: the published, browser-safe view-document layer
|
|
2
2
|
// (docs/26-ui-editor.md). The private editor and the kerf-ui-view CLI are
|
|
3
3
|
// its clients; neither owns the format.
|
|
4
|
+
export { childKind, classifyChild } from './child-kind.mjs';
|
|
5
|
+
export { channelOf, createViewCatalog, fieldZoneOf } from './catalog.mjs';
|
|
6
|
+
export { parseCssCall, parseCssTree } from './css-grammar.mjs';
|
|
7
|
+
export { isAssignable, isLiteralOf } from './types.mjs';
|
|
4
8
|
export {
|
|
5
|
-
|
|
6
|
-
createViewCatalog,
|
|
9
|
+
composedViewPath,
|
|
7
10
|
dataAttributeProblem,
|
|
8
|
-
fieldZoneOf,
|
|
9
|
-
isAssignable,
|
|
10
|
-
isLiteralOf,
|
|
11
|
-
parseCssCall,
|
|
12
|
-
parseCssTree,
|
|
13
11
|
validateView,
|
|
14
12
|
VIEW_DOCUMENT_SCHEMA_ID,
|
|
15
13
|
} from './validate.mjs';
|
|
@@ -28,8 +26,6 @@ export {
|
|
|
28
26
|
GENERATOR_VERSION,
|
|
29
27
|
generateView,
|
|
30
28
|
lucideExportName,
|
|
31
|
-
moduleSpecifier,
|
|
32
|
-
printDoc,
|
|
33
29
|
readViewHeader,
|
|
34
30
|
viewModulePath,
|
|
35
31
|
} from './generate.mjs';
|
package/view/interpret.mjs
CHANGED
|
@@ -10,11 +10,13 @@ import { contractDigest, contractOf } from './contract.mjs';
|
|
|
10
10
|
import {
|
|
11
11
|
channelOf,
|
|
12
12
|
fieldZoneOf,
|
|
13
|
-
parseCssTree,
|
|
14
13
|
withFieldZones,
|
|
15
14
|
ZoneFill,
|
|
16
15
|
zonePropOf,
|
|
17
|
-
} from './
|
|
16
|
+
} from './catalog.mjs';
|
|
17
|
+
import { childKind } from './child-kind.mjs';
|
|
18
|
+
import { parseCssTree } from './css-grammar.mjs';
|
|
19
|
+
import { composedViewPath, eachNodes } from './validate.mjs';
|
|
18
20
|
|
|
19
21
|
const isObject = (value) =>
|
|
20
22
|
value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
@@ -59,7 +61,8 @@ function readPath(root, path) {
|
|
|
59
61
|
* - `inputs`, `slots`: as the generated `render<Name>` takes them;
|
|
60
62
|
* - `contract`: the `<name>Contract` digest the app compiled against;
|
|
61
63
|
* - `onMismatch(error)`: returns fallback `SafeHtml` instead of throwing;
|
|
62
|
-
* - `resolveView(src)`: loads composed documents synchronously
|
|
64
|
+
* - `resolveView(src, path)`: loads composed documents synchronously; `path`
|
|
65
|
+
* is where `src` points relative to the top document's folder.
|
|
63
66
|
* Throws on an invalid document or a component missing from `components`.
|
|
64
67
|
*/
|
|
65
68
|
export function interpretView(document, options) {
|
|
@@ -95,7 +98,25 @@ export function previewView(document, options) {
|
|
|
95
98
|
return renderDocument(document, inputs, slots, options);
|
|
96
99
|
}
|
|
97
100
|
|
|
98
|
-
|
|
101
|
+
/**
|
|
102
|
+
* `at` is the document's place relative to the top document's folder
|
|
103
|
+
* (undefined for the top one), so a nested `#view`'s `src` resolves from the
|
|
104
|
+
* document that contains it, as the validator resolves it (KF-3X7MFF).
|
|
105
|
+
* `inRow` marks a composed document rendered inside a composing document's
|
|
106
|
+
* `$each` row, through any number of `#view` levels, and `rowKey` is that
|
|
107
|
+
* row's key, which its root carries as `data-key` the way any other row root
|
|
108
|
+
* does (KF-EP2152), so kerf reconciles the row by key and a row action reads
|
|
109
|
+
* it (KF-RDZ7N7).
|
|
110
|
+
*/
|
|
111
|
+
function renderDocument(
|
|
112
|
+
document,
|
|
113
|
+
inputs,
|
|
114
|
+
slots,
|
|
115
|
+
options,
|
|
116
|
+
at,
|
|
117
|
+
inRow = false,
|
|
118
|
+
rowKey = undefined,
|
|
119
|
+
) {
|
|
99
120
|
const { catalog, components, resolveView } = options;
|
|
100
121
|
const params = document.params ?? {};
|
|
101
122
|
|
|
@@ -149,37 +170,75 @@ function renderDocument(document, inputs, slots, options) {
|
|
|
149
170
|
};
|
|
150
171
|
|
|
151
172
|
const childValue = (child, scope, slot) => {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
);
|
|
164
|
-
// Scope holds only `$each` items, so a non-empty scope is a row
|
|
165
|
-
// template. kerf never reconciles a list inside a row (the row is
|
|
166
|
-
// flattened to HTML, and a keyed each() there throws), so an inner
|
|
167
|
-
// repeat is a plain map that re-renders with its row, as the generated
|
|
168
|
-
// module writes it (KF-CFA1S1).
|
|
169
|
-
return scope.size
|
|
170
|
-
? items.map(row)
|
|
171
|
-
: each(items, row, { key: child.template.id });
|
|
172
|
-
}
|
|
173
|
-
if ('$if' in child) {
|
|
174
|
-
if (value(child.$if, scope)) return childValue(child.then, scope, slot);
|
|
175
|
-
return 'else' in child ? childValue(child.else, scope, slot) : null;
|
|
173
|
+
switch (childKind(child)) {
|
|
174
|
+
case 'each':
|
|
175
|
+
return eachValue(child, scope, slot);
|
|
176
|
+
case 'if':
|
|
177
|
+
if (value(child.$if, scope)) return childValue(child.then, scope, slot);
|
|
178
|
+
return 'else' in child ? childValue(child.else, scope, slot) : null;
|
|
179
|
+
case 'slot':
|
|
180
|
+
return isObject(child.input)
|
|
181
|
+
? slots[child.$slot](value(child.input, scope))
|
|
182
|
+
: slots[child.$slot]();
|
|
183
|
+
default:
|
|
184
|
+
return nodeValue(child, scope, undefined, slot);
|
|
176
185
|
}
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
186
|
+
};
|
|
187
|
+
|
|
188
|
+
const eachValue = (child, scope, slot) => {
|
|
189
|
+
// The key path starts with `as` (validation requires it); read the rest
|
|
190
|
+
// from the item.
|
|
191
|
+
const rest = child.key.split('.').slice(1);
|
|
192
|
+
// KF-A01VDM: a composed document's own repeat inside a row is the shape
|
|
193
|
+
// validation rejects (KUI-V016). Name it, rather than letting each()
|
|
194
|
+
// refuse the keyed list inside the row with a generic error.
|
|
195
|
+
if (inRow && !scope.size) {
|
|
196
|
+
throw new Error(
|
|
197
|
+
`KUI-V016 ${at} is composed into a row, so it cannot repeat`,
|
|
198
|
+
);
|
|
181
199
|
}
|
|
182
|
-
|
|
200
|
+
const items = value(child.$each, scope);
|
|
201
|
+
const row = (item) => {
|
|
202
|
+
const inner = new Map(scope).set(child.as, item);
|
|
203
|
+
return rowValue(
|
|
204
|
+
rowTemplate(child, inner),
|
|
205
|
+
inner,
|
|
206
|
+
readPath(item, rest),
|
|
207
|
+
slot,
|
|
208
|
+
);
|
|
209
|
+
};
|
|
210
|
+
// Scope holds only `$each` items, so a non-empty scope is a row
|
|
211
|
+
// template. kerf never reconciles a list inside a row (the row is
|
|
212
|
+
// flattened to HTML, and a keyed each() there throws), so an inner
|
|
213
|
+
// repeat is a plain map that re-renders with its row, as the generated
|
|
214
|
+
// module writes it (KF-CFA1S1).
|
|
215
|
+
return scope.size
|
|
216
|
+
? items.map(row)
|
|
217
|
+
: each(items, row, { key: eachNodes(child)[0]?.id });
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
// KF-YX6HMT: the template an item's `kind` picks from `templates`, else
|
|
221
|
+
// the `default` one. A preview of a map with no `default` falls back to
|
|
222
|
+
// its first template, since a keyed row must be one element.
|
|
223
|
+
const rowTemplate = (child, scope) => {
|
|
224
|
+
if (!('templates' in child)) return child.template;
|
|
225
|
+
const { templates } = child;
|
|
226
|
+
const kind = value(child.kind, scope);
|
|
227
|
+
if (Object.hasOwn(templates, kind)) return templates[kind];
|
|
228
|
+
return templates.default ?? Object.values(templates)[0];
|
|
229
|
+
};
|
|
230
|
+
|
|
231
|
+
// A row: the template node, or the branch its `$if` chain picks for this
|
|
232
|
+
// item (KF-8J8E5V). A preview of an unfinished chain with no `else`
|
|
233
|
+
// renders `then` for every item, since a keyed row must be one element.
|
|
234
|
+
const rowValue = (template, scope, rowKey, slot) => {
|
|
235
|
+
if (!isObject(template) || !('$if' in template))
|
|
236
|
+
return nodeValue(template, scope, rowKey, slot);
|
|
237
|
+
const chosen =
|
|
238
|
+
'else' in template && !value(template.$if, scope)
|
|
239
|
+
? template.else
|
|
240
|
+
: template.then;
|
|
241
|
+
return rowValue(chosen, scope, rowKey, slot);
|
|
183
242
|
};
|
|
184
243
|
|
|
185
244
|
// A preview (previewView) swaps a node it cannot render for the caller's
|
|
@@ -205,8 +264,17 @@ function renderDocument(document, inputs, slots, options) {
|
|
|
205
264
|
return slot ? jsx('span', { slot, children: text }) : text;
|
|
206
265
|
}
|
|
207
266
|
if (node.type === '#view') {
|
|
208
|
-
const
|
|
209
|
-
|
|
267
|
+
const path = composedViewPath(at, node.src);
|
|
268
|
+
const child = resolveView(node.src, path);
|
|
269
|
+
return renderDocument(
|
|
270
|
+
child,
|
|
271
|
+
value(node.props ?? {}, scope),
|
|
272
|
+
{},
|
|
273
|
+
options,
|
|
274
|
+
path,
|
|
275
|
+
inRow || scope.size > 0,
|
|
276
|
+
rowKey,
|
|
277
|
+
);
|
|
210
278
|
}
|
|
211
279
|
const { component: definition, definitions } = catalog.components.get(
|
|
212
280
|
node.type,
|
|
@@ -267,5 +335,5 @@ function renderDocument(document, inputs, slots, options) {
|
|
|
267
335
|
return render(out);
|
|
268
336
|
};
|
|
269
337
|
|
|
270
|
-
return nodeValue(document.root, new Map(),
|
|
338
|
+
return nodeValue(document.root, new Map(), rowKey, undefined);
|
|
271
339
|
}
|
package/view/types.mjs
ADDED
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
// The structural type system of @kerfjs/ui/view: whether a param or binding
|
|
2
|
+
// type fits a prop type (isAssignable) and whether a JSON literal is a value
|
|
3
|
+
// of a type (isLiteralOf), over the catalogs' type descriptors.
|
|
4
|
+
|
|
5
|
+
import { isObject, resolveType, ZoneFill } from './catalog.mjs';
|
|
6
|
+
import { parseCssCall } from './css-grammar.mjs';
|
|
7
|
+
|
|
8
|
+
export const ICON_NAME = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
9
|
+
|
|
10
|
+
/** Whether a value of type `from` (a param or binding) fits type `to`. */
|
|
11
|
+
export function isAssignable(from, to, definitions = {}) {
|
|
12
|
+
// A component prop's type fits only that same component prop.
|
|
13
|
+
if (from?.kind === 'prop' || to?.kind === 'prop')
|
|
14
|
+
return (
|
|
15
|
+
from?.kind === to?.kind &&
|
|
16
|
+
from.component === to.component &&
|
|
17
|
+
from.prop === to.prop
|
|
18
|
+
);
|
|
19
|
+
const target = resolveType(to, definitions);
|
|
20
|
+
const source = resolveType(from, definitions);
|
|
21
|
+
if (target.kind === 'unknown' || source.kind === 'unknown') return true;
|
|
22
|
+
if (target.kind === 'union') {
|
|
23
|
+
return target.members.some((member) =>
|
|
24
|
+
isAssignable(source, member, definitions),
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
const values =
|
|
28
|
+
source.kind === 'enum'
|
|
29
|
+
? source.values
|
|
30
|
+
: source.kind === 'literal'
|
|
31
|
+
? [source.value]
|
|
32
|
+
: undefined;
|
|
33
|
+
if (values) {
|
|
34
|
+
if (target.kind === 'enum') {
|
|
35
|
+
return values.every((value) => target.values.includes(value));
|
|
36
|
+
}
|
|
37
|
+
if (target.kind === 'literal') {
|
|
38
|
+
return values.length === 1 && values[0] === target.value;
|
|
39
|
+
}
|
|
40
|
+
return values.every((value) => isLiteralOf(value, target, definitions));
|
|
41
|
+
}
|
|
42
|
+
switch (source.kind) {
|
|
43
|
+
case 'string':
|
|
44
|
+
case 'number':
|
|
45
|
+
return (
|
|
46
|
+
target.kind === source.kind ||
|
|
47
|
+
(target.kind === 'content' && target.acceptsText === true)
|
|
48
|
+
);
|
|
49
|
+
case 'boolean':
|
|
50
|
+
case 'content':
|
|
51
|
+
return target.kind === source.kind;
|
|
52
|
+
case 'array':
|
|
53
|
+
return (
|
|
54
|
+
target.kind === 'array' &&
|
|
55
|
+
isAssignable(source.items, target.items, definitions)
|
|
56
|
+
);
|
|
57
|
+
case 'object': {
|
|
58
|
+
if (target.kind === 'record') return true;
|
|
59
|
+
if (target.kind !== 'object') return false;
|
|
60
|
+
const given = new Map(
|
|
61
|
+
(source.props ?? []).map((prop) => [prop.name, prop]),
|
|
62
|
+
);
|
|
63
|
+
return (target.props ?? []).every((prop) => {
|
|
64
|
+
const match = given.get(prop.name);
|
|
65
|
+
if (!match) return !prop.required;
|
|
66
|
+
return (
|
|
67
|
+
(match.required || !prop.required) &&
|
|
68
|
+
isAssignable(match.type, prop.type, definitions)
|
|
69
|
+
);
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
default:
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** Whether a JSON literal is a valid value of a type descriptor. */
|
|
78
|
+
export function isLiteralOf(value, type, definitions = {}) {
|
|
79
|
+
return literalOf(value, type, definitions);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* `isLiteralOf`, with `hooks` for the forms a prop value may nest:
|
|
84
|
+
* `hooks.slot` decides a `{ $slot }` at a content-typed position (KF-SXDM56:
|
|
85
|
+
* item slots), and `hooks.dynamic` a `{ $param }` / `{ $bind }` at any typed
|
|
86
|
+
* position against that position's type (KF-3QEZFB: nested params). Without
|
|
87
|
+
* them, neither is a literal.
|
|
88
|
+
*/
|
|
89
|
+
export function literalOf(value, type, definitions, hooks) {
|
|
90
|
+
if (
|
|
91
|
+
hooks?.dynamic &&
|
|
92
|
+
isObject(value) &&
|
|
93
|
+
('$param' in value || '$bind' in value)
|
|
94
|
+
)
|
|
95
|
+
return hooks.dynamic(value, type);
|
|
96
|
+
const target = resolveType(type, definitions);
|
|
97
|
+
if (value === null) return target.nullable === true;
|
|
98
|
+
switch (target.kind) {
|
|
99
|
+
case 'unknown':
|
|
100
|
+
return true;
|
|
101
|
+
case 'union':
|
|
102
|
+
return target.members.some((member) =>
|
|
103
|
+
literalOf(value, member, definitions, hooks),
|
|
104
|
+
);
|
|
105
|
+
case 'string':
|
|
106
|
+
return typeof value === 'string';
|
|
107
|
+
case 'number':
|
|
108
|
+
return typeof value === 'number' && Number.isFinite(value);
|
|
109
|
+
case 'boolean':
|
|
110
|
+
return typeof value === 'boolean';
|
|
111
|
+
case 'enum':
|
|
112
|
+
return target.values.includes(value);
|
|
113
|
+
case 'literal':
|
|
114
|
+
return value === target.value;
|
|
115
|
+
// A builder call inside a list or object value (KF-3J9GJV).
|
|
116
|
+
case 'css-value':
|
|
117
|
+
return isObject(value) && parseCssCall(value.$css) !== undefined;
|
|
118
|
+
case 'content':
|
|
119
|
+
if (value instanceof ZoneFill) return true;
|
|
120
|
+
if (hooks?.slot && isObject(value) && '$slot' in value)
|
|
121
|
+
return hooks.slot(value);
|
|
122
|
+
return (
|
|
123
|
+
target.acceptsText === true &&
|
|
124
|
+
(typeof value === 'string' || typeof value === 'number')
|
|
125
|
+
);
|
|
126
|
+
case 'array':
|
|
127
|
+
return (
|
|
128
|
+
Array.isArray(value) &&
|
|
129
|
+
value.every((item) => literalOf(item, target.items, definitions, hooks))
|
|
130
|
+
);
|
|
131
|
+
case 'record':
|
|
132
|
+
return (
|
|
133
|
+
isObject(value) &&
|
|
134
|
+
Object.values(value).every((item) => typeof item === 'string')
|
|
135
|
+
);
|
|
136
|
+
case 'object': {
|
|
137
|
+
if (!isObject(value)) return false;
|
|
138
|
+
const known = new Map(
|
|
139
|
+
(target.props ?? []).map((prop) => [prop.name, prop]),
|
|
140
|
+
);
|
|
141
|
+
const { index } = target;
|
|
142
|
+
return (
|
|
143
|
+
Object.entries(value).every(([name, item]) =>
|
|
144
|
+
known.has(name)
|
|
145
|
+
? // An icon-data field names its icon (KF-3J9GJV).
|
|
146
|
+
(known.get(name).iconSource &&
|
|
147
|
+
ICON_NAME.test(item?.$icon ?? '')) ||
|
|
148
|
+
literalOf(item, known.get(name).type, definitions, hooks)
|
|
149
|
+
: index !== undefined &&
|
|
150
|
+
name.startsWith(index.keyPrefix) &&
|
|
151
|
+
literalOf(item, index.value, definitions, hooks),
|
|
152
|
+
) &&
|
|
153
|
+
[...known.values()].every(
|
|
154
|
+
(prop) => !prop.required || prop.name in value,
|
|
155
|
+
)
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
default:
|
|
159
|
+
return false;
|
|
160
|
+
}
|
|
161
|
+
}
|