@antelopejs/dms 0.25.7 → 0.25.8-next.1166.gbc4d5cc
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/E2E.md +3 -2
- package/data/mockup-example/spec.json +11 -0
- package/data/mockup-spec.schema.json +399 -20
- package/dist/e2e/index.d.mts +3 -1
- package/dist/e2e/run-state.d.mts +8 -0
- package/dist/e2e/stack.d.mts +3 -1
- package/dist/implementations/dms/page/access.js +1 -1
- package/dist/implementations/dms/page/access.js.map +1 -1
- package/dist/implementations/dms/page/payloads.js +1 -1
- package/dist/implementations/dms/page/payloads.js.map +1 -1
- package/dist/implementations/dms/page/registry.js +1 -1
- package/dist/implementations/dms/page/registry.js.map +1 -1
- package/dist/implementations/dms-base/bulk-selection.d.ts +1 -1
- package/dist/implementations/dms-base/bulk-selection.js +7 -1
- package/dist/implementations/dms-base/bulk-selection.js.map +1 -1
- package/dist/implementations/dms-base/group-order.d.ts +1 -1
- package/dist/implementations/dms-base/group-order.js +17 -4
- package/dist/implementations/dms-base/group-order.js.map +1 -1
- package/dist/implementations/dms-base/search-route.d.ts +1 -1
- package/dist/implementations/dms-base/search-route.js +11 -3
- package/dist/implementations/dms-base/search-route.js.map +1 -1
- package/dist/implementations/dms-base/table-view.js +12 -3
- package/dist/implementations/dms-base/table-view.js.map +1 -1
- package/dist/implementations/dms-builder/engine/expression.js +3 -2
- package/dist/implementations/dms-builder/engine/expression.js.map +1 -1
- package/dist/implementations/dms-builder/engine/inherited-variables.js +2 -1
- package/dist/implementations/dms-builder/engine/inherited-variables.js.map +1 -1
- package/dist/implementations/dms-builder/engine/preview.js +2 -1
- package/dist/implementations/dms-builder/engine/preview.js.map +1 -1
- package/dist/implementations/dms-builder/engine/table-view-settings.js +34 -14
- package/dist/implementations/dms-builder/engine/table-view-settings.js.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +2 -0
- package/dist/mcp/index.js +9 -0
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/mockup-export/capture.d.ts +19 -0
- package/dist/mcp/mockup-export/capture.js +99 -0
- package/dist/mcp/mockup-export/capture.js.map +1 -0
- package/dist/mcp/mockup-export/document.d.ts +4 -0
- package/dist/mcp/mockup-export/document.js +199 -0
- package/dist/mcp/mockup-export/document.js.map +1 -0
- package/dist/mcp/mockup-export/index.d.ts +20 -0
- package/dist/mcp/mockup-export/index.js +110 -0
- package/dist/mcp/mockup-export/index.js.map +1 -0
- package/dist/mcp/mockup-export/jobs.d.ts +32 -0
- package/dist/mcp/mockup-export/jobs.js +49 -0
- package/dist/mcp/mockup-export/jobs.js.map +1 -0
- package/dist/mcp/mockup-export/plan.d.ts +78 -0
- package/dist/mcp/mockup-export/plan.js +292 -0
- package/dist/mcp/mockup-export/plan.js.map +1 -0
- package/dist/mcp/mockup-export/route.d.ts +23 -0
- package/dist/mcp/mockup-export/route.js +91 -0
- package/dist/mcp/mockup-export/route.js.map +1 -0
- package/dist/mcp/page-verify/index.d.ts +15 -0
- package/dist/mcp/page-verify/index.js +16 -6
- package/dist/mcp/page-verify/index.js.map +1 -1
- package/dist/mcp/page-verify/mockup.d.ts +2 -1
- package/dist/mcp/page-verify/mockup.js +1 -0
- package/dist/mcp/page-verify/mockup.js.map +1 -1
- package/dist/mcp/page-verify/modules.d.ts +8 -0
- package/dist/mcp/page-verify/modules.js +49 -0
- package/dist/mcp/page-verify/modules.js.map +1 -0
- package/dist/mcp/page-verify/playwright.d.ts +22 -4
- package/dist/mcp/page-verify/playwright.js.map +1 -1
- package/dist/mcp/page-verify/report.d.ts +1 -0
- package/dist/mcp/tools/mockup-export-pdf.d.ts +1 -0
- package/dist/mcp/tools/mockup-export-pdf.js +69 -0
- package/dist/mcp/tools/mockup-export-pdf.js.map +1 -0
- package/dist/mcp/tools/mockup-module-catalog.d.ts +1 -0
- package/dist/mcp/tools/mockup-module-catalog.js +36 -0
- package/dist/mcp/tools/mockup-module-catalog.js.map +1 -0
- package/dist/mcp/tools/mockup-read-spec.js +2 -3
- package/dist/mcp/tools/mockup-read-spec.js.map +1 -1
- package/dist/mcp/tools/mockup.js +4 -0
- package/dist/mcp/tools/mockup.js.map +1 -1
- package/dist/mcp/tools/page-verify.d.ts +1 -0
- package/dist/mcp/tools/page-verify.js +6 -2
- package/dist/mcp/tools/page-verify.js.map +1 -1
- package/dist/mockup/annotations.js +2 -2
- package/dist/mockup/annotations.js.map +1 -1
- package/dist/mockup/apply-notes.js +1 -1
- package/dist/mockup/apply-notes.js.map +1 -1
- package/dist/mockup/compile-layouts.d.ts +5 -0
- package/dist/mockup/compile-layouts.js +74 -0
- package/dist/mockup/compile-layouts.js.map +1 -0
- package/dist/mockup/compile-nodes.d.ts +11 -0
- package/dist/mockup/compile-nodes.js +119 -0
- package/dist/mockup/compile-nodes.js.map +1 -0
- package/dist/mockup/compile-pages.d.ts +18 -0
- package/dist/mockup/compile-pages.js +188 -0
- package/dist/mockup/compile-pages.js.map +1 -0
- package/dist/mockup/compile.d.ts +6 -10
- package/dist/mockup/compile.js +31 -289
- package/dist/mockup/compile.js.map +1 -1
- package/dist/mockup/create.d.ts +16 -0
- package/dist/mockup/create.js +78 -0
- package/dist/mockup/create.js.map +1 -0
- package/dist/mockup/created-watch.d.ts +18 -0
- package/dist/mockup/created-watch.js +110 -0
- package/dist/mockup/created-watch.js.map +1 -0
- package/dist/mockup/entities.d.ts +20 -0
- package/dist/mockup/entities.js +213 -0
- package/dist/mockup/entities.js.map +1 -0
- package/dist/mockup/etag.d.ts +1 -0
- package/dist/mockup/etag.js +10 -0
- package/dist/mockup/etag.js.map +1 -0
- package/dist/mockup/extensions.d.ts +17 -0
- package/dist/mockup/extensions.js +56 -0
- package/dist/mockup/extensions.js.map +1 -0
- package/dist/mockup/files.d.ts +2 -1
- package/dist/mockup/files.js +2 -1
- package/dist/mockup/files.js.map +1 -1
- package/dist/mockup/fixture-answers.d.ts +1 -0
- package/dist/mockup/fixture-answers.js +1 -1
- package/dist/mockup/fixture-answers.js.map +1 -1
- package/dist/mockup/fixture-batch.d.ts +21 -0
- package/dist/mockup/fixture-batch.js +111 -0
- package/dist/mockup/fixture-batch.js.map +1 -0
- package/dist/mockup/fixture-routes.d.ts +21 -0
- package/dist/mockup/fixture-routes.js +136 -0
- package/dist/mockup/fixture-routes.js.map +1 -0
- package/dist/mockup/fixtures.d.ts +0 -27
- package/dist/mockup/fixtures.js +11 -117
- package/dist/mockup/fixtures.js.map +1 -1
- package/dist/mockup/from-page.js +2 -9
- package/dist/mockup/from-page.js.map +1 -1
- package/dist/mockup/generate.js +4 -1
- package/dist/mockup/generate.js.map +1 -1
- package/dist/mockup/history-routes.d.ts +2 -4
- package/dist/mockup/history-routes.js +27 -36
- package/dist/mockup/history-routes.js.map +1 -1
- package/dist/mockup/history.js +2 -1
- package/dist/mockup/history.js.map +1 -1
- package/dist/mockup/index.d.ts +10 -0
- package/dist/mockup/index.js +10 -0
- package/dist/mockup/index.js.map +1 -1
- package/dist/mockup/json-schema-entities.d.ts +5 -0
- package/dist/mockup/json-schema-entities.js +141 -0
- package/dist/mockup/json-schema-entities.js.map +1 -0
- package/dist/mockup/json-schema-layout.d.ts +1 -0
- package/dist/mockup/json-schema-layout.js +95 -2
- package/dist/mockup/json-schema-layout.js.map +1 -1
- package/dist/mockup/json-schema.js +40 -23
- package/dist/mockup/json-schema.js.map +1 -1
- package/dist/mockup/json.d.ts +8 -0
- package/dist/mockup/json.js +20 -0
- package/dist/mockup/json.js.map +1 -0
- package/dist/mockup/layout-model.d.ts +156 -0
- package/dist/mockup/layout-model.js +96 -0
- package/dist/mockup/layout-model.js.map +1 -0
- package/dist/mockup/layouts.d.ts +9 -0
- package/dist/mockup/layouts.js +40 -0
- package/dist/mockup/layouts.js.map +1 -0
- package/dist/mockup/manage-routes.d.ts +3 -1
- package/dist/mockup/manage-routes.js +38 -1
- package/dist/mockup/manage-routes.js.map +1 -1
- package/dist/mockup/manage.js +1 -1
- package/dist/mockup/manage.js.map +1 -1
- package/dist/mockup/model.d.ts +137 -101
- package/dist/mockup/model.js +105 -91
- package/dist/mockup/model.js.map +1 -1
- package/dist/mockup/module-manifests.d.ts +99 -0
- package/dist/mockup/module-manifests.js +95 -0
- package/dist/mockup/module-manifests.js.map +1 -0
- package/dist/mockup/module-states.d.ts +10 -0
- package/dist/mockup/module-states.js +85 -0
- package/dist/mockup/module-states.js.map +1 -0
- package/dist/mockup/modules-schema.d.ts +2 -0
- package/dist/mockup/modules-schema.js +39 -0
- package/dist/mockup/modules-schema.js.map +1 -0
- package/dist/mockup/modules.d.ts +6 -9
- package/dist/mockup/modules.js +105 -24
- package/dist/mockup/modules.js.map +1 -1
- package/dist/mockup/owner-controller.js +1 -1
- package/dist/mockup/owner-controller.js.map +1 -1
- package/dist/mockup/page-capture-routes.d.ts +19 -0
- package/dist/mockup/page-capture-routes.js +92 -0
- package/dist/mockup/page-capture-routes.js.map +1 -0
- package/dist/mockup/page-captures.d.ts +61 -0
- package/dist/mockup/page-captures.js +252 -0
- package/dist/mockup/page-captures.js.map +1 -0
- package/dist/mockup/parse-spec.d.ts +10 -0
- package/dist/mockup/parse-spec.js +62 -0
- package/dist/mockup/parse-spec.js.map +1 -0
- package/dist/mockup/places.d.ts +17 -0
- package/dist/mockup/places.js +75 -0
- package/dist/mockup/places.js.map +1 -0
- package/dist/mockup/presence-board.js +1 -1
- package/dist/mockup/presence-board.js.map +1 -1
- package/dist/mockup/presence-routes.js +2 -2
- package/dist/mockup/presence-routes.js.map +1 -1
- package/dist/mockup/refusals.d.ts +5 -0
- package/dist/mockup/refusals.js +16 -0
- package/dist/mockup/refusals.js.map +1 -1
- package/dist/mockup/routes.d.ts +3 -5
- package/dist/mockup/routes.js +19 -162
- package/dist/mockup/routes.js.map +1 -1
- package/dist/mockup/sketch-limits.d.ts +1 -0
- package/dist/mockup/sketch-limits.js +2 -1
- package/dist/mockup/sketch-limits.js.map +1 -1
- package/dist/mockup/sketch.d.ts +2 -2
- package/dist/mockup/sketch.js +2 -1
- package/dist/mockup/sketch.js.map +1 -1
- package/dist/mockup/slug.d.ts +3 -0
- package/dist/mockup/slug.js +7 -0
- package/dist/mockup/slug.js.map +1 -0
- package/dist/mockup/source-routes.d.ts +5 -4
- package/dist/mockup/source-routes.js +26 -17
- package/dist/mockup/source-routes.js.map +1 -1
- package/dist/mockup/source.js +2 -1
- package/dist/mockup/source.js.map +1 -1
- package/dist/mockup/state-patch.d.ts +22 -0
- package/dist/mockup/state-patch.js +75 -0
- package/dist/mockup/state-patch.js.map +1 -0
- package/dist/mockup/state.d.ts +112 -0
- package/dist/mockup/state.js +22 -0
- package/dist/mockup/state.js.map +1 -0
- package/dist/mockup/store-list.d.ts +28 -0
- package/dist/mockup/store-list.js +89 -0
- package/dist/mockup/store-list.js.map +1 -0
- package/dist/mockup/store.d.ts +16 -37
- package/dist/mockup/store.js +85 -200
- package/dist/mockup/store.js.map +1 -1
- package/dist/mockup/table-archive.d.ts +0 -1
- package/dist/mockup/table-archive.js +0 -16
- package/dist/mockup/table-archive.js.map +1 -1
- package/dist/mockup/tenancy.d.ts +19 -0
- package/dist/mockup/tenancy.js +73 -0
- package/dist/mockup/tenancy.js.map +1 -0
- package/dist/mockup/tenant-rows.d.ts +4 -0
- package/dist/mockup/tenant-rows.js +19 -0
- package/dist/mockup/tenant-rows.js.map +1 -0
- package/dist/pages/settings/users/account-activity.js +2 -1
- package/dist/pages/settings/users/account-activity.js.map +1 -1
- package/dist/routes/auth/oauth/config.js +1 -1
- package/dist/routes/auth/oauth/config.js.map +1 -1
- package/dist/routes/system-state.js +1 -1
- package/dist/routes/system-state.js.map +1 -1
- package/dist/store/interfaces.js +2 -1
- package/dist/store/interfaces.js.map +1 -1
- package/dist/utils/export-jobs-run.js +4 -4
- package/dist/utils/export-jobs-run.js.map +1 -1
- package/dist/utils/export-jobs.js +15 -3
- package/dist/utils/export-jobs.js.map +1 -1
- package/e2e/index.mjs +25 -3
- package/e2e/journey-run.mjs +4 -3
- package/e2e/run-state.mjs +11 -0
- package/e2e/stack.mjs +9 -1
- package/frontend-vue/eslint-globals.generated.mjs +40 -38
- package/frontend-vue/layers/dms-core/app/build/utils/asyncDataScope.ts +3 -31
- package/frontend-vue/layers/dms-core/app/composables/auth/useAuthFetch.ts +8 -2
- package/frontend-vue/layers/dms-core/app/composables/page/useSiteLayout.ts +5 -2
- package/frontend-vue/layers/dms-core/app/composables/period/usePeriod.ts +13 -19
- package/frontend-vue/layers/dms-core/app/composables/period/usePeriodScope.ts +6 -15
- package/frontend-vue/layers/dms-core/app/utils/localFetchAnswers.ts +124 -0
- package/frontend-vue/layers/dms-core/app/utils/textDigest.ts +29 -0
- package/frontend-vue/layers/dms-core/i18n/locales/core-en-GB.json +27 -3
- package/frontend-vue/layers/dms-core/i18n/locales/core-fr-FR.json +27 -3
- package/frontend-vue/layers/dms-layout/app/build/components/layout/DashboardSidebar.vue +110 -30
- package/frontend-vue/layers/dms-layout/app/build/components/layout/MockupSidebarMenu.vue +21 -6
- package/frontend-vue/layers/dms-layout/app/build/components/layout/SidebarUserMenu.vue +19 -7
- package/frontend-vue/layers/dms-layout/app/build/components/layout/mockupMenu.ts +79 -9
- package/frontend-vue/layers/dms-layout/app/build/components/layout/mockupWidgets.ts +65 -0
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/shell/SettingsNav.vue +17 -4
- package/frontend-vue/layers/dms-layout/app/build/components/pages/settings/shell/SettingsShell.vue +12 -0
- package/frontend-vue/layers/dms-layout/app/build/composables/notification/useNotificationGroupsOpen.ts +3 -3
- package/frontend-vue/layers/dms-layout/app/build/composables/notification/useNotificationPreferences.ts +13 -8
- package/frontend-vue/layers/dms-layout/app/build/composables/settings/useSettingsNavigation.ts +39 -0
- package/frontend-vue/layers/dms-layout/app/build/mockups/created-mockups.ts +12 -2
- package/frontend-vue/layers/dms-layout/app/build/mockups/created-toast.ts +9 -1
- package/frontend-vue/layers/dms-layout/app/composables/page/useModuleHistory.ts +3 -1
- package/frontend-vue/layers/dms-layout/app/custom-layouts/PreviewLayout.vue +53 -6
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/BlockPreviewSketch.vue +31 -5
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupCanvasChrome.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupDatabase.vue +153 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupEmptyState.vue +23 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupModuleStore.vue +164 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverview.vue +59 -33
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewSectionLabel.vue +51 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupOverviewSlot.vue +58 -12
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPagesList.vue +21 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPinCard.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupPinLayer.vue +1 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupReconnecting.vue +17 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupTenantBanner.vue +48 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupTopBar.vue +77 -9
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWorkbench.vue +130 -45
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupWorkspaceSwitcher.vue +142 -0
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/{MockupOverviewZoom.vue → MockupZoomControls.vue} +23 -15
- package/frontend-vue/layers/dms-ui/app/build/components/table/tableComponentTheme.ts +4 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewCapture.ts +70 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/previewNavigation.ts +44 -4
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useBlockInspector.ts +14 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useBlockPreviewEmbed.ts +241 -35
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useFixtureBatches.ts +154 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupActivation.ts +157 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupDatabase.ts +165 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupEditing.ts +13 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupFrameRender.ts +126 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupFrameSize.ts +10 -5
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupOverview.ts +63 -25
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPageFrame.ts +82 -29
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPageZoom.ts +138 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPdfExport.ts +124 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupPins.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupRealData.ts +10 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupRoutePage.ts +60 -14
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupSession.ts +8 -3
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupSpec.ts +6 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupTenancy.ts +37 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupToolModes.ts +5 -7
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerActivation.ts +56 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerExport.ts +46 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerPages.ts +29 -8
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useMockupViewerShortcuts.ts +13 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/useOverviewCaptures.ts +39 -10
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePersistedCaptures.ts +151 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/block-preview/usePreviewFrame.ts +19 -0
- package/frontend-vue/layers/dms-ui/app/build/composables/containers/drawerSize.ts +4 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/data-types/defaultIdentityCells.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/data-types/relationBadges.ts +2 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/form/formState.ts +3 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/navigation/useNavBadges.ts +3 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/page-toolbar/toolbarControlHeight.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewPresence.ts +10 -4
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/tableViewSelection.ts +5 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/useExpandedRowDetails.ts +6 -6
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/card.ts +4 -1
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/formTexts.ts +2 -2
- package/frontend-vue/layers/dms-ui/app/build/composables/table-view/utils/views.ts +1 -1
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCards.vue +37 -3
- package/frontend-vue/layers/dms-ui/app/build/mockups/MockupCreateModal.vue +130 -0
- package/frontend-vue/layers/dms-ui/app/build/mockups/manage.ts +20 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewChannel.ts +1 -8
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewMessages.ts +141 -103
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewNavigation.ts +332 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/blockPreviewRects.ts +22 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockup.ts +75 -173
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupActivation.ts +100 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupAnnotations.ts +146 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupCaptures.ts +118 -9
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupEdit.ts +0 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupEntities.ts +80 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupFrame.ts +123 -8
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupLinks.ts +6 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupModuleNavigation.ts +171 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupModules.ts +138 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupOverview.ts +42 -8
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupOverviewSections.ts +66 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupPageTree.ts +15 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupPins.ts +6 -8
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupRealData.ts +18 -5
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSchema.ts +177 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSections.ts +1 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupShortcuts.ts +17 -6
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSketchStates.ts +7 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupSpec.ts +0 -3
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupStatePatch.ts +179 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupStream.ts +17 -2
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupTenancy.ts +143 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupTenants.ts +23 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/mockupVersions.ts +2 -7
- package/frontend-vue/layers/dms-ui/app/build/utils/previewFixtureAnswers.ts +156 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/previewFixturesOnly.ts +8 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/previewPageLayout.ts +108 -6
- package/frontend-vue/layers/dms-ui/app/build/utils/previewPageQuery.ts +5 -1
- package/frontend-vue/layers/dms-ui/app/build/utils/previewRows.ts +400 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/recordGuards.ts +15 -0
- package/frontend-vue/layers/dms-ui/app/build/utils/sketch.ts +40 -10
- package/frontend-vue/layers/dms-ui/app/components/block-preview/BlockPreview.vue +23 -6
- package/frontend-vue/layers/dms-ui/app/components/block-preview/MockupViewer.vue +2 -0
- package/frontend-vue/layers/dms-ui/app/components/chart/ChartBlock.vue +1 -2
- package/frontend-vue/layers/dms-ui/app/components/form/components/RepeaterTable.vue +3 -1
- package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.ts +0 -2
- package/frontend-vue/layers/dms-ui/app/composables/chart/useApexChart.types.ts +0 -1
- package/frontend-vue/layers/dms-ui/app/composables/chart/useChartTheme.ts +8 -2
- package/frontend-vue/layers/dms-ui/app/composables/table-view/useTableDataChanges.ts +5 -4
- package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupModuleStore.ts +2 -0
- package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupTenantBanner.ts +2 -0
- package/frontend-vue/layers/dms-ui/app/entries/components/block-preview/MockupWorkspaceSwitcher.ts +2 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useFixtureBatches.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupActivation.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupOverview.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupPdfExport.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupRoutePage.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupSession.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/useMockupTenancy.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/composables/block-preview/usePersistedCaptures.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/json.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupActivation.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupAnnotations.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupModuleNavigation.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupOverviewSections.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupSchema.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupStatePatch.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupTenancy.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/mockupTenants.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/previewFixtureAnswers.ts +1 -0
- package/frontend-vue/layers/dms-ui/app/entries/utils/previewRows.ts +1 -0
- package/frontend-vue/layers/dms-ui/i18n/locales/ui-en-GB.json +53 -4
- package/frontend-vue/layers/dms-ui/i18n/locales/ui-fr-FR.json +53 -4
- package/frontend-vue/package.json +2 -2
- package/frontend-vue/server/private-options.ts +13 -3
- package/package.json +5 -5
- package/dist/mockup/row-filters.d.ts +0 -8
- package/dist/mockup/row-filters.js +0 -107
- package/dist/mockup/row-filters.js.map +0 -1
- package/frontend-vue/layers/dms-ui/app/build/components/block-preview/MockupModules.vue +0 -47
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isBoolean,
|
|
3
|
+
isNumber,
|
|
3
4
|
isObject,
|
|
4
5
|
isString,
|
|
5
6
|
} from "../../../../dms-core/app/utils/type-check";
|
|
7
|
+
import type { PreviewSketch } from "./blockPreview";
|
|
8
|
+
import { isPreviewSketch } from "./blockPreviewNavigation";
|
|
6
9
|
|
|
7
10
|
/**
|
|
8
11
|
* The layouts a mockup page is drawn in, named after their factories:
|
|
@@ -35,12 +38,51 @@ const LAYOUT_OPTION_KEYS: readonly string[] = [
|
|
|
35
38
|
"hideFooter",
|
|
36
39
|
] satisfies (keyof PreviewPageLayoutOptions)[];
|
|
37
40
|
|
|
38
|
-
/**
|
|
39
|
-
export interface
|
|
41
|
+
/** One of the DMS's layouts a page is drawn in, with its options. */
|
|
42
|
+
export interface PreviewBuiltInLayout {
|
|
40
43
|
type: PreviewPageLayoutType;
|
|
41
44
|
options?: PreviewPageLayoutOptions;
|
|
42
45
|
}
|
|
43
46
|
|
|
47
|
+
/** The side of the page a custom layout's aside is on. */
|
|
48
|
+
export type PreviewAsideSide = "start" | "end";
|
|
49
|
+
|
|
50
|
+
const ASIDE_SIDES: ReadonlySet<unknown> = new Set<PreviewAsideSide>([
|
|
51
|
+
"start",
|
|
52
|
+
"end",
|
|
53
|
+
]);
|
|
54
|
+
|
|
55
|
+
/** The aside of a custom layout: a sketch beside the page, `width` pixels wide. */
|
|
56
|
+
export interface PreviewLayoutAside extends PreviewSketch {
|
|
57
|
+
width: number;
|
|
58
|
+
side: PreviewAsideSide;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* A layout the spec declares, resolved for the page that names it: sketches
|
|
63
|
+
* drawn above, beside and under the page, and whether the dashboard's
|
|
64
|
+
* sidebar, top bar and page header stay around it.
|
|
65
|
+
*/
|
|
66
|
+
export interface PreviewCustomLayout {
|
|
67
|
+
type: "custom";
|
|
68
|
+
id: string;
|
|
69
|
+
title: string;
|
|
70
|
+
dashboard: boolean;
|
|
71
|
+
header?: PreviewSketch;
|
|
72
|
+
aside?: PreviewLayoutAside;
|
|
73
|
+
footer?: PreviewSketch;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** The layout a page is drawn in: one of the DMS's with its options, or a custom layout of the mockup. */
|
|
77
|
+
export type PreviewPageLayout = PreviewBuiltInLayout | PreviewCustomLayout;
|
|
78
|
+
|
|
79
|
+
/** The sketches a custom layout draws around the page. */
|
|
80
|
+
export interface PreviewCustomRegions {
|
|
81
|
+
header?: PreviewSketch;
|
|
82
|
+
aside?: PreviewLayoutAside;
|
|
83
|
+
footer?: PreviewSketch;
|
|
84
|
+
}
|
|
85
|
+
|
|
44
86
|
/** What the preview draws around a page's blocks. */
|
|
45
87
|
export interface PreviewFrame {
|
|
46
88
|
/** The dashboard's sidebar and top bar. */
|
|
@@ -57,6 +99,8 @@ export interface PreviewFrame {
|
|
|
57
99
|
brand: boolean;
|
|
58
100
|
/** Without the dashboard: the footer under the page. */
|
|
59
101
|
footer: boolean;
|
|
102
|
+
/** A custom layout's sketches around the page; absent for the DMS's own layouts. */
|
|
103
|
+
custom?: PreviewCustomRegions;
|
|
60
104
|
}
|
|
61
105
|
|
|
62
106
|
function isRecord(
|
|
@@ -85,10 +129,34 @@ function isLayoutOptions(value: unknown): value is PreviewPageLayoutOptions {
|
|
|
85
129
|
);
|
|
86
130
|
}
|
|
87
131
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
132
|
+
function isOptionalSketch(value: unknown): value is PreviewSketch | undefined {
|
|
133
|
+
return value === undefined || isPreviewSketch(value);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
function isLayoutAside(value: unknown): value is PreviewLayoutAside {
|
|
137
|
+
return (
|
|
138
|
+
isPreviewSketch(value) &&
|
|
139
|
+
isRecord(value) &&
|
|
140
|
+
isNumber(value.width) &&
|
|
141
|
+
Number.isFinite(value.width) &&
|
|
142
|
+
ASIDE_SIDES.has(value.side)
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
function isCustomLayout(value: unknown): value is PreviewCustomLayout {
|
|
147
|
+
return (
|
|
148
|
+
isRecord(value) &&
|
|
149
|
+
value.type === "custom" &&
|
|
150
|
+
isString(value.id) &&
|
|
151
|
+
isString(value.title) &&
|
|
152
|
+
isBoolean(value.dashboard) &&
|
|
153
|
+
isOptionalSketch(value.header) &&
|
|
154
|
+
(value.aside === undefined || isLayoutAside(value.aside)) &&
|
|
155
|
+
isOptionalSketch(value.footer)
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
function isBuiltInLayout(value: unknown): value is PreviewBuiltInLayout {
|
|
92
160
|
return (
|
|
93
161
|
isRecord(value) &&
|
|
94
162
|
isLayoutType(value.type) &&
|
|
@@ -96,6 +164,16 @@ export function isPreviewPageLayout(
|
|
|
96
164
|
);
|
|
97
165
|
}
|
|
98
166
|
|
|
167
|
+
/**
|
|
168
|
+
* Whether `value` is a layout a page is drawn in: one of the DMS's, each
|
|
169
|
+
* option a boolean the layouts take, or a custom layout, each region a sketch.
|
|
170
|
+
*/
|
|
171
|
+
export function isPreviewPageLayout(
|
|
172
|
+
value: unknown,
|
|
173
|
+
): value is PreviewPageLayout {
|
|
174
|
+
return isBuiltInLayout(value) || isCustomLayout(value);
|
|
175
|
+
}
|
|
176
|
+
|
|
99
177
|
/** Whether `value` is absent, or a layout a page is drawn in. */
|
|
100
178
|
export function isOptionalPreviewPageLayout(
|
|
101
179
|
value: unknown,
|
|
@@ -123,6 +201,7 @@ export function isOptionalStringRecord(
|
|
|
123
201
|
export function previewFrameOf(
|
|
124
202
|
layout: PreviewPageLayout | undefined,
|
|
125
203
|
): PreviewFrame {
|
|
204
|
+
if (layout?.type === "custom") return customFrameOf(layout);
|
|
126
205
|
const options = layout?.options ?? {};
|
|
127
206
|
const fillHeight = options.fillHeight ?? false;
|
|
128
207
|
if (layout?.type === "empty") {
|
|
@@ -147,3 +226,26 @@ export function previewFrameOf(
|
|
|
147
226
|
footer: false,
|
|
148
227
|
};
|
|
149
228
|
}
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* What the preview draws around a page in a custom layout: the dashboard's
|
|
232
|
+
* sidebar, top bar and page header when the layout keeps the dashboard, none
|
|
233
|
+
* of them and no logo or footer when it does not, and the layout's sketches,
|
|
234
|
+
* the blocks spanning the panel either way.
|
|
235
|
+
*/
|
|
236
|
+
function customFrameOf(layout: PreviewCustomLayout): PreviewFrame {
|
|
237
|
+
return {
|
|
238
|
+
dashboard: layout.dashboard,
|
|
239
|
+
header: layout.dashboard,
|
|
240
|
+
fullWidth: true,
|
|
241
|
+
settings: false,
|
|
242
|
+
fillHeight: false,
|
|
243
|
+
brand: false,
|
|
244
|
+
footer: false,
|
|
245
|
+
custom: {
|
|
246
|
+
...(layout.header && { header: layout.header }),
|
|
247
|
+
...(layout.aside && { aside: layout.aside }),
|
|
248
|
+
...(layout.footer && { footer: layout.footer }),
|
|
249
|
+
},
|
|
250
|
+
};
|
|
251
|
+
}
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
FIXTURES_ONLY_QUERY,
|
|
3
|
+
MOCKUP_PAGE_FRAME_QUERY,
|
|
4
|
+
} from "./previewFixturesOnly";
|
|
2
5
|
|
|
3
6
|
/** The query `/dms-preview` reads its first state from. */
|
|
4
7
|
export const STATE_QUERY = "state";
|
|
@@ -7,6 +10,7 @@ export const STATE_QUERY = "state";
|
|
|
7
10
|
const PREVIEW_QUERY_KEYS: ReadonlySet<string> = new Set([
|
|
8
11
|
STATE_QUERY,
|
|
9
12
|
FIXTURES_ONLY_QUERY,
|
|
13
|
+
MOCKUP_PAGE_FRAME_QUERY,
|
|
10
14
|
]);
|
|
11
15
|
|
|
12
16
|
type QueryValue = string | null | readonly (string | null)[];
|
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
import type { JsonValue } from "../../../../dms-core/app/types/json";
|
|
2
|
+
import { isNumber, isString } from "../../../../dms-core/app/utils/type-check";
|
|
3
|
+
import { isJsonObject, type JsonObject } from "./json";
|
|
4
|
+
|
|
5
|
+
/** The query key prefix of a column filter: `filter_<field>=<mode>:<value>`. */
|
|
6
|
+
const FILTER_PREFIX = "filter_";
|
|
7
|
+
const LIST_SEPARATOR = ",";
|
|
8
|
+
const ISO_DAY = /^\d{4}-\d{2}-\d{2}/;
|
|
9
|
+
|
|
10
|
+
/** The keys a row's id is read from, in order. */
|
|
11
|
+
const ROW_ID_KEYS = ["_id", "id"] as const;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The row field a mockup table in archive mode reads a row's archived state
|
|
15
|
+
* from: the member `@ArchiveField` decorates in the DMS docs and playground.
|
|
16
|
+
*/
|
|
17
|
+
const ARCHIVE_FIELD = "isArchived";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* One column filter of a list query, as a table sends it for a tab, a quick
|
|
21
|
+
* filter, a column filter or a saved view. A table repeats the key once per
|
|
22
|
+
* filter on a field, and a row must pass them all.
|
|
23
|
+
*/
|
|
24
|
+
export interface ColumnFilter {
|
|
25
|
+
field: string;
|
|
26
|
+
mode: string;
|
|
27
|
+
value: string;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** The list query a table sends its `fetchUrl`. */
|
|
31
|
+
export interface RowsQuery {
|
|
32
|
+
offset: number;
|
|
33
|
+
limit?: number;
|
|
34
|
+
/** Trimmed and lower-cased. */
|
|
35
|
+
search: string;
|
|
36
|
+
sortKey?: string;
|
|
37
|
+
sortDirection: "asc" | "desc";
|
|
38
|
+
/** Set by a table in archive mode: which side of the archive toggle it lists. */
|
|
39
|
+
showArchived?: boolean;
|
|
40
|
+
/** The values of the sorted field, in the order its groups are listed in. */
|
|
41
|
+
groupOrder?: GroupValue[];
|
|
42
|
+
filters: ColumnFilter[];
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** A value a group order lists. */
|
|
46
|
+
type GroupValue = string | number | boolean;
|
|
47
|
+
|
|
48
|
+
function isGroupValue(value: unknown): value is GroupValue {
|
|
49
|
+
return (
|
|
50
|
+
typeof value === "string" ||
|
|
51
|
+
typeof value === "number" ||
|
|
52
|
+
typeof value === "boolean"
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** One page of rows, as `TableView.fromSource` reads it. */
|
|
57
|
+
export interface RowsPage {
|
|
58
|
+
results: JsonObject[];
|
|
59
|
+
total: number;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/** Whether a cell passes a filter's value. */
|
|
63
|
+
type Test = (cell: JsonValue | undefined, value: string) => boolean;
|
|
64
|
+
|
|
65
|
+
function isScalar(
|
|
66
|
+
cell: JsonValue | undefined,
|
|
67
|
+
): cell is string | number | boolean {
|
|
68
|
+
return (
|
|
69
|
+
typeof cell === "string" ||
|
|
70
|
+
typeof cell === "number" ||
|
|
71
|
+
typeof cell === "boolean"
|
|
72
|
+
);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The values a cell holds, as text: its scalar, or each scalar entry of a list. */
|
|
76
|
+
function cellTexts(cell: JsonValue | undefined): string[] {
|
|
77
|
+
if (Array.isArray(cell)) return cell.flatMap(cellTexts);
|
|
78
|
+
return isScalar(cell) ? [String(cell)] : [];
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
function isNumeric(text: string): boolean {
|
|
82
|
+
return text.trim() !== "" && Number.isFinite(Number(text));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** Where `text` sits on a line: a number, or an ISO date as its epoch. */
|
|
86
|
+
function positionOf(text: string): number | undefined {
|
|
87
|
+
const trimmed = text.trim();
|
|
88
|
+
if (isNumeric(trimmed)) return Number(trimmed);
|
|
89
|
+
if (!ISO_DAY.test(trimmed)) return undefined;
|
|
90
|
+
const epoch = Date.parse(trimmed);
|
|
91
|
+
return Number.isNaN(epoch) ? undefined : epoch;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function sameValue(text: string, wanted: string): boolean {
|
|
95
|
+
if (text === wanted) return true;
|
|
96
|
+
return (
|
|
97
|
+
isNumeric(text) && isNumeric(wanted) && Number(text) === Number(wanted)
|
|
98
|
+
);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** Whether the cell, or one of its entries, equals the value or one of its comma-separated values. */
|
|
102
|
+
function isAny(cell: JsonValue | undefined, value: string): boolean {
|
|
103
|
+
const wanted = [value, ...value.split(LIST_SEPARATOR)];
|
|
104
|
+
return cellTexts(cell).some((text) =>
|
|
105
|
+
wanted.some((candidate) => sameValue(text, candidate)),
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function containsText(cell: JsonValue | undefined, value: string): boolean {
|
|
110
|
+
const needle = value.toLowerCase();
|
|
111
|
+
return cellTexts(cell).some((text) => text.toLowerCase().includes(needle));
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/** The positions of the cell's values on a line; a value off the line has none. */
|
|
115
|
+
function positionsOf(cell: JsonValue | undefined): number[] {
|
|
116
|
+
return cellTexts(cell).flatMap((text) => {
|
|
117
|
+
const position = positionOf(text);
|
|
118
|
+
return position === undefined ? [] : [position];
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
function ordered(accept: (here: number, bound: number) => boolean): Test {
|
|
123
|
+
return (cell, value) => {
|
|
124
|
+
const bound = positionOf(value);
|
|
125
|
+
return (
|
|
126
|
+
bound !== undefined &&
|
|
127
|
+
positionsOf(cell).some((here) => accept(here, bound))
|
|
128
|
+
);
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function isBetween(cell: JsonValue | undefined, value: string): boolean {
|
|
133
|
+
const bounds = value.split(LIST_SEPARATOR).map(positionOf);
|
|
134
|
+
const [low, high] = bounds;
|
|
135
|
+
if (bounds.length !== 2 || low === undefined || high === undefined) {
|
|
136
|
+
return false;
|
|
137
|
+
}
|
|
138
|
+
return positionsOf(cell).some((here) => here >= low && here <= high);
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
function isEmpty(cell: JsonValue | undefined): boolean {
|
|
142
|
+
return (
|
|
143
|
+
cell === undefined ||
|
|
144
|
+
cell === null ||
|
|
145
|
+
cell === "" ||
|
|
146
|
+
(Array.isArray(cell) && cell.length === 0)
|
|
147
|
+
);
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
/**
|
|
151
|
+
* The compare modes a table sends, as the DMS registers them
|
|
152
|
+
* (`DefaultDataCompareTypes`). `is` and `include` also read a quick filter's
|
|
153
|
+
* comma-separated values as any of them, and a list cell matches when one of
|
|
154
|
+
* its entries does.
|
|
155
|
+
*/
|
|
156
|
+
const MODES: ReadonlyMap<string, Test> = new Map<string, Test>([
|
|
157
|
+
["is", isAny],
|
|
158
|
+
["is_not", (cell, value) => !isAny(cell, value)],
|
|
159
|
+
["include", isAny],
|
|
160
|
+
["exclude", (cell, value) => !isAny(cell, value)],
|
|
161
|
+
["contains", containsText],
|
|
162
|
+
["not_contains", (cell, value) => !containsText(cell, value)],
|
|
163
|
+
["array_contains_string", containsText],
|
|
164
|
+
["greater_than", ordered((here, bound) => here > bound)],
|
|
165
|
+
["less_than", ordered((here, bound) => here < bound)],
|
|
166
|
+
["greater_than_or_equal_to", ordered((here, bound) => here >= bound)],
|
|
167
|
+
["less_than_or_equal_to", ordered((here, bound) => here <= bound)],
|
|
168
|
+
["is_between", isBetween],
|
|
169
|
+
["is_empty", isEmpty],
|
|
170
|
+
["is_not_empty", (cell) => !isEmpty(cell)],
|
|
171
|
+
]);
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* The column filters of a list query, in the order they were sent. A filter
|
|
175
|
+
* with no field, or of a mode no data controller has, is left out, so it
|
|
176
|
+
* keeps every row.
|
|
177
|
+
*/
|
|
178
|
+
function parseColumnFilters(params: URLSearchParams): ColumnFilter[] {
|
|
179
|
+
return [...params.entries()].flatMap(([key, raw]): ColumnFilter[] => {
|
|
180
|
+
if (!key.startsWith(FILTER_PREFIX) || key === FILTER_PREFIX) return [];
|
|
181
|
+
const separator = raw.indexOf(":");
|
|
182
|
+
const mode = separator < 0 ? raw : raw.slice(0, separator);
|
|
183
|
+
if (!MODES.has(mode)) return [];
|
|
184
|
+
return [
|
|
185
|
+
{
|
|
186
|
+
field: key.slice(FILTER_PREFIX.length),
|
|
187
|
+
mode,
|
|
188
|
+
value: separator < 0 ? "" : raw.slice(separator + 1),
|
|
189
|
+
},
|
|
190
|
+
];
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
function passesFilters(
|
|
195
|
+
row: JsonObject,
|
|
196
|
+
filters: readonly ColumnFilter[],
|
|
197
|
+
): boolean {
|
|
198
|
+
return filters.every(({ field, mode, value }) => {
|
|
199
|
+
const cell = Object.hasOwn(row, field) ? row[field] : undefined;
|
|
200
|
+
return MODES.get(mode)?.(cell, value) ?? true;
|
|
201
|
+
});
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** `raw` as a whole number of at least `min`, or undefined when it is none. */
|
|
205
|
+
function integerAtLeast(raw: string | null, min: number): number | undefined {
|
|
206
|
+
if (raw === null) return undefined;
|
|
207
|
+
const value = Number(raw);
|
|
208
|
+
return Number.isInteger(value) && value >= min ? value : undefined;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
/** Reads a list query; a malformed parameter falls back to its default. */
|
|
212
|
+
export function parseRowsQuery(params: URLSearchParams): RowsQuery {
|
|
213
|
+
const showArchived = params.get("showArchived");
|
|
214
|
+
const query: RowsQuery = {
|
|
215
|
+
offset: integerAtLeast(params.get("offset"), 0) ?? 0,
|
|
216
|
+
search: (params.get("search") ?? "").trim().toLowerCase(),
|
|
217
|
+
sortDirection: params.get("sortDirection") === "desc" ? "desc" : "asc",
|
|
218
|
+
filters: parseColumnFilters(params),
|
|
219
|
+
};
|
|
220
|
+
const limit = integerAtLeast(params.get("limit"), 1);
|
|
221
|
+
if (limit !== undefined) query.limit = limit;
|
|
222
|
+
const sortKey = params.get("sortKey");
|
|
223
|
+
if (sortKey !== null) query.sortKey = sortKey;
|
|
224
|
+
if (showArchived === "true" || showArchived === "false") {
|
|
225
|
+
query.showArchived = showArchived === "true";
|
|
226
|
+
}
|
|
227
|
+
const groupOrder = readGroupOrder(params.get("groupOrder"));
|
|
228
|
+
if (groupOrder) query.groupOrder = groupOrder;
|
|
229
|
+
return query;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
/** The most values a group order lists: the list route reads one group at a time. */
|
|
233
|
+
const MAX_GROUP_ORDER_VALUES = 50;
|
|
234
|
+
|
|
235
|
+
/** A list query's `groupOrder`, or undefined when it is no JSON list of 1 to {@link MAX_GROUP_ORDER_VALUES} scalars. */
|
|
236
|
+
function readGroupOrder(raw: string | null): GroupValue[] | undefined {
|
|
237
|
+
if (raw === null) return undefined;
|
|
238
|
+
try {
|
|
239
|
+
const parsed: unknown = JSON.parse(raw);
|
|
240
|
+
return Array.isArray(parsed) &&
|
|
241
|
+
parsed.length >= 1 &&
|
|
242
|
+
parsed.length <= MAX_GROUP_ORDER_VALUES &&
|
|
243
|
+
parsed.every(isGroupValue)
|
|
244
|
+
? parsed
|
|
245
|
+
: undefined;
|
|
246
|
+
} catch {
|
|
247
|
+
return undefined;
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
/** The rows of a fixture, or undefined when it is not an array of objects. */
|
|
252
|
+
export function parseRows(fixture: JsonValue): JsonObject[] | undefined {
|
|
253
|
+
return Array.isArray(fixture) && fixture.every(isJsonObject)
|
|
254
|
+
? fixture
|
|
255
|
+
: undefined;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
/** The id of `row` read at `key` when given, else its `_id`, else its `id`, as text. */
|
|
259
|
+
function rowIdAt(row: JsonObject, key?: string): string | undefined {
|
|
260
|
+
for (const field of key === undefined ? ROW_ID_KEYS : [key]) {
|
|
261
|
+
const value = Object.hasOwn(row, field) ? row[field] : undefined;
|
|
262
|
+
if (isString(value) || isNumber(value)) return String(value);
|
|
263
|
+
}
|
|
264
|
+
return undefined;
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/** The row of `rows` whose id is `id`, read at `key` when given. */
|
|
268
|
+
export function findRow(
|
|
269
|
+
rows: readonly JsonObject[],
|
|
270
|
+
id: string,
|
|
271
|
+
key?: string,
|
|
272
|
+
): JsonObject | undefined {
|
|
273
|
+
return rows.find((row) => rowIdAt(row, key) === id);
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
/** How many of `count` rows a fixture without an archive field gives as archived: a quarter, at least one, never all. */
|
|
277
|
+
function archivedCount(count: number): number {
|
|
278
|
+
return Math.min(Math.ceil(count / 4), count - 1);
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* The rows with their archived state at {@link ARCHIVE_FIELD}: as written when
|
|
283
|
+
* a row writes it, else made up, the last quarter of the rows archived, so a
|
|
284
|
+
* table in archive mode has rows on both sides of its toggle.
|
|
285
|
+
*/
|
|
286
|
+
function withArchiveField(rows: JsonObject[]): JsonObject[] {
|
|
287
|
+
if (rows.some((row) => Object.hasOwn(row, ARCHIVE_FIELD))) return rows;
|
|
288
|
+
const firstArchived = rows.length - archivedCount(rows.length);
|
|
289
|
+
return rows.map((row, index) => ({
|
|
290
|
+
...row,
|
|
291
|
+
[ARCHIVE_FIELD]: index >= firstArchived,
|
|
292
|
+
}));
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
/** The rows on one side of the archive toggle: the archived ones, or the others. */
|
|
296
|
+
function archiveSide(rows: JsonObject[], archived: boolean): JsonObject[] {
|
|
297
|
+
return withArchiveField(rows).filter(
|
|
298
|
+
(row) => (row[ARCHIVE_FIELD] === true) === archived,
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
|
|
302
|
+
/**
|
|
303
|
+
* Where a value sorts: numbers, and text that reads as one, by value; other
|
|
304
|
+
* text as people read it; anything else by its JSON text. Each class sorts
|
|
305
|
+
* before the next, so the order is total over mixed values.
|
|
306
|
+
*/
|
|
307
|
+
type SortKey =
|
|
308
|
+
| { rank: 0; value: number }
|
|
309
|
+
| { rank: 1; text: string }
|
|
310
|
+
| { rank: 2; text: string };
|
|
311
|
+
|
|
312
|
+
function sortKeyOf(value: JsonValue): SortKey {
|
|
313
|
+
if (isNumber(value)) return { rank: 0, value };
|
|
314
|
+
if (!isString(value)) return { rank: 2, text: JSON.stringify(value) };
|
|
315
|
+
const numeric = Number(value);
|
|
316
|
+
return value.trim() !== "" && Number.isFinite(numeric)
|
|
317
|
+
? { rank: 0, value: numeric }
|
|
318
|
+
: { rank: 1, text: value };
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
const TEXT_ORDER = new Intl.Collator(undefined, {
|
|
322
|
+
numeric: true,
|
|
323
|
+
sensitivity: "base",
|
|
324
|
+
});
|
|
325
|
+
|
|
326
|
+
function compareValues(left: JsonValue, right: JsonValue): number {
|
|
327
|
+
const a = sortKeyOf(left);
|
|
328
|
+
const b = sortKeyOf(right);
|
|
329
|
+
if (a.rank !== b.rank) return a.rank - b.rank;
|
|
330
|
+
if (a.rank === 0 && b.rank === 0) return a.value - b.value;
|
|
331
|
+
if (a.rank !== 0 && b.rank !== 0) return TEXT_ORDER.compare(a.text, b.text);
|
|
332
|
+
return 0;
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
/** Sorts in `direction`, rows missing the value last either way. */
|
|
336
|
+
function compareRows(
|
|
337
|
+
left: JsonValue | undefined,
|
|
338
|
+
right: JsonValue | undefined,
|
|
339
|
+
direction: number,
|
|
340
|
+
): number {
|
|
341
|
+
const leftMissing = left === undefined || left === null;
|
|
342
|
+
const rightMissing = right === undefined || right === null;
|
|
343
|
+
if (leftMissing || rightMissing) {
|
|
344
|
+
return Number(leftMissing) - Number(rightMissing);
|
|
345
|
+
}
|
|
346
|
+
return compareValues(left, right) * direction;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
/**
|
|
350
|
+
* Where a value's group stands in a list query's `groupOrder`, reversed on a
|
|
351
|
+
* descending sort; a value it leaves out, or none, after every listed one.
|
|
352
|
+
*/
|
|
353
|
+
function groupRank(
|
|
354
|
+
order: RowsQuery["groupOrder"],
|
|
355
|
+
direction: number,
|
|
356
|
+
): (value: JsonValue | undefined) => number {
|
|
357
|
+
if (!order) return () => 0;
|
|
358
|
+
const listed = direction < 0 ? [...order].reverse() : order;
|
|
359
|
+
return (value) => {
|
|
360
|
+
const rank = listed.findIndex((entry) => entry === value);
|
|
361
|
+
return rank < 0 ? listed.length : rank;
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
/**
|
|
366
|
+
* Filters, searches, sorts and pages `rows` as the list query asks. A table in
|
|
367
|
+
* archive mode sends `showArchived`: it lists the archived rows, or the others,
|
|
368
|
+
* each row carrying its archived state.
|
|
369
|
+
*/
|
|
370
|
+
export function listRows(rows: JsonObject[], query: RowsQuery): RowsPage {
|
|
371
|
+
const sided =
|
|
372
|
+
query.showArchived === undefined
|
|
373
|
+
? rows
|
|
374
|
+
: archiveSide(rows, query.showArchived);
|
|
375
|
+
const found = sided.filter(
|
|
376
|
+
(row) =>
|
|
377
|
+
passesFilters(row, query.filters) &&
|
|
378
|
+
(!query.search ||
|
|
379
|
+
Object.values(row).some(
|
|
380
|
+
(value) =>
|
|
381
|
+
isScalar(value) &&
|
|
382
|
+
String(value).toLowerCase().includes(query.search),
|
|
383
|
+
)),
|
|
384
|
+
);
|
|
385
|
+
const { sortKey, groupOrder } = query;
|
|
386
|
+
if (sortKey) {
|
|
387
|
+
const direction = query.sortDirection === "desc" ? -1 : 1;
|
|
388
|
+
const valueOf = (row: JsonObject) =>
|
|
389
|
+
Object.hasOwn(row, sortKey) ? row[sortKey] : undefined;
|
|
390
|
+
const groupOf = groupRank(groupOrder, direction);
|
|
391
|
+
found.sort(
|
|
392
|
+
(a, b) =>
|
|
393
|
+
groupOf(valueOf(a)) - groupOf(valueOf(b)) ||
|
|
394
|
+
compareRows(valueOf(a), valueOf(b), direction),
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
const end =
|
|
398
|
+
query.limit === undefined ? undefined : query.offset + query.limit;
|
|
399
|
+
return { results: found.slice(query.offset, end), total: found.length };
|
|
400
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { isObject, isString } from "../../../../dms-core/app/utils/type-check";
|
|
2
|
+
|
|
3
|
+
/** Whether `value` is a plain record: an object that is neither `null` nor a list. */
|
|
4
|
+
export function isRecord(
|
|
5
|
+
value: Parameters<typeof isObject>[0],
|
|
6
|
+
): value is Record<string, unknown> {
|
|
7
|
+
return isObject(value) && value !== null && !Array.isArray(value);
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/** Whether `value` is absent or a string. */
|
|
11
|
+
export function isOptionalString(
|
|
12
|
+
value: Parameters<typeof isString>[0],
|
|
13
|
+
): boolean {
|
|
14
|
+
return value === undefined || isString(value);
|
|
15
|
+
}
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
import type { PreviewSketch } from "./blockPreview";
|
|
2
2
|
import { MOCKUP_VIEWER_PATH } from "./mockupLinks";
|
|
3
|
+
import { isString } from "../../../../dms-core/app/utils/type-check";
|
|
4
|
+
import { isRecord } from "./recordGuards";
|
|
5
|
+
|
|
6
|
+
/** The type of the message {@link SKETCH_LINK_RELAY} posts. */
|
|
7
|
+
const SKETCH_LINK_MESSAGE = "dms-sketch-link";
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The one script a sketch frame runs, and only a sketch linking to a page of
|
|
11
|
+
* the mockup: a click on such a link posts its URL to the page holding the
|
|
12
|
+
* frame, which opens that page of the mockup ({@link sketchLinkHref}), in
|
|
13
|
+
* place of loading the whole dashboard again.
|
|
14
|
+
*/
|
|
15
|
+
export const SKETCH_LINK_RELAY = `document.addEventListener("click",function(e){var a=e.target instanceof Element&&e.target.closest("a[target=_top]");if(!a)return;e.preventDefault();parent.postMessage({type:"${SKETCH_LINK_MESSAGE}",href:a.href},"*")})`;
|
|
16
|
+
|
|
17
|
+
/** The CSP source of {@link SKETCH_LINK_RELAY}: its SHA-256, base64. */
|
|
18
|
+
export const SKETCH_LINK_RELAY_SOURCE =
|
|
19
|
+
"'sha256-6lqeH4ElBGXp0HTSjcu3IIz4LMoCGtwgjt4UkUBhX2I='";
|
|
3
20
|
|
|
4
21
|
/**
|
|
5
22
|
* How a sketch is drawn. The frame is the security boundary: a `sandbox`
|
|
6
|
-
* with
|
|
23
|
+
* with an opaque origin, no forms, popups or top navigation, and scripts
|
|
7
24
|
* only for a sketch linking to a page ({@link sketchSandbox}), and a CSP that
|
|
8
|
-
*
|
|
25
|
+
* runs no script but {@link SKETCH_LINK_RELAY} and loads nothing but inline
|
|
26
|
+
* styles and `data:` images and fonts.
|
|
9
27
|
*/
|
|
10
|
-
export const SKETCH_CSP =
|
|
11
|
-
"default-src 'none'; style-src 'unsafe-inline'; img-src data:; font-src data:";
|
|
28
|
+
export const SKETCH_CSP = `default-src 'none'; script-src ${SKETCH_LINK_RELAY_SOURCE}; style-src 'unsafe-inline'; img-src data:; font-src data:`;
|
|
12
29
|
|
|
13
30
|
/**
|
|
14
31
|
* A link to a page of the mockup as the compiler writes it in a sketch's
|
|
@@ -31,13 +48,22 @@ export interface SketchLinkContext {
|
|
|
31
48
|
|
|
32
49
|
/**
|
|
33
50
|
* The frame's `sandbox`: empty, except for a sketch linking to a page of the
|
|
34
|
-
* mockup, which
|
|
35
|
-
*
|
|
51
|
+
* mockup, which runs the scripts its CSP admits, {@link SKETCH_LINK_RELAY}
|
|
52
|
+
* alone. Never top navigation, never the dashboard's origin.
|
|
36
53
|
*/
|
|
37
54
|
export function sketchSandbox(html: string): string {
|
|
38
|
-
return HOLDS_PAGE_LINK.test(html)
|
|
39
|
-
|
|
40
|
-
|
|
55
|
+
return HOLDS_PAGE_LINK.test(html) ? "allow-scripts" : "";
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** The URL of the link a message of {@link SKETCH_LINK_RELAY} says was clicked. */
|
|
59
|
+
export function sketchLinkHref(
|
|
60
|
+
data: Parameters<typeof isRecord>[0],
|
|
61
|
+
): string | undefined {
|
|
62
|
+
return isRecord(data) &&
|
|
63
|
+
data.type === SKETCH_LINK_MESSAGE &&
|
|
64
|
+
isString(data.href)
|
|
65
|
+
? data.href
|
|
66
|
+
: undefined;
|
|
41
67
|
}
|
|
42
68
|
|
|
43
69
|
/**
|
|
@@ -203,7 +229,8 @@ export function currentSketchScheme(): SketchScheme {
|
|
|
203
229
|
* `#anchor` resolve inside the frame's own `about:srcdoc` document, where a
|
|
204
230
|
* srcdoc document would otherwise resolve it against the dashboard's URL and
|
|
205
231
|
* load the dashboard into the frame. With `links`, the sketch's links to the
|
|
206
|
-
* pages of the mockup are drawn absolute ({@link resolveSketchLinks}).
|
|
232
|
+
* pages of the mockup are drawn absolute ({@link resolveSketchLinks}). A
|
|
233
|
+
* sketch holding such a link carries {@link SKETCH_LINK_RELAY}.
|
|
207
234
|
*/
|
|
208
235
|
export function buildSketchDocument(
|
|
209
236
|
sketch: PreviewSketch,
|
|
@@ -217,6 +244,9 @@ export function buildSketchDocument(
|
|
|
217
244
|
'<meta charset="utf-8">',
|
|
218
245
|
`<style>${tokensCss}\n${SKETCH_BASE_CSS}</style>`,
|
|
219
246
|
`<style>${sketch.css ?? ""}</style>`,
|
|
247
|
+
HOLDS_PAGE_LINK.test(sketch.html)
|
|
248
|
+
? `<script>${SKETCH_LINK_RELAY}</script>`
|
|
249
|
+
: "",
|
|
220
250
|
`</head><body>${links ? resolveSketchLinks(sketch.html, links) : sketch.html}</body></html>`,
|
|
221
251
|
].join("");
|
|
222
252
|
}
|