@spark-ui/components 12.2.0 → 13.0.1-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -25,81 +25,111 @@ __export(alert_dialog_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(alert_dialog_exports);
27
27
 
28
- // src/dialog/Dialog.tsx
29
- var import_radix_ui = require("radix-ui");
28
+ // src/alert-dialog/AlertDialog.tsx
29
+ var import_alert_dialog = require("@base-ui-components/react/alert-dialog");
30
30
  var import_react2 = require("react");
31
31
 
32
- // src/dialog/DialogContext.tsx
32
+ // src/alert-dialog/AlertDialogContext.tsx
33
33
  var import_react = require("react");
34
34
  var import_jsx_runtime = require("react/jsx-runtime");
35
- var DialogContext = (0, import_react.createContext)(null);
36
- var DialogProvider = ({
37
- children: childrenProp,
38
- withFade = false
35
+ var AlertDialogContext = (0, import_react.createContext)(null);
36
+ var AlertDialogProvider = ({
37
+ children,
38
+ withFade = false,
39
+ cancelRef
39
40
  }) => {
40
- const [isFullScreen, setIsFullScreen] = (0, import_react.useState)(false);
41
41
  return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(
42
- DialogContext.Provider,
42
+ AlertDialogContext.Provider,
43
43
  {
44
44
  value: {
45
- isFullScreen,
46
- setIsFullScreen,
45
+ cancelRef,
47
46
  withFade
48
47
  },
49
- children: childrenProp
48
+ children
50
49
  }
51
50
  );
52
51
  };
53
- var useDialog = () => {
54
- const context = (0, import_react.useContext)(DialogContext);
52
+ var useAlertDialog = () => {
53
+ const context = (0, import_react.useContext)(AlertDialogContext);
55
54
  if (!context) {
56
- throw Error("useDialog must be used within a Dialog provider");
55
+ throw Error("useAlertDialog must be used within an AlertDialog provider");
57
56
  }
58
57
  return context;
59
58
  };
60
59
 
61
- // src/dialog/Dialog.tsx
60
+ // src/alert-dialog/AlertDialog.tsx
62
61
  var import_jsx_runtime2 = require("react/jsx-runtime");
63
- var Dialog = ({ children, withFade = false, ...rest }) => {
64
- const open = rest.open;
65
- const activeElementRef = (0, import_react2.useRef)(null);
66
- function handleActiveElementFocus() {
67
- if (open && document.activeElement) {
68
- activeElementRef.current = document.activeElement;
62
+ var AlertDialog = ({ onOpenChange, withFade = false, ...props }) => {
63
+ const cancelRef = (0, import_react2.useRef)(null);
64
+ const handleOpenChange = onOpenChange ? (open, _eventDetails) => {
65
+ onOpenChange(open);
66
+ } : void 0;
67
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(AlertDialogProvider, { withFade, cancelRef, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
68
+ import_alert_dialog.AlertDialog.Root,
69
+ {
70
+ "data-spark-component": "alert-dialog",
71
+ onOpenChange: handleOpenChange,
72
+ ...props
69
73
  }
70
- if (!open) {
71
- setTimeout(() => {
72
- if (!(activeElementRef.current instanceof HTMLElement)) return;
73
- activeElementRef.current.focus();
74
- }, 0);
74
+ ) });
75
+ };
76
+ AlertDialog.displayName = "AlertDialog";
77
+
78
+ // src/alert-dialog/AlertDialogAction.tsx
79
+ var import_alert_dialog2 = require("@base-ui-components/react/alert-dialog");
80
+
81
+ // src/slot/Slot.tsx
82
+ var import_radix_ui = require("radix-ui");
83
+ var import_react3 = require("react");
84
+ var import_jsx_runtime3 = require("react/jsx-runtime");
85
+ var Slottable = import_radix_ui.Slot.Slottable;
86
+ var Slot = ({ ref, ...props }) => {
87
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_radix_ui.Slot.Root, { ref, ...props });
88
+ };
89
+
90
+ // src/alert-dialog/useRenderSlot.tsx
91
+ var import_jsx_runtime4 = require("react/jsx-runtime");
92
+ function useRenderSlot(asChild, defaultTag) {
93
+ const Component = asChild ? Slot : defaultTag;
94
+ return asChild ? ({ ...props }) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(Component, { ...props }) : void 0;
95
+ }
96
+
97
+ // src/alert-dialog/AlertDialogAction.tsx
98
+ var import_jsx_runtime5 = require("react/jsx-runtime");
99
+ var AlertDialogAction = ({ asChild = false, ...props }) => {
100
+ const renderSlot = useRenderSlot(asChild, "button");
101
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
102
+ import_alert_dialog2.AlertDialog.Close,
103
+ {
104
+ "data-spark-component": "alert-dialog-action",
105
+ render: renderSlot,
106
+ ...props
75
107
  }
76
- }
77
- (0, import_react2.useEffect)(handleActiveElementFocus, [open]);
78
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DialogProvider, { withFade, children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_radix_ui.Dialog.Root, { ...rest, children }) });
108
+ );
79
109
  };
80
- Dialog.displayName = "Dialog.Root";
110
+ AlertDialogAction.displayName = "AlertDialog.Action";
81
111
 
82
- // src/dialog/DialogBody.tsx
112
+ // src/alert-dialog/AlertDialogBody.tsx
83
113
  var import_use_merge_refs = require("@spark-ui/hooks/use-merge-refs");
84
114
  var import_use_scroll_overflow = require("@spark-ui/hooks/use-scroll-overflow");
85
115
  var import_class_variance_authority = require("class-variance-authority");
86
- var import_react3 = require("react");
87
- var import_jsx_runtime3 = require("react/jsx-runtime");
88
- var Body = ({
116
+ var import_react4 = require("react");
117
+ var import_jsx_runtime6 = require("react/jsx-runtime");
118
+ var AlertDialogBody = ({
89
119
  children,
90
120
  className,
91
121
  inset = false,
92
122
  ref: forwardedRef,
93
123
  ...rest
94
124
  }) => {
95
- const scrollAreaRef = (0, import_react3.useRef)(null);
125
+ const scrollAreaRef = (0, import_react4.useRef)(null);
96
126
  const ref = (0, import_use_merge_refs.useMergeRefs)(forwardedRef, scrollAreaRef);
97
- const { withFade } = useDialog();
127
+ const { withFade } = useAlertDialog();
98
128
  const { overflow } = (0, import_use_scroll_overflow.useScrollOverflow)(scrollAreaRef);
99
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
129
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
100
130
  "div",
101
131
  {
102
- "data-spark-component": "dialog-body",
132
+ "data-spark-component": "alert-dialog-body",
103
133
  ref,
104
134
  className: (0, import_class_variance_authority.cx)(
105
135
  "focus-visible:u-outline relative grow overflow-y-auto outline-hidden",
@@ -121,1065 +151,39 @@ var Body = ({
121
151
  }
122
152
  );
123
153
  };
124
- Body.displayName = "Dialog.Body";
125
-
126
- // src/dialog/DialogClose.tsx
127
- var import_radix_ui2 = require("radix-ui");
128
- var import_jsx_runtime4 = require("react/jsx-runtime");
129
- var Close = (props) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_radix_ui2.Dialog.Close, { ...props });
130
- Close.displayName = "Dialog.Close";
131
-
132
- // src/dialog/DialogCloseButton.tsx
133
- var import_Close = require("@spark-ui/icons/Close");
134
- var import_class_variance_authority7 = require("class-variance-authority");
135
-
136
- // src/icon/Icon.tsx
137
- var import_react5 = require("react");
138
-
139
- // src/slot/Slot.tsx
140
- var import_radix_ui3 = require("radix-ui");
141
- var import_react4 = require("react");
142
- var import_jsx_runtime5 = require("react/jsx-runtime");
143
- var Slottable = import_radix_ui3.Slot.Slottable;
144
- var Slot = ({ ref, ...props }) => {
145
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_radix_ui3.Slot.Root, { ref, ...props });
146
- };
147
- var wrapPolymorphicSlot = (asChild, children, callback) => {
148
- if (!asChild) return callback(children);
149
- return (0, import_react4.isValidElement)(children) ? (0, import_react4.cloneElement)(
150
- children,
151
- void 0,
152
- callback(children.props.children)
153
- ) : null;
154
- };
155
-
156
- // src/visually-hidden/VisuallyHidden.tsx
157
- var import_jsx_runtime6 = require("react/jsx-runtime");
158
- var VisuallyHidden = ({ asChild = false, ref, ...props }) => {
159
- const Component = asChild ? Slot : "span";
160
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
161
- Component,
162
- {
163
- ...props,
164
- ref,
165
- style: {
166
- // See: https://github.com/twbs/bootstrap/blob/main/scss/mixins/_visually-hidden.scss
167
- position: "absolute",
168
- border: 0,
169
- width: 1,
170
- height: 1,
171
- padding: 0,
172
- margin: -1,
173
- overflow: "hidden",
174
- clip: "rect(0, 0, 0, 0)",
175
- whiteSpace: "nowrap",
176
- wordWrap: "normal",
177
- ...props.style
178
- }
179
- }
180
- );
181
- };
182
- VisuallyHidden.displayName = "VisuallyHidden";
183
-
184
- // src/icon/Icon.styles.tsx
185
- var import_internal_utils = require("@spark-ui/internal-utils");
186
- var import_class_variance_authority2 = require("class-variance-authority");
187
- var iconStyles = (0, import_class_variance_authority2.cva)(["fill-current shrink-0"], {
188
- variants: {
189
- /**
190
- * Color scheme of the icon.
191
- */
192
- intent: (0, import_internal_utils.makeVariants)({
193
- current: ["text-current"],
194
- main: ["text-main"],
195
- support: ["text-support"],
196
- accent: ["text-accent"],
197
- basic: ["text-basic"],
198
- success: ["text-success"],
199
- alert: ["text-alert"],
200
- error: ["text-error"],
201
- info: ["text-info"],
202
- neutral: ["text-neutral"]
203
- }),
204
- /**
205
- * Sets the size of the icon.
206
- */
207
- size: (0, import_internal_utils.makeVariants)({
208
- current: ["u-current-font-size"],
209
- sm: ["w-sz-16", "h-sz-16"],
210
- md: ["w-sz-24", "h-sz-24"],
211
- lg: ["w-sz-32", "h-sz-32"],
212
- xl: ["w-sz-40", "h-sz-40"]
213
- })
214
- }
215
- });
154
+ AlertDialogBody.displayName = "AlertDialog.Body";
216
155
 
217
- // src/icon/Icon.tsx
156
+ // src/alert-dialog/AlertDialogCancel.tsx
157
+ var import_alert_dialog3 = require("@base-ui-components/react/alert-dialog");
158
+ var import_use_merge_refs2 = require("@spark-ui/hooks/use-merge-refs");
218
159
  var import_jsx_runtime7 = require("react/jsx-runtime");
219
- var Icon = ({
220
- label,
221
- className,
222
- size = "current",
223
- intent = "current",
224
- children,
225
- ...others
226
- }) => {
227
- const child = import_react5.Children.only(children);
228
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
229
- (0, import_react5.cloneElement)(child, {
230
- className: iconStyles({ className, size, intent }),
231
- "data-spark-component": "icon",
232
- "aria-hidden": "true",
233
- focusable: "false",
234
- ...others
235
- }),
236
- label && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(VisuallyHidden, { children: label })
237
- ] });
238
- };
239
- Icon.displayName = "Icon";
240
-
241
- // src/button/Button.tsx
242
- var import_class_variance_authority5 = require("class-variance-authority");
243
- var import_react6 = require("react");
244
-
245
- // src/spinner/Spinner.styles.tsx
246
- var import_internal_utils2 = require("@spark-ui/internal-utils");
247
- var import_class_variance_authority3 = require("class-variance-authority");
248
- var defaultVariants = {
249
- intent: "current",
250
- size: "current",
251
- isBackgroundVisible: false
252
- };
253
- var spinnerStyles = (0, import_class_variance_authority3.cva)(
254
- ["inline-block", "border-solid", "rounded-full", "border-md", "animate-spin"],
255
- {
256
- variants: {
257
- /**
258
- * 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.
259
- */
260
- size: {
261
- current: ["u-current-font-size"],
262
- sm: ["w-sz-20", "h-sz-20"],
263
- md: ["w-sz-28", "h-sz-28"],
264
- full: ["w-full", "h-full"]
265
- },
266
- /**
267
- * Color scheme of the spinner.
268
- */
269
- intent: (0, import_internal_utils2.makeVariants)({
270
- current: ["border-current"],
271
- main: ["border-main"],
272
- support: ["border-support"],
273
- accent: ["border-accent"],
274
- basic: ["border-basic"],
275
- success: ["border-success"],
276
- alert: ["border-alert"],
277
- error: ["border-error"],
278
- info: ["border-info"],
279
- neutral: ["border-neutral"]
280
- }),
281
- /**
282
- * Size of the button.
283
- */
284
- isBackgroundVisible: {
285
- true: ["border-b-neutral-container", "border-l-neutral-container"],
286
- false: ["border-b-transparent", "border-l-transparent"]
287
- }
288
- },
289
- defaultVariants
290
- }
291
- );
292
-
293
- // src/spinner/Spinner.tsx
294
- var import_jsx_runtime8 = require("react/jsx-runtime");
295
- var Spinner = ({
296
- className,
297
- size = "current",
298
- intent = "current",
299
- label,
300
- isBackgroundVisible,
301
- ref,
302
- ...others
303
- }) => {
304
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
305
- "span",
306
- {
307
- role: "status",
308
- "data-spark-component": "spinner",
309
- ref,
310
- className: spinnerStyles({ className, size, intent, isBackgroundVisible }),
311
- ...others,
312
- children: label && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(VisuallyHidden, { children: label })
313
- }
314
- );
315
- };
316
-
317
- // src/button/Button.styles.tsx
318
- var import_internal_utils8 = require("@spark-ui/internal-utils");
319
- var import_class_variance_authority4 = require("class-variance-authority");
320
-
321
- // src/button/variants/filled.ts
322
- var import_internal_utils3 = require("@spark-ui/internal-utils");
323
- var filledVariants = [
324
- // Main
325
- {
326
- intent: "main",
327
- design: "filled",
328
- class: (0, import_internal_utils3.tw)([
329
- "bg-main",
330
- "text-on-main",
331
- "hover:bg-main-hovered",
332
- "enabled:active:bg-main-hovered",
333
- "focus-visible:bg-main-hovered"
334
- ])
335
- },
336
- // Support
337
- {
338
- intent: "support",
339
- design: "filled",
340
- class: (0, import_internal_utils3.tw)([
341
- "bg-support",
342
- "text-on-support",
343
- "hover:bg-support-hovered",
344
- "enabled:active:bg-support-hovered",
345
- "focus-visible:bg-support-hovered"
346
- ])
347
- },
348
- // Accent
349
- {
350
- intent: "accent",
351
- design: "filled",
352
- class: (0, import_internal_utils3.tw)([
353
- "bg-accent",
354
- "text-on-accent",
355
- "hover:bg-accent-hovered",
356
- "enabled:active:bg-accent-hovered",
357
- "focus-visible:bg-accent-hovered"
358
- ])
359
- },
360
- // Basic
361
- {
362
- intent: "basic",
363
- design: "filled",
364
- class: (0, import_internal_utils3.tw)([
365
- "bg-basic",
366
- "text-on-basic",
367
- "hover:bg-basic-hovered",
368
- "enabled:active:bg-basic-hovered",
369
- "focus-visible:bg-basic-hovered"
370
- ])
371
- },
372
- // Success
373
- {
374
- intent: "success",
375
- design: "filled",
376
- class: (0, import_internal_utils3.tw)([
377
- "bg-success",
378
- "text-on-success",
379
- "hover:bg-success-hovered",
380
- "enabled:active:bg-success-hovered",
381
- "focus-visible:bg-success-hovered"
382
- ])
383
- },
384
- // Alert
385
- {
386
- intent: "alert",
387
- design: "filled",
388
- class: (0, import_internal_utils3.tw)([
389
- "bg-alert",
390
- "text-on-alert",
391
- "hover:bg-alert-hovered",
392
- "enabled:active:bg-alert-hovered",
393
- "focus-visible:bg-alert-hovered"
394
- ])
395
- },
396
- // Danger
397
- {
398
- intent: "danger",
399
- design: "filled",
400
- class: (0, import_internal_utils3.tw)([
401
- "text-on-error bg-error",
402
- "hover:bg-error-hovered enabled:active:bg-error-hovered",
403
- "focus-visible:bg-error-hovered"
404
- ])
405
- },
406
- // Info
407
- {
408
- intent: "info",
409
- design: "filled",
410
- class: (0, import_internal_utils3.tw)([
411
- "text-on-error bg-info",
412
- "hover:bg-info-hovered enabled:active:bg-info-hovered",
413
- "focus-visible:bg-info-hovered"
414
- ])
415
- },
416
- // Neutral
417
- {
418
- intent: "neutral",
419
- design: "filled",
420
- class: (0, import_internal_utils3.tw)([
421
- "bg-neutral",
422
- "text-on-neutral",
423
- "hover:bg-neutral-hovered",
424
- "enabled:active:bg-neutral-hovered",
425
- "focus-visible:bg-neutral-hovered"
426
- ])
427
- },
428
- // Surface
429
- {
430
- intent: "surface",
431
- design: "filled",
432
- class: (0, import_internal_utils3.tw)([
433
- "bg-surface",
434
- "text-on-surface",
435
- "hover:bg-surface-hovered",
436
- "enabled:active:bg-surface-hovered",
437
- "focus-visible:bg-surface-hovered"
438
- ])
439
- },
440
- {
441
- intent: "surfaceInverse",
442
- design: "filled",
443
- class: (0, import_internal_utils3.tw)([
444
- "bg-surface-inverse",
445
- "text-on-surface-inverse",
446
- "hover:bg-surface-inverse-hovered",
447
- "enabled:active:bg-surface-inverse-hovered",
448
- "focus-visible:bg-surface-inverse-hovered"
449
- ])
450
- }
451
- ];
452
-
453
- // src/button/variants/ghost.ts
454
- var import_internal_utils4 = require("@spark-ui/internal-utils");
455
- var ghostVariants = [
456
- {
457
- intent: "main",
458
- design: "ghost",
459
- class: (0, import_internal_utils4.tw)([
460
- "text-on-main-container",
461
- "hover:bg-main/dim-5",
462
- "enabled:active:bg-main/dim-5",
463
- "focus-visible:bg-main/dim-5"
464
- ])
465
- },
466
- {
467
- intent: "support",
468
- design: "ghost",
469
- class: (0, import_internal_utils4.tw)([
470
- "text-on-support-container",
471
- "hover:bg-support/dim-5",
472
- "enabled:active:bg-support/dim-5",
473
- "focus-visible:bg-support/dim-5"
474
- ])
475
- },
476
- {
477
- intent: "accent",
478
- design: "ghost",
479
- class: (0, import_internal_utils4.tw)([
480
- "text-on-accent-container",
481
- "hover:bg-accent/dim-5",
482
- "enabled:active:bg-accent/dim-5",
483
- "focus-visible:bg-accent/dim-5"
484
- ])
485
- },
486
- {
487
- intent: "basic",
488
- design: "ghost",
489
- class: (0, import_internal_utils4.tw)([
490
- "text-on-basic-container",
491
- "hover:bg-basic/dim-5",
492
- "enabled:active:bg-basic/dim-5",
493
- "focus-visible:bg-basic/dim-5"
494
- ])
495
- },
496
- {
497
- intent: "success",
498
- design: "ghost",
499
- class: (0, import_internal_utils4.tw)([
500
- "text-on-success-container",
501
- "hover:bg-success/dim-5",
502
- "enabled:active:bg-success/dim-5",
503
- "focus-visible:bg-success/dim-5"
504
- ])
505
- },
506
- {
507
- intent: "alert",
508
- design: "ghost",
509
- class: (0, import_internal_utils4.tw)([
510
- "text-on-alert-container",
511
- "hover:bg-alert/dim-5",
512
- "enabled:active:bg-alert/dim-5",
513
- "focus-visible:bg-alert/dim-5"
514
- ])
515
- },
516
- {
517
- intent: "danger",
518
- design: "ghost",
519
- class: (0, import_internal_utils4.tw)([
520
- "text-on-error-container",
521
- "hover:bg-error/dim-5",
522
- "enabled:active:bg-error/dim-5",
523
- "focus-visible:bg-error/dim-5"
524
- ])
525
- },
526
- {
527
- intent: "info",
528
- design: "ghost",
529
- class: (0, import_internal_utils4.tw)([
530
- "text-on-info-container",
531
- "hover:bg-info/dim-5",
532
- "enabled:active:bg-info/dim-5",
533
- "focus-visible:bg-info/dim-5"
534
- ])
535
- },
536
- {
537
- intent: "neutral",
538
- design: "ghost",
539
- class: (0, import_internal_utils4.tw)([
540
- "text-on-neutral-container",
541
- "hover:bg-neutral/dim-5",
542
- "enabled:active:bg-neutral/dim-5",
543
- "focus-visible:bg-neutral/dim-5"
544
- ])
545
- },
546
- {
547
- intent: "surface",
548
- design: "ghost",
549
- class: (0, import_internal_utils4.tw)([
550
- "text-surface",
551
- "hover:bg-surface/dim-5",
552
- "enabled:active:bg-surface/dim-5",
553
- "focus-visible:bg-surface/dim-5"
554
- ])
555
- },
556
- {
557
- intent: "surfaceInverse",
558
- design: "ghost",
559
- class: (0, import_internal_utils4.tw)([
560
- "text-surface-inverse",
561
- "hover:bg-surface-inverse/dim-5",
562
- "enabled:active:bg-surface-inverse/dim-5",
563
- "focus-visible:bg-surface-inverse/dim-5"
564
- ])
565
- }
566
- ];
567
-
568
- // src/button/variants/outlined.ts
569
- var import_internal_utils5 = require("@spark-ui/internal-utils");
570
- var outlinedVariants = [
571
- {
572
- intent: "main",
573
- design: "outlined",
574
- class: (0, import_internal_utils5.tw)([
575
- "hover:bg-main/dim-5",
576
- "enabled:active:bg-main/dim-5",
577
- "focus-visible:bg-main/dim-5",
578
- "text-main"
579
- ])
580
- },
581
- {
582
- intent: "support",
583
- design: "outlined",
584
- class: (0, import_internal_utils5.tw)([
585
- "hover:bg-support/dim-5",
586
- "enabled:active:bg-support/dim-5",
587
- "focus-visible:bg-support/dim-5",
588
- "text-support"
589
- ])
590
- },
591
- {
592
- intent: "accent",
593
- design: "outlined",
594
- class: (0, import_internal_utils5.tw)([
595
- "hover:bg-accent/dim-5",
596
- "enabled:active:bg-accent/dim-5",
597
- "focus-visible:bg-accent/dim-5",
598
- "text-accent"
599
- ])
600
- },
601
- {
602
- intent: "basic",
603
- design: "outlined",
604
- class: (0, import_internal_utils5.tw)([
605
- "hover:bg-basic/dim-5",
606
- "enabled:active:bg-basic/dim-5",
607
- "focus-visible:bg-basic/dim-5",
608
- "text-basic"
609
- ])
610
- },
611
- {
612
- intent: "success",
613
- design: "outlined",
614
- class: (0, import_internal_utils5.tw)([
615
- "hover:bg-success/dim-5",
616
- "enabled:active:bg-success/dim-5",
617
- "focus-visible:bg-success/dim-5",
618
- "text-success"
619
- ])
620
- },
621
- {
622
- intent: "alert",
623
- design: "outlined",
624
- class: (0, import_internal_utils5.tw)([
625
- "hover:bg-alert/dim-5",
626
- "enabled:active:bg-alert/dim-5",
627
- "focus-visible:bg-alert/dim-5",
628
- "text-alert"
629
- ])
630
- },
631
- {
632
- intent: "danger",
633
- design: "outlined",
634
- class: (0, import_internal_utils5.tw)([
635
- "hover:bg-error/dim-5",
636
- "enabled:active:bg-error/dim-5",
637
- "focus-visible:bg-error/dim-5",
638
- "text-error"
639
- ])
640
- },
641
- {
642
- intent: "info",
643
- design: "outlined",
644
- class: (0, import_internal_utils5.tw)([
645
- "hover:bg-info/dim-5",
646
- "enabled:active:bg-info/dim-5",
647
- "focus-visible:bg-info/dim-5",
648
- "text-info"
649
- ])
650
- },
651
- {
652
- intent: "neutral",
653
- design: "outlined",
654
- class: (0, import_internal_utils5.tw)([
655
- "hover:bg-neutral/dim-5",
656
- "enabled:active:bg-neutral/dim-5",
657
- "focus-visible:bg-neutral/dim-5",
658
- "text-neutral"
659
- ])
660
- },
661
- {
662
- intent: "surface",
663
- design: "outlined",
664
- class: (0, import_internal_utils5.tw)([
665
- "hover:bg-surface/dim-5",
666
- "enabled:active:bg-surface/dim-5",
667
- "focus-visible:bg-surface/dim-5",
668
- "text-surface"
669
- ])
670
- },
671
- {
672
- intent: "surfaceInverse",
673
- design: "outlined",
674
- class: (0, import_internal_utils5.tw)([
675
- "hover:bg-surface-inverse/dim-5",
676
- "enabled:active:bg-surface-inverse/dim-5",
677
- "focus-visible:bg-surface-inverse/dim-5",
678
- "text-surface-inverse"
679
- ])
680
- }
681
- ];
682
-
683
- // src/button/variants/tinted.ts
684
- var import_internal_utils6 = require("@spark-ui/internal-utils");
685
- var tintedVariants = [
686
- {
687
- intent: "main",
688
- design: "tinted",
689
- class: (0, import_internal_utils6.tw)([
690
- "bg-main-container",
691
- "text-on-main-container",
692
- "hover:bg-main-container-hovered",
693
- "enabled:active:bg-main-container-hovered",
694
- "focus-visible:bg-main-container-hovered"
695
- ])
696
- },
697
- {
698
- intent: "support",
699
- design: "tinted",
700
- class: (0, import_internal_utils6.tw)([
701
- "bg-support-container",
702
- "text-on-support-container",
703
- "hover:bg-support-container-hovered",
704
- "enabled:active:bg-support-container-hovered",
705
- "focus-visible:bg-support-container-hovered"
706
- ])
707
- },
708
- {
709
- intent: "accent",
710
- design: "tinted",
711
- class: (0, import_internal_utils6.tw)([
712
- "bg-accent-container",
713
- "text-on-accent-container",
714
- "hover:bg-accent-container-hovered",
715
- "enabled:active:bg-accent-container-hovered",
716
- "focus-visible:bg-accent-container-hovered"
717
- ])
718
- },
719
- {
720
- intent: "basic",
721
- design: "tinted",
722
- class: (0, import_internal_utils6.tw)([
723
- "bg-basic-container",
724
- "text-on-basic-container",
725
- "hover:bg-basic-container-hovered",
726
- "enabled:active:bg-basic-container-hovered",
727
- "focus-visible:bg-basic-container-hovered"
728
- ])
729
- },
730
- {
731
- intent: "success",
732
- design: "tinted",
733
- class: (0, import_internal_utils6.tw)([
734
- "bg-success-container",
735
- "text-on-success-container",
736
- "hover:bg-success-container-hovered",
737
- "enabled:active:bg-success-container-hovered",
738
- "focus-visible:bg-success-container-hovered"
739
- ])
740
- },
741
- {
742
- intent: "alert",
743
- design: "tinted",
744
- class: (0, import_internal_utils6.tw)([
745
- "bg-alert-container",
746
- "text-on-alert-container",
747
- "hover:bg-alert-container-hovered",
748
- "enabled:active:bg-alert-container-hovered",
749
- "focus-visible:bg-alert-container-hovered"
750
- ])
751
- },
752
- {
753
- intent: "danger",
754
- design: "tinted",
755
- class: (0, import_internal_utils6.tw)([
756
- "bg-error-container",
757
- "text-on-error-container",
758
- "hover:bg-error-container-hovered",
759
- "enabled:active:bg-error-container-hovered",
760
- "focus-visible:bg-error-container-hovered"
761
- ])
762
- },
763
- {
764
- intent: "info",
765
- design: "tinted",
766
- class: (0, import_internal_utils6.tw)([
767
- "bg-info-container",
768
- "text-on-info-container",
769
- "hover:bg-info-container-hovered",
770
- "enabled:active:bg-info-container-hovered",
771
- "focus-visible:bg-info-container-hovered"
772
- ])
773
- },
774
- {
775
- intent: "neutral",
776
- design: "tinted",
777
- class: (0, import_internal_utils6.tw)([
778
- "bg-neutral-container",
779
- "text-on-neutral-container",
780
- "hover:bg-neutral-container-hovered",
781
- "enabled:active:bg-neutral-container-hovered",
782
- "focus-visible:bg-neutral-container-hovered"
783
- ])
784
- },
785
- {
786
- intent: "surface",
787
- design: "tinted",
788
- class: (0, import_internal_utils6.tw)([
789
- "bg-surface",
790
- "text-on-surface",
791
- "hover:bg-surface-hovered",
792
- "enabled:active:bg-surface-hovered",
793
- "focus-visible:bg-surface-hovered"
794
- ])
795
- },
796
- {
797
- intent: "surfaceInverse",
798
- design: "tinted",
799
- class: (0, import_internal_utils6.tw)([
800
- "bg-surface-inverse",
801
- "text-on-surface-inverse",
802
- "hover:bg-surface-inverse-hovered",
803
- "enabled:active:bg-surface-inverse-hovered",
804
- "focus-visible:bg-surface-inverse-hovered"
805
- ])
806
- }
807
- ];
808
-
809
- // src/button/variants/contrast.ts
810
- var import_internal_utils7 = require("@spark-ui/internal-utils");
811
- var contrastVariants = [
812
- {
813
- intent: "main",
814
- design: "contrast",
815
- class: (0, import_internal_utils7.tw)([
816
- "text-on-main-contaier bg-surface",
817
- "hover:bg-main-container-hovered",
818
- "enabled:active:bg-main-container-hovered",
819
- "focus-visible:bg-main-container-hovered"
820
- ])
821
- },
822
- {
823
- intent: "support",
824
- design: "contrast",
825
- class: (0, import_internal_utils7.tw)([
826
- "text-on-support-container bg-surface",
827
- "hover:bg-support-container-hovered",
828
- "enabled:active:bg-support-container-hovered",
829
- "focus-visible:bg-support-container-hovered"
830
- ])
831
- },
832
- {
833
- intent: "accent",
834
- design: "contrast",
835
- class: (0, import_internal_utils7.tw)([
836
- "text-on-accent-container bg-surface",
837
- "hover:bg-accent-container-hovered",
838
- "enabled:active:bg-accent-container-hovered",
839
- "focus-visible:bg-accent-container-hovered"
840
- ])
841
- },
842
- {
843
- intent: "basic",
844
- design: "contrast",
845
- class: (0, import_internal_utils7.tw)([
846
- "text-on-basic-container bg-surface",
847
- "hover:bg-basic-container-hovered",
848
- "enabled:active:bg-basic-container-hovered",
849
- "focus-visible:bg-basic-container-hovered"
850
- ])
851
- },
852
- {
853
- intent: "success",
854
- design: "contrast",
855
- class: (0, import_internal_utils7.tw)([
856
- "text-on-success-container bg-surface",
857
- "hover:bg-success-container-hovered",
858
- "enabled:active:bg-success-container-hovered",
859
- "focus-visible:bg-success-container-hovered"
860
- ])
861
- },
862
- {
863
- intent: "alert",
864
- design: "contrast",
865
- class: (0, import_internal_utils7.tw)([
866
- "text-on-alert-container bg-surface",
867
- "hover:bg-alert-container-hovered",
868
- "enabled:active:bg-alert-container-hovered",
869
- "focus-visible:bg-alert-container-hovered"
870
- ])
871
- },
872
- {
873
- intent: "danger",
874
- design: "contrast",
875
- class: (0, import_internal_utils7.tw)([
876
- "text-on-error-container bg-surface",
877
- "hover:bg-error-container-hovered",
878
- "enabled:active:bg-error-container-hovered",
879
- "focus-visible:bg-error-container-hovered"
880
- ])
881
- },
882
- {
883
- intent: "info",
884
- design: "contrast",
885
- class: (0, import_internal_utils7.tw)([
886
- "text-on-info-container bg-surface",
887
- "hover:bg-info-container-hovered",
888
- "enabled:active:bg-info-container-hovered",
889
- "focus-visible:bg-info-container-hovered"
890
- ])
891
- },
892
- {
893
- intent: "neutral",
894
- design: "contrast",
895
- class: (0, import_internal_utils7.tw)([
896
- "text-on-neutral-container bg-surface",
897
- "hover:bg-neutral-container-hovered",
898
- "enabled:active:bg-neutral-container-hovered",
899
- "focus-visible:bg-neutral-container-hovered"
900
- ])
901
- },
902
- {
903
- intent: "surface",
904
- design: "contrast",
905
- class: (0, import_internal_utils7.tw)([
906
- "text-on-surface bg-surface",
907
- "hover:bg-surface-hovered",
908
- "enabled:active:bg-surface-hovered",
909
- "focus-visible:bg-surface-hovered"
910
- ])
911
- },
912
- {
913
- intent: "surfaceInverse",
914
- design: "contrast",
915
- class: (0, import_internal_utils7.tw)([
916
- "text-on-surface-inverse bg-surface-inverse",
917
- "hover:bg-surface-inverse-hovered",
918
- "enabled:active:bg-surface-inverse-hovered",
919
- "focus-visible:bg-surface-inverse-hovered"
920
- ])
921
- }
922
- ];
923
-
924
- // src/button/Button.styles.tsx
925
- var buttonStyles = (0, import_class_variance_authority4.cva)(
926
- [
927
- "u-shadow-border-transition",
928
- "box-border inline-flex items-center justify-center gap-md whitespace-nowrap",
929
- "default:px-lg",
930
- "text-body-1 font-bold",
931
- "focus-visible:u-outline"
932
- ],
933
- {
934
- variants: {
935
- /**
936
- * Main style of the button.
937
- *
938
- * - `filled`: Button will be plain.
939
- *
940
- * - `outlined`: Button will be transparent with an outline.
941
- *
942
- * - `tinted`: Button will be filled but using a lighter color scheme.
943
- *
944
- * - `ghost`: Button will look like a link. No borders, plain text.
945
- *
946
- * - `contrast`: Button will be surface filled. No borders, plain text.
947
- *
948
- */
949
- design: (0, import_internal_utils8.makeVariants)({
950
- filled: [],
951
- outlined: ["bg-transparent", "border-sm", "border-current"],
952
- tinted: [],
953
- ghost: ["default:-mx-md px-md hover:bg-main/dim-5"],
954
- contrast: []
955
- }),
956
- underline: {
957
- true: ["underline"]
958
- },
959
- /**
960
- * Color scheme of the button.
961
- */
962
- intent: (0, import_internal_utils8.makeVariants)({
963
- main: [],
964
- support: [],
965
- accent: [],
966
- basic: [],
967
- success: [],
968
- alert: [],
969
- danger: [],
970
- info: [],
971
- neutral: [],
972
- surface: [],
973
- surfaceInverse: []
974
- }),
975
- /**
976
- * Size of the button.
977
- */
978
- size: (0, import_internal_utils8.makeVariants)({
979
- sm: ["min-w-sz-32", "h-sz-32"],
980
- md: ["min-w-sz-44", "h-sz-44"],
981
- lg: ["min-w-sz-56", "h-sz-56"]
982
- }),
983
- /**
984
- * Shape of the button.
985
- */
986
- shape: (0, import_internal_utils8.makeVariants)({
987
- rounded: ["rounded-lg"],
988
- square: ["rounded-0"],
989
- pill: ["rounded-full"]
990
- }),
991
- /**
992
- * Disable the button, preventing user interaction and adding opacity.
993
- */
994
- disabled: {
995
- true: ["cursor-not-allowed", "opacity-dim-3"],
996
- false: ["cursor-pointer"]
997
- }
998
- },
999
- compoundVariants: [
1000
- ...filledVariants,
1001
- ...outlinedVariants,
1002
- ...tintedVariants,
1003
- ...ghostVariants,
1004
- ...contrastVariants
1005
- ],
1006
- defaultVariants: {
1007
- design: "filled",
1008
- intent: "main",
1009
- size: "md",
1010
- shape: "rounded"
1011
- }
1012
- }
1013
- );
1014
-
1015
- // src/button/Button.tsx
1016
- var import_jsx_runtime9 = require("react/jsx-runtime");
1017
- var blockedEventHandlers = [
1018
- "onClick",
1019
- "onMouseDown",
1020
- "onMouseUp",
1021
- "onMouseEnter",
1022
- "onMouseLeave",
1023
- "onMouseOver",
1024
- "onMouseOut",
1025
- "onKeyDown",
1026
- "onKeyPress",
1027
- "onKeyUp",
1028
- "onSubmit"
1029
- ];
1030
- var Button = ({
1031
- children,
1032
- design = "filled",
1033
- disabled = false,
1034
- intent = "main",
1035
- isLoading = false,
1036
- loadingLabel,
1037
- loadingText,
1038
- shape = "rounded",
1039
- size = "md",
1040
- asChild,
1041
- className,
1042
- underline = false,
1043
- ref,
1044
- ...others
1045
- }) => {
1046
- const Component = asChild ? Slot : "button";
1047
- const shouldNotInteract = !!disabled || isLoading;
1048
- const disabledEventHandlers = (0, import_react6.useMemo)(() => {
1049
- const result = {};
1050
- if (shouldNotInteract) {
1051
- blockedEventHandlers.forEach((eventHandler) => result[eventHandler] = void 0);
1052
- }
1053
- return result;
1054
- }, [shouldNotInteract]);
1055
- const spinnerProps = {
1056
- size: "current",
1057
- className: loadingText ? "inline-block" : "absolute",
1058
- ...loadingLabel && { "aria-label": loadingLabel }
1059
- };
1060
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1061
- Component,
1062
- {
1063
- "data-spark-component": "button",
1064
- ...Component === "button" && { type: "button" },
1065
- ref,
1066
- className: buttonStyles({
1067
- className,
1068
- design,
1069
- disabled: shouldNotInteract,
1070
- intent,
1071
- shape,
1072
- size,
1073
- underline
1074
- }),
1075
- disabled: !!disabled,
1076
- "aria-busy": isLoading,
1077
- "aria-live": isLoading ? "assertive" : "off",
1078
- ...others,
1079
- ...disabledEventHandlers,
1080
- children: wrapPolymorphicSlot(
1081
- asChild,
1082
- children,
1083
- (slotted) => isLoading ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
1084
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Spinner, { ...spinnerProps }),
1085
- loadingText && loadingText,
1086
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
1087
- "div",
1088
- {
1089
- "aria-hidden": true,
1090
- className: (0, import_class_variance_authority5.cx)("gap-md", loadingText ? "hidden" : "inline-flex opacity-0"),
1091
- children: slotted
1092
- }
1093
- )
1094
- ] }) : slotted
1095
- )
1096
- }
1097
- );
1098
- };
1099
- Button.displayName = "Button";
1100
-
1101
- // src/icon-button/IconButton.styles.tsx
1102
- var import_internal_utils9 = require("@spark-ui/internal-utils");
1103
- var import_class_variance_authority6 = require("class-variance-authority");
1104
- var iconButtonStyles = (0, import_class_variance_authority6.cva)(["pl-0 pr-0"], {
1105
- variants: {
1106
- /**
1107
- * Sets the size of the icon.
1108
- */
1109
- size: (0, import_internal_utils9.makeVariants)({
1110
- sm: ["text-body-1"],
1111
- md: ["text-body-1"],
1112
- lg: ["text-display-3"]
1113
- })
1114
- }
1115
- });
1116
-
1117
- // src/icon-button/IconButton.tsx
1118
- var import_jsx_runtime10 = require("react/jsx-runtime");
1119
- var IconButton = ({
1120
- design = "filled",
1121
- disabled = false,
1122
- intent = "main",
1123
- shape = "rounded",
1124
- size = "md",
1125
- className,
1126
- ref,
1127
- ...others
1128
- }) => {
1129
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1130
- Button,
1131
- {
1132
- "data-spark-component": "icon-button",
1133
- ref,
1134
- className: iconButtonStyles({ size, className }),
1135
- design,
1136
- disabled,
1137
- intent,
1138
- shape,
1139
- size,
1140
- ...others
1141
- }
1142
- );
1143
- };
1144
- IconButton.displayName = "IconButton";
1145
-
1146
- // src/dialog/DialogCloseButton.tsx
1147
- var import_jsx_runtime11 = require("react/jsx-runtime");
1148
- var Root = ({
1149
- "aria-label": ariaLabel,
1150
- className,
1151
- size = "md",
1152
- intent = "neutral",
1153
- design = "ghost",
1154
- children = /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(import_Close.Close, {}),
1155
- ref,
1156
- ...rest
160
+ var AlertDialogCancel = ({
161
+ asChild = false,
162
+ ref: forwardedRef,
163
+ ...props
1157
164
  }) => {
1158
- return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1159
- Close,
165
+ const { cancelRef } = useAlertDialog();
166
+ const ref = (0, import_use_merge_refs2.useMergeRefs)(forwardedRef, cancelRef);
167
+ const renderSlot = useRenderSlot(asChild, "button");
168
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
169
+ import_alert_dialog3.AlertDialog.Close,
1160
170
  {
1161
- "data-spark-component": "dialog-close-button",
1162
- "data-part": "close",
1163
171
  ref,
1164
- className: (0, import_class_variance_authority7.cx)(["absolute", "top-md", "right-xl"], className),
1165
- asChild: true,
1166
- ...rest,
1167
- children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(IconButton, { intent, size, design, "aria-label": ariaLabel, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Icon, { children }) })
172
+ "data-spark-component": "alert-dialog-cancel",
173
+ render: renderSlot,
174
+ ...props
1168
175
  }
1169
176
  );
1170
177
  };
