@spark-ui/components 10.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 (296) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE.md +21 -0
  3. package/README.md +19 -0
  4. package/dist/DialogTrigger-5SI4dvpK.d.mts +142 -0
  5. package/dist/DialogTrigger-5SI4dvpK.d.ts +142 -0
  6. package/dist/Input-g0LpWuv0.d.mts +17 -0
  7. package/dist/Input-g0LpWuv0.d.ts +17 -0
  8. package/dist/InputGroup-aoaZxCLk.d.mts +28 -0
  9. package/dist/InputGroup-aoaZxCLk.d.ts +28 -0
  10. package/dist/InputTrailingIcon-BBp7sE6D.d.mts +20 -0
  11. package/dist/InputTrailingIcon-ZZx8PoJy.d.ts +20 -0
  12. package/dist/LabelRequiredIndicator-DRnCzHMU.d.mts +19 -0
  13. package/dist/LabelRequiredIndicator-DRnCzHMU.d.ts +19 -0
  14. package/dist/accordion/index.d.mts +85 -0
  15. package/dist/accordion/index.d.ts +85 -0
  16. package/dist/accordion/index.js +461 -0
  17. package/dist/accordion/index.js.map +1 -0
  18. package/dist/accordion/index.mjs +249 -0
  19. package/dist/accordion/index.mjs.map +1 -0
  20. package/dist/alert-dialog/index.d.mts +119 -0
  21. package/dist/alert-dialog/index.d.ts +119 -0
  22. package/dist/alert-dialog/index.js +1451 -0
  23. package/dist/alert-dialog/index.js.map +1 -0
  24. package/dist/alert-dialog/index.mjs +177 -0
  25. package/dist/alert-dialog/index.mjs.map +1 -0
  26. package/dist/badge/index.d.mts +47 -0
  27. package/dist/badge/index.d.ts +47 -0
  28. package/dist/badge/index.js +122 -0
  29. package/dist/badge/index.js.map +1 -0
  30. package/dist/badge/index.mjs +95 -0
  31. package/dist/badge/index.mjs.map +1 -0
  32. package/dist/breadcrumb/index.d.mts +64 -0
  33. package/dist/breadcrumb/index.d.ts +64 -0
  34. package/dist/breadcrumb/index.js +326 -0
  35. package/dist/breadcrumb/index.js.map +1 -0
  36. package/dist/breadcrumb/index.mjs +149 -0
  37. package/dist/breadcrumb/index.mjs.map +1 -0
  38. package/dist/button/index.d.mts +40 -0
  39. package/dist/button/index.d.ts +40 -0
  40. package/dist/button/index.js +877 -0
  41. package/dist/button/index.js.map +1 -0
  42. package/dist/button/index.mjs +10 -0
  43. package/dist/button/index.mjs.map +1 -0
  44. package/dist/carousel/index.d.mts +253 -0
  45. package/dist/carousel/index.d.ts +253 -0
  46. package/dist/carousel/index.js +1678 -0
  47. package/dist/carousel/index.js.map +1 -0
  48. package/dist/carousel/index.mjs +716 -0
  49. package/dist/carousel/index.mjs.map +1 -0
  50. package/dist/checkbox/index.d.mts +120 -0
  51. package/dist/checkbox/index.d.ts +120 -0
  52. package/dist/checkbox/index.js +873 -0
  53. package/dist/checkbox/index.js.map +1 -0
  54. package/dist/checkbox/index.mjs +349 -0
  55. package/dist/checkbox/index.mjs.map +1 -0
  56. package/dist/chip/index.d.mts +97 -0
  57. package/dist/chip/index.d.ts +97 -0
  58. package/dist/chip/index.js +905 -0
  59. package/dist/chip/index.js.map +1 -0
  60. package/dist/chip/index.mjs +793 -0
  61. package/dist/chip/index.mjs.map +1 -0
  62. package/dist/chunk-2KPFQEAA.mjs +52 -0
  63. package/dist/chunk-2KPFQEAA.mjs.map +1 -0
  64. package/dist/chunk-4F5DOL57.mjs +26 -0
  65. package/dist/chunk-4F5DOL57.mjs.map +1 -0
  66. package/dist/chunk-6JOA37TZ.mjs +742 -0
  67. package/dist/chunk-6JOA37TZ.mjs.map +1 -0
  68. package/dist/chunk-7PMPYEHJ.mjs +379 -0
  69. package/dist/chunk-7PMPYEHJ.mjs.map +1 -0
  70. package/dist/chunk-AESXFMCC.mjs +68 -0
  71. package/dist/chunk-AESXFMCC.mjs.map +1 -0
  72. package/dist/chunk-B42LOFIZ.mjs +308 -0
  73. package/dist/chunk-B42LOFIZ.mjs.map +1 -0
  74. package/dist/chunk-FGOZHKBT.mjs +97 -0
  75. package/dist/chunk-FGOZHKBT.mjs.map +1 -0
  76. package/dist/chunk-HLXYG643.mjs +52 -0
  77. package/dist/chunk-HLXYG643.mjs.map +1 -0
  78. package/dist/chunk-JKNBJHD5.mjs +601 -0
  79. package/dist/chunk-JKNBJHD5.mjs.map +1 -0
  80. package/dist/chunk-K7VP7DH3.mjs +66 -0
  81. package/dist/chunk-K7VP7DH3.mjs.map +1 -0
  82. package/dist/chunk-MUNDKRAE.mjs +80 -0
  83. package/dist/chunk-MUNDKRAE.mjs.map +1 -0
  84. package/dist/chunk-NBZKMCHF.mjs +36 -0
  85. package/dist/chunk-NBZKMCHF.mjs.map +1 -0
  86. package/dist/chunk-PZWESKAR.mjs +314 -0
  87. package/dist/chunk-PZWESKAR.mjs.map +1 -0
  88. package/dist/collapsible/index.d.mts +60 -0
  89. package/dist/collapsible/index.d.ts +60 -0
  90. package/dist/collapsible/index.js +140 -0
  91. package/dist/collapsible/index.js.map +1 -0
  92. package/dist/collapsible/index.mjs +8 -0
  93. package/dist/collapsible/index.mjs.map +1 -0
  94. package/dist/combobox/index.d.mts +285 -0
  95. package/dist/combobox/index.d.ts +285 -0
  96. package/dist/combobox/index.js +2920 -0
  97. package/dist/combobox/index.js.map +1 -0
  98. package/dist/combobox/index.mjs +1267 -0
  99. package/dist/combobox/index.mjs.map +1 -0
  100. package/dist/dialog/index.d.mts +33 -0
  101. package/dist/dialog/index.d.ts +33 -0
  102. package/dist/dialog/index.js +1286 -0
  103. package/dist/dialog/index.js.map +1 -0
  104. package/dist/dialog/index.mjs +13 -0
  105. package/dist/dialog/index.mjs.map +1 -0
  106. package/dist/divider/index.d.mts +61 -0
  107. package/dist/divider/index.d.ts +61 -0
  108. package/dist/divider/index.js +223 -0
  109. package/dist/divider/index.js.map +1 -0
  110. package/dist/divider/index.mjs +196 -0
  111. package/dist/divider/index.mjs.map +1 -0
  112. package/dist/drawer/index.d.mts +148 -0
  113. package/dist/drawer/index.d.ts +148 -0
  114. package/dist/drawer/index.js +1266 -0
  115. package/dist/drawer/index.js.map +1 -0
  116. package/dist/drawer/index.mjs +299 -0
  117. package/dist/drawer/index.mjs.map +1 -0
  118. package/dist/dropdown/index.d.mts +233 -0
  119. package/dist/dropdown/index.d.ts +233 -0
  120. package/dist/dropdown/index.js +2402 -0
  121. package/dist/dropdown/index.js.map +1 -0
  122. package/dist/dropdown/index.mjs +741 -0
  123. package/dist/dropdown/index.mjs.map +1 -0
  124. package/dist/form-field/index.d.mts +176 -0
  125. package/dist/form-field/index.d.ts +176 -0
  126. package/dist/form-field/index.js +540 -0
  127. package/dist/form-field/index.js.map +1 -0
  128. package/dist/form-field/index.mjs +13 -0
  129. package/dist/form-field/index.mjs.map +1 -0
  130. package/dist/icon/index.d.mts +28 -0
  131. package/dist/icon/index.d.ts +28 -0
  132. package/dist/icon/index.js +127 -0
  133. package/dist/icon/index.js.map +1 -0
  134. package/dist/icon/index.mjs +9 -0
  135. package/dist/icon/index.mjs.map +1 -0
  136. package/dist/icon-button/index.d.mts +16 -0
  137. package/dist/icon-button/index.d.ts +16 -0
  138. package/dist/icon-button/index.js +921 -0
  139. package/dist/icon-button/index.js.map +1 -0
  140. package/dist/icon-button/index.mjs +11 -0
  141. package/dist/icon-button/index.mjs.map +1 -0
  142. package/dist/input/index.d.mts +78 -0
  143. package/dist/input/index.d.ts +78 -0
  144. package/dist/input/index.js +1119 -0
  145. package/dist/input/index.js.map +1 -0
  146. package/dist/input/index.mjs +16 -0
  147. package/dist/input/index.mjs.map +1 -0
  148. package/dist/kbd/index.d.mts +9 -0
  149. package/dist/kbd/index.d.ts +9 -0
  150. package/dist/kbd/index.js +46 -0
  151. package/dist/kbd/index.js.map +1 -0
  152. package/dist/kbd/index.mjs +19 -0
  153. package/dist/kbd/index.mjs.map +1 -0
  154. package/dist/label/index.d.mts +11 -0
  155. package/dist/label/index.d.ts +11 -0
  156. package/dist/label/index.js +78 -0
  157. package/dist/label/index.js.map +1 -0
  158. package/dist/label/index.mjs +7 -0
  159. package/dist/label/index.mjs.map +1 -0
  160. package/dist/link-box/index.d.mts +34 -0
  161. package/dist/link-box/index.d.ts +34 -0
  162. package/dist/link-box/index.js +92 -0
  163. package/dist/link-box/index.js.map +1 -0
  164. package/dist/link-box/index.mjs +58 -0
  165. package/dist/link-box/index.mjs.map +1 -0
  166. package/dist/pagination/index.d.mts +143 -0
  167. package/dist/pagination/index.d.ts +143 -0
  168. package/dist/pagination/index.js +1303 -0
  169. package/dist/pagination/index.js.map +1 -0
  170. package/dist/pagination/index.mjs +326 -0
  171. package/dist/pagination/index.mjs.map +1 -0
  172. package/dist/popover/index.d.mts +93 -0
  173. package/dist/popover/index.d.ts +93 -0
  174. package/dist/popover/index.js +1280 -0
  175. package/dist/popover/index.js.map +1 -0
  176. package/dist/popover/index.mjs +13 -0
  177. package/dist/popover/index.mjs.map +1 -0
  178. package/dist/portal/index.d.mts +13 -0
  179. package/dist/portal/index.d.ts +13 -0
  180. package/dist/portal/index.js +37 -0
  181. package/dist/portal/index.js.map +1 -0
  182. package/dist/portal/index.mjs +10 -0
  183. package/dist/portal/index.mjs.map +1 -0
  184. package/dist/progress/index.d.mts +48 -0
  185. package/dist/progress/index.d.ts +48 -0
  186. package/dist/progress/index.js +201 -0
  187. package/dist/progress/index.js.map +1 -0
  188. package/dist/progress/index.mjs +174 -0
  189. package/dist/progress/index.mjs.map +1 -0
  190. package/dist/progress-tracker/index.d.mts +81 -0
  191. package/dist/progress-tracker/index.d.ts +81 -0
  192. package/dist/progress-tracker/index.js +834 -0
  193. package/dist/progress-tracker/index.js.map +1 -0
  194. package/dist/progress-tracker/index.mjs +716 -0
  195. package/dist/progress-tracker/index.mjs.map +1 -0
  196. package/dist/radio-group/index.d.mts +100 -0
  197. package/dist/radio-group/index.d.ts +100 -0
  198. package/dist/radio-group/index.js +824 -0
  199. package/dist/radio-group/index.js.map +1 -0
  200. package/dist/radio-group/index.mjs +297 -0
  201. package/dist/radio-group/index.mjs.map +1 -0
  202. package/dist/rating/index.d.mts +78 -0
  203. package/dist/rating/index.d.ts +78 -0
  204. package/dist/rating/index.js +362 -0
  205. package/dist/rating/index.js.map +1 -0
  206. package/dist/rating/index.mjs +247 -0
  207. package/dist/rating/index.mjs.map +1 -0
  208. package/dist/scrolling-list/index.d.mts +105 -0
  209. package/dist/scrolling-list/index.d.ts +105 -0
  210. package/dist/scrolling-list/index.js +1367 -0
  211. package/dist/scrolling-list/index.js.map +1 -0
  212. package/dist/scrolling-list/index.mjs +407 -0
  213. package/dist/scrolling-list/index.mjs.map +1 -0
  214. package/dist/select/index.d.mts +167 -0
  215. package/dist/select/index.d.ts +167 -0
  216. package/dist/select/index.js +991 -0
  217. package/dist/select/index.js.map +1 -0
  218. package/dist/select/index.mjs +470 -0
  219. package/dist/select/index.mjs.map +1 -0
  220. package/dist/skeleton/index.d.mts +67 -0
  221. package/dist/skeleton/index.d.ts +67 -0
  222. package/dist/skeleton/index.js +206 -0
  223. package/dist/skeleton/index.js.map +1 -0
  224. package/dist/skeleton/index.mjs +147 -0
  225. package/dist/skeleton/index.mjs.map +1 -0
  226. package/dist/slider/index.d.mts +97 -0
  227. package/dist/slider/index.d.ts +97 -0
  228. package/dist/slider/index.js +209 -0
  229. package/dist/slider/index.js.map +1 -0
  230. package/dist/slider/index.mjs +182 -0
  231. package/dist/slider/index.mjs.map +1 -0
  232. package/dist/slot/index.d.mts +17 -0
  233. package/dist/slot/index.d.ts +17 -0
  234. package/dist/slot/index.js +51 -0
  235. package/dist/slot/index.js.map +1 -0
  236. package/dist/slot/index.mjs +11 -0
  237. package/dist/slot/index.mjs.map +1 -0
  238. package/dist/snackbar/index.d.mts +158 -0
  239. package/dist/snackbar/index.d.ts +158 -0
  240. package/dist/snackbar/index.js +1693 -0
  241. package/dist/snackbar/index.js.map +1 -0
  242. package/dist/snackbar/index.mjs +733 -0
  243. package/dist/snackbar/index.mjs.map +1 -0
  244. package/dist/spinner/index.d.mts +21 -0
  245. package/dist/spinner/index.d.ts +21 -0
  246. package/dist/spinner/index.js +139 -0
  247. package/dist/spinner/index.js.map +1 -0
  248. package/dist/spinner/index.mjs +9 -0
  249. package/dist/spinner/index.mjs.map +1 -0
  250. package/dist/stepper/index.d.mts +82 -0
  251. package/dist/stepper/index.d.ts +82 -0
  252. package/dist/stepper/index.js +2178 -0
  253. package/dist/stepper/index.js.map +1 -0
  254. package/dist/stepper/index.mjs +229 -0
  255. package/dist/stepper/index.mjs.map +1 -0
  256. package/dist/switch/index.d.mts +64 -0
  257. package/dist/switch/index.d.ts +64 -0
  258. package/dist/switch/index.js +768 -0
  259. package/dist/switch/index.js.map +1 -0
  260. package/dist/switch/index.mjs +245 -0
  261. package/dist/switch/index.mjs.map +1 -0
  262. package/dist/tabs/index.d.mts +103 -0
  263. package/dist/tabs/index.d.ts +103 -0
  264. package/dist/tabs/index.js +1315 -0
  265. package/dist/tabs/index.js.map +1 -0
  266. package/dist/tabs/index.mjs +391 -0
  267. package/dist/tabs/index.mjs.map +1 -0
  268. package/dist/tag/index.d.mts +27 -0
  269. package/dist/tag/index.d.ts +27 -0
  270. package/dist/tag/index.js +269 -0
  271. package/dist/tag/index.js.map +1 -0
  272. package/dist/tag/index.mjs +237 -0
  273. package/dist/tag/index.mjs.map +1 -0
  274. package/dist/text-link/index.d.mts +20 -0
  275. package/dist/text-link/index.d.ts +20 -0
  276. package/dist/text-link/index.js +99 -0
  277. package/dist/text-link/index.js.map +1 -0
  278. package/dist/text-link/index.mjs +8 -0
  279. package/dist/text-link/index.mjs.map +1 -0
  280. package/dist/textarea/index.d.mts +47 -0
  281. package/dist/textarea/index.d.ts +47 -0
  282. package/dist/textarea/index.js +1180 -0
  283. package/dist/textarea/index.js.map +1 -0
  284. package/dist/textarea/index.mjs +77 -0
  285. package/dist/textarea/index.mjs.map +1 -0
  286. package/dist/visually-hidden/index.d.mts +16 -0
  287. package/dist/visually-hidden/index.d.ts +16 -0
  288. package/dist/visually-hidden/index.js +67 -0
  289. package/dist/visually-hidden/index.js.map +1 -0
  290. package/dist/visually-hidden/index.mjs +8 -0
  291. package/dist/visually-hidden/index.mjs.map +1 -0
  292. package/global.d.ts +12 -0
  293. package/package.json +75 -0
  294. package/tsconfig.build.json +9 -0
  295. package/tsconfig.json +9 -0
  296. package/tsup.config.ts +11 -0
