@spark-ui/components 11.4.1 → 11.4.3
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.
- package/dist/checkbox/index.js.map +1 -1
- package/dist/checkbox/index.mjs.map +1 -1
- package/dist/chip/index.js.map +1 -1
- package/dist/chip/index.mjs.map +1 -1
- package/dist/docgen.json +77 -274
- package/dist/file-upload/index.d.mts +47 -79
- package/dist/file-upload/index.d.ts +47 -79
- package/dist/file-upload/index.js +152 -186
- package/dist/file-upload/index.js.map +1 -1
- package/dist/file-upload/index.mjs +132 -166
- package/dist/file-upload/index.mjs.map +1 -1
- package/package.json +5 -5
|
@@ -127,14 +127,14 @@ var FileUpload = ({
|
|
|
127
127
|
children,
|
|
128
128
|
defaultValue = [],
|
|
129
129
|
value: controlledValue,
|
|
130
|
-
|
|
130
|
+
onFileAccept,
|
|
131
|
+
onFileReject,
|
|
132
|
+
onFileChange,
|
|
131
133
|
multiple = true,
|
|
132
134
|
accept,
|
|
133
135
|
maxFiles,
|
|
134
|
-
onMaxFilesReached,
|
|
135
136
|
maxFileSize,
|
|
136
137
|
minFileSize,
|
|
137
|
-
onFileSizeError,
|
|
138
138
|
disabled = false,
|
|
139
139
|
readOnly = false,
|
|
140
140
|
locale
|
|
@@ -144,11 +144,7 @@ var FileUpload = ({
|
|
|
144
144
|
const triggerRef = useRef(null);
|
|
145
145
|
const dropzoneRef = useRef(null);
|
|
146
146
|
const deleteButtonRefs = useRef([]);
|
|
147
|
-
const [filesState, setFilesState, ,] = useCombinedState(
|
|
148
|
-
controlledValue,
|
|
149
|
-
defaultValue,
|
|
150
|
-
onFilesChange
|
|
151
|
-
);
|
|
147
|
+
const [filesState, setFilesState, ,] = useCombinedState(controlledValue, defaultValue);
|
|
152
148
|
const files = filesState ?? [];
|
|
153
149
|
const setFiles = setFilesState;
|
|
154
150
|
const [rejectedFiles, setRejectedFiles] = useState([]);
|
|
@@ -177,9 +173,6 @@ var FileUpload = ({
|
|
|
177
173
|
errors: [error]
|
|
178
174
|
});
|
|
179
175
|
}
|
|
180
|
-
if (onFileSizeError) {
|
|
181
|
-
onFileSizeError(file, error);
|
|
182
|
-
}
|
|
183
176
|
};
|
|
184
177
|
setFiles((prev) => {
|
|
185
178
|
const currentFiles = prev ?? [];
|
|
@@ -243,19 +236,29 @@ var FileUpload = ({
|
|
|
243
236
|
filesToAdd.forEach((file) => {
|
|
244
237
|
addRejectedFile(file, "TOO_MANY_FILES");
|
|
245
238
|
});
|
|
246
|
-
onMaxFilesReached?.(maxFiles, filesToAdd.length);
|
|
247
239
|
filesToAdd = [];
|
|
248
240
|
} else if (filesToAdd.length > remainingSlots) {
|
|
249
241
|
filesToAdd.forEach((file) => {
|
|
250
242
|
addRejectedFile(file, "TOO_MANY_FILES");
|
|
251
243
|
});
|
|
252
|
-
onMaxFilesReached?.(maxFiles, filesToAdd.length);
|
|
253
244
|
filesToAdd = [];
|
|
254
245
|
}
|
|
255
246
|
}
|
|
256
247
|
const updated = multiple ? [...currentFiles, ...filesToAdd] : filesToAdd;
|
|
257
248
|
const rejectedFilesToAdd = [...newRejectedFiles];
|
|
258
249
|
setRejectedFiles(rejectedFilesToAdd);
|
|
250
|
+
if (filesToAdd.length > 0 && onFileAccept) {
|
|
251
|
+
onFileAccept({ files: filesToAdd });
|
|
252
|
+
}
|
|
253
|
+
if (rejectedFilesToAdd.length > 0 && onFileReject) {
|
|
254
|
+
onFileReject({ files: rejectedFilesToAdd });
|
|
255
|
+
}
|
|
256
|
+
if (onFileChange) {
|
|
257
|
+
onFileChange({
|
|
258
|
+
acceptedFiles: updated,
|
|
259
|
+
rejectedFiles: rejectedFilesToAdd
|
|
260
|
+
});
|
|
261
|
+
}
|
|
259
262
|
return updated;
|
|
260
263
|
});
|
|
261
264
|
};
|
|
@@ -266,10 +269,18 @@ var FileUpload = ({
|
|
|
266
269
|
setFiles((prev) => {
|
|
267
270
|
const currentFiles = prev ?? [];
|
|
268
271
|
const updated = currentFiles.filter((_, i) => i !== index);
|
|
272
|
+
let updatedRejectedFiles = rejectedFiles;
|
|
269
273
|
if (maxFiles !== void 0 && updated.length < maxFiles) {
|
|
270
|
-
|
|
271
|
-
(
|
|
274
|
+
updatedRejectedFiles = rejectedFiles.filter(
|
|
275
|
+
(rejected) => !rejected.errors.includes("TOO_MANY_FILES")
|
|
272
276
|
);
|
|
277
|
+
setRejectedFiles(updatedRejectedFiles);
|
|
278
|
+
}
|
|
279
|
+
if (onFileChange) {
|
|
280
|
+
onFileChange({
|
|
281
|
+
acceptedFiles: updated,
|
|
282
|
+
rejectedFiles: updatedRejectedFiles
|
|
283
|
+
});
|
|
273
284
|
}
|
|
274
285
|
return updated;
|
|
275
286
|
});
|
|
@@ -281,6 +292,12 @@ var FileUpload = ({
|
|
|
281
292
|
setFiles([]);
|
|
282
293
|
setRejectedFiles([]);
|
|
283
294
|
deleteButtonRefs.current = [];
|
|
295
|
+
if (onFileChange) {
|
|
296
|
+
onFileChange({
|
|
297
|
+
acceptedFiles: [],
|
|
298
|
+
rejectedFiles: []
|
|
299
|
+
});
|
|
300
|
+
}
|
|
284
301
|
};
|
|
285
302
|
const removeRejectedFile = (index) => {
|
|
286
303
|
if (disabled || readOnly) {
|
|
@@ -353,45 +370,23 @@ var useFileUploadContext = () => {
|
|
|
353
370
|
return context;
|
|
354
371
|
};
|
|
355
372
|
|
|
356
|
-
// src/file-upload/
|
|
357
|
-
import { cx } from "class-variance-authority";
|
|
358
|
-
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
359
|
-
var Item = ({
|
|
360
|
-
asChild: _asChild = false,
|
|
361
|
-
className,
|
|
362
|
-
children,
|
|
363
|
-
...props
|
|
364
|
-
}) => {
|
|
365
|
-
return /* @__PURE__ */ jsx2(
|
|
366
|
-
"li",
|
|
367
|
-
{
|
|
368
|
-
"data-spark-component": "file-upload-item",
|
|
369
|
-
className: cx(
|
|
370
|
-
"relative",
|
|
371
|
-
"default:bg-surface default:border-sm default:border-outline default:p-md default:rounded-md",
|
|
372
|
-
"gap-md flex items-center justify-between default:w-full",
|
|
373
|
-
className
|
|
374
|
-
),
|
|
375
|
-
...props,
|
|
376
|
-
children
|
|
377
|
-
}
|
|
378
|
-
);
|
|
379
|
-
};
|
|
380
|
-
Item.displayName = "FileUpload.Item";
|
|
373
|
+
// src/file-upload/FileUploadAcceptedFile.tsx
|
|
374
|
+
import { cx as cx2 } from "class-variance-authority";
|
|
381
375
|
|
|
382
376
|
// src/file-upload/FileUploadItemDeleteTrigger.tsx
|
|
383
377
|
import { Close } from "@spark-ui/icons/Close";
|
|
384
|
-
import { cx
|
|
378
|
+
import { cx } from "class-variance-authority";
|
|
385
379
|
import { useRef as useRef2 } from "react";
|
|
386
|
-
import { jsx as
|
|
380
|
+
import { jsx as jsx2 } from "react/jsx-runtime";
|
|
387
381
|
var ItemDeleteTrigger = ({
|
|
388
382
|
className,
|
|
389
|
-
|
|
383
|
+
file,
|
|
390
384
|
onClick,
|
|
391
385
|
...props
|
|
392
386
|
}) => {
|
|
393
|
-
const { removeFile, triggerRef, dropzoneRef, deleteButtonRefs, disabled, readOnly } = useFileUploadContext();
|
|
387
|
+
const { removeFile, triggerRef, dropzoneRef, deleteButtonRefs, disabled, readOnly, files } = useFileUploadContext();
|
|
394
388
|
const buttonRef = useRef2(null);
|
|
389
|
+
const fileIndex = files.findIndex((f) => f.name === file.name && f.size === file.size);
|
|
395
390
|
const handleClick = (e) => {
|
|
396
391
|
if (disabled || readOnly) {
|
|
397
392
|
return;
|
|
@@ -427,103 +422,68 @@ var ItemDeleteTrigger = ({
|
|
|
427
422
|
}
|
|
428
423
|
}
|
|
429
424
|
};
|
|
430
|
-
return /* @__PURE__ */
|
|
425
|
+
return /* @__PURE__ */ jsx2(
|
|
431
426
|
IconButton,
|
|
432
427
|
{
|
|
433
428
|
ref: setRef,
|
|
434
429
|
"data-spark-component": "file-upload-item-delete-trigger",
|
|
435
|
-
className:
|
|
430
|
+
className: cx(className),
|
|
436
431
|
onClick: handleClick,
|
|
437
432
|
disabled: disabled || readOnly,
|
|
438
433
|
size: "sm",
|
|
439
434
|
design: "contrast",
|
|
440
435
|
intent: "surface",
|
|
441
436
|
...props,
|
|
442
|
-
children: /* @__PURE__ */
|
|
437
|
+
children: /* @__PURE__ */ jsx2(Icon, { size: "sm", children: /* @__PURE__ */ jsx2(Close, {}) })
|
|
443
438
|
}
|
|
444
439
|
);
|
|
445
440
|
};
|
|
446
441
|
ItemDeleteTrigger.displayName = "FileUpload.ItemDeleteTrigger";
|
|
447
442
|
|
|
448
|
-
// src/file-upload/FileUploadItemFileName.tsx
|
|
449
|
-
import { cx as cx3 } from "class-variance-authority";
|
|
450
|
-
import { jsx as jsx4 } from "react/jsx-runtime";
|
|
451
|
-
var ItemFileName = ({
|
|
452
|
-
asChild: _asChild = false,
|
|
453
|
-
className,
|
|
454
|
-
children,
|
|
455
|
-
...props
|
|
456
|
-
}) => {
|
|
457
|
-
return /* @__PURE__ */ jsx4(
|
|
458
|
-
"p",
|
|
459
|
-
{
|
|
460
|
-
"data-spark-component": "file-upload-item-file-name",
|
|
461
|
-
className: cx3("text-body-2 truncate font-medium", className),
|
|
462
|
-
...props,
|
|
463
|
-
children
|
|
464
|
-
}
|
|
465
|
-
);
|
|
466
|
-
};
|
|
467
|
-
ItemFileName.displayName = "FileUpload.ItemFileName";
|
|
468
|
-
|
|
469
|
-
// src/file-upload/FileUploadItemSizeText.tsx
|
|
470
|
-
import { cx as cx4 } from "class-variance-authority";
|
|
471
|
-
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
472
|
-
var ItemSizeText = ({
|
|
473
|
-
asChild: _asChild = false,
|
|
474
|
-
className,
|
|
475
|
-
children,
|
|
476
|
-
...props
|
|
477
|
-
}) => {
|
|
478
|
-
return /* @__PURE__ */ jsx5(
|
|
479
|
-
"p",
|
|
480
|
-
{
|
|
481
|
-
"data-spark-component": "file-upload-item-size-text",
|
|
482
|
-
className: cx4("text-caption", className),
|
|
483
|
-
...props,
|
|
484
|
-
children
|
|
485
|
-
}
|
|
486
|
-
);
|
|
487
|
-
};
|
|
488
|
-
ItemSizeText.displayName = "FileUpload.ItemSizeText";
|
|
489
|
-
|
|
490
443
|
// src/file-upload/FileUploadAcceptedFile.tsx
|
|
491
|
-
import { jsx as
|
|
444
|
+
import { jsx as jsx3, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
492
445
|
var AcceptedFile = ({
|
|
493
446
|
asChild: _asChild = false,
|
|
494
447
|
className,
|
|
495
448
|
file,
|
|
496
|
-
fileIndex,
|
|
497
449
|
uploadProgress,
|
|
450
|
+
deleteButtonAriaLabel,
|
|
451
|
+
progressAriaLabel,
|
|
498
452
|
...props
|
|
499
453
|
}) => {
|
|
500
454
|
const { locale } = useFileUploadContext();
|
|
501
|
-
return /* @__PURE__ */ jsxs2(
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
455
|
+
return /* @__PURE__ */ jsxs2(
|
|
456
|
+
"li",
|
|
457
|
+
{
|
|
458
|
+
"data-spark-component": "file-upload-accepted-file",
|
|
459
|
+
className: cx2(
|
|
460
|
+
"relative",
|
|
461
|
+
"default:bg-surface default:border-sm default:border-outline default:p-md default:rounded-md",
|
|
462
|
+
"gap-md flex items-center justify-between default:w-full",
|
|
463
|
+
className
|
|
464
|
+
),
|
|
465
|
+
...props,
|
|
466
|
+
children: [
|
|
467
|
+
/* @__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) }) }),
|
|
468
|
+
/* @__PURE__ */ jsxs2("div", { className: "min-w-0 flex-1", children: [
|
|
469
|
+
/* @__PURE__ */ jsxs2("div", { className: "gap-md flex flex-row items-center justify-between", children: [
|
|
470
|
+
/* @__PURE__ */ jsx3("p", { className: "text-body-2 truncate font-medium", children: file.name }),
|
|
471
|
+
/* @__PURE__ */ jsx3("p", { className: "text-caption opacity-dim-1", children: formatFileSize(file.size, locale) })
|
|
472
|
+
] }),
|
|
473
|
+
uploadProgress !== void 0 && /* @__PURE__ */ jsx3("div", { className: "mt-md", children: /* @__PURE__ */ jsx3(Progress, { value: uploadProgress, max: 100, "aria-label": progressAriaLabel }) })
|
|
474
|
+
] }),
|
|
475
|
+
/* @__PURE__ */ jsx3(ItemDeleteTrigger, { "aria-label": deleteButtonAriaLabel, file })
|
|
476
|
+
]
|
|
477
|
+
}
|
|
478
|
+
);
|
|
519
479
|
};
|
|
520
480
|
AcceptedFile.displayName = "FileUpload.AcceptedFile";
|
|
521
481
|
|
|
522
482
|
// src/file-upload/FileUploadContext.tsx
|
|
523
|
-
import { Fragment, jsx as
|
|
483
|
+
import { Fragment, jsx as jsx4 } from "react/jsx-runtime";
|
|
524
484
|
var Context = ({ children }) => {
|
|
525
485
|
const { files = [], rejectedFiles = [], locale } = useFileUploadContext();
|
|
526
|
-
return /* @__PURE__ */
|
|
486
|
+
return /* @__PURE__ */ jsx4(Fragment, { children: children({
|
|
527
487
|
acceptedFiles: files,
|
|
528
488
|
rejectedFiles,
|
|
529
489
|
formatFileSize,
|
|
@@ -533,12 +493,11 @@ var Context = ({ children }) => {
|
|
|
533
493
|
Context.displayName = "FileUpload.Context";
|
|
534
494
|
|
|
535
495
|
// src/file-upload/FileUploadDropzone.tsx
|
|
536
|
-
import { cx as
|
|
496
|
+
import { cx as cx3 } from "class-variance-authority";
|
|
537
497
|
import { useRef as useRef3 } from "react";
|
|
538
|
-
import { jsx as
|
|
498
|
+
import { jsx as jsx5 } from "react/jsx-runtime";
|
|
539
499
|
function Dropzone({
|
|
540
500
|
children,
|
|
541
|
-
onFiles,
|
|
542
501
|
className,
|
|
543
502
|
unstyled = false
|
|
544
503
|
}) {
|
|
@@ -553,7 +512,6 @@ function Dropzone({
|
|
|
553
512
|
return;
|
|
554
513
|
}
|
|
555
514
|
const files = e.dataTransfer.files;
|
|
556
|
-
onFiles?.(files);
|
|
557
515
|
let filesArray = [];
|
|
558
516
|
if (files) {
|
|
559
517
|
filesArray = Array.isArray(files) ? [...files] : Array.from(files);
|
|
@@ -576,7 +534,7 @@ function Dropzone({
|
|
|
576
534
|
}
|
|
577
535
|
};
|
|
578
536
|
const isDisabled = ctx.disabled || ctx.readOnly;
|
|
579
|
-
return /* @__PURE__ */
|
|
537
|
+
return /* @__PURE__ */ jsx5(
|
|
580
538
|
"div",
|
|
581
539
|
{
|
|
582
540
|
ref: (node) => {
|
|
@@ -594,12 +552,12 @@ function Dropzone({
|
|
|
594
552
|
onDragOver: (e) => {
|
|
595
553
|
e.preventDefault();
|
|
596
554
|
},
|
|
597
|
-
className: unstyled ? className :
|
|
598
|
-
"default:bg-surface default:border-sm default:border-outline default:rounded-lg default:border-dashed",
|
|
555
|
+
className: unstyled ? className : cx3(
|
|
556
|
+
"default:bg-surface default:border-sm default:border-outline default:relative default:rounded-lg default:border-dashed",
|
|
599
557
|
"gap-lg flex flex-col items-center justify-center text-center",
|
|
600
558
|
"default:p-xl",
|
|
601
559
|
"transition-colors duration-200",
|
|
602
|
-
!isDisabled && "hover:bg-surface-hovered",
|
|
560
|
+
!isDisabled && "default:hover:bg-surface-hovered",
|
|
603
561
|
"data-[drag-over=true]:border-outline-high data-[drag-over=true]:bg-surface-hovered data-[drag-over=true]:border-solid",
|
|
604
562
|
// Disabled: more visually disabled (opacity + cursor)
|
|
605
563
|
ctx.disabled && "cursor-not-allowed opacity-50",
|
|
@@ -622,9 +580,9 @@ function Dropzone({
|
|
|
622
580
|
Dropzone.displayName = "FileUploadDropzone";
|
|
623
581
|
|
|
624
582
|
// src/file-upload/FileUploadPreviewImage.tsx
|
|
625
|
-
import { cx as
|
|
583
|
+
import { cx as cx4 } from "class-variance-authority";
|
|
626
584
|
import { useEffect, useState as useState2 } from "react";
|
|
627
|
-
import { jsx as
|
|
585
|
+
import { jsx as jsx6, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
628
586
|
var PreviewImage = ({
|
|
629
587
|
asChild: _asChild = false,
|
|
630
588
|
className,
|
|
@@ -644,11 +602,11 @@ var PreviewImage = ({
|
|
|
644
602
|
};
|
|
645
603
|
}, [imageUrl]);
|
|
646
604
|
if (!isImage || imageError) {
|
|
647
|
-
return /* @__PURE__ */
|
|
605
|
+
return /* @__PURE__ */ jsx6(
|
|
648
606
|
"div",
|
|
649
607
|
{
|
|
650
608
|
"data-spark-component": "file-upload-preview-image",
|
|
651
|
-
className:
|
|
609
|
+
className: cx4(
|
|
652
610
|
"bg-neutral-container flex items-center justify-center rounded-md",
|
|
653
611
|
className
|
|
654
612
|
),
|
|
@@ -661,20 +619,20 @@ var PreviewImage = ({
|
|
|
661
619
|
"div",
|
|
662
620
|
{
|
|
663
621
|
"data-spark-component": "file-upload-preview-image",
|
|
664
|
-
className:
|
|
622
|
+
className: cx4("bg-neutral-container overflow-hidden", className),
|
|
665
623
|
...props,
|
|
666
624
|
children: [
|
|
667
|
-
/* @__PURE__ */
|
|
625
|
+
/* @__PURE__ */ jsx6(
|
|
668
626
|
"img",
|
|
669
627
|
{
|
|
670
628
|
src: imageUrl,
|
|
671
629
|
alt: file.name,
|
|
672
|
-
className:
|
|
630
|
+
className: cx4("size-full object-cover", !imageLoaded && "opacity-0"),
|
|
673
631
|
onLoad: () => setImageLoaded(true),
|
|
674
632
|
onError: () => setImageError(true)
|
|
675
633
|
}
|
|
676
634
|
),
|
|
677
|
-
!imageLoaded && /* @__PURE__ */
|
|
635
|
+
!imageLoaded && /* @__PURE__ */ jsx6("div", { className: "absolute inset-0 flex items-center justify-center", children: fallback })
|
|
678
636
|
]
|
|
679
637
|
}
|
|
680
638
|
);
|
|
@@ -683,21 +641,24 @@ PreviewImage.displayName = "FileUpload.PreviewImage";
|
|
|
683
641
|
|
|
684
642
|
// src/file-upload/FileUploadRejectedFile.tsx
|
|
685
643
|
import { WarningOutline } from "@spark-ui/icons/WarningOutline";
|
|
686
|
-
import { cx as
|
|
644
|
+
import { cx as cx6 } from "class-variance-authority";
|
|
687
645
|
|
|
688
646
|
// src/file-upload/FileUploadRejectedFileDeleteTrigger.tsx
|
|
689
647
|
import { Close as Close2 } from "@spark-ui/icons/Close";
|
|
690
|
-
import { cx as
|
|
648
|
+
import { cx as cx5 } from "class-variance-authority";
|
|
691
649
|
import { useRef as useRef4 } from "react";
|
|
692
|
-
import { jsx as
|
|
650
|
+
import { jsx as jsx7 } from "react/jsx-runtime";
|
|
693
651
|
var RejectedFileDeleteTrigger = ({
|
|
694
652
|
className,
|
|
695
|
-
|
|
653
|
+
rejectedFile,
|
|
696
654
|
onClick,
|
|
697
655
|
...props
|
|
698
656
|
}) => {
|
|
699
|
-
const { removeRejectedFile, triggerRef, dropzoneRef, disabled, readOnly } = useFileUploadContext();
|
|
657
|
+
const { removeRejectedFile, triggerRef, dropzoneRef, disabled, readOnly, rejectedFiles } = useFileUploadContext();
|
|
700
658
|
const buttonRef = useRef4(null);
|
|
659
|
+
const rejectedFileIndex = rejectedFiles.findIndex(
|
|
660
|
+
(rf) => rf.file.name === rejectedFile.file.name && rf.file.size === rejectedFile.file.size
|
|
661
|
+
);
|
|
701
662
|
const handleClick = (e) => {
|
|
702
663
|
if (disabled || readOnly) {
|
|
703
664
|
return;
|
|
@@ -711,58 +672,66 @@ var RejectedFileDeleteTrigger = ({
|
|
|
711
672
|
}, 0);
|
|
712
673
|
onClick?.(e);
|
|
713
674
|
};
|
|
714
|
-
return /* @__PURE__ */
|
|
675
|
+
return /* @__PURE__ */ jsx7(
|
|
715
676
|
IconButton,
|
|
716
677
|
{
|
|
717
678
|
ref: buttonRef,
|
|
718
679
|
"data-spark-component": "file-upload-rejected-file-delete-trigger",
|
|
719
|
-
className:
|
|
680
|
+
className: cx5(className),
|
|
720
681
|
onClick: handleClick,
|
|
721
682
|
disabled: disabled || readOnly,
|
|
722
683
|
size: "sm",
|
|
723
684
|
design: "contrast",
|
|
724
685
|
intent: "surface",
|
|
725
686
|
...props,
|
|
726
|
-
children: /* @__PURE__ */
|
|
687
|
+
children: /* @__PURE__ */ jsx7(Icon, { size: "sm", children: /* @__PURE__ */ jsx7(Close2, {}) })
|
|
727
688
|
}
|
|
728
689
|
);
|
|
729
690
|
};
|
|
730
691
|
RejectedFileDeleteTrigger.displayName = "FileUpload.RejectedFileDeleteTrigger";
|
|
731
692
|
|
|
732
693
|
// src/file-upload/FileUploadRejectedFile.tsx
|
|
733
|
-
import { jsx as
|
|
694
|
+
import { jsx as jsx8, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
734
695
|
var RejectedFile = ({
|
|
735
696
|
asChild: _asChild = false,
|
|
736
697
|
className,
|
|
737
698
|
rejectedFile,
|
|
738
|
-
rejectedFileIndex,
|
|
739
699
|
renderError,
|
|
700
|
+
deleteButtonAriaLabel,
|
|
740
701
|
...props
|
|
741
702
|
}) => {
|
|
742
703
|
const { locale } = useFileUploadContext();
|
|
743
|
-
return /* @__PURE__ */ jsxs4(
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
704
|
+
return /* @__PURE__ */ jsxs4(
|
|
705
|
+
"li",
|
|
706
|
+
{
|
|
707
|
+
"data-spark-component": "file-upload-rejected-file",
|
|
708
|
+
className: cx6(
|
|
709
|
+
"relative",
|
|
710
|
+
"default:bg-surface default:border-sm default:border-outline default:p-md default:rounded-md",
|
|
711
|
+
"gap-md flex items-center justify-between default:w-full",
|
|
712
|
+
"border-error border-md",
|
|
713
|
+
className
|
|
714
|
+
),
|
|
715
|
+
...props,
|
|
716
|
+
children: [
|
|
717
|
+
/* @__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, {}) }) }),
|
|
718
|
+
/* @__PURE__ */ jsx8("div", { className: "min-w-0 flex-1", children: /* @__PURE__ */ jsxs4("div", { className: "gap-md flex flex-col", children: [
|
|
719
|
+
/* @__PURE__ */ jsxs4("div", { className: "gap-md flex flex-row items-center justify-between", children: [
|
|
720
|
+
/* @__PURE__ */ jsx8("p", { className: "text-body-2 truncate font-medium", children: rejectedFile.file.name }),
|
|
721
|
+
/* @__PURE__ */ jsx8("p", { className: "text-caption opacity-dim-1", children: formatFileSize(rejectedFile.file.size, locale) })
|
|
722
|
+
] }),
|
|
723
|
+
/* @__PURE__ */ jsx8("div", { className: "gap-xs flex flex-col", children: rejectedFile.errors.map((error, errorIndex) => /* @__PURE__ */ jsx8("div", { className: "text-caption text-error", "data-error-code": error, children: renderError(error) }, errorIndex)) })
|
|
724
|
+
] }) }),
|
|
725
|
+
/* @__PURE__ */ jsx8(RejectedFileDeleteTrigger, { "aria-label": deleteButtonAriaLabel, rejectedFile })
|
|
726
|
+
]
|
|
727
|
+
}
|
|
728
|
+
);
|
|
760
729
|
};
|
|
761
730
|
RejectedFile.displayName = "FileUpload.RejectedFile";
|
|
762
731
|
|
|
763
732
|
// src/file-upload/FileUploadTrigger.tsx
|
|
764
|
-
import { cx as
|
|
765
|
-
import { jsx as
|
|
733
|
+
import { cx as cx7 } from "class-variance-authority";
|
|
734
|
+
import { jsx as jsx9 } from "react/jsx-runtime";
|
|
766
735
|
var Trigger = ({
|
|
767
736
|
className,
|
|
768
737
|
children,
|
|
@@ -783,7 +752,7 @@ var Trigger = ({
|
|
|
783
752
|
};
|
|
784
753
|
const buttonComponent = unstyled ? "button" : Button;
|
|
785
754
|
const Comp = asChild ? Slot : buttonComponent;
|
|
786
|
-
return /* @__PURE__ */
|
|
755
|
+
return /* @__PURE__ */ jsx9(
|
|
787
756
|
Comp,
|
|
788
757
|
{
|
|
789
758
|
type: "button",
|
|
@@ -802,7 +771,7 @@ var Trigger = ({
|
|
|
802
771
|
design,
|
|
803
772
|
intent,
|
|
804
773
|
"data-spark-component": "file-upload-trigger",
|
|
805
|
-
className:
|
|
774
|
+
className: cx7(className),
|
|
806
775
|
disabled: disabled || readOnly,
|
|
807
776
|
onClick: handleClick,
|
|
808
777
|
...props,
|
|
@@ -814,25 +783,22 @@ Trigger.displayName = "FileUpload.Trigger";
|
|
|
814
783
|
|
|
815
784
|
// src/file-upload/index.ts
|
|
816
785
|
var FileUpload2 = Object.assign(FileUpload, {
|
|
786
|
+
// Main input components
|
|
817
787
|
Trigger,
|
|
818
788
|
Dropzone,
|
|
789
|
+
// Context components
|
|
819
790
|
Context,
|
|
820
|
-
Item,
|
|
821
|
-
ItemFileName,
|
|
822
|
-
ItemSizeText,
|
|
823
|
-
ItemDeleteTrigger,
|
|
824
|
-
PreviewImage,
|
|
825
791
|
AcceptedFile,
|
|
826
792
|
RejectedFile,
|
|
793
|
+
// Helpers for custom renders
|
|
794
|
+
PreviewImage,
|
|
795
|
+
ItemDeleteTrigger,
|
|
827
796
|
RejectedFileDeleteTrigger
|
|
828
797
|
});
|
|
829
798
|
FileUpload2.displayName = "FileUpload";
|
|
830
799
|
Trigger.displayName = "FileUpload.Trigger";
|
|
831
800
|
Dropzone.displayName = "FileUpload.Dropzone";
|
|
832
801
|
Context.displayName = "FileUpload.Context";
|
|
833
|
-
Item.displayName = "FileUpload.Item";
|
|
834
|
-
ItemFileName.displayName = "FileUpload.ItemFileName";
|
|
835
|
-
ItemSizeText.displayName = "FileUpload.ItemSizeText";
|
|
836
802
|
ItemDeleteTrigger.displayName = "FileUpload.ItemDeleteTrigger";
|
|
837
803
|
PreviewImage.displayName = "FileUpload.PreviewImage";
|
|
838
804
|
AcceptedFile.displayName = "FileUpload.AcceptedFile";
|