@spark-ui/components 10.0.13 → 10.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.
@@ -0,0 +1,1242 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/avatar/index.ts
31
+ var avatar_exports = {};
32
+ __export(avatar_exports, {
33
+ Avatar: () => AvatarComponent
34
+ });
35
+ module.exports = __toCommonJS(avatar_exports);
36
+
37
+ // src/avatar/Avatar.tsx
38
+ var import_class_variance_authority = require("class-variance-authority");
39
+ var React2 = __toESM(require("react"));
40
+
41
+ // src/slot/Slot.tsx
42
+ var import_radix_ui = require("radix-ui");
43
+ var import_react = require("react");
44
+ var import_jsx_runtime = require("react/jsx-runtime");
45
+ var Slottable = import_radix_ui.Slot.Slottable;
46
+ var Slot = ({ ref, ...props }) => {
47
+ return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
48
+ };
49
+ var wrapPolymorphicSlot = (asChild, children, callback) => {
50
+ if (!asChild) return callback(children);
51
+ return (0, import_react.isValidElement)(children) ? (0, import_react.cloneElement)(
52
+ children,
53
+ void 0,
54
+ callback(children.props.children)
55
+ ) : null;
56
+ };
57
+
58
+ // src/avatar/context.ts
59
+ var React = __toESM(require("react"));
60
+ var AvatarContext = React.createContext(void 0);
61
+ var useAvatarContext = () => {
62
+ const context = React.useContext(AvatarContext);
63
+ if (!context) {
64
+ throw new Error("useAvatarContext must be used within an Avatar component");
65
+ }
66
+ return context;
67
+ };
68
+
69
+ // src/avatar/Avatar.tsx
70
+ var import_jsx_runtime2 = require("react/jsx-runtime");
71
+ var sizeMap = {
72
+ xs: 24,
73
+ sm: 32,
74
+ md: 40,
75
+ lg: 56,
76
+ xl: 64,
77
+ // default
78
+ "2xl": 96
79
+ };
80
+ var Avatar = React2.forwardRef(
81
+ ({
82
+ className,
83
+ size = "xl",
84
+ isOnline = false,
85
+ onlineText,
86
+ username,
87
+ asChild,
88
+ children,
89
+ design = "circle",
90
+ ...props
91
+ }, ref) => {
92
+ const Comp = asChild ? Slot : "div";
93
+ const contextValue = React2.useMemo(
94
+ () => ({
95
+ size,
96
+ isOnline,
97
+ onlineText,
98
+ username,
99
+ design,
100
+ pixelSize: sizeMap[size]
101
+ }),
102
+ [size, isOnline, username, design, onlineText]
103
+ );
104
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AvatarContext.Provider, { value: contextValue, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
105
+ Comp,
106
+ {
107
+ ref,
108
+ style: {
109
+ width: sizeMap[size],
110
+ height: sizeMap[size]
111
+ },
112
+ "data-spark-component": "avatar",
113
+ className: (0, import_class_variance_authority.cx)("relative inline-flex items-center justify-center", className),
114
+ ...props,
115
+ children
116
+ }
117
+ ) });
118
+ }
119
+ );
120
+ Avatar.displayName = "Avatar";
121
+
122
+ // src/avatar/AvatarImage.tsx
123
+ var import_class_variance_authority2 = require("class-variance-authority");
124
+ var import_react2 = require("react");
125
+ var import_jsx_runtime3 = require("react/jsx-runtime");
126
+ var AvatarImage = ({ className, asChild, src, ...props }) => {
127
+ const { username, isOnline, onlineText } = useAvatarContext();
128
+ const Comp = asChild ? Slot : "img";
129
+ const [isVisible, setIsVisible] = (0, import_react2.useState)(false);
130
+ const accessibleName = isOnline && onlineText ? `${username} (${onlineText})` : username;
131
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
132
+ Comp,
133
+ {
134
+ "aria-hidden": true,
135
+ className: (0, import_class_variance_authority2.cx)(
136
+ "absolute inset-0 size-full",
137
+ "object-cover",
138
+ { "transition-all duration-300 group-hover:scale-120": props.onClick },
139
+ "focus-visible:u-outline",
140
+ isVisible ? "block" : "hidden",
141
+ className
142
+ ),
143
+ alt: accessibleName,
144
+ src,
145
+ onLoad: () => {
146
+ setIsVisible(true);
147
+ },
148
+ ...props
149
+ }
150
+ );
151
+ };
152
+ AvatarImage.displayName = "AvatarImage";
153
+
154
+ // src/avatar/AvatarAction.tsx
155
+ var import_PenOutline = require("@spark-ui/icons/PenOutline");
156
+ var import_class_variance_authority8 = require("class-variance-authority");
157
+
158
+ // src/icon/Icon.tsx
159
+ var import_react3 = require("react");
160
+
161
+ // src/visually-hidden/VisuallyHidden.tsx
162
+ var import_jsx_runtime4 = require("react/jsx-runtime");
163
+ var VisuallyHidden = ({ asChild = false, ref, ...props }) => {
164
+ const Component = asChild ? Slot : "span";
165
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
166
+ Component,
167
+ {
168
+ ...props,
169
+ ref,
170
+ style: {
171
+ // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
172
+ position: "absolute",
173
+ border: 0,
174
+ width: 1,
175
+ height: 1,
176
+ padding: 0,
177
+ margin: -1,
178
+ overflow: "hidden",
179
+ clip: "rect(0, 0, 0, 0)",
180
+ whiteSpace: "nowrap",
181
+ wordWrap: "normal",
182
+ ...props.style
183
+ }
184
+ }
185
+ );
186
+ };
187
+ VisuallyHidden.displayName = "VisuallyHidden";
188
+
189
+ // src/icon/Icon.styles.tsx
190
+ var import_internal_utils = require("@spark-ui/internal-utils");
191
+ var import_class_variance_authority3 = require("class-variance-authority");
192
+ var iconStyles = (0, import_class_variance_authority3.cva)(["fill-current shrink-0"], {
193
+ variants: {
194
+ /**
195
+ * Color scheme of the icon.
196
+ */
197
+ intent: (0, import_internal_utils.makeVariants)({
198
+ current: ["text-current"],
199
+ main: ["text-main"],
200
+ support: ["text-support"],
201
+ accent: ["text-accent"],
202
+ basic: ["text-basic"],
203
+ success: ["text-success"],
204
+ alert: ["text-alert"],
205
+ error: ["text-error"],
206
+ info: ["text-info"],
207
+ neutral: ["text-neutral"]
208
+ }),
209
+ /**
210
+ * Sets the size of the icon.
211
+ */
212
+ size: (0, import_internal_utils.makeVariants)({
213
+ current: ["u-current-font-size"],
214
+ sm: ["w-sz-16", "h-sz-16"],
215
+ md: ["w-sz-24", "h-sz-24"],
216
+ lg: ["w-sz-32", "h-sz-32"],
217
+ xl: ["w-sz-40", "h-sz-40"]
218
+ })
219
+ }
220
+ });
221
+
222
+ // src/icon/Icon.tsx
223
+ var import_jsx_runtime5 = require("react/jsx-runtime");
224
+ var Icon = ({
225
+ label,
226
+ className,
227
+ size = "current",
228
+ intent = "current",
229
+ children,
230
+ ...others
231
+ }) => {
232
+ const child = import_react3.Children.only(children);
233
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
234
+ (0, import_react3.cloneElement)(child, {
235
+ className: iconStyles({ className, size, intent }),
236
+ "data-spark-component": "icon",
237
+ "aria-hidden": "true",
238
+ focusable: "false",
239
+ ...others
240
+ }),
241
+ label && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(VisuallyHidden, { children: label })
242
+ ] });
243
+ };
244
+ Icon.displayName = "Icon";
245
+
246
+ // src/button/Button.tsx
247
+ var import_class_variance_authority6 = require("class-variance-authority");
248
+ var import_react4 = require("react");
249
+
250
+ // src/spinner/Spinner.styles.tsx
251
+ var import_internal_utils2 = require("@spark-ui/internal-utils");
252
+ var import_class_variance_authority4 = require("class-variance-authority");
253
+ var defaultVariants = {
254
+ intent: "current",
255
+ size: "current",
256
+ isBackgroundVisible: false
257
+ };
258
+ var spinnerStyles = (0, import_class_variance_authority4.cva)(
259
+ ["inline-block", "border-solid", "rounded-full", "border-md", "animate-spin"],
260
+ {
261
+ variants: {
262
+ /**
263
+ * 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.
264
+ */
265
+ size: {
266
+ current: ["u-current-font-size"],
267
+ sm: ["w-sz-20", "h-sz-20"],
268
+ md: ["w-sz-28", "h-sz-28"],
269
+ full: ["w-full", "h-full"]
270
+ },
271
+ /**
272
+ * Color scheme of the spinner.
273
+ */
274
+ intent: (0, import_internal_utils2.makeVariants)({
275
+ current: ["border-current"],
276
+ main: ["border-main"],
277
+ support: ["border-support"],
278
+ accent: ["border-accent"],
279
+ basic: ["border-basic"],
280
+ success: ["border-success"],
281
+ alert: ["border-alert"],
282
+ error: ["border-error"],
283
+ info: ["border-info"],
284
+ neutral: ["border-neutral"]
285
+ }),
286
+ /**
287
+ * Size of the button.
288
+ */
289
+ isBackgroundVisible: {
290
+ true: ["border-b-neutral-container", "border-l-neutral-container"],
291
+ false: ["border-b-transparent", "border-l-transparent"]
292
+ }
293
+ },
294
+ defaultVariants
295
+ }
296
+ );
297
+
298
+ // src/spinner/Spinner.tsx
299
+ var import_jsx_runtime6 = require("react/jsx-runtime");
300
+ var Spinner = ({
301
+ className,
302
+ size = "current",
303
+ intent = "current",
304
+ label,
305
+ isBackgroundVisible,
306
+ ref,
307
+ ...others
308
+ }) => {
309
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
310
+ "span",
311
+ {
312
+ role: "status",
313
+ "data-spark-component": "spinner",
314
+ ref,
315
+ className: spinnerStyles({ className, size, intent, isBackgroundVisible }),
316
+ ...others,
317
+ children: label && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(VisuallyHidden, { children: label })
318
+ }
319
+ );
320
+ };
321
+
322
+ // src/button/Button.styles.tsx
323
+ var import_internal_utils8 = require("@spark-ui/internal-utils");
324
+ var import_class_variance_authority5 = require("class-variance-authority");
325
+
326
+ // src/button/variants/filled.ts
327
+ var import_internal_utils3 = require("@spark-ui/internal-utils");
328
+ var filledVariants = [
329
+ // Main
330
+ {
331
+ intent: "main",
332
+ design: "filled",
333
+ class: (0, import_internal_utils3.tw)([
334
+ "bg-main",
335
+ "text-on-main",
336
+ "hover:bg-main-hovered",
337
+ "enabled:active:bg-main-hovered",
338
+ "focus-visible:bg-main-hovered"
339
+ ])
340
+ },
341
+ // Support
342
+ {
343
+ intent: "support",
344
+ design: "filled",
345
+ class: (0, import_internal_utils3.tw)([
346
+ "bg-support",
347
+ "text-on-support",
348
+ "hover:bg-support-hovered",
349
+ "enabled:active:bg-support-hovered",
350
+ "focus-visible:bg-support-hovered"
351
+ ])
352
+ },
353
+ // Accent
354
+ {
355
+ intent: "accent",
356
+ design: "filled",
357
+ class: (0, import_internal_utils3.tw)([
358
+ "bg-accent",
359
+ "text-on-accent",
360
+ "hover:bg-accent-hovered",
361
+ "enabled:active:bg-accent-hovered",
362
+ "focus-visible:bg-accent-hovered"
363
+ ])
364
+ },
365
+ // Basic
366
+ {
367
+ intent: "basic",
368
+ design: "filled",
369
+ class: (0, import_internal_utils3.tw)([
370
+ "bg-basic",
371
+ "text-on-basic",
372
+ "hover:bg-basic-hovered",
373
+ "enabled:active:bg-basic-hovered",
374
+ "focus-visible:bg-basic-hovered"
375
+ ])
376
+ },
377
+ // Success
378
+ {
379
+ intent: "success",
380
+ design: "filled",
381
+ class: (0, import_internal_utils3.tw)([
382
+ "bg-success",
383
+ "text-on-success",
384
+ "hover:bg-success-hovered",
385
+ "enabled:active:bg-success-hovered",
386
+ "focus-visible:bg-success-hovered"
387
+ ])
388
+ },
389
+ // Alert
390
+ {
391
+ intent: "alert",
392
+ design: "filled",
393
+ class: (0, import_internal_utils3.tw)([
394
+ "bg-alert",
395
+ "text-on-alert",
396
+ "hover:bg-alert-hovered",
397
+ "enabled:active:bg-alert-hovered",
398
+ "focus-visible:bg-alert-hovered"
399
+ ])
400
+ },
401
+ // Danger
402
+ {
403
+ intent: "danger",
404
+ design: "filled",
405
+ class: (0, import_internal_utils3.tw)([
406
+ "text-on-error bg-error",
407
+ "hover:bg-error-hovered enabled:active:bg-error-hovered",
408
+ "focus-visible:bg-error-hovered"
409
+ ])
410
+ },
411
+ // Info
412
+ {
413
+ intent: "info",
414
+ design: "filled",
415
+ class: (0, import_internal_utils3.tw)([
416
+ "text-on-error bg-info",
417
+ "hover:bg-info-hovered enabled:active:bg-info-hovered",
418
+ "focus-visible:bg-info-hovered"
419
+ ])
420
+ },
421
+ // Neutral
422
+ {
423
+ intent: "neutral",
424
+ design: "filled",
425
+ class: (0, import_internal_utils3.tw)([
426
+ "bg-neutral",
427
+ "text-on-neutral",
428
+ "hover:bg-neutral-hovered",
429
+ "enabled:active:bg-neutral-hovered",
430
+ "focus-visible:bg-neutral-hovered"
431
+ ])
432
+ },
433
+ // Surface
434
+ {
435
+ intent: "surface",
436
+ design: "filled",
437
+ class: (0, import_internal_utils3.tw)([
438
+ "bg-surface",
439
+ "text-on-surface",
440
+ "hover:bg-surface-hovered",
441
+ "enabled:active:bg-surface-hovered",
442
+ "focus-visible:bg-surface-hovered"
443
+ ])
444
+ }
445
+ ];
446
+
447
+ // src/button/variants/ghost.ts
448
+ var import_internal_utils4 = require("@spark-ui/internal-utils");
449
+ var ghostVariants = [
450
+ {
451
+ intent: "main",
452
+ design: "ghost",
453
+ class: (0, import_internal_utils4.tw)([
454
+ "text-main",
455
+ "hover:bg-main/dim-5",
456
+ "enabled:active:bg-main/dim-5",
457
+ "focus-visible:bg-main/dim-5"
458
+ ])
459
+ },
460
+ {
461
+ intent: "support",
462
+ design: "ghost",
463
+ class: (0, import_internal_utils4.tw)([
464
+ "text-support",
465
+ "hover:bg-support/dim-5",
466
+ "enabled:active:bg-support/dim-5",
467
+ "focus-visible:bg-support/dim-5"
468
+ ])
469
+ },
470
+ {
471
+ intent: "accent",
472
+ design: "ghost",
473
+ class: (0, import_internal_utils4.tw)([
474
+ "text-accent",
475
+ "hover:bg-accent/dim-5",
476
+ "enabled:active:bg-accent/dim-5",
477
+ "focus-visible:bg-accent/dim-5"
478
+ ])
479
+ },
480
+ {
481
+ intent: "basic",
482
+ design: "ghost",
483
+ class: (0, import_internal_utils4.tw)([
484
+ "text-basic",
485
+ "hover:bg-basic/dim-5",
486
+ "enabled:active:bg-basic/dim-5",
487
+ "focus-visible:bg-basic/dim-5"
488
+ ])
489
+ },
490
+ {
491
+ intent: "success",
492
+ design: "ghost",
493
+ class: (0, import_internal_utils4.tw)([
494
+ "text-success",
495
+ "hover:bg-success/dim-5",
496
+ "enabled:active:bg-success/dim-5",
497
+ "focus-visible:bg-success/dim-5"
498
+ ])
499
+ },
500
+ {
501
+ intent: "alert",
502
+ design: "ghost",
503
+ class: (0, import_internal_utils4.tw)([
504
+ "text-alert",
505
+ "hover:bg-alert/dim-5",
506
+ "enabled:active:bg-alert/dim-5",
507
+ "focus-visible:bg-alert/dim-5"
508
+ ])
509
+ },
510
+ {
511
+ intent: "danger",
512
+ design: "ghost",
513
+ class: (0, import_internal_utils4.tw)([
514
+ "text-error",
515
+ "hover:bg-error/dim-5",
516
+ "enabled:active:bg-error/dim-5",
517
+ "focus-visible:bg-error/dim-5"
518
+ ])
519
+ },
520
+ {
521
+ intent: "info",
522
+ design: "ghost",
523
+ class: (0, import_internal_utils4.tw)([
524
+ "text-info",
525
+ "hover:bg-info/dim-5",
526
+ "enabled:active:bg-info/dim-5",
527
+ "focus-visible:bg-info/dim-5"
528
+ ])
529
+ },
530
+ {
531
+ intent: "neutral",
532
+ design: "ghost",
533
+ class: (0, import_internal_utils4.tw)([
534
+ "text-neutral",
535
+ "hover:bg-neutral/dim-5",
536
+ "enabled:active:bg-neutral/dim-5",
537
+ "focus-visible:bg-neutral/dim-5"
538
+ ])
539
+ },
540
+ {
541
+ intent: "surface",
542
+ design: "ghost",
543
+ class: (0, import_internal_utils4.tw)([
544
+ "text-surface",
545
+ "hover:bg-surface/dim-5",
546
+ "enabled:active:bg-surface/dim-5",
547
+ "focus-visible:bg-surface/dim-5"
548
+ ])
549
+ }
550
+ ];
551
+
552
+ // src/button/variants/outlined.ts
553
+ var import_internal_utils5 = require("@spark-ui/internal-utils");
554
+ var outlinedVariants = [
555
+ {
556
+ intent: "main",
557
+ design: "outlined",
558
+ class: (0, import_internal_utils5.tw)([
559
+ "hover:bg-main/dim-5",
560
+ "enabled:active:bg-main/dim-5",
561
+ "focus-visible:bg-main/dim-5",
562
+ "text-main"
563
+ ])
564
+ },
565
+ {
566
+ intent: "support",
567
+ design: "outlined",
568
+ class: (0, import_internal_utils5.tw)([
569
+ "hover:bg-support/dim-5",
570
+ "enabled:active:bg-support/dim-5",
571
+ "focus-visible:bg-support/dim-5",
572
+ "text-support"
573
+ ])
574
+ },
575
+ {
576
+ intent: "accent",
577
+ design: "outlined",
578
+ class: (0, import_internal_utils5.tw)([
579
+ "hover:bg-accent/dim-5",
580
+ "enabled:active:bg-accent/dim-5",
581
+ "focus-visible:bg-accent/dim-5",
582
+ "text-accent"
583
+ ])
584
+ },
585
+ {
586
+ intent: "basic",
587
+ design: "outlined",
588
+ class: (0, import_internal_utils5.tw)([
589
+ "hover:bg-basic/dim-5",
590
+ "enabled:active:bg-basic/dim-5",
591
+ "focus-visible:bg-basic/dim-5",
592
+ "text-basic"
593
+ ])
594
+ },
595
+ {
596
+ intent: "success",
597
+ design: "outlined",
598
+ class: (0, import_internal_utils5.tw)([
599
+ "hover:bg-success/dim-5",
600
+ "enabled:active:bg-success/dim-5",
601
+ "focus-visible:bg-success/dim-5",
602
+ "text-success"
603
+ ])
604
+ },
605
+ {
606
+ intent: "alert",
607
+ design: "outlined",
608
+ class: (0, import_internal_utils5.tw)([
609
+ "hover:bg-alert/dim-5",
610
+ "enabled:active:bg-alert/dim-5",
611
+ "focus-visible:bg-alert/dim-5",
612
+ "text-alert"
613
+ ])
614
+ },
615
+ {
616
+ intent: "danger",
617
+ design: "outlined",
618
+ class: (0, import_internal_utils5.tw)([
619
+ "hover:bg-error/dim-5",
620
+ "enabled:active:bg-error/dim-5",
621
+ "focus-visible:bg-error/dim-5",
622
+ "text-error"
623
+ ])
624
+ },
625
+ {
626
+ intent: "info",
627
+ design: "outlined",
628
+ class: (0, import_internal_utils5.tw)([
629
+ "hover:bg-info/dim-5",
630
+ "enabled:active:bg-info/dim-5",
631
+ "focus-visible:bg-info/dim-5",
632
+ "text-info"
633
+ ])
634
+ },
635
+ {
636
+ intent: "neutral",
637
+ design: "outlined",
638
+ class: (0, import_internal_utils5.tw)([
639
+ "hover:bg-neutral/dim-5",
640
+ "enabled:active:bg-neutral/dim-5",
641
+ "focus-visible:bg-neutral/dim-5",
642
+ "text-neutral"
643
+ ])
644
+ },
645
+ {
646
+ intent: "surface",
647
+ design: "outlined",
648
+ class: (0, import_internal_utils5.tw)([
649
+ "hover:bg-surface/dim-5",
650
+ "enabled:active:bg-surface/dim-5",
651
+ "focus-visible:bg-surface/dim-5",
652
+ "text-surface"
653
+ ])
654
+ }
655
+ ];
656
+
657
+ // src/button/variants/tinted.ts
658
+ var import_internal_utils6 = require("@spark-ui/internal-utils");
659
+ var tintedVariants = [
660
+ {
661
+ intent: "main",
662
+ design: "tinted",
663
+ class: (0, import_internal_utils6.tw)([
664
+ "bg-main-container",
665
+ "text-on-main-container",
666
+ "hover:bg-main-container-hovered",
667
+ "enabled:active:bg-main-container-hovered",
668
+ "focus-visible:bg-main-container-hovered"
669
+ ])
670
+ },
671
+ {
672
+ intent: "support",
673
+ design: "tinted",
674
+ class: (0, import_internal_utils6.tw)([
675
+ "bg-support-container",
676
+ "text-on-support-container",
677
+ "hover:bg-support-container-hovered",
678
+ "enabled:active:bg-support-container-hovered",
679
+ "focus-visible:bg-support-container-hovered"
680
+ ])
681
+ },
682
+ {
683
+ intent: "accent",
684
+ design: "tinted",
685
+ class: (0, import_internal_utils6.tw)([
686
+ "bg-accent-container",
687
+ "text-on-accent-container",
688
+ "hover:bg-accent-container-hovered",
689
+ "enabled:active:bg-accent-container-hovered",
690
+ "focus-visible:bg-accent-container-hovered"
691
+ ])
692
+ },
693
+ {
694
+ intent: "basic",
695
+ design: "tinted",
696
+ class: (0, import_internal_utils6.tw)([
697
+ "bg-basic-container",
698
+ "text-on-basic-container",
699
+ "hover:bg-basic-container-hovered",
700
+ "enabled:active:bg-basic-container-hovered",
701
+ "focus-visible:bg-basic-container-hovered"
702
+ ])
703
+ },
704
+ {
705
+ intent: "success",
706
+ design: "tinted",
707
+ class: (0, import_internal_utils6.tw)([
708
+ "bg-success-container",
709
+ "text-on-success-container",
710
+ "hover:bg-success-container-hovered",
711
+ "enabled:active:bg-success-container-hovered",
712
+ "focus-visible:bg-success-container-hovered"
713
+ ])
714
+ },
715
+ {
716
+ intent: "alert",
717
+ design: "tinted",
718
+ class: (0, import_internal_utils6.tw)([
719
+ "bg-alert-container",
720
+ "text-on-alert-container",
721
+ "hover:bg-alert-container-hovered",
722
+ "enabled:active:bg-alert-container-hovered",
723
+ "focus-visible:bg-alert-container-hovered"
724
+ ])
725
+ },
726
+ {
727
+ intent: "danger",
728
+ design: "tinted",
729
+ class: (0, import_internal_utils6.tw)([
730
+ "bg-error-container",
731
+ "text-on-error-container",
732
+ "hover:bg-error-container-hovered",
733
+ "enabled:active:bg-error-container-hovered",
734
+ "focus-visible:bg-error-container-hovered"
735
+ ])
736
+ },
737
+ {
738
+ intent: "info",
739
+ design: "tinted",
740
+ class: (0, import_internal_utils6.tw)([
741
+ "bg-info-container",
742
+ "text-on-info-container",
743
+ "hover:bg-info-container-hovered",
744
+ "enabled:active:bg-info-container-hovered",
745
+ "focus-visible:bg-info-container-hovered"
746
+ ])
747
+ },
748
+ {
749
+ intent: "neutral",
750
+ design: "tinted",
751
+ class: (0, import_internal_utils6.tw)([
752
+ "bg-neutral-container",
753
+ "text-on-neutral-container",
754
+ "hover:bg-neutral-container-hovered",
755
+ "enabled:active:bg-neutral-container-hovered",
756
+ "focus-visible:bg-neutral-container-hovered"
757
+ ])
758
+ },
759
+ {
760
+ intent: "surface",
761
+ design: "tinted",
762
+ class: (0, import_internal_utils6.tw)([
763
+ "bg-surface",
764
+ "text-on-surface",
765
+ "hover:bg-surface-hovered",
766
+ "enabled:active:bg-surface-hovered",
767
+ "focus-visible:bg-surface-hovered"
768
+ ])
769
+ }
770
+ ];
771
+
772
+ // src/button/variants/contrast.ts
773
+ var import_internal_utils7 = require("@spark-ui/internal-utils");
774
+ var contrastVariants = [
775
+ {
776
+ intent: "main",
777
+ design: "contrast",
778
+ class: (0, import_internal_utils7.tw)([
779
+ "text-main",
780
+ "hover:bg-main-container-hovered",
781
+ "enabled:active:bg-main-container-hovered",
782
+ "focus-visible:bg-main-container-hovered"
783
+ ])
784
+ },
785
+ {
786
+ intent: "support",
787
+ design: "contrast",
788
+ class: (0, import_internal_utils7.tw)([
789
+ "text-support",
790
+ "hover:bg-support-container-hovered",
791
+ "enabled:active:bg-support-container-hovered",
792
+ "focus-visible:bg-support-container-hovered"
793
+ ])
794
+ },
795
+ {
796
+ intent: "accent",
797
+ design: "contrast",
798
+ class: (0, import_internal_utils7.tw)([
799
+ "text-accent",
800
+ "hover:bg-accent-container-hovered",
801
+ "enabled:active:bg-accent-container-hovered",
802
+ "focus-visible:bg-accent-container-hovered"
803
+ ])
804
+ },
805
+ {
806
+ intent: "basic",
807
+ design: "contrast",
808
+ class: (0, import_internal_utils7.tw)([
809
+ "text-basic",
810
+ "hover:bg-basic-container-hovered",
811
+ "enabled:active:bg-basic-container-hovered",
812
+ "focus-visible:bg-basic-container-hovered"
813
+ ])
814
+ },
815
+ {
816
+ intent: "success",
817
+ design: "contrast",
818
+ class: (0, import_internal_utils7.tw)([
819
+ "text-success",
820
+ "hover:bg-success-container-hovered",
821
+ "enabled:active:bg-success-container-hovered",
822
+ "focus-visible:bg-success-container-hovered"
823
+ ])
824
+ },
825
+ {
826
+ intent: "alert",
827
+ design: "contrast",
828
+ class: (0, import_internal_utils7.tw)([
829
+ "text-alert",
830
+ "hover:bg-alert-container-hovered",
831
+ "enabled:active:bg-alert-container-hovered",
832
+ "focus-visible:bg-alert-container-hovered"
833
+ ])
834
+ },
835
+ {
836
+ intent: "danger",
837
+ design: "contrast",
838
+ class: (0, import_internal_utils7.tw)([
839
+ "text-error",
840
+ "hover:bg-error-container-hovered",
841
+ "enabled:active:bg-error-container-hovered",
842
+ "focus-visible:bg-error-container-hovered"
843
+ ])
844
+ },
845
+ {
846
+ intent: "info",
847
+ design: "contrast",
848
+ class: (0, import_internal_utils7.tw)([
849
+ "text-info",
850
+ "hover:bg-info-container-hovered",
851
+ "enabled:active:bg-info-container-hovered",
852
+ "focus-visible:bg-info-container-hovered"
853
+ ])
854
+ },
855
+ {
856
+ intent: "neutral",
857
+ design: "contrast",
858
+ class: (0, import_internal_utils7.tw)([
859
+ "text-neutral",
860
+ "hover:bg-neutral-container-hovered",
861
+ "enabled:active:bg-neutral-container-hovered",
862
+ "focus-visible:bg-neutral-container-hovered"
863
+ ])
864
+ },
865
+ {
866
+ intent: "surface",
867
+ design: "contrast",
868
+ class: (0, import_internal_utils7.tw)([
869
+ "text-on-surface",
870
+ "hover:bg-surface-hovered",
871
+ "enabled:active:bg-surface-hovered",
872
+ "focus-visible:bg-surface-hovered"
873
+ ])
874
+ }
875
+ ];
876
+
877
+ // src/button/Button.styles.tsx
878
+ var buttonStyles = (0, import_class_variance_authority5.cva)(
879
+ [
880
+ "u-shadow-border-transition",
881
+ "box-border inline-flex items-center justify-center gap-md whitespace-nowrap",
882
+ "px-lg",
883
+ "text-body-1 font-bold",
884
+ "focus-visible:u-outline"
885
+ ],
886
+ {
887
+ variants: {
888
+ /**
889
+ * Main style of the button.
890
+ *
891
+ * - `filled`: Button will be plain.
892
+ *
893
+ * - `outlined`: Button will be transparent with an outline.
894
+ *
895
+ * - `tinted`: Button will be filled but using a lighter color scheme.
896
+ *
897
+ * - `ghost`: Button will look like a link. No borders, plain text.
898
+ *
899
+ * - `contrast`: Button will be surface filled. No borders, plain text.
900
+ *
901
+ */
902
+ design: (0, import_internal_utils8.makeVariants)({
903
+ filled: [],
904
+ outlined: ["bg-transparent", "border-sm", "border-current"],
905
+ tinted: [],
906
+ ghost: [],
907
+ contrast: ["bg-surface"]
908
+ }),
909
+ /**
910
+ * Color scheme of the button.
911
+ */
912
+ intent: (0, import_internal_utils8.makeVariants)({
913
+ main: [],
914
+ support: [],
915
+ accent: [],
916
+ basic: [],
917
+ success: [],
918
+ alert: [],
919
+ danger: [],
920
+ info: [],
921
+ neutral: [],
922
+ surface: []
923
+ }),
924
+ /**
925
+ * Size of the button.
926
+ */
927
+ size: (0, import_internal_utils8.makeVariants)({
928
+ sm: ["min-w-sz-32", "h-sz-32"],
929
+ md: ["min-w-sz-44", "h-sz-44"],
930
+ lg: ["min-w-sz-56", "h-sz-56"]
931
+ }),
932
+ /**
933
+ * Shape of the button.
934
+ */
935
+ shape: (0, import_internal_utils8.makeVariants)({
936
+ rounded: ["rounded-lg"],
937
+ square: ["rounded-0"],
938
+ pill: ["rounded-full"]
939
+ }),
940
+ /**
941
+ * Disable the button, preventing user interaction and adding opacity.
942
+ */
943
+ disabled: {
944
+ true: ["cursor-not-allowed", "opacity-dim-3"],
945
+ false: ["cursor-pointer"]
946
+ }
947
+ },
948
+ compoundVariants: [
949
+ ...filledVariants,
950
+ ...outlinedVariants,
951
+ ...tintedVariants,
952
+ ...ghostVariants,
953
+ ...contrastVariants
954
+ ],
955
+ defaultVariants: {
956
+ design: "filled",
957
+ intent: "main",
958
+ size: "md",
959
+ shape: "rounded"
960
+ }
961
+ }
962
+ );
963
+
964
+ // src/button/Button.tsx
965
+ var import_jsx_runtime7 = require("react/jsx-runtime");
966
+ var blockedEventHandlers = [
967
+ "onClick",
968
+ "onMouseDown",
969
+ "onMouseUp",
970
+ "onMouseEnter",
971
+ "onMouseLeave",
972
+ "onMouseOver",
973
+ "onMouseOut",
974
+ "onKeyDown",
975
+ "onKeyPress",
976
+ "onKeyUp",
977
+ "onSubmit"
978
+ ];
979
+ var Button = ({
980
+ children,
981
+ design = "filled",
982
+ disabled = false,
983
+ intent = "main",
984
+ isLoading = false,
985
+ loadingLabel,
986
+ loadingText,
987
+ shape = "rounded",
988
+ size = "md",
989
+ asChild,
990
+ className,
991
+ ref,
992
+ ...others
993
+ }) => {
994
+ const Component = asChild ? Slot : "button";
995
+ const shouldNotInteract = !!disabled || isLoading;
996
+ const disabledEventHandlers = (0, import_react4.useMemo)(() => {
997
+ const result = {};
998
+ if (shouldNotInteract) {
999
+ blockedEventHandlers.forEach((eventHandler) => result[eventHandler] = void 0);
1000
+ }
1001
+ return result;
1002
+ }, [shouldNotInteract]);
1003
+ const spinnerProps = {
1004
+ size: "current",
1005
+ className: loadingText ? "inline-block" : "absolute",
1006
+ ...loadingLabel && { "aria-label": loadingLabel }
1007
+ };
1008
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1009
+ Component,
1010
+ {
1011
+ "data-spark-component": "button",
1012
+ ...Component === "button" && { type: "button" },
1013
+ ref,
1014
+ className: buttonStyles({
1015
+ className,
1016
+ design,
1017
+ disabled: shouldNotInteract,
1018
+ intent,
1019
+ shape,
1020
+ size
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_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1031
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { ...spinnerProps }),
1032
+ loadingText && loadingText,
1033
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1034
+ "div",
1035
+ {
1036
+ "aria-hidden": true,
1037
+ className: (0, import_class_variance_authority6.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-button/IconButton.styles.tsx
1049
+ var import_internal_utils9 = require("@spark-ui/internal-utils");
1050
+ var import_class_variance_authority7 = require("class-variance-authority");
1051
+ var iconButtonStyles = (0, import_class_variance_authority7.cva)(["pl-0 pr-0"], {
1052
+ variants: {
1053
+ /**
1054
+ * Sets the size of the icon.
1055
+ */
1056
+ size: (0, import_internal_utils9.makeVariants)({
1057
+ sm: ["text-body-1"],
1058
+ md: ["text-body-1"],
1059
+ lg: ["text-display-3"]
1060
+ })
1061
+ }
1062
+ });
1063
+
1064
+ // src/icon-button/IconButton.tsx
1065
+ var import_jsx_runtime8 = require("react/jsx-runtime");
1066
+ var IconButton = ({
1067
+ design = "filled",
1068
+ disabled = false,
1069
+ intent = "main",
1070
+ shape = "rounded",
1071
+ size = "md",
1072
+ className,
1073
+ ref,
1074
+ ...others
1075
+ }) => {
1076
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1077
+ Button,
1078
+ {
1079
+ ref,
1080
+ className: iconButtonStyles({ size, className }),
1081
+ design,
1082
+ disabled,
1083
+ intent,
1084
+ shape,
1085
+ size,
1086
+ ...others
1087
+ }
1088
+ );
1089
+ };
1090
+ IconButton.displayName = "IconButton";
1091
+
1092
+ // src/avatar/AvatarAction.tsx
1093
+ var import_jsx_runtime9 = require("react/jsx-runtime");
1094
+ var AvatarAction = ({
1095
+ className,
1096
+ children,
1097
+ asChild,
1098
+ angle = 135,
1099
+ ariaLabel,
1100
+ ...props
1101
+ }) => {
1102
+ const Comp = asChild ? Slot : IconButton;
1103
+ const { pixelSize, design } = useAvatarContext();
1104
+ function getBadgePosition(circleSize) {
1105
+ const angleRad = (90 - angle) * Math.PI / 180;
1106
+ const circleRadius = circleSize / 2;
1107
+ return {
1108
+ x: circleRadius + circleRadius * Math.cos(angleRad),
1109
+ y: circleRadius - circleRadius * Math.sin(angleRad)
1110
+ };
1111
+ }
1112
+ const position = getBadgePosition(pixelSize);
1113
+ const isCustomElement = asChild;
1114
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1115
+ Comp,
1116
+ {
1117
+ style: {
1118
+ position: "absolute",
1119
+ ...design === "circle" ? { left: `${position.x}px`, top: `${position.y}px` } : {},
1120
+ ...design === "square" ? { right: "0px", bottom: "0px" } : {}
1121
+ },
1122
+ className: (0, import_class_variance_authority8.cx)(
1123
+ "z-raised",
1124
+ design === "circle" ? "-translate-x-1/2 -translate-y-1/2" : "translate-x-1/4 translate-y-1/4",
1125
+ { "shadow-sm": !isCustomElement },
1126
+ className
1127
+ ),
1128
+ "aria-label": ariaLabel,
1129
+ title: ariaLabel,
1130
+ ...!isCustomElement ? { size: "sm", intent: "support", design: "contrast" } : {},
1131
+ ...props,
1132
+ children: children || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_PenOutline.PenOutline, {}) })
1133
+ }
1134
+ );
1135
+ };
1136
+ AvatarAction.displayName = "AvatarAction";
1137
+
1138
+ // src/avatar/AvatarOnlineBadge.tsx
1139
+ var import_class_variance_authority9 = require("class-variance-authority");
1140
+ var import_jsx_runtime10 = require("react/jsx-runtime");
1141
+ var AvatarOnlineBadge = ({ angle = 135, ...props }) => {
1142
+ const { isOnline, pixelSize, design, onlineText, size } = useAvatarContext();
1143
+ if (!isOnline) return null;
1144
+ function getBadgePosition(circleSize) {
1145
+ const angleRad = (90 - angle) * Math.PI / 180;
1146
+ const circleRadius = circleSize / 2;
1147
+ return {
1148
+ x: circleRadius + circleRadius * Math.cos(angleRad),
1149
+ y: circleRadius - circleRadius * Math.sin(angleRad)
1150
+ };
1151
+ }
1152
+ const badgePosition = getBadgePosition(pixelSize);
1153
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1154
+ "div",
1155
+ {
1156
+ role: "status",
1157
+ "aria-label": onlineText,
1158
+ style: {
1159
+ ...design === "circle" ? { left: `${badgePosition.x}px`, top: `${badgePosition.y}px` } : { right: "0px", bottom: "0px" }
1160
+ },
1161
+ className: (0, import_class_variance_authority9.cx)(
1162
+ "bg-success outline-surface absolute rounded-full",
1163
+ design === "circle" ? "-translate-x-1/2 -translate-y-1/2" : "translate-x-1/4 translate-y-1/4",
1164
+ ["lg", "xl", "2xl"].includes(size) ? (0, import_class_variance_authority9.cx)("size-sz-12 outline-4") : (0, import_class_variance_authority9.cx)("size-sz-8 outline-2")
1165
+ ),
1166
+ ...props
1167
+ }
1168
+ );
1169
+ };
1170
+ AvatarOnlineBadge.displayName = "AvatarOnlineBadge";
1171
+
1172
+ // src/avatar/AvatarUser.tsx
1173
+ var import_class_variance_authority10 = require("class-variance-authority");
1174
+ var import_jsx_runtime11 = require("react/jsx-runtime");
1175
+ var AvatarUser = ({ asChild, children, className, ...props }) => {
1176
+ const { design, isOnline, onlineText, username } = useAvatarContext();
1177
+ const Comp = asChild ? Slot : "div";
1178
+ const accessibleName = isOnline && onlineText ? `${username} (${onlineText})` : username;
1179
+ return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1180
+ Comp,
1181
+ {
1182
+ ...!asChild && { role: "img" },
1183
+ "aria-label": accessibleName,
1184
+ title: accessibleName,
1185
+ className: (0, import_class_variance_authority10.cx)(
1186
+ "group default:border-outline relative size-full overflow-hidden",
1187
+ "focus-visible:u-outline",
1188
+ {
1189
+ "default:rounded-full": design === "circle",
1190
+ "default:rounded-md": design === "square",
1191
+ "hover:opacity-dim-1 cursor-pointer": asChild || props.onClick
1192
+ },
1193
+ className
1194
+ ),
1195
+ ...props,
1196
+ children
1197
+ }
1198
+ );
1199
+ };
1200
+ AvatarUser.displayName = "AvatarUser";
1201
+
1202
+ // src/avatar/AvatarPlaceholder.tsx
1203
+ var import_class_variance_authority11 = require("class-variance-authority");
1204
+ var import_jsx_runtime12 = require("react/jsx-runtime");
1205
+ var AvatarPlaceholder = ({ className, children, ...props }) => {
1206
+ const { size, username } = useAvatarContext();
1207
+ const firstLetter = username?.charAt(0);
1208
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1209
+ "div",
1210
+ {
1211
+ "aria-hidden": true,
1212
+ className: (0, import_class_variance_authority11.cx)(
1213
+ "absolute inset-0 flex size-full items-center justify-center",
1214
+ "default:bg-neutral default:text-on-neutral",
1215
+ {
1216
+ "text-display-1": size === "2xl",
1217
+ "text-display-2": ["xl", "lg"].includes(size),
1218
+ "text-display-3": size === "md",
1219
+ "text-headline-2": size === "sm",
1220
+ "text-body-2 font-bold": size === "xs"
1221
+ },
1222
+ className
1223
+ ),
1224
+ ...props,
1225
+ children: children || firstLetter
1226
+ }
1227
+ );
1228
+ };
1229
+ AvatarPlaceholder.displayName = "AvatarPlaceholder";
1230
+
1231
+ // src/avatar/index.ts
1232
+ var AvatarComponent = Avatar;
1233
+ AvatarComponent.Image = AvatarImage;
1234
+ AvatarComponent.Action = AvatarAction;
1235
+ AvatarComponent.OnlineBadge = AvatarOnlineBadge;
1236
+ AvatarComponent.User = AvatarUser;
1237
+ AvatarComponent.Placeholder = AvatarPlaceholder;
1238
+ // Annotate the CommonJS export names for ESM import in node:
1239
+ 0 && (module.exports = {
1240
+ Avatar
1241
+ });
1242
+ //# sourceMappingURL=index.js.map