@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,64 @@
|
|
|
1
|
+
import { type RepeatableDataset, type RepeatScope } from '@aglyn/aglyn/app-utils/expand-repeatables';
|
|
2
|
+
/** What a repeating element draws on the canvas. */
|
|
3
|
+
export interface RepeatPreview {
|
|
4
|
+
/** What authors call the thing being repeated, for the badge. */
|
|
5
|
+
label: string;
|
|
6
|
+
/**
|
|
7
|
+
* The records this element renders, in order, bounded exactly as the
|
|
8
|
+
* published page's composition bounds them.
|
|
9
|
+
*/
|
|
10
|
+
records: ReadonlyArray<Record<string, unknown>>;
|
|
11
|
+
/** Which scope applies, so the canvas draws what the page will build. */
|
|
12
|
+
scope: RepeatScope;
|
|
13
|
+
/** The repeated rows, for the token substitution's reference hops. */
|
|
14
|
+
dataset?: RepeatableDataset;
|
|
15
|
+
/** Every key the rows answered under, for a one-hop reference (AGL-180). */
|
|
16
|
+
datasetsByKey?: Readonly<Record<string, RepeatableDataset>>;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The rows a canvas element repeats over, and the copies it therefore draws
|
|
20
|
+
* (AGL-3111).
|
|
21
|
+
*
|
|
22
|
+
* The designer cannot read them itself — it renders inside a plugin sandbox,
|
|
23
|
+
* and which documents hold them is the source's business — so this HOLDS the
|
|
24
|
+
* request and reads back whatever the host app's reader filed. Without a
|
|
25
|
+
* provider, or before an answer, it returns `undefined` and the element draws
|
|
26
|
+
* its template once, the way the canvas always did.
|
|
27
|
+
*
|
|
28
|
+
* The records are {@link repeatedRecords}, not a second reading of the same
|
|
29
|
+
* props: the filter, the sort, the limit and `REPEAT_MAX_RECORDS` are applied
|
|
30
|
+
* by the function the page applies them with, so a copy on the canvas is a
|
|
31
|
+
* copy a visitor gets.
|
|
32
|
+
*/
|
|
33
|
+
export declare function useRepeatPreview(node: unknown): RepeatPreview | undefined;
|
|
34
|
+
/**
|
|
35
|
+
* The copies a repeating element draws BESIDE the one an author edits
|
|
36
|
+
* (AGL-3111): records 2..n, as denormalized trees ready for an inert render.
|
|
37
|
+
*
|
|
38
|
+
* The first record is deliberately missing. It is drawn by the element's own
|
|
39
|
+
* children — the real canvas nodes, selectable and draggable, with that
|
|
40
|
+
* record's values laid over their render copies through
|
|
41
|
+
* {@link RepeatRecordContext}. That is what makes editing the template edit
|
|
42
|
+
* every copy: there is one template, it is on the canvas, and the copies are
|
|
43
|
+
* pictures of it.
|
|
44
|
+
*
|
|
45
|
+
* Built by running the published page's own {@link expandRepeatables} over a
|
|
46
|
+
* snapshot of this subtree, so the canvas cannot draw a shape the page would
|
|
47
|
+
* not compose.
|
|
48
|
+
*/
|
|
49
|
+
export declare function useRepeatCopies(node: {
|
|
50
|
+
$id?: string;
|
|
51
|
+
parentId?: string;
|
|
52
|
+
} | null | undefined, preview: RepeatPreview | undefined): any[];
|
|
53
|
+
/**
|
|
54
|
+
* A node's render copy with the record its subtree is drawing laid over it
|
|
55
|
+
* (AGL-3111).
|
|
56
|
+
*
|
|
57
|
+
* Inside a repeating element the FIRST record's values belong on the real
|
|
58
|
+
* canvas nodes, so the element an author edits reads as the first copy rather
|
|
59
|
+
* than as a row of raw `{{item.*}}` tokens beside the copies that resolved
|
|
60
|
+
* them. Render copies only — the node keeps its tokens, and every save writes
|
|
61
|
+
* the template.
|
|
62
|
+
*/
|
|
63
|
+
export declare function useNodeWithRepeatRecord<N>(node: N): N;
|
|
64
|
+
export default useRepeatPreview;
|
|
@@ -0,0 +1,214 @@
|
|
|
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 { canvas } from "@aglyn/aglyn";
|
|
19
|
+
// By path: the repeat rules and the source registry stay out of every
|
|
20
|
+
// `@aglyn/aglyn` barrel, so nothing on a published page can pull them in.
|
|
21
|
+
import { expandRepeatables, repeatedRecords, repeatScope, substituteRecordTokens } from "@aglyn/aglyn/app-utils/expand-repeatables";
|
|
22
|
+
import { repeatSourceOf } from "@aglyn/aglyn/app-utils/repeat-sources";
|
|
23
|
+
import { useContext, useEffect, useMemo, useSyncExternalStore } from "react";
|
|
24
|
+
import { RepeatRowsContext, repeatRowsKey } from "../contexts/repeat-rows-context.js";
|
|
25
|
+
import { RepeatRecordContext } from "../contexts/repeat-record-context.js";
|
|
26
|
+
const subscribeToNothing = ()=>()=>undefined;
|
|
27
|
+
const noVersion = ()=>0;
|
|
28
|
+
/**
|
|
29
|
+
* The rows a canvas element repeats over, and the copies it therefore draws
|
|
30
|
+
* (AGL-3111).
|
|
31
|
+
*
|
|
32
|
+
* The designer cannot read them itself — it renders inside a plugin sandbox,
|
|
33
|
+
* and which documents hold them is the source's business — so this HOLDS the
|
|
34
|
+
* request and reads back whatever the host app's reader filed. Without a
|
|
35
|
+
* provider, or before an answer, it returns `undefined` and the element draws
|
|
36
|
+
* its template once, the way the canvas always did.
|
|
37
|
+
*
|
|
38
|
+
* The records are {@link repeatedRecords}, not a second reading of the same
|
|
39
|
+
* props: the filter, the sort, the limit and `REPEAT_MAX_RECORDS` are applied
|
|
40
|
+
* by the function the page applies them with, so a copy on the canvas is a
|
|
41
|
+
* copy a visitor gets.
|
|
42
|
+
*/ export function useRepeatPreview(node) {
|
|
43
|
+
const source = useContext(RepeatRowsContext);
|
|
44
|
+
const props = node == null ? void 0 : node.props;
|
|
45
|
+
// MobX props are observable and change in place; their JSON keys the memos
|
|
46
|
+
// below, the way every other render copy in the canvas is keyed.
|
|
47
|
+
const propsJson = JSON.stringify(props != null ? props : null);
|
|
48
|
+
const request = useMemo(()=>{
|
|
49
|
+
const repeat = source ? repeatSourceOf({
|
|
50
|
+
props
|
|
51
|
+
}) : undefined;
|
|
52
|
+
return repeat ? {
|
|
53
|
+
sourceId: repeat.source.id,
|
|
54
|
+
key: repeat.key,
|
|
55
|
+
label: repeat.source.label
|
|
56
|
+
} : undefined;
|
|
57
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
58
|
+
}, [
|
|
59
|
+
source,
|
|
60
|
+
props,
|
|
61
|
+
propsJson
|
|
62
|
+
]);
|
|
63
|
+
const key = request ? repeatRowsKey(request) : '';
|
|
64
|
+
useEffect(()=>{
|
|
65
|
+
if (!source || !request) return undefined;
|
|
66
|
+
return source.retain(request);
|
|
67
|
+
// `key` stands in for `request`: the same source and key keeps the read
|
|
68
|
+
// it already holds rather than dropping and re-taking it.
|
|
69
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
70
|
+
}, [
|
|
71
|
+
source,
|
|
72
|
+
key
|
|
73
|
+
]);
|
|
74
|
+
const version = useSyncExternalStore(source && request ? source.subscribe : subscribeToNothing, source ? source.getVersion : noVersion, noVersion);
|
|
75
|
+
return useMemo(()=>{
|
|
76
|
+
if (!source || !request) return undefined;
|
|
77
|
+
const answer = source.get(key);
|
|
78
|
+
if ((answer == null ? void 0 : answer.status) !== 'ready') return undefined;
|
|
79
|
+
const dataset = answer.rowsByKey[request.key];
|
|
80
|
+
const records = repeatedRecords({
|
|
81
|
+
props
|
|
82
|
+
}, dataset);
|
|
83
|
+
if (!records.length) return undefined;
|
|
84
|
+
return {
|
|
85
|
+
label: answer.label,
|
|
86
|
+
records,
|
|
87
|
+
scope: repeatScope(node),
|
|
88
|
+
dataset,
|
|
89
|
+
datasetsByKey: answer.rowsByKey
|
|
90
|
+
};
|
|
91
|
+
// `version` carries a new answer in; the body reads it through `get`.
|
|
92
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
|
+
}, [
|
|
94
|
+
source,
|
|
95
|
+
request,
|
|
96
|
+
key,
|
|
97
|
+
version,
|
|
98
|
+
node,
|
|
99
|
+
props,
|
|
100
|
+
propsJson
|
|
101
|
+
]);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* The stored subtree under `rootId`, as a plain snapshot.
|
|
105
|
+
*
|
|
106
|
+
* Canvas nodes are MobX observables the expansion must not read through — it
|
|
107
|
+
* copies props by reference into the copies it builds, and an observable read
|
|
108
|
+
* outside a reaction is both a stale value and a missing dependency.
|
|
109
|
+
*/ function subtreeSnapshot(rootId) {
|
|
110
|
+
var _canvas_toJSON_nodes;
|
|
111
|
+
const nodes = (_canvas_toJSON_nodes = canvas.toJSON().nodes) != null ? _canvas_toJSON_nodes : {};
|
|
112
|
+
const snapshot = {};
|
|
113
|
+
const walk = (id)=>{
|
|
114
|
+
var _node_nodes;
|
|
115
|
+
const node = nodes[id];
|
|
116
|
+
if (!node || snapshot[id]) return;
|
|
117
|
+
snapshot[id] = JSON.parse(JSON.stringify(node));
|
|
118
|
+
for (const childId of (_node_nodes = node.nodes) != null ? _node_nodes : [])walk(childId);
|
|
119
|
+
};
|
|
120
|
+
walk(rootId);
|
|
121
|
+
return snapshot;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* The copies a repeating element draws BESIDE the one an author edits
|
|
125
|
+
* (AGL-3111): records 2..n, as denormalized trees ready for an inert render.
|
|
126
|
+
*
|
|
127
|
+
* The first record is deliberately missing. It is drawn by the element's own
|
|
128
|
+
* children — the real canvas nodes, selectable and draggable, with that
|
|
129
|
+
* record's values laid over their render copies through
|
|
130
|
+
* {@link RepeatRecordContext}. That is what makes editing the template edit
|
|
131
|
+
* every copy: there is one template, it is on the canvas, and the copies are
|
|
132
|
+
* pictures of it.
|
|
133
|
+
*
|
|
134
|
+
* Built by running the published page's own {@link expandRepeatables} over a
|
|
135
|
+
* snapshot of this subtree, so the canvas cannot draw a shape the page would
|
|
136
|
+
* not compose.
|
|
137
|
+
*/ export function useRepeatCopies(node, preview) {
|
|
138
|
+
var _ref;
|
|
139
|
+
const $id = node == null ? void 0 : node.$id;
|
|
140
|
+
const recordCount = (_ref = preview == null ? void 0 : preview.records.length) != null ? _ref : 0;
|
|
141
|
+
const key = preview ? `${$id}\n${preview.scope}\n${JSON.stringify(preview.records)}` : '';
|
|
142
|
+
return useMemo(()=>{
|
|
143
|
+
var _preview_datasetsByKey, _ref, _ref1, _ref2;
|
|
144
|
+
var _expanded_holderId, _expanded_$id, // One template's worth of children per record: the first
|
|
145
|
+
// record's copies are the ones the real children already draw.
|
|
146
|
+
_expanded_$id1;
|
|
147
|
+
if (!$id || !preview || recordCount < 2) return [];
|
|
148
|
+
const snapshot = subtreeSnapshot($id);
|
|
149
|
+
if (!snapshot[$id]) return [];
|
|
150
|
+
// A parent the copies can take their place in. The real parent is not in
|
|
151
|
+
// this snapshot — only the subtree is — so a self-scoped repeat is given
|
|
152
|
+
// a holder that lists it, which is all the expansion reads a parent for.
|
|
153
|
+
const holderId = `${$id}__repeat-preview-parent`;
|
|
154
|
+
snapshot[$id] = _extends({}, snapshot[$id], {
|
|
155
|
+
parentId: holderId
|
|
156
|
+
});
|
|
157
|
+
snapshot[holderId] = {
|
|
158
|
+
$id: holderId,
|
|
159
|
+
nodes: [
|
|
160
|
+
$id
|
|
161
|
+
]
|
|
162
|
+
};
|
|
163
|
+
const expanded = expandRepeatables(snapshot, _extends({}, (_preview_datasetsByKey = preview.datasetsByKey) != null ? _preview_datasetsByKey : {}));
|
|
164
|
+
const copyIds = preview.scope === 'self' ? ((_ref = (_expanded_holderId = expanded[holderId]) == null ? void 0 : _expanded_holderId.nodes) != null ? _ref : []).slice(1) : ((_ref1 = (_expanded_$id = expanded[$id]) == null ? void 0 : _expanded_$id.nodes) != null ? _ref1 : []).slice(((_ref2 = (_expanded_$id1 = expanded[$id]) == null ? void 0 : _expanded_$id1.nodes) != null ? _ref2 : []).length / recordCount);
|
|
165
|
+
return copyIds.map((id)=>denormalize(expanded, id)).filter(Boolean);
|
|
166
|
+
// `key` stands in for the records and the node; both are snapshots.
|
|
167
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
168
|
+
}, [
|
|
169
|
+
$id,
|
|
170
|
+
key,
|
|
171
|
+
recordCount
|
|
172
|
+
]);
|
|
173
|
+
}
|
|
174
|
+
/** Nested-object form of an expanded map, which is what `Stem` walks. */ function denormalize(nodes, rootId, seen = new Set()) {
|
|
175
|
+
var _node_nodes;
|
|
176
|
+
const node = nodes == null ? void 0 : nodes[rootId];
|
|
177
|
+
if (!node || seen.has(rootId)) return undefined;
|
|
178
|
+
seen.add(rootId);
|
|
179
|
+
return _extends({}, node, {
|
|
180
|
+
children: ((_node_nodes = node.nodes) != null ? _node_nodes : []).map((childId)=>denormalize(nodes, childId, seen)).filter(Boolean)
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* A node's render copy with the record its subtree is drawing laid over it
|
|
185
|
+
* (AGL-3111).
|
|
186
|
+
*
|
|
187
|
+
* Inside a repeating element the FIRST record's values belong on the real
|
|
188
|
+
* canvas nodes, so the element an author edits reads as the first copy rather
|
|
189
|
+
* than as a row of raw `{{item.*}}` tokens beside the copies that resolved
|
|
190
|
+
* them. Render copies only — the node keeps its tokens, and every save writes
|
|
191
|
+
* the template.
|
|
192
|
+
*/ export function useNodeWithRepeatRecord(node) {
|
|
193
|
+
var _ref;
|
|
194
|
+
const context = useContext(RepeatRecordContext);
|
|
195
|
+
const rendered = node;
|
|
196
|
+
const propsJson = context ? JSON.stringify((_ref = rendered == null ? void 0 : rendered.props) != null ? _ref : null) : '';
|
|
197
|
+
return useMemo(()=>{
|
|
198
|
+
if (!context || !(rendered == null ? void 0 : rendered.props)) return node;
|
|
199
|
+
const props = substituteRecordTokens(_extends({}, rendered.props), context);
|
|
200
|
+
return _extends({}, rendered, {
|
|
201
|
+
props
|
|
202
|
+
});
|
|
203
|
+
// Observable props: the JSON string keys the copy, as everywhere else.
|
|
204
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
205
|
+
}, [
|
|
206
|
+
node,
|
|
207
|
+
rendered,
|
|
208
|
+
context,
|
|
209
|
+
propsJson
|
|
210
|
+
]);
|
|
211
|
+
}
|
|
212
|
+
export default useRepeatPreview;
|
|
213
|
+
|
|
214
|
+
//# sourceMappingURL=use-repeat-preview.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/hooks/use-repeat-preview.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 { canvas } from '@aglyn/aglyn'\n// By path: the repeat rules and the source registry stay out of every\n// `@aglyn/aglyn` barrel, so nothing on a published page can pull them in.\nimport {\n expandRepeatables,\n type RepeatableDataset,\n type RepeatScope,\n repeatedRecords,\n repeatScope,\n substituteRecordTokens,\n} from '@aglyn/aglyn/app-utils/expand-repeatables'\nimport { repeatSourceOf } from '@aglyn/aglyn/app-utils/repeat-sources'\nimport { useContext, useEffect, useMemo, useSyncExternalStore } from 'react'\nimport {\n RepeatRowsContext,\n repeatRowsKey,\n} from '../contexts/repeat-rows-context'\nimport { RepeatRecordContext } from '../contexts/repeat-record-context'\n\nconst subscribeToNothing = () => () => undefined\nconst noVersion = () => 0\n\n/** What a repeating element draws on the canvas. */\nexport interface RepeatPreview {\n /** What authors call the thing being repeated, for the badge. */\n label: string\n /**\n * The records this element renders, in order, bounded exactly as the\n * published page's composition bounds them.\n */\n records: ReadonlyArray<Record<string, unknown>>\n /** Which scope applies, so the canvas draws what the page will build. */\n scope: RepeatScope\n /** The repeated rows, for the token substitution's reference hops. */\n dataset?: RepeatableDataset\n /** Every key the rows answered under, for a one-hop reference (AGL-180). */\n datasetsByKey?: Readonly<Record<string, RepeatableDataset>>\n}\n\n/**\n * The rows a canvas element repeats over, and the copies it therefore draws\n * (AGL-3111).\n *\n * The designer cannot read them itself — it renders inside a plugin sandbox,\n * and which documents hold them is the source's business — so this HOLDS the\n * request and reads back whatever the host app's reader filed. Without a\n * provider, or before an answer, it returns `undefined` and the element draws\n * its template once, the way the canvas always did.\n *\n * The records are {@link repeatedRecords}, not a second reading of the same\n * props: the filter, the sort, the limit and `REPEAT_MAX_RECORDS` are applied\n * by the function the page applies them with, so a copy on the canvas is a\n * copy a visitor gets.\n */\nexport function useRepeatPreview(node: unknown): RepeatPreview | undefined {\n const source = useContext(RepeatRowsContext)\n const props = (node as { props?: Record<string, unknown> })?.props\n // MobX props are observable and change in place; their JSON keys the memos\n // below, the way every other render copy in the canvas is keyed.\n const propsJson = JSON.stringify(props ?? null)\n const request = useMemo(() => {\n const repeat = source ? repeatSourceOf({ props }) : undefined\n return repeat\n ? { sourceId: repeat.source.id, key: repeat.key, label: repeat.source.label }\n : undefined\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [source, props, propsJson])\n\n const key = request ? repeatRowsKey(request) : ''\n useEffect(() => {\n if (!source || !request) return undefined\n return source.retain(request)\n // `key` stands in for `request`: the same source and key keeps the read\n // it already holds rather than dropping and re-taking it.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [source, key])\n\n const version = useSyncExternalStore(\n source && request ? source.subscribe : subscribeToNothing,\n source ? source.getVersion : noVersion,\n noVersion,\n )\n\n return useMemo(() => {\n if (!source || !request) return undefined\n const answer = source.get(key)\n if (answer?.status !== 'ready') return undefined\n const dataset = answer.rowsByKey[request.key]\n const records = repeatedRecords({ props }, dataset)\n if (!records.length) return undefined\n return {\n label: answer.label,\n records,\n scope: repeatScope(node),\n dataset,\n datasetsByKey: answer.rowsByKey,\n }\n // `version` carries a new answer in; the body reads it through `get`.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [source, request, key, version, node, props, propsJson])\n}\n\n/**\n * The stored subtree under `rootId`, as a plain snapshot.\n *\n * Canvas nodes are MobX observables the expansion must not read through — it\n * copies props by reference into the copies it builds, and an observable read\n * outside a reaction is both a stale value and a missing dependency.\n */\nfunction subtreeSnapshot(rootId: string): Record<string, any> {\n const nodes = (canvas.toJSON().nodes ?? {}) as Record<string, any>\n const snapshot: Record<string, any> = {}\n const walk = (id: string) => {\n const node = nodes[id]\n if (!node || snapshot[id]) return\n snapshot[id] = JSON.parse(JSON.stringify(node))\n for (const childId of (node.nodes ?? []) as string[]) walk(childId)\n }\n walk(rootId)\n return snapshot\n}\n\n/**\n * The copies a repeating element draws BESIDE the one an author edits\n * (AGL-3111): records 2..n, as denormalized trees ready for an inert render.\n *\n * The first record is deliberately missing. It is drawn by the element's own\n * children — the real canvas nodes, selectable and draggable, with that\n * record's values laid over their render copies through\n * {@link RepeatRecordContext}. That is what makes editing the template edit\n * every copy: there is one template, it is on the canvas, and the copies are\n * pictures of it.\n *\n * Built by running the published page's own {@link expandRepeatables} over a\n * snapshot of this subtree, so the canvas cannot draw a shape the page would\n * not compose.\n */\nexport function useRepeatCopies(\n node: { $id?: string; parentId?: string } | null | undefined,\n preview: RepeatPreview | undefined,\n): any[] {\n const $id = node?.$id\n const recordCount = preview?.records.length ?? 0\n const key = preview\n ? `${$id}\\n${preview.scope}\\n${JSON.stringify(preview.records)}`\n : ''\n return useMemo(() => {\n if (!$id || !preview || recordCount < 2) return []\n const snapshot = subtreeSnapshot($id)\n if (!snapshot[$id]) return []\n // A parent the copies can take their place in. The real parent is not in\n // this snapshot — only the subtree is — so a self-scoped repeat is given\n // a holder that lists it, which is all the expansion reads a parent for.\n const holderId = `${$id}__repeat-preview-parent`\n snapshot[$id] = { ...snapshot[$id], parentId: holderId }\n snapshot[holderId] = { $id: holderId, nodes: [$id] }\n const expanded = expandRepeatables(snapshot as never, {\n // Under the key the node stores, which is the key the expansion looks\n // the rows up by.\n ...(preview.datasetsByKey ?? {}),\n } as never) as Record<string, any>\n const copyIds =\n preview.scope === 'self'\n ? (expanded[holderId]?.nodes ?? []).slice(1)\n : (expanded[$id]?.nodes ?? []).slice(\n // One template's worth of children per record: the first\n // record's copies are the ones the real children already draw.\n (expanded[$id]?.nodes ?? []).length / recordCount,\n )\n return copyIds\n .map((id: string) => denormalize(expanded, id))\n .filter(Boolean)\n // `key` stands in for the records and the node; both are snapshots.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [$id, key, recordCount])\n}\n\n/** Nested-object form of an expanded map, which is what `Stem` walks. */\nfunction denormalize(\n nodes: Record<string, any>,\n rootId: string,\n seen: Set<string> = new Set(),\n): any {\n const node = nodes?.[rootId]\n if (!node || seen.has(rootId)) return undefined\n seen.add(rootId)\n return {\n ...node,\n children: ((node.nodes ?? []) as string[])\n .map((childId) => denormalize(nodes, childId, seen))\n .filter(Boolean),\n }\n}\n\n/**\n * A node's render copy with the record its subtree is drawing laid over it\n * (AGL-3111).\n *\n * Inside a repeating element the FIRST record's values belong on the real\n * canvas nodes, so the element an author edits reads as the first copy rather\n * than as a row of raw `{{item.*}}` tokens beside the copies that resolved\n * them. Render copies only — the node keeps its tokens, and every save writes\n * the template.\n */\nexport function useNodeWithRepeatRecord<N>(node: N): N {\n const context = useContext(RepeatRecordContext)\n const rendered = node as { props?: Record<string, unknown> } | null | undefined\n const propsJson = context ? JSON.stringify(rendered?.props ?? null) : ''\n return useMemo(() => {\n if (!context || !rendered?.props) return node\n const props = substituteRecordTokens({ ...rendered.props }, context)\n return { ...rendered, props } as N\n // Observable props: the JSON string keys the copy, as everywhere else.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [node, rendered, context, propsJson])\n}\n\nexport default useRepeatPreview\n"],"names":["canvas","expandRepeatables","repeatedRecords","repeatScope","substituteRecordTokens","repeatSourceOf","useContext","useEffect","useMemo","useSyncExternalStore","RepeatRowsContext","repeatRowsKey","RepeatRecordContext","subscribeToNothing","undefined","noVersion","useRepeatPreview","node","source","props","propsJson","JSON","stringify","request","repeat","sourceId","id","key","label","retain","version","subscribe","getVersion","answer","get","status","dataset","rowsByKey","records","length","scope","datasetsByKey","subtreeSnapshot","rootId","nodes","toJSON","snapshot","walk","parse","childId","useRepeatCopies","preview","$id","recordCount","expanded","holderId","parentId","copyIds","slice","map","denormalize","filter","Boolean","seen","Set","has","add","children","useNodeWithRepeatRecord","context","rendered"],"mappings":"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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type RepeatSource } from '@aglyn/aglyn/app-utils/repeat-sources';
|
|
2
|
+
/**
|
|
3
|
+
* The repeat sources registered right now (AGL-3111).
|
|
4
|
+
*
|
|
5
|
+
* A plugin registers one from the function its loader calls by name, so the
|
|
6
|
+
* set is empty until that plugin has loaded and grows when it does. Subscribed
|
|
7
|
+
* rather than read once for exactly that reason: an author who enables the
|
|
8
|
+
* plugin mid-session gets the field without reloading the besigner.
|
|
9
|
+
*
|
|
10
|
+
* On the server there are none — registration happens in the browser, and a
|
|
11
|
+
* server snapshot that claimed otherwise would hydrate into a different form
|
|
12
|
+
* than it rendered.
|
|
13
|
+
*/
|
|
14
|
+
export declare function useRepeatSources(): readonly RepeatSource[];
|
|
15
|
+
/** Moves whenever the registered set changes; memo keys read it. */
|
|
16
|
+
export declare function useRepeatSourcesVersion(): number;
|
|
17
|
+
export default useRepeatSources;
|
|
@@ -0,0 +1,41 @@
|
|
|
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
|
+
// By path: what an element can repeat OVER is editor business, and nothing
|
|
18
|
+
// on a published page asks, so this stays out of every `@aglyn/aglyn` barrel.
|
|
19
|
+
import { getRepeatSourcesVersion, listRepeatSources, subscribeRepeatSources } from "@aglyn/aglyn/app-utils/repeat-sources";
|
|
20
|
+
import { useSyncExternalStore } from "react";
|
|
21
|
+
const NONE = [];
|
|
22
|
+
/**
|
|
23
|
+
* The repeat sources registered right now (AGL-3111).
|
|
24
|
+
*
|
|
25
|
+
* A plugin registers one from the function its loader calls by name, so the
|
|
26
|
+
* set is empty until that plugin has loaded and grows when it does. Subscribed
|
|
27
|
+
* rather than read once for exactly that reason: an author who enables the
|
|
28
|
+
* plugin mid-session gets the field without reloading the besigner.
|
|
29
|
+
*
|
|
30
|
+
* On the server there are none — registration happens in the browser, and a
|
|
31
|
+
* server snapshot that claimed otherwise would hydrate into a different form
|
|
32
|
+
* than it rendered.
|
|
33
|
+
*/ export function useRepeatSources() {
|
|
34
|
+
return useSyncExternalStore(subscribeRepeatSources, listRepeatSources, ()=>NONE);
|
|
35
|
+
}
|
|
36
|
+
/** Moves whenever the registered set changes; memo keys read it. */ export function useRepeatSourcesVersion() {
|
|
37
|
+
return useSyncExternalStore(subscribeRepeatSources, getRepeatSourcesVersion, ()=>0);
|
|
38
|
+
}
|
|
39
|
+
export default useRepeatSources;
|
|
40
|
+
|
|
41
|
+
//# sourceMappingURL=use-repeat-sources.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/hooks/use-repeat-sources.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\n// By path: what an element can repeat OVER is editor business, and nothing\n// on a published page asks, so this stays out of every `@aglyn/aglyn` barrel.\nimport {\n getRepeatSourcesVersion,\n listRepeatSources,\n type RepeatSource,\n subscribeRepeatSources,\n} from '@aglyn/aglyn/app-utils/repeat-sources'\nimport { useSyncExternalStore } from 'react'\n\nconst NONE: readonly RepeatSource[] = []\n\n/**\n * The repeat sources registered right now (AGL-3111).\n *\n * A plugin registers one from the function its loader calls by name, so the\n * set is empty until that plugin has loaded and grows when it does. Subscribed\n * rather than read once for exactly that reason: an author who enables the\n * plugin mid-session gets the field without reloading the besigner.\n *\n * On the server there are none — registration happens in the browser, and a\n * server snapshot that claimed otherwise would hydrate into a different form\n * than it rendered.\n */\nexport function useRepeatSources(): readonly RepeatSource[] {\n return useSyncExternalStore(\n subscribeRepeatSources,\n listRepeatSources,\n () => NONE,\n )\n}\n\n/** Moves whenever the registered set changes; memo keys read it. */\nexport function useRepeatSourcesVersion(): number {\n return useSyncExternalStore(\n subscribeRepeatSources,\n getRepeatSourcesVersion,\n () => 0,\n )\n}\n\nexport default useRepeatSources\n"],"names":["getRepeatSourcesVersion","listRepeatSources","subscribeRepeatSources","useSyncExternalStore","NONE","useRepeatSources","useRepeatSourcesVersion"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GACD;AAEA,2EAA2E;AAC3E,8EAA8E;AAC9E,SACEA,uBAAuB,EACvBC,iBAAiB,EAEjBC,sBAAsB,QACjB,wCAAuC;AAC9C,SAASC,oBAAoB,QAAQ,QAAO;AAE5C,MAAMC,OAAgC,EAAE;AAExC;;;;;;;;;;;CAWC,GACD,OAAO,SAASC;IACd,OAAOF,qBACLD,wBACAD,mBACA,IAAMG;AAEV;AAEA,kEAAkE,GAClE,OAAO,SAASE;IACd,OAAOH,qBACLD,wBACAF,yBACA,IAAM;AAEV;AAEA,eAAeK,iBAAgB"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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
|
+
*/
|
|
17
|
+
import type * as Aglyn from '@aglyn/aglyn';
|
|
18
|
+
/**
|
|
19
|
+
* Component-drawer categories filtered by the site's plugin set and the
|
|
20
|
+
* current canvas view type:
|
|
21
|
+
*
|
|
22
|
+
* - A plugin disabled for this site (AGL-1014) contributes nothing, in
|
|
23
|
+
* either drawer — the palette and the picker read this one hook.
|
|
24
|
+
* - Editing an EMAIL document → only the email plugin's email-safe blocks;
|
|
25
|
+
* web/layout components would render inconsistently across mail clients.
|
|
26
|
+
* - Editing a screen or layout → email blocks are hidden (they belong to
|
|
27
|
+
* emails only); layout-only components (the LayoutSlot outlet) are also
|
|
28
|
+
* hidden while editing screens.
|
|
29
|
+
*
|
|
30
|
+
* Call inside an observer component — the category list is a MobX computed.
|
|
31
|
+
*/
|
|
32
|
+
export declare function useVisibleComponentCategories(): {
|
|
33
|
+
items: (Aglyn.PresetSchema<any> | Aglyn.ComponentSchema<any>)[];
|
|
34
|
+
$id: string;
|
|
35
|
+
label: string;
|
|
36
|
+
}[];
|
|
37
|
+
export default useVisibleComponentCategories;
|
|
@@ -0,0 +1,79 @@
|
|
|
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 { components, HostViewType, isCategoryCapabilityEnabled, isFromEnabledPlugin, LAYOUT_SLOT_COMPONENT_ID, useEnabledPlugins } from "@aglyn/aglyn";
|
|
18
|
+
import useAglynBesignerFlag from "./use-aglyn-besigner-flag.js";
|
|
19
|
+
/** Bundle id of the email designer's blocks (AGL-395). */ const EMAIL_PLUGIN_ID = 'email';
|
|
20
|
+
function isLayoutOnlyPreset(preset) {
|
|
21
|
+
var _preset_data;
|
|
22
|
+
return (preset == null ? void 0 : (_preset_data = preset.data) == null ? void 0 : _preset_data.componentId) === LAYOUT_SLOT_COMPONENT_ID;
|
|
23
|
+
}
|
|
24
|
+
function isEmailComponent(item) {
|
|
25
|
+
return (item == null ? void 0 : item.pluginId) === EMAIL_PLUGIN_ID;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Component-drawer categories filtered by the site's plugin set and the
|
|
29
|
+
* current canvas view type:
|
|
30
|
+
*
|
|
31
|
+
* - A plugin disabled for this site (AGL-1014) contributes nothing, in
|
|
32
|
+
* either drawer — the palette and the picker read this one hook.
|
|
33
|
+
* - Editing an EMAIL document → only the email plugin's email-safe blocks;
|
|
34
|
+
* web/layout components would render inconsistently across mail clients.
|
|
35
|
+
* - Editing a screen or layout → email blocks are hidden (they belong to
|
|
36
|
+
* emails only); layout-only components (the LayoutSlot outlet) are also
|
|
37
|
+
* hidden while editing screens.
|
|
38
|
+
*
|
|
39
|
+
* Call inside an observer component — the category list is a MobX computed.
|
|
40
|
+
*/ export function useVisibleComponentCategories() {
|
|
41
|
+
const [viewType] = useAglynBesignerFlag('viewType');
|
|
42
|
+
// Per-site plugin enablement (AGL-1014). Enforcement, not decoration: the
|
|
43
|
+
// preset registry is a module-global union across every plugin loaded this
|
|
44
|
+
// session, so without this the drawer offers — and inserts — components
|
|
45
|
+
// from a plugin the site has switched off, which the published site then
|
|
46
|
+
// refuses to render. Undefined off host surfaces, which filters nothing.
|
|
47
|
+
const enabled = useEnabledPlugins();
|
|
48
|
+
if (viewType === HostViewType.EMAIL) {
|
|
49
|
+
return components.schemasBySortedCategories.map((category)=>{
|
|
50
|
+
var _category_items;
|
|
51
|
+
return _extends({}, category, {
|
|
52
|
+
items: isCategoryCapabilityEnabled(category.label, enabled) ? (_category_items = category.items) == null ? void 0 : _category_items.filter((item)=>isEmailComponent(item) && isFromEnabledPlugin(item, enabled)) : []
|
|
53
|
+
});
|
|
54
|
+
}).filter((category)=>{
|
|
55
|
+
var _category_items;
|
|
56
|
+
return (_category_items = category.items) == null ? void 0 : _category_items.length;
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const isLayout = viewType === HostViewType.LAYOUT;
|
|
60
|
+
return components.schemasBySortedCategories.map((category)=>{
|
|
61
|
+
var _category_items;
|
|
62
|
+
return _extends({}, category, {
|
|
63
|
+
// A category whose CAPABILITY is off contributes nothing, heading
|
|
64
|
+
// included (AGL-2486) — an empty "Members" heading still advertises a
|
|
65
|
+
// capability the site does not have. Emptying it here rather than
|
|
66
|
+
// filtering item by item is what makes the final `.filter` drop it.
|
|
67
|
+
items: !isCategoryCapabilityEnabled(category.label, enabled) ? [] : (_category_items = category.items) == null ? void 0 : _category_items.filter((item)=>// A plugin this site has switched off offers nothing.
|
|
68
|
+
isFromEnabledPlugin(item, enabled) && // Email blocks never appear outside an email document.
|
|
69
|
+
!isEmailComponent(item) && // The LayoutSlot outlet is layout-only.
|
|
70
|
+
(isLayout || !isLayoutOnlyPreset(item)))
|
|
71
|
+
});
|
|
72
|
+
}).filter((category)=>{
|
|
73
|
+
var _category_items;
|
|
74
|
+
return (_category_items = category.items) == null ? void 0 : _category_items.length;
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
export default useVisibleComponentCategories;
|
|
78
|
+
|
|
79
|
+
//# sourceMappingURL=use-visible-component-categories.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/hooks/use-visible-component-categories.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 components,\n HostViewType,\n isCategoryCapabilityEnabled,\n isFromEnabledPlugin,\n LAYOUT_SLOT_COMPONENT_ID,\n useEnabledPlugins,\n} from '@aglyn/aglyn'\nimport useAglynBesignerFlag from './use-aglyn-besigner-flag'\n\n/** Bundle id of the email designer's blocks (AGL-395). */\nconst EMAIL_PLUGIN_ID = 'email'\n\nfunction isLayoutOnlyPreset(preset: Aglyn.PresetSchema | undefined) {\n return preset?.data?.componentId === LAYOUT_SLOT_COMPONENT_ID\n}\n\nfunction isEmailComponent(item: { pluginId?: string } | undefined) {\n return item?.pluginId === EMAIL_PLUGIN_ID\n}\n\n/**\n * Component-drawer categories filtered by the site's plugin set and the\n * current canvas view type:\n *\n * - A plugin disabled for this site (AGL-1014) contributes nothing, in\n * either drawer — the palette and the picker read this one hook.\n * - Editing an EMAIL document → only the email plugin's email-safe blocks;\n * web/layout components would render inconsistently across mail clients.\n * - Editing a screen or layout → email blocks are hidden (they belong to\n * emails only); layout-only components (the LayoutSlot outlet) are also\n * hidden while editing screens.\n *\n * Call inside an observer component — the category list is a MobX computed.\n */\nexport function useVisibleComponentCategories() {\n const [viewType] = useAglynBesignerFlag('viewType')\n // Per-site plugin enablement (AGL-1014). Enforcement, not decoration: the\n // preset registry is a module-global union across every plugin loaded this\n // session, so without this the drawer offers — and inserts — components\n // from a plugin the site has switched off, which the published site then\n // refuses to render. Undefined off host surfaces, which filters nothing.\n const enabled = useEnabledPlugins()\n\n if (viewType === HostViewType.EMAIL) {\n return components.schemasBySortedCategories\n .map((category) => ({\n ...category,\n items: isCategoryCapabilityEnabled(category.label, enabled)\n ? category.items?.filter(\n (item) =>\n isEmailComponent(item) && isFromEnabledPlugin(item, enabled),\n )\n : [],\n }))\n .filter((category) => category.items?.length)\n }\n\n const isLayout = viewType === HostViewType.LAYOUT\n return components.schemasBySortedCategories\n .map((category) => ({\n ...category,\n // A category whose CAPABILITY is off contributes nothing, heading\n // included (AGL-2486) — an empty \"Members\" heading still advertises a\n // capability the site does not have. Emptying it here rather than\n // filtering item by item is what makes the final `.filter` drop it.\n items: !isCategoryCapabilityEnabled(category.label, enabled)\n ? []\n : category.items?.filter(\n (item) =>\n // A plugin this site has switched off offers nothing.\n isFromEnabledPlugin(item, enabled) &&\n // Email blocks never appear outside an email document.\n !isEmailComponent(item) &&\n // The LayoutSlot outlet is layout-only.\n (isLayout || !isLayoutOnlyPreset(item as Aglyn.PresetSchema)),\n ),\n }))\n .filter((category) => category.items?.length)\n}\n\nexport default useVisibleComponentCategories\n"],"names":["components","HostViewType","isCategoryCapabilityEnabled","isFromEnabledPlugin","LAYOUT_SLOT_COMPONENT_ID","useEnabledPlugins","useAglynBesignerFlag","EMAIL_PLUGIN_ID","isLayoutOnlyPreset","preset","data","componentId","isEmailComponent","item","pluginId","useVisibleComponentCategories","viewType","enabled","EMAIL","schemasBySortedCategories","map","category","items","label","filter","length","isLayout","LAYOUT"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC;AAGD,SACEA,UAAU,EACVC,YAAY,EACZC,2BAA2B,EAC3BC,mBAAmB,EACnBC,wBAAwB,EACxBC,iBAAiB,QACZ,eAAc;AACrB,OAAOC,0BAA0B,+BAA2B;AAE5D,wDAAwD,GACxD,MAAMC,kBAAkB;AAExB,SAASC,mBAAmBC,MAAsC;QACzDA;IAAP,OAAOA,CAAAA,2BAAAA,eAAAA,OAAQC,IAAI,qBAAZD,aAAcE,WAAW,MAAKP;AACvC;AAEA,SAASQ,iBAAiBC,IAAuC;IAC/D,OAAOA,CAAAA,wBAAAA,KAAMC,QAAQ,MAAKP;AAC5B;AAEA;;;;;;;;;;;;;CAaC,GACD,OAAO,SAASQ;IACd,MAAM,CAACC,SAAS,GAAGV,qBAAqB;IACxC,0EAA0E;IAC1E,2EAA2E;IAC3E,wEAAwE;IACxE,yEAAyE;IACzE,yEAAyE;IACzE,MAAMW,UAAUZ;IAEhB,IAAIW,aAAaf,aAAaiB,KAAK,EAAE;QACnC,OAAOlB,WAAWmB,yBAAyB,CACxCC,GAAG,CAAC,CAACC;gBAGAA;mBAHc,aACfA;gBACHC,OAAOpB,4BAA4BmB,SAASE,KAAK,EAAEN,YAC/CI,kBAAAA,SAASC,KAAK,qBAAdD,gBAAgBG,MAAM,CACpB,CAACX,OACCD,iBAAiBC,SAASV,oBAAoBU,MAAMI,YAExD,EAAE;;WAEPO,MAAM,CAAC,CAACH;gBAAaA;oBAAAA,kBAAAA,SAASC,KAAK,qBAAdD,gBAAgBI,MAAM;;IAChD;IAEA,MAAMC,WAAWV,aAAaf,aAAa0B,MAAM;IACjD,OAAO3B,WAAWmB,yBAAyB,CACxCC,GAAG,CAAC,CAACC;YAQAA;eARc,aACfA;YACH,kEAAkE;YAClE,sEAAsE;YACtE,kEAAkE;YAClE,oEAAoE;YACpEC,OAAO,CAACpB,4BAA4BmB,SAASE,KAAK,EAAEN,WAChD,EAAE,IACFI,kBAAAA,SAASC,KAAK,qBAAdD,gBAAgBG,MAAM,CACpB,CAACX,OACC,sDAAsD;gBACtDV,oBAAoBU,MAAMI,YAC1B,uDAAuD;gBACvD,CAACL,iBAAiBC,SAClB,wCAAwC;gBACvCa,CAAAA,YAAY,CAAClB,mBAAmBK,KAA0B;;OAGpEW,MAAM,CAAC,CAACH;YAAaA;gBAAAA,kBAAAA,SAASC,KAAK,qBAAdD,gBAAgBI,MAAM;;AAChD;AAEA,eAAeV,8BAA6B"}
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
*/
|
|
17
|
+
export declare function publishActiveHostTheme(doc: unknown): void;
|
|
18
|
+
export declare function useActiveHostTheme(): any;
|
|
19
|
+
/**
|
|
20
|
+
* Publishes the page's host theme for surfaces that sit outside the page.
|
|
21
|
+
* Call from a component mounted INSIDE `HostThemeDocumentContext.Provider`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function usePublishActiveHostTheme(): void;
|
|
24
|
+
/**
|
|
25
|
+
* The site theme document, preferring real context and falling back to the
|
|
26
|
+
* register. Use this anywhere a preview may be rendered outside the page.
|
|
27
|
+
*/
|
|
28
|
+
export declare function useResolvedHostThemeDocument(): any;
|
|
@@ -0,0 +1,77 @@
|
|
|
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 { useHostThemeDocument } from "@aglyn/shared-ui-theme";
|
|
17
|
+
import { useEffect, useSyncExternalStore } from "react";
|
|
18
|
+
/**
|
|
19
|
+
* The editor's current site theme, reachable from OUTSIDE the page tree
|
|
20
|
+
* (AGL-2486).
|
|
21
|
+
*
|
|
22
|
+
* `HostThemeDocumentContext` is provided inside the besigner PAGE, but
|
|
23
|
+
* `withBesignerContext` wraps that page — so `ComponentsDrawerContextProvider`,
|
|
24
|
+
* and the Choose-element dialog it renders, are ancestors of the provider
|
|
25
|
+
* rather than descendants. React context flows through portals, so the
|
|
26
|
+
* dialog's mounting is not the problem; its ANCESTRY is. The consequence was
|
|
27
|
+
* that the dialog's element preview fell back to the console's own brand and
|
|
28
|
+
* painted an Aglyn-cyan header for a site whose brand is brown — a preview
|
|
29
|
+
* showing the wrong colours is worse than no preview, because it sends an
|
|
30
|
+
* author to a component they believe matches their site.
|
|
31
|
+
*
|
|
32
|
+
* A register rather than another context, because another context would have
|
|
33
|
+
* exactly the same ancestry problem. One editor renders one site at a time,
|
|
34
|
+
* which is what makes a module-scoped value correct here rather than merely
|
|
35
|
+
* convenient — and the context is still preferred wherever it IS available,
|
|
36
|
+
* so this only ever fills the gap.
|
|
37
|
+
*/ let activeHostTheme = undefined;
|
|
38
|
+
const listeners = new Set();
|
|
39
|
+
function subscribe(listener) {
|
|
40
|
+
listeners.add(listener);
|
|
41
|
+
return ()=>void listeners.delete(listener);
|
|
42
|
+
}
|
|
43
|
+
function getSnapshot() {
|
|
44
|
+
return activeHostTheme;
|
|
45
|
+
}
|
|
46
|
+
/** Server render has no editor, so there is no theme to report. */ function getServerSnapshot() {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
export function publishActiveHostTheme(doc) {
|
|
50
|
+
if (activeHostTheme === doc) return;
|
|
51
|
+
activeHostTheme = doc;
|
|
52
|
+
listeners.forEach((listener)=>listener());
|
|
53
|
+
}
|
|
54
|
+
export function useActiveHostTheme() {
|
|
55
|
+
return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Publishes the page's host theme for surfaces that sit outside the page.
|
|
59
|
+
* Call from a component mounted INSIDE `HostThemeDocumentContext.Provider`.
|
|
60
|
+
*/ export function usePublishActiveHostTheme() {
|
|
61
|
+
const doc = useHostThemeDocument();
|
|
62
|
+
useEffect(()=>{
|
|
63
|
+
publishActiveHostTheme(doc);
|
|
64
|
+
}, [
|
|
65
|
+
doc
|
|
66
|
+
]);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* The site theme document, preferring real context and falling back to the
|
|
70
|
+
* register. Use this anywhere a preview may be rendered outside the page.
|
|
71
|
+
*/ export function useResolvedHostThemeDocument() {
|
|
72
|
+
const fromContext = useHostThemeDocument();
|
|
73
|
+
const fromRegister = useActiveHostTheme();
|
|
74
|
+
return fromContext != null ? fromContext : fromRegister;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
//# sourceMappingURL=active-host-theme.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../../../../../../../libs/besigner/feature/designer/src/lib/utils/active-host-theme.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 { useHostThemeDocument } from '@aglyn/shared-ui-theme'\nimport { useEffect, useSyncExternalStore } from 'react'\n\n/**\n * The editor's current site theme, reachable from OUTSIDE the page tree\n * (AGL-2486).\n *\n * `HostThemeDocumentContext` is provided inside the besigner PAGE, but\n * `withBesignerContext` wraps that page — so `ComponentsDrawerContextProvider`,\n * and the Choose-element dialog it renders, are ancestors of the provider\n * rather than descendants. React context flows through portals, so the\n * dialog's mounting is not the problem; its ANCESTRY is. The consequence was\n * that the dialog's element preview fell back to the console's own brand and\n * painted an Aglyn-cyan header for a site whose brand is brown — a preview\n * showing the wrong colours is worse than no preview, because it sends an\n * author to a component they believe matches their site.\n *\n * A register rather than another context, because another context would have\n * exactly the same ancestry problem. One editor renders one site at a time,\n * which is what makes a module-scoped value correct here rather than merely\n * convenient — and the context is still preferred wherever it IS available,\n * so this only ever fills the gap.\n */\nlet activeHostTheme: unknown = undefined\nconst listeners = new Set<() => void>()\n\nfunction subscribe(listener: () => void) {\n listeners.add(listener)\n return () => void listeners.delete(listener)\n}\n\nfunction getSnapshot() {\n return activeHostTheme\n}\n\n/** Server render has no editor, so there is no theme to report. */\nfunction getServerSnapshot() {\n return undefined\n}\n\nexport function publishActiveHostTheme(doc: unknown) {\n if (activeHostTheme === doc) return\n activeHostTheme = doc\n listeners.forEach((listener) => listener())\n}\n\nexport function useActiveHostTheme() {\n return useSyncExternalStore(subscribe, getSnapshot, getServerSnapshot)\n}\n\n/**\n * Publishes the page's host theme for surfaces that sit outside the page.\n * Call from a component mounted INSIDE `HostThemeDocumentContext.Provider`.\n */\nexport function usePublishActiveHostTheme() {\n const doc = useHostThemeDocument()\n useEffect(() => {\n publishActiveHostTheme(doc)\n }, [doc])\n}\n\n/**\n * The site theme document, preferring real context and falling back to the\n * register. Use this anywhere a preview may be rendered outside the page.\n */\nexport function useResolvedHostThemeDocument() {\n const fromContext = useHostThemeDocument()\n const fromRegister = useActiveHostTheme()\n return (fromContext ?? fromRegister) as any\n}\n"],"names":["useHostThemeDocument","useEffect","useSyncExternalStore","activeHostTheme","undefined","listeners","Set","subscribe","listener","add","delete","getSnapshot","getServerSnapshot","publishActiveHostTheme","doc","forEach","useActiveHostTheme","usePublishActiveHostTheme","useResolvedHostThemeDocument","fromContext","fromRegister"],"mappings":"AAAA;;;;;;;;;;;;;;;CAeC,GAED,SAASA,oBAAoB,QAAQ,yBAAwB;AAC7D,SAASC,SAAS,EAAEC,oBAAoB,QAAQ,QAAO;AAEvD;;;;;;;;;;;;;;;;;;;CAmBC,GACD,IAAIC,kBAA2BC;AAC/B,MAAMC,YAAY,IAAIC;AAEtB,SAASC,UAAUC,QAAoB;IACrCH,UAAUI,GAAG,CAACD;IACd,OAAO,IAAM,KAAKH,UAAUK,MAAM,CAACF;AACrC;AAEA,SAASG;IACP,OAAOR;AACT;AAEA,iEAAiE,GACjE,SAASS;IACP,OAAOR;AACT;AAEA,OAAO,SAASS,uBAAuBC,GAAY;IACjD,IAAIX,oBAAoBW,KAAK;IAC7BX,kBAAkBW;IAClBT,UAAUU,OAAO,CAAC,CAACP,WAAaA;AAClC;AAEA,OAAO,SAASQ;IACd,OAAOd,qBAAqBK,WAAWI,aAAaC;AACtD;AAEA;;;CAGC,GACD,OAAO,SAASK;IACd,MAAMH,MAAMd;IACZC,UAAU;QACRY,uBAAuBC;IACzB,GAAG;QAACA;KAAI;AACV;AAEA;;;CAGC,GACD,OAAO,SAASI;IACd,MAAMC,cAAcnB;IACpB,MAAMoB,eAAeJ;IACrB,OAAQG,sBAAAA,cAAeC;AACzB"}
|