@sincpro/web-ui 2.1.0 → 2.2.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.
Files changed (36) hide show
  1. package/README.md +45 -0
  2. package/dist/components/attachments/Attachments.d.ts +7 -1
  3. package/dist/components/attachments/Attachments.js +8 -2
  4. package/dist/components/board/Board.d.ts +32 -2
  5. package/dist/components/board/Board.js +27 -4
  6. package/dist/components/board/index.d.ts +1 -1
  7. package/dist/components/board/index.js +2 -1
  8. package/dist/components/listing/Row.js +2 -2
  9. package/dist/components/navigation/NavigationTree.js +2 -2
  10. package/dist/components/search/SearchBar.js +30 -7
  11. package/dist/components/shell/AppFrame.d.ts +9 -2
  12. package/dist/components/shell/AppFrame.js +99 -11
  13. package/dist/components/shell/Sidebar.d.ts +34 -0
  14. package/dist/components/shell/Sidebar.js +32 -0
  15. package/dist/components/shell/TopBar.d.ts +2 -0
  16. package/dist/components/shell/TopBar.js +13 -9
  17. package/dist/components/shell/index.d.ts +2 -0
  18. package/dist/components/shell/index.js +4 -0
  19. package/dist/components/shell/sidebarDrawer.d.ts +26 -0
  20. package/dist/components/shell/sidebarDrawer.js +22 -0
  21. package/dist/foundations/copy.d.ts +13 -0
  22. package/dist/foundations/copy.es.js +9 -2
  23. package/dist/foundations/copy.js +9 -2
  24. package/dist/primitives/field/DropZone.d.ts +22 -3
  25. package/dist/primitives/field/DropZone.js +33 -12
  26. package/dist/primitives/menu/Menu.d.ts +7 -3
  27. package/dist/primitives/menu/Menu.js +4 -3
  28. package/dist/primitives/tabs/Tabs.js +2 -28
  29. package/dist/primitives/tag/Count.d.ts +23 -0
  30. package/dist/primitives/tag/Count.js +59 -0
  31. package/dist/primitives/tag/index.d.ts +1 -0
  32. package/dist/primitives/tag/index.js +3 -0
  33. package/dist/primitives/value/Metric.d.ts +7 -2
  34. package/dist/primitives/value/Metric.js +12 -4
  35. package/dist/tokens.css +147 -40
  36. package/package.json +1 -1
