@sincpro/web-ui 2.1.0 → 2.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +111 -0
  2. package/dist/components/attachments/Attachments.d.ts +7 -1
  3. package/dist/components/attachments/Attachments.js +8 -2
  4. package/dist/components/board/Board.d.ts +32 -2
  5. package/dist/components/board/Board.js +27 -4
  6. package/dist/components/board/index.d.ts +1 -1
  7. package/dist/components/board/index.js +2 -1
  8. package/dist/components/listing/GroupingLevels.js +11 -9
  9. package/dist/components/listing/RecordCard.js +1 -1
  10. package/dist/components/listing/Row.js +2 -2
  11. package/dist/components/navigation/NavigationTree.js +37 -10
  12. package/dist/components/search/CriteriaBuilder.js +3 -2
  13. package/dist/components/search/CriteriaChips.js +6 -5
  14. package/dist/components/search/JoinWord.js +1 -1
  15. package/dist/components/search/SearchBar.js +68 -29
  16. package/dist/components/shell/AppFrame.d.ts +18 -2
  17. package/dist/components/shell/AppFrame.js +143 -12
  18. package/dist/components/shell/Sidebar.d.ts +39 -0
  19. package/dist/components/shell/Sidebar.js +57 -0
  20. package/dist/components/shell/TopBar.d.ts +10 -1
  21. package/dist/components/shell/TopBar.js +18 -13
  22. package/dist/components/shell/brandMark.d.ts +17 -0
  23. package/dist/components/shell/brandMark.js +9 -0
  24. package/dist/components/shell/index.d.ts +3 -0
  25. package/dist/components/shell/index.js +6 -0
  26. package/dist/components/shell/sidebarDrawer.d.ts +26 -0
  27. package/dist/components/shell/sidebarDrawer.js +22 -0
  28. package/dist/foundations/copy.d.ts +13 -0
  29. package/dist/foundations/copy.es.js +12 -5
  30. package/dist/foundations/copy.js +12 -5
  31. package/dist/foundations/variants.js +19 -2
  32. package/dist/primitives/block/Block.js +1 -1
  33. package/dist/primitives/button/Button.d.ts +3 -1
  34. package/dist/primitives/button/Button.js +6 -6
  35. package/dist/primitives/choice/SegmentedControl.d.ts +4 -1
  36. package/dist/primitives/choice/SegmentedControl.js +35 -7
  37. package/dist/primitives/dialog/Dialog.d.ts +1 -1
  38. package/dist/primitives/dialog/Dialog.js +2 -2
  39. package/dist/primitives/field/CardNumberInput.js +1 -1
  40. package/dist/primitives/field/Checks.d.ts +14 -0
  41. package/dist/primitives/field/Checks.js +12 -4
  42. package/dist/primitives/field/DropZone.d.ts +22 -3
  43. package/dist/primitives/field/DropZone.js +33 -12
  44. package/dist/primitives/field/DurationInput.js +1 -1
  45. package/dist/primitives/field/Field.js +7 -7
  46. package/dist/primitives/field/PatternInput.js +1 -1
  47. package/dist/primitives/field/RichTextEditor.js +2 -2
  48. package/dist/primitives/field/SignatureInput.js +1 -1
  49. package/dist/primitives/field/aria.d.ts +2 -2
  50. package/dist/primitives/field/aria.js +5 -5
  51. package/dist/primitives/field/index.d.ts +1 -1
  52. package/dist/primitives/field/index.js +1 -1
  53. package/dist/primitives/menu/Menu.d.ts +29 -9
  54. package/dist/primitives/menu/Menu.js +77 -22
  55. package/dist/primitives/overlay/Popover.js +2 -2
  56. package/dist/primitives/picker/Picker.js +3 -3
  57. package/dist/primitives/picker/TagsField.js +1 -1
  58. package/dist/primitives/table/EditableTable.js +2 -2
  59. package/dist/primitives/table/ReportTable.js +1 -1
  60. package/dist/primitives/table/Table.js +2 -2
  61. package/dist/primitives/tabs/Tabs.js +2 -28
  62. package/dist/primitives/tag/Count.d.ts +23 -0
  63. package/dist/primitives/tag/Count.js +59 -0
  64. package/dist/primitives/tag/Tag.d.ts +9 -0
  65. package/dist/primitives/tag/Tag.js +14 -1
  66. package/dist/primitives/tag/Tags.js +6 -7
  67. package/dist/primitives/tag/index.d.ts +1 -0
  68. package/dist/primitives/tag/index.js +3 -0
  69. package/dist/primitives/value/Metric.d.ts +7 -2
  70. package/dist/primitives/value/Metric.js +14 -6
  71. package/dist/tokens.css +306 -72
  72. package/package.json +1 -1
