@uploadista/react 0.0.20-beta.2 → 0.0.20-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. package/dist/components/index.d.mts +3 -3
  2. package/dist/components/index.mjs +1 -1
  3. package/dist/flow-upload-list-D6j8JSP8.mjs +2 -0
  4. package/dist/flow-upload-list-D6j8JSP8.mjs.map +1 -0
  5. package/dist/hooks/index.d.mts +3 -3
  6. package/dist/hooks/index.mjs +1 -1
  7. package/dist/index.d.mts +6 -6
  8. package/dist/index.mjs +1 -1
  9. package/dist/{uploadista-provider-D-N-eL2l.d.mts → uploadista-provider-Cb13AK7Z.d.mts} +515 -318
  10. package/dist/uploadista-provider-Cb13AK7Z.d.mts.map +1 -0
  11. package/dist/use-upload-BvvGROMR.mjs +2 -0
  12. package/dist/use-upload-BvvGROMR.mjs.map +1 -0
  13. package/dist/{use-uploadista-client-m9nF-irM.d.mts → use-uploadista-client-CkzVVmFT.d.mts} +121 -286
  14. package/dist/use-uploadista-client-CkzVVmFT.d.mts.map +1 -0
  15. package/dist/use-uploadista-events-BwUD-2Ck.mjs +2 -0
  16. package/dist/use-uploadista-events-BwUD-2Ck.mjs.map +1 -0
  17. package/dist/{use-upload-metrics-DhzS4lhG.d.mts → use-uploadista-events-CtDXJYrR.d.mts} +169 -371
  18. package/dist/use-uploadista-events-CtDXJYrR.d.mts.map +1 -0
  19. package/package.json +6 -6
  20. package/src/components/flow-primitives.tsx +843 -0
  21. package/src/components/index.tsx +31 -13
  22. package/src/hooks/index.ts +25 -37
  23. package/src/hooks/use-drag-drop.ts +1 -0
  24. package/src/index.ts +90 -81
  25. package/dist/upload-zone-BjWHuP7p.mjs +0 -6
  26. package/dist/upload-zone-BjWHuP7p.mjs.map +0 -1
  27. package/dist/uploadista-provider-D-N-eL2l.d.mts.map +0 -1
  28. package/dist/use-upload-BDHVhQsI.mjs +0 -2
  29. package/dist/use-upload-BDHVhQsI.mjs.map +0 -1
  30. package/dist/use-upload-metrics-Df90wIos.mjs +0 -2
  31. package/dist/use-upload-metrics-Df90wIos.mjs.map +0 -1
  32. package/dist/use-upload-metrics-DhzS4lhG.d.mts.map +0 -1
  33. package/dist/use-uploadista-client-m9nF-irM.d.mts.map +0 -1
  34. package/src/components/flow-input.tsx +0 -299
  35. package/src/components/flow-upload-zone.tsx +0 -441
  36. package/src/hooks/use-flow-execution.ts +0 -502
  37. package/src/hooks/use-flow-upload.ts +0 -299
@@ -1,7 +1,35 @@
1
- // Flow Upload Components
2
- export type { FlowInputProps } from "./flow-input";
3
- export { FlowInput } from "./flow-input";
1
+ // Flow Primitives (NEW compound component)
2
+ export {
3
+ Flow,
4
+ useFlowContext,
5
+ useFlowInputContext,
6
+ } from "./flow-primitives";
7
+ export type {
8
+ FlowCancelProps,
9
+ FlowContextValue,
10
+ FlowDropZoneProps,
11
+ FlowDropZoneRenderProps,
12
+ FlowErrorProps,
13
+ FlowErrorRenderProps,
14
+ FlowInputContextValue,
15
+ FlowInputDropZoneProps,
16
+ FlowInputDropZoneRenderProps,
17
+ FlowInputPreviewProps,
18
+ FlowInputPreviewRenderProps,
19
+ FlowInputProps,
20
+ FlowInputsProps,
21
+ FlowInputsRenderProps,
22
+ FlowInputUrlFieldProps,
23
+ FlowProgressProps,
24
+ FlowProgressRenderProps,
25
+ FlowProps,
26
+ FlowResetProps,
27
+ FlowStatusProps,
28
+ FlowStatusRenderProps,
29
+ FlowSubmitProps,
30
+ } from "./flow-primitives";
4
31
 
