@sincpro/web-ui 2.18.1 → 2.19.1

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 (60) hide show
  1. package/README.md +5 -3
  2. package/dist/components/flow/SetupCard.d.ts +21 -0
  3. package/dist/components/flow/SetupCard.js +16 -0
  4. package/dist/components/flow/index.d.ts +1 -0
  5. package/dist/components/flow/index.js +3 -0
  6. package/dist/components/form/Form.js +7 -5
  7. package/dist/components/listing/Row.d.ts +5 -2
  8. package/dist/components/listing/Row.js +4 -3
  9. package/dist/components/navigation/NavigationTree.d.ts +3 -0
  10. package/dist/components/navigation/NavigationTree.js +2 -1
  11. package/dist/components/record/ActionDock.d.ts +10 -3
  12. package/dist/components/record/ActionDock.js +15 -8
  13. package/dist/components/record/DirtyActions.d.ts +15 -7
  14. package/dist/components/record/DirtyActions.js +37 -13
  15. package/dist/components/record/DockMessage.d.ts +18 -0
  16. package/dist/components/record/DockMessage.js +31 -0
  17. package/dist/components/record/dock.d.ts +25 -0
  18. package/dist/components/record/index.d.ts +2 -1
  19. package/dist/components/record/index.js +1 -0
  20. package/dist/components/shell/Page.d.ts +12 -0
  21. package/dist/components/shell/Page.js +12 -0
  22. package/dist/components/shell/Sidebar.d.ts +22 -3
  23. package/dist/components/shell/Sidebar.js +88 -10
  24. package/dist/components/shell/index.d.ts +1 -0
  25. package/dist/components/shell/index.js +2 -0
  26. package/dist/foundations/copy.es.js +5 -0
  27. package/dist/foundations/grouping.d.ts +37 -0
  28. package/dist/foundations/grouping.js +0 -0
  29. package/dist/foundations/index.d.ts +1 -1
  30. package/dist/foundations/index.js +1 -1
  31. package/dist/foundations/uiCopy.d.ts +10 -0
  32. package/dist/foundations/uiCopy.js +5 -0
  33. package/dist/primitives/button/Button.d.ts +5 -1
  34. package/dist/primitives/button/Button.js +4 -4
  35. package/dist/primitives/button/classes.d.ts +1 -8
  36. package/dist/primitives/button/classes.js +12 -2
  37. package/dist/primitives/field/RichTextEditor.js +4 -1
  38. package/dist/primitives/menu/Menu.d.ts +22 -1
  39. package/dist/primitives/menu/Menu.js +44 -18
  40. package/dist/primitives/table/DataTable.d.ts +12 -1
  41. package/dist/primitives/table/DataTable.js +42 -14
  42. package/dist/primitives/table/PileFootLine.d.ts +4 -2
  43. package/dist/primitives/table/PileFootLine.js +16 -5
  44. package/dist/primitives/table/SheetTable.d.ts +19 -1
  45. package/dist/primitives/table/SheetTable.js +22 -2
  46. package/dist/primitives/table/index.d.ts +1 -1
  47. package/dist/primitives/table/index.js +1 -1
  48. package/dist/primitives/tabs/Tabs.d.ts +21 -1
  49. package/dist/primitives/tabs/Tabs.js +26 -7
  50. package/dist/primitives/tabs/index.d.ts +1 -1
  51. package/dist/primitives/tag/Tag.d.ts +5 -0
  52. package/dist/primitives/tag/Tag.js +2 -1
  53. package/dist/primitives/value/Avatar.d.ts +4 -1
  54. package/dist/primitives/value/Avatar.js +2 -2
  55. package/dist/views/list/ListView.js +23 -5
  56. package/dist/views/list/derive.d.ts +5 -3
  57. package/dist/views/list/derive.js +30 -5
  58. package/dist/views/list/presentations.js +2 -1
  59. package/dist/views/list/types.d.ts +5 -1
  60. package/package.json +1 -1
