@uploadista/react-native-core 0.0.20 → 0.1.0-beta.5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uploadista/react-native-core",
3
- "version": "0.0.20",
3
+ "version": "0.1.0-beta.5",
4
4
  "type": "module",
5
5
  "description": "Core React Native client for Uploadista",
6
6
  "license": "MIT",
@@ -15,8 +15,8 @@
15
15
  "dependencies": {
16
16
  "uuid": "^13.0.0",
17
17
  "js-base64": "^3.7.7",
18
- "@uploadista/core": "0.0.20",
19
- "@uploadista/client-core": "0.0.20"
18
+ "@uploadista/core": "0.1.0-beta.5",
19
+ "@uploadista/client-core": "0.1.0-beta.5"
20
20
  },
21
21
  "peerDependencies": {
22
22
  "react": ">=16.8.0",
@@ -30,8 +30,8 @@
30
30
  },
31
31
  "devDependencies": {
32
32
  "@types/react": ">=18.0.0",
33
- "tsdown": "0.18.0",
34
- "@uploadista/typescript-config": "0.0.20"
33
+ "tsdown": "0.19.0",
34
+ "@uploadista/typescript-config": "0.1.0-beta.5"
35
35
  },
36
36
  "scripts": {
37
37
  "build": "tsc --noEmit && tsdown",
@@ -648,11 +648,14 @@ function FlowSubmit({ children, disabled }: FlowSubmitProps) {
648
648
 
649
649
  const renderProps: FlowSubmitRenderProps = {
650
650
  submit: flow.execute,
651
- isDisabled: disabled || flow.isActive || Object.keys(flow.inputs).length === 0,
651
+ isDisabled:
652
+ disabled || flow.isActive || Object.keys(flow.inputs).length === 0,
652
653
  isSubmitting: flow.isActive,
653
654
  };
654
655
 
655
- return <>{typeof children === "function" ? children(renderProps) : children}</>;
656
+ return (
657
+ <>{typeof children === "function" ? children(renderProps) : children}</>
658
+ );
656
659
  }
657
660
 
658
661
  /**
@@ -684,7 +687,9 @@ function FlowCancel({ children }: FlowCancelProps) {
684
687
  isDisabled: !flow.isActive,
685
688
  };
686
689
 
687
- return <>{typeof children === "function" ? children(renderProps) : children}</>;
690
+ return (
691
+ <>{typeof children === "function" ? children(renderProps) : children}</>
692
+ );
688
693
  }
689
694
 
690
695
  /**
@@ -716,7 +721,9 @@ function FlowReset({ children }: FlowResetProps) {
716
721
  isDisabled: flow.isActive,
717
722
  };
718
723
 
719
- return <>{typeof children === "function" ? children(renderProps) : children}</>;
724
+ return (
725
+ <>{typeof children === "function" ? children(renderProps) : children}</>
726
+ );
720
727
  }
721
728
 
722
729
  // ============ QUICK UPLOAD PRIMITIVE ============
@@ -11,75 +11,74 @@ export {
11
11
  FileUploadButton,
12
12
  type FileUploadButtonProps,
13
13
  } from "./FileUploadButton";
14
- export {
15
- GalleryUploadButton,
16
- type GalleryUploadButtonProps,
17
- } from "./GalleryUploadButton";
18
- export { UploadList, type UploadListProps } from "./UploadList";
19
- export { UploadProgress, type UploadProgressProps } from "./UploadProgress";
20
-
21
14
  // Flow compound components
22
15
  export {
23
16
  Flow,
24
- useFlowContext,
25
- useFlowInputContext,
26
- type FlowProps,
27
- type FlowRenderProps,
17
+ type FlowCancelProps,
18
+ type FlowCancelRenderProps,
28
19
  type FlowContextValue,
20
+ type FlowErrorProps,
21
+ type FlowErrorRenderProps,
29
22
  type FlowInputContextValue,
30
- type FlowInputsProps,
31
- type FlowInputsRenderProps,
32
- type FlowInputProps,
33
23
  type FlowInputFilePickerProps,
34
24
  type FlowInputFilePickerRenderProps,
35
25
  type FlowInputPreviewProps,
36
26
  type FlowInputPreviewRenderProps,
27
+ type FlowInputProps,
28
+ type FlowInputsProps,
29
+ type FlowInputsRenderProps,
37
30
  type FlowProgressProps,
38
31
  type FlowProgressRenderProps,
32
+ type FlowProps,
33
+ type FlowQuickUploadProps,
34
+ type FlowQuickUploadRenderProps,
35
+ type FlowRenderProps,
36
+ type FlowResetProps,
37
+ type FlowResetRenderProps,
39
38
  type FlowStatusProps,
40
39
  type FlowStatusRenderProps,
41
- type FlowErrorProps,
42
- type FlowErrorRenderProps,
43
40
  type FlowSubmitProps,
44
41
  type FlowSubmitRenderProps,
45
- type FlowCancelProps,
46
- type FlowCancelRenderProps,
47
- type FlowResetProps,
48
- type FlowResetRenderProps,
49
- type FlowQuickUploadProps,
50
- type FlowQuickUploadRenderProps,
42
+ useFlowContext,
43
+ useFlowInputContext,
51
44
  } from "./flow-primitives";
45
+ export {
46
+ GalleryUploadButton,
47
+ type GalleryUploadButtonProps,
48
+ } from "./GalleryUploadButton";
49
+ export { UploadList, type UploadListProps } from "./UploadList";
50
+ export { UploadProgress, type UploadProgressProps } from "./UploadProgress";
52
51
 
53
52
  // Upload compound components
54
53
  export {
55
54
  Upload,
56
- useUploadContext,
57
- useUploadItemContext,
58
- type UploadProps,
59
- type UploadRenderProps,
55
+ type UploadCameraPickerProps,
56
+ type UploadCameraPickerRenderProps,
57
+ type UploadCancelProps,
58
+ type UploadCancelRenderProps,
60
59
  type UploadContextValue,
61
- type UploadItemContextValue,
60
+ type UploadErrorProps,
61
+ type UploadErrorRenderProps,
62
62
  type UploadFilePickerProps,
63
63
  type UploadFilePickerRenderProps,
64
64
  type UploadGalleryPickerProps,
65
65
  type UploadGalleryPickerRenderProps,
66
- type UploadCameraPickerProps,
67
- type UploadCameraPickerRenderProps,
66
+ type UploadItemContextValue,
67
+ type UploadItemProps,
68
68
  type UploadItemsProps,
69
69
  type UploadItemsRenderProps,
70
- type UploadItemProps,
71
70
  type UploadProgressProps as UploadCompoundProgressProps,
72
71
  type UploadProgressRenderProps as UploadCompoundProgressRenderProps,
73
- type UploadStatusProps,
74
- type UploadStatusRenderProps,
75
- type UploadErrorProps,
76
- type UploadErrorRenderProps,
77
- type UploadCancelProps,
78
- type UploadCancelRenderProps,
79
- type UploadRetryProps,
80
- type UploadRetryRenderProps,
72
+ type UploadProps,
73
+ type UploadRenderProps,
81
74
  type UploadResetProps,
82
75
  type UploadResetRenderProps,
76
+ type UploadRetryProps,
77
+ type UploadRetryRenderProps,
83
78
  type UploadStartAllProps,
84
79
  type UploadStartAllRenderProps,
80
+ type UploadStatusProps,
81
+ type UploadStatusRenderProps,
82
+ useUploadContext,
83
+ useUploadItemContext,
85
84
  } from "./upload-primitives";
@@ -133,7 +133,11 @@ export interface UploadProps {
133
133
  /** Called when an upload fails */
134
134
  onError?: (error: Error) => void;
135
135
  /** Called when all uploads complete (multi mode) */
136
- onComplete?: (results: { successful: number; failed: number; total: number }) => void;
136
+ onComplete?: (results: {
137
+ successful: number;
138
+ failed: number;
139
+ total: number;
140
+ }) => void;
137
141
  /** Children to render (can be render function or ReactNode) */
138
142
  children: ReactNode | ((props: UploadRenderProps) => ReactNode);
139
143
  }