package/README.md CHANGED
@@ -131,6 +131,51 @@ 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
+
149
+ --brand-dark-accent: #e0b850; /* the same, for the dark palette */
150
+ --brand-dark-chrome: #0a1428;
151
+ }
152
+ ```
153
+
154
+ The full list is `accent`, `accent-hover`, `on-accent`, `primary`, `primary-hover`, `chrome`,
155
+ `chrome-raised`, `chrome-edge`, `chrome-accent` and `chrome-link`; `--brand-<token>` is the light
156
+ palette's and `--brand-dark-<token>` the dark's. One left unset keeps the system's value. Do not
157
+ override `--color-*` directly: those are redefined per theme, so an override on `:root` loses to
158
+ `[data-theme="light"]` and leaks into the dark palette. The system measures its own contrasts;
159
+ your brand's are checked by Storybook's a11y pass if you render your stories with it.
160
+
161
+ #### Living beside a site's own CSS
162
+
163
+ The package's styles are in cascade layers (`@layer base`, `utilities`), and **CSS outside any
164
+ layer always beats CSS inside one** — so a site's global `h1 { font-family: … }` restyles every
165
+ heading web-ui draws. Put the site's element rules in a layer too:
166
+
167
+ ```css
168
+ @layer base {
169
+ h1,
170
+ h2 {
171
+ font-family: var(--font-display);
172
+ }
173
+ }
174
+ ```
175
+
176
+ or scope them to the site's own pages (`.site h1`). Classes are not affected; element selectors
177
+ and `*` are.
178
+
134
179
  Rules a new token must follow: define it in **both** palettes with its contrast on the same line
135
180
  (`tests/tokens.test.ts` measures each theme against its own ground, surface and chrome, and fails
136
181
  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 }), onFile: (file) => onAdd([file]) })) : null] }));
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
- export function Board({ title, description, filters, metrics, children }) {
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
- return (_jsxs("section", { "aria-label": title, className: `flex min-w-0 flex-col gap-4 rounded-box border border-line-strong bg-surface 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 }))] }), children] }));
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 } : {}), className: `flex min-w-0 flex-col gap-4 rounded-box border border-line-strong bg-surface 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";
@@ -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 }))] }), tags === undefined ? null : (_jsx("span", { className: "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 }) }) })] }) }));
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 })] }), tags === undefined ? null : (_jsx("span", { className: "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 }))] }));
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.
@@ -3,6 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { AriaLocale } from "../../foundations/aria.js";
4
4
  import { useUiCopy } from "../../foundations/copy.js";
5
5
  import { focusRing, tv } from "../../foundations/variants.js";
6
+ import { Count } from "../../primitives/tag/Count.js";
6
7
  import { ChevronRight } from "lucide-react";
7
8
  import { useMemo } from "react";
8
9
  import { Button as AriaButton, Link, NavigationTree as AriaNavigationTree, NavigationTreeItem as AriaNavigationTreeItem, NavigationTreeItemContent, RouterProvider, } from "react-aria-components";
@@ -54,7 +55,6 @@ function pathTo(items, id) {
54
55
  */
55
56
  export function NavigationTree({ items, current, onNavigate, defaultExpanded = [], label, }) {
56
57
  const copy = useUiCopy();
57
- const number = useMemo(() => new Intl.NumberFormat(copy.locale), [copy.locale]);
58
58
  const expanded = useMemo(() => [...new Set([...defaultExpanded, ...pathTo(items, current)])],
59
59
  // The initial state only: React Aria owns the expansion after the first render.
60
60
  // eslint-disable-next-line react-hooks/exhaustive-deps
@@ -73,7 +73,7 @@ export function NavigationTree({ items, current, onNavigate, defaultExpanded = [
73
73
  : undefined;
74
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: marker }) : 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)
75
75
  ? "text-primary"
76
- : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: `min-w-0 flex-1 truncate ${isCurrentAncestor && !isExpanded ? "text-primary" : ""}`, children: item.label }), item.count === undefined || item.count <= 0 ? null : (_jsx("span", { className: `shrink-0 rounded-pill px-1.5 text-micro leading-normal font-medium tabular-nums ${isCurrent ? "bg-primary/12 text-primary" : "bg-ink/6 text-muted"}`, children: number.format(item.count) }))] }), module ? (_jsx(AriaButton, { slot: "chevron", className: ({ isFocusVisible }) => chevronButton({ 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));
76
+ : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: `min-w-0 flex-1 truncate ${isCurrentAncestor && !isExpanded ? "text-primary" : ""}`, children: item.label }), item.count === undefined ? null : (_jsx(Count, { value: item.count, current: isCurrent }))] }), module ? (_jsx(AriaButton, { slot: "chevron", className: ({ isFocusVisible }) => chevronButton({ 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
77
  };
78
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)) }) }) }));
79
79
  }
@@ -8,7 +8,7 @@ import { bySurface, useSurface } from "../../foundations/surface.js";
8
8
  import { Tags } from "../../primitives/tag/Tags.js";
9
9
  import { ChevronRight, CornerDownRight, ListFilter, Search, SlidersHorizontal, X, } from "lucide-react";
10
10
  import { Fragment, useEffect, useId, useRef, useState } from "react";
11
- import { useOverlay } from "react-aria";
11
+ import { mergeProps, Overlay, useOverlay, useOverlayPosition } from "react-aria";
12
12
  function Option({ o, onSelect }) {
13
13
  const Icon = o.icon;
14
14
  return (_jsxs("button", { type: "button", disabled: o.disabled, onClick: () => onSelect?.(o.id), className: `flex w-full items-start gap-2 rounded-control px-1.5 py-1 text-left transition-colors duration-(--duration-instant) disabled:pointer-events-none disabled:opacity-45 hover:bg-primary/8 ${o.checked === true ? "bg-primary/6" : ""}`, children: [_jsx("span", { className: "mt-0.5 flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: o.checked === true ? (_jsx("span", { className: "size-1.5 rounded-pill bg-primary" })) : Icon !== undefined ? (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2 })) : (_jsx("span", { className: "size-3 rounded-pill border border-line-strong" })) }), _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.checked === true ? "font-medium text-ink" : "text-ink"}`, children: o.label }), o.badge === undefined ? null : (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-warn/30 bg-warn/10 px-2 py-0.5 text-micro text-warn", children: o.badge }))] }), o.hint === undefined ? null : (_jsx("span", { className: "mt-0.5 block truncate text-micro text-muted", children: o.hint }))] })] }));
@@ -34,6 +34,10 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
34
34
  const sup = useSurface(surface);
35
35
  const [text, setText] = useState("");
36
36
  const [panel, setPanel] = useState(false);
37
+ /* Which edge of the field the panel hangs from. It is wider than the field when the
38
+ field is narrow, so it opens toward the side of the screen with room: from the start
39
+ of a field on the left of a page, from its end on the right. */
40
+ const [panelSide, setPanelSide] = useState("end");
37
41
  /** The step the question being written is at: no field, with a field, or
38
42
  * with a field and operator. */
39
43
  const [step, setStep] = useState({});
@@ -161,6 +165,20 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
161
165
  isDismissable: true,
162
166
  shouldCloseOnInteractOutside: (element) => box.current?.contains(element) !== true,
163
167
  }, panelBox);
