@spark-ui/components 10.22.1 → 11.0.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/package.json +5 -5
  2. package/dist/DialogTrigger-woU7vsJi.d.ts +0 -142
  3. package/dist/Input-N8AWWSmt.d.ts +0 -41
  4. package/dist/InputTrailingIcon-ZZx8PoJy.d.ts +0 -20
  5. package/dist/LabelRequiredIndicator-DRnCzHMU.d.ts +0 -19
  6. package/dist/accordion/index.d.ts +0 -73
  7. package/dist/accordion/index.js +0 -325
  8. package/dist/accordion/index.js.map +0 -1
  9. package/dist/alert-dialog/index.d.ts +0 -119
  10. package/dist/alert-dialog/index.js +0 -1554
  11. package/dist/alert-dialog/index.js.map +0 -1
  12. package/dist/avatar/index.d.ts +0 -66
  13. package/dist/avatar/index.js +0 -1303
  14. package/dist/avatar/index.js.map +0 -1
  15. package/dist/badge/index.d.ts +0 -47
  16. package/dist/badge/index.js +0 -122
  17. package/dist/badge/index.js.map +0 -1
  18. package/dist/breadcrumb/index.d.ts +0 -64
  19. package/dist/breadcrumb/index.js +0 -327
  20. package/dist/breadcrumb/index.js.map +0 -1
  21. package/dist/button/index.d.ts +0 -41
  22. package/dist/button/index.js +0 -935
  23. package/dist/button/index.js.map +0 -1
  24. package/dist/card/index.d.ts +0 -61
  25. package/dist/card/index.js +0 -502
  26. package/dist/card/index.js.map +0 -1
  27. package/dist/carousel/index.d.ts +0 -261
  28. package/dist/carousel/index.js +0 -1801
  29. package/dist/carousel/index.js.map +0 -1
  30. package/dist/checkbox/index.d.ts +0 -120
  31. package/dist/checkbox/index.js +0 -511
  32. package/dist/checkbox/index.js.map +0 -1
  33. package/dist/chip/index.d.ts +0 -97
  34. package/dist/chip/index.js +0 -908
  35. package/dist/chip/index.js.map +0 -1
  36. package/dist/collapsible/index.d.ts +0 -43
  37. package/dist/collapsible/index.js +0 -109
  38. package/dist/collapsible/index.js.map +0 -1
  39. package/dist/combobox/index.d.ts +0 -287
  40. package/dist/combobox/index.js +0 -2588
  41. package/dist/combobox/index.js.map +0 -1
  42. package/dist/dialog/index.d.ts +0 -33
  43. package/dist/dialog/index.js +0 -1389
  44. package/dist/dialog/index.js.map +0 -1
  45. package/dist/divider/index.d.ts +0 -61
  46. package/dist/divider/index.js +0 -224
  47. package/dist/divider/index.js.map +0 -1
  48. package/dist/drawer/index.d.ts +0 -152
  49. package/dist/drawer/index.js +0 -1400
  50. package/dist/drawer/index.js.map +0 -1
  51. package/dist/dropdown/index.d.ts +0 -233
  52. package/dist/dropdown/index.js +0 -2051
  53. package/dist/dropdown/index.js.map +0 -1
  54. package/dist/form-field/index.d.ts +0 -186
  55. package/dist/form-field/index.js +0 -553
  56. package/dist/form-field/index.js.map +0 -1
  57. package/dist/icon/index.d.ts +0 -28
  58. package/dist/icon/index.js +0 -127
  59. package/dist/icon/index.js.map +0 -1
  60. package/dist/icon-button/index.d.ts +0 -16
  61. package/dist/icon-button/index.js +0 -980
  62. package/dist/icon-button/index.js.map +0 -1
  63. package/dist/input/index.d.ts +0 -78
  64. package/dist/input/index.js +0 -724
  65. package/dist/input/index.js.map +0 -1
  66. package/dist/kbd/index.d.ts +0 -9
  67. package/dist/kbd/index.js +0 -47
  68. package/dist/kbd/index.js.map +0 -1
  69. package/dist/label/index.d.ts +0 -11
  70. package/dist/label/index.js +0 -78
  71. package/dist/label/index.js.map +0 -1
  72. package/dist/link-box/index.d.ts +0 -34
  73. package/dist/link-box/index.js +0 -92
  74. package/dist/link-box/index.js.map +0 -1
  75. package/dist/pagination/index.d.ts +0 -143
  76. package/dist/pagination/index.js +0 -1353
  77. package/dist/pagination/index.js.map +0 -1
  78. package/dist/popover/index.d.ts +0 -93
  79. package/dist/popover/index.js +0 -1339
  80. package/dist/popover/index.js.map +0 -1
  81. package/dist/portal/index.d.ts +0 -13
  82. package/dist/portal/index.js +0 -37
  83. package/dist/portal/index.js.map +0 -1
  84. package/dist/progress/index.d.ts +0 -48
  85. package/dist/progress/index.js +0 -223
  86. package/dist/progress/index.js.map +0 -1
  87. package/dist/progress-tracker/index.d.ts +0 -80
  88. package/dist/progress-tracker/index.js +0 -571
  89. package/dist/progress-tracker/index.js.map +0 -1
  90. package/dist/radio-group/index.d.ts +0 -100
  91. package/dist/radio-group/index.js +0 -318
  92. package/dist/radio-group/index.js.map +0 -1
  93. package/dist/rating/index.d.ts +0 -78
  94. package/dist/rating/index.js +0 -363
  95. package/dist/rating/index.js.map +0 -1
  96. package/dist/scrolling-list/index.d.ts +0 -118
  97. package/dist/scrolling-list/index.js +0 -1426
  98. package/dist/scrolling-list/index.js.map +0 -1
  99. package/dist/segmented-gauge/index.d.ts +0 -100
  100. package/dist/segmented-gauge/index.js +0 -277
  101. package/dist/segmented-gauge/index.js.map +0 -1
  102. package/dist/select/index.d.ts +0 -167
  103. package/dist/select/index.js +0 -581
  104. package/dist/select/index.js.map +0 -1
  105. package/dist/skeleton/index.d.ts +0 -67
  106. package/dist/skeleton/index.js +0 -206
  107. package/dist/skeleton/index.js.map +0 -1
  108. package/dist/slider/index.d.ts +0 -97
  109. package/dist/slider/index.js +0 -220
  110. package/dist/slider/index.js.map +0 -1
  111. package/dist/slot/index.d.ts +0 -16
  112. package/dist/slot/index.js +0 -51
  113. package/dist/slot/index.js.map +0 -1
  114. package/dist/snackbar/index.d.ts +0 -158
  115. package/dist/snackbar/index.js +0 -1756
  116. package/dist/snackbar/index.js.map +0 -1
  117. package/dist/spinner/index.d.ts +0 -21
  118. package/dist/spinner/index.js +0 -139
  119. package/dist/spinner/index.js.map +0 -1
  120. package/dist/stepper/index.d.ts +0 -81
  121. package/dist/stepper/index.js +0 -1847
  122. package/dist/stepper/index.js.map +0 -1
  123. package/dist/switch/index.d.ts +0 -64
  124. package/dist/switch/index.js +0 -327
  125. package/dist/switch/index.js.map +0 -1
  126. package/dist/tabs/index.d.ts +0 -103
  127. package/dist/tabs/index.js +0 -1376
  128. package/dist/tabs/index.js.map +0 -1
  129. package/dist/tag/index.d.ts +0 -29
  130. package/dist/tag/index.js +0 -283
  131. package/dist/tag/index.js.map +0 -1
  132. package/dist/text-link/index.d.ts +0 -20
  133. package/dist/text-link/index.js +0 -100
  134. package/dist/text-link/index.js.map +0 -1
  135. package/dist/textarea/index.d.ts +0 -57
  136. package/dist/textarea/index.js +0 -797
  137. package/dist/textarea/index.js.map +0 -1
  138. package/dist/toast/index.d.ts +0 -56
  139. package/dist/toast/index.js +0 -1412
  140. package/dist/toast/index.js.map +0 -1
  141. package/dist/visually-hidden/index.d.ts +0 -16
  142. package/dist/visually-hidden/index.js +0 -67
  143. package/dist/visually-hidden/index.js.map +0 -1
