@spark-ui/components 11.1.0 → 11.1.2

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