@sincpro/web-ui 2.16.0 → 2.18.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 +25 -2
- package/dist/components/media/OnScroll.d.ts +27 -0
- package/dist/components/media/OnScroll.js +18 -0
- package/dist/components/media/Ribbon.d.ts +39 -0
- package/dist/components/media/Ribbon.js +74 -0
- package/dist/components/media/Rise.d.ts +31 -0
- package/dist/components/media/Rise.js +27 -0
- package/dist/components/media/index.d.ts +3 -0
- package/dist/components/media/index.js +7 -2
- package/dist/foundations/copy.es.js +4 -0
- package/dist/foundations/uiCopy.d.ts +5 -0
- package/dist/foundations/uiCopy.js +4 -0
- package/dist/primitives/table/DataTable.d.ts +11 -1
- package/dist/primitives/table/DataTable.js +16 -7
- package/dist/primitives/table/EditableTable.js +15 -58
- package/dist/primitives/table/Table.d.ts +11 -2
- package/dist/primitives/table/Table.js +12 -5
- package/dist/primitives/table/rowReorder.d.ts +25 -0
- package/dist/primitives/table/rowReorder.js +99 -0
- package/dist/tokens.css +182 -0
- package/dist/views/list/List.d.ts +5 -0
- package/dist/views/list/List.js +4 -0
- package/dist/views/list/ListView.d.ts +1 -1
- package/dist/views/list/ListView.js +2 -2
- package/dist/views/list/presentations.d.ts +2 -2
- package/dist/views/list/presentations.js +2 -2
- package/dist/views/list/types.d.ts +5 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -360,12 +360,14 @@ The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`
|
|
|
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
362
|
`search.advanced`, `search.keys`, `search.completion`, `search.undo`, `search.slash`, `search-entry`, `search-entry.keys`, `table`, `table.pile`, `yes-no`,
|
|
363
|
-
`table.head`, `row.ways`, `topbar`, `topbar.brand`, `topbar.menus`, `topbar.actions`, `topbar.user`,
|
|
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`,
|
|
366
366
|
`plan.features`, `plan.action`, `qr`, `price`, `price.before`, `range-slider`, `rating`, `gallery`,
|
|
367
367
|
`gallery.main`, `gallery.strip`, `lightbox`, `carousel`, `carousel.track`, `carousel.slide`,
|
|
368
|
-
`carousel.dots`, `
|
|
368
|
+
`carousel.dots`, `rise.line`, `appear`, `draw-on-scroll` (with `data-axis`), `enter-on-scroll`,
|
|
369
|
+
`ribbon` (with `data-moving`, `data-paused`, `data-direction`), `ribbon.viewport`, `ribbon.list`,
|
|
370
|
+
`ribbon.copy`, `story-ring` (with `data-seen`), `story-bar`, `story-viewer`, `story-viewer.progress`,
|
|
369
371
|
`story-viewer.media`, `notification-bell`, `notification-panel`, `notification-panel.group`,
|
|
370
372
|
`notification-panel.item` (with `data-unread`), `portal-nav`, `portal-nav.person`, `portal-nav.toggle`,
|
|
371
373
|
`portal-nav.sections`, `check-field`, `file-preview.video`, `file-preview.audio`, `file-preview.office` (with `data-kind`), `sidebar`, `sidebar.brand`,
|
|
@@ -407,6 +409,27 @@ real links, folded into one button on a phone), and `CheckField` — a yes/no ro
|
|
|
407
409
|
`FormSection columns` and is the «settings» row. `FilePreview` plays video and audio with the
|
|
408
410
|
browser's own players and shows Word, Excel and PowerPoint as an «abrir o descargar» card.
|
|
409
411
|
|
|
412
|
+
A site's landing has its own motion — and only a site's page uses it (the register is explained
|
|
413
|
+
under «A SITE'S PAGE» in `tokens.css`): `Rise` (a headline that rises line by line, inside the
|
|
414
|
+
application's own `<h1>`), `Appear step` (what follows it, on the same clock), `DrawOnScroll`
|
|
415
|
+
(a rule or a line drawn by the scroll itself) and `EnterOnScroll` (a section that enters), all
|
|
416
|
+
CSS with no JavaScript; and `Ribbon` (items that pass in a loop, as many copies as the width
|
|
417
|
+
needs, with a pause button). The same motion is open as utilities for an element of the site's
|
|
418
|
+
own — `rise-line`, `appear-in` (with `--motion-step`), `draw-on-scroll-x`, `draw-on-scroll-y`,
|
|
419
|
+
`enter-on-scroll`. Every one is the final state in the HTML, moves only under
|
|
420
|
+
`prefers-reduced-motion: no-preference`, and the scroll-driven ones are simply drawn where the
|
|
421
|
+
browser lacks `animation-timeline`; under reduced motion the ribbon is a row to scroll.
|
|
422
|
+
|
|
423
|
+
```tsx
|
|
424
|
+
<h1 className="font-serif text-6xl">
|
|
425
|
+
<Rise lines={["¿Tu auditor está", "habilitado para ejercer?"]} />
|
|
426
|
+
</h1>
|
|
427
|
+
<Appear step={2} as="p">Verifica en el registro del colegio…</Appear>
|
|
428
|
+
<Ribbon label="Galería del colegio" speed="slow">
|
|
429
|
+
{albums.map((album) => <AlbumCover key={album.id} album={album} />)}
|
|
430
|
+
</Ribbon>
|
|
431
|
+
```
|
|
432
|
+
|
|
410
433
|
#### A form that explains itself: the «settings» style
|
|
411
434
|
|
|
412
435
|
The default form is the dense sheet of an ERP — label | control, two columns, help behind a
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type DrawOnScrollProps = {
|
|
3
|
+
/** The rule or line drawn: a `Divider`, a bar of the brand's colour, a timeline's line. */
|
|
4
|
+
children: ReactNode;
|
|
5
|
+
/** `x` draws from the start edge (a rule under a word), `y` from the top (a timeline). */
|
|
6
|
+
axis?: "x" | "y";
|
|
7
|
+
/** The element it is. `div` by default; `span` inside a line of text. */
|
|
8
|
+
as?: "div" | "span";
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* A rule or a line drawn by the scroll itself as it comes into view.
|
|
12
|
+
*
|
|
13
|
+
* Context: it scales its own box, so it wraps the line and nothing else — a line that sits
|
|
14
|
+
* absolutely (a timeline's spine) takes the utility on itself instead:
|
|
15
|
+
* `className="draw-on-scroll-y"`.
|
|
16
|
+
*/
|
|
17
|
+
export declare function DrawOnScroll({ children, axis, as: Element, }: DrawOnScrollProps): import("react").JSX.Element;
|
|
18
|
+
export type EnterOnScrollProps = {
|
|
19
|
+
children: ReactNode;
|
|
20
|
+
/** The element it is. `div` by default; `li` for an item of a list. */
|
|
21
|
+
as?: "div" | "li" | "section" | "article";
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* A row of a site's page that enters as it scrolls into view. For a landing's sections —
|
|
25
|
+
* never for a list a person works in, where a row that is not there yet is a row not read.
|
|
26
|
+
*/
|
|
27
|
+
export declare function EnterOnScroll({ children, as: Element }: EnterOnScrollProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* A rule or a line drawn by the scroll itself as it comes into view.
|
|
4
|
+
*
|
|
5
|
+
* Context: it scales its own box, so it wraps the line and nothing else — a line that sits
|
|
6
|
+
* absolutely (a timeline's spine) takes the utility on itself instead:
|
|
7
|
+
* `className="draw-on-scroll-y"`.
|
|
8
|
+
*/
|
|
9
|
+
export function DrawOnScroll({ children, axis = "x", as: Element = "div", }) {
|
|
10
|
+
return (_jsx(Element, { "data-ui": "draw-on-scroll", "data-axis": axis, className: axis === "x" ? "draw-on-scroll-x" : "draw-on-scroll-y", children: children }));
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* A row of a site's page that enters as it scrolls into view. For a landing's sections —
|
|
14
|
+
* never for a list a person works in, where a row that is not there yet is a row not read.
|
|
15
|
+
*/
|
|
16
|
+
export function EnterOnScroll({ children, as: Element = "div" }) {
|
|
17
|
+
return (_jsx(Element, { "data-ui": "enter-on-scroll", className: "enter-on-scroll", children: children }));
|
|
18
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { type ReactNode } from "react";
|
|
2
|
+
declare const SPEED: {
|
|
3
|
+
readonly slow: 24;
|
|
4
|
+
readonly normal: 40;
|
|
5
|
+
readonly fast: 64;
|
|
6
|
+
};
|
|
7
|
+
declare const GAP: {
|
|
8
|
+
readonly sm: "gap-2 pe-2";
|
|
9
|
+
readonly md: "gap-4 pe-4";
|
|
10
|
+
readonly lg: "gap-6 pe-6";
|
|
11
|
+
};
|
|
12
|
+
export type RibbonProps = {
|
|
13
|
+
/** Each child is an item that passes: a cover, a logo, a testimony. */
|
|
14
|
+
children: ReactNode;
|
|
15
|
+
/** What the ribbon is, said: «Galería del colegio», «Confían en nosotros». */
|
|
16
|
+
label: string;
|
|
17
|
+
/** How fast it passes, by distance: slow, normal (default) or fast. */
|
|
18
|
+
speed?: keyof typeof SPEED;
|
|
19
|
+
/** Where it goes: to the left (default) or to the right — two rows that cross. */
|
|
20
|
+
direction?: "left" | "right";
|
|
21
|
+
/** The space between the items. */
|
|
22
|
+
gap?: keyof typeof GAP;
|
|
23
|
+
/** The edges fade instead of cutting. On by default. */
|
|
24
|
+
fade?: boolean;
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* Items that pass by themselves in a loop: a site's covers, its partners' logos.
|
|
28
|
+
*
|
|
29
|
+
* Context: the list is written once for everyone and repeated only to fill the loop — as
|
|
30
|
+
* many copies as the width needs, measured, so a short list on a wide screen never leaves a
|
|
31
|
+
* hole. The copies are `aria-hidden` and `inert`: a reader hears the list once, Tab stops on
|
|
32
|
+
* each link once. It stops under the pointer, with the focus inside, and with its pause
|
|
33
|
+
* button — a finger has no hover, and something that moves by itself for more than five
|
|
34
|
+
* seconds must be stoppable (WCAG 2.2.2). Under reduced motion, and on the server, it is a
|
|
35
|
+
* row that scrolls by hand: the server cannot know, so it sends the row, and the browser
|
|
36
|
+
* starts it once it has measured.
|
|
37
|
+
*/
|
|
38
|
+
export declare function Ribbon({ children, label, speed, direction, gap, fade, }: RibbonProps): import("react").JSX.Element;
|
|
39
|
+
export {};
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { useReducedMotion } from "./motion.js";
|
|
4
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
|
+
import { IconButton } from "../../primitives/button/Button.js";
|
|
6
|
+
import { Pause, Play } from "lucide-react";
|
|
7
|
+
import { Children, useLayoutEffect, useRef, useState, } from "react";
|
|
8
|
+
/* Pixels per second. By distance and not by a duration for the whole loop: a ribbon of four
|
|
9
|
+
covers and one of twenty logos then pass at the same pace, the one the eye can follow. */
|
|
10
|
+
const SPEED = { slow: 24, normal: 40, fast: 64 };
|
|
11
|
+
/* The gap is written twice on purpose: between the items, and once more after the last
|
|
12
|
+
(`pe-*`). Every copy is then exactly one period wide, and the track can move one copy and
|
|
13
|
+
start again without a jump — a single row with `gap` lands half a gap off on each turn. */
|
|
14
|
+
const GAP = {
|
|
15
|
+
sm: "gap-2 pe-2",
|
|
16
|
+
md: "gap-4 pe-4",
|
|
17
|
+
lg: "gap-6 pe-6",
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Items that pass by themselves in a loop: a site's covers, its partners' logos.
|
|
21
|
+
*
|
|
22
|
+
* Context: the list is written once for everyone and repeated only to fill the loop — as
|
|
23
|
+
* many copies as the width needs, measured, so a short list on a wide screen never leaves a
|
|
24
|
+
* hole. The copies are `aria-hidden` and `inert`: a reader hears the list once, Tab stops on
|
|
25
|
+
* each link once. It stops under the pointer, with the focus inside, and with its pause
|
|
26
|
+
* button — a finger has no hover, and something that moves by itself for more than five
|
|
27
|
+
* seconds must be stoppable (WCAG 2.2.2). Under reduced motion, and on the server, it is a
|
|
28
|
+
* row that scrolls by hand: the server cannot know, so it sends the row, and the browser
|
|
29
|
+
* starts it once it has measured.
|
|
30
|
+
*/
|
|
31
|
+
export function Ribbon({ children, label, speed = "normal", direction = "left", gap = "md", fade = true, }) {
|
|
32
|
+
const copy = useUiCopy();
|
|
33
|
+
const reduced = useReducedMotion();
|
|
34
|
+
const items = Children.toArray(children);
|
|
35
|
+
const viewport = useRef(null);
|
|
36
|
+
const first = useRef(null);
|
|
37
|
+
const [loop, setLoop] = useState(null);
|
|
38
|
+
const [paused, setPaused] = useState(false);
|
|
39
|
+
const moving = !reduced && loop !== null && items.length > 1;
|
|
40
|
+
/* Measured before paint, again when the width changes (a rotated phone, loaded images). */
|
|
41
|
+
useLayoutEffect(() => {
|
|
42
|
+
if (reduced)
|
|
43
|
+
return;
|
|
44
|
+
const view = viewport.current;
|
|
45
|
+
const list = first.current;
|
|
46
|
+
if (view === null || list === null)
|
|
47
|
+
return;
|
|
48
|
+
const measure = () => {
|
|
49
|
+
const period = list.offsetWidth;
|
|
50
|
+
if (period === 0)
|
|
51
|
+
return;
|
|
52
|
+
const copies = Math.max(2, Math.ceil(view.clientWidth / period) + 1);
|
|
53
|
+
const seconds = period / SPEED[speed];
|
|
54
|
+
setLoop((was) => was?.copies === copies && was.seconds === seconds ? was : { copies, seconds });
|
|
55
|
+
};
|
|
56
|
+
measure();
|
|
57
|
+
const observer = new ResizeObserver(measure);
|
|
58
|
+
observer.observe(view);
|
|
59
|
+
observer.observe(list);
|
|
60
|
+
return () => observer.disconnect();
|
|
61
|
+
}, [reduced, speed]);
|
|
62
|
+
const list = (repeat) => (_jsx("ul", { ref: repeat === 0 ? first : undefined, "data-ui": repeat === 0 ? "ribbon.list" : "ribbon.copy", "aria-hidden": repeat === 0 ? undefined : true, inert: repeat !== 0, className: `flex shrink-0 items-stretch ${GAP[gap]}`, children: items.map((item, at) => (_jsx("li", { className: "flex shrink-0 snap-start", children: item }, at))) }, repeat));
|
|
63
|
+
return (_jsxs("section", { "data-ui": "ribbon", "aria-label": label, "data-moving": moving ? "" : undefined, "data-paused": moving && paused ? "" : undefined, "data-direction": direction, className: "relative min-w-0", style: moving && loop !== null
|
|
64
|
+
? {
|
|
65
|
+
"--ribbon-copies": loop.copies,
|
|
66
|
+
"--ribbon-duration": `${loop.seconds}s`,
|
|
67
|
+
}
|
|
68
|
+
: undefined, children: [_jsx("div", { ref: viewport, "data-ui": "ribbon.viewport",
|
|
69
|
+
/* Still, it is a row to scroll — reachable by keyboard (axe:
|
|
70
|
+
scrollable-region-focusable); moving, the pause button is the stop. */
|
|
71
|
+
tabIndex: moving ? undefined : 0, className: `rounded-control focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${moving ? "overflow-clip" : "snap-x overflow-x-auto overscroll-x-contain"} ${fade && moving ? "ribbon-fade" : ""}`, children: _jsxs("div", { className: "ribbon-track", children: [list(0), moving && loop !== null
|
|
72
|
+
? Array.from({ length: loop.copies - 1 }, (_, at) => list(at + 1))
|
|
73
|
+
: null] }) }), !moving ? null : (_jsx("span", { className: "absolute end-3 top-1/2 -translate-y-1/2 rounded-pill bg-surface/90 shadow-raised", children: _jsx(IconButton, { icon: paused ? Play : Pause, label: paused ? copy.ribbon.play : copy.ribbon.pause, size: "sm", onClick: () => setPaused((was) => !was) }) }))] }));
|
|
74
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { ReactNode } from "react";
|
|
2
|
+
export type RiseProps = {
|
|
3
|
+
/** The headline, one entry per line: each rises in turn. Where it breaks is the
|
|
4
|
+
* application's decision — a line that does not fit still wraps inside its own mask. */
|
|
5
|
+
lines: readonly ReactNode[];
|
|
6
|
+
/** The step of the first line, when something enters before it. 0 by default. */
|
|
7
|
+
start?: number;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* A headline that rises line by line from behind its own lower edge — the one moment a
|
|
11
|
+
* site's landing opens with.
|
|
12
|
+
*
|
|
13
|
+
* Context: it draws only the lines, so it goes inside the application's own heading, with
|
|
14
|
+
* the heading's own look: `<h1 className="…"><Rise lines={[…]} /></h1>`. A space is written
|
|
15
|
+
* between the lines: each line is a block, and without it a reader announces «estáhabilitado».
|
|
16
|
+
* Under reduced motion the lines are simply there.
|
|
17
|
+
*/
|
|
18
|
+
export declare function Rise({ lines, start }: RiseProps): import("react").JSX.Element[];
|
|
19
|
+
export type AppearProps = {
|
|
20
|
+
children: ReactNode;
|
|
21
|
+
/** Its place in the page's entrance, on the same clock as `Rise`'s lines: after a
|
|
22
|
+
* two-line headline, what follows is step 2, then 3. */
|
|
23
|
+
step?: number;
|
|
24
|
+
/** The element it is. `div` by default. */
|
|
25
|
+
as?: "div" | "span" | "li" | "p";
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* What follows a headline, appearing in its step: the lead, the search box, the call to
|
|
29
|
+
* action.
|
|
30
|
+
*/
|
|
31
|
+
export declare function Appear({ children, step, as: Element }: AppearProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/* No "use client": an entrance is CSS (`rise-line`, `appear-in` in tokens.css). The server
|
|
3
|
+
sends the final state and the browser plays the entrance on its own first paint — there is
|
|
4
|
+
nothing to hydrate and nothing that can differ between the two sides. */
|
|
5
|
+
/** The place of a piece in its page's entrance: 0, 1, 2… on one clock (`--duration-step`). */
|
|
6
|
+
function stepStyle(step) {
|
|
7
|
+
return { "--motion-step": step };
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* A headline that rises line by line from behind its own lower edge — the one moment a
|
|
11
|
+
* site's landing opens with.
|
|
12
|
+
*
|
|
13
|
+
* Context: it draws only the lines, so it goes inside the application's own heading, with
|
|
14
|
+
* the heading's own look: `<h1 className="…"><Rise lines={[…]} /></h1>`. A space is written
|
|
15
|
+
* between the lines: each line is a block, and without it a reader announces «estáhabilitado».
|
|
16
|
+
* Under reduced motion the lines are simply there.
|
|
17
|
+
*/
|
|
18
|
+
export function Rise({ lines, start = 0 }) {
|
|
19
|
+
return lines.map((line, at) => (_jsxs("span", { "data-ui": "rise.line", className: "rise-line", style: stepStyle(start + at), children: [_jsx("span", { children: line }), at < lines.length - 1 ? " " : null] }, at)));
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* What follows a headline, appearing in its step: the lead, the search box, the call to
|
|
23
|
+
* action.
|
|
24
|
+
*/
|
|
25
|
+
export function Appear({ children, step = 0, as: Element = "div" }) {
|
|
26
|
+
return (_jsx(Element, { "data-ui": "appear", className: "appear-in", style: stepStyle(step), children: children }));
|
|
27
|
+
}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
1
|
export { Carousel, type CarouselPerView, type CarouselProps, } from "./Carousel.js";
|
|
2
|
+
export { DrawOnScroll, type DrawOnScrollProps, EnterOnScroll, type EnterOnScrollProps, } from "./OnScroll.js";
|
|
3
|
+
export { Ribbon, type RibbonProps } from "./Ribbon.js";
|
|
4
|
+
export { Appear, type AppearProps, Rise, type RiseProps, } from "./Rise.js";
|
|
2
5
|
export { StoryBar, type StoryBarProps, type StoryItem, type StoryPerson, StoryRing, type StoryRingProps, StoryViewer, type StoryViewerProps, } from "./Stories.js";
|
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
/* MEDIA AND SOCIAL — slides that turn (Carousel)
|
|
2
|
-
(StoryRing, StoryBar, StoryViewer)
|
|
1
|
+
/* MEDIA AND SOCIAL — slides that turn (Carousel), a person's stories at full screen
|
|
2
|
+
(StoryRing, StoryBar, StoryViewer), and a site's motion: a headline that rises (Rise,
|
|
3
|
+
Appear), lines drawn by the scroll (DrawOnScroll, EnterOnScroll) and items that pass by
|
|
4
|
+
themselves (Ribbon). Data-agnostic: the application passes the content. */
|
|
3
5
|
export { Carousel, } from "./Carousel.js";
|
|
6
|
+
export { DrawOnScroll, EnterOnScroll, } from "./OnScroll.js";
|
|
7
|
+
export { Ribbon } from "./Ribbon.js";
|
|
8
|
+
export { Appear, Rise, } from "./Rise.js";
|
|
4
9
|
export { StoryBar, StoryRing, StoryViewer, } from "./Stories.js";
|
|
@@ -961,6 +961,11 @@ export type UiCopy = {
|
|
|
961
961
|
pause: string;
|
|
962
962
|
play: string;
|
|
963
963
|
};
|
|
964
|
+
/** Items that pass by themselves (`Ribbon`). */
|
|
965
|
+
ribbon: {
|
|
966
|
+
pause: string;
|
|
967
|
+
play: string;
|
|
968
|
+
};
|
|
964
969
|
/** A person's stories (`StoryBar`, `StoryViewer`). */
|
|
965
970
|
stories: {
|
|
966
971
|
label: string;
|
|
@@ -178,7 +178,7 @@ export type GroupColumn<T> = {
|
|
|
178
178
|
/** How that key is read. */
|
|
179
179
|
labelOf: (key: string) => string;
|
|
180
180
|
};
|
|
181
|
-
export declare function DataTable<T extends object>({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals, collapsed, onGroupToggle, piles, onMore, create, copyable, }: {
|
|
181
|
+
export declare function DataTable<T extends object>({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals, collapsed, onGroupToggle, piles, onMore, create, copyable, onReorder, }: {
|
|
182
182
|
data: readonly T[];
|
|
183
183
|
columns: readonly DataColumn<T>[];
|
|
184
184
|
getRowId: (row: T) => string;
|
|
@@ -227,4 +227,14 @@ export declare function DataTable<T extends object>({ data, columns, getRowId, s
|
|
|
227
227
|
/** The cells' copy buttons, on by default. `false` takes them off the whole table; a
|
|
228
228
|
* column turns its own off with `copy: false`. */
|
|
229
229
|
copyable?: boolean;
|
|
230
|
+
/**
|
|
231
|
+
* The records are in an order a person sets by hand (a `sequence`): a grip at the start of
|
|
232
|
+
* each row drags it, Alt + ↑ / ↓ moves it — `EditableTable`'s, the same `useRowReorder`.
|
|
233
|
+
* `before` is the row it lands in front of, `null` the end: one move, true on a page too.
|
|
234
|
+
*
|
|
235
|
+
* Off while grouped (the piles decide the order) and while sorted by a column (a row
|
|
236
|
+
* dropped would jump back to where the sort puts it): the order shown has to be the one
|
|
237
|
+
* being changed.
|
|
238
|
+
*/
|
|
239
|
+
onReorder?: (id: string, before: string | null) => void;
|
|
230
240
|
}): import("react").JSX.Element;
|
|
@@ -10,6 +10,7 @@ import { EditRow, firstControl } from "./EditableTable.js";
|
|
|
10
10
|
import { levelNameOf } from "./levels.js";
|
|
11
11
|
import { PileFootLine } from "./PileFootLine.js";
|
|
12
12
|
import { RowActions } from "./RowActions.js";
|
|
13
|
+
import { useRowReorder } from "./rowReorder.js";
|
|
13
14
|
import { useRowWindow } from "./rowWindow.js";
|
|
14
15
|
import { SelectBox, Table, Td, Th, THead, Tr } from "./Table.js";
|
|
15
16
|
import { YesNo } from "../value/YesNo.js";
|
|
@@ -222,7 +223,7 @@ function entriesOfPiles(piles, columns, keyOf, collapsed, onToggle, onMore) {
|
|
|
222
223
|
];
|
|
223
224
|
});
|
|
224
225
|
}
|
|
225
|
-
export function DataTable({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals = false, collapsed, onGroupToggle, piles, onMore, create, copyable = true, }) {
|
|
226
|
+
export function DataTable({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals = false, collapsed, onGroupToggle, piles, onMore, create, copyable = true, onReorder, }) {
|
|
226
227
|
const copy = useUiCopy();
|
|
227
228
|
const draft = create?.draft ?? null;
|
|
228
229
|
const draftRow = useRef(null);
|
|
@@ -397,7 +398,15 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
397
398
|
};
|
|
398
399
|
});
|
|
399
400
|
const selecting = onSelectedChange !== undefined;
|
|
400
|
-
const
|
|
401
|
+
const reorder = useRowReorder({
|
|
402
|
+
order: entries.flatMap((entry) => (entry.kind === "row" ? [entry.id] : [])),
|
|
403
|
+
onReorder,
|
|
404
|
+
enabled: (levels ?? []).length === 0 && piles === undefined && (sort ?? []).length === 0,
|
|
405
|
+
});
|
|
406
|
+
const width = columns.length +
|
|
407
|
+
(selecting ? 1 : 0) +
|
|
408
|
+
(reorder.on ? 1 : 0) +
|
|
409
|
+
(rowActions === undefined ? 0 : 1);
|
|
401
410
|
/* Past a few hundred rows only the ones in view are drawn — see `rowWindow.tsx`. It
|
|
402
411
|
windows what is DRAWN, pile headers included and folded rows left out: that is the
|
|
403
412
|
sequence a person scrolls through. */
|
|
@@ -418,7 +427,7 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
418
427
|
first one that sums, and from there each column says what the pile adds up to UNDER
|
|
419
428
|
itself — Odoo's grouped list. With no column that sums, the name spans the row. */
|
|
420
429
|
const firstSum = columns.findIndex((c) => c.aggregate !== undefined && c.numeric === true);
|
|
421
|
-
const lead = selecting ? 1 : 0;
|
|
430
|
+
const lead = (selecting ? 1 : 0) + (reorder.on ? 1 : 0);
|
|
422
431
|
const labelSpan = firstSum < 0 ? width : Math.max(1, lead + firstSum);
|
|
423
432
|
const sumsFrom = firstSum < 0 ? columns.length : labelSpan - lead;
|
|
424
433
|
const all = leaves.length > 0 && leaves.every((id) => selected?.has(id) === true);
|
|
@@ -435,7 +444,7 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
435
444
|
? {
|
|
436
445
|
rowCount: 1 + entries.length + (draft === null ? 0 : 1) + (totals ? 1 : 0),
|
|
437
446
|
}
|
|
438
|
-
: {}), children: [_jsxs(THead, { ...(view.on ? { rowIndex: 1 } : {}), children: [selecting ? (_jsx(Th, { width: 36, children: _jsx(SelectBox, { label: copy.selection.all, checked: all, indeterminate: some, onChange: (v) => onSelectedChange?.(v ? new Set(leaves) : new Set()) }) })) : null, columns.map((c) => (_jsx(Th, { sortKey: c.sortable === false ? undefined : c.id, sort: sort, onSort: onSortChange, numeric: c.numeric, width: c.width, children: c.header }, c.id))), rowActions === undefined ? null : (_jsx("td", { className: "w-px border-b border-line-strong" }))] }), _jsxs("tbody", { ref: view.body.ref, children: [view.rows.flatMap((slot, at) => {
|
|
447
|
+
: {}), children: [_jsxs(THead, { ...(view.on ? { rowIndex: 1 } : {}), children: [reorder.on ? _jsx("td", { className: "w-0 border-b border-line-strong" }) : null, selecting ? (_jsx(Th, { width: 36, children: _jsx(SelectBox, { label: copy.selection.all, checked: all, indeterminate: some, onChange: (v) => onSelectedChange?.(v ? new Set(leaves) : new Set()) }) })) : null, columns.map((c) => (_jsx(Th, { sortKey: c.sortable === false ? undefined : c.id, sort: sort, onSort: onSortChange, numeric: c.numeric, width: c.width, children: c.header }, c.id))), rowActions === undefined ? null : (_jsx("td", { className: "w-px border-b border-line-strong" }))] }), _jsxs("tbody", { ref: view.body.ref, ...reorder.body, children: [view.rows.flatMap((slot, at) => {
|
|
439
448
|
const entry = entries[slot.index];
|
|
440
449
|
if (entry === undefined)
|
|
441
450
|
return [];
|
|
@@ -469,7 +478,7 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
469
478
|
const id = entry.id;
|
|
470
479
|
return [
|
|
471
480
|
gap,
|
|
472
|
-
_jsxs(Tr, { ...(windowed === undefined ? {} : { windowed }), selected: selected?.has(id) === true, onClick: onRowClick === undefined ? undefined : () => onRowClick(original), children: [selecting ? (_jsx(Td, { children: _jsx(SelectBox, { label: copy.selection.row, checked: selected?.has(id) === true, onChange: (v) => toggle(id, v) }) })) : null, columns.map((c) => {
|
|
481
|
+
_jsxs(Tr, { ...(windowed === undefined ? {} : { windowed }), selected: selected?.has(id) === true, onClick: onRowClick === undefined ? undefined : () => onRowClick(original), ...(reorder.on ? { rowId: id, line: reorder.line(id) } : {}), children: [reorder.on ? _jsx(Td, { fit: true, children: reorder.grip(id) }) : null, selecting ? (_jsx(Td, { children: _jsx(SelectBox, { label: copy.selection.row, checked: selected?.has(id) === true, onChange: (v) => toggle(id, v) }) })) : null, columns.map((c) => {
|
|
473
482
|
const t = c.tone?.(original);
|
|
474
483
|
const n = c.note?.(original);
|
|
475
484
|
const edit = c.edit?.when?.(original) === false ? undefined : c.edit;
|
|
@@ -489,10 +498,10 @@ export function DataTable({ data, columns, getRowId, sort, onSortChange, levels,
|
|
|
489
498
|
create.onCommit(draft);
|
|
490
499
|
start();
|
|
491
500
|
return true;
|
|
492
|
-
}, children: [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) => {
|
|
501
|
+
}, 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) => {
|
|
493
502
|
touched.current = true;
|
|
494
503
|
create.onChange(next);
|
|
495
|
-
}) ?? null }, c.id))), rowActions === undefined ? null : _jsx("td", { className: DRAFT_CELL })] }))] }), footer === null ? null : (_jsx("tfoot", { className: "sticky bottom-0 z-10 bg-ground", children: _jsxs("tr", { className: "border-t border-line-strong", "aria-rowindex": view.on ? 2 + entries.length + (draft === null ? 0 : 1) : undefined, children: [selecting ? _jsx("td", {}) : null, columns.map((c, i) => {
|
|
504
|
+
}) ?? null }, c.id))), rowActions === undefined ? null : _jsx("td", { className: DRAFT_CELL })] }))] }), footer === null ? null : (_jsx("tfoot", { className: "sticky bottom-0 z-10 bg-ground", children: _jsxs("tr", { className: "border-t border-line-strong", "aria-rowindex": view.on ? 2 + entries.length + (draft === null ? 0 : 1) : undefined, children: [reorder.on ? _jsx("td", {}) : null, selecting ? _jsx("td", {}) : null, columns.map((c, i) => {
|
|
496
505
|
const value = footer[i] ?? null;
|
|
497
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));
|
|
498
507
|
}), rowActions === undefined ? null : _jsx("td", {})] }) }))] }));
|
|
@@ -10,9 +10,10 @@ import { IconButton } from "../button/Button.js";
|
|
|
10
10
|
import { NoteCard, NoteRegistryContext, } from "../field/note.js";
|
|
11
11
|
import { Flag } from "../notice/Flag.js";
|
|
12
12
|
import { sectionLines, stackPlaces, tabTarget, } from "./editRules.js";
|
|
13
|
+
import { useRowReorder } from "./rowReorder.js";
|
|
13
14
|
import { useRowWindow } from "./rowWindow.js";
|
|
14
15
|
import { HEADER_TEXT } from "./Table.js";
|
|
15
|
-
import { AlertCircle,
|
|
16
|
+
import { AlertCircle, Plus, Trash2 } from "lucide-react";
|
|
16
17
|
import { Fragment, useContext, useEffect, useId, useLayoutEffect, useMemo, useRef, useState, } from "react";
|
|
17
18
|
import { useKeyboard } from "react-aria";
|
|
18
19
|
export { sectionLines, stackPlaces, tabTarget };
|
|
@@ -393,8 +394,6 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
|
|
|
393
394
|
/* The rows in the order they are drawn: what the arrows walk. */
|
|
394
395
|
const order = drawn.flatMap((entry) => entry.row === undefined ? [] : [getRowId(entry.row)]);
|
|
395
396
|
const stop = active !== null && order.includes(active) ? active : (order[0] ?? null);
|
|
396
|
-
/* REORDER — a grip at the start of each row. Dragged, the row shows where it would land (a
|
|
397
|
-
line over the row it goes in front of); Alt + ↑ / ↓ on the grip does the same by keyboard. */
|
|
398
397
|
/* The notes of the rows the window does not draw. A drawn row's mark registers its note
|
|
399
398
|
with the record (`NoteCard`); one scrolled out of the window would vanish from the
|
|
400
399
|
record's activity — «2 avisos» for a document that has nine. The table registers those
|
|
@@ -454,51 +453,20 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
|
|
|
454
453
|
for (const noteId of ownNotes.current)
|
|
455
454
|
registry?.drop(noteId);
|
|
456
455
|
}, [registry]);
|
|
457
|
-
|
|
456
|
+
/* The row's move — `useRowReorder`, shared with `DataTable`. Off while grouped (the piles
|
|
457
|
+
decide the order) and on a phone's cards. */
|
|
458
|
+
const reorder = useRowReorder({
|
|
459
|
+
order,
|
|
460
|
+
onReorder,
|
|
461
|
+
enabled: grouping === undefined && !stacked,
|
|
462
|
+
});
|
|
463
|
+
const reorderable = reorder.on;
|
|
458
464
|
/* Every cell of a row, the grip and the trash: what a spacer row spans. */
|
|
459
465
|
const width = columns.length + (onRemove === undefined ? 0 : 1) + (reorderable ? 1 : 0);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
const
|
|
464
|
-
const land = (id, before) => {
|
|
465
|
-
if (before === id || before === after(id))
|
|
466
|
-
return;
|
|
467
|
-
onReorder?.(id, before);
|
|
468
|
-
};
|
|
469
|
-
const overRow = (event) => {
|
|
470
|
-
if (dragged.current === null)
|
|
471
|
-
return;
|
|
472
|
-
const tr = event.target.closest("tr[data-row-id]");
|
|
473
|
-
if (tr === null)
|
|
474
|
-
return;
|
|
475
|
-
event.preventDefault();
|
|
476
|
-
const id = tr.dataset["rowId"] ?? "";
|
|
477
|
-
const box = tr.getBoundingClientRect();
|
|
478
|
-
setLanding(event.clientY < box.top + box.height / 2 ? id : after(id));
|
|
479
|
-
};
|
|
480
|
-
const lineOver = (id) => (landing === id ? "border-t-2 border-t-primary" : "");
|
|
481
|
-
const grip = (id, mark) => (_jsx("td", { className: `w-0 py-1 pr-0 pl-1 align-middle ${mark} ${lineOver(id)}`, children: _jsx("button", { type: "button", draggable: true, "aria-label": copy.editable.reorder, title: copy.editable.reorderHint, "aria-keyshortcuts": "Alt+ArrowUp Alt+ArrowDown", ...(editable && stop !== id ? { tabIndex: -1 } : {}), onClick: (event) => event.stopPropagation(), onKeyDown: (event) => {
|
|
482
|
-
if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown"))
|
|
483
|
-
return;
|
|
484
|
-
event.preventDefault();
|
|
485
|
-
event.stopPropagation();
|
|
486
|
-
const at = order.indexOf(id);
|
|
487
|
-
if (event.key === "ArrowUp" && at > 0)
|
|
488
|
-
land(id, order[at - 1] ?? null);
|
|
489
|
-
if (event.key === "ArrowDown" && at < order.length - 1)
|
|
490
|
-
land(id, order[at + 2] ?? null);
|
|
491
|
-
}, onDragStart: (event) => {
|
|
492
|
-
event.dataTransfer.setData("text/plain", id);
|
|
493
|
-
event.dataTransfer.effectAllowed = "move";
|
|
494
|
-
const tr = event.currentTarget.closest("tr");
|
|
495
|
-
if (tr !== null)
|
|
496
|
-
event.dataTransfer.setDragImage(tr, 16, 16);
|
|
497
|
-
dragged.current = id;
|
|
498
|
-
}, onDragEnd: () => {
|
|
499
|
-
dragged.current = null;
|
|
500
|
-
setLanding(undefined);
|
|
501
|
-
}, className: "flex cursor-grab items-center rounded-control p-0.5 text-muted opacity-40 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 hover:text-ink focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-primary active:cursor-grabbing", children: _jsx(GripVertical, { "aria-hidden": true, className: "size-(--size-icon-sm)", strokeWidth: 2 }) }) }));
|
|
466
|
+
const lineOver = reorder.line;
|
|
467
|
+
/* Only the row holding the tab stop offers its grip to `Tab`; the others are reached with
|
|
468
|
+
the arrows first. */
|
|
469
|
+
const grip = (id, mark) => (_jsx("td", { className: `w-0 py-1 pr-0 pl-1 align-middle ${mark} ${lineOver(id)}`, children: reorder.grip(id, { tabbable: !(editable && stop !== id) }) }));
|
|
502
470
|
/* The focus a row is waiting for, once it is drawn: opened by the keyboard (its first or
|
|
503
471
|
last control), or reached by a jump (`Home`, `End`) past what the window draws. Every
|
|
504
472
|
render and not on `editing` alone: a row outside the window shows up a render or two
|
|
@@ -785,18 +753,7 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
|
|
|
785
753
|
least: a name cut with «…» asks for no width of its own. */
|
|
786
754
|
places[ci] === "title" && c.width === undefined
|
|
787
755
|
? "min-w-(--size-cell-title)"
|
|
788
|
-
: ""}`, children: c.header }, c.id))), onRemove === undefined ? null : (_jsx("td", { className: "w-0 border-b border-line-strong" }))] }) }), _jsxs("tbody", { ref: view.body.ref, ...(
|
|
789
|
-
? {
|
|
790
|
-
onDragOver: overRow,
|
|
791
|
-
onDrop: (event) => {
|
|
792
|
-
event.preventDefault();
|
|
793
|
-
if (dragged.current !== null && landing !== undefined)
|
|
794
|
-
land(dragged.current, landing);
|
|
795
|
-
dragged.current = null;
|
|
796
|
-
setLanding(undefined);
|
|
797
|
-
},
|
|
798
|
-
}
|
|
799
|
-
: {}), children: [rows.length === 0 ? (_jsx("tr", { children: _jsx("td", { colSpan: columns.length +
|
|
756
|
+
: ""}`, children: c.header }, c.id))), onRemove === undefined ? null : (_jsx("td", { className: "w-0 border-b border-line-strong" }))] }) }), _jsxs("tbody", { ref: view.body.ref, ...reorder.body, children: [rows.length === 0 ? (_jsx("tr", { children: _jsx("td", { colSpan: columns.length +
|
|
800
757
|
(onRemove === undefined ? 0 : 1) +
|
|
801
758
|
(reorderable ? 1 : 0), className: `text-meta text-muted italic ${cell}`, children: emptyText }) })) : (view.rows.flatMap((slot, at) => {
|
|
802
759
|
const entry = drawn[slot.index];
|
|
@@ -47,12 +47,18 @@ export declare function Th({ children, sortKey, sort, onSort, numeric, align, wi
|
|
|
47
47
|
* system scale instead of pinning a size in pixels. */
|
|
48
48
|
width?: number | string;
|
|
49
49
|
}): import("react").JSX.Element;
|
|
50
|
-
export declare function Tr({ children, onClick, selected, windowed, }: {
|
|
50
|
+
export declare function Tr({ children, onClick, selected, windowed, rowId, line, }: {
|
|
51
51
|
children: ReactNode;
|
|
52
52
|
onClick?: () => void;
|
|
53
53
|
selected?: boolean;
|
|
54
54
|
/** Set by a table that draws only the rows in view (`useRowWindow`). */
|
|
55
55
|
windowed?: WindowedRow;
|
|
56
|
+
/** The row's id as `data-row-id`: what a drag reads to know which row it is over
|
|
57
|
+
* (`useRowReorder`). */
|
|
58
|
+
rowId?: string;
|
|
59
|
+
/** A class every cell of the row carries — the line where a dragged row would land
|
|
60
|
+
* (`useRowReorder`'s `line`). On the cells: a separated table draws no border on a row. */
|
|
61
|
+
line?: string;
|
|
56
62
|
}): import("react").JSX.Element;
|
|
57
63
|
/**
|
|
58
64
|
* A row that opens its own detail underneath.
|
|
@@ -92,8 +98,11 @@ mono,
|
|
|
92
98
|
* number is of another kind»; tinting the cell says «look here», which is
|
|
93
99
|
* something else — and in a table of forty rows by six columns, colored text
|
|
94
100
|
* gets lost. */
|
|
95
|
-
tone, title, }: {
|
|
101
|
+
tone, title, fit, }: {
|
|
96
102
|
children: ReactNode;
|
|
103
|
+
/** As narrow as what it holds, without the side padding: a cell for a control — the grip
|
|
104
|
+
* that moves the row — and not for a value. */
|
|
105
|
+
fit?: boolean;
|
|
97
106
|
numeric?: boolean;
|
|
98
107
|
/** Pushes without saying it is a number. See the note on `Th`. */
|
|
99
108
|
align?: "left" | "right";
|
|
@@ -100,7 +100,10 @@ export function Th({ children, sortKey, sort, onSort, numeric = false, align, wi
|
|
|
100
100
|
/** The wash of a row lives on the cells, not on the `<tr>`. A background on the
|
|
101
101
|
* row paints edge to edge; on the cells the ends can round and the table's
|
|
102
102
|
* padding keeps the mark off the card. */
|
|
103
|
-
const RowMark = createContext({
|
|
103
|
+
const RowMark = createContext({
|
|
104
|
+
selected: false,
|
|
105
|
+
interactive: false,
|
|
106
|
+
});
|
|
104
107
|
const ROW_WASH = "group-hover/row:bg-ink/4";
|
|
105
108
|
const ROW_ON = "bg-primary/8";
|
|
106
109
|
/* The hover wash only where a click does something: on a read-only row it promised a click
|
|
@@ -108,8 +111,12 @@ const ROW_ON = "bg-primary/8";
|
|
|
108
111
|
function rowWash({ selected, interactive }) {
|
|
109
112
|
return selected ? ROW_ON : interactive ? ROW_WASH : "";
|
|
110
113
|
}
|
|
111
|
-
export function Tr({ children, onClick, selected = false, windowed, }) {
|
|
112
|
-
return (_jsx(RowMark.Provider, { value: {
|
|
114
|
+
export function Tr({ children, onClick, selected = false, windowed, rowId, line, }) {
|
|
115
|
+
return (_jsx(RowMark.Provider, { value: {
|
|
116
|
+
selected,
|
|
117
|
+
interactive: onClick !== undefined,
|
|
118
|
+
...(line === undefined ? {} : { line }),
|
|
119
|
+
}, children: _jsx("tr", { ...windowed, ...(rowId === undefined ? {} : { "data-row-id": rowId }), onClick: onClick, className: `group/row ${onClick === undefined ? "" : "cursor-pointer"}`, children: children }) }));
|
|
113
120
|
}
|
|
114
121
|
/**
|
|
115
122
|
* A row that opens its own detail underneath.
|
|
@@ -149,9 +156,9 @@ mono = false,
|
|
|
149
156
|
* number is of another kind»; tinting the cell says «look here», which is
|
|
150
157
|
* something else — and in a table of forty rows by six columns, colored text
|
|
151
158
|
* gets lost. */
|
|
152
|
-
tone, title, }) {
|
|
159
|
+
tone, title, fit = false, }) {
|
|
153
160
|
const mark = useContext(RowMark);
|
|
154
|
-
return (_jsx("td", { title: title, className: `border-b border-line
|
|
161
|
+
return (_jsx("td", { title: title, className: `border-b border-line py-1.5 text-meta text-ink first:rounded-l-control last:rounded-r-control ${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 }));
|
|
155
162
|
}
|
|
156
163
|
/** The selection checkbox, with its third state.
|
|
157
164
|
*
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type HTMLAttributes, type ReactNode } from "react";
|
|
2
|
+
/** What a table wires to let its rows be moved. */
|
|
3
|
+
export interface RowReorder {
|
|
4
|
+
/** Whether rows move: `onReorder` given and the table allows it (not grouped, not sorted). */
|
|
5
|
+
readonly on: boolean;
|
|
6
|
+
/** For the `tbody`: where a dragged row would land, and the drop. Empty when off. */
|
|
7
|
+
readonly body: Pick<HTMLAttributes<HTMLElement>, "onDragOver" | "onDrop">;
|
|
8
|
+
/** The landing line, for EVERY cell of row `id`: over it when the row lands in front of
|
|
9
|
+
* it, under it when it is the last one and the row goes to the end. */
|
|
10
|
+
line: (id: string) => string;
|
|
11
|
+
/** The grip of row `id`: the button, without its cell — each table draws its own. With
|
|
12
|
+
* `tabbable: false` it leaves the tab order (a grid that walks its rows with arrows). */
|
|
13
|
+
grip: (id: string, options?: {
|
|
14
|
+
tabbable?: boolean;
|
|
15
|
+
}) => ReactNode;
|
|
16
|
+
}
|
|
17
|
+
/** A grip at the start of each row that drags it, and Alt + ↑ / ↓ that moves it. `order` is
|
|
18
|
+
* the ids in the order they are drawn — every one, drawn by the row window or not. */
|
|
19
|
+
export declare function useRowReorder({ order, onReorder, enabled, }: {
|
|
20
|
+
order: readonly string[];
|
|
21
|
+
onReorder: ((id: string, before: string | null) => void) | undefined;
|
|
22
|
+
/** The table's own conditions: off while grouped (the piles decide the order) or sorted
|
|
23
|
+
* by a column (a row dropped would jump back to where the sort puts it). */
|
|
24
|
+
enabled?: boolean;
|
|
25
|
+
}): RowReorder;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { GripVertical } from "lucide-react";
|
|
5
|
+
import { useLayoutEffect, useRef, useState, } from "react";
|
|
6
|
+
/* Over the row it goes in front of; under the last one for the end. Cells only: a border on
|
|
7
|
+
a `tr` is not drawn in a separated table. */
|
|
8
|
+
const OVER = "border-t-2 border-t-primary";
|
|
9
|
+
const UNDER = "border-b-2 border-b-primary";
|
|
10
|
+
/** A grip at the start of each row that drags it, and Alt + ↑ / ↓ that moves it. `order` is
|
|
11
|
+
* the ids in the order they are drawn — every one, drawn by the row window or not. */
|
|
12
|
+
export function useRowReorder({ order, onReorder, enabled = true, }) {
|
|
13
|
+
const copy = useUiCopy();
|
|
14
|
+
const on = onReorder !== undefined && enabled;
|
|
15
|
+
/* A ref and not state: `dragover` can arrive before React re-renders after `dragstart`. */
|
|
16
|
+
const dragged = useRef(null);
|
|
17
|
+
/* `undefined` while nothing is dragged; `null` is «to the end». */
|
|
18
|
+
const [landing, setLanding] = useState(undefined);
|
|
19
|
+
/* The row moved by keyboard, to give its grip the focus back: React moves the row's node
|
|
20
|
+
and a focused node that is moved loses the focus. */
|
|
21
|
+
const moved = useRef(null);
|
|
22
|
+
const signature = order.join("\u0000");
|
|
23
|
+
useLayoutEffect(() => {
|
|
24
|
+
const want = moved.current;
|
|
25
|
+
/* Only once the order came back changed: `onReorder` may answer after a round trip. */
|
|
26
|
+
if (want === null || want.was === signature)
|
|
27
|
+
return;
|
|
28
|
+
moved.current = null;
|
|
29
|
+
const grip = want.body.querySelector(`tr[data-row-id="${CSS.escape(want.id)}"] [data-ui="table.grip"]`);
|
|
30
|
+
if (grip !== null && document.activeElement !== grip)
|
|
31
|
+
grip.focus();
|
|
32
|
+
}, [signature]);
|
|
33
|
+
const after = (id) => order[order.indexOf(id) + 1] ?? null;
|
|
34
|
+
const land = (id, before) => {
|
|
35
|
+
if (before === id || before === after(id))
|
|
36
|
+
return;
|
|
37
|
+
onReorder?.(id, before);
|
|
38
|
+
};
|
|
39
|
+
const end = () => {
|
|
40
|
+
dragged.current = null;
|
|
41
|
+
setLanding(undefined);
|
|
42
|
+
};
|
|
43
|
+
if (!on)
|
|
44
|
+
return { on, body: {}, line: () => "", grip: () => null };
|
|
45
|
+
const last = order[order.length - 1];
|
|
46
|
+
return {
|
|
47
|
+
on,
|
|
48
|
+
body: {
|
|
49
|
+
onDragOver: (event) => {
|
|
50
|
+
if (dragged.current === null)
|
|
51
|
+
return;
|
|
52
|
+
const tr = event.target.closest("tr[data-row-id]");
|
|
53
|
+
const id = tr?.dataset["rowId"];
|
|
54
|
+
/* Only the rows of `order`: a row being written, a pile, a spacer are not places. */
|
|
55
|
+
if (tr === null || id === undefined || !order.includes(id))
|
|
56
|
+
return;
|
|
57
|
+
event.preventDefault();
|
|
58
|
+
const box = tr.getBoundingClientRect();
|
|
59
|
+
setLanding(event.clientY < box.top + box.height / 2 ? id : after(id));
|
|
60
|
+
},
|
|
61
|
+
onDrop: (event) => {
|
|
62
|
+
event.preventDefault();
|
|
63
|
+
if (dragged.current !== null && landing !== undefined)
|
|
64
|
+
land(dragged.current, landing);
|
|
65
|
+
end();
|
|
66
|
+
},
|
|
67
|
+
},
|
|
68
|
+
line: (id) => (landing === id ? OVER : landing === null && id === last ? UNDER : ""),
|
|
69
|
+
grip: (id, options) => (_jsx("button", { type: "button", draggable: true, "data-ui": "table.grip", "aria-label": copy.editable.reorder, title: copy.editable.reorderHint, "aria-keyshortcuts": "Alt+ArrowUp Alt+ArrowDown", ...(options?.tabbable === false ? { tabIndex: -1 } : {}),
|
|
70
|
+
/* The row may open on a click; the grip is not the row. */
|
|
71
|
+
onClick: (event) => event.stopPropagation(), onKeyDown: (event) => {
|
|
72
|
+
if (!event.altKey || (event.key !== "ArrowUp" && event.key !== "ArrowDown"))
|
|
73
|
+
return;
|
|
74
|
+
event.preventDefault();
|
|
75
|
+
event.stopPropagation();
|
|
76
|
+
const at = order.indexOf(id);
|
|
77
|
+
const to = event.key === "ArrowUp"
|
|
78
|
+
? at > 0
|
|
79
|
+
? (order[at - 1] ?? null)
|
|
80
|
+
: undefined
|
|
81
|
+
: at < order.length - 1
|
|
82
|
+
? (order[at + 2] ?? null)
|
|
83
|
+
: undefined;
|
|
84
|
+
if (to === undefined)
|
|
85
|
+
return;
|
|
86
|
+
const body = event.currentTarget.closest("tbody");
|
|
87
|
+
if (body !== null)
|
|
88
|
+
moved.current = { id, was: signature, body };
|
|
89
|
+
land(id, to);
|
|
90
|
+
}, onDragStart: (event) => {
|
|
91
|
+
event.dataTransfer.setData("text/plain", id);
|
|
92
|
+
event.dataTransfer.effectAllowed = "move";
|
|
93
|
+
const tr = event.currentTarget.closest("tr");
|
|
94
|
+
if (tr !== null)
|
|
95
|
+
event.dataTransfer.setDragImage(tr, 16, 16);
|
|
96
|
+
dragged.current = id;
|
|
97
|
+
}, onDragEnd: end, className: "flex cursor-grab items-center rounded-control p-0.5 text-muted opacity-40 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 hover:text-ink focus-visible:opacity-100 focus-visible:outline-2 focus-visible:outline-primary active:cursor-grabbing", children: _jsx(GripVertical, { "aria-hidden": true, className: "size-(--size-icon-sm)", strokeWidth: 2 }) })),
|
|
98
|
+
};
|
|
99
|
+
}
|
package/dist/tokens.css
CHANGED
|
@@ -803,6 +803,30 @@
|
|
|
803
803
|
takes its opacity. Something set by Enter — the dropdown closes, the text clears — has to
|
|
804
804
|
be seen landing, or the eye looks for where the question went. Behind `motion-safe:`. */
|
|
805
805
|
--animate-chip-in: chip-in var(--duration-quick) var(--ease-out) both;
|
|
806
|
+
|
|
807
|
+
/* ---------------------------------------------------------------- *
|
|
808
|
+
* A SITE'S PAGE — the second register, and the only one that may decorate.
|
|
809
|
+
*
|
|
810
|
+
* Everything above is for a screen used eight hours a day, and there the rule holds.
|
|
811
|
+
* A public site's landing is the opposite case: it is read once, by someone who has not
|
|
812
|
+
* decided to stay, and an entrance that orders the eye — the headline first, then what
|
|
813
|
+
* it promises, then what to do — is part of what it says. So it gets its own clock,
|
|
814
|
+
* slower and declared here, and the components that use it (`Rise`, `Appear`,
|
|
815
|
+
* `DrawOnScroll`, `EnterOnScroll`, `Ribbon`) are for a site's pages. A view (`List`,
|
|
816
|
+
* `Record`) never uses them.
|
|
817
|
+
*
|
|
818
|
+
* entrance 800ms a line that rises, a block that appears, once per page
|
|
819
|
+
* step 120ms the gap between one and the next of the same entrance
|
|
820
|
+
*
|
|
821
|
+
* Every one of them animates only under `prefers-reduced-motion: no-preference`. The
|
|
822
|
+
* global rule at the end of this file shortens durations to 1ms, and that is NOT enough
|
|
823
|
+
* here: it leaves the delays of a staggered entrance in place, a scroll-driven animation
|
|
824
|
+
* converts its duration into a share of the scroll (1ms = all of it, so it keeps
|
|
825
|
+
* moving), and a ribbon cut to one iteration stops on its last frame — half its track
|
|
826
|
+
* away, showing the copy.
|
|
827
|
+
* ---------------------------------------------------------------- */
|
|
828
|
+
--duration-entrance: 800ms;
|
|
829
|
+
--duration-step: 120ms;
|
|
806
830
|
}
|
|
807
831
|
|
|
808
832
|
/* ==================================================================== *
|
|
@@ -941,6 +965,50 @@
|
|
|
941
965
|
}
|
|
942
966
|
}
|
|
943
967
|
|
|
968
|
+
/* A site's page (see «A SITE'S PAGE» in the motion tokens). Individual properties —
|
|
969
|
+
`translate`, `scale` — and not `transform`: Tailwind v4's `translate-*` and `scale-*` write
|
|
970
|
+
these, so an application's own utility on the same element and the entrance do not fight
|
|
971
|
+
over one shorthand. */
|
|
972
|
+
@keyframes rise {
|
|
973
|
+
from {
|
|
974
|
+
translate: 0 110%;
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
@keyframes appear {
|
|
979
|
+
from {
|
|
980
|
+
opacity: 0;
|
|
981
|
+
translate: 0 0.875rem;
|
|
982
|
+
}
|
|
983
|
+
}
|
|
984
|
+
|
|
985
|
+
@keyframes draw-x {
|
|
986
|
+
from {
|
|
987
|
+
scale: 0 1;
|
|
988
|
+
}
|
|
989
|
+
}
|
|
990
|
+
|
|
991
|
+
@keyframes draw-y {
|
|
992
|
+
from {
|
|
993
|
+
scale: 1 0;
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
@keyframes enter {
|
|
998
|
+
from {
|
|
999
|
+
opacity: 0;
|
|
1000
|
+
translate: 0 1.75rem;
|
|
1001
|
+
}
|
|
1002
|
+
}
|
|
1003
|
+
|
|
1004
|
+
/* One copy of the list away: the track holds `--ribbon-copies` equal copies, so this lands
|
|
1005
|
+
exactly where the first began. */
|
|
1006
|
+
@keyframes ribbon {
|
|
1007
|
+
to {
|
|
1008
|
+
translate: calc(-100% / var(--ribbon-copies, 2)) 0;
|
|
1009
|
+
}
|
|
1010
|
+
}
|
|
1011
|
+
|
|
944
1012
|
/* The segment is two fifths of its track: from just off the left edge (-100 % of
|
|
945
1013
|
itself) to just off the right one (250 % of itself = the track's width). */
|
|
946
1014
|
@keyframes progress-sweep {
|
|
@@ -1694,6 +1762,120 @@
|
|
|
1694
1762
|
transform: rotate(180deg);
|
|
1695
1763
|
}
|
|
1696
1764
|
|
|
1765
|
+
/* ==================================================================== *
|
|
1766
|
+
* A SITE'S MOTION — `Rise`, `Appear`, `DrawOnScroll`, `EnterOnScroll`, `Ribbon`.
|
|
1767
|
+
*
|
|
1768
|
+
* Utilities and not only components, so a site can put them on an element of its own (a
|
|
1769
|
+
* timeline's line drawn absolutely, a rule inside a heading). Each one is the final state
|
|
1770
|
+
* first — what the server sends and what a browser without the feature, or a person who
|
|
1771
|
+
* asked for less motion, sees — and the motion is added on top, only under
|
|
1772
|
+
* `no-preference` (why the global rule is not enough: «A SITE'S PAGE», in the tokens).
|
|
1773
|
+
* The order of one entrance is `--motion-step` (0, 1, 2…): one clock for the lines of a
|
|
1774
|
+
* headline and for what follows them.
|
|
1775
|
+
* ==================================================================== */
|
|
1776
|
+
|
|
1777
|
+
/* A line of a headline that rises from behind its own lower edge. The mask is the line box,
|
|
1778
|
+
widened by 0.12em above and below — padding given back with a negative margin, so the
|
|
1779
|
+
layout does not move — or a tight leading cuts the accent of «Á» and the tail of «g». */
|
|
1780
|
+
@utility rise-line {
|
|
1781
|
+
display: block;
|
|
1782
|
+
overflow: clip;
|
|
1783
|
+
padding-block: 0.12em;
|
|
1784
|
+
margin-block: -0.12em;
|
|
1785
|
+
& > * {
|
|
1786
|
+
display: block;
|
|
1787
|
+
}
|
|
1788
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
1789
|
+
& > * {
|
|
1790
|
+
animation: rise var(--duration-entrance) var(--ease-out) both;
|
|
1791
|
+
animation-delay: calc((var(--motion-step, 0) + 1) * var(--duration-step));
|
|
1792
|
+
}
|
|
1793
|
+
}
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/* What follows the headline, on the same clock. */
|
|
1797
|
+
@utility appear-in {
|
|
1798
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
1799
|
+
animation: appear var(--duration-entrance) var(--ease-out) both;
|
|
1800
|
+
animation-delay: calc((var(--motion-step, 0) + 1) * var(--duration-step));
|
|
1801
|
+
}
|
|
1802
|
+
}
|
|
1803
|
+
|
|
1804
|
+
/* Drawn by the scroll itself. `animation-timeline` goes AFTER the shorthand: `animation`
|
|
1805
|
+
resets it. Without scroll-driven animations the line is simply there.
|
|
1806
|
+
The ranges end where every element can get to, even in the last screen of a page: `entry
|
|
1807
|
+
100%` is its lower edge inside the window, which the page's end always reaches. A range
|
|
1808
|
+
that ends at `cover 45%` leaves the last section half drawn — or half transparent — for
|
|
1809
|
+
good. A thin rule is the exception: its entry lasts its own 4px, so it draws over the
|
|
1810
|
+
first quarter of its way up, and in the last screen of a page it is drawn as far as the
|
|
1811
|
+
scroll goes. */
|
|
1812
|
+
@utility draw-on-scroll-x {
|
|
1813
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
1814
|
+
@supports (animation-timeline: view()) {
|
|
1815
|
+
transform-origin: left center;
|
|
1816
|
+
animation: draw-x linear both;
|
|
1817
|
+
animation-timeline: view();
|
|
1818
|
+
animation-range: cover 0% cover 25%;
|
|
1819
|
+
}
|
|
1820
|
+
}
|
|
1821
|
+
}
|
|
1822
|
+
|
|
1823
|
+
@utility draw-on-scroll-y {
|
|
1824
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
1825
|
+
@supports (animation-timeline: view()) {
|
|
1826
|
+
transform-origin: center top;
|
|
1827
|
+
animation: draw-y linear both;
|
|
1828
|
+
animation-timeline: view();
|
|
1829
|
+
animation-range: entry 0% entry 100%;
|
|
1830
|
+
}
|
|
1831
|
+
}
|
|
1832
|
+
}
|
|
1833
|
+
|
|
1834
|
+
@utility enter-on-scroll {
|
|
1835
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
1836
|
+
@supports (animation-timeline: view()) {
|
|
1837
|
+
animation: enter linear both;
|
|
1838
|
+
animation-timeline: view();
|
|
1839
|
+
animation-range: entry 0% entry 100%;
|
|
1840
|
+
}
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
|
|
1844
|
+
/* The ribbon's track. It moves only once `Ribbon` has measured it (`data-moving` on the
|
|
1845
|
+
root, set in the browser and never under reduced motion), and it stops under the pointer,
|
|
1846
|
+
with the focus inside, and with its pause button. */
|
|
1847
|
+
@utility ribbon-track {
|
|
1848
|
+
display: flex;
|
|
1849
|
+
width: max-content;
|
|
1850
|
+
@media (prefers-reduced-motion: no-preference) {
|
|
1851
|
+
:where([data-ui="ribbon"][data-moving]) & {
|
|
1852
|
+
animation: ribbon var(--ribbon-duration, 40s) linear infinite;
|
|
1853
|
+
}
|
|
1854
|
+
:where([data-ui="ribbon"][data-direction="right"]) & {
|
|
1855
|
+
animation-direction: reverse;
|
|
1856
|
+
}
|
|
1857
|
+
:where(
|
|
1858
|
+
[data-ui="ribbon"]:hover,
|
|
1859
|
+
[data-ui="ribbon"]:focus-within,
|
|
1860
|
+
[data-ui="ribbon"][data-paused]
|
|
1861
|
+
)
|
|
1862
|
+
& {
|
|
1863
|
+
animation-play-state: paused;
|
|
1864
|
+
}
|
|
1865
|
+
}
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
/* The edges fade instead of cutting a card in two: what leaves is seen leaving. */
|
|
1869
|
+
@utility ribbon-fade {
|
|
1870
|
+
mask-image: linear-gradient(
|
|
1871
|
+
to right,
|
|
1872
|
+
transparent,
|
|
1873
|
+
black calc(var(--spacing) * 16),
|
|
1874
|
+
black calc(100% - var(--spacing) * 16),
|
|
1875
|
+
transparent
|
|
1876
|
+
);
|
|
1877
|
+
}
|
|
1878
|
+
|
|
1697
1879
|
/* ==================================================================== *
|
|
1698
1880
|
* RICH TEXT — the HTML of a note, a description, an email body.
|
|
1699
1881
|
*
|
|
@@ -47,6 +47,11 @@ type TableProps<T extends object> = {
|
|
|
47
47
|
/** Write a new record as one more row of the table (Odoo's editable
|
|
48
48
|
* list). See `DataTable`'s header. */
|
|
49
49
|
create?: DataTableCreate<T>;
|
|
50
|
+
/** The records are in an order a person sets by hand (a `sequence`): a grip at the start of
|
|
51
|
+
* each row of the table drags it, Alt + ↑ / ↓ moves it. `before` is the row it lands in
|
|
52
|
+
* front of, `null` the end. Off while grouped or sorted by a column, and in the phone's
|
|
53
|
+
* rows — see `DataTable`'s `onReorder`. */
|
|
54
|
+
onReorder?: (id: string, before: string | null) => void;
|
|
50
55
|
};
|
|
51
56
|
/** The board. Without `card`, the card comes from what `List.Rows` already says: the
|
|
52
57
|
* name, the `meta` and the chips. Writing it anyway is declaring that THIS list
|
package/dist/views/list/List.js
CHANGED
|
@@ -151,6 +151,10 @@ export function List({ items, keyOf, embedded, surface, group, selection: select
|
|
|
151
151
|
? {}
|
|
152
152
|
: { rowActions: table.rowActions }),
|
|
153
153
|
...(table.create === undefined || readOnly ? {} : { create: table.create }),
|
|
154
|
+
/* Read-only: moving a record is writing its position. */
|
|
155
|
+
...(table.onReorder === undefined || readOnly
|
|
156
|
+
? {}
|
|
157
|
+
: { onReorder: table.onReorder }),
|
|
154
158
|
...(table.visibleColumnIds === undefined
|
|
155
159
|
? {}
|
|
156
160
|
: { visibleColumnIds: table.visibleColumnIds }),
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ListViewProps } from "./types.js";
|
|
2
|
-
export declare function ListView<T extends object>({ items, keyOf, identity, crumbs, embedded, surface: requestedSurface, metrics, filters, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, tiles, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested, presents, onPresentChange, sort, onSortChange, sortable, totals, rowActions, create, group, selection, onOpen, onPeek, openTargets, onOpenIn, rowClick, onChoose, state, filtered, empty, children, }: ListViewProps<T>): import("react").JSX.Element;
|
|
2
|
+
export declare function ListView<T extends object>({ items, keyOf, identity, crumbs, embedded, surface: requestedSurface, metrics, filters, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, tiles, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested, presents, onPresentChange, sort, onSortChange, sortable, totals, rowActions, onReorder, create, group, selection, onOpen, onPeek, openTargets, onOpenIn, rowClick, onChoose, state, filtered, empty, children, }: ListViewProps<T>): import("react").JSX.Element;
|
|
3
3
|
/** What a list offers when it fails and can be retried. */
|
|
4
4
|
export declare function RetryAction({ onRetry }: {
|
|
5
5
|
onRetry: () => void;
|
|
@@ -90,7 +90,7 @@ const PRESENT_ICONS = [
|
|
|
90
90
|
{ id: "gantt", icon: ChartGantt },
|
|
91
91
|
{ id: "timeline", icon: CalendarRange },
|
|
92
92
|
];
|
|
93
|
-
export function ListView({ items, keyOf, identity, crumbs, embedded = false, surface: requestedSurface, metrics, filters, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, tiles, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested = "rows", presents, onPresentChange, sort, onSortChange, sortable, totals = false, rowActions, create, group, selection, onOpen, onPeek, openTargets, onOpenIn, rowClick = "peek", onChoose, state, filtered = false, empty, children, }) {
|
|
93
|
+
export function ListView({ items, keyOf, identity, crumbs, embedded = false, surface: requestedSurface, metrics, filters, search, pagination, views, actions: written, dock, row, rowHeader, columns, visibleColumnIds, onVisibleColumnIdsChange, card, tiles, boardStages, calendar, gantt, timeline, sheet, report, pivot, chart, faces, present: requested = "rows", presents, onPresentChange, sort, onSortChange, sortable, totals = false, rowActions, onReorder, create, group, selection, onOpen, onPeek, openTargets, onOpenIn, rowClick = "peek", onChoose, state, filtered = false, empty, children, }) {
|
|
94
94
|
const wide = useMemo(() => [
|
|
95
95
|
...WIDE_PRESENTS,
|
|
96
96
|
...(faces ?? []).filter((f) => f.wide === true).map((f) => f.id),
|
|
@@ -423,7 +423,7 @@ export function ListView({ items, keyOf, identity, crumbs, embedded = false, sur
|
|
|
423
423
|
...(onOpen === undefined || choosing ? {} : { open: onOpen }),
|
|
424
424
|
})) : present === "table" && shownColumns !== undefined ? (
|
|
425
425
|
/* The table receives EVERYTHING that belongs to the set: see `TablePresentation`. */
|
|
426
|
-
_jsx(TablePresentation, { items: items, columns: shownColumns, keyOf: keyOf, levels: groupLevels, ...(sort === undefined ? {} : { sort }), ...(onSortChange === undefined ? {} : { onSortChange }), ...(group === undefined ? {} : { group }), ...(selection === undefined ? {} : { selection }), totals: totals, ...(rowActions === undefined ? {} : { rowActions }), ...(create === undefined ? {} : { create }), ...(onPeek === undefined || choosing ? {} : { onPeek }), ...(onOpen === undefined || choosing ? {} : { onOpen }), ...(openTargets === undefined || onOpenIn === undefined || choosing
|
|
426
|
+
_jsx(TablePresentation, { items: items, columns: shownColumns, keyOf: keyOf, levels: groupLevels, ...(sort === undefined ? {} : { sort }), ...(onSortChange === undefined ? {} : { onSortChange }), ...(group === undefined ? {} : { group }), ...(selection === undefined ? {} : { selection }), totals: totals, ...(rowActions === undefined ? {} : { rowActions }), ...(onReorder === undefined || choosing ? {} : { onReorder }), ...(create === undefined ? {} : { create }), ...(onPeek === undefined || choosing ? {} : { onPeek }), ...(onOpen === undefined || choosing ? {} : { onOpen }), ...(openTargets === undefined || onOpenIn === undefined || choosing
|
|
427
427
|
? {}
|
|
428
428
|
: { openTargets, onOpenIn }), ...(choosing ? { onChoose } : {}), rowClick: rowClick })) : present === "sheet" && sheetSpec !== undefined ? (
|
|
429
429
|
/* The sheet receives the set by INDEX and not an already built matrix: see `SheetPresentation`. */
|
|
@@ -15,14 +15,14 @@ type TableProps<T extends object> = {
|
|
|
15
15
|
levels: NonNullable<Parameters<typeof DataTable<T>>[0]["levels"]>;
|
|
16
16
|
group?: ListGroup<T>;
|
|
17
17
|
totals: boolean;
|
|
18
|
-
} & Pick<ListViewProps<T>, "sort" | "onSortChange" | "selection" | "rowActions" | "create" | "onPeek" | "onOpen" | "openTargets" | "onOpenIn"> & {
|
|
18
|
+
} & Pick<ListViewProps<T>, "sort" | "onSortChange" | "selection" | "rowActions" | "create" | "onReorder" | "onPeek" | "onOpen" | "openTargets" | "onOpenIn"> & {
|
|
19
19
|
rowClick?: "peek" | "open";
|
|
20
20
|
onChoose?: (item: T) => void;
|
|
21
21
|
};
|
|
22
22
|
/** The table receives EVERYTHING that belongs to the set —sorting, selection, grouping,
|
|
23
23
|
* which columns are on screen— and not a trimmed down version: that was exactly the trap
|
|
24
24
|
* this archetype exists to avoid, that switching presentation loses capabilities. */
|
|
25
|
-
export declare function TablePresentation<T extends object>({ items, columns, keyOf, levels, group, totals, sort, onSortChange, selection, rowActions, create, onPeek, onOpen, openTargets, onOpenIn, rowClick, onChoose, }: TableProps<T>): import("react").JSX.Element;
|
|
25
|
+
export declare function TablePresentation<T extends object>({ items, columns, keyOf, levels, group, totals, sort, onSortChange, selection, rowActions, create, onReorder, onPeek, onOpen, openTargets, onOpenIn, rowClick, onChoose, }: TableProps<T>): import("react").JSX.Element;
|
|
26
26
|
type SheetProps<T extends object> = {
|
|
27
27
|
spec: ListSheet<T>;
|
|
28
28
|
/** The flattened bands and rows when the set is grouped; `null` when it is not. */
|
|
@@ -15,7 +15,7 @@ const OPEN_ICON = {
|
|
|
15
15
|
/** The table receives EVERYTHING that belongs to the set —sorting, selection, grouping,
|
|
16
16
|
* which columns are on screen— and not a trimmed down version: that was exactly the trap
|
|
17
17
|
* this archetype exists to avoid, that switching presentation loses capabilities. */
|
|
18
|
-
export function TablePresentation({ items, columns, keyOf, levels, group, totals, sort, onSortChange, selection, rowActions, create, onPeek, onOpen, openTargets, onOpenIn, rowClick = "peek", onChoose, }) {
|
|
18
|
+
export function TablePresentation({ items, columns, keyOf, levels, group, totals, sort, onSortChange, selection, rowActions, create, onReorder, onPeek, onOpen, openTargets, onOpenIn, rowClick = "peek", onChoose, }) {
|
|
19
19
|
const copy = useUiCopy();
|
|
20
20
|
const press = onChoose ?? (rowClick === "open" ? (onOpen ?? onPeek) : (onPeek ?? onOpen));
|
|
21
21
|
/* The row's ways in go FIRST among its actions, so they are always the inline ones and
|
|
@@ -86,7 +86,7 @@ export function TablePresentation({ items, columns, keyOf, levels, group, totals
|
|
|
86
86
|
selection.toggle(id);
|
|
87
87
|
}
|
|
88
88
|
},
|
|
89
|
-
}), ...(totals ? { totals: true } : {}), ...(withOpeners === undefined ? {} : { rowActions: withOpeners }), ...(create === undefined ? {} : { create }), ...(press === undefined ? {} : { onRowClick: press }) }));
|
|
89
|
+
}), ...(totals ? { totals: true } : {}), ...(withOpeners === undefined ? {} : { rowActions: withOpeners }), ...(create === undefined ? {} : { create }), ...(onReorder === undefined ? {} : { onReorder }), ...(press === undefined ? {} : { onRowClick: press }) }));
|
|
90
90
|
}
|
|
91
91
|
/** The sheet receives the set by INDEX and not a ready-made matrix: `SheetTable` is
|
|
92
92
|
* virtualized precisely so as not to materialize a million rows, and handing it copies
|
|
@@ -380,6 +380,11 @@ export type ListViewProps<T extends object> = {
|
|
|
380
380
|
* columns that declare `input` get a control in that row. See `DataTable`'s header.
|
|
381
381
|
* While a record is being written the table shows even if the set is empty. */
|
|
382
382
|
create?: DataTableCreate<T>;
|
|
383
|
+
/** The records are in an order a person sets by hand (a `sequence`): a grip at the start of
|
|
384
|
+
* each row of the table drags it, Alt + ↑ / ↓ moves it. `before` is the row it lands in
|
|
385
|
+
* front of, `null` the end. Off while grouped or sorted by a column, and in the phone's
|
|
386
|
+
* rows — see `DataTable`'s `onReorder`. */
|
|
387
|
+
onReorder?: (id: string, before: string | null) => void;
|
|
383
388
|
/** The board presentation: the card of one record, with what a press on it does. */
|
|
384
389
|
card?: (item: T, ways: CardWays) => ReactNode;
|
|
385
390
|
/** The board by stages: one column each, cards moved between them. */
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sincpro/web-ui",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.18.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",
|