@sincpro/web-ui 2.8.0 → 2.10.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 +152 -3
- package/dist/components/activity/Activity.js +3 -2
- package/dist/components/board/Board.d.ts +2 -1
- package/dist/components/board/Board.js +17 -1
- package/dist/components/form/Form.js +12 -3
- package/dist/components/form/FormIndex.d.ts +5 -1
- package/dist/components/form/FormIndex.js +71 -23
- package/dist/components/form/Sheet.js +22 -4
- package/dist/components/listing/ListingBar.d.ts +25 -1
- package/dist/components/listing/ListingBar.js +43 -14
- package/dist/components/listing/Pagination.d.ts +4 -1
- package/dist/components/listing/Pagination.js +19 -6
- package/dist/components/listing/modelCells.js +1 -9
- package/dist/components/record/ActionDock.d.ts +58 -0
- package/dist/components/record/ActionDock.js +69 -0
- package/dist/components/record/Breadcrumb.d.ts +3 -1
- package/dist/components/record/Breadcrumb.js +13 -5
- package/dist/components/record/DirtyActions.js +11 -1
- package/dist/components/record/Pager.d.ts +12 -10
- package/dist/components/record/Pager.js +39 -6
- package/dist/components/record/RecordHeader.d.ts +13 -1
- package/dist/components/record/RecordHeader.js +70 -25
- package/dist/components/record/SmartButtons.js +2 -2
- package/dist/components/record/StatusBar.d.ts +68 -1
- package/dist/components/record/StatusBar.js +218 -48
- package/dist/components/record/dock.d.ts +56 -0
- package/dist/components/record/dock.js +58 -0
- package/dist/components/record/index.d.ts +3 -1
- package/dist/components/record/index.js +5 -1
- package/dist/foundations/copy.d.ts +9 -0
- package/dist/foundations/copy.es.js +10 -1
- package/dist/foundations/copy.js +5 -0
- package/dist/foundations/form.d.ts +10 -1
- package/dist/foundations/grouping.d.ts +9 -0
- package/dist/foundations/index.d.ts +3 -1
- package/dist/foundations/index.js +8 -2
- package/dist/foundations/keys.d.ts +34 -0
- package/dist/foundations/keys.js +99 -0
- package/dist/foundations/shortcut.d.ts +17 -1
- package/dist/foundations/shortcut.js +57 -1
- package/dist/foundations/viewStyle.d.ts +8 -0
- package/dist/foundations/viewStyle.js +12 -0
- package/dist/primitives/choice/Switch.d.ts +4 -1
- package/dist/primitives/choice/Switch.js +2 -2
- package/dist/primitives/menu/Menu.d.ts +3 -0
- package/dist/primitives/menu/Menu.js +7 -1
- package/dist/primitives/table/DataTable.d.ts +29 -0
- package/dist/primitives/table/DataTable.js +84 -13
- package/dist/primitives/table/EditableTable.js +7 -2
- package/dist/primitives/table/RowActions.d.ts +5 -0
- package/dist/primitives/table/RowActions.js +27 -3
- package/dist/primitives/table/SheetTable.d.ts +3 -0
- package/dist/primitives/table/SheetTable.js +15 -2
- package/dist/primitives/table/index.d.ts +1 -1
- package/dist/primitives/value/Value.d.ts +5 -1
- package/dist/primitives/value/Value.js +9 -3
- package/dist/primitives/value/YesNo.d.ts +22 -0
- package/dist/primitives/value/YesNo.js +16 -0
- package/dist/primitives/value/index.d.ts +1 -0
- package/dist/primitives/value/index.js +1 -0
- package/dist/tokens.css +35 -2
- package/dist/views/list/List.d.ts +7 -2
- package/dist/views/list/List.js +12 -4
- package/dist/views/list/ListView.d.ts +1 -1
- package/dist/views/list/ListView.js +112 -17
- package/dist/views/list/derive.d.ts +1 -1
- package/dist/views/list/derive.js +45 -9
- package/dist/views/list/presentations.d.ts +2 -2
- package/dist/views/list/presentations.js +35 -3
- package/dist/views/list/types.d.ts +43 -0
- package/dist/views/list/useReachBottom.d.ts +15 -0
- package/dist/views/list/useReachBottom.js +55 -0
- package/dist/views/record/Record.d.ts +16 -2
- package/dist/views/record/Record.js +30 -7
- package/package.json +1 -1
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
4
4
|
import { byDensity, useDensity } from "../../foundations/density.js";
|
|
5
5
|
import { SurfaceProvider, useSurface } from "../../foundations/surface.js";
|
|
6
6
|
import { Line } from "../../primitives/block/Line.js";
|
|
7
|
+
import { Hint } from "../../primitives/hint/Hint.js";
|
|
7
8
|
import { X } from "lucide-react";
|
|
8
9
|
/** THE BAR — two rows, two questions.
|
|
9
10
|
*
|
|
@@ -39,6 +40,26 @@ import { X } from "lucide-react";
|
|
|
39
40
|
* The actions on the left do NOT go away: «Nuevo» stays available with three
|
|
40
41
|
* rows selected, because selecting is not entering a mode.
|
|
41
42
|
*
|
|
43
|
+
* ── The modern style: the trail is the heading ──────────────────────
|
|
44
|
+
*
|
|
45
|
+
* ┌──────────────────────────────────────────────────────────────────┐
|
|
46
|
+
* │ Ventas › Andina › Pedidos ( 1–12 / 12 ‹ › ) │
|
|
47
|
+
* │ what it is made of 🔍 search… [sort][cols] [▤▦] │
|
|
48
|
+
* └──────────────────────────────────────────────────────────────────┘
|
|
49
|
+
* ( Pedidos │ Importar · Exportar ▾ · + Nueva cotización ) ← floats
|
|
50
|
+
*
|
|
51
|
+
* As a record in the modern style, WHERE I AM is the page's heading: the trail at the
|
|
52
|
+
* title's size (`Breadcrumb size="lg"`), its last crumb the list's name — so the title is
|
|
53
|
+
* not said twice —, and the page range at the other end, as the record's pager pill. Its
|
|
54
|
+
* counters are not here: beside the trail they read as more crumbs; the list draws them as
|
|
55
|
+
* mini stats under the bar (`List.Metrics`). The second row is how I look at the set: what
|
|
56
|
+
* it is made of (the description), the search centred, sort, columns and the faces. The
|
|
57
|
+
* list's actions float at the bottom of the screen in a pill named by the list
|
|
58
|
+
* (`List.Dock`), which turns into what is done to the chosen rows while some are chosen;
|
|
59
|
+
* given `placement="bar"`, or drawn by hand, they take the start of the second row and the
|
|
60
|
+
* description goes on demand (`Hint`) beside the heading. Without crumbs the title is the
|
|
61
|
+
* heading. Compact keeps the one bar below.
|
|
62
|
+
*
|
|
42
63
|
* ── Inside a record it is ONE line (`inline`) ────────────────────────
|
|
43
64
|
*
|
|
44
65
|
* ┌───────────────────────────────────────────────────────────────┐
|
|
@@ -70,7 +91,7 @@ import { X } from "lucide-react";
|
|
|
70
91
|
* The count is a live region: typing in the search changes it, and somebody
|
|
71
92
|
* who cannot see the rows thin out hears how many are left. With
|
|
72
93
|
* `pagination` the page range replaces it — it already says how many. */
|
|
73
|
-
export function ListingBar({ actions, title, description, counters, selection, search, pagination, views, crumbs, surface, inline = false, count, }) {
|
|
94
|
+
export function ListingBar({ actions, title, description, counters, selection, search, pagination, views, crumbs, surface, inline = false, count, look = "traditional", }) {
|
|
74
95
|
const selecting = selection !== undefined && selection.count > 0;
|
|
75
96
|
const d = useDensity();
|
|
76
97
|
const copy = useUiCopy();
|
|
@@ -116,22 +137,30 @@ export function ListingBar({ actions, title, description, counters, selection, s
|
|
|
116
137
|
just outside this box: pressing the funnel opened a panel nobody
|
|
117
138
|
saw. `clip` is the only value that leaves the other axis `visible`. */
|
|
118
139
|
center: center === null ? null : (_jsx("div", { className: "flex w-full min-w-0 items-center overflow-x-clip overflow-y-visible", children: center })), end: pagination }));
|
|
140
|
+
/* The list's name. No `truncate`: it may wrap onto two lines — a list that cannot be
|
|
141
|
+
named in full is indistinguishable from the one next to it. `title` and semibold: it is
|
|
142
|
+
the entry point of the screen; at `lead` it was smaller than the metrics under it, so the
|
|
143
|
+
largest thing on a list page was a number (measured 1.46:1 over the body, below the ~1.5
|
|
144
|
+
an eye needs to find where to start). */
|
|
145
|
+
const heading = title === undefined ? null : (_jsx("h2", { className: `text-title leading-tight font-semibold ${isChrome ? "text-chrome-ink" : "text-ink"}`, children: title }));
|
|
146
|
+
/* What the list is made of: its counters and its sentence. Under the title in the
|
|
147
|
+
traditional bar; at the start of the controls' row in the modern one. */
|
|
148
|
+
const about = description === undefined && counters === undefined ? null : (_jsxs("div", { className: "flex min-w-0 flex-wrap items-baseline gap-x-3 gap-y-0.5", children: [counters?.map((c) => (_jsxs("span", { className: "flex items-baseline gap-1", children: [_jsx("span", { className: `text-meta font-medium tabular-nums ${isChrome ? "text-chrome-ink" : "text-ink"}`, children: typeof c.value === "number" ? c.value.toLocaleString(copy.locale) : c.value }), _jsx("span", { className: `text-micro ${isChrome ? "text-chrome-muted" : "text-muted"}`, children: c.label })] }, c.label))), description === undefined ? null : (_jsx("span", { className: `min-w-0 text-micro ${isChrome ? "text-chrome-muted" : "text-muted"}`, children: description }))] }));
|
|
119
149
|
const bottomRow = actions === undefined && !withIdentity && views === undefined ? null : (
|
|
120
150
|
/* On a narrow list (a phone, a drawer) the name and its counters take the whole first
|
|
121
151
|
line and the action and the controls go below: squeezed between them, the
|
|
122
152
|
description wrapped one word per line. */
|
|
123
|
-
_jsxs("div", { className: `flex min-w-0 flex-wrap items-center gap-y-2 ${byDensity(d, "gap-x-4", "gap-x-2")}`, children: [actions === undefined ? null : (_jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: actions })), !withIdentity ? null : (_jsxs("div", { className: "flex min-w-0 flex-1 flex-col @max-2xl:order-first @max-2xl:basis-full", children: [
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
const bar = (_jsxs("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-2", "gap-1.5")}`, children: [!isChrome && bottomRow !== null ? (_jsx("div", { className: "border-b border-line pb-2", children: topRow })) : (topRow), bottomRow] }));
|
|
153
|
+
_jsxs("div", { className: `flex min-w-0 flex-wrap items-center gap-y-2 ${byDensity(d, "gap-x-4", "gap-x-2")}`, children: [actions === undefined ? null : (_jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: actions })), !withIdentity ? null : (_jsxs("div", { className: "flex min-w-0 flex-1 flex-col @max-2xl:order-first @max-2xl:basis-full", children: [heading, about === null ? null : _jsx("div", { className: "mt-0.5", children: about })] })), views === undefined ? null : (_jsx("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: views }))] }));
|
|
154
|
+
/* THE MODERN BAR — see «The modern style» above. Only with room for an identity:
|
|
155
|
+
compact (a drawer, a phone) keeps the one bar. */
|
|
156
|
+
const modern = look === "modern" && withIdentity;
|
|
157
|
+
const modernBar = !modern ? null : (_jsxs("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-2", "gap-1.5")}`, children: [_jsx(Line, { start: _jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1", children: [crumbs === undefined ? (heading) : (_jsxs(_Fragment, { children: [title === undefined ? null : _jsx("h2", { className: "sr-only", children: title }), crumbs] })), description === undefined || actions === undefined ? null : (_jsx(Hint, { children: description }))] }), end: pagination }), _jsx(Line, { asks: "var(--container-crumb)", centerAsks: center === null ? "auto" : "var(--container-search)", gap: byDensity(d, "gap-x-4 gap-y-2", "gap-x-2 gap-y-1.5"), start: actions !== undefined ? (_jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: actions })) : description === undefined ? null : (
|
|
158
|
+
/* What the list is made of, beside the search — the side the actions leave when
|
|
159
|
+
they float. Not the title: the trail's last crumb already says it. */
|
|
160
|
+
_jsx("p", { className: `line-clamp-2 min-w-0 text-micro ${isChrome ? "text-chrome-muted" : "text-muted"}`, children: description })), center: center === null ? null : (
|
|
161
|
+
/* `overflow-x-clip`: the same reason as the traditional top row's. */
|
|
162
|
+
_jsx("div", { className: "flex w-full min-w-0 items-center overflow-x-clip overflow-y-visible", children: center })), end: views === undefined ? null : (_jsx("div", { className: "ml-auto flex shrink-0 items-center gap-2", children: views })) })] }));
|
|
163
|
+
const bar = modernBar ?? (_jsxs("div", { className: `flex min-w-0 flex-col ${byDensity(d, "gap-2", "gap-1.5")}`, children: [!isChrome && bottomRow !== null ? (_jsx("div", { className: "border-b border-line pb-2", children: topRow })) : (topRow), bottomRow] }));
|
|
135
164
|
/* On the canvas the bar is a light control band: white, a hairline below, the same
|
|
136
165
|
padding as the dark one — a list inside an application whose bar is already dark keeps
|
|
137
166
|
ONE dark band per screen. Without its own band the bar sat flush on the page and its
|
|
@@ -22,7 +22,7 @@ import type { Surface } from "../../foundations/types.js";
|
|
|
22
22
|
* once. In a tool where somebody compares a hundred and eighty invoices,
|
|
23
23
|
* leaving it fixed at 25 forces paginating over something that is not a
|
|
24
24
|
* product decision. */
|
|
25
|
-
export declare function Pagination({ from, to, total, pageSize, pageSizes, onPageSizeChange, onPrev, onNext, surface, }: {
|
|
25
|
+
export declare function Pagination({ from, to, total, pageSize, pageSizes, onPageSizeChange, onPrev, onNext, surface, look: ownLook, }: {
|
|
26
26
|
from: number;
|
|
27
27
|
to: number;
|
|
28
28
|
total: number;
|
|
@@ -33,4 +33,7 @@ export declare function Pagination({ from, to, total, pageSize, pageSizes, onPag
|
|
|
33
33
|
onNext?: () => void;
|
|
34
34
|
/** By default it inherits it from the surface that wraps it. */
|
|
35
35
|
surface?: Surface;
|
|
36
|
+
/** `plain`: quiet, the range and two arrows. `pill`: the position stands out — the record's
|
|
37
|
+
* pager's translucent primary pill. Absent, the view style's: `modern` → `pill`. */
|
|
38
|
+
look?: "plain" | "pill";
|
|
36
39
|
}): import("react").JSX.Element;
|
|
@@ -4,6 +4,7 @@ import { PAGE_SIZES } from "./pages.js";
|
|
|
4
4
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
5
5
|
import { byDensity, useDensity } from "../../foundations/density.js";
|
|
6
6
|
import { bySurface, useSurface } from "../../foundations/surface.js";
|
|
7
|
+
import { useViewStyle } from "../../foundations/viewStyle.js";
|
|
7
8
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
8
9
|
import { useId, useState } from "react";
|
|
9
10
|
/* ---------------------------------------------------------------- *
|
|
@@ -32,16 +33,26 @@ import { useId, useState } from "react";
|
|
|
32
33
|
* once. In a tool where somebody compares a hundred and eighty invoices,
|
|
33
34
|
* leaving it fixed at 25 forces paginating over something that is not a
|
|
34
35
|
* product decision. */
|
|
35
|
-
export function Pagination({ from, to, total, pageSize, pageSizes = PAGE_SIZES, onPageSizeChange, onPrev, onNext, surface, }) {
|
|
36
|
+
export function Pagination({ from, to, total, pageSize, pageSizes = PAGE_SIZES, onPageSizeChange, onPrev, onNext, surface, look: ownLook, }) {
|
|
36
37
|
const d = useDensity();
|
|
37
38
|
const copy = useUiCopy();
|
|
38
39
|
const activeSurface = useSurface(surface);
|
|
39
40
|
const [editing, setEditing] = useState(false);
|
|
40
41
|
const [draft, setDraft] = useState("");
|
|
41
42
|
const listId = useId();
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
43
|
+
/* The modern style's position is the record's pager's: one translucent primary pill, so a
|
|
44
|
+
list and a record say «where I am in the set» the same way. */
|
|
45
|
+
const style = useViewStyle();
|
|
46
|
+
const pill = (ownLook ?? (style === "modern" ? "pill" : "plain")) === "pill";
|
|
47
|
+
const faint = pill
|
|
48
|
+
? bySurface(activeSurface, "text-primary", "text-chrome-link")
|
|
49
|
+
: bySurface(activeSurface, "text-muted", "text-chrome-muted");
|
|
50
|
+
const strong = pill
|
|
51
|
+
? bySurface(activeSurface, "text-primary", "text-chrome-link")
|
|
52
|
+
: bySurface(activeSurface, "text-ink", "text-chrome-ink");
|
|
53
|
+
const arrow = `inline-flex size-(--size-control-sm) items-center justify-center rounded-pill transition-colors duration-(--duration-instant) disabled:opacity-30 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${pill
|
|
54
|
+
? bySurface(activeSurface, "text-primary not-disabled:hover:bg-primary/15", "text-chrome-link not-disabled:hover:bg-chrome-link/20")
|
|
55
|
+
: bySurface(activeSurface, "text-muted not-disabled:hover:bg-ink/6 not-disabled:hover:text-ink", "text-chrome-muted not-disabled:hover:bg-chrome-ink/12 not-disabled:hover:text-chrome-ink")}`;
|
|
45
56
|
const canEdit = pageSize !== undefined && onPageSizeChange !== undefined && d === "comfortable";
|
|
46
57
|
const sizes = pageSize !== undefined && !pageSizes.includes(pageSize)
|
|
47
58
|
? [...pageSizes, pageSize]
|
|
@@ -55,14 +66,16 @@ export function Pagination({ from, to, total, pageSize, pageSizes = PAGE_SIZES,
|
|
|
55
66
|
onPageSizeChange?.(Math.floor(next));
|
|
56
67
|
setEditing(false);
|
|
57
68
|
}
|
|
58
|
-
return (_jsxs("div", { className: `flex shrink-0 items-center ${byDensity(d, "gap-1", "gap-0.5")}
|
|
69
|
+
return (_jsxs("div", { "data-ui": "pagination", "data-look": pill ? "pill" : "plain", className: `flex shrink-0 items-center ${byDensity(d, "gap-1", "gap-0.5")} ${pill
|
|
70
|
+
? `rounded-pill border p-0.5 pl-2.5 ${bySurface(activeSurface, "border-primary/20 bg-primary/8", "border-chrome-link/30 bg-chrome-link/12")}`
|
|
71
|
+
: ""}`, children: [editing && canEdit ? (_jsxs(_Fragment, { children: [_jsx("input", { autoFocus: true, type: "number", min: 1, step: 1, list: listId, value: draft, onChange: (e) => setDraft(e.target.value), onBlur: () => commitSize(draft), onKeyDown: (e) => {
|
|
59
72
|
if (e.key === "Enter") {
|
|
60
73
|
e.preventDefault();
|
|
61
74
|
commitSize(draft);
|
|
62
75
|
}
|
|
63
76
|
if (e.key === "Escape")
|
|
64
77
|
setEditing(false);
|
|
65
|
-
}, "aria-label": copy.pager.size, className: `h-(--size-control-sm) w-24 rounded-control border px-1.5 text-micro tabular-nums focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(activeSurface, "border-line-strong bg-surface text-ink", "border-chrome-ink/45 bg-chrome-ink/8 text-chrome-ink")}` }), _jsx("datalist", { id: listId, children: sizes.map((n) => (_jsx("option", { value: n }, n))) })] })) : (_jsxs("span", { className: `
|
|
78
|
+
}, "aria-label": copy.pager.size, className: `h-(--size-control-sm) w-24 rounded-control border px-1.5 text-micro tabular-nums focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(activeSurface, "border-line-strong bg-surface text-ink", "border-chrome-ink/45 bg-chrome-ink/8 text-chrome-ink")}` }), _jsx("datalist", { id: listId, children: sizes.map((n) => (_jsx("option", { value: n }, n))) })] })) : (_jsxs("span", { className: `tabular-nums whitespace-nowrap ${pill ? "text-meta font-semibold" : "text-micro"} ${faint}`, children: [canEdit ? (_jsxs("button", { type: "button", onClick: () => {
|
|
66
79
|
setDraft(String(pageSize));
|
|
67
80
|
setEditing(true);
|
|
68
81
|
}, title: fillCopy(copy.pager.sizeHint, { size: pageSize ?? 0 }), className: `rounded-control underline decoration-dotted underline-offset-4 transition-colors duration-(--duration-instant) ${strong} ${bySurface(activeSurface, "decoration-line-strong hover:decoration-primary", "decoration-chrome-ink/40 hover:decoration-chrome-link")} focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary`, children: [from.toLocaleString(copy.locale), "\u2013", to.toLocaleString(copy.locale)] })) : (_jsxs("span", { className: strong, children: [from.toLocaleString(copy.locale), "\u2013", to.toLocaleString(copy.locale)] })), _jsx("span", { className: "mx-1", children: "/" }), total.toLocaleString(copy.locale)] })), _jsxs("span", { className: "flex items-center", children: [_jsx("button", { type: "button", onClick: onPrev, disabled: from <= 1, "aria-label": copy.pager.prev, title: copy.pager.prev, className: arrow, children: _jsx(ChevronLeft, { className: "size-(--size-icon-md)", strokeWidth: 2 }) }), _jsx("button", { type: "button", onClick: onNext, disabled: to >= total, "aria-label": copy.pager.next, title: copy.pager.next, className: arrow, children: _jsx(ChevronRight, { className: "size-(--size-icon-md)", strokeWidth: 2 }) })] })] }));
|
|
@@ -5,7 +5,7 @@ import { emailHref, telHref, urlHref, urlLabel, } from "../../primitives/field/c
|
|
|
5
5
|
import { formatDuration } from "../../primitives/field/duration.js";
|
|
6
6
|
import { DateValue } from "../../primitives/value/DateValue.js";
|
|
7
7
|
import { Numeric } from "../../primitives/value/Value.js";
|
|
8
|
-
import {
|
|
8
|
+
import { YesNo } from "../../primitives/value/YesNo.js";
|
|
9
9
|
const LINK = "block truncate rounded-mark text-primary underline-offset-2 hover:underline focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary";
|
|
10
10
|
function Plain({ text }) {
|
|
11
11
|
return (_jsx("span", { className: "block truncate text-muted", title: text, children: text }));
|
|
@@ -19,14 +19,6 @@ function Link({ text, href, label, external = false, }) {
|
|
|
19
19
|
/* The row opens its record on a click; writing to its email must not ALSO open it. */
|
|
20
20
|
onClick: (event) => event.stopPropagation(), ...(external ? { target: "_blank", rel: "noopener noreferrer" } : {}), children: [label ?? text, external ? _jsxs("span", { className: "sr-only", children: [" (", copy.field.newTab, ")"] }) : null] }));
|
|
21
21
|
}
|
|
22
|
-
/** A yes/no in words: a check alone is not read by everyone the same way, and «no» needs
|
|
23
|
-
* no icon — an empty mark next to every false row would only add noise to the column. */
|
|
24
|
-
function YesNo({ value }) {
|
|
25
|
-
const copy = useUiCopy();
|
|
26
|
-
if (!value)
|
|
27
|
-
return _jsx("span", { className: "text-muted", children: copy.table.no });
|
|
28
|
-
return (_jsxs("span", { className: "inline-flex items-center gap-1 text-ink", children: [_jsx(Check, { "aria-hidden": true, className: "size-(--size-icon-sm) text-good", strokeWidth: 2.5 }), copy.table.yes] }));
|
|
29
|
-
}
|
|
30
22
|
/** One cell of a model column. `value` is what `readModelValue` read — never `null` here. */
|
|
31
23
|
export function ModelCell({ kind, value, }) {
|
|
32
24
|
const text = String(value);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { type DirtyState } from "./DirtyActions.js";
|
|
2
|
+
import { type DockAction } from "./dock.js";
|
|
3
|
+
import { type ReactNode, type Ref } from "react";
|
|
4
|
+
/** Where the dock goes. `bottom` floats it, stuck to the bottom of what scrolls; `inline` draws
|
|
5
|
+
* only the pill — its host places it (`Record.Dock` does). A pill resting in the rail and
|
|
6
|
+
* floating at the TOP on scroll was tried and dropped: the actions float at the bottom. */
|
|
7
|
+
export type DockPlacement = "bottom" | "inline";
|
|
8
|
+
/** The pill's band: the dark one (the settings bar's), a light card — or `bare`: no pill at
|
|
9
|
+
* all, the actions as the rail's buttons (the record's `traditional` style draws them so). */
|
|
10
|
+
export type DockLook = "chrome" | "canvas" | "bare";
|
|
11
|
+
export interface ActionDockProps {
|
|
12
|
+
actions: readonly DockAction[];
|
|
13
|
+
/** How many secondary actions are seen beside the primary; the rest wait in «Más». */
|
|
14
|
+
visible?: number;
|
|
15
|
+
/** Unsaved changes: the dock holds Discard and Save instead of the actions. */
|
|
16
|
+
dirty?: DirtyState;
|
|
17
|
+
/** It has just saved: «Guardado» for a moment (`useJustSaved`). */
|
|
18
|
+
saved?: boolean;
|
|
19
|
+
placement?: DockPlacement;
|
|
20
|
+
/** Centred over what it acts on, or at its end. */
|
|
21
|
+
align?: "center" | "end";
|
|
22
|
+
look?: DockLook;
|
|
23
|
+
/** The toolbar's accessible name: «Acciones de la factura». */
|
|
24
|
+
label?: string;
|
|
25
|
+
/** What the pill says before its actions — «3 elegidas ✕» over a list's chosen rows. Drawn
|
|
26
|
+
* on the pill's band: write it with `useSurface()` colours. */
|
|
27
|
+
lead?: ReactNode;
|
|
28
|
+
}
|
|
29
|
+
/** Where a record's actions go: as the rail's buttons, or floating at the bottom of the screen.
|
|
30
|
+
* Absent, the record's style decides: `traditional` → `rail`, `modern` → `bottom`. */
|
|
31
|
+
export type RecordDockPlacement = "rail" | "bottom";
|
|
32
|
+
/** What `Record.Dock` takes: the dock's, with the record's placements. */
|
|
33
|
+
export type RecordDockProps = Omit<ActionDockProps, "dirty" | "saved" | "placement"> & {
|
|
34
|
+
placement?: RecordDockPlacement;
|
|
35
|
+
};
|
|
36
|
+
export declare function ActionDock({ actions, visible, dirty, saved, placement, align, look, label, lead, }: ActionDockProps): import("react").JSX.Element;
|
|
37
|
+
/**
|
|
38
|
+
* The band a floating pill sits in. Sticky to the edge of what scrolls, as the settings bar: no
|
|
39
|
+
* padding to keep in sync with its height, and at the end of the page it settles in its place in
|
|
40
|
+
* the flow. Only the pill takes the pointer — the band around it lets the page be pressed through.
|
|
41
|
+
* The dock draws its own; the record's place (`DockHost`) draws an empty one for a pill to come.
|
|
42
|
+
*/
|
|
43
|
+
export declare function DockBand({ align, ref, children, }: {
|
|
44
|
+
align?: "center" | "end";
|
|
45
|
+
ref?: Ref<HTMLDivElement>;
|
|
46
|
+
children?: ReactNode;
|
|
47
|
+
}): import("react").JSX.Element;
|
|
48
|
+
export type DockHost = {
|
|
49
|
+
/** The band the taking pill is drawn into; `null` until the record has drawn it. */
|
|
50
|
+
target: HTMLElement | null;
|
|
51
|
+
/** The record is saying Save / Discard: its place is not given away. */
|
|
52
|
+
dirty: boolean;
|
|
53
|
+
/** Takes the place; the returned function gives it back. */
|
|
54
|
+
take: () => () => void;
|
|
55
|
+
};
|
|
56
|
+
export declare const DockHostContext: import("react").Context<DockHost | null>;
|
|
57
|
+
/** The floating place of the record this is inside, if it has one. */
|
|
58
|
+
export declare function useDockHost(): DockHost | null;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
|
+
import { DirtyActions, SavedMark, } from "./DirtyActions.js";
|
|
4
|
+
import { dockOption, dockPlan, dockShortcuts, moreGroups, } from "./dock.js";
|
|
5
|
+
import { useUiCopy } from "../../foundations/copy.js";
|
|
6
|
+
import { keysLabel } from "../../foundations/keys.js";
|
|
7
|
+
import { useKeyboardPlatform, useKeysHint, useShortcuts, } from "../../foundations/shortcut.js";
|
|
8
|
+
import { SurfaceProvider, useSurface } from "../../foundations/surface.js";
|
|
9
|
+
import { Button } from "../../primitives/button/Button.js";
|
|
10
|
+
import { Menu } from "../../primitives/menu/Menu.js";
|
|
11
|
+
import { MoreHorizontal } from "lucide-react";
|
|
12
|
+
import { createContext, use } from "react";
|
|
13
|
+
const PILL = { "--ui-button-radius": "var(--radius-pill)" };
|
|
14
|
+
/** One action as a button, its shortcut in its title and in `aria-keyshortcuts`. */
|
|
15
|
+
function DockButton({ action, role, size, surface, }) {
|
|
16
|
+
const hint = useKeysHint(action.shortcut);
|
|
17
|
+
return (_jsx(Button, { role: role, ...(size === undefined ? {} : { size }), surface: surface, ...(action.icon === undefined ? {} : { icon: action.icon }), ...(action.disabled === undefined ? {} : { disabled: action.disabled }), ...(action.onSelect === undefined ? {} : { onClick: action.onSelect }), ...(hint === undefined
|
|
18
|
+
? {}
|
|
19
|
+
: { title: `${action.label} (${hint.label})`, "aria-keyshortcuts": hint.aria }), children: action.label }));
|
|
20
|
+
}
|
|
21
|
+
/** The same actions with no pill: the rail's buttons — the primary first and gold, the
|
|
22
|
+
* secondary ones bordered, «⋯» with the rest. What the `traditional` style draws. */
|
|
23
|
+
function Bare({ actions, visible, dirty, saved, label, }) {
|
|
24
|
+
const copy = useUiCopy();
|
|
25
|
+
const surface = useSurface();
|
|
26
|
+
const platform = useKeyboardPlatform();
|
|
27
|
+
const label_ = (keys) => keysLabel(keys, platform);
|
|
28
|
+
const plan = dockPlan(actions, visible);
|
|
29
|
+
const more = moreGroups(plan, label_);
|
|
30
|
+
const tone = surface === "chrome" ? "chrome" : "canvas";
|
|
31
|
+
if (dirty !== undefined) {
|
|
32
|
+
return (_jsx("div", { className: "flex shrink-0 items-center gap-1.5", children: _jsx(DirtyActions, { ...dirty }) }));
|
|
33
|
+
}
|
|
34
|
+
return (_jsxs("div", { role: "toolbar", "aria-label": label ?? copy.dock.label, "data-ui": "dock.bare", className: "flex shrink-0 items-center gap-1.5", children: [plan.primary === undefined ? null : (_jsx(DockButton, { action: plan.primary, role: "primary", size: "sm", surface: tone })), plan.shown.map((action) => action.items === undefined ? (_jsx(DockButton, { action: action, role: "secondary", size: "sm", surface: tone }, action.id)) : (_jsx(Menu, { role: "secondary", size: "sm", surface: surface === "chrome" ? "chrome" : "canvas", label: action.label, ...(action.icon === undefined ? {} : { icon: action.icon }), groups: [{ options: action.items.map((one) => dockOption(one, label_)) }] }, action.id))), more.length === 0 ? null : (_jsx(Menu, { label: copy.dock.more, icon: MoreHorizontal, iconOnly: true, chevron: false, size: "sm", surface: surface === "chrome" ? "chrome" : "canvas", groups: more })), _jsx(SavedMark, { saved: saved === true })] }));
|
|
35
|
+
}
|
|
36
|
+
/** The pill alone: the actions, or Save and Discard. */
|
|
37
|
+
function Pill({ actions, visible, dirty, saved, look, label, lead, }) {
|
|
38
|
+
const copy = useUiCopy();
|
|
39
|
+
const platform = useKeyboardPlatform();
|
|
40
|
+
const label_ = (keys) => keysLabel(keys, platform);
|
|
41
|
+
const plan = dockPlan(actions, visible);
|
|
42
|
+
const more = moreGroups(plan, label_);
|
|
43
|
+
return (_jsx(SurfaceProvider, { value: look, children: _jsx("div", { role: "toolbar", "aria-label": label ?? copy.dock.label, "data-ui": "dock.pill", style: PILL, className: `pointer-events-auto flex max-w-full min-w-0 items-center gap-1 rounded-pill p-1.5 shadow-float *:shrink-0 ${look === "chrome"
|
|
44
|
+
? "border border-chrome-edge bg-chrome"
|
|
45
|
+
: "border border-line bg-surface"}`, children: dirty !== undefined ? (_jsx(DirtyActions, { ...dirty, floating: true })) : (_jsxs(_Fragment, { children: [lead, plan.shown.map((action) => action.items === undefined ? (_jsx(DockButton, { action: action, role: "ghost", surface: look }, action.id)) : (_jsx(Menu, { role: "ghost", surface: look, label: action.label, ...(action.icon === undefined ? {} : { icon: action.icon }), groups: [{ options: action.items.map((one) => dockOption(one, label_)) }] }, action.id))), more.length === 0 ? null : (_jsx(Menu, { label: copy.dock.more, icon: MoreHorizontal, iconOnly: true, chevron: false, variant: "text", surface: look, align: "end", groups: more })), plan.primary === undefined ? null : (_jsx(DockButton, { action: plan.primary, role: "primary", surface: look })), _jsx(SavedMark, { saved: saved === true })] })) }) }));
|
|
46
|
+
}
|
|
47
|
+
export function ActionDock({ actions, visible = 2, dirty, saved, placement = "bottom", align = "center", look = "chrome", label, lead, }) {
|
|
48
|
+
/* The combinations run while the dock is on screen; while there are changes Save answers
|
|
49
|
+
Mod+S itself. */
|
|
50
|
+
useShortcuts(dockShortcuts(actions, dirty !== undefined));
|
|
51
|
+
const pill = look === "bare" ? (_jsx(Bare, { actions: actions, visible: visible, ...(dirty === undefined ? {} : { dirty }), ...(saved === undefined ? {} : { saved }), ...(label === undefined ? {} : { label }) })) : (_jsx(Pill, { actions: actions, visible: visible, look: look, ...(lead === undefined ? {} : { lead }), ...(dirty === undefined ? {} : { dirty }), ...(saved === undefined ? {} : { saved }), ...(label === undefined ? {} : { label }) }));
|
|
52
|
+
if (placement === "inline")
|
|
53
|
+
return pill;
|
|
54
|
+
return _jsx(DockBand, { align: align, children: pill });
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* The band a floating pill sits in. Sticky to the edge of what scrolls, as the settings bar: no
|
|
58
|
+
* padding to keep in sync with its height, and at the end of the page it settles in its place in
|
|
59
|
+
* the flow. Only the pill takes the pointer — the band around it lets the page be pressed through.
|
|
60
|
+
* The dock draws its own; the record's place (`DockHost`) draws an empty one for a pill to come.
|
|
61
|
+
*/
|
|
62
|
+
export function DockBand({ align = "center", ref, children, }) {
|
|
63
|
+
return (_jsx("div", { ref: ref, "data-ui": "dock", "data-placement": "bottom", className: `pointer-events-none sticky bottom-0 z-20 mt-auto flex px-3 pt-3 safe-bottom ${align === "end" ? "justify-end" : "justify-center"}`, children: children }));
|
|
64
|
+
}
|
|
65
|
+
export const DockHostContext = createContext(null);
|
|
66
|
+
/** The floating place of the record this is inside, if it has one. */
|
|
67
|
+
export function useDockHost() {
|
|
68
|
+
return use(DockHostContext);
|
|
69
|
+
}
|
|
@@ -33,9 +33,11 @@ export interface Crumb {
|
|
|
33
33
|
* Folding and truncating are not the same and that is why both exist: one removes
|
|
34
34
|
* CRUMBS and the other removes LETTERS.
|
|
35
35
|
*/
|
|
36
|
-
export declare function Breadcrumb({ crumbs, surface: surfaceProp, folded, }: {
|
|
36
|
+
export declare function Breadcrumb({ crumbs, surface: surfaceProp, size, folded, }: {
|
|
37
37
|
crumbs: readonly Crumb[];
|
|
38
38
|
surface?: Surface;
|
|
39
|
+
/** `lg`: the trail is the page's heading — the record's «modern» style draws it so. */
|
|
40
|
+
size?: "md" | "lg";
|
|
39
41
|
/** From how many crumbs the middle folds. Below this every crumb is drawn:
|
|
40
42
|
* folding two crumbs hides half the trail to save one chevron. */
|
|
41
43
|
folded?: number;
|
|
@@ -12,7 +12,7 @@ import { Breadcrumb as AriaBreadcrumb, Breadcrumbs, Link } from "react-aria-comp
|
|
|
12
12
|
* read. */
|
|
13
13
|
const crumbStyles = tv({
|
|
14
14
|
extend: focusRing,
|
|
15
|
-
base: "block min-w-0 rounded-mark
|
|
15
|
+
base: "block min-w-0 rounded-mark transition-colors duration-(--duration-instant)",
|
|
16
16
|
variants: {
|
|
17
17
|
surface: { canvas: "", chrome: "outline-chrome-link" },
|
|
18
18
|
kind: {
|
|
@@ -20,8 +20,13 @@ const crumbStyles = tv({
|
|
|
20
20
|
inert: "cursor-default",
|
|
21
21
|
current: "cursor-default font-medium",
|
|
22
22
|
},
|
|
23
|
+
/* `lg`: the trail IS the page's heading — where I am, at the title's size, the way back
|
|
24
|
+
at the body's. */
|
|
25
|
+
size: { md: "text-meta", lg: "" },
|
|
23
26
|
},
|
|
24
27
|
compoundVariants: [
|
|
28
|
+
{ size: "lg", kind: ["link", "inert"], class: "text-body" },
|
|
29
|
+
{ size: "lg", kind: "current", class: "text-title font-semibold" },
|
|
25
30
|
{ surface: "canvas", kind: ["link", "inert"], class: "text-muted" },
|
|
26
31
|
{ surface: "canvas", kind: "link", class: "hover:text-ink" },
|
|
27
32
|
{ surface: "canvas", kind: "current", class: "text-ink" },
|
|
@@ -59,7 +64,7 @@ const crumbStyles = tv({
|
|
|
59
64
|
* Folding and truncating are not the same and that is why both exist: one removes
|
|
60
65
|
* CRUMBS and the other removes LETTERS.
|
|
61
66
|
*/
|
|
62
|
-
export function Breadcrumb({ crumbs, surface: surfaceProp, folded = 3, }) {
|
|
67
|
+
export function Breadcrumb({ crumbs, surface: surfaceProp, size = "md", folded = 3, }) {
|
|
63
68
|
const copy = useUiCopy();
|
|
64
69
|
const surface = useSurface(surfaceProp);
|
|
65
70
|
const edge = surface === "chrome" ? "text-chrome-muted/50" : "text-line-strong";
|
|
@@ -73,10 +78,10 @@ export function Breadcrumb({ crumbs, surface: surfaceProp, folded = 3, }) {
|
|
|
73
78
|
panel next to the page) are two trails, and a screen reader lists landmarks by name. */
|
|
74
79
|
const last = crumbs[crumbs.length - 1];
|
|
75
80
|
const name = last === undefined ? copy.record.location : `${copy.record.location}: ${last.label}`;
|
|
76
|
-
return (_jsx("nav", { "aria-label": name, className: "flex min-w-0", children: _jsx(Breadcrumbs, { "aria-label": name, className:
|
|
81
|
+
return (_jsx("nav", { "aria-label": name, className: "flex min-w-0", children: _jsx(Breadcrumbs, { "aria-label": name, className: `flex min-w-0 flex-wrap items-center ${size === "lg" ? "gap-1.5" : "gap-1"}`, children: shown.map((crumb, i) => {
|
|
77
82
|
const key = crumb === null ? "folded" : `${i}-${crumb.label}`;
|
|
78
83
|
const last = i === shown.length - 1;
|
|
79
|
-
return (_jsxs(AriaBreadcrumb, { id: key, className: "flex min-w-0 items-center gap-1", children: [i === 0 ? null : (_jsx(ChevronRight, { className:
|
|
84
|
+
return (_jsxs(AriaBreadcrumb, { id: key, className: "flex min-w-0 items-center gap-1", children: [i === 0 ? null : (_jsx(ChevronRight, { className: `${size === "lg" ? "size-(--size-icon-md)" : "size-(--size-icon-sm)"} shrink-0 ${edge}`, strokeWidth: 2, "aria-hidden": true })), crumb === null ? (_jsx(Menu, { label: copy.record.location, title: copy.record.location, icon: MoreHorizontal, iconOnly: true, chevron: false, variant: "text", size: "sm", surface: surface === "chrome" ? "chrome" : "canvas", align: "start", groups: [
|
|
80
85
|
{
|
|
81
86
|
options: hidden.map((one, at) => ({
|
|
82
87
|
id: `crumb-${at}`,
|
|
@@ -95,8 +100,11 @@ export function Breadcrumb({ crumbs, surface: surfaceProp, folded = 3, }) {
|
|
|
95
100
|
nothing. */
|
|
96
101
|
isDisabled: last ? undefined : crumb.onClick === undefined, onPress: crumb.onClick, className: ({ isFocusVisible }) => crumbStyles({
|
|
97
102
|
surface,
|
|
103
|
+
size,
|
|
98
104
|
isFocusVisible,
|
|
99
105
|
kind: last ? "current" : crumb.onClick === undefined ? "inert" : "link",
|
|
100
|
-
}), children: _jsx("span", { className:
|
|
106
|
+
}), children: _jsx("span", { className: `block truncate ${last && size === "lg"
|
|
107
|
+
? "max-w-(--container-crumb-heading)"
|
|
108
|
+
: "max-w-(--container-crumb)"}`, title: crumb.label, children: crumb.label }) }))] }, key));
|
|
101
109
|
}) }) }));
|
|
102
110
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
3
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { useKeysHint, useShortcuts } from "../../foundations/shortcut.js";
|
|
4
5
|
import { bySurface, SurfaceProvider, useSurface } from "../../foundations/surface.js";
|
|
5
6
|
import { Button } from "../../primitives/button/Button.js";
|
|
6
7
|
import { Check, Save, Undo2 } from "lucide-react";
|
|
@@ -18,6 +19,10 @@ import { useEffect, useId, useRef, useState } from "react";
|
|
|
18
19
|
* still reaches a screen reader, as the Save button's description. */
|
|
19
20
|
export function DirtyActions({ onSave, onDiscard, saving = false, label, blocked, changes, floating = false, }) {
|
|
20
21
|
const copy = useUiCopy();
|
|
22
|
+
/* Mod+S saves wherever Save is — the rail, the thumb bar, a floating pill —: the gesture
|
|
23
|
+
every editor has, and in a browser it would otherwise save the PAGE. */
|
|
24
|
+
useShortcuts([{ keys: "Mod+S", run: onSave, enabled: blocked === undefined && !saving }]);
|
|
25
|
+
const saveHint = useKeysHint("Mod+S");
|
|
21
26
|
const blockedId = useId();
|
|
22
27
|
const changesId = useId();
|
|
23
28
|
/* It follows the rail it sits on instead of assuming the dark one: on a light rail the
|
|
@@ -36,7 +41,12 @@ export function DirtyActions({ onSave, onDiscard, saving = false, label, blocked
|
|
|
36
41
|
}
|
|
37
42
|
: { hidden: true }), children: fillCopy(changes === 1 ? copy.record.unsavedOne : copy.record.unsavedMany, {
|
|
38
43
|
count: changes.toLocaleString(copy.locale),
|
|
39
|
-
}) })) : null, _jsx(Button, { ...(floating ? { role: "ghost" } : {}), surface: surface, onClick: onDiscard, disabled: saving, icon: Undo2, children: copy.record.discard }), _jsx(Button, { role: "primary", surface: surface, onClick: onSave, busy: saving, disabled: blocked !== undefined, icon: Save, ...(
|
|
44
|
+
}) })) : null, _jsx(Button, { ...(floating ? { role: "ghost" } : {}), surface: surface, onClick: onDiscard, disabled: saving, icon: Undo2, children: copy.record.discard }), _jsx(Button, { role: "primary", surface: surface, onClick: onSave, busy: saving, disabled: blocked !== undefined, icon: Save, ...(saveHint === undefined
|
|
45
|
+
? {}
|
|
46
|
+
: {
|
|
47
|
+
title: `${copy.record.save} (${saveHint.label})`,
|
|
48
|
+
"aria-keyshortcuts": saveHint.aria,
|
|
49
|
+
}), ...(describedBy === "" ? {} : { "aria-describedby": describedBy }), children: saving ? copy.record.saving : (label ?? copy.record.save) })] }));
|
|
40
50
|
}
|
|
41
51
|
/** The one action a view leads with: the element written with `role="primary"` — the
|
|
42
52
|
* same prop that paints it gold and that `make smoke` counts, so there is no second way to
|
|
@@ -1,18 +1,20 @@
|
|
|
1
|
+
import type { Keys } from "../../foundations/keys.js";
|
|
1
2
|
import type { Surface } from "../../foundations/types.js";
|
|
2
|
-
|
|
3
|
-
*
|
|
4
|
-
* **It turns a record into a position.** Without this, opening the third of a
|
|
5
|
-
* list of eighty and wanting to see the fourth forces going back, finding
|
|
6
|
-
* where you were and opening again — three actions for what is one arrow.
|
|
7
|
-
*
|
|
8
|
-
* It goes far from the actions on purpose: moving between records is not doing
|
|
9
|
-
* something to this record. Stuck next to «Eliminar», one extra click on the
|
|
10
|
-
* wrong arrow is a destructive action. */
|
|
11
|
-
export declare function Pager({ index, total, onPrev, onNext, surface: surfaceProp, }: {
|
|
3
|
+
export declare function Pager({ index, total, onPrev, onNext, surface: surfaceProp, look, keys, }: {
|
|
12
4
|
/** 1-based: what gets shown is «12 de 80», not «11». */
|
|
13
5
|
index: number;
|
|
14
6
|
total: number;
|
|
15
7
|
onPrev?: () => void;
|
|
16
8
|
onNext?: () => void;
|
|
17
9
|
surface?: Surface;
|
|
10
|
+
/** `plain`: quiet, a count and two arrows. `pill`: the position stands out — a translucent
|
|
11
|
+
* primary pill, Odoo's — for the record's modern style, where the trail is the heading
|
|
12
|
+
* and the pager its counterpart on the line. */
|
|
13
|
+
look?: "plain" | "pill";
|
|
14
|
+
/** The combinations that move: Alt+P and Alt+N by default, `false` for none. Bound while the
|
|
15
|
+
* pager is on screen — the last record mounted answers (`useShortcuts`). */
|
|
16
|
+
keys?: {
|
|
17
|
+
prev: Keys;
|
|
18
|
+
next: Keys;
|
|
19
|
+
} | false;
|
|
18
20
|
}): import("react").JSX.Element;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
|
|
3
3
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { useKeysHint, useShortcuts } from "../../foundations/shortcut.js";
|
|
4
5
|
import { useSurface } from "../../foundations/surface.js";
|
|
5
6
|
import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
6
7
|
/* ---------------------------------------------------------------- *
|
|
@@ -15,19 +16,51 @@ import { ChevronLeft, ChevronRight } from "lucide-react";
|
|
|
15
16
|
* It goes far from the actions on purpose: moving between records is not doing
|
|
16
17
|
* something to this record. Stuck next to «Eliminar», one extra click on the
|
|
17
18
|
* wrong arrow is a destructive action. */
|
|
18
|
-
|
|
19
|
+
/** The combinations a pager answers by default: Odoo's — Alt+P the previous, Alt+N the next. */
|
|
20
|
+
const PAGER_KEYS = { prev: "Alt+P", next: "Alt+N" };
|
|
21
|
+
export function Pager({ index, total, onPrev, onNext, surface: surfaceProp, look = "plain", keys = PAGER_KEYS, }) {
|
|
19
22
|
const copy = useUiCopy();
|
|
20
23
|
const surface = useSurface(surfaceProp);
|
|
21
24
|
const isChrome = surface === "chrome";
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
25
|
+
const pill = look === "pill";
|
|
26
|
+
const atStart = index <= 1;
|
|
27
|
+
const atEnd = index >= total;
|
|
28
|
+
useShortcuts(keys === false
|
|
29
|
+
? []
|
|
30
|
+
: [
|
|
31
|
+
{
|
|
32
|
+
keys: keys.prev,
|
|
33
|
+
run: () => onPrev?.(),
|
|
34
|
+
enabled: onPrev !== undefined && !atStart,
|
|
35
|
+
},
|
|
36
|
+
{ keys: keys.next, run: () => onNext?.(), enabled: onNext !== undefined && !atEnd },
|
|
37
|
+
]);
|
|
38
|
+
const prevHint = useKeysHint(keys === false ? undefined : keys.prev);
|
|
39
|
+
const nextHint = useKeysHint(keys === false ? undefined : keys.next);
|
|
40
|
+
const faint = pill
|
|
41
|
+
? isChrome
|
|
42
|
+
? "text-chrome-link"
|
|
43
|
+
: "text-primary"
|
|
44
|
+
: isChrome
|
|
45
|
+
? "text-chrome-muted"
|
|
46
|
+
: "text-muted";
|
|
47
|
+
const hover = pill
|
|
48
|
+
? isChrome
|
|
49
|
+
? "not-disabled:hover:bg-chrome-link/20"
|
|
50
|
+
: "not-disabled:hover:bg-primary/15"
|
|
51
|
+
: isChrome
|
|
52
|
+
? "not-disabled:hover:bg-chrome-ink/10 not-disabled:hover:text-chrome-ink"
|
|
53
|
+
: "not-disabled:hover:bg-ink/6 not-disabled:hover:text-ink";
|
|
26
54
|
/* On the chrome the ring is the chrome's link cyan, like the TopBar's: the
|
|
27
55
|
primary navy on a navy band is a ring nobody sees. */
|
|
28
56
|
const ring = isChrome
|
|
29
57
|
? "focus-visible:outline-chrome-link"
|
|
30
58
|
: "focus-visible:outline-primary";
|
|
31
59
|
const arrow = `inline-flex size-(--size-control-sm) items-center justify-center rounded-pill transition-colors duration-(--duration-instant) disabled:opacity-30 focus-visible:outline-2 focus-visible:outline-offset-2 ${ring} ${faint} ${hover}`;
|
|
32
|
-
|
|
60
|
+
const titled = (word, hint) => hint === undefined ? word : `${word} (${hint.label})`;
|
|
61
|
+
return (_jsxs("div", { "data-ui": "pager", "data-look": look, className: `flex shrink-0 items-center gap-1 ${pill
|
|
62
|
+
? `rounded-pill border p-0.5 ${isChrome
|
|
63
|
+
? "border-chrome-link/30 bg-chrome-link/12"
|
|
64
|
+
: "border-primary/20 bg-primary/8"}`
|
|
65
|
+
: ""}`, children: [_jsxs("span", { className: `tabular-nums ${pill ? `px-2 text-meta font-semibold ${faint}` : `text-micro ${faint}`}`, children: [index, " / ", total.toLocaleString(copy.locale)] }), _jsx("button", { type: "button", onClick: onPrev, disabled: atStart, "aria-label": copy.record.prev, title: titled(copy.record.prev, prevHint), ...(prevHint === undefined ? {} : { "aria-keyshortcuts": prevHint.aria }), className: arrow, children: _jsx(ChevronLeft, { className: "size-(--size-icon-md)", strokeWidth: 2 }) }), _jsx("button", { type: "button", onClick: onNext, disabled: atEnd, "aria-label": copy.record.next, title: titled(copy.record.next, nextHint), ...(nextHint === undefined ? {} : { "aria-keyshortcuts": nextHint.aria }), className: arrow, children: _jsx(ChevronRight, { className: "size-(--size-icon-md)", strokeWidth: 2 }) })] }));
|
|
33
66
|
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import { type RecordDockProps } from "./ActionDock.js";
|
|
1
2
|
import { type Crumb } from "./Breadcrumb.js";
|
|
2
3
|
import { type DirtyState } from "./DirtyActions.js";
|
|
3
4
|
import type { Surface, Tone } from "../../foundations/types.js";
|
|
5
|
+
import { type ViewStyle } from "../../foundations/viewStyle.js";
|
|
4
6
|
import type { LucideIcon } from "lucide-react";
|
|
5
7
|
import { type ReactNode } from "react";
|
|
6
8
|
export type { Surface };
|
|
7
|
-
export declare function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Icon, title, subtitle, tag, figure, railSurface, smart, aspects, dirty, activity, activityLayout, width, ribbon, blocking, indicator, paper: onPaper, children, }: {
|
|
9
|
+
export declare function RecordHeader({ crumbs, pager, actions, status, kicker, icon: Icon, title, subtitle, tag, figure, railSurface, smart, aspects, dirty, activity, activityLayout, width, ribbon, blocking, indicator, paper: onPaper, dock, look, children, }: {
|
|
8
10
|
crumbs?: readonly Crumb[];
|
|
9
11
|
pager?: ReactNode;
|
|
10
12
|
/** The action buttons. At most three visible + a `Menu` with `iconOnly`, and
|
|
@@ -79,6 +81,16 @@ export declare function RecordHeader({ crumbs, pager, actions, status, kicker, i
|
|
|
79
81
|
* `placement`). Only in comfortable: compact (the peek) is always one surface. Omitted, it
|
|
80
82
|
* is guessed from the rail: crumbs, pager or actions mean a page. */
|
|
81
83
|
paper?: boolean;
|
|
84
|
+
/**
|
|
85
|
+
* The record's actions FLOATING (`ActionDock`): in place of `actions` and of
|
|
86
|
+
* Save / Discard on the rail, one pill that, at the top, sits over the paper and stays in
|
|
87
|
+
* view as the record scrolls; at the bottom, the settings bar's place. The rail keeps where
|
|
88
|
+
* I am, which of eighty, and the state.
|
|
89
|
+
*/
|
|
90
|
+
dock?: RecordDockProps;
|
|
91
|
+
/** How the record is drawn — `traditional` or `modern`. Absent, the
|
|
92
|
+
* `ViewStyleProvider`'s. See `style.tsx`. */
|
|
93
|
+
look?: ViewStyle;
|
|
82
94
|
/** The record body. It sits IN the paper with the title, so groups, tabs
|
|
83
95
|
* and the page are one white sheet on the ground — Odoo's `<sheet>`. */
|
|
84
96
|
children?: ReactNode;
|