@zayne-labs/ui-react 0.10.46 → 0.10.47
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/esm/{client-gate-CZczUIeY.js → client-gate-Ch5I9_pc.js} +1 -1
- package/dist/esm/{client-gate-CZczUIeY.js.map → client-gate-Ch5I9_pc.js.map} +1 -1
- package/dist/esm/{cn-Dnsqr-G7.js → cn-pbJoeyH6.js} +1 -1
- package/dist/esm/{cn-Dnsqr-G7.js.map → cn-pbJoeyH6.js.map} +1 -1
- package/dist/esm/common/await/index.d.ts +6 -6
- package/dist/esm/common/await/index.js +8 -8
- package/dist/esm/common/await/index.js.map +1 -1
- package/dist/esm/common/client-gate/index.d.ts +6 -6
- package/dist/esm/common/client-gate/index.js +1 -1
- package/dist/esm/common/error-boundary/index.d.ts +1 -1
- package/dist/esm/common/error-boundary/index.js +1 -1
- package/dist/esm/common/for/index.d.ts +4 -4
- package/dist/esm/common/for/index.js +1 -1
- package/dist/esm/common/presence/index.d.ts +4 -4
- package/dist/esm/common/presence/index.js +1 -1
- package/dist/esm/common/show/index.d.ts +4 -4
- package/dist/esm/common/show/index.js +1 -1
- package/dist/esm/common/slot/index.d.ts +4 -4
- package/dist/esm/common/slot/index.js +1 -1
- package/dist/esm/common/suspense-with-boundary/index.d.ts +2 -2
- package/dist/esm/common/suspense-with-boundary/index.js +1 -1
- package/dist/esm/common/switch/index.d.ts +6 -6
- package/dist/esm/common/switch/index.js +1 -1
- package/dist/esm/common/switch/index.js.map +1 -1
- package/dist/esm/common/teleport/index.js +2 -2
- package/dist/esm/{error-boundary-TM4xzQfq.js → error-boundary-pMMeMfwH.js} +2 -2
- package/dist/esm/{error-boundary-TM4xzQfq.js.map → error-boundary-pMMeMfwH.js.map} +1 -1
- package/dist/esm/{for-BeCRb3k2.js → for-IenHovla.js} +1 -1
- package/dist/esm/{for-BeCRb3k2.js.map → for-IenHovla.js.map} +1 -1
- package/dist/esm/{index-Bw26wyvy.d.ts → index-CW1qt3Kq.d.ts} +4 -4
- package/dist/esm/{index-D3QKG4Tt.d.ts → index-DtJyivJH.d.ts} +5 -5
- package/dist/esm/{presence-BTPyxGeW.js → presence-BbOLyzEd.js} +3 -3
- package/dist/esm/{presence-BTPyxGeW.js.map → presence-BbOLyzEd.js.map} +1 -1
- package/dist/esm/{show-1Md5CZML.js → show-CWSAcfVL.js} +5 -5
- package/dist/esm/show-CWSAcfVL.js.map +1 -0
- package/dist/esm/{slot-aKEvaEWn.js → slot-C56gqKvk.js} +2 -2
- package/dist/esm/{slot-aKEvaEWn.js.map → slot-C56gqKvk.js.map} +1 -1
- package/dist/esm/ui/card/index.js +3 -3
- package/dist/esm/ui/carousel/index.d.ts +9 -9
- package/dist/esm/ui/carousel/index.js +5 -5
- package/dist/esm/ui/drag-scroll/index.d.ts +93 -27
- package/dist/esm/ui/drag-scroll/index.js +2 -2
- package/dist/esm/ui/drop-zone/index.d.ts +152 -80
- package/dist/esm/ui/drop-zone/index.js +66 -66
- package/dist/esm/ui/drop-zone/index.js.map +1 -1
- package/dist/esm/ui/form/index.d.ts +22 -22
- package/dist/esm/ui/form/index.js +6 -6
- package/dist/esm/ui/form/index.js.map +1 -1
- package/dist/style.css +3 -5
- package/package.json +17 -13
- package/dist/esm/show-1Md5CZML.js.map +0 -1
- /package/dist/esm/{chunk-CpZCTQkd.js → chunk-BN_g-Awi.js} +0 -0
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
|
|
3
|
-
import { t as __exportAll } from "../../chunk-
|
|
4
|
-
import { n as SlotRoot } from "../../slot-
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { t as
|
|
3
|
+
import { t as __exportAll } from "../../chunk-BN_g-Awi.js";
|
|
4
|
+
import { n as SlotRoot } from "../../slot-C56gqKvk.js";
|
|
5
|
+
import { t as cnMerge } from "../../cn-pbJoeyH6.js";
|
|
6
|
+
import { n as For } from "../../for-IenHovla.js";
|
|
7
|
+
import { t as Presence } from "../../presence-BbOLyzEd.js";
|
|
8
8
|
import { composeRefs, composeTwoEventHandlers } from "@zayne-labs/toolkit-react/utils";
|
|
9
9
|
import { isBoolean, isFile, isFunction, isNumber, isObject, isString } from "@zayne-labs/toolkit-type-helpers";
|
|
10
10
|
import { useCallback, useMemo, useRef } from "react";
|
|
11
|
-
import { createCustomContext, useCallbackRef, useCompareSelector, useCompareValue, useConstant, useStore, useUnmountEffect } from "@zayne-labs/toolkit-react";
|
|
12
11
|
import { Fragment as Fragment$1, jsx, jsxs } from "react/jsx-runtime";
|
|
13
12
|
import { createFileURL, createStore, dataAttr, formatBytes, generateFileID, handleFileValidationAsync, toArray } from "@zayne-labs/toolkit-core";
|
|
13
|
+
import { createCustomContext, useCallbackRef, useCompareSelector, useCompareValue, useStore, useUnmountEffect } from "@zayne-labs/toolkit-react";
|
|
14
14
|
import { createReactStoreContext } from "@zayne-labs/toolkit-react/zustand";
|
|
15
15
|
|
|
16
16
|
//#region src/components/ui/drop-zone/drop-zone-context.ts
|
|
@@ -220,8 +220,8 @@ const getErrorContext = (error) => {
|
|
|
220
220
|
|
|
221
221
|
//#endregion
|
|
222
222
|
//#region src/components/ui/drop-zone/drop-zone-store.ts
|
|
223
|
-
const createDropZoneStore = (
|
|
224
|
-
const { allowedFileTypes, disablePreviewGenForNonImageFiles, initialFiles, maxFileCount, maxFileSize, multiple, onFilesChange, onUpload, onValidationError, onValidationSuccess, rejectDuplicateFiles, validator } =
|
|
223
|
+
const createDropZoneStore = (storeContext) => {
|
|
224
|
+
const { allowedFileTypes, disablePreviewGenForNonImageFiles, initialFiles, maxFileCount, maxFileSize, multiple, onFilesChange, onUpload, onValidationError, onValidationSuccess, rejectDuplicateFiles, validator } = storeContext;
|
|
225
225
|
const inputRef = { current: null };
|
|
226
226
|
const initialFileArray = toArray(initialFiles).filter(Boolean);
|
|
227
227
|
const clearInputValue = () => {
|
|
@@ -247,10 +247,10 @@ const createDropZoneStore = (initStoreValues) => {
|
|
|
247
247
|
console.warn("No file selected!");
|
|
248
248
|
return;
|
|
249
249
|
}
|
|
250
|
-
const { actions, fileStateArray } = get();
|
|
250
|
+
const { actions, fileStateArray: existingFileStateArray } = get();
|
|
251
251
|
const resolvedNewFiles = !multiple ? [files[0]] : files;
|
|
252
252
|
const { errors, validFiles } = await handleFileValidationAsync({
|
|
253
|
-
existingFiles:
|
|
253
|
+
existingFiles: existingFileStateArray.map((fileWithPreview) => fileWithPreview.file),
|
|
254
254
|
hooks: {
|
|
255
255
|
onErrorEach: onValidationError,
|
|
256
256
|
onSuccessBatch: onValidationSuccess
|
|
@@ -280,7 +280,7 @@ const createDropZoneStore = (initStoreValues) => {
|
|
|
280
280
|
}));
|
|
281
281
|
set({
|
|
282
282
|
errors,
|
|
283
|
-
fileStateArray: !multiple ? newFileStateArray : [...
|
|
283
|
+
fileStateArray: !multiple ? newFileStateArray : [...existingFileStateArray, ...newFileStateArray],
|
|
284
284
|
isDraggingOver: false
|
|
285
285
|
}, { shouldNotifySync: true });
|
|
286
286
|
await actions.handleFileUpload({ newFileStateArray });
|
|
@@ -419,19 +419,21 @@ const createDropZoneStore = (initStoreValues) => {
|
|
|
419
419
|
const { fileStateOrID, ...updatedFileState } = ctx;
|
|
420
420
|
const { fileStateArray } = get();
|
|
421
421
|
set({ fileStateArray: fileStateArray.map((fileState) => {
|
|
422
|
-
if (isMatchingFile({
|
|
422
|
+
if (!isMatchingFile({
|
|
423
423
|
fileState,
|
|
424
424
|
fileStateOrID
|
|
425
|
-
})) return
|
|
425
|
+
})) return fileState;
|
|
426
|
+
return {
|
|
426
427
|
...fileState,
|
|
427
428
|
...updatedFileState
|
|
428
429
|
};
|
|
429
|
-
return fileState;
|
|
430
430
|
}) }, { shouldNotifySync: true });
|
|
431
431
|
}
|
|
432
432
|
}
|
|
433
433
|
}));
|
|
434
|
-
store.subscribe.withSelector((state) => state.fileStateArray, (fileStateArray) =>
|
|
434
|
+
store.subscribe.withSelector((state) => state.fileStateArray, (fileStateArray) => {
|
|
435
|
+
onFilesChange?.({ fileStateArray });
|
|
436
|
+
});
|
|
435
437
|
store.subscribe.withSelector((state) => state.errors, (errors) => {
|
|
436
438
|
if (errors.length === 0) return;
|
|
437
439
|
store.setState({ isInvalid: true });
|
|
@@ -443,21 +445,21 @@ const createDropZoneStore = (initStoreValues) => {
|
|
|
443
445
|
//#endregion
|
|
444
446
|
//#region src/components/ui/drop-zone/use-drop-zone.ts
|
|
445
447
|
const useDropZone = (props) => {
|
|
446
|
-
const { allowedFileTypes, disabled = false, disableFilePickerOpenOnAreaClick = false, disableInternalStateSubscription = false, disablePreviewGenForNonImageFiles = true, initialFiles, maxFileCount, maxFileSize, multiple, onFilesChange, onUpload, onValidationError, onValidationSuccess, rejectDuplicateFiles = true, validator } = props ?? {};
|
|
448
|
+
const { allowedFileTypes, disabled = false, disableFilePickerOpenOnAreaClick = false, disableInternalStateSubscription = false, disablePreviewGenForNonImageFiles = true, initialFiles, maxFileCount, maxFileSize, multiple, onFilesChange, onUpload, onValidationError, onValidationSuccess, rejectDuplicateFiles = true, unstyled: globalUnstyled = false, validator } = props ?? {};
|
|
447
449
|
const inputRef = useRef(null);
|
|
448
450
|
const stableOnFilesChange = useCallbackRef(onFilesChange);
|
|
449
451
|
const stableOnUpload = useCallbackRef(onUpload);
|
|
450
452
|
const stableOnUploadError = useCallbackRef(onValidationError);
|
|
451
453
|
const stableOnUploadSuccess = useCallbackRef(onValidationSuccess);
|
|
452
454
|
const stableValidator = useCallbackRef(validator);
|
|
453
|
-
const
|
|
455
|
+
const shallowComparedInitialFiles = useCompareValue(initialFiles);
|
|
454
456
|
const shallowComparedMaxFileSize = useCompareValue(maxFileSize);
|
|
455
457
|
const shallowComparedAllowedFileTypes = useCompareValue(allowedFileTypes);
|
|
456
458
|
const storeApi = useMemo(() => {
|
|
457
459
|
return createDropZoneStore({
|
|
458
460
|
allowedFileTypes: shallowComparedAllowedFileTypes,
|
|
459
461
|
disablePreviewGenForNonImageFiles,
|
|
460
|
-
initialFiles:
|
|
462
|
+
initialFiles: shallowComparedInitialFiles,
|
|
461
463
|
maxFileCount,
|
|
462
464
|
maxFileSize: shallowComparedMaxFileSize,
|
|
463
465
|
multiple,
|
|
@@ -471,7 +473,7 @@ const useDropZone = (props) => {
|
|
|
471
473
|
}, [
|
|
472
474
|
shallowComparedAllowedFileTypes,
|
|
473
475
|
disablePreviewGenForNonImageFiles,
|
|
474
|
-
|
|
476
|
+
shallowComparedInitialFiles,
|
|
475
477
|
maxFileCount,
|
|
476
478
|
shallowComparedMaxFileSize,
|
|
477
479
|
multiple,
|
|
@@ -490,9 +492,9 @@ const useDropZone = (props) => {
|
|
|
490
492
|
return useStore(storeApi, selector);
|
|
491
493
|
};
|
|
492
494
|
const isDraggingOver = useDropZoneStore((state) => !disableInternalStateSubscription ? state.isDraggingOver : null);
|
|
493
|
-
const hasFiles = useDropZoneStore((state) => !disableInternalStateSubscription ? state.fileStateArray.length > 0 : null);
|
|
494
495
|
const isInvalid = useDropZoneStore((state) => !disableInternalStateSubscription ? state.isInvalid : null);
|
|
495
496
|
const getContainerProps = useCallback((innerProps) => {
|
|
497
|
+
const { unstyled = globalUnstyled, ...restOfInnerProps } = innerProps;
|
|
496
498
|
const isDisabled = disabled;
|
|
497
499
|
const onFileDrop = !isDisabled ? actions.handleDrop : void 0;
|
|
498
500
|
const onFilePaste = !isDisabled ? actions.handlePaste : void 0;
|
|
@@ -506,11 +508,8 @@ const useDropZone = (props) => {
|
|
|
506
508
|
"data-drag-over": dataAttr(isDraggingOver),
|
|
507
509
|
"data-invalid": dataAttr(isInvalid)
|
|
508
510
|
},
|
|
509
|
-
...
|
|
510
|
-
className: cnMerge(`relative flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed
|
|
511
|
-
p-6 transition-colors duration-250 ease-out outline-none select-none
|
|
512
|
-
focus-visible:border-zu-ring/50`, `data-disabled:pointer-events-none data-drag-over:opacity-60
|
|
513
|
-
data-invalid:border-zu-destructive data-invalid:ring-zu-destructive/20`, innerProps.className),
|
|
511
|
+
...restOfInnerProps,
|
|
512
|
+
...!unstyled && { className: cnMerge(`relative flex flex-col items-center justify-center gap-2 rounded-lg border-2 border-dashed p-6 transition-colors duration-250 ease-out outline-none select-none focus-visible:border-zu-ring/50`, `data-disabled:pointer-events-none data-drag-over:opacity-60 data-invalid:border-zu-destructive data-invalid:ring-zu-destructive/20`, innerProps.className) },
|
|
514
513
|
"data-disabled": dataAttr(isDisabled),
|
|
515
514
|
onClick: composeTwoEventHandlers(onAreaClick, innerProps.onClick),
|
|
516
515
|
onDragEnter: composeTwoEventHandlers(actions.handleDragEnter, innerProps.onDragEnter),
|
|
@@ -522,18 +521,19 @@ const useDropZone = (props) => {
|
|
|
522
521
|
tabIndex
|
|
523
522
|
};
|
|
524
523
|
}, [
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
actions.handleDragOver,
|
|
524
|
+
globalUnstyled,
|
|
525
|
+
disabled,
|
|
528
526
|
actions.handleDrop,
|
|
529
|
-
actions.handleKeyDown,
|
|
530
527
|
actions.handlePaste,
|
|
531
528
|
actions.openFilePicker,
|
|
529
|
+
actions.handleKeyDown,
|
|
530
|
+
actions.handleDragEnter,
|
|
531
|
+
actions.handleDragLeave,
|
|
532
|
+
actions.handleDragOver,
|
|
533
|
+
disableFilePickerOpenOnAreaClick,
|
|
532
534
|
disableInternalStateSubscription,
|
|
533
|
-
disabled,
|
|
534
535
|
isDraggingOver,
|
|
535
|
-
isInvalid
|
|
536
|
-
disableFilePickerOpenOnAreaClick
|
|
536
|
+
isInvalid
|
|
537
537
|
]);
|
|
538
538
|
const refCallback = useCallbackRef((node) => {
|
|
539
539
|
inputRef.current = node;
|
|
@@ -576,32 +576,31 @@ const useDropZone = (props) => {
|
|
|
576
576
|
};
|
|
577
577
|
}, [actions.openFilePicker, disabled]);
|
|
578
578
|
const getFileListProps = useCallback((innerProps) => {
|
|
579
|
-
const { orientation = "vertical", ...restOfInnerProps } = innerProps;
|
|
579
|
+
const { orientation = "vertical", unstyled = globalUnstyled, ...restOfInnerProps } = innerProps;
|
|
580
580
|
return {
|
|
581
581
|
...getScopeAttrs("file-list"),
|
|
582
582
|
"data-orientation": orientation,
|
|
583
|
-
...!disableInternalStateSubscription && { "data-state": hasFiles ? "active" : "inactive" },
|
|
584
583
|
...restOfInnerProps,
|
|
585
|
-
className: cnMerge("flex flex-col gap-2
|
|
584
|
+
...!unstyled && { className: cnMerge("flex flex-col gap-2", orientation === "horizontal" && "flex-row overflow-x-auto p-1.5", innerProps.className) }
|
|
586
585
|
};
|
|
587
|
-
}, [
|
|
588
|
-
const getFileItemProps =
|
|
586
|
+
}, [globalUnstyled]);
|
|
587
|
+
const getFileItemProps = useCallback((innerProps) => {
|
|
588
|
+
const { unstyled = globalUnstyled, ...restOfInnerProps } = innerProps;
|
|
589
589
|
return {
|
|
590
590
|
...getScopeAttrs("file-item"),
|
|
591
|
-
...
|
|
592
|
-
className: cnMerge("relative flex items-center gap-2.5 rounded-md border p-2", innerProps.className)
|
|
591
|
+
...restOfInnerProps,
|
|
592
|
+
...!unstyled && { className: cnMerge("relative flex animate-files-in items-center gap-2.5 rounded-md border p-2", innerProps.className) }
|
|
593
593
|
};
|
|
594
|
-
});
|
|
595
|
-
const getFileItemProgressProps =
|
|
596
|
-
const { variant = "linear", ...restOfInnerProps } = innerProps;
|
|
594
|
+
}, [globalUnstyled]);
|
|
595
|
+
const getFileItemProgressProps = useCallback((innerProps) => {
|
|
596
|
+
const { unstyled = globalUnstyled, variant = "linear", ...restOfInnerProps } = innerProps;
|
|
597
597
|
return {
|
|
598
598
|
...getScopeAttrs("file-item-progress"),
|
|
599
599
|
role: "progressbar",
|
|
600
600
|
...restOfInnerProps,
|
|
601
|
-
className: cnMerge("inline-flex", variant === "circular" && "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2", variant === "fill" && `absolute inset-0 bg-zu-primary/50 transition-[clip-path] duration-300 ease-linear
|
|
602
|
-
[clip-path:var(--clip-path)]`, variant === "linear" && "relative h-1.5 w-full overflow-hidden rounded-full bg-zu-primary/20", restOfInnerProps.className)
|
|
601
|
+
...!unstyled && { className: cnMerge("inline-flex", variant === "circular" && "absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2", variant === "fill" && `absolute inset-0 bg-zu-primary/50 transition-[clip-path] duration-300 ease-linear [clip-path:var(--clip-path)]`, variant === "linear" && "relative h-1.5 w-full overflow-hidden rounded-full bg-zu-primary/20", restOfInnerProps.className) }
|
|
603
602
|
};
|
|
604
|
-
});
|
|
603
|
+
}, [globalUnstyled]);
|
|
605
604
|
const getFileItemDeleteProps = useCallback((innerProps) => {
|
|
606
605
|
const { fileStateOrID, ...restOfInnerProps } = innerProps;
|
|
607
606
|
const isDisabled = innerProps.disabled ?? disabled;
|
|
@@ -615,21 +614,22 @@ const useDropZone = (props) => {
|
|
|
615
614
|
onClick: composeTwoEventHandlers(onRemoveFile, restOfInnerProps.onClick)
|
|
616
615
|
};
|
|
617
616
|
}, [actions, disabled]);
|
|
618
|
-
const getFileItemPreviewProps =
|
|
617
|
+
const getFileItemPreviewProps = useCallback((innerProps) => {
|
|
618
|
+
const { unstyled = globalUnstyled, ...restOfInnerProps } = innerProps;
|
|
619
619
|
return {
|
|
620
620
|
...getScopeAttrs("file-item-preview"),
|
|
621
|
-
...
|
|
622
|
-
className: cnMerge(`relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-md
|
|
623
|
-
bg-zu-accent/50 [&>svg]:size-10`, innerProps.className)
|
|
621
|
+
...restOfInnerProps,
|
|
622
|
+
...!unstyled && { className: cnMerge(`relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded-md bg-zu-accent/50 [&>svg]:size-10`, innerProps.className) }
|
|
624
623
|
};
|
|
625
|
-
});
|
|
626
|
-
const getFileItemMetadataProps =
|
|
624
|
+
}, [globalUnstyled]);
|
|
625
|
+
const getFileItemMetadataProps = useCallback((innerProps) => {
|
|
626
|
+
const { unstyled = globalUnstyled, ...restOfInnerProps } = innerProps;
|
|
627
627
|
return {
|
|
628
628
|
...getScopeAttrs("file-item-metadata"),
|
|
629
|
-
...
|
|
630
|
-
className: cnMerge("flex min-w-0 grow flex-col", innerProps.className)
|
|
629
|
+
...restOfInnerProps,
|
|
630
|
+
...!unstyled && { className: cnMerge("flex min-w-0 grow flex-col", innerProps.className) }
|
|
631
631
|
};
|
|
632
|
-
});
|
|
632
|
+
}, [globalUnstyled]);
|
|
633
633
|
const getFileItemClearProps = useCallback((innerProps) => {
|
|
634
634
|
const isDisabled = innerProps.disabled ?? disabled;
|
|
635
635
|
return {
|
|
@@ -792,19 +792,19 @@ function DropZoneFileList(props) {
|
|
|
792
792
|
function DropZoneFileItem(props) {
|
|
793
793
|
const { as: Element = "li", asChild, fileState, ...restOfProps } = props;
|
|
794
794
|
const { propGetters } = useDropZoneRootContext();
|
|
795
|
-
const Component
|
|
795
|
+
const Component = asChild ? SlotRoot : Element;
|
|
796
796
|
return /* @__PURE__ */ jsx(FileItemContextProvider, {
|
|
797
797
|
value: useMemo(() => ({ fileState }), [fileState]),
|
|
798
|
-
children: /* @__PURE__ */ jsx(Component
|
|
798
|
+
children: /* @__PURE__ */ jsx(Component, { ...propGetters.getFileItemProps(restOfProps) })
|
|
799
799
|
});
|
|
800
800
|
}
|
|
801
801
|
function DropZoneFileItemDelete(props) {
|
|
802
802
|
const { asChild, fileStateOrID, ...restOfProps } = props;
|
|
803
803
|
const { propGetters } = useDropZoneRootContext();
|
|
804
804
|
const fileItemContextValue = useFileItemContext();
|
|
805
|
-
const Component
|
|
805
|
+
const Component = asChild ? SlotRoot : "button";
|
|
806
806
|
const resolvedFileStateOrID = fileStateOrID ?? fileItemContextValue?.fileState;
|
|
807
|
-
return /* @__PURE__ */ jsx(Component
|
|
807
|
+
return /* @__PURE__ */ jsx(Component, { ...propGetters.getFileItemDeleteProps({
|
|
808
808
|
fileStateOrID: resolvedFileStateOrID,
|
|
809
809
|
...restOfProps
|
|
810
810
|
}) });
|
|
@@ -816,7 +816,7 @@ function DropZoneFileItemProgress(props) {
|
|
|
816
816
|
if (!fileState) return null;
|
|
817
817
|
const currentProgress = fileState.progress;
|
|
818
818
|
if (!(forceMount || fileState.progress !== 100)) return null;
|
|
819
|
-
const Component
|
|
819
|
+
const Component = asChild ? SlotRoot : Element;
|
|
820
820
|
const componentProps = propGetters.getFileItemProgressProps({
|
|
821
821
|
variant,
|
|
822
822
|
...restOfProps
|
|
@@ -825,7 +825,7 @@ function DropZoneFileItemProgress(props) {
|
|
|
825
825
|
case "circular": {
|
|
826
826
|
const circumference = 2 * Math.PI * ((size - 4) / 2);
|
|
827
827
|
const strokeDashoffset = circumference - currentProgress / 100 * circumference;
|
|
828
|
-
return /* @__PURE__ */ jsx(Component
|
|
828
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
829
829
|
...componentProps,
|
|
830
830
|
children: /* @__PURE__ */ jsxs("svg", {
|
|
831
831
|
className: "-rotate-90",
|
|
@@ -855,12 +855,12 @@ function DropZoneFileItemProgress(props) {
|
|
|
855
855
|
}
|
|
856
856
|
case "fill": {
|
|
857
857
|
const topInset = 100 - currentProgress;
|
|
858
|
-
return /* @__PURE__ */ jsx(Component
|
|
858
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
859
859
|
...componentProps,
|
|
860
860
|
style: { "--clip-path": `inset(${topInset}% 0% 0% 0%)` }
|
|
861
861
|
});
|
|
862
862
|
}
|
|
863
|
-
case "linear": return /* @__PURE__ */ jsx(Component
|
|
863
|
+
case "linear": return /* @__PURE__ */ jsx(Component, {
|
|
864
864
|
...componentProps,
|
|
865
865
|
children: /* @__PURE__ */ jsx("span", {
|
|
866
866
|
className: "inline-block size-full grow translate-x-(--translate-distance) bg-zu-primary transition-transform duration-300 ease-linear",
|
|
@@ -878,7 +878,7 @@ function DropZoneFileItemPreview(props) {
|
|
|
878
878
|
if (!fileState) return null;
|
|
879
879
|
const fileType = fileState.file.type ?? "";
|
|
880
880
|
const fileExtension = fileState.file.name?.split(".").pop()?.toLowerCase() ?? "";
|
|
881
|
-
const Component
|
|
881
|
+
const Component = asChild ? SlotRoot : Element;
|
|
882
882
|
const fallbackPreview = () => getFilePreviewOrIcon({
|
|
883
883
|
fileExtension,
|
|
884
884
|
fileState,
|
|
@@ -891,7 +891,7 @@ function DropZoneFileItemPreview(props) {
|
|
|
891
891
|
fileState,
|
|
892
892
|
fileType
|
|
893
893
|
}) : children;
|
|
894
|
-
return /* @__PURE__ */ jsxs(Component
|
|
894
|
+
return /* @__PURE__ */ jsxs(Component, {
|
|
895
895
|
...propGetters.getFileItemPreviewProps(restOfProps),
|
|
896
896
|
children: [renderPreview && fallbackPreview(), resolvedChildren]
|
|
897
897
|
});
|
|
@@ -967,7 +967,7 @@ function DropZoneFileItemMetadata(props) {
|
|
|
967
967
|
const { propGetters } = useDropZoneRootContext();
|
|
968
968
|
const fileState = fileStateProp ?? fileItemContextValue?.fileState;
|
|
969
969
|
if (!fileState) return null;
|
|
970
|
-
const Component
|
|
970
|
+
const Component = asChild ? SlotRoot : "div";
|
|
971
971
|
const resolvedChildren = isFunction(children) ? children({ fileState }) : children;
|
|
972
972
|
const getDefaultMetadataChildren = () => {
|
|
973
973
|
return /* @__PURE__ */ jsxs(Fragment$1, { children: [
|
|
@@ -985,7 +985,7 @@ function DropZoneFileItemMetadata(props) {
|
|
|
985
985
|
})
|
|
986
986
|
] });
|
|
987
987
|
};
|
|
988
|
-
return /* @__PURE__ */ jsx(Component
|
|
988
|
+
return /* @__PURE__ */ jsx(Component, {
|
|
989
989
|
...propGetters.getFileItemMetadataProps(restOfProps),
|
|
990
990
|
children: resolvedChildren ?? getDefaultMetadataChildren()
|
|
991
991
|
});
|