@szum-tech/design-system 3.17.0 → 3.18.2
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/chunk-D5PAWOAZ.cjs +1 -0
- package/dist/chunk-JUNHRB4B.js +1 -0
- package/dist/chunk-P7BFOJLM.cjs +3 -0
- package/dist/chunk-ZYG2KYKK.js +3 -0
- package/dist/components/index.cjs +1 -924
- package/dist/components/index.d.cts +1650 -56
- package/dist/components/index.d.ts +1650 -56
- package/dist/components/index.js +1 -43
- package/dist/hooks/index.cjs +1 -35
- package/dist/hooks/index.js +1 -2
- package/dist/icons/index.cjs +2 -93
- package/dist/icons/index.js +2 -88
- package/dist/utils/index.cjs +1 -10
- package/dist/utils/index.js +1 -1
- package/package.json +30 -38
- package/dist/chunk-2WQJ36RD.cjs +0 -78
- package/dist/chunk-2Y2ZCPNV.cjs +0 -61
- package/dist/chunk-35H6T7OQ.cjs +0 -2912
- package/dist/chunk-375QAB65.cjs +0 -145
- package/dist/chunk-3DP3VMPN.js +0 -173
- package/dist/chunk-3GNVQFCK.cjs +0 -50
- package/dist/chunk-3RK5PCIC.js +0 -86
- package/dist/chunk-3WSQRFUY.cjs +0 -11
- package/dist/chunk-4LNGZHF2.cjs +0 -33
- package/dist/chunk-4TRADSTP.js +0 -34
- package/dist/chunk-5B37TQYT.cjs +0 -18
- package/dist/chunk-5F2Y65JH.js +0 -32
- package/dist/chunk-5MJPZUTO.js +0 -38
- package/dist/chunk-5MV54MWS.js +0 -46
- package/dist/chunk-6BSR3O2J.js +0 -53
- package/dist/chunk-6HX7ETL3.cjs +0 -183
- package/dist/chunk-7OD2NBSV.cjs +0 -50
- package/dist/chunk-A72LE53B.js +0 -21
- package/dist/chunk-A7SBXO2Y.cjs +0 -40
- package/dist/chunk-AAPMLWYK.js +0 -2831
- package/dist/chunk-B4M7Q5KX.cjs +0 -25
- package/dist/chunk-B7RHEMZH.js +0 -48
- package/dist/chunk-BTSHACKG.js +0 -123
- package/dist/chunk-BUJO4FB6.js +0 -252
- package/dist/chunk-CL2C6STG.cjs +0 -278
- package/dist/chunk-CXHDWIGF.cjs +0 -89
- package/dist/chunk-DGWBE2Y3.cjs +0 -205
- package/dist/chunk-DUAM4RTP.cjs +0 -23
- package/dist/chunk-EOTQVIA5.js +0 -993
- package/dist/chunk-EUH466AL.cjs +0 -179
- package/dist/chunk-F7NFSDOD.cjs +0 -91
- package/dist/chunk-G24PWQKG.js +0 -20
- package/dist/chunk-GEDBA3JU.cjs +0 -49
- package/dist/chunk-GYXQUTWZ.cjs +0 -59
- package/dist/chunk-H2BWO3SI.cjs +0 -11
- package/dist/chunk-H5NHGMSQ.js +0 -136
- package/dist/chunk-HCHVDUI6.cjs +0 -34
- package/dist/chunk-HNRVLRMN.js +0 -82
- package/dist/chunk-HPICKLBZ.cjs +0 -204
- package/dist/chunk-I3E75OQX.js +0 -16
- package/dist/chunk-I3RSTJP6.js +0 -20
- package/dist/chunk-IWF52DDE.js +0 -55
- package/dist/chunk-IZU3KULT.js +0 -41
- package/dist/chunk-K5AURCK5.js +0 -183
- package/dist/chunk-KTAIBRTH.cjs +0 -10
- package/dist/chunk-L2TRMQNN.js +0 -130
- package/dist/chunk-M7NIRB3U.js +0 -43
- package/dist/chunk-MNDQXDV4.cjs +0 -607
- package/dist/chunk-N4TYSZSU.cjs +0 -44
- package/dist/chunk-NU5UQPBX.cjs +0 -25
- package/dist/chunk-NXEZE7LG.js +0 -15
- package/dist/chunk-OCOCENE6.js +0 -42
- package/dist/chunk-OQCNPNPS.js +0 -23
- package/dist/chunk-OXZQGDTR.js +0 -208
- package/dist/chunk-OZSNSRLV.cjs +0 -1027
- package/dist/chunk-P4IL77YC.js +0 -66
- package/dist/chunk-P4JIMFSL.js +0 -51
- package/dist/chunk-P5IUC7HJ.js +0 -9
- package/dist/chunk-PBEZZMAB.js +0 -25
- package/dist/chunk-RKFU4DS3.cjs +0 -1064
- package/dist/chunk-S3ANEJJ7.cjs +0 -22
- package/dist/chunk-S3ZUFD6U.js +0 -23
- package/dist/chunk-SHPJGB2L.cjs +0 -19
- package/dist/chunk-TH44JYXB.cjs +0 -27
- package/dist/chunk-TMXVL5CV.cjs +0 -48
- package/dist/chunk-U3QKV7I4.js +0 -54
- package/dist/chunk-U7XZJQ4O.js +0 -36
- package/dist/chunk-UJX74PFK.cjs +0 -46
- package/dist/chunk-ULEEQ723.cjs +0 -108
- package/dist/chunk-UNOMGKAZ.cjs +0 -141
- package/dist/chunk-USIW3VT5.cjs +0 -73
- package/dist/chunk-VK2FJ65F.js +0 -575
- package/dist/chunk-VK5EX3OG.cjs +0 -132
- package/dist/chunk-WCQ5WKCQ.js +0 -1042
- package/dist/chunk-WMGJCB7O.js +0 -157
- package/dist/chunk-X3ZT3KGX.cjs +0 -53
- package/dist/chunk-X5O7GP4S.js +0 -48
- package/dist/chunk-X7WREEFD.js +0 -8
- package/dist/chunk-XENOUBSI.cjs +0 -37
- package/dist/chunk-XKCLVPUC.js +0 -176
- package/dist/chunk-XTKD76O5.js +0 -29
- package/dist/chunk-YBFG2IRJ.cjs +0 -225
- package/dist/chunk-YEFLGE3L.cjs +0 -47
- package/dist/chunk-YUMKV5TH.js +0 -56
- package/dist/chunk-ZD2QRAOX.js +0 -9
- package/dist/chunk-ZVF7J4EI.cjs +0 -58
- package/dist/color-picker.types-GI7dq2Ig.d.cts +0 -42
- package/dist/color-picker.types-GI7dq2Ig.d.ts +0 -42
- package/dist/components/accordion/index.cjs +0 -23
- package/dist/components/accordion/index.d.cts +0 -17
- package/dist/components/accordion/index.d.ts +0 -17
- package/dist/components/accordion/index.js +0 -2
- package/dist/components/alert/index.cjs +0 -19
- package/dist/components/alert/index.d.cts +0 -24
- package/dist/components/alert/index.d.ts +0 -24
- package/dist/components/alert/index.js +0 -2
- package/dist/components/alert-dialog/index.cjs +0 -43
- package/dist/components/alert-dialog/index.d.cts +0 -32
- package/dist/components/alert-dialog/index.d.ts +0 -32
- package/dist/components/alert-dialog/index.js +0 -2
- package/dist/components/avatar/index.cjs +0 -19
- package/dist/components/avatar/index.d.cts +0 -14
- package/dist/components/avatar/index.d.ts +0 -14
- package/dist/components/avatar/index.js +0 -2
- package/dist/components/badge/index.cjs +0 -19
- package/dist/components/badge/index.d.cts +0 -28
- package/dist/components/badge/index.d.ts +0 -28
- package/dist/components/badge/index.js +0 -2
- package/dist/components/badge-overflow/index.cjs +0 -183
- package/dist/components/badge-overflow/index.d.cts +0 -21
- package/dist/components/badge-overflow/index.d.ts +0 -21
- package/dist/components/badge-overflow/index.js +0 -161
- package/dist/components/breadcrump/index.cjs +0 -80
- package/dist/components/breadcrump/index.d.cts +0 -21
- package/dist/components/breadcrump/index.d.ts +0 -21
- package/dist/components/breadcrump/index.js +0 -72
- package/dist/components/button/index.cjs +0 -52
- package/dist/components/button/index.d.cts +0 -58
- package/dist/components/button/index.d.ts +0 -58
- package/dist/components/button/index.js +0 -43
- package/dist/components/card/index.cjs +0 -35
- package/dist/components/card/index.d.cts +0 -25
- package/dist/components/card/index.d.ts +0 -25
- package/dist/components/card/index.js +0 -2
- package/dist/components/carousel/index.cjs +0 -269
- package/dist/components/carousel/index.d.cts +0 -48
- package/dist/components/carousel/index.d.ts +0 -48
- package/dist/components/carousel/index.js +0 -238
- package/dist/components/checkbox/index.cjs +0 -11
- package/dist/components/checkbox/index.d.cts +0 -8
- package/dist/components/checkbox/index.d.ts +0 -8
- package/dist/components/checkbox/index.js +0 -2
- package/dist/components/collapsible/index.cjs +0 -18
- package/dist/components/collapsible/index.d.cts +0 -12
- package/dist/components/collapsible/index.d.ts +0 -12
- package/dist/components/collapsible/index.js +0 -1
- package/dist/components/color-picker/index.cjs +0 -92
- package/dist/components/color-picker/index.d.cts +0 -71
- package/dist/components/color-picker/index.d.ts +0 -71
- package/dist/components/color-picker/index.js +0 -43
- package/dist/components/color-swatch/index.cjs +0 -11
- package/dist/components/color-swatch/index.d.cts +0 -22
- package/dist/components/color-swatch/index.d.ts +0 -22
- package/dist/components/color-swatch/index.js +0 -2
- package/dist/components/counting-number/index.cjs +0 -11
- package/dist/components/counting-number/index.d.cts +0 -57
- package/dist/components/counting-number/index.d.ts +0 -57
- package/dist/components/counting-number/index.js +0 -2
- package/dist/components/dialog/index.cjs +0 -39
- package/dist/components/dialog/index.d.cts +0 -42
- package/dist/components/dialog/index.d.ts +0 -42
- package/dist/components/dialog/index.js +0 -2
- package/dist/components/dropdown-menu/index.cjs +0 -71
- package/dist/components/dropdown-menu/index.d.cts +0 -67
- package/dist/components/dropdown-menu/index.d.ts +0 -67
- package/dist/components/dropdown-menu/index.js +0 -2
- package/dist/components/empty/index.cjs +0 -31
- package/dist/components/empty/index.d.cts +0 -29
- package/dist/components/empty/index.d.ts +0 -29
- package/dist/components/empty/index.js +0 -2
- package/dist/components/field/index.cjs +0 -49
- package/dist/components/field/index.d.cts +0 -50
- package/dist/components/field/index.d.ts +0 -50
- package/dist/components/field/index.js +0 -4
- package/dist/components/file-upload/index.cjs +0 -60
- package/dist/components/file-upload/index.d.cts +0 -131
- package/dist/components/file-upload/index.d.ts +0 -131
- package/dist/components/file-upload/index.js +0 -3
- package/dist/components/header/index.cjs +0 -11
- package/dist/components/header/index.d.cts +0 -18
- package/dist/components/header/index.d.ts +0 -18
- package/dist/components/header/index.js +0 -2
- package/dist/components/input/index.cjs +0 -11
- package/dist/components/input/index.d.cts +0 -9
- package/dist/components/input/index.d.ts +0 -9
- package/dist/components/input/index.js +0 -2
- package/dist/components/item/index.cjs +0 -48
- package/dist/components/item/index.d.cts +0 -61
- package/dist/components/item/index.d.ts +0 -61
- package/dist/components/item/index.js +0 -3
- package/dist/components/label/index.cjs +0 -11
- package/dist/components/label/index.d.cts +0 -8
- package/dist/components/label/index.d.ts +0 -8
- package/dist/components/label/index.js +0 -2
- package/dist/components/marquee/index.cjs +0 -11
- package/dist/components/marquee/index.d.cts +0 -48
- package/dist/components/marquee/index.d.ts +0 -48
- package/dist/components/marquee/index.js +0 -2
- package/dist/components/masonry/index.cjs +0 -16
- package/dist/components/masonry/index.d.cts +0 -181
- package/dist/components/masonry/index.d.ts +0 -181
- package/dist/components/masonry/index.js +0 -3
- package/dist/components/popover/index.cjs +0 -35
- package/dist/components/popover/index.d.cts +0 -18
- package/dist/components/popover/index.d.ts +0 -18
- package/dist/components/popover/index.js +0 -2
- package/dist/components/progress/index.cjs +0 -11
- package/dist/components/progress/index.d.cts +0 -8
- package/dist/components/progress/index.d.ts +0 -8
- package/dist/components/progress/index.js +0 -2
- package/dist/components/radio-group/index.cjs +0 -15
- package/dist/components/radio-group/index.d.cts +0 -22
- package/dist/components/radio-group/index.d.ts +0 -22
- package/dist/components/radio-group/index.js +0 -2
- package/dist/components/scroll-area/index.cjs +0 -15
- package/dist/components/scroll-area/index.d.cts +0 -11
- package/dist/components/scroll-area/index.d.ts +0 -11
- package/dist/components/scroll-area/index.js +0 -2
- package/dist/components/select/index.cjs +0 -31
- package/dist/components/select/index.d.cts +0 -22
- package/dist/components/select/index.d.ts +0 -22
- package/dist/components/select/index.js +0 -2
- package/dist/components/separator/index.cjs +0 -11
- package/dist/components/separator/index.d.cts +0 -8
- package/dist/components/separator/index.d.ts +0 -8
- package/dist/components/separator/index.js +0 -2
- package/dist/components/sheet/index.cjs +0 -39
- package/dist/components/sheet/index.d.cts +0 -42
- package/dist/components/sheet/index.d.ts +0 -42
- package/dist/components/sheet/index.js +0 -2
- package/dist/components/sidebar/index.cjs +0 -148
- package/dist/components/sidebar/index.d.cts +0 -135
- package/dist/components/sidebar/index.d.ts +0 -135
- package/dist/components/sidebar/index.js +0 -43
- package/dist/components/skeleton/index.cjs +0 -11
- package/dist/components/skeleton/index.d.cts +0 -7
- package/dist/components/skeleton/index.d.ts +0 -7
- package/dist/components/skeleton/index.js +0 -2
- package/dist/components/sortable/index.cjs +0 -27
- package/dist/components/sortable/index.d.cts +0 -50
- package/dist/components/sortable/index.d.ts +0 -50
- package/dist/components/sortable/index.js +0 -2
- package/dist/components/spinner/index.cjs +0 -11
- package/dist/components/spinner/index.d.cts +0 -7
- package/dist/components/spinner/index.d.ts +0 -7
- package/dist/components/spinner/index.js +0 -2
- package/dist/components/status/index.cjs +0 -19
- package/dist/components/status/index.d.cts +0 -25
- package/dist/components/status/index.d.ts +0 -25
- package/dist/components/status/index.js +0 -2
- package/dist/components/stepper/index.cjs +0 -124
- package/dist/components/stepper/index.d.cts +0 -164
- package/dist/components/stepper/index.d.ts +0 -164
- package/dist/components/stepper/index.js +0 -43
- package/dist/components/switch/index.cjs +0 -11
- package/dist/components/switch/index.d.cts +0 -19
- package/dist/components/switch/index.d.ts +0 -19
- package/dist/components/switch/index.js +0 -2
- package/dist/components/tabs/index.cjs +0 -23
- package/dist/components/tabs/index.d.cts +0 -17
- package/dist/components/tabs/index.d.ts +0 -17
- package/dist/components/tabs/index.js +0 -2
- package/dist/components/textarea/index.cjs +0 -11
- package/dist/components/textarea/index.d.cts +0 -9
- package/dist/components/textarea/index.d.ts +0 -9
- package/dist/components/textarea/index.js +0 -2
- package/dist/components/timeline/index.cjs +0 -45
- package/dist/components/timeline/index.d.cts +0 -63
- package/dist/components/timeline/index.d.ts +0 -63
- package/dist/components/timeline/index.js +0 -4
- package/dist/components/toaster/index.cjs +0 -56
- package/dist/components/toaster/index.d.cts +0 -8
- package/dist/components/toaster/index.d.ts +0 -8
- package/dist/components/toaster/index.js +0 -43
- package/dist/components/tooltip/index.cjs +0 -19
- package/dist/components/tooltip/index.d.cts +0 -12
- package/dist/components/tooltip/index.d.ts +0 -12
- package/dist/components/tooltip/index.js +0 -2
- package/dist/components/typing-text/index.cjs +0 -11
- package/dist/components/typing-text/index.d.cts +0 -41
- package/dist/components/typing-text/index.d.ts +0 -41
- package/dist/components/typing-text/index.js +0 -2
- package/dist/components/word-rotate/index.cjs +0 -11
- package/dist/components/word-rotate/index.d.cts +0 -30
- package/dist/components/word-rotate/index.d.ts +0 -30
- package/dist/components/word-rotate/index.js +0 -2
- package/dist/direction-CUOPDLCj.d.cts +0 -7
- package/dist/direction-CUOPDLCj.d.ts +0 -7
- package/dist/popover-trigger-Cf4PPj0z.d.cts +0 -14
- package/dist/popover-trigger-Cf4PPj0z.d.ts +0 -14
- package/dist/select-Bf6XQtt-.d.cts +0 -12
- package/dist/select-Bf6XQtt-.d.ts +0 -12
- package/dist/tooltip-content-DqtogPBq.d.cts +0 -8
- package/dist/tooltip-content-DqtogPBq.d.ts +0 -8
package/dist/chunk-OZSNSRLV.cjs
DELETED
|
@@ -1,1027 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var chunkN4TYSZSU_cjs = require('./chunk-N4TYSZSU.cjs');
|
|
4
|
-
var chunkH2BWO3SI_cjs = require('./chunk-H2BWO3SI.cjs');
|
|
5
|
-
var React3 = require('react');
|
|
6
|
-
var radixUi = require('radix-ui');
|
|
7
|
-
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
-
var classVarianceAuthority = require('class-variance-authority');
|
|
9
|
-
var lucideReact = require('lucide-react');
|
|
10
|
-
|
|
11
|
-
function _interopNamespace(e) {
|
|
12
|
-
if (e && e.__esModule) return e;
|
|
13
|
-
var n = Object.create(null);
|
|
14
|
-
if (e) {
|
|
15
|
-
Object.keys(e).forEach(function (k) {
|
|
16
|
-
if (k !== 'default') {
|
|
17
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
18
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
19
|
-
enumerable: true,
|
|
20
|
-
get: function () { return e[k]; }
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
n.default = e;
|
|
26
|
-
return Object.freeze(n);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
var React3__namespace = /*#__PURE__*/_interopNamespace(React3);
|
|
30
|
-
|
|
31
|
-
// src/components/file-upload/file-upload.constants.ts
|
|
32
|
-
var ROOT_NAME = "FileUpload";
|
|
33
|
-
var DROPZONE_NAME = "FileUploadDropzone";
|
|
34
|
-
var TRIGGER_NAME = "FileUploadTrigger";
|
|
35
|
-
var LIST_NAME = "FileUploadList";
|
|
36
|
-
var ITEM_NAME = "FileUploadItem";
|
|
37
|
-
var ITEM_PREVIEW_NAME = "FileUploadItemPreview";
|
|
38
|
-
var ITEM_METADATA_NAME = "FileUploadItemMetadata";
|
|
39
|
-
var ITEM_PROGRESS_NAME = "FileUploadItemProgress";
|
|
40
|
-
var ITEM_DELETE_NAME = "FileUploadItemDelete";
|
|
41
|
-
var CLEAR_NAME = "FileUploadClear";
|
|
42
|
-
|
|
43
|
-
// src/components/file-upload/file-upload.context.tsx
|
|
44
|
-
var FileUploadContext = React3__namespace.createContext(null);
|
|
45
|
-
function useFileUploadContext(consumerName) {
|
|
46
|
-
const context = React3__namespace.useContext(FileUploadContext);
|
|
47
|
-
if (!context) {
|
|
48
|
-
throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
|
|
49
|
-
}
|
|
50
|
-
return context;
|
|
51
|
-
}
|
|
52
|
-
var FileUploadStoreContext = React3__namespace.createContext(null);
|
|
53
|
-
function useFileUploadStoreContext(consumerName) {
|
|
54
|
-
const context = React3__namespace.useContext(FileUploadStoreContext);
|
|
55
|
-
if (!context) {
|
|
56
|
-
throw new Error(`\`${consumerName}\` must be used within \`${ROOT_NAME}\``);
|
|
57
|
-
}
|
|
58
|
-
return context;
|
|
59
|
-
}
|
|
60
|
-
function useFileUploadStore(selector) {
|
|
61
|
-
const store = useFileUploadStoreContext("useFileUploadStore");
|
|
62
|
-
const lastValueRef = chunkN4TYSZSU_cjs.useLazyRef(() => null);
|
|
63
|
-
const getSnapshot = React3__namespace.useCallback(() => {
|
|
64
|
-
const state = store.getState();
|
|
65
|
-
const prevValue = lastValueRef.current;
|
|
66
|
-
if (prevValue && prevValue.state === state) {
|
|
67
|
-
return prevValue.value;
|
|
68
|
-
}
|
|
69
|
-
const nextValue = selector(state);
|
|
70
|
-
lastValueRef.current = { value: nextValue, state };
|
|
71
|
-
return nextValue;
|
|
72
|
-
}, [store, selector, lastValueRef]);
|
|
73
|
-
return React3__namespace.useSyncExternalStore(store.subscribe, getSnapshot, getSnapshot);
|
|
74
|
-
}
|
|
75
|
-
function createFileUploadStore(listeners, files, urlCache, propsRef, initialInvalid) {
|
|
76
|
-
let state = {
|
|
77
|
-
files,
|
|
78
|
-
dragOver: false,
|
|
79
|
-
invalid: initialInvalid
|
|
80
|
-
};
|
|
81
|
-
function reducer(state2, action) {
|
|
82
|
-
switch (action.type) {
|
|
83
|
-
case "ADD_FILES": {
|
|
84
|
-
for (const file of action.files) {
|
|
85
|
-
files.set(file, {
|
|
86
|
-
file,
|
|
87
|
-
progress: 0,
|
|
88
|
-
status: "idle"
|
|
89
|
-
});
|
|
90
|
-
}
|
|
91
|
-
if (propsRef.current.onValueChange) {
|
|
92
|
-
const fileList = Array.from(files.values()).map((fileState) => fileState.file);
|
|
93
|
-
propsRef.current.onValueChange(fileList);
|
|
94
|
-
}
|
|
95
|
-
return { ...state2, files };
|
|
96
|
-
}
|
|
97
|
-
case "SET_FILES": {
|
|
98
|
-
const newFileSet = new Set(action.files);
|
|
99
|
-
for (const existingFile of files.keys()) {
|
|
100
|
-
if (!newFileSet.has(existingFile)) {
|
|
101
|
-
files.delete(existingFile);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
for (const file of action.files) {
|
|
105
|
-
const existingState = files.get(file);
|
|
106
|
-
if (!existingState) {
|
|
107
|
-
files.set(file, {
|
|
108
|
-
file,
|
|
109
|
-
progress: 0,
|
|
110
|
-
status: "idle"
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
return { ...state2, files };
|
|
115
|
-
}
|
|
116
|
-
case "SET_PROGRESS": {
|
|
117
|
-
const fileState = files.get(action.file);
|
|
118
|
-
if (fileState) {
|
|
119
|
-
files.set(action.file, {
|
|
120
|
-
...fileState,
|
|
121
|
-
progress: action.progress,
|
|
122
|
-
status: "uploading"
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return { ...state2, files };
|
|
126
|
-
}
|
|
127
|
-
case "SET_SUCCESS": {
|
|
128
|
-
const fileState = files.get(action.file);
|
|
129
|
-
if (fileState) {
|
|
130
|
-
files.set(action.file, {
|
|
131
|
-
...fileState,
|
|
132
|
-
progress: 100,
|
|
133
|
-
status: "success"
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
return { ...state2, files };
|
|
137
|
-
}
|
|
138
|
-
case "SET_ERROR": {
|
|
139
|
-
const fileState = files.get(action.file);
|
|
140
|
-
if (fileState) {
|
|
141
|
-
files.set(action.file, {
|
|
142
|
-
...fileState,
|
|
143
|
-
error: action.error,
|
|
144
|
-
status: "error"
|
|
145
|
-
});
|
|
146
|
-
}
|
|
147
|
-
return { ...state2, files };
|
|
148
|
-
}
|
|
149
|
-
case "REMOVE_FILE": {
|
|
150
|
-
const cachedUrl = urlCache.get(action.file);
|
|
151
|
-
if (cachedUrl) {
|
|
152
|
-
URL.revokeObjectURL(cachedUrl);
|
|
153
|
-
urlCache.delete(action.file);
|
|
154
|
-
}
|
|
155
|
-
files.delete(action.file);
|
|
156
|
-
if (propsRef.current.onValueChange) {
|
|
157
|
-
const fileList = Array.from(files.values()).map((fileState) => fileState.file);
|
|
158
|
-
propsRef.current.onValueChange(fileList);
|
|
159
|
-
}
|
|
160
|
-
return { ...state2, files };
|
|
161
|
-
}
|
|
162
|
-
case "SET_DRAG_OVER": {
|
|
163
|
-
return { ...state2, dragOver: action.dragOver };
|
|
164
|
-
}
|
|
165
|
-
case "SET_INVALID": {
|
|
166
|
-
return { ...state2, invalid: action.invalid };
|
|
167
|
-
}
|
|
168
|
-
case "CLEAR": {
|
|
169
|
-
for (const file of files.keys()) {
|
|
170
|
-
const cachedUrl = urlCache.get(file);
|
|
171
|
-
if (cachedUrl) {
|
|
172
|
-
URL.revokeObjectURL(cachedUrl);
|
|
173
|
-
urlCache.delete(file);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
files.clear();
|
|
177
|
-
if (propsRef.current.onValueChange) {
|
|
178
|
-
propsRef.current.onValueChange([]);
|
|
179
|
-
}
|
|
180
|
-
return { ...state2, files, invalid: false };
|
|
181
|
-
}
|
|
182
|
-
default:
|
|
183
|
-
return state2;
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
return {
|
|
187
|
-
getState: () => state,
|
|
188
|
-
dispatch: (action) => {
|
|
189
|
-
state = reducer(state, action);
|
|
190
|
-
for (const listener of listeners) {
|
|
191
|
-
listener();
|
|
192
|
-
}
|
|
193
|
-
},
|
|
194
|
-
subscribe: (listener) => {
|
|
195
|
-
listeners.add(listener);
|
|
196
|
-
return () => listeners.delete(listener);
|
|
197
|
-
}
|
|
198
|
-
};
|
|
199
|
-
}
|
|
200
|
-
function FileUpload(props) {
|
|
201
|
-
const {
|
|
202
|
-
value,
|
|
203
|
-
defaultValue,
|
|
204
|
-
onValueChange,
|
|
205
|
-
onAccept,
|
|
206
|
-
onFileAccept,
|
|
207
|
-
onFileReject,
|
|
208
|
-
onFileValidate,
|
|
209
|
-
onUpload,
|
|
210
|
-
accept,
|
|
211
|
-
maxFiles,
|
|
212
|
-
maxSize,
|
|
213
|
-
dir: dirProp,
|
|
214
|
-
label,
|
|
215
|
-
name,
|
|
216
|
-
asChild,
|
|
217
|
-
disabled = false,
|
|
218
|
-
invalid = false,
|
|
219
|
-
multiple = false,
|
|
220
|
-
required = false,
|
|
221
|
-
children,
|
|
222
|
-
className,
|
|
223
|
-
...rootProps
|
|
224
|
-
} = props;
|
|
225
|
-
const inputId = React3__namespace.useId();
|
|
226
|
-
const dropzoneId = React3__namespace.useId();
|
|
227
|
-
const listId = React3__namespace.useId();
|
|
228
|
-
const labelId = React3__namespace.useId();
|
|
229
|
-
const dir = radixUi.Direction.useDirection(dirProp);
|
|
230
|
-
const listeners = chunkN4TYSZSU_cjs.useLazyRef(() => /* @__PURE__ */ new Set()).current;
|
|
231
|
-
const files = chunkN4TYSZSU_cjs.useLazyRef(() => /* @__PURE__ */ new Map()).current;
|
|
232
|
-
const urlCache = chunkN4TYSZSU_cjs.useLazyRef(() => /* @__PURE__ */ new WeakMap()).current;
|
|
233
|
-
const inputRef = React3__namespace.useRef(null);
|
|
234
|
-
const isControlled = value !== void 0;
|
|
235
|
-
const propsRef = chunkN4TYSZSU_cjs.useAsRef({
|
|
236
|
-
onValueChange,
|
|
237
|
-
onAccept,
|
|
238
|
-
onFileAccept,
|
|
239
|
-
onFileReject,
|
|
240
|
-
onFileValidate,
|
|
241
|
-
onUpload
|
|
242
|
-
});
|
|
243
|
-
const store = React3__namespace.useMemo(
|
|
244
|
-
() => createFileUploadStore(listeners, files, urlCache, propsRef, invalid),
|
|
245
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
246
|
-
[listeners, files, urlCache, propsRef]
|
|
247
|
-
);
|
|
248
|
-
React3__namespace.useEffect(() => {
|
|
249
|
-
store.dispatch({ type: "SET_INVALID", invalid });
|
|
250
|
-
}, [store, invalid]);
|
|
251
|
-
const acceptTypes = React3__namespace.useMemo(() => accept?.split(",").map((t) => t.trim()) ?? null, [accept]);
|
|
252
|
-
const onProgress = chunkN4TYSZSU_cjs.useLazyRef(() => {
|
|
253
|
-
let frame = 0;
|
|
254
|
-
return (file, progress) => {
|
|
255
|
-
if (frame) return;
|
|
256
|
-
frame = requestAnimationFrame(() => {
|
|
257
|
-
frame = 0;
|
|
258
|
-
store.dispatch({
|
|
259
|
-
type: "SET_PROGRESS",
|
|
260
|
-
file,
|
|
261
|
-
progress: Math.min(Math.max(0, progress), 100)
|
|
262
|
-
});
|
|
263
|
-
});
|
|
264
|
-
};
|
|
265
|
-
}).current;
|
|
266
|
-
React3__namespace.useEffect(() => {
|
|
267
|
-
if (isControlled) {
|
|
268
|
-
store.dispatch({ type: "SET_FILES", files: value });
|
|
269
|
-
} else if (defaultValue && defaultValue.length > 0 && !store.getState().files.size) {
|
|
270
|
-
store.dispatch({ type: "SET_FILES", files: defaultValue });
|
|
271
|
-
}
|
|
272
|
-
}, [value, defaultValue, isControlled, store]);
|
|
273
|
-
React3__namespace.useEffect(() => {
|
|
274
|
-
return () => {
|
|
275
|
-
for (const file of files.keys()) {
|
|
276
|
-
const cachedUrl = urlCache.get(file);
|
|
277
|
-
if (cachedUrl) {
|
|
278
|
-
URL.revokeObjectURL(cachedUrl);
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
};
|
|
282
|
-
}, [files, urlCache]);
|
|
283
|
-
const onFilesUpload = React3__namespace.useCallback(
|
|
284
|
-
async (filesToUpload) => {
|
|
285
|
-
try {
|
|
286
|
-
for (const file of filesToUpload) {
|
|
287
|
-
store.dispatch({ type: "SET_PROGRESS", file, progress: 0 });
|
|
288
|
-
}
|
|
289
|
-
if (propsRef.current.onUpload) {
|
|
290
|
-
await propsRef.current.onUpload(filesToUpload, {
|
|
291
|
-
onProgress,
|
|
292
|
-
onSuccess: (file) => {
|
|
293
|
-
store.dispatch({ type: "SET_SUCCESS", file });
|
|
294
|
-
},
|
|
295
|
-
onError: (file, error) => {
|
|
296
|
-
store.dispatch({
|
|
297
|
-
type: "SET_ERROR",
|
|
298
|
-
file,
|
|
299
|
-
error: error.message ?? "Upload failed"
|
|
300
|
-
});
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
} else {
|
|
304
|
-
for (const file of filesToUpload) {
|
|
305
|
-
store.dispatch({ type: "SET_SUCCESS", file });
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
} catch (error) {
|
|
309
|
-
const errorMessage = error instanceof Error ? error.message : "Upload failed";
|
|
310
|
-
for (const file of filesToUpload) {
|
|
311
|
-
store.dispatch({
|
|
312
|
-
type: "SET_ERROR",
|
|
313
|
-
file,
|
|
314
|
-
error: errorMessage
|
|
315
|
-
});
|
|
316
|
-
}
|
|
317
|
-
}
|
|
318
|
-
},
|
|
319
|
-
[store, propsRef, onProgress]
|
|
320
|
-
);
|
|
321
|
-
const onFilesChange = React3__namespace.useCallback(
|
|
322
|
-
(originalFiles) => {
|
|
323
|
-
if (disabled) return;
|
|
324
|
-
let filesToProcess = [...originalFiles];
|
|
325
|
-
let hasInvalid = false;
|
|
326
|
-
if (maxFiles) {
|
|
327
|
-
const currentCount = store.getState().files.size;
|
|
328
|
-
const remainingSlotCount = Math.max(0, maxFiles - currentCount);
|
|
329
|
-
if (remainingSlotCount < filesToProcess.length) {
|
|
330
|
-
const rejectedFiles = filesToProcess.slice(remainingSlotCount);
|
|
331
|
-
hasInvalid = true;
|
|
332
|
-
filesToProcess = filesToProcess.slice(0, remainingSlotCount);
|
|
333
|
-
for (const file of rejectedFiles) {
|
|
334
|
-
let rejectionMessage = `Maximum ${maxFiles} files allowed`;
|
|
335
|
-
if (propsRef.current.onFileValidate) {
|
|
336
|
-
const validationMessage = propsRef.current.onFileValidate(file);
|
|
337
|
-
if (validationMessage) {
|
|
338
|
-
rejectionMessage = validationMessage;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
propsRef.current.onFileReject?.(file, rejectionMessage);
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
const acceptedFiles = [];
|
|
346
|
-
for (const file of filesToProcess) {
|
|
347
|
-
let rejected = false;
|
|
348
|
-
let rejectionMessage = "";
|
|
349
|
-
if (propsRef.current.onFileValidate) {
|
|
350
|
-
const validationMessage = propsRef.current.onFileValidate(file);
|
|
351
|
-
if (validationMessage) {
|
|
352
|
-
rejectionMessage = validationMessage;
|
|
353
|
-
propsRef.current.onFileReject?.(file, rejectionMessage);
|
|
354
|
-
rejected = true;
|
|
355
|
-
hasInvalid = true;
|
|
356
|
-
continue;
|
|
357
|
-
}
|
|
358
|
-
}
|
|
359
|
-
if (acceptTypes) {
|
|
360
|
-
const fileType = file.type;
|
|
361
|
-
const fileExtension = `.${file.name.split(".").pop()}`;
|
|
362
|
-
if (!acceptTypes.some(
|
|
363
|
-
(type) => type === fileType || type === fileExtension || type.includes("/*") && fileType.startsWith(type.replace("/*", "/"))
|
|
364
|
-
)) {
|
|
365
|
-
rejectionMessage = "File type not accepted";
|
|
366
|
-
propsRef.current.onFileReject?.(file, rejectionMessage);
|
|
367
|
-
rejected = true;
|
|
368
|
-
hasInvalid = true;
|
|
369
|
-
}
|
|
370
|
-
}
|
|
371
|
-
if (maxSize && file.size > maxSize) {
|
|
372
|
-
rejectionMessage = "File too large";
|
|
373
|
-
propsRef.current.onFileReject?.(file, rejectionMessage);
|
|
374
|
-
rejected = true;
|
|
375
|
-
hasInvalid = true;
|
|
376
|
-
}
|
|
377
|
-
if (!rejected) {
|
|
378
|
-
acceptedFiles.push(file);
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
if (hasInvalid) {
|
|
382
|
-
store.dispatch({ type: "SET_INVALID", invalid: true });
|
|
383
|
-
setTimeout(() => {
|
|
384
|
-
store.dispatch({ type: "SET_INVALID", invalid: false });
|
|
385
|
-
}, 2e3);
|
|
386
|
-
}
|
|
387
|
-
if (acceptedFiles.length > 0) {
|
|
388
|
-
store.dispatch({ type: "ADD_FILES", files: acceptedFiles });
|
|
389
|
-
if (isControlled && propsRef.current.onValueChange) {
|
|
390
|
-
const currentFiles = Array.from(store.getState().files.values()).map((f) => f.file);
|
|
391
|
-
propsRef.current.onValueChange([...currentFiles]);
|
|
392
|
-
}
|
|
393
|
-
if (propsRef.current.onAccept) {
|
|
394
|
-
propsRef.current.onAccept(acceptedFiles);
|
|
395
|
-
}
|
|
396
|
-
for (const file of acceptedFiles) {
|
|
397
|
-
propsRef.current.onFileAccept?.(file);
|
|
398
|
-
}
|
|
399
|
-
if (propsRef.current.onUpload) {
|
|
400
|
-
requestAnimationFrame(() => {
|
|
401
|
-
void onFilesUpload(acceptedFiles);
|
|
402
|
-
});
|
|
403
|
-
}
|
|
404
|
-
}
|
|
405
|
-
},
|
|
406
|
-
[store, isControlled, propsRef, onFilesUpload, maxFiles, acceptTypes, maxSize, disabled]
|
|
407
|
-
);
|
|
408
|
-
const onInputChange = React3__namespace.useCallback(
|
|
409
|
-
(event) => {
|
|
410
|
-
const changedFiles = Array.from(event.target.files ?? []);
|
|
411
|
-
onFilesChange(changedFiles);
|
|
412
|
-
event.target.value = "";
|
|
413
|
-
},
|
|
414
|
-
[onFilesChange]
|
|
415
|
-
);
|
|
416
|
-
const contextValue = React3__namespace.useMemo(
|
|
417
|
-
() => ({
|
|
418
|
-
dropzoneId,
|
|
419
|
-
inputId,
|
|
420
|
-
listId,
|
|
421
|
-
labelId,
|
|
422
|
-
dir,
|
|
423
|
-
disabled,
|
|
424
|
-
inputRef,
|
|
425
|
-
urlCache
|
|
426
|
-
}),
|
|
427
|
-
[dropzoneId, inputId, listId, labelId, dir, disabled, urlCache]
|
|
428
|
-
);
|
|
429
|
-
const RootPrimitive = asChild ? radixUi.Slot.Slot : "div";
|
|
430
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FileUploadStoreContext.Provider, { value: store, children: /* @__PURE__ */ jsxRuntime.jsx(FileUploadContext.Provider, { value: contextValue, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
431
|
-
RootPrimitive,
|
|
432
|
-
{
|
|
433
|
-
"data-disabled": disabled ? "" : void 0,
|
|
434
|
-
"data-slot": "file-upload",
|
|
435
|
-
dir,
|
|
436
|
-
...rootProps,
|
|
437
|
-
className: chunkH2BWO3SI_cjs.cn("relative flex flex-col gap-2", className),
|
|
438
|
-
children: [
|
|
439
|
-
children,
|
|
440
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
441
|
-
"input",
|
|
442
|
-
{
|
|
443
|
-
type: "file",
|
|
444
|
-
id: inputId,
|
|
445
|
-
"aria-labelledby": labelId,
|
|
446
|
-
"aria-describedby": dropzoneId,
|
|
447
|
-
ref: inputRef,
|
|
448
|
-
tabIndex: -1,
|
|
449
|
-
accept,
|
|
450
|
-
name,
|
|
451
|
-
className: "sr-only",
|
|
452
|
-
disabled,
|
|
453
|
-
multiple,
|
|
454
|
-
required,
|
|
455
|
-
onChange: onInputChange
|
|
456
|
-
}
|
|
457
|
-
),
|
|
458
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { id: labelId, className: "sr-only", children: label ?? "File upload" })
|
|
459
|
-
]
|
|
460
|
-
}
|
|
461
|
-
) }) });
|
|
462
|
-
}
|
|
463
|
-
function FileUploadDropzone(props) {
|
|
464
|
-
const {
|
|
465
|
-
asChild,
|
|
466
|
-
className,
|
|
467
|
-
onClick: onClickProp,
|
|
468
|
-
onDragOver: onDragOverProp,
|
|
469
|
-
onDragEnter: onDragEnterProp,
|
|
470
|
-
onDragLeave: onDragLeaveProp,
|
|
471
|
-
onDrop: onDropProp,
|
|
472
|
-
onPaste: onPasteProp,
|
|
473
|
-
onKeyDown: onKeyDownProp,
|
|
474
|
-
...dropzoneProps
|
|
475
|
-
} = props;
|
|
476
|
-
const context = useFileUploadContext(DROPZONE_NAME);
|
|
477
|
-
const store = useFileUploadStoreContext(DROPZONE_NAME);
|
|
478
|
-
const dragOver = useFileUploadStore((state) => state.dragOver);
|
|
479
|
-
const invalid = useFileUploadStore((state) => state.invalid);
|
|
480
|
-
const propsRef = chunkN4TYSZSU_cjs.useAsRef({
|
|
481
|
-
onClick: onClickProp,
|
|
482
|
-
onDragOver: onDragOverProp,
|
|
483
|
-
onDragEnter: onDragEnterProp,
|
|
484
|
-
onDragLeave: onDragLeaveProp,
|
|
485
|
-
onDrop: onDropProp,
|
|
486
|
-
onPaste: onPasteProp,
|
|
487
|
-
onKeyDown: onKeyDownProp
|
|
488
|
-
});
|
|
489
|
-
const onClick = React3__namespace.useCallback(
|
|
490
|
-
(event) => {
|
|
491
|
-
propsRef.current.onClick?.(event);
|
|
492
|
-
if (event.defaultPrevented) return;
|
|
493
|
-
const target = event.target;
|
|
494
|
-
const isFromTrigger = target instanceof HTMLElement && target.closest('[data-slot="file-upload-trigger"]');
|
|
495
|
-
if (!isFromTrigger) {
|
|
496
|
-
context.inputRef.current?.click();
|
|
497
|
-
}
|
|
498
|
-
},
|
|
499
|
-
[context.inputRef, propsRef]
|
|
500
|
-
);
|
|
501
|
-
const onDragOver = React3__namespace.useCallback(
|
|
502
|
-
(event) => {
|
|
503
|
-
propsRef.current.onDragOver?.(event);
|
|
504
|
-
if (event.defaultPrevented) return;
|
|
505
|
-
event.preventDefault();
|
|
506
|
-
store.dispatch({ type: "SET_DRAG_OVER", dragOver: true });
|
|
507
|
-
},
|
|
508
|
-
[store, propsRef]
|
|
509
|
-
);
|
|
510
|
-
const onDragEnter = React3__namespace.useCallback(
|
|
511
|
-
(event) => {
|
|
512
|
-
propsRef.current.onDragEnter?.(event);
|
|
513
|
-
if (event.defaultPrevented) return;
|
|
514
|
-
event.preventDefault();
|
|
515
|
-
store.dispatch({ type: "SET_DRAG_OVER", dragOver: true });
|
|
516
|
-
},
|
|
517
|
-
[store, propsRef]
|
|
518
|
-
);
|
|
519
|
-
const onDragLeave = React3__namespace.useCallback(
|
|
520
|
-
(event) => {
|
|
521
|
-
propsRef.current.onDragLeave?.(event);
|
|
522
|
-
if (event.defaultPrevented) return;
|
|
523
|
-
const relatedTarget = event.relatedTarget;
|
|
524
|
-
if (relatedTarget && relatedTarget instanceof Node && event.currentTarget.contains(relatedTarget)) {
|
|
525
|
-
return;
|
|
526
|
-
}
|
|
527
|
-
event.preventDefault();
|
|
528
|
-
store.dispatch({ type: "SET_DRAG_OVER", dragOver: false });
|
|
529
|
-
},
|
|
530
|
-
[store, propsRef]
|
|
531
|
-
);
|
|
532
|
-
const onDrop = React3__namespace.useCallback(
|
|
533
|
-
(event) => {
|
|
534
|
-
propsRef.current.onDrop?.(event);
|
|
535
|
-
if (event.defaultPrevented) return;
|
|
536
|
-
event.preventDefault();
|
|
537
|
-
store.dispatch({ type: "SET_DRAG_OVER", dragOver: false });
|
|
538
|
-
const droppedFiles = Array.from(event.dataTransfer.files);
|
|
539
|
-
const inputElement = context.inputRef.current;
|
|
540
|
-
if (!inputElement) return;
|
|
541
|
-
const dataTransfer = new DataTransfer();
|
|
542
|
-
for (const file of droppedFiles) {
|
|
543
|
-
dataTransfer.items.add(file);
|
|
544
|
-
}
|
|
545
|
-
inputElement.files = dataTransfer.files;
|
|
546
|
-
inputElement.dispatchEvent(new Event("change", { bubbles: true }));
|
|
547
|
-
},
|
|
548
|
-
[store, context.inputRef, propsRef]
|
|
549
|
-
);
|
|
550
|
-
const onPaste = React3__namespace.useCallback(
|
|
551
|
-
(event) => {
|
|
552
|
-
propsRef.current.onPaste?.(event);
|
|
553
|
-
if (event.defaultPrevented) return;
|
|
554
|
-
event.preventDefault();
|
|
555
|
-
store.dispatch({ type: "SET_DRAG_OVER", dragOver: false });
|
|
556
|
-
const items = event.clipboardData?.items;
|
|
557
|
-
if (!items) return;
|
|
558
|
-
const pastedFiles = [];
|
|
559
|
-
for (let i = 0; i < items.length; i++) {
|
|
560
|
-
const item = items[i];
|
|
561
|
-
if (item?.kind === "file") {
|
|
562
|
-
const file = item.getAsFile();
|
|
563
|
-
if (file) {
|
|
564
|
-
pastedFiles.push(file);
|
|
565
|
-
}
|
|
566
|
-
}
|
|
567
|
-
}
|
|
568
|
-
if (pastedFiles.length === 0) return;
|
|
569
|
-
const inputElement = context.inputRef.current;
|
|
570
|
-
if (!inputElement) return;
|
|
571
|
-
const dataTransfer = new DataTransfer();
|
|
572
|
-
for (const file of pastedFiles) {
|
|
573
|
-
dataTransfer.items.add(file);
|
|
574
|
-
}
|
|
575
|
-
inputElement.files = dataTransfer.files;
|
|
576
|
-
inputElement.dispatchEvent(new Event("change", { bubbles: true }));
|
|
577
|
-
},
|
|
578
|
-
[store, context.inputRef, propsRef]
|
|
579
|
-
);
|
|
580
|
-
const onKeyDown = React3__namespace.useCallback(
|
|
581
|
-
(event) => {
|
|
582
|
-
propsRef.current.onKeyDown?.(event);
|
|
583
|
-
if (!event.defaultPrevented && (event.key === "Enter" || event.key === " ")) {
|
|
584
|
-
event.preventDefault();
|
|
585
|
-
context.inputRef.current?.click();
|
|
586
|
-
}
|
|
587
|
-
},
|
|
588
|
-
[context.inputRef, propsRef]
|
|
589
|
-
);
|
|
590
|
-
const DropzonePrimitive = asChild ? radixUi.Slot.Slot : "div";
|
|
591
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
592
|
-
DropzonePrimitive,
|
|
593
|
-
{
|
|
594
|
-
role: "region",
|
|
595
|
-
id: context.dropzoneId,
|
|
596
|
-
"aria-controls": `${context.inputId} ${context.listId}`,
|
|
597
|
-
"aria-disabled": context.disabled,
|
|
598
|
-
"aria-invalid": invalid,
|
|
599
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
600
|
-
"data-dragging": dragOver ? "" : void 0,
|
|
601
|
-
"data-invalid": invalid ? "" : void 0,
|
|
602
|
-
"data-slot": "file-upload-dropzone",
|
|
603
|
-
dir: context.dir,
|
|
604
|
-
tabIndex: context.disabled ? void 0 : 0,
|
|
605
|
-
...dropzoneProps,
|
|
606
|
-
className: chunkH2BWO3SI_cjs.cn(
|
|
607
|
-
"hover:bg-accent/30 focus-visible:border-ring/50 data-dragging:border-primary/30 data-invalid:border-error data-dragging:bg-accent/30 data-invalid:ring-error/20 relative flex flex-col items-center justify-center gap-2 rounded border-2 border-dashed p-6 transition-colors outline-none select-none data-disabled:pointer-events-none",
|
|
608
|
-
className
|
|
609
|
-
),
|
|
610
|
-
onClick,
|
|
611
|
-
onDragEnter,
|
|
612
|
-
onDragLeave,
|
|
613
|
-
onDragOver,
|
|
614
|
-
onDrop,
|
|
615
|
-
onKeyDown,
|
|
616
|
-
onPaste
|
|
617
|
-
}
|
|
618
|
-
);
|
|
619
|
-
}
|
|
620
|
-
function FileUploadTrigger(props) {
|
|
621
|
-
const { asChild, onClick: onClickProp, ...triggerProps } = props;
|
|
622
|
-
const context = useFileUploadContext(TRIGGER_NAME);
|
|
623
|
-
const propsRef = chunkN4TYSZSU_cjs.useAsRef({
|
|
624
|
-
onClick: onClickProp
|
|
625
|
-
});
|
|
626
|
-
const onClick = React3__namespace.useCallback(
|
|
627
|
-
(event) => {
|
|
628
|
-
propsRef.current.onClick?.(event);
|
|
629
|
-
if (event.defaultPrevented) return;
|
|
630
|
-
context.inputRef.current?.click();
|
|
631
|
-
},
|
|
632
|
-
[context.inputRef, propsRef]
|
|
633
|
-
);
|
|
634
|
-
const TriggerPrimitive = asChild ? radixUi.Slot.Slot : "button";
|
|
635
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
636
|
-
TriggerPrimitive,
|
|
637
|
-
{
|
|
638
|
-
type: "button",
|
|
639
|
-
"aria-controls": context.inputId,
|
|
640
|
-
"data-disabled": context.disabled ? "" : void 0,
|
|
641
|
-
"data-slot": "file-upload-trigger",
|
|
642
|
-
...triggerProps,
|
|
643
|
-
disabled: context.disabled,
|
|
644
|
-
onClick
|
|
645
|
-
}
|
|
646
|
-
);
|
|
647
|
-
}
|
|
648
|
-
var fileUploadListVariants = classVarianceAuthority.cva(
|
|
649
|
-
"data-[state=inactive]:fade-out-0 data-[state=active]:fade-in-0 data-[state=inactive]:slide-out-to-top-2 data-[state=active]:slide-in-from-top-2 data-[state=active]:animate-in data-[state=inactive]:animate-out flex flex-col gap-2",
|
|
650
|
-
{
|
|
651
|
-
variants: {
|
|
652
|
-
orientation: {
|
|
653
|
-
vertical: "",
|
|
654
|
-
horizontal: "flex-row overflow-x-auto p-1.5"
|
|
655
|
-
}
|
|
656
|
-
},
|
|
657
|
-
defaultVariants: {
|
|
658
|
-
orientation: "vertical"
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
);
|
|
662
|
-
function FileUploadList(props) {
|
|
663
|
-
const { className, orientation = "vertical", asChild, forceMount, ...listProps } = props;
|
|
664
|
-
const context = useFileUploadContext(LIST_NAME);
|
|
665
|
-
const fileCount = useFileUploadStore((state) => state.files.size);
|
|
666
|
-
const shouldRender = forceMount || fileCount > 0;
|
|
667
|
-
if (!shouldRender) return null;
|
|
668
|
-
const ListPrimitive = asChild ? radixUi.Slot.Slot : "div";
|
|
669
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
670
|
-
ListPrimitive,
|
|
671
|
-
{
|
|
672
|
-
role: "list",
|
|
673
|
-
id: context.listId,
|
|
674
|
-
"aria-orientation": orientation,
|
|
675
|
-
"data-orientation": orientation,
|
|
676
|
-
"data-slot": "file-upload-list",
|
|
677
|
-
"data-state": shouldRender ? "active" : "inactive",
|
|
678
|
-
dir: context.dir,
|
|
679
|
-
...listProps,
|
|
680
|
-
className: chunkH2BWO3SI_cjs.cn(fileUploadListVariants({ orientation }), className)
|
|
681
|
-
}
|
|
682
|
-
);
|
|
683
|
-
}
|
|
684
|
-
var FileUploadItemContext = React3__namespace.createContext(null);
|
|
685
|
-
function useFileUploadItemContext(consumerName) {
|
|
686
|
-
const context = React3__namespace.useContext(FileUploadItemContext);
|
|
687
|
-
if (!context) {
|
|
688
|
-
throw new Error(`\`${consumerName}\` must be used within \`${ITEM_NAME}\``);
|
|
689
|
-
}
|
|
690
|
-
return context;
|
|
691
|
-
}
|
|
692
|
-
function FileUploadItem(props) {
|
|
693
|
-
const { value, asChild, className, ...itemProps } = props;
|
|
694
|
-
const id = React3__namespace.useId();
|
|
695
|
-
const statusId = `${id}-status`;
|
|
696
|
-
const nameId = `${id}-name`;
|
|
697
|
-
const sizeId = `${id}-size`;
|
|
698
|
-
const messageId = `${id}-message`;
|
|
699
|
-
const context = useFileUploadContext(ITEM_NAME);
|
|
700
|
-
const fileState = useFileUploadStore((state) => state.files.get(value));
|
|
701
|
-
const fileCount = useFileUploadStore((state) => state.files.size);
|
|
702
|
-
const fileIndex = useFileUploadStore((state) => {
|
|
703
|
-
const keys = Array.from(state.files.keys());
|
|
704
|
-
return keys.indexOf(value) + 1;
|
|
705
|
-
});
|
|
706
|
-
const itemContext = React3__namespace.useMemo(
|
|
707
|
-
() => ({
|
|
708
|
-
id,
|
|
709
|
-
fileState,
|
|
710
|
-
nameId,
|
|
711
|
-
sizeId,
|
|
712
|
-
statusId,
|
|
713
|
-
messageId
|
|
714
|
-
}),
|
|
715
|
-
[id, fileState, statusId, nameId, sizeId, messageId]
|
|
716
|
-
);
|
|
717
|
-
if (!fileState) return null;
|
|
718
|
-
const statusText = fileState.error ? `Error: ${fileState.error}` : fileState.status === "uploading" ? `Uploading: ${fileState.progress}% complete` : fileState.status === "success" ? "Upload complete" : "Ready to upload";
|
|
719
|
-
const ItemPrimitive = asChild ? radixUi.Slot.Slot : "div";
|
|
720
|
-
return /* @__PURE__ */ jsxRuntime.jsx(FileUploadItemContext.Provider, { value: itemContext, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
721
|
-
ItemPrimitive,
|
|
722
|
-
{
|
|
723
|
-
role: "listitem",
|
|
724
|
-
id,
|
|
725
|
-
"aria-setsize": fileCount,
|
|
726
|
-
"aria-posinset": fileIndex,
|
|
727
|
-
"aria-describedby": `${nameId} ${sizeId} ${statusId} ${fileState.error ? messageId : ""}`,
|
|
728
|
-
"aria-labelledby": nameId,
|
|
729
|
-
"data-slot": "file-upload-item",
|
|
730
|
-
dir: context.dir,
|
|
731
|
-
...itemProps,
|
|
732
|
-
className: chunkH2BWO3SI_cjs.cn("relative flex items-center gap-2.5 rounded border p-3", className),
|
|
733
|
-
children: [
|
|
734
|
-
props.children,
|
|
735
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { id: statusId, className: "sr-only", children: statusText })
|
|
736
|
-
]
|
|
737
|
-
}
|
|
738
|
-
) });
|
|
739
|
-
}
|
|
740
|
-
function formatBytes(bytes) {
|
|
741
|
-
if (bytes === 0) return "0 B";
|
|
742
|
-
const sizes = ["B", "KB", "MB", "GB", "TB"];
|
|
743
|
-
const i = Math.floor(Math.log(bytes) / Math.log(1024));
|
|
744
|
-
return `${(bytes / 1024 ** i).toFixed(i ? 1 : 0)} ${sizes[i]}`;
|
|
745
|
-
}
|
|
746
|
-
function getFileIcon(file) {
|
|
747
|
-
const type = file.type;
|
|
748
|
-
const extension = file.name.split(".").pop()?.toLowerCase() ?? "";
|
|
749
|
-
if (type.startsWith("video/")) {
|
|
750
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileVideoIcon, {});
|
|
751
|
-
}
|
|
752
|
-
if (type.startsWith("audio/")) {
|
|
753
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileAudioIcon, {});
|
|
754
|
-
}
|
|
755
|
-
if (type.startsWith("text/") || ["txt", "md", "rtf", "pdf"].includes(extension)) {
|
|
756
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileTextIcon, {});
|
|
757
|
-
}
|
|
758
|
-
if (["html", "css", "js", "jsx", "ts", "tsx", "json", "xml", "php", "py", "rb", "java", "c", "cpp", "cs"].includes(
|
|
759
|
-
extension
|
|
760
|
-
)) {
|
|
761
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileCodeIcon, {});
|
|
762
|
-
}
|
|
763
|
-
if (["zip", "rar", "7z", "tar", "gz", "bz2"].includes(extension)) {
|
|
764
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileArchiveIcon, {});
|
|
765
|
-
}
|
|
766
|
-
if (["exe", "msi", "app", "apk", "deb", "rpm"].includes(extension) || type.startsWith("application/")) {
|
|
767
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileCogIcon, {});
|
|
768
|
-
}
|
|
769
|
-
return /* @__PURE__ */ jsxRuntime.jsx(lucideReact.FileIcon, {});
|
|
770
|
-
}
|
|
771
|
-
function FileUploadItemPreview(props) {
|
|
772
|
-
const { render, asChild, children, className, ...previewProps } = props;
|
|
773
|
-
const itemContext = useFileUploadItemContext(ITEM_PREVIEW_NAME);
|
|
774
|
-
const context = useFileUploadContext(ITEM_PREVIEW_NAME);
|
|
775
|
-
const getDefaultRender = React3__namespace.useCallback(
|
|
776
|
-
(file) => {
|
|
777
|
-
if (itemContext.fileState?.file.type.startsWith("image/")) {
|
|
778
|
-
let url = context.urlCache.get(file);
|
|
779
|
-
if (!url) {
|
|
780
|
-
url = URL.createObjectURL(file);
|
|
781
|
-
context.urlCache.set(file, url);
|
|
782
|
-
}
|
|
783
|
-
return (
|
|
784
|
-
// biome-ignore lint/performance/noImgElement: dynamic file URLs from user uploads don't work well with Next.js Image optimization
|
|
785
|
-
/* @__PURE__ */ jsxRuntime.jsx("img", { src: url, alt: file.name, className: "size-full object-cover" })
|
|
786
|
-
);
|
|
787
|
-
}
|
|
788
|
-
return getFileIcon(file);
|
|
789
|
-
},
|
|
790
|
-
[itemContext.fileState?.file.type, context.urlCache]
|
|
791
|
-
);
|
|
792
|
-
const onPreviewRender = React3__namespace.useCallback(
|
|
793
|
-
(file) => {
|
|
794
|
-
if (render) {
|
|
795
|
-
return render(file, () => getDefaultRender(file));
|
|
796
|
-
}
|
|
797
|
-
return getDefaultRender(file);
|
|
798
|
-
},
|
|
799
|
-
[render, getDefaultRender]
|
|
800
|
-
);
|
|
801
|
-
if (!itemContext.fileState) return null;
|
|
802
|
-
const ItemPreviewPrimitive = asChild ? radixUi.Slot.Slot : "div";
|
|
803
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
804
|
-
ItemPreviewPrimitive,
|
|
805
|
-
{
|
|
806
|
-
"aria-labelledby": itemContext.nameId,
|
|
807
|
-
"data-slot": "file-upload-preview",
|
|
808
|
-
...previewProps,
|
|
809
|
-
className: chunkH2BWO3SI_cjs.cn(
|
|
810
|
-
"bg-accent/50 relative flex size-10 shrink-0 items-center justify-center overflow-hidden rounded border [&>svg]:size-10",
|
|
811
|
-
className
|
|
812
|
-
),
|
|
813
|
-
children: [
|
|
814
|
-
onPreviewRender(itemContext.fileState.file),
|
|
815
|
-
children
|
|
816
|
-
]
|
|
817
|
-
}
|
|
818
|
-
);
|
|
819
|
-
}
|
|
820
|
-
function FileUploadItemMetadata(props) {
|
|
821
|
-
const { asChild, size = "default", children, className, ...metadataProps } = props;
|
|
822
|
-
const context = useFileUploadContext(ITEM_METADATA_NAME);
|
|
823
|
-
const itemContext = useFileUploadItemContext(ITEM_METADATA_NAME);
|
|
824
|
-
if (!itemContext.fileState) return null;
|
|
825
|
-
const ItemMetadataPrimitive = asChild ? radixUi.Slot.Slot : "div";
|
|
826
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
827
|
-
ItemMetadataPrimitive,
|
|
828
|
-
{
|
|
829
|
-
"data-slot": "file-upload-metadata",
|
|
830
|
-
dir: context.dir,
|
|
831
|
-
...metadataProps,
|
|
832
|
-
className: chunkH2BWO3SI_cjs.cn("flex min-w-0 flex-1 flex-col", className),
|
|
833
|
-
children: children ?? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
834
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
835
|
-
"span",
|
|
836
|
-
{
|
|
837
|
-
id: itemContext.nameId,
|
|
838
|
-
className: chunkH2BWO3SI_cjs.cn("truncate text-sm font-medium", size === "sm" && "text-[13px] leading-snug font-normal"),
|
|
839
|
-
children: itemContext.fileState.file.name
|
|
840
|
-
}
|
|
841
|
-
),
|
|
842
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
843
|
-
"span",
|
|
844
|
-
{
|
|
845
|
-
id: itemContext.sizeId,
|
|
846
|
-
className: chunkH2BWO3SI_cjs.cn("text-muted-foreground truncate text-xs", size === "sm" && "text-[11px] leading-snug"),
|
|
847
|
-
children: formatBytes(itemContext.fileState.file.size)
|
|
848
|
-
}
|
|
849
|
-
),
|
|
850
|
-
itemContext.fileState.error && /* @__PURE__ */ jsxRuntime.jsx("span", { id: itemContext.messageId, className: "text-destructive text-xs", children: itemContext.fileState.error })
|
|
851
|
-
] })
|
|
852
|
-
}
|
|
853
|
-
);
|
|
854
|
-
}
|
|
855
|
-
function FileUploadItemProgress(props) {
|
|
856
|
-
const { variant = "linear", size = 40, asChild, forceMount, className, ...progressProps } = props;
|
|
857
|
-
const itemContext = useFileUploadItemContext(ITEM_PROGRESS_NAME);
|
|
858
|
-
if (!itemContext.fileState) return null;
|
|
859
|
-
const shouldRender = forceMount || itemContext.fileState.progress !== 100;
|
|
860
|
-
if (!shouldRender) return null;
|
|
861
|
-
const ItemProgressPrimitive = asChild ? radixUi.Slot.Slot : "div";
|
|
862
|
-
switch (variant) {
|
|
863
|
-
case "circular": {
|
|
864
|
-
const circumference = 2 * Math.PI * ((size - 4) / 2);
|
|
865
|
-
const strokeDashoffset = circumference - itemContext.fileState.progress / 100 * circumference;
|
|
866
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
867
|
-
ItemProgressPrimitive,
|
|
868
|
-
{
|
|
869
|
-
role: "progressbar",
|
|
870
|
-
"aria-valuemin": 0,
|
|
871
|
-
"aria-valuemax": 100,
|
|
872
|
-
"aria-valuenow": itemContext.fileState.progress,
|
|
873
|
-
"aria-valuetext": `${itemContext.fileState.progress}%`,
|
|
874
|
-
"aria-labelledby": itemContext.nameId,
|
|
875
|
-
"data-slot": "file-upload-progress",
|
|
876
|
-
...progressProps,
|
|
877
|
-
className: chunkH2BWO3SI_cjs.cn("absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2", className),
|
|
878
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
879
|
-
"svg",
|
|
880
|
-
{
|
|
881
|
-
className: "-rotate-90 transform",
|
|
882
|
-
width: size,
|
|
883
|
-
height: size,
|
|
884
|
-
viewBox: `0 0 ${size} ${size}`,
|
|
885
|
-
fill: "none",
|
|
886
|
-
stroke: "currentColor",
|
|
887
|
-
children: [
|
|
888
|
-
/* @__PURE__ */ jsxRuntime.jsx("circle", { className: "text-primary/20", strokeWidth: "2", cx: size / 2, cy: size / 2, r: (size - 4) / 2 }),
|
|
889
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
890
|
-
"circle",
|
|
891
|
-
{
|
|
892
|
-
className: "text-primary transition-[stroke-dashoffset] duration-300 ease-linear",
|
|
893
|
-
strokeWidth: "2",
|
|
894
|
-
strokeLinecap: "round",
|
|
895
|
-
strokeDasharray: circumference,
|
|
896
|
-
strokeDashoffset,
|
|
897
|
-
cx: size / 2,
|
|
898
|
-
cy: size / 2,
|
|
899
|
-
r: (size - 4) / 2
|
|
900
|
-
}
|
|
901
|
-
)
|
|
902
|
-
]
|
|
903
|
-
}
|
|
904
|
-
)
|
|
905
|
-
}
|
|
906
|
-
);
|
|
907
|
-
}
|
|
908
|
-
case "fill": {
|
|
909
|
-
const progressPercentage = itemContext.fileState.progress;
|
|
910
|
-
const topInset = 100 - progressPercentage;
|
|
911
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
912
|
-
ItemProgressPrimitive,
|
|
913
|
-
{
|
|
914
|
-
role: "progressbar",
|
|
915
|
-
"aria-valuemin": 0,
|
|
916
|
-
"aria-valuemax": 100,
|
|
917
|
-
"aria-valuenow": progressPercentage,
|
|
918
|
-
"aria-valuetext": `${progressPercentage}%`,
|
|
919
|
-
"aria-labelledby": itemContext.nameId,
|
|
920
|
-
"data-slot": "file-upload-progress",
|
|
921
|
-
...progressProps,
|
|
922
|
-
className: chunkH2BWO3SI_cjs.cn("bg-primary/50 absolute inset-0 transition-[clip-path] duration-300 ease-linear", className),
|
|
923
|
-
style: {
|
|
924
|
-
clipPath: `inset(${topInset}% 0% 0% 0%)`
|
|
925
|
-
}
|
|
926
|
-
}
|
|
927
|
-
);
|
|
928
|
-
}
|
|
929
|
-
default:
|
|
930
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
931
|
-
ItemProgressPrimitive,
|
|
932
|
-
{
|
|
933
|
-
role: "progressbar",
|
|
934
|
-
"aria-valuemin": 0,
|
|
935
|
-
"aria-valuemax": 100,
|
|
936
|
-
"aria-valuenow": itemContext.fileState.progress,
|
|
937
|
-
"aria-valuetext": `${itemContext.fileState.progress}%`,
|
|
938
|
-
"aria-labelledby": itemContext.nameId,
|
|
939
|
-
"data-slot": "file-upload-progress",
|
|
940
|
-
...progressProps,
|
|
941
|
-
className: chunkH2BWO3SI_cjs.cn("bg-primary/20 relative h-1.5 w-full overflow-hidden rounded-full", className),
|
|
942
|
-
children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
943
|
-
"div",
|
|
944
|
-
{
|
|
945
|
-
className: "bg-primary h-full w-full flex-1 transition-transform duration-300 ease-linear",
|
|
946
|
-
style: {
|
|
947
|
-
transform: `translateX(-${100 - itemContext.fileState.progress}%)`
|
|
948
|
-
}
|
|
949
|
-
}
|
|
950
|
-
)
|
|
951
|
-
}
|
|
952
|
-
);
|
|
953
|
-
}
|
|
954
|
-
}
|
|
955
|
-
function FileUploadItemDelete(props) {
|
|
956
|
-
const { asChild, onClick: onClickProp, ...deleteProps } = props;
|
|
957
|
-
const store = useFileUploadStoreContext(ITEM_DELETE_NAME);
|
|
958
|
-
const itemContext = useFileUploadItemContext(ITEM_DELETE_NAME);
|
|
959
|
-
const onClick = React3__namespace.useCallback(
|
|
960
|
-
(event) => {
|
|
961
|
-
onClickProp?.(event);
|
|
962
|
-
if (!itemContext.fileState || event.defaultPrevented) return;
|
|
963
|
-
store.dispatch({
|
|
964
|
-
type: "REMOVE_FILE",
|
|
965
|
-
file: itemContext.fileState.file
|
|
966
|
-
});
|
|
967
|
-
},
|
|
968
|
-
[store, itemContext.fileState, onClickProp]
|
|
969
|
-
);
|
|
970
|
-
if (!itemContext.fileState) return null;
|
|
971
|
-
const ItemDeletePrimitive = asChild ? radixUi.Slot.Slot : "button";
|
|
972
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
973
|
-
ItemDeletePrimitive,
|
|
974
|
-
{
|
|
975
|
-
type: "button",
|
|
976
|
-
"aria-controls": itemContext.id,
|
|
977
|
-
"aria-describedby": itemContext.nameId,
|
|
978
|
-
"data-slot": "file-upload-item-delete",
|
|
979
|
-
...deleteProps,
|
|
980
|
-
onClick
|
|
981
|
-
}
|
|
982
|
-
);
|
|
983
|
-
}
|
|
984
|
-
function FileUploadClear(props) {
|
|
985
|
-
const { asChild, forceMount, disabled, onClick: onClickProp, ...clearProps } = props;
|
|
986
|
-
const context = useFileUploadContext(CLEAR_NAME);
|
|
987
|
-
const store = useFileUploadStoreContext(CLEAR_NAME);
|
|
988
|
-
const fileCount = useFileUploadStore((state) => state.files.size);
|
|
989
|
-
const isDisabled = disabled || context.disabled;
|
|
990
|
-
const onClick = React3__namespace.useCallback(
|
|
991
|
-
(event) => {
|
|
992
|
-
onClickProp?.(event);
|
|
993
|
-
if (event.defaultPrevented) return;
|
|
994
|
-
store.dispatch({ type: "CLEAR" });
|
|
995
|
-
},
|
|
996
|
-
[store, onClickProp]
|
|
997
|
-
);
|
|
998
|
-
const shouldRender = forceMount || fileCount > 0;
|
|
999
|
-
if (!shouldRender) return null;
|
|
1000
|
-
const ClearPrimitive = asChild ? radixUi.Slot.Slot : "button";
|
|
1001
|
-
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1002
|
-
ClearPrimitive,
|
|
1003
|
-
{
|
|
1004
|
-
type: "button",
|
|
1005
|
-
"aria-controls": context.listId,
|
|
1006
|
-
"data-slot": "file-upload-clear",
|
|
1007
|
-
"data-disabled": isDisabled ? "" : void 0,
|
|
1008
|
-
...clearProps,
|
|
1009
|
-
disabled: isDisabled,
|
|
1010
|
-
onClick
|
|
1011
|
-
}
|
|
1012
|
-
);
|
|
1013
|
-
}
|
|
1014
|
-
|
|
1015
|
-
exports.FileUpload = FileUpload;
|
|
1016
|
-
exports.FileUploadClear = FileUploadClear;
|
|
1017
|
-
exports.FileUploadDropzone = FileUploadDropzone;
|
|
1018
|
-
exports.FileUploadItem = FileUploadItem;
|
|
1019
|
-
exports.FileUploadItemDelete = FileUploadItemDelete;
|
|
1020
|
-
exports.FileUploadItemMetadata = FileUploadItemMetadata;
|
|
1021
|
-
exports.FileUploadItemPreview = FileUploadItemPreview;
|
|
1022
|
-
exports.FileUploadItemProgress = FileUploadItemProgress;
|
|
1023
|
-
exports.FileUploadList = FileUploadList;
|
|
1024
|
-
exports.FileUploadTrigger = FileUploadTrigger;
|
|
1025
|
-
exports.useFileUploadContext = useFileUploadContext;
|
|
1026
|
-
exports.useFileUploadItemContext = useFileUploadItemContext;
|
|
1027
|
-
exports.useFileUploadStore = useFileUploadStore;
|