32
+ // Flow Upload List (for batch uploads with useMultiFlowUpload)
5
33
  export type {
6
34
  FlowUploadListProps,
7
35
  FlowUploadListRenderProps,
@@ -14,16 +42,6 @@ export {
14
42
  SimpleFlowUploadListItem,
15
43
  } from "./flow-upload-list";
16
44
 
17
- export type {
18
- FlowUploadZoneProps,
19
- FlowUploadZoneRenderProps,
20
- SimpleFlowUploadZoneProps,
21
- } from "./flow-upload-zone";
22
- export {
23
- FlowUploadZone,
24
- SimpleFlowUploadZone,
25
- } from "./flow-upload-zone";
26
-
27
45
  // Upload Components
28
46
  export type {
29
47
  SimpleUploadListItemProps,
@@ -1,51 +1,30 @@
1
1
  // Event Hooks
2
2
  export { isFlowEvent, isUploadEvent } from "./event-utils";
3
- export { useUploadistaEvents } from "./use-uploadista-events";
4
- export type { UseFlowEventsOptions } from "./use-flow-events";
5
- export { useFlowEvents } from "./use-flow-events";
3
+
4
+ // Drag & Drop Hook
6
5
  export type {
7
- UploadFailedEventData,
8
- UploadFileEventData,
9
- UploadProgressEventData,
10
- UploadValidationFailedEventData,
11
- UploadValidationSuccessEventData,
12
- UploadValidationWarningEventData,
13
- UseUploadEventsOptions,
14
- } from "./use-upload-events";
15
- export { useUploadEvents } from "./use-upload-events";
6
+ DragDropOptions,
7
+ DragDropState,
8
+ UseDragDropReturn,
9
+ } from "./use-drag-drop";
10
+ export { useDragDrop } from "./use-drag-drop";
16
11
 
17
- // Flow Upload Hooks
12
+ // Flow Hooks
13
+ // useFlow is the primary hook for flow operations (replaces useFlowUpload)
18
14
  export type {
19
15
  FlowInputMetadata,
16
+ FlowUploadState,
17
+ FlowUploadStatus,
20
18
  InputExecutionState,
21
19
  UseFlowReturn,
22
20
  } from "./use-flow";
23
21
  export { useFlow } from "./use-flow";
24
-
25
- export type {
26
- InputBuilder,
27
- UseFlowExecutionOptions,
28
- UseFlowExecutionReturn,
29
- } from "./use-flow-execution";
30
- export { useFlowExecution } from "./use-flow-execution";
31
-
32
- export type {
33
- FlowUploadState,
34
- FlowUploadStatus,
35
- UseFlowUploadReturn,
36
- } from "./use-flow-upload";
37
- export { useFlowUpload } from "./use-flow-upload";
38
-
39
- // Upload Hooks
40
- export type {
41
- DragDropOptions,
42
- DragDropState,
43
- UseDragDropReturn,
44
- } from "./use-drag-drop";
45
- export { useDragDrop } from "./use-drag-drop";
22
+ export type { UseFlowEventsOptions } from "./use-flow-events";
23
+ export { useFlowEvents } from "./use-flow-events";
46
24
  export type { UseMultiFlowUploadReturn } from "./use-multi-flow-upload";
47
25
  export { useMultiFlowUpload } from "./use-multi-flow-upload";
48
26
 
27
+ // Upload Hooks
49
28
  export type {
50
29
  MultiUploadOptions,
51
30
  MultiUploadState,
@@ -53,7 +32,6 @@ export type {
53
32
  UseMultiUploadReturn,
54
33
  } from "./use-multi-upload";
55
34
  export { useMultiUpload } from "./use-multi-upload";
56
-
57
35
  export type {
58
36
  UploadState,
59
37
  UploadStatus,
@@ -61,7 +39,16 @@ export type {
61
39
  UseUploadReturn,
62
40
  } from "./use-upload";
63
41
  export { useUpload } from "./use-upload";
64
-
42
+ export type {
43
+ UploadFailedEventData,
44
+ UploadFileEventData,
45
+ UploadProgressEventData,
46
+ UploadValidationFailedEventData,
47
+ UploadValidationSuccessEventData,
48
+ UploadValidationWarningEventData,
49
+ UseUploadEventsOptions,
50
+ } from "./use-upload-events";
51
+ export { useUploadEvents } from "./use-upload-events";
65
52
  export type {
66
53
  FileUploadMetrics,
67
54
  UploadMetrics,
@@ -76,3 +63,4 @@ export type {
76
63
  UseUploadistaClientReturn,
77
64
  } from "./use-uploadista-client";
78
65
  export { useUploadistaClient } from "./use-uploadista-client";
66
+ export { useUploadistaEvents } from "./use-uploadista-events";
@@ -89,6 +89,7 @@ export interface UseDragDropReturn {
89
89
  accept?: string;
90
90
  onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
91
91
  style: { display: "none" };
92
+ ref: React.RefObject<HTMLInputElement | null>;
92
93
  };
93
94
 
94
95
  /**
package/src/index.ts CHANGED
@@ -1,8 +1,65 @@
1
- // Event Hooks
2
- export { isFlowEvent, isUploadEvent } from "./hooks/event-utils";
3
- export { useUploadistaEvents } from "./hooks/use-uploadista-events";
1
+ // ============ FLOW PRIMITIVES (NEW) ============
2
+ // Compound component for flow-based uploads
3
+ export {
4
+ Flow,
5
+ useFlowContext,
6
+ useFlowInputContext,
7
+ } from "./components/flow-primitives";
8
+ export type {
9
+ FlowProps,
10
+ FlowContextValue,
11
+ FlowInputContextValue,
12
+ FlowDropZoneProps,
13
+ FlowDropZoneRenderProps,
14
+ FlowInputsProps,
15
+ FlowInputsRenderProps,
16
+ FlowInputProps,
17
+ FlowInputDropZoneProps,
18
+ FlowInputDropZoneRenderProps,
19
+ FlowInputUrlFieldProps,
20
+ FlowInputPreviewProps,
21
+ FlowInputPreviewRenderProps,
22
+ FlowProgressProps,
23
+ FlowProgressRenderProps,
24
+ FlowStatusProps,
25
+ FlowStatusRenderProps,
26
+ FlowErrorProps,
27
+ FlowErrorRenderProps,
28
+ FlowSubmitProps,
29
+ FlowCancelProps,
30
+ FlowResetProps,
31
+ } from "./components/flow-primitives";
32
+
33
+ // ============ FLOW HOOKS ============
34
+ // useFlow is the primary hook for flow operations
35
+ export type {
36
+ FlowInputMetadata,
37
+ InputExecutionState,
38
+ UseFlowReturn,
39
+ FlowUploadState,
40
+ FlowUploadStatus,
41
+ } from "./hooks/use-flow";
42
+ export { useFlow } from "./hooks/use-flow";
4
43
  export type { UseFlowEventsOptions } from "./hooks/use-flow-events";
5
44
  export { useFlowEvents } from "./hooks/use-flow-events";
45
+ export type { UseMultiFlowUploadReturn } from "./hooks/use-multi-flow-upload";
46
+ export { useMultiFlowUpload } from "./hooks/use-multi-flow-upload";
47
+
48
+ // ============ UPLOAD HOOKS ============
49
+ export type {
50
+ MultiUploadOptions,
51
+ MultiUploadState,
52
+ UploadItem,
53
+ UseMultiUploadReturn,
54
+ } from "./hooks/use-multi-upload";
55
+ export { useMultiUpload } from "./hooks/use-multi-upload";
56
+ export type {
57
+ UploadState,
58
+ UploadStatus,
59
+ UseUploadOptions,
60
+ UseUploadReturn,
61
+ } from "./hooks/use-upload";
62
+ export { useUpload } from "./hooks/use-upload";
6
63
  export type {
7
64
  UploadFailedEventData,
8
65
  UploadFileEventData,
@@ -13,57 +70,23 @@ export type {
13
70
  UseUploadEventsOptions,
14
71
  } from "./hooks/use-upload-events";
15
72
  export { useUploadEvents } from "./hooks/use-upload-events";
16
-
17
- // Flow Upload Hooks
18
- export type { FlowInputProps } from "./components/flow-input";
19
- export { FlowInput } from "./components/flow-input";
20
-
21
73
  export type {
22
- FlowUploadListProps,
23
- FlowUploadListRenderProps,
24
- SimpleFlowUploadListItemProps,
25
- SimpleFlowUploadListProps,
26
- } from "./components/flow-upload-list";
27
- export {
28
- FlowUploadList,
29
- SimpleFlowUploadList,
30
- SimpleFlowUploadListItem,
31
- } from "./components/flow-upload-list";
32
- // Flow Upload Components
33
- export type {
34
- FlowUploadZoneProps,
35
- FlowUploadZoneRenderProps,
36
- SimpleFlowUploadZoneProps,
37
- } from "./components/flow-upload-zone";
38
- export {
39
- FlowUploadZone,
40
- SimpleFlowUploadZone,
41
- } from "./components/flow-upload-zone";
42
- export type {
43
- FlowUploadState,
44
- FlowUploadStatus,
45
- UseFlowUploadReturn,
46
- } from "./hooks/use-flow-upload";
47
- export { useFlowUpload } from "./hooks/use-flow-upload";
48
- export type { UseMultiFlowUploadReturn } from "./hooks/use-multi-flow-upload";
49
- export { useMultiFlowUpload } from "./hooks/use-multi-flow-upload";
50
-
51
- // Flow Hooks
52
- export type {
53
- FlowInputMetadata,
54
- InputExecutionState,
55
- UseFlowReturn,
56
- } from "./hooks/use-flow";
57
- export { useFlow } from "./hooks/use-flow";
74
+ FileUploadMetrics,
75
+ UploadMetrics,
76
+ UseUploadMetricsOptions,
77
+ UseUploadMetricsReturn,
78
+ } from "./hooks/use-upload-metrics";
79
+ export { useUploadMetrics } from "./hooks/use-upload-metrics";
58
80
 
81
+ // ============ DRAG & DROP ============
59
82
  export type {
60
- InputBuilder,
61
- UseFlowExecutionOptions,
62
- UseFlowExecutionReturn,
63
- } from "./hooks/use-flow-execution";
64
- export { useFlowExecution } from "./hooks/use-flow-execution";
83
+ DragDropOptions,
84
+ DragDropState,
85
+ UseDragDropReturn,
86
+ } from "./hooks/use-drag-drop";
87
+ export { useDragDrop } from "./hooks/use-drag-drop";
65
88
 
66
- // Upload Hooks
89
+ // ============ UPLOAD COMPONENTS ============
67
90
  export type {
68
91
  SimpleUploadListItemProps,
69
92
  UploadListProps,
@@ -77,48 +100,34 @@ export type {
77
100
  } from "./components/upload-zone";
78
101
  export { SimpleUploadZone, UploadZone } from "./components/upload-zone";
79
102
 
80
- // Components
103
+ // ============ FLOW UPLOAD LIST (for batch uploads) ============
104
+ export type {
105
+ FlowUploadListProps,
106
+ FlowUploadListRenderProps,
107
+ SimpleFlowUploadListItemProps,
108
+ SimpleFlowUploadListProps,
109
+ } from "./components/flow-upload-list";
110
+ export {
111
+ FlowUploadList,
112
+ SimpleFlowUploadList,
113
+ SimpleFlowUploadListItem,
114
+ } from "./components/flow-upload-list";
115
+
116
+ // ============ PROVIDERS & CONTEXTS ============
81
117
  export {
82
118
  UploadistaProvider,
83
119
  useUploadistaContext,
84
120
  } from "./components/uploadista-provider";
85
-
86
- // Contexts
87
121
  export {
88
122
  FlowManagerProvider,
89
123
  useFlowManagerContext,
90
124
  } from "./contexts/flow-manager-context";
91
- export type {
92
- DragDropOptions,
93
- DragDropState,
94
- UseDragDropReturn,
95
- } from "./hooks/use-drag-drop";
96
- export { useDragDrop } from "./hooks/use-drag-drop";
97
125
 
98
- export type {
99
- MultiUploadOptions,
100
- MultiUploadState,
101
- UploadItem,
102
- UseMultiUploadReturn,
103
- } from "./hooks/use-multi-upload";
104
- export { useMultiUpload } from "./hooks/use-multi-upload";
105
- export type {
106
- UploadState,
107
- UploadStatus,
108
- UseUploadOptions,
109
- UseUploadReturn,
110
- } from "./hooks/use-upload";
111
- export { useUpload } from "./hooks/use-upload";
112
- export type {
113
- FileUploadMetrics,
114
- UploadMetrics,
115
- UseUploadMetricsOptions,
116
- UseUploadMetricsReturn,
117
- } from "./hooks/use-upload-metrics";
118
- export { useUploadMetrics } from "./hooks/use-upload-metrics";
119
- // Types - Hooks
126
+ // ============ EVENT UTILITIES ============
127
+ export { isFlowEvent, isUploadEvent } from "./hooks/event-utils";
120
128
  export type {
121
129
  UseUploadistaClientOptions,
122
130
  UseUploadistaClientReturn,
123
131
  } from "./hooks/use-uploadista-client";
124
132
  export { useUploadistaClient } from "./hooks/use-uploadista-client";
133
+ export { useUploadistaEvents } from "./hooks/use-uploadista-events";
@@ -1,6 +0,0 @@
1
- import{a as e,i as t,n,r,t as i}from"./use-upload-BDHVhQsI.mjs";import{useCallback as a}from"react";import{Fragment as o,jsx as s,jsxs as c}from"react/jsx-runtime";function l({input:t,accept:n=`*`,allowUrl:r=!0,value:i,onChange:a,disabled:o=!1,className:l=``}){let u=i instanceof File,d=typeof i==`string`&&i.length>0,f=t.inputTypeId===`streaming-input-v1`,p=r&&(t.inputTypeId===`url-input-v1`||t.inputTypeId===`streaming-input-v1`),m=e({onFilesReceived:e=>{e[0]&&a(e[0])},accept:n?n.split(`,`).map(e=>e.trim()):void 0,multiple:!1}),h=e=>{a(e.target.value)},g=()=>{a(``)};return c(`div`,{className:`space-y-3 ${l}`,children:[c(`div`,{children:[c(`div`,{className:`flex items-center gap-2 mb-1`,children:[s(`h4`,{className:`font-semibold text-gray-900`,children:t.nodeName}),t.required&&s(`span`,{className:`text-red-500 text-sm`,children:`*`}),s(`span`,{className:`text-xs px-2 py-1 rounded-full bg-blue-100 text-blue-700 font-medium`,children:t.inputTypeId})]}),t.nodeDescription&&s(`p`,{className:`text-sm text-gray-600`,children:t.nodeDescription})]}),f&&c(`div`,{role:`button`,tabIndex:o?-1:0,...m.dragHandlers,onClick:()=>!o&&m.openFilePicker(),onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&!o&&(e.preventDefault(),m.openFilePicker())},className:`
2
- relative border-2 border-dashed rounded-xl p-6 text-center cursor-pointer transition-all
3
- ${m.state.isDragging?`border-indigo-500 bg-indigo-50`:`border-gray-300 bg-gray-50 hover:border-indigo-400 hover:bg-indigo-50/50`}
4
- ${o?`opacity-50 cursor-not-allowed`:``}
5
- `,children:[m.state.isDragging?c(`div`,{className:`flex flex-col items-center gap-2`,children:[c(`svg`,{className:`w-8 h-8 text-indigo-600`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:[s(`title`,{children:`Drop file`}),s(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12`})]}),s(`p`,{className:`text-sm font-medium text-indigo-600`,children:`Drop file here`})]}):u?c(`div`,{className:`flex items-center justify-between`,children:[c(`div`,{className:`flex items-center gap-3`,children:[s(`svg`,{className:`w-5 h-5 text-green-500`,fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:s(`path`,{fillRule:`evenodd`,d:`M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z`,clipRule:`evenodd`})}),c(`div`,{className:`text-left`,children:[s(`p`,{className:`text-sm font-medium text-gray-900`,children:i.name}),c(`p`,{className:`text-xs text-gray-500`,children:[(i.size/1024).toFixed(1),` KB`]})]})]}),s(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),g()},className:`px-3 py-1 text-sm text-red-600 hover:text-red-700 hover:bg-red-50 rounded-lg transition-colors`,children:`Remove`})]}):c(`div`,{className:`flex flex-col items-center gap-2`,children:[c(`svg`,{className:`w-8 h-8 text-gray-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:[s(`title`,{children:`Upload file`}),s(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M7 16a4 4 0 01-.88-7.903A5 5 0 1115.9 6L16 6a5 5 0 011 9.9M15 13l-3-3m0 0l-3 3m3-3v12`})]}),c(`div`,{children:[s(`p`,{className:`text-sm font-medium text-gray-700`,children:`Drag and drop a file here, or click to select`}),c(`p`,{className:`text-xs text-gray-500 mt-1`,children:[`Accepted: `,n]})]})]}),s(`input`,{...m.inputProps})]}),m.state.errors.length>0&&s(`div`,{className:`bg-red-50 border border-red-200 rounded-lg p-3`,children:m.state.errors.map((e,t)=>s(`p`,{className:`text-sm text-red-700`,children:e},t))}),p&&f&&c(`div`,{className:`flex items-center gap-3`,children:[s(`div`,{className:`flex-1 border-t border-gray-300`}),s(`span`,{className:`text-xs font-medium text-gray-500 uppercase`,children:`Or`}),s(`div`,{className:`flex-1 border-t border-gray-300`})]}),p&&c(`div`,{className:`space-y-2`,children:[!f&&s(`label`,{htmlFor:`url-${t.nodeId}`,className:`block text-sm font-medium text-gray-700`,children:`URL`}),c(`div`,{className:`relative`,children:[s(`input`,{id:`url-${t.nodeId}`,type:`url`,value:d?i:``,onChange:h,disabled:o,placeholder:`https://example.com/file.jpg`,className:`block w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-indigo-500 focus:border-indigo-500 disabled:opacity-50 disabled:cursor-not-allowed text-sm`}),d&&s(`button`,{type:`button`,onClick:g,disabled:o,className:`absolute right-2 top-1/2 -translate-y-1/2 p-1 text-gray-400 hover:text-gray-600 rounded-lg hover:bg-gray-100 transition-colors`,"aria-label":`Clear URL`,children:c(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,children:[s(`title`,{children:`Clear`}),s(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,strokeWidth:2,d:`M6 18L18 6M6 6l12 12`})]})})]}),d&&c(`div`,{className:`flex items-center gap-2 text-xs text-gray-600`,children:[s(`svg`,{className:`w-4 h-4 text-blue-500`,fill:`currentColor`,viewBox:`0 0 20 20`,"aria-hidden":`true`,children:s(`path`,{fillRule:`evenodd`,d:`M12.586 4.586a2 2 0 112.828 2.828l-3 3a2 2 0 01-2.828 0 1 1 0 00-1.414 1.414 4 4 0 005.656 0l3-3a4 4 0 00-5.656-5.656l-1.5 1.5a1 1 0 101.414 1.414l1.5-1.5zm-5 5a2 2 0 012.828 0 1 1 0 101.414-1.414 4 4 0 00-5.656 0l-3 3a4 4 0 105.656 5.656l1.5-1.5a1 1 0 10-1.414-1.414l-1.5 1.5a2 2 0 11-2.828-2.828l3-3z`,clipRule:`evenodd`})}),s(`span`,{className:`truncate`,children:i})]})]})]})}function u({flowConfig:e,options:n,children:r}){let i=t({...n,flowConfig:e});return s(o,{children:r({items:i.state.items,totalProgress:i.state.totalProgress,activeUploads:i.state.activeUploads,completedUploads:i.state.completedUploads,failedUploads:i.state.failedUploads,isUploading:i.isUploading,addFiles:i.addFiles,removeFile:i.removeFile,startUpload:i.startUpload,abortUpload:i.abortUpload,abortAll:i.abortAll,clear:i.clear,retryUpload:i.retryUpload})})}function d({item:e,onAbort:t,onRetry:n,onRemove:r}){return c(`div`,{style:{display:`flex`,alignItems:`center`,gap:`12px`,padding:`8px`,borderBottom:`1px solid #eee`},children:[s(`span`,{style:{color:(()=>{switch(e.status){case`success`:return`green`;case`error`:return`red`;case`uploading`:return`blue`;case`aborted`:return`gray`;default:return`black`}})(),fontSize:`18px`},children:(()=>{switch(e.status){case`success`:return`✓`;case`error`:return`✗`;case`uploading`:return`⟳`;case`aborted`:return`⊘`;default:return`○`}})()}),c(`div`,{style:{flex:1,minWidth:0},children:[s(`div`,{style:{fontSize:`14px`,fontWeight:500,overflow:`hidden`,textOverflow:`ellipsis`,whiteSpace:`nowrap`},children:e.file instanceof File?e.file.name:`Upload`}),e.status===`uploading`&&c(`div`,{style:{marginTop:`4px`},children:[s(`progress`,{value:e.progress,max:100,style:{width:`100%`,height:`4px`}}),c(`div`,{style:{fontSize:`12px`,color:`#666`,marginTop:`2px`},children:[e.progress,`% • `,Math.round(e.bytesUploaded/1024),` KB /`,` `,Math.round(e.totalBytes/1024),` KB`]})]}),e.status===`error`&&s(`div`,{style:{fontSize:`12px`,color:`red`,marginTop:`2px`},children:e.error?.message||`Upload failed`}),e.status===`success`&&s(`div`,{style:{fontSize:`12px`,color:`green`,marginTop:`2px`},children:`Upload complete`})]}),c(`div`,{style:{display:`flex`,gap:`8px`},children:[e.status===`uploading`&&s(`button`,{type:`button`,onClick:t,style:{padding:`4px 8px`,fontSize:`12px`,borderRadius:`4px`,border:`1px solid #ccc`,backgroundColor:`#fff`,cursor:`pointer`},children:`Cancel`}),e.status===`error`&&s(`button`,{type:`button`,onClick:n,style:{padding:`4px 8px`,fontSize:`12px`,borderRadius:`4px`,border:`1px solid #ccc`,backgroundColor:`#fff`,cursor:`pointer`},children:`Retry`}),(e.status===`pending`||e.status===`error`||e.status===`aborted`)&&s(`button`,{type:`button`,onClick:r,style:{padding:`4px 8px`,fontSize:`12px`,borderRadius:`4px`,border:`1px solid #ccc`,backgroundColor:`#fff`,cursor:`pointer`},children:`Remove`})]})]})}function f({flowConfig:e,options:t,className:n=``,showFileInput:r=!0,accept:i}){return s(u,{flowConfig:e,options:t,children:({items:e,addFiles:t,startUpload:a,abortUpload:o,retryUpload:l,removeFile:u,totalProgress:f})=>c(`div`,{className:n,children:[r&&s(`div`,{style:{marginBottom:`16px`},children:s(`input`,{type:`file`,multiple:!0,accept:i,onChange:e=>{e.target.files&&(t(e.target.files),a())},style:{padding:`8px`,border:`1px solid #ccc`,borderRadius:`4px`}})}),e.length>0&&c(`div`,{children:[c(`div`,{style:{marginBottom:`8px`,fontSize:`14px`,color:`#666`},children:[`Total Progress: `,f,`%`]}),s(`div`,{style:{border:`1px solid #eee`,borderRadius:`8px`,overflow:`hidden`},children:e.map(e=>s(d,{item:e,onAbort:()=>o(e.id),onRetry:()=>l(e.id),onRemove:()=>u(e.id)},e.id))})]})]})})}function p({flowConfig:t,options:n,accept:i,multiple:a=!1,children:c}){let l=r({...n,flowConfig:t}),u=e({onFilesReceived:e=>{let t=e[0];t&&l.upload(t)},accept:i?[i]:void 0,multiple:a}),d=e=>{let t=e.target.files?.[0];t&&l.upload(t)};return s(o,{children:c({flowUpload:l,dragDrop:u,isActive:u.state.isDragging||u.state.isOver,openFilePicker:u.openFilePicker,getRootProps:()=>u.dragHandlers,getInputProps:()=>({...u.inputProps,onChange:d})})})}function m({flowConfig:e,options:t,accept:n,className:r=``,dragText:i=`Drop files here`,idleText:a=`Drag & drop files or click to browse`}){return s(p,{flowConfig:e,options:t,accept:n,children:({dragDrop:e,flowUpload:t,getRootProps:n,getInputProps:o,openFilePicker:l})=>c(`div`,{...n(),className:r,style:{border:`2px dashed #ccc`,borderRadius:`8px`,padding:`32px`,textAlign:`center`,cursor:`pointer`,backgroundColor:e.state.isDragging?`#f0f0f0`:`transparent`,transition:`background-color 0.2s`},children:[s(`input`,{...o()}),e.state.isDragging&&s(`p`,{style:{margin:0},children:i}),!e.state.isDragging&&!t.isUploading&&t.state.status===`idle`&&c(`div`,{children:[s(`p`,{style:{margin:`0 0 16px 0`},children:a}),s(`button`,{type:`button`,onClick:e=>{e.stopPropagation(),l()},style:{padding:`8px 16px`,borderRadius:`4px`,border:`1px solid #ccc`,backgroundColor:`#fff`,cursor:`pointer`},children:`Choose Files`})]}),t.isUploading&&c(`div`,{children:[s(`progress`,{value:t.state.progress,max:100,style:{width:`100%`,height:`8px`}}),c(`p`,{style:{margin:`8px 0 0 0`},children:[t.state.progress,`%`]}),s(`button`,{type:`button`,onClick:e=>{e.stopPropagation()},style:{marginTop:`8px`,padding:`4px 12px`,borderRadius:`4px`,border:`1px solid #ccc`,backgroundColor:`#fff`,cursor:`pointer`},children:`Cancel`})]}),t.state.status===`success`&&s(`div`,{children:s(`p`,{style:{margin:0,color:`green`},children:`✓ Upload complete!`})}),t.state.status===`error`&&s(`div`,{children:c(`p`,{style:{margin:0,color:`red`},children:[`✗ Error: `,t.state.error?.message]})})]})})}function h({multiUpload:e,filter:t,sortBy:n,children:r}){let i=e.items;t&&(i=i.filter(t)),n&&(i=[...i].sort(n));let a={idle:i.filter(e=>e.state.status===`idle`),uploading:i.filter(e=>e.state.status===`uploading`),success:i.filter(e=>e.state.status===`success`),error:i.filter(e=>e.state.status===`error`),aborted:i.filter(e=>e.state.status===`aborted`)};return s(o,{children:r({items:i,itemsByStatus:a,multiUpload:e,actions:{removeItem:t=>{e.removeItem(t)},retryItem:t=>{e.retryFailed()},abortItem:t=>{e.removeItem(t.id)},startItem:t=>{e.startAll()}}})})}function g({item:e,actions:t,className:n=``,style:r={},showDetails:i=!0}){let a=e=>{switch(e){case`idle`:return`#6c757d`;case`uploading`:return`#007bff`;case`success`:return`#28a745`;case`error`:return`#dc3545`;case`aborted`:return`#6c757d`;default:return`#6c757d`}},l=e=>{switch(e){case`idle`:return`⏳`;case`uploading`:return`📤`;case`success`:return`✅`;case`error`:return`❌`;case`aborted`:return`⏹️`;default:return`❓`}},u=e=>{if(e===0)return`0 Bytes`;let t=1024,n=[`Bytes`,`KB`,`MB`,`GB`],r=Math.floor(Math.log(e)/Math.log(t));return`${parseFloat((e/t**r).toFixed(2))} ${n[r]}`};return c(`div`,{className:`upload-list-item upload-list-item--${e.state.status} ${n}`,style:{padding:`12px`,border:`1px solid #e0e0e0`,borderRadius:`6px`,marginBottom:`8px`,backgroundColor:`#fff`,transition:`all 0.2s ease`,...r},children:[c(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`8px`},children:[c(`div`,{style:{display:`flex`,alignItems:`center`,gap:`8px`,flex:1},children:[s(`span`,{style:{fontSize:`16px`},children:l(e.state.status)}),s(`span`,{style:{fontWeight:`500`,flex:1},children:e.file instanceof File?e.file.name:`File`})]}),s(`span`,{style:{fontSize:`12px`,color:a(e.state.status),fontWeight:`500`,textTransform:`uppercase`},children:e.state.status})]}),e.state.status===`uploading`&&c(`div`,{style:{marginBottom:`8px`},children:[c(`div`,{style:{display:`flex`,justifyContent:`space-between`,alignItems:`center`,marginBottom:`4px`},children:[c(`span`,{style:{fontSize:`12px`,color:`#666`},children:[e.state.progress,`%`]}),i&&e.state.totalBytes&&c(`span`,{style:{fontSize:`12px`,color:`#666`},children:[u(e.state.bytesUploaded),` /`,` `,u(e.state.totalBytes)]})]}),s(`div`,{style:{width:`100%`,height:`6px`,backgroundColor:`#e0e0e0`,borderRadius:`3px`,overflow:`hidden`},children:s(`div`,{style:{width:`${e.state.progress}%`,height:`100%`,backgroundColor:`#007bff`,transition:`width 0.2s ease`}})})]}),i&&c(`div`,{style:{fontSize:`12px`,color:`#666`,marginBottom:`8px`},children:[e.state.totalBytes&&s(`span`,{children:u(e.state.totalBytes)}),e.state.status===`uploading`&&e.state.progress>0&&c(`span`,{children:[` • Progress: `,e.state.progress,`%`]}),e.state.status===`error`&&e.state.error&&s(`div`,{style:{color:`#dc3545`,marginTop:`4px`},children:e.state.error.message})]}),c(`div`,{style:{display:`flex`,gap:`8px`,flexWrap:`wrap`},children:[e.state.status===`idle`&&c(o,{children:[s(`button`,{type:`button`,onClick:()=>t.startItem(e),style:{padding:`4px 8px`,fontSize:`12px`,border:`1px solid #007bff`,backgroundColor:`#007bff`,color:`white`,borderRadius:`4px`,cursor:`pointer`},children:`Start`}),s(`button`,{type:`button`,onClick:()=>t.removeItem(e.id),style:{padding:`4px 8px`,fontSize:`12px`,border:`1px solid #6c757d`,backgroundColor:`transparent`,color:`#6c757d`,borderRadius:`4px`,cursor:`pointer`},children:`Remove`})]}),e.state.status===`uploading`&&s(`button`,{type:`button`,onClick:()=>t.abortItem(e),style:{padding:`4px 8px`,fontSize:`12px`,border:`1px solid #dc3545`,backgroundColor:`transparent`,color:`#dc3545`,borderRadius:`4px`,cursor:`pointer`},children:`Cancel`}),e.state.status===`error`&&c(o,{children:[s(`button`,{type:`button`,onClick:()=>t.retryItem(e),style:{padding:`4px 8px`,fontSize:`12px`,border:`1px solid #28a745`,backgroundColor:`#28a745`,color:`white`,borderRadius:`4px`,cursor:`pointer`},children:`Retry`}),s(`button`,{type:`button`,onClick:()=>t.removeItem(e.id),style:{padding:`4px 8px`,fontSize:`12px`,border:`1px solid #6c757d`,backgroundColor:`transparent`,color:`#6c757d`,borderRadius:`4px`,cursor:`pointer`},children:`Remove`})]}),e.state.status===`success`&&s(`button`,{type:`button`,onClick:()=>t.removeItem(e.id),style:{padding:`4px 8px`,fontSize:`12px`,border:`1px solid #6c757d`,backgroundColor:`transparent`,color:`#6c757d`,borderRadius:`4px`,cursor:`pointer`},children:`Remove`}),e.state.status===`aborted`&&c(o,{children:[s(`button`,{type:`button`,onClick:()=>t.retryItem(e),style:{padding:`4px 8px`,fontSize:`12px`,border:`1px solid #007bff`,backgroundColor:`#007bff`,color:`white`,borderRadius:`4px`,cursor:`pointer`},children:`Retry`}),s(`button`,{type:`button`,onClick:()=>t.removeItem(e.id),style:{padding:`4px 8px`,fontSize:`12px`,border:`1px solid #6c757d`,backgroundColor:`transparent`,color:`#6c757d`,borderRadius:`4px`,cursor:`pointer`},children:`Remove`})]})]})]})}function _({children:t,multiple:r=!0,multiUploadOptions:c={},uploadOptions:l={},onUploadStart:u,onValidationError:d,...f}){let p=i(l),m=n(c),h=a(e=>{let t=[];if(!r&&e.length>1&&t.push(`Single file mode is enabled. Please select only one file. You selected ${e.length} files.`),f.accept&&f.accept.length>0){let n=e.filter(e=>!f.accept?.some(t=>{if(t.startsWith(`.`))return e.name.toLowerCase().endsWith(t.toLowerCase());if(t.endsWith(`/*`)){let n=t.slice(0,-2);return e.type.startsWith(n)}else return e.type===t}));if(n.length>0){let e=n.map(e=>`"${e.name}" (${e.type})`).join(`, `),r=f.accept.join(`, `);t.push(`Invalid file type(s): ${e}. Accepted types: ${r}.`)}}return t.length>0?t:null},[r,f.accept]),g=e=>{u?.(e),r&&m?(m.addFiles(e),setTimeout(()=>m.startAll(),0)):!r&&p&&e.length>0&&e[0]&&p.upload(e[0])},_=a(e=>{console.error(`Upload zone validation errors:`,e),d?.(e)},[d]),v=e({...f,multiple:r,validator:h,onFilesReceived:g,onValidationError:_}),y=v.state.isDragging||v.state.isOver,b=r?m?.state.isUploading??!1:p?.isUploading??!1;return s(o,{children:t({dragDrop:v,upload:p,multiUpload:m,openFilePicker:v.openFilePicker,isActive:y,isProcessing:b})})}function v({className:e=``,style:t={},text:n={},errorStyle:r={},children:i,...a}){let o={idle:a.multiple?`Drag files here or click to select`:`Drag a file here or click to select`,dragging:a.multiple?`Drop files here...`:`Drop file here...`,uploading:`Uploading...`,...n};return i?s(_,{...a,children:i}):s(_,{...a,children:({dragDrop:n,upload:i,multiUpload:a,openFilePicker:l,isActive:u,isProcessing:d})=>c(`button`,{type:`button`,onKeyDown:e=>{(e.key===`Enter`||e.key===` `)&&l()},onKeyUp:e=>{(e.key===`Enter`||e.key===` `)&&l()},...n.dragHandlers,onClick:l,className:`upload-zone ${u?`upload-zone--active`:``} ${d?`upload-zone--processing`:``} ${e}`,style:{border:u?`2px dashed #007bff`:`2px dashed #ccc`,borderRadius:`8px`,padding:`2rem`,textAlign:`center`,cursor:`pointer`,backgroundColor:u?`#f8f9fa`:`transparent`,transition:`all 0.2s ease`,minHeight:`120px`,display:`flex`,flexDirection:`column`,alignItems:`center`,justifyContent:`center`,...t},children:[n.state.isDragging?s(`p`,{style:{margin:0,fontSize:`16px`,color:`#007bff`},children:o.dragging}):d?c(`div`,{style:{textAlign:`center`},children:[s(`p`,{style:{margin:`0 0 10px 0`,fontSize:`14px`},children:o.uploading}),i&&c(`div`,{children:[s(`progress`,{value:i.state.progress,max:100,style:{width:`200px`,height:`8px`}}),c(`p`,{style:{margin:`5px 0 0 0`,fontSize:`12px`,color:`#666`},children:[i.state.progress,`%`]})]}),a&&c(`div`,{children:[s(`progress`,{value:a.state.progress,max:100,style:{width:`200px`,height:`8px`}}),c(`p`,{style:{margin:`5px 0 0 0`,fontSize:`12px`,color:`#666`},children:[a.state.progress,`% (`,a.state.uploading,` `,`uploading, `,a.state.successful,` completed)`]})]})]}):s(`p`,{style:{margin:0,fontSize:`16px`,color:`#666`},children:o.idle}),n.state.errors.length>0&&c(`div`,{style:{marginTop:`10px`,padding:`8px 12px`,backgroundColor:`#f8d7da`,border:`1px solid #f5c6cb`,borderRadius:`4px`,maxWidth:`100%`,...r},children:[s(`p`,{style:{margin:`0 0 5px 0`,fontSize:`12px`,fontWeight:`bold`,color:`#721c24`},children:`Validation Errors:`}),n.state.errors.map((e,t)=>c(`p`,{style:{color:`#721c24`,fontSize:`11px`,margin:`2px 0`,lineHeight:`1.3`},children:[`• `,e]},t))]}),s(`input`,{...n.inputProps})]})})}export{p as a,f as c,h as i,d as l,_ as n,m as o,g as r,u as s,v as t,l as u};
6
- //# sourceMappingURL=upload-zone-BjWHuP7p.mjs.map