@cosmicdrift/kumiko-renderer 0.413.1 → 0.415.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/action-form-support.js +4 -0
- package/dist/app/content-previews.d.ts +39 -0
- package/dist/app/content-previews.js +28 -0
- package/dist/app/entity-edit-screen.js +2 -5
- package/dist/app/entity-list-screen.js +42 -59
- package/dist/app/form-schema.d.ts +1 -0
- package/dist/app/form-schema.js +24 -0
- package/dist/app/list-facets.d.ts +1 -0
- package/dist/app/list-facets.js +10 -1
- package/dist/app/list-sort-options.d.ts +4 -0
- package/dist/app/list-sort-options.js +11 -0
- package/dist/app/named-filter-facet.d.ts +16 -3
- package/dist/app/named-filter-facet.js +97 -5
- package/dist/app/projection-detail-body.d.ts +2 -4
- package/dist/app/projection-detail-body.js +7 -1
- package/dist/app/projection-detail-guidance-data.d.ts +7 -0
- package/dist/app/projection-detail-guidance-data.js +103 -0
- package/dist/app/projection-detail-guidance.d.ts +13 -0
- package/dist/app/projection-detail-guidance.js +197 -0
- package/dist/app/projection-detail-header-model.d.ts +1 -3
- package/dist/app/projection-detail-header-model.js +4 -8
- package/dist/app/projection-detail-header-region.d.ts +2 -1
- package/dist/app/projection-detail-header-region.js +63 -23
- package/dist/app/projection-detail-header.d.ts +6 -1
- package/dist/app/projection-detail-header.js +76 -18
- package/dist/app/projection-detail-navigation.d.ts +2 -0
- package/dist/app/projection-detail-navigation.js +13 -3
- package/dist/app/projection-detail-states.d.ts +3 -3
- package/dist/app/projection-list-body.js +4 -2
- package/dist/app/projection-list-render.js +3 -1
- package/dist/app/projection-list-shim.d.ts +4 -1
- package/dist/app/projection-list-shim.js +35 -8
- package/dist/app/reference-link.d.ts +3 -2
- package/dist/app/reference-link.js +19 -4
- package/dist/app/row-actions.js +3 -3
- package/dist/app/screen-access.d.ts +4 -0
- package/dist/app/screen-access.js +18 -0
- package/dist/app/screen-shared.js +3 -1
- package/dist/app/unique-label-keys.d.ts +1 -0
- package/dist/app/unique-label-keys.js +9 -0
- package/dist/app/use-entity-list-payload.d.ts +26 -0
- package/dist/app/use-entity-list-payload.js +59 -0
- package/dist/app/use-entity-range-facets.js +2 -3
- package/dist/app/use-facet-counts.d.ts +5 -0
- package/dist/app/use-facet-counts.js +7 -0
- package/dist/app/use-list-summary-row.d.ts +10 -0
- package/dist/app/use-list-summary-row.js +33 -0
- package/dist/app/use-named-filter-queue.d.ts +20 -0
- package/dist/app/use-named-filter-queue.js +9 -0
- package/dist/app/use-projection-detail-actions.d.ts +5 -4
- package/dist/app/use-projection-detail-actions.js +42 -1
- package/dist/app/use-projection-list-data.d.ts +5 -0
- package/dist/app/use-projection-list-data.js +35 -6
- package/dist/app/use-projection-list-query.d.ts +2 -0
- package/dist/app/use-projection-list-query.js +29 -16
- package/dist/app/use-related-list-tab-counts.js +5 -1
- package/dist/app/use-row-decoration.d.ts +13 -0
- package/dist/app/use-row-decoration.js +103 -0
- package/dist/app/use-screen-list-rows.d.ts +4 -1
- package/dist/app/use-screen-list-rows.js +14 -5
- package/dist/app/use-screen-list-table.d.ts +3 -1
- package/dist/app/use-screen-list-table.js +10 -1
- package/dist/app/write-failed-error.d.ts +1 -0
- package/dist/app/write-failed-error.js +10 -0
- package/dist/card-options.d.ts +25 -0
- package/dist/card-options.js +1 -0
- package/dist/compact-tap-classes.d.ts +1 -0
- package/dist/compact-tap-classes.js +3 -0
- package/dist/components/embedded-list-field.js +13 -12
- package/dist/components/list-empty-state.d.ts +13 -1
- package/dist/components/list-empty-state.js +20 -1
- package/dist/components/list-group-page-bridges.d.ts +1 -1
- package/dist/components/list-group-page-bridges.js +2 -2
- package/dist/components/related-list-section.js +4 -22
- package/dist/components/render-edit-action-button.d.ts +3 -1
- package/dist/components/render-edit-action-button.js +5 -3
- package/dist/components/render-edit-render-model.d.ts +2 -2
- package/dist/components/render-edit-types.d.ts +4 -2
- package/dist/components/render-edit.js +3 -1
- package/dist/components/render-list-hint-columns.d.ts +9 -0
- package/dist/components/render-list-hint-columns.js +87 -0
- package/dist/components/render-list-reference-columns.js +4 -2
- package/dist/components/render-list-row-tone.d.ts +3 -0
- package/dist/components/render-list-row-tone.js +10 -0
- package/dist/components/render-list-table-props.d.ts +9 -1
- package/dist/components/render-list-table-props.js +4 -1
- package/dist/components/render-list-toolbar-action.d.ts +1 -2
- package/dist/components/render-list-toolbar-model.d.ts +4 -1
- package/dist/components/render-list-toolbar-model.js +21 -6
- package/dist/components/render-list-toolbar.d.ts +3 -2
- package/dist/components/render-list-toolbar.js +8 -6
- package/dist/components/render-list-types.d.ts +6 -1
- package/dist/components/render-list.js +26 -7
- package/dist/components/use-render-edit-controlled-sync.js +3 -5
- package/dist/components/use-render-edit-draft-save.js +7 -9
- package/dist/components/use-render-edit-schema.d.ts +3 -0
- package/dist/components/use-render-edit-schema.js +15 -0
- package/dist/components/use-render-edit-state.d.ts +1 -0
- package/dist/components/use-render-edit-state.js +4 -1
- package/dist/components/use-render-edit-steps.js +2 -3
- package/dist/components/use-render-list-columns.d.ts +3 -1
- package/dist/components/use-render-list-columns.js +22 -10
- package/dist/context/screen-focus-context.d.ts +14 -0
- package/dist/context/screen-focus-context.js +28 -0
- package/dist/data-table-facet-types.d.ts +6 -0
- package/dist/data-table-view-types.d.ts +20 -1
- package/dist/headless/form/form-controller.js +3 -1
- package/dist/headless/form/zod-bridge.d.ts +7 -1
- package/dist/headless/form/zod-bridge.js +10 -0
- package/dist/headless/index.d.ts +2 -1
- package/dist/headless/index.js +1 -0
- package/dist/headless/pwa-service-worker-meta.d.ts +4 -0
- package/dist/headless/pwa-service-worker-meta.js +13 -0
- package/dist/headless/view-model/index.d.ts +1 -1
- package/dist/headless/view-model/list-file-display.js +3 -2
- package/dist/headless/view-model/list.js +16 -0
- package/dist/headless/view-model/types.d.ts +37 -0
- package/dist/hooks/list-column-layout.js +2 -1
- package/dist/hooks/list-server-groups.js +14 -1
- package/dist/hooks/list-state-schema.d.ts +1 -0
- package/dist/hooks/list-state-schema.js +9 -1
- package/dist/hooks/use-debounced-value.d.ts +1 -0
- package/dist/hooks/use-debounced-value.js +11 -0
- package/dist/hooks/use-list-aggregates.d.ts +5 -1
- package/dist/hooks/use-list-aggregates.js +9 -5
- package/dist/hooks/use-list-table.d.ts +2 -1
- package/dist/hooks/use-list-table.js +3 -9
- package/dist/hooks/use-list-url-state.d.ts +2 -0
- package/dist/hooks/use-list-url-state.js +12 -4
- package/dist/hooks/use-list-view-state.js +23 -3
- package/dist/hooks/use-reference-lookup.js +7 -2
- package/dist/hooks/use-remembered-list-params.d.ts +6 -2
- package/dist/hooks/use-remembered-list-params.js +18 -3
- package/dist/hooks/use-store.js +0 -1
- package/dist/i18n-defaults.js +39 -3
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -1
- package/dist/live/dispatcher-live.js +2 -0
- package/dist/metric-types.d.ts +4 -0
- package/dist/primitives-record-guidance.d.ts +55 -0
- package/dist/primitives-record-guidance.js +1 -0
- package/dist/primitives.d.ts +47 -54
- package/dist/server-clock.d.ts +6 -0
- package/dist/server-clock.js +20 -0
- package/dist/session/session-ended.d.ts +1 -0
- package/dist/session/session-ended.js +2 -2
- package/dist/status-tone.d.ts +1 -0
- package/dist/status-tone.js +5 -0
- package/dist/web/app/browser-locale.js +1 -1
- package/dist/web/app/client-plugin.d.ts +6 -1
- package/dist/web/app/create-app.d.ts +2 -1
- package/dist/web/app/create-app.js +15 -5
- package/dist/web/app/dashboard-body.js +25 -11
- package/dist/web/app/dashboard-header.d.ts +2 -1
- package/dist/web/app/dashboard-header.js +19 -7
- package/dist/web/app/dashboard-list-panel.d.ts +12 -0
- package/dist/web/app/dashboard-list-panel.js +144 -0
- package/dist/web/app/dashboard-narrow-gate.d.ts +6 -0
- package/dist/web/app/dashboard-narrow-gate.js +6 -0
- package/dist/web/app/dashboard-narrow-order.d.ts +3 -0
- package/dist/web/app/dashboard-narrow-order.js +6 -0
- package/dist/web/app/dashboard-navigation-link.d.ts +12 -0
- package/dist/web/app/dashboard-navigation-link.js +21 -0
- package/dist/web/app/dashboard-panels.d.ts +7 -23
- package/dist/web/app/dashboard-panels.js +55 -123
- package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
- package/dist/web/app/dashboard-reference-list-table.js +13 -4
- package/dist/web/app/dashboard-shared.d.ts +23 -7
- package/dist/web/app/dashboard-shared.js +45 -17
- package/dist/web/app/dashboard-stat-group-panel.d.ts +14 -0
- package/dist/web/app/dashboard-stat-group-panel.js +74 -0
- package/dist/web/app/dashboard-text-panel.d.ts +12 -0
- package/dist/web/app/dashboard-text-panel.js +167 -0
- package/dist/web/app/dashboard-text.d.ts +2 -0
- package/dist/web/app/dashboard-text.js +1 -1
- package/dist/web/app/dashboard-visibility.js +1 -1
- package/dist/web/app/relative-time.js +2 -1
- package/dist/web/drawn-icons.d.ts +6 -0
- package/dist/web/drawn-icons.js +30 -0
- package/dist/web/editor/editor-footer.d.ts +28 -0
- package/dist/web/editor/editor-footer.js +23 -0
- package/dist/web/editor/editor-frame.d.ts +23 -0
- package/dist/web/editor/editor-frame.js +24 -0
- package/dist/web/editor/editor-header.d.ts +36 -0
- package/dist/web/editor/editor-header.js +30 -0
- package/dist/web/editor/editor-rail.d.ts +32 -0
- package/dist/web/editor/editor-rail.js +37 -0
- package/dist/web/editor/editor-workbench.d.ts +34 -0
- package/dist/web/editor/editor-workbench.js +19 -0
- package/dist/web/editor/index.d.ts +6 -0
- package/dist/web/editor/index.js +6 -0
- package/dist/web/editor/relative-when.d.ts +1 -0
- package/dist/web/editor/relative-when.js +18 -0
- package/dist/web/icons.js +6 -5
- package/dist/web/index.d.ts +9 -1
- package/dist/web/index.js +7 -1
- package/dist/web/layout/default-app-shell.js +6 -4
- package/dist/web/layout/focus-aware-sidebar.d.ts +4 -7
- package/dist/web/layout/focus-aware-sidebar.js +5 -7
- package/dist/web/layout/header-action-pinned.d.ts +8 -0
- package/dist/web/layout/header-action-pinned.js +25 -0
- package/dist/web/layout/nav-collapse-state.d.ts +7 -0
- package/dist/web/layout/nav-collapse-state.js +76 -0
- package/dist/web/layout/nav-tree.js +71 -28
- package/dist/web/layout/notification-bell.d.ts +7 -2
- package/dist/web/layout/notification-bell.js +16 -5
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.d.ts +8 -0
- package/dist/web/layout/screen-focus.js +42 -0
- package/dist/web/layout/shell-focus.d.ts +5 -4
- package/dist/web/layout/shell-focus.js +14 -7
- package/dist/web/layout/shell-header.d.ts +2 -1
- package/dist/web/layout/shell-header.js +84 -27
- package/dist/web/layout/shell-style.d.ts +3 -0
- package/dist/web/layout/shell-style.js +6 -0
- package/dist/web/layout/sidebar-open-state.d.ts +6 -0
- package/dist/web/layout/sidebar-open-state.js +28 -0
- package/dist/web/layout/uniform-bar-controls.d.ts +2 -2
- package/dist/web/layout/uniform-bar-controls.js +4 -3
- package/dist/web/layout/use-in-app-inbox.js +8 -1
- package/dist/web/layout/workspace-shell.d.ts +11 -1
- package/dist/web/layout/workspace-shell.js +9 -5
- package/dist/web/lib/upload-file-ref.d.ts +2 -2
- package/dist/web/lib/upload-file-ref.js +4 -9
- package/dist/web/presence/use-presence.js +7 -2
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +22 -9
- package/dist/web/primitives/calendar-day-picker.js +24 -5
- package/dist/web/primitives/card.js +18 -8
- package/dist/web/primitives/code-input.js +6 -1
- package/dist/web/primitives/data-table/actions-column.d.ts +2 -1
- package/dist/web/primitives/data-table/actions-column.js +7 -3
- package/dist/web/primitives/data-table/card-body.d.ts +6 -1
- package/dist/web/primitives/data-table/card-body.js +53 -6
- package/dist/web/primitives/data-table/card-frame.d.ts +8 -0
- package/dist/web/primitives/data-table/card-frame.js +9 -0
- package/dist/web/primitives/data-table/card-row.js +44 -7
- package/dist/web/primitives/data-table/card-sort-select.d.ts +6 -2
- package/dist/web/primitives/data-table/card-sort-select.js +10 -7
- package/dist/web/primitives/data-table/card-view.js +12 -2
- package/dist/web/primitives/data-table/column-picker-section.js +9 -2
- package/dist/web/primitives/data-table/column-resize-handle.js +3 -4
- package/dist/web/primitives/data-table/column-role.d.ts +1 -0
- package/dist/web/primitives/data-table/column-role.js +1 -0
- package/dist/web/primitives/data-table/data-cell-props.d.ts +5 -0
- package/dist/web/primitives/data-table/data-cell-props.js +5 -0
- package/dist/web/primitives/data-table/density.js +1 -0
- package/dist/web/primitives/data-table/facet-cluster.d.ts +2 -1
- package/dist/web/primitives/data-table/facet-cluster.js +2 -2
- package/dist/web/primitives/data-table/group-band.js +4 -0
- package/dist/web/primitives/data-table/hint-cell.d.ts +14 -0
- package/dist/web/primitives/data-table/hint-cell.js +68 -0
- package/dist/web/primitives/data-table/hint-column-width.d.ts +3 -0
- package/dist/web/primitives/data-table/hint-column-width.js +11 -0
- package/dist/web/primitives/data-table/measure-value.js +2 -3
- package/dist/web/primitives/data-table/row-action-column.d.ts +3 -0
- package/dist/web/primitives/data-table/row-action-column.js +4 -0
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -2
- package/dist/web/primitives/data-table/sort-options-select.d.ts +22 -0
- package/dist/web/primitives/data-table/sort-options-select.js +46 -0
- package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
- package/dist/web/primitives/data-table/sortable-header.js +5 -3
- package/dist/web/primitives/data-table/table-body.d.ts +1 -1
- package/dist/web/primitives/data-table/table-body.js +5 -3
- package/dist/web/primitives/data-table/table-chrome.js +3 -1
- package/dist/web/primitives/data-table/table-content.js +12 -7
- package/dist/web/primitives/data-table/table-data-cell.js +9 -3
- package/dist/web/primitives/data-table/table-header-row.js +5 -2
- package/dist/web/primitives/data-table/table-view.js +22 -3
- package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
- package/dist/web/primitives/data-table/toolbar.d.ts +2 -0
- package/dist/web/primitives/data-table/toolbar.js +70 -7
- package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
- package/dist/web/primitives/data-table/totals-footer.js +41 -9
- package/dist/web/primitives/data-table/use-bulk-selection.js +2 -1
- package/dist/web/primitives/data-table/use-column-pins.js +4 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +1 -0
- package/dist/web/primitives/data-table/use-data-table-state.js +9 -5
- package/dist/web/primitives/data-table/use-measured-column-widths.js +5 -4
- package/dist/web/primitives/data-table/use-row-selection.js +22 -11
- package/dist/web/primitives/data-table/view-menu.js +7 -1
- package/dist/web/primitives/data-table-cell.d.ts +21 -2
- package/dist/web/primitives/data-table-cell.js +129 -26
- package/dist/web/primitives/embedded-file-cell.js +3 -2
- package/dist/web/primitives/embedded-list-cards.js +3 -4
- package/dist/web/primitives/facet-filter.d.ts +5 -3
- package/dist/web/primitives/facet-filter.js +36 -5
- package/dist/web/primitives/facet-search-filter.d.ts +2 -1
- package/dist/web/primitives/facet-search-filter.js +3 -2
- package/dist/web/primitives/facet-trigger-label.d.ts +8 -0
- package/dist/web/primitives/facet-trigger-label.js +9 -0
- package/dist/web/primitives/file-thumbnail.d.ts +6 -2
- package/dist/web/primitives/file-thumbnail.js +13 -6
- package/dist/web/primitives/file-upload.js +3 -2
- package/dist/web/primitives/file-view-action.d.ts +6 -0
- package/dist/web/primitives/file-view-action.js +22 -0
- package/dist/web/primitives/files-dropzone.js +20 -9
- package/dist/web/primitives/form-footer-parts.d.ts +0 -1
- package/dist/web/primitives/form.js +0 -1
- package/dist/web/primitives/hint-reason-row.d.ts +32 -0
- package/dist/web/primitives/hint-reason-row.js +45 -0
- package/dist/web/primitives/index.js +6 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +3 -3
- package/dist/web/primitives/metric.js +20 -6
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +10 -2
- package/dist/web/primitives/pager.d.ts +3 -2
- package/dist/web/primitives/pager.js +31 -24
- package/dist/web/primitives/reason-box.d.ts +20 -0
- package/dist/web/primitives/reason-box.js +13 -0
- package/dist/web/primitives/record-breadcrumb.d.ts +3 -0
- package/dist/web/primitives/record-breadcrumb.js +11 -0
- package/dist/web/primitives/record-steps.d.ts +3 -0
- package/dist/web/primitives/record-steps.js +50 -0
- package/dist/web/primitives/record-summary.d.ts +3 -0
- package/dist/web/primitives/record-summary.js +18 -0
- package/dist/web/primitives/row-actions.d.ts +3 -1
- package/dist/web/primitives/row-actions.js +14 -5
- package/dist/web/primitives/segmented-select.js +10 -9
- package/dist/web/primitives/tabs.js +6 -1
- package/dist/web/pwa/pwa-support.d.ts +4 -0
- package/dist/web/pwa/pwa-support.js +131 -0
- package/dist/web/sse/live-events.js +2 -2
- package/dist/web/tokens.js +0 -3
- package/dist/web/ui/sidebar.d.ts +2 -1
- package/dist/web/ui/sidebar.js +4 -3
- package/dist/web/widgets/ai-text-field.js +3 -2
- package/dist/web/widgets/chart-parts.d.ts +7 -1
- package/dist/web/widgets/chart-parts.js +10 -4
- package/dist/web/widgets/collapsible-section.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.d.ts +17 -0
- package/dist/web/widgets/dashboard-list-cards.js +46 -0
- package/dist/web/widgets/dashboard-list.d.ts +45 -5
- package/dist/web/widgets/dashboard-list.js +126 -25
- package/dist/web/widgets/drawer-panel-class.d.ts +1 -0
- package/dist/web/widgets/drawer-panel-class.js +9 -1
- package/dist/web/widgets/drawer-sizing.js +1 -1
- package/dist/web/widgets/drawer.js +2 -2
- package/dist/web/widgets/floating-panel.js +4 -2
- package/dist/web/widgets/index.d.ts +2 -0
- package/dist/web/widgets/index.js +2 -0
- package/dist/web/widgets/infinity-list.js +18 -11
- package/dist/web/widgets/pdf-viewer-toolbar.js +3 -2
- package/dist/web/widgets/preview-width-frame.d.ts +7 -0
- package/dist/web/widgets/preview-width-frame.js +10 -0
- package/dist/web/widgets/section-card.d.ts +1 -1
- package/dist/web/widgets/sheet-parts.js +3 -1
- package/dist/web/widgets/stacked-area-chrome.js +3 -3
- package/dist/web/widgets/stacked-area-tooltip.js +2 -10
- package/dist/web/widgets/stat-box-cell.d.ts +19 -0
- package/dist/web/widgets/stat-box-cell.js +10 -0
- package/dist/web/widgets/stat.d.ts +16 -1
- package/dist/web/widgets/stat.js +24 -7
- package/dist/web/widgets/status-badge.d.ts +7 -5
- package/dist/web/widgets/status-badge.js +2 -2
- package/dist/web/widgets/step-bar.d.ts +1 -1
- package/dist/web/widgets/step-bar.js +37 -7
- package/dist/web/widgets/step-list-row.d.ts +4 -0
- package/dist/web/widgets/step-list-row.js +22 -14
- package/dist/web/widgets/step-list.d.ts +12 -4
- package/dist/web/widgets/step-list.js +38 -20
- package/dist/web/widgets/upload-zone.d.ts +8 -1
- package/dist/web/widgets/upload-zone.js +13 -3
- package/package.json +5 -5
- package/src/changes.json +289 -0
- package/src/web/styles.css +15 -0
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { EntityListScreenDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { Translate } from "../headless/index.ts";
|
|
3
|
+
import type { ListUrlStateApi } from "../hooks/use-list-url-state.ts";
|
|
4
|
+
import type { FacetCountQuery } from "./facet-count-bridge.tsx";
|
|
5
|
+
import { buildNamedFilterEmpty } from "./named-filter-facet.ts";
|
|
6
|
+
import type { RangeFilter } from "./use-entity-range-facets.ts";
|
|
7
|
+
/** The count requests and the empty text an entityList derives from its named filters. */
|
|
8
|
+
export declare function useNamedFilterQueue({ screen, urlState, userRoles, translate, filterPayload, rangeFilters, activeNamedFilter, listPayloadFor, }: {
|
|
9
|
+
readonly screen: EntityListScreenDefinition;
|
|
10
|
+
readonly urlState: ListUrlStateApi;
|
|
11
|
+
readonly userRoles: readonly string[] | undefined;
|
|
12
|
+
readonly translate: Translate;
|
|
13
|
+
readonly filterPayload: readonly unknown[];
|
|
14
|
+
readonly rangeFilters: readonly RangeFilter[];
|
|
15
|
+
readonly activeNamedFilter: string | undefined;
|
|
16
|
+
readonly listPayloadFor: (namedFilter: string | undefined) => Readonly<Record<string, unknown>>;
|
|
17
|
+
}): {
|
|
18
|
+
readonly namedFilterCountQueries: FacetCountQuery[];
|
|
19
|
+
readonly namedFilterEmpty: ReturnType<typeof buildNamedFilterEmpty>;
|
|
20
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useMemo } from "react";
|
|
2
|
+
import { buildNamedFilterCountQueries, buildNamedFilterEmpty } from "./named-filter-facet.js";
|
|
3
|
+
/** The count requests and the empty text an entityList derives from its named filters. */
|
|
4
|
+
export function useNamedFilterQueue({ screen, urlState, userRoles, translate, filterPayload, rangeFilters, activeNamedFilter, listPayloadFor, }) {
|
|
5
|
+
const otherNarrowing = filterPayload.length + rangeFilters.length > 0;
|
|
6
|
+
const namedFilterCountQueries = useMemo(() => buildNamedFilterCountQueries(screen.namedFilters, userRoles, screen.namedFilterFacet, listPayloadFor), [screen.namedFilters, screen.namedFilterFacet, userRoles, listPayloadFor]);
|
|
7
|
+
const namedFilterEmpty = buildNamedFilterEmpty(screen.namedFilters, activeNamedFilter, urlState.q, otherNarrowing, translate, () => urlState.setNamedFilter(undefined));
|
|
8
|
+
return { namedFilterCountQueries, namedFilterEmpty };
|
|
9
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { RowAction } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import type { RenderEditAction } from "../components/render-edit.tsx";
|
|
3
3
|
import type { useOptionalDispatcher } from "../context/dispatcher-context.tsx";
|
|
4
4
|
import type { useUserRoles } from "../context/user-roles-context.tsx";
|
|
@@ -8,13 +8,12 @@ import type { useAppFeatures } from "./app-features-context.tsx";
|
|
|
8
8
|
import type { useClientActionRuntime } from "./client-actions.tsx";
|
|
9
9
|
import type { FeatureSchema } from "./feature-schema.ts";
|
|
10
10
|
import type { NavApi } from "./nav.tsx";
|
|
11
|
+
import type { ProjectionDetailScreenWithTarget } from "./projection-detail-states.tsx";
|
|
11
12
|
import { type useReturnHost, type useReturnTarget } from "./return-to.tsx";
|
|
12
13
|
import type { useProjectionDetailData } from "./use-projection-detail-data.ts";
|
|
13
14
|
type DetailActionsInput = {
|
|
14
15
|
readonly schema: FeatureSchema;
|
|
15
|
-
readonly screen:
|
|
16
|
-
readonly detailFor?: string;
|
|
17
|
-
};
|
|
16
|
+
readonly screen: ProjectionDetailScreenWithTarget;
|
|
18
17
|
readonly effectiveTranslate: Translate;
|
|
19
18
|
readonly effectiveEntityId: string | undefined;
|
|
20
19
|
readonly nav: NavApi;
|
|
@@ -31,6 +30,8 @@ type DetailActionsInput = {
|
|
|
31
30
|
};
|
|
32
31
|
export declare function useProjectionDetailActions(input: DetailActionsInput): {
|
|
33
32
|
buildSectionActions: (actions: readonly RowAction[]) => readonly RenderEditAction[] | undefined;
|
|
33
|
+
buildItemActions: (actions: readonly RowAction[], item: Readonly<Record<string, unknown>>) => readonly RenderEditAction[] | undefined;
|
|
34
34
|
headerActions: readonly RenderEditAction[] | undefined;
|
|
35
35
|
};
|
|
36
|
+
export declare function omitActionsDefaultingToShownRecordId(actions: readonly RowAction[], shownRecordId: string | undefined): readonly RowAction[];
|
|
36
37
|
export {};
|
|
@@ -123,6 +123,35 @@ export function useProjectionDetailActions(input) {
|
|
|
123
123
|
handleRecordLeft,
|
|
124
124
|
sameEntityScreenId,
|
|
125
125
|
]);
|
|
126
|
+
const buildItemActions = useCallback((actions, item) => {
|
|
127
|
+
const shownRecordId = effectiveEntityId ?? stringId(detailQuery.data?.["id"]);
|
|
128
|
+
return buildRecordActions({
|
|
129
|
+
actions: omitActionsDefaultingToShownRecordId(actions, shownRecordId),
|
|
130
|
+
record: item,
|
|
131
|
+
translate: effectiveTranslate,
|
|
132
|
+
nav,
|
|
133
|
+
host,
|
|
134
|
+
dispatcher,
|
|
135
|
+
openDrawer,
|
|
136
|
+
onWriteSuccess: reloadDetail,
|
|
137
|
+
onRecordLeft: handleRecordLeft,
|
|
138
|
+
sameEntityScreenId,
|
|
139
|
+
clientActions,
|
|
140
|
+
defaultWritePayloadId: shownRecordId,
|
|
141
|
+
});
|
|
142
|
+
}, [
|
|
143
|
+
detailQuery.data,
|
|
144
|
+
effectiveEntityId,
|
|
145
|
+
reloadDetail,
|
|
146
|
+
effectiveTranslate,
|
|
147
|
+
nav,
|
|
148
|
+
host,
|
|
149
|
+
dispatcher,
|
|
150
|
+
clientActions,
|
|
151
|
+
openDrawer,
|
|
152
|
+
handleRecordLeft,
|
|
153
|
+
sameEntityScreenId,
|
|
154
|
+
]);
|
|
126
155
|
const headerActions = useMemo(() => {
|
|
127
156
|
const declaredHasEdit = screen.actions?.some((a) => a.id === "edit") === true;
|
|
128
157
|
const resolved = buildRecordActions({
|
|
@@ -157,5 +186,17 @@ export function useProjectionDetailActions(input) {
|
|
|
157
186
|
handleRecordLeft,
|
|
158
187
|
sameEntityScreenId,
|
|
159
188
|
]);
|
|
160
|
-
return { buildSectionActions, headerActions };
|
|
189
|
+
return { buildSectionActions, buildItemActions, headerActions };
|
|
190
|
+
}
|
|
191
|
+
// Without a shown record id, a payload-less write or client action would fall back to the guidance item's own id (a step key, not a record id).
|
|
192
|
+
export function omitActionsDefaultingToShownRecordId(actions, shownRecordId) {
|
|
193
|
+
if (shownRecordId !== undefined)
|
|
194
|
+
return actions;
|
|
195
|
+
return actions.filter((action) => !((action.kind === undefined ||
|
|
196
|
+
action.kind === "writeHandler" ||
|
|
197
|
+
action.kind === "clientAction") &&
|
|
198
|
+
action.payload === undefined));
|
|
199
|
+
}
|
|
200
|
+
function stringId(value) {
|
|
201
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
161
202
|
}
|
|
@@ -11,10 +11,15 @@ type ProjectionListDataInput = {
|
|
|
11
11
|
readonly usePager: boolean;
|
|
12
12
|
readonly effectiveTranslate: Translate;
|
|
13
13
|
readonly resolvedFacetSpecs: readonly ResolvedFacetSpec[];
|
|
14
|
+
readonly listPayloadFor: (namedFilter: string | undefined) => Readonly<Record<string, unknown>>;
|
|
14
15
|
};
|
|
15
16
|
export declare function useProjectionListData(input: ProjectionListDataInput): {
|
|
16
17
|
listTable: import("./use-screen-list-table.ts").ScreenListTable;
|
|
17
18
|
listRows: import("./use-screen-list-rows.ts").ScreenListRows;
|
|
18
19
|
filterFacets: DataTableFacet[];
|
|
20
|
+
refreshAfterWrite: () => Promise<void>;
|
|
21
|
+
namedFilterCountQueries: import("./facet-count-bridge.tsx").FacetCountQuery[];
|
|
22
|
+
handleFacetCount: (key: string, count: number) => void;
|
|
23
|
+
countRefreshNonce: number;
|
|
19
24
|
};
|
|
20
25
|
export {};
|
|
@@ -1,10 +1,13 @@
|
|
|
1
|
-
import { useMemo } from "react";
|
|
1
|
+
import { useCallback, useMemo, useState } from "react";
|
|
2
|
+
import { useUserRoles } from "../context/user-roles-context.js";
|
|
2
3
|
import { buildFilterFacets } from "./list-facets.js";
|
|
3
|
-
import { buildNamedFilterFacet } from "./named-filter-facet.js";
|
|
4
|
+
import { buildNamedFilterCountQueries, buildNamedFilterFacet } from "./named-filter-facet.js";
|
|
5
|
+
import { useFacetCounts } from "./use-facet-counts.js";
|
|
4
6
|
import { useScreenListRows } from "./use-screen-list-rows.js";
|
|
5
7
|
import { useScreenListTable } from "./use-screen-list-table.js";
|
|
6
8
|
export function useProjectionListData(input) {
|
|
7
|
-
const { screen, featureName, queryPayload, limit, usePager, effectiveTranslate, resolvedFacetSpecs, } = input;
|
|
9
|
+
const { screen, featureName, queryPayload, limit, usePager, effectiveTranslate, resolvedFacetSpecs, listPayloadFor, } = input;
|
|
10
|
+
const userRoles = useUserRoles();
|
|
8
11
|
const facetFilterFields = useMemo(() => (screen.facets ?? []).map((facet) => facet.field), [screen.facets]);
|
|
9
12
|
const listTable = useScreenListTable({
|
|
10
13
|
screen,
|
|
@@ -21,13 +24,39 @@ export function useProjectionListData(input) {
|
|
|
21
24
|
payload: queryPayload,
|
|
22
25
|
infinite: false,
|
|
23
26
|
aggregates: listTable.aggregates,
|
|
27
|
+
rowDecoration: screen.rowDecoration,
|
|
28
|
+
restoring: listTable.restoring,
|
|
24
29
|
});
|
|
30
|
+
// Counts come from their own queries, which a write leaves untouched.
|
|
31
|
+
const [countRefreshNonce, setCountRefreshNonce] = useState(0);
|
|
32
|
+
const { refreshAfterWrite: refreshListAfterWrite } = listRows;
|
|
33
|
+
const refreshAfterWrite = useCallback(async () => {
|
|
34
|
+
setCountRefreshNonce((n) => n + 1);
|
|
35
|
+
await refreshListAfterWrite();
|
|
36
|
+
}, [refreshListAfterWrite]);
|
|
37
|
+
const { facetCounts, handleFacetCount } = useFacetCounts();
|
|
38
|
+
const namedFilterCountQueries = useMemo(() => buildNamedFilterCountQueries(screen.namedFilters, userRoles, screen.namedFilterFacet, listPayloadFor), [screen.namedFilters, screen.namedFilterFacet, userRoles, listPayloadFor]);
|
|
25
39
|
const filterFacets = useMemo(() => {
|
|
26
|
-
const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate);
|
|
40
|
+
const namedFacet = buildNamedFilterFacet(screen.namedFilters, effectiveTranslate, userRoles, screen.namedFilterFacet, facetCounts);
|
|
27
41
|
return [
|
|
28
42
|
...(namedFacet !== undefined ? [namedFacet] : []),
|
|
29
43
|
...buildFilterFacets(resolvedFacetSpecs),
|
|
30
44
|
];
|
|
31
|
-
}, [
|
|
32
|
-
|
|
45
|
+
}, [
|
|
46
|
+
resolvedFacetSpecs,
|
|
47
|
+
screen.namedFilters,
|
|
48
|
+
screen.namedFilterFacet,
|
|
49
|
+
effectiveTranslate,
|
|
50
|
+
userRoles,
|
|
51
|
+
facetCounts,
|
|
52
|
+
]);
|
|
53
|
+
return {
|
|
54
|
+
listTable,
|
|
55
|
+
listRows,
|
|
56
|
+
filterFacets,
|
|
57
|
+
refreshAfterWrite,
|
|
58
|
+
namedFilterCountQueries,
|
|
59
|
+
handleFacetCount,
|
|
60
|
+
countRefreshNonce,
|
|
61
|
+
};
|
|
33
62
|
}
|
|
@@ -13,6 +13,7 @@ type ProjectionListQueryInput = {
|
|
|
13
13
|
readonly paginated: boolean;
|
|
14
14
|
};
|
|
15
15
|
export declare function useProjectionListQuery(input: ProjectionListQueryInput): {
|
|
16
|
+
listPayloadFor: (namedFilter: string | undefined) => Record<string, unknown>;
|
|
16
17
|
urlState: ListUrlStateApi;
|
|
17
18
|
activeSearch: string;
|
|
18
19
|
activeSort: import("../primitives.tsx").DataTableSort | null;
|
|
@@ -25,5 +26,6 @@ export declare function useProjectionListQuery(input: ProjectionListQueryInput):
|
|
|
25
26
|
handleDateRangeChange: (field: string, bound: "from" | "to", value: string) => void;
|
|
26
27
|
queryPayload: Record<string, unknown>;
|
|
27
28
|
activeNamedFilter: string | undefined;
|
|
29
|
+
facetNarrowing: boolean;
|
|
28
30
|
};
|
|
29
31
|
export {};
|
|
@@ -1,26 +1,30 @@
|
|
|
1
1
|
import { useCallback, useMemo, useState } from "react";
|
|
2
2
|
import { useListUrlState } from "../hooks/use-list-url-state.js";
|
|
3
3
|
import { buildFilterPayload, mergeReferenceFacetOptions, resolveProjectionFacetSpecs, } from "./list-facets.js";
|
|
4
|
+
import { namedFilterSort } from "./named-filter-facet.js";
|
|
4
5
|
import { withReferenceFacetState } from "./reference-facet-bridge.js";
|
|
5
6
|
import { buildListQueryPayload } from "./screen-shared.js";
|
|
6
7
|
import { useProjectionDateRange } from "./use-projection-date-range.js";
|
|
7
8
|
// Same predicate that makes a header clickable: a stale link onto a
|
|
8
9
|
// sortable:false/unknown column must not reach the server (it answers 400).
|
|
9
|
-
function resolveActiveSort(urlSort, input) {
|
|
10
|
+
function resolveActiveSort(urlSort, input, activeNamedFilter) {
|
|
10
11
|
const { screen, entity, sortable } = input;
|
|
11
12
|
const urlSortField = urlSort === null ? undefined : entity.fields[urlSort.field];
|
|
12
13
|
const urlSortAllowed = urlSortField !== undefined && "sortable" in urlSortField && urlSortField.sortable === true;
|
|
13
|
-
|
|
14
|
+
const filterSort = namedFilterSort(screen.namedFilters, activeNamedFilter);
|
|
15
|
+
return sortable
|
|
16
|
+
? ((urlSortAllowed ? urlSort : null) ?? filterSort ?? screen.defaultSort ?? null)
|
|
17
|
+
: null;
|
|
14
18
|
}
|
|
15
19
|
export function useProjectionListQuery(input) {
|
|
16
|
-
const { screen, featureName, effectiveTranslate, searchable, paginated } = input;
|
|
20
|
+
const { screen, featureName, effectiveTranslate, entity, searchable, sortable, paginated } = input;
|
|
17
21
|
const urlState = useListUrlState(screen.id);
|
|
18
22
|
const activeNamedFilter = screen.namedFilters === undefined ? undefined : urlState.namedFilter;
|
|
19
23
|
// Gated on the derived capability, not just on whether URL-state happens to
|
|
20
24
|
// carry a value — a stale/hand-crafted URL (?…q=x on a non-searchable
|
|
21
25
|
// screen) must not smuggle a param the query's Zod schema doesn't accept.
|
|
22
26
|
const activeSearch = searchable ? urlState.q : "";
|
|
23
|
-
const activeSort = resolveActiveSort(urlState.sort, input);
|
|
27
|
+
const activeSort = resolveActiveSort(urlState.sort, input, activeNamedFilter);
|
|
24
28
|
const limit = urlState.pageSize ?? screen.pageSize ?? 50;
|
|
25
29
|
// Pages-mode only (see header comment) — an author-set pagination:
|
|
26
30
|
// "infinite" on a paginated projectionList is silently a no-op today.
|
|
@@ -34,15 +38,17 @@ export function useProjectionListQuery(input) {
|
|
|
34
38
|
const [projectionReferenceFacetOptions, setProjectionReferenceFacetOptions] = useState({});
|
|
35
39
|
const handleProjectionFacetOptions = useCallback((field, state) => setProjectionReferenceFacetOptions((prev) => withReferenceFacetState(prev, field, state)), []);
|
|
36
40
|
const resolvedFacetSpecs = useMemo(() => mergeReferenceFacetOptions(facetSpecs, projectionReferenceFacetOptions), [facetSpecs, projectionReferenceFacetOptions]);
|
|
37
|
-
const
|
|
41
|
+
const facetFiltersFor = useCallback((filters) => buildFilterPayload(filters, (field) => facetSpecs.find((spec) => spec.field === field)?.type), [facetSpecs]);
|
|
42
|
+
const filterPayload = useMemo(() => facetFiltersFor(urlState.filters), [facetFiltersFor, urlState.filters]);
|
|
38
43
|
const { dateRangePayload, dateRangeFacets, handleDateRangeChange } = useProjectionDateRange(screen.facets, effectiveTranslate, urlState);
|
|
39
|
-
const
|
|
44
|
+
const { sort: urlSort, page, filtersFor } = urlState;
|
|
45
|
+
const listPayloadFor = useCallback((namedFilter) => {
|
|
40
46
|
const payload = buildListQueryPayload({
|
|
41
47
|
limit,
|
|
42
48
|
search: activeSearch,
|
|
43
|
-
sort:
|
|
49
|
+
sort: resolveActiveSort(urlSort, { screen, entity, sortable }, namedFilter),
|
|
44
50
|
usePager,
|
|
45
|
-
page
|
|
51
|
+
page,
|
|
46
52
|
useInfinite: false,
|
|
47
53
|
cursor: undefined,
|
|
48
54
|
});
|
|
@@ -53,26 +59,32 @@ export function useProjectionListQuery(input) {
|
|
|
53
59
|
if (screen.filter !== undefined) {
|
|
54
60
|
payload["filter"] = screen.filter;
|
|
55
61
|
}
|
|
56
|
-
|
|
57
|
-
|
|
62
|
+
const filters = facetFiltersFor(filtersFor(namedFilter));
|
|
63
|
+
if (screen.facets !== undefined && filters.length > 0) {
|
|
64
|
+
payload["filters"] = filters;
|
|
58
65
|
}
|
|
59
|
-
if (
|
|
60
|
-
payload["namedFilter"] =
|
|
66
|
+
if (namedFilter !== undefined)
|
|
67
|
+
payload["namedFilter"] = namedFilter;
|
|
61
68
|
Object.assign(payload, dateRangePayload);
|
|
62
69
|
return payload;
|
|
63
70
|
}, [
|
|
64
|
-
activeNamedFilter,
|
|
65
71
|
limit,
|
|
66
72
|
activeSearch,
|
|
67
|
-
|
|
73
|
+
urlSort,
|
|
74
|
+
screen,
|
|
75
|
+
entity,
|
|
76
|
+
sortable,
|
|
68
77
|
usePager,
|
|
69
|
-
|
|
78
|
+
page,
|
|
70
79
|
screen.filter,
|
|
71
80
|
screen.facets,
|
|
72
|
-
|
|
81
|
+
filtersFor,
|
|
82
|
+
facetFiltersFor,
|
|
73
83
|
dateRangePayload,
|
|
74
84
|
]);
|
|
85
|
+
const queryPayload = useMemo(() => listPayloadFor(activeNamedFilter), [listPayloadFor, activeNamedFilter]);
|
|
75
86
|
return {
|
|
87
|
+
listPayloadFor,
|
|
76
88
|
urlState,
|
|
77
89
|
activeSearch,
|
|
78
90
|
activeSort,
|
|
@@ -85,5 +97,6 @@ export function useProjectionListQuery(input) {
|
|
|
85
97
|
handleDateRangeChange,
|
|
86
98
|
queryPayload,
|
|
87
99
|
activeNamedFilter,
|
|
100
|
+
facetNarrowing: filterPayload.length > 0 || Object.keys(dateRangePayload).length > 0,
|
|
88
101
|
};
|
|
89
102
|
}
|
|
@@ -34,16 +34,20 @@ export function useRelatedListTabCounts(args) {
|
|
|
34
34
|
return out;
|
|
35
35
|
}, [sections, parentId]);
|
|
36
36
|
useEffect(() => {
|
|
37
|
+
// Counts of the previous record or section set must not linger while the new ones load.
|
|
38
|
+
setCounts((previous) => (Object.keys(previous).length === 0 ? previous : {}));
|
|
37
39
|
// skip: nothing to count, or no dispatcher mounted
|
|
38
40
|
if (requests.length === 0 || dispatcher === undefined)
|
|
39
41
|
return;
|
|
40
42
|
const ctrl = new AbortController();
|
|
43
|
+
let latestLoad = 0;
|
|
41
44
|
const load = async () => {
|
|
45
|
+
const thisLoad = ++latestLoad;
|
|
42
46
|
const results = await Promise.all(requests.map((request) => dispatcher.query(request.query, request.payload, {
|
|
43
47
|
signal: ctrl.signal,
|
|
44
48
|
})));
|
|
45
49
|
// skip: unmounted or superseded while the queries were in flight
|
|
46
|
-
if (ctrl.signal.aborted)
|
|
50
|
+
if (ctrl.signal.aborted || thisLoad !== latestLoad)
|
|
47
51
|
return;
|
|
48
52
|
const next = {};
|
|
49
53
|
results.forEach((result, index) => {
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ListRowDecoration } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
type Row = Readonly<Record<string, unknown>>;
|
|
3
|
+
/** Decoration fields win over same-named row fields; the row id is kept. Entries for ids not in `rows` and malformed entries are ignored. */
|
|
4
|
+
export declare function mergeRowDecoration(rows: readonly Row[], answer: unknown): readonly Row[];
|
|
5
|
+
/**
|
|
6
|
+
* Sends only ids that have no answer yet, so an infinite list asks once per new page and the
|
|
7
|
+
* answers are kept across calls. `resetKey` drops them (filter or sort changed); a new list
|
|
8
|
+
* answer that is not an append (reload after a write) asks for every id again, in batches of
|
|
9
|
+
* the first send's size.
|
|
10
|
+
* Loading and error show the plain rows.
|
|
11
|
+
*/
|
|
12
|
+
export declare function useRowDecoration(decoration: ListRowDecoration | undefined, rows: readonly Row[], answerToken: unknown, resetKey: string): readonly Row[];
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
2
|
+
import { useEffect, useMemo, useRef, useState } from "react";
|
|
3
|
+
import { useQuery } from "../hooks/use-query.js";
|
|
4
|
+
function rowId(row) {
|
|
5
|
+
const id = row["id"];
|
|
6
|
+
return typeof id === "string" ? id : undefined;
|
|
7
|
+
}
|
|
8
|
+
function decorationFieldsById(answer) {
|
|
9
|
+
const byId = new Map();
|
|
10
|
+
const entries = isPlainObject(answer) ? answer["rows"] : undefined;
|
|
11
|
+
if (!Array.isArray(entries))
|
|
12
|
+
return byId;
|
|
13
|
+
for (const entry of entries) {
|
|
14
|
+
if (!isPlainObject(entry))
|
|
15
|
+
continue;
|
|
16
|
+
const id = rowId(entry);
|
|
17
|
+
if (id !== undefined)
|
|
18
|
+
byId.set(id, entry);
|
|
19
|
+
}
|
|
20
|
+
return byId;
|
|
21
|
+
}
|
|
22
|
+
function applyDecorationFields(rows, byId) {
|
|
23
|
+
if (byId.size === 0)
|
|
24
|
+
return rows;
|
|
25
|
+
return rows.map((row) => {
|
|
26
|
+
const id = rowId(row);
|
|
27
|
+
const fields = id === undefined ? undefined : byId.get(id);
|
|
28
|
+
return fields === undefined ? row : { ...row, ...fields, id: row["id"] };
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
/** Decoration fields win over same-named row fields; the row id is kept. Entries for ids not in `rows` and malformed entries are ignored. */
|
|
32
|
+
export function mergeRowDecoration(rows, answer) {
|
|
33
|
+
return applyDecorationFields(rows, decorationFieldsById(answer));
|
|
34
|
+
}
|
|
35
|
+
function emptyAccumulated(resetKey) {
|
|
36
|
+
return { resetKey, answeredIds: new Set(), fieldsById: new Map(), batchSize: undefined };
|
|
37
|
+
}
|
|
38
|
+
function absorbAnswer(previous, answer, sentIds) {
|
|
39
|
+
// A sent id the answer no longer contains loses its decoration; ids not asked for keep theirs,
|
|
40
|
+
// so rows do not flicker while a refresh runs batch by batch.
|
|
41
|
+
const fieldsById = new Map(previous.fieldsById);
|
|
42
|
+
for (const id of sentIds)
|
|
43
|
+
fieldsById.delete(id);
|
|
44
|
+
for (const [id, fields] of decorationFieldsById(answer))
|
|
45
|
+
fieldsById.set(id, fields);
|
|
46
|
+
return {
|
|
47
|
+
resetKey: previous.resetKey,
|
|
48
|
+
answeredIds: new Set([...previous.answeredIds, ...sentIds]),
|
|
49
|
+
fieldsById,
|
|
50
|
+
batchSize: previous.batchSize ?? sentIds.length,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function isAppendOf(previousIds, ids) {
|
|
54
|
+
return ids.length > previousIds.length && previousIds.every((id, index) => ids[index] === id);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Sends only ids that have no answer yet, so an infinite list asks once per new page and the
|
|
58
|
+
* answers are kept across calls. `resetKey` drops them (filter or sort changed); a new list
|
|
59
|
+
* answer that is not an append (reload after a write) asks for every id again, in batches of
|
|
60
|
+
* the first send's size.
|
|
61
|
+
* Loading and error show the plain rows.
|
|
62
|
+
*/
|
|
63
|
+
export function useRowDecoration(decoration, rows, answerToken, resetKey) {
|
|
64
|
+
const ids = rows.flatMap((row) => {
|
|
65
|
+
const id = rowId(row);
|
|
66
|
+
return id === undefined ? [] : [id];
|
|
67
|
+
});
|
|
68
|
+
const [stored, setStored] = useState(() => emptyAccumulated(resetKey));
|
|
69
|
+
const accumulated = stored.resetKey === resetKey ? stored : emptyAccumulated(resetKey);
|
|
70
|
+
const idsToSend = ids
|
|
71
|
+
.filter((id) => !accumulated.answeredIds.has(id))
|
|
72
|
+
.slice(0, accumulated.batchSize);
|
|
73
|
+
const enabled = decoration !== undefined && idsToSend.length > 0;
|
|
74
|
+
const { data, error } = useQuery(decoration?.query ?? "", { ...decoration?.params, ids: idsToSend }, { enabled });
|
|
75
|
+
const sentIdsRef = useRef(idsToSend);
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
sentIdsRef.current = idsToSend;
|
|
78
|
+
});
|
|
79
|
+
const absorbedAnswerRef = useRef(null);
|
|
80
|
+
useEffect(() => {
|
|
81
|
+
if (data === null || data === absorbedAnswerRef.current)
|
|
82
|
+
return;
|
|
83
|
+
absorbedAnswerRef.current = data;
|
|
84
|
+
const sentIds = sentIdsRef.current;
|
|
85
|
+
setStored((current) => absorbAnswer(current.resetKey === resetKey ? current : emptyAccumulated(resetKey), data, sentIds));
|
|
86
|
+
}, [data, resetKey]);
|
|
87
|
+
const previousListRef = useRef(null);
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
const previous = previousListRef.current;
|
|
90
|
+
previousListRef.current = { token: answerToken, ids };
|
|
91
|
+
if (previous === null || previous.token === answerToken)
|
|
92
|
+
return;
|
|
93
|
+
if (isAppendOf(previous.ids, ids))
|
|
94
|
+
return;
|
|
95
|
+
setStored((current) => ({
|
|
96
|
+
...(current.resetKey === resetKey ? current : emptyAccumulated(resetKey)),
|
|
97
|
+
answeredIds: new Set(),
|
|
98
|
+
}));
|
|
99
|
+
}, [answerToken, ids, resetKey]);
|
|
100
|
+
const fieldsById = accumulated.fieldsById;
|
|
101
|
+
const decorated = decoration !== undefined;
|
|
102
|
+
return useMemo(() => (!decorated || error !== null ? rows : applyDecorationFields(rows, fieldsById)), [decorated, error, rows, fieldsById]);
|
|
103
|
+
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { ListRowDecoration } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
2
|
import type { DispatcherError } from "../headless/index.ts";
|
|
2
3
|
import type { ListAggregates } from "../hooks/use-list-aggregates.ts";
|
|
3
4
|
import type { ListUrlStateApi } from "../hooks/use-list-url-state.ts";
|
|
@@ -21,11 +22,13 @@ export type ScreenListRows = {
|
|
|
21
22
|
};
|
|
22
23
|
/** Rows of a URL-backed list screen: one page, accumulated infinite pages, or the
|
|
23
24
|
* loaded rows of the open server groups. `payload` carries no cursor. */
|
|
24
|
-
export declare function useScreenListRows({ queryType, payload, infinite, aggregates, }: {
|
|
25
|
+
export declare function useScreenListRows({ queryType, payload, infinite, aggregates, rowDecoration, restoring, }: {
|
|
25
26
|
readonly queryType: string;
|
|
26
27
|
readonly payload: Readonly<Record<string, unknown>>;
|
|
27
28
|
readonly infinite: boolean;
|
|
28
29
|
readonly aggregates: ListAggregates;
|
|
30
|
+
readonly rowDecoration?: ListRowDecoration | undefined;
|
|
31
|
+
readonly restoring?: boolean;
|
|
29
32
|
}): ScreenListRows;
|
|
30
33
|
/** Pager props for `pagination: "pages"`; none until the server total arrives. */
|
|
31
34
|
export declare function listPager(args: {
|
|
@@ -2,6 +2,8 @@ import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
|
2
2
|
import { useQuery } from "../hooks/use-query.js";
|
|
3
3
|
import { refetchAfterWrite } from "./row-actions.js";
|
|
4
4
|
import { pageSizeOptionsFor } from "./screen-shared.js";
|
|
5
|
+
import { useRowDecoration } from "./use-row-decoration.js";
|
|
6
|
+
const NO_ROWS = [];
|
|
5
7
|
function freshInfiniteState(resetKey) {
|
|
6
8
|
return { resetKey, rows: [], cursor: undefined, hasMore: true };
|
|
7
9
|
}
|
|
@@ -12,7 +14,7 @@ function appendUnseen(previous, next) {
|
|
|
12
14
|
}
|
|
13
15
|
/** Rows of a URL-backed list screen: one page, accumulated infinite pages, or the
|
|
14
16
|
* loaded rows of the open server groups. `payload` carries no cursor. */
|
|
15
|
-
export function useScreenListRows({ queryType, payload, infinite, aggregates, }) {
|
|
17
|
+
export function useScreenListRows({ queryType, payload, infinite, aggregates, rowDecoration, restoring = false, }) {
|
|
16
18
|
const { grouped, refresh: refreshAggregates } = aggregates;
|
|
17
19
|
const resetKey = JSON.stringify(payload);
|
|
18
20
|
const [infiniteState, setInfiniteState] = useState(() => freshInfiniteState(resetKey));
|
|
@@ -21,7 +23,10 @@ export function useScreenListRows({ queryType, payload, infinite, aggregates, })
|
|
|
21
23
|
setInfiniteState(state);
|
|
22
24
|
const cursor = infinite ? state.cursor : undefined;
|
|
23
25
|
const rowsPayload = useMemo(() => (cursor === undefined ? payload : { ...payload, cursor }), [payload, cursor]);
|
|
24
|
-
const rowsQuery = useQuery(queryType, rowsPayload, {
|
|
26
|
+
const rowsQuery = useQuery(queryType, rowsPayload, {
|
|
27
|
+
live: true,
|
|
28
|
+
enabled: !grouped && !restoring,
|
|
29
|
+
});
|
|
25
30
|
const { data, loading, refetch } = rowsQuery;
|
|
26
31
|
const lastDataRef = useRef(null);
|
|
27
32
|
useEffect(() => {
|
|
@@ -65,9 +70,13 @@ export function useScreenListRows({ queryType, payload, infinite, aggregates, })
|
|
|
65
70
|
else
|
|
66
71
|
await refetch();
|
|
67
72
|
}, [grouped, refreshAggregates, refetch]);
|
|
73
|
+
const loadedRows = grouped ? aggregates.rows : infinite ? state.rows : (data?.rows ?? NO_ROWS);
|
|
74
|
+
// Grouped rows are rebuilt on every render, so only a group refresh counts as a new answer.
|
|
75
|
+
const answerToken = grouped ? aggregates.groupPages.refreshNonce : loadedRows;
|
|
76
|
+
const rows = useRowDecoration(rowDecoration, loadedRows, answerToken, resetKey);
|
|
68
77
|
if (grouped) {
|
|
69
78
|
return {
|
|
70
|
-
rows
|
|
79
|
+
rows,
|
|
71
80
|
page: null,
|
|
72
81
|
firstLoad: aggregates.loading,
|
|
73
82
|
error: aggregates.error,
|
|
@@ -77,9 +86,9 @@ export function useScreenListRows({ queryType, payload, infinite, aggregates, })
|
|
|
77
86
|
};
|
|
78
87
|
}
|
|
79
88
|
return {
|
|
80
|
-
rows
|
|
89
|
+
rows,
|
|
81
90
|
page: data,
|
|
82
|
-
firstLoad: loading && data === null,
|
|
91
|
+
firstLoad: restoring || (loading && data === null),
|
|
83
92
|
error: rowsQuery.error,
|
|
84
93
|
hasData: data !== null,
|
|
85
94
|
retry,
|
|
@@ -16,8 +16,10 @@ type ScreenListTableArgs = {
|
|
|
16
16
|
readonly translate: Translate;
|
|
17
17
|
};
|
|
18
18
|
export type ScreenListTable = {
|
|
19
|
-
readonly props: ListTableProps & Pick<DataTableTableBlockProps, "serverGroups" | "totals" | "notice">;
|
|
19
|
+
readonly props: ListTableProps & Pick<DataTableTableBlockProps, "serverGroups" | "totals" | "summaryRow" | "notice">;
|
|
20
20
|
readonly aggregates: ListAggregates;
|
|
21
|
+
/** The remembered params are still on their way into the URL; list queries wait. */
|
|
22
|
+
readonly restoring: boolean;
|
|
21
23
|
};
|
|
22
24
|
/** Table-block wiring of a URL-backed list screen (entityList, projectionList). */
|
|
23
25
|
export declare function useScreenListTable({ screen, featureName, payload, filterFields, queryType, pageSize, paging, translate, }: ScreenListTableArgs): ScreenListTable;
|
|
@@ -4,13 +4,14 @@ import { useListAggregates } from "../hooks/use-list-aggregates.js";
|
|
|
4
4
|
import { useListTable } from "../hooks/use-list-table.js";
|
|
5
5
|
import { listViewSchemaColumns } from "../hooks/use-list-view-state.js";
|
|
6
6
|
import { useRememberedListParams } from "../hooks/use-remembered-list-params.js";
|
|
7
|
+
import { useListSummaryRow } from "./use-list-summary-row.js";
|
|
7
8
|
/** Table-block wiring of a URL-backed list screen (entityList, projectionList). */
|
|
8
9
|
export function useScreenListTable({ screen, featureName, payload, filterFields, queryType, pageSize, paging, translate, }) {
|
|
9
10
|
const { id: screenId, table, columns } = screen;
|
|
10
11
|
const store = useListStateStore();
|
|
11
12
|
const schemaColumns = useMemo(() => listViewSchemaColumns(columns), [columns]);
|
|
12
13
|
const known = useMemo(() => ({ columnFields: schemaColumns.map((column) => column.field), filterFields }), [schemaColumns, filterFields]);
|
|
13
|
-
useRememberedListParams({
|
|
14
|
+
const { restoring } = useRememberedListParams({
|
|
14
15
|
screenId,
|
|
15
16
|
enabled: table?.rememberState === true,
|
|
16
17
|
store,
|
|
@@ -32,15 +33,23 @@ export function useScreenListTable({ screen, featureName, payload, filterFields,
|
|
|
32
33
|
pageSize,
|
|
33
34
|
paging,
|
|
34
35
|
translate,
|
|
36
|
+
paused: restoring,
|
|
35
37
|
});
|
|
36
38
|
const { serverGroups, totals, notice } = aggregates;
|
|
39
|
+
const summaryRow = useListSummaryRow({
|
|
40
|
+
summaryRow: table?.summaryRow,
|
|
41
|
+
payload,
|
|
42
|
+
paused: restoring,
|
|
43
|
+
});
|
|
37
44
|
return {
|
|
38
45
|
props: {
|
|
39
46
|
...props,
|
|
47
|
+
...(summaryRow !== undefined && { summaryRow }),
|
|
40
48
|
...(serverGroups !== undefined && { serverGroups }),
|
|
41
49
|
...(totals !== undefined && { totals }),
|
|
42
50
|
...(notice !== undefined && { notice }),
|
|
43
51
|
},
|
|
44
52
|
aggregates,
|
|
53
|
+
restoring,
|
|
45
54
|
};
|
|
46
55
|
}
|
|
@@ -4,3 +4,4 @@ export declare class WriteFailedError extends Error {
|
|
|
4
4
|
constructor(error: DispatcherError, message: string);
|
|
5
5
|
}
|
|
6
6
|
export declare function dispatcherErrorText(error: DispatcherError, translate: (key: string, params?: Readonly<Record<string, unknown>>) => string): string;
|
|
7
|
+
export declare function dispatcherErrorTextWithFieldIssues(error: DispatcherError, translate: (key: string, params?: Readonly<Record<string, unknown>>) => string): string;
|
|
@@ -20,3 +20,13 @@ export function dispatcherErrorText(error, translate) {
|
|
|
20
20
|
return translated;
|
|
21
21
|
return error.message !== "" ? error.message : error.code;
|
|
22
22
|
}
|
|
23
|
+
// A validation_error alone says nothing; the server names the offending field and reason per
|
|
24
|
+
// issue, so the user gets those as text.
|
|
25
|
+
export function dispatcherErrorTextWithFieldIssues(error, translate) {
|
|
26
|
+
const headline = dispatcherErrorText(error, translate);
|
|
27
|
+
const issues = (error.details?.fields ?? []).map((issue) => {
|
|
28
|
+
const text = translate(issue.i18nKey, issue.params);
|
|
29
|
+
return text === issue.i18nKey ? `${issue.path}: ${issue.code}` : text;
|
|
30
|
+
});
|
|
31
|
+
return issues.length === 0 ? headline : `${headline} ${issues.join(" ")}`;
|
|
32
|
+
}
|