@spark-ui/components 11.0.1 → 11.1.1

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 (143) 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.ts +21 -0
  117. package/dist/spinner/index.js +139 -0
  118. package/dist/spinner/index.js.map +1 -0
  119. package/dist/stepper/index.d.ts +81 -0
  120. package/dist/stepper/index.js +1847 -0
  121. package/dist/stepper/index.js.map +1 -0
  122. package/dist/switch/index.d.ts +64 -0
  123. package/dist/switch/index.js +327 -0
  124. package/dist/switch/index.js.map +1 -0
  125. package/dist/tabs/index.d.ts +103 -0
  126. package/dist/tabs/index.js +1376 -0
  127. package/dist/tabs/index.js.map +1 -0
  128. package/dist/tag/index.d.ts +29 -0
  129. package/dist/tag/index.js +283 -0
  130. package/dist/tag/index.js.map +1 -0
  131. package/dist/text-link/index.d.ts +20 -0
  132. package/dist/text-link/index.js +100 -0
  133. package/dist/text-link/index.js.map +1 -0
  134. package/dist/textarea/index.d.ts +57 -0
  135. package/dist/textarea/index.js +797 -0
  136. package/dist/textarea/index.js.map +1 -0
  137. package/dist/toast/index.d.ts +56 -0
  138. package/dist/toast/index.js +1412 -0
  139. package/dist/toast/index.js.map +1 -0
  140. package/dist/visually-hidden/index.d.ts +16 -0
  141. package/dist/visually-hidden/index.js +67 -0
  142. package/dist/visually-hidden/index.js.map +1 -0
  143. package/package.json +5 -5
