@cosmicdrift/kumiko-renderer 0.413.1 → 0.414.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/action-form-support.js +4 -0
- package/dist/app/content-previews.d.ts +39 -0
- package/dist/app/content-previews.js +28 -0
- package/dist/app/entity-edit-screen.js +2 -5
- package/dist/app/entity-list-screen.js +30 -50
- package/dist/app/form-schema.d.ts +1 -0
- package/dist/app/form-schema.js +24 -0
- package/dist/app/list-sort-options.d.ts +4 -0
- package/dist/app/list-sort-options.js +11 -0
- package/dist/app/named-filter-facet.d.ts +17 -3
- package/dist/app/named-filter-facet.js +88 -5
- package/dist/app/projection-detail-body.d.ts +2 -4
- package/dist/app/projection-detail-body.js +7 -1
- package/dist/app/projection-detail-guidance-data.d.ts +7 -0
- package/dist/app/projection-detail-guidance-data.js +101 -0
- package/dist/app/projection-detail-guidance.d.ts +13 -0
- package/dist/app/projection-detail-guidance.js +197 -0
- package/dist/app/projection-detail-header-model.d.ts +1 -3
- package/dist/app/projection-detail-header-model.js +4 -8
- package/dist/app/projection-detail-header-region.d.ts +2 -1
- package/dist/app/projection-detail-header-region.js +63 -23
- package/dist/app/projection-detail-header.d.ts +6 -1
- package/dist/app/projection-detail-header.js +75 -18
- package/dist/app/projection-detail-states.d.ts +3 -3
- package/dist/app/projection-list-body.js +4 -2
- package/dist/app/projection-list-render.js +3 -1
- package/dist/app/projection-list-shim.d.ts +4 -1
- package/dist/app/projection-list-shim.js +35 -8
- package/dist/app/reference-link.d.ts +3 -2
- package/dist/app/reference-link.js +19 -4
- package/dist/app/row-actions.js +3 -3
- package/dist/app/screen-access.d.ts +4 -0
- package/dist/app/screen-access.js +19 -0
- package/dist/app/screen-shared.js +3 -1
- package/dist/app/unique-label-keys.d.ts +1 -0
- package/dist/app/unique-label-keys.js +9 -0
- package/dist/app/use-entity-list-payload.d.ts +25 -0
- package/dist/app/use-entity-list-payload.js +57 -0
- package/dist/app/use-entity-range-facets.js +2 -3
- package/dist/app/use-facet-counts.d.ts +5 -0
- package/dist/app/use-facet-counts.js +7 -0
- package/dist/app/use-list-summary-row.d.ts +10 -0
- package/dist/app/use-list-summary-row.js +33 -0
- package/dist/app/use-named-filter-queue.d.ts +20 -0
- package/dist/app/use-named-filter-queue.js +9 -0
- package/dist/app/use-projection-detail-actions.d.ts +4 -4
- package/dist/app/use-projection-detail-actions.js +30 -1
- package/dist/app/use-projection-list-data.d.ts +5 -0
- package/dist/app/use-projection-list-data.js +35 -6
- package/dist/app/use-projection-list-query.d.ts +2 -0
- package/dist/app/use-projection-list-query.js +29 -16
- package/dist/app/use-related-list-tab-counts.js +5 -1
- package/dist/app/use-row-decoration.d.ts +11 -0
- package/dist/app/use-row-decoration.js +55 -0
- package/dist/app/use-screen-list-rows.d.ts +4 -1
- package/dist/app/use-screen-list-rows.js +14 -5
- package/dist/app/use-screen-list-table.d.ts +3 -1
- package/dist/app/use-screen-list-table.js +10 -1
- package/dist/app/write-failed-error.d.ts +1 -0
- package/dist/app/write-failed-error.js +10 -0
- package/dist/compact-tap-classes.d.ts +1 -0
- package/dist/compact-tap-classes.js +3 -0
- package/dist/components/embedded-list-field.js +13 -12
- package/dist/components/list-empty-state.d.ts +8 -1
- package/dist/components/list-empty-state.js +4 -1
- package/dist/components/list-group-page-bridges.d.ts +1 -1
- package/dist/components/list-group-page-bridges.js +2 -2
- package/dist/components/related-list-section.js +4 -22
- package/dist/components/render-edit-action-button.d.ts +3 -1
- package/dist/components/render-edit-action-button.js +5 -3
- package/dist/components/render-edit-render-model.d.ts +2 -2
- package/dist/components/render-edit-types.d.ts +4 -2
- package/dist/components/render-edit.js +3 -1
- package/dist/components/render-list-hint-columns.d.ts +8 -0
- package/dist/components/render-list-hint-columns.js +77 -0
- package/dist/components/render-list-reference-columns.js +4 -2
- package/dist/components/render-list-row-tone.d.ts +3 -0
- package/dist/components/render-list-row-tone.js +10 -0
- package/dist/components/render-list-table-props.d.ts +9 -1
- package/dist/components/render-list-table-props.js +4 -1
- package/dist/components/render-list-toolbar-action.d.ts +1 -2
- package/dist/components/render-list-toolbar-model.d.ts +3 -0
- package/dist/components/render-list-toolbar-model.js +21 -6
- package/dist/components/render-list-toolbar.d.ts +3 -2
- package/dist/components/render-list-toolbar.js +8 -6
- package/dist/components/render-list-types.d.ts +6 -1
- package/dist/components/render-list.js +26 -7
- package/dist/components/use-render-edit-controlled-sync.js +3 -5
- package/dist/components/use-render-edit-draft-save.js +7 -9
- package/dist/components/use-render-edit-schema.d.ts +3 -0
- package/dist/components/use-render-edit-schema.js +15 -0
- package/dist/components/use-render-edit-state.d.ts +1 -0
- package/dist/components/use-render-edit-state.js +4 -1
- package/dist/components/use-render-edit-steps.js +2 -3
- package/dist/components/use-render-list-columns.d.ts +3 -1
- package/dist/components/use-render-list-columns.js +22 -10
- package/dist/context/screen-focus-context.d.ts +14 -0
- package/dist/context/screen-focus-context.js +28 -0
- package/dist/data-table-facet-types.d.ts +2 -0
- package/dist/data-table-view-types.d.ts +20 -1
- package/dist/headless/form/form-controller.js +3 -1
- package/dist/headless/form/zod-bridge.d.ts +7 -1
- package/dist/headless/form/zod-bridge.js +10 -0
- package/dist/headless/index.d.ts +2 -1
- package/dist/headless/index.js +1 -0
- package/dist/headless/pwa-service-worker-meta.d.ts +1 -0
- package/dist/headless/pwa-service-worker-meta.js +3 -0
- package/dist/headless/view-model/index.d.ts +1 -1
- package/dist/headless/view-model/list-file-display.js +3 -2
- package/dist/headless/view-model/list.js +16 -0
- package/dist/headless/view-model/types.d.ts +33 -0
- package/dist/hooks/list-column-layout.js +2 -1
- package/dist/hooks/list-server-groups.js +14 -1
- package/dist/hooks/list-state-schema.d.ts +1 -0
- package/dist/hooks/list-state-schema.js +9 -1
- package/dist/hooks/use-debounced-value.d.ts +1 -0
- package/dist/hooks/use-debounced-value.js +11 -0
- package/dist/hooks/use-list-aggregates.d.ts +5 -1
- package/dist/hooks/use-list-aggregates.js +9 -5
- package/dist/hooks/use-list-table.d.ts +2 -1
- package/dist/hooks/use-list-table.js +3 -9
- package/dist/hooks/use-list-url-state.d.ts +2 -0
- package/dist/hooks/use-list-url-state.js +12 -4
- package/dist/hooks/use-list-view-state.js +23 -3
- package/dist/hooks/use-reference-lookup.js +7 -2
- package/dist/hooks/use-remembered-list-params.d.ts +6 -2
- package/dist/hooks/use-remembered-list-params.js +18 -3
- package/dist/hooks/use-store.js +0 -1
- package/dist/i18n-defaults.js +37 -2
- package/dist/index.d.ts +7 -2
- package/dist/index.js +4 -1
- package/dist/live/dispatcher-live.js +2 -0
- package/dist/metric-types.d.ts +2 -0
- package/dist/primitives-record-guidance.d.ts +53 -0
- package/dist/primitives-record-guidance.js +1 -0
- package/dist/primitives.d.ts +41 -31
- package/dist/server-clock.d.ts +6 -0
- package/dist/server-clock.js +20 -0
- package/dist/session/session-ended.d.ts +1 -0
- package/dist/session/session-ended.js +2 -2
- package/dist/status-tone.d.ts +1 -0
- package/dist/status-tone.js +5 -0
- package/dist/web/app/browser-locale.js +1 -1
- package/dist/web/app/client-plugin.d.ts +6 -1
- package/dist/web/app/create-app.d.ts +2 -1
- package/dist/web/app/create-app.js +15 -5
- package/dist/web/app/dashboard-body.js +25 -11
- package/dist/web/app/dashboard-header.d.ts +2 -1
- package/dist/web/app/dashboard-header.js +19 -7
- package/dist/web/app/dashboard-list-panel.d.ts +12 -0
- package/dist/web/app/dashboard-list-panel.js +149 -0
- package/dist/web/app/dashboard-narrow-gate.d.ts +6 -0
- package/dist/web/app/dashboard-narrow-gate.js +6 -0
- package/dist/web/app/dashboard-narrow-order.d.ts +3 -0
- package/dist/web/app/dashboard-narrow-order.js +6 -0
- package/dist/web/app/dashboard-navigation-link.d.ts +12 -0
- package/dist/web/app/dashboard-navigation-link.js +21 -0
- package/dist/web/app/dashboard-panels.d.ts +6 -23
- package/dist/web/app/dashboard-panels.js +53 -123
- package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
- package/dist/web/app/dashboard-reference-list-table.js +12 -4
- package/dist/web/app/dashboard-shared.d.ts +23 -7
- package/dist/web/app/dashboard-shared.js +44 -17
- package/dist/web/app/dashboard-stat-group-panel.d.ts +13 -0
- package/dist/web/app/dashboard-stat-group-panel.js +67 -0
- package/dist/web/app/dashboard-text-panel.d.ts +12 -0
- package/dist/web/app/dashboard-text-panel.js +163 -0
- package/dist/web/app/dashboard-text.d.ts +2 -0
- package/dist/web/app/dashboard-text.js +1 -1
- package/dist/web/app/dashboard-visibility.js +1 -1
- package/dist/web/app/relative-time.js +2 -1
- package/dist/web/editor/editor-footer.d.ts +28 -0
- package/dist/web/editor/editor-footer.js +23 -0
- package/dist/web/editor/editor-frame.d.ts +23 -0
- package/dist/web/editor/editor-frame.js +24 -0
- package/dist/web/editor/editor-header.d.ts +36 -0
- package/dist/web/editor/editor-header.js +30 -0
- package/dist/web/editor/editor-rail.d.ts +32 -0
- package/dist/web/editor/editor-rail.js +37 -0
- package/dist/web/editor/editor-workbench.d.ts +34 -0
- package/dist/web/editor/editor-workbench.js +19 -0
- package/dist/web/editor/index.d.ts +6 -0
- package/dist/web/editor/index.js +6 -0
- package/dist/web/editor/relative-when.d.ts +1 -0
- package/dist/web/editor/relative-when.js +18 -0
- package/dist/web/index.d.ts +7 -1
- package/dist/web/index.js +5 -1
- package/dist/web/layout/default-app-shell.js +6 -4
- package/dist/web/layout/focus-aware-sidebar.d.ts +4 -7
- package/dist/web/layout/focus-aware-sidebar.js +5 -7
- package/dist/web/layout/header-action-pinned.d.ts +8 -0
- package/dist/web/layout/header-action-pinned.js +25 -0
- package/dist/web/layout/nav-collapse-state.d.ts +5 -0
- package/dist/web/layout/nav-collapse-state.js +66 -0
- package/dist/web/layout/nav-tree.js +25 -5
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.d.ts +8 -0
- package/dist/web/layout/screen-focus.js +42 -0
- package/dist/web/layout/shell-focus.d.ts +6 -5
- package/dist/web/layout/shell-focus.js +12 -9
- package/dist/web/layout/shell-header.js +38 -10
- package/dist/web/layout/sidebar-open-state.d.ts +6 -0
- package/dist/web/layout/sidebar-open-state.js +28 -0
- package/dist/web/layout/uniform-bar-controls.d.ts +2 -2
- package/dist/web/layout/uniform-bar-controls.js +4 -3
- package/dist/web/layout/use-in-app-inbox.js +8 -1
- package/dist/web/layout/workspace-shell.js +6 -4
- package/dist/web/lib/upload-file-ref.d.ts +2 -2
- package/dist/web/lib/upload-file-ref.js +4 -9
- package/dist/web/presence/use-presence.js +7 -2
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +14 -6
- package/dist/web/primitives/calendar-day-picker.js +24 -5
- package/dist/web/primitives/card.js +1 -1
- package/dist/web/primitives/code-input.js +6 -1
- package/dist/web/primitives/data-table/actions-column.d.ts +1 -0
- package/dist/web/primitives/data-table/actions-column.js +4 -2
- package/dist/web/primitives/data-table/card-body.d.ts +5 -0
- package/dist/web/primitives/data-table/card-body.js +47 -5
- package/dist/web/primitives/data-table/card-frame.d.ts +8 -0
- package/dist/web/primitives/data-table/card-frame.js +9 -0
- package/dist/web/primitives/data-table/card-row.js +40 -7
- package/dist/web/primitives/data-table/card-sort-select.d.ts +6 -2
- package/dist/web/primitives/data-table/card-sort-select.js +10 -7
- package/dist/web/primitives/data-table/card-view.js +12 -2
- package/dist/web/primitives/data-table/column-picker-section.js +9 -2
- package/dist/web/primitives/data-table/column-resize-handle.js +3 -4
- package/dist/web/primitives/data-table/column-role.d.ts +1 -0
- package/dist/web/primitives/data-table/column-role.js +1 -0
- package/dist/web/primitives/data-table/data-cell-props.d.ts +5 -0
- package/dist/web/primitives/data-table/data-cell-props.js +5 -0
- package/dist/web/primitives/data-table/density.js +1 -0
- package/dist/web/primitives/data-table/facet-cluster.d.ts +2 -1
- package/dist/web/primitives/data-table/facet-cluster.js +2 -2
- package/dist/web/primitives/data-table/group-band.js +4 -0
- package/dist/web/primitives/data-table/hint-cell.d.ts +16 -0
- package/dist/web/primitives/data-table/hint-cell.js +74 -0
- package/dist/web/primitives/data-table/hint-column-width.d.ts +3 -0
- package/dist/web/primitives/data-table/hint-column-width.js +11 -0
- package/dist/web/primitives/data-table/measure-value.js +2 -3
- package/dist/web/primitives/data-table/row-action-column.d.ts +3 -0
- package/dist/web/primitives/data-table/row-action-column.js +4 -0
- package/dist/web/primitives/data-table/sort-options-select.d.ts +22 -0
- package/dist/web/primitives/data-table/sort-options-select.js +46 -0
- package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
- package/dist/web/primitives/data-table/sortable-header.js +5 -3
- package/dist/web/primitives/data-table/table-body.d.ts +1 -1
- package/dist/web/primitives/data-table/table-body.js +5 -3
- package/dist/web/primitives/data-table/table-chrome.js +3 -1
- package/dist/web/primitives/data-table/table-content.js +10 -5
- package/dist/web/primitives/data-table/table-data-cell.js +9 -3
- package/dist/web/primitives/data-table/table-header-row.js +5 -2
- package/dist/web/primitives/data-table/table-view.js +17 -3
- package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +31 -3
- package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
- package/dist/web/primitives/data-table/totals-footer.js +40 -9
- package/dist/web/primitives/data-table/use-bulk-selection.js +2 -1
- package/dist/web/primitives/data-table/use-column-pins.js +4 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +1 -0
- package/dist/web/primitives/data-table/use-data-table-state.js +9 -5
- package/dist/web/primitives/data-table/use-measured-column-widths.js +5 -4
- package/dist/web/primitives/data-table/use-row-selection.js +22 -11
- package/dist/web/primitives/data-table/view-menu.js +7 -1
- package/dist/web/primitives/data-table-cell.d.ts +21 -2
- package/dist/web/primitives/data-table-cell.js +96 -19
- package/dist/web/primitives/embedded-file-cell.js +3 -2
- package/dist/web/primitives/embedded-list-cards.js +3 -4
- package/dist/web/primitives/facet-filter.d.ts +4 -2
- package/dist/web/primitives/facet-filter.js +26 -3
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/file-thumbnail.d.ts +6 -2
- package/dist/web/primitives/file-thumbnail.js +13 -6
- package/dist/web/primitives/file-upload.js +3 -2
- package/dist/web/primitives/file-view-action.d.ts +6 -0
- package/dist/web/primitives/file-view-action.js +19 -0
- package/dist/web/primitives/files-dropzone.js +20 -9
- package/dist/web/primitives/form-footer-parts.d.ts +0 -1
- package/dist/web/primitives/form.js +0 -1
- package/dist/web/primitives/hint-reason-row.d.ts +32 -0
- package/dist/web/primitives/hint-reason-row.js +45 -0
- package/dist/web/primitives/index.js +6 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +2 -2
- package/dist/web/primitives/metric.js +8 -6
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +29 -18
- package/dist/web/primitives/reason-box.d.ts +20 -0
- package/dist/web/primitives/reason-box.js +13 -0
- package/dist/web/primitives/record-breadcrumb.d.ts +3 -0
- package/dist/web/primitives/record-breadcrumb.js +11 -0
- package/dist/web/primitives/record-steps.d.ts +3 -0
- package/dist/web/primitives/record-steps.js +45 -0
- package/dist/web/primitives/record-summary.d.ts +3 -0
- package/dist/web/primitives/record-summary.js +18 -0
- package/dist/web/primitives/row-actions.d.ts +3 -1
- package/dist/web/primitives/row-actions.js +14 -5
- package/dist/web/primitives/segmented-select.js +5 -7
- package/dist/web/pwa/pwa-support.d.ts +4 -0
- package/dist/web/pwa/pwa-support.js +113 -0
- package/dist/web/sse/live-events.js +2 -2
- package/dist/web/tokens.js +0 -3
- package/dist/web/widgets/chart-parts.d.ts +7 -1
- package/dist/web/widgets/chart-parts.js +10 -4
- package/dist/web/widgets/collapsible-section.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.d.ts +17 -0
- package/dist/web/widgets/dashboard-list-cards.js +54 -0
- package/dist/web/widgets/dashboard-list.d.ts +37 -5
- package/dist/web/widgets/dashboard-list.js +95 -20
- package/dist/web/widgets/drawer-sizing.js +1 -1
- package/dist/web/widgets/floating-panel.js +4 -2
- package/dist/web/widgets/index.d.ts +2 -0
- package/dist/web/widgets/index.js +2 -0
- package/dist/web/widgets/infinity-list.js +18 -11
- package/dist/web/widgets/preview-width-frame.d.ts +7 -0
- package/dist/web/widgets/preview-width-frame.js +10 -0
- package/dist/web/widgets/section-card.d.ts +1 -1
- package/dist/web/widgets/stacked-area-chrome.js +3 -3
- package/dist/web/widgets/stacked-area-tooltip.js +2 -10
- package/dist/web/widgets/stat-box-cell.d.ts +19 -0
- package/dist/web/widgets/stat-box-cell.js +10 -0
- package/dist/web/widgets/stat.d.ts +10 -1
- package/dist/web/widgets/stat.js +14 -5
- package/dist/web/widgets/status-badge.d.ts +7 -5
- package/dist/web/widgets/status-badge.js +2 -2
- package/dist/web/widgets/step-bar.d.ts +1 -1
- package/dist/web/widgets/step-bar.js +37 -7
- package/dist/web/widgets/upload-zone.d.ts +8 -1
- package/dist/web/widgets/upload-zone.js +13 -3
- package/package.json +5 -5
- package/src/changes.json +217 -0
- package/src/web/styles.css +9 -0
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { normalizeListColumn } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
3
|
+
import { ChevronRight } from "lucide-react";
|
|
4
|
+
import { useNav } from "../../app/nav.js";
|
|
5
|
+
import { useScreenLinkResolver } from "../../app/reference-link.js";
|
|
6
|
+
import { namedFilterNavigateAllows, navigateTargetAllows } from "../../app/screen-access.js";
|
|
7
|
+
import { hintViewModel } from "../../components/render-list-hint-columns.js";
|
|
8
|
+
import { screenLinkFor } from "../../components/use-render-list-columns.js";
|
|
9
|
+
import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, usePrimitives, useUserRoles, } from "../../index.js";
|
|
10
|
+
import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
|
|
11
|
+
import { dashboardNavigationLink } from "./dashboard-navigation-link.js";
|
|
12
|
+
import { DashboardReferenceListTable, } from "./dashboard-reference-list-table.js";
|
|
13
|
+
import { QueryPanel, useDashboardFormats } from "./dashboard-shared.js";
|
|
14
|
+
function knownTotal(data) {
|
|
15
|
+
return typeof data.total === "number" && Number.isFinite(data.total) ? data.total : undefined;
|
|
16
|
+
}
|
|
17
|
+
function limitedEnvelope(data, limit) {
|
|
18
|
+
const rows = data.rows ?? [];
|
|
19
|
+
if (limit === undefined || rows.length <= limit)
|
|
20
|
+
return data;
|
|
21
|
+
return { rows: rows.slice(0, limit), total: knownTotal(data) ?? rows.length };
|
|
22
|
+
}
|
|
23
|
+
function listSubtitle(panel, data, translate) {
|
|
24
|
+
const own = panel.subtitle !== undefined ? translate(panel.subtitle) : undefined;
|
|
25
|
+
const count = totalText(panel, data, false, translate);
|
|
26
|
+
if (count === undefined)
|
|
27
|
+
return own;
|
|
28
|
+
return own === undefined ? count : `${own} · ${count}`;
|
|
29
|
+
}
|
|
30
|
+
/** The "{shown} of {total}" text; a `showTotal.text` / `narrowText` replaces the default key. */
|
|
31
|
+
function totalText(panel, data, narrow, translate) {
|
|
32
|
+
const { showTotal } = panel;
|
|
33
|
+
const total = knownTotal(data);
|
|
34
|
+
if (showTotal === undefined || total === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
const custom = showTotal === true
|
|
37
|
+
? undefined
|
|
38
|
+
: narrow
|
|
39
|
+
? (showTotal.narrowText ?? showTotal.text)
|
|
40
|
+
: showTotal.text;
|
|
41
|
+
return translate(custom ?? "kumiko.dashboard.list.shown-of-total", {
|
|
42
|
+
shown: (data.rows ?? []).length,
|
|
43
|
+
total,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
function ListFooter({ link, data, narrow, translate, }) {
|
|
47
|
+
const { Link } = usePrimitives();
|
|
48
|
+
const nav = useNav();
|
|
49
|
+
const appFeatures = useAppFeatures();
|
|
50
|
+
const userRoles = useUserRoles();
|
|
51
|
+
const total = knownTotal(data);
|
|
52
|
+
const remaining = total === undefined ? 0 : total - (data.rows ?? []).length;
|
|
53
|
+
const allowed = navigateTargetAllows({ screen: link.screen }, appFeatures, userRoles) &&
|
|
54
|
+
namedFilterNavigateAllows(link, appFeatures, userRoles);
|
|
55
|
+
const target = dashboardNavigationLink(nav, link);
|
|
56
|
+
return (_jsxs(_Fragment, { children: [remaining > 0 && (_jsxs("span", { "data-testid": "dashboard-list-more", children: [translate((narrow ? (link.narrowMoreText ?? link.moreText) : link.moreText) ??
|
|
57
|
+
"kumiko.dashboard.list.more", { count: remaining }), allowed && " · "] })), allowed && (_jsx(Link, { href: target.href, onPress: target.onPress, testId: "dashboard-list-footer-link", className: "font-medium", children: translate(link.label) }))] }));
|
|
58
|
+
}
|
|
59
|
+
function rowLinkResolverOf(rowLink, resolveScreenLink) {
|
|
60
|
+
if (rowLink.screenField !== undefined) {
|
|
61
|
+
const link = screenLinkFor(resolveScreenLink, rowLink.screenField, rowLink.paramsField);
|
|
62
|
+
return (row) => link(undefined, row);
|
|
63
|
+
}
|
|
64
|
+
const { paramField, screen } = rowLink;
|
|
65
|
+
return (row) => resolveScreenLink(screen, paramField === undefined ? undefined : row[paramField]);
|
|
66
|
+
}
|
|
67
|
+
// The same number and date formatting the list cells use, so the phone line agrees with the table.
|
|
68
|
+
function lineValueText(raw, display, formats) {
|
|
69
|
+
if (display === "datetime") {
|
|
70
|
+
const atMs = typeof raw === "number" ? raw : typeof raw === "string" ? Date.parse(raw) : Number.NaN;
|
|
71
|
+
return Number.isFinite(atMs) ? formats.formatDateTime(atMs) : undefined;
|
|
72
|
+
}
|
|
73
|
+
if (typeof raw === "number")
|
|
74
|
+
return formats.formatNumber(raw);
|
|
75
|
+
return typeof raw === "string" && raw !== "" ? raw : undefined;
|
|
76
|
+
}
|
|
77
|
+
function ListLine({ panel, label, data, link, translate, screenId, screenParams, }) {
|
|
78
|
+
const { Link } = usePrimitives();
|
|
79
|
+
const nav = useNav();
|
|
80
|
+
const Icon = useExtensionSectionComponent(panel.icon !== undefined ? extensionSectionName(panel.icon) : undefined);
|
|
81
|
+
const rows = data.rows ?? [];
|
|
82
|
+
const firstRow = rows[0];
|
|
83
|
+
const columns = panel.columns.map((column) => normalizeListColumn(column));
|
|
84
|
+
const lineField = panel.narrow?.field ??
|
|
85
|
+
columns.find((column) => column.display === undefined && typeof firstRow?.[column.field] === "string")?.field;
|
|
86
|
+
const formats = useDashboardFormats();
|
|
87
|
+
const firstText = lineField === undefined
|
|
88
|
+
? undefined
|
|
89
|
+
: lineValueText(firstRow?.[lineField], columns.find((column) => column.field === lineField)?.display, formats);
|
|
90
|
+
const more = (knownTotal(data) ?? rows.length) - 1;
|
|
91
|
+
const target = dashboardNavigationLink(nav, link);
|
|
92
|
+
return (_jsxs(Link, { href: target.href, onPress: target.onPress, testId: `dashboard-panel-${panel.id}`, className: "flex items-center gap-2 rounded-lg border border-border bg-card px-4 py-3 text-sm text-card-foreground", children: [Icon !== undefined && (_jsx("span", { className: "flex shrink-0 items-center", children: _jsx(Icon, { entityName: screenId, entityId: null, screenId: screenId, filterParams: screenParams.filterParams }) })), _jsxs("span", { className: "min-w-0 flex-1 truncate", children: [_jsx("span", { className: "font-semibold", children: label }), firstText !== undefined && ` · ${firstText}`, more > 0 &&
|
|
93
|
+
` · ${translate(panel.narrow?.moreText ?? "kumiko.dashboard.list.line-more", { count: more })}`] }), _jsx(ChevronRight, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" })] }));
|
|
94
|
+
}
|
|
95
|
+
function NarrowCardsPanel({ panel, label, data, columns, featureName, translate, }) {
|
|
96
|
+
const { formatPercent, formatNumber, formatDateTime } = useDashboardFormats();
|
|
97
|
+
const { footerLink } = panel;
|
|
98
|
+
const totalLabel = totalText(panel, data, true, translate);
|
|
99
|
+
return (_jsxs("section", { "data-testid": `dashboard-panel-${panel.id}`, className: "flex flex-col gap-2", children: [_jsxs("header", { className: "flex items-baseline justify-between gap-3", children: [_jsx("h2", { className: "text-sm font-semibold", children: label }), totalLabel !== undefined && (_jsx("span", { className: "text-xs text-muted-foreground", children: totalLabel }))] }), _jsx(DashboardReferenceListTable, { columns: columns, rows: data.rows ?? [], featureName: featureName, formatPercent: formatPercent, formatNumber: formatNumber, formatDateTime: formatDateTime, translate: translate, narrowCards: true, ...(panel.narrow?.titleField !== undefined && { titleField: panel.narrow.titleField }), ...(panel.rowToneField !== undefined && { rowToneField: panel.rowToneField }) }), footerLink !== undefined && (_jsx("footer", { className: "flex flex-wrap items-center gap-x-1 text-xs text-muted-foreground", children: _jsx(ListFooter, { link: footerLink, data: data, narrow: true, translate: translate }) }))] }));
|
|
100
|
+
}
|
|
101
|
+
export function ListPanelBody({ panel, label, featureName, screenId, screenParams, translate, }) {
|
|
102
|
+
const { formatPercent, formatNumber, formatDateTime } = useDashboardFormats();
|
|
103
|
+
const narrow = useIsBelowSmViewport() ? panel.narrow : undefined;
|
|
104
|
+
const narrowLimit = narrow?.limit;
|
|
105
|
+
const narrowLayout = narrow !== undefined ? (narrow.layout ?? "cards") : undefined;
|
|
106
|
+
const resolveScreenLink = useScreenLinkResolver();
|
|
107
|
+
const columns = panel.columns.map((c) => {
|
|
108
|
+
const normalized = normalizeListColumn(c);
|
|
109
|
+
const { hint } = normalized;
|
|
110
|
+
return {
|
|
111
|
+
field: normalized.field,
|
|
112
|
+
label: translate(normalized.label ?? normalized.field),
|
|
113
|
+
...(normalized.display !== undefined && { display: normalized.display }),
|
|
114
|
+
...(normalized.badgeToneField !== undefined && {
|
|
115
|
+
badgeToneField: normalized.badgeToneField,
|
|
116
|
+
}),
|
|
117
|
+
...(normalized.badgeDot !== undefined && { badgeDot: normalized.badgeDot }),
|
|
118
|
+
...(normalized.refEntity !== undefined && {
|
|
119
|
+
reference: {
|
|
120
|
+
refEntity: normalized.refEntity,
|
|
121
|
+
...(normalized.refLabelField !== undefined && {
|
|
122
|
+
refLabelField: normalized.refLabelField,
|
|
123
|
+
}),
|
|
124
|
+
},
|
|
125
|
+
}),
|
|
126
|
+
...(normalized.linkScreenField !== undefined && {
|
|
127
|
+
linkFor: screenLinkFor(resolveScreenLink, normalized.linkScreenField, normalized.linkParamsField),
|
|
128
|
+
}),
|
|
129
|
+
...(normalized.showOnNarrowOnly === true && { narrowOnly: true }),
|
|
130
|
+
...(hint !== undefined && { hint: hintViewModel(hint, panel.rowToneField, translate) }),
|
|
131
|
+
};
|
|
132
|
+
});
|
|
133
|
+
const { footerLink } = panel;
|
|
134
|
+
return (_jsx(QueryPanel, { panel: panel, label: label, subtitle: panel.subtitle === undefined && panel.showTotal === undefined
|
|
135
|
+
? undefined
|
|
136
|
+
: (data) => listSubtitle(panel, limitedEnvelope(data, narrowLimit), translate), ...(narrowLayout === "cards" && {
|
|
137
|
+
replaceShell: (data) => (_jsx(NarrowCardsPanel, { panel: panel, label: label, data: limitedEnvelope(data, narrowLimit), columns: columns, featureName: featureName, translate: translate })),
|
|
138
|
+
}), ...(narrowLayout === "line" &&
|
|
139
|
+
footerLink !== undefined && {
|
|
140
|
+
replaceShell: (data) => (_jsx(ListLine, { panel: panel, label: label, data: data, link: footerLink, translate: translate, screenId: screenId, screenParams: screenParams })),
|
|
141
|
+
}), ...(panel.subtitle !== undefined && { staticSubtitle: translate(panel.subtitle) }), footer: footerLink === undefined || (footerLink.narrowOnly === true && narrow === undefined)
|
|
142
|
+
? undefined
|
|
143
|
+
: (data) => (_jsx(ListFooter, { link: footerLink, data: limitedEnvelope(data, narrowLimit), narrow: narrow !== undefined, translate: translate })), screenParams: screenParams, translate: translate, skeleton: "rows", isEmpty: (data) => (data.rows ?? []).length === 0, children: (data) => (_jsx(DashboardReferenceListTable, { columns: columns, rows: limitedEnvelope(data, narrowLimit).rows ?? [], featureName: featureName, formatPercent: formatPercent, formatNumber: formatNumber, formatDateTime: formatDateTime, translate: translate, ...(narrowLayout === "cards" && { narrowCards: true }), ...(panel.rowLink !== undefined && {
|
|
144
|
+
rowLink: {
|
|
145
|
+
linkFor: rowLinkResolverOf(panel.rowLink, resolveScreenLink),
|
|
146
|
+
icon: panel.rowLink.icon ?? "arrow",
|
|
147
|
+
},
|
|
148
|
+
}), ...(panel.rowToneField !== undefined && { rowToneField: panel.rowToneField }), ...(panel.rowToneMarker !== undefined && { rowToneMarker: panel.rowToneMarker }), ...(panel.showHeader !== undefined && { showHeader: panel.showHeader }) })) }));
|
|
149
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
|
|
2
|
+
/** Leaves its panel unmounted below `sm`, so a hidden panel runs no query. */
|
|
3
|
+
export function HiddenOnNarrow({ hide, children, }) {
|
|
4
|
+
const belowSm = useIsBelowSmViewport();
|
|
5
|
+
return hide && belowSm ? null : children;
|
|
6
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { DashboardPanelDefinition } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
/** Under sm panels follow `narrowOrder` (default 0); `toSorted` is stable, so equal values keep the declared order. */
|
|
3
|
+
export declare function panelsInNarrowOrder(panels: readonly DashboardPanelDefinition[], belowSm: boolean): readonly DashboardPanelDefinition[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/** Under sm panels follow `narrowOrder` (default 0); `toSorted` is stable, so equal values keep the declared order. */
|
|
2
|
+
export function panelsInNarrowOrder(panels, belowSm) {
|
|
3
|
+
if (!belowSm)
|
|
4
|
+
return panels;
|
|
5
|
+
return panels.toSorted((a, b) => (a.narrowOrder ?? 0) - (b.narrowOrder ?? 0));
|
|
6
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { NavApi } from "../../app/nav.tsx";
|
|
2
|
+
export type DashboardNavigationTarget = {
|
|
3
|
+
readonly screen: string;
|
|
4
|
+
readonly namedFilter?: string;
|
|
5
|
+
readonly params?: Readonly<Record<string, string>>;
|
|
6
|
+
};
|
|
7
|
+
export type DashboardNavigationLink = {
|
|
8
|
+
readonly href: string;
|
|
9
|
+
readonly onPress: () => void;
|
|
10
|
+
};
|
|
11
|
+
export declare function optionalDashboardNavigationLink(nav: NavApi, navigate: DashboardNavigationTarget | undefined): DashboardNavigationLink | undefined;
|
|
12
|
+
export declare function dashboardNavigationLink(nav: NavApi, navigate: DashboardNavigationTarget): DashboardNavigationLink;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { lastSegment } from "../../app/qn.js";
|
|
2
|
+
import { listNamedFilterUrlKey } from "../../hooks/use-list-url-state.js";
|
|
3
|
+
// One resolver for stat tiles, list footers and stat-group links, so a namedFilter always lands
|
|
4
|
+
// as `<screenId>.filter` and the three never drift.
|
|
5
|
+
export function optionalDashboardNavigationLink(nav, navigate) {
|
|
6
|
+
return navigate === undefined ? undefined : dashboardNavigationLink(nav, navigate);
|
|
7
|
+
}
|
|
8
|
+
export function dashboardNavigationLink(nav, navigate) {
|
|
9
|
+
const target = { screenId: lastSegment(navigate.screen) };
|
|
10
|
+
const searchParams = {
|
|
11
|
+
...navigate.params,
|
|
12
|
+
...(navigate.namedFilter !== undefined && {
|
|
13
|
+
[listNamedFilterUrlKey(target.screenId)]: navigate.namedFilter,
|
|
14
|
+
}),
|
|
15
|
+
};
|
|
16
|
+
const options = Object.keys(searchParams).length === 0 ? undefined : { searchParams };
|
|
17
|
+
return {
|
|
18
|
+
href: nav.hrefFor(target, options),
|
|
19
|
+
onPress: () => nav.navigate(target, options),
|
|
20
|
+
};
|
|
21
|
+
}
|
|
@@ -1,35 +1,22 @@
|
|
|
1
|
-
import type { DashboardChartPanel, DashboardCustomPanel, DashboardFeedPanel,
|
|
1
|
+
import type { DashboardChartPanel, DashboardCustomPanel, DashboardFeedPanel, DashboardProgressListPanel, DashboardStatPanel } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import { type Translate } from "../../headless/index.ts";
|
|
4
4
|
import { type ScreenParams } from "./dashboard-shared.tsx";
|
|
5
|
-
|
|
5
|
+
type StatPanelBodyProps = {
|
|
6
6
|
readonly panel: DashboardStatPanel;
|
|
7
7
|
readonly label: string;
|
|
8
8
|
readonly screenId: string;
|
|
9
9
|
readonly screenParams: ScreenParams;
|
|
10
10
|
readonly translate: Translate;
|
|
11
|
-
readonly variant: "card" | "strip";
|
|
12
|
-
}
|
|
13
|
-
export declare function
|
|
14
|
-
readonly panel: DashboardStatGroupPanel;
|
|
15
|
-
readonly label: string | undefined;
|
|
16
|
-
readonly screenId: string;
|
|
17
|
-
readonly screenParams: ScreenParams;
|
|
18
|
-
readonly translate: Translate;
|
|
19
|
-
}): ReactNode;
|
|
11
|
+
readonly variant: "card" | "strip" | "strip-compact";
|
|
12
|
+
};
|
|
13
|
+
export declare function StatPanelBody(props: StatPanelBodyProps): ReactNode;
|
|
20
14
|
export declare function ChartPanelBody({ panel, label, screenParams, translate, }: {
|
|
21
15
|
readonly panel: DashboardChartPanel;
|
|
22
16
|
readonly label: string;
|
|
23
17
|
readonly screenParams: ScreenParams;
|
|
24
18
|
readonly translate: Translate;
|
|
25
19
|
}): ReactNode;
|
|
26
|
-
export declare function ListPanelBody({ panel, label, featureName, screenParams, translate, }: {
|
|
27
|
-
readonly panel: DashboardListPanel;
|
|
28
|
-
readonly label: string;
|
|
29
|
-
readonly featureName: string;
|
|
30
|
-
readonly screenParams: ScreenParams;
|
|
31
|
-
readonly translate: Translate;
|
|
32
|
-
}): ReactNode;
|
|
33
20
|
export declare function FeedPanelBody({ panel, label, screenParams, translate, }: {
|
|
34
21
|
readonly panel: DashboardFeedPanel;
|
|
35
22
|
readonly label: string;
|
|
@@ -42,13 +29,9 @@ export declare function ProgressListPanelBody({ panel, label, screenParams, tran
|
|
|
42
29
|
readonly screenParams: ScreenParams;
|
|
43
30
|
readonly translate: Translate;
|
|
44
31
|
}): ReactNode;
|
|
45
|
-
export declare function TextPanelBody({ panel, label, translate, }: {
|
|
46
|
-
readonly panel: DashboardTextPanel;
|
|
47
|
-
readonly label: string | undefined;
|
|
48
|
-
readonly translate: Translate;
|
|
49
|
-
}): ReactNode;
|
|
50
32
|
export declare function CustomPanelBody({ panel, screenId, filterParams, }: {
|
|
51
33
|
readonly panel: DashboardCustomPanel;
|
|
52
34
|
readonly screenId: string;
|
|
53
35
|
readonly filterParams: Readonly<Record<string, unknown>>;
|
|
54
36
|
}): ReactNode;
|
|
37
|
+
export {};
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { normalizeListColumn } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
3
2
|
import { DASHBOARD_STAT_TONES } from "@cosmicdrift/kumiko-types/screen";
|
|
4
3
|
import { isOneOf } from "@cosmicdrift/kumiko-types/type-guards";
|
|
5
4
|
import { useEffect, useState } from "react";
|
|
5
|
+
import { namedFilterNavigateAllows, navigateTargetAllows } from "../../app/screen-access.js";
|
|
6
6
|
import { rendererWarn } from "../../dev-console.js";
|
|
7
7
|
import { EMPTY_VALUE_PLACEHOLDER } from "../../headless/index.js";
|
|
8
|
-
import {
|
|
9
|
-
import { extensionSectionName, lastSegment, useExtensionSectionComponent, useNav, usePrimitives, useTranslation, useUserRoles, } from "../../index.js";
|
|
8
|
+
import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, useNav, useTranslation, useUserRoles, } from "../../index.js";
|
|
10
9
|
import { initialWindowSelection, } from "../widgets/chart-window.js";
|
|
11
10
|
import { chartToneColor, SegmentBarChart, StackedAreaChart, StackedBarChart, TimeseriesChart, } from "../widgets/charts.js";
|
|
12
11
|
import { FeedList } from "../widgets/feed-list.js";
|
|
13
12
|
import { ModeSwitch } from "../widgets/mode-switch.js";
|
|
14
13
|
import { ProgressList } from "../widgets/progress-list.js";
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
14
|
+
import { StatCard, StatStripCell, } from "../widgets/stat.js";
|
|
15
|
+
import { StatBoxCell } from "../widgets/stat-box-cell.js";
|
|
17
16
|
import { EmptyState, LoadingState } from "../widgets/states.js";
|
|
18
|
-
import {
|
|
19
|
-
import { DAY_MS, HOUR_MS, PanelError,
|
|
17
|
+
import { optionalDashboardNavigationLink } from "./dashboard-navigation-link.js";
|
|
18
|
+
import { DAY_MS, HOUR_MS, PanelError, panelPayload, QueryPanel, useDashboardFormats, useDashboardQuery, useReportPanelLoaded, } from "./dashboard-shared.js";
|
|
20
19
|
import { isRecord, resolveDashboardText } from "./dashboard-text.js";
|
|
21
20
|
function isSparkPoint(value) {
|
|
22
21
|
return (typeof value === "object" &&
|
|
@@ -40,10 +39,22 @@ function fallbackText(raw, placeholder) {
|
|
|
40
39
|
return placeholder;
|
|
41
40
|
return String(raw);
|
|
42
41
|
}
|
|
43
|
-
|
|
42
|
+
// Hidden before any query hook runs: the tile's own count query would be refused for this user.
|
|
43
|
+
export function StatPanelBody(props) {
|
|
44
|
+
const appFeatures = useAppFeatures();
|
|
45
|
+
const userRoles = useUserRoles();
|
|
46
|
+
const { navigate } = props.panel;
|
|
47
|
+
if (navigate !== undefined &&
|
|
48
|
+
!(navigateTargetAllows({ screen: navigate.screen }, appFeatures, userRoles) &&
|
|
49
|
+
namedFilterNavigateAllows(navigate, appFeatures, userRoles))) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return _jsx(StatPanelContent, { ...props });
|
|
53
|
+
}
|
|
54
|
+
function StatPanelContent({ panel, label, screenId, screenParams, translate, variant, }) {
|
|
44
55
|
const formats = useDashboardFormats();
|
|
45
56
|
const nav = useNav();
|
|
46
|
-
const link =
|
|
57
|
+
const link = optionalDashboardNavigationLink(nav, panel.navigate);
|
|
47
58
|
// Resolved HERE (not in a separate always-rendered child) so `icon` on
|
|
48
59
|
// <StatCard> is `undefined` — not a React element that renders empty —
|
|
49
60
|
// when the icon name isn't registered. StatCard gates its accent chip on
|
|
@@ -60,7 +71,7 @@ export function StatPanelBody({ panel, label, screenId, screenParams, translate,
|
|
|
60
71
|
const { data, error, loading, refetch } = useDashboardQuery(panel.query,
|
|
61
72
|
// A navigate tile counts exactly what its target list can reproduce from the URL.
|
|
62
73
|
panel.navigate === undefined ? panelPayload(panel, screenParams) : (panel.params ?? {}));
|
|
63
|
-
useReportPanelLoaded(data);
|
|
74
|
+
useReportPanelLoaded(data, loading);
|
|
64
75
|
if (loading && data === null)
|
|
65
76
|
return _jsx(LoadingState, { rows: 2 });
|
|
66
77
|
if (error !== null) {
|
|
@@ -72,40 +83,45 @@ export function StatPanelBody({ panel, label, screenId, screenParams, translate,
|
|
|
72
83
|
// A fixed tone must not paint an all-clear "0" as an alarm.
|
|
73
84
|
(rawValue === 0 ? undefined : panel.tone);
|
|
74
85
|
const sub = panel.subField !== undefined ? record[panel.subField] : undefined;
|
|
86
|
+
const dynamicLabel = panel.labelField !== undefined ? record[panel.labelField] : undefined;
|
|
87
|
+
const shownLabel = typeof dynamicLabel === "string" && dynamicLabel !== "" ? dynamicLabel : label;
|
|
75
88
|
const delta = readDelta(panel, record);
|
|
76
|
-
const
|
|
77
|
-
let value;
|
|
78
|
-
if (typeof rawValue !== "number") {
|
|
79
|
-
value =
|
|
80
|
-
resolveDashboardText(rawValue, translate, formats) ??
|
|
81
|
-
fallbackText(rawValue, EMPTY_VALUE_PLACEHOLDER);
|
|
82
|
-
}
|
|
83
|
-
else if (valueFormat?.kind === "relativeTime") {
|
|
84
|
-
value = formats.formatRelative(rawValue);
|
|
85
|
-
}
|
|
86
|
-
else {
|
|
87
|
-
value = formats.formatPanelValue(valueFormat)(rawValue);
|
|
88
|
-
}
|
|
89
|
+
const value = statValueText(rawValue, panel.valueFormat, translate, formats);
|
|
89
90
|
const spark = readSparkline(panel, record);
|
|
90
91
|
const testId = `dashboard-panel-${panel.id}`;
|
|
91
92
|
const subText = resolveDashboardText(sub, translate, formats) ?? fallbackText(sub, undefined);
|
|
92
93
|
const icon = Icon !== undefined ? (_jsx(Icon, { entityName: screenId, entityId: null, screenId: screenId, filterParams: screenParams.filterParams })) : undefined;
|
|
93
|
-
|
|
94
|
-
|
|
94
|
+
const narrowLabel = panel.narrowLabel !== undefined ? translate(panel.narrowLabel) : undefined;
|
|
95
|
+
return (_jsx(StatVariantCell, { variant: variant, cell: {
|
|
96
|
+
icon,
|
|
97
|
+
label: shownLabel,
|
|
98
|
+
value,
|
|
99
|
+
tone: tone ?? "default",
|
|
100
|
+
testId,
|
|
101
|
+
...(narrowLabel !== undefined && { narrowLabel }),
|
|
102
|
+
...(Icon !== undefined && { accentColor: panel.accentColor }),
|
|
103
|
+
...(subText !== undefined && { sub: subText }),
|
|
104
|
+
...(delta !== undefined && { delta }),
|
|
105
|
+
...(spark !== undefined && { spark }),
|
|
106
|
+
...(link !== undefined && { link }),
|
|
107
|
+
} }));
|
|
108
|
+
}
|
|
109
|
+
function StatVariantCell({ variant, cell, }) {
|
|
110
|
+
if (variant === "strip-compact") {
|
|
111
|
+
const { accentColor: _unused, ...boxCell } = cell;
|
|
112
|
+
return _jsx(StatBoxCell, { ...boxCell });
|
|
95
113
|
}
|
|
96
|
-
|
|
114
|
+
const { narrowLabel: _narrow, ...tileCell } = cell;
|
|
115
|
+
return variant === "strip" ? _jsx(StatStripCell, { ...tileCell }) : _jsx(StatCard, { ...tileCell });
|
|
97
116
|
}
|
|
98
|
-
function
|
|
99
|
-
if (
|
|
100
|
-
return
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
return
|
|
106
|
-
href: nav.hrefFor(target, options),
|
|
107
|
-
onPress: () => nav.navigate(target, options),
|
|
108
|
-
};
|
|
117
|
+
function statValueText(rawValue, valueFormat, translate, formats) {
|
|
118
|
+
if (typeof rawValue !== "number") {
|
|
119
|
+
return (resolveDashboardText(rawValue, translate, formats) ??
|
|
120
|
+
fallbackText(rawValue, EMPTY_VALUE_PLACEHOLDER));
|
|
121
|
+
}
|
|
122
|
+
if (valueFormat?.kind === "relativeTime")
|
|
123
|
+
return formats.formatRelative(rawValue);
|
|
124
|
+
return formats.formatPanelValue(valueFormat)(rawValue);
|
|
109
125
|
}
|
|
110
126
|
function readDelta(panel, record) {
|
|
111
127
|
if (panel.deltaField === undefined || panel.deltaDirectionField === undefined)
|
|
@@ -119,13 +135,6 @@ function readDelta(panel, record) {
|
|
|
119
135
|
const tone = readTone(panel.deltaToneField !== undefined ? record[panel.deltaToneField] : undefined);
|
|
120
136
|
return { value: String(value), direction, ...(tone !== undefined && { tone }) };
|
|
121
137
|
}
|
|
122
|
-
export function StatGroupPanelBody({ panel, label, screenId, screenParams, translate, }) {
|
|
123
|
-
const testId = `dashboard-panel-${panel.id}`;
|
|
124
|
-
if (label === undefined) {
|
|
125
|
-
return (_jsx("div", { "data-testid": testId, className: "grid grid-cols-2 gap-y-2 rounded-lg border border-border bg-card py-1 lg:auto-cols-fr lg:grid-flow-col lg:divide-x lg:divide-border-row", children: panel.stats.map((stat) => (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: "strip" }, stat.id))) }));
|
|
126
|
-
}
|
|
127
|
-
return (_jsx(SectionCard, { title: label, ...(panel.subtitle !== undefined && { subtitle: translate(panel.subtitle) }), testId: testId, children: _jsx("section", { className: STAT_CARD_GRID_CLASSES, children: panel.stats.map((stat) => (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: "card" }, stat.id))) }) }));
|
|
128
|
-
}
|
|
129
138
|
function markerKindColor(kind) {
|
|
130
139
|
if (kind === undefined)
|
|
131
140
|
return undefined;
|
|
@@ -239,29 +248,6 @@ export function ChartPanelBody({ panel, label, screenParams, translate, }) {
|
|
|
239
248
|
}), ariaLabel: label, testId: testId }));
|
|
240
249
|
} }));
|
|
241
250
|
}
|
|
242
|
-
export function ListPanelBody({ panel, label, featureName, screenParams, translate, }) {
|
|
243
|
-
const { formatPercent, formatNumber, formatDateTime } = useDashboardFormats();
|
|
244
|
-
const columns = panel.columns.map((c) => {
|
|
245
|
-
const normalized = normalizeListColumn(c);
|
|
246
|
-
return {
|
|
247
|
-
field: normalized.field,
|
|
248
|
-
label: translate(normalized.label ?? normalized.field),
|
|
249
|
-
...(normalized.display !== undefined && { display: normalized.display }),
|
|
250
|
-
...(normalized.badgeToneField !== undefined && {
|
|
251
|
-
badgeToneField: normalized.badgeToneField,
|
|
252
|
-
}),
|
|
253
|
-
...(normalized.refEntity !== undefined && {
|
|
254
|
-
reference: {
|
|
255
|
-
refEntity: normalized.refEntity,
|
|
256
|
-
...(normalized.refLabelField !== undefined && {
|
|
257
|
-
refLabelField: normalized.refLabelField,
|
|
258
|
-
}),
|
|
259
|
-
},
|
|
260
|
-
}),
|
|
261
|
-
};
|
|
262
|
-
});
|
|
263
|
-
return (_jsx(QueryPanel, { panel: panel, label: label, screenParams: screenParams, translate: translate, skeleton: "rows", isEmpty: (data) => (data.rows ?? []).length === 0, children: (data) => (_jsx(DashboardReferenceListTable, { columns: columns, rows: data.rows ?? [], featureName: featureName, formatPercent: formatPercent, formatNumber: formatNumber, formatDateTime: formatDateTime, translate: translate })) }));
|
|
264
|
-
}
|
|
265
251
|
export function FeedPanelBody({ panel, label, screenParams, translate, }) {
|
|
266
252
|
return (_jsx(QueryPanel, { panel: panel, label: label, screenParams: screenParams, translate: translate, skeleton: "rows", isEmpty: (data) => (data.rows ?? []).length === 0, children: (data, formats) => {
|
|
267
253
|
const rows = (data.rows ?? []).map((row, i) => {
|
|
@@ -327,62 +313,6 @@ export function ProgressListPanelBody({ panel, label, screenParams, translate, }
|
|
|
327
313
|
return _jsx(ProgressList, { rows: rows });
|
|
328
314
|
} }));
|
|
329
315
|
}
|
|
330
|
-
function TextBlockView({ block, translate, }) {
|
|
331
|
-
switch (block.kind) {
|
|
332
|
-
case "heading":
|
|
333
|
-
return (_jsx("h3", { "data-block": "heading", className: "text-sm font-semibold text-foreground", children: translate(block.text) }));
|
|
334
|
-
case "paragraph":
|
|
335
|
-
return (_jsx("p", { "data-block": "paragraph", className: block.emphasis === "strong"
|
|
336
|
-
? "text-sm font-medium text-foreground"
|
|
337
|
-
: "text-sm text-muted-foreground", children: translate(block.text) }));
|
|
338
|
-
case "list":
|
|
339
|
-
return (_jsx("ul", { "data-block": "list", className: "list-disc space-y-1 pl-5 text-sm text-muted-foreground", children: withOccurrenceKeys(block.items, (item) => item).map(({ entry, key }) => (_jsx("li", { children: translate(entry) }, key))) }));
|
|
340
|
-
case "code":
|
|
341
|
-
return (_jsx("pre", { "data-block": "code", className: "overflow-x-auto rounded-md bg-muted p-3 text-xs", children: _jsx("code", { children: block.code }) }));
|
|
342
|
-
case "hint":
|
|
343
|
-
return (_jsx("p", { "data-block": "hint", className: "text-xs text-muted-foreground", children: translate(block.text) }));
|
|
344
|
-
case "link":
|
|
345
|
-
return _jsx(TextBlockLink, { block: block, translate: translate });
|
|
346
|
-
}
|
|
347
|
-
}
|
|
348
|
-
function TextBlockLink({ block, translate, }) {
|
|
349
|
-
const { Link } = usePrimitives();
|
|
350
|
-
const nav = useNav();
|
|
351
|
-
const userRoles = useUserRoles();
|
|
352
|
-
if (block.roles !== undefined && !block.roles.some((role) => userRoles?.includes(role))) {
|
|
353
|
-
return null;
|
|
354
|
-
}
|
|
355
|
-
const target = { screenId: lastSegment(block.screen) };
|
|
356
|
-
return (_jsx(Link, { href: nav.hrefFor(target), onPress: () => nav.navigate(target), testId: `dashboard-text-link-${target.screenId}`, children: translate(block.text) }));
|
|
357
|
-
}
|
|
358
|
-
// Content-derived keys collide for identical entries; the occurrence count keeps them unique.
|
|
359
|
-
function withOccurrenceKeys(entries, contentKey) {
|
|
360
|
-
const seen = new Map();
|
|
361
|
-
return entries.map((entry) => {
|
|
362
|
-
const content = contentKey(entry);
|
|
363
|
-
const occurrence = seen.get(content) ?? 0;
|
|
364
|
-
seen.set(content, occurrence + 1);
|
|
365
|
-
return { entry, key: `${content}#${occurrence}` };
|
|
366
|
-
});
|
|
367
|
-
}
|
|
368
|
-
function textBlockKey(block) {
|
|
369
|
-
switch (block.kind) {
|
|
370
|
-
case "list":
|
|
371
|
-
return `list:${block.items.join("|")}`;
|
|
372
|
-
case "code":
|
|
373
|
-
return `code:${block.code}`;
|
|
374
|
-
default:
|
|
375
|
-
return `${block.kind}:${block.text}`;
|
|
376
|
-
}
|
|
377
|
-
}
|
|
378
|
-
export function TextPanelBody({ panel, label, translate, }) {
|
|
379
|
-
const blocks = (_jsx("div", { className: "flex flex-col gap-3", children: withOccurrenceKeys(panel.blocks, textBlockKey).map(({ entry, key }) => (_jsx(TextBlockView, { block: entry, translate: translate }, key))) }));
|
|
380
|
-
const testId = `dashboard-panel-${panel.id}`;
|
|
381
|
-
if (label !== undefined) {
|
|
382
|
-
return (_jsx(PanelShell, { testId: testId, title: label, children: blocks }));
|
|
383
|
-
}
|
|
384
|
-
return (_jsx("section", { "data-testid": testId, className: "h-full rounded-lg border border-border bg-card p-4 text-card-foreground", children: blocks }));
|
|
385
|
-
}
|
|
386
316
|
// Resolves panel.component through the same extensionSectionComponents
|
|
387
317
|
// registry as entityEdit extension sections and list header slots; it
|
|
388
318
|
// stays at its array position instead of moving into a separate slot (see
|
|
@@ -12,6 +12,10 @@ type Props = Omit<ComponentProps<typeof DashboardListTable>, "columns"> & {
|
|
|
12
12
|
readonly columns: readonly DashboardListTableColumn[];
|
|
13
13
|
readonly featureName: string;
|
|
14
14
|
readonly translate: Translate;
|
|
15
|
+
/** Phone layout: one card per row instead of the table. */
|
|
16
|
+
readonly narrowCards?: boolean;
|
|
17
|
+
/** Row field whose text replaces the card title in the phone layout. */
|
|
18
|
+
readonly titleField?: string;
|
|
15
19
|
};
|
|
16
|
-
export declare function DashboardReferenceListTable({ columns, rows, featureName, translate, ...tableProps }: Props): ReactNode;
|
|
20
|
+
export declare function DashboardReferenceListTable({ columns, rows, featureName, translate, narrowCards, titleField, ...tableProps }: Props): ReactNode;
|
|
17
21
|
export {};
|
|
@@ -6,6 +6,7 @@ import { renderReferenceLookupBridges } from "../../components/render-list-refer
|
|
|
6
6
|
import { enrichReferenceColumns, selectReferenceColumns, } from "../../components/render-list-reference-columns.js";
|
|
7
7
|
import { useReferenceColumnLookups } from "../../components/use-reference-column-lookups.js";
|
|
8
8
|
import { DashboardListTable } from "../widgets/dashboard-list.js";
|
|
9
|
+
import { DashboardListCards } from "../widgets/dashboard-list-cards.js";
|
|
9
10
|
function toReferenceViewColumn(column, featureName) {
|
|
10
11
|
if (column.reference === undefined)
|
|
11
12
|
return undefined;
|
|
@@ -22,7 +23,7 @@ function toReferenceViewColumn(column, featureName) {
|
|
|
22
23
|
}
|
|
23
24
|
// Dashboard list rows carry raw ids; reference columns resolve them to the target's label
|
|
24
25
|
// the way entity lists do.
|
|
25
|
-
export function DashboardReferenceListTable({ columns, rows, featureName, translate, ...tableProps }) {
|
|
26
|
+
export function DashboardReferenceListTable({ columns, rows, featureName, translate, narrowCards = false, titleField, ...tableProps }) {
|
|
26
27
|
const viewColumns = useMemo(() => columns.flatMap((column) => {
|
|
27
28
|
const viewColumn = toReferenceViewColumn(column, featureName);
|
|
28
29
|
return viewColumn === undefined ? [] : [viewColumn];
|
|
@@ -39,9 +40,16 @@ export function DashboardReferenceListTable({ columns, rows, featureName, transl
|
|
|
39
40
|
translate,
|
|
40
41
|
}), [viewColumns, referenceColumns, referenceLookups, resolveReferenceLink, featureName, translate]);
|
|
41
42
|
const tableColumns = columns.map((column) => {
|
|
42
|
-
const
|
|
43
|
+
const enrichedColumn = enriched.find((c) => c.field === column.field);
|
|
44
|
+
const renderer = enrichedColumn?.renderer;
|
|
43
45
|
const { reference: _reference, ...base } = column;
|
|
44
|
-
|
|
46
|
+
if (typeof renderer !== "function")
|
|
47
|
+
return base;
|
|
48
|
+
return {
|
|
49
|
+
...base,
|
|
50
|
+
renderValue: renderer,
|
|
51
|
+
...(enrichedColumn?.linkFor !== undefined && { linkFor: enrichedColumn.linkFor }),
|
|
52
|
+
};
|
|
45
53
|
});
|
|
46
|
-
return (_jsxs(_Fragment, { children: [renderReferenceLookupBridges(referenceRequests, handleLookupMap), _jsx(DashboardListTable, { columns: tableColumns, rows: rows, translate: translate, ...tableProps })] }));
|
|
54
|
+
return (_jsxs(_Fragment, { children: [renderReferenceLookupBridges(referenceRequests, handleLookupMap), narrowCards ? (_jsx(DashboardListCards, { columns: tableColumns, rows: rows, translate: translate, formatPercent: tableProps.formatPercent, formatNumber: tableProps.formatNumber, formatDateTime: tableProps.formatDateTime, ...(tableProps.testId !== undefined && { testId: tableProps.testId }), ...(tableProps.rowToneField !== undefined && { rowToneField: tableProps.rowToneField }), ...(titleField !== undefined && { titleField }) })) : (_jsx(DashboardListTable, { columns: tableColumns, rows: rows, translate: translate, ...tableProps }))] }));
|
|
47
55
|
}
|