@cosmicdrift/kumiko-renderer 0.413.0 → 0.414.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/action-form-support.js +4 -0
- package/dist/app/content-previews.d.ts +39 -0
- package/dist/app/content-previews.js +28 -0
- package/dist/app/entity-edit-screen.js +2 -5
- package/dist/app/entity-list-screen.js +30 -50
- package/dist/app/form-schema.d.ts +1 -0
- package/dist/app/form-schema.js +24 -0
- package/dist/app/list-sort-options.d.ts +4 -0
- package/dist/app/list-sort-options.js +11 -0
- package/dist/app/named-filter-facet.d.ts +17 -3
- package/dist/app/named-filter-facet.js +88 -5
- package/dist/app/projection-detail-body.d.ts +2 -4
- package/dist/app/projection-detail-body.js +7 -1
- package/dist/app/projection-detail-guidance-data.d.ts +7 -0
- package/dist/app/projection-detail-guidance-data.js +101 -0
- package/dist/app/projection-detail-guidance.d.ts +13 -0
- package/dist/app/projection-detail-guidance.js +197 -0
- package/dist/app/projection-detail-header-model.d.ts +1 -3
- package/dist/app/projection-detail-header-model.js +4 -8
- package/dist/app/projection-detail-header-region.d.ts +2 -1
- package/dist/app/projection-detail-header-region.js +63 -23
- package/dist/app/projection-detail-header.d.ts +6 -1
- package/dist/app/projection-detail-header.js +75 -18
- package/dist/app/projection-detail-states.d.ts +3 -3
- package/dist/app/projection-list-body.js +4 -2
- package/dist/app/projection-list-render.js +3 -1
- package/dist/app/projection-list-shim.d.ts +4 -1
- package/dist/app/projection-list-shim.js +35 -8
- package/dist/app/reference-link.d.ts +3 -2
- package/dist/app/reference-link.js +19 -4
- package/dist/app/row-actions.js +3 -3
- package/dist/app/screen-access.d.ts +4 -0
- package/dist/app/screen-access.js +19 -0
- package/dist/app/screen-shared.js +3 -1
- package/dist/app/unique-label-keys.d.ts +1 -0
- package/dist/app/unique-label-keys.js +9 -0
- package/dist/app/use-entity-list-payload.d.ts +25 -0
- package/dist/app/use-entity-list-payload.js +57 -0
- package/dist/app/use-entity-range-facets.js +2 -3
- package/dist/app/use-facet-counts.d.ts +5 -0
- package/dist/app/use-facet-counts.js +7 -0
- package/dist/app/use-list-summary-row.d.ts +10 -0
- package/dist/app/use-list-summary-row.js +33 -0
- package/dist/app/use-named-filter-queue.d.ts +20 -0
- package/dist/app/use-named-filter-queue.js +9 -0
- package/dist/app/use-projection-detail-actions.d.ts +4 -4
- package/dist/app/use-projection-detail-actions.js +30 -1
- package/dist/app/use-projection-list-data.d.ts +5 -0
- package/dist/app/use-projection-list-data.js +35 -6
- package/dist/app/use-projection-list-query.d.ts +2 -0
- package/dist/app/use-projection-list-query.js +29 -16
- package/dist/app/use-related-list-tab-counts.js +5 -1
- package/dist/app/use-row-decoration.d.ts +11 -0
- package/dist/app/use-row-decoration.js +55 -0
- package/dist/app/use-screen-list-rows.d.ts +4 -1
- package/dist/app/use-screen-list-rows.js +14 -5
- package/dist/app/use-screen-list-table.d.ts +3 -1
- package/dist/app/use-screen-list-table.js +10 -1
- package/dist/app/write-failed-error.d.ts +1 -0
- package/dist/app/write-failed-error.js +10 -0
- package/dist/compact-tap-classes.d.ts +1 -0
- package/dist/compact-tap-classes.js +3 -0
- package/dist/components/embedded-list-field.js +13 -12
- package/dist/components/form-pending-uploads.d.ts +8 -0
- package/dist/components/form-pending-uploads.js +27 -0
- package/dist/components/list-empty-state.d.ts +8 -1
- package/dist/components/list-empty-state.js +4 -1
- package/dist/components/list-group-page-bridges.d.ts +1 -1
- package/dist/components/list-group-page-bridges.js +2 -2
- package/dist/components/related-list-section.js +4 -22
- package/dist/components/render-edit-action-button.d.ts +3 -1
- package/dist/components/render-edit-action-button.js +5 -3
- package/dist/components/render-edit-form-actions.js +6 -3
- package/dist/components/render-edit-layout.js +2 -1
- package/dist/components/render-edit-render-model.d.ts +2 -2
- package/dist/components/render-edit-submit.js +2 -1
- package/dist/components/render-edit-types.d.ts +4 -2
- package/dist/components/render-edit.js +3 -1
- package/dist/components/render-list-hint-columns.d.ts +8 -0
- package/dist/components/render-list-hint-columns.js +77 -0
- package/dist/components/render-list-reference-columns.js +4 -2
- package/dist/components/render-list-row-tone.d.ts +3 -0
- package/dist/components/render-list-row-tone.js +10 -0
- package/dist/components/render-list-table-props.d.ts +9 -1
- package/dist/components/render-list-table-props.js +4 -1
- package/dist/components/render-list-toolbar-action.d.ts +1 -2
- package/dist/components/render-list-toolbar-model.d.ts +3 -0
- package/dist/components/render-list-toolbar-model.js +21 -6
- package/dist/components/render-list-toolbar.d.ts +3 -2
- package/dist/components/render-list-toolbar.js +8 -6
- package/dist/components/render-list-types.d.ts +6 -1
- package/dist/components/render-list.js +26 -7
- package/dist/components/use-render-edit-controlled-sync.js +5 -4
- package/dist/components/use-render-edit-draft-save.js +7 -9
- package/dist/components/use-render-edit-schema.d.ts +3 -0
- package/dist/components/use-render-edit-schema.js +15 -0
- package/dist/components/use-render-edit-state.d.ts +4 -0
- package/dist/components/use-render-edit-state.js +9 -1
- package/dist/components/use-render-edit-steps.js +2 -3
- package/dist/components/use-render-list-columns.d.ts +3 -1
- package/dist/components/use-render-list-columns.js +22 -10
- package/dist/context/screen-focus-context.d.ts +14 -0
- package/dist/context/screen-focus-context.js +28 -0
- package/dist/data-table-facet-types.d.ts +2 -0
- package/dist/data-table-view-types.d.ts +20 -1
- package/dist/headless/form/form-controller.js +3 -1
- package/dist/headless/form/zod-bridge.d.ts +7 -1
- package/dist/headless/form/zod-bridge.js +10 -0
- package/dist/headless/index.d.ts +2 -1
- package/dist/headless/index.js +1 -0
- package/dist/headless/pwa-service-worker-meta.d.ts +1 -0
- package/dist/headless/pwa-service-worker-meta.js +3 -0
- package/dist/headless/view-model/index.d.ts +1 -1
- package/dist/headless/view-model/list-file-display.js +3 -2
- package/dist/headless/view-model/list.js +16 -0
- package/dist/headless/view-model/types.d.ts +33 -0
- package/dist/hooks/list-column-layout.js +2 -1
- package/dist/hooks/list-server-groups.js +14 -1
- package/dist/hooks/list-state-schema.d.ts +1 -0
- package/dist/hooks/list-state-schema.js +9 -1
- package/dist/hooks/use-debounced-value.d.ts +1 -0
- package/dist/hooks/use-debounced-value.js +11 -0
- package/dist/hooks/use-list-aggregates.d.ts +5 -1
- package/dist/hooks/use-list-aggregates.js +9 -5
- package/dist/hooks/use-list-table.d.ts +2 -1
- package/dist/hooks/use-list-table.js +3 -9
- package/dist/hooks/use-list-url-state.d.ts +2 -0
- package/dist/hooks/use-list-url-state.js +12 -4
- package/dist/hooks/use-list-view-state.js +23 -3
- package/dist/hooks/use-reference-lookup.js +7 -2
- package/dist/hooks/use-remembered-list-params.d.ts +6 -2
- package/dist/hooks/use-remembered-list-params.js +18 -3
- package/dist/hooks/use-store.js +0 -1
- package/dist/i18n-defaults.js +37 -2
- package/dist/index.d.ts +8 -2
- package/dist/index.js +5 -1
- package/dist/live/dispatcher-live.js +2 -0
- package/dist/metric-types.d.ts +2 -0
- package/dist/primitives-record-guidance.d.ts +53 -0
- package/dist/primitives-record-guidance.js +1 -0
- package/dist/primitives.d.ts +41 -31
- package/dist/server-clock.d.ts +6 -0
- package/dist/server-clock.js +20 -0
- package/dist/session/session-ended.d.ts +1 -0
- package/dist/session/session-ended.js +2 -2
- package/dist/status-tone.d.ts +1 -0
- package/dist/status-tone.js +5 -0
- package/dist/web/app/browser-locale.js +1 -1
- package/dist/web/app/client-plugin.d.ts +6 -1
- package/dist/web/app/create-app.d.ts +2 -1
- package/dist/web/app/create-app.js +15 -5
- package/dist/web/app/dashboard-body.js +25 -11
- package/dist/web/app/dashboard-header.d.ts +2 -1
- package/dist/web/app/dashboard-header.js +19 -7
- package/dist/web/app/dashboard-list-panel.d.ts +12 -0
- package/dist/web/app/dashboard-list-panel.js +149 -0
- package/dist/web/app/dashboard-narrow-gate.d.ts +6 -0
- package/dist/web/app/dashboard-narrow-gate.js +6 -0
- package/dist/web/app/dashboard-narrow-order.d.ts +3 -0
- package/dist/web/app/dashboard-narrow-order.js +6 -0
- package/dist/web/app/dashboard-navigation-link.d.ts +12 -0
- package/dist/web/app/dashboard-navigation-link.js +21 -0
- package/dist/web/app/dashboard-panels.d.ts +6 -23
- package/dist/web/app/dashboard-panels.js +53 -123
- package/dist/web/app/dashboard-reference-list-table.d.ts +5 -1
- package/dist/web/app/dashboard-reference-list-table.js +12 -4
- package/dist/web/app/dashboard-shared.d.ts +23 -7
- package/dist/web/app/dashboard-shared.js +44 -17
- package/dist/web/app/dashboard-stat-group-panel.d.ts +13 -0
- package/dist/web/app/dashboard-stat-group-panel.js +67 -0
- package/dist/web/app/dashboard-text-panel.d.ts +12 -0
- package/dist/web/app/dashboard-text-panel.js +163 -0
- package/dist/web/app/dashboard-text.d.ts +2 -0
- package/dist/web/app/dashboard-text.js +1 -1
- package/dist/web/app/dashboard-visibility.js +1 -1
- package/dist/web/app/relative-time.js +2 -1
- package/dist/web/editor/editor-footer.d.ts +28 -0
- package/dist/web/editor/editor-footer.js +23 -0
- package/dist/web/editor/editor-frame.d.ts +23 -0
- package/dist/web/editor/editor-frame.js +24 -0
- package/dist/web/editor/editor-header.d.ts +36 -0
- package/dist/web/editor/editor-header.js +30 -0
- package/dist/web/editor/editor-rail.d.ts +32 -0
- package/dist/web/editor/editor-rail.js +37 -0
- package/dist/web/editor/editor-workbench.d.ts +34 -0
- package/dist/web/editor/editor-workbench.js +19 -0
- package/dist/web/editor/index.d.ts +6 -0
- package/dist/web/editor/index.js +6 -0
- package/dist/web/editor/relative-when.d.ts +1 -0
- package/dist/web/editor/relative-when.js +18 -0
- package/dist/web/index.d.ts +7 -1
- package/dist/web/index.js +5 -1
- package/dist/web/layout/default-app-shell.js +6 -4
- package/dist/web/layout/focus-aware-sidebar.d.ts +4 -7
- package/dist/web/layout/focus-aware-sidebar.js +5 -7
- package/dist/web/layout/header-action-pinned.d.ts +8 -0
- package/dist/web/layout/header-action-pinned.js +25 -0
- package/dist/web/layout/nav-collapse-state.d.ts +5 -0
- package/dist/web/layout/nav-collapse-state.js +66 -0
- package/dist/web/layout/nav-tree.js +25 -5
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.d.ts +8 -0
- package/dist/web/layout/screen-focus.js +42 -0
- package/dist/web/layout/shell-focus.d.ts +6 -5
- package/dist/web/layout/shell-focus.js +12 -9
- package/dist/web/layout/shell-header.js +38 -10
- package/dist/web/layout/sidebar-open-state.d.ts +6 -0
- package/dist/web/layout/sidebar-open-state.js +28 -0
- package/dist/web/layout/uniform-bar-controls.d.ts +2 -2
- package/dist/web/layout/uniform-bar-controls.js +4 -3
- package/dist/web/layout/use-in-app-inbox.js +8 -1
- package/dist/web/layout/workspace-shell.js +6 -4
- package/dist/web/lib/upload-file-ref.d.ts +2 -2
- package/dist/web/lib/upload-file-ref.js +4 -9
- package/dist/web/presence/use-presence.js +7 -2
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +14 -6
- package/dist/web/primitives/calendar-day-picker.js +24 -5
- package/dist/web/primitives/card.js +1 -1
- package/dist/web/primitives/code-input.js +6 -1
- package/dist/web/primitives/data-table/actions-column.d.ts +1 -0
- package/dist/web/primitives/data-table/actions-column.js +4 -2
- package/dist/web/primitives/data-table/card-body.d.ts +5 -0
- package/dist/web/primitives/data-table/card-body.js +47 -5
- package/dist/web/primitives/data-table/card-frame.d.ts +8 -0
- package/dist/web/primitives/data-table/card-frame.js +9 -0
- package/dist/web/primitives/data-table/card-row.js +40 -7
- package/dist/web/primitives/data-table/card-sort-select.d.ts +6 -2
- package/dist/web/primitives/data-table/card-sort-select.js +10 -7
- package/dist/web/primitives/data-table/card-view.js +12 -2
- package/dist/web/primitives/data-table/column-picker-section.js +9 -2
- package/dist/web/primitives/data-table/column-resize-handle.js +3 -4
- package/dist/web/primitives/data-table/column-role.d.ts +1 -0
- package/dist/web/primitives/data-table/column-role.js +1 -0
- package/dist/web/primitives/data-table/data-cell-props.d.ts +5 -0
- package/dist/web/primitives/data-table/data-cell-props.js +5 -0
- package/dist/web/primitives/data-table/density.js +1 -0
- package/dist/web/primitives/data-table/facet-cluster.d.ts +2 -1
- package/dist/web/primitives/data-table/facet-cluster.js +2 -2
- package/dist/web/primitives/data-table/group-band.js +4 -0
- package/dist/web/primitives/data-table/hint-cell.d.ts +16 -0
- package/dist/web/primitives/data-table/hint-cell.js +74 -0
- package/dist/web/primitives/data-table/hint-column-width.d.ts +3 -0
- package/dist/web/primitives/data-table/hint-column-width.js +11 -0
- package/dist/web/primitives/data-table/measure-value.js +2 -3
- package/dist/web/primitives/data-table/row-action-column.d.ts +3 -0
- package/dist/web/primitives/data-table/row-action-column.js +4 -0
- package/dist/web/primitives/data-table/sort-options-select.d.ts +22 -0
- package/dist/web/primitives/data-table/sort-options-select.js +46 -0
- package/dist/web/primitives/data-table/sortable-header.d.ts +3 -1
- package/dist/web/primitives/data-table/sortable-header.js +5 -3
- package/dist/web/primitives/data-table/table-body.d.ts +1 -1
- package/dist/web/primitives/data-table/table-body.js +5 -3
- package/dist/web/primitives/data-table/table-chrome.js +3 -1
- package/dist/web/primitives/data-table/table-content.js +10 -5
- package/dist/web/primitives/data-table/table-data-cell.js +9 -3
- package/dist/web/primitives/data-table/table-header-row.js +5 -2
- package/dist/web/primitives/data-table/table-view.js +17 -3
- package/dist/web/primitives/data-table/toolbar-end-cluster.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +31 -3
- package/dist/web/primitives/data-table/totals-footer.d.ts +20 -0
- package/dist/web/primitives/data-table/totals-footer.js +40 -9
- package/dist/web/primitives/data-table/use-bulk-selection.js +2 -1
- package/dist/web/primitives/data-table/use-column-pins.js +4 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +1 -0
- package/dist/web/primitives/data-table/use-data-table-state.js +9 -5
- package/dist/web/primitives/data-table/use-measured-column-widths.js +5 -4
- package/dist/web/primitives/data-table/use-row-selection.js +22 -11
- package/dist/web/primitives/data-table/view-menu.js +7 -1
- package/dist/web/primitives/data-table-cell.d.ts +21 -2
- package/dist/web/primitives/data-table-cell.js +96 -19
- package/dist/web/primitives/embedded-file-cell.js +10 -6
- package/dist/web/primitives/embedded-list-cards.js +3 -4
- package/dist/web/primitives/facet-filter.d.ts +4 -2
- package/dist/web/primitives/facet-filter.js +26 -3
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/file-thumbnail.d.ts +6 -2
- package/dist/web/primitives/file-thumbnail.js +13 -6
- package/dist/web/primitives/file-upload.js +15 -11
- package/dist/web/primitives/file-view-action.d.ts +6 -0
- package/dist/web/primitives/file-view-action.js +19 -0
- package/dist/web/primitives/files-dropzone.js +18 -4
- package/dist/web/primitives/form-footer-parts.d.ts +0 -1
- package/dist/web/primitives/form.js +0 -1
- package/dist/web/primitives/hint-reason-row.d.ts +32 -0
- package/dist/web/primitives/hint-reason-row.js +45 -0
- package/dist/web/primitives/index.js +6 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +2 -2
- package/dist/web/primitives/metric.js +8 -6
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +29 -18
- package/dist/web/primitives/reason-box.d.ts +20 -0
- package/dist/web/primitives/reason-box.js +13 -0
- package/dist/web/primitives/record-breadcrumb.d.ts +3 -0
- package/dist/web/primitives/record-breadcrumb.js +11 -0
- package/dist/web/primitives/record-steps.d.ts +3 -0
- package/dist/web/primitives/record-steps.js +45 -0
- package/dist/web/primitives/record-summary.d.ts +3 -0
- package/dist/web/primitives/record-summary.js +18 -0
- package/dist/web/primitives/row-actions.d.ts +3 -1
- package/dist/web/primitives/row-actions.js +14 -5
- package/dist/web/primitives/segmented-select.js +5 -7
- package/dist/web/pwa/pwa-support.d.ts +4 -0
- package/dist/web/pwa/pwa-support.js +113 -0
- package/dist/web/sse/live-events.js +2 -2
- package/dist/web/tokens.js +0 -3
- package/dist/web/widgets/chart-parts.d.ts +7 -1
- package/dist/web/widgets/chart-parts.js +10 -4
- package/dist/web/widgets/collapsible-section.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.d.ts +17 -0
- package/dist/web/widgets/dashboard-list-cards.js +54 -0
- package/dist/web/widgets/dashboard-list.d.ts +37 -5
- package/dist/web/widgets/dashboard-list.js +95 -20
- package/dist/web/widgets/drawer-sizing.js +1 -1
- package/dist/web/widgets/floating-panel.js +4 -2
- package/dist/web/widgets/index.d.ts +2 -0
- package/dist/web/widgets/index.js +2 -0
- package/dist/web/widgets/infinity-list.js +18 -11
- package/dist/web/widgets/preview-width-frame.d.ts +7 -0
- package/dist/web/widgets/preview-width-frame.js +10 -0
- package/dist/web/widgets/section-card.d.ts +1 -1
- package/dist/web/widgets/stacked-area-chrome.js +3 -3
- package/dist/web/widgets/stacked-area-tooltip.js +2 -10
- package/dist/web/widgets/stat-box-cell.d.ts +19 -0
- package/dist/web/widgets/stat-box-cell.js +10 -0
- package/dist/web/widgets/stat.d.ts +10 -1
- package/dist/web/widgets/stat.js +14 -5
- package/dist/web/widgets/status-badge.d.ts +7 -5
- package/dist/web/widgets/status-badge.js +2 -2
- package/dist/web/widgets/step-bar.d.ts +1 -1
- package/dist/web/widgets/step-bar.js +37 -7
- package/dist/web/widgets/upload-zone.d.ts +8 -1
- package/dist/web/widgets/upload-zone.js +13 -3
- package/package.json +5 -5
- package/src/changes.json +223 -0
- package/src/web/styles.css +9 -0
|
@@ -52,8 +52,8 @@ export function InfiniteSentinel({ onReachEnd, loadingMore, hasMore, rowsCount,
|
|
|
52
52
|
const showEndLabel = !hasMore && rowsCount >= END_LABEL_MIN_ROWS;
|
|
53
53
|
return (_jsx("div", { ref: ref, "data-testid": testId, className: cn("flex items-center justify-center text-sm text-muted-foreground", showEndLabel || loadingMore ? "py-4" : ""), children: showEndLabel ? (_jsx("span", { "data-testid": testId !== undefined ? `${testId}-end` : undefined, children: t("kumiko.list.end-of-list") })) : loadingMore ? (_jsx(Loader2, { className: "size-4 animate-spin", "aria-hidden": "true" })) : hasMore ? (_jsx("span", { "aria-hidden": "true", children: "\u00A0" })) : null }));
|
|
54
54
|
}
|
|
55
|
-
// Pager —
|
|
56
|
-
//
|
|
55
|
+
// Pager — left "X – Y of Z · N per page" (the page size is a select in text
|
|
56
|
+
// style), right "‹ 1 2 3 ›" from sm; below sm only the arrows.
|
|
57
57
|
// `pinned` renders the footer bar of a scrollBody table (fixed height, top
|
|
58
58
|
// border); unpinned it sits as a plain row below the table.
|
|
59
59
|
//
|
|
@@ -68,22 +68,33 @@ export function Pager({ page, limit, total, onPageChange, pageSizeOptions, onPag
|
|
|
68
68
|
const to = Math.min(safePage * limit, total);
|
|
69
69
|
return (_jsxs("div", { "data-testid": testId, className: pinned === true
|
|
70
70
|
? TABLE_FOOTER_BAR_CLASS
|
|
71
|
-
: "mt-3 flex items-center gap-4 text-[13px] tabular-nums text-foreground-secondary", children: [_jsx("div", { "data-testid": testId !== undefined ? `${testId}-status` : undefined,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
71
|
+
: "mt-3 flex items-center gap-4 text-[13px] tabular-nums text-foreground-secondary", children: [_jsxs("div", { className: "flex min-w-0 flex-1 items-center gap-1", children: [_jsx("div", { "data-testid": testId !== undefined ? `${testId}-status` : undefined, children: itemNoun !== undefined
|
|
72
|
+
? t("kumiko.pager.status.noun", {
|
|
73
|
+
from: from.toLocaleString(),
|
|
74
|
+
to: to.toLocaleString(),
|
|
75
|
+
total: total.toLocaleString(),
|
|
76
|
+
noun: itemNoun(total),
|
|
77
|
+
})
|
|
78
|
+
: t("kumiko.pager.status", {
|
|
79
|
+
from: from.toLocaleString(),
|
|
80
|
+
to: to.toLocaleString(),
|
|
81
|
+
total: total.toLocaleString(),
|
|
82
|
+
}) }), pageSizeOptions !== undefined && onPageSizeChange !== undefined && (_jsxs("div", { className: "relative hidden items-center sm:flex", children: [_jsx("span", { "aria-hidden": "true", children: "\u00B7" }), _jsx("select", { "aria-label": t("kumiko.pager.pageSizeLabel"), "data-testid": testId !== undefined ? `${testId}-page-size` : undefined, value: limit, onChange: (e) => onPageSizeChange(Number(e.target.value)), className: "h-7 cursor-pointer appearance-none rounded-md border-0 bg-transparent pl-1.5 pr-5 text-[13px] text-foreground-secondary hover:text-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", children: pageSizeOptions.map((size) => (_jsx("option", { value: size, children: t("kumiko.pager.pageSize", { size: size.toLocaleString() }) }, size))) }), _jsx(ChevronDown, { className: "pointer-events-none absolute right-0.5 top-1/2 size-3.5 -translate-y-1/2 opacity-50", "aria-hidden": "true" })] }))] }), _jsxs("div", { className: "flex items-center gap-1", children: [_jsx(PagerButton, { ariaLabel: t("kumiko.pager.previousPage"), disabled: safePage <= 1, onClick: () => onPageChange(safePage - 1), testId: testId !== undefined ? `${testId}-prev` : undefined, children: _jsx(ChevronLeft, { className: "size-3.5", "aria-hidden": "true" }) }), _jsx("div", { className: "hidden items-center gap-1 sm:flex", children: pageNumbersAround(safePage, totalPages).map((entry) => typeof entry !== "number" ? (_jsx("span", { "aria-hidden": "true", className: "px-1", children: "\u2026" }, `gap-${entry.gapBefore}`)) : (_jsx(PageNumberButton, { page: entry, current: entry === safePage, label: t("kumiko.pager.goToPage", { page: entry.toLocaleString() }), onClick: () => onPageChange(entry), testId: testId !== undefined ? `${testId}-page-${entry}` : undefined }, entry))) }), _jsx(PagerButton, { ariaLabel: t("kumiko.pager.nextPage"), disabled: safePage >= totalPages, onClick: () => onPageChange(safePage + 1), testId: testId !== undefined ? `${testId}-next` : undefined, children: _jsx(ChevronRight, { className: "size-3.5", "aria-hidden": "true" }) })] })] }));
|
|
83
|
+
}
|
|
84
|
+
// All pages up to 7, else first, last and the neighbours of the current page, gaps in between.
|
|
85
|
+
function pageNumbersAround(current, totalPages) {
|
|
86
|
+
if (totalPages <= 7)
|
|
87
|
+
return Array.from({ length: totalPages }, (_, i) => i + 1);
|
|
88
|
+
const wanted = new Set([1, current - 1, current, current + 1, totalPages]);
|
|
89
|
+
const pages = [...wanted].filter((page) => page >= 1 && page <= totalPages).sort((a, b) => a - b);
|
|
90
|
+
return pages.flatMap((page, index) => {
|
|
91
|
+
const previous = pages[index - 1];
|
|
92
|
+
return previous !== undefined && page - previous > 1 ? [{ gapBefore: page }, page] : [page];
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function PageNumberButton({ page, current, label, onClick, testId, }) {
|
|
96
|
+
return (_jsx("button", { type: "button", onClick: onClick, "aria-label": label, "aria-current": current ? "page" : undefined, "data-testid": testId, className: cn("inline-flex h-7 min-w-7 items-center justify-center rounded-md px-1.5", "hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", current && "bg-muted font-semibold text-foreground"), children: page.toLocaleString() }));
|
|
86
97
|
}
|
|
87
98
|
function PagerButton({ children, onClick, ariaLabel, disabled, testId, }) {
|
|
88
|
-
return (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, "aria-label": ariaLabel, "data-testid": testId, className: cn("inline-flex size-11 items-center justify-center rounded-md border border-border
|
|
99
|
+
return (_jsx("button", { type: "button", onClick: onClick, disabled: disabled, "aria-label": ariaLabel, "data-testid": testId, className: cn("inline-flex size-11 items-center justify-center rounded-md border border-border sm:size-7", "hover:bg-muted focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", "disabled:pointer-events-none disabled:text-foreground-disabled"), children: children }));
|
|
89
100
|
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
/** The opened "why" of a hint or step: a dark note box with a small arrow at the top left, so it reads as a note on top of the row tint. */
|
|
3
|
+
export declare function ReasonBox({ children, title, testId, id, ...dataAttributes }: {
|
|
4
|
+
readonly children: ReactNode;
|
|
5
|
+
/** Bold lead-in of the paragraph. */
|
|
6
|
+
readonly title?: string;
|
|
7
|
+
readonly testId?: string;
|
|
8
|
+
/** Target of the info button's `aria-controls`. */
|
|
9
|
+
readonly id?: string;
|
|
10
|
+
readonly "data-hint-reason"?: "true";
|
|
11
|
+
}): ReactNode;
|
|
12
|
+
/** Info icon that opens a ReasonBox; sits next to a title and never opens a clickable row around it. */
|
|
13
|
+
export declare function ReasonInfoButton({ label, open, onToggle, controls, ...dataAttributes }: {
|
|
14
|
+
readonly label: string;
|
|
15
|
+
readonly open: boolean;
|
|
16
|
+
readonly onToggle: () => void;
|
|
17
|
+
/** Id of the box this button opens; only referenced while open. */
|
|
18
|
+
readonly controls?: string;
|
|
19
|
+
readonly "data-hint-reason-toggle"?: "true";
|
|
20
|
+
}): ReactNode;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Info } from "lucide-react";
|
|
3
|
+
/** The opened "why" of a hint or step: a dark note box with a small arrow at the top left, so it reads as a note on top of the row tint. */
|
|
4
|
+
export function ReasonBox({ children, title, testId, id, ...dataAttributes }) {
|
|
5
|
+
return (_jsxs("span", { "data-testid": testId, id: id, ...dataAttributes, className: "relative mt-1 block rounded-md bg-sidebar px-3 py-2.5 text-[12.5px] leading-[1.45] text-sidebar-foreground whitespace-pre-line before:absolute before:-top-[5px] before:left-[18px] before:border-[5px] before:border-t-0 before:border-transparent before:border-b-sidebar before:content-['']", children: [title !== undefined && _jsxs("b", { className: "font-semibold", children: [title, " "] }), children] }));
|
|
6
|
+
}
|
|
7
|
+
/** Info icon that opens a ReasonBox; sits next to a title and never opens a clickable row around it. */
|
|
8
|
+
export function ReasonInfoButton({ label, open, onToggle, controls, ...dataAttributes }) {
|
|
9
|
+
return (_jsx("button", { type: "button", "aria-expanded": open, "aria-controls": open ? controls : undefined, "aria-label": label, title: label, ...dataAttributes, className: "shrink-0 text-muted-foreground hover:text-foreground", onClick: (event) => {
|
|
10
|
+
event.stopPropagation();
|
|
11
|
+
onToggle();
|
|
12
|
+
}, children: _jsx(Info, { className: "size-4", "aria-hidden": "true" }) }));
|
|
13
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { Fragment, useContext } from "react";
|
|
3
|
+
import { uniqueLabelKeys } from "../../app/unique-label-keys.js";
|
|
4
|
+
import { cn } from "../lib/cn.js";
|
|
5
|
+
import { DefaultLink } from "./layout-elements.js";
|
|
6
|
+
import { InsideScreenFormColumnContext } from "./metric.js";
|
|
7
|
+
export function DefaultRecordBreadcrumb({ items, ariaLabel, testId, }) {
|
|
8
|
+
const insideScreenFormColumn = useContext(InsideScreenFormColumnContext);
|
|
9
|
+
const keys = uniqueLabelKeys(items.map((item) => item.label));
|
|
10
|
+
return (_jsx("nav", { "aria-label": ariaLabel, "data-testid": testId, className: cn("flex shrink-0 flex-wrap items-center gap-2 text-[13px] text-muted-foreground", !insideScreenFormColumn && "px-6 pt-3.5"), children: items.map((item, index) => (_jsxs(Fragment, { children: [index > 0 && _jsx("span", { "aria-hidden": "true", children: "\u203A" }), item.link !== undefined ? (_jsx(DefaultLink, { href: item.link.href, onPress: item.link.onPress, className: "text-foreground-secondary", children: item.label })) : (_jsx("span", { className: "font-medium text-foreground", children: item.label }))] }, keys[index]))) }));
|
|
11
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
import type { RecordStepsProps } from "../../index.ts";
|
|
3
|
+
export declare function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, narrowLimit, moreLabel, lessLabel, items, count, testId, }: RecordStepsProps): ReactNode;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useContext, useId, useState } from "react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { InsideScreenFormColumnContext } from "./metric.js";
|
|
5
|
+
import { ReasonBox, ReasonInfoButton } from "./reason-box.js";
|
|
6
|
+
import { useIsBelowSmViewport } from "./use-narrow-viewport.js";
|
|
7
|
+
const STEP_STRIPE_CLASS = {
|
|
8
|
+
bad: "bg-status-bad",
|
|
9
|
+
warn: "bg-status-warn",
|
|
10
|
+
critical: "bg-status-critical",
|
|
11
|
+
ok: "bg-status-ok",
|
|
12
|
+
accent: "bg-primary",
|
|
13
|
+
neutral: "bg-border-strong",
|
|
14
|
+
};
|
|
15
|
+
function StepDetail({ item }) {
|
|
16
|
+
const narrow = useIsBelowSmViewport();
|
|
17
|
+
const detail = narrow ? (item.narrowDetail ?? item.detail) : item.detail;
|
|
18
|
+
if (detail === undefined)
|
|
19
|
+
return null;
|
|
20
|
+
return _jsx("small", { className: "block text-xs text-muted-foreground", children: detail });
|
|
21
|
+
}
|
|
22
|
+
function StepRow({ item, reasonLabel }) {
|
|
23
|
+
const [reasonOpen, setReasonOpen] = useState(item.reasonOpen === true);
|
|
24
|
+
const reasonBoxId = useId();
|
|
25
|
+
return (_jsxs("li", { "data-testid": `record-step-${item.id}`, "data-tone": item.tone, className: "relative grid grid-cols-[minmax(0,1fr)_auto] gap-x-3 gap-y-1 py-3 pl-5 pr-4 max-sm:py-1.5 max-sm:pl-3.5 max-sm:pr-0", children: [_jsx("span", { "aria-hidden": "true", className: cn("absolute inset-y-2 left-0 w-1 rounded-full max-sm:inset-y-0 max-sm:w-[3px]", STEP_STRIPE_CLASS[item.tone ?? "neutral"]) }), _jsxs("div", { className: "col-start-1 row-start-1 flex min-w-0 items-start gap-2", children: [_jsx("span", { className: "font-medium text-foreground max-sm:text-sm", children: item.title }), item.reason !== undefined && (_jsx("span", { className: "flex max-sm:hidden", children: _jsx(ReasonInfoButton, { label: reasonLabel, open: reasonOpen, controls: reasonBoxId, onToggle: () => setReasonOpen((open) => !open) }) }))] }), _jsxs("div", { className: "col-start-2 row-start-1 flex shrink-0 items-center gap-3 max-sm:row-span-2 max-sm:self-center max-sm:[&_button]:h-8 max-sm:[&_button]:text-[13px]", children: [item.moreActions !== undefined && _jsx("div", { className: "max-sm:hidden", children: item.moreActions }), item.actions] }), _jsx("div", { className: "col-start-1 row-start-2 min-w-0 sm:col-span-2", children: _jsx(StepDetail, { item: item }) }), item.reason !== undefined && reasonOpen && (_jsx("div", { className: "col-span-2 row-start-3 max-sm:hidden", children: _jsx(ReasonBox, { id: reasonBoxId, testId: `record-step-${item.id}-reason`, ...(item.reasonTitle !== undefined && { title: item.reasonTitle }), children: item.reason }) }))] }));
|
|
26
|
+
}
|
|
27
|
+
function StepsHeader({ title, subtitle, count, testId, }) {
|
|
28
|
+
return (_jsxs("header", { className: "flex flex-wrap items-baseline gap-x-3 gap-y-1 px-4 py-3 sm:border-b max-sm:px-0 max-sm:pt-1", children: [_jsx("h3", { className: "m-0 text-sm font-semibold text-foreground", children: title }), subtitle !== undefined && (_jsx("span", { className: "text-[13px] text-muted-foreground max-sm:hidden", children: subtitle })), count !== undefined && (_jsx("span", { "data-testid": `${testId ?? "record-steps"}-count`, className: "ml-auto text-xs text-muted-foreground sm:hidden", children: count }))] }));
|
|
29
|
+
}
|
|
30
|
+
function StepsMoreToggle({ testId, expanded, label, onToggle, }) {
|
|
31
|
+
return (_jsxs("button", { type: "button", "data-testid": `${testId ?? "record-steps"}-toggle`, "aria-expanded": expanded, className: "relative w-full border-t px-4 py-3 text-left text-sm font-medium text-primary hover:underline max-sm:mt-2.5 max-sm:border-t-0 max-sm:py-1 max-sm:pl-3.5 max-sm:pr-0 max-sm:text-xs max-sm:font-normal max-sm:text-muted-foreground max-sm:no-underline", onClick: onToggle, children: [_jsx("span", { "aria-hidden": "true", className: "absolute inset-y-0 left-0 w-[3px] rounded-full bg-border sm:hidden" }), label] }));
|
|
32
|
+
}
|
|
33
|
+
export function DefaultRecordSteps({ title, subtitle, emptyLabel, reasonLabel, narrowLimit, moreLabel, lessLabel, items, count, testId, }) {
|
|
34
|
+
const insideScreenFormColumn = useContext(InsideScreenFormColumnContext);
|
|
35
|
+
const narrow = useIsBelowSmViewport();
|
|
36
|
+
const [expanded, setExpanded] = useState(false);
|
|
37
|
+
const limited = narrow && narrowLimit !== undefined && items.length > narrowLimit;
|
|
38
|
+
const visible = limited && !expanded ? items.slice(0, narrowLimit) : items;
|
|
39
|
+
const toggleLabel = moreLabel === undefined || lessLabel === undefined
|
|
40
|
+
? undefined
|
|
41
|
+
: expanded
|
|
42
|
+
? lessLabel
|
|
43
|
+
: moreLabel(items.length - visible.length);
|
|
44
|
+
return (_jsx("section", { "data-testid": testId, className: cn("shrink-0", !insideScreenFormColumn && "px-6 py-2"), children: _jsxs("div", { className: "sm:rounded-md sm:border sm:bg-card", children: [_jsx(StepsHeader, { title: title, subtitle: subtitle, count: count, testId: testId }), items.length === 0 ? (_jsx("p", { className: "m-0 px-4 py-3 text-sm text-muted-foreground", children: emptyLabel })) : (_jsx("ul", { className: "m-0 flex list-none flex-col p-0 max-sm:gap-2.5 sm:divide-y", children: visible.map((item) => (_jsx(StepRow, { item: item, reasonLabel: reasonLabel }, item.id))) })), limited && toggleLabel !== undefined && (_jsx(StepsMoreToggle, { testId: testId, expanded: expanded, label: toggleLabel, onToggle: () => setExpanded((open) => !open) }))] }) }));
|
|
45
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { useContext } from "react";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { InsideScreenFormColumnContext } from "./metric.js";
|
|
5
|
+
import { useIsBelowSmViewport } from "./use-narrow-viewport.js";
|
|
6
|
+
const SUMMARY_BORDER_CLASS = {
|
|
7
|
+
bad: "border-status-bad",
|
|
8
|
+
warn: "border-status-warn",
|
|
9
|
+
critical: "border-status-critical",
|
|
10
|
+
ok: "border-status-ok",
|
|
11
|
+
accent: "border-primary",
|
|
12
|
+
neutral: "border-border-strong",
|
|
13
|
+
};
|
|
14
|
+
export function DefaultRecordSummary({ text, narrowText, tone, testId, }) {
|
|
15
|
+
const insideScreenFormColumn = useContext(InsideScreenFormColumnContext);
|
|
16
|
+
const narrow = useIsBelowSmViewport();
|
|
17
|
+
return (_jsx("div", { className: cn("shrink-0", !insideScreenFormColumn && "px-6 py-2"), children: _jsx("p", { "data-testid": testId, "data-tone": tone, className: cn("m-0 rounded-md border border-l-[3px] bg-card px-4 py-3 font-heading text-[15.5px] leading-[1.5] sm:text-[17px] sm:leading-relaxed text-foreground", tone === undefined ? "border-l-primary" : SUMMARY_BORDER_CLASS[tone]), children: narrow && narrowText !== undefined ? narrowText : text }) }));
|
|
18
|
+
}
|
|
@@ -3,11 +3,13 @@ import type { ListRowViewModel } from "../../headless/index.ts";
|
|
|
3
3
|
import type { DataTableRowAction, DataTableRowActionMode } from "../../index.ts";
|
|
4
4
|
import { type ActionOverflowMenuProps } from "../../index.ts";
|
|
5
5
|
import "../react-css-custom-properties.ts";
|
|
6
|
-
export declare function RowActionsCell({ row, actions, mode, rowIsLink, compact, }: {
|
|
6
|
+
export declare function RowActionsCell({ row, actions, mode, rowIsLink, compact, small, }: {
|
|
7
7
|
readonly row: ListRowViewModel;
|
|
8
8
|
readonly actions: readonly DataTableRowAction[];
|
|
9
9
|
readonly mode?: DataTableRowActionMode;
|
|
10
10
|
readonly rowIsLink?: boolean;
|
|
11
11
|
readonly compact?: boolean;
|
|
12
|
+
/** Small bordered buttons without the phone touch height; for buttons sitting inside a card. */
|
|
13
|
+
readonly small?: boolean;
|
|
12
14
|
}): ReactNode;
|
|
13
15
|
export declare function ActionOverflowMenu({ items, label, testId }: ActionOverflowMenuProps): ReactNode;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Loader2, MoreHorizontal } from "lucide-react";
|
|
3
3
|
import { useState } from "react";
|
|
4
|
+
import { COMPACT_TAP_CLASSES } from "../../compact-tap-classes.js";
|
|
4
5
|
import { needsActionConfirm, shouldRenderActionsIconOnly, useTranslation, WriteFailedError, } from "../../index.js";
|
|
5
6
|
import { Icon } from "../icons.js";
|
|
6
7
|
import { cn } from "../lib/cn.js";
|
|
@@ -24,14 +25,18 @@ function primaryRowAction(actions) {
|
|
|
24
25
|
// >2 (no kebab). `w-full justify-start` pins the first button to the
|
|
25
26
|
// column's left edge so it sits at the same position across rows
|
|
26
27
|
// (otherwise it would drift with differently-sized labels).
|
|
28
|
+
// - "menu": every action in the kebab, whatever its `display`.
|
|
27
29
|
// The isVisible filter runs here; an action hidden for a given row never
|
|
28
30
|
// reaches render. If every action is hidden, the cell stays empty (no
|
|
29
31
|
// phantom column).
|
|
30
|
-
export function RowActionsCell({ row, actions, mode = "adaptive", rowIsLink = false, compact = false, }) {
|
|
32
|
+
export function RowActionsCell({ row, actions, mode = "adaptive", rowIsLink = false, compact = false, small = false, }) {
|
|
31
33
|
const visible = actions.filter((a) => a.isVisible === undefined || a.isVisible(row));
|
|
32
34
|
if (visible.length === 0)
|
|
33
35
|
return null;
|
|
34
36
|
const hasExplicitDisplay = visible.some((a) => a.display !== undefined);
|
|
37
|
+
if (mode === "menu") {
|
|
38
|
+
return (_jsx("div", { className: "inline-flex items-center justify-end", children: _jsx(RowActionsKebab, { row: row, actions: visible }) }));
|
|
39
|
+
}
|
|
35
40
|
if (mode === "inline") {
|
|
36
41
|
// Teil C: >2 actions all carrying an icon collapse to icon-only —
|
|
37
42
|
// otherwise "inline" is exactly the wall-to-wall text-button problem
|
|
@@ -42,7 +47,7 @@ export function RowActionsCell({ row, actions, mode = "adaptive", rowIsLink = fa
|
|
|
42
47
|
if (hasExplicitDisplay) {
|
|
43
48
|
const inline = visible.filter((a) => a.display !== undefined);
|
|
44
49
|
const rest = visible.filter((a) => a.display === undefined);
|
|
45
|
-
return (_jsxs("div", { className: "inline-flex flex-nowrap items-center gap-1 justify-end whitespace-nowrap", children: [inline.map((a) => (_jsx(RowActionButton, { row: row, action: a, compact: compact }, a.id))), rest.length > 0 && _jsx(RowActionsKebab, { row: row, actions: rest })] }));
|
|
50
|
+
return (_jsxs("div", { className: "inline-flex flex-nowrap items-center gap-1 justify-end whitespace-nowrap", children: [inline.map((a) => (_jsx(RowActionButton, { row: row, action: a, compact: compact, small: small }, a.id))), rest.length > 0 && _jsx(RowActionsKebab, { row: row, actions: rest })] }));
|
|
46
51
|
}
|
|
47
52
|
if (rowIsLink) {
|
|
48
53
|
return (_jsx("div", { className: "inline-flex items-center justify-end", children: _jsx(RowActionsKebab, { row: row, actions: visible }) }));
|
|
@@ -93,11 +98,13 @@ function effectiveRowActionDisplay(display, hasIcon, compact) {
|
|
|
93
98
|
return "link";
|
|
94
99
|
return display;
|
|
95
100
|
}
|
|
96
|
-
function RowActionButton({ row, action, iconOnly = false, asLink = false, compact = false, }) {
|
|
101
|
+
function RowActionButton({ row, action, iconOnly = false, asLink = false, compact = false, small = false, }) {
|
|
97
102
|
const { busy, triggerNow } = useRowActionTrigger(row);
|
|
98
103
|
const [confirmOpen, setConfirmOpen] = useState(false);
|
|
99
104
|
const resolvedIcon = actionIconFor(action.icon);
|
|
100
|
-
const
|
|
105
|
+
const resolvedDisplay = effectiveRowActionDisplay(action.display, resolvedIcon !== undefined, compact);
|
|
106
|
+
// A card's small row action is always an outlined button, also when the author asked for a link.
|
|
107
|
+
const display = small && resolvedDisplay === "link" ? "button" : resolvedDisplay;
|
|
101
108
|
const isBorderedButton = display === "button";
|
|
102
109
|
const showIconOnly = display === "icon" || (display === undefined && iconOnly && resolvedIcon !== undefined);
|
|
103
110
|
const linkLike = display === "link" || (display === undefined && asLink);
|
|
@@ -123,7 +130,9 @@ function RowActionButton({ row, action, iconOnly = false, asLink = false, compac
|
|
|
123
130
|
void triggerNow(action);
|
|
124
131
|
}
|
|
125
132
|
}, className: cn("inline-flex items-center justify-center gap-1.5 text-sm", isBorderedButton
|
|
126
|
-
?
|
|
133
|
+
? small
|
|
134
|
+
? cn("rounded-md font-medium", COMPACT_TAP_CLASSES)
|
|
135
|
+
: "h-8 rounded-md px-3 font-medium max-md:h-11"
|
|
127
136
|
: linkLike
|
|
128
137
|
? "h-7 rounded-md px-2.5 max-md:h-11"
|
|
129
138
|
: "h-8 rounded-sm max-md:h-11", showIconOnly ? "w-8 max-md:w-11" : !linkLike && !isBorderedButton && "px-2", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", "disabled:opacity-50 disabled:pointer-events-none", variantClass), children: busy ? (_jsx(Loader2, { className: "size-3.5 animate-spin", "aria-hidden": "true" })) : resolvedIcon === undefined || (linkLike && !showIconOnly) ? (action.label) : showIconOnly ? (_jsx(Icon, { name: resolvedIcon, className: "size-4" })) : (_jsxs(_Fragment, { children: [_jsx(Icon, { name: resolvedIcon, className: "size-4" }), action.label] })) }), _jsx(DefaultDialog, { open: confirmOpen, onOpenChange: setConfirmOpen, title: action.label, ...(action.confirm !== undefined && { description: action.confirm }), confirmLabel: action.confirmLabel ?? action.label, ...(action.style === "danger" && { variant: "danger" }), onConfirm: () => triggerNow(action), testId: `row-${row.id}-action-${action.id}-dialog` })] }));
|
|
@@ -3,7 +3,6 @@ import { useRef } from "react";
|
|
|
3
3
|
import { statusToneForOptionTone } from "../../index.js";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
5
5
|
import { TONE_PILL } from "../widgets/status-badge.js";
|
|
6
|
-
const EQUAL_WIDTH_MAX_SEGMENTS = 4;
|
|
7
6
|
// WAI-ARIA radiogroup pattern (role="radiogroup" + role="radio" children):
|
|
8
7
|
// arrow keys move focus AND selection in the same step, only the checked
|
|
9
8
|
// segment (or the first when none is checked) sits in the tab order.
|
|
@@ -39,11 +38,10 @@ export function SegmentedControl({ id, name, value, onChange, options, disabled,
|
|
|
39
38
|
}
|
|
40
39
|
};
|
|
41
40
|
return (_jsxs("div", { role: "radiogroup", ...labelProps, "aria-required": required, "aria-invalid": hasError === true ? true : undefined, "data-testid": `segmented-${id}`, className: cn(
|
|
42
|
-
//
|
|
43
|
-
//
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
: "inline-flex w-fit flex-wrap", size === "touch" ? "min-h-11" : "min-h-9", "overflow-hidden rounded-md border", hasError === true ? "border-destructive" : "border-input"), children: [_jsx("input", { type: "hidden", name: name, value: value }), options.map((opt, index) => {
|
|
41
|
+
// Labels stay whole (nowrap on the segment, whose min-content is then the full
|
|
42
|
+
// label); when the column is too narrow the segment moves to the next row
|
|
43
|
+
// instead of breaking a word or spilling into its neighbour.
|
|
44
|
+
"inline-flex w-fit max-w-full flex-wrap", size === "touch" ? "min-h-11" : "min-h-9", "overflow-hidden rounded-md border", hasError === true ? "border-destructive" : "border-input"), children: [_jsx("input", { type: "hidden", name: name, value: value }), options.map((opt, index) => {
|
|
47
45
|
const checked = opt.value === value;
|
|
48
46
|
const declaredTone = tones !== undefined && Object.hasOwn(tones, opt.value) ? tones[opt.value] : undefined;
|
|
49
47
|
const badgeTone = declaredTone !== undefined ? statusToneForOptionTone(declaredTone) : undefined;
|
|
@@ -65,7 +63,7 @@ export function SegmentedControl({ id, name, value, onChange, options, disabled,
|
|
|
65
63
|
// and the next row's top border cut a notch into the row above.
|
|
66
64
|
// Harmless on a single-row layout: there's no leftover space to
|
|
67
65
|
// grow into, so `w-fit` on the container still holds.
|
|
68
|
-
"-ml-px -mt-px grow border-l border-t px-3 py-1.5 text-center text-sm transition-colors", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", "disabled:pointer-events-none disabled:opacity-50", hasError === true ? "border-destructive/50" : "border-border", size === "touch" && "min-h-11", checked
|
|
66
|
+
"-ml-px -mt-px grow basis-0 whitespace-nowrap border-l border-t px-3 py-1.5 text-center text-sm transition-colors", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", "disabled:pointer-events-none disabled:opacity-50", hasError === true ? "border-destructive/50" : "border-border", size === "touch" && "min-h-11", checked
|
|
69
67
|
? cn("font-semibold", badgeTone !== undefined ? TONE_PILL[badgeTone] : "bg-primary/10 text-primary")
|
|
70
68
|
: "bg-transparent font-medium text-foreground hover:bg-accent"), children: opt.label }, opt.value));
|
|
71
69
|
})] }));
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
import { PWA_SERVICE_WORKER_META_NAME } from "../../headless/pwa-service-worker-meta.js";
|
|
4
|
+
import { useTranslation } from "../../index.js";
|
|
5
|
+
import { cn } from "../lib/cn.js";
|
|
6
|
+
export const PWA_INSTALL_HINT_DISMISSED_KEY = "kumiko:pwa-install-hint-dismissed";
|
|
7
|
+
function isBeforeInstallPromptEvent(event) {
|
|
8
|
+
return "prompt" in event && typeof event.prompt === "function";
|
|
9
|
+
}
|
|
10
|
+
export function readPwaServiceWorkerUrl() {
|
|
11
|
+
if (typeof document === "undefined")
|
|
12
|
+
return undefined;
|
|
13
|
+
const content = document
|
|
14
|
+
.querySelector(`meta[name="${PWA_SERVICE_WORKER_META_NAME}"]`)
|
|
15
|
+
?.getAttribute("content");
|
|
16
|
+
return content ? content : undefined;
|
|
17
|
+
}
|
|
18
|
+
function isRunningStandalone() {
|
|
19
|
+
if (typeof window.matchMedia === "function") {
|
|
20
|
+
if (window.matchMedia("(display-mode: standalone)").matches)
|
|
21
|
+
return true;
|
|
22
|
+
}
|
|
23
|
+
return "standalone" in navigator && navigator.standalone === true;
|
|
24
|
+
}
|
|
25
|
+
// iPadOS reports a desktop Mac user agent; the touch points tell it apart.
|
|
26
|
+
function isIosDevice() {
|
|
27
|
+
const userAgent = navigator.userAgent;
|
|
28
|
+
if (/iPhone|iPad|iPod/.test(userAgent))
|
|
29
|
+
return true;
|
|
30
|
+
return /Macintosh/.test(userAgent) && navigator.maxTouchPoints > 1;
|
|
31
|
+
}
|
|
32
|
+
// Storage can throw (Safari private mode, blocked site data); the hint then just shows again.
|
|
33
|
+
function isInstallHintDismissed() {
|
|
34
|
+
try {
|
|
35
|
+
return window.localStorage.getItem(PWA_INSTALL_HINT_DISMISSED_KEY) === "1";
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
function rememberInstallHintDismissed() {
|
|
42
|
+
try {
|
|
43
|
+
window.localStorage.setItem(PWA_INSTALL_HINT_DISMISSED_KEY, "1");
|
|
44
|
+
}
|
|
45
|
+
catch {
|
|
46
|
+
// Not remembered: the hint comes back on the next visit.
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
function registerServiceWorker(serviceWorkerUrl) {
|
|
50
|
+
if (!("serviceWorker" in navigator))
|
|
51
|
+
return;
|
|
52
|
+
// Fails on insecure origins and in some private modes; the app works without the worker.
|
|
53
|
+
// The worker may only control its own directory, so the scope follows the worker's URL.
|
|
54
|
+
const scope = new URL("./", new URL(serviceWorkerUrl, window.location.href)).pathname;
|
|
55
|
+
navigator.serviceWorker
|
|
56
|
+
.register(serviceWorkerUrl, { scope, updateViaCache: "none" })
|
|
57
|
+
.catch(() => undefined);
|
|
58
|
+
}
|
|
59
|
+
function useInstallHint(enabled) {
|
|
60
|
+
const [hint, setHint] = useState({ kind: "none" });
|
|
61
|
+
useEffect(() => {
|
|
62
|
+
if (!enabled || isRunningStandalone() || isInstallHintDismissed())
|
|
63
|
+
return;
|
|
64
|
+
if (isIosDevice()) {
|
|
65
|
+
setHint({ kind: "ios" });
|
|
66
|
+
return;
|
|
67
|
+
}
|
|
68
|
+
const onBeforeInstallPrompt = (event) => {
|
|
69
|
+
if (!isBeforeInstallPromptEvent(event))
|
|
70
|
+
return;
|
|
71
|
+
// Keeps the browser's own mini-infobar away; the hint offers the prompt instead.
|
|
72
|
+
event.preventDefault();
|
|
73
|
+
setHint({ kind: "prompt", event });
|
|
74
|
+
};
|
|
75
|
+
const onAppInstalled = () => {
|
|
76
|
+
rememberInstallHintDismissed();
|
|
77
|
+
setHint({ kind: "none" });
|
|
78
|
+
};
|
|
79
|
+
window.addEventListener("beforeinstallprompt", onBeforeInstallPrompt);
|
|
80
|
+
window.addEventListener("appinstalled", onAppInstalled);
|
|
81
|
+
return () => {
|
|
82
|
+
window.removeEventListener("beforeinstallprompt", onBeforeInstallPrompt);
|
|
83
|
+
window.removeEventListener("appinstalled", onAppInstalled);
|
|
84
|
+
};
|
|
85
|
+
}, [enabled]);
|
|
86
|
+
const dismiss = () => {
|
|
87
|
+
rememberInstallHintDismissed();
|
|
88
|
+
setHint({ kind: "none" });
|
|
89
|
+
};
|
|
90
|
+
return [hint, dismiss];
|
|
91
|
+
}
|
|
92
|
+
const HINT_BUTTON_CLASSES = cn("rounded-md px-3 py-1 text-xs font-medium", "hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-ring");
|
|
93
|
+
export function PwaSupport() {
|
|
94
|
+
const t = useTranslation();
|
|
95
|
+
const serviceWorkerUrl = readPwaServiceWorkerUrl();
|
|
96
|
+
const [hint, dismiss] = useInstallHint(serviceWorkerUrl !== undefined);
|
|
97
|
+
useEffect(() => {
|
|
98
|
+
if (serviceWorkerUrl !== undefined)
|
|
99
|
+
registerServiceWorker(serviceWorkerUrl);
|
|
100
|
+
}, [serviceWorkerUrl]);
|
|
101
|
+
if (hint.kind === "none")
|
|
102
|
+
return null;
|
|
103
|
+
const install = async (event) => {
|
|
104
|
+
dismiss();
|
|
105
|
+
try {
|
|
106
|
+
await event.prompt();
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
// prompt() rejects when the browser already used this event; nothing left to offer.
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
return (_jsxs("div", { role: "status", className: cn("fixed inset-x-0 bottom-0 z-[150] flex flex-wrap items-center justify-center gap-3", "border-t bg-background px-4 py-3 text-sm text-foreground shadow-md", "pb-[max(0.75rem,env(safe-area-inset-bottom))]"), children: [_jsx("span", { children: hint.kind === "ios" ? t("kumiko.pwa.install-hint-ios") : t("kumiko.pwa.install-hint") }), hint.kind === "prompt" && (_jsx("button", { type: "button", onClick: () => void install(hint.event), className: cn(HINT_BUTTON_CLASSES, "bg-primary text-primary-foreground"), children: t("kumiko.pwa.install") })), _jsx("button", { type: "button", onClick: dismiss, className: cn(HINT_BUTTON_CLASSES, "border bg-background"), children: t("kumiko.pwa.dismiss") })] }));
|
|
113
|
+
}
|
|
@@ -45,7 +45,6 @@ function hasErrorCode(body) {
|
|
|
45
45
|
async function isSessionEndedRejection(url) {
|
|
46
46
|
const controller = new AbortController();
|
|
47
47
|
try {
|
|
48
|
-
// kumiko-lint-ignore direct-fetch url is the app's own SSE endpoint, probed with same-origin credentials
|
|
49
48
|
const res = await fetch(url, {
|
|
50
49
|
credentials: "same-origin",
|
|
51
50
|
headers: { Accept: "text/event-stream" },
|
|
@@ -166,7 +165,8 @@ export function createEventSourceLiveEvents(options = {}) {
|
|
|
166
165
|
sessionEndedSignalled = true;
|
|
167
166
|
onSessionEnded?.();
|
|
168
167
|
};
|
|
169
|
-
|
|
168
|
+
// Armed on `open`, not here: a scale-from-zero cold start can hold the handshake longer
|
|
169
|
+
// than the stall timeout, and aborting it would restart the cold start on every retry.
|
|
170
170
|
connection.addEventListener("ping", () => armStallWatchdog(connection));
|
|
171
171
|
connection.addEventListener("open", () => {
|
|
172
172
|
armStallWatchdog(connection);
|
package/dist/web/tokens.js
CHANGED
|
@@ -83,11 +83,9 @@ function readCurrentPreference() {
|
|
|
83
83
|
}
|
|
84
84
|
return currentPreference;
|
|
85
85
|
}
|
|
86
|
-
// @wrapper-known semantic-alias
|
|
87
86
|
function notifyThemeChange() {
|
|
88
87
|
themeTick.setState((t) => t + 1);
|
|
89
88
|
}
|
|
90
|
-
// @wrapper-known semantic-alias
|
|
91
89
|
function persistPreference(preference) {
|
|
92
90
|
try {
|
|
93
91
|
window.localStorage.setItem(THEME_STORAGE_KEY, preference);
|
|
@@ -147,7 +145,6 @@ export function useBrowserTokensApi() {
|
|
|
147
145
|
});
|
|
148
146
|
const mode = useSyncExternalStore(themeTick.subscribe, readCurrentMode, () => "dark");
|
|
149
147
|
const preference = useSyncExternalStore(themeTick.subscribe, readCurrentPreference, () => "dark");
|
|
150
|
-
// kumiko-lint-ignore no-raw-hooks listener lifecycle, no data fetching
|
|
151
148
|
useEffect(() => {
|
|
152
149
|
// skip: without matchMedia, auto keeps the mode resolved at apply time
|
|
153
150
|
if (typeof window.matchMedia !== "function")
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
+
export type ChartSwatchKind = "area" | "line" | "dashed-line";
|
|
3
|
+
export declare function ChartSwatch({ color, swatch, className, }: {
|
|
4
|
+
readonly color: string;
|
|
5
|
+
readonly swatch: ChartSwatchKind;
|
|
6
|
+
readonly className?: string;
|
|
7
|
+
}): ReactNode;
|
|
2
8
|
export declare function ChartLegend({ items, formatValue, }: {
|
|
3
9
|
readonly items: readonly {
|
|
4
10
|
readonly key: string;
|
|
@@ -8,7 +14,7 @@ export declare function ChartLegend({ items, formatValue, }: {
|
|
|
8
14
|
readonly color: string;
|
|
9
15
|
/** Omitted: no sum next to the label. */
|
|
10
16
|
readonly total?: number;
|
|
11
|
-
readonly swatch?:
|
|
17
|
+
readonly swatch?: ChartSwatchKind;
|
|
12
18
|
}[];
|
|
13
19
|
readonly formatValue: (value: number) => string;
|
|
14
20
|
}): ReactNode;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../lib/cn.js";
|
|
3
|
+
export function ChartSwatch({ color, swatch, className, }) {
|
|
4
|
+
if (swatch === "area") {
|
|
5
|
+
return (_jsx("span", { "aria-hidden": "true", className: cn("size-2 rounded-[2px]", className), style: { backgroundColor: color } }));
|
|
6
|
+
}
|
|
7
|
+
return (_jsx("span", { "aria-hidden": "true", className: cn("w-3 border-t-2", className), style: {
|
|
8
|
+
borderColor: color,
|
|
9
|
+
borderTopStyle: swatch === "dashed-line" ? "dashed" : "solid",
|
|
10
|
+
} }));
|
|
11
|
+
}
|
|
3
12
|
export function ChartLegend({ items, formatValue, }) {
|
|
4
|
-
return (_jsx("ul", { className: "flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground", children: items.map((item) => (_jsxs("li", { "data-testid": `chart-legend-${item.testIdKey ?? item.key}`, className: "flex items-center gap-1.5", children: [item.swatch
|
|
5
|
-
borderColor: item.color,
|
|
6
|
-
borderTopStyle: item.swatch === "dashed-line" ? "dashed" : "solid",
|
|
7
|
-
} })), _jsx("span", { children: item.label }), item.total !== undefined && (_jsx("span", { className: "tabular-nums text-foreground", children: formatValue(item.total) }))] }, item.key))) }));
|
|
13
|
+
return (_jsx("ul", { className: "flex flex-wrap gap-x-4 gap-y-1 text-xs text-muted-foreground", children: items.map((item) => (_jsxs("li", { "data-testid": `chart-legend-${item.testIdKey ?? item.key}`, className: "flex items-center gap-1.5", children: [_jsx(ChartSwatch, { color: item.color, swatch: item.swatch ?? "area" }), _jsx("span", { children: item.label }), item.total !== undefined && (_jsx("span", { className: "tabular-nums text-foreground", children: formatValue(item.total) }))] }, item.key))) }));
|
|
8
14
|
}
|
|
9
15
|
const Y_TICK_COUNT = 3;
|
|
10
16
|
export function evenYTickValues(max) {
|
|
@@ -13,5 +13,5 @@ export function CollapsibleSection({ title, defaultOpen = false, children, testI
|
|
|
13
13
|
if (defaultOpen)
|
|
14
14
|
setOpen(true);
|
|
15
15
|
}, [defaultOpen]);
|
|
16
|
-
return (_jsxs("details", { "data-testid": testId, className: "group rounded-lg border bg-card", open: open, onToggle: (e) => setOpen(e.currentTarget.open), children: [_jsxs("summary", { className: "flex h-9 cursor-pointer select-none items-center justify-between gap-2 rounded-lg px-4 text-sm font-medium hover:bg-muted/50 [&::-webkit-details-marker]:hidden", children: [_jsx("span", { children: title }), _jsx(ChevronRight, { "aria-hidden": "true", className: "size-4 text-muted-foreground transition-transform group-open:rotate-90" })] }), _jsx("div", { className: "border-t px-4 py-3", children: children })] }));
|
|
16
|
+
return (_jsxs("details", { "data-testid": testId, className: "group rounded-lg border bg-card", open: open, onToggle: (e) => setOpen(e.currentTarget.open), children: [_jsxs("summary", { className: "flex min-h-9 py-1.5 cursor-pointer select-none items-center justify-between gap-2 rounded-lg px-4 text-sm font-medium hover:bg-muted/50 [&::-webkit-details-marker]:hidden", children: [_jsx("span", { children: title }), _jsx(ChevronRight, { "aria-hidden": "true", className: "size-4 text-muted-foreground transition-transform group-open:rotate-90" })] }), _jsx("div", { className: "border-t px-4 py-3", children: children })] }));
|
|
17
17
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import { type DashboardListColumn, type DashboardListRow } from "./dashboard-list.tsx";
|
|
3
|
+
type CardsProps = {
|
|
4
|
+
readonly columns: readonly DashboardListColumn[];
|
|
5
|
+
readonly rows: readonly DashboardListRow[];
|
|
6
|
+
readonly formatPercent: (fraction: number) => string;
|
|
7
|
+
readonly formatNumber: (value: number) => string;
|
|
8
|
+
readonly formatDateTime: (atMs: number) => string;
|
|
9
|
+
readonly translate: (key: string) => string;
|
|
10
|
+
readonly testId?: string;
|
|
11
|
+
readonly rowToneField?: string;
|
|
12
|
+
/** Row field replacing the hint sentence as card title. */
|
|
13
|
+
readonly titleField?: string;
|
|
14
|
+
};
|
|
15
|
+
/** One card per row for the phone layout of a dashboard list. Row 1: badges and a one-line detail, row 2: the hint sentence, row 3: `showOnNarrowOnly` columns left and the small buttons right. */
|
|
16
|
+
export declare function DashboardListCards({ columns, rows, testId, rowToneField, titleField, ...cellProps }: CardsProps): ReactNode;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { isSelectOptionTone } from "../../status-tone.js";
|
|
3
|
+
import { cn } from "../lib/cn.js";
|
|
4
|
+
import { DIMMED_HINT_SENTENCE_CLASS, HINT_TONE_TEXT_CLASS, isDimmedHintSentence, } from "../primitives/data-table/hint-cell.js";
|
|
5
|
+
import { cardToneClass } from "../primitives/data-table-cell.js";
|
|
6
|
+
import { DashboardListCell, rowToneOf, } from "./dashboard-list.js";
|
|
7
|
+
function nonEmptyText(value) {
|
|
8
|
+
if (typeof value !== "string")
|
|
9
|
+
return undefined;
|
|
10
|
+
const trimmed = value.trim();
|
|
11
|
+
return trimmed === "" ? undefined : trimmed;
|
|
12
|
+
}
|
|
13
|
+
function hasValue(value) {
|
|
14
|
+
return value !== undefined && value !== null && value !== "";
|
|
15
|
+
}
|
|
16
|
+
// The reason toggle of the table is left out on purpose: a phone card shows its facts, not a hidden explanation.
|
|
17
|
+
function CardHeadline({ column, row, titleField, }) {
|
|
18
|
+
const { hint } = column;
|
|
19
|
+
const sentence = (titleField === undefined ? undefined : nonEmptyText(row[titleField])) ??
|
|
20
|
+
nonEmptyText(row[column.field]);
|
|
21
|
+
const toneValue = hint.toneField === undefined ? undefined : row[hint.toneField];
|
|
22
|
+
const tone = isSelectOptionTone(toneValue) ? toneValue : undefined;
|
|
23
|
+
if (sentence === undefined) {
|
|
24
|
+
return (_jsx("span", { "data-hint-empty": "true", className: "text-sm text-muted-foreground", children: hint.emptyLabel }));
|
|
25
|
+
}
|
|
26
|
+
return (_jsx("span", { className: cn("text-sm", isDimmedHintSentence(tone, hint.plainSentence)
|
|
27
|
+
? DIMMED_HINT_SENTENCE_CLASS
|
|
28
|
+
: [
|
|
29
|
+
"font-semibold",
|
|
30
|
+
hint.plainSentence !== true && tone !== undefined && HINT_TONE_TEXT_CLASS[tone],
|
|
31
|
+
]), children: sentence }));
|
|
32
|
+
}
|
|
33
|
+
function detailOf(hint, row) {
|
|
34
|
+
if (hint === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
const field = hint.narrowDetailField ?? hint.detailField;
|
|
37
|
+
return field === undefined ? undefined : nonEmptyText(row[field]);
|
|
38
|
+
}
|
|
39
|
+
/** One card per row for the phone layout of a dashboard list. Row 1: badges and a one-line detail, row 2: the hint sentence, row 3: `showOnNarrowOnly` columns left and the small buttons right. */
|
|
40
|
+
export function DashboardListCards({ columns, rows, testId, rowToneField, titleField, ...cellProps }) {
|
|
41
|
+
const hintColumn = columns.find((column) => column.hint !== undefined);
|
|
42
|
+
const plain = columns.filter((column) => column.hint === undefined);
|
|
43
|
+
const badgeColumns = plain.filter((column) => column.display === "badge");
|
|
44
|
+
const buttonColumns = plain.filter((column) => column.display === "button");
|
|
45
|
+
const otherColumns = plain.filter((column) => column.display !== "badge" && column.display !== "button");
|
|
46
|
+
const cell = (column, row) => (_jsx(DashboardListCell, { column: column, row: row, ...cellProps }, column.field));
|
|
47
|
+
return (_jsx("ul", { "data-testid": testId, className: "m-0 flex list-none flex-col gap-2 p-0", children: rows.map((row, index) => {
|
|
48
|
+
const detail = detailOf(hintColumn?.hint, row);
|
|
49
|
+
const badges = badgeColumns.filter((column) => hasValue(row[column.field]));
|
|
50
|
+
const buttons = buttonColumns.filter((column) => hasValue(row[column.field]));
|
|
51
|
+
const others = otherColumns.filter((column) => hasValue(row[column.field]));
|
|
52
|
+
return (_jsxs("li", { "data-testid": "dashboard-list-card", className: cn("flex flex-col gap-1 rounded-lg border border-border bg-card px-3 py-2.5", cardToneClass(rowToneOf(row, rowToneField))), children: [(badges.length > 0 || detail !== undefined) && (_jsxs("div", { className: "flex min-w-0 items-center gap-2 text-xs text-muted-foreground", children: [badges.map((column) => cell(column, row)), detail !== undefined && (_jsx("small", { "data-testid": "dashboard-list-card-detail", className: "min-w-0 truncate text-xs", children: detail }))] })), hintColumn !== undefined && (_jsx(CardHeadline, { column: hintColumn, row: row, titleField: titleField })), (others.length > 0 || buttons.length > 0) && (_jsxs("div", { className: "flex items-center justify-between gap-3", children: [_jsx("div", { className: "flex min-w-0 flex-col text-xs text-muted-foreground", children: others.map((column) => (_jsx("span", { className: "truncate", children: cell(column, row) }, column.field))) }), buttons.length > 0 && (_jsx("div", { className: "flex shrink-0 flex-wrap justify-end gap-2 [&_a]:relative [&_a]:h-8 [&_a]:px-2.5 [&_a]:text-xs [&_a]:max-md:min-h-0 [&_a]:before:absolute [&_a]:before:inset-x-0 [&_a]:before:-inset-y-1.5 [&_a]:before:content-['']", children: buttons.map((column) => cell(column, row)) }))] }))] }, typeof row["id"] === "string" ? row["id"] : index));
|
|
53
|
+
}) }));
|
|
54
|
+
}
|