@@ -3,7 +3,9 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useUiCopy } from "../../foundations/copy.js";
4
4
  import { buttonClasses, } from "../button/Button.js";
5
5
  import { Popover } from "../overlay/Popover.js";
6
+ import { Count } from "../tag/Count.js";
6
7
  import { Check, ChevronDown, ChevronRight } from "lucide-react";
8
+ import { useState } from "react";
7
9
  import { Autocomplete, Button as AriaButton, Header, Input, Keyboard, Menu as AriaMenu, MenuItem, MenuSection, MenuTrigger, SearchField, Separator, SubmenuTrigger, useFilter, } from "react-aria-components";
8
10
  const WIDTH = {
9
11
  /** A menu of short verbs hanging off an icon: "duplicate", "delete". */
@@ -11,6 +13,17 @@ const WIDTH = {
11
13
  md: "min-w-56 max-w-80",
12
14
  lg: "min-w-80 max-w-(--container-short)",
13
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:";
14
27
  /** A submenu opens beside its row, flush against the parent panel and pulled up by the
15
28
  * panel's padding plus its hairline (`p-1` + 1), so its first row lines up with the row that
16
29
  * opened it — a submenu that starts half a row lower reads as belonging to the next one. */
@@ -34,7 +47,7 @@ export function indexOptions(options, into = new Map()) {
34
47
  * criteria) still has to look like its neighbours; copying these classes is how the third
35
48
  * trigger ends up one pixel off. Same reason `buttonClasses` exists.
36
49
  */
37
- 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, }) {
38
51
  /* `text` is the menu of a BAR: no frame and no background, just the highlight
39
52
  on hover. Five bordered menus on top of an application are five buttons
40
53
  competing with the ones in the view, and the bar stops reading as an index.
@@ -47,30 +60,38 @@ export function menuTriggerClasses({ variant = "button", surface = "canvas", act
47
60
  : surface === "chrome"
48
61
  ? `border-chrome-muted/35 bg-chrome-raised text-chrome-ink hover:border-chrome-accent/45 ${active ? "border-chrome-accent/60" : ""}`
49
62
  : `border-line-strong bg-surface hover:border-primary/45 hover:bg-primary/5 ${active ? "border-primary/60 text-primary" : "text-ink"}`;
50
- 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}`;
51
71
  }
52
72
  export function Menu({ label, groups, onSelect, surface = "canvas", align = "start", icon: Trigger,
53
73
  /** The menu as a control of a list ("filters ▾") carries the chevron; the
54
74
  * actions `⋯` does not, because the icon already says there is more. */
55
- chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, }) {
75
+ chevron = true, active = false, iconOnly = false, variant = "button", searchPlaceholder, emptyText, width = "md", role, size = "md", title, closeOnSelect = true, count, current = false, layout = "list", }) {
56
76
  const copy = useUiCopy();
57
77
  const { contains } = useFilter({ sensitivity: "base" });
58
78
  const byId = indexOptions(groups.flatMap((g) => g.options));
59
- 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) => {
60
80
  const option = byId.get(String(key));
61
81
  option?.onSelect?.();
62
82
  onSelect?.(String(key));
63
83
  }, emptyText: emptyText ?? copy.menu.empty }));
