@sincpro/web-ui 2.18.0 → 2.18.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.
- package/README.md +1 -1
- package/dist/components/calendar/RecordCalendar.js +1 -1
- package/dist/components/listing/Pagination.js +28 -3
- package/dist/components/listing/Row.js +2 -2
- package/dist/components/listing/modelCells.js +1 -1
- package/dist/primitives/table/DataTable.d.ts +4 -0
- package/dist/primitives/table/DataTable.js +21 -9
- package/dist/primitives/table/EditableTable.js +6 -7
- package/dist/primitives/table/ReportTable.js +2 -2
- package/dist/primitives/table/RowActions.js +1 -1
- package/dist/primitives/table/Table.js +9 -6
- package/dist/primitives/tag/Tags.js +1 -1
- package/dist/primitives/value/Avatar.d.ts +3 -2
- package/dist/primitives/value/Avatar.js +15 -9
- package/dist/primitives/value/Person.js +9 -3
- package/dist/primitives/value/Value.js +4 -1
- package/dist/views/list/ListView.js +4 -2
- package/dist/views/list/derive.d.ts +10 -0
- package/dist/views/list/derive.js +18 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -359,7 +359,7 @@ The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`
|
|
|
359
359
|
`kiosk.content`, `kiosk.reach`, `board.tile`,
|
|
360
360
|
`board.stat`, `board.stat.value`, `activity.changes`, `file-list`, `file-list.file`, `file-value`, `metric`, `metric.detail`, `tag`, `tags.item`, `search`, `search.field`, `search.chip`, `search.facet-mark`,
|
|
361
361
|
`search.panel`, `search.suggestions`, `search.suggestion`, `search.record`, `search.recent`,
|
|
362
|
-
`search.advanced`, `search.keys`, `search.completion`, `search.undo`, `search.slash`, `search-entry`, `search-entry.keys`, `table`, `table.pile`, `yes-no`,
|
|
362
|
+
`search.advanced`, `search.keys`, `search.completion`, `search.undo`, `search.slash`, `search-entry`, `search-entry.keys`, `table`, `table.pile`, `list.pile`, `yes-no`,
|
|
363
363
|
`table.head`, `table.grip`, `row.ways`, `topbar`, `topbar.brand`, `topbar.menus`, `topbar.actions`, `topbar.user`,
|
|
364
364
|
`frame`, `frame.banner`, `frame.bar`, `frame.sidebar`, `frame.main`, `banner`, `banner.action`,
|
|
365
365
|
`inbox`, `inbox.item` (with `data-unread`), `kbd`, `plans`, `plan` (with `data-highlight`, `data-current`), `plan.highlight`, `plan.price`,
|
|
@@ -66,7 +66,7 @@ export function RecordCalendar({ items, keyOf, titleOf, startOf, endOf, allDayOf
|
|
|
66
66
|
return renderEvent(item, info.timeText);
|
|
67
67
|
const person = avatarOf?.(item);
|
|
68
68
|
const meta = metaOf?.(item);
|
|
69
|
-
return (_jsxs("span", { className: "flex min-w-0 items-start gap-1.5 px-0.5 py-px", children: [person === undefined ? null : (_jsx(Avatar, { name: person.name, size: "
|
|
69
|
+
return (_jsxs("span", { className: "flex min-w-0 items-start gap-1.5 px-0.5 py-px", children: [person === undefined ? null : (_jsx(Avatar, { name: person.name, size: "xs", ...(person.src === undefined ? {} : { src: person.src }) })), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsxs("span", { className: "min-w-0 truncate", children: [info.timeText === "" ? null : (_jsxs("b", { className: "font-semibold tabular-nums", children: [info.timeText, " "] })), titleOf(item)] }), meta === undefined ? null : (_jsx("span", { className: "min-w-0 truncate opacity-80", children: meta }))] })] }));
|
|
70
70
|
};
|
|
71
71
|
const moved = (info) => {
|
|
72
72
|
const item = byId.get(info.event.id);
|
|
@@ -6,7 +6,7 @@ import { byDensity, useDensity } from "../../foundations/density.js";
|
|
|
6
6
|
import { bySurface, useSurface } from "../../foundations/surface.js";
|
|
7
7
|
import { useViewStyle } from "../../foundations/viewStyle.js";
|
|
8
8
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
9
|
-
import { useId, useState } from "react";
|
|
9
|
+
import { useEffect, useId, useRef, useState } from "react";
|
|
10
10
|
/* ---------------------------------------------------------------- *
|
|
11
11
|
* THE FOOTER AND ITS PAGINATION
|
|
12
12
|
* ---------------------------------------------------------------- */
|
|
@@ -40,6 +40,15 @@ export function Pagination({ from, to, total, pageSize, pageSizes = PAGE_SIZES,
|
|
|
40
40
|
const [editing, setEditing] = useState(false);
|
|
41
41
|
const [draft, setDraft] = useState("");
|
|
42
42
|
const listId = useId();
|
|
43
|
+
const range = useRef(null);
|
|
44
|
+
/* Back to the range once the size is set or dropped: the field goes away under the focus,
|
|
45
|
+
and a focus left on the page's body sends the next Tab to its first control. */
|
|
46
|
+
const wasEditing = useRef(false);
|
|
47
|
+
useEffect(() => {
|
|
48
|
+
if (wasEditing.current && !editing)
|
|
49
|
+
range.current?.focus();
|
|
50
|
+
wasEditing.current = editing;
|
|
51
|
+
}, [editing]);
|
|
43
52
|
/* The modern style's position is the record's pager's: one translucent primary pill, so a
|
|
44
53
|
list and a record say «where I am in the set» the same way. */
|
|
45
54
|
const style = useViewStyle();
|
|
@@ -58,6 +67,9 @@ export function Pagination({ from, to, total, pageSize, pageSizes = PAGE_SIZES,
|
|
|
58
67
|
? [...pageSizes, pageSize]
|
|
59
68
|
: pageSizes;
|
|
60
69
|
function commitSize(raw) {
|
|
70
|
+
/* Enter commits and the field leaves; its blur on the way out must not commit twice. */
|
|
71
|
+
if (!editing)
|
|
72
|
+
return;
|
|
61
73
|
const next = Number(raw);
|
|
62
74
|
if (!Number.isFinite(next) || next < 1) {
|
|
63
75
|
setEditing(false);
|
|
@@ -75,8 +87,21 @@ export function Pagination({ from, to, total, pageSize, pageSizes = PAGE_SIZES,
|
|
|
75
87
|
}
|
|
76
88
|
if (e.key === "Escape")
|
|
77
89
|
setEditing(false);
|
|
78
|
-
}, "aria-label": copy.pager.size,
|
|
90
|
+
}, "aria-label": copy.pager.size,
|
|
91
|
+
/* Inside the pill it is a pill: a square box there broke the one shape the
|
|
92
|
+
position has. */
|
|
93
|
+
className: `h-(--size-control-sm) w-24 border px-1.5 tabular-nums focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${pill
|
|
94
|
+
? "rounded-pill px-2.5 text-meta font-semibold"
|
|
95
|
+
: "rounded-control text-micro"} ${bySurface(activeSurface, pill
|
|
96
|
+
? "border-primary/30 bg-surface text-primary"
|
|
97
|
+
: "border-line-strong bg-surface text-ink", "border-chrome-ink/45 bg-chrome-ink/8 text-chrome-ink")}` }), _jsx("datalist", { id: listId, children: sizes.map((n) => (_jsx("option", { value: n }, n))) })] })) : (_jsxs("span", { className: `tabular-nums whitespace-nowrap ${pill ? "text-meta font-semibold" : "text-micro"} ${faint}`, children: [canEdit ? (_jsxs("button", { ref: range, type: "button", onClick: () => {
|
|
79
98
|
setDraft(String(pageSize));
|
|
80
99
|
setEditing(true);
|
|
81
|
-
}, title: fillCopy(copy.pager.sizeHint, { size: pageSize ?? 0 }),
|
|
100
|
+
}, title: fillCopy(copy.pager.sizeHint, { size: pageSize ?? 0 }),
|
|
101
|
+
/* Plain, the range says it is touchable with a dotted underline. In the pill an
|
|
102
|
+
underline read as a typo under a label: there it lights up like the arrows
|
|
103
|
+
beside it, which are the pill's other buttons. */
|
|
104
|
+
className: `transition-colors duration-(--duration-instant) ${strong} ${pill
|
|
105
|
+
? `-mx-1.5 -my-1 rounded-pill px-1.5 py-1 ${bySurface(activeSurface, "hover:bg-primary/15", "hover:bg-chrome-link/20")}`
|
|
106
|
+
: `rounded-control underline decoration-dotted underline-offset-4 ${bySurface(activeSurface, "decoration-line-strong hover:decoration-primary", "decoration-chrome-ink/40 hover:decoration-chrome-link")}`} focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`, children: [from.toLocaleString(copy.locale), "\u2013", to.toLocaleString(copy.locale)] })) : (_jsxs("span", { className: strong, children: [from.toLocaleString(copy.locale), "\u2013", to.toLocaleString(copy.locale)] })), _jsx("span", { className: "mx-1", children: "/" }), total.toLocaleString(copy.locale)] })), _jsxs("span", { className: "flex items-center", children: [_jsx("button", { type: "button", onClick: onPrev, disabled: from <= 1, "aria-label": copy.pager.prev, title: copy.pager.prev, className: arrow, children: _jsx(ChevronLeft, { className: "size-(--size-icon-md)", strokeWidth: 2 }) }), _jsx("button", { type: "button", onClick: onNext, disabled: to >= total, "aria-label": copy.pager.next, title: copy.pager.next, className: arrow, children: _jsx(ChevronRight, { className: "size-(--size-icon-md)", strokeWidth: 2 }) })] })] }));
|
|
82
107
|
}
|
|
@@ -132,7 +132,7 @@ export function RowHeader({ name, meta, tags, withSelection = false, withIcon =
|
|
|
132
132
|
export function GroupHeader({ field, label, count, detail, depth = 0, open = true, onToggle, }) {
|
|
133
133
|
const d = useDensity();
|
|
134
134
|
const copy = useUiCopy();
|
|
135
|
-
const content = (_jsxs(_Fragment, { children: [onToggle === undefined ? null : (_jsx(ChevronRight, { className: `size-(--size-icon-sm) shrink-0 text-muted transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true })), field === undefined ? null : (_jsx("span", { className: "shrink-0 text-micro text-muted", children: field })), _jsx("span", { className: "truncate text-
|
|
135
|
+
const content = (_jsxs(_Fragment, { children: [onToggle === undefined ? null : (_jsx(ChevronRight, { className: `size-(--size-icon-sm) shrink-0 text-muted transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true })), field === undefined ? null : (_jsx("span", { className: "shrink-0 text-micro text-muted", children: field })), _jsx("span", { className: "truncate text-meta font-medium text-ink", children: label }), count === undefined ? null : (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro tabular-nums text-muted", children: count.toLocaleString(copy.locale) })), detail === undefined ? null : (_jsx("span", { className: "shrink-0 text-micro tabular-nums text-muted", children: detail }))] }));
|
|
136
136
|
/* The indentation goes in the left padding and not in a margin: the
|
|
137
137
|
header has a background and a bottom border, and a margin would cut them before the
|
|
138
138
|
list's edge — the band would stop reading as a stripe. The hover
|
|
@@ -140,7 +140,7 @@ export function GroupHeader({ field, label, count, detail, depth = 0, open = tru
|
|
|
140
140
|
const box = `flex min-w-0 items-center gap-2 border-b border-line bg-ground ${byDensity(d, "px-3 py-1.5", "px-2.5 py-1")}`;
|
|
141
141
|
const indent = depth === 0 ? undefined : { paddingLeft: `calc(var(--spacing-indent) * ${depth})` };
|
|
142
142
|
const mark = (_jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-x-1 inset-y-0.5 rounded-control group-hover/head:bg-ink/4" }));
|
|
143
|
-
return onToggle === undefined ? (_jsx("div", { className: box, style: indent, children: content })) : (_jsxs("button", { type: "button", onClick: onToggle, "aria-expanded": open, style: indent, className: `group/head relative ${box} w-full text-left focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary`, children: [mark, content] }));
|
|
143
|
+
return onToggle === undefined ? (_jsx("div", { "data-ui": "list.pile", className: box, style: indent, children: content })) : (_jsxs("button", { type: "button", "data-ui": "list.pile", onClick: onToggle, "aria-expanded": open, style: indent, className: `group/head relative ${box} w-full text-left focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary`, children: [mark, content] }));
|
|
144
144
|
}
|
|
145
145
|
/** Under a short pile: «Ver 50 más de 49.950», or «Se muestran 500 de 49.950» when there is
|
|
146
146
|
* no next page. Indented like the pile's rows. */
|
|
@@ -36,7 +36,7 @@ export function ModelCell({ kind, value, }) {
|
|
|
36
36
|
case "duration":
|
|
37
37
|
return typeof value === "number" ? (
|
|
38
38
|
/* Right aligned like `Numeric`: a column of hours lines up by the colon. */
|
|
39
|
-
_jsx("span", { className: "block text-right
|
|
39
|
+
_jsx("span", { className: "block text-right tabular-nums whitespace-nowrap text-ink", children: formatDuration(value) })) : (_jsx(Plain, { text: text }));
|
|
40
40
|
case "boolean":
|
|
41
41
|
return typeof value === "boolean" ? _jsx(YesNo, { value: value }) : _jsx(Plain, { text: text });
|
|
42
42
|
case "date":
|
|
@@ -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;
|
|
@@ -70,7 +70,9 @@ export function aggregateText(column, value) {
|
|
|
70
70
|
const format = aggregateFormat(column);
|
|
71
71
|
return format === undefined ? value : format(value);
|
|
72
72
|
}
|
|
73
|
-
|
|
73
|
+
/** A pile's or the footer's number as the table writes it: «Bs. 185.200,50», «máx 5». Exported
|
|
74
|
+
* for the presentations without columns, so a pile says the same thing in rows and tiles. */
|
|
75
|
+
export function aggregateLabel(copy, column, v) {
|
|
74
76
|
const n = v.toLocaleString(copy.locale);
|
|
75
77
|
/* Raw, a sum of amounts read «78.752,9»: one decimal lost and no currency, under a
|
|
76
78
|
column whose every cell says «Bs. 12.300,00». */
|
|
@@ -462,16 +464,21 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
462
464
|
gap,
|
|
463
465
|
/* The pile's row: it spans the whole width, says which value it groups by
|
|
464
466
|
and how many are inside — what makes it useful without opening it. */
|
|
465
|
-
_jsxs("tr", { ...windowed, "data-ui": "table.pile",
|
|
467
|
+
_jsxs("tr", { ...windowed, "data-ui": "table.pile", ...(entry.toggle === undefined
|
|
468
|
+
? {}
|
|
469
|
+
: { 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) => {
|
|
470
|
+
e.stopPropagation();
|
|
471
|
+
entry.toggle?.();
|
|
472
|
+
}, "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
473
|
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),
|
|
474
|
+
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));
|
|
475
|
+
}), firstSum < 0 || rowActions === undefined ? null : (_jsx("td", { className: PILE_CELL }))] }, entry.id),
|
|
469
476
|
];
|
|
470
477
|
}
|
|
471
478
|
if (entry.kind === "more") {
|
|
472
479
|
return [
|
|
473
480
|
gap,
|
|
474
|
-
_jsx("tr", { ...windowed,
|
|
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),
|
|
475
482
|
];
|
|
476
483
|
}
|
|
477
484
|
const original = entry.item;
|
|
@@ -501,13 +508,18 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
501
508
|
}, 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
509
|
touched.current = true;
|
|
503
510
|
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", {
|
|
511
|
+
}) ?? 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
512
|
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", {})] }) }))] }));
|
|
513
|
+
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));
|
|
514
|
+
}), rowActions === undefined ? null : _jsx("td", { className: FOOT_CELL })] }) }))] }));
|
|
508
515
|
if (create === undefined)
|
|
509
516
|
return _jsx(FieldBoundary, { children: grid });
|
|
510
517
|
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
518
|
}
|
|
512
519
|
/* 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
|
|
520
|
+
const DRAFT_CELL = "border-b border-line bg-primary/5 px-3 py-1 align-middle text-meta text-ink";
|
|
521
|
+
/* The rows that are not records draw their hairline and their band on the CELLS. The table is
|
|
522
|
+
`border-separate` (a sticky header needs it), and in that model the browser ignores a
|
|
523
|
+
border set on a `<tr>`: the piles' bands had no line under them and the footer none over it. */
|
|
524
|
+
const PILE_CELL = "border-b border-line bg-ground group-hover/pile:bg-ink/5";
|
|
525
|
+
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
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
|
|
809
|
+
const mark = `border-b border-line ${wash}`;
|
|
811
810
|
const set = setter(id);
|
|
812
811
|
return [
|
|
813
812
|
gap,
|
|
@@ -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
|
|
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
|
|
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
|
|
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,
|
|
@@ -52,7 +52,7 @@ height, rowCount, }) {
|
|
|
52
52
|
`useScrollBox`: the whole dilemma lives there, and so does its explanation. The
|
|
53
53
|
three tables of the system solved it with three copies of the same
|
|
54
54
|
measurement. */
|
|
55
|
-
_jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsx("table", { "data-ui": "table", "aria-rowcount": rowCount, className: "w-full border-separate border-spacing-0
|
|
55
|
+
_jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsx("table", { "data-ui": "table", "aria-rowcount": rowCount, className: "w-full border-separate border-spacing-0 text-left", children: children }) }));
|
|
56
56
|
}
|
|
57
57
|
/** The text of a column header, shared by every table of the family. Ink and semibold, not
|
|
58
58
|
* muted: in grey at the cells' weight the names of the columns read as one more row. */
|
|
@@ -97,13 +97,16 @@ export function Th({ children, sortKey, sort, onSort, numeric = false, align, wi
|
|
|
97
97
|
direction: dir === "asc" ? copy.sorting.asc : copy.sorting.desc,
|
|
98
98
|
}) })) : null] })) }));
|
|
99
99
|
}
|
|
100
|
-
/** The wash of a row lives on the cells, not on the `<tr
|
|
101
|
-
*
|
|
102
|
-
*
|
|
100
|
+
/** The wash of a row lives on the cells, not on the `<tr>`: the table is `border-separate`.
|
|
101
|
+
* Edge to edge, like the head and the hairlines — the table had a 4 px side padding to keep a
|
|
102
|
+
* rounded wash off the card, and with square stripes it only cut every line short of it. */
|
|
103
103
|
const RowMark = createContext({
|
|
104
104
|
selected: false,
|
|
105
105
|
interactive: false,
|
|
106
106
|
});
|
|
107
|
+
/* Square, edge to edge: a table row is a stripe. Its cells used to round their outer corners
|
|
108
|
+
so the wash read as a pill, and the hairline under a rounded corner follows the curve — every
|
|
109
|
+
separator of every table hooked up at both ends, read-only rows included. */
|
|
107
110
|
const ROW_WASH = "group-hover/row:bg-ink/4";
|
|
108
111
|
const ROW_ON = "bg-primary/8";
|
|
109
112
|
/* The hover wash only where a click does something: on a read-only row it promised a click
|
|
@@ -132,7 +135,7 @@ export function Tr({ children, onClick, selected = false, windowed, rowId, line,
|
|
|
132
135
|
*/
|
|
133
136
|
export function TrDetail({ children, detail, open, onToggle, columns, label, selected = false, }) {
|
|
134
137
|
const id = useId();
|
|
135
|
-
return (_jsx(RowMark.Provider, { value: { selected, interactive: true }, children: _jsxs(_Fragment, { children: [_jsxs("tr", { onClick: onToggle, className: "group/row cursor-pointer", children: [_jsx("td", { className: `border-b border-line py-1.5 pr-0 pl-2.5 align-middle
|
|
138
|
+
return (_jsx(RowMark.Provider, { value: { selected, interactive: true }, children: _jsxs(_Fragment, { children: [_jsxs("tr", { onClick: onToggle, className: "group/row cursor-pointer", children: [_jsx("td", { className: `border-b border-line py-1.5 pr-0 pl-2.5 align-middle ${rowWash({ selected, interactive: true })}`, children: _jsx("button", { type: "button", onClick: (e) => {
|
|
136
139
|
e.stopPropagation();
|
|
137
140
|
onToggle();
|
|
138
141
|
}, "aria-expanded": open, "aria-controls": id, "aria-label": label, className: "hit-target inline-flex size-5 items-center justify-center rounded-pill text-muted transition-colors duration-(--duration-instant) hover:bg-ink/6 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary", children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2 }) }) }), children] }), _jsx("tr", { id: id, hidden: !open, children: _jsx("td", { colSpan: columns + 1, className: "border-b border-line bg-ground px-3 py-3", children: detail }) })] }) }));
|
|
@@ -158,7 +161,7 @@ mono = false,
|
|
|
158
161
|
* gets lost. */
|
|
159
162
|
tone, title, fit = false, }) {
|
|
160
163
|
const mark = useContext(RowMark);
|
|
161
|
-
return (_jsx("td", { title: title, className: `border-b border-line py-1.5 text-meta text-ink
|
|
164
|
+
return (_jsx("td", { title: title, className: `border-b border-line py-1.5 text-meta text-ink ${fit ? "w-0 pr-0 pl-1 align-middle" : "px-3"} ${(align ?? (numeric ? "right" : "left")) === "right" ? "text-right" : "text-left"} ${mono ? "font-mono tabular-nums" : numeric ? "tabular-nums whitespace-nowrap" : ""} ${tone === undefined ? rowWash(mark) : CELL_TONE[tone]} ${mark.line ?? ""}`, children: children }));
|
|
162
165
|
}
|
|
163
166
|
/** The selection checkbox, with its third state.
|
|
164
167
|
*
|
|
@@ -136,7 +136,7 @@ function shell({ item, surface, stack, size, removable, pressable, }) {
|
|
|
136
136
|
}
|
|
137
137
|
function Inside({ item }) {
|
|
138
138
|
const Icon = item.icon;
|
|
139
|
-
return (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-3 shrink-0 opacity-70", strokeWidth: 2, "aria-hidden": true })), item.avatar === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "-my-0.5 -ml-1.5 flex shrink-0", children: _jsx(Avatar, { name: item.label, size: "
|
|
139
|
+
return (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-3 shrink-0 opacity-70", strokeWidth: 2, "aria-hidden": true })), item.avatar === undefined ? null : (_jsx("span", { "aria-hidden": true, className: "-my-0.5 -ml-1.5 flex shrink-0", children: _jsx(Avatar, { name: item.label, size: "xs", ...(typeof item.avatar === "string" ? { src: item.avatar } : {}) }) })), _jsx("span", { className: "min-w-0 truncate", children: item.label }), item.note === undefined ? null : (
|
|
140
140
|
/* Secondary by its separator and weight, not by fading: at 60 % the note fell
|
|
141
141
|
under 4.5:1 on a tinted chip. */
|
|
142
142
|
_jsxs("span", { className: "shrink-0 font-normal", children: ["\u00B7 ", item.note] })), item.count === undefined ? null : (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export declare const SIZE: {
|
|
2
|
-
readonly
|
|
3
|
-
readonly
|
|
2
|
+
readonly xs: "size-5 text-micro";
|
|
3
|
+
readonly sm: "size-6 text-micro";
|
|
4
|
+
readonly md: "size-7 text-micro";
|
|
4
5
|
readonly lg: "size-8 text-meta";
|
|
5
6
|
readonly xl: "size-12 text-body";
|
|
6
7
|
};
|
|
@@ -57,21 +57,27 @@ function toneOf(name, surface = "canvas") {
|
|
|
57
57
|
}
|
|
58
58
|
/* The text doesn't go below `micro`: two initials at 10 px can't be read, and an
|
|
59
59
|
unreadable initial is a colored circle — which is exactly what we don't want.
|
|
60
|
-
What changes between sizes is the circle
|
|
60
|
+
What changes between sizes is the circle — and it leaves the initials room: two 12 px
|
|
61
|
+
letters filled a 20 px disc edge to edge («NF» in a table cell read as a stamp, not a face),
|
|
62
|
+
so the small one is 24 and the default 28. `xs` keeps the 20 px disc for where height is
|
|
63
|
+
fixed by something else — inside a tag, on a calendar event. */
|
|
61
64
|
export const SIZE = {
|
|
62
|
-
|
|
63
|
-
|
|
65
|
+
xs: "size-5 text-micro",
|
|
66
|
+
sm: "size-6 text-micro",
|
|
67
|
+
md: "size-7 text-micro",
|
|
64
68
|
lg: "size-8 text-meta",
|
|
65
69
|
/* The head of a contact card: the face is what the card is about. */
|
|
66
70
|
xl: "size-12 text-body",
|
|
67
71
|
};
|
|
68
|
-
/* Two initials, so the overlap stays short of the second letter
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
/* Two initials, so the overlap stays short of the second letter: it covers only the room
|
|
73
|
+
between the disc's edge and its letters (two 12 px initials are ~16 px wide), never a stroke.
|
|
74
|
+
Deeper, «AG JM CR» read «AC JN CR». The ring is 1px: a 2px ring of the surface color reads
|
|
75
|
+
as a gap between people, which is the thing a stack is not. */
|
|
71
76
|
export const OVERLAP = {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
77
|
+
xs: "-ml-0.5",
|
|
78
|
+
sm: "-ml-1",
|
|
79
|
+
md: "-ml-1.5",
|
|
80
|
+
lg: "-ml-2",
|
|
75
81
|
xl: "-ml-3.5",
|
|
76
82
|
};
|
|
77
83
|
export function Avatar({ name, size = "md",
|
|
@@ -17,8 +17,11 @@ function ChipButton({ expanded, haspopup, children, ref, ...native }) {
|
|
|
17
17
|
return (_jsx("button", { ...native, ref: ref, type: "button", ...(haspopup === undefined ? {} : { "aria-haspopup": haspopup }), ...(expanded === undefined ? {} : { "aria-expanded": expanded }),
|
|
18
18
|
/* The hover tint is a pseudo-element that spills past the box, not padding: padding
|
|
19
19
|
moved the chip off the column of values, and negative margins to undo it made the
|
|
20
|
-
chip wider than the room its parent measured — and it truncated itself.
|
|
21
|
-
|
|
20
|
+
chip wider than the room its parent measured — and it truncated itself.
|
|
21
|
+
It is a CAPSULE around the face: the same 2 px all around the disc, so its left end
|
|
22
|
+
is concentric with it. A rounded rectangle there let the disc's curve poke out of
|
|
23
|
+
the tint's corners. */
|
|
24
|
+
className: "relative isolate inline-flex max-w-full min-w-0 cursor-pointer items-center gap-2 rounded-pill text-left outline-primary outline-offset-2 before:absolute before:-inset-y-0.5 before:-right-2 before:-left-0.5 before:-z-10 before:rounded-pill before:transition-colors before:duration-(--duration-instant) hover:before:bg-ink/6 focus-visible:outline-2 aria-expanded:before:bg-ink/6 forced-colors:outline-[Highlight]", children: children }));
|
|
22
25
|
}
|
|
23
26
|
/**
|
|
24
27
|
* The person with their name next to them. For a cell, a list row, a field in read mode or
|
|
@@ -65,5 +68,8 @@ export function UserStack({ names, max = 4, size = "md", }) {
|
|
|
65
68
|
}
|
|
66
69
|
const visible = names.length <= max ? names : names.slice(0, max - 1);
|
|
67
70
|
const rest = names.length - visible.length;
|
|
68
|
-
return (_jsxs("span", { className: "inline-flex items-center", title: names.join(", "), children: [visible.map((n, i) => (_jsx("span", { className: i === 0 ? "" : OVERLAP[size], children: _jsx("span", { className: "block rounded-pill ring-1 ring-surface", children: _jsx(Avatar, { name: n, size: size }) }) }, n))), rest <= 0 ? null : (
|
|
71
|
+
return (_jsxs("span", { className: "inline-flex items-center", title: names.join(", "), children: [visible.map((n, i) => (_jsx("span", { className: i === 0 ? "" : OVERLAP[size], children: _jsx("span", { className: "block rounded-pill ring-1 ring-surface", children: _jsx(Avatar, { name: n, size: size }) }) }, n))), rest <= 0 ? null : (
|
|
72
|
+
/* Opaque, like every disc of the stack: a translucent «+3» let the face under it
|
|
73
|
+
show through and its «+» read as a smudge. */
|
|
74
|
+
_jsxs("span", { className: `${OVERLAP[size]} relative inline-flex items-center justify-center overflow-hidden rounded-pill bg-surface font-medium tabular-nums text-muted ring-1 ring-surface ${SIZE[size]}`, children: [_jsx("span", { "aria-hidden": true, className: "absolute inset-0 bg-ink/10" }), _jsxs("span", { className: "relative", children: ["+", rest] })] }))] }));
|
|
69
75
|
}
|
|
@@ -47,7 +47,10 @@ export function Numeric({ value, unit, format = "integer", align = "right", roun
|
|
|
47
47
|
const options = typeof format === "object" ? format : PRESET[format];
|
|
48
48
|
const text = formatWith(shown, signed ? { ...options, signDisplay: "exceptZero" } : options, locale);
|
|
49
49
|
const negative = signed && shown < 0;
|
|
50
|
-
return (
|
|
50
|
+
return (
|
|
51
|
+
/* No size of its own: it takes its container's, like a date or a yes/no beside it. At
|
|
52
|
+
`text-body` a quantity in a 13 px row stood a size above its row and off its baseline. */
|
|
53
|
+
_jsxs("span", { className: `${align === "left" ? "inline-block text-left" : "block text-right"} tabular-nums whitespace-nowrap ${negative ? "text-danger" : "text-ink"}`, children: [_jsx("span", { className: "tabular-nums", children: text }), unit === undefined ? null : _jsx("span", { className: "ml-1 text-muted", children: unit })] }));
|
|
51
54
|
}
|
|
52
55
|
/**
|
|
53
56
|
* The content of a data cell, with what the system decides and the view does not.
|
|
@@ -27,7 +27,7 @@ import { ReportTable } from "../../primitives/table/ReportTable.js";
|
|
|
27
27
|
import { Metric, Metrics } from "../../primitives/value/Metric.js";
|
|
28
28
|
import { ProgressBar } from "../../primitives/value/ProgressBar.js";
|
|
29
29
|
import { groupedColumnIds, WIDE_PRESENTS } from "./columns.js";
|
|
30
|
-
import { groupLevelsOf, reportColumnsOf, reportRowsOf, sheetFromColumns, sheetRowsOf, } from "./derive.js";
|
|
30
|
+
import { groupLevelsOf, pileSummaryOf, reportColumnsOf, reportRowsOf, sheetFromColumns, sheetRowsOf, } from "./derive.js";
|
|
31
31
|
import { SheetPresentation, TablePresentation, } from "./presentations.js";
|
|
32
32
|
import { useNarrowList } from "./useNarrowList.js";
|
|
33
33
|
import { useReachBottom } from "./useReachBottom.js";
|
|
@@ -361,11 +361,13 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
361
361
|
/** The buckets, with their rows inside. It calls itself because the tree
|
|
362
362
|
* has N levels: a bucket draws its header and, inside, either the buckets
|
|
363
363
|
* below or the rows — never both. */
|
|
364
|
+
/* What the server summed and wrote, else what the columns add up to — the table's numbers. */
|
|
365
|
+
const withDetail = (detail) => (detail === undefined ? {} : { detail });
|
|
364
366
|
function renderPiles(list, nodes) {
|
|
365
367
|
return list.map((pile) => {
|
|
366
368
|
const key = pathKey(pile.path);
|
|
367
369
|
const open = isOpen(pile);
|
|
368
|
-
return (_jsxs(Fragment, { children: [_jsx(GroupHeader, { field: levelNameOf(pile.field, columns), label: pile.label, count: pile.count, ...(pile.detail
|
|
370
|
+
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
|
|
369
371
|
? {}
|
|
370
372
|
: { onToggle: () => group.onToggle?.(key) }) }), !open
|
|
371
373
|
? null
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type Pile } from "../../foundations/grouping.js";
|
|
2
|
+
import type { UiCopy } from "../../foundations/uiCopy.js";
|
|
2
3
|
import { type DataColumn } from "../../primitives/table/DataTable.js";
|
|
3
4
|
import type { ReportColumn, ReportRow } from "../../primitives/table/ReportTable.js";
|
|
4
5
|
import type { SheetColumn } from "../../primitives/table/SheetTable.js";
|
|
@@ -85,3 +86,12 @@ export declare function reportRowsOf<T extends object>(piles: readonly Pile<T>[]
|
|
|
85
86
|
* number format — a count of rows is not an amount.
|
|
86
87
|
*/
|
|
87
88
|
export declare function reportColumnsOf<T extends object>(reportColumns: readonly ReportColumn[], columns: readonly DataColumn<T>[] | undefined): readonly ReportColumn[];
|
|
89
|
+
/**
|
|
90
|
+
* What a pile adds up to, in one line — for the presentations without columns (rows, tiles,
|
|
91
|
+
* cards), where there is no column to write each total under.
|
|
92
|
+
*
|
|
93
|
+
* Context: the table's pile said «185.200,50 · máx 5» under its columns, and the same pile in
|
|
94
|
+
* rows said only «5». Switching presentation lost the answer the grouping was asked for. The
|
|
95
|
+
* numbers are the table's (`pileAggregate`, `aggregateLabel`), so the two never disagree.
|
|
96
|
+
*/
|
|
97
|
+
export declare function pileSummaryOf<T extends object>(pile: Pile<T>, columns: readonly DataColumn<T>[] | undefined, copy: UiCopy): string | undefined;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { levelKey, pathKey, pileCount, pileItems, pileLabel, } from "../../foundations/grouping.js";
|
|
2
|
-
import { aggregateFormat, aggregateOf, aggregateText, pileAggregate, } from "../../primitives/table/DataTable.js";
|
|
2
|
+
import { aggregateFormat, aggregateLabel, aggregateOf, aggregateText, pileAggregate, } from "../../primitives/table/DataTable.js";
|
|
3
3
|
import { levelNameOf } from "../../primitives/table/levels.js";
|
|
4
4
|
/**
|
|
5
5
|
* Context: what a list DERIVES from its set, as pure functions — the table's group levels,
|
|
@@ -242,3 +242,20 @@ export function reportColumnsOf(reportColumns, columns) {
|
|
|
242
242
|
: { ...column, format };
|
|
243
243
|
});
|
|
244
244
|
}
|
|
245
|
+
/**
|
|
246
|
+
* What a pile adds up to, in one line — for the presentations without columns (rows, tiles,
|
|
247
|
+
* cards), where there is no column to write each total under.
|
|
248
|
+
*
|
|
249
|
+
* Context: the table's pile said «185.200,50 · máx 5» under its columns, and the same pile in
|
|
250
|
+
* rows said only «5». Switching presentation lost the answer the grouping was asked for. The
|
|
251
|
+
* numbers are the table's (`pileAggregate`, `aggregateLabel`), so the two never disagree.
|
|
252
|
+
*/
|
|
253
|
+
export function pileSummaryOf(pile, columns, copy) {
|
|
254
|
+
if (columns === undefined)
|
|
255
|
+
return undefined;
|
|
256
|
+
const parts = columns.flatMap((column) => {
|
|
257
|
+
const value = pileAggregate(column, pile);
|
|
258
|
+
return value === null ? [] : [`${column.header} ${aggregateLabel(copy, column, value)}`];
|
|
259
|
+
});
|
|
260
|
+
return parts.length === 0 ? undefined : parts.join(" · ");
|
|
261
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "2.18.
|
|
3
|
+
"version": "2.18.1",
|
|
4
4
|
"description": "An enterprise web design system for business software — ERPs, back offices, management tools — in React and Tailwind: tokens, primitives, components and the two views every management screen is made of.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|