@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 @@
1
+ {"version":3,"file":"shortcuts-dialog.js","names":[],"sources":["../../src/components/shortcuts-dialog.tsx"],"sourcesContent":["\"use client\"\n\nimport { useRef, useState } from \"react\"\nimport { eyebrowClasses } from \"../lib/classes\"\nimport { matchesMedia, POINTER_FINE } from \"../lib/media\"\nimport { formatKeys, useShortcutList } from \"../lib/shortcuts\"\nimport { cn } from \"../lib/variants\"\nimport { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from \"./dialog\"\nimport { EmptyState } from \"./empty-state\"\nimport { SearchInput } from \"./search-input\"\nimport { ShortcutKeys } from \"./shortcut-keys\"\n\ninterface ShortcutsDialogProps {\n open: boolean\n onOpenChange: (open: boolean) => void\n}\n\n/**\n * The one reference list of every shortcut mounted right now, read straight off the registry in\n * `lib/shortcuts`. Nothing to wire: whatever a page registers shows up here, grouped.\n */\nexport function ShortcutsDialog({ open, onOpenChange }: ShortcutsDialogProps) {\n const groups = useShortcutList()\n const [search, setSearch] = useState(\"\")\n const searchRef = useRef<HTMLInputElement>(null)\n\n const query = search.trim().toLowerCase()\n\n const matches = groups\n .map(group => ({\n group: group.group,\n shortcuts: group.shortcuts.filter(shortcut => {\n const haystack = [shortcut.label, group.group, ...formatKeys(shortcut.keys)]\n return haystack.join(\" \").toLowerCase().includes(query)\n }),\n }))\n .filter(group => group.shortcuts.length > 0)\n\n // The search is scoped to one visit: whatever was typed goes when the dialog is dismissed.\n function handleOpenChange(next: boolean) {\n if (!next) setSearch(\"\")\n onOpenChange(next)\n }\n\n return (\n <Dialog open={open} onOpenChange={handleOpenChange}>\n <DialogContent\n size=\"2xl\"\n instant\n // The sheet on a phone is a coarse-pointer surface: focusing the field there throws up\n // the on-screen keyboard over the list it is meant to filter.\n initialFocus={() => (matchesMedia(POINTER_FINE) ? searchRef.current : true)}\n >\n {/* Sticky rather than a fixed-height scrolling body: a multi-column box with a capped\n height spills into a THIRD column and scrolls sideways, so the list keeps its natural\n height, the popup does the scrolling, and the header rides along. */}\n <DialogHeader\n bordered\n className=\"sticky top-0 z-20 bg-surface\"\n title=\"Keyboard shortcuts\"\n description=\"Press ? anywhere to open this list.\"\n />\n\n <div className=\"border-b bg-surface px-6 py-3\">\n <SearchInput\n ref={searchRef}\n value={search}\n onValueChange={setSearch}\n placeholder=\"Search shortcuts\"\n aria-label=\"Search shortcuts\"\n />\n </div>\n\n <div className=\"gap-x-10 px-6 py-5 sm:columns-2\">\n {matches.length === 0 ? (\n <EmptyState variant=\"inline\" title=\"No shortcuts match\" />\n ) : (\n matches.map(group => (\n <div key={group.group} className=\"mb-5 break-inside-avoid last:mb-0\">\n <p className={cn(eyebrowClasses, \"mb-1\")}>{group.group}</p>\n\n {group.shortcuts.map(shortcut => (\n <div\n key={`${shortcut.keys} ${shortcut.label}`}\n className=\"flex items-center justify-between gap-6 py-1.5 text-sm\"\n >\n <span className=\"min-w-0 truncate text-ink-secondary\">{shortcut.label}</span>\n\n <ShortcutKeys keys={shortcut.keys} />\n </div>\n ))}\n </div>\n ))\n )}\n </div>\n\n {/* Desktop only: a sheet closes by its X or a swipe, so a band across its foot would\n only take room from the list. Sticky like the header, since the popup itself is\n what scrolls here. */}\n <DialogFooter className=\"sticky bottom-0 z-20 max-sm:hidden\">\n <DialogClose variant=\"primary\">Done</DialogClose>\n </DialogFooter>\n </DialogContent>\n </Dialog>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAqBA,SAAgB,gBAAgB,EAAE,MAAM,gBAAsC;CAC5E,MAAM,SAAS,gBAAgB;CAC/B,MAAM,CAAC,QAAQ,aAAa,SAAS,EAAE;CACvC,MAAM,YAAY,OAAyB,IAAI;CAE/C,MAAM,QAAQ,OAAO,KAAK,CAAC,CAAC,YAAY;CAExC,MAAM,UAAU,OACb,KAAI,WAAU;EACb,OAAO,MAAM;EACb,WAAW,MAAM,UAAU,QAAO,aAAY;GAE5C,OAAO;IADW,SAAS;IAAO,MAAM;IAAO,GAAG,WAAW,SAAS,IAAI;GAC5D,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,YAAY,CAAC,CAAC,SAAS,KAAK;EACxD,CAAC;CACH,EAAE,CAAC,CACF,QAAO,UAAS,MAAM,UAAU,SAAS,CAAC;CAG7C,SAAS,iBAAiB,MAAe;EACvC,IAAI,CAAC,MAAM,UAAU,EAAE;EACvB,aAAa,IAAI;CACnB;CAEA,OACE,oBAAC,QAAD;EAAc;EAAM,cAAc;EAChC,UAAA,qBAAC,eAAD;GACE,MAAK;GACL,SAAA;GAGA,oBAAqB,aAAA,iBAAyB,IAAI,UAAU,UAAU;GALxE,UAAA;IAUE,oBAAC,cAAD;KACE,UAAA;KACA,WAAU;KACV,OAAM;KACN,aAAY;IACb,CAAA;IAED,oBAAC,OAAD;KAAK,WAAU;KACb,UAAA,oBAAC,aAAD;MACE,KAAK;MACL,OAAO;MACP,eAAe;MACf,aAAY;MACZ,cAAW;KACZ,CAAA;IACE,CAAA;IAEL,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA,QAAQ,WAAW,IAClB,oBAAC,YAAD;MAAY,SAAQ;MAAS,OAAM;KAAsB,CAAA,IAEzD,QAAQ,KAAI,UACV,qBAAC,OAAD;MAAuB,WAAU;MAAjC,UAAA,CACE,oBAAC,KAAD;OAAG,WAAW,GAAG,gBAAgB,MAAM;OAAI,UAAA,MAAM;MAAS,CAAA,GAEzD,MAAM,UAAU,KAAI,aACnB,qBAAC,OAAD;OAEE,WAAU;OAFZ,UAAA,CAIE,oBAAC,QAAD;QAAM,WAAU;QAAuC,UAAA,SAAS;OAAY,CAAA,GAE5E,oBAAC,cAAD,EAAc,MAAM,SAAS,KAAO,CAAA,CACjC;MANE,GAAA,GAAG,SAAS,KAAK,GAAG,SAAS,OAM/B,CACN,CACE;KAbK,GAAA,MAAM,KAaX,CACN;IAEA,CAAA;IAKL,oBAAC,cAAD;KAAc,WAAU;KACtB,UAAA,oBAAC,aAAD;MAAa,SAAQ;MAAU,UAAA;KAAiB,CAAA;IACpC,CAAA;GACD;;CACT,CAAA;AAEZ"}
@@ -0,0 +1,8 @@
1
+ import { useRender } from "@base-ui/react/use-render";
2
+ /**
3
+ * Loading stand-in in the fill, the same colour as a `BarList` bar, so every
4
+ * skeleton across a page reads as one thing. Size it with `className`; pass `render` for a
5
+ * different element, e.g. `render={<span />}` inside a paragraph. Hidden from screen readers:
6
+ * the container it stands in for says it is loading with `aria-busy`.
7
+ */
8
+ export declare function Skeleton({ className, render, ...props }: useRender.ComponentProps<"div">): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
@@ -0,0 +1,23 @@
1
+ import { cn } from "../lib/variants.js";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ // src/components/skeleton.tsx
4
+ /**
5
+ * Loading stand-in in the fill, the same colour as a `BarList` bar, so every
6
+ * skeleton across a page reads as one thing. Size it with `className`; pass `render` for a
7
+ * different element, e.g. `render={<span />}` inside a paragraph. Hidden from screen readers:
8
+ * the container it stands in for says it is loading with `aria-busy`.
9
+ */
10
+ function Skeleton({ className, render, ...props }) {
11
+ return useRender({
12
+ render,
13
+ defaultTagName: "div",
14
+ props: {
15
+ "aria-hidden": true,
16
+ className: cn("animate-pulse rounded-md bg-fill motion-reduce:animate-none", className),
17
+ ...props
18
+ }
19
+ });
20
+ }
21
+ export { Skeleton };
22
+
23
+ //# sourceMappingURL=skeleton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"skeleton.js","names":[],"sources":["../../src/components/skeleton.tsx"],"sourcesContent":["import { useRender } from \"@base-ui/react/use-render\"\nimport { cn } from \"../lib/variants\"\n\n/**\n * Loading stand-in in the fill, the same colour as a `BarList` bar, so every\n * skeleton across a page reads as one thing. Size it with `className`; pass `render` for a\n * different element, e.g. `render={<span />}` inside a paragraph. Hidden from screen readers:\n * the container it stands in for says it is loading with `aria-busy`.\n */\nexport function Skeleton({ className, render, ...props }: useRender.ComponentProps<\"div\">) {\n return useRender({\n render,\n defaultTagName: \"div\",\n props: {\n \"aria-hidden\": true,\n className: cn(\"animate-pulse rounded-md bg-fill motion-reduce:animate-none\", className),\n ...props,\n },\n })\n}\n"],"mappings":";;;;;;;;;AASA,SAAgB,SAAS,EAAE,WAAW,QAAQ,GAAG,SAA0C;CACzF,OAAO,UAAU;EACf;EACA,gBAAgB;EAChB,OAAO;GACL,eAAe;GACf,WAAW,GAAG,+DAA+D,SAAS;GACtF,GAAG;EACL;CACF,CAAC;AACH"}
@@ -0,0 +1,25 @@
1
+ import { ComponentProps } from "react";
2
+ export type SparklineProps = Omit<ComponentProps<"div">, "children"> & {
3
+ /** One figure per step along the line, in order. */
4
+ data: number[];
5
+ /**
6
+ * Series colour; one of the `--color-chart-*` tokens.
7
+ */
8
+ color?: string;
9
+ /**
10
+ * Line weight in px.
11
+ */
12
+ strokeWidth?: number;
13
+ /**
14
+ * Whether the line wipes in when the element enters the page. Off by default: a line on a
15
+ * page people return to all day would redraw on every visit.
16
+ */
17
+ animated?: boolean;
18
+ };
19
+ /**
20
+ * A trend at a glance: the smooth gradient area of `TimeSeriesChart` with no axes, grid,
21
+ * tooltip or hover, filling whatever box it is given. Plain SVG rather than a chart, so the
22
+ * pages that list sites never load the chart runtime for it. Purely a picture, so it takes no
23
+ * pointer events and whatever sits under it stays clickable.
24
+ */
25
+ export declare function Sparkline({ data, color, strokeWidth, animated, className, ...props }: SparklineProps): import("react").JSX.Element;
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import { AREA_FADE } from "../lib/time-series.js";
3
+ import { cn } from "../lib/variants.js";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { useId } from "react";
6
+ import { area, curveMonotoneX, line } from "d3-shape";
7
+ // src/components/sparkline.tsx
8
+ /**
9
+ * The drawing box. The SVG stretches it to whatever size its class gives, and the stroke keeps
10
+ * its width through `vectorEffect`, so the box's proportions never show.
11
+ */
12
+ const WIDTH = 100;
13
+ const HEIGHT = 32;
14
+ const AREA = area().x((point) => point.x).y0(HEIGHT).y1((point) => point.y).curve(curveMonotoneX);
15
+ const LINE = line().x((point) => point.x).y((point) => point.y).curve(curveMonotoneX);
16
+ /**
17
+ * A trend at a glance: the smooth gradient area of `TimeSeriesChart` with no axes, grid,
18
+ * tooltip or hover, filling whatever box it is given. Plain SVG rather than a chart, so the
19
+ * pages that list sites never load the chart runtime for it. Purely a picture, so it takes no
20
+ * pointer events and whatever sits under it stays clickable.
21
+ */
22
+ function Sparkline({ data, color = "var(--color-chart-1)", strokeWidth = 1.5, animated = false, className, ...props }) {
23
+ const gradientId = useId();
24
+ const max = Math.max(...data, 0);
25
+ const last = Math.max(data.length - 1, 1);
26
+ const plotted = data.map((value, index) => ({
27
+ x: index / last * WIDTH,
28
+ y: 31 - value / (max || 1) * 30
29
+ }));
30
+ return /* @__PURE__ */ jsx("div", {
31
+ "aria-hidden": true,
32
+ className: cn("pointer-events-none h-16 w-full", className),
33
+ ...props,
34
+ children: /* @__PURE__ */ jsxs("svg", {
35
+ viewBox: `0 0 ${WIDTH} ${HEIGHT}`,
36
+ preserveAspectRatio: "none",
37
+ className: cn("size-full overflow-visible", animated && "animate-wipe-in motion-reduce:animate-none"),
38
+ children: [
39
+ /* @__PURE__ */ jsx("defs", { children: /* @__PURE__ */ jsx("linearGradient", {
40
+ id: gradientId,
41
+ x1: "0",
42
+ y1: "0",
43
+ x2: "0",
44
+ y2: "1",
45
+ children: AREA_FADE.map((stop) => /* @__PURE__ */ jsx("stop", {
46
+ offset: stop.offset,
47
+ stopColor: color,
48
+ stopOpacity: stop.opacity
49
+ }, stop.offset))
50
+ }) }),
51
+ /* @__PURE__ */ jsx("path", {
52
+ d: AREA(plotted) ?? void 0,
53
+ fill: `url(#${gradientId})`
54
+ }),
55
+ /* @__PURE__ */ jsx("path", {
56
+ d: LINE(plotted) ?? void 0,
57
+ fill: "none",
58
+ stroke: color,
59
+ strokeWidth,
60
+ strokeLinecap: "round",
61
+ strokeLinejoin: "round",
62
+ vectorEffect: "non-scaling-stroke"
63
+ })
64
+ ]
65
+ })
66
+ });
67
+ }
68
+ export { Sparkline };
69
+
70
+ //# sourceMappingURL=sparkline.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sparkline.js","names":[],"sources":["../../src/components/sparkline.tsx"],"sourcesContent":["\"use client\"\n\nimport { area, curveMonotoneX, line } from \"d3-shape\"\nimport { type ComponentProps, useId } from \"react\"\nimport { AREA_FADE } from \"../lib/time-series\"\nimport { cn } from \"../lib/variants\"\n\nexport type SparklineProps = Omit<ComponentProps<\"div\">, \"children\"> & {\n /** One figure per step along the line, in order. */\n data: number[]\n /**\n * Series colour; one of the `--color-chart-*` tokens.\n */\n color?: string\n /**\n * Line weight in px.\n */\n strokeWidth?: number\n /**\n * Whether the line wipes in when the element enters the page. Off by default: a line on a\n * page people return to all day would redraw on every visit.\n */\n animated?: boolean\n}\n\n/**\n * The drawing box. The SVG stretches it to whatever size its class gives, and the stroke keeps\n * its width through `vectorEffect`, so the box's proportions never show.\n */\nconst WIDTH = 100\nconst HEIGHT = 32\n/** Half a stroke at the box's top and bottom, so a line at either end is not cut in half. */\nconst INSET = 1\n\ninterface Plotted {\n x: number\n y: number\n}\n\nconst AREA = area<Plotted>()\n .x(point => point.x)\n .y0(HEIGHT)\n .y1(point => point.y)\n .curve(curveMonotoneX)\nconst LINE = line<Plotted>()\n .x(point => point.x)\n .y(point => point.y)\n .curve(curveMonotoneX)\n\n/**\n * A trend at a glance: the smooth gradient area of `TimeSeriesChart` with no axes, grid,\n * tooltip or hover, filling whatever box it is given. Plain SVG rather than a chart, so the\n * pages that list sites never load the chart runtime for it. Purely a picture, so it takes no\n * pointer events and whatever sits under it stays clickable.\n */\nexport function Sparkline({\n data,\n color = \"var(--color-chart-1)\",\n strokeWidth = 1.5,\n animated = false,\n className,\n ...props\n}: SparklineProps) {\n const gradientId = useId()\n const max = Math.max(...data, 0)\n const last = Math.max(data.length - 1, 1)\n const plotted = data.map((value, index) => ({\n x: (index / last) * WIDTH,\n // `||`: an all-zero series still draws its baseline at the bottom, not mid-box.\n // oxlint-disable-next-line typescript/prefer-nullish-coalescing\n y: HEIGHT - INSET - (value / (max || 1)) * (HEIGHT - INSET * 2),\n }))\n\n return (\n <div\n // Decorative: the figures it sketches are printed beside it.\n aria-hidden\n className={cn(\"pointer-events-none h-16 w-full\", className)}\n {...props}\n >\n <svg\n viewBox={`0 0 ${WIDTH} ${HEIGHT}`}\n preserveAspectRatio=\"none\"\n className={cn(\n \"size-full overflow-visible\",\n animated && \"animate-wipe-in motion-reduce:animate-none\",\n )}\n >\n <defs>\n <linearGradient id={gradientId} x1=\"0\" y1=\"0\" x2=\"0\" y2=\"1\">\n {AREA_FADE.map(stop => (\n <stop\n key={stop.offset}\n offset={stop.offset}\n stopColor={color}\n stopOpacity={stop.opacity}\n />\n ))}\n </linearGradient>\n </defs>\n <path d={AREA(plotted) ?? undefined} fill={`url(#${gradientId})`} />\n <path\n d={LINE(plotted) ?? undefined}\n fill=\"none\"\n stroke={color}\n strokeWidth={strokeWidth}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n vectorEffect=\"non-scaling-stroke\"\n />\n </svg>\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;AA6BA,MAAM,QAAQ;AACd,MAAM,SAAS;AASf,MAAM,OAAO,KAAc,CAAC,CACzB,GAAE,UAAS,MAAM,CAAC,CAAC,CACnB,GAAG,MAAM,CAAC,CACV,IAAG,UAAS,MAAM,CAAC,CAAC,CACpB,MAAM,cAAc;AACvB,MAAM,OAAO,KAAc,CAAC,CACzB,GAAE,UAAS,MAAM,CAAC,CAAC,CACnB,GAAE,UAAS,MAAM,CAAC,CAAC,CACnB,MAAM,cAAc;;;;;;;AAQvB,SAAgB,UAAU,EACxB,MACA,QAAQ,wBACR,cAAc,KACd,WAAW,OACX,WACA,GAAG,SACc;CACjB,MAAM,aAAa,MAAM;CACzB,MAAM,MAAM,KAAK,IAAI,GAAG,MAAM,CAAC;CAC/B,MAAM,OAAO,KAAK,IAAI,KAAK,SAAS,GAAG,CAAC;CACxC,MAAM,UAAU,KAAK,KAAK,OAAO,WAAW;EAC1C,GAAI,QAAQ,OAAQ;EAGpB,GAAG,KAAkB,SAAS,OAAO,KAAO;CAC9C,EAAE;CAEF,OACE,oBAAC,OAAD;EAEE,eAAA;EACA,WAAW,GAAG,mCAAmC,SAAS;EAC1D,GAAI;EAEJ,UAAA,qBAAC,OAAD;GACE,SAAS,OAAO,MAAM,GAAG;GACzB,qBAAoB;GACpB,WAAW,GACT,8BACA,YAAY,4CACd;GANF,UAAA;IAQE,oBAAC,QAAD,EAAA,UACE,oBAAC,kBAAD;KAAgB,IAAI;KAAY,IAAG;KAAI,IAAG;KAAI,IAAG;KAAI,IAAG;KACrD,UAAA,UAAU,KAAI,SACb,oBAAC,QAAD;MAEE,QAAQ,KAAK;MACb,WAAW;MACX,aAAa,KAAK;KACnB,GAJM,KAAK,MAIX,CACF;IACa,CAAA,EACZ,CAAA;IACN,oBAAC,QAAD;KAAM,GAAG,KAAK,OAAO,KAAK,KAAA;KAAW,MAAM,QAAQ,WAAW;IAAK,CAAA;IACnE,oBAAC,QAAD;KACE,GAAG,KAAK,OAAO,KAAK,KAAA;KACpB,MAAK;KACL,QAAQ;KACK;KACb,eAAc;KACd,gBAAe;KACf,cAAa;IACd,CAAA;GACE;;CACF,CAAA;AAET"}
@@ -0,0 +1,21 @@
1
+ import { VariantProps } from "../lib/variants.js";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ declare const stackVariants: import("tailwind-variants").TVReturnType<{
4
+ size: {
5
+ xs: string;
6
+ sm: string;
7
+ md: string;
8
+ lg: string;
9
+ };
10
+ direction: {
11
+ row: string;
12
+ column: string;
13
+ };
14
+ wrap: {
15
+ true: string;
16
+ false: string;
17
+ };
18
+ }, undefined, "flex", undefined, undefined, undefined>;
19
+ type StackProps = useRender.ComponentProps<"div"> & VariantProps<typeof stackVariants>;
20
+ declare function Stack({ className, render, size, direction, wrap, ...props }: StackProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
21
+ export { Stack };
@@ -0,0 +1,45 @@
1
+ import { variants } from "../lib/variants.js";
2
+ import { useRender } from "@base-ui/react/use-render";
3
+ // src/components/stack.tsx
4
+ const stackVariants = variants({
5
+ base: "flex",
6
+ variants: {
7
+ size: {
8
+ xs: "gap-1",
9
+ sm: "gap-x-2 gap-y-1",
10
+ md: "gap-x-3 gap-y-2",
11
+ lg: "gap-x-4 gap-y-3"
12
+ },
13
+ direction: {
14
+ row: "flex-row items-center place-content-start",
15
+ column: "flex-col items-start"
16
+ },
17
+ wrap: {
18
+ true: "flex-wrap",
19
+ false: ""
20
+ }
21
+ },
22
+ defaultVariants: {
23
+ size: "md",
24
+ direction: "row",
25
+ wrap: true
26
+ }
27
+ });
28
+ function Stack({ className, render, size, direction, wrap, ...props }) {
29
+ return useRender({
30
+ render,
31
+ defaultTagName: "div",
32
+ props: {
33
+ className: stackVariants({
34
+ size,
35
+ direction,
36
+ wrap,
37
+ className
38
+ }),
39
+ ...props
40
+ }
41
+ });
42
+ }
43
+ export { Stack };
44
+
45
+ //# sourceMappingURL=stack.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stack.js","names":[],"sources":["../../src/components/stack.tsx"],"sourcesContent":["import { useRender } from \"@base-ui/react/use-render\"\nimport { variants, type VariantProps } from \"../lib/variants\"\n\nconst stackVariants = variants({\n base: \"flex\",\n\n variants: {\n size: {\n xs: \"gap-1\",\n sm: \"gap-x-2 gap-y-1\",\n md: \"gap-x-3 gap-y-2\",\n lg: \"gap-x-4 gap-y-3\",\n },\n direction: {\n row: \"flex-row items-center place-content-start\",\n column: \"flex-col items-start\",\n },\n wrap: {\n true: \"flex-wrap\",\n false: \"\",\n },\n },\n\n defaultVariants: {\n size: \"md\",\n direction: \"row\",\n wrap: true,\n },\n})\n\ntype StackProps = useRender.ComponentProps<\"div\"> & VariantProps<typeof stackVariants>\n\nfunction Stack({ className, render, size, direction, wrap, ...props }: StackProps) {\n return useRender({\n render,\n defaultTagName: \"div\",\n props: { className: stackVariants({ size, direction, wrap, className }), ...props },\n })\n}\n\nexport { Stack }\n"],"mappings":";;;AAGA,MAAM,gBAAgB,SAAS;CAC7B,MAAM;CAEN,UAAU;EACR,MAAM;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;GACJ,IAAI;EACN;EACA,WAAW;GACT,KAAK;GACL,QAAQ;EACV;EACA,MAAM;GACJ,MAAM;GACN,OAAO;EACT;CACF;CAEA,iBAAiB;EACf,MAAM;EACN,WAAW;EACX,MAAM;CACR;AACF,CAAC;AAID,SAAS,MAAM,EAAE,WAAW,QAAQ,MAAM,WAAW,MAAM,GAAG,SAAqB;CACjF,OAAO,UAAU;EACf;EACA,gBAAgB;EAChB,OAAO;GAAE,WAAW,cAAc;IAAE;IAAM;IAAW;IAAM;GAAU,CAAC;GAAG,GAAG;EAAM;CACpF,CAAC;AACH"}
@@ -0,0 +1,43 @@
1
+ import { VariantProps } from "../lib/variants.js";
2
+ import { NumberFormat } from "./formatted-number.js";
3
+ import { useRender } from "@base-ui/react/use-render";
4
+ import { ComponentProps, ReactNode } from "react";
5
+ declare const stripVariants: import("tailwind-variants").TVReturnType<{
6
+ variant: {
7
+ plain: string;
8
+ track: string;
9
+ };
10
+ row: {
11
+ lg: string;
12
+ wide: string;
13
+ };
14
+ }, undefined, string[], undefined, undefined, undefined>;
15
+ interface StatStripProps extends Omit<ComponentProps<"div">, "ref">, VariantProps<typeof stripVariants> {}
16
+ declare function StatStrip({ className, variant, row, ...props }: StatStripProps): import("react").JSX.Element;
17
+ type StatStripItemProps = Omit<useRender.ComponentProps<"div">, "children" | "onSelect"> & {
18
+ label: string;
19
+ /** The full name a screen reader hears where `label` shortens it ("Revenue per visitor"). */
20
+ name?: string;
21
+ /**
22
+ * A number (or a string) is formatted with `format`; any other node renders as is.
23
+ */
24
+ value: ReactNode;
25
+ format?: NumberFormat;
26
+ /** A line under the figure: what it counts, or the figure it is compared with. */
27
+ hint?: ReactNode;
28
+ /** Folds the hint line away; keep passing the hint so the line has its text as it closes. */
29
+ hintHidden?: boolean;
30
+ /**
31
+ * Rendered at the end of the label row, e.g. a change against a previous period.
32
+ */
33
+ trend?: ReactNode;
34
+ /** Marks the item as the one driving the panel beside it. */
35
+ selected?: boolean;
36
+ /**
37
+ * Makes the item a toggle button for the panel beside it, pressed while `selected`. Its label
38
+ * and figure stay its name, so a screen reader hears the number with the label.
39
+ */
40
+ onSelect?: () => void;
41
+ };
42
+ declare function StatStripItem({ label, name, value, format, hint, hintHidden, trend, selected, onSelect, render, className, ...props }: StatStripItemProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
43
+ export { StatStrip, StatStripItem };
@@ -0,0 +1,151 @@
1
+ "use client";
2
+ import { formatIdList } from "../lib/aria.js";
3
+ import { figureClasses } from "../lib/classes.js";
4
+ import { cn, variants } from "../lib/variants.js";
5
+ import { cardSurfaceClasses } from "./card.js";
6
+ import { Collapse } from "./collapse.js";
7
+ import { FormattedNumber } from "./formatted-number.js";
8
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
9
+ import { useRender } from "@base-ui/react/use-render";
10
+ import { isValidElement, useCallback, useId, useLayoutEffect, useRef } from "react";
11
+ // src/components/stat-strip.tsx
12
+ const stripVariants = variants({
13
+ base: ["@container group/strip grid grid-cols-2 max-sm:[&>*:last-child:nth-child(odd)]:col-span-2", "sm:grid-cols-3 sm:[&>*:last-child:nth-child(3n+1)]:col-span-3 sm:[&>*:last-child:nth-child(3n+2)]:col-span-2"],
14
+ variants: {
15
+ variant: {
16
+ plain: cardSurfaceClasses,
17
+ track: ""
18
+ },
19
+ row: {
20
+ lg: "lg:flex lg:flex-wrap",
21
+ wide: "min-[1360px]:flex min-[1360px]:flex-wrap"
22
+ }
23
+ },
24
+ defaultVariants: {
25
+ variant: "plain",
26
+ row: "lg"
27
+ }
28
+ });
29
+ /**
30
+ * Shrinks every figure of the strip by the same factor until the widest one fits its cell, so
31
+ * figures stay one size across the strip and none is cut off. A figure's length depends on the
32
+ * reader's language ("12.6K" in English, "12,6 tys." in Polish), so the fit is measured, not
33
+ * assumed.
34
+ *
35
+ * Text width is proportional to font size, so a figure's full-size width is its width now over
36
+ * the factor now: one pass of reads and at most one write, with no reset to full size and the
37
+ * second layout that would cost on every frame of a window resize. The factor is written only
38
+ * when it changes, and a figure that got shorter grows back.
39
+ */
40
+ function useFigureFit() {
41
+ const ref = useRef(null);
42
+ const fit = useCallback(() => {
43
+ const strip = ref.current;
44
+ if (!strip) return;
45
+ const current = Number(strip.style.getPropertyValue("--stat-fit")) || 1;
46
+ let scale = 1;
47
+ for (const text of strip.querySelectorAll("[data-value] > [data-figure]")) {
48
+ const available = (text.parentElement?.clientWidth ?? 0) - 2;
49
+ const needed = text.getBoundingClientRect().width / current;
50
+ if (needed > available) scale = Math.min(scale, available / needed);
51
+ }
52
+ const next = Math.floor(scale * 100) / 100;
53
+ if (next !== current) strip.style.setProperty("--stat-fit", String(next));
54
+ }, []);
55
+ useLayoutEffect(fit);
56
+ useLayoutEffect(() => {
57
+ const strip = ref.current;
58
+ if (!strip) return;
59
+ let width = 0;
60
+ const observer = new ResizeObserver(([entry]) => {
61
+ if (!entry || entry.contentRect.width === width) return;
62
+ width = entry.contentRect.width;
63
+ fit();
64
+ });
65
+ observer.observe(strip);
66
+ return () => observer.disconnect();
67
+ }, [fit]);
68
+ return ref;
69
+ }
70
+ function StatStrip({ className, variant, row, ...props }) {
71
+ const ref = useFigureFit();
72
+ return /* @__PURE__ */ jsx("div", {
73
+ ref,
74
+ "data-row": row ?? "lg",
75
+ className: stripVariants({
76
+ variant,
77
+ row,
78
+ className
79
+ }),
80
+ ...props
81
+ });
82
+ }
83
+ const valueClasses = cn(figureClasses, "mt-0.5 truncate text-[calc(clamp(1.125rem,8cqw,1.75rem)*var(--stat-fit,1))] leading-figure sm:mt-1", "sm:text-[calc(clamp(1.125rem,5cqw,1.75rem)*var(--stat-fit,1))]", "group-data-[row=lg]/strip:lg:text-[calc(clamp(1.125rem,3.3cqw,1.75rem)*var(--stat-fit,1))]", "group-data-[row=wide]/strip:min-[1360px]:text-[calc(clamp(1.125rem,2.2cqw,1.75rem)*var(--stat-fit,1))]");
84
+ function StatStripItem({ label, name, value, format, hint, hintHidden, trend, selected, onSelect, render, className, ...props }) {
85
+ const id = useId();
86
+ const button = onSelect && /* @__PURE__ */ jsx("button", {
87
+ type: "button",
88
+ "aria-pressed": !!selected,
89
+ "aria-labelledby": `${id}-label ${id}-value`,
90
+ "aria-describedby": formatIdList(!!trend && `${id}-trend`, !!hint && !hintHidden && `${id}-hint`),
91
+ onClick: () => onSelect()
92
+ });
93
+ return useRender({
94
+ render: render ?? button,
95
+ defaultTagName: "div",
96
+ props: {
97
+ "data-selected": selected ? true : void 0,
98
+ className: cn("group/stat relative min-w-0 flex-1 px-[clamp(1rem,2cqw,1.5rem)] py-[clamp(0.75rem,1.5cqw,1.25rem)] text-start", "before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-edge", "first:before:hidden max-sm:[&:nth-child(odd)]:before:hidden", "group-data-[row=lg]/strip:sm:max-lg:[&:nth-child(3n+1)]:before:hidden", "group-data-[row=wide]/strip:sm:max-[1360px]:[&:nth-child(3n+1)]:before:hidden", "after:absolute after:inset-x-0 after:top-0 after:hidden after:h-px after:bg-edge", "max-sm:[&:nth-child(n+3)]:after:block", "group-data-[row=lg]/strip:sm:max-lg:[&:nth-child(n+4)]:after:block", "group-data-[row=wide]/strip:sm:max-[1360px]:[&:nth-child(n+4)]:after:block", "data-selected:[&_[data-label]]:text-ink", "[&:is(button)]:hover:not-data-selected:[&_[data-label]]:text-ink-secondary", "focus-visible:outline-offset-[-2px]", className),
99
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
100
+ /* @__PURE__ */ jsx("span", {
101
+ "aria-hidden": true,
102
+ className: cn("absolute inset-x-0 bottom-0 h-0.5 bg-chart-1 opacity-0", onSelect && "group-hover/stat:opacity-35", "group-data-selected/stat:opacity-100!")
103
+ }),
104
+ /* @__PURE__ */ jsxs("p", {
105
+ "data-label": true,
106
+ className: "flex items-baseline justify-between gap-2 text-ink-muted text-sm",
107
+ children: [/* @__PURE__ */ jsx("span", {
108
+ id: `${id}-label`,
109
+ className: "min-w-0 truncate",
110
+ children: name ? /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("span", {
111
+ "aria-hidden": true,
112
+ children: label
113
+ }), /* @__PURE__ */ jsx("span", {
114
+ className: "sr-only",
115
+ children: name
116
+ })] }) : label
117
+ }), trend && /* @__PURE__ */ jsx("span", {
118
+ id: `${id}-trend`,
119
+ className: "shrink-0",
120
+ children: trend
121
+ })]
122
+ }),
123
+ /* @__PURE__ */ jsx("p", {
124
+ id: `${id}-value`,
125
+ "data-value": true,
126
+ className: valueClasses,
127
+ children: /* @__PURE__ */ jsx("span", {
128
+ "data-figure": true,
129
+ children: isValidElement(value) || typeof value !== "number" && typeof value !== "string" ? value : /* @__PURE__ */ jsx(FormattedNumber, {
130
+ value,
131
+ format
132
+ })
133
+ })
134
+ }),
135
+ hint && /* @__PURE__ */ jsx(Collapse, {
136
+ open: !hintHidden,
137
+ className: hintHidden ? "duration-200" : void 0,
138
+ children: /* @__PURE__ */ jsx("p", {
139
+ id: `${id}-hint`,
140
+ className: cn("truncate text-ink-muted text-sm", "transition-[translate,filter] duration-250 ease-out-expo motion-reduce:transition-none", hintHidden && "-translate-y-1.5 blur-[4px]"),
141
+ children: hint
142
+ })
143
+ })
144
+ ] }),
145
+ ...props
146
+ }
147
+ });
148
+ }
149
+ export { StatStrip, StatStripItem };
150
+
151
+ //# sourceMappingURL=stat-strip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"stat-strip.js","names":[],"sources":["../../src/components/stat-strip.tsx"],"sourcesContent":["\"use client\"\n\nimport { useRender } from \"@base-ui/react/use-render\"\nimport {\n type ComponentProps,\n isValidElement,\n type ReactNode,\n useCallback,\n useLayoutEffect,\n useId,\n useRef,\n} from \"react\"\nimport { formatIdList } from \"../lib/aria\"\nimport { figureClasses } from \"../lib/classes\"\nimport { cn, variants, type VariantProps } from \"../lib/variants\"\nimport { cardSurfaceClasses } from \"./card\"\nimport { Collapse } from \"./collapse\"\nimport { FormattedNumber, type NumberFormat } from \"./formatted-number\"\n\nconst stripVariants = variants({\n // Stacked in a tighter cut (see the item) until there is room for one row: two-up on a\n // phone, three-up from a tablet, then a flex row that fits however many stats there are.\n // A short last row stretches to the strip's edge instead of leaving an empty cell: a lone\n // last tile spans the row on a phone, and at three-up the last tile takes whatever the row\n // has left (four stats read three and one, five read three and two).\n // A container, so a figure can be sized against the whole strip rather than its own cell.\n base: [\n \"@container group/strip grid grid-cols-2 max-sm:[&>*:last-child:nth-child(odd)]:col-span-2\",\n \"sm:grid-cols-3 sm:[&>*:last-child:nth-child(3n+1)]:col-span-3 sm:[&>*:last-child:nth-child(3n+2)]:col-span-2\",\n ],\n\n variants: {\n variant: {\n // A white card of figures on its own, divided by full-height hairlines.\n plain: cardSurfaceClasses,\n // The same row as a band of the card it shares with something else, most often the\n // chart the selected figure draws: no surface of its own, and the panel below it\n // carries the hairline that closes the band.\n track: \"\",\n },\n\n // Where the stacked grid gives way to one row. A cell of that row is the full width over\n // the number of stats, so how early it can happen is the caller's to know. `lg` carries\n // up to four stats, which are comfortable on a laptop. `wide` carries up to six with a\n // change beside each label: a label of about twelve characters plus a percentage holds\n // from 1360px up and clips at `xl`.\n row: {\n lg: \"lg:flex lg:flex-wrap\",\n wide: \"min-[1360px]:flex min-[1360px]:flex-wrap\",\n },\n },\n\n defaultVariants: {\n variant: \"plain\",\n row: \"lg\",\n },\n})\n\n/**\n * Shrinks every figure of the strip by the same factor until the widest one fits its cell, so\n * figures stay one size across the strip and none is cut off. A figure's length depends on the\n * reader's language (\"12.6K\" in English, \"12,6 tys.\" in Polish), so the fit is measured, not\n * assumed.\n *\n * Text width is proportional to font size, so a figure's full-size width is its width now over\n * the factor now: one pass of reads and at most one write, with no reset to full size and the\n * second layout that would cost on every frame of a window resize. The factor is written only\n * when it changes, and a figure that got shorter grows back.\n */\nfunction useFigureFit() {\n const ref = useRef<HTMLDivElement>(null)\n\n const fit = useCallback(() => {\n const strip = ref.current\n if (!strip) return\n\n // `||`, not `??`: an unset property reads as \"\" and so as 0, which means full size.\n const current = Number(strip.style.getPropertyValue(\"--stat-fit\")) || 1\n let scale = 1\n\n // The text's own width against its line's: a truncated line reports no overflow through\n // `scrollWidth`, since the ellipsis is what fills it. The browser truncates a figure that\n // fits to within a pixel, so the line is taken as two pixels narrower than it is.\n for (const text of strip.querySelectorAll<HTMLElement>(\"[data-value] > [data-figure]\")) {\n const available = (text.parentElement?.clientWidth ?? 0) - 2\n const needed = text.getBoundingClientRect().width / current\n if (needed > available) scale = Math.min(scale, available / needed)\n }\n\n // Rounded down, so a figure that fits by a subpixel is not cut off by rounding up.\n const next = Math.floor(scale * 100) / 100\n if (next !== current) strip.style.setProperty(\"--stat-fit\", String(next))\n }, [])\n\n // Every render, since any figure may have changed.\n useLayoutEffect(fit)\n\n // A cell's width follows the strip's, and the layout steps between two-up, three-up and one\n // row. Only a width change refits: the refit itself changes the strip's height. The observer\n // runs after layout, so its reads are free.\n useLayoutEffect(() => {\n const strip = ref.current\n if (!strip) return\n\n let width = 0\n const observer = new ResizeObserver(([entry]) => {\n if (!entry || entry.contentRect.width === width) return\n width = entry.contentRect.width\n fit()\n })\n\n observer.observe(strip)\n return () => observer.disconnect()\n }, [fit])\n\n return ref\n}\n\ninterface StatStripProps\n extends Omit<ComponentProps<\"div\">, \"ref\">, VariantProps<typeof stripVariants> {}\n\nfunction StatStrip({ className, variant, row, ...props }: StatStripProps) {\n const ref = useFigureFit()\n\n return (\n <div\n ref={ref}\n data-row={row ?? \"lg\"}\n className={stripVariants({ variant, row, className })}\n {...props}\n />\n )\n}\n\n// Sized against the strip (`cqw`, the strip being the container) rather than its own cell, so\n// every figure in a strip comes out the same size. The share follows the layout: half the\n// strip per cell while the grid is two-up, a third three-up, and in one row the most cells\n// the row variant carries: a quarter for `lg`, a sixth for `wide`. Measured: ~26px on a\n// phone; in one row, the 28px cap from about 850px of `lg` strip and 1270px of `wide` strip,\n// with the 18px floor never binding. Tabular digits are wider than proportional ones, so the\n// shares are 3.3% and 2.2% and the cap 28: a \"$30.6K\" fits its cell. A longer figure (a\n// language that abbreviates in more letters) scales the whole strip down by `--stat-fit`.\nconst valueClasses = cn(\n // Tabular, so a figure that repolls in place or steps on a range change does not nudge\n // what sits beside it.\n figureClasses,\n \"mt-0.5 truncate text-[calc(clamp(1.125rem,8cqw,1.75rem)*var(--stat-fit,1))] leading-figure sm:mt-1\",\n \"sm:text-[calc(clamp(1.125rem,5cqw,1.75rem)*var(--stat-fit,1))]\",\n \"group-data-[row=lg]/strip:lg:text-[calc(clamp(1.125rem,3.3cqw,1.75rem)*var(--stat-fit,1))]\",\n \"group-data-[row=wide]/strip:min-[1360px]:text-[calc(clamp(1.125rem,2.2cqw,1.75rem)*var(--stat-fit,1))]\",\n)\n\ntype StatStripItemProps = Omit<useRender.ComponentProps<\"div\">, \"children\" | \"onSelect\"> & {\n label: string\n /** The full name a screen reader hears where `label` shortens it (\"Revenue per visitor\"). */\n name?: string\n /**\n * A number (or a string) is formatted with `format`; any other node renders as is.\n */\n value: ReactNode\n format?: NumberFormat\n /** A line under the figure: what it counts, or the figure it is compared with. */\n hint?: ReactNode\n /** Folds the hint line away; keep passing the hint so the line has its text as it closes. */\n hintHidden?: boolean\n /**\n * Rendered at the end of the label row, e.g. a change against a previous period.\n */\n trend?: ReactNode\n /** Marks the item as the one driving the panel beside it. */\n selected?: boolean\n /**\n * Makes the item a toggle button for the panel beside it, pressed while `selected`. Its label\n * and figure stay its name, so a screen reader hears the number with the label.\n */\n onSelect?: () => void\n}\n\nfunction StatStripItem({\n label,\n name,\n value,\n format,\n hint,\n hintHidden,\n trend,\n selected,\n onSelect,\n render,\n className,\n ...props\n}: StatStripItemProps) {\n const id = useId()\n // Named by the label and the figure alone (\"Visitors 1,234\"), so the change and the hint\n // read after them as its description rather than running into the number.\n const button = onSelect && (\n <button\n type=\"button\"\n aria-pressed={!!selected}\n aria-labelledby={`${id}-label ${id}-value`}\n aria-describedby={formatIdList(\n !!trend && `${id}-trend`,\n !!hint && !hintHidden && `${id}-hint`,\n )}\n onClick={() => onSelect()}\n />\n )\n\n return useRender({\n render: render ?? button,\n defaultTagName: \"div\",\n props: {\n \"data-selected\": selected ? true : undefined,\n className: cn(\n // The inset scales with the strip like the figure does, so a cell keeps its proportions\n // from a phone (16/12) up to the full desktop row (24/20).\n \"group/stat relative min-w-0 flex-1 px-[clamp(1rem,2cqw,1.5rem)] py-[clamp(0.75rem,1.5cqw,1.25rem)] text-start\",\n // Hairline divider before every neighbour: between the columns while the strip is\n // stacked, then between the cells of the single row. Hidden on whichever item starts\n // a row, which is every other one at two-up and every third at three-up.\n \"before:absolute before:inset-y-0 before:left-0 before:w-px before:bg-edge\",\n \"first:before:hidden max-sm:[&:nth-child(odd)]:before:hidden\",\n \"group-data-[row=lg]/strip:sm:max-lg:[&:nth-child(3n+1)]:before:hidden\",\n \"group-data-[row=wide]/strip:sm:max-[1360px]:[&:nth-child(3n+1)]:before:hidden\",\n // And one above every row after the first while the strip is stacked: from the third\n // item at two-up, the fourth at three-up. The single row has nothing above it.\n \"after:absolute after:inset-x-0 after:top-0 after:hidden after:h-px after:bg-edge\",\n \"max-sm:[&:nth-child(n+3)]:after:block\",\n \"group-data-[row=lg]/strip:sm:max-lg:[&:nth-child(n+4)]:after:block\",\n \"group-data-[row=wide]/strip:sm:max-[1360px]:[&:nth-child(n+4)]:after:block\",\n // The selected cell carries a 2px bar in the first series colour along its bottom edge,\n // where the chart it picks begins, as a tab marks its panel; the hairlines either side\n // stay. The value is full-strength whichever way; the label is muted until the cell is\n // selected.\n \"data-selected:[&_[data-label]]:text-ink\",\n // A cell other than the selected one answers the pointer as a tab does, with no fill: its\n // label steps up one shade, short of the selected ink, and the bar shows faintly.\n \"[&:is(button)]:hover:not-data-selected:[&_[data-label]]:text-ink-secondary\",\n // A surface that clips would cut a focus outline drawn past a flush cell, so the\n // outline sits inside the cell instead.\n \"focus-visible:outline-offset-[-2px]\",\n className,\n ),\n children: (\n <>\n {/* One bar for both states, so a click on a hovered cell only strengthens it. */}\n <span\n aria-hidden\n className={cn(\n \"absolute inset-x-0 bottom-0 h-0.5 bg-chart-1 opacity-0\",\n onSelect && \"group-hover/stat:opacity-35\",\n \"group-data-selected/stat:opacity-100!\",\n )}\n />\n <p\n data-label\n className=\"flex items-baseline justify-between gap-2 text-ink-muted text-sm\"\n >\n <span id={`${id}-label`} className=\"min-w-0 truncate\">\n {name ? (\n <>\n <span aria-hidden>{label}</span>\n <span className=\"sr-only\">{name}</span>\n </>\n ) : (\n label\n )}\n </span>\n {trend && (\n <span id={`${id}-trend`} className=\"shrink-0\">\n {trend}\n </span>\n )}\n </p>\n\n <p id={`${id}-value`} data-value className={valueClasses}>\n <span data-figure>\n {isValidElement(value) || (typeof value !== \"number\" && typeof value !== \"string\") ? (\n value\n ) : (\n <FormattedNumber value={value} format={format} />\n )}\n </span>\n </p>\n\n {hint && (\n <Collapse open={!hintHidden} className={hintHidden ? \"duration-200\" : undefined}>\n <p\n id={`${id}-hint`}\n className={cn(\n \"truncate text-ink-muted text-sm\",\n \"transition-[translate,filter] duration-250 ease-out-expo motion-reduce:transition-none\",\n hintHidden && \"-translate-y-1.5 blur-[4px]\",\n )}\n >\n {hint}\n </p>\n </Collapse>\n )}\n </>\n ),\n ...props,\n },\n })\n}\n\nexport { StatStrip, StatStripItem }\n"],"mappings":";;;;;;;;;;;AAmBA,MAAM,gBAAgB,SAAS;CAO7B,MAAM,CACJ,6FACA,8GACF;CAEA,UAAU;EACR,SAAS;GAEP,OAAO;GAIP,OAAO;EACT;EAOA,KAAK;GACH,IAAI;GACJ,MAAM;EACR;CACF;CAEA,iBAAiB;EACf,SAAS;EACT,KAAK;CACP;AACF,CAAC;;;;;;;;;;;;AAaD,SAAS,eAAe;CACtB,MAAM,MAAM,OAAuB,IAAI;CAEvC,MAAM,MAAM,kBAAkB;EAC5B,MAAM,QAAQ,IAAI;EAClB,IAAI,CAAC,OAAO;EAGZ,MAAM,UAAU,OAAO,MAAM,MAAM,iBAAiB,YAAY,CAAC,KAAK;EACtE,IAAI,QAAQ;EAKZ,KAAK,MAAM,QAAQ,MAAM,iBAA8B,8BAA8B,GAAG;GACtF,MAAM,aAAa,KAAK,eAAe,eAAe,KAAK;GAC3D,MAAM,SAAS,KAAK,sBAAsB,CAAC,CAAC,QAAQ;GACpD,IAAI,SAAS,WAAW,QAAQ,KAAK,IAAI,OAAO,YAAY,MAAM;EACpE;EAGA,MAAM,OAAO,KAAK,MAAM,QAAQ,GAAG,IAAI;EACvC,IAAI,SAAS,SAAS,MAAM,MAAM,YAAY,cAAc,OAAO,IAAI,CAAC;CAC1E,GAAG,CAAC,CAAC;CAGL,gBAAgB,GAAG;CAKnB,sBAAsB;EACpB,MAAM,QAAQ,IAAI;EAClB,IAAI,CAAC,OAAO;EAEZ,IAAI,QAAQ;EACZ,MAAM,WAAW,IAAI,gBAAgB,CAAC,WAAW;GAC/C,IAAI,CAAC,SAAS,MAAM,YAAY,UAAU,OAAO;GACjD,QAAQ,MAAM,YAAY;GAC1B,IAAI;EACN,CAAC;EAED,SAAS,QAAQ,KAAK;EACtB,aAAa,SAAS,WAAW;CACnC,GAAG,CAAC,GAAG,CAAC;CAER,OAAO;AACT;AAKA,SAAS,UAAU,EAAE,WAAW,SAAS,KAAK,GAAG,SAAyB;CACxE,MAAM,MAAM,aAAa;CAEzB,OACE,oBAAC,OAAD;EACO;EACL,YAAU,OAAO;EACjB,WAAW,cAAc;GAAE;GAAS;GAAK;EAAU,CAAC;EACpD,GAAI;CACL,CAAA;AAEL;AAUA,MAAM,eAAe,GAGnB,eACA,sGACA,kEACA,8FACA,wGACF;AA4BA,SAAS,cAAc,EACrB,OACA,MACA,OACA,QACA,MACA,YACA,OACA,UACA,UACA,QACA,WACA,GAAG,SACkB;CACrB,MAAM,KAAK,MAAM;CAGjB,MAAM,SAAS,YACb,oBAAC,UAAD;EACE,MAAK;EACL,gBAAc,CAAC,CAAC;EAChB,mBAAiB,GAAG,GAAG,SAAS,GAAG;EACnC,oBAAkB,aAChB,CAAC,CAAC,SAAS,GAAG,GAAG,SACjB,CAAC,CAAC,QAAQ,CAAC,cAAc,GAAG,GAAG,MACjC;EACA,eAAe,SAAS;CACzB,CAAA;CAGH,OAAO,UAAU;EACf,QAAQ,UAAU;EAClB,gBAAgB;EAChB,OAAO;GACL,iBAAiB,WAAW,OAAO,KAAA;GACnC,WAAW,GAGT,iHAIA,6EACA,+DACA,yEACA,iFAGA,oFACA,yCACA,sEACA,8EAKA,2CAGA,8EAGA,uCACA,SACF;GACA,UACE,qBAAA,UAAA,EAAA,UAAA;IAEE,oBAAC,QAAD;KACE,eAAA;KACA,WAAW,GACT,0DACA,YAAY,+BACZ,uCACF;IACD,CAAA;IACD,qBAAC,KAAD;KACE,cAAA;KACA,WAAU;KAFZ,UAAA,CAIE,oBAAC,QAAD;MAAM,IAAI,GAAG,GAAG;MAAS,WAAU;MAChC,UAAA,OACC,qBAAA,UAAA,EAAA,UAAA,CACE,oBAAC,QAAD;OAAM,eAAA;OAAa,UAAA;MAAY,CAAA,GAC/B,oBAAC,QAAD;OAAM,WAAU;OAAW,UAAA;MAAW,CAAA,CACtC,EAAA,CAAA,IAEF;KAEE,CAAA,GACL,SACC,oBAAC,QAAD;MAAM,IAAI,GAAG,GAAG;MAAS,WAAU;MAChC,UAAA;KACG,CAAA,CAEP;;IAEH,oBAAC,KAAD;KAAG,IAAI,GAAG,GAAG;KAAS,cAAA;KAAW,WAAW;KAC1C,UAAA,oBAAC,QAAD;MAAM,eAAA;MACH,UAAA,eAAe,KAAK,KAAM,OAAO,UAAU,YAAY,OAAO,UAAU,WACvE,QAEA,oBAAC,iBAAD;OAAwB;OAAe;MAAS,CAAA;KAE9C,CAAA;IACL,CAAA;IAEF,QACC,oBAAC,UAAD;KAAU,MAAM,CAAC;KAAY,WAAW,aAAa,iBAAiB,KAAA;KACpE,UAAA,oBAAC,KAAD;MACE,IAAI,GAAG,GAAG;MACV,WAAW,GACT,mCACA,0FACA,cAAc,6BAChB;MAEC,UAAA;KACA,CAAA;IACK,CAAA;GAEZ,EAAA,CAAA;GAEJ,GAAG;EACL;CACF,CAAC;AACH"}
@@ -0,0 +1,19 @@
1
+ import { ComponentProps } from "react";
2
+ type StepsProps = ComponentProps<"div"> & {
3
+ /**
4
+ * The step in progress, 1-based. Past `total` every bar reads as done, which is the state
5
+ * a flow ends on: nothing is in progress any more.
6
+ */
7
+ current: number;
8
+ /**
9
+ * The total number of steps.
10
+ */
11
+ total: number;
12
+ };
13
+ /**
14
+ * Segmented progress bars for multi-step flows: a done step is the page's ink, the step in
15
+ * progress is a shade lighter and animates in, and the ones ahead are the hairline colour.
16
+ * Screen readers get "Step n of m", announced again whenever the step changes.
17
+ */
18
+ export declare function Steps({ className, current, total, ...props }: StepsProps): import("react").JSX.Element;
19
+ export {};
@@ -0,0 +1,25 @@
1
+ import { cn } from "../lib/variants.js";
2
+ import { jsx, jsxs } from "react/jsx-runtime";
3
+ // src/components/steps.tsx
4
+ /**
5
+ * Segmented progress bars for multi-step flows: a done step is the page's ink, the step in
6
+ * progress is a shade lighter and animates in, and the ones ahead are the hairline colour.
7
+ * Screen readers get "Step n of m", announced again whenever the step changes.
8
+ */
9
+ function Steps({ className, current, total, ...props }) {
10
+ return /* @__PURE__ */ jsxs("div", {
11
+ className: cn("flex gap-1.5", className),
12
+ ...props,
13
+ children: [/* @__PURE__ */ jsx("p", {
14
+ "aria-live": "polite",
15
+ className: "sr-only",
16
+ children: current > total ? "All steps complete" : `Step ${current} of ${total}`
17
+ }), Array.from({ length: total }, (_, index) => /* @__PURE__ */ jsx("div", {
18
+ "aria-hidden": true,
19
+ className: cn("h-1 flex-1 rounded-full transition-colors duration-300 ease-out-expo", index < current - 1 && "bg-ink", index === current - 1 && "origin-left animate-fill-bar bg-ink-muted motion-reduce:animate-none", index > current - 1 && "bg-edge")
20
+ }, index))]
21
+ });
22
+ }
23
+ export { Steps };
24
+
25
+ //# sourceMappingURL=steps.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"steps.js","names":[],"sources":["../../src/components/steps.tsx"],"sourcesContent":["import type { ComponentProps } from \"react\"\nimport { cn } from \"../lib/variants\"\n\ntype StepsProps = ComponentProps<\"div\"> & {\n /**\n * The step in progress, 1-based. Past `total` every bar reads as done, which is the state\n * a flow ends on: nothing is in progress any more.\n */\n current: number\n\n /**\n * The total number of steps.\n */\n total: number\n}\n\n/**\n * Segmented progress bars for multi-step flows: a done step is the page's ink, the step in\n * progress is a shade lighter and animates in, and the ones ahead are the hairline colour.\n * Screen readers get \"Step n of m\", announced again whenever the step changes.\n */\nexport function Steps({ className, current, total, ...props }: StepsProps) {\n return (\n <div className={cn(\"flex gap-1.5\", className)} {...props}>\n <p aria-live=\"polite\" className=\"sr-only\">\n {current > total ? \"All steps complete\" : `Step ${current} of ${total}`}\n </p>\n\n {Array.from({ length: total }, (_, index) => (\n <div\n key={index}\n aria-hidden\n className={cn(\n \"h-1 flex-1 rounded-full transition-colors duration-300 ease-out-expo\",\n index < current - 1 && \"bg-ink\",\n index === current - 1 &&\n \"origin-left animate-fill-bar bg-ink-muted motion-reduce:animate-none\",\n index > current - 1 && \"bg-edge\",\n )}\n />\n ))}\n </div>\n )\n}\n"],"mappings":";;;;;;;;AAqBA,SAAgB,MAAM,EAAE,WAAW,SAAS,OAAO,GAAG,SAAqB;CACzE,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,gBAAgB,SAAS;EAAG,GAAI;EAAnD,UAAA,CACE,oBAAC,KAAD;GAAG,aAAU;GAAS,WAAU;GAC7B,UAAA,UAAU,QAAQ,uBAAuB,QAAQ,QAAQ,MAAM;EAC/D,CAAA,GAEF,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,UACjC,oBAAC,OAAD;GAEE,eAAA;GACA,WAAW,GACT,wEACA,QAAQ,UAAU,KAAK,UACvB,UAAU,UAAU,KAClB,wEACF,QAAQ,UAAU,KAAK,SACzB;EACD,GATM,KASN,CACF,CACE;;AAET"}
@@ -0,0 +1,16 @@
1
+ import { Switch as Switch$1 } from "@base-ui/react/switch";
2
+ /**
3
+ * Base UI renders the switch as a `<span role="switch">`, so a disabled one carries
4
+ * `data-disabled` and never matches `:disabled`: the state and hover rules key off the data
5
+ * attribute, and the shared pointer cursor is set here for the same reason.
6
+ *
7
+ * The knob is a raised key inset 2px in the track, a well with no edge of its own, the way the
8
+ * chosen option of a segmented control sits in its row. Both are pills, so the knob's curve
9
+ * follows the track's at any inset.
10
+ * Off, the track is the well and the knob carries the strong edge, which darkens under the
11
+ * pointer as a checkbox's does. On, the track and the knob's edge take the brand, the track at
12
+ * 80% so it sits a shade lighter than the knob's edge. In dark the knob is the lighter part: mid
13
+ * grey on the well, near white on the brand.
14
+ */
15
+ declare function Switch({ className, ...props }: Switch$1.Root.Props): import("react").JSX.Element;
16
+ export { Switch };
@@ -0,0 +1,29 @@
1
+ "use client";
2
+ import { interactiveVariants } from "../lib/interactive.js";
3
+ import { cn } from "../lib/variants.js";
4
+ import { jsx } from "react/jsx-runtime";
5
+ import { Switch as Switch$1 } from "@base-ui/react/switch";
6
+ // src/components/switch.tsx
7
+ /**
8
+ * Base UI renders the switch as a `<span role="switch">`, so a disabled one carries
9
+ * `data-disabled` and never matches `:disabled`: the state and hover rules key off the data
10
+ * attribute, and the shared pointer cursor is set here for the same reason.
11
+ *
12
+ * The knob is a raised key inset 2px in the track, a well with no edge of its own, the way the
13
+ * chosen option of a segmented control sits in its row. Both are pills, so the knob's curve
14
+ * follows the track's at any inset.
15
+ * Off, the track is the well and the knob carries the strong edge, which darkens under the
16
+ * pointer as a checkbox's does. On, the track and the knob's edge take the brand, the track at
17
+ * 80% so it sits a shade lighter than the knob's edge. In dark the knob is the lighter part: mid
18
+ * grey on the well, near white on the brand.
19
+ */
20
+ function Switch({ className, ...props }) {
21
+ return /* @__PURE__ */ jsx(Switch$1.Root, {
22
+ className: cn(interactiveVariants({ interactive: false }), "group/switch inline-flex h-5 w-9 shrink-0 items-center rounded-full p-0.5 shadow-well", "data-unchecked:bg-well data-checked:bg-brand/80 aria-invalid:data-unchecked:bg-danger-subtle", "not-data-disabled:not-aria-disabled:cursor-pointer", "data-disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50", className),
23
+ ...props,
24
+ children: /* @__PURE__ */ jsx(Switch$1.Thumb, { className: cn("pointer-events-none block size-4 rounded-full border border-edge-strong bg-knob shadow-control transition-[translate,border-color,background-color] duration-200 ease-out-expo", "group-hover/switch:not-data-checked:not-data-disabled:border-edge-solid", "data-checked:translate-x-4 data-checked:border-brand data-checked:bg-knob-on") })
25
+ });
26
+ }
27
+ export { Switch };
28
+
29
+ //# sourceMappingURL=switch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"switch.js","names":["SwitchPrimitive"],"sources":["../../src/components/switch.tsx"],"sourcesContent":["\"use client\"\n\nimport { Switch as SwitchPrimitive } from \"@base-ui/react/switch\"\nimport { interactiveVariants } from \"../lib/interactive\"\nimport { cn } from \"../lib/variants\"\n\n/**\n * Base UI renders the switch as a `<span role=\"switch\">`, so a disabled one carries\n * `data-disabled` and never matches `:disabled`: the state and hover rules key off the data\n * attribute, and the shared pointer cursor is set here for the same reason.\n *\n * The knob is a raised key inset 2px in the track, a well with no edge of its own, the way the\n * chosen option of a segmented control sits in its row. Both are pills, so the knob's curve\n * follows the track's at any inset.\n * Off, the track is the well and the knob carries the strong edge, which darkens under the\n * pointer as a checkbox's does. On, the track and the knob's edge take the brand, the track at\n * 80% so it sits a shade lighter than the knob's edge. In dark the knob is the lighter part: mid\n * grey on the well, near white on the brand.\n */\nfunction Switch({ className, ...props }: SwitchPrimitive.Root.Props) {\n // Merged outside `variants`, which cannot take Base UI's state-function `className`.\n return (\n <SwitchPrimitive.Root\n className={cn(\n interactiveVariants({ interactive: false }),\n \"group/switch inline-flex h-5 w-9 shrink-0 items-center rounded-full p-0.5 shadow-well\",\n \"data-unchecked:bg-well data-checked:bg-brand/80 aria-invalid:data-unchecked:bg-danger-subtle\",\n \"not-data-disabled:not-aria-disabled:cursor-pointer\",\n \"data-disabled:opacity-50 aria-disabled:cursor-not-allowed aria-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n <SwitchPrimitive.Thumb\n className={cn(\n \"pointer-events-none block size-4 rounded-full border border-edge-strong bg-knob shadow-control transition-[translate,border-color,background-color] duration-200 ease-out-expo\",\n \"group-hover/switch:not-data-checked:not-data-disabled:border-edge-solid\",\n \"data-checked:translate-x-4 data-checked:border-brand data-checked:bg-knob-on\",\n )}\n />\n </SwitchPrimitive.Root>\n )\n}\n\nexport { Switch }\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAmBA,SAAS,OAAO,EAAE,WAAW,GAAG,SAAqC;CAEnE,OACE,oBAACA,SAAgB,MAAjB;EACE,WAAW,GACT,oBAAoB,EAAE,aAAa,MAAM,CAAC,GAC1C,yFACA,gGACA,sDACA,sFACA,SACF;EACA,GAAI;EAEJ,UAAA,oBAACA,SAAgB,OAAjB,EACE,WAAW,GACT,kLACA,2EACA,8EACF,EACD,CAAA;CACmB,CAAA;AAE1B"}
@@ -0,0 +1,55 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+ export interface TableFacetOption {
3
+ value: string;
4
+ label: ReactNode;
5
+ }
6
+ interface TableToolbarProps extends Omit<ComponentProps<"div">, "children"> {
7
+ /** A `SearchInput`, 200px wide; on a phone it fills its own row. */
8
+ search?: ReactNode;
9
+ /** The filters: a `TableFacetFilter` per common field, the Filter button, its chips. */
10
+ children?: ReactNode;
11
+ /** The sort picker (only for an order no column shows) and the column picker. */
12
+ end?: ReactNode;
13
+ }
14
+ /**
15
+ * The row above a table: the search, then the filters, which wrap onto a second row, then the
16
+ * pickers at the end. Page actions ("New site") belong in the page header, never here.
17
+ */
18
+ export declare function TableToolbar({ search, children, end, className, ...props }: TableToolbarProps): import("react").JSX.Element;
19
+ interface TableFacetFilterProps {
20
+ /** The field: "Category", "Status". */
21
+ label: string;
22
+ options: TableFacetOption[];
23
+ /** The chosen values, empty while the filter is off. */
24
+ value: string[];
25
+ onValueChange: (value: string[]) => void;
26
+ /** What the trigger shows for several values. */
27
+ formatSelected?: (count: number) => string;
28
+ clearLabel?: string;
29
+ }
30
+ /**
31
+ * A column filter in the toolbar, 32px like a button. Off, it is a dashed button with a plus;
32
+ * on, it shows the chosen value, or how many are chosen, after a divider. Its menu ticks values
33
+ * on and off and clears the filter. A filter with a relation (is not, contains) is a
34
+ * `TableFilterChip`.
35
+ */
36
+ export declare function TableFacetFilter({ label, options, value, onValueChange, formatSelected, clearLabel }: TableFacetFilterProps): import("react").JSX.Element;
37
+ interface TableFilterChipProps {
38
+ field: ReactNode;
39
+ /** The relation: "is", "is not", "contains", "before". */
40
+ operator: ReactNode;
41
+ value: ReactNode;
42
+ /** The items of each part's menu. A part with none is plain text. */
43
+ fieldMenu?: ReactNode;
44
+ operatorMenu?: ReactNode;
45
+ valueMenu?: ReactNode;
46
+ onRemove: () => void;
47
+ removeLabel?: string;
48
+ className?: string;
49
+ }
50
+ /**
51
+ * One filter added from the Filter menu: the field, the relation and the value, each opening its
52
+ * own menu, then a cross that removes it. Chips follow the filter buttons and wrap.
53
+ */
54
+ export declare function TableFilterChip({ field, operator, value, fieldMenu, operatorMenu, valueMenu, onRemove, removeLabel, className }: TableFilterChipProps): import("react").JSX.Element;
55
+ export {};