@sincpro/web-ui 2.18.0 → 2.19.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.
Files changed (69) hide show
  1. package/README.md +6 -4
  2. package/dist/components/calendar/RecordCalendar.js +1 -1
  3. package/dist/components/flow/SetupCard.d.ts +21 -0
  4. package/dist/components/flow/SetupCard.js +16 -0
  5. package/dist/components/flow/index.d.ts +1 -0
  6. package/dist/components/flow/index.js +3 -0
  7. package/dist/components/form/Form.js +7 -5
  8. package/dist/components/listing/Pagination.js +28 -3
  9. package/dist/components/listing/Row.d.ts +5 -2
  10. package/dist/components/listing/Row.js +6 -5
  11. package/dist/components/listing/modelCells.js +1 -1
  12. package/dist/components/navigation/NavigationTree.d.ts +3 -0
  13. package/dist/components/navigation/NavigationTree.js +2 -1
  14. package/dist/components/record/ActionDock.d.ts +10 -3
  15. package/dist/components/record/ActionDock.js +15 -8
  16. package/dist/components/record/DirtyActions.d.ts +15 -7
  17. package/dist/components/record/DirtyActions.js +37 -13
  18. package/dist/components/record/DockMessage.d.ts +18 -0
  19. package/dist/components/record/DockMessage.js +31 -0
  20. package/dist/components/record/dock.d.ts +25 -0
  21. package/dist/components/record/index.d.ts +2 -1
  22. package/dist/components/record/index.js +1 -0
  23. package/dist/components/shell/Page.d.ts +12 -0
  24. package/dist/components/shell/Page.js +12 -0
  25. package/dist/components/shell/Sidebar.d.ts +22 -3
  26. package/dist/components/shell/Sidebar.js +88 -10
  27. package/dist/components/shell/index.d.ts +1 -0
  28. package/dist/components/shell/index.js +2 -0
  29. package/dist/foundations/copy.es.js +5 -0
  30. package/dist/foundations/grouping.d.ts +37 -0
  31. package/dist/foundations/grouping.js +0 -0
  32. package/dist/foundations/index.d.ts +1 -1
  33. package/dist/foundations/index.js +1 -1
  34. package/dist/foundations/uiCopy.d.ts +10 -0
  35. package/dist/foundations/uiCopy.js +5 -0
  36. package/dist/primitives/button/Button.d.ts +5 -1
  37. package/dist/primitives/button/Button.js +4 -4
  38. package/dist/primitives/button/classes.d.ts +1 -8
  39. package/dist/primitives/button/classes.js +12 -2
  40. package/dist/primitives/menu/Menu.d.ts +22 -1
  41. package/dist/primitives/menu/Menu.js +44 -18
  42. package/dist/primitives/table/DataTable.d.ts +16 -1
  43. package/dist/primitives/table/DataTable.js +62 -22
  44. package/dist/primitives/table/EditableTable.js +6 -7
  45. package/dist/primitives/table/PileFootLine.d.ts +4 -2
  46. package/dist/primitives/table/PileFootLine.js +16 -5
  47. package/dist/primitives/table/ReportTable.js +2 -2
  48. package/dist/primitives/table/RowActions.js +1 -1
  49. package/dist/primitives/table/SheetTable.d.ts +19 -1
  50. package/dist/primitives/table/SheetTable.js +22 -2
  51. package/dist/primitives/table/Table.js +9 -6
  52. package/dist/primitives/table/index.d.ts +1 -1
  53. package/dist/primitives/table/index.js +1 -1
  54. package/dist/primitives/tabs/Tabs.d.ts +21 -1
  55. package/dist/primitives/tabs/Tabs.js +26 -7
  56. package/dist/primitives/tabs/index.d.ts +1 -1
  57. package/dist/primitives/tag/Tag.d.ts +5 -0
  58. package/dist/primitives/tag/Tag.js +2 -1
  59. package/dist/primitives/tag/Tags.js +1 -1
  60. package/dist/primitives/value/Avatar.d.ts +7 -3
  61. package/dist/primitives/value/Avatar.js +17 -11
  62. package/dist/primitives/value/Person.js +9 -3
  63. package/dist/primitives/value/Value.js +4 -1
  64. package/dist/views/list/ListView.js +27 -7
  65. package/dist/views/list/derive.d.ts +15 -3
  66. package/dist/views/list/derive.js +48 -6
  67. package/dist/views/list/presentations.js +2 -1
  68. package/dist/views/list/types.d.ts +5 -1
  69. package/package.json +1 -1
@@ -46,7 +46,7 @@ export { menuTriggerClasses };
46
46
  export function Menu({ label, groups, onSelect, surface = "canvas", align = "start", icon: Trigger,
47
47
  /** The menu as a control of a list ("filters ▾") carries the chevron; the
48
48
  * actions `⋯` does not, because the icon already says there is more. */
49
- chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, count, current = false, layout = "list", }) {
49
+ chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, count, current = false, layout = "list", header, trigger, placement, }) {
50
50
  const copy = useUiCopy();
51
51
  const { contains } = useFilter({ sensitivity: "base" });
52
52
  const byId = indexOptions(groups.flatMap((g) => g.options));
@@ -55,22 +55,28 @@ chevron = true, active = false, iconOnly = false, variant = "button", searchPlac
55
55
  option?.onSelect?.();
56
56
  onSelect?.(String(key));
57
57
  }, emptyText: emptyText ?? copy.menu.empty }));
