@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
|
@@ -4,20 +4,62 @@ import { cellLinkProp, DataTableCell, isBadgeColumn, isEmptyCellValue, isUnlabel
|
|
|
4
4
|
import { CardLeadingImage } from "../file-thumbnail.js";
|
|
5
5
|
import { columnCellPresentationProps } from "./data-cell-props.js";
|
|
6
6
|
import { showFullTextOnHover } from "./table-footer.js";
|
|
7
|
-
|
|
7
|
+
// The phone card shows the sentence and its (narrow) detail; the reason toggle stays a table feature.
|
|
8
|
+
function cardHint(hint) {
|
|
9
|
+
const { reasonField: _reason, reasonOpenField: _reasonOpen, reasonTitleField: _reasonTitle, detailField: _detail, narrowDetailField, ...rest } = hint;
|
|
10
|
+
const detailField = narrowDetailField ?? _detail;
|
|
11
|
+
return { ...rest, ...(detailField !== undefined && { detailField }) };
|
|
12
|
+
}
|
|
13
|
+
function cardCell(m, row, col, { linksAllowed } = { linksAllowed: false }) {
|
|
8
14
|
const { onCellChange } = m;
|
|
15
|
+
const opensRow = m.rowOpener(row) !== undefined;
|
|
9
16
|
// A bare check mark in the subtitle line says nothing without its column.
|
|
10
17
|
if (showsBareCheckMark(col.type, row.values[col.field], col.renderer))
|
|
11
18
|
return col.label;
|
|
12
|
-
return (_jsx(DataTableCell, { value: row.values[col.field], row: row.values, field: col.field, type: col.type, renderer: col.renderer, translate: m.tableTranslate, locale: m.tableLocale, ...columnCellPresentationProps(col), ...(col.fileDisplay !== undefined && { fileDisplay: col.fileDisplay, compactFile: true }), ...(onCellChange !== undefined && {
|
|
19
|
+
return (_jsx(DataTableCell, { value: row.values[col.field], row: row.values, field: col.field, type: col.type, renderer: col.renderer, translate: m.tableTranslate, locale: m.tableLocale, ...columnCellPresentationProps(col), ...(col.hint !== undefined && { hint: cardHint(col.hint) }), ...(col.fileDisplay !== undefined && { fileDisplay: col.fileDisplay, compactFile: true }), ...(onCellChange !== undefined && {
|
|
13
20
|
onChange: (value) => onCellChange(row.id, col.field, value),
|
|
14
|
-
}), ...
|
|
21
|
+
}), ...(col.rowActionLink === true &&
|
|
22
|
+
col.display === undefined && { display: "button" }), ...cellLinkProp(col, row, linksAllowed || !opensRow) }));
|
|
15
23
|
}
|
|
16
24
|
function cellTestIdOf(m, row, field) {
|
|
17
25
|
return m.getCellTestId?.(row, field) ?? `cell-${row.id}-${field}`;
|
|
18
26
|
}
|
|
27
|
+
function hasCardLink(row, col) {
|
|
28
|
+
return (!isEmptyCellValue(row.values[col.field]) && cellLinkProp(col, row, true).link !== undefined);
|
|
29
|
+
}
|
|
30
|
+
function needsControlOutsideOpener(row, col) {
|
|
31
|
+
return hasCardLink(row, col);
|
|
32
|
+
}
|
|
33
|
+
// A link inside the row's opener button would be an <a> or <button> in a
|
|
34
|
+
// <button>, so such columns of an openable card move out of the body and render below it.
|
|
35
|
+
export function splitLinkColumns(m, row, roles) {
|
|
36
|
+
if (m.rowOpener(row) === undefined)
|
|
37
|
+
return { bodyRoles: roles, linkColumns: [] };
|
|
38
|
+
const lead = roles.lead;
|
|
39
|
+
const leadColumn = lead !== undefined && needsControlOutsideOpener(row, lead) ? lead : undefined;
|
|
40
|
+
const linkMeta = roles.meta.filter((col) => needsControlOutsideOpener(row, col));
|
|
41
|
+
if (leadColumn === undefined && linkMeta.length === 0) {
|
|
42
|
+
return { bodyRoles: roles, linkColumns: [] };
|
|
43
|
+
}
|
|
44
|
+
return {
|
|
45
|
+
bodyRoles: {
|
|
46
|
+
...roles,
|
|
47
|
+
lead: leadColumn === undefined ? lead : undefined,
|
|
48
|
+
meta: roles.meta.filter((col) => !linkMeta.includes(col)),
|
|
49
|
+
},
|
|
50
|
+
linkColumns: [...(leadColumn !== undefined ? [leadColumn] : []), ...linkMeta],
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export function renderCardLinks(m, row, linkColumns) {
|
|
54
|
+
return (_jsx("div", { "data-testid": `card-links-${row.id}`, className: "flex flex-wrap items-center gap-x-3 text-[13px] leading-5", children: linkColumns.map((col) => (_jsx("span", { "data-testid": cellTestIdOf(m, row, col.field), children: cardCell(m, row, col, { linksAllowed: true }) }, col.field))) }));
|
|
55
|
+
}
|
|
19
56
|
function renderCardMeta(m, row, metaColumns) {
|
|
20
|
-
return (_jsx("div", { className: "min-w-0
|
|
57
|
+
return (_jsx("div", { className: "min-w-0", children: _jsx("div", { "data-testid": `card-meta-${row.id}`, className: "flex min-w-0 flex-col text-[13px] leading-5 tabular-nums text-foreground-secondary", children: metaColumns.map((col) => (_jsx("div", { className: "flex h-5 min-w-0 max-w-full items-center", children: _jsx("div", { "data-testid": cellTestIdOf(m, row, col.field), className: "min-w-0 truncate leading-5", onPointerEnter: showFullTextOnHover, children: isBadgeColumn(col) ? (_jsx("span", { className: "inline-flex align-middle", children: cardCell(m, row, col) })) : (cardCell(m, row, col)) }) }, col.field))) }) }));
|
|
58
|
+
}
|
|
59
|
+
function renderCardLead(m, row, lead) {
|
|
60
|
+
if (lead === undefined || isEmptyCellValue(row.values[lead.field]))
|
|
61
|
+
return null;
|
|
62
|
+
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, lead.field), className: "min-w-0 text-[13px] leading-5", children: cardCell(m, row, lead) }));
|
|
21
63
|
}
|
|
22
64
|
function renderCardHeading(m, row, roles) {
|
|
23
65
|
const { title: cardTitleColumn, status: cardStatusColumn } = roles;
|
|
@@ -28,5 +70,5 @@ export function renderCardBody(m, row, roles) {
|
|
|
28
70
|
const { image: cardImageColumn, meta: cardMetaColumns } = roles;
|
|
29
71
|
const metaColumns = cardMetaColumns.filter((col) => !isEmptyCellValue(row.values[col.field]) &&
|
|
30
72
|
!isUnlabeledFalse(col.type, row.values[col.field], col.renderer));
|
|
31
|
-
return (_jsxs(_Fragment, { children: [cardImageColumn?.fileDisplay !== undefined && (_jsx("div", { "data-testid": `card-image-${row.id}`, className: "shrink-0", children: _jsx(CardLeadingImage, { value: row.values[cardImageColumn.field], display: cardImageColumn.fileDisplay }) })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [renderCardHeading(m, row, roles), metaColumns.length > 0 && renderCardMeta(m, row, metaColumns)] }), m.rowOpener(row) !== undefined && (_jsx(ChevronRight, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }))] }));
|
|
73
|
+
return (_jsxs(_Fragment, { children: [cardImageColumn?.fileDisplay !== undefined && (_jsx("div", { "data-testid": `card-image-${row.id}`, className: "shrink-0", children: _jsx(CardLeadingImage, { value: row.values[cardImageColumn.field], display: cardImageColumn.fileDisplay }) })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [renderCardLead(m, row, roles.lead), renderCardHeading(m, row, roles), metaColumns.length > 0 && renderCardMeta(m, row, metaColumns)] }), m.rowOpener(row) !== undefined && (_jsx(ChevronRight, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }))] }));
|
|
32
74
|
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { DataTableModel } from "./use-data-table-state.ts";
|
|
2
|
+
type FrameInput = Pick<DataTableModel, "frame" | "belowSm">;
|
|
3
|
+
/** `frame: "card"` from sm: one bordered card around table or card list, summary row and pager. */
|
|
4
|
+
export declare function isInsideCardFrame(m: FrameInput): boolean;
|
|
5
|
+
/** `frame: "card"` below sm: every card of the card layout is bordered and rounded, with a gap. */
|
|
6
|
+
export declare function hasSeparateCardRows(m: FrameInput): boolean;
|
|
7
|
+
export declare const CARD_SURFACE_CLASS = "rounded-lg border border-border bg-card";
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/** `frame: "card"` from sm: one bordered card around table or card list, summary row and pager. */
|
|
2
|
+
export function isInsideCardFrame(m) {
|
|
3
|
+
return m.frame === "card" && !m.belowSm;
|
|
4
|
+
}
|
|
5
|
+
/** `frame: "card"` below sm: every card of the card layout is bordered and rounded, with a gap. */
|
|
6
|
+
export function hasSeparateCardRows(m) {
|
|
7
|
+
return m.frame === "card" && m.belowSm;
|
|
8
|
+
}
|
|
9
|
+
export const CARD_SURFACE_CLASS = "rounded-lg border border-border bg-card";
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Fragment } from "react";
|
|
3
3
|
import { cn } from "../../lib/cn.js";
|
|
4
|
-
import {
|
|
4
|
+
import { cardToneClass } from "../data-table-cell.js";
|
|
5
5
|
import { RowActionsCell } from "../row-actions.js";
|
|
6
|
-
import { renderCardBody } from "./card-body.js";
|
|
6
|
+
import { renderCardBody, renderCardLinks, splitLinkColumns } from "./card-body.js";
|
|
7
|
+
import { CARD_SURFACE_CLASS, hasSeparateCardRows } from "./card-frame.js";
|
|
7
8
|
import { renderExpandToggle, renderExpansion } from "./row-render-parts.js";
|
|
9
|
+
// The card's <li> opens the row on click; controls inside must not reach it.
|
|
10
|
+
function renderStopPropagation(className, testId, children) {
|
|
11
|
+
return (_jsx("div", { className: className, "data-testid": testId, onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), children: children }));
|
|
12
|
+
}
|
|
8
13
|
function renderCardMenu(m, row, menuActions) {
|
|
9
|
-
return (
|
|
14
|
+
return renderStopPropagation("shrink-0", undefined, _jsx(RowActionsCell, { row: row, actions: menuActions, mode: m.rowActionMode, rowIsLink: m.onRowClick !== undefined, compact: true }));
|
|
10
15
|
}
|
|
11
16
|
function renderCardOpenButton(openRow, body) {
|
|
12
17
|
return (_jsx("button", { type: "button", className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 bg-transparent p-0 text-left", onKeyDown: (e) => {
|
|
@@ -17,12 +22,40 @@ function renderCardOpenButton(openRow, body) {
|
|
|
17
22
|
openRow();
|
|
18
23
|
}, children: body }));
|
|
19
24
|
}
|
|
25
|
+
function renderCardButtons(m, row, buttonActions) {
|
|
26
|
+
return renderStopPropagation("flex justify-start", `row-${row.id}-card-buttons`, _jsx(RowActionsCell, { row: row, actions: buttonActions, mode: m.rowActionMode, compact: true, small: true }));
|
|
27
|
+
}
|
|
28
|
+
function cardLeftPadding(compact, toned) {
|
|
29
|
+
if (compact)
|
|
30
|
+
return toned ? "pl-[5px]" : "pl-2";
|
|
31
|
+
return toned ? "pl-[13px]" : "pl-4";
|
|
32
|
+
}
|
|
33
|
+
function cardRowBaseClass(m) {
|
|
34
|
+
return hasSeparateCardRows(m)
|
|
35
|
+
? `flex min-h-[72px] items-center gap-2 py-3 ${CARD_SURFACE_CLASS}`
|
|
36
|
+
: "flex min-h-[72px] items-center gap-2 border-b border-border-row py-3";
|
|
37
|
+
}
|
|
20
38
|
export function renderCard(m, row, roles) {
|
|
21
|
-
const { rowTone
|
|
22
|
-
const
|
|
39
|
+
const { rowTone } = m;
|
|
40
|
+
const allActions = m.menuActions ?? [];
|
|
23
41
|
const openRow = m.rowOpener(row);
|
|
24
|
-
|
|
25
|
-
|
|
42
|
+
// "menu" mode keeps every action in the table's kebab; a phone card opens the row instead,
|
|
43
|
+
// unless the row cannot be opened, then the actions would be unreachable.
|
|
44
|
+
const cardActions = m.rowActionMode === "menu" && openRow !== undefined ? [] : allActions;
|
|
45
|
+
const menuMode = m.rowActionMode === "menu";
|
|
46
|
+
const buttonActions = cardActions.filter((a) => !menuMode &&
|
|
47
|
+
(a.display === "button" || a.display === "link") &&
|
|
48
|
+
(a.isVisible === undefined || a.isVisible(row)));
|
|
49
|
+
const menuActions = cardActions.filter((a) => menuMode || (a.display !== "button" && a.display !== "link"));
|
|
50
|
+
const hasMenu = menuActions.length > 0;
|
|
51
|
+
const hasButtons = buttonActions.length > 0;
|
|
52
|
+
const { bodyRoles, linkColumns } = splitLinkColumns(m, row, roles);
|
|
53
|
+
const body = renderCardBody(m, row, bodyRoles);
|
|
54
|
+
const main = openRow !== undefined ? renderCardOpenButton(openRow, body) : body;
|
|
55
|
+
const toned = cardToneClass(rowTone?.(row)) !== "";
|
|
56
|
+
const rowItem = (_jsxs("li", { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), className: cn(cardRowBaseClass(m), cardToneClass(rowTone?.(row)),
|
|
57
|
+
// The 3px tone border sits inside the box, so the inner padding gives it up to keep the content aligned.
|
|
58
|
+
cardLeftPadding(m.expansion !== undefined || m.selection.active, toned), hasMenu ? "pr-2" : "pr-4", m.density.card), ...(openRow !== undefined && { onClick: openRow }), children: [m.selection.cardCheckbox(row), renderExpandToggle(m, row), linkColumns.length > 0 || hasButtons ? (_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [main, linkColumns.length > 0 && renderCardLinks(m, row, linkColumns), hasButtons && renderCardButtons(m, row, buttonActions)] })) : (main), hasMenu && renderCardMenu(m, row, menuActions)] }, row.id));
|
|
26
59
|
if (m.expansion === undefined)
|
|
27
60
|
return rowItem;
|
|
28
61
|
// The expansion is a sibling <li>, outside the row's click target, so
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
|
-
import type { DataTableSort } from "../../../index.ts";
|
|
2
|
+
import type { DataTableProps, DataTableSort } from "../../../index.ts";
|
|
3
3
|
type SortableColumn = {
|
|
4
4
|
readonly field: string;
|
|
5
5
|
readonly label: string;
|
|
6
6
|
readonly sortable?: boolean;
|
|
7
7
|
};
|
|
8
|
-
|
|
8
|
+
type CardSortSelectProps = {
|
|
9
9
|
readonly columns: readonly SortableColumn[];
|
|
10
10
|
readonly sort: DataTableSort | null | undefined;
|
|
11
11
|
readonly onSortChange: ((next: DataTableSort | null) => void) | undefined;
|
|
12
12
|
readonly testId: string | undefined;
|
|
13
|
+
};
|
|
14
|
+
export declare function CardSortSelect({ sortOptions, summary, ...props }: CardSortSelectProps & {
|
|
15
|
+
readonly sortOptions?: DataTableProps["sortOptions"];
|
|
16
|
+
readonly summary?: string | undefined;
|
|
13
17
|
}): ReactNode;
|
|
14
18
|
export {};
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ArrowDown, ArrowUp } from "lucide-react";
|
|
3
3
|
import { useOptionalTranslation } from "../../../index.js";
|
|
4
|
-
|
|
5
|
-
//
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { hasSortOptionsSelect, SortOptionsSelect } from "./sort-options-select.js";
|
|
5
|
+
// Screen-declared sortOptions replace the per-column entries.
|
|
6
|
+
export function CardSortSelect({ sortOptions, summary, ...props }) {
|
|
7
|
+
const { sort, onSortChange, testId } = props;
|
|
8
|
+
if (onSortChange !== undefined && hasSortOptionsSelect(sortOptions, onSortChange)) {
|
|
9
|
+
return (_jsx(SortOptionsSelect, { options: sortOptions, sort: sort, onSortChange: onSortChange, testId: testId !== undefined ? `${testId}-sort` : "render-list-sort", className: "px-4", chevron: summary === undefined, ...(summary !== undefined && { summary }) }));
|
|
10
|
+
}
|
|
11
|
+
return _jsx(ColumnSortSelect, { ...props });
|
|
12
|
+
}
|
|
13
|
+
function ColumnSortSelect({ columns, sort, onSortChange, testId }) {
|
|
11
14
|
const translate = useOptionalTranslation();
|
|
12
15
|
const sortableColumns = columns.filter((col) => col.sortable);
|
|
13
16
|
if (onSortChange === undefined || sortableColumns.length === 0)
|
|
@@ -1,13 +1,23 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cardColumnRoles } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
3
3
|
import { cn } from "../../lib/cn.js";
|
|
4
|
+
import { hasSeparateCardRows, isInsideCardFrame } from "./card-frame.js";
|
|
4
5
|
import { renderCard } from "./card-row.js";
|
|
5
6
|
import { CardSortSelect } from "./card-sort-select.js";
|
|
6
7
|
import { bandClassName, bandReactKey, bandTestId } from "./group-band.js";
|
|
7
8
|
import { renderBand } from "./row-render-parts.js";
|
|
8
|
-
import {
|
|
9
|
+
import { hasSortOptionsSelect, sortSummaryText } from "./sort-options-select.js";
|
|
10
|
+
import { SummaryCard, TotalsCard } from "./totals-footer.js";
|
|
9
11
|
export function renderCardsView(m) {
|
|
10
12
|
const { testId, totals, columns } = m;
|
|
11
13
|
const roles = cardColumnRoles(columns);
|
|
12
|
-
|
|
14
|
+
// Below sm the card sort line also carries the list size; from sm up the toolbar shows it.
|
|
15
|
+
const toolbarOwnsSort = m.toolbarSort === true && !m.belowSm && hasSortOptionsSelect(m.sortOptions, m.onSortChange);
|
|
16
|
+
const summary = m.belowSm ? sortSummaryText(m) : undefined;
|
|
17
|
+
const separateCards = hasSeparateCardRows(m);
|
|
18
|
+
return (_jsx("div", { "data-testid": testId, className: "contents", children: _jsxs("div", { "data-testid": testId !== undefined ? `${testId}-cards` : "render-list-cards", className: "flex flex-col", children: [!toolbarOwnsSort && (_jsx(CardSortSelect, { columns: columns, sort: m.sort, onSortChange: m.onSortChange, testId: testId, summary: summary, ...(m.sortOptions !== undefined && { sortOptions: m.sortOptions }) })), _jsx("ul", { className: separateCards
|
|
19
|
+
? cn("m-0 flex list-none flex-col gap-2 p-0 pb-2", m.fillsHeight && "px-4")
|
|
20
|
+
: isInsideCardFrame(m)
|
|
21
|
+
? "m-0 list-none p-0"
|
|
22
|
+
: "m-0 list-none border-t border-border-row p-0", children: m.tableItems.map((item) => item.kind === "row" ? (renderCard(m, item.row, roles)) : (_jsx("li", { "data-testid": bandTestId(item), className: cn("border-b border-border-row", bandClassName(item)), children: renderBand(m, item) }, bandReactKey(item)))) }), m.summaryRow !== undefined && !m.belowSm && _jsx(SummaryCard, { summary: m.summaryRow }), totals !== undefined && _jsx(TotalsCard, { totals: totals, columnOf: m.columnOf })] }) }));
|
|
13
23
|
}
|
|
@@ -20,8 +20,15 @@ function PickerRow({ columns, index, label, isLastVisible, onChange }) {
|
|
|
20
20
|
const column = columns[index];
|
|
21
21
|
// Positions are relative to the order at pointer-down, so every move is idempotent.
|
|
22
22
|
const drag = usePointerDrag({
|
|
23
|
-
onStart: () => ({ snapshot: columns, from: index }),
|
|
24
|
-
onMove: (start, { dy }) =>
|
|
23
|
+
onStart: () => ({ snapshot: columns, from: index, lastTarget: index }),
|
|
24
|
+
onMove: (start, { dy }) => {
|
|
25
|
+
const target = start.from + Math.round(dy / ROW_HEIGHT_PX);
|
|
26
|
+
// Each onChange is a storage write plus a table re-render; skip pointer moves that stay on the same row.
|
|
27
|
+
if (target === start.lastTarget)
|
|
28
|
+
return;
|
|
29
|
+
start.lastTarget = target;
|
|
30
|
+
onChange(moveColumn(start.snapshot, start.from, target));
|
|
31
|
+
},
|
|
25
32
|
});
|
|
26
33
|
if (column === undefined)
|
|
27
34
|
return null;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useRef } from "react";
|
|
3
|
-
import { MAX_COLUMN_WIDTH_PX } from "../../../hooks/list-column-layout.js";
|
|
3
|
+
import { clampWidth, MAX_COLUMN_WIDTH_PX } from "../../../hooks/list-column-layout.js";
|
|
4
4
|
import { useOptionalTranslation } from "../../../index.js";
|
|
5
5
|
import { arrowKeyDelta, usePointerDrag } from "../../widgets/use-pointer-drag.js";
|
|
6
6
|
import { EXPAND_COLUMN_WIDTH_PX, SELECT_COLUMN_WIDTH_PX } from "./use-measured-column-widths.js";
|
|
@@ -16,11 +16,10 @@ export function ColumnResizeHandle({ field, label, sizing, }) {
|
|
|
16
16
|
const width = sizing.widthOf(field);
|
|
17
17
|
const minWidth = sizing.minWidthOf(field);
|
|
18
18
|
const draggedWidth = useRef(null);
|
|
19
|
-
const clampToBounds = (value) => Math.min(MAX_COLUMN_WIDTH_PX, Math.max(minWidth, value));
|
|
20
19
|
const drag = usePointerDrag({
|
|
21
20
|
onStart: () => width,
|
|
22
21
|
onMove: (startWidth, { dx }) => {
|
|
23
|
-
const next =
|
|
22
|
+
const next = clampWidth(startWidth + dx, minWidth);
|
|
24
23
|
draggedWidth.current = next;
|
|
25
24
|
sizing.setLiveWidth(field, next);
|
|
26
25
|
},
|
|
@@ -37,7 +36,7 @@ export function ColumnResizeHandle({ field, label, sizing, }) {
|
|
|
37
36
|
if (delta === undefined || delta.dx === 0)
|
|
38
37
|
return;
|
|
39
38
|
event.preventDefault();
|
|
40
|
-
sizing.commit(field,
|
|
39
|
+
sizing.commit(field, clampWidth(width + delta.dx, minWidth));
|
|
41
40
|
};
|
|
42
41
|
return (_jsx("hr", { "aria-orientation": "vertical", "aria-valuenow": Math.round(width), "aria-valuemin": minWidth, "aria-valuemax": MAX_COLUMN_WIDTH_PX,
|
|
43
42
|
// title, not aria-label: getByLabel("<column>") would match a resize handle for every column.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const COLUMN_ROLE_ATTRIBUTE = "data-column-role";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const COLUMN_ROLE_ATTRIBUTE = "data-column-role";
|
|
@@ -4,4 +4,9 @@ export declare function columnCellPresentationProps(col: ListColumnViewModel): {
|
|
|
4
4
|
optionLabels?: Readonly<Record<string, string>> | undefined;
|
|
5
5
|
optionTones?: Readonly<Partial<Record<string, "accent" | "bad" | "critical" | "neutral" | "ok" | "warn">>> | undefined;
|
|
6
6
|
grouping?: boolean | undefined;
|
|
7
|
+
hint?: import("../../../headless/index.ts").ListColumnHintViewModel | undefined;
|
|
8
|
+
display?: import("../../../headless/index.ts").ListColumnCellDisplay | undefined;
|
|
9
|
+
badgeToneField?: string | undefined;
|
|
10
|
+
badgeDot?: false | undefined;
|
|
11
|
+
emptyPlaceholder?: false | undefined;
|
|
7
12
|
};
|
|
@@ -4,5 +4,10 @@ export function columnCellPresentationProps(col) {
|
|
|
4
4
|
...(col.optionLabels !== undefined && { optionLabels: col.optionLabels }),
|
|
5
5
|
...(col.optionTones !== undefined && { optionTones: col.optionTones }),
|
|
6
6
|
...(col.grouping !== undefined && { grouping: col.grouping }),
|
|
7
|
+
...(col.hint !== undefined && { hint: col.hint }),
|
|
8
|
+
...(col.display !== undefined && { display: col.display }),
|
|
9
|
+
...(col.badgeToneField !== undefined && { badgeToneField: col.badgeToneField }),
|
|
10
|
+
...(col.badgeDot !== undefined && { badgeDot: col.badgeDot }),
|
|
11
|
+
...(col.emptyPlaceholder !== undefined && { emptyPlaceholder: col.emptyPlaceholder }),
|
|
7
12
|
};
|
|
8
13
|
}
|
|
@@ -3,6 +3,7 @@ const NO_DENSITY_CLASSES = { row: "", cell: "", header: "", card: "" };
|
|
|
3
3
|
const FILL_EDGE_INSET = " first:pl-6! last:pr-6!";
|
|
4
4
|
const DENSITY_CLASSES = {
|
|
5
5
|
comfortable: NO_DENSITY_CLASSES,
|
|
6
|
+
relaxed: { row: "", cell: "sm:py-3!", header: "", card: "" },
|
|
6
7
|
compact: { row: "h-8", cell: "p-1!", header: "px-1!", card: "min-h-14 py-2" },
|
|
7
8
|
};
|
|
8
9
|
/** Comfortable (and a table without `view`) adds no class at all, so the markup stays as it was. */
|
|
@@ -2,7 +2,8 @@ import type { ReactNode } from "react";
|
|
|
2
2
|
import { type DataTableProps } from "../../../index.ts";
|
|
3
3
|
type FacetClusterProps = Pick<DataTableProps, "filterFacets" | "filterValues" | "onFilterChange" | "onFilterReset" | "dateRangeFacets" | "onDateRangeChange" | "rangeFacets" | "onRangeChange" | "resetAll" | "notice"> & {
|
|
4
4
|
readonly dense: boolean;
|
|
5
|
+
readonly pills: boolean;
|
|
5
6
|
};
|
|
6
7
|
/** The toolbar's filter controls; undefined when the list has none. */
|
|
7
|
-
export declare function buildFacetCluster({ filterFacets, filterValues, onFilterChange, onFilterReset, dateRangeFacets, onDateRangeChange, rangeFacets, onRangeChange, resetAll, notice, dense, }: FacetClusterProps): ReactNode | undefined;
|
|
8
|
+
export declare function buildFacetCluster({ filterFacets, filterValues, onFilterChange, onFilterReset, dateRangeFacets, onDateRangeChange, rangeFacets, onRangeChange, resetAll, notice, dense, pills, }: FacetClusterProps): ReactNode | undefined;
|
|
8
9
|
export {};
|
|
@@ -17,7 +17,7 @@ function FacetResetButton({ onReset }) {
|
|
|
17
17
|
return (_jsxs(UiButton, { variant: "ghost", size: "sm", className: "h-9 px-2", onClick: onReset, "data-testid": "facet-reset", children: [translate?.("kumiko.list.filter.reset") ?? "Reset", _jsx(X, {})] }));
|
|
18
18
|
}
|
|
19
19
|
/** The toolbar's filter controls; undefined when the list has none. */
|
|
20
|
-
export function buildFacetCluster({ filterFacets, filterValues, onFilterChange, onFilterReset, dateRangeFacets, onDateRangeChange, rangeFacets, onRangeChange, resetAll, notice, dense, }) {
|
|
20
|
+
export function buildFacetCluster({ filterFacets, filterValues, onFilterChange, onFilterReset, dateRangeFacets, onDateRangeChange, rangeFacets, onRangeChange, resetAll, notice, dense, pills, }) {
|
|
21
21
|
const hasFacets = filterFacets !== undefined && filterFacets.length > 0 && onFilterChange !== undefined;
|
|
22
22
|
const hasDateRangeFacets = dateRangeFacets !== undefined && dateRangeFacets.length > 0 && onDateRangeChange !== undefined;
|
|
23
23
|
const hasRangeFacets = rangeFacets !== undefined && rangeFacets.length > 0 && onRangeChange !== undefined;
|
|
@@ -31,7 +31,7 @@ export function buildFacetCluster({ filterFacets, filterValues, onFilterChange,
|
|
|
31
31
|
return undefined;
|
|
32
32
|
}
|
|
33
33
|
return (_jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [hasFacets &&
|
|
34
|
-
filterFacets.map((facet) => (_jsx(FacetFilter, { facet: facet, selected: filterValues?.[facet.field] ?? [], onChange: onFilterChange, dense: dense }, facet.field))), hasDateRangeFacets &&
|
|
34
|
+
filterFacets.map((facet) => (_jsx(FacetFilter, { facet: facet, selected: filterValues?.[facet.field] ?? [], onChange: onFilterChange, dense: dense, pill: pills }, facet.field))), hasDateRangeFacets &&
|
|
35
35
|
dateRangeFacets.map((facet) => (_jsx(DateRangeFacetFilter, { facet: facet, onChange: onDateRangeChange }, facet.field))), hasRangeFacets &&
|
|
36
36
|
rangeFacets.map((facet) => (_jsx(NumberRangeFacetFilter, { facet: facet, onChange: onRangeChange }, facet.field))), resetAll === undefined && hasActiveFilters && onFilterReset !== undefined && (_jsx(FacetResetButton, { onReset: onFilterReset })), showsResetAll && _jsx(ResetAllButton, { onReset: resetAll.onReset }), notice !== undefined && _jsx(ListNotice, { notice: notice })] }));
|
|
37
37
|
}
|
|
@@ -49,5 +49,9 @@ export function GroupBand({ item, columnOf, }) {
|
|
|
49
49
|
return (_jsx(ServerGroupHeader, { group: item.group, groupColumn: columnOf(item.owner.field), columnOf: columnOf, onToggle: item.owner.onToggle, onVisible: item.owner.onHeaderVisible }));
|
|
50
50
|
case "groupMore":
|
|
51
51
|
return _jsx(GroupLoadMore, { item: item });
|
|
52
|
+
default: {
|
|
53
|
+
const exhaustiveCheck = item;
|
|
54
|
+
return exhaustiveCheck;
|
|
55
|
+
}
|
|
52
56
|
}
|
|
53
57
|
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
|
+
import type { ListColumnHintViewModel } from "../../../headless/index.ts";
|
|
4
|
+
export declare const HINT_TONE_TEXT_CLASS: Readonly<Record<SelectOptionTone, string>>;
|
|
5
|
+
/** Tone `neutral` dims the sentence like an empty label (muted, not bold); `plainSentence` opts out. */
|
|
6
|
+
export declare function isDimmedHintSentence(tone: SelectOptionTone | undefined, plainSentence: boolean | undefined): boolean;
|
|
7
|
+
export declare const DIMMED_HINT_SENTENCE_CLASS = "font-normal text-muted-foreground";
|
|
8
|
+
/** "To do" cell: an emphasized sentence in the row tone with an optional muted second line. */
|
|
9
|
+
export declare function HintCell({ value, row, hint, onOpen, leading, }: {
|
|
10
|
+
readonly value: unknown;
|
|
11
|
+
readonly row: Readonly<Record<string, unknown>>;
|
|
12
|
+
readonly hint: ListColumnHintViewModel;
|
|
13
|
+
/** Drawn in front of the sentence on its line (a badge or tone dot); the detail line starts below it, at the left edge. */
|
|
14
|
+
readonly leading?: ReactNode;
|
|
15
|
+
readonly onOpen?: () => void;
|
|
16
|
+
}): ReactNode;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useId, useState } from "react";
|
|
3
|
+
import { isSelectOptionTone } from "../../../status-tone.js";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
import { hintReasonOf, nonEmptyText, useHintReasonRowControl } from "../hint-reason-row.js";
|
|
6
|
+
import { ReasonBox, ReasonInfoButton } from "../reason-box.js";
|
|
7
|
+
export const HINT_TONE_TEXT_CLASS = {
|
|
8
|
+
bad: "text-status-bad",
|
|
9
|
+
warn: "text-status-warn",
|
|
10
|
+
critical: "text-status-critical",
|
|
11
|
+
ok: "text-status-ok",
|
|
12
|
+
accent: "text-primary",
|
|
13
|
+
neutral: "",
|
|
14
|
+
};
|
|
15
|
+
/** Tone `neutral` dims the sentence like an empty label (muted, not bold); `plainSentence` opts out. */
|
|
16
|
+
export function isDimmedHintSentence(tone, plainSentence) {
|
|
17
|
+
return tone === "neutral" && plainSentence !== true;
|
|
18
|
+
}
|
|
19
|
+
export const DIMMED_HINT_SENTENCE_CLASS = "font-normal text-muted-foreground";
|
|
20
|
+
const OPEN_SENTENCE_CLASS = "min-w-0 cursor-pointer bg-transparent p-0 text-left font-medium hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring";
|
|
21
|
+
function SentenceText({ text, className, onOpen, }) {
|
|
22
|
+
if (onOpen === undefined)
|
|
23
|
+
return _jsx("span", { className: className, children: text });
|
|
24
|
+
return (_jsx("button", { type: "button", className: cn(OPEN_SENTENCE_CLASS, className), onClick: (event) => {
|
|
25
|
+
event.stopPropagation();
|
|
26
|
+
onOpen();
|
|
27
|
+
}, onKeyDown: (event) => {
|
|
28
|
+
if (event.key !== "Enter")
|
|
29
|
+
return;
|
|
30
|
+
event.preventDefault();
|
|
31
|
+
event.stopPropagation();
|
|
32
|
+
onOpen();
|
|
33
|
+
}, children: text }));
|
|
34
|
+
}
|
|
35
|
+
// Without a sentence the empty label is the only element of the first cell, so it must stay
|
|
36
|
+
// the keyboard opener of a clickable row.
|
|
37
|
+
function EmptyHint({ label, onOpen, }) {
|
|
38
|
+
if (onOpen === undefined) {
|
|
39
|
+
return (_jsx("span", { "data-hint-empty": "true", className: "text-muted-foreground", children: label }));
|
|
40
|
+
}
|
|
41
|
+
return (_jsx("button", { type: "button", "data-hint-empty": "true", className: cn(OPEN_SENTENCE_CLASS, DIMMED_HINT_SENTENCE_CLASS), onClick: (event) => {
|
|
42
|
+
event.stopPropagation();
|
|
43
|
+
onOpen();
|
|
44
|
+
}, children: label }));
|
|
45
|
+
}
|
|
46
|
+
function useHintReason(hint, row) {
|
|
47
|
+
const [ownOpen, setOwnOpen] = useState(false);
|
|
48
|
+
const ownBoxId = useId();
|
|
49
|
+
const rowReason = useHintReasonRowControl(hint);
|
|
50
|
+
return {
|
|
51
|
+
reason: hintReasonOf(hint, row),
|
|
52
|
+
reasonOpen: rowReason?.open ?? ownOpen,
|
|
53
|
+
toggleReason: rowReason?.onToggle ?? (() => setOwnOpen((open) => !open)),
|
|
54
|
+
boxInRow: rowReason !== undefined,
|
|
55
|
+
boxId: rowReason?.boxId ?? ownBoxId,
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
function hintSentenceClass(tone, plainSentence) {
|
|
59
|
+
if (isDimmedHintSentence(tone, plainSentence))
|
|
60
|
+
return DIMMED_HINT_SENTENCE_CLASS;
|
|
61
|
+
return cn("font-medium", plainSentence !== true && tone !== undefined && HINT_TONE_TEXT_CLASS[tone]);
|
|
62
|
+
}
|
|
63
|
+
/** "To do" cell: an emphasized sentence in the row tone with an optional muted second line. */
|
|
64
|
+
export function HintCell({ value, row, hint, onOpen, leading, }) {
|
|
65
|
+
const { reason, reasonOpen, toggleReason, boxInRow, boxId } = useHintReason(hint, row);
|
|
66
|
+
const sentence = nonEmptyText(value);
|
|
67
|
+
if (sentence === undefined)
|
|
68
|
+
return _jsx(EmptyHint, { label: hint.emptyLabel, onOpen: onOpen });
|
|
69
|
+
const toneValue = hint.toneField === undefined ? undefined : row[hint.toneField];
|
|
70
|
+
const tone = isSelectOptionTone(toneValue) ? toneValue : undefined;
|
|
71
|
+
const detail = hint.detailField === undefined ? undefined : nonEmptyText(row[hint.detailField]);
|
|
72
|
+
const sentenceClass = hintSentenceClass(tone, hint.plainSentence);
|
|
73
|
+
return (_jsxs("span", { "data-hint-tone": tone, className: "flex min-w-0 flex-col gap-0.5", children: [_jsxs("span", { className: "flex items-start gap-2", children: [leading !== undefined && (_jsx("span", { className: "flex h-[1lh] shrink-0 items-center", children: leading })), _jsx(SentenceText, { text: sentence, className: sentenceClass, onOpen: onOpen }), reason !== undefined && (_jsx(ReasonInfoButton, { label: hint.reasonLabel, open: reasonOpen, onToggle: toggleReason, controls: boxId, "data-hint-reason-toggle": "true" }))] }), detail !== undefined && _jsx("small", { className: "text-xs text-muted-foreground", children: detail }), reason !== undefined && reasonOpen && !boxInRow && (_jsx(ReasonBox, { id: boxId, "data-hint-reason": "true", ...(reason.title !== undefined && { title: reason.title }), children: reason.text }))] }));
|
|
74
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
// A hint column states its width itself; the resizing layout already owns widths through <col>.
|
|
2
|
+
export function hintColumnWidthStyle(col, resizing) {
|
|
3
|
+
if (resizing || col.hint === undefined)
|
|
4
|
+
return undefined;
|
|
5
|
+
if (col.width === undefined && col.minWidth === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
return {
|
|
8
|
+
...(col.width !== undefined && { width: col.width }),
|
|
9
|
+
...(col.minWidth !== undefined && { minWidth: col.minWidth }),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { isListAggregateCurrencyAmounts } from "@cosmicdrift/kumiko-types/list-aggregate-types";
|
|
3
|
+
import { toMajorUnits } from "@cosmicdrift/kumiko-types/minor-units";
|
|
3
4
|
import { useOptionalLocale, useOptionalTranslation } from "../../../index.js";
|
|
4
5
|
import { DataTableCell } from "../data-table-cell.js";
|
|
5
|
-
// Money measures arrive in the storage scale (minor units, ×100), one entry per currency.
|
|
6
|
-
const MONEY_STORAGE_SCALE = 100;
|
|
7
6
|
const NO_ROW = {};
|
|
8
7
|
function cellTypeOf(measure, column) {
|
|
9
8
|
return measure.kind === "count" ? "number" : (column?.type ?? "number");
|
|
@@ -24,5 +23,5 @@ export function MeasureValue({ measure, column, }) {
|
|
|
24
23
|
const { value } = measure;
|
|
25
24
|
if (!isListAggregateCurrencyAmounts(value))
|
|
26
25
|
return cell(value, measure.kind);
|
|
27
|
-
return (_jsx("span", { className: "inline-flex flex-col items-end", children: value.map((entry) => cell({ amount: entry.value
|
|
26
|
+
return (_jsx("span", { className: "inline-flex flex-col items-end", children: value.map((entry) => cell({ amount: toMajorUnits(entry.value), currency: entry.currency }, entry.currency)) }));
|
|
28
27
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
import type { DataTableProps, DataTableSort } from "../../../index.ts";
|
|
3
|
+
import type { DataTableModel } from "./use-data-table-state.ts";
|
|
4
|
+
type SortOptions = NonNullable<DataTableProps["sortOptions"]>;
|
|
5
|
+
export declare function sortOptionValue(option: DataTableSort): string;
|
|
6
|
+
export declare function activeSortOption(options: SortOptions, sort: DataTableSort | null | undefined): SortOptions[number] | undefined;
|
|
7
|
+
export declare function hasSortOptionsSelect(options: DataTableProps["sortOptions"], onSortChange: DataTableProps["onSortChange"]): options is SortOptions;
|
|
8
|
+
export declare function sortSummaryText(m: DataTableModel): string | undefined;
|
|
9
|
+
export declare function SortOptionsSelect({ options, sort, onSortChange, testId, className, summary, bordered, chevron, }: {
|
|
10
|
+
readonly options: SortOptions;
|
|
11
|
+
readonly sort: DataTableSort | null | undefined;
|
|
12
|
+
readonly onSortChange: (next: DataTableSort | null) => void;
|
|
13
|
+
readonly testId: string;
|
|
14
|
+
readonly className?: string;
|
|
15
|
+
/** Replaces the label text, e.g. with the sentence that also names the list size. */
|
|
16
|
+
readonly summary?: string;
|
|
17
|
+
/** Draws the select like the filter-row selects: bordered, same height. */
|
|
18
|
+
readonly bordered?: boolean;
|
|
19
|
+
/** `false` leaves the trailing chevron out, so a summary sentence reads as plain text. */
|
|
20
|
+
readonly chevron?: boolean;
|
|
21
|
+
}): ReactNode;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { ChevronDown } from "lucide-react";
|
|
3
|
+
import { useOptionalTranslation } from "../../../index.js";
|
|
4
|
+
import { cn } from "../../lib/cn.js";
|
|
5
|
+
export function sortOptionValue(option) {
|
|
6
|
+
return `${option.field}:${option.dir}`;
|
|
7
|
+
}
|
|
8
|
+
export function activeSortOption(options, sort) {
|
|
9
|
+
if (sort === undefined || sort === null)
|
|
10
|
+
return undefined;
|
|
11
|
+
return options.find((option) => option.field === sort.field && option.dir === sort.dir);
|
|
12
|
+
}
|
|
13
|
+
export function hasSortOptionsSelect(options, onSortChange) {
|
|
14
|
+
return onSortChange !== undefined && options !== undefined && options.length > 0;
|
|
15
|
+
}
|
|
16
|
+
// "Sorted by Urgency ↓ · 26 contracts": one sentence with the order and the size of the list.
|
|
17
|
+
// Undefined while no sort option is active, so the plain label stays.
|
|
18
|
+
export function sortSummaryText(m) {
|
|
19
|
+
if (m.sortOptions === undefined)
|
|
20
|
+
return undefined;
|
|
21
|
+
const active = activeSortOption(m.sortOptions, m.sort);
|
|
22
|
+
if (active === undefined)
|
|
23
|
+
return undefined;
|
|
24
|
+
const total = m.pager?.total ?? m.rows.length;
|
|
25
|
+
const noun = m.itemNoun?.(total) ?? "";
|
|
26
|
+
const direction = active.dir === "asc" ? "↑" : "↓";
|
|
27
|
+
const count = total.toLocaleString();
|
|
28
|
+
return (m.tableTranslate?.("kumiko.list.sort.summary", {
|
|
29
|
+
sort: active.label,
|
|
30
|
+
direction,
|
|
31
|
+
count,
|
|
32
|
+
noun,
|
|
33
|
+
}) ?? `Sorted by ${active.label} ${direction} · ${count} ${noun}`).trim();
|
|
34
|
+
}
|
|
35
|
+
// "Sorted by: <active label>" over a native select; with no matching option only the prefix shows
|
|
36
|
+
// so the control never claims an order the list is not in.
|
|
37
|
+
export function SortOptionsSelect({ options, sort, onSortChange, testId, className, summary, bordered = false, chevron = true, }) {
|
|
38
|
+
const translate = useOptionalTranslation();
|
|
39
|
+
const active = activeSortOption(options, sort);
|
|
40
|
+
const prefix = translate?.("kumiko.list.sort.prefix") ?? "Sorted by";
|
|
41
|
+
return (_jsxs("div", { className: cn("relative flex h-9 items-center gap-1.5 rounded-md text-[13px] text-foreground-secondary focus-within:ring-1 focus-within:ring-ring", bordered && "rounded-md border border-border-strong bg-background px-2.5 text-foreground", className), children: [_jsx("span", { "aria-hidden": "true", "data-testid": `${testId}-label`, children: summary ?? (active !== undefined ? `${prefix}: ${active.label}` : prefix) }), chevron && _jsx(ChevronDown, { className: "size-3.5", "aria-hidden": "true" }), _jsxs("select", { "aria-label": prefix, "data-testid": testId, value: active !== undefined ? sortOptionValue(active) : "", onChange: (e) => {
|
|
42
|
+
const picked = options.find((option) => sortOptionValue(option) === e.target.value);
|
|
43
|
+
if (picked !== undefined)
|
|
44
|
+
onSortChange({ field: picked.field, dir: picked.dir });
|
|
45
|
+
}, className: "absolute inset-0 size-full cursor-pointer opacity-0", children: [active === undefined && _jsx("option", { value: "", children: prefix }), options.map((option) => (_jsx("option", { value: sortOptionValue(option), children: option.label }, sortOptionValue(option))))] })] }));
|
|
46
|
+
}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
2
|
import type { DataTableSort } from "../../../index.ts";
|
|
3
3
|
export declare const COMPACT_HEADER_CLASS = "text-xs font-semibold";
|
|
4
|
-
export declare function SortableHeader({ field, label, sortable, highlighted, numeric, fitContent, compact, className, sort, onSortChange, style, columnField, trailing, }: {
|
|
4
|
+
export declare function SortableHeader({ field, label, sortable, highlighted, numeric, actionColumn, fitContent, compact, className, sort, onSortChange, style, columnField, trailing, }: {
|
|
5
5
|
readonly field: string;
|
|
6
6
|
readonly label: string;
|
|
7
7
|
readonly sortable: boolean;
|
|
8
8
|
readonly highlighted?: boolean;
|
|
9
9
|
readonly numeric?: boolean;
|
|
10
|
+
/** Per-row action column: from sm right-aligned and without visible header text. */
|
|
11
|
+
readonly actionColumn?: boolean;
|
|
10
12
|
readonly fitContent?: boolean;
|
|
11
13
|
readonly compact?: boolean;
|
|
12
14
|
readonly className?: string;
|