@aglyn/besigner-ui 1.0.0-beta.143
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/LICENSE +201 -0
- package/README.md +7 -0
- package/package.json +73 -0
- package/src/besigner.d.ts +88 -0
- package/src/besigner.js +89 -0
- package/src/besigner.js.map +1 -0
- package/src/index.d.ts +17 -0
- package/src/index.js +18 -0
- package/src/index.js.map +1 -0
- package/src/lib/box-styler/box-styler.d.ts +57 -0
- package/src/lib/box-styler/box-styler.js +240 -0
- package/src/lib/box-styler/box-styler.js.map +1 -0
- package/src/lib/box-styler/components/box-diagram.d.ts +89 -0
- package/src/lib/box-styler/components/box-diagram.js +661 -0
- package/src/lib/box-styler/components/box-diagram.js.map +1 -0
- package/src/lib/box-styler/components/legend.d.ts +56 -0
- package/src/lib/box-styler/components/legend.js +130 -0
- package/src/lib/box-styler/components/legend.js.map +1 -0
- package/src/lib/box-styler/components/spacing-editor.d.ts +55 -0
- package/src/lib/box-styler/components/spacing-editor.js +347 -0
- package/src/lib/box-styler/components/spacing-editor.js.map +1 -0
- package/src/lib/box-styler/constants.d.ts +17 -0
- package/src/lib/box-styler/constants.js +30 -0
- package/src/lib/box-styler/constants.js.map +1 -0
- package/src/lib/box-styler/index.d.ts +2 -0
- package/src/lib/box-styler/index.js +4 -0
- package/src/lib/box-styler/index.js.map +1 -0
- package/src/lib/box-styler/region-fills.d.ts +107 -0
- package/src/lib/box-styler/region-fills.js +139 -0
- package/src/lib/box-styler/region-fills.js.map +1 -0
- package/src/lib/box-styler/spacing-value.d.ts +104 -0
- package/src/lib/box-styler/spacing-value.js +223 -0
- package/src/lib/box-styler/spacing-value.js.map +1 -0
- package/src/lib/box-styler/types.d.ts +29 -0
- package/src/lib/box-styler/types.js +18 -0
- package/src/lib/box-styler/types.js.map +1 -0
- package/src/lib/components/accordion-list.component.d.ts +50 -0
- package/src/lib/components/accordion-list.component.js +228 -0
- package/src/lib/components/accordion-list.component.js.map +1 -0
- package/src/lib/components/add-controls.component.d.ts +22 -0
- package/src/lib/components/add-controls.component.js +50 -0
- package/src/lib/components/add-controls.component.js.map +1 -0
- package/src/lib/components/app-bar-breadcrumbs.component.d.ts +29 -0
- package/src/lib/components/app-bar-breadcrumbs.component.js +279 -0
- package/src/lib/components/app-bar-breadcrumbs.component.js.map +1 -0
- package/src/lib/components/app-bar-primary.component.d.ts +21 -0
- package/src/lib/components/app-bar-primary.component.js +108 -0
- package/src/lib/components/app-bar-primary.component.js.map +1 -0
- package/src/lib/components/app-bar-secondary.component.d.ts +21 -0
- package/src/lib/components/app-bar-secondary.component.js +94 -0
- package/src/lib/components/app-bar-secondary.component.js.map +1 -0
- package/src/lib/components/aside-panel.component.d.ts +23 -0
- package/src/lib/components/aside-panel.component.js +505 -0
- package/src/lib/components/aside-panel.component.js.map +1 -0
- package/src/lib/components/besigner-conflict-alert.component.d.ts +36 -0
- package/src/lib/components/besigner-conflict-alert.component.js +51 -0
- package/src/lib/components/besigner-conflict-alert.component.js.map +1 -0
- package/src/lib/components/besigner-dnd-context.component.d.ts +32 -0
- package/src/lib/components/besigner-dnd-context.component.js +75 -0
- package/src/lib/components/besigner-dnd-context.component.js.map +1 -0
- package/src/lib/components/besigner-draft-alert.component.d.ts +70 -0
- package/src/lib/components/besigner-draft-alert.component.js +155 -0
- package/src/lib/components/besigner-draft-alert.component.js.map +1 -0
- package/src/lib/components/besigner-root-provider.component.d.ts +33 -0
- package/src/lib/components/besigner-root-provider.component.js +68 -0
- package/src/lib/components/besigner-root-provider.component.js.map +1 -0
- package/src/lib/components/binding-preview-controls.component.d.ts +28 -0
- package/src/lib/components/binding-preview-controls.component.js +63 -0
- package/src/lib/components/binding-preview-controls.component.js.map +1 -0
- package/src/lib/components/closeable-drawer.component.d.ts +32 -0
- package/src/lib/components/closeable-drawer.component.js +134 -0
- package/src/lib/components/closeable-drawer.component.js.map +1 -0
- package/src/lib/components/component-accordion-list.d.ts +28 -0
- package/src/lib/components/component-accordion-list.js +205 -0
- package/src/lib/components/component-accordion-list.js.map +1 -0
- package/src/lib/components/component-icon.component.d.ts +32 -0
- package/src/lib/components/component-icon.component.js +51 -0
- package/src/lib/components/component-icon.component.js.map +1 -0
- package/src/lib/components/component-picker.d.ts +27 -0
- package/src/lib/components/component-picker.js +368 -0
- package/src/lib/components/component-picker.js.map +1 -0
- package/src/lib/components/components-grid-list.component.d.ts +31 -0
- package/src/lib/components/components-grid-list.component.js +162 -0
- package/src/lib/components/components-grid-list.component.js.map +1 -0
- package/src/lib/components/custom-css-form.component.d.ts +115 -0
- package/src/lib/components/custom-css-form.component.js +699 -0
- package/src/lib/components/custom-css-form.component.js.map +1 -0
- package/src/lib/components/device-preview-controls.component.d.ts +22 -0
- package/src/lib/components/device-preview-controls.component.js +150 -0
- package/src/lib/components/device-preview-controls.component.js.map +1 -0
- package/src/lib/components/dnd/canvas-drop-indicator.d.ts +20 -0
- package/src/lib/components/dnd/canvas-drop-indicator.js +61 -0
- package/src/lib/components/dnd/canvas-drop-indicator.js.map +1 -0
- package/src/lib/components/dnd/draggable-droppable.d.ts +31 -0
- package/src/lib/components/dnd/draggable-droppable.js +383 -0
- package/src/lib/components/dnd/draggable-droppable.js.map +1 -0
- package/src/lib/components/dnd/draggable.d.ts +42 -0
- package/src/lib/components/dnd/draggable.js +66 -0
- package/src/lib/components/dnd/draggable.js.map +1 -0
- package/src/lib/components/dnd/drop-indicator.d.ts +31 -0
- package/src/lib/components/dnd/drop-indicator.js +139 -0
- package/src/lib/components/dnd/drop-indicator.js.map +1 -0
- package/src/lib/components/dnd/droppable.d.ts +43 -0
- package/src/lib/components/dnd/droppable.js +63 -0
- package/src/lib/components/dnd/droppable.js.map +1 -0
- package/src/lib/components/element-card.component.d.ts +23 -0
- package/src/lib/components/element-card.component.js +49 -0
- package/src/lib/components/element-card.component.js.map +1 -0
- package/src/lib/components/element-classes-field.component.d.ts +41 -0
- package/src/lib/components/element-classes-field.component.js +140 -0
- package/src/lib/components/element-classes-field.component.js.map +1 -0
- package/src/lib/components/element-detail-overlay.component.d.ts +55 -0
- package/src/lib/components/element-detail-overlay.component.js +157 -0
- package/src/lib/components/element-detail-overlay.component.js.map +1 -0
- package/src/lib/components/element-detail.component.d.ts +56 -0
- package/src/lib/components/element-detail.component.js +171 -0
- package/src/lib/components/element-detail.component.js.map +1 -0
- package/src/lib/components/element-info-details.component.d.ts +18 -0
- package/src/lib/components/element-info-details.component.js +169 -0
- package/src/lib/components/element-info-details.component.js.map +1 -0
- package/src/lib/components/element-interactions-form.component.d.ts +21 -0
- package/src/lib/components/element-interactions-form.component.js +199 -0
- package/src/lib/components/element-interactions-form.component.js.map +1 -0
- package/src/lib/components/element-preview.component.d.ts +75 -0
- package/src/lib/components/element-preview.component.js +346 -0
- package/src/lib/components/element-preview.component.js.map +1 -0
- package/src/lib/components/element-props-form.component.d.ts +565 -0
- package/src/lib/components/element-props-form.component.js +2392 -0
- package/src/lib/components/element-props-form.component.js.map +1 -0
- package/src/lib/components/element-styles-form-template.component.d.ts +27 -0
- package/src/lib/components/element-styles-form-template.component.js +89 -0
- package/src/lib/components/element-styles-form-template.component.js.map +1 -0
- package/src/lib/components/element-styles-form.component.d.ts +52 -0
- package/src/lib/components/element-styles-form.component.js +1350 -0
- package/src/lib/components/element-styles-form.component.js.map +1 -0
- package/src/lib/components/empty-document-slot.d.ts +39 -0
- package/src/lib/components/empty-document-slot.js +121 -0
- package/src/lib/components/empty-document-slot.js.map +1 -0
- package/src/lib/components/empty-results.d.ts +22 -0
- package/src/lib/components/empty-results.js +131 -0
- package/src/lib/components/empty-results.js.map +1 -0
- package/src/lib/components/history-controls.component.d.ts +21 -0
- package/src/lib/components/history-controls.component.js +67 -0
- package/src/lib/components/history-controls.component.js.map +1 -0
- package/src/lib/components/inline-markdown-editor.component.d.ts +17 -0
- package/src/lib/components/inline-markdown-editor.component.js +220 -0
- package/src/lib/components/inline-markdown-editor.component.js.map +1 -0
- package/src/lib/components/inline-text-editor.component.d.ts +48 -0
- package/src/lib/components/inline-text-editor.component.js +905 -0
- package/src/lib/components/inline-text-editor.component.js.map +1 -0
- package/src/lib/components/insert-token-menu.component.d.ts +86 -0
- package/src/lib/components/insert-token-menu.component.js +232 -0
- package/src/lib/components/insert-token-menu.component.js.map +1 -0
- package/src/lib/components/instance-attr-overrides.component.d.ts +50 -0
- package/src/lib/components/instance-attr-overrides.component.js +298 -0
- package/src/lib/components/instance-attr-overrides.component.js.map +1 -0
- package/src/lib/components/interact-controls.component.d.ts +22 -0
- package/src/lib/components/interact-controls.component.js +74 -0
- package/src/lib/components/interact-controls.component.js.map +1 -0
- package/src/lib/components/markdown-attribute-field.component.d.ts +40 -0
- package/src/lib/components/markdown-attribute-field.component.js +103 -0
- package/src/lib/components/markdown-attribute-field.component.js.map +1 -0
- package/src/lib/components/node-card.d.ts +24 -0
- package/src/lib/components/node-card.js +86 -0
- package/src/lib/components/node-card.js.map +1 -0
- package/src/lib/components/node-context-menu.d.ts +25 -0
- package/src/lib/components/node-context-menu.js +558 -0
- package/src/lib/components/node-context-menu.js.map +1 -0
- package/src/lib/components/node-leaf.d.ts +39 -0
- package/src/lib/components/node-leaf.js +628 -0
- package/src/lib/components/node-leaf.js.map +1 -0
- package/src/lib/components/node-outline.d.ts +24 -0
- package/src/lib/components/node-outline.js +156 -0
- package/src/lib/components/node-outline.js.map +1 -0
- package/src/lib/components/node-overlay.d.ts +23 -0
- package/src/lib/components/node-overlay.js +299 -0
- package/src/lib/components/node-overlay.js.map +1 -0
- package/src/lib/components/node-quick-actions.d.ts +24 -0
- package/src/lib/components/node-quick-actions.js +284 -0
- package/src/lib/components/node-quick-actions.js.map +1 -0
- package/src/lib/components/node-tree-view.d.ts +106 -0
- package/src/lib/components/node-tree-view.js +820 -0
- package/src/lib/components/node-tree-view.js.map +1 -0
- package/src/lib/components/panel-controls.component.d.ts +22 -0
- package/src/lib/components/panel-controls.component.js +76 -0
- package/src/lib/components/panel-controls.component.js.map +1 -0
- package/src/lib/components/picker-search-field.d.ts +38 -0
- package/src/lib/components/picker-search-field.js +79 -0
- package/src/lib/components/picker-search-field.js.map +1 -0
- package/src/lib/components/plugin-settings-field.component.d.ts +38 -0
- package/src/lib/components/plugin-settings-field.component.js +264 -0
- package/src/lib/components/plugin-settings-field.component.js.map +1 -0
- package/src/lib/components/properties-dialog.component.d.ts +22 -0
- package/src/lib/components/properties-dialog.component.js +40 -0
- package/src/lib/components/properties-dialog.component.js.map +1 -0
- package/src/lib/components/property-binding-field.component.d.ts +142 -0
- package/src/lib/components/property-binding-field.component.js +325 -0
- package/src/lib/components/property-binding-field.component.js.map +1 -0
- package/src/lib/components/property-values-form.component.d.ts +43 -0
- package/src/lib/components/property-values-form.component.js +223 -0
- package/src/lib/components/property-values-form.component.js.map +1 -0
- package/src/lib/components/scheme-preview-controls.component.d.ts +26 -0
- package/src/lib/components/scheme-preview-controls.component.js +56 -0
- package/src/lib/components/scheme-preview-controls.component.js.map +1 -0
- package/src/lib/components/screen-link-field.component.d.ts +118 -0
- package/src/lib/components/screen-link-field.component.js +282 -0
- package/src/lib/components/screen-link-field.component.js.map +1 -0
- package/src/lib/components/site-theme-color-tokens-provider.component.d.ts +33 -0
- package/src/lib/components/site-theme-color-tokens-provider.component.js +53 -0
- package/src/lib/components/site-theme-color-tokens-provider.component.js.map +1 -0
- package/src/lib/components/subtree-json-dialog.component.d.ts +46 -0
- package/src/lib/components/subtree-json-dialog.component.js +125 -0
- package/src/lib/components/subtree-json-dialog.component.js.map +1 -0
- package/src/lib/components/token-pill.component.d.ts +51 -0
- package/src/lib/components/token-pill.component.js +164 -0
- package/src/lib/components/token-pill.component.js.map +1 -0
- package/src/lib/components/token-text-field.component.d.ts +146 -0
- package/src/lib/components/token-text-field.component.js +603 -0
- package/src/lib/components/token-text-field.component.js.map +1 -0
- package/src/lib/components/tree/tree-list.d.ts +6 -0
- package/src/lib/components/tree/tree-list.js +108 -0
- package/src/lib/components/tree/tree-list.js.map +1 -0
- package/src/lib/components/viewport-canvas.component.d.ts +23 -0
- package/src/lib/components/viewport-canvas.component.js +128 -0
- package/src/lib/components/viewport-canvas.component.js.map +1 -0
- package/src/lib/components/viewport-frame.component.d.ts +47 -0
- package/src/lib/components/viewport-frame.component.js +332 -0
- package/src/lib/components/viewport-frame.component.js.map +1 -0
- package/src/lib/components/viewport-root.component.d.ts +22 -0
- package/src/lib/components/viewport-root.component.js +112 -0
- package/src/lib/components/viewport-root.component.js.map +1 -0
- package/src/lib/components/viewport-zoom-controls.d.ts +29 -0
- package/src/lib/components/viewport-zoom-controls.js +147 -0
- package/src/lib/components/viewport-zoom-controls.js.map +1 -0
- package/src/lib/components/workspace-editor.component.d.ts +23 -0
- package/src/lib/components/workspace-editor.component.js +191 -0
- package/src/lib/components/workspace-editor.component.js.map +1 -0
- package/src/lib/components/workspace-panel.component.d.ts +28 -0
- package/src/lib/components/workspace-panel.component.js +147 -0
- package/src/lib/components/workspace-panel.component.js.map +1 -0
- package/src/lib/constants/sample-data.d.ts +18 -0
- package/src/lib/constants/sample-data.js +106 -0
- package/src/lib/constants/sample-data.js.map +1 -0
- package/src/lib/constants/shared.d.ts +17 -0
- package/src/lib/constants/shared.js +18 -0
- package/src/lib/constants/shared.js.map +1 -0
- package/src/lib/contexts/besigner-app-context.d.ts +30 -0
- package/src/lib/contexts/besigner-app-context.js +41 -0
- package/src/lib/contexts/besigner-app-context.js.map +1 -0
- package/src/lib/contexts/binding-picker-context.d.ts +78 -0
- package/src/lib/contexts/binding-picker-context.js +21 -0
- package/src/lib/contexts/binding-picker-context.js.map +1 -0
- package/src/lib/contexts/canvas-host-tokens-context.d.ts +49 -0
- package/src/lib/contexts/canvas-host-tokens-context.js +63 -0
- package/src/lib/contexts/canvas-host-tokens-context.js.map +1 -0
- package/src/lib/contexts/canvas-reveal-context.d.ts +32 -0
- package/src/lib/contexts/canvas-reveal-context.js +34 -0
- package/src/lib/contexts/canvas-reveal-context.js.map +1 -0
- package/src/lib/contexts/component-promotion-context.d.ts +89 -0
- package/src/lib/contexts/component-promotion-context.js +21 -0
- package/src/lib/contexts/component-promotion-context.js.map +1 -0
- package/src/lib/contexts/components-drawer-context.provider.d.ts +32 -0
- package/src/lib/contexts/components-drawer-context.provider.js +80 -0
- package/src/lib/contexts/components-drawer-context.provider.js.map +1 -0
- package/src/lib/contexts/element-drawer-context.d.ts +1005 -0
- package/src/lib/contexts/element-drawer-context.js +45 -0
- package/src/lib/contexts/element-drawer-context.js.map +1 -0
- package/src/lib/contexts/inspected-selection.d.ts +32 -0
- package/src/lib/contexts/inspected-selection.js +38 -0
- package/src/lib/contexts/inspected-selection.js.map +1 -0
- package/src/lib/contexts/inspector-extras-context.d.ts +56 -0
- package/src/lib/contexts/inspector-extras-context.js +35 -0
- package/src/lib/contexts/inspector-extras-context.js.map +1 -0
- package/src/lib/contexts/interactions-context.d.ts +99 -0
- package/src/lib/contexts/interactions-context.js +22 -0
- package/src/lib/contexts/interactions-context.js.map +1 -0
- package/src/lib/contexts/layout-chrome-context.d.ts +37 -0
- package/src/lib/contexts/layout-chrome-context.js +75 -0
- package/src/lib/contexts/layout-chrome-context.js.map +1 -0
- package/src/lib/contexts/media-asset-facts-context.d.ts +74 -0
- package/src/lib/contexts/media-asset-facts-context.js +27 -0
- package/src/lib/contexts/media-asset-facts-context.js.map +1 -0
- package/src/lib/contexts/media-picker-context.d.ts +88 -0
- package/src/lib/contexts/media-picker-context.js +21 -0
- package/src/lib/contexts/media-picker-context.js.map +1 -0
- package/src/lib/contexts/rendered-canvas-elements.d.ts +42 -0
- package/src/lib/contexts/rendered-canvas-elements.js +79 -0
- package/src/lib/contexts/rendered-canvas-elements.js.map +1 -0
- package/src/lib/contexts/repeat-record-context.d.ts +38 -0
- package/src/lib/contexts/repeat-record-context.js +21 -0
- package/src/lib/contexts/repeat-record-context.js.map +1 -0
- package/src/lib/contexts/repeat-rows-context.d.ts +53 -0
- package/src/lib/contexts/repeat-rows-context.js +38 -0
- package/src/lib/contexts/repeat-rows-context.js.map +1 -0
- package/src/lib/contexts/toolbar-extras-context.d.ts +31 -0
- package/src/lib/contexts/toolbar-extras-context.js +33 -0
- package/src/lib/contexts/toolbar-extras-context.js.map +1 -0
- package/src/lib/drafts/besigner-draft-store.d.ts +110 -0
- package/src/lib/drafts/besigner-draft-store.js +125 -0
- package/src/lib/drafts/besigner-draft-store.js.map +1 -0
- package/src/lib/drafts/besigner-server-draft.d.ts +130 -0
- package/src/lib/drafts/besigner-server-draft.js +211 -0
- package/src/lib/drafts/besigner-server-draft.js.map +1 -0
- package/src/lib/form-fields/components/shared/inline-form-control.d.ts +32 -0
- package/src/lib/form-fields/components/shared/inline-form-control.js +85 -0
- package/src/lib/form-fields/components/shared/inline-form-control.js.map +1 -0
- package/src/lib/form-fields/components/shared/toggle-button-form-control.d.ts +33 -0
- package/src/lib/form-fields/components/shared/toggle-button-form-control.js +83 -0
- package/src/lib/form-fields/components/shared/toggle-button-form-control.js.map +1 -0
- package/src/lib/form-fields/form-fields.d.ts +20 -0
- package/src/lib/form-fields/form-fields.js +21 -0
- package/src/lib/form-fields/form-fields.js.map +1 -0
- package/src/lib/form-fields/index.d.ts +1 -0
- package/src/lib/form-fields/index.js +3 -0
- package/src/lib/form-fields/index.js.map +1 -0
- package/src/lib/hooks/use-add-element-drawer-callback.d.ts +28 -0
- package/src/lib/hooks/use-add-element-drawer-callback.js +112 -0
- package/src/lib/hooks/use-add-element-drawer-callback.js.map +1 -0
- package/src/lib/hooks/use-aglyn-besigner-flag.d.ts +23 -0
- package/src/lib/hooks/use-aglyn-besigner-flag.js +47 -0
- package/src/lib/hooks/use-aglyn-besigner-flag.js.map +1 -0
- package/src/lib/hooks/use-aglyn-besigner-panel-value.d.ts +23 -0
- package/src/lib/hooks/use-aglyn-besigner-panel-value.js +54 -0
- package/src/lib/hooks/use-aglyn-besigner-panel-value.js.map +1 -0
- package/src/lib/hooks/use-aglyn-besigner-panel.d.ts +23 -0
- package/src/lib/hooks/use-aglyn-besigner-panel.js +47 -0
- package/src/lib/hooks/use-aglyn-besigner-panel.js.map +1 -0
- package/src/lib/hooks/use-anchored-rect.d.ts +68 -0
- package/src/lib/hooks/use-anchored-rect.js +131 -0
- package/src/lib/hooks/use-anchored-rect.js.map +1 -0
- package/src/lib/hooks/use-besigner-app-context.d.ts +18 -0
- package/src/lib/hooks/use-besigner-app-context.js +19 -0
- package/src/lib/hooks/use-besigner-app-context.js.map +1 -0
- package/src/lib/hooks/use-besigner-document.d.ts +309 -0
- package/src/lib/hooks/use-besigner-document.js +500 -0
- package/src/lib/hooks/use-besigner-document.js.map +1 -0
- package/src/lib/hooks/use-besigner-draft.d.ts +209 -0
- package/src/lib/hooks/use-besigner-draft.js +429 -0
- package/src/lib/hooks/use-besigner-draft.js.map +1 -0
- package/src/lib/hooks/use-clipboard-callbacks.d.ts +29 -0
- package/src/lib/hooks/use-clipboard-callbacks.js +82 -0
- package/src/lib/hooks/use-clipboard-callbacks.js.map +1 -0
- package/src/lib/hooks/use-clipboard-shortcuts.d.ts +52 -0
- package/src/lib/hooks/use-clipboard-shortcuts.js +102 -0
- package/src/lib/hooks/use-clipboard-shortcuts.js.map +1 -0
- package/src/lib/hooks/use-component-propagation-notice.d.ts +96 -0
- package/src/lib/hooks/use-component-propagation-notice.js +177 -0
- package/src/lib/hooks/use-component-propagation-notice.js.map +1 -0
- package/src/lib/hooks/use-debounced-commit.d.ts +43 -0
- package/src/lib/hooks/use-debounced-commit.js +88 -0
- package/src/lib/hooks/use-debounced-commit.js.map +1 -0
- package/src/lib/hooks/use-delete-element-callback.d.ts +24 -0
- package/src/lib/hooks/use-delete-element-callback.js +82 -0
- package/src/lib/hooks/use-delete-element-callback.js.map +1 -0
- package/src/lib/hooks/use-detail-hover-intent.d.ts +76 -0
- package/src/lib/hooks/use-detail-hover-intent.js +123 -0
- package/src/lib/hooks/use-detail-hover-intent.js.map +1 -0
- package/src/lib/hooks/use-document-repair-callbacks.d.ts +50 -0
- package/src/lib/hooks/use-document-repair-callbacks.js +237 -0
- package/src/lib/hooks/use-document-repair-callbacks.js.map +1 -0
- package/src/lib/hooks/use-insert-token-options.d.ts +52 -0
- package/src/lib/hooks/use-insert-token-options.js +230 -0
- package/src/lib/hooks/use-insert-token-options.js.map +1 -0
- package/src/lib/hooks/use-leaf-drag.d.ts +24 -0
- package/src/lib/hooks/use-leaf-drag.js +28 -0
- package/src/lib/hooks/use-leaf-drag.js.map +1 -0
- package/src/lib/hooks/use-leaf-drop.d.ts +31 -0
- package/src/lib/hooks/use-leaf-drop.js +43 -0
- package/src/lib/hooks/use-leaf-drop.js.map +1 -0
- package/src/lib/hooks/use-markdown-media-picker.d.ts +63 -0
- package/src/lib/hooks/use-markdown-media-picker.js +110 -0
- package/src/lib/hooks/use-markdown-media-picker.js.map +1 -0
- package/src/lib/hooks/use-media-asset-facts-overlay.d.ts +43 -0
- package/src/lib/hooks/use-media-asset-facts-overlay.js +133 -0
- package/src/lib/hooks/use-media-asset-facts-overlay.js.map +1 -0
- package/src/lib/hooks/use-move-node-callbacks.d.ts +22 -0
- package/src/lib/hooks/use-move-node-callbacks.js +57 -0
- package/src/lib/hooks/use-move-node-callbacks.js.map +1 -0
- package/src/lib/hooks/use-node-with-host-tokens.d.ts +42 -0
- package/src/lib/hooks/use-node-with-host-tokens.js +59 -0
- package/src/lib/hooks/use-node-with-host-tokens.js.map +1 -0
- package/src/lib/hooks/use-picker-filter.d.ts +61 -0
- package/src/lib/hooks/use-picker-filter.js +122 -0
- package/src/lib/hooks/use-picker-filter.js.map +1 -0
- package/src/lib/hooks/use-repeat-preview.d.ts +64 -0
- package/src/lib/hooks/use-repeat-preview.js +214 -0
- package/src/lib/hooks/use-repeat-preview.js.map +1 -0
- package/src/lib/hooks/use-repeat-sources.d.ts +17 -0
- package/src/lib/hooks/use-repeat-sources.js +41 -0
- package/src/lib/hooks/use-repeat-sources.js.map +1 -0
- package/src/lib/hooks/use-visible-component-categories.d.ts +37 -0
- package/src/lib/hooks/use-visible-component-categories.js +79 -0
- package/src/lib/hooks/use-visible-component-categories.js.map +1 -0
- package/src/lib/utils/active-host-theme.d.ts +28 -0
- package/src/lib/utils/active-host-theme.js +77 -0
- package/src/lib/utils/active-host-theme.js.map +1 -0
- package/src/lib/utils/attr-target.d.ts +170 -0
- package/src/lib/utils/attr-target.js +229 -0
- package/src/lib/utils/attr-target.js.map +1 -0
- package/src/lib/utils/attribute-field-value.d.ts +21 -0
- package/src/lib/utils/attribute-field-value.js +28 -0
- package/src/lib/utils/attribute-field-value.js.map +1 -0
- package/src/lib/utils/canvas-context-menu.d.ts +28 -0
- package/src/lib/utils/canvas-context-menu.js +56 -0
- package/src/lib/utils/canvas-context-menu.js.map +1 -0
- package/src/lib/utils/canvas-reveal.d.ts +115 -0
- package/src/lib/utils/canvas-reveal.js +165 -0
- package/src/lib/utils/canvas-reveal.js.map +1 -0
- package/src/lib/utils/describe-element.d.ts +72 -0
- package/src/lib/utils/describe-element.js +159 -0
- package/src/lib/utils/describe-element.js.map +1 -0
- package/src/lib/utils/device-preview-styles.d.ts +89 -0
- package/src/lib/utils/device-preview-styles.js +228 -0
- package/src/lib/utils/device-preview-styles.js.map +1 -0
- package/src/lib/utils/docs-help.d.ts +22 -0
- package/src/lib/utils/docs-help.generated.d.ts +47 -0
- package/src/lib/utils/docs-help.generated.js +229 -0
- package/src/lib/utils/docs-help.generated.js.map +1 -0
- package/src/lib/utils/docs-help.js +37 -0
- package/src/lib/utils/docs-help.js.map +1 -0
- package/src/lib/utils/held-answers-store.d.ts +59 -0
- package/src/lib/utils/held-answers-store.js +94 -0
- package/src/lib/utils/held-answers-store.js.map +1 -0
- package/src/lib/utils/in-place-edit-surface.d.ts +118 -0
- package/src/lib/utils/in-place-edit-surface.js +164 -0
- package/src/lib/utils/in-place-edit-surface.js.map +1 -0
- package/src/lib/utils/inline-markdown-edit.store.d.ts +71 -0
- package/src/lib/utils/inline-markdown-edit.store.js +90 -0
- package/src/lib/utils/inline-markdown-edit.store.js.map +1 -0
- package/src/lib/utils/inline-text-edit.store.d.ts +85 -0
- package/src/lib/utils/inline-text-edit.store.js +78 -0
- package/src/lib/utils/inline-text-edit.store.js.map +1 -0
- package/src/lib/utils/instance-leaf-hit.d.ts +39 -0
- package/src/lib/utils/instance-leaf-hit.js +56 -0
- package/src/lib/utils/instance-leaf-hit.js.map +1 -0
- package/src/lib/utils/muted-classes.d.ts +76 -0
- package/src/lib/utils/muted-classes.js +108 -0
- package/src/lib/utils/muted-classes.js.map +1 -0
- package/src/lib/utils/muted-styles.d.ts +125 -0
- package/src/lib/utils/muted-styles.js +193 -0
- package/src/lib/utils/muted-styles.js.map +1 -0
- package/src/lib/utils/numeric-text-value.d.ts +42 -0
- package/src/lib/utils/numeric-text-value.js +47 -0
- package/src/lib/utils/numeric-text-value.js.map +1 -0
- package/src/lib/utils/preset-interactions.d.ts +37 -0
- package/src/lib/utils/preset-interactions.js +87 -0
- package/src/lib/utils/preset-interactions.js.map +1 -0
- package/src/lib/utils/publish-failure-message.d.ts +35 -0
- package/src/lib/utils/publish-failure-message.js +51 -0
- package/src/lib/utils/publish-failure-message.js.map +1 -0
- package/src/lib/utils/rank-picker-results.d.ts +45 -0
- package/src/lib/utils/rank-picker-results.js +136 -0
- package/src/lib/utils/rank-picker-results.js.map +1 -0
- package/src/lib/utils/responsive-sx.d.ts +65 -0
- package/src/lib/utils/responsive-sx.js +129 -0
- package/src/lib/utils/responsive-sx.js.map +1 -0
- package/src/lib/utils/rich-text-commands.d.ts +28 -0
- package/src/lib/utils/rich-text-commands.js +43 -0
- package/src/lib/utils/rich-text-commands.js.map +1 -0
- package/src/lib/utils/sanitize-rich-text.d.ts +52 -0
- package/src/lib/utils/sanitize-rich-text.js +173 -0
- package/src/lib/utils/sanitize-rich-text.js.map +1 -0
- package/src/lib/utils/state-sx.d.ts +255 -0
- package/src/lib/utils/state-sx.js +338 -0
- package/src/lib/utils/state-sx.js.map +1 -0
- package/src/lib/utils/style-field-groups.d.ts +136 -0
- package/src/lib/utils/style-field-groups.js +874 -0
- package/src/lib/utils/style-field-groups.js.map +1 -0
- package/src/lib/utils/style-field-search.d.ts +84 -0
- package/src/lib/utils/style-field-search.js +505 -0
- package/src/lib/utils/style-field-search.js.map +1 -0
- package/src/lib/utils/style-target.d.ts +69 -0
- package/src/lib/utils/style-target.js +203 -0
- package/src/lib/utils/style-target.js.map +1 -0
- package/src/lib/utils/theme-scale-options.d.ts +169 -0
- package/src/lib/utils/theme-scale-options.js +702 -0
- package/src/lib/utils/theme-scale-options.js.map +1 -0
- package/src/lib/utils/token-editable-dom.d.ts +82 -0
- package/src/lib/utils/token-editable-dom.js +280 -0
- package/src/lib/utils/token-editable-dom.js.map +1 -0
- package/src/lib/utils/token-segments.d.ts +111 -0
- package/src/lib/utils/token-segments.js +246 -0
- package/src/lib/utils/token-segments.js.map +1 -0
- package/src/lib/utils/visibility-styles.d.ts +38 -0
- package/src/lib/utils/visibility-styles.js +54 -0
- package/src/lib/utils/visibility-styles.js.map +1 -0
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
17
|
+
import { _ as _object_without_properties_loose } from "@swc/helpers/_/_object_without_properties_loose";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
19
|
+
import { attributeFieldValueShape, matchComponentPropToken, REUSABLE_PROP_KINDS, reusablePropBindsToField, unofferedChoiceValues } from "@aglyn/aglyn";
|
|
20
|
+
import { FormFieldGrid, useFieldApi } from "@aglyn/shared-ui-jsx-forms";
|
|
21
|
+
import { Box, ButtonBase, TextField } from "@mui/material";
|
|
22
|
+
import { forwardRef, useMemo, useState } from "react";
|
|
23
|
+
import { componentPropBindingOptions } from "../hooks/use-insert-token-options.js";
|
|
24
|
+
import { TOKEN_PILL_ATTR, TOKEN_PILL_GROUP_ATTR } from "../utils/token-editable-dom.js";
|
|
25
|
+
import { resolveTokenLabel } from "../utils/token-segments.js";
|
|
26
|
+
import { InsertTokenMenu } from "./insert-token-menu.component.js";
|
|
27
|
+
import { TokenPillPopover, tokenPillContainerSx } from "./token-pill.component.js";
|
|
28
|
+
/**
|
|
29
|
+
* Binding a field that has no text to type a token into.
|
|
30
|
+
*
|
|
31
|
+
* A free-text attribute has always taken `{{prop.headline}}`: the token is
|
|
32
|
+
* typed, or picked with the `{}` in the box, and substitution does the rest.
|
|
33
|
+
* A switch, a checkbox, a dropdown or an icon picker has no text to type into,
|
|
34
|
+
* so inside a reusable component it could only ever hold the component's own
|
|
35
|
+
* value — and a property of the matching kind had nothing to drive.
|
|
36
|
+
*
|
|
37
|
+
* This wraps such a field, inside a component editor only. Unbound, it is the
|
|
38
|
+
* field exactly as before, with a `{}` among its corner controls. Bound, the
|
|
39
|
+
* control gives way to the property it is bound to, drawn as the pill a text
|
|
40
|
+
* field would draw — because the control would otherwise go on showing a
|
|
41
|
+
* value the page no longer uses.
|
|
42
|
+
*
|
|
43
|
+
* The stored value is the same exact `{{prop.<name>}}` token a text field
|
|
44
|
+
* holds, so the graft needs nothing new to find it, and a binding to a
|
|
45
|
+
* property of the wrong kind is simply never offered.
|
|
46
|
+
*/ /** Mapper key for {@link PropertyBindingField} (editor-internal, never persisted). */ export const PROPERTY_BINDING_FIELD_COMPONENT = 'aglyn-property-binding-field';
|
|
47
|
+
/**
|
|
48
|
+
* The names of the property kinds a declared field can be bound to, in the
|
|
49
|
+
* panel's own words — `Yes / no or Checkbox` for a switch, `Color` for a color
|
|
50
|
+
* picker — for the sentences that tell an author what to add.
|
|
51
|
+
*
|
|
52
|
+
* Every kind is tried as it can be declared (bare, with answers, taking
|
|
53
|
+
* several), so a list-holding dropdown names the kinds that hold lists.
|
|
54
|
+
*/ export function propertyKindsBindableTo(declared) {
|
|
55
|
+
var _labels_;
|
|
56
|
+
const labels = Object.keys(REUSABLE_PROP_KINDS).filter((type)=>[
|
|
57
|
+
{
|
|
58
|
+
type
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
type,
|
|
62
|
+
options: [
|
|
63
|
+
{
|
|
64
|
+
value: 'a'
|
|
65
|
+
}
|
|
66
|
+
]
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
type,
|
|
70
|
+
options: [
|
|
71
|
+
{
|
|
72
|
+
value: 'a'
|
|
73
|
+
}
|
|
74
|
+
],
|
|
75
|
+
settings: {
|
|
76
|
+
isMulti: true
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
].some((candidate)=>reusablePropBindsToField(candidate, declared))).map((type)=>REUSABLE_PROP_KINDS[type].label);
|
|
80
|
+
if (labels.length <= 1) return (_labels_ = labels[0]) != null ? _labels_ : '';
|
|
81
|
+
return `${labels.slice(0, -1).join(', ')} or ${labels[labels.length - 1]}`;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The field, wrapped to take a property binding when it can, or unchanged.
|
|
85
|
+
*
|
|
86
|
+
* Every field kind that holds a value can be bound (AGL-2893), to the
|
|
87
|
+
* properties that hold the same shape of value (`reusablePropBindsToField`):
|
|
88
|
+
* a switch to a Yes / no, a color picker to a Color, a dropdown that takes
|
|
89
|
+
* several answers to a property that holds several.
|
|
90
|
+
*
|
|
91
|
+
* Unchanged outside a component or layout editor, for a free-text field — it
|
|
92
|
+
* takes any property's token typed into it — for a read-only or disabled
|
|
93
|
+
* field (a control that writes an unwritable field is a lie), and whenever the
|
|
94
|
+
* control to fall back to is unknown, since a wrapper with nothing to render
|
|
95
|
+
* would blank the field.
|
|
96
|
+
*/ export function withPropertyBinding(field, options) {
|
|
97
|
+
const { declaredComponent, declaredField, componentProps, control, tokenLabelContext, owner = 'component' } = options;
|
|
98
|
+
if (!componentProps || !control) return field;
|
|
99
|
+
const declared = _extends({}, declaredField != null ? declaredField : field, {
|
|
100
|
+
component: declaredComponent
|
|
101
|
+
});
|
|
102
|
+
if (attributeFieldValueShape(declared) === undefined) return field;
|
|
103
|
+
if (field['isReadOnly'] || field['isDisabled']) return field;
|
|
104
|
+
const bindable = componentProps.filter((prop)=>reusablePropBindsToField(prop, declared));
|
|
105
|
+
const kinds = propertyKindsBindableTo(declared);
|
|
106
|
+
return _extends({}, field, {
|
|
107
|
+
component: PROPERTY_BINDING_FIELD_COMPONENT,
|
|
108
|
+
bindingControl: control,
|
|
109
|
+
bindingOptions: componentPropBindingOptions(bindable, owner),
|
|
110
|
+
bindingProps: bindable,
|
|
111
|
+
bindingKinds: kinds,
|
|
112
|
+
bindingEmptyText: `This ${owner} has no ${kinds || 'matching'} properties yet. Add one ` + 'under File ▸ Properties…, then bind it here.',
|
|
113
|
+
tokenLabelContext
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/** The mapper entry split into the component and the defaults it carries. */ function splitControl(control) {
|
|
117
|
+
if (!control) return {
|
|
118
|
+
Control: undefined,
|
|
119
|
+
defaults: {}
|
|
120
|
+
};
|
|
121
|
+
if (typeof control === 'object' && 'component' in control) {
|
|
122
|
+
const { component } = control, defaults = _object_without_properties_loose(control, [
|
|
123
|
+
"component"
|
|
124
|
+
]);
|
|
125
|
+
return {
|
|
126
|
+
Control: component,
|
|
127
|
+
defaults
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
return {
|
|
131
|
+
Control: control,
|
|
132
|
+
defaults: {}
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* The bound property, drawn INSIDE a real outlined field so the label, notch,
|
|
137
|
+
* helper text and focus ring are the ones every other attribute has.
|
|
138
|
+
*
|
|
139
|
+
* The pill is a button rather than the passive span a text field draws: here
|
|
140
|
+
* it is the whole value, so it has to be reachable by keyboard, and pressing
|
|
141
|
+
* it is how the binding is changed or removed.
|
|
142
|
+
*/ const BoundPropertyInput = /*#__PURE__*/ forwardRef(function BoundPropertyInput(props, ref) {
|
|
143
|
+
const { token, resolved, onOpen, fieldLabel, className, disabled, id, onFocus, onBlur, 'aria-describedby': describedBy } = props;
|
|
144
|
+
const pillAttributes = {
|
|
145
|
+
[TOKEN_PILL_ATTR]: token,
|
|
146
|
+
[TOKEN_PILL_GROUP_ATTR]: resolved.known ? resolved.group : 'unknown'
|
|
147
|
+
};
|
|
148
|
+
return /*#__PURE__*/ _jsx(Box, {
|
|
149
|
+
className: className,
|
|
150
|
+
sx: _extends({}, tokenPillContainerSx, {
|
|
151
|
+
display: 'flex',
|
|
152
|
+
alignItems: 'center'
|
|
153
|
+
}),
|
|
154
|
+
children: /*#__PURE__*/ _jsx(ButtonBase, _extends({
|
|
155
|
+
ref: ref,
|
|
156
|
+
id: id,
|
|
157
|
+
disabled: disabled,
|
|
158
|
+
"aria-describedby": describedBy,
|
|
159
|
+
"aria-label": `${fieldLabel ? `${fieldLabel}: ` : ''}bound to ${resolved.label}. Change or remove the binding`,
|
|
160
|
+
title: token,
|
|
161
|
+
onFocus: onFocus,
|
|
162
|
+
onBlur: onBlur,
|
|
163
|
+
onClick: (event)=>onOpen(event.currentTarget)
|
|
164
|
+
}, pillAttributes, {
|
|
165
|
+
children: resolved.label
|
|
166
|
+
}))
|
|
167
|
+
});
|
|
168
|
+
});
|
|
169
|
+
/**
|
|
170
|
+
* What a bound field says under the property it follows, and whether that is
|
|
171
|
+
* a problem.
|
|
172
|
+
*
|
|
173
|
+
* Three ways a binding can be wrong while still looking bound, each named in
|
|
174
|
+
* words an author can act on: the property is gone (it was renamed or
|
|
175
|
+
* removed, so nothing substitutes), the property is the wrong kind (a token
|
|
176
|
+
* written some other way than this field's picker), or — for a dropdown —
|
|
177
|
+
* some of the property's choices are values the dropdown does not offer.
|
|
178
|
+
*/ export function describePropertyBinding(options) {
|
|
179
|
+
const { token, resolved, bindingProps, bindingKinds, fieldOptions } = options;
|
|
180
|
+
const name = matchComponentPropToken(token);
|
|
181
|
+
const prop = (bindingProps != null ? bindingProps : []).find((entry)=>(entry == null ? void 0 : entry.name) === name);
|
|
182
|
+
if (!prop) {
|
|
183
|
+
return resolved.known ? {
|
|
184
|
+
text: `${resolved.label} is not a ${bindingKinds || 'matching'} ` + 'property, so it cannot set this field. Bind one that is, or ' + 'remove the binding.',
|
|
185
|
+
error: true
|
|
186
|
+
} : {
|
|
187
|
+
text: 'This component declares no property by that name, so pages ' + 'cannot set it. Bind a property it declares, or remove the ' + 'binding.',
|
|
188
|
+
error: true
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
const unoffered = unofferedChoiceValues(prop, fieldOptions);
|
|
192
|
+
if (unoffered.length) {
|
|
193
|
+
const offered = (Array.isArray(fieldOptions) ? fieldOptions : []).map((option)=>{
|
|
194
|
+
const { value, label } = option != null ? option : {};
|
|
195
|
+
const text = String(value != null ? value : '');
|
|
196
|
+
return label != null && String(label) !== text ? `${String(label)} (${text})` : text;
|
|
197
|
+
}).filter(Boolean);
|
|
198
|
+
return {
|
|
199
|
+
text: `This field does not offer ${unoffered.join(', ')}, so a page that ` + `chooses ${unoffered.length === 1 ? 'it' : 'one of those'} gets the ` + `field's own default. Give ${resolved.label} values from: ` + `${offered.join(', ')}.`,
|
|
200
|
+
error: true
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
return {
|
|
204
|
+
text: `Each page sets this with the ${resolved.label} property.`,
|
|
205
|
+
error: false
|
|
206
|
+
};
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The data-driven-forms field registered as
|
|
210
|
+
* {@link PROPERTY_BINDING_FIELD_COMPONENT}. The token flows through
|
|
211
|
+
* react-final-form like any other value, so the Attributes panel's debounced
|
|
212
|
+
* autosave commits a binding exactly as it commits a tick.
|
|
213
|
+
*/ export function PropertyBindingField(props) {
|
|
214
|
+
var _fieldProps_FormFieldGridProps;
|
|
215
|
+
const { bindingControl, bindingOptions = [], bindingProps, bindingKinds, bindingEmptyText, tokenLabelContext = {} } = props, fieldProps = _object_without_properties_loose(props, [
|
|
216
|
+
"bindingControl",
|
|
217
|
+
"bindingOptions",
|
|
218
|
+
"bindingProps",
|
|
219
|
+
"bindingKinds",
|
|
220
|
+
"bindingEmptyText",
|
|
221
|
+
"tokenLabelContext"
|
|
222
|
+
]);
|
|
223
|
+
const { input } = useFieldApi({
|
|
224
|
+
name: fieldProps.name
|
|
225
|
+
});
|
|
226
|
+
const [menuAnchor, setMenuAnchor] = useState(null);
|
|
227
|
+
const [pillAnchor, setPillAnchor] = useState(null);
|
|
228
|
+
const bound = matchComponentPropToken(input.value) != null ? String(input.value).trim() : null;
|
|
229
|
+
const resolved = useMemo(()=>bound ? resolveTokenLabel(bound, tokenLabelContext) : undefined, [
|
|
230
|
+
bound,
|
|
231
|
+
tokenLabelContext
|
|
232
|
+
]);
|
|
233
|
+
const labelText = typeof fieldProps.label === 'string' && fieldProps.label ? fieldProps.label : undefined;
|
|
234
|
+
const bind = {
|
|
235
|
+
label: bound ? `Change the property ${labelText != null ? labelText : 'this field'} is bound to` : `Bind ${labelText != null ? labelText : 'this field'} to a property`,
|
|
236
|
+
onOpen: setMenuAnchor
|
|
237
|
+
};
|
|
238
|
+
const gridProps = _extends({}, (_fieldProps_FormFieldGridProps = fieldProps.FormFieldGridProps) != null ? _fieldProps_FormFieldGridProps : {}, {
|
|
239
|
+
bind
|
|
240
|
+
});
|
|
241
|
+
const { Control, defaults } = splitControl(bindingControl);
|
|
242
|
+
const menus = /*#__PURE__*/ _jsxs(_Fragment, {
|
|
243
|
+
children: [
|
|
244
|
+
/*#__PURE__*/ _jsx(InsertTokenMenu, {
|
|
245
|
+
anchorEl: menuAnchor,
|
|
246
|
+
open: Boolean(menuAnchor),
|
|
247
|
+
onClose: ()=>setMenuAnchor(null),
|
|
248
|
+
options: bindingOptions,
|
|
249
|
+
emptyText: bindingEmptyText,
|
|
250
|
+
onInsert: (token)=>{
|
|
251
|
+
setMenuAnchor(null);
|
|
252
|
+
input.onChange(token);
|
|
253
|
+
}
|
|
254
|
+
}),
|
|
255
|
+
/*#__PURE__*/ _jsx(TokenPillPopover, {
|
|
256
|
+
anchorEl: pillAnchor,
|
|
257
|
+
token: bound != null ? bound : '',
|
|
258
|
+
onClose: ()=>setPillAnchor(null),
|
|
259
|
+
onReplace: ()=>{
|
|
260
|
+
setMenuAnchor(pillAnchor);
|
|
261
|
+
setPillAnchor(null);
|
|
262
|
+
},
|
|
263
|
+
onRemove: ()=>{
|
|
264
|
+
setPillAnchor(null);
|
|
265
|
+
// Unset rather than `false` or `''`: the element goes back to its
|
|
266
|
+
// own default, which is what it rendered before it was bound.
|
|
267
|
+
input.onChange(undefined);
|
|
268
|
+
}
|
|
269
|
+
})
|
|
270
|
+
]
|
|
271
|
+
});
|
|
272
|
+
if (bound && resolved) {
|
|
273
|
+
const described = describePropertyBinding({
|
|
274
|
+
token: bound,
|
|
275
|
+
resolved,
|
|
276
|
+
bindingProps,
|
|
277
|
+
bindingKinds,
|
|
278
|
+
fieldOptions: fieldProps['options']
|
|
279
|
+
});
|
|
280
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
281
|
+
children: [
|
|
282
|
+
/*#__PURE__*/ _jsx(FormFieldGrid, _extends({
|
|
283
|
+
help: fieldProps.help
|
|
284
|
+
}, gridProps, {
|
|
285
|
+
children: /*#__PURE__*/ _jsx(TextField, {
|
|
286
|
+
fullWidth: true,
|
|
287
|
+
label: fieldProps.label,
|
|
288
|
+
value: "",
|
|
289
|
+
helperText: described.text,
|
|
290
|
+
error: described.error,
|
|
291
|
+
slotProps: {
|
|
292
|
+
inputLabel: {
|
|
293
|
+
shrink: true
|
|
294
|
+
},
|
|
295
|
+
input: {
|
|
296
|
+
readOnly: true,
|
|
297
|
+
inputComponent: BoundPropertyInput,
|
|
298
|
+
inputProps: {
|
|
299
|
+
token: bound,
|
|
300
|
+
resolved,
|
|
301
|
+
fieldLabel: labelText,
|
|
302
|
+
onOpen: setPillAnchor
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
})
|
|
307
|
+
})),
|
|
308
|
+
menus
|
|
309
|
+
]
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
if (!Control) return null;
|
|
313
|
+
return /*#__PURE__*/ _jsxs(_Fragment, {
|
|
314
|
+
children: [
|
|
315
|
+
/*#__PURE__*/ _jsx(Control, _extends({}, defaults, fieldProps, {
|
|
316
|
+
FormFieldGridProps: gridProps
|
|
317
|
+
})),
|
|
318
|
+
menus
|
|
319
|
+
]
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
PropertyBindingField.displayName = 'PropertyBindingField';
|
|
323
|
+
export default PropertyBindingField;
|
|
324
|
+
|
|
325
|
+
//# sourceMappingURL=property-binding-field.component.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/components/property-binding-field.component.tsx"],"sourcesContent":["/**\n * @license\n * Copyright 2026 Aglyn LLC\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\nimport type * as Aglyn from '@aglyn/aglyn'\nimport {\n attributeFieldValueShape,\n type BindableAttributeField,\n matchComponentPropToken,\n REUSABLE_PROP_KINDS,\n reusablePropBindsToField,\n unofferedChoiceValues,\n} from '@aglyn/aglyn'\nimport {\n type FieldBindAction,\n FormFieldGrid,\n type FormFieldGridProps,\n useFieldApi,\n} from '@aglyn/shared-ui-jsx-forms'\nimport { Box, ButtonBase, TextField } from '@mui/material'\nimport {\n type ComponentType,\n type FocusEvent,\n forwardRef,\n type MouseEvent,\n type ReactNode,\n useMemo,\n useState,\n} from 'react'\n\nimport type { BindingOption } from '../contexts/binding-picker-context'\nimport { componentPropBindingOptions } from '../hooks/use-insert-token-options'\nimport {\n TOKEN_PILL_ATTR,\n TOKEN_PILL_GROUP_ATTR,\n} from '../utils/token-editable-dom'\nimport {\n type ResolvedTokenLabel,\n resolveTokenLabel,\n type TokenLabelContext,\n} from '../utils/token-segments'\nimport { InsertTokenMenu } from './insert-token-menu.component'\nimport { TokenPillPopover, tokenPillContainerSx } from './token-pill.component'\n\n/**\n * Binding a field that has no text to type a token into.\n *\n * A free-text attribute has always taken `{{prop.headline}}`: the token is\n * typed, or picked with the `{}` in the box, and substitution does the rest.\n * A switch, a checkbox, a dropdown or an icon picker has no text to type into,\n * so inside a reusable component it could only ever hold the component's own\n * value — and a property of the matching kind had nothing to drive.\n *\n * This wraps such a field, inside a component editor only. Unbound, it is the\n * field exactly as before, with a `{}` among its corner controls. Bound, the\n * control gives way to the property it is bound to, drawn as the pill a text\n * field would draw — because the control would otherwise go on showing a\n * value the page no longer uses.\n *\n * The stored value is the same exact `{{prop.<name>}}` token a text field\n * holds, so the graft needs nothing new to find it, and a binding to a\n * property of the wrong kind is simply never offered.\n */\n\n/** Mapper key for {@link PropertyBindingField} (editor-internal, never persisted). */\nexport const PROPERTY_BINDING_FIELD_COMPONENT = 'aglyn-property-binding-field'\n\n/**\n * The names of the property kinds a declared field can be bound to, in the\n * panel's own words — `Yes / no or Checkbox` for a switch, `Color` for a color\n * picker — for the sentences that tell an author what to add.\n *\n * Every kind is tried as it can be declared (bare, with answers, taking\n * several), so a list-holding dropdown names the kinds that hold lists.\n */\nexport function propertyKindsBindableTo(\n declared: BindableAttributeField,\n): string {\n const labels = (Object.keys(REUSABLE_PROP_KINDS) as Aglyn.ReusableComponentPropType[])\n .filter((type) =>\n [\n { type },\n { type, options: [{ value: 'a' }] },\n { type, options: [{ value: 'a' }], settings: { isMulti: true } },\n ].some((candidate) => reusablePropBindsToField(candidate, declared)),\n )\n .map((type) => REUSABLE_PROP_KINDS[type].label)\n if (labels.length <= 1) return labels[0] ?? ''\n return `${labels.slice(0, -1).join(', ')} or ${labels[labels.length - 1]}`\n}\n\n/** A component-mapper entry: a component, or `{ component, ...defaults }`. */\nexport type PropertyBindingControl =\n | ComponentType<any>\n | { component: ComponentType<any>; [key: string]: unknown }\n\nexport interface PropertyBindingOptions {\n /** The attribute type the component schema declares for this field. */\n declaredComponent: unknown\n /**\n * The attribute as the schema declares it, for whether it holds one value\n * or several (`isMulti`, a checkbox's `options`). The field itself is read\n * when this is absent.\n */\n declaredField?: BindableAttributeField\n /**\n * The props the edited component declares, or `undefined` outside a\n * component editor — where `{{prop.*}}` resolves to nothing, so there is\n * nothing to bind to.\n */\n componentProps: readonly Aglyn.ReusableComponentProp[] | null | undefined\n /** The mapper entry this field renders with while unbound. */\n control: PropertyBindingControl | undefined\n /** Display-name inputs for the bound pill. */\n tokenLabelContext?: TokenLabelContext\n /** Whose properties these are, for what an empty picker says. */\n owner?: 'component' | 'layout'\n}\n\n/**\n * The field, wrapped to take a property binding when it can, or unchanged.\n *\n * Every field kind that holds a value can be bound (AGL-2893), to the\n * properties that hold the same shape of value (`reusablePropBindsToField`):\n * a switch to a Yes / no, a color picker to a Color, a dropdown that takes\n * several answers to a property that holds several.\n *\n * Unchanged outside a component or layout editor, for a free-text field — it\n * takes any property's token typed into it — for a read-only or disabled\n * field (a control that writes an unwritable field is a lie), and whenever the\n * control to fall back to is unknown, since a wrapper with nothing to render\n * would blank the field.\n */\nexport function withPropertyBinding<T extends Record<string, unknown>>(\n field: T,\n options: PropertyBindingOptions,\n): T {\n const {\n declaredComponent,\n declaredField,\n componentProps,\n control,\n tokenLabelContext,\n owner = 'component',\n } = options\n if (!componentProps || !control) return field\n const declared: BindableAttributeField = {\n ...(declaredField ?? field),\n component: declaredComponent,\n }\n if (attributeFieldValueShape(declared) === undefined) return field\n if (field['isReadOnly'] || field['isDisabled']) return field\n const bindable = componentProps.filter((prop) =>\n reusablePropBindsToField(prop, declared),\n )\n const kinds = propertyKindsBindableTo(declared)\n return {\n ...field,\n component: PROPERTY_BINDING_FIELD_COMPONENT,\n bindingControl: control,\n bindingOptions: componentPropBindingOptions(bindable, owner),\n bindingProps: bindable,\n bindingKinds: kinds,\n bindingEmptyText:\n `This ${owner} has no ${kinds || 'matching'} properties yet. Add one ` +\n 'under File ▸ Properties…, then bind it here.',\n tokenLabelContext,\n }\n}\n\n/** The mapper entry split into the component and the defaults it carries. */\nfunction splitControl(control: PropertyBindingControl | undefined): {\n Control: ComponentType<any> | undefined\n defaults: Record<string, unknown>\n} {\n if (!control) return { Control: undefined, defaults: {} }\n if (typeof control === 'object' && 'component' in control) {\n const { component, ...defaults } = control\n return { Control: component, defaults }\n }\n return { Control: control as ComponentType<any>, defaults: {} }\n}\n\ninterface BoundPropertyInputProps {\n token: string\n resolved: ResolvedTokenLabel\n onOpen: (anchor: HTMLElement) => void\n /** The field's own label, so the button says what it changes. */\n fieldLabel?: string\n // Injected by MUI InputBase:\n className?: string\n disabled?: boolean\n id?: string\n onFocus?: (event: FocusEvent<HTMLElement>) => void\n onBlur?: (event: FocusEvent<HTMLElement>) => void\n 'aria-describedby'?: string\n}\n\n/**\n * The bound property, drawn INSIDE a real outlined field so the label, notch,\n * helper text and focus ring are the ones every other attribute has.\n *\n * The pill is a button rather than the passive span a text field draws: here\n * it is the whole value, so it has to be reachable by keyboard, and pressing\n * it is how the binding is changed or removed.\n */\nconst BoundPropertyInput = forwardRef<HTMLButtonElement, BoundPropertyInputProps>(\n function BoundPropertyInput(props, ref) {\n const {\n token,\n resolved,\n onOpen,\n fieldLabel,\n className,\n disabled,\n id,\n onFocus,\n onBlur,\n 'aria-describedby': describedBy,\n } = props\n const pillAttributes = {\n [TOKEN_PILL_ATTR]: token,\n [TOKEN_PILL_GROUP_ATTR]: resolved.known ? resolved.group : 'unknown',\n }\n return (\n <Box\n className={className}\n sx={{ ...tokenPillContainerSx, display: 'flex', alignItems: 'center' }}\n >\n <ButtonBase\n ref={ref}\n id={id}\n disabled={disabled}\n aria-describedby={describedBy}\n aria-label={`${fieldLabel ? `${fieldLabel}: ` : ''}bound to ${resolved.label}. Change or remove the binding`}\n title={token}\n onFocus={onFocus}\n onBlur={onBlur}\n onClick={(event: MouseEvent<HTMLElement>) =>\n onOpen(event.currentTarget)\n }\n {...pillAttributes}\n >\n {resolved.label}\n </ButtonBase>\n </Box>\n )\n },\n)\n\nexport interface PropertyBindingFieldProps {\n [key: string]: unknown\n name: string\n label?: ReactNode\n help?: unknown\n description?: ReactNode\n helperText?: ReactNode\n bindingControl?: PropertyBindingControl\n bindingOptions?: BindingOption[]\n /** The declared props this field can be bound to. */\n bindingProps?: readonly Aglyn.ReusableComponentProp[]\n /** Those props' kinds in the panel's words, e.g. `Choice`. */\n bindingKinds?: string\n bindingEmptyText?: string\n tokenLabelContext?: TokenLabelContext\n FormFieldGridProps?: FormFieldGridProps\n}\n\n/**\n * What a bound field says under the property it follows, and whether that is\n * a problem.\n *\n * Three ways a binding can be wrong while still looking bound, each named in\n * words an author can act on: the property is gone (it was renamed or\n * removed, so nothing substitutes), the property is the wrong kind (a token\n * written some other way than this field's picker), or — for a dropdown —\n * some of the property's choices are values the dropdown does not offer.\n */\nexport function describePropertyBinding(options: {\n token: string\n resolved: ResolvedTokenLabel\n bindingProps?: readonly Aglyn.ReusableComponentProp[]\n bindingKinds?: string\n fieldOptions?: unknown\n}): { text: string; error: boolean } {\n const { token, resolved, bindingProps, bindingKinds, fieldOptions } = options\n const name = matchComponentPropToken(token)\n const prop = (bindingProps ?? []).find((entry) => entry?.name === name)\n if (!prop) {\n return resolved.known\n ? {\n text:\n `${resolved.label} is not a ${bindingKinds || 'matching'} ` +\n 'property, so it cannot set this field. Bind one that is, or ' +\n 'remove the binding.',\n error: true,\n }\n : {\n text:\n 'This component declares no property by that name, so pages ' +\n 'cannot set it. Bind a property it declares, or remove the ' +\n 'binding.',\n error: true,\n }\n }\n const unoffered = unofferedChoiceValues(prop, fieldOptions)\n if (unoffered.length) {\n const offered = (Array.isArray(fieldOptions) ? fieldOptions : [])\n .map((option) => {\n const { value, label } = (option ?? {}) as {\n value?: unknown\n label?: unknown\n }\n const text = String(value ?? '')\n return label != null && String(label) !== text\n ? `${String(label)} (${text})`\n : text\n })\n .filter(Boolean)\n return {\n text:\n `This field does not offer ${unoffered.join(', ')}, so a page that ` +\n `chooses ${unoffered.length === 1 ? 'it' : 'one of those'} gets the ` +\n `field's own default. Give ${resolved.label} values from: ` +\n `${offered.join(', ')}.`,\n error: true,\n }\n }\n return {\n text: `Each page sets this with the ${resolved.label} property.`,\n error: false,\n }\n}\n\n/**\n * The data-driven-forms field registered as\n * {@link PROPERTY_BINDING_FIELD_COMPONENT}. The token flows through\n * react-final-form like any other value, so the Attributes panel's debounced\n * autosave commits a binding exactly as it commits a tick.\n */\nexport function PropertyBindingField(props: PropertyBindingFieldProps) {\n const {\n bindingControl,\n bindingOptions = [],\n bindingProps,\n bindingKinds,\n bindingEmptyText,\n tokenLabelContext = {},\n ...fieldProps\n } = props\n const { input } = useFieldApi({ name: fieldProps.name } as never) as {\n input: { value: unknown; onChange: (value: unknown) => void }\n }\n const [menuAnchor, setMenuAnchor] = useState<HTMLElement | null>(null)\n const [pillAnchor, setPillAnchor] = useState<HTMLElement | null>(null)\n\n const bound =\n matchComponentPropToken(input.value) != null\n ? String(input.value).trim()\n : null\n const resolved = useMemo(\n () => (bound ? resolveTokenLabel(bound, tokenLabelContext) : undefined),\n [bound, tokenLabelContext],\n )\n const labelText =\n typeof fieldProps.label === 'string' && fieldProps.label\n ? fieldProps.label\n : undefined\n const bind: FieldBindAction = {\n label: bound\n ? `Change the property ${labelText ?? 'this field'} is bound to`\n : `Bind ${labelText ?? 'this field'} to a property`,\n onOpen: setMenuAnchor,\n }\n const gridProps: FormFieldGridProps = {\n ...(fieldProps.FormFieldGridProps ?? {}),\n bind,\n }\n\n const { Control, defaults } = splitControl(bindingControl)\n\n const menus = (\n <>\n <InsertTokenMenu\n anchorEl={menuAnchor}\n open={Boolean(menuAnchor)}\n onClose={() => setMenuAnchor(null)}\n options={bindingOptions}\n emptyText={bindingEmptyText}\n onInsert={(token) => {\n setMenuAnchor(null)\n input.onChange(token)\n }}\n />\n <TokenPillPopover\n anchorEl={pillAnchor}\n token={bound ?? ''}\n onClose={() => setPillAnchor(null)}\n onReplace={() => {\n setMenuAnchor(pillAnchor)\n setPillAnchor(null)\n }}\n onRemove={() => {\n setPillAnchor(null)\n // Unset rather than `false` or `''`: the element goes back to its\n // own default, which is what it rendered before it was bound.\n input.onChange(undefined)\n }}\n />\n </>\n )\n\n if (bound && resolved) {\n const described = describePropertyBinding({\n token: bound,\n resolved,\n bindingProps,\n bindingKinds,\n fieldOptions: fieldProps['options'],\n })\n return (\n <>\n <FormFieldGrid\n help={fieldProps.help as FormFieldGridProps['help']}\n {...gridProps}\n >\n <TextField\n fullWidth\n label={fieldProps.label}\n value=\"\"\n helperText={described.text}\n error={described.error}\n slotProps={{\n inputLabel: { shrink: true },\n input: {\n readOnly: true,\n inputComponent: BoundPropertyInput as never,\n inputProps: {\n token: bound,\n resolved,\n fieldLabel: labelText,\n onOpen: setPillAnchor,\n },\n },\n }}\n />\n </FormFieldGrid>\n {menus}\n </>\n )\n }\n\n if (!Control) return null\n return (\n <>\n <Control {...defaults} {...fieldProps} FormFieldGridProps={gridProps} />\n {menus}\n </>\n )\n}\nPropertyBindingField.displayName = 'PropertyBindingField'\n\nexport default PropertyBindingField\n"],"names":["attributeFieldValueShape","matchComponentPropToken","REUSABLE_PROP_KINDS","reusablePropBindsToField","unofferedChoiceValues","FormFieldGrid","useFieldApi","Box","ButtonBase","TextField","forwardRef","useMemo","useState","componentPropBindingOptions","TOKEN_PILL_ATTR","TOKEN_PILL_GROUP_ATTR","resolveTokenLabel","InsertTokenMenu","TokenPillPopover","tokenPillContainerSx","PROPERTY_BINDING_FIELD_COMPONENT","propertyKindsBindableTo","declared","labels","Object","keys","filter","type","options","value","settings","isMulti","some","candidate","map","label","length","slice","join","withPropertyBinding","field","declaredComponent","declaredField","componentProps","control","tokenLabelContext","owner","component","undefined","bindable","prop","kinds","bindingControl","bindingOptions","bindingProps","bindingKinds","bindingEmptyText","splitControl","Control","defaults","BoundPropertyInput","props","ref","token","resolved","onOpen","fieldLabel","className","disabled","id","onFocus","onBlur","describedBy","pillAttributes","known","group","sx","display","alignItems","aria-describedby","aria-label","title","onClick","event","currentTarget","describePropertyBinding","fieldOptions","name","find","entry","text","error","unoffered","offered","Array","isArray","option","String","Boolean","PropertyBindingField","fieldProps","input","menuAnchor","setMenuAnchor","pillAnchor","setPillAnchor","bound","trim","labelText","bind","gridProps","FormFieldGridProps","menus","anchorEl","open","onClose","emptyText","onInsert","onChange","onReplace","onRemove","described","help","fullWidth","helperText","slotProps","inputLabel","shrink","readOnly","inputComponent","inputProps","displayName"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;;;AAGD,SACEA,wBAAwB,EAExBC,uBAAuB,EACvBC,mBAAmB,EACnBC,wBAAwB,EACxBC,qBAAqB,QAChB,eAAc;AACrB,SAEEC,aAAa,EAEbC,WAAW,QACN,6BAA4B;AACnC,SAASC,GAAG,EAAEC,UAAU,EAAEC,SAAS,QAAQ,gBAAe;AAC1D,SAGEC,UAAU,EAGVC,OAAO,EACPC,QAAQ,QACH,QAAO;AAGd,SAASC,2BAA2B,QAAQ,uCAAmC;AAC/E,SACEC,eAAe,EACfC,qBAAqB,QAChB,iCAA6B;AACpC,SAEEC,iBAAiB,QAEZ,6BAAyB;AAChC,SAASC,eAAe,QAAQ,mCAA+B;AAC/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1DE;;;AAGP;AACAb,qBAAqBgC,WAAW,GAAG;AAEnC,eAAehC,qBAAoB"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type * as Aglyn from '@aglyn/aglyn';
|
|
2
|
+
import { type PropertyOwnerNoun } from './element-props-form.component';
|
|
3
|
+
export interface AttributeFieldsFormProps {
|
|
4
|
+
/**
|
|
5
|
+
* Attribute fields — as a coded component would declare them, or as
|
|
6
|
+
* {@link buildPropertyField} draws a property — named for paths in
|
|
7
|
+
* `values`.
|
|
8
|
+
*/
|
|
9
|
+
fields: ReadonlyArray<Record<string, unknown>>;
|
|
10
|
+
/** The values the form starts from. Later changes to this are not re-read. */
|
|
11
|
+
values?: Record<string, unknown>;
|
|
12
|
+
onChange: (values: Record<string, unknown>) => void;
|
|
13
|
+
/** Written into the field when a media library pick lands, by field name. */
|
|
14
|
+
mediaFields?: ReadonlySet<string>;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Attribute fields in a form of their own, resolved and drawn exactly as the
|
|
18
|
+
* Attributes panel draws them, reporting every change.
|
|
19
|
+
*/
|
|
20
|
+
export declare function AttributeFieldsForm(props: AttributeFieldsFormProps): import("react").JSX.Element;
|
|
21
|
+
export interface PropertyValuesFormProps {
|
|
22
|
+
/** The properties the owner declares. */
|
|
23
|
+
declared: readonly Aglyn.ReusableComponentProp[];
|
|
24
|
+
/** Each property's value, by name. */
|
|
25
|
+
values?: Record<string, unknown>;
|
|
26
|
+
/** Every property's value, by name, after each change. */
|
|
27
|
+
onChange: (values: Record<string, unknown>) => void;
|
|
28
|
+
/**
|
|
29
|
+
* `value` for a page setting them, with each empty field falling back to
|
|
30
|
+
* the default and every condition applied; `default` for declaring those
|
|
31
|
+
* defaults.
|
|
32
|
+
*/
|
|
33
|
+
role?: 'value' | 'default';
|
|
34
|
+
noun?: PropertyOwnerNoun;
|
|
35
|
+
/** Only these properties, by name; all of them when omitted. */
|
|
36
|
+
only?: readonly string[];
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* A component's or layout's properties, each edited with the control its
|
|
40
|
+
* kind names in the Attributes panel.
|
|
41
|
+
*/
|
|
42
|
+
export declare function PropertyValuesForm(props: PropertyValuesFormProps): import("react").JSX.Element;
|
|
43
|
+
export default PropertyValuesForm;
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2026 Aglyn LLC
|
|
4
|
+
*
|
|
5
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
* you may not use this file except in compliance with the License.
|
|
7
|
+
* You may obtain a copy of the License at
|
|
8
|
+
*
|
|
9
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
*
|
|
11
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
* See the License for the specific language governing permissions and
|
|
15
|
+
* limitations under the License.
|
|
16
|
+
*/ 'use client';
|
|
17
|
+
import { _ as _extends } from "@swc/helpers/_/_extends";
|
|
18
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
19
|
+
import { canvas, components, EntityPickerContext, FieldComponentType, getKnownPluginInstallsVersion, ScreenLinkContext, subscribeKnownPluginInstalls } from "@aglyn/aglyn";
|
|
20
|
+
import { useAglynSiteTheme } from "@aglyn/aglyn-node-renderer";
|
|
21
|
+
import { FormRenderer, FormSpy, useFormApi } from "@aglyn/shared-ui-jsx-forms";
|
|
22
|
+
import { useHostThemeDocument } from "@aglyn/shared-ui-theme";
|
|
23
|
+
import { Grid } from "@mui/material";
|
|
24
|
+
import { useContext, useEffect, useMemo, useRef, useState, useSyncExternalStore } from "react";
|
|
25
|
+
import { MediaPickerContext } from "../contexts/media-picker-context.js";
|
|
26
|
+
import useInsertTokenOptions from "../hooks/use-insert-token-options.js";
|
|
27
|
+
import { buildStyleThemeScales } from "../utils/theme-scale-options.js";
|
|
28
|
+
import { buildPropertyField, elementPropsComponentMapper, entityKindsForAttributes, resolveAttributeField, withNumericValueParse } from "./element-props-form.component.js";
|
|
29
|
+
import { TOKEN_TEXT_FIELD_COMPONENT } from "./token-text-field.component.js";
|
|
30
|
+
/**
|
|
31
|
+
* Property values edited OUTSIDE the Attributes panel, with the Attributes
|
|
32
|
+
* panel's own controls (AGL-2893): the Properties dialog's Default for each
|
|
33
|
+
* property, a kind's settings, a condition's operand, and a screen's values
|
|
34
|
+
* for the layout it renders inside.
|
|
35
|
+
*
|
|
36
|
+
* Each field is an attribute field — {@link buildPropertyField} for a
|
|
37
|
+
* property — finished by {@link resolveAttributeField} against the same site
|
|
38
|
+
* data the panel reads and drawn by `elementPropsComponentMapper`. So a Yes /
|
|
39
|
+
* no is the switch, an Icon the icon picker and a Color the color picker
|
|
40
|
+
* here exactly as they are on an instance, and nothing here can drift from
|
|
41
|
+
* the panel into a look-alike.
|
|
42
|
+
*/ /** The form's nothing-to-submit: every change is reported as it happens. */ const noop = ()=>undefined;
|
|
43
|
+
/** The values each change reports, compared so a re-render is not a change. */ function serialize(values) {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.stringify(values != null ? values : {});
|
|
46
|
+
} catch (unused) {
|
|
47
|
+
return '';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/** Hands the parent every change, and the form API for writes from outside. */ function AttributeFieldsFormTemplate(props) {
|
|
51
|
+
const { formFields, onValues, formApiRef } = props;
|
|
52
|
+
const formApi = useFormApi();
|
|
53
|
+
formApiRef.current = formApi;
|
|
54
|
+
// The values the form opened with, so the spy's first report — the state
|
|
55
|
+
// it subscribed to, not a change — is not handed on as one.
|
|
56
|
+
const last = useRef(serialize(formApi.getState().values));
|
|
57
|
+
return /*#__PURE__*/ _jsxs("form", {
|
|
58
|
+
onSubmit: (event)=>event.preventDefault(),
|
|
59
|
+
noValidate: true,
|
|
60
|
+
children: [
|
|
61
|
+
/*#__PURE__*/ _jsx(Grid, {
|
|
62
|
+
container: true,
|
|
63
|
+
spacing: 2,
|
|
64
|
+
children: formFields
|
|
65
|
+
}),
|
|
66
|
+
/*#__PURE__*/ _jsx(FormSpy, {
|
|
67
|
+
subscription: {
|
|
68
|
+
values: true
|
|
69
|
+
},
|
|
70
|
+
onChange: ({ values })=>{
|
|
71
|
+
const next = serialize(values);
|
|
72
|
+
if (next === last.current) return;
|
|
73
|
+
last.current = next;
|
|
74
|
+
onValues(values);
|
|
75
|
+
}
|
|
76
|
+
})
|
|
77
|
+
]
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Attribute fields in a form of their own, resolved and drawn exactly as the
|
|
82
|
+
* Attributes panel draws them, reporting every change.
|
|
83
|
+
*/ export function AttributeFieldsForm(props) {
|
|
84
|
+
const { fields, values, onChange, mediaFields } = props;
|
|
85
|
+
const [initialValues] = useState(()=>values != null ? values : {});
|
|
86
|
+
const formApiRef = useRef(undefined);
|
|
87
|
+
const onChangeRef = useRef(onChange);
|
|
88
|
+
onChangeRef.current = onChange;
|
|
89
|
+
const { screens, labels } = useContext(ScreenLinkContext);
|
|
90
|
+
const entityOptions = useContext(EntityPickerContext);
|
|
91
|
+
const { onPickMedia } = useContext(MediaPickerContext);
|
|
92
|
+
const { options: insertOptions, labelContext: tokenLabelContext } = useInsertTokenOptions(undefined);
|
|
93
|
+
const pluginInstallsVersion = useSyncExternalStore(subscribeKnownPluginInstalls, getKnownPluginInstallsVersion, getKnownPluginInstallsVersion);
|
|
94
|
+
// Ask for the entity lists these fields' pickers show (AGL-703), as the
|
|
95
|
+
// Attributes panel does for the element it edits.
|
|
96
|
+
const requestEntities = entityOptions.request;
|
|
97
|
+
useEffect(()=>{
|
|
98
|
+
if (!requestEntities) return;
|
|
99
|
+
for (const kind of entityKindsForAttributes(fields)){
|
|
100
|
+
requestEntities(kind);
|
|
101
|
+
}
|
|
102
|
+
}, [
|
|
103
|
+
fields,
|
|
104
|
+
requestEntities
|
|
105
|
+
]);
|
|
106
|
+
// The canvas's elements, for element pickers.
|
|
107
|
+
const wantsNodes = fields.some((field)=>field['component'] === FieldComponentType.NODE_SELECT);
|
|
108
|
+
const nodeOptions = useMemo(()=>{
|
|
109
|
+
var _canvas_toJSON_nodes;
|
|
110
|
+
if (!wantsNodes) return [];
|
|
111
|
+
const canvasNodes = (_canvas_toJSON_nodes = canvas.toJSON().nodes) != null ? _canvas_toJSON_nodes : {};
|
|
112
|
+
return Object.entries(canvasNodes).filter(([id])=>Boolean(id)).map(([id, candidate])=>{
|
|
113
|
+
var _ref, _ref1;
|
|
114
|
+
var _components_getSchema, _candidate_props;
|
|
115
|
+
const displayName = (_ref = (_ref1 = (_components_getSchema = components.getSchema(candidate == null ? void 0 : candidate.componentId)) == null ? void 0 : _components_getSchema.displayName) != null ? _ref1 : candidate == null ? void 0 : candidate.componentId) != null ? _ref : 'Element';
|
|
116
|
+
const text = typeof (candidate == null ? void 0 : (_candidate_props = candidate.props) == null ? void 0 : _candidate_props.children) === 'string' ? candidate.props.children.trim().slice(0, 24) : '';
|
|
117
|
+
return {
|
|
118
|
+
value: id,
|
|
119
|
+
label: `${displayName}${text ? ` "${text}"` : ''} · ${id.slice(0, 6)}`
|
|
120
|
+
};
|
|
121
|
+
}).sort((a, b)=>a.label.localeCompare(b.label));
|
|
122
|
+
}, [
|
|
123
|
+
wantsNodes
|
|
124
|
+
]);
|
|
125
|
+
const context = useMemo(()=>({
|
|
126
|
+
screens,
|
|
127
|
+
labels,
|
|
128
|
+
values: initialValues,
|
|
129
|
+
entityOptions,
|
|
130
|
+
nodeOptions,
|
|
131
|
+
insertOptions,
|
|
132
|
+
tokenLabelContext,
|
|
133
|
+
pluginInstallsVersion
|
|
134
|
+
}), [
|
|
135
|
+
screens,
|
|
136
|
+
labels,
|
|
137
|
+
initialValues,
|
|
138
|
+
entityOptions,
|
|
139
|
+
nodeOptions,
|
|
140
|
+
insertOptions,
|
|
141
|
+
tokenLabelContext,
|
|
142
|
+
pluginInstallsVersion
|
|
143
|
+
]);
|
|
144
|
+
const resolved = useMemo(()=>fields.map((field)=>resolveAttributeField(field, context)).map((field)=>onPickMedia && (mediaFields == null ? void 0 : mediaFields.has(String(field['name']))) && field['component'] === TOKEN_TEXT_FIELD_COMPONENT ? _extends({}, field, {
|
|
145
|
+
onBrowseMedia: ()=>onPickMedia((value)=>{
|
|
146
|
+
var _formApiRef_current;
|
|
147
|
+
return (_formApiRef_current = formApiRef.current) == null ? void 0 : _formApiRef_current.change(String(field['name']), value);
|
|
148
|
+
})
|
|
149
|
+
}) : field).filter((field)=>String(field['component']) in elementPropsComponentMapper).map(withNumericValueParse), [
|
|
150
|
+
fields,
|
|
151
|
+
context,
|
|
152
|
+
onPickMedia,
|
|
153
|
+
mediaFields
|
|
154
|
+
]);
|
|
155
|
+
// One component for the life of the form: a template created per render
|
|
156
|
+
// would be a new component type each time, remounting every field.
|
|
157
|
+
const [Template] = useState(()=>function BoundTemplate(templateProps) {
|
|
158
|
+
return /*#__PURE__*/ _jsx(AttributeFieldsFormTemplate, _extends({}, templateProps, {
|
|
159
|
+
formApiRef: formApiRef,
|
|
160
|
+
onValues: (next)=>onChangeRef.current(next)
|
|
161
|
+
}));
|
|
162
|
+
});
|
|
163
|
+
return /*#__PURE__*/ _jsx(FormRenderer, {
|
|
164
|
+
componentMapper: elementPropsComponentMapper,
|
|
165
|
+
FormTemplate: Template,
|
|
166
|
+
initialValues: initialValues,
|
|
167
|
+
onSubmit: noop,
|
|
168
|
+
schema: {
|
|
169
|
+
fields: resolved
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
/** The path a property's value sits at inside this form. */ const VALUES_KEY = 'values';
|
|
174
|
+
const pathOf = (name)=>`${VALUES_KEY}.${name}`;
|
|
175
|
+
/**
|
|
176
|
+
* A component's or layout's properties, each edited with the control its
|
|
177
|
+
* kind names in the Attributes panel.
|
|
178
|
+
*/ export function PropertyValuesForm(props) {
|
|
179
|
+
const { declared, values, onChange, role = 'value', noun = 'component', only } = props;
|
|
180
|
+
const hostThemeDoc = useHostThemeDocument();
|
|
181
|
+
const siteTheme = useAglynSiteTheme({
|
|
182
|
+
theme: hostThemeDoc
|
|
183
|
+
});
|
|
184
|
+
const themeScales = useMemo(()=>buildStyleThemeScales(siteTheme), [
|
|
185
|
+
siteTheme
|
|
186
|
+
]);
|
|
187
|
+
const shown = useMemo(()=>declared.filter((prop)=>Boolean(prop == null ? void 0 : prop.name) && (!only || only.includes(prop.name))), [
|
|
188
|
+
declared,
|
|
189
|
+
only
|
|
190
|
+
]);
|
|
191
|
+
const fields = useMemo(()=>shown.map((prop)=>buildPropertyField(prop, {
|
|
192
|
+
name: pathOf(prop.name),
|
|
193
|
+
role,
|
|
194
|
+
declared,
|
|
195
|
+
valuePath: pathOf,
|
|
196
|
+
noun,
|
|
197
|
+
themeScales
|
|
198
|
+
})), [
|
|
199
|
+
shown,
|
|
200
|
+
role,
|
|
201
|
+
declared,
|
|
202
|
+
noun,
|
|
203
|
+
themeScales
|
|
204
|
+
]);
|
|
205
|
+
const mediaFields = useMemo(()=>new Set(shown.filter((prop)=>prop.type === 'image').map((prop)=>pathOf(prop.name))), [
|
|
206
|
+
shown
|
|
207
|
+
]);
|
|
208
|
+
const [initial] = useState(()=>({
|
|
209
|
+
[VALUES_KEY]: values != null ? values : {}
|
|
210
|
+
}));
|
|
211
|
+
return /*#__PURE__*/ _jsx(AttributeFieldsForm, {
|
|
212
|
+
fields: fields,
|
|
213
|
+
values: initial,
|
|
214
|
+
mediaFields: mediaFields,
|
|
215
|
+
onChange: (next)=>{
|
|
216
|
+
var _ref;
|
|
217
|
+
return onChange((_ref = next == null ? void 0 : next[VALUES_KEY]) != null ? _ref : {});
|
|
218
|
+
}
|
|
219
|
+
});
|
|
220
|
+
}
|
|
221
|
+
export default PropertyValuesForm;
|
|
222
|
+
|
|
223
|
+
//# sourceMappingURL=property-values-form.component.js.map
|