@@ -0,0 +1,2402 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/dropdown/index.ts
21
+ var dropdown_exports = {};
22
+ __export(dropdown_exports, {
23
+ Dropdown: () => Dropdown2,
24
+ DropdownProvider: () => DropdownProvider,
25
+ useDropdownContext: () => useDropdownContext
26
+ });
27
+ module.exports = __toCommonJS(dropdown_exports);
28
+
29
+ // src/dropdown/DropdownContext.tsx
30
+ var import_react12 = require("react");
31
+
32
+ // src/form-field/FormField.tsx
33
+ var import_class_variance_authority = require("class-variance-authority");
34
+ var import_react4 = require("react");
35
+
36
+ // src/slot/Slot.tsx
37
+ var import_radix_ui = require("radix-ui");
38
+ var import_react = require("react");
39
+ var import_jsx_runtime = require("react/jsx-runtime");
40
+ var Slottable = import_radix_ui.Slot.Slottable;
41
+ var Slot = ({ ref, ...props }) => {
42
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
43
+ };
44
+ var wrapPolymorphicSlot = (asChild, children, callback) => {
45
+ if (!asChild) return callback(children);
46
+ return (0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(
47
+ children,
48
+ void 0,
49
+ callback(children.props.children)
50
+ ) : null;
51
+ };
52
+
53
+ // src/form-field/FormFieldContext.tsx
54
+ var import_react2 = require("react");
55
+ var FormFieldContext = (0, import_react2.createContext)(null);
56
+ var ID_PREFIX = ":form-field";
57
+ var useFormField = () => {
58
+ const context = (0, import_react2.useContext)(FormFieldContext);
59
+ if (!context) {
60
+ throw Error("useFormField must be used within a FormField provider");
61
+ }
62
+ return context;
63
+ };
64
+
65
+ // src/form-field/FormFieldProvider.tsx
66
+ var import_react3 = require("react");
67
+ var import_jsx_runtime2 = require("react/jsx-runtime");
68
+ var FormFieldProvider = ({
69
+ id,
70
+ name,
71
+ disabled = false,
72
+ readOnly = false,
73
+ state,
74
+ isRequired,
75
+ children
76
+ }) => {
77
+ const labelId = `${ID_PREFIX}-label-${(0, import_react3.useId)()}`;
78
+ const [messageIds, setMessageIds] = (0, import_react3.useState)([]);
79
+ const description = messageIds.length > 0 ? messageIds.join(" ") : void 0;
80
+ const handleMessageIdAdd = (0, import_react3.useCallback)((msgId) => {
81
+ setMessageIds((ids) => [...ids, msgId]);
82
+ }, []);
83
+ const handleMessageIdRemove = (0, import_react3.useCallback)((msgId) => {
84
+ setMessageIds((ids) => ids.filter((current) => current !== msgId));
85
+ }, []);
86
+ const value = (0, import_react3.useMemo)(() => {
87
+ const isInvalid = state === "error";
88
+ return {
89
+ id,
90
+ labelId,
91
+ name,
92
+ disabled,
93
+ readOnly,
94
+ state,
95
+ isRequired,
96
+ isInvalid,
97
+ description,
98
+ onMessageIdAdd: handleMessageIdAdd,
99
+ onMessageIdRemove: handleMessageIdRemove
100
+ };
101
+ }, [
102
+ id,
103
+ labelId,
104
+ name,
105
+ disabled,
106
+ readOnly,
107
+ description,
108
+ state,
109
+ isRequired,
110
+ handleMessageIdAdd,
111
+ handleMessageIdRemove
112
+ ]);
113
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(FormFieldContext.Provider, { value, children });
114
+ };
115
+ FormFieldProvider.displayName = "FormFieldProvider";
116
+
117
+ // src/form-field/FormField.tsx
118
+ var import_jsx_runtime3 = require("react/jsx-runtime");
119
+ var FormField = ({
120
+ className,
121
+ disabled = false,
122
+ readOnly = false,
123
+ name,
124
+ state,
125
+ isRequired = false,
126
+ asChild = false,
127
+ ref,
128
+ ...others
129
+ }) => {
130
+ const id = `${ID_PREFIX}-${(0, import_react4.useId)()}`;
131
+ const Component = asChild ? Slot : "div";
132
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
133
+ FormFieldProvider,
134
+ {
135
+ id,
136
+ name,
137
+ isRequired,
138
+ disabled,
139
+ readOnly,
140
+ state,
141
+ children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
142
+ Component,
143
+ {
144
+ ref,
145
+ "data-spark-component": "form-field",
146
+ className: (0, import_class_variance_authority.cx)(className, "gap-sm flex flex-col"),
147
+ ...others
148
+ }
149
+ )
150
+ }
151
+ );
152
+ };
153
+ FormField.displayName = "FormField";
154
+
155
+ // src/form-field/FormFieldStateMessage.tsx
156
+ var import_AlertOutline = require("@spark-ui/icons/AlertOutline");
157
+ var import_Check = require("@spark-ui/icons/Check");
158
+ var import_WarningOutline = require("@spark-ui/icons/WarningOutline");
159
+ var import_class_variance_authority4 = require("class-variance-authority");
160
+
161
+ // src/icon/Icon.tsx
162
+ var import_react5 = require("react");
163
+
164
+ // src/visually-hidden/VisuallyHidden.tsx
165
+ var import_jsx_runtime4 = require("react/jsx-runtime");
166
+ var VisuallyHidden = ({ asChild = false, ref, ...props }) => {
167
+ const Component = asChild ? Slot : "span";
168
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
169
+ Component,
170
+ {
171
+ ...props,
172
+ ref,
173
+ style: {
174
+ // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
175
+ position: "absolute",
176
+ border: 0,
177
+ width: 1,
178
+ height: 1,
179
+ padding: 0,
180
+ margin: -1,
181
+ overflow: "hidden",
182
+ clip: "rect(0, 0, 0, 0)",
183
+ whiteSpace: "nowrap",
184
+ wordWrap: "normal",
185
+ ...props.style
186
+ }
187
+ }
188
+ );
189
+ };
190
+ VisuallyHidden.displayName = "VisuallyHidden";
191
+
192
+ // src/icon/Icon.styles.tsx
193
+ var import_internal_utils = require("@spark-ui/internal-utils");
194
+ var import_class_variance_authority2 = require("class-variance-authority");
195
+ var iconStyles = (0, import_class_variance_authority2.cva)(["fill-current shrink-0"], {
196
+ variants: {
197
+ /**
198
+ * Color scheme of the icon.
199
+ */
200
+ intent: (0, import_internal_utils.makeVariants)({
201
+ current: ["text-current"],
202
+ main: ["text-main"],
203
+ support: ["text-support"],
204
+ accent: ["text-accent"],
205
+ basic: ["text-basic"],
206
+ success: ["text-success"],
207
+ alert: ["text-alert"],
208
+ error: ["text-error"],
209
+ info: ["text-info"],
210
+ neutral: ["text-neutral"]
211
+ }),
212
+ /**
213
+ * Sets the size of the icon.
214
+ */
215
+ size: (0, import_internal_utils.makeVariants)({
216
+ current: ["u-current-font-size"],
217
+ sm: ["w-sz-16", "h-sz-16"],
218
+ md: ["w-sz-24", "h-sz-24"],
219
+ lg: ["w-sz-32", "h-sz-32"],
220
+ xl: ["w-sz-40", "h-sz-40"]
221
+ })
222
+ }
223
+ });
224
+
225
+ // src/icon/Icon.tsx
226
+ var import_jsx_runtime5 = require("react/jsx-runtime");
227
+ var Icon = ({
228
+ label,
229
+ className,
230
+ size = "current",
231
+ intent = "current",
232
+ children,
233
+ ...others
234
+ }) => {
235
+ const child = import_react5.Children.only(children);
236
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
237
+ (0, import_react5.cloneElement)(child, {
238
+ className: iconStyles({ className, size, intent }),
239
+ "data-spark-component": "icon",
240
+ "aria-hidden": "true",
241
+ focusable: "false",
242
+ ...others
243
+ }),
244
+ label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VisuallyHidden, { children: label })
245
+ ] });
246
+ };
247
+ Icon.displayName = "Icon";
248
+
249
+ // src/form-field/FormFieldMessage.tsx
250
+ var import_class_variance_authority3 = require("class-variance-authority");
251
+ var import_react6 = require("react");
252
+ var import_jsx_runtime6 = require("react/jsx-runtime");
253
+ var FormFieldMessage = ({
254
+ id: idProp,
255
+ className,
256
+ ref,
257
+ ...others
258
+ }) => {
259
+ const { onMessageIdAdd, onMessageIdRemove } = useFormField();
260
+ const currentId = `${ID_PREFIX}-message-${(0, import_react6.useId)()}`;
261
+ const id = idProp || currentId;
262
+ (0, import_react6.useEffect)(() => {
263
+ onMessageIdAdd(id);
264
+ return () => {
265
+ onMessageIdRemove(id);
266
+ };
267
+ }, [id, onMessageIdAdd, onMessageIdRemove]);
268
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
269
+ "span",
270
+ {
271
+ ref,
272
+ id,
273
+ "data-spark-component": "form-field-message",
274
+ className: (0, import_class_variance_authority3.cx)(className, "text-caption"),
275
+ ...others
276
+ }
277
+ );
278
+ };
279
+ FormFieldMessage.displayName = "FormField.Message";
280
+
281
+ // src/form-field/FormFieldStateMessage.tsx
282
+ var import_jsx_runtime7 = require("react/jsx-runtime");
283
+ var FormFieldStateMessage = ({
284
+ className,
285
+ state,
286
+ children,
287
+ ref,
288
+ ...others
289
+ }) => {
290
+ const field = useFormField();
291
+ if (field.state !== state) {
292
+ return null;
293
+ }
294
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
295
+ FormFieldMessage,
296
+ {
297
+ ref,
298
+ "data-spark-component": "form-field-state-message",
299
+ "aria-live": "polite",
300
+ className: (0, import_class_variance_authority4.cx)(
301
+ "gap-sm flex items-center",
302
+ state === "error" ? "text-error" : "text-on-surface/dim-1",
303
+ className
304
+ ),
305
+ ...others,
306
+ children: [
307
+ state === "alert" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_WarningOutline.WarningOutline, {}) }),
308
+ state === "error" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", intent: "error", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_AlertOutline.AlertOutline, {}) }),
309
+ state === "success" && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_Check.Check, {}) }),
310
+ children
311
+ ]
312
+ }
313
+ );
314
+ };
315
+ FormFieldStateMessage.displayName = "FormField.StateMessage";
316
+
317
+ // src/form-field/FormFieldAlertMessage.tsx
318
+ var import_jsx_runtime8 = require("react/jsx-runtime");
319
+ var FormFieldAlertMessage = ({ ref, ...props }) => {
320
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
321
+ FormFieldStateMessage,
322
+ {
323
+ ref,
324
+ "data-spark-component": "form-field-alert-message",
325
+ state: "alert",
326
+ ...props
327
+ }
328
+ );
329
+ };
330
+ FormFieldAlertMessage.displayName = "FormField.AlertMessage";
331
+
332
+ // src/form-field/FormFieldCharactersCount.tsx
333
+ var import_class_variance_authority5 = require("class-variance-authority");
334
+ var import_jsx_runtime9 = require("react/jsx-runtime");
335
+ var FormFieldCharactersCount = ({
336
+ className,
337
+ value = "",
338
+ maxLength,
339
+ ref,
340
+ ...others
341
+ }) => {
342
+ const displayValue = `${value.length}/${maxLength}`;
343
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
344
+ "span",
345
+ {
346
+ ref,
347
+ "data-spark-component": "form-field-characters-count",
348
+ className: (0, import_class_variance_authority5.cx)(className, "text-caption", "text-neutral"),
349
+ ...others,
350
+ children: displayValue
351
+ }
352
+ );
353
+ };
354
+ FormFieldCharactersCount.displayName = "FormField.CharactersCount";
355
+
356
+ // src/form-field/FormFieldControl.tsx
357
+ var import_react7 = require("react");
358
+ var import_jsx_runtime10 = require("react/jsx-runtime");
359
+ var useFormFieldControl = () => {
360
+ const { id, name, description, disabled, readOnly, state, labelId, isInvalid, isRequired } = (0, import_react7.useContext)(FormFieldContext) || {};
361
+ return {
362
+ id,
363
+ name,
364
+ description,
365
+ disabled,
366
+ readOnly,
367
+ state,
368
+ labelId,
369
+ isInvalid,
370
+ isRequired
371
+ };
372
+ };
373
+ var FormFieldControl = ({ children }) => {
374
+ const props = useFormFieldControl();
375
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_jsx_runtime10.Fragment, { children: children(props) });
376
+ };
377
+ FormFieldControl.displayName = "FormField.Control";
378
+
379
+ // src/form-field/FormFieldErrorMessage.tsx
380
+ var import_jsx_runtime11 = require("react/jsx-runtime");
381
+ var FormFieldErrorMessage = ({ ref, ...props }) => {
382
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
383
+ FormFieldStateMessage,
384
+ {
385
+ ref,
386
+ "data-spark-component": "form-field-error-message",
387
+ state: "error",
388
+ ...props
389
+ }
390
+ );
391
+ };
392
+ FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
393
+
394
+ // src/form-field/FormFieldHelperMessage.tsx
395
+ var import_class_variance_authority6 = require("class-variance-authority");
396
+ var import_jsx_runtime12 = require("react/jsx-runtime");
397
+ var FormFieldHelperMessage = ({
398
+ className,
399
+ ref,
400
+ ...others
401
+ }) => {
402
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
403
+ FormFieldMessage,
404
+ {
405
+ ref,
406
+ "data-spark-component": "form-field-helper-message",
407
+ className: (0, import_class_variance_authority6.cx)("text-on-surface/dim-1", className),
408
+ ...others
409
+ }
410
+ );
411
+ };
412
+ FormFieldHelperMessage.displayName = "FormField.HelperMessage";
413
+
414
+ // src/form-field/FormFieldLabel.tsx
415
+ var import_class_variance_authority10 = require("class-variance-authority");
416
+
417
+ // src/label/Label.tsx
418
+ var import_class_variance_authority7 = require("class-variance-authority");
419
+ var import_radix_ui2 = require("radix-ui");
420
+ var import_jsx_runtime13 = require("react/jsx-runtime");
421
+ var Label = ({ className, ref, ...others }) => {
422
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
423
+ import_radix_ui2.Label.Label,
424
+ {
425
+ ref,
426
+ "data-spark-component": "label",
427
+ className: (0, import_class_variance_authority7.cx)("text-body-1", className),
428
+ ...others
429
+ }
430
+ );
431
+ };
432
+ Label.displayName = "Label";
433
+
434
+ // src/label/LabelRequiredIndicator.tsx
435
+ var import_class_variance_authority8 = require("class-variance-authority");
436
+ var import_jsx_runtime14 = require("react/jsx-runtime");
437
+ var LabelRequiredIndicator = ({
438
+ className,
439
+ children = "*",
440
+ ref,
441
+ ...others
442
+ }) => {
443
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
444
+ "span",
445
+ {
446
+ ref,
447
+ "data-spark-component": "label-required-indicator",
448
+ role: "presentation",
449
+ "aria-hidden": "true",
450
+ className: (0, import_class_variance_authority8.cx)(className, "text-caption text-on-surface/dim-1"),
451
+ ...others,
452
+ children
453
+ }
454
+ );
455
+ };
456
+ LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
457
+
458
+ // src/label/index.ts
459
+ var Label2 = Object.assign(Label, {
460
+ RequiredIndicator: LabelRequiredIndicator
461
+ });
462
+ Label2.displayName = "Label";
463
+ LabelRequiredIndicator.displayName = "Label.RequiredIndicator";
464
+
465
+ // src/form-field/FormFieldRequiredIndicator.tsx
466
+ var import_class_variance_authority9 = require("class-variance-authority");
467
+ var import_jsx_runtime15 = require("react/jsx-runtime");
468
+ var FormFieldRequiredIndicator = ({
469
+ className,
470
+ ref,
471
+ ...props
472
+ }) => {
473
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Label2.RequiredIndicator, { ref, className: (0, import_class_variance_authority9.cx)("ml-sm", className), ...props });
474
+ };
475
+ FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
476
+
477
+ // src/form-field/FormFieldLabel.tsx
478
+ var import_jsx_runtime16 = require("react/jsx-runtime");
479
+ var FormFieldLabel = ({
480
+ htmlFor: htmlForProp,
481
+ className,
482
+ children,
483
+ requiredIndicator = /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(FormFieldRequiredIndicator, {}),
484
+ asChild,
485
+ ref,
486
+ ...others
487
+ }) => {
488
+ const control = useFormField();
489
+ const { disabled, labelId, isRequired } = control;
490
+ const htmlFor = asChild ? void 0 : htmlForProp || control.id;
491
+ return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
492
+ Label2,
493
+ {
494
+ ref,
495
+ id: labelId,
496
+ "data-spark-component": "form-field-label",
497
+ htmlFor,
498
+ className: (0, import_class_variance_authority10.cx)(className, disabled ? "text-on-surface/dim-3 pointer-events-none" : void 0),
499
+ asChild,
500
+ ...others,
501
+ children: /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
502
+ /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Slottable, { children }),
503
+ isRequired && requiredIndicator
504
+ ] })
505
+ }
506
+ );
507
+ };
508
+ FormFieldLabel.displayName = "FormField.Label";
509
+
510
+ // src/form-field/FormFieldSuccessMessage.tsx
511
+ var import_jsx_runtime17 = require("react/jsx-runtime");
512
+ var FormFieldSuccessMessage = ({ ref, ...props }) => {
513
+ return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
514
+ FormFieldStateMessage,
515
+ {
516
+ ref,
517
+ "data-spark-component": "form-field-success-message",
518
+ state: "success",
519
+ ...props
520
+ }
521
+ );
522
+ };
523
+ FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
524
+
525
+ // src/form-field/index.ts
526
+ var FormField2 = Object.assign(FormField, {
527
+ Label: FormFieldLabel,
528
+ Control: FormFieldControl,
529
+ StateMessage: FormFieldStateMessage,
530
+ SuccessMessage: FormFieldSuccessMessage,
531
+ AlertMessage: FormFieldAlertMessage,
532
+ ErrorMessage: FormFieldErrorMessage,
533
+ HelperMessage: FormFieldHelperMessage,
534
+ RequiredIndicator: FormFieldRequiredIndicator,
535
+ CharactersCount: FormFieldCharactersCount
536
+ });
537
+ FormField2.displayName = "FormField";
538
+ FormFieldLabel.displayName = "FormField.Label";
539
+ FormFieldControl.displayName = "FormField.Control";
540
+ FormFieldStateMessage.displayName = "FormField.StateMessage";
541
+ FormFieldSuccessMessage.displayName = "FormField.SuccessMessage";
542
+ FormFieldAlertMessage.displayName = "FormField.AlertMessage";
543
+ FormFieldErrorMessage.displayName = "FormField.ErrorMessage";
544
+ FormFieldHelperMessage.displayName = "FormField.HelperMessage";
545
+ FormFieldRequiredIndicator.displayName = "FormField.RequiredIndicator";
546
+ FormFieldCharactersCount.displayName = "FormField.CharactersCount";
547
+
548
+ // src/popover/Popover.tsx
549
+ var import_radix_ui3 = require("radix-ui");
550
+
551
+ // src/popover/PopoverContext.tsx
552
+ var import_react8 = require("react");
553
+ var import_jsx_runtime18 = require("react/jsx-runtime");
554
+ var PopoverContext = (0, import_react8.createContext)(null);
555
+ var ID_PREFIX2 = ":popover";
556
+ var PopoverProvider = ({
557
+ children,
558
+ intent
559
+ }) => {
560
+ const [headerId, setHeaderId] = (0, import_react8.useState)(null);
561
+ return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
562
+ PopoverContext.Provider,
563
+ {
564
+ value: {
565
+ headerId,
566
+ setHeaderId,
567
+ intent
568
+ },
569
+ children
570
+ }
571
+ );
572
+ };
573
+ var usePopover = () => {
574
+ const context = (0, import_react8.useContext)(PopoverContext);
575
+ if (!context) {
576
+ throw Error("usePopover must be used within a Popover provider");
577
+ }
578
+ return context;
579
+ };
580
+
581
+ // src/popover/Popover.tsx
582
+ var import_jsx_runtime19 = require("react/jsx-runtime");
583
+ var Popover = ({ children, intent = "surface", modal = false, ...rest }) => {
584
+ return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(PopoverProvider, { intent, children: /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_radix_ui3.Popover.Root, { "data-spark-component": "popover", modal, ...rest, children }) });
585
+ };
586
+ Popover.displayName = "Popover";
587
+
588
+ // src/popover/PopoverAnchor.tsx
589
+ var import_radix_ui4 = require("radix-ui");
590
+ var import_jsx_runtime20 = require("react/jsx-runtime");
591
+ var Anchor = ({ asChild = false, children, ref, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(import_radix_ui4.Popover.Anchor, { "data-spark-component": "popover-anchor", ref, asChild, ...rest, children });
592
+ Anchor.displayName = "Popover.Anchor";
593
+
594
+ // src/popover/PopoverArrow.tsx
595
+ var import_class_variance_authority11 = require("class-variance-authority");
596
+ var import_radix_ui5 = require("radix-ui");
597
+ var import_jsx_runtime21 = require("react/jsx-runtime");
598
+ var Arrow = ({
599
+ asChild = false,
600
+ width = 16,
601
+ height = 8,
602
+ className,
603
+ ref,
604
+ ...rest
605
+ }) => {
606
+ const { intent } = usePopover();
607
+ const styles4 = (0, import_class_variance_authority11.cva)("visible", {
608
+ variants: {
609
+ intent: {
610
+ surface: "fill-surface",
611
+ main: "fill-main-container",
612
+ support: "fill-support-container",
613
+ accent: "fill-accent-container",
614
+ basic: "fill-basic-container",
615
+ success: "fill-success-container",
616
+ alert: "fill-alert-container",
617
+ danger: "fill-error-container",
618
+ info: "fill-info-container",
619
+ neutral: "fill-neutral-container"
620
+ }
621
+ },
622
+ defaultVariants: {
623
+ intent: "surface"
624
+ }
625
+ });
626
+ return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
627
+ import_radix_ui5.Popover.Arrow,
628
+ {
629
+ "data-spark-component": "popover-arrow",
630
+ ref,
631
+ className: styles4({ intent, className }),
632
+ asChild,
633
+ width,
634
+ height,
635
+ ...rest
636
+ }
637
+ );
638
+ };
639
+ Arrow.displayName = "Popover.Arrow";
640
+
641
+ // src/popover/PopoverCloseButton.tsx
642
+ var import_Close = require("@spark-ui/icons/Close");
643
+ var import_class_variance_authority16 = require("class-variance-authority");
644
+ var import_radix_ui6 = require("radix-ui");
645
+
646
+ // src/button/Button.tsx
647
+ var import_class_variance_authority14 = require("class-variance-authority");
648
+ var import_react9 = require("react");
649
+
650
+ // src/spinner/Spinner.styles.tsx
651
+ var import_internal_utils2 = require("@spark-ui/internal-utils");
652
+ var import_class_variance_authority12 = require("class-variance-authority");
653
+ var defaultVariants = {
654
+ intent: "current",
655
+ size: "current",
656
+ isBackgroundVisible: false
657
+ };
658
+ var spinnerStyles = (0, import_class_variance_authority12.cva)(
659
+ ["inline-block", "border-solid", "rounded-full", "border-md", "animate-spin"],
660
+ {
661
+ variants: {
662
+ /**
663
+ * Use `size` prop to set the size of the spinner. If you want to set the full size for the spinner, don't forget to add a wrapping container with its own size.
664
+ */
665
+ size: {
666
+ current: ["u-current-font-size"],
667
+ sm: ["w-sz-20", "h-sz-20"],
668
+ md: ["w-sz-28", "h-sz-28"],
669
+ full: ["w-full", "h-full"]
670
+ },
671
+ /**
672
+ * Color scheme of the spinner.
673
+ */
674
+ intent: (0, import_internal_utils2.makeVariants)({
675
+ current: ["border-current"],
676
+ main: ["border-main"],
677
+ support: ["border-support"],
678
+ accent: ["border-accent"],
679
+ basic: ["border-basic"],
680
+ success: ["border-success"],
681
+ alert: ["border-alert"],
682
+ error: ["border-error"],
683
+ info: ["border-info"],
684
+ neutral: ["border-neutral"]
685
+ }),
686
+ /**
687
+ * Size of the button.
688
+ */
689
+ isBackgroundVisible: {
690
+ true: ["border-b-neutral-container", "border-l-neutral-container"],
691
+ false: ["border-b-transparent", "border-l-transparent"]
692
+ }
693
+ },
694
+ defaultVariants
695
+ }
696
+ );
697
+
698
+ // src/spinner/Spinner.tsx
699
+ var import_jsx_runtime22 = require("react/jsx-runtime");
700
+ var Spinner = ({
701
+ className,
702
+ size = "current",
703
+ intent = "current",
704
+ label,
705
+ isBackgroundVisible,
706
+ ref,
707
+ ...others
708
+ }) => {
709
+ return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(
710
+ "span",
711
+ {
712
+ role: "status",
713
+ "data-spark-component": "spinner",
714
+ ref,
715
+ className: spinnerStyles({ className, size, intent, isBackgroundVisible }),
716
+ ...others,
717
+ children: label && /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(VisuallyHidden, { children: label })
718
+ }
719
+ );
720
+ };
721
+
722
+ // src/button/Button.styles.tsx
723
+ var import_internal_utils8 = require("@spark-ui/internal-utils");
724
+ var import_class_variance_authority13 = require("class-variance-authority");
725
+
726
+ // src/button/variants/filled.ts
727
+ var import_internal_utils3 = require("@spark-ui/internal-utils");
728
+ var filledVariants = [
729
+ // Main
730
+ {
731
+ intent: "main",
732
+ design: "filled",
733
+ class: (0, import_internal_utils3.tw)([
734
+ "bg-main",
735
+ "text-on-main",
736
+ "hover:bg-main-hovered",
737
+ "enabled:active:bg-main-hovered",
738
+ "focus-visible:bg-main-hovered"
739
+ ])
740
+ },
741
+ // Support
742
+ {
743
+ intent: "support",
744
+ design: "filled",
745
+ class: (0, import_internal_utils3.tw)([
746
+ "bg-support",
747
+ "text-on-support",
748
+ "hover:bg-support-hovered",
749
+ "enabled:active:bg-support-hovered",
750
+ "focus-visible:bg-support-hovered"
751
+ ])
752
+ },
753
+ // Accent
754
+ {
755
+ intent: "accent",
756
+ design: "filled",
757
+ class: (0, import_internal_utils3.tw)([
758
+ "bg-accent",
759
+ "text-on-accent",
760
+ "hover:bg-accent-hovered",
761
+ "enabled:active:bg-accent-hovered",
762
+ "focus-visible:bg-accent-hovered"
763
+ ])
764
+ },
765
+ // Basic
766
+ {
767
+ intent: "basic",
768
+ design: "filled",
769
+ class: (0, import_internal_utils3.tw)([
770
+ "bg-basic",
771
+ "text-on-basic",
772
+ "hover:bg-basic-hovered",
773
+ "enabled:active:bg-basic-hovered",
774
+ "focus-visible:bg-basic-hovered"
775
+ ])
776
+ },
777
+ // Success
778
+ {
779
+ intent: "success",
780
+ design: "filled",
781
+ class: (0, import_internal_utils3.tw)([
782
+ "bg-success",
783
+ "text-on-success",
784
+ "hover:bg-success-hovered",
785
+ "enabled:active:bg-success-hovered",
786
+ "focus-visible:bg-success-hovered"
787
+ ])
788
+ },
789
+ // Alert
790
+ {
791
+ intent: "alert",
792
+ design: "filled",
793
+ class: (0, import_internal_utils3.tw)([
794
+ "bg-alert",
795
+ "text-on-alert",
796
+ "hover:bg-alert-hovered",
797
+ "enabled:active:bg-alert-hovered",
798
+ "focus-visible:bg-alert-hovered"
799
+ ])
800
+ },
801
+ // Danger
802
+ {
803
+ intent: "danger",
804
+ design: "filled",
805
+ class: (0, import_internal_utils3.tw)([
806
+ "text-on-error bg-error",
807
+ "hover:bg-error-hovered enabled:active:bg-error-hovered",
808
+ "focus-visible:bg-error-hovered"
809
+ ])
810
+ },
811
+ // Info
812
+ {
813
+ intent: "info",
814
+ design: "filled",
815
+ class: (0, import_internal_utils3.tw)([
816
+ "text-on-error bg-info",
817
+ "hover:bg-info-hovered enabled:active:bg-info-hovered",
818
+ "focus-visible:bg-info-hovered"
819
+ ])
820
+ },
821
+ // Neutral
822
+ {
823
+ intent: "neutral",
824
+ design: "filled",
825
+ class: (0, import_internal_utils3.tw)([
826
+ "bg-neutral",
827
+ "text-on-neutral",
828
+ "hover:bg-neutral-hovered",
829
+ "enabled:active:bg-neutral-hovered",
830
+ "focus-visible:bg-neutral-hovered"
831
+ ])
832
+ },
833
+ // Surface
834
+ {
835
+ intent: "surface",
836
+ design: "filled",
837
+ class: (0, import_internal_utils3.tw)([
838
+ "bg-surface",
839
+ "text-on-surface",
840
+ "hover:bg-surface-hovered",
841
+ "enabled:active:bg-surface-hovered",
842
+ "focus-visible:bg-surface-hovered"
843
+ ])
844
+ }
845
+ ];
846
+
847
+ // src/button/variants/ghost.ts
848
+ var import_internal_utils4 = require("@spark-ui/internal-utils");
849
+ var ghostVariants = [
850
+ {
851
+ intent: "main",
852
+ design: "ghost",
853
+ class: (0, import_internal_utils4.tw)([
854
+ "text-main",
855
+ "hover:bg-main/dim-5",
856
+ "enabled:active:bg-main/dim-5",
857
+ "focus-visible:bg-main/dim-5"
858
+ ])
859
+ },
860
+ {
861
+ intent: "support",
862
+ design: "ghost",
863
+ class: (0, import_internal_utils4.tw)([
864
+ "text-support",
865
+ "hover:bg-support/dim-5",
866
+ "enabled:active:bg-support/dim-5",
867
+ "focus-visible:bg-support/dim-5"
868
+ ])
869
+ },
870
+ {
871
+ intent: "accent",
872
+ design: "ghost",
873
+ class: (0, import_internal_utils4.tw)([
874
+ "text-accent",
875
+ "hover:bg-accent/dim-5",
876
+ "enabled:active:bg-accent/dim-5",
877
+ "focus-visible:bg-accent/dim-5"
878
+ ])
879
+ },
880
+ {
881
+ intent: "basic",
882
+ design: "ghost",
883
+ class: (0, import_internal_utils4.tw)([
884
+ "text-basic",
885
+ "hover:bg-basic/dim-5",
886
+ "enabled:active:bg-basic/dim-5",
887
+ "focus-visible:bg-basic/dim-5"
888
+ ])
889
+ },
890
+ {
891
+ intent: "success",
892
+ design: "ghost",
893
+ class: (0, import_internal_utils4.tw)([
894
+ "text-success",
895
+ "hover:bg-success/dim-5",
896
+ "enabled:active:bg-success/dim-5",
897
+ "focus-visible:bg-success/dim-5"
898
+ ])
899
+ },
900
+ {
901
+ intent: "alert",
902
+ design: "ghost",
903
+ class: (0, import_internal_utils4.tw)([
904
+ "text-alert",
905
+ "hover:bg-alert/dim-5",
906
+ "enabled:active:bg-alert/dim-5",
907
+ "focus-visible:bg-alert/dim-5"
908
+ ])
909
+ },
910
+ {
911
+ intent: "danger",
912
+ design: "ghost",
913
+ class: (0, import_internal_utils4.tw)([
914
+ "text-error",
915
+ "hover:bg-error/dim-5",
916
+ "enabled:active:bg-error/dim-5",
917
+ "focus-visible:bg-error/dim-5"
918
+ ])
919
+ },
920
+ {
921
+ intent: "info",
922
+ design: "ghost",
923
+ class: (0, import_internal_utils4.tw)([
924
+ "text-info",
925
+ "hover:bg-info/dim-5",
926
+ "enabled:active:bg-info/dim-5",
927
+ "focus-visible:bg-info/dim-5"
928
+ ])
929
+ },
930
+ {
931
+ intent: "neutral",
932
+ design: "ghost",
933
+ class: (0, import_internal_utils4.tw)([
934
+ "text-neutral",
935
+ "hover:bg-neutral/dim-5",
936
+ "enabled:active:bg-neutral/dim-5",
937
+ "focus-visible:bg-neutral/dim-5"
938
+ ])
939
+ },
940
+ {
941
+ intent: "surface",
942
+ design: "ghost",
943
+ class: (0, import_internal_utils4.tw)([
944
+ "text-surface",
945
+ "hover:bg-surface/dim-5",
946
+ "enabled:active:bg-surface/dim-5",
947
+ "focus-visible:bg-surface/dim-5"
948
+ ])
949
+ }
950
+ ];
951
+
952
+ // src/button/variants/outlined.ts
953
+ var import_internal_utils5 = require("@spark-ui/internal-utils");
954
+ var outlinedVariants = [
955
+ {
956
+ intent: "main",
957
+ design: "outlined",
958
+ class: (0, import_internal_utils5.tw)([
959
+ "hover:bg-main/dim-5",
960
+ "enabled:active:bg-main/dim-5",
961
+ "focus-visible:bg-main/dim-5",
962
+ "text-main"
963
+ ])
964
+ },
965
+ {
966
+ intent: "support",
967
+ design: "outlined",
968
+ class: (0, import_internal_utils5.tw)([
969
+ "hover:bg-support/dim-5",
970
+ "enabled:active:bg-support/dim-5",
971
+ "focus-visible:bg-support/dim-5",
972
+ "text-support"
973
+ ])
974
+ },
975
+ {
976
+ intent: "accent",
977
+ design: "outlined",
978
+ class: (0, import_internal_utils5.tw)([
979
+ "hover:bg-accent/dim-5",
980
+ "enabled:active:bg-accent/dim-5",
981
+ "focus-visible:bg-accent/dim-5",
982
+ "text-accent"
983
+ ])
984
+ },
985
+ {
986
+ intent: "basic",
987
+ design: "outlined",
988
+ class: (0, import_internal_utils5.tw)([
989
+ "hover:bg-basic/dim-5",
990
+ "enabled:active:bg-basic/dim-5",
991
+ "focus-visible:bg-basic/dim-5",
992
+ "text-basic"
993
+ ])
994
+ },
995
+ {
996
+ intent: "success",
997
+ design: "outlined",
998
+ class: (0, import_internal_utils5.tw)([
999
+ "hover:bg-success/dim-5",
1000
+ "enabled:active:bg-success/dim-5",
1001
+ "focus-visible:bg-success/dim-5",
1002
+ "text-success"
1003
+ ])
1004
+ },
1005
+ {
1006
+ intent: "alert",
1007
+ design: "outlined",
1008
+ class: (0, import_internal_utils5.tw)([
1009
+ "hover:bg-alert/dim-5",
1010
+ "enabled:active:bg-alert/dim-5",
1011
+ "focus-visible:bg-alert/dim-5",
1012
+ "text-alert"
1013
+ ])
1014
+ },
1015
+ {
1016
+ intent: "danger",
1017
+ design: "outlined",
1018
+ class: (0, import_internal_utils5.tw)([
1019
+ "hover:bg-error/dim-5",
1020
+ "enabled:active:bg-error/dim-5",
1021
+ "focus-visible:bg-error/dim-5",
1022
+ "text-error"
1023
+ ])
1024
+ },
1025
+ {
1026
+ intent: "info",
1027
+ design: "outlined",
1028
+ class: (0, import_internal_utils5.tw)([
1029
+ "hover:bg-info/dim-5",
1030
+ "enabled:active:bg-info/dim-5",
1031
+ "focus-visible:bg-info/dim-5",
1032
+ "text-info"
1033
+ ])
1034
+ },
1035
+ {
1036
+ intent: "neutral",
1037
+ design: "outlined",
1038
+ class: (0, import_internal_utils5.tw)([
1039
+ "hover:bg-neutral/dim-5",
1040
+ "enabled:active:bg-neutral/dim-5",
1041
+ "focus-visible:bg-neutral/dim-5",
1042
+ "text-neutral"
1043
+ ])
1044
+ },
1045
+ {
1046
+ intent: "surface",
1047
+ design: "outlined",
1048
+ class: (0, import_internal_utils5.tw)([
1049
+ "hover:bg-surface/dim-5",
1050
+ "enabled:active:bg-surface/dim-5",
1051
+ "focus-visible:bg-surface/dim-5",
1052
+ "text-surface"
1053
+ ])
1054
+ }
1055
+ ];
1056
+
1057
+ // src/button/variants/tinted.ts
1058
+ var import_internal_utils6 = require("@spark-ui/internal-utils");
1059
+ var tintedVariants = [
1060
+ {
1061
+ intent: "main",
1062
+ design: "tinted",
1063
+ class: (0, import_internal_utils6.tw)([
1064
+ "bg-main-container",
1065
+ "text-on-main-container",
1066
+ "hover:bg-main-container-hovered",
1067
+ "enabled:active:bg-main-container-hovered",
1068
+ "focus-visible:bg-main-container-hovered"
1069
+ ])
1070
+ },
1071
+ {
1072
+ intent: "support",
1073
+ design: "tinted",
1074
+ class: (0, import_internal_utils6.tw)([
1075
+ "bg-support-container",
1076
+ "text-on-support-container",
1077
+ "hover:bg-support-container-hovered",
1078
+ "enabled:active:bg-support-container-hovered",
1079
+ "focus-visible:bg-support-container-hovered"
1080
+ ])
1081
+ },
1082
+ {
1083
+ intent: "accent",
1084
+ design: "tinted",
1085
+ class: (0, import_internal_utils6.tw)([
1086
+ "bg-accent-container",
1087
+ "text-on-accent-container",
1088
+ "hover:bg-accent-container-hovered",
1089
+ "enabled:active:bg-accent-container-hovered",
1090
+ "focus-visible:bg-accent-container-hovered"
1091
+ ])
1092
+ },
1093
+ {
1094
+ intent: "basic",
1095
+ design: "tinted",
1096
+ class: (0, import_internal_utils6.tw)([
1097
+ "bg-basic-container",
1098
+ "text-on-basic-container",
1099
+ "hover:bg-basic-container-hovered",
1100
+ "enabled:active:bg-basic-container-hovered",
1101
+ "focus-visible:bg-basic-container-hovered"
1102
+ ])
1103
+ },
1104
+ {
1105
+ intent: "success",
1106
+ design: "tinted",
1107
+ class: (0, import_internal_utils6.tw)([
1108
+ "bg-success-container",
1109
+ "text-on-success-container",
1110
+ "hover:bg-success-container-hovered",
1111
+ "enabled:active:bg-success-container-hovered",
1112
+ "focus-visible:bg-success-container-hovered"
1113
+ ])
1114
+ },
1115
+ {
1116
+ intent: "alert",
1117
+ design: "tinted",
1118
+ class: (0, import_internal_utils6.tw)([
1119
+ "bg-alert-container",
1120
+ "text-on-alert-container",
1121
+ "hover:bg-alert-container-hovered",
1122
+ "enabled:active:bg-alert-container-hovered",
1123
+ "focus-visible:bg-alert-container-hovered"
1124
+ ])
1125
+ },
1126
+ {
1127
+ intent: "danger",
1128
+ design: "tinted",
1129
+ class: (0, import_internal_utils6.tw)([
1130
+ "bg-error-container",
1131
+ "text-on-error-container",
1132
+ "hover:bg-error-container-hovered",
1133
+ "enabled:active:bg-error-container-hovered",
1134
+ "focus-visible:bg-error-container-hovered"
1135
+ ])
1136
+ },
1137
+ {
1138
+ intent: "info",
1139
+ design: "tinted",
1140
+ class: (0, import_internal_utils6.tw)([
1141
+ "bg-info-container",
1142
+ "text-on-info-container",
1143
+ "hover:bg-info-container-hovered",
1144
+ "enabled:active:bg-info-container-hovered",
1145
+ "focus-visible:bg-info-container-hovered"
1146
+ ])
1147
+ },
1148
+ {
1149
+ intent: "neutral",
1150
+ design: "tinted",
1151
+ class: (0, import_internal_utils6.tw)([
1152
+ "bg-neutral-container",
1153
+ "text-on-neutral-container",
1154
+ "hover:bg-neutral-container-hovered",
1155
+ "enabled:active:bg-neutral-container-hovered",
1156
+ "focus-visible:bg-neutral-container-hovered"
1157
+ ])
1158
+ },
1159
+ {
1160
+ intent: "surface",
1161
+ design: "tinted",
1162
+ class: (0, import_internal_utils6.tw)([
1163
+ "bg-surface",
1164
+ "text-on-surface",
1165
+ "hover:bg-surface-hovered",
1166
+ "enabled:active:bg-surface-hovered",
1167
+ "focus-visible:bg-surface-hovered"
1168
+ ])
1169
+ }
1170
+ ];
1171
+
1172
+ // src/button/variants/contrast.ts
1173
+ var import_internal_utils7 = require("@spark-ui/internal-utils");
1174
+ var contrastVariants = [
1175
+ {
1176
+ intent: "main",
1177
+ design: "contrast",
1178
+ class: (0, import_internal_utils7.tw)([
1179
+ "text-main",
1180
+ "hover:bg-main-container-hovered",
1181
+ "enabled:active:bg-main-container-hovered",
1182
+ "focus-visible:bg-main-container-hovered"
1183
+ ])
1184
+ },
1185
+ {
1186
+ intent: "support",
1187
+ design: "contrast",
1188
+ class: (0, import_internal_utils7.tw)([
1189
+ "text-support",
1190
+ "hover:bg-support-container-hovered",
1191
+ "enabled:active:bg-support-container-hovered",
1192
+ "focus-visible:bg-support-container-hovered"
1193
+ ])
1194
+ },
1195
+ {
1196
+ intent: "accent",
1197
+ design: "contrast",
1198
+ class: (0, import_internal_utils7.tw)([
1199
+ "text-accent",
1200
+ "hover:bg-accent-container-hovered",
1201
+ "enabled:active:bg-accent-container-hovered",
1202
+ "focus-visible:bg-accent-container-hovered"
1203
+ ])
1204
+ },
1205
+ {
1206
+ intent: "basic",
1207
+ design: "contrast",
1208
+ class: (0, import_internal_utils7.tw)([
1209
+ "text-basic",
1210
+ "hover:bg-basic-container-hovered",
1211
+ "enabled:active:bg-basic-container-hovered",
1212
+ "focus-visible:bg-basic-container-hovered"
1213
+ ])
1214
+ },
1215
+ {
1216
+ intent: "success",
1217
+ design: "contrast",
1218
+ class: (0, import_internal_utils7.tw)([
1219
+ "text-success",
1220
+ "hover:bg-success-container-hovered",
1221
+ "enabled:active:bg-success-container-hovered",
1222
+ "focus-visible:bg-success-container-hovered"
1223
+ ])
1224
+ },
1225
+ {
1226
+ intent: "alert",
1227
+ design: "contrast",
1228
+ class: (0, import_internal_utils7.tw)([
1229
+ "text-alert",
1230
+ "hover:bg-alert-container-hovered",
1231
+ "enabled:active:bg-alert-container-hovered",
1232
+ "focus-visible:bg-alert-container-hovered"
1233
+ ])
1234
+ },
1235
+ {
1236
+ intent: "danger",
1237
+ design: "contrast",
1238
+ class: (0, import_internal_utils7.tw)([
1239
+ "text-error",
1240
+ "hover:bg-error-container-hovered",
1241
+ "enabled:active:bg-error-container-hovered",
1242
+ "focus-visible:bg-error-container-hovered"
1243
+ ])
1244
+ },
1245
+ {
1246
+ intent: "info",
1247
+ design: "contrast",
1248
+ class: (0, import_internal_utils7.tw)([
1249
+ "text-info",
1250
+ "hover:bg-info-container-hovered",
1251
+ "enabled:active:bg-info-container-hovered",
1252
+ "focus-visible:bg-info-container-hovered"
1253
+ ])
1254
+ },
1255
+ {
1256
+ intent: "neutral",
1257
+ design: "contrast",
1258
+ class: (0, import_internal_utils7.tw)([
1259
+ "text-neutral",
1260
+ "hover:bg-neutral-container-hovered",
1261
+ "enabled:active:bg-neutral-container-hovered",
1262
+ "focus-visible:bg-neutral-container-hovered"
1263
+ ])
1264
+ },
1265
+ {
1266
+ intent: "surface",
1267
+ design: "contrast",
1268
+ class: (0, import_internal_utils7.tw)([
1269
+ "text-on-surface",
1270
+ "hover:bg-surface-hovered",
1271
+ "enabled:active:bg-surface-hovered",
1272
+ "focus-visible:bg-surface-hovered"
1273
+ ])
1274
+ }
1275
+ ];
1276
+
1277
+ // src/button/Button.styles.tsx
1278
+ var buttonStyles = (0, import_class_variance_authority13.cva)(
1279
+ [
1280
+ "u-shadow-border-transition",
1281
+ "box-border inline-flex items-center justify-center gap-md whitespace-nowrap",
1282
+ "px-lg",
1283
+ "text-body-1 font-bold",
1284
+ "focus-visible:u-outline"
1285
+ ],
1286
+ {
1287
+ variants: {
1288
+ /**
1289
+ * Main style of the button.
1290
+ *
1291
+ * - `filled`: Button will be plain.
1292
+ *
1293
+ * - `outlined`: Button will be transparent with an outline.
1294
+ *
1295
+ * - `tinted`: Button will be filled but using a lighter color scheme.
1296
+ *
1297
+ * - `ghost`: Button will look like a link. No borders, plain text.
1298
+ *
1299
+ * - `contrast`: Button will be surface filled. No borders, plain text.
1300
+ *
1301
+ */
1302
+ design: (0, import_internal_utils8.makeVariants)({
1303
+ filled: [],
1304
+ outlined: ["bg-transparent", "border-sm", "border-current"],
1305
+ tinted: [],
1306
+ ghost: [],
1307
+ contrast: ["bg-surface"]
1308
+ }),
1309
+ /**
1310
+ * Color scheme of the button.
1311
+ */
1312
+ intent: (0, import_internal_utils8.makeVariants)({
1313
+ main: [],
1314
+ support: [],
1315
+ accent: [],
1316
+ basic: [],
1317
+ success: [],
1318
+ alert: [],
1319
+ danger: [],
1320
+ info: [],
1321
+ neutral: [],
1322
+ surface: []
1323
+ }),
1324
+ /**
1325
+ * Size of the button.
1326
+ */
1327
+ size: (0, import_internal_utils8.makeVariants)({
1328
+ sm: ["min-w-sz-32", "h-sz-32"],
1329
+ md: ["min-w-sz-44", "h-sz-44"],
1330
+ lg: ["min-w-sz-56", "h-sz-56"]
1331
+ }),
1332
+ /**
1333
+ * Shape of the button.
1334
+ */
1335
+ shape: (0, import_internal_utils8.makeVariants)({
1336
+ rounded: ["rounded-lg"],
1337
+ square: ["rounded-0"],
1338
+ pill: ["rounded-full"]
1339
+ }),
1340
+ /**
1341
+ * Disable the button, preventing user interaction and adding opacity.
1342
+ */
1343
+ disabled: {
1344
+ true: ["cursor-not-allowed", "opacity-dim-3"],
1345
+ false: ["cursor-pointer"]
1346
+ }
1347
+ },
1348
+ compoundVariants: [
1349
+ ...filledVariants,
1350
+ ...outlinedVariants,
1351
+ ...tintedVariants,
1352
+ ...ghostVariants,
1353
+ ...contrastVariants
1354
+ ],
1355
+ defaultVariants: {
1356
+ design: "filled",
1357
+ intent: "main",
1358
+ size: "md",
1359
+ shape: "rounded"
1360
+ }
1361
+ }
1362
+ );
1363
+
1364
+ // src/button/Button.tsx
1365
+ var import_jsx_runtime23 = require("react/jsx-runtime");
1366
+ var blockedEventHandlers = [
1367
+ "onClick",
1368
+ "onMouseDown",
1369
+ "onMouseUp",
1370
+ "onMouseEnter",
1371
+ "onMouseLeave",
1372
+ "onMouseOver",
1373
+ "onMouseOut",
1374
+ "onKeyDown",
1375
+ "onKeyPress",
1376
+ "onKeyUp",
1377
+ "onSubmit"
1378
+ ];
1379
+ var Button = ({
1380
+ children,
1381
+ design = "filled",
1382
+ disabled = false,
1383
+ intent = "main",
1384
+ isLoading = false,
1385
+ loadingLabel,
1386
+ loadingText,
1387
+ shape = "rounded",
1388
+ size = "md",
1389
+ asChild,
1390
+ className,
1391
+ ref,
1392
+ ...others
1393
+ }) => {
1394
+ const Component = asChild ? Slot : "button";
1395
+ const shouldNotInteract = !!disabled || isLoading;
1396
+ const disabledEventHandlers = (0, import_react9.useMemo)(() => {
1397
+ const result = {};
1398
+ if (shouldNotInteract) {
1399
+ blockedEventHandlers.forEach((eventHandler) => result[eventHandler] = void 0);
1400
+ }
1401
+ return result;
1402
+ }, [shouldNotInteract]);
1403
+ const spinnerProps = {
1404
+ size: "current",
1405
+ className: loadingText ? "inline-block" : "absolute",
1406
+ ...loadingLabel && { "aria-label": loadingLabel }
1407
+ };
1408
+ return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1409
+ Component,
1410
+ {
1411
+ "data-spark-component": "button",
1412
+ ...Component === "button" && { type: "button" },
1413
+ ref,
1414
+ className: buttonStyles({
1415
+ className,
1416
+ design,
1417
+ disabled: shouldNotInteract,
1418
+ intent,
1419
+ shape,
1420
+ size
1421
+ }),
1422
+ disabled: !!disabled,
1423
+ "aria-busy": isLoading,
1424
+ "aria-live": isLoading ? "assertive" : "off",
1425
+ ...others,
1426
+ ...disabledEventHandlers,
1427
+ children: wrapPolymorphicSlot(
1428
+ asChild,
1429
+ children,
1430
+ (slotted) => isLoading ? /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(import_jsx_runtime23.Fragment, { children: [
1431
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Spinner, { ...spinnerProps }),
1432
+ loadingText && loadingText,
1433
+ /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
1434
+ "div",
1435
+ {
1436
+ "aria-hidden": true,
1437
+ className: (0, import_class_variance_authority14.cx)("gap-md", loadingText ? "hidden" : "inline-flex opacity-0"),
1438
+ children: slotted
1439
+ }
1440
+ )
1441
+ ] }) : slotted
1442
+ )
1443
+ }
1444
+ );
1445
+ };
1446
+ Button.displayName = "Button";
1447
+
1448
+ // src/icon-button/IconButton.styles.tsx
1449
+ var import_internal_utils9 = require("@spark-ui/internal-utils");
1450
+ var import_class_variance_authority15 = require("class-variance-authority");
1451
+ var iconButtonStyles = (0, import_class_variance_authority15.cva)(["pl-0 pr-0"], {
1452
+ variants: {
1453
+ /**
1454
+ * Sets the size of the icon.
1455
+ */
1456
+ size: (0, import_internal_utils9.makeVariants)({
1457
+ sm: ["text-body-1"],
1458
+ md: ["text-body-1"],
1459
+ lg: ["text-display-3"]
1460
+ })
1461
+ }
1462
+ });
1463
+
1464
+ // src/icon-button/IconButton.tsx
1465
+ var import_jsx_runtime24 = require("react/jsx-runtime");
1466
+ var IconButton = ({
1467
+ design = "filled",
1468
+ disabled = false,
1469
+ intent = "main",
1470
+ shape = "rounded",
1471
+ size = "md",
1472
+ className,
1473
+ ref,
1474
+ ...others
1475
+ }) => {
1476
+ return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1477
+ Button,
1478
+ {
1479
+ ref,
1480
+ className: iconButtonStyles({ size, className }),
1481
+ design,
1482
+ disabled,
1483
+ intent,
1484
+ shape,
1485
+ size,
1486
+ ...others
1487
+ }
1488
+ );
1489
+ };
1490
+ IconButton.displayName = "IconButton";
1491
+
1492
+ // src/popover/PopoverCloseButton.tsx
1493
+ var import_jsx_runtime25 = require("react/jsx-runtime");
1494
+ var CloseButton = ({
1495
+ "aria-label": ariaLabel,
1496
+ className,
1497
+ ref,
1498
+ ...rest
1499
+ }) => {
1500
+ return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
1501
+ import_radix_ui6.Popover.Close,
1502
+ {
1503
+ "data-spark-component": "popover-close-button",
1504
+ ref,
1505
+ className: (0, import_class_variance_authority16.cx)("right-md top-md absolute", className),
1506
+ asChild: true,
1507
+ ...rest,
1508
+ children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(IconButton, { size: "sm", intent: "neutral", design: "ghost", "aria-label": ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(import_Close.Close, {}) }) })
1509
+ }
1510
+ );
1511
+ };
1512
+ CloseButton.displayName = "Popover.CloseButton";
1513
+
1514
+ // src/popover/PopoverContent.tsx
1515
+ var import_radix_ui7 = require("radix-ui");
1516
+
1517
+ // src/popover/PopoverContent.styles.ts
1518
+ var import_class_variance_authority17 = require("class-variance-authority");
1519
+ var styles = (0, import_class_variance_authority17.cva)(
1520
+ [
1521
+ "rounded-md",
1522
+ "shadow-sm",
1523
+ "focus-visible:outline-hidden focus-visible:u-outline",
1524
+ "max-h-(--radix-popper-available-height) overflow-y-auto"
1525
+ ],
1526
+ {
1527
+ variants: {
1528
+ intent: {
1529
+ surface: "bg-surface text-on-surface",
1530
+ main: "bg-main-container text-on-main-container",
1531
+ support: "bg-support-container text-on-support-container",
1532
+ accent: "bg-accent-container text-on-accent-container",
1533
+ basic: "bg-basic-container text-on-basic-container",
1534
+ success: "bg-success-container text-on-success-container",
1535
+ alert: "bg-alert-container text-on-alert-container",
1536
+ danger: "bg-error-container text-on-error-container",
1537
+ info: "bg-info-container text-on-info-container",
1538
+ neutral: "bg-neutral-container text-on-neutral-container"
1539
+ },
1540
+ matchTriggerWidth: {
1541
+ true: "w-(--radix-popper-anchor-width)"
1542
+ },
1543
+ enforceBoundaries: {
1544
+ true: ["max-w-(--radix-popper-available-width)"]
1545
+ },
1546
+ inset: {
1547
+ true: "overflow-hidden",
1548
+ false: "p-lg"
1549
+ },
1550
+ elevation: {
1551
+ dropdown: "z-dropdown",
1552
+ popover: "z-popover"
1553
+ }
1554
+ },
1555
+ compoundVariants: [
1556
+ {
1557
+ inset: false,
1558
+ /**
1559
+ * When there is a close button, padding to the right side must be adjusted to avoid content overlapping with it.
1560
+ */
1561
+ class: "has-data-[spark-component=popover-close-button]:pr-3xl"
1562
+ },
1563
+ {
1564
+ enforceBoundaries: false,
1565
+ matchTriggerWidth: false,
1566
+ class: "max-w-[min(var(--spacing-sz-384),100vw)]"
1567
+ }
1568
+ ],
1569
+ defaultVariants: {
1570
+ matchTriggerWidth: false,
1571
+ enforceBoundaries: false,
1572
+ inset: false,
1573
+ intent: "surface",
1574
+ elevation: "popover"
1575
+ }
1576
+ }
1577
+ );
1578
+
1579
+ // src/popover/PopoverContent.tsx
1580
+ var import_jsx_runtime26 = require("react/jsx-runtime");
1581
+ var Content = ({
1582
+ // Spark props
1583
+ className,
1584
+ children,
1585
+ matchTriggerWidth = false,
1586
+ // Radix props
1587
+ align = "center",
1588
+ arrowPadding = 16,
1589
+ // In order not to overlap the arrow on the rounded corners of the popover.
1590
+ asChild = false,
1591
+ avoidCollisions = true,
1592
+ "aria-labelledby": ariaLabelledBy,
1593
+ collisionBoundary,
1594
+ collisionPadding = 0,
1595
+ hideWhenDetached = false,
1596
+ side = "bottom",
1597
+ sideOffset = 8,
1598
+ sticky = "partial",
1599
+ inset = false,
1600
+ elevation = "popover",
1601
+ ref,
1602
+ ...rest
1603
+ }) => {
1604
+ const { headerId, intent } = usePopover();
1605
+ return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
1606
+ import_radix_ui7.Popover.Content,
1607
+ {
1608
+ "aria-labelledby": headerId || ariaLabelledBy,
1609
+ className: styles({
1610
+ enforceBoundaries: !!collisionBoundary,
1611
+ matchTriggerWidth,
1612
+ inset,
1613
+ elevation,
1614
+ intent,
1615
+ className
1616
+ }),
1617
+ "data-spark-component": "popover-content",
1618
+ ref,
1619
+ ...{
1620
+ align,
1621
+ arrowPadding,
1622
+ asChild,
1623
+ avoidCollisions,
1624
+ collisionBoundary,
1625
+ collisionPadding,
1626
+ hideWhenDetached,
1627
+ side,
1628
+ sideOffset,
1629
+ sticky
1630
+ },
1631
+ ...rest,
1632
+ children
1633
+ }
1634
+ );
1635
+ };
1636
+ Content.displayName = "Popover.Content";
1637
+
1638
+ // src/popover/PopoverHeader.tsx
1639
+ var import_class_variance_authority18 = require("class-variance-authority");
1640
+ var import_react10 = require("react");
1641
+ var import_jsx_runtime27 = require("react/jsx-runtime");
1642
+ var Header = ({ children, className, ref, ...rest }) => {
1643
+ const id = `${ID_PREFIX2}-header-${(0, import_react10.useId)()}`;
1644
+ const { setHeaderId } = usePopover();
1645
+ (0, import_react10.useLayoutEffect)(() => {
1646
+ setHeaderId(id);
1647
+ return () => setHeaderId(null);
1648
+ }, [id, setHeaderId]);
1649
+ return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("header", { id, ref, className: (0, import_class_variance_authority18.cx)("mb-md text-headline-2", className), ...rest, children });
1650
+ };
1651
+ Header.displayName = "Popover.Header";
1652
+
1653
+ // src/popover/PopoverPortal.tsx
1654
+ var import_radix_ui8 = require("radix-ui");
1655
+ var import_jsx_runtime28 = require("react/jsx-runtime");
1656
+ var Portal = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(import_radix_ui8.Popover.Portal, { ...rest, children });
1657
+ Portal.displayName = "Popover.Portal";
1658
+
1659
+ // src/popover/PopoverTrigger.tsx
1660
+ var import_radix_ui9 = require("radix-ui");
1661
+ var import_jsx_runtime29 = require("react/jsx-runtime");
1662
+ var Trigger = ({ asChild = false, children, ref, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
1663
+ import_radix_ui9.Popover.Trigger,
1664
+ {
1665
+ "data-spark-component": "popover-trigger",
1666
+ ref,
1667
+ asChild,
1668
+ ...rest,
1669
+ children
1670
+ }
1671
+ );
1672
+ Trigger.displayName = "Popover.Trigger";
1673
+
1674
+ // src/popover/index.ts
1675
+ var Popover2 = Object.assign(Popover, {
1676
+ Anchor,
1677
+ Arrow,
1678
+ CloseButton,
1679
+ Content,
1680
+ Header,
1681
+ Portal,
1682
+ Trigger
1683
+ });
1684
+ Popover2.displayName = "Popover";
1685
+ Anchor.displayName = "Popover.Anchor";
1686
+ Arrow.displayName = "Popover.Arrow";
1687
+ CloseButton.displayName = "Popover.CloseButton";
1688
+ Content.displayName = "Popover.Content";
1689
+ Header.displayName = "Popover.Header";
1690
+ Portal.displayName = "Popover.Portal";
1691
+ Trigger.displayName = "Popover.Trigger";
1692
+
1693
+ // src/dropdown/useDropdown.ts
1694
+ var import_downshift = require("downshift");
1695
+ var useDropdown = ({
1696
+ itemsMap,
1697
+ defaultValue,
1698
+ value,
1699
+ onValueChange,
1700
+ open,
1701
+ onOpenChange,
1702
+ defaultOpen,
1703
+ multiple,
1704
+ id,
1705
+ labelId
1706
+ }) => {
1707
+ const items = [...itemsMap.values()];
1708
+ const downshiftMultipleSelection = (0, import_downshift.useMultipleSelection)({
1709
+ selectedItems: value != null && multiple ? items.filter(
1710
+ (item) => multiple ? value.includes(item.value) : value === item.value
1711
+ ) : void 0,
1712
+ initialSelectedItems: defaultValue != null && multiple ? items.filter(
1713
+ (item) => multiple ? defaultValue.includes(item.value) : defaultValue === item.value
1714
+ ) : void 0,
1715
+ onSelectedItemsChange: ({ selectedItems }) => {
1716
+ if (selectedItems != null && multiple) {
1717
+ onValueChange?.(selectedItems.map((item) => item.value));
1718
+ }
1719
+ }
1720
+ });
1721
+ const stateReducer = (state, { changes, type }) => {
1722
+ if (!multiple) return changes;
1723
+ const { selectedItems, removeSelectedItem, addSelectedItem } = downshiftMultipleSelection;
1724
+ switch (type) {
1725
+ case import_downshift.useSelect.stateChangeTypes.ToggleButtonKeyDownEnter:
1726
+ case import_downshift.useSelect.stateChangeTypes.ToggleButtonKeyDownSpaceButton:
1727
+ case import_downshift.useSelect.stateChangeTypes.ItemClick:
1728
+ if (changes.selectedItem != null) {
1729
+ const isAlreadySelected = selectedItems.some(
1730
+ (selectedItem) => selectedItem.value === changes.selectedItem?.value
1731
+ );
1732
+ if (isAlreadySelected) removeSelectedItem(changes.selectedItem);
1733
+ else addSelectedItem(changes.selectedItem);
1734
+ }
1735
+ return {
1736
+ ...changes,
1737
+ isOpen: true,
1738
+ // keep the menu open after selection.
1739
+ highlightedIndex: state.highlightedIndex
1740
+ // preserve highlighted index position
1741
+ };
1742
+ default:
1743
+ return changes;
1744
+ }
1745
+ };
1746
+ const downshift = (0, import_downshift.useSelect)({
1747
+ items,
1748
+ isItemDisabled: (item) => item.disabled,
1749
+ itemToString: (item) => item ? item.text : "",
1750
+ // a11y attributes
1751
+ id,
1752
+ labelId,
1753
+ // Controlled open state
1754
+ isOpen: open,
1755
+ // undefined must be passed for stateful behaviour (uncontrolled)
1756
+ onIsOpenChange: ({ isOpen }) => {
1757
+ if (isOpen != null) onOpenChange?.(isOpen);
1758
+ },
1759
+ initialIsOpen: defaultOpen ?? false,
1760
+ stateReducer,
1761
+ // Controlled mode (single selection)
1762
+ selectedItem: value != null && !multiple ? itemsMap.get(value) || null : void 0,
1763
+ initialSelectedItem: (defaultValue != null || value != null) && !multiple ? itemsMap.get(defaultValue) || null : void 0,
1764
+ onSelectedItemChange: ({ selectedItem }) => {
1765
+ if (selectedItem?.value != null && !multiple) {
1766
+ onValueChange?.(selectedItem?.value);
1767
+ }
1768
+ },
1769
+ /**
1770
+ * 1. Downshift default behaviour is to scroll into view the highlighted item when the dropdown opens. This behaviour is not stable and scrolls the dropdown to the bottom of the screen.
1771
+ */
1772
+ scrollIntoView: (node) => {
1773
+ if (node) {
1774
+ node.scrollIntoView({ block: "nearest" });
1775
+ }
1776
+ return void 0;
1777
+ }
1778
+ });
1779
+ return {
1780
+ ...downshift,
1781
+ ...downshiftMultipleSelection,
1782
+ /** There is a Downshift bug in React 19, it duplicates some selectedItems */
1783
+ selectedItems: [...new Set(downshiftMultipleSelection.selectedItems)]
1784
+ };
1785
+ };
1786
+
1787
+ // src/dropdown/utils.ts
1788
+ var import_react11 = require("react");
1789
+ function getIndexByKey(map, targetKey) {
1790
+ let index = 0;
1791
+ for (const [key] of map.entries()) {
1792
+ if (key === targetKey) {
1793
+ return index;
1794
+ }
1795
+ index++;
1796
+ }
1797
+ return -1;
1798
+ }
1799
+ var getKeyAtIndex = (map, index) => {
1800
+ let i = 0;
1801
+ for (const key of map.keys()) {
1802
+ if (i === index) return key;
1803
+ i++;
1804
+ }
1805
+ return void 0;
1806
+ };
1807
+ var getElementByIndex = (map, index) => {
1808
+ const key = getKeyAtIndex(map, index);
1809
+ return key !== void 0 ? map.get(key) : void 0;
1810
+ };
1811
+ var getElementDisplayName = (element) => {
1812
+ return element ? element.type.displayName : "";
1813
+ };
1814
+ var getOrderedItems = (children, result = []) => {
1815
+ import_react11.Children.forEach(children, (child) => {
1816
+ if (!(0, import_react11.isValidElement)(child)) return;
1817
+ if (getElementDisplayName(child) === "Dropdown.Item") {
1818
+ const childProps = child.props;
1819
+ result.push({
1820
+ value: childProps.value,
1821
+ disabled: !!childProps.disabled,
1822
+ text: getItemText(childProps.children)
1823
+ });
1824
+ }
1825
+ if (child.props.children) {
1826
+ getOrderedItems(child.props.children, result);
1827
+ }
1828
+ });
1829
+ return result;
1830
+ };
1831
+ var getItemText = (children, itemText = "") => {
1832
+ if (typeof children === "string") {
1833
+ return children;
1834
+ }
1835
+ import_react11.Children.forEach(children, (child) => {
1836
+ if (!(0, import_react11.isValidElement)(child)) return;
1837
+ if (getElementDisplayName(child) === "Dropdown.ItemText") {
1838
+ itemText = child.props.children;
1839
+ }
1840
+ if (child.props.children) {
1841
+ getItemText(child.props.children, itemText);
1842
+ }
1843
+ });
1844
+ return itemText;
1845
+ };
1846
+ var getItemsFromChildren = (children) => {
1847
+ const newMap = /* @__PURE__ */ new Map();
1848
+ getOrderedItems(children).forEach((itemData) => {
1849
+ newMap.set(itemData.value, itemData);
1850
+ });
1851
+ return newMap;
1852
+ };
1853
+ var hasChildComponent = (children, displayName) => {
1854
+ return import_react11.Children.toArray(children).some((child) => {
1855
+ if (!(0, import_react11.isValidElement)(child)) return false;
1856
+ if (getElementDisplayName(child) === displayName) {
1857
+ return true;
1858
+ } else if (child.props.children) {
1859
+ return hasChildComponent(child.props.children, displayName);
1860
+ }
1861
+ return false;
1862
+ });
1863
+ };
1864
+
1865
+ // src/dropdown/DropdownContext.tsx
1866
+ var import_jsx_runtime30 = require("react/jsx-runtime");
1867
+ var DropdownContext = (0, import_react12.createContext)(null);
1868
+ var ID_PREFIX3 = ":dropdown";
1869
+ var DropdownProvider = ({
1870
+ children,
1871
+ defaultValue,
1872
+ value,
1873
+ onValueChange,
1874
+ open,
1875
+ onOpenChange,
1876
+ defaultOpen,
1877
+ multiple = false,
1878
+ disabled: disabledProp = false,
1879
+ readOnly: readOnlyProp = false,
1880
+ state: stateProp
1881
+ }) => {
1882
+ const [itemsMap, setItemsMap] = (0, import_react12.useState)(getItemsFromChildren(children));
1883
+ const [hasPopover, setHasPopover] = (0, import_react12.useState)(
1884
+ hasChildComponent(children, "Dropdown.Popover")
1885
+ );
1886
+ const [lastInteractionType, setLastInteractionType] = (0, import_react12.useState)("mouse");
1887
+ const field = useFormFieldControl();
1888
+ const state = field.state || stateProp;
1889
+ const internalFieldLabelID = `${ID_PREFIX3}-label-${(0, import_react12.useId)()}`;
1890
+ const internalFieldID = `${ID_PREFIX3}-input-${(0, import_react12.useId)()}`;
1891
+ const id = field.id || internalFieldID;
1892
+ const labelId = field.labelId || internalFieldLabelID;
1893
+ const disabled = field.disabled ?? disabledProp;
1894
+ const readOnly = field.readOnly ?? readOnlyProp;
1895
+ const dropdownState = useDropdown({
1896
+ itemsMap,
1897
+ defaultValue,
1898
+ value,
1899
+ onValueChange,
1900
+ open,
1901
+ onOpenChange,
1902
+ defaultOpen,
1903
+ multiple,
1904
+ id,
1905
+ labelId
1906
+ });
1907
+ (0, import_react12.useEffect)(() => {
1908
+ const newMap = getItemsFromChildren(children);
1909
+ const previousItems = [...itemsMap.values()];
1910
+ const newItems = [...newMap.values()];
1911
+ const hasItemsChanges = previousItems.length !== newItems.length || previousItems.some((item, index) => {
1912
+ const hasUpdatedValue = item.value !== newItems[index]?.value;
1913
+ const hasUpdatedText = item.text !== newItems[index]?.text;
1914
+ return hasUpdatedValue || hasUpdatedText;
1915
+ });
1916
+ if (hasItemsChanges) {
1917
+ setItemsMap(newMap);
1918
+ }
1919
+ }, [children]);
1920
+ const [WrapperComponent, wrapperProps] = hasPopover ? [Popover2, { open: true }] : [import_react12.Fragment, {}];
1921
+ return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
1922
+ DropdownContext.Provider,
1923
+ {
1924
+ value: {
1925
+ multiple,
1926
+ disabled,
1927
+ readOnly,
1928
+ ...dropdownState,
1929
+ itemsMap,
1930
+ highlightedItem: getElementByIndex(itemsMap, dropdownState.highlightedIndex),
1931
+ hasPopover,
1932
+ setHasPopover,
1933
+ state,
1934
+ lastInteractionType,
1935
+ setLastInteractionType
1936
+ },
1937
+ children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(WrapperComponent, { ...wrapperProps, children })
1938
+ }
1939
+ );
1940
+ };
1941
+ var useDropdownContext = () => {
1942
+ const context = (0, import_react12.useContext)(DropdownContext);
1943
+ if (!context) {
1944
+ throw Error("useDropdownContext must be used within a Dropdown provider");
1945
+ }
1946
+ return context;
1947
+ };
1948
+
1949
+ // src/dropdown/Dropdown.tsx
1950
+ var import_jsx_runtime31 = require("react/jsx-runtime");
1951
+ var Dropdown = ({ children, ...props }) => {
1952
+ return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(DropdownProvider, { ...props, children });
1953
+ };
1954
+ Dropdown.displayName = "Dropdown";
1955
+
1956
+ // src/dropdown/DropdownDivider.tsx
1957
+ var import_class_variance_authority19 = require("class-variance-authority");
1958
+ var import_jsx_runtime32 = require("react/jsx-runtime");
1959
+ var Divider = ({ className, ref: forwardedRef }) => {
1960
+ return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("div", { ref: forwardedRef, className: (0, import_class_variance_authority19.cx)("my-md border-b-sm border-outline", className) });
1961
+ };
1962
+ Divider.displayName = "Dropdown.Divider";
1963
+
1964
+ // src/dropdown/DropdownGroup.tsx
1965
+ var import_class_variance_authority20 = require("class-variance-authority");
1966
+
1967
+ // src/dropdown/DropdownItemsGroupContext.tsx
1968
+ var import_react13 = require("react");
1969
+ var import_jsx_runtime33 = require("react/jsx-runtime");
1970
+ var DropdownGroupContext = (0, import_react13.createContext)(null);
1971
+ var DropdownGroupProvider = ({ children }) => {
1972
+ const labelId = `${ID_PREFIX3}-group-label-${(0, import_react13.useId)()}`;
1973
+ return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(DropdownGroupContext.Provider, { value: { labelId }, children });
1974
+ };
1975
+ var useDropdownGroupContext = () => {
1976
+ const context = (0, import_react13.useContext)(DropdownGroupContext);
1977
+ if (!context) {
1978
+ throw Error("useDropdownGroupContext must be used within a DropdownGroup provider");
1979
+ }
1980
+ return context;
1981
+ };
1982
+
1983
+ // src/dropdown/DropdownGroup.tsx
1984
+ var import_jsx_runtime34 = require("react/jsx-runtime");
1985
+ var Group = ({ children, ref: forwardedRef, ...props }) => {
1986
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(DropdownGroupProvider, { children: /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(GroupContent, { ref: forwardedRef, ...props, children }) });
1987
+ };
1988
+ var GroupContent = ({ children, className, ref: forwardedRef }) => {
1989
+ const { labelId } = useDropdownGroupContext();
1990
+ return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)("div", { ref: forwardedRef, role: "group", "aria-labelledby": labelId, className: (0, import_class_variance_authority20.cx)(className), children });
1991
+ };
1992
+ Group.displayName = "Dropdown.Group";
1993
+
1994
+ // src/dropdown/DropdownItem.tsx
1995
+ var import_use_merge_refs = require("@spark-ui/use-merge-refs");
1996
+ var import_class_variance_authority21 = require("class-variance-authority");
1997
+
1998
+ // src/dropdown/DropdownItemContext.tsx
1999
+ var import_react14 = require("react");
2000
+ var import_jsx_runtime35 = require("react/jsx-runtime");
2001
+ var DropdownItemContext = (0, import_react14.createContext)(null);
2002
+ var DropdownItemProvider = ({
2003
+ value,
2004
+ disabled = false,
2005
+ children
2006
+ }) => {
2007
+ const { multiple, itemsMap, selectedItem, selectedItems } = useDropdownContext();
2008
+ const [textId, setTextId] = (0, import_react14.useState)(void 0);
2009
+ const index = getIndexByKey(itemsMap, value);
2010
+ const itemData = { disabled, value, text: getItemText(children) };
2011
+ const isSelected = multiple ? selectedItems.some((selectedItem2) => selectedItem2.value === value) : selectedItem?.value === value;
2012
+ return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
2013
+ DropdownItemContext.Provider,
2014
+ {
2015
+ value: { textId, setTextId, isSelected, itemData, index, disabled },
2016
+ children
2017
+ }
2018
+ );
2019
+ };
2020
+ var useDropdownItemContext = () => {
2021
+ const context = (0, import_react14.useContext)(DropdownItemContext);
2022
+ if (!context) {
2023
+ throw Error("useDropdownItemContext must be used within a DropdownItem provider");
2024
+ }
2025
+ return context;
2026
+ };
2027
+
2028
+ // src/dropdown/DropdownItem.tsx
2029
+ var import_jsx_runtime36 = require("react/jsx-runtime");
2030
+ var Item = ({ children, ref: forwardedRef, ...props }) => {
2031
+ const { value, disabled } = props;
2032
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(DropdownItemProvider, { value, disabled, children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(ItemContent, { ref: forwardedRef, ...props, children }) });
2033
+ };
2034
+ var styles2 = (0, import_class_variance_authority21.cva)("px-lg py-md text-body-1", {
2035
+ variants: {
2036
+ selected: {
2037
+ true: "font-bold"
2038
+ },
2039
+ disabled: {
2040
+ true: "opacity-dim-3 cursor-not-allowed",
2041
+ false: "cursor-pointer"
2042
+ },
2043
+ highlighted: {
2044
+ true: ""
2045
+ },
2046
+ interactionType: {
2047
+ mouse: "",
2048
+ keyboard: ""
2049
+ }
2050
+ },
2051
+ compoundVariants: [
2052
+ {
2053
+ highlighted: true,
2054
+ interactionType: "mouse",
2055
+ class: "bg-surface-hovered"
2056
+ },
2057
+ {
2058
+ highlighted: true,
2059
+ interactionType: "keyboard",
2060
+ class: "u-outline"
2061
+ }
2062
+ ]
2063
+ });
2064
+ var ItemContent = ({
2065
+ className,
2066
+ disabled = false,
2067
+ value,
2068
+ children,
2069
+ ref: forwardedRef
2070
+ }) => {
2071
+ const { getItemProps, highlightedItem, lastInteractionType } = useDropdownContext();
2072
+ const { textId, index, itemData, isSelected } = useDropdownItemContext();
2073
+ const isHighlighted = highlightedItem?.value === value;
2074
+ const { ref: downshiftRef, ...downshiftItemProps } = getItemProps({ item: itemData, index });
2075
+ const ref = (0, import_use_merge_refs.useMergeRefs)(forwardedRef, downshiftRef);
2076
+ return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
2077
+ "li",
2078
+ {
2079
+ ref,
2080
+ className: (0, import_class_variance_authority21.cx)(
2081
+ styles2({
2082
+ selected: isSelected,
2083
+ disabled,
2084
+ highlighted: isHighlighted,
2085
+ interactionType: lastInteractionType,
2086
+ className
2087
+ })
2088
+ ),
2089
+ ...downshiftItemProps,
2090
+ "aria-selected": isSelected,
2091
+ "aria-labelledby": textId,
2092
+ children
2093
+ },
2094
+ value
2095
+ );
2096
+ };
2097
+ Item.displayName = "Dropdown.Item";
2098
+
2099
+ // src/dropdown/DropdownItemIndicator.tsx
2100
+ var import_Check2 = require("@spark-ui/icons/Check");
2101
+ var import_class_variance_authority22 = require("class-variance-authority");
2102
+ var import_jsx_runtime37 = require("react/jsx-runtime");
2103
+ var ItemIndicator = ({
2104
+ className,
2105
+ children,
2106
+ label,
2107
+ ref: forwardedRef
2108
+ }) => {
2109
+ const { disabled, isSelected } = useDropdownItemContext();
2110
+ const childElement = children || /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(import_Check2.Check, { "aria-label": label }) });
2111
+ return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
2112
+ "span",
2113
+ {
2114
+ ref: forwardedRef,
2115
+ className: (0, import_class_variance_authority22.cx)("min-h-sz-16 min-w-sz-16 flex", disabled && "opacity-dim-3", className),
2116
+ children: isSelected && childElement
2117
+ }
2118
+ );
2119
+ };
2120
+ ItemIndicator.displayName = "Dropdown.ItemIndicator";
2121
+
2122
+ // src/dropdown/DropdownItems.tsx
2123
+ var import_use_merge_refs2 = require("@spark-ui/use-merge-refs");
2124
+ var import_class_variance_authority23 = require("class-variance-authority");
2125
+ var import_react15 = require("react");
2126
+ var import_jsx_runtime38 = require("react/jsx-runtime");
2127
+ var Items = ({ children, className, ref: forwardedRef, ...props }) => {
2128
+ const { isOpen, getMenuProps, hasPopover, setLastInteractionType } = useDropdownContext();
2129
+ const { ref: downshiftRef, ...downshiftMenuProps } = getMenuProps({
2130
+ onMouseMove: () => {
2131
+ setLastInteractionType("mouse");
2132
+ }
2133
+ });
2134
+ const innerRef = (0, import_react15.useRef)(null);
2135
+ const ref = (0, import_use_merge_refs2.useMergeRefs)(forwardedRef, downshiftRef, innerRef);
2136
+ (0, import_react15.useLayoutEffect)(() => {
2137
+ if (!hasPopover) return;
2138
+ if (!innerRef.current) return;
2139
+ if (innerRef.current.parentElement) {
2140
+ innerRef.current.parentElement.style.pointerEvents = isOpen ? "" : "none";
2141
+ innerRef.current.style.pointerEvents = isOpen ? "" : "none";
2142
+ }
2143
+ }, [isOpen, hasPopover]);
2144
+ return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
2145
+ "ul",
2146
+ {
2147
+ ref,
2148
+ className: (0, import_class_variance_authority23.cx)(
2149
+ className,
2150
+ "flex flex-col",
2151
+ isOpen ? "pointer-events-auto! block" : "pointer-events-none invisible absolute opacity-0",
2152
+ hasPopover && "p-lg"
2153
+ ),
2154
+ ...props,
2155
+ ...downshiftMenuProps,
2156
+ "data-spark-component": "dropdown-items",
2157
+ children
2158
+ }
2159
+ );
2160
+ };
2161
+ Items.displayName = "Dropdown.Items";
2162
+
2163
+ // src/dropdown/DropdownItemText.tsx
2164
+ var import_class_variance_authority24 = require("class-variance-authority");
2165
+ var import_react16 = require("react");
2166
+ var import_jsx_runtime39 = require("react/jsx-runtime");
2167
+ var ItemText = ({ children, ref: forwardedRef }) => {
2168
+ const id = `${ID_PREFIX3}-item-text-${(0, import_react16.useId)()}`;
2169
+ const { setTextId } = useDropdownItemContext();
2170
+ (0, import_react16.useEffect)(() => {
2171
+ setTextId(id);
2172
+ return () => setTextId(void 0);
2173
+ });
2174
+ return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("span", { id, className: (0, import_class_variance_authority24.cx)("inline"), ref: forwardedRef, children });
2175
+ };
2176
+ ItemText.displayName = "Dropdown.ItemText";
2177
+
2178
+ // src/dropdown/DropdownLabel.tsx
2179
+ var import_class_variance_authority25 = require("class-variance-authority");
2180
+ var import_jsx_runtime40 = require("react/jsx-runtime");
2181
+ var Label3 = ({ children, className, ref: forwardedRef }) => {
2182
+ const { labelId } = useDropdownGroupContext();
2183
+ return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(
2184
+ "div",
2185
+ {
2186
+ ref: forwardedRef,
2187
+ id: labelId,
2188
+ className: (0, import_class_variance_authority25.cx)("px-md py-sm text-body-2 text-neutral italic", className),
2189
+ children
2190
+ }
2191
+ );
2192
+ };
2193
+ Label3.displayName = "Dropdown.Label";
2194
+
2195
+ // src/dropdown/DropdownLeadingIcon.tsx
2196
+ var import_jsx_runtime41 = require("react/jsx-runtime");
2197
+ var LeadingIcon = ({ children }) => {
2198
+ return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Icon, { size: "sm", className: "shrink-0", children });
2199
+ };
2200
+ LeadingIcon.displayName = "Dropdown.LeadingIcon";
2201
+
2202
+ // src/dropdown/DropdownPopover.tsx
2203
+ var import_class_variance_authority26 = require("class-variance-authority");
2204
+ var import_react17 = require("react");
2205
+ var import_jsx_runtime42 = require("react/jsx-runtime");
2206
+ var Popover3 = ({
2207
+ children,
2208
+ matchTriggerWidth = true,
2209
+ sideOffset = 4,
2210
+ className,
2211
+ elevation = "dropdown",
2212
+ ref: forwardedRef,
2213
+ ...props
2214
+ }) => {
2215
+ const ctx = useDropdownContext();
2216
+ (0, import_react17.useEffect)(() => {
2217
+ ctx.setHasPopover(true);
2218
+ return () => ctx.setHasPopover(false);
2219
+ }, []);
2220
+ return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(
2221
+ Popover2.Content,
2222
+ {
2223
+ ref: forwardedRef,
2224
+ inset: true,
2225
+ asChild: true,
2226
+ matchTriggerWidth,
2227
+ elevation,
2228
+ className: (0, import_class_variance_authority26.cx)("relative", className),
2229
+ sideOffset,
2230
+ onOpenAutoFocus: (e) => {
2231
+ e.preventDefault();
2232
+ },
2233
+ ...props,
2234
+ "data-spark-component": "dropdown-popover",
2235
+ children
2236
+ }
2237
+ );
2238
+ };
2239
+ Popover3.displayName = "Dropdown.Popover";
2240
+
2241
+ // src/dropdown/DropdownPortal.tsx
2242
+ var import_jsx_runtime43 = require("react/jsx-runtime");
2243
+ var Portal2 = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Popover2.Portal, { ...rest, children });
2244
+ Portal2.displayName = "Dropdown.Portal";
2245
+
2246
+ // src/dropdown/DropdownTrigger.tsx
2247
+ var import_ArrowHorizontalDown = require("@spark-ui/icons/ArrowHorizontalDown");
2248
+ var import_use_merge_refs3 = require("@spark-ui/use-merge-refs");
2249
+ var import_class_variance_authority28 = require("class-variance-authority");
2250
+ var import_react18 = require("react");
2251
+
2252
+ // src/dropdown/DropdownTrigger.styles.tsx
2253
+ var import_class_variance_authority27 = require("class-variance-authority");
2254
+ var styles3 = (0, import_class_variance_authority27.cva)(
2255
+ [
2256
+ "flex w-full items-center justify-between",
2257
+ "min-h-sz-44 rounded-lg bg-surface text-on-surface px-lg",
2258
+ "text-body-1",
2259
+ // outline styles
2260
+ "ring-1 outline-hidden ring-inset focus:ring-2"
2261
+ ],
2262
+ {
2263
+ variants: {
2264
+ state: {
2265
+ undefined: "ring-outline focus:ring-outline-high",
2266
+ error: "ring-error",
2267
+ alert: "ring-alert",
2268
+ success: "ring-success"
2269
+ },
2270
+ disabled: {
2271
+ true: "disabled:bg-on-surface/dim-5 cursor-not-allowed text-on-surface/dim-3"
2272
+ },
2273
+ readOnly: {
2274
+ true: "disabled:bg-on-surface/dim-5 cursor-not-allowed text-on-surface/dim-3"
2275
+ }
2276
+ },
2277
+ compoundVariants: [
2278
+ {
2279
+ disabled: false,
2280
+ state: void 0,
2281
+ class: "hover:ring-outline-high"
2282
+ }
2283
+ ]
2284
+ }
2285
+ );
2286
+
2287
+ // src/dropdown/DropdownTrigger.tsx
2288
+ var import_jsx_runtime44 = require("react/jsx-runtime");
2289
+ var Trigger2 = ({
2290
+ "aria-label": ariaLabel,
2291
+ children,
2292
+ className,
2293
+ ref: forwardedRef
2294
+ }) => {
2295
+ const {
2296
+ getToggleButtonProps,
2297
+ getDropdownProps,
2298
+ getLabelProps,
2299
+ hasPopover,
2300
+ disabled,
2301
+ readOnly,
2302
+ state,
2303
+ setLastInteractionType
2304
+ } = useDropdownContext();
2305
+ const [WrapperComponent, wrapperProps] = hasPopover ? [Popover2.Trigger, { asChild: true }] : [import_react18.Fragment, {}];
2306
+ const { ref: downshiftRef, ...downshiftTriggerProps } = getToggleButtonProps({
2307
+ ...getDropdownProps(),
2308
+ onKeyDown: () => {
2309
+ setLastInteractionType("keyboard");
2310
+ }
2311
+ });
2312
+ const isExpanded = downshiftTriggerProps["aria-expanded"];
2313
+ const ref = (0, import_use_merge_refs3.useMergeRefs)(forwardedRef, downshiftRef);
2314
+ return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(import_jsx_runtime44.Fragment, { children: [
2315
+ ariaLabel && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(VisuallyHidden, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("label", { ...getLabelProps(), children: ariaLabel }) }),
2316
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(WrapperComponent, { ...wrapperProps, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(
2317
+ "button",
2318
+ {
2319
+ type: "button",
2320
+ ref,
2321
+ disabled: disabled || readOnly,
2322
+ className: styles3({ className, state, disabled, readOnly }),
2323
+ ...downshiftTriggerProps,
2324
+ "data-spark-component": "dropdown-trigger",
2325
+ children: [
2326
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("span", { className: "gap-md flex items-center justify-start", children }),
2327
+ /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
2328
+ Icon,
2329
+ {
2330
+ className: (0, import_class_variance_authority28.cx)("ml-md shrink-0 rotate-0 transition duration-100 ease-in", {
2331
+ "rotate-180": isExpanded
2332
+ }),
2333
+ size: "sm",
2334
+ children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_ArrowHorizontalDown.ArrowHorizontalDown, {})
2335
+ }
2336
+ )
2337
+ ]
2338
+ }
2339
+ ) })
2340
+ ] });
2341
+ };
2342
+ Trigger2.displayName = "Dropdown.Trigger";
2343
+
2344
+ // src/dropdown/DropdownValue.tsx
2345
+ var import_class_variance_authority29 = require("class-variance-authority");
2346
+ var import_jsx_runtime45 = require("react/jsx-runtime");
2347
+ var Value = ({ children, className, placeholder, ref: forwardedRef }) => {
2348
+ const { selectedItem, multiple, selectedItems } = useDropdownContext();
2349
+ const hasSelectedItems = !!(multiple ? selectedItems.length : selectedItem);
2350
+ const text = multiple ? selectedItems[0]?.text : selectedItem?.text;
2351
+ const suffix = selectedItems.length > 1 ? `, +${selectedItems.length - 1}` : "";
2352
+ return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("span", { ref: forwardedRef, className: (0, import_class_variance_authority29.cx)("flex shrink items-center text-left", className), children: [
2353
+ /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(
2354
+ "span",
2355
+ {
2356
+ className: (0, import_class_variance_authority29.cx)(
2357
+ "line-clamp-1 flex-1 overflow-hidden break-all text-ellipsis",
2358
+ !hasSelectedItems && "text-on-surface/dim-1"
2359
+ ),
2360
+ children: !hasSelectedItems ? placeholder : children || text
2361
+ }
2362
+ ),
2363
+ suffix && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("span", { children: suffix })
2364
+ ] });
2365
+ };
2366
+ Value.displayName = "Dropdown.Value";
2367
+
2368
+ // src/dropdown/index.ts
2369
+ var Dropdown2 = Object.assign(Dropdown, {
2370
+ Group,
2371
+ Item,
2372
+ Items,
2373
+ ItemText,
2374
+ ItemIndicator,
2375
+ Label: Label3,
2376
+ Popover: Popover3,
2377
+ Divider,
2378
+ Trigger: Trigger2,
2379
+ Value,
2380
+ LeadingIcon,
2381
+ Portal: Portal2
2382
+ });
2383
+ Dropdown2.displayName = "Dropdown";
2384
+ Group.displayName = "Dropdown.Group";
2385
+ Items.displayName = "Dropdown.Items";
2386
+ Item.displayName = "Dropdown.Item";
2387
+ ItemText.displayName = "Dropdown.ItemText";
2388
+ ItemIndicator.displayName = "Dropdown.ItemIndicator";
2389
+ Label3.displayName = "Dropdown.Label";
2390
+ Popover3.displayName = "Dropdown.Popover";
2391
+ Divider.displayName = "Dropdown.Divider";
2392
+ Trigger2.displayName = "Dropdown.Trigger";
2393
+ Value.displayName = "Dropdown.Value";
2394
+ LeadingIcon.displayName = "Dropdown.LeadingIcon";
2395
+ Portal2.displayName = "Dropdown.Portal";
2396
+ // Annotate the CommonJS export names for ESM import in node:
2397
+ 0 && (module.exports = {
2398
+ Dropdown,
2399
+ DropdownProvider,
2400
+ useDropdownContext
2401
+ });
2402
+ //# sourceMappingURL=index.js.map