@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,230 @@
|
|
|
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 { AUTHOR_TOKEN_CATALOG, canvas, COLLECTION_ENTRIES_COMPONENT_ID, COLLECTION_TOKEN_CATALOG, COMPONENT_PROP_NAME_PATTERN, COMPONENT_PROP_TOKEN_PREFIX, datasetItemToken, EntityPickerContext, entityValueNeedsResolution, ENTRY_TOKEN_CATALOG, readYesNoValue, reusablePropDefaultValue, reusablePropHasAnswers, reusablePropValueClass } from "@aglyn/aglyn";
|
|
18
|
+
import { useContext, useEffect, useMemo } from "react";
|
|
19
|
+
import { BindingPickerContext } from "../contexts/binding-picker-context.js";
|
|
20
|
+
/**
|
|
21
|
+
* A component's or layout's own declared props as picker options (AGL-1335).
|
|
22
|
+
* A free-text field offers every one; a field with no text box is handed only
|
|
23
|
+
* the properties it can be bound to (see `withPropertyBinding`).
|
|
24
|
+
*
|
|
25
|
+
* Names are filtered by the SAME pattern the graft requires, so a picker can
|
|
26
|
+
* never offer a token that would not substitute.
|
|
27
|
+
*/ export function componentPropBindingOptions(componentProps, owner = 'component') {
|
|
28
|
+
const options = [];
|
|
29
|
+
for (const prop of componentProps != null ? componentProps : []){
|
|
30
|
+
var _ref;
|
|
31
|
+
if (!COMPONENT_PROP_NAME_PATTERN.test((_ref = prop == null ? void 0 : prop.name) != null ? _ref : '')) continue;
|
|
32
|
+
options.push({
|
|
33
|
+
group: 'Properties',
|
|
34
|
+
groupHint: owner === 'layout' ? 'Set per screen in the Screen Properties of each screen using this layout' : 'Set per page in the Attributes panel of each instance',
|
|
35
|
+
label: prop.label || prop.name,
|
|
36
|
+
token: `{{${COMPONENT_PROP_TOKEN_PREFIX}${prop.name}}}`,
|
|
37
|
+
preview: componentPropDefaultPreview(prop)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
return options;
|
|
41
|
+
}
|
|
42
|
+
/** The picker's second line for a property: what a page that sets nothing gets. */ export function componentPropDefaultPreview(prop) {
|
|
43
|
+
const valueClass = reusablePropValueClass(prop);
|
|
44
|
+
if (valueClass === 'boolean') {
|
|
45
|
+
// A yes/no has no "nothing": unset with no default substitutes `''`,
|
|
46
|
+
// which every Yes / no reader takes for a no.
|
|
47
|
+
return readYesNoValue(prop.defaultValue) === true ? 'Defaults to Yes' : 'Defaults to No';
|
|
48
|
+
}
|
|
49
|
+
if (valueClass === 'icon') {
|
|
50
|
+
// An icon id is not something to read out; the picker shows the icon.
|
|
51
|
+
return prop.defaultValue ? 'Defaults to the icon picked in Properties' : 'No default — shows no icon until a page picks one';
|
|
52
|
+
}
|
|
53
|
+
const fallback = reusablePropDefaultValue(prop);
|
|
54
|
+
if (reusablePropHasAnswers(prop)) {
|
|
55
|
+
// Named by the label a page author picks, not the value a field gets.
|
|
56
|
+
const chosen = (Array.isArray(fallback) ? fallback : [
|
|
57
|
+
fallback
|
|
58
|
+
]).map((value)=>{
|
|
59
|
+
var _prop_options;
|
|
60
|
+
const answer = ((_prop_options = prop.options) != null ? _prop_options : []).find((option)=>(option == null ? void 0 : option.value) && option.value === value);
|
|
61
|
+
return answer ? answer.label || answer.value : undefined;
|
|
62
|
+
}).filter(Boolean);
|
|
63
|
+
return chosen.length ? `Defaults to ${chosen.join(', ')}` : 'No default — the field keeps its own until a page chooses';
|
|
64
|
+
}
|
|
65
|
+
if (fallback === undefined) {
|
|
66
|
+
return valueClass === 'text' ? 'No default — renders as nothing until a page sets it' : 'No default — the field keeps its own until a page sets it';
|
|
67
|
+
}
|
|
68
|
+
return `Defaults to "${Array.isArray(fallback) ? fallback.join(', ') : String(fallback)}"`;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Assembles the insert-picker options for a canvas node from ITS context
|
|
72
|
+
* (AGL-583, extracted for AGL-586 so the attributes panel and the inline
|
|
73
|
+
* text editor share one walk): the ancestor chain is scanned for a
|
|
74
|
+
* repeatable container (dataset-item tokens need its model fields) and for
|
|
75
|
+
* a Collection entries block (entry tokens resolve right there, not only
|
|
76
|
+
* on entry pages). `repeatDataset` persists a dataset id OR a legacy
|
|
77
|
+
* display name — either resolves against the entity picker options.
|
|
78
|
+
*/ export function useInsertTokenOptions(node) {
|
|
79
|
+
const { options: bindingOptions, variables: bindingVariables, functions: bindingFunctions, componentProps, componentPropsOwner } = useContext(BindingPickerContext);
|
|
80
|
+
const entityOptions = useContext(EntityPickerContext);
|
|
81
|
+
const insertContext = useMemo(()=>{
|
|
82
|
+
var _canvas_toJSON_nodes, _entityOptions_datasets, _ref, _ref1, _datasets_find, _ref2;
|
|
83
|
+
var _entityOptions_resolved_datasets, _entityOptions_resolved, _entityOptions_datasetFields;
|
|
84
|
+
const nodes = (_canvas_toJSON_nodes = canvas.toJSON().nodes) != null ? _canvas_toJSON_nodes : {};
|
|
85
|
+
let repeatDatasetKey;
|
|
86
|
+
let inCollectionEntries = false;
|
|
87
|
+
let current = (node == null ? void 0 : node.$id) ? nodes[node.$id] : undefined;
|
|
88
|
+
for(let hops = 0; current && hops < 100; hops += 1){
|
|
89
|
+
var _current_props;
|
|
90
|
+
const props = (_current_props = current.props) != null ? _current_props : {};
|
|
91
|
+
if (!repeatDatasetKey && typeof props.repeatDataset === 'string' && props.repeatDataset.trim()) {
|
|
92
|
+
repeatDatasetKey = props.repeatDataset.trim();
|
|
93
|
+
}
|
|
94
|
+
if (current.componentId === COLLECTION_ENTRIES_COMPONENT_ID) {
|
|
95
|
+
inCollectionEntries = true;
|
|
96
|
+
}
|
|
97
|
+
current = current.parentId ? nodes[current.parentId] : undefined;
|
|
98
|
+
}
|
|
99
|
+
const datasets = (_entityOptions_datasets = entityOptions.datasets) != null ? _entityOptions_datasets : [];
|
|
100
|
+
/*
|
|
101
|
+
* The browse window is a PAGE of the org's datasets, so a repeat bound to
|
|
102
|
+
* one outside it matches nothing here — and this is where the token menu
|
|
103
|
+
* would silently stop offering that dataset's fields on exactly the
|
|
104
|
+
* orgs with enough datasets to need them. A resolution counts as a match,
|
|
105
|
+
* which is the same keyed read the attributes panel already spends on a
|
|
106
|
+
* picker's stored value.
|
|
107
|
+
*/ const dataset = repeatDatasetKey ? (_ref = (_ref1 = (_datasets_find = datasets.find((candidate)=>candidate.id === repeatDatasetKey)) != null ? _datasets_find : datasets.find((candidate)=>candidate.label === repeatDatasetKey)) != null ? _ref1 : (_entityOptions_resolved = entityOptions.resolved) == null ? void 0 : (_entityOptions_resolved_datasets = _entityOptions_resolved.datasets) == null ? void 0 : _entityOptions_resolved_datasets[repeatDatasetKey]) != null ? _ref : undefined : undefined;
|
|
108
|
+
return {
|
|
109
|
+
inCollectionEntries,
|
|
110
|
+
datasetLabel: dataset == null ? void 0 : dataset.label,
|
|
111
|
+
datasetFields: dataset ? (_ref2 = (_entityOptions_datasetFields = entityOptions.datasetFields) == null ? void 0 : _entityOptions_datasetFields[dataset.id]) != null ? _ref2 : [] : [],
|
|
112
|
+
// Carried out of the walk so the effect below can ask for the dataset
|
|
113
|
+
// list without repeating it.
|
|
114
|
+
repeatDatasetKey
|
|
115
|
+
};
|
|
116
|
+
}, [
|
|
117
|
+
node,
|
|
118
|
+
entityOptions.datasets,
|
|
119
|
+
entityOptions.datasetFields,
|
|
120
|
+
entityOptions.resolved
|
|
121
|
+
]);
|
|
122
|
+
/**
|
|
123
|
+
* Ask for the dataset list, and only when this node is inside a repeat
|
|
124
|
+
* bound to one (AGL-703).
|
|
125
|
+
*
|
|
126
|
+
* This hook runs on every selection — the props form and the inline text
|
|
127
|
+
* editor both call it — so requesting unconditionally would put the
|
|
128
|
+
* provider back to reading datasets on every click. `repeatDatasetKey` is
|
|
129
|
+
* the precise condition: without it there is no dataset to name and the
|
|
130
|
+
* token menu offers none.
|
|
131
|
+
*/ const requestEntities = entityOptions.request;
|
|
132
|
+
const resolveEntity = entityOptions.resolve;
|
|
133
|
+
useEffect(()=>{
|
|
134
|
+
const key = insertContext.repeatDatasetKey;
|
|
135
|
+
if (!key) return;
|
|
136
|
+
requestEntities == null ? void 0 : requestEntities('datasets');
|
|
137
|
+
// Nothing to look up once the dataset is named. `repeatDataset` may hold
|
|
138
|
+
// a legacy DISPLAY NAME, which the label match above answers from the
|
|
139
|
+
// window — reading a document at that name as though it were an id would
|
|
140
|
+
// be a read that could only ever miss.
|
|
141
|
+
if (insertContext.datasetLabel) return;
|
|
142
|
+
const id = entityValueNeedsResolution(entityOptions, 'datasets', key);
|
|
143
|
+
if (id) resolveEntity == null ? void 0 : resolveEntity('datasets', id);
|
|
144
|
+
}, [
|
|
145
|
+
requestEntities,
|
|
146
|
+
resolveEntity,
|
|
147
|
+
entityOptions,
|
|
148
|
+
insertContext.repeatDatasetKey,
|
|
149
|
+
insertContext.datasetLabel
|
|
150
|
+
]);
|
|
151
|
+
const options = useMemo(()=>{
|
|
152
|
+
const assembled = [
|
|
153
|
+
...bindingOptions != null ? bindingOptions : []
|
|
154
|
+
];
|
|
155
|
+
/**
|
|
156
|
+
* The component's own declared props (AGL-1335), first because they are
|
|
157
|
+
* the nearest scope — inside a component definition, `{{prop.x}}` is
|
|
158
|
+
* what the author reaches for most.
|
|
159
|
+
*
|
|
160
|
+
* They were absent from this picker entirely, so binding one meant
|
|
161
|
+
* typing `{{prop.name}}` by hand while a `{}` button sat next to the
|
|
162
|
+
* field implying otherwise.
|
|
163
|
+
*/ assembled.push(...componentPropBindingOptions(componentProps, componentPropsOwner));
|
|
164
|
+
const entryHint = insertContext.inCollectionEntries ? undefined : 'Resolves in Collection entries blocks and on entry pages';
|
|
165
|
+
for (const entry of ENTRY_TOKEN_CATALOG){
|
|
166
|
+
assembled.push(_extends({
|
|
167
|
+
group: 'Entry',
|
|
168
|
+
label: entry.label,
|
|
169
|
+
token: entry.token,
|
|
170
|
+
preview: entry.description
|
|
171
|
+
}, entryHint ? {
|
|
172
|
+
groupHint: entryHint
|
|
173
|
+
} : {}));
|
|
174
|
+
}
|
|
175
|
+
for (const entry of COLLECTION_TOKEN_CATALOG){
|
|
176
|
+
assembled.push({
|
|
177
|
+
group: 'Collection',
|
|
178
|
+
label: entry.label,
|
|
179
|
+
token: entry.token,
|
|
180
|
+
preview: entry.description,
|
|
181
|
+
groupHint: 'Resolves on collection pages'
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
for (const entry of AUTHOR_TOKEN_CATALOG){
|
|
185
|
+
assembled.push({
|
|
186
|
+
group: 'Author',
|
|
187
|
+
label: entry.label,
|
|
188
|
+
token: entry.token,
|
|
189
|
+
preview: entry.description,
|
|
190
|
+
groupHint: 'Resolves on author pages'
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
for (const field of insertContext.datasetFields){
|
|
194
|
+
assembled.push(_extends({
|
|
195
|
+
group: 'Dataset item',
|
|
196
|
+
label: field.label,
|
|
197
|
+
token: datasetItemToken(field.id)
|
|
198
|
+
}, insertContext.datasetLabel ? {
|
|
199
|
+
groupHint: `From dataset "${insertContext.datasetLabel}"`
|
|
200
|
+
} : {}));
|
|
201
|
+
}
|
|
202
|
+
return assembled;
|
|
203
|
+
}, [
|
|
204
|
+
bindingOptions,
|
|
205
|
+
componentProps,
|
|
206
|
+
componentPropsOwner,
|
|
207
|
+
insertContext
|
|
208
|
+
]);
|
|
209
|
+
const labelContext = useMemo(()=>({
|
|
210
|
+
options,
|
|
211
|
+
variables: bindingVariables,
|
|
212
|
+
functions: bindingFunctions,
|
|
213
|
+
datasetFields: insertContext.datasetFields
|
|
214
|
+
}), [
|
|
215
|
+
options,
|
|
216
|
+
bindingVariables,
|
|
217
|
+
bindingFunctions,
|
|
218
|
+
insertContext.datasetFields
|
|
219
|
+
]);
|
|
220
|
+
return useMemo(()=>({
|
|
221
|
+
options,
|
|
222
|
+
labelContext
|
|
223
|
+
}), [
|
|
224
|
+
options,
|
|
225
|
+
labelContext
|
|
226
|
+
]);
|
|
227
|
+
}
|
|
228
|
+
export default useInsertTokenOptions;
|
|
229
|
+
|
|
230
|
+
//# sourceMappingURL=use-insert-token-options.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/hooks/use-insert-token-options.ts"],"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 AUTHOR_TOKEN_CATALOG,\n canvas,\n COLLECTION_ENTRIES_COMPONENT_ID,\n COLLECTION_TOKEN_CATALOG,\n COMPONENT_PROP_NAME_PATTERN,\n COMPONENT_PROP_TOKEN_PREFIX,\n datasetItemToken,\n EntityPickerContext,\n entityValueNeedsResolution,\n ENTRY_TOKEN_CATALOG,\n readYesNoValue,\n reusablePropDefaultValue,\n reusablePropHasAnswers,\n reusablePropValueClass,\n} from '@aglyn/aglyn'\nimport { useContext, useEffect, useMemo } from 'react'\n\nimport {\n BindingPickerContext,\n type BindingOption,\n} from '../contexts/binding-picker-context'\nimport type { TokenLabelContext } from '../utils/token-segments'\n\nexport interface InsertTokenOptionsResult {\n /**\n * The full grouped picker list (AGL-583): host bindings first (AGL-100),\n * then the data-placeholder catalogs. Entry/Collection stay browsable\n * even out of context — with a hint saying where they resolve — while\n * the Dataset item group only appears inside a resolvable repeatable.\n */\n options: BindingOption[]\n /** Display-name resolution inputs for pill rendering (AGL-586). */\n labelContext: TokenLabelContext\n}\n\n/**\n * A component's or layout's own declared props as picker options (AGL-1335).\n * A free-text field offers every one; a field with no text box is handed only\n * the properties it can be bound to (see `withPropertyBinding`).\n *\n * Names are filtered by the SAME pattern the graft requires, so a picker can\n * never offer a token that would not substitute.\n */\nexport function componentPropBindingOptions(\n componentProps: readonly Aglyn.ReusableComponentProp[] | undefined | null,\n owner: 'component' | 'layout' = 'component',\n): BindingOption[] {\n const options: BindingOption[] = []\n for (const prop of componentProps ?? []) {\n if (!COMPONENT_PROP_NAME_PATTERN.test(prop?.name ?? '')) continue\n options.push({\n group: 'Properties',\n groupHint:\n owner === 'layout'\n ? 'Set per screen in the Screen Properties of each screen using this layout'\n : 'Set per page in the Attributes panel of each instance',\n label: prop.label || prop.name,\n token: `{{${COMPONENT_PROP_TOKEN_PREFIX}${prop.name}}}`,\n preview: componentPropDefaultPreview(prop),\n })\n }\n return options\n}\n\n/** The picker's second line for a property: what a page that sets nothing gets. */\nexport function componentPropDefaultPreview(\n prop: Aglyn.ReusableComponentProp,\n): string {\n const valueClass = reusablePropValueClass(prop)\n if (valueClass === 'boolean') {\n // A yes/no has no \"nothing\": unset with no default substitutes `''`,\n // which every Yes / no reader takes for a no.\n return readYesNoValue(prop.defaultValue) === true\n ? 'Defaults to Yes'\n : 'Defaults to No'\n }\n if (valueClass === 'icon') {\n // An icon id is not something to read out; the picker shows the icon.\n return prop.defaultValue\n ? 'Defaults to the icon picked in Properties'\n : 'No default — shows no icon until a page picks one'\n }\n const fallback = reusablePropDefaultValue(prop)\n if (reusablePropHasAnswers(prop)) {\n // Named by the label a page author picks, not the value a field gets.\n const chosen = (Array.isArray(fallback) ? fallback : [fallback])\n .map((value) => {\n const answer = (prop.options ?? []).find(\n (option) => option?.value && option.value === value,\n )\n return answer ? answer.label || answer.value : undefined\n })\n .filter(Boolean)\n return chosen.length\n ? `Defaults to ${chosen.join(', ')}`\n : 'No default — the field keeps its own until a page chooses'\n }\n if (fallback === undefined) {\n return valueClass === 'text'\n ? 'No default — renders as nothing until a page sets it'\n : 'No default — the field keeps its own until a page sets it'\n }\n return `Defaults to \"${Array.isArray(fallback) ? fallback.join(', ') : String(fallback)}\"`\n}\n\n/**\n * Assembles the insert-picker options for a canvas node from ITS context\n * (AGL-583, extracted for AGL-586 so the attributes panel and the inline\n * text editor share one walk): the ancestor chain is scanned for a\n * repeatable container (dataset-item tokens need its model fields) and for\n * a Collection entries block (entry tokens resolve right there, not only\n * on entry pages). `repeatDataset` persists a dataset id OR a legacy\n * display name — either resolves against the entity picker options.\n */\nexport function useInsertTokenOptions(\n node?: Aglyn.NodeSchema<any> | null,\n): InsertTokenOptionsResult {\n const {\n options: bindingOptions,\n variables: bindingVariables,\n functions: bindingFunctions,\n componentProps,\n componentPropsOwner,\n } = useContext(BindingPickerContext)\n const entityOptions = useContext(EntityPickerContext)\n\n const insertContext = useMemo(() => {\n const nodes = (canvas.toJSON().nodes ?? {}) as Record<string, any>\n let repeatDatasetKey: string | undefined\n let inCollectionEntries = false\n let current = node?.$id ? nodes[node.$id] : undefined\n for (let hops = 0; current && hops < 100; hops += 1) {\n const props = current.props ?? {}\n if (\n !repeatDatasetKey &&\n typeof props.repeatDataset === 'string' &&\n props.repeatDataset.trim()\n ) {\n repeatDatasetKey = props.repeatDataset.trim()\n }\n if (current.componentId === COLLECTION_ENTRIES_COMPONENT_ID) {\n inCollectionEntries = true\n }\n current = current.parentId ? nodes[current.parentId] : undefined\n }\n const datasets = entityOptions.datasets ?? []\n /*\n * The browse window is a PAGE of the org's datasets, so a repeat bound to\n * one outside it matches nothing here — and this is where the token menu\n * would silently stop offering that dataset's fields on exactly the\n * orgs with enough datasets to need them. A resolution counts as a match,\n * which is the same keyed read the attributes panel already spends on a\n * picker's stored value.\n */\n const dataset = repeatDatasetKey\n ? datasets.find((candidate) => candidate.id === repeatDatasetKey) ??\n datasets.find((candidate) => candidate.label === repeatDatasetKey) ??\n entityOptions.resolved?.datasets?.[repeatDatasetKey] ??\n undefined\n : undefined\n return {\n inCollectionEntries,\n datasetLabel: dataset?.label,\n datasetFields: dataset\n ? entityOptions.datasetFields?.[dataset.id] ?? []\n : [],\n // Carried out of the walk so the effect below can ask for the dataset\n // list without repeating it.\n repeatDatasetKey,\n }\n }, [\n node,\n entityOptions.datasets,\n entityOptions.datasetFields,\n entityOptions.resolved,\n ])\n\n /**\n * Ask for the dataset list, and only when this node is inside a repeat\n * bound to one (AGL-703).\n *\n * This hook runs on every selection — the props form and the inline text\n * editor both call it — so requesting unconditionally would put the\n * provider back to reading datasets on every click. `repeatDatasetKey` is\n * the precise condition: without it there is no dataset to name and the\n * token menu offers none.\n */\n const requestEntities = entityOptions.request\n const resolveEntity = entityOptions.resolve\n useEffect(() => {\n const key = insertContext.repeatDatasetKey\n if (!key) return\n requestEntities?.('datasets')\n // Nothing to look up once the dataset is named. `repeatDataset` may hold\n // a legacy DISPLAY NAME, which the label match above answers from the\n // window — reading a document at that name as though it were an id would\n // be a read that could only ever miss.\n if (insertContext.datasetLabel) return\n const id = entityValueNeedsResolution(entityOptions, 'datasets', key)\n if (id) resolveEntity?.('datasets', id)\n }, [\n requestEntities,\n resolveEntity,\n entityOptions,\n insertContext.repeatDatasetKey,\n insertContext.datasetLabel,\n ])\n\n const options = useMemo(() => {\n const assembled: BindingOption[] = [...(bindingOptions ?? [])]\n /**\n * The component's own declared props (AGL-1335), first because they are\n * the nearest scope — inside a component definition, `{{prop.x}}` is\n * what the author reaches for most.\n *\n * They were absent from this picker entirely, so binding one meant\n * typing `{{prop.name}}` by hand while a `{}` button sat next to the\n * field implying otherwise.\n */\n assembled.push(\n ...componentPropBindingOptions(componentProps, componentPropsOwner),\n )\n const entryHint = insertContext.inCollectionEntries\n ? undefined\n : 'Resolves in Collection entries blocks and on entry pages'\n for (const entry of ENTRY_TOKEN_CATALOG) {\n assembled.push({\n group: 'Entry',\n label: entry.label,\n token: entry.token,\n preview: entry.description,\n ...(entryHint ? { groupHint: entryHint } : {}),\n })\n }\n for (const entry of COLLECTION_TOKEN_CATALOG) {\n assembled.push({\n group: 'Collection',\n label: entry.label,\n token: entry.token,\n preview: entry.description,\n groupHint: 'Resolves on collection pages',\n })\n }\n for (const entry of AUTHOR_TOKEN_CATALOG) {\n assembled.push({\n group: 'Author',\n label: entry.label,\n token: entry.token,\n preview: entry.description,\n groupHint: 'Resolves on author pages',\n })\n }\n for (const field of insertContext.datasetFields) {\n assembled.push({\n group: 'Dataset item',\n label: field.label,\n token: datasetItemToken(field.id),\n ...(insertContext.datasetLabel\n ? { groupHint: `From dataset \"${insertContext.datasetLabel}\"` }\n : {}),\n })\n }\n return assembled\n }, [bindingOptions, componentProps, componentPropsOwner, insertContext])\n\n const labelContext = useMemo<TokenLabelContext>(\n () => ({\n options,\n variables: bindingVariables as TokenLabelContext['variables'],\n functions: bindingFunctions as TokenLabelContext['functions'],\n datasetFields: insertContext.datasetFields,\n }),\n [options, bindingVariables, bindingFunctions, insertContext.datasetFields],\n )\n\n return useMemo(\n () => ({ options, labelContext }),\n [options, labelContext],\n )\n}\n\nexport default useInsertTokenOptions\n"],"names":["AUTHOR_TOKEN_CATALOG","canvas","COLLECTION_ENTRIES_COMPONENT_ID","COLLECTION_TOKEN_CATALOG","COMPONENT_PROP_NAME_PATTERN","COMPONENT_PROP_TOKEN_PREFIX","datasetItemToken","EntityPickerContext","entityValueNeedsResolution","ENTRY_TOKEN_CATALOG","readYesNoValue","reusablePropDefaultValue","reusablePropHasAnswers","reusablePropValueClass","useContext","useEffect","useMemo","BindingPickerContext","componentPropBindingOptions","componentProps","owner","options","prop","test","name","push","group","groupHint","label","token","preview","componentPropDefaultPreview","valueClass","defaultValue","fallback","chosen","Array","isArray","map","value","answer","find","option","undefined","filter","Boolean","length","join","String","useInsertTokenOptions","node","bindingOptions","variables","bindingVariables","functions","bindingFunctions","componentPropsOwner","entityOptions","insertContext","datasets","nodes","toJSON","repeatDatasetKey","inCollectionEntries","current","$id","hops","props","repeatDataset","trim","componentId","parentId","dataset","candidate","id","resolved","datasetLabel","datasetFields","requestEntities","request","resolveEntity","resolve","key","assembled","entryHint","entry","description","field","labelContext"],"mappings":"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"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 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
|
+
*/
|
|
17
|
+
import type * as Aglyn from '@aglyn/aglyn';
|
|
18
|
+
import * as Besigner from '@aglyn/besigner';
|
|
19
|
+
import { useDraggable } from '@dnd-kit/core';
|
|
20
|
+
export type NodeDragItem = {
|
|
21
|
+
node?: Aglyn.NodeSchema<any>;
|
|
22
|
+
};
|
|
23
|
+
export declare function useLeafDrag(node: NodeDragItem['node'], type: Besigner.DragType): ReturnType<typeof useDraggable>;
|
|
24
|
+
export default useLeafDrag;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2022 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 { useDraggable } from "@dnd-kit/core";
|
|
17
|
+
export function useLeafDrag(node, type) {
|
|
18
|
+
return useDraggable({
|
|
19
|
+
id: `${type}:${node == null ? void 0 : node.$id}`,
|
|
20
|
+
data: {
|
|
21
|
+
type,
|
|
22
|
+
node
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
export default useLeafDrag;
|
|
27
|
+
|
|
28
|
+
//# sourceMappingURL=use-leaf-drag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/hooks/use-leaf-drag.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2022 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 * as Besigner from '@aglyn/besigner'\nimport { useDraggable } from '@dnd-kit/core'\n\nexport type NodeDragItem = {\n node?: Aglyn.NodeSchema<any>\n}\n\nexport function useLeafDrag(\n node: NodeDragItem['node'],\n type: Besigner.DragType,\n): ReturnType<typeof useDraggable> {\n return useDraggable({\n id: `${type}:${node?.$id}`,\n data: {\n type,\n node,\n },\n })\n}\nexport default useLeafDrag\n"],"names":["useDraggable","useLeafDrag","node","type","id","$id","data"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAID,SAASA,YAAY,QAAQ,gBAAe;AAM5C,OAAO,SAASC,YACdC,IAA0B,EAC1BC,IAAuB;IAEvB,OAAOH,aAAa;QAClBI,IAAI,GAAGD,KAAK,CAAC,EAAED,wBAAAA,KAAMG,GAAG,EAAE;QAC1BC,MAAM;YACJH;YACAD;QACF;IACF;AACF;AACA,eAAeD,YAAW"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 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
|
+
*/
|
|
17
|
+
import type * as Aglyn from '@aglyn/aglyn';
|
|
18
|
+
import * as Besigner from '@aglyn/besigner';
|
|
19
|
+
import { useDroppable } from '@dnd-kit/core';
|
|
20
|
+
export type NodeDropArea = {
|
|
21
|
+
node?: Aglyn.NodeSchema<any>;
|
|
22
|
+
};
|
|
23
|
+
export declare function useLeafDrop(node: Aglyn.NodeSchema<any>, accept?: Besigner.DragType[],
|
|
24
|
+
/**
|
|
25
|
+
* Distinct surface rendering this droppable (tree, breadcrumbs, ...).
|
|
26
|
+
* Multiple surfaces register droppables for the same node simultaneously;
|
|
27
|
+
* without a discriminator their dnd-kit ids collide and the later mount
|
|
28
|
+
* evicts the earlier one from the registry, leaving dead drop targets.
|
|
29
|
+
*/
|
|
30
|
+
area?: string): ReturnType<typeof useDroppable>;
|
|
31
|
+
export default useLeafDrop;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
* Copyright 2023 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 Besigner from "@aglyn/besigner";
|
|
17
|
+
import { useDroppable } from "@dnd-kit/core";
|
|
18
|
+
const acceptAll = Object.values(Besigner.DragType);
|
|
19
|
+
export function useLeafDrop(node, accept = acceptAll, /**
|
|
20
|
+
* Distinct surface rendering this droppable (tree, breadcrumbs, ...).
|
|
21
|
+
* Multiple surfaces register droppables for the same node simultaneously;
|
|
22
|
+
* without a discriminator their dnd-kit ids collide and the later mount
|
|
23
|
+
* evicts the earlier one from the registry, leaving dead drop targets.
|
|
24
|
+
*/ area = 'leaf') {
|
|
25
|
+
// Disable the droppable for the node that is currently being dragged.
|
|
26
|
+
// Without a DragOverlay the draggable element receives the CSS transform
|
|
27
|
+
// and moves with the cursor, which shifts its droppable rect to the cursor
|
|
28
|
+
// position. This causes it to win every pointerWithin collision check and
|
|
29
|
+
// prevents leaf nodes (like an empty Container) from ever being detected as
|
|
30
|
+
// the drop target.
|
|
31
|
+
const isBeingDragged = Besigner.dnd.isDraggingNode(node);
|
|
32
|
+
return useDroppable({
|
|
33
|
+
id: `drop:${area}:${node == null ? void 0 : node.$id}:${accept}`,
|
|
34
|
+
disabled: isBeingDragged,
|
|
35
|
+
data: {
|
|
36
|
+
accept,
|
|
37
|
+
node
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
export default useLeafDrop;
|
|
42
|
+
|
|
43
|
+
//# sourceMappingURL=use-leaf-drop.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/hooks/use-leaf-drop.ts"],"sourcesContent":["/**\n * @license\n * Copyright 2023 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 * as Besigner from '@aglyn/besigner'\nimport { useDroppable } from '@dnd-kit/core'\n\nexport type NodeDropArea = {\n node?: Aglyn.NodeSchema<any>\n}\n\nconst acceptAll = Object.values(Besigner.DragType)\n\nexport function useLeafDrop(\n node: Aglyn.NodeSchema<any>,\n accept: Besigner.DragType[] = acceptAll,\n /**\n * Distinct surface rendering this droppable (tree, breadcrumbs, ...).\n * Multiple surfaces register droppables for the same node simultaneously;\n * without a discriminator their dnd-kit ids collide and the later mount\n * evicts the earlier one from the registry, leaving dead drop targets.\n */\n area = 'leaf',\n): ReturnType<typeof useDroppable> {\n // Disable the droppable for the node that is currently being dragged.\n // Without a DragOverlay the draggable element receives the CSS transform\n // and moves with the cursor, which shifts its droppable rect to the cursor\n // position. This causes it to win every pointerWithin collision check and\n // prevents leaf nodes (like an empty Container) from ever being detected as\n // the drop target.\n const isBeingDragged = Besigner.dnd.isDraggingNode(node)\n\n return useDroppable({\n id: `drop:${area}:${node?.$id}:${accept}`,\n disabled: isBeingDragged,\n data: {\n accept,\n node,\n },\n })\n}\nexport default useLeafDrop\n"],"names":["Besigner","useDroppable","acceptAll","Object","values","DragType","useLeafDrop","node","accept","area","isBeingDragged","dnd","isDraggingNode","id","$id","disabled","data"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAGD,YAAYA,cAAc,kBAAiB;AAC3C,SAASC,YAAY,QAAQ,gBAAe;AAM5C,MAAMC,YAAYC,OAAOC,MAAM,CAACJ,SAASK,QAAQ;AAEjD,OAAO,SAASC,YACdC,IAA2B,EAC3BC,SAA8BN,SAAS,EACvC;;;;;GAKC,GACDO,OAAO,MAAM;IAEb,sEAAsE;IACtE,yEAAyE;IACzE,2EAA2E;IAC3E,0EAA0E;IAC1E,4EAA4E;IAC5E,mBAAmB;IACnB,MAAMC,iBAAiBV,SAASW,GAAG,CAACC,cAAc,CAACL;IAEnD,OAAON,aAAa;QAClBY,IAAI,CAAC,KAAK,EAAEJ,KAAK,CAAC,EAAEF,wBAAAA,KAAMO,GAAG,CAAC,CAAC,EAAEN,QAAQ;QACzCO,UAAUL;QACVM,MAAM;YACJR;YACAD;QACF;IACF;AACF;AACA,eAAeD,YAAW"}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { MarkdownFieldHandle } from '@aglyn/aglyn-markdown-editor';
|
|
2
|
+
export interface MarkdownMediaPicker {
|
|
3
|
+
/** Pass to `MarkdownField`'s `editorRef`. */
|
|
4
|
+
editorRef: (handle: MarkdownFieldHandle | null) => void;
|
|
5
|
+
/**
|
|
6
|
+
* Pass to `MarkdownField`'s `onPickImageFromMedia`. `undefined` when the
|
|
7
|
+
* host supplies no picker, which is what makes the editor keep offering its
|
|
8
|
+
* own URL prompt instead of a dead "Choose from media" button — the email
|
|
9
|
+
* besigner has no media scope and mounts no provider.
|
|
10
|
+
*/
|
|
11
|
+
onPickImageFromMedia?: (alt: string) => void;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Wires a `MarkdownField` on a besigner surface to the host's media library
|
|
15
|
+
* (AGL-1645).
|
|
16
|
+
*
|
|
17
|
+
* Both besigner surfaces — the attributes panel and the in-place canvas editor
|
|
18
|
+
* — took the editor complete except for this callback, so the toolbar's image
|
|
19
|
+
* action opened a "paste a URL" prompt while every other image attribute in the
|
|
20
|
+
* designer opened the DAM. Same context, same picker, same pipeline the
|
|
21
|
+
* Attributes panel's Browse button and AGL-1304's instance `src` edit already
|
|
22
|
+
* use; nothing new is invented here.
|
|
23
|
+
*
|
|
24
|
+
* ## The picked value is stored VERBATIM
|
|
25
|
+
*
|
|
26
|
+
* Which is what every other besigner surface does, and it took AGL-1686 to get
|
|
27
|
+
* back to it.
|
|
28
|
+
*
|
|
29
|
+
* `onPickMedia` hands back what an attribute should store: a
|
|
30
|
+
* `media:{scope}/{mediaId}` reference for library assets (AGL-1215). The first
|
|
31
|
+
* pass resolved that to a `/api/media/cdn/…` path HERE, at insert time,
|
|
32
|
+
* because no markdown-lite renderer called `resolveMediaSrc` and a reference in
|
|
33
|
+
* a document would have rendered nothing. All five now resolve, so the reason
|
|
34
|
+
* is gone — and keeping the workaround anyway would not be belt-and-braces, it
|
|
35
|
+
* would be a downgrade:
|
|
36
|
+
*
|
|
37
|
+
* * **It bakes the route into the content.** A CDN path in a document couples
|
|
38
|
+
* every screen, layout, component and template on every host to a delivery
|
|
39
|
+
* detail that has already changed once (AGL-829). That coupling is the whole
|
|
40
|
+
* thing the reference exists to remove.
|
|
41
|
+
* * **It is lossy in a way the renderer cannot undo.** Resolving early freezes
|
|
42
|
+
* the picker's best-guess host qualification. `hostQualifiedScope` re-points
|
|
43
|
+
* a reference at whichever site is actually rendering, which is what lets ONE
|
|
44
|
+
* image in a reusable component or a shared layout work on every site that
|
|
45
|
+
* uses it. A resolved path can only ever name one of them.
|
|
46
|
+
*
|
|
47
|
+
* The reference reaches the document unchanged, and `parseMarkdownLite` now
|
|
48
|
+
* accepts it — the other half of AGL-1686, without which the editor would
|
|
49
|
+
* insert a row that the next parse silently deleted.
|
|
50
|
+
*
|
|
51
|
+
* ## Focus
|
|
52
|
+
*
|
|
53
|
+
* The picker is a modal dialog and it steals focus, which is the class of
|
|
54
|
+
* interaction that breaks a blur-committed editor. Neither surface commits on
|
|
55
|
+
* blur — the panel is on react-final-form's debounce, the canvas on
|
|
56
|
+
* `useDebouncedCommit` — and the dialog is portaled outside both editors'
|
|
57
|
+
* React subtrees, so its Escape never reaches the canvas editor's own
|
|
58
|
+
* close-on-Escape. The insert itself arrives through the imperative handle
|
|
59
|
+
* rather than through focus, so it does not care where the caret went; the
|
|
60
|
+
* editor falls back to appending when its last selection is gone.
|
|
61
|
+
*/
|
|
62
|
+
export declare function useMarkdownMediaPicker(): MarkdownMediaPicker;
|
|
63
|
+
export default useMarkdownMediaPicker;
|
|
@@ -0,0 +1,110 @@
|
|
|
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 { inheritedMediaAlt, isSupportedImageSrc } from "@aglyn/aglyn";
|
|
18
|
+
import { useCallback, useContext, useMemo, useRef } from "react";
|
|
19
|
+
import { MediaPickerContext } from "../contexts/media-picker-context.js";
|
|
20
|
+
/**
|
|
21
|
+
* Wires a `MarkdownField` on a besigner surface to the host's media library
|
|
22
|
+
* (AGL-1645).
|
|
23
|
+
*
|
|
24
|
+
* Both besigner surfaces — the attributes panel and the in-place canvas editor
|
|
25
|
+
* — took the editor complete except for this callback, so the toolbar's image
|
|
26
|
+
* action opened a "paste a URL" prompt while every other image attribute in the
|
|
27
|
+
* designer opened the DAM. Same context, same picker, same pipeline the
|
|
28
|
+
* Attributes panel's Browse button and AGL-1304's instance `src` edit already
|
|
29
|
+
* use; nothing new is invented here.
|
|
30
|
+
*
|
|
31
|
+
* ## The picked value is stored VERBATIM
|
|
32
|
+
*
|
|
33
|
+
* Which is what every other besigner surface does, and it took AGL-1686 to get
|
|
34
|
+
* back to it.
|
|
35
|
+
*
|
|
36
|
+
* `onPickMedia` hands back what an attribute should store: a
|
|
37
|
+
* `media:{scope}/{mediaId}` reference for library assets (AGL-1215). The first
|
|
38
|
+
* pass resolved that to a `/api/media/cdn/…` path HERE, at insert time,
|
|
39
|
+
* because no markdown-lite renderer called `resolveMediaSrc` and a reference in
|
|
40
|
+
* a document would have rendered nothing. All five now resolve, so the reason
|
|
41
|
+
* is gone — and keeping the workaround anyway would not be belt-and-braces, it
|
|
42
|
+
* would be a downgrade:
|
|
43
|
+
*
|
|
44
|
+
* * **It bakes the route into the content.** A CDN path in a document couples
|
|
45
|
+
* every screen, layout, component and template on every host to a delivery
|
|
46
|
+
* detail that has already changed once (AGL-829). That coupling is the whole
|
|
47
|
+
* thing the reference exists to remove.
|
|
48
|
+
* * **It is lossy in a way the renderer cannot undo.** Resolving early freezes
|
|
49
|
+
* the picker's best-guess host qualification. `hostQualifiedScope` re-points
|
|
50
|
+
* a reference at whichever site is actually rendering, which is what lets ONE
|
|
51
|
+
* image in a reusable component or a shared layout work on every site that
|
|
52
|
+
* uses it. A resolved path can only ever name one of them.
|
|
53
|
+
*
|
|
54
|
+
* The reference reaches the document unchanged, and `parseMarkdownLite` now
|
|
55
|
+
* accepts it — the other half of AGL-1686, without which the editor would
|
|
56
|
+
* insert a row that the next parse silently deleted.
|
|
57
|
+
*
|
|
58
|
+
* ## Focus
|
|
59
|
+
*
|
|
60
|
+
* The picker is a modal dialog and it steals focus, which is the class of
|
|
61
|
+
* interaction that breaks a blur-committed editor. Neither surface commits on
|
|
62
|
+
* blur — the panel is on react-final-form's debounce, the canvas on
|
|
63
|
+
* `useDebouncedCommit` — and the dialog is portaled outside both editors'
|
|
64
|
+
* React subtrees, so its Escape never reaches the canvas editor's own
|
|
65
|
+
* close-on-Escape. The insert itself arrives through the imperative handle
|
|
66
|
+
* rather than through focus, so it does not care where the caret went; the
|
|
67
|
+
* editor falls back to appending when its last selection is gone.
|
|
68
|
+
*/ export function useMarkdownMediaPicker() {
|
|
69
|
+
const { onPickMedia } = useContext(MediaPickerContext);
|
|
70
|
+
const handleRef = useRef(null);
|
|
71
|
+
const editorRef = useCallback((handle)=>{
|
|
72
|
+
handleRef.current = handle;
|
|
73
|
+
}, []);
|
|
74
|
+
const onPickImageFromMedia = useMemo(()=>{
|
|
75
|
+
if (!onPickMedia) return undefined;
|
|
76
|
+
return (alt)=>{
|
|
77
|
+
onPickMedia((stored, asset)=>{
|
|
78
|
+
var _inheritedMediaAlt;
|
|
79
|
+
var _handleRef_current;
|
|
80
|
+
// Gated on what the PARSER keeps, not on what resolves: a value the
|
|
81
|
+
// editor accepts and the parser drops is an image that disappears on
|
|
82
|
+
// the next load with nothing logged, which is exactly how AGL-1645
|
|
83
|
+
// shipped broken. `insertImage` re-checks with the same predicate, so
|
|
84
|
+
// this is the early, reportable refusal rather than the guard.
|
|
85
|
+
if (!stored || !isSupportedImageSrc(stored)) return;
|
|
86
|
+
// The asset's stored alt fills a blank dialog field (AGL-1896).
|
|
87
|
+
// This surface needs the default MORE than the others, not less: an
|
|
88
|
+
// image row's alt is fixed at insert time and the editor offers no
|
|
89
|
+
// way to edit it afterwards, so an alt left empty here is
|
|
90
|
+
// unrepairable short of deleting the row and inserting it again.
|
|
91
|
+
// A typed alt still wins — `inheritedMediaAlt` returns undefined for
|
|
92
|
+
// one, and the `?? alt` below keeps it verbatim.
|
|
93
|
+
const resolvedAlt = (_inheritedMediaAlt = inheritedMediaAlt({
|
|
94
|
+
placementAlt: alt,
|
|
95
|
+
assetAlt: asset == null ? void 0 : asset.alt
|
|
96
|
+
})) != null ? _inheritedMediaAlt : alt;
|
|
97
|
+
(_handleRef_current = handleRef.current) == null ? void 0 : _handleRef_current.insertImage(resolvedAlt, stored);
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
}, [
|
|
101
|
+
onPickMedia
|
|
102
|
+
]);
|
|
103
|
+
return {
|
|
104
|
+
editorRef,
|
|
105
|
+
onPickImageFromMedia
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
export default useMarkdownMediaPicker;
|
|
109
|
+
|
|
110
|
+
//# sourceMappingURL=use-markdown-media-picker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/hooks/use-markdown-media-picker.ts"],"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'use client'\n\nimport { inheritedMediaAlt, isSupportedImageSrc } from '@aglyn/aglyn'\nimport type { MarkdownFieldHandle } from '@aglyn/aglyn-markdown-editor'\nimport { useCallback, useContext, useMemo, useRef } from 'react'\nimport { MediaPickerContext } from '../contexts/media-picker-context'\n\nexport interface MarkdownMediaPicker {\n /** Pass to `MarkdownField`'s `editorRef`. */\n editorRef: (handle: MarkdownFieldHandle | null) => void\n /**\n * Pass to `MarkdownField`'s `onPickImageFromMedia`. `undefined` when the\n * host supplies no picker, which is what makes the editor keep offering its\n * own URL prompt instead of a dead \"Choose from media\" button — the email\n * besigner has no media scope and mounts no provider.\n */\n onPickImageFromMedia?: (alt: string) => void\n}\n\n/**\n * Wires a `MarkdownField` on a besigner surface to the host's media library\n * (AGL-1645).\n *\n * Both besigner surfaces — the attributes panel and the in-place canvas editor\n * — took the editor complete except for this callback, so the toolbar's image\n * action opened a \"paste a URL\" prompt while every other image attribute in the\n * designer opened the DAM. Same context, same picker, same pipeline the\n * Attributes panel's Browse button and AGL-1304's instance `src` edit already\n * use; nothing new is invented here.\n *\n * ## The picked value is stored VERBATIM\n *\n * Which is what every other besigner surface does, and it took AGL-1686 to get\n * back to it.\n *\n * `onPickMedia` hands back what an attribute should store: a\n * `media:{scope}/{mediaId}` reference for library assets (AGL-1215). The first\n * pass resolved that to a `/api/media/cdn/…` path HERE, at insert time,\n * because no markdown-lite renderer called `resolveMediaSrc` and a reference in\n * a document would have rendered nothing. All five now resolve, so the reason\n * is gone — and keeping the workaround anyway would not be belt-and-braces, it\n * would be a downgrade:\n *\n * * **It bakes the route into the content.** A CDN path in a document couples\n * every screen, layout, component and template on every host to a delivery\n * detail that has already changed once (AGL-829). That coupling is the whole\n * thing the reference exists to remove.\n * * **It is lossy in a way the renderer cannot undo.** Resolving early freezes\n * the picker's best-guess host qualification. `hostQualifiedScope` re-points\n * a reference at whichever site is actually rendering, which is what lets ONE\n * image in a reusable component or a shared layout work on every site that\n * uses it. A resolved path can only ever name one of them.\n *\n * The reference reaches the document unchanged, and `parseMarkdownLite` now\n * accepts it — the other half of AGL-1686, without which the editor would\n * insert a row that the next parse silently deleted.\n *\n * ## Focus\n *\n * The picker is a modal dialog and it steals focus, which is the class of\n * interaction that breaks a blur-committed editor. Neither surface commits on\n * blur — the panel is on react-final-form's debounce, the canvas on\n * `useDebouncedCommit` — and the dialog is portaled outside both editors'\n * React subtrees, so its Escape never reaches the canvas editor's own\n * close-on-Escape. The insert itself arrives through the imperative handle\n * rather than through focus, so it does not care where the caret went; the\n * editor falls back to appending when its last selection is gone.\n */\nexport function useMarkdownMediaPicker(): MarkdownMediaPicker {\n const { onPickMedia } = useContext(MediaPickerContext)\n const handleRef = useRef<MarkdownFieldHandle | null>(null)\n\n const editorRef = useCallback((handle: MarkdownFieldHandle | null) => {\n handleRef.current = handle\n }, [])\n\n const onPickImageFromMedia = useMemo(() => {\n if (!onPickMedia) return undefined\n return (alt: string) => {\n onPickMedia((stored, asset) => {\n // Gated on what the PARSER keeps, not on what resolves: a value the\n // editor accepts and the parser drops is an image that disappears on\n // the next load with nothing logged, which is exactly how AGL-1645\n // shipped broken. `insertImage` re-checks with the same predicate, so\n // this is the early, reportable refusal rather than the guard.\n if (!stored || !isSupportedImageSrc(stored)) return\n // The asset's stored alt fills a blank dialog field (AGL-1896).\n // This surface needs the default MORE than the others, not less: an\n // image row's alt is fixed at insert time and the editor offers no\n // way to edit it afterwards, so an alt left empty here is\n // unrepairable short of deleting the row and inserting it again.\n // A typed alt still wins — `inheritedMediaAlt` returns undefined for\n // one, and the `?? alt` below keeps it verbatim.\n const resolvedAlt =\n inheritedMediaAlt({\n placementAlt: alt,\n assetAlt: asset?.alt,\n }) ?? alt\n handleRef.current?.insertImage(resolvedAlt, stored)\n })\n }\n }, [onPickMedia])\n\n return { editorRef, onPickImageFromMedia }\n}\n\nexport default useMarkdownMediaPicker\n"],"names":["inheritedMediaAlt","isSupportedImageSrc","useCallback","useContext","useMemo","useRef","MediaPickerContext","useMarkdownMediaPicker","onPickMedia","handleRef","editorRef","handle","current","onPickImageFromMedia","undefined","alt","stored","asset","resolvedAlt","placementAlt","assetAlt","insertImage"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;AAEA,SAASA,iBAAiB,EAAEC,mBAAmB,QAAQ,eAAc;AAErE,SAASC,WAAW,EAAEC,UAAU,EAAEC,OAAO,EAAEC,MAAM,QAAQ,QAAO;AAChE,SAASC,kBAAkB,QAAQ,sCAAkC;AAcrE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgDC,GACD,OAAO,SAASC;IACd,MAAM,EAAEC,WAAW,EAAE,GAAGL,WAAWG;IACnC,MAAMG,YAAYJ,OAAmC;IAErD,MAAMK,YAAYR,YAAY,CAACS;QAC7BF,UAAUG,OAAO,GAAGD;IACtB,GAAG,EAAE;IAEL,MAAME,uBAAuBT,QAAQ;QACnC,IAAI,CAACI,aAAa,OAAOM;QACzB,OAAO,CAACC;YACNP,YAAY,CAACQ,QAAQC;oBAejBjB;oBAIFS;gBAlBA,oEAAoE;gBACpE,qEAAqE;gBACrE,mEAAmE;gBACnE,sEAAsE;gBACtE,+DAA+D;gBAC/D,IAAI,CAACO,UAAU,CAACf,oBAAoBe,SAAS;gBAC7C,gEAAgE;gBAChE,oEAAoE;gBACpE,mEAAmE;gBACnE,0DAA0D;gBAC1D,iEAAiE;gBACjE,qEAAqE;gBACrE,iDAAiD;gBACjD,MAAME,eACJlB,qBAAAA,kBAAkB;oBAChBmB,cAAcJ;oBACdK,QAAQ,EAAEH,yBAAAA,MAAOF,GAAG;gBACtB,cAHAf,qBAGMe;iBACRN,qBAAAA,UAAUG,OAAO,qBAAjBH,mBAAmBY,WAAW,CAACH,aAAaF;YAC9C;QACF;IACF,GAAG;QAACR;KAAY;IAEhB,OAAO;QAAEE;QAAWG;IAAqB;AAC3C;AAEA,eAAeN,uBAAsB"}
|