@cosmicdrift/kumiko-renderer 0.416.0 → 0.418.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-body.d.ts +1 -4
- package/dist/app/action-form-body.js +14 -9
- package/dist/app/action-form-preview.d.ts +13 -0
- package/dist/app/action-form-preview.js +66 -0
- package/dist/app/action-form-support.d.ts +6 -1
- package/dist/app/action-form-support.js +26 -9
- package/dist/app/config-edit-body.js +71 -79
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/header-actions-bar.d.ts +3 -1
- package/dist/app/header-actions-bar.js +12 -4
- package/dist/app/list-bulk-actions.d.ts +8 -1
- package/dist/app/list-bulk-actions.js +28 -4
- package/dist/app/locked-screen-header.d.ts +2 -0
- package/dist/app/locked-screen-header.js +8 -1
- package/dist/app/projection-detail-body.js +24 -5
- package/dist/app/projection-detail-guidance.d.ts +1 -0
- package/dist/app/projection-detail-guidance.js +7 -4
- package/dist/app/projection-detail-header-model.js +4 -1
- package/dist/app/projection-detail-header-region.js +25 -9
- package/dist/app/projection-detail-header.d.ts +2 -0
- package/dist/app/projection-detail-header.js +30 -3
- package/dist/app/projection-list-shim.js +1 -0
- package/dist/app/row-actions.d.ts +4 -0
- package/dist/app/row-actions.js +19 -3
- package/dist/app/use-projection-detail-actions.d.ts +3 -1
- package/dist/app/use-projection-detail-actions.js +9 -1
- package/dist/app/use-projection-detail-data.js +17 -1
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/choice-chip-class.d.ts +1 -0
- package/dist/components/choice-chip-class.js +9 -0
- package/dist/components/edit-mounts.d.ts +1 -1
- package/dist/components/embedded-list-paste.js +2 -2
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.js +7 -2
- package/dist/components/multi-select-count.d.ts +5 -0
- package/dist/components/multi-select-count.js +10 -0
- package/dist/components/narrow-description.d.ts +3 -0
- package/dist/components/narrow-description.js +12 -0
- package/dist/components/related-list-section.d.ts +5 -3
- package/dist/components/related-list-section.js +9 -4
- package/dist/components/related-photo-grid.js +17 -3
- package/dist/components/render-edit-field-grid.d.ts +12 -3
- package/dist/components/render-edit-field-grid.js +60 -18
- package/dist/components/render-edit-fields-section.js +45 -11
- package/dist/components/render-edit-header-actions.js +1 -1
- package/dist/components/render-edit-layout.js +5 -3
- package/dist/components/render-edit-section-kinds.js +50 -12
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +26 -7
- package/dist/components/render-field-choice-inputs.js +3 -0
- package/dist/components/render-field-control.js +1 -1
- package/dist/components/render-field-value-chips.js +6 -4
- package/dist/components/render-field-values.js +3 -3
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +30 -5
- package/dist/components/render-list-reference-columns.js +2 -4
- package/dist/components/render-list-row-tone.d.ts +2 -0
- package/dist/components/render-list-row-tone.js +6 -0
- package/dist/components/render-list-table-props.d.ts +13 -2
- package/dist/components/render-list-table-props.js +9 -3
- package/dist/components/render-list-types.d.ts +4 -0
- package/dist/components/render-list.js +12 -4
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/components/write-form-registry.d.ts +13 -0
- package/dist/components/write-form-registry.js +6 -0
- package/dist/components/write-form-section.d.ts +5 -1
- package/dist/components/write-form-section.js +55 -16
- package/dist/data-table-bulk-types.d.ts +11 -2
- package/dist/data-table-bulk-types.js +3 -1
- package/dist/headless/form/form-controller.d.ts +2 -0
- package/dist/headless/form/form-controller.js +2 -2
- package/dist/headless/format/index.d.ts +1 -1
- package/dist/headless/format/index.js +6 -5
- package/dist/headless/format/money.d.ts +5 -0
- package/dist/headless/format/money.js +10 -0
- package/dist/headless/format/relative-time.d.ts +2 -0
- package/dist/headless/format/relative-time.js +4 -1
- package/dist/headless/index.d.ts +1 -1
- package/dist/headless/index.js +1 -1
- package/dist/headless/view-model/edit.js +87 -37
- package/dist/headless/view-model/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +50 -5
- package/dist/hooks/use-bulk-run.d.ts +2 -2
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +8 -2
- package/dist/primitives-record-guidance.d.ts +4 -0
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +34 -83
- package/dist/web/app/bold-markup.d.ts +3 -0
- package/dist/web/app/bold-markup.js +14 -0
- package/dist/web/app/dashboard-body.js +5 -1
- package/dist/web/app/dashboard-list-panel.js +7 -4
- package/dist/web/app/dashboard-panels.js +31 -3
- package/dist/web/app/dashboard-shared.d.ts +3 -1
- package/dist/web/app/dashboard-shared.js +3 -3
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +16 -2
- package/dist/web/app/dashboard-text-panel.js +11 -6
- package/dist/web/app/relative-time.js +10 -1
- package/dist/web/components/config-cascade.d.ts +2 -1
- package/dist/web/components/config-cascade.js +16 -4
- package/dist/web/drawn-icons.js +2 -1
- package/dist/web/layout/header-action-pinned.d.ts +4 -2
- package/dist/web/layout/header-action-pinned.js +13 -4
- package/dist/web/layout/header-overflow-menu.d.ts +2 -0
- package/dist/web/layout/header-overflow-menu.js +2 -0
- package/dist/web/layout/nav-tree.js +1 -1
- package/dist/web/layout/notification-bell.js +13 -4
- 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.js +4 -1
- package/dist/web/layout/shell-header.js +15 -7
- package/dist/web/primitives/banner.js +14 -3
- package/dist/web/primitives/card.js +5 -3
- package/dist/web/primitives/combobox.js +2 -2
- package/dist/web/primitives/data-table/actions-column.js +1 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +37 -14
- package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
- package/dist/web/primitives/data-table/card-frame.js +3 -0
- package/dist/web/primitives/data-table/card-row.js +28 -9
- package/dist/web/primitives/data-table/card-sort-select.js +1 -1
- package/dist/web/primitives/data-table/card-view.js +1 -1
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -1
- package/dist/web/primitives/data-table/data-cell-props.js +1 -0
- package/dist/web/primitives/data-table/density.d.ts +3 -1
- package/dist/web/primitives/data-table/density.js +11 -4
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -5
- package/dist/web/primitives/data-table/sort-options-select.js +2 -2
- package/dist/web/primitives/data-table/sortable-header.js +4 -4
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +7 -11
- package/dist/web/primitives/data-table/table-data-cell.js +31 -17
- package/dist/web/primitives/data-table/table-header-row.js +1 -1
- package/dist/web/primitives/data-table/table-view.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +6 -7
- package/dist/web/primitives/data-table/use-bulk-selection.d.ts +1 -1
- package/dist/web/primitives/data-table/use-bulk-selection.js +5 -0
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
- package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
- package/dist/web/primitives/data-table-cell.d.ts +13 -2
- package/dist/web/primitives/data-table-cell.js +125 -53
- package/dist/web/primitives/data-table.js +1 -1
- package/dist/web/primitives/default-form.d.ts +1 -1
- package/dist/web/primitives/default-form.js +11 -10
- package/dist/web/primitives/drawer.js +2 -7
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +2 -5
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
- package/dist/web/primitives/facet-trigger-label.js +4 -7
- package/dist/web/primitives/field.js +15 -8
- package/dist/web/primitives/form-footer-parts.js +2 -2
- package/dist/web/primitives/inline-suffix.d.ts +2 -0
- package/dist/web/primitives/inline-suffix.js +5 -0
- package/dist/web/primitives/input-choice-kinds.js +12 -2
- package/dist/web/primitives/input-number-kinds.js +2 -2
- package/dist/web/primitives/input-text-kinds.js +1 -1
- package/dist/web/primitives/layout-elements.d.ts +4 -4
- package/dist/web/primitives/layout-elements.js +49 -12
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- package/dist/web/primitives/metric.js +4 -5
- package/dist/web/primitives/money-input.js +8 -7
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +9 -4
- 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 +12 -21
- package/dist/web/primitives/photo-grid.js +2 -1
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +6 -15
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/use-container-narrow.d.ts +12 -0
- package/dist/web/primitives/use-container-narrow.js +42 -0
- package/dist/web/pwa/pwa-support.js +13 -7
- package/dist/web/ui/input.js +1 -1
- package/dist/web/ui/textarea.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.js +6 -3
- package/dist/web/widgets/dashboard-list.d.ts +4 -1
- package/dist/web/widgets/dashboard-list.js +10 -5
- package/dist/web/widgets/progress-list.js +1 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +51 -0
- package/src/web/styles.css +3 -2
|
@@ -5,16 +5,9 @@ import { cellLinkProp, cellTitle, DataTableCell, FIT_CONTENT_CELL_CLASS, FirstCe
|
|
|
5
5
|
import { columnCellPresentationProps } from "./data-cell-props.js";
|
|
6
6
|
import { hintColumnWidthStyle } from "./hint-column-width.js";
|
|
7
7
|
import { isRowActionColumn } from "./row-action-column.js";
|
|
8
|
-
//
|
|
9
|
-
//
|
|
10
|
-
//
|
|
11
|
-
// nothing visibly cut off. max-w-xs bounds a single column;
|
|
12
|
-
// badges and dates stay nowrap by their own classes.
|
|
13
|
-
// A resizable table sizes by content until the user drags a column. Its
|
|
14
|
-
// first column names the row and gets the room it needs: it breaks anywhere
|
|
15
|
-
// only when the table runs out of width, so a long identifier stays on one
|
|
16
|
-
// line on a wide screen instead of wrapping at 20rem. Dates and timestamps
|
|
17
|
-
// keep one line there too; a narrow screen scrolls the table sideways.
|
|
8
|
+
// Cells stay on one line and end in "…" when the text does not fit (the full text is the
|
|
9
|
+
// cell's `title`); max-w-* bounds a column in the auto layout, where truncation needs a width.
|
|
10
|
+
// Hint cells wrap: their sentence and detail line are the row's content.
|
|
18
11
|
const ONE_LINE_COLUMN_TYPES = new Set(["timestamp", "date"]);
|
|
19
12
|
// Projection lists synthesize every column as type "text"; their dates carry a format spec.
|
|
20
13
|
function isDateColumn(col) {
|
|
@@ -30,26 +23,47 @@ function isDateColumn(col) {
|
|
|
30
23
|
function autoLayoutCellClassName(m, col, colIndex) {
|
|
31
24
|
if (m.sizing !== undefined && isDateColumn(col))
|
|
32
25
|
return "whitespace-nowrap";
|
|
26
|
+
if (col.multiline === true)
|
|
27
|
+
return "max-w-md whitespace-pre-line break-words";
|
|
33
28
|
// max-w-xs would cap a hint column that states a wider width.
|
|
34
29
|
if (col.hint !== undefined && col.width !== undefined)
|
|
35
30
|
return "whitespace-normal break-words";
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
31
|
+
if (col.hint !== undefined)
|
|
32
|
+
return "max-w-xs whitespace-normal break-words";
|
|
33
|
+
return colIndex === 0 ? "max-w-md truncate" : "max-w-xs truncate";
|
|
39
34
|
}
|
|
40
|
-
function
|
|
35
|
+
function fixedLayoutCellClassName(col) {
|
|
36
|
+
return col.hint !== undefined || col.multiline === true
|
|
37
|
+
? "overflow-hidden whitespace-normal break-words"
|
|
38
|
+
: "overflow-hidden truncate";
|
|
39
|
+
}
|
|
40
|
+
function dataCellClassName(m, row, col, colIndex, pinClassName) {
|
|
41
41
|
return cn(col.fileDisplay === undefined
|
|
42
42
|
? m.sizing?.fixed === true
|
|
43
|
-
?
|
|
43
|
+
? fixedLayoutCellClassName(col)
|
|
44
44
|
: autoLayoutCellClassName(m, col, colIndex)
|
|
45
|
-
: FIT_CONTENT_CELL_CLASS, colIndex ===
|
|
45
|
+
: FIT_CONTENT_CELL_CLASS, "px-3 first:pl-6 last:pr-[34px]", cellTextClass(m, row, col, colIndex), col.ellipsis === true && "truncate", col.multiline === true && "whitespace-pre-line", NUMERIC_COLUMN_TYPES.has(col.type) && "text-right", isRowActionColumn(col) && "sm:text-right", TABULAR_COLUMN_TYPES.has(col.type) && "tabular-nums", col.highlighted === true && "bg-accent/40", m.density.cell, m.density.cellHeight, pinClassName);
|
|
46
|
+
}
|
|
47
|
+
function isMutedRow(m, row) {
|
|
48
|
+
return m.rowMuted?.(row) === true;
|
|
49
|
+
}
|
|
50
|
+
function cellTextClass(m, row, col, colIndex) {
|
|
51
|
+
if (col.tone === "muted")
|
|
52
|
+
return "text-muted-foreground";
|
|
53
|
+
if (col.emphasis === true)
|
|
54
|
+
return "font-semibold text-foreground";
|
|
55
|
+
if (isMutedRow(m, row))
|
|
56
|
+
return "text-muted-foreground";
|
|
57
|
+
if (colIndex === 0 && !m.hasEmphasisColumn)
|
|
58
|
+
return "font-medium text-foreground";
|
|
59
|
+
return "text-foreground";
|
|
46
60
|
}
|
|
47
61
|
export function renderDataCell(m, row, col, colIndex, opensOnClick) {
|
|
48
62
|
const { getCellTestId, onCellChange, onRowClick, tableTranslate, tableLocale } = m;
|
|
49
63
|
const bodyPin = m.pins.bodyCell(col.field);
|
|
50
64
|
const linksFirstCell = colIndex === 0 && opensOnClick && onCellChange === undefined;
|
|
51
65
|
const wrapsCellInOpener = linksFirstCell && col.hint === undefined;
|
|
52
|
-
return (_jsx(TableCell, { "data-testid": getCellTestId?.(row, col.field) ?? `cell-${row.id}-${col.field}`, "data-highlighted": col.highlighted === true ? "true" : undefined, className: dataCellClassName(m, col, colIndex, bodyPin.className), style: { ...bodyPin.style, ...hintColumnWidthStyle(col, m.sizing !== undefined) }, title: cellTitle(row.values[col.field]), children: _jsx(FirstCellLink, { enabled: wrapsCellInOpener, onOpen: () => onRowClick?.(row), empty: col.hint === undefined && isEmptyCellValue(row.values[col.field]), emptyLabel: m.rowClickLabel, children: _jsx(DataTableCell, { value: row.values[col.field], row: row.values, field: col.field, type: col.type, renderer: col.renderer, translate: tableTranslate, locale: tableLocale, ...columnCellPresentationProps(col), ...(col.fileDisplay !== undefined && {
|
|
66
|
+
return (_jsx(TableCell, { "data-testid": getCellTestId?.(row, col.field) ?? `cell-${row.id}-${col.field}`, "data-highlighted": col.highlighted === true ? "true" : undefined, className: dataCellClassName(m, row, col, colIndex, bodyPin.className), style: { ...bodyPin.style, ...hintColumnWidthStyle(col, m.sizing !== undefined) }, title: cellTitle(row.values[col.field]), children: _jsx(FirstCellLink, { enabled: wrapsCellInOpener, onOpen: () => onRowClick?.(row), empty: col.hint === undefined && isEmptyCellValue(row.values[col.field]), emptyLabel: m.rowClickLabel, emptyPlaceholder: col.emptyPlaceholder, children: _jsx(DataTableCell, { value: row.values[col.field], row: row.values, field: col.field, type: col.type, renderer: col.renderer, translate: tableTranslate, locale: tableLocale, ...columnCellPresentationProps(col), ...(col.fileDisplay !== undefined && {
|
|
53
67
|
fileDisplay: col.fileDisplay,
|
|
54
68
|
}), ...(onCellChange !== undefined && {
|
|
55
69
|
onChange: (value) => onCellChange(row.id, col.field, value),
|
|
@@ -20,5 +20,5 @@ function renderExpandHeaderCell(m) {
|
|
|
20
20
|
return (_jsx(TableHead, { "data-testid": "column-expand", [COLUMN_ROLE_ATTRIBUTE]: "expand", className: cn(EXPAND_TOGGLE_CELL_CLASS, expandHeaderPin.className), style: expandHeaderPin.style }));
|
|
21
21
|
}
|
|
22
22
|
export function renderTableHeader(m) {
|
|
23
|
-
return (_jsx(TableHeader, { className: "bg-
|
|
23
|
+
return (_jsx(TableHeader, { className: "bg-background", children: _jsxs(TableRow, { ref: m.headerRowRef, className: "hover:bg-transparent", children: [m.selection.headerCell(m.pins.headerCell(SELECT_COLUMN_KEY)), m.expansion !== undefined && renderExpandHeaderCell(m), m.columns.map((col) => renderColumnHeader(m, col)), m.hasTableActions && (_jsx(ActionsHeaderCell, { label: m.tableTranslate?.("kumiko.list.actions") ?? "Actions", style: m.pins.actionsHeaderStyle, absorbsLeftover: m.sizing?.fixed === true }))] }) }));
|
|
24
24
|
}
|
|
@@ -35,7 +35,7 @@ function renderTableFooter(m) {
|
|
|
35
35
|
}
|
|
36
36
|
// A framed list that is empty keeps its header row; the empty state fills one spanning row below it.
|
|
37
37
|
function renderEmptyBody(m) {
|
|
38
|
-
return (_jsx(TableBody, { children: _jsx(TableRow, { className: "hover:bg-transparent", children: _jsx(TableCell, { colSpan: m.fullColSpan, className: "p-0", children: renderEmptyBlock(m
|
|
38
|
+
return (_jsx(TableBody, { children: _jsx(TableRow, { className: "hover:bg-transparent", children: _jsx(TableCell, { colSpan: m.fullColSpan, className: "p-0", children: renderEmptyBlock(m) }) }) }));
|
|
39
39
|
}
|
|
40
40
|
export function renderTableView(m) {
|
|
41
41
|
const { fillsHeight, chromeless, sizing, testId } = m;
|
|
@@ -51,11 +51,10 @@ export function hasToolbarContent(m, facetCluster) {
|
|
|
51
51
|
hasVisibleSortOptions(m) ||
|
|
52
52
|
toolbarEndHasContent(m.view, m.exportList, m.toolbarEnd));
|
|
53
53
|
}
|
|
54
|
-
//
|
|
55
|
-
//
|
|
54
|
+
// Desktop sorts through the column headers; the toolbar select is an opt-in (`toolbarSort`),
|
|
55
|
+
// and below sm the card sort bar owns sorting.
|
|
56
56
|
function hasVisibleSortOptions(m) {
|
|
57
|
-
return (
|
|
58
|
-
hasSortOptionsSelect(m.sortOptions, m.onSortChange));
|
|
57
|
+
return (m.toolbarSort === true && !m.belowSm && hasSortOptionsSelect(m.sortOptions, m.onSortChange));
|
|
59
58
|
}
|
|
60
59
|
function toolbarClassName({ fillsHeight, isNarrow }) {
|
|
61
60
|
if (!fillsHeight)
|
|
@@ -85,10 +84,10 @@ export function toolbarMergesDescription(m, facetCluster) {
|
|
|
85
84
|
}
|
|
86
85
|
function renderSortOptions(m) {
|
|
87
86
|
const { sortOptions, onSortChange, testId } = m;
|
|
88
|
-
if (onSortChange === undefined || !
|
|
87
|
+
if (onSortChange === undefined || !hasVisibleSortOptions(m) || sortOptions === undefined) {
|
|
89
88
|
return null;
|
|
90
89
|
}
|
|
91
|
-
return (_jsx(SortOptionsSelect, { options: sortOptions, sort: m.sort, onSortChange: onSortChange, testId: testId !== undefined ? `${testId}-sort-options` : "render-list-sort-options",
|
|
90
|
+
return (_jsx(SortOptionsSelect, { options: sortOptions, sort: m.sort, onSortChange: onSortChange, testId: testId !== undefined ? `${testId}-sort-options` : "render-list-sort-options", bordered: true }));
|
|
92
91
|
}
|
|
93
92
|
function hasOnlySelectFacets(m) {
|
|
94
93
|
return ((m.filterFacets ?? []).some((facet) => !isBehindFilter(m, facet)) &&
|
|
@@ -102,7 +101,7 @@ function renderFacetArea(m, facetCluster) {
|
|
|
102
101
|
if (!m.belowSm || (facetCluster === undefined && behindFilter === undefined)) {
|
|
103
102
|
return facetCluster;
|
|
104
103
|
}
|
|
105
|
-
if (facetCluster !== undefined && hasOnlySelectFacets(m)) {
|
|
104
|
+
if (facetCluster !== undefined && m.narrowFacets === "pills" && hasOnlySelectFacets(m)) {
|
|
106
105
|
const inline = _jsx("div", { className: "flex w-full flex-wrap gap-2", children: facetCluster });
|
|
107
106
|
if (behindFilter === undefined)
|
|
108
107
|
return inline;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import type
|
|
2
|
+
import { type DataTableBulk } from "../../../data-table-bulk-types.ts";
|
|
3
3
|
import type { ListRowViewModel } from "../../../headless/index.ts";
|
|
4
4
|
import type { PinnedCellProps } from "./use-column-pins.ts";
|
|
5
5
|
export type BulkSelection = {
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
+
import { isBulkFormAction, } from "../../../data-table-bulk-types.js";
|
|
3
4
|
import { useBulkRun } from "../../../hooks/use-bulk-run.js";
|
|
4
5
|
import { useOptionalTranslation } from "../../../i18n.js";
|
|
5
6
|
import { cn } from "../../lib/cn.js";
|
|
@@ -36,6 +37,10 @@ export function useBulkSelection({ bulk, rows, titleField, rowTestId, flush, })
|
|
|
36
37
|
const reload = bulk.reload;
|
|
37
38
|
async function execute(action) {
|
|
38
39
|
setPendingAction(undefined);
|
|
40
|
+
if (isBulkFormAction(action)) {
|
|
41
|
+
action.openForm(selection.selectedRows);
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
39
44
|
setResultActionLabel(action.label);
|
|
40
45
|
const result = await run.start(action, selection.selectedRows);
|
|
41
46
|
// Failed rows stay selected for a retry; so do rows a cancel kept from running.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Dispatch, type SetStateAction } from "react";
|
|
1
|
+
import { type Dispatch, type RefObject, type SetStateAction } from "react";
|
|
2
2
|
import type { ListColumnViewModel, ListRowViewModel } from "../../../headless/index.ts";
|
|
3
3
|
import { type DataTableProps, useOptionalLocale, useOptionalTranslation } from "../../../index.ts";
|
|
4
4
|
import { densityClasses } from "./density.ts";
|
|
@@ -14,10 +14,15 @@ type RowExpansion = {
|
|
|
14
14
|
};
|
|
15
15
|
export type DataTableModel = Omit<DataTableProps, "columns"> & {
|
|
16
16
|
readonly schemaColumns: readonly ListColumnViewModel[];
|
|
17
|
+
/** With an emphasis column the first column is plain: the emphasised one carries the row. */
|
|
18
|
+
readonly hasEmphasisColumn: boolean;
|
|
17
19
|
readonly columns: ColumnPins<ListColumnViewModel>["columns"];
|
|
18
20
|
readonly tableTranslate: ReturnType<typeof useOptionalTranslation>;
|
|
19
21
|
readonly tableLocale: ReturnType<typeof useOptionalLocale>;
|
|
20
22
|
readonly isNarrow: boolean;
|
|
23
|
+
readonly containerRef: RefObject<HTMLDivElement | null>;
|
|
24
|
+
/** Row the assistant currently sees (the screen focus names its record); drawn highlighted. */
|
|
25
|
+
readonly focusedRowId: string | undefined;
|
|
21
26
|
readonly belowSm: boolean;
|
|
22
27
|
readonly density: ReturnType<typeof densityClasses>;
|
|
23
28
|
readonly facetsOpenNarrow: boolean;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { useId, useMemo, useState } from "react";
|
|
1
|
+
import { useId, useMemo, useState, } from "react";
|
|
2
2
|
import { useIsEmbeddedScreen } from "../../../context/embedded-screen-context.js";
|
|
3
|
+
import { useScreenFocus } from "../../../context/screen-focus-context.js";
|
|
3
4
|
import { useOptionalLocale, useOptionalTranslation } from "../../../index.js";
|
|
5
|
+
import { useContainerSqueeze } from "../use-container-narrow.js";
|
|
4
6
|
import { useIsBelowSmViewport, useIsNarrowViewport } from "../use-narrow-viewport.js";
|
|
5
7
|
import { isPinningActive, isResizingActive } from "./column-layout-mode.js";
|
|
6
8
|
import { densityClasses } from "./density.js";
|
|
@@ -47,7 +49,12 @@ export function useDataTableState(props) {
|
|
|
47
49
|
// single-mount pattern as EmbeddedListInput/embedded-list-input.tsx.
|
|
48
50
|
const isNarrow = useIsNarrowViewport();
|
|
49
51
|
const belowSm = useIsBelowSmViewport();
|
|
50
|
-
const
|
|
52
|
+
const focusedRowId = useScreenFocus()?.recordId;
|
|
53
|
+
const [containerRef, squeeze] = useContainerSqueeze();
|
|
54
|
+
const containerNarrow = squeeze.narrow || squeeze.docked;
|
|
55
|
+
const schemaColumns = useMemo(() => isNarrow
|
|
56
|
+
? allColumns
|
|
57
|
+
: allColumns.filter((col) => col.showOnNarrowOnly !== true && !(containerNarrow && col.hideWhenDocked === true)), [allColumns, isNarrow, containerNarrow]);
|
|
51
58
|
const viewColumns = useViewColumns(schemaColumns, view, isNarrow);
|
|
52
59
|
const density = densityClasses(view, scrollBody === true);
|
|
53
60
|
const [facetsOpenNarrow, setFacetsOpenNarrow] = useState(false);
|
|
@@ -99,11 +106,14 @@ export function useDataTableState(props) {
|
|
|
99
106
|
return {
|
|
100
107
|
...props,
|
|
101
108
|
schemaColumns,
|
|
109
|
+
hasEmphasisColumn: schemaColumns.some((column) => column.emphasis === true),
|
|
102
110
|
columns,
|
|
103
111
|
tableTranslate,
|
|
104
112
|
tableLocale,
|
|
105
113
|
isNarrow,
|
|
106
114
|
belowSm,
|
|
115
|
+
containerRef,
|
|
116
|
+
focusedRowId,
|
|
107
117
|
density,
|
|
108
118
|
facetsOpenNarrow,
|
|
109
119
|
setFacetsOpenNarrow,
|
|
@@ -11,9 +11,10 @@ export declare function isBadgeColumn(col: {
|
|
|
11
11
|
readonly type: string;
|
|
12
12
|
readonly renderer?: unknown;
|
|
13
13
|
}): boolean;
|
|
14
|
-
export declare function FirstCellLink({ enabled, empty, emptyLabel, onOpen, children, }: {
|
|
14
|
+
export declare function FirstCellLink({ enabled, empty, emptyLabel, emptyPlaceholder, onOpen, children, }: {
|
|
15
15
|
readonly enabled: boolean;
|
|
16
16
|
readonly empty: boolean;
|
|
17
|
+
readonly emptyPlaceholder?: string | false | undefined;
|
|
17
18
|
readonly emptyLabel?: string | undefined;
|
|
18
19
|
readonly onOpen: () => void;
|
|
19
20
|
readonly children: ReactNode;
|
|
@@ -47,9 +48,13 @@ type DataTableCellProps = {
|
|
|
47
48
|
readonly badgeDot?: false;
|
|
48
49
|
readonly pillField?: string;
|
|
49
50
|
readonly pillToneField?: string;
|
|
50
|
-
readonly emptyPlaceholder?: false;
|
|
51
|
+
readonly emptyPlaceholder?: string | false;
|
|
52
|
+
readonly dateOnlyAfterDays?: number;
|
|
51
53
|
readonly onOpenRow?: () => void;
|
|
52
54
|
};
|
|
55
|
+
export declare function EmptyCell({ placeholder, }: {
|
|
56
|
+
readonly placeholder: string | false | undefined;
|
|
57
|
+
}): ReactNode;
|
|
53
58
|
/** `display: "button"` draws a cell link as a small outline button. */
|
|
54
59
|
export declare const LINK_BUTTON_CLASS: string;
|
|
55
60
|
export declare const LINK_BUTTON_PRIMARY_CLASS: string;
|
|
@@ -74,5 +79,11 @@ export declare function CellTextLink({ link, children, className, }: {
|
|
|
74
79
|
readonly children: ReactNode;
|
|
75
80
|
readonly className?: string;
|
|
76
81
|
}): ReactNode;
|
|
82
|
+
/** The extra pill a column draws beside its value in a table row, or in the header line of a phone card. */
|
|
83
|
+
export declare function CellPill({ row, pillField, pillToneField, }: {
|
|
84
|
+
readonly row: Readonly<Record<string, unknown>>;
|
|
85
|
+
readonly pillField: string | undefined;
|
|
86
|
+
readonly pillToneField: string | undefined;
|
|
87
|
+
}): ReactNode;
|
|
77
88
|
export declare function DataTableCell(props: DataTableCellProps): ReactNode;
|
|
78
89
|
export {};
|
|
@@ -5,8 +5,9 @@ import { Check } from "lucide-react";
|
|
|
5
5
|
import { Fragment } from "react";
|
|
6
6
|
import { rendererWarn } from "../../dev-console.js";
|
|
7
7
|
import { fileIdsOf } from "../../file-ids-of.js";
|
|
8
|
-
import { applyFormatSpec, EMPTY_VALUE_PLACEHOLDER, isSafeHref, telHref, } from "../../headless/index.js";
|
|
8
|
+
import { applyFormatSpec, EMPTY_VALUE_PLACEHOLDER, formatMoneyValue, isSafeHref, telHref, } from "../../headless/index.js";
|
|
9
9
|
import { statusToneForOptionTone, statusToneForValue, useColumnRenderer, useOptionalPrimitives, } from "../../index.js";
|
|
10
|
+
import { serverNowMs } from "../../server-clock.js";
|
|
10
11
|
import { isSelectOptionTone } from "../../status-tone.js";
|
|
11
12
|
import { Badge } from "../ui/badge.js";
|
|
12
13
|
import { buttonVariants } from "../ui/button.js";
|
|
@@ -14,8 +15,8 @@ import { StatusBadge } from "../widgets/status-badge.js";
|
|
|
14
15
|
import { HintCell } from "./data-table/hint-cell.js";
|
|
15
16
|
import { FileDisplayCell } from "./file-thumbnail.js";
|
|
16
17
|
import { FileViewAction } from "./file-view-action.js";
|
|
17
|
-
import { currencyDecimals, formatMoney } from "./money-input.js";
|
|
18
18
|
import "../react-css-custom-properties.js";
|
|
19
|
+
import { useOptionalTranslation } from "../../index.js";
|
|
19
20
|
import { isPlainPrimaryClick } from "./layout-elements.js";
|
|
20
21
|
export function isEmptyCellValue(value) {
|
|
21
22
|
return (value === null || value === undefined || (typeof value === "string" && value.trim() === ""));
|
|
@@ -77,10 +78,10 @@ export function isBadgeColumn(col) {
|
|
|
77
78
|
// The first cell is the keyboard-reachable entry point of a clickable row; the
|
|
78
79
|
// row's own onClick keeps serving the mouse. Enter is handled explicitly so
|
|
79
80
|
// it also opens the row where a button does not synthesize a click.
|
|
80
|
-
export function FirstCellLink({ enabled, empty, emptyLabel, onOpen, children, }) {
|
|
81
|
+
export function FirstCellLink({ enabled, empty, emptyLabel, emptyPlaceholder, onOpen, children, }) {
|
|
81
82
|
if (!enabled || (empty && emptyLabel === undefined))
|
|
82
83
|
return children;
|
|
83
|
-
return (_jsx("button", { type: "button", className: "max-w-full cursor-pointer bg-transparent p-0 text-left font-medium text-
|
|
84
|
+
return (_jsx("button", { type: "button", className: "max-w-full cursor-pointer bg-transparent p-0 text-left font-medium text-inherit hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", onClick: (e) => {
|
|
84
85
|
e.stopPropagation();
|
|
85
86
|
onOpen();
|
|
86
87
|
}, onKeyDown: (e) => {
|
|
@@ -89,7 +90,7 @@ export function FirstCellLink({ enabled, empty, emptyLabel, onOpen, children, })
|
|
|
89
90
|
e.preventDefault();
|
|
90
91
|
e.stopPropagation();
|
|
91
92
|
onOpen();
|
|
92
|
-
}, children: empty ? _jsx("span", { className: "sr-only", children: emptyLabel }) : children }));
|
|
93
|
+
}, children: empty ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: emptyLabel }), _jsx(EmptyCell, { placeholder: emptyPlaceholder })] })) : (children) }));
|
|
93
94
|
}
|
|
94
95
|
// w-px on an auto-layout table cell shrinks the column to its content (the
|
|
95
96
|
// actions column relies on the same behaviour).
|
|
@@ -157,14 +158,7 @@ export function defaultCellRender(value, type, optionLabels, locale, columnKey,
|
|
|
157
158
|
if (type === "money") {
|
|
158
159
|
if (!isMoneyValue(value))
|
|
159
160
|
return String(value);
|
|
160
|
-
|
|
161
|
-
// rehydrateMoney's `amountMinor` is scaled by a flat MINOR_UNIT_SCALE=100
|
|
162
|
-
// instead, which disagrees with currencyDecimals for non-2-decimal
|
|
163
|
-
// currencies (JPY: 0 decimals → 100x too high; BHD: 3 decimals → 10x too
|
|
164
|
-
// low). Deriving minor units from `amount` keeps this consistent with
|
|
165
|
-
// render-field.tsx's moneyMinorValue.
|
|
166
|
-
const minor = Math.round(value.amount * 10 ** currencyDecimals(value.currency));
|
|
167
|
-
return formatMoney(minor, value.currency, locale);
|
|
161
|
+
return formatMoneyValue(value, locale);
|
|
168
162
|
}
|
|
169
163
|
if (type === "select" || type === "multiSelect") {
|
|
170
164
|
const values = Array.isArray(value) ? value : [value];
|
|
@@ -235,8 +229,34 @@ function enumOptionTones(spec) {
|
|
|
235
229
|
}
|
|
236
230
|
return out;
|
|
237
231
|
}
|
|
238
|
-
|
|
239
|
-
|
|
232
|
+
const MS_PER_DAY = 86_400_000;
|
|
233
|
+
function dateOnlyWhenOlderThan(value, days, locale, renderer) {
|
|
234
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
235
|
+
return undefined;
|
|
236
|
+
const atMs = typeof value === "number" ? value : Date.parse(value);
|
|
237
|
+
// An unparsable or out-of-range value falls back to the plain cell text.
|
|
238
|
+
if (Number.isNaN(new Date(atMs).getTime()))
|
|
239
|
+
return undefined;
|
|
240
|
+
if (serverNowMs() - atMs <= days * MS_PER_DAY)
|
|
241
|
+
return undefined;
|
|
242
|
+
const timeZone = typeof renderer === "object" &&
|
|
243
|
+
renderer !== null &&
|
|
244
|
+
"timeZone" in renderer &&
|
|
245
|
+
typeof renderer.timeZone === "string"
|
|
246
|
+
? renderer.timeZone
|
|
247
|
+
: undefined;
|
|
248
|
+
return applyFormatSpec({
|
|
249
|
+
format: "date",
|
|
250
|
+
dateStyle: "long",
|
|
251
|
+
...(locale !== undefined && { locale }),
|
|
252
|
+
...(timeZone !== undefined && { timeZone }),
|
|
253
|
+
}, new Date(atMs).toISOString());
|
|
254
|
+
}
|
|
255
|
+
export function EmptyCell({ placeholder, }) {
|
|
256
|
+
const t = useOptionalTranslation();
|
|
257
|
+
// translate returns an unknown key (a literal like "No vehicle") unchanged.
|
|
258
|
+
const text = typeof placeholder === "string" ? (t?.(placeholder) ?? placeholder) : null;
|
|
259
|
+
return (_jsx("span", { "data-empty-cell": "true", className: "text-muted-foreground", children: text }));
|
|
240
260
|
}
|
|
241
261
|
/** `display: "button"` draws a cell link as a small outline button. */
|
|
242
262
|
export const LINK_BUTTON_CLASS = buttonVariants({ variant: "outline", size: "sm" });
|
|
@@ -247,6 +267,10 @@ export const LIST_BADGE_TONE = {
|
|
|
247
267
|
warn: "warn",
|
|
248
268
|
negative: "bad",
|
|
249
269
|
neutral: "muted",
|
|
270
|
+
ok: "ok",
|
|
271
|
+
bad: "bad",
|
|
272
|
+
critical: "bad",
|
|
273
|
+
accent: "muted",
|
|
250
274
|
};
|
|
251
275
|
// A multi reference may list the same id twice; the occurrence count keeps React keys unique.
|
|
252
276
|
function uniqueLinkItemKeys(items) {
|
|
@@ -282,8 +306,8 @@ const ROW_TONE_STRIPE_CLASS = {
|
|
|
282
306
|
accent: `${ROW_STRIPE_SHADOW_CLASS} [&>td:first-child]:[--row-stripe:var(--color-primary)]`,
|
|
283
307
|
neutral: "",
|
|
284
308
|
};
|
|
285
|
-
// Inner
|
|
286
|
-
const CARD_STRIPE_BASE = "relative pl-
|
|
309
|
+
// Inner 3px edge stripe (board .card.cw): sits inside the card border, rounded with the card corners.
|
|
310
|
+
const CARD_STRIPE_BASE = "relative pl-5 before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:rounded-l-[7px] before:content-['']";
|
|
287
311
|
const CARD_TONE_STRIPE_CLASS = {
|
|
288
312
|
bad: `${CARD_STRIPE_BASE} before:bg-status-bad`,
|
|
289
313
|
warn: `${CARD_STRIPE_BASE} before:bg-status-warn`,
|
|
@@ -381,23 +405,37 @@ function renderFileCell({ value, fileDisplay, compactFile, translate, }) {
|
|
|
381
405
|
// "X" via useColumnRenderer and renders `<X value row column/>`.
|
|
382
406
|
// Not registered -> one-time warning + default fallback.
|
|
383
407
|
// 4. Otherwise -> defaultCellRender (type-based string renderer).
|
|
384
|
-
|
|
385
|
-
|
|
408
|
+
/** The extra pill a column draws beside its value in a table row, or in the header line of a phone card. */
|
|
409
|
+
export function CellPill({ row, pillField, pillToneField, }) {
|
|
386
410
|
const pillText = pillField === undefined ? undefined : row[pillField];
|
|
387
411
|
if (typeof pillText !== "string" || pillText === "")
|
|
388
|
-
return
|
|
412
|
+
return null;
|
|
389
413
|
const toneKey = pillToneField === undefined ? undefined : row[pillToneField];
|
|
390
414
|
const tone = (typeof toneKey === "string" ? LIST_BADGE_TONE[toneKey] : undefined) ?? "muted";
|
|
391
|
-
return
|
|
415
|
+
return _jsx(StatusBadge, { tone: tone, children: pillText });
|
|
392
416
|
}
|
|
393
|
-
function
|
|
417
|
+
export function DataTableCell(props) {
|
|
418
|
+
const { pillField, pillToneField, row } = props;
|
|
419
|
+
if (pillField === undefined)
|
|
420
|
+
return _jsx(DataTableCellBody, { ...props });
|
|
421
|
+
const pill = _jsx(CellPill, { row: row, pillField: pillField, pillToneField: pillToneField });
|
|
422
|
+
if (isEmptyCellValue(row[pillField]))
|
|
423
|
+
return _jsx(DataTableCellBody, { ...props });
|
|
424
|
+
return (_jsxs("span", { className: "inline-flex items-center gap-2", children: [_jsx(DataTableCellBody, { ...props }), pill] }));
|
|
425
|
+
}
|
|
426
|
+
function DataTableCellBody({ value, row, field, type, renderer, optionLabels, optionTones, onChange, translate, locale, grouping = true, fileDisplay, compactFile = false, link, linkItems, hint, display, badgeToneField, badgeDot, emptyPlaceholder, dateOnlyAfterDays, onOpenRow, }) {
|
|
394
427
|
const componentRef = isComponentRendererRef(renderer);
|
|
395
428
|
const ResolvedComponent = useColumnRenderer(componentRef?.name);
|
|
396
429
|
const RegisteredStatusBadge = useOptionalPrimitives()?.StatusBadge;
|
|
397
430
|
if (hint !== undefined) {
|
|
398
431
|
return (_jsx(HintCell, { value: value, row: row, hint: hint, ...(onOpenRow !== undefined && { onOpen: onOpenRow }) }));
|
|
399
432
|
}
|
|
400
|
-
|
|
433
|
+
// A function renderer formats its own values; only an explicit `emptyPlaceholder` takes an empty value over.
|
|
434
|
+
const showsPlaceholder = typeof renderer !== "function"
|
|
435
|
+
? isEmptyCellValue(value)
|
|
436
|
+
: typeof emptyPlaceholder === "string" &&
|
|
437
|
+
(isEmptyCellValue(value) || (Array.isArray(value) && value.length === 0));
|
|
438
|
+
if (showsPlaceholder && componentRef === undefined) {
|
|
401
439
|
return _jsx(EmptyCell, { placeholder: emptyPlaceholder });
|
|
402
440
|
}
|
|
403
441
|
if (value === PII_ERASED_SENTINEL && translate !== undefined) {
|
|
@@ -425,6 +463,12 @@ function DataTableCellBody({ value, row, field, type, renderer, optionLabels, op
|
|
|
425
463
|
});
|
|
426
464
|
if (displayCell !== undefined)
|
|
427
465
|
return displayCell;
|
|
466
|
+
const dateOnlyText = dateOnlyAfterDays === undefined
|
|
467
|
+
? undefined
|
|
468
|
+
: dateOnlyWhenOlderThan(value, dateOnlyAfterDays, locale, renderer);
|
|
469
|
+
if (dateOnlyText !== undefined) {
|
|
470
|
+
return link === undefined ? (dateOnlyText) : (_jsx(CellTextLink, { link: link, children: dateOnlyText }));
|
|
471
|
+
}
|
|
428
472
|
if (typeof value === "boolean" &&
|
|
429
473
|
isBooleanColumn(type, renderer) &&
|
|
430
474
|
(renderer === undefined || isUnlabeledBooleanFormat(renderer))) {
|
|
@@ -436,34 +480,21 @@ function DataTableCellBody({ value, row, field, type, renderer, optionLabels, op
|
|
|
436
480
|
return renderFileCell({ value, fileDisplay, compactFile, translate });
|
|
437
481
|
}
|
|
438
482
|
if (isFormatSpecRenderer(renderer)) {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
483
|
+
return renderFormatSpecCell({
|
|
484
|
+
renderer,
|
|
485
|
+
value,
|
|
486
|
+
translate,
|
|
487
|
+
locale,
|
|
488
|
+
link,
|
|
489
|
+
RegisteredStatusBadge,
|
|
490
|
+
});
|
|
449
491
|
}
|
|
450
492
|
if (isFunctionRenderer(renderer)) {
|
|
451
|
-
|
|
452
|
-
const linkItemKeys = uniqueLinkItemKeys(linkItems);
|
|
453
|
-
return (_jsx(_Fragment, { children: linkItems.map((item, index) => (_jsxs(Fragment, { children: [index > 0 && ", ", item.link === undefined ? (item.label) : (_jsx(CellTextLink, { link: item.link, children: item.label }))] }, linkItemKeys[index]))) }));
|
|
454
|
-
}
|
|
455
|
-
const text = renderer(value, row);
|
|
456
|
-
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
493
|
+
return renderFunctionRendererCell({ renderer, value, row, link, linkItems });
|
|
457
494
|
}
|
|
458
495
|
if (componentRef !== undefined) {
|
|
459
496
|
if (ResolvedComponent !== undefined) {
|
|
460
|
-
|
|
461
|
-
// stopPropagation only on the editable branch — plain cells must still
|
|
462
|
-
// fire row onClick when onCellChange is set for sibling editable cells.
|
|
463
|
-
if (onChange !== undefined) {
|
|
464
|
-
return (_jsx("span", { className: "contents", onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), children: node }));
|
|
465
|
-
}
|
|
466
|
-
return node;
|
|
497
|
+
return renderResolvedComponentCell({ ResolvedComponent, value, row, field, onChange });
|
|
467
498
|
}
|
|
468
499
|
// Renderer referenced in the schema but no map entry client-side —
|
|
469
500
|
// typical case: clientFeatures.columnRenderers forgotten or a typo in the
|
|
@@ -471,11 +502,53 @@ function DataTableCellBody({ value, row, field, type, renderer, optionLabels, op
|
|
|
471
502
|
// (the default type renderer takes over).
|
|
472
503
|
rendererWarn(`[kumiko] columnRenderer "${componentRef.name}" not registered`);
|
|
473
504
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
505
|
+
const selectCell = renderSelectTypeCell({
|
|
506
|
+
type,
|
|
507
|
+
value,
|
|
508
|
+
optionLabels,
|
|
509
|
+
optionTones,
|
|
510
|
+
locale,
|
|
511
|
+
RegisteredStatusBadge,
|
|
512
|
+
});
|
|
513
|
+
if (selectCell !== undefined)
|
|
514
|
+
return selectCell;
|
|
515
|
+
const text = defaultCellRender(value, type, optionLabels, locale, field, grouping);
|
|
516
|
+
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
517
|
+
}
|
|
518
|
+
function renderFormatSpecCell({ renderer, value, translate, locale, link, RegisteredStatusBadge, }) {
|
|
519
|
+
const text = applyFormatSpec({ ...renderer, locale: renderer.locale ?? locale }, value, translate);
|
|
520
|
+
const phoneHref = renderer.format === "phone" ? telHref(text) : undefined;
|
|
521
|
+
if (phoneHref !== undefined) {
|
|
522
|
+
return (_jsx(CellTextLink, { link: { href: phoneHref, onPress: () => window.location.assign(phoneHref) }, children: text }));
|
|
523
|
+
}
|
|
524
|
+
const tones = enumOptionTones(renderer);
|
|
525
|
+
if (tones !== undefined && typeof value === "string") {
|
|
526
|
+
return selectPill(value, { [value]: text }, tones, locale, RegisteredStatusBadge);
|
|
527
|
+
}
|
|
528
|
+
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
529
|
+
}
|
|
530
|
+
function renderFunctionRendererCell({ renderer, value, row, link, linkItems, }) {
|
|
531
|
+
if (linkItems !== undefined) {
|
|
532
|
+
const linkItemKeys = uniqueLinkItemKeys(linkItems);
|
|
533
|
+
return (_jsx(_Fragment, { children: linkItems.map((item, index) => (_jsxs(Fragment, { children: [index > 0 && ", ", item.link === undefined ? (item.label) : (_jsx(CellTextLink, { link: item.link, children: item.label }))] }, linkItemKeys[index]))) }));
|
|
534
|
+
}
|
|
535
|
+
const text = renderer(value, row);
|
|
536
|
+
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
537
|
+
}
|
|
538
|
+
function renderResolvedComponentCell({ ResolvedComponent, value, row, field, onChange, }) {
|
|
539
|
+
const node = (_jsx(ResolvedComponent, { value: value, row: row, column: { field }, ...(onChange !== undefined && { onChange }) }));
|
|
540
|
+
// stopPropagation only on the editable branch — plain cells must still
|
|
541
|
+
// fire row onClick when onCellChange is set for sibling editable cells.
|
|
542
|
+
if (onChange === undefined)
|
|
543
|
+
return node;
|
|
544
|
+
return (_jsx("span", { className: "contents", onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), children: node }));
|
|
545
|
+
}
|
|
546
|
+
// A select value renders as a pill instead of plain text. When the raw
|
|
547
|
+
// value is a known status word, it carries the same tone as the
|
|
548
|
+
// projectionDetail header badge — a status column stayed grey while the
|
|
549
|
+
// detail view of the same value was coloured. Unknown values
|
|
550
|
+
// keep the neutral outline pill.
|
|
551
|
+
function renderSelectTypeCell({ type, value, optionLabels, optionTones, locale, RegisteredStatusBadge, }) {
|
|
479
552
|
if (type === "select" && value !== null && value !== undefined && value !== "") {
|
|
480
553
|
return selectPill(value, optionLabels, optionTones, locale, RegisteredStatusBadge);
|
|
481
554
|
}
|
|
@@ -483,6 +556,5 @@ function DataTableCellBody({ value, row, field, type, renderer, optionLabels, op
|
|
|
483
556
|
if (type === "multiSelect" && Array.isArray(value) && value.length > 0) {
|
|
484
557
|
return (_jsx("span", { className: "flex flex-wrap gap-1", children: value.map((entry) => (_jsx(Fragment, { children: selectPill(entry, optionLabels, optionTones, locale, RegisteredStatusBadge) }, String(entry)))) }));
|
|
485
558
|
}
|
|
486
|
-
|
|
487
|
-
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
559
|
+
return undefined;
|
|
488
560
|
}
|
|
@@ -34,5 +34,5 @@ export function DefaultDataTable(props) {
|
|
|
34
34
|
// (that lives in the shell's breadcrumb). The toolbar is NOT sticky: lists
|
|
35
35
|
// typically scroll with the page container, not internally. Sticky would
|
|
36
36
|
// compete with the topbar.
|
|
37
|
-
return (_jsxs("div", { className: wrapperClassName(model), children: [!mergesDescription && !model.fillsHeight && renderToolbarDescription(model, hasToolbar), hasToolbar && renderToolbar(model, facetCluster), !mergesDescription && model.fillsHeight && renderToolbarDescription(model, hasToolbar), renderTableContent(model)] }));
|
|
37
|
+
return (_jsxs("div", { ref: model.containerRef, className: wrapperClassName(model), children: [!mergesDescription && !model.fillsHeight && renderToolbarDescription(model, hasToolbar), hasToolbar && renderToolbar(model, facetCluster), !mergesDescription && model.fillsHeight && renderToolbarDescription(model, hasToolbar), renderTableContent(model)] }));
|
|
38
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type FormProps } from "../../index.ts";
|
|
3
3
|
import "../react-css-custom-properties.ts";
|
|
4
|
-
export declare function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, subtitle, actions, secondaryActions, testId, width, stickyActions, headerRegion, titleAction, fillHeight, chromeless, screenForm, unsavedCount, sectionNav, sideRail, summary, }: FormProps): ReactNode;
|
|
4
|
+
export declare function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, subtitle, actions, secondaryActions, testId, width, stickyActions, headerRegion, titleAction, fillHeight, chromeless, screenForm, unsavedCount, sectionNav, sideRail, summary, topBanner, }: FormProps): ReactNode;
|