@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.
Files changed (72) hide show
  1. package/README.md +111 -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/GroupingLevels.js +11 -9
  9. package/dist/components/listing/RecordCard.js +1 -1
  10. package/dist/components/listing/Row.js +2 -2
  11. package/dist/components/navigation/NavigationTree.js +37 -10
  12. package/dist/components/search/CriteriaBuilder.js +3 -2
  13. package/dist/components/search/CriteriaChips.js +6 -5
  14. package/dist/components/search/JoinWord.js +1 -1
  15. package/dist/components/search/SearchBar.js +68 -29
  16. package/dist/components/shell/AppFrame.d.ts +18 -2
  17. package/dist/components/shell/AppFrame.js +143 -12
  18. package/dist/components/shell/Sidebar.d.ts +39 -0
  19. package/dist/components/shell/Sidebar.js +57 -0
  20. package/dist/components/shell/TopBar.d.ts +10 -1
  21. package/dist/components/shell/TopBar.js +18 -13
  22. package/dist/components/shell/brandMark.d.ts +17 -0
  23. package/dist/components/shell/brandMark.js +9 -0
  24. package/dist/components/shell/index.d.ts +3 -0
  25. package/dist/components/shell/index.js +6 -0
  26. package/dist/components/shell/sidebarDrawer.d.ts +26 -0
  27. package/dist/components/shell/sidebarDrawer.js +22 -0
  28. package/dist/foundations/copy.d.ts +13 -0
  29. package/dist/foundations/copy.es.js +12 -5
  30. package/dist/foundations/copy.js +12 -5
  31. package/dist/foundations/variants.js +19 -2
  32. package/dist/primitives/block/Block.js +1 -1
  33. package/dist/primitives/button/Button.d.ts +3 -1
  34. package/dist/primitives/button/Button.js +6 -6
  35. package/dist/primitives/choice/SegmentedControl.d.ts +4 -1
  36. package/dist/primitives/choice/SegmentedControl.js +35 -7
  37. package/dist/primitives/dialog/Dialog.d.ts +1 -1
  38. package/dist/primitives/dialog/Dialog.js +2 -2
  39. package/dist/primitives/field/CardNumberInput.js +1 -1
  40. package/dist/primitives/field/Checks.d.ts +14 -0
  41. package/dist/primitives/field/Checks.js +12 -4
  42. package/dist/primitives/field/DropZone.d.ts +22 -3
  43. package/dist/primitives/field/DropZone.js +33 -12
  44. package/dist/primitives/field/DurationInput.js +1 -1
  45. package/dist/primitives/field/Field.js +7 -7
  46. package/dist/primitives/field/PatternInput.js +1 -1
  47. package/dist/primitives/field/RichTextEditor.js +2 -2
  48. package/dist/primitives/field/SignatureInput.js +1 -1
  49. package/dist/primitives/field/aria.d.ts +2 -2
  50. package/dist/primitives/field/aria.js +5 -5
  51. package/dist/primitives/field/index.d.ts +1 -1
  52. package/dist/primitives/field/index.js +1 -1
  53. package/dist/primitives/menu/Menu.d.ts +29 -9
  54. package/dist/primitives/menu/Menu.js +77 -22
  55. package/dist/primitives/overlay/Popover.js +2 -2
  56. package/dist/primitives/picker/Picker.js +3 -3
  57. package/dist/primitives/picker/TagsField.js +1 -1
  58. package/dist/primitives/table/EditableTable.js +2 -2
  59. package/dist/primitives/table/ReportTable.js +1 -1
  60. package/dist/primitives/table/Table.js +2 -2
  61. package/dist/primitives/tabs/Tabs.js +2 -28
  62. package/dist/primitives/tag/Count.d.ts +23 -0
  63. package/dist/primitives/tag/Count.js +59 -0
  64. package/dist/primitives/tag/Tag.d.ts +9 -0
  65. package/dist/primitives/tag/Tag.js +14 -1
  66. package/dist/primitives/tag/Tags.js +6 -7
  67. package/dist/primitives/tag/index.d.ts +1 -0
  68. package/dist/primitives/tag/index.js +3 -0
  69. package/dist/primitives/value/Metric.d.ts +7 -2
  70. package/dist/primitives/value/Metric.js +14 -6
  71. package/dist/tokens.css +306 -72
  72. package/package.json +1 -1
@@ -5,27 +5,31 @@ import { CriteriaChips } from "./CriteriaChips.js";
5
5
  import { describeCondition, opLabel, queryFields, readTyped, suggest, withoutValue, } from "./query.js";
6
6
  import { fillCopy, useUiCopy } from "../../foundations/copy.js";
7
7
  import { bySurface, useSurface } from "../../foundations/surface.js";
8
+ import { CheckMark } from "../../primitives/field/Checks.js";
9
+ import { Count } from "../../primitives/tag/Count.js";
10
+ import { chosenTone } from "../../primitives/tag/Tag.js";
8
11
  import { Tags } from "../../primitives/tag/Tags.js";
9
- import { ChevronRight, CornerDownRight, ListFilter, Search, SlidersHorizontal, X, } from "lucide-react";
12
+ import { ChevronRight, CornerDownRight, Layers, ListFilter, Search, SlidersHorizontal, Star, X, } from "lucide-react";
10
13
  import { Fragment, useEffect, useId, useRef, useState } from "react";