1171
- var CloseButton = Object.assign(Root, {
1172
- id: "CloseButton"
1173
- });
1174
- Root.displayName = "Dialog.CloseButton";
178
+ AlertDialogCancel.displayName = "AlertDialog.Cancel";
1175
179
 
1176
- // src/dialog/DialogContent.tsx
1177
- var import_radix_ui4 = require("radix-ui");
1178
- var import_react7 = require("react");
180
+ // src/alert-dialog/AlertDialogContent.tsx
181
+ var import_alert_dialog4 = require("@base-ui-components/react/alert-dialog");
182
+ var import_class_variance_authority3 = require("class-variance-authority");
1179
183
 
1180
184
  // src/dialog/DialogContent.styles.tsx
1181
- var import_class_variance_authority8 = require("class-variance-authority");
1182
- var dialogContentStyles = (0, import_class_variance_authority8.cva)(
185
+ var import_class_variance_authority2 = require("class-variance-authority");
186
+ var dialogContentStyles = (0, import_class_variance_authority2.cva)(
1183
187
  [
1184
188
  "z-modal flex flex-col bg-surface group",
1185
189
  "focus-visible:outline-hidden focus-visible:u-outline",
@@ -1223,300 +227,142 @@ var dialogContentStyles = (0, import_class_variance_authority8.cva)(
1223
227
  }
1224
228
  );
1225
229
 
1226
- // src/dialog/DialogContent.tsx
1227
- var import_jsx_runtime12 = require("react/jsx-runtime");
1228
- var Content = ({
1229
- children,
1230
- className,
1231
- isNarrow = false,
1232
- size = "md",
1233
- onInteractOutside,
1234
- ref,
1235
- ...rest
1236
- }) => {
1237
- const { setIsFullScreen } = useDialog();
1238
- (0, import_react7.useEffect)(() => {
1239
- if (size === "fullscreen") setIsFullScreen(true);
1240
- return () => setIsFullScreen(false);
1241
- }, [setIsFullScreen, size]);
1242
- return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
1243
- import_radix_ui4.Dialog.Content,
230
+ // src/alert-dialog/AlertDialogContent.tsx
231
+ var import_jsx_runtime8 = require("react/jsx-runtime");
232
+ var AlertDialogContent = ({ className, ref, initialFocus, ...others }) => {
233
+ const { cancelRef } = useAlertDialog();
234
+ const handleInitialFocus = initialFocus !== void 0 ? initialFocus : () => cancelRef.current;
235
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
236
+ import_alert_dialog4.AlertDialog.Popup,
1244
237
  {
1245
- "data-spark-component": "dialog-content",
1246
238
  ref,
1247
- className: dialogContentStyles({
1248
- className,
1249
- isNarrow,
1250
- size
1251
- }),
1252
- onInteractOutside: (e) => {
1253
- const isForegroundElement = e.target.closest(".z-toast, .z-popover");
1254
- if (isForegroundElement) {
1255
- e.preventDefault();
1256
- }
1257
- onInteractOutside?.(e);
1258
- },
1259
- ...rest,
1260
- children
239
+ "data-spark-component": "alert-dialog-content",
240
+ role: "alertdialog",
241
+ className: (state) => (0, import_class_variance_authority3.cx)(
242
+ dialogContentStyles({ size: "md", isNarrow: true }),
243
+ "min-w-sz-288",
244
+ // Base UI automatically adds data-[starting-style] and data-[ending-style] attributes
245
+ // Transition with opacity and scale for smooth open/close animations
246
+ "transition-all duration-150",
247
+ "data-starting-style:scale-90 data-starting-style:opacity-0",
248
+ "data-ending-style:scale-90 data-ending-style:opacity-0",
249
+ typeof className === "function" ? className(state) : className
250
+ ),
251
+ initialFocus: handleInitialFocus,
252
+ ...others
1261
253
  }
1262
254
  );
1263
255
  };
1264
- Content.displayName = "Dialog.Content";
256
+ AlertDialogContent.displayName = "AlertDialog.Content";
1265
257
 
1266
- // src/dialog/DialogDescription.tsx
1267
- var import_radix_ui5 = require("radix-ui");
1268
- var import_jsx_runtime13 = require("react/jsx-runtime");
1269
- var Description = (props) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_radix_ui5.Dialog.Description, { "data-spark-component": "dialog-description", ...props });
1270
- Description.displayName = "Dialog.Description";
258
+ // src/alert-dialog/AlertDialogDescription.tsx
259
+ var import_alert_dialog5 = require("@base-ui-components/react/alert-dialog");
260
+ var import_jsx_runtime9 = require("react/jsx-runtime");
261
+ var AlertDialogDescription = (props) => {
262
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_alert_dialog5.AlertDialog.Description, { "data-spark-component": "alert-dialog-description", ...props });
263
+ };
264
+ AlertDialogDescription.displayName = "AlertDialog.Description";
1271
265
 