168
+ /* The panel floats in the page's overlay layer (`Overlay`, a portal React Aria stacks with
169
+ dialogs), placed against the field: a list's bar clips its search box sideways
170
+ (`ListingBar`, so the field never paints over «1–80») and a page may clip its card, and a
171
+ panel drawn inside them was cut wherever it outgrew the field. Placed this way it is as
172
+ wide as `--container-cuts`, inside the screen, toward the side with room. */
173
+ const { overlayProps: positionProps } = useOverlayPosition({
174
+ targetRef: box,
175
+ overlayRef: panelBox,
176
+ placement: panelSide === "start" ? "bottom start" : "bottom end",
177
+ offset: 4,
178
+ containerPadding: 16,
179
+ shouldFlip: false,
180
+ isOpen: panel,
181
+ });
164
182
  /* With the focus still in the bar (the input, the button) and the panel open, Escape is
165
183
  the panel's too — used up the same way, so it does not reach the dialog either. With the
166
184
  panel closed, Escape is not the bar's and goes on to whoever owns it. */
@@ -416,7 +434,12 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
416
434
  onCriteriaChange([]);
417
435
  setOpenGroup(null);
418
436
  input.current?.focus();
419
- }, "aria-label": copy.search.clearAll, title: copy.search.clearAll, className: `my-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center rounded-control px-1.5 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:bg-ink/5 hover:text-ink", "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: _jsx(X, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }) })), columns.length === 0 && onOpenBuilder === undefined ? null : (_jsxs("button", { ref: toolsButton, type: "button", onClick: () => setPanel((v) => !v), "aria-expanded": panel, "aria-controls": panel ? id : undefined, "aria-label": puestos === 0
437
+ }, "aria-label": copy.search.clearAll, title: copy.search.clearAll, className: `my-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center rounded-control px-1.5 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${bySurface(sup, "text-muted hover:bg-ink/5 hover:text-ink", "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: _jsx(X, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }) })), columns.length === 0 && onOpenBuilder === undefined ? null : (_jsxs("button", { ref: toolsButton, type: "button", onClick: () => {
438
+ const rect = box.current?.getBoundingClientRect();
439
+ if (!panel && rect !== undefined)
440
+ setPanelSide(window.innerWidth - rect.left >= rect.right ? "start" : "end");
441
+ setPanel((v) => !v);
442
+ }, "aria-expanded": panel, "aria-controls": panel ? id : undefined, "aria-label": puestos === 0
420
443
  ? copy.search.tools
421
444
  : fillCopy(puestos === 1 ? copy.search.toolsSetOne : copy.search.toolsSetMany, {
422
445
  label: copy.search.tools,
@@ -439,9 +462,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
439
462
  onSelect: () => pick(one),
440
463
  })) }) })) : (_jsx("div", { id: listId, role: "listbox", "aria-label": copy.search.suggestions, className: "p-1", children: suggestions.map((one, at) => (_jsxs("div", { id: optionId(at), role: "option", "aria-selected": at === active,
441
464
  /* The input keeps the focus: pressing an option must not take it. */
442
- onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-control px-2 py-1.5 text-left text-meta transition-colors duration-(--duration-instant) ${at === active ? "bg-primary/8" : "hover:bg-ink/4"}`, children: [_jsx("span", { className: "shrink-0 font-medium text-ink", children: one.label }), one.kind === "condition" || one.kind === "literal" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-muted", children: ":" }), _jsx("span", { className: "min-w-0 truncate font-mono text-micro text-ink", children: one.hint })] })) : one.kind === "field" && one.hint !== undefined ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro text-muted", children: one.hint })) : null] }, one.id))) }))] })) : null, panel && (columns.length > 0 || onOpenBuilder !== undefined) ? (_jsxs("div", { ...overlayProps, ref: panelBox, id: id, className: "absolute top-full right-0 z-30 mt-1 flex w-max max-w-full flex-wrap overflow-hidden rounded-panel border border-line-strong bg-surface shadow-float", children: [columns.map((c, i) => (_jsxs("div", { className: `flex min-w-48 flex-1 flex-col ${i === 0 ? "" : "border-t border-line sm:border-t-0 sm:border-l"}`, children: [_jsx("div", { className: "border-b border-line px-2.5 py-1.5 text-micro font-medium text-muted", children: c.title }), _jsx("div", { className: "flex flex-col gap-0.5 p-1", children: c.content ??
443
- c.groups?.map((g, gi) => (_jsx(Group, { group: g, first: gi === 0, onSelect: c.onSelect }, g.label ?? gi))) })] }, c.title))), onOpenBuilder === undefined ? null : (_jsx("div", { className: "w-full border-t border-line p-1", children: _jsxs("button", { type: "button", onClick: () => {
444
- onOpenBuilder();
445
- setPanel(false);
446
- }, className: "flex w-full items-center gap-2 rounded-control px-1.5 py-1 text-left text-meta text-ink transition-colors duration-(--duration-instant) hover:bg-primary/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(SlidersHorizontal, { className: "size-(--size-icon-sm)", strokeWidth: 2 }), copy.search.openBuilder] }) }))] })) : null] }));
465
+ onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-control px-2 py-1.5 text-left text-meta transition-colors duration-(--duration-instant) ${at === active ? "bg-primary/8" : "hover:bg-ink/4"}`, children: [_jsx("span", { className: "shrink-0 font-medium text-ink", children: one.label }), one.kind === "condition" || one.kind === "literal" ? (_jsxs(_Fragment, { children: [_jsx("span", { className: "shrink-0 text-muted", children: ":" }), _jsx("span", { className: "min-w-0 truncate font-mono text-micro text-ink", children: one.hint })] })) : one.kind === "field" && one.hint !== undefined ? (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-line-strong bg-ink/5 px-2 py-0.5 text-micro text-muted", children: one.hint })) : null] }, one.id))) }))] })) : null, panel && (columns.length > 0 || onOpenBuilder !== undefined) ? (_jsx(Overlay, { children: _jsxs("div", { ...mergeProps(overlayProps, positionProps), ref: panelBox, id: id, "data-react-aria-top-layer": "", className: "z-30 flex w-max max-w-(--container-cuts) flex-wrap overflow-hidden rounded-panel border border-line-strong bg-surface shadow-float", children: [columns.map((c, i) => (_jsxs("div", { className: `flex min-w-48 flex-1 flex-col ${i === 0 ? "" : "border-t border-line sm:border-t-0 sm:border-l"}`, children: [_jsx("div", { className: "border-b border-line px-2.5 py-1.5 text-micro font-medium text-muted", children: c.title }), _jsx("div", { className: "flex max-h-96 flex-col gap-0.5 overflow-y-auto p-1", children: c.content ??
466
+ c.groups?.map((g, gi) => (_jsx(Group, { group: g, first: gi === 0, onSelect: c.onSelect }, g.label ?? gi))) })] }, c.title))), onOpenBuilder === undefined ? null : (_jsx("div", { className: "w-full border-t border-line p-1", children: _jsxs("button", { type: "button", onClick: () => {
467
+ onOpenBuilder();
468
+ setPanel(false);
469
+ }, className: "flex w-full items-center gap-2 rounded-control px-1.5 py-1 text-left text-meta text-ink transition-colors duration-(--duration-instant) hover:bg-primary/8 focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary", children: [_jsx(SlidersHorizontal, { className: "size-(--size-icon-sm)", strokeWidth: 2 }), copy.search.openBuilder] }) }))] }) })) : null] }));
447
470
  }