11
- import { useOverlay } from "react-aria";
12
- function Option({ o, onSelect }) {
14
+ import { mergeProps, Overlay, useOverlay, useOverlayPosition } from "react-aria";
15
+ function Option({ o, checks, onSelect, }) {
13
16
  const Icon = o.icon;
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 }))] })] }));
17
+ const toggles = checks || o.checked !== undefined;
18
+ return (_jsxs("button", { type: "button", disabled: o.disabled, onClick: () => onSelect?.(o.id), ...(toggles ? { "aria-pressed": o.checked === true } : {}), className: "flex w-full items-start gap-2 rounded-ui-option px-1.5 py-1 text-left transition-colors duration-(--duration-instant) disabled:pointer-events-none disabled:opacity-45 hover:bg-ui-option-active", children: [_jsx("span", { className: "mt-0.5 flex size-(--size-icon-sm) shrink-0 items-center justify-center", children: toggles ? (_jsx(CheckMark, { on: o.checked === true })) : Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2, "aria-hidden": true })) }), _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 }))] })] }));
15
19
  }
16
20
  /** A panel group. Collapsible when it asks —a date, which brings eleven
17
21
  * options— and open from the start if it already has something ticked: otherwise what is set
18
22
  * stays hidden behind a chevron and you have to guess where it is. */
19
- function Group({ group, first, onSelect, }) {
23
+ function Group({ group, first, checks, onSelect, }) {
20
24
  const active = group.options.some((o) => o.checked === true);
21
25
  const [open, setOpen] = useState(active);
22
- const options = (_jsx(_Fragment, { children: group.options.map((o) => (_jsxs(Fragment, { children: [o.divider === true ? _jsx("div", { className: "my-1 h-px bg-line", role: "separator" }) : null, _jsx(Option, { o: o, onSelect: onSelect })] }, o.id))) }));
26
+ const options = (_jsx(_Fragment, { children: group.options.map((o) => (_jsxs(Fragment, { children: [o.divider === true ? _jsx("div", { className: "my-1 h-px bg-line", role: "separator" }) : null, _jsx(Option, { o: o, checks: checks, onSelect: onSelect })] }, o.id))) }));
23
27
  return (_jsxs("div", { className: "flex flex-col gap-0.5", children: [first ? null : _jsx("div", { className: "my-1 h-px bg-line", role: "separator" }), group.label === undefined ? null : group.collapsible !== true ? (
24
- /* The group's label goes in the TEXT column, not the edge one.
25
- The column's band is already the title (medium, over the line). This
26
- one is a step down: normal weight, and the same gap as the mark
27
- so that «mostrar sólo» starts where «traídos» starts. */
28
- _jsxs("div", { className: "flex items-center gap-2 px-1.5 pt-1 pb-0.5 text-micro text-muted", children: [_jsx("span", { className: "size-(--size-icon-sm) shrink-0", "aria-hidden": true }), group.label] })) : (_jsxs("button", { type: "button", onClick: () => setOpen(!open), "aria-expanded": open, className: "flex items-center gap-2 rounded-control px-1.5 py-1 text-left transition-colors duration-(--duration-instant) hover:bg-primary/8", 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 ${active ? "font-medium text-ink" : "text-ink"}`, children: group.label }), !active ? null : (_jsx("span", { className: "inline-flex shrink-0 items-center rounded-pill border border-accent/40 bg-accent/18 px-2 py-0.5 text-micro tabular-nums text-ink", children: group.options.filter((o) => o.checked === true).length }))] })), group.collapsible === true && !open ? null : (_jsx("div", { className: group.collapsible === true
28
+ /* The group's label goes in the TEXT column, not the edge one. The column's title
29
+ is the step above (the section, with its icon); this one is a step down: the
30
+ quiet size, and the same gap as the mark so that «mostrar sólo» starts where
31
+ «traídos» starts. */
32
+ _jsxs("div", { className: "flex items-center gap-2 px-1.5 pt-1 pb-0.5 text-micro text-muted", children: [_jsx("span", { className: "size-(--size-icon-sm) shrink-0", "aria-hidden": true }), group.label] })) : (_jsxs("button", { type: "button", onClick: () => setOpen(!open), "aria-expanded": open, 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(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 ${active ? "font-medium text-ink" : "text-ink"}`, children: group.label }), !active ? null : (_jsx(Count, { value: group.options.filter((o) => o.checked === true).length }))] })), group.collapsible === true && !open ? null : (_jsx("div", { className: group.collapsible === true
29
33
  ? "flex flex-col gap-0.5 pl-(--spacing-indent)"
30
34
  : "flex flex-col gap-0.5", children: options }))] }));
31
35
  }
@@ -34,6 +38,10 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
34
38
  const sup = useSurface(surface);
35
39
  const [text, setText] = useState("");
36
40
  const [panel, setPanel] = useState(false);
41
+ /* Which edge of the field the panel hangs from. It is wider than the field when the
42
+ field is narrow, so it opens toward the side of the screen with room: from the start
43
+ of a field on the left of a page, from its end on the right. */
44
+ const [panelSide, setPanelSide] = useState("end");
37
45
  /** The step the question being written is at: no field, with a field, or
38
46
  * with a field and operator. */
39
47
  const [step, setStep] = useState({});