1272
- // src/dialog/DialogFooter.tsx
1273
- var import_class_variance_authority9 = require("class-variance-authority");
1274
- var import_jsx_runtime14 = require("react/jsx-runtime");
1275
- var Footer = ({ children, className, ref, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
266
+ // src/alert-dialog/AlertDialogFooter.tsx
267
+ var import_class_variance_authority4 = require("class-variance-authority");
268
+ var import_jsx_runtime10 = require("react/jsx-runtime");
269
+ var AlertDialogFooter = ({
270
+ children,
271
+ className,
272
+ ref,
273
+ ...rest
274
+ }) => /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
1276
275
  "footer",
1277
276
  {
1278
- "data-spark-component": "dialog-footer",
277
+ "data-spark-component": "alert-dialog-footer",
1279
278
  ref,
1280
- className: (0, import_class_variance_authority9.cx)(className, ["px-xl", "py-lg"]),
279
+ className: (0, import_class_variance_authority4.cx)(className, ["px-xl", "py-lg"]),
1281
280
  ...rest,
1282
281
  children
1283
282
  }
1284
283
  );
1285
- Footer.displayName = "Dialog.Footer";
284
+ AlertDialogFooter.displayName = "AlertDialog.Footer";
1286
285
 
1287
- // src/dialog/DialogHeader.tsx
1288
- var import_class_variance_authority10 = require("class-variance-authority");
1289
- var import_jsx_runtime15 = require("react/jsx-runtime");
1290
- var Header = ({ children, className, ref, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
286
+ // src/alert-dialog/AlertDialogHeader.tsx
287
+ var import_class_variance_authority5 = require("class-variance-authority");
288
+ var import_jsx_runtime11 = require("react/jsx-runtime");
289
+ var AlertDialogHeader = ({
290
+ children,
291
+ className,
292
+ ref,
293
+ ...rest
294
+ }) => /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
1291
295
  "header",
1292
296
  {
1293
- "data-spark-component": "dialog-header",
297
+ "data-spark-component": "alert-dialog-header",
1294
298
  ref,
1295
- className: (0, import_class_variance_authority10.cx)(className, ["px-xl", "py-lg"]),
299
+ className: (0, import_class_variance_authority5.cx)(className, ["px-xl", "py-lg"]),
1296
300
  ...rest,
1297
301
  children
1298
302
  }
1299
303
  );
1300
- Header.displayName = "Dialog.Header";
1301
-
1302
- // src/dialog/DialogOverlay.tsx
1303
- var import_class_variance_authority11 = require("class-variance-authority");
1304
- var import_radix_ui6 = require("radix-ui");
1305
- var import_jsx_runtime16 = require("react/jsx-runtime");
1306
- var Overlay = ({ className, ref, ...rest }) => {
1307
- const { isFullScreen } = useDialog();
1308
- return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
1309
- import_radix_ui6.Dialog.Overlay,
1310
- {
1311
- "data-spark-component": "dialog-overlay",
1312
- ref,
1313
- className: (0, import_class_variance_authority11.cx)(
1314
- isFullScreen ? "hidden" : "fixed",
1315
- ["top-0", "left-0", "w-screen", "h-screen", "z-overlay"],
1316
- ["bg-overlay/dim-1"],
1317
- ["data-[state=open]:animate-fade-in"],
1318
- ["data-[state=closed]:animate-fade-out"],
1319
- className
1320
- ),
1321
- ...rest
1322
- }
1323
- );
1324
- };
1325
- Overlay.displayName = "Dialog.Overlay";
1326
-
1327
- // src/dialog/DialogPortal.tsx
1328
- var import_radix_ui7 = require("radix-ui");
1329
- var import_jsx_runtime17 = require("react/jsx-runtime");
1330
- var Portal = ({ children, ...rest }) => /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_radix_ui7.Dialog.Portal, { ...rest, children });
1331
- Portal.displayName = "Dialog.Portal";
304
+ AlertDialogHeader.displayName = "AlertDialog.Header";
1332
305
 