58
- return (_jsxs(MenuTrigger, { children: [_jsx(AriaButton, { "data-ui": "menu.trigger", "aria-label": iconOnly ? label : undefined, ...(role === undefined ? {} : { "data-emphasis": role }), className: ({ isPressed, isFocusVisible }) => role === undefined
59
- ? menuTriggerClasses({
60
- variant,
61
- surface,
62
- active,
63
- current,
64
- open: isPressed,
65
- focusVisible: isFocusVisible,
66
- iconOnly,
67
- })
68
- : `${buttonClasses(role, size, surface)} gap-1.5`, children: _jsxs("span", { className: "contents", title: title ?? (iconOnly ? label : undefined), children: [Trigger === undefined ? (iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null) : (_jsx(Trigger, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })), iconOnly ? null : label, iconOnly || count === undefined ? null : _jsx(Count, { value: count, surface: surface }), chevron && !iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null] }) }), _jsx(Popover, { placement: align === "end" ? "bottom end" : "bottom start", className: layout === "columns" ? COLUMNS_WIDTH : WIDTH[width], children: searchPlaceholder === undefined ? (menu) : (
69
- /* The search box stays at the top: in a menu of twenty-five entries,
70
- scrolling loses exactly the control that explains why only three are
71
- visible. It filters on label AND hint — half the entries of this
72
- product are told apart only by the hint. */
73
- _jsxs(Autocomplete, { filter: contains, children: [_jsx(SearchField, { "aria-label": searchPlaceholder, autoFocus: true, className: "border-b border-line px-2 pt-2 pb-2", children: _jsx(Input, { placeholder: searchPlaceholder, className: "h-(--size-control-sm) w-full rounded-control border border-line-strong bg-surface px-2.5 text-meta text-ink outline-0 placeholder:text-muted focus-visible:border-primary" }) }), menu] })) })] }));
58
+ return (_jsxs(MenuTrigger, { children: [_jsx(AriaButton, { "data-ui": "menu.trigger", "aria-label": iconOnly && trigger === undefined ? label : undefined, ...(role === undefined ? {} : { "data-emphasis": role }), className: ({ isPressed, isFocusVisible }) => trigger !== undefined
59
+ ? `flex w-full min-w-0 cursor-default items-center gap-2 rounded-control p-1.5 text-left outline-0 transition-colors duration-(--duration-instant) ${surface === "chrome"
60
+ ? "hover:bg-chrome-ink/10 data-pressed:bg-chrome-ink/10"
61
+ : "hover:bg-ink/6 data-pressed:bg-ink/6"} ${isFocusVisible ? "outline-2 -outline-offset-2 outline-primary" : ""}`
62
+ : role === undefined
63
+ ? menuTriggerClasses({
64
+ variant,
65
+ surface,
66
+ active,
67
+ current,
68
+ open: isPressed,
69
+ focusVisible: isFocusVisible,
70
+ iconOnly,
71
+ })
72
+ : `${buttonClasses(role, size, surface)} gap-1.5`, children: trigger !== undefined ? (trigger) : (
73
+ /* `title` on a span: React Aria's button does not forward it. */
74
+ _jsxs("span", { className: "contents", title: title ?? (iconOnly ? label : undefined), children: [Trigger === undefined ? (iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null) : (_jsx(Trigger, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })), iconOnly ? null : label, iconOnly || count === undefined ? null : (_jsx(Count, { value: count, surface: surface })), chevron && !iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null] })) }), _jsxs(Popover, { placement: placement ?? (align === "end" ? "bottom end" : "bottom start"), className: layout === "columns" ? COLUMNS_WIDTH : WIDTH[width], children: [header === undefined ? null : (_jsx("div", { "data-ui": "menu.header", className: "border-b border-line px-3 py-2.5", children: header })), searchPlaceholder === undefined ? (menu) : (
75
+ /* The search box stays at the top: in a menu of twenty-five entries,
76
+ scrolling loses exactly the control that explains why only three are
77
+ visible. It filters on label AND hint — half the entries of this
78
+ product are told apart only by the hint. */
79
+ _jsxs(Autocomplete, { filter: contains, children: [_jsx(SearchField, { "aria-label": searchPlaceholder, autoFocus: true, className: "border-b border-line px-2 pt-2 pb-2", children: _jsx(Input, { placeholder: searchPlaceholder, className: "h-(--size-control-sm) w-full rounded-control border border-line-strong bg-surface px-2.5 text-meta text-ink outline-0 placeholder:text-muted focus-visible:border-primary" }) }), menu] }))] })] }));
74
80
  }