@@ -215,12 +219,21 @@ function UploadRoot({
215
219
  // Track completion
216
220
  const checkComplete = useCallback(() => {
217
221
  const { items } = multiUpload.state;
218
- const allComplete = items.length > 0 && items.every(
219
- (item) => item.status === "success" || item.status === "error" || item.status === "aborted"
220
- );
222
+ const allComplete =
223
+ items.length > 0 &&
224
+ items.every(
225
+ (item) =>
226
+ item.status === "success" ||
227
+ item.status === "error" ||
228
+ item.status === "aborted",
229
+ );
221
230
  if (allComplete && onComplete) {
222
- const successful = items.filter((item) => item.status === "success").length;
223
- const failed = items.filter((item) => item.status === "error" || item.status === "aborted").length;
231
+ const successful = items.filter(
232
+ (item) => item.status === "success",
233
+ ).length;
234
+ const failed = items.filter(
235
+ (item) => item.status === "error" || item.status === "aborted",
236
+ ).length;
224
237
  onComplete({ successful, failed, total: items.length });
225
238
  }
226
239
  }, [multiUpload.state, onComplete]);
@@ -255,7 +268,9 @@ function UploadRoot({
255
268
  if (!fileSystemProvider?.pickImage) {
256
269
  throw new Error("Image picker not available");
257
270
  }
258
- const result = await fileSystemProvider.pickImage({ allowMultiple: multiple });
271
+ const result = await fileSystemProvider.pickImage({
272
+ allowMultiple: multiple,
273
+ });
259
274
  if (result.status === "success") {
260
275
  handleFilesReceived([result]);
261
276
  return result;
@@ -669,7 +684,10 @@ function UploadStatus({ children }: UploadStatusProps) {
669
684
  status = "uploading";
670
685
  } else if (state.items.length > 0) {
671
686
  const allComplete = state.items.every(
672
- (item) => item.status === "success" || item.status === "error" || item.status === "aborted"
687
+ (item) =>
688
+ item.status === "success" ||
689
+ item.status === "error" ||
690
+ item.status === "aborted",
673
691
  );
674
692
  if (allComplete) {
675
693
  status = state.failedCount > 0 ? "error" : "success";
@@ -680,7 +698,10 @@ function UploadStatus({ children }: UploadStatusProps) {
680
698
  status,
681
699
  isIdle: status === "idle",
682
700
  isUploading: state.activeCount > 0,
683
- isSuccess: state.completedCount > 0 && state.failedCount === 0 && state.activeCount === 0,
701
+ isSuccess:
702
+ state.completedCount > 0 &&
703
+ state.failedCount === 0 &&
704
+ state.activeCount === 0,
684
705
  isError: state.failedCount > 0,
685
706
  total: state.items.length,
686
707
  successful: state.completedCount,
@@ -737,8 +758,8 @@ export interface UploadErrorProps {
737
758
  function UploadError({ children }: UploadErrorProps) {
738
759
  const upload = useUploadContext();
739
760
 
740
- const failedItems = upload.state.items.filter((item) =>
741
- item.status === "error" || item.status === "aborted"
761
+ const failedItems = upload.state.items.filter(
762
+ (item) => item.status === "error" || item.status === "aborted",
742
763
  );
743
764
 
744
765
  const renderProps: UploadErrorRenderProps = {
@@ -778,9 +799,11 @@ function UploadCancel({ children }: UploadCancelProps) {
778
799
  const upload = useUploadContext();
779
800
 
780
801
  const cancel = useCallback(() => {
781
- upload.state.items
782
- .filter((item) => item.status === "uploading")
783
- .forEach((item) => upload.abortItem(item.id));
802
+ for (const item of upload.state.items.filter(
803
+ (item) => item.status === "uploading",
804
+ )) {
805
+ upload.abortItem(item.id);
806
+ }
784
807
  }, [upload]);
785
808
 
786
809
  const renderProps: UploadCancelRenderProps = {
@@ -817,7 +840,7 @@ function UploadRetry({ children }: UploadRetryProps) {
817
840
 
818
841
  const retry = useCallback(async () => {
819
842
  const failedItems = upload.state.items.filter(
820
- (item) => item.status === "error" || item.status === "aborted"
843
+ (item) => item.status === "error" || item.status === "aborted",
821
844
  );
822
845
  for (const item of failedItems) {
823
846
  await upload.retryItem(item.id);
@@ -886,7 +909,7 @@ function UploadStartAll({ children }: UploadStartAllProps) {
886
909
  const upload = useUploadContext();
887
910
 
888
911
  const idleCount = upload.state.items.filter(
889
- (item) => item.status === "idle"
912
+ (item) => item.status === "idle",
890
913
  ).length;
891
914
 
892
915
  const start = useCallback(async () => {
package/src/index.ts CHANGED
@@ -33,72 +33,72 @@ export {
33
33
  type CameraUploadButtonProps,
34
34
  FileUploadButton,
35
35
  type FileUploadButtonProps,
36
- GalleryUploadButton,
37
- type GalleryUploadButtonProps,
38
- UploadList,
39
- type UploadListProps,
40
- UploadProgress,
41
- type UploadProgressProps,
42
36
  // Flow compound components
43
37
  Flow,
44
- useFlowContext,
45
- useFlowInputContext,
46
- type FlowProps,
47
- type FlowRenderProps,
38
+ type FlowCancelProps,
39
+ type FlowCancelRenderProps,
48
40
  type FlowContextValue,
41
+ type FlowErrorProps,
42
+ type FlowErrorRenderProps,
49
43
  type FlowInputContextValue,
50
- type FlowInputsProps,
51
- type FlowInputsRenderProps,
52
- type FlowInputProps,
53
44
  type FlowInputFilePickerProps,
54
45
  type FlowInputFilePickerRenderProps,
55
46
  type FlowInputPreviewProps,
56
47
  type FlowInputPreviewRenderProps,
48
+ type FlowInputProps,
49
+ type FlowInputsProps,
50
+ type FlowInputsRenderProps,
57
51
  type FlowProgressProps,
58
52
  type FlowProgressRenderProps,
53
+ type FlowProps,
54
+ type FlowQuickUploadProps,
55
+ type FlowQuickUploadRenderProps,
56
+ type FlowRenderProps,
57
+ type FlowResetProps,
58
+ type FlowResetRenderProps,
59
59
  type FlowStatusProps,
60
60
  type FlowStatusRenderProps,
61
- type FlowErrorProps,
62
- type FlowErrorRenderProps,
63
61
  type FlowSubmitProps,
64
62
  type FlowSubmitRenderProps,
65
- type FlowCancelProps,
66
- type FlowCancelRenderProps,
67
- type FlowResetProps,
68
- type FlowResetRenderProps,
69
- type FlowQuickUploadProps,
70
- type FlowQuickUploadRenderProps,
63
+ GalleryUploadButton,
64
+ type GalleryUploadButtonProps,
71
65
  // Upload compound components
72
66
  Upload,
73
- useUploadContext,
74
- useUploadItemContext,
75
- type UploadProps,
76
- type UploadRenderProps,
67
+ type UploadCameraPickerProps,
68
+ type UploadCameraPickerRenderProps,
69
+ type UploadCancelProps,
70
+ type UploadCancelRenderProps,
71
+ type UploadCompoundProgressProps,
72
+ type UploadCompoundProgressRenderProps,
77
73
  type UploadContextValue,
78
- type UploadItemContextValue,
74
+ type UploadErrorProps,
75
+ type UploadErrorRenderProps,
79
76
  type UploadFilePickerProps,
80
77
  type UploadFilePickerRenderProps,
81
78
  type UploadGalleryPickerProps,
82
79
  type UploadGalleryPickerRenderProps,
83
- type UploadCameraPickerProps,
84
- type UploadCameraPickerRenderProps,
80
+ type UploadItemContextValue,
81
+ type UploadItemProps,
85
82
  type UploadItemsProps,
86
83
  type UploadItemsRenderProps,
87
- type UploadItemProps,
88
- type UploadCompoundProgressProps,
89
- type UploadCompoundProgressRenderProps,
90
- type UploadStatusProps,
91
- type UploadStatusRenderProps,
92
- type UploadErrorProps,
93
- type UploadErrorRenderProps,
94
- type UploadCancelProps,
95
- type UploadCancelRenderProps,
96
- type UploadRetryProps,
97
- type UploadRetryRenderProps,
84
+ UploadList,
85
+ type UploadListProps,
86
+ UploadProgress,
87
+ type UploadProgressProps,
88
+ type UploadProps,
89
+ type UploadRenderProps,
98
90
  type UploadResetProps,
99
91
  type UploadResetRenderProps,
92
+ type UploadRetryProps,
93
+ type UploadRetryRenderProps,
100
94
  type UploadStartAllProps,
101
95
  type UploadStartAllRenderProps,
96
+ type UploadStatusProps,
97
+ type UploadStatusRenderProps,
98
+ useFlowContext,
99
+ useFlowInputContext,
100
+ useUploadContext,
101
+ useUploadItemContext,
102
102
  } from "./components";
103
103
  // Export contexts
104
104
  export {