64
- 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
65
85
  ? menuTriggerClasses({
66
86
  variant,
67
87
  surface,
68
88
  active,
89
+ current,
69
90
  open: isPressed,
70
91
  focusVisible: isFocusVisible,
71
92
  iconOnly,
72
93
  })
73
- : `${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, 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) : (
74
95
  /* The search box stays at the top: in a menu of twenty-five entries,
75
96
  scrolling loses exactly the control that explains why only three are
76
97
  visible. It filters on label AND hint — half the entries of this
@@ -83,25 +104,59 @@ chevron = true, active = false, iconOnly = false, variant = "button", searchPlac
83
104
  * submenu is this same panel one level down, and a panel can be rendered on the server
84
105
  * without the trigger's popover, which is how the tests see the rows.
85
106
  */
86
- export function MenuList({ label, groups, onAction, closeOnSelect, emptyText, width = "md", }) {
87
- /* Per panel: a submenu without icons does not inherit its parent's mark column. */
88
- 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));
89
133
  const hasHints = groups.some((g) => g.options.some((o) => o.hint !== undefined));
90
- const row = (o) => {
134
+ const row = (o, nested = false) => {
91
135
  const Icon = o.icon;
92
136
  const opens = o.items !== undefined;
93
137
  const checked = !opens && o.checked === true;
94
- 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 === "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));
95
139
  };
96
- 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 : (
97
- /* Same skeleton as the row: the label sits on the text column. */
98
- _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) => {
99
- 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));
100
- return o.divider === true
101
- ? [
102
- _jsx(Separator, { className: "my-1 h-px border-0 bg-line" }, `${o.id}-divider`),
103
- item,
104
- ]
105
- : [item];
106
- })] }, 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
+ }) }));
107
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
  *
@@ -1,26 +1,8 @@
1
1
  "use client";
2
2
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
3
  import { useUiCopy } from "../../foundations/copy.js";
4
+ import { Count } from "../tag/Count.js";
4
5
  import { createContext, useContext, useId, useRef, } from "react";
5
- /* The notification's colour. Static and in a table because Tailwind cannot
6
- compose a class with a variable piece: `bg-${tone}/12` does not exist in the
7
- stylesheet. */
8
- const NOTICE_TONE = {
9
- neutral: "bg-ink/8 text-muted",
10
- info: "bg-info/12 text-info",
11
- good: "bg-good/12 text-good",
12
- warn: "bg-warn/14 text-warn",
13
- bad: "bg-bad/12 text-bad",
14
- accent: "bg-accent/14 text-accent",
15
- };
16
- const NOTICE_DOT = {
17
- neutral: "bg-muted",
18
- info: "bg-info",
19
- good: "bg-good",
20
- warn: "bg-warn",
21
- bad: "bg-bad",
22
- accent: "bg-accent",
23
- };
24
6
  /**
25
7
  * The strip only: what each tab opens is drawn by whoever uses it (`Record`, `Activity`).
26
8
  *
@@ -89,7 +71,6 @@ export function Tabs({ tabs, current, onSelect, label, }) {
89
71
  };
90
72
  return (_jsx("div", { ref: strip, role: "tablist", "aria-label": label ?? copy.record.faces, onKeyDown: onKeyDown, className: "flex min-w-0 flex-wrap items-end gap-1", children: tabs.map((a) => {
91
73
  const Icon = a.icon;
92
- const empty = a.count === 0;
93
74
  /* A zero asks for nothing, so it is not drawn. That is the difference from the
94
75
  counter, where «0» is an answer. */
95
76
  const notice = a.notice?.count === 0 ? undefined : a.notice;
@@ -98,13 +79,6 @@ export function Tabs({ tabs, current, onSelect, label, }) {
98
79
  ? {}
99
80
  : { id: tabIdOf(base, a.id), "aria-controls": panelIdOf(base, a.id) }), onClick: () => onSelect?.(a.id), className: `inline-flex shrink-0 cursor-default items-center px-3 py-2 text-meta outline-0 transition-colors duration-(--duration-instant) focus-visible:outline-2 focus-visible:-outline-offset-2 focus-visible:outline-primary ${isSelected
100
81
  ? "-mb-px rounded-t-control border border-b-0 border-line-strong bg-surface font-medium text-ink"
101
- : "border border-transparent text-muted hover:text-ink"}`, children: _jsxs("span", { className: "inline-flex items-center gap-1.5", ...(notice === undefined ? {} : { title: notice.label }), children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-sm) shrink-0 ${isSelected ? "text-ink" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), a.label, a.count === undefined ? null : (_jsx("span", { className: `rounded-pill px-1.5 text-micro tabular-nums ${empty
102
- ? "bg-ink/5 text-muted"
103
- : isSelected
104
- ? "bg-ink/8 text-ink"
105
- : "bg-ink/8 text-muted"}`, children: a.count.toLocaleString(copy.locale) })), notice === undefined ? null : (_jsx("span", { className: "sr-only", children: ` · ${notice.label}` })), notice === undefined ? null : notice.count === undefined ? (
106
- /* Without a number, a dot. The word is not drawn but it is there: in the
107
- `title` and in the tab's accessible name. */
108
- _jsx("span", { className: `size-1.5 shrink-0 rounded-pill ${NOTICE_DOT[notice.tone ?? "bad"]}`, "aria-hidden": true })) : (_jsx("span", { className: `rounded-pill px-1.5 text-micro font-medium tabular-nums ${NOTICE_TONE[notice.tone ?? "bad"]}`, "aria-hidden": true, children: notice.count.toLocaleString(copy.locale) }))] }) }, a.id));
82
+ : "border border-transparent text-muted hover:text-ink"}`, children: _jsxs("span", { className: "inline-flex items-center gap-1.5", ...(notice === undefined ? {} : { title: notice.label }), children: [Icon === undefined ? null : (_jsx(Icon, { className: `size-(--size-icon-sm) shrink-0 ${isSelected ? "text-ink" : "text-muted"}`, strokeWidth: 2, "aria-hidden": true })), a.label, a.count === undefined ? null : (_jsx(Count, { value: a.count, showZero: true, current: isSelected })), notice === undefined ? null : (_jsx("span", { className: "sr-only", children: ` · ${notice.label}` })), notice === undefined ? null : (_jsx(Count, { ...(notice.count === undefined ? {} : { value: notice.count }), tone: notice.tone ?? "bad", "aria-hidden": true }))] }) }, a.id));
109
83
  }) }));
