@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,54 @@
1
+ import { VariantProps } from "../lib/variants.js";
2
+ import { Avatar } from "./avatar.js";
3
+ import { ComponentProps, ReactNode } from "react";
4
+ declare const entityAvatar: import("tailwind-variants").TVReturnType<{
5
+ size: {
6
+ sm: {
7
+ root: string;
8
+ image: string;
9
+ fallback: string;
10
+ };
11
+ md: {
12
+ root: string;
13
+ fallback: string;
14
+ };
15
+ lg: {
16
+ root: string;
17
+ fallback: string;
18
+ };
19
+ };
20
+ /**
21
+ * Drop the inset around the image, for artwork that already fills its square (a favicon).
22
+ */
23
+ flush: {
24
+ true: {
25
+ image: string;
26
+ };
27
+ };
28
+ }, {
29
+ root: string;
30
+ image: string;
31
+ fallback: string;
32
+ }, undefined, undefined, undefined, undefined>;
33
+ type EntityAvatarProps = Omit<ComponentProps<typeof Avatar>, "className"> & VariantProps<typeof entityAvatar> & {
34
+ className?: string;
35
+ /**
36
+ * The image source (e.g. a favicon URL). When absent, only the fallback renders.
37
+ */
38
+ src?: string | null;
39
+ /**
40
+ * The entity's display name; its initials are the default fallback.
41
+ */
42
+ name: string;
43
+ /**
44
+ * Overrides the initials derived from `name`.
45
+ */
46
+ fallback?: ReactNode;
47
+ /**
48
+ * Names the avatar for a screen reader, for one with no visible name beside it. Without it
49
+ * the avatar is hidden from assistive tech, since the initials would only repeat the name.
50
+ */
51
+ label?: string;
52
+ };
53
+ export declare function EntityAvatar({ src, name, fallback, size, flush, label, className, ...props }: EntityAvatarProps): import("react").JSX.Element;
54
+ export {};
@@ -0,0 +1,68 @@
1
+ import { variants } from "../lib/variants.js";
2
+ import { Avatar, AvatarFallback, AvatarImage } from "./avatar.js";
3
+ import { jsx, jsxs } from "react/jsx-runtime";
4
+ // src/components/entity-avatar.tsx
5
+ /**
6
+ * The initials standing in for a missing image: a name of two characters or less as it is,
7
+ * otherwise the first letter of each of its first two words. Counted by code point, so an emoji
8
+ * stays whole.
9
+ */
10
+ function formatInitials(name) {
11
+ const value = name.trim();
12
+ if (Array.from(value).length <= 2) return value.toUpperCase();
13
+ return value.split(/\s+/).filter(Boolean).slice(0, 2).map((word) => Array.from(word)[0]?.toUpperCase() ?? "").join("");
14
+ }
15
+ const entityAvatar = variants({
16
+ slots: {
17
+ root: "outline outline-edge-subtle -outline-offset-1",
18
+ image: "p-[7.5%]",
19
+ fallback: "font-medium text-ink-secondary"
20
+ },
21
+ variants: {
22
+ size: {
23
+ sm: {
24
+ root: "size-5 rounded-sm",
25
+ image: "p-0",
26
+ fallback: "text-2xs"
27
+ },
28
+ md: {
29
+ root: "size-9 rounded-lg",
30
+ fallback: "text-control"
31
+ },
32
+ lg: {
33
+ root: "size-14 rounded-xl",
34
+ fallback: "text-xl"
35
+ }
36
+ },
37
+ /**
38
+ * Drop the inset around the image, for artwork that already fills its square (a favicon).
39
+ */
40
+ flush: { true: { image: "p-0" } }
41
+ }
42
+ });
43
+ function EntityAvatar({ src, name, fallback, size, flush, label, className, ...props }) {
44
+ const styles = entityAvatar({
45
+ size,
46
+ flush
47
+ });
48
+ const named = label ? {
49
+ role: "img",
50
+ "aria-label": label
51
+ } : { "aria-hidden": true };
52
+ return /* @__PURE__ */ jsxs(Avatar, {
53
+ className: styles.root({ className }),
54
+ ...named,
55
+ ...props,
56
+ children: [src && /* @__PURE__ */ jsx(AvatarImage, {
57
+ src,
58
+ alt: "",
59
+ className: styles.image()
60
+ }), /* @__PURE__ */ jsx(AvatarFallback, {
61
+ className: styles.fallback(),
62
+ children: fallback ?? formatInitials(name)
63
+ })]
64
+ });
65
+ }
66
+ export { EntityAvatar };
67
+
68
+ //# sourceMappingURL=entity-avatar.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity-avatar.js","names":[],"sources":["../../src/components/entity-avatar.tsx"],"sourcesContent":["import type { ComponentProps, ReactNode } from \"react\"\nimport { variants, type VariantProps } from \"../lib/variants\"\nimport { Avatar, AvatarFallback, AvatarImage } from \"./avatar\"\n\n/**\n * The initials standing in for a missing image: a name of two characters or less as it is,\n * otherwise the first letter of each of its first two words. Counted by code point, so an emoji\n * stays whole.\n */\nfunction formatInitials(name: string) {\n const value = name.trim()\n\n if (Array.from(value).length <= 2) {\n return value.toUpperCase()\n }\n\n return value\n .split(/\\s+/)\n .filter(Boolean)\n .slice(0, 2)\n .map(word => Array.from(word)[0]?.toUpperCase() ?? \"\")\n .join(\"\")\n}\n\n// Radius lives on the root, which clips its children, and grows with the box (`sm`, `lg`, `xl`). The\n// edge is an inset outline rather than a border, so it draws over the artwork instead of shrinking\n// the box it sits in. Initials are two letters at most, in 500, about 40% of the box.\nconst entityAvatar = variants({\n slots: {\n root: \"outline outline-edge-subtle -outline-offset-1\",\n image: \"p-[7.5%]\",\n fallback: \"font-medium text-ink-secondary\",\n },\n\n variants: {\n size: {\n // 20px: the identity mark of a nav row or menu item, flush.\n sm: {\n root: \"size-5 rounded-sm\",\n image: \"p-0\",\n fallback: \"text-2xs\",\n },\n // 36px: list rows and cards.\n md: { root: \"size-9 rounded-lg\", fallback: \"text-control\" },\n // 56px: the logo field.\n lg: { root: \"size-14 rounded-xl\", fallback: \"text-xl\" },\n },\n /**\n * Drop the inset around the image, for artwork that already fills its square (a favicon).\n */\n flush: {\n true: { image: \"p-0\" },\n },\n },\n})\n\ntype EntityAvatarProps = Omit<ComponentProps<typeof Avatar>, \"className\"> &\n VariantProps<typeof entityAvatar> & {\n className?: string\n\n /**\n * The image source (e.g. a favicon URL). When absent, only the fallback renders.\n */\n src?: string | null\n\n /**\n * The entity's display name; its initials are the default fallback.\n */\n name: string\n\n /**\n * Overrides the initials derived from `name`.\n */\n fallback?: ReactNode\n\n /**\n * Names the avatar for a screen reader, for one with no visible name beside it. Without it\n * the avatar is hidden from assistive tech, since the initials would only repeat the name.\n */\n label?: string\n }\n\nexport function EntityAvatar({\n src,\n name,\n fallback,\n size,\n flush,\n label,\n className,\n ...props\n}: EntityAvatarProps) {\n const styles = entityAvatar({ size, flush })\n const named = label ? ({ role: \"img\", \"aria-label\": label } as const) : { \"aria-hidden\": true }\n\n return (\n <Avatar className={styles.root({ className })} {...named} {...props}>\n {src && <AvatarImage src={src} alt=\"\" className={styles.image()} />}\n\n <AvatarFallback className={styles.fallback()}>\n {fallback ?? formatInitials(name)}\n </AvatarFallback>\n </Avatar>\n )\n}\n"],"mappings":";;;;;;;;;AASA,SAAS,eAAe,MAAc;CACpC,MAAM,QAAQ,KAAK,KAAK;CAExB,IAAI,MAAM,KAAK,KAAK,CAAC,CAAC,UAAU,GAC9B,OAAO,MAAM,YAAY;CAG3B,OAAO,MACJ,MAAM,KAAK,CAAC,CACZ,OAAO,OAAO,CAAC,CACf,MAAM,GAAG,CAAC,CAAC,CACX,KAAI,SAAQ,MAAM,KAAK,IAAI,CAAC,CAAC,EAAE,EAAE,YAAY,KAAK,EAAE,CAAC,CACrD,KAAK,EAAE;AACZ;AAKA,MAAM,eAAe,SAAS;CAC5B,OAAO;EACL,MAAM;EACN,OAAO;EACP,UAAU;CACZ;CAEA,UAAU;EACR,MAAM;GAEJ,IAAI;IACF,MAAM;IACN,OAAO;IACP,UAAU;GACZ;GAEA,IAAI;IAAE,MAAM;IAAqB,UAAU;GAAe;GAE1D,IAAI;IAAE,MAAM;IAAsB,UAAU;GAAU;EACxD;;;;EAIA,OAAO,EACL,MAAM,EAAE,OAAO,MAAM,EACvB;CACF;AACF,CAAC;AA4BD,SAAgB,aAAa,EAC3B,KACA,MACA,UACA,MACA,OACA,OACA,WACA,GAAG,SACiB;CACpB,MAAM,SAAS,aAAa;EAAE;EAAM;CAAM,CAAC;CAC3C,MAAM,QAAQ,QAAS;EAAE,MAAM;EAAO,cAAc;CAAM,IAAc,EAAE,eAAe,KAAK;CAE9F,OACE,qBAAC,QAAD;EAAQ,WAAW,OAAO,KAAK,EAAE,UAAU,CAAC;EAAG,GAAI;EAAO,GAAI;EAA9D,UAAA,CACG,OAAO,oBAAC,aAAD;GAAkB;GAAK,KAAI;GAAG,WAAW,OAAO,MAAM;EAAI,CAAA,GAElE,oBAAC,gBAAD;GAAgB,WAAW,OAAO,SAAS;GACxC,UAAA,YAAY,eAAe,IAAI;EAClB,CAAA,CACV;;AAEZ"}
@@ -0,0 +1,22 @@
1
+ import { useRender } from "@base-ui/react/use-render";
2
+ import { ReactNode } from "react";
3
+ type FormSectionProps = Omit<useRender.ComponentProps<"section">, "title"> & {
4
+ id?: string;
5
+ /**
6
+ * Optional heading. Leave it out when the page header above already names the section.
7
+ */
8
+ title?: ReactNode;
9
+ description?: ReactNode;
10
+ actions?: ReactNode;
11
+ /**
12
+ * Right-aligned actions after the rows, e.g. a save button, on the `CardFooter` band.
13
+ */
14
+ footer?: ReactNode;
15
+ };
16
+ /**
17
+ * A block of settings: one padded container whose children (optional heading, the rows,
18
+ * optional footer) stack with hairlines between them. Renders as a `<form>` via `render`
19
+ * when the rows are fields, so the form is the only wrapper.
20
+ */
21
+ export declare function FormSection({ id, title, description, actions, footer, className, children, render, ...props }: FormSectionProps): import("react").ReactElement<unknown, string | import("react").JSXElementConstructor<any>>;
22
+ export {};
@@ -0,0 +1,38 @@
1
+ import { cn } from "../lib/variants.js";
2
+ import { SectionHeader } from "./section-header.js";
3
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
4
+ import { useRender } from "@base-ui/react/use-render";
5
+ // src/components/form-section.tsx
6
+ /**
7
+ * A block of settings: one padded container whose children (optional heading, the rows,
8
+ * optional footer) stack with hairlines between them. Renders as a `<form>` via `render`
9
+ * when the rows are fields, so the form is the only wrapper.
10
+ */
11
+ function FormSection({ id, title, description, actions, footer, className, children, render, ...props }) {
12
+ return useRender({
13
+ render,
14
+ defaultTagName: "section",
15
+ props: {
16
+ id,
17
+ className: cn("@container flex flex-col divide-y px-4 md:px-5", footer && "[&>:nth-last-child(2)]:border-b-0", className),
18
+ children: /* @__PURE__ */ jsxs(Fragment, { children: [
19
+ (title || actions) && /* @__PURE__ */ jsx(SectionHeader, {
20
+ size: "panel",
21
+ className: cn("-mx-4 w-auto px-4 py-4 md:-mx-5 md:px-5 @xl:flex-nowrap", actions && "[&>:last-child]:@xl:shrink-0"),
22
+ title,
23
+ description,
24
+ actions
25
+ }),
26
+ children,
27
+ footer && /* @__PURE__ */ jsx("div", {
28
+ className: "-mx-4 flex flex-wrap items-center justify-end gap-2 border-t bg-canvas px-4 py-4 md:-mx-5 md:px-5",
29
+ children: footer
30
+ })
31
+ ] }),
32
+ ...props
33
+ }
34
+ });
35
+ }
36
+ export { FormSection };
37
+
38
+ //# sourceMappingURL=form-section.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"form-section.js","names":[],"sources":["../../src/components/form-section.tsx"],"sourcesContent":["import { useRender } from \"@base-ui/react/use-render\"\nimport type { ReactNode } from \"react\"\nimport { cn } from \"../lib/variants\"\nimport { SectionHeader } from \"./section-header\"\n\ntype FormSectionProps = Omit<useRender.ComponentProps<\"section\">, \"title\"> & {\n id?: string\n /**\n * Optional heading. Leave it out when the page header above already names the section.\n */\n title?: ReactNode\n description?: ReactNode\n actions?: ReactNode\n /**\n * Right-aligned actions after the rows, e.g. a save button, on the `CardFooter` band.\n */\n footer?: ReactNode\n}\n\n/**\n * A block of settings: one padded container whose children (optional heading, the rows,\n * optional footer) stack with hairlines between them. Renders as a `<form>` via `render`\n * when the rows are fields, so the form is the only wrapper.\n */\nexport function FormSection({\n id,\n title,\n description,\n actions,\n footer,\n className,\n children,\n render,\n ...props\n}: FormSectionProps) {\n return useRender({\n render,\n defaultTagName: \"section\",\n props: {\n id,\n // The container its rows lay themselves out against (see DetailRow's `form` density).\n // Row hairlines stop at the inset; the header's and the footer's run edge to edge, so the\n // row above the footer drops its own.\n className: cn(\n \"@container flex flex-col divide-y px-4 md:px-5\",\n footer && \"[&>:nth-last-child(2)]:border-b-0\",\n className,\n ),\n children: (\n <>\n {/* `||`: a `false` or `\"\"` slot counts as missing. */}\n {/* oxlint-disable-next-line typescript/prefer-nullish-coalescing */}\n {(title || actions) && (\n <SectionHeader\n size=\"panel\"\n // Two columns from the same container width the rows split at: the description\n // wraps inside its own column and the action stays at the end of the title line,\n // rather than dropping under a long description on a wide panel. Only the actions\n // hold their width; without them the last child is the description's column.\n className={cn(\n \"-mx-4 w-auto px-4 py-4 md:-mx-5 md:px-5 @xl:flex-nowrap\",\n actions && \"[&>:last-child]:@xl:shrink-0\",\n )}\n title={title}\n description={description}\n actions={actions}\n />\n )}\n\n {children}\n\n {footer && (\n <div className=\"-mx-4 flex flex-wrap items-center justify-end gap-2 border-t bg-canvas px-4 py-4 md:-mx-5 md:px-5\">\n {footer}\n </div>\n )}\n </>\n ),\n ...props,\n },\n })\n}\n"],"mappings":";;;;;;;;;;AAwBA,SAAgB,YAAY,EAC1B,IACA,OACA,aACA,SACA,QACA,WACA,UACA,QACA,GAAG,SACgB;CACnB,OAAO,UAAU;EACf;EACA,gBAAgB;EAChB,OAAO;GACL;GAIA,WAAW,GACT,kDACA,UAAU,qCACV,SACF;GACA,UACE,qBAAA,UAAA,EAAA,UAAA;KAGI,SAAS,YACT,oBAAC,eAAD;KACE,MAAK;KAKL,WAAW,GACT,2DACA,WAAW,8BACb;KACO;KACM;KACJ;IACV,CAAA;IAGF;IAEA,UACC,oBAAC,OAAD;KAAK,WAAU;KACZ,UAAA;IACE,CAAA;GAEP,EAAA,CAAA;GAEJ,GAAG;EACL;CACF,CAAC;AACH"}
@@ -0,0 +1,199 @@
1
+ import { Button } from "./button.js";
2
+ import { DatePickerProps } from "./date-picker.js";
3
+ import { Input } from "./input.js";
4
+ import { NumberInput } from "./number-input.js";
5
+ import { Textarea } from "./textarea.js";
6
+ import { ComponentProps, ComponentType, ReactElement, ReactNode } from "react";
7
+ /**
8
+ * Form primitives over TanStack Form. An app wires them up once with `createFormHook`:
9
+ *
10
+ * const { useAppForm } = createFormHook({ fieldContext, formContext, fieldComponents, formComponents })
11
+ *
12
+ * and then writes `<form.AppField name="email">{field => <field.TextField label="Email" />}</form.AppField>`
13
+ * inside a `<Form form={form}>`. The field components read the field they belong to from context,
14
+ * so a call site names the field once, on `AppField`.
15
+ */
16
+ export declare const fieldContext: import("react").Context<import("@tanstack/react-form").AnyFieldApi>, formContext: import("react").Context<import("@tanstack/react-form").AnyFormApi>, useFieldContext: <TData>() => import("@tanstack/react-form").FieldApi<any, string, TData, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any>, useFormContext: () => import("@tanstack/react-form").ReactFormExtendedApi<Record<string, never>, any, any, any, any, any, any, any, any, any, any, any>;
17
+ /**
18
+ * `stack` puts the label above a full-width control, for dialogs and single-column pages;
19
+ * `rows` puts the label and its description beside the control, for a `divide-y` settings body.
20
+ */
21
+ export type FieldLayout = "stack" | "rows";
22
+ /** What a control needs to be the field's: its id, the aria links to the copy under it, and blur. */
23
+ export interface FieldControlProps {
24
+ id: string;
25
+ name: string;
26
+ "aria-describedby"?: string;
27
+ "aria-invalid"?: true;
28
+ "aria-required"?: true;
29
+ onBlur: () => void;
30
+ }
31
+ /** The error a touched field shows, for a field that renders its own control and message. */
32
+ export declare function fieldError(meta: {
33
+ isTouched: boolean;
34
+ errors: unknown[];
35
+ }): string | undefined;
36
+ export interface FieldProps {
37
+ label: ReactNode;
38
+ description?: ReactNode;
39
+ isRequired?: boolean;
40
+ layout?: FieldLayout;
41
+ /** Classes for the whole field; a width set here constrains the control, which fills it. */
42
+ className?: string;
43
+ /** Extra classes for the label, e.g. `sr-only` where the row around the control already names it. */
44
+ labelClassName?: string;
45
+ /** An item at the end of the label's line: an `InlineAction`, a badge. */
46
+ trailing?: ReactNode;
47
+ /** Extra classes for the value column in `rows` layout, e.g. `sm:items-end`. */
48
+ valueClassName?: string;
49
+ /**
50
+ * Why the control cannot be used: read with it, and shown above it on hover and focus. A
51
+ * control handed over as an element gets it through `DisabledReason`; a text field also needs
52
+ * `readOnly`, which the typed fields set. A function child wraps its own control.
53
+ */
54
+ disabledReason?: string;
55
+ /**
56
+ * The control: an element the field's id and aria attributes are merged onto, or a function
57
+ * handed them to put on the element that should carry them.
58
+ */
59
+ children: ReactElement<FieldControlProps> | ((control: FieldControlProps) => ReactNode);
60
+ }
61
+ /**
62
+ * One labelled field in whichever frame the form asked for: label, control, description, and
63
+ * the first validation error, with the label's `htmlFor` and the control's `aria-describedby`
64
+ * and `aria-invalid` wired the same way in both layouts. In `stack` the error takes the
65
+ * description's place, worded as the fix, so the line under the control never doubles up.
66
+ */
67
+ export declare function Field({ label, description, isRequired, layout, className, labelClassName, valueClassName, trailing, disabledReason, children }: FieldProps): import("react").JSX.Element;
68
+ type FrameProps = Omit<FieldProps, "children">;
69
+ type TextFieldProps = FrameProps & Omit<ComponentProps<typeof Input>, "value" | "onChange" | "id" | "name" | "className">;
70
+ /** A `Field` around an `Input` bound to a string field. */
71
+ export declare function TextField(props: TextFieldProps): import("react").JSX.Element;
72
+ type TextareaFieldProps = FrameProps & Omit<ComponentProps<typeof Textarea>, "value" | "onChange" | "id" | "name" | "className">;
73
+ /** A `Field` around a `Textarea` bound to a string field. */
74
+ export declare function TextareaField(props: TextareaFieldProps): import("react").JSX.Element;
75
+ type NumberFieldProps = FrameProps & Omit<ComponentProps<typeof NumberInput>, "value" | "onValueChange" | "id" | "name" | "className">;
76
+ /** A `Field` around a `NumberInput` bound to a number field; `nullable` for one that may be null. */
77
+ export declare function NumberField(props: NumberFieldProps): import("react").JSX.Element;
78
+ /** A run of items under one optional heading, drawn apart from the next by a separator. */
79
+ export interface SelectFieldGroup {
80
+ label?: string;
81
+ /** Value to label. */
82
+ items: Record<string, string>;
83
+ }
84
+ interface SelectFieldProps extends FrameProps {
85
+ /**
86
+ * Value to label, one flat list. The trigger shows the label of the selected value. Pass
87
+ * `groups` instead to draw the list in sections.
88
+ */
89
+ items?: Record<string, string>;
90
+ groups?: SelectFieldGroup[];
91
+ /** Why an item cannot be chosen, by value: it stays in the list, disabled, with the reason. */
92
+ reasons?: Record<string, string>;
93
+ /** Something to draw before an item's label, like a glyph for the value. */
94
+ prefix?: (value: string) => ReactNode;
95
+ placeholder?: string;
96
+ }
97
+ /**
98
+ * A `Field` around a `Select` bound to a string field, one item per entry of `items`, or per
99
+ * entry of each of the `groups`.
100
+ */
101
+ export declare function SelectField({ items, groups, reasons, prefix, placeholder, ...frame }: SelectFieldProps): import("react").JSX.Element;
102
+ type DateFieldProps = FrameProps & Pick<DatePickerProps, "min" | "max" | "placeholder" | "formatDay" | "disabled" | "clearable">;
103
+ /** A `Field` around a `DatePicker` bound to a "YYYY-MM-DD" string field. */
104
+ export declare function DateField({ min, max, placeholder, formatDay, disabled, clearable, ...frame }: DateFieldProps): import("react").JSX.Element;
105
+ interface SwitchFieldProps {
106
+ label: ReactNode;
107
+ description?: ReactNode;
108
+ className?: string;
109
+ /** What the switch turns on, e.g. the password field itself. Rendered only while it is on. */
110
+ children?: ReactNode;
111
+ }
112
+ /**
113
+ * A switch with its label and one line of consequence beside it, bound to a boolean field.
114
+ * Its own frame rather than `Field`: a switch sits at the end of its label's line in every
115
+ * layout, and Base UI renders it as a `<span role="switch">`, which `<label for>` cannot address.
116
+ */
117
+ export declare function SwitchField({ label, description, className, children }: SwitchFieldProps): import("react").JSX.Element;
118
+ interface CheckboxFieldProps {
119
+ label: ReactNode;
120
+ description?: ReactNode;
121
+ className?: string;
122
+ }
123
+ /**
124
+ * A checkbox before its label, bound to a boolean field. The row is a `<label>`, so a click on
125
+ * the text toggles the box; the description and the error sit under the label text, not under
126
+ * the box. Use it for an option of a one-off action; a setting that stays on is a `SwitchField`.
127
+ */
128
+ export declare function CheckboxField({ label, description, className }: CheckboxFieldProps): import("react").JSX.Element;
129
+ export interface RadioCardOption {
130
+ value: string;
131
+ label: ReactNode;
132
+ description?: ReactNode;
133
+ badge?: ReactNode;
134
+ /** Why this card alone cannot be chosen, as `disabledReason` says it for all of them. */
135
+ disabledReason?: string;
136
+ }
137
+ interface RadioCardFieldProps {
138
+ label: ReactNode;
139
+ description?: ReactNode;
140
+ options: RadioCardOption[];
141
+ className?: string;
142
+ /**
143
+ * Why the cards cannot be chosen: they stay reachable and cannot be picked, and each one reads
144
+ * the reason and shows it above itself on hover and focus.
145
+ */
146
+ disabledReason?: string;
147
+ /** Under the cards, e.g. a note that holds for every choice. */
148
+ children?: ReactNode;
149
+ }
150
+ /**
151
+ * A choice out of a few cards, bound to a string field, for choices that each need a sentence
152
+ * to tell apart. Two plain states are a `SwitchField`, a long list a `SelectField`.
153
+ */
154
+ export declare function RadioCardField({ label, description, options, className, disabledReason, children }: RadioCardFieldProps): import("react").JSX.Element;
155
+ /** The part of a `useAppForm` result the `Form` element needs: the provider and the submit. */
156
+ export interface SubmittableForm {
157
+ AppForm: ComponentType<{
158
+ children?: ReactNode;
159
+ }>;
160
+ validate: (cause: "submit") => unknown;
161
+ handleSubmit: () => Promise<void>;
162
+ }
163
+ interface FormProps extends Omit<ComponentProps<"form">, "onSubmit"> {
164
+ form: SubmittableForm;
165
+ }
166
+ /**
167
+ * The `<form>` element of a TanStack form: provides the form to the components inside it,
168
+ * validates the whole form and hands submit to `handleSubmit`, then moves focus to the first
169
+ * invalid control. Browser validation is off, since the form's own validators own the messages.
170
+ *
171
+ * The explicit `validate` matters: `handleSubmit` runs the form-level validators (where a
172
+ * schema lives) only once every field is valid, so while one error stands a field revealed
173
+ * since the last submit would never get its own.
174
+ */
175
+ export declare function Form({ form: { AppForm, validate, handleSubmit }, ...props }: FormProps): import("react").JSX.Element;
176
+ /** A submit button that shows the form's pending state. */
177
+ export declare function SubmitButton({ isPending, ...props }: ComponentProps<typeof Button>): import("react").JSX.Element;
178
+ interface FormErrorProps {
179
+ className?: string;
180
+ }
181
+ /** The error the last submit left on the form as a whole, if any. Field errors show on their fields. */
182
+ export declare function FormError({ className }: FormErrorProps): import("react").JSX.Element;
183
+ /** The sets `createFormHook` takes, so an app registers every primitive in one line. */
184
+ export declare const fieldComponents: {
185
+ Field: typeof Field;
186
+ TextField: typeof TextField;
187
+ TextareaField: typeof TextareaField;
188
+ NumberField: typeof NumberField;
189
+ SelectField: typeof SelectField;
190
+ DateField: typeof DateField;
191
+ SwitchField: typeof SwitchField;
192
+ CheckboxField: typeof CheckboxField;
193
+ RadioCardField: typeof RadioCardField;
194
+ };
195
+ export declare const formComponents: {
196
+ SubmitButton: typeof SubmitButton;
197
+ FormError: typeof FormError;
198
+ };
199
+ export {};