@underpin/ui 0.0.0 → 2.1.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 (277) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -1
  3. package/components/autocomplete.d.ts +25 -0
  4. package/components/autocomplete.js +71 -0
  5. package/components/autocomplete.js.map +1 -0
  6. package/components/avatar.d.ts +5 -0
  7. package/components/avatar.js +26 -0
  8. package/components/avatar.js.map +1 -0
  9. package/components/badge.d.ts +36 -0
  10. package/components/badge.js +140 -0
  11. package/components/badge.js.map +1 -0
  12. package/components/bar-list.d.ts +133 -0
  13. package/components/bar-list.js +204 -0
  14. package/components/bar-list.js.map +1 -0
  15. package/components/breakdown-card.d.ts +30 -0
  16. package/components/breakdown-card.js +43 -0
  17. package/components/breakdown-card.js.map +1 -0
  18. package/components/bulk-action-bar.d.ts +21 -0
  19. package/components/bulk-action-bar.js +38 -0
  20. package/components/bulk-action-bar.js.map +1 -0
  21. package/components/button-group.d.ts +21 -0
  22. package/components/button-group.js +32 -0
  23. package/components/button-group.js.map +1 -0
  24. package/components/button.d.ts +39 -0
  25. package/components/button.js +145 -0
  26. package/components/button.js.map +1 -0
  27. package/components/calendar.d.ts +27 -0
  28. package/components/calendar.js +95 -0
  29. package/components/calendar.js.map +1 -0
  30. package/components/callout.d.ts +26 -0
  31. package/components/callout.js +71 -0
  32. package/components/callout.js.map +1 -0
  33. package/components/card.d.ts +55 -0
  34. package/components/card.js +96 -0
  35. package/components/card.js.map +1 -0
  36. package/components/chart.d.ts +32 -0
  37. package/components/chart.js +43 -0
  38. package/components/chart.js.map +1 -0
  39. package/components/checkbox.d.ts +15 -0
  40. package/components/checkbox.js +42 -0
  41. package/components/checkbox.js.map +1 -0
  42. package/components/code-block.d.ts +21 -0
  43. package/components/code-block.js +35 -0
  44. package/components/code-block.js.map +1 -0
  45. package/components/collapse.d.ts +14 -0
  46. package/components/collapse.js +25 -0
  47. package/components/collapse.js.map +1 -0
  48. package/components/combobox.d.ts +71 -0
  49. package/components/combobox.js +155 -0
  50. package/components/combobox.js.map +1 -0
  51. package/components/copy-button.d.ts +29 -0
  52. package/components/copy-button.js +100 -0
  53. package/components/copy-button.js.map +1 -0
  54. package/components/copy-input.d.ts +15 -0
  55. package/components/copy-input.js +51 -0
  56. package/components/copy-input.js.map +1 -0
  57. package/components/data-table.d.ts +120 -0
  58. package/components/data-table.js +336 -0
  59. package/components/data-table.js.map +1 -0
  60. package/components/date-picker-trigger.d.ts +12 -0
  61. package/components/date-picker-trigger.js +30 -0
  62. package/components/date-picker-trigger.js.map +1 -0
  63. package/components/date-picker.d.ts +36 -0
  64. package/components/date-picker.js +70 -0
  65. package/components/date-picker.js.map +1 -0
  66. package/components/detail-row.d.ts +51 -0
  67. package/components/detail-row.js +77 -0
  68. package/components/detail-row.js.map +1 -0
  69. package/components/dialog.d.ts +121 -0
  70. package/components/dialog.js +327 -0
  71. package/components/dialog.js.map +1 -0
  72. package/components/disabled-reason.d.ts +31 -0
  73. package/components/disabled-reason.js +67 -0
  74. package/components/disabled-reason.js.map +1 -0
  75. package/components/empty-state.d.ts +41 -0
  76. package/components/empty-state.js +84 -0
  77. package/components/empty-state.js.map +1 -0
  78. package/components/entity-avatar.d.ts +54 -0
  79. package/components/entity-avatar.js +68 -0
  80. package/components/entity-avatar.js.map +1 -0
  81. package/components/form-section.d.ts +22 -0
  82. package/components/form-section.js +38 -0
  83. package/components/form-section.js.map +1 -0
  84. package/components/form.d.ts +199 -0
  85. package/components/form.js +456 -0
  86. package/components/form.js.map +1 -0
  87. package/components/formatted-number.d.ts +21 -0
  88. package/components/formatted-number.js +13 -0
  89. package/components/formatted-number.js.map +1 -0
  90. package/components/heading.d.ts +23 -0
  91. package/components/heading.js +44 -0
  92. package/components/heading.js.map +1 -0
  93. package/components/icon-swap.d.ts +15 -0
  94. package/components/icon-swap.js +29 -0
  95. package/components/icon-swap.js.map +1 -0
  96. package/components/inline-action.d.ts +21 -0
  97. package/components/inline-action.js +36 -0
  98. package/components/inline-action.js.map +1 -0
  99. package/components/input.d.ts +51 -0
  100. package/components/input.js +52 -0
  101. package/components/input.js.map +1 -0
  102. package/components/kbd.d.ts +17 -0
  103. package/components/kbd.js +34 -0
  104. package/components/kbd.js.map +1 -0
  105. package/components/label.d.ts +10 -0
  106. package/components/label.js +20 -0
  107. package/components/label.js.map +1 -0
  108. package/components/menu.d.ts +77 -0
  109. package/components/menu.js +189 -0
  110. package/components/menu.js.map +1 -0
  111. package/components/nav-button.d.ts +34 -0
  112. package/components/nav-button.js +71 -0
  113. package/components/nav-button.js.map +1 -0
  114. package/components/nav.d.ts +39 -0
  115. package/components/nav.js +68 -0
  116. package/components/nav.js.map +1 -0
  117. package/components/number-input.d.ts +16 -0
  118. package/components/number-input.js +25 -0
  119. package/components/number-input.js.map +1 -0
  120. package/components/page.d.ts +14 -0
  121. package/components/page.js +23 -0
  122. package/components/page.js.map +1 -0
  123. package/components/pagination.d.ts +73 -0
  124. package/components/pagination.js +212 -0
  125. package/components/pagination.js.map +1 -0
  126. package/components/ping.d.ts +38 -0
  127. package/components/ping.js +50 -0
  128. package/components/ping.js.map +1 -0
  129. package/components/popover.d.ts +5 -0
  130. package/components/popover.js +25 -0
  131. package/components/popover.js.map +1 -0
  132. package/components/radio-group.d.ts +35 -0
  133. package/components/radio-group.js +81 -0
  134. package/components/radio-group.js.map +1 -0
  135. package/components/relative-time.d.ts +25 -0
  136. package/components/relative-time.js +51 -0
  137. package/components/relative-time.js.map +1 -0
  138. package/components/saved-mark.d.ts +15 -0
  139. package/components/saved-mark.js +45 -0
  140. package/components/saved-mark.js.map +1 -0
  141. package/components/search-input.d.ts +13 -0
  142. package/components/search-input.js +44 -0
  143. package/components/search-input.js.map +1 -0
  144. package/components/section-header.d.ts +83 -0
  145. package/components/section-header.js +170 -0
  146. package/components/section-header.js.map +1 -0
  147. package/components/segmented-control.d.ts +24 -0
  148. package/components/segmented-control.js +70 -0
  149. package/components/segmented-control.js.map +1 -0
  150. package/components/select.d.ts +28 -0
  151. package/components/select.js +129 -0
  152. package/components/select.js.map +1 -0
  153. package/components/shortcut-keys.d.ts +14 -0
  154. package/components/shortcut-keys.js +32 -0
  155. package/components/shortcut-keys.js.map +1 -0
  156. package/components/shortcuts-dialog.d.ts +10 -0
  157. package/components/shortcuts-dialog.js +92 -0
  158. package/components/shortcuts-dialog.js.map +1 -0
  159. package/components/skeleton.d.ts +8 -0
  160. package/components/skeleton.js +23 -0
  161. package/components/skeleton.js.map +1 -0
  162. package/components/sparkline.d.ts +25 -0
  163. package/components/sparkline.js +70 -0
  164. package/components/sparkline.js.map +1 -0
  165. package/components/stack.d.ts +21 -0
  166. package/components/stack.js +45 -0
  167. package/components/stack.js.map +1 -0
  168. package/components/stat-strip.d.ts +43 -0
  169. package/components/stat-strip.js +151 -0
  170. package/components/stat-strip.js.map +1 -0
  171. package/components/steps.d.ts +19 -0
  172. package/components/steps.js +25 -0
  173. package/components/steps.js.map +1 -0
  174. package/components/switch.d.ts +16 -0
  175. package/components/switch.js +29 -0
  176. package/components/switch.js.map +1 -0
  177. package/components/table-toolbar.d.ts +55 -0
  178. package/components/table-toolbar.js +119 -0
  179. package/components/table-toolbar.js.map +1 -0
  180. package/components/table.d.ts +276 -0
  181. package/components/table.js +572 -0
  182. package/components/table.js.map +1 -0
  183. package/components/tabs.d.ts +36 -0
  184. package/components/tabs.js +120 -0
  185. package/components/tabs.js.map +1 -0
  186. package/components/text-link.d.ts +16 -0
  187. package/components/text-link.js +32 -0
  188. package/components/text-link.js.map +1 -0
  189. package/components/textarea.d.ts +10 -0
  190. package/components/textarea.js +23 -0
  191. package/components/textarea.js.map +1 -0
  192. package/components/theme.d.ts +28 -0
  193. package/components/theme.js +158 -0
  194. package/components/theme.js.map +1 -0
  195. package/components/time-series-chart.d.ts +122 -0
  196. package/components/time-series-chart.js +722 -0
  197. package/components/time-series-chart.js.map +1 -0
  198. package/components/toaster.d.ts +3 -0
  199. package/components/toaster.js +44 -0
  200. package/components/toaster.js.map +1 -0
  201. package/components/tooltip.d.ts +64 -0
  202. package/components/tooltip.js +126 -0
  203. package/components/tooltip.js.map +1 -0
  204. package/components/view-picker.d.ts +20 -0
  205. package/components/view-picker.js +24 -0
  206. package/components/view-picker.js.map +1 -0
  207. package/fonts/inter-OFL.txt +93 -0
  208. package/fonts/inter-cyrillic-ext.woff2 +0 -0
  209. package/fonts/inter-cyrillic.woff2 +0 -0
  210. package/fonts/inter-greek-ext.woff2 +0 -0
  211. package/fonts/inter-greek.woff2 +0 -0
  212. package/fonts/inter-latin-ext.woff2 +0 -0
  213. package/fonts/inter-latin.woff2 +0 -0
  214. package/fonts/inter-vietnamese.woff2 +0 -0
  215. package/fonts.css +83 -0
  216. package/lib/animation.d.ts +14 -0
  217. package/lib/animation.js +20 -0
  218. package/lib/animation.js.map +1 -0
  219. package/lib/aria.d.ts +5 -0
  220. package/lib/aria.js +12 -0
  221. package/lib/aria.js.map +1 -0
  222. package/lib/chart-curve.d.ts +13 -0
  223. package/lib/chart-curve.js +79 -0
  224. package/lib/chart-curve.js.map +1 -0
  225. package/lib/classes.d.ts +134 -0
  226. package/lib/classes.js +152 -0
  227. package/lib/classes.js.map +1 -0
  228. package/lib/color.d.ts +25 -0
  229. package/lib/color.js +149 -0
  230. package/lib/color.js.map +1 -0
  231. package/lib/data-table-state.d.ts +87 -0
  232. package/lib/data-table-state.js +92 -0
  233. package/lib/data-table-state.js.map +1 -0
  234. package/lib/day.d.ts +9 -0
  235. package/lib/day.js +20 -0
  236. package/lib/day.js.map +1 -0
  237. package/lib/design-tokens.d.ts +56 -0
  238. package/lib/design-tokens.js +196 -0
  239. package/lib/design-tokens.js.map +1 -0
  240. package/lib/icon.d.ts +17 -0
  241. package/lib/icon.js +34 -0
  242. package/lib/icon.js.map +1 -0
  243. package/lib/icons.d.ts +29 -0
  244. package/lib/icons.js +34 -0
  245. package/lib/icons.js.map +1 -0
  246. package/lib/interactive.d.ts +21 -0
  247. package/lib/interactive.js +31 -0
  248. package/lib/interactive.js.map +1 -0
  249. package/lib/load-more.d.ts +14 -0
  250. package/lib/load-more.js +27 -0
  251. package/lib/load-more.js.map +1 -0
  252. package/lib/media.d.ts +58 -0
  253. package/lib/media.js +116 -0
  254. package/lib/media.js.map +1 -0
  255. package/lib/segmented.d.ts +57 -0
  256. package/lib/segmented.js +83 -0
  257. package/lib/segmented.js.map +1 -0
  258. package/lib/shortcuts.d.ts +94 -0
  259. package/lib/shortcuts.js +271 -0
  260. package/lib/shortcuts.js.map +1 -0
  261. package/lib/slot.d.ts +9 -0
  262. package/lib/slot.js +18 -0
  263. package/lib/slot.js.map +1 -0
  264. package/lib/time-series.d.ts +100 -0
  265. package/lib/time-series.js +144 -0
  266. package/lib/time-series.js.map +1 -0
  267. package/lib/tone.d.ts +6 -0
  268. package/lib/tone.js +0 -0
  269. package/lib/variants.d.ts +12 -0
  270. package/lib/variants.js +14 -0
  271. package/lib/variants.js.map +1 -0
  272. package/package.json +122 -3
  273. package/styles.css +630 -0
  274. package/tokens.d.ts +104 -0
  275. package/tokens.js +108 -0
  276. package/tokens.js.map +1 -0
  277. package/publish.log +0 -1