75
81
  /**
76
82
  * The panel of a `Menu`: its groups and rows, and the submenus hanging from them. Internal —
@@ -109,7 +115,12 @@ export function MenuList({ label, groups, onAction, closeOnSelect, emptyText, wi
109
115
  const Icon = o.icon;
110
116
  const opens = o.items !== undefined;
111
117
  const checked = !opens && o.checked === true;
112
- return (_jsxs(MenuItem, { id: o.id, textValue: o.hint === undefined ? o.label : `${o.label} ${o.hint}`, isDisabled: o.disabled, "data-ui": "menu.item", className: `flex w-full cursor-default rounded-ui-option ${hasHints ? "items-start py-1.5" : "items-center py-1"} gap-2 ${nested ? "pr-2 pl-(--spacing-indent)" : "px-2"} text-left outline-0 transition-colors duration-(--duration-instant) ${o.danger === true
118
+ return (_jsxs(MenuItem, { id: o.id, textValue: o.hint === undefined ? o.label : `${o.label} ${o.hint}`, isDisabled: o.disabled, ...(o.href === undefined || opens
119
+ ? {}
120
+ : {
121
+ href: o.href,
122
+ ...(o.target === undefined ? {} : { target: o.target, rel: "noreferrer" }),
123
+ }), "data-ui": "menu.item", className: `flex w-full cursor-default rounded-ui-option ${hasHints ? "items-start py-1.5" : "items-center py-1"} gap-2 ${nested ? "pr-2 pl-(--spacing-indent)" : "px-2"} text-left outline-0 transition-colors duration-(--duration-instant) ${o.danger === true
113
124
  ? "data-focused:bg-danger/10"
114
125
  : "data-focused:bg-ui-option-active data-open:bg-ui-option-active"} disabled:opacity-45`, children: [hasMarks ? (_jsx("span", { className: `${hasHints ? "mt-0.5" : ""} flex size-(--size-icon-sm) shrink-0 items-center justify-center`, children: checked ? (_jsx(Check, { className: "size-(--size-icon-sm) text-primary", strokeWidth: 2.5, "aria-hidden": true })) : Icon !== undefined ? (_jsx(Icon, { className: `size-(--size-icon-sm) ${o.danger === true ? "text-danger" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })) : null })) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${o.danger === true
115
126
  ? "text-danger"
@@ -121,6 +132,21 @@ export function MenuList({ label, groups, onAction, closeOnSelect, emptyText, wi
121
132
  const key = sectionKey(g, gi);
122
133
  const folding = folds(g);
123
134
  const open = !folding || unfolded.has(key);
135
+ if (g.inline === true) {
136
+ /* One row: the label, then each option as an icon toggle. They are still menu
137
+ items — the arrows walk them and Enter picks — only laid side by side. */
138
+ return (_jsxs(MenuSection, { "data-ui": "menu.section", "data-inline": true,
139
+ /* A choice of one: each mark is a `menuitemradio`, and the chosen one is
140
+ `aria-checked` — the tint alone told a screen reader nothing. */
141
+ selectionMode: "single", disallowEmptySelection: true, selectedKeys: g.options.filter((o) => o.checked === true).map((o) => o.id), className: `${SECTION[layout]} flex items-center gap-1 px-2 py-1`, children: [g.label === undefined ? null : (_jsx(Header, { className: "min-w-0 flex-1 truncate text-meta text-ink", children: g.label })), g.options.map((o) => {
142
+ const Icon = o.icon;
143
+ return (_jsx(MenuItem, { id: o.id, textValue: o.label, "aria-label": o.label, isDisabled: o.disabled,
144
+ /* Picking a theme shows it at once: the menu stays to compare. */
145
+ shouldCloseOnSelect: false, "data-ui": "menu.item", ...(o.checked === true ? { "data-checked": true } : {}), className: `flex size-(--size-control-sm) shrink-0 cursor-default items-center justify-center rounded-control outline-0 transition-colors duration-(--duration-instant) data-focused:bg-ui-option-active ${o.checked === true
146
+ ? "bg-ink/8 text-ink inset-ring inset-ring-line-strong"
147
+ : "text-muted"}`, children: _jsx("span", { title: o.label, className: "contents", children: Icon === undefined ? (_jsx("span", { className: "text-micro", children: o.label })) : (_jsx(Icon, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) }) }, o.id));
148
+ })] }, key));
149
+ }
124
150
  return (_jsxs(MenuSection, { "data-ui": "menu.section", className: SECTION[layout], children: [g.label === undefined ? null : folding ? (
125
151
  /* A folded section is a ROW you press — it is the door to the options, so it
126
152
  reads as one (ink, the row's size) and says how many wait behind it. The
@@ -1,3 +1,4 @@
1
+ import { type UiCopy } from "../../foundations/copy.js";
1
2
  import { type Pile } from "../../foundations/grouping.js";
2
3
  import type { Tone } from "../../foundations/types.js";
3
4
  import { type RowAction } from "./RowActions.js";
@@ -33,6 +34,9 @@ export declare function columnFormat<T>(column: DataColumn<T>, locale?: string):
33
34
  export declare function pileAggregate<T extends object>(column: DataColumn<T>, pile: Pile<T>): number | null;
34
35
  /** An aggregate of a column, written — or the bare number when nothing says how. */
35
36
  export declare function aggregateText<T>(column: DataColumn<T>, value: number): string | number;
37
+ /** A pile's or the footer's number as the table writes it: «Bs. 185.200,50», «máx 5». Exported
38
+ * for the presentations without columns, so a pile says the same thing in rows and tiles. */
39
+ export declare function aggregateLabel<T>(copy: UiCopy, column: DataColumn<T>, v: number): string;
36
40
  export interface DataColumn<T> {
37
41
  id: string;
38
42
  header: string;
@@ -64,6 +68,10 @@ export interface DataColumn<T> {
64
68
  * which is the normal case — a table with everything colored highlights
65
69
  * nothing. */
66
70
  tone?: (row: T) => Tone | undefined;
71
+ /** How the tone is carried: `fill` paints the cell (the default); `tag` writes the value
72
+ * as a `Tag` of that tone — a column of STATES («Observado», «Habilitado») — and the sheet
73
+ * derived from these columns draws it the same way (`SheetColumn.look`). */
74
+ look?: "fill" | "tag";
67
75
  /** Why it is painted, on hover. */
68
76
  note?: (row: T) => string | undefined;
69
77
  numeric?: boolean;
@@ -178,7 +186,7 @@ export type GroupColumn<T> = {
178
186
  /** How that key is read. */
179
187
  labelOf: (key: string) => string;
180
188
  };
181
- export declare function DataTable<T extends object>({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals, collapsed, onGroupToggle, piles, onMore, create, copyable, onReorder, }: {
189
+ export declare function DataTable<T extends object>({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals, collapsed, onGroupToggle, piles, onMore, pilesCount, morePiles, onMorePiles, create, copyable, onReorder, }: {
182
190
  data: readonly T[];
183
191
  columns: readonly DataColumn<T>[];
184
192
  getRowId: (row: T) => string;
@@ -222,6 +230,13 @@ export declare function DataTable<T extends object>({ data, columns, getRowId, s
222
230
  /** A pile shows its first page and counts them all: this asks for the next ones, and
223
231
  * the table offers it under each pile that holds fewer than it counts. */
224
232
  onMore?: (pile: Pile<T>) => void;
233
+ /** How many piles the first level holds over the whole set, when `piles` is its first
234
+ * page — see `Grouping.pilesCount`. The levels below say theirs in `Pile.pilesCount`. */
235
+ pilesCount?: number;
236
+ /** What the next «more groups» brings at the first level: `false` = no next page. */
237
+ morePiles?: number | false;
238
+ /** Asks for the next page of piles under `parent` (`null` = the first level). */
239
+ onMorePiles?: (parent: Pile<T> | null) => void;
225
240
  /** Write a new record as a row of the list. See the file's header. */
226
241
  create?: DataTableCreate<T>;
227
242
  /** The cells' copy buttons, on by default. `false` takes them off the whole table; a
@@ -2,7 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
3
  import { currentCopyLocale, fillCopy, useUiCopy, } from "../../foundations/copy.js";
4
4
  import { FieldBoundary } from "../../foundations/form.js";
5
- import { pathKey, pileFoot, pileItems, } from "../../foundations/grouping.js";
5
+ import { pathKey, pileFoot, pileItems, pilesFoot, } from "../../foundations/grouping.js";
6
6
  import { Switch } from "../choice/Switch.js";
7
7
  import { CellCopy } from "./CellCopy.js";
8
8
  import { CellEditor } from "./CellEditor.js";
@@ -13,6 +13,7 @@ import { RowActions } from "./RowActions.js";
13
13
  import { useRowReorder } from "./rowReorder.js";
14
14
  import { useRowWindow } from "./rowWindow.js";
15
15
  import { SelectBox, Table, Td, Th, THead, Tr } from "./Table.js";
16
+ import { Tag } from "../tag/Tag.js";
16
17
  import { YesNo } from "../value/YesNo.js";
17
18
  import { aggregationFns, columnGroupingFeature, createColumnHelper, createExpandedRowModel, createGroupedRowModel, createSortedRowModel, rowAggregationFeature, rowExpandingFeature, rowSortingFeature, sortFns, tableFeatures, useTable, } from "@tanstack/react-table";
18
19
  import { ChevronRight, Plus } from "lucide-react";
@@ -70,7 +71,9 @@ export function aggregateText(column, value) {
70
71
  const format = aggregateFormat(column);
71
72
  return format === undefined ? value : format(value);
72
73
  }
73
- function aggregateLabel(copy, column, v) {
74
+ /** A pile's or the footer's number as the table writes it: «Bs. 185.200,50», «máx 5». Exported
75
+ * for the presentations without columns, so a pile says the same thing in rows and tiles. */
76
+ export function aggregateLabel(copy, column, v) {
74
77
  const n = v.toLocaleString(copy.locale);
75
78
  /* Raw, a sum of amounts read «78.752,9»: one decimal lost and no currency, under a
76
79
  column whose every cell says «Bs. 12.300,00». */
@@ -180,9 +183,11 @@ export function aggregateOf(column, rows) {
180
183
  }
181
184
  }
182
185
  /** The piles someone else counted, as the body draws them: open ones with what is inside,
183
- * the deepest with its records and, when it holds fewer than it counts, its «show more». */
184
- function entriesOfPiles(piles, columns, keyOf, collapsed, onToggle, onMore) {
185
- return piles.flatMap((pile) => {
186
+ * the deepest with its records and, when it holds fewer than it counts, its «show more»;
187
+ * a level that holds fewer piles than it counts ends with its «more groups». */
188
+ function entriesOfPiles(piles, walk, parent = null) {
189
+ const { columns, keyOf, collapsed, onToggle, onMore, paging } = walk;
190
+ const level = piles.flatMap((pile) => {
186
191
  const key = pathKey(pile.path);
187
192
  const open = collapsed?.includes(key) !== true;
188
193
  const head = {
@@ -199,12 +204,8 @@ function entriesOfPiles(piles, columns, keyOf, collapsed, onToggle, onMore) {
199
204
  };
200
205
  if (!open)
201
206
  return [head];
202
- if (pile.piles.length > 0) {
203
- return [
204
- head,
205
- ...entriesOfPiles(pile.piles, columns, keyOf, collapsed, onToggle, onMore),
206
- ];
207
- }
207
+ if (pile.piles.length > 0)
208
+ return [head, ...entriesOfPiles(pile.piles, walk, pile)];
208
209
  const foot = pileFoot(pile, onMore !== undefined);
209
210
  return [
210
211
  head,
@@ -217,13 +218,28 @@ function entriesOfPiles(piles, columns, keyOf, collapsed, onToggle, onMore) {
217
218
  id: `\u0000more${key}`,
218
219
  depth: pile.depth,
219
220
  foot,
221
+ of: "rows",
220
222
  more: () => onMore?.(pile),
221
223
  },
222
224
  ]),
223
225
  ];
224
226
  });
227
+ const foot = pilesFoot(parent, piles, paging);
228
+ if (foot === null)
229
+ return level;
230
+ return [
231
+ ...level,
232
+ {
233
+ kind: "more",
234
+ id: `\u0000piles${parent === null ? "" : pathKey(parent.path)}`,
235
+ depth: parent === null ? 0 : parent.depth + 1,
236
+ foot,
237
+ of: "piles",
238
+ more: () => paging?.onMorePiles?.(parent),
239
+ },
240
+ ];
225
241
  }
226
- export function DataTable({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals = false, collapsed, onGroupToggle, piles, onMore, create, copyable = true, onReorder, }) {
242
+ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals = false, collapsed, onGroupToggle, piles, onMore, pilesCount, morePiles, onMorePiles, create, copyable = true, onReorder, }) {
227
243
  const copy = useUiCopy();
228
244
  const draft = create?.draft ?? null;
229
245
  const draftRow = useRef(null);
@@ -366,7 +382,18 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
366
382
  TanStack built from the page. Before, the table only knew the second — grouped on the
367
383
  server, a list said «187» in rows and «12» in the table. */
368
384
  const entries = piles !== undefined
369
- ? entriesOfPiles(piles, columns, getRowId, collapsed, onGroupToggle, onMore)
385
+ ? entriesOfPiles(piles, {
386
+ columns,
387
+ keyOf: getRowId,
388
+ collapsed,
389
+ onToggle: onGroupToggle,
390
+ onMore,
391
+ paging: {
392
+ ...(pilesCount === undefined ? {} : { pilesCount }),
393
+ ...(morePiles === undefined ? {} : { morePiles }),
394
+ ...(onMorePiles === undefined ? {} : { onMorePiles }),
395
+ },
396
+ })
370
397
  : shown.map((row) => {
371
398
  if (row.subRows.length === 0)
372
399
  return { kind: "row", id: row.id, item: row.original };
@@ -462,16 +489,21 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
462
489
  gap,
463
490
  /* The pile's row: it spans the whole width, says which value it groups by
464
491
  and how many are inside — what makes it useful without opening it. */
465
- _jsxs("tr", { ...windowed, "data-ui": "table.pile", className: "border-b border-line bg-ground", children: [_jsx("td", { colSpan: labelSpan, className: "px-3 py-1.5 whitespace-nowrap", style: indent, children: entry.toggle === undefined ? (_jsx("span", { className: "inline-flex items-center gap-1.5 text-meta font-medium text-ink", children: head })) : (_jsx("button", { type: "button", onClick: entry.toggle, "aria-expanded": entry.open, className: "inline-flex items-center gap-1.5 rounded-control text-meta font-medium text-ink transition-colors duration-(--duration-instant) hover:text-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: head })) }), columns.slice(sumsFrom).map((c, i) => {
492
+ _jsxs("tr", { ...windowed, "data-ui": "table.pile", ...(entry.toggle === undefined
493
+ ? {}
494
+ : { onClick: entry.toggle, className: "group/pile cursor-pointer" }), children: [_jsx("td", { colSpan: labelSpan, className: `px-3 py-1.5 whitespace-nowrap ${PILE_CELL}`, style: indent, children: entry.toggle === undefined ? (_jsx("span", { className: "inline-flex items-center gap-1.5 text-meta font-medium text-ink", children: head })) : (_jsx("button", { type: "button", onClick: (e) => {
495
+ e.stopPropagation();
496
+ entry.toggle?.();
497
+ }, "aria-expanded": entry.open, className: "inline-flex items-center gap-1.5 rounded-control text-meta font-medium text-ink transition-colors duration-(--duration-instant) group-hover/pile:text-primary focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: head })) }), columns.slice(sumsFrom).map((c, i) => {
466
498
  const value = entry.totals[sumsFrom + i] ?? null;
467
- return (_jsx("td", { className: `px-3 py-1.5 text-meta font-semibold tabular-nums whitespace-nowrap text-ink ${c.numeric === true ? "text-right" : ""}`, children: value === null ? null : aggregateLabel(copy, c, value) }, c.id));
468
- }), firstSum < 0 || rowActions === undefined ? null : _jsx("td", {})] }, entry.id),
499
+ return (_jsx("td", { className: `px-3 py-1.5 text-meta font-semibold tabular-nums whitespace-nowrap text-ink ${PILE_CELL} ${c.numeric === true ? "text-right" : ""}`, children: value === null ? null : aggregateLabel(copy, c, value) }, c.id));
500
+ }), firstSum < 0 || rowActions === undefined ? null : (_jsx("td", { className: PILE_CELL }))] }, entry.id),
469
501
  ];
470
502
  }
471
503
  if (entry.kind === "more") {
472
504
  return [
473
505
  gap,
474
- _jsx("tr", { ...windowed, className: "border-b border-line", children: _jsx("td", { colSpan: width, className: "px-3 py-1", style: indent, children: _jsx(PileFootLine, { foot: entry.foot, onMore: entry.more }) }) }, entry.id),
506
+ _jsx("tr", { ...windowed, children: _jsx("td", { colSpan: width, className: "border-b border-line px-3 py-1", style: indent, children: _jsx(PileFootLine, { foot: entry.foot, onMore: entry.more, of: entry.of }) }) }, entry.id),
475
507
  ];
476
508
  }
477
509
  const original = entry.item;
@@ -482,7 +514,10 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
482
514
  const t = c.tone?.(original);
483
515
  const n = c.note?.(original);
484
516
  const edit = c.edit?.when?.(original) === false ? undefined : c.edit;
485
- return (_jsx(Td, { numeric: c.numeric, mono: c.mono === true, ...(t === undefined ? {} : { tone: t }), ...(n === undefined ? {} : { title: n }), children: edit !== undefined ? (_jsx(CellEditor, { label: fillCopy(copy.inlineEdit.editCell, { column: c.header }), numeric: c.numeric === true, editor: (done) => edit.render(original, done), children: drawCell(copy, c, original) })) : copyable && c.copy !== false ? (_jsx(CellCopy, { header: c.header, numeric: c.numeric === true, ...(c.copy === undefined ? {} : { value: c.copy(original) }), children: drawCell(copy, c, original) })) : (drawCell(copy, c, original)) }, c.id));
517
+ const asTag = c.look === "tag" && t !== undefined;
518
+ const drawn = drawCell(copy, c, original);
519
+ const content = asTag ? _jsx(Tag, { tone: t, children: drawn }) : drawn;
520
+ return (_jsx(Td, { numeric: c.numeric, mono: c.mono === true, ...(t === undefined || asTag ? {} : { tone: t }), ...(n === undefined ? {} : { title: n }), children: edit !== undefined ? (_jsx(CellEditor, { label: fillCopy(copy.inlineEdit.editCell, { column: c.header }), numeric: c.numeric === true, editor: (done) => edit.render(original, done), children: content })) : copyable && c.copy !== false ? (_jsx(CellCopy, { header: c.header, numeric: c.numeric === true, ...(c.copy === undefined ? {} : { value: c.copy(original) }), children: content })) : (content) }, c.id));
486
521
  }), rowActions === undefined ? null : (_jsx(RowActions, { actions: rowActions(original) }))] }, id),
487
522
  ];
488
523
  }), view.tail(width), create === undefined || draft === null ? null : (_jsxs(EditRow, { as: "tr", rowId: "\\u0000draft", rowRef: (node) => {
@@ -501,13 +536,18 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
501
536
  }, children: [reorder.on ? _jsx("td", { className: DRAFT_CELL }) : null, selecting ? _jsx("td", { className: DRAFT_CELL }) : null, columns.map((c) => (_jsx("td", { ...(c.input === undefined ? {} : { "data-edit": "" }), className: `${DRAFT_CELL} ${c.numeric === true ? "text-right tabular-nums" : ""}`, children: c.input?.(draft, (next) => {
502
537
  touched.current = true;
503
538
  create.onChange(next);
504
- }) ?? null }, c.id))), rowActions === undefined ? null : _jsx("td", { className: DRAFT_CELL })] }))] }), footer === null ? null : (_jsx("tfoot", { className: "sticky bottom-0 z-10 bg-ground", children: _jsxs("tr", { className: "border-t border-line-strong", "aria-rowindex": view.on ? 2 + entries.length + (draft === null ? 0 : 1) : undefined, children: [reorder.on ? _jsx("td", {}) : null, selecting ? _jsx("td", {}) : null, columns.map((c, i) => {
539
+ }) ?? null }, c.id))), rowActions === undefined ? null : _jsx("td", { className: DRAFT_CELL })] }))] }), footer === null ? null : (_jsx("tfoot", { className: "sticky bottom-0 z-10 bg-ground", children: _jsxs("tr", { "aria-rowindex": view.on ? 2 + entries.length + (draft === null ? 0 : 1) : undefined, children: [reorder.on ? _jsx("td", { className: FOOT_CELL }) : null, selecting ? _jsx("td", { className: FOOT_CELL }) : null, columns.map((c, i) => {
505
540
  const value = footer[i] ?? null;
506
- return (_jsx("td", { className: `px-3 py-1.5 text-meta font-semibold text-ink ${c.numeric === true ? "text-right tabular-nums" : ""}`, children: i === 0 && value === null ? (_jsxs("span", { className: "text-muted", children: [data.length.toLocaleString(copy.locale), " ", data.length === 1 ? copy.table.row : copy.table.rows] })) : value === null ? null : (aggregateLabel(copy, c, value)) }, c.id));
507
- }), rowActions === undefined ? null : _jsx("td", {})] }) }))] }));
541
+ return (_jsx("td", { className: `px-3 py-1.5 text-meta font-semibold text-ink ${FOOT_CELL} ${c.numeric === true ? "text-right tabular-nums" : ""}`, children: i === 0 && value === null ? (_jsxs("span", { className: "text-muted", children: [data.length.toLocaleString(copy.locale), " ", data.length === 1 ? copy.table.row : copy.table.rows] })) : value === null ? null : (aggregateLabel(copy, c, value)) }, c.id));
542
+ }), rowActions === undefined ? null : _jsx("td", { className: FOOT_CELL })] }) }))] }));
508
543
  if (create === undefined)
