@bettercms-ai/kit 0.1.0 → 1.0.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/_virtual/_rolldown/runtime.js +13 -0
- package/adapters/icons.d.ts +15 -0
- package/adapters/icons.js +27 -0
- package/adapters/icons.js.map +1 -0
- package/adapters/lossy.d.ts +267 -0
- package/adapters/lossy.js +233 -0
- package/adapters/lossy.js.map +1 -0
- package/adapters/prod-types.d.ts +468 -0
- package/adapters/prod-types.js +646 -0
- package/adapters/prod-types.js.map +1 -0
- package/adapters/schema.d.ts +115 -0
- package/adapters/schema.js +2203 -0
- package/adapters/schema.js.map +1 -0
- package/adapters/values.d.ts +200 -0
- package/adapters/values.js +553 -0
- package/adapters/values.js.map +1 -0
- package/brand/logo.d.ts +17 -0
- package/brand/logo.js +9 -0
- package/brand/logo.js.map +1 -0
- package/context.d.ts +269 -0
- package/context.js +214 -0
- package/context.js.map +1 -0
- package/controls/button.d.ts +58 -0
- package/controls/button.js +507 -0
- package/controls/button.js.map +1 -0
- package/controls/c1.d.ts +11 -0
- package/controls/c1.js +24 -0
- package/controls/c1.js.map +1 -0
- package/controls/c2.d.ts +10 -0
- package/controls/c2.js +19 -0
- package/controls/c2.js.map +1 -0
- package/controls/choice.d.ts +39 -0
- package/controls/choice.js +410 -0
- package/controls/choice.js.map +1 -0
- package/controls/code-register.d.ts +1 -0
- package/controls/code-register.js +8 -0
- package/controls/code-register.js.map +1 -0
- package/controls/code.d.ts +42 -0
- package/controls/code.js +396 -0
- package/controls/code.js.map +1 -0
- package/controls/color.d.ts +5 -0
- package/controls/color.js +130 -0
- package/controls/color.js.map +1 -0
- package/controls/component-services.d.ts +114 -0
- package/controls/date-register.d.ts +1 -0
- package/controls/date-register.js +9 -0
- package/controls/date-register.js.map +1 -0
- package/controls/date-zone.d.ts +104 -0
- package/controls/date-zone.js +272 -0
- package/controls/date-zone.js.map +1 -0
- package/controls/date.d.ts +7 -0
- package/controls/date.js +458 -0
- package/controls/date.js.map +1 -0
- package/controls/form-picker-register.d.ts +1 -0
- package/controls/form-picker-register.js +19 -0
- package/controls/form-picker-register.js.map +1 -0
- package/controls/form-picker.d.ts +43 -0
- package/controls/form-picker.js +83 -0
- package/controls/form-picker.js.map +1 -0
- package/controls/icon-register.d.ts +1 -0
- package/controls/icon-register.js +8 -0
- package/controls/icon-register.js.map +1 -0
- package/controls/icon.d.ts +38 -0
- package/controls/icon.js +355 -0
- package/controls/icon.js.map +1 -0
- package/controls/index.d.ts +5 -0
- package/controls/index.js +37 -0
- package/controls/index.js.map +1 -0
- package/controls/json-register.d.ts +1 -0
- package/controls/json-register.js +8 -0
- package/controls/json-register.js.map +1 -0
- package/controls/json.d.ts +2 -0
- package/controls/json.js +72 -0
- package/controls/json.js.map +1 -0
- package/controls/link.d.ts +260 -0
- package/controls/link.js +1186 -0
- package/controls/link.js.map +1 -0
- package/controls/location-register.d.ts +1 -0
- package/controls/location-register.js +8 -0
- package/controls/location-register.js.map +1 -0
- package/controls/location.d.ts +16 -0
- package/controls/location.js +197 -0
- package/controls/location.js.map +1 -0
- package/controls/media-register.d.ts +1 -0
- package/controls/media-register.js +12 -0
- package/controls/media-register.js.map +1 -0
- package/controls/media-services.d.ts +40 -0
- package/controls/media.d.ts +73 -0
- package/controls/media.js +1076 -0
- package/controls/media.js.map +1 -0
- package/controls/number.d.ts +22 -0
- package/controls/number.js +195 -0
- package/controls/number.js.map +1 -0
- package/controls/reference-register.d.ts +1 -0
- package/controls/reference-register.js +10 -0
- package/controls/reference-register.js.map +1 -0
- package/controls/reference-services.d.ts +54 -0
- package/controls/reference.d.ts +23 -0
- package/controls/reference.js +761 -0
- package/controls/reference.js.map +1 -0
- package/controls/rich-text/blocks.d.ts +28 -0
- package/controls/rich-text/blocks.js +1532 -0
- package/controls/rich-text/blocks.js.map +1 -0
- package/controls/rich-text/catalog.d.ts +98 -0
- package/controls/rich-text/catalog.js +613 -0
- package/controls/rich-text/catalog.js.map +1 -0
- package/controls/rich-text/codec.d.ts +56 -0
- package/controls/rich-text/codec.js +32 -0
- package/controls/rich-text/codec.js.map +1 -0
- package/controls/rich-text/component-card.d.ts +14 -0
- package/controls/rich-text/component-card.js +706 -0
- package/controls/rich-text/component-card.js.map +1 -0
- package/controls/rich-text/control.d.ts +21 -0
- package/controls/rich-text/control.js +254 -0
- package/controls/rich-text/control.js.map +1 -0
- package/controls/rich-text/dom.d.ts +190 -0
- package/controls/rich-text/dom.js +690 -0
- package/controls/rich-text/dom.js.map +1 -0
- package/controls/rich-text/editor.d.ts +50 -0
- package/controls/rich-text/editor.js +1530 -0
- package/controls/rich-text/editor.js.map +1 -0
- package/controls/rich-text/floating.d.ts +23 -0
- package/controls/rich-text/floating.js +137 -0
- package/controls/rich-text/floating.js.map +1 -0
- package/controls/rich-text/index.d.ts +1 -0
- package/controls/rich-text/index.js +12 -0
- package/controls/rich-text/index.js.map +1 -0
- package/controls/rich-text/link-form.d.ts +13 -0
- package/controls/rich-text/link-form.js +111 -0
- package/controls/rich-text/link-form.js.map +1 -0
- package/controls/rich-text/markdown.d.ts +6 -0
- package/controls/rich-text/markdown.js +179 -0
- package/controls/rich-text/markdown.js.map +1 -0
- package/controls/rich-text/ops.d.ts +35 -0
- package/controls/rich-text/ops.js +314 -0
- package/controls/rich-text/ops.js.map +1 -0
- package/controls/rich-text/toolbar.d.ts +85 -0
- package/controls/rich-text/toolbar.js +338 -0
- package/controls/rich-text/toolbar.js.map +1 -0
- package/controls/scale.d.ts +56 -0
- package/controls/scale.js +563 -0
- package/controls/scale.js.map +1 -0
- package/controls/slot-register.d.ts +1 -0
- package/controls/slot-register.js +16 -0
- package/controls/slot-register.js.map +1 -0
- package/controls/slot-services.d.ts +97 -0
- package/controls/slot-services.js +38 -0
- package/controls/slot-services.js.map +1 -0
- package/controls/slot.d.ts +33 -0
- package/controls/slot.js +348 -0
- package/controls/slot.js.map +1 -0
- package/controls/table/index.d.ts +1 -0
- package/controls/table/index.js +12 -0
- package/controls/table/index.js.map +1 -0
- package/controls/table/prod.d.ts +21 -0
- package/controls/table/prod.js +79 -0
- package/controls/table/prod.js.map +1 -0
- package/controls/table/refs.d.ts +50 -0
- package/controls/table/refs.js +68 -0
- package/controls/table/refs.js.map +1 -0
- package/controls/table/stored.d.ts +15 -0
- package/controls/table/stored.js +44 -0
- package/controls/table/stored.js.map +1 -0
- package/controls/table/table-editor.d.ts +103 -0
- package/controls/table/table-editor.js +2722 -0
- package/controls/table/table-editor.js.map +1 -0
- package/controls/table/table-link.d.ts +24 -0
- package/controls/table/table-link.js +180 -0
- package/controls/table/table-link.js.map +1 -0
- package/controls/table/table.d.ts +9 -0
- package/controls/table/table.js +103 -0
- package/controls/table/table.js.map +1 -0
- package/controls/text.d.ts +17 -0
- package/controls/text.js +287 -0
- package/controls/text.js.map +1 -0
- package/engine/array.d.ts +101 -0
- package/engine/array.js +893 -0
- package/engine/array.js.map +1 -0
- package/engine/bits.d.ts +24 -0
- package/engine/bits.js +60 -0
- package/engine/bits.js.map +1 -0
- package/engine/breadcrumb.d.ts +45 -0
- package/engine/breadcrumb.js +87 -0
- package/engine/breadcrumb.js.map +1 -0
- package/engine/expand.d.ts +68 -0
- package/engine/expand.js +170 -0
- package/engine/expand.js.map +1 -0
- package/engine/field-list.d.ts +20 -0
- package/engine/field-list.js +19 -0
- package/engine/field-list.js.map +1 -0
- package/engine/field-shell.d.ts +49 -0
- package/engine/field-shell.js +860 -0
- package/engine/field-shell.js.map +1 -0
- package/engine/frame.d.ts +120 -0
- package/engine/frame.js +599 -0
- package/engine/frame.js.map +1 -0
- package/engine/group-summary.d.ts +4 -0
- package/engine/group-summary.js +66 -0
- package/engine/group-summary.js.map +1 -0
- package/engine/grouping.d.ts +224 -0
- package/engine/grouping.js +824 -0
- package/engine/grouping.js.map +1 -0
- package/engine/item-list.d.ts +89 -0
- package/engine/item-list.js +703 -0
- package/engine/item-list.js.map +1 -0
- package/engine/kit-field.d.ts +72 -0
- package/engine/kit-field.js +523 -0
- package/engine/kit-field.js.map +1 -0
- package/engine/schema-form.d.ts +91 -0
- package/engine/schema-form.js +320 -0
- package/engine/schema-form.js.map +1 -0
- package/engine/slot.d.ts +13 -0
- package/engine/slot.js +226 -0
- package/engine/slot.js.map +1 -0
- package/index.d.ts +46 -0
- package/index.js +55 -0
- package/index.js.map +1 -0
- package/kit.css +56 -0
- package/lib/cn.d.ts +4 -0
- package/lib/cn.js +53 -0
- package/lib/cn.js.map +1 -0
- package/lib/columns.d.ts +14 -0
- package/lib/columns.js +27 -0
- package/lib/columns.js.map +1 -0
- package/lib/frames.d.ts +36 -0
- package/lib/frames.js +214 -0
- package/lib/frames.js.map +1 -0
- package/lib/icons.d.ts +16 -0
- package/lib/icons.js +172 -0
- package/lib/icons.js.map +1 -0
- package/lib/path.d.ts +29 -0
- package/lib/path.js +64 -0
- package/lib/path.js.map +1 -0
- package/lib/schema.d.ts +49 -0
- package/lib/schema.js +287 -0
- package/lib/schema.js.map +1 -0
- package/lib/utils.d.ts +7 -0
- package/lib/utils.js +37 -0
- package/lib/utils.js.map +1 -0
- package/lib/validate.d.ts +20 -0
- package/lib/validate.js +150 -0
- package/lib/validate.js.map +1 -0
- package/package.json +31 -59
- package/schema/adapters.d.ts +28 -0
- package/schema/adapters.js +493 -0
- package/schema/adapters.js.map +1 -0
- package/schema/help.d.ts +25 -0
- package/schema/help.js +54 -0
- package/schema/help.js.map +1 -0
- package/schema/scale.d.ts +69 -0
- package/schema/scale.js +250 -0
- package/schema/scale.js.map +1 -0
- package/schema/sources.d.ts +103 -0
- package/schema/sources.js +65 -0
- package/schema/sources.js.map +1 -0
- package/schema/table.d.ts +319 -0
- package/schema/table.js +1198 -0
- package/schema/table.js.map +1 -0
- package/schema/types.d.ts +269 -0
- package/schema/types.js +14 -0
- package/schema/types.js.map +1 -0
- package/types.d.ts +17 -0
- package/ui/action-tray.d.ts +54 -0
- package/ui/action-tray.js +153 -0
- package/ui/action-tray.js.map +1 -0
- package/ui/button.d.ts +57 -0
- package/ui/button.js +202 -0
- package/ui/button.js.map +1 -0
- package/ui/choice-switch.d.ts +36 -0
- package/ui/choice-switch.js +57 -0
- package/ui/choice-switch.js.map +1 -0
- package/ui/controls.d.ts +83 -0
- package/ui/controls.js +319 -0
- package/ui/controls.js.map +1 -0
- package/ui/display.d.ts +156 -0
- package/ui/display.js +444 -0
- package/ui/display.js.map +1 -0
- package/ui/expanded-editor-modal.d.ts +26 -0
- package/ui/expanded-editor-modal.js +140 -0
- package/ui/expanded-editor-modal.js.map +1 -0
- package/ui/field-context.d.ts +12 -0
- package/ui/field-context.js +23 -0
- package/ui/field-context.js.map +1 -0
- package/ui/floating-panel.d.ts +152 -0
- package/ui/floating-panel.js +912 -0
- package/ui/floating-panel.js.map +1 -0
- package/ui/index.d.ts +12 -0
- package/ui/index.js +13 -0
- package/ui/input.d.ts +78 -0
- package/ui/input.js +250 -0
- package/ui/input.js.map +1 -0
- package/ui/mode-bar.d.ts +31 -0
- package/ui/mode-bar.js +65 -0
- package/ui/mode-bar.js.map +1 -0
- package/ui/overlay.d.ts +123 -0
- package/ui/overlay.js +378 -0
- package/ui/overlay.js.map +1 -0
- package/ui/path-crumbs.d.ts +90 -0
- package/ui/path-crumbs.js +532 -0
- package/ui/path-crumbs.js.map +1 -0
- package/ui/presence.d.ts +16 -0
- package/ui/presence.js +65 -0
- package/ui/presence.js.map +1 -0
- package/ui/select.d.ts +66 -0
- package/ui/select.js +405 -0
- package/ui/select.js.map +1 -0
- package/ui/shortcut-hint.d.ts +14 -0
- package/ui/shortcut-hint.js +35 -0
- package/ui/shortcut-hint.js.map +1 -0
- package/ui/surfaces.d.ts +23 -0
- package/ui/surfaces.js +26 -0
- package/ui/surfaces.js.map +1 -0
- package/ui/tooltip-root.d.ts +12 -0
- package/ui/tooltip-root.js +76 -0
- package/ui/tooltip-root.js.map +1 -0
- package/ui/variants.d.ts +15 -0
- package/ui/variants.js +14 -0
- package/ui/variants.js.map +1 -0
- package/LICENSE +0 -21
- package/README.md +0 -27
- package/dist/_chunks-cjs/_visual-editing.js +0 -5898
- package/dist/_chunks-cjs/refractor.js +0 -22
- package/dist/_chunks-es/_visual-editing.mjs +0 -5904
- package/dist/_chunks-es/refractor.mjs +0 -25
- package/dist/_color.d.mts +0 -119
- package/dist/_color.d.ts +0 -119
- package/dist/_color.js +0 -1412
- package/dist/_color.mjs +0 -1411
- package/dist/_visual-editing.d.mts +0 -1126
- package/dist/_visual-editing.d.ts +0 -1126
- package/dist/_visual-editing.js +0 -30
- package/dist/_visual-editing.mjs +0 -30
- package/dist/index.d.mts +0 -3140
- package/dist/index.d.ts +0 -3140
- package/dist/index.js +0 -2036
- package/dist/index.mjs +0 -2044
- package/dist/theme.d.mts +0 -1506
- package/dist/theme.d.ts +0 -1506
- package/dist/theme.js +0 -4126
- package/dist/theme.mjs +0 -4126
- package/exports/_visual-editing.ts +0 -31
- package/exports/index.ts +0 -1
- package/exports/theme.ts +0 -1
- package/src/color/index.d.mts +0 -119
- package/src/color/index.mjs +0 -1411
- package/src/core/__workshop__/constants.ts +0 -293
- package/src/core/_compat.ts +0 -264
- package/src/core/components/autocomplete/__mocks__/apiStore.ts +0 -49
- package/src/core/components/autocomplete/__mocks__/countries.ts +0 -245
- package/src/core/components/autocomplete/__workshop__/async.tsx +0 -156
- package/src/core/components/autocomplete/__workshop__/constrainedHeight.tsx +0 -137
- package/src/core/components/autocomplete/__workshop__/custom.tsx +0 -89
- package/src/core/components/autocomplete/__workshop__/example.tsx +0 -79
- package/src/core/components/autocomplete/__workshop__/focusAndBlur.tsx +0 -36
- package/src/core/components/autocomplete/__workshop__/fullscreen.tsx +0 -294
- package/src/core/components/autocomplete/__workshop__/index.ts +0 -39
- package/src/core/components/autocomplete/__workshop__/types.ts +0 -4
- package/src/core/components/autocomplete/autocomplete.styles.tsx +0 -39
- package/src/core/components/autocomplete/autocomplete.tsx +0 -767
- package/src/core/components/autocomplete/autocompleteOption.tsx +0 -45
- package/src/core/components/autocomplete/autocompleteReducer.ts +0 -47
- package/src/core/components/autocomplete/constants.ts +0 -28
- package/src/core/components/autocomplete/index.ts +0 -2
- package/src/core/components/autocomplete/types.ts +0 -108
- package/src/core/components/breadcrumbs/__workshop__/example.tsx +0 -62
- package/src/core/components/breadcrumbs/__workshop__/index.ts +0 -14
- package/src/core/components/breadcrumbs/breadcrumbs.styles.ts +0 -18
- package/src/core/components/breadcrumbs/breadcrumbs.test.tsx +0 -51
- package/src/core/components/breadcrumbs/breadcrumbs.tsx +0 -133
- package/src/core/components/breadcrumbs/index.ts +0 -1
- package/src/core/components/dialog/__workshop__/activate.tsx +0 -134
- package/src/core/components/dialog/__workshop__/autoFocus.tsx +0 -29
- package/src/core/components/dialog/__workshop__/index.ts +0 -19
- package/src/core/components/dialog/__workshop__/layering.tsx +0 -41
- package/src/core/components/dialog/__workshop__/nested.tsx +0 -72
- package/src/core/components/dialog/__workshop__/onScroll.tsx +0 -39
- package/src/core/components/dialog/__workshop__/panes.tsx +0 -82
- package/src/core/components/dialog/__workshop__/position.tsx +0 -30
- package/src/core/components/dialog/__workshop__/props.tsx +0 -75
- package/src/core/components/dialog/__workshop__/provider.tsx +0 -11
- package/src/core/components/dialog/__workshop__/wrapped.tsx +0 -76
- package/src/core/components/dialog/dialog.tsx +0 -430
- package/src/core/components/dialog/dialogContext.ts +0 -20
- package/src/core/components/dialog/dialogProvider.tsx +0 -35
- package/src/core/components/dialog/index.ts +0 -4
- package/src/core/components/dialog/styles.ts +0 -77
- package/src/core/components/dialog/useDialog.ts +0 -11
- package/src/core/components/hotkeys/__workshop__/index.ts +0 -14
- package/src/core/components/hotkeys/__workshop__/plain.tsx +0 -9
- package/src/core/components/hotkeys/hotkeys.test.tsx +0 -42
- package/src/core/components/hotkeys/hotkeys.tsx +0 -66
- package/src/core/components/hotkeys/index.ts +0 -1
- package/src/core/components/index.ts +0 -9
- package/src/core/components/menu/__workshop__/asComponent.tsx +0 -45
- package/src/core/components/menu/__workshop__/avatarMenu.tsx +0 -51
- package/src/core/components/menu/__workshop__/closableMenuButton.tsx +0 -46
- package/src/core/components/menu/__workshop__/constrainedInBoundary.tsx +0 -134
- package/src/core/components/menu/__workshop__/customMenuItem.tsx +0 -45
- package/src/core/components/menu/__workshop__/customSelectedState.tsx +0 -39
- package/src/core/components/menu/__workshop__/disableFocusOnClose.tsx +0 -40
- package/src/core/components/menu/__workshop__/groups.tsx +0 -156
- package/src/core/components/menu/__workshop__/index.ts +0 -89
- package/src/core/components/menu/__workshop__/menuButton.tsx +0 -80
- package/src/core/components/menu/__workshop__/menuGroupRight.tsx +0 -58
- package/src/core/components/menu/__workshop__/nestedMenu.tsx +0 -22
- package/src/core/components/menu/__workshop__/onCloseMenuButton.tsx +0 -41
- package/src/core/components/menu/__workshop__/selectedItem.tsx +0 -69
- package/src/core/components/menu/__workshop__/shouldFocus.tsx +0 -47
- package/src/core/components/menu/__workshop__/tones.tsx +0 -25
- package/src/core/components/menu/__workshop__/withoutArrow.tsx +0 -32
- package/src/core/components/menu/helpers.ts +0 -82
- package/src/core/components/menu/index.ts +0 -5
- package/src/core/components/menu/menu.spacing.test.tsx +0 -63
- package/src/core/components/menu/menu.test.tsx +0 -125
- package/src/core/components/menu/menu.tsx +0 -178
- package/src/core/components/menu/menuButton.tsx +0 -268
- package/src/core/components/menu/menuContext.ts +0 -18
- package/src/core/components/menu/menuDivider.ts +0 -23
- package/src/core/components/menu/menuGroup.spacing.test.tsx +0 -63
- package/src/core/components/menu/menuGroup.tsx +0 -233
- package/src/core/components/menu/menuItem.spacing.test.tsx +0 -59
- package/src/core/components/menu/menuItem.tsx +0 -197
- package/src/core/components/menu/useMenu.ts +0 -21
- package/src/core/components/menu/useMenuController.ts +0 -231
- package/src/core/components/skeleton/__workshop__/delay.tsx +0 -70
- package/src/core/components/skeleton/__workshop__/index.ts +0 -11
- package/src/core/components/skeleton/__workshop__/skeleton.tsx +0 -64
- package/src/core/components/skeleton/index.ts +0 -2
- package/src/core/components/skeleton/skeleton.tsx +0 -57
- package/src/core/components/skeleton/styles.ts +0 -50
- package/src/core/components/skeleton/textSkeleton.tsx +0 -122
- package/src/core/components/tab/__workshop__/example.tsx +0 -79
- package/src/core/components/tab/__workshop__/index.ts +0 -14
- package/src/core/components/tab/index.ts +0 -3
- package/src/core/components/tab/tab.tsx +0 -101
- package/src/core/components/tab/tabList.test.tsx +0 -48
- package/src/core/components/tab/tabList.tsx +0 -70
- package/src/core/components/tab/tabPanel.tsx +0 -39
- package/src/core/components/toast/__workshop__/hook.tsx +0 -71
- package/src/core/components/toast/__workshop__/index.ts +0 -19
- package/src/core/components/toast/__workshop__/toast.tsx +0 -26
- package/src/core/components/toast/index.ts +0 -4
- package/src/core/components/toast/styles.ts +0 -77
- package/src/core/components/toast/toast.test.tsx +0 -101
- package/src/core/components/toast/toast.tsx +0 -198
- package/src/core/components/toast/toastContext.ts +0 -7
- package/src/core/components/toast/toastLayer.tsx +0 -51
- package/src/core/components/toast/toastProvider.tsx +0 -113
- package/src/core/components/toast/toastState.ts +0 -6
- package/src/core/components/toast/types.ts +0 -26
- package/src/core/components/toast/useToast.ts +0 -25
- package/src/core/components/tree/__workshop__/basic.perf.ts +0 -19
- package/src/core/components/tree/__workshop__/basic.tsx +0 -105
- package/src/core/components/tree/__workshop__/index.ts +0 -21
- package/src/core/components/tree/__workshop__/tabFromElement.tsx +0 -84
- package/src/core/components/tree/helpers.ts +0 -105
- package/src/core/components/tree/index.ts +0 -4
- package/src/core/components/tree/style.ts +0 -105
- package/src/core/components/tree/tree.test.tsx +0 -55
- package/src/core/components/tree/tree.tsx +0 -240
- package/src/core/components/tree/treeContext.ts +0 -10
- package/src/core/components/tree/treeGroup.tsx +0 -28
- package/src/core/components/tree/treeItem.test.tsx +0 -65
- package/src/core/components/tree/treeItem.tsx +0 -224
- package/src/core/components/tree/types.ts +0 -25
- package/src/core/components/tree/useTree.ts +0 -17
- package/src/core/constants.ts +0 -79
- package/src/core/helpers/animation.ts +0 -27
- package/src/core/helpers/element.ts +0 -55
- package/src/core/helpers/focus.ts +0 -100
- package/src/core/helpers/index.ts +0 -4
- package/src/core/helpers/scroll.ts +0 -15
- package/src/core/hooks/index.ts +0 -12
- package/src/core/hooks/useArrayProp.ts +0 -17
- package/src/core/hooks/useClickOutside.test.tsx +0 -482
- package/src/core/hooks/useClickOutside.ts +0 -118
- package/src/core/hooks/useClickOutsideEvent.test.tsx +0 -115
- package/src/core/hooks/useClickOutsideEvent.ts +0 -73
- package/src/core/hooks/useCustomValidity.ts +0 -13
- package/src/core/hooks/useDelayed.test.ts +0 -88
- package/src/core/hooks/useDelayedState.ts +0 -36
- package/src/core/hooks/useElementRect/__workshop__/example.tsx +0 -32
- package/src/core/hooks/useElementRect/__workshop__/index.ts +0 -14
- package/src/core/hooks/useElementRect/index.ts +0 -1
- package/src/core/hooks/useElementRect/useElementRect.ts +0 -13
- package/src/core/hooks/useElementSize.ts +0 -19
- package/src/core/hooks/useForwardedRef.ts +0 -19
- package/src/core/hooks/useGlobalKeyDown.ts +0 -24
- package/src/core/hooks/useIsomorphicEffect.ts +0 -7
- package/src/core/hooks/useMatchMedia.ts +0 -28
- package/src/core/hooks/useMediaIndex/__workshop__/index.ts +0 -14
- package/src/core/hooks/useMediaIndex/__workshop__/test.tsx +0 -14
- package/src/core/hooks/useMediaIndex/index.ts +0 -1
- package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +0 -36
- package/src/core/hooks/useMediaIndex/useMediaIndex.ts +0 -102
- package/src/core/hooks/useMounted.ts +0 -15
- package/src/core/hooks/usePrefersDark.hydration.test.tsx +0 -56
- package/src/core/hooks/usePrefersDark.test.tsx +0 -19
- package/src/core/hooks/usePrefersDark.ts +0 -16
- package/src/core/hooks/usePrefersReducedMotion.hydration.test.tsx +0 -56
- package/src/core/hooks/usePrefersReducedMotion.test.tsx +0 -19
- package/src/core/hooks/usePrefersReducedMotion.ts +0 -16
- package/src/core/index.ts +0 -10
- package/src/core/lib/createGlobalScopedContext.ts +0 -36
- package/src/core/lib/globalScope.ts +0 -19
- package/src/core/lib/isRecord.ts +0 -3
- package/src/core/middleware/origin.ts +0 -47
- package/src/core/observers/elementSizeObserver.ts +0 -116
- package/src/core/observers/index.ts +0 -2
- package/src/core/observers/resizeObserver.ts +0 -9
- package/src/core/primitives/_selectable/index.ts +0 -1
- package/src/core/primitives/_selectable/selectable.tsx +0 -15
- package/src/core/primitives/_selectable/style.ts +0 -115
- package/src/core/primitives/avatar/__workshop__/asButton.tsx +0 -14
- package/src/core/primitives/avatar/__workshop__/index.ts +0 -29
- package/src/core/primitives/avatar/__workshop__/stack.tsx +0 -25
- package/src/core/primitives/avatar/__workshop__/withinButton.tsx +0 -63
- package/src/core/primitives/avatar/__workshop__/withinMenuItem.tsx +0 -70
- package/src/core/primitives/avatar/avatar.tsx +0 -200
- package/src/core/primitives/avatar/avatarCounter.tsx +0 -91
- package/src/core/primitives/avatar/avatarStack.tsx +0 -100
- package/src/core/primitives/avatar/index.ts +0 -4
- package/src/core/primitives/avatar/styles.ts +0 -167
- package/src/core/primitives/avatar/types.ts +0 -17
- package/src/core/primitives/badge/__workshop__/index.ts +0 -19
- package/src/core/primitives/badge/__workshop__/props.tsx +0 -30
- package/src/core/primitives/badge/__workshop__/tones.tsx +0 -21
- package/src/core/primitives/badge/badge.test.tsx +0 -16
- package/src/core/primitives/badge/badge.tsx +0 -70
- package/src/core/primitives/badge/index.ts +0 -1
- package/src/core/primitives/badge/styles.ts +0 -20
- package/src/core/primitives/badge/types.ts +0 -8
- package/src/core/primitives/box/__workshop__/asComponent.tsx +0 -31
- package/src/core/primitives/box/__workshop__/index.ts +0 -24
- package/src/core/primitives/box/__workshop__/props.tsx +0 -20
- package/src/core/primitives/box/__workshop__/responsive.tsx +0 -20
- package/src/core/primitives/box/box.test.tsx +0 -142
- package/src/core/primitives/box/box.tsx +0 -154
- package/src/core/primitives/box/index.ts +0 -1
- package/src/core/primitives/button/__workshop__/custom.tsx +0 -51
- package/src/core/primitives/button/__workshop__/customIcons.tsx +0 -30
- package/src/core/primitives/button/__workshop__/disabled.tsx +0 -74
- package/src/core/primitives/button/__workshop__/index.ts +0 -59
- package/src/core/primitives/button/__workshop__/labelUploadButton.tsx +0 -36
- package/src/core/primitives/button/__workshop__/mixedChildren.tsx +0 -12
- package/src/core/primitives/button/__workshop__/props.tsx +0 -55
- package/src/core/primitives/button/__workshop__/stacked.tsx +0 -58
- package/src/core/primitives/button/__workshop__/styled1.tsx +0 -17
- package/src/core/primitives/button/__workshop__/styled2.tsx +0 -19
- package/src/core/primitives/button/__workshop__/uploadButton.tsx +0 -28
- package/src/core/primitives/button/button.test.tsx +0 -82
- package/src/core/primitives/button/button.tsx +0 -210
- package/src/core/primitives/button/index.ts +0 -1
- package/src/core/primitives/button/styles.ts +0 -117
- package/src/core/primitives/card/__workshop__/allTones.tsx +0 -25
- package/src/core/primitives/card/__workshop__/asButton.tsx +0 -107
- package/src/core/primitives/card/__workshop__/asComponent.tsx +0 -27
- package/src/core/primitives/card/__workshop__/checkered.tsx +0 -26
- package/src/core/primitives/card/__workshop__/index.ts +0 -18
- package/src/core/primitives/card/__workshop__/interactive.tsx +0 -30
- package/src/core/primitives/card/__workshop__/listNavigation.tsx +0 -80
- package/src/core/primitives/card/__workshop__/props.tsx +0 -53
- package/src/core/primitives/card/__workshop__/selected.tsx +0 -94
- package/src/core/primitives/card/__workshop__/styled.tsx +0 -14
- package/src/core/primitives/card/card.tsx +0 -128
- package/src/core/primitives/card/index.ts +0 -2
- package/src/core/primitives/card/styles.ts +0 -147
- package/src/core/primitives/card/types.ts +0 -11
- package/src/core/primitives/checkbox/__workshop__/example.tsx +0 -25
- package/src/core/primitives/checkbox/__workshop__/index.ts +0 -13
- package/src/core/primitives/checkbox/__workshop__/props.tsx +0 -33
- package/src/core/primitives/checkbox/__workshop__/readOnly.tsx +0 -16
- package/src/core/primitives/checkbox/__workshop__/tones.tsx +0 -28
- package/src/core/primitives/checkbox/checkbox.tsx +0 -73
- package/src/core/primitives/checkbox/index.ts +0 -1
- package/src/core/primitives/checkbox/styles.ts +0 -128
- package/src/core/primitives/code/__workshop__/index.ts +0 -19
- package/src/core/primitives/code/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/code/__workshop__/props.tsx +0 -21
- package/src/core/primitives/code/code.tsx +0 -55
- package/src/core/primitives/code/index.ts +0 -1
- package/src/core/primitives/code/refractor.tsx +0 -20
- package/src/core/primitives/code/styles.ts +0 -77
- package/src/core/primitives/container/__workshop__/example.tsx +0 -20
- package/src/core/primitives/container/__workshop__/index.ts +0 -8
- package/src/core/primitives/container/container.tsx +0 -54
- package/src/core/primitives/container/index.ts +0 -2
- package/src/core/primitives/container/styles.ts +0 -23
- package/src/core/primitives/container/types.ts +0 -6
- package/src/core/primitives/flex/__workshop__/example.tsx +0 -34
- package/src/core/primitives/flex/__workshop__/gap.tsx +0 -25
- package/src/core/primitives/flex/__workshop__/index.ts +0 -11
- package/src/core/primitives/flex/flex.tsx +0 -64
- package/src/core/primitives/flex/index.ts +0 -1
- package/src/core/primitives/grid/__workshop__/index.ts +0 -10
- package/src/core/primitives/grid/__workshop__/responsive.tsx +0 -54
- package/src/core/primitives/grid/grid.test.tsx +0 -80
- package/src/core/primitives/grid/grid.tsx +0 -74
- package/src/core/primitives/grid/index.ts +0 -1
- package/src/core/primitives/heading/__workshop__/index.ts +0 -19
- package/src/core/primitives/heading/__workshop__/opticalAlignment.tsx +0 -54
- package/src/core/primitives/heading/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/heading/heading.tsx +0 -88
- package/src/core/primitives/heading/index.ts +0 -1
- package/src/core/primitives/heading/styles.ts +0 -64
- package/src/core/primitives/heading/types.ts +0 -7
- package/src/core/primitives/index.ts +0 -27
- package/src/core/primitives/inline/__workshop__/index.ts +0 -8
- package/src/core/primitives/inline/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/inline/index.ts +0 -1
- package/src/core/primitives/inline/inline.test.tsx +0 -51
- package/src/core/primitives/inline/inline.tsx +0 -63
- package/src/core/primitives/inline/styles.ts +0 -32
- package/src/core/primitives/inline/types.ts +0 -6
- package/src/core/primitives/kbd/__workshop__/index.ts +0 -8
- package/src/core/primitives/kbd/__workshop__/plain.tsx +0 -9
- package/src/core/primitives/kbd/index.ts +0 -1
- package/src/core/primitives/kbd/kbd.tsx +0 -69
- package/src/core/primitives/label/__workshop__/index.ts +0 -19
- package/src/core/primitives/label/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/label/__workshop__/plain.tsx +0 -24
- package/src/core/primitives/label/index.ts +0 -1
- package/src/core/primitives/label/label.tsx +0 -87
- package/src/core/primitives/label/styles.ts +0 -45
- package/src/core/primitives/popover/__workshop__/AlignedStory.tsx +0 -77
- package/src/core/primitives/popover/__workshop__/MarginsStory.tsx +0 -31
- package/src/core/primitives/popover/__workshop__/MatchReferenceWidthStory.tsx +0 -32
- package/src/core/primitives/popover/__workshop__/OpenOnMountStory.tsx +0 -11
- package/src/core/primitives/popover/__workshop__/PlainStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/RecursiveStory.tsx +0 -71
- package/src/core/primitives/popover/__workshop__/SidePanelStory.tsx +0 -89
- package/src/core/primitives/popover/__workshop__/TestStory.tsx +0 -97
- package/src/core/primitives/popover/__workshop__/index.ts +0 -49
- package/src/core/primitives/popover/constants.ts +0 -22
- package/src/core/primitives/popover/floating-ui/size.ts +0 -99
- package/src/core/primitives/popover/helpers.ts +0 -31
- package/src/core/primitives/popover/index.ts +0 -2
- package/src/core/primitives/popover/popover.tsx +0 -511
- package/src/core/primitives/popover/popoverCard.tsx +0 -166
- package/src/core/primitives/popover/types.ts +0 -7
- package/src/core/primitives/radio/__workshop__/example.tsx +0 -63
- package/src/core/primitives/radio/__workshop__/index.ts +0 -11
- package/src/core/primitives/radio/__workshop__/plain.tsx +0 -28
- package/src/core/primitives/radio/index.ts +0 -1
- package/src/core/primitives/radio/radio.tsx +0 -51
- package/src/core/primitives/radio/styles.ts +0 -117
- package/src/core/primitives/select/__workshop__/index.ts +0 -11
- package/src/core/primitives/select/__workshop__/plain.tsx +0 -27
- package/src/core/primitives/select/__workshop__/readOnly.tsx +0 -23
- package/src/core/primitives/select/index.ts +0 -1
- package/src/core/primitives/select/select.test.tsx +0 -52
- package/src/core/primitives/select/select.tsx +0 -94
- package/src/core/primitives/select/styles.ts +0 -166
- package/src/core/primitives/spinner/__workshop__/Props.tsx +0 -15
- package/src/core/primitives/spinner/__workshop__/index.ts +0 -14
- package/src/core/primitives/spinner/index.ts +0 -1
- package/src/core/primitives/spinner/spinner.tsx +0 -46
- package/src/core/primitives/stack/__workshop__/index.ts +0 -14
- package/src/core/primitives/stack/__workshop__/plain.tsx +0 -32
- package/src/core/primitives/stack/index.ts +0 -1
- package/src/core/primitives/stack/stack.test.tsx +0 -57
- package/src/core/primitives/stack/stack.tsx +0 -57
- package/src/core/primitives/stack/styles.ts +0 -32
- package/src/core/primitives/switch/__workshop__/example.tsx +0 -23
- package/src/core/primitives/switch/__workshop__/index.ts +0 -11
- package/src/core/primitives/switch/__workshop__/props.tsx +0 -21
- package/src/core/primitives/switch/index.ts +0 -1
- package/src/core/primitives/switch/styles.ts +0 -173
- package/src/core/primitives/switch/switch.tsx +0 -68
- package/src/core/primitives/text/__workshop__/colored.tsx +0 -30
- package/src/core/primitives/text/__workshop__/example.tsx +0 -39
- package/src/core/primitives/text/__workshop__/index.ts +0 -24
- package/src/core/primitives/text/__workshop__/opticalAlignment.tsx +0 -48
- package/src/core/primitives/text/index.ts +0 -1
- package/src/core/primitives/text/styles.ts +0 -74
- package/src/core/primitives/text/text.tsx +0 -89
- package/src/core/primitives/textArea/__workshop__/index.ts +0 -14
- package/src/core/primitives/textArea/__workshop__/plain.tsx +0 -50
- package/src/core/primitives/textArea/index.ts +0 -1
- package/src/core/primitives/textArea/textArea.tsx +0 -120
- package/src/core/primitives/textInput/__workshop__/clearButton.tsx +0 -30
- package/src/core/primitives/textInput/__workshop__/customValidity.tsx +0 -17
- package/src/core/primitives/textInput/__workshop__/index.ts +0 -44
- package/src/core/primitives/textInput/__workshop__/plain.tsx +0 -98
- package/src/core/primitives/textInput/__workshop__/readOnly.tsx +0 -9
- package/src/core/primitives/textInput/__workshop__/states.tsx +0 -53
- package/src/core/primitives/textInput/__workshop__/tones.tsx +0 -277
- package/src/core/primitives/textInput/__workshop__/typed.tsx +0 -23
- package/src/core/primitives/textInput/index.ts +0 -1
- package/src/core/primitives/textInput/textInput.test.tsx +0 -48
- package/src/core/primitives/textInput/textInput.tsx +0 -395
- package/src/core/primitives/tooltip/__workshop__/customPortal.tsx +0 -102
- package/src/core/primitives/tooltip/__workshop__/index.ts +0 -29
- package/src/core/primitives/tooltip/__workshop__/overflowingBoundary.tsx +0 -74
- package/src/core/primitives/tooltip/__workshop__/props.tsx +0 -107
- package/src/core/primitives/tooltip/__workshop__/resizableBoundary.tsx +0 -86
- package/src/core/primitives/tooltip/constants.ts +0 -23
- package/src/core/primitives/tooltip/index.ts +0 -2
- package/src/core/primitives/tooltip/tooltip.test.tsx +0 -452
- package/src/core/primitives/tooltip/tooltip.tsx +0 -495
- package/src/core/primitives/tooltip/tooltipCard.tsx +0 -109
- package/src/core/primitives/tooltip/tooltipDelayGroup/index.ts +0 -4
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupContext.tsx +0 -11
- package/src/core/primitives/tooltip/tooltipDelayGroup/tooltipDelayGroupProvider.tsx +0 -57
- package/src/core/primitives/tooltip/tooltipDelayGroup/types.ts +0 -10
- package/src/core/primitives/tooltip/tooltipDelayGroup/useTooltipDelayGroup.ts +0 -13
- package/src/core/primitives/types.ts +0 -179
- package/src/core/styles/border/borderStyle.ts +0 -56
- package/src/core/styles/border/index.ts +0 -2
- package/src/core/styles/border/types.ts +0 -10
- package/src/core/styles/box/boxStyle.ts +0 -69
- package/src/core/styles/box/index.ts +0 -2
- package/src/core/styles/box/types.ts +0 -11
- package/src/core/styles/card/_cardColorStyle.ts +0 -108
- package/src/core/styles/card/index.ts +0 -1
- package/src/core/styles/flex/flexItemStyle.ts +0 -27
- package/src/core/styles/flex/flexStyle.ts +0 -70
- package/src/core/styles/flex/index.ts +0 -3
- package/src/core/styles/flex/types.ts +0 -25
- package/src/core/styles/focusRing/index.ts +0 -25
- package/src/core/styles/font/codeFontStyle.ts +0 -13
- package/src/core/styles/font/headingFontStyle.ts +0 -13
- package/src/core/styles/font/index.ts +0 -6
- package/src/core/styles/font/labelFontStyle.ts +0 -13
- package/src/core/styles/font/responsiveFont.ts +0 -103
- package/src/core/styles/font/textAlignStyle.ts +0 -19
- package/src/core/styles/font/textFontStyle.ts +0 -13
- package/src/core/styles/font/types.ts +0 -35
- package/src/core/styles/grid/gridItemStyle.ts +0 -82
- package/src/core/styles/grid/gridStyle.ts +0 -108
- package/src/core/styles/grid/index.ts +0 -3
- package/src/core/styles/grid/types.ts +0 -37
- package/src/core/styles/helpers.ts +0 -72
- package/src/core/styles/index.ts +0 -5
- package/src/core/styles/input/index.ts +0 -2
- package/src/core/styles/input/responsiveInputPaddingStyle.ts +0 -78
- package/src/core/styles/input/textInputStyle.ts +0 -263
- package/src/core/styles/internal.ts +0 -12
- package/src/core/styles/margin/index.ts +0 -2
- package/src/core/styles/margin/marginStyle.ts +0 -21
- package/src/core/styles/margin/marginsStyle.test.ts +0 -33
- package/src/core/styles/margin/types.ts +0 -9
- package/src/core/styles/padding/index.ts +0 -2
- package/src/core/styles/padding/paddingStyle.test.ts +0 -33
- package/src/core/styles/padding/paddingStyle.ts +0 -21
- package/src/core/styles/padding/types.ts +0 -12
- package/src/core/styles/radius/index.ts +0 -2
- package/src/core/styles/radius/radiusStyle.ts +0 -23
- package/src/core/styles/radius/types.ts +0 -8
- package/src/core/styles/shadow/index.ts +0 -2
- package/src/core/styles/shadow/shadowStyle.ts +0 -29
- package/src/core/styles/shadow/types.ts +0 -6
- package/src/core/styles/types.ts +0 -8
- package/src/core/theme/__workshop__/build/Root.tsx +0 -367
- package/src/core/theme/__workshop__/build/helpers.ts +0 -46
- package/src/core/theme/__workshop__/build/story.tsx +0 -465
- package/src/core/theme/__workshop__/canvas.tsx +0 -352
- package/src/core/theme/__workshop__/color.tsx +0 -62
- package/src/core/theme/__workshop__/debug/story.tsx +0 -408
- package/src/core/theme/__workshop__/index.ts +0 -39
- package/src/core/theme/__workshop__/layer.tsx +0 -78
- package/src/core/theme/__workshop__/nestedProvider.tsx +0 -15
- package/src/core/theme/index.ts +0 -5
- package/src/core/theme/theme.test.tsx +0 -73
- package/src/core/theme/themeColorProvider.tsx +0 -29
- package/src/core/theme/themeContext.ts +0 -10
- package/src/core/theme/themeProvider.tsx +0 -62
- package/src/core/theme/types.ts +0 -12
- package/src/core/theme/useRootTheme.ts +0 -17
- package/src/core/theme/useTheme.ts +0 -16
- package/src/core/types/avatar.ts +0 -14
- package/src/core/types/badge.ts +0 -12
- package/src/core/types/box.ts +0 -19
- package/src/core/types/button.ts +0 -21
- package/src/core/types/card.ts +0 -6
- package/src/core/types/component.ts +0 -32
- package/src/core/types/dialog.ts +0 -4
- package/src/core/types/flex.ts +0 -30
- package/src/core/types/grid.ts +0 -14
- package/src/core/types/gridItem.ts +0 -29
- package/src/core/types/index.ts +0 -15
- package/src/core/types/placement.ts +0 -18
- package/src/core/types/popover.ts +0 -4
- package/src/core/types/radius.ts +0 -4
- package/src/core/types/selectable.ts +0 -6
- package/src/core/types/text.ts +0 -4
- package/src/core/utils/arrow/arrow.tsx +0 -123
- package/src/core/utils/arrow/cmds.ts +0 -91
- package/src/core/utils/arrow/index.ts +0 -1
- package/src/core/utils/boundaryElement/__workshop__/index.ts +0 -14
- package/src/core/utils/boundaryElement/__workshop__/plain.tsx +0 -19
- package/src/core/utils/boundaryElement/boundaryElement.test.tsx +0 -100
- package/src/core/utils/boundaryElement/boundaryElementContext.ts +0 -7
- package/src/core/utils/boundaryElement/boundaryElementProvider.tsx +0 -24
- package/src/core/utils/boundaryElement/index.ts +0 -3
- package/src/core/utils/boundaryElement/types.ts +0 -7
- package/src/core/utils/boundaryElement/useBoundaryElement.ts +0 -26
- package/src/core/utils/conditionalWrapper/conditionalWrapper.tsx +0 -21
- package/src/core/utils/conditionalWrapper/index.ts +0 -1
- package/src/core/utils/elementQuery/__workshop__/customMedia.tsx +0 -30
- package/src/core/utils/elementQuery/__workshop__/index.ts +0 -14
- package/src/core/utils/elementQuery/elementQuery.tsx +0 -53
- package/src/core/utils/elementQuery/helpers.ts +0 -27
- package/src/core/utils/elementQuery/index.ts +0 -1
- package/src/core/utils/errorBoundary.tsx +0 -48
- package/src/core/utils/getElementRef.ts +0 -26
- package/src/core/utils/index.ts +0 -9
- package/src/core/utils/layer/__workshop__/_debug.tsx +0 -17
- package/src/core/utils/layer/__workshop__/index.ts +0 -24
- package/src/core/utils/layer/__workshop__/multipleRoots.tsx +0 -49
- package/src/core/utils/layer/__workshop__/nested.tsx +0 -98
- package/src/core/utils/layer/__workshop__/responsiveZOffset.tsx +0 -13
- package/src/core/utils/layer/getLayerContext.test.ts +0 -30
- package/src/core/utils/layer/getLayerContext.ts +0 -21
- package/src/core/utils/layer/index.ts +0 -4
- package/src/core/utils/layer/layer.test.tsx +0 -108
- package/src/core/utils/layer/layer.tsx +0 -98
- package/src/core/utils/layer/layerContext.ts +0 -7
- package/src/core/utils/layer/layerProvider.tsx +0 -111
- package/src/core/utils/layer/types.ts +0 -9
- package/src/core/utils/layer/useLayer.ts +0 -26
- package/src/core/utils/portal/__workshop__/index.ts +0 -14
- package/src/core/utils/portal/__workshop__/named.tsx +0 -63
- package/src/core/utils/portal/index.ts +0 -4
- package/src/core/utils/portal/portal.test.tsx +0 -103
- package/src/core/utils/portal/portal.ts +0 -32
- package/src/core/utils/portal/portalContext.ts +0 -31
- package/src/core/utils/portal/portalProvider.tsx +0 -47
- package/src/core/utils/portal/types.ts +0 -9
- package/src/core/utils/portal/usePortal.ts +0 -25
- package/src/core/utils/spanWithTextOverflow.tsx +0 -10
- package/src/core/utils/srOnly/index.ts +0 -1
- package/src/core/utils/srOnly/srOnly.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/changingProps.tsx +0 -36
- package/src/core/utils/virtualList/__workshop__/elementScroll.tsx +0 -24
- package/src/core/utils/virtualList/__workshop__/index.ts +0 -29
- package/src/core/utils/virtualList/__workshop__/infiniteList.tsx +0 -48
- package/src/core/utils/virtualList/__workshop__/windowScrolll.tsx +0 -22
- package/src/core/utils/virtualList/index.ts +0 -1
- package/src/core/utils/virtualList/virtualList.tsx +0 -200
- package/src/theme/build/_deprecated/color/_selectable/createSelectableTones.ts +0 -76
- package/src/theme/build/_deprecated/color/_solid/createSolidTones.ts +0 -54
- package/src/theme/build/_deprecated/color/button/createButtonModes.ts +0 -22
- package/src/theme/build/_deprecated/color/button/createButtonTones.ts +0 -55
- package/src/theme/build/_deprecated/color/card/createCardStates.ts +0 -60
- package/src/theme/build/_deprecated/color/color.test.ts +0 -63
- package/src/theme/build/_deprecated/color/defaults.ts +0 -390
- package/src/theme/build/_deprecated/color/factory.ts +0 -142
- package/src/theme/build/_deprecated/color/index.ts +0 -1
- package/src/theme/build/_deprecated/color/input/createInputModes.ts +0 -81
- package/src/theme/build/_deprecated/color/muted/createMuted.ts +0 -54
- package/src/theme/build/_deprecated/color/spot/createSpot.ts +0 -20
- package/src/theme/build/buildColorTheme.test.ts +0 -183
- package/src/theme/build/buildColorTheme.ts +0 -499
- package/src/theme/build/buildTheme.test.ts +0 -87
- package/src/theme/build/buildTheme.ts +0 -36
- package/src/theme/build/colorToken/colorToken.ts +0 -19
- package/src/theme/build/colorToken/compileColorToken.ts +0 -21
- package/src/theme/build/colorToken/index.ts +0 -2
- package/src/theme/build/colorToken/types.ts +0 -6
- package/src/theme/build/index.ts +0 -3
- package/src/theme/build/lib/color-fns/blend/index.ts +0 -3
- package/src/theme/build/lib/color-fns/blend/mix.ts +0 -21
- package/src/theme/build/lib/color-fns/blend/multiply.ts +0 -18
- package/src/theme/build/lib/color-fns/blend/screen.ts +0 -18
- package/src/theme/build/lib/color-fns/color-fns.test.ts +0 -68
- package/src/theme/build/lib/color-fns/contrastRatio.ts +0 -31
- package/src/theme/build/lib/color-fns/convert.ts +0 -150
- package/src/theme/build/lib/color-fns/index.ts +0 -6
- package/src/theme/build/lib/color-fns/parse.ts +0 -60
- package/src/theme/build/lib/color-fns/rgba.ts +0 -10
- package/src/theme/build/lib/color-fns/types.ts +0 -28
- package/src/theme/build/lib/isRecord.ts +0 -3
- package/src/theme/build/lib/lazy.ts +0 -30
- package/src/theme/build/lib/utils.ts +0 -19
- package/src/theme/build/merge.ts +0 -26
- package/src/theme/build/mixThemeColor.test.ts +0 -21
- package/src/theme/build/mixThemeColor.ts +0 -53
- package/src/theme/build/renderColorTheme.ts +0 -532
- package/src/theme/build/renderColorValue.ts +0 -85
- package/src/theme/build/resolveColorTokens.ts +0 -268
- package/src/theme/build/theme.test.ts +0 -27
- package/src/theme/config/helpers.ts +0 -55
- package/src/theme/config/index.ts +0 -4
- package/src/theme/config/system.ts +0 -115
- package/src/theme/config/tokens/color/index.ts +0 -1
- package/src/theme/config/tokens/color/types.ts +0 -133
- package/src/theme/config/tokens/index.ts +0 -4
- package/src/theme/config/tokens/parseTokenKey.test.ts +0 -64
- package/src/theme/config/tokens/parseTokenKey.ts +0 -67
- package/src/theme/config/tokens/parseTokenValue.test.ts +0 -42
- package/src/theme/config/tokens/parseTokenValue.ts +0 -133
- package/src/theme/config/tokens/types.ts +0 -53
- package/src/theme/config/types.ts +0 -46
- package/src/theme/defaults/colorPalette.ts +0 -5
- package/src/theme/defaults/colorTokens.ts +0 -648
- package/src/theme/defaults/config.ts +0 -84
- package/src/theme/defaults/fonts.ts +0 -227
- package/src/theme/getScopedTheme.ts +0 -98
- package/src/theme/index.ts +0 -5
- package/src/theme/system/avatar.ts +0 -14
- package/src/theme/system/color/_constants.ts +0 -45
- package/src/theme/system/color/_helpers.ts +0 -24
- package/src/theme/system/color/_system.ts +0 -40
- package/src/theme/system/color/avatar.ts +0 -15
- package/src/theme/system/color/badge.ts +0 -16
- package/src/theme/system/color/button.ts +0 -17
- package/src/theme/system/color/color.ts +0 -34
- package/src/theme/system/color/index.ts +0 -13
- package/src/theme/system/color/input.ts +0 -25
- package/src/theme/system/color/kbd.ts +0 -8
- package/src/theme/system/color/selectable.ts +0 -12
- package/src/theme/system/color/shadow.ts +0 -7
- package/src/theme/system/color/state.ts +0 -43
- package/src/theme/system/color/syntax.ts +0 -41
- package/src/theme/system/css.ts +0 -14
- package/src/theme/system/focusRing.ts +0 -7
- package/src/theme/system/font.ts +0 -52
- package/src/theme/system/index.ts +0 -11
- package/src/theme/system/input.ts +0 -33
- package/src/theme/system/layer.ts +0 -8
- package/src/theme/system/shadow.ts +0 -19
- package/src/theme/system/styles.ts +0 -13
- package/src/theme/system/theme.ts +0 -138
- package/src/theme/system/v0/avatar.ts +0 -10
- package/src/theme/system/v0/color/_generic.ts +0 -35
- package/src/theme/system/v0/color/_system.ts +0 -17
- package/src/theme/system/v0/color/base.ts +0 -21
- package/src/theme/system/v0/color/button.ts +0 -42
- package/src/theme/system/v0/color/card.ts +0 -19
- package/src/theme/system/v0/color/color.ts +0 -40
- package/src/theme/system/v0/color/index.ts +0 -11
- package/src/theme/system/v0/color/input.ts +0 -34
- package/src/theme/system/v0/color/muted.ts +0 -26
- package/src/theme/system/v0/color/selectable.ts +0 -31
- package/src/theme/system/v0/color/solid.ts +0 -26
- package/src/theme/system/v0/color/spot.ts +0 -13
- package/src/theme/system/v0/index.ts +0 -3
- package/src/theme/system/v0/input.ts +0 -23
- package/src/theme/versioning/getTheme_v2.ts +0 -57
- package/src/theme/versioning/index.ts +0 -5
- package/src/theme/versioning/is_v0.ts +0 -6
- package/src/theme/versioning/is_v2.ts +0 -6
- package/src/theme/versioning/themeColor_v0_v2.ts +0 -243
- package/src/theme/versioning/themeColor_v2_v2_9.ts +0 -49
- package/src/theme/versioning/v0_v2.ts +0 -94
- package/src/theme/versioning/v2_v0.ts +0 -135
|
@@ -0,0 +1,2203 @@
|
|
|
1
|
+
import { CONTROL_TYPES, HELP_MORE_MAX, ITEM_NAME_RE, UI_CONTROLS } from "./prod-types.js";
|
|
2
|
+
import { dockIconOf, tablerIconOf } from "./icons.js";
|
|
3
|
+
import { CATALOG, FEATURES } from "./lossy.js";
|
|
4
|
+
import { isDataTableProp, tableConfigFromOptions, tableOptionsFromConfig } from "../controls/table/prod.js";
|
|
5
|
+
import { buttonFromProd, buttonToProd, datetimeFromProd, datetimeToProd, imageFromProd, imageToProd, linkFromProd, linkToProd, listFromProd, listToProd, ratingFromProd, ratingToProd, referenceFromProd, referenceToProd, scaleFromProd, scaleToProd, videoFromProd, videoToProd, zoneListFromProd, zoneListToProd } from "./values.js";
|
|
6
|
+
//#region src/kit/adapters/schema.ts
|
|
7
|
+
var isObj = (v) => !!v && typeof v === "object" && !Array.isArray(v);
|
|
8
|
+
function deepEqual(a, b) {
|
|
9
|
+
if (a === b) return true;
|
|
10
|
+
if (Array.isArray(a) || Array.isArray(b)) return Array.isArray(a) && Array.isArray(b) && a.length === b.length && a.every((x, i) => deepEqual(x, b[i]));
|
|
11
|
+
if (!isObj(a) || !isObj(b)) return false;
|
|
12
|
+
return [...new Set([...Object.keys(a), ...Object.keys(b)].filter((k) => a[k] !== void 0 || b[k] !== void 0))].every((k) => deepEqual(a[k], b[k]));
|
|
13
|
+
}
|
|
14
|
+
var singular = (t) => t.endsWith("ies") ? `${t.slice(0, -3)}y` : t.endsWith("s") && !t.endsWith("ss") ? t.slice(0, -1) : t;
|
|
15
|
+
var kebab = (s) => s.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/^-+|-+$/g, "") || "schema";
|
|
16
|
+
var camel = (s) => s.replace(/-([a-z0-9])/g, (_, c) => c.toUpperCase());
|
|
17
|
+
var capitalize = (s) => s.charAt(0).toUpperCase() + s.slice(1);
|
|
18
|
+
var ZONE_NAMES = new Set(typeof Intl.supportedValuesOf === "function" ? [...Intl.supportedValuesOf("timeZone"), "UTC"] : ["UTC"]);
|
|
19
|
+
/** An IANA zone name (isTimeZoneName): ICU's canonical list, or a current name Intl itself accepts (Asia/Kolkata). */
|
|
20
|
+
var isZone = (z) => {
|
|
21
|
+
if (ZONE_NAMES.has(z)) return true;
|
|
22
|
+
if (!/^[A-Za-z]+(?:\/[A-Za-z0-9_+-]+)+$/.test(z)) return false;
|
|
23
|
+
try {
|
|
24
|
+
new Intl.DateTimeFormat("en", { timeZone: z });
|
|
25
|
+
return true;
|
|
26
|
+
} catch {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
/** The item type of a single-type array, as both directions name it when prod has no name for it. */
|
|
31
|
+
var conventionItem = (fieldName, fieldTitle, itemLabel) => ({
|
|
32
|
+
name: singular(fieldName),
|
|
33
|
+
title: itemLabel ?? singular(fieldTitle)
|
|
34
|
+
});
|
|
35
|
+
/** A condition's value as the sibling's type reads it (prod stores rule values as strings). */
|
|
36
|
+
function coerceRuleValue(siblingType, s) {
|
|
37
|
+
if (siblingType === "boolean") return s === "true" ? true : s === "false" ? false : s;
|
|
38
|
+
if ((siblingType === "number" || siblingType === "rating") && s.trim() !== "" && Number.isFinite(Number(s))) return Number(s);
|
|
39
|
+
return s;
|
|
40
|
+
}
|
|
41
|
+
/** V2 primitive types → the same-valued prod field type (fields lane). */
|
|
42
|
+
var FIELD_TYPE = {
|
|
43
|
+
string: "text",
|
|
44
|
+
text: "longtext",
|
|
45
|
+
richtext: "richtext",
|
|
46
|
+
number: "number",
|
|
47
|
+
rating: "rating",
|
|
48
|
+
boolean: "boolean",
|
|
49
|
+
slug: "slug",
|
|
50
|
+
email: "email",
|
|
51
|
+
date: "date",
|
|
52
|
+
datetime: "datetime",
|
|
53
|
+
color: "color",
|
|
54
|
+
select: "select",
|
|
55
|
+
multiselect: "multiselect",
|
|
56
|
+
tags: "tags",
|
|
57
|
+
image: "image",
|
|
58
|
+
file: "file",
|
|
59
|
+
icon: "icon",
|
|
60
|
+
link: "link",
|
|
61
|
+
button: "button",
|
|
62
|
+
reference: "reference",
|
|
63
|
+
json: "json",
|
|
64
|
+
geopoint: "location",
|
|
65
|
+
url: "text",
|
|
66
|
+
code: "code",
|
|
67
|
+
video: "video"
|
|
68
|
+
};
|
|
69
|
+
/** V2 primitive types → prop types. */
|
|
70
|
+
var PROP_TYPE = {
|
|
71
|
+
string: "text",
|
|
72
|
+
text: "longtext",
|
|
73
|
+
video: "video",
|
|
74
|
+
richtext: "richtext",
|
|
75
|
+
number: "number",
|
|
76
|
+
rating: "rating",
|
|
77
|
+
boolean: "boolean",
|
|
78
|
+
slug: "slug",
|
|
79
|
+
email: "email",
|
|
80
|
+
date: "date",
|
|
81
|
+
datetime: "datetime",
|
|
82
|
+
color: "color",
|
|
83
|
+
select: "select",
|
|
84
|
+
multiselect: "multiselect",
|
|
85
|
+
tags: "tags",
|
|
86
|
+
image: "image",
|
|
87
|
+
file: "file",
|
|
88
|
+
icon: "icon",
|
|
89
|
+
link: "link",
|
|
90
|
+
button: "button",
|
|
91
|
+
json: "json",
|
|
92
|
+
geopoint: "location",
|
|
93
|
+
url: "url",
|
|
94
|
+
code: "code"
|
|
95
|
+
};
|
|
96
|
+
/** Field types whose `config` the backend parses strictly (unknown keys stripped or refused). */
|
|
97
|
+
var STRICT_CONFIG = new Set([
|
|
98
|
+
"array",
|
|
99
|
+
"reference",
|
|
100
|
+
"multi-reference",
|
|
101
|
+
"multiReference",
|
|
102
|
+
"date",
|
|
103
|
+
"datetime",
|
|
104
|
+
"component-ref",
|
|
105
|
+
"modular",
|
|
106
|
+
"sections",
|
|
107
|
+
"tags",
|
|
108
|
+
"rating",
|
|
109
|
+
"code",
|
|
110
|
+
"video"
|
|
111
|
+
]);
|
|
112
|
+
/** V2 list item types → prod `config.itemType` (ARRAY_ITEM_TYPES); a V2 `text` item reads back as `string`. */
|
|
113
|
+
var PRIM_ITEM = {
|
|
114
|
+
string: "text",
|
|
115
|
+
text: "text",
|
|
116
|
+
number: "number",
|
|
117
|
+
date: "date",
|
|
118
|
+
image: "image",
|
|
119
|
+
link: "link",
|
|
120
|
+
richtext: "richtext"
|
|
121
|
+
};
|
|
122
|
+
var ENTRY_TARGET = (t) => ![
|
|
123
|
+
"page",
|
|
124
|
+
"form",
|
|
125
|
+
"shopify",
|
|
126
|
+
"collection"
|
|
127
|
+
].includes(t);
|
|
128
|
+
/** The old rating: a number with ui.control "rating" and these bounds read back as no `numeric` (read side only). */
|
|
129
|
+
var RATING_CONFIG = {
|
|
130
|
+
min: 0,
|
|
131
|
+
max: 5,
|
|
132
|
+
step: .5
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* V2 block-picker category (KitCategory, and the core examples' own) → the nearest prod ComponentCategory. A category
|
|
136
|
+
* with no row has no prod twin; the server defaults the component to "custom".
|
|
137
|
+
*/
|
|
138
|
+
var CATEGORY_TO_PROD = {
|
|
139
|
+
"Navigation & chrome": "navbar",
|
|
140
|
+
Heroes: "hero",
|
|
141
|
+
"Features & storytelling": "content",
|
|
142
|
+
"Social proof": "social-proof",
|
|
143
|
+
"Media & galleries": "content",
|
|
144
|
+
Commerce: "conversion",
|
|
145
|
+
"Pricing & plans": "conversion",
|
|
146
|
+
"Conversion & forms": "conversion",
|
|
147
|
+
"Listings & feeds": "content",
|
|
148
|
+
"Long-form & docs": "content",
|
|
149
|
+
"Company & people": "content",
|
|
150
|
+
"Events & places": "content",
|
|
151
|
+
"Data & interactive": "section",
|
|
152
|
+
Navigation: "navbar",
|
|
153
|
+
Hero: "hero",
|
|
154
|
+
Content: "content",
|
|
155
|
+
Layout: "section"
|
|
156
|
+
};
|
|
157
|
+
/** The field types a kind:'block' model may hold (backend block-model-mapping.ts FIELD_PRIMITIVE). */
|
|
158
|
+
var BLOCK_FIELD_TYPES = new Set([
|
|
159
|
+
"text",
|
|
160
|
+
"longtext",
|
|
161
|
+
"richtext",
|
|
162
|
+
"image",
|
|
163
|
+
"link",
|
|
164
|
+
"slug",
|
|
165
|
+
"email",
|
|
166
|
+
"phone",
|
|
167
|
+
"color",
|
|
168
|
+
"select",
|
|
169
|
+
"number",
|
|
170
|
+
"rating",
|
|
171
|
+
"date",
|
|
172
|
+
"datetime",
|
|
173
|
+
"boolean"
|
|
174
|
+
]);
|
|
175
|
+
/** A prop's config.minItems / maxItems cap (SLOT_ITEMS_CAP, componentPropDefSchema). */
|
|
176
|
+
var SLOT_ITEMS_CAP = 50;
|
|
177
|
+
/** Backend dock-vocabulary.ts SLIDER_MAX_STOPS: a slider's (max − min) / step. */
|
|
178
|
+
var SLIDER_MAX_STOPS = 1e3;
|
|
179
|
+
/**
|
|
180
|
+
* The field types prod's unique flag accepts (uniqueFlagRules): a comparable scalar (UNIQUE_FIELD_TYPES, no two entries
|
|
181
|
+
* share it; a reference only to one model) or a list (UNIQUE_ITEMS_FIELD_TYPES, no item repeats).
|
|
182
|
+
*/
|
|
183
|
+
var UNIQUE_TYPES = new Set([
|
|
184
|
+
"text",
|
|
185
|
+
"longtext",
|
|
186
|
+
"slug",
|
|
187
|
+
"email",
|
|
188
|
+
"phone",
|
|
189
|
+
"link",
|
|
190
|
+
"number",
|
|
191
|
+
"select",
|
|
192
|
+
"reference",
|
|
193
|
+
"date",
|
|
194
|
+
"array",
|
|
195
|
+
"multiselect",
|
|
196
|
+
"tags",
|
|
197
|
+
"multi-reference"
|
|
198
|
+
]);
|
|
199
|
+
/** Prop types whose value is a list (UNIQUE_LIST_PROP_TYPES), and the sub-field types a table row compares (UNIQUE_ROW_PROP_TYPES). */
|
|
200
|
+
var UNIQUE_LIST_PROPS = new Set([
|
|
201
|
+
"multiselect",
|
|
202
|
+
"tags",
|
|
203
|
+
"multi-reference",
|
|
204
|
+
"table",
|
|
205
|
+
"array"
|
|
206
|
+
]);
|
|
207
|
+
var UNIQUE_ROW_PROPS = new Set([
|
|
208
|
+
"text",
|
|
209
|
+
"url",
|
|
210
|
+
"slug",
|
|
211
|
+
"email",
|
|
212
|
+
"phone",
|
|
213
|
+
"number",
|
|
214
|
+
"select",
|
|
215
|
+
"date"
|
|
216
|
+
]);
|
|
217
|
+
/** Types measured by minLength / maxLength (fields: LENGTH_FIELD_TYPES; props: LENGTH_TWIN), and those that take a pattern. */
|
|
218
|
+
var LENGTH_FIELDS = new Set([
|
|
219
|
+
"text",
|
|
220
|
+
"longtext",
|
|
221
|
+
"richtext",
|
|
222
|
+
"document"
|
|
223
|
+
]);
|
|
224
|
+
var LENGTH_PROPS = new Set([
|
|
225
|
+
"text",
|
|
226
|
+
"url",
|
|
227
|
+
"longtext",
|
|
228
|
+
"richtext"
|
|
229
|
+
]);
|
|
230
|
+
var PATTERN_TYPES = new Set([
|
|
231
|
+
"text",
|
|
232
|
+
"longtext",
|
|
233
|
+
"url"
|
|
234
|
+
]);
|
|
235
|
+
/**
|
|
236
|
+
* Leaf types whose value is an object a dotted preview path may read into (previewPathProblem OBJECT_VALUE_TYPES), and the
|
|
237
|
+
* keys an image or video value holds (LEAF_VALUE_KEYS). V2 reads `image.alt`; prod stores the key as `altText`.
|
|
238
|
+
*/
|
|
239
|
+
var OBJECT_VALUE_TYPES = new Set([
|
|
240
|
+
"image",
|
|
241
|
+
"link",
|
|
242
|
+
"button",
|
|
243
|
+
"file",
|
|
244
|
+
"video",
|
|
245
|
+
"location",
|
|
246
|
+
"json",
|
|
247
|
+
"code",
|
|
248
|
+
"reference",
|
|
249
|
+
"multi-reference"
|
|
250
|
+
]);
|
|
251
|
+
var LEAF_VALUE_KEYS = {
|
|
252
|
+
image: [
|
|
253
|
+
"id",
|
|
254
|
+
"url",
|
|
255
|
+
"name",
|
|
256
|
+
"altText",
|
|
257
|
+
"width",
|
|
258
|
+
"height",
|
|
259
|
+
"focal",
|
|
260
|
+
"crop"
|
|
261
|
+
],
|
|
262
|
+
video: [
|
|
263
|
+
"url",
|
|
264
|
+
"poster",
|
|
265
|
+
"autoplay",
|
|
266
|
+
"loop",
|
|
267
|
+
"transcript"
|
|
268
|
+
]
|
|
269
|
+
};
|
|
270
|
+
var IMAGE_PATH_KEY = { alt: "altText" };
|
|
271
|
+
var lose = (ctx, path, feature) => ctx.lossy.push({
|
|
272
|
+
path,
|
|
273
|
+
feature,
|
|
274
|
+
reason: FEATURES[feature].reason
|
|
275
|
+
});
|
|
276
|
+
var cat = (ctx, path, feature) => ctx.catalog.push({
|
|
277
|
+
path,
|
|
278
|
+
feature,
|
|
279
|
+
reason: CATALOG[feature]
|
|
280
|
+
});
|
|
281
|
+
/** Keys every type keeps, including a field degraded to json. */
|
|
282
|
+
var COMMON_KEYS = new Set([
|
|
283
|
+
"name",
|
|
284
|
+
"title",
|
|
285
|
+
"type",
|
|
286
|
+
"description",
|
|
287
|
+
"helpMore",
|
|
288
|
+
"initialValue",
|
|
289
|
+
"validation",
|
|
290
|
+
"fieldset",
|
|
291
|
+
"group",
|
|
292
|
+
"hidden",
|
|
293
|
+
"readOnly",
|
|
294
|
+
"access",
|
|
295
|
+
"lockReason",
|
|
296
|
+
"advanced",
|
|
297
|
+
"localized",
|
|
298
|
+
"ai",
|
|
299
|
+
"placeholder"
|
|
300
|
+
]);
|
|
301
|
+
function shapeOf(f, lv, ctx, top) {
|
|
302
|
+
const props = ctx.lane === "props";
|
|
303
|
+
const deep = lv >= 10;
|
|
304
|
+
const of = Array.isArray(f.of) ? f.of : void 0;
|
|
305
|
+
/** a prop reference needs a content model to point at (refTargetNamed): with none it is stored as json */
|
|
306
|
+
const noEntry = (r) => props && !(r?.to ?? []).some(ENTRY_TARGET);
|
|
307
|
+
switch (f.type) {
|
|
308
|
+
case "object": return deep ? {
|
|
309
|
+
kind: "json",
|
|
310
|
+
type: "json",
|
|
311
|
+
feature: "depth>10"
|
|
312
|
+
} : {
|
|
313
|
+
kind: "object",
|
|
314
|
+
type: "object"
|
|
315
|
+
};
|
|
316
|
+
case "array": {
|
|
317
|
+
if (of && of.length > 1 && !props && of.every((i) => i.type === "object")) return {
|
|
318
|
+
kind: "modular",
|
|
319
|
+
type: "modular",
|
|
320
|
+
items: of
|
|
321
|
+
};
|
|
322
|
+
if (!of || of.length !== 1) return {
|
|
323
|
+
kind: "json",
|
|
324
|
+
type: "json",
|
|
325
|
+
feature: of ? "type:polymorphic-array" : "type:slot"
|
|
326
|
+
};
|
|
327
|
+
const item = of[0];
|
|
328
|
+
if (item.type === "object") return deep ? {
|
|
329
|
+
kind: "json",
|
|
330
|
+
type: "json",
|
|
331
|
+
feature: "depth>10"
|
|
332
|
+
} : {
|
|
333
|
+
kind: "zones",
|
|
334
|
+
type: props ? "table" : "array",
|
|
335
|
+
item
|
|
336
|
+
};
|
|
337
|
+
if (item.type === "reference") return noEntry(item.reference) ? {
|
|
338
|
+
kind: "json",
|
|
339
|
+
type: "json",
|
|
340
|
+
feature: "reference target"
|
|
341
|
+
} : {
|
|
342
|
+
kind: "refs",
|
|
343
|
+
type: "multi-reference",
|
|
344
|
+
item
|
|
345
|
+
};
|
|
346
|
+
const prim = PRIM_ITEM[item.type];
|
|
347
|
+
if (prim) return {
|
|
348
|
+
kind: "itemType",
|
|
349
|
+
type: "array",
|
|
350
|
+
item,
|
|
351
|
+
itemType: prim
|
|
352
|
+
};
|
|
353
|
+
return {
|
|
354
|
+
kind: "json",
|
|
355
|
+
type: "json",
|
|
356
|
+
feature: "type:primitive-array"
|
|
357
|
+
};
|
|
358
|
+
}
|
|
359
|
+
case "slot": return {
|
|
360
|
+
kind: "json",
|
|
361
|
+
type: "json",
|
|
362
|
+
feature: "type:slot"
|
|
363
|
+
};
|
|
364
|
+
case "table": return props ? {
|
|
365
|
+
kind: "leaf",
|
|
366
|
+
type: "table"
|
|
367
|
+
} : {
|
|
368
|
+
kind: "json",
|
|
369
|
+
type: "json",
|
|
370
|
+
feature: "type:table"
|
|
371
|
+
};
|
|
372
|
+
case "reference":
|
|
373
|
+
if (props && top && f.reference?.to?.length === 1 && f.reference.to[0] === "form" && !f.reference.filter) return {
|
|
374
|
+
kind: "leaf",
|
|
375
|
+
type: "form"
|
|
376
|
+
};
|
|
377
|
+
return noEntry(f.reference) ? {
|
|
378
|
+
kind: "json",
|
|
379
|
+
type: "json",
|
|
380
|
+
feature: "reference target"
|
|
381
|
+
} : {
|
|
382
|
+
kind: "leaf",
|
|
383
|
+
type: "reference"
|
|
384
|
+
};
|
|
385
|
+
default: {
|
|
386
|
+
const t = props ? PROP_TYPE[f.type] : FIELD_TYPE[f.type];
|
|
387
|
+
return t ? {
|
|
388
|
+
kind: "leaf",
|
|
389
|
+
type: t
|
|
390
|
+
} : {
|
|
391
|
+
kind: "json",
|
|
392
|
+
type: "json",
|
|
393
|
+
feature: "unsupported key"
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
var trunc = (ctx, at, s, max, feature) => {
|
|
399
|
+
if (s.length <= max) return s;
|
|
400
|
+
lose(ctx, at, feature);
|
|
401
|
+
return s.slice(0, max);
|
|
402
|
+
};
|
|
403
|
+
function convertField(f, at, lv, ctx, siblings, top, inTable = false) {
|
|
404
|
+
const props = ctx.lane === "props";
|
|
405
|
+
const shape = shapeOf(f, lv, ctx, top);
|
|
406
|
+
const node = {
|
|
407
|
+
key: f.name,
|
|
408
|
+
label: f.title,
|
|
409
|
+
type: shape.type,
|
|
410
|
+
config: {},
|
|
411
|
+
ui: {}
|
|
412
|
+
};
|
|
413
|
+
const twins = siblings.slice(0, Math.max(0, siblings.indexOf(f))).filter((s) => s.name === f.name).length;
|
|
414
|
+
if (twins) {
|
|
415
|
+
node.key = `${f.name}_${twins + 1}`;
|
|
416
|
+
lose(ctx, `${at}/name`, "duplicate name");
|
|
417
|
+
}
|
|
418
|
+
const nesting = shape.kind === "object" || shape.kind === "zones";
|
|
419
|
+
/** a list of items (objects, block models, scalars or entries): ui.itemLabel names one item */
|
|
420
|
+
const listy = shape.kind === "zones" || shape.kind === "modular" || shape.kind === "itemType" || shape.kind === "refs";
|
|
421
|
+
const looseConfig = props || !STRICT_CONFIG.has(shape.type);
|
|
422
|
+
if (shape.kind === "json") lose(ctx, `${at}/type`, shape.feature);
|
|
423
|
+
if (!props && f.type === "url") node.config.inputType = "url";
|
|
424
|
+
if (shape.type === "datetime" && !props) node.config.includeTime = true;
|
|
425
|
+
if (shape.kind === "leaf" && shape.type === "table") node.config.mode = "data";
|
|
426
|
+
if (listy) {
|
|
427
|
+
const label = f.itemNoun !== void 0 ? capitalize(f.itemNoun) : shape.kind === "zones" && shape.item.title !== conventionItem(f.name, f.title).title ? shape.item.title : void 0;
|
|
428
|
+
if (label !== void 0 && label.length <= 24) node.ui.itemLabel = label;
|
|
429
|
+
}
|
|
430
|
+
const devLock = f.access?.edit === "schema.manage" && !!f.lockReason;
|
|
431
|
+
for (const k of Object.keys(f)) {
|
|
432
|
+
if (f[k] === void 0) continue;
|
|
433
|
+
const p = `${at}/${k}`;
|
|
434
|
+
if (shape.kind === "json" && !COMMON_KEYS.has(k)) {
|
|
435
|
+
lose(ctx, p, shape.feature);
|
|
436
|
+
continue;
|
|
437
|
+
}
|
|
438
|
+
switch (k) {
|
|
439
|
+
case "name":
|
|
440
|
+
case "title":
|
|
441
|
+
case "type": break;
|
|
442
|
+
case "description":
|
|
443
|
+
node.helpText = trunc(ctx, p, f.description, props ? 200 : 500, "help>limit");
|
|
444
|
+
break;
|
|
445
|
+
case "helpMore":
|
|
446
|
+
node.helpMore = trunc(ctx, p, f.helpMore, HELP_MORE_MAX, "help>limit");
|
|
447
|
+
break;
|
|
448
|
+
case "placeholder":
|
|
449
|
+
if (props) node.placeholder = trunc(ctx, p, f.placeholder, 120, "help>limit");
|
|
450
|
+
else if (looseConfig) node.placeholder = f.placeholder;
|
|
451
|
+
else node.ui.placeholder = trunc(ctx, p, f.placeholder, 120, "help>limit");
|
|
452
|
+
break;
|
|
453
|
+
case "initialValue":
|
|
454
|
+
if (props && (shape.type === "reference" || shape.type === "multi-reference")) cat(ctx, p, "seeded instance");
|
|
455
|
+
else node.defaultValue = defaultToProd(f, shape, f.initialValue, p, ctx, lv, top);
|
|
456
|
+
break;
|
|
457
|
+
case "validation":
|
|
458
|
+
validationToProd(f, shape, node, p, ctx, inTable, top);
|
|
459
|
+
break;
|
|
460
|
+
case "options":
|
|
461
|
+
optionsToProd(f, shape, node, p, ctx);
|
|
462
|
+
break;
|
|
463
|
+
case "layout":
|
|
464
|
+
layoutToProd(f, shape, node, p, ctx);
|
|
465
|
+
break;
|
|
466
|
+
case "fields":
|
|
467
|
+
if (shape.kind === "object") node.children = f.fields.map((c, i) => convertField(c, `${p}/${i}`, lv + 1, ctx, f.fields, false));
|
|
468
|
+
else lose(ctx, p, "unsupported key");
|
|
469
|
+
break;
|
|
470
|
+
case "of":
|
|
471
|
+
ofToProd(f, shape, node, p, lv, ctx);
|
|
472
|
+
break;
|
|
473
|
+
case "openMode":
|
|
474
|
+
if (nesting) node.openMode = f.openMode;
|
|
475
|
+
else lose(ctx, p, "openMode");
|
|
476
|
+
break;
|
|
477
|
+
case "preview":
|
|
478
|
+
if (shape.kind === "object") node.ui.preview = previewToProd(f.preview, f.fields ?? [], p, ctx);
|
|
479
|
+
else lose(ctx, p, "unsupported key");
|
|
480
|
+
break;
|
|
481
|
+
case "fieldset":
|
|
482
|
+
case "group": break;
|
|
483
|
+
case "hidden":
|
|
484
|
+
if (typeof f.hidden === "boolean") node.ui.hidden = f.hidden;
|
|
485
|
+
else {
|
|
486
|
+
const showIf = conditionToShowIf(f.hidden, p, siblings, ctx, props && top);
|
|
487
|
+
if (showIf) node.showIf = showIf;
|
|
488
|
+
}
|
|
489
|
+
break;
|
|
490
|
+
case "readOnly":
|
|
491
|
+
if (f.readOnly === true && !devLock) node.readOnly = true;
|
|
492
|
+
else lose(ctx, p, "access");
|
|
493
|
+
break;
|
|
494
|
+
case "access": {
|
|
495
|
+
const access = {};
|
|
496
|
+
for (const [ak, av] of Object.entries(f.access)) {
|
|
497
|
+
if (av === void 0) continue;
|
|
498
|
+
if (ak === "view" && av === "schema.view") access.view = av;
|
|
499
|
+
else if (ak === "edit" && av === "schema.manage") access.edit = av;
|
|
500
|
+
else lose(ctx, `${p}/${ak}`, "access");
|
|
501
|
+
}
|
|
502
|
+
if (Object.keys(access).length) node.ui.access = access;
|
|
503
|
+
if (devLock) node.readOnly = "developer";
|
|
504
|
+
break;
|
|
505
|
+
}
|
|
506
|
+
case "lockReason":
|
|
507
|
+
node.lockReason = trunc(ctx, p, f.lockReason, 200, "help>limit");
|
|
508
|
+
break;
|
|
509
|
+
case "localized":
|
|
510
|
+
node.localized = f.localized;
|
|
511
|
+
break;
|
|
512
|
+
case "advanced":
|
|
513
|
+
node.advanced = f.advanced;
|
|
514
|
+
break;
|
|
515
|
+
case "ai":
|
|
516
|
+
cat(ctx, p, "ai");
|
|
517
|
+
break;
|
|
518
|
+
case "reference":
|
|
519
|
+
if (shape.kind === "leaf" && shape.type === "reference") referenceToConfig(f.reference, node, p, ctx);
|
|
520
|
+
else if (shape.type !== "form") lose(ctx, p, "unsupported key");
|
|
521
|
+
break;
|
|
522
|
+
case "numeric":
|
|
523
|
+
numericToProd(f, node, p, ctx);
|
|
524
|
+
break;
|
|
525
|
+
case "scale":
|
|
526
|
+
if (shape.type === "number") scaleToConfig(f.scale, node, p, ctx);
|
|
527
|
+
else lose(ctx, p, "unsupported key");
|
|
528
|
+
break;
|
|
529
|
+
case "icon": {
|
|
530
|
+
const dock = shape.kind === "object" || shape.kind === "modular" ? dockIconOf(f.icon) : void 0;
|
|
531
|
+
if (dock) node.ui.icon = dock;
|
|
532
|
+
else lose(ctx, p, "icon");
|
|
533
|
+
break;
|
|
534
|
+
}
|
|
535
|
+
case "rows":
|
|
536
|
+
if ((shape.type === "text" || shape.type === "longtext") && isWhole(f.rows, 1, 40)) node.ui.rows = f.rows;
|
|
537
|
+
else lose(ctx, p, "rows");
|
|
538
|
+
break;
|
|
539
|
+
case "synced": {
|
|
540
|
+
const from = f.synced.from;
|
|
541
|
+
if (typeof from === "string" && from === from.trim() && from.length >= 1 && from.length <= 64 && Object.keys(f.synced).every((x) => x === "from")) node.ui.synced = { from };
|
|
542
|
+
else lose(ctx, p, "synced");
|
|
543
|
+
break;
|
|
544
|
+
}
|
|
545
|
+
case "slotSettings":
|
|
546
|
+
lose(ctx, p, "slotSettings");
|
|
547
|
+
break;
|
|
548
|
+
case "itemNoun":
|
|
549
|
+
if (!listy || node.ui.itemLabel?.toLowerCase() !== f.itemNoun) lose(ctx, p, "itemNoun");
|
|
550
|
+
break;
|
|
551
|
+
case "arrayLayout":
|
|
552
|
+
if (shape.kind === "zones" || shape.kind === "modular") node.ui.layout = f.arrayLayout;
|
|
553
|
+
else if ((shape.kind === "itemType" || shape.kind === "refs") && f.arrayLayout === "grid") node.ui.layout = "gallery";
|
|
554
|
+
else lose(ctx, p, "layout");
|
|
555
|
+
break;
|
|
556
|
+
case "valueShape":
|
|
557
|
+
if (shape.type === "link" || shape.type === "image" || shape.type === "button") node.ui.valueShape = f.valueShape;
|
|
558
|
+
else lose(ctx, p, "valueShape");
|
|
559
|
+
break;
|
|
560
|
+
case "timezone":
|
|
561
|
+
if (shape.type === "date" || shape.type === "datetime") {
|
|
562
|
+
const tz = f.timezone;
|
|
563
|
+
const zone = typeof tz === "boolean" || tz === "site" ? tz : typeof tz === "string" && tz.startsWith("fixed:") && isZone(tz.slice(6)) ? tz.slice(6) : void 0;
|
|
564
|
+
if (zone !== void 0) node.config.timezone = zone;
|
|
565
|
+
else lose(ctx, p, "timezone");
|
|
566
|
+
} else lose(ctx, p, "unsupported key");
|
|
567
|
+
break;
|
|
568
|
+
case "language":
|
|
569
|
+
if (shape.type === "code" && typeof f.language === "string") node.config.language = f.language;
|
|
570
|
+
else lose(ctx, p, "unsupported key");
|
|
571
|
+
break;
|
|
572
|
+
case "languages":
|
|
573
|
+
if (shape.type === "code" && Array.isArray(f.languages) && f.languages.every((l) => typeof l === "string")) node.config.languages = [...f.languages];
|
|
574
|
+
else lose(ctx, p, "unsupported key");
|
|
575
|
+
break;
|
|
576
|
+
case "table":
|
|
577
|
+
if (shape.kind === "leaf" && shape.type === "table") Object.assign(node.config, tableConfigFromOptions(f.table));
|
|
578
|
+
else lose(ctx, p, "type:table");
|
|
579
|
+
break;
|
|
580
|
+
default: lose(ctx, p, "unsupported key");
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
if (f.itemNoun === void 0 && shape.kind === "zones" && node.ui.itemLabel !== void 0) cat(ctx, `${at}/itemNoun`, "itemNoun (derived)");
|
|
584
|
+
placeInSet(f, node, at, ctx, top, siblings);
|
|
585
|
+
if (node.ui.control === "slider" && !sliderOk(node.config)) {
|
|
586
|
+
delete node.ui.control;
|
|
587
|
+
lose(ctx, `${at}/layout`, "layout");
|
|
588
|
+
}
|
|
589
|
+
return node;
|
|
590
|
+
}
|
|
591
|
+
var isWhole = (n, lo = 0, hi = Infinity) => typeof n === "number" && Number.isInteger(n) && n >= lo && n <= hi;
|
|
592
|
+
var compiles = (re) => {
|
|
593
|
+
try {
|
|
594
|
+
new RegExp(re);
|
|
595
|
+
return true;
|
|
596
|
+
} catch {
|
|
597
|
+
return false;
|
|
598
|
+
}
|
|
599
|
+
};
|
|
600
|
+
var ratingIsDefault = (c) => c.min === RATING_CONFIG.min && c.max === RATING_CONFIG.max && c.step === RATING_CONFIG.step;
|
|
601
|
+
/** Backend controlHardening: a slider spans min < max; a set step is > 0 with at most SLIDER_MAX_STOPS stops. */
|
|
602
|
+
function sliderOk({ min, max, step }) {
|
|
603
|
+
if (!(typeof min === "number" && typeof max === "number" && min < max)) return false;
|
|
604
|
+
return step === void 0 || typeof step === "number" && step > 0 && (max - min) / step <= SLIDER_MAX_STOPS;
|
|
605
|
+
}
|
|
606
|
+
/** Where a field sits: its tab (fields lane) or prop group (props lane). */
|
|
607
|
+
function placeInSet(f, node, at, ctx, top, siblings) {
|
|
608
|
+
if (ctx.lane === "props") {
|
|
609
|
+
if (f.group !== void 0) lose(ctx, `${at}/group`, "group (props)");
|
|
610
|
+
if (f.fieldset === void 0) return;
|
|
611
|
+
const set = ctx.propSets.get(f.fieldset);
|
|
612
|
+
if (!set) return lose(ctx, `${at}/fieldset`, "fieldset collision");
|
|
613
|
+
let defined = ctx.definedGroups.get(siblings);
|
|
614
|
+
if (!defined) ctx.definedGroups.set(siblings, defined = /* @__PURE__ */ new Set());
|
|
615
|
+
if (defined.has(set.name)) node.ui.group = { id: set.name };
|
|
616
|
+
else {
|
|
617
|
+
defined.add(set.name);
|
|
618
|
+
node.ui.group = propGroupOf(set, ctx);
|
|
619
|
+
}
|
|
620
|
+
return;
|
|
621
|
+
}
|
|
622
|
+
const set = f.fieldset !== void 0 && ctx.sets.has(f.fieldset) ? f.fieldset : void 0;
|
|
623
|
+
if (f.fieldset !== void 0 && !set) lose(ctx, `${at}/fieldset`, "fieldset collision");
|
|
624
|
+
if (!top) {
|
|
625
|
+
if (f.group !== void 0) lose(ctx, `${at}/group`, "group (nested)");
|
|
626
|
+
if (set) node.fieldsetId = set;
|
|
627
|
+
return;
|
|
628
|
+
}
|
|
629
|
+
const tab = set ? ctx.sets.get(set) : void 0;
|
|
630
|
+
if (f.group !== void 0 && !ctx.tabs.has(f.group)) lose(ctx, `${at}/group`, ctx.droppedTabs.get(f.group) ?? "unsupported key");
|
|
631
|
+
else if (set && tab !== f.group) lose(ctx, `${at}/group`, "fieldset spans groups");
|
|
632
|
+
node.fieldsetId = set ?? (f.group !== void 0 && ctx.tabs.has(f.group) ? f.group : void 0);
|
|
633
|
+
}
|
|
634
|
+
/** A V2 fieldset as the inline prop group its first member defines (what propSetsFor found unstorable is named there). */
|
|
635
|
+
function propGroupOf(s, ctx) {
|
|
636
|
+
const g = {
|
|
637
|
+
id: s.name,
|
|
638
|
+
label: s.title.slice(0, 32),
|
|
639
|
+
kind: "group"
|
|
640
|
+
};
|
|
641
|
+
if (s.collapsed !== void 0) g.collapsed = s.collapsed;
|
|
642
|
+
if (groupDescriptionOk(s.description)) g.description = s.description;
|
|
643
|
+
if (s.columns !== void 0) g.columns = s.columns;
|
|
644
|
+
if (s.collapsible !== void 0) g.collapsible = s.collapsible;
|
|
645
|
+
if (s.layout !== void 0) g.layout = s.layout;
|
|
646
|
+
if (ctx.groupOrder) g.order = Math.min(99, ctx.propOrder.get(s.name) ?? 0);
|
|
647
|
+
return g;
|
|
648
|
+
}
|
|
649
|
+
var groupDescriptionOk = (d) => typeof d === "string" && d === d.trim() && d.length >= 1 && d.length <= 200;
|
|
650
|
+
/** The zone a datetime field fixes, if any (what lets a stored instant read back with its [Zone]). */
|
|
651
|
+
var fixedZone = (f) => typeof f.timezone === "string" && f.timezone.startsWith("fixed:") ? f.timezone.slice(6) : void 0;
|
|
652
|
+
/**
|
|
653
|
+
* A field default: forward through the value adapters, then read back the way toTypeSchema will; every leaf that does
|
|
654
|
+
* not come back is named (so the lossy list matches what the read side really returns). Objects and list rows go
|
|
655
|
+
* through their child fields' adapters too.
|
|
656
|
+
*/
|
|
657
|
+
function defaultToProd(f, shape, v, at, ctx, lv, top) {
|
|
658
|
+
const plan = writePlan(f, shape, lv, ctx, top);
|
|
659
|
+
const out = planToProd(plan, v);
|
|
660
|
+
for (const d of diffPaths(v, planFromProd(plan, out))) lose(ctx, `${at}${d}`, "default value");
|
|
661
|
+
return out;
|
|
662
|
+
}
|
|
663
|
+
var AS_IS = { k: "as-is" };
|
|
664
|
+
/** The write side's plan, from the V2 field and the shape it is stored as. */
|
|
665
|
+
function writePlan(f, shape, lv, ctx, top) {
|
|
666
|
+
const kids = (fields) => new Map(fields.map((c) => [c.name, writePlan(c, shapeOf(c, lv + 1, ctx, false), lv + 1, ctx, false)]));
|
|
667
|
+
switch (shape.kind) {
|
|
668
|
+
case "json": return AS_IS;
|
|
669
|
+
case "itemType": return shape.itemType === "image" || shape.itemType === "link" ? {
|
|
670
|
+
k: "list",
|
|
671
|
+
item: shape.itemType
|
|
672
|
+
} : AS_IS;
|
|
673
|
+
case "object": return {
|
|
674
|
+
k: "object",
|
|
675
|
+
fields: kids(f.fields ?? [])
|
|
676
|
+
};
|
|
677
|
+
case "zones": return {
|
|
678
|
+
k: "rows",
|
|
679
|
+
zoned: ctx.lane === "fields",
|
|
680
|
+
fields: kids(shape.item.fields ?? [])
|
|
681
|
+
};
|
|
682
|
+
case "modular": {
|
|
683
|
+
const top1 = (fields) => new Map(fields.map((c) => [c.name, writePlan(c, shapeOf(c, 1, ctx, false), 1, ctx, false)]));
|
|
684
|
+
return {
|
|
685
|
+
k: "modular",
|
|
686
|
+
types: new Map(shape.items.map((i) => [i.name, top1(i.fields ?? [])]))
|
|
687
|
+
};
|
|
688
|
+
}
|
|
689
|
+
case "refs": return { k: "refs" };
|
|
690
|
+
case "leaf":
|
|
691
|
+
if (f.type === "link" || f.type === "url") return { k: "link" };
|
|
692
|
+
if (f.type === "button" || f.type === "image") return { k: f.type };
|
|
693
|
+
if (f.type === "datetime") return {
|
|
694
|
+
k: "datetime",
|
|
695
|
+
zone: fixedZone(f)
|
|
696
|
+
};
|
|
697
|
+
if (f.type === "reference") return { k: top && shape.type === "form" ? "form" : "ref" };
|
|
698
|
+
return leafPlan(f, shape.type);
|
|
699
|
+
}
|
|
700
|
+
}
|
|
701
|
+
/** The plan of a leaf whose value needs its own adapter but no link / reference handling (both directions agree). */
|
|
702
|
+
function leafPlan(f, prodType) {
|
|
703
|
+
if (f.type === "video") return { k: "video" };
|
|
704
|
+
if (f.type === "rating") return {
|
|
705
|
+
k: "rating",
|
|
706
|
+
scale: {
|
|
707
|
+
min: f.numeric?.min,
|
|
708
|
+
max: f.numeric?.max,
|
|
709
|
+
step: f.numeric?.step
|
|
710
|
+
}
|
|
711
|
+
};
|
|
712
|
+
if (f.type === "number" && f.scale) return {
|
|
713
|
+
k: "scale",
|
|
714
|
+
scale: f.scale
|
|
715
|
+
};
|
|
716
|
+
return prodType === "number" ? { k: "number" } : AS_IS;
|
|
717
|
+
}
|
|
718
|
+
/**
|
|
719
|
+
* The read side's plan, from the V2 field read back (`zoned`: lists read from an array's repeatable zone; `modular`:
|
|
720
|
+
* lists read from a modular field, whose item fields live in their block models and pass as stored).
|
|
721
|
+
*/
|
|
722
|
+
function readPlan(f, prodType, zoned, modular) {
|
|
723
|
+
const kids = (fields) => new Map(fields.map((c) => [c.name, readPlan(c, "", zoned, modular)]));
|
|
724
|
+
switch (f.type) {
|
|
725
|
+
case "link":
|
|
726
|
+
case "url": return { k: "link" };
|
|
727
|
+
case "button":
|
|
728
|
+
case "image": return { k: f.type };
|
|
729
|
+
case "datetime": return {
|
|
730
|
+
k: "datetime",
|
|
731
|
+
zone: fixedZone(f)
|
|
732
|
+
};
|
|
733
|
+
case "date": return { k: "date" };
|
|
734
|
+
case "reference": return { k: prodType === "form" ? "form" : "ref" };
|
|
735
|
+
case "object": return {
|
|
736
|
+
k: "object",
|
|
737
|
+
fields: kids(f.fields ?? [])
|
|
738
|
+
};
|
|
739
|
+
case "array": {
|
|
740
|
+
if (modular.has(f)) return {
|
|
741
|
+
k: "modular",
|
|
742
|
+
types: new Map((Array.isArray(f.of) ? f.of : []).map((i) => [i.name, kids(i.fields ?? [])]))
|
|
743
|
+
};
|
|
744
|
+
const item = Array.isArray(f.of) && f.of.length === 1 ? f.of[0] : void 0;
|
|
745
|
+
if (item?.type === "object") return {
|
|
746
|
+
k: "rows",
|
|
747
|
+
zoned: zoned.has(f),
|
|
748
|
+
fields: kids(item.fields ?? [])
|
|
749
|
+
};
|
|
750
|
+
if (item?.type === "image" || item?.type === "link") return {
|
|
751
|
+
k: "list",
|
|
752
|
+
item: item.type
|
|
753
|
+
};
|
|
754
|
+
return item?.type === "reference" ? { k: "refs" } : AS_IS;
|
|
755
|
+
}
|
|
756
|
+
default: return leafPlan(f, prodType);
|
|
757
|
+
}
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* The plan for ONE leaf field read from prod type `prodType` (a link, an image, a reference…), for a host that edits a
|
|
761
|
+
* single field's value outside a whole read (the dock's legacy controls). Objects and lists need the read's own plan
|
|
762
|
+
* (`ToTypeSchemaOptions.plans`), which knows which lists are zoned or modular.
|
|
763
|
+
*/
|
|
764
|
+
function leafValuePlan(f, prodType) {
|
|
765
|
+
return readPlan(f, prodType, /* @__PURE__ */ new WeakSet(), /* @__PURE__ */ new WeakSet());
|
|
766
|
+
}
|
|
767
|
+
/**
|
|
768
|
+
* A V2 value → what prod stores. `lost` (optional) collects every V2 key prod cannot keep, as a path under the value
|
|
769
|
+
* ("cta/style", "(value)" for the value itself): a caller that finds any must refuse the write and name them.
|
|
770
|
+
*/
|
|
771
|
+
function planToProd(plan, v, lost, at = "") {
|
|
772
|
+
if (v === void 0) return void 0;
|
|
773
|
+
const take = (r) => {
|
|
774
|
+
if (lost) for (const l of r.lost) lost.push(at ? `${at}/${l}` : l);
|
|
775
|
+
return r.value;
|
|
776
|
+
};
|
|
777
|
+
const under = (k) => at ? `${at}/${k}` : String(k);
|
|
778
|
+
switch (plan.k) {
|
|
779
|
+
case "link": return take(linkToProd(v));
|
|
780
|
+
case "button": return take(buttonToProd(v));
|
|
781
|
+
case "image": return take(imageToProd(v));
|
|
782
|
+
case "datetime": return take(datetimeToProd(v, { zone: plan.zone }));
|
|
783
|
+
case "form": return take(referenceToProd(v, { to: "form" }));
|
|
784
|
+
case "ref":
|
|
785
|
+
case "refs": return take(referenceToProd(v));
|
|
786
|
+
case "number":
|
|
787
|
+
if (typeof v === "number" || v === null) return v;
|
|
788
|
+
lost?.push(at || "(value)");
|
|
789
|
+
return;
|
|
790
|
+
case "video": return take(videoToProd(v));
|
|
791
|
+
case "list": return take(listToProd(v, plan.item));
|
|
792
|
+
case "scale": return take(scaleToProd(v, plan.scale));
|
|
793
|
+
case "rating": return take(ratingToProd(v, plan.scale));
|
|
794
|
+
case "object": return mapKeys(v, plan.fields, (p, x, k) => planToProd(p, x, lost, under(k)));
|
|
795
|
+
case "rows": {
|
|
796
|
+
if (!Array.isArray(v)) return v;
|
|
797
|
+
const rows = v.map((row, i) => mapKeys(row, plan.fields, (p, x, k) => planToProd(p, x, lost, `${under(i)}/${k}`)));
|
|
798
|
+
return plan.zoned ? zoneListToProd(rows) : rows;
|
|
799
|
+
}
|
|
800
|
+
case "modular":
|
|
801
|
+
if (!Array.isArray(v)) return v;
|
|
802
|
+
return v.map((row, i) => {
|
|
803
|
+
if (!isObj(row) || typeof row._type !== "string") return row;
|
|
804
|
+
const { _key, _type, ...rest } = row;
|
|
805
|
+
const fields = plan.types.get(_type);
|
|
806
|
+
return {
|
|
807
|
+
__id: typeof _key === "string" && _key ? _key : `${kebab(_type)}-${i + 1}`,
|
|
808
|
+
__type: kebab(_type),
|
|
809
|
+
data: fields ? mapKeys(rest, fields, (p, x, k) => planToProd(p, x, lost, `${under(i)}/${k}`)) : rest
|
|
810
|
+
};
|
|
811
|
+
});
|
|
812
|
+
default: return v;
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
/** The keys the kit reads back from a stored image object (imageFromProd) and writes again (imageToProd). */
|
|
816
|
+
var IMAGE_KIT_KEYS = new Set([
|
|
817
|
+
"url",
|
|
818
|
+
"id",
|
|
819
|
+
"name",
|
|
820
|
+
"altText",
|
|
821
|
+
"focal"
|
|
822
|
+
]);
|
|
823
|
+
/** Every key of a stored image the kit cannot hand back: a crop (read back only with the asset's pixel size) or a key it does not model. */
|
|
824
|
+
function imageStoredLoss(v, rel, loss) {
|
|
825
|
+
if (!isObj(v)) return;
|
|
826
|
+
for (const [k, x] of Object.entries(v)) {
|
|
827
|
+
if (IMAGE_KIT_KEYS.has(k) || x === void 0) continue;
|
|
828
|
+
if (k === "crop") {
|
|
829
|
+
if (x != null) loss(`${rel}/crop`, "A saved crop is not read back by the kit; editing the image would drop it.");
|
|
830
|
+
} else loss(`${rel}/${k}`, `The image's saved "${k}" is not kept by the kit; editing the image would drop it.`);
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
var datedLossReason = (v) => isObj(v) && ("date" in v || "time" in v || "timezone" in v) ? "A stored date-time in the older {date,time,timezone} form; the kit can't read it, so editing it would replace it." : "A stored date/time that is not an ISO string can't be read by the kit; editing it would replace it.";
|
|
834
|
+
/** A stored prod value → the V2 value. `loss(rel, reason)`: what the prod value carries that the V2 value cannot (rel is
|
|
835
|
+
* under the value, "/0/modelSlug"); a caller that hears any must not write the value back through V2. */
|
|
836
|
+
function planFromProd(plan, v, loss, rel = "") {
|
|
837
|
+
if (v === void 0) return void 0;
|
|
838
|
+
switch (plan.k) {
|
|
839
|
+
case "link": return linkFromProd(v);
|
|
840
|
+
case "button": return buttonFromProd(v);
|
|
841
|
+
case "image":
|
|
842
|
+
if (loss) imageStoredLoss(v, rel, loss);
|
|
843
|
+
return imageFromProd(v);
|
|
844
|
+
case "datetime":
|
|
845
|
+
case "date":
|
|
846
|
+
if (loss && v !== null && typeof v !== "string") loss(rel || "(value)", datedLossReason(v));
|
|
847
|
+
return plan.k === "date" ? v : datetimeFromProd(v, { zone: plan.zone });
|
|
848
|
+
case "video": return videoFromProd(v);
|
|
849
|
+
case "list":
|
|
850
|
+
if (loss && plan.item === "image" && Array.isArray(v)) v.forEach((x, i) => imageStoredLoss(x, `${rel}/${i}`, loss));
|
|
851
|
+
return listFromProd(v, plan.item);
|
|
852
|
+
case "scale": return scaleFromProd(v);
|
|
853
|
+
case "rating": return ratingFromProd(v, plan.scale);
|
|
854
|
+
case "form": return referenceFromProd(v);
|
|
855
|
+
case "ref":
|
|
856
|
+
case "refs":
|
|
857
|
+
if (loss) {
|
|
858
|
+
for (const [i, x] of (Array.isArray(v) ? v : [v]).entries()) if (isObj(x) && x.modelSlug !== void 0) loss(`${rel}${Array.isArray(v) ? `/${i}` : ""}/modelSlug`, "A V2 reference stores the target id; the polymorphic modelSlug is dropped.");
|
|
859
|
+
else if (isObj(x) && referenceFromProd(x) === null) loss(`${rel}${Array.isArray(v) ? `/${i}` : ""}` || "(value)", "A stored reference the kit can't read; editing it would drop it.");
|
|
860
|
+
}
|
|
861
|
+
return referenceFromProd(v);
|
|
862
|
+
case "object": return mapKeys(v, plan.fields, (p, x, k) => planFromProd(p, x, loss, `${rel}/${k}`));
|
|
863
|
+
case "rows": {
|
|
864
|
+
const rows = plan.zoned ? zoneListFromProd(v) : v;
|
|
865
|
+
return Array.isArray(rows) ? rows.map((row, i) => mapKeys(row, plan.fields, (p, x, k) => planFromProd(p, x, loss, `${rel}/${i}/${k}`))) : rows;
|
|
866
|
+
}
|
|
867
|
+
case "modular": return Array.isArray(v) ? v.map((row, i) => {
|
|
868
|
+
if (!isObj(row) || typeof row.__type !== "string") return row;
|
|
869
|
+
const data = isObj(row.data) ? row.data : {};
|
|
870
|
+
const fields = plan.types.get(camel(row.__type));
|
|
871
|
+
const back = fields ? mapKeys(data, fields, (p, x, k) => planFromProd(p, x, loss, `${rel}/${i}/${k}`)) : data;
|
|
872
|
+
return {
|
|
873
|
+
_key: row.__id,
|
|
874
|
+
_type: camel(row.__type),
|
|
875
|
+
...back
|
|
876
|
+
};
|
|
877
|
+
}) : v;
|
|
878
|
+
default: return v;
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
/** Each key of an object value through its child field's plan; keys with no field ride along as they are. */
|
|
882
|
+
function mapKeys(v, fields, fn) {
|
|
883
|
+
if (!isObj(v)) return v;
|
|
884
|
+
const out = {};
|
|
885
|
+
for (const [k, x] of Object.entries(v)) {
|
|
886
|
+
const plan = fields.get(k);
|
|
887
|
+
const y = plan ? fn(plan, x, k) : x;
|
|
888
|
+
if (y !== void 0) out[k] = y;
|
|
889
|
+
}
|
|
890
|
+
return out;
|
|
891
|
+
}
|
|
892
|
+
/** Every leaf (a JSON pointer under the value, "" for the value itself) where `a` and `b` differ; undefined = absent. */
|
|
893
|
+
function diffPaths(a, b, path = "", out = []) {
|
|
894
|
+
if (deepEqual(a, b)) return out;
|
|
895
|
+
if ((isObj(a) || a === void 0) && (isObj(b) || b === void 0) && (a !== void 0 || b !== void 0)) {
|
|
896
|
+
const A = a ?? {};
|
|
897
|
+
const B = b ?? {};
|
|
898
|
+
for (const k of new Set([...Object.keys(A), ...Object.keys(B)])) diffPaths(A[k], B[k], `${path}/${k}`, out);
|
|
899
|
+
} else if (Array.isArray(a) && Array.isArray(b)) for (let i = 0; i < Math.max(a.length, b.length); i++) diffPaths(a[i], b[i], `${path}/${i}`, out);
|
|
900
|
+
else out.push(path);
|
|
901
|
+
return out;
|
|
902
|
+
}
|
|
903
|
+
function validationToProd(f, shape, node, at, ctx, inTable, top) {
|
|
904
|
+
const props = ctx.lane === "props";
|
|
905
|
+
const val = f.validation;
|
|
906
|
+
const t = shape.type;
|
|
907
|
+
const leaf = shape.kind === "leaf";
|
|
908
|
+
const lengthy = leaf && (props ? LENGTH_PROPS : LENGTH_FIELDS).has(t);
|
|
909
|
+
const patternOk = leaf && (props ? PATTERN_TYPES : LENGTH_FIELDS).has(t) && t !== "richtext" && t !== "document" && typeof val.pattern === "string" && val.pattern.length <= 200 && compiles(val.pattern);
|
|
910
|
+
/** the pair each key bounds, so a min over its max is named rather than refused at save */
|
|
911
|
+
const pairs = [];
|
|
912
|
+
const set = (key, n, feature, lo, hi) => {
|
|
913
|
+
node.config[key] = n;
|
|
914
|
+
if (!pairs.some((x) => x[0] === lo)) pairs.push([
|
|
915
|
+
lo,
|
|
916
|
+
hi,
|
|
917
|
+
`${at}/min`,
|
|
918
|
+
`${at}/max`,
|
|
919
|
+
feature
|
|
920
|
+
]);
|
|
921
|
+
};
|
|
922
|
+
for (const k of Object.keys(val)) {
|
|
923
|
+
const v = val[k];
|
|
924
|
+
if (v === void 0) continue;
|
|
925
|
+
const p = `${at}/${k}`;
|
|
926
|
+
if (shape.kind === "json" && k !== "required" && k !== "recommendedMax") {
|
|
927
|
+
lose(ctx, p, shape.feature);
|
|
928
|
+
continue;
|
|
929
|
+
}
|
|
930
|
+
switch (k) {
|
|
931
|
+
case "required":
|
|
932
|
+
node.required = val.required;
|
|
933
|
+
break;
|
|
934
|
+
case "min":
|
|
935
|
+
case "max": {
|
|
936
|
+
const n = v;
|
|
937
|
+
const lo = k === "min";
|
|
938
|
+
if (lengthy) if (isWhole(n)) set(lo ? "minLength" : "maxLength", n, "validation.length", "minLength", "maxLength");
|
|
939
|
+
else lose(ctx, p, "validation.length");
|
|
940
|
+
else if (t === "number") {
|
|
941
|
+
const b = node.config.validation ??= {};
|
|
942
|
+
b[k] = n;
|
|
943
|
+
} else if (t === "rating") lose(ctx, p, "rating bounds");
|
|
944
|
+
else if (shape.kind === "zones" || shape.kind === "modular" || shape.kind === "itemType") if (props && top ? isWhole(n, lo ? 0 : 1, SLOT_ITEMS_CAP) : isWhole(n)) set(lo ? "minItems" : "maxItems", n, "validation.items", "minItems", "maxItems");
|
|
945
|
+
else lose(ctx, p, "validation.items");
|
|
946
|
+
else if (shape.kind === "refs" || t === "multiselect" || t === "tags") if (t === "tags" ? isWhole(n, lo ? 0 : 1, 500) : isWhole(n)) set(k, n, "validation.items", "min", "max");
|
|
947
|
+
else lose(ctx, p, "validation.items");
|
|
948
|
+
else lose(ctx, p, "validation.length");
|
|
949
|
+
break;
|
|
950
|
+
}
|
|
951
|
+
case "recommendedMax":
|
|
952
|
+
if (isWhole(v, 1)) node.recommendedMax = v;
|
|
953
|
+
else lose(ctx, p, "validation.recommendedMax");
|
|
954
|
+
break;
|
|
955
|
+
case "pattern":
|
|
956
|
+
if (patternOk) node.config.pattern = v;
|
|
957
|
+
else lose(ctx, p, "validation.pattern");
|
|
958
|
+
break;
|
|
959
|
+
case "patternMessage":
|
|
960
|
+
if (patternOk && typeof v === "string" && v.trim() !== "" && v.length <= 200) node.config.patternMessage = v;
|
|
961
|
+
else lose(ctx, p, "validation.patternMessage");
|
|
962
|
+
break;
|
|
963
|
+
case "unique":
|
|
964
|
+
if (val.unique === false) node.unique = false;
|
|
965
|
+
else if (props) if (UNIQUE_LIST_PROPS.has(t) || inTable && UNIQUE_ROW_PROPS.has(t)) node.unique = true;
|
|
966
|
+
else cat(ctx, p, "not applicable (props)");
|
|
967
|
+
else {
|
|
968
|
+
const polymorphic = t === "reference" && (f.reference?.to ?? []).filter(ENTRY_TARGET).length > 1;
|
|
969
|
+
if (UNIQUE_TYPES.has(t) && !polymorphic) node.unique = true;
|
|
970
|
+
else lose(ctx, p, "validation.unique");
|
|
971
|
+
}
|
|
972
|
+
break;
|
|
973
|
+
default: lose(ctx, p, "unsupported key");
|
|
974
|
+
}
|
|
975
|
+
}
|
|
976
|
+
const b = node.config.validation;
|
|
977
|
+
if (b && b.min !== void 0 && b.max !== void 0 && b.min > b.max) {
|
|
978
|
+
delete node.config.validation;
|
|
979
|
+
lose(ctx, `${at}/min`, "validation.items");
|
|
980
|
+
lose(ctx, `${at}/max`, "validation.items");
|
|
981
|
+
}
|
|
982
|
+
for (const [lo, hi, pLo, pHi, feature] of pairs) {
|
|
983
|
+
const a = node.config[lo];
|
|
984
|
+
const z = node.config[hi];
|
|
985
|
+
if (typeof a === "number" && typeof z === "number" && a > z) {
|
|
986
|
+
delete node.config[lo];
|
|
987
|
+
delete node.config[hi];
|
|
988
|
+
lose(ctx, pLo, feature);
|
|
989
|
+
lose(ctx, pHi, feature);
|
|
990
|
+
}
|
|
991
|
+
}
|
|
992
|
+
}
|
|
993
|
+
function optionsToProd(f, shape, node, at, ctx) {
|
|
994
|
+
if (shape.type !== "select" && shape.type !== "multiselect" && shape.type !== "tags") return lose(ctx, at, "unsupported key");
|
|
995
|
+
const opts = f.options;
|
|
996
|
+
const icons = opts.map((o) => o.icon === void 0 ? void 0 : dockIconOf(o.icon));
|
|
997
|
+
const allIcons = opts.every((o, i) => o.icon === void 0 || icons[i] !== void 0);
|
|
998
|
+
node.options = opts.map((o, i) => {
|
|
999
|
+
const out = {
|
|
1000
|
+
label: o.label,
|
|
1001
|
+
value: o.value
|
|
1002
|
+
};
|
|
1003
|
+
if (o.icon !== void 0) if (allIcons) out.icon = icons[i];
|
|
1004
|
+
else lose(ctx, `${at}/${i}/icon`, "option icon");
|
|
1005
|
+
const d = o.description;
|
|
1006
|
+
if (d !== void 0) if (typeof d === "string" && d.trim() !== "" && !/[\r\n]/.test(d) && d.length <= 140) out.description = d;
|
|
1007
|
+
else lose(ctx, `${at}/${i}/description`, "option description");
|
|
1008
|
+
for (const k of Object.keys(o)) if (![
|
|
1009
|
+
"value",
|
|
1010
|
+
"label",
|
|
1011
|
+
"icon",
|
|
1012
|
+
"description"
|
|
1013
|
+
].includes(k)) lose(ctx, `${at}/${i}/${k}`, "unsupported key");
|
|
1014
|
+
return out;
|
|
1015
|
+
});
|
|
1016
|
+
}
|
|
1017
|
+
/** V2 layouts → prod ui.control (a leaf's control) or ui.layout (a list's rows); dock-vocabulary.ts controlHardening rules. */
|
|
1018
|
+
function layoutToProd(f, shape, node, at, ctx) {
|
|
1019
|
+
const l = f.layout;
|
|
1020
|
+
const t = shape.type;
|
|
1021
|
+
const n = f.options?.length ?? 0;
|
|
1022
|
+
if (l === "segmented" && t === "select") if (n >= 2 && n <= 4) node.ui.control = "segmented";
|
|
1023
|
+
else if (n >= 5) {
|
|
1024
|
+
node.ui.control = n <= 6 ? "radio" : "dropdown";
|
|
1025
|
+
lose(ctx, at, "segmented>4");
|
|
1026
|
+
} else lose(ctx, at, "layout");
|
|
1027
|
+
else if (l === "slider" && t === "number" && f.type === "number") node.ui.control = "slider";
|
|
1028
|
+
else if (UI_CONTROLS.includes(l) && l !== "segmented" && l !== "slider" && CONTROL_TYPES[l]?.includes(t)) node.ui.control = l;
|
|
1029
|
+
else if (l === "list" && (shape.kind === "zones" || shape.kind === "itemType" || shape.kind === "modular" || shape.kind === "refs") && f.arrayLayout === void 0) node.ui.layout = "rows";
|
|
1030
|
+
else lose(ctx, at, "layout");
|
|
1031
|
+
}
|
|
1032
|
+
/** The prod type a V2 field is stored as, for a preview path reading into it (no loss is reported). */
|
|
1033
|
+
function storedType(f, ctx) {
|
|
1034
|
+
return shapeOf(f, 1, {
|
|
1035
|
+
...ctx,
|
|
1036
|
+
lossy: [],
|
|
1037
|
+
catalog: []
|
|
1038
|
+
}, false).type;
|
|
1039
|
+
}
|
|
1040
|
+
/** The V2 fields a preview path segment may name below `f` (an object's fields, a list's item fields), or null for a leaf. */
|
|
1041
|
+
function previewKids(f) {
|
|
1042
|
+
if (f.type === "object") return f.fields ?? [];
|
|
1043
|
+
if (f.type === "array" && Array.isArray(f.of) && f.of.length === 1 && f.of[0].type === "object") return f.of[0].fields ?? [];
|
|
1044
|
+
return null;
|
|
1045
|
+
}
|
|
1046
|
+
/**
|
|
1047
|
+
* A V2 preview path → the path prod stores (previewPathProblem): the first segment a child, each later one a child of the
|
|
1048
|
+
* node before it, or a key of an object-valued leaf (`image.alt` is stored `image.altText`). undefined: no prod form.
|
|
1049
|
+
*/
|
|
1050
|
+
function previewPathToProd(path, children, ctx) {
|
|
1051
|
+
const segs = path.split(".");
|
|
1052
|
+
let node = children.find((c) => c.name === segs[0]);
|
|
1053
|
+
if (!node) return void 0;
|
|
1054
|
+
const out = [segs[0]];
|
|
1055
|
+
for (let i = 1; i < segs.length; i++) {
|
|
1056
|
+
const kids = previewKids(node);
|
|
1057
|
+
if (kids) {
|
|
1058
|
+
const next = kids.find((c) => c.name === segs[i]);
|
|
1059
|
+
if (!next) return void 0;
|
|
1060
|
+
out.push(segs[i]);
|
|
1061
|
+
node = next;
|
|
1062
|
+
continue;
|
|
1063
|
+
}
|
|
1064
|
+
const type = storedType(node, ctx);
|
|
1065
|
+
if (!OBJECT_VALUE_TYPES.has(type)) return void 0;
|
|
1066
|
+
const key = type === "image" ? IMAGE_PATH_KEY[segs[i]] ?? segs[i] : segs[i];
|
|
1067
|
+
if (LEAF_VALUE_KEYS[type] && !LEAF_VALUE_KEYS[type].includes(key)) return void 0;
|
|
1068
|
+
return [
|
|
1069
|
+
...out,
|
|
1070
|
+
key,
|
|
1071
|
+
...segs.slice(i + 1)
|
|
1072
|
+
].join(".");
|
|
1073
|
+
}
|
|
1074
|
+
return out.join(".");
|
|
1075
|
+
}
|
|
1076
|
+
function previewToProd(pv, children, at, ctx) {
|
|
1077
|
+
const out = {};
|
|
1078
|
+
for (const k of Object.keys(pv)) {
|
|
1079
|
+
const v = pv[k];
|
|
1080
|
+
if (v === void 0) continue;
|
|
1081
|
+
if (k === "title" || k === "subtitle" || k === "media") {
|
|
1082
|
+
const stored = previewPathToProd(v, children, ctx);
|
|
1083
|
+
if (stored !== void 0) out[k] = stored;
|
|
1084
|
+
else lose(ctx, `${at}/${k}`, "preview path");
|
|
1085
|
+
} else if (k === "fallback") {
|
|
1086
|
+
const t = v.trim();
|
|
1087
|
+
if (t && t === v && t.length <= 60) out.fallback = v;
|
|
1088
|
+
else lose(ctx, `${at}/${k}`, "help>limit");
|
|
1089
|
+
} else if (k === "icon") {
|
|
1090
|
+
const dock = dockIconOf(v);
|
|
1091
|
+
if (dock) out.icon = dock;
|
|
1092
|
+
else lose(ctx, `${at}/${k}`, "preview icon");
|
|
1093
|
+
} else lose(ctx, `${at}/${k}`, "unsupported key");
|
|
1094
|
+
}
|
|
1095
|
+
return out;
|
|
1096
|
+
}
|
|
1097
|
+
/** A list item's name and title: the convention, else ui.itemName / ui.itemTitle (chromeUiProblems). */
|
|
1098
|
+
function itemIdentity(item, conv, node, ip, ctx) {
|
|
1099
|
+
if (item.name !== conv.name) if (ITEM_NAME_RE.test(item.name)) node.ui.itemName = item.name;
|
|
1100
|
+
else lose(ctx, `${ip}/name`, "item identity");
|
|
1101
|
+
if (item.title !== conv.title) {
|
|
1102
|
+
const t = item.title;
|
|
1103
|
+
if (t === t.trim() && t.length >= 1 && t.length <= 60) node.ui.itemTitle = t;
|
|
1104
|
+
else lose(ctx, `${ip}/title`, "item identity");
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
function ofToProd(f, shape, node, at, lv, ctx) {
|
|
1108
|
+
if (shape.kind === "json" || shape.kind === "leaf" || shape.kind === "object") return lose(ctx, at, "unsupported key");
|
|
1109
|
+
if (shape.kind === "modular") {
|
|
1110
|
+
node.config.blockSlugs = shape.items.map((i) => kebab(i.name));
|
|
1111
|
+
shape.items.forEach((item, i) => blockModelFor(item, `${at}/${i}`, ctx, node));
|
|
1112
|
+
return;
|
|
1113
|
+
}
|
|
1114
|
+
const item = shape.item;
|
|
1115
|
+
const ip = `${at}/0`;
|
|
1116
|
+
if (shape.kind === "zones") {
|
|
1117
|
+
const fields = item.fields ?? [];
|
|
1118
|
+
node.zoned = true;
|
|
1119
|
+
node.children = fields.map((c, i) => convertField(c, `${ip}/fields/${i}`, lv + 1, ctx, fields, false, ctx.lane === "props"));
|
|
1120
|
+
itemIdentity(item, conventionItem(f.name, f.title, node.ui.itemLabel), node, ip, ctx);
|
|
1121
|
+
for (const k of Object.keys(item)) {
|
|
1122
|
+
if (item[k] === void 0) continue;
|
|
1123
|
+
const p = `${ip}/${k}`;
|
|
1124
|
+
if (k === "type" || k === "fields" || k === "name" || k === "title") continue;
|
|
1125
|
+
if (k === "preview") node.ui.preview = previewToProd(item.preview, fields, p, ctx);
|
|
1126
|
+
else if (k === "icon") {
|
|
1127
|
+
const dock = f.icon === void 0 ? dockIconOf(item.icon) : void 0;
|
|
1128
|
+
if (dock) node.ui.icon = dock;
|
|
1129
|
+
else lose(ctx, p, "item icon");
|
|
1130
|
+
} else if (k === "openMode") cat(ctx, p, "item openMode");
|
|
1131
|
+
else lose(ctx, p, "item identity");
|
|
1132
|
+
}
|
|
1133
|
+
return;
|
|
1134
|
+
}
|
|
1135
|
+
if (shape.kind === "itemType") node.config.itemType = shape.itemType;
|
|
1136
|
+
itemIdentity(item, conventionItem(f.name, f.title), node, ip, ctx);
|
|
1137
|
+
for (const k of Object.keys(item)) {
|
|
1138
|
+
if (item[k] === void 0) continue;
|
|
1139
|
+
const p = `${ip}/${k}`;
|
|
1140
|
+
if (k === "name" || k === "title") continue;
|
|
1141
|
+
if (k === "type") {
|
|
1142
|
+
if (shape.kind === "itemType" && item.type === "text") lose(ctx, p, "item settings");
|
|
1143
|
+
} else if (k === "reference" && shape.kind === "refs") referenceToConfig(item.reference, node, p, ctx);
|
|
1144
|
+
else lose(ctx, p, "item settings");
|
|
1145
|
+
}
|
|
1146
|
+
}
|
|
1147
|
+
/**
|
|
1148
|
+
* A modular item type → the kind:'block' model its rows are stored against: the item title is the model name, its fields
|
|
1149
|
+
* the model's top-level fields. A block model holds only fields a block primitive renders; any other is not stored. The
|
|
1150
|
+
* item's icon and preview are how its rows read in THIS field: the field's ui.blocks, by slug.
|
|
1151
|
+
*/
|
|
1152
|
+
function blockModelFor(item, at, ctx, list) {
|
|
1153
|
+
const start = ctx.lossy.length;
|
|
1154
|
+
const startCat = ctx.catalog.length;
|
|
1155
|
+
const slug = kebab(item.name);
|
|
1156
|
+
const sub = {
|
|
1157
|
+
...ctx,
|
|
1158
|
+
tabs: /* @__PURE__ */ new Set(),
|
|
1159
|
+
droppedTabs: /* @__PURE__ */ new Map(),
|
|
1160
|
+
sets: /* @__PURE__ */ new Map()
|
|
1161
|
+
};
|
|
1162
|
+
const fields = item.fields ?? [];
|
|
1163
|
+
const kept = [];
|
|
1164
|
+
const chrome = {};
|
|
1165
|
+
for (const k of Object.keys(item)) {
|
|
1166
|
+
const p = `${at}/${k}`;
|
|
1167
|
+
if (item[k] === void 0 || k === "type" || k === "title") continue;
|
|
1168
|
+
if (k === "name") {
|
|
1169
|
+
if (camel(slug) !== item.name) lose(ctx, p, "item identity");
|
|
1170
|
+
} else if (k === "fields") {
|
|
1171
|
+
let dropped = false;
|
|
1172
|
+
let shifted = false;
|
|
1173
|
+
fields.forEach((c, j) => {
|
|
1174
|
+
const fp = `${p}/${j}`;
|
|
1175
|
+
const mark = ctx.lossy.length;
|
|
1176
|
+
const markCat = ctx.catalog.length;
|
|
1177
|
+
const node = convertField(c, fp, 1, sub, fields, false);
|
|
1178
|
+
if (BLOCK_FIELD_TYPES.has(node.type)) {
|
|
1179
|
+
kept.push(emitField(node));
|
|
1180
|
+
if (dropped && !shifted) {
|
|
1181
|
+
shifted = true;
|
|
1182
|
+
lose(ctx, p, "block model field");
|
|
1183
|
+
}
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
ctx.lossy.length = mark;
|
|
1187
|
+
ctx.catalog.length = markCat;
|
|
1188
|
+
dropped = true;
|
|
1189
|
+
lose(ctx, fp, "block model field");
|
|
1190
|
+
});
|
|
1191
|
+
} else if (k === "openMode") cat(ctx, p, "item openMode");
|
|
1192
|
+
else if (k === "icon") {
|
|
1193
|
+
const dock = dockIconOf(item.icon);
|
|
1194
|
+
if (dock) chrome.icon = dock;
|
|
1195
|
+
else lose(ctx, p, "item icon");
|
|
1196
|
+
} else if (k === "preview") chrome.preview = previewToProd(item.preview, fields, p, ctx);
|
|
1197
|
+
else lose(ctx, p, "item identity");
|
|
1198
|
+
}
|
|
1199
|
+
const model = {
|
|
1200
|
+
name: item.title,
|
|
1201
|
+
slug,
|
|
1202
|
+
kind: "block",
|
|
1203
|
+
fields: kept
|
|
1204
|
+
};
|
|
1205
|
+
const prev = ctx.blockModels.get(slug);
|
|
1206
|
+
const keep = () => {
|
|
1207
|
+
if (!nonEmpty(chrome) || list.ui.blocks?.[slug]) return;
|
|
1208
|
+
list.ui.blocks = {
|
|
1209
|
+
...list.ui.blocks,
|
|
1210
|
+
[slug]: chrome
|
|
1211
|
+
};
|
|
1212
|
+
};
|
|
1213
|
+
if (!prev) {
|
|
1214
|
+
ctx.blockModels.set(slug, model);
|
|
1215
|
+
return keep();
|
|
1216
|
+
}
|
|
1217
|
+
if (deepEqual(prev, model)) return keep();
|
|
1218
|
+
ctx.lossy.length = start;
|
|
1219
|
+
ctx.catalog.length = startCat;
|
|
1220
|
+
lose(ctx, at, "duplicate name");
|
|
1221
|
+
}
|
|
1222
|
+
function referenceToConfig(ref, node, at, ctx) {
|
|
1223
|
+
const to = ref.to ?? [];
|
|
1224
|
+
const entries = to.filter(ENTRY_TARGET);
|
|
1225
|
+
if (entries.length < to.length) lose(ctx, entries.length || !to.length ? `${at}/to` : at, "reference target");
|
|
1226
|
+
if (entries.length === 1) node.config.contentModelId = entries[0];
|
|
1227
|
+
else if (entries.length > 1) Object.assign(node.config, {
|
|
1228
|
+
polymorphic: true,
|
|
1229
|
+
allowedModelSlugs: entries
|
|
1230
|
+
});
|
|
1231
|
+
if (ref.filter !== void 0) lose(ctx, `${at}/filter`, "reference filter");
|
|
1232
|
+
for (const k of Object.keys(ref)) if (k !== "to" && k !== "filter") lose(ctx, `${at}/${k}`, "unsupported key");
|
|
1233
|
+
}
|
|
1234
|
+
function numericToProd(f, node, at, ctx) {
|
|
1235
|
+
if (f.type !== "number" && f.type !== "rating") return lose(ctx, at, "unsupported key");
|
|
1236
|
+
const n = f.numeric;
|
|
1237
|
+
const lo = n.min ?? 0;
|
|
1238
|
+
const hi = n.max ?? 5;
|
|
1239
|
+
const st = n.step ?? 1;
|
|
1240
|
+
const stops = (hi - lo) / st;
|
|
1241
|
+
const ratingOk = (n.min === void 0 || Number.isFinite(n.min) && n.min >= 0) && (n.max === void 0 || isWhole(n.max, 1, 10)) && (n.step === void 0 || Number.isFinite(n.step) && n.step > 0) && lo < hi && Math.abs(stops - Math.round(stops)) < 1e-9 && Math.round(stops) <= 100;
|
|
1242
|
+
for (const k of Object.keys(n)) {
|
|
1243
|
+
const v = n[k];
|
|
1244
|
+
if (v === void 0) continue;
|
|
1245
|
+
const p = `${at}/${k}`;
|
|
1246
|
+
if (k === "unit") {
|
|
1247
|
+
const u = v;
|
|
1248
|
+
if (f.type === "number" && typeof u === "string" && u.trim() !== "" && u.length <= 24) node.config.unit = u;
|
|
1249
|
+
else lose(ctx, p, "numeric unit");
|
|
1250
|
+
} else if (k === "min" || k === "max" || k === "step") if (f.type === "number") node.config[k] = v;
|
|
1251
|
+
else if (ratingOk) node.config[k] = v;
|
|
1252
|
+
else lose(ctx, p, "rating bounds");
|
|
1253
|
+
else lose(ctx, p, "unsupported key");
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
var SCALE_UNIT_SET = new Set([
|
|
1257
|
+
"px",
|
|
1258
|
+
"%",
|
|
1259
|
+
"rem",
|
|
1260
|
+
"em",
|
|
1261
|
+
"vw",
|
|
1262
|
+
"vh"
|
|
1263
|
+
]);
|
|
1264
|
+
var unitsOk = (u) => Array.isArray(u) && u.length >= 1 && u.every((x) => SCALE_UNIT_SET.has(x));
|
|
1265
|
+
var boundOk = (b) => b === void 0 || typeof b === "number" && Number.isFinite(b) || isObj(b) && Object.entries(b).every(([k, x]) => SCALE_UNIT_SET.has(k) && typeof x === "number");
|
|
1266
|
+
var textOk = (s, max) => typeof s === "string" && s.length >= 1 && s.length <= max;
|
|
1267
|
+
/** A V2 scale → config.scale (numberScaleSchema): steps, units, presets and the custom escape hatch, each held to its rules. */
|
|
1268
|
+
function scaleToConfig(s, node, at, ctx) {
|
|
1269
|
+
const steps = s.steps;
|
|
1270
|
+
let outSteps;
|
|
1271
|
+
if (Array.isArray(steps)) {
|
|
1272
|
+
if (!(steps.length >= 1 && steps.length <= 50 && new Set(steps.map((x) => x.value)).size === steps.length && steps.every((x) => typeof x.value === "string" && x.value === x.value.trim() && textOk(x.value, 32) && textOk(x.label, 24) && (x.title === void 0 || textOk(x.title, 60)) && (x.css === void 0 || textOk(x.css, 60)) && (x.px === void 0 || typeof x.px === "number" && Number.isFinite(x.px)) && Object.keys(x).every((k) => [
|
|
1273
|
+
"value",
|
|
1274
|
+
"label",
|
|
1275
|
+
"title",
|
|
1276
|
+
"px",
|
|
1277
|
+
"css"
|
|
1278
|
+
].includes(k))))) return lose(ctx, at, "scale rules");
|
|
1279
|
+
outSteps = steps.map((x) => ({ ...x }));
|
|
1280
|
+
} else {
|
|
1281
|
+
if (!(steps.min < steps.max) || steps.step !== void 0 && !(steps.step > 0)) return lose(ctx, at, "scale rules");
|
|
1282
|
+
outSteps = {
|
|
1283
|
+
min: steps.min,
|
|
1284
|
+
max: steps.max,
|
|
1285
|
+
...steps.step !== void 0 ? { step: steps.step } : {}
|
|
1286
|
+
};
|
|
1287
|
+
}
|
|
1288
|
+
const out = { steps: outSteps };
|
|
1289
|
+
const tokens = Array.isArray(steps) ? new Set(steps.map((x) => x.value)) : void 0;
|
|
1290
|
+
const c = s.allowCustom;
|
|
1291
|
+
const customOk = c === void 0 || typeof c === "boolean" || typeof c === "object" && c !== null && boundOk(c.min) && boundOk(c.max) && (c.units === void 0 || unitsOk(c.units)) && (c.step === void 0 || c.step > 0) && Object.keys(c).every((x) => [
|
|
1292
|
+
"min",
|
|
1293
|
+
"max",
|
|
1294
|
+
"units",
|
|
1295
|
+
"step"
|
|
1296
|
+
].includes(x));
|
|
1297
|
+
for (const k of Object.keys(s)) {
|
|
1298
|
+
const v = s[k];
|
|
1299
|
+
if (v === void 0 || k === "steps") continue;
|
|
1300
|
+
const p = `${at}/${k}`;
|
|
1301
|
+
if (k === "units") if (unitsOk(v)) out.units = [...v];
|
|
1302
|
+
else lose(ctx, p, "scale rules");
|
|
1303
|
+
else if (k === "defaultUnit") if (SCALE_UNIT_SET.has(v)) out.defaultUnit = s.defaultUnit;
|
|
1304
|
+
else lose(ctx, p, "scale rules");
|
|
1305
|
+
else if (k === "allowCustom") if (customOk) out.allowCustom = typeof c === "boolean" ? c : JSON.parse(JSON.stringify(c));
|
|
1306
|
+
else lose(ctx, p, "scale rules");
|
|
1307
|
+
else if (k === "presets") {
|
|
1308
|
+
const presets = s.presets;
|
|
1309
|
+
if (presets.length <= 20 && presets.every((x) => {
|
|
1310
|
+
if (x.label !== void 0 && !textOk(x.label, 24)) return false;
|
|
1311
|
+
if (Object.keys(x).some((y) => y !== "label" && y !== "value")) return false;
|
|
1312
|
+
const pv = x.value;
|
|
1313
|
+
if (typeof pv === "number") return Number.isFinite(pv);
|
|
1314
|
+
if (typeof pv === "string") return textOk(pv, 32) && !!tokens?.has(pv);
|
|
1315
|
+
return isObj(pv) && typeof pv.value === "number" && SCALE_UNIT_SET.has(pv.unit) && Object.keys(pv).length === 2 && customOk && !!s.allowCustom;
|
|
1316
|
+
})) out.presets = presets.map((x) => ({
|
|
1317
|
+
...x.label !== void 0 ? { label: x.label } : {},
|
|
1318
|
+
value: typeof x.value === "object" ? { ...x.value } : x.value
|
|
1319
|
+
}));
|
|
1320
|
+
else lose(ctx, p, "scale rules");
|
|
1321
|
+
} else lose(ctx, p, "unsupported key");
|
|
1322
|
+
}
|
|
1323
|
+
node.config.scale = out;
|
|
1324
|
+
}
|
|
1325
|
+
function conditionToShowIf(h, at, siblings, ctx, variantOk) {
|
|
1326
|
+
const variant = variantOk && h.field === "_variant";
|
|
1327
|
+
if (!h.field || !variant && !siblings.some((s) => s.name === h.field)) return void lose(ctx, at, "condition");
|
|
1328
|
+
if (Object.keys(h).filter((k) => ![
|
|
1329
|
+
"field",
|
|
1330
|
+
"equals",
|
|
1331
|
+
"notEmpty"
|
|
1332
|
+
].includes(k) && h[k] !== void 0).length || h.equals !== void 0 === (h.notEmpty !== void 0)) return void lose(ctx, at, "condition");
|
|
1333
|
+
if (h.notEmpty !== void 0) return h.notEmpty === true ? {
|
|
1334
|
+
match: "all",
|
|
1335
|
+
rules: [{
|
|
1336
|
+
field: h.field,
|
|
1337
|
+
op: "notEmpty"
|
|
1338
|
+
}]
|
|
1339
|
+
} : void lose(ctx, at, "condition");
|
|
1340
|
+
const sibType = variant ? void 0 : siblings.find((s) => s.name === h.field)?.type;
|
|
1341
|
+
const list = Array.isArray(h.equals) ? h.equals : [h.equals];
|
|
1342
|
+
const strs = [];
|
|
1343
|
+
for (const v of list) {
|
|
1344
|
+
if (![
|
|
1345
|
+
"string",
|
|
1346
|
+
"number",
|
|
1347
|
+
"boolean"
|
|
1348
|
+
].includes(typeof v)) return void lose(ctx, at, "condition");
|
|
1349
|
+
const s = String(v);
|
|
1350
|
+
if (coerceRuleValue(sibType, s) !== v) return void lose(ctx, at, "condition");
|
|
1351
|
+
strs.push(s);
|
|
1352
|
+
}
|
|
1353
|
+
return {
|
|
1354
|
+
match: "all",
|
|
1355
|
+
rules: [Array.isArray(h.equals) ? {
|
|
1356
|
+
field: h.field,
|
|
1357
|
+
op: "in",
|
|
1358
|
+
value: strs
|
|
1359
|
+
} : {
|
|
1360
|
+
field: h.field,
|
|
1361
|
+
op: "eq",
|
|
1362
|
+
value: strs[0]
|
|
1363
|
+
}]
|
|
1364
|
+
};
|
|
1365
|
+
}
|
|
1366
|
+
var nonEmpty = (o) => Object.keys(o).length ? o : void 0;
|
|
1367
|
+
function common(n) {
|
|
1368
|
+
const out = {
|
|
1369
|
+
key: n.key,
|
|
1370
|
+
label: n.label,
|
|
1371
|
+
type: n.type
|
|
1372
|
+
};
|
|
1373
|
+
for (const k of [
|
|
1374
|
+
"helpText",
|
|
1375
|
+
"required",
|
|
1376
|
+
"defaultValue",
|
|
1377
|
+
"showIf",
|
|
1378
|
+
"helpMore",
|
|
1379
|
+
"advanced",
|
|
1380
|
+
"recommendedMax",
|
|
1381
|
+
"openMode",
|
|
1382
|
+
"localized"
|
|
1383
|
+
]) if (n[k] !== void 0) out[k] = n[k];
|
|
1384
|
+
return out;
|
|
1385
|
+
}
|
|
1386
|
+
function emitField(n) {
|
|
1387
|
+
const out = common(n);
|
|
1388
|
+
if (n.unique !== void 0) out.unique = n.unique;
|
|
1389
|
+
if (n.readOnly !== void 0) out.readOnly = n.readOnly;
|
|
1390
|
+
if (n.lockReason !== void 0) out.lockReason = n.lockReason;
|
|
1391
|
+
if (n.fieldsetId !== void 0) out.fieldsetId = n.fieldsetId;
|
|
1392
|
+
const config = { ...n.config };
|
|
1393
|
+
if (n.placeholder !== void 0) config.placeholder = n.placeholder;
|
|
1394
|
+
if (n.type === "select" && n.options) out.options = n.options;
|
|
1395
|
+
if ((n.type === "multiselect" || n.type === "tags") && n.options) config.options = n.options;
|
|
1396
|
+
if (n.type === "object") out.fields = (n.children ?? []).map(emitField);
|
|
1397
|
+
if (n.zoned) {
|
|
1398
|
+
const { minItems, maxItems, ...rest } = config;
|
|
1399
|
+
out.config = {
|
|
1400
|
+
...rest,
|
|
1401
|
+
zones: { repeatable: {
|
|
1402
|
+
fields: (n.children ?? []).map(emitField),
|
|
1403
|
+
...minItems !== void 0 ? { minItems } : {},
|
|
1404
|
+
...maxItems !== void 0 ? { maxItems } : {}
|
|
1405
|
+
} }
|
|
1406
|
+
};
|
|
1407
|
+
} else if (nonEmpty(config)) out.config = config;
|
|
1408
|
+
const ui = nonEmpty(n.ui);
|
|
1409
|
+
if (ui) out.ui = ui;
|
|
1410
|
+
return out;
|
|
1411
|
+
}
|
|
1412
|
+
function emitProp(n) {
|
|
1413
|
+
const out = common(n);
|
|
1414
|
+
if (n.unique !== void 0) out.unique = n.unique;
|
|
1415
|
+
if (n.readOnly !== void 0) out.readOnly = n.readOnly;
|
|
1416
|
+
if (n.lockReason !== void 0) out.lockReason = n.lockReason;
|
|
1417
|
+
if (n.placeholder !== void 0) out.placeholder = n.placeholder;
|
|
1418
|
+
const config = { ...n.config };
|
|
1419
|
+
if (n.options) config.options = n.options;
|
|
1420
|
+
if (n.children) config.fields = n.children.map(emitSubField);
|
|
1421
|
+
if (nonEmpty(config)) out.config = config;
|
|
1422
|
+
const ui = nonEmpty(n.ui);
|
|
1423
|
+
if (ui) out.ui = ui;
|
|
1424
|
+
return out;
|
|
1425
|
+
}
|
|
1426
|
+
function emitSubField(n) {
|
|
1427
|
+
const out = common(n);
|
|
1428
|
+
if (n.unique !== void 0) out.unique = n.unique;
|
|
1429
|
+
if (n.readOnly !== void 0) out.readOnly = n.readOnly;
|
|
1430
|
+
if (n.lockReason !== void 0) out.lockReason = n.lockReason;
|
|
1431
|
+
if (n.placeholder !== void 0) out.placeholder = n.placeholder;
|
|
1432
|
+
if (n.options) out.options = n.options;
|
|
1433
|
+
if (n.children) out.fields = n.children.map(emitSubField);
|
|
1434
|
+
if (nonEmpty(n.config)) out.config = { ...n.config };
|
|
1435
|
+
const ui = nonEmpty(n.ui);
|
|
1436
|
+
if (ui) out.ui = ui;
|
|
1437
|
+
return out;
|
|
1438
|
+
}
|
|
1439
|
+
function fromTypeSchema(v2, target) {
|
|
1440
|
+
const ctx = {
|
|
1441
|
+
lane: target,
|
|
1442
|
+
lossy: [],
|
|
1443
|
+
catalog: [],
|
|
1444
|
+
tabs: /* @__PURE__ */ new Set(),
|
|
1445
|
+
droppedTabs: /* @__PURE__ */ new Map(),
|
|
1446
|
+
sets: /* @__PURE__ */ new Map(),
|
|
1447
|
+
propSets: /* @__PURE__ */ new Map(),
|
|
1448
|
+
definedGroups: /* @__PURE__ */ new WeakMap(),
|
|
1449
|
+
propOrder: /* @__PURE__ */ new Map(),
|
|
1450
|
+
groupOrder: false,
|
|
1451
|
+
blockModels: /* @__PURE__ */ new Map()
|
|
1452
|
+
};
|
|
1453
|
+
const props = target === "props";
|
|
1454
|
+
const slug = kebab(v2.name);
|
|
1455
|
+
const category = v2.category !== void 0 ? CATEGORY_TO_PROD[v2.category] : void 0;
|
|
1456
|
+
const fieldsets = [];
|
|
1457
|
+
for (const k of Object.keys(v2)) {
|
|
1458
|
+
if (v2[k] === void 0) continue;
|
|
1459
|
+
const p = `/${k}`;
|
|
1460
|
+
switch (k) {
|
|
1461
|
+
case "name":
|
|
1462
|
+
if (camel(slug) !== v2.name) lose(ctx, p, "type name");
|
|
1463
|
+
break;
|
|
1464
|
+
case "title":
|
|
1465
|
+
case "description":
|
|
1466
|
+
case "fields":
|
|
1467
|
+
case "fieldsets":
|
|
1468
|
+
case "groups": break;
|
|
1469
|
+
case "kind":
|
|
1470
|
+
if (props && v2.kind !== "block") cat(ctx, p, v2.kind === "global" ? "kind:global" : "kind:entry (props)");
|
|
1471
|
+
else if (!props && v2.kind !== "entry") cat(ctx, p, v2.kind === "global" ? "kind:global" : v2.kind === "page" ? "kind:page" : v2.kind === "block" ? "kind:block (fields)" : "kind:object");
|
|
1472
|
+
break;
|
|
1473
|
+
case "icon":
|
|
1474
|
+
cat(ctx, p, "block icon");
|
|
1475
|
+
break;
|
|
1476
|
+
case "preview":
|
|
1477
|
+
cat(ctx, p, "document preview");
|
|
1478
|
+
break;
|
|
1479
|
+
case "variants":
|
|
1480
|
+
cat(ctx, p, "variants");
|
|
1481
|
+
break;
|
|
1482
|
+
case "category":
|
|
1483
|
+
if (!props || !category || capitalize(category) !== v2.category) cat(ctx, p, "category");
|
|
1484
|
+
break;
|
|
1485
|
+
case "placement":
|
|
1486
|
+
cat(ctx, p, "block placement");
|
|
1487
|
+
break;
|
|
1488
|
+
case "initialValue":
|
|
1489
|
+
cat(ctx, p, "seeded instance");
|
|
1490
|
+
break;
|
|
1491
|
+
default: lose(ctx, p, "unsupported key");
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1494
|
+
if (props) {
|
|
1495
|
+
if (v2.groups?.length) lose(ctx, "/groups", "group (props)");
|
|
1496
|
+
propSetsFor(v2, ctx);
|
|
1497
|
+
} else fieldsetsFor(v2, ctx, fieldsets);
|
|
1498
|
+
const nodes = v2.fields.map((f, i) => convertField(f, `/fields/${i}`, 1, ctx, v2.fields, true));
|
|
1499
|
+
if (props) {
|
|
1500
|
+
const component = {
|
|
1501
|
+
name: v2.title,
|
|
1502
|
+
slug,
|
|
1503
|
+
props: nodes.map(emitProp)
|
|
1504
|
+
};
|
|
1505
|
+
if (v2.description !== void 0) component.description = v2.description;
|
|
1506
|
+
if (category) component.category = category;
|
|
1507
|
+
return {
|
|
1508
|
+
schema: component,
|
|
1509
|
+
blockModels: [],
|
|
1510
|
+
lossy: ctx.lossy,
|
|
1511
|
+
catalog: ctx.catalog
|
|
1512
|
+
};
|
|
1513
|
+
}
|
|
1514
|
+
const model = {
|
|
1515
|
+
name: v2.title,
|
|
1516
|
+
slug,
|
|
1517
|
+
fields: nodes.map(emitField)
|
|
1518
|
+
};
|
|
1519
|
+
if (v2.description !== void 0) model.description = v2.description;
|
|
1520
|
+
model.kind = "model";
|
|
1521
|
+
if (fieldsets.length) model.fieldsets = fieldsets;
|
|
1522
|
+
return {
|
|
1523
|
+
schema: model,
|
|
1524
|
+
blockModels: [...ctx.blockModels.values()],
|
|
1525
|
+
lossy: ctx.lossy,
|
|
1526
|
+
catalog: ctx.catalog
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
/** Fields lane: V2 groups → `kind: "tab"` fieldsets, V2 fieldsets → `kind: "group"` fieldsets in the tab their members share. */
|
|
1530
|
+
function fieldsetsFor(v2, ctx, out) {
|
|
1531
|
+
const names = /* @__PURE__ */ new Set();
|
|
1532
|
+
let firstDrop;
|
|
1533
|
+
let shifted = false;
|
|
1534
|
+
(v2.groups ?? []).forEach((g, i) => {
|
|
1535
|
+
const p = `/groups/${i}`;
|
|
1536
|
+
const stored = g.title.slice(0, 20);
|
|
1537
|
+
const folded = stored.trim().toLowerCase();
|
|
1538
|
+
const drop = (why) => {
|
|
1539
|
+
if (!ctx.tabs.has(g.name) && !ctx.droppedTabs.has(g.name)) ctx.droppedTabs.set(g.name, why);
|
|
1540
|
+
firstDrop ??= why;
|
|
1541
|
+
lose(ctx, p, why);
|
|
1542
|
+
};
|
|
1543
|
+
if (ctx.tabs.has(g.name) || names.has(folded)) return drop("group name collision");
|
|
1544
|
+
if (out.length >= 3) return drop("groups>3");
|
|
1545
|
+
names.add(folded);
|
|
1546
|
+
const tab = {
|
|
1547
|
+
id: g.name,
|
|
1548
|
+
name: stored,
|
|
1549
|
+
kind: "tab"
|
|
1550
|
+
};
|
|
1551
|
+
if (g.title.length > 20) lose(ctx, `${p}/title`, "group name>20");
|
|
1552
|
+
if (g.icon !== void 0) {
|
|
1553
|
+
const dock = dockIconOf(g.icon);
|
|
1554
|
+
if (dock) tab.icon = dock;
|
|
1555
|
+
else lose(ctx, `${p}/icon`, "group icon");
|
|
1556
|
+
}
|
|
1557
|
+
if (i === 0 ? g.default !== true : g.default !== void 0) lose(ctx, `${p}/default`, "group default");
|
|
1558
|
+
for (const k of Object.keys(g)) if (![
|
|
1559
|
+
"name",
|
|
1560
|
+
"title",
|
|
1561
|
+
"icon",
|
|
1562
|
+
"default"
|
|
1563
|
+
].includes(k) && g[k] !== void 0) lose(ctx, `${p}/${k}`, "unsupported key");
|
|
1564
|
+
ctx.tabs.add(g.name);
|
|
1565
|
+
out.push(tab);
|
|
1566
|
+
if (firstDrop && !shifted) {
|
|
1567
|
+
shifted = true;
|
|
1568
|
+
lose(ctx, "/groups", firstDrop);
|
|
1569
|
+
}
|
|
1570
|
+
});
|
|
1571
|
+
(v2.fieldsets ?? []).forEach((fs, i) => {
|
|
1572
|
+
const p = `/fieldsets/${i}`;
|
|
1573
|
+
if (ctx.tabs.has(fs.name) || ctx.droppedTabs.has(fs.name) || ctx.sets.has(fs.name) || out.length >= 30) return lose(ctx, p, "fieldset collision");
|
|
1574
|
+
const tally = /* @__PURE__ */ new Map();
|
|
1575
|
+
for (const f of v2.fields) if (f.fieldset === fs.name) tally.set(f.group, (tally.get(f.group) ?? 0) + 1);
|
|
1576
|
+
const best = [...tally.entries()].sort((a, b) => b[1] - a[1])[0]?.[0];
|
|
1577
|
+
const tab = best !== void 0 && ctx.tabs.has(best) ? best : void 0;
|
|
1578
|
+
const set = {
|
|
1579
|
+
id: fs.name,
|
|
1580
|
+
name: fs.title.slice(0, 60),
|
|
1581
|
+
kind: "group"
|
|
1582
|
+
};
|
|
1583
|
+
if (fs.title.length > 60) lose(ctx, `${p}/title`, "fieldset name>limit");
|
|
1584
|
+
if (tab) set.tab = tab;
|
|
1585
|
+
for (const k of Object.keys(fs)) {
|
|
1586
|
+
const v = fs[k];
|
|
1587
|
+
if (v === void 0 || k === "name" || k === "title") continue;
|
|
1588
|
+
if (k === "description") if (v.length <= 500) set.description = v;
|
|
1589
|
+
else lose(ctx, `${p}/${k}`, "help>limit");
|
|
1590
|
+
else if (k === "collapsed" || k === "collapsible" || k === "columns" || k === "layout") set[k] = v;
|
|
1591
|
+
else lose(ctx, `${p}/${k}`, "unsupported key");
|
|
1592
|
+
}
|
|
1593
|
+
ctx.sets.set(fs.name, tab);
|
|
1594
|
+
out.push(set);
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
/**
|
|
1598
|
+
* Props lane: a V2 fieldset is an inline ui.group, defined on the first prop (at each level, sub-fields too) that uses
|
|
1599
|
+
* it. A fieldset no prop uses has nothing to be defined on; when the V2 order differs from where each group is first
|
|
1600
|
+
* met (depth first, a prop before its sub-fields: how propsToTypeSchema meets them), every group carries its `order`.
|
|
1601
|
+
*/
|
|
1602
|
+
function propSetsFor(v2, ctx) {
|
|
1603
|
+
const sets = v2.fieldsets ?? [];
|
|
1604
|
+
if (!sets.length) return;
|
|
1605
|
+
const named = new Set(sets.map((s) => s.name));
|
|
1606
|
+
const firstSeen = [];
|
|
1607
|
+
const visit = (fields, lv) => {
|
|
1608
|
+
for (const f of fields) {
|
|
1609
|
+
if (f.fieldset !== void 0 && named.has(f.fieldset) && !firstSeen.includes(f.fieldset)) firstSeen.push(f.fieldset);
|
|
1610
|
+
if (lv >= 10) continue;
|
|
1611
|
+
const kids = previewKids(f);
|
|
1612
|
+
if (kids) visit(kids, lv + 1);
|
|
1613
|
+
}
|
|
1614
|
+
};
|
|
1615
|
+
visit(v2.fields, 1);
|
|
1616
|
+
ctx.groupOrder = sets.filter((s) => firstSeen.includes(s.name)).some((s, i) => s.name !== firstSeen[i]);
|
|
1617
|
+
let gap = false;
|
|
1618
|
+
sets.forEach((s, i) => {
|
|
1619
|
+
ctx.propSets.set(s.name, s);
|
|
1620
|
+
ctx.propOrder.set(s.name, i);
|
|
1621
|
+
if (!firstSeen.includes(s.name)) {
|
|
1622
|
+
gap = true;
|
|
1623
|
+
return lose(ctx, `/fieldsets/${i}`, "fieldset (props)");
|
|
1624
|
+
}
|
|
1625
|
+
if (gap) {
|
|
1626
|
+
gap = false;
|
|
1627
|
+
lose(ctx, "/fieldsets", "fieldset (props)");
|
|
1628
|
+
}
|
|
1629
|
+
for (const k of Object.keys(s)) {
|
|
1630
|
+
if (s[k] === void 0 || k === "name" || k === "collapsed" || k === "columns" || k === "collapsible" || k === "layout") continue;
|
|
1631
|
+
if (k === "title") {
|
|
1632
|
+
if (s.title.length > 32) lose(ctx, `/fieldsets/${i}/title`, "fieldset name>limit");
|
|
1633
|
+
} else if (k === "description") {
|
|
1634
|
+
if (!groupDescriptionOk(s.description)) lose(ctx, `/fieldsets/${i}/description`, "help>limit");
|
|
1635
|
+
} else lose(ctx, `/fieldsets/${i}/${k}`, "unsupported key");
|
|
1636
|
+
}
|
|
1637
|
+
});
|
|
1638
|
+
}
|
|
1639
|
+
function readField(f) {
|
|
1640
|
+
const cfg = { ...f.config ?? {} };
|
|
1641
|
+
const n = {
|
|
1642
|
+
...f,
|
|
1643
|
+
config: cfg,
|
|
1644
|
+
ui: { ...f.ui ?? {} }
|
|
1645
|
+
};
|
|
1646
|
+
if (typeof cfg.placeholder === "string") {
|
|
1647
|
+
n.placeholder = cfg.placeholder;
|
|
1648
|
+
delete cfg.placeholder;
|
|
1649
|
+
}
|
|
1650
|
+
if (n.placeholder === void 0 && typeof n.ui.placeholder === "string") n.placeholder = n.ui.placeholder;
|
|
1651
|
+
delete n.ui.placeholder;
|
|
1652
|
+
if ((f.type === "multiselect" || f.type === "tags") && cfg.options) {
|
|
1653
|
+
n.options = cfg.options;
|
|
1654
|
+
delete cfg.options;
|
|
1655
|
+
}
|
|
1656
|
+
n.fields = f.fields?.map(readField);
|
|
1657
|
+
if (cfg.zones) {
|
|
1658
|
+
const z = cfg.zones;
|
|
1659
|
+
n.zones = {
|
|
1660
|
+
...z.nonRepeatable ? { nonRepeatable: z.nonRepeatable.map(readField) } : {},
|
|
1661
|
+
...z.repeatable ? { repeatable: {
|
|
1662
|
+
...z.repeatable,
|
|
1663
|
+
fields: z.repeatable.fields.map(readField)
|
|
1664
|
+
} } : {}
|
|
1665
|
+
};
|
|
1666
|
+
delete cfg.zones;
|
|
1667
|
+
}
|
|
1668
|
+
return n;
|
|
1669
|
+
}
|
|
1670
|
+
function readProp(p) {
|
|
1671
|
+
const { config, fields, options, ...rest } = p;
|
|
1672
|
+
const cfg = { ...config ?? {} };
|
|
1673
|
+
const n = {
|
|
1674
|
+
...rest,
|
|
1675
|
+
config: cfg,
|
|
1676
|
+
ui: { ...p.ui ?? {} }
|
|
1677
|
+
};
|
|
1678
|
+
const opts = cfg.options ?? options;
|
|
1679
|
+
if (opts) n.options = opts;
|
|
1680
|
+
delete cfg.options;
|
|
1681
|
+
const kids = cfg.fields ?? fields;
|
|
1682
|
+
if (kids) n.fields = kids.map(readProp);
|
|
1683
|
+
delete cfg.fields;
|
|
1684
|
+
return n;
|
|
1685
|
+
}
|
|
1686
|
+
/** A stored choice → the V2 option: a dock icon reads back as the kit's Tabler name, the description as itself. */
|
|
1687
|
+
var optionsFromProd = (opts) => opts.map((o) => {
|
|
1688
|
+
if (typeof o === "string") return {
|
|
1689
|
+
value: o,
|
|
1690
|
+
label: o
|
|
1691
|
+
};
|
|
1692
|
+
const out = {
|
|
1693
|
+
value: o.value,
|
|
1694
|
+
label: o.label
|
|
1695
|
+
};
|
|
1696
|
+
if (typeof o.icon === "string") out.icon = tablerIconOf(o.icon);
|
|
1697
|
+
if (typeof o.description === "string") out.description = o.description;
|
|
1698
|
+
return out;
|
|
1699
|
+
});
|
|
1700
|
+
function scaleFromConfig(s, at, ctx) {
|
|
1701
|
+
const steps = s.steps;
|
|
1702
|
+
const out = !Array.isArray(steps) ? { steps: {
|
|
1703
|
+
min: steps.min,
|
|
1704
|
+
max: steps.max,
|
|
1705
|
+
...steps.step !== void 0 ? { step: steps.step } : {}
|
|
1706
|
+
} } : steps.some((x) => typeof x.value === "string") ? { steps: steps.map((x) => ({ ...x })) } : (ctx.onLoss(`${at}/steps`, "scale steps", "Numeric step lists read back as token steps named by their number."), { steps: steps.map((x) => ({
|
|
1707
|
+
value: String(x.value),
|
|
1708
|
+
label: x.label ?? String(x.value),
|
|
1709
|
+
px: x.value
|
|
1710
|
+
})) });
|
|
1711
|
+
if (s.units) out.units = s.units;
|
|
1712
|
+
if (s.defaultUnit) out.defaultUnit = s.defaultUnit;
|
|
1713
|
+
if (s.allowCustom !== void 0) out.allowCustom = isObj(s.allowCustom) ? JSON.parse(JSON.stringify(s.allowCustom)) : s.allowCustom;
|
|
1714
|
+
if (s.presets) out.presets = s.presets.map((p) => ({
|
|
1715
|
+
...p.label !== void 0 ? { label: p.label } : {},
|
|
1716
|
+
value: typeof p.value === "object" ? { ...p.value } : p.value
|
|
1717
|
+
}));
|
|
1718
|
+
return out;
|
|
1719
|
+
}
|
|
1720
|
+
/** The prod children a preview path segment may name below a node (an object's, a list's rows'), or null for a leaf. */
|
|
1721
|
+
var readKids = (n) => n.zones ? [...n.zones.nonRepeatable ?? [], ...n.zones.repeatable?.fields ?? []] : n.fields && [
|
|
1722
|
+
"object",
|
|
1723
|
+
"group",
|
|
1724
|
+
"repeater",
|
|
1725
|
+
"table"
|
|
1726
|
+
].includes(n.type) ? n.fields : null;
|
|
1727
|
+
/** A stored preview path → the V2 path: `image.altText` reads as `image.alt`, the rest as it is. */
|
|
1728
|
+
function previewPathFromProd(path, children) {
|
|
1729
|
+
const segs = path.split(".");
|
|
1730
|
+
let node = children.find((c) => c.key === segs[0]);
|
|
1731
|
+
for (let i = 1; node && i < segs.length; i++) {
|
|
1732
|
+
const kids = readKids(node);
|
|
1733
|
+
if (kids) {
|
|
1734
|
+
node = kids.find((c) => c.key === segs[i]);
|
|
1735
|
+
continue;
|
|
1736
|
+
}
|
|
1737
|
+
if (node.type === "image") {
|
|
1738
|
+
const back = Object.entries(IMAGE_PATH_KEY).find(([, stored]) => stored === segs[i])?.[0];
|
|
1739
|
+
if (back) segs[i] = back;
|
|
1740
|
+
}
|
|
1741
|
+
break;
|
|
1742
|
+
}
|
|
1743
|
+
return segs.join(".");
|
|
1744
|
+
}
|
|
1745
|
+
function previewFromProd(pv, children) {
|
|
1746
|
+
const out = { ...pv };
|
|
1747
|
+
for (const k of [
|
|
1748
|
+
"title",
|
|
1749
|
+
"subtitle",
|
|
1750
|
+
"media"
|
|
1751
|
+
]) if (typeof pv[k] === "string") out[k] = previewPathFromProd(pv[k], children);
|
|
1752
|
+
if (typeof pv.icon === "string") out.icon = tablerIconOf(pv.icon);
|
|
1753
|
+
return out;
|
|
1754
|
+
}
|
|
1755
|
+
function showIfToCondition(s, siblings, at, ctx) {
|
|
1756
|
+
const drop = (why) => void ctx.onLoss(at, "condition", why);
|
|
1757
|
+
if (s.rules.length !== 1) return drop("V2 conditions test one sibling; a multi-rule showIf is dropped (the field always shows).");
|
|
1758
|
+
const r = s.rules[0];
|
|
1759
|
+
const sib = siblings.find((x) => x.key === r.field);
|
|
1760
|
+
const t = sib?.type === "number" ? "number" : sib?.type;
|
|
1761
|
+
const read = (v) => coerceRuleValue(t, v);
|
|
1762
|
+
switch (r.op) {
|
|
1763
|
+
case "eq": return Array.isArray(r.value) ? {
|
|
1764
|
+
field: r.field,
|
|
1765
|
+
equals: r.value.map(read)
|
|
1766
|
+
} : {
|
|
1767
|
+
field: r.field,
|
|
1768
|
+
equals: read(r.value ?? "")
|
|
1769
|
+
};
|
|
1770
|
+
case "in": return {
|
|
1771
|
+
field: r.field,
|
|
1772
|
+
equals: (Array.isArray(r.value) ? r.value : [r.value ?? ""]).map(read)
|
|
1773
|
+
};
|
|
1774
|
+
case "isSet":
|
|
1775
|
+
case "notEmpty": return {
|
|
1776
|
+
field: r.field,
|
|
1777
|
+
notEmpty: true
|
|
1778
|
+
};
|
|
1779
|
+
default: return drop(`V2 conditions have no "${r.op}"; the field always shows.`);
|
|
1780
|
+
}
|
|
1781
|
+
}
|
|
1782
|
+
function v2Type(n, at, ctx) {
|
|
1783
|
+
switch (n.type) {
|
|
1784
|
+
case "text": return n.config.inputType === "url" ? "url" : "string";
|
|
1785
|
+
case "longtext": return "text";
|
|
1786
|
+
case "document":
|
|
1787
|
+
ctx.onLoss(`${at}/type`, "document", "A document (article body) reads as rich text.");
|
|
1788
|
+
return "richtext";
|
|
1789
|
+
case "phone":
|
|
1790
|
+
ctx.onLoss(`${at}/type`, "phone", "V2 has no phone type; it reads as a string.");
|
|
1791
|
+
return "string";
|
|
1792
|
+
case "location": return "geopoint";
|
|
1793
|
+
case "number": return n.ui.control === "rating" ? "rating" : "number";
|
|
1794
|
+
case "select": return n.config.multiSelect === true ? "multiselect" : "select";
|
|
1795
|
+
case "multiselect": return n.config.allowCustom === true ? "tags" : "multiselect";
|
|
1796
|
+
case "group":
|
|
1797
|
+
case "object": return "object";
|
|
1798
|
+
case "repeater":
|
|
1799
|
+
case "table":
|
|
1800
|
+
case "array":
|
|
1801
|
+
case "multi-reference":
|
|
1802
|
+
case "multiReference":
|
|
1803
|
+
case "modular": return "array";
|
|
1804
|
+
case "form": return "reference";
|
|
1805
|
+
case "component-ref":
|
|
1806
|
+
case "sections":
|
|
1807
|
+
case "slot":
|
|
1808
|
+
ctx.onLoss(`${at}/type`, n.type, "This prod type stores component or block instances V2 cannot edit; it reads as json.");
|
|
1809
|
+
return "json";
|
|
1810
|
+
default: return n.type;
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
function readToV2(n, at, siblings, ctx, top, lane) {
|
|
1814
|
+
/** a data-table prop (config.mode "data") holds one TableValue: the V2 `table` field, not a list of rows */
|
|
1815
|
+
const dataTable = lane === "props" && isDataTableProp(n);
|
|
1816
|
+
const type = dataTable ? "table" : v2Type(n, at, ctx);
|
|
1817
|
+
const f = {
|
|
1818
|
+
name: n.key,
|
|
1819
|
+
title: n.label,
|
|
1820
|
+
type
|
|
1821
|
+
};
|
|
1822
|
+
const cfg = n.config;
|
|
1823
|
+
const val = {};
|
|
1824
|
+
const loss = (k, feature, reason) => ctx.onLoss(`${at}/${k}`, feature, reason);
|
|
1825
|
+
if (n.helpText !== void 0) f.description = n.helpText;
|
|
1826
|
+
if (n.helpMore !== void 0) f.helpMore = n.helpMore;
|
|
1827
|
+
if (n.placeholder !== void 0) f.placeholder = n.placeholder;
|
|
1828
|
+
if (n.required !== void 0) val.required = n.required;
|
|
1829
|
+
if (n.unique !== void 0) val.unique = n.unique;
|
|
1830
|
+
if (n.recommendedMax !== void 0) val.recommendedMax = n.recommendedMax;
|
|
1831
|
+
if (n.advanced !== void 0) f.advanced = n.advanced;
|
|
1832
|
+
if (n.openMode !== void 0) f.openMode = n.openMode;
|
|
1833
|
+
if (n.readOnly === true) f.readOnly = true;
|
|
1834
|
+
if (n.ui.access) f.access = { ...n.ui.access };
|
|
1835
|
+
else if (n.readOnly === "developer") f.access = { edit: "schema.manage" };
|
|
1836
|
+
if (n.lockReason !== void 0) f.lockReason = n.lockReason;
|
|
1837
|
+
if (n.localized !== void 0) f.localized = n.localized;
|
|
1838
|
+
if (n.ui.hidden !== void 0) f.hidden = n.ui.hidden;
|
|
1839
|
+
if (n.ui.rows !== void 0) f.rows = n.ui.rows;
|
|
1840
|
+
if (n.ui.synced !== void 0) f.synced = { ...n.ui.synced };
|
|
1841
|
+
if (n.ui.valueShape !== void 0) f.valueShape = n.ui.valueShape;
|
|
1842
|
+
if (n.showIf) {
|
|
1843
|
+
const c = showIfToCondition(n.showIf, siblings, `${at}/showIf`, ctx);
|
|
1844
|
+
if (c) f.hidden = c;
|
|
1845
|
+
}
|
|
1846
|
+
if (n.placement !== void 0) loss("placement", "placement", "V2 has no editor placement; the field renders in the form.");
|
|
1847
|
+
if (n.searchable === false) loss("searchable", "searchable", "V2 has no search-index flag.");
|
|
1848
|
+
if (n.ui.collapsed !== void 0) loss("ui/collapsed", "ui.collapsed", "V2 fields have no start-collapsed flag.");
|
|
1849
|
+
if (n.ui.reorderable !== void 0) loss("ui/reorderable", "ui.reorderable", "V2 lists are always reorderable.");
|
|
1850
|
+
if (n.ui.input !== void 0) loss("ui/input", "ui.input", "Custom dock inputs are a dock feature V2 has no key for.");
|
|
1851
|
+
if (n.fieldsetId !== void 0) {
|
|
1852
|
+
const set = ctx.sets.get(n.fieldsetId);
|
|
1853
|
+
if (set?.kind === "tab") if (top) f.group = set.id;
|
|
1854
|
+
else loss("fieldsetId", "fieldset", "Only top-level V2 fields sit in a tab; this nested field's tab is dropped.");
|
|
1855
|
+
else if (set) {
|
|
1856
|
+
f.fieldset = set.id;
|
|
1857
|
+
if (top && set.tab !== void 0) f.group = set.tab;
|
|
1858
|
+
} else loss("fieldsetId", "fieldset", `No fieldset "${n.fieldsetId}" exists on this model; the membership is dropped.`);
|
|
1859
|
+
}
|
|
1860
|
+
if (lane === "props" && n.ui.group) f.fieldset = n.ui.group.id;
|
|
1861
|
+
for (const k of [
|
|
1862
|
+
"target",
|
|
1863
|
+
"stale",
|
|
1864
|
+
"origin"
|
|
1865
|
+
]) if (n[k] !== void 0) loss(k, k, k === "target" ? "A prop's target (where it writes in the component) is binding, not schema: V2 has no key for it, so the host keeps it." : `V2 has no "${k}" key.`);
|
|
1866
|
+
const used = new Set([
|
|
1867
|
+
"placeholder",
|
|
1868
|
+
"zones",
|
|
1869
|
+
"options",
|
|
1870
|
+
"fields"
|
|
1871
|
+
]);
|
|
1872
|
+
const usedUi = new Set([
|
|
1873
|
+
"collapsed",
|
|
1874
|
+
"reorderable",
|
|
1875
|
+
"input",
|
|
1876
|
+
"access",
|
|
1877
|
+
"hidden",
|
|
1878
|
+
"rows",
|
|
1879
|
+
"synced",
|
|
1880
|
+
"valueShape"
|
|
1881
|
+
]);
|
|
1882
|
+
const use = (...k) => k.forEach((x) => used.add(x));
|
|
1883
|
+
const useUi = (...k) => k.forEach((x) => usedUi.add(x));
|
|
1884
|
+
if (lane === "props") useUi("group");
|
|
1885
|
+
if ([
|
|
1886
|
+
"text",
|
|
1887
|
+
"longtext",
|
|
1888
|
+
"url",
|
|
1889
|
+
"richtext",
|
|
1890
|
+
"document"
|
|
1891
|
+
].includes(n.type)) {
|
|
1892
|
+
use("minLength", "maxLength", "pattern", "patternMessage", "inputType");
|
|
1893
|
+
if (typeof cfg.minLength === "number") val.min = cfg.minLength;
|
|
1894
|
+
if (typeof cfg.maxLength === "number") val.max = cfg.maxLength;
|
|
1895
|
+
if (typeof cfg.pattern === "string") val.pattern = cfg.pattern;
|
|
1896
|
+
if (typeof cfg.patternMessage === "string") val.patternMessage = cfg.patternMessage;
|
|
1897
|
+
}
|
|
1898
|
+
if (type === "number" || type === "rating") {
|
|
1899
|
+
const numeric = {};
|
|
1900
|
+
for (const k of [
|
|
1901
|
+
"min",
|
|
1902
|
+
"max",
|
|
1903
|
+
"step"
|
|
1904
|
+
]) if (typeof cfg[k] === "number") numeric[k] = cfg[k];
|
|
1905
|
+
const ratingDefault = type === "rating" && n.type === "number" && ratingIsDefault(numeric);
|
|
1906
|
+
if (typeof cfg.unit === "string") numeric.unit = cfg.unit;
|
|
1907
|
+
if (Object.keys(numeric).length && !ratingDefault) f.numeric = numeric;
|
|
1908
|
+
const bounds = cfg.validation;
|
|
1909
|
+
if (isObj(bounds)) {
|
|
1910
|
+
for (const k of ["min", "max"]) if (typeof bounds[k] === "number") val[k] = bounds[k];
|
|
1911
|
+
}
|
|
1912
|
+
if (cfg.scale) f.scale = scaleFromConfig(cfg.scale, `${at}/config/scale`, ctx);
|
|
1913
|
+
if (n.ui.control === "slider") f.layout = "slider";
|
|
1914
|
+
use("min", "max", "step", "scale", "unit", "validation");
|
|
1915
|
+
if (n.ui.control === "slider" || n.ui.control === "rating") useUi("control");
|
|
1916
|
+
}
|
|
1917
|
+
const control = n.ui.control;
|
|
1918
|
+
if (control !== void 0 && control !== "slider" && control !== "rating" && (control === "segmented" ? type === "select" : CONTROL_TYPES[control]?.includes(type))) {
|
|
1919
|
+
f.layout = control;
|
|
1920
|
+
useUi("control");
|
|
1921
|
+
}
|
|
1922
|
+
if (n.type === "select") use("multiSelect");
|
|
1923
|
+
if ((type === "select" || type === "multiselect" || type === "tags") && n.options) f.options = optionsFromProd(n.options);
|
|
1924
|
+
if (type === "multiselect" || type === "tags") {
|
|
1925
|
+
if (typeof cfg.min === "number") val.min = cfg.min;
|
|
1926
|
+
if (typeof cfg.max === "number") val.max = cfg.max;
|
|
1927
|
+
use("min", "max", "allowCustom");
|
|
1928
|
+
}
|
|
1929
|
+
if (n.type === "code") {
|
|
1930
|
+
if (typeof cfg.language === "string") f.language = cfg.language;
|
|
1931
|
+
else if (cfg.language !== void 0) loss("config/language", "code language", "The field's language is not a string; it is dropped.");
|
|
1932
|
+
if (Array.isArray(cfg.languages) && cfg.languages.every((l) => typeof l === "string")) f.languages = [...cfg.languages];
|
|
1933
|
+
else if (cfg.languages !== void 0) loss("config/languages", "code language", "The field's languages are not a list of names; they are dropped.");
|
|
1934
|
+
use("language", "languages");
|
|
1935
|
+
}
|
|
1936
|
+
if (n.type === "tags" && cfg.allowCustom === false) loss("config/allowCustom", "tags closed", "V2 tags always take free entry; a closed tags list reads as open tags.");
|
|
1937
|
+
if (type === "date" || type === "datetime") use("timezone", "includeTime");
|
|
1938
|
+
if ((type === "date" || type === "datetime") && typeof cfg.timezone === "string") f.timezone = cfg.timezone === "site" ? "site" : `fixed:${cfg.timezone}`;
|
|
1939
|
+
if ((type === "date" || type === "datetime") && typeof cfg.timezone === "boolean") f.timezone = cfg.timezone;
|
|
1940
|
+
if (n.type === "reference" || n.type === "multi-reference" || n.type === "multiReference") use("contentModelId", "polymorphic", "allowedModelSlugs");
|
|
1941
|
+
if (n.type === "reference") {
|
|
1942
|
+
const to = cfg.polymorphic ? cfg.allowedModelSlugs ?? [] : cfg.contentModelId ? [cfg.contentModelId] : [];
|
|
1943
|
+
if (to.length) f.reference = { to };
|
|
1944
|
+
}
|
|
1945
|
+
if (n.type === "form") f.reference = { to: ["form"] };
|
|
1946
|
+
if (n.type === "object" || n.type === "group") {
|
|
1947
|
+
f.fields = (n.fields ?? []).map((c, i) => readToV2(c, `${at}/fields/${i}`, n.fields ?? [], ctx, false, lane));
|
|
1948
|
+
if (n.ui.preview) f.preview = previewFromProd(n.ui.preview, n.fields ?? []);
|
|
1949
|
+
if (n.ui.icon) f.icon = tablerIconOf(n.ui.icon);
|
|
1950
|
+
useUi("preview", "icon");
|
|
1951
|
+
}
|
|
1952
|
+
if (n.type === "array" && n.zones?.nonRepeatable) {
|
|
1953
|
+
const nr = n.zones.nonRepeatable;
|
|
1954
|
+
const kids = [{
|
|
1955
|
+
name: "nonRepeatable",
|
|
1956
|
+
title: n.label,
|
|
1957
|
+
type: "object",
|
|
1958
|
+
fields: nr.map((c, i) => readToV2(c, `${at}/config/zones/nonRepeatable/${i}`, nr, ctx, false, lane))
|
|
1959
|
+
}];
|
|
1960
|
+
if (n.zones.repeatable) kids.push(listOf(n, n.zones.repeatable.fields, "repeatable", `${at}/config/zones/repeatable`, ctx, lane));
|
|
1961
|
+
ctx.onLoss(`${at}/config/zones`, "zone envelope", "A non-repeatable zone reads as an object with nonRepeatable (and repeatable) children, matching its stored {nonRepeatable, repeatable} value.");
|
|
1962
|
+
Object.assign(f, {
|
|
1963
|
+
type: "object",
|
|
1964
|
+
fields: kids
|
|
1965
|
+
});
|
|
1966
|
+
} else if (dataTable) {
|
|
1967
|
+
f.table = tableOptionsFromConfig(cfg);
|
|
1968
|
+
use("mode", "columnTypes", "lockColumns", "requireCaption", "allowGroups", "allowFootnotes", "allowNote", "minRows", "maxRows", "maxColumns", "settings", "jsonLd");
|
|
1969
|
+
} else if (n.type === "array" && n.zones?.repeatable || n.type === "repeater" || n.type === "table") {
|
|
1970
|
+
const list = listOf(n, n.zones?.repeatable?.fields ?? n.fields ?? [], n.key, at, ctx, lane);
|
|
1971
|
+
useUi("preview", "icon", "itemLabel", "layout", "itemName", "itemTitle");
|
|
1972
|
+
if (n.zones?.repeatable) ctx.zoned.add(f);
|
|
1973
|
+
f.of = list.of;
|
|
1974
|
+
if (list.itemNoun !== void 0) f.itemNoun = list.itemNoun;
|
|
1975
|
+
if (list.arrayLayout) f.arrayLayout = list.arrayLayout;
|
|
1976
|
+
if (list.layout) f.layout = list.layout;
|
|
1977
|
+
const r = n.zones?.repeatable ?? (n.type === "table" ? {
|
|
1978
|
+
minItems: cfg.minItems,
|
|
1979
|
+
maxItems: cfg.maxItems
|
|
1980
|
+
} : void 0);
|
|
1981
|
+
if (typeof r?.minItems === "number") val.min = r.minItems;
|
|
1982
|
+
if (typeof r?.maxItems === "number") val.max = r.maxItems;
|
|
1983
|
+
if (n.type === "table") use("minItems", "maxItems");
|
|
1984
|
+
} else if (n.type === "array" && cfg.itemType) {
|
|
1985
|
+
f.of = [{
|
|
1986
|
+
...itemOf(n),
|
|
1987
|
+
type: cfg.itemType === "text" ? "string" : cfg.itemType
|
|
1988
|
+
}];
|
|
1989
|
+
leafListChrome(n, f, loss, "a list of scalars");
|
|
1990
|
+
if (typeof cfg.minItems === "number") val.min = cfg.minItems;
|
|
1991
|
+
if (typeof cfg.maxItems === "number") val.max = cfg.maxItems;
|
|
1992
|
+
use("itemType", "minItems", "maxItems");
|
|
1993
|
+
useUi("layout", "itemLabel", "itemName", "itemTitle");
|
|
1994
|
+
} else if (n.type === "modular") {
|
|
1995
|
+
const slugs = cfg.blockSlugs ?? [];
|
|
1996
|
+
f.of = slugs.map((s, j) => {
|
|
1997
|
+
const bm = ctx.blockModels.get(s);
|
|
1998
|
+
const chrome = n.ui.blocks?.[s];
|
|
1999
|
+
const kids = bm ? bm.fields.map(readField) : [];
|
|
2000
|
+
const item = bm ? {
|
|
2001
|
+
name: camel(s),
|
|
2002
|
+
title: bm.name,
|
|
2003
|
+
type: "object",
|
|
2004
|
+
fields: kids.map((c, k) => readToV2(c, `${at}/of/${j}/fields/${k}`, kids, ctx, false, lane))
|
|
2005
|
+
} : {
|
|
2006
|
+
name: camel(s),
|
|
2007
|
+
title: camel(s),
|
|
2008
|
+
type: "object",
|
|
2009
|
+
fields: []
|
|
2010
|
+
};
|
|
2011
|
+
if (chrome?.icon) item.icon = tablerIconOf(chrome.icon);
|
|
2012
|
+
if (chrome?.preview) item.preview = previewFromProd(chrome.preview, kids);
|
|
2013
|
+
return item;
|
|
2014
|
+
});
|
|
2015
|
+
const missing = slugs.filter((s) => !ctx.blockModels.has(s));
|
|
2016
|
+
if (missing.length) ctx.onLoss(`${at}/config/blockSlugs`, "block models", `Each item type is its own block model; ${missing.join(", ")} was not passed, so its fields read as none.`);
|
|
2017
|
+
ctx.modular.add(f);
|
|
2018
|
+
if (n.ui.itemLabel) f.itemNoun = n.ui.itemLabel.toLowerCase();
|
|
2019
|
+
if (n.ui.icon) f.icon = tablerIconOf(n.ui.icon);
|
|
2020
|
+
const l = n.ui.layout;
|
|
2021
|
+
if (l === "grid" || l === "list") f.arrayLayout = l;
|
|
2022
|
+
else if (l === "rows") f.layout = "list";
|
|
2023
|
+
else if (l) loss("ui/layout", "ui.layout", `V2 has no "${l}" layout for a list of blocks.`);
|
|
2024
|
+
if (typeof cfg.minItems === "number") val.min = cfg.minItems;
|
|
2025
|
+
if (typeof cfg.maxItems === "number") val.max = cfg.maxItems;
|
|
2026
|
+
use("blockSlugs", "minItems", "maxItems");
|
|
2027
|
+
useUi("itemLabel", "icon", "layout", "blocks");
|
|
2028
|
+
} else if (n.type === "multi-reference" || n.type === "multiReference") {
|
|
2029
|
+
const to = cfg.polymorphic ? cfg.allowedModelSlugs ?? [] : cfg.contentModelId ? [cfg.contentModelId] : [];
|
|
2030
|
+
f.of = [{
|
|
2031
|
+
...itemOf(n),
|
|
2032
|
+
type: "reference",
|
|
2033
|
+
...to.length ? { reference: { to } } : {}
|
|
2034
|
+
}];
|
|
2035
|
+
leafListChrome(n, f, loss, "a list of entries");
|
|
2036
|
+
if (typeof cfg.min === "number") val.min = cfg.min;
|
|
2037
|
+
if (typeof cfg.max === "number") val.max = cfg.max;
|
|
2038
|
+
use("min", "max");
|
|
2039
|
+
useUi("layout", "itemLabel", "itemName", "itemTitle");
|
|
2040
|
+
}
|
|
2041
|
+
if (n.type === "array" && n.zones?.nonRepeatable && n.zones.repeatable) useUi("preview", "icon", "itemLabel", "layout");
|
|
2042
|
+
for (const [k, x] of Object.entries(cfg)) if (x !== void 0 && !used.has(k)) loss(`config/${k}`, "config", `V2 has no "${k}" setting on a ${type} field.`);
|
|
2043
|
+
for (const [k, x] of Object.entries(n.ui)) if (x !== void 0 && !usedUi.has(k)) loss(`ui/${k}`, `ui.${k}`, `V2 has no ui.${k} on a ${type} field.`);
|
|
2044
|
+
if (n.defaultValue !== void 0 || top && ctx.plans) {
|
|
2045
|
+
const plan = readPlan(f, n.type, ctx.zoned, ctx.modular);
|
|
2046
|
+
if (top) ctx.plans?.set(f.name, plan);
|
|
2047
|
+
if (n.defaultValue !== void 0) f.initialValue = planFromProd(plan, n.defaultValue, (rel, reason) => loss(`defaultValue${rel}`, "stored value", reason));
|
|
2048
|
+
}
|
|
2049
|
+
if (Object.keys(val).length) f.validation = val;
|
|
2050
|
+
return f;
|
|
2051
|
+
}
|
|
2052
|
+
/** A list of scalars or entries: its item's name and title (ui.itemName / ui.itemTitle, else the convention). */
|
|
2053
|
+
var itemOf = (n) => {
|
|
2054
|
+
const conv = conventionItem(n.key, n.label);
|
|
2055
|
+
return {
|
|
2056
|
+
name: n.ui.itemName ?? conv.name,
|
|
2057
|
+
title: n.ui.itemTitle ?? conv.title
|
|
2058
|
+
};
|
|
2059
|
+
};
|
|
2060
|
+
/** A list of scalars or entries: the noun (ui.itemLabel) and its layout (rows → list, gallery → grid tiles). */
|
|
2061
|
+
function leafListChrome(n, f, loss, what) {
|
|
2062
|
+
if (n.ui.itemLabel !== void 0) f.itemNoun = n.ui.itemLabel.toLowerCase();
|
|
2063
|
+
const l = n.ui.layout;
|
|
2064
|
+
if (l === "rows") f.layout = "list";
|
|
2065
|
+
else if (l === "gallery") f.arrayLayout = "grid";
|
|
2066
|
+
else if (l) loss("ui/layout", "ui.layout", `V2 has no "${l}" layout for ${what}.`);
|
|
2067
|
+
}
|
|
2068
|
+
/** A list of object rows (zones.repeatable, legacy repeater, prop table) → the V2 array's single item type. */
|
|
2069
|
+
function listOf(n, kids, name, at, ctx, lane) {
|
|
2070
|
+
const conv = conventionItem(name, n.label, n.ui.itemLabel);
|
|
2071
|
+
const item = {
|
|
2072
|
+
name: n.ui.itemName ?? conv.name,
|
|
2073
|
+
title: n.ui.itemTitle ?? conv.title,
|
|
2074
|
+
type: "object",
|
|
2075
|
+
fields: kids.map((c, i) => readToV2(c, `${at}/fields/${i}`, kids, ctx, false, lane))
|
|
2076
|
+
};
|
|
2077
|
+
if (n.ui.preview) item.preview = previewFromProd(n.ui.preview, kids);
|
|
2078
|
+
if (n.ui.icon) item.icon = tablerIconOf(n.ui.icon);
|
|
2079
|
+
const out = {
|
|
2080
|
+
name,
|
|
2081
|
+
title: n.label,
|
|
2082
|
+
type: "array",
|
|
2083
|
+
of: [item]
|
|
2084
|
+
};
|
|
2085
|
+
if (n.ui.itemLabel !== void 0) out.itemNoun = n.ui.itemLabel.toLowerCase();
|
|
2086
|
+
const l = n.ui.layout;
|
|
2087
|
+
if (l === "grid" || l === "list") out.arrayLayout = l;
|
|
2088
|
+
else if (l === "rows") out.layout = "list";
|
|
2089
|
+
else if (l) ctx.onLoss(`${at}/ui/layout`, "ui.layout", `V2 has no "${l}" layout for rows.`);
|
|
2090
|
+
return out;
|
|
2091
|
+
}
|
|
2092
|
+
/** A prod content model (both dialects) → TypeSchema. */
|
|
2093
|
+
function toTypeSchema(model, opts = {}) {
|
|
2094
|
+
const ctx = {
|
|
2095
|
+
onLoss: (path, feature, reason) => opts.onLoss?.({
|
|
2096
|
+
path,
|
|
2097
|
+
feature,
|
|
2098
|
+
reason
|
|
2099
|
+
}),
|
|
2100
|
+
sets: /* @__PURE__ */ new Map(),
|
|
2101
|
+
zoned: /* @__PURE__ */ new WeakSet(),
|
|
2102
|
+
modular: /* @__PURE__ */ new WeakSet(),
|
|
2103
|
+
blockModels: new Map((opts.blockModels ?? []).map((m) => [m.slug, m])),
|
|
2104
|
+
plans: opts.plans
|
|
2105
|
+
};
|
|
2106
|
+
const sets = model.fieldsets ?? [];
|
|
2107
|
+
const groups = [];
|
|
2108
|
+
const fieldsets = [];
|
|
2109
|
+
sets.forEach((s, i) => {
|
|
2110
|
+
ctx.sets.set(s.id, s);
|
|
2111
|
+
if (s.kind === "tab") {
|
|
2112
|
+
const g = {
|
|
2113
|
+
name: s.id,
|
|
2114
|
+
title: s.name
|
|
2115
|
+
};
|
|
2116
|
+
if (s.icon) g.icon = tablerIconOf(s.icon);
|
|
2117
|
+
if (groups.length === 0) g.default = true;
|
|
2118
|
+
groups.push(g);
|
|
2119
|
+
return;
|
|
2120
|
+
}
|
|
2121
|
+
const fs = {
|
|
2122
|
+
name: s.id,
|
|
2123
|
+
title: s.name
|
|
2124
|
+
};
|
|
2125
|
+
if (s.description !== void 0) fs.description = s.description;
|
|
2126
|
+
for (const k of [
|
|
2127
|
+
"collapsed",
|
|
2128
|
+
"collapsible",
|
|
2129
|
+
"columns",
|
|
2130
|
+
"layout"
|
|
2131
|
+
]) if (s[k] !== void 0) fs[k] = s[k];
|
|
2132
|
+
if (s.kind === "row") ctx.onLoss(`/fieldsets/${i}/kind`, "fieldset row", "V2 has no row fieldset; it reads as a section.");
|
|
2133
|
+
if (s.icon !== void 0) ctx.onLoss(`/fieldsets/${i}/icon`, "fieldset icon", "V2 sections have no icon.");
|
|
2134
|
+
fieldsets.push(fs);
|
|
2135
|
+
});
|
|
2136
|
+
const nodes = model.fields.map(readField);
|
|
2137
|
+
const out = {
|
|
2138
|
+
name: camel(model.slug),
|
|
2139
|
+
title: model.name,
|
|
2140
|
+
kind: model.kind === "block" ? "block" : "entry",
|
|
2141
|
+
fields: nodes.map((n, i) => readToV2(n, `/fields/${i}`, nodes, ctx, true, "fields"))
|
|
2142
|
+
};
|
|
2143
|
+
if (model.description !== void 0) out.description = model.description;
|
|
2144
|
+
if (fieldsets.length) out.fieldsets = fieldsets;
|
|
2145
|
+
if (groups.length) out.groups = groups;
|
|
2146
|
+
return out;
|
|
2147
|
+
}
|
|
2148
|
+
/** A prod component's props → TypeSchema (kind "block"); prop groups read back as fieldsets. */
|
|
2149
|
+
function propsToTypeSchema(component, opts = {}) {
|
|
2150
|
+
const ctx = {
|
|
2151
|
+
onLoss: (path, feature, reason) => opts.onLoss?.({
|
|
2152
|
+
path,
|
|
2153
|
+
feature,
|
|
2154
|
+
reason
|
|
2155
|
+
}),
|
|
2156
|
+
sets: /* @__PURE__ */ new Map(),
|
|
2157
|
+
zoned: /* @__PURE__ */ new WeakSet(),
|
|
2158
|
+
modular: /* @__PURE__ */ new WeakSet(),
|
|
2159
|
+
blockModels: new Map((opts.blockModels ?? []).map((m) => [m.slug, m])),
|
|
2160
|
+
plans: opts.plans
|
|
2161
|
+
};
|
|
2162
|
+
const nodes = component.props.map(readProp);
|
|
2163
|
+
const fieldsets = [];
|
|
2164
|
+
const order = /* @__PURE__ */ new Map();
|
|
2165
|
+
const visit = (list, at) => list.forEach((n, i) => {
|
|
2166
|
+
const g = n.ui.group;
|
|
2167
|
+
if (g && !fieldsets.some((s) => s.name === g.id)) {
|
|
2168
|
+
const fs = {
|
|
2169
|
+
name: g.id,
|
|
2170
|
+
title: g.label ?? g.id
|
|
2171
|
+
};
|
|
2172
|
+
if (g.description !== void 0) fs.description = g.description;
|
|
2173
|
+
if (g.collapsed !== void 0) fs.collapsed = g.collapsed;
|
|
2174
|
+
if (g.columns !== void 0) fs.columns = g.columns;
|
|
2175
|
+
if (g.collapsible !== void 0) fs.collapsible = g.collapsible;
|
|
2176
|
+
if (g.layout !== void 0) fs.layout = g.layout;
|
|
2177
|
+
if (typeof g.order === "number") order.set(g.id, g.order);
|
|
2178
|
+
if (g.kind === "row") ctx.onLoss(`${at}/${i}/ui/group/kind`, "fieldset row", "V2 has no row fieldset; it reads as a section.");
|
|
2179
|
+
if (g.icon !== void 0) ctx.onLoss(`${at}/${i}/ui/group/icon`, "fieldset icon", "V2 sections have no icon.");
|
|
2180
|
+
fieldsets.push(fs);
|
|
2181
|
+
}
|
|
2182
|
+
if (n.fields) visit(n.fields, `${at}/${i}/fields`);
|
|
2183
|
+
});
|
|
2184
|
+
visit(nodes, "/fields");
|
|
2185
|
+
if (order.size) {
|
|
2186
|
+
const at = new Map(fieldsets.map((s, i) => [s.name, i]));
|
|
2187
|
+
fieldsets.sort((a, b) => (order.get(a.name) ?? at.get(a.name)) - (order.get(b.name) ?? at.get(b.name)));
|
|
2188
|
+
}
|
|
2189
|
+
const out = {
|
|
2190
|
+
name: camel(component.slug),
|
|
2191
|
+
title: component.name,
|
|
2192
|
+
kind: "block",
|
|
2193
|
+
fields: nodes.map((n, i) => readToV2(n, `/fields/${i}`, nodes, ctx, true, "props"))
|
|
2194
|
+
};
|
|
2195
|
+
if (component.description !== void 0 && component.description !== null) out.description = component.description;
|
|
2196
|
+
if (component.category !== void 0 && component.category !== "custom") out.category = capitalize(component.category);
|
|
2197
|
+
if (fieldsets.length) out.fieldsets = fieldsets;
|
|
2198
|
+
return out;
|
|
2199
|
+
}
|
|
2200
|
+
//#endregion
|
|
2201
|
+
export { CATEGORY_TO_PROD, fromTypeSchema, leafValuePlan, planFromProd, planToProd, propsToTypeSchema, toTypeSchema };
|
|
2202
|
+
|
|
2203
|
+
//# sourceMappingURL=schema.js.map
|