@@ -5,10 +5,17 @@ menu,
5
5
  /** The band at the bottom. It goes AFTER the content, not pinned to the
6
6
  * floor of the window — pinning left a hole between it and a short view. */
7
7
  status,
8
- /** The module's navigation, on the left of the view: a `NavigationTree`. */
9
- sidebar, children, }: {
8
+ /** The module's navigation, on the left of the view: a `NavigationTree`, or a `Sidebar`
9
+ * around one when there is no `menu` and the sidebar is the application's chrome. On a
10
+ * phone it opens as a drawer. */
11
+ sidebar,
12
+ /** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
13
+ * drawer and something has to open it — a `TopBar` with the product's name, which draws
14
+ * the button first. A bare `TopBar` by default. */
15
+ narrowMenu, children, }: {
10
16
  menu?: ReactNode;
11
17
  status?: ReactNode;
12
18
  sidebar?: ReactNode;
19
+ narrowMenu?: ReactNode;
13
20
  children: ReactNode;
14
21
  }): import("react").JSX.Element;
@@ -1,8 +1,15 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { HeaderSlotContext } from "./headerSlot.js";
4
+ import { SidebarDrawerContext } from "./sidebarDrawer.js";
5
+ import { TopBar } from "./TopBar.js";
6
+ import { useUiCopy } from "../../foundations/copy.js";
7
+ import { HANDHELD_WIDTH } from "../../foundations/layout.js";
4
8
  import { stickyTop, useStickyLayer } from "../../foundations/sticky.js";
