@cosmicdrift/kumiko-renderer 0.416.0 → 0.417.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 +9 -8
- 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/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/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.js +2 -1
- 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 +4 -2
- 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 +11 -0
- package/dist/components/render-field-ai-assist.js +3 -2
- package/dist/components/render-field-control.js +1 -1
- package/dist/components/render-field-value-chips.js +4 -2
- 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/headless/form/form-controller.d.ts +1 -0
- package/dist/headless/form/form-controller.js +1 -1
- package/dist/headless/format/index.js +5 -4
- package/dist/headless/format/relative-time.d.ts +2 -0
- package/dist/headless/format/relative-time.js +4 -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 +49 -4
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +7 -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/notification-bell.js +12 -3
- 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 +13 -5
- 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-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 +123 -43
- 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/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/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
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cardMetaLines } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { Sparkles } from "lucide-react";
|
|
4
|
+
import { Fragment } from "react";
|
|
5
|
+
import { cn } from "../../lib/cn.js";
|
|
6
|
+
import { CellPill, cellLinkProp, DataTableCell, isBadgeColumn, isEmptyCellValue, isUnlabeledFalse, showsBareCheckMark, } from "../data-table-cell.js";
|
|
5
7
|
import { CardLeadingImage } from "../file-thumbnail.js";
|
|
6
8
|
import { columnCellPresentationProps } from "./data-cell-props.js";
|
|
7
9
|
import { showFullTextOnHover } from "./table-footer.js";
|
|
@@ -11,17 +13,22 @@ function cardHint(hint) {
|
|
|
11
13
|
const detailField = narrowDetailField ?? _detail;
|
|
12
14
|
return { ...rest, ...(detailField !== undefined && { detailField }) };
|
|
13
15
|
}
|
|
14
|
-
function
|
|
16
|
+
function withoutPill(col) {
|
|
17
|
+
const { pillField: _pill, pillToneField: _pillTone, ...rest } = col;
|
|
18
|
+
return rest;
|
|
19
|
+
}
|
|
20
|
+
function cardCell(m, row, col, { linksAllowed, omitPill } = {
|
|
21
|
+
linksAllowed: false,
|
|
22
|
+
}) {
|
|
15
23
|
const { onCellChange } = m;
|
|
16
24
|
const opensRow = m.rowOpener(row) !== undefined;
|
|
17
25
|
// A bare check mark in the subtitle line says nothing without its column.
|
|
18
26
|
if (showsBareCheckMark(col.type, row.values[col.field], col.renderer))
|
|
19
27
|
return col.label;
|
|
20
28
|
const shortSentence = col.hint?.narrowField === undefined ? undefined : row.values[col.hint.narrowField];
|
|
21
|
-
return (_jsx(DataTableCell, { value: isEmptyCellValue(shortSentence) ? row.values[col.field] : shortSentence, 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 && {
|
|
29
|
+
return (_jsx(DataTableCell, { value: isEmptyCellValue(shortSentence) ? row.values[col.field] : shortSentence, row: row.values, field: col.field, type: col.type, renderer: col.renderer, translate: m.tableTranslate, locale: m.tableLocale, ...columnCellPresentationProps(omitPill === true ? withoutPill(col) : col), ...(col.hint !== undefined && { hint: cardHint(col.hint) }), ...(col.fileDisplay !== undefined && { fileDisplay: col.fileDisplay, compactFile: true }), ...(onCellChange !== undefined && {
|
|
22
30
|
onChange: (value) => onCellChange(row.id, col.field, value),
|
|
23
|
-
}), ...(col
|
|
24
|
-
col.display === undefined && { display: "button" }), ...cellLinkProp(col, row, linksAllowed || !opensRow) }));
|
|
31
|
+
}), ...cellLinkProp(col, row, linksAllowed || !opensRow) }));
|
|
25
32
|
}
|
|
26
33
|
function cellTestIdOf(m, row, field) {
|
|
27
34
|
return m.getCellTestId?.(row, field) ?? `cell-${row.id}-${field}`;
|
|
@@ -53,27 +60,43 @@ export function splitLinkColumns(m, row, roles) {
|
|
|
53
60
|
};
|
|
54
61
|
}
|
|
55
62
|
export function renderCardLinks(m, row, linkColumns) {
|
|
56
|
-
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))) }));
|
|
63
|
+
return (_jsx("div", { "data-testid": `card-links-${row.id}`, className: "flex flex-wrap items-center gap-x-3 text-[13px] font-medium leading-5 text-primary", children: linkColumns.map((col) => (_jsx("span", { "data-testid": cellTestIdOf(m, row, col.field), children: cardCell(m, row, col, { linksAllowed: true }) }, col.field))) }));
|
|
57
64
|
}
|
|
58
65
|
function renderMetaCell(m, row, col) {
|
|
59
|
-
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, col.field), className:
|
|
66
|
+
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, col.field), className: `min-w-0 max-w-full leading-5 ${col.ellipsis === true ? "truncate" : "break-words"}${col.multiline === true ? " whitespace-pre-line" : ""}${col.emphasis === true ? " font-semibold text-foreground" : ""}`, onPointerEnter: showFullTextOnHover, children: isBadgeColumn(col) ? (_jsx("span", { className: "inline-flex align-middle", children: cardCell(m, row, col) })) : (cardCell(m, row, col)) }, col.field));
|
|
60
67
|
}
|
|
61
|
-
function renderCardMeta(m, row, metaColumns) {
|
|
62
|
-
|
|
68
|
+
function renderCardMeta(m, row, metaColumns, placement = "below") {
|
|
69
|
+
const plain = m.plainPhoneCards === true;
|
|
70
|
+
const lines = cardMetaLines(metaColumns);
|
|
71
|
+
return (_jsx("div", { className: "min-w-0", children: _jsx("div", { "data-testid": placement === "above" ? `card-above-${row.id}` : `card-meta-${row.id}`, className: `flex min-w-0 flex-col text-[12.5px] leading-5 tabular-nums text-muted-foreground`, children: lines.map((line, lineIndex) => line[0]?.narrowInline === true ? (_jsx("div", { "data-testid": `card-vals-${row.id}-${line[0].field}`, className: cn("mt-1 flex min-w-0 max-w-full flex-wrap items-center gap-y-0.5 text-[12.5px] leading-5", plain ? "gap-x-0" : "gap-x-3"), children: line.map((col, colIndex) => (_jsxs(Fragment, { children: [plain && colIndex > 0 && _jsx("span", { "aria-hidden": "true", children: ",\u00A0" }), renderMetaCell(m, row, col)] }, col.field))) }, line.map((col) => col.field).join("|"))) : (_jsx("div", { className: cn("flex min-h-5 min-w-0 max-w-full items-center", plain &&
|
|
72
|
+
placement === "below" &&
|
|
73
|
+
lineIndex === lines.length - 1 &&
|
|
74
|
+
"text-foreground"), children: line.map((col) => renderMetaCell(m, row, col)) }, line.map((col) => col.field).join("|")))) }) }));
|
|
63
75
|
}
|
|
76
|
+
// Header line of the card: the "to do" sentence (primary with a sparkle when the column is `emphasis`)
|
|
77
|
+
// on the left, the column's extra pill on the right.
|
|
64
78
|
function renderCardLead(m, row, lead) {
|
|
65
79
|
if (lead === undefined || isEmptyCellValue(row.values[lead.field]))
|
|
66
80
|
return null;
|
|
67
|
-
|
|
81
|
+
const emphasized = lead.emphasis === true;
|
|
82
|
+
const pill = (_jsx(CellPill, { row: row.values, pillField: lead.pillField, pillToneField: lead.pillToneField }));
|
|
83
|
+
return (_jsxs("div", { className: "flex min-w-0 items-center justify-between gap-2", children: [_jsxs("div", { "data-testid": cellTestIdOf(m, row, lead.field), className: `flex min-w-0 items-start gap-1.5 text-xs leading-5 ${emphasized ? "font-medium text-primary [&_span]:text-primary" : "font-medium text-muted-foreground"}`, children: [emphasized && _jsx(Sparkles, { className: "mt-0.5 size-3.5 shrink-0", "aria-hidden": "true" }), cardCell(m, row, lead, { linksAllowed: false, omitPill: true })] }), pill !== null && _jsx("span", { className: "shrink-0", children: pill })] }));
|
|
84
|
+
}
|
|
85
|
+
const OUTLINED_NEUTRAL_PILL_CLASS = "[&_span]:border [&_span]:border-border-strong [&_span]:bg-transparent [&_span]:text-muted-foreground";
|
|
86
|
+
function renderCardStatus(m, row, status) {
|
|
87
|
+
const cell = cardCell(m, row, status);
|
|
88
|
+
return (_jsx("span", { "data-testid": cellTestIdOf(m, row, status.field), className: "shrink-0", children: status.cardBadge === true ? (isBadgeColumn(status) ? (_jsx("span", { className: `inline-flex ${OUTLINED_NEUTRAL_PILL_CLASS}`, children: cell })) : (_jsx("span", { className: "inline-flex rounded-full border border-border-strong px-2 py-0.5 text-xs text-muted-foreground", children: cell }))) : (cell) }));
|
|
68
89
|
}
|
|
69
90
|
function renderCardHeading(m, row, roles) {
|
|
70
91
|
const { title: cardTitleColumn, status: cardStatusColumn } = roles;
|
|
71
92
|
const showStatus = cardStatusColumn !== undefined && !isEmptyCellValue(row.values[cardStatusColumn.field]);
|
|
72
|
-
return (_jsxs("div", { className: "flex min-w-0 items-start justify-between gap-2", children: [cardTitleColumn !== undefined && (_jsx("span", { "data-testid": cellTestIdOf(m, row, cardTitleColumn.field), className: "min-w-0 truncate text-[14.5px] font-semibold text-foreground", onPointerEnter: showFullTextOnHover, children: cardCell(m, row, cardTitleColumn) })), showStatus && (
|
|
93
|
+
return (_jsxs("div", { className: "flex min-w-0 items-start justify-between gap-2", children: [cardTitleColumn !== undefined && (_jsx("span", { "data-testid": cellTestIdOf(m, row, cardTitleColumn.field), className: "min-w-0 truncate text-[14.5px] font-semibold text-foreground", onPointerEnter: showFullTextOnHover, children: cardCell(m, row, cardTitleColumn) })), showStatus && renderCardStatus(m, row, cardStatusColumn)] }));
|
|
73
94
|
}
|
|
74
95
|
export function renderCardBody(m, row, roles) {
|
|
75
96
|
const { image: cardImageColumn, meta: cardMetaColumns } = roles;
|
|
76
|
-
const
|
|
97
|
+
const shownMeta = cardMetaColumns.filter((col) => !isEmptyCellValue(row.values[col.field]) &&
|
|
77
98
|
!isUnlabeledFalse(col.type, row.values[col.field], col.renderer));
|
|
78
|
-
|
|
99
|
+
const aboveColumns = shownMeta.filter((col) => col.cardAbove === true);
|
|
100
|
+
const metaColumns = shownMeta.filter((col) => col.cardAbove !== true);
|
|
101
|
+
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), aboveColumns.length > 0 && renderCardMeta(m, row, aboveColumns, "above"), renderCardHeading(m, row, roles), metaColumns.length > 0 && renderCardMeta(m, row, metaColumns)] })] }));
|
|
79
102
|
}
|
|
@@ -5,4 +5,6 @@ export declare function isInsideCardFrame(m: FrameInput): boolean;
|
|
|
5
5
|
/** `frame: "card"` below sm: every card of the card layout is bordered and rounded, with a gap. */
|
|
6
6
|
export declare function hasSeparateCardRows(m: FrameInput): boolean;
|
|
7
7
|
export declare const CARD_SURFACE_CLASS = "rounded-lg border border-border bg-card";
|
|
8
|
+
export declare const ASSISTANT_FOCUS_CARD_CLASS = "bg-primary/10 shadow-[inset_3px_0_0_var(--color-primary)]";
|
|
9
|
+
export declare const ASSISTANT_FOCUS_ROW_CLASS = "bg-primary/10 hover:bg-primary/10 [&>td:first-child]:shadow-[inset_3px_0_0_var(--color-primary)]";
|
|
8
10
|
export {};
|
|
@@ -7,3 +7,6 @@ export function hasSeparateCardRows(m) {
|
|
|
7
7
|
return m.frame === "card" && m.belowSm;
|
|
8
8
|
}
|
|
9
9
|
export const CARD_SURFACE_CLASS = "rounded-lg border border-border bg-card";
|
|
10
|
+
// The row the assistant sees: light primary wash plus a 3px primary bar on the left edge.
|
|
11
|
+
export const ASSISTANT_FOCUS_CARD_CLASS = "bg-primary/10 shadow-[inset_3px_0_0_var(--color-primary)]";
|
|
12
|
+
export const ASSISTANT_FOCUS_ROW_CLASS = "bg-primary/10 hover:bg-primary/10 [&>td:first-child]:shadow-[inset_3px_0_0_var(--color-primary)]";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
1
|
+
import { Fragment as _Fragment, 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
4
|
import { cardToneClass } from "../data-table-cell.js";
|
|
5
5
|
import { RowActionsCell } from "../row-actions.js";
|
|
6
6
|
import { renderCardBody, renderCardLinks, splitLinkColumns } from "./card-body.js";
|
|
7
|
-
import { CARD_SURFACE_CLASS, hasSeparateCardRows } from "./card-frame.js";
|
|
7
|
+
import { ASSISTANT_FOCUS_CARD_CLASS, CARD_SURFACE_CLASS, hasSeparateCardRows, } from "./card-frame.js";
|
|
8
8
|
import { rowClickHandler } from "./row-click-guard.js";
|
|
9
9
|
import { renderExpandToggle, renderExpansion } from "./row-render-parts.js";
|
|
10
10
|
// The card's <li> opens the row on click; controls inside must not reach it.
|
|
@@ -27,8 +27,17 @@ function renderCardOpenButton(openRow, body) {
|
|
|
27
27
|
openRow();
|
|
28
28
|
}, children: body }));
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
|
|
30
|
+
const CARD_BUTTON_DISPLAYS = new Set([
|
|
31
|
+
"button",
|
|
32
|
+
"link",
|
|
33
|
+
"text",
|
|
34
|
+
"responsive",
|
|
35
|
+
]);
|
|
36
|
+
// The footer line: the AI chip (a `responsive` action) on the left, the other actions and link columns on the right.
|
|
37
|
+
function renderCardFooter(m, row, buttonActions, links) {
|
|
38
|
+
const aiActions = buttonActions.filter((a) => a.display === "responsive");
|
|
39
|
+
const otherActions = buttonActions.filter((a) => a.display !== "responsive");
|
|
40
|
+
return renderStopPropagation("flex items-center justify-between gap-3", `row-${row.id}-card-buttons`, _jsxs(_Fragment, { children: [aiActions.length > 0 && (_jsx(RowActionsCell, { row: row, actions: aiActions, mode: m.rowActionMode, compact: true, small: true })), _jsxs("div", { className: cn("flex items-center gap-3", aiActions.length > 0 && "ml-auto"), children: [links, otherActions.length > 0 && (_jsx(RowActionsCell, { row: row, actions: otherActions, mode: m.rowActionMode, compact: true, small: true }))] })] }));
|
|
32
41
|
}
|
|
33
42
|
function cardLeftPadding(compact) {
|
|
34
43
|
return compact ? "pl-2" : "pl-4";
|
|
@@ -45,26 +54,36 @@ function splitCardActions(m, row, opensRow) {
|
|
|
45
54
|
const cardActions = menuMode && opensRow ? [] : (m.menuActions ?? []);
|
|
46
55
|
return {
|
|
47
56
|
buttonActions: cardActions.filter((a) => !menuMode &&
|
|
48
|
-
(a.display === "button" ||
|
|
57
|
+
(a.display === "button" ||
|
|
58
|
+
a.display === "link" ||
|
|
59
|
+
a.display === "text" ||
|
|
60
|
+
a.display === "responsive") &&
|
|
49
61
|
(a.isVisible === undefined || a.isVisible(row))),
|
|
50
|
-
menuActions: cardActions.filter((a) => menuMode || (a.display
|
|
62
|
+
menuActions: cardActions.filter((a) => menuMode || !CARD_BUTTON_DISPLAYS.has(a.display)),
|
|
51
63
|
};
|
|
52
64
|
}
|
|
65
|
+
function renderCardContent(m, row, main, buttonActions, linkColumns) {
|
|
66
|
+
const hasButtons = buttonActions.length > 0;
|
|
67
|
+
if (linkColumns.length === 0 && !hasButtons)
|
|
68
|
+
return main;
|
|
69
|
+
return (_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [main, hasButtons
|
|
70
|
+
? renderCardFooter(m, row, buttonActions, linkColumns.length > 0 ? renderCardLinks(m, row, linkColumns) : null)
|
|
71
|
+
: renderCardLinks(m, row, linkColumns)] }));
|
|
72
|
+
}
|
|
53
73
|
export function renderCard(m, row, roles) {
|
|
54
74
|
const { rowTone } = m;
|
|
55
75
|
const openRow = m.rowOpener(row);
|
|
56
76
|
const { buttonActions, menuActions } = splitCardActions(m, row, openRow !== undefined);
|
|
57
77
|
const hasMenu = menuActions.length > 0;
|
|
58
|
-
const hasButtons = buttonActions.length > 0;
|
|
59
78
|
const { bodyRoles, linkColumns } = splitLinkColumns(m, row, roles);
|
|
60
79
|
const body = renderCardBody(m, row, bodyRoles);
|
|
61
80
|
const main = openRow !== undefined ? renderCardOpenButton(openRow, body) : body;
|
|
62
81
|
// In a list with row tones every card carries a stripe (neutral = grey) so the cards align.
|
|
63
82
|
const toneClass = cardToneClass(rowTone === undefined ? undefined : (rowTone(row) ?? "neutral"));
|
|
64
83
|
const toned = toneClass !== "";
|
|
65
|
-
const rowItem = (_jsxs("li", { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), className: cn(cardRowBaseClass(m), toneClass,
|
|
84
|
+
const rowItem = (_jsxs("li", { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), className: cn(cardRowBaseClass(m), toneClass, m.focusedRowId === row.id && ASSISTANT_FOCUS_CARD_CLASS,
|
|
66
85
|
// A toned card already pads past its inner 4px stripe (see cardToneClass); a later pl-* would override it.
|
|
67
|
-
!toned && cardLeftPadding(m.expansion !== undefined || m.selection.active), hasMenu ? "pr-2" : "pr-4", m.density.card), ...(openRow !== undefined && { onClick: rowClickHandler(openRow) }), children: [m.selection.cardCheckbox(row), renderExpandToggle(m, row),
|
|
86
|
+
!toned && cardLeftPadding(m.expansion !== undefined || m.selection.active), hasMenu ? "pr-2" : "pr-4", m.density.card), ...(openRow !== undefined && { onClick: rowClickHandler(openRow) }), children: [m.selection.cardCheckbox(row), renderExpandToggle(m, row), renderCardContent(m, row, main, buttonActions, linkColumns), hasMenu && renderCardMenu(m, row, menuActions)] }, row.id));
|
|
68
87
|
if (m.expansion === undefined)
|
|
69
88
|
return rowItem;
|
|
70
89
|
// The expansion is a sibling <li>, outside the row's click target, so
|
|
@@ -29,7 +29,7 @@ function ColumnSortSelect({ columns, sort, onSortChange, testId }) {
|
|
|
29
29
|
// option for it the select would claim "Unsorted" while the list is sorted.
|
|
30
30
|
const currentSortValue = sort !== undefined && sort !== null ? `${sort.field}:${sort.dir}` : "";
|
|
31
31
|
const currentSortIsUnlisted = sort !== undefined && sort !== null && !sortOptions.some((o) => o.value === currentSortValue);
|
|
32
|
-
return (_jsxs("div", { className: "relative flex h-
|
|
32
|
+
return (_jsxs("div", { className: "relative flex h-[37px] items-center gap-1.5 px-4 text-[13px] text-foreground-secondary", children: [_jsx("span", { "aria-hidden": "true", children: sortLabel }), sort !== undefined && sort !== null && _jsx(SortArrow, { className: "size-3.5", "aria-hidden": "true" }), _jsxs("select", { "aria-label": translate?.("kumiko.list.sort.label") ?? "Sort", "data-testid": testId !== undefined ? `${testId}-sort` : "render-list-sort", value: currentSortValue, onChange: (e) => {
|
|
33
33
|
const raw = e.target.value;
|
|
34
34
|
if (raw === "") {
|
|
35
35
|
onSortChange(null);
|
|
@@ -15,7 +15,7 @@ export function renderCardsView(m) {
|
|
|
15
15
|
const toolbarOwnsSort = m.toolbarSort === true && !m.belowSm && hasSortOptionsSelect(m.sortOptions, m.onSortChange);
|
|
16
16
|
const summary = m.belowSm ? sortSummaryText(m) : undefined;
|
|
17
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
|
|
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 && m.plainPhoneCards !== true && (_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
19
|
? cn("m-0 flex list-none flex-col gap-2 p-0 pb-2", m.fillsHeight && "px-4")
|
|
20
20
|
: isInsideCardFrame(m)
|
|
21
21
|
? "m-0 list-none p-0"
|
|
@@ -10,5 +10,6 @@ export declare function columnCellPresentationProps(col: ListColumnViewModel): {
|
|
|
10
10
|
badgeDot?: false | undefined;
|
|
11
11
|
pillField?: string | undefined;
|
|
12
12
|
pillToneField?: string | undefined;
|
|
13
|
-
emptyPlaceholder?: false | undefined;
|
|
13
|
+
emptyPlaceholder?: string | false | undefined;
|
|
14
|
+
dateOnlyAfterDays?: number | undefined;
|
|
14
15
|
};
|
|
@@ -11,5 +11,6 @@ export function columnCellPresentationProps(col) {
|
|
|
11
11
|
...(col.pillField !== undefined && { pillField: col.pillField }),
|
|
12
12
|
...(col.pillToneField !== undefined && { pillToneField: col.pillToneField }),
|
|
13
13
|
...(col.emptyPlaceholder !== undefined && { emptyPlaceholder: col.emptyPlaceholder }),
|
|
14
|
+
...(col.dateOnlyAfterDays !== undefined && { dateOnlyAfterDays: col.dateOnlyAfterDays }),
|
|
14
15
|
};
|
|
15
16
|
}
|
|
@@ -4,11 +4,13 @@ type DensityClasses = {
|
|
|
4
4
|
readonly row: string;
|
|
5
5
|
/** Table body cell; `!` beats the fill-height table's own cell padding. */
|
|
6
6
|
readonly cell: string;
|
|
7
|
+
/** Height of a body cell: the board row is 50px; compact rows stay tight. */
|
|
8
|
+
readonly cellHeight: string;
|
|
7
9
|
/** Header cell; keeps the horizontal inset in line with the body cells. */
|
|
8
10
|
readonly header: string;
|
|
9
11
|
/** Card row below the md breakpoint. */
|
|
10
12
|
readonly card: string;
|
|
11
13
|
};
|
|
12
|
-
/** Comfortable (and a table without `view`) adds
|
|
14
|
+
/** Comfortable (and a table without `view`) adds only the board row height. */
|
|
13
15
|
export declare function densityClasses(view: DataTableViewOptions | undefined, keepsFillEdgeInset: boolean): DensityClasses;
|
|
14
16
|
export {};
|
|
@@ -1,12 +1,19 @@
|
|
|
1
|
-
const
|
|
1
|
+
const ROW_HEIGHT_CLASS = "h-[50px]";
|
|
2
|
+
const NO_DENSITY_CLASSES = {
|
|
3
|
+
row: "",
|
|
4
|
+
cell: "",
|
|
5
|
+
cellHeight: ROW_HEIGHT_CLASS,
|
|
6
|
+
header: "",
|
|
7
|
+
card: "",
|
|
8
|
+
};
|
|
2
9
|
// A fill-height table insets its first and last column by 24px; compact keeps that edge.
|
|
3
10
|
const FILL_EDGE_INSET = " first:pl-6! last:pr-6!";
|
|
4
11
|
const DENSITY_CLASSES = {
|
|
5
12
|
comfortable: NO_DENSITY_CLASSES,
|
|
6
|
-
relaxed: { row: "", cell: "sm:py-3!", header: "", card: "" },
|
|
7
|
-
compact: { row: "h-8", cell: "p-1!", header: "px-1!", card: "min-h-14 py-2" },
|
|
13
|
+
relaxed: { row: "", cell: "sm:py-3!", cellHeight: ROW_HEIGHT_CLASS, header: "", card: "" },
|
|
14
|
+
compact: { row: "h-8", cell: "p-1!", cellHeight: "", header: "px-1!", card: "min-h-14 py-2" },
|
|
8
15
|
};
|
|
9
|
-
/** Comfortable (and a table without `view`) adds
|
|
16
|
+
/** Comfortable (and a table without `view`) adds only the board row height. */
|
|
10
17
|
export function densityClasses(view, keepsFillEdgeInset) {
|
|
11
18
|
if (view === undefined)
|
|
12
19
|
return NO_DENSITY_CLASSES;
|
|
@@ -5,4 +5,4 @@ import type { DataTableModel } from "./use-data-table-state.ts";
|
|
|
5
5
|
export declare function renderExpandToggle(m: DataTableModel, row: ListRowViewModel): ReactNode;
|
|
6
6
|
export declare function renderExpansion(m: DataTableModel, row: ListRowViewModel, as: "row" | "item", colSpan: number): ReactNode;
|
|
7
7
|
export declare function renderBand(m: DataTableModel, item: DataTableBandItem): ReactNode;
|
|
8
|
-
export declare function renderEmptyBlock(m: DataTableModel
|
|
8
|
+
export declare function renderEmptyBlock(m: DataTableModel): ReactNode;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { cn } from "../../lib/cn.js";
|
|
3
2
|
import { TableCell, TableRow } from "../../ui/table.js";
|
|
4
3
|
import { cellTitle } from "../data-table-cell.js";
|
|
5
4
|
import { GroupBand } from "./group-band.js";
|
|
@@ -29,8 +28,7 @@ export function renderExpansion(m, row, as, colSpan) {
|
|
|
29
28
|
export function renderBand(m, item) {
|
|
30
29
|
return _jsx(GroupBand, { item: item, columnOf: m.columnOf });
|
|
31
30
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
return (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-empty` : "render-list-empty", className: cn("flex flex-col items-center justify-center gap-3 px-6 py-10 text-[13px] text-muted-foreground", !embedded && chromeless !== true && !fillsHeight && "rounded-md border border-border-row"), children: emptyState ?? _jsx("span", { children: tableTranslate?.("kumiko.list.no-entries") ?? "No entries." }) }));
|
|
31
|
+
export function renderEmptyBlock(m) {
|
|
32
|
+
const { testId, emptyState, tableTranslate } = m;
|
|
33
|
+
return (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-empty` : "render-list-empty", className: "m-6 flex flex-col items-center justify-center gap-3 rounded-[9px] border border-dashed border-border-strong px-6 py-10 text-[13px] text-muted-foreground [&>:first-child]:font-semibold [&>:first-child]:text-foreground", children: emptyState ?? (_jsx("span", { className: "text-sm font-semibold text-foreground", children: tableTranslate?.("kumiko.list.no-entries") ?? "No entries." })) }));
|
|
36
34
|
}
|
|
@@ -30,7 +30,7 @@ export function sortSummaryText(m) {
|
|
|
30
30
|
direction,
|
|
31
31
|
count,
|
|
32
32
|
noun,
|
|
33
|
-
}) ?? `Sorted by ${active.label} ${direction}
|
|
33
|
+
}) ?? `Sorted by ${active.label} ${direction}`).trim();
|
|
34
34
|
}
|
|
35
35
|
// "Sorted by: <active label>" over a native select; with no matching option only the prefix shows
|
|
36
36
|
// so the control never claims an order the list is not in.
|
|
@@ -38,7 +38,7 @@ export function SortOptionsSelect({ options, sort, onSortChange, testId, classNa
|
|
|
38
38
|
const translate = useOptionalTranslation();
|
|
39
39
|
const active = activeSortOption(options, sort);
|
|
40
40
|
const prefix = translate?.("kumiko.list.sort.prefix") ?? "Sorted by";
|
|
41
|
-
return (_jsxs("div", { className: cn("relative flex h-
|
|
41
|
+
return (_jsxs("div", { className: cn("relative flex h-[37px] items-center gap-1.5 rounded-md text-[13px] text-foreground-secondary focus-within:ring-1 focus-within:ring-ring", summary !== undefined && !bordered && "h-6 text-xs text-muted-foreground", 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`, className: summary === undefined && active !== undefined ? "inline-flex gap-1.5" : undefined, children: summary !== undefined || active === undefined ? ((summary ?? prefix)) : (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-muted-foreground", children: `${prefix}: ` }), _jsx("span", { "data-testid": `${testId}-value`, children: active.label })] })) }), 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
42
|
const picked = options.find((option) => sortOptionValue(option) === e.target.value);
|
|
43
43
|
if (picked !== undefined)
|
|
44
44
|
onSortChange({ field: picked.field, dir: picked.dir });
|
|
@@ -4,8 +4,8 @@ import { cn } from "../../lib/cn.js";
|
|
|
4
4
|
import { TableHead } from "../../ui/table.js";
|
|
5
5
|
import { FIT_CONTENT_CELL_CLASS } from "../data-table-cell.js";
|
|
6
6
|
export const COMPACT_HEADER_CLASS = "text-xs font-semibold";
|
|
7
|
-
/**
|
|
8
|
-
const
|
|
7
|
+
/** Board header: 13.5px regular, ink colour, 37px high, 12px side padding. */
|
|
8
|
+
const HEADER_CLASS = "h-[37px] border-b-[1.5px] border-border-row px-3 text-[13.5px] first:pl-6 last:pr-[34px]";
|
|
9
9
|
// SortableHeader: renders the th header per column, with or without
|
|
10
10
|
// click-sort. Three paths:
|
|
11
11
|
// (a) sortable=false OR no onSortChange -> plain label, no cursor
|
|
@@ -23,13 +23,13 @@ export function SortableHeader({ field, label, sortable, highlighted, numeric, a
|
|
|
23
23
|
...(columnField !== undefined && { "data-column-field": columnField }),
|
|
24
24
|
};
|
|
25
25
|
if (!sortable || onSortChange === undefined) {
|
|
26
|
-
return (_jsxs(TableHead, { "data-testid": `column-${field}`, "data-sortable": sortable === true ? true : undefined, "data-highlighted": highlighted === true ? "true" : undefined, className: cn("font-
|
|
26
|
+
return (_jsxs(TableHead, { "data-testid": `column-${field}`, "data-sortable": sortable === true ? true : undefined, "data-highlighted": highlighted === true ? "true" : undefined, className: cn("font-normal whitespace-normal text-foreground-secondary", HEADER_CLASS, numeric === true && "text-right", actionColumn === true && "sm:text-right", fitContent === true && FIT_CONTENT_CELL_CLASS, highlighted === true && "bg-accent/40", trailing !== undefined && "group/header relative", compact === true && COMPACT_HEADER_CLASS, className), ...cellExtras, children: [actionColumn === true ? _jsx("span", { className: "sm:sr-only", children: label }) : label, trailing] }));
|
|
27
27
|
}
|
|
28
28
|
const Icon = active?.dir === "asc" ? ArrowUp : active?.dir === "desc" ? ArrowDown : ArrowUpDown;
|
|
29
29
|
const next = nextSortState(active?.dir, field);
|
|
30
30
|
return (_jsxs(TableHead, { "data-testid": `column-${field}`, "data-sortable": "true", "data-highlighted": highlighted === true ? "true" : undefined, "aria-sort": ariaSort, className: cn(active !== undefined
|
|
31
31
|
? "font-semibold text-foreground"
|
|
32
|
-
: "font-
|
|
32
|
+
: "font-normal text-foreground-secondary", "whitespace-normal", HEADER_CLASS, numeric === true && "text-right", fitContent === true && FIT_CONTENT_CELL_CLASS, highlighted === true && "bg-accent/40", trailing !== undefined && "group/header relative", compact === true && COMPACT_HEADER_CLASS, className), ...cellExtras, children: [_jsxs("button", { type: "button", onClick: () => onSortChange(next), className: cn("group/sort inline-flex h-8 items-center gap-1.5 rounded-sm px-2 -mx-2 text-[13.5px] [font-weight:inherit]", "hover:bg-accent hover:text-accent-foreground", "focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", active !== undefined && "text-foreground", compact === true && "text-xs"), children: [_jsx("span", { children: label }), _jsx(Icon, { "data-sort-icon": active === undefined ? "idle" : "active", className: cn("size-3.5", active === undefined &&
|
|
33
33
|
"opacity-0 group-hover/sort:opacity-40 group-focus-visible/sort:opacity-40"), "aria-hidden": "true" })] }), trailing] }));
|
|
34
34
|
}
|
|
35
35
|
// 3-state toggle: no sort -> asc -> desc -> no sort. Idiomatic for
|
|
@@ -5,6 +5,7 @@ import { rowToneClass } from "../data-table-cell.js";
|
|
|
5
5
|
import { HintReasonRowScope, hintReasonOf } from "../hint-reason-row.js";
|
|
6
6
|
import { RowActionsCell } from "../row-actions.js";
|
|
7
7
|
import { ActionsBodyCell } from "./actions-column.js";
|
|
8
|
+
import { ASSISTANT_FOCUS_ROW_CLASS } from "./card-frame.js";
|
|
8
9
|
import { bandClassName, bandReactKey, bandTestId } from "./group-band.js";
|
|
9
10
|
import { rowClickHandler } from "./row-click-guard.js";
|
|
10
11
|
import { renderBand, renderExpandToggle, renderExpansion } from "./row-render-parts.js";
|
|
@@ -27,7 +28,7 @@ function renderDataRow(m, row) {
|
|
|
27
28
|
const opensOnClick = openRow !== undefined;
|
|
28
29
|
const keyboard = m.keyboardRow(row.id, openRow);
|
|
29
30
|
const reasonHint = m.columns.find((col) => col.hint !== undefined && hintReasonOf(col.hint, row.values) !== undefined)?.hint;
|
|
30
|
-
const rowElements = (_jsxs(_Fragment, { children: [_jsxs(TableRow, { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), onClick: rowClickHandler(openRow), className: cn(rowToneClass(rowTone?.(row)), opensOnClick && "cursor-pointer", "[&:has(+[data-reason-row])]:border-b-0", m.fillsHeight && "h-
|
|
31
|
+
const rowElements = (_jsxs(_Fragment, { children: [_jsxs(TableRow, { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), onClick: rowClickHandler(openRow), className: cn(rowToneClass(rowTone?.(row)), opensOnClick && "cursor-pointer", m.focusedRowId === row.id && ASSISTANT_FOCUS_ROW_CLASS, "[&:has(+[data-reason-row])]:border-b-0", m.fillsHeight && "h-[50px] border-border-row hover:bg-muted", density.row, keyboard.className), ...keyboard.props, children: [m.selection.bodyCell(row, m.pins.bodyCell(SELECT_COLUMN_KEY)), m.expansion !== undefined && renderExpandCell(m, row), m.columns.map((col, colIndex) => renderDataCell(m, row, col, colIndex, opensOnClick)), m.hasTableActions && tableActions !== undefined && renderActionsCell(m, row, tableActions)] }), renderExpansion(m, row, "row", m.fullColSpan)] }));
|
|
31
32
|
return (_jsx(HintReasonRowScope, { hint: reasonHint, row: row.values, renderBoxRow: (box) => (_jsx(TableRow, { "data-testid": `${m.rowTestId(row)}-reason`, "data-reason-row": "true", children: _jsx(TableCell, { colSpan: m.fullColSpan, children: box }) })), children: rowElements }, row.id));
|
|
32
33
|
}
|
|
33
34
|
export function renderTableBody(m) {
|
|
@@ -14,9 +14,7 @@ export function FlushTable({ className, ...props }) {
|
|
|
14
14
|
// in SortableHeader: a `[&_th]:font-*` rule here would outrank it.
|
|
15
15
|
// Child selectors only: an expanded row nests a whole table inside a cell, and
|
|
16
16
|
// descendant selectors would make its header sticky and re-pad its cells.
|
|
17
|
-
export const FILL_TABLE_CLASS = cn("[&>thead>tr>th]:sticky [&>thead>tr>th]:top-0 [&>thead>tr>th]:z-10 [&>thead>tr>th]:h-
|
|
18
|
-
// The small-caps header size of SortableHeader; the child selectors above would outrank it.
|
|
19
|
-
"sm:[&>thead>tr>th]:text-[11px] sm:[&>thead>tr>th_button]:text-[11px]", "[&>*>tr>:first-child]:pl-6 [&>*>tr>:last-child]:pr-6");
|
|
17
|
+
export const FILL_TABLE_CLASS = cn("[&>thead>tr>th]:sticky [&>thead>tr>th]:top-0 [&>thead>tr>th]:z-10 [&>thead>tr>th]:h-[37px] [&>thead>tr>th]:bg-background [&>thead>tr>th]:px-3 [&>thead>tr>th]:text-[13.5px]", "[&>thead>tr>th]:shadow-[inset_0_-1.5px_0_var(--color-border-row)] [&>thead>tr>th_button]:text-[13.5px] [&>tbody>tr>td]:px-3 [&>tbody>tr>td]:py-0", "[&>*>tr>:first-child]:pl-6 [&>*>tr>:last-child]:pr-[34px]");
|
|
20
18
|
// `!`: beats the first/last-child padding of FILL_TABLE_CLASS, which would
|
|
21
19
|
// otherwise widen the narrow toggle column / pad the full-width expansion cell.
|
|
22
20
|
// The nested table's sticky actions cell (last td) gets the muted surface
|
|
@@ -8,11 +8,10 @@ import { DataTableFooter } from "./table-footer.js";
|
|
|
8
8
|
import { renderTableView } from "./table-view.js";
|
|
9
9
|
// The pager is ALWAYS rendered below the table (even with rows=[]) so the
|
|
10
10
|
// user can page back on a filter hit of zero without losing the list.
|
|
11
|
-
//
|
|
12
|
-
// infinite scroll: the caller sets either pager OR onReachEnd.
|
|
11
|
+
// Incompatible with infinite scroll: the caller sets either pager OR onReachEnd.
|
|
13
12
|
function renderPager(m) {
|
|
14
13
|
const { pager, serverGroups, testId } = m;
|
|
15
|
-
if (pager === undefined ||
|
|
14
|
+
if (pager === undefined || serverGroups !== undefined)
|
|
16
15
|
return undefined;
|
|
17
16
|
return (_jsx(Pager, { page: pager.page, limit: pager.limit, total: pager.total, onPageChange: pager.onPageChange, ...(pager.pageSizeOptions !== undefined && { pageSizeOptions: pager.pageSizeOptions }), ...(pager.onPageSizeChange !== undefined && { onPageSizeChange: pager.onPageSizeChange }), testId: testId !== undefined ? `${testId}-pager` : "render-list-pager", pinned: m.fillsHeight || isInsideCardFrame(m), plain: m.isNarrow && hasSeparateCardRows(m) }));
|
|
18
17
|
}
|
|
@@ -25,7 +24,7 @@ function renderSentinel(m, pagerElement) {
|
|
|
25
24
|
}
|
|
26
25
|
function renderTableBodyContent(m) {
|
|
27
26
|
if (m.isEmpty)
|
|
28
|
-
return
|
|
27
|
+
return renderEmptyBlock(m);
|
|
29
28
|
return m.isNarrow ? renderCardsView(m) : renderTableView(m);
|
|
30
29
|
}
|
|
31
30
|
export function renderTableContent(m) {
|
|
@@ -33,17 +32,14 @@ export function renderTableContent(m) {
|
|
|
33
32
|
const tableContent = renderTableBodyContent(m);
|
|
34
33
|
const pagerElement = renderPager(m);
|
|
35
34
|
const sentinelElement = renderSentinel(m, pagerElement);
|
|
36
|
-
|
|
35
|
+
// An empty list is only the dashed empty block, with no card frame around it.
|
|
36
|
+
const framed = isInsideCardFrame(m) && !m.isEmpty;
|
|
37
37
|
// With scrollBody the footer (pager, else the entry count) sits OUTSIDE the
|
|
38
38
|
// scroll surface so it stays put at any row count; the infinite sentinel
|
|
39
39
|
// stays INSIDE, or it would never intersect the scrollport.
|
|
40
40
|
const content = m.fillsHeight ? (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : "render-list-scroll", className: cn("min-h-0 flex-1 overflow-auto bg-card", !framed && "border-t border-border"), children: [tableContent, sentinelElement] })) : (_jsxs(_Fragment, { children: [tableContent, sentinelElement] }));
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
const footer = hasEmptyState
|
|
44
|
-
? undefined
|
|
45
|
-
: (pagerElement ??
|
|
46
|
-
(m.fillsHeight ? (_jsx(DataTableFooter, { count: serverGroups?.totalCount ?? m.rows.length, ...(itemNoun !== undefined && { itemNoun }), testId: testId !== undefined ? `${testId}-footer` : "render-list-footer" })) : undefined));
|
|
41
|
+
const footer = pagerElement ??
|
|
42
|
+
(m.fillsHeight && m.hideCountFooter !== true ? (_jsx(DataTableFooter, { count: serverGroups?.totalCount ?? m.rows.length, ...(itemNoun !== undefined && { itemNoun }), testId: testId !== undefined ? `${testId}-footer` : "render-list-footer" })) : undefined);
|
|
47
43
|
// Frame card: content and footer share one bordered card. A fill-height card is as tall as
|
|
48
44
|
// its rows and shrinks into the scroll container; the 24px sides match the toolbar's inset.
|
|
49
45
|
return (_jsxs(_Fragment, { children: [m.selection.bar, framed ? (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-frame` : "render-list-frame", className: cn(CARD_SURFACE_CLASS, "overflow-hidden", m.fillsHeight && "mx-6 mb-6 flex min-h-0 flex-col"), children: [content, footer] })) : (_jsxs(_Fragment, { children: [content, footer] }))] }));
|
|
@@ -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;
|