@sincpro/web-ui 2.19.1 → 2.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/components/listing/Row.d.ts +5 -1
- package/dist/components/listing/Row.js +3 -1
- package/dist/components/record/DockMessage.d.ts +3 -1
- package/dist/components/record/DockMessage.js +35 -2
- package/dist/foundations/grouping.d.ts +27 -0
- package/dist/foundations/grouping.js +0 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +1 -1
- package/dist/primitives/overlay/Tooltip.d.ts +8 -1
- package/dist/primitives/overlay/Tooltip.js +2 -2
- package/dist/primitives/table/DataTable.d.ts +4 -1
- package/dist/primitives/table/DataTable.js +12 -7
- package/dist/primitives/table/PilePager.d.ts +13 -0
- package/dist/primitives/table/PilePager.js +21 -0
- package/dist/views/list/ListView.js +7 -2
- package/dist/views/list/presentations.js +1 -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`, `list.pile`, `yes-no`,
|
|
362
|
+
`search.advanced`, `search.keys`, `search.completion`, `search.undo`, `search.slash`, `search-entry`, `search-entry.keys`, `table`, `table.pile`, `list.pile`, `pile.pager`, `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`,
|
|
@@ -374,7 +374,7 @@ The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`
|
|
|
374
374
|
`sidebar.user`, `sidebar.me` (the person at the foot, `account="menu"`), `sidebar.search`,
|
|
375
375
|
`sidebar.nav`, `sidebar.account`, `navigation`, `navigation.item`, `menu.header`, `tabs` (with
|
|
376
376
|
`data-look`), `tabs.tab`, `dirty.blocked`, `dirty.bar`, `field`, `field.label`, `form.section`,
|
|
377
|
-
`form.card`, `form.index`, `dock`, `dock.pill`, `dock.bare`, `dock.message` (with `data-tone`),
|
|
377
|
+
`form.card`, `form.index`, `dock`, `dock.pill`, `dock.bare`, `dock.message` (with `data-tone`), `dock.sentence` (a button with the whole of it in a tooltip, when cut), `dock.text`, `dock.detail`,
|
|
378
378
|
`setup`, `setup.step`, `setup.reason`, `setup.preview`, `page`, `pager`, `pagination`, `smart`, `guide`, `guide.veil`, `guide.spot`, `guide.card`,
|
|
379
379
|
`guide.progress`, `guide.title`, `guide.body`, `guide.actions`. A part that is one of many
|
|
380
380
|
carries `data-key` too (`navigation.item`). Put your rules in a cascade layer above web-ui's, or
|
|
@@ -113,7 +113,7 @@ export declare function RowHeader({ name, meta, tags, withSelection, withIcon, w
|
|
|
113
113
|
* ran, and two consecutive headers can read as siblings when one is inside the
|
|
114
114
|
* other. The field names the cut; the indent says how deep it is.
|
|
115
115
|
*/
|
|
116
|
-
export declare function GroupHeader({ field, label, count, detail, depth, open, onToggle, }: {
|
|
116
|
+
export declare function GroupHeader({ field, label, count, detail, depth, open, onToggle, pager, }: {
|
|
117
117
|
/** By which field this pile was cut. Without it a value is ambiguous as soon
|
|
118
118
|
* as there is more than one level. */
|
|
119
119
|
field?: string;
|
|
@@ -127,6 +127,10 @@ export declare function GroupHeader({ field, label, count, detail, depth, open,
|
|
|
127
127
|
depth?: number;
|
|
128
128
|
open?: boolean;
|
|
129
129
|
onToggle?: () => void;
|
|
130
|
+
/** At the band's end, on an open pile paged a page at a time: «51–100 / 2.328 ‹ ›»
|
|
131
|
+
* (`PilePager`). A button cannot hold buttons: with it, the band is a strip that holds
|
|
132
|
+
* the folding button and the pager side by side. */
|
|
133
|
+
pager?: ReactNode;
|
|
130
134
|
}): import("react").JSX.Element;
|
|
131
135
|
/** Under a short pile: «Ver 50 más de 49.950», or «Se muestran 500 de 49.950» when there is
|
|
132
136
|
* no next page — and after a short level of piles, «Ver 50 grupos más». Indented like the
|
|
@@ -129,7 +129,7 @@ export function RowHeader({ name, meta, tags, withSelection = false, withIcon =
|
|
|
129
129
|
* ran, and two consecutive headers can read as siblings when one is inside the
|
|
130
130
|
* other. The field names the cut; the indent says how deep it is.
|
|
131
131
|
*/
|
|
132
|
-
export function GroupHeader({ field, label, count, detail, depth = 0, open = true, onToggle, }) {
|
|
132
|
+
export function GroupHeader({ field, label, count, detail, depth = 0, open = true, onToggle, pager, }) {
|
|
133
133
|
const d = useDensity();
|
|
134
134
|
const copy = useUiCopy();
|
|
135
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 }))] }));
|
|
@@ -140,6 +140,8 @@ 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
|
+
if (pager !== undefined && pager !== null)
|
|
144
|
+
return (_jsxs("div", { "data-ui": "list.pile", className: `${box} justify-between`, style: indent, children: [onToggle === undefined ? (_jsx("span", { className: "flex min-w-0 items-center gap-2", children: content })) : (_jsxs("button", { type: "button", onClick: onToggle, "aria-expanded": open, className: "group/head relative flex min-w-0 flex-1 items-center gap-2 text-left focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary", children: [mark, content] })), pager] }));
|
|
143
145
|
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
146
|
}
|
|
145
147
|
/** Under a short pile: «Ver 50 más de 49.950», or «Se muestran 500 de 49.950» when there is
|
|
@@ -9,7 +9,9 @@ import type { DockMoment } from "./dock.js";
|
|
|
9
9
|
* The visible part is keyed by its text: a new sentence enters with a short rise, so dirty → saved → the record's state reads as one place
|
|
10
10
|
* changing, not as a pill rebuilt. The global reduced-motion rule flattens it.
|
|
11
11
|
*
|
|
12
|
-
* It gives way first: one row on a phone too, the sentence truncates and the buttons stay
|
|
12
|
+
* It gives way first: one row on a phone too, the sentence truncates and the buttons stay —
|
|
13
|
+
* and, cut, it is still read whole: its text and help in a `Tooltip`, on hover and on keyboard
|
|
14
|
+
* focus (`Entero`). Nothing cut, nothing added: no tooltip, no extra Tab stop.
|
|
13
15
|
*/
|
|
14
16
|
export declare function DockMessage({ moment, detailId, }: {
|
|
15
17
|
moment: DockMoment | undefined;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { useSurface } from "../../foundations/surface.js";
|
|
4
|
+
import { Tooltip, TooltipTrigger } from "../../primitives/overlay/Tooltip.js";
|
|
4
5
|
import { DOT_TONE } from "../../primitives/tag/Tag.js";
|
|
6
|
+
import { useLayoutEffect, useState } from "react";
|
|
5
7
|
/* The mark in each tone when it is an icon; the dot is `Tag`'s own (`DOT_TONE`). */
|
|
6
8
|
const INK = {
|
|
7
9
|
neutral: { canvas: "text-muted", chrome: "text-chrome-muted" },
|
|
@@ -21,11 +23,42 @@ const INK = {
|
|
|
21
23
|
* The visible part is keyed by its text: a new sentence enters with a short rise, so dirty → saved → the record's state reads as one place
|
|
22
24
|
* changing, not as a pill rebuilt. The global reduced-motion rule flattens it.
|
|
23
25
|
*
|
|
24
|
-
* It gives way first: one row on a phone too, the sentence truncates and the buttons stay
|
|
26
|
+
* It gives way first: one row on a phone too, the sentence truncates and the buttons stay —
|
|
27
|
+
* and, cut, it is still read whole: its text and help in a `Tooltip`, on hover and on keyboard
|
|
28
|
+
* focus (`Entero`). Nothing cut, nothing added: no tooltip, no extra Tab stop.
|
|
25
29
|
*/
|
|
26
30
|
export function DockMessage({ moment, detailId, }) {
|
|
27
31
|
const surface = useSurface() === "chrome" ? "chrome" : "canvas";
|
|
28
32
|
const tone = moment?.tone ?? "neutral";
|
|
29
33
|
const Icon = moment?.icon;
|
|
30
|
-
return (_jsx(_Fragment, { children: moment === undefined ? null : (_jsxs("span", { "data-ui": "dock.message", "data-tone": tone, className: "flex min-w-0 shrink! items-center gap-2 px-2.5 transition-[opacity,translate] duration-(--duration-quick) ease-(--ease-out) starting:translate-y-0.5 starting:opacity-0", children: [Icon === undefined ? (_jsxs("span", { "aria-hidden": true, className: "relative flex size-1.5 shrink-0", children: [moment.busy === true ? (_jsx("span", { className: `absolute inline-flex size-full animate-ping rounded-pill opacity-70 ${DOT_TONE[tone][surface]}` })) : null, _jsx("span", { className: `relative inline-flex size-1.5 rounded-pill ${DOT_TONE[tone][surface]}` })] })) : (_jsx(Icon, { "aria-hidden": true, strokeWidth: 2.25, className: `size-(--size-icon-sm) shrink-0 ${INK[tone][surface]}` })), _jsxs(
|
|
34
|
+
return (_jsx(_Fragment, { children: moment === undefined ? null : (_jsxs("span", { "data-ui": "dock.message", "data-tone": tone, className: "flex min-w-0 shrink! items-center gap-2 px-2.5 transition-[opacity,translate] duration-(--duration-quick) ease-(--ease-out) starting:translate-y-0.5 starting:opacity-0", children: [Icon === undefined ? (_jsxs("span", { "aria-hidden": true, className: "relative flex size-1.5 shrink-0", children: [moment.busy === true ? (_jsx("span", { className: `absolute inline-flex size-full animate-ping rounded-pill opacity-70 ${DOT_TONE[tone][surface]}` })) : null, _jsx("span", { className: `relative inline-flex size-1.5 rounded-pill ${DOT_TONE[tone][surface]}` })] })) : (_jsx(Icon, { "aria-hidden": true, strokeWidth: 2.25, className: `size-(--size-icon-sm) shrink-0 ${INK[tone][surface]}` })), _jsxs(Entero, { text: moment.text, detail: moment.detail, children: [_jsx("span", { "data-ui": "dock.text", className: `truncate text-meta font-medium ${surface === "chrome" ? "text-chrome-ink" : "text-ink"}`, children: moment.text }), moment.detail === undefined ? null : (_jsx("span", { ...(detailId === undefined ? {} : { id: detailId }), "data-ui": "dock.detail", className: `truncate text-micro ${surface === "chrome" ? "text-chrome-muted" : "text-muted"}`, children: moment.detail }))] })] }, moment.text)) }));
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* The sentence and its help, and — only when one of them is cut — the whole of both in a
|
|
38
|
+
* `Tooltip`. Measured after layout and again on every resize: a pill that widens shows it all
|
|
39
|
+
* and drops the tooltip; one that narrows takes it.
|
|
40
|
+
*
|
|
41
|
+
* Context: cut, the block is a button — a tooltip's trigger must take focus and have a role —
|
|
42
|
+
* that shows it on hover and on keyboard focus, and pins it on a press: the pill is cut mostly
|
|
43
|
+
* on a phone, where nothing hovers. Not cut, it is plain text: no extra Tab stop.
|
|
44
|
+
*/
|
|
45
|
+
function Entero({ text, detail, children, }) {
|
|
46
|
+
// The node by state, not by a ref object: becoming a button mounts a new one, and the
|
|
47
|
+
// measuring has to follow it.
|
|
48
|
+
const [nodo, setNodo] = useState(null);
|
|
49
|
+
const [cortado, setCortado] = useState(false);
|
|
50
|
+
const [abierto, setAbierto] = useState(false);
|
|
51
|
+
useLayoutEffect(() => {
|
|
52
|
+
if (nodo === null)
|
|
53
|
+
return;
|
|
54
|
+
const medir = () => setCortado([...nodo.children].some((linea) => linea.scrollWidth > linea.clientWidth));
|
|
55
|
+
medir();
|
|
56
|
+
const observador = new ResizeObserver(medir);
|
|
57
|
+
observador.observe(nodo);
|
|
58
|
+
return () => observador.disconnect();
|
|
59
|
+
}, [nodo, text, detail]);
|
|
60
|
+
const clase = "flex min-w-0 flex-col leading-tight";
|
|
61
|
+
if (!cortado)
|
|
62
|
+
return (_jsx("span", { ref: setNodo, "data-ui": "dock.sentence", className: clase, children: children }));
|
|
63
|
+
return (_jsxs(TooltipTrigger, { open: abierto, onOpenChange: setAbierto, closeOnPress: false, children: [_jsx("button", { ref: setNodo, type: "button", "data-ui": "dock.sentence", onClick: () => setAbierto((ahora) => !ahora), className: `${clase} cursor-default rounded-control text-left focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary`, children: children }), _jsxs(Tooltip, { children: [_jsx("span", { className: "block font-medium", children: text }), detail === undefined ? null : _jsx("span", { className: "mt-0.5 block", children: detail })] })] }));
|
|
31
64
|
}
|
|
@@ -122,6 +122,11 @@ export type Pile<T> = {
|
|
|
122
122
|
* it shows. Absent, the button counts what is left, as it did before this existed.
|
|
123
123
|
*/
|
|
124
124
|
more?: number | false;
|
|
125
|
+
/**
|
|
126
|
+
* Where `items` start among the pile's rows, when it is paged a page at a time (`onPage`):
|
|
127
|
+
* `50` = they are rows 51 onwards. Absent, `0` — the first page, and «show more» adds to it.
|
|
128
|
+
*/
|
|
129
|
+
from?: number;
|
|
125
130
|
/**
|
|
126
131
|
* How many piles the level BELOW holds — all of them, not the ones in `piles`.
|
|
127
132
|
*
|
|
@@ -230,6 +235,13 @@ export type Grouping<T> = {
|
|
|
230
235
|
* `pile.items`.
|
|
231
236
|
*/
|
|
232
237
|
onMore?: (pile: Pile<T>) => void;
|
|
238
|
+
/**
|
|
239
|
+
* Turns an open pile's page — `1` the next, `-1` the one before — in place of the rows it
|
|
240
|
+
* shows, as Odoo's pager on a group's line: «1–80 / 2.131 ‹ ›». With this, each presentation
|
|
241
|
+
* draws that pager on the header of an open pile that holds fewer rows than it counts;
|
|
242
|
+
* «Ver N más» stays under it, for whoever scrolled down and wants the next ones added.
|
|
243
|
+
*/
|
|
244
|
+
onPage?: (pile: Pile<T>, step: 1 | -1) => void;
|
|
233
245
|
/**
|
|
234
246
|
* How many piles the FIRST level holds over the whole set — a register grouped by surname
|
|
235
247
|
* has ~800, and the server brings the first page of them. Absent, `piles` is all of it.
|
|
@@ -341,6 +353,21 @@ export type PileFoot = {
|
|
|
341
353
|
count: number;
|
|
342
354
|
};
|
|
343
355
|
export declare function pileFoot<T>(pile: Pile<T>, canAsk: boolean): PileFoot | null;
|
|
356
|
+
/**
|
|
357
|
+
* The pager on an open pile's header: which of its rows are shown — «51–100 / 2.328» — and
|
|
358
|
+
* the steps to the page before and after, each only where there is one.
|
|
359
|
+
*
|
|
360
|
+
* `null` when the pile holds piles and not rows, shows nothing, holds every row it counts, or
|
|
361
|
+
* nobody turns its pages (`onPage`). The range is 1-based, as people read it.
|
|
362
|
+
*/
|
|
363
|
+
export type PilePage = {
|
|
364
|
+
from: number;
|
|
365
|
+
to: number;
|
|
366
|
+
count: number;
|
|
367
|
+
prev?: () => void;
|
|
368
|
+
next?: () => void;
|
|
369
|
+
};
|
|
370
|
+
export declare function pilePage<T>(pile: Pile<T>, onPage: ((pile: Pile<T>, step: 1 | -1) => void) | undefined): PilePage | null;
|
|
344
371
|
/** Where a level's piles say how many there are and how the next page is asked for: the
|
|
345
372
|
* first level in the grouping, the rest in the pile above them. */
|
|
346
373
|
export type PilesPaging<T> = Pick<Grouping<T>, "pilesCount" | "morePiles" | "onMorePiles">;
|
|
Binary file
|
|
@@ -20,7 +20,7 @@ export type { Density, OpenTarget, Size, Surface, Tone, } from "./types.js";
|
|
|
20
20
|
export { SPANISH_COPY } from "./copy.es.js";
|
|
21
21
|
export { flatten, loose, pick, pickAll, propsOf, slot, slotOf, type Slotted, } from "./slots.js";
|
|
22
22
|
export { dateKey, dateKeysBetween, dateKeyYear, dateLabel, dateTick, grainName, monthName, nextDateKey, } from "./calendar.js";
|
|
23
|
-
export { GRAIN_ORDER, type GroupableField, type GroupGrain, type Grouping, type GroupLevel, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, type Pile, pileCount, type PileFoot, pileFoot, pileIsOpen, pileItems, pileLabel, type PileLabelOf, type PileOf, pilesFoot, pilesFrom, pilesOf, type PilesPaging, } from "./grouping.js";
|
|
23
|
+
export { GRAIN_ORDER, type GroupableField, type GroupGrain, type Grouping, type GroupLevel, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, type Pile, pileCount, type PileFoot, pileFoot, pileIsOpen, pileItems, pileLabel, type PileLabelOf, type PileOf, type PilePage, pilePage, pilesFoot, pilesFrom, pilesOf, type PilesPaging, } from "./grouping.js";
|
|
24
24
|
export { axisLabels, axisSpans, keyStarts, type Pivot, type PivotAxis, type PivotCell, type PivotCrossing, type PivotFold, pivotFrom, pivotIsEmpty, type PivotKey, type PivotLevel, type PivotMargin, type PivotMeasure, pivotOf, type PivotSource, type PivotSpec, } from "./pivot.js";
|
|
25
25
|
export { chartCompare, type ChartData, chartFromPivot, chartFromRecord, type ChartKind, type ChartMeasure, chartMeasures, type ChartOrder, type ChartPoint, type ChartReading, COUNT_MEASURE, orderChart, SERIES_COLORS, } from "./chart.js";
|
|
26
26
|
export { downloadPivot, pivotSheet, type PivotSheetOptions, pivotXlsx, } from "./pivotSheet.js";
|
|
@@ -46,7 +46,7 @@ export { dateKey, dateKeysBetween, dateKeyYear, dateLabel, dateTick, grainName,
|
|
|
46
46
|
/* THE GROUPING — the vocabulary, which both layers speak: the list builds the
|
|
47
47
|
tree of buckets and the table draws it. It lives here and not in `contexts/list`
|
|
48
48
|
because a primitive cannot import from a context. */
|
|
49
|
-
export { GRAIN_ORDER, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, pileCount, pileFoot, pileIsOpen, pileItems, pileLabel, pilesFoot, pilesFrom, pilesOf, } from "./grouping.js";
|
|
49
|
+
export { GRAIN_ORDER, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, pileCount, pileFoot, pileIsOpen, pileItems, pileLabel, pilePage, pilesFoot, pilesFrom, pilesOf, } from "./grouping.js";
|
|
50
50
|
/* THE PIVOT — the same split: the vocabulary here, the grid in `primitives`.
|
|
51
51
|
That margins come from the base and that a hole is not a zero are rules
|
|
52
52
|
of the CONTRACT, not of the drawing, and that is why they live on this side. */
|
|
@@ -27,7 +27,7 @@ export declare function useInTooltipTrigger(): boolean;
|
|
|
27
27
|
* with the system's own buttons — they forward `ref` and spread native props — or with a
|
|
28
28
|
* plain `<button>`, and never has to know the adapter exists.
|
|
29
29
|
*/
|
|
30
|
-
export declare function TooltipTrigger({ children, delay, closeDelay, disabled, }: {
|
|
30
|
+
export declare function TooltipTrigger({ children, delay, closeDelay, disabled, open, onOpenChange, closeOnPress, }: {
|
|
31
31
|
/** The control — one element that forwards `ref` and spreads native props, like every
|
|
32
32
|
* system button — then the `Tooltip`. */
|
|
33
33
|
children: ReactNode;
|
|
@@ -35,4 +35,11 @@ export declare function TooltipTrigger({ children, delay, closeDelay, disabled,
|
|
|
35
35
|
delay?: number;
|
|
36
36
|
closeDelay?: number;
|
|
37
37
|
disabled?: boolean;
|
|
38
|
+
/** Open by the consumer — a tooltip a press pins, for a screen with no pointer to hover —,
|
|
39
|
+
* told every change by `onOpenChange`. Absent, React Aria decides. */
|
|
40
|
+
open?: boolean;
|
|
41
|
+
onOpenChange?: (open: boolean) => void;
|
|
42
|
+
/** Pressing the control closes the tooltip (on by default): off when the press is what
|
|
43
|
+
* opens it. */
|
|
44
|
+
closeOnPress?: boolean;
|
|
38
45
|
}): import("react").JSX.Element;
|
|
@@ -68,7 +68,7 @@ function isDisabledControl(control) {
|
|
|
68
68
|
* with the system's own buttons — they forward `ref` and spread native props — or with a
|
|
69
69
|
* plain `<button>`, and never has to know the adapter exists.
|
|
70
70
|
*/
|
|
71
|
-
export function TooltipTrigger({ children, delay, closeDelay, disabled = false, }) {
|
|
71
|
+
export function TooltipTrigger({ children, delay, closeDelay, disabled = false, open, onOpenChange, closeOnPress = true, }) {
|
|
72
72
|
const [control, ...tooltip] = Children.toArray(children);
|
|
73
|
-
return (_jsxs(AriaTooltipTrigger, { delay: delay, closeDelay: closeDelay, isDisabled: disabled, children: [_jsx(InTooltipTrigger.Provider, { value: true, children: _jsx(Focusable, { isDisabled: isDisabledControl(control), children: control }) }), tooltip] }));
|
|
73
|
+
return (_jsxs(AriaTooltipTrigger, { delay: delay, closeDelay: closeDelay, isDisabled: disabled, shouldCloseOnPress: closeOnPress, ...(open === undefined ? {} : { isOpen: open }), ...(onOpenChange === undefined ? {} : { onOpenChange }), children: [_jsx(InTooltipTrigger.Provider, { value: true, children: _jsx(Focusable, { isDisabled: isDisabledControl(control), children: control }) }), tooltip] }));
|
|
74
74
|
}
|
|
@@ -186,7 +186,7 @@ export type GroupColumn<T> = {
|
|
|
186
186
|
/** How that key is read. */
|
|
187
187
|
labelOf: (key: string) => string;
|
|
188
188
|
};
|
|
189
|
-
export declare function DataTable<T extends object>({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals, collapsed, onGroupToggle, piles, onMore, pilesCount, morePiles, onMorePiles, create, copyable, onReorder, }: {
|
|
189
|
+
export declare function DataTable<T extends object>({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals, collapsed, onGroupToggle, piles, onMore, onPage, pilesCount, morePiles, onMorePiles, create, copyable, onReorder, }: {
|
|
190
190
|
data: readonly T[];
|
|
191
191
|
columns: readonly DataColumn<T>[];
|
|
192
192
|
getRowId: (row: T) => string;
|
|
@@ -230,6 +230,9 @@ export declare function DataTable<T extends object>({ data, columns, getRowId, s
|
|
|
230
230
|
/** A pile shows its first page and counts them all: this asks for the next ones, and
|
|
231
231
|
* the table offers it under each pile that holds fewer than it counts. */
|
|
232
232
|
onMore?: (pile: Pile<T>) => void;
|
|
233
|
+
/** Turns an open pile's page (`1` next, `-1` before): its header then carries a pager —
|
|
234
|
+
* see `Grouping.onPage`. «Ver N más» stays under the pile. */
|
|
235
|
+
onPage?: (pile: Pile<T>, step: 1 | -1) => void;
|
|
233
236
|
/** How many piles the first level holds over the whole set, when `piles` is its first
|
|
234
237
|
* page — see `Grouping.pilesCount`. The levels below say theirs in `Pile.pilesCount`. */
|
|
235
238
|
pilesCount?: number;
|
|
@@ -2,13 +2,14 @@
|
|
|
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, pilesFoot, } from "../../foundations/grouping.js";
|
|
5
|
+
import { pathKey, pileFoot, pileItems, pilePage, 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";
|
|
9
9
|
import { EditRow, firstControl } from "./EditableTable.js";
|
|
10
10
|
import { levelNameOf } from "./levels.js";
|
|
11
11
|
import { PileFootLine } from "./PileFootLine.js";
|
|
12
|
+
import { PilePager } from "./PilePager.js";
|
|
12
13
|
import { RowActions } from "./RowActions.js";
|
|
13
14
|
import { useRowReorder } from "./rowReorder.js";
|
|
14
15
|
import { useRowWindow } from "./rowWindow.js";
|
|
@@ -186,7 +187,7 @@ export function aggregateOf(column, rows) {
|
|
|
186
187
|
* the deepest with its records and, when it holds fewer than it counts, its «show more»;
|
|
187
188
|
* a level that holds fewer piles than it counts ends with its «more groups». */
|
|
188
189
|
function entriesOfPiles(piles, walk, parent = null) {
|
|
189
|
-
const { columns, keyOf, collapsed, onToggle, onMore, paging } = walk;
|
|
190
|
+
const { columns, keyOf, collapsed, onToggle, onMore, onPage, paging } = walk;
|
|
190
191
|
const level = piles.flatMap((pile) => {
|
|
191
192
|
const key = pathKey(pile.path);
|
|
192
193
|
const open = collapsed?.includes(key) !== true;
|
|
@@ -201,6 +202,7 @@ function entriesOfPiles(piles, walk, parent = null) {
|
|
|
201
202
|
totals: columns.map((column) => pileAggregate(column, pile)),
|
|
202
203
|
open,
|
|
203
204
|
toggle: onToggle === undefined ? undefined : () => onToggle(key),
|
|
205
|
+
page: open ? pilePage(pile, onPage) : null,
|
|
204
206
|
};
|
|
205
207
|
if (!open)
|
|
206
208
|
return [head];
|
|
@@ -239,7 +241,7 @@ function entriesOfPiles(piles, walk, parent = null) {
|
|
|
239
241
|
},
|
|
240
242
|
];
|
|
241
243
|
}
|
|
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, }) {
|
|
244
|
+
export function DataTable({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals = false, collapsed, onGroupToggle, piles, onMore, onPage, pilesCount, morePiles, onMorePiles, create, copyable = true, onReorder, }) {
|
|
243
245
|
const copy = useUiCopy();
|
|
244
246
|
const draft = create?.draft ?? null;
|
|
245
247
|
const draftRow = useRef(null);
|
|
@@ -388,6 +390,7 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
388
390
|
collapsed,
|
|
389
391
|
onToggle: onGroupToggle,
|
|
390
392
|
onMore,
|
|
393
|
+
onPage,
|
|
391
394
|
paging: {
|
|
392
395
|
...(pilesCount === undefined ? {} : { pilesCount }),
|
|
393
396
|
...(morePiles === undefined ? {} : { morePiles }),
|
|
@@ -422,6 +425,8 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
422
425
|
totals: columns.map((column) => aggregateOf(column, inside)),
|
|
423
426
|
open: collapsed === undefined ? row.getIsExpanded() : !collapsed.includes(key),
|
|
424
427
|
toggle: () => onGroupToggle === undefined ? row.toggleExpanded() : onGroupToggle(key),
|
|
428
|
+
// Grouped from the page in hand: every row of the pile is here, nothing to page.
|
|
429
|
+
page: null,
|
|
425
430
|
};
|
|
426
431
|
});
|
|
427
432
|
const selecting = onSelectedChange !== undefined;
|
|
@@ -491,10 +496,10 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
491
496
|
and how many are inside — what makes it useful without opening it. */
|
|
492
497
|
_jsxs("tr", { ...windowed, "data-ui": "table.pile", ...(entry.toggle === undefined
|
|
493
498
|
? {}
|
|
494
|
-
: { onClick: entry.toggle, className: "group/pile cursor-pointer" }), children: [_jsx("td", { colSpan: labelSpan, className: `px-3 py-1.5 whitespace-nowrap ${PILE_CELL}`, style: indent, children: entry.toggle === undefined ? (_jsx("span", { className: "inline-flex items-center gap-1.5 text-meta font-medium text-ink", children: head })) : (_jsx("button", { type: "button", onClick: (e) => {
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
499
|
+
: { 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: _jsxs("span", { className: "flex items-center justify-between gap-3", 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) => {
|
|
500
|
+
e.stopPropagation();
|
|
501
|
+
entry.toggle?.();
|
|
502
|
+
}, "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 })), entry.page === null ? null : _jsx(PilePager, { page: entry.page })] }) }), columns.slice(sumsFrom).map((c, i) => {
|
|
498
503
|
const value = entry.totals[sumsFrom + i] ?? null;
|
|
499
504
|
return (_jsx("td", { className: `px-3 py-1.5 text-meta font-semibold tabular-nums whitespace-nowrap text-ink ${PILE_CELL} ${c.numeric === true ? "text-right" : ""}`, children: value === null ? null : aggregateLabel(copy, c, value) }, c.id));
|
|
500
505
|
}), firstSum < 0 || rowActions === undefined ? null : (_jsx("td", { className: PILE_CELL }))] }, entry.id),
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { PilePage } from "../../foundations/grouping.js";
|
|
2
|
+
/**
|
|
3
|
+
* The pager on an open pile's header — «51–100 / 2.328 ‹ ›» —, as Odoo draws it on a group's
|
|
4
|
+
* line: where the rows shown fall among the pile's, and the page before and after.
|
|
5
|
+
*
|
|
6
|
+
* Context: it reads as the list's pager (`Pagination`, plain) — the range, then two arrows
|
|
7
|
+
* with the same words —, drawn here because a primitive knows no component. It sits on a
|
|
8
|
+
* header that folds the pile on a press: its own presses stop there, so turning a page never
|
|
9
|
+
* folds what is being read.
|
|
10
|
+
*/
|
|
11
|
+
export declare function PilePager({ page }: {
|
|
12
|
+
page: PilePage;
|
|
13
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
5
|
+
const ARROW = "inline-flex size-(--size-control-sm) items-center justify-center rounded-pill text-muted transition-colors duration-(--duration-instant) disabled:opacity-30 not-disabled:hover:bg-ink/6 not-disabled:hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary";
|
|
6
|
+
/**
|
|
7
|
+
* The pager on an open pile's header — «51–100 / 2.328 ‹ ›» —, as Odoo draws it on a group's
|
|
8
|
+
* line: where the rows shown fall among the pile's, and the page before and after.
|
|
9
|
+
*
|
|
10
|
+
* Context: it reads as the list's pager (`Pagination`, plain) — the range, then two arrows
|
|
11
|
+
* with the same words —, drawn here because a primitive knows no component. It sits on a
|
|
12
|
+
* header that folds the pile on a press: its own presses stop there, so turning a page never
|
|
13
|
+
* folds what is being read.
|
|
14
|
+
*/
|
|
15
|
+
export function PilePager({ page }) {
|
|
16
|
+
const copy = useUiCopy();
|
|
17
|
+
const n = (value) => value.toLocaleString(copy.locale);
|
|
18
|
+
return (
|
|
19
|
+
// biome-ignore lint/a11y/noStaticElementInteractions: it only keeps its presses to itself
|
|
20
|
+
_jsxs("span", { "data-ui": "pile.pager", className: "inline-flex shrink-0 items-center gap-1 text-micro font-normal tabular-nums text-muted", onClick: (event) => event.stopPropagation(), onKeyDown: (event) => event.stopPropagation(), children: [_jsxs("span", { className: "px-1 text-ink", children: [n(page.from), "\u2013", n(page.to)] }), _jsxs("span", { children: ["/ ", n(page.count)] }), _jsx("button", { type: "button", className: ARROW, "aria-label": copy.pager.prev, disabled: page.prev === undefined, onClick: page.prev, children: _jsx(ChevronLeft, { className: "size-(--size-icon-sm)", "aria-hidden": true }) }), _jsx("button", { type: "button", className: ARROW, "aria-label": copy.pager.next, disabled: page.next === undefined, onClick: page.next, children: _jsx(ChevronRight, { className: "size-(--size-icon-sm)", "aria-hidden": true }) })] }));
|
|
21
|
+
}
|
|
@@ -15,13 +15,14 @@ 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, pilesFoot, pilesOf, } from "../../foundations/grouping.js";
|
|
18
|
+
import { pathKey, pileFoot, pileIsOpen, pilePage, 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";
|
|
22
22
|
import { Button } from "../../primitives/button/Button.js";
|
|
23
23
|
import { Empty, Failed, Skeleton } from "../../primitives/notice/Notice.js";
|
|
24
24
|
import { levelNameOf } from "../../primitives/table/levels.js";
|
|
25
|
+
import { PilePager } from "../../primitives/table/PilePager.js";
|
|
25
26
|
import { PivotTable } from "../../primitives/table/PivotTable.js";
|
|
26
27
|
import { ReportTable } from "../../primitives/table/ReportTable.js";
|
|
27
28
|
import { Metric, Metrics } from "../../primitives/value/Metric.js";
|
|
@@ -374,7 +375,11 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
374
375
|
const open = isOpen(pile);
|
|
375
376
|
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
|
|
376
377
|
? {}
|
|
377
|
-
: { onToggle: () => group.onToggle?.(key) })
|
|
378
|
+
: { onToggle: () => group.onToggle?.(key) }), ...(() => {
|
|
379
|
+
/* Odoo's pager on the open pile's band, as the table draws it on its row. */
|
|
380
|
+
const page = open ? pilePage(pile, group?.onPage) : null;
|
|
381
|
+
return page === null ? {} : { pager: _jsx(PilePager, { page: page }) };
|
|
382
|
+
})() }), !open
|
|
378
383
|
? null
|
|
379
384
|
: pile.piles.length > 0
|
|
380
385
|
? renderPiles(pile.piles, nodes, pile)
|
|
@@ -71,7 +71,7 @@ export function TablePresentation({ items, columns, keyOf, levels, group, totals
|
|
|
71
71
|
];
|
|
72
72
|
/* Piles counted by whoever keeps the data go through as they are: the table draws those,
|
|
73
73
|
not the ones it would build from the page. */
|
|
74
|
-
return (_jsx(DataTable, { data: items, columns: columns, getRowId: keyOf, ...(sort === undefined ? {} : { sort }), ...(onSortChange === undefined ? {} : { onSortChange }), ...(levels.length === 0 ? {} : { levels: levels }), ...(group?.collapsed === undefined ? {} : { collapsed: group.collapsed }), ...(group?.onToggle === undefined ? {} : { onGroupToggle: group.onToggle }), ...(group?.piles === undefined || levels.length === 0 ? {} : { piles: group.piles }), ...(group?.onMore === undefined ? {} : { onMore: group.onMore }), ...(group?.pilesCount === undefined ? {} : { pilesCount: group.pilesCount }), ...(group?.morePiles === undefined ? {} : { morePiles: group.morePiles }), ...(group?.onMorePiles === undefined ? {} : { onMorePiles: group.onMorePiles }), ...(selection === undefined
|
|
74
|
+
return (_jsx(DataTable, { data: items, columns: columns, getRowId: keyOf, ...(sort === undefined ? {} : { sort }), ...(onSortChange === undefined ? {} : { onSortChange }), ...(levels.length === 0 ? {} : { levels: levels }), ...(group?.collapsed === undefined ? {} : { collapsed: group.collapsed }), ...(group?.onToggle === undefined ? {} : { onGroupToggle: group.onToggle }), ...(group?.piles === undefined || levels.length === 0 ? {} : { piles: group.piles }), ...(group?.onMore === undefined ? {} : { onMore: group.onMore }), ...(group?.onPage === undefined ? {} : { onPage: group.onPage }), ...(group?.pilesCount === undefined ? {} : { pilesCount: group.pilesCount }), ...(group?.morePiles === undefined ? {} : { morePiles: group.morePiles }), ...(group?.onMorePiles === undefined ? {} : { onMorePiles: group.onMorePiles }), ...(selection === undefined
|
|
75
75
|
? {}
|
|
76
76
|
: {
|
|
77
77
|
selected: new Set(items.filter((i) => selection.has(keyOf(i))).map(keyOf)),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.21.0",
|
|
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",
|