5
- import { useState } from "react";
9
+ import { IconButton } from "../../primitives/button/Button.js";
10
+ import { X } from "lucide-react";
11
+ import { useEffect, useId, useMemo, useState } from "react";
12
+ import { Dialog as AriaDialog, Modal, ModalOverlay } from "react-aria-components";
6
13
  /* ==================================================================== *
7
14
  * THE APPLICATION FRAME — the three bands, and nothing between them.
8
15
  *
@@ -52,15 +59,63 @@ import { useState } from "react";
52
59
  * is left of the window and scrolls on its own, so a long module never takes
53
60
  * the page with it. The page still scrolls as a whole — only the view moves.
54
61
  * Without a `sidebar` the frame is exactly what it was.
62
+ *
63
+ * ── The sidebar AS the chrome: no `menu` ────────────────────────────
64
+ *
65
+ * ┌──────────┬────────────────────────────────────────────┐
66
+ * │ brand │ view │
67
+ * │ user │ …its own header sticks at the top… │
68
+ * │ sections │ │
69
+ * │ ──────── │ │
70
+ * │ sign out │ │
71
+ * └──────────┴────────────────────────────────────────────┘
72
+ *
73
+ * A back office whose navigation is all in the sidebar has no bar on top: the
74
+ * sidebar is as tall as the window and holds the brand and the user itself
75
+ * (`Sidebar`). A view's header then stays in the view's column — there is no
76
+ * bar for it to hang under, and spanning above the sidebar it would push the
77
+ * brand down from the top-left, which is the brand's place.
78
+ *
79
+ * ── On a phone the sidebar is a drawer ──────────────────────────────
80
+ *
81
+ * Below `sm` a 15 rem column is two thirds of the screen. The sidebar is hidden
82
+ * and the SAME content opens as a drawer from the start edge: from a button the
83
+ * `TopBar` draws first, or — with no `menu` — from the bar the frame draws for
84
+ * the phone alone (`narrowMenu`, a bare `TopBar` by default). Following a link
85
+ * in it closes it: the person went where they were going.
55
86
  * ==================================================================== */