@@ -131,11 +139,28 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
131
139
  const columns = [
132
140
  ...(filters === undefined || !withOptions(filters)
133
141
  ? []
134
- : [{ title: copy.search.filters, groups: filters, onSelect: onFilterSelect }]),
135
- ...(grouping === undefined ? [] : [{ title: copy.search.groupBy, content: grouping }]),
142
+ : [
143
+ {
144
+ title: copy.search.filters,
145
+ icon: ListFilter,
146
+ groups: filters,
147
+ checks: true,
148
+ onSelect: onFilterSelect,
149
+ },
150
+ ]),
151
+ ...(grouping === undefined
152
+ ? []
153
+ : [{ title: copy.search.groupBy, icon: Layers, content: grouping }]),
136
154
  ...(favorites === undefined || !withOptions(favorites)
137
155
  ? []
138
- : [{ title: copy.search.favorites, groups: favorites, onSelect: onFavoriteSelect }]),
156
+ : [
157
+ {
158
+ title: copy.search.favorites,
159
+ icon: Star,
160
+ groups: favorites,
161
+ onSelect: onFavoriteSelect,
162
+ },
163
+ ]),
139
164
  ];
140
165
  /* THE PANEL IS A LAYER, and Escape closes the layer on top — only that one.
141
166
 
@@ -161,6 +186,20 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
161
186
  isDismissable: true,
162
187
  shouldCloseOnInteractOutside: (element) => box.current?.contains(element) !== true,
163
188
  }, panelBox);
189
+ /* The panel floats in the page's overlay layer (`Overlay`, a portal React Aria stacks with
190
+ dialogs), placed against the field: a list's bar clips its search box sideways
191
+ (`ListingBar`, so the field never paints over «1–80») and a page may clip its card, and a
192
+ panel drawn inside them was cut wherever it outgrew the field. Placed this way it is as
193
+ wide as `--container-cuts`, inside the screen, toward the side with room. */
194
+ const { overlayProps: positionProps } = useOverlayPosition({
195
+ targetRef: box,
196
+ overlayRef: panelBox,
197
+ placement: panelSide === "start" ? "bottom start" : "bottom end",
198
+ offset: 4,
199
+ containerPadding: 16,
200
+ shouldFlip: false,
201
+ isOpen: panel,
202
+ });
164
203
  /* With the focus still in the bar (the input, the button) and the panel open, Escape is
165
204
  the panel's too — used up the same way, so it does not reach the dialog either. With the
166
205
  panel closed, Escape is not the bar's and goes on to whoever owns it. */
@@ -241,12 +280,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
241
280
  ? one
242
281
  : { ...node, of: [...node.of, one] };
243
282
  }