110
84
  }
@@ -0,0 +1,23 @@
1
+ import type { Surface, Tone } from "../../foundations/types.js";
2
+ export type CountProps = {
3
+ /** How many. Without it the count is a dot: something is there, not counted. */
4
+ value?: number;
5
+ /** `neutral` counts; any other tone says that something asks for attention. */
6
+ tone?: Tone;
7
+ /** Filled: the badge over an icon (a bell, a cart), which has to read on its own. */
8
+ solid?: boolean;
9
+ /** Past this it reads «99+». Without it every number is written in full. */
10
+ max?: number;
11
+ /** Draw the zero, fainter: where «0» is an answer and not noise (a tab). */
12
+ showZero?: boolean;
13
+ /** The thing it counts is the current one — the count takes its host's colour. */
14
+ current?: boolean;
15
+ surface?: Surface;
16
+ /** When the host already says the number in its name (`aria-label`), the count is only
17
+ * seen: hidden from assistive technology so it is not read twice. */
18
+ "aria-hidden"?: boolean;
19
+ };
20
+ /** The text of a count: formatted for the locale, and «99+» past `max`. Exported for the
21
+ * hosts that also need it in words — a button's `aria-label`, a `title`. */
22
+ export declare function countText(value: number, format: (n: number) => string, max?: number): string;
23
+ export declare function Count({ value, tone, solid, max, showZero, current, surface, "aria-hidden": hidden, }: CountProps): import("react").JSX.Element | null;
@@ -0,0 +1,59 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { useUiCopy } from "../../foundations/copy.js";
4
+ import { useSurface } from "../../foundations/surface.js";
5
+ import { useMemo } from "react";
6
+ /* Static and in a table: Tailwind cannot compose `bg-${tone}/12`. The gold is never text on
7
+ the canvas (2.43:1), so there its count is ink on a gold wash — the same rule as `Tag`. */
8
+ const SOFT = {
9
+ neutral: { canvas: "bg-ink/8 text-muted", chrome: "bg-chrome-ink/10 text-chrome-muted" },
10
+ info: { canvas: "bg-info/12 text-info", chrome: "bg-chrome-link/15 text-chrome-link" },
11
+ good: { canvas: "bg-good/12 text-good", chrome: "bg-chrome-good/15 text-chrome-good" },
12
+ warn: { canvas: "bg-warn/14 text-warn", chrome: "bg-chrome-warn/15 text-chrome-warn" },
13
+ bad: { canvas: "bg-bad/12 text-bad", chrome: "bg-chrome-bad/15 text-chrome-bad" },
14
+ accent: {
15
+ canvas: "bg-accent/20 text-ink",
16
+ chrome: "bg-chrome-accent/15 text-chrome-accent",
17
+ },
18
+ };
19
+ const SOLID = {
20
+ neutral: { canvas: "bg-ink text-surface", chrome: "bg-chrome-ink text-chrome" },
21
+ info: { canvas: "bg-info text-surface", chrome: "bg-chrome-link text-chrome" },
22
+ good: { canvas: "bg-good text-surface", chrome: "bg-chrome-good text-chrome" },
23
+ warn: { canvas: "bg-warn text-surface", chrome: "bg-chrome-warn text-chrome" },
24
+ bad: { canvas: "bg-bad text-surface", chrome: "bg-chrome-bad text-chrome" },
25
+ accent: { canvas: "bg-accent text-on-accent", chrome: "bg-chrome-accent text-chrome" },
26
+ };
27
+ const DOT = {
28
+ neutral: { canvas: "bg-muted", chrome: "bg-chrome-muted" },
29
+ info: { canvas: "bg-info", chrome: "bg-chrome-link" },
30
+ good: { canvas: "bg-good", chrome: "bg-chrome-good" },
31
+ warn: { canvas: "bg-warn", chrome: "bg-chrome-warn" },
32
+ bad: { canvas: "bg-bad", chrome: "bg-chrome-bad" },
33
+ accent: { canvas: "bg-accent", chrome: "bg-chrome-accent" },
34
+ };
35
+ /** The text of a count: formatted for the locale, and «99+» past `max`. Exported for the
36
+ * hosts that also need it in words — a button's `aria-label`, a `title`. */
37
+ export function countText(value, format, max) {
38
+ return max !== undefined && value > max ? `${format(max)}+` : format(value);
39
+ }
40
+ function skinOf(tone, surface, { solid, current, zero }) {
41
+ if (solid)
42
+ return SOLID[tone][surface];
43
+ if (zero)
44
+ return surface === "chrome" ? "bg-chrome-ink/6 text-chrome-muted" : "bg-ink/5 text-muted";
45
+ if (current && tone === "neutral")
46
+ return "bg-current/12 text-current";
47
+ return SOFT[tone][surface];
48
+ }
49
+ export function Count({ value, tone = "neutral", solid = false, max, showZero = false, current = false, surface, "aria-hidden": hidden, }) {
50
+ const copy = useUiCopy();
51
+ const sup = useSurface(surface);
52
+ const number = useMemo(() => new Intl.NumberFormat(copy.locale), [copy.locale]);
53
+ if (value === undefined) {
54
+ return (_jsx("span", { "data-count": "dot", className: `inline-block size-1.5 shrink-0 rounded-pill ${DOT[tone][sup]}`, "aria-hidden": true }));
55
+ }
56
+ if (value <= 0 && !showZero)
57
+ return null;
58
+ return (_jsx("span", { "data-count": value, ...(hidden === true ? { "aria-hidden": true } : {}), className: `inline-flex min-w-4 shrink-0 items-center justify-center rounded-pill text-micro tabular-nums ${solid ? "px-1 leading-none font-semibold" : "px-1.5 leading-normal font-medium"} ${skinOf(tone, sup, { solid, current, zero: value <= 0 })}`, children: countText(value, number.format, max) }));
59
+ }
@@ -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;
@@ -1,2 +1,3 @@
1
1
  export { StatusDot, Tag } from "./Tag.js";
