@sincpro/web-ui 2.2.0 → 2.4.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 (80) hide show
  1. package/README.md +113 -3
  2. package/dist/components/board/Board.js +1 -1
  3. package/dist/components/guide/Guide.d.ts +33 -0
  4. package/dist/components/guide/Guide.js +288 -0
  5. package/dist/components/guide/GuideSpot.d.ts +14 -0
  6. package/dist/components/guide/GuideSpot.js +13 -0
  7. package/dist/components/guide/index.d.ts +4 -0
  8. package/dist/components/guide/index.js +6 -0
  9. package/dist/components/guide/place.d.ts +44 -0
  10. package/dist/components/guide/place.js +69 -0
  11. package/dist/components/guide/target.d.ts +41 -0
  12. package/dist/components/guide/target.js +55 -0
  13. package/dist/components/index.d.ts +1 -0
  14. package/dist/components/index.js +1 -0
  15. package/dist/components/listing/GroupingLevels.js +11 -9
  16. package/dist/components/listing/Listing.js +7 -5
  17. package/dist/components/listing/RecordCard.js +1 -1
  18. package/dist/components/listing/Row.js +8 -7
  19. package/dist/components/navigation/NavigationTree.js +36 -9
  20. package/dist/components/record/DirtyActions.d.ts +9 -7
  21. package/dist/components/record/DirtyActions.js +14 -9
  22. package/dist/components/record/ThumbBar.js +2 -1
  23. package/dist/components/search/CriteriaBuilder.js +3 -2
  24. package/dist/components/search/CriteriaChips.js +6 -5
  25. package/dist/components/search/JoinWord.js +1 -1
  26. package/dist/components/search/SearchBar.js +41 -25
  27. package/dist/components/shell/AppFrame.d.ts +10 -1
  28. package/dist/components/shell/AppFrame.js +53 -10
  29. package/dist/components/shell/SearchEntry.d.ts +29 -0
  30. package/dist/components/shell/SearchEntry.js +34 -0
  31. package/dist/components/shell/Sidebar.d.ts +12 -3
  32. package/dist/components/shell/Sidebar.js +38 -12
  33. package/dist/components/shell/TopBar.d.ts +12 -1
  34. package/dist/components/shell/TopBar.js +7 -5
  35. package/dist/components/shell/brandMark.d.ts +17 -0
  36. package/dist/components/shell/brandMark.js +9 -0
  37. package/dist/components/shell/index.d.ts +2 -0
  38. package/dist/components/shell/index.js +5 -0
  39. package/dist/foundations/copy.d.ts +19 -2
  40. package/dist/foundations/copy.es.js +13 -3
  41. package/dist/foundations/copy.js +13 -3
  42. package/dist/foundations/index.d.ts +1 -0
  43. package/dist/foundations/index.js +2 -0
  44. package/dist/foundations/shortcut.d.ts +18 -0
  45. package/dist/foundations/shortcut.js +20 -0
  46. package/dist/foundations/variants.js +19 -2
  47. package/dist/primitives/block/Block.js +1 -1
  48. package/dist/primitives/button/Button.d.ts +3 -1
  49. package/dist/primitives/button/Button.js +6 -6
  50. package/dist/primitives/choice/SegmentedControl.d.ts +4 -1
  51. package/dist/primitives/choice/SegmentedControl.js +35 -7
  52. package/dist/primitives/dialog/Dialog.d.ts +1 -1
  53. package/dist/primitives/dialog/Dialog.js +2 -2
  54. package/dist/primitives/field/CardNumberInput.js +1 -1
  55. package/dist/primitives/field/Checks.d.ts +14 -0
  56. package/dist/primitives/field/Checks.js +12 -4
  57. package/dist/primitives/field/DurationInput.js +1 -1
  58. package/dist/primitives/field/Field.js +7 -7
  59. package/dist/primitives/field/PatternInput.js +1 -1
  60. package/dist/primitives/field/RichTextEditor.js +2 -2
  61. package/dist/primitives/field/SignatureInput.js +1 -1
  62. package/dist/primitives/field/aria.d.ts +2 -2
  63. package/dist/primitives/field/aria.js +5 -5
  64. package/dist/primitives/field/index.d.ts +1 -1
  65. package/dist/primitives/field/index.js +1 -1
  66. package/dist/primitives/menu/Menu.d.ts +23 -7
  67. package/dist/primitives/menu/Menu.js +76 -22
  68. package/dist/primitives/overlay/Popover.js +2 -2
  69. package/dist/primitives/picker/Picker.js +3 -3
  70. package/dist/primitives/picker/TagsField.js +1 -1
  71. package/dist/primitives/table/EditableTable.js +2 -2
  72. package/dist/primitives/table/ReportTable.js +1 -1
  73. package/dist/primitives/table/Table.js +2 -2
  74. package/dist/primitives/tag/Tag.d.ts +9 -0
  75. package/dist/primitives/tag/Tag.js +14 -1
  76. package/dist/primitives/tag/Tags.js +6 -7
  77. package/dist/primitives/value/Metric.d.ts +5 -1
  78. package/dist/primitives/value/Metric.js +8 -6
  79. package/dist/tokens.css +202 -56
  80. 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
