@cosmicdrift/kumiko-renderer 0.413.0 → 0.414.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/action-form-support.js +4 -0
- package/dist/app/content-previews.d.ts +39 -0
- package/dist/app/content-previews.js +28 -0
- package/dist/app/entity-edit-screen.js +2 -5
- package/dist/app/entity-list-screen.js +30 -50
- package/dist/app/form-schema.d.ts +1 -0
- package/dist/app/form-schema.js +24 -0
- package/dist/app/list-sort-options.d.ts +4 -0
- package/dist/app/list-sort-options.js +11 -0
- package/dist/app/named-filter-facet.d.ts +17 -3
- package/dist/app/named-filter-facet.js +88 -5
- package/dist/app/projection-detail-body.d.ts +2 -4
- package/dist/app/projection-detail-body.js +7 -1
- package/dist/app/projection-detail-guidance-data.d.ts +7 -0
- package/dist/app/projection-detail-guidance-data.js +101 -0
- package/dist/app/projection-detail-guidance.d.ts +13 -0
- package/dist/app/projection-detail-guidance.js +197 -0
- package/dist/app/projection-detail-header-model.d.ts +1 -3
- package/dist/app/projection-detail-header-model.js +4 -8
- package/dist/app/projection-detail-header-region.d.ts +2 -1
- package/dist/app/projection-detail-header-region.js +63 -23
- package/dist/app/projection-detail-header.d.ts +6 -1
- package/dist/app/projection-detail-header.js +75 -18
- package/dist/app/projection-detail-states.d.ts +3 -3
- package/dist/app/projection-list-body.js +4 -2
- package/dist/app/projection-list-render.js +3 -1
- package/dist/app/projection-list-shim.d.ts +4 -1
- package/dist/app/projection-list-shim.js +35 -8
- package/dist/app/reference-link.d.ts +3 -2
- package/dist/app/reference-link.js +19 -4
- package/dist/app/row-actions.js +3 -3
- package/dist/app/screen-access.d.ts +4 -0
- package/dist/app/screen-access.js +19 -0
- package/dist/app/screen-shared.js +3 -1
- package/dist/app/unique-label-keys.d.ts +1 -0
- package/dist/app/unique-label-keys.js +9 -0
- package/dist/app/use-entity-list-payload.d.ts +25 -0
- package/dist/app/use-entity-list-payload.js +57 -0
- package/dist/app/use-entity-range-facets.js +2 -3
- package/dist/app/use-facet-counts.d.ts +5 -0
- package/dist/app/use-facet-counts.js +7 -0
- package/dist/app/use-list-summary-row.d.ts +10 -0
- package/dist/app/use-list-summary-row.js +33 -0
- package/dist/app/use-named-filter-queue.d.ts +20 -0
- package/dist/app/use-named-filter-queue.js +9 -0
- package/dist/app/use-projection-detail-actions.d.ts +4 -4
- package/dist/app/use-projection-detail-actions.js +30 -1
- package/dist/app/use-projection-list-data.d.ts +5 -0
- package/dist/app/use-projection-list-data.js +35 -6
- package/dist/app/use-projection-list-query.d.ts +2 -0
- package/dist/app/use-projection-list-query.js +29 -16
- package/dist/app/use-related-list-tab-counts.js +5 -1
- package/dist/app/use-row-decoration.d.ts +11 -0
- package/dist/app/use-row-decoration.js +55 -0
- package/dist/app/use-screen-list-rows.d.ts +4 -1
- package/dist/app/use-screen-list-rows.js +14 -5
- package/dist/app/use-screen-list-table.d.ts +3 -1
- package/dist/app/use-screen-list-table.js +10 -1
- package/dist/app/write-failed-error.d.ts +1 -0
- package/dist/app/write-failed-error.js +10 -0
- package/dist/compact-tap-classes.d.ts +1 -0
- package/dist/compact-tap-classes.js +3 -0
- package/dist/components/embedded-list-field.js +13 -12
- package/dist/components/form-pending-uploads.d.ts +8 -0
- package/dist/components/form-pending-uploads.js +27 -0
- package/dist/components/list-empty-state.d.ts +8 -1
- package/dist/components/list-empty-state.js +4 -1
- package/dist/components/list-group-page-bridges.d.ts +1 -1
- package/dist/components/list-group-page-bridges.js +2 -2
- package/dist/components/related-list-section.js +4 -22
- package/dist/components/render-edit-action-button.d.ts +3 -1
- package/dist/components/render-edit-action-button.js +5 -3
- package/dist/components/render-edit-form-actions.js +6 -3
- package/dist/components/render-edit-layout.js +2 -1
- package/dist/components/render-edit-render-model.d.ts +2 -2
- package/dist/components/render-edit-submit.js +2 -1
- package/dist/components/render-edit-types.d.ts +4 -2
- package/dist/components/render-edit.js +3 -1
- package/dist/components/render-list-hint-columns.d.ts +8 -0
- package/dist/components/render-list-hint-columns.js +77 -0
- package/dist/components/render-list-reference-columns.js +4 -2
- package/dist/components/render-list-row-tone.d.ts +3 -0
- package/dist/components/render-list-row-tone.js +10 -0
- package/dist/components/render-list-table-props.d.ts +9 -1
- package/dist/components/render-list-table-props.js +4 -1
- package/dist/components/render-list-toolbar-action.d.ts +1 -2
- package/dist/components/render-list-toolbar-model.d.ts +3 -0
- package/dist/components/render-list-toolbar-model.js +21 -6
- package/dist/components/render-list-toolbar.d.ts +3 -2
- package/dist/components/render-list-toolbar.js +8 -6
- package/dist/components/render-list-types.d.ts +6 -1
- package/dist/components/render-list.js +26 -7
- package/dist/components/use-render-edit-controlled-sync.js +5 -4
- package/dist/components/use-render-edit-draft-save.js +7 -9
- package/dist/components/use-render-edit-schema.d.ts +3 -0
- package/dist/components/use-render-edit-schema.js +15 -0
- package/dist/components/use-render-edit-state.d.ts +4 -0
- package/dist/components/use-render-edit-state.js +9 -1
- package/dist/components/use-render-edit-steps.js +2 -3
- package/dist/components/use-render-list-columns.d.ts +3 -1
- package/dist/components/use-render-list-columns.js +22 -10
- package/dist/context/screen-focus-context.d.ts +14 -0
- package/dist/context/screen-focus-context.js +28 -0
- package/dist/data-table-facet-types.d.ts +2 -0
- package/dist/data-table-view-types.d.ts +20 -1
- package/dist/headless/form/form-controller.js +3 -1
- package/dist/headless/form/zod-bridge.d.ts +7 -1
- package/dist/headless/form/zod-bridge.js +10 -0
- package/dist/headless/index.d.ts +2 -1
- package/dist/headless/index.js +1 -0
- package/dist/headless/pwa-service-worker-meta.d.ts +1 -0
- package/dist/headless/pwa-service-worker-meta.js +3 -0
- package/dist/headless/view-model/index.d.ts +1 -1
- package/dist/headless/view-model/list-file-display.js +3 -2
- package/dist/headless/view-model/list.js +16 -0
- package/dist/headless/view-model/types.d.ts +33 -0
- package/dist/hooks/list-column-layout.js +2 -1
- package/dist/hooks/list-server-groups.js +14 -1
- package/dist/hooks/list-state-schema.d.ts +1 -0
- package/dist/hooks/list-state-schema.js +9 -1
- package/dist/hooks/use-debounced-value.d.ts +1 -0
- package/dist/hooks/use-debounced-value.js +11 -0
- package/dist/hooks/use-list-aggregates.d.ts +5 -1
- package/dist/hooks/use-list-aggregates.js +9 -5
- package/dist/hooks/use-list-table.d.ts +2 -1
- package/dist/hooks/use-list-table.js +3 -9
- package/dist/hooks/use-list-url-state.d.ts +2 -0
- package/dist/hooks/use-list-url-state.js +12 -4
- package/dist/hooks/use-list-view-state.js +23 -3
- package/dist/hooks/use-reference-lookup.js +7 -2
- package/dist/hooks/use-remembered-list-params.d.ts +6 -2
- package/dist/hooks/use-remembered-list-params.js +18 -3
- package/dist/hooks/use-store.js +0 -1
- package/dist/i18n-defaults.js +37 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +5 -1
- package/dist/live/dispatcher-live.js +2 -0
- package/dist/metric-types.d.ts +2 -0
- package/dist/primitives-record-guidance.d.ts +53 -0
- package/dist/primitives-record-guidance.js +1 -0
- package/dist/primitives.d.ts +41 -31
- package/dist/server-clock.d.ts +6 -0
- package/dist/server-clock.js +20 -0
- package/dist/session/session-ended.d.ts +1 -0
- package/dist/session/session-ended.js +2 -2
- package/dist/status-tone.d.ts +1 -0
- package/dist/status-tone.js +5 -0
- package/dist/web/app/browser-locale.js +1 -1
- package/dist/web/app/client-plugin.d.ts +6 -1
- package/dist/web/app/create-app.d.ts +2 -1
- package/dist/web/app/create-app.js +15 -5
- package/dist/web/app/dashboard-body.js +25 -11
- package/dist/web/app/dashboard-header.d.ts +2 -1
- package/dist/web/app/dashboard-header.js +19 -7
- package/dist/web/app/dashboard-list-panel.d.ts +12 -0
- package/dist/web/app/dashboard-list-panel.js +149 -0
- package/dist/web/app/dashboard-narrow-gate.d.ts +6 -0
- package/dist/web/app/dashboard-narrow-gate.js +6 -0
- package/dist/web/app/dashboard-narrow-order.d.ts +3 -0
- package/dist/web/app/dashboard-narrow-order.js +6 -0
- package/dist/web/app/dashboard-navigation-link.d.ts +12 -0
- package/dist/web/app/dashboard-navigation-link.js +21 -0
- package/dist/web/app/dashboard-panels.d.ts +6 -23
- package/dist/web/app/dashboard-panels.js +53 -123
- package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
- package/dist/web/app/dashboard-reference-list-table.js +12 -4
- package/dist/web/app/dashboard-shared.d.ts +23 -7
- package/dist/web/app/dashboard-shared.js +44 -17
- package/dist/web/app/dashboard-stat-group-panel.d.ts +13 -0
- package/dist/web/app/dashboard-stat-group-panel.js +67 -0
- package/dist/web/app/dashboard-text-panel.d.ts +12 -0
- package/dist/web/app/dashboard-text-panel.js +163 -0
- package/dist/web/app/dashboard-text.d.ts +2 -0
- package/dist/web/app/dashboard-text.js +1 -1
- package/dist/web/app/dashboard-visibility.js +1 -1
- package/dist/web/app/relative-time.js +2 -1
- package/dist/web/editor/editor-footer.d.ts +28 -0
- package/dist/web/editor/editor-footer.js +23 -0
- package/dist/web/editor/editor-frame.d.ts +23 -0
- package/dist/web/editor/editor-frame.js +24 -0
- package/dist/web/editor/editor-header.d.ts +36 -0
- package/dist/web/editor/editor-header.js +30 -0
- package/dist/web/editor/editor-rail.d.ts +32 -0
- package/dist/web/editor/editor-rail.js +37 -0
- package/dist/web/editor/editor-workbench.d.ts +34 -0
- package/dist/web/editor/editor-workbench.js +19 -0
- package/dist/web/editor/index.d.ts +6 -0
- package/dist/web/editor/index.js +6 -0
- package/dist/web/editor/relative-when.d.ts +1 -0
- package/dist/web/editor/relative-when.js +18 -0
- package/dist/web/index.d.ts +7 -1
- package/dist/web/index.js +5 -1
- package/dist/web/layout/default-app-shell.js +6 -4
- package/dist/web/layout/focus-aware-sidebar.d.ts +4 -7
- package/dist/web/layout/focus-aware-sidebar.js +5 -7
- package/dist/web/layout/header-action-pinned.d.ts +8 -0
- package/dist/web/layout/header-action-pinned.js +25 -0
- package/dist/web/layout/nav-collapse-state.d.ts +5 -0
- package/dist/web/layout/nav-collapse-state.js +66 -0
- package/dist/web/layout/nav-tree.js +25 -5
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.d.ts +8 -0
- package/dist/web/layout/screen-focus.js +42 -0
- package/dist/web/layout/shell-focus.d.ts +6 -5
- package/dist/web/layout/shell-focus.js +12 -9
- package/dist/web/layout/shell-header.js +38 -10
- package/dist/web/layout/sidebar-open-state.d.ts +6 -0
- package/dist/web/layout/sidebar-open-state.js +28 -0
- package/dist/web/layout/uniform-bar-controls.d.ts +2 -2
- package/dist/web/layout/uniform-bar-controls.js +4 -3
- package/dist/web/layout/use-in-app-inbox.js +8 -1
- package/dist/web/layout/workspace-shell.js +6 -4
- package/dist/web/lib/upload-file-ref.d.ts +2 -2
- package/dist/web/lib/upload-file-ref.js +4 -9
- package/dist/web/presence/use-presence.js +7 -2
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +14 -6
- package/dist/web/primitives/calendar-day-picker.js +24 -5
- package/dist/web/primitives/card.js +1 -1
- package/dist/web/primitives/code-input.js +6 -1
- package/dist/web/primitives/data-table/actions-column.d.ts +1 -0
- package/dist/web/primitives/data-table/actions-column.js +4 -2
- package/dist/web/primitives/data-table/card-body.d.ts +5 -0
- package/dist/web/primitives/data-table/card-body.js +47 -5
- package/dist/web/primitives/data-table/card-frame.d.ts +8 -0
- package/dist/web/primitives/data-table/card-frame.js +9 -0
- package/dist/web/primitives/data-table/card-row.js +40 -7
- package/dist/web/primitives/data-table/card-sort-select.d.ts +6 -2
- package/dist/web/primitives/data-table/card-sort-select.js +10 -7
- package/dist/web/primitives/data-table/card-view.js +12 -2
- package/dist/web/primitives/data-table/column-picker-section.js +9 -2
- package/dist/web/primitives/data-table/column-resize-handle.js +3 -4
- package/dist/web/primitives/data-table/column-role.d.ts +1 -0
- package/dist/web/primitives/data-table/column-role.js +1 -0
- package/dist/web/primitives/data-table/data-cell-props.d.ts +5 -0
- package/dist/web/primitives/data-table/data-cell-props.js +5 -0
- package/dist/web/primitives/data-table/density.js +1 -0
- package/dist/web/primitives/data-table/facet-cluster.d.ts +2 -1
- package/dist/web/primitives/data-table/facet-cluster.js +2 -2
- package/dist/web/primitives/data-table/group-band.js +4 -0
- package/dist/web/primitives/data-table/hint-cell.d.ts +16 -0
- package/dist/web/primitives/data-table/hint-cell.js +74 -0
- package/dist/web/primitives/data-table/hint-column-width.d.ts +3 -0
- package/dist/web/primitives/data-table/hint-column-width.js +11 -0
- package/dist/web/primitives/data-table/measure-value.js +2 -3
- package/dist/web/primitives/data-table/row-action-column.d.ts +3 -0
- package/dist/web/primitives/data-table/row-action-column.js +4 -0
- package/dist/web/primitives/data-table/sort-options-select.d.ts +22 -0
- package/dist/web/primitives/data-table/sort-options-select.js +46 -0
- package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
- package/dist/web/primitives/data-table/sortable-header.js +5 -3
- package/dist/web/primitives/data-table/table-body.d.ts +1 -1
- package/dist/web/primitives/data-table/table-body.js +5 -3
- package/dist/web/primitives/data-table/table-chrome.js +3 -1
- package/dist/web/primitives/data-table/table-content.js +10 -5
- package/dist/web/primitives/data-table/table-data-cell.js +9 -3
- package/dist/web/primitives/data-table/table-header-row.js +5 -2
- package/dist/web/primitives/data-table/table-view.js +17 -3
- package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +31 -3
- package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
- package/dist/web/primitives/data-table/totals-footer.js +40 -9
- package/dist/web/primitives/data-table/use-bulk-selection.js +2 -1
- package/dist/web/primitives/data-table/use-column-pins.js +4 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +1 -0
- package/dist/web/primitives/data-table/use-data-table-state.js +9 -5
- package/dist/web/primitives/data-table/use-measured-column-widths.js +5 -4
- package/dist/web/primitives/data-table/use-row-selection.js +22 -11
- package/dist/web/primitives/data-table/view-menu.js +7 -1
- package/dist/web/primitives/data-table-cell.d.ts +21 -2
- package/dist/web/primitives/data-table-cell.js +96 -19
- package/dist/web/primitives/embedded-file-cell.js +10 -6
- package/dist/web/primitives/embedded-list-cards.js +3 -4
- package/dist/web/primitives/facet-filter.d.ts +4 -2
- package/dist/web/primitives/facet-filter.js +26 -3
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/file-thumbnail.d.ts +6 -2
- package/dist/web/primitives/file-thumbnail.js +13 -6
- package/dist/web/primitives/file-upload.js +15 -11
- package/dist/web/primitives/file-view-action.d.ts +6 -0
- package/dist/web/primitives/file-view-action.js +19 -0
- package/dist/web/primitives/files-dropzone.js +18 -4
- package/dist/web/primitives/form-footer-parts.d.ts +0 -1
- package/dist/web/primitives/form.js +0 -1
- package/dist/web/primitives/hint-reason-row.d.ts +32 -0
- package/dist/web/primitives/hint-reason-row.js +45 -0
- package/dist/web/primitives/index.js +6 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +2 -2
- package/dist/web/primitives/metric.js +8 -6
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +29 -18
- package/dist/web/primitives/reason-box.d.ts +20 -0
- package/dist/web/primitives/reason-box.js +13 -0
- package/dist/web/primitives/record-breadcrumb.d.ts +3 -0
- package/dist/web/primitives/record-breadcrumb.js +11 -0
- package/dist/web/primitives/record-steps.d.ts +3 -0
- package/dist/web/primitives/record-steps.js +45 -0
- package/dist/web/primitives/record-summary.d.ts +3 -0
- package/dist/web/primitives/record-summary.js +18 -0
- package/dist/web/primitives/row-actions.d.ts +3 -1
- package/dist/web/primitives/row-actions.js +14 -5
- package/dist/web/primitives/segmented-select.js +5 -7
- package/dist/web/pwa/pwa-support.d.ts +4 -0
- package/dist/web/pwa/pwa-support.js +113 -0
- package/dist/web/sse/live-events.js +2 -2
- package/dist/web/tokens.js +0 -3
- package/dist/web/widgets/chart-parts.d.ts +7 -1
- package/dist/web/widgets/chart-parts.js +10 -4
- package/dist/web/widgets/collapsible-section.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.d.ts +17 -0
- package/dist/web/widgets/dashboard-list-cards.js +54 -0
- package/dist/web/widgets/dashboard-list.d.ts +37 -5
- package/dist/web/widgets/dashboard-list.js +95 -20
- package/dist/web/widgets/drawer-sizing.js +1 -1
- package/dist/web/widgets/floating-panel.js +4 -2
- package/dist/web/widgets/index.d.ts +2 -0
- package/dist/web/widgets/index.js +2 -0
- package/dist/web/widgets/infinity-list.js +18 -11
- package/dist/web/widgets/preview-width-frame.d.ts +7 -0
- package/dist/web/widgets/preview-width-frame.js +10 -0
- package/dist/web/widgets/section-card.d.ts +1 -1
- package/dist/web/widgets/stacked-area-chrome.js +3 -3
- package/dist/web/widgets/stacked-area-tooltip.js +2 -10
- package/dist/web/widgets/stat-box-cell.d.ts +19 -0
- package/dist/web/widgets/stat-box-cell.js +10 -0
- package/dist/web/widgets/stat.d.ts +10 -1
- package/dist/web/widgets/stat.js +14 -5
- package/dist/web/widgets/status-badge.d.ts +7 -5
- package/dist/web/widgets/status-badge.js +2 -2
- package/dist/web/widgets/step-bar.d.ts +1 -1
- package/dist/web/widgets/step-bar.js +37 -7
- package/dist/web/widgets/upload-zone.d.ts +8 -1
- package/dist/web/widgets/upload-zone.js +13 -3
- package/package.json +5 -5
- package/src/changes.json +223 -0
- package/src/web/styles.css +9 -0
|
@@ -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,7 @@ 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
36
|
export {};
|
|
@@ -123,6 +123,32 @@ export function useProjectionDetailActions(input) {
|
|
|
123
123
|
handleRecordLeft,
|
|
124
124
|
sameEntityScreenId,
|
|
125
125
|
]);
|
|
126
|
+
const buildItemActions = useCallback((actions, item) => buildRecordActions({
|
|
127
|
+
actions,
|
|
128
|
+
record: item,
|
|
129
|
+
translate: effectiveTranslate,
|
|
130
|
+
nav,
|
|
131
|
+
host,
|
|
132
|
+
dispatcher,
|
|
133
|
+
openDrawer,
|
|
134
|
+
onWriteSuccess: reloadDetail,
|
|
135
|
+
onRecordLeft: handleRecordLeft,
|
|
136
|
+
sameEntityScreenId,
|
|
137
|
+
clientActions,
|
|
138
|
+
defaultWritePayloadId: effectiveEntityId ?? stringId(detailQuery.data?.["id"]),
|
|
139
|
+
}), [
|
|
140
|
+
detailQuery.data,
|
|
141
|
+
effectiveEntityId,
|
|
142
|
+
reloadDetail,
|
|
143
|
+
effectiveTranslate,
|
|
144
|
+
nav,
|
|
145
|
+
host,
|
|
146
|
+
dispatcher,
|
|
147
|
+
clientActions,
|
|
148
|
+
openDrawer,
|
|
149
|
+
handleRecordLeft,
|
|
150
|
+
sameEntityScreenId,
|
|
151
|
+
]);
|
|
126
152
|
const headerActions = useMemo(() => {
|
|
127
153
|
const declaredHasEdit = screen.actions?.some((a) => a.id === "edit") === true;
|
|
128
154
|
const resolved = buildRecordActions({
|
|
@@ -157,5 +183,8 @@ export function useProjectionDetailActions(input) {
|
|
|
157
183
|
handleRecordLeft,
|
|
158
184
|
sameEntityScreenId,
|
|
159
185
|
]);
|
|
160
|
-
return { buildSectionActions, headerActions };
|
|
186
|
+
return { buildSectionActions, buildItemActions, headerActions };
|
|
187
|
+
}
|
|
188
|
+
function stringId(value) {
|
|
189
|
+
return typeof value === "string" && value !== "" ? value : undefined;
|
|
161
190
|
}
|
|
@@ -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,11 @@
|
|
|
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
|
+
* One decoration call per list answer. `answerToken` changes with every new list answer;
|
|
7
|
+
* the decoration query is not live itself. A changed id set refetches through the payload,
|
|
8
|
+
* so only a new answer with the same ids calls `refetch`. Loading and error show the plain rows.
|
|
9
|
+
*/
|
|
10
|
+
export declare function useRowDecoration(decoration: ListRowDecoration | undefined, rows: readonly Row[], answerToken: unknown): readonly Row[];
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
2
|
+
import { useEffect, useMemo, useRef } 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
|
+
/** Decoration fields win over same-named row fields; the row id is kept. Entries for ids not in `rows` and malformed entries are ignored. */
|
|
23
|
+
export function mergeRowDecoration(rows, answer) {
|
|
24
|
+
const byId = decorationFieldsById(answer);
|
|
25
|
+
if (byId.size === 0)
|
|
26
|
+
return rows;
|
|
27
|
+
return rows.map((row) => {
|
|
28
|
+
const id = rowId(row);
|
|
29
|
+
const fields = id === undefined ? undefined : byId.get(id);
|
|
30
|
+
return fields === undefined ? row : { ...row, ...fields, id: row["id"] };
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* One decoration call per list answer. `answerToken` changes with every new list answer;
|
|
35
|
+
* the decoration query is not live itself. A changed id set refetches through the payload,
|
|
36
|
+
* so only a new answer with the same ids calls `refetch`. Loading and error show the plain rows.
|
|
37
|
+
*/
|
|
38
|
+
export function useRowDecoration(decoration, rows, answerToken) {
|
|
39
|
+
const ids = rows.flatMap((row) => {
|
|
40
|
+
const id = rowId(row);
|
|
41
|
+
return id === undefined ? [] : [id];
|
|
42
|
+
});
|
|
43
|
+
const idsKey = ids.join("\n");
|
|
44
|
+
const enabled = decoration !== undefined && ids.length > 0;
|
|
45
|
+
const { data, error, refetch } = useQuery(decoration?.query ?? "", { ...decoration?.params, ids }, { enabled });
|
|
46
|
+
const lastAnswerRef = useRef(null);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
const last = lastAnswerRef.current;
|
|
49
|
+
lastAnswerRef.current = enabled ? { token: answerToken, idsKey } : null;
|
|
50
|
+
if (enabled && last !== null && last.token !== answerToken && last.idsKey === idsKey) {
|
|
51
|
+
void refetch();
|
|
52
|
+
}
|
|
53
|
+
}, [enabled, answerToken, idsKey, refetch]);
|
|
54
|
+
return useMemo(() => (!enabled || error !== null || data === null ? rows : mergeRowDecoration(rows, data)), [enabled, error, data, rows]);
|
|
55
|
+
}
|
|
@@ -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);
|
|
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
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const COMPACT_TAP_CLASSES = "relative h-8 px-2.5 text-xs max-md:min-h-0 before:absolute before:inset-x-0 before:-inset-y-1.5 before:content-['']";
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// The button looks 32px high but keeps a 44px touch area: the ::before layer reaches 6px past the
|
|
2
|
+
// visible border on top and bottom. Tailwind needs the literal class string.
|
|
3
|
+
export const COMPACT_TAP_CLASSES = "relative h-8 px-2.5 text-xs max-md:min-h-0 before:absolute before:inset-x-0 before:-inset-y-1.5 before:content-['']";
|
|
@@ -4,12 +4,13 @@ import { isPlainObject } from "@cosmicdrift/kumiko-types/type-guards";
|
|
|
4
4
|
import { useState } from "react";
|
|
5
5
|
import { groupEmbeddedListIssues, sumEmbeddedListColumn, withDerivedCells, } from "../headless/index.js";
|
|
6
6
|
import { pluralKey } from "../headless/plural-key.js";
|
|
7
|
-
import { REFERENCE_COMBOBOX_LIMIT } from "../hooks/reference-limits.js";
|
|
7
|
+
import { REFERENCE_COMBOBOX_LIMIT, REFERENCE_LIST_LOOKUP_LIMIT, } from "../hooks/reference-limits.js";
|
|
8
8
|
import { useQuery } from "../hooks/use-query.js";
|
|
9
9
|
import { referenceOptionSource, storedReferenceRowsPayload, withUnlistedSelectedRows, } from "../hooks/use-reference-lookup.js";
|
|
10
10
|
import { useTranslation } from "../i18n.js";
|
|
11
11
|
import { usePrimitives } from "../primitives.js";
|
|
12
12
|
import { coerceCellValue } from "./embedded-list-paste.js";
|
|
13
|
+
import { referenceIdChunks } from "./render-list-reference-columns.js";
|
|
13
14
|
// The primitive never imports condition logic, so the per-row state is evaluated here.
|
|
14
15
|
function rowStateCallbacks(cell, derivedDef) {
|
|
15
16
|
const { visibleWhen, requiredWhen } = cell;
|
|
@@ -42,12 +43,15 @@ function cardPlacementByField(derived, cells) {
|
|
|
42
43
|
const [value, min, max] = def.from;
|
|
43
44
|
if (value === undefined || min === undefined || max === undefined)
|
|
44
45
|
continue;
|
|
46
|
+
const merge = (field, next) => {
|
|
47
|
+
placement.set(field, { ...placement.get(field), ...next });
|
|
48
|
+
};
|
|
45
49
|
if (isNotEditable(min) && isNotEditable(max)) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
50
|
+
merge(value, { cardLimits: { min, max } });
|
|
51
|
+
merge(min, { hiddenInCard: true });
|
|
52
|
+
merge(max, { hiddenInCard: true });
|
|
49
53
|
}
|
|
50
|
-
|
|
54
|
+
merge(target, { cardAttachedTo: value });
|
|
51
55
|
}
|
|
52
56
|
return placement;
|
|
53
57
|
}
|
|
@@ -60,14 +64,11 @@ function cardColumnProps(cell, placement) {
|
|
|
60
64
|
}),
|
|
61
65
|
};
|
|
62
66
|
}
|
|
67
|
+
// Hooks cannot be called per chunk (fixed count per mount), so only the first chunk that fits the
|
|
68
|
+
// list handler's limit is resolved; stored references beyond it keep their raw id.
|
|
63
69
|
function storedCellIds(rows, cellField) {
|
|
64
|
-
const
|
|
65
|
-
|
|
66
|
-
const value = row[cellField];
|
|
67
|
-
if (typeof value === "string" && value !== "")
|
|
68
|
-
ids.add(value);
|
|
69
|
-
}
|
|
70
|
-
return [...ids].sort();
|
|
70
|
+
const [firstChunk = []] = referenceIdChunks(rows, cellField, REFERENCE_LIST_LOOKUP_LIMIT);
|
|
71
|
+
return [...firstChunk].sort();
|
|
71
72
|
}
|
|
72
73
|
function withRecomputedDerived(row, derived, cells) {
|
|
73
74
|
if (derived === undefined)
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type TrackFormUpload = <T>(upload: () => Promise<T>) => Promise<T>;
|
|
2
|
+
export declare const FormUploadTrackerProvider: import("react").Provider<TrackFormUpload>;
|
|
3
|
+
export declare function useTrackFormUpload(): TrackFormUpload;
|
|
4
|
+
export declare function useFormPendingUploadsHost(): {
|
|
5
|
+
pendingUploads: number;
|
|
6
|
+
pendingUploadsRef: import("react").RefObject<number>;
|
|
7
|
+
trackUpload: TrackFormUpload;
|
|
8
|
+
};
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { createContext, useCallback, useContext, useMemo, useRef, useState } from "react";
|
|
2
|
+
const runUntracked = (upload) => upload();
|
|
3
|
+
const FormUploadTrackerContext = createContext(runUntracked);
|
|
4
|
+
export const FormUploadTrackerProvider = FormUploadTrackerContext.Provider;
|
|
5
|
+
// A widget registers its in-flight upload here so the surrounding form can hold
|
|
6
|
+
// back submit until the file id has reached the form value. Outside a form the
|
|
7
|
+
// upload simply runs.
|
|
8
|
+
export function useTrackFormUpload() {
|
|
9
|
+
return useContext(FormUploadTrackerContext);
|
|
10
|
+
}
|
|
11
|
+
export function useFormPendingUploadsHost() {
|
|
12
|
+
const [pendingUploads, setPendingUploads] = useState(0);
|
|
13
|
+
// Mirror for handleSubmit: it must see a running upload before React re-renders.
|
|
14
|
+
const pendingUploadsRef = useRef(0);
|
|
15
|
+
const trackUpload = useCallback(async (upload) => {
|
|
16
|
+
pendingUploadsRef.current += 1;
|
|
17
|
+
setPendingUploads(pendingUploadsRef.current);
|
|
18
|
+
try {
|
|
19
|
+
return await upload();
|
|
20
|
+
}
|
|
21
|
+
finally {
|
|
22
|
+
pendingUploadsRef.current -= 1;
|
|
23
|
+
setPendingUploads(pendingUploadsRef.current);
|
|
24
|
+
}
|
|
25
|
+
}, []);
|
|
26
|
+
return useMemo(() => ({ pendingUploads, pendingUploadsRef, trackUpload }), [pendingUploads, trackUpload]);
|
|
27
|
+
}
|