@@ -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";
@@ -182,9 +183,11 @@ export function aggregateOf(column, rows) {
182
183
  }
183
184
  }
184
185
  /** The piles someone else counted, as the body draws them: open ones with what is inside,
185
- * the deepest with its records and, when it holds fewer than it counts, its «show more». */
186
- function entriesOfPiles(piles, columns, keyOf, collapsed, onToggle, onMore) {
187
- 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) => {
188
191
  const key = pathKey(pile.path);
189
192
  const open = collapsed?.includes(key) !== true;
190
193
  const head = {
@@ -201,12 +204,8 @@ function entriesOfPiles(piles, columns, keyOf, collapsed, onToggle, onMore) {
201
204
  };
202
205
  if (!open)
203
206
  return [head];
204
- if (pile.piles.length > 0) {
205
- return [
206
- head,
207
- ...entriesOfPiles(pile.piles, columns, keyOf, collapsed, onToggle, onMore),
208
- ];
209
- }
207
+ if (pile.piles.length > 0)
208
+ return [head, ...entriesOfPiles(pile.piles, walk, pile)];
210
209
  const foot = pileFoot(pile, onMore !== undefined);
211
210
  return [
212
211
  head,
@@ -219,13 +218,28 @@ function entriesOfPiles(piles, columns, keyOf, collapsed, onToggle, onMore) {
219
218
  id: `\u0000more${key}`,
220
219
  depth: pile.depth,
221
220
  foot,
221
+ of: "rows",
222
222
  more: () => onMore?.(pile),
223
223
  },
224
224
  ]),
225
225
  ];
226
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
+ ];
227
241
  }
228
- 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, }) {
229
243
  const copy = useUiCopy();
230
244
  const draft = create?.draft ?? null;
231
245
  const draftRow = useRef(null);
@@ -368,7 +382,18 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
368
382
  TanStack built from the page. Before, the table only knew the second — grouped on the
369
383
  server, a list said «187» in rows and «12» in the table. */
370
384
  const entries = piles !== undefined
371
- ? 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
+ })
372
397
  : shown.map((row) => {
373
398
  if (row.subRows.length === 0)
374
399
  return { kind: "row", id: row.id, item: row.original };
@@ -478,7 +503,7 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
478
503
  if (entry.kind === "more") {
479
504
  return [
480
505
  gap,
481
- _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 }) }) }, 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),
482
507
  ];
483
508
  }
484
509
  const original = entry.item;
@@ -489,7 +514,10 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
489
514
  const t = c.tone?.(original);
490
515
  const n = c.note?.(original);
491
516
  const edit = c.edit?.when?.(original) === false ? undefined : c.edit;
492
- 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));
493
521
  }), rowActions === undefined ? null : (_jsx(RowActions, { actions: rowActions(original) }))] }, id),
494
522
  ];