14
  import { mergeProps, Overlay, useOverlay, useOverlayPosition } from "react-aria";
12
- function Option({ o, onSelect }) {
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
  }
@@ -135,11 +139,28 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
135
139
  const columns = [
136
140
  ...(filters === undefined || !withOptions(filters)
137
141
  ? []
138
- : [{ title: copy.search.filters, groups: filters, onSelect: onFilterSelect }]),
139
- ...(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 }]),
140
154
  ...(favorites === undefined || !withOptions(favorites)
141
155
  ? []
142
- : [{ 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
+ ]),
143
164
  ];
144
165
  /* THE PANEL IS A LAYER, and Escape closes the layer on top — only that one.
145
166
 
@@ -259,12 +280,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
259
280
  ? one
260
281
  : { ...node, of: [...node.of, one] };
261
282
  }
262
- return (_jsxs("div", { ref: box, onKeyDown: closePanelOnEscape,
263
- /* `min-w-48`: placed in a flex row without a width, the bar used to collapse to its
264
- narrowest and the input slid UNDER the filters button («bu⊞car»). 12rem is the
265
- magnifier, a word of input and the buttons; a narrower container scrolls, it does
266
- not stack controls on top of each other. */
267
- 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",
268
284
  /* On the chrome what defines the field is the BORDER, not the fill. The
269
285
  blue is already almost black, so sinking it gives no contrast (1.05:1) and
270
286
  raising it gives 1.21:1 — in both cases the field does not read as a
@@ -430,7 +446,7 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
430
446
  is not available, the input stretches as always. */
431
447
  style: step.field === undefined ? undefined : { fieldSizing: "content" }, className: step.field === undefined
