@thetechfossil/upfiles 1.0.4 → 1.0.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/dist/index.d.mts +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +12 -2
- package/dist/index.mjs +12 -2
- package/package.json +2 -2
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -192,7 +192,7 @@ var UpfilesClient = class {
|
|
|
192
192
|
};
|
|
193
193
|
|
|
194
194
|
// src/Uploader.tsx
|
|
195
|
-
var import_react = require("react");
|
|
195
|
+
var import_react = __toESM(require("react"));
|
|
196
196
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
197
197
|
var Uploader = ({
|
|
198
198
|
clientOptions,
|
|
@@ -213,7 +213,8 @@ var Uploader = ({
|
|
|
213
213
|
folderPath,
|
|
214
214
|
fetchThumbnails,
|
|
215
215
|
autoRecordToDb = false,
|
|
216
|
-
recordUrl = "/api/files"
|
|
216
|
+
recordUrl = "/api/files",
|
|
217
|
+
autoUpload = false
|
|
217
218
|
}) => {
|
|
218
219
|
const inputRef = (0, import_react.useRef)(null);
|
|
219
220
|
const client = (0, import_react.useMemo)(() => new UpfilesClient(clientOptions ?? {}), [clientOptions]);
|
|
@@ -364,6 +365,14 @@ var Uploader = ({
|
|
|
364
365
|
setIsUploading(false);
|
|
365
366
|
}
|
|
366
367
|
}, [files, onComplete, onError, uploadOne]);
|
|
368
|
+
import_react.default.useEffect(() => {
|
|
369
|
+
if (autoUpload && files.some((f2) => f2.status === "pending") && !isUploading) {
|
|
370
|
+
const timer = setTimeout(() => {
|
|
371
|
+
uploadAll();
|
|
372
|
+
}, 100);
|
|
373
|
+
return () => clearTimeout(timer);
|
|
374
|
+
}
|
|
375
|
+
}, [autoUpload, files, isUploading, uploadAll]);
|
|
367
376
|
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className, children: [
|
|
368
377
|
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
369
378
|
"input",
|
|
@@ -1167,6 +1176,7 @@ function ImageManager(props) {
|
|
|
1167
1176
|
maxFiles,
|
|
1168
1177
|
autoRecordToDb,
|
|
1169
1178
|
fetchThumbnails,
|
|
1179
|
+
autoUpload: true,
|
|
1170
1180
|
onClientUploadComplete: (file) => {
|
|
1171
1181
|
if (file.status === "success" && file.publicUrl && file.fileKey) {
|
|
1172
1182
|
const newItem = {
|
package/dist/index.mjs
CHANGED
|
@@ -143,7 +143,7 @@ var UpfilesClient = class {
|
|
|
143
143
|
};
|
|
144
144
|
|
|
145
145
|
// src/Uploader.tsx
|
|
146
|
-
import { useCallback, useMemo, useRef, useState } from "react";
|
|
146
|
+
import React, { useCallback, useMemo, useRef, useState } from "react";
|
|
147
147
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
148
148
|
var Uploader = ({
|
|
149
149
|
clientOptions,
|
|
@@ -164,7 +164,8 @@ var Uploader = ({
|
|
|
164
164
|
folderPath,
|
|
165
165
|
fetchThumbnails,
|
|
166
166
|
autoRecordToDb = false,
|
|
167
|
-
recordUrl = "/api/files"
|
|
167
|
+
recordUrl = "/api/files",
|
|
168
|
+
autoUpload = false
|
|
168
169
|
}) => {
|
|
169
170
|
const inputRef = useRef(null);
|
|
170
171
|
const client = useMemo(() => new UpfilesClient(clientOptions ?? {}), [clientOptions]);
|
|
@@ -315,6 +316,14 @@ var Uploader = ({
|
|
|
315
316
|
setIsUploading(false);
|
|
316
317
|
}
|
|
317
318
|
}, [files, onComplete, onError, uploadOne]);
|
|
319
|
+
React.useEffect(() => {
|
|
320
|
+
if (autoUpload && files.some((f2) => f2.status === "pending") && !isUploading) {
|
|
321
|
+
const timer = setTimeout(() => {
|
|
322
|
+
uploadAll();
|
|
323
|
+
}, 100);
|
|
324
|
+
return () => clearTimeout(timer);
|
|
325
|
+
}
|
|
326
|
+
}, [autoUpload, files, isUploading, uploadAll]);
|
|
318
327
|
return /* @__PURE__ */ jsxs("div", { className, children: [
|
|
319
328
|
/* @__PURE__ */ jsx(
|
|
320
329
|
"input",
|
|
@@ -1118,6 +1127,7 @@ function ImageManager(props) {
|
|
|
1118
1127
|
maxFiles,
|
|
1119
1128
|
autoRecordToDb,
|
|
1120
1129
|
fetchThumbnails,
|
|
1130
|
+
autoUpload: true,
|
|
1121
1131
|
onClientUploadComplete: (file) => {
|
|
1122
1132
|
if (file.status === "success" && file.publicUrl && file.fileKey) {
|
|
1123
1133
|
const newItem = {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@thetechfossil/upfiles",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"description": "Lightweight client and React components for Upfiles Plugin API (presigned S3)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "UpFiles",
|
|
@@ -42,4 +42,4 @@
|
|
|
42
42
|
"tsup": "^8.3.0",
|
|
43
43
|
"typescript": "^5.6.2"
|
|
44
44
|
}
|
|
45
|
-
}
|
|
45
|
+
}
|