@cosmicdrift/kumiko-renderer 0.413.1 → 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/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-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 +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 +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 +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 +7 -2
- package/dist/index.js +4 -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 +3 -2
- 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 +3 -2
- 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 +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 +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 +217 -0
- package/src/web/styles.css +9 -0
|
@@ -1,14 +1,19 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from "react";
|
|
3
|
+
import { isSelectOptionTone } from "../status-tone.js";
|
|
3
4
|
import { ErrorReference } from "./error-reference.js";
|
|
4
5
|
import { HeaderActionsBar } from "./header-actions-bar.js";
|
|
5
|
-
import { headerStatusTone, resolveHeaderStatusText,
|
|
6
|
+
import { formatOrRaw, headerStatusTone, resolveHeaderStatusText, resolveSubtitleHref, } from "./projection-detail-header-model.js";
|
|
6
7
|
import { buildSubtitleParts, metricNavigateResolves, runMetricNavigate, } from "./projection-detail-navigation.js";
|
|
7
8
|
import { navigateTargetAllows } from "./screen-access.js";
|
|
8
|
-
export function renderHeaderActionsContent(model) {
|
|
9
|
+
export function renderHeaderActionsContent(model, pageHeaderOptions) {
|
|
9
10
|
const { screen, primitives, headerActionsList, setActionError } = model;
|
|
10
11
|
const { Grid, Button, Dialog, ActionOverflowMenu } = primitives;
|
|
11
|
-
return (_jsx(Grid, { columns: "auto", testId: "kumiko-screen-projection-detail-actions", children: _jsx(HeaderActionsBar, { actions: headerActionsList, Button: Button, Dialog: Dialog, ActionOverflowMenu: ActionOverflowMenu, onError: setActionError, ...(
|
|
12
|
+
return (_jsx(Grid, { columns: "auto", testId: "kumiko-screen-projection-detail-actions", children: _jsx(HeaderActionsBar, { actions: headerActionsList, Button: Button, Dialog: Dialog, ActionOverflowMenu: ActionOverflowMenu, onError: setActionError, ...(pageHeaderOptions !== undefined && {
|
|
13
|
+
collapseAfterPrimary: true,
|
|
14
|
+
compact: pageHeaderOptions.compact,
|
|
15
|
+
PageHeader: pageHeaderOptions.PageHeader,
|
|
16
|
+
}), ...(screen.primaryAction !== undefined && { preferredPrimaryId: screen.primaryAction }), ...(screen.inlineActions !== undefined && { inlineActionIds: screen.inlineActions }) }) }));
|
|
12
17
|
}
|
|
13
18
|
// Plain Text, not Heading — the Card title slot already renders as its own
|
|
14
19
|
// heading element (h3); nesting another heading (h1) inside it is invalid HTML.
|
|
@@ -19,20 +24,38 @@ export function renderHeaderTitleSlot(model) {
|
|
|
19
24
|
const statusText = resolveHeaderStatusText(screen, record, model.effectiveTranslate);
|
|
20
25
|
return header !== undefined ? (header.status !== undefined ? (_jsxs(Grid, { columns: "auto", children: [_jsx(Text, { testId: "kumiko-screen-projection-detail-title", children: String(record[header.title] ?? "") }), StatusBadge !== undefined ? (_jsx(StatusBadge, { value: statusText, tone: headerStatusTone(header, record), testId: "kumiko-screen-projection-detail-status" })) : (_jsx(Text, { testId: "kumiko-screen-projection-detail-status", children: statusText }))] })) : (_jsx(Text, { testId: "kumiko-screen-projection-detail-title", children: String(record[header.title] ?? "") }))) : undefined;
|
|
21
26
|
}
|
|
27
|
+
// Body title block under the breadcrumb: record title (the h1) and the grey subtitle. The status chip sits
|
|
28
|
+
// beside it only where the shell bar does not carry it (phone); on desktop the bar shows it.
|
|
29
|
+
export function renderRecordTitleBlock(model, titleText, statusBadge, subtitle, chipInBar) {
|
|
30
|
+
const { Grid, Heading, FillContainer } = model.primitives;
|
|
31
|
+
const block = (_jsxs(_Fragment, { children: [_jsxs(Grid, { columns: "auto", testId: "kumiko-screen-projection-detail-title-block", children: [_jsx(Heading, { variant: "page", testId: "kumiko-screen-projection-detail-title", children: titleText }), !chipInBar && statusBadge] }), subtitle] }));
|
|
32
|
+
return FillContainer !== undefined ? (_jsx(FillContainer, { className: "flex flex-col gap-1 px-6 pt-2", children: block })) : (block);
|
|
33
|
+
}
|
|
22
34
|
function renderSubtitleParts(model, subtitleParts) {
|
|
23
35
|
const { Text, Link } = model.primitives;
|
|
24
|
-
return (_jsx(Text, { testId: "kumiko-screen-projection-detail-subtitle", children: subtitleParts.map((part, index) => (_jsxs(Fragment, { children: [index > 0 && (_jsx(Text, { variant: "muted", decorative: true, children: " · " })), part.href !== undefined ? (_jsx(Link, { href: part.href, ...(part.onPress !== undefined && { onPress: part.onPress }), className: "underline", testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text })) : (_jsx(Text, { testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text }))] }, part.field))) }));
|
|
36
|
+
return (_jsx(Text, { variant: "muted", testId: "kumiko-screen-projection-detail-subtitle", children: subtitleParts.map((part, index) => (_jsxs(Fragment, { children: [index > 0 && (_jsx(Text, { variant: "muted", decorative: true, children: " · " })), part.href !== undefined ? (_jsx(Link, { href: part.href, ...(part.onPress !== undefined && { onPress: part.onPress }), className: "underline", testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text })) : (_jsx(Text, { testId: `kumiko-screen-projection-detail-subtitle-${part.field}`, children: part.text }))] }, part.field))) }));
|
|
25
37
|
}
|
|
26
|
-
function renderSubtitleField(model, subtitleField) {
|
|
38
|
+
function renderSubtitleField(model, subtitleField, testId = "kumiko-screen-projection-detail-subtitle") {
|
|
27
39
|
const { screen, record, primitives } = model;
|
|
28
40
|
const { Text, Link } = primitives;
|
|
29
41
|
const subtitleText = String(record[subtitleField] ?? "");
|
|
30
42
|
if (subtitleText === "")
|
|
31
43
|
return undefined;
|
|
32
44
|
const subtitleHref = resolveSubtitleHref(screen.header, record);
|
|
33
|
-
return subtitleHref !== undefined ? (_jsx(Link, { href: subtitleHref, target: "_blank", testId:
|
|
45
|
+
return subtitleHref !== undefined ? (_jsx(Link, { href: subtitleHref, target: "_blank", testId: testId, children: subtitleText })) : (_jsx(Text, { variant: "muted", testId: testId, children: subtitleText }));
|
|
34
46
|
}
|
|
35
47
|
export function renderHeaderSubtitleSlot(model) {
|
|
48
|
+
const full = renderFullSubtitle(model);
|
|
49
|
+
const narrowField = model.screen.header?.narrowSubtitle;
|
|
50
|
+
if (narrowField === undefined)
|
|
51
|
+
return full;
|
|
52
|
+
const narrow = renderSubtitleField(model, narrowField, "kumiko-screen-projection-detail-narrow-subtitle");
|
|
53
|
+
const { FillContainer } = model.primitives;
|
|
54
|
+
if (narrow === undefined || FillContainer === undefined)
|
|
55
|
+
return full;
|
|
56
|
+
return (_jsxs(_Fragment, { children: [full !== undefined && _jsx(FillContainer, { className: "max-sm:hidden", children: full }), narrow !== undefined && _jsx(FillContainer, { className: "sm:hidden", children: narrow })] }));
|
|
57
|
+
}
|
|
58
|
+
function renderFullSubtitle(model) {
|
|
36
59
|
const { screen, record, nav, appFeatures, userRoles, host } = model;
|
|
37
60
|
const header = screen.header;
|
|
38
61
|
const subtitleParts = header !== undefined && typeof header.subtitle === "object"
|
|
@@ -46,27 +69,61 @@ export function renderHeaderSubtitleSlot(model) {
|
|
|
46
69
|
? renderSubtitleField(model, header.subtitle)
|
|
47
70
|
: undefined;
|
|
48
71
|
}
|
|
72
|
+
const METRIC_TONE_BY_SELECT_TONE = {
|
|
73
|
+
ok: "ok",
|
|
74
|
+
warn: "warn",
|
|
75
|
+
bad: "negative",
|
|
76
|
+
critical: "negative",
|
|
77
|
+
accent: "default",
|
|
78
|
+
neutral: "default",
|
|
79
|
+
};
|
|
80
|
+
function metricFieldTone(toneField, record) {
|
|
81
|
+
if (toneField === undefined)
|
|
82
|
+
return undefined;
|
|
83
|
+
const fieldTone = record[toneField];
|
|
84
|
+
return isSelectOptionTone(fieldTone) ? METRIC_TONE_BY_SELECT_TONE[fieldTone] : undefined;
|
|
85
|
+
}
|
|
86
|
+
function metricSubline(subField, record) {
|
|
87
|
+
const raw = subField === undefined ? undefined : record[subField];
|
|
88
|
+
if (typeof raw === "string")
|
|
89
|
+
return raw === "" ? undefined : raw;
|
|
90
|
+
return typeof raw === "number" ? String(raw) : undefined;
|
|
91
|
+
}
|
|
92
|
+
function metricLabel(metric, record, translate) {
|
|
93
|
+
const fromRecord = metric.labelField === undefined ? undefined : record[metric.labelField];
|
|
94
|
+
return typeof fromRecord === "string" && fromRecord !== "" ? fromRecord : translate(metric.label);
|
|
95
|
+
}
|
|
96
|
+
function metricPressHandler(model, metric) {
|
|
97
|
+
const { record, nav, appFeatures, userRoles, host } = model;
|
|
98
|
+
const navigate = metric.navigate;
|
|
99
|
+
return navigate !== undefined &&
|
|
100
|
+
metricNavigateResolves(navigate, record) &&
|
|
101
|
+
navigateTargetAllows(navigate, appFeatures, userRoles)
|
|
102
|
+
? () => runMetricNavigate(nav, navigate, record, host)
|
|
103
|
+
: undefined;
|
|
104
|
+
}
|
|
105
|
+
// Same rule as the dashboard stat panels: a fixed tone must not paint an all-clear 0.
|
|
106
|
+
function metricTone(metric, record, rawValue) {
|
|
107
|
+
return metricFieldTone(metric.toneField, record) ?? (rawValue === 0 ? undefined : metric.tone);
|
|
108
|
+
}
|
|
49
109
|
// slots.header shares the header card with the actions (one card, actions
|
|
50
110
|
// top right) instead of rendering as an unframed block above it.
|
|
51
111
|
export function buildMetricItems(model) {
|
|
52
|
-
const { screen, record, primitives, effectiveTranslate
|
|
112
|
+
const { screen, record, primitives, effectiveTranslate } = model;
|
|
53
113
|
const { Metric, GridCell, Text } = primitives;
|
|
54
114
|
return screen.metrics?.map((metric) => {
|
|
55
115
|
const field = metric.field;
|
|
56
|
-
const label =
|
|
116
|
+
const label = metricLabel(metric, record, effectiveTranslate);
|
|
57
117
|
const rawValue = record[field];
|
|
58
|
-
const value =
|
|
118
|
+
const value = formatOrRaw(metric.format, rawValue, effectiveTranslate);
|
|
59
119
|
const tiles = screen.metricsStyle === "tiles";
|
|
60
|
-
|
|
61
|
-
const
|
|
120
|
+
const tone = metricTone(metric, record, rawValue);
|
|
121
|
+
const sub = metricSubline(metric.subField, record);
|
|
62
122
|
const testId = `kumiko-screen-projection-detail-metric-${field}`;
|
|
63
|
-
const
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
? () => runMetricNavigate(nav, navigate, record, host)
|
|
68
|
-
: undefined;
|
|
69
|
-
return Metric !== undefined ? (_jsx(Metric, { label: label, value: value, testId: testId, ...(onPress !== undefined && { onPress }), ...(tiles && { tile: true }), ...(tone !== undefined && { tone }), ...(metric.icon !== undefined && { icon: metric.icon }) }, field)) : (_jsxs(GridCell, { children: [_jsx(Text, { variant: "small", testId: `${testId}-label`, children: label }), _jsx(Text, { testId: `${testId}-value`, children: value })] }, field));
|
|
123
|
+
const onPress = metricPressHandler(model, metric);
|
|
124
|
+
const item = Metric !== undefined ? (_jsx(Metric, { label: label, value: value, testId: testId, ...(onPress !== undefined && { onPress }), ...(tiles && { tile: true }), ...(tone !== undefined && { tone }), ...(metric.icon !== undefined && { icon: metric.icon }), ...(sub !== undefined && { sub }) }, field)) : (_jsxs(GridCell, { children: [_jsx(Text, { variant: "small", testId: `${testId}-label`, children: label }), _jsx(Text, { testId: `${testId}-value`, children: value })] }, field));
|
|
125
|
+
const { FillContainer } = primitives;
|
|
126
|
+
return metric.hideOnNarrow === true && FillContainer !== undefined ? (_jsx(FillContainer, { className: "max-sm:hidden", children: item }, field)) : (item);
|
|
70
127
|
});
|
|
71
128
|
}
|
|
72
129
|
// Metrics are a dl band when the primitive exists; the old Grid stays as the fallback.
|
|
@@ -6,14 +6,14 @@ import type { FeatureSchema } from "./feature-schema.ts";
|
|
|
6
6
|
import type { NavApi } from "./nav.tsx";
|
|
7
7
|
import { QueryErrorBanner } from "./query-state-banners.tsx";
|
|
8
8
|
import { type useReturnTarget } from "./return-to.tsx";
|
|
9
|
-
type
|
|
9
|
+
export type ProjectionDetailScreenWithTarget = ProjectionDetailScreenDefinition & {
|
|
10
10
|
readonly detailFor?: string;
|
|
11
11
|
};
|
|
12
|
-
export declare function renderMissingIdBanner(primitives: Pick<ReturnType<typeof usePrimitives>, "Banner" | "Text">, screen:
|
|
12
|
+
export declare function renderMissingIdBanner(primitives: Pick<ReturnType<typeof usePrimitives>, "Banner" | "Text">, screen: ProjectionDetailScreenWithTarget): ReactNode;
|
|
13
13
|
export declare function renderDetailQueryError(error: Parameters<typeof QueryErrorBanner>[0]["error"], translate: Translate, onRetry: () => Promise<void>): ReactNode;
|
|
14
14
|
type NotFoundModel = {
|
|
15
15
|
readonly schema: FeatureSchema;
|
|
16
|
-
readonly screen:
|
|
16
|
+
readonly screen: ProjectionDetailScreenWithTarget;
|
|
17
17
|
readonly nav: NavApi;
|
|
18
18
|
readonly returnTarget: ReturnType<typeof useReturnTarget> | undefined;
|
|
19
19
|
readonly effectiveTranslate: Translate;
|
|
@@ -8,6 +8,7 @@ import { usePrimitives } from "../primitives.js";
|
|
|
8
8
|
import { useDrawerAction } from "./action-form-body.js";
|
|
9
9
|
import { useAppFeatures } from "./app-features-context.js";
|
|
10
10
|
import { useClientActionRuntime } from "./client-actions.js";
|
|
11
|
+
import { FacetCountBridges } from "./facet-count-bridge.js";
|
|
11
12
|
import { NamedFilterRemove } from "./named-filter-remove.js";
|
|
12
13
|
import { useNav } from "./nav.js";
|
|
13
14
|
import { renderProjectionDrawerHost } from "./projection-drawer-host.js";
|
|
@@ -61,9 +62,10 @@ export function ProjectionListBody({ schema, screen, translate, onRowClick, }) {
|
|
|
61
62
|
usePager: query.usePager,
|
|
62
63
|
effectiveTranslate,
|
|
63
64
|
resolvedFacetSpecs: query.resolvedFacetSpecs,
|
|
65
|
+
listPayloadFor: query.listPayloadFor,
|
|
64
66
|
});
|
|
65
67
|
const { listRows } = data;
|
|
66
|
-
const refreshRows =
|
|
68
|
+
const refreshRows = data.refreshAfterWrite;
|
|
67
69
|
const actions = useProjectionListActions({
|
|
68
70
|
screen,
|
|
69
71
|
effectiveTranslate,
|
|
@@ -109,7 +111,7 @@ export function ProjectionListBody({ schema, screen, translate, onRowClick, }) {
|
|
|
109
111
|
limit: query.limit,
|
|
110
112
|
urlState: query.urlState,
|
|
111
113
|
});
|
|
112
|
-
return (_jsxs(_Fragment, { children: [refetchErrorBanner, actions.toolbarGateQueries, _jsx(ListGroupPageBridges, { ...data.listTable.aggregates.groupPages }), _jsx(ReferenceFacetBridges, { specs: query.facetSpecs, selected: query.urlState.filters, onState: query.handleProjectionFacetOptions }), renderProjectionList({
|
|
114
|
+
return (_jsxs(_Fragment, { children: [refetchErrorBanner, actions.toolbarGateQueries, _jsx(ListGroupPageBridges, { ...data.listTable.aggregates.groupPages }), _jsx(ReferenceFacetBridges, { specs: query.facetSpecs, selected: query.urlState.filters, onState: query.handleProjectionFacetOptions }), _jsx(FacetCountBridges, { queryType: screen.query, queries: data.namedFilterCountQueries, onCount: data.handleFacetCount, refreshNonce: data.countRefreshNonce }), renderProjectionList({
|
|
113
115
|
schema,
|
|
114
116
|
screen,
|
|
115
117
|
translate,
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { RenderList } from "../components/render-list.js";
|
|
3
3
|
import { isListNarrowed } from "./list-empty-content.js";
|
|
4
|
+
import { translatedSortOptionProps } from "./list-sort-options.js";
|
|
5
|
+
import { buildNamedFilterEmpty } from "./named-filter-facet.js";
|
|
4
6
|
import { projectionActionProps, projectionFacetProps, projectionFilterStateProps, projectionLayoutProps, projectionLeadProps, } from "./projection-list-render-props.js";
|
|
5
7
|
import { QueryErrorBanner } from "./query-state-banners.js";
|
|
6
8
|
export function renderQueryRetryBanner(listRows, error, effectiveTranslate) {
|
|
@@ -17,5 +19,5 @@ export function renderProjectionList(model) {
|
|
|
17
19
|
const { filterFacets, listRows, listTable } = data;
|
|
18
20
|
const { dateRangeFacets } = query;
|
|
19
21
|
return (_jsx(RenderList, { screen: definitions.listScreen, entity: definitions.entity, rows: listRows.rows, featureName: schema.featureName, searchable: definitions.searchable, narrowed: query.activeNamedFilter !== undefined ||
|
|
20
|
-
isListNarrowed(query.activeSearch, urlState.filters), ...projectionLeadProps(screen, effectiveTranslate, actions.emptyContent, isEmbeddedScreen), searchValue: urlState.q, onSearchChange: urlState.setQ, sort: query.activeSort, onSortChange: urlState.setSort, ...projectionLayoutProps(isEmbeddedScreen, screen, definitions.listScreen, pager, actions.rowActions), ...projectionActionProps(actions, translate, wrappedOnRowClick), ...projectionFacetProps(filterFacets, dateRangeFacets, query.handleDateRangeChange, urlState), ...listTable.props, ...projectionFilterStateProps(filterFacets, dateRangeFacets, urlState, query.activeNamedFilter) }));
|
|
22
|
+
isListNarrowed(query.activeSearch, urlState.filters), namedFilterEmpty: buildNamedFilterEmpty(screen.namedFilters, query.activeNamedFilter, query.activeSearch, query.facetNarrowing, effectiveTranslate, () => urlState.setNamedFilter(undefined)), ...projectionLeadProps(screen, effectiveTranslate, actions.emptyContent, isEmbeddedScreen), searchValue: urlState.q, onSearchChange: urlState.setQ, sort: query.activeSort, onSortChange: urlState.setSort, ...translatedSortOptionProps(screen.sortOptions, effectiveTranslate), ...projectionLayoutProps(isEmbeddedScreen, screen, definitions.listScreen, pager, actions.rowActions), ...projectionActionProps(actions, translate, wrappedOnRowClick), ...projectionFacetProps(filterFacets, dateRangeFacets, query.handleDateRangeChange, urlState), ...listTable.props, ...projectionFilterStateProps(filterFacets, dateRangeFacets, urlState, query.activeNamedFilter) }));
|
|
21
23
|
}
|
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { EntityDefinition, EntityListScreenDefinition, ListColumnSpec, ProjectionListScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
export declare const SYNTHESIZED_FIELD_PII_REASON = "synthesized display field, not stored entity data";
|
|
3
|
+
export type SynthesizedField = EntityDefinition["fields"][string];
|
|
4
|
+
/** Field for a column without an entity field behind it: text unless the column declares a numeric `valueType`. */
|
|
5
|
+
export declare function valueTypeField(valueType: "number" | "decimal" | "bigInt" | "money" | undefined, sortable: boolean): SynthesizedField;
|
|
3
6
|
/** Minimal EntityDefinition from the column list: every field is a text
|
|
4
|
-
* field
|
|
7
|
+
* field unless the column declares a numeric `valueType`. `sortable` applies to all columns — buildAppSchema derives it from
|
|
5
8
|
* the query's Zod schema (`screen.sortable`); the query itself has
|
|
6
9
|
* no per-field server-sort guarantee, so a column opts out with
|
|
7
10
|
* `sortable: false` when the handler cannot order by it.
|
|
@@ -17,8 +17,23 @@ const PROJECTION_PSEUDO_ENTITY = "__projection__";
|
|
|
17
17
|
// Satisfies the text-field PII stance of the entity field type; these synthesized
|
|
18
18
|
// fields describe query columns and never map to stored entity data.
|
|
19
19
|
export const SYNTHESIZED_FIELD_PII_REASON = "synthesized display field, not stored entity data";
|
|
20
|
+
/** Field for a column without an entity field behind it: text unless the column declares a numeric `valueType`. */
|
|
21
|
+
export function valueTypeField(valueType, sortable) {
|
|
22
|
+
switch (valueType) {
|
|
23
|
+
case "number":
|
|
24
|
+
// decimal renders through the same number formatter; digits come from the column spec, not scale
|
|
25
|
+
case "decimal":
|
|
26
|
+
return { type: "number", sortable };
|
|
27
|
+
case "bigInt":
|
|
28
|
+
return { type: "bigInt", sortable };
|
|
29
|
+
case "money":
|
|
30
|
+
return { type: "money", sortable };
|
|
31
|
+
case undefined:
|
|
32
|
+
return { type: "text", allowPlaintext: SYNTHESIZED_FIELD_PII_REASON, sortable };
|
|
33
|
+
}
|
|
34
|
+
}
|
|
20
35
|
/** Minimal EntityDefinition from the column list: every field is a text
|
|
21
|
-
* field
|
|
36
|
+
* field unless the column declares a numeric `valueType`. `sortable` applies to all columns — buildAppSchema derives it from
|
|
22
37
|
* the query's Zod schema (`screen.sortable`); the query itself has
|
|
23
38
|
* no per-field server-sort guarantee, so a column opts out with
|
|
24
39
|
* `sortable: false` when the handler cannot order by it.
|
|
@@ -28,14 +43,25 @@ export function synthesizeProjectionEntity(columns, sortable) {
|
|
|
28
43
|
const fields = {};
|
|
29
44
|
for (const col of columns) {
|
|
30
45
|
const normalized = normalizeListColumn(col);
|
|
31
|
-
fields[normalized.field] =
|
|
32
|
-
type: "text",
|
|
33
|
-
allowPlaintext: SYNTHESIZED_FIELD_PII_REASON,
|
|
34
|
-
sortable: sortable && normalized.sortable !== false,
|
|
35
|
-
};
|
|
46
|
+
fields[normalized.field] = valueTypeField(normalized.valueType, sortable && normalized.sortable !== false);
|
|
36
47
|
}
|
|
37
48
|
return { fields };
|
|
38
49
|
}
|
|
50
|
+
function rowPresentation(screen) {
|
|
51
|
+
return {
|
|
52
|
+
...(screen.rowToneField !== undefined && { rowToneField: screen.rowToneField }),
|
|
53
|
+
...(screen.rowRenderer !== undefined && { rowRenderer: screen.rowRenderer }),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function toolbarPresentation(screen) {
|
|
57
|
+
return {
|
|
58
|
+
...(screen.narrowFacets !== undefined && { narrowFacets: screen.narrowFacets }),
|
|
59
|
+
...(screen.toolbarActionsPlacement !== undefined && {
|
|
60
|
+
toolbarActionsPlacement: screen.toolbarActionsPlacement,
|
|
61
|
+
}),
|
|
62
|
+
...(screen.toolbarSort !== undefined && { toolbarSort: screen.toolbarSort }),
|
|
63
|
+
};
|
|
64
|
+
}
|
|
39
65
|
/** Converts a ProjectionListScreenDefinition to the EntityListScreen shape
|
|
40
66
|
* expected by RenderList. `type` = "entityList" plus a pseudo-entity satisfy
|
|
41
67
|
* the type constraint; RenderList does not branch on `type` and reads `entity`
|
|
@@ -46,15 +72,16 @@ export function synthesizeProjectionScreen(screen) {
|
|
|
46
72
|
type: "entityList",
|
|
47
73
|
entity: PROJECTION_PSEUDO_ENTITY,
|
|
48
74
|
columns: screen.columns,
|
|
49
|
-
...(screen
|
|
50
|
-
...(screen.cardRenderer !== undefined && { cardRenderer: screen.cardRenderer }),
|
|
75
|
+
...rowPresentation(screen),
|
|
51
76
|
...(screen.rowActions !== undefined && { rowActions: screen.rowActions }),
|
|
52
77
|
...(screen.toolbarActions !== undefined && { toolbarActions: screen.toolbarActions }),
|
|
78
|
+
...toolbarPresentation(screen),
|
|
53
79
|
...(screen.pagination !== undefined && { pagination: screen.pagination }),
|
|
54
80
|
...(screen.pageSize !== undefined && { pageSize: screen.pageSize }),
|
|
55
81
|
...(screen.defaultSort !== undefined && { defaultSort: screen.defaultSort }),
|
|
56
82
|
...(screen.searchable !== undefined && { searchable: screen.searchable }),
|
|
57
83
|
...(screen.createLabel !== undefined && { createLabel: screen.createLabel }),
|
|
84
|
+
...(screen.itemNounKey !== undefined && { itemNounKey: screen.itemNounKey }),
|
|
58
85
|
...(screen.searchPlaceholder !== undefined && { searchPlaceholder: screen.searchPlaceholder }),
|
|
59
86
|
...(screen.slots !== undefined && { slots: screen.slots }),
|
|
60
87
|
...(screen.access !== undefined && { access: screen.access }),
|
|
@@ -4,6 +4,7 @@ import type { CellLink } from "../headless/index.ts";
|
|
|
4
4
|
export type ReferenceLinkResolver = (refEntity: string, id: string) => CellLink | undefined;
|
|
5
5
|
export declare function useReferenceLinkResolver(): ReferenceLinkResolver;
|
|
6
6
|
/** Link to a screen named by its QN, or undefined when there is no navigation
|
|
7
|
-
* or the user may not open that screen.
|
|
8
|
-
|
|
7
|
+
* or the user may not open that screen. `params` is a row-supplied object:
|
|
8
|
+
* `entityId` opens that record, every other key becomes a search param. */
|
|
9
|
+
export type ScreenLinkResolver = (screenQn: string, params?: unknown) => CellLink | undefined;
|
|
9
10
|
export declare function useScreenLinkResolver(): ScreenLinkResolver;
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
1
2
|
import { useCallback } from "react";
|
|
2
3
|
import { useUserRoles } from "../context/user-roles-context.js";
|
|
3
4
|
import { useAppFeatures } from "./app-features-context.js";
|
|
4
5
|
import { useOptionalNav } from "./nav.js";
|
|
5
6
|
import { lastSegment } from "./qn.js";
|
|
6
|
-
import { navigateWithReturnTo, useReturnHost } from "./return-to.js";
|
|
7
|
+
import { navigateWithReturnTo, RETURN_TO_PARAM, useReturnHost } from "./return-to.js";
|
|
8
|
+
import { stringifyNavParams } from "./row-actions.js";
|
|
7
9
|
import { navigateTargetAllows } from "./screen-access.js";
|
|
8
10
|
export function useReferenceLinkResolver() {
|
|
9
11
|
const nav = useOptionalNav();
|
|
@@ -31,18 +33,31 @@ export function useReferenceLinkResolver() {
|
|
|
31
33
|
return { href, onPress: () => navigateWithReturnTo(nav, target, host) };
|
|
32
34
|
}, [nav, appFeatures, userRoles, host]);
|
|
33
35
|
}
|
|
36
|
+
// Row values become search params as-is (except returnTo), so a row can overwrite reserved
|
|
37
|
+
// keys such as `tab`, `page` or `<screenId>.filter` of the target screen; only trusted query output may feed them.
|
|
34
38
|
export function useScreenLinkResolver() {
|
|
35
39
|
const nav = useOptionalNav();
|
|
36
40
|
const appFeatures = useAppFeatures();
|
|
37
41
|
const userRoles = useUserRoles();
|
|
38
42
|
const host = useReturnHost();
|
|
39
|
-
return useCallback((screenQn) => {
|
|
43
|
+
return useCallback((screenQn, params) => {
|
|
40
44
|
const screenId = lastSegment(screenQn);
|
|
41
45
|
if (nav === undefined || screenId === "")
|
|
42
46
|
return undefined;
|
|
43
47
|
if (!navigateTargetAllows({ screen: screenId }, appFeatures, userRoles))
|
|
44
48
|
return undefined;
|
|
45
|
-
|
|
46
|
-
|
|
49
|
+
// returnTo belongs to the navigation itself; a row must not choose where "back" leads.
|
|
50
|
+
const { entityId, [RETURN_TO_PARAM]: _rowReturnTo, ...rest } = isPlainObject(params) ? params : {};
|
|
51
|
+
const target = typeof entityId === "string" && entityId !== "" ? { screenId, entityId } : { screenId };
|
|
52
|
+
const searchParams = stringifyNavParams(rest);
|
|
53
|
+
const hrefParams = {};
|
|
54
|
+
for (const [key, value] of Object.entries(searchParams)) {
|
|
55
|
+
if (value !== null)
|
|
56
|
+
hrefParams[key] = value;
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
href: nav.hrefFor(target, { searchParams: hrefParams }),
|
|
60
|
+
onPress: () => navigateWithReturnTo(nav, target, host, searchParams),
|
|
61
|
+
};
|
|
47
62
|
}, [nav, appFeatures, userRoles, host]);
|
|
48
63
|
}
|
package/dist/app/row-actions.js
CHANGED
|
@@ -253,7 +253,7 @@ export function buildProjectionRowActions(options) {
|
|
|
253
253
|
return out.length > 0 ? out : undefined;
|
|
254
254
|
}
|
|
255
255
|
function buildNavigateToolbarAction(action, translate, nav, host, prefill, record) {
|
|
256
|
-
const actionIcon = resolveActionIcon(action.id);
|
|
256
|
+
const actionIcon = resolveActionIcon(action.id, action.icon);
|
|
257
257
|
const target = { screenId: action.screen };
|
|
258
258
|
return {
|
|
259
259
|
id: action.id,
|
|
@@ -278,7 +278,7 @@ function buildNavigateToolbarAction(action, translate, nav, host, prefill, recor
|
|
|
278
278
|
};
|
|
279
279
|
}
|
|
280
280
|
function buildDrawerToolbarAction(action, translate, openDrawer, record) {
|
|
281
|
-
const actionIcon = resolveActionIcon(action.id);
|
|
281
|
+
const actionIcon = resolveActionIcon(action.id, action.icon);
|
|
282
282
|
return {
|
|
283
283
|
id: action.id,
|
|
284
284
|
label: translate(action.label),
|
|
@@ -291,7 +291,7 @@ function buildDrawerToolbarAction(action, translate, openDrawer, record) {
|
|
|
291
291
|
};
|
|
292
292
|
}
|
|
293
293
|
function buildWriteHandlerToolbarAction(action, translate, refetch, dispatcher, record) {
|
|
294
|
-
const actionIcon = resolveActionIcon(action.id);
|
|
294
|
+
const actionIcon = resolveActionIcon(action.id, action.icon);
|
|
295
295
|
return {
|
|
296
296
|
id: action.id,
|
|
297
297
|
label: translate(action.label),
|
|
@@ -5,4 +5,8 @@ export declare function navigateTargetAllows(navigate: {
|
|
|
5
5
|
readonly screen?: string;
|
|
6
6
|
readonly entity?: string;
|
|
7
7
|
}, appFeatures: readonly FeatureSchema[], userRoles: readonly string[] | undefined): boolean;
|
|
8
|
+
export declare function namedFilterNavigateAllows(navigate: {
|
|
9
|
+
readonly screen: string;
|
|
10
|
+
readonly namedFilter?: string;
|
|
11
|
+
}, appFeatures: readonly FeatureSchema[], userRoles: readonly string[] | undefined): boolean;
|
|
8
12
|
export declare function findEditScreenFor(entity: string, appFeatures: readonly FeatureSchema[], userRoles: readonly string[] | undefined): EntityEditScreenDefinition | undefined;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { isUiAccessGranted } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import { isNamedFilterOffered } from "./named-filter-facet.js";
|
|
2
3
|
import { findDetailForScreen } from "./nav.js";
|
|
3
4
|
import { lastSegment } from "./qn.js";
|
|
4
5
|
// Shared UI-visibility predicate for the screen-render path — nav
|
|
@@ -42,6 +43,24 @@ export function navigateTargetAllows(navigate, appFeatures, userRoles) {
|
|
|
42
43
|
// targets, so this is a typo'd dead jump. Don't offer it.
|
|
43
44
|
return false;
|
|
44
45
|
}
|
|
46
|
+
// A tile counting a named filter the user may not open would only get the 403 of its count query.
|
|
47
|
+
// An unresolvable target or filter is left to the boot validator and the target screen itself.
|
|
48
|
+
export function namedFilterNavigateAllows(navigate, appFeatures, userRoles) {
|
|
49
|
+
const { namedFilter } = navigate;
|
|
50
|
+
if (namedFilter === undefined)
|
|
51
|
+
return true;
|
|
52
|
+
const targetId = lastSegment(navigate.screen);
|
|
53
|
+
for (const feature of appFeatures) {
|
|
54
|
+
const target = feature.screens.find((s) => lastSegment(s.id) === targetId);
|
|
55
|
+
if (target === undefined)
|
|
56
|
+
continue;
|
|
57
|
+
if (target.type !== "entityList" && target.type !== "projectionList")
|
|
58
|
+
return true;
|
|
59
|
+
const ref = target.namedFilters?.find((candidate) => candidate.id === namedFilter);
|
|
60
|
+
return ref === undefined || isNamedFilterOffered(ref, userRoles);
|
|
61
|
+
}
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
45
64
|
// Searches all mounted features, and access is part of the predicate so a
|
|
46
65
|
// role-gated first match can't hide an accessible second one.
|
|
47
66
|
export function findEditScreenFor(entity, appFeatures, userRoles) {
|
|
@@ -349,7 +349,9 @@ export function navigateAfterDrawerSubmit(options) {
|
|
|
349
349
|
return;
|
|
350
350
|
const target = resolveRedirectTarget(redirect, resultData, schema, appFeatures);
|
|
351
351
|
const hostScreenId = nav.route === undefined ? undefined : lastSegment(nav.route.screenId);
|
|
352
|
-
const isHostScreen = target.screenId === hostScreenId &&
|
|
352
|
+
const isHostScreen = target.screenId === hostScreenId &&
|
|
353
|
+
(target.entityId === undefined || target.entityId === nav.route?.entityId) &&
|
|
354
|
+
target.tab === undefined;
|
|
353
355
|
if (!isHostScreen)
|
|
354
356
|
navigateToRedirectTarget(nav, target);
|
|
355
357
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function uniqueLabelKeys(labels: readonly string[]): readonly string[];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
// Labels may repeat along a path; the occurrence count keeps React keys unique.
|
|
2
|
+
export function uniqueLabelKeys(labels) {
|
|
3
|
+
const seen = new Map();
|
|
4
|
+
return labels.map((label) => {
|
|
5
|
+
const occurrence = seen.get(label) ?? 0;
|
|
6
|
+
seen.set(label, occurrence + 1);
|
|
7
|
+
return `${label}#${occurrence}`;
|
|
8
|
+
});
|
|
9
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { EntityDefinition, EntityListScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { ListUrlStateApi } from "../hooks/use-list-url-state.ts";
|
|
3
|
+
import type { RangeFilter } from "./use-entity-range-facets.ts";
|
|
4
|
+
type EntityListPayloadInput = {
|
|
5
|
+
readonly screen: EntityListScreenDefinition;
|
|
6
|
+
readonly entity: EntityDefinition;
|
|
7
|
+
readonly urlState: ListUrlStateApi;
|
|
8
|
+
readonly rangeFilters: readonly RangeFilter[];
|
|
9
|
+
readonly activeNamedFilter: string | undefined;
|
|
10
|
+
readonly limit: number;
|
|
11
|
+
readonly usePager: boolean;
|
|
12
|
+
readonly useInfinite: boolean;
|
|
13
|
+
};
|
|
14
|
+
/** The list payload as a function of the named filter, so the list and every filter count share one path. */
|
|
15
|
+
export declare function useEntityListPayload({ screen, entity, urlState, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }: EntityListPayloadInput): {
|
|
16
|
+
filterPayload: {
|
|
17
|
+
field: string;
|
|
18
|
+
op: "in";
|
|
19
|
+
value: unknown;
|
|
20
|
+
}[];
|
|
21
|
+
listPayloadFor: (namedFilter: string | undefined) => Record<string, unknown>;
|
|
22
|
+
queryPayload: Record<string, unknown>;
|
|
23
|
+
effectiveSort: import("../primitives.tsx").DataTableSort | null;
|
|
24
|
+
};
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
2
|
+
import { useCallback, useMemo } from "react";
|
|
3
|
+
import { buildFilterPayload } from "./list-facets.js";
|
|
4
|
+
import { resolveListSort } from "./named-filter-facet.js";
|
|
5
|
+
import { buildListQueryPayload } from "./screen-shared.js";
|
|
6
|
+
/** The list payload as a function of the named filter, so the list and every filter count share one path. */
|
|
7
|
+
export function useEntityListPayload({ screen, entity, urlState, rangeFilters, activeNamedFilter, limit, usePager, useInfinite, }) {
|
|
8
|
+
// typeOf reads the field type straight from entity.fields (not gated on
|
|
9
|
+
// filterable, deliberately permissive; see the buildFilterPayload doc).
|
|
10
|
+
const filterPayloadFor = useCallback((filters) => buildFilterPayload(filters, (field) => {
|
|
11
|
+
// entity.fields is weakly typed at the renderer layer (deserialized from
|
|
12
|
+
// the schema); boundary cast like buildInitialValues.
|
|
13
|
+
const type = propertyOf(entity.fields[field], "type");
|
|
14
|
+
return typeof type === "string" ? type : undefined;
|
|
15
|
+
}), [entity.fields]);
|
|
16
|
+
const filterPayload = useMemo(() => filterPayloadFor(urlState.filters), [filterPayloadFor, urlState.filters]);
|
|
17
|
+
const { filtersFor, sort: urlSort, q, page } = urlState;
|
|
18
|
+
const listPayloadFor = useCallback((namedFilter) => {
|
|
19
|
+
const payload = buildListQueryPayload({
|
|
20
|
+
limit,
|
|
21
|
+
search: q,
|
|
22
|
+
sort: resolveListSort(urlSort, screen.namedFilters, namedFilter, screen.defaultSort),
|
|
23
|
+
usePager,
|
|
24
|
+
page,
|
|
25
|
+
useInfinite,
|
|
26
|
+
cursor: undefined,
|
|
27
|
+
});
|
|
28
|
+
// Screen filter (tier 2.7c), declared by the author on the schema and
|
|
29
|
+
// independent of the user's q search. Several buckets of the same entity
|
|
30
|
+
// ("Upcoming" / "Active" / "Past") use different filters with the same
|
|
31
|
+
// query handler.
|
|
32
|
+
if (screen.filter !== undefined)
|
|
33
|
+
payload["filter"] = screen.filter;
|
|
34
|
+
const filters = [...filterPayloadFor(filtersFor(namedFilter)), ...rangeFilters];
|
|
35
|
+
if (filters.length > 0)
|
|
36
|
+
payload["filters"] = filters;
|
|
37
|
+
if (namedFilter !== undefined)
|
|
38
|
+
payload["namedFilter"] = namedFilter;
|
|
39
|
+
return payload;
|
|
40
|
+
}, [
|
|
41
|
+
limit,
|
|
42
|
+
q,
|
|
43
|
+
urlSort,
|
|
44
|
+
page,
|
|
45
|
+
screen.namedFilters,
|
|
46
|
+
screen.defaultSort,
|
|
47
|
+
screen.filter,
|
|
48
|
+
usePager,
|
|
49
|
+
useInfinite,
|
|
50
|
+
filtersFor,
|
|
51
|
+
filterPayloadFor,
|
|
52
|
+
rangeFilters,
|
|
53
|
+
]);
|
|
54
|
+
const queryPayload = useMemo(() => listPayloadFor(activeNamedFilter), [listPayloadFor, activeNamedFilter]);
|
|
55
|
+
const effectiveSort = resolveListSort(urlSort, screen.namedFilters, activeNamedFilter, screen.defaultSort);
|
|
56
|
+
return { filterPayload, listPayloadFor, queryPayload, effectiveSort };
|
|
57
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
+
import { toMinorUnits } from "@cosmicdrift/kumiko-types/minor-units";
|
|
1
2
|
import { propertyOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
2
3
|
import { useCallback, useMemo } from "react";
|
|
3
4
|
import { fieldLabelKey } from "../headless/index.js";
|
|
4
5
|
const RANGE_FIELD_TYPES = new Set(["number", "decimal", "money", "bigInt"]);
|
|
5
|
-
// Money is stored and filtered in minor units; the user types the major amount.
|
|
6
|
-
const MONEY_MINOR_UNITS = 100;
|
|
7
6
|
// The bounds live in the facet URL namespace (`<screenId>.f.<field>.min`), so
|
|
8
7
|
// page reset and clearFilters cover them; buildFilterPayload skips the dotted key.
|
|
9
8
|
function rangeUrlField(field, bound) {
|
|
@@ -42,7 +41,7 @@ function rangeFiltersOf(specs, urlFilters) {
|
|
|
42
41
|
const amount = Number(typed);
|
|
43
42
|
if (typed === "" || !Number.isFinite(amount))
|
|
44
43
|
return [];
|
|
45
|
-
const value = spec.money ?
|
|
44
|
+
const value = spec.money ? toMinorUnits(amount) : amount;
|
|
46
45
|
return [{ field: spec.field, op: bound === "min" ? "gte" : "lte", value }];
|
|
47
46
|
}));
|
|
48
47
|
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
/** Counts reported by the facet count bridges, keyed like the queries that asked for them. */
|
|
3
|
+
export function useFacetCounts() {
|
|
4
|
+
const [facetCounts, setFacetCounts] = useState({});
|
|
5
|
+
const handleFacetCount = useCallback((key, count) => setFacetCounts((prev) => (prev[key] === count ? prev : { ...prev, [key]: count })), []);
|
|
6
|
+
return { facetCounts, handleFacetCount };
|
|
7
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { ListTableSummaryRow } from "@cosmicdrift/kumiko-types/screen";
|
|
2
|
+
import type { DataTableSummaryItem, DataTableSummaryRow } from "../data-table-view-types.ts";
|
|
3
|
+
export declare function summaryRowPayload(listPayload: Readonly<Record<string, unknown>>, params: ListTableSummaryRow["params"]): Record<string, unknown>;
|
|
4
|
+
export declare function parseSummaryItems(data: unknown): readonly DataTableSummaryItem[];
|
|
5
|
+
/** One query for the whole table block; absent `summaryRow` leaves it disabled. */
|
|
6
|
+
export declare function useListSummaryRow({ summaryRow, payload, paused, }: {
|
|
7
|
+
readonly summaryRow: ListTableSummaryRow | undefined;
|
|
8
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
9
|
+
readonly paused: boolean;
|
|
10
|
+
}): DataTableSummaryRow | undefined;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { SELECT_OPTION_TONES } from "@cosmicdrift/kumiko-types/fields";
|
|
2
|
+
import { isOneOf, isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
3
|
+
import { useMemo } from "react";
|
|
4
|
+
import { useQuery } from "../hooks/use-query.js";
|
|
5
|
+
import { namedFilterCountPayload } from "./named-filter-facet.js";
|
|
6
|
+
// The list's narrowing without paging and sort; the summary query answers for the whole filtered list.
|
|
7
|
+
export function summaryRowPayload(listPayload, params) {
|
|
8
|
+
const { limit: _limit, totalCount: _totalCount, ...narrowing } = namedFilterCountPayload(listPayload);
|
|
9
|
+
// The list's own keys win: a param must not widen the numbers beyond what the list shows.
|
|
10
|
+
return { ...params, ...narrowing };
|
|
11
|
+
}
|
|
12
|
+
function isSummaryItem(value) {
|
|
13
|
+
return (isPlainObject(value) &&
|
|
14
|
+
(value["label"] === undefined || typeof value["label"] === "string") &&
|
|
15
|
+
(value["column"] === undefined || typeof value["column"] === "string") &&
|
|
16
|
+
(typeof value["value"] === "string" || typeof value["value"] === "number") &&
|
|
17
|
+
(value["tone"] === undefined || isOneOf(SELECT_OPTION_TONES, value["tone"])));
|
|
18
|
+
}
|
|
19
|
+
export function parseSummaryItems(data) {
|
|
20
|
+
if (!isPlainObject(data) || !Array.isArray(data["items"]))
|
|
21
|
+
return [];
|
|
22
|
+
return data["items"].filter(isSummaryItem);
|
|
23
|
+
}
|
|
24
|
+
/** One query for the whole table block; absent `summaryRow` leaves it disabled. */
|
|
25
|
+
export function useListSummaryRow({ summaryRow, payload, paused, }) {
|
|
26
|
+
const queryPayload = useMemo(() => summaryRowPayload(payload, summaryRow?.params), [payload, summaryRow?.params]);
|
|
27
|
+
const result = useQuery(summaryRow?.query ?? "", queryPayload, {
|
|
28
|
+
enabled: summaryRow !== undefined && !paused,
|
|
29
|
+
live: true,
|
|
30
|
+
});
|
|
31
|
+
const items = useMemo(() => parseSummaryItems(result.data), [result.data]);
|
|
32
|
+
return summaryRow === undefined || items.length === 0 ? undefined : { items };
|
|
33
|
+
}
|