@bagelink/vue 0.0.953 → 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 +44 -38
- package/dist/index.mjs +44 -38
- package/dist/style.css +34 -34
- package/package.json +1 -1
- package/src/components/form/inputs/FileUpload.vue +48 -40
|
@@ -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
|
@@ -18694,7 +18694,7 @@ const _hoisted_17 = ["src"];
|
|
|
18694
18694
|
const _hoisted_18 = { class: "p-1 flex column hover fileUploadPlaceHolder justify-content-center mb-05" };
|
|
18695
18695
|
const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
18696
18696
|
__name: "FileUpload",
|
|
18697
|
-
props: {
|
|
18697
|
+
props: /* @__PURE__ */ vue.mergeModels({
|
|
18698
18698
|
label: {},
|
|
18699
18699
|
multiple: { type: Boolean },
|
|
18700
18700
|
files: {},
|
|
@@ -18708,44 +18708,62 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18708
18708
|
theme: {},
|
|
18709
18709
|
accept: {},
|
|
18710
18710
|
required: { type: Boolean }
|
|
18711
|
-
},
|
|
18712
|
-
|
|
18711
|
+
}, {
|
|
18712
|
+
"modelValue": { default: () => [] },
|
|
18713
|
+
"modelModifiers": {}
|
|
18714
|
+
}),
|
|
18715
|
+
emits: /* @__PURE__ */ vue.mergeModels(["update:modelValue", "addFileStart"], ["update:modelValue"]),
|
|
18713
18716
|
setup(__props, { emit: __emit }) {
|
|
18714
18717
|
const props2 = __props;
|
|
18715
18718
|
const emit2 = __emit;
|
|
18716
18719
|
const bindKey2 = props2.bindkey || "id";
|
|
18717
18720
|
const bagel = useBagel();
|
|
18718
18721
|
const isImage = (str) => IMAGE_FORMATS_REGEXP.test(str);
|
|
18719
|
-
|
|
18722
|
+
const file_bindkeys = vue.useModel(__props, "modelValue");
|
|
18720
18723
|
const storageFiles = vue.ref([]);
|
|
18721
|
-
async function
|
|
18724
|
+
async function fetchTopicFiles() {
|
|
18722
18725
|
const files = await bagel.get(`/files?topic=${props2.topic}`);
|
|
18723
18726
|
storageFiles.value.push(...files);
|
|
18724
18727
|
}
|
|
18725
|
-
|
|
18726
|
-
|
|
18727
|
-
if (!
|
|
18728
|
-
|
|
18729
|
-
|
|
18730
|
-
|
|
18731
|
-
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
|
|
18735
|
-
|
|
18736
|
-
if (
|
|
18737
|
-
|
|
18738
|
-
|
|
18739
|
-
|
|
18740
|
-
|
|
18741
|
-
|
|
18742
|
-
|
|
18743
|
-
|
|
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) => {
|
|
18744
18750
|
storageFiles.value.push(file);
|
|
18745
18751
|
}).catch(console.error);
|
|
18746
|
-
}
|
|
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();
|
|
18747
18763
|
}
|
|
18748
18764
|
});
|
|
18765
|
+
vue.watch(() => props2.topic, fetchTopicFiles);
|
|
18766
|
+
vue.watch(() => props2.modelValue, loadFiles);
|
|
18749
18767
|
vue.watch(
|
|
18750
18768
|
() => props2.files,
|
|
18751
18769
|
(newFiles) => {
|
|
@@ -18762,17 +18780,6 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18762
18780
|
function compareLists(a2, b2) {
|
|
18763
18781
|
return [a2].flat().every((id) => [b2].flat().includes(id)) && [b2].flat().every((id) => [a2].flat().includes(id));
|
|
18764
18782
|
}
|
|
18765
|
-
vue.watch(() => props2.modelValue, (newVal = []) => {
|
|
18766
|
-
console.log(newVal, "newVal");
|
|
18767
|
-
const isSame = compareLists(file_bindkeys.value, newVal);
|
|
18768
|
-
if (!isSame) {
|
|
18769
|
-
file_bindkeys.value = newVal;
|
|
18770
|
-
for (const fle of storageFiles.value) {
|
|
18771
|
-
const index2 = [file_bindkeys.value].flat().findIndex((key) => fle[bindKey2] === key);
|
|
18772
|
-
if (index2 === -1) storageFiles.value.splice(index2, 1);
|
|
18773
|
-
}
|
|
18774
|
-
}
|
|
18775
|
-
});
|
|
18776
18783
|
function updateModelValue() {
|
|
18777
18784
|
let idValue;
|
|
18778
18785
|
if (props2.multiple) {
|
|
@@ -18783,7 +18790,6 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
18783
18790
|
const isSame = compareLists(file_bindkeys.value, idValue);
|
|
18784
18791
|
if (!isSame) {
|
|
18785
18792
|
file_bindkeys.value = idValue;
|
|
18786
|
-
emit2("update:modelValue", file_bindkeys.value);
|
|
18787
18793
|
}
|
|
18788
18794
|
}
|
|
18789
18795
|
const fileQueue = vue.ref([]);
|
|
@@ -19102,7 +19108,7 @@ const _sfc_main$D = /* @__PURE__ */ vue.defineComponent({
|
|
|
19102
19108
|
};
|
|
19103
19109
|
}
|
|
19104
19110
|
});
|
|
19105
|
-
const $el = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-
|
|
19111
|
+
const $el = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-30231b53"]]);
|
|
19106
19112
|
const _hoisted_1$u = ["title"];
|
|
19107
19113
|
const _hoisted_2$k = { key: 0 };
|
|
19108
19114
|
const _hoisted_3$g = ["value", "placeholder"];
|
package/dist/index.mjs
CHANGED
|
@@ -18692,7 +18692,7 @@ const _hoisted_17 = ["src"];
|
|
|
18692
18692
|
const _hoisted_18 = { class: "p-1 flex column hover fileUploadPlaceHolder justify-content-center mb-05" };
|
|
18693
18693
|
const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
18694
18694
|
__name: "FileUpload",
|
|
18695
|
-
props: {
|
|
18695
|
+
props: /* @__PURE__ */ mergeModels({
|
|
18696
18696
|
label: {},
|
|
18697
18697
|
multiple: { type: Boolean },
|
|
18698
18698
|
files: {},
|
|
@@ -18706,44 +18706,62 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18706
18706
|
theme: {},
|
|
18707
18707
|
accept: {},
|
|
18708
18708
|
required: { type: Boolean }
|
|
18709
|
-
},
|
|
18710
|
-
|
|
18709
|
+
}, {
|
|
18710
|
+
"modelValue": { default: () => [] },
|
|
18711
|
+
"modelModifiers": {}
|
|
18712
|
+
}),
|
|
18713
|
+
emits: /* @__PURE__ */ mergeModels(["update:modelValue", "addFileStart"], ["update:modelValue"]),
|
|
18711
18714
|
setup(__props, { emit: __emit }) {
|
|
18712
18715
|
const props2 = __props;
|
|
18713
18716
|
const emit2 = __emit;
|
|
18714
18717
|
const bindKey2 = props2.bindkey || "id";
|
|
18715
18718
|
const bagel = useBagel();
|
|
18716
18719
|
const isImage = (str) => IMAGE_FORMATS_REGEXP.test(str);
|
|
18717
|
-
|
|
18720
|
+
const file_bindkeys = useModel(__props, "modelValue");
|
|
18718
18721
|
const storageFiles = ref([]);
|
|
18719
|
-
async function
|
|
18722
|
+
async function fetchTopicFiles() {
|
|
18720
18723
|
const files = await bagel.get(`/files?topic=${props2.topic}`);
|
|
18721
18724
|
storageFiles.value.push(...files);
|
|
18722
18725
|
}
|
|
18723
|
-
|
|
18724
|
-
|
|
18725
|
-
if (!
|
|
18726
|
-
|
|
18727
|
-
|
|
18728
|
-
|
|
18729
|
-
|
|
18730
|
-
|
|
18731
|
-
|
|
18732
|
-
|
|
18733
|
-
|
|
18734
|
-
if (
|
|
18735
|
-
|
|
18736
|
-
|
|
18737
|
-
|
|
18738
|
-
|
|
18739
|
-
|
|
18740
|
-
|
|
18741
|
-
|
|
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) => {
|
|
18742
18748
|
storageFiles.value.push(file);
|
|
18743
18749
|
}).catch(console.error);
|
|
18744
|
-
}
|
|
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();
|
|
18745
18761
|
}
|
|
18746
18762
|
});
|
|
18763
|
+
watch(() => props2.topic, fetchTopicFiles);
|
|
18764
|
+
watch(() => props2.modelValue, loadFiles);
|
|
18747
18765
|
watch(
|
|
18748
18766
|
() => props2.files,
|
|
18749
18767
|
(newFiles) => {
|
|
@@ -18760,17 +18778,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18760
18778
|
function compareLists(a2, b2) {
|
|
18761
18779
|
return [a2].flat().every((id) => [b2].flat().includes(id)) && [b2].flat().every((id) => [a2].flat().includes(id));
|
|
18762
18780
|
}
|
|
18763
|
-
watch(() => props2.modelValue, (newVal = []) => {
|
|
18764
|
-
console.log(newVal, "newVal");
|
|
18765
|
-
const isSame = compareLists(file_bindkeys.value, newVal);
|
|
18766
|
-
if (!isSame) {
|
|
18767
|
-
file_bindkeys.value = newVal;
|
|
18768
|
-
for (const fle of storageFiles.value) {
|
|
18769
|
-
const index2 = [file_bindkeys.value].flat().findIndex((key) => fle[bindKey2] === key);
|
|
18770
|
-
if (index2 === -1) storageFiles.value.splice(index2, 1);
|
|
18771
|
-
}
|
|
18772
|
-
}
|
|
18773
|
-
});
|
|
18774
18781
|
function updateModelValue() {
|
|
18775
18782
|
let idValue;
|
|
18776
18783
|
if (props2.multiple) {
|
|
@@ -18781,7 +18788,6 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
18781
18788
|
const isSame = compareLists(file_bindkeys.value, idValue);
|
|
18782
18789
|
if (!isSame) {
|
|
18783
18790
|
file_bindkeys.value = idValue;
|
|
18784
|
-
emit2("update:modelValue", file_bindkeys.value);
|
|
18785
18791
|
}
|
|
18786
18792
|
}
|
|
18787
18793
|
const fileQueue = ref([]);
|
|
@@ -19100,7 +19106,7 @@ const _sfc_main$D = /* @__PURE__ */ defineComponent({
|
|
|
19100
19106
|
};
|
|
19101
19107
|
}
|
|
19102
19108
|
});
|
|
19103
|
-
const $el = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-
|
|
19109
|
+
const $el = /* @__PURE__ */ _export_sfc(_sfc_main$D, [["__scopeId", "data-v-30231b53"]]);
|
|
19104
19110
|
const _hoisted_1$u = ["title"];
|
|
19105
19111
|
const _hoisted_2$k = { key: 0 };
|
|
19106
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, '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
|
|