@cosmicdrift/kumiko-renderer 0.413.1 → 0.415.0
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/dist/app/action-form-support.js +4 -0
- package/dist/app/content-previews.d.ts +39 -0
- package/dist/app/content-previews.js +28 -0
- package/dist/app/entity-edit-screen.js +2 -5
- package/dist/app/entity-list-screen.js +42 -59
- package/dist/app/form-schema.d.ts +1 -0
- package/dist/app/form-schema.js +24 -0
- package/dist/app/list-facets.d.ts +1 -0
- package/dist/app/list-facets.js +10 -1
- package/dist/app/list-sort-options.d.ts +4 -0
- package/dist/app/list-sort-options.js +11 -0
- package/dist/app/named-filter-facet.d.ts +16 -3
- package/dist/app/named-filter-facet.js +97 -5
- package/dist/app/projection-detail-body.d.ts +2 -4
- package/dist/app/projection-detail-body.js +7 -1
- package/dist/app/projection-detail-guidance-data.d.ts +7 -0
- package/dist/app/projection-detail-guidance-data.js +103 -0
- package/dist/app/projection-detail-guidance.d.ts +13 -0
- package/dist/app/projection-detail-guidance.js +197 -0
- package/dist/app/projection-detail-header-model.d.ts +1 -3
- package/dist/app/projection-detail-header-model.js +4 -8
- package/dist/app/projection-detail-header-region.d.ts +2 -1
- package/dist/app/projection-detail-header-region.js +63 -23
- package/dist/app/projection-detail-header.d.ts +6 -1
- package/dist/app/projection-detail-header.js +76 -18
- package/dist/app/projection-detail-navigation.d.ts +2 -0
- package/dist/app/projection-detail-navigation.js +13 -3
- package/dist/app/projection-detail-states.d.ts +3 -3
- package/dist/app/projection-list-body.js +4 -2
- package/dist/app/projection-list-render.js +3 -1
- package/dist/app/projection-list-shim.d.ts +4 -1
- package/dist/app/projection-list-shim.js +35 -8
- package/dist/app/reference-link.d.ts +3 -2
- package/dist/app/reference-link.js +19 -4
- package/dist/app/row-actions.js +3 -3
- package/dist/app/screen-access.d.ts +4 -0
- package/dist/app/screen-access.js +18 -0
- package/dist/app/screen-shared.js +3 -1
- package/dist/app/unique-label-keys.d.ts +1 -0
- package/dist/app/unique-label-keys.js +9 -0
- package/dist/app/use-entity-list-payload.d.ts +26 -0
- package/dist/app/use-entity-list-payload.js +59 -0
- package/dist/app/use-entity-range-facets.js +2 -3
- package/dist/app/use-facet-counts.d.ts +5 -0
- package/dist/app/use-facet-counts.js +7 -0
- package/dist/app/use-list-summary-row.d.ts +10 -0
- package/dist/app/use-list-summary-row.js +33 -0
- package/dist/app/use-named-filter-queue.d.ts +20 -0
- package/dist/app/use-named-filter-queue.js +9 -0
- package/dist/app/use-projection-detail-actions.d.ts +5 -4
- package/dist/app/use-projection-detail-actions.js +42 -1
- package/dist/app/use-projection-list-data.d.ts +5 -0
- package/dist/app/use-projection-list-data.js +35 -6
- package/dist/app/use-projection-list-query.d.ts +2 -0
- package/dist/app/use-projection-list-query.js +29 -16
- package/dist/app/use-related-list-tab-counts.js +5 -1
- package/dist/app/use-row-decoration.d.ts +13 -0
- package/dist/app/use-row-decoration.js +103 -0
- package/dist/app/use-screen-list-rows.d.ts +4 -1
- package/dist/app/use-screen-list-rows.js +14 -5
- package/dist/app/use-screen-list-table.d.ts +3 -1
- package/dist/app/use-screen-list-table.js +10 -1
- package/dist/app/write-failed-error.d.ts +1 -0
- package/dist/app/write-failed-error.js +10 -0
- package/dist/card-options.d.ts +25 -0
- package/dist/card-options.js +1 -0
- package/dist/compact-tap-classes.d.ts +1 -0
- package/dist/compact-tap-classes.js +3 -0
- package/dist/components/embedded-list-field.js +13 -12
- package/dist/components/list-empty-state.d.ts +13 -1
- package/dist/components/list-empty-state.js +20 -1
- package/dist/components/list-group-page-bridges.d.ts +1 -1
- package/dist/components/list-group-page-bridges.js +2 -2
- package/dist/components/related-list-section.js +4 -22
- package/dist/components/render-edit-action-button.d.ts +3 -1
- package/dist/components/render-edit-action-button.js +5 -3
- package/dist/components/render-edit-render-model.d.ts +2 -2
- package/dist/components/render-edit-types.d.ts +4 -2
- package/dist/components/render-edit.js +3 -1
- package/dist/components/render-list-hint-columns.d.ts +9 -0
- package/dist/components/render-list-hint-columns.js +87 -0
- package/dist/components/render-list-reference-columns.js +4 -2
- package/dist/components/render-list-row-tone.d.ts +3 -0
- package/dist/components/render-list-row-tone.js +10 -0
- package/dist/components/render-list-table-props.d.ts +9 -1
- package/dist/components/render-list-table-props.js +4 -1
- package/dist/components/render-list-toolbar-action.d.ts +1 -2
- package/dist/components/render-list-toolbar-model.d.ts +4 -1
- package/dist/components/render-list-toolbar-model.js +21 -6
- package/dist/components/render-list-toolbar.d.ts +3 -2
- package/dist/components/render-list-toolbar.js +8 -6
- package/dist/components/render-list-types.d.ts +6 -1
- package/dist/components/render-list.js +26 -7
- package/dist/components/use-render-edit-controlled-sync.js +3 -5
- package/dist/components/use-render-edit-draft-save.js +7 -9
- package/dist/components/use-render-edit-schema.d.ts +3 -0
- package/dist/components/use-render-edit-schema.js +15 -0
- package/dist/components/use-render-edit-state.d.ts +1 -0
- package/dist/components/use-render-edit-state.js +4 -1
- package/dist/components/use-render-edit-steps.js +2 -3
- package/dist/components/use-render-list-columns.d.ts +3 -1
- package/dist/components/use-render-list-columns.js +22 -10
- package/dist/context/screen-focus-context.d.ts +14 -0
- package/dist/context/screen-focus-context.js +28 -0
- package/dist/data-table-facet-types.d.ts +6 -0
- package/dist/data-table-view-types.d.ts +20 -1
- package/dist/headless/form/form-controller.js +3 -1
- package/dist/headless/form/zod-bridge.d.ts +7 -1
- package/dist/headless/form/zod-bridge.js +10 -0
- package/dist/headless/index.d.ts +2 -1
- package/dist/headless/index.js +1 -0
- package/dist/headless/pwa-service-worker-meta.d.ts +4 -0
- package/dist/headless/pwa-service-worker-meta.js +13 -0
- package/dist/headless/view-model/index.d.ts +1 -1
- package/dist/headless/view-model/list-file-display.js +3 -2
- package/dist/headless/view-model/list.js +16 -0
- package/dist/headless/view-model/types.d.ts +37 -0
- package/dist/hooks/list-column-layout.js +2 -1
- package/dist/hooks/list-server-groups.js +14 -1
- package/dist/hooks/list-state-schema.d.ts +1 -0
- package/dist/hooks/list-state-schema.js +9 -1
- package/dist/hooks/use-debounced-value.d.ts +1 -0
- package/dist/hooks/use-debounced-value.js +11 -0
- package/dist/hooks/use-list-aggregates.d.ts +5 -1
- package/dist/hooks/use-list-aggregates.js +9 -5
- package/dist/hooks/use-list-table.d.ts +2 -1
- package/dist/hooks/use-list-table.js +3 -9
- package/dist/hooks/use-list-url-state.d.ts +2 -0
- package/dist/hooks/use-list-url-state.js +12 -4
- package/dist/hooks/use-list-view-state.js +23 -3
- package/dist/hooks/use-reference-lookup.js +7 -2
- package/dist/hooks/use-remembered-list-params.d.ts +6 -2
- package/dist/hooks/use-remembered-list-params.js +18 -3
- package/dist/hooks/use-store.js +0 -1
- package/dist/i18n-defaults.js +39 -3
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -1
- package/dist/live/dispatcher-live.js +2 -0
- package/dist/metric-types.d.ts +4 -0
- package/dist/primitives-record-guidance.d.ts +55 -0
- package/dist/primitives-record-guidance.js +1 -0
- package/dist/primitives.d.ts +47 -54
- package/dist/server-clock.d.ts +6 -0
- package/dist/server-clock.js +20 -0
- package/dist/session/session-ended.d.ts +1 -0
- package/dist/session/session-ended.js +2 -2
- package/dist/status-tone.d.ts +1 -0
- package/dist/status-tone.js +5 -0
- package/dist/web/app/browser-locale.js +1 -1
- package/dist/web/app/client-plugin.d.ts +6 -1
- package/dist/web/app/create-app.d.ts +2 -1
- package/dist/web/app/create-app.js +15 -5
- package/dist/web/app/dashboard-body.js +25 -11
- package/dist/web/app/dashboard-header.d.ts +2 -1
- package/dist/web/app/dashboard-header.js +19 -7
- package/dist/web/app/dashboard-list-panel.d.ts +12 -0
- package/dist/web/app/dashboard-list-panel.js +144 -0
- package/dist/web/app/dashboard-narrow-gate.d.ts +6 -0
- package/dist/web/app/dashboard-narrow-gate.js +6 -0
- package/dist/web/app/dashboard-narrow-order.d.ts +3 -0
- package/dist/web/app/dashboard-narrow-order.js +6 -0
- package/dist/web/app/dashboard-navigation-link.d.ts +12 -0
- package/dist/web/app/dashboard-navigation-link.js +21 -0
- package/dist/web/app/dashboard-panels.d.ts +7 -23
- package/dist/web/app/dashboard-panels.js +55 -123
- package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
- package/dist/web/app/dashboard-reference-list-table.js +13 -4
- package/dist/web/app/dashboard-shared.d.ts +23 -7
- package/dist/web/app/dashboard-shared.js +45 -17
- package/dist/web/app/dashboard-stat-group-panel.d.ts +14 -0
- package/dist/web/app/dashboard-stat-group-panel.js +74 -0
- package/dist/web/app/dashboard-text-panel.d.ts +12 -0
- package/dist/web/app/dashboard-text-panel.js +167 -0
- package/dist/web/app/dashboard-text.d.ts +2 -0
- package/dist/web/app/dashboard-text.js +1 -1
- package/dist/web/app/dashboard-visibility.js +1 -1
- package/dist/web/app/relative-time.js +2 -1
- package/dist/web/drawn-icons.d.ts +6 -0
- package/dist/web/drawn-icons.js +30 -0
- package/dist/web/editor/editor-footer.d.ts +28 -0
- package/dist/web/editor/editor-footer.js +23 -0
- package/dist/web/editor/editor-frame.d.ts +23 -0
- package/dist/web/editor/editor-frame.js +24 -0
- package/dist/web/editor/editor-header.d.ts +36 -0
- package/dist/web/editor/editor-header.js +30 -0
- package/dist/web/editor/editor-rail.d.ts +32 -0
- package/dist/web/editor/editor-rail.js +37 -0
- package/dist/web/editor/editor-workbench.d.ts +34 -0
- package/dist/web/editor/editor-workbench.js +19 -0
- package/dist/web/editor/index.d.ts +6 -0
- package/dist/web/editor/index.js +6 -0
- package/dist/web/editor/relative-when.d.ts +1 -0
- package/dist/web/editor/relative-when.js +18 -0
- package/dist/web/icons.js +6 -5
- package/dist/web/index.d.ts +9 -1
- package/dist/web/index.js +7 -1
- package/dist/web/layout/default-app-shell.js +6 -4
- package/dist/web/layout/focus-aware-sidebar.d.ts +4 -7
- package/dist/web/layout/focus-aware-sidebar.js +5 -7
- package/dist/web/layout/header-action-pinned.d.ts +8 -0
- package/dist/web/layout/header-action-pinned.js +25 -0
- package/dist/web/layout/nav-collapse-state.d.ts +7 -0
- package/dist/web/layout/nav-collapse-state.js +76 -0
- package/dist/web/layout/nav-tree.js +71 -28
- package/dist/web/layout/notification-bell.d.ts +7 -2
- package/dist/web/layout/notification-bell.js +16 -5
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.d.ts +8 -0
- package/dist/web/layout/screen-focus.js +42 -0
- package/dist/web/layout/shell-focus.d.ts +5 -4
- package/dist/web/layout/shell-focus.js +14 -7
- package/dist/web/layout/shell-header.d.ts +2 -1
- package/dist/web/layout/shell-header.js +84 -27
- package/dist/web/layout/shell-style.d.ts +3 -0
- package/dist/web/layout/shell-style.js +6 -0
- package/dist/web/layout/sidebar-open-state.d.ts +6 -0
- package/dist/web/layout/sidebar-open-state.js +28 -0
- package/dist/web/layout/uniform-bar-controls.d.ts +2 -2
- package/dist/web/layout/uniform-bar-controls.js +4 -3
- package/dist/web/layout/use-in-app-inbox.js +8 -1
- package/dist/web/layout/workspace-shell.d.ts +11 -1
- package/dist/web/layout/workspace-shell.js +9 -5
- package/dist/web/lib/upload-file-ref.d.ts +2 -2
- package/dist/web/lib/upload-file-ref.js +4 -9
- package/dist/web/presence/use-presence.js +7 -2
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +22 -9
- package/dist/web/primitives/calendar-day-picker.js +24 -5
- package/dist/web/primitives/card.js +18 -8
- package/dist/web/primitives/code-input.js +6 -1
- package/dist/web/primitives/data-table/actions-column.d.ts +2 -1
- package/dist/web/primitives/data-table/actions-column.js +7 -3
- package/dist/web/primitives/data-table/card-body.d.ts +6 -1
- package/dist/web/primitives/data-table/card-body.js +53 -6
- package/dist/web/primitives/data-table/card-frame.d.ts +8 -0
- package/dist/web/primitives/data-table/card-frame.js +9 -0
- package/dist/web/primitives/data-table/card-row.js +44 -7
- package/dist/web/primitives/data-table/card-sort-select.d.ts +6 -2
- package/dist/web/primitives/data-table/card-sort-select.js +10 -7
- package/dist/web/primitives/data-table/card-view.js +12 -2
- package/dist/web/primitives/data-table/column-picker-section.js +9 -2
- package/dist/web/primitives/data-table/column-resize-handle.js +3 -4
- package/dist/web/primitives/data-table/column-role.d.ts +1 -0
- package/dist/web/primitives/data-table/column-role.js +1 -0
- package/dist/web/primitives/data-table/data-cell-props.d.ts +5 -0
- package/dist/web/primitives/data-table/data-cell-props.js +5 -0
- package/dist/web/primitives/data-table/density.js +1 -0
- package/dist/web/primitives/data-table/facet-cluster.d.ts +2 -1
- package/dist/web/primitives/data-table/facet-cluster.js +2 -2
- package/dist/web/primitives/data-table/group-band.js +4 -0
- package/dist/web/primitives/data-table/hint-cell.d.ts +14 -0
- package/dist/web/primitives/data-table/hint-cell.js +68 -0
- package/dist/web/primitives/data-table/hint-column-width.d.ts +3 -0
- package/dist/web/primitives/data-table/hint-column-width.js +11 -0
- package/dist/web/primitives/data-table/measure-value.js +2 -3
- package/dist/web/primitives/data-table/row-action-column.d.ts +3 -0
- package/dist/web/primitives/data-table/row-action-column.js +4 -0
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -2
- package/dist/web/primitives/data-table/sort-options-select.d.ts +22 -0
- package/dist/web/primitives/data-table/sort-options-select.js +46 -0
- package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
- package/dist/web/primitives/data-table/sortable-header.js +5 -3
- package/dist/web/primitives/data-table/table-body.d.ts +1 -1
- package/dist/web/primitives/data-table/table-body.js +5 -3
- package/dist/web/primitives/data-table/table-chrome.js +3 -1
- package/dist/web/primitives/data-table/table-content.js +12 -7
- package/dist/web/primitives/data-table/table-data-cell.js +9 -3
- package/dist/web/primitives/data-table/table-header-row.js +5 -2
- package/dist/web/primitives/data-table/table-view.js +22 -3
- package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
- package/dist/web/primitives/data-table/toolbar.d.ts +2 -0
- package/dist/web/primitives/data-table/toolbar.js +70 -7
- package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
- package/dist/web/primitives/data-table/totals-footer.js +41 -9
- package/dist/web/primitives/data-table/use-bulk-selection.js +2 -1
- package/dist/web/primitives/data-table/use-column-pins.js +4 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +1 -0
- package/dist/web/primitives/data-table/use-data-table-state.js +9 -5
- package/dist/web/primitives/data-table/use-measured-column-widths.js +5 -4
- package/dist/web/primitives/data-table/use-row-selection.js +22 -11
- package/dist/web/primitives/data-table/view-menu.js +7 -1
- package/dist/web/primitives/data-table-cell.d.ts +21 -2
- package/dist/web/primitives/data-table-cell.js +129 -26
- package/dist/web/primitives/embedded-file-cell.js +3 -2
- package/dist/web/primitives/embedded-list-cards.js +3 -4
- package/dist/web/primitives/facet-filter.d.ts +5 -3
- package/dist/web/primitives/facet-filter.js +36 -5
- package/dist/web/primitives/facet-search-filter.d.ts +2 -1
- package/dist/web/primitives/facet-search-filter.js +3 -2
- package/dist/web/primitives/facet-trigger-label.d.ts +8 -0
- package/dist/web/primitives/facet-trigger-label.js +9 -0
- package/dist/web/primitives/file-thumbnail.d.ts +6 -2
- package/dist/web/primitives/file-thumbnail.js +13 -6
- package/dist/web/primitives/file-upload.js +3 -2
- package/dist/web/primitives/file-view-action.d.ts +6 -0
- package/dist/web/primitives/file-view-action.js +22 -0
- package/dist/web/primitives/files-dropzone.js +20 -9
- package/dist/web/primitives/form-footer-parts.d.ts +0 -1
- package/dist/web/primitives/form.js +0 -1
- package/dist/web/primitives/hint-reason-row.d.ts +32 -0
- package/dist/web/primitives/hint-reason-row.js +45 -0
- package/dist/web/primitives/index.js +6 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +3 -3
- package/dist/web/primitives/metric.js +20 -6
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +10 -2
- package/dist/web/primitives/pager.d.ts +3 -2
- package/dist/web/primitives/pager.js +31 -24
- package/dist/web/primitives/reason-box.d.ts +20 -0
- package/dist/web/primitives/reason-box.js +13 -0
- package/dist/web/primitives/record-breadcrumb.d.ts +3 -0
- package/dist/web/primitives/record-breadcrumb.js +11 -0
- package/dist/web/primitives/record-steps.d.ts +3 -0
- package/dist/web/primitives/record-steps.js +50 -0
- package/dist/web/primitives/record-summary.d.ts +3 -0
- package/dist/web/primitives/record-summary.js +18 -0
- package/dist/web/primitives/row-actions.d.ts +3 -1
- package/dist/web/primitives/row-actions.js +14 -5
- package/dist/web/primitives/segmented-select.js +10 -9
- package/dist/web/primitives/tabs.js +6 -1
- package/dist/web/pwa/pwa-support.d.ts +4 -0
- package/dist/web/pwa/pwa-support.js +131 -0
- package/dist/web/sse/live-events.js +2 -2
- package/dist/web/tokens.js +0 -3
- package/dist/web/ui/sidebar.d.ts +2 -1
- package/dist/web/ui/sidebar.js +4 -3
- package/dist/web/widgets/ai-text-field.js +3 -2
- package/dist/web/widgets/chart-parts.d.ts +7 -1
- package/dist/web/widgets/chart-parts.js +10 -4
- package/dist/web/widgets/collapsible-section.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.d.ts +17 -0
- package/dist/web/widgets/dashboard-list-cards.js +46 -0
- package/dist/web/widgets/dashboard-list.d.ts +45 -5
- package/dist/web/widgets/dashboard-list.js +126 -25
- package/dist/web/widgets/drawer-panel-class.d.ts +1 -0
- package/dist/web/widgets/drawer-panel-class.js +9 -1
- package/dist/web/widgets/drawer-sizing.js +1 -1
- package/dist/web/widgets/drawer.js +2 -2
- package/dist/web/widgets/floating-panel.js +4 -2
- package/dist/web/widgets/index.d.ts +2 -0
- package/dist/web/widgets/index.js +2 -0
- package/dist/web/widgets/infinity-list.js +18 -11
- package/dist/web/widgets/pdf-viewer-toolbar.js +3 -2
- package/dist/web/widgets/preview-width-frame.d.ts +7 -0
- package/dist/web/widgets/preview-width-frame.js +10 -0
- package/dist/web/widgets/section-card.d.ts +1 -1
- package/dist/web/widgets/sheet-parts.js +3 -1
- package/dist/web/widgets/stacked-area-chrome.js +3 -3
- package/dist/web/widgets/stacked-area-tooltip.js +2 -10
- package/dist/web/widgets/stat-box-cell.d.ts +19 -0
- package/dist/web/widgets/stat-box-cell.js +10 -0
- package/dist/web/widgets/stat.d.ts +16 -1
- package/dist/web/widgets/stat.js +24 -7
- package/dist/web/widgets/status-badge.d.ts +7 -5
- package/dist/web/widgets/status-badge.js +2 -2
- package/dist/web/widgets/step-bar.d.ts +1 -1
- package/dist/web/widgets/step-bar.js +37 -7
- package/dist/web/widgets/step-list-row.d.ts +4 -0
- package/dist/web/widgets/step-list-row.js +22 -14
- package/dist/web/widgets/step-list.d.ts +12 -4
- package/dist/web/widgets/step-list.js +38 -20
- package/dist/web/widgets/upload-zone.d.ts +8 -1
- package/dist/web/widgets/upload-zone.js +13 -3
- package/package.json +5 -5
- package/src/changes.json +289 -0
- package/src/web/styles.css +15 -0
|
@@ -67,6 +67,10 @@ export function ActionFormLoadStatus({ state, screenId, translate, }) {
|
|
|
67
67
|
return (_jsx(Banner, { padded: true, variant: "error", testId: "kumiko-screen-record-missing", children: translate("kumiko.record.not-found.title") }));
|
|
68
68
|
case "missing-id":
|
|
69
69
|
return (_jsxs(Banner, { padded: true, variant: "error", testId: "kumiko-screen-action-form-missing-id", children: ["Screen ", _jsx(Text, { variant: "code", children: screenId }), " (actionForm with load) needs a record id in the path or the clicked row."] }));
|
|
70
|
+
default: {
|
|
71
|
+
const exhaustiveCheck = state;
|
|
72
|
+
return exhaustiveCheck;
|
|
73
|
+
}
|
|
70
74
|
}
|
|
71
75
|
}
|
|
72
76
|
function factLine(entry, locale) {
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { ContentEditorFormat } from "@cosmicdrift/kumiko-types/nav";
|
|
2
|
+
import { type ComponentType, type ReactNode } from "react";
|
|
3
|
+
export declare const PREVIEW_TARGETS: readonly ["pdf", "mail", "web", "text"];
|
|
4
|
+
export type PreviewTarget = (typeof PREVIEW_TARGETS)[number];
|
|
5
|
+
export type PreviewSubject = {
|
|
6
|
+
readonly kind: "template";
|
|
7
|
+
readonly templateKind: string;
|
|
8
|
+
readonly slug: string;
|
|
9
|
+
readonly locale: string;
|
|
10
|
+
readonly meta: unknown;
|
|
11
|
+
/** Placeholder schema of the template; the server derives sample values from it. */
|
|
12
|
+
readonly variableSchema?: unknown;
|
|
13
|
+
} | {
|
|
14
|
+
readonly kind: "layout";
|
|
15
|
+
readonly templateKind: string;
|
|
16
|
+
readonly html: string;
|
|
17
|
+
} | {
|
|
18
|
+
readonly kind: "body";
|
|
19
|
+
};
|
|
20
|
+
export type PreviewRendererProps = {
|
|
21
|
+
readonly content: string;
|
|
22
|
+
readonly editFormat: ContentEditorFormat;
|
|
23
|
+
readonly variables: Readonly<Record<string, unknown>>;
|
|
24
|
+
readonly subject: PreviewSubject;
|
|
25
|
+
/** The renderer hands the answer of its server call to a host that shows it elsewhere (the mail editor's side rail). */
|
|
26
|
+
readonly onResult?: (result: unknown) => void;
|
|
27
|
+
};
|
|
28
|
+
export type PreviewRenderer = ComponentType<PreviewRendererProps>;
|
|
29
|
+
export type ContentPreviewsMap = Partial<Record<PreviewTarget, PreviewRenderer>>;
|
|
30
|
+
export declare function ContentPreviewsProvider({ children, value, }: {
|
|
31
|
+
readonly children: ReactNode;
|
|
32
|
+
readonly value: ContentPreviewsMap;
|
|
33
|
+
}): ReactNode;
|
|
34
|
+
export declare function TextPreviewRenderer({ content, editFormat, variables, }: PreviewRendererProps): ReactNode;
|
|
35
|
+
export declare function useContentPreview(target: PreviewTarget): PreviewRenderer;
|
|
36
|
+
/** Mounts the renderer registered for `target`. */
|
|
37
|
+
export declare function PreviewPane({ target, ...props }: PreviewRendererProps & {
|
|
38
|
+
readonly target: PreviewTarget;
|
|
39
|
+
}): ReactNode;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { createContext, useContext } from "react";
|
|
3
|
+
import { ContentPreview } from "./content-preview.js";
|
|
4
|
+
export const PREVIEW_TARGETS = ["pdf", "mail", "web", "text"];
|
|
5
|
+
const ContentPreviewsContext = createContext({});
|
|
6
|
+
export function ContentPreviewsProvider({ children, value, }) {
|
|
7
|
+
return (_jsx(ContentPreviewsContext.Provider, { value: value, children: children }));
|
|
8
|
+
}
|
|
9
|
+
function stringVariables(variables) {
|
|
10
|
+
const strings = {};
|
|
11
|
+
for (const [name, value] of Object.entries(variables)) {
|
|
12
|
+
if (typeof value === "string")
|
|
13
|
+
strings[name] = value;
|
|
14
|
+
}
|
|
15
|
+
return strings;
|
|
16
|
+
}
|
|
17
|
+
export function TextPreviewRenderer({ content, editFormat, variables, }) {
|
|
18
|
+
return (_jsx(ContentPreview, { content: content, variables: stringVariables(variables), contentFormat: editFormat }));
|
|
19
|
+
}
|
|
20
|
+
export function useContentPreview(target) {
|
|
21
|
+
const map = useContext(ContentPreviewsContext);
|
|
22
|
+
return map[target] ?? TextPreviewRenderer;
|
|
23
|
+
}
|
|
24
|
+
/** Mounts the renderer registered for `target`. */
|
|
25
|
+
export function PreviewPane({ target, ...props }) {
|
|
26
|
+
const Renderer = useContentPreview(target);
|
|
27
|
+
return _jsx(Renderer, { ...props });
|
|
28
|
+
}
|
|
@@ -16,7 +16,6 @@ import { useAppFeatures } from "./app-features-context.js";
|
|
|
16
16
|
import { useClientActionRuntime } from "./client-actions.js";
|
|
17
17
|
import { applyEditPrefill } from "./edit-prefill.js";
|
|
18
18
|
import { buildInitialValues, mergeSearchParamsIntoInitial, tenantCurrencyMoneyFieldNames, useMoneyCurrencyOverrides, versionOf, } from "./entity-edit-prefill.js";
|
|
19
|
-
import { buildFormSchema } from "./form-schema.js";
|
|
20
19
|
import { layoutEditFields, layoutFieldNames } from "./layout-fields.js";
|
|
21
20
|
import { useInitialValuesHandoff, useNav } from "./nav.js";
|
|
22
21
|
import { lastSegment, toKebab } from "./qn.js";
|
|
@@ -77,7 +76,6 @@ function EntityEditCreateBody({ schema, screen, entity, translate, onSaved, }) {
|
|
|
77
76
|
currentUser,
|
|
78
77
|
fallbackTimeZone,
|
|
79
78
|
]);
|
|
80
|
-
const formSchema = useMemo(() => buildFormSchema(entity, screen, "create"), [entity, screen]);
|
|
81
79
|
const writeCommand = entityWriteCommand(schema.featureName, screen.entity, "create");
|
|
82
80
|
const navigateToList = useNavigateToListAfter(schema, screen.entity);
|
|
83
81
|
const handleCancel = useCallback(() => navigateToReturnOr(nav, returnTarget, navigateToList), [nav, returnTarget, navigateToList]);
|
|
@@ -125,7 +123,7 @@ function EntityEditCreateBody({ schema, screen, entity, translate, onSaved, }) {
|
|
|
125
123
|
// EXISTING record (publish/archive/duplicate and friends), which the
|
|
126
124
|
// create branch has none of yet — see EntityEditUpdateForm for the
|
|
127
125
|
// wired-up counterpart.
|
|
128
|
-
return (_jsx(RenderEdit, { screen: screen, entity: entity, featureName: schema.featureName, initial: initial,
|
|
126
|
+
return (_jsx(RenderEdit, { screen: screen, entity: entity, featureName: schema.featureName, initial: initial, writeCommand: writeCommand, onSubmit: handleSubmitted, onControlsReady: handleControlsReady, onCancel: handleCancel, ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...(screen.submitLabel !== undefined && { submitLabel: screen.submitLabel }), ...(translate !== undefined && { translate }) }));
|
|
129
127
|
}
|
|
130
128
|
// Update body: loads the existing record via `<feature>:query:<entity>:detail`,
|
|
131
129
|
// then mounts a form pre-filled with the server values and dispatches
|
|
@@ -192,7 +190,6 @@ function EntityEditUpdateForm({ schema, screen, entity, entityId, record, onRelo
|
|
|
192
190
|
}
|
|
193
191
|
return out;
|
|
194
192
|
}, [entity.fields, entityDefaultCurrency, moneyCurrencyOverrides, record]);
|
|
195
|
-
const formSchema = useMemo(() => buildFormSchema(entity, screen, "update", initial), [entity, screen, initial]);
|
|
196
193
|
// Hand extension values (e.g. customFields jsonb) to the extension sections
|
|
197
194
|
// so they show the existing data on edit instead of being write-only.
|
|
198
195
|
const extensionInitialValues = useMemo(() => {
|
|
@@ -353,7 +350,7 @@ function EntityEditUpdateForm({ schema, screen, entity, entityId, record, onRelo
|
|
|
353
350
|
entityId: entityId,
|
|
354
351
|
// Stored customFields for the extension section, so editing shows the
|
|
355
352
|
// persisted values instead of behaving write-only.
|
|
356
|
-
extensionInitialValues: extensionInitialValues,
|
|
353
|
+
extensionInitialValues: extensionInitialValues, writeCommand: writeCommand, payloadMode: "changes", buildPayload: buildPayload, serverFieldPathPrefix: `${UPDATE_CHANGES_KEY}.`, onSubmit: handleSubmitted, onDirtyChange: setFormDirty, ...(screen.allowDelete !== false && !viewMode && { onDelete: handleDelete }), onCancel: handleCancel, onReload: () => void onReload(), ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...(screen.submitLabel !== undefined && { submitLabel: screen.submitLabel }), ...(translate !== undefined && { translate }), ...(onCopyLink !== undefined && { onCopyLink }), ...(headerActions !== undefined && { actions: headerActions }), ...(headerMenuActions !== undefined && { menuActions: headerMenuActions }), buildSectionActions: buildSectionActions }), _jsx(DrawerHost, { schema: schema, drawerAction: drawerAction, drawerScreen: drawerScreen, ...(drawerInitialValues !== undefined && { drawerInitialValues }), userRoles: userRoles, ...(translate !== undefined && { translate }), onClose: closeDrawer, onSuccess: () => {
|
|
357
354
|
closeDrawer();
|
|
358
355
|
void onReload();
|
|
359
356
|
} })] }));
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { evalFieldCondition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
3
3
|
import { resolveActionIcon } from "@cosmicdrift/kumiko-types/action-icon";
|
|
4
|
-
import {
|
|
4
|
+
import { entityListDeclaresSearch } from "@cosmicdrift/kumiko-types/screen";
|
|
5
5
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
6
6
|
import { ListGroupPageBridges } from "../components/list-group-page-bridges.js";
|
|
7
7
|
import { RenderList } from "../components/render-list.js";
|
|
@@ -24,6 +24,7 @@ import { FacetCountBridges } from "./facet-count-bridge.js";
|
|
|
24
24
|
import { useListBulk } from "./list-bulk-actions.js";
|
|
25
25
|
import { isDefaultFilterActive, isListNarrowed, useListEmptyContent, } from "./list-empty-content.js";
|
|
26
26
|
import { buildEntityFilterFacets, buildFacetCountRequests, buildFilterPayload, mergeReferenceFacetOptions, normalizeDefaultFilters, } from "./list-facets.js";
|
|
27
|
+
import { translatedSortOptionProps } from "./list-sort-options.js";
|
|
27
28
|
import { buildNamedFilterFacet, routeFacetChange, withNamedFilterValues, } from "./named-filter-facet.js";
|
|
28
29
|
import { NamedFilterRemove } from "./named-filter-remove.js";
|
|
29
30
|
import { useNav } from "./nav.js";
|
|
@@ -32,9 +33,12 @@ import { ReferenceFacetBridges, withReferenceFacetState, } from "./reference-fac
|
|
|
32
33
|
import { navigateWithReturnTo, useReturnHost } from "./return-to.js";
|
|
33
34
|
import { buildClientActionRowAction, buildDefaultEditRowAction, buildDrawerRowAction, buildProjectionToolbarActions, buildWriteHandlerRowAction, findRowClickAction, navigateActionSearchParams, runDrawerRowAction, } from "./row-actions.js";
|
|
34
35
|
import { findEditScreenFor } from "./screen-access.js";
|
|
35
|
-
import {
|
|
36
|
+
import { entityQueryCommand, isEntityEditScreenOfEntity, useNavigateToCreateFor, } from "./screen-shared.js";
|
|
37
|
+
import { useEntityListPayload } from "./use-entity-list-payload.js";
|
|
36
38
|
import { useEntityRangeFacets } from "./use-entity-range-facets.js";
|
|
39
|
+
import { useFacetCounts } from "./use-facet-counts.js";
|
|
37
40
|
import { useGatedToolbarActions } from "./use-gated-toolbar-actions.js";
|
|
41
|
+
import { useNamedFilterQueue } from "./use-named-filter-queue.js";
|
|
38
42
|
import { listPager, useScreenListRows } from "./use-screen-list-rows.js";
|
|
39
43
|
import { useScreenListTable } from "./use-screen-list-table.js";
|
|
40
44
|
export function EntityListScreen({ schema, screen, translate, onRowClick, }) {
|
|
@@ -52,6 +56,15 @@ export function EntityListScreen({ schema, screen, translate, onRowClick, }) {
|
|
|
52
56
|
function toolbarDescriptionOf(description, isEmbedded, translate) {
|
|
53
57
|
return description === undefined || isEmbedded ? undefined : translate(description);
|
|
54
58
|
}
|
|
59
|
+
// Searchable default: explicit author choice wins, otherwise auto-on when
|
|
60
|
+
// the entity has searchable fields (dead toolbar slot otherwise — the
|
|
61
|
+
// server search index has nothing to filter). Gated on
|
|
62
|
+
// schema.searchAdapterMissing !== true regardless of source (explicit or
|
|
63
|
+
// auto) — a search bar the server can't serve would 422 at request-time;
|
|
64
|
+
// matches the boot-time check in api/server.ts.
|
|
65
|
+
function isEntityListSearchable(schema, screen, entity) {
|
|
66
|
+
return schema.searchAdapterMissing !== true && entityListDeclaresSearch(screen, entity);
|
|
67
|
+
}
|
|
55
68
|
function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
56
69
|
const isEmbeddedScreen = useIsEmbeddedScreen();
|
|
57
70
|
const featureName = schema.featureName;
|
|
@@ -73,7 +86,6 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
73
86
|
const urlState = useListUrlState(screen.id, defaultFilters);
|
|
74
87
|
// Gated on the screen offering named filters, so a stale URL cannot send a param the list rejects.
|
|
75
88
|
const activeNamedFilter = screen.namedFilters === undefined ? undefined : urlState.namedFilter;
|
|
76
|
-
const effectiveSort = urlState.sort ?? screen.defaultSort ?? null;
|
|
77
89
|
const limit = urlState.pageSize ?? screen.pageSize ?? 50;
|
|
78
90
|
const paginationMode = screen.pagination ?? "pages";
|
|
79
91
|
const usePager = paginationMode === "pages";
|
|
@@ -90,52 +102,28 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
90
102
|
translate: effectiveTranslate,
|
|
91
103
|
urlState,
|
|
92
104
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
return typeof type === "string" ? type : undefined;
|
|
101
|
-
}), [urlState.filters, entity.fields]);
|
|
102
|
-
// Entity-only additions (screen.filter, faceted filters) layer on top of
|
|
103
|
-
// the shared buildListQueryPayload — projectionList has neither.
|
|
104
|
-
const queryPayload = useMemo(() => {
|
|
105
|
-
const payload = buildListQueryPayload({
|
|
106
|
-
limit,
|
|
107
|
-
search: urlState.q,
|
|
108
|
-
sort: effectiveSort,
|
|
109
|
-
usePager,
|
|
110
|
-
page: urlState.page,
|
|
111
|
-
useInfinite,
|
|
112
|
-
cursor: undefined,
|
|
113
|
-
});
|
|
114
|
-
// Screen filter (tier 2.7c), declared by the author on the schema and
|
|
115
|
-
// independent of the user's q search. Several buckets of the same entity
|
|
116
|
-
// ("Upcoming" / "Active" / "Past") use different filters with the same
|
|
117
|
-
// query handler.
|
|
118
|
-
if (screen.filter !== undefined) {
|
|
119
|
-
payload["filter"] = screen.filter;
|
|
120
|
-
}
|
|
121
|
-
const filters = [...filterPayload, ...range.rangeFilters];
|
|
122
|
-
if (filters.length > 0)
|
|
123
|
-
payload["filters"] = filters;
|
|
124
|
-
if (activeNamedFilter !== undefined)
|
|
125
|
-
payload["namedFilter"] = activeNamedFilter;
|
|
126
|
-
return payload;
|
|
127
|
-
}, [
|
|
105
|
+
const searchable = isEntityListSearchable(schema, screen, entity);
|
|
106
|
+
const { filterPayload, listPayloadFor, queryPayload, effectiveSort } = useEntityListPayload({
|
|
107
|
+
screen,
|
|
108
|
+
entity,
|
|
109
|
+
searchable,
|
|
110
|
+
urlState,
|
|
111
|
+
rangeFilters: range.rangeFilters,
|
|
128
112
|
activeNamedFilter,
|
|
129
113
|
limit,
|
|
130
|
-
urlState.q,
|
|
131
|
-
effectiveSort,
|
|
132
|
-
screen.filter,
|
|
133
|
-
filterPayload,
|
|
134
|
-
range.rangeFilters,
|
|
135
114
|
usePager,
|
|
136
|
-
urlState.page,
|
|
137
115
|
useInfinite,
|
|
138
|
-
|
|
116
|
+
});
|
|
117
|
+
const { namedFilterCountQueries, namedFilterEmpty } = useNamedFilterQueue({
|
|
118
|
+
screen,
|
|
119
|
+
urlState,
|
|
120
|
+
userRoles,
|
|
121
|
+
translate: effectiveTranslate,
|
|
122
|
+
filterPayload,
|
|
123
|
+
rangeFilters: range.rangeFilters,
|
|
124
|
+
activeNamedFilter,
|
|
125
|
+
listPayloadFor,
|
|
126
|
+
});
|
|
139
127
|
// Facet counts come from their own queries, which a write leaves untouched.
|
|
140
128
|
const [facetCountRefreshNonce, setFacetCountRefreshNonce] = useState(0);
|
|
141
129
|
const refreshFacetCounts = useCallback(() => setFacetCountRefreshNonce((n) => n + 1), []);
|
|
@@ -160,6 +148,8 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
160
148
|
payload: queryPayload,
|
|
161
149
|
infinite: useInfinite,
|
|
162
150
|
aggregates: listTable.aggregates,
|
|
151
|
+
rowDecoration: screen.rowDecoration,
|
|
152
|
+
restoring: listTable.restoring,
|
|
163
153
|
});
|
|
164
154
|
const { refreshAfterWrite: refreshListAfterWrite } = listRows;
|
|
165
155
|
const refreshRowsAfterWrite = useCallback(async () => {
|
|
@@ -168,10 +158,9 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
168
158
|
}, [refreshFacetCounts, refreshListAfterWrite]);
|
|
169
159
|
const [entityReferenceFacetOptions, setEntityReferenceFacetOptions] = useState({});
|
|
170
160
|
const handleEntityFacetOptions = useCallback((field, state) => setEntityReferenceFacetOptions((prev) => withReferenceFacetState(prev, field, state)), []);
|
|
171
|
-
const
|
|
172
|
-
const handleFacetCount = useCallback((key, count) => setFacetCounts((prev) => (prev[key] === count ? prev : { ...prev, [key]: count })), []);
|
|
161
|
+
const { facetCounts, handleFacetCount } = useFacetCounts();
|
|
173
162
|
const filterFacets = useMemo(() => {
|
|
174
|
-
const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate);
|
|
163
|
+
const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate, userRoles, screen.namedFilterFacet, facetCounts);
|
|
175
164
|
return [
|
|
176
165
|
...(namedFacet !== undefined ? [namedFacet] : []),
|
|
177
166
|
...buildEntityFilterFacets(mergeReferenceFacetOptions(entityFacetSpecs, entityReferenceFacetOptions), screen.facets, effectiveTranslate, facetCounts),
|
|
@@ -181,7 +170,9 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
181
170
|
entityReferenceFacetOptions,
|
|
182
171
|
screen.facets,
|
|
183
172
|
screen.namedFilters,
|
|
173
|
+
screen.namedFilterFacet,
|
|
184
174
|
effectiveTranslate,
|
|
175
|
+
userRoles,
|
|
185
176
|
facetCounts,
|
|
186
177
|
]);
|
|
187
178
|
const filterValues = useMemo(() => withNamedFilterValues(urlState.filters, activeNamedFilter), [urlState.filters, activeNamedFilter]);
|
|
@@ -213,6 +204,7 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
213
204
|
entity.fields,
|
|
214
205
|
range.rangeFilters,
|
|
215
206
|
]);
|
|
207
|
+
const allFacetCountQueries = useMemo(() => [...namedFilterCountQueries, ...facetCountQueries], [namedFilterCountQueries, facetCountQueries]);
|
|
216
208
|
// Soft dispatcher: in tests that mount without a DispatcherProvider,
|
|
217
209
|
// rowActions stays undefined instead of crashing. Real apps have the
|
|
218
210
|
// provider via createKumikoApp; if it is missing it is most likely a setup
|
|
@@ -405,21 +397,12 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
405
397
|
: onRowClick !== undefined
|
|
406
398
|
? (row) => onRowClick(row, screen.entity)
|
|
407
399
|
: undefined;
|
|
408
|
-
// Searchable default: explicit author choice wins, otherwise auto-on when
|
|
409
|
-
// the entity has searchable fields (dead toolbar slot otherwise — the
|
|
410
|
-
// server search index has nothing to filter). Gated on
|
|
411
|
-
// schema.searchAdapterMissing !== true regardless of source (explicit or
|
|
412
|
-
// auto) — a search bar the server can't serve would 422 at request-time;
|
|
413
|
-
// matches the boot-time check in api/server.ts.
|
|
414
|
-
const searchable = schema.searchAdapterMissing !== true &&
|
|
415
|
-
(screen.searchable ??
|
|
416
|
-
Object.values(entity.fields).some((f) => "searchable" in f && f.searchable === true));
|
|
417
400
|
// Assemble pager props only for pagination="pages". The server total
|
|
418
401
|
// arrives async; until it is there RenderList renders the table without a
|
|
419
402
|
// pager (the pager has its own total>0 guard).
|
|
420
403
|
const pager = listPager({ usePager, page: listRows.page, limit, urlState });
|
|
421
|
-
return (_jsxs(_Fragment, { children: [refetchErrorBanner, _jsx(ListGroupPageBridges, { ...listTable.aggregates.groupPages }), _jsx(ReferenceFacetBridges, { specs: entityFacetSpecs, selected: urlState.filters, onState: handleEntityFacetOptions }), _jsx(FacetCountBridges, { queryType: queryType, queries:
|
|
422
|
-
isListNarrowed(urlState.q, urlState.filters, defaultFilters), defaultFilterActive: isDefaultFilterActive(urlState.q, urlState.filters, defaultFilters), ...(toolbarDescription !== undefined && { description: toolbarDescription }), ...(emptyContent !== undefined && { emptyContent }), searchValue: urlState.q, onSearchChange: urlState.setQ, sort: effectiveSort, onSortChange: urlState.setSort, ...(isEmbeddedScreen
|
|
404
|
+
return (_jsxs(_Fragment, { children: [refetchErrorBanner, _jsx(ListGroupPageBridges, { ...listTable.aggregates.groupPages }), _jsx(ReferenceFacetBridges, { specs: entityFacetSpecs, selected: urlState.filters, onState: handleEntityFacetOptions }), _jsx(FacetCountBridges, { queryType: queryType, queries: allFacetCountQueries, onCount: handleFacetCount, refreshNonce: facetCountRefreshNonce }), _jsx(RenderList, { screen: screen, entity: entity, rows: listRows.rows, featureName: featureName, searchable: searchable, narrowed: activeNamedFilter !== undefined ||
|
|
405
|
+
isListNarrowed(urlState.q, urlState.filters, defaultFilters), namedFilterEmpty: namedFilterEmpty, defaultFilterActive: isDefaultFilterActive(urlState.q, urlState.filters, defaultFilters), ...(toolbarDescription !== undefined && { description: toolbarDescription }), ...(emptyContent !== undefined && { emptyContent }), searchValue: urlState.q, onSearchChange: urlState.setQ, sort: effectiveSort, onSortChange: urlState.setSort, ...translatedSortOptionProps(screen.sortOptions, effectiveTranslate), ...(isEmbeddedScreen
|
|
423
406
|
? { screenPadding: false, chromeless: true }
|
|
424
407
|
: { screenPadding: true }), ...(screenFillsHeight(screen) && { scrollBody: true }), ...(pager !== undefined && { pager }), ...(rowActions !== undefined && { rowActions }), ...(screen.rowActionMode !== undefined && { rowActionMode: screen.rowActionMode }), ...(bulk !== undefined && { bulk }), ...(toolbarActions !== undefined && toolbarActions.length > 0 && { toolbarActions }), ...listRows.infinite, ...(onCreate !== undefined && { onCreate }), ...(translate !== undefined && { translate }), ...(wrappedOnRowClick !== undefined && { onRowClick: wrappedOnRowClick }), ...(filterFacets.length > 0 && { filterFacets, onFilterChange }), ...(range.rangeFacets.length > 0 && {
|
|
425
408
|
rangeFacets: range.rangeFacets,
|
|
@@ -5,3 +5,4 @@ export declare function isPresent(value: unknown): boolean;
|
|
|
5
5
|
export declare const REQUIRED_FIELD_I18N_KEY = "kumiko.validation.required";
|
|
6
6
|
export declare const OPTION_NOT_AVAILABLE_I18N_KEY = "kumiko.validation.optionNotAvailable";
|
|
7
7
|
export declare function buildFormSchema(entity: EntityDefinition, screen: EntityEditScreenDefinition, verb: EditFormMode, unchangedFrom?: Readonly<Record<string, unknown>>): z.ZodType;
|
|
8
|
+
export declare function allOfSchemas(first: z.ZodType, second: z.ZodType): z.ZodType;
|
package/dist/app/form-schema.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { evalFieldCondition, findMissingConditionalRequirements, findUnavailableSelectOptions, isFieldRequired, isUnchangedValue, NO_WIDGET_FIELD_TYPES, } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import * as z from "zod";
|
|
3
|
+
import { asCustomIssue } from "../headless/form/zod-bridge.js";
|
|
3
4
|
import { I18N_KEY_PARAM } from "../headless/index.js";
|
|
4
5
|
import { layoutEditFields } from "./layout-fields.js";
|
|
5
6
|
// `required` means "has a value", not "is truthy" — `false` and `0` count
|
|
@@ -40,6 +41,11 @@ function isRequiredValueMissing(spec, field, record, unchangedFrom) {
|
|
|
40
41
|
return false;
|
|
41
42
|
return !(unchangedFrom !== undefined && isUnchangedValue(record[spec.field], unchangedFrom[spec.field]));
|
|
42
43
|
}
|
|
44
|
+
// Only select fields map "" and null to their default on insert (selectFieldToZod);
|
|
45
|
+
// other types apply `.default()` to undefined only, so a user-cleared "" still fails there.
|
|
46
|
+
function isSelectWithDefault(field) {
|
|
47
|
+
return field.type === "select" && field.default !== undefined;
|
|
48
|
+
}
|
|
43
49
|
// Embedded sub-field `requiredWhen` (e.g. checkpoints.0.finding) — the top-level
|
|
44
50
|
// conditions are already covered by isRequiredValueMissing.
|
|
45
51
|
function addEmbeddedRequirementIssues(ctx, entity, record, unchangedFrom, checkedFields) {
|
|
@@ -134,6 +140,10 @@ export function buildFormSchema(entity, screen, verb, unchangedFrom) {
|
|
|
134
140
|
continue;
|
|
135
141
|
}
|
|
136
142
|
selectFieldsToCheck[spec.field] = field;
|
|
143
|
+
// On insert the server turns an empty select into its default, so a presence
|
|
144
|
+
// error would block a value the user may leave empty.
|
|
145
|
+
if (verb === "create" && isSelectWithDefault(field))
|
|
146
|
+
continue;
|
|
137
147
|
if (!isRequiredValueMissing(spec, field, record, unchangedFrom))
|
|
138
148
|
continue;
|
|
139
149
|
ctx.addIssue({
|
|
@@ -148,3 +158,17 @@ export function buildFormSchema(entity, screen, verb, unchangedFrom) {
|
|
|
148
158
|
addUnavailableOptionIssues(ctx, record, unchangedFrom, lockedSelectFields, selectFieldsToCheck);
|
|
149
159
|
});
|
|
150
160
|
}
|
|
161
|
+
// Both schemas run on the same values and their issues are merged, so a
|
|
162
|
+
// caller-supplied schema adds rules instead of replacing the field-derived ones.
|
|
163
|
+
// Not z.intersection: that would fail when the two parsed outputs cannot merge.
|
|
164
|
+
export function allOfSchemas(first, second) {
|
|
165
|
+
return z.unknown().superRefine((values, ctx) => {
|
|
166
|
+
for (const schema of [first, second]) {
|
|
167
|
+
const parsed = schema.safeParse(values);
|
|
168
|
+
if (parsed.success)
|
|
169
|
+
continue;
|
|
170
|
+
for (const issue of parsed.error.issues)
|
|
171
|
+
ctx.addIssue(asCustomIssue(issue));
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
}
|
|
@@ -21,6 +21,7 @@ export type ResolvedFacetSpec = {
|
|
|
21
21
|
/** Author handler that serves the options instead of the entity list. */
|
|
22
22
|
readonly optionsQuery?: string;
|
|
23
23
|
};
|
|
24
|
+
readonly narrowPlacement?: "behind-filter";
|
|
24
25
|
/** Reference facets only: set once the bridge resolved it. Makes the facet searchable. */
|
|
25
26
|
readonly onSearchChange?: (query: string) => void;
|
|
26
27
|
readonly searching?: boolean;
|
package/dist/app/list-facets.js
CHANGED
|
@@ -22,6 +22,7 @@ function facetBase(spec) {
|
|
|
22
22
|
field: spec.field,
|
|
23
23
|
label: spec.label,
|
|
24
24
|
options: spec.options,
|
|
25
|
+
...(spec.narrowPlacement !== undefined && { narrowPlacement: spec.narrowPlacement }),
|
|
25
26
|
...(spec.onSearchChange !== undefined && { onSearchChange: spec.onSearchChange }),
|
|
26
27
|
...(spec.searching !== undefined && { searching: spec.searching }),
|
|
27
28
|
};
|
|
@@ -37,6 +38,7 @@ export function buildFacetChips(spec, config, translate) {
|
|
|
37
38
|
id: extra.id,
|
|
38
39
|
label: translate(extra.label),
|
|
39
40
|
values: extra.values,
|
|
41
|
+
...(extra.separatorAfter === true && { separatorAfter: true }),
|
|
40
42
|
});
|
|
41
43
|
return [
|
|
42
44
|
...extras.filter((extra) => extra.position !== "end").map(toChip),
|
|
@@ -56,7 +58,10 @@ export function buildEntityFilterFacets(specs, configs, translate, counts) {
|
|
|
56
58
|
const config = configs?.[spec.field];
|
|
57
59
|
if (config === false)
|
|
58
60
|
continue;
|
|
59
|
-
const base =
|
|
61
|
+
const base = {
|
|
62
|
+
...facetBase(spec),
|
|
63
|
+
...(config?.narrowPlacement !== undefined && { narrowPlacement: config.narrowPlacement }),
|
|
64
|
+
};
|
|
60
65
|
if (config?.display !== "chips") {
|
|
61
66
|
out.push(base);
|
|
62
67
|
continue;
|
|
@@ -150,12 +155,14 @@ export function resolveProjectionFacetSpecs(facets, translate, featureName) {
|
|
|
150
155
|
return facets.flatMap((facet) => {
|
|
151
156
|
if (facet.type === "dateRange")
|
|
152
157
|
return [];
|
|
158
|
+
const placement = facet.narrowPlacement !== undefined ? { narrowPlacement: facet.narrowPlacement } : {};
|
|
153
159
|
if (facet.type === "select") {
|
|
154
160
|
return [
|
|
155
161
|
{
|
|
156
162
|
field: facet.field,
|
|
157
163
|
type: "select",
|
|
158
164
|
label: tr(facet.label),
|
|
165
|
+
...placement,
|
|
159
166
|
options: facet.options.map((opt) => ({
|
|
160
167
|
value: opt.value,
|
|
161
168
|
label: tr(opt.label),
|
|
@@ -169,6 +176,7 @@ export function resolveProjectionFacetSpecs(facets, translate, featureName) {
|
|
|
169
176
|
field: facet.field,
|
|
170
177
|
type: "boolean",
|
|
171
178
|
label: tr(facet.label),
|
|
179
|
+
...placement,
|
|
172
180
|
options: [
|
|
173
181
|
{ value: "true", label: tr(facet.trueLabel) },
|
|
174
182
|
{ value: "false", label: tr(facet.falseLabel) },
|
|
@@ -182,6 +190,7 @@ export function resolveProjectionFacetSpecs(facets, translate, featureName) {
|
|
|
182
190
|
field: facet.field,
|
|
183
191
|
type: "reference",
|
|
184
192
|
label: tr(facet.label),
|
|
193
|
+
...placement,
|
|
185
194
|
options: [],
|
|
186
195
|
reference: {
|
|
187
196
|
refEntity: target.entityName,
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { ListSortOption } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { Translate } from "../headless/index.ts";
|
|
3
|
+
import type { DataTableProps } from "../primitives.tsx";
|
|
4
|
+
export declare function translatedSortOptionProps(sortOptions: readonly ListSortOption[] | undefined, translate: Translate): Pick<DataTableProps, "sortOptions">;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export function translatedSortOptionProps(sortOptions, translate) {
|
|
2
|
+
if (sortOptions === undefined || sortOptions.length === 0)
|
|
3
|
+
return {};
|
|
4
|
+
return {
|
|
5
|
+
sortOptions: sortOptions.map((option) => ({
|
|
6
|
+
field: option.field,
|
|
7
|
+
dir: option.dir,
|
|
8
|
+
label: translate(option.label),
|
|
9
|
+
})),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -1,12 +1,25 @@
|
|
|
1
|
-
import type { NamedListFilterRef } from "@cosmicdrift/kumiko-types/named-list-filters";
|
|
1
|
+
import type { NamedFilterFacetOptions, NamedListFilterRef } from "@cosmicdrift/kumiko-types/named-list-filters";
|
|
2
|
+
import type { NamedFilterEmptyContent } from "../components/list-empty-state.tsx";
|
|
2
3
|
import type { Translate } from "../headless/index.ts";
|
|
3
4
|
import type { ListUrlStateApi } from "../hooks/use-list-url-state.ts";
|
|
4
5
|
import type { DataTableFacet } from "../primitives.tsx";
|
|
6
|
+
import type { FacetCountQuery } from "./facet-count-bridge.tsx";
|
|
5
7
|
export declare const NAMED_FILTER_FACET_FIELD = "__namedFilter";
|
|
6
8
|
type NamedFilterUrlState = Pick<ListUrlStateApi, "namedFilter" | "setFilter" | "setNamedFilter">;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
+
export declare function namedFilterCountKey(id: string | undefined): string;
|
|
10
|
+
/** One toggle chip (or one select entry) per named filter the user may open, rendered by the facet row. */
|
|
11
|
+
export declare function buildNamedFilterFacet(allRefs: readonly NamedListFilterRef[] | undefined, translate: Translate, userRoles: readonly string[] | undefined, options?: NamedFilterFacetOptions, counts?: Readonly<Record<string, number>>): DataTableFacet | undefined;
|
|
12
|
+
/** The list payload of one named filter reduced to a count: no sort and no paging, one row, the total. */
|
|
13
|
+
export declare function namedFilterCountPayload(listPayload: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
14
|
+
/** One count query per offered filter plus one for "all"; each takes the very payload the list would send for that filter. */
|
|
15
|
+
export declare function buildNamedFilterCountQueries(allRefs: readonly NamedListFilterRef[] | undefined, userRoles: readonly string[] | undefined, options: NamedFilterFacetOptions | undefined, listPayloadFor: (namedFilter: string | undefined) => Readonly<Record<string, unknown>>): FacetCountQuery[];
|
|
9
16
|
export declare function withNamedFilterValues(filters: Readonly<Record<string, readonly string[]>>, namedFilter: string | undefined): Readonly<Record<string, readonly string[]>>;
|
|
10
17
|
/** Pressing the active chip again removes it. */
|
|
11
18
|
export declare function routeFacetChange(urlState: NamedFilterUrlState): (field: string, values: readonly string[]) => void;
|
|
19
|
+
/** The active filter's sort, unless the URL set one: ref.sort wins over the screen default. */
|
|
20
|
+
export declare function namedFilterSort(allRefs: readonly NamedListFilterRef[] | undefined, activeNamedFilter: string | undefined): NamedListFilterRef["sort"];
|
|
21
|
+
/** URL sort, else the named filter's sort, else the screen default. */
|
|
22
|
+
export declare function resolveListSort(urlSort: ListUrlStateApi["sort"], allRefs: readonly NamedListFilterRef[] | undefined, namedFilter: string | undefined, defaultSort: ListUrlStateApi["sort"] | undefined): ListUrlStateApi["sort"];
|
|
23
|
+
/** Only while the filter alone explains the empty list: a search term or another narrowing would make the sentence wrong. */
|
|
24
|
+
export declare function buildNamedFilterEmpty(allRefs: readonly NamedListFilterRef[] | undefined, activeNamedFilter: string | undefined, search: string, otherNarrowing: boolean, translate: Translate, onReset: () => void): NamedFilterEmptyContent | undefined;
|
|
12
25
|
export {};
|
|
@@ -1,16 +1,80 @@
|
|
|
1
|
+
import { isUiAccessGranted } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
2
|
// Not a real field: keeps the named filter out of the `.f.<field>` facet namespace.
|
|
2
3
|
export const NAMED_FILTER_FACET_FIELD = "__namedFilter";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const NAMED_FILTER_ALL_CHIP_ID = "all";
|
|
5
|
+
// `undefined` is the "all" entry: the list without any named filter.
|
|
6
|
+
export function namedFilterCountKey(id) {
|
|
7
|
+
return `${NAMED_FILTER_FACET_FIELD}:${id ?? ""}`;
|
|
8
|
+
}
|
|
9
|
+
function offeredRefs(allRefs, userRoles) {
|
|
10
|
+
return allRefs?.filter((ref) => isUiAccessGranted(ref.access, userRoles)) ?? [];
|
|
11
|
+
}
|
|
12
|
+
/** One toggle chip (or one select entry) per named filter the user may open, rendered by the facet row. */
|
|
13
|
+
export function buildNamedFilterFacet(allRefs, translate, userRoles, options, counts = {}) {
|
|
14
|
+
const refs = offeredRefs(allRefs, userRoles);
|
|
15
|
+
if (refs.length === 0)
|
|
6
16
|
return undefined;
|
|
17
|
+
const isSelect = options?.display === "select";
|
|
18
|
+
const showCounts = options?.showCounts === true;
|
|
19
|
+
const hideEmpty = options?.hideEmpty === true;
|
|
20
|
+
const countOf = (id) => {
|
|
21
|
+
const count = showCounts || hideEmpty ? counts[namedFilterCountKey(id)] : undefined;
|
|
22
|
+
return count === undefined ? {} : { count };
|
|
23
|
+
};
|
|
24
|
+
const chips = refs.map((ref) => ({
|
|
25
|
+
id: ref.id,
|
|
26
|
+
label: translate(ref.label),
|
|
27
|
+
values: [ref.id],
|
|
28
|
+
...(ref.separatorAfter === true && { separatorAfter: true }),
|
|
29
|
+
...countOf(ref.id),
|
|
30
|
+
}));
|
|
7
31
|
return {
|
|
8
32
|
field: NAMED_FILTER_FACET_FIELD,
|
|
9
|
-
label:
|
|
33
|
+
label: options?.label !== undefined
|
|
34
|
+
? translate(options.label)
|
|
35
|
+
: refs.map((ref) => translate(ref.label)).join(" / "),
|
|
10
36
|
options: refs.map((ref) => ({ value: ref.id, label: translate(ref.label) })),
|
|
11
|
-
chips:
|
|
37
|
+
chips: isSelect
|
|
38
|
+
? [
|
|
39
|
+
{
|
|
40
|
+
id: NAMED_FILTER_ALL_CHIP_ID,
|
|
41
|
+
label: translate("kumiko.list.named-filter.all"),
|
|
42
|
+
values: [],
|
|
43
|
+
...countOf(undefined),
|
|
44
|
+
},
|
|
45
|
+
...chips,
|
|
46
|
+
]
|
|
47
|
+
: chips,
|
|
48
|
+
...(isSelect && { display: "select" }),
|
|
49
|
+
...(options?.narrowPlacement !== undefined && { narrowPlacement: options.narrowPlacement }),
|
|
50
|
+
...(showCounts && { showCounts: true }),
|
|
51
|
+
...(hideEmpty && { hideEmpty: true }),
|
|
12
52
|
};
|
|
13
53
|
}
|
|
54
|
+
/** The list payload of one named filter reduced to a count: no sort and no paging, one row, the total. */
|
|
55
|
+
export function namedFilterCountPayload(listPayload) {
|
|
56
|
+
const payload = { ...listPayload, limit: 1, totalCount: true };
|
|
57
|
+
for (const pagingOrSortKey of ["sort", "sortDirection", "offset", "cursor"]) {
|
|
58
|
+
delete payload[pagingOrSortKey];
|
|
59
|
+
}
|
|
60
|
+
return payload;
|
|
61
|
+
}
|
|
62
|
+
/** One count query per offered filter plus one for "all"; each takes the very payload the list would send for that filter. */
|
|
63
|
+
export function buildNamedFilterCountQueries(allRefs, userRoles, options, listPayloadFor) {
|
|
64
|
+
if (options?.showCounts !== true && options?.hideEmpty !== true)
|
|
65
|
+
return [];
|
|
66
|
+
const refs = offeredRefs(allRefs, userRoles);
|
|
67
|
+
if (refs.length === 0)
|
|
68
|
+
return [];
|
|
69
|
+
const ids = [
|
|
70
|
+
...(options.display === "select" ? [undefined] : []),
|
|
71
|
+
...refs.map((ref) => ref.id),
|
|
72
|
+
];
|
|
73
|
+
return ids.map((id) => ({
|
|
74
|
+
key: namedFilterCountKey(id),
|
|
75
|
+
payload: namedFilterCountPayload(listPayloadFor(id)),
|
|
76
|
+
}));
|
|
77
|
+
}
|
|
14
78
|
export function withNamedFilterValues(filters, namedFilter) {
|
|
15
79
|
return namedFilter === undefined
|
|
16
80
|
? filters
|
|
@@ -28,3 +92,31 @@ export function routeFacetChange(urlState) {
|
|
|
28
92
|
urlState.setNamedFilter(picked === urlState.namedFilter ? undefined : picked);
|
|
29
93
|
};
|
|
30
94
|
}
|
|
95
|
+
/** The active filter's sort, unless the URL set one: ref.sort wins over the screen default. */
|
|
96
|
+
export function namedFilterSort(allRefs, activeNamedFilter) {
|
|
97
|
+
return allRefs?.find((ref) => ref.id === activeNamedFilter)?.sort;
|
|
98
|
+
}
|
|
99
|
+
/** URL sort, else the named filter's sort, else the screen default. */
|
|
100
|
+
export function resolveListSort(urlSort, allRefs, namedFilter, defaultSort) {
|
|
101
|
+
return urlSort ?? namedFilterSort(allRefs, namedFilter) ?? defaultSort ?? null;
|
|
102
|
+
}
|
|
103
|
+
/** Only while the filter alone explains the empty list: a search term or another narrowing would make the sentence wrong. */
|
|
104
|
+
export function buildNamedFilterEmpty(allRefs, activeNamedFilter, search, otherNarrowing, translate, onReset) {
|
|
105
|
+
const emptyState = allRefs?.find((ref) => ref.id === activeNamedFilter)?.emptyState;
|
|
106
|
+
if (emptyState === undefined || otherNarrowing || search.trim() !== "")
|
|
107
|
+
return undefined;
|
|
108
|
+
const { title, description, paramsQuery } = emptyState;
|
|
109
|
+
return {
|
|
110
|
+
title: translate(title),
|
|
111
|
+
...(description !== undefined &&
|
|
112
|
+
(paramsQuery === undefined
|
|
113
|
+
? { description: translate(description) }
|
|
114
|
+
: {
|
|
115
|
+
describedByQuery: {
|
|
116
|
+
query: paramsQuery,
|
|
117
|
+
describe: (params) => translate(description, params),
|
|
118
|
+
},
|
|
119
|
+
})),
|
|
120
|
+
onReset,
|
|
121
|
+
};
|
|
122
|
+
}
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import type { ProjectionDetailScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
1
|
import { type ReactNode } from "react";
|
|
3
2
|
import type { Translate } from "../headless/index.ts";
|
|
4
3
|
import type { FeatureSchema } from "./feature-schema.ts";
|
|
4
|
+
import { type ProjectionDetailScreenWithTarget } from "./projection-detail-states.tsx";
|
|
5
5
|
export declare function ProjectionDetailBody({ schema, screen, translate, entityId, }: {
|
|
6
6
|
readonly schema: FeatureSchema;
|
|
7
|
-
readonly screen:
|
|
8
|
-
readonly detailFor?: string;
|
|
9
|
-
};
|
|
7
|
+
readonly screen: ProjectionDetailScreenWithTarget;
|
|
10
8
|
readonly translate?: Translate;
|
|
11
9
|
readonly entityId?: string;
|
|
12
10
|
}): ReactNode;
|