@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,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":"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"}
@@ -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 };
@@ -0,0 +1,70 @@
1
+ "use client";
2
+ import { SEGMENTED_INDICATOR_BOX, SEGMENTED_UNMEASURED_KEY, segmentedVariants, useSegmentedIndicator } from "../lib/segmented.js";
3
+ import { cn } from "../lib/variants.js";
4
+ import { jsx, jsxs } from "react/jsx-runtime";
5
+ import { createContext, isValidElement, memo, use, useState } from "react";
6
+ import { Radio } from "@base-ui/react/radio";
7
+ import { RadioGroup } from "@base-ui/react/radio-group";
8
+ // src/components/segmented-control.tsx
9
+ const SegmentedControlContext = createContext({
10
+ variant: "segmented",
11
+ size: "md"
12
+ });
13
+ /**
14
+ * One choice out of a few short options, drawn as a row with a pill behind the chosen one: a
15
+ * theme, a billing interval, the framework a snippet is written for. It is a radio group, so
16
+ * the arrow keys move the choice and a screen reader announces "radio, 2 of 3"; a row whose
17
+ * options each show a panel of their own is `Tabs`.
18
+ *
19
+ * The pill is measured after layout. Until then the checked option paints its own fill, so a
20
+ * server render, or a page before hydration, already shows the choice.
21
+ */
22
+ function SegmentedControl({ className, children, variant = "segmented", size = "md", value, defaultValue, onValueChange, ...props }) {
23
+ const [uncontrolled, setUncontrolled] = useState(defaultValue);
24
+ const ref = useSegmentedIndicator(value ?? uncontrolled);
25
+ const slots = segmentedVariants({
26
+ variant,
27
+ size
28
+ });
29
+ return /* @__PURE__ */ jsx(SegmentedControlContext, {
30
+ value: {
31
+ variant,
32
+ size
33
+ },
34
+ children: /* @__PURE__ */ jsxs(RadioGroup, {
35
+ ref,
36
+ value,
37
+ defaultValue,
38
+ className: cn(slots.root(), variant === "segmented" ? SEGMENTED_UNMEASURED_KEY : "[&:not([data-measured])_[data-checked]]:bg-fill", className),
39
+ onValueChange: (next, eventDetails) => {
40
+ setUncontrolled(next);
41
+ onValueChange?.(next, eventDetails);
42
+ },
43
+ ...props,
44
+ children: [/* @__PURE__ */ jsx("span", {
45
+ "aria-hidden": true,
46
+ className: slots.indicator({ className: SEGMENTED_INDICATOR_BOX })
47
+ }), children]
48
+ })
49
+ });
50
+ }
51
+ /**
52
+ * One option in a `SegmentedControl`; its children are its label. Memoised, as a row
53
+ * re-renders with its card and its options rarely change with it; `memo` drops the `Value`
54
+ * parameter, so the cast below puts it back.
55
+ */
56
+ const SegmentedControlItem = memo(function SegmentedControlItem({ className, ...props }) {
57
+ const { variant, size } = use(SegmentedControlContext);
58
+ const icon = Boolean(props["aria-label"]) && isValidElement(props.children);
59
+ return /* @__PURE__ */ jsx(Radio.Root, {
60
+ className: cn(segmentedVariants({
61
+ variant,
62
+ size,
63
+ icon
64
+ }).item(), "not-data-disabled:cursor-pointer data-disabled:opacity-50 data-checked:text-ink", className),
65
+ ...props
66
+ });
67
+ });
68
+ export { SegmentedControl, SegmentedControlItem };
69
+
70
+ //# sourceMappingURL=segmented-control.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"segmented-control.js","names":["RadioGroupPrimitive","RadioPrimitive"],"sources":["../../src/components/segmented-control.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 { createContext, isValidElement, type JSX, memo, use, useState } from \"react\"\nimport {\n SEGMENTED_INDICATOR_BOX,\n SEGMENTED_UNMEASURED_KEY,\n type SegmentedStyle,\n segmentedVariants,\n useSegmentedIndicator,\n} from \"../lib/segmented\"\nimport { cn, type VariantProps } from \"../lib/variants\"\n\n// The parts below merge `className` outside the variants call, unlike everywhere else: Base UI\n// types it as a function of the part's own state too, which `variants` cannot take.\n\nconst SegmentedControlContext = createContext<SegmentedStyle>({\n variant: \"segmented\",\n size: \"md\",\n})\n\nexport type SegmentedControlProps<Value> = RadioGroupPrimitive.Props<Value> &\n VariantProps<typeof segmentedVariants>\n\n/**\n * One choice out of a few short options, drawn as a row with a pill behind the chosen one: a\n * theme, a billing interval, the framework a snippet is written for. It is a radio group, so\n * the arrow keys move the choice and a screen reader announces \"radio, 2 of 3\"; a row whose\n * options each show a panel of their own is `Tabs`.\n *\n * The pill is measured after layout. Until then the checked option paints its own fill, so a\n * server render, or a page before hydration, already shows the choice.\n */\nfunction SegmentedControl<Value>({\n className,\n children,\n variant = \"segmented\",\n size = \"md\",\n value,\n defaultValue,\n onValueChange,\n ...props\n}: SegmentedControlProps<Value>) {\n // Followed here only to know when to measure again; Base UI still owns the value.\n const [uncontrolled, setUncontrolled] = useState(defaultValue)\n const ref = useSegmentedIndicator(value ?? uncontrolled)\n\n const slots = segmentedVariants({ variant, size })\n\n return (\n <SegmentedControlContext value={{ variant, size }}>\n <RadioGroupPrimitive\n ref={ref}\n value={value}\n defaultValue={defaultValue}\n className={cn(\n slots.root(),\n variant === \"segmented\"\n ? SEGMENTED_UNMEASURED_KEY\n : \"[&:not([data-measured])_[data-checked]]:bg-fill\",\n className,\n )}\n onValueChange={(next, eventDetails) => {\n setUncontrolled(next)\n onValueChange?.(next, eventDetails)\n }}\n {...props}\n >\n <span aria-hidden className={slots.indicator({ className: SEGMENTED_INDICATOR_BOX })} />\n {children}\n </RadioGroupPrimitive>\n </SegmentedControlContext>\n )\n}\n\nexport type SegmentedControlItemProps<Value> = RadioPrimitive.Root.Props<Value>\n\n/**\n * One option in a `SegmentedControl`; its children are its label. Memoised, as a row\n * re-renders with its card and its options rarely change with it; `memo` drops the `Value`\n * parameter, so the cast below puts it back.\n */\nconst SegmentedControlItem = memo(function SegmentedControlItem<Value>({\n className,\n ...props\n}: SegmentedControlItemProps<Value>) {\n const { variant, size } = use(SegmentedControlContext)\n // Named by `aria-label` and showing one element: an icon, drawn as a square.\n const icon = Boolean(props[\"aria-label\"]) && isValidElement(props.children)\n\n return (\n <RadioPrimitive.Root\n className={cn(\n segmentedVariants({ variant, size, icon }).item(),\n \"not-data-disabled:cursor-pointer data-disabled:opacity-50 data-checked:text-ink\",\n className,\n )}\n {...props}\n />\n )\n}) as <Value>(props: SegmentedControlItemProps<Value>) => JSX.Element\n\nexport { SegmentedControl, SegmentedControlItem }\n"],"mappings":";;;;;;;;AAiBA,MAAM,0BAA0B,cAA8B;CAC5D,SAAS;CACT,MAAM;AACR,CAAC;;;;;;;;;;AAcD,SAAS,iBAAwB,EAC/B,WACA,UACA,UAAU,aACV,OAAO,MACP,OACA,cACA,eACA,GAAG,SAC4B;CAE/B,MAAM,CAAC,cAAc,mBAAmB,SAAS,YAAY;CAC7D,MAAM,MAAM,sBAAsB,SAAS,YAAY;CAEvD,MAAM,QAAQ,kBAAkB;EAAE;EAAS;CAAK,CAAC;CAEjD,OACE,oBAAC,yBAAD;EAAyB,OAAO;GAAE;GAAS;EAAK;EAC9C,UAAA,qBAACA,YAAD;GACO;GACE;GACO;GACd,WAAW,GACT,MAAM,KAAK,GACX,YAAY,cACR,2BACA,mDACJ,SACF;GACA,gBAAgB,MAAM,iBAAiB;IACrC,gBAAgB,IAAI;IACpB,gBAAgB,MAAM,YAAY;GACpC;GACA,GAAI;GAfN,UAAA,CAiBE,oBAAC,QAAD;IAAM,eAAA;IAAY,WAAW,MAAM,UAAU,EAAE,WAAW,wBAAwB,CAAC;GAAI,CAAA,GACtF,QACkB;;CACE,CAAA;AAE7B;;;;;;AASA,MAAM,uBAAuB,KAAK,SAAS,qBAA4B,EACrE,WACA,GAAG,SACgC;CACnC,MAAM,EAAE,SAAS,SAAS,IAAI,uBAAuB;CAErD,MAAM,OAAO,QAAQ,MAAM,aAAa,KAAK,eAAe,MAAM,QAAQ;CAE1E,OACE,oBAACC,MAAe,MAAhB;EACE,WAAW,GACT,kBAAkB;GAAE;GAAS;GAAM;EAAK,CAAC,CAAC,CAAC,KAAK,GAChD,mFACA,SACF;EACA,GAAI;CACL,CAAA;AAEL,CAAC"}
@@ -0,0 +1,28 @@
1
+ import { VariantProps } from "../lib/variants.js";
2
+ import { inputVariants } from "./input.js";
3
+ import { ReactNode } from "react";
4
+ import { Select as Select$1 } from "@base-ui/react/select";
5
+ /** Not modal, as a menu is. Base UI's own default is modal. */
6
+ declare function Select<Value, Multiple extends boolean | undefined = false>(props: Select$1.Root.Props<Value, Multiple>): import("react").JSX.Element;
7
+ declare const SelectGroup: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").SelectGroupProps, "ref"> & import("react").RefAttributes<HTMLDivElement>>;
8
+ declare const SelectValue: import("react").ForwardRefExoticComponent<Omit<import("@base-ui/react").SelectValueProps, "ref"> & import("react").RefAttributes<HTMLSpanElement>>;
9
+ declare function SelectTrigger({ children, className, interactive, size, ...props }: Select$1.Trigger.Props & VariantProps<typeof inputVariants>): import("react").JSX.Element;
10
+ declare function SelectScrollUpButton({ className, ...props }: Select$1.ScrollUpArrow.Props): import("react").JSX.Element;
11
+ declare function SelectScrollDownButton({ className, ...props }: Select$1.ScrollDownArrow.Props): import("react").JSX.Element;
12
+ declare function SelectContent({ className, children, align, side, sideOffset, alignItemWithTrigger, ...props }: Select$1.Popup.Props & Pick<Select$1.Positioner.Props, "align" | "side" | "sideOffset" | "alignItemWithTrigger">): import("react").JSX.Element;
13
+ declare function SelectLabel({ className, ...props }: Select$1.GroupLabel.Props): import("react").JSX.Element;
14
+ interface SelectItemProps extends Omit<Select$1.Item.Props, "prefix"> {
15
+ prefix?: ReactNode;
16
+ /**
17
+ * Why the option cannot be chosen. It stays in the list, disabled but reachable with the arrow
18
+ * keys, and the reason is read with it and shown in a tooltip, which a tap opens too.
19
+ */
20
+ disabledReason?: string;
21
+ }
22
+ /**
23
+ * One option. The check ends the row in muted ink, as in a menu, so the label keeps the row's
24
+ * inset whether or not the option carries a leading glyph.
25
+ */
26
+ declare function SelectItem({ className, children, label, prefix, disabled, disabledReason, onPointerUp, ...props }: SelectItemProps): import("react").JSX.Element;
27
+ declare function SelectSeparator({ className, ...props }: Select$1.Separator.Props): import("react").JSX.Element;
28
+ export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue };
@@ -0,0 +1,129 @@
1
+ "use client";
2
+ import { popoverAnimationClasses, popupBackdropClasses, popupGroupLabelClasses, popupItemClasses, popupSeparatorClasses, popupSurfaceClasses } from "../lib/classes.js";
3
+ import { CheckIcon, ChevronDownIcon, ChevronUpIcon, ChevronsUpDownIcon } from "../lib/icons.js";
4
+ import { cn, variants } from "../lib/variants.js";
5
+ import { useDisabledReason } from "./disabled-reason.js";
6
+ import { inputVariants } from "./input.js";
7
+ import { Tooltip } from "./tooltip.js";
8
+ import { jsx, jsxs } from "react/jsx-runtime";
9
+ import { Select as Select$1 } from "@base-ui/react/select";
10
+ // src/components/select.tsx
11
+ /** Not modal, as a menu is. Base UI's own default is modal. */
12
+ function Select(props) {
13
+ return /* @__PURE__ */ jsx(Select$1.Root, {
14
+ modal: false,
15
+ ...props
16
+ });
17
+ }
18
+ const SelectGroup = Select$1.Group;
19
+ const SelectValue = Select$1.Value;
20
+ function SelectTrigger({ children, className, interactive = true, size, ...props }) {
21
+ return /* @__PURE__ */ jsxs(Select$1.Trigger, {
22
+ className: inputVariants({
23
+ interactive,
24
+ size,
25
+ className: cn("flex items-center justify-between", "data-popup-open:border-edge-solid data-popup-open:bg-fill-subtle", interactive && "active:not-disabled:bg-fill-subtle", className)
26
+ }),
27
+ ...props,
28
+ children: [/* @__PURE__ */ jsx("span", {
29
+ className: "truncate",
30
+ children
31
+ }), /* @__PURE__ */ jsx(Select$1.Icon, { render: /* @__PURE__ */ jsx(ChevronsUpDownIcon, { className: "ml-1 size-3.5 shrink-0 text-ink-muted" }) })]
32
+ });
33
+ }
34
+ function SelectScrollUpButton({ className, ...props }) {
35
+ return /* @__PURE__ */ jsx(Select$1.ScrollUpArrow, {
36
+ className: cn("flex cursor-pointer items-center justify-center py-1", className),
37
+ ...props,
38
+ children: /* @__PURE__ */ jsx(ChevronUpIcon, {})
39
+ });
40
+ }
41
+ function SelectScrollDownButton({ className, ...props }) {
42
+ return /* @__PURE__ */ jsx(Select$1.ScrollDownArrow, {
43
+ className: cn("flex cursor-pointer items-center justify-center py-1", className),
44
+ ...props,
45
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, {})
46
+ });
47
+ }
48
+ const selectScrollButtonVariants = variants({
49
+ base: "absolute inset-x-0 z-10 bg-overlay animate-in fade-in-0 duration-150 ease-out",
50
+ variants: { position: {
51
+ top: "top-0 mask-b-from-0",
52
+ bottom: "bottom-0 mask-t-from-0"
53
+ } }
54
+ });
55
+ function SelectContent({ className, children, align, side, sideOffset = 6, alignItemWithTrigger = false, ...props }) {
56
+ return /* @__PURE__ */ jsxs(Select$1.Portal, { children: [/* @__PURE__ */ jsx(Select$1.Backdrop, { className: popupBackdropClasses }), /* @__PURE__ */ jsx(Select$1.Positioner, {
57
+ sideOffset,
58
+ align,
59
+ side,
60
+ alignItemWithTrigger,
61
+ className: "isolate z-50",
62
+ children: /* @__PURE__ */ jsxs(Select$1.Popup, {
63
+ className: cn(popupSurfaceClasses, "relative z-50 isolate max-h-(--available-height) min-w-(--anchor-width) overflow-hidden outline-none", !alignItemWithTrigger && popoverAnimationClasses, className),
64
+ ...props,
65
+ children: [
66
+ /* @__PURE__ */ jsx(SelectScrollUpButton, { className: selectScrollButtonVariants({ position: "top" }) }),
67
+ /* @__PURE__ */ jsx(Select$1.List, {
68
+ className: "max-h-(--available-height) overflow-y-auto overscroll-contain p-1",
69
+ children
70
+ }),
71
+ /* @__PURE__ */ jsx(SelectScrollDownButton, { className: selectScrollButtonVariants({ position: "bottom" }) })
72
+ ]
73
+ })
74
+ })] });
75
+ }
76
+ function SelectLabel({ className, ...props }) {
77
+ return /* @__PURE__ */ jsx(Select$1.GroupLabel, {
78
+ className: cn(popupGroupLabelClasses, className),
79
+ ...props
80
+ });
81
+ }
82
+ /**
83
+ * One option. The check ends the row in muted ink, as in a menu, so the label keeps the row's
84
+ * inset whether or not the option carries a leading glyph.
85
+ */
86
+ function SelectItem({ className, children, label, prefix, disabled, disabledReason, onPointerUp, ...props }) {
87
+ const reason = useDisabledReason(disabledReason, props["aria-describedby"]);
88
+ return /* @__PURE__ */ jsx(Tooltip, {
89
+ id: reason.triggerId,
90
+ tooltip: disabledReason,
91
+ side: "left",
92
+ children: /* @__PURE__ */ jsxs(Select$1.Item, {
93
+ ...props,
94
+ label: label ?? (typeof children === "string" ? children : void 0),
95
+ disabled: disabled === true || !!disabledReason,
96
+ "aria-describedby": reason.describedBy,
97
+ onPointerUp: (event) => {
98
+ onPointerUp?.(event);
99
+ reason.onPointerUp(event);
100
+ },
101
+ className: cn(popupItemClasses, "group/choice w-full gap-2 px-2 data-selected:text-ink", className),
102
+ children: [
103
+ prefix != null && /* @__PURE__ */ jsx("span", {
104
+ className: "flex shrink-0 text-ink-muted [&>svg]:size-4",
105
+ children: prefix
106
+ }),
107
+ /* @__PURE__ */ jsx(Select$1.ItemText, {
108
+ className: "truncate",
109
+ children
110
+ }),
111
+ /* @__PURE__ */ jsx("span", {
112
+ "aria-hidden": true,
113
+ className: "ml-auto hidden shrink-0 pl-4 text-ink-muted group-data-selected/choice:flex",
114
+ children: /* @__PURE__ */ jsx(Select$1.ItemIndicator, { children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4" }) })
115
+ }),
116
+ reason.reasonText
117
+ ]
118
+ })
119
+ });
120
+ }
121
+ function SelectSeparator({ className, ...props }) {
122
+ return /* @__PURE__ */ jsx(Select$1.Separator, {
123
+ className: cn(popupSeparatorClasses, className),
124
+ ...props
125
+ });
126
+ }
127
+ export { Select, SelectContent, SelectGroup, SelectItem, SelectLabel, SelectScrollDownButton, SelectScrollUpButton, SelectSeparator, SelectTrigger, SelectValue };
128
+
129
+ //# sourceMappingURL=select.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"select.js","names":["SelectPrimitive"],"sources":["../../src/components/select.tsx"],"sourcesContent":["\"use client\"\n\nimport { Select as SelectPrimitive } from \"@base-ui/react/select\"\nimport type { ReactNode } from \"react\"\nimport {\n POPUP_SIDE_OFFSET,\n popoverAnimationClasses,\n popupBackdropClasses,\n popupGroupLabelClasses,\n popupItemClasses,\n popupSeparatorClasses,\n popupSurfaceClasses,\n} from \"../lib/classes\"\nimport { CheckIcon, ChevronDownIcon, ChevronUpIcon, ChevronsUpDownIcon } from \"../lib/icons\"\nimport { cn, variants, type VariantProps } from \"../lib/variants\"\nimport { useDisabledReason } from \"./disabled-reason\"\nimport { inputVariants } from \"./input\"\nimport { Tooltip } from \"./tooltip\"\n\n/** Not modal, as a menu is. Base UI's own default is modal. */\nfunction Select<Value, Multiple extends boolean | undefined = false>(\n props: SelectPrimitive.Root.Props<Value, Multiple>,\n) {\n return <SelectPrimitive.Root modal={false} {...props} />\n}\n\nconst SelectGroup = SelectPrimitive.Group\nconst SelectValue = SelectPrimitive.Value\n\nfunction SelectTrigger({\n children,\n className,\n interactive = true,\n size,\n ...props\n}: SelectPrimitive.Trigger.Props & VariantProps<typeof inputVariants>) {\n return (\n <SelectPrimitive.Trigger\n className={inputVariants({\n interactive,\n size,\n className: cn(\n \"flex items-center justify-between\",\n \"data-popup-open:border-edge-solid data-popup-open:bg-fill-subtle\",\n interactive && \"active:not-disabled:bg-fill-subtle\",\n className,\n ),\n })}\n {...props}\n >\n <span className=\"truncate\">{children}</span>\n\n <SelectPrimitive.Icon\n render={<ChevronsUpDownIcon className=\"ml-1 size-3.5 shrink-0 text-ink-muted\" />}\n />\n </SelectPrimitive.Trigger>\n )\n}\n\nfunction SelectScrollUpButton({ className, ...props }: SelectPrimitive.ScrollUpArrow.Props) {\n return (\n <SelectPrimitive.ScrollUpArrow\n className={cn(\"flex cursor-pointer items-center justify-center py-1\", className)}\n {...props}\n >\n <ChevronUpIcon />\n </SelectPrimitive.ScrollUpArrow>\n )\n}\n\nfunction SelectScrollDownButton({ className, ...props }: SelectPrimitive.ScrollDownArrow.Props) {\n return (\n <SelectPrimitive.ScrollDownArrow\n className={cn(\"flex cursor-pointer items-center justify-center py-1\", className)}\n {...props}\n >\n <ChevronDownIcon />\n </SelectPrimitive.ScrollDownArrow>\n )\n}\n\nconst selectScrollButtonVariants = variants({\n base: \"absolute inset-x-0 z-10 bg-overlay animate-in fade-in-0 duration-150 ease-out\",\n variants: {\n position: {\n top: \"top-0 mask-b-from-0\",\n bottom: \"bottom-0 mask-t-from-0\",\n },\n },\n})\n\nfunction SelectContent({\n className,\n children,\n align,\n side,\n sideOffset = POPUP_SIDE_OFFSET,\n alignItemWithTrigger = false,\n ...props\n}: SelectPrimitive.Popup.Props &\n Pick<\n SelectPrimitive.Positioner.Props,\n \"align\" | \"side\" | \"sideOffset\" | \"alignItemWithTrigger\"\n >) {\n return (\n <SelectPrimitive.Portal>\n <SelectPrimitive.Backdrop className={popupBackdropClasses} />\n <SelectPrimitive.Positioner\n sideOffset={sideOffset}\n align={align}\n side={side}\n alignItemWithTrigger={alignItemWithTrigger}\n className=\"isolate z-50\"\n >\n <SelectPrimitive.Popup\n className={cn(\n popupSurfaceClasses,\n \"relative z-50 isolate max-h-(--available-height) min-w-(--anchor-width) overflow-hidden outline-none\",\n !alignItemWithTrigger && popoverAnimationClasses,\n className,\n )}\n {...props}\n >\n <SelectScrollUpButton className={selectScrollButtonVariants({ position: \"top\" })} />\n {/* The list is the scroller (not the popup), so the scroll arrows can overlay it. */}\n <SelectPrimitive.List className=\"max-h-(--available-height) overflow-y-auto overscroll-contain p-1\">\n {children}\n </SelectPrimitive.List>\n <SelectScrollDownButton className={selectScrollButtonVariants({ position: \"bottom\" })} />\n </SelectPrimitive.Popup>\n </SelectPrimitive.Positioner>\n </SelectPrimitive.Portal>\n )\n}\n\nfunction SelectLabel({ className, ...props }: SelectPrimitive.GroupLabel.Props) {\n return <SelectPrimitive.GroupLabel className={cn(popupGroupLabelClasses, className)} {...props} />\n}\n\ninterface SelectItemProps extends Omit<SelectPrimitive.Item.Props, \"prefix\"> {\n prefix?: ReactNode\n /**\n * Why the option cannot be chosen. It stays in the list, disabled but reachable with the arrow\n * keys, and the reason is read with it and shown in a tooltip, which a tap opens too.\n */\n disabledReason?: string\n}\n\n/**\n * One option. The check ends the row in muted ink, as in a menu, so the label keeps the row's\n * inset whether or not the option carries a leading glyph.\n */\nfunction SelectItem({\n className,\n children,\n label,\n prefix,\n disabled,\n disabledReason,\n onPointerUp,\n ...props\n}: SelectItemProps) {\n const reason = useDisabledReason(disabledReason, props[\"aria-describedby\"])\n\n return (\n <Tooltip id={reason.triggerId} tooltip={disabledReason} side=\"left\">\n <SelectPrimitive.Item\n // First, so the caller's description and pointer-up merge with the reason's.\n {...props}\n label={label ?? (typeof children === \"string\" ? children : undefined)}\n disabled={disabled === true || !!disabledReason}\n aria-describedby={reason.describedBy}\n onPointerUp={event => {\n onPointerUp?.(event)\n reason.onPointerUp(event)\n }}\n className={cn(\n popupItemClasses,\n \"group/choice w-full gap-2 px-2 data-selected:text-ink\",\n className,\n )}\n >\n {prefix != null && (\n <span className=\"flex shrink-0 text-ink-muted [&>svg]:size-4\">{prefix}</span>\n )}\n\n <SelectPrimitive.ItemText className=\"truncate\">{children}</SelectPrimitive.ItemText>\n\n {/* Only the selected row carries the check, so the others give its width to the label;\n `pl-4` on top of the row's gap keeps a floor between the label and the check. */}\n <span\n aria-hidden\n className=\"ml-auto hidden shrink-0 pl-4 text-ink-muted group-data-selected/choice:flex\"\n >\n <SelectPrimitive.ItemIndicator>\n <CheckIcon className=\"size-4\" />\n </SelectPrimitive.ItemIndicator>\n </span>\n\n {reason.reasonText}\n </SelectPrimitive.Item>\n </Tooltip>\n )\n}\n\nfunction SelectSeparator({ className, ...props }: SelectPrimitive.Separator.Props) {\n return <SelectPrimitive.Separator className={cn(popupSeparatorClasses, className)} {...props} />\n}\n\nexport {\n Select,\n SelectGroup,\n SelectValue,\n SelectTrigger,\n SelectContent,\n SelectLabel,\n SelectItem,\n SelectSeparator,\n SelectScrollUpButton,\n SelectScrollDownButton,\n}\n"],"mappings":"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"}
@@ -0,0 +1,14 @@
1
+ import { Kbd } from "./kbd.js";
2
+ import { ComponentProps } from "react";
3
+ interface ShortcutKeysProps extends Pick<ComponentProps<typeof Kbd>, "variant"> {
4
+ keys: string;
5
+ className?: string;
6
+ }
7
+ /**
8
+ * The badge for one key string, a box per part, in the font the platform draws modifiers in.
9
+ * At the end of a menu row it takes `variant="plain"`, the letters alone, as `MenuShortcut` draws.
10
+ * A screen reader hears the keys spelled out ("Command K") instead of the glyphs. The badge
11
+ * names its key in `data-shortcut`, so an open menu picks the row it sits in when it is pressed.
12
+ */
13
+ export declare function ShortcutKeys({ keys, variant, className }: ShortcutKeysProps): import("react").JSX.Element;
14
+ export {};
@@ -0,0 +1,32 @@
1
+ "use client";
2
+ import { formatKeys, formatSpokenKeys, toHotkey, useIsMac } from "../lib/shortcuts.js";
3
+ import { cn } from "../lib/variants.js";
4
+ import { Kbd } from "./kbd.js";
5
+ import { jsx, jsxs } from "react/jsx-runtime";
6
+ // src/components/shortcut-keys.tsx
7
+ /**
8
+ * The badge for one key string, a box per part, in the font the platform draws modifiers in.
9
+ * At the end of a menu row it takes `variant="plain"`, the letters alone, as `MenuShortcut` draws.
10
+ * A screen reader hears the keys spelled out ("Command K") instead of the glyphs. The badge
11
+ * names its key in `data-shortcut`, so an open menu picks the row it sits in when it is pressed.
12
+ */
13
+ function ShortcutKeys({ keys, variant, className }) {
14
+ const mac = useIsMac();
15
+ const parts = formatKeys(keys, mac);
16
+ const spelled = parts.some((part) => part.length > 1);
17
+ return /* @__PURE__ */ jsxs(Kbd, {
18
+ "data-shortcut": toHotkey(keys),
19
+ variant,
20
+ className: cn("shrink-0", spelled && "gap-[0.35em]", className),
21
+ children: [/* @__PURE__ */ jsx("span", {
22
+ className: "sr-only",
23
+ children: formatSpokenKeys(keys, mac)
24
+ }), parts.map((part) => /* @__PURE__ */ jsx("span", {
25
+ "aria-hidden": true,
26
+ children: part
27
+ }, part))]
28
+ });
29
+ }
30
+ export { ShortcutKeys };
31
+
32
+ //# sourceMappingURL=shortcut-keys.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shortcut-keys.js","names":[],"sources":["../../src/components/shortcut-keys.tsx"],"sourcesContent":["\"use client\"\n\nimport type { ComponentProps } from \"react\"\nimport { formatKeys, formatSpokenKeys, toHotkey, useIsMac } from \"../lib/shortcuts\"\nimport { cn } from \"../lib/variants\"\nimport { Kbd } from \"./kbd\"\n\ninterface ShortcutKeysProps extends Pick<ComponentProps<typeof Kbd>, \"variant\"> {\n keys: string\n className?: string\n}\n\n/**\n * The badge for one key string, a box per part, in the font the platform draws modifiers in.\n * At the end of a menu row it takes `variant=\"plain\"`, the letters alone, as `MenuShortcut` draws.\n * A screen reader hears the keys spelled out (\"Command K\") instead of the glyphs. The badge\n * names its key in `data-shortcut`, so an open menu picks the row it sits in when it is pressed.\n */\nexport function ShortcutKeys({ keys, variant, className }: ShortcutKeysProps) {\n const mac = useIsMac()\n const parts = formatKeys(keys, mac)\n // Glyphs read as one cluster on `Kbd`'s own hairline gap (\"⇧X\"); a modifier spelled out in\n // words, which is every modifier off a Mac, runs into its key at that gap and needs air.\n const spelled = parts.some(part => part.length > 1)\n\n return (\n <Kbd\n data-shortcut={toHotkey(keys)}\n variant={variant}\n className={cn(\"shrink-0\", spelled && \"gap-[0.35em]\", className)}\n >\n <span className=\"sr-only\">{formatSpokenKeys(keys, mac)}</span>\n {parts.map(part => (\n <span key={part} aria-hidden>\n {part}\n </span>\n ))}\n </Kbd>\n )\n}\n"],"mappings":";;;;;;;;;;;;AAkBA,SAAgB,aAAa,EAAE,MAAM,SAAS,aAAgC;CAC5E,MAAM,MAAM,SAAS;CACrB,MAAM,QAAQ,WAAW,MAAM,GAAG;CAGlC,MAAM,UAAU,MAAM,MAAK,SAAQ,KAAK,SAAS,CAAC;CAElD,OACE,qBAAC,KAAD;EACE,iBAAe,SAAS,IAAI;EACnB;EACT,WAAW,GAAG,YAAY,WAAW,gBAAgB,SAAS;EAHhE,UAAA,CAKE,oBAAC,QAAD;GAAM,WAAU;GAAW,UAAA,iBAAiB,MAAM,GAAG;EAAQ,CAAA,GAC5D,MAAM,KAAI,SACT,oBAAC,QAAD;GAAiB,eAAA;GACd,UAAA;EACG,GAFK,IAEL,CACP,CACE;;AAET"}
@@ -0,0 +1,10 @@
1
+ interface ShortcutsDialogProps {
2
+ open: boolean;
3
+ onOpenChange: (open: boolean) => void;
4
+ }
5
+ /**
6
+ * The one reference list of every shortcut mounted right now, read straight off the registry in
7
+ * `lib/shortcuts`. Nothing to wire: whatever a page registers shows up here, grouped.
8
+ */
9
+ export declare function ShortcutsDialog({ open, onOpenChange }: ShortcutsDialogProps): import("react").JSX.Element;
10
+ export {};
@@ -0,0 +1,92 @@
1
+ "use client";
2
+ import { eyebrowClasses } from "../lib/classes.js";
3
+ import { matchesMedia } from "../lib/media.js";
4
+ import { formatKeys, useShortcutList } from "../lib/shortcuts.js";
5
+ import { cn } from "../lib/variants.js";
6
+ import { Dialog, DialogClose, DialogContent, DialogFooter, DialogHeader } from "./dialog.js";
7
+ import { EmptyState } from "./empty-state.js";
8
+ import { SearchInput } from "./search-input.js";
9
+ import { ShortcutKeys } from "./shortcut-keys.js";
10
+ import { jsx, jsxs } from "react/jsx-runtime";
11
+ import { useRef, useState } from "react";
12
+ // src/components/shortcuts-dialog.tsx
13
+ /**
14
+ * The one reference list of every shortcut mounted right now, read straight off the registry in
15
+ * `lib/shortcuts`. Nothing to wire: whatever a page registers shows up here, grouped.
16
+ */
17
+ function ShortcutsDialog({ open, onOpenChange }) {
18
+ const groups = useShortcutList();
19
+ const [search, setSearch] = useState("");
20
+ const searchRef = useRef(null);
21
+ const query = search.trim().toLowerCase();
22
+ const matches = groups.map((group) => ({
23
+ group: group.group,
24
+ shortcuts: group.shortcuts.filter((shortcut) => {
25
+ return [
26
+ shortcut.label,
27
+ group.group,
28
+ ...formatKeys(shortcut.keys)
29
+ ].join(" ").toLowerCase().includes(query);
30
+ })
31
+ })).filter((group) => group.shortcuts.length > 0);
32
+ function handleOpenChange(next) {
33
+ if (!next) setSearch("");
34
+ onOpenChange(next);
35
+ }
36
+ return /* @__PURE__ */ jsx(Dialog, {
37
+ open,
38
+ onOpenChange: handleOpenChange,
39
+ children: /* @__PURE__ */ jsxs(DialogContent, {
40
+ size: "2xl",
41
+ instant: true,
42
+ initialFocus: () => matchesMedia("(pointer: fine)") ? searchRef.current : true,
43
+ children: [
44
+ /* @__PURE__ */ jsx(DialogHeader, {
45
+ bordered: true,
46
+ className: "sticky top-0 z-20 bg-surface",
47
+ title: "Keyboard shortcuts",
48
+ description: "Press ? anywhere to open this list."
49
+ }),
50
+ /* @__PURE__ */ jsx("div", {
51
+ className: "border-b bg-surface px-6 py-3",
52
+ children: /* @__PURE__ */ jsx(SearchInput, {
53
+ ref: searchRef,
54
+ value: search,
55
+ onValueChange: setSearch,
56
+ placeholder: "Search shortcuts",
57
+ "aria-label": "Search shortcuts"
58
+ })
59
+ }),
60
+ /* @__PURE__ */ jsx("div", {
61
+ className: "gap-x-10 px-6 py-5 sm:columns-2",
62
+ children: matches.length === 0 ? /* @__PURE__ */ jsx(EmptyState, {
63
+ variant: "inline",
64
+ title: "No shortcuts match"
65
+ }) : matches.map((group) => /* @__PURE__ */ jsxs("div", {
66
+ className: "mb-5 break-inside-avoid last:mb-0",
67
+ children: [/* @__PURE__ */ jsx("p", {
68
+ className: cn(eyebrowClasses, "mb-1"),
69
+ children: group.group
70
+ }), group.shortcuts.map((shortcut) => /* @__PURE__ */ jsxs("div", {
71
+ className: "flex items-center justify-between gap-6 py-1.5 text-sm",
72
+ children: [/* @__PURE__ */ jsx("span", {
73
+ className: "min-w-0 truncate text-ink-secondary",
74
+ children: shortcut.label
75
+ }), /* @__PURE__ */ jsx(ShortcutKeys, { keys: shortcut.keys })]
76
+ }, `${shortcut.keys} ${shortcut.label}`))]
77
+ }, group.group))
78
+ }),
79
+ /* @__PURE__ */ jsx(DialogFooter, {
80
+ className: "sticky bottom-0 z-20 max-sm:hidden",
81
+ children: /* @__PURE__ */ jsx(DialogClose, {
82
+ variant: "primary",
83
+ children: "Done"
84
+ })
85
+ })
86
+ ]
87
+ })
88
+ });
89
+ }
90
+ export { ShortcutsDialog };
91
+
92
+ //# sourceMappingURL=shortcuts-dialog.js.map