@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
|
@@ -2,8 +2,11 @@ import type { DashboardCurrencyFormat, DashboardPanelEmptyState, DashboardPanelQ
|
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import { type Translate } from "../../headless/index.ts";
|
|
4
4
|
import { dispatcherErrorText, type UseQueryResult } from "../../index.ts";
|
|
5
|
-
export declare const
|
|
6
|
-
export declare const
|
|
5
|
+
export declare const STAT_PANEL = "lg:col-span-3";
|
|
6
|
+
export declare const WIDE_PANEL = "sm:col-span-2 lg:col-span-12";
|
|
7
|
+
export declare const HALF_PANEL = "sm:col-span-2 lg:col-span-6";
|
|
8
|
+
export declare const THIRD_PANEL = "lg:col-span-4";
|
|
9
|
+
export declare const TWO_THIRDS_PANEL = "sm:col-span-2 lg:col-span-8";
|
|
7
10
|
export declare const HOUR_MS = 3600000;
|
|
8
11
|
export declare const DAY_MS: number;
|
|
9
12
|
export type ScreenParams = {
|
|
@@ -41,6 +44,8 @@ export type DashboardFormats = {
|
|
|
41
44
|
readonly formatMonth: (atMs: number) => string;
|
|
42
45
|
readonly formatHour: (atMs: number) => string;
|
|
43
46
|
readonly formatDateTime: (atMs: number) => string;
|
|
47
|
+
/** Weekday and full date, no time: "Tuesday, 3 November 2026". */
|
|
48
|
+
readonly formatLongDate: (atMs: number) => string;
|
|
44
49
|
readonly formatMedium: (atMs: number) => string;
|
|
45
50
|
readonly formatMinor: (amountMinor: number, currency: string, fractionDigits?: number) => string;
|
|
46
51
|
/** "5 minutes ago"; the component that called `useDashboardFormats` redraws on a
|
|
@@ -52,11 +57,13 @@ export type DashboardFormats = {
|
|
|
52
57
|
readonly formatPanelAxisValue: (valueFormat: DashboardCurrencyFormat | undefined) => (value: number) => string;
|
|
53
58
|
};
|
|
54
59
|
export declare function useDashboardFormats(): DashboardFormats;
|
|
55
|
-
export declare function PanelShell({ testId, title, subtitle, action, children, }: {
|
|
60
|
+
export declare function PanelShell({ testId, title, subtitle, action, footer, children, }: {
|
|
56
61
|
readonly testId: string;
|
|
57
|
-
|
|
62
|
+
/** Without a title the panel has no header (a titleless stat-group). */
|
|
63
|
+
readonly title?: string;
|
|
58
64
|
readonly subtitle?: string;
|
|
59
65
|
readonly action?: ReactNode;
|
|
66
|
+
readonly footer?: ReactNode;
|
|
60
67
|
readonly children: ReactNode;
|
|
61
68
|
}): ReactNode;
|
|
62
69
|
export declare function PanelError({ label, error, onRetry, testId, }: {
|
|
@@ -66,14 +73,23 @@ export declare function PanelError({ label, error, onRetry, testId, }: {
|
|
|
66
73
|
readonly testId?: string;
|
|
67
74
|
}): ReactNode;
|
|
68
75
|
type SkeletonShape = "bars" | "segments" | "rows";
|
|
76
|
+
export declare function PanelSkeleton({ shape }: {
|
|
77
|
+
readonly shape: SkeletonShape;
|
|
78
|
+
}): ReactNode;
|
|
69
79
|
type QueryPanelProps<TData> = {
|
|
70
80
|
readonly panel: DashboardPanelQueryOptions & DashboardPanelEmptyState & {
|
|
71
81
|
readonly id: string;
|
|
72
82
|
readonly query: string;
|
|
73
83
|
};
|
|
74
84
|
readonly label: string;
|
|
75
|
-
|
|
85
|
+
/** A function derives the line from the loaded data (e.g. "n of m"); `staticSubtitle` stands in until then. */
|
|
86
|
+
readonly subtitle?: string | ((data: TData) => string | undefined);
|
|
87
|
+
readonly staticSubtitle?: string;
|
|
76
88
|
readonly action?: ReactNode;
|
|
89
|
+
/** Rendered under the body, only once data is shown. */
|
|
90
|
+
readonly footer?: (data: TData) => ReactNode;
|
|
91
|
+
/** Replaces the whole panel shell once data is shown, e.g. a one-line summary on phones. */
|
|
92
|
+
readonly replaceShell?: (data: TData) => ReactNode;
|
|
77
93
|
readonly screenParams: ScreenParams;
|
|
78
94
|
readonly translate: Translate;
|
|
79
95
|
readonly skeleton: SkeletonShape;
|
|
@@ -82,11 +98,11 @@ type QueryPanelProps<TData> = {
|
|
|
82
98
|
* redraws this panel and nothing else. */
|
|
83
99
|
readonly children: (data: TData, formats: DashboardFormats) => ReactNode;
|
|
84
100
|
};
|
|
85
|
-
export declare function QueryPanel<TData>({ panel, label, subtitle, action, screenParams, translate, skeleton, isEmpty, children, }: QueryPanelProps<TData>): ReactNode;
|
|
101
|
+
export declare function QueryPanel<TData>({ panel, label, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }: QueryPanelProps<TData>): ReactNode;
|
|
86
102
|
export declare function useLoadedAt(screenParams: ScreenParams): {
|
|
87
103
|
readonly loadedAtMs: number;
|
|
88
104
|
readonly reportLoaded: (atMs: number) => void;
|
|
89
105
|
};
|
|
90
106
|
export declare const PanelLoadedContext: import("react").Context<(atMs: number) => void>;
|
|
91
|
-
export declare function useReportPanelLoaded(data: unknown): void;
|
|
107
|
+
export declare function useReportPanelLoaded(data: unknown, loading: boolean): void;
|
|
92
108
|
export {};
|
|
@@ -2,14 +2,19 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { createContext, useCallback, useContext, useEffect, useRef, useState, } from "react";
|
|
3
3
|
import { currencyDecimals } from "../../headless/index.js";
|
|
4
4
|
import { dispatcherErrorText, useLocale, usePrimitives, useQuery, useTranslation, } from "../../index.js";
|
|
5
|
+
import { serverNowMs } from "../../server-clock.js";
|
|
5
6
|
import { resolveSafeLocale } from "../primitives/locale-number.js";
|
|
6
7
|
import { formatMoney } from "../primitives/money-input.js";
|
|
7
8
|
import { Skeleton } from "../ui/skeleton.js";
|
|
8
9
|
import { EmptyState, LoadingState } from "../widgets/states.js";
|
|
9
10
|
import { useRelativeTimeFormatter } from "./relative-time.js";
|
|
10
11
|
const SKELETON_SEGMENT_WIDTHS = ["100%", "72%", "48%"];
|
|
11
|
-
|
|
12
|
-
export const
|
|
12
|
+
// The dashboard grid has twelve columns on wide screens, so a stat tile is a quarter of the row.
|
|
13
|
+
export const STAT_PANEL = "lg:col-span-3";
|
|
14
|
+
export const WIDE_PANEL = "sm:col-span-2 lg:col-span-12";
|
|
15
|
+
export const HALF_PANEL = "sm:col-span-2 lg:col-span-6";
|
|
16
|
+
export const THIRD_PANEL = "lg:col-span-4";
|
|
17
|
+
export const TWO_THIRDS_PANEL = "sm:col-span-2 lg:col-span-8";
|
|
13
18
|
const CURRENCY_CODE_PATTERN = /^[A-Za-z]{3}$/;
|
|
14
19
|
export const HOUR_MS = 3_600_000;
|
|
15
20
|
export const DAY_MS = 24 * HOUR_MS;
|
|
@@ -80,6 +85,7 @@ export function useDashboardFormats() {
|
|
|
80
85
|
timeStyle: "short",
|
|
81
86
|
timeZone,
|
|
82
87
|
});
|
|
88
|
+
const longDate = new Intl.DateTimeFormat(locale, { dateStyle: "full", timeZone });
|
|
83
89
|
const medium = new Intl.DateTimeFormat(locale, { dateStyle: "medium", timeZone });
|
|
84
90
|
const formatMinor = (amountMinor, currency, fractionDigits) => formatMoney(amountMinor, currency, locale, fractionDigits);
|
|
85
91
|
return {
|
|
@@ -108,17 +114,18 @@ export function useDashboardFormats() {
|
|
|
108
114
|
formatMonth: (atMs) => month.format(atMs),
|
|
109
115
|
formatHour: (atMs) => hour.format(atMs),
|
|
110
116
|
formatDateTime: (atMs) => dateTime.format(atMs),
|
|
117
|
+
formatLongDate: (atMs) => longDate.format(atMs),
|
|
111
118
|
};
|
|
112
119
|
}
|
|
113
|
-
export function PanelShell({ testId, title, subtitle, action, children, }) {
|
|
114
|
-
return (_jsxs("section", { "data-testid": testId, className: "flex h-full flex-col rounded-lg border border-border bg-card text-card-foreground", children: [_jsxs("header", { className: "flex min-h-11 shrink-0 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b border-border-row px-4 py-2", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5", children: [_jsx("h2", { className: "text-sm font-semibold break-words", children: title }), subtitle !== undefined && _jsx("p", { className: "text-xs text-muted-foreground", children: subtitle })] }), action !== undefined && _jsx("div", { className: "shrink-0", children: action })] }), _jsx("div", { className: "grow p-4", children: children })] }));
|
|
120
|
+
export function PanelShell({ testId, title, subtitle, action, footer, children, }) {
|
|
121
|
+
return (_jsxs("section", { "data-testid": testId, className: "flex h-full flex-col rounded-lg border border-border bg-card text-card-foreground", children: [(title !== undefined || action !== undefined) && (_jsxs("header", { className: "flex min-h-11 shrink-0 flex-wrap items-center justify-between gap-x-3 gap-y-2 border-b border-border-row px-4 py-2", children: [_jsxs("div", { className: "flex min-w-0 flex-col gap-0.5 sm:flex-row sm:flex-wrap sm:items-baseline sm:gap-x-3", children: [title !== undefined && _jsx("h2", { className: "text-sm font-semibold break-words", children: title }), subtitle !== undefined && _jsx("p", { className: "text-xs text-muted-foreground", children: subtitle })] }), action !== undefined && _jsx("div", { className: "shrink-0", children: action })] })), _jsx("div", { className: "grow p-4", children: children }), footer !== undefined && (_jsx("footer", { className: "flex shrink-0 flex-wrap items-center gap-x-1 border-t border-border-row px-4 py-2 text-xs text-muted-foreground", children: footer }))] }));
|
|
115
122
|
}
|
|
116
123
|
export function PanelError({ label, error, onRetry, testId, }) {
|
|
117
124
|
const { Button } = usePrimitives();
|
|
118
125
|
const t = useTranslation();
|
|
119
126
|
return (_jsxs("div", { role: "alert", "data-testid": testId, className: "flex flex-col items-start gap-2 rounded-lg border border-dashed border-status-bad/40 px-4 py-6 text-sm", children: [_jsx("div", { className: "font-medium text-status-bad", children: t("kumiko.dashboard.panel.error.title", { label }) }), _jsx("div", { className: "text-muted-foreground", children: dispatcherErrorText(error, t) }), _jsx(Button, { variant: "secondary", onClick: onRetry, children: t("kumiko.dashboard.panel.error.retry") }), _jsx("div", { className: "text-xs text-muted-foreground", children: t("kumiko.dashboard.panel.error.isolated") })] }));
|
|
120
127
|
}
|
|
121
|
-
function PanelSkeleton({ shape }) {
|
|
128
|
+
export function PanelSkeleton({ shape }) {
|
|
122
129
|
const t = useTranslation();
|
|
123
130
|
if (shape === "rows")
|
|
124
131
|
return _jsx(LoadingState, { rows: 3 });
|
|
@@ -127,11 +134,19 @@ function PanelSkeleton({ shape }) {
|
|
|
127
134
|
}
|
|
128
135
|
return (_jsx("output", { "aria-label": t("kumiko.widget.loading"), className: "flex h-40 items-end gap-1", children: SKELETON_BAR_HEIGHTS.map((height) => (_jsx(Skeleton, { className: "flex-1", style: { height } }, height))) }));
|
|
129
136
|
}
|
|
130
|
-
|
|
137
|
+
// Without loaded data the derived line cannot be computed; the static line keeps the header height
|
|
138
|
+
// from jumping when the data arrives.
|
|
139
|
+
function resolveSubtitle(subtitle, fallback, data) {
|
|
140
|
+
if (typeof subtitle !== "function")
|
|
141
|
+
return subtitle;
|
|
142
|
+
return data === undefined ? fallback : subtitle(data);
|
|
143
|
+
}
|
|
144
|
+
export function QueryPanel({ panel, label, subtitle, staticSubtitle, action, footer, replaceShell, screenParams, translate, skeleton, isEmpty, children, }) {
|
|
131
145
|
const formats = useDashboardFormats();
|
|
132
146
|
const { data, error, loading, refetch } = useDashboardQuery(panel.query, panelPayload(panel, screenParams));
|
|
133
|
-
useReportPanelLoaded(data);
|
|
147
|
+
useReportPanelLoaded(data, loading);
|
|
134
148
|
let body;
|
|
149
|
+
let shown;
|
|
135
150
|
if (loading && data === null) {
|
|
136
151
|
body = _jsx(PanelSkeleton, { shape: skeleton });
|
|
137
152
|
}
|
|
@@ -142,30 +157,42 @@ export function QueryPanel({ panel, label, subtitle, action, screenParams, trans
|
|
|
142
157
|
body = (_jsx(EmptyState, { title: translate(panel.emptyLabel ?? "kumiko.list.no-entries"), description: panel.emptyHint !== undefined ? translate(panel.emptyHint) : undefined }));
|
|
143
158
|
}
|
|
144
159
|
else {
|
|
160
|
+
shown = data;
|
|
145
161
|
body = children(data, formats);
|
|
146
162
|
}
|
|
147
|
-
|
|
163
|
+
if (shown !== undefined && replaceShell !== undefined)
|
|
164
|
+
return replaceShell(shown);
|
|
165
|
+
return (_jsx(PanelShell, { testId: `dashboard-panel-${panel.id}`, title: label, subtitle: resolveSubtitle(subtitle, staticSubtitle, shown), action: action, footer: shown !== undefined ? footer?.(shown) : undefined, children: body }));
|
|
148
166
|
}
|
|
149
167
|
// Starts at render time and restarts whenever the merged query params change;
|
|
150
168
|
// panels additionally report each successful (re)load, so live refetches and
|
|
151
|
-
// retries keep the stamp current.
|
|
169
|
+
// retries keep the stamp current. An older report never replaces a newer answer-based stamp;
|
|
170
|
+
// the render-time stamp is only a guess from the device clock until the first answer, so
|
|
171
|
+
// that answer wins even when the app clock is pinned behind the device.
|
|
152
172
|
export function useLoadedAt(screenParams) {
|
|
153
173
|
const paramsKey = JSON.stringify([
|
|
154
174
|
screenParams.filterParams,
|
|
155
175
|
screenParams.rangeParams,
|
|
156
176
|
screenParams.recordParams,
|
|
157
177
|
]);
|
|
158
|
-
const [loaded, setLoaded] = useState(() => ({
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
178
|
+
const [loaded, setLoaded] = useState(() => ({
|
|
179
|
+
paramsKey,
|
|
180
|
+
atMs: serverNowMs(),
|
|
181
|
+
answered: false,
|
|
182
|
+
}));
|
|
183
|
+
if (loaded.paramsKey !== paramsKey) {
|
|
184
|
+
setLoaded({ paramsKey, atMs: serverNowMs(), answered: false });
|
|
185
|
+
}
|
|
186
|
+
const reportLoaded = useCallback((atMs) => setLoaded((prev) => prev.answered && prev.atMs >= atMs ? prev : { ...prev, atMs, answered: true }), []);
|
|
162
187
|
return { loadedAtMs: loaded.atMs, reportLoaded };
|
|
163
188
|
}
|
|
164
189
|
export const PanelLoadedContext = createContext(() => { });
|
|
165
|
-
|
|
190
|
+
// While `loading`, `data` still holds the answer to the previous params (useQuery keeps it
|
|
191
|
+
// until the new one lands), so only a settled answer may stamp the header.
|
|
192
|
+
export function useReportPanelLoaded(data, loading) {
|
|
166
193
|
const reportLoaded = useContext(PanelLoadedContext);
|
|
167
194
|
useEffect(() => {
|
|
168
|
-
if (data !== null)
|
|
169
|
-
reportLoaded(
|
|
170
|
-
}, [data, reportLoaded]);
|
|
195
|
+
if (data !== null && !loading)
|
|
196
|
+
reportLoaded(serverNowMs());
|
|
197
|
+
}, [data, loading, reportLoaded]);
|
|
171
198
|
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { DashboardStatGroupPanel } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { Translate } from "../../headless/index.ts";
|
|
4
|
+
import { type ScreenParams } from "./dashboard-shared.tsx";
|
|
5
|
+
type StatGroupProps = {
|
|
6
|
+
readonly panel: DashboardStatGroupPanel;
|
|
7
|
+
readonly label: string | undefined;
|
|
8
|
+
readonly screenId: string;
|
|
9
|
+
readonly screenParams: ScreenParams;
|
|
10
|
+
readonly translate: Translate;
|
|
11
|
+
};
|
|
12
|
+
export declare function StatGroupPanelBody(props: StatGroupProps): ReactNode;
|
|
13
|
+
export {};
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronRight } from "lucide-react";
|
|
3
|
+
import { useNav } from "../../app/nav.js";
|
|
4
|
+
import { navigateTargetAllows } from "../../app/screen-access.js";
|
|
5
|
+
import { extensionSectionName, useAppFeatures, useExtensionSectionComponent, usePrimitives, useUserRoles, } from "../../index.js";
|
|
6
|
+
import { cn } from "../lib/cn.js";
|
|
7
|
+
import { STAT_CARD_GRID_CLASSES } from "../widgets/stat.js";
|
|
8
|
+
import { dashboardNavigationLink } from "./dashboard-navigation-link.js";
|
|
9
|
+
import { StatPanelBody } from "./dashboard-panels.js";
|
|
10
|
+
import { PanelShell } from "./dashboard-shared.js";
|
|
11
|
+
// Literal class strings: Tailwind only emits classes it can read in the source.
|
|
12
|
+
const STAT_CARD_COLUMN_CLASSES = {
|
|
13
|
+
2: "grid grid-cols-1 gap-3 sm:grid-cols-2",
|
|
14
|
+
3: "grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3",
|
|
15
|
+
4: "grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-4",
|
|
16
|
+
};
|
|
17
|
+
// Literal class strings: Tailwind only emits classes it can read in the source.
|
|
18
|
+
const PHONE_STRIP_TONE_CLASS = {
|
|
19
|
+
accent: "max-sm:border-primary/30 max-sm:bg-primary/10",
|
|
20
|
+
ok: "max-sm:border-status-ok/30 max-sm:bg-status-ok-surface",
|
|
21
|
+
warn: "max-sm:border-status-warn/30 max-sm:bg-status-warn-surface",
|
|
22
|
+
bad: "max-sm:border-status-bad/30 max-sm:bg-status-bad-surface",
|
|
23
|
+
critical: "max-sm:border-status-critical/30 max-sm:bg-status-critical-surface",
|
|
24
|
+
neutral: "",
|
|
25
|
+
};
|
|
26
|
+
function StatGroupLink({ link, translate, stretchOnNarrow, }) {
|
|
27
|
+
const { Link } = usePrimitives();
|
|
28
|
+
const nav = useNav();
|
|
29
|
+
const appFeatures = useAppFeatures();
|
|
30
|
+
const userRoles = useUserRoles();
|
|
31
|
+
if (!navigateTargetAllows({ screen: link.screen }, appFeatures, userRoles))
|
|
32
|
+
return null;
|
|
33
|
+
const target = dashboardNavigationLink(nav, link);
|
|
34
|
+
return (_jsxs(Link, { href: target.href, onPress: target.onPress, testId: "dashboard-stat-group-link", className: stretchOnNarrow
|
|
35
|
+
? "ml-auto flex shrink-0 items-center gap-1 text-sm font-medium max-sm:after:absolute max-sm:after:inset-0"
|
|
36
|
+
: "ml-auto flex shrink-0 items-center gap-1 text-sm font-medium", children: [_jsx("span", { className: stretchOnNarrow ? "max-sm:sr-only" : undefined, children: translate(link.label) }), _jsx(ChevronRight, { className: "size-4", "aria-hidden": "true" })] }));
|
|
37
|
+
}
|
|
38
|
+
function StatCells({ panel, screenId, screenParams, translate, variant, }) {
|
|
39
|
+
return panel.stats.map((stat) => (_jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: screenId, screenParams: screenParams, translate: translate, variant: variant }, stat.id)));
|
|
40
|
+
}
|
|
41
|
+
function FlatStatStrip(props) {
|
|
42
|
+
const { panel, translate } = props;
|
|
43
|
+
return (_jsxs("div", { "data-testid": `dashboard-panel-${panel.id}`, className: "rounded-lg border border-border bg-card py-1 lg:flex lg:items-center", children: [_jsx("div", { className: "grid grow grid-cols-2 gap-y-2 lg:auto-cols-fr lg:grid-flow-col lg:divide-x lg:divide-border-row", children: _jsx(StatCells, { ...props, variant: "strip" }) }), panel.link !== undefined && (_jsx("div", { className: "flex px-4 max-lg:pt-1 lg:shrink-0", children: _jsx(StatGroupLink, { link: panel.link, translate: translate, stretchOnNarrow: false }) }))] }));
|
|
44
|
+
}
|
|
45
|
+
function PhoneStripIcon({ panel, screenId, screenParams, }) {
|
|
46
|
+
const Icon = useExtensionSectionComponent(panel.icon !== undefined ? extensionSectionName(panel.icon) : undefined);
|
|
47
|
+
if (Icon === undefined)
|
|
48
|
+
return null;
|
|
49
|
+
return (_jsx("span", { className: "flex shrink-0 items-center self-center sm:hidden", children: _jsx(Icon, { entityName: screenId, entityId: null, screenId: screenId, filterParams: screenParams.filterParams }) }));
|
|
50
|
+
}
|
|
51
|
+
function TitledStatStrip(props) {
|
|
52
|
+
const { panel, label, translate } = props;
|
|
53
|
+
return (_jsxs("div", { "data-testid": `dashboard-panel-${panel.id}`, "data-narrow-tone": panel.narrow?.tone, className: cn("relative flex items-center gap-x-4 rounded-lg border border-border bg-card px-4 py-3 max-sm:items-baseline max-sm:gap-x-2 max-sm:overflow-hidden max-sm:py-2", panel.narrow?.tone !== undefined && PHONE_STRIP_TONE_CLASS[panel.narrow.tone]), children: [_jsx(PhoneStripIcon, { panel: panel, screenId: props.screenId, screenParams: props.screenParams }), _jsxs("div", { className: "flex min-w-0 shrink-0 flex-col max-sm:flex-row max-sm:items-baseline", children: [_jsx("h2", { className: "text-sm font-semibold max-sm:after:ml-2 max-sm:after:font-normal max-sm:after:text-muted-foreground max-sm:after:content-['\u00B7']", children: label }), panel.subtitle !== undefined && (_jsx("p", { className: "text-xs text-muted-foreground max-sm:hidden", children: translate(panel.subtitle) }))] }), _jsx("div", { className: "flex min-w-0 items-stretch gap-3 max-sm:block max-sm:grow max-sm:truncate max-sm:text-sm", children: panel.stats.map((stat) => (_jsx("div", { className: `flex min-w-0 max-sm:inline max-sm:[&_a]:inline max-sm:[&:not(:last-child)]:after:mx-1.5 max-sm:[&:not(:last-child)]:after:text-muted-foreground max-sm:[&:not(:last-child)]:after:content-['·'] [&>*]:min-w-0${stat.navigate !== undefined ? " max-sm:relative max-sm:z-10" : ""}`, children: _jsx(StatPanelBody, { panel: stat, label: translate(stat.label), screenId: props.screenId, screenParams: props.screenParams, translate: translate, variant: "strip-compact" }) }, stat.id))) }), panel.link !== undefined && (_jsx(StatGroupLink, { link: panel.link, translate: translate, stretchOnNarrow: true }))] }));
|
|
54
|
+
}
|
|
55
|
+
export function StatGroupPanelBody(props) {
|
|
56
|
+
const { panel, label, translate } = props;
|
|
57
|
+
const layout = panel.layout ?? (label === undefined ? "strip" : "cards");
|
|
58
|
+
if (layout === "strip") {
|
|
59
|
+
return label === undefined ? (_jsx(FlatStatStrip, { ...props })) : (_jsx(TitledStatStrip, { ...props, label: label }));
|
|
60
|
+
}
|
|
61
|
+
const cells = (_jsx("section", { className: panel.columns === undefined
|
|
62
|
+
? STAT_CARD_GRID_CLASSES
|
|
63
|
+
: STAT_CARD_COLUMN_CLASSES[panel.columns], children: _jsx(StatCells, { ...props, variant: "card" }) }));
|
|
64
|
+
return (_jsx(PanelShell, { testId: `dashboard-panel-${panel.id}`, ...(label !== undefined && { title: label }), ...(panel.subtitle !== undefined && { subtitle: translate(panel.subtitle) }), ...(panel.link !== undefined && {
|
|
65
|
+
action: _jsx(StatGroupLink, { link: panel.link, translate: translate, stretchOnNarrow: false }),
|
|
66
|
+
}), children: cells }));
|
|
67
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { DashboardTextPanel } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import type { ReactNode } from "react";
|
|
3
|
+
import type { Translate } from "../../headless/index.ts";
|
|
4
|
+
import { type ScreenParams } from "./dashboard-shared.tsx";
|
|
5
|
+
type TextPanelBodyProps = {
|
|
6
|
+
readonly panel: DashboardTextPanel;
|
|
7
|
+
readonly label: string | undefined;
|
|
8
|
+
readonly screenParams: ScreenParams;
|
|
9
|
+
readonly translate: Translate;
|
|
10
|
+
};
|
|
11
|
+
export declare function TextPanelBody(props: TextPanelBodyProps): ReactNode;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { navigateTargetAllows } from "../../app/screen-access.js";
|
|
3
|
+
import { lastSegment, useAppFeatures, useNav, usePrimitives, useUserRoles } from "../../index.js";
|
|
4
|
+
import { useIsBelowSmViewport } from "../primitives/use-narrow-viewport.js";
|
|
5
|
+
import { PanelError, PanelShell, PanelSkeleton, panelPayload, useDashboardFormats, useDashboardQuery, useReportPanelLoaded, } from "./dashboard-shared.js";
|
|
6
|
+
import { isDashboardI18nText, isRecord, resolveDashboardText } from "./dashboard-text.js";
|
|
7
|
+
function isDashboardText(value) {
|
|
8
|
+
return typeof value === "string" || isDashboardI18nText(value);
|
|
9
|
+
}
|
|
10
|
+
function isRoleList(value) {
|
|
11
|
+
return Array.isArray(value) && value.every((role) => typeof role === "string");
|
|
12
|
+
}
|
|
13
|
+
function readParagraphBlock(raw) {
|
|
14
|
+
const { text, emphasis } = raw;
|
|
15
|
+
if (!isDashboardText(text))
|
|
16
|
+
return undefined;
|
|
17
|
+
return {
|
|
18
|
+
kind: "paragraph",
|
|
19
|
+
text,
|
|
20
|
+
...((emphasis === "muted" || emphasis === "strong" || emphasis === "lead") && { emphasis }),
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
function readLinkBlock(raw) {
|
|
24
|
+
const { text, screen, roles } = raw;
|
|
25
|
+
if (!isDashboardText(text) || typeof screen !== "string" || screen === "")
|
|
26
|
+
return undefined;
|
|
27
|
+
return { kind: "link", text, screen, ...(isRoleList(roles) && { roles }) };
|
|
28
|
+
}
|
|
29
|
+
// A query answers untyped JSON: one guard per block kind, so a malformed block is dropped
|
|
30
|
+
// instead of crashing the panel.
|
|
31
|
+
const QUERY_BLOCK_READERS = {
|
|
32
|
+
heading: ({ text }) => (isDashboardText(text) ? { kind: "heading", text } : undefined),
|
|
33
|
+
hint: ({ text }) => (isDashboardText(text) ? { kind: "hint", text } : undefined),
|
|
34
|
+
paragraph: readParagraphBlock,
|
|
35
|
+
list: ({ items }) => Array.isArray(items) && items.every(isDashboardText) ? { kind: "list", items } : undefined,
|
|
36
|
+
code: ({ code }) => (typeof code === "string" ? { kind: "code", code } : undefined),
|
|
37
|
+
link: readLinkBlock,
|
|
38
|
+
};
|
|
39
|
+
function isBlockKind(value) {
|
|
40
|
+
return typeof value === "string" && Object.hasOwn(QUERY_BLOCK_READERS, value);
|
|
41
|
+
}
|
|
42
|
+
function readQueryBlock(raw) {
|
|
43
|
+
if (!isRecord(raw) || !isBlockKind(raw["kind"]))
|
|
44
|
+
return undefined;
|
|
45
|
+
return QUERY_BLOCK_READERS[raw["kind"]](raw);
|
|
46
|
+
}
|
|
47
|
+
function readQueryBlocks(data, key) {
|
|
48
|
+
const blocks = isRecord(data) ? data[key] : undefined;
|
|
49
|
+
if (!Array.isArray(blocks))
|
|
50
|
+
return [];
|
|
51
|
+
return blocks.flatMap((raw) => {
|
|
52
|
+
const block = readQueryBlock(raw);
|
|
53
|
+
return block === undefined ? [] : [block];
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
function resolveBlockText(text, translate, formats) {
|
|
57
|
+
return typeof text === "string"
|
|
58
|
+
? translate(text)
|
|
59
|
+
: (resolveDashboardText(text, translate, formats) ?? "");
|
|
60
|
+
}
|
|
61
|
+
const PARAGRAPH_CLASS_NAMES = {
|
|
62
|
+
muted: "text-sm text-muted-foreground",
|
|
63
|
+
strong: "text-sm font-medium text-foreground",
|
|
64
|
+
lead: "font-heading text-[15.5px] leading-[1.5] sm:text-[17px] sm:leading-relaxed text-foreground",
|
|
65
|
+
};
|
|
66
|
+
function TextBlockView({ block, translate, }) {
|
|
67
|
+
const formats = useDashboardFormats();
|
|
68
|
+
const resolve = (text) => resolveBlockText(text, translate, formats);
|
|
69
|
+
switch (block.kind) {
|
|
70
|
+
case "heading":
|
|
71
|
+
return (_jsx("h3", { "data-block": "heading", className: "text-sm font-semibold text-foreground", children: resolve(block.text) }));
|
|
72
|
+
case "paragraph":
|
|
73
|
+
return (_jsx("p", { "data-block": "paragraph", className: PARAGRAPH_CLASS_NAMES[block.emphasis ?? "muted"], children: resolve(block.text) }));
|
|
74
|
+
case "list":
|
|
75
|
+
return (_jsx("ul", { "data-block": "list", className: "list-disc space-y-1 pl-5 text-sm text-muted-foreground", children: withOccurrenceKeys(block.items, textKey).map(({ entry, key }) => (_jsx("li", { children: resolve(entry) }, key))) }));
|
|
76
|
+
case "code":
|
|
77
|
+
return (_jsx("pre", { "data-block": "code", className: "overflow-x-auto rounded-md bg-muted p-3 text-xs", children: _jsx("code", { children: block.code }) }));
|
|
78
|
+
case "hint":
|
|
79
|
+
return (_jsx("p", { "data-block": "hint", className: "text-xs text-muted-foreground", children: resolve(block.text) }));
|
|
80
|
+
case "link":
|
|
81
|
+
return _jsx(TextBlockLink, { block: block, resolve: resolve });
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
function TextBlockLink({ block, resolve, }) {
|
|
85
|
+
const { Link } = usePrimitives();
|
|
86
|
+
const nav = useNav();
|
|
87
|
+
const userRoles = useUserRoles();
|
|
88
|
+
const appFeatures = useAppFeatures();
|
|
89
|
+
if (block.roles !== undefined && !block.roles.some((role) => userRoles?.includes(role))) {
|
|
90
|
+
return null;
|
|
91
|
+
}
|
|
92
|
+
const target = { screenId: lastSegment(block.screen) };
|
|
93
|
+
if (!navigateTargetAllows({ screen: target.screenId }, appFeatures, userRoles))
|
|
94
|
+
return null;
|
|
95
|
+
return (_jsx(Link, { href: nav.hrefFor(target), onPress: () => nav.navigate(target), testId: `dashboard-text-link-${target.screenId}`, children: resolve(block.text) }));
|
|
96
|
+
}
|
|
97
|
+
// Content-derived keys collide for identical entries; the occurrence count keeps them unique.
|
|
98
|
+
function withOccurrenceKeys(entries, contentKey) {
|
|
99
|
+
const seen = new Map();
|
|
100
|
+
return entries.map((entry) => {
|
|
101
|
+
const content = contentKey(entry);
|
|
102
|
+
const occurrence = seen.get(content) ?? 0;
|
|
103
|
+
seen.set(content, occurrence + 1);
|
|
104
|
+
return { entry, key: `${content}#${occurrence}` };
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
function textKey(text) {
|
|
108
|
+
return typeof text === "string" ? text : JSON.stringify(text);
|
|
109
|
+
}
|
|
110
|
+
function textBlockKey(block) {
|
|
111
|
+
switch (block.kind) {
|
|
112
|
+
case "list":
|
|
113
|
+
return `list:${block.items.map(textKey).join("|")}`;
|
|
114
|
+
case "code":
|
|
115
|
+
return `code:${block.code}`;
|
|
116
|
+
default:
|
|
117
|
+
return `${block.kind}:${textKey(block.text)}`;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
function TextPanelFrame({ panel, label, children, }) {
|
|
121
|
+
const testId = `dashboard-panel-${panel.id}`;
|
|
122
|
+
if (label !== undefined) {
|
|
123
|
+
return (_jsx(PanelShell, { testId: testId, title: label, children: children }));
|
|
124
|
+
}
|
|
125
|
+
return (_jsx("section", { "data-testid": testId, className: "h-full rounded-lg border border-border bg-card p-4 text-card-foreground", children: children }));
|
|
126
|
+
}
|
|
127
|
+
function TextBlockList({ blocks, translate, }) {
|
|
128
|
+
return (_jsx("div", { className: "flex flex-col gap-3", children: withOccurrenceKeys(blocks, textBlockKey).map(({ entry, key }) => (_jsx(TextBlockView, { block: entry, translate: translate }, key))) }));
|
|
129
|
+
}
|
|
130
|
+
export function TextPanelBody(props) {
|
|
131
|
+
const { panel, label, translate } = props;
|
|
132
|
+
const narrow = useIsBelowSmViewport();
|
|
133
|
+
if (panel.query === undefined) {
|
|
134
|
+
return (_jsx(TextPanelFrame, { panel: panel, label: label, children: _jsx(TextBlockList, { blocks: (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [], translate: translate }) }));
|
|
135
|
+
}
|
|
136
|
+
return _jsx(QueryTextPanelBody, { ...props, query: panel.query });
|
|
137
|
+
}
|
|
138
|
+
// Not QueryPanel: that shell shows a skeleton/error/empty state instead of content, but the
|
|
139
|
+
// static blocks are the fallback here and must stay visible while the query loads, fails or is empty.
|
|
140
|
+
function QueryTextPanelBody({ panel, query, label, screenParams, translate, }) {
|
|
141
|
+
const { data, error, loading, refetch } = useDashboardQuery(query, panelPayload(panel, screenParams));
|
|
142
|
+
useReportPanelLoaded(data, loading);
|
|
143
|
+
const narrow = useIsBelowSmViewport();
|
|
144
|
+
const queriedNarrow = narrow ? readQueryBlocks(data, "narrowBlocks") : [];
|
|
145
|
+
const queriedWide = readQueryBlocks(data, "blocks");
|
|
146
|
+
const queried = queriedNarrow.length > 0 ? queriedNarrow : queriedWide;
|
|
147
|
+
const staticBlocks = (narrow ? panel.narrowBlocks : undefined) ?? panel.blocks ?? [];
|
|
148
|
+
const blocks = queried.length > 0 ? queried : staticBlocks;
|
|
149
|
+
let body;
|
|
150
|
+
if (blocks.length > 0) {
|
|
151
|
+
body = _jsx(TextBlockList, { blocks: blocks, translate: translate });
|
|
152
|
+
}
|
|
153
|
+
else if (error !== null) {
|
|
154
|
+
body = _jsx(PanelError, { label: label ?? "", error: error, onRetry: () => void refetch() });
|
|
155
|
+
}
|
|
156
|
+
else if (loading && data === null) {
|
|
157
|
+
body = _jsx(PanelSkeleton, { shape: "rows" });
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
body = null;
|
|
161
|
+
}
|
|
162
|
+
return (_jsx(TextPanelFrame, { panel: panel, label: label, children: body }));
|
|
163
|
+
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
+
import type { DashboardI18nText } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
1
2
|
import type { Translate } from "../../headless/index.ts";
|
|
2
3
|
import type { DashboardFormats } from "./dashboard-shared.tsx";
|
|
3
4
|
export declare function isRecord(value: unknown): value is Readonly<Record<string, unknown>>;
|
|
5
|
+
export declare function isDashboardI18nText(value: unknown): value is DashboardI18nText;
|
|
4
6
|
/** Plain strings pass through; DashboardI18nText is translated (nested params first).
|
|
5
7
|
* Anything else yields undefined so callers fall back to their own placeholder. */
|
|
6
8
|
export declare function resolveDashboardText(value: unknown, translate: Translate, formats: DashboardFormats): string | undefined;
|
|
@@ -2,7 +2,7 @@ const MAX_TEXT_PARAM_DEPTH = 4;
|
|
|
2
2
|
export function isRecord(value) {
|
|
3
3
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
4
4
|
}
|
|
5
|
-
function isDashboardI18nText(value) {
|
|
5
|
+
export function isDashboardI18nText(value) {
|
|
6
6
|
return isRecord(value) && typeof value["i18nKey"] === "string";
|
|
7
7
|
}
|
|
8
8
|
function isMoneyParam(value) {
|
|
@@ -15,7 +15,7 @@ function panelVisibilityGate(panel, screenParams) {
|
|
|
15
15
|
return undefined;
|
|
16
16
|
if (panel.kind === "screen")
|
|
17
17
|
return visibilityGate(panel.visibleWhen.query, NO_GATE_PAYLOAD);
|
|
18
|
-
const dropsFilter = panel.kind !== "stat-group" && panel.
|
|
18
|
+
const dropsFilter = panel.kind !== "stat-group" && panel.ignoreScreenFilter === true;
|
|
19
19
|
return visibilityGate(panel.visibleWhen.query, {
|
|
20
20
|
...(dropsFilter ? {} : screenParams.filterParams),
|
|
21
21
|
...screenParams.rangeParams,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
import { serverNowMs } from "../../server-clock.js";
|
|
2
3
|
import { resolveSafeLocale } from "../primitives/locale-number.js";
|
|
3
4
|
const SECONDS_PER_MINUTE = 60;
|
|
4
5
|
const MINUTES_PER_HOUR = 60;
|
|
@@ -49,7 +50,7 @@ export function useRelativeTimeFormatter(locale) {
|
|
|
49
50
|
return () => clearInterval(timer);
|
|
50
51
|
}, [intervalMs]);
|
|
51
52
|
return (atMs) => {
|
|
52
|
-
const nowMs =
|
|
53
|
+
const nowMs = serverNowMs();
|
|
53
54
|
nearestDistanceMs.current = Math.min(nearestDistanceMs.current, Math.abs(atMs - nowMs));
|
|
54
55
|
return formatRelativeTime(atMs, nowMs, locale);
|
|
55
56
|
};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type FooterTone = "bad" | "warn" | "ok";
|
|
3
|
+
export type EditorActionTestIds = {
|
|
4
|
+
readonly discard: string;
|
|
5
|
+
readonly save: string;
|
|
6
|
+
readonly publish: string;
|
|
7
|
+
};
|
|
8
|
+
export declare function EditorFooter({ testIdPrefix, actionTestIds, message, pendingMessage, saveError, modifiedAt, dirty, busy, canSave, canPublish, onDiscard, onSave, saveLabel, onPublish, }: {
|
|
9
|
+
readonly testIdPrefix: string;
|
|
10
|
+
readonly actionTestIds?: EditorActionTestIds;
|
|
11
|
+
readonly message: {
|
|
12
|
+
readonly tone: FooterTone;
|
|
13
|
+
readonly text: string;
|
|
14
|
+
} | null;
|
|
15
|
+
/** Shown while `message` is null (a check still running, or nothing to report). */
|
|
16
|
+
readonly pendingMessage?: string;
|
|
17
|
+
readonly saveError: string | null;
|
|
18
|
+
readonly modifiedAt: string | null;
|
|
19
|
+
readonly dirty: boolean;
|
|
20
|
+
readonly busy: boolean;
|
|
21
|
+
readonly canSave: boolean;
|
|
22
|
+
readonly canPublish?: boolean;
|
|
23
|
+
readonly onDiscard: () => void;
|
|
24
|
+
readonly onSave: () => void;
|
|
25
|
+
readonly saveLabel?: string;
|
|
26
|
+
/** Without it the footer has no publish button (content that is live as soon as it is saved). */
|
|
27
|
+
readonly onPublish?: () => void;
|
|
28
|
+
}): ReactNode;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useTranslation } from "../../i18n.js";
|
|
3
|
+
import { usePrimitives } from "../../primitives.js";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { formatRelativeWhen } from "./relative-when.js";
|
|
6
|
+
const FOOTER_TONE = {
|
|
7
|
+
ok: { text: "text-status-ok", glyph: "✓" },
|
|
8
|
+
warn: { text: "text-status-warn", glyph: "!" },
|
|
9
|
+
bad: { text: "text-status-bad", glyph: "!" },
|
|
10
|
+
};
|
|
11
|
+
const DEFAULT_ACTION_TEST_IDS = {
|
|
12
|
+
discard: "editor-discard",
|
|
13
|
+
save: "editor-save",
|
|
14
|
+
publish: "editor-publish",
|
|
15
|
+
};
|
|
16
|
+
export function EditorFooter({ testIdPrefix, actionTestIds = DEFAULT_ACTION_TEST_IDS, message, pendingMessage, saveError, modifiedAt, dirty, busy, canSave, canPublish, onDiscard, onSave, saveLabel, onPublish, }) {
|
|
17
|
+
const t = useTranslation();
|
|
18
|
+
const { Banner, Button, Text } = usePrimitives();
|
|
19
|
+
const tone = message === null ? null : FOOTER_TONE[message.tone];
|
|
20
|
+
return (_jsxs("div", { className: "flex items-center gap-4 border-t bg-background px-6 py-3", "data-testid": `${testIdPrefix}-footer`, children: [_jsxs("div", { className: "min-w-0 flex-1 text-sm", children: [saveError !== null ? (_jsx(Banner, { variant: "error", testId: `${testIdPrefix}-save-error`, children: saveError })) : (_jsx("span", { className: cn(tone === null ? "text-muted-foreground" : tone.text), "data-testid": `${testIdPrefix}-footer-message`, "data-tone": message?.tone, children: message === null
|
|
21
|
+
? (pendingMessage ?? t("kumiko.editor.noChanges"))
|
|
22
|
+
: `${tone?.glyph ?? ""} ${message.text}` })), modifiedAt !== null && (_jsxs(_Fragment, { children: [" ", _jsx(Text, { variant: "muted", testId: `${testIdPrefix}-saved-at`, children: t("kumiko.editor.savedAt", { when: formatRelativeWhen(modifiedAt) }) })] }))] }), _jsxs("div", { className: "flex shrink-0 items-center gap-3", children: [_jsx(Button, { variant: "ghost", disabled: !dirty, onClick: onDiscard, testId: actionTestIds.discard, children: t("kumiko.editor.discard") }), _jsx(Button, { variant: onPublish === undefined ? "primary" : "secondary", disabled: !canSave, loading: busy, onClick: onSave, testId: actionTestIds.save, children: saveLabel ?? t("kumiko.actions.save") }), onPublish !== undefined && (_jsx(Button, { disabled: canPublish !== true, onClick: onPublish, testId: actionTestIds.publish, children: t("kumiko.editor.publish") }))] })] }));
|
|
23
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type InfoBarTone = "active" | "muted" | "warn";
|
|
3
|
+
export declare function EditorFrame({ testId, children, }: {
|
|
4
|
+
readonly testId: string;
|
|
5
|
+
readonly children: ReactNode;
|
|
6
|
+
}): ReactNode;
|
|
7
|
+
export declare function EditorInfoBar({ tone, testId, origin, controls, links, overlays, children, }: {
|
|
8
|
+
readonly tone: InfoBarTone;
|
|
9
|
+
readonly testId: string;
|
|
10
|
+
/** Badge in front of the text: where the content comes from. */
|
|
11
|
+
readonly origin?: ReactNode;
|
|
12
|
+
/** Right side, before the links: locale switch and the editor's secondary action. */
|
|
13
|
+
readonly controls?: ReactNode;
|
|
14
|
+
readonly links?: ReactNode;
|
|
15
|
+
readonly overlays?: ReactNode;
|
|
16
|
+
readonly children: ReactNode;
|
|
17
|
+
}): ReactNode;
|
|
18
|
+
export declare function EditorBody({ left, center, right, testId, }: {
|
|
19
|
+
readonly left?: ReactNode;
|
|
20
|
+
readonly center: ReactNode;
|
|
21
|
+
readonly right: ReactNode;
|
|
22
|
+
readonly testId?: string;
|
|
23
|
+
}): ReactNode;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cn } from "../lib/cn.js";
|
|
3
|
+
const INFO_BAR_TONE = {
|
|
4
|
+
active: "bg-primary/10",
|
|
5
|
+
muted: "bg-muted",
|
|
6
|
+
warn: "bg-status-warn-surface",
|
|
7
|
+
};
|
|
8
|
+
// Height below the shell header: the rails and the center scroll on their own.
|
|
9
|
+
export function EditorFrame({ testId, children, }) {
|
|
10
|
+
return (_jsx("div", { className: "flex h-[calc(100svh-var(--shell-header-height))] min-h-[600px] flex-col", "data-testid": testId, children: children }));
|
|
11
|
+
}
|
|
12
|
+
export function EditorInfoBar({ tone, testId, origin, controls, links, overlays, children, }) {
|
|
13
|
+
return (_jsxs(_Fragment, { children: [_jsxs("div", { className: cn("flex items-start gap-4 border-b px-6 py-2 text-sm", INFO_BAR_TONE[tone]), "data-testid": testId, "data-variant": tone === "warn" ? "warn" : undefined, children: [_jsxs("span", { className: "min-w-0 flex-1", children: [origin, " ", children] }), controls !== undefined && (_jsx("div", { className: "flex shrink-0 items-center gap-2", children: controls })), links !== undefined && _jsx("div", { className: "flex shrink-0 items-center gap-4", children: links })] }), overlays] }));
|
|
14
|
+
}
|
|
15
|
+
export function EditorBody({ left, center, right, testId, }) {
|
|
16
|
+
const centerColumn = (_jsx("div", { className: "flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted", children: center }));
|
|
17
|
+
if (left === undefined) {
|
|
18
|
+
return (_jsxs("div", { className: "grid min-h-0 flex-1 grid-cols-[minmax(0,1fr)_280px]", "data-testid": testId, children: [centerColumn, _jsx("aside", { className: "min-h-0 overflow-y-auto border-l bg-background", children: right })] }));
|
|
19
|
+
}
|
|
20
|
+
// Three columns leave a narrow window (1024px beside the app sidebar) too little room for the
|
|
21
|
+
// page: there both rails share the left column, one below the other, and the center keeps its width.
|
|
22
|
+
// DOM order stays left, center, right (focus order); only grid placement moves the rails.
|
|
23
|
+
return (_jsx("div", { className: "@container flex min-h-0 min-w-0 flex-1", "data-testid": testId, children: _jsxs("div", { className: "grid min-h-0 min-w-0 flex-1 grid-cols-[240px_minmax(0,1fr)_280px] @max-4xl:grid-cols-[240px_minmax(0,1fr)] @max-4xl:grid-rows-[minmax(0,1fr)_minmax(0,1fr)]", children: [_jsx("aside", { className: "min-h-0 overflow-y-auto border-r bg-background @max-4xl:col-start-1 @max-4xl:row-start-1 @max-4xl:border-b", children: left }), _jsx("div", { className: "flex min-h-0 min-w-0 flex-col overflow-hidden bg-muted @max-4xl:col-start-2 @max-4xl:row-span-2 @max-4xl:row-start-1", children: center }), _jsx("aside", { className: "min-h-0 overflow-y-auto border-l bg-background @max-4xl:col-start-1 @max-4xl:row-start-2 @max-4xl:border-l-0 @max-4xl:border-r", children: right })] }) }));
|
|
24
|
+
}
|