432
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")}`
433
- : `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: () => {
434
450
  onCriteriaChange([]);
435
451
  setOpenGroup(null);
436
452
  input.current?.focus();
@@ -445,8 +461,8 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
445
461
  label: copy.search.tools,
446
462
  count: puestos.toLocaleString(copy.locale),
447
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
448
- ? bySurface(sup, "border-accent/40 bg-accent/18 text-ink", "border-chrome-link/35 bg-chrome-link/15 text-chrome-link")
449
- : 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 ? (
450
466
  /* A LIST, not a strip. You are CHOOSING: the eye goes down a
451
467
  column and so does the keyboard. Twelve attributes folded into three
452
468
  rows are twelve things to sweep in zigzag to find one. */
@@ -462,9 +478,9 @@ export function SearchBar({ facets, model, criteria, onCriteriaChange, placehold
462
478
  onSelect: () => pick(one),
463
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,
464
480
  /* The input keeps the focus: pressing an option must not take it. */
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: () => {
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: () => {
467
483
  onOpenBuilder();
468
484
  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] }));
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] }));
470
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. */
@@ -12,10 +13,18 @@ sidebar,
12
13
  /** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
13
14
  * drawer and something has to open it — a `TopBar` with the product's name, which draws
14
15
  * the button first. A bare `TopBar` by default. */
15
- narrowMenu, children, }: {
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, }: {
16
23
  menu?: ReactNode;
17
24
  status?: ReactNode;
18
25
  sidebar?: ReactNode;
19
26
  narrowMenu?: ReactNode;
27
+ sidebarSurface?: Surface;
28
+ scroll?: "page" | "view";
20
29
  children: ReactNode;
21
30
  }): import("react").JSX.Element;
@@ -5,7 +5,8 @@ import { SidebarDrawerContext } from "./sidebarDrawer.js";
5
5
  import { TopBar } from "./TopBar.js";
6
6
  import { useUiCopy } from "../../foundations/copy.js";
7
7
  import { HANDHELD_WIDTH } from "../../foundations/layout.js";
8
- import { stickyTop, useStickyLayer } from "../../foundations/sticky.js";
8
+ import { stickyReset, stickyTop, useStickyLayer } from "../../foundations/sticky.js";
9
+ import { bySurface, SurfaceProvider } from "../../foundations/surface.js";
9
10
  import { IconButton } from "../../primitives/button/Button.js";
10
11
  import { X } from "lucide-react";
11
12
  import { useEffect, useId, useMemo, useState } from "react";
@@ -83,6 +84,36 @@ import { Dialog as AriaDialog, Modal, ModalOverlay } from "react-aria-components
83
84
  * `TopBar` draws first, or — with no `menu` — from the bar the frame draws for
84
85
  * the phone alone (`narrowMenu`, a bare `TopBar` by default). Following a link
85
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.
86
117
  * ==================================================================== */
87
118
  /* Following a link closes the drawer. On the CAPTURE phase: React Aria's links stop the
88
119
  click from bubbling, and a keyboard Enter on one reaches here as the click it dispatches. */
@@ -95,12 +126,12 @@ function closeOnLink(close) {
95
126
  /** The sidebar as a drawer, for a phone: modal (the page behind is inert and dimmed, the
96
127
  * focus is kept inside and returns to the button), dismissed by the scrim, Escape, its ×
97
128
  * or a link followed. */
98
- function SidebarDrawerPanel({ id, open, onClose, children, }) {
129
+ function SidebarDrawerPanel({ id, open, onClose, surface, children, }) {
99
130
  const copy = useUiCopy();
100
131
  return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: (next) => {
101
132
  if (!next)
102
133
  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 })] }) }) }));
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 })] }) }) }) }));
104
135
  }
105
136
  export function AppFrame({
106
137
  /** The bar at the top. It stays in view while scrolling. */
@@ -115,7 +146,13 @@ sidebar,
115
146
  /** With a `sidebar` and no `menu`: the bar on top on a PHONE only, where the sidebar is a
116
147
  * drawer and something has to open it — a `TopBar` with the product's name, which draws
117
148
  * the button first. A bare `TopBar` by default. */
118
- narrowMenu, children, }) {
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, }) {
119
156
  /* The top bar MEASURES what it takes and passes it to what is below: a list's
120
157
  bar sticks beneath it, and a table's header beneath the other two. None of the
121
158
  three has a fixed height — see `system/sticky.tsx`. */
@@ -154,15 +191,21 @@ narrowMenu, children, }) {
154
191
  on a phone a bar appears to open it. */
155
192
  const sidebarIsChrome = hasSidebar && menu === undefined;
156
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" : "";
157
200
  /* 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 : (
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 : (
162
205
  /* Hidden on a wide screen when it is only the phone's bar: it measures 0 there, so
163
206
  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) => {
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) => {
165
208
  head.ref.current = node;
166
209
  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 }))] }) }));
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 }))] }) }));
168
211
  }
@@ -0,0 +1,29 @@
1
+ import type { Surface } from "../../foundations/types.js";
2
+ /**
3
+ * THE WAY INTO THE PALETTE, drawn — «Buscar… ⌘K».
4
+ *
5
+ * Context: a command palette that only opens with a key is a feature nobody finds. quipu's
6
+ * people asked for «a global search» while ⌘K already opened one. This is the visible door: it
7
+ * reads like a search field, it says the shortcut so the next time the hand goes to the
8
+ * keyboard, and pressing it calls `onSearch` — the application opens its palette there.
9
+ *
10
+ * It does NOT listen for the shortcut. The palette does (composer's ⌘K); a second listener here
11
+ * would open it twice, or open it in an application whose palette uses another key.
12
+ *
13
+ * Inside the phone drawer it closes the drawer first: the palette opens over the page, not
14
+ * over a drawer about to cover it.
15
+ */
16
+ export type SearchEntryProps = {
17
+ onSearch: () => void;
18
+ /** What it says. «Buscar…» by default; «Buscar socios…» when the palette searches one thing. */
19
+ label?: string;
20
+ /** The key the palette listens for together with ⌘ / Ctrl: `K` by default. `false` draws no
21
+ * shortcut — the palette has none, or it is not a ⌘ one. */
22
+ shortcut?: string | false;
23
+ /** `row` fills its column (the sidebar). `bar` sizes to its words, and on a phone folds to
24
+ * the magnifier alone (a bar on top). */
25
+ layout?: "row" | "bar";
26
+ /** By default the surface it sits on. */
27
+ surface?: Surface;
28
+ };
29
+ export declare function SearchEntry({ onSearch, label, shortcut, layout, surface, }: SearchEntryProps): import("react").JSX.Element;
@@ -0,0 +1,34 @@
1
+ "use client";
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useSidebarDrawer } from "./sidebarDrawer.js";
4
+ import { useUiCopy } from "../../foundations/copy.js";
5
+ import { modShortcut, useKeyboardPlatform } from "../../foundations/shortcut.js";
6
+ import { useSurface } from "../../foundations/surface.js";
7
+ import { Search } from "lucide-react";
8
+ const SKIN = {
9
+ canvas: {
10
+ box: "border-ui-control-border bg-ui-control text-muted hover:border-line-strong hover:text-ink focus-visible:outline-primary",
11
+ keys: "border-line text-muted",
12
+ },
13
+ chrome: {
14
+ box: "border-chrome-ink/15 bg-chrome-ink/6 text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink focus-visible:outline-chrome-link",
15
+ keys: "border-chrome-ink/20 text-chrome-muted",
16
+ },
17
+ };
18
+ export function SearchEntry({ onSearch, label, shortcut = "K", layout = "row", surface, }) {
19
+ const copy = useUiCopy();
20
+ const sup = useSurface(surface);
21
+ const drawer = useSidebarDrawer();
22
+ const platform = useKeyboardPlatform();
23
+ const skin = SKIN[sup];
24
+ const keys = shortcut === false || platform === null ? null : modShortcut(shortcut, platform);
25
+ const bar = layout === "bar";
26
+ return (_jsxs("button", { type: "button", onClick: () => {
27
+ if (drawer?.isOpen === true)
28
+ drawer.close();
29
+ onSearch();
30
+ }, ...(keys === null ? {} : { "aria-keyshortcuts": keys.aria }), className: `flex h-(--size-control-sm) min-w-0 cursor-pointer items-center gap-2 rounded-ui-control border px-2 text-meta transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 ${bar ? "shrink-0 max-sm:w-(--size-control-sm) max-sm:justify-center" : "w-full"} ${skin.box}`, "data-ui": "search-entry", "data-surface": sup, children: [_jsx(Search, { className: "size-(--size-icon-md) shrink-0", strokeWidth: 2, "aria-hidden": true }), _jsx("span", { className: `min-w-0 flex-1 truncate text-left ${bar ? "max-sm:sr-only" : ""}`, children: label ?? copy.shell.search }), keys === null ? null : (
31
+ /* Seen, not heard: `aria-keyshortcuts` already tells a screen reader, and «⌘K» read
32
+ aloud is noise after the name. Not drawn for a finger: a phone has no ⌘. */
33
+ _jsx("kbd", { "aria-hidden": true, className: `shrink-0 rounded-control border px-1.5 font-mono text-micro pointer-coarse:hidden ${bar ? "max-sm:hidden" : ""} ${skin.keys}`, "data-ui": "search-entry.keys", children: keys.label }))] }));
34
+ }
@@ -1,3 +1,6 @@
1
+ import { type BrandLogo } from "./brandMark.js";
2
+ import { type SearchEntryProps } from "./SearchEntry.js";
3
+ import type { Surface } from "../../foundations/types.js";
1
4
  import type { LucideIcon } from "lucide-react";
2
5
  import type { ReactNode } from "react";
3
6
  export type SidebarAction = {
@@ -10,11 +13,12 @@ export type SidebarAction = {
10
13
  external?: boolean;
11
14
  };
12
15
  export type SidebarProps = {
13
- /** The product, at the top: its name and its mark — an icon, or the logo's image. */
16
+ /** The product, at the top: its name and its mark — an icon, or its logo: the URL of an
17
+ * image, or an inline `<svg>` that paints with the tokens and so follows theme and surface. */
14
18
  brand?: {
15
19
  label: string;
16
20
  icon?: LucideIcon;
17
- logo?: string;
21
+ logo?: BrandLogo;
18
22
  };
19
23
  /** Who is signed in. */
20
24
  user?: {
@@ -22,6 +26,9 @@ export type SidebarProps = {
22
26
  detail?: string;
23
27
  avatar?: string;
24
28
  };
29
+ /** «Buscar… ⌘K» under the product and the user: the application's palette, made visible.
30
+ * `onSearch` opens it; the palette keeps listening for its own key. */
31
+ search?: Omit<SearchEntryProps, "layout" | "surface">;
25
32
  /** The navigation: a `NavigationTree`. It scrolls; the top and the bottom stay. */
26
33
  children: ReactNode;
27
34
  /** The account, pinned to the bottom: change the password, view the site, sign out. */
@@ -30,5 +37,7 @@ export type SidebarProps = {
30
37
  onAction?: (id: string) => void;
31
38
  /** Anything else at the very bottom: a `ThemeSwitcher`, the version. */
32
39
  footer?: ReactNode;
40
+ /** `chrome` wears the brand's colour. By default the frame's `sidebarSurface`. */
41
+ surface?: Surface;
33
42
  };
34
- export declare function Sidebar({ brand, user, children, actions, onAction, footer }: SidebarProps): import("react").JSX.Element;
43
+ export declare function Sidebar({ brand, user, search, children, actions, onAction, footer, surface, }: SidebarProps): import("react").JSX.Element;
@@ -1,32 +1,58 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { BrandMark } from "./brandMark.js";
4
+ import { SearchEntry, } from "./SearchEntry.js";
3
5
  import { useSidebarDrawer } from "./sidebarDrawer.js";
4
6
  import { useUiCopy } from "../../foundations/copy.js";
7
+ import { SurfaceProvider, useSurface } from "../../foundations/surface.js";
5
8
  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 }) {
9
+ /* Each surface's colours in one place: the column is ONE surface, and a row drawn with the
10
+ other palette is the bug the surface context exists to prevent. The hairlines are ink at a
11
+ low alpha on the chrome: `chrome-edge` is the chrome itself on light, an invisible line. */
12
+ const SKIN = {
13
+ canvas: {
14
+ root: "",
15
+ ink: "text-ink",
16
+ muted: "text-muted",
17
+ mark: "text-primary",
18
+ line: "border-line",
19
+ row: "text-ink hover:bg-ink/6 focus-visible:outline-primary",
20
+ },
21
+ chrome: {
22
+ root: "bg-chrome",
23
+ ink: "text-chrome-ink",
24
+ muted: "text-chrome-muted",
25
+ mark: "text-chrome-link",
26
+ line: "border-chrome-ink/12",
27
+ row: "text-chrome-ink hover:bg-chrome-ink/10 focus-visible:outline-chrome-link",
28
+ },
29
+ };
30
+ const ROW = "flex h-(--size-control-sm) w-full min-w-0 cursor-pointer items-center gap-2 rounded-control px-2 text-meta no-underline transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2";
31
+ function Brand({ brand, skin }) {
8
32
  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 })] }));
33
+ return (_jsxs("div", { "data-ui": "sidebar.brand", className: "flex min-w-0 items-center gap-2 px-4 pt-4 pb-2", children: [brand.logo === undefined ? (Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-lg) shrink-0 ${skin.mark}`, strokeWidth: 1.75, "aria-hidden": true }))) : (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-md) shrink-0" })), _jsx("span", { className: `min-w-0 truncate text-lead font-semibold ${skin.ink}`, children: brand.label })] }));
10
34
  }
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 }))] })] }));
35
+ function User({ user, skin }) {
36
+ 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 }))] })] }));
13
37
  }