1333
- // src/dialog/DialogTitle.tsx
1334
- var import_class_variance_authority12 = require("class-variance-authority");
1335
- var import_radix_ui8 = require("radix-ui");
1336
- var import_jsx_runtime18 = require("react/jsx-runtime");
1337
- var Title = ({ className, ref, ...others }) => {
1338
- return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
1339
- import_radix_ui8.Dialog.Title,
306
+ // src/alert-dialog/AlertDialogOverlay.tsx
307
+ var import_alert_dialog6 = require("@base-ui-components/react/alert-dialog");
308
+ var import_class_variance_authority6 = require("class-variance-authority");
309
+ var import_jsx_runtime12 = require("react/jsx-runtime");
310
+ var AlertDialogOverlay = ({ className, ...props }) => {
311
+ return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
312
+ import_alert_dialog6.AlertDialog.Backdrop,
1340
313
  {
1341
- "data-spark-component": "dialog-title",
1342
- ref,
1343
- className: (0, import_class_variance_authority12.cx)(
1344
- "text-headline-1 text-on-surface",
1345
- "group-has-data-[part=close]:pr-3xl",
1346
- className
314
+ "data-spark-component": "alert-dialog-overlay",
315
+ className: (state) => (0, import_class_variance_authority6.cx)(
316
+ "z-overlay fixed top-0 left-0 h-screen w-screen",
317
+ "bg-overlay/dim-1",
318
+ // Base UI automatically adds data-[starting-style] and data-[ending-style] attributes
319
+ "data-[starting-style]:animate-fade-in",
320
+ "data-[ending-style]:animate-fade-out",
321
+ typeof className === "function" ? className(state) : className
1347
322
  ),
1348
- ...others
323
+ ...props
1349
324
  }
1350
325
  );
1351
326
  };
1352
- Title.displayName = "Dialog.Title";
1353
-
1354
- // src/dialog/DialogTrigger.tsx
1355
- var import_radix_ui9 = require("radix-ui");
1356
- var import_jsx_runtime19 = require("react/jsx-runtime");
1357
- var Trigger = (props) => /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(import_radix_ui9.Dialog.Trigger, { "data-spark-component": "dialog-trigger", ...props });
1358
- Trigger.displayName = "Dialog.Trigger";
1359
-
1360
- // src/dialog/index.ts
1361
- var Dialog2 = Object.assign(Dialog, {
1362
- Trigger,
1363
- Portal,
1364
- Overlay,
1365
- Content,
1366
- Header,
1367
- Body,
1368
- Footer,
1369
- Close,
1370
- CloseButton,
1371
- Title,
1372
- Description
1373
- });
1374
- Dialog2.displayName = "Dialog";
1375
- Dialog2.Trigger.displayName = "Dialog.Trigger";
1376
- Trigger.displayName = "Dialog.Trigger";
1377
- Portal.displayName = "Dialog.Portal";
1378
- Overlay.displayName = "Dialog.Overlay";
1379
- Content.displayName = "Dialog.Content";
1380
- Header.displayName = "Dialog.Header";
1381
- Body.displayName = "Dialog.Body";
1382
- Footer.displayName = "Dialog.Footer";
1383
- CloseButton.displayName = "Dialog.CloseButton";
1384
- Title.displayName = "Dialog.Title";
1385
- Description.displayName = "Dialog.Description";
1386
-
1387
- // src/alert-dialog/AlertDialog.tsx
1388
- var import_jsx_runtime20 = require("react/jsx-runtime");
1389
- var AlertDialog = (props) => {
1390
- return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Dialog2, { "data-spark-component": "alert-dialog", ...props, modal: true });
1391
- };
1392
- AlertDialog.displayName = "AlertDialog";
1393
-
1394
- // src/alert-dialog/AlertDialogAction.tsx
1395
- var import_jsx_runtime21 = require("react/jsx-runtime");
1396
- var AlertDialogAction = (props) => {
1397
- return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Dialog2.Close, { "data-spark-component": "alert-dialog-action", ...props });
1398
- };
1399
- AlertDialogAction.displayName = "AlertDialog.Action";
1400
-
1401
- // src/alert-dialog/AlertDialogBody.tsx
1402
- var import_jsx_runtime22 = require("react/jsx-runtime");
1403
- var AlertDialogBody = (props) => {
1404
- return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(Dialog2.Body, { "data-spark-component": "alert-dialog-body", ...props });
1405
- };
1406
- AlertDialogBody.displayName = "AlertDialog.Body";
1407
-
1408
- // src/alert-dialog/AlertDialogCancel.tsx
1409
- var import_use_merge_refs2 = require("@spark-ui/hooks/use-merge-refs");
1410
-
1411
- // src/alert-dialog/AlertDialogContext.ts
1412
- var import_react8 = require("react");
1413
- var AlertDialogContext = (0, import_react8.createContext)(null);
1414
- var useAlertDialog = () => {
1415
- const context = (0, import_react8.useContext)(AlertDialogContext);
1416
- if (!context) {
1417
- throw Error("useAlertDialog must be used within a RadioGroup provider");
1418
- }
1419
- return context;
1420
- };
1421
-
1422
- // src/alert-dialog/AlertDialogCancel.tsx
1423
- var import_jsx_runtime23 = require("react/jsx-runtime");
1424
- var AlertDialogCancel = ({ ref: forwardedRef, ...props }) => {
1425
- const { cancelRef } = useAlertDialog();
1426
- const ref = (0, import_use_merge_refs2.useMergeRefs)(forwardedRef, cancelRef);
1427
- return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Dialog2.Close, { ref, "data-spark-component": "alert-dialog-cancel", ...props });
1428
- };
1429
- AlertDialogCancel.displayName = "AlertDialog.Cancel";
1430
-
1431
- // src/alert-dialog/AlertDialogContent.tsx
1432
- var import_class_variance_authority13 = require("class-variance-authority");
1433
- var import_internal = require("radix-ui/internal");
1434
- var import_react9 = require("react");
1435
- var import_jsx_runtime24 = require("react/jsx-runtime");
1436
- var AlertDialogContent = ({
1437
- className,
1438
- onOpenAutoFocus,
1439
- ref,
1440
- ...others
1441
- }) => {
1442
- const cancelRef = (0, import_react9.useRef)(null);
1443
- const value = (0, import_react9.useMemo)(() => {
1444
- return { cancelRef };
1445
- }, []);
1446
- const handleOpenAutoFocus = (event) => {
1447
- event.preventDefault();
1448
- cancelRef.current?.focus({ preventScroll: true });
1449
- };
1450
- const handlePointerDownOutside = (event) => {
1451
- event.preventDefault();
1452
- };
1453
- const handleInteractOutside = (event) => {
1454
- event.preventDefault();
1455
- };
1456
- return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(AlertDialogContext.Provider, { value, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
1457
- Dialog2.Content,
1458
- {
1459
- ref,
1460
- "data-spark-component": "alert-dialog-content",
1461
- ...others,
1462
- className: (0, import_class_variance_authority13.cx)(className, "min-w-sz-288"),
1463
- role: "alertdialog",
1464
- size: "md",
1465
- onOpenAutoFocus: (0, import_internal.composeEventHandlers)(onOpenAutoFocus, handleOpenAutoFocus),
1466
- onPointerDownOutside: handlePointerDownOutside,
1467
- onInteractOutside: handleInteractOutside,
1468
- isNarrow: true
1469
- }
1470
- ) });
1471
- };
1472
- AlertDialogContent.displayName = "AlertDialog.Content";
1473
-
1474
- // src/alert-dialog/AlertDialogDescription.tsx
1475
- var import_jsx_runtime25 = require("react/jsx-runtime");
1476
- var AlertDialogDescription = (props) => {
1477
- return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(Dialog2.Description, { "data-spark-component": "alert-dialog-description", ...props });
1478
- };
1479
- AlertDialogDescription.displayName = "AlertDialog.Description";
1480
-
1481
- // src/alert-dialog/AlertDialogFooter.tsx
1482
- var import_jsx_runtime26 = require("react/jsx-runtime");
1483
- var AlertDialogFooter = (props) => {
1484
- return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(Dialog2.Footer, { "data-spark-component": "alert-dialog-footer", ...props });
1485
- };
1486
- AlertDialogFooter.displayName = "AlertDialog.Footer";
1487
-
1488
- // src/alert-dialog/AlertDialogHeader.tsx
1489
- var import_jsx_runtime27 = require("react/jsx-runtime");
1490
- var AlertDialogHeader = (props) => {
1491
- return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Dialog2.Header, { "data-spark-component": "alert-dialog-header", ...props });
1492
- };
1493
- AlertDialogHeader.displayName = "AlertDialog.Header";
1494
-
1495
- // src/alert-dialog/AlertDialogOverlay.tsx
1496
- var import_jsx_runtime28 = require("react/jsx-runtime");
1497
- var AlertDialogOverlay = (props) => {
1498
- return /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Dialog2.Overlay, { "data-spark-component": "alert-dialog-overlay", ...props });
1499
- };
1500
327
  AlertDialogOverlay.displayName = "AlertDialog.Overlay";