509
544
  return _jsx(FieldBoundary, { children: grid });
510
545
  return (_jsx(FieldBoundary, { children: _jsxs("div", { className: "flex min-w-0 flex-col", children: [grid, writing ? null : (_jsx("div", { className: "px-1 py-0.5", children: _jsxs("button", { ref: addButton, type: "button", onClick: start, className: "flex w-full items-center gap-1.5 rounded-control px-3 py-1 text-left text-meta text-primary transition-colors duration-(--duration-instant) hover:bg-primary/5 focus-visible:outline-2 focus-visible:-outline-offset-1 focus-visible:outline-primary", children: [_jsx(Plus, { className: "size-(--size-icon-sm)", strokeWidth: 2.5, "aria-hidden": true }), create.label ?? copy.table.add] }) }))] }) }));
511
546
  }
512
547
  /* A cell of the row being written: the table's cell, washed like an edited row. */
513
- const DRAFT_CELL = "border-b border-line bg-primary/5 px-3 py-1 align-middle text-meta text-ink first:rounded-l-control last:rounded-r-control";
548
+ const DRAFT_CELL = "border-b border-line bg-primary/5 px-3 py-1 align-middle text-meta text-ink";
549
+ /* The rows that are not records draw their hairline and their band on the CELLS. The table is
550
+ `border-separate` (a sticky header needs it), and in that model the browser ignores a
551
+ border set on a `<tr>`: the piles' bands had no line under them and the footer none over it. */
552
+ const PILE_CELL = "border-b border-line bg-ground group-hover/pile:bg-ink/5";
553
+ const FOOT_CELL = "border-t border-line-strong";
@@ -687,7 +687,7 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
687
687
  /* The errors of the cells that are not a control right now: under the card. A control
688
688
  carries its own, under it. */