14
- function Action({ action, onAction, }) {
38
+ function Action({ action, skin, onAction, }) {
15
39
  const copy = useUiCopy();
16
40
  const drawer = useSidebarDrawer();
17
41
  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 })] }));
42
+ 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 })] }));
19
43
  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] }));
44
+ 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] }));
21
45
  }
22
- return (_jsx("button", { type: "button", className: ROW, onClick: () => {
46
+ return (_jsx("button", { type: "button", className: `${ROW} ${skin.row}`, onClick: () => {
23
47
  onAction?.(action.id);
24
48
  drawer?.close();
25
49
  }, children: content }));
26
50
  }
27
- export function Sidebar({ brand, user, children, actions, onAction, footer }) {
51
+ export function Sidebar({ brand, user, search, children, actions, onAction, footer, surface, }) {
28
52
  const copy = useUiCopy();
29
- const head = brand !== undefined || user !== undefined;
53
+ const sup = useSurface(surface);
54
+ const skin = SKIN[sup];
55
+ const head = brand !== undefined || user !== undefined || search !== undefined;
30
56
  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] }));
57
+ 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 }), search === undefined ? null : (_jsx("div", { "data-ui": "sidebar.search", className: "px-2 pt-2", children: _jsx(SearchEntry, { ...search }) }))] })) : null, _jsx("div", { "data-ui": "sidebar.nav", className: "min-h-0 flex-1 overflow-y-auto overscroll-contain", children: children }), foot ? (_jsxs("div", { "data-ui": "sidebar.account", className: `flex shrink-0 flex-col gap-2 border-t p-2 ${skin.line}`, children: [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] }) }));
32
58
  }