1501
328
 
1502
329
  // src/alert-dialog/AlertDialogPortal.tsx
1503
- var import_jsx_runtime29 = require("react/jsx-runtime");
330
+ var import_alert_dialog7 = require("@base-ui-components/react/alert-dialog");
331
+ var import_jsx_runtime13 = require("react/jsx-runtime");
1504
332
  var AlertDialogPortal = (props) => {
1505
- return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(Dialog2.Portal, { "data-spark-component": "alert-dialog-portal", ...props });
333
+ return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(import_alert_dialog7.AlertDialog.Portal, { "data-spark-component": "alert-dialog-portal", ...props });
1506
334
  };
1507
335
  AlertDialogPortal.displayName = "AlertDialog.Portal";
1508
336
 
1509
337
  // src/alert-dialog/AlertDialogTitle.tsx
1510
- var import_jsx_runtime30 = require("react/jsx-runtime");
1511
- var AlertDialogTitle = (props) => {
1512
- return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Dialog2.Title, { "data-spark-component": "alert-dialog-title", ...props });
338
+ var import_alert_dialog8 = require("@base-ui-components/react/alert-dialog");
339
+ var import_class_variance_authority7 = require("class-variance-authority");
340
+ var import_jsx_runtime14 = require("react/jsx-runtime");
341
+ var AlertDialogTitle = ({ className, ...props }) => {
342
+ return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
343
+ import_alert_dialog8.AlertDialog.Title,
344
+ {
345
+ "data-spark-component": "alert-dialog-title",
346
+ className: (0, import_class_variance_authority7.cx)("text-headline-1 text-on-surface", className),
347
+ ...props
348
+ }
349
+ );
1513
350
  };
1514
351
  AlertDialogTitle.displayName = "AlertDialog.Title";
1515
352
 
1516
353
  // src/alert-dialog/AlertDialogTrigger.tsx
1517
- var import_jsx_runtime31 = require("react/jsx-runtime");
1518
- var AlertDialogTrigger = (props) => {
1519
- return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(Dialog2.Trigger, { "data-spark-component": "alert-dialog-title", ...props });
354
+ var import_alert_dialog9 = require("@base-ui-components/react/alert-dialog");
355
+ var import_jsx_runtime15 = require("react/jsx-runtime");
356
+ var AlertDialogTrigger = ({ asChild = false, ...props }) => {
357
+ const renderSlot = useRenderSlot(asChild, "button");
358
+ return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
359
+ import_alert_dialog9.AlertDialog.Trigger,
360
+ {
361
+ "data-spark-component": "alert-dialog-trigger",
362
+ render: renderSlot,
363
+ ...props
364
+ }
365
+ );
1520
366
  };
1521
367
  AlertDialogTrigger.displayName = "AlertDialog.Trigger";
1522
368