@cosmicdrift/kumiko-renderer 0.414.0 → 0.416.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 -1
- package/dist/app/action-form-body.js +43 -16
- 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 +13 -4
- package/dist/app/entity-list-screen.js +12 -9
- package/dist/app/extension-sections.d.ts +2 -0
- package/dist/app/list-facets.d.ts +1 -0
- package/dist/app/list-facets.js +10 -1
- package/dist/app/named-filter-facet.d.ts +0 -1
- package/dist/app/named-filter-facet.js +19 -10
- package/dist/app/projection-detail-body.js +8 -6
- package/dist/app/projection-detail-guidance-data.js +3 -1
- package/dist/app/projection-detail-guidance.d.ts +1 -1
- package/dist/app/projection-detail-guidance.js +45 -33
- package/dist/app/projection-detail-header-model.d.ts +1 -1
- package/dist/app/projection-detail-header-model.js +10 -5
- package/dist/app/projection-detail-header.js +5 -4
- package/dist/app/projection-detail-navigation.d.ts +6 -0
- package/dist/app/projection-detail-navigation.js +18 -4
- package/dist/app/screen-access.js +1 -2
- package/dist/app/screen-shared.d.ts +1 -0
- package/dist/app/screen-shared.js +23 -3
- package/dist/app/use-entity-list-payload.d.ts +2 -1
- package/dist/app/use-entity-list-payload.js +4 -2
- package/dist/app/use-projection-detail-actions.d.ts +14 -0
- package/dist/app/use-projection-detail-actions.js +40 -16
- package/dist/app/use-projection-detail-data.d.ts +2 -0
- package/dist/app/use-projection-detail-data.js +37 -10
- package/dist/app/use-row-decoration.d.ts +6 -4
- package/dist/app/use-row-decoration.js +67 -19
- package/dist/app/use-screen-list-rows.js +1 -1
- package/dist/card-options.d.ts +25 -0
- package/dist/card-options.js +1 -0
- package/dist/components/ai-assist-payload.d.ts +2 -0
- package/dist/components/ai-assist-payload.js +8 -0
- package/dist/components/edit-mounts.d.ts +3 -2
- package/dist/components/edit-mounts.js +2 -2
- package/dist/components/list-empty-state.d.ts +5 -0
- package/dist/components/list-empty-state.js +17 -1
- package/dist/components/multi-select-chips.d.ts +10 -0
- package/dist/components/multi-select-chips.js +18 -0
- package/dist/components/related-list-section.js +44 -32
- package/dist/components/related-photo-grid.d.ts +11 -0
- package/dist/components/related-photo-grid.js +40 -0
- package/dist/components/render-edit-action-button.d.ts +2 -2
- package/dist/components/render-edit-field-grid.js +3 -3
- 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 +2 -2
- package/dist/components/render-edit-logic.js +1 -0
- package/dist/components/render-edit-section-kinds.js +11 -0
- package/dist/components/render-edit-types.d.ts +11 -1
- package/dist/components/render-field-ai-assist.d.ts +13 -0
- package/dist/components/render-field-ai-assist.js +89 -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 +18 -8
- package/dist/components/render-field-value-chips.d.ts +9 -0
- package/dist/components/render-field-value-chips.js +45 -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 +23 -0
- package/dist/components/render-list-toolbar-model.d.ts +2 -2
- package/dist/components/use-render-edit-sections.js +5 -1
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/context/screen-focus-context.d.ts +1 -1
- package/dist/context/screen-focus-context.js +3 -3
- package/dist/data-table-facet-types.d.ts +4 -0
- package/dist/headless/format/index.d.ts +1 -0
- package/dist/headless/format/index.js +20 -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 +13 -0
- package/dist/headless/format/relative-time.js +60 -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 +3 -3
- package/dist/headless/index.js +3 -3
- package/dist/headless/pwa-service-worker-meta.d.ts +3 -0
- package/dist/headless/pwa-service-worker-meta.js +10 -0
- package/dist/headless/view-model/edit.d.ts +3 -2
- package/dist/headless/view-model/edit.js +78 -2
- 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/types.d.ts +33 -3
- package/dist/i18n-defaults.js +4 -1
- package/dist/index.d.ts +1 -1
- package/dist/metric-types.d.ts +2 -0
- package/dist/primitives-record-guidance.d.ts +30 -1
- package/dist/primitives.d.ts +17 -27
- package/dist/web/app/dashboard-body.js +3 -2
- package/dist/web/app/dashboard-header.js +1 -1
- package/dist/web/app/dashboard-list-panel.js +9 -13
- 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.d.ts +1 -0
- package/dist/web/app/dashboard-panels.js +9 -7
- package/dist/web/app/dashboard-reference-list-table.js +1 -0
- package/dist/web/app/dashboard-shared.js +3 -2
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -0
- package/dist/web/app/dashboard-stat-group-panel.js +22 -8
- package/dist/web/app/dashboard-text-panel.d.ts +1 -0
- package/dist/web/app/dashboard-text-panel.js +18 -12
- package/dist/web/app/relative-time.d.ts +0 -5
- package/dist/web/app/relative-time.js +1 -20
- package/dist/web/drawn-icons.d.ts +6 -0
- package/dist/web/drawn-icons.js +30 -0
- package/dist/web/icons.js +6 -5
- package/dist/web/index.d.ts +2 -0
- package/dist/web/index.js +2 -0
- package/dist/web/layout/default-app-shell.js +3 -3
- package/dist/web/layout/nav-collapse-state.d.ts +2 -0
- package/dist/web/layout/nav-collapse-state.js +10 -0
- package/dist/web/layout/nav-tree.js +46 -23
- package/dist/web/layout/notification-bell.d.ts +7 -2
- package/dist/web/layout/notification-bell.js +16 -5
- package/dist/web/layout/shell-focus.d.ts +2 -2
- package/dist/web/layout/shell-focus.js +7 -3
- package/dist/web/layout/shell-header.d.ts +2 -1
- package/dist/web/layout/shell-header.js +56 -27
- package/dist/web/layout/shell-style.d.ts +3 -0
- package/dist/web/layout/shell-style.js +6 -0
- package/dist/web/layout/workspace-shell.d.ts +11 -1
- package/dist/web/layout/workspace-shell.js +6 -4
- package/dist/web/primitives/banner.d.ts +1 -1
- package/dist/web/primitives/banner.js +19 -9
- package/dist/web/primitives/card.js +18 -8
- package/dist/web/primitives/data-table/actions-column.d.ts +1 -1
- package/dist/web/primitives/data-table/actions-column.js +3 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +11 -6
- package/dist/web/primitives/data-table/card-row.js +27 -18
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -0
- package/dist/web/primitives/data-table/data-cell-props.js +2 -0
- package/dist/web/primitives/data-table/hint-cell.d.ts +1 -3
- package/dist/web/primitives/data-table/hint-cell.js +4 -10
- 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 -2
- package/dist/web/primitives/data-table/sort-options-select.js +3 -3
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-content.js +10 -6
- package/dist/web/primitives/data-table/table-view.js +8 -3
- package/dist/web/primitives/data-table/toolbar.d.ts +2 -0
- package/dist/web/primitives/data-table/toolbar.js +44 -9
- package/dist/web/primitives/data-table/totals-footer.js +4 -3
- package/dist/web/primitives/data-table-cell.d.ts +4 -1
- package/dist/web/primitives/data-table-cell.js +60 -20
- package/dist/web/primitives/default-form.js +6 -3
- package/dist/web/primitives/drawer.js +5 -1
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +16 -8
- package/dist/web/primitives/facet-search-filter.d.ts +2 -1
- package/dist/web/primitives/facet-search-filter.js +3 -2
- package/dist/web/primitives/facet-trigger-label.d.ts +8 -0
- package/dist/web/primitives/facet-trigger-label.js +9 -0
- package/dist/web/primitives/file-view-action.js +4 -1
- package/dist/web/primitives/form-footer-parts.js +4 -1
- package/dist/web/primitives/form.js +6 -8
- package/dist/web/primitives/index.js +4 -0
- package/dist/web/primitives/layout-elements.d.ts +1 -1
- package/dist/web/primitives/layout-elements.js +3 -3
- package/dist/web/primitives/locale-number.d.ts +0 -1
- package/dist/web/primitives/locale-number.js +1 -13
- package/dist/web/primitives/metric.js +17 -5
- package/dist/web/primitives/money-input.js +2 -1
- package/dist/web/primitives/narrow-pinned-footer.js +7 -3
- package/dist/web/primitives/number-input.js +2 -1
- package/dist/web/primitives/page-header.js +3 -2
- package/dist/web/primitives/pager.d.ts +3 -2
- package/dist/web/primitives/pager.js +16 -20
- package/dist/web/primitives/photo-grid.d.ts +3 -0
- package/dist/web/primitives/photo-grid.js +5 -0
- package/dist/web/primitives/record-breadcrumb.js +1 -1
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +11 -6
- package/dist/web/primitives/record-summary.d.ts +1 -1
- package/dist/web/primitives/record-summary.js +8 -3
- package/dist/web/primitives/segmented-select.js +6 -3
- package/dist/web/primitives/step-list.d.ts +3 -0
- package/dist/web/primitives/step-list.js +11 -0
- package/dist/web/primitives/tabs.js +6 -1
- package/dist/web/pwa/pwa-support.js +19 -1
- package/dist/web/ui/sidebar.d.ts +2 -1
- package/dist/web/ui/sidebar.js +4 -3
- package/dist/web/widgets/ai-text-field.js +3 -2
- package/dist/web/widgets/dashboard-list-cards.js +6 -14
- package/dist/web/widgets/dashboard-list.d.ts +10 -0
- package/dist/web/widgets/dashboard-list.js +36 -10
- package/dist/web/widgets/drawer-panel-class.d.ts +1 -0
- package/dist/web/widgets/drawer-panel-class.js +9 -1
- package/dist/web/widgets/drawer.js +2 -2
- package/dist/web/widgets/pdf-viewer-toolbar.js +3 -2
- package/dist/web/widgets/sheet-parts.js +3 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/dist/web/widgets/stat.d.ts +7 -1
- package/dist/web/widgets/stat.js +12 -4
- package/dist/web/widgets/step-list-row.d.ts +4 -0
- package/dist/web/widgets/step-list-row.js +22 -14
- package/dist/web/widgets/step-list.d.ts +12 -4
- package/dist/web/widgets/step-list.js +38 -20
- package/package.json +5 -5
- package/src/changes.json +126 -0
- package/src/web/styles.css +6 -0
|
@@ -3,6 +3,7 @@ import { Icon } from "../icons.js";
|
|
|
3
3
|
import { cn } from "../lib/cn.js";
|
|
4
4
|
import "../react-css-custom-properties.js";
|
|
5
5
|
import { fieldLabelId } from "./field.js";
|
|
6
|
+
import { useIsBelowSmViewport } from "./use-narrow-viewport.js";
|
|
6
7
|
const ICON_COLOR_CLASS = {
|
|
7
8
|
hint: "text-primary",
|
|
8
9
|
info: "text-primary",
|
|
@@ -17,7 +18,7 @@ function variantClass(variant, compact) {
|
|
|
17
18
|
case "error":
|
|
18
19
|
return "border-destructive/50 text-destructive bg-destructive/10 dark:border-destructive";
|
|
19
20
|
case "warning":
|
|
20
|
-
return "border-status-warn/30 bg-status-warn
|
|
21
|
+
return "border-status-warn/30 bg-status-warn-surface text-status-warn";
|
|
21
22
|
case "ok":
|
|
22
23
|
return "border-status-ok/30 bg-status-ok-surface text-foreground";
|
|
23
24
|
case "primary":
|
|
@@ -41,31 +42,40 @@ function BannerParts({ parts }) {
|
|
|
41
42
|
return part.strong === true ? (_jsx("strong", { className: "font-semibold", children: part.text }, key)) : (_jsx("span", { children: part.text }, key));
|
|
42
43
|
});
|
|
43
44
|
}
|
|
44
|
-
function BannerText({ compact, title, titleTestId, children, parts, actionsBelow, inline, }) {
|
|
45
|
+
function BannerText({ compact, title: fullTitle, narrowTitle, narrowText, titleTestId, children: fullText, parts, actionsBelow, inline, wrapsActions, }) {
|
|
46
|
+
const narrow = useIsBelowSmViewport();
|
|
47
|
+
const title = narrow && narrowTitle !== undefined ? narrowTitle : fullTitle;
|
|
48
|
+
const showsNarrowText = narrow && narrowText !== undefined;
|
|
49
|
+
const children = showsNarrowText ? narrowText : fullText;
|
|
45
50
|
if (compact || inline) {
|
|
46
|
-
return (_jsxs("div", { className: "min-w-0 grow", children: [title !== undefined && (_jsxs(_Fragment, { children: [_jsx("strong", { "data-testid": titleTestId, className: "font-semibold", children: title }), " "] })), _jsxs("span", { className: cn(inline && "max-sm:hidden"), children: [children, _jsx(BannerParts, { parts: parts })] })] }));
|
|
51
|
+
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 })] })] }));
|
|
47
52
|
}
|
|
48
|
-
return (_jsxs("div", { className: "flex-1", children: [title !== undefined && (_jsx("div", { "data-testid": titleTestId, className: "font-semibold", children: title })), children, _jsx(BannerParts, { parts: parts }), actionsBelow] }));
|
|
53
|
+
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] }));
|
|
49
54
|
}
|
|
50
|
-
function bannerLayoutClass(variant, compact, actionsBelow) {
|
|
51
|
-
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-
|
|
55
|
+
function bannerLayoutClass(variant, compact, actionsBelow, wrapsActions) {
|
|
56
|
+
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",
|
|
52
57
|
// Viewport breakpoint like the form footer bar; actions drop below the text on phones.
|
|
53
58
|
!compact &&
|
|
54
59
|
!actionsBelow &&
|
|
55
60
|
variant === "primary" &&
|
|
56
|
-
"flex-col items-start sm:flex-row sm:items-center", actionsBelow && "items-start", variantClass(variant, compact));
|
|
61
|
+
"flex-col items-start sm:flex-row sm:items-center", actionsBelow && "items-start", wrapsActions && "max-sm:flex-wrap", variantClass(variant, compact));
|
|
57
62
|
}
|
|
58
|
-
|
|
63
|
+
// On phones the actions leave the text line and wrap below it instead of squeezing the text.
|
|
64
|
+
function wrapsActionsOnPhone(variant, compact, actionsBelow, hasActions) {
|
|
65
|
+
return !compact && !actionsBelow && hasActions && variant !== "primary";
|
|
66
|
+
}
|
|
67
|
+
export function DefaultBanner({ variant = "info", density = "default", icon, title, narrowTitle, narrowText, titleTestId, children, parts, actions, actionsPlacement = "end", padded, inline = false, testId, id, }) {
|
|
59
68
|
const isError = variant === "error";
|
|
60
69
|
const compact = density === "compact";
|
|
61
70
|
// A compact banner is one line, so its actions always stay at the end.
|
|
62
71
|
const actionsBelow = actionsPlacement === "below" && !compact && actions !== undefined;
|
|
72
|
+
const wrapsActions = wrapsActionsOnPhone(variant, compact, actionsBelow, actions !== undefined);
|
|
63
73
|
// `id` is set when a <Field> wraps this Banner as its control (see
|
|
64
74
|
// BannerProps.id). A <div> isn't labelable, so a <label htmlFor> pointing
|
|
65
75
|
// at it is inert for screen readers — role="group" + aria-labelledby is
|
|
66
76
|
// the actual mechanism, pointed at the label id Field emits (fieldLabelId).
|
|
67
77
|
const bannerRole = id !== undefined ? "group" : isError ? "alert" : undefined;
|
|
68
|
-
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, 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 }))] }));
|
|
78
|
+
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 }))] }));
|
|
69
79
|
// Page state: the banner sits alone in main (which no longer has padding).
|
|
70
80
|
// The wrapper adds 24px outer spacing so the banner does not stick
|
|
71
81
|
// edge-to-edge to the sidebar/browser.
|
|
@@ -4,6 +4,20 @@ import { InsideScreenFormColumnContext } from "./metric.js";
|
|
|
4
4
|
import "../react-css-custom-properties.js";
|
|
5
5
|
import { cardFooter, cardFooterBorder, cardFooterInset, cardSurface } from "./card-styles.js";
|
|
6
6
|
import { FormScreenShell } from "./form.js";
|
|
7
|
+
function cardBodyPadding(inline, hasHeader) {
|
|
8
|
+
if (inline)
|
|
9
|
+
return "px-4 pb-4 pt-3";
|
|
10
|
+
return hasHeader
|
|
11
|
+
? "px-[var(--card-padding)] pb-[var(--card-padding)]"
|
|
12
|
+
: "p-[var(--card-padding)]";
|
|
13
|
+
}
|
|
14
|
+
function CardTitleRow({ slots, inline, }) {
|
|
15
|
+
const { title, subtitle, headerActions } = slots;
|
|
16
|
+
if (inline) {
|
|
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
|
+
}
|
|
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: "text-base font-semibold leading-none tracking-tight", children: title })), subtitle !== undefined && _jsx("div", { className: "text-sm text-muted-foreground", children: subtitle })] }), headerActions] }));
|
|
20
|
+
}
|
|
7
21
|
// Generic card chrome (rounded-xl like the entity card), slot- and
|
|
8
22
|
// options-based so the contract grows additively and consumers never have
|
|
9
23
|
// to migrate.
|
|
@@ -16,10 +30,9 @@ export function DefaultCard({ slots, options, className, testId, dataAttributes,
|
|
|
16
30
|
const fillHeight = options?.fillHeight ?? false;
|
|
17
31
|
const framed = screenBody ? false : (options?.framed ?? true);
|
|
18
32
|
const s = slots ?? {};
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
s.headerActions !== undefined ? (_jsxs("div", { className: cn("flex flex-col gap-3 px-[var(--card-padding)] pt-6 pb-4", fillHeight && "shrink-0"), children: [(s.title !== undefined || s.subtitle !== undefined || s.headerActions !== undefined) && (_jsxs("div", { className: "flex flex-wrap items-start justify-between gap-3", children: [_jsxs("div", { className: "flex flex-col gap-1", children: [s.title !== undefined && (_jsx("h3", { className: "text-base font-semibold leading-none tracking-tight", children: s.title })), s.subtitle !== undefined && (_jsx("div", { className: "text-sm text-muted-foreground", children: s.subtitle }))] }), s.headerActions] })), s.headerContent] })) : null;
|
|
33
|
+
const inlineHeader = options?.headerLayout === "inline";
|
|
34
|
+
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;
|
|
23
36
|
const header = s.header ?? defaultHeader;
|
|
24
37
|
const hasHeader = header !== null && header !== undefined;
|
|
25
38
|
const card = (_jsxs("div", { ...dataAttributes, "data-slot": "card", "data-testid": testId, className: cn(framed ? cardSurface({ radius }) : "flex flex-col",
|
|
@@ -29,10 +42,7 @@ export function DefaultCard({ slots, options, className, testId, dataAttributes,
|
|
|
29
42
|
// Same "no flex-1" reasoning as DefaultForm's own fillHeight card:
|
|
30
43
|
// sizes to content and only shrinks (min-h-0) once
|
|
31
44
|
// an ancestor is itself height-constrained.
|
|
32
|
-
fillHeight && "min-h-0 flex flex-col", className), children: [header, children != null && (_jsx("div", { className: cn("grow", screenBody && "flex flex-col gap-6", padded &&
|
|
33
|
-
(hasHeader
|
|
34
|
-
? "px-[var(--card-padding)] pb-[var(--card-padding)]"
|
|
35
|
-
: "p-[var(--card-padding)]"),
|
|
45
|
+
fillHeight && "min-h-0 flex flex-col", className), children: [header, children != null && (_jsx("div", { className: cn("grow", screenBody && "flex flex-col gap-6", padded && cardBodyPadding(inlineHeader, hasHeader),
|
|
36
46
|
// The one region allowed to shrink and scroll internally — mirrors
|
|
37
47
|
// FormSections' fillHeight === true && "min-h-0" treatment of the
|
|
38
48
|
// section it wraps.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { CSSProperties, ReactNode } from "react";
|
|
2
2
|
import "../../react-css-custom-properties.ts";
|
|
3
3
|
export declare const ACTIONS_CONTENT_ATTRIBUTE = "data-actions-content";
|
|
4
|
-
export declare function stickyActionsCellClass(fillsHeight: boolean): string;
|
|
4
|
+
export declare function stickyActionsCellClass(fillsHeight: boolean, inFooter?: boolean): string;
|
|
5
5
|
export declare function ActionsHeaderCell({ label, style, absorbsLeftover, }: {
|
|
6
6
|
readonly label: string;
|
|
7
7
|
readonly style?: CSSProperties | undefined;
|
|
@@ -5,7 +5,9 @@ import { COLUMN_ROLE_ATTRIBUTE } from "./column-role.js";
|
|
|
5
5
|
import { ROW_FOCUS_RING_CELL_CLASS } from "./use-row-keyboard-navigation.js";
|
|
6
6
|
import "../../react-css-custom-properties.js";
|
|
7
7
|
export const ACTIONS_CONTENT_ATTRIBUTE = "data-actions-content";
|
|
8
|
-
export function stickyActionsCellClass(fillsHeight) {
|
|
8
|
+
export function stickyActionsCellClass(fillsHeight, inFooter = false) {
|
|
9
|
+
if (inFooter)
|
|
10
|
+
return "md:sticky md:right-0 md:z-10 md:bg-muted";
|
|
9
11
|
return cn("md:sticky md:right-0 md:z-10", fillsHeight ? "md:bg-card" : "md:bg-background");
|
|
10
12
|
}
|
|
11
13
|
export function ActionsHeaderCell({ label, style, absorbsLeftover, }) {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type cardColumnRoles } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
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";
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { cardMetaLines } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
2
3
|
import { ChevronRight } from "lucide-react";
|
|
3
4
|
import { cellLinkProp, DataTableCell, isBadgeColumn, isEmptyCellValue, isUnlabeledFalse, showsBareCheckMark, } from "../data-table-cell.js";
|
|
4
5
|
import { CardLeadingImage } from "../file-thumbnail.js";
|
|
@@ -6,7 +7,7 @@ import { columnCellPresentationProps } from "./data-cell-props.js";
|
|
|
6
7
|
import { showFullTextOnHover } from "./table-footer.js";
|
|
7
8
|
// The phone card shows the sentence and its (narrow) detail; the reason toggle stays a table feature.
|
|
8
9
|
function cardHint(hint) {
|
|
9
|
-
const { reasonField: _reason, reasonOpenField: _reasonOpen, reasonTitleField: _reasonTitle, detailField: _detail, narrowDetailField, ...rest } = hint;
|
|
10
|
+
const { reasonField: _reason, reasonOpenField: _reasonOpen, reasonTitleField: _reasonTitle, detailField: _detail, narrowDetailField, narrowField: _narrowField, ...rest } = hint;
|
|
10
11
|
const detailField = narrowDetailField ?? _detail;
|
|
11
12
|
return { ...rest, ...(detailField !== undefined && { detailField }) };
|
|
12
13
|
}
|
|
@@ -16,7 +17,8 @@ function cardCell(m, row, col, { linksAllowed } = { linksAllowed: false }) {
|
|
|
16
17
|
// A bare check mark in the subtitle line says nothing without its column.
|
|
17
18
|
if (showsBareCheckMark(col.type, row.values[col.field], col.renderer))
|
|
18
19
|
return col.label;
|
|
19
|
-
|
|
20
|
+
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 && {
|
|
20
22
|
onChange: (value) => onCellChange(row.id, col.field, value),
|
|
21
23
|
}), ...(col.rowActionLink === true &&
|
|
22
24
|
col.display === undefined && { display: "button" }), ...cellLinkProp(col, row, linksAllowed || !opensRow) }));
|
|
@@ -53,22 +55,25 @@ export function splitLinkColumns(m, row, roles) {
|
|
|
53
55
|
export function renderCardLinks(m, row, linkColumns) {
|
|
54
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))) }));
|
|
55
57
|
}
|
|
58
|
+
function renderMetaCell(m, row, col) {
|
|
59
|
+
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, col.field), className: "min-w-0 max-w-full truncate leading-5", onPointerEnter: showFullTextOnHover, children: isBadgeColumn(col) ? (_jsx("span", { className: "inline-flex align-middle", children: cardCell(m, row, col) })) : (cardCell(m, row, col)) }, col.field));
|
|
60
|
+
}
|
|
56
61
|
function renderCardMeta(m, row, metaColumns) {
|
|
57
|
-
return (_jsx("div", { className: "min-w-0", children: _jsx("div", { "data-testid": `card-meta-${row.id}`, className: "flex min-w-0 flex-col text-[13px] leading-5 tabular-nums text-foreground-secondary", children: metaColumns.map((
|
|
62
|
+
return (_jsx("div", { className: "min-w-0", children: _jsx("div", { "data-testid": `card-meta-${row.id}`, className: "flex min-w-0 flex-col text-[13px] leading-5 tabular-nums text-foreground-secondary", children: cardMetaLines(metaColumns).map((line) => line[0]?.narrowInline === true ? (_jsx("div", { "data-testid": `card-vals-${row.id}-${line[0].field}`, className: "mt-1 flex min-w-0 max-w-full flex-wrap items-center gap-x-3 gap-y-0.5 text-[12.5px] leading-5", children: line.map((col) => renderMetaCell(m, row, col)) }, line.map((col) => col.field).join("|"))) : (_jsx("div", { className: "flex h-5 min-w-0 max-w-full items-center", children: line.map((col) => renderMetaCell(m, row, col)) }, line.map((col) => col.field).join("|")))) }) }));
|
|
58
63
|
}
|
|
59
64
|
function renderCardLead(m, row, lead) {
|
|
60
65
|
if (lead === undefined || isEmptyCellValue(row.values[lead.field]))
|
|
61
66
|
return null;
|
|
62
|
-
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, lead.field), className: "min-w-0 text-
|
|
67
|
+
return (_jsx("div", { "data-testid": cellTestIdOf(m, row, lead.field), className: "min-w-0 text-xs font-medium leading-5", children: cardCell(m, row, lead) }));
|
|
63
68
|
}
|
|
64
69
|
function renderCardHeading(m, row, roles) {
|
|
65
70
|
const { title: cardTitleColumn, status: cardStatusColumn } = roles;
|
|
66
71
|
const showStatus = cardStatusColumn !== undefined && !isEmptyCellValue(row.values[cardStatusColumn.field]);
|
|
67
|
-
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-
|
|
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 && (_jsx("span", { "data-testid": cellTestIdOf(m, row, cardStatusColumn.field), className: "shrink-0", children: cardCell(m, row, cardStatusColumn) }))] }));
|
|
68
73
|
}
|
|
69
74
|
export function renderCardBody(m, row, roles) {
|
|
70
75
|
const { image: cardImageColumn, meta: cardMetaColumns } = roles;
|
|
71
76
|
const metaColumns = cardMetaColumns.filter((col) => !isEmptyCellValue(row.values[col.field]) &&
|
|
72
77
|
!isUnlabeledFalse(col.type, row.values[col.field], col.renderer));
|
|
73
|
-
return (_jsxs(_Fragment, { children: [cardImageColumn?.fileDisplay !== undefined && (_jsx("div", { "data-testid": `card-image-${row.id}`, className: "shrink-0", children: _jsx(CardLeadingImage, { value: row.values[cardImageColumn.field], display: cardImageColumn.fileDisplay }) })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [renderCardLead(m, row, roles.lead), renderCardHeading(m, row, roles), metaColumns.length > 0 && renderCardMeta(m, row, metaColumns)] }), m.rowOpener(row) !== undefined && (_jsx(ChevronRight, { className: "size-4 shrink-0 text-
|
|
78
|
+
return (_jsxs(_Fragment, { children: [cardImageColumn?.fileDisplay !== undefined && (_jsx("div", { "data-testid": `card-image-${row.id}`, className: "shrink-0", children: _jsx(CardLeadingImage, { value: row.values[cardImageColumn.field], display: cardImageColumn.fileDisplay }) })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [renderCardLead(m, row, roles.lead), renderCardHeading(m, row, roles), metaColumns.length > 0 && renderCardMeta(m, row, metaColumns)] }), m.rowOpener(row) !== undefined && (_jsx(ChevronRight, { className: "size-4 shrink-0 text-border-strong", "aria-hidden": "true" }))] }));
|
|
74
79
|
}
|
|
@@ -5,6 +5,7 @@ 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
7
|
import { 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();
|
|
@@ -25,37 +30,41 @@ function renderCardOpenButton(openRow, body) {
|
|
|
25
30
|
function renderCardButtons(m, row, buttonActions) {
|
|
26
31
|
return renderStopPropagation("flex justify-start", `row-${row.id}-card-buttons`, _jsx(RowActionsCell, { row: row, actions: buttonActions, mode: m.rowActionMode, compact: true, small: true }));
|
|
27
32
|
}
|
|
28
|
-
function cardLeftPadding(compact
|
|
29
|
-
|
|
30
|
-
return toned ? "pl-[5px]" : "pl-2";
|
|
31
|
-
return toned ? "pl-[13px]" : "pl-4";
|
|
33
|
+
function cardLeftPadding(compact) {
|
|
34
|
+
return compact ? "pl-2" : "pl-4";
|
|
32
35
|
}
|
|
33
36
|
function cardRowBaseClass(m) {
|
|
34
37
|
return hasSeparateCardRows(m)
|
|
35
38
|
? `flex min-h-[72px] items-center gap-2 py-3 ${CARD_SURFACE_CLASS}`
|
|
36
39
|
: "flex min-h-[72px] items-center gap-2 border-b border-border-row py-3";
|
|
37
40
|
}
|
|
41
|
+
function splitCardActions(m, row, opensRow) {
|
|
42
|
+
const menuMode = m.rowActionMode === "menu";
|
|
43
|
+
// "menu" mode keeps every action in the table's kebab; a phone card opens the row instead,
|
|
44
|
+
// unless the row cannot be opened, then the actions would be unreachable.
|
|
45
|
+
const cardActions = menuMode && opensRow ? [] : (m.menuActions ?? []);
|
|
46
|
+
return {
|
|
47
|
+
buttonActions: cardActions.filter((a) => !menuMode &&
|
|
48
|
+
(a.display === "button" || a.display === "link") &&
|
|
49
|
+
(a.isVisible === undefined || a.isVisible(row))),
|
|
50
|
+
menuActions: cardActions.filter((a) => menuMode || (a.display !== "button" && a.display !== "link")),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
38
53
|
export function renderCard(m, row, roles) {
|
|
39
54
|
const { rowTone } = m;
|
|
40
|
-
const allActions = m.menuActions ?? [];
|
|
41
55
|
const openRow = m.rowOpener(row);
|
|
42
|
-
|
|
43
|
-
// unless the row cannot be opened, then the actions would be unreachable.
|
|
44
|
-
const cardActions = m.rowActionMode === "menu" && openRow !== undefined ? [] : allActions;
|
|
45
|
-
const menuMode = m.rowActionMode === "menu";
|
|
46
|
-
const buttonActions = cardActions.filter((a) => !menuMode &&
|
|
47
|
-
(a.display === "button" || a.display === "link") &&
|
|
48
|
-
(a.isVisible === undefined || a.isVisible(row)));
|
|
49
|
-
const menuActions = cardActions.filter((a) => menuMode || (a.display !== "button" && a.display !== "link"));
|
|
56
|
+
const { buttonActions, menuActions } = splitCardActions(m, row, openRow !== undefined);
|
|
50
57
|
const hasMenu = menuActions.length > 0;
|
|
51
58
|
const hasButtons = buttonActions.length > 0;
|
|
52
59
|
const { bodyRoles, linkColumns } = splitLinkColumns(m, row, roles);
|
|
53
60
|
const body = renderCardBody(m, row, bodyRoles);
|
|
54
61
|
const main = openRow !== undefined ? renderCardOpenButton(openRow, body) : body;
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
// In a list with row tones every card carries a stripe (neutral = grey) so the cards align.
|
|
63
|
+
const toneClass = cardToneClass(rowTone === undefined ? undefined : (rowTone(row) ?? "neutral"));
|
|
64
|
+
const toned = toneClass !== "";
|
|
65
|
+
const rowItem = (_jsxs("li", { "data-testid": m.rowTestId(row), "data-tone": rowTone?.(row), className: cn(cardRowBaseClass(m), toneClass,
|
|
66
|
+
// 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), linkColumns.length > 0 || hasButtons ? (_jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-1", children: [main, linkColumns.length > 0 && renderCardLinks(m, row, linkColumns), hasButtons && renderCardButtons(m, row, buttonActions)] })) : (main), hasMenu && renderCardMenu(m, row, menuActions)] }, row.id));
|
|
59
68
|
if (m.expansion === undefined)
|
|
60
69
|
return rowItem;
|
|
61
70
|
// The expansion is a sibling <li>, outside the row's click target, so
|
|
@@ -8,5 +8,7 @@ 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
|
+
pillField?: string | undefined;
|
|
12
|
+
pillToneField?: string | undefined;
|
|
11
13
|
emptyPlaceholder?: false | undefined;
|
|
12
14
|
};
|
|
@@ -8,6 +8,8 @@ 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 }),
|
|
12
14
|
};
|
|
13
15
|
}
|
|
@@ -2,9 +2,7 @@ import type { SelectOptionTone } from "@cosmicdrift/kumiko-framework/ui-types";
|
|
|
2
2
|
import { type ReactNode } from "react";
|
|
3
3
|
import type { ListColumnHintViewModel } from "../../../headless/index.ts";
|
|
4
4
|
export declare const HINT_TONE_TEXT_CLASS: Readonly<Record<SelectOptionTone, string>>;
|
|
5
|
-
|
|
6
|
-
export declare function isDimmedHintSentence(tone: SelectOptionTone | undefined, plainSentence: boolean | undefined): boolean;
|
|
7
|
-
export declare const DIMMED_HINT_SENTENCE_CLASS = "font-normal text-muted-foreground";
|
|
5
|
+
export declare function hintSentenceClass(tone: SelectOptionTone | undefined, plainSentence: boolean | undefined, weight?: "font-medium" | "font-semibold"): string;
|
|
8
6
|
/** "To do" cell: an emphasized sentence in the row tone with an optional muted second line. */
|
|
9
7
|
export declare function HintCell({ value, row, hint, onOpen, leading, }: {
|
|
10
8
|
readonly value: unknown;
|
|
@@ -13,10 +13,10 @@ export const HINT_TONE_TEXT_CLASS = {
|
|
|
13
13
|
neutral: "",
|
|
14
14
|
};
|
|
15
15
|
/** Tone `neutral` dims the sentence like an empty label (muted, not bold); `plainSentence` opts out. */
|
|
16
|
-
|
|
16
|
+
function isDimmedHintSentence(tone, plainSentence) {
|
|
17
17
|
return tone === "neutral" && plainSentence !== true;
|
|
18
18
|
}
|
|
19
|
-
|
|
19
|
+
const DIMMED_HINT_SENTENCE_CLASS = "font-normal text-muted-foreground";
|
|
20
20
|
const OPEN_SENTENCE_CLASS = "min-w-0 cursor-pointer bg-transparent p-0 text-left font-medium hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring";
|
|
21
21
|
function SentenceText({ text, className, onOpen, }) {
|
|
22
22
|
if (onOpen === undefined)
|
|
@@ -24,12 +24,6 @@ function SentenceText({ text, className, onOpen, }) {
|
|
|
24
24
|
return (_jsx("button", { type: "button", className: cn(OPEN_SENTENCE_CLASS, className), onClick: (event) => {
|
|
25
25
|
event.stopPropagation();
|
|
26
26
|
onOpen();
|
|
27
|
-
}, onKeyDown: (event) => {
|
|
28
|
-
if (event.key !== "Enter")
|
|
29
|
-
return;
|
|
30
|
-
event.preventDefault();
|
|
31
|
-
event.stopPropagation();
|
|
32
|
-
onOpen();
|
|
33
27
|
}, children: text }));
|
|
34
28
|
}
|
|
35
29
|
// Without a sentence the empty label is the only element of the first cell, so it must stay
|
|
@@ -55,10 +49,10 @@ function useHintReason(hint, row) {
|
|
|
55
49
|
boxId: rowReason?.boxId ?? ownBoxId,
|
|
56
50
|
};
|
|
57
51
|
}
|
|
58
|
-
function hintSentenceClass(tone, plainSentence) {
|
|
52
|
+
export function hintSentenceClass(tone, plainSentence, weight = "font-medium") {
|
|
59
53
|
if (isDimmedHintSentence(tone, plainSentence))
|
|
60
54
|
return DIMMED_HINT_SENTENCE_CLASS;
|
|
61
|
-
return cn(
|
|
55
|
+
return cn(weight, plainSentence !== true && tone !== undefined && HINT_TONE_TEXT_CLASS[tone]);
|
|
62
56
|
}
|
|
63
57
|
/** "To do" cell: an emphasized sentence in the row tone with an optional muted second line. */
|
|
64
58
|
export function HintCell({ value, row, hint, onOpen, leading, }) {
|
|
@@ -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): ReactNode;
|
|
8
|
+
export declare function renderEmptyBlock(m: DataTableModel, embedded?: boolean): ReactNode;
|
|
@@ -29,7 +29,8 @@ export function renderExpansion(m, row, as, colSpan) {
|
|
|
29
29
|
export function renderBand(m, item) {
|
|
30
30
|
return _jsx(GroupBand, { item: item, columnOf: m.columnOf });
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
// `embedded`: the block sits inside the framed table's body, which already draws the border.
|
|
33
|
+
export function renderEmptyBlock(m, embedded = false) {
|
|
33
34
|
const { testId, chromeless, fillsHeight, emptyState, tableTranslate } = m;
|
|
34
|
-
return (_jsx("div", { "data-testid": testId !== undefined ? `${testId}-empty` : "render-list-empty", className: cn("flex flex-col items-center justify-center
|
|
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." }) }));
|
|
35
36
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
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 { ChevronDown } from "lucide-react";
|
|
3
3
|
import { useOptionalTranslation } from "../../../index.js";
|
|
4
4
|
import { cn } from "../../lib/cn.js";
|
|
@@ -24,7 +24,7 @@ export function sortSummaryText(m) {
|
|
|
24
24
|
const total = m.pager?.total ?? m.rows.length;
|
|
25
25
|
const noun = m.itemNoun?.(total) ?? "";
|
|
26
26
|
const direction = active.dir === "asc" ? "↑" : "↓";
|
|
27
|
-
const count = total.toLocaleString();
|
|
27
|
+
const count = total.toLocaleString(m.tableLocale);
|
|
28
28
|
return (m.tableTranslate?.("kumiko.list.sort.summary", {
|
|
29
29
|
sort: active.label,
|
|
30
30
|
direction,
|
|
@@ -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-9 items-center gap-1.5 rounded-md text-[13px] text-foreground-secondary focus-within:ring-1 focus-within:ring-ring", bordered && "rounded-md border border-border-strong bg-background px-2.5 text-foreground", className), children: [_jsx("span", { "aria-hidden": "true", "data-testid": `${testId}-label`,
|
|
41
|
+
return (_jsxs("div", { className: cn("relative flex h-9 items-center gap-1.5 rounded-md text-[13px] text-foreground-secondary focus-within:ring-1 focus-within:ring-ring", 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 });
|
|
@@ -6,6 +6,7 @@ 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
8
|
import { bandClassName, bandReactKey, bandTestId } from "./group-band.js";
|
|
9
|
+
import { rowClickHandler } from "./row-click-guard.js";
|
|
9
10
|
import { renderBand, renderExpandToggle, renderExpansion } from "./row-render-parts.js";
|
|
10
11
|
import { EXPAND_TOGGLE_CELL_CLASS } from "./table-chrome.js";
|
|
11
12
|
import { renderDataCell } from "./table-data-cell.js";
|
|
@@ -26,7 +27,7 @@ function renderDataRow(m, row) {
|
|
|
26
27
|
const opensOnClick = openRow !== undefined;
|
|
27
28
|
const keyboard = m.keyboardRow(row.id, openRow);
|
|
28
29
|
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-10 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
|
+
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-10 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
31
|
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
32
|
}
|
|
32
33
|
export function renderTableBody(m) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../lib/cn.js";
|
|
3
3
|
import { InfiniteSentinel, Pager } from "../pager.js";
|
|
4
|
-
import { CARD_SURFACE_CLASS, isInsideCardFrame } from "./card-frame.js";
|
|
4
|
+
import { CARD_SURFACE_CLASS, hasSeparateCardRows, isInsideCardFrame } from "./card-frame.js";
|
|
5
5
|
import { renderCardsView } from "./card-view.js";
|
|
6
6
|
import { renderEmptyBlock } from "./row-render-parts.js";
|
|
7
7
|
import { DataTableFooter } from "./table-footer.js";
|
|
@@ -11,10 +11,10 @@ import { renderTableView } from "./table-view.js";
|
|
|
11
11
|
// Except total === 0: then there is nothing to paginate. Incompatible with
|
|
12
12
|
// infinite scroll: the caller sets either pager OR onReachEnd.
|
|
13
13
|
function renderPager(m) {
|
|
14
|
-
const { pager, serverGroups,
|
|
14
|
+
const { pager, serverGroups, testId } = m;
|
|
15
15
|
if (pager === undefined || !(pager.total > 0) || serverGroups !== undefined)
|
|
16
16
|
return undefined;
|
|
17
|
-
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 }),
|
|
17
|
+
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
18
|
}
|
|
19
19
|
function renderSentinel(m, pagerElement) {
|
|
20
20
|
const { onReachEnd, serverGroups, testId } = m;
|
|
@@ -25,7 +25,7 @@ function renderSentinel(m, pagerElement) {
|
|
|
25
25
|
}
|
|
26
26
|
function renderTableBodyContent(m) {
|
|
27
27
|
if (m.isEmpty)
|
|
28
|
-
return renderEmptyBlock(m);
|
|
28
|
+
return isInsideCardFrame(m) ? renderTableView(m) : renderEmptyBlock(m);
|
|
29
29
|
return m.isNarrow ? renderCardsView(m) : renderTableView(m);
|
|
30
30
|
}
|
|
31
31
|
export function renderTableContent(m) {
|
|
@@ -38,8 +38,12 @@ export function renderTableContent(m) {
|
|
|
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
|
-
|
|
41
|
+
// A rendered empty state stands alone: a "0 entries" count or pager under it only repeats it.
|
|
42
|
+
const hasEmptyState = m.isEmpty && m.emptyState !== undefined;
|
|
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));
|
|
43
47
|
// Frame card: content and footer share one bordered card. A fill-height card is as tall as
|
|
44
48
|
// its rows and shrinks into the scroll container; the 24px sides match the toolbar's inset.
|
|
45
49
|
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] }))] }));
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { cn } from "../../lib/cn.js";
|
|
3
|
-
import { Table, TableFooter } from "../../ui/table.js";
|
|
3
|
+
import { Table, TableBody, TableCell, TableFooter, TableRow } from "../../ui/table.js";
|
|
4
4
|
import { isInsideCardFrame } from "./card-frame.js";
|
|
5
5
|
import { ColumnWidthGroup } from "./column-resize-handle.js";
|
|
6
|
+
import { renderEmptyBlock } from "./row-render-parts.js";
|
|
6
7
|
import { renderTableBody } from "./table-body.js";
|
|
7
8
|
import { FILL_TABLE_CLASS, FlushTable } from "./table-chrome.js";
|
|
8
9
|
import { renderTableHeader } from "./table-header-row.js";
|
|
@@ -30,10 +31,14 @@ function renderTableFooter(m) {
|
|
|
30
31
|
const totals = renderTotalsRow(m);
|
|
31
32
|
if (summary === null && totals === null)
|
|
32
33
|
return null;
|
|
33
|
-
return (_jsxs(TableFooter, { children: [summary, totals] }));
|
|
34
|
+
return (_jsxs(TableFooter, { className: "bg-muted text-[12.5px]", children: [summary, totals] }));
|
|
35
|
+
}
|
|
36
|
+
// A framed list that is empty keeps its header row; the empty state fills one spanning row below it.
|
|
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, true) }) }) }));
|
|
34
39
|
}
|
|
35
40
|
export function renderTableView(m) {
|
|
36
41
|
const { fillsHeight, chromeless, sizing, testId } = m;
|
|
37
42
|
const TableRoot = fillsHeight ? FlushTable : Table;
|
|
38
|
-
return (_jsx("div", { className: cn(!fillsHeight && "overflow-hidden", !fillsHeight && chromeless !== true && !isInsideCardFrame(m) && "rounded-lg border bg-card"), children: _jsxs(TableRoot, { "data-testid": testId, className: fillsHeight ? FILL_TABLE_CLASS : undefined, ...(sizing?.tableStyle !== undefined && { style: sizing.tableStyle }), children: [renderColumnWidths(m), renderTableHeader(m), renderTableBody(m), renderTableFooter(m)] }) }));
|
|
43
|
+
return (_jsx("div", { className: cn(!fillsHeight && "overflow-hidden", !fillsHeight && chromeless !== true && !isInsideCardFrame(m) && "rounded-lg border bg-card"), children: _jsxs(TableRoot, { "data-testid": testId, className: fillsHeight ? FILL_TABLE_CLASS : undefined, ...(sizing?.tableStyle !== undefined && { style: sizing.tableStyle }), children: [renderColumnWidths(m), renderTableHeader(m), m.isEmpty ? renderEmptyBody(m) : renderTableBody(m), m.isEmpty ? null : renderTableFooter(m)] }) }));
|
|
39
44
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
import type { DataTableModel } from "./use-data-table-state.ts";
|
|
3
|
+
/** Facets that open behind the filter icon on a phone; the rest stays in the inline cluster. */
|
|
4
|
+
export declare function buildBehindFilterCluster(m: DataTableModel): ReactNode;
|
|
3
5
|
export declare function buildModelFacetCluster(m: DataTableModel): ReactNode;
|
|
4
6
|
export declare function hasToolbarContent(m: DataTableModel, facetCluster: ReactNode): boolean;
|
|
5
7
|
export declare function toolbarMergesDescription(m: DataTableModel, facetCluster: ReactNode): boolean;
|