@@ -1,3 +1,5 @@
1
+ import { type BrandLogo } from "./brandMark.js";
2
+ import { type SearchEntryProps } from "./SearchEntry.js";
1
3
  import { type MenuGroup } from "../../primitives/menu/Menu.js";
2
4
  import { type LucideIcon } from "lucide-react";
3
5
  import { type ReactNode } from "react";
@@ -14,14 +16,17 @@ export interface TopMenu {
14
16
  groups: readonly MenuGroup[];
15
17
  /** What is waiting inside — «Pagos 5» — seen without opening the menu. Zero is not drawn. */
16
18
  count?: number;
19
+ /** `columns` lays its sections side by side: a big module menu, seen whole. */
20
+ layout?: "list" | "columns";
17
21
  }
18
- export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }: {
22
+ export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, search, systray, user, onUserSelect, userGroups, }: {
19
23
  /** The product's name, when there is ONE product. It is drawn like the
20
24
  * current app of the switcher —same icon, same weight— but without the
21
25
  * switcher: nothing to switch to. */
22
26
  app?: {
23
27
  label: string;
24
28
  icon?: LucideIcon;
29
+ logo?: BrandLogo;
25
30
  };
26
31
  /** Everything that exists. Without this there is no switcher — a product with
27
32
  * a single app does not need one, and drawing it empty promises something
@@ -31,7 +36,13 @@ export declare function TopBar({ app, apps, currentApp, onAppSelect, menus, onMe
31
36
  onAppSelect?: (id: string) => void;
32
37
  /** The menus OF the current app. */
33
38
  menus?: readonly TopMenu[];
39
+ /** The menu that holds the screen on view: marked with a bar under its label, so «where am
40
+ * I» is answered without opening any of them. */
41
+ currentMenu?: string;
34
42
  onMenuSelect?: (menuId: string, optionId: string) => void;
43
+ /** «Buscar… ⌘K» before the tray: the application's palette, made visible. On a phone it
44
+ * folds to the magnifier. `onSearch` opens the palette; the palette keeps its own key. */
45
+ search?: Omit<SearchEntryProps, "layout" | "surface">;
35
46
  /** What happened while I was not looking: activity, alerts. Icons with a count. */
36
47
  systray?: ReactNode;
37
48
  user?: {
@@ -1,5 +1,7 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ import { BrandMark } from "./brandMark.js";
4
+ import { SearchEntry, } from "./SearchEntry.js";
3
5
  import { SidebarToggle } from "./sidebarDrawer.js";
4
6
  import { useUiCopy } from "../../foundations/copy.js";
5
7
  import { SurfaceProvider } from "../../foundations/surface.js";
@@ -8,11 +10,11 @@ import { Count, countText } from "../../primitives/tag/Count.js";
8
10
  import { Avatar } from "../../primitives/value/Person.js";
9
11
  import { Grid3x3 } from "lucide-react";
10
12
  import { useMemo, useState } from "react";
11
- export function TopBar({ app, apps, currentApp, onAppSelect, menus, onMenuSelect, systray, user, onUserSelect, userGroups, }) {
13
+ export function TopBar({ app, apps, currentApp, onAppSelect, menus, currentMenu, onMenuSelect, search, systray, user, onUserSelect, userGroups, }) {
12
14
  const copy = useUiCopy();
13
15
  const actual = apps?.find((a) => a.id === currentApp);
14
16
  const brand = app ?? actual;
15
- return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { className: "flex h-(--size-appbar) min-w-0 items-center gap-1 border-b border-chrome-edge bg-chrome px-2", children: [_jsx(SidebarToggle, {}), apps === undefined || apps.length === 0 ? null : (_jsx(AppSwitcher, { apps: apps, current: currentApp, ...(onAppSelect === undefined ? {} : { onSelect: onAppSelect }) })), brand === undefined ? null : (_jsxs("span", { className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: [brand.icon === undefined ? null : (_jsx(brand.icon, { className: "size-(--size-icon-md) text-chrome-link", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "text-lead font-medium text-chrome-ink", children: brand.label })] })), menus === undefined ? null : (_jsx("nav", { className: "scroll-quiet flex min-w-0 items-center gap-0.5", "aria-label": copy.shell.menus, children: menus.map((m) => (_jsx(Menu, { label: m.label, groups: m.groups, surface: "chrome", variant: "text", chevron: false, ...(m.count === undefined ? {} : { count: m.count }), onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { className: "ml-auto flex shrink-0 items-center gap-1 pl-2", children: [systray, user === undefined ? null : (_jsx(UserMenu, { name: user.name, ...(user.detail === undefined ? {} : { detail: user.detail }), groups: userGroups ?? [], ...(onUserSelect === undefined ? {} : { onSelect: onUserSelect }) }))] })] }) }));
17
+ return (_jsx(SurfaceProvider, { value: "chrome", children: _jsxs("header", { "data-ui": "topbar", className: "flex h-(--size-appbar) min-w-0 items-center gap-1 border-b border-chrome-edge bg-chrome px-2", children: [_jsx(SidebarToggle, {}), apps === undefined || apps.length === 0 ? null : (_jsx(AppSwitcher, { apps: apps, current: currentApp, ...(onAppSelect === undefined ? {} : { onSelect: onAppSelect }) })), brand === undefined ? null : (_jsxs("span", { "data-ui": "topbar.brand", className: "flex shrink-0 items-center gap-2 pr-2 pl-1", children: ["logo" in brand && brand.logo !== undefined ? (_jsx(BrandMark, { logo: brand.logo, className: "size-(--size-control-sm) shrink-0" })) : brand.icon === undefined ? null : (_jsx(brand.icon, { className: "size-(--size-icon-md) text-chrome-link", strokeWidth: 2, "aria-hidden": true })), _jsx("span", { className: "text-lead font-medium text-chrome-ink", children: brand.label })] })), menus === undefined ? null : (_jsx("nav", { "data-ui": "topbar.menus", className: "scroll-quiet flex min-w-0 items-center gap-0.5", "aria-label": copy.shell.menus, children: menus.map((m) => (_jsx(Menu, { label: m.label, groups: m.groups, surface: "chrome", variant: "text", chevron: false, current: m.id === currentMenu, ...(m.layout === undefined ? {} : { layout: m.layout }), ...(m.count === undefined ? {} : { count: m.count }), onSelect: (id) => onMenuSelect?.(m.id, id) }, m.id))) })), _jsxs("div", { "data-ui": "topbar.actions", className: "ml-auto flex shrink-0 items-center gap-1 pl-2", children: [search === undefined ? null : _jsx(SearchEntry, { ...search, layout: "bar" }), systray, user === undefined ? null : (_jsx(UserMenu, { name: user.name, ...(user.detail === undefined ? {} : { detail: user.detail }), groups: userGroups ?? [], ...(onUserSelect === undefined ? {} : { onSelect: onUserSelect }) }))] })] }) }));
16
18
  }
17
19
  /** The app switcher: a grid, not a list.
18
20
  *
@@ -25,12 +27,12 @@ export function AppSwitcher({ apps, current, onSelect, }) {
25
27
  const copy = useUiCopy();
26
28
  return (_jsxs("div", { className: "relative shrink-0", children: [_jsx("button", { type: "button", onClick: () => setOpen((v) => !v), "aria-expanded": open, "aria-haspopup": "menu", "aria-label": copy.shell.modules, title: copy.shell.modules, className: `inline-flex size-(--size-control-md) items-center justify-center rounded-pill transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-chrome-link ${open
27
29
  ? "bg-chrome-ink/12 text-chrome-ink"
28
- : "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: _jsx(Grid3x3, { className: "size-(--size-icon-md)", strokeWidth: 2 }) }), !open ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40", onClick: () => setOpen(false), role: "presentation" }), _jsx("div", { role: "menu", className: "absolute top-full left-0 z-50 mt-1 grid w-(--container-apps) grid-cols-3 gap-1 rounded-panel border border-line bg-surface p-2 shadow-float", children: apps.map((a) => {
30
+ : "text-chrome-muted hover:bg-chrome-ink/10 hover:text-chrome-ink"}`, children: _jsx(Grid3x3, { className: "size-(--size-icon-md)", strokeWidth: 2 }) }), !open ? null : (_jsxs(_Fragment, { children: [_jsx("div", { className: "fixed inset-0 z-40", onClick: () => setOpen(false), role: "presentation" }), _jsx("div", { role: "menu", className: "absolute top-full left-0 z-50 mt-1 grid w-(--container-apps) grid-cols-3 gap-1 rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", children: apps.map((a) => {
29
31
  const here = a.id === current;
30
32
  return (_jsxs("button", { type: "button", role: "menuitem", title: a.hint, onClick: () => {
31
33
  onSelect?.(a.id);
32
34
  setOpen(false);
33
- }, className: `flex flex-col items-center gap-1.5 rounded-box px-2 py-3 text-center transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${here ? "bg-primary/8 text-primary" : "text-ink hover:bg-ink/5"}`, children: [_jsx(a.icon, { className: "size-(--size-icon-lg)", strokeWidth: 1.75, "aria-hidden": true }), _jsx("span", { className: "text-micro leading-tight", children: a.label })] }, a.id));
35
+ }, className: `flex flex-col items-center gap-1.5 rounded-control px-2 py-3 text-center transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:outline-offset-1 focus-visible:outline-primary ${here ? "bg-primary/8 text-primary" : "text-ink hover:bg-ink/5"}`, children: [_jsx(a.icon, { className: "size-(--size-icon-lg)", strokeWidth: 1.75, "aria-hidden": true }), _jsx("span", { className: "text-micro leading-tight", children: a.label })] }, a.id));
34
36
  }) })] }))] }));
35
37
  }
36
38
  /** A badge over an icon is read in a glance: past two digits it says «a lot». */
@@ -54,5 +56,5 @@ export function SystrayButton({ icon: Icon, label, count = 0, tone = "info", onC
54
56
  * only the avatar stays, which is what gets recognised without reading. */
55
57
  export function UserMenu({ name, detail, groups, onSelect, }) {
56
58
  const copy = useUiCopy();
57
- return (_jsxs("span", { className: "flex shrink-0 items-center gap-2 pl-1", children: [_jsx(Avatar, { name: name, size: "md" }), _jsxs("span", { className: "hidden min-w-0 flex-col leading-tight sm:flex", children: [_jsx("span", { className: "truncate text-meta text-chrome-ink", children: name }), detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-chrome-muted", children: detail }))] }), _jsx(Menu, { label: copy.shell.account, groups: groups, surface: "chrome", variant: "text", align: "end", iconOnly: true, ...(onSelect === undefined ? {} : { onSelect }) })] }));
59
+ return (_jsxs("span", { "data-ui": "topbar.user", className: "flex shrink-0 items-center gap-2 pl-1", children: [_jsx(Avatar, { name: name, size: "md" }), _jsxs("span", { className: "hidden min-w-0 flex-col leading-tight sm:flex", children: [_jsx("span", { className: "truncate text-meta text-chrome-ink", children: name }), detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-chrome-muted", children: detail }))] }), _jsx(Menu, { label: copy.shell.account, groups: groups, surface: "chrome", variant: "text", align: "end", iconOnly: true, ...(onSelect === undefined ? {} : { onSelect }) })] }));
58
60
  }
@@ -0,0 +1,17 @@
1
+ import type { ReactElement } from "react";
2
+ /**
3
+ * A product's mark: the URL of an image, or an element drawn inline.
4
+ *
5
+ * Context: an image paints with the colours baked into its file, so it cannot follow the
6
+ * theme nor the surface it sits on — a navy crest disappears on a navy sidebar and glares in
7
+ * the dark theme. An inline `<svg>` that paints with `currentColor` or the tokens
8
+ * (`var(--color-chrome-accent)`) follows both. A string stays a URL, so `logo: "/logo.svg"`
9
+ * keeps working.
10
+ */
11
+ export type BrandLogo = string | ReactElement;
12
+ /** Draws a `BrandLogo` in a box the host sizes. Decorative: the product's name is written
13
+ * beside it, and saying it twice is noise for a screen reader. */
14
+ export declare function BrandMark({ logo, className }: {
15
+ logo: BrandLogo;
16
+ className: string;
17
+ }): import("react").JSX.Element;
@@ -0,0 +1,9 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ /** Draws a `BrandLogo` in a box the host sizes. Decorative: the product's name is written
3
+ * beside it, and saying it twice is noise for a screen reader. */
4
+ export function BrandMark({ logo, className }) {
5
+ if (typeof logo === "string") {
6
+ return _jsx("img", { src: logo, alt: "", className: `${className} object-contain` });
7
+ }
8
+ return (_jsx("span", { "aria-hidden": true, className: `${className} flex items-center justify-center *:size-full`, children: logo }));
9
+ }