689
689
  const loose = columns.filter((c) => !controls.includes(c) && (states.get(c.id)?.error ?? null) !== null);
690
- return (_jsxs(EditRow, { as: "li", ...rowWiring(id, row), className: `group/row flex min-w-0 flex-col gap-1 rounded-control border-b border-line ${pad} ${isEditing ? "bg-primary/5" : "hover:bg-ink/4"} ${operable ? RING : ""} ${operable && !isEditing
690
+ return (_jsxs(EditRow, { as: "li", ...rowWiring(id, row), className: `group/row flex min-w-0 flex-col gap-1 border-b border-line ${pad} ${isEditing ? "bg-primary/5" : "hover:bg-ink/4"} ${operable ? RING : ""} ${operable && !isEditing
691
691
  ? opens
692
692
  ? "cursor-pointer"
693
693
  : locked(row)
@@ -711,7 +711,7 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
711
711
  const band = bandOf(row);
712
712
  const isEditing = editing === id;
713
713
  const lines = underSection?.get(id) ?? null;
714
- return (_jsxs(EditRow, { as: "li", ...rowWiring(id, row), className: `flex min-w-0 flex-col gap-1.5 rounded-control border-b border-line ${pad} ${isEditing ? "bg-primary/5" : band === "section" ? "bg-ground" : ""} ${operable ? RING : ""}`, children: [_jsxs("div", { className: "flex min-w-0 items-baseline gap-3 text-meta", children: [_jsx("span", { className: `min-w-0 flex-1 ${band === "section" ? "font-semibold text-ink" : "text-muted italic"}`, children: bands?.render(row) }), lines === null
714
+ return (_jsxs(EditRow, { as: "li", ...rowWiring(id, row), className: `flex min-w-0 flex-col gap-1.5 border-b border-line ${pad} ${isEditing ? "bg-primary/5" : band === "section" ? "bg-ground" : ""} ${operable ? RING : ""}`, children: [_jsxs("div", { className: "flex min-w-0 items-baseline gap-3 text-meta", children: [_jsx("span", { className: `min-w-0 flex-1 ${band === "section" ? "font-semibold text-ink" : "text-muted italic"}`, children: bands?.render(row) }), lines === null
715
715
  ? null
716
716
  : amounts.map((c) => (_jsx("span", { className: "shrink-0 font-semibold text-ink tabular-nums", children: bands?.total?.(c, lines) ?? null }, c.id))), isEditing && onRemove !== undefined ? (_jsx(IconButton, { icon: Trash2, label: copy.editable.remove, size: "sm", tone: "danger", onClick: () => onRemove(id) })) : null] }), isEditing && editable && bands?.edit !== undefined ? (_jsx("div", { "data-edit": "", children: bands.edit(row, setter(id)) })) : null] }, id));
717
717
  };
@@ -742,7 +742,7 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
742
742
  return (
743
743
  /* A collection is many controls, each named by its column: no enclosing `Field`
744
744
  reaches inside (see `FieldBoundary`). */
745
- _jsx(FieldBoundary, { children: _jsxs("div", { ref: frame, className: "min-w-0", children: [_jsx("div", { ref: box.ref, tabIndex: box.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${box.className}`, style: box.style, children: stacked ? (list) : (_jsxs("table", { "data-ui": "table", className: "w-full border-separate border-spacing-0 px-1 text-left", ...(view.on
745
+ _jsx(FieldBoundary, { children: _jsxs("div", { ref: frame, className: "min-w-0", children: [_jsx("div", { ref: box.ref, tabIndex: box.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${box.className}`, style: box.style, children: stacked ? (list) : (_jsxs("table", { "data-ui": "table", className: "w-full border-separate border-spacing-0 text-left", ...(view.on
746
746
  ? { "aria-rowcount": 1 + drawn.length + (totals === undefined ? 0 : 1) }
747
747
  : {}), children: [_jsx("thead", { className: "sticky z-10 bg-ui-table-head", style: stickyTop, "data-ui": "table.head", children: _jsxs("tr", { ...(view.on ? { "aria-rowindex": 1 } : {}), children: [reorderable ? _jsx("td", { className: "w-0 border-b border-line-strong" }) : null, columns.map((c, ci) => c.header === "" ? (_jsx("td", { className: "w-0 border-b border-line-strong" }, c.id)) : (_jsx("th", { scope: "col", style: c.width === undefined ? undefined : { width: c.width },
748
748
  /* A column of figures takes its figures' width (`w-0` in an auto
@@ -793,7 +793,7 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
793
793
  : band === "section"
794
794
  ? "bg-ground group-hover/row:bg-ink/6"
795
795
  : "group-hover/row:bg-ink/4";
796
- const bandMark = `border-b border-line first:rounded-l-control last:rounded-r-control ${bandWash}`;
796
+ const bandMark = `border-b border-line ${bandWash}`;
797
797
  const control = isEditing && editable && bands?.edit !== undefined;
798
798
  return [
799
799
  gap,
@@ -804,10 +804,9 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
804
804
  : ""}`, children: figures[span + i] ?? null }, c.id))), onRemove === undefined ? null : (_jsx("td", { className: `w-0 py-1 pr-2 pl-1 align-middle ${bandMark}`, children: _jsx("span", { className: "flex opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 group-focus-visible/row:opacity-100 focus-within:opacity-100", onClick: (e) => e.stopPropagation(), children: _jsx(IconButton, { icon: Trash2, label: copy.editable.remove, size: "sm", tone: "danger", ...(editable && stop !== id ? { tabIndex: -1 } : {}), onClick: () => onRemove(id) }) }) }))] }, id),
805
805
  ];
806
806
  }
807
- /* The wash lives on the cells. A background on the row paints
808
- edge to edge, and `border-collapse` would ignore a radius. */
807
+ /* The wash lives on the cells, like `Td`'s: the table is `border-separate`. */
809
808
  const wash = isEditing ? "bg-primary/5" : "group-hover/row:bg-ink/4";
810
- const mark = `border-b border-line first:rounded-l-control last:rounded-r-control ${wash}`;
809
+ const mark = `border-b border-line ${wash}`;
811
810
  const set = setter(id);
812
811
  return [
813
812
  gap,
@@ -1,14 +1,16 @@
1
1
  import type { PileFoot } from "../../foundations/grouping.js";
2
2
  /**
3
3
  * The foot of a short pile, as words: «Show 50 more of 49,950», or «Showing 500 of 49,950»
4
- * when there is no next page.
4
+ * when there is no next page — and of a short LEVEL of piles: «Show 50 more groups of 760».
5
5
  *
6
6
  * Context: the table's row and the list's line both draw it, each in its own frame (a `td`
7
7
  * with a `colSpan`, an indented line), so this is only what goes inside. The end is quiet
8
8
  * text and not a disabled button: there is nothing to press, and a control that does
9
9
  * nothing is the bug this replaced.
10
10
  */
11
- export declare function PileFootLine({ foot, onMore }: {
11
+ export declare function PileFootLine({ foot, onMore, of, }: {
12
12
  foot: PileFoot;
13
13
  onMore: () => void;
14
+ /** What the foot pages: a pile's rows (`pileFoot`) or a level's piles (`pilesFoot`). */
15
+ of?: "rows" | "piles";
14
16
  }): import("react").JSX.Element;
@@ -3,20 +3,31 @@ import { jsx as _jsx } from "react/jsx-runtime";
3
3
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
4
4
  /**
5
5
  * The foot of a short pile, as words: «Show 50 more of 49,950», or «Showing 500 of 49,950»
6
- * when there is no next page.
6
+ * when there is no next page — and of a short LEVEL of piles: «Show 50 more groups of 760».
7
7
  *
8
8
  * Context: the table's row and the list's line both draw it, each in its own frame (a `td`
9
9
  * with a `colSpan`, an indented line), so this is only what goes inside. The end is quiet
10
10
  * text and not a disabled button: there is nothing to press, and a control that does
11
11
  * nothing is the bug this replaced.
12
12
  */
13
- export function PileFootLine({ foot, onMore }) {
13
+ export function PileFootLine({ foot, onMore, of = "rows", }) {
14
14
  const copy = useUiCopy();
15
15
  const n = (value) => value.toLocaleString(copy.locale);
16
+ const words = of === "piles"
17
+ ? {
18
+ more: copy.table.pilesMore,
19
+ moreOf: copy.table.pilesMoreOf,
20
+ shown: copy.table.pilesShown,
21
+ }
22
+ : {
23
+ more: copy.table.pileMore,
24
+ moreOf: copy.table.pileMoreOf,
25
+ shown: copy.table.pileShown,
26
+ };
16
27
  if (foot.kind === "end") {
17
- return (_jsx("span", { className: "text-meta text-muted", children: fillCopy(copy.table.pileShown, { shown: n(foot.shown), count: n(foot.count) }) }));
28
+ return (_jsx("span", { className: "text-meta text-muted", children: fillCopy(words.shown, { shown: n(foot.shown), count: n(foot.count) }) }));
18
29
  }
19
30
  return (_jsx("button", { type: "button", onClick: onMore, className: "rounded-control text-meta text-primary transition-colors duration-(--duration-instant) hover:underline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: foot.next === undefined
20
- ? fillCopy(copy.table.pileMore, { count: n(foot.left) })
21
- : fillCopy(copy.table.pileMoreOf, { count: n(foot.next), left: n(foot.left) }) }));
31
+ ? fillCopy(words.more, { count: n(foot.left) })
32
+ : fillCopy(words.moreOf, { count: n(foot.next), left: n(foot.left) }) }));
22
33
  }
@@ -63,7 +63,7 @@ function ReportLine({ row, columns, open, onToggle, compact, }) {
63
63
  /* `sticky left-0` so that the account name does not go away when you
64
64
  scroll twelve comparison columns to the right. An amount without its
65
65
  line is a loose number. */
66
- className: `sticky left-0 z-10 text-left font-normal ${skin.cell} ${compact ? "py-1 pr-4 pl-2" : "py-1.5 pr-6 pl-3"}`, style: { paddingLeft: `${(compact ? 0.5 : 0.75) + level * INDENT}rem` }, children: [clickable ? (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 rounded-l-control group-hover/row:bg-primary/5" })) : null, _jsxs("span", { className: `relative flex min-w-0 items-center gap-1.5 text-meta ${skin.text}`, children: [collapsible ? (_jsx("button", { type: "button", onClick: (e) => {
66
+ className: `sticky left-0 z-10 text-left font-normal ${skin.cell} ${compact ? "py-1 pr-4 pl-2" : "py-1.5 pr-6 pl-3"}`, style: { paddingLeft: `${(compact ? 0.5 : 0.75) + level * INDENT}rem` }, children: [clickable ? (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 group-hover/row:bg-primary/5" })) : null, _jsxs("span", { className: `relative flex min-w-0 items-center gap-1.5 text-meta ${skin.text}`, children: [collapsible ? (_jsx("button", { type: "button", onClick: (e) => {
67
67
  e.stopPropagation();
68
68
  onToggle(row.id);
69
69
  }, "aria-expanded": isOpen, "aria-label": fillCopy(isOpen ? copy.report.close : copy.report.open, {
@@ -72,7 +72,7 @@ function ReportLine({ row, columns, open, onToggle, compact, }) {
72
72
  /* The slot for the chevron is reserved anyway: without it, a leaf
73
73
  account and a collapsible one would start on different
74
74
  verticals and the hierarchy would stop reading. */
75
- _jsx("span", { className: "-ml-1 size-4 shrink-0", "aria-hidden": true })), _jsx("span", { className: "truncate", children: row.label })] })] }), columns.map((c, i) => (_jsxs("td", { className: `text-right text-meta whitespace-nowrap ${clickable ? "relative" : ""} ${skin.cell} ${compact ? "px-2 py-1" : "px-3 py-1.5"}`, children: [clickable ? (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 group-hover/row:bg-primary/5" })) : null, kind === "section" ? null : (_jsx("span", { className: "relative", children: _jsx(Amount, { value: row.values[i] ?? null, ...(c.format === undefined ? {} : { format: c.format }) }) }))] }, c.id))), _jsxs("td", { className: `w-0 ${clickable ? "relative" : ""} ${skin.cell} ${compact ? "pr-2" : "pr-3"}`, children: [clickable ? (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 rounded-r-control group-hover/row:bg-primary/5" })) : null, row.note === undefined ? null : (_jsx("span", { title: row.note, className: "relative inline-flex text-muted transition-colors duration-(--duration-instant) hover:text-ink", children: _jsx(Info, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-label": row.note }) }))] })] }), !collapsible || !isOpen
75
+ _jsx("span", { className: "-ml-1 size-4 shrink-0", "aria-hidden": true })), _jsx("span", { className: "truncate", children: row.label })] })] }), columns.map((c, i) => (_jsxs("td", { className: `text-right text-meta whitespace-nowrap ${clickable ? "relative" : ""} ${skin.cell} ${compact ? "px-2 py-1" : "px-3 py-1.5"}`, children: [clickable ? (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 group-hover/row:bg-primary/5" })) : null, kind === "section" ? null : (_jsx("span", { className: "relative", children: _jsx(Amount, { value: row.values[i] ?? null, ...(c.format === undefined ? {} : { format: c.format }) }) }))] }, c.id))), _jsxs("td", { className: `w-0 ${clickable ? "relative" : ""} ${skin.cell} ${compact ? "pr-2" : "pr-3"}`, children: [clickable ? (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-0 group-hover/row:bg-primary/5" })) : null, row.note === undefined ? null : (_jsx("span", { title: row.note, className: "relative inline-flex text-muted transition-colors duration-(--duration-instant) hover:text-ink", children: _jsx(Info, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-label": row.note }) }))] })] }), !collapsible || !isOpen
76
76
  ? null
77
77
  : row.children?.map((child) => (_jsx(ReportLine, { row: child, columns: columns, open: open, onToggle: onToggle, compact: compact }, child.id)))] }));
78
78
  }
@@ -44,7 +44,7 @@ inline = 2, }) {
44
44
  return (
45
45
  /* The row's hairline runs under its actions too: without it the separators stopped one
46
46
  column short and the actions read as outside the table. */
47
- _jsx("td", { className: `w-0 border-b border-line py-1 pr-2 pl-1 align-middle whitespace-nowrap last:rounded-r-control ${wash}`, children: _jsxs("div", { onClick: (e) => e.stopPropagation(), className: "flex items-center justify-end gap-0.5 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 touch:opacity-100", children: [ways.length === 0 ? null : (_jsx("span", { "data-ui": "row.ways", "data-look": pill ? "pill" : "plain", className: `flex items-center gap-0.5 ${pill ? "rounded-pill border border-primary/20 bg-primary/8 p-0.5" : ""}`, children: ways.map((way) => (_jsx(WayButton, { way: way, pill: pill }, way.id))) })), inlineActions.map((a) => (_jsx(IconButton, { icon: a.icon, label: a.label, size: "sm", ...(a.tone === undefined ? {} : { tone: a.tone }), ...(a.disabled === undefined ? {} : { disabled: a.disabled }), onClick: a.onSelect }, a.id))), overflow.length === 0 ? null : (_jsx(Menu, { label: copy.selection.more, icon: MoreHorizontal, iconOnly: true, chevron: false, align: "end", groups: [
47
+ _jsx("td", { className: `w-0 border-b border-line py-1 pr-2 pl-1 align-middle whitespace-nowrap ${wash}`, children: _jsxs("div", { onClick: (e) => e.stopPropagation(), className: "flex items-center justify-end gap-0.5 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 touch:opacity-100", children: [ways.length === 0 ? null : (_jsx("span", { "data-ui": "row.ways", "data-look": pill ? "pill" : "plain", className: `flex items-center gap-0.5 ${pill ? "rounded-pill border border-primary/20 bg-primary/8 p-0.5" : ""}`, children: ways.map((way) => (_jsx(WayButton, { way: way, pill: pill }, way.id))) })), inlineActions.map((a) => (_jsx(IconButton, { icon: a.icon, label: a.label, size: "sm", ...(a.tone === undefined ? {} : { tone: a.tone }), ...(a.disabled === undefined ? {} : { disabled: a.disabled }), onClick: a.onSelect }, a.id))), overflow.length === 0 ? null : (_jsx(Menu, { label: copy.selection.more, icon: MoreHorizontal, iconOnly: true, chevron: false, align: "end", groups: [
48
48
  {
49
49
  options: overflow.map((a) => ({
50
50
  id: a.id,
@@ -1,3 +1,4 @@
1
+ import type { PileFoot } from "../../foundations/grouping.js";
1
2
  import type { Tone } from "../../foundations/types.js";
2
3
  import { type ReactNode } from "react";
3
4
  export interface SheetColumn {
@@ -12,7 +13,22 @@ export interface SheetColumn {
12
13
  * its bands: `2` lines «6.057,10» up over «8.370,57». Absent, up to two, as each value has. */
13
14
  decimals?: number;
14
15
  width?: number;
16
+ /**
17
+ * How a toned cell carries its tone. `fill` (the default) paints the cell — an imputed or
18
+ * out-of-range value, which is what raw data is looked at for. `tag` writes the value as
19
+ * the table's `Tag`: a column that holds a STATE («Observado», «Habilitado») reads in the
20
+ * sheet as it reads in the table, and not as a stain behind a word.
21
+ */
22
+ look?: "fill" | "tag";
15
23
  }
24
+ /** A row of the sheet that is the «show more» of the pile above it, or of a level of piles.
25
+ * Like a band, it is one more row of another kind: the sheet stays virtualized. */
26
+ export type SheetFoot = {
27
+ foot: PileFoot;
28
+ of: "rows" | "piles";
29
+ depth: number;
30
+ onMore: () => void;
31
+ };
16
32
  export declare function SheetTable({ columns, rows,
17
33
  /** The value of a cell, by index. It is a function and not a prebuilt matrix
18
34
  * so that the consumer can read from wherever they want without copying a
@@ -23,7 +39,7 @@ value,
23
39
  * nothing. */
24
40
  tone,
25
41
  /** What the cell says on hover: «imputado por la mediana». */
26
- note, height, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRow, }: {
42
+ note, height, rowLabel, band, onBandToggle, foot, caption, onCommit, editable, onAddRow, }: {
27
43
  columns: readonly SheetColumn[];
28
44
  rows: number;
29
45
  value: (row: number, column: SheetColumn, columnIndex: number) => string | number | null;
@@ -62,6 +78,8 @@ note, height, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRo
62
78
  total?: (column: SheetColumn, columnIndex: number) => string | number | null;
63
79
  } | undefined;
64
80
  onBandToggle?: (row: number) => void;
81
+ /** This row is the foot of a pile or of a level: «Ver 50 más», «Ver 50 grupos más». */
82
+ foot?: (row: number) => SheetFoot | undefined;
65
83
  caption?: ReactNode;
66
84
  /** Present = the spreadsheet is editable. It receives the raw text just as it
67
85
  * was typed; converting it to the column's type belongs to the domain, not
@@ -2,6 +2,8 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
4
4
  import { stickyTop, useScrollBox } from "../../foundations/sticky.js";
5
+ import { PileFootLine } from "./PileFootLine.js";
6
+ import { Tag } from "../tag/Tag.js";
5
7
  import { Cell } from "../value/Value.js";
6
8
  import { useVirtualizer } from "@tanstack/react-virtual";
7
9
  import { ChevronRight, Plus } from "lucide-react";
@@ -26,7 +28,7 @@ value,
26
28
  * nothing. */
27
29
  tone,
28
30
  /** What the cell says on hover: «imputado por la mediana». */
29
- note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, onAddRow, }) {
31
+ note, height = 420, rowLabel, band, onBandToggle, foot, caption, onCommit, editable, onAddRow, }) {
30
32
  const copy = useUiCopy();
31
33
  const labelOf = rowLabel ?? ((i) => (i + 1).toLocaleString(copy.locale));
32
34
  /* `"auto"` is for a set that already came CUT —a page of eighty— and
@@ -103,6 +105,10 @@ note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, o
103
105
  each cell is how you end up with spreadsheets whose arrows sometimes move
104
106
  and sometimes scroll. */
105
107
  function onKey(e) {
108
+ /* A key on a button inside the grid — a band's toggle, a «Ver más» — is that button's:
109
+ Enter, Space and Tab belong to it, not to the active cell. */
110
+ if (e.target instanceof HTMLButtonElement)
111
+ return;
106
112
  if (active === null)
107
113
  return;
108
114
  const { r, c } = active;
@@ -171,6 +177,14 @@ note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, o
171
177
  return (_jsxs("div", { className: "flex min-w-0 flex-col", children: [caption === undefined ? null : (_jsx("div", { className: "px-3 pb-2 text-meta text-muted", children: caption })), _jsx("div", { ref: caja.ref, style: caja.style, onKeyDown: isEditable ? onKey : undefined, tabIndex: isEditable ? 0 : caja.tabIndex, className: `relative min-w-0 rounded-box border border-line bg-surface outline-none focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, role: "grid", "aria-rowcount": rows, "aria-colcount": columns.length + 1, children: _jsxs("div", { style: {
172
178
  minWidth: `${ROW_LABEL_WIDTH + columns.reduce((a, c) => a + (c.width ?? WIDTH), 0)}px`,
173
179
  }, children: [_jsxs("div", { className: "sticky z-20 flex border-b border-line-strong bg-ground", style: stickyTop, role: "row", children: [_jsx("div", { className: "sticky left-0 z-30 shrink-0 border-r border-line bg-ground", style: { width: ROW_LABEL_WIDTH } }), columns.map((c) => (_jsxs("div", { role: "columnheader", style: { width: c.width ?? WIDTH }, className: `flex shrink-0 flex-col justify-center gap-0.5 border-r border-line px-2.5 py-1.5 ${c.numeric === true ? "items-end" : "items-start"}`, children: [_jsx("span", { className: "max-w-full truncate text-meta font-medium text-ink", title: c.header, children: c.header }), c.type === undefined ? null : (_jsx("span", { className: "max-w-full truncate font-mono text-micro text-muted", children: c.type }))] }, c.id))), _jsx("div", { className: "flex-1" })] }), _jsx("div", { style: { height: v.getTotalSize(), position: "relative" }, children: items.map((item) => {
180
+ const below = foot?.(item.index);
181
+ if (below !== undefined) {
182
+ /* Sticks to the left like the band's label: with forty columns the button
183
+ must not scroll away with the grid it pages. */
184
+ return (_jsx("div", { role: "row", "aria-rowindex": item.index + 1, className: "absolute top-0 left-0 flex w-full border-b border-line bg-surface", style: { height: item.size, transform: `translateY(${item.start}px)` }, children: _jsx("div", { role: "gridcell", "aria-colspan": columns.length + 1, className: "sticky left-0 flex items-center px-2.5", style: {
185
+ paddingLeft: `calc(${ROW_LABEL_WIDTH}px + var(--spacing-indent) * ${below.depth} + 0.625rem)`,
186
+ }, children: _jsx(PileFootLine, { foot: below.foot, onMore: below.onMore, of: below.of }) }) }, item.key));
187
+ }
174
188
  const montón = band?.(item.index);
175
189
  if (montón !== undefined) {
176
190
  /* The band sticks to the LEFT like the row number:
@@ -206,7 +220,7 @@ note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, o
206
220
  const n = note?.(item.index, c, ci);
207
221
  const isActive = active !== null && active.r === item.index && active.c === ci;
208
222
  const isEditingHere = isActive && editing;
209
- return (_jsx("div", { role: "gridcell", title: n, "aria-selected": isActive, onClick: isEditable ? () => goTo(item.index, ci) : undefined, onDoubleClick: isEditable ? () => openCell(item.index, ci) : undefined, style: { width: c.width ?? WIDTH }, className: `relative flex shrink-0 items-center overflow-hidden border-r border-line px-2.5 text-meta tabular-nums whitespace-nowrap text-ink ${c.numeric === true ? "justify-end" : "justify-start"} ${t === undefined ? "" : TONE[t]} ${
223
+ return (_jsx("div", { role: "gridcell", title: n, "aria-selected": isActive, onClick: isEditable ? () => goTo(item.index, ci) : undefined, onDoubleClick: isEditable ? () => openCell(item.index, ci) : undefined, style: { width: c.width ?? WIDTH }, className: `relative flex shrink-0 items-center overflow-hidden border-r border-line px-2.5 text-meta tabular-nums whitespace-nowrap text-ink ${c.numeric === true ? "justify-end" : "justify-start"} ${t === undefined || c.look === "tag" ? "" : TONE[t]} ${
210
224
  /* The outline of the active cell goes on the inside
211
225
  (`inset-ring`) and not on the outside: a 2 px border
212
226
  would push the content and the whole row would dance
@@ -217,6 +231,12 @@ note, height = 420, rowLabel, band, onBandToggle, caption, onCommit, editable, o
217
231
  ? "cursor-cell"
218
232
  : ""}`, children: isEditingHere ? (_jsx("input", { autoFocus: true, value: draft, onChange: (ev) => setDraft(ev.target.value), onBlur: () => commit(0, 0), className: `absolute inset-0 w-full bg-surface px-2.5 text-meta tabular-nums text-ink outline-none ${c.numeric === true ? "text-right" : "text-left"}` })) : ((() => {
219
233
  const v = value(item.index, c, ci);
234
+ if (c.look === "tag" &&
235
+ t !== undefined &&
236
+ v !== null &&
237
+ v !== "") {
238
+ return (_jsx(Tag, { tone: t, ...(typeof v === "string" ? { title: v } : {}), children: _jsx("span", { className: "max-w-full truncate", children: String(v) }) }));
239
+ }
220
240
  /* Cut by the column's WIDTH, with «…» and the whole text a hover
221
241
  away: «TRASPASO CTA PROPIA BN» fit the character limit and not
222
242
  the column, and was clipped mid-letter. */