@@ -1,1303 +0,0 @@
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
- intent: "surfaceInverse",
447
- design: "filled",
448
- class: (0, import_internal_utils3.tw)([
449
- "bg-surface-inverse",
450
- "text-on-surface-inverse",
451
- "hover:bg-surface-inverse-hovered",
452
- "enabled:active:bg-surface-inverse-hovered",
453
- "focus-visible:bg-surface-inverse-hovered"
454
- ])
455
- }
456
- ];
457
-
458
- // src/button/variants/ghost.ts
459
- var import_internal_utils4 = require("@spark-ui/internal-utils");
460
- var ghostVariants = [
461
- {
462
- intent: "main",
463
- design: "ghost",
464
- class: (0, import_internal_utils4.tw)([
465
- "text-on-main-container",
466
- "hover:bg-main/dim-5",
467
- "enabled:active:bg-main/dim-5",
468
- "focus-visible:bg-main/dim-5"
469
- ])
470
- },
471
- {
472
- intent: "support",
473
- design: "ghost",
474
- class: (0, import_internal_utils4.tw)([
475
- "text-on-support-container",
476
- "hover:bg-support/dim-5",
477
- "enabled:active:bg-support/dim-5",
478
- "focus-visible:bg-support/dim-5"
479
- ])
480
- },
481
- {
482
- intent: "accent",
483
- design: "ghost",
484
- class: (0, import_internal_utils4.tw)([
485
- "text-on-accent-container",
486
- "hover:bg-accent/dim-5",
487
- "enabled:active:bg-accent/dim-5",
488
- "focus-visible:bg-accent/dim-5"
489
- ])
490
- },
491
- {
492
- intent: "basic",
493
- design: "ghost",
494
- class: (0, import_internal_utils4.tw)([
495
- "text-on-basic-container",
496
- "hover:bg-basic/dim-5",
497
- "enabled:active:bg-basic/dim-5",
498
- "focus-visible:bg-basic/dim-5"
499
- ])
500
- },
501
- {
502
- intent: "success",
503
- design: "ghost",
504
- class: (0, import_internal_utils4.tw)([
505
- "text-on-success-container",
506
- "hover:bg-success/dim-5",
507
- "enabled:active:bg-success/dim-5",
508
- "focus-visible:bg-success/dim-5"
509
- ])
510
- },
511
- {
512
- intent: "alert",
513
- design: "ghost",
514
- class: (0, import_internal_utils4.tw)([
515
- "text-on-alert-container",
516
- "hover:bg-alert/dim-5",
517
- "enabled:active:bg-alert/dim-5",
518
- "focus-visible:bg-alert/dim-5"
519
- ])
520
- },
521
- {
522
- intent: "danger",
523
- design: "ghost",
524
- class: (0, import_internal_utils4.tw)([
525
- "text-on-error-container",
526
- "hover:bg-error/dim-5",
527
- "enabled:active:bg-error/dim-5",
528
- "focus-visible:bg-error/dim-5"
529
- ])
530
- },
531
- {
532
- intent: "info",
533
- design: "ghost",
534
- class: (0, import_internal_utils4.tw)([
535
- "text-on-info-container",
536
- "hover:bg-info/dim-5",
537
- "enabled:active:bg-info/dim-5",
538
- "focus-visible:bg-info/dim-5"
539
- ])
540
- },
541
- {
542
- intent: "neutral",
543
- design: "ghost",
544
- class: (0, import_internal_utils4.tw)([
545
- "text-on-neutral-container",
546
- "hover:bg-neutral/dim-5",
547
- "enabled:active:bg-neutral/dim-5",
548
- "focus-visible:bg-neutral/dim-5"
549
- ])
550
- },
551
- {
552
- intent: "surface",
553
- design: "ghost",
554
- class: (0, import_internal_utils4.tw)([
555
- "text-surface",
556
- "hover:bg-surface/dim-5",
557
- "enabled:active:bg-surface/dim-5",
558
- "focus-visible:bg-surface/dim-5"
559
- ])
560
- },
561
- {
562
- intent: "surfaceInverse",
563
- design: "ghost",
564
- class: (0, import_internal_utils4.tw)([
565
- "text-surface-inverse",
566
- "hover:bg-surface-inverse/dim-5",
567
- "enabled:active:bg-surface-inverse/dim-5",
568
- "focus-visible:bg-surface-inverse/dim-5"
569
- ])
570
- }
571
- ];
572
-
573
- // src/button/variants/outlined.ts
574
- var import_internal_utils5 = require("@spark-ui/internal-utils");
575
- var outlinedVariants = [
576
- {
577
- intent: "main",
578
- design: "outlined",
579
- class: (0, import_internal_utils5.tw)([
580
- "hover:bg-main/dim-5",
581
- "enabled:active:bg-main/dim-5",
582
- "focus-visible:bg-main/dim-5",
583
- "text-main"
584
- ])
585
- },
586
- {
587
- intent: "support",
588
- design: "outlined",
589
- class: (0, import_internal_utils5.tw)([
590
- "hover:bg-support/dim-5",
591
- "enabled:active:bg-support/dim-5",
592
- "focus-visible:bg-support/dim-5",
593
- "text-support"
594
- ])
595
- },
596
- {
597
- intent: "accent",
598
- design: "outlined",
599
- class: (0, import_internal_utils5.tw)([
600
- "hover:bg-accent/dim-5",
601
- "enabled:active:bg-accent/dim-5",
602
- "focus-visible:bg-accent/dim-5",
603
- "text-accent"
604
- ])
605
- },
606
- {
607
- intent: "basic",
608
- design: "outlined",
609
- class: (0, import_internal_utils5.tw)([
610
- "hover:bg-basic/dim-5",
611
- "enabled:active:bg-basic/dim-5",
612
- "focus-visible:bg-basic/dim-5",
613
- "text-basic"
614
- ])
615
- },
616
- {
617
- intent: "success",
618
- design: "outlined",
619
- class: (0, import_internal_utils5.tw)([
620
- "hover:bg-success/dim-5",
621
- "enabled:active:bg-success/dim-5",
622
- "focus-visible:bg-success/dim-5",
623
- "text-success"
624
- ])
625
- },
626
- {
627
- intent: "alert",
628
- design: "outlined",
629
- class: (0, import_internal_utils5.tw)([
630
- "hover:bg-alert/dim-5",
631
- "enabled:active:bg-alert/dim-5",
632
- "focus-visible:bg-alert/dim-5",
633
- "text-alert"
634
- ])
635
- },
636
- {
637
- intent: "danger",
638
- design: "outlined",
639
- class: (0, import_internal_utils5.tw)([
640
- "hover:bg-error/dim-5",
641
- "enabled:active:bg-error/dim-5",
642
- "focus-visible:bg-error/dim-5",
643
- "text-error"
644
- ])
645
- },
646
- {
647
- intent: "info",
648
- design: "outlined",
649
- class: (0, import_internal_utils5.tw)([
650
- "hover:bg-info/dim-5",
651
- "enabled:active:bg-info/dim-5",
652
- "focus-visible:bg-info/dim-5",
653
- "text-info"
654
- ])
655
- },
656
- {
657
- intent: "neutral",
658
- design: "outlined",
659
- class: (0, import_internal_utils5.tw)([
660
- "hover:bg-neutral/dim-5",
661
- "enabled:active:bg-neutral/dim-5",
662
- "focus-visible:bg-neutral/dim-5",
663
- "text-neutral"
664
- ])
665
- },
666
- {
667
- intent: "surface",
668
- design: "outlined",
669
- class: (0, import_internal_utils5.tw)([
670
- "hover:bg-surface/dim-5",
671
- "enabled:active:bg-surface/dim-5",
672
- "focus-visible:bg-surface/dim-5",
673
- "text-surface"
674
- ])
675
- },
676
- {
677
- intent: "surfaceInverse",
678
- design: "outlined",
679
- class: (0, import_internal_utils5.tw)([
680
- "hover:bg-surface-inverse/dim-5",
681
- "enabled:active:bg-surface-inverse/dim-5",
682
- "focus-visible:bg-surface-inverse/dim-5",
683
- "text-surface-inverse"
684
- ])
685
- }
686
- ];
687
-
688
- // src/button/variants/tinted.ts
689
- var import_internal_utils6 = require("@spark-ui/internal-utils");
690
- var tintedVariants = [
691
- {
692
- intent: "main",
693
- design: "tinted",
694
- class: (0, import_internal_utils6.tw)([
695
- "bg-main-container",
696
- "text-on-main-container",
697
- "hover:bg-main-container-hovered",
698
- "enabled:active:bg-main-container-hovered",
699
- "focus-visible:bg-main-container-hovered"
700
- ])
701
- },
702
- {
703
- intent: "support",
704
- design: "tinted",
705
- class: (0, import_internal_utils6.tw)([
706
- "bg-support-container",
707
- "text-on-support-container",
708
- "hover:bg-support-container-hovered",
709
- "enabled:active:bg-support-container-hovered",
710
- "focus-visible:bg-support-container-hovered"
711
- ])
712
- },
713
- {
714
- intent: "accent",
715
- design: "tinted",
716
- class: (0, import_internal_utils6.tw)([
717
- "bg-accent-container",
718
- "text-on-accent-container",
719
- "hover:bg-accent-container-hovered",
720
- "enabled:active:bg-accent-container-hovered",
721
- "focus-visible:bg-accent-container-hovered"
722
- ])
723
- },
724
- {
725
- intent: "basic",
726
- design: "tinted",
727
- class: (0, import_internal_utils6.tw)([
728
- "bg-basic-container",
729
- "text-on-basic-container",
730
- "hover:bg-basic-container-hovered",
731
- "enabled:active:bg-basic-container-hovered",
732
- "focus-visible:bg-basic-container-hovered"
733
- ])
734
- },
735
- {
736
- intent: "success",
737
- design: "tinted",
738
- class: (0, import_internal_utils6.tw)([
739
- "bg-success-container",
740
- "text-on-success-container",
741
- "hover:bg-success-container-hovered",
742
- "enabled:active:bg-success-container-hovered",
743
- "focus-visible:bg-success-container-hovered"
744
- ])
745
- },
746
- {
747
- intent: "alert",
748
- design: "tinted",
749
- class: (0, import_internal_utils6.tw)([
750
- "bg-alert-container",
751
- "text-on-alert-container",
752
- "hover:bg-alert-container-hovered",
753
- "enabled:active:bg-alert-container-hovered",
754
- "focus-visible:bg-alert-container-hovered"
755
- ])
756
- },
757
- {
758
- intent: "danger",
759
- design: "tinted",
760
- class: (0, import_internal_utils6.tw)([
761
- "bg-error-container",
762
- "text-on-error-container",
763
- "hover:bg-error-container-hovered",
764
- "enabled:active:bg-error-container-hovered",
765
- "focus-visible:bg-error-container-hovered"
766
- ])
767
- },
768
- {
769
- intent: "info",
770
- design: "tinted",
771
- class: (0, import_internal_utils6.tw)([
772
- "bg-info-container",
773
- "text-on-info-container",
774
- "hover:bg-info-container-hovered",
775
- "enabled:active:bg-info-container-hovered",
776
- "focus-visible:bg-info-container-hovered"
777
- ])
778
- },
779
- {
780
- intent: "neutral",
781
- design: "tinted",
782
- class: (0, import_internal_utils6.tw)([
783
- "bg-neutral-container",
784
- "text-on-neutral-container",
785
- "hover:bg-neutral-container-hovered",
786
- "enabled:active:bg-neutral-container-hovered",
787
- "focus-visible:bg-neutral-container-hovered"
788
- ])
789
- },
790
- {
791
- intent: "surface",
792
- design: "tinted",
793
- class: (0, import_internal_utils6.tw)([
794
- "bg-surface",
795
- "text-on-surface",
796
- "hover:bg-surface-hovered",
797
- "enabled:active:bg-surface-hovered",
798
- "focus-visible:bg-surface-hovered"
799
- ])
800
- },
801
- {
802
- intent: "surfaceInverse",
803
- design: "tinted",
804
- class: (0, import_internal_utils6.tw)([
805
- "bg-surface-inverse",
806
- "text-on-surface-inverse",
807
- "hover:bg-surface-inverse-hovered",
808
- "enabled:active:bg-surface-inverse-hovered",
809
- "focus-visible:bg-surface-inverse-hovered"
810
- ])
811
- }
812
- ];
813
-
814
- // src/button/variants/contrast.ts
815
- var import_internal_utils7 = require("@spark-ui/internal-utils");
816
- var contrastVariants = [
817
- {
818
- intent: "main",
819
- design: "contrast",
820
- class: (0, import_internal_utils7.tw)([
821
- "text-on-main-contaier bg-surface",
822
- "hover:bg-main-container-hovered",
823
- "enabled:active:bg-main-container-hovered",
824
- "focus-visible:bg-main-container-hovered"
825
- ])
826
- },
827
- {
828
- intent: "support",
829
- design: "contrast",
830
- class: (0, import_internal_utils7.tw)([
831
- "text-on-support-container bg-surface",
832
- "hover:bg-support-container-hovered",
833
- "enabled:active:bg-support-container-hovered",
834
- "focus-visible:bg-support-container-hovered"
835
- ])
836
- },
837
- {
838
- intent: "accent",
839
- design: "contrast",
840
- class: (0, import_internal_utils7.tw)([
841
- "text-on-accent-container bg-surface",
842
- "hover:bg-accent-container-hovered",
843
- "enabled:active:bg-accent-container-hovered",
844
- "focus-visible:bg-accent-container-hovered"
845
- ])
846
- },
847
- {
848
- intent: "basic",
849
- design: "contrast",
850
- class: (0, import_internal_utils7.tw)([
851
- "text-on-basic-container bg-surface",
852
- "hover:bg-basic-container-hovered",
853
- "enabled:active:bg-basic-container-hovered",
854
- "focus-visible:bg-basic-container-hovered"
855
- ])
856
- },
857
- {
858
- intent: "success",
859
- design: "contrast",
860
- class: (0, import_internal_utils7.tw)([
861
- "text-on-success-container bg-surface",
862
- "hover:bg-success-container-hovered",
863
- "enabled:active:bg-success-container-hovered",
864
- "focus-visible:bg-success-container-hovered"
865
- ])
866
- },
867
- {
868
- intent: "alert",
869
- design: "contrast",
870
- class: (0, import_internal_utils7.tw)([
871
- "text-on-alert-container bg-surface",
872
- "hover:bg-alert-container-hovered",
873
- "enabled:active:bg-alert-container-hovered",
874
- "focus-visible:bg-alert-container-hovered"
875
- ])
876
- },
877
- {
878
- intent: "danger",
879
- design: "contrast",
880
- class: (0, import_internal_utils7.tw)([
881
- "text-on-error-container bg-surface",
882
- "hover:bg-error-container-hovered",
883
- "enabled:active:bg-error-container-hovered",
884
- "focus-visible:bg-error-container-hovered"
885
- ])
886
- },
887
- {
888
- intent: "info",
889
- design: "contrast",
890
- class: (0, import_internal_utils7.tw)([
891
- "text-on-info-container bg-surface",
892
- "hover:bg-info-container-hovered",
893
- "enabled:active:bg-info-container-hovered",
894
- "focus-visible:bg-info-container-hovered"
895
- ])
896
- },
897
- {
898
- intent: "neutral",
899
- design: "contrast",
900
- class: (0, import_internal_utils7.tw)([
901
- "text-on-neutral-container bg-surface",
902
- "hover:bg-neutral-container-hovered",
903
- "enabled:active:bg-neutral-container-hovered",
904
- "focus-visible:bg-neutral-container-hovered"
905
- ])
906
- },
907
- {
908
- intent: "surface",
909
- design: "contrast",
910
- class: (0, import_internal_utils7.tw)([
911
- "text-on-surface bg-surface",
912
- "hover:bg-surface-hovered",
913
- "enabled:active:bg-surface-hovered",
914
- "focus-visible:bg-surface-hovered"
915
- ])
916
- },
917
- {
918
- intent: "surfaceInverse",
919
- design: "contrast",
920
- class: (0, import_internal_utils7.tw)([
921
- "text-on-surface-inverse bg-surface-inverse",
922
- "hover:bg-surface-inverse-hovered",
923
- "enabled:active:bg-surface-inverse-hovered",
924
- "focus-visible:bg-surface-inverse-hovered"
925
- ])
926
- }
927
- ];
928
-
929
- // src/button/Button.styles.tsx
930
- var buttonStyles = (0, import_class_variance_authority5.cva)(
931
- [
932
- "u-shadow-border-transition",
933
- "box-border inline-flex items-center justify-center gap-md whitespace-nowrap",
934
- "default:px-lg",
935
- "text-body-1 font-bold",
936
- "focus-visible:u-outline"
937
- ],
938
- {
939
- variants: {
940
- /**
941
- * Main style of the button.
942
- *
943
- * - `filled`: Button will be plain.
944
- *
945
- * - `outlined`: Button will be transparent with an outline.
946
- *
947
- * - `tinted`: Button will be filled but using a lighter color scheme.
948
- *
949
- * - `ghost`: Button will look like a link. No borders, plain text.
950
- *
951
- * - `contrast`: Button will be surface filled. No borders, plain text.
952
- *
953
- */
954
- design: (0, import_internal_utils8.makeVariants)({
955
- filled: [],
956
- outlined: ["bg-transparent", "border-sm", "border-current"],
957
- tinted: [],
958
- ghost: ["default:-mx-md px-md hover:bg-main/dim-5"],
959
- contrast: []
960
- }),
961
- underline: {
962
- true: ["underline"]
963
- },
964
- /**
965
- * Color scheme of the button.
966
- */
967
- intent: (0, import_internal_utils8.makeVariants)({
968
- main: [],
969
- support: [],
970
- accent: [],
971
- basic: [],
972
- success: [],
973
- alert: [],
974
- danger: [],
975
- info: [],
976
- neutral: [],
977
- surface: [],
978
- surfaceInverse: []
979
- }),
980
- /**
981
- * Size of the button.
982
- */
983
- size: (0, import_internal_utils8.makeVariants)({
984
- sm: ["min-w-sz-32", "h-sz-32"],
985
- md: ["min-w-sz-44", "h-sz-44"],
986
- lg: ["min-w-sz-56", "h-sz-56"]
987
- }),
988
- /**
989
- * Shape of the button.
990
- */
991
- shape: (0, import_internal_utils8.makeVariants)({
992
- rounded: ["rounded-lg"],
993
- square: ["rounded-0"],
994
- pill: ["rounded-full"]
995
- }),
996
- /**
997
- * Disable the button, preventing user interaction and adding opacity.
998
- */
999
- disabled: {
1000
- true: ["cursor-not-allowed", "opacity-dim-3"],
1001
- false: ["cursor-pointer"]
1002
- }
1003
- },
1004
- compoundVariants: [
1005
- ...filledVariants,
1006
- ...outlinedVariants,
1007
- ...tintedVariants,
1008
- ...ghostVariants,
1009
- ...contrastVariants
1010
- ],
1011
- defaultVariants: {
1012
- design: "filled",
1013
- intent: "main",
1014
- size: "md",
1015
- shape: "rounded"
1016
- }
1017
- }
1018
- );
1019
-
1020
- // src/button/Button.tsx
1021
- var import_jsx_runtime7 = require("react/jsx-runtime");
1022
- var blockedEventHandlers = [
1023
- "onClick",
1024
- "onMouseDown",
1025
- "onMouseUp",
1026
- "onMouseEnter",
1027
- "onMouseLeave",
1028
- "onMouseOver",
1029
- "onMouseOut",
1030
- "onKeyDown",
1031
- "onKeyPress",
1032
- "onKeyUp",
1033
- "onSubmit"
1034
- ];
1035
- var Button = ({
1036
- children,
1037
- design = "filled",
1038
- disabled = false,
1039
- intent = "main",
1040
- isLoading = false,
1041
- loadingLabel,
1042
- loadingText,
1043
- shape = "rounded",
1044
- size = "md",
1045
- asChild,
1046
- className,
1047
- underline = false,
1048
- ref,
1049
- ...others
1050
- }) => {
1051
- const Component = asChild ? Slot : "button";
1052
- const shouldNotInteract = !!disabled || isLoading;
1053
- const disabledEventHandlers = (0, import_react4.useMemo)(() => {
1054
- const result = {};
1055
- if (shouldNotInteract) {
1056
- blockedEventHandlers.forEach((eventHandler) => result[eventHandler] = void 0);
1057
- }
1058
- return result;
1059
- }, [shouldNotInteract]);
1060
- const spinnerProps = {
1061
- size: "current",
1062
- className: loadingText ? "inline-block" : "absolute",
1063
- ...loadingLabel && { "aria-label": loadingLabel }
1064
- };
1065
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1066
- Component,
1067
- {
1068
- "data-spark-component": "button",
1069
- ...Component === "button" && { type: "button" },
1070
- ref,
1071
- className: buttonStyles({
1072
- className,
1073
- design,
1074
- disabled: shouldNotInteract,
1075
- intent,
1076
- shape,
1077
- size,
1078
- underline
1079
- }),
1080
- disabled: !!disabled,
1081
- "aria-busy": isLoading,
1082
- "aria-live": isLoading ? "assertive" : "off",
1083
- ...others,
1084
- ...disabledEventHandlers,
1085
- children: wrapPolymorphicSlot(
1086
- asChild,
1087
- children,
1088
- (slotted) => isLoading ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
1089
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Spinner, { ...spinnerProps }),
1090
- loadingText && loadingText,
1091
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
1092
- "div",
1093
- {
1094
- "aria-hidden": true,
1095
- className: (0, import_class_variance_authority6.cx)("gap-md", loadingText ? "hidden" : "inline-flex opacity-0"),
1096
- children: slotted
1097
- }
1098
- )
1099
- ] }) : slotted
1100
- )
1101
- }
1102
- );
1103
- };
1104
- Button.displayName = "Button";
1105
-
1106
- // src/icon-button/IconButton.styles.tsx
1107
- var import_internal_utils9 = require("@spark-ui/internal-utils");
1108
- var import_class_variance_authority7 = require("class-variance-authority");
1109
- var iconButtonStyles = (0, import_class_variance_authority7.cva)(["pl-0 pr-0"], {
1110
- variants: {
1111
- /**
1112
- * Sets the size of the icon.
1113
- */
1114
- size: (0, import_internal_utils9.makeVariants)({
1115
- sm: ["text-body-1"],
1116
- md: ["text-body-1"],
1117
- lg: ["text-display-3"]
1118
- })
1119
- }
1120
- });
1121
-
1122
- // src/icon-button/IconButton.tsx
1123
- var import_jsx_runtime8 = require("react/jsx-runtime");
1124
- var IconButton = ({
1125
- design = "filled",
1126
- disabled = false,
1127
- intent = "main",
1128
- shape = "rounded",
1129
- size = "md",
1130
- className,
1131
- ref,
1132
- ...others
1133
- }) => {
1134
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
1135
- Button,
1136
- {
1137
- "data-spark-component": "icon-button",
1138
- ref,
1139
- className: iconButtonStyles({ size, className }),
1140
- design,
1141
- disabled,
1142
- intent,
1143
- shape,
1144
- size,
1145
- ...others
1146
- }
1147
- );
1148
- };
1149
- IconButton.displayName = "IconButton";
1150
-
1151
- // src/avatar/AvatarAction.tsx
1152
- var import_jsx_runtime9 = require("react/jsx-runtime");
1153
- var AvatarAction = ({
1154
- className,
1155
- children,
1156
- asChild,
1157
- angle = 135,
1158
- ariaLabel,
1159
- ...props
1160
- }) => {
1161
- const Comp = asChild ? Slot : IconButton;
1162
- const { pixelSize, design } = useAvatarContext();
1163
- function getBadgePosition(circleSize) {
1164
- const angleRad = (90 - angle) * Math.PI / 180;
1165
- const circleRadius = circleSize / 2;
1166
- return {
1167
- x: circleRadius + circleRadius * Math.cos(angleRad),
1168
- y: circleRadius - circleRadius * Math.sin(angleRad)
1169
- };
1170
- }
1171
- const position = getBadgePosition(pixelSize);
1172
- const isCustomElement = asChild;
1173
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1174
- Comp,
1175
- {
1176
- "data-spark-component": "avatar-action",
1177
- style: {
1178
- position: "absolute",
1179
- ...design === "circle" ? { left: `${position.x}px`, top: `${position.y}px` } : {},
1180
- ...design === "square" ? { right: "0px", bottom: "0px" } : {}
1181
- },
1182
- className: (0, import_class_variance_authority8.cx)(
1183
- "z-raised",
1184
- design === "circle" ? "-translate-x-1/2 -translate-y-1/2" : "translate-x-1/4 translate-y-1/4",
1185
- { "shadow-sm": !isCustomElement },
1186
- className
1187
- ),
1188
- "aria-label": ariaLabel,
1189
- title: ariaLabel,
1190
- ...!isCustomElement ? { size: "sm", intent: "support", design: "contrast" } : {},
1191
- ...props,
1192
- children: children || /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Icon, { size: "sm", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_PenOutline.PenOutline, {}) })
1193
- }
1194
- );
1195
- };
1196
- AvatarAction.displayName = "AvatarAction";
1197
-
1198
- // src/avatar/AvatarOnlineBadge.tsx
1199
- var import_class_variance_authority9 = require("class-variance-authority");
1200
- var import_jsx_runtime10 = require("react/jsx-runtime");
1201
- var AvatarOnlineBadge = ({ angle = 135, ...props }) => {
1202
- const { isOnline, pixelSize, design, onlineText, size } = useAvatarContext();
1203
- if (!isOnline) return null;
1204
- function getBadgePosition(circleSize) {
1205
- const angleRad = (90 - angle) * Math.PI / 180;
1206
- const circleRadius = circleSize / 2;
1207
- return {
1208
- x: circleRadius + circleRadius * Math.cos(angleRad),
1209
- y: circleRadius - circleRadius * Math.sin(angleRad)
1210
- };
1211
- }
1212
- const badgePosition = getBadgePosition(pixelSize);
1213
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1214
- "div",
1215
- {
1216
- "data-spark-component": "avatar-online-badge",
1217
- role: "status",
1218
- "aria-label": onlineText,
1219
- style: {
1220
- ...design === "circle" ? { left: `${badgePosition.x}px`, top: `${badgePosition.y}px` } : { right: "0px", bottom: "0px" }
1221
- },
1222
- className: (0, import_class_variance_authority9.cx)(
1223
- "bg-success outline-surface absolute rounded-full",
1224
- design === "circle" ? "-translate-x-1/2 -translate-y-1/2" : "translate-x-1/4 translate-y-1/4",
1225
- ["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")
1226
- ),
1227
- ...props
1228
- }
1229
- );
1230
- };
1231
- AvatarOnlineBadge.displayName = "AvatarOnlineBadge";
1232
-
1233
- // src/avatar/AvatarUser.tsx
1234
- var import_class_variance_authority10 = require("class-variance-authority");
1235
- var import_jsx_runtime11 = require("react/jsx-runtime");
1236
- var AvatarUser = ({ asChild, children, className, ...props }) => {
1237
- const { design, isOnline, onlineText, username } = useAvatarContext();
1238
- const Comp = asChild ? Slot : "div";
1239
- const accessibleName = isOnline && onlineText ? `${username} (${onlineText})` : username;
1240
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1241
- Comp,
1242
- {
1243
- ...!asChild && { role: "img" },
1244
- "aria-label": accessibleName,
1245
- title: accessibleName,
1246
- className: (0, import_class_variance_authority10.cx)(
1247
- "group default:border-outline relative size-full overflow-hidden",
1248
- "focus-visible:u-outline",
1249
- {
1250
- "default:rounded-full": design === "circle",
1251
- "default:rounded-md": design === "square",
1252
- "hover:opacity-dim-1 cursor-pointer": asChild || props.onClick
1253
- },
1254
- className
1255
- ),
1256
- ...props,
1257
- children
1258
- }
1259
- );
1260
- };
1261
- AvatarUser.displayName = "AvatarUser";
1262
-
1263
- // src/avatar/AvatarPlaceholder.tsx
1264
- var import_class_variance_authority11 = require("class-variance-authority");
1265
- var import_jsx_runtime12 = require("react/jsx-runtime");
1266
- var AvatarPlaceholder = ({ className, children, ...props }) => {
1267
- const { size, username } = useAvatarContext();
1268
- const firstLetter = username?.charAt(0);
1269
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1270
- "div",
1271
- {
1272
- "aria-hidden": true,
1273
- className: (0, import_class_variance_authority11.cx)(
1274
- "absolute inset-0 flex size-full items-center justify-center",
1275
- "default:bg-neutral default:text-on-neutral",
1276
- {
1277
- "text-display-1": size === "2xl",
1278
- "text-display-2": ["xl", "lg"].includes(size),
1279
- "text-display-3": size === "md",
1280
- "text-headline-2": size === "sm",
1281
- "text-body-2 font-bold": size === "xs"
1282
- },
1283
- className
1284
- ),
1285
- ...props,
1286
- children: children || firstLetter
1287
- }
1288
- );
1289
- };
1290
- AvatarPlaceholder.displayName = "AvatarPlaceholder";
1291
-
1292
- // src/avatar/index.ts
1293
- var AvatarComponent = Avatar;
1294
- AvatarComponent.Image = AvatarImage;
1295
- AvatarComponent.Action = AvatarAction;
1296
- AvatarComponent.OnlineBadge = AvatarOnlineBadge;
1297
- AvatarComponent.User = AvatarUser;
1298
- AvatarComponent.Placeholder = AvatarPlaceholder;
1299
- // Annotate the CommonJS export names for ESM import in node:
1300
- 0 && (module.exports = {
1301
- Avatar
1302
- });
1303
- //# sourceMappingURL=index.js.map