@spark-ui/components 11.5.0 → 11.6.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.
Files changed (44) hide show
  1. package/dist/alert-dialog/index.mjs +3 -3
  2. package/dist/avatar/index.d.mts +2 -2
  3. package/dist/avatar/index.d.ts +2 -2
  4. package/dist/avatar/index.mjs +2 -2
  5. package/dist/button/index.mjs +1 -1
  6. package/dist/carousel/index.mjs +2 -2
  7. package/dist/{chunk-HEKSVWYW.mjs → chunk-2YM6GKWW.mjs} +2 -1
  8. package/dist/{chunk-TKAU6SMC.mjs → chunk-7EWSMIZU.mjs} +21 -4
  9. package/dist/chunk-7EWSMIZU.mjs.map +1 -0
  10. package/dist/{chunk-XYK6V3JF.mjs → chunk-DCXWGQVZ.mjs} +2 -2
  11. package/dist/{chunk-D7YBYT5H.mjs → chunk-GPJMLIHC.mjs} +2 -2
  12. package/dist/{chunk-2BSBKLHG.mjs → chunk-WLI4EPS6.mjs} +2 -2
  13. package/dist/combobox/index.mjs +3 -3
  14. package/dist/dialog/index.mjs +3 -3
  15. package/dist/docgen.json +344 -65
  16. package/dist/drawer/index.mjs +2 -2
  17. package/dist/dropdown/index.mjs +3 -3
  18. package/dist/file-upload/index.d.mts +51 -32
  19. package/dist/file-upload/index.d.ts +51 -32
  20. package/dist/file-upload/index.js +256 -129
  21. package/dist/file-upload/index.js.map +1 -1
  22. package/dist/file-upload/index.mjs +219 -109
  23. package/dist/file-upload/index.mjs.map +1 -1
  24. package/dist/icon-button/index.mjs +2 -2
  25. package/dist/pagination/index.mjs +2 -2
  26. package/dist/popover/index.mjs +3 -3
  27. package/dist/progress/index.d.mts +6 -2
  28. package/dist/progress/index.d.ts +6 -2
  29. package/dist/progress/index.js +20 -3
  30. package/dist/progress/index.js.map +1 -1
  31. package/dist/progress/index.mjs +1 -1
  32. package/dist/scrolling-list/index.mjs +2 -2
  33. package/dist/snackbar/index.mjs +2 -2
  34. package/dist/stepper/index.mjs +2 -2
  35. package/dist/tabs/index.mjs +1 -1
  36. package/dist/toast/index.d.mts +6 -6
  37. package/dist/toast/index.d.ts +6 -6
  38. package/dist/toast/index.mjs +2 -2
  39. package/package.json +5 -5
  40. package/dist/chunk-TKAU6SMC.mjs.map +0 -1
  41. /package/dist/{chunk-HEKSVWYW.mjs.map → chunk-2YM6GKWW.mjs.map} +0 -0
  42. /package/dist/{chunk-XYK6V3JF.mjs.map → chunk-DCXWGQVZ.mjs.map} +0 -0
  43. /package/dist/{chunk-D7YBYT5H.mjs.map → chunk-GPJMLIHC.mjs.map} +0 -0
  44. /package/dist/{chunk-2BSBKLHG.mjs.map → chunk-WLI4EPS6.mjs.map} +0 -0
@@ -1,15 +1,16 @@
1
1
  import {
2
2
  Progress
3
- } from "../chunk-TKAU6SMC.mjs";
3
+ } from "../chunk-7EWSMIZU.mjs";
4
4
  import {
5
5
  IconButton
6
- } from "../chunk-XYK6V3JF.mjs";
6
+ } from "../chunk-DCXWGQVZ.mjs";
7
7
  import {
8
8
  Icon
9
9
  } from "../chunk-UMUMFMFB.mjs";
10
10
  import {
11
- Button
12
- } from "../chunk-HEKSVWYW.mjs";
11
+ Button,
12
+ buttonStyles
13
+ } from "../chunk-2YM6GKWW.mjs";
13
14
  import "../chunk-GAK4SC2F.mjs";
14
15
  import "../chunk-KEGAAGJW.mjs";
