@sincpro/web-ui 2.2.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 (55) hide show
  1. package/README.md +69 -3
  2. package/dist/components/board/Board.js +1 -1
  3. package/dist/components/listing/GroupingLevels.js +11 -9
  4. package/dist/components/listing/RecordCard.js +1 -1
  5. package/dist/components/navigation/NavigationTree.js +36 -9
  6. package/dist/components/search/CriteriaBuilder.js +3 -2
  7. package/dist/components/search/CriteriaChips.js +6 -5
  8. package/dist/components/search/JoinWord.js +1 -1
  9. package/dist/components/search/SearchBar.js +41 -25
  10. package/dist/components/shell/AppFrame.d.ts +10 -1
  11. package/dist/components/shell/AppFrame.js +53 -10
  12. package/dist/components/shell/Sidebar.d.ts +8 -3
  13. package/dist/components/shell/Sidebar.js +36 -11
  14. package/dist/components/shell/TopBar.d.ts +8 -1
  15. package/dist/components/shell/TopBar.js +6 -5
  16. package/dist/components/shell/brandMark.d.ts +17 -0
  17. package/dist/components/shell/brandMark.js +9 -0
  18. package/dist/components/shell/index.d.ts +1 -0
  19. package/dist/components/shell/index.js +2 -0
  20. package/dist/foundations/copy.es.js +3 -3
  21. package/dist/foundations/copy.js +3 -3
  22. package/dist/foundations/variants.js +19 -2
  23. package/dist/primitives/block/Block.js +1 -1
  24. package/dist/primitives/button/Button.d.ts +3 -1
  25. package/dist/primitives/button/Button.js +6 -6
  26. package/dist/primitives/choice/SegmentedControl.d.ts +4 -1
  27. package/dist/primitives/choice/SegmentedControl.js +35 -7
  28. package/dist/primitives/dialog/Dialog.d.ts +1 -1
  29. package/dist/primitives/dialog/Dialog.js +2 -2
  30. package/dist/primitives/field/CardNumberInput.js +1 -1
  31. package/dist/primitives/field/Checks.d.ts +14 -0
  32. package/dist/primitives/field/Checks.js +12 -4
  33. package/dist/primitives/field/DurationInput.js +1 -1
  34. package/dist/primitives/field/Field.js +7 -7
  35. package/dist/primitives/field/PatternInput.js +1 -1
  36. package/dist/primitives/field/RichTextEditor.js +2 -2
  37. package/dist/primitives/field/SignatureInput.js +1 -1
  38. package/dist/primitives/field/aria.d.ts +2 -2
  39. package/dist/primitives/field/aria.js +5 -5
  40. package/dist/primitives/field/index.d.ts +1 -1
  41. package/dist/primitives/field/index.js +1 -1
  42. package/dist/primitives/menu/Menu.d.ts +23 -7
  43. package/dist/primitives/menu/Menu.js +76 -22
  44. package/dist/primitives/overlay/Popover.js +2 -2
  45. package/dist/primitives/picker/Picker.js +3 -3
  46. package/dist/primitives/picker/TagsField.js +1 -1
  47. package/dist/primitives/table/EditableTable.js +2 -2
  48. package/dist/primitives/table/ReportTable.js +1 -1
  49. package/dist/primitives/table/Table.js +2 -2
  50. package/dist/primitives/tag/Tag.d.ts +9 -0
  51. package/dist/primitives/tag/Tag.js +14 -1
  52. package/dist/primitives/tag/Tags.js +6 -7
  53. package/dist/primitives/value/Metric.js +4 -4
  54. package/dist/tokens.css +163 -36
  55. package/package.json +1 -1