495
523
  }), view.tail(width), create === undefined || draft === null ? null : (_jsxs(EditRow, { as: "tr", rowId: "\\u0000draft", rowRef: (node) => {
@@ -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
  }
@@ -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. */
@@ -7,6 +7,6 @@ export { PileFootLine } from "./PileFootLine.js";
7
7
  export { PivotTable, type PivotTableProps, } from "./PivotTable.js";
8
8
  export { type ReportColumn, type ReportRow, type ReportRowKind, ReportTable, } from "./ReportTable.js";
9
9
  export { type RowAction, RowActions } from "./RowActions.js";
10
- export { type SheetColumn, SheetTable } from "./SheetTable.js";
10
+ export { type SheetColumn, type SheetFoot, SheetTable, } from "./SheetTable.js";
11
11
  export { compareBy, flipSort, moveSort, pressSort, type SortDirection, sortPosition, type SortState, } from "./sorting.js";
12
12
  export { Table, Td, Th, THead, Tr } from "./Table.js";
@@ -9,6 +9,6 @@ export { PileFootLine } from "./PileFootLine.js";
9
9
  export { PivotTable, } from "./PivotTable.js";
10
10
  export { ReportTable, } from "./ReportTable.js";
11
11
  export { RowActions } from "./RowActions.js";
12
- export { SheetTable } from "./SheetTable.js";
12
+ export { SheetTable, } from "./SheetTable.js";
13
13
  export { compareBy, flipSort, moveSort, pressSort, sortPosition, } from "./sorting.js";
14
14
  export { Table, Td, Th, THead, Tr } from "./Table.js";
@@ -75,7 +75,23 @@ export type TabItem = {
75
75
  count?: number;
76
76
  /** That something in here asks you to look. Apart from the counter: see `TabNotice`. */
77
77
  notice?: TabNotice;
78
+ /** A word about the tab itself, not about what is behind it: «Beta», «Nuevo». Quiet, after
79
+ * the label — a counter says how many, this says what kind. */
80
+ badge?: string;
81
+ /** The tabs that belong together. Where the group changes, a hairline separates them:
82
+ * «Ajustes · Verificar | Aprendizajes» — what you configure, and what you read. */
83
+ group?: string;
78
84
  };
85
+ /**
86
+ * How the strip draws the open tab.
87
+ *
88
+ * folder the open tab sticks out of the border and covers the line: what is below is
89
+ * ITS content. A record's faces, the activity's two sources.
90
+ * underline a bar under the open one, on a strip with a hairline: the SECTIONS of a page —
91
+ * settings, the sub-screens of a module — where the content below is a different
92
+ * screen, not the same paper. It takes `end`: the page's own action, on the right.
93
+ */
94
+ export type TabsLook = "folder" | "underline";
79
95
  /**
80
96
  * A notebook whose strip and page are far apart — the record's tabs ride in its header and
81
97
  * the page is drawn in its paper. It only shares an id: no box, no context of anything
@@ -100,10 +116,14 @@ export declare function TabsPanel({ id, className, children, }: {
100
116
  * The keyboard is the ARIA tabs pattern with automatic activation: one tab stop (the open
101
117
  * tab), ← / → move AND open (wrapping), Home / End go to the ends.
102
118
  */
103
- export declare function Tabs({ tabs, current, onSelect, label, }: {
119
+ export declare function Tabs({ tabs, current, onSelect, label, look, end, }: {
104
120
  tabs: readonly TabItem[];
105
121
  current: string;
106
122
  onSelect?: (id: string) => void;
107
123
  /** The strip's accessible label. Without this, «las caras del registro». */
108
124
  label?: string;
125
+ look?: TabsLook;
126
+ /** At the strip's right end, outside the tab list: the page's action («Añadir
127
+ * repositorios»). It sits on the strip's line, where the eye already is. */
128
+ end?: ReactNode;
109
129
  }): import("react").JSX.Element;
@@ -2,6 +2,7 @@
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useUiCopy } from "../../foundations/copy.js";
4
4
  import { Count } from "../tag/Count.js";
5
+ import { Tag } from "../tag/Tag.js";
5
6
  import { createContext, useContext, useId, useRef, } from "react";
6
7
  /**
7
8
  * The strip only: what each tab opens is drawn by whoever uses it (`Record`, `Activity`).
@@ -42,7 +43,7 @@ export function TabsPanel({ id, className, children, }) {
42
43
  * The keyboard is the ARIA tabs pattern with automatic activation: one tab stop (the open
43
44
  * tab), ← / → move AND open (wrapping), Home / End go to the ends.
44
45
  */
45
- export function Tabs({ tabs, current, onSelect, label, }) {
46
+ export function Tabs({ tabs, current, onSelect, label, look = "folder", end, }) {
46
47
  const copy = useUiCopy();
47
48
  const base = useContext(Scope);
48
49
  const strip = useRef(null);
@@ -69,16 +70,34 @@ export function Tabs({ tabs, current, onSelect, label, }) {
69
70
  event.preventDefault();
70
71
  go(to);
71
72
  };
72
- return (_jsx("div", { ref: strip, role: "tablist", "aria-label": label ?? copy.record.faces, onKeyDown: onKeyDown, className: "flex min-w-0 flex-wrap items-end gap-1", children: tabs.map((a) => {
73
+ const underline = look === "underline";
74
+ const list = (_jsx("div", { ref: strip, role: "tablist", "aria-label": label ?? copy.record.faces, onKeyDown: onKeyDown, "data-ui": "tabs", "data-look": look, className: underline
75
+ ? "flex min-w-0 flex-1 items-stretch gap-1 overflow-x-auto"
76
+ : "flex min-w-0 flex-wrap items-end gap-1", children: tabs.map((a, at) => {
73
77
  const Icon = a.icon;
78
+ const before = tabs[at - 1];
79
+ const parted = before !== undefined && before.group !== a.group;
74
80
  /* A zero asks for nothing, so it is not drawn. That is the difference from the
75
81
  counter, where «0» is an answer. */
76
82
  const notice = a.notice?.count === 0 ? undefined : a.notice;
77
83
  const isSelected = a.id === current;
78
- return (_jsx("button", { type: "button", role: "tab", "data-tab": a.id, "aria-selected": isSelected, tabIndex: isSelected ? 0 : -1, ...(base === null
79
- ? {}
80
- : { id: tabIdOf(base, a.id), "aria-controls": panelIdOf(base, a.id) }), onClick: () => onSelect?.(a.id), className: `inline-flex shrink-0 cursor-default items-center px-3 py-2 text-meta outline-0 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${isSelected
81
- ? "-mb-px rounded-t-control border border-b-0 border-line-strong bg-surface font-medium text-ink"
82
- : "border border-transparent text-muted hover:text-ink"}`, children: _jsxs("span", { className: "inline-flex items-center gap-1.5", ...(notice === undefined ? {} : { title: notice.label }), children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-sm) shrink-0 ${isSelected ? "text-ink" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), a.label, a.count === undefined ? null : (_jsx(Count, { value: a.count, showZero: true, current: isSelected })), notice === undefined ? null : (_jsx("span", { className: "sr-only", children: ` · ${notice.label}` })), notice === undefined ? null : (_jsx(Count, { ...(notice.count === undefined ? {} : { value: notice.count }), tone: notice.tone ?? "bad", "aria-hidden": true }))] }) }, a.id));
84
+ return [
85
+ parted ? (_jsx("span", { "aria-hidden": true, className: "mx-1.5 my-auto h-(--size-icon-md) w-px shrink-0 bg-line-strong" }, `${a.id}-sep`)) : null,
86
+ _jsx("button", { type: "button", role: "tab", "data-tab": a.id, "aria-selected": isSelected, tabIndex: isSelected ? 0 : -1, ...(base === null
87
+ ? {}
88
+ : { id: tabIdOf(base, a.id), "aria-controls": panelIdOf(base, a.id) }), onClick: () => onSelect?.(a.id), "data-ui": "tabs.tab", className: `inline-flex shrink-0 cursor-default items-center px-3 text-meta outline-0 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${underline
89
+ ? `relative py-2.5 after:absolute after:inset-x-2 after:bottom-0 after:h-0.5 after:rounded-pill after:transition-colors after:duration-(--duration-instant) ${isSelected
90
+ ? "font-medium text-ink after:bg-primary"
91
+ : "text-muted after:bg-transparent hover:text-ink hover:after:bg-line-strong"}`
92
+ : `py-2 ${isSelected
93
+ ? "-mb-px rounded-t-control border border-b-0 border-line-strong bg-surface font-medium text-ink"
94
+ : "border border-transparent text-muted hover:text-ink"}`}`, children: _jsxs("span", { className: "inline-flex items-center gap-1.5", ...(notice === undefined ? {} : { title: notice.label }), children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-sm) shrink-0 ${isSelected ? "text-ink" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), a.label, a.badge === undefined ? null : _jsx(Tag, { children: a.badge }), a.count === undefined ? null : (_jsx(Count, { value: a.count, showZero: true, current: isSelected })), notice === undefined ? null : (_jsx("span", { className: "sr-only", children: ` · ${notice.label}` })), notice === undefined ? null : (_jsx(Count, { ...(notice.count === undefined ? {} : { value: notice.count }), tone: notice.tone ?? "bad", "aria-hidden": true }))] }) }, a.id),
95
+ ];
83
96
  }) }));
97
+ if (!underline && end === undefined)
98
+ return list;
99
+ return (_jsxs("div", {
100
+ /* A page's sections open the page: the strip keeps the page's side margin, so the first
101
+ tab lines up with the content under it and the action does not touch the edge. */
102
+ className: `flex min-w-0 gap-3 ${underline ? "items-center border-b border-line px-4 pt-1.5" : "items-end"}`, children: [list, end === undefined ? null : (_jsx("div", { className: "flex shrink-0 items-center gap-2", children: end }))] }));
84
103
  }
@@ -1 +1 @@
1
- export { type TabItem, type TabNotice, Tabs, TabsPanel, TabsScope, } from "./Tabs.js";
1
+ export { type TabItem, type TabNotice, Tabs, type TabsLook, TabsPanel, TabsScope, } from "./Tabs.js";
@@ -23,6 +23,11 @@ title, }: {
23
23
  surface?: "canvas" | "chrome";
24
24
  title?: string;
25
25
  }): import("react").JSX.Element;
26
+ /** The dot in each tone — shared with the dock's sentence, so a tone has one dot. */
27
+ export declare const DOT_TONE: Record<Tone, {
28
+ canvas: string;
29
+ chrome: string;
30
+ }>;
26
31
  /** The status dot.
27
32
  *
28
33
  * **It never goes alone.** A colored dot without its word next to it forces
@@ -56,7 +56,8 @@ export function Tag({ children, tone = "neutral", surface = "canvas",
56
56
  title, }) {
57
57
  return (_jsx("span", { title: title, "data-ui": "tag", "data-tone": tone, className: `inline-flex shrink-0 items-center rounded-ui-tag px-2 py-0.5 text-micro font-medium whitespace-nowrap ${TAG_TONE[tone][surface]}`, children: children }));
58
58
  }
59
- const DOT_TONE = {
59
+ /** The dot in each tone — shared with the dock's sentence, so a tone has one dot. */
60
+ export const DOT_TONE = {
60
61
  neutral: { canvas: "bg-muted", chrome: "bg-chrome-muted" },
61
62
  info: { canvas: "bg-info", chrome: "bg-chrome-link" },
62
63
  good: { canvas: "bg-good", chrome: "bg-chrome-good" },
@@ -10,8 +10,11 @@ export type AvatarSize = keyof typeof SIZE;
10
10
  export declare function Avatar({ name, size,
11
11
  /** The photo, if there is one. Without it the initials go, which is the normal
12
12
  * case here. */
13
- src, }: {
13
+ src, decorative, }: {
14
14
  name: string;
15
+ /** The name is written beside it (a person row, an account button): the photo then says
16
+ * nothing a screen reader has not heard, and naming it twice is noise. */
17
+ decorative?: boolean;
15
18
  size?: AvatarSize;
16
19
  src?: string;
17
20
  }): import("react").JSX.Element;
@@ -83,7 +83,7 @@ export const OVERLAP = {
83
83
  export function Avatar({ name, size = "md",
84
84
  /** The photo, if there is one. Without it the initials go, which is the normal
85
85
  * case here. */
86
- src, }) {
86
+ src, decorative = false, }) {
87
87
  const surface = useSurface();
88
88
  if (src !== undefined) {
89
89
  return (
@@ -91,7 +91,7 @@ src, }) {
91
91
  a chip with a photo sat on the image's bottom edge in a row aligned by baseline (a
92
92
  `DataField`), higher than the label next to it. The hidden initials give the photo
93
93
  the same baseline the initials disc has. */
94
- _jsxs("span", { title: name, className: `relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-pill ${SIZE[size]}`, children: [_jsx("span", { "aria-hidden": true, className: "invisible", children: initials(name) }), _jsx("img", { src: src, alt: name, className: "absolute inset-0 size-full object-cover" })] }));
94
+ _jsxs("span", { title: name, className: `relative inline-flex shrink-0 items-center justify-center overflow-hidden rounded-pill ${SIZE[size]}`, children: [_jsx("span", { "aria-hidden": true, className: "invisible", children: initials(name) }), _jsx("img", { src: src, alt: decorative ? "" : name, className: "absolute inset-0 size-full object-cover" })] }));
95
95
  }
96
96
  /* Each identity is a tint and an ink: the tint goes on the disc, the ink on the letters. */
97
97
  const [tint = "", ink = ""] = toneOf(name, surface).split(" ");
@@ -15,7 +15,7 @@ import { Breadcrumb } from "../../components/record/Breadcrumb.js";
15
15
  import { RecordTimeline } from "../../components/timeline/RecordTimeline.js";
16
16
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
17
17
  import { useDensity } from "../../foundations/density.js";
18
- import { pathKey, pileFoot, pileIsOpen, pilesOf, } from "../../foundations/grouping.js";
18
+ import { pathKey, pileFoot, pileIsOpen, pilesFoot, pilesOf, } from "../../foundations/grouping.js";
19
19
  import { pivotFrom, pivotIsEmpty } from "../../foundations/pivot.js";
20
20
  import { bySurface, useSurface } from "../../foundations/surface.js";
21
21
  import { useViewStyle } from "../../foundations/viewStyle.js";
@@ -347,7 +347,7 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
347
347
  one built with the rows in hand. */
348
348
  const piles = useMemo(() => pilesOf(ordered, group), [group, ordered]);
349
349
  const isOpen = useCallback((pile) => pileIsOpen(pile, group), [group]);
350
- const sheetRows = useMemo(() => sheetRowsOf(piles, isOpen, columns), [piles, isOpen, columns]);
350
+ const sheetRows = useMemo(() => sheetRowsOf(piles, isOpen, columns, group), [piles, isOpen, columns, group]);
351
351
  /* The shape of a row of THIS list, so that the header reserves the
352
352
  same spacers. The first is looked at and not all: the icon and the actions
353
353
  are decided by the view for the whole list. */
@@ -363,8 +363,13 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
363
363
  * below or the rows — never both. */
364
364
  /* What the server summed and wrote, else what the columns add up to — the table's numbers. */
365
365
  const withDetail = (detail) => (detail === undefined ? {} : { detail });
366
- function renderPiles(list, nodes) {
367
- return list.map((pile) => {
366
+ /* After the last pile of a level that holds fewer than it counts: «Ver 50 grupos más». */
367
+ function pilesFootOf(parent, list) {
368
+ const foot = pilesFoot(parent, list, group);
369
+ return foot === null ? null : (_jsx(GroupMore, { foot: foot, of: "piles", depth: parent === null ? 0 : parent.depth + 1, onMore: () => group?.onMorePiles?.(parent) }));
370
+ }
371
+ function renderPiles(list, nodes, parent = null) {
372
+ const drawn = list.map((pile) => {
368
373
  const key = pathKey(pile.path);
369
374
  const open = isOpen(pile);
370
375
  return (_jsxs(Fragment, { children: [_jsx(GroupHeader, { field: levelNameOf(pile.field, columns), label: pile.label, count: pile.count, ...withDetail(pile.detail ?? pileSummaryOf(pile, columns, copy)), depth: pile.depth, open: open, ...(group?.onToggle === undefined
@@ -372,9 +377,10 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
372
377
  : { onToggle: () => group.onToggle?.(key) }) }), !open
373
378
  ? null
374
379
  : pile.piles.length > 0
375
- ? renderPiles(pile.piles, nodes)
380
+ ? renderPiles(pile.piles, nodes, pile)
376
381
  : nodes(pile.items), open ? footOf(pile) : null] }, key));
377
382
  });
383
+ return (_jsxs(_Fragment, { children: [drawn, pilesFootOf(parent, list)] }));
378
384
  }
379
385
  const reportRows = useMemo(() => reportRowsOf(piles, columns, row, copy.report.total), [piles, columns, row, copy.report.total]);
380
386
  function wrapGroups(nodes) {
@@ -417,6 +423,18 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
417
423
  ? {}
418
424
  : { toggle: (pile) => group.onToggle?.(pathKey(pile.path)) }),
419
425
  ...(group?.onMore === undefined ? {} : { more: group.onMore }),
426
+ ...(group === undefined ||
427
+ (group.pilesCount === undefined && group.onMorePiles === undefined)
428
+ ? {}
429
+ : {
430
+ pilesPaging: {
431
+ ...(group.pilesCount === undefined ? {} : { pilesCount: group.pilesCount }),
432
+ ...(group.morePiles === undefined ? {} : { morePiles: group.morePiles }),
433
+ ...(group.onMorePiles === undefined
434
+ ? {}
435
+ : { onMorePiles: group.onMorePiles }),
436
+ },
437
+ }),
420
438
  ...(selection === undefined
421
439
  ? {}
422
440
  : { selection: { has: selection.has, toggle: selection.toggle } }),
@@ -1,8 +1,8 @@
1
- import { type Pile } from "../../foundations/grouping.js";
1
+ import { type Grouping, type Pile } from "../../foundations/grouping.js";
2
2
  import type { UiCopy } from "../../foundations/uiCopy.js";
3
3
  import { type DataColumn } from "../../primitives/table/DataTable.js";
4
4
  import type { ReportColumn, ReportRow } from "../../primitives/table/ReportTable.js";
5
- import type { SheetColumn } from "../../primitives/table/SheetTable.js";
5
+ import type { SheetColumn, SheetFoot } from "../../primitives/table/SheetTable.js";
6
6
  import type { ListGroup, ListSheet, RowOf } from "./types.js";
7
7
  /**
8
8
  * Context: what a list DERIVES from its set, as pure functions — the table's group levels,
@@ -46,6 +46,8 @@ export type SheetEntry<T> = {
46
46
  total?: (column: SheetColumn, columnIndex: number) => string | number | null;
47
47
  };
48
48
  item?: T;
49
+ /** The «show more» of the pile above, or the «more groups» of a level — `SheetTable foot`. */
50
+ foot?: SheetFoot;
49
51
  n?: number;
50
52
  };
51
53
  /**
@@ -63,7 +65,7 @@ export type SheetEntry<T> = {
63
65
  * The rule stays in the view's hands, as it should: if it declares `group`,
64
66
  * it groups; if not, there are no buckets to draw.
65
67
  */
66
- export declare function sheetRowsOf<T extends object>(piles: readonly Pile<T>[] | null, isOpen: (pile: Pile<T>) => boolean, columns: readonly DataColumn<T>[] | undefined): SheetEntry<T>[] | null;
68
+ export declare function sheetRowsOf<T extends object>(piles: readonly Pile<T>[] | null, isOpen: (pile: Pile<T>) => boolean, columns: readonly DataColumn<T>[] | undefined, group?: Pick<Grouping<T>, "onMore" | "pilesCount" | "morePiles" | "onMorePiles">): SheetEntry<T>[] | null;
67
69
  /**
68
70
  * The report built from the buckets, when the domain did not declare
69
71
  * lines.