@cosmicdrift/kumiko-renderer 0.416.0 → 0.417.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/action-form-body.d.ts +1 -4
- package/dist/app/action-form-body.js +9 -8
- package/dist/app/config-edit-body.js +71 -79
- package/dist/app/entity-list-screen.js +1 -1
- package/dist/app/header-actions-bar.d.ts +3 -1
- package/dist/app/header-actions-bar.js +12 -4
- package/dist/app/locked-screen-header.d.ts +2 -0
- package/dist/app/locked-screen-header.js +8 -1
- package/dist/app/projection-detail-body.js +24 -5
- package/dist/app/projection-detail-guidance.d.ts +1 -0
- package/dist/app/projection-detail-guidance.js +7 -4
- package/dist/app/projection-detail-header-model.js +4 -1
- package/dist/app/projection-detail-header-region.js +25 -9
- package/dist/app/projection-detail-header.d.ts +2 -0
- package/dist/app/projection-detail-header.js +30 -3
- package/dist/app/projection-list-shim.js +1 -0
- package/dist/app/row-actions.d.ts +4 -0
- package/dist/app/row-actions.js +19 -3
- package/dist/app/use-projection-detail-actions.d.ts +3 -1
- package/dist/app/use-projection-detail-actions.js +9 -1
- package/dist/app/use-projection-detail-data.js +17 -1
- package/dist/app/use-projection-list-data.js +1 -1
- package/dist/card-options.d.ts +2 -0
- package/dist/components/choice-chip-class.d.ts +1 -0
- package/dist/components/choice-chip-class.js +9 -0
- package/dist/components/edit-mounts.d.ts +1 -1
- package/dist/components/grid-cell-for-field.js +1 -1
- package/dist/components/multi-select-chips.js +2 -1
- package/dist/components/narrow-description.d.ts +3 -0
- package/dist/components/narrow-description.js +12 -0
- package/dist/components/related-list-section.d.ts +5 -3
- package/dist/components/related-list-section.js +9 -4
- package/dist/components/related-photo-grid.js +17 -3
- package/dist/components/render-edit-field-grid.d.ts +12 -3
- package/dist/components/render-edit-field-grid.js +60 -18
- package/dist/components/render-edit-fields-section.js +45 -11
- package/dist/components/render-edit-header-actions.js +1 -1
- package/dist/components/render-edit-layout.js +4 -2
- package/dist/components/render-edit-section-kinds.js +50 -12
- package/dist/components/render-edit-titles.js +1 -1
- package/dist/components/render-edit-types.d.ts +11 -0
- package/dist/components/render-field-ai-assist.js +3 -2
- package/dist/components/render-field-control.js +1 -1
- package/dist/components/render-field-value-chips.js +4 -2
- package/dist/components/render-list-hint-columns.d.ts +1 -0
- package/dist/components/render-list-hint-columns.js +30 -5
- package/dist/components/render-list-reference-columns.js +2 -4
- package/dist/components/render-list-row-tone.d.ts +2 -0
- package/dist/components/render-list-row-tone.js +6 -0
- package/dist/components/render-list-table-props.d.ts +13 -2
- package/dist/components/render-list-table-props.js +9 -3
- package/dist/components/render-list-types.d.ts +4 -0
- package/dist/components/render-list.js +12 -4
- package/dist/components/use-render-list-columns.js +3 -3
- package/dist/components/write-form-registry.d.ts +13 -0
- package/dist/components/write-form-registry.js +6 -0
- package/dist/components/write-form-section.d.ts +5 -1
- package/dist/components/write-form-section.js +55 -16
- package/dist/headless/form/form-controller.d.ts +1 -0
- package/dist/headless/form/form-controller.js +1 -1
- package/dist/headless/format/index.js +5 -4
- package/dist/headless/format/relative-time.d.ts +2 -0
- package/dist/headless/format/relative-time.js +4 -1
- package/dist/headless/view-model/edit.js +87 -37
- package/dist/headless/view-model/list.js +6 -0
- package/dist/headless/view-model/types.d.ts +49 -4
- package/dist/hooks/use-list-table.js +11 -6
- package/dist/i18n-defaults.js +7 -2
- package/dist/primitives-record-guidance.d.ts +4 -0
- package/dist/primitives-share-types.d.ts +82 -0
- package/dist/primitives-share-types.js +1 -0
- package/dist/primitives.d.ts +34 -83
- package/dist/web/app/bold-markup.d.ts +3 -0
- package/dist/web/app/bold-markup.js +14 -0
- package/dist/web/app/dashboard-body.js +5 -1
- package/dist/web/app/dashboard-list-panel.js +7 -4
- package/dist/web/app/dashboard-panels.js +31 -3
- package/dist/web/app/dashboard-shared.d.ts +3 -1
- package/dist/web/app/dashboard-shared.js +3 -3
- package/dist/web/app/dashboard-stat-group-panel.d.ts +1 -1
- package/dist/web/app/dashboard-stat-group-panel.js +16 -2
- package/dist/web/app/dashboard-text-panel.js +11 -6
- package/dist/web/app/relative-time.js +10 -1
- package/dist/web/components/config-cascade.d.ts +2 -1
- package/dist/web/components/config-cascade.js +16 -4
- package/dist/web/drawn-icons.js +2 -1
- package/dist/web/layout/header-action-pinned.d.ts +4 -2
- package/dist/web/layout/header-action-pinned.js +13 -4
- package/dist/web/layout/header-overflow-menu.d.ts +2 -0
- package/dist/web/layout/header-overflow-menu.js +2 -0
- package/dist/web/layout/notification-bell.js +12 -3
- package/dist/web/layout/page-header-slot.d.ts +2 -0
- package/dist/web/layout/page-header-slot.js +4 -0
- package/dist/web/layout/screen-focus.js +4 -1
- package/dist/web/layout/shell-header.js +13 -5
- package/dist/web/primitives/banner.js +14 -3
- package/dist/web/primitives/card.js +5 -3
- package/dist/web/primitives/combobox.js +2 -2
- package/dist/web/primitives/data-table/actions-column.js +1 -1
- package/dist/web/primitives/data-table/card-body.d.ts +1 -1
- package/dist/web/primitives/data-table/card-body.js +37 -14
- package/dist/web/primitives/data-table/card-frame.d.ts +2 -0
- package/dist/web/primitives/data-table/card-frame.js +3 -0
- package/dist/web/primitives/data-table/card-row.js +28 -9
- package/dist/web/primitives/data-table/card-sort-select.js +1 -1
- package/dist/web/primitives/data-table/card-view.js +1 -1
- package/dist/web/primitives/data-table/data-cell-props.d.ts +2 -1
- package/dist/web/primitives/data-table/data-cell-props.js +1 -0
- package/dist/web/primitives/data-table/density.d.ts +3 -1
- package/dist/web/primitives/data-table/density.js +11 -4
- package/dist/web/primitives/data-table/row-render-parts.d.ts +1 -1
- package/dist/web/primitives/data-table/row-render-parts.js +3 -5
- package/dist/web/primitives/data-table/sort-options-select.js +2 -2
- package/dist/web/primitives/data-table/sortable-header.js +4 -4
- package/dist/web/primitives/data-table/table-body.js +2 -1
- package/dist/web/primitives/data-table/table-chrome.js +1 -3
- package/dist/web/primitives/data-table/table-content.js +7 -11
- package/dist/web/primitives/data-table/table-data-cell.js +31 -17
- package/dist/web/primitives/data-table/table-header-row.js +1 -1
- package/dist/web/primitives/data-table/table-view.js +1 -1
- package/dist/web/primitives/data-table/toolbar.js +6 -7
- package/dist/web/primitives/data-table/use-data-table-state.d.ts +6 -1
- package/dist/web/primitives/data-table/use-data-table-state.js +12 -2
- package/dist/web/primitives/data-table-cell.d.ts +13 -2
- package/dist/web/primitives/data-table-cell.js +123 -43
- package/dist/web/primitives/data-table.js +1 -1
- package/dist/web/primitives/default-form.d.ts +1 -1
- package/dist/web/primitives/default-form.js +11 -10
- package/dist/web/primitives/drawer.js +2 -7
- package/dist/web/primitives/facet-filter.d.ts +1 -1
- package/dist/web/primitives/facet-filter.js +2 -5
- package/dist/web/primitives/facet-search-filter.js +1 -1
- package/dist/web/primitives/facet-trigger-label.d.ts +1 -4
- package/dist/web/primitives/facet-trigger-label.js +4 -7
- package/dist/web/primitives/field.js +15 -8
- package/dist/web/primitives/form-footer-parts.js +2 -2
- package/dist/web/primitives/inline-suffix.d.ts +2 -0
- package/dist/web/primitives/inline-suffix.js +5 -0
- package/dist/web/primitives/input-choice-kinds.js +12 -2
- package/dist/web/primitives/input-number-kinds.js +2 -2
- package/dist/web/primitives/input-text-kinds.js +1 -1
- package/dist/web/primitives/layout-elements.d.ts +4 -4
- package/dist/web/primitives/layout-elements.js +49 -12
- package/dist/web/primitives/layout.d.ts +1 -1
- package/dist/web/primitives/layout.js +1 -1
- package/dist/web/primitives/money-input.js +8 -7
- package/dist/web/primitives/number-input.d.ts +2 -1
- package/dist/web/primitives/number-input.js +9 -4
- package/dist/web/primitives/page-header.d.ts +1 -1
- package/dist/web/primitives/page-header.js +8 -1
- package/dist/web/primitives/pager.js +12 -21
- package/dist/web/primitives/photo-grid.js +2 -1
- package/dist/web/primitives/record-steps.d.ts +1 -1
- package/dist/web/primitives/record-steps.js +6 -15
- package/dist/web/primitives/row-actions.js +38 -24
- package/dist/web/primitives/use-container-narrow.d.ts +12 -0
- package/dist/web/primitives/use-container-narrow.js +42 -0
- package/dist/web/ui/input.js +1 -1
- package/dist/web/ui/textarea.js +1 -1
- package/dist/web/widgets/dashboard-list-cards.js +6 -3
- package/dist/web/widgets/dashboard-list.d.ts +4 -1
- package/dist/web/widgets/dashboard-list.js +10 -5
- package/dist/web/widgets/progress-list.js +1 -1
- package/dist/web/widgets/stat-box-cell.js +1 -1
- package/package.json +5 -5
- package/src/changes.json +51 -0
- package/src/web/styles.css +3 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type Dispatch, type SetStateAction } from "react";
|
|
1
|
+
import { type Dispatch, type RefObject, type SetStateAction } from "react";
|
|
2
2
|
import type { ListColumnViewModel, ListRowViewModel } from "../../../headless/index.ts";
|
|
3
3
|
import { type DataTableProps, useOptionalLocale, useOptionalTranslation } from "../../../index.ts";
|
|
4
4
|
import { densityClasses } from "./density.ts";
|
|
@@ -14,10 +14,15 @@ type RowExpansion = {
|
|
|
14
14
|
};
|
|
15
15
|
export type DataTableModel = Omit<DataTableProps, "columns"> & {
|
|
16
16
|
readonly schemaColumns: readonly ListColumnViewModel[];
|
|
17
|
+
/** With an emphasis column the first column is plain: the emphasised one carries the row. */
|
|
18
|
+
readonly hasEmphasisColumn: boolean;
|
|
17
19
|
readonly columns: ColumnPins<ListColumnViewModel>["columns"];
|
|
18
20
|
readonly tableTranslate: ReturnType<typeof useOptionalTranslation>;
|
|
19
21
|
readonly tableLocale: ReturnType<typeof useOptionalLocale>;
|
|
20
22
|
readonly isNarrow: boolean;
|
|
23
|
+
readonly containerRef: RefObject<HTMLDivElement | null>;
|
|
24
|
+
/** Row the assistant currently sees (the screen focus names its record); drawn highlighted. */
|
|
25
|
+
readonly focusedRowId: string | undefined;
|
|
21
26
|
readonly belowSm: boolean;
|
|
22
27
|
readonly density: ReturnType<typeof densityClasses>;
|
|
23
28
|
readonly facetsOpenNarrow: boolean;
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { useId, useMemo, useState } from "react";
|
|
1
|
+
import { useId, useMemo, useState, } from "react";
|
|
2
2
|
import { useIsEmbeddedScreen } from "../../../context/embedded-screen-context.js";
|
|
3
|
+
import { useScreenFocus } from "../../../context/screen-focus-context.js";
|
|
3
4
|
import { useOptionalLocale, useOptionalTranslation } from "../../../index.js";
|
|
5
|
+
import { useContainerSqueeze } from "../use-container-narrow.js";
|
|
4
6
|
import { useIsBelowSmViewport, useIsNarrowViewport } from "../use-narrow-viewport.js";
|
|
5
7
|
import { isPinningActive, isResizingActive } from "./column-layout-mode.js";
|
|
6
8
|
import { densityClasses } from "./density.js";
|
|
@@ -47,7 +49,12 @@ export function useDataTableState(props) {
|
|
|
47
49
|
// single-mount pattern as EmbeddedListInput/embedded-list-input.tsx.
|
|
48
50
|
const isNarrow = useIsNarrowViewport();
|
|
49
51
|
const belowSm = useIsBelowSmViewport();
|
|
50
|
-
const
|
|
52
|
+
const focusedRowId = useScreenFocus()?.recordId;
|
|
53
|
+
const [containerRef, squeeze] = useContainerSqueeze();
|
|
54
|
+
const containerNarrow = squeeze.narrow || squeeze.docked;
|
|
55
|
+
const schemaColumns = useMemo(() => isNarrow
|
|
56
|
+
? allColumns
|
|
57
|
+
: allColumns.filter((col) => col.showOnNarrowOnly !== true && !(containerNarrow && col.hideWhenDocked === true)), [allColumns, isNarrow, containerNarrow]);
|
|
51
58
|
const viewColumns = useViewColumns(schemaColumns, view, isNarrow);
|
|
52
59
|
const density = densityClasses(view, scrollBody === true);
|
|
53
60
|
const [facetsOpenNarrow, setFacetsOpenNarrow] = useState(false);
|
|
@@ -99,11 +106,14 @@ export function useDataTableState(props) {
|
|
|
99
106
|
return {
|
|
100
107
|
...props,
|
|
101
108
|
schemaColumns,
|
|
109
|
+
hasEmphasisColumn: schemaColumns.some((column) => column.emphasis === true),
|
|
102
110
|
columns,
|
|
103
111
|
tableTranslate,
|
|
104
112
|
tableLocale,
|
|
105
113
|
isNarrow,
|
|
106
114
|
belowSm,
|
|
115
|
+
containerRef,
|
|
116
|
+
focusedRowId,
|
|
107
117
|
density,
|
|
108
118
|
facetsOpenNarrow,
|
|
109
119
|
setFacetsOpenNarrow,
|
|
@@ -11,9 +11,10 @@ export declare function isBadgeColumn(col: {
|
|
|
11
11
|
readonly type: string;
|
|
12
12
|
readonly renderer?: unknown;
|
|
13
13
|
}): boolean;
|
|
14
|
-
export declare function FirstCellLink({ enabled, empty, emptyLabel, onOpen, children, }: {
|
|
14
|
+
export declare function FirstCellLink({ enabled, empty, emptyLabel, emptyPlaceholder, onOpen, children, }: {
|
|
15
15
|
readonly enabled: boolean;
|
|
16
16
|
readonly empty: boolean;
|
|
17
|
+
readonly emptyPlaceholder?: string | false | undefined;
|
|
17
18
|
readonly emptyLabel?: string | undefined;
|
|
18
19
|
readonly onOpen: () => void;
|
|
19
20
|
readonly children: ReactNode;
|
|
@@ -47,9 +48,13 @@ type DataTableCellProps = {
|
|
|
47
48
|
readonly badgeDot?: false;
|
|
48
49
|
readonly pillField?: string;
|
|
49
50
|
readonly pillToneField?: string;
|
|
50
|
-
readonly emptyPlaceholder?: false;
|
|
51
|
+
readonly emptyPlaceholder?: string | false;
|
|
52
|
+
readonly dateOnlyAfterDays?: number;
|
|
51
53
|
readonly onOpenRow?: () => void;
|
|
52
54
|
};
|
|
55
|
+
export declare function EmptyCell({ placeholder, }: {
|
|
56
|
+
readonly placeholder: string | false | undefined;
|
|
57
|
+
}): ReactNode;
|
|
53
58
|
/** `display: "button"` draws a cell link as a small outline button. */
|
|
54
59
|
export declare const LINK_BUTTON_CLASS: string;
|
|
55
60
|
export declare const LINK_BUTTON_PRIMARY_CLASS: string;
|
|
@@ -74,5 +79,11 @@ export declare function CellTextLink({ link, children, className, }: {
|
|
|
74
79
|
readonly children: ReactNode;
|
|
75
80
|
readonly className?: string;
|
|
76
81
|
}): ReactNode;
|
|
82
|
+
/** The extra pill a column draws beside its value in a table row, or in the header line of a phone card. */
|
|
83
|
+
export declare function CellPill({ row, pillField, pillToneField, }: {
|
|
84
|
+
readonly row: Readonly<Record<string, unknown>>;
|
|
85
|
+
readonly pillField: string | undefined;
|
|
86
|
+
readonly pillToneField: string | undefined;
|
|
87
|
+
}): ReactNode;
|
|
77
88
|
export declare function DataTableCell(props: DataTableCellProps): ReactNode;
|
|
78
89
|
export {};
|
|
@@ -7,6 +7,7 @@ import { rendererWarn } from "../../dev-console.js";
|
|
|
7
7
|
import { fileIdsOf } from "../../file-ids-of.js";
|
|
8
8
|
import { applyFormatSpec, EMPTY_VALUE_PLACEHOLDER, isSafeHref, telHref, } from "../../headless/index.js";
|
|
9
9
|
import { statusToneForOptionTone, statusToneForValue, useColumnRenderer, useOptionalPrimitives, } from "../../index.js";
|
|
10
|
+
import { serverNowMs } from "../../server-clock.js";
|
|
10
11
|
import { isSelectOptionTone } from "../../status-tone.js";
|
|
11
12
|
import { Badge } from "../ui/badge.js";
|
|
12
13
|
import { buttonVariants } from "../ui/button.js";
|
|
@@ -16,6 +17,7 @@ import { FileDisplayCell } from "./file-thumbnail.js";
|
|
|
16
17
|
import { FileViewAction } from "./file-view-action.js";
|
|
17
18
|
import { currencyDecimals, formatMoney } from "./money-input.js";
|
|
18
19
|
import "../react-css-custom-properties.js";
|
|
20
|
+
import { useOptionalTranslation } from "../../index.js";
|
|
19
21
|
import { isPlainPrimaryClick } from "./layout-elements.js";
|
|
20
22
|
export function isEmptyCellValue(value) {
|
|
21
23
|
return (value === null || value === undefined || (typeof value === "string" && value.trim() === ""));
|
|
@@ -77,10 +79,10 @@ export function isBadgeColumn(col) {
|
|
|
77
79
|
// The first cell is the keyboard-reachable entry point of a clickable row; the
|
|
78
80
|
// row's own onClick keeps serving the mouse. Enter is handled explicitly so
|
|
79
81
|
// it also opens the row where a button does not synthesize a click.
|
|
80
|
-
export function FirstCellLink({ enabled, empty, emptyLabel, onOpen, children, }) {
|
|
82
|
+
export function FirstCellLink({ enabled, empty, emptyLabel, emptyPlaceholder, onOpen, children, }) {
|
|
81
83
|
if (!enabled || (empty && emptyLabel === undefined))
|
|
82
84
|
return children;
|
|
83
|
-
return (_jsx("button", { type: "button", className: "max-w-full cursor-pointer bg-transparent p-0 text-left font-medium text-
|
|
85
|
+
return (_jsx("button", { type: "button", className: "max-w-full cursor-pointer bg-transparent p-0 text-left font-medium text-inherit hover:underline focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring", onClick: (e) => {
|
|
84
86
|
e.stopPropagation();
|
|
85
87
|
onOpen();
|
|
86
88
|
}, onKeyDown: (e) => {
|
|
@@ -89,7 +91,7 @@ export function FirstCellLink({ enabled, empty, emptyLabel, onOpen, children, })
|
|
|
89
91
|
e.preventDefault();
|
|
90
92
|
e.stopPropagation();
|
|
91
93
|
onOpen();
|
|
92
|
-
}, children: empty ? _jsx("span", { className: "sr-only", children: emptyLabel }) : children }));
|
|
94
|
+
}, children: empty ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "sr-only", children: emptyLabel }), _jsx(EmptyCell, { placeholder: emptyPlaceholder })] })) : (children) }));
|
|
93
95
|
}
|
|
94
96
|
// w-px on an auto-layout table cell shrinks the column to its content (the
|
|
95
97
|
// actions column relies on the same behaviour).
|
|
@@ -235,8 +237,34 @@ function enumOptionTones(spec) {
|
|
|
235
237
|
}
|
|
236
238
|
return out;
|
|
237
239
|
}
|
|
238
|
-
|
|
239
|
-
|
|
240
|
+
const MS_PER_DAY = 86_400_000;
|
|
241
|
+
function dateOnlyWhenOlderThan(value, days, locale, renderer) {
|
|
242
|
+
if (typeof value !== "string" && typeof value !== "number")
|
|
243
|
+
return undefined;
|
|
244
|
+
const atMs = typeof value === "number" ? value : Date.parse(value);
|
|
245
|
+
// An unparsable or out-of-range value falls back to the plain cell text.
|
|
246
|
+
if (Number.isNaN(new Date(atMs).getTime()))
|
|
247
|
+
return undefined;
|
|
248
|
+
if (serverNowMs() - atMs <= days * MS_PER_DAY)
|
|
249
|
+
return undefined;
|
|
250
|
+
const timeZone = typeof renderer === "object" &&
|
|
251
|
+
renderer !== null &&
|
|
252
|
+
"timeZone" in renderer &&
|
|
253
|
+
typeof renderer.timeZone === "string"
|
|
254
|
+
? renderer.timeZone
|
|
255
|
+
: undefined;
|
|
256
|
+
return applyFormatSpec({
|
|
257
|
+
format: "date",
|
|
258
|
+
dateStyle: "long",
|
|
259
|
+
...(locale !== undefined && { locale }),
|
|
260
|
+
...(timeZone !== undefined && { timeZone }),
|
|
261
|
+
}, new Date(atMs).toISOString());
|
|
262
|
+
}
|
|
263
|
+
export function EmptyCell({ placeholder, }) {
|
|
264
|
+
const t = useOptionalTranslation();
|
|
265
|
+
// translate returns an unknown key (a literal like "No vehicle") unchanged.
|
|
266
|
+
const text = typeof placeholder === "string" ? (t?.(placeholder) ?? placeholder) : null;
|
|
267
|
+
return (_jsx("span", { "data-empty-cell": "true", className: "text-muted-foreground", children: text }));
|
|
240
268
|
}
|
|
241
269
|
/** `display: "button"` draws a cell link as a small outline button. */
|
|
242
270
|
export const LINK_BUTTON_CLASS = buttonVariants({ variant: "outline", size: "sm" });
|
|
@@ -247,6 +275,10 @@ export const LIST_BADGE_TONE = {
|
|
|
247
275
|
warn: "warn",
|
|
248
276
|
negative: "bad",
|
|
249
277
|
neutral: "muted",
|
|
278
|
+
ok: "ok",
|
|
279
|
+
bad: "bad",
|
|
280
|
+
critical: "bad",
|
|
281
|
+
accent: "muted",
|
|
250
282
|
};
|
|
251
283
|
// A multi reference may list the same id twice; the occurrence count keeps React keys unique.
|
|
252
284
|
function uniqueLinkItemKeys(items) {
|
|
@@ -282,8 +314,8 @@ const ROW_TONE_STRIPE_CLASS = {
|
|
|
282
314
|
accent: `${ROW_STRIPE_SHADOW_CLASS} [&>td:first-child]:[--row-stripe:var(--color-primary)]`,
|
|
283
315
|
neutral: "",
|
|
284
316
|
};
|
|
285
|
-
// Inner
|
|
286
|
-
const CARD_STRIPE_BASE = "relative pl-
|
|
317
|
+
// Inner 3px edge stripe (board .card.cw): sits inside the card border, rounded with the card corners.
|
|
318
|
+
const CARD_STRIPE_BASE = "relative pl-5 before:absolute before:inset-y-0 before:left-0 before:w-[3px] before:rounded-l-[7px] before:content-['']";
|
|
287
319
|
const CARD_TONE_STRIPE_CLASS = {
|
|
288
320
|
bad: `${CARD_STRIPE_BASE} before:bg-status-bad`,
|
|
289
321
|
warn: `${CARD_STRIPE_BASE} before:bg-status-warn`,
|
|
@@ -381,23 +413,37 @@ function renderFileCell({ value, fileDisplay, compactFile, translate, }) {
|
|
|
381
413
|
// "X" via useColumnRenderer and renders `<X value row column/>`.
|
|
382
414
|
// Not registered -> one-time warning + default fallback.
|
|
383
415
|
// 4. Otherwise -> defaultCellRender (type-based string renderer).
|
|
384
|
-
|
|
385
|
-
|
|
416
|
+
/** The extra pill a column draws beside its value in a table row, or in the header line of a phone card. */
|
|
417
|
+
export function CellPill({ row, pillField, pillToneField, }) {
|
|
386
418
|
const pillText = pillField === undefined ? undefined : row[pillField];
|
|
387
419
|
if (typeof pillText !== "string" || pillText === "")
|
|
388
|
-
return
|
|
420
|
+
return null;
|
|
389
421
|
const toneKey = pillToneField === undefined ? undefined : row[pillToneField];
|
|
390
422
|
const tone = (typeof toneKey === "string" ? LIST_BADGE_TONE[toneKey] : undefined) ?? "muted";
|
|
391
|
-
return
|
|
423
|
+
return _jsx(StatusBadge, { tone: tone, children: pillText });
|
|
392
424
|
}
|
|
393
|
-
function
|
|
425
|
+
export function DataTableCell(props) {
|
|
426
|
+
const { pillField, pillToneField, row } = props;
|
|
427
|
+
if (pillField === undefined)
|
|
428
|
+
return _jsx(DataTableCellBody, { ...props });
|
|
429
|
+
const pill = _jsx(CellPill, { row: row, pillField: pillField, pillToneField: pillToneField });
|
|
430
|
+
if (isEmptyCellValue(row[pillField]))
|
|
431
|
+
return _jsx(DataTableCellBody, { ...props });
|
|
432
|
+
return (_jsxs("span", { className: "inline-flex items-center gap-2", children: [_jsx(DataTableCellBody, { ...props }), pill] }));
|
|
433
|
+
}
|
|
434
|
+
function DataTableCellBody({ value, row, field, type, renderer, optionLabels, optionTones, onChange, translate, locale, grouping = true, fileDisplay, compactFile = false, link, linkItems, hint, display, badgeToneField, badgeDot, emptyPlaceholder, dateOnlyAfterDays, onOpenRow, }) {
|
|
394
435
|
const componentRef = isComponentRendererRef(renderer);
|
|
395
436
|
const ResolvedComponent = useColumnRenderer(componentRef?.name);
|
|
396
437
|
const RegisteredStatusBadge = useOptionalPrimitives()?.StatusBadge;
|
|
397
438
|
if (hint !== undefined) {
|
|
398
439
|
return (_jsx(HintCell, { value: value, row: row, hint: hint, ...(onOpenRow !== undefined && { onOpen: onOpenRow }) }));
|
|
399
440
|
}
|
|
400
|
-
|
|
441
|
+
// A function renderer formats its own values; only an explicit `emptyPlaceholder` takes an empty value over.
|
|
442
|
+
const showsPlaceholder = typeof renderer !== "function"
|
|
443
|
+
? isEmptyCellValue(value)
|
|
444
|
+
: typeof emptyPlaceholder === "string" &&
|
|
445
|
+
(isEmptyCellValue(value) || (Array.isArray(value) && value.length === 0));
|
|
446
|
+
if (showsPlaceholder && componentRef === undefined) {
|
|
401
447
|
return _jsx(EmptyCell, { placeholder: emptyPlaceholder });
|
|
402
448
|
}
|
|
403
449
|
if (value === PII_ERASED_SENTINEL && translate !== undefined) {
|
|
@@ -425,6 +471,12 @@ function DataTableCellBody({ value, row, field, type, renderer, optionLabels, op
|
|
|
425
471
|
});
|
|
426
472
|
if (displayCell !== undefined)
|
|
427
473
|
return displayCell;
|
|
474
|
+
const dateOnlyText = dateOnlyAfterDays === undefined
|
|
475
|
+
? undefined
|
|
476
|
+
: dateOnlyWhenOlderThan(value, dateOnlyAfterDays, locale, renderer);
|
|
477
|
+
if (dateOnlyText !== undefined) {
|
|
478
|
+
return link === undefined ? (dateOnlyText) : (_jsx(CellTextLink, { link: link, children: dateOnlyText }));
|
|
479
|
+
}
|
|
428
480
|
if (typeof value === "boolean" &&
|
|
429
481
|
isBooleanColumn(type, renderer) &&
|
|
430
482
|
(renderer === undefined || isUnlabeledBooleanFormat(renderer))) {
|
|
@@ -436,34 +488,21 @@ function DataTableCellBody({ value, row, field, type, renderer, optionLabels, op
|
|
|
436
488
|
return renderFileCell({ value, fileDisplay, compactFile, translate });
|
|
437
489
|
}
|
|
438
490
|
if (isFormatSpecRenderer(renderer)) {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
}
|
|
448
|
-
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
491
|
+
return renderFormatSpecCell({
|
|
492
|
+
renderer,
|
|
493
|
+
value,
|
|
494
|
+
translate,
|
|
495
|
+
locale,
|
|
496
|
+
link,
|
|
497
|
+
RegisteredStatusBadge,
|
|
498
|
+
});
|
|
449
499
|
}
|
|
450
500
|
if (isFunctionRenderer(renderer)) {
|
|
451
|
-
|
|
452
|
-
const linkItemKeys = uniqueLinkItemKeys(linkItems);
|
|
453
|
-
return (_jsx(_Fragment, { children: linkItems.map((item, index) => (_jsxs(Fragment, { children: [index > 0 && ", ", item.link === undefined ? (item.label) : (_jsx(CellTextLink, { link: item.link, children: item.label }))] }, linkItemKeys[index]))) }));
|
|
454
|
-
}
|
|
455
|
-
const text = renderer(value, row);
|
|
456
|
-
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
501
|
+
return renderFunctionRendererCell({ renderer, value, row, link, linkItems });
|
|
457
502
|
}
|
|
458
503
|
if (componentRef !== undefined) {
|
|
459
504
|
if (ResolvedComponent !== undefined) {
|
|
460
|
-
|
|
461
|
-
// stopPropagation only on the editable branch — plain cells must still
|
|
462
|
-
// fire row onClick when onCellChange is set for sibling editable cells.
|
|
463
|
-
if (onChange !== undefined) {
|
|
464
|
-
return (_jsx("span", { className: "contents", onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), children: node }));
|
|
465
|
-
}
|
|
466
|
-
return node;
|
|
505
|
+
return renderResolvedComponentCell({ ResolvedComponent, value, row, field, onChange });
|
|
467
506
|
}
|
|
468
507
|
// Renderer referenced in the schema but no map entry client-side —
|
|
469
508
|
// typical case: clientFeatures.columnRenderers forgotten or a typo in the
|
|
@@ -471,11 +510,53 @@ function DataTableCellBody({ value, row, field, type, renderer, optionLabels, op
|
|
|
471
510
|
// (the default type renderer takes over).
|
|
472
511
|
rendererWarn(`[kumiko] columnRenderer "${componentRef.name}" not registered`);
|
|
473
512
|
}
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
513
|
+
const selectCell = renderSelectTypeCell({
|
|
514
|
+
type,
|
|
515
|
+
value,
|
|
516
|
+
optionLabels,
|
|
517
|
+
optionTones,
|
|
518
|
+
locale,
|
|
519
|
+
RegisteredStatusBadge,
|
|
520
|
+
});
|
|
521
|
+
if (selectCell !== undefined)
|
|
522
|
+
return selectCell;
|
|
523
|
+
const text = defaultCellRender(value, type, optionLabels, locale, field, grouping);
|
|
524
|
+
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
525
|
+
}
|
|
526
|
+
function renderFormatSpecCell({ renderer, value, translate, locale, link, RegisteredStatusBadge, }) {
|
|
527
|
+
const text = applyFormatSpec({ ...renderer, locale: renderer.locale ?? locale }, value, translate);
|
|
528
|
+
const phoneHref = renderer.format === "phone" ? telHref(text) : undefined;
|
|
529
|
+
if (phoneHref !== undefined) {
|
|
530
|
+
return (_jsx(CellTextLink, { link: { href: phoneHref, onPress: () => window.location.assign(phoneHref) }, children: text }));
|
|
531
|
+
}
|
|
532
|
+
const tones = enumOptionTones(renderer);
|
|
533
|
+
if (tones !== undefined && typeof value === "string") {
|
|
534
|
+
return selectPill(value, { [value]: text }, tones, locale, RegisteredStatusBadge);
|
|
535
|
+
}
|
|
536
|
+
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
537
|
+
}
|
|
538
|
+
function renderFunctionRendererCell({ renderer, value, row, link, linkItems, }) {
|
|
539
|
+
if (linkItems !== undefined) {
|
|
540
|
+
const linkItemKeys = uniqueLinkItemKeys(linkItems);
|
|
541
|
+
return (_jsx(_Fragment, { children: linkItems.map((item, index) => (_jsxs(Fragment, { children: [index > 0 && ", ", item.link === undefined ? (item.label) : (_jsx(CellTextLink, { link: item.link, children: item.label }))] }, linkItemKeys[index]))) }));
|
|
542
|
+
}
|
|
543
|
+
const text = renderer(value, row);
|
|
544
|
+
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
545
|
+
}
|
|
546
|
+
function renderResolvedComponentCell({ ResolvedComponent, value, row, field, onChange, }) {
|
|
547
|
+
const node = (_jsx(ResolvedComponent, { value: value, row: row, column: { field }, ...(onChange !== undefined && { onChange }) }));
|
|
548
|
+
// stopPropagation only on the editable branch — plain cells must still
|
|
549
|
+
// fire row onClick when onCellChange is set for sibling editable cells.
|
|
550
|
+
if (onChange === undefined)
|
|
551
|
+
return node;
|
|
552
|
+
return (_jsx("span", { className: "contents", onClick: (e) => e.stopPropagation(), onKeyDown: (e) => e.stopPropagation(), children: node }));
|
|
553
|
+
}
|
|
554
|
+
// A select value renders as a pill instead of plain text. When the raw
|
|
555
|
+
// value is a known status word, it carries the same tone as the
|
|
556
|
+
// projectionDetail header badge — a status column stayed grey while the
|
|
557
|
+
// detail view of the same value was coloured. Unknown values
|
|
558
|
+
// keep the neutral outline pill.
|
|
559
|
+
function renderSelectTypeCell({ type, value, optionLabels, optionTones, locale, RegisteredStatusBadge, }) {
|
|
479
560
|
if (type === "select" && value !== null && value !== undefined && value !== "") {
|
|
480
561
|
return selectPill(value, optionLabels, optionTones, locale, RegisteredStatusBadge);
|
|
481
562
|
}
|
|
@@ -483,6 +564,5 @@ function DataTableCellBody({ value, row, field, type, renderer, optionLabels, op
|
|
|
483
564
|
if (type === "multiSelect" && Array.isArray(value) && value.length > 0) {
|
|
484
565
|
return (_jsx("span", { className: "flex flex-wrap gap-1", children: value.map((entry) => (_jsx(Fragment, { children: selectPill(entry, optionLabels, optionTones, locale, RegisteredStatusBadge) }, String(entry)))) }));
|
|
485
566
|
}
|
|
486
|
-
|
|
487
|
-
return link === undefined ? text : _jsx(CellTextLink, { link: link, children: text });
|
|
567
|
+
return undefined;
|
|
488
568
|
}
|
|
@@ -34,5 +34,5 @@ export function DefaultDataTable(props) {
|
|
|
34
34
|
// (that lives in the shell's breadcrumb). The toolbar is NOT sticky: lists
|
|
35
35
|
// typically scroll with the page container, not internally. Sticky would
|
|
36
36
|
// compete with the topbar.
|
|
37
|
-
return (_jsxs("div", { className: wrapperClassName(model), children: [!mergesDescription && !model.fillsHeight && renderToolbarDescription(model, hasToolbar), hasToolbar && renderToolbar(model, facetCluster), !mergesDescription && model.fillsHeight && renderToolbarDescription(model, hasToolbar), renderTableContent(model)] }));
|
|
37
|
+
return (_jsxs("div", { ref: model.containerRef, className: wrapperClassName(model), children: [!mergesDescription && !model.fillsHeight && renderToolbarDescription(model, hasToolbar), hasToolbar && renderToolbar(model, facetCluster), !mergesDescription && model.fillsHeight && renderToolbarDescription(model, hasToolbar), renderTableContent(model)] }));
|
|
38
38
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
2
|
import { type FormProps } from "../../index.ts";
|
|
3
3
|
import "../react-css-custom-properties.ts";
|
|
4
|
-
export declare function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, subtitle, actions, secondaryActions, testId, width, stickyActions, headerRegion, titleAction, fillHeight, chromeless, screenForm, unsavedCount, sectionNav, sideRail, summary, }: FormProps): ReactNode;
|
|
4
|
+
export declare function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, subtitle, actions, secondaryActions, testId, width, stickyActions, headerRegion, titleAction, fillHeight, chromeless, screenForm, unsavedCount, sectionNav, sideRail, summary, topBanner, }: FormProps): ReactNode;
|
|
@@ -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 { useContext } from "react";
|
|
3
3
|
import { InsideDrawerProvider, useInsideDrawer, useTranslation, } from "../../index.js";
|
|
4
4
|
import { cn } from "../lib/cn.js";
|
|
@@ -15,17 +15,18 @@ import { unsavedStatusText } from "./form-footer-parts.js";
|
|
|
15
15
|
function FormSummaryBox({ summary, testId }) {
|
|
16
16
|
if (summary === undefined)
|
|
17
17
|
return null;
|
|
18
|
-
return (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-summary` : undefined, className: "flex flex-col gap-
|
|
18
|
+
return (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-summary` : undefined, className: "flex flex-col gap-[3px] rounded-[9px] border border-l-[3px] border-border-strong border-l-primary bg-card px-4 py-[13px]", children: [_jsx("span", { className: "text-[15px] leading-[21px] font-semibold text-foreground", children: summary.title }), summary.subtitle !== undefined && (_jsx("span", { className: "text-[13.5px] text-foreground-secondary", children: summary.subtitle }))] }));
|
|
19
19
|
}
|
|
20
|
-
function DrawerFormLayout({ onSubmit, focusFirstErrorKey, subtitle, actions, secondaryActions, summary, testId, children, }) {
|
|
21
|
-
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex h-full min-h-0 w-full flex-col", children: [_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : undefined, className: "flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-6 py-5", children: [_jsx(FormSummaryBox, { summary: summary, testId: testId }), subtitle !== undefined && (_jsx("p", { "data-testid": testId !== undefined ? `${testId}-subtitle` : undefined, className: "text-[13px] text-foreground-secondary", children: subtitle })), _jsx(InsideFormContext.Provider, { value: true, children: _jsx(ScreenFormContext.Provider, { value: true, children: _jsx(InsideDrawerProvider, { value: false, children: _jsx(DrawerBodyContext.Provider, { value: true, children: _jsx("div", { className: "flex flex-col gap-5", children: children }) }) }) }) })] }), (actions !== undefined || secondaryActions !== undefined) && (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-footer` : undefined, className: "flex h-16 shrink-0 items-center justify-end gap-2 border-t border-border px-6", children: [secondaryActions, actions] }))] }));
|
|
20
|
+
function DrawerFormLayout({ onSubmit, focusFirstErrorKey, subtitle, actions, secondaryActions, summary, topBanner, testId, children, }) {
|
|
21
|
+
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex h-full min-h-0 w-full flex-col", children: [_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : undefined, className: "flex min-h-0 flex-1 flex-col gap-5 overflow-y-auto px-6 py-5", children: [topBanner, _jsx(FormSummaryBox, { summary: summary, testId: testId }), subtitle !== undefined && (_jsx("p", { "data-testid": testId !== undefined ? `${testId}-subtitle` : undefined, className: "text-[13px] text-foreground-secondary", children: subtitle })), _jsx(InsideFormContext.Provider, { value: true, children: _jsx(ScreenFormContext.Provider, { value: true, children: _jsx(InsideDrawerProvider, { value: false, children: _jsx(DrawerBodyContext.Provider, { value: true, children: _jsx("div", { className: "flex flex-col gap-5", children: children }) }) }) }) })] }), (actions !== undefined || secondaryActions !== undefined) && (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-footer` : undefined, className: "flex h-16 shrink-0 items-center justify-end gap-2 border-t border-border px-6", children: [secondaryActions, actions] }))] }));
|
|
22
22
|
}
|
|
23
23
|
function EmbeddedFormLayout({ onSubmit, focusFirstErrorKey, actions, secondaryActions, unsavedCount, testId, children, }) {
|
|
24
24
|
const t = useTranslation();
|
|
25
25
|
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex w-full flex-col gap-6", children: [_jsx(FormSections, { chromeless: true, stickyActions: undefined, fillHeight: false, screenForm: true, children: children }), (actions !== undefined || secondaryActions !== undefined) && (_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-footer` : undefined, className: "flex flex-wrap items-center gap-2", children: [actions, secondaryActions, unsavedCount !== undefined && unsavedCount > 0 && (_jsxs("span", { "data-testid": testId !== undefined ? `${testId}-unsaved` : undefined, className: "flex items-center gap-2 text-[13px] text-foreground-secondary", children: [_jsx("span", { className: "size-1.5 shrink-0 rounded-full bg-status-active", "aria-hidden": "true" }), unsavedStatusText(t, unsavedCount)] }))] }))] }));
|
|
26
26
|
}
|
|
27
|
-
export function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, subtitle, actions, secondaryActions, testId, width, stickyActions, headerRegion, titleAction, fillHeight, chromeless, screenForm, unsavedCount, sectionNav, sideRail, summary, }) {
|
|
27
|
+
export function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, subtitle, actions, secondaryActions, testId, width, stickyActions, headerRegion, titleAction, fillHeight, chromeless, screenForm, unsavedCount, sectionNav, sideRail, summary, topBanner, }) {
|
|
28
28
|
const insideDrawer = useInsideDrawer();
|
|
29
|
+
const bodyWithTopBanner = topBanner === undefined ? (children) : (_jsxs(_Fragment, { children: [topBanner, children] }));
|
|
29
30
|
const isEmbeddedForm = useContext(EmbeddedFormContext);
|
|
30
31
|
const contextWidth = useContext(ScreenWidthContext);
|
|
31
32
|
// Embedded (AuthCard etc.): bare <form>, stacked fields with gap; the
|
|
@@ -34,17 +35,17 @@ export function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, sub
|
|
|
34
35
|
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: cn("flex flex-col gap-4",
|
|
35
36
|
// Bare forms stack sections without a card; without a divider a
|
|
36
37
|
// section boundary reads as a layout gap, not structure.
|
|
37
|
-
"[&>section:not(:first-child)]:border-t"), children: [headerRegion, _jsx(InsideFormContext.Provider, { value: true, children:
|
|
38
|
+
"[&>section:not(:first-child)]:border-t"), children: [headerRegion, _jsx(InsideFormContext.Provider, { value: true, children: bodyWithTopBanner }), (secondaryActions !== undefined || actions !== undefined) && (_jsxs("div", { className: "flex items-center justify-end gap-2", children: [secondaryActions, actions] }))] }));
|
|
38
39
|
}
|
|
39
40
|
if (insideDrawer) {
|
|
40
|
-
return (_jsx(DrawerFormLayout, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, subtitle: subtitle, actions: actions, secondaryActions: secondaryActions, summary: summary, testId: testId, children: children }));
|
|
41
|
+
return (_jsx(DrawerFormLayout, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, subtitle: subtitle, actions: actions, secondaryActions: secondaryActions, summary: summary, topBanner: topBanner, testId: testId, children: children }));
|
|
41
42
|
}
|
|
42
43
|
if (isEmbeddedForm) {
|
|
43
|
-
return (_jsx(EmbeddedFormLayout, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, actions: actions, secondaryActions: secondaryActions, unsavedCount: unsavedCount, testId: testId, children:
|
|
44
|
+
return (_jsx(EmbeddedFormLayout, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, actions: actions, secondaryActions: secondaryActions, unsavedCount: unsavedCount, testId: testId, children: bodyWithTopBanner }));
|
|
44
45
|
}
|
|
45
46
|
const isScreenForm = screenForm === true && fillHeight === true && chromeless !== true;
|
|
46
47
|
const screenFormWidth = width ?? contextWidth;
|
|
47
|
-
const sections = (_jsx(FormSections, { chromeless: chromeless === true, stickyActions: stickyActions, fillHeight: fillHeight, screenForm: isScreenForm, children: children }));
|
|
48
|
+
const sections = (_jsx(FormSections, { chromeless: chromeless === true, stickyActions: stickyActions, fillHeight: fillHeight, screenForm: isScreenForm, children: isScreenForm ? children : bodyWithTopBanner }));
|
|
48
49
|
const footer = (_jsx(FormFooter, { actions: actions, secondaryActions: secondaryActions, testId: testId, chromeless: chromeless === true, stickyActions: stickyActions, fillHeight: fillHeight, ...(unsavedCount !== undefined && { unsavedCount }), railed: sideRail !== undefined }));
|
|
49
50
|
// Screen form: no card. A padded scroll surface holds the form column and,
|
|
50
51
|
// from xl, the section navigation; the footer stays pinned below it.
|
|
@@ -52,7 +53,7 @@ export function DefaultForm({ onSubmit, focusFirstErrorKey, children, title, sub
|
|
|
52
53
|
const showsSectionNav = sectionNav !== undefined && sectionNav.length >= SECTION_NAV_MIN_ITEMS;
|
|
53
54
|
return (_jsxs(FormRoot, { onSubmit: onSubmit, focusFirstErrorKey: focusFirstErrorKey, testId: testId, className: "flex h-full min-h-0 w-full flex-col", children: [_jsxs("div", { className: "flex min-h-0 flex-1 flex-col lg:flex-row", children: [sideRail, _jsx("div", { "data-testid": testId !== undefined ? `${testId}-scroll` : undefined, className: cn("min-h-0 flex-1 overflow-y-auto", screenPaddingClassName), children: _jsxs("div", { className: "flex gap-18", children: [_jsxs("div", { className: cn("flex w-full min-w-0 flex-col gap-9", screenFormWidth !== undefined
|
|
54
55
|
? screenFormColumnWidthClassName[screenFormWidth]
|
|
55
|
-
: "max-w-[640px]"), children: [headerRegion !== undefined && (_jsx("div", { className: "flex flex-col gap-9", children: _jsx(InsideScreenFormColumnContext.Provider, { value: true, children: headerRegion }) })), _jsx(FormTitleBlock, { title: title, subtitle: subtitle, titleAction: titleAction, testId: testId, bordered: false, fillHeight: false }), _jsx(FormSummaryBox, { summary: summary, testId: testId }), sections] }), showsSectionNav && _jsx(FormSectionNav, { items: sectionNav })] }) })] }), footer] }));
|
|
56
|
+
: "max-w-[640px]"), children: [headerRegion !== undefined && (_jsx("div", { className: "flex flex-col gap-9", children: _jsx(InsideScreenFormColumnContext.Provider, { value: true, children: headerRegion }) })), _jsx(FormTitleBlock, { title: title, subtitle: subtitle, titleAction: titleAction, testId: testId, bordered: false, fillHeight: false }), topBanner, _jsx(FormSummaryBox, { summary: summary, testId: testId }), sections] }), showsSectionNav && _jsx(FormSectionNav, { items: sectionNav })] }) })] }), footer] }));
|
|
56
57
|
}
|
|
57
58
|
// Pinned footer (fillHeight + stickyActions): the footer is a full-bleed
|
|
58
59
|
// sibling BELOW the padded shell, so the shell's bottom inset does not float
|
|
@@ -8,14 +8,9 @@ import { XIcon } from "lucide-react";
|
|
|
8
8
|
import { useTranslation } from "../../index.js";
|
|
9
9
|
import { SheetTitle } from "../ui/sheet.js";
|
|
10
10
|
import { Drawer } from "../widgets/drawer.js";
|
|
11
|
-
import { useIsNarrowViewport } from "./use-narrow-viewport.js";
|
|
12
|
-
const DRAWER_WIDTH_PX = 480;
|
|
13
11
|
const DRAWER_DIM_PERCENT = 32;
|
|
14
|
-
const PANEL_CLASS = "bg-
|
|
12
|
+
const PANEL_CLASS = "bg-background border-border-strong shadow-[-12px_0_32px_rgb(0_0_0/0.14)]";
|
|
15
13
|
export function DefaultDrawer({ open, onOpenChange, title, subtitle, children, testId, }) {
|
|
16
14
|
const t = useTranslation();
|
|
17
|
-
|
|
18
|
-
// instead of a full-screen takeover.
|
|
19
|
-
const narrow = useIsNarrowViewport();
|
|
20
|
-
return (_jsxs(Drawer, { open: open, onOpenChange: onOpenChange, testId: testId, variant: "flush", side: narrow ? "bottom" : "right", width: DRAWER_WIDTH_PX, backdrop: { dimPercent: DRAWER_DIM_PERCENT }, showCloseButton: false, panelClassName: narrow ? undefined : PANEL_CLASS, fillBody: true, children: [_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-header` : undefined, className: "flex min-h-14 shrink-0 items-center gap-3 border-b border-border py-2 pr-3 pl-6", children: [_jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx(SheetTitle, { className: "text-base font-semibold", children: title ?? "" }), subtitle !== undefined && (_jsx("p", { "data-testid": testId !== undefined ? `${testId}-subtitle` : undefined, className: "text-sm text-muted-foreground", children: subtitle }))] }), _jsx("button", { type: "button", "aria-label": t("kumiko.dialog.close"), onClick: () => onOpenChange(false), className: "flex size-8 items-center justify-center rounded-md text-foreground-secondary hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-hidden", children: _jsx(XIcon, { className: "size-4" }) })] }), _jsx("div", { "data-testid": testId !== undefined ? `${testId}-body` : undefined, onSubmit: (e) => e.stopPropagation(), className: "flex min-h-0 flex-1 flex-col", children: children })] }));
|
|
15
|
+
return (_jsxs(Drawer, { open: open, onOpenChange: onOpenChange, testId: testId, variant: "flush", side: "right", backdrop: { dimPercent: DRAWER_DIM_PERCENT }, showCloseButton: false, panelClassName: PANEL_CLASS, fillBody: true, children: [_jsxs("div", { "data-testid": testId !== undefined ? `${testId}-header` : undefined, className: "flex min-h-14 shrink-0 items-center gap-3 border-b border-border py-2 pr-3 pl-6", children: [_jsxs("div", { className: "flex min-w-0 flex-1 flex-col", children: [_jsx(SheetTitle, { className: "text-base font-semibold", children: title ?? "" }), subtitle !== undefined && (_jsx("p", { "data-testid": testId !== undefined ? `${testId}-subtitle` : undefined, className: "text-sm text-muted-foreground", children: subtitle }))] }), _jsx("button", { type: "button", "aria-label": t("kumiko.dialog.close"), onClick: () => onOpenChange(false), className: "flex size-8 items-center justify-center rounded-md text-foreground-secondary hover:bg-muted focus-visible:ring-2 focus-visible:ring-ring focus-visible:outline-hidden", children: _jsx(XIcon, { className: "size-4" }) })] }), _jsx("div", { "data-testid": testId !== undefined ? `${testId}-body` : undefined, onSubmit: (e) => e.stopPropagation(), className: "flex min-h-0 flex-1 flex-col", children: children })] }));
|
|
21
16
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type ReactNode } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import type { DataTableDateRangeFacet, DataTableFacet } from "../../index.ts";
|
|
3
3
|
import "../react-css-custom-properties.ts";
|
|
4
4
|
export declare function FacetFilter({ facet, selected, onChange, dense, pill, }: {
|
|
5
5
|
facet: DataTableFacet;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { ChevronDown } from "lucide-react";
|
|
3
3
|
import { Fragment } from "react";
|
|
4
|
-
import { useOptionalTranslation, } from "../../index.js";
|
|
5
4
|
import { cn } from "../lib/cn.js";
|
|
6
5
|
import { Badge } from "../ui/badge.js";
|
|
7
6
|
import { Button as UiButton } from "../ui/button.js";
|
|
@@ -35,7 +34,7 @@ function FacetSelect({ facet, selected, onChange, dense, pill, }) {
|
|
|
35
34
|
// A stale URL can name an entry the facet does not offer; showing "all" then would misstate the list.
|
|
36
35
|
const active = chips.find((chip) => sameValueSet(selected, chip.values)) ??
|
|
37
36
|
(isFiltered ? undefined : chips[0]);
|
|
38
|
-
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(UiButton, { variant: "outline", size: "sm", className: cn("h-9", dense && "border-border-strong px-2.5", pill && FACET_PILL_CLASSES, isFiltered && "border-primary"), "data-testid": `facet-${facet.field}`, children: [_jsx("span", { className: "text-muted-foreground", children: active === undefined ? facet.label : `${facet.label}: ` }), active !== undefined && (_jsx("span", { "data-testid": `facet-${facet.field}-value`, className: isFiltered ? "font-medium text-primary" : "text-foreground", children: active.label })), _jsx(ChevronDown, { className: "text-muted-foreground" })] }) }), _jsx(DropdownMenuContent, { align: "start", className: "max-h-[var(--radix-dropdown-menu-content-available-height)] w-56 overflow-y-auto", children: _jsx(DropdownMenuRadioGroup, { value: active?.id ?? "", onValueChange: (id) => {
|
|
37
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(UiButton, { variant: "outline", size: "sm", className: cn("h-9", dense && "border-border-strong px-2.5", pill && FACET_PILL_CLASSES, isFiltered && "border-primary"), "data-testid": `facet-${facet.field}`, children: [_jsx("span", { className: "text-muted-foreground", children: active === undefined || !isFiltered ? facet.label : `${facet.label}: ` }), active !== undefined && isFiltered && (_jsx("span", { "data-testid": `facet-${facet.field}-value`, className: isFiltered ? "font-medium text-primary" : "text-foreground", children: active.label })), _jsx(ChevronDown, { className: "text-muted-foreground" })] }) }), _jsx(DropdownMenuContent, { align: "start", className: "max-h-[var(--radix-dropdown-menu-content-available-height)] w-56 overflow-y-auto", children: _jsx(DropdownMenuRadioGroup, { value: active?.id ?? "", onValueChange: (id) => {
|
|
39
38
|
if (id === active?.id)
|
|
40
39
|
return;
|
|
41
40
|
const chip = chips.find((candidate) => candidate.id === id);
|
|
@@ -46,8 +45,6 @@ function FacetSelect({ facet, selected, onChange, dense, pill, }) {
|
|
|
46
45
|
// Faceted filter dropdown: outline button (like shadcn's "Columns" toggle) +
|
|
47
46
|
// multi-select checkboxes. Active selection -> count badge on the button.
|
|
48
47
|
export function FacetFilter({ facet, selected, onChange, dense = false, pill = false, }) {
|
|
49
|
-
const translate = useOptionalTranslation();
|
|
50
|
-
const allLabel = translate?.("kumiko.list.filter.all") ?? "All";
|
|
51
48
|
const toggle = (value, checked) => {
|
|
52
49
|
const next = checked ? [...selected, value] : selected.filter((v) => v !== value);
|
|
53
50
|
onChange(facet.field, next);
|
|
@@ -61,7 +58,7 @@ export function FacetFilter({ facet, selected, onChange, dense = false, pill = f
|
|
|
61
58
|
if (facet.onSearchChange !== undefined) {
|
|
62
59
|
return (_jsx(FacetSearchFilter, { facet: facet, onSearchChange: facet.onSearchChange, selected: selected, onChange: onChange, dense: dense, pill: pill }));
|
|
63
60
|
}
|
|
64
|
-
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(UiButton, { variant: "outline", size: "sm", className: cn("h-9", dense && "border-border-strong px-2.5", pill && FACET_PILL_CLASSES), "data-testid": `facet-${facet.field}`, children: [selected.length === 0 ?
|
|
61
|
+
return (_jsxs(DropdownMenu, { children: [_jsx(DropdownMenuTrigger, { asChild: true, children: _jsxs(UiButton, { variant: "outline", size: "sm", className: cn("h-9", dense && "border-border-strong px-2.5", pill && FACET_PILL_CLASSES), "data-testid": `facet-${facet.field}`, children: [selected.length === 0 ? _jsx(FacetTriggerLabel, { label: facet.label }) : facet.label, selected.length > 0 && (_jsx(Badge, { variant: "secondary", className: "ml-1 rounded-sm px-1 font-normal tabular-nums", children: selected.length })), _jsx(ChevronDown, { className: "text-muted-foreground" })] }) }), _jsx(DropdownMenuContent, { align: "start", className: "max-h-[var(--radix-dropdown-menu-content-available-height)] w-44 overflow-y-auto", children: facet.options.map((opt) => (_jsx(DropdownMenuCheckboxItem, { checked: selected.includes(opt.value), onCheckedChange: (checked) => toggle(opt.value, checked), onSelect: (e) => e.preventDefault(), "data-testid": `facet-${facet.field}-${opt.value}`, children: opt.label }, opt.value))) })] }));
|
|
65
62
|
}
|
|
66
63
|
// Time-range filter: two native <input type="date"> instead of a
|
|
67
64
|
// dropdown — the browser supplies the calendar, the locale and the keyboard
|
|
@@ -26,7 +26,7 @@ export function FacetSearchFilter({ facet, onSearchChange, selected, onChange, d
|
|
|
26
26
|
const toggle = (value) => {
|
|
27
27
|
onChange(facet.field, selected.includes(value) ? selected.filter((v) => v !== value) : [...selected, value]);
|
|
28
28
|
};
|
|
29
|
-
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs(UiButton, { variant: "outline", size: "sm", className: cn("h-9", dense && "border-border-strong px-2.5", pill && FACET_PILL_CLASSES), "data-testid": `facet-${facet.field}`, children: [selected.length === 0 ?
|
|
29
|
+
return (_jsxs(PopoverPrimitive.Root, { open: open, onOpenChange: setOpen, children: [_jsx(PopoverPrimitive.Trigger, { asChild: true, children: _jsxs(UiButton, { variant: "outline", size: "sm", className: cn("h-9", dense && "border-border-strong px-2.5", pill && FACET_PILL_CLASSES), "data-testid": `facet-${facet.field}`, children: [selected.length === 0 ? _jsx(FacetTriggerLabel, { label: facet.label }) : facet.label, selected.length > 0 && (_jsx(Badge, { variant: "secondary", className: "ml-1 rounded-sm px-1 font-normal tabular-nums", children: selected.length })), _jsx(ChevronDown, { className: "text-muted-foreground" })] }) }), _jsx(PopoverPrimitive.Portal, { children: _jsx(PopoverPrimitive.Content, { align: "start", sideOffset: 4, className: "z-50 w-64 rounded-md border bg-popover p-0 text-popover-foreground shadow-md outline-none", children: _jsxs(Command, { shouldFilter: false, children: [_jsxs("div", { className: "relative", children: [_jsx(Command.Input, { value: searchTerm, onValueChange: setSearchTerm, placeholder: t("kumiko.combobox.search-placeholder"), "data-testid": `facet-${facet.field}-search`, className: "flex h-9 w-full border-0 border-b border-border bg-transparent px-3 py-1 text-sm outline-none placeholder:text-muted-foreground" }), facet.searching === true && (_jsx(Loader2, { className: "absolute right-2 top-2.5 h-4 w-4 animate-spin text-muted-foreground" }))] }), _jsxs(Command.List, { className: "max-h-64 overflow-y-auto p-1", children: [_jsx(Command.Empty, { className: "py-3 text-center text-sm text-muted-foreground", children: facet.searching === true
|
|
30
30
|
? t("kumiko.combobox.loading")
|
|
31
31
|
: t("kumiko.combobox.empty") }), facet.options.map((opt) => (_jsxs(Command.Item, { value: opt.value, onSelect: () => toggle(opt.value), "data-testid": `facet-${facet.field}-${opt.value}`, className: "relative flex cursor-pointer select-none items-center rounded-sm py-1.5 pl-8 pr-2 text-sm outline-none aria-selected:bg-accent aria-selected:text-accent-foreground", children: [selected.includes(opt.value) && (_jsx("span", { className: "absolute left-2 flex h-3.5 w-3.5 items-center justify-center", children: _jsx(Check, { className: "h-4 w-4" }) })), opt.label] }, opt.value)))] })] }) }) })] }));
|
|
32
32
|
}
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { ReactNode } from "react";
|
|
2
2
|
export declare const FACET_PILL_CLASSES = "h-9 rounded-full border-border-strong px-3";
|
|
3
|
-
export declare function FacetTriggerLabel({
|
|
4
|
-
readonly field: string;
|
|
3
|
+
export declare function FacetTriggerLabel({ label }: {
|
|
5
4
|
readonly label: string;
|
|
6
|
-
readonly emptyValueLabel: string;
|
|
7
|
-
readonly showEmptyValue: boolean;
|
|
8
5
|
}): ReactNode;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
export const FACET_PILL_CLASSES = "h-9 rounded-full border-border-strong px-3";
|
|
3
|
-
//
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
if (!showEmptyValue)
|
|
7
|
-
return _jsx("span", { className: "text-muted-foreground", children: label });
|
|
8
|
-
return (_jsxs(_Fragment, { children: [_jsx("span", { className: "text-muted-foreground", children: `${label}: ` }), _jsx("span", { "data-testid": `facet-${field}-value`, className: "text-foreground", children: emptyValueLabel })] }));
|
|
3
|
+
// A facet with nothing chosen names itself only, like the boards ("Property ▾").
|
|
4
|
+
export function FacetTriggerLabel({ label }) {
|
|
5
|
+
return _jsx("span", { className: "text-muted-foreground", children: label });
|
|
9
6
|
}
|