244
- return (_jsxs("div", { ref: box, onKeyDown: closePanelOnEscape,
245
- /* `min-w-48`: placed in a flex row without a width, the bar used to collapse to its
246
- narrowest and the input slid UNDER the filters button («bu⊞car»). 12rem is the
247
- magnifier, a word of input and the buttons; a narrower container scrolls, it does
248
- not stack controls on top of each other. */
249
- className: "relative flex min-w-48 items-center gap-2", children: [_jsxs("div", { className: `@container/bar flex min-h-(--size-control-md) w-full min-w-0 items-start rounded-box border transition-colors duration-(--duration-instant) ${bySurface(sup, "border-line-strong bg-surface focus-within:border-primary/60",
283
+ return (_jsxs("div", { ref: box, onKeyDown: closePanelOnEscape, "data-ui": "search", className: "relative flex min-w-48 items-center gap-2", children: [_jsxs("div", { "data-ui": "search.field", className: `@container/bar flex min-h-(--size-control-md) w-full min-w-0 items-start rounded-ui-search border transition-colors duration-(--duration-instant) ${bySurface(sup, "border-ui-control-border bg-ui-control focus-within:border-primary/60",
250
284
  /* On the chrome what defines the field is the BORDER, not the fill. The
251
285
  blue is already almost black, so sinking it gives no contrast (1.05:1) and
252
286
  raising it gives 1.21:1 — in both cases the field does not read as a
@@ -412,18 +446,23 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
412
446
  is not available, the input stretches as always. */
413
447
  style: step.field === undefined ? undefined : { fieldSizing: "content" }, className: step.field === undefined
414
448
  ? `h-7 ${criteria.length === 0 ? "min-w-24" : "min-w-16"} flex-1 bg-transparent text-meta outline-none ${bySurface(sup, "text-ink placeholder:text-muted", "text-chrome-ink placeholder:text-chrome-muted")}`
415
- : `min-w-16 rounded-pill px-2 py-0.5 text-micro outline-none ${bySurface(sup, "bg-accent/18 text-ink placeholder:text-muted", "bg-chrome-link/20 text-chrome-ink placeholder:text-chrome-muted")}` })] }), puestos === 0 ? null : (_jsx("button", { type: "button", onClick: () => {
449
+ : `min-w-16 rounded-pill px-2 py-0.5 text-micro outline-none ${bySurface(sup, "bg-primary/8 text-ink placeholder:text-muted", "bg-chrome-link/20 text-chrome-ink placeholder:text-chrome-muted")}` })] }), puestos === 0 ? null : (_jsx("button", { type: "button", onClick: () => {
416
450
  onCriteriaChange([]);
417
451
  setOpenGroup(null);
418
452
  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
453
+ }, "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: () => {
454
+ const rect = box.current?.getBoundingClientRect();
455
+ if (!panel && rect !== undefined)
456
+ setPanelSide(window.innerWidth - rect.left >= rect.right ? "start" : "end");
457
+ setPanel((v) => !v);
458
+ }, "aria-expanded": panel, "aria-controls": panel ? id : undefined, "aria-label": puestos === 0
420
459
  ? copy.search.tools
421
460
  : fillCopy(puestos === 1 ? copy.search.toolsSetOne : copy.search.toolsSetMany, {
422
461
  label: copy.search.tools,
423
462
  count: puestos.toLocaleString(copy.locale),
424
463
  }), title: copy.search.tools, className: `my-0.5 mr-0.5 inline-flex h-(--size-control-sm) shrink-0 items-center gap-1 rounded-control border px-2 text-micro transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${puestos > 0 || panel
425
- ? bySurface(sup, "border-accent/40 bg-accent/18 text-ink", "border-chrome-link/35 bg-chrome-link/15 text-chrome-link")
426
- : bySurface(sup, "border-transparent text-muted hover:bg-ink/5 hover:text-ink", "border-transparent text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: [_jsx(ListFilter, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }), puestos > 0 ? _jsx("span", { className: "text-micro tabular-nums", children: puestos }) : null] }))] }), trailing, open ? (_jsxs("div", { className: `absolute top-full z-30 mt-1 overflow-hidden rounded-panel border border-line-strong bg-surface shadow-float ${asTags ? "left-0 w-max max-w-full" : "right-0 left-0"}`, children: [openJoin === undefined ? null : (_jsxs("div", { className: "flex items-center gap-1.5 border-line border-b px-3 py-1.5 text-micro text-muted", children: [_jsx(CornerDownRight, { className: "size-3 shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: copy.search.landsHere }), _jsx("span", { className: "shrink-0 rounded-pill border border-accent/40 bg-accent/18 px-1.5 text-ink", children: copy.search.joins[openJoin === "not" ? "none" : openJoin] })] })), asTags ? (
464
+ ? bySurface(sup, "border-primary/30 bg-primary/8 text-primary", "border-chrome-link/35 bg-chrome-link/15 text-chrome-link")
465
+ : bySurface(sup, "border-transparent text-muted hover:bg-ink/5 hover:text-ink", "border-transparent text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink")}`, children: [_jsx(ListFilter, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true }), puestos > 0 ? _jsx("span", { className: "text-micro tabular-nums", children: puestos }) : null] }))] }), trailing, open ? (_jsxs("div", { "data-ui": "search.suggestions", className: `absolute top-full z-30 mt-1 overflow-hidden rounded-ui-popover border border-ui-popover-border bg-ui-popover shadow-ui-popover ${asTags ? "left-0 w-max max-w-full" : "right-0 left-0"}`, children: [openJoin === undefined ? null : (_jsxs("div", { className: "flex items-center gap-1.5 border-line border-b px-3 py-1.5 text-micro text-muted", children: [_jsx(CornerDownRight, { className: "size-3 shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: "min-w-0 truncate", children: copy.search.landsHere }), _jsx("span", { className: `shrink-0 rounded-pill px-1.5 ${chosenTone("canvas")}`, children: copy.search.joins[openJoin === "not" ? "none" : openJoin] })] })), asTags ? (
427
466
  /* A LIST, not a strip. You are CHOOSING: the eye goes down a
428
467
  column and so does the keyboard. Twelve attributes folded into three
429
468
  rows are twelve things to sweep in zigzag to find one. */
@@ -439,9 +478,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
439
478
  onSelect: () => pick(one),
440
479
  })) }) })) : (_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
480
  /* 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] }));
481
+ onMouseDown: (event) => event.preventDefault(), onClick: () => pick(one), onMouseEnter: () => setActive(at), className: `flex w-full cursor-pointer items-baseline gap-1.5 rounded-ui-option px-2 py-1.5 text-left text-meta transition-colors duration-(--duration-instant) ${at === active ? "bg-ui-option-active" : "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": "", "data-ui": "search.panel", className: "z-30 flex w-max max-w-(--container-cuts) flex-wrap overflow-hidden rounded-ui-popover border border-ui-popover-border bg-ui-popover shadow-ui-popover", 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: [_jsxs("div", { className: "flex items-center gap-2 px-2.5 pt-2.5 pb-1 text-meta font-semibold text-ink", children: [_jsx(c.icon, { className: "size-(--size-icon-sm) shrink-0 text-muted", strokeWidth: 2, "aria-hidden": true }), c.title] }), _jsx("div", { className: "flex max-h-96 flex-col gap-0.5 overflow-y-auto p-1", children: c.content ??
482
+ c.groups?.map((g, gi) => (_jsx(Group, { group: g, first: gi === 0, checks: c.checks === true, 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: () => {
483
+ onOpenBuilder();
484
+ setPanel(false);
485
+ }, className: "flex w-full items-center gap-2 rounded-ui-option px-1.5 py-1 text-left text-meta text-ink transition-colors duration-(--duration-instant) hover:bg-ui-option-active 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
486
  }
@@ -1,3 +1,4 @@
1
+ import type { Surface } from "../../foundations/types.js";
1
2
  import { type ReactNode } from "react";
2
3
  export declare function AppFrame({
3
4
  /** The bar at the top. It stays in view while scrolling. */
@@ -5,10 +6,25 @@ menu,
5
6
  /** The band at the bottom. It goes AFTER the content, not pinned to the
6
7
  * floor of the window — pinning left a hole between it and a short view. */
7
8
  status,
8
- /** The module's navigation, on the left of the view: a `NavigationTree`. */
9
- sidebar, children, }: {
9
+ /** The module's navigation, on the left of the view: a `NavigationTree`, or a `Sidebar`
10
+ * around one when there is no `menu` and the sidebar is the application's chrome. On a
11
+ * phone it opens as a drawer. */
12
+ sidebar,
13
+ /** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
14
+ * drawer and something has to open it — a `TopBar` with the product's name, which draws
15
+ * the button first. A bare `TopBar` by default. */
16
+ narrowMenu,
17
+ /** The surface of the sidebar and its drawer. `chrome` wears the brand's colour — for the
18
+ * sidebar as the application's chrome (no `menu`). `canvas` by default. */
19
+ sidebarSurface,
20
+ /** Who scrolls. `page` (the default): the whole page, with the bars stuck on top. `view`:
21
+ * the frame is the window's height and the view scrolls inside itself — a workspace. */
22
+ scroll, children, }: {
10
23
  menu?: ReactNode;
11
24
  status?: ReactNode;
12
25
  sidebar?: ReactNode;
26
+ narrowMenu?: ReactNode;
27
+ sidebarSurface?: Surface;
28
+ scroll?: "page" | "view";
13
29
  children: ReactNode;
14
30
  }): import("react").JSX.Element;
@@ -1,8 +1,16 @@
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 { stickyTop, useStickyLayer } from "../../foundations/sticky.js";
5
- import { useState } from "react";
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";
8
+ import { stickyReset, stickyTop, useStickyLayer } from "../../foundations/sticky.js";
9
+ import { bySurface, SurfaceProvider } from "../../foundations/surface.js";
10
+ import { IconButton } from "../../primitives/button/Button.js";
11
+ import { X } from "lucide-react";
12
+ import { useEffect, useId, useMemo, useState } from "react";
13
+ import { Dialog as AriaDialog, Modal, ModalOverlay } from "react-aria-components";
6
14
  /* ==================================================================== *
7
15
  * THE APPLICATION FRAME — the three bands, and nothing between them.
8
16
  *
@@ -52,15 +60,99 @@ import { useState } from "react";
52
60
  * is left of the window and scrolls on its own, so a long module never takes
53
61
  * the page with it. The page still scrolls as a whole — only the view moves.
54
62
  * Without a `sidebar` the frame is exactly what it was.
63
+ *
64
+ * ── The sidebar AS the chrome: no `menu` ────────────────────────────
65
+ *
66
+ * ┌──────────┬────────────────────────────────────────────┐
67
+ * │ brand │ view │
68
+ * │ user │ …its own header sticks at the top… │
69
+ * │ sections │ │
70
+ * │ ──────── │ │
71
+ * │ sign out │ │
72
+ * └──────────┴────────────────────────────────────────────┘
73
+ *
74
+ * A back office whose navigation is all in the sidebar has no bar on top: the
75
+ * sidebar is as tall as the window and holds the brand and the user itself
76
+ * (`Sidebar`). A view's header then stays in the view's column — there is no
77
+ * bar for it to hang under, and spanning above the sidebar it would push the
78
+ * brand down from the top-left, which is the brand's place.
79
+ *
80
+ * ── On a phone the sidebar is a drawer ──────────────────────────────
81
+ *
82
+ * Below `sm` a 15 rem column is two thirds of the screen. The sidebar is hidden
83
+ * and the SAME content opens as a drawer from the start edge: from a button the
84
+ * `TopBar` draws first, or — with no `menu` — from the bar the frame draws for
85
+ * the phone alone (`narrowMenu`, a bare `TopBar` by default). Following a link
86
+ * in it closes it: the person went where they were going.
87
+ *
88
+ * ── In the brand's colour: `sidebarSurface="chrome"` ────────────────
89
+ *
90
+ * The frame paints the column (and the drawer), so the frame is told which
91
+ * surface it is, and hands it to what is inside: a `Sidebar`, its tree, its
92
+ * counts. It is meant for the sidebar AS the chrome — with a `menu` too it
93
+ * would be a second dark band beside the bar's.
94
+ *
95
+ * ── A workspace that scrolls itself: `scroll="view"` ────────────────
96
+ *
97
+ * ┌──────────┬────────────────────────────────────────────┐
98
+ * │ sidebar │ ┌ the workspace ─────────────────────────┐ │
99
+ * │ │ │ its own header sticks at ITS top │ │ ← exactly the window,
100
+ * │ │ │ …and it scrolls inside itself… │ │ minus the bar
101
+ * │ │ └────────────────────────────────────────┘ │
102
+ * └──────────┴────────────────────────────────────────────┘
103
+ *
104
+ * By default the PAGE scrolls and the bars above announce their height in
105
+ * `--sticky-top`, so a view's sticky bands hang under them. A workspace
106
+ * (composer's) is the opposite: it is as tall as the window and scrolls
107
+ * inside its own boxes, where that offset is wrong — a table's header stuck
108
+ * that far down INSIDE the box, over its first rows. With `scroll="view"` the
109
+ * frame is the window's height, the view gets what the bars leave, and the
110
+ * stack starts from zero inside it (`stickyReset`). Without it every app wrote
111
+ * the same two `div`s by hand — the frame this component exists to replace.
112
+ *
113
+ * ── On paper ────────────────────────────────────────────────────────
114
+ *
115
+ * The bar, the sidebar and the drawer do not print: a printed record is the
116
+ * record. And a frame the window's height lets the whole view out on paper.
55
117
  * ==================================================================== */
118
+ /* Following a link closes the drawer. On the CAPTURE phase: React Aria's links stop the
119
+ click from bubbling, and a keyboard Enter on one reaches here as the click it dispatches. */
120
+ function closeOnLink(close) {
121
+ return (event) => {
122
+ if (event.target.closest("a[href]") !== null)
123
+ close();
124
+ };
125
+ }
126
+ /** The sidebar as a drawer, for a phone: modal (the page behind is inert and dimmed, the
127
+ * focus is kept inside and returns to the button), dismissed by the scrim, Escape, its ×
128
+ * or a link followed. */
129
+ function SidebarDrawerPanel({ id, open, onClose, surface, children, }) {
130
+ const copy = useUiCopy();
131
+ return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: (next) => {
132
+ if (!next)
133
+ onClose();
134
+ }, isDismissable: true, className: ({ isEntering, isExiting }) => `fixed inset-0 z-50 bg-scrim/40 transition-opacity duration-(--duration-quick) ease-(--ease-out) sm:hidden print: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 shadow-window outline-0 transition-[translate] duration-(--duration-panel) ease-(--ease-out) ${bySurface(surface, "border-line-strong bg-ground", "border-chrome-edge bg-chrome")} ${isEntering || isExiting ? "-translate-x-full rtl:translate-x-full" : ""}`, children: _jsx(AriaDialog, { id: id, "aria-label": copy.shell.navigation, className: "flex min-h-0 flex-1 flex-col outline-0", children: _jsxs(SurfaceProvider, { value: surface, 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 })] }) }) }) }));
135
+ }
56
136
  export function AppFrame({
57
137
  /** The bar at the top. It stays in view while scrolling. */
58
138
  menu,
59
139
  /** The band at the bottom. It goes AFTER the content, not pinned to the
60
140
  * floor of the window — pinning left a hole between it and a short view. */
61
141
  status,
62
- /** The module's navigation, on the left of the view: a `NavigationTree`. */
63
- sidebar, children, }) {
142
+ /** The module's navigation, on the left of the view: a `NavigationTree`, or a `Sidebar`
143
+ * around one when there is no `menu` and the sidebar is the application's chrome. On a
144
+ * phone it opens as a drawer. */
145
+ sidebar,
146
+ /** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
147
+ * drawer and something has to open it — a `TopBar` with the product's name, which draws
148
+ * the button first. A bare `TopBar` by default. */
149
+ narrowMenu,
150
+ /** The surface of the sidebar and its drawer. `chrome` wears the brand's colour — for the
151
+ * sidebar as the application's chrome (no `menu`). `canvas` by default. */
152
+ sidebarSurface = "canvas",
153
+ /** Who scrolls. `page` (the default): the whole page, with the bars stuck on top. `view`:
154
+ * the frame is the window's height and the view scrolls inside itself — a workspace. */
155
+ scroll = "page", children, }) {
64
156
  /* The top bar MEASURES what it takes and passes it to what is below: a list's
65
157
  bar sticks beneath it, and a table's header beneath the other two. None of the
66
158
  three has a fixed height — see `system/sticky.tsx`. */
@@ -69,12 +161,51 @@ sidebar, children, }) {
69
161
  application bar, and it pushes the stack down for the sidebar and the table header. */
70
162
  const [slot, setSlot] = useState(null);
71
163
  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] }));
