@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
@@ -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. */
@@ -819,9 +819,9 @@ groupTotal, height, layout = "auto", onOpen, onDiscard, bands, adds, flag, onReo
819
819
  return (
820
820
  /* A collection is many controls, each named by its column: no enclosing `Field`
821
821
  reaches inside (see `FieldBoundary`). */
822
- _jsx(FieldBoundary, { children: _jsxs("div", { ref: frame, className: "min-w-0", children: [_jsx("div", { ref: box.ref, tabIndex: box.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${box.className}`, style: box.style, children: stacked ? (list) : (_jsxs("table", { className: "w-full border-separate border-spacing-0 px-1 text-left", ...(view.on
822
+ _jsx(FieldBoundary, { children: _jsxs("div", { ref: frame, className: "min-w-0", children: [_jsx("div", { ref: box.ref, tabIndex: box.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${box.className}`, style: box.style, children: stacked ? (list) : (_jsxs("table", { "data-ui": "table", className: "w-full border-separate border-spacing-0 px-1 text-left", ...(view.on
823
823
  ? { "aria-rowcount": 1 + drawn.length + (totals === undefined ? 0 : 1) }
824
- : {}), children: [_jsx("thead", { className: "sticky z-10 bg-ground", style: stickyTop, children: _jsxs("tr", { ...(view.on ? { "aria-rowindex": 1 } : {}), children: [reorderable ? _jsx("td", { className: "w-0 border-b border-line-strong" }) : null, columns.map((c) => c.header === "" ? (_jsx("td", { className: "w-0 border-b border-line-strong" }, c.id)) : (_jsx("th", { scope: "col", style: c.width === undefined ? undefined : { width: c.width },
824
+ : {}), children: [_jsx("thead", { className: "sticky z-10 bg-ui-table-head", style: stickyTop, "data-ui": "table.head", children: _jsxs("tr", { ...(view.on ? { "aria-rowindex": 1 } : {}), children: [reorderable ? _jsx("td", { className: "w-0 border-b border-line-strong" }) : null, columns.map((c) => c.header === "" ? (_jsx("td", { className: "w-0 border-b border-line-strong" }, c.id)) : (_jsx("th", { scope: "col", style: c.width === undefined ? undefined : { width: c.width },
825
825
  /* A column of figures takes its figures' width (`w-0` in an auto
826
826
  table is «as narrow as its content») and the text takes the rest:
827
827
  the product name was cut while «Cantidad» had room for ten digits. */
@@ -104,5 +104,5 @@ defaultOpen, caption, height, }) {
104
104
  bar's offset and ended up pushed 68 px into its
105
105
  own box — a blank band on top and column titles falling between
106
106
  the rows. */
107
- _jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsxs("table", { className: "w-full border-collapse px-1", children: [caption === undefined ? null : (_jsx("caption", { className: `text-left text-meta text-muted ${byDensity(d, "px-3 pb-2", "px-2 pb-1.5")}`, children: caption })), _jsx("thead", { className: "sticky z-20 bg-ground", style: stickyTop, children: _jsxs("tr", { className: "border-b border-line-strong", children: [_jsx("th", { className: `sticky left-0 z-10 bg-ground text-left ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: _jsx("span", { className: "sr-only", children: copy.report.concept }) }), columns.map((c) => (_jsx("th", { scope: "col", className: `text-right ${HEADER_TEXT} ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: c.header }, c.id))), _jsx("td", { className: "w-0" })] }) }), _jsx("tbody", { children: rows.map((r) => (_jsx(ReportLine, { row: r, columns: columns, open: open, onToggle: toggle, compact: compact }, r.id))) })] }) }));
107
+ _jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsxs("table", { "data-ui": "table", className: "w-full border-collapse px-1", children: [caption === undefined ? null : (_jsx("caption", { className: `text-left text-meta text-muted ${byDensity(d, "px-3 pb-2", "px-2 pb-1.5")}`, children: caption })), _jsx("thead", { className: "sticky z-20 bg-ui-table-head", style: stickyTop, "data-ui": "table.head", children: _jsxs("tr", { className: "border-b border-line-strong", children: [_jsx("th", { className: `sticky left-0 z-10 bg-ground text-left ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: _jsx("span", { className: "sr-only", children: copy.report.concept }) }), columns.map((c) => (_jsx("th", { scope: "col", className: `text-right ${HEADER_TEXT} ${compact ? "px-2 py-1.5" : "px-3 py-2"}`, children: c.header }, c.id))), _jsx("td", { className: "w-0" })] }) }), _jsx("tbody", { children: rows.map((r) => (_jsx(ReportLine, { row: r, columns: columns, open: open, onToggle: toggle, compact: compact }, r.id))) })] }) }));
108
108
  }
@@ -51,7 +51,7 @@ height, rowCount, }) {
51
51
  `useScrollBox`: the whole dilemma lives there, and so does its explanation. The
52
52
  three tables of the system solved it with three copies of the same
53
53
  measurement. */
54
- _jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsx("table", { "aria-rowcount": rowCount, className: "w-full border-separate border-spacing-0 px-1 text-left", children: children }) }));
54
+ _jsx("div", { ref: caja.ref, tabIndex: caja.tabIndex, className: `min-w-0 focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${caja.className}`, style: caja.style, children: _jsx("table", { "data-ui": "table", "aria-rowcount": rowCount, className: "w-full border-separate border-spacing-0 px-1 text-left", children: children }) }));
55
55
  }
56
56
  /** The text of a column header, shared by every table of the family. Ink and semibold, not
57
57
  * muted: in grey at the cells' weight the names of the columns read as one more row. */
@@ -62,7 +62,7 @@ export function THead({ children, rowIndex, }) {
62
62
  list's— and not at `top: 0`, which tucked it behind both. Without a height on
63
63
  `Table` the page is what scrolls, and there the difference is exactly
64
64
  what made the column names disappear. See `system/sticky.tsx`. */
65
- _jsx("thead", { className: "sticky z-10 bg-ground", style: stickyTop, children: _jsx("tr", { "aria-rowindex": rowIndex, children: children }) }));
65
+ _jsx("thead", { className: "sticky z-10 bg-ui-table-head", style: stickyTop, "data-ui": "table.head", children: _jsx("tr", { "aria-rowindex": rowIndex, children: children }) }));
66
66
  }
67
67
  /** A column. If it gets a `sortKey`, it can be sorted.
68
68
  *
@@ -4,6 +4,15 @@ export type { Tone };
4
4
  /** The classes of a tone on a surface — the capsule's colors, shared with the chips of
5
5
  * `Tags` so a classification reads the same as a value and as a removable chip. */
6
6
  export declare function tagTone(tone: Tone, surface: "canvas" | "chrome"): string;
7
+ /**
8
+ * The capsule of something SET: an applied filter, a grouping level, a chip of the draft.
9
+ *
10
+ * Context: a selection, so it wears the selection's family — the navy on the canvas, the
11
+ * link on the chrome — as the current row of a `NavigationTree` does. It was the gold, and a
12
+ * bar of six gold chips drowned the one action the gold is kept for (PRINCIPLES §3: «the
13
+ * accent only for the action»).
14
+ */
15
+ export declare function chosenTone(surface: "canvas" | "chrome"): string;
7
16
  export declare function Tag({ children, tone, surface,
8
17
  /** Context: a one-word classification sometimes needs a sentence that does not
9
18
  * fit. The sentence goes into the `title` and not underneath, because the
@@ -36,12 +36,25 @@ const TAG_TONE = {
36
36
  export function tagTone(tone, surface) {
37
37
  return TAG_TONE[tone][surface];
38
38
  }
39
+ /**
40
+ * The capsule of something SET: an applied filter, a grouping level, a chip of the draft.
41
+ *
42
+ * Context: a selection, so it wears the selection's family — the navy on the canvas, the
43
+ * link on the chrome — as the current row of a `NavigationTree` does. It was the gold, and a
44
+ * bar of six gold chips drowned the one action the gold is kept for (PRINCIPLES §3: «the
45
+ * accent only for the action»).
46
+ */
47
+ export function chosenTone(surface) {
48
+ return surface === "chrome"
49
+ ? "border border-chrome-link/40 bg-chrome-link/20 text-chrome-ink"
50
+ : "border border-primary/30 bg-primary/8 text-ink";
51
+ }
39
52
  export function Tag({ children, tone = "neutral", surface = "canvas",
40
53
  /** Context: a one-word classification sometimes needs a sentence that does not
41
54
  * fit. The sentence goes into the `title` and not underneath, because the
42
55
  * line below is taken up by the row's metadata. */
43
56
  title, }) {
44
- return (_jsx("span", { title: title, className: `inline-flex shrink-0 items-center rounded-pill px-2 py-0.5 text-micro font-medium whitespace-nowrap ${TAG_TONE[tone][surface]}`, children: children }));
57
+ return (_jsx("span", { title: title, "data-ui": "tag", "data-tone": tone, className: `inline-flex shrink-0 items-center rounded-ui-tag px-2 py-0.5 text-micro font-medium whitespace-nowrap ${TAG_TONE[tone][surface]}`, children: children }));
45
58
  }
46
59
  const DOT_TONE = {
47
60
  neutral: { canvas: "bg-muted", chrome: "bg-chrome-muted" },
@@ -3,7 +3,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
3
3
  import { AriaLocale } from "../../foundations/aria.js";
4
4
  import { bySurface, useSurface } from "../../foundations/surface.js";
5
5
  import { cn, focusRing } from "../../foundations/variants.js";
6
- import { tagTone } from "./Tag.js";
6
+ import { chosenTone, tagTone } from "./Tag.js";
7
7
  import { Avatar } from "../value/Person.js";
8
8
  import { X } from "lucide-react";
9
9
  import { Button as AriaButton, Tag as AriaTag, TagGroup, TagList, } from "react-aria-components";
@@ -21,7 +21,7 @@ const STACK = "flex min-w-0 flex-col items-stretch gap-0.5";
21
21
  /** A strip nobody presses: text in a row, a list only when it is named. */
22
22
  function StillStrip({ items, surface, label, stack, }) {
23
23
  const listed = label !== undefined;
24
- return (_jsx("span", { className: stack ? STACK : STRIP, ...(listed ? { role: "list", "aria-label": label } : {}), children: items.map((item) => (_jsx("span", { ...(listed ? { role: "listitem" } : {}), ...(item.title === undefined ? {} : { title: item.title }), className: shell({ item, surface, stack, removable: false, pressable: false }), children: _jsx(Inside, { item: item }) }, item.id))) }));
24
+ return (_jsx("span", { className: stack ? STACK : STRIP, ...(listed ? { role: "list", "aria-label": label } : {}), children: items.map((item) => (_jsx("span", { "data-ui": "tags.item", ...(listed ? { role: "listitem" } : {}), ...(item.title === undefined ? {} : { title: item.title }), className: shell({ item, surface, stack, removable: false, pressable: false }), children: _jsx(Inside, { item: item }) }, item.id))) }));
25
25
  }
26
26
  function ChipGroup({ items, surface, label, labelledBy, stack, multiple, }) {
27
27
  const byId = new Map(items.map((item) => [item.id, item]));
@@ -65,7 +65,7 @@ function ChipGroup({ items, surface, label, labelledBy, stack, multiple, }) {
65
65
  : {}),
66
66
  /* Escape belongs to whatever holds the strip — the popover it lives in closes with it —
67
67
  and not to «clear the selection», which would erase the choice without a word. */
68
- escapeKeyBehavior: "none", className: "min-w-0", children: _jsx(TagList, { items: items, className: stack ? STACK : STRIP, children: (item) => (_jsxs(AriaTag, { id: item.id, textValue: item.note === undefined ? item.label : `${item.label} ${item.note}`, ...(!selecting && item.onSelect !== undefined
68
+ escapeKeyBehavior: "none", className: "min-w-0", children: _jsx(TagList, { items: items, className: stack ? STACK : STRIP, children: (item) => (_jsxs(AriaTag, { "data-ui": "tags.item", id: item.id, textValue: item.note === undefined ? item.label : `${item.label} ${item.note}`, ...(!selecting && item.onSelect !== undefined
69
69
  ? { onAction: item.onSelect }
70
70
  : {}), ...(item.title === undefined ? {} : { title: item.title }), className: ({ isFocusVisible, isHovered }) => cn(shell({
71
71
  item,
@@ -81,9 +81,8 @@ function paint(item, surface) {
81
81
  if (item.active === true) {
82
82
  return bySurface(surface, "border border-primary bg-primary text-surface", "border border-chrome-link bg-chrome-link text-chrome");
83
83
  }
84
- if (item.selected === true) {
85
- return bySurface(surface, "border border-accent/40 bg-accent/18 text-ink", "border border-chrome-link/40 bg-chrome-link/25 text-chrome-ink");
86
- }
84
+ if (item.selected === true)
85
+ return chosenTone(surface);
87
86
  if (item.tone !== undefined && item.tone !== "neutral")
88
87
  return tagTone(item.tone, surface);
89
88
  return bySurface(surface, "border border-line-strong bg-ink/5 text-ink", "border border-chrome-muted/30 bg-chrome-ink/12 text-chrome-ink");
@@ -92,7 +91,7 @@ function paint(item, surface) {
92
91
  read as a list, it reads as a mess — and the blank on the right is what lets it be
93
92
  pressed without aiming. */
94
93
  function shell({ item, surface, stack, removable, pressable, }) {
95
- return cn(stack ? "flex w-full justify-start" : "inline-flex shrink-0", "min-w-0 items-center gap-1 rounded-pill py-0.5 text-micro transition-colors duration-(--duration-instant)", paint(item, surface), removable ? "pr-0.5 pl-2" : "px-2", pressable ? "cursor-pointer" : "cursor-default");
94
+ return cn(stack ? "flex w-full justify-start" : "inline-flex shrink-0", "min-w-0 items-center gap-1 rounded-ui-tag py-0.5 text-micro transition-colors duration-(--duration-instant)", paint(item, surface), removable ? "pr-0.5 pl-2" : "px-2", pressable ? "cursor-pointer" : "cursor-default");
96
95
  }
97
96
  function Inside({ item }) {
98
97
  const Icon = item.icon;
@@ -29,6 +29,10 @@ export type MetricProps = {
29
29
  * zero. */
30
30
  value?: number | string;
31
31
  label: string;
32
+ /** A second reading of the same count, already formatted, under the label: «6 · Bs
33
+ * 1.000,00» is how many AND how much. Muted and small — the figure on top is still the
34
+ * one compared across the row. */
35
+ detail?: string;
32
36
  /** The figure is being read. The label stays and the box keeps its size, so a row of
33
37
  * metrics does not jump when the numbers land one at a time. */
34
38
  loading?: boolean;
@@ -50,7 +54,7 @@ export type MetricProps = {
50
54
  better?: "up" | "down";
51
55
  };
52
56
  };
53
- export declare function Metric({ value, label, tone, icon: Icon, onClick, active, change, loading, }: MetricProps): import("react").JSX.Element;
57
+ export declare function Metric({ value, label, detail, tone, icon: Icon, onClick, active, change, loading, }: MetricProps): import("react").JSX.Element;
54
58
  /** The row of metrics. It wraps if they don't fit; it doesn't scroll: a hidden
55
59
  * metric is a filter nobody finds. */
56
60
  export declare function Metrics({ children }: {
@@ -14,7 +14,7 @@ const TONE = {
14
14
  ink and the tone is only visible when the card is lit up. */
15
15
  accent: { background: "bg-accent/20", text: "text-ink", edge: "border-accent/50" },
16
16
  };
17
- export function Metric({ value, label, tone = "neutral", icon: Icon, onClick, active = false, change, loading = false, }) {
17
+ export function Metric({ value, label, detail, tone = "neutral", icon: Icon, onClick, active = false, change, loading = false, }) {
18
18
  const copy = useUiCopy();
19
19
  const sup = useSurface();
20
20
  const t = TONE[tone];
@@ -28,8 +28,8 @@ export function Metric({ value, label, tone = "neutral", icon: Icon, onClick, ac
28
28
  there the color says which one is applied. */
29
29
  const skin = active
30
30
  ? `${t.background} ${t.edge}`
31
- : bySurface(sup, "bg-surface border-line", "bg-chrome-ink/6 border-chrome-ink/15");
32
- const box = `flex min-w-(--container-metric) shrink-0 flex-col justify-center gap-0.5 rounded-box border px-3.5 py-2 text-left transition-colors duration-(--duration-instant) ${skin} ${onClick === undefined
31
+ : bySurface(sup, "bg-ui-card border-ui-card-border", "bg-chrome-ink/6 border-chrome-ink/15");
32
+ const box = `flex min-w-(--container-metric) shrink-0 flex-col justify-center gap-0.5 rounded-ui-card border px-3.5 py-2 text-left transition-colors duration-(--duration-instant) ${skin} ${onClick === undefined
33
33
  ? ""
34
34
  : "cursor-pointer hover:border-line-strong focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-primary"}`;
35
35
  const figure = value === undefined
@@ -40,11 +40,13 @@ export function Metric({ value, label, tone = "neutral", icon: Icon, onClick, ac
40
40
  const content = (_jsxs(_Fragment, { children: [_jsxs("span", { className: `flex items-center gap-1.5 text-title font-semibold tabular-nums ${t.text}`, children: [Icon === undefined ? null : (_jsx(Icon, { className: "size-(--size-icon-md)", strokeWidth: 2, "aria-hidden": true })), loading ? (
41
41
  /* A bar one line of the figure tall (`h-lh`), so the box is the size it will
42
42
  be. It appears late, like every skeleton: a fast read never shows it. */
43
- _jsx("span", { "aria-hidden": true, className: `inline-block h-lh w-16 animate-reveal-late rounded-control ${bySurface(sup, "bg-ink/8", "bg-chrome-ink/12")}` })) : (figure)] }), _jsx("span", { className: `text-micro ${bySurface(sup, "text-muted", "text-chrome-muted")}`, children: label }), change === undefined || loading ? null : (_jsx(Change, { change: change, format: percent.format }))] }));
43
+ _jsx("span", { "aria-hidden": true, className: `inline-block h-lh w-16 animate-reveal-late rounded-control ${bySurface(sup, "bg-ink/8", "bg-chrome-ink/12")}` })) : (figure)] }), _jsx("span", { className: `text-micro ${bySurface(sup, "text-muted", "text-chrome-muted")}`, children: label }), detail === undefined || loading ? null : (_jsx("span", { "data-ui": "metric.detail", className: `text-micro tabular-nums ${bySurface(sup, "text-muted", "text-chrome-muted")}`, children: detail })), change === undefined || loading ? null : (_jsx(Change, { change: change, format: percent.format }))] }));
44
44
  if (onClick === undefined) {
45
- return (_jsx("div", { className: box, "aria-label": loading ? `${label}: ${copy.failed.loading}` : `${figure} ${label}`, ...(loading ? { "aria-busy": true } : {}), children: content }));
45
+ return (_jsx("div", { "data-ui": "metric", className: box, "aria-label": loading
46
+ ? `${label}: ${copy.failed.loading}`
47
+ : `${figure} ${label}${detail === undefined ? "" : `, ${detail}`}`, ...(loading ? { "aria-busy": true } : {}), children: content }));
46
48
  }
47
- return (_jsxs("button", { type: "button", onClick: onClick, "aria-pressed": active, ...(loading ? { "aria-busy": true } : {}), className: box, children: [content, loading ? _jsx("span", { className: "sr-only", children: copy.failed.loading }) : null] }));
49
+ return (_jsxs("button", { type: "button", onClick: onClick, "aria-pressed": active, ...(loading ? { "aria-busy": true } : {}), "data-ui": "metric", className: box, children: [content, loading ? _jsx("span", { className: "sr-only", children: copy.failed.loading }) : null] }));
48
50
  }
49
51
  function Change({ change, format, }) {
50
52
  const copy = useUiCopy();