2
+ export { Count, type CountProps, countText } from "./Count.js";
2
3
  export { type TagItem, Tags } from "./Tags.js";
@@ -1,5 +1,8 @@
1
1
  /* Saying a state without writing a sentence: the capsule and the dot. */
2
2
  export { StatusDot, Tag } from "./Tag.js";
3
+ /* How many things are behind something, or that something asks for: one counter for the
4
+ sidebar, the tabs, the systray, a menu and an application's own button. */
5
+ export { Count, countText } from "./Count.js";
3
6
  /* The strip of chips: the same in the bar, in the dropdown and anywhere
4
7
  a list of short words is drawn. */
5
8
  export { Tags } from "./Tags.js";
@@ -25,8 +25,13 @@ import { type LucideIcon } from "lucide-react";
25
25
  * the NUMBER.
26
26
  */
27
27
  export type MetricProps = {
28
- value: number | string;
28
+ /** The figure. Without it — and not `loading` — it reads «—»: not counted, which is not
29
+ * zero. */
30
+ value?: number | string;
29
31
  label: string;
32
+ /** The figure is being read. The label stays and the box keeps its size, so a row of
33
+ * metrics does not jump when the numbers land one at a time. */
34
+ loading?: boolean;
30
35
  tone?: Tone;
31
36
  icon?: LucideIcon;
32
37
  /** Present = narrows the list. Absent = only informs, and doesn't get pressed. */
@@ -45,7 +50,7 @@ export type MetricProps = {
45
50
  better?: "up" | "down";
46
51
  };
47
52
  };