164
+ const hasSidebar = sidebar !== undefined;
165
+ const [drawerOpen, setDrawerOpen] = useState(false);
166
+ const drawerId = useId();
167
+ const drawer = useMemo(() => hasSidebar
168
+ ? {
169
+ isOpen: drawerOpen,
170
+ open: () => setDrawerOpen(true),
171
+ close: () => setDrawerOpen(false),
172
+ id: drawerId,
173
+ }
174
+ : null, [hasSidebar, drawerOpen, drawerId]);
175
+ /* A window widened past the phone while the drawer was open (a tablet turned): the
176
+ sidebar is back beside the view, and a modal drawer left open would keep the page inert
177
+ behind a panel CSS has already hidden. */
178
+ useEffect(() => {
179
+ if (!drawerOpen)
180
+ return;
181
+ const wide = window.matchMedia(`(min-width: ${HANDHELD_WIDTH}px)`);
182
+ const close = () => {
183
+ if (wide.matches)
184
+ setDrawerOpen(false);
185
+ };
186
+ close();
187
+ wide.addEventListener("change", close);
188
+ return () => wide.removeEventListener("change", close);
189
+ }, [drawerOpen]);
190
+ /* With no `menu` the sidebar is the chrome: on a wide screen nothing is on top of it, and
191
+ on a phone a bar appears to open it. */
192
+ const sidebarIsChrome = hasSidebar && menu === undefined;
193
+ const top = sidebarIsChrome ? (narrowMenu ?? _jsx(TopBar, {})) : menu;
194
+ /* With `scroll="view"` the regions down to `main` take the height they are given instead of
195
+ growing with their content (`min-h-0`), and `main` is where the view scrolls: the stack
196
+ of sticky things starts again at its top. */
197
+ const fills = scroll === "view";
198
+ const region = fills ? "min-h-0" : "";
199
+ const mainScroll = fills ? "min-h-0 overflow-y-auto print:overflow-visible" : "";
200
+ /* The sidebar sits on the ground tone, the content on the paper (surface): the same white
201
+ for both made the navigation read as part of the list bar. On the chrome it wears the
202
+ brand's colour. On a phone it is hidden: the drawer shows it. */
203
+ const aside = sidebar === undefined ? null : (_jsx("aside", { className: `sticky w-(--container-sidebar) shrink-0 self-start overflow-y-auto overscroll-contain border-r max-sm:hidden print:hidden ${bySurface(sidebarSurface, "border-ui-sidebar-border bg-ui-sidebar", "border-chrome-edge bg-chrome")}`, style: { ...stickyTop, height: "calc(100dvh - var(--sticky-top, 0px))" }, "data-ui": "frame.sidebar", children: _jsx(SurfaceProvider, { value: sidebarSurface, children: sidebar }) }));
204
+ return (_jsx(SidebarDrawerContext, { value: drawer, children: _jsxs("div", { className: `relative flex min-w-0 flex-col bg-ground ${fills ? "h-dvh overflow-hidden print:h-auto print:overflow-visible" : "min-h-dvh"}`, "data-ui": "frame", "data-scroll": scroll, children: [top === undefined ? null : (
205
+ /* Hidden on a wide screen when it is only the phone's bar: it measures 0 there, so
206
+ nothing below is pushed down by it. */
207
+ _jsx("div", { ref: bar.ref, className: `sticky top-0 z-40 print:hidden ${sidebarIsChrome ? "sm:hidden" : ""}`, "data-ui": "frame.bar", children: top })), sidebar === undefined ? (_jsx("main", { className: `flex min-w-0 flex-1 flex-col ${mainScroll}`, style: fills ? stickyReset() : bar.below, "data-ui": "frame.main", children: children })) : sidebarIsChrome ? (_jsxs("div", { className: `flex min-w-0 flex-1 items-start ${region}`, style: bar.below, children: [aside, _jsx("main", { className: `flex min-w-0 flex-1 flex-col self-stretch ${mainScroll}`, ...(fills ? { style: stickyReset() } : {}), "data-ui": "frame.main", children: children })] })) : (_jsx(HeaderSlotContext, { value: slot, children: _jsxs("div", { className: `flex min-w-0 flex-1 flex-col ${region}`, style: bar.below, children: [_jsx("div", { ref: (node) => {
208
+ head.ref.current = node;
209
+ setSlot(node);
210
+ }, className: "sticky z-30 min-w-0", style: head.self }), _jsxs("div", { className: `flex min-w-0 flex-1 items-start ${region}`, style: head.below, children: [aside, _jsx("main", { className: `flex min-w-0 flex-1 flex-col self-stretch ${mainScroll}`, ...(fills ? { style: stickyReset() } : {}), "data-ui": "frame.main", children: children })] })] }) })), status, sidebar === undefined ? null : (_jsx(SidebarDrawerPanel, { id: drawerId, open: drawerOpen, onClose: () => setDrawerOpen(false), surface: sidebarSurface, children: sidebar }))] }) }));
80
211
  }