@@ -23,7 +23,7 @@ const overlay = tv({
23
23
  * are rounded (the bottom ones sit on the screen's edge), it stops at `--size-sheet`,
24
24
  * and it enters from below — the motion says where it lives. */
25
25
  const modal = tv({
26
- base: "flex max-h-full w-full flex-col overflow-hidden rounded-panel border border-line-strong bg-surface text-ink shadow-window outline-0 transition-[opacity,translate] duration-(--duration-panel) ease-(--ease-out) forced-colors:bg-[Canvas] max-sm:max-h-(--size-sheet) max-sm:max-w-none max-sm:rounded-b-none max-sm:border-x-0 max-sm:border-b-0",
26
+ base: "flex max-h-full w-full flex-col overflow-hidden rounded-ui-dialog border border-line-strong bg-ui-dialog text-ink shadow-window outline-0 transition-[opacity,translate] duration-(--duration-panel) ease-(--ease-out) forced-colors:bg-[Canvas] max-sm:max-h-(--size-sheet) max-sm:max-w-none max-sm:rounded-b-none max-sm:border-x-0 max-sm:border-b-0",
27
27
  variants: {
28
28
  width: { sm: "max-w-md", md: "max-w-2xl", lg: "max-w-4xl" },
29
29
  isEntering: { true: "translate-y-2 opacity-0 max-sm:translate-y-full" },
@@ -97,7 +97,7 @@ export function Dialog({ open, width = "md", onClose, movable = false, ...surfac
97
97
  return (_jsx(ModalOverlay, { isOpen: open, onOpenChange: (next) => {
98
98
  if (!next)
99
99
  onClose();
100
- }, isDismissable: true, className: overlay, children: _jsx(Modal, { className: (state) => modal({ ...state, width }), ...(movable
100
+ }, isDismissable: true, className: overlay, children: _jsx(Modal, { "data-ui": "dialog", "data-width": width, className: (state) => modal({ ...state, width }), ...(movable
101
101
  ? { style: { transform: `translate(${offset.x}px, ${offset.y}px)` } }
102
102
  : {}), children: _jsx(DialogSurface, { onClose: onClose, ...surface, ...(movable ? { onDragStart: drag } : {}) }) }) }));
103
103
  }
@@ -64,7 +64,7 @@ function CardDatumBox({ id: ownId, value, onChange, placeholder, describedBy: ow
64
64
  describedBy: ownDescribedBy,
65
65
  invalid: ownInvalid,
66
66
  });
67
- return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: onChange, inputMode: "numeric", autoComplete: autoComplete, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ...(inputRef === undefined ? {} : { ref: inputRef }), "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
67
+ return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: onChange, inputMode: "numeric", autoComplete: autoComplete, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ...(inputRef === undefined ? {} : { ref: inputRef }), "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, "data-ui": "control", className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
68
68
  }
69
69
  /**
70
70
  * The expiry of a card, «MM/AA». The value is the four digits («1228»); the slash is drawn.
@@ -6,6 +6,20 @@ export interface CheckItem {
6
6
  detail?: string;
7
7
  disabled?: boolean;
8
8
  }
9
+ /**
10
+ * The drawn box of a check, with no behaviour of its own.
11
+ *
12
+ * Context: exported for the rows that ARE a multiple choice without being a form input —
13
+ * the filters of the search panel, a grouping level — so they mark «on» with the same box
14
+ * as `Checkbox`. The host carries the semantics (`aria-pressed`, a listbox option); this
15
+ * is `aria-hidden`.
16
+ */
17
+ export declare function CheckMark({ on, mixed, focus, invalid, }: {
18
+ on: boolean;
19
+ mixed?: boolean;
20
+ focus?: boolean;
21
+ invalid?: boolean;
22
+ }): import("react").JSX.Element;
9
23
  /**
10
24
  * One yes/no answer of a form: «Exento de IVA», «Enviar la factura por correo al
11
25
  * publicar».
@@ -6,7 +6,15 @@ import { useFormMode } from "../../foundations/form.js";
6
6
  import { Check, Minus } from "lucide-react";
7
7
  import { useId } from "react";
8
8
  import { Checkbox as AriaCheckbox, ListBox, ListBoxItem, } from "react-aria-components";
9
- function Mark({ on, mixed, focus = false, invalid = false, }) {
9
+ /**
10
+ * The drawn box of a check, with no behaviour of its own.
11
+ *
12
+ * Context: exported for the rows that ARE a multiple choice without being a form input —
13
+ * the filters of the search panel, a grouping level — so they mark «on» with the same box
14
+ * as `Checkbox`. The host carries the semantics (`aria-pressed`, a listbox option); this
15
+ * is `aria-hidden`.
16
+ */
17
+ export function CheckMark({ on, mixed = false, focus = false, invalid = false, }) {
10
18
  return (_jsx("span", { "aria-hidden": true, className: `inline-flex size-4 shrink-0 items-center justify-center rounded-mark border transition-colors duration-(--duration-instant) forced-color-adjust-none ${on
11
19
  ? "border-primary bg-primary text-surface forced-colors:border-[Highlight] forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]"
12
20
  : `bg-surface text-transparent ${invalid ? "border-danger" : "border-line-strong"} forced-colors:border-[ButtonBorder]`} ${focus ? "outline-2 outline-offset-2 outline-primary forced-colors:outline-[Highlight]" : ""}`, children: mixed ? (_jsx(Minus, { className: "size-3", strokeWidth: 2.5 })) : (_jsx(Check, { className: "size-3", strokeWidth: 2.5 })) }));
@@ -33,9 +41,9 @@ export function Checkbox({ checked, mixed = false, onChange, label, disabled = f
33
41
  const textId = useId();
34
42
  const on = checked || mixed;
35
43
  if (useFormMode(mode) === "read") {
36
- return (_jsxs("span", { className: "flex min-h-(--size-control-md) items-center gap-2 text-meta text-ink", children: [_jsx(Mark, { on: on, mixed: mixed && !checked }), label] }));
44
+ return (_jsxs("span", { className: "flex min-h-(--size-control-md) items-center gap-2 text-meta text-ink", children: [_jsx(CheckMark, { on: on, mixed: mixed && !checked }), label] }));
37
45
  }
38
- return (_jsx(AriaCheckbox, { id: id, "aria-labelledby": labelledBy === undefined ? undefined : `${labelledBy} ${textId}`, "aria-describedby": describedBy, isSelected: checked, isIndeterminate: mixed, onChange: (next) => onChange?.(mixed ? true : next), isDisabled: disabled, isInvalid: invalid, className: "group inline-flex min-w-0 cursor-pointer items-center gap-2.5 text-meta text-ink disabled:cursor-not-allowed disabled:opacity-45", children: ({ isSelected, isIndeterminate, isFocusVisible, isInvalid }) => (_jsxs(_Fragment, { children: [_jsx(Mark, { on: isSelected || isIndeterminate, mixed: isIndeterminate, focus: isFocusVisible, invalid: isInvalid }), _jsx("span", { id: textId, className: "min-w-0", children: label })] })) }));
46
+ return (_jsx(AriaCheckbox, { id: id, "aria-labelledby": labelledBy === undefined ? undefined : `${labelledBy} ${textId}`, "aria-describedby": describedBy, isSelected: checked, isIndeterminate: mixed, onChange: (next) => onChange?.(mixed ? true : next), isDisabled: disabled, isInvalid: invalid, className: "group inline-flex min-w-0 cursor-pointer items-center gap-2.5 text-meta text-ink disabled:cursor-not-allowed disabled:opacity-45", children: ({ isSelected, isIndeterminate, isFocusVisible, isInvalid }) => (_jsxs(_Fragment, { children: [_jsx(CheckMark, { on: isSelected || isIndeterminate, mixed: isIndeterminate, focus: isFocusVisible, invalid: isInvalid }), _jsx("span", { id: textId, className: "min-w-0", children: label })] })) }));
39
47
  }
40
48
  /** The chosen values, in the order the person picked them — what `onChange` hands back. */
41
49
  function valuesOf(keys, items) {
@@ -68,5 +76,5 @@ export function CheckList({ label, items, value, onChange, mono = false, emptyLa
68
76
  }
69
77
  return (_jsxs("div", { className: "flex min-w-0 flex-col gap-1.5", children: [_jsx("p", { id: labelId, className: "text-micro text-muted", children: label }), _jsx(ListBox, { "aria-labelledby": labelId, "aria-describedby": describedBy, items: items, selectionMode: "multiple", selectedKeys: value, onSelectionChange: (keys) => onChange?.(valuesOf(keys, items)), disabledKeys: items.filter((item) => item.disabled).map((item) => item.value), shouldFocusWrap: true, className: "flex flex-col overflow-hidden rounded-box border border-line bg-surface outline-0 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary", children: (item) => (_jsx(ListBoxItem, { id: item.value, textValue: item.label, className: ({ isSelected, isFocusVisible, isDisabled }) => `flex min-w-0 cursor-pointer items-center gap-2.5 border-b border-line px-3 py-2 text-left outline-0 last:border-b-0 ${isFocusVisible
70
78
  ? "outline-2 -outline-offset-2 outline-primary forced-colors:outline-[Highlight]"
71
- : ""} ${isDisabled ? "cursor-not-allowed opacity-45" : ""} ${isSelected ? "bg-primary/8" : "hover:bg-ink/4"}`, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx(Mark, { on: isSelected, mixed: false }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: `truncate text-meta text-ink ${mono ? "font-mono" : ""}`, children: item.label }), item.detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-muted", children: item.detail }))] })] })) })) })] }));
79
+ : ""} ${isDisabled ? "cursor-not-allowed opacity-45" : ""} ${isSelected ? "bg-primary/8" : "hover:bg-ink/4"}`, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx(CheckMark, { on: isSelected }), _jsxs("span", { className: "flex min-w-0 flex-col", children: [_jsx("span", { className: `truncate text-meta text-ink ${mono ? "font-mono" : ""}`, children: item.label }), item.detail === undefined ? null : (_jsx("span", { className: "truncate text-micro text-muted", children: item.detail }))] })] })) })) })] }));
72
80
  }
@@ -50,5 +50,5 @@ export function DurationInput({ id: ownId, value, onChange, placeholder = "0:00"
50
50
  setDraft(null);
51
51
  onChange?.(minutes / 60);
52
52
  };
53
- return (_jsxs(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: draft ?? shown, onChange: setDraft, inputMode: "decimal", isInvalid: invalid, isDisabled: disabled, className: "flex w-full min-w-0 items-center gap-2", children: [_jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, onBlur: commit, onKeyDown: arrows, className: `${controlClasses(invalid)} tabular-nums` }), _jsx("span", { className: "shrink-0 text-meta text-muted", children: copy.field.hours })] }));
53
+ return (_jsxs(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: draft ?? shown, onChange: setDraft, inputMode: "decimal", isInvalid: invalid, isDisabled: disabled, className: "flex w-full min-w-0 items-center gap-2", children: [_jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: false, onBlur: commit, onKeyDown: arrows, "data-ui": "control", className: `${controlClasses(invalid)} tabular-nums` }), _jsx("span", { className: "shrink-0 text-meta text-muted", children: copy.field.hours })] }));
54
54
  }
@@ -128,9 +128,9 @@ export function ReadValue({ value, mono = false }) {
128
128
  * be born with another height, another radius or another focus. That was the
129
129
  * original defect: every file wrote its own `<input className="…">`. */
130
130
  export function controlClasses(invalid = false) {
131
- return `h-(--size-control-md) w-full min-w-0 rounded-control border bg-surface px-2.5 text-meta text-ink transition-colors duration-(--duration-instant) placeholder:text-muted focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:bg-ground disabled:text-muted ${invalid
131
+ return `h-(--size-control-md) w-full min-w-0 rounded-ui-control border bg-ui-control px-2.5 text-meta text-ink transition-colors duration-(--duration-instant) placeholder:text-muted focus-visible:outline-2 focus-visible:outline-offset-2 disabled:cursor-not-allowed disabled:bg-ground disabled:text-muted ${invalid
132
132
  ? "border-danger focus-visible:border-danger focus-visible:outline-danger"
133
- : "border-line-strong focus-visible:border-primary focus-visible:outline-primary"}`;
133
+ : "border-ui-control-border focus-visible:border-primary focus-visible:outline-primary"}`;
134
134
  }
135
135
  /* `aria-describedby` goes on the INPUT and not on React Aria's field: the field adds the ids
136
136
  of its own description and error slots, which this system never renders (`Field` draws
@@ -157,7 +157,7 @@ export function TextInput({ id: ownId, value, onChange, placeholder, describedBy
157
157
  });
158
158
  if (useFormMode(mode) === "read")
159
159
  return _jsx(ReadValue, { value: value, mono: mono });
160
- return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: spellCheck, className: `${controlClasses(invalid)} ${mono ? "font-mono tabular-nums" : ""}` }) }));
160
+ return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { "aria-describedby": describedBy, placeholder: placeholder, spellCheck: spellCheck, "data-ui": "control", className: `${controlClasses(invalid)} ${mono ? "font-mono tabular-nums" : ""}` }) }));
161
161
  }
162
162
  /** The amount, the quantity, the percentage — read in the copy's locale, every time. */
163
163
  function useReadNumber(format) {
@@ -224,17 +224,17 @@ export function TextArea({ id: ownId, value, onChange, placeholder, rows = 3, de
224
224
  if (useFormMode(mode) === "read") {
225
225
  return value === "" ? (_jsx(ReadValue, { value: null })) : (_jsx("span", { className: "text-meta whitespace-pre-line text-ink", children: value }));
226
226
  }
227
- return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(AriaTextArea, { "aria-describedby": describedBy, rows: rows, placeholder: placeholder, className: `${controlClasses(invalid)} h-auto resize-y py-1.5 leading-relaxed` }) }));
227
+ return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), value: value, onChange: (next) => onChange?.(next), isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(AriaTextArea, { "aria-describedby": describedBy, rows: rows, placeholder: placeholder, "data-ui": "control", className: `${controlClasses(invalid)} h-auto resize-y py-1.5 leading-relaxed` }) }));
228
228
  }
229
229
  const selectTrigger = tv({
230
230
  extend: focusRing,
231
- base: "flex h-(--size-control-md) w-full min-w-0 cursor-default items-center gap-2 rounded-control border bg-surface pr-2 pl-2.5 text-start text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
231
+ base: "flex h-(--size-control-md) w-full min-w-0 cursor-default items-center gap-2 rounded-ui-control border bg-ui-control pr-2 pl-2.5 text-start text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
232
232
  variants: {
233
233
  isFocusVisible: {
234
234
  true: "border-primary",
235
235
  },
236
236
  isInvalid: {
237
- false: "border-line-strong forced-colors:border-[ButtonBorder]",
237
+ false: "border-ui-control-border forced-colors:border-[ButtonBorder]",
238
238
  true: "border-danger outline-danger forced-colors:border-[Mark]",
239
239
  },
240
240
  isDisabled: {
@@ -265,5 +265,5 @@ export function Select({ id: ownId, value, options, onChange, describedBy: ownDe
265
265
  if (useFormMode(mode) === "read") {
266
266
  return _jsx(ReadValue, { value: options.find((o) => o.value === value)?.label ?? null });
267
267
  }
268
- return (_jsx(AriaLocale, { children: _jsxs(AriaSelect, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), "aria-describedby": describedBy, value: value === "" ? null : value, onChange: (next) => onChange?.(next === null ? "" : String(next)), placeholder: placeholder, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: [_jsxs(AriaButton, { className: (state) => selectTrigger({ ...state, isInvalid: invalid }), children: [_jsx(SelectValue, { className: "min-w-0 flex-1 truncate data-placeholder:text-muted", children: ({ isPlaceholder, selectedText, defaultChildren }) => isPlaceholder ? defaultChildren : selectedText }), _jsx(ChevronDown, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2 })] }), _jsx(Popover, { placement: "bottom start", className: "min-w-(--trigger-width)", children: _jsx(ListBox, { items: options, className: "max-h-[inherit] overflow-auto p-1 outline-0", children: (option) => (_jsx(ListBoxItem, { id: option.value, textValue: option.label, isDisabled: option.disabled, className: listOptionStyles, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: `min-w-0 flex-1 truncate ${isSelected ? "font-medium" : ""}`, children: option.label }), _jsx("span", { className: "flex size-(--size-icon-md) shrink-0 items-center justify-center", children: isSelected ? (_jsx(Check, { "aria-hidden": true, className: "size-(--size-icon-md) text-primary forced-colors:text-[HighlightText]", strokeWidth: 2 })) : null })] })) })) }) })] }) }));
268
+ return (_jsx(AriaLocale, { children: _jsxs(AriaSelect, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, placeholder), "aria-describedby": describedBy, value: value === "" ? null : value, onChange: (next) => onChange?.(next === null ? "" : String(next)), placeholder: placeholder, isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: [_jsxs(AriaButton, { "data-ui": "control", className: (state) => selectTrigger({ ...state, isInvalid: invalid }), children: [_jsx(SelectValue, { className: "min-w-0 flex-1 truncate data-placeholder:text-muted", children: ({ isPlaceholder, selectedText, defaultChildren }) => isPlaceholder ? defaultChildren : selectedText }), _jsx(ChevronDown, { "aria-hidden": true, className: "size-(--size-icon-md) shrink-0 text-muted", strokeWidth: 2 })] }), _jsx(Popover, { placement: "bottom start", className: "min-w-(--trigger-width)", children: _jsx(ListBox, { items: options, className: "max-h-[inherit] overflow-auto p-1 outline-0", children: (option) => (_jsx(ListBoxItem, { id: option.value, textValue: option.label, isDisabled: option.disabled, className: listOptionStyles, children: ({ isSelected }) => (_jsxs(_Fragment, { children: [_jsx("span", { className: `min-w-0 flex-1 truncate ${isSelected ? "font-medium" : ""}`, children: option.label }), _jsx("span", { className: "flex size-(--size-icon-md) shrink-0 items-center justify-center", children: isSelected ? (_jsx(Check, { "aria-hidden": true, className: "size-(--size-icon-md) text-primary forced-colors:text-[HighlightText]", strokeWidth: 2 })) : null })] })) })) }) })] }) }));
269
269
  }
@@ -44,5 +44,5 @@ export function PatternInput({ id: ownId, value, onChange, pattern, placeholder,
44
44
  onChange?.(next);
45
45
  };
46
46
  const shown = placeholder ?? pattern.replace(/#/g, "0").replace(/\*/g, "X");
47
- return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, shown), value: drawn, onChange: change, inputMode: /[A*]/.test(pattern) ? "text" : "numeric", isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ref: input, "aria-describedby": describedBy, placeholder: shown, spellCheck: false, autoCapitalize: "characters", className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
47
+ return (_jsx(AriaTextField, { id: id, "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel, shown), value: drawn, onChange: change, inputMode: /[A*]/.test(pattern) ? "text" : "numeric", isInvalid: invalid, isDisabled: disabled, className: "w-full min-w-0", children: _jsx(Input, { ref: input, "aria-describedby": describedBy, placeholder: shown, spellCheck: false, autoCapitalize: "characters", "data-ui": "control", className: `${controlClasses(invalid)} font-mono tabular-nums` }) }));
48
48
  }
@@ -86,10 +86,10 @@ function MentionList({ asking, active, listId, }) {
86
86
  const rect = asking.rect;
87
87
  if (rect === null)
88
88
  return null;
89
- return (_jsx("ul", { id: listId, role: "listbox", "aria-label": copy.mentions, className: "fixed z-50 flex w-64 flex-col rounded-panel border border-line-strong bg-surface p-1 shadow-float", style: { left: rect.left, top: rect.bottom + 4 }, children: asking.items.length === 0 ? (_jsx("li", { role: "option", "aria-selected": false, "aria-disabled": true, className: "px-2 py-1 text-meta text-muted", children: copy.noMatches })) : (asking.items.map((item, index) => (_jsx("li", { id: `${listId}-${index}`, role: "option", "aria-selected": index === active, onMouseDown: (event) => {
89
+ return (_jsx("ul", { id: listId, role: "listbox", "aria-label": copy.mentions, "data-ui": "popover", className: "fixed z-50 flex w-64 flex-col rounded-ui-popover border border-ui-popover-border bg-ui-popover p-1 shadow-ui-popover", style: { left: rect.left, top: rect.bottom + 4 }, children: asking.items.length === 0 ? (_jsx("li", { role: "option", "aria-selected": false, "aria-disabled": true, className: "px-2 py-1 text-meta text-muted", children: copy.noMatches })) : (asking.items.map((item, index) => (_jsx("li", { id: `${listId}-${index}`, role: "option", "aria-selected": index === active, onMouseDown: (event) => {
90
90
  event.preventDefault();
91
91
  asking.pick(item);
92
- }, className: `cursor-default rounded-control px-2 py-1 text-meta text-ink ${index === active ? "bg-primary/8" : ""}`, children: item.label }, item.id)))) }));
92
+ }, className: `cursor-default rounded-control px-2 py-1 text-meta text-ink ${index === active ? "bg-ui-option-active" : ""}`, children: item.label }, item.id)))) }));
93
93
  }
94
94
  export function RichTextEditor({ id, labelledBy, describedBy, invalid, ariaLabel, value, onChange, placeholder, disabled, toolbar, mentions, }) {
95
95
  const changed = useRef(onChange);
@@ -211,5 +211,5 @@ export function SignatureInput({ id: ownId, value, onChange, name = "", alt, des
211
211
  const paper = cn("relative h-32 w-full overflow-clip rounded-control border bg-surface font-sans text-ink", invalid ? "border-danger" : "border-line-strong", disabled ? "bg-ground" : "");
212
212
  return (_jsxs("div", { id: id, role: "group", "aria-labelledby": labelledBy, "aria-label": nameOf(labelledBy, ariaLabel), "aria-describedby": describedBy, className: "flex w-full min-w-0 flex-col gap-2", children: [_jsxs("div", { ref: pad, "data-theme": "light", className: paper, children: [stored || (typing && has) ? (_jsx("img", { src: value ?? "", alt: label, className: "size-full object-contain object-left" })) : typing ? null : (_jsx("canvas", { ref: canvas, role: "img", "aria-label": copy.media.signaturePad, "aria-describedby": helpId, onPointerDown: onPointerDown, onPointerMove: onPointerMove, onPointerUp: onPointerUp, onPointerCancel: onPointerUp, className: cn("absolute inset-0 size-full touch-none", disabled ? "cursor-not-allowed" : "cursor-crosshair") })), _jsx("span", { "aria-hidden": true, className: "pointer-events-none absolute inset-x-4 bottom-1/4 border-t border-line-strong" })] }), typing ? (_jsxs("label", { className: "flex flex-col gap-1 text-micro font-medium text-muted", children: [copy.media.typedName, _jsx("input", {
213
213
  /* The person asked for this box by pressing the button: the focus goes there. */
214
- autoFocus: true, value: typed, disabled: disabled, autoComplete: "name", onChange: (event) => writeTyped(event.target.value), className: `${controlClasses(invalid)} font-normal` })] })) : (_jsx("p", { id: helpId, className: "text-micro text-muted", children: copy.media.signatureHelp })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { size: "sm", icon: typing ? PenLine : Type, disabled: disabled, onClick: switchMode, children: typing ? copy.media.drawInstead : copy.media.typeName }), _jsx(Button, { role: "ghost", size: "sm", icon: Eraser, disabled: disabled, onClick: clear, children: copy.media.clear })] })] }));
214
+ autoFocus: true, value: typed, disabled: disabled, autoComplete: "name", onChange: (event) => writeTyped(event.target.value), "data-ui": "control", className: `${controlClasses(invalid)} font-normal` })] })) : (_jsx("p", { id: helpId, className: "text-micro text-muted", children: copy.media.signatureHelp })), _jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [_jsx(Button, { size: "sm", icon: typing ? PenLine : Type, disabled: disabled, onClick: switchMode, children: typing ? copy.media.drawInstead : copy.media.typeName }), _jsx(Button, { role: "ghost", size: "sm", icon: Eraser, disabled: disabled, onClick: clear, children: copy.media.clear })] })] }));
215
215
  }
@@ -20,7 +20,7 @@ export declare const fieldGroupStyles: import("tailwind-variants/config").TVRetu
20
20
  isDisabled: {
21
21
  true: string;
22
22
  };
23
- }, undefined, "group flex h-(--size-control-md) w-full min-w-0 items-center overflow-hidden rounded-control border bg-surface text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]", {
23
+ }, undefined, "group flex h-(--size-control-md) w-full min-w-0 items-center overflow-hidden rounded-ui-control border bg-ui-control text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]", {
24
24
  isFocusVisible: {
25
25
  false: string;
26
26
  true: string;
@@ -56,6 +56,6 @@ export declare const listOptionStyles: import("tailwind-variants/config").TVRetu
56
56
  isDisabled: {
57
57
  true: string;
58
58
  };
59
- }, undefined, "group flex min-h-(--size-control-md) cursor-default items-center gap-2 rounded-control px-2 py-1 text-meta text-ink outline-0 select-none forced-color-adjust-none", undefined, undefined, undefined>;
59
+ }, undefined, "group flex min-h-(--size-control-md) cursor-default items-center gap-2 rounded-ui-option px-2 py-1 text-meta text-ink outline-0 select-none forced-color-adjust-none", undefined, undefined, undefined>;
60
60
  /** For a control that only adds to the system's classes. */
61
61
  export { composeClasses };
@@ -12,10 +12,10 @@ import { Button as AriaButton, composeRenderProps, Group, } from "react-aria-com
12
12
  */
13
13
  export const fieldGroupStyles = tv({
14
14
  extend: focusRing,
15
- base: "group flex h-(--size-control-md) w-full min-w-0 items-center overflow-hidden rounded-control border bg-surface text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
15
+ base: "group flex h-(--size-control-md) w-full min-w-0 items-center overflow-hidden rounded-ui-control border bg-ui-control text-meta text-ink transition-colors duration-(--duration-instant) forced-colors:bg-[Field]",
16
16
  variants: {
17
17
  isFocusWithin: {
18
- false: "border-line-strong forced-colors:border-[ButtonBorder]",
18
+ false: "border-ui-control-border forced-colors:border-[ButtonBorder]",
19
19
  true: "border-primary forced-colors:border-[Highlight]",
20
20
  },
21
21
  isInvalid: {
@@ -30,7 +30,7 @@ export const fieldGroupStyles = tv({
30
30
  * reaches the box (React 19: a plain prop) — a control that floats a list as wide as the
31
31
  * box, like `TagsField`, measures it. */
32
32
  export function FieldGroup({ ref, ...props }) {
33
- return (_jsx(Group, { ref: ref, ...props, className: composeRenderProps(props.className, (className, state) => fieldGroupStyles({ ...state, className })) }));
33
+ return (_jsx(Group, { ref: ref, "data-ui": "control", ...props, className: composeRenderProps(props.className, (className, state) => fieldGroupStyles({ ...state, className })) }));
34
34
  }
35
35
  const fieldButton = tv({
36
36
  extend: focusRing,
@@ -53,10 +53,10 @@ export function FieldButton(props) {
53
53
  * control opened it.
54
54
  */
55
55
  export const listOptionStyles = tv({
56
- base: "group flex min-h-(--size-control-md) cursor-default items-center gap-2 rounded-control px-2 py-1 text-meta text-ink outline-0 select-none forced-color-adjust-none",
56
+ base: "group flex min-h-(--size-control-md) cursor-default items-center gap-2 rounded-ui-option px-2 py-1 text-meta text-ink outline-0 select-none forced-color-adjust-none",
57
57
  variants: {
58
58
  isFocused: {
59
- true: "bg-primary/8 forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
59
+ true: "bg-ui-option-active forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
60
60
  },
61
61
  isPressed: {
62
62
  true: "bg-primary/12",
@@ -1,6 +1,6 @@
1
1
  export { CARD_MAX_DIGITS, type CardBrand, cardBrand, cardBrandName, cardCodeLength, cardDigits, expiryDigits, expiryParts, formatCardNumber, formatExpiry, isExpiryValid, isValidCardNumber, luhnValid, maskCardNumber, } from "./card.js";
2
2
  export { CardCodeInput, CardExpiryInput, CardNumberInput, } from "./CardNumberInput.js";
3
- export { Checkbox, type CheckItem, CheckList } from "./Checks.js";
3
+ export { Checkbox, type CheckItem, CheckList, CheckMark, } from "./Checks.js";
4
4
  export { CodeInput } from "./CodeInput.js";
5
5
  export { ColorInput } from "./ColorInput.js";
6
6
  export { emailHref, isEmail, isUrl, telHref, urlHref, urlLabel, whatsappHref, } from "./contact.js";
@@ -8,7 +8,7 @@
8
8
  export { CARD_MAX_DIGITS, cardBrand, cardBrandName, cardCodeLength, cardDigits, expiryDigits, expiryParts, formatCardNumber, formatExpiry, isExpiryValid, isValidCardNumber, luhnValid, maskCardNumber, } from "./card.js";
9
9
  export { CardCodeInput, CardExpiryInput, CardNumberInput, } from "./CardNumberInput.js";
10
10
  /* An address to reach someone: typed with its keyboard, read as a link. */
11
- export { Checkbox, CheckList } from "./Checks.js";
11
+ export { Checkbox, CheckList, CheckMark, } from "./Checks.js";
12
12
  export { CodeInput } from "./CodeInput.js";
13
13
  export { ColorInput } from "./ColorInput.js";
14
14
  export { emailHref, isEmail, isUrl, telHref, urlHref, urlLabel, whatsappHref, } from "./contact.js";
@@ -1,6 +1,6 @@
1
1
  import { type ButtonRole, type ButtonSize } from "../button/Button.js";
2
2
  import type { LucideIcon } from "lucide-react";
3
- import type { ReactNode } from "react";
3
+ import { type ReactNode } from "react";
4
4
  import { type Key } from "react-aria-components";
5
5
  export interface MenuOption {
6
6
  id: string;
@@ -43,15 +43,21 @@ export interface MenuGroup {
43
43
  /** The group's label, in the brand voice. Without a label, the group is just
44
44
  * a separator — which also serves a purpose. */
45
45
  label?: string;
46
+ /** Drawn beside the label: the sections of a big menu are told apart before they are
47
+ * read. Only with a `label`. */
48
+ icon?: LucideIcon;
46
49
  /**
47
50
  * The group folds under its label, and starts folded unless something in it
48
51
  * is ticked.
49
52
  *
50
53
  * It exists for the DATE narrowings. «Fecha de pedido» is not one option, it
51
54
  * is eleven —three months, four quarters, three years— and eleven options
52
- * always open push the rest of the panel off the screen. A date is the only
53
- * field that brings its own little calendar, so it is the only one that
54
- * folds; the others are a list and a list does not need a door.
55
+ * always open push the rest of the panel off the screen.
56
+ *
57
+ * In a `Menu` it is the section that is there without taking the room: «Reportes
58
+ * financieros ▾» is one row, and pressing it unfolds its nine reports in place —
59
+ * the menu stays open. A menu with a search box shows every section open: a fold
60
+ * would hide what the search finds.
55
61
  */
56
62
  collapsible?: boolean;
57
63
  options: MenuOption[];
@@ -73,10 +79,12 @@ export declare function indexOptions(options: readonly MenuOption[], into?: Map<
73
79
  * criteria) still has to look like its neighbours; copying these classes is how the third
74
80
  * trigger ends up one pixel off. Same reason `buttonClasses` exists.
75
81
  */
76
- export declare function menuTriggerClasses({ variant, surface, active, open, focusVisible, iconOnly, }: {
82
+ export declare function menuTriggerClasses({ variant, surface, active, current, open, focusVisible, iconOnly, }: {
77
83
  variant?: "button" | "text";
78
84
  surface?: "canvas" | "chrome";
79
85
  active?: boolean;
86
+ /** The screen on view is inside this menu: a bar under the label. */
87
+ current?: boolean;
80
88
  open?: boolean;
81
89
  focusVisible?: boolean;
82
90
  iconOnly?: boolean;
@@ -84,7 +92,7 @@ export declare function menuTriggerClasses({ variant, surface, active, open, foc
84
92
  export declare function Menu({ label, groups, onSelect, surface, align, icon: Trigger,
85
93
  /** The menu as a control of a list ("filters ▾") carries the chevron; the
86
94
  * actions `⋯` does not, because the icon already says there is more. */
87
- chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, size, title, closeOnSelect, count, }: {
95
+ chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, size, title, closeOnSelect, count, current, layout, }: {
88
96
  label: string;
89
97
  groups: readonly MenuGroup[];
90
98
  onSelect?: (id: string) => void;
@@ -130,6 +138,11 @@ chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, s
130
138
  * without opening the menu. Zero is not drawn. Not with `iconOnly`, where there is no
131
139
  * label for it to belong to. */
132
140
  count?: number;
141
+ /** The screen on view is inside this menu — an application bar's «here». */
142
+ current?: boolean;
143
+ /** `columns` lays the sections side by side: a big menu of an application bar, seen
144
+ * whole. Stacked on a phone. */
145
+ layout?: "list" | "columns";
133
146
  }): import("react").JSX.Element;
134
147
  /**
135
148
  * The panel of a `Menu`: its groups and rows, and the submenus hanging from them. Internal —
@@ -137,12 +150,15 @@ chevron, active, iconOnly, variant, searchPlaceholder, emptyText, width, role, s
137
150
  * submenu is this same panel one level down, and a panel can be rendered on the server
138
151
  * without the trigger's popover, which is how the tests see the rows.
139
152
  */
140
- export declare function MenuList({ label, groups, onAction, closeOnSelect, emptyText, width, }: {
153
+ export declare function MenuList({ label, groups, onAction, closeOnSelect, emptyText, width, layout, foldable, }: {
141
154
  label: string;
142
155
  groups: readonly MenuGroup[];
143
156
  onAction: (key: Key) => void;
144
157
  closeOnSelect: boolean;
145
158
  emptyText: string;
146
159
  width?: keyof typeof WIDTH;
160
+ layout?: "list" | "columns";
161
+ /** `false` shows every `collapsible` section open — under a search box. */
162
+ foldable?: boolean;
147
163
  }): import("react").JSX.Element;
148
164
  export {};
@@ -5,6 +5,7 @@ import { buttonClasses, } from "../button/Button.js";
5
5
  import { Popover } from "../overlay/Popover.js";
6
6
  import { Count } from "../tag/Count.js";
7
7
  import { Check, ChevronDown, ChevronRight } from "lucide-react";
8
+ import { useState } from "react";
8
9
  import { Autocomplete, Button as AriaButton, Header, Input, Keyboard, Menu as AriaMenu, MenuItem, MenuSection, MenuTrigger, SearchField, Separator, SubmenuTrigger, useFilter, } from "react-aria-components";
9
10
  const WIDTH = {
10
11
  /** A menu of short verbs hanging off an icon: "duplicate", "delete". */
@@ -12,6 +13,17 @@ const WIDTH = {
12
13
  md: "min-w-56 max-w-80",
13
14
  lg: "min-w-80 max-w-(--container-short)",
14
15
  };
16
+ /** Sections side by side take the width they need, up to the cuts panel's. */
17
+ const COLUMNS_WIDTH = "w-max max-w-(--container-cuts)";
18
+ /* A section after the first: a hairline above it in a list; in columns, a hairline on its
19
+ start edge from `sm` up (stacked again on a phone). */
20
+ const SECTION = {
21
+ list: "[&:not(:first-child)]:mt-1 [&:not(:first-child)]:border-t [&:not(:first-child)]:border-line [&:not(:first-child)]:pt-1",
22
+ columns: "min-w-48 flex-1 [&:not(:first-child)]:mt-1 [&:not(:first-child)]:border-t [&:not(:first-child)]:border-line [&:not(:first-child)]:pt-1 sm:[&:not(:first-child)]:mt-0 sm:[&:not(:first-child)]:ml-1 sm:[&:not(:first-child)]:border-t-0 sm:[&:not(:first-child)]:border-l sm:[&:not(:first-child)]:pt-0 sm:[&:not(:first-child)]:pl-1",
23
+ };
24
+ /** The id of a folded section's own row. The options' ids share one namespace with it, so it
25
+ * carries a prefix no option id has. */
26
+ const FOLD = "\u0000fold:";
15
27
  /** A submenu opens beside its row, flush against the parent panel and pulled up by the
16
28
  * panel's padding plus its hairline (`p-1` + 1), so its first row lines up with the row that
17
29
  * opened it — a submenu that starts half a row lower reads as belonging to the next one. */
@@ -35,7 +47,7 @@ export function indexOptions(options, into = new Map()) {
35
47
  * criteria) still has to look like its neighbours; copying these classes is how the third
36
48
  * trigger ends up one pixel off. Same reason `buttonClasses` exists.
37
49
  */
38
- export function menuTriggerClasses({ variant = "button", surface = "canvas", active = false, open = false, focusVisible = false, iconOnly = false, }) {
50
+ export function menuTriggerClasses({ variant = "button", surface = "canvas", active = false, current = false, open = false, focusVisible = false, iconOnly = false, }) {
39
51
  /* `text` is the menu of a BAR: no frame and no background, just the highlight
40
52
  on hover. Five bordered menus on top of an application are five buttons
41
53
  competing with the ones in the view, and the bar stops reading as an index.
@@ -48,30 +60,38 @@ export function menuTriggerClasses({ variant = "button", surface = "canvas", act
48
60
  : surface === "chrome"
49
61
  ? `border-chrome-muted/35 bg-chrome-raised text-chrome-ink hover:border-chrome-accent/45 ${active ? "border-chrome-accent/60" : ""}`
50
62
  : `border-line-strong bg-surface hover:border-primary/45 hover:bg-primary/5 ${active ? "border-primary/60 text-primary" : "text-ink"}`;
51
- return `inline-flex h-(--size-control-sm) shrink-0 cursor-default items-center gap-1.5 border text-micro font-medium whitespace-nowrap outline-0 transition-colors duration-(--duration-instant) ${focusVisible ? "outline-2 outline-offset-2 outline-primary" : ""} ${iconOnly ? "w-(--size-control-sm) justify-center rounded-pill" : "rounded-control px-2.5"} ${tone}`;
63
+ /* «Here» is a SHAPE under the label, in the colour that marks the place on each surface:
64
+ the gold on the chrome (where it is legible, 6.70:1), the navy on the canvas. */
65
+ const here = current
66
+ ? `relative after:absolute after:inset-x-2.5 after:bottom-0.5 after:h-0.5 after:rounded-pill ${surface === "chrome"
67
+ ? "text-chrome-ink after:bg-chrome-accent"
68
+ : "text-ink after:bg-primary"}`
69
+ : "";
70
+ return `inline-flex h-(--size-control-sm) shrink-0 cursor-default items-center gap-1.5 border text-micro font-medium whitespace-nowrap outline-0 transition-colors duration-(--duration-instant) ${focusVisible ? "outline-2 outline-offset-2 outline-primary" : ""} ${iconOnly ? "w-(--size-control-sm) justify-center rounded-pill" : "rounded-control px-2.5"} ${tone} ${here}`;
52
71
  }
53
72
  export function Menu({ label, groups, onSelect, surface = "canvas", align = "start", icon: Trigger,
54
73
  /** The menu as a control of a list ("filters ▾") carries the chevron; the
55
74
  * actions `⋯` does not, because the icon already says there is more. */
56
- chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, count, }) {
75
+ chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, count, current = false, layout = "list", }) {
57
76
  const copy = useUiCopy();
58
77
  const { contains } = useFilter({ sensitivity: "base" });
59
78
  const byId = indexOptions(groups.flatMap((g) => g.options));
60
- const menu = (_jsx(MenuList, { label: label, groups: groups, width: width, closeOnSelect: closeOnSelect, onAction: (key) => {
79
+ const menu = (_jsx(MenuList, { label: label, groups: groups, width: width, layout: layout, foldable: searchPlaceholder === undefined, closeOnSelect: closeOnSelect, onAction: (key) => {
61
80
  const option = byId.get(String(key));
62
81
  option?.onSelect?.();
63
82
  onSelect?.(String(key));
64
83
  }, emptyText: emptyText ?? copy.menu.empty }));
65
- return (_jsxs(MenuTrigger, { children: [_jsx(AriaButton, { "aria-label": iconOnly ? label : undefined, ...(role === undefined ? {} : { "data-emphasis": role }), className: ({ isPressed, isFocusVisible }) => role === undefined
84
+ return (_jsxs(MenuTrigger, { children: [_jsx(AriaButton, { "data-ui": "menu.trigger", "aria-label": iconOnly ? label : undefined, ...(role === undefined ? {} : { "data-emphasis": role }), className: ({ isPressed, isFocusVisible }) => role === undefined
66
85
  ? menuTriggerClasses({
67
86
  variant,
68
87
  surface,
69
88
  active,
89
+ current,
70
90
  open: isPressed,
71
91
  focusVisible: isFocusVisible,
72
92
  iconOnly,
73
93
  })
74
- : `${buttonClasses(role, size, surface)} gap-1.5`, children: _jsxs("span", { className: "contents", title: title ?? (iconOnly ? label : undefined), children: [Trigger === undefined ? (iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null) : (_jsx(Trigger, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })), iconOnly ? null : label, iconOnly || count === undefined ? null : _jsx(Count, { value: count, surface: surface }), chevron && !iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null] }) }), _jsx(Popover, { placement: align === "end" ? "bottom end" : "bottom start", className: WIDTH[width], children: searchPlaceholder === undefined ? (menu) : (
94
+ : `${buttonClasses(role, size, surface)} gap-1.5`, children: _jsxs("span", { className: "contents", title: title ?? (iconOnly ? label : undefined), children: [Trigger === undefined ? (iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null) : (_jsx(Trigger, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })), iconOnly ? null : label, iconOnly || count === undefined ? null : _jsx(Count, { value: count, surface: surface }), chevron && !iconOnly ? (_jsx(ChevronDown, { className: "size-(--size-icon-sm)", strokeWidth: 2, "aria-hidden": true })) : null] }) }), _jsx(Popover, { placement: align === "end" ? "bottom end" : "bottom start", className: layout === "columns" ? COLUMNS_WIDTH : WIDTH[width], children: searchPlaceholder === undefined ? (menu) : (
75
95
  /* The search box stays at the top: in a menu of twenty-five entries,
76
96
  scrolling loses exactly the control that explains why only three are
77
97
  visible. It filters on label AND hint — half the entries of this
@@ -84,25 +104,59 @@ chevron = true, active = false, iconOnly = false, variant = "button", searchPlac
84
104
  * submenu is this same panel one level down, and a panel can be rendered on the server
85
105
  * without the trigger's popover, which is how the tests see the rows.
86
106
  */
87
- export function MenuList({ label, groups, onAction, closeOnSelect, emptyText, width = "md", }) {
88
- /* Per panel: a submenu without icons does not inherit its parent's mark column. */
89
- const hasMarks = groups.some((g) => g.options.some((o) => o.checked !== undefined || o.icon !== undefined));
107
+ export function MenuList({ label, groups, onAction, closeOnSelect, emptyText, width = "md", layout = "list", foldable = true, }) {
108
+ const sectionKey = (g, index) => g.label ?? String(index);
109
+ const folds = (g) => foldable && g.collapsible === true && g.label !== undefined;
110
+ /* Which folded sections are open. One that holds something ticked starts open: otherwise
111
+ what is set hides behind a chevron and you have to guess where. */
112
+ const [unfolded, setUnfolded] = useState(() => new Set(groups
113
+ .filter((g) => folds(g) && g.options.some((o) => o.checked === true))
114
+ .map((g) => g.label)));
115
+ const act = (key) => {
116
+ const id = String(key);
117
+ if (!id.startsWith(FOLD)) {
118
+ onAction(key);
119
+ return;
120
+ }
121
+ const section = id.slice(FOLD.length);
122
+ setUnfolded((current) => {
123
+ const next = new Set(current);
124
+ if (!next.delete(section))
125
+ next.add(section);
126
+ return next;
127
+ });
128
+ };
129
+ /* Per panel: a submenu without icons does not inherit its parent's mark column. A section's
130
+ icon sits in that column too, so its title starts where its rows' text does. */
131
+ const hasMarks = groups.some((g) => (g.label !== undefined && g.icon !== undefined) ||
132
+ g.options.some((o) => o.checked !== undefined || o.icon !== undefined));
90
133
  const hasHints = groups.some((g) => g.options.some((o) => o.hint !== undefined));
91
- const row = (o) => {
134
+ const row = (o, nested = false) => {
92
135
  const Icon = o.icon;
93
136
  const opens = o.items !== undefined;
94
137
  const checked = !opens && o.checked === true;
95
- return (_jsxs(MenuItem, { id: o.id, textValue: o.hint === undefined ? o.label : `${o.label} ${o.hint}`, isDisabled: o.disabled, className: `flex w-full cursor-default rounded-control ${hasHints ? "items-start py-1.5" : "items-center py-1"} gap-2 px-2 text-left outline-0 transition-colors duration-(--duration-instant) data-focused:bg-primary/8 data-open:bg-primary/8 disabled:opacity-45`, children: [hasMarks ? (_jsx("span", { className: `${hasHints ? "mt-0.5" : ""} flex size-(--size-icon-sm) shrink-0 items-center justify-center`, children: checked ? (_jsx(Check, { className: "size-(--size-icon-sm) text-primary", strokeWidth: 2.5, "aria-hidden": true })) : Icon !== undefined ? (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2, "aria-hidden": true })) : null })) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${checked ? "font-medium text-ink" : "text-ink"}`, children: o.label }), o.badge === undefined ? null : typeof o.badge === "number" ? (_jsx("span", { className: "ml-auto flex shrink-0", children: _jsx(Count, { value: o.badge }) })) : typeof o.badge === "string" ? (_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 })) : (_jsx("span", { className: "ml-auto shrink-0", children: o.badge }))] }), o.hint === undefined ? null : (_jsx("span", { className: "mt-0.5 block truncate text-micro text-muted", children: o.hint }))] }), o.shortcut === undefined ? null : (_jsx(Keyboard, { className: "shrink-0 self-center pl-3 font-mono text-micro text-muted", children: o.shortcut })), opens ? (_jsx(ChevronRight, { className: "size-(--size-icon-sm) shrink-0 self-center text-muted", strokeWidth: 2, "aria-hidden": true })) : null] }, o.id));
138
+ return (_jsxs(MenuItem, { id: o.id, textValue: o.hint === undefined ? o.label : `${o.label} ${o.hint}`, isDisabled: o.disabled, "data-ui": "menu.item", className: `flex w-full cursor-default rounded-ui-option ${hasHints ? "items-start py-1.5" : "items-center py-1"} gap-2 ${nested ? "pr-2 pl-(--spacing-indent)" : "px-2"} text-left outline-0 transition-colors duration-(--duration-instant) data-focused:bg-ui-option-active data-open:bg-ui-option-active disabled:opacity-45`, children: [hasMarks ? (_jsx("span", { className: `${hasHints ? "mt-0.5" : ""} flex size-(--size-icon-sm) shrink-0 items-center justify-center`, children: checked ? (_jsx(Check, { className: "size-(--size-icon-sm) text-primary", strokeWidth: 2.5, "aria-hidden": true })) : Icon !== undefined ? (_jsx(Icon, { className: "size-(--size-icon-sm) text-muted", strokeWidth: 2, "aria-hidden": true })) : null })) : null, _jsxs("span", { className: "min-w-0 flex-1", children: [_jsxs("span", { className: "flex items-center gap-1.5", children: [_jsx("span", { className: `truncate text-meta ${checked ? "font-medium text-ink" : "text-ink"}`, children: o.label }), o.badge === undefined ? null : typeof o.badge === "number" ? (_jsx("span", { className: "ml-auto flex shrink-0", children: _jsx(Count, { value: o.badge }) })) : typeof o.badge === "string" ? (_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 })) : (_jsx("span", { className: "ml-auto shrink-0", children: o.badge }))] }), o.hint === undefined ? null : (_jsx("span", { className: "mt-0.5 block truncate text-micro text-muted", children: o.hint }))] }), o.shortcut === undefined ? null : (_jsx(Keyboard, { className: "shrink-0 self-center pl-3 font-mono text-micro text-muted", children: o.shortcut })), opens ? (_jsx(ChevronRight, { className: "size-(--size-icon-sm) shrink-0 self-center text-muted", strokeWidth: 2, "aria-hidden": true })) : null] }, o.id));
96
139
  };
97
- return (_jsx(AriaMenu, { "aria-label": label, shouldCloseOnSelect: closeOnSelect, onAction: onAction, renderEmptyState: () => (_jsx("p", { className: "px-3 py-3 text-meta text-muted italic", children: emptyText })), className: "max-h-[inherit] overflow-y-auto p-1 outline-0", children: groups.map((g, gi) => (_jsxs(MenuSection, { className: "[&:not(:first-child)]:mt-1 [&:not(:first-child)]:border-t [&:not(:first-child)]:border-line [&:not(:first-child)]:pt-1", children: [g.label === undefined ? null : (
98
- /* Same skeleton as the row: the label sits on the text column. */
99
- _jsxs(Header, { className: "flex items-center gap-2 px-2 pt-1 pb-0.5 text-micro font-medium text-muted", children: [hasMarks ? (_jsx("span", { className: "size-(--size-icon-sm) shrink-0", "aria-hidden": true })) : null, g.label] })), g.options.flatMap((o) => {
100
- const item = o.items === undefined ? (row(o)) : (_jsxs(SubmenuTrigger, { children: [row(o), _jsx(Popover, { offset: SUBMENU_OFFSET, crossOffset: SUBMENU_CROSS_OFFSET, className: WIDTH[width], children: _jsx(MenuList, { label: o.label, groups: [{ options: [...o.items] }], onAction: onAction, closeOnSelect: closeOnSelect, emptyText: emptyText, width: width }) })] }, o.id));
101
- return o.divider === true
102
- ? [
103
- _jsx(Separator, { className: "my-1 h-px border-0 bg-line" }, `${o.id}-divider`),
104
- item,
105
- ]
106
- : [item];
107
- })] }, g.label ?? gi))) }));
140
+ return (_jsx(AriaMenu, { "data-ui": "menu", "aria-label": label, shouldCloseOnSelect: closeOnSelect, onAction: act, renderEmptyState: () => (_jsx("p", { className: "px-3 py-3 text-meta text-muted italic", children: emptyText })), className: `max-h-[inherit] overflow-y-auto p-1 outline-0 ${layout === "columns" ? "flex flex-col sm:flex-row sm:items-stretch" : ""}`, children: groups.map((g, gi) => {
141
+ const key = sectionKey(g, gi);
142
+ const folding = folds(g);
143
+ const open = !folding || unfolded.has(key);
144
+ return (_jsxs(MenuSection, { "data-ui": "menu.section", className: SECTION[layout], children: [g.label === undefined ? null : folding ? (
145
+ /* A folded section is a ROW you press — it is the door to the options, so it
146
+ reads as one (ink, the row's size) and says how many wait behind it. The
147
+ chevron points down and turns: a submenu's points to the side. */
148
+ _jsxs(MenuItem, { id: `${FOLD}${key}`, textValue: g.label, shouldCloseOnSelect: false, "aria-expanded": open, "data-ui": "menu.fold", className: "flex w-full cursor-default items-center gap-2 rounded-ui-option px-2 py-1 text-left outline-0 transition-colors duration-(--duration-instant) data-focused:bg-ui-option-active", children: [g.icon !== undefined ? (_jsx(g.icon, { className: "size-(--size-icon-sm) shrink-0 text-muted", strokeWidth: 2, "aria-hidden": true })) : hasMarks ? (_jsx("span", { className: "size-(--size-icon-sm) shrink-0", "aria-hidden": true })) : null, _jsx("span", { className: "min-w-0 flex-1 truncate text-meta font-semibold text-ink", children: g.label }), open ? null : _jsx(Count, { value: g.options.length, "aria-hidden": true }), _jsx(ChevronDown, { className: `size-(--size-icon-sm) shrink-0 text-muted transition-transform duration-(--duration-instant) ${open ? "rotate-180" : ""}`, strokeWidth: 2, "aria-hidden": true })] })) : (
149
+ /* Same skeleton as the row: the label sits on the text column, its icon on the
150
+ mark column. A step above the rows — semibold — and still quieter than them:
151
+ it names the block, it is not one more thing to choose. */
152
+ _jsxs(Header, { className: "flex items-center gap-2 px-2 pt-1.5 pb-1 text-micro font-semibold text-muted", children: [g.icon !== undefined ? (_jsx(g.icon, { className: "size-(--size-icon-sm) shrink-0", strokeWidth: 2, "aria-hidden": true })) : hasMarks ? (_jsx("span", { className: "size-(--size-icon-sm) shrink-0", "aria-hidden": true })) : null, g.label] })), (open ? g.options : []).flatMap((o) => {
153
+ const item = o.items === undefined ? (row(o, folding)) : (_jsxs(SubmenuTrigger, { children: [row(o, folding), _jsx(Popover, { offset: SUBMENU_OFFSET, crossOffset: SUBMENU_CROSS_OFFSET, className: WIDTH[width], children: _jsx(MenuList, { label: o.label, groups: [{ options: [...o.items] }], onAction: onAction, closeOnSelect: closeOnSelect, emptyText: emptyText, width: width }) })] }, o.id));
154
+ return o.divider === true
155
+ ? [
156
+ _jsx(Separator, { className: "my-1 h-px border-0 bg-line" }, `${o.id}-divider`),
157
+ item,
158
+ ]
159
+ : [item];
160
+ })] }, key));
161
+ }) }));
108
162
  }
@@ -12,7 +12,7 @@ import { composeRenderProps, Popover as AriaPopover, } from "react-aria-componen
12
12
  * focus and closes it on Escape; this only dresses it.
13
13
  */
14
14
  const popover = tv({
15
- base: "rounded-panel border border-line-strong bg-surface text-ink shadow-float outline-0 transition-[opacity,translate] duration-(--duration-quick) ease-(--ease-out) forced-colors:bg-[Canvas]",
15
+ base: "rounded-ui-popover border border-ui-popover-border bg-ui-popover text-ink shadow-ui-popover outline-0 transition-[opacity,translate] duration-(--duration-quick) ease-(--ease-out) forced-colors:bg-[Canvas]",
16
16
  variants: {
17
17
  isEntering: {
18
18
  true: "opacity-0 placement-bottom:-translate-y-1 placement-top:translate-y-1",
@@ -23,5 +23,5 @@ const popover = tv({
23
23
  },
24
24
  });
25
25
  export function Popover({ children, className, offset = 6, ...props }) {
26
- return (_jsx(AriaPopover, { offset: offset, ...props, className: composeRenderProps(className, (own, state) => popover({ ...state, className: own })), children: children }));
26
+ return (_jsx(AriaPopover, { "data-ui": "popover", offset: offset, ...props, className: composeRenderProps(className, (own, state) => popover({ ...state, className: own })), children: children }));
27
27
  }
@@ -68,14 +68,14 @@ function sectioned(items) {
68
68
  and the marked row is said by its tint — a ring inside the list as well as around the
69
69
  field is two marks for one place. */
70
70
  const option = tv({
71
- base: "flex w-full min-w-0 cursor-default gap-2 rounded-control px-2 text-left outline-0 select-none forced-color-adjust-none",
71
+ base: "flex w-full min-w-0 cursor-default gap-2 rounded-ui-option px-2 text-left outline-0 select-none forced-color-adjust-none",
72
72
  variants: {
73
73
  hints: {
74
74
  true: "items-start py-1.5",
75
75
  false: "items-center py-1",
76
76
  },
77
77
  isFocused: {
78
- true: "bg-primary/8 forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
78
+ true: "bg-ui-option-active forced-colors:bg-[Highlight] forced-colors:text-[HighlightText]",
79
79
  },
80
80
  isHovered: {
81
81
  true: "bg-ink/4",
@@ -87,7 +87,7 @@ const option = tv({
87
87
  true: "opacity-45 forced-colors:text-[GrayText]",
88
88
  },
89
89
  },
90
- compoundVariants: [{ isFocused: true, isHovered: true, class: "bg-primary/8" }],
90
+ compoundVariants: [{ isFocused: true, isHovered: true, class: "bg-ui-option-active" }],
91
91
  });
92
92
  export function Picker({ mode, ...props }) {
93
93
  if (useFormMode(mode) === "read") {
@@ -162,7 +162,7 @@ function EditableTagsField({ value, onChange, options, onCreate, onSearch, onBro
162
162
  list from what it holds, and a tag group in there is read as part of that list. The
163
163
  popover is anchored to the whole box and as wide as it — the list continues the field,
164
164
  and the input alone is a sliver after the last chip. */
165
- _jsxs(Group, { ref: boxRef, isDisabled: disabled, isInvalid: invalid, className: (state) => fieldGroupStyles({
165
+ _jsxs(Group, { ref: boxRef, "data-ui": "control", isDisabled: disabled, isInvalid: invalid, className: (state) => fieldGroupStyles({
166
166
  ...state,
167
167
  /* The box grows with the chips: five categories wrap to a second line instead of
168
168
  scrolling out of sight. */