@elytracms/studio 0.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 +3 -0
- package/convex/assets.ts +107 -0
- package/convex/auth.config.ts +15 -0
- package/convex/auth.ts +50 -0
- package/convex/cliTokens.ts +63 -0
- package/convex/cms.ts +174 -0
- package/convex/content.ts +316 -0
- package/convex/delivery.ts +266 -0
- package/convex/functions.ts +35 -0
- package/convex/graphs.ts +51 -0
- package/convex/guard.ts +67 -0
- package/convex/http.ts +30 -0
- package/convex/members.ts +83 -0
- package/convex/publishing.ts +102 -0
- package/convex/references.ts +168 -0
- package/convex/schema.ts +173 -0
- package/convex/sync.ts +322 -0
- package/convex/tsconfig.json +12 -0
- package/convex/users.ts +23 -0
- package/convex/webhooks.ts +85 -0
- package/dist/components/assets/asset-library.d.ts +14 -0
- package/dist/components/assets/asset-library.js +191 -0
- package/dist/components/assets/asset-library.js.map +1 -0
- package/dist/components/assets/asset-metadata.d.ts +34 -0
- package/dist/components/assets/asset-metadata.js +40 -0
- package/dist/components/assets/asset-metadata.js.map +1 -0
- package/dist/components/assets/asset-search.d.ts +7 -0
- package/dist/components/assets/asset-search.js +12 -0
- package/dist/components/assets/asset-search.js.map +1 -0
- package/dist/components/assets/asset-selection.d.ts +17 -0
- package/dist/components/assets/asset-selection.js +33 -0
- package/dist/components/assets/asset-selection.js.map +1 -0
- package/dist/components/assets/assets-store.d.ts +51 -0
- package/dist/components/assets/assets-store.js +153 -0
- package/dist/components/assets/assets-store.js.map +1 -0
- package/dist/components/auth-context.d.ts +38 -0
- package/dist/components/auth-context.js +88 -0
- package/dist/components/auth-context.js.map +1 -0
- package/dist/components/backend-gate.d.ts +19 -0
- package/dist/components/backend-gate.js +63 -0
- package/dist/components/backend-gate.js.map +1 -0
- package/dist/components/breadcrumb-context.d.ts +39 -0
- package/dist/components/breadcrumb-context.js +38 -0
- package/dist/components/breadcrumb-context.js.map +1 -0
- package/dist/components/builder/blocks-model.d.ts +80 -0
- package/dist/components/builder/blocks-model.js +181 -0
- package/dist/components/builder/blocks-model.js.map +1 -0
- package/dist/components/builder/blocks-panel.d.ts +44 -0
- package/dist/components/builder/blocks-panel.js +147 -0
- package/dist/components/builder/blocks-panel.js.map +1 -0
- package/dist/components/builder/builder-store.d.ts +69 -0
- package/dist/components/builder/builder-store.js +294 -0
- package/dist/components/builder/builder-store.js.map +1 -0
- package/dist/components/builder/canvas-stylesheet.d.ts +4 -0
- package/dist/components/builder/canvas-stylesheet.js +24 -0
- package/dist/components/builder/canvas-stylesheet.js.map +1 -0
- package/dist/components/builder/canvas.d.ts +8 -0
- package/dist/components/builder/canvas.js +723 -0
- package/dist/components/builder/canvas.js.map +1 -0
- package/dist/components/builder/clipboard-actions.d.ts +93 -0
- package/dist/components/builder/clipboard-actions.js +246 -0
- package/dist/components/builder/clipboard-actions.js.map +1 -0
- package/dist/components/builder/composition-field-editor.d.ts +11 -0
- package/dist/components/builder/composition-field-editor.js +150 -0
- package/dist/components/builder/composition-field-editor.js.map +1 -0
- package/dist/components/builder/composition-scope.d.ts +16 -0
- package/dist/components/builder/composition-scope.js +7 -0
- package/dist/components/builder/composition-scope.js.map +1 -0
- package/dist/components/builder/drag-session.d.ts +41 -0
- package/dist/components/builder/drag-session.js +51 -0
- package/dist/components/builder/drag-session.js.map +1 -0
- package/dist/components/builder/fixture-thumbnail.d.ts +18 -0
- package/dist/components/builder/fixture-thumbnail.js +97 -0
- package/dist/components/builder/fixture-thumbnail.js.map +1 -0
- package/dist/components/builder/inline-edit.d.ts +142 -0
- package/dist/components/builder/inline-edit.js +136 -0
- package/dist/components/builder/inline-edit.js.map +1 -0
- package/dist/components/builder/insert-context.d.ts +14 -0
- package/dist/components/builder/insert-context.js +65 -0
- package/dist/components/builder/insert-context.js.map +1 -0
- package/dist/components/builder/insert-menu.d.ts +9 -0
- package/dist/components/builder/insert-menu.js +9 -0
- package/dist/components/builder/insert-menu.js.map +1 -0
- package/dist/components/builder/layout-inspector.d.ts +14 -0
- package/dist/components/builder/layout-inspector.js +84 -0
- package/dist/components/builder/layout-inspector.js.map +1 -0
- package/dist/components/builder/node-factory.d.ts +17 -0
- package/dist/components/builder/node-factory.js +90 -0
- package/dist/components/builder/node-factory.js.map +1 -0
- package/dist/components/builder/page-tree.d.ts +3 -0
- package/dist/components/builder/page-tree.js +207 -0
- package/dist/components/builder/page-tree.js.map +1 -0
- package/dist/components/builder/property-inspector.d.ts +1 -0
- package/dist/components/builder/property-inspector.js +233 -0
- package/dist/components/builder/property-inspector.js.map +1 -0
- package/dist/components/builder/rich-text-toolbar.d.ts +4 -0
- package/dist/components/builder/rich-text-toolbar.js +104 -0
- package/dist/components/builder/rich-text-toolbar.js.map +1 -0
- package/dist/components/builder/spacing-handles.d.ts +22 -0
- package/dist/components/builder/spacing-handles.js +213 -0
- package/dist/components/builder/spacing-handles.js.map +1 -0
- package/dist/components/cms/asset-picker.d.ts +12 -0
- package/dist/components/cms/asset-picker.js +60 -0
- package/dist/components/cms/asset-picker.js.map +1 -0
- package/dist/components/cms/bulk-actions.d.ts +60 -0
- package/dist/components/cms/bulk-actions.js +95 -0
- package/dist/components/cms/bulk-actions.js.map +1 -0
- package/dist/components/cms/bulk-bar.d.ts +23 -0
- package/dist/components/cms/bulk-bar.js +26 -0
- package/dist/components/cms/bulk-bar.js.map +1 -0
- package/dist/components/cms/cell-edit.d.ts +91 -0
- package/dist/components/cms/cell-edit.js +144 -0
- package/dist/components/cms/cell-edit.js.map +1 -0
- package/dist/components/cms/cell.d.ts +29 -0
- package/dist/components/cms/cell.js +127 -0
- package/dist/components/cms/cell.js.map +1 -0
- package/dist/components/cms/cms-index.d.ts +8 -0
- package/dist/components/cms/cms-index.js +23 -0
- package/dist/components/cms/cms-index.js.map +1 -0
- package/dist/components/cms/cms-store.d.ts +188 -0
- package/dist/components/cms/cms-store.js +702 -0
- package/dist/components/cms/cms-store.js.map +1 -0
- package/dist/components/cms/collection-table.d.ts +6 -0
- package/dist/components/cms/collection-table.js +250 -0
- package/dist/components/cms/collection-table.js.map +1 -0
- package/dist/components/cms/collections-sidebar.d.ts +9 -0
- package/dist/components/cms/collections-sidebar.js +25 -0
- package/dist/components/cms/collections-sidebar.js.map +1 -0
- package/dist/components/cms/detail-editor.d.ts +7 -0
- package/dist/components/cms/detail-editor.js +386 -0
- package/dist/components/cms/detail-editor.js.map +1 -0
- package/dist/components/cms/doc-state.d.ts +13 -0
- package/dist/components/cms/doc-state.js +18 -0
- package/dist/components/cms/doc-state.js.map +1 -0
- package/dist/components/cms/document-editor-context.d.ts +48 -0
- package/dist/components/cms/document-editor-context.js +23 -0
- package/dist/components/cms/document-editor-context.js.map +1 -0
- package/dist/components/cms/editable-cell.d.ts +22 -0
- package/dist/components/cms/editable-cell.js +176 -0
- package/dist/components/cms/editable-cell.js.map +1 -0
- package/dist/components/cms/field-control.d.ts +8 -0
- package/dist/components/cms/field-control.js +149 -0
- package/dist/components/cms/field-control.js.map +1 -0
- package/dist/components/cms/filter-builder.d.ts +12 -0
- package/dist/components/cms/filter-builder.js +84 -0
- package/dist/components/cms/filter-builder.js.map +1 -0
- package/dist/components/cms/import-export.d.ts +6 -0
- package/dist/components/cms/import-export.js +33 -0
- package/dist/components/cms/import-export.js.map +1 -0
- package/dist/components/cms/new-page-dialog.d.ts +22 -0
- package/dist/components/cms/new-page-dialog.js +42 -0
- package/dist/components/cms/new-page-dialog.js.map +1 -0
- package/dist/components/cms/reference-confirm.d.ts +25 -0
- package/dist/components/cms/reference-confirm.js +124 -0
- package/dist/components/cms/reference-confirm.js.map +1 -0
- package/dist/components/cms/relation-picker.d.ts +16 -0
- package/dist/components/cms/relation-picker.js +47 -0
- package/dist/components/cms/relation-picker.js.map +1 -0
- package/dist/components/cms/use-cell-edit.d.ts +33 -0
- package/dist/components/cms/use-cell-edit.js +125 -0
- package/dist/components/cms/use-cell-edit.js.map +1 -0
- package/dist/components/cms/versions-model.d.ts +15 -0
- package/dist/components/cms/versions-model.js +23 -0
- package/dist/components/cms/versions-model.js.map +1 -0
- package/dist/components/cms/versions-pane.d.ts +14 -0
- package/dist/components/cms/versions-pane.js +86 -0
- package/dist/components/cms/versions-pane.js.map +1 -0
- package/dist/components/cms/view-bar.d.ts +11 -0
- package/dist/components/cms/view-bar.js +80 -0
- package/dist/components/cms/view-bar.js.map +1 -0
- package/dist/components/collab/collab-context.d.ts +34 -0
- package/dist/components/collab/collab-context.js +52 -0
- package/dist/components/collab/collab-context.js.map +1 -0
- package/dist/components/collab/collab-seed.d.ts +27 -0
- package/dist/components/collab/collab-seed.js +42 -0
- package/dist/components/collab/collab-seed.js.map +1 -0
- package/dist/components/components/component-detail.d.ts +9 -0
- package/dist/components/components/component-detail.js +30 -0
- package/dist/components/components/component-detail.js.map +1 -0
- package/dist/components/components/component-status.d.ts +10 -0
- package/dist/components/components/component-status.js +30 -0
- package/dist/components/components/component-status.js.map +1 -0
- package/dist/components/components/components-index.d.ts +8 -0
- package/dist/components/components/components-index.js +42 -0
- package/dist/components/components/components-index.js.map +1 -0
- package/dist/components/components/field-inspector.d.ts +9 -0
- package/dist/components/components/field-inspector.js +38 -0
- package/dist/components/components/field-inspector.js.map +1 -0
- package/dist/components/components/fixture-runner.d.ts +10 -0
- package/dist/components/components/fixture-runner.js +24 -0
- package/dist/components/components/fixture-runner.js.map +1 -0
- package/dist/components/components/registry-browser.d.ts +4 -0
- package/dist/components/components/registry-browser.js +64 -0
- package/dist/components/components/registry-browser.js.map +1 -0
- package/dist/components/current-user-menu.d.ts +13 -0
- package/dist/components/current-user-menu.js +31 -0
- package/dist/components/current-user-menu.js.map +1 -0
- package/dist/components/dev-login-badge.d.ts +9 -0
- package/dist/components/dev-login-badge.js +18 -0
- package/dist/components/dev-login-badge.js.map +1 -0
- package/dist/components/extensions/extensions-view.d.ts +7 -0
- package/dist/components/extensions/extensions-view.js +126 -0
- package/dist/components/extensions/extensions-view.js.map +1 -0
- package/dist/components/guards.d.ts +27 -0
- package/dist/components/guards.js +46 -0
- package/dist/components/guards.js.map +1 -0
- package/dist/components/inspector/inspector-sidebar.d.ts +26 -0
- package/dist/components/inspector/inspector-sidebar.js +17 -0
- package/dist/components/inspector/inspector-sidebar.js.map +1 -0
- package/dist/components/operation-error.d.ts +17 -0
- package/dist/components/operation-error.js +54 -0
- package/dist/components/operation-error.js.map +1 -0
- package/dist/components/playground-badge.d.ts +10 -0
- package/dist/components/playground-badge.js +19 -0
- package/dist/components/playground-badge.js.map +1 -0
- package/dist/components/project-list.d.ts +15 -0
- package/dist/components/project-list.js +52 -0
- package/dist/components/project-list.js.map +1 -0
- package/dist/components/project-session.d.ts +46 -0
- package/dist/components/project-session.js +107 -0
- package/dist/components/project-session.js.map +1 -0
- package/dist/components/project-switcher.d.ts +11 -0
- package/dist/components/project-switcher.js +44 -0
- package/dist/components/project-switcher.js.map +1 -0
- package/dist/components/references/builder-deep-link.d.ts +12 -0
- package/dist/components/references/builder-deep-link.js +53 -0
- package/dist/components/references/builder-deep-link.js.map +1 -0
- package/dist/components/references/references-panel.d.ts +17 -0
- package/dist/components/references/references-panel.js +66 -0
- package/dist/components/references/references-panel.js.map +1 -0
- package/dist/components/routes/redirect-chain.d.ts +9 -0
- package/dist/components/routes/redirect-chain.js +16 -0
- package/dist/components/routes/redirect-chain.js.map +1 -0
- package/dist/components/routes/redirect-manager.d.ts +13 -0
- package/dist/components/routes/redirect-manager.js +24 -0
- package/dist/components/routes/redirect-manager.js.map +1 -0
- package/dist/components/routes/route-list.d.ts +35 -0
- package/dist/components/routes/route-list.js +69 -0
- package/dist/components/routes/route-list.js.map +1 -0
- package/dist/components/routes/routes-shell.d.ts +14 -0
- package/dist/components/routes/routes-shell.js +68 -0
- package/dist/components/routes/routes-shell.js.map +1 -0
- package/dist/components/section-nav.d.ts +17 -0
- package/dist/components/section-nav.js +33 -0
- package/dist/components/section-nav.js.map +1 -0
- package/dist/components/section-state.d.ts +24 -0
- package/dist/components/section-state.js +78 -0
- package/dist/components/section-state.js.map +1 -0
- package/dist/components/section-surface.d.ts +31 -0
- package/dist/components/section-surface.js +46 -0
- package/dist/components/section-surface.js.map +1 -0
- package/dist/components/sections.d.ts +38 -0
- package/dist/components/sections.js +72 -0
- package/dist/components/sections.js.map +1 -0
- package/dist/components/settings-form.d.ts +10 -0
- package/dist/components/settings-form.js +17 -0
- package/dist/components/settings-form.js.map +1 -0
- package/dist/components/studio-context.d.ts +22 -0
- package/dist/components/studio-context.js +48 -0
- package/dist/components/studio-context.js.map +1 -0
- package/dist/components/studio-project-screen.d.ts +19 -0
- package/dist/components/studio-project-screen.js +195 -0
- package/dist/components/studio-project-screen.js.map +1 -0
- package/dist/components/studio-shell.d.ts +18 -0
- package/dist/components/studio-shell.js +64 -0
- package/dist/components/studio-shell.js.map +1 -0
- package/dist/components/theme-context.d.ts +17 -0
- package/dist/components/theme-context.js +26 -0
- package/dist/components/theme-context.js.map +1 -0
- package/dist/components/workspace-gate.d.ts +12 -0
- package/dist/components/workspace-gate.js +27 -0
- package/dist/components/workspace-gate.js.map +1 -0
- package/dist/components/workspace-projects.d.ts +13 -0
- package/dist/components/workspace-projects.js +18 -0
- package/dist/components/workspace-projects.js.map +1 -0
- package/dist/lib/assets/delete-asset.d.ts +34 -0
- package/dist/lib/assets/delete-asset.js +34 -0
- package/dist/lib/assets/delete-asset.js.map +1 -0
- package/dist/lib/assets/image-dimensions.d.ts +18 -0
- package/dist/lib/assets/image-dimensions.js +26 -0
- package/dist/lib/assets/image-dimensions.js.map +1 -0
- package/dist/lib/assets/index.d.ts +9 -0
- package/dist/lib/assets/index.js +10 -0
- package/dist/lib/assets/index.js.map +1 -0
- package/dist/lib/assets/upload-state.d.ts +53 -0
- package/dist/lib/assets/upload-state.js +59 -0
- package/dist/lib/assets/upload-state.js.map +1 -0
- package/dist/lib/assets/upload.d.ts +56 -0
- package/dist/lib/assets/upload.js +125 -0
- package/dist/lib/assets/upload.js.map +1 -0
- package/dist/lib/auth/auth-adapter.d.ts +57 -0
- package/dist/lib/auth/auth-adapter.js +13 -0
- package/dist/lib/auth/auth-adapter.js.map +1 -0
- package/dist/lib/auth/convex-auth-adapter.d.ts +39 -0
- package/dist/lib/auth/convex-auth-adapter.js +171 -0
- package/dist/lib/auth/convex-auth-adapter.js.map +1 -0
- package/dist/lib/auth/dev-auto-login-adapter.d.ts +25 -0
- package/dist/lib/auth/dev-auto-login-adapter.js +40 -0
- package/dist/lib/auth/dev-auto-login-adapter.js.map +1 -0
- package/dist/lib/auth/index.d.ts +28 -0
- package/dist/lib/auth/index.js +61 -0
- package/dist/lib/auth/index.js.map +1 -0
- package/dist/lib/auth/local-auth-adapter.d.ts +57 -0
- package/dist/lib/auth/local-auth-adapter.js +78 -0
- package/dist/lib/auth/local-auth-adapter.js.map +1 -0
- package/dist/lib/auth/route-guard.d.ts +33 -0
- package/dist/lib/auth/route-guard.js +51 -0
- package/dist/lib/auth/route-guard.js.map +1 -0
- package/dist/lib/auth-errors.d.ts +42 -0
- package/dist/lib/auth-errors.js +74 -0
- package/dist/lib/auth-errors.js.map +1 -0
- package/dist/lib/bindings/section-bindings.d.ts +24 -0
- package/dist/lib/bindings/section-bindings.js +9 -0
- package/dist/lib/bindings/section-bindings.js.map +1 -0
- package/dist/lib/clipboard/index.d.ts +7 -0
- package/dist/lib/clipboard/index.js +8 -0
- package/dist/lib/clipboard/index.js.map +1 -0
- package/dist/lib/clipboard/os-clipboard.d.ts +46 -0
- package/dist/lib/clipboard/os-clipboard.js +105 -0
- package/dist/lib/clipboard/os-clipboard.js.map +1 -0
- package/dist/lib/clipboard/paste-issues.d.ts +34 -0
- package/dist/lib/clipboard/paste-issues.js +67 -0
- package/dist/lib/clipboard/paste-issues.js.map +1 -0
- package/dist/lib/clipboard/paste-target.d.ts +20 -0
- package/dist/lib/clipboard/paste-target.js +28 -0
- package/dist/lib/clipboard/paste-target.js.map +1 -0
- package/dist/lib/cms/published-documents.d.ts +30 -0
- package/dist/lib/cms/published-documents.js +75 -0
- package/dist/lib/cms/published-documents.js.map +1 -0
- package/dist/lib/cms-views/index.d.ts +9 -0
- package/dist/lib/cms-views/index.js +10 -0
- package/dist/lib/cms-views/index.js.map +1 -0
- package/dist/lib/cms-views/selection.d.ts +29 -0
- package/dist/lib/cms-views/selection.js +46 -0
- package/dist/lib/cms-views/selection.js.map +1 -0
- package/dist/lib/cms-views/view-model.d.ts +192 -0
- package/dist/lib/cms-views/view-model.js +353 -0
- package/dist/lib/cms-views/view-model.js.map +1 -0
- package/dist/lib/cms-views/views-store.d.ts +70 -0
- package/dist/lib/cms-views/views-store.js +129 -0
- package/dist/lib/cms-views/views-store.js.map +1 -0
- package/dist/lib/data/collection-content.d.ts +105 -0
- package/dist/lib/data/collection-content.js +196 -0
- package/dist/lib/data/collection-content.js.map +1 -0
- package/dist/lib/data/data-store.d.ts +97 -0
- package/dist/lib/data/data-store.js +205 -0
- package/dist/lib/data/data-store.js.map +1 -0
- package/dist/lib/data/index.d.ts +4 -0
- package/dist/lib/data/index.js +8 -0
- package/dist/lib/data/index.js.map +1 -0
- package/dist/lib/data/providers.d.ts +143 -0
- package/dist/lib/data/providers.js +255 -0
- package/dist/lib/data/providers.js.map +1 -0
- package/dist/lib/data/sample-capture.d.ts +30 -0
- package/dist/lib/data/sample-capture.js +70 -0
- package/dist/lib/data/sample-capture.js.map +1 -0
- package/dist/lib/data/sources-store.d.ts +42 -0
- package/dist/lib/data/sources-store.js +120 -0
- package/dist/lib/data/sources-store.js.map +1 -0
- package/dist/lib/dnd/drop-rules.d.ts +219 -0
- package/dist/lib/dnd/drop-rules.js +257 -0
- package/dist/lib/dnd/drop-rules.js.map +1 -0
- package/dist/lib/dnd/gap-drag.d.ts +66 -0
- package/dist/lib/dnd/gap-drag.js +95 -0
- package/dist/lib/dnd/gap-drag.js.map +1 -0
- package/dist/lib/locale/binding-fallback.d.ts +28 -0
- package/dist/lib/locale/binding-fallback.js +66 -0
- package/dist/lib/locale/binding-fallback.js.map +1 -0
- package/dist/lib/locale/fallback.d.ts +43 -0
- package/dist/lib/locale/fallback.js +52 -0
- package/dist/lib/locale/fallback.js.map +1 -0
- package/dist/lib/locale/index.d.ts +6 -0
- package/dist/lib/locale/index.js +7 -0
- package/dist/lib/locale/index.js.map +1 -0
- package/dist/lib/locale/locale-store.d.ts +40 -0
- package/dist/lib/locale/locale-store.js +61 -0
- package/dist/lib/locale/locale-store.js.map +1 -0
- package/dist/lib/locale/locale-switcher.d.ts +10 -0
- package/dist/lib/locale/locale-switcher.js +24 -0
- package/dist/lib/locale/locale-switcher.js.map +1 -0
- package/dist/lib/locale/route-variant.d.ts +14 -0
- package/dist/lib/locale/route-variant.js +11 -0
- package/dist/lib/locale/route-variant.js.map +1 -0
- package/dist/lib/locale/use-studio-locale.d.ts +10 -0
- package/dist/lib/locale/use-studio-locale.js +8 -0
- package/dist/lib/locale/use-studio-locale.js.map +1 -0
- package/dist/lib/operations/asset-repository.d.ts +15 -0
- package/dist/lib/operations/asset-repository.js +56 -0
- package/dist/lib/operations/asset-repository.js.map +1 -0
- package/dist/lib/operations/cms-persistence.d.ts +35 -0
- package/dist/lib/operations/cms-persistence.js +75 -0
- package/dist/lib/operations/cms-persistence.js.map +1 -0
- package/dist/lib/operations/graph-commands.d.ts +140 -0
- package/dist/lib/operations/graph-commands.js +86 -0
- package/dist/lib/operations/graph-commands.js.map +1 -0
- package/dist/lib/operations/graph-persistence.d.ts +27 -0
- package/dist/lib/operations/graph-persistence.js +35 -0
- package/dist/lib/operations/graph-persistence.js.map +1 -0
- package/dist/lib/operations/index.d.ts +13 -0
- package/dist/lib/operations/index.js +14 -0
- package/dist/lib/operations/index.js.map +1 -0
- package/dist/lib/operations/operations-package.d.ts +6 -0
- package/dist/lib/operations/operations-package.js +7 -0
- package/dist/lib/operations/operations-package.js.map +1 -0
- package/dist/lib/operations/persist-queue.d.ts +16 -0
- package/dist/lib/operations/persist-queue.js +18 -0
- package/dist/lib/operations/persist-queue.js.map +1 -0
- package/dist/lib/operations/session-hydration.d.ts +84 -0
- package/dist/lib/operations/session-hydration.js +112 -0
- package/dist/lib/operations/session-hydration.js.map +1 -0
- package/dist/lib/operations/studio-operations.d.ts +59 -0
- package/dist/lib/operations/studio-operations.js +92 -0
- package/dist/lib/operations/studio-operations.js.map +1 -0
- package/dist/lib/persistence/backend-mode.d.ts +69 -0
- package/dist/lib/persistence/backend-mode.js +120 -0
- package/dist/lib/persistence/backend-mode.js.map +1 -0
- package/dist/lib/persistence/convex-adapter.d.ts +34 -0
- package/dist/lib/persistence/convex-adapter.js +681 -0
- package/dist/lib/persistence/convex-adapter.js.map +1 -0
- package/dist/lib/persistence/convex-blob-storage.d.ts +57 -0
- package/dist/lib/persistence/convex-blob-storage.js +97 -0
- package/dist/lib/persistence/convex-blob-storage.js.map +1 -0
- package/dist/lib/persistence/convex-client.d.ts +19 -0
- package/dist/lib/persistence/convex-client.js +40 -0
- package/dist/lib/persistence/convex-client.js.map +1 -0
- package/dist/lib/persistence/index.d.ts +30 -0
- package/dist/lib/persistence/index.js +60 -0
- package/dist/lib/persistence/index.js.map +1 -0
- package/dist/lib/persona/labels.d.ts +23 -0
- package/dist/lib/persona/labels.js +122 -0
- package/dist/lib/persona/labels.js.map +1 -0
- package/dist/lib/rail.d.ts +11 -0
- package/dist/lib/rail.js +26 -0
- package/dist/lib/rail.js.map +1 -0
- package/dist/lib/references/impact.d.ts +64 -0
- package/dist/lib/references/impact.js +62 -0
- package/dist/lib/references/impact.js.map +1 -0
- package/dist/lib/references/index.d.ts +7 -0
- package/dist/lib/references/index.js +8 -0
- package/dist/lib/references/index.js.map +1 -0
- package/dist/lib/references/reference-model.d.ts +125 -0
- package/dist/lib/references/reference-model.js +242 -0
- package/dist/lib/references/reference-model.js.map +1 -0
- package/dist/lib/references/references-store.d.ts +65 -0
- package/dist/lib/references/references-store.js +221 -0
- package/dist/lib/references/references-store.js.map +1 -0
- package/dist/lib/registry/index.d.ts +65 -0
- package/dist/lib/registry/index.js +114 -0
- package/dist/lib/registry/index.js.map +1 -0
- package/dist/lib/registry/preview.d.ts +15 -0
- package/dist/lib/registry/preview.js +110 -0
- package/dist/lib/registry/preview.js.map +1 -0
- package/dist/lib/registry/project-components.d.ts +16 -0
- package/dist/lib/registry/project-components.js +152 -0
- package/dist/lib/registry/project-components.js.map +1 -0
- package/dist/lib/routing/index.d.ts +10 -0
- package/dist/lib/routing/index.js +11 -0
- package/dist/lib/routing/index.js.map +1 -0
- package/dist/lib/routing/routing-analysis.d.ts +26 -0
- package/dist/lib/routing/routing-analysis.js +37 -0
- package/dist/lib/routing/routing-analysis.js.map +1 -0
- package/dist/lib/routing/routing-store.d.ts +50 -0
- package/dist/lib/routing/routing-store.js +72 -0
- package/dist/lib/routing/routing-store.js.map +1 -0
- package/dist/lib/starters/kit-session.d.ts +5 -0
- package/dist/lib/starters/kit-session.js +17 -0
- package/dist/lib/starters/kit-session.js.map +1 -0
- package/dist/lib/theme.d.ts +21 -0
- package/dist/lib/theme.js +32 -0
- package/dist/lib/theme.js.map +1 -0
- package/dist/lib/utils.d.ts +11 -0
- package/dist/lib/utils.js +28 -0
- package/dist/lib/utils.js.map +1 -0
- package/dist/lib/webhooks/config.d.ts +15 -0
- package/dist/lib/webhooks/config.js +64 -0
- package/dist/lib/webhooks/config.js.map +1 -0
- package/dist/lib/webhooks/dispatcher.d.ts +67 -0
- package/dist/lib/webhooks/dispatcher.js +61 -0
- package/dist/lib/webhooks/dispatcher.js.map +1 -0
- package/dist/lib/webhooks/index.d.ts +11 -0
- package/dist/lib/webhooks/index.js +10 -0
- package/dist/lib/webhooks/index.js.map +1 -0
- package/dist/lib/webhooks/signing.d.ts +15 -0
- package/dist/lib/webhooks/signing.js +24 -0
- package/dist/lib/webhooks/signing.js.map +1 -0
- package/dist/lib/webhooks/tags.d.ts +25 -0
- package/dist/lib/webhooks/tags.js +173 -0
- package/dist/lib/webhooks/tags.js.map +1 -0
- package/dist/lib/working-graph.d.ts +82 -0
- package/dist/lib/working-graph.js +113 -0
- package/dist/lib/working-graph.js.map +1 -0
- package/dist/lib/workspace/index.d.ts +109 -0
- package/dist/lib/workspace/index.js +206 -0
- package/dist/lib/workspace/index.js.map +1 -0
- package/dist/lib/workspace/switcher-source.d.ts +39 -0
- package/dist/lib/workspace/switcher-source.js +23 -0
- package/dist/lib/workspace/switcher-source.js.map +1 -0
- package/dist/lib/workspace/workspace-source.d.ts +47 -0
- package/dist/lib/workspace/workspace-source.js +67 -0
- package/dist/lib/workspace/workspace-source.js.map +1 -0
- package/dist/router/index.d.ts +32 -0
- package/dist/router/index.js +32 -0
- package/dist/router/index.js.map +1 -0
- package/dist/router/match.d.ts +75 -0
- package/dist/router/match.js +87 -0
- package/dist/router/match.js.map +1 -0
- package/dist/router/search.d.ts +22 -0
- package/dist/router/search.js +16 -0
- package/dist/router/search.js.map +1 -0
- package/dist/ui/avatar.d.ts +17 -0
- package/dist/ui/avatar.js +38 -0
- package/dist/ui/avatar.js.map +1 -0
- package/dist/ui/badge.d.ts +9 -0
- package/dist/ui/badge.js +23 -0
- package/dist/ui/badge.js.map +1 -0
- package/dist/ui/button.d.ts +11 -0
- package/dist/ui/button.js +30 -0
- package/dist/ui/button.js.map +1 -0
- package/dist/ui/card.d.ts +11 -0
- package/dist/ui/card.js +23 -0
- package/dist/ui/card.js.map +1 -0
- package/dist/ui/dialog.d.ts +12 -0
- package/dist/ui/dialog.js +27 -0
- package/dist/ui/dialog.js.map +1 -0
- package/dist/ui/dropdown-menu.d.ts +15 -0
- package/dist/ui/dropdown-menu.js +24 -0
- package/dist/ui/dropdown-menu.js.map +1 -0
- package/dist/ui/field.d.ts +15 -0
- package/dist/ui/field.js +14 -0
- package/dist/ui/field.js.map +1 -0
- package/dist/ui/index.d.ts +14 -0
- package/dist/ui/index.js +15 -0
- package/dist/ui/index.js.map +1 -0
- package/dist/ui/input.d.ts +3 -0
- package/dist/ui/input.js +7 -0
- package/dist/ui/input.js.map +1 -0
- package/dist/ui/inspector.d.ts +18 -0
- package/dist/ui/inspector.js +14 -0
- package/dist/ui/inspector.js.map +1 -0
- package/dist/ui/layout.d.ts +45 -0
- package/dist/ui/layout.js +48 -0
- package/dist/ui/layout.js.map +1 -0
- package/dist/ui/panel.d.ts +12 -0
- package/dist/ui/panel.js +20 -0
- package/dist/ui/panel.js.map +1 -0
- package/dist/ui/separator.d.ts +6 -0
- package/dist/ui/separator.js +7 -0
- package/dist/ui/separator.js.map +1 -0
- package/dist/ui/toolbar.d.ts +9 -0
- package/dist/ui/toolbar.js +16 -0
- package/dist/ui/toolbar.js.map +1 -0
- package/dist/ui/typography.d.ts +50 -0
- package/dist/ui/typography.js +43 -0
- package/dist/ui/typography.js.map +1 -0
- package/package.json +149 -0
- package/src/styles/studio.css +101 -0
- package/src/styles/tokens.css +63 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { DEFAULT_SLOT, GRID_COMPONENT_ID, OUTLET_SLOT, STACK_COMPONENT_ID, getNode, getParentInfo, gridContainerNode, isDescendantOf, removeNode, updateNode, } from '@elytracms/project-graph';
|
|
2
|
+
function rejected(code, reason) {
|
|
3
|
+
return { eligible: false, code, reason };
|
|
4
|
+
}
|
|
5
|
+
// ---------------------------------------------------------------------------
|
|
6
|
+
// Slot rules
|
|
7
|
+
// ---------------------------------------------------------------------------
|
|
8
|
+
/**
|
|
9
|
+
* The slot an `into` drop inserts into: the default `children` slot when
|
|
10
|
+
* declared, else the first authored slot that is not the layout `outlet`.
|
|
11
|
+
* Mirrors the shell's insert-context resolution so click-insert and
|
|
12
|
+
* drag-insert land in the same place.
|
|
13
|
+
*/
|
|
14
|
+
export function primaryInsertSlot(manifest) {
|
|
15
|
+
if (!manifest)
|
|
16
|
+
return undefined;
|
|
17
|
+
return (manifest.slots.find((s) => s.name === DEFAULT_SLOT) ??
|
|
18
|
+
manifest.slots.find((s) => s.name !== OUTLET_SLOT));
|
|
19
|
+
}
|
|
20
|
+
/** True when a component can receive `into` drops at all (declares an insertable slot). */
|
|
21
|
+
export function canNestInto(getManifest, componentId) {
|
|
22
|
+
return primaryInsertSlot(getManifest(componentId)) !== undefined;
|
|
23
|
+
}
|
|
24
|
+
/** True when a slot's allow-list (if any) permits the component id. */
|
|
25
|
+
export function slotAllows(slot, componentId) {
|
|
26
|
+
if (!slot?.allow)
|
|
27
|
+
return true;
|
|
28
|
+
return slot.allow.includes(componentId);
|
|
29
|
+
}
|
|
30
|
+
// ---------------------------------------------------------------------------
|
|
31
|
+
// Resolution
|
|
32
|
+
// ---------------------------------------------------------------------------
|
|
33
|
+
/**
|
|
34
|
+
* Resolve a prospective drop into either an executable plan (one `move` or
|
|
35
|
+
* `insert` builder action → one operations command → one undo step) or a
|
|
36
|
+
* structured rejection the UI shows *during* the drag. Pure: same inputs,
|
|
37
|
+
* same answer, on both surfaces.
|
|
38
|
+
*/
|
|
39
|
+
export function resolveDrop(args) {
|
|
40
|
+
const { root, getManifest, subject, location } = args;
|
|
41
|
+
if (subject.kind === 'node' && subject.nodeId === root.id) {
|
|
42
|
+
return rejected('root', 'The page root cannot be moved.');
|
|
43
|
+
}
|
|
44
|
+
const reference = getNode(root, location.nodeId);
|
|
45
|
+
if (!reference) {
|
|
46
|
+
return rejected('missing-target', `Node "${location.nodeId}" is not on this page.`);
|
|
47
|
+
}
|
|
48
|
+
// EC-162: dropping beside the reference wraps both in a two-column Grid.
|
|
49
|
+
if (location.position === 'left' || location.position === 'right') {
|
|
50
|
+
return resolveWrap({ root, getManifest, subject, reference, side: location.position });
|
|
51
|
+
}
|
|
52
|
+
// Resolve the concrete insertion point: parent node, slot, index.
|
|
53
|
+
let parentId;
|
|
54
|
+
let slotRule;
|
|
55
|
+
let slotName;
|
|
56
|
+
let index;
|
|
57
|
+
if (location.position === 'into') {
|
|
58
|
+
const manifest = getManifest(reference.componentId);
|
|
59
|
+
const slot = primaryInsertSlot(manifest);
|
|
60
|
+
if (!slot) {
|
|
61
|
+
return rejected('no-slot', `"${reference.componentId}" does not accept children.`);
|
|
62
|
+
}
|
|
63
|
+
parentId = reference.id;
|
|
64
|
+
slotRule = slot;
|
|
65
|
+
slotName = slot.name;
|
|
66
|
+
index = (reference.slots?.[slot.name] ?? []).length;
|
|
67
|
+
}
|
|
68
|
+
else {
|
|
69
|
+
const info = getParentInfo(root, reference.id);
|
|
70
|
+
if (!info) {
|
|
71
|
+
return rejected('root', 'Nothing can be dropped beside the page root.');
|
|
72
|
+
}
|
|
73
|
+
parentId = info.parent.id;
|
|
74
|
+
slotName = info.slot;
|
|
75
|
+
// Unknown parent manifests impose no allow-list; validation owns that issue.
|
|
76
|
+
slotRule = getManifest(info.parent.componentId)?.slots.find((s) => s.name === info.slot);
|
|
77
|
+
index = info.index + (location.position === 'after' ? 1 : 0);
|
|
78
|
+
}
|
|
79
|
+
if (!slotAllows(slotRule, subject.componentId)) {
|
|
80
|
+
return rejected('not-allowed', `Slot "${slotName}" does not allow "${subject.componentId}".`);
|
|
81
|
+
}
|
|
82
|
+
const target = { parentId, slot: slotName, index };
|
|
83
|
+
if (subject.kind === 'component') {
|
|
84
|
+
return { eligible: true, kind: 'insert', target };
|
|
85
|
+
}
|
|
86
|
+
// Cycle prevention: a node can never land inside its own subtree.
|
|
87
|
+
if (subject.nodeId === parentId || isDescendantOf(root, subject.nodeId, parentId)) {
|
|
88
|
+
return rejected('own-subtree', 'A node cannot be dropped into its own subtree.');
|
|
89
|
+
}
|
|
90
|
+
// No-op detection: the final position (after same-slot removal compensation,
|
|
91
|
+
// matching `moveNode`) equals the node's current position.
|
|
92
|
+
const current = getParentInfo(root, subject.nodeId);
|
|
93
|
+
if (current && current.parent.id === parentId && current.slot === slotName) {
|
|
94
|
+
const finalIndex = index > current.index ? index - 1 : index;
|
|
95
|
+
if (finalIndex === current.index) {
|
|
96
|
+
return rejected('no-op', 'Dropping here would not move the node.');
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return { eligible: true, kind: 'move', nodeId: subject.nodeId, target };
|
|
100
|
+
}
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
// Wrap gesture (EC-162): drop beside → two-column Grid container
|
|
103
|
+
// ---------------------------------------------------------------------------
|
|
104
|
+
/**
|
|
105
|
+
* The container a "drop beside" gesture creates. Canonical choice (EC-161
|
|
106
|
+
* semantics): a `Grid` with two columns, **not** a horizontal `Stack` —
|
|
107
|
+
* EC-161 gives `Grid` the canonical column vocabulary (`columns` is a
|
|
108
|
+
* validated graph value the contextual inspector refines from 2 → n), while
|
|
109
|
+
* a horizontal Stack expresses flow order, not column tracks. The values
|
|
110
|
+
* mirror the Grid manifest defaults (`columns: 2`, `gap: '4'`), so the
|
|
111
|
+
* gesture's graph is exactly what composing the same layout manually would
|
|
112
|
+
* produce.
|
|
113
|
+
*/
|
|
114
|
+
export const WRAP_GRID_OPTIONS = { columns: 2, gap: '4' };
|
|
115
|
+
/** Eligibility for a `left`/`right` (wrap-beside) drop. */
|
|
116
|
+
function resolveWrap(args) {
|
|
117
|
+
const { root, getManifest, subject, reference, side } = args;
|
|
118
|
+
// The Grid takes the reference's place in its parent slot — so the
|
|
119
|
+
// reference needs a parent (the root is the page anchor, never wrapped)
|
|
120
|
+
// and that slot's allow-list must accept a Grid.
|
|
121
|
+
const info = getParentInfo(root, reference.id);
|
|
122
|
+
if (!info) {
|
|
123
|
+
return rejected('root', 'The page root cannot be wrapped in a container.');
|
|
124
|
+
}
|
|
125
|
+
const parentSlotRule = getManifest(info.parent.componentId)?.slots.find((s) => s.name === info.slot);
|
|
126
|
+
if (!slotAllows(parentSlotRule, GRID_COMPONENT_ID)) {
|
|
127
|
+
return rejected('not-allowed', `Slot "${info.slot}" does not allow a Grid container.`);
|
|
128
|
+
}
|
|
129
|
+
// Both columns land in the Grid's children slot.
|
|
130
|
+
const gridSlot = primaryInsertSlot(getManifest(GRID_COMPONENT_ID));
|
|
131
|
+
for (const componentId of [reference.componentId, subject.componentId]) {
|
|
132
|
+
if (!slotAllows(gridSlot, componentId)) {
|
|
133
|
+
return rejected('not-allowed', `A Grid container does not allow "${componentId}".`);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
if (subject.kind === 'component') {
|
|
137
|
+
return { eligible: true, kind: 'wrap', referenceId: reference.id, side };
|
|
138
|
+
}
|
|
139
|
+
if (subject.nodeId === reference.id) {
|
|
140
|
+
return rejected('no-op', 'A node cannot be placed beside itself.');
|
|
141
|
+
}
|
|
142
|
+
// The reference must not live inside the dragged subtree (the subject is
|
|
143
|
+
// lifted out first — taking the reference with it would orphan the wrap).
|
|
144
|
+
if (isDescendantOf(root, subject.nodeId, reference.id)) {
|
|
145
|
+
return rejected('own-subtree', 'A node cannot wrap an element of its own subtree.');
|
|
146
|
+
}
|
|
147
|
+
return { eligible: true, kind: 'wrap', referenceId: reference.id, side, nodeId: subject.nodeId };
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Execute a wrap plan as **one** structural edit: lift the partner out of the
|
|
151
|
+
* tree (when it is an existing node) and replace the reference with
|
|
152
|
+
* `gridContainerNode(containerId, WRAP_GRID_OPTIONS, [left, right])` in a
|
|
153
|
+
* single pass. The caller commits the result as one builder action → one
|
|
154
|
+
* operations command → one undo step; EC-161 normalization then runs on the
|
|
155
|
+
* *committed* tree, so the two-child container can never be observed (or
|
|
156
|
+
* persisted) in a half-built state. Returns `null` for structurally invalid
|
|
157
|
+
* input (missing nodes, root reference, reference inside the partner).
|
|
158
|
+
*
|
|
159
|
+
* Determinism (EC-162): the produced container subtree is exactly the
|
|
160
|
+
* `gridContainerNode` constructor output — identical to manual composition.
|
|
161
|
+
*/
|
|
162
|
+
export function applyWrap(args) {
|
|
163
|
+
const { root, referenceId, side, partner, containerId } = args;
|
|
164
|
+
if (referenceId === root.id || !getNode(root, referenceId))
|
|
165
|
+
return null;
|
|
166
|
+
let working = root;
|
|
167
|
+
let partnerNode;
|
|
168
|
+
if (partner.kind === 'node') {
|
|
169
|
+
if (partner.nodeId === referenceId || partner.nodeId === root.id)
|
|
170
|
+
return null;
|
|
171
|
+
const node = getNode(root, partner.nodeId);
|
|
172
|
+
if (!node || isDescendantOf(root, partner.nodeId, referenceId))
|
|
173
|
+
return null;
|
|
174
|
+
partnerNode = node;
|
|
175
|
+
working = removeNode(root, partner.nodeId);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
partnerNode = partner.node;
|
|
179
|
+
}
|
|
180
|
+
const next = updateNode(working, referenceId, (reference) => gridContainerNode(containerId, WRAP_GRID_OPTIONS, side === 'left' ? [partnerNode, reference] : [reference, partnerNode]));
|
|
181
|
+
return { root: next, containerId };
|
|
182
|
+
}
|
|
183
|
+
function staticPropValue(node, name) {
|
|
184
|
+
const prop = node.props?.[name];
|
|
185
|
+
return prop?.kind === 'static' ? prop.value : undefined;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* The flow axis of a container — the axis its children stack along, and
|
|
189
|
+
* therefore the hit-band axis for drops over those children (EC-162 ledger
|
|
190
|
+
* fix: bands follow the parent's flow direction, on both surfaces). Mirrors
|
|
191
|
+
* the renderer: a horizontal Stack flows horizontally; a Grid flows
|
|
192
|
+
* horizontally when it actually has ≥ 2 column tracks (an absent/invalid
|
|
193
|
+
* `columns` renders one column). Everything else is block flow (vertical).
|
|
194
|
+
*/
|
|
195
|
+
export function containerFlowAxis(node) {
|
|
196
|
+
if (!node)
|
|
197
|
+
return 'vertical';
|
|
198
|
+
if (node.componentId === STACK_COMPONENT_ID) {
|
|
199
|
+
return staticPropValue(node, 'direction') === 'horizontal' ? 'horizontal' : 'vertical';
|
|
200
|
+
}
|
|
201
|
+
if (node.componentId === GRID_COMPONENT_ID) {
|
|
202
|
+
const columns = staticPropValue(node, 'columns');
|
|
203
|
+
return typeof columns === 'number' && columns >= 2 ? 'horizontal' : 'vertical';
|
|
204
|
+
}
|
|
205
|
+
return 'vertical';
|
|
206
|
+
}
|
|
207
|
+
/** Cross-axis side-band width (fraction of the box) that triggers the wrap gesture. */
|
|
208
|
+
const WRAP_BAND = 0.18;
|
|
209
|
+
/**
|
|
210
|
+
* Map a 2D pointer offset within a drop target's box onto a `DropPosition`
|
|
211
|
+
* (EC-162). `flow` is the flow axis of the target's *parent* — before/after
|
|
212
|
+
* bands run along it. On vertically flowing targets, narrow side bands on the
|
|
213
|
+
* cross axis produce `left`/`right` (the wrap-into-columns gesture, when
|
|
214
|
+
* `wrappable`); children of horizontal containers get left/right bands for
|
|
215
|
+
* plain reorder instead, so "beside" already means before/after there.
|
|
216
|
+
*/
|
|
217
|
+
export function dropPositionForPoint(args) {
|
|
218
|
+
const { x, y, flow, nestable, edges, wrappable = false } = args;
|
|
219
|
+
if (!edges)
|
|
220
|
+
return 'into';
|
|
221
|
+
if (wrappable && flow === 'vertical') {
|
|
222
|
+
if (x < WRAP_BAND)
|
|
223
|
+
return 'left';
|
|
224
|
+
if (x > 1 - WRAP_BAND)
|
|
225
|
+
return 'right';
|
|
226
|
+
}
|
|
227
|
+
return dropPositionForPointer({ ratio: flow === 'horizontal' ? x : y, nestable, edges });
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Map a pointer offset within a drop target's box onto a `DropPosition`.
|
|
231
|
+
* `ratio` is the pointer's offset along the target's main axis, 0..1 — the
|
|
232
|
+
* caller picks the axis (the parent's flow axis; see `containerFlowAxis`).
|
|
233
|
+
*
|
|
234
|
+
* - nestable targets with siblings: edge quarters insert before/after, the
|
|
235
|
+
* middle half nests into the slot
|
|
236
|
+
* - leaf targets: top/bottom halves insert before/after
|
|
237
|
+
* - targets without siblings (the root): always `into`
|
|
238
|
+
*/
|
|
239
|
+
export function dropPositionForPointer(args) {
|
|
240
|
+
const { ratio, nestable, edges } = args;
|
|
241
|
+
if (!edges)
|
|
242
|
+
return 'into';
|
|
243
|
+
if (nestable) {
|
|
244
|
+
if (ratio < 0.25)
|
|
245
|
+
return 'before';
|
|
246
|
+
if (ratio > 0.75)
|
|
247
|
+
return 'after';
|
|
248
|
+
return 'into';
|
|
249
|
+
}
|
|
250
|
+
return ratio < 0.5 ? 'before' : 'after';
|
|
251
|
+
}
|
|
252
|
+
export function dropIndicatorFor(resolution, position) {
|
|
253
|
+
if (resolution.eligible)
|
|
254
|
+
return position;
|
|
255
|
+
return resolution.code === 'no-op' ? null : 'blocked';
|
|
256
|
+
}
|
|
257
|
+
//# sourceMappingURL=drop-rules.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"drop-rules.js","sourceRoot":"","sources":["../../../src/lib/dnd/drop-rules.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,kBAAkB,EAClB,OAAO,EACP,aAAa,EACb,iBAAiB,EACjB,cAAc,EACd,UAAU,EACV,UAAU,GACX,MAAM,0BAA0B,CAAA;AAmGjC,SAAS,QAAQ,CAAC,IAAuB,EAAE,MAAc;IACvD,OAAO,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,EAAE,CAAA;AAC1C,CAAC;AAED,8EAA8E;AAC9E,aAAa;AACb,8EAA8E;AAE9E;;;;;GAKG;AACH,MAAM,UAAU,iBAAiB,CAAC,QAAmC;IACnE,IAAI,CAAC,QAAQ;QAAE,OAAO,SAAS,CAAA;IAC/B,OAAO,CACL,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,YAAY,CAAC;QACnD,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,WAAW,CAAC,CACnD,CAAA;AACH,CAAC;AAED,2FAA2F;AAC3F,MAAM,UAAU,WAAW,CAAC,WAA2B,EAAE,WAAmB;IAC1E,OAAO,iBAAiB,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC,KAAK,SAAS,CAAA;AAClE,CAAC;AAED,uEAAuE;AACvE,MAAM,UAAU,UAAU,CAAC,IAA0B,EAAE,WAAmB;IACxE,IAAI,CAAC,IAAI,EAAE,KAAK;QAAE,OAAO,IAAI,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AK,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,SAAS,CAAA;AACvD,CAAC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { ComponentNode, SpacingTokenName } from '@elytracms/project-graph';
|
|
2
|
+
import type { FlowAxis } from './drop-rules';
|
|
3
|
+
/**
|
|
4
|
+
* Tokenized gap-drag math (EC-163, vision §3.1 / AD-10) — pure functions with
|
|
5
|
+
* no DOM dependencies, shared by the canvas spacing handles. The drag model is
|
|
6
|
+
* deliberately token-quantized: a pointer delta moves the gap through the
|
|
7
|
+
* EC-161 spacing-token *steps*, and the only values that can ever be produced
|
|
8
|
+
* are a `SpacingTokenName` or `null` ("no gap" — the prop is removed, exactly
|
|
9
|
+
* what the layout inspector's "None" choice does). No freeform pixel value can
|
|
10
|
+
* leave this module, so none can enter the graph from the canvas.
|
|
11
|
+
*/
|
|
12
|
+
/** A gap step the drag can land on: a spacing token, or `null` for "no gap". */
|
|
13
|
+
export type GapStep = SpacingTokenName | null;
|
|
14
|
+
/** The full drag range, smallest to largest: none, then the EC-161 token scale. */
|
|
15
|
+
export declare const GAP_STEPS: readonly GapStep[];
|
|
16
|
+
/** Canvas root font size — the deterministic rem basis for token CSS lengths. */
|
|
17
|
+
export declare const GAP_REM_PX = 16;
|
|
18
|
+
/** The pixel length of a gap step at the canvas rem basis. */
|
|
19
|
+
export declare function gapStepPx(step: GapStep): number;
|
|
20
|
+
/** The CSS length a previewed step renders with (the same length the renderer emits). */
|
|
21
|
+
export declare function gapStepCss(step: GapStep): string;
|
|
22
|
+
/** Snap a raw pixel gap onto the nearest step of the token scale. */
|
|
23
|
+
export declare function nearestGapStep(px: number): GapStep;
|
|
24
|
+
/**
|
|
25
|
+
* The step a drag lands on: the starting step's pixel length plus the pointer
|
|
26
|
+
* delta along the container's flow axis, snapped to the scale. Monotonic and
|
|
27
|
+
* deterministic — the same delta from the same start always lands on the same
|
|
28
|
+
* token.
|
|
29
|
+
*/
|
|
30
|
+
export declare function gapStepFromDrag(start: GapStep, deltaPx: number): GapStep;
|
|
31
|
+
/**
|
|
32
|
+
* The current gap step of a container node: a token name verbatim, a legacy
|
|
33
|
+
* on-scale integer mapped to its token, anything else (absent, off-scale,
|
|
34
|
+
* bound) as `null` — mirroring how the layout inspector reads the same prop,
|
|
35
|
+
* so handle and inspector always start from the same value.
|
|
36
|
+
*/
|
|
37
|
+
export declare function containerGapStep(node: ComponentNode): GapStep;
|
|
38
|
+
/** A minimal rectangle (client or document coordinates — caller's choice). */
|
|
39
|
+
export interface GapRect {
|
|
40
|
+
left: number;
|
|
41
|
+
top: number;
|
|
42
|
+
width: number;
|
|
43
|
+
height: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* One draggable spot between two adjacent children. `x`/`y` is the gap's
|
|
47
|
+
* center point; `crossStart`/`crossLength` span the children's shared extent
|
|
48
|
+
* on the cross axis (the handle's visible length).
|
|
49
|
+
*/
|
|
50
|
+
export interface GapHandleSpot {
|
|
51
|
+
/** Index of the leading child of the pair. */
|
|
52
|
+
index: number;
|
|
53
|
+
x: number;
|
|
54
|
+
y: number;
|
|
55
|
+
crossStart: number;
|
|
56
|
+
crossLength: number;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* The handle spots between consecutive child rects along the container's flow
|
|
60
|
+
* axis. Pairs that wrap (grid rows: the next rect starts before the previous
|
|
61
|
+
* ends along the axis) or that do not overlap on the cross axis yield no
|
|
62
|
+
* handle — handles only ever sit in real gaps between visual neighbours.
|
|
63
|
+
* Works at gap 0 too: the handle sits on the shared boundary so a closed gap
|
|
64
|
+
* can be dragged open.
|
|
65
|
+
*/
|
|
66
|
+
export declare function gapHandleSpots(rects: readonly GapRect[], axis: FlowAxis): GapHandleSpot[];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { SPACING_TOKEN_CSS, SPACING_TOKEN_NAMES, isSpacingTokenName, spacingTokenFromLegacyGap, } from '@elytracms/project-graph';
|
|
2
|
+
/** The full drag range, smallest to largest: none, then the EC-161 token scale. */
|
|
3
|
+
export const GAP_STEPS = [null, ...SPACING_TOKEN_NAMES];
|
|
4
|
+
/** Canvas root font size — the deterministic rem basis for token CSS lengths. */
|
|
5
|
+
export const GAP_REM_PX = 16;
|
|
6
|
+
/** The pixel length of a gap step at the canvas rem basis. */
|
|
7
|
+
export function gapStepPx(step) {
|
|
8
|
+
if (step === null)
|
|
9
|
+
return 0;
|
|
10
|
+
const css = SPACING_TOKEN_CSS[step];
|
|
11
|
+
const value = Number.parseFloat(css);
|
|
12
|
+
return css.endsWith('rem') ? value * GAP_REM_PX : value;
|
|
13
|
+
}
|
|
14
|
+
/** The CSS length a previewed step renders with (the same length the renderer emits). */
|
|
15
|
+
export function gapStepCss(step) {
|
|
16
|
+
return step === null ? '0px' : SPACING_TOKEN_CSS[step];
|
|
17
|
+
}
|
|
18
|
+
/** Snap a raw pixel gap onto the nearest step of the token scale. */
|
|
19
|
+
export function nearestGapStep(px) {
|
|
20
|
+
let best = null;
|
|
21
|
+
let bestDistance = Number.POSITIVE_INFINITY;
|
|
22
|
+
for (const step of GAP_STEPS) {
|
|
23
|
+
const distance = Math.abs(gapStepPx(step) - px);
|
|
24
|
+
if (distance < bestDistance) {
|
|
25
|
+
bestDistance = distance;
|
|
26
|
+
best = step;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return best;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* The step a drag lands on: the starting step's pixel length plus the pointer
|
|
33
|
+
* delta along the container's flow axis, snapped to the scale. Monotonic and
|
|
34
|
+
* deterministic — the same delta from the same start always lands on the same
|
|
35
|
+
* token.
|
|
36
|
+
*/
|
|
37
|
+
export function gapStepFromDrag(start, deltaPx) {
|
|
38
|
+
return nearestGapStep(gapStepPx(start) + deltaPx);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* The current gap step of a container node: a token name verbatim, a legacy
|
|
42
|
+
* on-scale integer mapped to its token, anything else (absent, off-scale,
|
|
43
|
+
* bound) as `null` — mirroring how the layout inspector reads the same prop,
|
|
44
|
+
* so handle and inspector always start from the same value.
|
|
45
|
+
*/
|
|
46
|
+
export function containerGapStep(node) {
|
|
47
|
+
const prop = node.props?.['gap'];
|
|
48
|
+
if (prop?.kind !== 'static')
|
|
49
|
+
return null;
|
|
50
|
+
if (typeof prop.value === 'string' && isSpacingTokenName(prop.value))
|
|
51
|
+
return prop.value;
|
|
52
|
+
if (typeof prop.value === 'number') {
|
|
53
|
+
const token = spacingTokenFromLegacyGap(prop.value);
|
|
54
|
+
if (token)
|
|
55
|
+
return token;
|
|
56
|
+
}
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* The handle spots between consecutive child rects along the container's flow
|
|
61
|
+
* axis. Pairs that wrap (grid rows: the next rect starts before the previous
|
|
62
|
+
* ends along the axis) or that do not overlap on the cross axis yield no
|
|
63
|
+
* handle — handles only ever sit in real gaps between visual neighbours.
|
|
64
|
+
* Works at gap 0 too: the handle sits on the shared boundary so a closed gap
|
|
65
|
+
* can be dragged open.
|
|
66
|
+
*/
|
|
67
|
+
export function gapHandleSpots(rects, axis) {
|
|
68
|
+
const spots = [];
|
|
69
|
+
for (let i = 0; i < rects.length - 1; i += 1) {
|
|
70
|
+
const a = rects[i];
|
|
71
|
+
const b = rects[i + 1];
|
|
72
|
+
const aEnd = axis === 'horizontal' ? a.left + a.width : a.top + a.height;
|
|
73
|
+
const bStart = axis === 'horizontal' ? b.left : b.top;
|
|
74
|
+
// Wrapped to the next row/column: not visual neighbours along the axis.
|
|
75
|
+
// A small tolerance keeps sub-pixel layout from dropping legitimate pairs.
|
|
76
|
+
if (bStart < aEnd - 0.5)
|
|
77
|
+
continue;
|
|
78
|
+
const crossStart = axis === 'horizontal' ? Math.max(a.top, b.top) : Math.max(a.left, b.left);
|
|
79
|
+
const crossEnd = axis === 'horizontal'
|
|
80
|
+
? Math.min(a.top + a.height, b.top + b.height)
|
|
81
|
+
: Math.min(a.left + a.width, b.left + b.width);
|
|
82
|
+
if (crossEnd <= crossStart)
|
|
83
|
+
continue;
|
|
84
|
+
const mid = (aEnd + bStart) / 2;
|
|
85
|
+
spots.push({
|
|
86
|
+
index: i,
|
|
87
|
+
x: axis === 'horizontal' ? mid : crossStart + (crossEnd - crossStart) / 2,
|
|
88
|
+
y: axis === 'horizontal' ? crossStart + (crossEnd - crossStart) / 2 : mid,
|
|
89
|
+
crossStart,
|
|
90
|
+
crossLength: crossEnd - crossStart,
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
return spots;
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=gap-drag.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gap-drag.js","sourceRoot":"","sources":["../../../src/lib/dnd/gap-drag.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,mBAAmB,EACnB,kBAAkB,EAClB,yBAAyB,GAC1B,MAAM,0BAA0B,CAAA;AAiBjC,mFAAmF;AACnF,MAAM,CAAC,MAAM,SAAS,GAAuB,CAAC,IAAI,EAAE,GAAG,mBAAmB,CAAC,CAAA;AAE3E,iFAAiF;AACjF,MAAM,CAAC,MAAM,UAAU,GAAG,EAAE,CAAA;AAE5B,8DAA8D;AAC9D,MAAM,UAAU,SAAS,CAAC,IAAa;IACrC,IAAI,IAAI,KAAK,IAAI;QAAE,OAAO,CAAC,CAAA;IAC3B,MAAM,GAAG,GAAG,iBAAiB,CAAC,IAAI,CAAC,CAAA;IACnC,MAAM,KAAK,GAAG,MAAM,CAAC,UAAU,CAAC,GAAG,CAAC,CAAA;IACpC,OAAO,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,GAAG,UAAU,CAAC,CAAC,CAAC,KAAK,CAAA;AACzD,CAAC;AAED,yFAAyF;AACzF,MAAM,UAAU,UAAU,CAAC,IAAa;IACtC,OAAO,IAAI,KAAK,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,IAAI,GAAG,CAAC,CAAC,KAAK,CAAC,CAAA;QAClD,IAAI,QAAQ,IAAI,UAAU;YAAE,SAAQ;QACpC,MAAM,GAAG,GAAG,CAAC,IAAI,GAAG,MAAM,CAAC,GAAG,CAAC,CAAA;QAC/B,KAAK,CAAC,IAAI,CAAC;YACT,KAAK,EAAE,CAAC;YACR,CAAC,EAAE,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC;YACzE,CAAC,EAAE,IAAI,KAAK,YAAY,CAAC,CAAC,CAAC,UAAU,GAAG,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG;YACzE,UAAU;YACV,WAAW,EAAE,QAAQ,GAAG,UAAU;SACnC,CAAC,CAAA;IACJ,CAAC;IACD,OAAO,KAAK,CAAA;AACd,CAAC"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Locale } from '@elytracms/cms-core';
|
|
2
|
+
import type { BindingReference } from '@elytracms/project-graph';
|
|
3
|
+
import type { DataSource } from '@elytracms/data-binding';
|
|
4
|
+
import type { DisplayedFallback } from './fallback';
|
|
5
|
+
/**
|
|
6
|
+
* Fallback visibility for BOUND content (EC-176): given a stored content
|
|
7
|
+
* binding and its CMS source, decide whether the value the canvas currently
|
|
8
|
+
* previews for the active locale is served via EC-018 locale fallback. Used
|
|
9
|
+
* by the inspector's Content tab — the surface that explains what a bound
|
|
10
|
+
* field shows (the canvas overlay itself is out of this wave's reach; see
|
|
11
|
+
* EC-176 notes).
|
|
12
|
+
*
|
|
13
|
+
* Deterministic over the playground delivery engine: the same
|
|
14
|
+
* `@elytracms/content` resolution that produced the previewed value reports
|
|
15
|
+
* which fields fell back (`ResolutionInfo.localeFallbacks`), so the label can
|
|
16
|
+
* never disagree with the displayed value.
|
|
17
|
+
*/
|
|
18
|
+
/** A previewed bound value that fell back, plus which field it came from. */
|
|
19
|
+
export interface BoundValueFallback extends DisplayedFallback {
|
|
20
|
+
field: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Whether the bound field's previewed value (first entry for list/repeater
|
|
24
|
+
* bindings, the bound document otherwise) is a locale fallback in `locale`.
|
|
25
|
+
* `null` when the binding is not CMS-shaped, points at no field, or the value
|
|
26
|
+
* is a real translation.
|
|
27
|
+
*/
|
|
28
|
+
export declare function cmsBindingFallback(binding: BindingReference, source: DataSource | undefined, locale: Locale): BoundValueFallback | null;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { listQueryOfConfig } from '../bindings/section-bindings';
|
|
2
|
+
import { getCollectionDocument, runCollectionListQuery } from '../data/collection-content';
|
|
3
|
+
function isCmsSource(source) {
|
|
4
|
+
return source.kind === 'cms';
|
|
5
|
+
}
|
|
6
|
+
/** JSON-pointer-ish token → path segments ('/0/title' → ['0', 'title']). */
|
|
7
|
+
function pathOfToken(token) {
|
|
8
|
+
return token
|
|
9
|
+
.split('/')
|
|
10
|
+
.filter((segment) => segment.length > 0)
|
|
11
|
+
.map((segment) => segment.replaceAll('~1', '/').replaceAll('~0', '~'));
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Whether the bound field's previewed value (first entry for list/repeater
|
|
15
|
+
* bindings, the bound document otherwise) is a locale fallback in `locale`.
|
|
16
|
+
* `null` when the binding is not CMS-shaped, points at no field, or the value
|
|
17
|
+
* is a real translation.
|
|
18
|
+
*/
|
|
19
|
+
export function cmsBindingFallback(binding, source, locale) {
|
|
20
|
+
if (source === undefined || !isCmsSource(source))
|
|
21
|
+
return null;
|
|
22
|
+
if (binding.mode !== 'value' && binding.mode !== 'repeaterItem')
|
|
23
|
+
return null;
|
|
24
|
+
const config = source.config;
|
|
25
|
+
let path = pathOfToken(binding.token);
|
|
26
|
+
if (path.length === 0)
|
|
27
|
+
return null;
|
|
28
|
+
// List-shaped value bindings carry a leading entry index; repeater-item
|
|
29
|
+
// bindings preview the first entry (the same convention as ContentPreview).
|
|
30
|
+
let entryIndex = 0;
|
|
31
|
+
const listShaped = config.documentId === undefined;
|
|
32
|
+
if (binding.mode === 'value' && listShaped) {
|
|
33
|
+
const head = path[0];
|
|
34
|
+
if (!/^\d+$/.test(head))
|
|
35
|
+
return null;
|
|
36
|
+
entryIndex = Number(head);
|
|
37
|
+
path = path.slice(1);
|
|
38
|
+
}
|
|
39
|
+
const field = path[0];
|
|
40
|
+
if (field === undefined)
|
|
41
|
+
return null;
|
|
42
|
+
// Resolve the previewed document's id, then ask the delivery engine which
|
|
43
|
+
// fields fell back for it in the active locale.
|
|
44
|
+
let documentId = config.documentId;
|
|
45
|
+
if (documentId === undefined) {
|
|
46
|
+
const list = runCollectionListQuery(config.collectionId, listQueryOfConfig(config), locale);
|
|
47
|
+
if (!list.ok)
|
|
48
|
+
return null;
|
|
49
|
+
const entry = list.documents[entryIndex];
|
|
50
|
+
if (entry === undefined)
|
|
51
|
+
return null;
|
|
52
|
+
documentId = entry.id;
|
|
53
|
+
}
|
|
54
|
+
const { info } = getCollectionDocument(config.collectionId, documentId, locale);
|
|
55
|
+
if (info === null)
|
|
56
|
+
return null;
|
|
57
|
+
const fellBack = info.localeFallbacks.find((entry) => entry.path[0] === field);
|
|
58
|
+
if (fellBack === undefined)
|
|
59
|
+
return null;
|
|
60
|
+
return {
|
|
61
|
+
field,
|
|
62
|
+
sourceLocale: fellBack.sourceLocale,
|
|
63
|
+
requestedLocale: fellBack.requestedLocale,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=binding-fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"binding-fallback.js","sourceRoot":"","sources":["../../../src/lib/locale/binding-fallback.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAA;AAEhE,OAAO,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,4BAA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ocument, CollectionDef, Locale, LocaleConfig } from '@elytracms/cms-core';
|
|
2
|
+
/**
|
|
3
|
+
* Fallback visibility (EC-176) — the pure "is this displayed value a
|
|
4
|
+
* fallback?" decision the CMS table cells, detail-editor fields, and the
|
|
5
|
+
* builder's Content tab all share. One function answers it, so a value is
|
|
6
|
+
* either labeled everywhere or a real translation everywhere — never
|
|
7
|
+
* silently mixed.
|
|
8
|
+
*/
|
|
9
|
+
/** A displayed value that came from the fallback locale, not the active one. */
|
|
10
|
+
export interface DisplayedFallback {
|
|
11
|
+
/** The locale the rendered value was actually read from. */
|
|
12
|
+
sourceLocale: Locale;
|
|
13
|
+
/** The locale the surface asked for (the ambient active locale). */
|
|
14
|
+
requestedLocale: Locale;
|
|
15
|
+
}
|
|
16
|
+
/** True when the document stores an explicit variant of `field` for `locale`. */
|
|
17
|
+
export declare function hasLocaleVariant(doc: CmsDocument, fieldName: string, locale: Locale): boolean;
|
|
18
|
+
/**
|
|
19
|
+
* Whether the value a surface displays for `field` in `locale` is served via
|
|
20
|
+
* EC-018 default-locale fallback. `null` means "not a fallback": the field is
|
|
21
|
+
* not localized (locale-independent by design), the active locale has its own
|
|
22
|
+
* variant, or there is nothing to display at all (an empty field is empty,
|
|
23
|
+
* not a fallback).
|
|
24
|
+
*/
|
|
25
|
+
export declare function displayedFieldFallback(collection: CollectionDef, doc: CmsDocument, fieldName: string, locale: Locale, config: LocaleConfig): DisplayedFallback | null;
|
|
26
|
+
/**
|
|
27
|
+
* The value a surface should display for `field` in `locale` (explicit
|
|
28
|
+
* variant, else fallback) together with its fallback marker. Display and
|
|
29
|
+
* label come from the same resolution, so they can never disagree.
|
|
30
|
+
*/
|
|
31
|
+
export declare function resolveDisplayedValue(collection: CollectionDef, doc: CmsDocument, fieldName: string, locale: Locale, config: LocaleConfig): {
|
|
32
|
+
value: unknown;
|
|
33
|
+
fallback: DisplayedFallback | null;
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* True when editing `field` in `locale` would CREATE a new localized variant
|
|
37
|
+
* (rather than update an existing one): the field is localized and the active
|
|
38
|
+
* locale isn't the document's fallback source and has no variant yet. Drives
|
|
39
|
+
* the "translating from EN" affordance on editors.
|
|
40
|
+
*/
|
|
41
|
+
export declare function editCreatesVariant(collection: CollectionDef, doc: CmsDocument, fieldName: string, locale: Locale, config: LocaleConfig): boolean;
|
|
42
|
+
/** Compact display form of a locale code for chips/badges ("en" → "EN"). */
|
|
43
|
+
export declare function localeChipLabel(locale: Locale): string;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { documentDefaultLocale, isFieldLocalized, resolveField } from '@elytracms/cms-core';
|
|
2
|
+
/** True when the document stores an explicit variant of `field` for `locale`. */
|
|
3
|
+
export function hasLocaleVariant(doc, fieldName, locale) {
|
|
4
|
+
const bag = doc.localized?.[locale];
|
|
5
|
+
return bag !== undefined && fieldName in bag;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Whether the value a surface displays for `field` in `locale` is served via
|
|
9
|
+
* EC-018 default-locale fallback. `null` means "not a fallback": the field is
|
|
10
|
+
* not localized (locale-independent by design), the active locale has its own
|
|
11
|
+
* variant, or there is nothing to display at all (an empty field is empty,
|
|
12
|
+
* not a fallback).
|
|
13
|
+
*/
|
|
14
|
+
export function displayedFieldFallback(collection, doc, fieldName, locale, config) {
|
|
15
|
+
if (!isFieldLocalized(collection, fieldName))
|
|
16
|
+
return null;
|
|
17
|
+
if (hasLocaleVariant(doc, fieldName, locale))
|
|
18
|
+
return null;
|
|
19
|
+
const resolved = resolveField(collection, doc, fieldName, locale, config);
|
|
20
|
+
if (!resolved.fellBack || resolved.value === undefined)
|
|
21
|
+
return null;
|
|
22
|
+
return { sourceLocale: resolved.sourceLocale, requestedLocale: locale };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* The value a surface should display for `field` in `locale` (explicit
|
|
26
|
+
* variant, else fallback) together with its fallback marker. Display and
|
|
27
|
+
* label come from the same resolution, so they can never disagree.
|
|
28
|
+
*/
|
|
29
|
+
export function resolveDisplayedValue(collection, doc, fieldName, locale, config) {
|
|
30
|
+
return {
|
|
31
|
+
value: resolveField(collection, doc, fieldName, locale, config).value,
|
|
32
|
+
fallback: displayedFieldFallback(collection, doc, fieldName, locale, config),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* True when editing `field` in `locale` would CREATE a new localized variant
|
|
37
|
+
* (rather than update an existing one): the field is localized and the active
|
|
38
|
+
* locale isn't the document's fallback source and has no variant yet. Drives
|
|
39
|
+
* the "translating from EN" affordance on editors.
|
|
40
|
+
*/
|
|
41
|
+
export function editCreatesVariant(collection, doc, fieldName, locale, config) {
|
|
42
|
+
if (!isFieldLocalized(collection, fieldName))
|
|
43
|
+
return false;
|
|
44
|
+
if (locale === documentDefaultLocale(doc, config))
|
|
45
|
+
return false;
|
|
46
|
+
return !hasLocaleVariant(doc, fieldName, locale);
|
|
47
|
+
}
|
|
48
|
+
/** Compact display form of a locale code for chips/badges ("en" → "EN"). */
|
|
49
|
+
export function localeChipLabel(locale) {
|
|
50
|
+
return locale.toUpperCase();
|
|
51
|
+
}
|
|
52
|
+
//# sourceMappingURL=fallback.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fallback.js","sourceRoot":"","sources":["../../../src/lib/locale/fallback.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAA;AAmB3F,iFAAiF;AACjF,MAAM,UAAU,gBAAgB,CAAC,GAAgB,EAAE,SAAiB,EAAE,MAAc;IAClF,MAAM,GAAG,GAAG,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,CAAA;IACnC,OAAO,GAAG,KAAK,SAAS,IAAI,SAAS,IAAI,GAAG,CAAA;AAC9C,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,sBAAsB,CACpC,UAAyB,EACzB,GAA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