@@ -0,0 +1,204 @@
1
+ import { ArrowUpRightIcon } from "../lib/icons.js";
2
+ import { cn } from "../lib/variants.js";
3
+ import { FormattedNumber } from "./formatted-number.js";
4
+ import { Skeleton } from "./skeleton.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/bar-list.tsx
7
+ /**
8
+ * Ranked breakdown list: each row is a label sitting on a soft bar whose width is the row's
9
+ * share of the largest value, measured across the whole row, with the figures right-aligned
10
+ * beside it. It is a real `<table>` on auto layout, so every figure column is exactly as wide
11
+ * as its own widest cell (its column name included) rather than every column sharing one
12
+ * width cut to fit the longest name. Compose it as `BarList` → `BarList.Header` +
13
+ * `BarList.Body` (or `BarList.Skeleton`), so the names and the figures share the columns.
14
+ *
15
+ * A row that links out carries its `href` on the arrow beside the label; a row-sized click
16
+ * target (click-to-filter) goes in the row's `overlay`, since a `<tr>` can be neither.
17
+ *
18
+ * The bar and the overlay span the row but hang off the label cell, not the `<tr>`: Safari
19
+ * never made a positioned table row a containing block (WebKit 240961), so anything absolute
20
+ * inside one lands on the nearest positioned ancestor outside the table (the card), and every
21
+ * row's bar ran the card's full height and painted over the rows above it. A cell is honoured
22
+ * everywhere, and the wrapper is a container so `100cqw` is the table's width, which is what
23
+ * a share of the row measures against.
24
+ */
25
+ function BarListRoot({ className, ...props }) {
26
+ return /* @__PURE__ */ jsx("div", {
27
+ className: cn("@container -mx-2 -my-1", className),
28
+ children: /* @__PURE__ */ jsx("table", {
29
+ className: "w-full border-separate border-spacing-y-1",
30
+ ...props
31
+ })
32
+ });
33
+ }
34
+ /**
35
+ * The label column takes every pixel the figure columns leave (`w-full`) and may shrink below
36
+ * its own text (`max-w-0`), so a long name truncates instead of widening the table. It is the
37
+ * positioned box the bar and the overlay are laid out against (see `BarListRoot`).
38
+ */
39
+ const labelCellClasses = "relative w-full max-w-0 pl-2";
40
+ /** Laid out from the label cell's left edge across the whole row, whatever the column count. */
41
+ const rowSpanClasses = "absolute inset-y-0 left-0 w-[100cqw]";
42
+ /**
43
+ * The gutter before a figure column. Content-sized columns sit as close as their own digits
44
+ * allow, so the gutter is what keeps four of them from reading as one number.
45
+ */
46
+ const figureGutter = "pl-4";
47
+ /**
48
+ * A figure column is at least 64px, so the columns of two cards side by side line up, and
49
+ * grows with its contents past that. `relative` lifts the figure over the bar, which reaches
50
+ * across from the label cell; that also puts it above a row-sized `overlay`, which is why the
51
+ * overlay carries a z-index.
52
+ */
53
+ const figureCellClasses = cn(figureGutter, "relative min-w-16 text-right whitespace-nowrap tabular-nums");
54
+ /** The rightmost column carries the row's padding at the end of the row. */
55
+ const lastCellClasses = "pr-2";
56
+ function BarListRow({ label, name, icon, value, max, share: shareOverride, format, secondaryValue, secondaryFormat, secondaryClassName, extras, href, overlay, className, style, ...props }) {
57
+ const share = Math.min(Math.max(shareOverride ?? (max > 0 ? value / max : 0), 0), 1);
58
+ return /* @__PURE__ */ jsxs("tr", {
59
+ className: cn("group/bar h-7.5 text-start text-sm", className),
60
+ style: {
61
+ "--bar-share": share,
62
+ ...style
63
+ },
64
+ ...props,
65
+ children: [
66
+ /* @__PURE__ */ jsxs("td", {
67
+ className: labelCellClasses,
68
+ children: [
69
+ /* @__PURE__ */ jsx("div", {
70
+ "aria-hidden": true,
71
+ "data-bar": true,
72
+ className: "absolute inset-y-0 left-0 w-[100cqw] bg-fill-subtle transition-[clip-path] duration-250 ease-out-expo [clip-path:inset(0_calc(100%-max(var(--bar-share)*100%,0.375rem))_0_0_round_var(--radius-md))]"
73
+ }),
74
+ /* @__PURE__ */ jsxs("div", {
75
+ className: "relative flex items-center gap-2",
76
+ children: [
77
+ icon && /* @__PURE__ */ jsx("span", {
78
+ className: "flex size-4 shrink-0 items-center justify-center",
79
+ children: icon
80
+ }),
81
+ /* @__PURE__ */ jsx("span", {
82
+ title: name ?? (typeof label === "string" ? label : void 0),
83
+ className: "min-w-0 truncate",
84
+ children: label
85
+ }),
86
+ href && /* @__PURE__ */ jsx("a", {
87
+ href,
88
+ target: "_blank",
89
+ rel: "noreferrer",
90
+ "data-row-link": true,
91
+ "aria-label": `Open ${name ?? (typeof label === "string" ? label : "this row")} in a new tab`,
92
+ className: "relative z-10 -ml-[3px] flex size-5 shrink-0 items-center justify-center rounded-sm text-ink-muted hover:text-ink pointer-coarse:-mx-1 pointer-coarse:size-7",
93
+ children: /* @__PURE__ */ jsx(ArrowUpRightIcon, { className: "size-3.5" })
94
+ })
95
+ ]
96
+ }),
97
+ overlay
98
+ ]
99
+ }),
100
+ secondaryValue !== void 0 && /* @__PURE__ */ jsx("td", {
101
+ className: cn(figureCellClasses, "text-ink-muted", secondaryClassName),
102
+ children: /* @__PURE__ */ jsx(FormattedNumber, {
103
+ value: secondaryValue,
104
+ format: secondaryFormat
105
+ })
106
+ }),
107
+ extras?.map((extra, index) => /* @__PURE__ */ jsx("td", {
108
+ className: cn(figureCellClasses, "text-ink-muted", extra.className),
109
+ children: extra.value
110
+ }, index)),
111
+ /* @__PURE__ */ jsx("td", {
112
+ className: cn(figureCellClasses, lastCellClasses, "font-medium text-ink-muted"),
113
+ children: /* @__PURE__ */ jsx(FormattedNumber, {
114
+ value,
115
+ format
116
+ })
117
+ })
118
+ ]
119
+ });
120
+ }
121
+ /**
122
+ * Holds the `BarList.Row`s, next to the `BarList.Header` that names their columns.
123
+ */
124
+ function BarListBody(props) {
125
+ return /* @__PURE__ */ jsx("tbody", { ...props });
126
+ }
127
+ /**
128
+ * Column names over a `BarList`, in the rows' own columns: the table lines them up, and each
129
+ * name is free to be as wide as it needs. Keep it inside the same `BarList` as whatever swaps
130
+ * the rows for their skeleton, and the card keeps one height across loading and loaded; drop
131
+ * the whole table for an empty or error state, or the names stand over nothing.
132
+ */
133
+ function BarListHeader({ extras, secondary, value, sticky, className, ...props }) {
134
+ const stickyClasses = sticky && "sticky top-0 z-20 bg-surface";
135
+ const cellClasses = cn(figureGutter, "pb-2 text-right font-normal whitespace-nowrap", stickyClasses);
136
+ return /* @__PURE__ */ jsx("thead", {
137
+ className: cn("text-ink-muted text-xs", className),
138
+ ...props,
139
+ children: /* @__PURE__ */ jsxs("tr", { children: [
140
+ /* @__PURE__ */ jsx("td", { className: cn(labelCellClasses, stickyClasses) }),
141
+ secondary !== void 0 && /* @__PURE__ */ jsx("th", {
142
+ className: cellClasses,
143
+ children: secondary
144
+ }),
145
+ extras?.map((extra, index) => /* @__PURE__ */ jsx("th", {
146
+ className: cn(cellClasses, extra.className),
147
+ children: extra.label
148
+ }, index)),
149
+ /* @__PURE__ */ jsx("th", {
150
+ className: cn(cellClasses, lastCellClasses),
151
+ children: value
152
+ })
153
+ ] })
154
+ });
155
+ }
156
+ /**
157
+ * Label bars step down like a ranked list would, so the swap to data reads as a fill-in
158
+ * rather than a reflow.
159
+ */
160
+ const skeletonShares = [
161
+ "70cqw",
162
+ "55cqw",
163
+ "45cqw",
164
+ "35cqw",
165
+ "30cqw"
166
+ ];
167
+ /**
168
+ * Loading stand-in at the exact row height of `BarList.Row`, so swapping in data causes no
169
+ * layout shift. Its bars take `Skeleton`'s own fill, a step darker than a row's, so the pulse
170
+ * still reads on a card.
171
+ */
172
+ function BarListSkeleton({ rows = 5, columns = 2, className, ...props }) {
173
+ return /* @__PURE__ */ jsx("tbody", {
174
+ "aria-hidden": true,
175
+ className,
176
+ ...props,
177
+ children: Array.from({ length: rows }, (_, index) => /* @__PURE__ */ jsxs("tr", {
178
+ className: "h-7.5",
179
+ children: [
180
+ /* @__PURE__ */ jsx("td", {
181
+ className: labelCellClasses,
182
+ children: /* @__PURE__ */ jsx(Skeleton, {
183
+ className: "absolute inset-y-0 left-0",
184
+ style: { width: skeletonShares[index % skeletonShares.length] }
185
+ })
186
+ }),
187
+ Array.from({ length: Math.max(columns - 2, 0) }, (_, column) => /* @__PURE__ */ jsx("td", { "aria-hidden": true }, column)),
188
+ columns > 1 && /* @__PURE__ */ jsx("td", {
189
+ className: cn(figureCellClasses, lastCellClasses),
190
+ children: /* @__PURE__ */ jsx(Skeleton, { className: "ml-auto h-3.5 w-8" })
191
+ })
192
+ ]
193
+ }, index))
194
+ });
195
+ }
196
+ const BarList = Object.assign(BarListRoot, {
197
+ Row: BarListRow,
198
+ Body: BarListBody,
199
+ Header: BarListHeader,
200
+ Skeleton: BarListSkeleton
201
+ });
202
+ export { BarList, rowSpanClasses };
203
+
204
+ //# sourceMappingURL=bar-list.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bar-list.js","names":[],"sources":["../../src/components/bar-list.tsx"],"sourcesContent":["import type { ComponentProps, CSSProperties, ReactNode } from \"react\"\nimport { ArrowUpRightIcon } from \"../lib/icons\"\nimport { cn } from \"../lib/variants\"\nimport { FormattedNumber, type NumberFormat } from \"./formatted-number\"\nimport { Skeleton } from \"./skeleton\"\n\n/**\n * Ranked breakdown list: each row is a label sitting on a soft bar whose width is the row's\n * share of the largest value, measured across the whole row, with the figures right-aligned\n * beside it. It is a real `<table>` on auto layout, so every figure column is exactly as wide\n * as its own widest cell (its column name included) rather than every column sharing one\n * width cut to fit the longest name. Compose it as `BarList` → `BarList.Header` +\n * `BarList.Body` (or `BarList.Skeleton`), so the names and the figures share the columns.\n *\n * A row that links out carries its `href` on the arrow beside the label; a row-sized click\n * target (click-to-filter) goes in the row's `overlay`, since a `<tr>` can be neither.\n *\n * The bar and the overlay span the row but hang off the label cell, not the `<tr>`: Safari\n * never made a positioned table row a containing block (WebKit 240961), so anything absolute\n * inside one lands on the nearest positioned ancestor outside the table (the card), and every\n * row's bar ran the card's full height and painted over the rows above it. A cell is honoured\n * everywhere, and the wrapper is a container so `100cqw` is the table's width, which is what\n * a share of the row measures against.\n */\nfunction BarListRoot({ className, ...props }: ComponentProps<\"table\">) {\n return (\n // `border-spacing-y` is the row gap; it also pads the table's top and bottom edge, which\n // `-my-1` takes back. `-mx-2` is the row's own cell padding, so the text sits on the\n // parent's inset and the bar bleeds 8px past it. The margins ride the wrapper: a container\n // is its own formatting context, so a margin on the table would not collapse through it.\n <div className={cn(\"@container -mx-2 -my-1\", className)}>\n <table className=\"w-full border-separate border-spacing-y-1\" {...props} />\n </div>\n )\n}\n\n/**\n * The label column takes every pixel the figure columns leave (`w-full`) and may shrink below\n * its own text (`max-w-0`), so a long name truncates instead of widening the table. It is the\n * positioned box the bar and the overlay are laid out against (see `BarListRoot`).\n */\nconst labelCellClasses = \"relative w-full max-w-0 pl-2\"\n\n/** Laid out from the label cell's left edge across the whole row, whatever the column count. */\nexport const rowSpanClasses = \"absolute inset-y-0 left-0 w-[100cqw]\"\n\n/**\n * The gutter before a figure column. Content-sized columns sit as close as their own digits\n * allow, so the gutter is what keeps four of them from reading as one number.\n */\nconst figureGutter = \"pl-4\"\n\n/**\n * A figure column is at least 64px, so the columns of two cards side by side line up, and\n * grows with its contents past that. `relative` lifts the figure over the bar, which reaches\n * across from the label cell; that also puts it above a row-sized `overlay`, which is why the\n * overlay carries a z-index.\n */\nconst figureCellClasses = cn(\n figureGutter,\n \"relative min-w-16 text-right whitespace-nowrap tabular-nums\",\n)\n\n/** The rightmost column carries the row's padding at the end of the row. */\nconst lastCellClasses = \"pr-2\"\n\nexport type BarListRowProps = Omit<ComponentProps<\"tr\">, \"children\"> & {\n /**\n * Row text; string labels truncate.\n */\n label: ReactNode\n /**\n * Plain-text row name for the link's aria label, when `label` isn't a string.\n */\n name?: string\n /**\n * Leading visual (favicon, flag, icon tile), 16px.\n */\n icon?: ReactNode\n value: number\n /**\n * The largest value in the list; the bar spans `value / max` of the row.\n */\n max: number\n /**\n * Bar width as a fraction of the row, overriding `value / max`: e.g. a rank ladder so the\n * bars hold still while the rows' labels and values change under them.\n */\n share?: number\n format?: NumberFormat\n /**\n * The figure that leads the row (revenue, a conversion rate), in the column right after the\n * label: the same place on a card and in the full list beside it.\n */\n secondaryValue?: number | string\n secondaryFormat?: NumberFormat\n /** Styles the secondary figure, e.g. tinting money apart from the counts around it. */\n secondaryClassName?: string\n /**\n * Further muted figures in their own columns between the secondary one and the value, for\n * a wide list (a dialog) that has room for figures the card holds back.\n */\n extras?: { value: ReactNode; className?: string }[]\n /**\n * External URL, shown as an arrow beside the label that opens in a new tab.\n */\n href?: string\n /**\n * An element laid over the whole row, such as a click-to-filter button. It renders inside the\n * label cell, which positions it; give it `rowSpanClasses` to cover every column. Give it a\n * `z-index`: the figure cells are positioned and come after it, so at `z-auto` they would\n * paint over it and swallow every click outside the label. Keep it under the `href` arrow's\n * `z-10` and the arrow stays clickable above it.\n */\n overlay?: ReactNode\n}\n\nfunction BarListRow({\n label,\n name,\n icon,\n value,\n max,\n share: shareOverride,\n format,\n secondaryValue,\n secondaryFormat,\n secondaryClassName,\n extras,\n href,\n overlay,\n className,\n style,\n ...props\n}: BarListRowProps) {\n // Clamped at both ends. The low end guards a negative value and the divide by zero; the\n // high end guards a `share` override above 1, or a `max` computed from a filtered subset\n // while `value` comes from the full set. The bar is absolutely positioned, so it would\n // run past the row's right edge and under the value column.\n const share = Math.min(Math.max(shareOverride ?? (max > 0 ? value / max : 0), 0), 1)\n\n return (\n <tr\n className={cn(\"group/bar h-7.5 text-start text-sm\", className)}\n style={{ \"--bar-share\": share, ...style } as CSSProperties}\n {...props}\n >\n <td className={labelCellClasses}>\n {/* The bar spans the whole row, so a 100% share runs edge to edge behind label and\n value alike; the text sits above it. A clip draws the share, since a list changes\n every bar at once and animating their widths would lay the rows out on each frame. */}\n <div\n aria-hidden\n data-bar\n className=\"absolute inset-y-0 left-0 w-[100cqw] bg-fill-subtle transition-[clip-path] duration-250 ease-out-expo [clip-path:inset(0_calc(100%-max(var(--bar-share)*100%,0.375rem))_0_0_round_var(--radius-md))]\"\n />\n\n <div className=\"relative flex items-center gap-2\">\n {icon && <span className=\"flex size-4 shrink-0 items-center justify-center\">{icon}</span>}\n {/* A truncated label has no other full reading: the row has no tooltip, and the\n details dialog truncates the same way. */}\n <span\n title={name ?? (typeof label === \"string\" ? label : undefined)}\n className=\"min-w-0 truncate\"\n >\n {label}\n </span>\n\n {href && (\n <a\n href={href}\n target=\"_blank\"\n rel=\"noreferrer\"\n data-row-link\n aria-label={`Open ${name ?? (typeof label === \"string\" ? label : \"this row\")} in a new tab`}\n // Its own flex item, never inside the label: a truncating label would clip\n // the arrow away. `z-10` keeps it clickable under a row-sized `overlay`\n // (click-to-filter); a coarse pointer gets a target grown around the glyph,\n // with the negative margin keeping the row's layout. The -3px takes back the\n // inset its click target leaves around a 14px glyph, so the arrow sits the same\n // 8px off the label as the icon does on the other side.\n className=\"relative z-10 -ml-[3px] flex size-5 shrink-0 items-center justify-center rounded-sm text-ink-muted hover:text-ink pointer-coarse:-mx-1 pointer-coarse:size-7\"\n >\n <ArrowUpRightIcon className=\"size-3.5\" />\n </a>\n )}\n </div>\n\n {overlay}\n </td>\n\n {secondaryValue !== undefined && (\n <td className={cn(figureCellClasses, \"text-ink-muted\", secondaryClassName)}>\n <FormattedNumber value={secondaryValue} format={secondaryFormat} />\n </td>\n )}\n\n {extras?.map((extra, index) => (\n <td key={index} className={cn(figureCellClasses, \"text-ink-muted\", extra.className)}>\n {extra.value}\n </td>\n ))}\n\n <td className={cn(figureCellClasses, lastCellClasses, \"font-medium text-ink-muted\")}>\n <FormattedNumber value={value} format={format} />\n </td>\n </tr>\n )\n}\n\nexport type BarListBodyProps = ComponentProps<\"tbody\">\n\n/**\n * Holds the `BarList.Row`s, next to the `BarList.Header` that names their columns.\n */\nfunction BarListBody(props: BarListBodyProps) {\n return <tbody {...props} />\n}\n\nexport type BarListHeaderProps = Omit<ComponentProps<\"thead\">, \"children\"> & {\n /**\n * Names the rows' `extras` columns, in the same order.\n */\n extras?: { label: ReactNode; className?: string }[]\n /**\n * Names the secondary column; leave it out when no row fills that column.\n */\n secondary?: ReactNode\n value: ReactNode\n /**\n * Pin the names to the top of the nearest scroll container, for a list long enough to scroll\n * (the full list in a dialog), so the figures stay named however far down you are. Give the\n * scroll container no top padding: the names then start where they stick and never move.\n */\n sticky?: boolean\n}\n\n/**\n * Column names over a `BarList`, in the rows' own columns: the table lines them up, and each\n * name is free to be as wide as it needs. Keep it inside the same `BarList` as whatever swaps\n * the rows for their skeleton, and the card keeps one height across loading and loaded; drop\n * the whole table for an empty or error state, or the names stand over nothing.\n */\nfunction BarListHeader({\n extras,\n secondary,\n value,\n sticky,\n className,\n ...props\n}: BarListHeaderProps) {\n // Sticky rides the cells, not the `<thead>`: a table section only sticks in newer browsers,\n // and each cell has to carry the background itself: `border-separate` leaves gaps a\n // section-level background never paints, which the rows would show through. A sticky\n // element is held inside its scroll container's padding, so padding there would leave a band\n // over the names that the rows pass through; the room above belongs outside the container.\n // `z-20`, over the rows' `z-10` arrows: at the same z, later in the DOM, they paint over it.\n const stickyClasses = sticky && \"sticky top-0 z-20 bg-surface\"\n // No top padding: the parent's padding is the room over the names. 8px plus the row gap\n // puts the first bar 12px under them, matching the 12px above.\n const cellClasses = cn(\n figureGutter,\n \"pb-2 text-right font-normal whitespace-nowrap\",\n stickyClasses,\n )\n\n return (\n <thead className={cn(\"text-ink-muted text-xs\", className)} {...props}>\n <tr>\n {/* The label column goes unnamed (the card's title and tab already say what the\n rows are), so its corner is a plain cell holding the column open, not a header\n of nothing. It stays in the accessibility tree: a hidden cell in a header row can\n shift which header a screen reader pairs with each column. */}\n {/* oxlint-disable-next-line jsx-a11y/control-has-associated-label */}\n <td className={cn(labelCellClasses, stickyClasses)} />\n {secondary !== undefined && <th className={cellClasses}>{secondary}</th>}\n {extras?.map((extra, index) => (\n <th key={index} className={cn(cellClasses, extra.className)}>\n {extra.label}\n </th>\n ))}\n <th className={cn(cellClasses, lastCellClasses)}>{value}</th>\n </tr>\n </thead>\n )\n}\n\n/**\n * Label bars step down like a ranked list would, so the swap to data reads as a fill-in\n * rather than a reflow.\n */\nconst skeletonShares = [\"70cqw\", \"55cqw\", \"45cqw\", \"35cqw\", \"30cqw\"] as const\n\nexport type BarListSkeletonProps = ComponentProps<\"tbody\"> & {\n /**\n * Rows to draw, matching the list that replaces it.\n */\n rows?: number\n /**\n * Columns the list has, the label one included, so the one figure the skeleton draws lands\n * under the same name the data's will.\n */\n columns?: number\n}\n\n/**\n * Loading stand-in at the exact row height of `BarList.Row`, so swapping in data causes no\n * layout shift. Its bars take `Skeleton`'s own fill, a step darker than a row's, so the pulse\n * still reads on a card.\n */\nfunction BarListSkeleton({ rows = 5, columns = 2, className, ...props }: BarListSkeletonProps) {\n return (\n <tbody aria-hidden className={className} {...props}>\n {Array.from({ length: rows }, (_, index) => (\n <tr key={index} className=\"h-7.5\">\n <td className={labelCellClasses}>\n <Skeleton\n className=\"absolute inset-y-0 left-0\"\n style={{ width: skeletonShares[index % skeletonShares.length] }}\n />\n </td>\n {/* Placeholders for the columns between the label and the last figure. They carry no\n padding of their own, so a column its header hides on a narrow screen collapses\n to nothing here too. */}\n {Array.from({ length: Math.max(columns - 2, 0) }, (_, column) => (\n <td key={column} aria-hidden />\n ))}\n {columns > 1 && (\n <td className={cn(figureCellClasses, lastCellClasses)}>\n <Skeleton className=\"ml-auto h-3.5 w-8\" />\n </td>\n )}\n </tr>\n ))}\n </tbody>\n )\n}\n\nconst BarList = Object.assign(BarListRoot, {\n Row: BarListRow,\n Body: BarListBody,\n Header: BarListHeader,\n Skeleton: BarListSkeleton,\n})\n\nexport { BarList }\n"],"mappings":"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"}
@@ -0,0 +1,30 @@
1
+ import { Card } from "./card.js";
2
+ import { ComponentProps, ReactNode } from "react";
3
+ export type BreakdownCardProps = Omit<ComponentProps<typeof Card>, "title"> & {
4
+ title: ReactNode;
5
+ description?: ReactNode;
6
+ /**
7
+ * Header actions, right-aligned beside the title (a menu, a time-range control).
8
+ */
9
+ actions?: ReactNode;
10
+ /**
11
+ * A view switcher (e.g. `ViewPicker`) pinned to the top of the body, above the children.
12
+ */
13
+ tabs?: ReactNode;
14
+ /**
15
+ * A compact hairline-topped strip under the body, for a "Details" link or a total. It sets
16
+ * the small type scale every footer control and note reads at, so its content passes no
17
+ * size of its own.
18
+ */
19
+ footer?: ReactNode;
20
+ /**
21
+ * Drop the body panel's padding, for a body that draws its own edges (a divided row list).
22
+ */
23
+ flush?: boolean;
24
+ };
25
+ /**
26
+ * A dashboard panel: a titled header panel above a flex body panel, hairline-divided, with an
27
+ * optional footer strip. The body grows to fill the card so panels in the same row keep an
28
+ * even height.
29
+ */
30
+ export declare function BreakdownCard({ title, description, actions, tabs, footer, flush, children, ...props }: BreakdownCardProps): import("react").JSX.Element;
@@ -0,0 +1,43 @@
1
+ import { cn } from "../lib/variants.js";
2
+ import { Card, CardHeader, CardPanel } from "./card.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ // src/components/breakdown-card.tsx
5
+ /**
6
+ * A dashboard panel: a titled header panel above a flex body panel, hairline-divided, with an
7
+ * optional footer strip. The body grows to fill the card so panels in the same row keep an
8
+ * even height.
9
+ */
10
+ function BreakdownCard({ title, description, actions, tabs, footer, flush, children, ...props }) {
11
+ return /* @__PURE__ */ jsxs(Card, {
12
+ ...props,
13
+ children: [
14
+ /* @__PURE__ */ jsx(CardPanel, {
15
+ size: "none",
16
+ className: "px-4 py-3 md:px-5 md:py-3.5",
17
+ children: /* @__PURE__ */ jsx(CardHeader, {
18
+ size: "panel",
19
+ className: "flex-nowrap gap-y-0.5 [&>*:first-child]:flex-none",
20
+ title,
21
+ description,
22
+ actions
23
+ })
24
+ }),
25
+ /* @__PURE__ */ jsxs(CardPanel, {
26
+ size: "none",
27
+ className: cn("flex flex-1 flex-col gap-3 px-4 py-3 md:px-5", flush && "p-0 md:p-0"),
28
+ children: [tabs && /* @__PURE__ */ jsx("div", {
29
+ className: cn("flex", flush && "px-4 pt-4"),
30
+ children: tabs
31
+ }), children]
32
+ }),
33
+ footer && /* @__PURE__ */ jsx(CardPanel, {
34
+ size: "none",
35
+ className: "px-4 py-3 text-xs/5 md:px-5",
36
+ children: footer
37
+ })
38
+ ]
39
+ });
40
+ }
41
+ export { BreakdownCard };
42
+
43
+ //# sourceMappingURL=breakdown-card.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"breakdown-card.js","names":[],"sources":["../../src/components/breakdown-card.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from \"react\"\nimport { cn } from \"../lib/variants\"\nimport { Card, CardHeader, CardPanel } from \"./card\"\n\n// `title` is omitted before it is redeclared: a `<div>`'s own `title` attribute is a string,\n// and the intersection would otherwise narrow the card's heading to one.\nexport type BreakdownCardProps = Omit<ComponentProps<typeof Card>, \"title\"> & {\n title: ReactNode\n description?: ReactNode\n /**\n * Header actions, right-aligned beside the title (a menu, a time-range control).\n */\n actions?: ReactNode\n /**\n * A view switcher (e.g. `ViewPicker`) pinned to the top of the body, above the children.\n */\n tabs?: ReactNode\n /**\n * A compact hairline-topped strip under the body, for a \"Details\" link or a total. It sets\n * the small type scale every footer control and note reads at, so its content passes no\n * size of its own.\n */\n footer?: ReactNode\n /**\n * Drop the body panel's padding, for a body that draws its own edges (a divided row list).\n */\n flush?: boolean\n}\n\n/**\n * A dashboard panel: a titled header panel above a flex body panel, hairline-divided, with an\n * optional footer strip. The body grows to fill the card so panels in the same row keep an\n * even height.\n */\nexport function BreakdownCard({\n title,\n description,\n actions,\n tabs,\n footer,\n flush,\n children,\n ...props\n}: BreakdownCardProps) {\n return (\n <Card {...props}>\n <CardPanel size=\"none\" className=\"px-4 py-3 md:px-5 md:py-3.5\">\n <CardHeader\n size=\"panel\"\n // The actions keep the title's line and wrap within the space left beside it, rather\n // than dropping under the title the moment they no longer fit on one row: a card's\n // tab row is the usual actions here, and it has its own wrapping.\n className=\"flex-nowrap gap-y-0.5 [&>*:first-child]:flex-none\"\n title={title}\n description={description}\n actions={actions}\n />\n </CardPanel>\n\n {/* The header's inset, so row text starts under the title and figures end under the\n actions; `BarList` bleeds its bars past that line. 12px over and under the list. */}\n <CardPanel\n size=\"none\"\n // `md:p-0` alongside `p-0`: the merge treats a variant class as its own group, so\n // `p-0` on its own leaves `md:px-5` standing and a flush body is only flush on a phone.\n className={cn(\"flex flex-1 flex-col gap-3 px-4 py-3 md:px-5\", flush && \"p-0 md:p-0\")}\n >\n {tabs && <div className={cn(\"flex\", flush && \"px-4 pt-4\")}>{tabs}</div>}\n {children}\n </CardPanel>\n\n {/* A fixed band: 12px over a 20px line and 12px under it, whatever the body is showing.\n The line is `text-xs/5`, not the 16px one this size carries by default, so the band\n is 44px for a footer that passes plain text as much as for one that pins its own row. */}\n {footer && (\n <CardPanel size=\"none\" className=\"px-4 py-3 text-xs/5 md:px-5\">\n {footer}\n </CardPanel>\n )}\n </Card>\n )\n}\n"],"mappings":";;;;;;;;;AAkCA,SAAgB,cAAc,EAC5B,OACA,aACA,SACA,MACA,QACA,OACA,UACA,GAAG,SACkB;CACrB,OACE,qBAAC,MAAD;EAAM,GAAI;EAAV,UAAA;GACE,oBAAC,WAAD;IAAW,MAAK;IAAO,WAAU;IAC/B,UAAA,oBAAC,YAAD;KACE,MAAK;KAIL,WAAU;KACH;KACM;KACJ;IACV,CAAA;GACQ,CAAA;GAIX,qBAAC,WAAD;IACE,MAAK;IAGL,WAAW,GAAG,gDAAgD,SAAS,YAAY;IAJrF,UAAA,CAMG,QAAQ,oBAAC,OAAD;KAAK,WAAW,GAAG,QAAQ,SAAS,WAAW;KAAI,UAAA;IAAU,CAAA,GACrE,QACQ;;GAKV,UACC,oBAAC,WAAD;IAAW,MAAK;IAAO,WAAU;IAC9B,UAAA;GACQ,CAAA;EAET;;AAEV"}
@@ -0,0 +1,21 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+ interface BulkActionBarProps extends Omit<ComponentProps<"section">, "children"> {
3
+ /** How many rows are selected. The bar shows while there is at least one. */
4
+ count: number;
5
+ /** The selection as text, formatted by the caller. */
6
+ label?: ReactNode;
7
+ onClear: () => void;
8
+ clearLabel?: string;
9
+ /**
10
+ * The actions for the selection: small ghost buttons, the destructive one last with
11
+ * `tone="danger"`.
12
+ */
13
+ children: ReactNode;
14
+ }
15
+ /**
16
+ * Floats at the bottom centre of the page while rows are selected: "N selected" with a cross
17
+ * that clears the selection, then the actions for it. It owns the selection count, so the
18
+ * footer band never shows one. A selection covers the current page only.
19
+ */
20
+ export declare function BulkActionBar({ count, label, onClear, clearLabel, "aria-label": ariaLabel, className, children, ...props }: BulkActionBarProps): import("react").JSX.Element;
21
+ export {};
@@ -0,0 +1,38 @@
1
+ "use client";
2
+ import { CancelIcon } from "../lib/icons.js";
3
+ import { cn } from "../lib/variants.js";
4
+ import { Button } from "./button.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/bulk-action-bar.tsx
7
+ /**
8
+ * Floats at the bottom centre of the page while rows are selected: "N selected" with a cross
9
+ * that clears the selection, then the actions for it. It owns the selection count, so the
10
+ * footer band never shows one. A selection covers the current page only.
11
+ */
12
+ function BulkActionBar({ count, label = `${count} selected`, onClear, clearLabel = "Clear selection", "aria-label": ariaLabel = "Selection", className, children, ...props }) {
13
+ return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
14
+ "aria-live": "polite",
15
+ className: "sr-only",
16
+ children: count > 0 ? label : ""
17
+ }), count > 0 && /* @__PURE__ */ jsxs("section", {
18
+ "aria-label": ariaLabel,
19
+ className: cn("fixed bottom-6 left-1/2 z-40 flex max-w-[calc(100vw-2rem)] -translate-x-1/2 items-center gap-2 rounded-xl border border-edge-float bg-overlay p-1.5 shadow-popup", "fade-in-0 slide-in-from-bottom-2 animate-in duration-150 ease-out-expo", className),
20
+ ...props,
21
+ children: [/* @__PURE__ */ jsxs("span", {
22
+ className: "flex h-7 shrink-0 items-center gap-1 rounded-md border border-edge border-dashed pr-0.5 pl-2.5 font-medium text-control text-ink tabular-nums",
23
+ children: [label, /* @__PURE__ */ jsx(Button, {
24
+ variant: "ghost",
25
+ size: "xs",
26
+ "aria-label": clearLabel,
27
+ prefix: /* @__PURE__ */ jsx(CancelIcon, {}),
28
+ onClick: onClear
29
+ })]
30
+ }), /* @__PURE__ */ jsx("div", {
31
+ className: "flex min-w-0 items-center gap-0.5 overflow-x-auto",
32
+ children
33
+ })]
34
+ })] });
35
+ }
36
+ export { BulkActionBar };
37
+
38
+ //# sourceMappingURL=bulk-action-bar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bulk-action-bar.js","names":[],"sources":["../../src/components/bulk-action-bar.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ComponentProps, ReactNode } from \"react\"\nimport { CancelIcon } from \"../lib/icons\"\nimport { cn } from \"../lib/variants\"\nimport { Button } from \"./button\"\n\ninterface BulkActionBarProps extends Omit<ComponentProps<\"section\">, \"children\"> {\n /** How many rows are selected. The bar shows while there is at least one. */\n count: number\n /** The selection as text, formatted by the caller. */\n label?: ReactNode\n onClear: () => void\n clearLabel?: string\n /**\n * The actions for the selection: small ghost buttons, the destructive one last with\n * `tone=\"danger\"`.\n */\n children: ReactNode\n}\n\n/**\n * Floats at the bottom centre of the page while rows are selected: \"N selected\" with a cross\n * that clears the selection, then the actions for it. It owns the selection count, so the\n * footer band never shows one. A selection covers the current page only.\n */\nexport function BulkActionBar({\n count,\n label = `${count} selected`,\n onClear,\n clearLabel = \"Clear selection\",\n \"aria-label\": ariaLabel = \"Selection\",\n className,\n children,\n ...props\n}: BulkActionBarProps) {\n return (\n <>\n {/* Mounted while nothing is selected too: a screen reader skips the text a live region\n is born with, so the first selection would go unannounced. */}\n <span aria-live=\"polite\" className=\"sr-only\">\n {count > 0 ? label : \"\"}\n </span>\n {count > 0 && (\n <section\n aria-label={ariaLabel}\n className={cn(\n \"fixed bottom-6 left-1/2 z-40 flex max-w-[calc(100vw-2rem)] -translate-x-1/2 items-center gap-2 rounded-xl border border-edge-float bg-overlay p-1.5 shadow-popup\",\n \"fade-in-0 slide-in-from-bottom-2 animate-in duration-150 ease-out-expo\",\n className,\n )}\n {...props}\n >\n <span className=\"flex h-7 shrink-0 items-center gap-1 rounded-md border border-edge border-dashed pr-0.5 pl-2.5 font-medium text-control text-ink tabular-nums\">\n {label}\n <Button\n variant=\"ghost\"\n size=\"xs\"\n aria-label={clearLabel}\n prefix={<CancelIcon />}\n onClick={onClear}\n />\n </span>\n <div className=\"flex min-w-0 items-center gap-0.5 overflow-x-auto\">{children}</div>\n </section>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;AA0BA,SAAgB,cAAc,EAC5B,OACA,QAAQ,GAAG,MAAM,YACjB,SACA,aAAa,mBACb,cAAc,YAAY,aAC1B,WACA,UACA,GAAG,SACkB;CACrB,OACE,qBAAA,UAAA,EAAA,UAAA,CAGE,oBAAC,QAAD;EAAM,aAAU;EAAS,WAAU;EAChC,UAAA,QAAQ,IAAI,QAAQ;CACjB,CAAA,GACL,QAAQ,KACP,qBAAC,WAAD;EACE,cAAY;EACZ,WAAW,GACT,oKACA,0EACA,SACF;EACA,GAAI;EAPN,UAAA,CASE,qBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACG,OACD,oBAAC,QAAD;IACE,SAAQ;IACR,MAAK;IACL,cAAY;IACZ,QAAQ,oBAAC,YAAD,CAAa,CAAA;IACrB,SAAS;GACV,CAAA,CACG;EACN,CAAA,GAAA,oBAAC,OAAD;GAAK,WAAU;GAAqD;EAAc,CAAA,CAC3E;CAEX,CAAA,CAAA,EAAA,CAAA;AAEN"}
@@ -0,0 +1,21 @@
1
+ import { ComponentProps } from "react";
2
+ /**
3
+ * Buttons joined into one control, meant for bordered (`secondary`) buttons. The group only
4
+ * shapes its members: every member after the first drops its left border, so the edge of the one
5
+ * before it is the divider, and the inner corners square off. Edges are translucent, so two
6
+ * borders laid over each other would draw a darker seam. Each member paints its fill inside its
7
+ * border, over the group's surface, so every edge lies on the same colour, and a hovered or
8
+ * pressed fill cannot darken three of a member's edges and not the fourth, which its neighbour
9
+ * draws. The group's corners are a medium button's.
10
+ *
11
+ * Each member's states stay its own, and `Button` keeps them inside its box when it sits in a
12
+ * group (the `ui-standalone` variant in `styles.css`): no darker edge on hover, no drop on press,
13
+ * a disabled member keeps its edge.
14
+ *
15
+ * The ends are found among the members, not the children: an open popup trigger gets
16
+ * focus-guard and `aria-owns` spans rendered beside it, a member under `DisabledReason` a
17
+ * `hidden` reason, and `:first-child` would move off the button onto one of those. A guard is
18
+ * matched by its `data-base-ui-focus-guard` attribute, not `aria-hidden`: in Safari, Base UI
19
+ * gives it `role="button"` in place of `aria-hidden`, for VoiceOver.
20
+ */
21
+ export declare function ButtonGroup({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
@@ -0,0 +1,32 @@
1
+ import { cn } from "../lib/variants.js";
2
+ import { jsx } from "react/jsx-runtime";
3
+ // src/components/button-group.tsx
4
+ /**
5
+ * Buttons joined into one control, meant for bordered (`secondary`) buttons. The group only
6
+ * shapes its members: every member after the first drops its left border, so the edge of the one
7
+ * before it is the divider, and the inner corners square off. Edges are translucent, so two
8
+ * borders laid over each other would draw a darker seam. Each member paints its fill inside its
9
+ * border, over the group's surface, so every edge lies on the same colour, and a hovered or
10
+ * pressed fill cannot darken three of a member's edges and not the fourth, which its neighbour
11
+ * draws. The group's corners are a medium button's.
12
+ *
13
+ * Each member's states stay its own, and `Button` keeps them inside its box when it sits in a
14
+ * group (the `ui-standalone` variant in `styles.css`): no darker edge on hover, no drop on press,
15
+ * a disabled member keeps its edge.
16
+ *
17
+ * The ends are found among the members, not the children: an open popup trigger gets
18
+ * focus-guard and `aria-owns` spans rendered beside it, a member under `DisabledReason` a
19
+ * `hidden` reason, and `:first-child` would move off the button onto one of those. A guard is
20
+ * matched by its `data-base-ui-focus-guard` attribute, not `aria-hidden`: in Safari, Base UI
21
+ * gives it `role="button"` in place of `aria-hidden`, for VoiceOver.
22
+ */
23
+ function ButtonGroup({ className, ...props }) {
24
+ return /* @__PURE__ */ jsx("div", {
25
+ "data-slot": "button-group",
26
+ className: cn("inline-flex rounded-md bg-surface [&>*]:bg-clip-padding", "[&>:not(:nth-child(1_of_:not([data-base-ui-focus-guard]):not([aria-owns]):not([hidden])))]:rounded-l-none", "[&>:not(:nth-child(1_of_:not([data-base-ui-focus-guard]):not([aria-owns]):not([hidden])))]:border-l-0", "[&>:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard]):not([aria-owns]):not([hidden])))]:rounded-r-none", className),
27
+ ...props
28
+ });
29
+ }
30
+ export { ButtonGroup };
31
+
32
+ //# sourceMappingURL=button-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"button-group.js","names":[],"sources":["../../src/components/button-group.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\"\nimport { cn } from \"../lib/variants\"\n\n/**\n * Buttons joined into one control, meant for bordered (`secondary`) buttons. The group only\n * shapes its members: every member after the first drops its left border, so the edge of the one\n * before it is the divider, and the inner corners square off. Edges are translucent, so two\n * borders laid over each other would draw a darker seam. Each member paints its fill inside its\n * border, over the group's surface, so every edge lies on the same colour, and a hovered or\n * pressed fill cannot darken three of a member's edges and not the fourth, which its neighbour\n * draws. The group's corners are a medium button's.\n *\n * Each member's states stay its own, and `Button` keeps them inside its box when it sits in a\n * group (the `ui-standalone` variant in `styles.css`): no darker edge on hover, no drop on press,\n * a disabled member keeps its edge.\n *\n * The ends are found among the members, not the children: an open popup trigger gets\n * focus-guard and `aria-owns` spans rendered beside it, a member under `DisabledReason` a\n * `hidden` reason, and `:first-child` would move off the button onto one of those. A guard is\n * matched by its `data-base-ui-focus-guard` attribute, not `aria-hidden`: in Safari, Base UI\n * gives it `role=\"button\"` in place of `aria-hidden`, for VoiceOver.\n */\nexport function ButtonGroup({ className, ...props }: ComponentProps<\"div\">) {\n return (\n <div\n data-slot=\"button-group\"\n className={cn(\n \"inline-flex rounded-md bg-surface [&>*]:bg-clip-padding\",\n \"[&>:not(:nth-child(1_of_:not([data-base-ui-focus-guard]):not([aria-owns]):not([hidden])))]:rounded-l-none\",\n \"[&>:not(:nth-child(1_of_:not([data-base-ui-focus-guard]):not([aria-owns]):not([hidden])))]:border-l-0\",\n \"[&>:not(:nth-last-child(1_of_:not([data-base-ui-focus-guard]):not([aria-owns]):not([hidden])))]:rounded-r-none\",\n className,\n )}\n {...props}\n />\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAsBA,SAAgB,YAAY,EAAE,WAAW,GAAG,SAAgC;CAC1E,OACE,oBAAC,OAAD;EACE,aAAU;EACV,WAAW,GACT,2DACA,6GACA,yGACA,kHACA,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
@@ -0,0 +1,39 @@
1
+ import { VariantProps } from "../lib/variants.js";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ import { ReactNode } from "react";
4
+ declare const buttonVariants: import("tailwind-variants").TVReturnType<{
5
+ variant: {
6
+ primary: string;
7
+ secondary: string;
8
+ soft: string;
9
+ ghost: string;
10
+ };
11
+ tone: {
12
+ neutral: string;
13
+ danger: string;
14
+ };
15
+ bordered: {
16
+ true: string;
17
+ };
18
+ size: {
19
+ xs: string;
20
+ sm: string;
21
+ md: string;
22
+ lg: string;
23
+ };
24
+ interactive: {
25
+ true: string[];
26
+ };
27
+ }, undefined, string[], undefined, undefined, undefined>;
28
+ export type ButtonProps = Omit<useRender.ComponentProps<"button">, "size" | "prefix"> & VariantProps<typeof buttonVariants> & {
29
+ /**
30
+ * If set to `true`, the button will be rendered in the pending state.
31
+ */
32
+ isPending?: boolean;
33
+ /** The slot to be rendered before the label. */
34
+ prefix?: ReactNode;
35
+ /** The slot to be rendered after the label. */
36
+ suffix?: ReactNode;
37
+ };
38
+ declare function Button({ children, className, disabled, render, isPending, prefix, suffix, variant, tone, size, interactive, bordered, ...rest }: ButtonProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
39
+ export { Button, buttonVariants };
@@ -0,0 +1,145 @@
1
+ import { LoadingIcon } from "../lib/icons.js";
2
+ import { interactiveVariants } from "../lib/interactive.js";
3
+ import { slot } from "../lib/slot.js";
4
+ import { cn, variants } from "../lib/variants.js";
5
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
6
+ import { mergeProps } from "@base-ui/react";
7
+ import { useRender } from "@base-ui/react/use-render";
8
+ import { Children, isValidElement } from "react";
9
+ // src/components/button.tsx
10
+ const buttonInteractiveClasses = interactiveVariants({ interactive: false });
11
+ const buttonVariants = variants({
12
+ base: [
13
+ buttonInteractiveClasses,
14
+ "group/button inline-flex items-center justify-center font-medium text-start rounded-md hover:z-10 focus-visible:z-10",
15
+ "text-control",
16
+ "relative transition-[color,background-color,border-color,box-shadow,translate] duration-150 ease-out-expo"
17
+ ],
18
+ variants: {
19
+ variant: {
20
+ primary: "bg-ink text-ink-inverse shadow-control aria-expanded:bg-ink/90 aria-expanded:shadow-none",
21
+ secondary: "bg-surface text-ink-secondary aria-expanded:bg-fill-subtle aria-expanded:text-ink",
22
+ soft: "bg-fill text-ink-secondary aria-expanded:bg-fill-strong aria-expanded:text-ink",
23
+ ghost: "text-ink-secondary aria-expanded:bg-fill-subtle aria-expanded:text-ink"
24
+ },
25
+ tone: {
26
+ neutral: "",
27
+ danger: ""
28
+ },
29
+ bordered: { true: "border border-edge-strong shadow-control aria-expanded:ui-standalone:border-edge-solid aria-expanded:ui-standalone:shadow-none" },
30
+ size: {
31
+ xs: "h-6 px-2 gap-1 text-xs rounded",
32
+ sm: "h-7 px-2 gap-1.5",
33
+ md: "h-control px-3 gap-1.5",
34
+ lg: "h-9 px-3.5 gap-2 text-sm rounded-lg"
35
+ },
36
+ interactive: { true: [
37
+ "not-disabled:not-aria-disabled:cursor-pointer aria-disabled:cursor-not-allowed",
38
+ "ui-pressed:duration-75 ui-pressed:ui-standalone:shadow-none ui-pressed:ui-standalone:translate-y-px",
39
+ "ui-pressed:ui-standalone:after:absolute ui-pressed:ui-standalone:after:inset-x-0 ui-pressed:ui-standalone:after:-top-0.5 ui-pressed:ui-standalone:after:h-0.5"
40
+ ] }
41
+ },
42
+ compoundVariants: [
43
+ {
44
+ variant: [
45
+ "secondary",
46
+ "soft",
47
+ "ghost"
48
+ ],
49
+ class: ["not-data-pending:disabled:*:opacity-50 not-data-pending:disabled:ui-standalone:shadow-none", "aria-disabled:*:opacity-50 aria-disabled:ui-standalone:shadow-none"]
50
+ },
51
+ {
52
+ variant: "primary",
53
+ class: ["not-data-pending:disabled:bg-fill not-data-pending:disabled:text-ink-muted not-data-pending:disabled:shadow-none", "aria-disabled:bg-fill aria-disabled:text-ink-muted aria-disabled:shadow-none"]
54
+ },
55
+ {
56
+ variant: "primary",
57
+ interactive: true,
58
+ class: "hover:not-disabled:not-aria-disabled:bg-ink/90 ui-pressed:bg-ink/80"
59
+ },
60
+ {
61
+ variant: ["secondary", "ghost"],
62
+ interactive: true,
63
+ class: "hover:not-disabled:not-aria-disabled:bg-fill-subtle hover:not-disabled:not-aria-disabled:text-ink ui-pressed:bg-fill"
64
+ },
65
+ {
66
+ bordered: true,
67
+ interactive: true,
68
+ class: "hover:ui-standalone:not-disabled:not-aria-disabled:border-edge-solid"
69
+ },
70
+ {
71
+ variant: "soft",
72
+ interactive: true,
73
+ class: "hover:not-disabled:not-aria-disabled:bg-fill-strong hover:not-disabled:not-aria-disabled:text-ink ui-pressed:bg-fill-strong"
74
+ },
75
+ {
76
+ variant: "primary",
77
+ tone: "danger",
78
+ class: "bg-danger text-danger-on hover:not-disabled:not-aria-disabled:bg-danger/90 aria-expanded:bg-danger/90"
79
+ },
80
+ {
81
+ variant: "primary",
82
+ tone: "danger",
83
+ interactive: true,
84
+ class: "ui-pressed:bg-danger/80"
85
+ },
86
+ {
87
+ variant: [
88
+ "secondary",
89
+ "soft",
90
+ "ghost"
91
+ ],
92
+ tone: "danger",
93
+ class: "text-danger-ink hover:not-disabled:not-aria-disabled:text-danger-ink aria-expanded:text-danger-ink"
94
+ }
95
+ ],
96
+ defaultVariants: {
97
+ variant: "primary",
98
+ tone: "neutral",
99
+ size: "md",
100
+ interactive: true
101
+ }
102
+ });
103
+ const buttonAffixClasses = "shrink-0 first:-ml-0.5 last:-mr-0.5 [svg]:size-3.5";
104
+ const buttonSquareClasses = "px-0 aspect-square";
105
+ const buttonSquareAffixClasses = "shrink-0 [svg]:size-3.5";
106
+ /**
107
+ * Hidden while a button with no leading icon is pending, so only the spinner reads as content. A
108
+ * button with one keeps its label, since the spinner takes the icon's place.
109
+ */
110
+ const buttonPendingClasses = "group-data-pending/button:text-transparent";
111
+ function Button({ children, className, disabled = false, render, isPending, prefix, suffix, variant, tone, size, interactive = true, bordered, ...rest }) {
112
+ const square = Children.toArray(children).length === 0;
113
+ const affixClasses = square ? buttonSquareAffixClasses : buttonAffixClasses;
114
+ const props = mergeProps({
115
+ disabled: disabled || isPending,
116
+ "aria-busy": isPending ? true : void 0,
117
+ className: buttonVariants({
118
+ variant,
119
+ tone,
120
+ size,
121
+ interactive,
122
+ bordered: bordered ?? variant === "secondary",
123
+ className: cn(square && buttonSquareClasses, className)
124
+ }),
125
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
126
+ slot(prefix && isPending ? /* @__PURE__ */ jsx(LoadingIcon, { className: "animate-spin" }) : prefix, { className: affixClasses }),
127
+ !square && slot(isValidElement(children) ? children : /* @__PURE__ */ jsx("span", { children }), { className: cn("flex-1 truncate only:flex-initial has-[div]:contents", !prefix && buttonPendingClasses) }),
128
+ slot(suffix, { className: cn(affixClasses, buttonPendingClasses) }),
129
+ !prefix && !!isPending && /* @__PURE__ */ jsx(LoadingIcon, { className: "absolute size-[1.25em] animate-spin" })
130
+ ] })
131
+ }, rest);
132
+ return useRender({
133
+ defaultTagName: "button",
134
+ render,
135
+ props: {
136
+ "data-pending": isPending ? true : void 0,
137
+ "data-pressable": interactive ? "" : void 0,
138
+ ...!render && { type: "button" },
139
+ ...props
140
+ }
141
+ });
142
+ }
143
+ export { Button, buttonVariants };
144
+
145
+ //# sourceMappingURL=button.js.map