@next-buildr/editor 0.0.0-stage → 2.0.1
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 +21 -0
- package/README.md +4 -2
- package/dist/.tsbuildinfo +1 -0
- package/dist/app/builder-editor.d.ts +8 -0
- package/dist/app/builder-editor.d.ts.map +1 -0
- package/dist/app/builder-editor.js +14 -0
- package/dist/app/builder-editor.test.d.ts +2 -0
- package/dist/app/builder-editor.test.d.ts.map +1 -0
- package/dist/app/builder-editor.test.js +199 -0
- package/dist/app/config.d.ts +59 -0
- package/dist/app/config.d.ts.map +1 -0
- package/dist/app/config.js +18 -0
- package/dist/app/content-language.test.d.ts +2 -0
- package/dist/app/content-language.test.d.ts.map +1 -0
- package/dist/app/content-language.test.js +157 -0
- package/dist/app/editor-app.d.ts +17 -0
- package/dist/app/editor-app.d.ts.map +1 -0
- package/dist/app/editor-app.js +206 -0
- package/dist/app/editor-app.test.d.ts +2 -0
- package/dist/app/editor-app.test.d.ts.map +1 -0
- package/dist/app/editor-app.test.js +135 -0
- package/dist/app/layout.d.ts +32 -0
- package/dist/app/layout.d.ts.map +1 -0
- package/dist/app/layout.js +82 -0
- package/dist/app/manifest.d.ts +12 -0
- package/dist/app/manifest.d.ts.map +1 -0
- package/dist/app/manifest.js +17 -0
- package/dist/app/shell-panels.d.ts +15 -0
- package/dist/app/shell-panels.d.ts.map +1 -0
- package/dist/app/shell-panels.js +5 -0
- package/dist/app/small-screen.d.ts +12 -0
- package/dist/app/small-screen.d.ts.map +1 -0
- package/dist/app/small-screen.js +33 -0
- package/dist/app/small-screen.test.d.ts +2 -0
- package/dist/app/small-screen.test.d.ts.map +1 -0
- package/dist/app/small-screen.test.js +108 -0
- package/dist/app/status-info.d.ts +14 -0
- package/dist/app/status-info.d.ts.map +1 -0
- package/dist/app/status-info.js +34 -0
- package/dist/app/use-resizable.d.ts +34 -0
- package/dist/app/use-resizable.d.ts.map +1 -0
- package/dist/app/use-resizable.js +84 -0
- package/dist/canvas-host/canvas-frame.d.ts +53 -0
- package/dist/canvas-host/canvas-frame.d.ts.map +1 -0
- package/dist/canvas-host/canvas-frame.js +146 -0
- package/dist/canvas-host/canvas-frame.test.d.ts +2 -0
- package/dist/canvas-host/canvas-frame.test.d.ts.map +1 -0
- package/dist/canvas-host/canvas-frame.test.js +91 -0
- package/dist/canvas-host/host.d.ts +109 -0
- package/dist/canvas-host/host.d.ts.map +1 -0
- package/dist/canvas-host/host.js +293 -0
- package/dist/canvas-host/host.test.d.ts +2 -0
- package/dist/canvas-host/host.test.d.ts.map +1 -0
- package/dist/canvas-host/host.test.js +398 -0
- package/dist/canvas-host/index.d.ts +5 -0
- package/dist/canvas-host/index.d.ts.map +1 -0
- package/dist/canvas-host/index.js +2 -0
- package/dist/clipboard/clipboard.d.ts +38 -0
- package/dist/clipboard/clipboard.d.ts.map +1 -0
- package/dist/clipboard/clipboard.js +160 -0
- package/dist/clipboard/clipboard.test.d.ts +2 -0
- package/dist/clipboard/clipboard.test.d.ts.map +1 -0
- package/dist/clipboard/clipboard.test.js +457 -0
- package/dist/clipboard/format.d.ts +27 -0
- package/dist/clipboard/format.d.ts.map +1 -0
- package/dist/clipboard/format.js +37 -0
- package/dist/clipboard/index.d.ts +6 -0
- package/dist/clipboard/index.d.ts.map +1 -0
- package/dist/clipboard/index.js +3 -0
- package/dist/clipboard/react.d.ts +20 -0
- package/dist/clipboard/react.d.ts.map +1 -0
- package/dist/clipboard/react.js +71 -0
- package/dist/dialogs/index.d.ts +2 -0
- package/dist/dialogs/index.d.ts.map +1 -0
- package/dist/dialogs/index.js +1 -0
- package/dist/dialogs/media-picker/index.d.ts +7 -0
- package/dist/dialogs/media-picker/index.d.ts.map +1 -0
- package/dist/dialogs/media-picker/index.js +3 -0
- package/dist/dialogs/media-picker/library.d.ts +17 -0
- package/dist/dialogs/media-picker/library.d.ts.map +1 -0
- package/dist/dialogs/media-picker/library.js +9 -0
- package/dist/dialogs/media-picker/media-picker.d.ts +18 -0
- package/dist/dialogs/media-picker/media-picker.d.ts.map +1 -0
- package/dist/dialogs/media-picker/media-picker.js +99 -0
- package/dist/dialogs/media-picker/media-picker.test.d.ts +2 -0
- package/dist/dialogs/media-picker/media-picker.test.d.ts.map +1 -0
- package/dist/dialogs/media-picker/media-picker.test.js +161 -0
- package/dist/dialogs/media-picker/media-ref.d.ts +28 -0
- package/dist/dialogs/media-picker/media-ref.d.ts.map +1 -0
- package/dist/dialogs/media-picker/media-ref.js +52 -0
- package/dist/dnd/check.d.ts +8 -0
- package/dist/dnd/check.d.ts.map +1 -0
- package/dist/dnd/check.js +12 -0
- package/dist/dnd/destinations.d.ts +15 -0
- package/dist/dnd/destinations.d.ts.map +1 -0
- package/dist/dnd/destinations.js +43 -0
- package/dist/dnd/dnd-react.test.d.ts +2 -0
- package/dist/dnd/dnd-react.test.d.ts.map +1 -0
- package/dist/dnd/dnd-react.test.js +93 -0
- package/dist/dnd/dnd.test.d.ts +2 -0
- package/dist/dnd/dnd.test.d.ts.map +1 -0
- package/dist/dnd/dnd.test.js +327 -0
- package/dist/dnd/engine.d.ts +85 -0
- package/dist/dnd/engine.d.ts.map +1 -0
- package/dist/dnd/engine.js +185 -0
- package/dist/dnd/fragment.d.ts +6 -0
- package/dist/dnd/fragment.d.ts.map +1 -0
- package/dist/dnd/fragment.js +18 -0
- package/dist/dnd/geometry.d.ts +30 -0
- package/dist/dnd/geometry.d.ts.map +1 -0
- package/dist/dnd/geometry.js +31 -0
- package/dist/dnd/index.d.ts +14 -0
- package/dist/dnd/index.d.ts.map +1 -0
- package/dist/dnd/index.js +7 -0
- package/dist/dnd/move-to-dialog.d.ts +13 -0
- package/dist/dnd/move-to-dialog.d.ts.map +1 -0
- package/dist/dnd/move-to-dialog.js +30 -0
- package/dist/dnd/react.d.ts +43 -0
- package/dist/dnd/react.d.ts.map +1 -0
- package/dist/dnd/react.js +185 -0
- package/dist/dnd/tree-target.d.ts +29 -0
- package/dist/dnd/tree-target.d.ts.map +1 -0
- package/dist/dnd/tree-target.js +97 -0
- package/dist/fonts/LICENSE-inter.txt +93 -0
- package/dist/fonts/inter-latin-400-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-500-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-600-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-400-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-500-normal.woff2 +0 -0
- package/dist/fonts/inter-latin-ext-600-normal.woff2 +0 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +21 -0
- package/dist/messages/en.d.ts +335 -0
- package/dist/messages/en.d.ts.map +1 -0
- package/dist/messages/en.js +332 -0
- package/dist/messages/index.d.ts +16 -0
- package/dist/messages/index.d.ts.map +1 -0
- package/dist/messages/index.js +22 -0
- package/dist/messages/pl.d.ts +3 -0
- package/dist/messages/pl.d.ts.map +1 -0
- package/dist/messages/pl.js +327 -0
- package/dist/panels/breadcrumbs/breadcrumbs.d.ts +6 -0
- package/dist/panels/breadcrumbs/breadcrumbs.d.ts.map +1 -0
- package/dist/panels/breadcrumbs/breadcrumbs.js +24 -0
- package/dist/panels/breadcrumbs/breadcrumbs.test.d.ts +2 -0
- package/dist/panels/breadcrumbs/breadcrumbs.test.d.ts.map +1 -0
- package/dist/panels/breadcrumbs/breadcrumbs.test.js +56 -0
- package/dist/panels/index.d.ts +9 -0
- package/dist/panels/index.d.ts.map +1 -0
- package/dist/panels/index.js +6 -0
- package/dist/panels/insert/catalog.d.ts +30 -0
- package/dist/panels/insert/catalog.d.ts.map +1 -0
- package/dist/panels/insert/catalog.js +76 -0
- package/dist/panels/insert/catalog.order.test.d.ts +2 -0
- package/dist/panels/insert/catalog.order.test.d.ts.map +1 -0
- package/dist/panels/insert/catalog.order.test.js +17 -0
- package/dist/panels/insert/category-name.d.ts +4 -0
- package/dist/panels/insert/category-name.d.ts.map +1 -0
- package/dist/panels/insert/category-name.js +8 -0
- package/dist/panels/insert/index.d.ts +3 -0
- package/dist/panels/insert/index.d.ts.map +1 -0
- package/dist/panels/insert/index.js +2 -0
- package/dist/panels/insert/insert-panel.d.ts +7 -0
- package/dist/panels/insert/insert-panel.d.ts.map +1 -0
- package/dist/panels/insert/insert-panel.js +155 -0
- package/dist/panels/insert/insert-panel.test.d.ts +2 -0
- package/dist/panels/insert/insert-panel.test.d.ts.map +1 -0
- package/dist/panels/insert/insert-panel.test.js +323 -0
- package/dist/panels/insert/target.d.ts +17 -0
- package/dist/panels/insert/target.d.ts.map +1 -0
- package/dist/panels/insert/target.js +48 -0
- package/dist/panels/inspector/controls/boolean.d.ts +4 -0
- package/dist/panels/inspector/controls/boolean.d.ts.map +1 -0
- package/dist/panels/inspector/controls/boolean.js +4 -0
- package/dist/panels/inspector/controls/compound.d.ts +15 -0
- package/dist/panels/inspector/controls/compound.d.ts.map +1 -0
- package/dist/panels/inspector/controls/compound.js +99 -0
- package/dist/panels/inspector/controls/compound.test.d.ts +2 -0
- package/dist/panels/inspector/controls/compound.test.d.ts.map +1 -0
- package/dist/panels/inspector/controls/compound.test.js +195 -0
- package/dist/panels/inspector/controls/icon.d.ts +5 -0
- package/dist/panels/inspector/controls/icon.d.ts.map +1 -0
- package/dist/panels/inspector/controls/icon.js +6 -0
- package/dist/panels/inspector/controls/index.d.ts +13 -0
- package/dist/panels/inspector/controls/index.d.ts.map +1 -0
- package/dist/panels/inspector/controls/index.js +11 -0
- package/dist/panels/inspector/controls/label.d.ts +4 -0
- package/dist/panels/inspector/controls/label.d.ts.map +1 -0
- package/dist/panels/inspector/controls/label.js +8 -0
- package/dist/panels/inspector/controls/link.d.ts +5 -0
- package/dist/panels/inspector/controls/link.d.ts.map +1 -0
- package/dist/panels/inspector/controls/link.js +6 -0
- package/dist/panels/inspector/controls/media.d.ts +9 -0
- package/dist/panels/inspector/controls/media.d.ts.map +1 -0
- package/dist/panels/inspector/controls/media.js +21 -0
- package/dist/panels/inspector/controls/number.d.ts +10 -0
- package/dist/panels/inspector/controls/number.d.ts.map +1 -0
- package/dist/panels/inspector/controls/number.js +33 -0
- package/dist/panels/inspector/controls/rich-text-model.d.ts +20 -0
- package/dist/panels/inspector/controls/rich-text-model.d.ts.map +1 -0
- package/dist/panels/inspector/controls/rich-text-model.js +91 -0
- package/dist/panels/inspector/controls/rich-text.d.ts +10 -0
- package/dist/panels/inspector/controls/rich-text.d.ts.map +1 -0
- package/dist/panels/inspector/controls/rich-text.js +159 -0
- package/dist/panels/inspector/controls/select.d.ts +5 -0
- package/dist/panels/inspector/controls/select.d.ts.map +1 -0
- package/dist/panels/inspector/controls/select.js +16 -0
- package/dist/panels/inspector/controls/select.test.d.ts +2 -0
- package/dist/panels/inspector/controls/select.test.d.ts.map +1 -0
- package/dist/panels/inspector/controls/select.test.js +43 -0
- package/dist/panels/inspector/controls/text.d.ts +4 -0
- package/dist/panels/inspector/controls/text.d.ts.map +1 -0
- package/dist/panels/inspector/controls/text.js +5 -0
- package/dist/panels/inspector/controls/textarea.d.ts +4 -0
- package/dist/panels/inspector/controls/textarea.d.ts.map +1 -0
- package/dist/panels/inspector/controls/textarea.js +4 -0
- package/dist/panels/inspector/controls/types.d.ts +16 -0
- package/dist/panels/inspector/controls/types.d.ts.map +1 -0
- package/dist/panels/inspector/controls/types.js +1 -0
- package/dist/panels/inspector/index.d.ts +17 -0
- package/dist/panels/inspector/index.d.ts.map +1 -0
- package/dist/panels/inspector/index.js +9 -0
- package/dist/panels/inspector/inspector.d.ts +16 -0
- package/dist/panels/inspector/inspector.d.ts.map +1 -0
- package/dist/panels/inspector/inspector.js +116 -0
- package/dist/panels/inspector/inspector.test.d.ts +2 -0
- package/dist/panels/inspector/inspector.test.d.ts.map +1 -0
- package/dist/panels/inspector/inspector.test.js +328 -0
- package/dist/panels/inspector/props-panel.d.ts +26 -0
- package/dist/panels/inspector/props-panel.d.ts.map +1 -0
- package/dist/panels/inspector/props-panel.js +117 -0
- package/dist/panels/inspector/styles/box-model.d.ts +20 -0
- package/dist/panels/inspector/styles/box-model.d.ts.map +1 -0
- package/dist/panels/inspector/styles/box-model.js +31 -0
- package/dist/panels/inspector/styles/index.d.ts +5 -0
- package/dist/panels/inspector/styles/index.d.ts.map +1 -0
- package/dist/panels/inspector/styles/index.js +2 -0
- package/dist/panels/inspector/styles/model.d.ts +55 -0
- package/dist/panels/inspector/styles/model.d.ts.map +1 -0
- package/dist/panels/inspector/styles/model.js +111 -0
- package/dist/panels/inspector/styles/segments.d.ts +18 -0
- package/dist/panels/inspector/styles/segments.d.ts.map +1 -0
- package/dist/panels/inspector/styles/segments.js +75 -0
- package/dist/panels/inspector/styles/sides-editor.d.ts +34 -0
- package/dist/panels/inspector/styles/sides-editor.d.ts.map +1 -0
- package/dist/panels/inspector/styles/sides-editor.js +86 -0
- package/dist/panels/inspector/styles/style-inspector.d.ts +15 -0
- package/dist/panels/inspector/styles/style-inspector.d.ts.map +1 -0
- package/dist/panels/inspector/styles/style-inspector.js +219 -0
- package/dist/panels/inspector/styles/style-inspector.test.d.ts +2 -0
- package/dist/panels/inspector/styles/style-inspector.test.d.ts.map +1 -0
- package/dist/panels/inspector/styles/style-inspector.test.js +265 -0
- package/dist/panels/inspector/styles/token-picker.d.ts +15 -0
- package/dist/panels/inspector/styles/token-picker.d.ts.map +1 -0
- package/dist/panels/inspector/styles/token-picker.js +23 -0
- package/dist/panels/inspector/styles/use-style-value.d.ts +28 -0
- package/dist/panels/inspector/styles/use-style-value.d.ts.map +1 -0
- package/dist/panels/inspector/styles/use-style-value.js +51 -0
- package/dist/panels/inspector/value.d.ts +20 -0
- package/dist/panels/inspector/value.d.ts.map +1 -0
- package/dist/panels/inspector/value.js +32 -0
- package/dist/panels/inspector/values/analyze.d.ts +49 -0
- package/dist/panels/inspector/values/analyze.d.ts.map +1 -0
- package/dist/panels/inspector/values/analyze.js +115 -0
- package/dist/panels/inspector/values/data.d.ts +18 -0
- package/dist/panels/inspector/values/data.d.ts.map +1 -0
- package/dist/panels/inspector/values/data.js +10 -0
- package/dist/panels/inspector/values/translation.d.ts +20 -0
- package/dist/panels/inspector/values/translation.d.ts.map +1 -0
- package/dist/panels/inspector/values/translation.js +25 -0
- package/dist/panels/inspector/values/value-editor.d.ts +30 -0
- package/dist/panels/inspector/values/value-editor.d.ts.map +1 -0
- package/dist/panels/inspector/values/value-editor.js +191 -0
- package/dist/panels/inspector/values/values.test.d.ts +2 -0
- package/dist/panels/inspector/values/values.test.d.ts.map +1 -0
- package/dist/panels/inspector/values/values.test.js +173 -0
- package/dist/panels/issues/collect.d.ts +70 -0
- package/dist/panels/issues/collect.d.ts.map +1 -0
- package/dist/panels/issues/collect.js +96 -0
- package/dist/panels/issues/index.d.ts +5 -0
- package/dist/panels/issues/index.d.ts.map +1 -0
- package/dist/panels/issues/index.js +2 -0
- package/dist/panels/issues/issues-panel.d.ts +17 -0
- package/dist/panels/issues/issues-panel.d.ts.map +1 -0
- package/dist/panels/issues/issues-panel.js +77 -0
- package/dist/panels/layers/flatten.d.ts +28 -0
- package/dist/panels/layers/flatten.d.ts.map +1 -0
- package/dist/panels/layers/flatten.js +61 -0
- package/dist/panels/layers/layers-panel.d.ts +14 -0
- package/dist/panels/layers/layers-panel.d.ts.map +1 -0
- package/dist/panels/layers/layers-panel.js +428 -0
- package/dist/panels/layers/layers-panel.test.d.ts +2 -0
- package/dist/panels/layers/layers-panel.test.d.ts.map +1 -0
- package/dist/panels/layers/layers-panel.test.js +315 -0
- package/dist/persistence/controller.d.ts +55 -0
- package/dist/persistence/controller.d.ts.map +1 -0
- package/dist/persistence/controller.js +341 -0
- package/dist/persistence/index.d.ts +6 -0
- package/dist/persistence/index.d.ts.map +1 -0
- package/dist/persistence/index.js +3 -0
- package/dist/persistence/load.d.ts +35 -0
- package/dist/persistence/load.d.ts.map +1 -0
- package/dist/persistence/load.js +67 -0
- package/dist/persistence/persistence.test.d.ts +2 -0
- package/dist/persistence/persistence.test.d.ts.map +1 -0
- package/dist/persistence/persistence.test.js +483 -0
- package/dist/persistence/react.d.ts +18 -0
- package/dist/persistence/react.d.ts.map +1 -0
- package/dist/persistence/react.js +105 -0
- package/dist/persistence/types.d.ts +182 -0
- package/dist/persistence/types.d.ts.map +1 -0
- package/dist/persistence/types.js +1 -0
- package/dist/preview/index.d.ts +3 -0
- package/dist/preview/index.d.ts.map +1 -0
- package/dist/preview/index.js +2 -0
- package/dist/preview/prepare.d.ts +16 -0
- package/dist/preview/prepare.d.ts.map +1 -0
- package/dist/preview/prepare.js +21 -0
- package/dist/preview/preview.d.ts +27 -0
- package/dist/preview/preview.d.ts.map +1 -0
- package/dist/preview/preview.js +51 -0
- package/dist/preview/preview.test.d.ts +2 -0
- package/dist/preview/preview.test.d.ts.map +1 -0
- package/dist/preview/preview.test.js +129 -0
- package/dist/shortcuts/actions.d.ts +17 -0
- package/dist/shortcuts/actions.d.ts.map +1 -0
- package/dist/shortcuts/actions.js +85 -0
- package/dist/shortcuts/index.d.ts +11 -0
- package/dist/shortcuts/index.d.ts.map +1 -0
- package/dist/shortcuts/index.js +5 -0
- package/dist/shortcuts/keys.d.ts +29 -0
- package/dist/shortcuts/keys.d.ts.map +1 -0
- package/dist/shortcuts/keys.js +100 -0
- package/dist/shortcuts/map.d.ts +17 -0
- package/dist/shortcuts/map.d.ts.map +1 -0
- package/dist/shortcuts/map.js +31 -0
- package/dist/shortcuts/registry.d.ts +32 -0
- package/dist/shortcuts/registry.d.ts.map +1 -0
- package/dist/shortcuts/registry.js +53 -0
- package/dist/shortcuts/shortcuts.d.ts +32 -0
- package/dist/shortcuts/shortcuts.d.ts.map +1 -0
- package/dist/shortcuts/shortcuts.js +95 -0
- package/dist/shortcuts/shortcuts.test.d.ts +2 -0
- package/dist/shortcuts/shortcuts.test.d.ts.map +1 -0
- package/dist/shortcuts/shortcuts.test.js +263 -0
- package/dist/store/create-store.d.ts +13 -0
- package/dist/store/create-store.d.ts.map +1 -0
- package/dist/store/create-store.js +248 -0
- package/dist/store/index.d.ts +9 -0
- package/dist/store/index.d.ts.map +1 -0
- package/dist/store/index.js +5 -0
- package/dist/store/locale.d.ts +23 -0
- package/dist/store/locale.d.ts.map +1 -0
- package/dist/store/locale.js +31 -0
- package/dist/store/react.d.ts +17 -0
- package/dist/store/react.d.ts.map +1 -0
- package/dist/store/react.js +32 -0
- package/dist/store/selection.d.ts +32 -0
- package/dist/store/selection.d.ts.map +1 -0
- package/dist/store/selection.js +84 -0
- package/dist/store/selection.test.d.ts +2 -0
- package/dist/store/selection.test.d.ts.map +1 -0
- package/dist/store/selection.test.js +95 -0
- package/dist/store/selectors.d.ts +18 -0
- package/dist/store/selectors.d.ts.map +1 -0
- package/dist/store/selectors.js +39 -0
- package/dist/store/store.test.d.ts +2 -0
- package/dist/store/store.test.d.ts.map +1 -0
- package/dist/store/store.test.js +331 -0
- package/dist/store/types.d.ts +114 -0
- package/dist/store/types.d.ts.map +1 -0
- package/dist/store/types.js +1 -0
- package/dist/styles/tokens.test.d.ts +2 -0
- package/dist/styles/tokens.test.d.ts.map +1 -0
- package/dist/styles/tokens.test.js +199 -0
- package/dist/styles.css +2885 -0
- package/dist/toolbar/brand.d.ts +7 -0
- package/dist/toolbar/brand.d.ts.map +1 -0
- package/dist/toolbar/brand.js +11 -0
- package/dist/toolbar/breakpoint-control.d.ts +9 -0
- package/dist/toolbar/breakpoint-control.d.ts.map +1 -0
- package/dist/toolbar/breakpoint-control.js +23 -0
- package/dist/toolbar/editable-title.d.ts +14 -0
- package/dist/toolbar/editable-title.d.ts.map +1 -0
- package/dist/toolbar/editable-title.js +46 -0
- package/dist/toolbar/editable-title.test.d.ts +2 -0
- package/dist/toolbar/editable-title.test.d.ts.map +1 -0
- package/dist/toolbar/editable-title.test.js +53 -0
- package/dist/toolbar/index.d.ts +12 -0
- package/dist/toolbar/index.d.ts.map +1 -0
- package/dist/toolbar/index.js +5 -0
- package/dist/toolbar/locale-switcher.d.ts +10 -0
- package/dist/toolbar/locale-switcher.d.ts.map +1 -0
- package/dist/toolbar/locale-switcher.js +20 -0
- package/dist/toolbar/more-menu.d.ts +12 -0
- package/dist/toolbar/more-menu.d.ts.map +1 -0
- package/dist/toolbar/more-menu.js +47 -0
- package/dist/toolbar/panel-toggles.d.ts +9 -0
- package/dist/toolbar/panel-toggles.d.ts.map +1 -0
- package/dist/toolbar/panel-toggles.js +19 -0
- package/dist/toolbar/publish-dialog.d.ts +18 -0
- package/dist/toolbar/publish-dialog.d.ts.map +1 -0
- package/dist/toolbar/publish-dialog.js +49 -0
- package/dist/toolbar/publish.test.d.ts +2 -0
- package/dist/toolbar/publish.test.d.ts.map +1 -0
- package/dist/toolbar/publish.test.js +258 -0
- package/dist/toolbar/sample-picker.d.ts +18 -0
- package/dist/toolbar/sample-picker.d.ts.map +1 -0
- package/dist/toolbar/sample-picker.js +72 -0
- package/dist/toolbar/sample-picker.test.d.ts +2 -0
- package/dist/toolbar/sample-picker.test.d.ts.map +1 -0
- package/dist/toolbar/sample-picker.test.js +78 -0
- package/dist/toolbar/save-indicator.d.ts +8 -0
- package/dist/toolbar/save-indicator.d.ts.map +1 -0
- package/dist/toolbar/save-indicator.js +30 -0
- package/dist/toolbar/theme.d.ts +22 -0
- package/dist/toolbar/theme.d.ts.map +1 -0
- package/dist/toolbar/theme.js +46 -0
- package/dist/toolbar/theme.test.d.ts +2 -0
- package/dist/toolbar/theme.test.d.ts.map +1 -0
- package/dist/toolbar/theme.test.js +49 -0
- package/dist/toolbar/toolbar-centre.d.ts +13 -0
- package/dist/toolbar/toolbar-centre.d.ts.map +1 -0
- package/dist/toolbar/toolbar-centre.js +7 -0
- package/dist/toolbar/toolbar-left.d.ts +12 -0
- package/dist/toolbar/toolbar-left.d.ts.map +1 -0
- package/dist/toolbar/toolbar-left.js +16 -0
- package/dist/toolbar/toolbar-right.d.ts +19 -0
- package/dist/toolbar/toolbar-right.d.ts.map +1 -0
- package/dist/toolbar/toolbar-right.js +21 -0
- package/dist/toolbar/toolbar.d.ts +38 -0
- package/dist/toolbar/toolbar.d.ts.map +1 -0
- package/dist/toolbar/toolbar.js +27 -0
- package/dist/toolbar/toolbar.test.d.ts +2 -0
- package/dist/toolbar/toolbar.test.d.ts.map +1 -0
- package/dist/toolbar/toolbar.test.js +289 -0
- package/dist/toolbar/use-overflow-level.d.ts +9 -0
- package/dist/toolbar/use-overflow-level.d.ts.map +1 -0
- package/dist/toolbar/use-overflow-level.js +40 -0
- package/dist/toolbar/zoom-menu.d.ts +10 -0
- package/dist/toolbar/zoom-menu.d.ts.map +1 -0
- package/dist/toolbar/zoom-menu.js +17 -0
- package/dist/ui/icon.d.ts +102 -0
- package/dist/ui/icon.d.ts.map +1 -0
- package/dist/ui/icon.js +182 -0
- package/dist/ui/icon.test.d.ts +2 -0
- package/dist/ui/icon.test.d.ts.map +1 -0
- package/dist/ui/icon.test.js +115 -0
- package/dist/ui/index.d.ts +11 -0
- package/dist/ui/index.d.ts.map +1 -0
- package/dist/ui/index.js +5 -0
- package/dist/ui/panel.d.ts +18 -0
- package/dist/ui/panel.d.ts.map +1 -0
- package/dist/ui/panel.js +21 -0
- package/dist/ui/portal.d.ts +14 -0
- package/dist/ui/portal.d.ts.map +1 -0
- package/dist/ui/portal.js +14 -0
- package/dist/ui/primitives.d.ts +190 -0
- package/dist/ui/primitives.d.ts.map +1 -0
- package/dist/ui/primitives.js +164 -0
- package/dist/ui/primitives.test.d.ts +2 -0
- package/dist/ui/primitives.test.d.ts.map +1 -0
- package/dist/ui/primitives.test.js +215 -0
- package/dist/ui/toast.d.ts +39 -0
- package/dist/ui/toast.d.ts.map +1 -0
- package/dist/ui/toast.js +76 -0
- package/dist/ui/toast.test.d.ts +2 -0
- package/dist/ui/toast.test.d.ts.map +1 -0
- package/dist/ui/toast.test.js +95 -0
- package/package.json +67 -3
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { fromTree, instantiateTemplate, registryVersions, } from '@next-buildr/core';
|
|
3
|
+
import { useEffect, useMemo, useRef, useState } from 'react';
|
|
4
|
+
import { useManifest } from '../../app/manifest.js';
|
|
5
|
+
import { useDragPress } from '../../dnd/index.js';
|
|
6
|
+
import { useT } from '../../messages/index.js';
|
|
7
|
+
import { isTypingTarget } from '../../shortcuts/index.js';
|
|
8
|
+
import { useEditor, useEditorState } from '../../store/index.js';
|
|
9
|
+
import { ComponentIcon, Icon, IconButton, Input, Tooltip, useToast } from '../../ui/index.js';
|
|
10
|
+
import { filterItems, groupByCategory, paletteItems, safeThumbnail, } from './catalog.js';
|
|
11
|
+
import { categoryName } from './category-name.js';
|
|
12
|
+
import { placeInsertion } from './target.js';
|
|
13
|
+
const VIEW_KEY = 'buildr.editor.insert.view';
|
|
14
|
+
const SKELETONS = ['a', 'b', 'c', 'd'];
|
|
15
|
+
function readView() {
|
|
16
|
+
try {
|
|
17
|
+
return globalThis.localStorage?.getItem(VIEW_KEY) === 'list' ? 'list' : 'grid';
|
|
18
|
+
}
|
|
19
|
+
catch {
|
|
20
|
+
return 'grid';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
function writeView(view) {
|
|
24
|
+
try {
|
|
25
|
+
globalThis.localStorage?.setItem(VIEW_KEY, view);
|
|
26
|
+
}
|
|
27
|
+
catch {
|
|
28
|
+
// Storage can be blocked; the choice then only lasts for this session.
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The component and template palette (docs/editor.md#insert): search, categories, and a click (or
|
|
33
|
+
* Enter) that inserts at the first position the rules allow — inside the selected container, else
|
|
34
|
+
* after the selection. It never needs drag and drop. When nothing fits the reason is shown instead.
|
|
35
|
+
*/
|
|
36
|
+
export function InsertPanel() {
|
|
37
|
+
const t = useT();
|
|
38
|
+
const store = useEditor();
|
|
39
|
+
const manifest = useManifest();
|
|
40
|
+
const readOnly = useEditorState((state) => state.readOnly);
|
|
41
|
+
const [query, setQuery] = useState('');
|
|
42
|
+
const [view, setView] = useState(readView);
|
|
43
|
+
const [collapsed, setCollapsed] = useState(() => new Set());
|
|
44
|
+
const searchRef = useRef(null);
|
|
45
|
+
const toast = useToast();
|
|
46
|
+
const sections = useMemo(() => {
|
|
47
|
+
if (manifest === undefined)
|
|
48
|
+
return [];
|
|
49
|
+
const { components, templates } = paletteItems(manifest);
|
|
50
|
+
return [
|
|
51
|
+
{ id: 'components', groups: groupByCategory(filterItems(components, query)) },
|
|
52
|
+
{ id: 'templates', groups: groupByCategory(filterItems(templates, query)) },
|
|
53
|
+
];
|
|
54
|
+
}, [manifest, query]);
|
|
55
|
+
const loading = manifest === undefined;
|
|
56
|
+
const searching = query.trim() !== '';
|
|
57
|
+
const empty = !loading && sections.every((section) => section.groups.length === 0);
|
|
58
|
+
const press = useDragPress();
|
|
59
|
+
// `/` jumps to the search, unless the keyboard already belongs to a field or an editable region.
|
|
60
|
+
useEffect(() => {
|
|
61
|
+
const onKey = (event) => {
|
|
62
|
+
if (event.key !== '/' || event.defaultPrevented || event.isComposing)
|
|
63
|
+
return;
|
|
64
|
+
if (event.ctrlKey || event.metaKey || event.altKey)
|
|
65
|
+
return;
|
|
66
|
+
if (isTypingTarget(event.target))
|
|
67
|
+
return;
|
|
68
|
+
event.preventDefault();
|
|
69
|
+
searchRef.current?.focus();
|
|
70
|
+
searchRef.current?.select();
|
|
71
|
+
};
|
|
72
|
+
document.addEventListener('keydown', onKey);
|
|
73
|
+
return () => document.removeEventListener('keydown', onKey);
|
|
74
|
+
}, []);
|
|
75
|
+
const chooseView = (next) => {
|
|
76
|
+
setView(next);
|
|
77
|
+
writeView(next);
|
|
78
|
+
};
|
|
79
|
+
const toggleCategory = (key) => setCollapsed((current) => {
|
|
80
|
+
const next = new Set(current);
|
|
81
|
+
if (!next.delete(key))
|
|
82
|
+
next.add(key);
|
|
83
|
+
return next;
|
|
84
|
+
});
|
|
85
|
+
const fragmentOf = (item) => {
|
|
86
|
+
const versions = registryVersions(store.registry);
|
|
87
|
+
if (item.kind === 'template') {
|
|
88
|
+
const definition = manifest?.templates[item.id];
|
|
89
|
+
return definition === undefined
|
|
90
|
+
? undefined
|
|
91
|
+
: instantiateTemplate(definition, undefined, undefined, versions);
|
|
92
|
+
}
|
|
93
|
+
const meta = manifest?.components[item.id];
|
|
94
|
+
if (meta === undefined)
|
|
95
|
+
return undefined;
|
|
96
|
+
return fromTree({
|
|
97
|
+
type: meta.type,
|
|
98
|
+
...(meta.defaults?.slots !== undefined ? { slots: meta.defaults.slots } : {}),
|
|
99
|
+
}, undefined, versions);
|
|
100
|
+
};
|
|
101
|
+
const insert = (item) => {
|
|
102
|
+
if (readOnly) {
|
|
103
|
+
toast.show({ id: 'insert', variant: 'warning', message: t('insert.readOnly') });
|
|
104
|
+
return;
|
|
105
|
+
}
|
|
106
|
+
const fragment = fragmentOf(item);
|
|
107
|
+
if (fragment === undefined)
|
|
108
|
+
return;
|
|
109
|
+
const state = store.getState();
|
|
110
|
+
const placement = placeInsertion(state.doc, store.registry, state.selectedIds.at(-1) ?? null, fragment);
|
|
111
|
+
if (!placement.ok) {
|
|
112
|
+
toast.show({
|
|
113
|
+
id: 'insert',
|
|
114
|
+
variant: 'warning',
|
|
115
|
+
message: `${t('insert.impossible')} ${placement.reason?.message ?? ''}`.trim(),
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
const { parentId, slot, at } = placement.target;
|
|
120
|
+
const result = store.dispatch({
|
|
121
|
+
type: 'node.insert',
|
|
122
|
+
payload: { parentId, slot, index: at, fragment },
|
|
123
|
+
});
|
|
124
|
+
if (!result.ok) {
|
|
125
|
+
toast.show({ id: 'insert', variant: 'error', message: result.error.message });
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
toast.show({ id: 'insert', variant: 'success', message: `${t('insert.done')}: ${item.label}` });
|
|
129
|
+
// The command gives the fragment fresh ids; the new node is the one now at the target position.
|
|
130
|
+
const created = store.getState().doc.nodes[parentId]?.slots?.[slot]?.[at];
|
|
131
|
+
if (created !== undefined)
|
|
132
|
+
store.select(created);
|
|
133
|
+
};
|
|
134
|
+
const renderItem = (item) => {
|
|
135
|
+
const thumbnail = safeThumbnail(item.thumbnail);
|
|
136
|
+
const button = (_jsxs("button", { type: "button", className: "bd-insert-item", onPointerDown: (event) => {
|
|
137
|
+
if (readOnly)
|
|
138
|
+
return;
|
|
139
|
+
press?.(item.kind === 'template'
|
|
140
|
+
? { kind: 'template', id: item.id }
|
|
141
|
+
: { kind: 'component', type: item.id }, item.label, event);
|
|
142
|
+
}, "data-kind": item.kind, "data-id": item.id, onClick: () => insert(item), children: [item.kind === 'template' ? (_jsx("span", { className: "bd-insert-thumb", "aria-hidden": "true", children: thumbnail !== undefined ? (_jsx("img", { src: thumbnail, alt: "", loading: "lazy" })) : (_jsx(ComponentIcon, { meta: { icon: 'layout-template' }, size: "md" })) })) : (_jsx("span", { className: "bd-insert-icon", "aria-hidden": "true", "data-icon": item.icon, children: _jsx(ComponentIcon, { meta: { icon: item.icon }, size: "md" }) })), _jsx("span", { className: "bd-insert-label", children: item.label }), view === 'list' && item.description !== undefined ? (_jsx("span", { className: "bd-insert-desc", "aria-hidden": "true", children: item.description })) : null] }));
|
|
143
|
+
return (_jsx("li", { children: item.description === undefined ? (button) : (_jsx(Tooltip, { content: item.description, children: button })) }, `${item.kind}:${item.id}`));
|
|
144
|
+
};
|
|
145
|
+
return (_jsxs("div", { className: "bd-insert", "data-view": view, children: [_jsxs("div", { className: "bd-insert-bar", children: [_jsxs("div", { className: "bd-insert-searchbox", children: [_jsx(Icon, { name: "search", className: "bd-insert-search-icon" }), _jsx(Input, { ref: searchRef, type: "search", className: "bd-insert-search", value: query, "aria-label": t('insert.search'), "aria-keyshortcuts": "/", placeholder: t('insert.search'), onChange: (event) => setQuery(event.target.value) }), query === '' ? null : (_jsx(IconButton, { className: "bd-insert-clear", label: t('insert.clear'), icon: "x", onClick: () => {
|
|
146
|
+
setQuery('');
|
|
147
|
+
searchRef.current?.focus();
|
|
148
|
+
} }))] }), _jsxs("div", { className: "bd-insert-views", children: [_jsx(IconButton, { label: t('insert.view.grid'), icon: "layout-grid", "aria-pressed": view === 'grid', onClick: () => chooseView('grid') }), _jsx(IconButton, { label: t('insert.view.list'), icon: "list", "aria-pressed": view === 'list', onClick: () => chooseView('list') })] })] }), _jsxs("div", { className: "bd-insert-scroll", children: [empty ? _jsx("p", { className: "bd-insert-empty", children: t('insert.empty') }) : null, loading ? (_jsxs("section", { className: "bd-insert-section", "aria-busy": "true", children: [_jsx("h3", { className: "bd-insert-heading", children: t('insert.templates') }), _jsx("ul", { className: "bd-insert-list", "data-kind": "template", "aria-hidden": "true", children: SKELETONS.map((key) => (_jsx("li", { className: "bd-insert-skeleton" }, key))) })] })) : null, sections.map((section) => section.groups.length === 0 ? null : (_jsxs("section", { className: "bd-insert-section", children: [_jsx("h3", { className: "bd-insert-heading", children: t(`insert.${section.id}`) }), section.groups.map((group) => {
|
|
149
|
+
const key = `${section.id}:${group.category}`;
|
|
150
|
+
const open = searching || !collapsed.has(key);
|
|
151
|
+
const name = categoryName(t, group.category);
|
|
152
|
+
const listId = `bd-insert-${section.id}-${group.category}`;
|
|
153
|
+
return (_jsxs("div", { role: "group", "aria-label": name, className: "bd-insert-group", children: [_jsx("h4", { className: "bd-insert-category", children: _jsxs("button", { type: "button", className: "bd-insert-category-toggle", "aria-expanded": open, "aria-controls": listId, onClick: () => toggleCategory(key), children: [_jsx(Icon, { name: open ? 'chevron-down' : 'chevron-right' }), _jsx("span", { className: "bd-insert-category-name", children: name }), _jsx("span", { className: "bd-insert-count", children: group.items.length })] }) }), _jsx("ul", { className: "bd-insert-list", id: listId, "data-kind": section.id === 'templates' ? 'template' : 'component', hidden: !open, children: group.items.map(renderItem) })] }, key));
|
|
154
|
+
})] }, section.id)))] })] }));
|
|
155
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"insert-panel.test.d.ts","sourceRoot":"","sources":["../../../src/panels/insert/insert-panel.test.tsx"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
// @vitest-environment jsdom
|
|
3
|
+
import { createRegistryMeta, createSeededIdGenerator, defineTemplate, p, s, toManifest, } from '@next-buildr/core';
|
|
4
|
+
import { act } from 'react';
|
|
5
|
+
import { createRoot } from 'react-dom/client';
|
|
6
|
+
import { afterEach, beforeEach, describe, expect, it } from 'vitest';
|
|
7
|
+
import { axe } from 'vitest-axe';
|
|
8
|
+
import * as matchers from 'vitest-axe/matchers';
|
|
9
|
+
import { ManifestProvider } from '../../app/manifest.js';
|
|
10
|
+
import { MessagesProvider } from '../../messages/index.js';
|
|
11
|
+
import { createEditorStore, EditorStoreProvider } from '../../store/index.js';
|
|
12
|
+
import { ToastProvider } from '../../ui/index.js';
|
|
13
|
+
import { filterItems, paletteItems, safeThumbnail } from './catalog.js';
|
|
14
|
+
import { InsertPanel } from './insert-panel.js';
|
|
15
|
+
expect.extend(matchers);
|
|
16
|
+
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
|
|
17
|
+
const meta = (type, overrides = {}) => ({
|
|
18
|
+
type,
|
|
19
|
+
version: 1,
|
|
20
|
+
label: type.split('/')[1] ?? type,
|
|
21
|
+
category: 'content',
|
|
22
|
+
props: {},
|
|
23
|
+
contentCategories: ['flow'],
|
|
24
|
+
styles: { groups: [] },
|
|
25
|
+
runtime: 'shared',
|
|
26
|
+
...overrides,
|
|
27
|
+
});
|
|
28
|
+
const registry = createRegistryMeta({
|
|
29
|
+
components: [
|
|
30
|
+
meta('buildr/page', {
|
|
31
|
+
capabilities: { root: true },
|
|
32
|
+
slots: { default: { max: 2 } },
|
|
33
|
+
}),
|
|
34
|
+
meta('buildr/box', {
|
|
35
|
+
label: 'Box',
|
|
36
|
+
category: 'layout',
|
|
37
|
+
icon: 'layout-grid',
|
|
38
|
+
slots: { default: {} },
|
|
39
|
+
}),
|
|
40
|
+
meta('buildr/text', {
|
|
41
|
+
label: 'Text',
|
|
42
|
+
icon: 'no-such-lucide-icon',
|
|
43
|
+
keywords: ['paragraph', 'copy'],
|
|
44
|
+
props: { text: p.text({ default: '' }) },
|
|
45
|
+
}),
|
|
46
|
+
meta('buildr/hidden', { label: 'Hidden', capabilities: { insertable: false } }),
|
|
47
|
+
],
|
|
48
|
+
templates: [
|
|
49
|
+
defineTemplate({
|
|
50
|
+
id: 'site/hero',
|
|
51
|
+
version: 1,
|
|
52
|
+
label: 'Hero',
|
|
53
|
+
category: 'sections',
|
|
54
|
+
thumbnail: '/thumbs/hero.png',
|
|
55
|
+
lock: 'none',
|
|
56
|
+
tree: { type: 'buildr/box', children: [{ type: 'buildr/text' }] },
|
|
57
|
+
}),
|
|
58
|
+
defineTemplate({
|
|
59
|
+
id: 'site/evil',
|
|
60
|
+
version: 1,
|
|
61
|
+
label: 'Evil',
|
|
62
|
+
category: 'sections',
|
|
63
|
+
thumbnail: 'javascript:alert(1)',
|
|
64
|
+
lock: 'none',
|
|
65
|
+
tree: { type: 'buildr/box' },
|
|
66
|
+
}),
|
|
67
|
+
],
|
|
68
|
+
});
|
|
69
|
+
const manifest = toManifest(registry);
|
|
70
|
+
const fixture = () => ({
|
|
71
|
+
schemaVersion: 1,
|
|
72
|
+
root: 'root',
|
|
73
|
+
nodes: {
|
|
74
|
+
root: { id: 'root', type: 'buildr/page', slots: { default: ['boxNode001', 'boxNode002'] } },
|
|
75
|
+
boxNode001: { id: 'boxNode001', type: 'buildr/box', slots: { default: ['textNodeA1'] } },
|
|
76
|
+
boxNode002: { id: 'boxNode002', type: 'buildr/box' },
|
|
77
|
+
textNodeA1: { id: 'textNodeA1', type: 'buildr/text', props: { text: s('A') } },
|
|
78
|
+
},
|
|
79
|
+
components: {},
|
|
80
|
+
});
|
|
81
|
+
let container;
|
|
82
|
+
let root;
|
|
83
|
+
beforeEach(() => {
|
|
84
|
+
container = document.createElement('div');
|
|
85
|
+
document.body.append(container);
|
|
86
|
+
root = createRoot(container);
|
|
87
|
+
});
|
|
88
|
+
afterEach(() => {
|
|
89
|
+
act(() => root.unmount());
|
|
90
|
+
document.body.innerHTML = '';
|
|
91
|
+
});
|
|
92
|
+
async function mount(readOnly = false, locale = 'en', reg = registry, man = manifest) {
|
|
93
|
+
const store = createEditorStore({
|
|
94
|
+
doc: fixture(),
|
|
95
|
+
registry: reg,
|
|
96
|
+
generateId: createSeededIdGenerator(5),
|
|
97
|
+
validationDelayMs: null,
|
|
98
|
+
readOnly,
|
|
99
|
+
});
|
|
100
|
+
await act(async () => root.render(_jsx(MessagesProvider, { locale: locale, children: _jsx(ManifestProvider, { manifest: man, children: _jsx(EditorStoreProvider, { store: store, children: _jsx(ToastProvider, { children: _jsx(InsertPanel, {}) }) }) }) })));
|
|
101
|
+
return store;
|
|
102
|
+
}
|
|
103
|
+
const button = (label) => [...container.querySelectorAll('button')].find((b) => b.querySelector('.bd-insert-label')?.textContent === label);
|
|
104
|
+
const click = (label) => act(async () => button(label).click());
|
|
105
|
+
const notice = () => container.querySelector('.bd-toast-text')?.textContent;
|
|
106
|
+
const children = (store, id) => store.getState().doc.nodes[id]?.slots?.['default'] ?? [];
|
|
107
|
+
describe('tile icons', () => {
|
|
108
|
+
it('draws an svg for a known icon and the neutral box for an unknown one, never a letter', async () => {
|
|
109
|
+
await mount();
|
|
110
|
+
const icon = (label) => button(label).querySelector('.bd-insert-icon');
|
|
111
|
+
expect(icon('Box')?.querySelector('svg')?.getAttribute('data-icon')).toBe('layout-grid');
|
|
112
|
+
const fallback = icon('Text')?.querySelector('svg');
|
|
113
|
+
expect(fallback?.getAttribute('data-icon')).toBe('box');
|
|
114
|
+
expect(fallback?.getAttribute('data-fallback')).toBe('true');
|
|
115
|
+
expect(icon('Text')?.textContent).toBe('');
|
|
116
|
+
});
|
|
117
|
+
});
|
|
118
|
+
describe('catalog', () => {
|
|
119
|
+
it('lists only what can be inserted, sorted, with templates apart', () => {
|
|
120
|
+
const { components, templates } = paletteItems(manifest);
|
|
121
|
+
expect(components.map((c) => c.label)).toEqual(['Box', 'Text']);
|
|
122
|
+
expect(templates.map((t) => t.label)).toEqual(['Evil', 'Hero']);
|
|
123
|
+
});
|
|
124
|
+
it('searches by label, type, keyword and every word', () => {
|
|
125
|
+
const { components } = paletteItems(manifest);
|
|
126
|
+
expect(filterItems(components, 'para').map((c) => c.label)).toEqual(['Text']);
|
|
127
|
+
expect(filterItems(components, 'BUILDR/box').map((c) => c.label)).toEqual(['Box']);
|
|
128
|
+
expect(filterItems(components, 'copy text').map((c) => c.label)).toEqual(['Text']);
|
|
129
|
+
expect(filterItems(components, 'copy box')).toEqual([]);
|
|
130
|
+
expect(filterItems(components, ' ')).toHaveLength(2);
|
|
131
|
+
});
|
|
132
|
+
it('shows a thumbnail only when it is an image address', () => {
|
|
133
|
+
expect(safeThumbnail('/thumbs/a.png')).toBe('/thumbs/a.png');
|
|
134
|
+
expect(safeThumbnail('https://cdn.example.com/a.png')).toBe('https://cdn.example.com/a.png');
|
|
135
|
+
expect(safeThumbnail('data:image/png;base64,AAAA')).toBeDefined();
|
|
136
|
+
expect(safeThumbnail('javascript:alert(1)')).toBeUndefined();
|
|
137
|
+
expect(safeThumbnail('//evil.example.com/a.png')).toBeUndefined();
|
|
138
|
+
expect(safeThumbnail('data:text/html,<script>')).toBeUndefined();
|
|
139
|
+
expect(safeThumbnail(undefined)).toBeUndefined();
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
describe('category headings', () => {
|
|
143
|
+
const custom = createRegistryMeta({
|
|
144
|
+
components: [
|
|
145
|
+
meta('buildr/page', { capabilities: { root: true }, slots: { default: {} } }),
|
|
146
|
+
meta('buildr/button', { label: 'Button', category: 'ui' }),
|
|
147
|
+
meta('buildr/list', { label: 'List', category: 'cms' }),
|
|
148
|
+
meta('buildr/quote', { label: 'Quote', category: 'blog' }),
|
|
149
|
+
],
|
|
150
|
+
templates: [],
|
|
151
|
+
});
|
|
152
|
+
const customManifest = toManifest(custom);
|
|
153
|
+
const headings = () => [...container.querySelectorAll('[role=group]')].map((g) => g.getAttribute('aria-label'));
|
|
154
|
+
it('names ui and cms in capitals and title-cases a custom category', async () => {
|
|
155
|
+
await mount(false, 'en', custom, customManifest);
|
|
156
|
+
expect(headings()).toEqual(['UI', 'CMS', 'Blog']);
|
|
157
|
+
expect(container.querySelector('.bd-insert-category-name')?.textContent).toBe('UI');
|
|
158
|
+
});
|
|
159
|
+
it('uses the Polish catalog', async () => {
|
|
160
|
+
await mount(false, 'pl', custom, customManifest);
|
|
161
|
+
expect(headings()).toEqual(['UI', 'CMS', 'Blog']);
|
|
162
|
+
await mount(false, 'pl');
|
|
163
|
+
expect(headings()).toEqual(['Układ', 'Treść', 'Sections']);
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
describe('InsertPanel', () => {
|
|
167
|
+
it('is accessible and groups by category', async () => {
|
|
168
|
+
await mount();
|
|
169
|
+
expect(await axe(container)).toHaveNoViolations();
|
|
170
|
+
const groups = [...container.querySelectorAll('[role=group]')].map((g) => g.getAttribute('aria-label'));
|
|
171
|
+
expect(groups).toEqual(['Layout', 'Content', 'Sections']);
|
|
172
|
+
expect(container.querySelector('img')?.getAttribute('src')).toBe('/thumbs/hero.png');
|
|
173
|
+
expect(container.querySelectorAll('img')).toHaveLength(1);
|
|
174
|
+
});
|
|
175
|
+
it('inserts into the selected container, at the end, and selects the new node', async () => {
|
|
176
|
+
const store = await mount();
|
|
177
|
+
await act(async () => store.select('boxNode001'));
|
|
178
|
+
await click('Text');
|
|
179
|
+
const kids = children(store, 'boxNode001');
|
|
180
|
+
expect(kids).toHaveLength(2);
|
|
181
|
+
expect(kids[0]).toBe('textNodeA1');
|
|
182
|
+
expect(store.getState().doc.nodes[kids[1]]?.type).toBe('buildr/text');
|
|
183
|
+
expect(store.getState().selectedIds).toEqual([kids[1]]);
|
|
184
|
+
expect(notice()).toBe('Inserted: Text');
|
|
185
|
+
expect(store.getState().undoLabel).toBe('node.insert');
|
|
186
|
+
});
|
|
187
|
+
it('inserts after a selection that cannot hold children', async () => {
|
|
188
|
+
const store = await mount();
|
|
189
|
+
await act(async () => store.select('textNodeA1'));
|
|
190
|
+
await click('Box');
|
|
191
|
+
const kids = children(store, 'boxNode001');
|
|
192
|
+
expect(kids).toHaveLength(2);
|
|
193
|
+
expect(kids[0]).toBe('textNodeA1');
|
|
194
|
+
expect(store.getState().doc.nodes[kids[1]]?.type).toBe('buildr/box');
|
|
195
|
+
});
|
|
196
|
+
it('inserts a template as one undo step', async () => {
|
|
197
|
+
const store = await mount();
|
|
198
|
+
await act(async () => store.select('boxNode002'));
|
|
199
|
+
await click('Hero');
|
|
200
|
+
const [box] = children(store, 'boxNode002');
|
|
201
|
+
const inserted = store.getState().doc.nodes[box];
|
|
202
|
+
expect(inserted?.type).toBe('buildr/box');
|
|
203
|
+
expect(inserted?.source).toEqual({ template: 'site/hero', version: 1 });
|
|
204
|
+
await act(async () => store.undo());
|
|
205
|
+
expect(children(store, 'boxNode002')).toEqual([]);
|
|
206
|
+
});
|
|
207
|
+
it('says why when there is no place for it', async () => {
|
|
208
|
+
const store = await mount();
|
|
209
|
+
// The page holds two children at most, and nothing is selected, so there is nowhere to go.
|
|
210
|
+
await click('Box');
|
|
211
|
+
expect(notice()).toContain('cannot be inserted here');
|
|
212
|
+
expect(notice()?.length).toBeGreaterThan('It cannot be inserted here.'.length);
|
|
213
|
+
expect(children(store, 'root')).toHaveLength(2);
|
|
214
|
+
});
|
|
215
|
+
it('does nothing to a read-only document', async () => {
|
|
216
|
+
const store = await mount(true);
|
|
217
|
+
await act(async () => store.select('boxNode002'));
|
|
218
|
+
await click('Text');
|
|
219
|
+
expect(notice()).toBe('The page is read-only.');
|
|
220
|
+
expect(children(store, 'boxNode002')).toEqual([]);
|
|
221
|
+
});
|
|
222
|
+
it('filters while typing and says when nothing matches', async () => {
|
|
223
|
+
await mount();
|
|
224
|
+
const input = container.querySelector('input');
|
|
225
|
+
const type = async (value) => act(async () => {
|
|
226
|
+
const set = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;
|
|
227
|
+
set?.call(input, value);
|
|
228
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
229
|
+
});
|
|
230
|
+
await type('paragraph');
|
|
231
|
+
expect(container.querySelectorAll('.bd-insert-item')).toHaveLength(1);
|
|
232
|
+
await type('zzzz');
|
|
233
|
+
expect(container.querySelector('.bd-insert-empty')?.textContent).toBe('Nothing matches the search.');
|
|
234
|
+
});
|
|
235
|
+
it('is operable with the keyboard alone (real buttons in tab order)', async () => {
|
|
236
|
+
await mount();
|
|
237
|
+
const items = [...container.querySelectorAll('.bd-insert-item')];
|
|
238
|
+
expect(items.length).toBe(4);
|
|
239
|
+
for (const item of items) {
|
|
240
|
+
expect(item.tagName).toBe('BUTTON');
|
|
241
|
+
expect(item.tabIndex).toBe(0);
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
});
|
|
245
|
+
describe('InsertPanel (PB-125)', () => {
|
|
246
|
+
const press = (target, key) => act(async () => {
|
|
247
|
+
target.dispatchEvent(new KeyboardEvent('keydown', { key, bubbles: true, cancelable: true }));
|
|
248
|
+
});
|
|
249
|
+
const named = (name) => [...container.querySelectorAll('button')].find((b) => b.getAttribute('aria-label') === name);
|
|
250
|
+
it('collapses a category and reports it with aria-expanded and a count', async () => {
|
|
251
|
+
await mount();
|
|
252
|
+
const toggle = [...container.querySelectorAll('.bd-insert-category-toggle')].find((b) => b.textContent?.includes('Layout'));
|
|
253
|
+
expect(toggle.getAttribute('aria-expanded')).toBe('true');
|
|
254
|
+
expect(toggle.querySelector('.bd-insert-count')?.textContent).toBe('1');
|
|
255
|
+
await act(async () => toggle.click());
|
|
256
|
+
expect(toggle.getAttribute('aria-expanded')).toBe('false');
|
|
257
|
+
const list = container.querySelector(`#${toggle.getAttribute('aria-controls')}`);
|
|
258
|
+
expect(list.hidden).toBe(true);
|
|
259
|
+
await act(async () => toggle.click());
|
|
260
|
+
expect(list.hidden).toBe(false);
|
|
261
|
+
});
|
|
262
|
+
it('remembers the list view', async () => {
|
|
263
|
+
localStorage.removeItem('buildr.editor.insert.view');
|
|
264
|
+
await mount();
|
|
265
|
+
expect(container.querySelector('.bd-insert')?.getAttribute('data-view')).toBe('grid');
|
|
266
|
+
await act(async () => named('List view').click());
|
|
267
|
+
expect(container.querySelector('.bd-insert')?.getAttribute('data-view')).toBe('list');
|
|
268
|
+
expect(named('List view').getAttribute('aria-pressed')).toBe('true');
|
|
269
|
+
expect(localStorage.getItem('buildr.editor.insert.view')).toBe('list');
|
|
270
|
+
act(() => root.unmount());
|
|
271
|
+
root = createRoot(container);
|
|
272
|
+
await mount();
|
|
273
|
+
expect(container.querySelector('.bd-insert')?.getAttribute('data-view')).toBe('list');
|
|
274
|
+
localStorage.removeItem('buildr.editor.insert.view');
|
|
275
|
+
});
|
|
276
|
+
it('focuses the search on "/" only when no text field has focus', async () => {
|
|
277
|
+
await mount();
|
|
278
|
+
const search = container.querySelector('input');
|
|
279
|
+
await press(document.body, '/');
|
|
280
|
+
expect(document.activeElement).toBe(search);
|
|
281
|
+
// While typing in the search the key is just a character.
|
|
282
|
+
const typed = new KeyboardEvent('keydown', { key: '/', bubbles: true, cancelable: true });
|
|
283
|
+
search.dispatchEvent(typed);
|
|
284
|
+
expect(typed.defaultPrevented).toBe(false);
|
|
285
|
+
const other = document.createElement('input');
|
|
286
|
+
document.body.append(other);
|
|
287
|
+
other.focus();
|
|
288
|
+
await press(other, '/');
|
|
289
|
+
expect(document.activeElement).toBe(other);
|
|
290
|
+
});
|
|
291
|
+
it('clears the search with the clear button', async () => {
|
|
292
|
+
await mount();
|
|
293
|
+
const input = container.querySelector('input');
|
|
294
|
+
await act(async () => {
|
|
295
|
+
const set = Object.getOwnPropertyDescriptor(HTMLInputElement.prototype, 'value')?.set;
|
|
296
|
+
set?.call(input, 'zzzz');
|
|
297
|
+
input.dispatchEvent(new Event('input', { bubbles: true }));
|
|
298
|
+
});
|
|
299
|
+
await act(async () => named('Clear search').click());
|
|
300
|
+
expect(input.value).toBe('');
|
|
301
|
+
expect(container.querySelector('.bd-insert-empty')).toBeNull();
|
|
302
|
+
});
|
|
303
|
+
});
|
|
304
|
+
describe('versions', () => {
|
|
305
|
+
it('stamps what it inserts with the versions of the registry', async () => {
|
|
306
|
+
const v2 = createRegistryMeta({
|
|
307
|
+
components: [
|
|
308
|
+
meta('buildr/page', { capabilities: { root: true }, slots: { default: {} } }),
|
|
309
|
+
meta('buildr/box', {
|
|
310
|
+
label: 'Box',
|
|
311
|
+
category: 'layout',
|
|
312
|
+
version: 2,
|
|
313
|
+
slots: { default: {} },
|
|
314
|
+
}),
|
|
315
|
+
],
|
|
316
|
+
templates: [],
|
|
317
|
+
});
|
|
318
|
+
const store = await mount(false, 'en', v2, toManifest(v2));
|
|
319
|
+
await click('Box');
|
|
320
|
+
expect(store.getState().doc.components['buildr/box']).toBe(2);
|
|
321
|
+
expect(children(store, 'root')).toHaveLength(3);
|
|
322
|
+
});
|
|
323
|
+
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type BuilderDocument, type BuilderFragment, type InsertTarget, type NodeId, type Reason, type RegistryMeta } from '@next-buildr/core';
|
|
2
|
+
/** Where an insertion goes, or why nowhere works. */
|
|
3
|
+
export type Placement = {
|
|
4
|
+
readonly ok: true;
|
|
5
|
+
readonly target: Required<InsertTarget>;
|
|
6
|
+
} | {
|
|
7
|
+
readonly ok: false;
|
|
8
|
+
readonly reason: Reason | undefined;
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* The first position the palette can insert `what` at, for the current selection: inside the
|
|
12
|
+
* selected node (each of its slots in order, at the end), else right after it, else after each
|
|
13
|
+
* ancestor in turn. With no selection, inside the root. `canInsert` decides every candidate, so the
|
|
14
|
+
* result is always a position the `node.insert` command will accept.
|
|
15
|
+
*/
|
|
16
|
+
export declare function placeInsertion(doc: BuilderDocument, registry: RegistryMeta, selectedId: NodeId | null, what: string | BuilderFragment): Placement;
|
|
17
|
+
//# sourceMappingURL=target.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"target.d.ts","sourceRoot":"","sources":["../../../src/panels/insert/target.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,eAAe,EACpB,KAAK,eAAe,EAGpB,KAAK,YAAY,EACjB,KAAK,MAAM,EACX,KAAK,MAAM,EACX,KAAK,YAAY,EAClB,MAAM,mBAAmB,CAAC;AAE3B,qDAAqD;AACrD,MAAM,MAAM,SAAS,GACjB;IAAE,QAAQ,CAAC,EAAE,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,YAAY,CAAC,CAAA;CAAE,GAC9D;IAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAA;CAAE,CAAC;AAEhE;;;;;GAKG;AACH,wBAAgB,cAAc,CAC5B,GAAG,EAAE,eAAe,EACpB,QAAQ,EAAE,YAAY,EACtB,UAAU,EAAE,MAAM,GAAG,IAAI,EACzB,IAAI,EAAE,MAAM,GAAG,eAAe,GAC7B,SAAS,CAsCX"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { canInsert, createIndex, } from '@next-buildr/core';
|
|
2
|
+
/**
|
|
3
|
+
* The first position the palette can insert `what` at, for the current selection: inside the
|
|
4
|
+
* selected node (each of its slots in order, at the end), else right after it, else after each
|
|
5
|
+
* ancestor in turn. With no selection, inside the root. `canInsert` decides every candidate, so the
|
|
6
|
+
* result is always a position the `node.insert` command will accept.
|
|
7
|
+
*/
|
|
8
|
+
export function placeInsertion(doc, registry, selectedId, what) {
|
|
9
|
+
const index = createIndex(doc);
|
|
10
|
+
let firstReason;
|
|
11
|
+
const attempt = (target) => {
|
|
12
|
+
const verdict = canInsert(doc, index, registry, target, what);
|
|
13
|
+
if (verdict.ok)
|
|
14
|
+
return { ok: true, target };
|
|
15
|
+
firstReason ??= verdict.error;
|
|
16
|
+
return undefined;
|
|
17
|
+
};
|
|
18
|
+
const inside = (id) => {
|
|
19
|
+
const node = Object.hasOwn(doc.nodes, id) ? doc.nodes[id] : undefined;
|
|
20
|
+
if (node === undefined)
|
|
21
|
+
return undefined;
|
|
22
|
+
const slots = Object.keys(registry.get(node.type)?.slots ?? {});
|
|
23
|
+
for (const slot of slots) {
|
|
24
|
+
const found = attempt({ parentId: id, slot, at: node.slots?.[slot]?.length ?? 0 });
|
|
25
|
+
if (found !== undefined)
|
|
26
|
+
return found;
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
};
|
|
30
|
+
const start = selectedId !== null && Object.hasOwn(doc.nodes, selectedId) ? selectedId : doc.root;
|
|
31
|
+
const inner = inside(start);
|
|
32
|
+
if (inner !== undefined)
|
|
33
|
+
return inner;
|
|
34
|
+
// Not inside: after the selection, then after each ancestor (the guard stops a corrupt cycle).
|
|
35
|
+
let current = start;
|
|
36
|
+
for (let hops = 0; current !== undefined && hops < 10_000; hops++) {
|
|
37
|
+
const parentId = index.parentOf[current];
|
|
38
|
+
const slot = index.slotOf[current];
|
|
39
|
+
const position = index.indexOf[current];
|
|
40
|
+
if (parentId === undefined || slot === undefined || position === undefined)
|
|
41
|
+
break;
|
|
42
|
+
const found = attempt({ parentId, slot, at: position + 1 });
|
|
43
|
+
if (found !== undefined)
|
|
44
|
+
return found;
|
|
45
|
+
current = parentId;
|
|
46
|
+
}
|
|
47
|
+
return { ok: false, reason: firstReason };
|
|
48
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { BooleanPropDef } from '@next-buildr/core';
|
|
2
|
+
import type { ControlProps } from './types.ts';
|
|
3
|
+
export declare function BooleanControl({ id, def, label, describedBy, value, disabled, onChange, }: ControlProps<BooleanPropDef>): import("react").JSX.Element;
|
|
4
|
+
//# sourceMappingURL=boolean.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"boolean.d.ts","sourceRoot":"","sources":["../../../../src/panels/inspector/controls/boolean.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,wBAAgB,cAAc,CAAC,EAC7B,EAAE,EACF,GAAG,EACH,KAAK,EACL,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,YAAY,CAAC,cAAc,CAAC,+BAa9B"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export function BooleanControl({ id, def, label, describedBy, value, disabled, onChange, }) {
|
|
3
|
+
return (_jsx("input", { id: id, type: "checkbox", className: "bd-checkbox", checked: typeof value === 'boolean' ? value : def.default, disabled: disabled, "aria-label": label, "aria-describedby": describedBy, onChange: (event) => onChange(event.target.checked) }));
|
|
4
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { ListPropDef, ObjectPropDef, PropDef } from '@next-buildr/core';
|
|
2
|
+
import type { ReactNode } from 'react';
|
|
3
|
+
import type { ControlProps } from './types.ts';
|
|
4
|
+
/** The control for a prop of any kind, or `null` for a kind that has none. Lists and objects recurse. */
|
|
5
|
+
export declare function renderControl(def: PropDef, common: ControlProps): ReactNode;
|
|
6
|
+
/** Moves the item at `from` to `to`; out of range returns the list unchanged. */
|
|
7
|
+
export declare function moveItem<T>(list: readonly T[], from: number, to: number): T[];
|
|
8
|
+
/**
|
|
9
|
+
* A list of sub-props: each item is edited with the control of `def.of`, and items can be added
|
|
10
|
+
* (up to `max`), removed (down to `min`) and reordered. Every change writes the whole new list.
|
|
11
|
+
*/
|
|
12
|
+
export declare function ListControl({ id, def, label, describedBy, value, disabled, onChange, }: ControlProps<ListPropDef>): import("react").JSX.Element;
|
|
13
|
+
/** A group of named sub-props, each edited with its own control; a change writes the whole object. */
|
|
14
|
+
export declare function ObjectControl({ id, def, label, describedBy, value, disabled, onChange, }: ControlProps<ObjectPropDef>): import("react").JSX.Element;
|
|
15
|
+
//# sourceMappingURL=compound.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"compound.d.ts","sourceRoot":"","sources":["../../../../src/panels/inspector/controls/compound.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAavC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,yGAAyG;AACzG,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,YAAY,GAAG,SAAS,CA2B3E;AAQD,iFAAiF;AACjF,wBAAgB,QAAQ,CAAC,CAAC,EAAE,IAAI,EAAE,SAAS,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,GAAG,CAAC,EAAE,CAM7E;AAED;;;GAGG;AACH,wBAAgB,WAAW,CAAC,EAC1B,EAAE,EACF,GAAG,EACH,KAAK,EACL,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,YAAY,CAAC,WAAW,CAAC,+BAyE3B;AAED,sGAAsG;AACtG,wBAAgB,aAAa,CAAC,EAC5B,EAAE,EACF,GAAG,EACH,KAAK,EACL,WAAW,EACX,KAAK,EACL,QAAQ,EACR,QAAQ,GACT,EAAE,YAAY,CAAC,aAAa,CAAC,+BA6B7B"}
|