@cosmicdrift/kumiko-renderer 0.415.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 +2 -5
- package/dist/app/action-form-body.js +50 -22
- package/dist/app/action-form-support.d.ts +4 -1
- package/dist/app/action-form-support.js +8 -4
- package/dist/app/client-actions.js +6 -4
- package/dist/app/config-edit-body.js +83 -82
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/extension-sections.d.ts +2 -0
- 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 +29 -8
- package/dist/app/projection-detail-guidance.d.ts +2 -1
- package/dist/app/projection-detail-guidance.js +45 -30
- package/dist/app/projection-detail-header-model.d.ts +1 -1
- package/dist/app/projection-detail-header-model.js +14 -6
- 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 +31 -4
- package/dist/app/projection-detail-navigation.d.ts +4 -0
- package/dist/app/projection-detail-navigation.js +5 -1
- 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/screen-shared.d.ts +1 -0
- package/dist/app/screen-shared.js +23 -3
- package/dist/app/use-projection-detail-actions.d.ts +16 -1
- package/dist/app/use-projection-detail-actions.js +23 -3
- package/dist/app/use-projection-detail-data.d.ts +2 -0
- package/dist/app/use-projection-detail-data.js +53 -10
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/ai-assist-payload.d.ts +2 -0
- package/dist/components/ai-assist-payload.js +8 -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 +3 -2
- package/dist/components/edit-mounts.js +2 -2
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.d.ts +10 -0
- package/dist/components/multi-select-chips.js +19 -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 +52 -35
- package/dist/components/related-photo-grid.d.ts +11 -0
- package/dist/components/related-photo-grid.js +54 -0
- package/dist/components/render-edit-action-button.d.ts +2 -2
- 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.d.ts +2 -1
- package/dist/components/render-edit-header-actions.js +18 -1
- package/dist/components/render-edit-layout.js +5 -3
- package/dist/components/render-edit-logic.js +1 -0
- package/dist/components/render-edit-section-kinds.js +59 -10
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +22 -1
- package/dist/components/render-field-ai-assist.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +90 -0
- package/dist/components/render-field-choice-inputs.js +4 -0
- package/dist/components/render-field-control.d.ts +1 -1
- package/dist/components/render-field-control.js +19 -9
- package/dist/components/render-field-value-chips.d.ts +9 -0
- package/dist/components/render-field-value-chips.js +47 -0
- package/dist/components/render-field-write-only.js +12 -4
- package/dist/components/render-list-hint-columns.d.ts +2 -0
- package/dist/components/render-list-hint-columns.js +43 -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-edit-sections.js +5 -1
- 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.d.ts +1 -0
- package/dist/headless/format/index.js +21 -0
- package/dist/headless/format/phone.d.ts +1 -0
- package/dist/headless/format/phone.js +8 -0
- package/dist/headless/format/relative-time.d.ts +15 -0
- package/dist/headless/format/relative-time.js +63 -0
- package/dist/headless/format/safe-locale.d.ts +1 -0
- package/dist/headless/format/safe-locale.js +13 -0
- package/dist/headless/index.d.ts +2 -2
- package/dist/headless/index.js +2 -2
- package/dist/headless/view-model/edit.d.ts +3 -2
- package/dist/headless/view-model/edit.js +162 -36
- package/dist/headless/view-model/field-text.d.ts +9 -0
- package/dist/headless/view-model/field-text.js +19 -0
- package/dist/headless/view-model/index.d.ts +1 -0
- package/dist/headless/view-model/index.js +1 -0
- package/dist/headless/view-model/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +76 -5
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +9 -2
- package/dist/index.d.ts +1 -1
- package/dist/primitives-record-guidance.d.ts +32 -1
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +44 -86
- 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 +8 -3
- package/dist/web/app/dashboard-list-panel.js +8 -4
- package/dist/web/app/dashboard-panel-columns.d.ts +9 -0
- package/dist/web/app/dashboard-panel-columns.js +14 -0
- 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 +4 -4
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +24 -3
- package/dist/web/app/dashboard-text-panel.d.ts +1 -0
- package/dist/web/app/dashboard-text-panel.js +18 -11
- package/dist/web/app/relative-time.d.ts +0 -5
- package/dist/web/app/relative-time.js +11 -21
- 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 +24 -8
- 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 +34 -10
- 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 +4 -1
- package/dist/web/primitives/data-table/data-cell-props.js +3 -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-click-guard.d.ts +2 -0
- package/dist/web/primitives/data-table/row-click-guard.js +19 -0
- 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 +3 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +6 -6
- 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 +17 -3
- package/dist/web/primitives/data-table-cell.js +130 -36
- 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 +15 -11
- package/dist/web/primitives/drawer.js +2 -3
- 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 +6 -3
- package/dist/web/primitives/form.js +6 -8
- package/dist/web/primitives/index.js +4 -0
- 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 +50 -13
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- package/dist/web/primitives/locale-number.d.ts +0 -1
- package/dist/web/primitives/locale-number.js +1 -13
- package/dist/web/primitives/money-input.js +10 -8
- package/dist/web/primitives/narrow-pinned-footer.js +7 -3
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +11 -5
- 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.d.ts +3 -0
- package/dist/web/primitives/photo-grid.js +6 -0
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +7 -16
- package/dist/web/primitives/record-summary.d.ts +1 -1
- package/dist/web/primitives/record-summary.js +8 -3
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/step-list.d.ts +3 -0
- package/dist/web/primitives/step-list.js +11 -0
- 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 +6 -1
- package/dist/web/widgets/dashboard-list.js +12 -7
- package/dist/web/widgets/drawer-panel-class.js +1 -1
- 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 +105 -0
- package/src/web/styles.css +3 -2
|
@@ -8,6 +8,7 @@ const ICON_COLOR_CLASS = {
|
|
|
8
8
|
hint: "text-primary",
|
|
9
9
|
info: "text-primary",
|
|
10
10
|
primary: "text-primary",
|
|
11
|
+
assist: "text-primary",
|
|
11
12
|
ok: "text-status-ok",
|
|
12
13
|
warning: "text-status-warn",
|
|
13
14
|
error: "text-destructive",
|
|
@@ -23,6 +24,8 @@ function variantClass(variant, compact) {
|
|
|
23
24
|
return "border-status-ok/30 bg-status-ok-surface text-foreground";
|
|
24
25
|
case "primary":
|
|
25
26
|
return "border-l-4 border-l-primary bg-card text-card-foreground";
|
|
27
|
+
case "assist":
|
|
28
|
+
return "rounded-[9px] border-transparent border-l-[3px] border-l-primary bg-secondary px-3 py-2.5 text-primary font-medium";
|
|
26
29
|
case "hint":
|
|
27
30
|
return compact
|
|
28
31
|
? "border-border bg-card text-foreground"
|
|
@@ -42,35 +45,48 @@ function BannerParts({ parts }) {
|
|
|
42
45
|
return part.strong === true ? (_jsx("strong", { className: "font-semibold", children: part.text }, key)) : (_jsx("span", { children: part.text }, key));
|
|
43
46
|
});
|
|
44
47
|
}
|
|
45
|
-
function BannerText({ compact, title: fullTitle, narrowTitle, narrowText, titleTestId, children: fullText, parts, actionsBelow, inline, }) {
|
|
48
|
+
function BannerText({ compact, title: fullTitle, narrowTitle, narrowText, titleTestId, children: fullText, parts, actionsBelow, inline, wrapsActions, }) {
|
|
46
49
|
const narrow = useIsBelowSmViewport();
|
|
47
50
|
const title = narrow && narrowTitle !== undefined ? narrowTitle : fullTitle;
|
|
48
51
|
const showsNarrowText = narrow && narrowText !== undefined;
|
|
49
52
|
const children = showsNarrowText ? narrowText : fullText;
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
const text = { title, children, showsNarrowText, titleTestId, parts, wrapsActions };
|
|
54
|
+
if (inline && !compact && title !== undefined)
|
|
55
|
+
return _jsx(InlineTitledBannerText, { ...text });
|
|
56
|
+
if (compact || inline)
|
|
57
|
+
return _jsx(CompactBannerText, { inline: inline, ...text });
|
|
58
|
+
return (_jsxs("div", { className: "min-w-0 flex-1", children: [title !== undefined && (_jsx("div", { "data-testid": titleTestId, className: "font-semibold", children: title })), children, !showsNarrowText && _jsx(BannerParts, { parts: parts }), actionsBelow] }));
|
|
59
|
+
}
|
|
60
|
+
function InlineTitledBannerText({ title, children, showsNarrowText, titleTestId, parts, wrapsActions, }) {
|
|
61
|
+
return (_jsxs("div", { className: cn("min-w-0 grow", wrapsActions && "max-sm:min-w-[10rem] max-sm:basis-0"), children: [_jsx("div", { "data-testid": titleTestId, className: cn("text-xs text-muted-foreground", !showsNarrowText && "max-sm:text-sm max-sm:font-semibold max-sm:text-foreground"), children: title }), _jsxs("div", { className: cn(!showsNarrowText && "max-sm:hidden"), children: [children, !showsNarrowText && _jsx(BannerParts, { parts: parts })] })] }));
|
|
54
62
|
}
|
|
55
|
-
function
|
|
63
|
+
function CompactBannerText({ inline, title, children, showsNarrowText, titleTestId, parts, wrapsActions, }) {
|
|
64
|
+
return (_jsxs("div", { className: cn("min-w-0 grow", wrapsActions && "max-sm:min-w-[10rem] max-sm:basis-0"), children: [title !== undefined && (_jsxs(_Fragment, { children: [_jsx("strong", { "data-testid": titleTestId, className: "font-semibold", children: title }), " "] })), _jsxs("span", { className: cn(inline && !showsNarrowText && "max-sm:hidden"), children: [children, !showsNarrowText && _jsx(BannerParts, { parts: parts })] })] }));
|
|
65
|
+
}
|
|
66
|
+
function bannerLayoutClass(variant, compact, actionsBelow, wrapsActions) {
|
|
56
67
|
return cn("relative flex w-full items-center border", compact ? "gap-2 rounded-md px-2.5 py-2 text-[13px]" : "gap-3 rounded-lg px-3.5 py-2.5 text-sm",
|
|
57
68
|
// Viewport breakpoint like the form footer bar; actions drop below the text on phones.
|
|
58
69
|
!compact &&
|
|
59
70
|
!actionsBelow &&
|
|
60
71
|
variant === "primary" &&
|
|
61
|
-
"flex-col items-start sm:flex-row sm:items-center", actionsBelow && "items-start", variantClass(variant, compact));
|
|
72
|
+
"flex-col items-start sm:flex-row sm:items-center", actionsBelow && "items-start", wrapsActions && "max-sm:flex-wrap", variantClass(variant, compact));
|
|
73
|
+
}
|
|
74
|
+
// On phones the actions leave the text line and wrap below it instead of squeezing the text.
|
|
75
|
+
function wrapsActionsOnPhone(variant, compact, actionsBelow, hasActions) {
|
|
76
|
+
return !compact && !actionsBelow && hasActions && variant !== "primary";
|
|
62
77
|
}
|
|
63
78
|
export function DefaultBanner({ variant = "info", density = "default", icon, title, narrowTitle, narrowText, titleTestId, children, parts, actions, actionsPlacement = "end", padded, inline = false, testId, id, }) {
|
|
64
79
|
const isError = variant === "error";
|
|
65
80
|
const compact = density === "compact";
|
|
66
81
|
// A compact banner is one line, so its actions always stay at the end.
|
|
67
82
|
const actionsBelow = actionsPlacement === "below" && !compact && actions !== undefined;
|
|
83
|
+
const wrapsActions = wrapsActionsOnPhone(variant, compact, actionsBelow, actions !== undefined);
|
|
68
84
|
// `id` is set when a <Field> wraps this Banner as its control (see
|
|
69
85
|
// BannerProps.id). A <div> isn't labelable, so a <label htmlFor> pointing
|
|
70
86
|
// at it is inert for screen readers — role="group" + aria-labelledby is
|
|
71
87
|
// the actual mechanism, pointed at the label id Field emits (fieldLabelId).
|
|
72
88
|
const bannerRole = id !== undefined ? "group" : isError ? "alert" : undefined;
|
|
73
|
-
const banner = (_jsxs("div", { role: bannerRole, ...(id !== undefined && { "aria-labelledby": fieldLabelId(id) }), "data-testid": testId, "data-variant": variant, "data-density": density, className: bannerLayoutClass(variant, compact, actionsBelow), children: [icon !== undefined && (_jsx(Icon, { name: icon, className: cn("size-3.5 shrink-0", ICON_COLOR_CLASS[variant]) })), _jsx(BannerText, { compact: compact, inline: inline, title: title, narrowTitle: narrowTitle, narrowText: narrowText, titleTestId: titleTestId, parts: parts, actionsBelow: actionsBelow ? (_jsx("div", { "data-slot": "actions", className: "mt-3 flex flex-wrap gap-2", children: actions })) : undefined, children: children }), !actionsBelow && actions !== undefined && (_jsx("div", { "data-slot": "actions", className: cn(compact && "shrink-0"), children: actions }))] }));
|
|
89
|
+
const banner = (_jsxs("div", { role: bannerRole, ...(id !== undefined && { "aria-labelledby": fieldLabelId(id) }), "data-testid": testId, "data-variant": variant, "data-density": density, className: bannerLayoutClass(variant, compact, actionsBelow, wrapsActions), children: [icon !== undefined && (_jsx(Icon, { name: icon, className: cn("size-3.5 shrink-0", ICON_COLOR_CLASS[variant]) })), _jsx(BannerText, { compact: compact, inline: inline, wrapsActions: wrapsActions, title: title, narrowTitle: narrowTitle, narrowText: narrowText, titleTestId: titleTestId, parts: parts, actionsBelow: actionsBelow ? (_jsx("div", { "data-slot": "actions", className: "mt-3 flex flex-wrap gap-2", children: actions })) : undefined, children: children }), !actionsBelow && actions !== undefined && (_jsx("div", { "data-slot": "actions", className: cn(compact && "shrink-0", wrapsActions && "max-sm:flex max-sm:w-full max-sm:flex-wrap max-sm:gap-2"), children: actions }))] }));
|
|
74
90
|
// Page state: the banner sits alone in main (which no longer has padding).
|
|
75
91
|
// The wrapper adds 24px outer spacing so the banner does not stick
|
|
76
92
|
// edge-to-edge to the sidebar/browser.
|
|
@@ -11,12 +11,14 @@ function cardBodyPadding(inline, hasHeader) {
|
|
|
11
11
|
? "px-[var(--card-padding)] pb-[var(--card-padding)]"
|
|
12
12
|
: "p-[var(--card-padding)]";
|
|
13
13
|
}
|
|
14
|
-
function CardTitleRow({ slots, inline, }) {
|
|
14
|
+
function CardTitleRow({ slots, inline, labelTitle, }) {
|
|
15
15
|
const { title, subtitle, headerActions } = slots;
|
|
16
16
|
if (inline) {
|
|
17
17
|
return (_jsxs("div", { className: "flex flex-wrap items-baseline gap-x-2.5 gap-y-1", children: [title !== undefined && _jsx("h3", { className: "m-0 text-sm font-semibold", children: title }), subtitle !== undefined && (_jsx("div", { className: "text-[12.5px] text-muted-foreground", children: subtitle })), headerActions !== undefined && _jsx("div", { className: "ml-auto", children: headerActions })] }));
|
|
18
18
|
}
|
|
19
|
-
return (_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [title !== undefined && (_jsx("h3", { className:
|
|
19
|
+
return (_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [title !== undefined && (_jsx("h3", { className: labelTitle
|
|
20
|
+
? "text-[12.5px] font-semibold uppercase leading-none tracking-[0.06em] text-muted-foreground"
|
|
21
|
+
: "text-base font-semibold leading-none tracking-tight", children: title })), subtitle !== undefined && _jsx("div", { className: "text-sm text-muted-foreground", children: subtitle })] }), headerActions] }));
|
|
20
22
|
}
|
|
21
23
|
// Generic card chrome (rounded-xl like the entity card), slot- and
|
|
22
24
|
// options-based so the contract grows additively and consumers never have
|
|
@@ -32,7 +34,7 @@ export function DefaultCard({ slots, options, className, testId, dataAttributes,
|
|
|
32
34
|
const s = slots ?? {};
|
|
33
35
|
const inlineHeader = options?.headerLayout === "inline";
|
|
34
36
|
const hasTitleRow = s.title !== undefined || s.subtitle !== undefined || s.headerActions !== undefined;
|
|
35
|
-
const defaultHeader = hasTitleRow || s.headerContent !== undefined ? (_jsxs("div", { className: cn("flex flex-col gap-3", inlineHeader ? "px-4 pt-3.5" : "px-[var(--card-padding)] pt-6 pb-4", fillHeight && "shrink-0"), children: [hasTitleRow && _jsx(CardTitleRow, { slots: s, inline: inlineHeader }), s.headerContent] })) : null;
|
|
37
|
+
const defaultHeader = hasTitleRow || s.headerContent !== undefined ? (_jsxs("div", { className: cn("flex flex-col gap-3", inlineHeader ? "px-4 pt-3.5" : "px-[var(--card-padding)] pt-6 pb-4", fillHeight && "shrink-0"), children: [hasTitleRow && (_jsx(CardTitleRow, { slots: s, inline: inlineHeader, labelTitle: options?.titleStyle === "label" })), s.headerContent] })) : null;
|
|
36
38
|
const header = s.header ?? defaultHeader;
|
|
37
39
|
const hasHeader = header !== null && header !== undefined;
|
|
38
40
|
const card = (_jsxs("div", { ...dataAttributes, "data-slot": "card", "data-testid": testId, className: cn(framed ? cardSurface({ radius }) : "flex flex-col",
|
|
@@ -19,8 +19,8 @@ import { useEffect, useState } from "react";
|
|
|
19
19
|
import { REFERENCE_SEARCH_DEBOUNCE_MS, useTranslation } from "../../index.js";
|
|
20
20
|
import { cn } from "../lib/cn.js";
|
|
21
21
|
import { groupOptions } from "./option-groups.js";
|
|
22
|
-
const triggerClass = "flex h-
|
|
23
|
-
"rounded-
|
|
22
|
+
const triggerClass = "flex h-[38px] w-full min-w-0 items-center justify-between gap-2 " +
|
|
23
|
+
"rounded-[7px] border-[1.5px] border-input text-left max-md:min-h-11 " +
|
|
24
24
|
"bg-transparent px-3 py-1 text-sm shadow-sm transition-colors " +
|
|
25
25
|
"placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 " +
|
|
26
26
|
"focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";
|
|
@@ -19,7 +19,7 @@ export function ActionsHeaderCell({ label, style, absorbsLeftover, }) {
|
|
|
19
19
|
// preceding data column instead of the (already narrow)
|
|
20
20
|
// page edge. No border-l: a permanent divider looks heavy;
|
|
21
21
|
// the sticky bg already sets the column apart during scroll.
|
|
22
|
-
className: "w-px text-right text-muted-foreground md:sticky md:right-0 md:z-10 md:bg-
|
|
22
|
+
className: "w-px text-right text-muted-foreground md:sticky md:right-0 md:z-10 md:bg-background", "aria-label": label, style: absorbsLeftover ? { ...style, width: "auto" } : style }));
|
|
23
23
|
}
|
|
24
24
|
export function ActionsBodyCell({ testId, fillsHeight, measureContent, children, }) {
|
|
25
25
|
return (_jsx(TableCell, { "data-testid": testId,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type cardColumnRoles } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
|
-
import type
|
|
2
|
+
import { type ReactNode } from "react";
|
|
3
3
|
import type { ListColumnViewModel, ListRowViewModel } from "../../../headless/index.ts";
|
|
4
4
|
import type { DataTableModel } from "./use-data-table-state.ts";
|
|
5
5
|
export type CardRoles = ReturnType<typeof cardColumnRoles<ListColumnViewModel>>;
|
|
@@ -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,11 @@
|
|
|
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
|
+
import { rowClickHandler } from "./row-click-guard.js";
|
|
8
9
|
import { renderExpandToggle, renderExpansion } from "./row-render-parts.js";
|
|
9
10
|
// The card's <li> opens the row on click; controls inside must not reach it.
|
|
10
11
|
function renderStopPropagation(className, testId, children) {
|
|
@@ -14,7 +15,11 @@ function renderCardMenu(m, row, menuActions) {
|
|
|
14
15
|
return renderStopPropagation("shrink-0", undefined, _jsx(RowActionsCell, { row: row, actions: menuActions, mode: m.rowActionMode, rowIsLink: m.onRowClick !== undefined, compact: true }));
|
|
15
16
|
}
|
|
16
17
|
function renderCardOpenButton(openRow, body) {
|
|
17
|
-
return (_jsx("button", { type: "button", className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 bg-transparent p-0 text-left",
|
|
18
|
+
return (_jsx("button", { type: "button", className: "flex min-w-0 flex-1 cursor-pointer items-center gap-2 bg-transparent p-0 text-left", onClick: (e) => {
|
|
19
|
+
// The card's click guard skips clicks on buttons, so this one opens the row itself.
|
|
20
|
+
e.stopPropagation();
|
|
21
|
+
openRow();
|
|
22
|
+
}, onKeyDown: (e) => {
|
|
18
23
|
if (e.key !== "Enter")
|
|
19
24
|
return;
|
|
20
25
|
e.preventDefault();
|
|
@@ -22,8 +27,17 @@ function renderCardOpenButton(openRow, body) {
|
|
|
22
27
|
openRow();
|
|
23
28
|
}, children: body }));
|
|
24
29
|
}
|
|
25
|
-
|
|
26
|
-
|
|
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 }))] })] }));
|
|
27
41
|
}
|
|
28
42
|
function cardLeftPadding(compact) {
|
|
29
43
|
return compact ? "pl-2" : "pl-4";
|
|
@@ -40,26 +54,36 @@ function splitCardActions(m, row, opensRow) {
|
|
|
40
54
|
const cardActions = menuMode && opensRow ? [] : (m.menuActions ?? []);
|
|
41
55
|
return {
|
|
42
56
|
buttonActions: cardActions.filter((a) => !menuMode &&
|
|
43
|
-
(a.display === "button" ||
|
|
57
|
+
(a.display === "button" ||
|
|
58
|
+
a.display === "link" ||
|
|
59
|
+
a.display === "text" ||
|
|
60
|
+
a.display === "responsive") &&
|
|
44
61
|
(a.isVisible === undefined || a.isVisible(row))),
|
|
45
|
-
menuActions: cardActions.filter((a) => menuMode || (a.display
|
|
62
|
+
menuActions: cardActions.filter((a) => menuMode || !CARD_BUTTON_DISPLAYS.has(a.display)),
|
|
46
63
|
};
|
|
47
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
|
+
}
|
|
48
73
|
export function renderCard(m, row, roles) {
|
|
49
74
|
const { rowTone } = m;
|
|
50
75
|
const openRow = m.rowOpener(row);
|
|
51
76
|
const { buttonActions, menuActions } = splitCardActions(m, row, openRow !== undefined);
|
|
52
77
|
const hasMenu = menuActions.length > 0;
|
|
53
|
-
const hasButtons = buttonActions.length > 0;
|
|
54
78
|
const { bodyRoles, linkColumns } = splitLinkColumns(m, row, roles);
|
|
55
79
|
const body = renderCardBody(m, row, bodyRoles);
|
|
56
80
|
const main = openRow !== undefined ? renderCardOpenButton(openRow, body) : body;
|
|
57
81
|
// In a list with row tones every card carries a stripe (neutral = grey) so the cards align.
|
|
58
82
|
const toneClass = cardToneClass(rowTone === undefined ? undefined : (rowTone(row) ?? "neutral"));
|
|
59
83
|
const toned = toneClass !== "";
|
|
60
|
-
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,
|
|
61
85
|
// A toned card already pads past its inner 4px stripe (see cardToneClass); a later pl-* would override it.
|
|
62
|
-
!toned && cardLeftPadding(m.expansion !== undefined || m.selection.active), hasMenu ? "pr-2" : "pr-4", m.density.card), ...(openRow !== undefined && { onClick: 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));
|
|
63
87
|
if (m.expansion === undefined)
|
|
64
88
|
return rowItem;
|
|
65
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"
|
|
@@ -8,5 +8,8 @@ export declare function columnCellPresentationProps(col: ListColumnViewModel): {
|
|
|
8
8
|
display?: import("../../../headless/index.ts").ListColumnCellDisplay | undefined;
|
|
9
9
|
badgeToneField?: string | undefined;
|
|
10
10
|
badgeDot?: false | undefined;
|
|
11
|
-
|
|
11
|
+
pillField?: string | undefined;
|
|
12
|
+
pillToneField?: string | undefined;
|
|
13
|
+
emptyPlaceholder?: string | false | undefined;
|
|
14
|
+
dateOnlyAfterDays?: number | undefined;
|
|
12
15
|
};
|
|
@@ -8,6 +8,9 @@ export function columnCellPresentationProps(col) {
|
|
|
8
8
|
...(col.display !== undefined && { display: col.display }),
|
|
9
9
|
...(col.badgeToneField !== undefined && { badgeToneField: col.badgeToneField }),
|
|
10
10
|
...(col.badgeDot !== undefined && { badgeDot: col.badgeDot }),
|
|
11
|
+
...(col.pillField !== undefined && { pillField: col.pillField }),
|
|
12
|
+
...(col.pillToneField !== undefined && { pillToneField: col.pillToneField }),
|
|
11
13
|
...(col.emptyPlaceholder !== undefined && { emptyPlaceholder: col.emptyPlaceholder }),
|
|
14
|
+
...(col.dateOnlyAfterDays !== undefined && { dateOnlyAfterDays: col.dateOnlyAfterDays }),
|
|
12
15
|
};
|
|
13
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;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
const INTERACTIVE_SELECTOR = "a[href], button, input, select, textarea, label, [role='button'], [role='link'], [role='switch'], [role='checkbox'], [role='menuitem'], [contenteditable='true']";
|
|
2
|
+
// React bubbles synthetic events through portals, so a click inside a drawer
|
|
3
|
+
// rendered from a custom cell reaches the row even though its DOM is elsewhere.
|
|
4
|
+
export function rowClickHandler(openRow) {
|
|
5
|
+
if (openRow === undefined)
|
|
6
|
+
return undefined;
|
|
7
|
+
return (event) => {
|
|
8
|
+
const { target, currentTarget } = event;
|
|
9
|
+
if (!(target instanceof Element) || !currentTarget.contains(target))
|
|
10
|
+
return;
|
|
11
|
+
const interactive = target.closest(INTERACTIVE_SELECTOR);
|
|
12
|
+
if (interactive !== null &&
|
|
13
|
+
interactive !== currentTarget &&
|
|
14
|
+
currentTarget.contains(interactive)) {
|
|
15
|
+
return;
|
|
16
|
+
}
|
|
17
|
+
openRow();
|
|
18
|
+
};
|
|
19
|
+
}
|
|
@@ -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,7 +5,9 @@ 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";
|
|
10
|
+
import { rowClickHandler } from "./row-click-guard.js";
|
|
9
11
|
import { renderBand, renderExpandToggle, renderExpansion } from "./row-render-parts.js";
|
|
10
12
|
import { EXPAND_TOGGLE_CELL_CLASS } from "./table-chrome.js";
|
|
11
13
|
import { renderDataCell } from "./table-data-cell.js";
|
|
@@ -26,7 +28,7 @@ function renderDataRow(m, row) {
|
|
|
26
28
|
const opensOnClick = openRow !== undefined;
|
|
27
29
|
const keyboard = m.keyboardRow(row.id, openRow);
|
|
28
30
|
const reasonHint = m.columns.find((col) => col.hint !== undefined && hintReasonOf(col.hint, row.values) !== undefined)?.hint;
|
|
29
|
-
const rowElements = (_jsxs(_Fragment, { children: [_jsxs(TableRow, { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), onClick: 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)] }));
|
|
30
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));
|
|
31
33
|
}
|
|
32
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
|