@sincpro/web-ui 2.1.0 → 2.3.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 +111 -0
- package/dist/components/attachments/Attachments.d.ts +7 -1
- package/dist/components/attachments/Attachments.js +8 -2
- package/dist/components/board/Board.d.ts +32 -2
- package/dist/components/board/Board.js +27 -4
- package/dist/components/board/index.d.ts +1 -1
- package/dist/components/board/index.js +2 -1
- package/dist/components/listing/GroupingLevels.js +11 -9
- package/dist/components/listing/RecordCard.js +1 -1
- package/dist/components/listing/Row.js +2 -2
- package/dist/components/navigation/NavigationTree.js +37 -10
- package/dist/components/search/CriteriaBuilder.js +3 -2
- package/dist/components/search/CriteriaChips.js +6 -5
- package/dist/components/search/JoinWord.js +1 -1
- package/dist/components/search/SearchBar.js +68 -29
- package/dist/components/shell/AppFrame.d.ts +18 -2
- package/dist/components/shell/AppFrame.js +143 -12
- package/dist/components/shell/Sidebar.d.ts +39 -0
- package/dist/components/shell/Sidebar.js +57 -0
- package/dist/components/shell/TopBar.d.ts +10 -1
- package/dist/components/shell/TopBar.js +18 -13
- package/dist/components/shell/brandMark.d.ts +17 -0
- package/dist/components/shell/brandMark.js +9 -0
- package/dist/components/shell/index.d.ts +3 -0
- package/dist/components/shell/index.js +6 -0
- package/dist/components/shell/sidebarDrawer.d.ts +26 -0
- package/dist/components/shell/sidebarDrawer.js +22 -0
- package/dist/foundations/copy.d.ts +13 -0
- package/dist/foundations/copy.es.js +12 -5
- package/dist/foundations/copy.js +12 -5
- package/dist/foundations/variants.js +19 -2
- package/dist/primitives/block/Block.js +1 -1
- package/dist/primitives/button/Button.d.ts +3 -1
- package/dist/primitives/button/Button.js +6 -6
- package/dist/primitives/choice/SegmentedControl.d.ts +4 -1
- package/dist/primitives/choice/SegmentedControl.js +35 -7
- package/dist/primitives/dialog/Dialog.d.ts +1 -1
- package/dist/primitives/dialog/Dialog.js +2 -2
- package/dist/primitives/field/CardNumberInput.js +1 -1
- package/dist/primitives/field/Checks.d.ts +14 -0
- package/dist/primitives/field/Checks.js +12 -4
- package/dist/primitives/field/DropZone.d.ts +22 -3
- package/dist/primitives/field/DropZone.js +33 -12
- package/dist/primitives/field/DurationInput.js +1 -1
- package/dist/primitives/field/Field.js +7 -7
- package/dist/primitives/field/PatternInput.js +1 -1
- package/dist/primitives/field/RichTextEditor.js +2 -2
- package/dist/primitives/field/SignatureInput.js +1 -1
- package/dist/primitives/field/aria.d.ts +2 -2
- package/dist/primitives/field/aria.js +5 -5
- package/dist/primitives/field/index.d.ts +1 -1
- package/dist/primitives/field/index.js +1 -1
- package/dist/primitives/menu/Menu.d.ts +29 -9
- package/dist/primitives/menu/Menu.js +77 -22
- package/dist/primitives/overlay/Popover.js +2 -2
- package/dist/primitives/picker/Picker.js +3 -3
- package/dist/primitives/picker/TagsField.js +1 -1
- package/dist/primitives/table/EditableTable.js +2 -2
- package/dist/primitives/table/ReportTable.js +1 -1
- package/dist/primitives/table/Table.js +2 -2
- package/dist/primitives/tabs/Tabs.js +2 -28
- package/dist/primitives/tag/Count.d.ts +23 -0
- package/dist/primitives/tag/Count.js +59 -0
- package/dist/primitives/tag/Tag.d.ts +9 -0
- package/dist/primitives/tag/Tag.js +14 -1
- package/dist/primitives/tag/Tags.js +6 -7
- package/dist/primitives/tag/index.d.ts +1 -0
- package/dist/primitives/tag/index.js +3 -0
- package/dist/primitives/value/Metric.d.ts +7 -2
- package/dist/primitives/value/Metric.js +14 -6
- package/dist/tokens.css +306 -72
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -131,6 +131,117 @@ a screen needs no change to work in both.
|
|
|
131
131
|
</ThemeProvider>
|
|
132
132
|
```
|
|
133
133
|
|
|
134
|
+
#### Your brand
|
|
135
|
+
|
|
136
|
+
The colours a brand owns read a `--brand-*` variable before the system's value. Set them once,
|
|
137
|
+
on `:root`, and every palette — light, dark, and a light subtree inside a dark page — follows:
|
|
138
|
+
|
|
139
|
+
```css
|
|
140
|
+
:root {
|
|
141
|
+
--brand-accent: #d4a73a; /* the primary action */
|
|
142
|
+
--brand-accent-hover: #c0942c;
|
|
143
|
+
--brand-primary: #1f3a6e; /* links, the current place */
|
|
144
|
+
--brand-primary-hover: #152a52;
|
|
145
|
+
--brand-chrome: #10203f; /* the application bar */
|
|
146
|
+
--brand-chrome-raised: #1a2c52;
|
|
147
|
+
--brand-chrome-edge: #10203f;
|
|
148
|
+
--brand-ground: #f7f8fa; /* the page's paper */
|
|
149
|
+
--brand-surface: #ffffff; /* raised boxes, menus */
|
|
150
|
+
|
|
151
|
+
--brand-dark-accent: #e0b850; /* the same, for the dark palette */
|
|
152
|
+
--brand-dark-chrome: #0a1428;
|
|
153
|
+
--brand-dark-ground: #121417;
|
|
154
|
+
|
|
155
|
+
--brand-radius: 0.5; /* the corners: 0 square everywhere · 1 the system's · 1.5 rounder */
|
|
156
|
+
}
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
The full list is `ground`, `surface`, `line`, `line-strong`, `ink`, `muted`, `accent`,
|
|
160
|
+
`accent-hover`, `on-accent`, `primary`, `primary-hover`, `chrome`, `chrome-raised`, `chrome-edge`,
|
|
161
|
+
`chrome-accent` and `chrome-link`; `--brand-<token>` is the light palette's and
|
|
162
|
+
`--brand-dark-<token>` the dark's. One left unset keeps the system's value. Do not
|
|
163
|
+
override `--color-*` directly: those are redefined per theme, so an override on `:root` loses to
|
|
164
|
+
`[data-theme="light"]` and leaks into the dark palette. The system measures its own contrasts;
|
|
165
|
+
your brand's are checked by Storybook's a11y pass if you render your stories with it.
|
|
166
|
+
|
|
167
|
+
The corners are one knob: `--brand-radius` multiplies the whole radius scale (`mark`, `control`,
|
|
168
|
+
`box`, `panel`, `pill`), so the steps keep their proportion and a dropdown stays concentric with
|
|
169
|
+
its rows. `0` squares everything, the capsules too. A single step can still be set on its own —
|
|
170
|
+
`--brand-radius-control: 6px`. Both go on `:root`.
|
|
171
|
+
|
|
172
|
+
#### Customizing a component
|
|
173
|
+
|
|
174
|
+
The brand changes the whole product. To change **one component** — square buttons for a
|
|
175
|
+
till, a cooler menu, cards without a border — set its `--ui-*` tokens, on `:root` for the
|
|
176
|
+
whole application or on any element for a zone. Each one falls back to the system's token, so
|
|
177
|
+
setting nothing changes nothing, and each resolves on the element, so the dark theme still
|
|
178
|
+
follows:
|
|
179
|
+
|
|
180
|
+
```css
|
|
181
|
+
:root {
|
|
182
|
+
--ui-button-radius: 0;
|
|
183
|
+
--ui-popover-bg: var(--color-ground);
|
|
184
|
+
}
|
|
185
|
+
.till {
|
|
186
|
+
--ui-control-radius: 0; /* only inside this zone */
|
|
187
|
+
}
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
| Component | Tokens |
|
|
191
|
+
| ----------------------------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
192
|
+
| `Button`, `ButtonLink` | `--ui-button-radius` |
|
|
193
|
+
| `IconButton`, `IconLink` | `--ui-icon-button-radius` |
|
|
194
|
+
| Inputs, selects, date and pickers' boxes | `--ui-control-radius`, `--ui-control-bg`, `--ui-control-border` |
|
|
195
|
+
| Menus, lists, popovers, the cuts panel | `--ui-popover-radius`, `--ui-popover-bg`, `--ui-popover-border`, `--ui-popover-shadow` |
|
|
196
|
+
| A row inside them (menu item, option) | `--ui-option-radius`, `--ui-option-active-bg` |
|
|
197
|
+
| `Dialog` | `--ui-dialog-radius`, `--ui-dialog-bg` |
|
|
198
|
+
| `Block`, `RecordCard`, `BoardTile`, `Metric` | `--ui-card-radius`, `--ui-card-bg`, `--ui-card-border` |
|
|
199
|
+
| `Tag`, `Tags`, the search bar's chips | `--ui-tag-radius` |
|
|
200
|
+
| `SearchBar`'s field | `--ui-search-radius` (and the control's bg and border) |
|
|
201
|
+
| The sidebar on the canvas | `--ui-sidebar-bg`, `--ui-sidebar-border` |
|
|
202
|
+
| `NavigationTree` | `--ui-nav-radius`, `--ui-nav-current-bg` |
|
|
203
|
+
| Table headers (`DataTable`, `EditableTable`, `ReportTable`) | `--ui-table-head-bg` |
|
|
204
|
+
|
|
205
|
+
What a token does not cover, a **part** does. Every customizable piece names its root
|
|
206
|
+
`data-ui="<component>"` and its parts `data-ui="<component>.<part>"`, with its variant beside
|
|
207
|
+
(`data-emphasis`, `data-size`, `data-surface`, `data-tone`) — stable names for your CSS, instead
|
|
208
|
+
of classes that change with the next refactor:
|
|
209
|
+
|
|
210
|
+
```css
|
|
211
|
+
[data-ui="button"][data-emphasis="primary"] {
|
|
212
|
+
letter-spacing: 0.02em;
|
|
213
|
+
}
|
|
214
|
+
[data-ui="popover"] {
|
|
215
|
+
backdrop-filter: blur(8px);
|
|
216
|
+
}
|
|
217
|
+
```
|
|
218
|
+
|
|
219
|
+
The parts: `button`, `icon-button`, `control`, `popover`, `menu`, `menu.trigger`,
|
|
220
|
+
`menu.section`, `menu.item`, `menu.fold`, `dialog`, `block`, `record-card`, `board.tile`,
|
|
221
|
+
`metric`, `tag`, `tags.item`, `search`, `search.field`, `search.chip`, `search.panel`,
|
|
222
|
+
`search.suggestions`, `table`, `table.head`, `topbar`, `topbar.brand`, `topbar.menus`,
|
|
223
|
+
`topbar.actions`, `topbar.user`, `frame`, `frame.bar`, `frame.sidebar`, `frame.main`, `sidebar`,
|
|
224
|
+
`sidebar.brand`, `sidebar.user`, `sidebar.nav`, `sidebar.account`, `navigation`,
|
|
225
|
+
`navigation.item`. Put your rules in a cascade layer above web-ui's, or outside any layer.
|
|
226
|
+
|
|
227
|
+
#### Living beside a site's own CSS
|
|
228
|
+
|
|
229
|
+
The package's styles are in cascade layers (`@layer base`, `utilities`), and **CSS outside any
|
|
230
|
+
layer always beats CSS inside one** — so a site's global `h1 { font-family: … }` restyles every
|
|
231
|
+
heading web-ui draws. Put the site's element rules in a layer too:
|
|
232
|
+
|
|
233
|
+
```css
|
|
234
|
+
@layer base {
|
|
235
|
+
h1,
|
|
236
|
+
h2 {
|
|
237
|
+
font-family: var(--font-display);
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
or scope them to the site's own pages (`.site h1`). Classes are not affected; element selectors
|
|
243
|
+
and `*` are.
|
|
244
|
+
|
|
134
245
|
Rules a new token must follow: define it in **both** palettes with its contrast on the same line
|
|
135
246
|
(`tests/tokens.test.ts` measures each theme against its own ground, surface and chrome, and fails
|
|
136
247
|
if a light token has no dark twin or the two dark copies drift); the gold stays the primary
|
|
@@ -42,6 +42,12 @@ export type AttachmentsProps = {
|
|
|
42
42
|
onRetry?: (file: AttachmentFile) => void;
|
|
43
43
|
/** The browser's `accept` list for the file dialog (`".pdf,image/*"`). */
|
|
44
44
|
accept?: string;
|
|
45
|
+
/** Several files per drop or choice, in one `onAdd` — on by default: a record gathers
|
|
46
|
+
* scans and photos in batches. `false` takes one at a time. */
|
|
47
|
+
multiple?: boolean;
|
|
48
|
+
/** At most this many per batch (a gallery's 30 photos); the zone says how many it left
|
|
49
|
+
* out. */
|
|
50
|
+
max?: number;
|
|
45
51
|
/** `read` for a record that can no longer change. By default, the form's mode. */
|
|
46
52
|
mode?: FormMode;
|
|
47
53
|
/** The accessible name of the list. «Adjuntos» by default. */
|
|
@@ -53,4 +59,4 @@ export type AttachmentsProps = {
|
|
|
53
59
|
* text every minute. */
|
|
54
60
|
now?: Date;
|
|
55
61
|
};
|
|
56
|
-
export declare function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, mode, label, empty, now, }: AttachmentsProps): import("react").JSX.Element;
|
|
62
|
+
export declare function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, multiple, max, mode, label, empty, now, }: AttachmentsProps): import("react").JSX.Element;
|
|
@@ -32,7 +32,7 @@ function Thumb({ file, kind }) {
|
|
|
32
32
|
say it twice. */
|
|
33
33
|
_jsx("span", { "aria-hidden": true, className: "flex size-(--size-control-lg) shrink-0 flex-col items-center justify-center gap-0.5 overflow-clip rounded-control border border-line bg-ink/4 text-muted", children: picture === undefined ? (_jsxs(_Fragment, { children: [_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 1.75 }), extension === "" ? null : (_jsx("span", { className: "text-micro leading-none font-medium uppercase", children: extension }))] })) : (_jsx("img", { src: picture, alt: "", loading: "lazy", className: "size-full object-cover" })) }));
|
|
34
34
|
}
|
|
35
|
-
export function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, mode, label, empty, now, }) {
|
|
35
|
+
export function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry, accept, multiple = true, max, mode, label, empty, now, }) {
|
|
36
36
|
const copy = useUiCopy();
|
|
37
37
|
const toast = useToastIfAny();
|
|
38
38
|
const editable = useFormMode(mode) !== "read";
|
|
@@ -89,5 +89,11 @@ export function Attachments({ files, onAdd, onRemove, onRestore, onOpen, onRetry
|
|
|
89
89
|
_jsxs("p", { id: detailId, role: "alert", className: "flex min-w-0 items-start gap-1.5 text-meta text-bad", children: [_jsx(TriangleAlert, { "aria-hidden": true, className: "mt-px size-(--size-icon-sm) shrink-0", strokeWidth: 2 }), _jsx("span", { className: "min-w-0", children: file.error ?? copy.attachments.failed })] })) : (_jsxs("p", { id: detailId, className: "flex min-w-0 flex-wrap items-center gap-x-2 gap-y-1 text-meta text-muted", children: [file.size === undefined ? null : (_jsx("span", { className: "tabular-nums whitespace-nowrap", children: formatFileSize(file.size, copy.locale) })), file.by === undefined ? null : (_jsx(UserChip, { name: file.by, size: "sm", ...(file.byAvatar === undefined ? {} : { src: file.byAvatar }) })), file.at === undefined ? null : (_jsx(DateValue, { when: file.at, ...(now === undefined ? {} : { now }) }))] }))] }), _jsxs("div", { className: "flex shrink-0 items-center gap-1", children: [status === "failed" && onRetry !== undefined ? (_jsx(Button, { role: "ghost", size: "sm", icon: RotateCcw, "aria-describedby": nameId, onClick: () => onRetry(file), children: copy.attachments.retry })) : null, status === "ready" && file.url !== undefined ? (_jsx(IconLink, { icon: Download, label: copy.attachments.download, href: file.url, download: file.name, tone: "normal", "aria-describedby": nameId })) : null, editable && onRemove !== undefined ? (_jsx(IconButton, { icon: status === "ready" ? Trash2 : X, label: status === "uploading"
|
|
90
90
|
? copy.attachments.cancelUpload
|
|
91
91
|
: copy.attachments.remove, tone: status === "ready" ? "danger" : "normal", "data-attachment-remove": true, "aria-describedby": nameId, onClick: () => remove(file, index) })) : null] })] }, file.id));
|
|
92
|
-
}) })), adding ? (_jsx(DropZone, { id: dropId, mode: "edit", label: files.length === 0 ? (empty ?? copy.attachments.emptyAdd) : copy.attachments.add, ...(accept === undefined ? {} : { accept }),
|
|
92
|
+
}) })), adding ? (_jsx(DropZone, { id: dropId, mode: "edit", label: files.length === 0 ? (empty ?? copy.attachments.emptyAdd) : copy.attachments.add, ...(accept === undefined ? {} : { accept }), ...(multiple
|
|
93
|
+
? {
|
|
94
|
+
multiple: true,
|
|
95
|
+
onFiles: onAdd,
|
|
96
|
+
...(max === undefined ? {} : { max }),
|
|
97
|
+
}
|
|
98
|
+
: { onFile: (file) => onAdd([file]) }) })) : null] }));
|
|
93
99
|
}
|
|
@@ -18,7 +18,31 @@ import type { ReactNode } from "react";
|
|
|
18
18
|
*
|
|
19
19
|
* It knows no domain and folds nothing: the application reads its data with the filters and
|
|
20
20
|
* hands each tile what to draw — the same `Pivot` the list's chart and pivot read.
|
|
21
|
+
*
|
|
22
|
+
* ── Each tile reads on its own, and says so ─────────────────────────
|
|
23
|
+
*
|
|
24
|
+
* N tiles are N readings, and they land one at a time. A board that waited for all of them
|
|
25
|
+
* blanked the page for its slowest tile; one that drew nothing for a failed tile left a hole
|
|
26
|
+
* nobody could explain. So a tile takes its `state` — reading, ready, or failed with the
|
|
27
|
+
* server's refusal and a way to ask again — and draws it in ITS OWN space, the height of the
|
|
28
|
+
* chart it will hold (`--size-tile-body`), so a neighbour landing never moves the grid. The
|
|
29
|
+
* board's own `state` is the same for what the board reads as a whole: its headline numbers.
|
|
30
|
+
* The application (or web-framework's boards) decides each state; web-ui only draws it.
|
|
21
31
|
*/
|
|
32
|
+
/** What a tile — or the board's own headline reading — is doing. */
|
|
33
|
+
export type BoardState = {
|
|
34
|
+
status: "ready";
|
|
35
|
+
} | {
|
|
36
|
+
status: "loading";
|
|
37
|
+
} | {
|
|
38
|
+
status: "failed";
|
|
39
|
+
/** Why, in the server's words: the refusal, not «something went wrong». */
|
|
40
|
+
sentence: string;
|
|
41
|
+
/** The technical text — a status, an id — that «Copiar el error» carries. */
|
|
42
|
+
detail?: string;
|
|
43
|
+
/** Ask again. Present = the failure offers «Reintentar». */
|
|
44
|
+
onRetry?: () => void;
|
|
45
|
+
};
|
|
22
46
|
export type BoardProps = {
|
|
23
47
|
/** What the board is about: «Ventas». */
|
|
24
48
|
title: string;
|
|
@@ -27,10 +51,13 @@ export type BoardProps = {
|
|
|
27
51
|
filters?: ReactNode;
|
|
28
52
|
/** The headline numbers — `Metrics` — read before the tiles. */
|
|
29
53
|
metrics?: ReactNode;
|
|
54
|
+
/** What the board reads as a whole — its headline numbers. Reading, they are a quiet strip
|
|
55
|
+
* of their size; failed, the refusal takes their place. The tiles keep their own states. */
|
|
56
|
+
state?: BoardState;
|
|
30
57
|
/** The tiles: `BoardTile`s. */
|
|
31
58
|
children: ReactNode;
|
|
32
59
|
};
|
|
33
|
-
export declare function Board({ title, description, filters, metrics, children }: BoardProps): import("react").JSX.Element;
|
|
60
|
+
export declare function Board({ title, description, filters, metrics, state, children, }: BoardProps): import("react").JSX.Element;
|
|
34
61
|
declare const SPAN: {
|
|
35
62
|
readonly 1: "";
|
|
36
63
|
readonly 2: "@3xl:col-span-2";
|
|
@@ -44,8 +71,11 @@ export type BoardTileProps = {
|
|
|
44
71
|
actions?: ReactNode;
|
|
45
72
|
/** How many columns it takes: a time series reads better wide. */
|
|
46
73
|
span?: keyof typeof SPAN;
|
|
74
|
+
/** Reading, ready or failed. Not ready, the body is the state, the height of a chart; the
|
|
75
|
+
* title, its description and its actions stay. */
|
|
76
|
+
state?: BoardState;
|
|
47
77
|
children: ReactNode;
|
|
48
78
|
};
|
|
49
79
|
/** One tile of a `Board`: a titled surface around a chart, a list or a number. */
|
|
50
|
-
export declare function BoardTile({ title, description, actions, span, children, }: BoardTileProps): import("react").JSX.Element;
|
|
80
|
+
export declare function BoardTile({ title, description, actions, span, state, children, }: BoardTileProps): import("react").JSX.Element;
|
|
51
81
|
export {};
|
|
@@ -1,8 +1,27 @@
|
|
|
1
|
+
"use client";
|
|
1
2
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
|
|
3
|
+
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
4
|
+
import { Button } from "../../primitives/button/Button.js";
|
|
5
|
+
import { Failed } from "../../primitives/notice/Notice.js";
|
|
6
|
+
const READY = { status: "ready" };
|
|
7
|
+
function Failure({ heading, state, }) {
|
|
8
|
+
const copy = useUiCopy();
|
|
9
|
+
return (_jsx(Failed, { heading: heading, sentence: state.sentence, ...(state.detail === undefined ? {} : { detail: state.detail }), ...(state.onRetry === undefined
|
|
10
|
+
? {}
|
|
11
|
+
: {
|
|
12
|
+
action: (_jsx(Button, { role: "secondary", size: "sm", onClick: state.onRetry, children: copy.failed.retry })),
|
|
13
|
+
}) }));
|
|
14
|
+
}
|
|
15
|
+
/** The headline numbers while the board reads them: the strip they will fill, quiet. */
|
|
16
|
+
function MetricsReading() {
|
|
17
|
+
const copy = useUiCopy();
|
|
18
|
+
return (_jsxs("div", { className: "flex min-w-0 animate-reveal-late flex-wrap gap-2", children: [_jsx("span", { className: "sr-only", children: copy.failed.loading }), [0, 1, 2].map((i) => (_jsx("span", { "aria-hidden": true, className: "h-(--size-metric) w-(--container-metric) rounded-box border border-line bg-ink/4" }, i)))] }));
|
|
19
|
+
}
|
|
20
|
+
export function Board({ title, description, filters, metrics, state = READY, children, }) {
|
|
21
|
+
const copy = useUiCopy();
|
|
3
22
|
return (
|
|
4
23
|
/* Its own gutter: a board is a page (or a whole panel), not a piece inside one. */
|
|
5
|
-
_jsxs("div", { className: "@container flex min-w-0 flex-col gap-5 p-4 sm:p-6", children: [_jsxs("header", { className: "flex min-w-0 flex-wrap items-end justify-between gap-x-6 gap-y-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-display font-semibold text-ink", children: title }), description === undefined ? null : (_jsx("p", { className: "mt-1 text-body text-muted", children: description }))] }), filters === undefined ? null : (_jsx("div", { className: "flex min-w-0 flex-wrap items-end gap-3", children: filters }))] }), metrics, _jsx("div", { className: "grid min-w-0 grid-cols-1 gap-4 @3xl:grid-cols-2 @7xl:grid-cols-3", children: children })] }));
|
|
24
|
+
_jsxs("div", { className: "@container flex min-w-0 flex-col gap-5 p-4 sm:p-6", ...(state.status === "loading" ? { "aria-busy": true } : {}), children: [_jsxs("header", { className: "flex min-w-0 flex-wrap items-end justify-between gap-x-6 gap-y-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h1", { className: "text-display font-semibold text-ink", children: title }), description === undefined ? null : (_jsx("p", { className: "mt-1 text-body text-muted", children: description }))] }), filters === undefined ? null : (_jsx("div", { className: "flex min-w-0 flex-wrap items-end gap-3", children: filters }))] }), state.status === "loading" ? (_jsx(MetricsReading, {})) : state.status === "failed" ? (_jsx(Failure, { heading: copy.board.failed, state: state })) : (metrics), _jsx("div", { className: "grid min-w-0 grid-cols-1 gap-4 @3xl:grid-cols-2 @7xl:grid-cols-3", children: children })] }));
|
|
6
25
|
}
|
|
7
26
|
const SPAN = {
|
|
8
27
|
1: "",
|
|
@@ -10,6 +29,10 @@ const SPAN = {
|
|
|
10
29
|
full: "col-span-full",
|
|
11
30
|
};
|
|
12
31
|
/** One tile of a `Board`: a titled surface around a chart, a list or a number. */
|
|
13
|
-
export function BoardTile({ title, description, actions, span = 1, children, }) {
|
|
14
|
-
|
|
32
|
+
export function BoardTile({ title, description, actions, span = 1, state = READY, children, }) {
|
|
33
|
+
const copy = useUiCopy();
|
|
34
|
+
return (_jsxs("section", { "aria-label": title, ...(state.status === "loading" ? { "aria-busy": true } : {}), "data-ui": "board.tile", className: `flex min-w-0 flex-col gap-4 rounded-ui-card border border-line-strong bg-ui-card p-4 ${SPAN[span]}`, children: [_jsxs("header", { className: "flex min-w-0 items-start justify-between gap-3", children: [_jsxs("div", { className: "min-w-0", children: [_jsx("h2", { className: "text-lead font-semibold text-ink", children: title }), description === undefined ? null : (_jsx("p", { className: "mt-0.5 text-meta text-muted", children: description }))] }), actions === undefined ? null : (_jsx("div", { className: "flex shrink-0 items-center gap-1", children: actions }))] }), state.status === "loading" ? (
|
|
35
|
+
/* A quiet block where the chart goes. It appears late, like every skeleton: a fast
|
|
36
|
+
read never shows it. */
|
|
37
|
+
_jsx("div", { className: "min-h-(--size-tile-body) animate-reveal-late rounded-control bg-ink/4", children: _jsx("span", { className: "sr-only", children: copy.failed.loading }) })) : state.status === "failed" ? (_jsx("div", { className: "flex min-h-(--size-tile-body) flex-col justify-center", children: _jsx(Failure, { heading: fillCopy(copy.board.tileFailed, { title }), state: state }) })) : (children)] }));
|
|
15
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Board, type BoardProps, BoardTile, type BoardTileProps, } from "./Board.js";
|
|
1
|
+
export { Board, type BoardProps, type BoardState, BoardTile, type BoardTileProps, } from "./Board.js";
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
/* A dashboard: one filter row, the headline numbers, and tiles over the same slice
|
|
1
|
+
/* A dashboard: one filter row, the headline numbers, and tiles over the same slice — each
|
|
2
|
+
tile reading on its own, with its loading and failed states. */
|
|
2
3
|
export { Board, BoardTile, } from "./Board.js";
|
|
@@ -4,6 +4,9 @@ import { FieldPath } from "../search/FieldPath.js";
|
|
|
4
4
|
import { grainName } from "../../foundations/calendar.js";
|
|
5
5
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
6
6
|
import { GRAIN_ORDER, levelKey, } from "../../foundations/grouping.js";
|
|
7
|
+
import { CheckMark } from "../../primitives/field/Checks.js";
|
|
8
|
+
import { Count } from "../../primitives/tag/Count.js";
|
|
9
|
+
import { chosenTone } from "../../primitives/tag/Tag.js";
|
|
7
10
|
import { ChevronDown, ChevronRight, ChevronUp, Plus, X } from "lucide-react";
|
|
8
11
|
import { useState } from "react";
|
|
9
12
|
function fieldLabel(fields, field) {
|
|
@@ -21,28 +24,27 @@ export function GroupingLevels({ fields, control, grainLabel, addPath, }) {
|
|
|
21
24
|
const grain = (one) => grainLabel?.(one) ?? grainName(one);
|
|
22
25
|
const isOpen = (field) => opened.includes(field);
|
|
23
26
|
const toggleOpen = (field) => setOpened((current) => current.includes(field) ? current.filter((one) => one !== field) : [...current, field]);
|
|
24
|
-
return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("ol", { className: "flex flex-wrap gap-1 px-1 pb-1.5", children: placed.map((level, index) => (_jsx("li", { children: _jsxs("span", { className:
|
|
27
|
+
return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("ol", { className: "flex flex-wrap gap-1 px-1 pb-1.5", children: placed.map((level, index) => (_jsx("li", { children: _jsxs("span", { "data-ui": "search.chip", className: `inline-flex items-center gap-1 rounded-ui-tag py-0.5 pr-0.5 pl-1.5 text-micro ${chosenTone("canvas")}`, children: [_jsx("span", { className: "tabular-nums opacity-70", children: index + 1 }), _jsxs("span", { className: "max-w-32 truncate", children: [fieldLabel(fields, level.field), level.grain === undefined ? "" : ` · ${grain(level.grain)}`] }), _jsx("button", { type: "button", onClick: () => control.move(level.field, -1), disabled: index === 0, "aria-label": copy.grouping.up, title: copy.grouping.up, className: "rounded-pill p-0.5 hover:bg-primary/15 disabled:opacity-30 disabled:hover:bg-transparent", children: _jsx(ChevronUp, { className: "size-3", strokeWidth: 2.5 }) }), _jsx("button", { type: "button", onClick: () => control.move(level.field, 1), disabled: index === placed.length - 1, "aria-label": copy.grouping.down, title: copy.grouping.down, className: "rounded-pill p-0.5 hover:bg-primary/15 disabled:opacity-30 disabled:hover:bg-transparent", children: _jsx(ChevronDown, { className: "size-3", strokeWidth: 2.5 }) }), _jsx("button", { type: "button", onClick: () => control.remove(level.field, level.grain), "aria-label": copy.grouping.remove, title: copy.grouping.remove, className: "rounded-pill p-0.5 hover:bg-primary/15", children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) })] }) }, levelKey(level)))) }), _jsx("div", { className: "mb-1 h-px bg-line", role: "separator" })] })), fields.map((one) => {
|
|
25
28
|
const grains = one.grains;
|
|
26
29
|
/* An ordinary field: a checkbox and nothing more. */
|
|
27
30
|
if (grains === undefined || grains.length === 0) {
|
|
28
31
|
const on = control.has(one.field);
|
|
29
|
-
return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field), "aria-pressed": on, className:
|
|
32
|
+
return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field), "aria-pressed": on, className: "flex items-center gap-2 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-ui-option-active", children: [_jsx(Mark, { on: on }), _jsx("span", { className: `min-w-0 truncate text-meta ${on ? "font-medium text-ink" : "text-ink"}`, children: one.label })] }, one.field));
|
|
30
33
|
}
|
|
31
34
|
/* A DATE: it unfolds and offers its cuts as checkboxes. */
|
|
32
35
|
const open = isOpen(one.field);
|
|
33
36
|
const puestos = placed.filter((level) => level.field === one.field);
|
|
34
|
-
return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("button", { type: "button", onClick: () => toggleOpen(one.field), "aria-expanded": open, className: "flex items-center gap-1.5 rounded-
|
|
37
|
+
return (_jsxs("div", { className: "flex flex-col", children: [_jsxs("button", { type: "button", onClick: () => toggleOpen(one.field), "aria-expanded": open, className: "flex items-center gap-1.5 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-ui-option-active", children: [_jsx(ChevronRight, { className: `size-(--size-icon-sm) shrink-0 text-muted transition-transform duration-(--duration-instant) ${open ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-meta ${puestos.length > 0 ? "font-medium text-ink" : "text-ink"}`, children: one.label }), puestos.length === 0 ? null : _jsx(Count, { value: puestos.length })] }), !open ? null : (_jsx("div", { className: "flex flex-col pl-(--spacing-indent)", children: GRAIN_ORDER.filter((g) => grains.includes(g)).map((g) => {
|
|
35
38
|
const on = control.has(one.field, g);
|
|
36
|
-
return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field, g), "aria-pressed": on, className:
|
|
39
|
+
return (_jsxs("button", { type: "button", onClick: () => control.toggle(one.field, g), "aria-pressed": on, className: "flex items-center gap-2 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-ui-option-active", children: [_jsx(Mark, { on: on }), _jsx("span", { className: `min-w-0 truncate text-meta ${on ? "font-medium text-ink" : "text-muted"}`, children: grain(g) })] }, g));
|
|
37
40
|
}) }))] }, one.field));
|
|
38
41
|
}), addPath === undefined ? null : (_jsx("div", { className: "px-1 pt-1", children: _jsx(FieldPath, { look: "button", icon: Plus, model: addPath.model, ...(addPath.loadModel === undefined ? {} : { loadModel: addPath.loadModel }), ...(addPath.filter === undefined ? {} : { filter: addPath.filter }), ...(addPath.followRelations === undefined
|
|
39
42
|
? {}
|
|
40
43
|
: { followRelations: addPath.followRelations }), value: [], label: copy.fieldPath.addLevel, placeholder: copy.fieldPath.addLevel, onChange: addPath.onPick }) })), placed.length === 0 ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "my-1 h-px bg-line", role: "separator" }), _jsx("button", { type: "button", onClick: () => control.clear(), className: "rounded-control px-2 py-1 text-left text-meta text-muted transition-colors duration-(--duration-instant) hover:bg-ink/4 hover:text-ink", children: copy.grouping.clear })] }))] }));
|
|
41
44
|
}
|
|
42
|
-
/** The tick mark. The column ALWAYS exists, ticked or not: without it,
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* checkboxes and not as loose text with a gap on the left. */
|
|
45
|
+
/** The tick mark. The column ALWAYS exists, ticked or not: without it, ticking shifts the
|
|
46
|
+
* text and the list jumps. It is `Checkbox`'s box, the same as the filters column, so both
|
|
47
|
+
* columns read as the multiple choice they are. */
|
|
46
48
|
function Mark({ on }) {
|
|
47
|
-
return (_jsx("span", { className: "flex size-(--size-icon-sm) shrink-0 items-center justify-center", children:
|
|
49
|
+
return (_jsx("span", { className: "flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: _jsx(CheckMark, { on: on }) }));
|
|
48
50
|
}
|
|
@@ -20,7 +20,7 @@ export function RecordCard({ title, subtitle, tags, meta, figure, media, footer,
|
|
|
20
20
|
kanban state inside it would be a control inside a control, which is invalid and which a
|
|
21
21
|
screen reader announces as one thing. The footer's controls sit above the stretch. */
|
|
22
22
|
const titleText = _jsx("span", { className: "min-w-0 truncate", children: title });
|
|
23
|
-
return (_jsxs("div", { className: `relative flex w-full min-w-0 flex-col gap-2 rounded-
|
|
23
|
+
return (_jsxs("div", { "data-ui": "record-card", className: `relative flex w-full min-w-0 flex-col gap-2 rounded-ui-card border border-ui-card-border bg-ui-card p-4 text-left ${onOpen === undefined
|
|
24
24
|
? ""
|
|
25
25
|
: "transition-colors duration-(--duration-instant) focus-within:border-line-strong hover:border-line-strong"}`, children: [media === undefined ? null : media.person === true ? (
|
|
26
26
|
/* The name is written right below it: the photo's `alt` would say it twice. */
|
|
@@ -73,7 +73,7 @@ export function Row({ icon: Icon, avatar, name, onOpen, onPeek, click = "peek",
|
|
|
73
73
|
having to open a set to know whether it is a thousand rows or a
|
|
74
74
|
million— and it truncates instead of wrapping into itself: three
|
|
75
75
|
lines per row in a 480 px drawer means three rows fit on screen. */
|
|
76
|
-
_jsx("span", { className: "min-w-0 truncate text-micro tabular-nums text-muted", children: meta }))
|
|
76
|
+
_jsx("span", { className: "min-w-0 truncate text-micro tabular-nums text-muted", children: meta })), tags === undefined ? null : (_jsx("span", { className: "ms-auto flex min-w-fit shrink basis-(--container-tags) items-center justify-end gap-1.5", children: tags }))] }), _jsx("span", { className: "flex shrink-0 items-center gap-1 opacity-0 transition-opacity duration-(--duration-instant) group-hover/row:opacity-100 focus-within:opacity-100 pointer-coarse:opacity-100", children: _jsx(Trail, { name: name, openAs: openAs, ...(actions === undefined ? {} : { actions }), copy: copyAs, ...(onPeek === undefined || !openers ? {} : { onPeek }), ...(onOpen === undefined || !openers ? {} : { onOpen }), ...(more === undefined ? {} : { more }), ...(onMoreSelect === undefined ? {} : { onMoreSelect }) }) })] }) }));
|
|
77
77
|
if (children === undefined)
|
|
78
78
|
return row;
|
|
79
79
|
/* What the resource produced, hanging below. The indent reaches up to where
|
|
@@ -110,7 +110,7 @@ export function RowHeader({ name, meta, tags, withSelection = false, withIcon =
|
|
|
110
110
|
return (_jsxs("div", { "data-slot": "row-header",
|
|
111
111
|
/* It sticks below the list's bar, like the table's header
|
|
112
112
|
and the sheet's. See `system/sticky.tsx`. */
|
|
113
|
-
className: `sticky z-10 flex min-w-0 items-center border-b border-line-strong bg-ground ${byDensity(d, "gap-3 px-3 py-2", "gap-2 px-2.5 py-1.5")}`, style: stickyTop, role: "presentation", children: [!withSelection ? null : _jsx("span", { className: "size-3.5 shrink-0", "aria-hidden": true }), withAvatar ? (_jsx("span", { className: "size-5 shrink-0", "aria-hidden": true })) : !withIcon ? null : (_jsx("span", { className: "size-(--size-icon-md) shrink-0", "aria-hidden": true })), _jsxs("div", { className: `flex min-w-0 shrink grow basis-(--container-name) flex-wrap items-center gap-y-0 ${byDensity(d, "gap-x-3", "gap-x-2")}`, children: [_jsx("span", { className: `min-w-0 grow basis-(--container-name) ${rotulo}`, children: name }), meta === undefined ? null : _jsx("span", { className: `min-w-0 ${rotulo}`, children: meta })
|
|
113
|
+
className: `sticky z-10 flex min-w-0 items-center border-b border-line-strong bg-ground ${byDensity(d, "gap-3 px-3 py-2", "gap-2 px-2.5 py-1.5")}`, style: stickyTop, role: "presentation", children: [!withSelection ? null : _jsx("span", { className: "size-3.5 shrink-0", "aria-hidden": true }), withAvatar ? (_jsx("span", { className: "size-5 shrink-0", "aria-hidden": true })) : !withIcon ? null : (_jsx("span", { className: "size-(--size-icon-md) shrink-0", "aria-hidden": true })), _jsxs("div", { className: `flex min-w-0 shrink grow basis-(--container-name) flex-wrap items-center gap-y-0 ${byDensity(d, "gap-x-3", "gap-x-2")}`, children: [_jsx("span", { className: `min-w-0 grow basis-(--container-name) ${rotulo}`, children: name }), meta === undefined ? null : _jsx("span", { className: `min-w-0 ${rotulo}`, children: meta }), tags === undefined ? null : (_jsx("span", { className: "ms-auto flex min-w-fit shrink basis-(--container-tags) items-center justify-end", children: _jsx("span", { className: rotulo, children: tags }) }))] }), trail !== undefined ? (_jsx("span", { inert: true, "aria-hidden": true, className: "invisible flex shrink-0 items-center gap-1", children: _jsx(Trail, { name: "", openAs: "", ...(trail.actions === undefined ? {} : { actions: trail.actions }), ...(trail.copy === false ? { copy: false } : {}), ...(trail.peek === true ? { onPeek: () => { } } : {}), ...(trail.open === true ? { onOpen: () => { } } : {}) }) })) : !withActions ? null : (_jsx("span", { className: "size-(--size-control-sm) shrink-0", "aria-hidden": true }))] }));
|
|
114
114
|
}
|
|
115
115
|
/**
|
|
116
116
|
* The header of a group inside a list.
|
|
@@ -2,19 +2,31 @@
|
|
|
2
2
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
3
3
|
import { AriaLocale } from "../../foundations/aria.js";
|
|
4
4
|
import { useUiCopy } from "../../foundations/copy.js";
|
|
5
|
+
import { useSurface } from "../../foundations/surface.js";
|
|
5
6
|
import { focusRing, tv } from "../../foundations/variants.js";
|
|
7
|
+
import { Count } from "../../primitives/tag/Count.js";
|
|
6
8
|
import { ChevronRight } from "lucide-react";
|
|
7
9
|
import { useMemo } from "react";
|
|
8
10
|
import { Button as AriaButton, Link, NavigationTree as AriaNavigationTree, NavigationTreeItem as AriaNavigationTreeItem, NavigationTreeItemContent, RouterProvider, } from "react-aria-components";
|
|
9
11
|
const row = tv({
|
|
10
12
|
extend: focusRing,
|
|
11
|
-
base: "group relative flex min-w-0 items-center rounded-
|
|
13
|
+
base: "group relative flex min-w-0 items-center rounded-ui-nav text-meta outline-offset-0 select-none",
|
|
12
14
|
variants: {
|
|
15
|
+
surface: {
|
|
16
|
+
canvas: "text-ink",
|
|
17
|
+
chrome: "text-chrome-ink outline-chrome-link",
|
|
18
|
+
},
|
|
13
19
|
isCurrent: {
|
|
14
|
-
true: "
|
|
15
|
-
false: "
|
|
20
|
+
true: "font-medium forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
|
|
21
|
+
false: "",
|
|
16
22
|
},
|
|
17
23
|
},
|
|
24
|
+
compoundVariants: [
|
|
25
|
+
{ surface: "canvas", isCurrent: true, class: "bg-ui-nav-current text-primary" },
|
|
26
|
+
{ surface: "canvas", isCurrent: false, class: "hover:bg-ink/6" },
|
|
27
|
+
{ surface: "chrome", isCurrent: true, class: "bg-chrome-link/15 text-chrome-link" },
|
|
28
|
+
{ surface: "chrome", isCurrent: false, class: "hover:bg-chrome-ink/10" },
|
|
29
|
+
],
|
|
18
30
|
});
|
|
19
31
|
const link = tv({
|
|
20
32
|
base: "flex h-(--size-control-sm) min-w-0 flex-1 cursor-pointer items-center gap-2 px-2 text-current no-underline outline-0",
|
|
@@ -24,11 +36,26 @@ const link = tv({
|
|
|
24
36
|
});
|
|
25
37
|
const chevronButton = tv({
|
|
26
38
|
extend: focusRing,
|
|
27
|
-
base: "mr-1 inline-flex shrink-0 items-center justify-center rounded-mark p-1
|
|
39
|
+
base: "mr-1 inline-flex shrink-0 items-center justify-center rounded-mark p-1 transition-colors duration-(--duration-instant)",
|
|
40
|
+
variants: {
|
|
41
|
+
surface: {
|
|
42
|
+
canvas: "text-muted hover:bg-ink/6 hover:text-ink pressed:bg-ink/10",
|
|
43
|
+
chrome: "text-chrome-muted outline-chrome-link hover:bg-chrome-ink/10 hover:text-chrome-ink pressed:bg-chrome-ink/15",
|
|
44
|
+
},
|
|
45
|
+
},
|
|
28
46
|
});
|
|
29
47
|
/** The marker of the current row: a bar on the leading edge, so the spot reads in the
|
|
30
48
|
* margin before the label is read. */
|
|
31
|
-
const
|
|
49
|
+
const MARKER = {
|
|
50
|
+
canvas: "absolute inset-y-1 start-0 w-0.5 rounded-pill bg-primary forced-colors:bg-[HighlightText]",
|
|
51
|
+
chrome: "absolute inset-y-1 start-0 w-0.5 rounded-pill bg-chrome-link forced-colors:bg-[HighlightText]",
|
|
52
|
+
};
|
|
53
|
+
/** The colour of what is «here» — the current row's icon, a folded module that holds it —
|
|
54
|
+
* and of what is not. */
|
|
55
|
+
const HERE = {
|
|
56
|
+
canvas: { here: "text-primary", rest: "text-muted" },
|
|
57
|
+
chrome: { here: "text-chrome-link", rest: "text-chrome-muted" },
|
|
58
|
+
};
|
|
32
59
|
/** The ids of every module on the way to `id`, so the row you are on is never folded away. */
|
|
33
60
|
function pathTo(items, id) {
|
|
34
61
|
if (id === undefined)
|
|
@@ -54,7 +81,7 @@ function pathTo(items, id) {
|
|
|
54
81
|
*/
|
|
55
82
|
export function NavigationTree({ items, current, onNavigate, defaultExpanded = [], label, }) {
|
|
56
83
|
const copy = useUiCopy();
|
|
57
|
-
const
|
|
84
|
+
const surface = useSurface();
|
|
58
85
|
const expanded = useMemo(() => [...new Set([...defaultExpanded, ...pathTo(items, current)])],
|
|
59
86
|
// The initial state only: React Aria owns the expansion after the first render.
|
|
60
87
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
@@ -71,9 +98,9 @@ export function NavigationTree({ items, current, onNavigate, defaultExpanded = [
|
|
|
71
98
|
paddingInlineStart: `calc(var(--spacing) * 4 + var(--size-icon-md) + var(--spacing-indent) * ${level - 2})`,
|
|
72
99
|
}
|
|
73
100
|
: undefined;
|
|
74
|
-
return (_jsxs(AriaNavigationTreeItem, { id: item.id, textValue: item.label, ...(module ? {} : { href: item.id }), className: ({ isCurrent, isFocusVisible }) => row({ isCurrent, isFocusVisible }), children: [_jsx(NavigationTreeItemContent, { children: ({ isCurrent, isCurrentAncestor, isExpanded }) => (_jsxs(_Fragment, { children: [isCurrent ? _jsx("span", { "aria-hidden": true, className:
|
|
75
|
-
?
|
|
76
|
-
:
|
|
101
|
+
return (_jsxs(AriaNavigationTreeItem, { "data-ui": "navigation.item", id: item.id, textValue: item.label, ...(module ? {} : { href: item.id }), className: ({ isCurrent, isFocusVisible }) => row({ surface, isCurrent, isFocusVisible }), children: [_jsx(NavigationTreeItemContent, { children: ({ isCurrent, isCurrentAncestor, isExpanded }) => (_jsxs(_Fragment, { children: [isCurrent ? _jsx("span", { "aria-hidden": true, className: MARKER[surface] }) : null, _jsxs(Link, { className: link({ isModule: module }), style: indent, children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-md) shrink-0 ${isCurrent || (isCurrentAncestor && !isExpanded)
|
|
102
|
+
? HERE[surface].here
|
|
103
|
+
: HERE[surface].rest}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: `min-w-0 flex-1 truncate ${isCurrentAncestor && !isExpanded ? HERE[surface].here : ""}`, children: item.label }), item.count === undefined ? null : (_jsx(Count, { value: item.count, current: isCurrent }))] }), module ? (_jsx(AriaButton, { slot: "chevron", className: ({ isFocusVisible }) => chevronButton({ surface, isFocusVisible }), children: _jsx(ChevronRight, { className: `size-(--size-icon-sm) transition-transform duration-(--duration-quick) ease-(--ease-out) ${isExpanded ? "rotate-90" : ""}`, strokeWidth: 2, "aria-hidden": true }) })) : null] })) }), children.map((child) => render(child, level + 1))] }, item.id));
|
|
77
104
|
};
|
|
78
|
-
return (_jsx(AriaLocale, { children: _jsx(RouterProvider, { navigate: (id) => onNavigate?.(id), useHref: (id) => `#${id}`, children: _jsx(AriaNavigationTree, { "aria-label": label ?? copy.shell.menus, selectedRoute: current ?? null, defaultExpandedKeys: expanded, className: "flex w-full min-w-0 flex-col gap-px p-2 outline-0", children: items.map((item) => render(item, 1)) }) }) }));
|
|
105
|
+
return (_jsx(AriaLocale, { children: _jsx(RouterProvider, { navigate: (id) => onNavigate?.(id), useHref: (id) => `#${id}`, children: _jsx(AriaNavigationTree, { "data-ui": "navigation", "aria-label": label ?? copy.shell.menus, selectedRoute: current ?? null, defaultExpandedKeys: expanded, className: "flex w-full min-w-0 flex-col gap-px p-2 outline-0", children: items.map((item) => render(item, 1)) }) }) }));
|
|
79
106
|
}
|
|
@@ -8,6 +8,7 @@ import { GRAIN_ORDER } from "../../foundations/grouping.js";
|
|
|
8
8
|
import { useSurface } from "../../foundations/surface.js";
|
|
9
9
|
import { Rule } from "../../primitives/block/Block.js";
|
|
10
10
|
import { Button } from "../../primitives/button/index.js";
|
|
11
|
+
import { chosenTone } from "../../primitives/tag/Tag.js";
|
|
11
12
|
import { Tags } from "../../primitives/tag/Tags.js";
|
|
12
13
|
import { Plus, Trash2 } from "lucide-react";
|
|
13
14
|
import { Fragment, useMemo, useState } from "react";
|
|
@@ -56,7 +57,7 @@ function AddTag({ label, options, onPick, }) {
|
|
|
56
57
|
const [open, setOpen] = useState(false);
|
|
57
58
|
if (options.length === 0)
|
|
58
59
|
return null;
|
|
59
|
-
return (_jsxs("span", { className: "relative inline-flex shrink-0", children: [_jsxs("button", { type: "button", onClick: () => setOpen((current) => !current), "aria-expanded": open, className: "inline-flex shrink-0 items-center gap-1 rounded-pill border border-dashed border-line-strong px-2 py-0.5 text-micro text-muted transition-colors duration-(--duration-instant) hover:border-line-strong hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(Plus, { className: "size-3", strokeWidth: 2, "aria-hidden": true }), label] }), open ? (_jsx("span", { className: "absolute top-full left-0 z-40 mt-1 max-h-64 overflow-y-auto rounded-
|
|
60
|
+
return (_jsxs("span", { className: "relative inline-flex shrink-0", children: [_jsxs("button", { type: "button", onClick: () => setOpen((current) => !current), "aria-expanded": open, className: "inline-flex shrink-0 items-center gap-1 rounded-pill border border-dashed border-line-strong px-2 py-0.5 text-micro text-muted transition-colors duration-(--duration-instant) hover:border-line-strong hover:bg-ink/5 hover:text-ink focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(Plus, { className: "size-3", strokeWidth: 2, "aria-hidden": true }), label] }), open ? (_jsx("span", { "data-ui": "popover", className: "absolute top-full left-0 z-40 mt-1 max-h-64 overflow-y-auto rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", children: _jsx(Tags, { stack: true, label: label, items: options.map((name) => ({
|
|
60
61
|
id: name,
|
|
61
62
|
label: name,
|
|
62
63
|
onSelect: () => {
|
|
@@ -283,6 +284,6 @@ export function CriteriaBuilder({ model, initial, focus, onApply, onCancel, }) {
|
|
|
283
284
|
const chosen = fields.includes(name);
|
|
284
285
|
return (_jsx("button", { type: "button", onClick: () => push({
|
|
285
286
|
fields: chosen ? fields.filter((one) => one !== name) : [...fields, name],
|
|
286
|
-
}), className: `rounded-pill border px-2 py-0.5 text-micro ${chosen ? "
|
|
287
|
+
}), className: `rounded-pill border px-2 py-0.5 text-micro ${chosen ? chosenTone("canvas") : `text-muted ${box}`}`, children: name }, name));
|
|
287
288
|
}) })] }), _jsx(LazyJsonEditor, { value: rawText, onChange: updateRaw, error: rawError, height: "14rem", label: copy.builder.json }), _jsxs("div", { className: "flex gap-2", children: [_jsx(Button, { role: "primary", disabled: rawError !== null, onClick: () => onApply(rawText.trim() === "" ? undefined : JSON.parse(rawText)), children: copy.builder.apply }), onCancel === undefined ? null : (_jsx(Button, { role: "ghost", onClick: onCancel, children: copy.builder.cancel }))] })] }));
|
|
288
289
|
}
|
|
@@ -4,6 +4,7 @@ import { filtersOf, groupsOf, } from "./criteria.js";
|
|
|
4
4
|
import { JoinWord } from "./JoinWord.js";
|
|
5
5
|
import { fillCopy, useUiCopy } from "../../foundations/copy.js";
|
|
6
6
|
import { bySurface, useSurface } from "../../foundations/surface.js";
|
|
7
|
+
import { chosenTone } from "../../primitives/tag/Tag.js";
|
|
7
8
|
import { ChevronRight, Layers, X } from "lucide-react";
|
|
8
9
|
import { Fragment, useState } from "react";
|
|
9
10
|
export function CriteriaChips({ criteria, onOpen, onJoin, onRemove, onRemoveMany, open, collapseAfter = 4, surface, }) {
|
|
@@ -39,7 +40,7 @@ export function CriteriaChips({ criteria, onOpen, onJoin, onRemove, onRemoveMany
|
|
|
39
40
|
const unfolded = expanded || open !== undefined || !Number.isFinite(collapseAfter);
|
|
40
41
|
const beyondWide = Math.max(0, facets.length - collapseAfter);
|
|
41
42
|
const beyondNarrow = Math.max(0, facets.length - 1);
|
|
42
|
-
const more = (count, hidden, className) => (_jsx("button", { type: "button", onClick: () => setExpanded(true), title: hidden, "aria-label": `${fillCopy(copy.search.moreFacets, { count })}: ${hidden}`, className: `${className} shrink-0 items-center rounded-
|
|
43
|
+
const more = (count, hidden, className) => (_jsx("button", { type: "button", onClick: () => setExpanded(true), title: hidden, "aria-label": `${fillCopy(copy.search.moreFacets, { count })}: ${hidden}`, className: `${className} shrink-0 items-center rounded-ui-tag border px-2 py-0.5 text-micro font-medium tabular-nums transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "border-line-strong text-muted hover:bg-ink/5 hover:text-ink", "border-chrome-ink/30 text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: fillCopy(copy.search.moreFacets, { count }) }));
|
|
43
44
|
const hiddenFrom = (from) => facets
|
|
44
45
|
.slice(from)
|
|
45
46
|
.map((one) => one.label)
|
|
@@ -76,7 +77,7 @@ function labelOf(node, joins) {
|
|
|
76
77
|
function GroupChain({ groups, onOpen, onRemoveMany, surface, }) {
|
|
77
78
|
const copy = useUiCopy();
|
|
78
79
|
const chain = groups.map((one) => one.label).join(" › ");
|
|
79
|
-
return (_jsxs("span", { role: "group", "aria-label": `${copy.search.groupedBy} ${chain}`, title: `${copy.search.groupedBy} ${chain}`, className: `inline-flex min-w-0 max-w-(--container-chain) items-center gap-1 rounded-
|
|
80
|
+
return (_jsxs("span", { role: "group", "aria-label": `${copy.search.groupedBy} ${chain}`, title: `${copy.search.groupedBy} ${chain}`, className: `inline-flex min-w-0 max-w-(--container-chain) items-center gap-1 rounded-ui-tag border py-0.5 pl-1.5 text-micro ${bySurface(surface, "border-line-strong bg-surface text-ink", "border-chrome-ink/30 bg-chrome-ink/8 text-chrome-ink")} ${onRemoveMany === undefined ? "pr-2" : "pr-0.5"}`, children: [_jsx(Layers, { className: `size-3 shrink-0 ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: groups.map((one, at) => (_jsxs(Fragment, { children: [at === 0 ? null : (_jsx(ChevronRight, { className: `mx-0.5 inline size-3 align-middle ${bySurface(surface, "text-muted", "text-chrome-muted")}`, strokeWidth: 2, "aria-hidden": true })), onOpen === undefined ? (_jsx("span", { children: one.label })) : (_jsx("button", { type: "button", onClick: () => onOpen(one.path), title: copy.search.openBuilderHere, className: "inline rounded-control hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: one.label }))] }, one.path.join(".")))) }), onRemoveMany === undefined ? null : (_jsx("button", { type: "button", onClick: () => onRemoveMany(groups.map((one) => one.path)), "aria-label": copy.search.removeGrouping, title: copy.search.removeGrouping, className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-ink/10", "hover:bg-chrome-ink/20")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }))] }));
|
|
80
81
|
}
|
|
81
82
|
function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
|
|
82
83
|
const copy = useUiCopy();
|
|
@@ -97,7 +98,7 @@ function Node({ node, path, onOpen, onJoin, onRemove, open, surface, }) {
|
|
|
97
98
|
}
|
|
98
99
|
function Chip({ label, path, onOpen, onRemove, surface, }) {
|
|
99
100
|
const copy = useUiCopy();
|
|
100
|
-
const shell = `inline-flex min-w-0 max-w-(--container-facet) items-center gap-1 rounded-
|
|
101
|
+
const shell = `inline-flex min-w-0 max-w-(--container-facet) items-center gap-1 rounded-ui-tag py-0.5 text-micro ${chosenTone(surface)} ${onRemove === undefined ? "px-2" : "pr-0.5 pl-2"}`;
|
|
101
102
|
const remove = onRemove === undefined ? null : (_jsx("button", { type: "button", onClick: (event) => {
|
|
102
103
|
/* Without this, removing it also opens it: the click arrives here and then
|
|
103
104
|
bubbles up. */
|
|
@@ -105,11 +106,11 @@ function Chip({ label, path, onOpen, onRemove, surface, }) {
|
|
|
105
106
|
onRemove(path);
|
|
106
107
|
}, "aria-label": copy.search.removeFilter.replace("{label}", label), className: `inline-flex size-4 shrink-0 items-center justify-center rounded-pill transition-colors duration-(--duration-instant) ${bySurface(surface, "hover:bg-primary/20", "hover:bg-chrome-link/25")}`, children: _jsx(X, { className: "size-3", strokeWidth: 2.5 }) }));
|
|
107
108
|
if (onOpen === undefined) {
|
|
108
|
-
return (_jsxs("span", { className: shell, children: [_jsx("span", { className: "min-w-0 truncate", children: label }), remove] }));
|
|
109
|
+
return (_jsxs("span", { "data-ui": "search.chip", className: shell, children: [_jsx("span", { className: "min-w-0 truncate", children: label }), remove] }));
|
|
109
110
|
}
|
|
110
111
|
/* Two SIBLING buttons in the chip — open and remove — and never one inside the other. It
|
|
111
112
|
used to be a `span role="button"` holding the × button: an interactive control inside
|
|
112
113
|
another one, which a screen reader announces as one thing and axe flags
|
|
113
114
|
(`nested-interactive`). Siblings, each with its own name, are both reachable. */
|
|
114
|
-
return (_jsxs("span", { className: shell, children: [_jsx("button", { type: "button", onClick: () => onOpen(path), title: copy.search.openBuilderHere, className: "min-w-0 truncate rounded-control text-left hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: label }), remove] }));
|
|
115
|
+
return (_jsxs("span", { "data-ui": "search.chip", className: shell, children: [_jsx("button", { type: "button", onClick: () => onOpen(path), title: copy.search.openBuilderHere, className: "min-w-0 truncate rounded-control text-left hover:underline hover:underline-offset-4 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: label }), remove] }));
|
|
115
116
|
}
|
|
@@ -35,7 +35,7 @@ export function JoinWord({ join, onChange, surface, }) {
|
|
|
35
35
|
if (onChange === undefined) {
|
|
36
36
|
return _jsx("span", { className: "shrink-0 text-micro text-muted", children: word });
|
|
37
37
|
}
|
|
38
|
-
return (_jsxs("span", { className: "relative inline-flex shrink-0", children: [_jsx("button", { type: "button", onClick: () => setOpen((current) => !current), "aria-expanded": open, title: copy.search.switchJoin, className: `shrink-0 rounded-control px-1 text-micro font-medium underline decoration-dotted underline-offset-4 decoration-current/40 transition-colors hover:decoration-current focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:text-ink", "text-chrome-muted hover:text-chrome-ink")}`, children: word }), open ? (_jsx("span", { className: "absolute top-full left-0 z-40 mt-1 rounded-
|
|
38
|
+
return (_jsxs("span", { className: "relative inline-flex shrink-0", children: [_jsx("button", { type: "button", onClick: () => setOpen((current) => !current), "aria-expanded": open, title: copy.search.switchJoin, className: `shrink-0 rounded-control px-1 text-micro font-medium underline decoration-dotted underline-offset-4 decoration-current/40 transition-colors hover:decoration-current focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:text-ink", "text-chrome-muted hover:text-chrome-ink")}`, children: word }), open ? (_jsx("span", { "data-ui": "popover", className: "absolute top-full left-0 z-40 mt-1 rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", children: _jsx(Tags, { stack: true, surface: "canvas", label: copy.search.switchJoin, items: OPTIONS.map((one) => ({
|
|
39
39
|
id: one,
|
|
40
40
|
label: copy.search.joins[one === "not" ? "none" : one],
|
|
41
41
|
selected: one === join,
|