@sincpro/web-ui 2.18.1 → 2.19.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 +5 -3
- package/dist/components/flow/SetupCard.d.ts +21 -0
- package/dist/components/flow/SetupCard.js +16 -0
- package/dist/components/flow/index.d.ts +1 -0
- package/dist/components/flow/index.js +3 -0
- package/dist/components/form/Form.js +7 -5
- package/dist/components/listing/Row.d.ts +5 -2
- package/dist/components/listing/Row.js +4 -3
- package/dist/components/navigation/NavigationTree.d.ts +3 -0
- package/dist/components/navigation/NavigationTree.js +2 -1
- package/dist/components/record/ActionDock.d.ts +10 -3
- package/dist/components/record/ActionDock.js +15 -8
- package/dist/components/record/DirtyActions.d.ts +15 -7
- package/dist/components/record/DirtyActions.js +37 -13
- package/dist/components/record/DockMessage.d.ts +18 -0
- package/dist/components/record/DockMessage.js +31 -0
- package/dist/components/record/dock.d.ts +25 -0
- package/dist/components/record/index.d.ts +2 -1
- package/dist/components/record/index.js +1 -0
- package/dist/components/shell/Page.d.ts +12 -0
- package/dist/components/shell/Page.js +12 -0
- package/dist/components/shell/Sidebar.d.ts +22 -3
- package/dist/components/shell/Sidebar.js +88 -10
- package/dist/components/shell/index.d.ts +1 -0
- package/dist/components/shell/index.js +2 -0
- package/dist/foundations/copy.es.js +5 -0
- package/dist/foundations/grouping.d.ts +37 -0
- package/dist/foundations/grouping.js +0 -0
- package/dist/foundations/index.d.ts +1 -1
- package/dist/foundations/index.js +1 -1
- package/dist/foundations/uiCopy.d.ts +10 -0
- package/dist/foundations/uiCopy.js +5 -0
- package/dist/primitives/button/Button.d.ts +5 -1
- package/dist/primitives/button/Button.js +4 -4
- package/dist/primitives/button/classes.d.ts +1 -8
- package/dist/primitives/button/classes.js +12 -2
- package/dist/primitives/menu/Menu.d.ts +22 -1
- package/dist/primitives/menu/Menu.js +44 -18
- package/dist/primitives/table/DataTable.d.ts +12 -1
- package/dist/primitives/table/DataTable.js +42 -14
- package/dist/primitives/table/PileFootLine.d.ts +4 -2
- package/dist/primitives/table/PileFootLine.js +16 -5
- package/dist/primitives/table/SheetTable.d.ts +19 -1
- package/dist/primitives/table/SheetTable.js +22 -2
- package/dist/primitives/table/index.d.ts +1 -1
- package/dist/primitives/table/index.js +1 -1
- package/dist/primitives/tabs/Tabs.d.ts +21 -1
- package/dist/primitives/tabs/Tabs.js +26 -7
- package/dist/primitives/tabs/index.d.ts +1 -1
- package/dist/primitives/tag/Tag.d.ts +5 -0
- package/dist/primitives/tag/Tag.js +2 -1
- package/dist/primitives/value/Avatar.d.ts +4 -1
- package/dist/primitives/value/Avatar.js +2 -2
- package/dist/views/list/ListView.js +23 -5
- package/dist/views/list/derive.d.ts +5 -3
- package/dist/views/list/derive.js +30 -5
- package/dist/views/list/presentations.js +2 -1
- package/dist/views/list/types.d.ts +5 -1
- package/package.json +1 -1
|
@@ -5,7 +5,11 @@ import { SearchEntry, } from "./SearchEntry.js";
|
|
|
5
5
|
import { useSidebarDrawer } from "./sidebarDrawer.js";
|
|
6
6
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
7
7
|
import { SurfaceProvider, useSurface } from "../../foundations/surface.js";
|
|
8
|
+
import { useTheme } from "../../foundations/theme.js";
|
|
9
|
+
import { Menu } from "../../primitives/menu/Menu.js";
|
|
10
|
+
import { Tag } from "../../primitives/tag/Tag.js";
|
|
8
11
|
import { Avatar } from "../../primitives/value/Person.js";
|
|
12
|
+
import { ChevronsUpDown, Monitor, Moon, Sun } from "lucide-react";
|
|
9
13
|
/* Each surface's colours in one place: the column is ONE surface, and a row drawn with the
|
|
10
14
|
other palette is the bug the surface context exists to prevent. The hairlines are ink at a
|
|
11
15
|
low alpha on the chrome: `chrome-edge` is the chrome itself on light, an invisible line. */
|
|
@@ -17,6 +21,8 @@ const SKIN = {
|
|
|
17
21
|
mark: "text-primary",
|
|
18
22
|
line: "border-line",
|
|
19
23
|
row: "text-ink hover:bg-ink/6 focus-visible:outline-primary",
|
|
24
|
+
/* «Salir» in the danger tone: the word is what warns, the colour helps. */
|
|
25
|
+
danger: "text-danger hover:bg-danger/10 focus-visible:outline-primary",
|
|
20
26
|
},
|
|
21
27
|
chrome: {
|
|
22
28
|
root: "bg-chrome",
|
|
@@ -25,34 +31,106 @@ const SKIN = {
|
|
|
25
31
|
mark: "text-chrome-link",
|
|
26
32
|
line: "border-chrome-ink/12",
|
|
27
33
|
row: "text-chrome-ink hover:bg-chrome-ink/10 focus-visible:outline-chrome-link",
|
|
34
|
+
danger: "text-chrome-bad hover:bg-chrome-bad/10 focus-visible:outline-chrome-link",
|
|
28
35
|
},
|
|
29
36
|
};
|
|
30
37
|
const ROW = "flex h-(--size-control-sm) w-full min-w-0 cursor-pointer items-center gap-2 rounded-control px-2 text-meta no-underline transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2";
|
|
31
|
-
function Brand({ brand, skin }) {
|
|
38
|
+
function Brand({ brand, skin, surface, }) {
|
|
32
39
|
const Icon = brand.icon;
|
|
33
|
-
return (_jsxs("div", { "data-ui": "sidebar.brand", className: "flex min-w-0 items-center gap-2 px-4 pt-4 pb-2", children: [brand.logo === undefined ? (Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-lg) shrink-0 ${skin.mark}`, strokeWidth: 1.75, "aria-hidden": true }))) : (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-md) shrink-0" })), _jsx("span", { className: `min-w-0 truncate text-lead font-semibold ${skin.ink}`, children: brand.label })] }));
|
|
40
|
+
return (_jsxs("div", { "data-ui": "sidebar.brand", className: "flex min-w-0 items-center gap-2 px-4 pt-4 pb-2", children: [brand.logo === undefined ? (Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-lg) shrink-0 ${skin.mark}`, strokeWidth: 1.75, "aria-hidden": true }))) : (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-md) shrink-0" })), _jsx("span", { className: `min-w-0 truncate text-lead font-semibold ${skin.ink}`, children: brand.label }), brand.badge === undefined ? null : _jsx(Tag, { surface: surface, children: brand.badge })] }));
|
|
34
41
|
}
|
|
35
42
|
function User({ user, skin }) {
|
|
36
43
|
return (_jsxs("div", { "data-ui": "sidebar.user", className: "flex min-w-0 items-center gap-2 px-4 py-2", children: [_jsx(Avatar, { name: user.name, size: "md", ...(user.avatar === undefined ? {} : { src: user.avatar }) }), _jsxs("span", { className: "flex min-w-0 flex-col leading-tight", children: [_jsx("span", { className: `truncate text-meta ${skin.ink}`, children: user.name }), user.detail === undefined ? null : (_jsx("span", { className: `truncate text-micro ${skin.muted}`, children: user.detail }))] })] }));
|
|
37
44
|
}
|
|
45
|
+
/** What choosing an account action does, in the list and in the menu alike: copy what it
|
|
46
|
+
* carries, then report it. */
|
|
47
|
+
function run(action, onAction) {
|
|
48
|
+
if (action.copy !== undefined)
|
|
49
|
+
void navigator.clipboard?.writeText(action.copy);
|
|
50
|
+
onAction?.(action.id);
|
|
51
|
+
}
|
|
38
52
|
function Action({ action, skin, onAction, }) {
|
|
39
53
|
const copy = useUiCopy();
|
|
40
54
|
const drawer = useSidebarDrawer();
|
|
41
55
|
const Icon = action.icon;
|
|
42
|
-
const
|
|
56
|
+
const row = `${ROW} ${action.danger === true ? skin.danger : skin.row}`;
|
|
57
|
+
const content = (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-md) shrink-0 ${action.danger === true ? "" : skin.muted}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "min-w-0 truncate", children: action.label })] }));
|
|
43
58
|
if (action.href !== undefined) {
|
|
44
|
-
return (_jsxs("a", { href: action.href, className:
|
|
59
|
+
return (_jsxs("a", { href: action.href, className: row, ...(action.external === true ? { target: "_blank", rel: "noreferrer" } : {}), children: [content, action.external === true ? (_jsx("span", { className: "sr-only", children: ` (${copy.field.newTab})` })) : null] }));
|
|
45
60
|
}
|
|
46
|
-
return (_jsx("button", { type: "button", className:
|
|
47
|
-
|
|
61
|
+
return (_jsx("button", { type: "button", className: row, onClick: () => {
|
|
62
|
+
run(action, onAction);
|
|
48
63
|
drawer?.close();
|
|
49
64
|
}, children: content }));
|
|
50
65
|
}
|
|
51
|
-
|
|
66
|
+
/** Who the person is, as the account row and the menu's header draw it. */
|
|
67
|
+
function Who({ user, skin, line, }) {
|
|
68
|
+
return (_jsxs(_Fragment, { children: [_jsx(Avatar, { name: user.name, size: "md", decorative: true, ...(user.avatar === undefined ? {} : { src: user.avatar }) }), _jsxs("span", { className: "flex min-w-0 flex-1 flex-col leading-tight", children: [_jsx("span", { className: `truncate text-meta font-medium ${skin.ink}`, children: user.name }), line === undefined ? null : (_jsx("span", { className: `truncate text-micro ${skin.muted}`, children: line }))] })] }));
|
|
69
|
+
}
|
|
70
|
+
/** The account at the foot: one button — the person — that opens what is done with the
|
|
71
|
+
* account, the bell beside it. */
|
|
72
|
+
function Account({ user, actions, onAction, theme, bell, skin, surface, }) {
|
|
73
|
+
const copy = useUiCopy();
|
|
74
|
+
const drawer = useSidebarDrawer();
|
|
75
|
+
const { theme: chosen, setTheme } = useTheme();
|
|
76
|
+
const option = (action) => ({
|
|
77
|
+
id: action.id,
|
|
78
|
+
label: action.label,
|
|
79
|
+
...(action.icon === undefined ? {} : { icon: action.icon }),
|
|
80
|
+
...(action.apart === true ? { divider: true } : {}),
|
|
81
|
+
...(action.danger === true ? { danger: true } : {}),
|
|
82
|
+
/* A link stays a link: the row is an `<a>` (new tab, the router, «copy link»). */
|
|
83
|
+
...(action.href === undefined
|
|
84
|
+
? {}
|
|
85
|
+
: {
|
|
86
|
+
href: action.href,
|
|
87
|
+
...(action.external === true ? { target: "_blank" } : {}),
|
|
88
|
+
}),
|
|
89
|
+
...(action.href === undefined || action.external !== true
|
|
90
|
+
? {}
|
|
91
|
+
: { hint: copy.field.newTab }),
|
|
92
|
+
onSelect: () => {
|
|
93
|
+
if (action.href !== undefined)
|
|
94
|
+
return;
|
|
95
|
+
run(action, onAction);
|
|
96
|
+
drawer?.close();
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
const groups = [
|
|
100
|
+
...(theme
|
|
101
|
+
? [
|
|
102
|
+
{
|
|
103
|
+
label: copy.theme.label,
|
|
104
|
+
inline: true,
|
|
105
|
+
options: [
|
|
106
|
+
["light", copy.theme.light, Sun],
|
|
107
|
+
["dark", copy.theme.dark, Moon],
|
|
108
|
+
["system", copy.theme.system, Monitor],
|
|
109
|
+
].map(([value, label, icon]) => ({
|
|
110
|
+
id: `\u0000theme:${value}`,
|
|
111
|
+
label,
|
|
112
|
+
icon,
|
|
113
|
+
checked: chosen === value,
|
|
114
|
+
onSelect: () => setTheme(value),
|
|
115
|
+
})),
|
|
116
|
+
},
|
|
117
|
+
]
|
|
118
|
+
: []),
|
|
119
|
+
...(actions.length === 0 ? [] : [{ options: actions.map(option) }]),
|
|
120
|
+
];
|
|
121
|
+
return (_jsxs("div", { "data-ui": "sidebar.me", className: "flex min-w-0 items-center gap-1", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(Menu, { label: copy.shell.account, groups: groups, surface: surface === "chrome" ? "chrome" : "canvas", placement: "top start", header: _jsx("span", { className: "flex min-w-0 items-center gap-2", children: _jsx(Who, { user: user, skin: { ink: "text-ink", muted: "text-muted" }, line: user.org ?? user.detail }) }), trigger: _jsxs(_Fragment, { children: [_jsx(Who, { user: user, skin: skin, line: user.detail }), _jsx(ChevronsUpDown, { className: `size-(--size-icon-sm) shrink-0 ${skin.muted}`, strokeWidth: 2, "aria-hidden": true })] }) }) }), bell] }));
|
|
122
|
+
}
|
|
123
|
+
export function Sidebar({ brand, user, search, children, actions, onAction, footer, surface, account = "menu", theme = false, bell, }) {
|
|
52
124
|
const copy = useUiCopy();
|
|
53
125
|
const sup = useSurface(surface);
|
|
54
126
|
const skin = SKIN[sup];
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
127
|
+
/* The person goes to the foot as a menu only when there is a person AND something to put
|
|
128
|
+
in it: verbs and no user stay listed, and a person with nothing to choose stays a name —
|
|
129
|
+
a button that opens «nothing matches» is a door to an empty room. */
|
|
130
|
+
const asMenu = account === "menu" && user !== undefined && ((actions?.length ?? 0) > 0 || theme);
|
|
131
|
+
const head = brand !== undefined || (user !== undefined && !asMenu) || search !== undefined;
|
|
132
|
+
const foot = asMenu || (actions !== undefined && actions.length > 0) || footer !== undefined;
|
|
133
|
+
return (_jsx(SurfaceProvider, { value: sup, children: _jsxs("div", { "data-ui": "sidebar", "data-surface": sup, className: `flex h-full min-h-0 min-w-0 flex-col ${skin.root}`, children: [head ? (_jsxs("div", { className: `shrink-0 border-b pb-2 ${skin.line}`, children: [brand === undefined ? null : (_jsx(Brand, { brand: brand, skin: skin, surface: sup === "chrome" ? "chrome" : "canvas" })), user === undefined || asMenu ? null : (_jsxs("div", { className: "flex min-w-0 items-center pr-2", children: [_jsx("div", { className: "min-w-0 flex-1", children: _jsx(User, { user: user, skin: skin }) }), bell] })), search === undefined ? null : (_jsx("div", { "data-ui": "sidebar.search", className: "px-2 pt-2", children: _jsx(SearchEntry, { ...search }) }))] })) : null, _jsx("div", { "data-ui": "sidebar.nav", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { "data-ui": "sidebar.account", className: `flex shrink-0 flex-col gap-2 border-t p-2 ${skin.line}`, children: [asMenu ? (_jsxs(_Fragment, { children: [footer, _jsx(Account, { user: user, actions: actions ?? [], onAction: onAction, theme: theme, bell: bell, skin: skin, surface: sup })] })) : actions === undefined || actions.length === 0 ? null : (_jsx("ul", { "aria-label": copy.shell.account, className: "flex flex-col gap-px", children: actions.map((action) => (_jsx("li", { ...(action.apart === true
|
|
134
|
+
? { className: `mt-1 border-t pt-1 ${skin.line}` }
|
|
135
|
+
: {}), children: _jsx(Action, { action: action, skin: skin, ...(onAction === undefined ? {} : { onAction }) }) }, action.id))) })), asMenu ? null : footer] })) : null] }) }));
|
|
58
136
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { AppFrame } from "./AppFrame.js";
|
|
2
|
+
export { Page } from "./Page.js";
|
|
2
3
|
export { type BrandLogo } from "./brandMark.js";
|
|
3
4
|
export { Sidebar, type SidebarAction, type SidebarProps, } from "./Sidebar.js";
|
|
4
5
|
export { SearchEntry, type SearchEntryProps, } from "./SearchEntry.js";
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
/* THE APPLICATION FRAME — what sits above every view. */
|
|
2
2
|
export { AppFrame } from "./AppFrame.js";
|
|
3
|
+
/* The page's margin and reading width, for a page that is not a Record or a List. */
|
|
4
|
+
export { Page } from "./Page.js";
|
|
3
5
|
/* A product's mark: an image's URL, or an inline <svg> that paints with the tokens. */
|
|
4
6
|
export {} from "./brandMark.js";
|
|
5
7
|
/* The whole chrome in one column, for a back office with no bar on top. */
|
|
@@ -79,6 +79,7 @@ export const SPANISH_COPY = {
|
|
|
79
79
|
unsaved: "sin guardar",
|
|
80
80
|
unsavedOne: "1 cambio sin guardar",
|
|
81
81
|
unsavedMany: "{count} cambios sin guardar",
|
|
82
|
+
unsavedAny: "Cambios sin guardar",
|
|
82
83
|
save: "Guardar",
|
|
83
84
|
saving: "Guardando…",
|
|
84
85
|
saved: "Guardado",
|
|
@@ -263,6 +264,9 @@ export const SPANISH_COPY = {
|
|
|
263
264
|
pileMore: "Ver {count} más",
|
|
264
265
|
pileMoreOf: "Ver {count} más de {left}",
|
|
265
266
|
pileShown: "Se muestran {shown} de {count}",
|
|
267
|
+
pilesMore: "Ver {count} grupos más",
|
|
268
|
+
pilesMoreOf: "Ver {count} grupos más de {left}",
|
|
269
|
+
pilesShown: "Se muestran {shown} de {count} grupos",
|
|
266
270
|
},
|
|
267
271
|
menu: { empty: "Nada coincide." },
|
|
268
272
|
list: {
|
|
@@ -430,6 +434,7 @@ export const SPANISH_COPY = {
|
|
|
430
434
|
stepFlow: {
|
|
431
435
|
steps: "Pasos",
|
|
432
436
|
position: "Paso {index} de {total}",
|
|
437
|
+
where: "Paso {index} de {total} · {label}",
|
|
433
438
|
announce: "{position}: {title}",
|
|
434
439
|
done: "hecho",
|
|
435
440
|
pending: "pendiente",
|
|
@@ -122,6 +122,16 @@ export type Pile<T> = {
|
|
|
122
122
|
* it shows. Absent, the button counts what is left, as it did before this existed.
|
|
123
123
|
*/
|
|
124
124
|
more?: number | false;
|
|
125
|
+
/**
|
|
126
|
+
* How many piles the level BELOW holds — all of them, not the ones in `piles`.
|
|
127
|
+
*
|
|
128
|
+
* A pile split by surname inside a province can hold 800 surnames and bring 40: the 40 are
|
|
129
|
+
* `piles`, the 800 is this, and the foot under the 40th says «Ver 50 grupos más». Absent,
|
|
130
|
+
* `piles` is the whole level.
|
|
131
|
+
*/
|
|
132
|
+
pilesCount?: number;
|
|
133
|
+
/** What the next «more groups» brings, as `more` does for rows: `false` = no next page. */
|
|
134
|
+
morePiles?: number | false;
|
|
125
135
|
};
|
|
126
136
|
/**
|
|
127
137
|
* The identity of a LEVEL: the field and, if it is a date, its grain.
|
|
@@ -220,6 +230,20 @@ export type Grouping<T> = {
|
|
|
220
230
|
* `pile.items`.
|
|
221
231
|
*/
|
|
222
232
|
onMore?: (pile: Pile<T>) => void;
|
|
233
|
+
/**
|
|
234
|
+
* How many piles the FIRST level holds over the whole set — a register grouped by surname
|
|
235
|
+
* has ~800, and the server brings the first page of them. Absent, `piles` is all of it.
|
|
236
|
+
* The levels below say theirs in `Pile.pilesCount`.
|
|
237
|
+
*/
|
|
238
|
+
pilesCount?: number;
|
|
239
|
+
/** What the next «more groups» at the first level brings: `false` = no next page. */
|
|
240
|
+
morePiles?: number | false;
|
|
241
|
+
/**
|
|
242
|
+
* Asks for the next page of piles: under `parent`, or of the first level when `null`.
|
|
243
|
+
* With this, each presentation offers «Ver N grupos más» after the last pile of a level
|
|
244
|
+
* that holds fewer than it counts; whoever stores the data adds the ones that arrive.
|
|
245
|
+
*/
|
|
246
|
+
onMorePiles?: (parent: Pile<T> | null) => void;
|
|
223
247
|
};
|
|
224
248
|
/**
|
|
225
249
|
* The tree to draw, or `null` if nothing is grouped.
|
|
@@ -317,6 +341,19 @@ export type PileFoot = {
|
|
|
317
341
|
count: number;
|
|
318
342
|
};
|
|
319
343
|
export declare function pileFoot<T>(pile: Pile<T>, canAsk: boolean): PileFoot | null;
|
|
344
|
+
/** Where a level's piles say how many there are and how the next page is asked for: the
|
|
345
|
+
* first level in the grouping, the rest in the pile above them. */
|
|
346
|
+
export type PilesPaging<T> = Pick<Grouping<T>, "pilesCount" | "morePiles" | "onMorePiles">;
|
|
347
|
+
/**
|
|
348
|
+
* The foot of a LEVEL of piles: «Ver 50 grupos más de 760», or «Se muestran 40 de 800
|
|
349
|
+
* grupos» with no next page — drawn after the last pile of the level, indented like them.
|
|
350
|
+
*
|
|
351
|
+
* Context: the same question as `pileFoot`, one step up — `pileFoot` pages the rows of a
|
|
352
|
+
* pile, this pages the piles themselves. `parent` is the pile whose sub-piles these are, or
|
|
353
|
+
* `null` for the first level, whose count lives in the grouping (`root` are its piles).
|
|
354
|
+
* `null` when the level holds every pile it counts, or when nobody counted.
|
|
355
|
+
*/
|
|
356
|
+
export declare function pilesFoot<T>(parent: Pile<T> | null, root: readonly Pile<T>[], paging: PilesPaging<T> | undefined): PileFoot | null;
|
|
320
357
|
/** How many rows there are in total. Adds up the counts of the first level, which already
|
|
321
358
|
* include those below — it does not walk the rows, because it may not have them. */
|
|
322
359
|
export declare function pileCount<T>(piles: readonly Pile<T>[]): number;
|
|
Binary file
|
|
@@ -20,7 +20,7 @@ export type { Density, OpenTarget, Size, Surface, Tone, } from "./types.js";
|
|
|
20
20
|
export { SPANISH_COPY } from "./copy.es.js";
|
|
21
21
|
export { flatten, loose, pick, pickAll, propsOf, slot, slotOf, type Slotted, } from "./slots.js";
|
|
22
22
|
export { dateKey, dateKeysBetween, dateKeyYear, dateLabel, dateTick, grainName, monthName, nextDateKey, } from "./calendar.js";
|
|
23
|
-
export { GRAIN_ORDER, type GroupableField, type GroupGrain, type Grouping, type GroupLevel, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, type Pile, pileCount, type PileFoot, pileFoot, pileIsOpen, pileItems, pileLabel, type PileLabelOf, type PileOf, pilesFrom, pilesOf, } from "./grouping.js";
|
|
23
|
+
export { GRAIN_ORDER, type GroupableField, type GroupGrain, type Grouping, type GroupLevel, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, type Pile, pileCount, type PileFoot, pileFoot, pileIsOpen, pileItems, pileLabel, type PileLabelOf, type PileOf, pilesFoot, pilesFrom, pilesOf, type PilesPaging, } from "./grouping.js";
|
|
24
24
|
export { axisLabels, axisSpans, keyStarts, type Pivot, type PivotAxis, type PivotCell, type PivotCrossing, type PivotFold, pivotFrom, pivotIsEmpty, type PivotKey, type PivotLevel, type PivotMargin, type PivotMeasure, pivotOf, type PivotSource, type PivotSpec, } from "./pivot.js";
|
|
25
25
|
export { chartCompare, type ChartData, chartFromPivot, chartFromRecord, type ChartKind, type ChartMeasure, chartMeasures, type ChartOrder, type ChartPoint, type ChartReading, COUNT_MEASURE, orderChart, SERIES_COLORS, } from "./chart.js";
|
|
26
26
|
export { downloadPivot, pivotSheet, type PivotSheetOptions, pivotXlsx, } from "./pivotSheet.js";
|
|
@@ -46,7 +46,7 @@ export { dateKey, dateKeysBetween, dateKeyYear, dateLabel, dateTick, grainName,
|
|
|
46
46
|
/* THE GROUPING — the vocabulary, which both layers speak: the list builds the
|
|
47
47
|
tree of buckets and the table draws it. It lives here and not in `contexts/list`
|
|
48
48
|
because a primitive cannot import from a context. */
|
|
49
|
-
export { GRAIN_ORDER, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, pileCount, pileFoot, pileIsOpen, pileItems, pileLabel, pilesFrom, pilesOf, } from "./grouping.js";
|
|
49
|
+
export { GRAIN_ORDER, itemPath, levelKey, moveLevel, normalizeLevels, pathKey, pathLabels, pileCount, pileFoot, pileIsOpen, pileItems, pileLabel, pilesFoot, pilesFrom, pilesOf, } from "./grouping.js";
|
|
50
50
|
/* THE PIVOT — the same split: the vocabulary here, the grid in `primitives`.
|
|
51
51
|
That margins come from the base and that a hole is not a zero are rules
|
|
52
52
|
of the CONTRACT, not of the drawing, and that is why they live on this side. */
|
|
@@ -85,6 +85,8 @@ export type UiCopy = {
|
|
|
85
85
|
/** How many fields changed — the Save button's description, for a screen reader. */
|
|
86
86
|
unsavedOne: string;
|
|
87
87
|
unsavedMany: string;
|
|
88
|
+
/** The floating pill's sentence when nobody counted the changes. */
|
|
89
|
+
unsavedAny: string;
|
|
88
90
|
save: string;
|
|
89
91
|
saving: string;
|
|
90
92
|
/** Said, briefly, once what was saved is saved. */
|
|
@@ -342,6 +344,12 @@ export type UiCopy = {
|
|
|
342
344
|
pileMoreOf: string;
|
|
343
345
|
/** Under a short pile with no next page: what it shows of what it counts. */
|
|
344
346
|
pileShown: string;
|
|
347
|
+
/** After the last pile of a level that holds fewer piles than it counts. */
|
|
348
|
+
pilesMore: string;
|
|
349
|
+
/** The same, saying what one press brings: «Show 50 more groups of 760». */
|
|
350
|
+
pilesMoreOf: string;
|
|
351
|
+
/** After a short level with no next page: what it shows of the piles it counts. */
|
|
352
|
+
pilesShown: string;
|
|
345
353
|
};
|
|
346
354
|
menu: {
|
|
347
355
|
empty: string;
|
|
@@ -649,6 +657,8 @@ export type UiCopy = {
|
|
|
649
657
|
steps: string;
|
|
650
658
|
/** Over the step's title: «Step 2 of 3». */
|
|
651
659
|
position: string;
|
|
660
|
+
/** A `SetupCard`'s step with its name: «Step 1 of 2 · Connect Slack». */
|
|
661
|
+
where: string;
|
|
652
662
|
/** Read by the live region on every move: `{position}` is the line above, `{title}`
|
|
653
663
|
* the step's. */
|
|
654
664
|
announce: string;
|
|
@@ -54,6 +54,7 @@ export const ENGLISH_COPY = {
|
|
|
54
54
|
unsaved: "unsaved",
|
|
55
55
|
unsavedOne: "1 change unsaved",
|
|
56
56
|
unsavedMany: "{count} changes unsaved",
|
|
57
|
+
unsavedAny: "Unsaved changes",
|
|
57
58
|
save: "Save",
|
|
58
59
|
saving: "Saving…",
|
|
59
60
|
saved: "Saved",
|
|
@@ -208,6 +209,9 @@ export const ENGLISH_COPY = {
|
|
|
208
209
|
pileMore: "Show {count} more",
|
|
209
210
|
pileMoreOf: "Show {count} more of {left}",
|
|
210
211
|
pileShown: "Showing {shown} of {count}",
|
|
212
|
+
pilesMore: "Show {count} more groups",
|
|
213
|
+
pilesMoreOf: "Show {count} more groups of {left}",
|
|
214
|
+
pilesShown: "Showing {shown} of {count} groups",
|
|
211
215
|
},
|
|
212
216
|
menu: {
|
|
213
217
|
empty: "Nothing matches.",
|
|
@@ -415,6 +419,7 @@ export const ENGLISH_COPY = {
|
|
|
415
419
|
stepFlow: {
|
|
416
420
|
steps: "Steps",
|
|
417
421
|
position: "Step {index} of {total}",
|
|
422
|
+
where: "Step {index} of {total} · {label}",
|
|
418
423
|
announce: "{position}: {title}",
|
|
419
424
|
done: "done",
|
|
420
425
|
pending: "to do",
|
|
@@ -53,8 +53,12 @@ export type ButtonProps = NativeProps<"button", "type" | "disabled" | "title" |
|
|
|
53
53
|
* ignores presses until it is done.
|
|
54
54
|
*/
|
|
55
55
|
busy?: boolean;
|
|
56
|
+
/** It throws work away — «Descartar» beside «Guardar». A `secondary` or `ghost` takes the
|
|
57
|
+
* soft red: the loss reads before the press without a second solid button. It is not a
|
|
58
|
+
* fifth role: the weight stays the role's, this only says what pressing it costs. */
|
|
59
|
+
destructive?: boolean;
|
|
56
60
|
};
|
|
57
|
-
export declare function Button({ children, role, size, surface: surfaceProp, icon: Icon, disabled, title, type, expanded, haspopup, busy, ref, onClick, ...native }: ButtonProps): import("react").JSX.Element;
|
|
61
|
+
export declare function Button({ children, role, size, surface: surfaceProp, icon: Icon, disabled, title, type, expanded, haspopup, busy, destructive, ref, onClick, ...native }: ButtonProps): import("react").JSX.Element;
|
|
58
62
|
export type ButtonLinkProps = NativeProps<"a", "href" | "download" | "title"> & {
|
|
59
63
|
children: ReactNode;
|
|
60
64
|
href: string;
|
|
@@ -84,7 +84,7 @@ function popupAttrs(expanded, haspopup) {
|
|
|
84
84
|
...(expanded === undefined ? {} : { "aria-expanded": expanded }),
|
|
85
85
|
};
|
|
86
86
|
}
|
|
87
|
-
export function Button({ children, role = "secondary", size = "md", surface: surfaceProp, icon: Icon, disabled = false, title, type = "button", expanded, haspopup, busy = false, ref, onClick, ...native }) {
|
|
87
|
+
export function Button({ children, role = "secondary", size = "md", surface: surfaceProp, icon: Icon, disabled = false, title, type = "button", expanded, haspopup, busy = false, destructive = false, ref, onClick, ...native }) {
|
|
88
88
|
const surface = useSurface(surfaceProp);
|
|
89
89
|
const ic = ICON[size];
|
|
90
90
|
const Mark = busy ? LoaderCircle : Icon;
|
|
@@ -94,9 +94,9 @@ export function Button({ children, role = "secondary", size = "md", surface: sur
|
|
|
94
94
|
return;
|
|
95
95
|
}
|
|
96
96
|
onClick?.(event);
|
|
97
|
-
}, ...popupAttrs(expanded, haspopup), "data-ui": "button", "data-emphasis": role, "data-size": size, "data-surface": surface, className: busy
|
|
98
|
-
? `${buttonClasses(role, size, surface)} cursor-progress`
|
|
99
|
-
: buttonClasses(role, size, surface), children: [Mark === undefined ? null : (_jsx(Mark, { className: `${ic.size} shrink-0 ${busy ? "motion-safe:animate-spin" : ""}`, strokeWidth: ic.stroke, "aria-hidden": true })), children] }));
|
|
97
|
+
}, ...popupAttrs(expanded, haspopup), "data-ui": "button", "data-emphasis": role, "data-size": size, "data-surface": surface, ...(destructive ? { "data-destructive": true } : {}), className: busy
|
|
98
|
+
? `${buttonClasses(role, size, surface, destructive)} cursor-progress`
|
|
99
|
+
: buttonClasses(role, size, surface, destructive), children: [Mark === undefined ? null : (_jsx(Mark, { className: `${ic.size} shrink-0 ${busy ? "motion-safe:animate-spin" : ""}`, strokeWidth: ic.stroke, "aria-hidden": true })), children] }));
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* The same button, but it is a real link.
|
|
@@ -11,11 +11,4 @@ import type { Surface } from "../../foundations/types.js";
|
|
|
11
11
|
*/
|
|
12
12
|
export type ButtonRole = "primary" | "secondary" | "ghost" | "danger";
|
|
13
13
|
export type ButtonSize = "sm" | "md" | "lg";
|
|
14
|
-
|
|
15
|
-
*
|
|
16
|
-
* Context: it exists because there are things that LOOK like a button and are
|
|
17
|
-
* not — a menu trigger is the case. Without this, each one copies the classes
|
|
18
|
-
* and by the third copy they no longer match: that is exactly what happened
|
|
19
|
-
* with «+ Crear», which was the only primary button in the product with a
|
|
20
|
-
* different height. */
|
|
21
|
-
export declare function buttonClasses(role?: ButtonRole, size?: ButtonSize, surface?: Surface): string;
|
|
14
|
+
export declare function buttonClasses(role?: ButtonRole, size?: ButtonSize, surface?: Surface, destructive?: boolean): string;
|
|
@@ -60,6 +60,16 @@ const ROLE = {
|
|
|
60
60
|
* and by the third copy they no longer match: that is exactly what happened
|
|
61
61
|
* with «+ Crear», which was the only primary button in the product with a
|
|
62
62
|
* different height. */
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
/* A quiet role that throws work away: «Descartar» beside «Guardar». Soft red, so the loss
|
|
64
|
+
reads before the press, and still under the gold — it is not the screen's last word, and
|
|
65
|
+
it is not `danger`, which is solid and cannot be undone. */
|
|
66
|
+
const LOSES = {
|
|
67
|
+
canvas: "border border-transparent bg-bad/8 text-bad hover:bg-bad/14",
|
|
68
|
+
chrome: "border border-transparent bg-chrome-bad/12 text-chrome-bad hover:bg-chrome-bad/20",
|
|
69
|
+
};
|
|
70
|
+
export function buttonClasses(role = "secondary", size = "md", surface = "canvas", destructive = false) {
|
|
71
|
+
const look = destructive && (role === "secondary" || role === "ghost")
|
|
72
|
+
? LOSES[surface]
|
|
73
|
+
: ROLE[role][surface];
|
|
74
|
+
return `inline-flex shrink-0 items-center justify-center rounded-ui-button whitespace-nowrap transition-[background-color,border-color,filter,color] duration-(--duration-instant) ease-(--ease-out) disabled:pointer-events-none disabled:opacity-45 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary ${SIZE[size]} ${WEIGHT[role]} ${look}`;
|
|
65
75
|
}
|
|
@@ -38,6 +38,11 @@ export interface MenuOption {
|
|
|
38
38
|
/** It destroys or undoes — «Anular», «Eliminar»: the label and its icon in the danger tone,
|
|
39
39
|
* so it is read before it is pressed. Put such options in a group of their own, last. */
|
|
40
40
|
danger?: boolean;
|
|
41
|
+
/** A real link: the row is an `<a>` — a new tab with the middle button or ⌘, the
|
|
42
|
+
* application's router (React Aria's `RouterProvider`), «copy link». «Ver el sitio». */
|
|
43
|
+
href?: string;
|
|
44
|
+
/** With `href`, where it opens: `_blank` for another tab (`rel="noreferrer"` is added). */
|
|
45
|
+
target?: "_blank";
|
|
41
46
|
/** The option opens a SUBMENU with these options instead of running. Its own `onSelect`
|
|
42
47
|
* and `checked` are ignored — a row that opens something does not also do something.
|
|
43
48
|
* Children may carry `items` too, but a third level is usually a dialog in disguise. */
|
|
@@ -64,6 +69,12 @@ export interface MenuGroup {
|
|
|
64
69
|
* would hide what the search finds.
|
|
65
70
|
*/
|
|
66
71
|
collapsible?: boolean;
|
|
72
|
+
/**
|
|
73
|
+
* The options in ONE row beside the label, as icon toggles: «Tema ☀ ☾ 🖥». For a short
|
|
74
|
+
* choice of three that reads faster as marks than as three rows — the theme in an account
|
|
75
|
+
* menu. Each option needs its `icon`; its `label` names it (title and accessible name).
|
|
76
|
+
*/
|
|
77
|
+
inline?: boolean;
|
|
67
78
|
options: MenuOption[];
|
|
68
79
|
}
|
|
69
80
|
declare const WIDTH: {
|
|
@@ -79,7 +90,7 @@ export { menuTriggerClasses };
|
|
|
79
90
|
export declare function Menu({ label, groups, onSelect, surface, align, icon: Trigger,
|
|
80
91
|
/** The menu as a control of a list ("filters ▾") carries the chevron; the
|
|
81
92
|
* actions `⋯` does not, because the icon already says there is more. */
|
|
82
|
-
chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, size, title, closeOnSelect, count, current, layout, }: {
|
|
93
|
+
chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, size, title, closeOnSelect, count, current, layout, header, trigger, placement, }: {
|
|
83
94
|
label: string;
|
|
84
95
|
groups: readonly MenuGroup[];
|
|
85
96
|
onSelect?: (id: string) => void;
|
|
@@ -130,6 +141,16 @@ chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, s
|
|
|
130
141
|
/** `columns` lays the sections side by side: a big menu of an application bar, seen
|
|
131
142
|
* whole. Stacked on a phone. */
|
|
132
143
|
layout?: "list" | "columns";
|
|
144
|
+
/** Above the options, not one of them: who the account menu belongs to — the avatar, the
|
|
145
|
+
* name, the organization. Read, not pressed. */
|
|
146
|
+
header?: ReactNode;
|
|
147
|
+
/** The trigger's content in place of the icon and the label — a whole row («(AG) Ana
|
|
148
|
+
* Gutiérrez · Admin ⌃⌄») that opens the menu. It names the button by what it shows;
|
|
149
|
+
* `label` names the panel. */
|
|
150
|
+
trigger?: ReactNode;
|
|
151
|
+
/** Where the panel opens. Below by default (`align` picks the side); a trigger at the
|
|
152
|
+
* bottom of the window — the account at the foot of a sidebar — opens it above. */
|
|
153
|
+
placement?: "bottom start" | "bottom end" | "top start" | "top end";
|
|
133
154
|
}): import("react").JSX.Element;
|
|
134
155
|
/**
|
|
135
156
|
* The panel of a `Menu`: its groups and rows, and the submenus hanging from them. Internal —
|
|
@@ -46,7 +46,7 @@ export { menuTriggerClasses };
|
|
|
46
46
|
export function Menu({ label, groups, onSelect, surface = "canvas", align = "start", icon: Trigger,
|
|
47
47
|
/** The menu as a control of a list ("filters ▾") carries the chevron; the
|
|
48
48
|
* actions `⋯` does not, because the icon already says there is more. */
|
|
49
|
-
chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, count, current = false, layout = "list", }) {
|
|
49
|
+
chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, count, current = false, layout = "list", header, trigger, placement, }) {
|
|
50
50
|
const copy = useUiCopy();
|
|
51
51
|
const { contains } = useFilter({ sensitivity: "base" });
|
|
52
52
|
const byId = indexOptions(groups.flatMap((g) => g.options));
|
|
@@ -55,22 +55,28 @@ chevron = true, active = false, iconOnly = false, variant = "button", searchPlac
|
|
|
55
55
|
option?.onSelect?.();
|
|
56
56
|
onSelect?.(String(key));
|
|
57
57
|
}, emptyText: emptyText ?? copy.menu.empty }));
|
|
58
|
-
return (_jsxs(MenuTrigger, { children: [_jsx(AriaButton, { "data-ui": "menu.trigger", "aria-label": iconOnly ? label : undefined, ...(role === undefined ? {} : { "data-emphasis": role }), className: ({ isPressed, isFocusVisible }) =>
|
|
59
|
-
?
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
58
|
+
return (_jsxs(MenuTrigger, { children: [_jsx(AriaButton, { "data-ui": "menu.trigger", "aria-label": iconOnly && trigger === undefined ? label : undefined, ...(role === undefined ? {} : { "data-emphasis": role }), className: ({ isPressed, isFocusVisible }) => trigger !== undefined
|
|
59
|
+
? `flex w-full min-w-0 cursor-default items-center gap-2 rounded-control p-1.5 text-left outline-0 transition-colors duration-(--duration-instant) ${surface === "chrome"
|
|
60
|
+
? "hover:bg-chrome-ink/10 data-pressed:bg-chrome-ink/10"
|
|
61
|
+
: "hover:bg-ink/6 data-pressed:bg-ink/6"} ${isFocusVisible ? "outline-2 -outline-offset-2 outline-primary" : ""}`
|
|
62
|
+
: role === undefined
|
|
63
|
+
? menuTriggerClasses({
|
|
64
|
+
variant,
|
|
65
|
+
surface,
|
|
66
|
+
active,
|
|
67
|
+
current,
|
|
68
|
+
open: isPressed,
|
|
69
|
+
focusVisible: isFocusVisible,
|
|
70
|
+
iconOnly,
|
|
71
|
+
})
|
|
72
|
+
: `${buttonClasses(role, size, surface)} gap-1.5`, children: trigger !== undefined ? (trigger) : (
|
|
73
|
+
/* `title` on a span: React Aria's button does not forward it. */
|
|
74
|
+
_jsxs("span", { className: "contents", title: title ?? (iconOnly ? label : undefined), children: [Trigger === undefined ? (iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null) : (_jsx(Trigger, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })), iconOnly ? null : label, iconOnly || count === undefined ? null : (_jsx(Count, { value: count, surface: surface })), chevron && !iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null] })) }), _jsxs(Popover, { placement: placement ?? (align === "end" ? "bottom end" : "bottom start"), className: layout === "columns" ? COLUMNS_WIDTH : WIDTH[width], children: [header === undefined ? null : (_jsx("div", { "data-ui": "menu.header", className: "border-b border-line px-3 py-2.5", children: header })), searchPlaceholder === undefined ? (menu) : (
|
|
75
|
+
/* The search box stays at the top: in a menu of twenty-five entries,
|
|
76
|
+
scrolling loses exactly the control that explains why only three are
|
|
77
|
+
visible. It filters on label AND hint — half the entries of this
|
|
78
|
+
product are told apart only by the hint. */
|
|
79
|
+
_jsxs(Autocomplete, { filter: contains, children: [_jsx(SearchField, { "aria-label": searchPlaceholder, autoFocus: true, className: "border-b border-line px-2 pt-2 pb-2", children: _jsx(Input, { placeholder: searchPlaceholder, className: "h-(--size-control-sm) w-full rounded-control border border-line-strong bg-surface px-2.5 text-meta text-ink outline-0 placeholder:text-muted focus-visible:border-primary" }) }), menu] }))] })] }));
|
|
74
80
|
}
|
|
75
81
|
/**
|
|
76
82
|
* The panel of a `Menu`: its groups and rows, and the submenus hanging from them. Internal —
|
|
@@ -109,7 +115,12 @@ export function MenuList({ label, groups, onAction, closeOnSelect, emptyText, wi
|
|
|
109
115
|
const Icon = o.icon;
|
|
110
116
|
const opens = o.items !== undefined;
|
|
111
117
|
const checked = !opens && o.checked === true;
|
|
112
|
-
return (_jsxs(MenuItem, { id: o.id, textValue: o.hint === undefined ? o.label : `${o.label} ${o.hint}`, isDisabled: o.disabled,
|
|
118
|
+
return (_jsxs(MenuItem, { id: o.id, textValue: o.hint === undefined ? o.label : `${o.label} ${o.hint}`, isDisabled: o.disabled, ...(o.href === undefined || opens
|
|
119
|
+
? {}
|
|
120
|
+
: {
|
|
121
|
+
href: o.href,
|
|
122
|
+
...(o.target === undefined ? {} : { target: o.target, rel: "noreferrer" }),
|
|
123
|
+
}), "data-ui": "menu.item", className: `flex w-full cursor-default rounded-ui-option ${hasHints ? "items-start py-1.5" : "items-center py-1"} gap-2 ${nested ? "pr-2 pl-(--spacing-indent)" : "px-2"} text-left outline-0 transition-colors duration-(--duration-instant) ${o.danger === true
|
|
113
124
|
? "data-focused:bg-danger/10"
|
|
114
125
|
: "data-focused:bg-ui-option-active data-open:bg-ui-option-active"} disabled:opacity-45`, children: [hasMarks ? (_jsx("span", { className: `${hasHints ? "mt-0.5" : ""} flex size-(--size-icon-sm) shrink-0 items-center justify-center`, children: checked ? (_jsx(Check, { className: "size-(--size-icon-sm) text-primary", strokeWidth: 2.5, "aria-hidden": true })) : Icon !== undefined ? (_jsx(Icon, { className: `size-(--size-icon-sm) ${o.danger === true ? "text-danger" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })) : null })) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${o.danger === true
|
|
115
126
|
? "text-danger"
|
|
@@ -121,6 +132,21 @@ export function MenuList({ label, groups, onAction, closeOnSelect, emptyText, wi
|
|
|
121
132
|
const key = sectionKey(g, gi);
|
|
122
133
|
const folding = folds(g);
|
|
123
134
|
const open = !folding || unfolded.has(key);
|
|
135
|
+
if (g.inline === true) {
|
|
136
|
+
/* One row: the label, then each option as an icon toggle. They are still menu
|
|
137
|
+
items — the arrows walk them and Enter picks — only laid side by side. */
|
|
138
|
+
return (_jsxs(MenuSection, { "data-ui": "menu.section", "data-inline": true,
|
|
139
|
+
/* A choice of one: each mark is a `menuitemradio`, and the chosen one is
|
|
140
|
+
`aria-checked` — the tint alone told a screen reader nothing. */
|
|
141
|
+
selectionMode: "single", disallowEmptySelection: true, selectedKeys: g.options.filter((o) => o.checked === true).map((o) => o.id), className: `${SECTION[layout]} flex items-center gap-1 px-2 py-1`, children: [g.label === undefined ? null : (_jsx(Header, { className: "min-w-0 flex-1 truncate text-meta text-ink", children: g.label })), g.options.map((o) => {
|
|
142
|
+
const Icon = o.icon;
|
|
143
|
+
return (_jsx(MenuItem, { id: o.id, textValue: o.label, "aria-label": o.label, isDisabled: o.disabled,
|
|
144
|
+
/* Picking a theme shows it at once: the menu stays to compare. */
|
|
145
|
+
shouldCloseOnSelect: false, "data-ui": "menu.item", ...(o.checked === true ? { "data-checked": true } : {}), className: `flex size-(--size-control-sm) shrink-0 cursor-default items-center justify-center rounded-control outline-0 transition-colors duration-(--duration-instant) data-focused:bg-ui-option-active ${o.checked === true
|
|
146
|
+
? "bg-ink/8 text-ink inset-ring inset-ring-line-strong"
|
|
147
|
+
: "text-muted"}`, children: _jsx("span", { title: o.label, className: "contents", children: Icon === undefined ? (_jsx("span", { className: "text-micro", children: o.label })) : (_jsx(Icon, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) }) }, o.id));
|
|
148
|
+
})] }, key));
|
|
149
|
+
}
|
|
124
150
|
return (_jsxs(MenuSection, { "data-ui": "menu.section", className: SECTION[layout], children: [g.label === undefined ? null : folding ? (
|
|
125
151
|
/* A folded section is a ROW you press — it is the door to the options, so it
|
|
126
152
|
reads as one (ink, the row's size) and says how many wait behind it. The
|
|
@@ -68,6 +68,10 @@ export interface DataColumn<T> {
|
|
|
68
68
|
* which is the normal case — a table with everything colored highlights
|
|
69
69
|
* nothing. */
|
|
70
70
|
tone?: (row: T) => Tone | undefined;
|
|
71
|
+
/** How the tone is carried: `fill` paints the cell (the default); `tag` writes the value
|
|
72
|
+
* as a `Tag` of that tone — a column of STATES («Observado», «Habilitado») — and the sheet
|
|
73
|
+
* derived from these columns draws it the same way (`SheetColumn.look`). */
|
|
74
|
+
look?: "fill" | "tag";
|
|
71
75
|
/** Why it is painted, on hover. */
|
|
72
76
|
note?: (row: T) => string | undefined;
|
|
73
77
|
numeric?: boolean;
|
|
@@ -182,7 +186,7 @@ export type GroupColumn<T> = {
|
|
|
182
186
|
/** How that key is read. */
|
|
183
187
|
labelOf: (key: string) => string;
|
|
184
188
|
};
|
|
185
|
-
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, }: {
|
|
189
|
+
export declare function DataTable<T extends object>({ data, columns, getRowId, sort, onSortChange, levels, selected, onSelectedChange, height, onRowClick, rowActions, totals, collapsed, onGroupToggle, piles, onMore, pilesCount, morePiles, onMorePiles, create, copyable, onReorder, }: {
|
|
186
190
|
data: readonly T[];
|
|
187
191
|
columns: readonly DataColumn<T>[];
|
|
188
192
|
getRowId: (row: T) => string;
|
|
@@ -226,6 +230,13 @@ export declare function DataTable<T extends object>({ data, columns, getRowId, s
|
|
|
226
230
|
/** A pile shows its first page and counts them all: this asks for the next ones, and
|
|
227
231
|
* the table offers it under each pile that holds fewer than it counts. */
|
|
228
232
|
onMore?: (pile: Pile<T>) => void;
|
|
233
|
+
/** How many piles the first level holds over the whole set, when `piles` is its first
|
|
234
|
+
* page — see `Grouping.pilesCount`. The levels below say theirs in `Pile.pilesCount`. */
|
|
235
|
+
pilesCount?: number;
|
|
236
|
+
/** What the next «more groups» brings at the first level: `false` = no next page. */
|
|
237
|
+
morePiles?: number | false;
|
|
238
|
+
/** Asks for the next page of piles under `parent` (`null` = the first level). */
|
|
239
|
+
onMorePiles?: (parent: Pile<T> | null) => void;
|
|
229
240
|
/** Write a new record as a row of the list. See the file's header. */
|
|
230
241
|
create?: DataTableCreate<T>;
|
|
231
242
|
/** The cells' copy buttons, on by default. `false` takes them off the whole table; a
|