@astra-kit/ui 0.0.0-stage → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (304) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +330 -2
  4. package/THIRD_PARTY_NOTICES.md +31 -0
  5. package/assets/fonts/geist-LICENSE.txt +93 -0
  6. package/assets/fonts/geist-latin-variable.woff2 +0 -0
  7. package/assets/fonts/ibm-plex-mono-latin-400.woff2 +0 -0
  8. package/assets/fonts/ibm-plex-mono-latin-500.woff2 +0 -0
  9. package/assets/fonts/ibmplexmono-LICENSE.txt +93 -0
  10. package/assets/fonts/inter-LICENSE.txt +93 -0
  11. package/assets/fonts/inter-latin-variable.woff2 +0 -0
  12. package/dist/adapters/unpic-image.d.ts +3 -0
  13. package/dist/adapters/unpic-image.js +98 -0
  14. package/dist/components/account-menu.d.ts +67 -0
  15. package/dist/components/account-menu.js +440 -0
  16. package/dist/components/action-button.d.ts +25 -0
  17. package/dist/components/action-button.js +264 -0
  18. package/dist/components/alert.d.ts +31 -0
  19. package/dist/components/alert.js +503 -0
  20. package/dist/components/animated-collapse.d.ts +19 -0
  21. package/dist/components/animated-collapse.js +170 -0
  22. package/dist/components/animated-count.d.ts +13 -0
  23. package/dist/components/animated-count.js +105 -0
  24. package/dist/components/animated-list-item.d.ts +25 -0
  25. package/dist/components/animated-list-item.js +134 -0
  26. package/dist/components/animated-theme-toggler.d.ts +12 -0
  27. package/dist/components/animated-theme-toggler.js +200 -0
  28. package/dist/components/avatar.d.ts +65 -0
  29. package/dist/components/avatar.js +463 -0
  30. package/dist/components/badge.d.ts +21 -0
  31. package/dist/components/badge.js +297 -0
  32. package/dist/components/button-interaction.d.ts +23 -0
  33. package/dist/components/button-interaction.js +22 -0
  34. package/dist/components/button-label.d.ts +8 -0
  35. package/dist/components/button-label.js +203 -0
  36. package/dist/components/button.d.ts +23 -0
  37. package/dist/components/button.js +145 -0
  38. package/dist/components/calendar.d.ts +47 -0
  39. package/dist/components/calendar.js +155 -0
  40. package/dist/components/card.d.ts +38 -0
  41. package/dist/components/card.js +904 -0
  42. package/dist/components/carousel.d.ts +71 -0
  43. package/dist/components/carousel.js +585 -0
  44. package/dist/components/checkbox.d.ts +15 -0
  45. package/dist/components/checkbox.js +324 -0
  46. package/dist/components/control-button.d.ts +16 -0
  47. package/dist/components/control-button.js +215 -0
  48. package/dist/components/data-table.d.ts +118 -0
  49. package/dist/components/data-table.js +895 -0
  50. package/dist/components/dialog-surface.d.ts +49 -0
  51. package/dist/components/dialog-surface.js +220 -0
  52. package/dist/components/dialog.d.ts +92 -0
  53. package/dist/components/dialog.js +320 -0
  54. package/dist/components/dropdown-menu.d.ts +58 -0
  55. package/dist/components/dropdown-menu.js +135 -0
  56. package/dist/components/field.d.ts +53 -0
  57. package/dist/components/field.js +710 -0
  58. package/dist/components/file-upload.d.ts +88 -0
  59. package/dist/components/file-upload.js +776 -0
  60. package/dist/components/filter-presets-bar.d.ts +73 -0
  61. package/dist/components/filter-presets-bar.js +510 -0
  62. package/dist/components/filter-query-bar.d.ts +21 -0
  63. package/dist/components/filter-query-bar.js +881 -0
  64. package/dist/components/filter-query-grammar.d.ts +188 -0
  65. package/dist/components/filter-query-grammar.js +875 -0
  66. package/dist/components/form.d.ts +29 -0
  67. package/dist/components/form.js +330 -0
  68. package/dist/components/highlighter.d.ts +15 -0
  69. package/dist/components/highlighter.js +152 -0
  70. package/dist/components/hover-card.d.ts +50 -0
  71. package/dist/components/hover-card.js +80 -0
  72. package/dist/components/input-group.d.ts +16 -0
  73. package/dist/components/input-group.js +277 -0
  74. package/dist/components/input.d.ts +17 -0
  75. package/dist/components/input.js +120 -0
  76. package/dist/components/label.d.ts +4 -0
  77. package/dist/components/label.js +43 -0
  78. package/dist/components/link.d.ts +9 -0
  79. package/dist/components/link.js +43 -0
  80. package/dist/components/morph-text.d.ts +14 -0
  81. package/dist/components/morph-text.js +210 -0
  82. package/dist/components/pagination.d.ts +59 -0
  83. package/dist/components/pagination.js +190 -0
  84. package/dist/components/popover.d.ts +17 -0
  85. package/dist/components/popover.js +40 -0
  86. package/dist/components/presence-swap.d.ts +22 -0
  87. package/dist/components/presence-swap.js +209 -0
  88. package/dist/components/primitives/alert-dialog.d.ts +68 -0
  89. package/dist/components/primitives/alert-dialog.js +629 -0
  90. package/dist/components/primitives/avatar.d.ts +46 -0
  91. package/dist/components/primitives/avatar.js +265 -0
  92. package/dist/components/primitives/calendar.d.ts +37 -0
  93. package/dist/components/primitives/calendar.js +1250 -0
  94. package/dist/components/primitives/carousel.d.ts +106 -0
  95. package/dist/components/primitives/carousel.js +928 -0
  96. package/dist/components/primitives/dialog.d.ts +62 -0
  97. package/dist/components/primitives/dialog.js +490 -0
  98. package/dist/components/primitives/dropdown-menu-items.d.ts +59 -0
  99. package/dist/components/primitives/dropdown-menu-items.js +265 -0
  100. package/dist/components/primitives/dropdown-menu.d.ts +64 -0
  101. package/dist/components/primitives/dropdown-menu.js +560 -0
  102. package/dist/components/primitives/hover-card.d.ts +50 -0
  103. package/dist/components/primitives/hover-card.js +507 -0
  104. package/dist/components/primitives/pagination.d.ts +65 -0
  105. package/dist/components/primitives/pagination.js +373 -0
  106. package/dist/components/primitives/popover.d.ts +22 -0
  107. package/dist/components/primitives/popover.js +213 -0
  108. package/dist/components/primitives/select.d.ts +37 -0
  109. package/dist/components/primitives/select.js +428 -0
  110. package/dist/components/primitives/tooltip.d.ts +30 -0
  111. package/dist/components/primitives/tooltip.js +277 -0
  112. package/dist/components/progress-ring.d.ts +20 -0
  113. package/dist/components/progress-ring.js +53 -0
  114. package/dist/components/radio-group.d.ts +34 -0
  115. package/dist/components/radio-group.js +392 -0
  116. package/dist/components/reaction-button.d.ts +30 -0
  117. package/dist/components/reaction-button.js +189 -0
  118. package/dist/components/rich-link-editor.d.ts +25 -0
  119. package/dist/components/rich-link-editor.js +320 -0
  120. package/dist/components/rich-markdown-content.d.ts +10 -0
  121. package/dist/components/rich-markdown-content.js +56 -0
  122. package/dist/components/rich-text-content.d.ts +19 -0
  123. package/dist/components/rich-text-content.js +26 -0
  124. package/dist/components/select.d.ts +55 -0
  125. package/dist/components/select.js +188 -0
  126. package/dist/components/separator.d.ts +3 -0
  127. package/dist/components/separator.js +48 -0
  128. package/dist/components/sheet.d.ts +19 -0
  129. package/dist/components/sheet.js +420 -0
  130. package/dist/components/sidebar-panel-context.d.ts +17 -0
  131. package/dist/components/sidebar-panel-context.js +14 -0
  132. package/dist/components/sidebar.d.ts +195 -0
  133. package/dist/components/sidebar.js +2041 -0
  134. package/dist/components/skeleton.d.ts +23 -0
  135. package/dist/components/skeleton.js +334 -0
  136. package/dist/components/split-button.d.ts +36 -0
  137. package/dist/components/split-button.js +306 -0
  138. package/dist/components/svgs/whatsappIcon.d.ts +3 -0
  139. package/dist/components/svgs/whatsappIcon.js +14 -0
  140. package/dist/components/switch.d.ts +13 -0
  141. package/dist/components/switch.js +444 -0
  142. package/dist/components/table.d.ts +10 -0
  143. package/dist/components/table.js +298 -0
  144. package/dist/components/tabs.d.ts +36 -0
  145. package/dist/components/tabs.js +636 -0
  146. package/dist/components/textarea.d.ts +16 -0
  147. package/dist/components/textarea.js +111 -0
  148. package/dist/components/themed-toaster.d.ts +7 -0
  149. package/dist/components/themed-toaster.js +86 -0
  150. package/dist/components/toaster.d.ts +12 -0
  151. package/dist/components/toaster.js +62 -0
  152. package/dist/components/tooltip.d.ts +43 -0
  153. package/dist/components/tooltip.js +65 -0
  154. package/dist/components/typing-animation.d.ts +34 -0
  155. package/dist/components/typing-animation.js +389 -0
  156. package/dist/constants/action-button.d.ts +20 -0
  157. package/dist/constants/action-button.js +17 -0
  158. package/dist/constants/alert.d.ts +16 -0
  159. package/dist/constants/alert.js +13 -0
  160. package/dist/constants/avatar.d.ts +38 -0
  161. package/dist/constants/avatar.js +32 -0
  162. package/dist/constants/badge.d.ts +6 -0
  163. package/dist/constants/badge.js +6 -0
  164. package/dist/constants/button.d.ts +16 -0
  165. package/dist/constants/button.js +16 -0
  166. package/dist/constants/calendar.d.ts +36 -0
  167. package/dist/constants/calendar.js +34 -0
  168. package/dist/constants/card.d.ts +23 -0
  169. package/dist/constants/card.js +20 -0
  170. package/dist/constants/carousel.d.ts +55 -0
  171. package/dist/constants/carousel.js +74 -0
  172. package/dist/constants/checkbox.d.ts +17 -0
  173. package/dist/constants/checkbox.js +17 -0
  174. package/dist/constants/dialog.d.ts +11 -0
  175. package/dist/constants/dialog.js +10 -0
  176. package/dist/constants/dropdown-menu.d.ts +17 -0
  177. package/dist/constants/dropdown-menu.js +48 -0
  178. package/dist/constants/field.d.ts +24 -0
  179. package/dist/constants/field.js +24 -0
  180. package/dist/constants/hover-card.d.ts +37 -0
  181. package/dist/constants/hover-card.js +85 -0
  182. package/dist/constants/morph-text.d.ts +13 -0
  183. package/dist/constants/morph-text.js +13 -0
  184. package/dist/constants/motion.d.ts +12 -0
  185. package/dist/constants/motion.js +12 -0
  186. package/dist/constants/pagination.d.ts +20 -0
  187. package/dist/constants/pagination.js +20 -0
  188. package/dist/constants/popover.d.ts +7 -0
  189. package/dist/constants/popover.js +33 -0
  190. package/dist/constants/radio-group.d.ts +10 -0
  191. package/dist/constants/radio-group.js +10 -0
  192. package/dist/constants/select.d.ts +7 -0
  193. package/dist/constants/select.js +34 -0
  194. package/dist/constants/sidebar.d.ts +9 -0
  195. package/dist/constants/sidebar.js +17 -0
  196. package/dist/constants/skeleton.d.ts +17 -0
  197. package/dist/constants/skeleton.js +17 -0
  198. package/dist/constants/split-button.d.ts +7 -0
  199. package/dist/constants/split-button.js +5 -0
  200. package/dist/constants/switch.d.ts +33 -0
  201. package/dist/constants/switch.js +41 -0
  202. package/dist/constants/tabs.d.ts +17 -0
  203. package/dist/constants/tabs.js +17 -0
  204. package/dist/constants/toast.d.ts +3 -0
  205. package/dist/constants/toast.js +3 -0
  206. package/dist/constants/tooltip.d.ts +13 -0
  207. package/dist/constants/tooltip.js +52 -0
  208. package/dist/hooks/use-horizontal-swipe.d.ts +23 -0
  209. package/dist/hooks/use-horizontal-swipe.js +80 -0
  210. package/dist/hooks/use-is-hydrated.d.ts +6 -0
  211. package/dist/hooks/use-is-hydrated.js +20 -0
  212. package/dist/hooks/use-mobile.d.ts +1 -0
  213. package/dist/hooks/use-mobile.js +19 -0
  214. package/dist/hooks/use-prefers-reduced-motion.d.ts +2 -0
  215. package/dist/hooks/use-prefers-reduced-motion.js +27 -0
  216. package/dist/hooks/use-rich-link-editor.d.ts +55 -0
  217. package/dist/hooks/use-rich-link-editor.js +515 -0
  218. package/dist/hooks/use-sidebar-persistence.d.ts +6 -0
  219. package/dist/hooks/use-sidebar-persistence.js +52 -0
  220. package/dist/hooks/use-today.d.ts +7 -0
  221. package/dist/hooks/use-today.js +50 -0
  222. package/dist/hooks/use-viewer-time-zone.d.ts +6 -0
  223. package/dist/hooks/use-viewer-time-zone.js +20 -0
  224. package/dist/hooks.d.ts +11 -0
  225. package/dist/hooks.js +11 -0
  226. package/dist/index.d.ts +71 -0
  227. package/dist/index.js +69 -0
  228. package/dist/lib/browser-clipboard.d.ts +13 -0
  229. package/dist/lib/browser-clipboard.js +48 -0
  230. package/dist/lib/column-filter-value.d.ts +12 -0
  231. package/dist/lib/column-filter-value.js +52 -0
  232. package/dist/lib/file-acceptance.d.ts +43 -0
  233. package/dist/lib/file-acceptance.js +107 -0
  234. package/dist/lib/format-file-size.d.ts +16 -0
  235. package/dist/lib/format-file-size.js +34 -0
  236. package/dist/lib/fuzzy-search.d.ts +17 -0
  237. package/dist/lib/fuzzy-search.js +183 -0
  238. package/dist/lib/horizontal-swipe.d.ts +23 -0
  239. package/dist/lib/horizontal-swipe.js +29 -0
  240. package/dist/lib/image-dimensions.d.ts +2 -0
  241. package/dist/lib/image-dimensions.js +7 -0
  242. package/dist/lib/name-initials.d.ts +7 -0
  243. package/dist/lib/name-initials.js +11 -0
  244. package/dist/lib/rich-text/link-markdown-constants.d.ts +147 -0
  245. package/dist/lib/rich-text/link-markdown-constants.js +458 -0
  246. package/dist/lib/rich-text/link-markdown-types.d.ts +53 -0
  247. package/dist/lib/rich-text/link-markdown-types.js +1 -0
  248. package/dist/lib/rich-text/link-markdown.d.ts +193 -0
  249. package/dist/lib/rich-text/link-markdown.js +592 -0
  250. package/dist/lib/rich-text/rich-markdown.d.ts +41 -0
  251. package/dist/lib/rich-text/rich-markdown.js +105 -0
  252. package/dist/lib/rich-text/rich-text-editor-dom.d.ts +26 -0
  253. package/dist/lib/rich-text/rich-text-editor-dom.js +79 -0
  254. package/dist/lib/toast-layer.d.ts +24 -0
  255. package/dist/lib/toast-layer.js +76 -0
  256. package/dist/lib/utils.d.ts +2 -0
  257. package/dist/lib/utils.js +2 -0
  258. package/dist/lib/year-month-filter.d.ts +16 -0
  259. package/dist/lib/year-month-filter.js +46 -0
  260. package/dist/motion/arc-floating-slot.d.ts +40 -0
  261. package/dist/motion/arc-floating-slot.js +177 -0
  262. package/dist/motion/arc-press.d.ts +6 -0
  263. package/dist/motion/arc-press.js +59 -0
  264. package/dist/motion/arc-swap.d.ts +22 -0
  265. package/dist/motion/arc-swap.js +49 -0
  266. package/dist/motion/arc-tokens.d.ts +53 -0
  267. package/dist/motion/arc-tokens.js +73 -0
  268. package/dist/motion/glide-indicator.d.ts +69 -0
  269. package/dist/motion/glide-indicator.js +309 -0
  270. package/dist/motion/glide-slot.d.ts +9 -0
  271. package/dist/motion/glide-slot.js +71 -0
  272. package/dist/motion/motion-slot.d.ts +12 -0
  273. package/dist/motion/motion-slot.js +376 -0
  274. package/dist/motion/overlay-warmth.d.ts +24 -0
  275. package/dist/motion/overlay-warmth.js +70 -0
  276. package/dist/motion/presence.d.ts +40 -0
  277. package/dist/motion/presence.js +101 -0
  278. package/dist/motion/surface-keyframes.d.ts +24 -0
  279. package/dist/motion/surface-keyframes.js +141 -0
  280. package/dist/motion/tokens.d.ts +81 -0
  281. package/dist/motion/tokens.js +67 -0
  282. package/dist/motion/use-attached-element.d.ts +7 -0
  283. package/dist/motion/use-attached-element.js +22 -0
  284. package/dist/motion/use-morph-width.d.ts +13 -0
  285. package/dist/motion/use-morph-width.js +59 -0
  286. package/dist/next.d.ts +14 -0
  287. package/dist/next.js +79 -0
  288. package/dist/providers/astra-ui-provider.d.ts +27 -0
  289. package/dist/providers/astra-ui-provider.js +100 -0
  290. package/dist/providers/native-provider.d.ts +4 -0
  291. package/dist/providers/native-provider.js +45 -0
  292. package/dist/sonner.d.ts +7 -0
  293. package/dist/sonner.js +8 -0
  294. package/dist/styles.css +2 -0
  295. package/dist/tanstack.d.ts +11 -0
  296. package/dist/tanstack.js +50 -0
  297. package/dist/theme.d.ts +3 -0
  298. package/dist/theme.js +1 -0
  299. package/dist/types/data-table.d.ts +27 -0
  300. package/dist/types/data-table.js +1 -0
  301. package/fonts.css +5 -0
  302. package/package.json +450 -4
  303. package/styles.css +4 -0
  304. package/theme.css +248 -0