@@ -0,0 +1,39 @@
1
+ import { type BrandLogo } from "./brandMark.js";
2
+ import type { Surface } from "../../foundations/types.js";
3
+ import type { LucideIcon } from "lucide-react";
4
+ import type { ReactNode } from "react";
5
+ export type SidebarAction = {
6
+ id: string;
7
+ label: string;
8
+ icon?: LucideIcon;
9
+ /** A link instead of an action — «Ver el sitio». It is followed, not reported. */
10
+ href?: string;
11
+ /** The link opens in another tab; a screen reader is told so. */
12
+ external?: boolean;
13
+ };
14
+ export type SidebarProps = {
15
+ /** The product, at the top: its name and its mark — an icon, or its logo: the URL of an
16
+ * image, or an inline `<svg>` that paints with the tokens and so follows theme and surface. */
17
+ brand?: {
18
+ label: string;
19
+ icon?: LucideIcon;
20
+ logo?: BrandLogo;
21
+ };
22
+ /** Who is signed in. */
23
+ user?: {
24
+ name: string;
25
+ detail?: string;
26
+ avatar?: string;
27
+ };
28
+ /** The navigation: a `NavigationTree`. It scrolls; the top and the bottom stay. */
29
+ children: ReactNode;
30
+ /** The account, pinned to the bottom: change the password, view the site, sign out. */
31
+ actions?: readonly SidebarAction[];
32
+ /** An action without `href` was chosen. */
33
+ onAction?: (id: string) => void;
34
+ /** Anything else at the very bottom: a `ThemeSwitcher`, the version. */
35
+ footer?: ReactNode;
36
+ /** `chrome` wears the brand's colour. By default the frame's `sidebarSurface`. */
37
+ surface?: Surface;
38
+ };
39
+ export declare function Sidebar({ brand, user, children, actions, onAction, footer, surface, }: SidebarProps): import("react").JSX.Element;
@@ -0,0 +1,57 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { BrandMark } from "./brandMark.js";
4
+ import { useSidebarDrawer } from "./sidebarDrawer.js";
5
+ import { useUiCopy } from "../../foundations/copy.js";
6
+ import { SurfaceProvider, useSurface } from "../../foundations/surface.js";
7
+ import { Avatar } from "../../primitives/value/Person.js";
8
+ /* Each surface's colours in one place: the column is ONE surface, and a row drawn with the
9
+ other palette is the bug the surface context exists to prevent. The hairlines are ink at a
10
+ low alpha on the chrome: `chrome-edge` is the chrome itself on light, an invisible line. */
11
+ const SKIN = {
12
+ canvas: {
13
+ root: "",
14
+ ink: "text-ink",
15
+ muted: "text-muted",
16
+ mark: "text-primary",
17
+ line: "border-line",
18
+ row: "text-ink hover:bg-ink/6 focus-visible:outline-primary",
19
+ },
20
+ chrome: {
21
+ root: "bg-chrome",
22
+ ink: "text-chrome-ink",
23
+ muted: "text-chrome-muted",
24
+ mark: "text-chrome-link",
25
+ line: "border-chrome-ink/12",
26
+ row: "text-chrome-ink hover:bg-chrome-ink/10 focus-visible:outline-chrome-link",
27
+ },
28
+ };
29
+ const ROW = "flex h-(--size-control-sm) w-full min-w-0 cursor-pointer items-center gap-2 rounded-control px-2 text-meta no-underline transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2";
30
+ function Brand({ brand, skin }) {
31
+ const Icon = brand.icon;
32
+ return (_jsxs("div", { "data-ui": "sidebar.brand", className: "flex min-w-0 items-center gap-2 px-4 pt-4 pb-2", children: [brand.logo === undefined ? (Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-lg) shrink-0 ${skin.mark}`, strokeWidth: 1.75, "aria-hidden": true }))) : (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-md) shrink-0" })), _jsx("span", { className: `min-w-0 truncate text-lead font-semibold ${skin.ink}`, children: brand.label })] }));
33
+ }
34
+ function User({ user, skin }) {
35
+ return (_jsxs("div", { "data-ui": "sidebar.user", className: "flex min-w-0 items-center gap-2 px-4 py-2", children: [_jsx(Avatar, { name: user.name, size: "md", ...(user.avatar === undefined ? {} : { src: user.avatar }) }), _jsxs("span", { className: "flex min-w-0 flex-col leading-tight", children: [_jsx("span", { className: `truncate text-meta ${skin.ink}`, children: user.name }), user.detail === undefined ? null : (_jsx("span", { className: `truncate text-micro ${skin.muted}`, children: user.detail }))] })] }));
36
+ }
37
+ function Action({ action, skin, onAction, }) {
38
+ const copy = useUiCopy();
39
+ const drawer = useSidebarDrawer();
40
+ const Icon = action.icon;
41
+ const content = (_jsxs(_Fragment, { children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-md) shrink-0 ${skin.muted}`, strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "min-w-0 truncate", children: action.label })] }));
42
+ if (action.href !== undefined) {
43
+ return (_jsxs("a", { href: action.href, className: `${ROW} ${skin.row}`, ...(action.external === true ? { target: "_blank", rel: "noreferrer" } : {}), children: [content, action.external === true ? (_jsx("span", { className: "sr-only", children: ` (${copy.field.newTab})` })) : null] }));
44
+ }
45
+ return (_jsx("button", { type: "button", className: `${ROW} ${skin.row}`, onClick: () => {
46
+ onAction?.(action.id);
47
+ drawer?.close();
48
+ }, children: content }));
49
+ }
50
+ export function Sidebar({ brand, user, children, actions, onAction, footer, surface, }) {
51
+ const copy = useUiCopy();
52
+ const sup = useSurface(surface);
53
+ const skin = SKIN[sup];
54
+ const head = brand !== undefined || user !== undefined;
55
+ const foot = (actions !== undefined && actions.length > 0) || footer !== undefined;
56
+ return (_jsx(SurfaceProvider, { value: sup, children: _jsxs("div", { "data-ui": "sidebar", "data-surface": sup, className: `flex h-full min-h-0 min-w-0 flex-col ${skin.root}`, children: [head ? (_jsxs("div", { className: `shrink-0 border-b pb-2 ${skin.line}`, children: [brand === undefined ? null : _jsx(Brand, { brand: brand, skin: skin }), user === undefined ? null : _jsx(User, { user: user, skin: skin })] })) : null, _jsx("div", { "data-ui": "sidebar.nav", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { "data-ui": "sidebar.account", className: `flex shrink-0 flex-col gap-2 border-t p-2 ${skin.line}`, children: [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, skin: skin, ...(onAction === undefined ? {} : { onAction }) }) }, action.id))) })), footer] })) : null] }) }));
57
+ }
@@ -1,3 +1,4 @@
1
+ import { type BrandLogo } from "./brandMark.js";
1
2
  import { type MenuGroup } from "../../primitives/menu/Menu.js";