87
+ /* Following a link closes the drawer. On the CAPTURE phase: React Aria's links stop the
88
+ click from bubbling, and a keyboard Enter on one reaches here as the click it dispatches. */
89
+ function closeOnLink(close) {
90
+ return (event) => {
91
+ if (event.target.closest("a[href]") !== null)
92
+ close();
93
+ };
94
+ }
95
+ /** The sidebar as a drawer, for a phone: modal (the page behind is inert and dimmed, the
96
+ * focus is kept inside and returns to the button), dismissed by the scrim, Escape, its ×
97
+ * or a link followed. */
98
+ function SidebarDrawerPanel({ id, open, onClose, children, }) {
99
+ const copy = useUiCopy();
100
+ return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: (next) => {
101
+ if (!next)
102
+ onClose();
103
+ }, isDismissable: true, className: ({ isEntering, isExiting }) => `fixed inset-0 z-50 bg-scrim/40 transition-opacity duration-(--duration-quick) ease-(--ease-out) sm:hidden ${isEntering || isExiting ? "opacity-0" : ""}`, children: _jsx(Modal, { className: ({ isEntering, isExiting }) => `fixed inset-y-0 start-0 flex w-(--container-drawer) flex-col border-e border-line-strong bg-ground shadow-window outline-0 transition-[translate] duration-(--duration-panel) ease-(--ease-out) ${isEntering || isExiting ? "-translate-x-full rtl:translate-x-full" : ""}`, children: _jsxs(AriaDialog, { id: id, "aria-label": copy.shell.navigation, className: "flex min-h-0 flex-1 flex-col outline-0", children: [_jsx("div", { className: "flex shrink-0 justify-end px-2 pt-2", children: _jsx(IconButton, { icon: X, label: copy.shell.close, onClick: onClose }) }), _jsx("div", { className: "flex min-h-0 flex-1 flex-col overflow-y-auto", onClickCapture: closeOnLink(onClose), children: children })] }) }) }));
104
+ }
56
105
  export function AppFrame({
57
106
  /** The bar at the top. It stays in view while scrolling. */
58
107
  menu,
59
108
  /** The band at the bottom. It goes AFTER the content, not pinned to the
60
109
  * floor of the window — pinning left a hole between it and a short view. */
61
110
  status,
62
- /** The module's navigation, on the left of the view: a `NavigationTree`. */
63
- sidebar, children, }) {
111
+ /** The module's navigation, on the left of the view: a `NavigationTree`, or a `Sidebar`
112
+ * around one when there is no `menu` and the sidebar is the application's chrome. On a
113
+ * phone it opens as a drawer. */
114
+ sidebar,
115
+ /** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
116
+ * drawer and something has to open it — a `TopBar` with the product's name, which draws
117
+ * the button first. A bare `TopBar` by default. */
118
+ narrowMenu, children, }) {
64
119
  /* The top bar MEASURES what it takes and passes it to what is below: a list's
65
120
  bar sticks beneath it, and a table's header beneath the other two. None of the
66
121
  three has a fixed height — see `system/sticky.tsx`. */
@@ -69,12 +124,45 @@ sidebar, children, }) {
69
124
  application bar, and it pushes the stack down for the sidebar and the table header. */
70
125
  const [slot, setSlot] = useState(null);
71
126
  const head = useStickyLayer();
72
- return (
73
- /* The frame owns the page: its background and its full height. A screen built inside
74
- it is only composition — before, every page had to wrap itself in a `div` with the
75
- ground color and `min-h-dvh`, and the one that forgot ended where its content did. */
76
- _jsxs("div", { className: "relative flex min-h-dvh min-w-0 flex-col bg-ground", children: [menu === undefined ? null : (_jsx("div", { ref: bar.ref, className: "sticky top-0 z-40", children: menu })), sidebar === undefined ? (_jsx("main", { className: "flex min-w-0 flex-1 flex-col", style: bar.below, children: children })) : (_jsx(HeaderSlotContext, { value: slot, children: _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", style: bar.below, children: [_jsx("div", { ref: (node) => {
77
- head.ref.current = node;
78
- setSlot(node);
79
- }, className: "sticky z-30 min-w-0", style: head.self }), _jsxs("div", { className: "flex min-w-0 flex-1 items-start", style: head.below, children: [_jsx("aside", { className: "sticky w-(--container-sidebar) shrink-0 self-start overflow-y-auto overscroll-contain border-r border-line bg-ground", style: { ...stickyTop, height: "calc(100dvh - var(--sticky-top, 0px))" }, children: sidebar }), _jsx("main", { className: "flex min-w-0 flex-1 flex-col self-stretch", children: children })] })] }) })), status] }));
127
+ const hasSidebar = sidebar !== undefined;
128
+ const [drawerOpen, setDrawerOpen] = useState(false);
129
+ const drawerId = useId();
130
+ const drawer = useMemo(() => hasSidebar
131
+ ? {
132
+ isOpen: drawerOpen,
133
+ open: () => setDrawerOpen(true),
134
+ close: () => setDrawerOpen(false),
135
+ id: drawerId,
136
+ }
137
+ : null, [hasSidebar, drawerOpen, drawerId]);
138
+ /* A window widened past the phone while the drawer was open (a tablet turned): the
139
+ sidebar is back beside the view, and a modal drawer left open would keep the page inert
140
+ behind a panel CSS has already hidden. */
141
+ useEffect(() => {
142
+ if (!drawerOpen)
143
+ return;
144
+ const wide = window.matchMedia(`(min-width: ${HANDHELD_WIDTH}px)`);
145
+ const close = () => {
146
+ if (wide.matches)
147
+ setDrawerOpen(false);
148
+ };
149
+ close();
150
+ wide.addEventListener("change", close);
151
+ return () => wide.removeEventListener("change", close);
152
+ }, [drawerOpen]);
153
+ /* With no `menu` the sidebar is the chrome: on a wide screen nothing is on top of it, and
154
+ on a phone a bar appears to open it. */
155
+ const sidebarIsChrome = hasSidebar && menu === undefined;
156
+ const top = sidebarIsChrome ? (narrowMenu ?? _jsx(TopBar, {})) : menu;
157
+ /* The sidebar sits on the ground tone, the content on the paper (surface): the same white
158
+ for both made the navigation read as part of the list bar. On a phone it is hidden: the
159
+ drawer shows it. */
160
+ const aside = sidebar === undefined ? null : (_jsx("aside", { className: "sticky w-(--container-sidebar) shrink-0 self-start overflow-y-auto overscroll-contain border-r border-line bg-ground max-sm:hidden", style: { ...stickyTop, height: "calc(100dvh - var(--sticky-top, 0px))" }, children: sidebar }));
161
+ return (_jsx(SidebarDrawerContext, { value: drawer, children: _jsxs("div", { className: "relative flex min-h-dvh min-w-0 flex-col bg-ground", children: [top === undefined ? null : (
162
+ /* Hidden on a wide screen when it is only the phone's bar: it measures 0 there, so
163
+ nothing below is pushed down by it. */
164
+ _jsx("div", { ref: bar.ref, className: `sticky top-0 z-40 ${sidebarIsChrome ? "sm:hidden" : ""}`, children: top })), sidebar === undefined ? (_jsx("main", { className: "flex min-w-0 flex-1 flex-col", style: bar.below, children: children })) : sidebarIsChrome ? (_jsxs("div", { className: "flex min-w-0 flex-1 items-start", style: bar.below, children: [aside, _jsx("main", { className: "flex min-w-0 flex-1 flex-col self-stretch", children: children })] })) : (_jsx(HeaderSlotContext, { value: slot, children: _jsxs("div", { className: "flex min-w-0 flex-1 flex-col", style: bar.below, children: [_jsx("div", { ref: (node) => {
165
+ head.ref.current = node;
166
+ setSlot(node);
167
+ }, className: "sticky z-30 min-w-0", style: head.self }), _jsxs("div", { className: "flex min-w-0 flex-1 items-start", style: head.below, children: [aside, _jsx("main", { className: "flex min-w-0 flex-1 flex-col self-stretch", children: children })] })] }) })), status, sidebar === undefined ? null : (_jsx(SidebarDrawerPanel, { id: drawerId, open: drawerOpen, onClose: () => setDrawerOpen(false), children: sidebar }))] }) }));
80
168
  }
