knt-shared 1.10.5 → 1.10.6
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/components/Upload/BasicUpload.vue.d.ts.map +1 -1
- package/dist/components/Upload/types.d.ts +6 -0
- package/dist/components/Upload/types.d.ts.map +1 -1
- package/dist/index.cjs.js +46 -12
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +46 -12
- package/dist/index.esm.js.map +1 -1
- package/dist/style.css +32 -32
- package/dist/utils/url.d.ts +1 -1
- package/dist/utils/url.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.esm.js
CHANGED
|
@@ -1824,6 +1824,19 @@ const DEFAULT_CONFIG = {
|
|
|
1824
1824
|
filePath: "filePath",
|
|
1825
1825
|
fullFilePath: "fullFilePath"
|
|
1826
1826
|
};
|
|
1827
|
+
function generateBackfillUid(fileObj, config, url, index = 0) {
|
|
1828
|
+
if ((fileObj == null ? void 0 : fileObj.id) != null) {
|
|
1829
|
+
return `back-${fileObj.id}`;
|
|
1830
|
+
}
|
|
1831
|
+
const path = fileObj == null ? void 0 : fileObj[config.filePath];
|
|
1832
|
+
if (path) {
|
|
1833
|
+
return `back-${path}`;
|
|
1834
|
+
}
|
|
1835
|
+
if (url) {
|
|
1836
|
+
return `back-${url}`;
|
|
1837
|
+
}
|
|
1838
|
+
return `back-${Date.now()}-${index}`;
|
|
1839
|
+
}
|
|
1827
1840
|
function transformUploadUrl(transferUrl) {
|
|
1828
1841
|
var _a;
|
|
1829
1842
|
if (isNullOrUnDef(transferUrl)) {
|
|
@@ -1842,13 +1855,13 @@ function transformUploadUrl(transferUrl) {
|
|
|
1842
1855
|
}
|
|
1843
1856
|
return void 0;
|
|
1844
1857
|
}
|
|
1845
|
-
function transformBackUrl(transferUrl, config) {
|
|
1858
|
+
function transformBackUrl(transferUrl, config, index = 0) {
|
|
1846
1859
|
const mergedConfig = { ...DEFAULT_CONFIG, ...config };
|
|
1847
1860
|
if (!isArray(transferUrl) && (isNullOrUnDef(transferUrl) || isNullOrUnDef(transferUrl[mergedConfig.fullFilePath]) || isNullOrUnDef(transferUrl[mergedConfig.filePath]))) {
|
|
1848
1861
|
return void 0;
|
|
1849
1862
|
}
|
|
1850
1863
|
if (isArray(transferUrl)) {
|
|
1851
|
-
const result = transferUrl.map((item) => transformBackUrl(item, config)).filter((item) => !isNullOrUnDef(item));
|
|
1864
|
+
const result = transferUrl.map((item, index2) => transformBackUrl(item, config, index2)).filter((item) => !isNullOrUnDef(item));
|
|
1852
1865
|
if (mergedConfig.backType === "object") {
|
|
1853
1866
|
return result;
|
|
1854
1867
|
}
|
|
@@ -1857,14 +1870,19 @@ function transformBackUrl(transferUrl, config) {
|
|
|
1857
1870
|
let resultObj;
|
|
1858
1871
|
if (isString(transferUrl)) {
|
|
1859
1872
|
resultObj = {
|
|
1873
|
+
uid: generateBackfillUid(null, mergedConfig, transferUrl, index),
|
|
1874
|
+
name: transferUrl.split("/").pop() || `file-${index}`,
|
|
1860
1875
|
url: transferUrl,
|
|
1861
1876
|
path: void 0,
|
|
1862
1877
|
status: "done"
|
|
1863
1878
|
};
|
|
1864
1879
|
} else if (isObject(transferUrl)) {
|
|
1865
1880
|
const fileObj = transferUrl;
|
|
1881
|
+
const url = fileObj[mergedConfig.fullFilePath];
|
|
1866
1882
|
resultObj = {
|
|
1867
|
-
|
|
1883
|
+
uid: generateBackfillUid(fileObj, mergedConfig, url, index),
|
|
1884
|
+
name: (url == null ? void 0 : url.split("/").pop()) || `file-${index}`,
|
|
1885
|
+
url,
|
|
1868
1886
|
path: fileObj[mergedConfig.filePath],
|
|
1869
1887
|
status: "done"
|
|
1870
1888
|
};
|
|
@@ -2956,7 +2974,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
2956
2974
|
emits: ["register", "update:modelValue", "change", "success", "handleSuccess", "error", "handlError", "progress", "remove", "preview", "exceed", "sortChange"],
|
|
2957
2975
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
2958
2976
|
useCssVars((_ctx) => ({
|
|
2959
|
-
"
|
|
2977
|
+
"eb56f194": cardSizeValue.value
|
|
2960
2978
|
}));
|
|
2961
2979
|
const MAX_SIZE_UNIT_BYTES = {
|
|
2962
2980
|
B: 1,
|
|
@@ -3342,10 +3360,30 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3342
3360
|
emit("update:modelValue", fileList);
|
|
3343
3361
|
}
|
|
3344
3362
|
};
|
|
3363
|
+
const normalizeFileItem = (item, index) => {
|
|
3364
|
+
var _a;
|
|
3365
|
+
return {
|
|
3366
|
+
...item,
|
|
3367
|
+
uid: item.uid || `file-${item.path || item.url || index}-${index}`,
|
|
3368
|
+
name: item.name || ((_a = item.url) == null ? void 0 : _a.split("/").pop()) || `file-${index}`,
|
|
3369
|
+
status: item.status || "done"
|
|
3370
|
+
};
|
|
3371
|
+
};
|
|
3372
|
+
const findFileIndex = (fileItem) => {
|
|
3373
|
+
if (fileItem.uid != null) {
|
|
3374
|
+
const index = fileListRef.value.findIndex(
|
|
3375
|
+
(item) => item.uid != null && item.uid === fileItem.uid
|
|
3376
|
+
);
|
|
3377
|
+
if (index !== -1) return index;
|
|
3378
|
+
}
|
|
3379
|
+
return fileListRef.value.findIndex(
|
|
3380
|
+
(item) => item.url === fileItem.url && item.path === fileItem.path
|
|
3381
|
+
);
|
|
3382
|
+
};
|
|
3345
3383
|
const parseModelValue = (value) => {
|
|
3346
3384
|
if (!value) return [];
|
|
3347
3385
|
if (Array.isArray(value) && value.length > 0 && typeof value[0] === "object") {
|
|
3348
|
-
return value;
|
|
3386
|
+
return value.map(normalizeFileItem);
|
|
3349
3387
|
}
|
|
3350
3388
|
if (Array.isArray(value)) {
|
|
3351
3389
|
return value.map((url, index) => ({
|
|
@@ -3399,18 +3437,14 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3399
3437
|
updateModelValue(fileListRef.value);
|
|
3400
3438
|
};
|
|
3401
3439
|
const removeFile = (fileItem) => {
|
|
3402
|
-
const index =
|
|
3403
|
-
(item) => item.uid === fileItem.uid
|
|
3404
|
-
);
|
|
3440
|
+
const index = findFileIndex(fileItem);
|
|
3405
3441
|
if (index !== -1) {
|
|
3406
3442
|
fileListRef.value.splice(index, 1);
|
|
3407
3443
|
updateModelValue(fileListRef.value);
|
|
3408
3444
|
}
|
|
3409
3445
|
};
|
|
3410
3446
|
const updateFile = (fileItem) => {
|
|
3411
|
-
const index =
|
|
3412
|
-
(item) => item.uid === fileItem.uid
|
|
3413
|
-
);
|
|
3447
|
+
const index = findFileIndex(fileItem);
|
|
3414
3448
|
if (index !== -1) {
|
|
3415
3449
|
fileListRef.value[index] = { ...fileListRef.value[index], ...fileItem };
|
|
3416
3450
|
updateModelValue(fileListRef.value);
|
|
@@ -3617,7 +3651,7 @@ const _sfc_main$f = /* @__PURE__ */ defineComponent({
|
|
|
3617
3651
|
};
|
|
3618
3652
|
}
|
|
3619
3653
|
});
|
|
3620
|
-
const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-
|
|
3654
|
+
const BasicUpload = /* @__PURE__ */ _export_sfc(_sfc_main$f, [["__scopeId", "data-v-3a5bef91"]]);
|
|
3621
3655
|
function useUpload(props) {
|
|
3622
3656
|
const uploadRef = ref(null);
|
|
3623
3657
|
const fileListRef = ref((props == null ? void 0 : props.defaultFileList) || []);
|