48
- export declare function Metric({ value, label, tone, icon: Icon, onClick, active, change, }: MetricProps): import("react").JSX.Element;
53
+ export declare function Metric({ value, label, tone, icon: Icon, onClick, active, change, loading, }: MetricProps): import("react").JSX.Element;
49
54
  /** The row of metrics. It wraps if they don't fit; it doesn't scroll: a hidden
50
55
  * metric is a filter nobody finds. */
51
56
  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, }) {
17
+ export function Metric({ value, label, 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,15 +28,23 @@ 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
- 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 })), typeof value === "number" ? value.toLocaleString(copy.locale) : value] }), _jsx("span", { className: `text-micro ${bySurface(sup, "text-muted", "text-chrome-muted")}`, children: label }), change === undefined ? null : _jsx(Change, { change: change, format: percent.format })] }));
35
+ const figure = value === undefined
36
+ ? "—"
37
+ : typeof value === "number"
38
+ ? value.toLocaleString(copy.locale)
39
+ : value;
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
+ /* A bar one line of the figure tall (`h-lh`), so the box is the size it will
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 }))] }));
36
44
  if (onClick === undefined) {
37
- return (_jsx("div", { className: box, "aria-label": `${value} ${label}`, children: content }));
45
+ return (_jsx("div", { "data-ui": "metric", className: box, "aria-label": loading ? `${label}: ${copy.failed.loading}` : `${figure} ${label}`, ...(loading ? { "aria-busy": true } : {}), children: content }));
38
46
  }
39
- return (_jsx("button", { type: "button", onClick: onClick, "aria-pressed": active, className: box, children: content }));
47
+ 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] }));
40
48
  }
41
49
  function Change({ change, format, }) {
42
50
  const copy = useUiCopy();