15
16
  import {
@@ -18,8 +19,39 @@ import {
18
19
 
19
20
  // src/file-upload/FileUpload.tsx
20
21
  import { useFormFieldControl } from "@spark-ui/components/form-field";
22
+ import { createContext, useContext, useId, useRef } from "react";
23
+
24
+ // src/file-upload/useFileUploadState.tsx
21
25
  import { useCombinedState } from "@spark-ui/hooks/use-combined-state";
22
- import { createContext, useContext, useId, useRef, useState } from "react";
26
+ import { useState } from "react";
27
+
28
+ // src/file-upload/constants.ts
29
+ var FILE_UPLOAD_ERRORS = {
30
+ /**
31
+ * Exceeds the maxFiles limit
32
+ */
33
+ TOO_MANY_FILES: "TOO_MANY_FILES",
34
+ /**
35
+ * File type not in the accept list
36
+ */
37
+ FILE_INVALID_TYPE: "FILE_INVALID_TYPE",
38
+ /**
39
+ * File size exceeds maxFileSize
40
+ */
41
+ FILE_TOO_LARGE: "FILE_TOO_LARGE",
42
+ /**
43
+ * File size below minFileSize
44
+ */
45
+ FILE_TOO_SMALL: "FILE_TOO_SMALL",
46
+ /**
47
+ * Generic validation failure
48
+ */
49
+ FILE_INVALID: "FILE_INVALID",
50
+ /**
51
+ * Duplicate file detected
52
+ */
53
+ FILE_EXISTS: "FILE_EXISTS"
54
+ };
23
55
 
24
56
  // src/file-upload/utils.ts
25
57
  import { CvOutline } from "@spark-ui/icons/CvOutline";
@@ -120,13 +152,8 @@ function getFileIcon(file) {
120
152
  return createElement(CvOutline);
121
153
  }
122
154
 
123
- // src/file-upload/FileUpload.tsx
124
- import { jsx, jsxs } from "react/jsx-runtime";
125
- var FileUploadContext = createContext(null);
126
- var ID_PREFIX = ":file-upload";
127
- var FileUpload = ({
128
- asChild: _asChild = false,
129
- children,
155
+ // src/file-upload/useFileUploadState.tsx
156
+ function useFileUploadState({
130
157
  defaultValue = [],
131
158
  value: controlledValue,
132
159
  onFileAccept,
@@ -137,31 +164,12 @@ var FileUpload = ({
137
164
  maxFiles,
138
165
  maxFileSize,
139
166
  minFileSize,
140
- disabled: disabledProp = false,
141
- readOnly: readOnlyProp = false,
167
+ disabled = false,
168
+ readOnly = false,
142
169
  locale
143
- }) => {
144
- const field = useFormFieldControl();
145
- const {
146
- id: fieldId,
147
- name: fieldName,
148
- isInvalid,
149
- isRequired,
150
- description,
151
- disabled: fieldDisabled,
152
- readOnly: fieldReadOnly
153
- } = field;
170
+ }) {
154
171
  const defaultLocale = locale || (typeof navigator !== "undefined" && navigator.language ? navigator.language : "en");
155
- const internalId = useId();
156
- const inputId = fieldId || `${ID_PREFIX}-${internalId}`;
157
- const inputName = fieldName;
158
- const inputRef = useRef(null);
159
- const triggerRef = useRef(null);
160
- const dropzoneRef = useRef(null);
161
- const deleteButtonRefs = useRef([]);
162
- const disabled = fieldDisabled ?? disabledProp;
163
- const readOnly = fieldReadOnly ?? readOnlyProp;
164
- const [filesState, setFilesState, ,] = useCombinedState(controlledValue, defaultValue);
172
+ const [filesState, setFilesState] = useCombinedState(controlledValue, defaultValue);
165
173
  const files = filesState ?? [];
166
174
  const setFiles = setFilesState;
167
175
  const [rejectedFiles, setRejectedFiles] = useState([]);
@@ -193,20 +201,17 @@ var FileUpload = ({
193
201
  };
194
202
  setFiles((prev) => {
195
203
  const currentFiles = prev ?? [];
196
- if (maxFiles !== void 0) {
197
- const currentCount = currentFiles.length;
198
- const remainingSlots = maxFiles - currentCount;
199
- if (remainingSlots <= 0) {
200
- newFiles.forEach((file) => {
201
- addRejectedFile(file, "TOO_MANY_FILES");
202
- });
203
- }
204
+ const remainingSlots = maxFiles !== void 0 ? maxFiles - currentFiles.length : void 0;
205
+ if (remainingSlots !== void 0 && remainingSlots <= 0) {
206
+ newFiles.forEach((file) => {
207
+ addRejectedFile(file, FILE_UPLOAD_ERRORS.TOO_MANY_FILES);
208
+ });
204
209
  }
205
210
  let filteredFiles = newFiles;
206
211
  if (accept) {
207
212
  const rejectedByAccept = newFiles.filter((file) => !validateFileAccept(file, accept));
208
213
  rejectedByAccept.forEach((file) => {
209
- addRejectedFile(file, "FILE_INVALID_TYPE");
214
+ addRejectedFile(file, FILE_UPLOAD_ERRORS.FILE_INVALID_TYPE);
210
215
  });
211
216
  filteredFiles = newFiles.filter((file) => validateFileAccept(file, accept));
212
217
  }
@@ -216,11 +221,11 @@ var FileUpload = ({
216
221
  const validation = validateFileSize(file, minFileSize, maxFileSize, defaultLocale);
217
222
  if (!validation.valid) {
218
223
  if (maxFileSize !== void 0 && file.size > maxFileSize) {
219
- addRejectedFile(file, "FILE_TOO_LARGE");
224
+ addRejectedFile(file, FILE_UPLOAD_ERRORS.FILE_TOO_LARGE);
220
225
  } else if (minFileSize !== void 0 && file.size < minFileSize) {
221
- addRejectedFile(file, "FILE_TOO_SMALL");
226
+ addRejectedFile(file, FILE_UPLOAD_ERRORS.FILE_TOO_SMALL);
222
227
  } else {
223
- addRejectedFile(file, "FILE_INVALID");
228
+ addRejectedFile(file, FILE_UPLOAD_ERRORS.FILE_INVALID);
224
229
  }
225
230
  return false;
226
231
  }
@@ -228,35 +233,27 @@ var FileUpload = ({
228
233
  });
229
234
  }
230
235
  const seenFiles = /* @__PURE__ */ new Map();
231
- const duplicateFiles = [];
232
236
  const uniqueFiles = validSizeFiles.filter((file) => {
233
237
  const fileKey = `${file.name}-${file.size}`;
234
238
  const existsInPrev = fileExists(file, currentFiles);
235
239
  if (existsInPrev) {
236
- duplicateFiles.push(file);
237
- addRejectedFile(file, "FILE_EXISTS");
240
+ addRejectedFile(file, FILE_UPLOAD_ERRORS.FILE_EXISTS);
238
241
  return false;
239
242
  }
240
243
  if (seenFiles.has(fileKey)) {
241
- duplicateFiles.push(file);
242
- addRejectedFile(file, "FILE_EXISTS");
244
+ addRejectedFile(file, FILE_UPLOAD_ERRORS.FILE_EXISTS);
243
245
  return false;
244
246
  }
245
247
  seenFiles.set(fileKey, file);
246
248
  return true;
247
249
  });
248
250
  let filesToAdd = multiple ? uniqueFiles : uniqueFiles.slice(0, 1);
249
- if (maxFiles !== void 0) {
250
- const currentCount = currentFiles.length;
251
- const remainingSlots = maxFiles - currentCount;
251
+ if (remainingSlots !== void 0) {
252
252
  if (remainingSlots <= 0) {
253
- filesToAdd.forEach((file) => {
254
- addRejectedFile(file, "TOO_MANY_FILES");
255
- });
256
253
  filesToAdd = [];
257
254
  } else if (filesToAdd.length > remainingSlots) {
258
255
  filesToAdd.forEach((file) => {
259
- addRejectedFile(file, "TOO_MANY_FILES");
256
+ addRejectedFile(file, FILE_UPLOAD_ERRORS.TOO_MANY_FILES);
260
257
  });
261
258
  filesToAdd = [];
262
259
  }
@@ -289,7 +286,7 @@ var FileUpload = ({
289
286
  let updatedRejectedFiles = rejectedFiles;
290
287
  if (maxFiles !== void 0 && updated.length < maxFiles) {
291
288
  updatedRejectedFiles = rejectedFiles.filter(
292
- (rejected) => !rejected.errors.includes("TOO_MANY_FILES")
289
+ (rejected) => !rejected.errors.includes(FILE_UPLOAD_ERRORS.TOO_MANY_FILES)
293
290
  );
294
291
  setRejectedFiles(updatedRejectedFiles);
295
292
  }
@@ -308,7 +305,6 @@ var FileUpload = ({
308
305
  }
309
306
  setFiles([]);
310
307
  setRejectedFiles([]);
311
- deleteButtonRefs.current = [];
312
308
  if (onFileChange) {
313
309
  onFileChange({
314
310
  acceptedFiles: [],
@@ -326,6 +322,77 @@ var FileUpload = ({
326
322
  setRejectedFiles([]);
327
323
  };
328
324
  const maxFilesReached = maxFiles !== void 0 && files.length >= maxFiles;
325
+ return {
326
+ files,
327
+ rejectedFiles,
328
+ addFiles,
329
+ removeFile,
330
+ removeRejectedFile,
331
+ clearFiles,
332
+ clearRejectedFiles,
333
+ maxFilesReached
334
+ };
335
+ }
336
+
337
+ // src/file-upload/FileUpload.tsx
338
+ import { jsx, jsxs } from "react/jsx-runtime";
339
+ var FileUploadContext = createContext(null);
340
+ var ID_PREFIX = ":file-upload";
341
+ var FileUpload = ({
342
+ asChild: _asChild = false,
343
+ children,
344
+ defaultValue = [],
345
+ value: controlledValue,
346
+ onFileAccept,
347
+ onFileReject,
348
+ onFileChange,
349
+ multiple = true,
350
+ accept,
351
+ maxFiles,
352
+ maxFileSize,
353
+ minFileSize,
354
+ disabled: disabledProp = false,
355
+ readOnly: readOnlyProp = false,
356
+ locale
357
+ }) => {
358
+ const field = useFormFieldControl();
359
+ const internalId = useId();
360
+ const inputId = field.id || `${ID_PREFIX}-${internalId}`;
361
+ const inputName = field.name;
362
+ const inputRef = useRef(null);
363
+ const triggerRef = useRef(null);
364
+ const dropzoneRef = useRef(null);
365
+ const deleteButtonRefs = useRef([]);
366
+ const disabled = field.disabled ?? disabledProp;
367
+ const readOnly = field.readOnly ?? readOnlyProp;
368
+ const {
369
+ files,
370
+ rejectedFiles,
371
+ addFiles,
372
+ removeFile,
373
+ removeRejectedFile,
374
+ clearFiles: clearFilesFromHook,
375
+ clearRejectedFiles,
376
+ maxFilesReached
377
+ } = useFileUploadState({
378
+ defaultValue,
379
+ value: controlledValue,
380
+ onFileAccept,
381
+ onFileReject,
382
+ onFileChange,
383
+ multiple,
384
+ accept,
385
+ maxFiles,
386
+ maxFileSize,
387
+ minFileSize,
388
+ disabled,
389
+ readOnly,
390
+ locale
391
+ });
392
+ const clearFiles = () => {
393
+ clearFilesFromHook();
394
+ deleteButtonRefs.current = [];
395
+ };
329
396
  return /* @__PURE__ */ jsx(
330
397
  FileUploadContext.Provider,
331
398
  {
@@ -346,10 +413,10 @@ var FileUpload = ({
346
413
  maxFilesReached,
347
414
  disabled,
348
415
  readOnly,
349
- locale: defaultLocale,
350
- description,
351
- isInvalid,
352
- isRequired
416
+ locale: locale || (typeof navigator !== "undefined" && navigator.language ? navigator.language : "en"),
417
+ description: field.description,
418
+ isInvalid: field.isInvalid,
419
+ isRequired: field.isRequired
353
420
  },
354
421
  children: /* @__PURE__ */ jsxs("div", { className: "relative", children: [
355
422
  children,
@@ -365,9 +432,10 @@ var FileUpload = ({
365
432
  accept,
366
433
  disabled,
367
434
  readOnly: readOnly && !disabled,
368
- required: isRequired,
369
- "aria-invalid": isInvalid,
370
- "aria-describedby": description,
435
+ required: field.isRequired,
436
+ "aria-invalid": field.isInvalid,
437
+ "aria-describedby": field.description,
438
+ "aria-label": !field.labelId ? "Upload files" : void 0,
371
439
  className: "sr-only",
372
440
  onChange: (e) => {
373
441
  if (e.target.files && !disabled && !readOnly) {
@@ -395,6 +463,7 @@ var useFileUploadContext = () => {
395
463
 
396
464
  // src/file-upload/FileUploadAcceptedFile.tsx
397
465
  import { cx as cx2 } from "class-variance-authority";
466
+ import { useCallback, useEffect, useState as useState2 } from "react";
398
467
 
399
468
  // src/file-upload/FileUploadItemDeleteTrigger.tsx
400
469
  import { Close } from "@spark-ui/icons/Close";
@@ -415,7 +484,7 @@ var ItemDeleteTrigger = ({
415
484
  return;
416
485
  }
417
486
  removeFile(fileIndex);
418
- setTimeout(() => {
487
+ requestAnimationFrame(() => {
419
488
  const remainingButtons = deleteButtonRefs.current.filter(Boolean);
420
489
  if (remainingButtons.length > 0) {
421
490
  const targetIndex = Math.min(fileIndex, remainingButtons.length - 1);
@@ -429,7 +498,7 @@ var ItemDeleteTrigger = ({
429
498
  focusTarget.focus();
430
499
  }
431
500
  }
432
- }, 0);
501
+ });
433
502
  onClick?.(e);
434
503
  };
435
504
  const setRef = (node) => {
@@ -466,7 +535,6 @@ ItemDeleteTrigger.displayName = "FileUpload.ItemDeleteTrigger";
466
535
  // src/file-upload/FileUploadAcceptedFile.tsx
467
536
  import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
468
537
  var AcceptedFile = ({
469
- asChild: _asChild = false,
470
538
  className,
471
539
  file,
472
540
  uploadProgress,
@@ -475,6 +543,17 @@ var AcceptedFile = ({
475
543
  ...props
476
544
  }) => {
477
545
  const { locale } = useFileUploadContext();
546
+ const [showProgress, setShowProgress] = useState2(uploadProgress !== void 0);
547
+ useEffect(() => {
548
+ if (uploadProgress !== void 0) {
549
+ setShowProgress(true);
550
+ } else {
551
+ setShowProgress(false);
552
+ }
553
+ }, [uploadProgress]);
554
+ const handleProgressComplete = useCallback(() => {
555
+ setShowProgress(false);
556
+ }, []);
478
557
  return /* @__PURE__ */ jsxs2(
479
558
  "li",
480
559
  {
@@ -487,13 +566,19 @@ var AcceptedFile = ({
487
566
  ),
488
567
  ...props,
489
568
  children: [
490
- /* @__PURE__ */ jsx3("div", { className: "size-sz-40 bg-support-container flex items-center justify-center rounded-md", children: /* @__PURE__ */ jsx3(Icon, { size: "md", children: getFileIcon(file) }) }),
491
- /* @__PURE__ */ jsxs2("div", { className: "min-w-0 flex-1", children: [
492
- /* @__PURE__ */ jsxs2("div", { className: "gap-md flex flex-row items-center justify-between", children: [
493
- /* @__PURE__ */ jsx3("p", { className: "text-body-2 truncate font-medium", children: file.name }),
494
- /* @__PURE__ */ jsx3("p", { className: "text-caption opacity-dim-1", children: formatFileSize(file.size, locale) })
495
- ] }),
496
- uploadProgress !== void 0 && /* @__PURE__ */ jsx3("div", { className: "mt-md", children: /* @__PURE__ */ jsx3(Progress, { value: uploadProgress, max: 100, "aria-label": progressAriaLabel }) })
569
+ /* @__PURE__ */ jsx3("div", { className: "size-sz-36 bg-support-container flex items-center justify-center rounded-md", children: /* @__PURE__ */ jsx3(Icon, { size: "md", children: getFileIcon(file) }) }),
570
+ /* @__PURE__ */ jsxs2("div", { className: "gap-md relative flex min-w-0 flex-1 flex-row items-center justify-between self-stretch", children: [
571
+ /* @__PURE__ */ jsx3("p", { className: "text-body-2 truncate font-medium", children: file.name }),
572
+ /* @__PURE__ */ jsx3("p", { className: "text-caption opacity-dim-1", children: formatFileSize(file.size, locale) }),
573
+ showProgress && uploadProgress !== void 0 && /* @__PURE__ */ jsx3("div", { className: "absolute bottom-0 left-0 w-full", children: /* @__PURE__ */ jsx3(
574
+ Progress,
575
+ {
576
+ value: uploadProgress,
577
+ max: 100,
578
+ "aria-label": progressAriaLabel,
579
+ onComplete: handleProgressComplete
580
+ }
581
+ ) })
497
582
  ] }),
498
583
  /* @__PURE__ */ jsx3(ItemDeleteTrigger, { "aria-label": deleteButtonAriaLabel, file })
499
584
  ]
@@ -517,8 +602,10 @@ Context.displayName = "FileUpload.Context";
517
602
 
518
603
  // src/file-upload/FileUploadDropzone.tsx
519
604
  import { cx as cx3 } from "class-variance-authority";
520
- import { useRef as useRef3 } from "react";
605
+ import { createContext as createContext2, useContext as useContext2, useRef as useRef3 } from "react";
521
606
  import { jsx as jsx5 } from "react/jsx-runtime";
607
+ var DropzoneContext = createContext2(false);
608
+ var useDropzoneContext = () => useContext2(DropzoneContext);
522
609
  function Dropzone({
523
610
  children,
524
611
  className,
@@ -557,7 +644,7 @@ function Dropzone({
557
644
  }
558
645
  };
559
646
  const isDisabled = ctx.disabled || ctx.readOnly;
560
- return /* @__PURE__ */ jsx5(
647
+ return /* @__PURE__ */ jsx5(DropzoneContext.Provider, { value: true, children: /* @__PURE__ */ jsx5(
561
648
  "div",
562
649
  {
563
650
  ref: (node) => {
@@ -601,26 +688,25 @@ function Dropzone({
601
688
  },
602
689
  children
603
690
  }
604
- );
691
+ ) });
605
692
  }
606
693
  Dropzone.displayName = "FileUploadDropzone";
607
694
 
608
695
  // src/file-upload/FileUploadPreviewImage.tsx
609
696
  import { cx as cx4 } from "class-variance-authority";
610
- import { useEffect, useState as useState2 } from "react";
697
+ import { useEffect as useEffect2, useState as useState3 } from "react";
611
698
  import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
612
699
  var PreviewImage = ({
613
- asChild: _asChild = false,
614
700
  className,
615
701
  file,
616
702
  fallback = "\u{1F4C4}",
617
703
  ...props
618
704
  }) => {
619
- const [imageError, setImageError] = useState2(false);
620
- const [imageLoaded, setImageLoaded] = useState2(false);
705
+ const [imageError, setImageError] = useState3(false);
706
+ const [imageLoaded, setImageLoaded] = useState3(false);
621
707
  const isImage = file.type.startsWith("image/");
622
708
  const imageUrl = isImage ? URL.createObjectURL(file) : null;
623
- useEffect(() => {
709
+ useEffect2(() => {
624
710
  return () => {
625
711
  if (imageUrl) {
626
712
  URL.revokeObjectURL(imageUrl);
@@ -719,7 +805,6 @@ RejectedFileDeleteTrigger.displayName = "FileUpload.RejectedFileDeleteTrigger";
719
805
  // src/file-upload/FileUploadRejectedFile.tsx
720
806
  import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
721
807
  var RejectedFile = ({
722
- asChild: _asChild = false,
723
808
  className,
724
809
  rejectedFile,
725
810
  renderError,
@@ -740,7 +825,7 @@ var RejectedFile = ({
740
825
  ),
741
826
  ...props,
742
827
  children: [
743
- /* @__PURE__ */ jsx8("div", { className: "size-sz-40 bg-error-container flex items-center justify-center rounded-md", children: /* @__PURE__ */ jsx8(Icon, { size: "md", className: "text-error", children: /* @__PURE__ */ jsx8(WarningOutline, {}) }) }),
828
+ /* @__PURE__ */ jsx8("div", { className: "size-sz-36 bg-error-container flex items-center justify-center rounded-md", children: /* @__PURE__ */ jsx8(Icon, { size: "md", className: "text-error", children: /* @__PURE__ */ jsx8(WarningOutline, {}) }) }),
744
829
  /* @__PURE__ */ jsx8("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxs4("div", { className: "gap-md flex flex-col", children: [
745
830
  /* @__PURE__ */ jsxs4("div", { className: "gap-md flex flex-row items-center justify-between", children: [
746
831
  /* @__PURE__ */ jsx8("p", { className: "text-body-2 truncate font-medium", children: rejectedFile.file.name }),
@@ -765,10 +850,13 @@ var Trigger = ({
765
850
  unstyled = false,
766
851
  design = "filled",
767
852
  intent = "basic",
853
+ size = "md",
854
+ shape = "rounded",
768
855
  ref,
769
856
  ...props
770
857
  }) => {
771
858
  const { inputRef, triggerRef, disabled, readOnly, description, isInvalid, isRequired } = useFileUploadContext();
859
+ const isInsideDropzone = useDropzoneContext();
772
860
  const handleClick = (e) => {
773
861
  e.stopPropagation();
774
862
  e.preventDefault();
@@ -776,26 +864,47 @@ var Trigger = ({
776
864
  inputRef.current?.click();
777
865
  }
778
866
  };
779
- const buttonComponent = unstyled ? "button" : Button;
780
- const Comp = asChild ? Slot : buttonComponent;
781
- return /* @__PURE__ */ jsx9(
782
- Comp,
783
- {
867
+ const handleRef = (node) => {
868
+ if (triggerRef) {
869
+ triggerRef.current = node;
870
+ }
871
+ if (ref) {
872
+ if (typeof ref === "function") {
873
+ ref(node);
874
+ } else {
875
+ ref.current = node;
876
+ }
877
+ }
878
+ };
879
+ let Component;
880
+ let componentProps;
881
+ if (isInsideDropzone) {
882
+ Component = "span";
883
+ const spanStyles = unstyled ? className : buttonStyles({
884
+ design,
885
+ intent,
886
+ size,
887
+ shape,
888
+ disabled: disabled || readOnly,
889
+ className
890
+ });
891
+ componentProps = {
892
+ ref: handleRef,
893
+ "data-spark-component": "file-upload-trigger",
894
+ className: spanStyles
895
+ // No onClick, no role, no tabIndex - Dropzone handles interaction
896
+ // No aria attributes here - they're on the Dropzone
897
+ };
898
+ } else {
899
+ const buttonComponent = unstyled ? "button" : Button;
900
+ Component = asChild ? Slot : buttonComponent;
901
+ componentProps = {
902
+ ref: handleRef,
784
903
  type: "button",
785
- ref: (node) => {
786
- if (triggerRef) {
787
- triggerRef.current = node;
788
- }
789
- if (ref) {
790
- if (typeof ref === "function") {
791
- ref(node);
792
- } else {
793
- ref.current = node;
794
- }
795
- }
796
- },
797
904
  design,
798
905
  intent,
906
+ size,
907
+ shape,
799
908
  "data-spark-component": "file-upload-trigger",
800
909
  className: cx7(className),
801
910
  disabled: disabled || readOnly,
@@ -803,10 +912,10 @@ var Trigger = ({
803
912
  "aria-describedby": description,
804
913
  "aria-invalid": isInvalid,
805
914
  "aria-required": isRequired,
806
- ...props,
807
- children
808
- }
809
- );
915
+ ...props
916
+ };
917
+ }
918
+ return /* @__PURE__ */ jsx9(Component, { ...componentProps, children });
810
919
  };
811
920
  Trigger.displayName = "FileUpload.Trigger";
812
921
 
@@ -834,6 +943,7 @@ AcceptedFile.displayName = "FileUpload.AcceptedFile";
834
943
  RejectedFile.displayName = "FileUpload.RejectedFile";
835
944
  RejectedFileDeleteTrigger.displayName = "FileUpload.RejectedFileDeleteTrigger";
836
945
  export {
946
+ FILE_UPLOAD_ERRORS,
837
947
  FileUpload2 as FileUpload
838
948
  };
839
949
  //# sourceMappingURL=index.mjs.map