@@ -0,0 +1,58 @@
1
+ /**
2
+ * Arc's Dropdown menu (https://uiarc.dev, MIT License, see THIRD_PARTY_NOTICES.md): a labelled trigger that opens a
3
+ * focused list of actions on Arc's raised panel, with item rows, danger tone, separators, a staggered item entrance
4
+ * and a highlight that glides between items with the keyboard. It follows Arc's closed API: items are data, not
5
+ * children. @astra-kit/ui adds a custom trigger, link, checkbox and radio rows, trailing content, and placement and open
6
+ * state of the menu.
7
+ */
8
+ import type { ReactElement, ReactNode } from "react";
9
+ import { type DropdownItem, type DropdownItemAttributes, type DropdownMenuSelection } from "./primitives/dropdown-menu-items.js";
10
+ /** Side of the trigger the menu prefers. */
11
+ export type DropdownMenuSide = "top" | "right" | "bottom" | "left";
12
+ /** Alignment of the menu against its trigger. */
13
+ export type DropdownMenuAlign = "start" | "center" | "end";
14
+ export type DropdownMenuProps = {
15
+ /**
16
+ * Text of the trigger Arc draws, and the accessible name of the menu. With a custom `trigger`, it only names the
17
+ * menu.
18
+ */
19
+ label: string;
20
+ /** Rows of the menu, in order. */
21
+ items: DropdownItem[];
22
+ /** Leading icon of the trigger Arc draws. */
23
+ icon?: ReactNode;
24
+ /**
25
+ * Your own trigger, rendered with `asChild` instead of Arc's labelled button, such as an icon button with its own
26
+ * `aria-label`. It must accept a ref and be focusable. While the rendered trigger is disabled (its own `disabled`, an
27
+ * ancestor `<fieldset disabled>`) or has `aria-disabled="true"`, the menu does not open.
28
+ */
29
+ trigger?: ReactElement;
30
+ /** Single selection: rows with a `value` render as radio items checked against `selection.value`. */
31
+ selection?: DropdownMenuSelection;
32
+ /** Preferred side of the trigger. Defaults to `bottom`. */
33
+ side?: DropdownMenuSide;
34
+ /** Alignment against the trigger. Defaults to `start`. */
35
+ align?: DropdownMenuAlign;
36
+ /** Class added to the menu panel. */
37
+ contentClassName?: string;
38
+ /** Accessible name of the menu when it should differ from `label`. */
39
+ contentLabel?: string;
40
+ /** Class added to the trigger Arc draws. */
41
+ className?: string;
42
+ /** Controlled open state. */
43
+ open?: boolean;
44
+ /** Initial open state when uncontrolled. */
45
+ defaultOpen?: boolean;
46
+ /** Called when the menu opens or closes. */
47
+ onOpenChange?: (open: boolean) => void;
48
+ /** Blocks outside interaction and hides the rest of the page from assistive technology while open. Defaults to `true`. */
49
+ modal?: boolean;
50
+ };
51
+ /**
52
+ * A focused list of actions anchored to a trigger.
53
+ * @param props - The label, the items and optional trigger, selection, placement and open state.
54
+ * @returns The trigger with its menu.
55
+ */
56
+ declare function DropdownMenu({ label, items, icon, trigger, selection, side, align, contentClassName, contentLabel, className, open, defaultOpen, onOpenChange, modal, }: DropdownMenuProps): import("react").JSX.Element;
57
+ export { DropdownMenu };
58
+ export type { DropdownItem, DropdownItemAttributes, DropdownMenuSelection };
@@ -0,0 +1,135 @@
1
+ "use client";
2
+ import { c as _c } from "react/compiler-runtime";
3
+ import { ChevronDownIcon } from "lucide-react";
4
+ import { DROPDOWN_MENU_OPEN_KEYS, DROPDOWN_MENU_UNAVAILABLE_TRIGGER_SELECTOR } from "../constants/dropdown-menu.js";
5
+ import { cn } from "../lib/utils.js";
6
+ import { Button } from "./button.js";
7
+ import { DropdownMenu as DropdownMenuRoot, DropdownMenuContent, DropdownMenuTrigger } from "./primitives/dropdown-menu.js";
8
+ import { DropdownMenuItems } from "./primitives/dropdown-menu-items.js";
9
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
10
+ /**
11
+ * Tells whether the rendered trigger is unavailable, however it got there: its own `disabled`, an ancestor
12
+ * `<fieldset disabled>`, state derived inside a custom component, or `aria-disabled="true"`.
13
+ * @param trigger - Element the event reached.
14
+ * @returns Whether the menu must stay closed.
15
+ */
16
+ function isUnavailableTrigger(trigger) {
17
+ return trigger.matches(DROPDOWN_MENU_UNAVAILABLE_TRIGGER_SELECTOR);
18
+ }
19
+ /**
20
+ * Keeps an unavailable trigger from opening the menu on press. The engine still delivers `pointerdown` to a disabled
21
+ * button, and Radix opens on it unless the event is already default-prevented.
22
+ * @param event - Pointer event on the trigger.
23
+ */
24
+ function preventPointerOpenWhileUnavailable(event) {
25
+ if (isUnavailableTrigger(event.currentTarget)) event.preventDefault();
26
+ }
27
+ /**
28
+ * Keeps an `aria-disabled` trigger, which stays focusable, from opening the menu with Enter, Space or ArrowDown. Other
29
+ * keys, such as Tab, keep their default so focus can leave it.
30
+ * @param event - Keyboard event on the trigger.
31
+ */
32
+ function preventKeyboardOpenWhileUnavailable(event) {
33
+ if (DROPDOWN_MENU_OPEN_KEYS.includes(event.key) && isUnavailableTrigger(event.currentTarget)) event.preventDefault();
34
+ }
35
+ /**
36
+ * A focused list of actions anchored to a trigger.
37
+ * @param props - The label, the items and optional trigger, selection, placement and open state.
38
+ * @returns The trigger with its menu.
39
+ */
40
+ function DropdownMenu(t0) {
41
+ const $ = _c(23);
42
+ const { label, items, icon, trigger, selection, side, align, contentClassName, contentLabel, className, open, defaultOpen, onOpenChange, modal } = t0;
43
+ let t1;
44
+ if ($[0] !== className || $[1] !== icon || $[2] !== label || $[3] !== trigger) {
45
+ t1 = trigger ?? /* @__PURE__ */ _jsxs(Button, {
46
+ variant: "secondary",
47
+ className: cn("max-w-full", className),
48
+ children: [
49
+ icon,
50
+ /* @__PURE__ */ _jsx("span", {
51
+ className: "min-w-0 truncate",
52
+ children: label
53
+ }),
54
+ /* @__PURE__ */ _jsx(ChevronDownIcon, {
55
+ "aria-hidden": "true",
56
+ strokeWidth: 1.75,
57
+ className: "text-text-muted"
58
+ })
59
+ ]
60
+ });
61
+ $[0] = className;
62
+ $[1] = icon;
63
+ $[2] = label;
64
+ $[3] = trigger;
65
+ $[4] = t1;
66
+ } else {
67
+ t1 = $[4];
68
+ }
69
+ let t2;
70
+ if ($[5] !== t1) {
71
+ t2 = /* @__PURE__ */ _jsx(DropdownMenuTrigger, {
72
+ asChild: true,
73
+ onPointerDown: preventPointerOpenWhileUnavailable,
74
+ onKeyDown: preventKeyboardOpenWhileUnavailable,
75
+ children: t1
76
+ });
77
+ $[5] = t1;
78
+ $[6] = t2;
79
+ } else {
80
+ t2 = $[6];
81
+ }
82
+ const t3 = contentLabel ?? label;
83
+ let t4;
84
+ if ($[7] !== items || $[8] !== selection) {
85
+ t4 = /* @__PURE__ */ _jsx(DropdownMenuItems, {
86
+ items,
87
+ selection
88
+ });
89
+ $[7] = items;
90
+ $[8] = selection;
91
+ $[9] = t4;
92
+ } else {
93
+ t4 = $[9];
94
+ }
95
+ let t5;
96
+ if ($[10] !== align || $[11] !== contentClassName || $[12] !== side || $[13] !== t3 || $[14] !== t4) {
97
+ t5 = /* @__PURE__ */ _jsx(DropdownMenuContent, {
98
+ side,
99
+ align,
100
+ className: contentClassName,
101
+ "aria-label": t3,
102
+ "aria-labelledby": undefined,
103
+ children: t4
104
+ });
105
+ $[10] = align;
106
+ $[11] = contentClassName;
107
+ $[12] = side;
108
+ $[13] = t3;
109
+ $[14] = t4;
110
+ $[15] = t5;
111
+ } else {
112
+ t5 = $[15];
113
+ }
114
+ let t6;
115
+ if ($[16] !== defaultOpen || $[17] !== modal || $[18] !== onOpenChange || $[19] !== open || $[20] !== t2 || $[21] !== t5) {
116
+ t6 = /* @__PURE__ */ _jsxs(DropdownMenuRoot, {
117
+ open,
118
+ defaultOpen,
119
+ onOpenChange,
120
+ modal,
121
+ children: [t2, t5]
122
+ });
123
+ $[16] = defaultOpen;
124
+ $[17] = modal;
125
+ $[18] = onOpenChange;
126
+ $[19] = open;
127
+ $[20] = t2;
128
+ $[21] = t5;
129
+ $[22] = t6;
130
+ } else {
131
+ t6 = $[22];
132
+ }
133
+ return t6;
134
+ }
135
+ export { DropdownMenu };
@@ -0,0 +1,53 @@
1
+ import type { AriaAttributes, ReactNode } from "react";
2
+ /** Copy that turns a bare control into a labelled field. */
3
+ export type FieldCopyProps = {
4
+ /** Visible label, tied to the control with `htmlFor`. */
5
+ label?: string;
6
+ /** Helper copy under the control, linked through `aria-describedby`; counts in it roll their digits. */
7
+ description?: string;
8
+ /** Error copy: sets `aria-invalid` and renders in a `role="alert"` row that rewords in place. */
9
+ error?: string;
10
+ };
11
+ type FieldAriaOptions = FieldCopyProps & {
12
+ id?: string;
13
+ "aria-describedby"?: string;
14
+ "aria-invalid"?: AriaAttributes["aria-invalid"];
15
+ };
16
+ /** Ids and ARIA wiring a labelled field passes to its control. */
17
+ export type FieldAria = {
18
+ controlId: string;
19
+ descriptionId: string;
20
+ errorId: string;
21
+ "aria-describedby"?: string;
22
+ "aria-invalid"?: AriaAttributes["aria-invalid"];
23
+ };
24
+ /**
25
+ * Resolves the control id (the caller's or a generated one) and merges the helper and error ids into the caller's
26
+ * `aria-describedby`. An error always marks the control invalid.
27
+ * @param options - Field copy and the caller's id and ARIA attributes.
28
+ * @returns The ids and ARIA attributes for the control.
29
+ */
30
+ export declare function useFieldAria({ id, description, error, ...aria }: FieldAriaOptions): FieldAria;
31
+ /**
32
+ * Tells whether a control renders as a labelled field. It looks at which props were passed, not at their values, so a
33
+ * field whose error or description comes and goes keeps the same tree and its control never remounts (losing an
34
+ * uncontrolled value or the focus) when validation appears.
35
+ * @param props - Props passed to the control.
36
+ * @returns `true` when the caller passed `label`, `description` or `error`, even as `undefined`.
37
+ */
38
+ export declare function usesFieldCopy(props: FieldCopyProps): boolean;
39
+ type FieldProps = Omit<FieldCopyProps, "label"> & {
40
+ label?: string;
41
+ /** Keeps the label for assistive technology only, for layouts that already show their own label. */
42
+ hideLabel?: boolean;
43
+ aria: FieldAria;
44
+ className?: string;
45
+ children: ReactNode;
46
+ };
47
+ /**
48
+ * Arc's field layout: label, control, then the helper and error rows. There is no row gap, because grid tracks clamp
49
+ * a negative margin at zero and a closed row would still pay it; each row carries its own space instead. The wrapper
50
+ * keeps the bare control's full-width contract, so a field fills a flex row like the control alone does.
51
+ */
52
+ export declare function Field({ label, hideLabel, description, error, aria, className, children }: FieldProps): import("react").JSX.Element;
53
+ export {};