@cosmicdrift/kumiko-renderer 0.413.0 → 0.414.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 +30 -50
- package/dist/app/form-schema.d.ts +1 -0
- package/dist/app/form-schema.js +24 -0
- 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 +17 -3
- package/dist/app/named-filter-facet.js +88 -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 +101 -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 +75 -18
- 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 +19 -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 +25 -0
- package/dist/app/use-entity-list-payload.js +57 -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 +4 -4
- package/dist/app/use-projection-detail-actions.js +30 -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 +11 -0
- package/dist/app/use-row-decoration.js +55 -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/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/form-pending-uploads.d.ts +8 -0
- package/dist/components/form-pending-uploads.js +27 -0
- package/dist/components/list-empty-state.d.ts +8 -1
- package/dist/components/list-empty-state.js +4 -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-form-actions.js +6 -3
- package/dist/components/render-edit-layout.js +2 -1
- package/dist/components/render-edit-render-model.d.ts +2 -2
- package/dist/components/render-edit-submit.js +2 -1
- 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 +8 -0
- package/dist/components/render-list-hint-columns.js +77 -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 +3 -0
- 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 +5 -4
- 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 +4 -0
- package/dist/components/use-render-edit-state.js +9 -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 +2 -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 +1 -0
- package/dist/headless/pwa-service-worker-meta.js +3 -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 +33 -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 +37 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +5 -1
- package/dist/live/dispatcher-live.js +2 -0
- package/dist/metric-types.d.ts +2 -0
- package/dist/primitives-record-guidance.d.ts +53 -0
- package/dist/primitives-record-guidance.js +1 -0
- package/dist/primitives.d.ts +41 -31
- 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 +149 -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 +6 -23
- package/dist/web/app/dashboard-panels.js +53 -123
- package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
- package/dist/web/app/dashboard-reference-list-table.js +12 -4
- package/dist/web/app/dashboard-shared.d.ts +23 -7
- package/dist/web/app/dashboard-shared.js +44 -17
- package/dist/web/app/dashboard-stat-group-panel.d.ts +13 -0
- package/dist/web/app/dashboard-stat-group-panel.js +67 -0
- package/dist/web/app/dashboard-text-panel.d.ts +12 -0
- package/dist/web/app/dashboard-text-panel.js +163 -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/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/index.d.ts +7 -1
- package/dist/web/index.js +5 -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 +5 -0
- package/dist/web/layout/nav-collapse-state.js +66 -0
- package/dist/web/layout/nav-tree.js +25 -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 +6 -5
- package/dist/web/layout/shell-focus.js +12 -9
- package/dist/web/layout/shell-header.js +38 -10
- 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.js +6 -4
- 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 +14 -6
- package/dist/web/primitives/calendar-day-picker.js +24 -5
- package/dist/web/primitives/card.js +1 -1
- package/dist/web/primitives/code-input.js +6 -1
- package/dist/web/primitives/data-table/actions-column.d.ts +1 -0
- package/dist/web/primitives/data-table/actions-column.js +4 -2
- package/dist/web/primitives/data-table/card-body.d.ts +5 -0
- package/dist/web/primitives/data-table/card-body.js +47 -5
- 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 +40 -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 +16 -0
- package/dist/web/primitives/data-table/hint-cell.js +74 -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/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 +10 -5
- 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 +17 -3
- package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +31 -3
- package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
- package/dist/web/primitives/data-table/totals-footer.js +40 -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 +96 -19
- package/dist/web/primitives/embedded-file-cell.js +10 -6
- package/dist/web/primitives/embedded-list-cards.js +3 -4
- package/dist/web/primitives/facet-filter.d.ts +4 -2
- package/dist/web/primitives/facet-filter.js +26 -3
- package/dist/web/primitives/facet-search-filter.js +1 -1
- 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 +15 -11
- package/dist/web/primitives/file-view-action.d.ts +6 -0
- package/dist/web/primitives/file-view-action.js +19 -0
- package/dist/web/primitives/files-dropzone.js +18 -4
- 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 +2 -2
- package/dist/web/primitives/metric.js +8 -6
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +29 -18
- 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 +45 -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 +5 -7
- package/dist/web/pwa/pwa-support.d.ts +4 -0
- package/dist/web/pwa/pwa-support.js +113 -0
- package/dist/web/sse/live-events.js +2 -2
- package/dist/web/tokens.js +0 -3
- 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 +54 -0
- package/dist/web/widgets/dashboard-list.d.ts +37 -5
- package/dist/web/widgets/dashboard-list.js +95 -20
- package/dist/web/widgets/drawer-sizing.js +1 -1
- 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/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/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 +10 -1
- package/dist/web/widgets/stat.js +14 -5
- 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/upload-zone.d.ts +8 -1
- package/dist/web/widgets/upload-zone.js +13 -3
- package/package.json +5 -5
- package/src/changes.json +223 -0
- package/src/web/styles.css +9 -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,6 @@
|
|
|
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 { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
5
4
|
import { useCallback, useEffect, useMemo, useState } from "react";
|
|
6
5
|
import { ListGroupPageBridges } from "../components/list-group-page-bridges.js";
|
|
7
6
|
import { RenderList } from "../components/render-list.js";
|
|
@@ -24,6 +23,7 @@ import { FacetCountBridges } from "./facet-count-bridge.js";
|
|
|
24
23
|
import { useListBulk } from "./list-bulk-actions.js";
|
|
25
24
|
import { isDefaultFilterActive, isListNarrowed, useListEmptyContent, } from "./list-empty-content.js";
|
|
26
25
|
import { buildEntityFilterFacets, buildFacetCountRequests, buildFilterPayload, mergeReferenceFacetOptions, normalizeDefaultFilters, } from "./list-facets.js";
|
|
26
|
+
import { translatedSortOptionProps } from "./list-sort-options.js";
|
|
27
27
|
import { buildNamedFilterFacet, routeFacetChange, withNamedFilterValues, } from "./named-filter-facet.js";
|
|
28
28
|
import { NamedFilterRemove } from "./named-filter-remove.js";
|
|
29
29
|
import { useNav } from "./nav.js";
|
|
@@ -32,9 +32,12 @@ import { ReferenceFacetBridges, withReferenceFacetState, } from "./reference-fac
|
|
|
32
32
|
import { navigateWithReturnTo, useReturnHost } from "./return-to.js";
|
|
33
33
|
import { buildClientActionRowAction, buildDefaultEditRowAction, buildDrawerRowAction, buildProjectionToolbarActions, buildWriteHandlerRowAction, findRowClickAction, navigateActionSearchParams, runDrawerRowAction, } from "./row-actions.js";
|
|
34
34
|
import { findEditScreenFor } from "./screen-access.js";
|
|
35
|
-
import {
|
|
35
|
+
import { entityQueryCommand, isEntityEditScreenOfEntity, useNavigateToCreateFor, } from "./screen-shared.js";
|
|
36
|
+
import { useEntityListPayload } from "./use-entity-list-payload.js";
|
|
36
37
|
import { useEntityRangeFacets } from "./use-entity-range-facets.js";
|
|
38
|
+
import { useFacetCounts } from "./use-facet-counts.js";
|
|
37
39
|
import { useGatedToolbarActions } from "./use-gated-toolbar-actions.js";
|
|
40
|
+
import { useNamedFilterQueue } from "./use-named-filter-queue.js";
|
|
38
41
|
import { listPager, useScreenListRows } from "./use-screen-list-rows.js";
|
|
39
42
|
import { useScreenListTable } from "./use-screen-list-table.js";
|
|
40
43
|
export function EntityListScreen({ schema, screen, translate, onRowClick, }) {
|
|
@@ -73,7 +76,6 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
73
76
|
const urlState = useListUrlState(screen.id, defaultFilters);
|
|
74
77
|
// Gated on the screen offering named filters, so a stale URL cannot send a param the list rejects.
|
|
75
78
|
const activeNamedFilter = screen.namedFilters === undefined ? undefined : urlState.namedFilter;
|
|
76
|
-
const effectiveSort = urlState.sort ?? screen.defaultSort ?? null;
|
|
77
79
|
const limit = urlState.pageSize ?? screen.pageSize ?? 50;
|
|
78
80
|
const paginationMode = screen.pagination ?? "pages";
|
|
79
81
|
const usePager = paginationMode === "pages";
|
|
@@ -90,52 +92,26 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
90
92
|
translate: effectiveTranslate,
|
|
91
93
|
urlState,
|
|
92
94
|
});
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
// the schema); boundary cast like buildInitialValues.
|
|
99
|
-
const type = propertyOf(entity.fields[field], "type");
|
|
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
|
-
}, [
|
|
95
|
+
const { filterPayload, listPayloadFor, queryPayload, effectiveSort } = useEntityListPayload({
|
|
96
|
+
screen,
|
|
97
|
+
entity,
|
|
98
|
+
urlState,
|
|
99
|
+
rangeFilters: range.rangeFilters,
|
|
128
100
|
activeNamedFilter,
|
|
129
101
|
limit,
|
|
130
|
-
urlState.q,
|
|
131
|
-
effectiveSort,
|
|
132
|
-
screen.filter,
|
|
133
|
-
filterPayload,
|
|
134
|
-
range.rangeFilters,
|
|
135
102
|
usePager,
|
|
136
|
-
urlState.page,
|
|
137
103
|
useInfinite,
|
|
138
|
-
|
|
104
|
+
});
|
|
105
|
+
const { namedFilterCountQueries, namedFilterEmpty } = useNamedFilterQueue({
|
|
106
|
+
screen,
|
|
107
|
+
urlState,
|
|
108
|
+
userRoles,
|
|
109
|
+
translate: effectiveTranslate,
|
|
110
|
+
filterPayload,
|
|
111
|
+
rangeFilters: range.rangeFilters,
|
|
112
|
+
activeNamedFilter,
|
|
113
|
+
listPayloadFor,
|
|
114
|
+
});
|
|
139
115
|
// Facet counts come from their own queries, which a write leaves untouched.
|
|
140
116
|
const [facetCountRefreshNonce, setFacetCountRefreshNonce] = useState(0);
|
|
141
117
|
const refreshFacetCounts = useCallback(() => setFacetCountRefreshNonce((n) => n + 1), []);
|
|
@@ -160,6 +136,8 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
160
136
|
payload: queryPayload,
|
|
161
137
|
infinite: useInfinite,
|
|
162
138
|
aggregates: listTable.aggregates,
|
|
139
|
+
rowDecoration: screen.rowDecoration,
|
|
140
|
+
restoring: listTable.restoring,
|
|
163
141
|
});
|
|
164
142
|
const { refreshAfterWrite: refreshListAfterWrite } = listRows;
|
|
165
143
|
const refreshRowsAfterWrite = useCallback(async () => {
|
|
@@ -168,10 +146,9 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
168
146
|
}, [refreshFacetCounts, refreshListAfterWrite]);
|
|
169
147
|
const [entityReferenceFacetOptions, setEntityReferenceFacetOptions] = useState({});
|
|
170
148
|
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 })), []);
|
|
149
|
+
const { facetCounts, handleFacetCount } = useFacetCounts();
|
|
173
150
|
const filterFacets = useMemo(() => {
|
|
174
|
-
const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate);
|
|
151
|
+
const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate, userRoles, screen.namedFilterFacet, facetCounts);
|
|
175
152
|
return [
|
|
176
153
|
...(namedFacet !== undefined ? [namedFacet] : []),
|
|
177
154
|
...buildEntityFilterFacets(mergeReferenceFacetOptions(entityFacetSpecs, entityReferenceFacetOptions), screen.facets, effectiveTranslate, facetCounts),
|
|
@@ -181,7 +158,9 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
181
158
|
entityReferenceFacetOptions,
|
|
182
159
|
screen.facets,
|
|
183
160
|
screen.namedFilters,
|
|
161
|
+
screen.namedFilterFacet,
|
|
184
162
|
effectiveTranslate,
|
|
163
|
+
userRoles,
|
|
185
164
|
facetCounts,
|
|
186
165
|
]);
|
|
187
166
|
const filterValues = useMemo(() => withNamedFilterValues(urlState.filters, activeNamedFilter), [urlState.filters, activeNamedFilter]);
|
|
@@ -213,6 +192,7 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
213
192
|
entity.fields,
|
|
214
193
|
range.rangeFilters,
|
|
215
194
|
]);
|
|
195
|
+
const allFacetCountQueries = useMemo(() => [...namedFilterCountQueries, ...facetCountQueries], [namedFilterCountQueries, facetCountQueries]);
|
|
216
196
|
// Soft dispatcher: in tests that mount without a DispatcherProvider,
|
|
217
197
|
// rowActions stays undefined instead of crashing. Real apps have the
|
|
218
198
|
// provider via createKumikoApp; if it is missing it is most likely a setup
|
|
@@ -418,8 +398,8 @@ function EntityListBody({ schema, screen, entity, translate, onRowClick, }) {
|
|
|
418
398
|
// arrives async; until it is there RenderList renders the table without a
|
|
419
399
|
// pager (the pager has its own total>0 guard).
|
|
420
400
|
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
|
|
401
|
+
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 ||
|
|
402
|
+
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
403
|
? { screenPadding: false, chromeless: true }
|
|
424
404
|
: { 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
405
|
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
|
+
}
|
|
@@ -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,26 @@
|
|
|
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
|
-
export declare function
|
|
9
|
+
export declare function isNamedFilterOffered(ref: NamedListFilterRef, userRoles: readonly string[] | undefined): boolean;
|
|
10
|
+
export declare function namedFilterCountKey(id: string | undefined): string;
|
|
11
|
+
/** One toggle chip (or one select entry) per named filter the user may open, rendered by the facet row. */
|
|
12
|
+
export declare function buildNamedFilterFacet(allRefs: readonly NamedListFilterRef[] | undefined, translate: Translate, userRoles: readonly string[] | undefined, options?: NamedFilterFacetOptions, counts?: Readonly<Record<string, number>>): DataTableFacet | undefined;
|
|
13
|
+
/** The list payload of one named filter reduced to a count: no sort and no paging, one row, the total. */
|
|
14
|
+
export declare function namedFilterCountPayload(listPayload: Readonly<Record<string, unknown>>): Record<string, unknown>;
|
|
15
|
+
/** One count query per offered filter plus one for "all"; each takes the very payload the list would send for that filter. */
|
|
16
|
+
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
17
|
export declare function withNamedFilterValues(filters: Readonly<Record<string, readonly string[]>>, namedFilter: string | undefined): Readonly<Record<string, readonly string[]>>;
|
|
10
18
|
/** Pressing the active chip again removes it. */
|
|
11
19
|
export declare function routeFacetChange(urlState: NamedFilterUrlState): (field: string, values: readonly string[]) => void;
|
|
20
|
+
/** The active filter's sort, unless the URL set one: ref.sort wins over the screen default. */
|
|
21
|
+
export declare function namedFilterSort(allRefs: readonly NamedListFilterRef[] | undefined, activeNamedFilter: string | undefined): NamedListFilterRef["sort"];
|
|
22
|
+
/** URL sort, else the named filter's sort, else the screen default. */
|
|
23
|
+
export declare function resolveListSort(urlSort: ListUrlStateApi["sort"], allRefs: readonly NamedListFilterRef[] | undefined, namedFilter: string | undefined, defaultSort: ListUrlStateApi["sort"] | undefined): ListUrlStateApi["sort"];
|
|
24
|
+
/** Only while the filter alone explains the empty list: a search term or another narrowing would make the sentence wrong. */
|
|
25
|
+
export declare function buildNamedFilterEmpty(allRefs: readonly NamedListFilterRef[] | undefined, activeNamedFilter: string | undefined, search: string, otherNarrowing: boolean, translate: Translate, onReset: () => void): NamedFilterEmptyContent | undefined;
|
|
12
26
|
export {};
|
|
@@ -1,16 +1,80 @@
|
|
|
1
1
|
// Not a real field: keeps the named filter out of the `.f.<field>` facet namespace.
|
|
2
2
|
export const NAMED_FILTER_FACET_FIELD = "__namedFilter";
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const NAMED_FILTER_ALL_CHIP_ID = "all";
|
|
4
|
+
// Unknown roles (undefined) deny a restricted filter, like role-gated screens do.
|
|
5
|
+
export function isNamedFilterOffered(ref, userRoles) {
|
|
6
|
+
const required = ref.roles;
|
|
7
|
+
return required === undefined || (userRoles ?? []).some((role) => required.includes(role));
|
|
8
|
+
}
|
|
9
|
+
// `undefined` is the "all" entry: the list without any named filter.
|
|
10
|
+
export function namedFilterCountKey(id) {
|
|
11
|
+
return `${NAMED_FILTER_FACET_FIELD}:${id ?? ""}`;
|
|
12
|
+
}
|
|
13
|
+
function offeredRefs(allRefs, userRoles) {
|
|
14
|
+
return allRefs?.filter((ref) => isNamedFilterOffered(ref, userRoles)) ?? [];
|
|
15
|
+
}
|
|
16
|
+
/** One toggle chip (or one select entry) per named filter the user may open, rendered by the facet row. */
|
|
17
|
+
export function buildNamedFilterFacet(allRefs, translate, userRoles, options, counts = {}) {
|
|
18
|
+
const refs = offeredRefs(allRefs, userRoles);
|
|
19
|
+
if (refs.length === 0)
|
|
6
20
|
return undefined;
|
|
21
|
+
const isSelect = options?.display === "select";
|
|
22
|
+
const showCounts = options?.showCounts === true;
|
|
23
|
+
const countOf = (id) => {
|
|
24
|
+
const count = showCounts ? counts[namedFilterCountKey(id)] : undefined;
|
|
25
|
+
return count === undefined ? {} : { count };
|
|
26
|
+
};
|
|
27
|
+
const chips = refs.map((ref) => ({
|
|
28
|
+
id: ref.id,
|
|
29
|
+
label: translate(ref.label),
|
|
30
|
+
values: [ref.id],
|
|
31
|
+
...countOf(ref.id),
|
|
32
|
+
}));
|
|
7
33
|
return {
|
|
8
34
|
field: NAMED_FILTER_FACET_FIELD,
|
|
9
|
-
label:
|
|
35
|
+
label: options?.label !== undefined
|
|
36
|
+
? translate(options.label)
|
|
37
|
+
: refs.map((ref) => translate(ref.label)).join(" / "),
|
|
10
38
|
options: refs.map((ref) => ({ value: ref.id, label: translate(ref.label) })),
|
|
11
|
-
chips:
|
|
39
|
+
chips: isSelect
|
|
40
|
+
? [
|
|
41
|
+
{
|
|
42
|
+
id: NAMED_FILTER_ALL_CHIP_ID,
|
|
43
|
+
label: translate("kumiko.list.named-filter.all"),
|
|
44
|
+
values: [],
|
|
45
|
+
...countOf(undefined),
|
|
46
|
+
},
|
|
47
|
+
...chips,
|
|
48
|
+
]
|
|
49
|
+
: chips,
|
|
50
|
+
...(isSelect && { display: "select" }),
|
|
51
|
+
...(showCounts && { showCounts: 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)
|
|
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,22 @@ 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
|
+
return {
|
|
109
|
+
title: translate(emptyState.title),
|
|
110
|
+
...(emptyState.description !== undefined && { description: translate(emptyState.description) }),
|
|
111
|
+
onReset,
|
|
112
|
+
};
|
|
113
|
+
}
|
|
@@ -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;
|
|
@@ -11,10 +11,12 @@ import { useDrawerAction } from "./action-form-body.js";
|
|
|
11
11
|
import { useAppFeatures } from "./app-features-context.js";
|
|
12
12
|
import { useClientActionRuntime } from "./client-actions.js";
|
|
13
13
|
import { useNav } from "./nav.js";
|
|
14
|
+
import { hasRecordGuidance } from "./projection-detail-guidance-data.js";
|
|
14
15
|
import { deriveDetailRegionPieces, renderDetailHeaderContent, } from "./projection-detail-header-region.js";
|
|
15
16
|
import { renderDetailQueryError, renderMissingIdBanner, renderRecordNotFound, } from "./projection-detail-states.js";
|
|
16
17
|
import { renderProjectionDrawerHost } from "./projection-drawer-host.js";
|
|
17
18
|
import { QueryLoadingBanner } from "./query-state-banners.js";
|
|
19
|
+
import { useReferenceLinkResolver } from "./reference-link.js";
|
|
18
20
|
import { useReturnHost, useReturnTarget } from "./return-to.js";
|
|
19
21
|
import { useProjectionDetailActions } from "./use-projection-detail-actions.js";
|
|
20
22
|
import { useProjectionDetailData } from "./use-projection-detail-data.js";
|
|
@@ -54,13 +56,14 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
|
54
56
|
const userRoles = useUserRoles();
|
|
55
57
|
const dispatcher = useOptionalDispatcher();
|
|
56
58
|
const clientActions = useClientActionRuntime();
|
|
59
|
+
const resolveReference = useReferenceLinkResolver();
|
|
57
60
|
const host = useReturnHost();
|
|
58
61
|
const returnTargetParam = useReturnTarget(screen.id);
|
|
59
62
|
// A singleton has no record route to come back to — same as entityEdit.
|
|
60
63
|
const returnTarget = screen.singleton === true ? undefined : returnTargetParam;
|
|
61
64
|
const drawer = useDrawerAction(schema);
|
|
62
65
|
const { openDrawer } = drawer;
|
|
63
|
-
const { buildSectionActions, headerActions } = useProjectionDetailActions({
|
|
66
|
+
const { buildSectionActions, buildItemActions, headerActions } = useProjectionDetailActions({
|
|
64
67
|
schema,
|
|
65
68
|
screen,
|
|
66
69
|
effectiveTranslate,
|
|
@@ -121,11 +124,14 @@ export function ProjectionDetailBody({ schema, screen, translate, entityId, }) {
|
|
|
121
124
|
hasTabs,
|
|
122
125
|
tabCounts,
|
|
123
126
|
activeSection,
|
|
127
|
+
resolveReference,
|
|
128
|
+
buildItemActions,
|
|
124
129
|
};
|
|
125
130
|
const regionPieces = deriveDetailRegionPieces(regionModel);
|
|
126
131
|
const renderHeaderContent = (headerSlot) => renderDetailHeaderContent(regionModel, regionPieces, headerSlot);
|
|
127
132
|
return (_jsxs(_Fragment, { children: [refetchErrorBanner, _jsx(RenderEdit, { refreshToken: reloadNonce, screen: renderedDetailScreen, entity: entity, featureName: schema.featureName, initial: record, entityId: effectiveEntityId, customSubmit: async () => ({ isSuccess: true, validationBlocked: false, data: undefined }), onReload: reloadDetail, onRelatedListDrawerAction: openDrawer, ...(translate !== undefined && { translate }), ...(hasTabs && { hideSectionTitles: true }), ...(screenFillsHeight(screen) && { fillScreenHeight: true }), ...((hasHeaderCard ||
|
|
128
133
|
hasTabs ||
|
|
134
|
+
hasRecordGuidance(screen) ||
|
|
129
135
|
screen.slots?.header !== undefined ||
|
|
130
136
|
screen.recordTitleField !== undefined) && {
|
|
131
137
|
headerRegion: renderHeaderContent,
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ProjectionDetailScreenDefinition, RecordBreadcrumbItem, RecordNotice, RecordProgress, RecordStep, SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
export declare function readTone(value: unknown): SelectOptionTone | undefined;
|
|
3
|
+
export declare function readBreadcrumbItems(value: unknown): RecordBreadcrumbItem[];
|
|
4
|
+
export declare function readNotice(value: unknown): RecordNotice | undefined;
|
|
5
|
+
export declare function readSteps(value: unknown): RecordStep[];
|
|
6
|
+
export declare function isRecordProgressArray(value: unknown): value is readonly RecordProgress[];
|
|
7
|
+
export declare function hasRecordGuidance(screen: ProjectionDetailScreenDefinition): boolean;
|