@@ -0,0 +1,1376 @@
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/tabs/index.ts
21
+ var tabs_exports = {};
22
+ __export(tabs_exports, {
23
+ Tabs: () => Tabs2
24
+ });
25
+ module.exports = __toCommonJS(tabs_exports);
26
+
27
+ // src/tabs/Tabs.tsx
28
+ var import_radix_ui = require("radix-ui");
29
+
30
+ // src/tabs/TabsContext.tsx
31
+ var import_react = require("react");
32
+ var TabsContext = (0, import_react.createContext)({});
33
+ var useTabsContext = () => {
34
+ const context = (0, import_react.useContext)(TabsContext);
35
+ if (!context) {
36
+ throw Error("useTabsContext must be used within a TabsContext Provider");
37
+ }
38
+ return context;
39
+ };
40
+
41
+ // src/tabs/TabsRoot.styles.ts
42
+ var import_class_variance_authority = require("class-variance-authority");
43
+ var rootStyles = (0, import_class_variance_authority.cva)([
44
+ "flex",
45
+ "data-[orientation=horizontal]:flex-col",
46
+ "data-[orientation=vertical]:flex-row",
47
+ "max-w-full"
48
+ ]);
49
+
50
+ // src/tabs/Tabs.tsx
51
+ var import_jsx_runtime = require("react/jsx-runtime");
52
+ var Tabs = ({
53
+ intent = "basic",
54
+ size = "md",
55
+ /**
56
+ * Default Radix Primitive values
57
+ * see https://www.radix-ui.com/docs/primitives/components/tabs#root
58
+ */
59
+ asChild = false,
60
+ forceMount = false,
61
+ orientation = "horizontal",
62
+ children,
63
+ className,
64
+ ref,
65
+ ...rest
66
+ }) => {
67
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
68
+ TabsContext.Provider,
69
+ {
70
+ value: {
71
+ intent,
72
+ size,
73
+ orientation,
74
+ forceMount
75
+ },
76
+ children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
77
+ import_radix_ui.Tabs.Root,
78
+ {
79
+ ref,
80
+ asChild,
81
+ orientation,
82
+ className: rootStyles({ className }),
83
+ "data-spark-component": "tabs",
84
+ activationMode: "automatic",
85
+ ...rest,
86
+ children
87
+ }
88
+ )
89
+ }
90
+ );
91
+ };
92
+ Tabs.displayName = "Tabs";
93
+
94
+ // src/tabs/TabsContent.tsx
95
+ var import_radix_ui2 = require("radix-ui");
96
+
97
+ // src/tabs/TabsContent.styles.ts
98
+ var import_class_variance_authority2 = require("class-variance-authority");
99
+ var contentStyles = (0, import_class_variance_authority2.cva)(["w-full p-lg", "focus-visible:u-outline-inset"], {
100
+ variants: {
101
+ forceMount: {
102
+ true: "data-[state=inactive]:hidden",
103
+ false: ""
104
+ }
105
+ }
106
+ });
107
+
108
+ // src/tabs/TabsContent.tsx
109
+ var import_jsx_runtime2 = require("react/jsx-runtime");
110
+ var TabsContent = ({
111
+ /**
112
+ * Default Radix Primitive values
113
+ * see https://www.radix-ui.com/docs/primitives/components/tabs#content
114
+ */
115
+ children,
116
+ asChild = false,
117
+ className,
118
+ ref,
119
+ ...rest
120
+ }) => {
121
+ const { forceMount } = useTabsContext();
122
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
123
+ import_radix_ui2.Tabs.Content,
124
+ {
125
+ "data-spark-component": "tabs-content",
126
+ ref,
127
+ forceMount: forceMount || rest.forceMount,
128
+ className: contentStyles({ className, forceMount }),
129
+ asChild,
130
+ ...rest,
131
+ children
132
+ }
133
+ );
134
+ };
135
+ TabsContent.displayName = "Tabs.Content";
136
+
137
+ // src/tabs/TabsList.tsx
138
+ var import_ArrowVerticalLeft = require("@spark-ui/icons/ArrowVerticalLeft");
139
+ var import_ArrowVerticalRight = require("@spark-ui/icons/ArrowVerticalRight");
140
+ var import_radix_ui4 = require("radix-ui");
141
+ var import_react6 = require("react");
142
+
143
+ // src/button/Button.tsx
144
+ var import_class_variance_authority5 = require("class-variance-authority");
145
+ var import_react3 = require("react");
146
+
147
+ // src/slot/Slot.tsx
148
+ var import_radix_ui3 = require("radix-ui");
149
+ var import_react2 = require("react");
150
+ var import_jsx_runtime3 = require("react/jsx-runtime");
151
+ var Slottable = import_radix_ui3.Slot.Slottable;
152
+ var Slot = ({ ref, ...props }) => {
153
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_radix_ui3.Slot.Root, { ref, ...props });
154
+ };
155
+ var wrapPolymorphicSlot = (asChild, children, callback) => {
156
+ if (!asChild) return callback(children);
157
+ return (0, import_react2.isValidElement)(children) ? (0, import_react2.cloneElement)(
158
+ children,
159
+ void 0,
160
+ callback(children.props.children)
161
+ ) : null;
162
+ };
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/spinner/Spinner.styles.tsx
193
+ var import_internal_utils = require("@spark-ui/internal-utils");
194
+ var import_class_variance_authority3 = require("class-variance-authority");
195
+ var defaultVariants = {
196
+ intent: "current",
197
+ size: "current",
198
+ isBackgroundVisible: false
199
+ };
200
+ var spinnerStyles = (0, import_class_variance_authority3.cva)(
201
+ ["inline-block", "border-solid", "rounded-full", "border-md", "animate-spin"],
202
+ {
203
+ variants: {
204
+ /**
205
+ * 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.
206
+ */
207
+ size: {
208
+ current: ["u-current-font-size"],
209
+ sm: ["w-sz-20", "h-sz-20"],
210
+ md: ["w-sz-28", "h-sz-28"],
211
+ full: ["w-full", "h-full"]
212
+ },
213
+ /**
214
+ * Color scheme of the spinner.
215
+ */
216
+ intent: (0, import_internal_utils.makeVariants)({
217
+ current: ["border-current"],
218
+ main: ["border-main"],
219
+ support: ["border-support"],
220
+ accent: ["border-accent"],
221
+ basic: ["border-basic"],
222
+ success: ["border-success"],
223
+ alert: ["border-alert"],
224
+ error: ["border-error"],
225
+ info: ["border-info"],
226
+ neutral: ["border-neutral"]
227
+ }),
228
+ /**
229
+ * Size of the button.
230
+ */
231
+ isBackgroundVisible: {
232
+ true: ["border-b-neutral-container", "border-l-neutral-container"],
233
+ false: ["border-b-transparent", "border-l-transparent"]
234
+ }
235
+ },
236
+ defaultVariants
237
+ }
238
+ );
239
+
240
+ // src/spinner/Spinner.tsx
241
+ var import_jsx_runtime5 = require("react/jsx-runtime");
242
+ var Spinner = ({
243
+ className,
244
+ size = "current",
245
+ intent = "current",
246
+ label,
247
+ isBackgroundVisible,
248
+ ref,
249
+ ...others
250
+ }) => {
251
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
252
+ "span",
253
+ {
254
+ role: "status",
255
+ "data-spark-component": "spinner",
256
+ ref,
257
+ className: spinnerStyles({ className, size, intent, isBackgroundVisible }),
258
+ ...others,
259
+ children: label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VisuallyHidden, { children: label })
260
+ }
261
+ );
262
+ };
263
+
264
+ // src/button/Button.styles.tsx
265
+ var import_internal_utils7 = require("@spark-ui/internal-utils");
266
+ var import_class_variance_authority4 = require("class-variance-authority");
267
+
268
+ // src/button/variants/filled.ts
269
+ var import_internal_utils2 = require("@spark-ui/internal-utils");
270
+ var filledVariants = [
271
+ // Main
272
+ {
273
+ intent: "main",
274
+ design: "filled",
275
+ class: (0, import_internal_utils2.tw)([
276
+ "bg-main",
277
+ "text-on-main",
278
+ "hover:bg-main-hovered",
279
+ "enabled:active:bg-main-hovered",
280
+ "focus-visible:bg-main-hovered"
281
+ ])
282
+ },
283
+ // Support
284
+ {
285
+ intent: "support",
286
+ design: "filled",
287
+ class: (0, import_internal_utils2.tw)([
288
+ "bg-support",
289
+ "text-on-support",
290
+ "hover:bg-support-hovered",
291
+ "enabled:active:bg-support-hovered",
292
+ "focus-visible:bg-support-hovered"
293
+ ])
294
+ },
295
+ // Accent
296
+ {
297
+ intent: "accent",
298
+ design: "filled",
299
+ class: (0, import_internal_utils2.tw)([
300
+ "bg-accent",
301
+ "text-on-accent",
302
+ "hover:bg-accent-hovered",
303
+ "enabled:active:bg-accent-hovered",
304
+ "focus-visible:bg-accent-hovered"
305
+ ])
306
+ },
307
+ // Basic
308
+ {
309
+ intent: "basic",
310
+ design: "filled",
311
+ class: (0, import_internal_utils2.tw)([
312
+ "bg-basic",
313
+ "text-on-basic",
314
+ "hover:bg-basic-hovered",
315
+ "enabled:active:bg-basic-hovered",
316
+ "focus-visible:bg-basic-hovered"
317
+ ])
318
+ },
319
+ // Success
320
+ {
321
+ intent: "success",
322
+ design: "filled",
323
+ class: (0, import_internal_utils2.tw)([
324
+ "bg-success",
325
+ "text-on-success",
326
+ "hover:bg-success-hovered",
327
+ "enabled:active:bg-success-hovered",
328
+ "focus-visible:bg-success-hovered"
329
+ ])
330
+ },
331
+ // Alert
332
+ {
333
+ intent: "alert",
334
+ design: "filled",
335
+ class: (0, import_internal_utils2.tw)([
336
+ "bg-alert",
337
+ "text-on-alert",
338
+ "hover:bg-alert-hovered",
339
+ "enabled:active:bg-alert-hovered",
340
+ "focus-visible:bg-alert-hovered"
341
+ ])
342
+ },
343
+ // Danger
344
+ {
345
+ intent: "danger",
346
+ design: "filled",
347
+ class: (0, import_internal_utils2.tw)([
348
+ "text-on-error bg-error",
349
+ "hover:bg-error-hovered enabled:active:bg-error-hovered",
350
+ "focus-visible:bg-error-hovered"
351
+ ])
352
+ },
353
+ // Info
354
+ {
355
+ intent: "info",
356
+ design: "filled",
357
+ class: (0, import_internal_utils2.tw)([
358
+ "text-on-error bg-info",
359
+ "hover:bg-info-hovered enabled:active:bg-info-hovered",
360
+ "focus-visible:bg-info-hovered"
361
+ ])
362
+ },
363
+ // Neutral
364
+ {
365
+ intent: "neutral",
366
+ design: "filled",
367
+ class: (0, import_internal_utils2.tw)([
368
+ "bg-neutral",
369
+ "text-on-neutral",
370
+ "hover:bg-neutral-hovered",
371
+ "enabled:active:bg-neutral-hovered",
372
+ "focus-visible:bg-neutral-hovered"
373
+ ])
374
+ },
375
+ // Surface
376
+ {
377
+ intent: "surface",
378
+ design: "filled",
379
+ class: (0, import_internal_utils2.tw)([
380
+ "bg-surface",
381
+ "text-on-surface",
382
+ "hover:bg-surface-hovered",
383
+ "enabled:active:bg-surface-hovered",
384
+ "focus-visible:bg-surface-hovered"
385
+ ])
386
+ },
387
+ {
388
+ intent: "surfaceInverse",
389
+ design: "filled",
390
+ class: (0, import_internal_utils2.tw)([
391
+ "bg-surface-inverse",
392
+ "text-on-surface-inverse",
393
+ "hover:bg-surface-inverse-hovered",
394
+ "enabled:active:bg-surface-inverse-hovered",
395
+ "focus-visible:bg-surface-inverse-hovered"
396
+ ])
397
+ }
398
+ ];
399
+
400
+ // src/button/variants/ghost.ts
401
+ var import_internal_utils3 = require("@spark-ui/internal-utils");
402
+ var ghostVariants = [
403
+ {
404
+ intent: "main",
405
+ design: "ghost",
406
+ class: (0, import_internal_utils3.tw)([
407
+ "text-on-main-container",
408
+ "hover:bg-main/dim-5",
409
+ "enabled:active:bg-main/dim-5",
410
+ "focus-visible:bg-main/dim-5"
411
+ ])
412
+ },
413
+ {
414
+ intent: "support",
415
+ design: "ghost",
416
+ class: (0, import_internal_utils3.tw)([
417
+ "text-on-support-container",
418
+ "hover:bg-support/dim-5",
419
+ "enabled:active:bg-support/dim-5",
420
+ "focus-visible:bg-support/dim-5"
421
+ ])
422
+ },
423
+ {
424
+ intent: "accent",
425
+ design: "ghost",
426
+ class: (0, import_internal_utils3.tw)([
427
+ "text-on-accent-container",
428
+ "hover:bg-accent/dim-5",
429
+ "enabled:active:bg-accent/dim-5",
430
+ "focus-visible:bg-accent/dim-5"
431
+ ])
432
+ },
433
+ {
434
+ intent: "basic",
435
+ design: "ghost",
436
+ class: (0, import_internal_utils3.tw)([
437
+ "text-on-basic-container",
438
+ "hover:bg-basic/dim-5",
439
+ "enabled:active:bg-basic/dim-5",
440
+ "focus-visible:bg-basic/dim-5"
441
+ ])
442
+ },
443
+ {
444
+ intent: "success",
445
+ design: "ghost",
446
+ class: (0, import_internal_utils3.tw)([
447
+ "text-on-success-container",
448
+ "hover:bg-success/dim-5",
449
+ "enabled:active:bg-success/dim-5",
450
+ "focus-visible:bg-success/dim-5"
451
+ ])
452
+ },
453
+ {
454
+ intent: "alert",
455
+ design: "ghost",
456
+ class: (0, import_internal_utils3.tw)([
457
+ "text-on-alert-container",
458
+ "hover:bg-alert/dim-5",
459
+ "enabled:active:bg-alert/dim-5",
460
+ "focus-visible:bg-alert/dim-5"
461
+ ])
462
+ },
463
+ {
464
+ intent: "danger",
465
+ design: "ghost",
466
+ class: (0, import_internal_utils3.tw)([
467
+ "text-on-error-container",
468
+ "hover:bg-error/dim-5",
469
+ "enabled:active:bg-error/dim-5",
470
+ "focus-visible:bg-error/dim-5"
471
+ ])
472
+ },
473
+ {
474
+ intent: "info",
475
+ design: "ghost",
476
+ class: (0, import_internal_utils3.tw)([
477
+ "text-on-info-container",
478
+ "hover:bg-info/dim-5",
479
+ "enabled:active:bg-info/dim-5",
480
+ "focus-visible:bg-info/dim-5"
481
+ ])
482
+ },
483
+ {
484
+ intent: "neutral",
485
+ design: "ghost",
486
+ class: (0, import_internal_utils3.tw)([
487
+ "text-on-neutral-container",
488
+ "hover:bg-neutral/dim-5",
489
+ "enabled:active:bg-neutral/dim-5",
490
+ "focus-visible:bg-neutral/dim-5"
491
+ ])
492
+ },
493
+ {
494
+ intent: "surface",
495
+ design: "ghost",
496
+ class: (0, import_internal_utils3.tw)([
497
+ "text-surface",
498
+ "hover:bg-surface/dim-5",
499
+ "enabled:active:bg-surface/dim-5",
500
+ "focus-visible:bg-surface/dim-5"
501
+ ])
502
+ },
503
+ {
504
+ intent: "surfaceInverse",
505
+ design: "ghost",
506
+ class: (0, import_internal_utils3.tw)([
507
+ "text-surface-inverse",
508
+ "hover:bg-surface-inverse/dim-5",
509
+ "enabled:active:bg-surface-inverse/dim-5",
510
+ "focus-visible:bg-surface-inverse/dim-5"
511
+ ])
512
+ }
513
+ ];
514
+
515
+ // src/button/variants/outlined.ts
516
+ var import_internal_utils4 = require("@spark-ui/internal-utils");
517
+ var outlinedVariants = [
518
+ {
519
+ intent: "main",
520
+ design: "outlined",
521
+ class: (0, import_internal_utils4.tw)([
522
+ "hover:bg-main/dim-5",
523
+ "enabled:active:bg-main/dim-5",
524
+ "focus-visible:bg-main/dim-5",
525
+ "text-main"
526
+ ])
527
+ },
528
+ {
529
+ intent: "support",
530
+ design: "outlined",
531
+ class: (0, import_internal_utils4.tw)([
532
+ "hover:bg-support/dim-5",
533
+ "enabled:active:bg-support/dim-5",
534
+ "focus-visible:bg-support/dim-5",
535
+ "text-support"
536
+ ])
537
+ },
538
+ {
539
+ intent: "accent",
540
+ design: "outlined",
541
+ class: (0, import_internal_utils4.tw)([
542
+ "hover:bg-accent/dim-5",
543
+ "enabled:active:bg-accent/dim-5",
544
+ "focus-visible:bg-accent/dim-5",
545
+ "text-accent"
546
+ ])
547
+ },
548
+ {
549
+ intent: "basic",
550
+ design: "outlined",
551
+ class: (0, import_internal_utils4.tw)([
552
+ "hover:bg-basic/dim-5",
553
+ "enabled:active:bg-basic/dim-5",
554
+ "focus-visible:bg-basic/dim-5",
555
+ "text-basic"
556
+ ])
557
+ },
558
+ {
559
+ intent: "success",
560
+ design: "outlined",
561
+ class: (0, import_internal_utils4.tw)([
562
+ "hover:bg-success/dim-5",
563
+ "enabled:active:bg-success/dim-5",
564
+ "focus-visible:bg-success/dim-5",
565
+ "text-success"
566
+ ])
567
+ },
568
+ {
569
+ intent: "alert",
570
+ design: "outlined",
571
+ class: (0, import_internal_utils4.tw)([
572
+ "hover:bg-alert/dim-5",
573
+ "enabled:active:bg-alert/dim-5",
574
+ "focus-visible:bg-alert/dim-5",
575
+ "text-alert"
576
+ ])
577
+ },
578
+ {
579
+ intent: "danger",
580
+ design: "outlined",
581
+ class: (0, import_internal_utils4.tw)([
582
+ "hover:bg-error/dim-5",
583
+ "enabled:active:bg-error/dim-5",
584
+ "focus-visible:bg-error/dim-5",
585
+ "text-error"
586
+ ])
587
+ },
588
+ {
589
+ intent: "info",
590
+ design: "outlined",
591
+ class: (0, import_internal_utils4.tw)([
592
+ "hover:bg-info/dim-5",
593
+ "enabled:active:bg-info/dim-5",
594
+ "focus-visible:bg-info/dim-5",
595
+ "text-info"
596
+ ])
597
+ },
598
+ {
599
+ intent: "neutral",
600
+ design: "outlined",
601
+ class: (0, import_internal_utils4.tw)([
602
+ "hover:bg-neutral/dim-5",
603
+ "enabled:active:bg-neutral/dim-5",
604
+ "focus-visible:bg-neutral/dim-5",
605
+ "text-neutral"
606
+ ])
607
+ },
608
+ {
609
+ intent: "surface",
610
+ design: "outlined",
611
+ class: (0, import_internal_utils4.tw)([
612
+ "hover:bg-surface/dim-5",
613
+ "enabled:active:bg-surface/dim-5",
614
+ "focus-visible:bg-surface/dim-5",
615
+ "text-surface"
616
+ ])
617
+ },
618
+ {
619
+ intent: "surfaceInverse",
620
+ design: "outlined",
621
+ class: (0, import_internal_utils4.tw)([
622
+ "hover:bg-surface-inverse/dim-5",
623
+ "enabled:active:bg-surface-inverse/dim-5",
624
+ "focus-visible:bg-surface-inverse/dim-5",
625
+ "text-surface-inverse"
626
+ ])
627
+ }
628
+ ];
629
+
630
+ // src/button/variants/tinted.ts
631
+ var import_internal_utils5 = require("@spark-ui/internal-utils");
632
+ var tintedVariants = [
633
+ {
634
+ intent: "main",
635
+ design: "tinted",
636
+ class: (0, import_internal_utils5.tw)([
637
+ "bg-main-container",
638
+ "text-on-main-container",
639
+ "hover:bg-main-container-hovered",
640
+ "enabled:active:bg-main-container-hovered",
641
+ "focus-visible:bg-main-container-hovered"
642
+ ])
643
+ },
644
+ {
645
+ intent: "support",
646
+ design: "tinted",
647
+ class: (0, import_internal_utils5.tw)([
648
+ "bg-support-container",
649
+ "text-on-support-container",
650
+ "hover:bg-support-container-hovered",
651
+ "enabled:active:bg-support-container-hovered",
652
+ "focus-visible:bg-support-container-hovered"
653
+ ])
654
+ },
655
+ {
656
+ intent: "accent",
657
+ design: "tinted",
658
+ class: (0, import_internal_utils5.tw)([
659
+ "bg-accent-container",
660
+ "text-on-accent-container",
661
+ "hover:bg-accent-container-hovered",
662
+ "enabled:active:bg-accent-container-hovered",
663
+ "focus-visible:bg-accent-container-hovered"
664
+ ])
665
+ },
666
+ {
667
+ intent: "basic",
668
+ design: "tinted",
669
+ class: (0, import_internal_utils5.tw)([
670
+ "bg-basic-container",
671
+ "text-on-basic-container",
672
+ "hover:bg-basic-container-hovered",
673
+ "enabled:active:bg-basic-container-hovered",
674
+ "focus-visible:bg-basic-container-hovered"
675
+ ])
676
+ },
677
+ {
678
+ intent: "success",
679
+ design: "tinted",
680
+ class: (0, import_internal_utils5.tw)([
681
+ "bg-success-container",
682
+ "text-on-success-container",
683
+ "hover:bg-success-container-hovered",
684
+ "enabled:active:bg-success-container-hovered",
685
+ "focus-visible:bg-success-container-hovered"
686
+ ])
687
+ },
688
+ {
689
+ intent: "alert",
690
+ design: "tinted",
691
+ class: (0, import_internal_utils5.tw)([
692
+ "bg-alert-container",
693
+ "text-on-alert-container",
694
+ "hover:bg-alert-container-hovered",
695
+ "enabled:active:bg-alert-container-hovered",
696
+ "focus-visible:bg-alert-container-hovered"
697
+ ])
698
+ },
699
+ {
700
+ intent: "danger",
701
+ design: "tinted",
702
+ class: (0, import_internal_utils5.tw)([
703
+ "bg-error-container",
704
+ "text-on-error-container",
705
+ "hover:bg-error-container-hovered",
706
+ "enabled:active:bg-error-container-hovered",
707
+ "focus-visible:bg-error-container-hovered"
708
+ ])
709
+ },
710
+ {
711
+ intent: "info",
712
+ design: "tinted",
713
+ class: (0, import_internal_utils5.tw)([
714
+ "bg-info-container",
715
+ "text-on-info-container",
716
+ "hover:bg-info-container-hovered",
717
+ "enabled:active:bg-info-container-hovered",
718
+ "focus-visible:bg-info-container-hovered"
719
+ ])
720
+ },
721
+ {
722
+ intent: "neutral",
723
+ design: "tinted",
724
+ class: (0, import_internal_utils5.tw)([
725
+ "bg-neutral-container",
726
+ "text-on-neutral-container",
727
+ "hover:bg-neutral-container-hovered",
728
+ "enabled:active:bg-neutral-container-hovered",
729
+ "focus-visible:bg-neutral-container-hovered"
730
+ ])
731
+ },
732
+ {
733
+ intent: "surface",
734
+ design: "tinted",
735
+ class: (0, import_internal_utils5.tw)([
736
+ "bg-surface",
737
+ "text-on-surface",
738
+ "hover:bg-surface-hovered",
739
+ "enabled:active:bg-surface-hovered",
740
+ "focus-visible:bg-surface-hovered"
741
+ ])
742
+ },
743
+ {
744
+ intent: "surfaceInverse",
745
+ design: "tinted",
746
+ class: (0, import_internal_utils5.tw)([
747
+ "bg-surface-inverse",
748
+ "text-on-surface-inverse",
749
+ "hover:bg-surface-inverse-hovered",
750
+ "enabled:active:bg-surface-inverse-hovered",
751
+ "focus-visible:bg-surface-inverse-hovered"
752
+ ])
753
+ }
754
+ ];
755
+
756
+ // src/button/variants/contrast.ts
757
+ var import_internal_utils6 = require("@spark-ui/internal-utils");
758
+ var contrastVariants = [
759
+ {
760
+ intent: "main",
761
+ design: "contrast",
762
+ class: (0, import_internal_utils6.tw)([
763
+ "text-on-main-contaier bg-surface",
764
+ "hover:bg-main-container-hovered",
765
+ "enabled:active:bg-main-container-hovered",
766
+ "focus-visible:bg-main-container-hovered"
767
+ ])
768
+ },
769
+ {
770
+ intent: "support",
771
+ design: "contrast",
772
+ class: (0, import_internal_utils6.tw)([
773
+ "text-on-support-container bg-surface",
774
+ "hover:bg-support-container-hovered",
775
+ "enabled:active:bg-support-container-hovered",
776
+ "focus-visible:bg-support-container-hovered"
777
+ ])
778
+ },
779
+ {
780
+ intent: "accent",
781
+ design: "contrast",
782
+ class: (0, import_internal_utils6.tw)([
783
+ "text-on-accent-container bg-surface",
784
+ "hover:bg-accent-container-hovered",
785
+ "enabled:active:bg-accent-container-hovered",
786
+ "focus-visible:bg-accent-container-hovered"
787
+ ])
788
+ },
789
+ {
790
+ intent: "basic",
791
+ design: "contrast",
792
+ class: (0, import_internal_utils6.tw)([
793
+ "text-on-basic-container bg-surface",
794
+ "hover:bg-basic-container-hovered",
795
+ "enabled:active:bg-basic-container-hovered",
796
+ "focus-visible:bg-basic-container-hovered"
797
+ ])
798
+ },
799
+ {
800
+ intent: "success",
801
+ design: "contrast",
802
+ class: (0, import_internal_utils6.tw)([
803
+ "text-on-success-container bg-surface",
804
+ "hover:bg-success-container-hovered",
805
+ "enabled:active:bg-success-container-hovered",
806
+ "focus-visible:bg-success-container-hovered"
807
+ ])
808
+ },
809
+ {
810
+ intent: "alert",
811
+ design: "contrast",
812
+ class: (0, import_internal_utils6.tw)([
813
+ "text-on-alert-container bg-surface",
814
+ "hover:bg-alert-container-hovered",
815
+ "enabled:active:bg-alert-container-hovered",
816
+ "focus-visible:bg-alert-container-hovered"
817
+ ])
818
+ },
819
+ {
820
+ intent: "danger",
821
+ design: "contrast",
822
+ class: (0, import_internal_utils6.tw)([
823
+ "text-on-error-container bg-surface",
824
+ "hover:bg-error-container-hovered",
825
+ "enabled:active:bg-error-container-hovered",
826
+ "focus-visible:bg-error-container-hovered"
827
+ ])
828
+ },
829
+ {
830
+ intent: "info",
831
+ design: "contrast",
832
+ class: (0, import_internal_utils6.tw)([
833
+ "text-on-info-container bg-surface",
834
+ "hover:bg-info-container-hovered",
835
+ "enabled:active:bg-info-container-hovered",
836
+ "focus-visible:bg-info-container-hovered"
837
+ ])
838
+ },
839
+ {
840
+ intent: "neutral",
841
+ design: "contrast",
842
+ class: (0, import_internal_utils6.tw)([
843
+ "text-on-neutral-container bg-surface",
844
+ "hover:bg-neutral-container-hovered",
845
+ "enabled:active:bg-neutral-container-hovered",
846
+ "focus-visible:bg-neutral-container-hovered"
847
+ ])
848
+ },
849
+ {
850
+ intent: "surface",
851
+ design: "contrast",
852
+ class: (0, import_internal_utils6.tw)([
853
+ "text-on-surface bg-surface",
854
+ "hover:bg-surface-hovered",
855
+ "enabled:active:bg-surface-hovered",
856
+ "focus-visible:bg-surface-hovered"
857
+ ])
858
+ },
859
+ {
860
+ intent: "surfaceInverse",
861
+ design: "contrast",
862
+ class: (0, import_internal_utils6.tw)([
863
+ "text-on-surface-inverse bg-surface-inverse",
864
+ "hover:bg-surface-inverse-hovered",
865
+ "enabled:active:bg-surface-inverse-hovered",
866
+ "focus-visible:bg-surface-inverse-hovered"
867
+ ])
868
+ }
869
+ ];
870
+
871
+ // src/button/Button.styles.tsx
872
+ var buttonStyles = (0, import_class_variance_authority4.cva)(
873
+ [
874
+ "u-shadow-border-transition",
875
+ "box-border inline-flex items-center justify-center gap-md whitespace-nowrap",
876
+ "default:px-lg",
877
+ "text-body-1 font-bold",
878
+ "focus-visible:u-outline"
879
+ ],
880
+ {
881
+ variants: {
882
+ /**
883
+ * Main style of the button.
884
+ *
885
+ * - `filled`: Button will be plain.
886
+ *
887
+ * - `outlined`: Button will be transparent with an outline.
888
+ *
889
+ * - `tinted`: Button will be filled but using a lighter color scheme.
890
+ *
891
+ * - `ghost`: Button will look like a link. No borders, plain text.
892
+ *
893
+ * - `contrast`: Button will be surface filled. No borders, plain text.
894
+ *
895
+ */
896
+ design: (0, import_internal_utils7.makeVariants)({
897
+ filled: [],
898
+ outlined: ["bg-transparent", "border-sm", "border-current"],
899
+ tinted: [],
900
+ ghost: ["default:-mx-md px-md hover:bg-main/dim-5"],
901
+ contrast: []
902
+ }),
903
+ underline: {
904
+ true: ["underline"]
905
+ },
906
+ /**
907
+ * Color scheme of the button.
908
+ */
909
+ intent: (0, import_internal_utils7.makeVariants)({
910
+ main: [],
911
+ support: [],
912
+ accent: [],
913
+ basic: [],
914
+ success: [],
915
+ alert: [],
916
+ danger: [],
917
+ info: [],
918
+ neutral: [],
919
+ surface: [],
920
+ surfaceInverse: []
921
+ }),
922
+ /**
923
+ * Size of the button.
924
+ */
925
+ size: (0, import_internal_utils7.makeVariants)({
926
+ sm: ["min-w-sz-32", "h-sz-32"],
927
+ md: ["min-w-sz-44", "h-sz-44"],
928
+ lg: ["min-w-sz-56", "h-sz-56"]
929
+ }),
930
+ /**
931
+ * Shape of the button.
932
+ */
933
+ shape: (0, import_internal_utils7.makeVariants)({
934
+ rounded: ["rounded-lg"],
935
+ square: ["rounded-0"],
936
+ pill: ["rounded-full"]
937
+ }),
938
+ /**
939
+ * Disable the button, preventing user interaction and adding opacity.
940
+ */
941
+ disabled: {
942
+ true: ["cursor-not-allowed", "opacity-dim-3"],
943
+ false: ["cursor-pointer"]
944
+ }
945
+ },
946
+ compoundVariants: [
947
+ ...filledVariants,
948
+ ...outlinedVariants,
949
+ ...tintedVariants,
950
+ ...ghostVariants,
951
+ ...contrastVariants
952
+ ],
953
+ defaultVariants: {
954
+ design: "filled",
955
+ intent: "main",
956
+ size: "md",
957
+ shape: "rounded"
958
+ }
959
+ }
960
+ );
961
+
962
+ // src/button/Button.tsx
963
+ var import_jsx_runtime6 = require("react/jsx-runtime");
964
+ var blockedEventHandlers = [
965
+ "onClick",
966
+ "onMouseDown",
967
+ "onMouseUp",
968
+ "onMouseEnter",
969
+ "onMouseLeave",
970
+ "onMouseOver",
971
+ "onMouseOut",
972
+ "onKeyDown",
973
+ "onKeyPress",
974
+ "onKeyUp",
975
+ "onSubmit"
976
+ ];
977
+ var Button = ({
978
+ children,
979
+ design = "filled",
980
+ disabled = false,
981
+ intent = "main",
982
+ isLoading = false,
983
+ loadingLabel,
984
+ loadingText,
985
+ shape = "rounded",
986
+ size = "md",
987
+ asChild,
988
+ className,
989
+ underline = false,
990
+ ref,
991
+ ...others
992
+ }) => {
993
+ const Component = asChild ? Slot : "button";
994
+ const shouldNotInteract = !!disabled || isLoading;
995
+ const disabledEventHandlers = (0, import_react3.useMemo)(() => {
996
+ const result = {};
997
+ if (shouldNotInteract) {
998
+ blockedEventHandlers.forEach((eventHandler) => result[eventHandler] = void 0);
999
+ }
1000
+ return result;
1001
+ }, [shouldNotInteract]);
1002
+ const spinnerProps = {
1003
+ size: "current",
1004
+ className: loadingText ? "inline-block" : "absolute",
1005
+ ...loadingLabel && { "aria-label": loadingLabel }
1006
+ };
1007
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1008
+ Component,
1009
+ {
1010
+ "data-spark-component": "button",
1011
+ ...Component === "button" && { type: "button" },
1012
+ ref,
1013
+ className: buttonStyles({
1014
+ className,
1015
+ design,
1016
+ disabled: shouldNotInteract,
1017
+ intent,
1018
+ shape,
1019
+ size,
1020
+ underline
1021
+ }),
1022
+ disabled: !!disabled,
1023
+ "aria-busy": isLoading,
1024
+ "aria-live": isLoading ? "assertive" : "off",
1025
+ ...others,
1026
+ ...disabledEventHandlers,
1027
+ children: wrapPolymorphicSlot(
1028
+ asChild,
1029
+ children,
1030
+ (slotted) => isLoading ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1031
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(Spinner, { ...spinnerProps }),
1032
+ loadingText && loadingText,
1033
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1034
+ "div",
1035
+ {
1036
+ "aria-hidden": true,
1037
+ className: (0, import_class_variance_authority5.cx)("gap-md", loadingText ? "hidden" : "inline-flex opacity-0"),
1038
+ children: slotted
1039
+ }
1040
+ )
1041
+ ] }) : slotted
1042
+ )
1043
+ }
1044
+ );
1045
+ };
1046
+ Button.displayName = "Button";
1047
+
1048
+ // src/icon/Icon.tsx
1049
+ var import_react4 = require("react");
1050
+
1051
+ // src/icon/Icon.styles.tsx
1052
+ var import_internal_utils8 = require("@spark-ui/internal-utils");
1053
+ var import_class_variance_authority6 = require("class-variance-authority");
1054
+ var iconStyles = (0, import_class_variance_authority6.cva)(["fill-current shrink-0"], {
1055
+ variants: {
1056
+ /**
1057
+ * Color scheme of the icon.
1058
+ */
1059
+ intent: (0, import_internal_utils8.makeVariants)({
1060
+ current: ["text-current"],
1061
+ main: ["text-main"],
1062
+ support: ["text-support"],
1063
+ accent: ["text-accent"],
1064
+ basic: ["text-basic"],
1065
+ success: ["text-success"],
1066
+ alert: ["text-alert"],
1067
+ error: ["text-error"],
1068
+ info: ["text-info"],
1069
+ neutral: ["text-neutral"]
1070
+ }),
1071
+ /**
1072
+ * Sets the size of the icon.
1073
+ */
1074
+ size: (0, import_internal_utils8.makeVariants)({
1075
+ current: ["u-current-font-size"],
1076
+ sm: ["w-sz-16", "h-sz-16"],
1077
+ md: ["w-sz-24", "h-sz-24"],
1078
+ lg: ["w-sz-32", "h-sz-32"],
1079
+ xl: ["w-sz-40", "h-sz-40"]
1080
+ })
1081
+ }
1082
+ });
1083
+
1084
+ // src/icon/Icon.tsx
1085
+ var import_jsx_runtime7 = require("react/jsx-runtime");
1086
+ var Icon = ({
1087
+ label,
1088
+ className,
1089
+ size = "current",
1090
+ intent = "current",
1091
+ children,
1092
+ ...others
1093
+ }) => {
1094
+ const child = import_react4.Children.only(children);
1095
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1096
+ (0, import_react4.cloneElement)(child, {
1097
+ className: iconStyles({ className, size, intent }),
1098
+ "data-spark-component": "icon",
1099
+ "aria-hidden": "true",
1100
+ focusable: "false",
1101
+ ...others
1102
+ }),
1103
+ label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(VisuallyHidden, { children: label })
1104
+ ] });
1105
+ };
1106
+ Icon.displayName = "Icon";
1107
+
1108
+ // src/tabs/TabsList.styles.ts
1109
+ var import_class_variance_authority7 = require("class-variance-authority");
1110
+ var wrapperStyles = (0, import_class_variance_authority7.cva)(["relative flex"]);
1111
+ var listStyles = (0, import_class_variance_authority7.cva)([
1112
+ "flex w-full",
1113
+ "data-[orientation=horizontal]:flex-row",
1114
+ "data-[orientation=vertical]:flex-col",
1115
+ "overflow-y-hidden u-no-scrollbar data-[orientation=vertical]:overflow-x-hidden",
1116
+ "after:flex after:shrink after:grow after:border-outline",
1117
+ "data-[orientation=horizontal]:after:border-b-sm",
1118
+ "data-[orientation=vertical]:after:border-r-sm"
1119
+ ]);
1120
+ var navigationArrowStyles = (0, import_class_variance_authority7.cva)([
1121
+ "h-auto! flex-none",
1122
+ "border-b-sm border-outline",
1123
+ "outline-hidden",
1124
+ "focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset!"
1125
+ ]);
1126
+
1127
+ // src/tabs/useResizeObserver.ts
1128
+ var import_react5 = require("react");
1129
+ var useResizeObserver = (target, onResize) => {
1130
+ const [size, setSize] = (0, import_react5.useState)({ width: void 0, height: void 0 });
1131
+ const resizeObserverRef = (0, import_react5.useRef)(null);
1132
+ const resizeCallbackRef = (0, import_react5.useRef)(onResize);
1133
+ (0, import_react5.useEffect)(() => {
1134
+ resizeCallbackRef.current = onResize;
1135
+ }, [onResize]);
1136
+ (0, import_react5.useEffect)(() => {
1137
+ const targetElm = target && "current" in target ? target.current : target;
1138
+ if (!targetElm || resizeObserverRef.current) {
1139
+ return;
1140
+ }
1141
+ resizeObserverRef.current = new ResizeObserver(([entry]) => {
1142
+ const { inlineSize: width, blockSize: height } = entry?.borderBoxSize?.[0] ?? {};
1143
+ resizeCallbackRef.current?.(entry);
1144
+ setSize({ width, height });
1145
+ });
1146
+ resizeObserverRef.current.observe(targetElm);
1147
+ return () => {
1148
+ resizeObserverRef.current && resizeObserverRef.current.unobserve(targetElm);
1149
+ };
1150
+ }, [target, resizeObserverRef, resizeCallbackRef]);
1151
+ return size;
1152
+ };
1153
+
1154
+ // src/tabs/TabsList.tsx
1155
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1156
+ var TabsList = ({
1157
+ /**
1158
+ * Default Radix Primitive values
1159
+ * see https://www.radix-ui.com/docs/primitives/components/tabs#list
1160
+ */
1161
+ asChild = false,
1162
+ loop = false,
1163
+ children,
1164
+ className,
1165
+ ref,
1166
+ ...rest
1167
+ }) => {
1168
+ const wrapperRef = (0, import_react6.useRef)(null);
1169
+ const innerRef = (0, import_react6.useRef)(null);
1170
+ const listRef = ref || innerRef;
1171
+ const { orientation } = useTabsContext();
1172
+ const { width } = useResizeObserver(wrapperRef);
1173
+ const [arrows, setArrows] = (0, import_react6.useState)({
1174
+ prev: "hidden",
1175
+ next: "hidden"
1176
+ });
1177
+ (0, import_react6.useEffect)(() => {
1178
+ if (typeof listRef === "function" || !listRef.current) {
1179
+ return;
1180
+ }
1181
+ if (orientation !== "horizontal") {
1182
+ setArrows({ prev: "hidden", next: "hidden" });
1183
+ } else {
1184
+ setArrows({
1185
+ prev: listRef.current.scrollWidth > listRef.current.clientWidth ? "visible" : "hidden",
1186
+ next: listRef.current.scrollWidth > listRef.current.clientWidth ? "visible" : "hidden"
1187
+ });
1188
+ }
1189
+ }, [orientation, listRef, width]);
1190
+ (0, import_react6.useEffect)(() => {
1191
+ if (typeof listRef === "function" || !listRef.current || arrows.prev === "hidden" || loop) {
1192
+ return;
1193
+ }
1194
+ const toggleArrowsVisibility = (target) => {
1195
+ setArrows({
1196
+ prev: target.scrollLeft > 0 ? "visible" : "disabled",
1197
+ next: target.scrollLeft + target.clientWidth < target.scrollWidth ? "visible" : "disabled"
1198
+ });
1199
+ };
1200
+ const currentList = listRef.current;
1201
+ toggleArrowsVisibility(currentList);
1202
+ currentList.addEventListener(
1203
+ "scroll",
1204
+ ({ target }) => toggleArrowsVisibility(target)
1205
+ );
1206
+ return () => currentList.removeEventListener(
1207
+ "scroll",
1208
+ ({ target }) => toggleArrowsVisibility(target)
1209
+ );
1210
+ }, [listRef, arrows.prev, loop]);
1211
+ const handlePrevClick = () => {
1212
+ if (typeof listRef === "function" || !listRef.current) {
1213
+ return;
1214
+ }
1215
+ const shouldLoopForward = loop && listRef.current.scrollLeft <= 0;
1216
+ listRef.current.scrollTo({
1217
+ left: shouldLoopForward ? listRef.current.scrollLeft + listRef.current.scrollWidth - listRef.current.clientWidth : listRef.current.scrollLeft - listRef.current.clientWidth,
1218
+ behavior: "smooth"
1219
+ });
1220
+ };
1221
+ const handleNextClick = () => {
1222
+ if (typeof listRef === "function" || !listRef.current) {
1223
+ return;
1224
+ }
1225
+ const shouldLoopBackward = loop && listRef.current.scrollLeft + listRef.current.clientWidth >= listRef.current.scrollWidth;
1226
+ listRef.current.scrollTo({
1227
+ left: shouldLoopBackward ? 0 : listRef.current.scrollLeft + listRef.current.clientWidth,
1228
+ behavior: "smooth"
1229
+ });
1230
+ };
1231
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: wrapperStyles({ className }), ref: wrapperRef, children: [
1232
+ arrows.prev !== "hidden" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1233
+ Button,
1234
+ {
1235
+ shape: "square",
1236
+ intent: "surface",
1237
+ size: "sm",
1238
+ className: navigationArrowStyles(),
1239
+ onClick: handlePrevClick,
1240
+ disabled: arrows.prev === "disabled",
1241
+ "aria-label": "Scroll left",
1242
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ArrowVerticalLeft.ArrowVerticalLeft, {}) })
1243
+ }
1244
+ ),
1245
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1246
+ import_radix_ui4.Tabs.List,
1247
+ {
1248
+ "data-spark-component": "tabs-list",
1249
+ ref: listRef,
1250
+ className: listStyles(),
1251
+ asChild,
1252
+ loop,
1253
+ ...rest,
1254
+ children
1255
+ }
1256
+ ),
1257
+ arrows.next !== "hidden" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1258
+ Button,
1259
+ {
1260
+ shape: "square",
1261
+ intent: "surface",
1262
+ size: "sm",
1263
+ className: navigationArrowStyles(),
1264
+ onClick: handleNextClick,
1265
+ disabled: arrows.next === "disabled",
1266
+ "aria-label": "Scroll right",
1267
+ children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(Icon, { children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_ArrowVerticalRight.ArrowVerticalRight, {}) })
1268
+ }
1269
+ )
1270
+ ] });
1271
+ };
1272
+ TabsList.displayName = "Tabs.List";
1273
+
1274
+ // src/tabs/TabsTrigger.tsx
1275
+ var import_radix_ui5 = require("radix-ui");
1276
+
1277
+ // src/tabs/TabsTrigger.styles.ts
1278
+ var import_internal_utils9 = require("@spark-ui/internal-utils");
1279
+ var import_class_variance_authority8 = require("class-variance-authority");
1280
+ var triggerVariants = (0, import_class_variance_authority8.cva)(
1281
+ [
1282
+ "px-md",
1283
+ "relative flex flex-none items-center",
1284
+ "border-outline",
1285
+ "hover:not-disabled:bg-surface-hovered",
1286
+ "after:absolute",
1287
+ "data-[state=active]:font-bold",
1288
+ "data-[state=inactive]:not-disabled:cursor-pointer",
1289
+ "data-[orientation=horizontal]:border-b-sm data-[orientation=horizontal]:after:inset-x-0 data-[orientation=horizontal]:after:bottom-[-1px] data-[orientation=horizontal]:after:h-sz-2",
1290
+ "data-[orientation=vertical]:border-r-sm data-[orientation=vertical]:after:inset-y-0 data-[orientation=vertical]:after:right-[-1px] data-[orientation=vertical]:after:w-sz-2",
1291
+ "focus-visible:border-none focus-visible:bg-surface-hovered focus-visible:u-outline-inset",
1292
+ "disabled:cursor-not-allowed disabled:opacity-dim-3",
1293
+ "gap-md [&>*:first-child]:ml-md [&>*:last-child]:mr-md",
1294
+ "[&>svg:last-child:first-child]:mx-auto"
1295
+ ],
1296
+ {
1297
+ variants: {
1298
+ /**
1299
+ * Change the color scheme of the tabs
1300
+ * @default basic
1301
+ */
1302
+ intent: (0, import_internal_utils9.makeVariants)({
1303
+ main: ["data-[state=active]:text-main data-[state=active]:after:bg-main"],
1304
+ support: ["data-[state=active]:text-support data-[state=active]:after:bg-support"],
1305
+ basic: ["data-[state=active]:text-basic data-[state=active]:after:bg-basic"]
1306
+ }),
1307
+ /**
1308
+ * Change the size of the tabs
1309
+ * @default md
1310
+ */
1311
+ size: {
1312
+ xs: ["h-sz-32 min-w-sz-32 text-caption"],
1313
+ sm: ["h-sz-36 min-w-sz-36 text-body-2"],
1314
+ md: ["h-sz-40 min-w-sz-40 text-body-1"]
1315
+ }
1316
+ },
1317
+ defaultVariants: {
1318
+ intent: "basic",
1319
+ size: "md"
1320
+ }
1321
+ }
1322
+ );
1323
+
1324
+ // src/tabs/TabsTrigger.tsx
1325
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1326
+ var TabsTrigger = ({
1327
+ /**
1328
+ * Default Radix Primitive values
1329
+ * see https://www.radix-ui.com/docs/primitives/components/tabs#trigger
1330
+ */
1331
+ asChild = false,
1332
+ value,
1333
+ disabled = false,
1334
+ children,
1335
+ className,
1336
+ ref,
1337
+ ...rest
1338
+ }) => {
1339
+ const { intent, size } = useTabsContext();
1340
+ const scrollToFocusedElement = ({ target }) => target.scrollIntoView({
1341
+ behavior: "smooth",
1342
+ block: "nearest",
1343
+ inline: "nearest"
1344
+ });
1345
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1346
+ import_radix_ui5.Tabs.Trigger,
1347
+ {
1348
+ "data-spark-component": "tabs-trigger",
1349
+ ref,
1350
+ className: triggerVariants({ intent, size, className }),
1351
+ asChild,
1352
+ disabled,
1353
+ value,
1354
+ onFocus: scrollToFocusedElement,
1355
+ ...rest,
1356
+ children
1357
+ }
1358
+ );
1359
+ };
1360
+ TabsTrigger.displayName = "Tabs.Trigger";
1361
+
1362
+ // src/tabs/index.ts
1363
+ var Tabs2 = Object.assign(Tabs, {
1364
+ List: TabsList,
1365
+ Trigger: TabsTrigger,
1366
+ Content: TabsContent
1367
+ });
1368
+ Tabs2.displayName = "Tabs";
1369
+ TabsList.displayName = "Tabs.List";
1370
+ TabsTrigger.displayName = "Tabs.Trigger";
1371
+ TabsContent.displayName = "Tabs.Content";
1372
+ // Annotate the CommonJS export names for ESM import in node:
1373
+ 0 && (module.exports = {
1374
+ Tabs
1375
+ });
1376
+ //# sourceMappingURL=index.js.map