@@ -0,0 +1,34 @@
1
+ import type { LucideIcon } from "lucide-react";
2
+ import type { ReactNode } from "react";
3
+ export type SidebarAction = {
4
+ id: string;
5
+ label: string;
6
+ icon?: LucideIcon;
7
+ /** A link instead of an action — «Ver el sitio». It is followed, not reported. */
8
+ href?: string;
9
+ /** The link opens in another tab; a screen reader is told so. */
10
+ external?: boolean;
11
+ };
12
+ export type SidebarProps = {
13
+ /** The product, at the top: its name and its mark — an icon, or the logo's image. */
14
+ brand?: {
15
+ label: string;
16
+ icon?: LucideIcon;
17
+ logo?: string;
18
+ };
19
+ /** Who is signed in. */
20
+ user?: {
21
+ name: string;
22
+ detail?: string;
23
+ avatar?: string;
24
+ };
25
+ /** The navigation: a `NavigationTree`. It scrolls; the top and the bottom stay. */
26
+ children: ReactNode;
27
+ /** The account, pinned to the bottom: change the password, view the site, sign out. */
28
+ actions?: readonly SidebarAction[];
29
+ /** An action without `href` was chosen. */
30
+ onAction?: (id: string) => void;
31
+ /** Anything else at the very bottom: a `ThemeSwitcher`, the version. */
32
+ footer?: ReactNode;
33
+ };
34
+ export declare function Sidebar({ brand, user, children, actions, onAction, footer }: SidebarProps): import("react").JSX.Element;
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { useSidebarDrawer } from "./sidebarDrawer.js";
4
+ import { useUiCopy } from "../../foundations/copy.js";
5
+ import { Avatar } from "../../primitives/value/Person.js";
6
+ const ROW = "flex h-(--size-control-sm) w-full min-w-0 cursor-pointer items-center gap-2 rounded-control px-2 text-meta text-ink no-underline transition-colors duration-(--duration-instant) hover:bg-ink/6 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary";
7
+ function Brand({ brand }) {
8
+ const Icon = brand.icon;
9
+ return (_jsxs("div", { 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 text-primary", strokeWidth: 1.75, "aria-hidden": true }))) : (_jsx("img", { src: brand.logo, alt: "", className: "size-(--size-control-md) shrink-0 object-contain" })), _jsx("span", { className: "min-w-0 truncate text-lead font-semibold text-ink", children: brand.label })] }));
10
+ }
11
+ function User({ user }) {
12
+ return (_jsxs("div", { 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 text-ink", children: user.name }), user.detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-muted", children: user.detail }))] })] }));
13
+ }
14
+ function Action({ action, onAction, }) {
15
+ const copy = useUiCopy();
16
+ const drawer = useSidebarDrawer();
17
+ const Icon = action.icon;
18
+ const content = (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "min-w-0 truncate", children: action.label })] }));
19
+ if (action.href !== undefined) {
20
+ 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] }));
21
+ }
22
+ return (_jsx("button", { type: "button", className: ROW, onClick: () => {
23
+ onAction?.(action.id);
24
+ drawer?.close();
25
+ }, children: content }));
26
+ }
27
+ export function Sidebar({ brand, user, children, actions, onAction, footer }) {
28
+ const copy = useUiCopy();
29
+ const head = brand !== undefined || user !== undefined;
30
+ const foot = (actions !== undefined && actions.length > 0) || footer !== undefined;
31
+ return (_jsxs("div", { className: "flex h-full min-h-0 min-w-0 flex-col", children: [head ? (_jsxs("div", { className: "shrink-0 border-b border-line pb-2", children: [brand === undefined ? null : _jsx(Brand, { brand: brand }), user === undefined ? null : _jsx(User, { user: user })] })) : null, _jsx("div", { className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { className: "flex shrink-0 flex-col gap-2 border-t border-line p-2", children: [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", { children: _jsx(Action, { action: action, ...(onAction === undefined ? {} : { onAction }) }) }, action.id))) })), footer] })) : null] }));
32
+ }
@@ -12,6 +12,8 @@ export interface TopMenu {
12
12
  id: string;
13
13
  label: string;
14
14
  groups: readonly MenuGroup[];
15
+ /** What is waiting inside — «Pagos 5» — seen without opening the menu. Zero is not drawn. */
16
+ count?: number;
15
17
  }
16
18
  export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
17
19
  /** The product's name, when there is ONE product. It is drawn like the