@bagelink/vue 0.0.951 → 0.0.955
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/form/inputs/FileUpload.vue.d.ts +23 -30
- package/dist/components/form/inputs/FileUpload.vue.d.ts.map +1 -1
- package/dist/index.cjs +124 -82
- package/dist/index.mjs +124 -82
- package/dist/style.css +34 -34
- package/package.json +1 -1
- package/src/components/form/inputs/FileUpload.vue +74 -50
|
@@ -1,7 +1,28 @@
|
|
|
1
1
|
import { StorageFile } from '../../..';
|
|
2
2
|
type StrKey = keyof StorageFile;
|
|
3
3
|
type FSValue = string[] | string | number;
|
|
4
|
+
declare let __VLS_typeProps: {
|
|
5
|
+
label?: string;
|
|
6
|
+
multiple?: boolean;
|
|
7
|
+
files?: StorageFile | StorageFile[];
|
|
8
|
+
bindkey?: StrKey;
|
|
9
|
+
modelValue?: FSValue;
|
|
10
|
+
width?: string;
|
|
11
|
+
height?: string | 'auto';
|
|
12
|
+
topic?: string;
|
|
13
|
+
fill?: boolean;
|
|
14
|
+
oval?: boolean;
|
|
15
|
+
theme?: 'dropzone' | 'basic';
|
|
16
|
+
accept?: string;
|
|
17
|
+
required?: boolean;
|
|
18
|
+
};
|
|
4
19
|
declare function browse(): void;
|
|
20
|
+
declare const __VLS_defaults: {
|
|
21
|
+
modelValue: () => FSValue;
|
|
22
|
+
};
|
|
23
|
+
type __VLS_PublicProps = {
|
|
24
|
+
'modelValue'?: typeof __VLS_defaults['modelValue'];
|
|
25
|
+
} & typeof __VLS_typeProps;
|
|
5
26
|
declare function __VLS_template(): {
|
|
6
27
|
slots: {
|
|
7
28
|
files?(_: {
|
|
@@ -72,38 +93,10 @@ declare function __VLS_template(): {
|
|
|
72
93
|
attrs: Partial<{}>;
|
|
73
94
|
};
|
|
74
95
|
type __VLS_TemplateResult = ReturnType<typeof __VLS_template>;
|
|
75
|
-
declare const __VLS_component: import('vue').DefineComponent<{
|
|
76
|
-
label?: string;
|
|
77
|
-
multiple?: boolean;
|
|
78
|
-
files?: StorageFile | StorageFile[];
|
|
79
|
-
bindkey?: StrKey;
|
|
80
|
-
modelValue?: FSValue;
|
|
81
|
-
width?: string;
|
|
82
|
-
height?: string | "auto";
|
|
83
|
-
topic?: string;
|
|
84
|
-
fill?: boolean;
|
|
85
|
-
oval?: boolean;
|
|
86
|
-
theme?: "dropzone" | "basic";
|
|
87
|
-
accept?: string;
|
|
88
|
-
required?: boolean;
|
|
89
|
-
}, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
96
|
+
declare const __VLS_component: import('vue').DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import('vue').ComponentOptionsMixin, import('vue').ComponentOptionsMixin, {
|
|
90
97
|
"update:modelValue": (...args: any[]) => void;
|
|
91
98
|
addFileStart: (...args: any[]) => void;
|
|
92
|
-
}, string, import('vue').PublicProps, Readonly<{
|
|
93
|
-
label?: string;
|
|
94
|
-
multiple?: boolean;
|
|
95
|
-
files?: StorageFile | StorageFile[];
|
|
96
|
-
bindkey?: StrKey;
|
|
97
|
-
modelValue?: FSValue;
|
|
98
|
-
width?: string;
|
|
99
|
-
height?: string | "auto";
|
|
100
|
-
topic?: string;
|
|
101
|
-
fill?: boolean;
|
|
102
|
-
oval?: boolean;
|
|
103
|
-
theme?: "dropzone" | "basic";
|
|
104
|
-
accept?: string;
|
|
105
|
-
required?: boolean;
|
|
106
|
-
}> & Readonly<{
|
|
99
|
+
}, string, import('vue').PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
107
100
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
108
101
|
onAddFileStart?: ((...args: any[]) => any) | undefined;
|
|
109
102
|
}>, {}, {}, {}, {}, string, import('vue').ComponentProvideOptions, false, {}, any>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FileUpload.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/FileUpload.vue"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"FileUpload.vue.d.ts","sourceRoot":"","sources":["../../../../src/components/form/inputs/FileUpload.vue"],"names":[],"mappings":"AAomBA,OAAO,EAAmC,KAAK,WAAW,EAAkB,MAAM,eAAe,CAAA;AAKjG,KAAK,MAAM,GAAG,MAAM,WAAW,CAAA;AAE/B,KAAK,OAAO,GAAG,MAAM,EAAE,GAAG,MAAM,GAAG,MAAM,CAAA;AAEzC,QAAA,IAAI,eAAe,EAAG;IACrB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,KAAK,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAA;IACnC,OAAO,CAAC,EAAE,MAAM,CAAA;IAChB,UAAU,CAAC,EAAE,OAAO,CAAA;IACpB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAAA;IACxB,KAAK,CAAC,EAAE,MAAM,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,IAAI,CAAC,EAAE,OAAO,CAAA;IACd,KAAK,CAAC,EAAE,UAAU,GAAG,OAAO,CAAA;IAC5B,MAAM,CAAC,EAAE,MAAM,CAAA;IACf,QAAQ,CAAC,EAAE,OAAO,CAAA;CAClB,CAAC;AAkJF,iBAAS,MAAM,SAiBd;AA+BD,QAAA,MAAM,cAAc;sBACI,OAAO;CAC9B,CAAC;AACF,KAAK,iBAAiB,GAAG;IACzB,YAAY,CAAC,EAAE,OAAO,cAAc,CAAC,YAAY,CAAC,CAAC;CAClD,GAAG,OAAO,eAAe,CAAC;AAI3B,iBAAS,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;;;0BAhMZ,MAAM;4BACJ,OAAO;uBACZ,MAAM;2BACF,OAAO;;YAorBS,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;0BAvrBpB,MAAM;4BACJ,OAAO;uBACZ,MAAM;2BACF,OAAO;;;YAqrBgB,GAAG;;;WASxB,OAAO,IAA6B;EAEjD;AA0BD,KAAK,oBAAoB,GAAG,UAAU,CAAC,OAAO,cAAc,CAAC,CAAC;AAC9D,QAAA,MAAM,eAAe;;;;;;kFAUnB,CAAC;wBACkB,uBAAuB,CAAC,OAAO,eAAe,EAAE,oBAAoB,CAAC,OAAO,CAAC,CAAC;AAAnG,wBAAoG;AAWpG,KAAK,uBAAuB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,GAAG;IACxC,QAAO;QACN,MAAM,EAAE,CAAC,CAAC;KAEV,CAAA;CACD,CAAC"}
|
package/dist/index.cjs
CHANGED
|
@@ -18658,42 +18658,43 @@ const _hoisted_2$l = {
|
|
|
18658
18658
|
required: "",
|
|
18659
18659
|
class: "pixel"
|
|
18660
18660
|
};
|
|
18661
|
-
const _hoisted_3$h = { class: "
|
|
18662
|
-
const _hoisted_4$b = {
|
|
18663
|
-
|
|
18661
|
+
const _hoisted_3$h = { class: "m-05 flex opacity-7 z-99" };
|
|
18662
|
+
const _hoisted_4$b = { class: "ellipsis-1 word-break-all h-20 m-0" };
|
|
18663
|
+
const _hoisted_5$a = {
|
|
18664
|
+
key: 1,
|
|
18664
18665
|
class: "txt-gray txt-12"
|
|
18665
18666
|
};
|
|
18666
|
-
const
|
|
18667
|
+
const _hoisted_6$8 = {
|
|
18667
18668
|
key: 0,
|
|
18668
18669
|
class: "bgl-multi-preview"
|
|
18669
18670
|
};
|
|
18670
|
-
const
|
|
18671
|
-
const
|
|
18672
|
-
const
|
|
18673
|
-
const
|
|
18674
|
-
const
|
|
18671
|
+
const _hoisted_7$5 = ["src"];
|
|
18672
|
+
const _hoisted_8$3 = { class: "m-0" };
|
|
18673
|
+
const _hoisted_9$2 = ["width", "src"];
|
|
18674
|
+
const _hoisted_10$2 = { class: "no-margin multi-preview-txt" };
|
|
18675
|
+
const _hoisted_11$1 = {
|
|
18675
18676
|
key: 0,
|
|
18676
18677
|
class: "progress"
|
|
18677
18678
|
};
|
|
18678
|
-
const
|
|
18679
|
+
const _hoisted_12$1 = {
|
|
18679
18680
|
key: 1,
|
|
18680
18681
|
class: "bgl-single-preview"
|
|
18681
18682
|
};
|
|
18682
|
-
const
|
|
18683
|
-
const
|
|
18683
|
+
const _hoisted_13$1 = { class: "position-start m-05 flex opacity-7 z-99" };
|
|
18684
|
+
const _hoisted_14$1 = {
|
|
18684
18685
|
key: 0,
|
|
18685
18686
|
class: "h-100"
|
|
18686
18687
|
};
|
|
18687
|
-
const
|
|
18688
|
-
const
|
|
18688
|
+
const _hoisted_15$1 = ["src"];
|
|
18689
|
+
const _hoisted_16 = {
|
|
18689
18690
|
key: 0,
|
|
18690
18691
|
class: "progress"
|
|
18691
18692
|
};
|
|
18692
|
-
const
|
|
18693
|
-
const
|
|
18693
|
+
const _hoisted_17 = ["src"];
|
|
18694
|
+
const _hoisted_18 = { class: "p-1 flex column hover fileUploadPlaceHolder justify-content-center mb-05" };
|
|
18694
18695
|
const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
18695
18696
|
__name: "FileUpload",
|
|
18696
|
-
props: {
|
|
18697
|
+
props: /* @__PURE__ */ vue.mergeModels({
|
|
18697
18698
|
label: {},
|
|
18698
18699
|
multiple: { type: Boolean },
|
|
18699
18700
|
files: {},
|
|
@@ -18707,44 +18708,62 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18707
18708
|
theme: {},
|
|
18708
18709
|
accept: {},
|
|
18709
18710
|
required: { type: Boolean }
|
|
18710
|
-
},
|
|
18711
|
-
|
|
18711
|
+
}, {
|
|
18712
|
+
"modelValue": { default: () => [] },
|
|
18713
|
+
"modelModifiers": {}
|
|
18714
|
+
}),
|
|
18715
|
+
emits: /* @__PURE__ */ vue.mergeModels(["update:modelValue", "addFileStart"], ["update:modelValue"]),
|
|
18712
18716
|
setup(__props, { emit: __emit }) {
|
|
18713
18717
|
const props2 = __props;
|
|
18714
18718
|
const emit2 = __emit;
|
|
18715
18719
|
const bindKey2 = props2.bindkey || "id";
|
|
18716
18720
|
const bagel = useBagel();
|
|
18717
18721
|
const isImage = (str) => IMAGE_FORMATS_REGEXP.test(str);
|
|
18718
|
-
|
|
18722
|
+
const file_bindkeys = vue.useModel(__props, "modelValue");
|
|
18719
18723
|
const storageFiles = vue.ref([]);
|
|
18720
|
-
async function
|
|
18724
|
+
async function fetchTopicFiles() {
|
|
18721
18725
|
const files = await bagel.get(`/files?topic=${props2.topic}`);
|
|
18722
18726
|
storageFiles.value.push(...files);
|
|
18723
18727
|
}
|
|
18724
|
-
|
|
18725
|
-
|
|
18726
|
-
if (!
|
|
18727
|
-
|
|
18728
|
-
|
|
18729
|
-
|
|
18730
|
-
|
|
18731
|
-
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
|
|
18735
|
-
if (
|
|
18736
|
-
|
|
18737
|
-
|
|
18738
|
-
|
|
18739
|
-
|
|
18740
|
-
|
|
18741
|
-
|
|
18742
|
-
|
|
18728
|
+
function loadFiles() {
|
|
18729
|
+
const ids = [file_bindkeys.value].flat().filter(Boolean);
|
|
18730
|
+
if (!ids.length) {
|
|
18731
|
+
storageFiles.value.splice(0, storageFiles.value.length);
|
|
18732
|
+
return;
|
|
18733
|
+
}
|
|
18734
|
+
const currentIds = storageFiles.value.map((file) => file[bindKey2]);
|
|
18735
|
+
const idsToAdd = ids.filter((id) => !currentIds.includes(id));
|
|
18736
|
+
const idsToRemove = currentIds.filter((id) => (typeof id === "string" || typeof id === "number") && !ids.includes(id));
|
|
18737
|
+
idsToRemove.forEach((id) => {
|
|
18738
|
+
const index2 = storageFiles.value.findIndex((file) => file[bindKey2] === id);
|
|
18739
|
+
if (index2 !== -1) storageFiles.value.splice(index2, 1);
|
|
18740
|
+
});
|
|
18741
|
+
if (bindKey2 === "url") {
|
|
18742
|
+
idsToAdd.forEach((url) => {
|
|
18743
|
+
storageFiles.value.push({ url });
|
|
18744
|
+
});
|
|
18745
|
+
return;
|
|
18746
|
+
}
|
|
18747
|
+
if (props2.multiple) {
|
|
18748
|
+
idsToAdd.forEach((id) => {
|
|
18749
|
+
void bagel.get(`/files/${id}`).then((file) => {
|
|
18743
18750
|
storageFiles.value.push(file);
|
|
18744
18751
|
}).catch(console.error);
|
|
18745
|
-
}
|
|
18752
|
+
});
|
|
18753
|
+
} else {
|
|
18754
|
+
void bagel.get(`/files/${idsToAdd[0]}`).then((file) => {
|
|
18755
|
+
storageFiles.value.push(file);
|
|
18756
|
+
}).catch(console.error);
|
|
18757
|
+
}
|
|
18758
|
+
}
|
|
18759
|
+
vue.onMounted(() => {
|
|
18760
|
+
if (props2.topic) fetchTopicFiles();
|
|
18761
|
+
if (!props2.files && [file_bindkeys.value].flat().length > 0) {
|
|
18762
|
+
loadFiles();
|
|
18746
18763
|
}
|
|
18747
18764
|
});
|
|
18765
|
+
vue.watch(() => props2.topic, fetchTopicFiles);
|
|
18766
|
+
vue.watch(() => props2.modelValue, loadFiles);
|
|
18748
18767
|
vue.watch(
|
|
18749
18768
|
() => props2.files,
|
|
18750
18769
|
(newFiles) => {
|
|
@@ -18761,17 +18780,6 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18761
18780
|
function compareLists(a2, b2) {
|
|
18762
18781
|
return [a2].flat().every((id) => [b2].flat().includes(id)) && [b2].flat().every((id) => [a2].flat().includes(id));
|
|
18763
18782
|
}
|
|
18764
|
-
vue.watch(() => props2.modelValue, (newVal = []) => {
|
|
18765
|
-
console.log(newVal);
|
|
18766
|
-
const isSame = compareLists(file_bindkeys.value, newVal);
|
|
18767
|
-
if (!isSame) {
|
|
18768
|
-
file_bindkeys.value = newVal;
|
|
18769
|
-
for (const fle of storageFiles.value) {
|
|
18770
|
-
const index2 = [file_bindkeys.value].flat().findIndex((key) => fle[bindKey2] === key);
|
|
18771
|
-
if (index2 === -1) storageFiles.value.splice(index2, 1);
|
|
18772
|
-
}
|
|
18773
|
-
}
|
|
18774
|
-
});
|
|
18775
18783
|
function updateModelValue() {
|
|
18776
18784
|
let idValue;
|
|
18777
18785
|
if (props2.multiple) {
|
|
@@ -18782,7 +18790,6 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18782
18790
|
const isSame = compareLists(file_bindkeys.value, idValue);
|
|
18783
18791
|
if (!isSame) {
|
|
18784
18792
|
file_bindkeys.value = idValue;
|
|
18785
|
-
emit2("update:modelValue", file_bindkeys.value);
|
|
18786
18793
|
}
|
|
18787
18794
|
}
|
|
18788
18795
|
const fileQueue = vue.ref([]);
|
|
@@ -18851,8 +18858,8 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18851
18858
|
flushQueue();
|
|
18852
18859
|
}
|
|
18853
18860
|
return (_ctx, _cache) => {
|
|
18854
|
-
const _directive_lightbox = vue.resolveDirective("lightbox");
|
|
18855
18861
|
const _directive_tooltip = vue.resolveDirective("tooltip");
|
|
18862
|
+
const _directive_lightbox = vue.resolveDirective("lightbox");
|
|
18856
18863
|
return vue.openBlock(), vue.createElementBlock("div", _hoisted_1$v, [
|
|
18857
18864
|
vue.createElementVNode("label", null, vue.toDisplayString(_ctx.label), 1),
|
|
18858
18865
|
_ctx.required && !storageFiles.value.length ? (vue.openBlock(), vue.createElementBlock("input", _hoisted_2$l)) : vue.createCommentVNode("", true),
|
|
@@ -18864,33 +18871,68 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18864
18871
|
onDrop: drop3
|
|
18865
18872
|
}, {
|
|
18866
18873
|
default: vue.withCtx(() => [
|
|
18867
|
-
vue.
|
|
18874
|
+
!storageFiles.value.length && !fileQueue.value.length ? (vue.openBlock(), vue.createBlock(vue.unref(Btn), {
|
|
18875
|
+
key: 0,
|
|
18868
18876
|
class: "px-1-5",
|
|
18869
18877
|
icon: "upload",
|
|
18870
18878
|
outline: "",
|
|
18871
18879
|
onClick: browse
|
|
18872
18880
|
}, {
|
|
18873
|
-
default: vue.withCtx(() => _cache[
|
|
18881
|
+
default: vue.withCtx(() => _cache[2] || (_cache[2] = [
|
|
18874
18882
|
vue.createTextVNode(" Upload ")
|
|
18875
18883
|
])),
|
|
18876
18884
|
_: 1
|
|
18877
|
-
}),
|
|
18885
|
+
})) : vue.createCommentVNode("", true),
|
|
18878
18886
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(storageFiles.value, (file) => {
|
|
18879
18887
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
18880
18888
|
key: file.id,
|
|
18881
18889
|
class: "txt-gray txt-12 flex"
|
|
18882
18890
|
}, [
|
|
18883
|
-
vue.createElementVNode("
|
|
18884
|
-
|
|
18885
|
-
|
|
18886
|
-
|
|
18887
|
-
|
|
18888
|
-
|
|
18889
|
-
|
|
18890
|
-
|
|
18891
|
+
vue.createElementVNode("div", _hoisted_3$h, [
|
|
18892
|
+
vue.withDirectives(vue.createVNode(vue.unref(Btn), {
|
|
18893
|
+
color: "gray",
|
|
18894
|
+
thin: "",
|
|
18895
|
+
icon: "delete",
|
|
18896
|
+
onClick: vue.withModifiers(($event) => removeFile(file), ["stop"])
|
|
18897
|
+
}, null, 8, ["onClick"]), [
|
|
18898
|
+
[_directive_tooltip, "Delete"]
|
|
18899
|
+
]),
|
|
18900
|
+
vue.withDirectives(vue.createVNode(vue.unref(Btn), {
|
|
18901
|
+
color: "gray",
|
|
18902
|
+
thin: "",
|
|
18903
|
+
icon: "autorenew",
|
|
18904
|
+
onClick: browse
|
|
18905
|
+
}, null, 512), [
|
|
18906
|
+
[_directive_tooltip, "Replace"]
|
|
18907
|
+
]),
|
|
18908
|
+
vue.withDirectives(vue.createVNode(vue.unref(Btn), {
|
|
18909
|
+
href: file.url,
|
|
18910
|
+
download: file.name,
|
|
18911
|
+
color: "gray",
|
|
18912
|
+
thin: "",
|
|
18913
|
+
icon: "download",
|
|
18914
|
+
target: "_blank",
|
|
18915
|
+
onClick: _cache[0] || (_cache[0] = vue.withModifiers(() => {
|
|
18916
|
+
}, ["stop"]))
|
|
18917
|
+
}, null, 8, ["href", "download"]), [
|
|
18918
|
+
[_directive_tooltip, "Download"]
|
|
18919
|
+
]),
|
|
18920
|
+
vue.withDirectives((vue.openBlock(), vue.createElementBlock("p", _hoisted_4$b, [
|
|
18921
|
+
vue.createTextVNode(vue.toDisplayString(file.name), 1)
|
|
18922
|
+
])), [
|
|
18923
|
+
[_directive_lightbox, { src: file.url, download: true }]
|
|
18924
|
+
]),
|
|
18925
|
+
vue.createVNode(vue.unref(Btn), {
|
|
18926
|
+
thin: "",
|
|
18927
|
+
flat: "",
|
|
18928
|
+
icon: "delete",
|
|
18929
|
+
color: "red",
|
|
18930
|
+
onClick: vue.withModifiers(($event) => removeFile(file), ["stop"])
|
|
18931
|
+
}, null, 8, ["onClick"])
|
|
18932
|
+
])
|
|
18891
18933
|
]);
|
|
18892
18934
|
}), 128)),
|
|
18893
|
-
!storageFiles.value.length && !fileQueue.value.length ? (vue.openBlock(), vue.createElementBlock("span",
|
|
18935
|
+
!storageFiles.value.length && !fileQueue.value.length ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_5$a, " No file selected ")) : vue.createCommentVNode("", true)
|
|
18894
18936
|
]),
|
|
18895
18937
|
_: 1
|
|
18896
18938
|
})) : (vue.openBlock(), vue.createElementBlock("div", {
|
|
@@ -18910,7 +18952,7 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18910
18952
|
files: storageFiles.value,
|
|
18911
18953
|
fileQueue: fileQueue.value
|
|
18912
18954
|
}, () => [
|
|
18913
|
-
_ctx.multiple ? (vue.openBlock(), vue.createElementBlock("div",
|
|
18955
|
+
_ctx.multiple ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_6$8, [
|
|
18914
18956
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(storageFiles.value, (file) => {
|
|
18915
18957
|
return vue.withDirectives((vue.openBlock(), vue.createElementBlock("div", {
|
|
18916
18958
|
key: file.id,
|
|
@@ -18921,12 +18963,12 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18921
18963
|
class: "multi-preview",
|
|
18922
18964
|
src: file.url,
|
|
18923
18965
|
alt: ""
|
|
18924
|
-
}, null, 8,
|
|
18966
|
+
}, null, 8, _hoisted_7$5)) : (vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$c), {
|
|
18925
18967
|
key: 1,
|
|
18926
18968
|
icon: "draft",
|
|
18927
18969
|
class: "multi-preview"
|
|
18928
18970
|
})),
|
|
18929
|
-
vue.createElementVNode("p",
|
|
18971
|
+
vue.createElementVNode("p", _hoisted_8$3, vue.toDisplayString(file.name), 1),
|
|
18930
18972
|
vue.createVNode(vue.unref(Btn), {
|
|
18931
18973
|
thin: "",
|
|
18932
18974
|
flat: "",
|
|
@@ -18950,18 +18992,18 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18950
18992
|
class: "multi-preview",
|
|
18951
18993
|
src: fileToUrl(fileQ.file),
|
|
18952
18994
|
alt: ""
|
|
18953
|
-
}, null, 8,
|
|
18995
|
+
}, null, 8, _hoisted_9$2)) : vue.createCommentVNode("", true)
|
|
18954
18996
|
], 64)) : (vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$c), {
|
|
18955
18997
|
key: 1,
|
|
18956
18998
|
icon: "draft",
|
|
18957
18999
|
class: "multi-preview"
|
|
18958
19000
|
})),
|
|
18959
|
-
vue.createElementVNode("p",
|
|
19001
|
+
vue.createElementVNode("p", _hoisted_10$2, vue.toDisplayString(fileQ.name), 1),
|
|
18960
19002
|
vue.createElementVNode("div", {
|
|
18961
19003
|
class: vue.normalizeClass(["pie", { complete: fileQ.progress === 100 }]),
|
|
18962
19004
|
style: vue.normalizeStyle([`--p:${fileQ.progress}`, { "--b": "2px" }])
|
|
18963
19005
|
}, [
|
|
18964
|
-
fileQ.progress < 100 ? (vue.openBlock(), vue.createElementBlock("span",
|
|
19006
|
+
fileQ.progress < 100 ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_11$1, vue.toDisplayString(`${fileQ.progress.toFixed(0)}`), 1)) : vue.createCommentVNode("", true),
|
|
18965
19007
|
vue.createVNode(vue.unref(_sfc_main$c), {
|
|
18966
19008
|
class: "success",
|
|
18967
19009
|
icon: "check"
|
|
@@ -18970,13 +19012,13 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18970
19012
|
]);
|
|
18971
19013
|
}), 128))
|
|
18972
19014
|
])) : vue.createCommentVNode("", true),
|
|
18973
|
-
!_ctx.multiple && (storageFiles.value.length > 0 || fileQueue.value.length > 0) ? (vue.openBlock(), vue.createElementBlock("div",
|
|
19015
|
+
!_ctx.multiple && (storageFiles.value.length > 0 || fileQueue.value.length > 0) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_12$1, [
|
|
18974
19016
|
(vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(storageFiles.value, (file) => {
|
|
18975
19017
|
return vue.openBlock(), vue.createElementBlock("div", {
|
|
18976
19018
|
key: file.id,
|
|
18977
19019
|
class: vue.normalizeClass(["single-image-item-preview", { "bgl_fill-image": _ctx.fill }])
|
|
18978
19020
|
}, [
|
|
18979
|
-
vue.createElementVNode("div",
|
|
19021
|
+
vue.createElementVNode("div", _hoisted_13$1, [
|
|
18980
19022
|
vue.withDirectives(vue.createVNode(vue.unref(Btn), {
|
|
18981
19023
|
color: "gray",
|
|
18982
19024
|
thin: "",
|
|
@@ -19000,18 +19042,18 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
19000
19042
|
thin: "",
|
|
19001
19043
|
icon: "download",
|
|
19002
19044
|
target: "_blank",
|
|
19003
|
-
onClick: _cache[
|
|
19045
|
+
onClick: _cache[1] || (_cache[1] = vue.withModifiers(() => {
|
|
19004
19046
|
}, ["stop"]))
|
|
19005
19047
|
}, null, 8, ["href", "download"]), [
|
|
19006
19048
|
[_directive_tooltip, "Download"]
|
|
19007
19049
|
])
|
|
19008
19050
|
]),
|
|
19009
|
-
isImage(file.extension || file.url) ? (vue.openBlock(), vue.createElementBlock("div",
|
|
19051
|
+
isImage(file.extension || file.url) ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_14$1, [
|
|
19010
19052
|
vue.withDirectives(vue.createElementVNode("img", {
|
|
19011
19053
|
class: "single-preview",
|
|
19012
19054
|
src: file.url,
|
|
19013
19055
|
alt: ""
|
|
19014
|
-
}, null, 8,
|
|
19056
|
+
}, null, 8, _hoisted_15$1), [
|
|
19015
19057
|
[_directive_lightbox, { src: file.url, download: true }]
|
|
19016
19058
|
])
|
|
19017
19059
|
])) : vue.withDirectives((vue.openBlock(), vue.createBlock(vue.unref(_sfc_main$c), {
|
|
@@ -19034,7 +19076,7 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
19034
19076
|
class: vue.normalizeClass(["pie", { complete: fileQ.progress === 100 }]),
|
|
19035
19077
|
style: vue.normalizeStyle([`--p:${fileQ.progress}`, { "--b": "2px" }])
|
|
19036
19078
|
}, [
|
|
19037
|
-
fileQ.progress < 100 ? (vue.openBlock(), vue.createElementBlock("span",
|
|
19079
|
+
fileQ.progress < 100 ? (vue.openBlock(), vue.createElementBlock("span", _hoisted_16, vue.toDisplayString(`${fileQ.progress.toFixed(0)}`), 1)) : vue.createCommentVNode("", true),
|
|
19038
19080
|
vue.createVNode(vue.unref(_sfc_main$c), {
|
|
19039
19081
|
class: "success",
|
|
19040
19082
|
icon: "check"
|
|
@@ -19045,7 +19087,7 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
19045
19087
|
class: "single-preview",
|
|
19046
19088
|
src: fileToUrl(fileQ.file),
|
|
19047
19089
|
alt: ""
|
|
19048
|
-
}, null, 8,
|
|
19090
|
+
}, null, 8, _hoisted_17)) : vue.createCommentVNode("", true)
|
|
19049
19091
|
], 2);
|
|
19050
19092
|
}), 128))
|
|
19051
19093
|
])) : vue.createCommentVNode("", true)
|
|
@@ -19056,9 +19098,9 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
19056
19098
|
fileQueue: fileQueue.value,
|
|
19057
19099
|
browse
|
|
19058
19100
|
}, () => [
|
|
19059
|
-
vue.createElementVNode("p",
|
|
19101
|
+
vue.createElementVNode("p", _hoisted_18, [
|
|
19060
19102
|
vue.createVNode(vue.unref(_sfc_main$c), { icon: "upload_2" }),
|
|
19061
|
-
_cache[
|
|
19103
|
+
_cache[3] || (_cache[3] = vue.createTextVNode(" Drop files here or click to upload "))
|
|
19062
19104
|
])
|
|
19063
19105
|
], true) : vue.createCommentVNode("", true)
|
|
19064
19106
|
], 38))
|
|
@@ -19066,7 +19108,7 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
19066
19108
|
};
|
|
19067
19109
|
}
|
|
19068
19110
|
});
|
|
19069
|
-
const $el = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-
|
|
19111
|
+
const $el = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-30231b53"]]);
|
|
19070
19112
|
const _hoisted_1$u = ["title"];
|
|
19071
19113
|
const _hoisted_2$k = { key: 0 };
|
|
19072
19114
|
const _hoisted_3$g = ["value", "placeholder"];
|
package/dist/index.mjs
CHANGED
|
@@ -18656,42 +18656,43 @@ const _hoisted_2$l = {
|
|
|
18656
18656
|
required: "",
|
|
18657
18657
|
class: "pixel"
|
|
18658
18658
|
};
|
|
18659
|
-
const _hoisted_3$h = { class: "
|
|
18660
|
-
const _hoisted_4$b = {
|
|
18661
|
-
|
|
18659
|
+
const _hoisted_3$h = { class: "m-05 flex opacity-7 z-99" };
|
|
18660
|
+
const _hoisted_4$b = { class: "ellipsis-1 word-break-all h-20 m-0" };
|
|
18661
|
+
const _hoisted_5$a = {
|
|
18662
|
+
key: 1,
|
|
18662
18663
|
class: "txt-gray txt-12"
|
|
18663
18664
|
};
|
|
18664
|
-
const
|
|
18665
|
+
const _hoisted_6$8 = {
|
|
18665
18666
|
key: 0,
|
|
18666
18667
|
class: "bgl-multi-preview"
|
|
18667
18668
|
};
|
|
18668
|
-
const
|
|
18669
|
-
const
|
|
18670
|
-
const
|
|
18671
|
-
const
|
|
18672
|
-
const
|
|
18669
|
+
const _hoisted_7$5 = ["src"];
|
|
18670
|
+
const _hoisted_8$3 = { class: "m-0" };
|
|
18671
|
+
const _hoisted_9$2 = ["width", "src"];
|
|
18672
|
+
const _hoisted_10$2 = { class: "no-margin multi-preview-txt" };
|
|
18673
|
+
const _hoisted_11$1 = {
|
|
18673
18674
|
key: 0,
|
|
18674
18675
|
class: "progress"
|
|
18675
18676
|
};
|
|
18676
|
-
const
|
|
18677
|
+
const _hoisted_12$1 = {
|
|
18677
18678
|
key: 1,
|
|
18678
18679
|
class: "bgl-single-preview"
|
|
18679
18680
|
};
|
|
18680
|
-
const
|
|
18681
|
-
const
|
|
18681
|
+
const _hoisted_13$1 = { class: "position-start m-05 flex opacity-7 z-99" };
|
|
18682
|
+
const _hoisted_14$1 = {
|
|
18682
18683
|
key: 0,
|
|
18683
18684
|
class: "h-100"
|
|
18684
18685
|
};
|
|
18685
|
-
const
|
|
18686
|
-
const
|
|
18686
|
+
const _hoisted_15$1 = ["src"];
|
|
18687
|
+
const _hoisted_16 = {
|
|
18687
18688
|
key: 0,
|
|
18688
18689
|
class: "progress"
|
|
18689
18690
|
};
|
|
18690
|
-
const
|
|
18691
|
-
const
|
|
18691
|
+
const _hoisted_17 = ["src"];
|
|
18692
|
+
const _hoisted_18 = { class: "p-1 flex column hover fileUploadPlaceHolder justify-content-center mb-05" };
|
|
18692
18693
|
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
18693
18694
|
__name: "FileUpload",
|
|
18694
|
-
props: {
|
|
18695
|
+
props: /* @__PURE__ */ mergeModels({
|
|
18695
18696
|
label: {},
|
|
18696
18697
|
multiple: { type: Boolean },
|
|
18697
18698
|
files: {},
|
|
@@ -18705,44 +18706,62 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18705
18706
|
theme: {},
|
|
18706
18707
|
accept: {},
|
|
18707
18708
|
required: { type: Boolean }
|
|
18708
|
-
},
|
|
18709
|
-
|
|
18709
|
+
}, {
|
|
18710
|
+
"modelValue": { default: () => [] },
|
|
18711
|
+
"modelModifiers": {}
|
|
18712
|
+
}),
|
|
18713
|
+
emits: /* @__PURE__ */ mergeModels(["update:modelValue", "addFileStart"], ["update:modelValue"]),
|
|
18710
18714
|
setup(__props, { emit: __emit }) {
|
|
18711
18715
|
const props2 = __props;
|
|
18712
18716
|
const emit2 = __emit;
|
|
18713
18717
|
const bindKey2 = props2.bindkey || "id";
|
|
18714
18718
|
const bagel = useBagel();
|
|
18715
18719
|
const isImage = (str) => IMAGE_FORMATS_REGEXP.test(str);
|
|
18716
|
-
|
|
18720
|
+
const file_bindkeys = useModel(__props, "modelValue");
|
|
18717
18721
|
const storageFiles = ref([]);
|
|
18718
|
-
async function
|
|
18722
|
+
async function fetchTopicFiles() {
|
|
18719
18723
|
const files = await bagel.get(`/files?topic=${props2.topic}`);
|
|
18720
18724
|
storageFiles.value.push(...files);
|
|
18721
18725
|
}
|
|
18722
|
-
|
|
18723
|
-
|
|
18724
|
-
if (!
|
|
18725
|
-
|
|
18726
|
-
|
|
18727
|
-
|
|
18728
|
-
|
|
18729
|
-
|
|
18730
|
-
|
|
18731
|
-
|
|
18732
|
-
|
|
18733
|
-
if (
|
|
18734
|
-
|
|
18735
|
-
|
|
18736
|
-
|
|
18737
|
-
|
|
18738
|
-
|
|
18739
|
-
|
|
18740
|
-
|
|
18726
|
+
function loadFiles() {
|
|
18727
|
+
const ids = [file_bindkeys.value].flat().filter(Boolean);
|
|
18728
|
+
if (!ids.length) {
|
|
18729
|
+
storageFiles.value.splice(0, storageFiles.value.length);
|
|
18730
|
+
return;
|
|
18731
|
+
}
|
|
18732
|
+
const currentIds = storageFiles.value.map((file) => file[bindKey2]);
|
|
18733
|
+
const idsToAdd = ids.filter((id) => !currentIds.includes(id));
|
|
18734
|
+
const idsToRemove = currentIds.filter((id) => (typeof id === "string" || typeof id === "number") && !ids.includes(id));
|
|
18735
|
+
idsToRemove.forEach((id) => {
|
|
18736
|
+
const index2 = storageFiles.value.findIndex((file) => file[bindKey2] === id);
|
|
18737
|
+
if (index2 !== -1) storageFiles.value.splice(index2, 1);
|
|
18738
|
+
});
|
|
18739
|
+
if (bindKey2 === "url") {
|
|
18740
|
+
idsToAdd.forEach((url) => {
|
|
18741
|
+
storageFiles.value.push({ url });
|
|
18742
|
+
});
|
|
18743
|
+
return;
|
|
18744
|
+
}
|
|
18745
|
+
if (props2.multiple) {
|
|
18746
|
+
idsToAdd.forEach((id) => {
|
|
18747
|
+
void bagel.get(`/files/${id}`).then((file) => {
|
|
18741
18748
|
storageFiles.value.push(file);
|
|
18742
18749
|
}).catch(console.error);
|
|
18743
|
-
}
|
|
18750
|
+
});
|
|
18751
|
+
} else {
|
|
18752
|
+
void bagel.get(`/files/${idsToAdd[0]}`).then((file) => {
|
|
18753
|
+
storageFiles.value.push(file);
|
|
18754
|
+
}).catch(console.error);
|
|
18755
|
+
}
|
|
18756
|
+
}
|
|
18757
|
+
onMounted(() => {
|
|
18758
|
+
if (props2.topic) fetchTopicFiles();
|
|
18759
|
+
if (!props2.files && [file_bindkeys.value].flat().length > 0) {
|
|
18760
|
+
loadFiles();
|
|
18744
18761
|
}
|
|
18745
18762
|
});
|
|
18763
|
+
watch(() => props2.topic, fetchTopicFiles);
|
|
18764
|
+
watch(() => props2.modelValue, loadFiles);
|
|
18746
18765
|
watch(
|
|
18747
18766
|
() => props2.files,
|
|
18748
18767
|
(newFiles) => {
|
|
@@ -18759,17 +18778,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18759
18778
|
function compareLists(a2, b2) {
|
|
18760
18779
|
return [a2].flat().every((id) => [b2].flat().includes(id)) && [b2].flat().every((id) => [a2].flat().includes(id));
|
|
18761
18780
|
}
|
|
18762
|
-
watch(() => props2.modelValue, (newVal = []) => {
|
|
18763
|
-
console.log(newVal);
|
|
18764
|
-
const isSame = compareLists(file_bindkeys.value, newVal);
|
|
18765
|
-
if (!isSame) {
|
|
18766
|
-
file_bindkeys.value = newVal;
|
|
18767
|
-
for (const fle of storageFiles.value) {
|
|
18768
|
-
const index2 = [file_bindkeys.value].flat().findIndex((key) => fle[bindKey2] === key);
|
|
18769
|
-
if (index2 === -1) storageFiles.value.splice(index2, 1);
|
|
18770
|
-
}
|
|
18771
|
-
}
|
|
18772
|
-
});
|
|
18773
18781
|
function updateModelValue() {
|
|
18774
18782
|
let idValue;
|
|
18775
18783
|
if (props2.multiple) {
|
|
@@ -18780,7 +18788,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18780
18788
|
const isSame = compareLists(file_bindkeys.value, idValue);
|
|
18781
18789
|
if (!isSame) {
|
|
18782
18790
|
file_bindkeys.value = idValue;
|
|
18783
|
-
emit2("update:modelValue", file_bindkeys.value);
|
|
18784
18791
|
}
|
|
18785
18792
|
}
|
|
18786
18793
|
const fileQueue = ref([]);
|
|
@@ -18849,8 +18856,8 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18849
18856
|
flushQueue();
|
|
18850
18857
|
}
|
|
18851
18858
|
return (_ctx, _cache) => {
|
|
18852
|
-
const _directive_lightbox = resolveDirective("lightbox");
|
|
18853
18859
|
const _directive_tooltip = resolveDirective("tooltip");
|
|
18860
|
+
const _directive_lightbox = resolveDirective("lightbox");
|
|
18854
18861
|
return openBlock(), createElementBlock("div", _hoisted_1$v, [
|
|
18855
18862
|
createElementVNode("label", null, toDisplayString(_ctx.label), 1),
|
|
18856
18863
|
_ctx.required && !storageFiles.value.length ? (openBlock(), createElementBlock("input", _hoisted_2$l)) : createCommentVNode("", true),
|
|
@@ -18862,33 +18869,68 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18862
18869
|
onDrop: drop3
|
|
18863
18870
|
}, {
|
|
18864
18871
|
default: withCtx(() => [
|
|
18865
|
-
|
|
18872
|
+
!storageFiles.value.length && !fileQueue.value.length ? (openBlock(), createBlock(unref(Btn), {
|
|
18873
|
+
key: 0,
|
|
18866
18874
|
class: "px-1-5",
|
|
18867
18875
|
icon: "upload",
|
|
18868
18876
|
outline: "",
|
|
18869
18877
|
onClick: browse
|
|
18870
18878
|
}, {
|
|
18871
|
-
default: withCtx(() => _cache[
|
|
18879
|
+
default: withCtx(() => _cache[2] || (_cache[2] = [
|
|
18872
18880
|
createTextVNode(" Upload ")
|
|
18873
18881
|
])),
|
|
18874
18882
|
_: 1
|
|
18875
|
-
}),
|
|
18883
|
+
})) : createCommentVNode("", true),
|
|
18876
18884
|
(openBlock(true), createElementBlock(Fragment$1, null, renderList(storageFiles.value, (file) => {
|
|
18877
18885
|
return openBlock(), createElementBlock("div", {
|
|
18878
18886
|
key: file.id,
|
|
18879
18887
|
class: "txt-gray txt-12 flex"
|
|
18880
18888
|
}, [
|
|
18881
|
-
createElementVNode("
|
|
18882
|
-
|
|
18883
|
-
|
|
18884
|
-
|
|
18885
|
-
|
|
18886
|
-
|
|
18887
|
-
|
|
18888
|
-
|
|
18889
|
+
createElementVNode("div", _hoisted_3$h, [
|
|
18890
|
+
withDirectives(createVNode(unref(Btn), {
|
|
18891
|
+
color: "gray",
|
|
18892
|
+
thin: "",
|
|
18893
|
+
icon: "delete",
|
|
18894
|
+
onClick: withModifiers(($event) => removeFile(file), ["stop"])
|
|
18895
|
+
}, null, 8, ["onClick"]), [
|
|
18896
|
+
[_directive_tooltip, "Delete"]
|
|
18897
|
+
]),
|
|
18898
|
+
withDirectives(createVNode(unref(Btn), {
|
|
18899
|
+
color: "gray",
|
|
18900
|
+
thin: "",
|
|
18901
|
+
icon: "autorenew",
|
|
18902
|
+
onClick: browse
|
|
18903
|
+
}, null, 512), [
|
|
18904
|
+
[_directive_tooltip, "Replace"]
|
|
18905
|
+
]),
|
|
18906
|
+
withDirectives(createVNode(unref(Btn), {
|
|
18907
|
+
href: file.url,
|
|
18908
|
+
download: file.name,
|
|
18909
|
+
color: "gray",
|
|
18910
|
+
thin: "",
|
|
18911
|
+
icon: "download",
|
|
18912
|
+
target: "_blank",
|
|
18913
|
+
onClick: _cache[0] || (_cache[0] = withModifiers(() => {
|
|
18914
|
+
}, ["stop"]))
|
|
18915
|
+
}, null, 8, ["href", "download"]), [
|
|
18916
|
+
[_directive_tooltip, "Download"]
|
|
18917
|
+
]),
|
|
18918
|
+
withDirectives((openBlock(), createElementBlock("p", _hoisted_4$b, [
|
|
18919
|
+
createTextVNode(toDisplayString(file.name), 1)
|
|
18920
|
+
])), [
|
|
18921
|
+
[_directive_lightbox, { src: file.url, download: true }]
|
|
18922
|
+
]),
|
|
18923
|
+
createVNode(unref(Btn), {
|
|
18924
|
+
thin: "",
|
|
18925
|
+
flat: "",
|
|
18926
|
+
icon: "delete",
|
|
18927
|
+
color: "red",
|
|
18928
|
+
onClick: withModifiers(($event) => removeFile(file), ["stop"])
|
|
18929
|
+
}, null, 8, ["onClick"])
|
|
18930
|
+
])
|
|
18889
18931
|
]);
|
|
18890
18932
|
}), 128)),
|
|
18891
|
-
!storageFiles.value.length && !fileQueue.value.length ? (openBlock(), createElementBlock("span",
|
|
18933
|
+
!storageFiles.value.length && !fileQueue.value.length ? (openBlock(), createElementBlock("span", _hoisted_5$a, " No file selected ")) : createCommentVNode("", true)
|
|
18892
18934
|
]),
|
|
18893
18935
|
_: 1
|
|
18894
18936
|
})) : (openBlock(), createElementBlock("div", {
|
|
@@ -18908,7 +18950,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18908
18950
|
files: storageFiles.value,
|
|
18909
18951
|
fileQueue: fileQueue.value
|
|
18910
18952
|
}, () => [
|
|
18911
|
-
_ctx.multiple ? (openBlock(), createElementBlock("div",
|
|
18953
|
+
_ctx.multiple ? (openBlock(), createElementBlock("div", _hoisted_6$8, [
|
|
18912
18954
|
(openBlock(true), createElementBlock(Fragment$1, null, renderList(storageFiles.value, (file) => {
|
|
18913
18955
|
return withDirectives((openBlock(), createElementBlock("div", {
|
|
18914
18956
|
key: file.id,
|
|
@@ -18919,12 +18961,12 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18919
18961
|
class: "multi-preview",
|
|
18920
18962
|
src: file.url,
|
|
18921
18963
|
alt: ""
|
|
18922
|
-
}, null, 8,
|
|
18964
|
+
}, null, 8, _hoisted_7$5)) : (openBlock(), createBlock(unref(_sfc_main$c), {
|
|
18923
18965
|
key: 1,
|
|
18924
18966
|
icon: "draft",
|
|
18925
18967
|
class: "multi-preview"
|
|
18926
18968
|
})),
|
|
18927
|
-
createElementVNode("p",
|
|
18969
|
+
createElementVNode("p", _hoisted_8$3, toDisplayString(file.name), 1),
|
|
18928
18970
|
createVNode(unref(Btn), {
|
|
18929
18971
|
thin: "",
|
|
18930
18972
|
flat: "",
|
|
@@ -18948,18 +18990,18 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18948
18990
|
class: "multi-preview",
|
|
18949
18991
|
src: fileToUrl(fileQ.file),
|
|
18950
18992
|
alt: ""
|
|
18951
|
-
}, null, 8,
|
|
18993
|
+
}, null, 8, _hoisted_9$2)) : createCommentVNode("", true)
|
|
18952
18994
|
], 64)) : (openBlock(), createBlock(unref(_sfc_main$c), {
|
|
18953
18995
|
key: 1,
|
|
18954
18996
|
icon: "draft",
|
|
18955
18997
|
class: "multi-preview"
|
|
18956
18998
|
})),
|
|
18957
|
-
createElementVNode("p",
|
|
18999
|
+
createElementVNode("p", _hoisted_10$2, toDisplayString(fileQ.name), 1),
|
|
18958
19000
|
createElementVNode("div", {
|
|
18959
19001
|
class: normalizeClass(["pie", { complete: fileQ.progress === 100 }]),
|
|
18960
19002
|
style: normalizeStyle([`--p:${fileQ.progress}`, { "--b": "2px" }])
|
|
18961
19003
|
}, [
|
|
18962
|
-
fileQ.progress < 100 ? (openBlock(), createElementBlock("span",
|
|
19004
|
+
fileQ.progress < 100 ? (openBlock(), createElementBlock("span", _hoisted_11$1, toDisplayString(`${fileQ.progress.toFixed(0)}`), 1)) : createCommentVNode("", true),
|
|
18963
19005
|
createVNode(unref(_sfc_main$c), {
|
|
18964
19006
|
class: "success",
|
|
18965
19007
|
icon: "check"
|
|
@@ -18968,13 +19010,13 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18968
19010
|
]);
|
|
18969
19011
|
}), 128))
|
|
18970
19012
|
])) : createCommentVNode("", true),
|
|
18971
|
-
!_ctx.multiple && (storageFiles.value.length > 0 || fileQueue.value.length > 0) ? (openBlock(), createElementBlock("div",
|
|
19013
|
+
!_ctx.multiple && (storageFiles.value.length > 0 || fileQueue.value.length > 0) ? (openBlock(), createElementBlock("div", _hoisted_12$1, [
|
|
18972
19014
|
(openBlock(true), createElementBlock(Fragment$1, null, renderList(storageFiles.value, (file) => {
|
|
18973
19015
|
return openBlock(), createElementBlock("div", {
|
|
18974
19016
|
key: file.id,
|
|
18975
19017
|
class: normalizeClass(["single-image-item-preview", { "bgl_fill-image": _ctx.fill }])
|
|
18976
19018
|
}, [
|
|
18977
|
-
createElementVNode("div",
|
|
19019
|
+
createElementVNode("div", _hoisted_13$1, [
|
|
18978
19020
|
withDirectives(createVNode(unref(Btn), {
|
|
18979
19021
|
color: "gray",
|
|
18980
19022
|
thin: "",
|
|
@@ -18998,18 +19040,18 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18998
19040
|
thin: "",
|
|
18999
19041
|
icon: "download",
|
|
19000
19042
|
target: "_blank",
|
|
19001
|
-
onClick: _cache[
|
|
19043
|
+
onClick: _cache[1] || (_cache[1] = withModifiers(() => {
|
|
19002
19044
|
}, ["stop"]))
|
|
19003
19045
|
}, null, 8, ["href", "download"]), [
|
|
19004
19046
|
[_directive_tooltip, "Download"]
|
|
19005
19047
|
])
|
|
19006
19048
|
]),
|
|
19007
|
-
isImage(file.extension || file.url) ? (openBlock(), createElementBlock("div",
|
|
19049
|
+
isImage(file.extension || file.url) ? (openBlock(), createElementBlock("div", _hoisted_14$1, [
|
|
19008
19050
|
withDirectives(createElementVNode("img", {
|
|
19009
19051
|
class: "single-preview",
|
|
19010
19052
|
src: file.url,
|
|
19011
19053
|
alt: ""
|
|
19012
|
-
}, null, 8,
|
|
19054
|
+
}, null, 8, _hoisted_15$1), [
|
|
19013
19055
|
[_directive_lightbox, { src: file.url, download: true }]
|
|
19014
19056
|
])
|
|
19015
19057
|
])) : withDirectives((openBlock(), createBlock(unref(_sfc_main$c), {
|
|
@@ -19032,7 +19074,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
19032
19074
|
class: normalizeClass(["pie", { complete: fileQ.progress === 100 }]),
|
|
19033
19075
|
style: normalizeStyle([`--p:${fileQ.progress}`, { "--b": "2px" }])
|
|
19034
19076
|
}, [
|
|
19035
|
-
fileQ.progress < 100 ? (openBlock(), createElementBlock("span",
|
|
19077
|
+
fileQ.progress < 100 ? (openBlock(), createElementBlock("span", _hoisted_16, toDisplayString(`${fileQ.progress.toFixed(0)}`), 1)) : createCommentVNode("", true),
|
|
19036
19078
|
createVNode(unref(_sfc_main$c), {
|
|
19037
19079
|
class: "success",
|
|
19038
19080
|
icon: "check"
|
|
@@ -19043,7 +19085,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
19043
19085
|
class: "single-preview",
|
|
19044
19086
|
src: fileToUrl(fileQ.file),
|
|
19045
19087
|
alt: ""
|
|
19046
|
-
}, null, 8,
|
|
19088
|
+
}, null, 8, _hoisted_17)) : createCommentVNode("", true)
|
|
19047
19089
|
], 2);
|
|
19048
19090
|
}), 128))
|
|
19049
19091
|
])) : createCommentVNode("", true)
|
|
@@ -19054,9 +19096,9 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
19054
19096
|
fileQueue: fileQueue.value,
|
|
19055
19097
|
browse
|
|
19056
19098
|
}, () => [
|
|
19057
|
-
createElementVNode("p",
|
|
19099
|
+
createElementVNode("p", _hoisted_18, [
|
|
19058
19100
|
createVNode(unref(_sfc_main$c), { icon: "upload_2" }),
|
|
19059
|
-
_cache[
|
|
19101
|
+
_cache[3] || (_cache[3] = createTextVNode(" Drop files here or click to upload "))
|
|
19060
19102
|
])
|
|
19061
19103
|
], true) : createCommentVNode("", true)
|
|
19062
19104
|
], 38))
|
|
@@ -19064,7 +19106,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
19064
19106
|
};
|
|
19065
19107
|
}
|
|
19066
19108
|
});
|
|
19067
|
-
const $el = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-
|
|
19109
|
+
const $el = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-30231b53"]]);
|
|
19068
19110
|
const _hoisted_1$u = ["title"];
|
|
19069
19111
|
const _hoisted_2$k = { key: 0 };
|
|
19070
19112
|
const _hoisted_3$g = ["value", "placeholder"];
|
package/dist/style.css
CHANGED
|
@@ -707,7 +707,7 @@ data[data-v-6c27f163] {
|
|
|
707
707
|
}
|
|
708
708
|
}
|
|
709
709
|
|
|
710
|
-
.fileUploadWrap[data-v-
|
|
710
|
+
.fileUploadWrap[data-v-30231b53] {
|
|
711
711
|
outline: 1px solid var(--border-color);
|
|
712
712
|
border-radius: var(--input-border-radius);
|
|
713
713
|
text-align: center;
|
|
@@ -719,7 +719,7 @@ data[data-v-6c27f163] {
|
|
|
719
719
|
background: var(--input-bg);
|
|
720
720
|
height: 215px;
|
|
721
721
|
}
|
|
722
|
-
.bagel-input .fileUploadWrap.fileDropZone[data-v-
|
|
722
|
+
.bagel-input .fileUploadWrap.fileDropZone[data-v-30231b53] {
|
|
723
723
|
background: var(--input-bg);
|
|
724
724
|
display: flex;
|
|
725
725
|
align-items: center;
|
|
@@ -727,14 +727,14 @@ data[data-v-6c27f163] {
|
|
|
727
727
|
color: var(--bgl-gray);
|
|
728
728
|
flex-direction: column;
|
|
729
729
|
}
|
|
730
|
-
.fileUploadWrap.dragover[data-v-
|
|
731
|
-
.fileUploadWrap[data-v-
|
|
730
|
+
.fileUploadWrap.dragover[data-v-30231b53],
|
|
731
|
+
.fileUploadWrap[data-v-30231b53]:hover {
|
|
732
732
|
box-shadow: inset 0 0 10px #00000012;
|
|
733
733
|
}
|
|
734
|
-
.fileUploadWrap[style*="height: auto;"][data-v-
|
|
734
|
+
.fileUploadWrap[style*="height: auto;"][data-v-30231b53] {
|
|
735
735
|
min-height: 215px;
|
|
736
736
|
}
|
|
737
|
-
.multi-image-item-preview[data-v-
|
|
737
|
+
.multi-image-item-preview[data-v-30231b53] {
|
|
738
738
|
border: 1px solid var(--border-color) !important;
|
|
739
739
|
border-radius: var(--input-border-radius);
|
|
740
740
|
margin: 0.5rem !important;
|
|
@@ -748,12 +748,12 @@ data[data-v-6c27f163] {
|
|
|
748
748
|
gap: 1rem;
|
|
749
749
|
align-items: center;
|
|
750
750
|
}
|
|
751
|
-
.multi-image-item-preview p[data-v-
|
|
751
|
+
.multi-image-item-preview p[data-v-30231b53] {
|
|
752
752
|
overflow: hidden;
|
|
753
753
|
text-overflow: ellipsis;
|
|
754
754
|
white-space: nowrap;
|
|
755
755
|
}
|
|
756
|
-
.multi-preview[data-v-
|
|
756
|
+
.multi-preview[data-v-30231b53]{
|
|
757
757
|
width: 40px;
|
|
758
758
|
height: 40px;
|
|
759
759
|
border-radius: var(--input-border-radius);
|
|
@@ -764,17 +764,17 @@ data[data-v-6c27f163] {
|
|
|
764
764
|
align-items: center;
|
|
765
765
|
display: flex;
|
|
766
766
|
}
|
|
767
|
-
.bgl-single-preview[data-v-
|
|
767
|
+
.bgl-single-preview[data-v-30231b53]{
|
|
768
768
|
height: 100%;
|
|
769
769
|
position: relative;
|
|
770
770
|
}
|
|
771
|
-
.bgl-single-preview + .fileUploadPlaceHolder[data-v-
|
|
771
|
+
.bgl-single-preview + .fileUploadPlaceHolder[data-v-30231b53]{
|
|
772
772
|
position: absolute;
|
|
773
773
|
inset: 0;
|
|
774
774
|
margin: auto;
|
|
775
775
|
top: calc(50% - 2rem);
|
|
776
776
|
}
|
|
777
|
-
.single-image-item-preview[data-v-
|
|
777
|
+
.single-image-item-preview[data-v-30231b53] {
|
|
778
778
|
height: 100%;
|
|
779
779
|
min-height: 100%;
|
|
780
780
|
position: relative;
|
|
@@ -782,13 +782,13 @@ data[data-v-6c27f163] {
|
|
|
782
782
|
align-items: center;
|
|
783
783
|
justify-content: center;
|
|
784
784
|
}
|
|
785
|
-
.fileUploadWrap[style*="height: auto"] .single-image-item-preview[data-v-
|
|
785
|
+
.fileUploadWrap[style*="height: auto"] .single-image-item-preview[data-v-30231b53] {
|
|
786
786
|
min-height: 215px;
|
|
787
787
|
}
|
|
788
|
-
.fileUploadWrap[style*="height: auto"] .single-preview[data-v-
|
|
788
|
+
.fileUploadWrap[style*="height: auto"] .single-preview[data-v-30231b53] {
|
|
789
789
|
margin: 0rem !important;
|
|
790
790
|
}
|
|
791
|
-
.single-preview[data-v-
|
|
791
|
+
.single-preview[data-v-30231b53]{
|
|
792
792
|
border-radius: var(--input-border-radius);
|
|
793
793
|
margin: 1rem;
|
|
794
794
|
padding: 0px;
|
|
@@ -797,7 +797,7 @@ data[data-v-6c27f163] {
|
|
|
797
797
|
object-fit: cover;
|
|
798
798
|
background: var(--bgl-gray-light);
|
|
799
799
|
}
|
|
800
|
-
.single-image-item-preview[data-v-
|
|
800
|
+
.single-image-item-preview[data-v-30231b53]:hover::after{
|
|
801
801
|
content: "zoom_in";
|
|
802
802
|
font-size: 32px;
|
|
803
803
|
font-family: "Material Symbols Outlined", serif;
|
|
@@ -807,20 +807,20 @@ data[data-v-6c27f163] {
|
|
|
807
807
|
z-index: 9;
|
|
808
808
|
pointer-events: none;
|
|
809
809
|
}
|
|
810
|
-
.single-image-item-preview:hover img[data-v-
|
|
810
|
+
.single-image-item-preview:hover img[data-v-30231b53]{
|
|
811
811
|
filter: brightness(70%);
|
|
812
812
|
}
|
|
813
|
-
.bgl_fill-image.single-image-item-preview[data-v-
|
|
813
|
+
.bgl_fill-image.single-image-item-preview[data-v-30231b53] {
|
|
814
814
|
height: 100%;
|
|
815
815
|
}
|
|
816
|
-
.bgl_fill-image.single-image-item-preview .single-preview[data-v-
|
|
816
|
+
.bgl_fill-image.single-image-item-preview .single-preview[data-v-30231b53]{
|
|
817
817
|
border-radius: unset;
|
|
818
818
|
object-fit: cover;
|
|
819
819
|
box-shadow: unset;
|
|
820
820
|
width: 100%;
|
|
821
821
|
height: auto;
|
|
822
822
|
}
|
|
823
|
-
.single-image-item-preview .pie[data-v-
|
|
823
|
+
.single-image-item-preview .pie[data-v-30231b53] {
|
|
824
824
|
transform-origin: top;
|
|
825
825
|
transform: scale(1.4);
|
|
826
826
|
position: absolute;
|
|
@@ -834,31 +834,31 @@ data[data-v-6c27f163] {
|
|
|
834
834
|
border: none !important;
|
|
835
835
|
padding: 0 !important;
|
|
836
836
|
}
|
|
837
|
-
.bgl_oval-upload[data-v-
|
|
837
|
+
.bgl_oval-upload[data-v-30231b53] {
|
|
838
838
|
border-radius: 100% !important;
|
|
839
839
|
overflow: hidden;
|
|
840
840
|
}
|
|
841
|
-
.bgl_oval-upload p[data-v-
|
|
841
|
+
.bgl_oval-upload p[data-v-30231b53] {
|
|
842
842
|
padding: 0.75rem !important;
|
|
843
843
|
font-size: 12px
|
|
844
844
|
}
|
|
845
|
-
.bgl_oval-upload .fileUploadPlaceHolder[data-v-
|
|
845
|
+
.bgl_oval-upload .fileUploadPlaceHolder[data-v-30231b53]{
|
|
846
846
|
top: 0;
|
|
847
847
|
}
|
|
848
|
-
.bgl_oval-upload .pie[data-v-
|
|
848
|
+
.bgl_oval-upload .pie[data-v-30231b53] {
|
|
849
849
|
transform: scale(1);
|
|
850
850
|
}
|
|
851
|
-
.bgl_oval-upload span.bgl_icon-font.color-primary[data-v-
|
|
851
|
+
.bgl_oval-upload span.bgl_icon-font.color-primary[data-v-30231b53] {
|
|
852
852
|
transform: scale(0.4) !important;
|
|
853
853
|
}
|
|
854
|
-
.bgl_oval-upload .single-image-item-preview[data-v-
|
|
854
|
+
.bgl_oval-upload .single-image-item-preview[data-v-30231b53]{
|
|
855
855
|
height: 100%;
|
|
856
856
|
}
|
|
857
|
-
.bgl_oval-upload .single-preview[data-v-
|
|
857
|
+
.bgl_oval-upload .single-preview[data-v-30231b53] {
|
|
858
858
|
margin: 0;
|
|
859
859
|
height: 100% !important;
|
|
860
860
|
}
|
|
861
|
-
.pie[data-v-
|
|
861
|
+
.pie[data-v-30231b53] {
|
|
862
862
|
width: 30px;
|
|
863
863
|
height: 30px;
|
|
864
864
|
position: relative;
|
|
@@ -866,7 +866,7 @@ data[data-v-6c27f163] {
|
|
|
866
866
|
align-items: center;
|
|
867
867
|
justify-content: center;
|
|
868
868
|
}
|
|
869
|
-
.pie[data-v-
|
|
869
|
+
.pie[data-v-30231b53]:before {
|
|
870
870
|
content: '';
|
|
871
871
|
position: absolute;
|
|
872
872
|
border-radius: 50%;
|
|
@@ -884,26 +884,26 @@ data[data-v-6c27f163] {
|
|
|
884
884
|
#000 calc(100% - var(--b))
|
|
885
885
|
);
|
|
886
886
|
}
|
|
887
|
-
.pie .success[data-v-
|
|
887
|
+
.pie .success[data-v-30231b53] {
|
|
888
888
|
transform: scale(0);
|
|
889
889
|
opacity: 0;
|
|
890
890
|
transition: all 0.3s ease-in-out;
|
|
891
891
|
}
|
|
892
|
-
.pie .progress[data-v-
|
|
892
|
+
.pie .progress[data-v-30231b53] {
|
|
893
893
|
position: absolute;
|
|
894
894
|
font-size: 10px;
|
|
895
895
|
}
|
|
896
|
-
.pie.complete .progress[data-v-
|
|
896
|
+
.pie.complete .progress[data-v-30231b53] {
|
|
897
897
|
display: none;
|
|
898
898
|
}
|
|
899
|
-
.pie.complete .success[data-v-
|
|
899
|
+
.pie.complete .success[data-v-30231b53] {
|
|
900
900
|
transform: scale(1.3);
|
|
901
901
|
opacity: 1;
|
|
902
902
|
}
|
|
903
|
-
.pie.complete[data-v-
|
|
903
|
+
.pie.complete[data-v-30231b53]:before {
|
|
904
904
|
background: conic-gradient(var(--bgl-green) calc(var(--p) * 1%), #0000 0);
|
|
905
905
|
}
|
|
906
|
-
.pie.complete[data-v-
|
|
906
|
+
.pie.complete[data-v-30231b53] {
|
|
907
907
|
color: var(--bgl-green);
|
|
908
908
|
}
|
|
909
909
|
|
package/package.json
CHANGED
|
@@ -38,45 +38,66 @@ interface QueueFile {
|
|
|
38
38
|
|
|
39
39
|
const isImage = (str: string) => IMAGE_FORMATS_REGEXP.test(str)
|
|
40
40
|
|
|
41
|
-
|
|
41
|
+
const file_bindkeys = defineModel('modelValue', { default: () => [] as FSValue })
|
|
42
42
|
const storageFiles = $ref<StorageFile[]>([])
|
|
43
43
|
|
|
44
|
-
async function
|
|
44
|
+
async function fetchTopicFiles() {
|
|
45
45
|
const files = await bagel.get<StorageFile[]>(`/files?topic=${props.topic}`)
|
|
46
46
|
storageFiles.push(...files)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
if (!
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
49
|
+
function loadFiles() {
|
|
50
|
+
const ids = ([file_bindkeys.value].flat().filter(Boolean) as unknown) as (string | number)[]
|
|
51
|
+
if (!ids.length) {
|
|
52
|
+
storageFiles.splice(0, storageFiles.length)
|
|
53
|
+
return
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const currentIds = storageFiles.map(file => file[bindKey])
|
|
57
|
+
const idsToAdd = ids.filter(id => !currentIds.includes(id))
|
|
58
|
+
const idsToRemove = currentIds.filter((id): id is string | number => (typeof id === 'string' || typeof id === 'number') && !ids.includes(id))
|
|
59
|
+
|
|
60
|
+
idsToRemove.forEach((id) => {
|
|
61
|
+
const index = storageFiles.findIndex(file => file[bindKey] === id)
|
|
62
|
+
if (index !== -1) storageFiles.splice(index, 1)
|
|
63
|
+
})
|
|
64
|
+
|
|
65
|
+
if (bindKey === 'url') {
|
|
66
|
+
idsToAdd.forEach((url) => {
|
|
67
|
+
storageFiles.push({ url } as StorageFile)
|
|
68
|
+
})
|
|
69
|
+
return
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (props.multiple) {
|
|
73
|
+
idsToAdd.forEach((id) => {
|
|
70
74
|
void bagel
|
|
71
|
-
.get<StorageFile>(`/files/${
|
|
75
|
+
.get<StorageFile>(`/files/${id}`)
|
|
72
76
|
.then((file) => {
|
|
73
77
|
storageFiles.push(file)
|
|
74
78
|
})
|
|
75
79
|
.catch(console.error)
|
|
76
|
-
}
|
|
80
|
+
})
|
|
81
|
+
} else {
|
|
82
|
+
void bagel
|
|
83
|
+
.get<StorageFile>(`/files/${idsToAdd[0]}`)
|
|
84
|
+
.then((file) => {
|
|
85
|
+
storageFiles.push(file)
|
|
86
|
+
})
|
|
87
|
+
.catch(console.error)
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
onMounted(() => {
|
|
92
|
+
if (props.topic) fetchTopicFiles()
|
|
93
|
+
if (!props.files && [file_bindkeys.value].flat().length > 0) {
|
|
94
|
+
loadFiles()
|
|
77
95
|
}
|
|
78
96
|
})
|
|
79
97
|
|
|
98
|
+
watch(() => props.topic, fetchTopicFiles)
|
|
99
|
+
watch(() => props.modelValue, loadFiles)
|
|
100
|
+
|
|
80
101
|
watch(
|
|
81
102
|
() => props.files,
|
|
82
103
|
(newFiles) => {
|
|
@@ -100,18 +121,6 @@ function compareLists(a: any, b: any) {
|
|
|
100
121
|
.every((id: any) => [b].flat().includes(id)) && [b].flat().every(id => [a].flat().includes(id))
|
|
101
122
|
}
|
|
102
123
|
|
|
103
|
-
watch(() => props.modelValue, (newVal: FSValue = []) => {
|
|
104
|
-
console.log(newVal)
|
|
105
|
-
const isSame = compareLists(file_bindkeys, newVal)
|
|
106
|
-
if (!isSame) {
|
|
107
|
-
file_bindkeys = newVal
|
|
108
|
-
for (const fle of storageFiles) {
|
|
109
|
-
const index = [file_bindkeys].flat().findIndex(key => fle[bindKey] === key)
|
|
110
|
-
if (index === -1) storageFiles.splice(index, 1)
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
})
|
|
114
|
-
|
|
115
124
|
function updateModelValue() {
|
|
116
125
|
let idValue: FSValue
|
|
117
126
|
if (props.multiple) {
|
|
@@ -119,10 +128,9 @@ function updateModelValue() {
|
|
|
119
128
|
} else {
|
|
120
129
|
idValue = (storageFiles[0][bindKey] as string) || ''
|
|
121
130
|
}
|
|
122
|
-
const isSame = compareLists(file_bindkeys, idValue)
|
|
131
|
+
const isSame = compareLists(file_bindkeys.value, idValue)
|
|
123
132
|
if (!isSame) {
|
|
124
|
-
file_bindkeys = idValue
|
|
125
|
-
emit('update:modelValue', file_bindkeys)
|
|
133
|
+
file_bindkeys.value = idValue
|
|
126
134
|
}
|
|
127
135
|
}
|
|
128
136
|
|
|
@@ -210,6 +218,7 @@ function drop(e: DragEvent) {
|
|
|
210
218
|
@drop="drop"
|
|
211
219
|
>
|
|
212
220
|
<Btn
|
|
221
|
+
v-if="!storageFiles.length && !fileQueue.length"
|
|
213
222
|
class="px-1-5"
|
|
214
223
|
icon="upload"
|
|
215
224
|
outline
|
|
@@ -217,17 +226,32 @@ function drop(e: DragEvent) {
|
|
|
217
226
|
>
|
|
218
227
|
Upload
|
|
219
228
|
</Btn>
|
|
229
|
+
|
|
220
230
|
<div v-for="file in storageFiles" :key="file.id" class="txt-gray txt-12 flex">
|
|
221
|
-
<
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
+
<div class="m-05 flex opacity-7 z-99">
|
|
232
|
+
<Btn v-tooltip="'Delete'" color="gray" thin icon="delete" @click.stop="removeFile(file)" />
|
|
233
|
+
<Btn
|
|
234
|
+
v-tooltip="'Replace'" color="gray" thin icon="autorenew"
|
|
235
|
+
@click="browse"
|
|
236
|
+
/>
|
|
237
|
+
<Btn
|
|
238
|
+
v-tooltip="'Download'"
|
|
239
|
+
:href="file.url" :download="file.name"
|
|
240
|
+
color="gray" thin icon="download"
|
|
241
|
+
target="_blank"
|
|
242
|
+
@click.stop
|
|
243
|
+
/>
|
|
244
|
+
<p v-lightbox="{ src: file.url, download: true }" class="ellipsis-1 word-break-all h-20 m-0">
|
|
245
|
+
{{ file.name }}
|
|
246
|
+
</p>
|
|
247
|
+
<Btn
|
|
248
|
+
thin
|
|
249
|
+
flat
|
|
250
|
+
icon="delete"
|
|
251
|
+
color="red"
|
|
252
|
+
@click.stop="removeFile(file)"
|
|
253
|
+
/>
|
|
254
|
+
</div>
|
|
231
255
|
</div>
|
|
232
256
|
<span v-if="!storageFiles.length && !fileQueue.length" class="txt-gray txt-12">
|
|
233
257
|
No file selected
|