@underpin/ui 0.0.0-stage → 2.0.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 (258) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +45 -2
  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/button-group.d.ts +17 -0
  19. package/components/button-group.js +27 -0
  20. package/components/button-group.js.map +1 -0
  21. package/components/button.d.ts +39 -0
  22. package/components/button.js +128 -0
  23. package/components/button.js.map +1 -0
  24. package/components/calendar.d.ts +27 -0
  25. package/components/calendar.js +95 -0
  26. package/components/calendar.js.map +1 -0
  27. package/components/callout.d.ts +26 -0
  28. package/components/callout.js +71 -0
  29. package/components/callout.js.map +1 -0
  30. package/components/card.d.ts +55 -0
  31. package/components/card.js +96 -0
  32. package/components/card.js.map +1 -0
  33. package/components/chart.d.ts +32 -0
  34. package/components/chart.js +43 -0
  35. package/components/chart.js.map +1 -0
  36. package/components/checkbox.d.ts +15 -0
  37. package/components/checkbox.js +42 -0
  38. package/components/checkbox.js.map +1 -0
  39. package/components/code-block.d.ts +21 -0
  40. package/components/code-block.js +35 -0
  41. package/components/code-block.js.map +1 -0
  42. package/components/collapse.d.ts +14 -0
  43. package/components/collapse.js +25 -0
  44. package/components/collapse.js.map +1 -0
  45. package/components/combobox.d.ts +71 -0
  46. package/components/combobox.js +155 -0
  47. package/components/combobox.js.map +1 -0
  48. package/components/copy-button.d.ts +29 -0
  49. package/components/copy-button.js +100 -0
  50. package/components/copy-button.js.map +1 -0
  51. package/components/copy-input.d.ts +15 -0
  52. package/components/copy-input.js +51 -0
  53. package/components/copy-input.js.map +1 -0
  54. package/components/date-picker-trigger.d.ts +12 -0
  55. package/components/date-picker-trigger.js +30 -0
  56. package/components/date-picker-trigger.js.map +1 -0
  57. package/components/date-picker.d.ts +36 -0
  58. package/components/date-picker.js +70 -0
  59. package/components/date-picker.js.map +1 -0
  60. package/components/detail-row.d.ts +51 -0
  61. package/components/detail-row.js +77 -0
  62. package/components/detail-row.js.map +1 -0
  63. package/components/dialog.d.ts +121 -0
  64. package/components/dialog.js +327 -0
  65. package/components/dialog.js.map +1 -0
  66. package/components/disabled-reason.d.ts +31 -0
  67. package/components/disabled-reason.js +67 -0
  68. package/components/disabled-reason.js.map +1 -0
  69. package/components/empty-state.d.ts +41 -0
  70. package/components/empty-state.js +84 -0
  71. package/components/empty-state.js.map +1 -0
  72. package/components/entity-avatar.d.ts +54 -0
  73. package/components/entity-avatar.js +68 -0
  74. package/components/entity-avatar.js.map +1 -0
  75. package/components/form-section.d.ts +22 -0
  76. package/components/form-section.js +38 -0
  77. package/components/form-section.js.map +1 -0
  78. package/components/form.d.ts +199 -0
  79. package/components/form.js +456 -0
  80. package/components/form.js.map +1 -0
  81. package/components/formatted-number.d.ts +21 -0
  82. package/components/formatted-number.js +13 -0
  83. package/components/formatted-number.js.map +1 -0
  84. package/components/heading.d.ts +23 -0
  85. package/components/heading.js +44 -0
  86. package/components/heading.js.map +1 -0
  87. package/components/icon-swap.d.ts +15 -0
  88. package/components/icon-swap.js +29 -0
  89. package/components/icon-swap.js.map +1 -0
  90. package/components/inline-action.d.ts +21 -0
  91. package/components/inline-action.js +36 -0
  92. package/components/inline-action.js.map +1 -0
  93. package/components/input.d.ts +51 -0
  94. package/components/input.js +52 -0
  95. package/components/input.js.map +1 -0
  96. package/components/kbd.d.ts +17 -0
  97. package/components/kbd.js +34 -0
  98. package/components/kbd.js.map +1 -0
  99. package/components/label.d.ts +10 -0
  100. package/components/label.js +20 -0
  101. package/components/label.js.map +1 -0
  102. package/components/menu.d.ts +77 -0
  103. package/components/menu.js +189 -0
  104. package/components/menu.js.map +1 -0
  105. package/components/nav-button.d.ts +34 -0
  106. package/components/nav-button.js +71 -0
  107. package/components/nav-button.js.map +1 -0
  108. package/components/nav.d.ts +39 -0
  109. package/components/nav.js +68 -0
  110. package/components/nav.js.map +1 -0
  111. package/components/number-input.d.ts +16 -0
  112. package/components/number-input.js +25 -0
  113. package/components/number-input.js.map +1 -0
  114. package/components/page.d.ts +14 -0
  115. package/components/page.js +23 -0
  116. package/components/page.js.map +1 -0
  117. package/components/pagination.d.ts +15 -0
  118. package/components/pagination.js +63 -0
  119. package/components/pagination.js.map +1 -0
  120. package/components/ping.d.ts +38 -0
  121. package/components/ping.js +50 -0
  122. package/components/ping.js.map +1 -0
  123. package/components/popover.d.ts +5 -0
  124. package/components/popover.js +25 -0
  125. package/components/popover.js.map +1 -0
  126. package/components/radio-group.d.ts +35 -0
  127. package/components/radio-group.js +81 -0
  128. package/components/radio-group.js.map +1 -0
  129. package/components/relative-time.d.ts +25 -0
  130. package/components/relative-time.js +51 -0
  131. package/components/relative-time.js.map +1 -0
  132. package/components/saved-mark.d.ts +15 -0
  133. package/components/saved-mark.js +45 -0
  134. package/components/saved-mark.js.map +1 -0
  135. package/components/search-input.d.ts +13 -0
  136. package/components/search-input.js +44 -0
  137. package/components/search-input.js.map +1 -0
  138. package/components/section-header.d.ts +83 -0
  139. package/components/section-header.js +170 -0
  140. package/components/section-header.js.map +1 -0
  141. package/components/segmented-control.d.ts +24 -0
  142. package/components/segmented-control.js +70 -0
  143. package/components/segmented-control.js.map +1 -0
  144. package/components/select.d.ts +28 -0
  145. package/components/select.js +129 -0
  146. package/components/select.js.map +1 -0
  147. package/components/shortcut-keys.d.ts +14 -0
  148. package/components/shortcut-keys.js +32 -0
  149. package/components/shortcut-keys.js.map +1 -0
  150. package/components/shortcuts-dialog.d.ts +10 -0
  151. package/components/shortcuts-dialog.js +92 -0
  152. package/components/shortcuts-dialog.js.map +1 -0
  153. package/components/skeleton.d.ts +8 -0
  154. package/components/skeleton.js +23 -0
  155. package/components/skeleton.js.map +1 -0
  156. package/components/sparkline.d.ts +25 -0
  157. package/components/sparkline.js +70 -0
  158. package/components/sparkline.js.map +1 -0
  159. package/components/stack.d.ts +21 -0
  160. package/components/stack.js +45 -0
  161. package/components/stack.js.map +1 -0
  162. package/components/stat-strip.d.ts +43 -0
  163. package/components/stat-strip.js +151 -0
  164. package/components/stat-strip.js.map +1 -0
  165. package/components/steps.d.ts +19 -0
  166. package/components/steps.js +25 -0
  167. package/components/steps.js.map +1 -0
  168. package/components/switch.d.ts +16 -0
  169. package/components/switch.js +29 -0
  170. package/components/switch.js.map +1 -0
  171. package/components/tabs.d.ts +18 -0
  172. package/components/tabs.js +65 -0
  173. package/components/tabs.js.map +1 -0
  174. package/components/text-link.d.ts +16 -0
  175. package/components/text-link.js +32 -0
  176. package/components/text-link.js.map +1 -0
  177. package/components/textarea.d.ts +10 -0
  178. package/components/textarea.js +23 -0
  179. package/components/textarea.js.map +1 -0
  180. package/components/theme.d.ts +28 -0
  181. package/components/theme.js +158 -0
  182. package/components/theme.js.map +1 -0
  183. package/components/time-series-chart.d.ts +122 -0
  184. package/components/time-series-chart.js +722 -0
  185. package/components/time-series-chart.js.map +1 -0
  186. package/components/toaster.d.ts +3 -0
  187. package/components/toaster.js +44 -0
  188. package/components/toaster.js.map +1 -0
  189. package/components/tooltip.d.ts +64 -0
  190. package/components/tooltip.js +126 -0
  191. package/components/tooltip.js.map +1 -0
  192. package/components/view-picker.d.ts +20 -0
  193. package/components/view-picker.js +24 -0
  194. package/components/view-picker.js.map +1 -0
  195. package/fonts/inter-OFL.txt +93 -0
  196. package/fonts/inter-cyrillic-ext.woff2 +0 -0
  197. package/fonts/inter-cyrillic.woff2 +0 -0
  198. package/fonts/inter-greek-ext.woff2 +0 -0
  199. package/fonts/inter-greek.woff2 +0 -0
  200. package/fonts/inter-latin-ext.woff2 +0 -0
  201. package/fonts/inter-latin.woff2 +0 -0
  202. package/fonts/inter-vietnamese.woff2 +0 -0
  203. package/fonts.css +83 -0
  204. package/lib/animation.d.ts +14 -0
  205. package/lib/animation.js +20 -0
  206. package/lib/animation.js.map +1 -0
  207. package/lib/aria.d.ts +5 -0
  208. package/lib/aria.js +12 -0
  209. package/lib/aria.js.map +1 -0
  210. package/lib/chart-curve.d.ts +13 -0
  211. package/lib/chart-curve.js +79 -0
  212. package/lib/chart-curve.js.map +1 -0
  213. package/lib/classes.d.ts +134 -0
  214. package/lib/classes.js +152 -0
  215. package/lib/classes.js.map +1 -0
  216. package/lib/color.d.ts +25 -0
  217. package/lib/color.js +149 -0
  218. package/lib/color.js.map +1 -0
  219. package/lib/day.d.ts +9 -0
  220. package/lib/day.js +20 -0
  221. package/lib/day.js.map +1 -0
  222. package/lib/design-tokens.d.ts +56 -0
  223. package/lib/design-tokens.js +196 -0
  224. package/lib/design-tokens.js.map +1 -0
  225. package/lib/icon.d.ts +17 -0
  226. package/lib/icon.js +34 -0
  227. package/lib/icon.js.map +1 -0
  228. package/lib/icons.d.ts +23 -0
  229. package/lib/icons.js +28 -0
  230. package/lib/icons.js.map +1 -0
  231. package/lib/interactive.d.ts +21 -0
  232. package/lib/interactive.js +31 -0
  233. package/lib/interactive.js.map +1 -0
  234. package/lib/media.d.ts +58 -0
  235. package/lib/media.js +116 -0
  236. package/lib/media.js.map +1 -0
  237. package/lib/segmented.d.ts +57 -0
  238. package/lib/segmented.js +83 -0
  239. package/lib/segmented.js.map +1 -0
  240. package/lib/shortcuts.d.ts +94 -0
  241. package/lib/shortcuts.js +271 -0
  242. package/lib/shortcuts.js.map +1 -0
  243. package/lib/slot.d.ts +9 -0
  244. package/lib/slot.js +18 -0
  245. package/lib/slot.js.map +1 -0
  246. package/lib/time-series.d.ts +100 -0
  247. package/lib/time-series.js +144 -0
  248. package/lib/time-series.js.map +1 -0
  249. package/lib/tone.d.ts +6 -0
  250. package/lib/tone.js +0 -0
  251. package/lib/variants.d.ts +12 -0
  252. package/lib/variants.js +14 -0
  253. package/lib/variants.js.map +1 -0
  254. package/package.json +116 -4
  255. package/styles.css +619 -0
  256. package/tokens.d.ts +104 -0
  257. package/tokens.js +108 -0
  258. package/tokens.js.map +1 -0