2
3
  import { type LucideIcon } from "lucide-react";
3
4
  import { type ReactNode } from "react";
@@ -12,14 +13,19 @@ export interface TopMenu {
12
13
  id: string;
13
14
  label: string;
14
15
  groups: readonly MenuGroup[];
16
+ /** What is waiting inside — «Pagos 5» — seen without opening the menu. Zero is not drawn. */
17
+ count?: number;
18
+ /** `columns` lays its sections side by side: a big module menu, seen whole. */
19
+ layout?: "list" | "columns";
15
20
  }
16
- export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
21
+ export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
17
22
  /** The product's name, when there is ONE product. It is drawn like the
18
23
  * current app of the switcher —same icon, same weight— but without the
19
24
  * switcher: nothing to switch to. */
20
25
  app?: {
21
26
  label: string;
22
27
  icon?: LucideIcon;
28
+ logo?: BrandLogo;
23
29
  };
24
30
  /** Everything that exists. Without this there is no switcher — a product with
25
31
  * a single app does not need one, and drawing it empty promises something
@@ -29,6 +35,9 @@ export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMe
29
35
  onAppSelect?: (id: string) => void;
30
36
  /** The menus OF the current app. */
31
37
  menus?: readonly TopMenu[];
38
+ /** The menu that holds the screen on view: marked with a bar under its label, so «where am
39
+ * I» is answered without opening any of them. */
40
+ currentMenu?: string;
32
41
  onMenuSelect?: (menuId: string, optionId: string) => void;
33
42
  /** What happened while I was not looking: activity, alerts. Icons with a count. */
34
43
  systray?: ReactNode;