@@ -0,0 +1,81 @@
1
+ "use client";
2
+ import { formatIdList } from "../lib/aria.js";
3
+ import "../lib/classes.js";
4
+ import { interactiveVariants } from "../lib/interactive.js";
5
+ import { cn } from "../lib/variants.js";
6
+ import { useDisabledReason } from "./disabled-reason.js";
7
+ import { Tooltip, showTooltip } from "./tooltip.js";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { useId } from "react";
10
+ import { Radio as Radio$1 } from "@base-ui/react/radio";
11
+ import { RadioGroup as RadioGroup$1 } from "@base-ui/react/radio-group";
12
+ // src/components/radio-group.tsx
13
+ /**
14
+ * One choice out of a few, each shown at once with what it means. Arrow keys move the choice,
15
+ * as in any radio group. A choice between two states is a `Switch`; a longer list is a
16
+ * `Select`.
17
+ */
18
+ function RadioGroup({ className, ...props }) {
19
+ return /* @__PURE__ */ jsx(RadioGroup$1, {
20
+ className: cn("flex flex-col gap-2", className),
21
+ ...props
22
+ });
23
+ }
24
+ /**
25
+ * The 16px round control, raised on `Checkbox`'s strong edge and filled with the brand once
26
+ * chosen. A `RadioCard` keeps its own lighter card edge around it. Base UI renders a
27
+ * `<span role="radio">` beside a hidden input, so a disabled one carries `data-disabled` rather
28
+ * than matching `:disabled`, as with `Checkbox`.
29
+ */
30
+ function Radio({ className, ...props }) {
31
+ return /* @__PURE__ */ jsx(Radio$1.Root, {
32
+ className: cn(interactiveVariants({ interactive: false }), "inline-flex size-4 shrink-0 items-center justify-center rounded-full border border-edge-strong bg-surface shadow-control", "data-checked:border-brand data-checked:bg-brand/80", "hover:not-data-disabled:not-data-checked:border-edge-solid", "not-data-disabled:cursor-pointer data-disabled:opacity-50", className),
33
+ ...props,
34
+ children: /* @__PURE__ */ jsx(Radio$1.Indicator, { className: "size-1.5 rounded-full bg-brand-on" })
35
+ });
36
+ }
37
+ /**
38
+ * A choice as a card: the radio, then its label and what it means. The whole card is the
39
+ * `<label>`, so a click anywhere on it picks the choice; the chosen card takes the fill.
40
+ */
41
+ function RadioCard({ label, description, badge, disabledReason, readOnly, className, ...props }) {
42
+ const id = useId();
43
+ const descriptionId = `${id}-description`;
44
+ const reason = useDisabledReason(disabledReason, formatIdList(!!description && descriptionId, props["aria-describedby"]));
45
+ return /* @__PURE__ */ jsx(Tooltip, {
46
+ id: reason.triggerId,
47
+ tooltip: disabledReason,
48
+ side: "top",
49
+ children: /* @__PURE__ */ jsxs("label", {
50
+ className: cn("flex cursor-pointer items-start gap-2.5 rounded-lg border bg-surface px-3.5 py-3 transition-colors duration-75", "has-data-checked:bg-fill", "has-data-disabled:pointer-events-none has-data-disabled:opacity-50", disabledReason ? "cursor-not-allowed opacity-50" : "hover:not-has-data-checked:bg-fill-subtle", className),
51
+ onClick: disabledReason ? () => showTooltip(reason.triggerId) : void 0,
52
+ children: [
53
+ /* @__PURE__ */ jsx(Radio, {
54
+ ...props,
55
+ "aria-labelledby": id,
56
+ "aria-describedby": reason.describedBy,
57
+ readOnly: readOnly === true || !!disabledReason,
58
+ className: cn("mt-0.5 data-disabled:opacity-100", disabledReason && "cursor-not-allowed")
59
+ }),
60
+ /* @__PURE__ */ jsxs("span", {
61
+ className: "flex min-w-0 flex-col gap-0.5",
62
+ children: [/* @__PURE__ */ jsxs("span", {
63
+ className: "flex items-center gap-2 font-medium text-sm",
64
+ children: [/* @__PURE__ */ jsx("span", {
65
+ id,
66
+ children: label
67
+ }), badge]
68
+ }), description && /* @__PURE__ */ jsx("span", {
69
+ id: descriptionId,
70
+ className: "max-w-prose text-copy text-ink-muted",
71
+ children: description
72
+ })]
73
+ }),
74
+ reason.reasonText
75
+ ]
76
+ })
77
+ });
78
+ }
79
+ export { Radio, RadioCard, RadioGroup };
80
+
81
+ //# sourceMappingURL=radio-group.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"radio-group.js","names":["RadioGroupPrimitive","RadioPrimitive"],"sources":["../../src/components/radio-group.tsx"],"sourcesContent":["\"use client\"\n\nimport { Radio as RadioPrimitive } from \"@base-ui/react/radio\"\nimport { RadioGroup as RadioGroupPrimitive } from \"@base-ui/react/radio-group\"\nimport { type ReactNode, useId } from \"react\"\nimport { formatIdList } from \"../lib/aria\"\nimport { descriptionClasses } from \"../lib/classes\"\nimport { interactiveVariants } from \"../lib/interactive\"\nimport { cn } from \"../lib/variants\"\nimport { useDisabledReason } from \"./disabled-reason\"\nimport { showTooltip, Tooltip } from \"./tooltip\"\n\n/**\n * One choice out of a few, each shown at once with what it means. Arrow keys move the choice,\n * as in any radio group. A choice between two states is a `Switch`; a longer list is a\n * `Select`.\n */\nfunction RadioGroup({ className, ...props }: RadioGroupPrimitive.Props) {\n return <RadioGroupPrimitive className={cn(\"flex flex-col gap-2\", className)} {...props} />\n}\n\n/**\n * The 16px round control, raised on `Checkbox`'s strong edge and filled with the brand once\n * chosen. A `RadioCard` keeps its own lighter card edge around it. Base UI renders a\n * `<span role=\"radio\">` beside a hidden input, so a disabled one carries `data-disabled` rather\n * than matching `:disabled`, as with `Checkbox`.\n */\nfunction Radio({ className, ...props }: RadioPrimitive.Root.Props) {\n // Merged outside `variants`, which cannot take Base UI's state-function `className`.\n return (\n <RadioPrimitive.Root\n className={cn(\n interactiveVariants({ interactive: false }),\n \"inline-flex size-4 shrink-0 items-center justify-center rounded-full border border-edge-strong bg-surface shadow-control\",\n \"data-checked:border-brand data-checked:bg-brand/80\",\n \"hover:not-data-disabled:not-data-checked:border-edge-solid\",\n \"not-data-disabled:cursor-pointer data-disabled:opacity-50\",\n className,\n )}\n {...props}\n >\n <RadioPrimitive.Indicator className=\"size-1.5 rounded-full bg-brand-on\" />\n </RadioPrimitive.Root>\n )\n}\n\ninterface RadioCardProps extends Omit<RadioPrimitive.Root.Props, \"children\"> {\n label: ReactNode\n /** What the choice means, under the label. */\n description?: ReactNode\n /** Beside the label, e.g. a \"Default\" badge. */\n badge?: ReactNode\n /**\n * Why the choice cannot be made. The radio turns read-only rather than disabled, so the arrow\n * keys still reach it, which they skip on a disabled one; the reason is read with it and shown\n * in a tooltip, which a tap opens too.\n */\n disabledReason?: string\n}\n\n/**\n * A choice as a card: the radio, then its label and what it means. The whole card is the\n * `<label>`, so a click anywhere on it picks the choice; the chosen card takes the fill.\n */\nfunction RadioCard({\n label,\n description,\n badge,\n disabledReason,\n readOnly,\n className,\n ...props\n}: RadioCardProps) {\n const id = useId()\n const descriptionId = `${id}-description`\n const reason = useDisabledReason(\n disabledReason,\n formatIdList(!!description && descriptionId, props[\"aria-describedby\"]),\n )\n\n return (\n <Tooltip id={reason.triggerId} tooltip={disabledReason} side=\"top\">\n {/* oxlint-disable-next-line jsx-a11y/click-events-have-key-events, jsx-a11y/no-noninteractive-element-interactions -- the radio inside takes the keyboard; the click only opens the reason for a tap */}\n <label\n className={cn(\n \"flex cursor-pointer items-start gap-2.5 rounded-lg border bg-surface px-3.5 py-3 transition-colors duration-75\",\n \"has-data-checked:bg-fill\",\n \"has-data-disabled:pointer-events-none has-data-disabled:opacity-50\",\n disabledReason\n ? \"cursor-not-allowed opacity-50\"\n : \"hover:not-has-data-checked:bg-fill-subtle\",\n className,\n )}\n onClick={disabledReason ? () => showTooltip(reason.triggerId) : undefined}\n >\n {/* The card dims as a whole, so the radio does not dim a second time inside it. */}\n <Radio\n // First, so the caller's description merges with the card's own and the reason's.\n {...props}\n aria-labelledby={id}\n aria-describedby={reason.describedBy}\n readOnly={readOnly === true || !!disabledReason}\n className={cn(\"mt-0.5 data-disabled:opacity-100\", disabledReason && \"cursor-not-allowed\")}\n />\n\n <span className=\"flex min-w-0 flex-col gap-0.5\">\n <span className=\"flex items-center gap-2 font-medium text-sm\">\n <span id={id}>{label}</span>\n {badge}\n </span>\n {description && (\n <span id={descriptionId} className={descriptionClasses}>\n {description}\n </span>\n )}\n </span>\n\n {reason.reasonText}\n </label>\n </Tooltip>\n )\n}\n\nexport { Radio, RadioCard, RadioGroup }\n"],"mappings":";;;;;;;;;;;;;;;;;AAiBA,SAAS,WAAW,EAAE,WAAW,GAAG,SAAoC;CACtE,OAAO,oBAACA,cAAD;EAAqB,WAAW,GAAG,uBAAuB,SAAS;EAAG,GAAI;CAAQ,CAAA;AAC3F;;;;;;;AAQA,SAAS,MAAM,EAAE,WAAW,GAAG,SAAoC;CAEjE,OACE,oBAACC,QAAe,MAAhB;EACE,WAAW,GACT,oBAAoB,EAAE,aAAa,MAAM,CAAC,GAC1C,4HACA,sDACA,8DACA,6DACA,SACF;EACA,GAAI;EAEJ,UAAA,oBAACA,QAAe,WAAhB,EAA0B,WAAU,oCAAqC,CAAA;CACtD,CAAA;AAEzB;;;;;AAoBA,SAAS,UAAU,EACjB,OACA,aACA,OACA,gBACA,UACA,WACA,GAAG,SACc;CACjB,MAAM,KAAK,MAAM;CACjB,MAAM,gBAAgB,GAAG,GAAG;CAC5B,MAAM,SAAS,kBACb,gBACA,aAAa,CAAC,CAAC,eAAe,eAAe,MAAM,mBAAmB,CACxE;CAEA,OACE,oBAAC,SAAD;EAAS,IAAI,OAAO;EAAW,SAAS;EAAgB,MAAK;EAE3D,UAAA,qBAAC,SAAD;GACE,WAAW,GACT,kHACA,4BACA,sEACA,iBACI,kCACA,6CACJ,SACF;GACA,SAAS,uBAAuB,YAAY,OAAO,SAAS,IAAI,KAAA;GAVlE,UAAA;IAaE,oBAAC,OAAD;KAEE,GAAI;KACJ,mBAAiB;KACjB,oBAAkB,OAAO;KACzB,UAAU,aAAa,QAAQ,CAAC,CAAC;KACjC,WAAW,GAAG,oCAAoC,kBAAkB,oBAAoB;IACzF,CAAA;IAED,qBAAC,QAAD;KAAM,WAAU;KAAhB,UAAA,CACE,qBAAC,QAAD;MAAM,WAAU;MAAhB,UAAA,CACE,oBAAC,QAAD;OAAU;OAAK,UAAA;MAAY,CAAA,GAC1B,KACG;KACL,CAAA,GAAA,eACC,oBAAC,QAAD;MAAM,IAAI;MAAe,WAAA;MACtB,UAAA;KACG,CAAA,CAEJ;;IAEL,OAAO;GACH;;CACA,CAAA;AAEb"}
@@ -0,0 +1,25 @@
1
+ import { ComponentProps, ReactNode } from "react";
2
+ /** One instant as a single clock reads it. */
3
+ export interface RelativeTimeStamp {
4
+ /** The clock's name: "UTC", "GMT+2". */
5
+ label: string;
6
+ /** The day on that clock: "September 20, 2026". */
7
+ date: string;
8
+ /** The time on that clock: "04:58:20 PM". */
9
+ clock: string;
10
+ }
11
+ export interface RelativeTimeProps extends Omit<ComponentProps<"time">, "dateTime"> {
12
+ /** The instant being reported on; ISO 8601, or a `Date`. */
13
+ date: Date | string;
14
+ /** What the hover says: the full date, or how long ago above a list of `stamps`. */
15
+ tooltip: ReactNode;
16
+ /** The same instant on several clocks, one row each under `tooltip`. */
17
+ stamps?: RelativeTimeStamp[];
18
+ }
19
+ /**
20
+ * A moment printed short, with the exact one on hover. The caller formats every string, as this
21
+ * package formats no dates: the children are the short reading ("2 months ago", "14:32:05"), and
22
+ * `tooltip` is the long one. For a stamp that has to stay short on the page (a feed row, a log
23
+ * line), where the exact moment is worth one hover but not one column.
24
+ */
25
+ export declare function RelativeTime({ date, tooltip, stamps, ...props }: RelativeTimeProps): import("react").JSX.Element;
@@ -0,0 +1,51 @@
1
+ "use client";
2
+ import { Badge } from "./badge.js";
3
+ import { Tooltip } from "./tooltip.js";
4
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
5
+ // src/components/relative-time.tsx
6
+ /**
7
+ * A moment printed short, with the exact one on hover. The caller formats every string, as this
8
+ * package formats no dates: the children are the short reading ("2 months ago", "14:32:05"), and
9
+ * `tooltip` is the long one. For a stamp that has to stay short on the page (a feed row, a log
10
+ * line), where the exact moment is worth one hover but not one column.
11
+ */
12
+ function RelativeTime({ date, tooltip, stamps, ...props }) {
13
+ const time = /* @__PURE__ */ jsx("time", {
14
+ dateTime: new Date(date).toISOString(),
15
+ ...props
16
+ });
17
+ if (!stamps?.length) return /* @__PURE__ */ jsx(Tooltip, {
18
+ tooltip,
19
+ children: time
20
+ });
21
+ return /* @__PURE__ */ jsx(Tooltip, {
22
+ variant: "rich",
23
+ side: "right",
24
+ tooltip: /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx("div", {
25
+ className: "text-ink-muted",
26
+ children: tooltip
27
+ }), /* @__PURE__ */ jsx("div", {
28
+ className: "mt-2.5 flex flex-col gap-1.5",
29
+ children: stamps.map((stamp) => /* @__PURE__ */ jsxs("div", {
30
+ className: "flex items-center gap-2 whitespace-nowrap",
31
+ children: [
32
+ /* @__PURE__ */ jsx(Badge, {
33
+ size: "sm",
34
+ className: "font-mono",
35
+ children: stamp.label
36
+ }),
37
+ /* @__PURE__ */ jsx("span", { children: stamp.date }),
38
+ /* @__PURE__ */ jsx("span", {
39
+ className: "ml-auto pl-4 font-mono text-ink-muted tabular-nums",
40
+ children: stamp.clock
41
+ })
42
+ ]
43
+ }, stamp.label))
44
+ })] }),
45
+ className: "max-w-sm",
46
+ children: time
47
+ });
48
+ }
49
+ export { RelativeTime };
50
+
51
+ //# sourceMappingURL=relative-time.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relative-time.js","names":[],"sources":["../../src/components/relative-time.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ComponentProps, ReactNode } from \"react\"\nimport { Badge } from \"./badge\"\nimport { Tooltip } from \"./tooltip\"\n\n/** One instant as a single clock reads it. */\nexport interface RelativeTimeStamp {\n /** The clock's name: \"UTC\", \"GMT+2\". */\n label: string\n /** The day on that clock: \"September 20, 2026\". */\n date: string\n /** The time on that clock: \"04:58:20 PM\". */\n clock: string\n}\n\nexport interface RelativeTimeProps extends Omit<ComponentProps<\"time\">, \"dateTime\"> {\n /** The instant being reported on; ISO 8601, or a `Date`. */\n date: Date | string\n /** What the hover says: the full date, or how long ago above a list of `stamps`. */\n tooltip: ReactNode\n /** The same instant on several clocks, one row each under `tooltip`. */\n stamps?: RelativeTimeStamp[]\n}\n\n/**\n * A moment printed short, with the exact one on hover. The caller formats every string, as this\n * package formats no dates: the children are the short reading (\"2 months ago\", \"14:32:05\"), and\n * `tooltip` is the long one. For a stamp that has to stay short on the page (a feed row, a log\n * line), where the exact moment is worth one hover but not one column.\n */\nexport function RelativeTime({ date, tooltip, stamps, ...props }: RelativeTimeProps) {\n const time = <time dateTime={new Date(date).toISOString()} {...props} />\n\n if (!stamps?.length) return <Tooltip tooltip={tooltip}>{time}</Tooltip>\n\n return (\n <Tooltip\n variant=\"rich\"\n side=\"right\"\n tooltip={\n <>\n {/* The date carries the weight: it is what a reader came for. How long ago frames\n it and the clock qualifies it, so both sit back a shade. */}\n <div className=\"text-ink-muted\">{tooltip}</div>\n\n <div className=\"mt-2.5 flex flex-col gap-1.5\">\n {stamps.map(stamp => (\n // The date hangs off its own zone rather than a column the two rows share, so a\n // wider label pushes its date along instead of indenting both. The clocks still\n // end together, which is where a pair of them is read.\n <div key={stamp.label} className=\"flex items-center gap-2 whitespace-nowrap\">\n <Badge size=\"sm\" className=\"font-mono\">\n {stamp.label}\n </Badge>\n <span>{stamp.date}</span>\n <span className=\"ml-auto pl-4 font-mono text-ink-muted tabular-nums\">\n {stamp.clock}\n </span>\n </div>\n ))}\n </div>\n </>\n }\n // Wider than a rich tooltip's own ceiling: two zones, two dates and two clocks on one\n // line each, and the longer label must not fold its date onto a second line.\n className=\"max-w-sm\"\n >\n {time}\n </Tooltip>\n )\n}\n"],"mappings":";;;;;;;;;;;AA+BA,SAAgB,aAAa,EAAE,MAAM,SAAS,QAAQ,GAAG,SAA4B;CACnF,MAAM,OAAO,oBAAC,QAAD;EAAM,UAAU,IAAI,KAAK,IAAI,CAAC,CAAC,YAAY;EAAG,GAAI;CAAQ,CAAA;CAEvE,IAAI,CAAC,QAAQ,QAAQ,OAAO,oBAAC,SAAD;EAAkB;EAAU,UAAA;CAAc,CAAA;CAEtE,OACE,oBAAC,SAAD;EACE,SAAQ;EACR,MAAK;EACL,SACE,qBAAA,UAAA,EAAA,UAAA,CAGE,oBAAC,OAAD;GAAK,WAAU;GAAkB,UAAA;EAAa,CAAA,GAE9C,oBAAC,OAAD;GAAK,WAAU;GACZ,UAAA,OAAO,KAAI,UAIV,qBAAC,OAAD;IAAuB,WAAU;IAAjC,UAAA;KACE,oBAAC,OAAD;MAAO,MAAK;MAAK,WAAU;MACxB,UAAA,MAAM;KACF,CAAA;KACP,oBAAC,QAAD,EAAA,UAAO,MAAM,KAAW,CAAA;KACxB,oBAAC,QAAD;MAAM,WAAU;MACb,UAAA,MAAM;KACH,CAAA;IACH;GARK,GAAA,MAAM,KAQX,CACN;EACE,CAAA,CACL,EAAA,CAAA;EAIJ,WAAU;EAET,UAAA;CACM,CAAA;AAEb"}
@@ -0,0 +1,15 @@
1
+ import { ReactNode } from "react";
2
+ interface SavedMarkProps {
3
+ /** A count the caller bumps after each save; every change shows the mark again. */
4
+ saves: number;
5
+ /** How long the mark stays, in milliseconds. */
6
+ duration?: number;
7
+ label?: ReactNode;
8
+ className?: string;
9
+ }
10
+ /**
11
+ * The note an autosaved control shows beside its label for a moment after each save. Screen
12
+ * readers hear it through a status region instead of the visible mark.
13
+ */
14
+ export declare function SavedMark({ saves, duration, label, className }: SavedMarkProps): import("react").JSX.Element;
15
+ export {};
@@ -0,0 +1,45 @@
1
+ "use client";
2
+ import { CheckIcon } from "../lib/icons.js";
3
+ import { cn } from "../lib/variants.js";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { useEffect, useState } from "react";
6
+ // src/components/saved-mark.tsx
7
+ const markClasses = ["inline-flex items-center gap-1 font-medium text-success-ink text-xs", "transition-[opacity,filter,translate] motion-reduce:transition-opacity"];
8
+ const markShownClasses = "opacity-100 blur-none translate-x-0 duration-200 ease-swap";
9
+ const markHiddenClasses = ["pointer-events-none opacity-0 blur-[4px] -translate-x-1 duration-150 ease-out", "motion-reduce:blur-none motion-reduce:translate-x-0"];
10
+ const iconClasses = "size-3.5 transition-[scale] duration-200 ease-swap motion-reduce:scale-100";
11
+ /**
12
+ * The note an autosaved control shows beside its label for a moment after each save. Screen
13
+ * readers hear it through a status region instead of the visible mark.
14
+ */
15
+ function SavedMark({ saves, duration = 2e3, label = "Saved", className }) {
16
+ const [visible, setVisible] = useState(false);
17
+ const [seen, setSeen] = useState(saves);
18
+ if (saves !== seen) {
19
+ setSeen(saves);
20
+ setVisible(true);
21
+ }
22
+ useEffect(() => {
23
+ if (!visible) return;
24
+ const timer = setTimeout(() => setVisible(false), duration);
25
+ return () => clearTimeout(timer);
26
+ }, [
27
+ visible,
28
+ saves,
29
+ duration
30
+ ]);
31
+ return /* @__PURE__ */ jsxs("span", {
32
+ className: cn("inline-flex items-center align-middle", className),
33
+ children: [/* @__PURE__ */ jsxs("span", {
34
+ "aria-hidden": true,
35
+ className: cn(markClasses, visible ? markShownClasses : markHiddenClasses),
36
+ children: [/* @__PURE__ */ jsx(CheckIcon, { className: cn(iconClasses, visible ? "scale-100" : "scale-[0.25]") }), label]
37
+ }), /* @__PURE__ */ jsx("output", {
38
+ className: "sr-only",
39
+ children: visible && label
40
+ })]
41
+ });
42
+ }
43
+ export { SavedMark };
44
+
45
+ //# sourceMappingURL=saved-mark.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"saved-mark.js","names":[],"sources":["../../src/components/saved-mark.tsx"],"sourcesContent":["\"use client\"\n\nimport { type ReactNode, useEffect, useState } from \"react\"\nimport { CheckIcon } from \"../lib/icons\"\nimport { cn } from \"../lib/variants\"\n\n/*\n * Both states stay mounted and change by transition, so a save during the fade-out turns it\n * around. The exit is quicker and plainer than the enter; reduced motion keeps the fade alone.\n */\nconst markClasses = [\n \"inline-flex items-center gap-1 font-medium text-success-ink text-xs\",\n \"transition-[opacity,filter,translate] motion-reduce:transition-opacity\",\n]\nconst markShownClasses = \"opacity-100 blur-none translate-x-0 duration-200 ease-swap\"\nconst markHiddenClasses = [\n \"pointer-events-none opacity-0 blur-[4px] -translate-x-1 duration-150 ease-out\",\n \"motion-reduce:blur-none motion-reduce:translate-x-0\",\n]\n\nconst iconClasses = \"size-3.5 transition-[scale] duration-200 ease-swap motion-reduce:scale-100\"\n\ninterface SavedMarkProps {\n /** A count the caller bumps after each save; every change shows the mark again. */\n saves: number\n /** How long the mark stays, in milliseconds. */\n duration?: number\n label?: ReactNode\n className?: string\n}\n\n/**\n * The note an autosaved control shows beside its label for a moment after each save. Screen\n * readers hear it through a status region instead of the visible mark.\n */\nexport function SavedMark({ saves, duration = 2000, label = \"Saved\", className }: SavedMarkProps) {\n const [visible, setVisible] = useState(false)\n const [seen, setSeen] = useState(saves)\n\n // A changed count shows the mark; the first render only records the count.\n if (saves !== seen) {\n setSeen(saves)\n setVisible(true)\n }\n\n // Keyed on the count too, so a save while shown restarts the timer.\n useEffect(() => {\n if (!visible) return\n const timer = setTimeout(() => setVisible(false), duration)\n return () => clearTimeout(timer)\n }, [visible, saves, duration])\n\n return (\n <span className={cn(\"inline-flex items-center align-middle\", className)}>\n <span aria-hidden className={cn(markClasses, visible ? markShownClasses : markHiddenClasses)}>\n <CheckIcon className={cn(iconClasses, visible ? \"scale-100\" : \"scale-[0.25]\")} />\n {label}\n </span>\n\n <output className=\"sr-only\">{visible && label}</output>\n </span>\n )\n}\n"],"mappings":";;;;;;AAUA,MAAM,cAAc,CAClB,uEACA,wEACF;AACA,MAAM,mBAAmB;AACzB,MAAM,oBAAoB,CACxB,iFACA,qDACF;AAEA,MAAM,cAAc;;;;;AAepB,SAAgB,UAAU,EAAE,OAAO,WAAW,KAAM,QAAQ,SAAS,aAA6B;CAChG,MAAM,CAAC,SAAS,cAAc,SAAS,KAAK;CAC5C,MAAM,CAAC,MAAM,WAAW,SAAS,KAAK;CAGtC,IAAI,UAAU,MAAM;EAClB,QAAQ,KAAK;EACb,WAAW,IAAI;CACjB;CAGA,gBAAgB;EACd,IAAI,CAAC,SAAS;EACd,MAAM,QAAQ,iBAAiB,WAAW,KAAK,GAAG,QAAQ;EAC1D,aAAa,aAAa,KAAK;CACjC,GAAG;EAAC;EAAS;EAAO;CAAQ,CAAC;CAE7B,OACE,qBAAC,QAAD;EAAM,WAAW,GAAG,yCAAyC,SAAS;EAAtE,UAAA,CACE,qBAAC,QAAD;GAAM,eAAA;GAAY,WAAW,GAAG,aAAa,UAAU,mBAAmB,iBAAiB;GAA3F,UAAA,CACE,oBAAC,WAAD,EAAW,WAAW,GAAG,aAAa,UAAU,cAAc,cAAc,EAAI,CAAA,GAC/E,KACG;EAEN,CAAA,GAAA,oBAAC,UAAD;GAAQ,WAAU;GAAW,UAAA,WAAW;EAAc,CAAA,CAClD;;AAEV"}
@@ -0,0 +1,13 @@
1
+ import { Input } from "./input.js";
2
+ import { ComponentProps } from "react";
3
+ type SearchInputProps = Omit<ComponentProps<typeof Input>, "value" | "onChange"> & {
4
+ value: string;
5
+ onValueChange: (value: string) => void;
6
+ };
7
+ /**
8
+ * Text input with a leading search icon and a clear button once it holds a value. Labels and
9
+ * placeholders come from the caller. Clearing puts focus back in the field, since the button
10
+ * that held it unmounts with the value.
11
+ */
12
+ export declare function SearchInput({ ref, value, onValueChange, className, ...props }: SearchInputProps): import("react").JSX.Element;
13
+ export {};
@@ -0,0 +1,44 @@
1
+ "use client";
2
+ import { CancelIcon, SearchIcon } from "../lib/icons.js";
3
+ import { cn } from "../lib/variants.js";
4
+ import { Button } from "./button.js";
5
+ import { Input } from "./input.js";
6
+ import { jsx, jsxs } from "react/jsx-runtime";
7
+ import { useImperativeHandle, useRef } from "react";
8
+ // src/components/search-input.tsx
9
+ /**
10
+ * Text input with a leading search icon and a clear button once it holds a value. Labels and
11
+ * placeholders come from the caller. Clearing puts focus back in the field, since the button
12
+ * that held it unmounts with the value.
13
+ */
14
+ function SearchInput({ ref, value, onValueChange, className, ...props }) {
15
+ const inputRef = useRef(null);
16
+ useImperativeHandle(ref, () => inputRef.current);
17
+ return /* @__PURE__ */ jsxs("div", {
18
+ className: cn("relative", className),
19
+ children: [
20
+ /* @__PURE__ */ jsx(SearchIcon, { className: "pointer-events-none absolute top-1/2 left-3 size-3.5 -translate-y-1/2 text-ink-muted" }),
21
+ /* @__PURE__ */ jsx(Input, {
22
+ ref: inputRef,
23
+ value,
24
+ className: "pr-9 pl-8.5",
25
+ onChange: (event) => onValueChange(event.target.value),
26
+ ...props
27
+ }),
28
+ value.length > 0 && /* @__PURE__ */ jsx(Button, {
29
+ variant: "ghost",
30
+ size: "sm",
31
+ "aria-label": "Clear search",
32
+ prefix: /* @__PURE__ */ jsx(CancelIcon, {}),
33
+ className: "absolute top-1/2 right-0.5 -translate-y-1/2 rounded",
34
+ onClick: () => {
35
+ onValueChange("");
36
+ inputRef.current?.focus();
37
+ }
38
+ })
39
+ ]
40
+ });
41
+ }
42
+ export { SearchInput };
43
+
44
+ //# sourceMappingURL=search-input.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"search-input.js","names":[],"sources":["../../src/components/search-input.tsx"],"sourcesContent":["\"use client\"\n\nimport { type ComponentProps, useImperativeHandle, useRef } from \"react\"\nimport { CancelIcon, SearchIcon } from \"../lib/icons\"\nimport { cn } from \"../lib/variants\"\nimport { Button } from \"./button\"\nimport { Input } from \"./input\"\n\ntype SearchInputProps = Omit<ComponentProps<typeof Input>, \"value\" | \"onChange\"> & {\n value: string\n onValueChange: (value: string) => void\n}\n\n/**\n * Text input with a leading search icon and a clear button once it holds a value. Labels and\n * placeholders come from the caller. Clearing puts focus back in the field, since the button\n * that held it unmounts with the value.\n */\nexport function SearchInput({ ref, value, onValueChange, className, ...props }: SearchInputProps) {\n const inputRef = useRef<HTMLInputElement>(null)\n useImperativeHandle(ref, () => inputRef.current as HTMLInputElement)\n\n return (\n <div className={cn(\"relative\", className)}>\n <SearchIcon className=\"pointer-events-none absolute top-1/2 left-3 size-3.5 -translate-y-1/2 text-ink-muted\" />\n\n <Input\n ref={inputRef}\n value={value}\n className=\"pr-9 pl-8.5\"\n onChange={event => onValueChange(event.target.value)}\n {...props}\n />\n\n {value.length > 0 && (\n <Button\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Clear search\"\n prefix={<CancelIcon />}\n className=\"absolute top-1/2 right-0.5 -translate-y-1/2 rounded\"\n onClick={() => {\n onValueChange(\"\")\n inputRef.current?.focus()\n }}\n />\n )}\n </div>\n )\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAAgB,YAAY,EAAE,KAAK,OAAO,eAAe,WAAW,GAAG,SAA2B;CAChG,MAAM,WAAW,OAAyB,IAAI;CAC9C,oBAAoB,WAAW,SAAS,OAA2B;CAEnE,OACE,qBAAC,OAAD;EAAK,WAAW,GAAG,YAAY,SAAS;EAAxC,UAAA;GACE,oBAAC,YAAD,EAAY,WAAU,uFAAwF,CAAA;GAE9G,oBAAC,OAAD;IACE,KAAK;IACE;IACP,WAAU;IACV,WAAU,UAAS,cAAc,MAAM,OAAO,KAAK;IACnD,GAAI;GACL,CAAA;GAEA,MAAM,SAAS,KACd,oBAAC,QAAD;IACE,SAAQ;IACR,MAAK;IACL,cAAW;IACX,QAAQ,oBAAC,YAAD,CAAa,CAAA;IACrB,WAAU;IACV,eAAe;KACb,cAAc,EAAE;KAChB,SAAS,SAAS,MAAM;IAC1B;GACD,CAAA;EAEA;;AAET"}
@@ -0,0 +1,83 @@
1
+ import { VariantProps } from "../lib/variants.js";
2
+ import { HeadingProps } from "./heading.js";
3
+ import { Stack } from "./stack.js";
4
+ import { useRender } from "@base-ui/react/use-render";
5
+ import { ComponentProps, ReactNode } from "react";
6
+ declare const sectionHeaderVariants: import("tailwind-variants").TVReturnType<{
7
+ alignment: {
8
+ left: string;
9
+ center: string;
10
+ };
11
+ size: {
12
+ page: string[];
13
+ card: string;
14
+ panel: string;
15
+ hero: string;
16
+ };
17
+ wrap: {
18
+ true: string;
19
+ false: string;
20
+ };
21
+ }, undefined, "flex items-center w-full min-w-0", undefined, undefined, undefined>;
22
+ type SectionHeaderProps = Omit<useRender.ComponentProps<"div">, "title"> & Omit<VariantProps<typeof sectionHeaderVariants>, "wrap"> & {
23
+ /**
24
+ * Keep the title block and the actions on one line instead of wrapping them.
25
+ */
26
+ wrap?: boolean;
27
+ /**
28
+ * Title block. Given any of `title`/`description`/`leading`/`actions`, the header renders
29
+ * its own `SectionHeaderBody` (empty if there is nothing but actions, so they still sit right);
30
+ * leave them all out to compose the body by hand, e.g. an entity header with dot-joined
31
+ * meta or the dashboard greeting.
32
+ */
33
+ title?: ReactNode;
34
+ description?: ReactNode;
35
+ actions?: ReactNode;
36
+ /**
37
+ * The link back to the list a record belongs to, above its title.
38
+ */
39
+ back?: ReactNode;
40
+ /**
41
+ * Leading visual beside the title, e.g. an entity avatar.
42
+ */
43
+ leading?: ReactNode;
44
+ };
45
+ /**
46
+ * The one header for every surface in the app: pages, cards, list panels, dialogs and settings
47
+ * sections. Pass `title`/`description`/`actions` for the standard block, or compose
48
+ * `SectionHeaderBody` + `SectionHeaderActions` as children when the content is bespoke.
49
+ */
50
+ declare function SectionHeader({ className, alignment, size, wrap, title, description, actions, back, leading, children, render, ...props }: SectionHeaderProps): import("react").JSX.Element;
51
+ /**
52
+ * The page title. Its visual size and semantic level both follow the header's `size`, so a
53
+ * page heading stays the route's single `<h1>` while cards and panels render `<h2>`s. Pass
54
+ * `size`/`as` to override either one on its own.
55
+ */
56
+ declare function SectionHeaderTitle({ size, as, className, ...props }: HeadingProps): import("react").JSX.Element;
57
+ /**
58
+ * The link back to the list a record belongs to, over the title: muted, one size on every
59
+ * page. The caller passes the link with its chevron.
60
+ */
61
+ declare function SectionHeaderBack({ className, ...props }: ComponentProps<"div">): import("react").JSX.Element;
62
+ type SectionHeaderBodyProps = ComponentProps<"div"> & {
63
+ /**
64
+ * Leading visual, e.g. an entity avatar.
65
+ */
66
+ leading?: ReactNode;
67
+ };
68
+ /**
69
+ * The one title block for every header in the app (pages, cards, dialogs, settings sections):
70
+ * an optional leading visual beside a column of `SectionHeaderTitle` + `SectionHeaderDescription`. Change the
71
+ * spacing here and it changes everywhere.
72
+ */
73
+ declare function SectionHeaderBody({ leading, children, className, ...props }: SectionHeaderBodyProps): import("react").JSX.Element;
74
+ /**
75
+ * The muted line under a title. Wraps by default; pass `truncate` for one-line entity meta.
76
+ */
77
+ declare function SectionHeaderDescription({ className, ...props }: ComponentProps<"p">): import("react").JSX.Element;
78
+ /**
79
+ * Right-aligned actions. Stops shrinking when the header is `wrap={false}`, so a long title
80
+ * truncates instead of squeezing the buttons.
81
+ */
82
+ declare function SectionHeaderActions({ className, ...props }: ComponentProps<typeof Stack>): import("react").JSX.Element;
83
+ export { SectionHeader, SectionHeaderActions, SectionHeaderBack, SectionHeaderBody, SectionHeaderDescription, SectionHeaderTitle };
@@ -0,0 +1,170 @@
1
+ "use client";
2
+ import { descriptionClasses } from "../lib/classes.js";
3
+ import { cn, variants } from "../lib/variants.js";
4
+ import { Heading } from "./heading.js";
5
+ import { Stack } from "./stack.js";
6
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
7
+ import { useRender } from "@base-ui/react/use-render";
8
+ import { createContext, use } from "react";
9
+ // src/components/section-header.tsx
10
+ const sectionHeaderVariants = variants({
11
+ base: "flex items-center w-full min-w-0",
12
+ variants: {
13
+ alignment: {
14
+ left: "justify-between text-start",
15
+ center: "justify-center text-center"
16
+ },
17
+ size: {
18
+ page: [
19
+ "gap-x-6 lg:gap-x-12",
20
+ "max-sm:grid max-sm:grid-cols-[minmax(0,1fr)_auto] max-sm:gap-x-3",
21
+ "max-sm:[grid-template-areas:'back_back'_'title_actions'_'description_description']"
22
+ ],
23
+ card: "gap-y-2 gap-x-6 max-sm:flex-col max-sm:items-stretch",
24
+ panel: "gap-y-2 gap-x-6 [&>*:first-child]:flex-auto",
25
+ hero: "gap-y-3 gap-x-6 lg:gap-x-12"
26
+ },
27
+ wrap: {
28
+ true: "flex-wrap",
29
+ false: "flex-nowrap"
30
+ }
31
+ },
32
+ defaultVariants: {
33
+ alignment: "left",
34
+ wrap: true
35
+ }
36
+ });
37
+ /**
38
+ * The title each header scale gets, alongside the spacing the variant above gives it: `page`
39
+ * for a route heading, `card` for a standalone card, `panel` for a dashboard or list panel,
40
+ * `hero` for the centered auth and callback screens. The `as` entry keeps the heading outline
41
+ * intact: one `<h1>` per route, `<h2>` for everything nested inside it.
42
+ */
43
+ const sectionHeaderTitles = {
44
+ page: {
45
+ size: "h3",
46
+ as: "h1"
47
+ },
48
+ card: {
49
+ size: "h4",
50
+ as: "h2"
51
+ },
52
+ panel: {
53
+ size: "h5",
54
+ as: "h2"
55
+ },
56
+ hero: {
57
+ size: "h2",
58
+ as: "h1"
59
+ }
60
+ };
61
+ const SectionHeaderContext = createContext({
62
+ size: "page",
63
+ wrap: true
64
+ });
65
+ /**
66
+ * The one header for every surface in the app: pages, cards, list panels, dialogs and settings
67
+ * sections. Pass `title`/`description`/`actions` for the standard block, or compose
68
+ * `SectionHeaderBody` + `SectionHeaderActions` as children when the content is bespoke.
69
+ */
70
+ function SectionHeader({ className, alignment = "left", size = "page", wrap = true, title, description, actions, back, leading, children, render, ...props }) {
71
+ const element = useRender({
72
+ render,
73
+ defaultTagName: "div",
74
+ props: {
75
+ className: sectionHeaderVariants({
76
+ alignment,
77
+ size,
78
+ wrap,
79
+ className
80
+ }),
81
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
82
+ (title || description || back || leading || actions) && /* @__PURE__ */ jsxs(SectionHeaderBody, {
83
+ leading,
84
+ className: cn(alignment === "center" && "justify-center"),
85
+ children: [
86
+ back && /* @__PURE__ */ jsx(SectionHeaderBack, { children: back }),
87
+ title && /* @__PURE__ */ jsx(SectionHeaderTitle, { children: title }),
88
+ description && /* @__PURE__ */ jsx(SectionHeaderDescription, { children: description })
89
+ ]
90
+ }),
91
+ actions && /* @__PURE__ */ jsx(SectionHeaderActions, { children: actions }),
92
+ children
93
+ ] }),
94
+ ...props
95
+ }
96
+ });
97
+ return /* @__PURE__ */ jsx(SectionHeaderContext, {
98
+ value: {
99
+ size,
100
+ wrap
101
+ },
102
+ children: element
103
+ });
104
+ }
105
+ /**
106
+ * The page title. Its visual size and semantic level both follow the header's `size`, so a
107
+ * page heading stays the route's single `<h1>` while cards and panels render `<h2>`s. Pass
108
+ * `size`/`as` to override either one on its own.
109
+ */
110
+ function SectionHeaderTitle({ size, as, className, ...props }) {
111
+ const context = use(SectionHeaderContext);
112
+ const preset = sectionHeaderTitles[context.size];
113
+ return /* @__PURE__ */ jsx(Heading, {
114
+ size: size ?? preset.size,
115
+ as: as ?? preset.as,
116
+ className: cn(context.size === "page" && "max-sm:text-xl max-sm:[grid-area:title]", className),
117
+ ...props
118
+ });
119
+ }
120
+ /**
121
+ * The link back to the list a record belongs to, over the title: muted, one size on every
122
+ * page. The caller passes the link with its chevron.
123
+ */
124
+ function SectionHeaderBack({ className, ...props }) {
125
+ const { size } = use(SectionHeaderContext);
126
+ return /* @__PURE__ */ jsx("div", {
127
+ className: cn("flex text-copy [&_svg]:size-3.5", size === "page" && "max-sm:mb-2 max-sm:[grid-area:back]", className),
128
+ ...props
129
+ });
130
+ }
131
+ /**
132
+ * The one title block for every header in the app (pages, cards, dialogs, settings sections):
133
+ * an optional leading visual beside a column of `SectionHeaderTitle` + `SectionHeaderDescription`. Change the
134
+ * spacing here and it changes everywhere.
135
+ */
136
+ function SectionHeaderBody({ leading, children, className, ...props }) {
137
+ const dissolve = use(SectionHeaderContext).size === "page" && !leading;
138
+ return /* @__PURE__ */ jsxs("div", {
139
+ className: cn("flex min-w-0 flex-1 items-center gap-3", dissolve && "max-sm:contents", className),
140
+ ...props,
141
+ children: [leading, /* @__PURE__ */ jsx("div", {
142
+ className: cn("flex min-w-0 flex-col gap-1.5", dissolve && "max-sm:contents"),
143
+ children
144
+ })]
145
+ });
146
+ }
147
+ /**
148
+ * The muted line under a title. Wraps by default; pass `truncate` for one-line entity meta.
149
+ */
150
+ function SectionHeaderDescription({ className, ...props }) {
151
+ const { size } = use(SectionHeaderContext);
152
+ return /* @__PURE__ */ jsx("p", {
153
+ className: cn(descriptionClasses, size === "page" && "max-sm:mt-2 max-sm:line-clamp-2 max-sm:[grid-area:description]", className),
154
+ ...props
155
+ });
156
+ }
157
+ /**
158
+ * Right-aligned actions. Stops shrinking when the header is `wrap={false}`, so a long title
159
+ * truncates instead of squeezing the buttons.
160
+ */
161
+ function SectionHeaderActions({ className, ...props }) {
162
+ const { size, wrap } = use(SectionHeaderContext);
163
+ return /* @__PURE__ */ jsx(Stack, {
164
+ className: cn("-my-0.5", !wrap && "shrink-0", size === "page" && "flex-nowrap gap-1.5 max-sm:[grid-area:actions]", className),
165
+ ...props
166
+ });
167
+ }
168
+ export { SectionHeader, SectionHeaderActions, SectionHeaderBack, SectionHeaderBody, SectionHeaderDescription, SectionHeaderTitle };
169
+
170
+ //# sourceMappingURL=section-header.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"section-header.js","names":[],"sources":["../../src/components/section-header.tsx"],"sourcesContent":["\"use client\"\n\nimport { useRender } from \"@base-ui/react/use-render\"\nimport { type ComponentProps, createContext, type ReactNode, use } from \"react\"\nimport { descriptionClasses } from \"../lib/classes\"\nimport { cn, variants, type VariantProps } from \"../lib/variants\"\nimport { Heading, type HeadingProps } from \"./heading\"\nimport { Stack } from \"./stack\"\n\nconst sectionHeaderVariants = variants({\n base: \"flex items-center w-full min-w-0\",\n\n variants: {\n alignment: {\n left: \"justify-between text-start\",\n center: \"justify-center text-center\",\n },\n size: {\n // On a phone the actions stay on the title's line and the description runs the full\n // width under both, so a page never spends a row on its actions alone. The body and its\n // column dissolve into this grid there (see `SectionHeaderBody`), and each part names\n // its own area.\n page: [\n \"gap-x-6 lg:gap-x-12\",\n \"max-sm:grid max-sm:grid-cols-[minmax(0,1fr)_auto] max-sm:gap-x-3\",\n \"max-sm:[grid-template-areas:'back_back'_'title_actions'_'description_description']\",\n ],\n card: \"gap-y-2 gap-x-6 max-sm:flex-col max-sm:items-stretch\",\n // The title block keeps its content width in the wrap calculation, so the actions (a\n // card's tab row) drop under it only when the two really cannot share the line.\n panel: \"gap-y-2 gap-x-6 [&>*:first-child]:flex-auto\",\n hero: \"gap-y-3 gap-x-6 lg:gap-x-12\",\n },\n wrap: {\n true: \"flex-wrap\",\n false: \"flex-nowrap\",\n },\n },\n\n defaultVariants: {\n alignment: \"left\",\n wrap: true,\n },\n})\n\ntype SectionHeaderSize = NonNullable<VariantProps<typeof sectionHeaderVariants>[\"size\"]>\n\n/**\n * The title each header scale gets, alongside the spacing the variant above gives it: `page`\n * for a route heading, `card` for a standalone card, `panel` for a dashboard or list panel,\n * `hero` for the centered auth and callback screens. The `as` entry keeps the heading outline\n * intact: one `<h1>` per route, `<h2>` for everything nested inside it.\n */\nconst sectionHeaderTitles = {\n page: { size: \"h3\", as: \"h1\" },\n card: { size: \"h4\", as: \"h2\" },\n panel: { size: \"h5\", as: \"h2\" },\n hero: { size: \"h2\", as: \"h1\" },\n} as const satisfies Record<SectionHeaderSize, { size: HeadingProps[\"size\"]; as: string }>\n\nconst SectionHeaderContext = createContext<{ size: SectionHeaderSize; wrap: boolean }>({\n size: \"page\",\n wrap: true,\n})\n\ntype SectionHeaderProps = Omit<useRender.ComponentProps<\"div\">, \"title\"> &\n Omit<VariantProps<typeof sectionHeaderVariants>, \"wrap\"> & {\n /**\n * Keep the title block and the actions on one line instead of wrapping them.\n */\n wrap?: boolean\n /**\n * Title block. Given any of `title`/`description`/`leading`/`actions`, the header renders\n * its own `SectionHeaderBody` (empty if there is nothing but actions, so they still sit right);\n * leave them all out to compose the body by hand, e.g. an entity header with dot-joined\n * meta or the dashboard greeting.\n */\n title?: ReactNode\n description?: ReactNode\n actions?: ReactNode\n /**\n * The link back to the list a record belongs to, above its title.\n */\n back?: ReactNode\n /**\n * Leading visual beside the title, e.g. an entity avatar.\n */\n leading?: ReactNode\n }\n\n/**\n * The one header for every surface in the app: pages, cards, list panels, dialogs and settings\n * sections. Pass `title`/`description`/`actions` for the standard block, or compose\n * `SectionHeaderBody` + `SectionHeaderActions` as children when the content is bespoke.\n */\nfunction SectionHeader({\n className,\n alignment = \"left\",\n size = \"page\",\n wrap = true,\n title,\n description,\n actions,\n back,\n leading,\n children,\n render,\n ...props\n}: SectionHeaderProps) {\n const element = useRender({\n render,\n defaultTagName: \"div\",\n props: {\n className: sectionHeaderVariants({ alignment, size, wrap, className }),\n children: (\n <>\n {/* `||`: a `false` or `\"\"` slot counts as missing. */}\n {/* oxlint-disable-next-line typescript/prefer-nullish-coalescing */}\n {(title || description || back || leading || actions) && (\n <SectionHeaderBody\n leading={leading}\n className={cn(alignment === \"center\" && \"justify-center\")}\n >\n {back && <SectionHeaderBack>{back}</SectionHeaderBack>}\n {title && <SectionHeaderTitle>{title}</SectionHeaderTitle>}\n {description && <SectionHeaderDescription>{description}</SectionHeaderDescription>}\n </SectionHeaderBody>\n )}\n\n {actions && <SectionHeaderActions>{actions}</SectionHeaderActions>}\n\n {children}\n </>\n ),\n ...props,\n },\n })\n\n return <SectionHeaderContext value={{ size, wrap }}>{element}</SectionHeaderContext>\n}\n\n/**\n * The page title. Its visual size and semantic level both follow the header's `size`, so a\n * page heading stays the route's single `<h1>` while cards and panels render `<h2>`s. Pass\n * `size`/`as` to override either one on its own.\n */\nfunction SectionHeaderTitle({ size, as, className, ...props }: HeadingProps) {\n const context = use(SectionHeaderContext)\n const preset = sectionHeaderTitles[context.size]\n\n return (\n <Heading\n size={size ?? preset.size}\n as={as ?? preset.as}\n // A page title steps down to 20px on a phone, where it shares its line with the actions.\n className={cn(\n context.size === \"page\" && \"max-sm:text-xl max-sm:[grid-area:title]\",\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * The link back to the list a record belongs to, over the title: muted, one size on every\n * page. The caller passes the link with its chevron.\n */\nfunction SectionHeaderBack({ className, ...props }: ComponentProps<\"div\">) {\n const { size } = use(SectionHeaderContext)\n\n return (\n <div\n className={cn(\n \"flex text-copy [&_svg]:size-3.5\",\n size === \"page\" && \"max-sm:mb-2 max-sm:[grid-area:back]\",\n className,\n )}\n {...props}\n />\n )\n}\n\ntype SectionHeaderBodyProps = ComponentProps<\"div\"> & {\n /**\n * Leading visual, e.g. an entity avatar.\n */\n leading?: ReactNode\n}\n\n/**\n * The one title block for every header in the app (pages, cards, dialogs, settings sections):\n * an optional leading visual beside a column of `SectionHeaderTitle` + `SectionHeaderDescription`. Change the\n * spacing here and it changes everywhere.\n */\nfunction SectionHeaderBody({ leading, children, className, ...props }: SectionHeaderBodyProps) {\n // A page header without a leading visual hands its parts to the header's phone grid.\n const dissolve = use(SectionHeaderContext).size === \"page\" && !leading\n\n return (\n <div\n className={cn(\n \"flex min-w-0 flex-1 items-center gap-3\",\n dissolve && \"max-sm:contents\",\n className,\n )}\n {...props}\n >\n {leading}\n <div className={cn(\"flex min-w-0 flex-col gap-1.5\", dissolve && \"max-sm:contents\")}>\n {children}\n </div>\n </div>\n )\n}\n\n/**\n * The muted line under a title. Wraps by default; pass `truncate` for one-line entity meta.\n */\nfunction SectionHeaderDescription({ className, ...props }: ComponentProps<\"p\">) {\n const { size } = use(SectionHeaderContext)\n\n return (\n <p\n className={cn(\n descriptionClasses,\n // Two lines at most on a phone, so a long one never pushes the page down.\n size === \"page\" && \"max-sm:mt-2 max-sm:line-clamp-2 max-sm:[grid-area:description]\",\n className,\n )}\n {...props}\n />\n )\n}\n\n/**\n * Right-aligned actions. Stops shrinking when the header is `wrap={false}`, so a long title\n * truncates instead of squeezing the buttons.\n */\nfunction SectionHeaderActions({ className, ...props }: ComponentProps<typeof Stack>) {\n const { size, wrap } = use(SectionHeaderContext)\n\n return (\n <Stack\n className={cn(\n \"-my-0.5\",\n !wrap && \"shrink-0\",\n // A page's actions sit as close as the toolbar's controls, and on a phone they hold the\n // end of the title's line.\n size === \"page\" && \"flex-nowrap gap-1.5 max-sm:[grid-area:actions]\",\n className,\n )}\n {...props}\n />\n )\n}\n\nexport {\n SectionHeader,\n SectionHeaderTitle,\n SectionHeaderBack,\n SectionHeaderBody,\n SectionHeaderDescription,\n SectionHeaderActions,\n}\n"],"mappings":";;;;;;;;;AASA,MAAM,wBAAwB,SAAS;CACrC,MAAM;CAEN,UAAU;EACR,WAAW;GACT,MAAM;GACN,QAAQ;EACV;EACA,MAAM;GAKJ,MAAM;IACJ;IACA;IACA;GACF;GACA,MAAM;GAGN,OAAO;GACP,MAAM;EACR;EACA,MAAM;GACJ,MAAM;GACN,OAAO;EACT;CACF;CAEA,iBAAiB;EACf,WAAW;EACX,MAAM;CACR;AACF,CAAC;;;;;;;AAUD,MAAM,sBAAsB;CAC1B,MAAM;EAAE,MAAM;EAAM,IAAI;CAAK;CAC7B,MAAM;EAAE,MAAM;EAAM,IAAI;CAAK;CAC7B,OAAO;EAAE,MAAM;EAAM,IAAI;CAAK;CAC9B,MAAM;EAAE,MAAM;EAAM,IAAI;CAAK;AAC/B;AAEA,MAAM,uBAAuB,cAA0D;CACrF,MAAM;CACN,MAAM;AACR,CAAC;;;;;;AAgCD,SAAS,cAAc,EACrB,WACA,YAAY,QACZ,OAAO,QACP,OAAO,MACP,OACA,aACA,SACA,MACA,SACA,UACA,QACA,GAAG,SACkB;CACrB,MAAM,UAAU,UAAU;EACxB;EACA,gBAAgB;EAChB,OAAO;GACL,WAAW,sBAAsB;IAAE;IAAW;IAAM;IAAM;GAAU,CAAC;GACrE,UACE,qBAAA,UAAA,EAAA,UAAA;KAGI,SAAS,eAAe,QAAQ,WAAW,YAC3C,qBAAC,mBAAD;KACW;KACT,WAAW,GAAG,cAAc,YAAY,gBAAgB;KAF1D,UAAA;MAIG,QAAQ,oBAAC,mBAAD,EAAA,UAAoB,KAAwB,CAAA;MACpD,SAAS,oBAAC,oBAAD,EAAA,UAAqB,MAA0B,CAAA;MACxD,eAAe,oBAAC,0BAAD,EAAA,UAA2B,YAAsC,CAAA;KAChE;;IAGpB,WAAW,oBAAC,sBAAD,EAAA,UAAuB,QAA8B,CAAA;IAEhE;GACD,EAAA,CAAA;GAEJ,GAAG;EACL;CACF,CAAC;CAED,OAAO,oBAAC,sBAAD;EAAsB,OAAO;GAAE;GAAM;EAAK;EAAI,UAAA;CAA8B,CAAA;AACrF;;;;;;AAOA,SAAS,mBAAmB,EAAE,MAAM,IAAI,WAAW,GAAG,SAAuB;CAC3E,MAAM,UAAU,IAAI,oBAAoB;CACxC,MAAM,SAAS,oBAAoB,QAAQ;CAE3C,OACE,oBAAC,SAAD;EACE,MAAM,QAAQ,OAAO;EACrB,IAAI,MAAM,OAAO;EAEjB,WAAW,GACT,QAAQ,SAAS,UAAU,2CAC3B,SACF;EACA,GAAI;CACL,CAAA;AAEL;;;;;AAMA,SAAS,kBAAkB,EAAE,WAAW,GAAG,SAAgC;CACzE,MAAM,EAAE,SAAS,IAAI,oBAAoB;CAEzC,OACE,oBAAC,OAAD;EACE,WAAW,GACT,mCACA,SAAS,UAAU,uCACnB,SACF;EACA,GAAI;CACL,CAAA;AAEL;;;;;;AAcA,SAAS,kBAAkB,EAAE,SAAS,UAAU,WAAW,GAAG,SAAiC;CAE7F,MAAM,WAAW,IAAI,oBAAoB,CAAC,CAAC,SAAS,UAAU,CAAC;CAE/D,OACE,qBAAC,OAAD;EACE,WAAW,GACT,0CACA,YAAY,mBACZ,SACF;EACA,GAAI;EANN,UAAA,CAQG,SACD,oBAAC,OAAD;GAAK,WAAW,GAAG,iCAAiC,YAAY,iBAAiB;GAC9E;EACE,CAAA,CACF;;AAET;;;;AAKA,SAAS,yBAAyB,EAAE,WAAW,GAAG,SAA8B;CAC9E,MAAM,EAAE,SAAS,IAAI,oBAAoB;CAEzC,OACE,oBAAC,KAAD;EACE,WAAW,GACT,oBAEA,SAAS,UAAU,kEACnB,SACF;EACA,GAAI;CACL,CAAA;AAEL;;;;;AAMA,SAAS,qBAAqB,EAAE,WAAW,GAAG,SAAuC;CACnF,MAAM,EAAE,MAAM,SAAS,IAAI,oBAAoB;CAE/C,OACE,oBAAC,OAAD;EACE,WAAW,GACT,WACA,CAAC,QAAQ,YAGT,SAAS,UAAU,kDACnB,SACF;EACA,GAAI;CACL,CAAA;AAEL"}
@@ -0,0 +1,24 @@
1
+ import { segmentedVariants } from "../lib/segmented.js";
2
+ import { VariantProps } from "../lib/variants.js";
3
+ import { JSX } from "react";
4
+ import { Radio } from "@base-ui/react/radio";
5
+ import { RadioGroup } from "@base-ui/react/radio-group";
6
+ export type SegmentedControlProps<Value> = RadioGroup.Props<Value> & VariantProps<typeof segmentedVariants>;
7
+ /**
8
+ * One choice out of a few short options, drawn as a row with a pill behind the chosen one: a
9
+ * theme, a billing interval, the framework a snippet is written for. It is a radio group, so
10
+ * the arrow keys move the choice and a screen reader announces "radio, 2 of 3"; a row whose
11
+ * options each show a panel of their own is `Tabs`.
12
+ *
13
+ * The pill is measured after layout. Until then the checked option paints its own fill, so a
14
+ * server render, or a page before hydration, already shows the choice.
15
+ */
16
+ declare function SegmentedControl<Value>({ className, children, variant, size, value, defaultValue, onValueChange, ...props }: SegmentedControlProps<Value>): JSX.Element;
17
+ export type SegmentedControlItemProps<Value> = Radio.Root.Props<Value>;
18
+ /**
19
+ * One option in a `SegmentedControl`; its children are its label. Memoised, as a row
20
+ * re-renders with its card and its options rarely change with it; `memo` drops the `Value`
21
+ * parameter, so the cast below puts it back.
22
+ */
23
+ declare const SegmentedControlItem: <Value>(props: SegmentedControlItemProps<Value>) => JSX.Element;
24
+ export { SegmentedControl, SegmentedControlItem };