@voicenter-team/voicenter-ui-plus 3.4.1 → 3.4.3
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/library/assets/assets/sass/main.css +1 -1
- package/library/assets/components/VcFileUploader/VcFileUploaderArea.css +1 -0
- package/library/assets/components/VcFileUploader/{VcFileUploader.css → VcFileUploaderSimple.css} +1 -1
- package/library/components/VcFileUploader/VcFileUploader.vue.mjs +87 -5
- package/library/components/VcFileUploader/VcFileUploader.vue2.mjs +1 -381
- package/library/components/VcFileUploader/VcFileUploaderArea.vue.mjs +338 -0
- package/library/components/VcFileUploader/VcFileUploaderArea.vue3.mjs +5 -0
- package/library/components/VcFileUploader/VcFileUploaderSimple.vue.mjs +7 -0
- package/library/components/VcFileUploader/VcFileUploaderSimple.vue2.mjs +200 -0
- package/library/components/VcFileUploader/VcSimpleUploaderAction.vue.mjs +62 -0
- package/library/components/VcFileUploader/VcSimpleUploaderAction.vue2.mjs +4 -0
- package/library/components/VcFileUploader/VcSimpleUploaderFileList.vue.mjs +75 -0
- package/library/components/VcFileUploader/VcSimpleUploaderFileList.vue2.mjs +4 -0
- package/library/components/VcTree/VcTree.vue.mjs +8 -2
- package/library/components/VcTree/VcTreeSelect.vue.mjs +7 -1
- package/library/composables/input/useFileUploader.mjs +163 -0
- package/library/index.mjs +151 -146
- package/library/index.mjs.br +0 -0
- package/library/index.mjs.gz +0 -0
- package/library/localization/locales/en.json.mjs +2 -0
- package/library/plugin-components.gen.mjs +157 -152
- package/library/plugin.mjs +149 -144
- package/library/plugin.mjs.br +0 -0
- package/library/plugin.mjs.gz +0 -0
- package/library/style.css +4 -2
- package/library/style.css.br +0 -0
- package/library/style.css.gz +0 -0
- package/library/types/components/VcFileUploader/VcFileUploader.vue.d.ts +29 -139
- package/library/types/components/VcFileUploader/VcFileUploaderArea.vue.d.ts +122 -0
- package/library/types/components/VcFileUploader/VcFileUploaderSimple.vue.d.ts +127 -0
- package/library/types/components/VcFileUploader/VcSimpleUploaderAction.vue.d.ts +38 -0
- package/library/types/components/VcFileUploader/VcSimpleUploaderFileList.vue.d.ts +41 -0
- package/library/types/components/VcTree/VcTree.vue.d.ts +9 -0
- package/library/types/components/VcTree/VcTreeSelect.vue.d.ts +9 -0
- package/library/types/components/exports.d.ts +5 -1
- package/library/types/components.gen.d.ts +2 -0
- package/library/types/composables/input/useFileUploader.d.ts +82 -0
- package/library/types/localization/locales/en.json.d.ts +2 -0
- package/package.json +1 -1
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { defineComponent, openBlock, createBlock, withCtx, createElementBlock, Fragment, renderList, renderSlot, createVNode } from "vue";
|
|
2
|
+
import _sfc_main$2 from "../VcTag/VcTag.vue.mjs";
|
|
3
|
+
import '../../assets/components/VcDelimitedList/VcDelimitedList.css';import '../../assets/components/VcTag/VcTag.css';/* empty css */
|
|
4
|
+
import _sfc_main$1 from "../VcDelimitedList/VcDelimitedList.vue.mjs";
|
|
5
|
+
/* empty css */
|
|
6
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
7
|
+
__name: "VcSimpleUploaderFileList",
|
|
8
|
+
props: {
|
|
9
|
+
items: {},
|
|
10
|
+
maxLength: {},
|
|
11
|
+
tagMaxContentWidth: {},
|
|
12
|
+
tagIcon: {}
|
|
13
|
+
},
|
|
14
|
+
emits: ["on-close"],
|
|
15
|
+
setup(__props, { emit: __emit }) {
|
|
16
|
+
const emit = __emit;
|
|
17
|
+
function onTagClose(itemId) {
|
|
18
|
+
emit("on-close", itemId);
|
|
19
|
+
}
|
|
20
|
+
return (_ctx, _cache) => {
|
|
21
|
+
return openBlock(), createBlock(_sfc_main$1, {
|
|
22
|
+
list: __props.items,
|
|
23
|
+
limit: __props.maxLength,
|
|
24
|
+
trigger: "hover",
|
|
25
|
+
"popover-max-width": "400",
|
|
26
|
+
separator: ""
|
|
27
|
+
}, {
|
|
28
|
+
"list-item": withCtx(({ item }) => [
|
|
29
|
+
renderSlot(_ctx.$slots, "tag-item", {
|
|
30
|
+
data: item,
|
|
31
|
+
close: onTagClose
|
|
32
|
+
}, () => [
|
|
33
|
+
createVNode(_sfc_main$2, {
|
|
34
|
+
label: item.name,
|
|
35
|
+
"max-content": __props.tagMaxContentWidth,
|
|
36
|
+
icon: __props.tagIcon,
|
|
37
|
+
closable: "",
|
|
38
|
+
onOnClose: ($event) => onTagClose(item.id)
|
|
39
|
+
}, null, 8, ["label", "max-content", "icon", "onOnClose"])
|
|
40
|
+
])
|
|
41
|
+
]),
|
|
42
|
+
reference: withCtx(({ listLength }) => [
|
|
43
|
+
createVNode(_sfc_main$2, {
|
|
44
|
+
label: `+ ${listLength}`
|
|
45
|
+
}, null, 8, ["label"])
|
|
46
|
+
]),
|
|
47
|
+
"other-content": withCtx(({ list }) => [
|
|
48
|
+
(openBlock(true), createElementBlock(Fragment, null, renderList(list, (item, index) => {
|
|
49
|
+
return openBlock(), createElementBlock("div", {
|
|
50
|
+
key: index,
|
|
51
|
+
class: "flex items-center justify-start p-2"
|
|
52
|
+
}, [
|
|
53
|
+
renderSlot(_ctx.$slots, "tag-item-other", {
|
|
54
|
+
data: item,
|
|
55
|
+
close: onTagClose
|
|
56
|
+
}, () => [
|
|
57
|
+
createVNode(_sfc_main$2, {
|
|
58
|
+
label: item.name,
|
|
59
|
+
icon: __props.tagIcon,
|
|
60
|
+
"max-content": __props.tagMaxContentWidth,
|
|
61
|
+
closable: "",
|
|
62
|
+
onOnClose: ($event) => onTagClose(item.id)
|
|
63
|
+
}, null, 8, ["label", "icon", "max-content", "onOnClose"])
|
|
64
|
+
])
|
|
65
|
+
]);
|
|
66
|
+
}), 128))
|
|
67
|
+
]),
|
|
68
|
+
_: 3
|
|
69
|
+
}, 8, ["list", "limit"]);
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
export {
|
|
74
|
+
_sfc_main as default
|
|
75
|
+
};
|
|
@@ -42,7 +42,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
42
42
|
filterPrefixIconColor: { default: "" },
|
|
43
43
|
useTypes: { default: () => [] },
|
|
44
44
|
scrollHeight: { default: void 0 },
|
|
45
|
-
|
|
45
|
+
indent: { default: 18 },
|
|
46
|
+
clearFilterOnOptionsChange: { type: Boolean, default: true },
|
|
47
|
+
accordion: { type: Boolean, default: false },
|
|
48
|
+
checkStrictly: { type: Boolean, default: false }
|
|
46
49
|
},
|
|
47
50
|
emits: ["update:selectedKeys", "update:selectNode", "update:selectedNodes"],
|
|
48
51
|
setup(__props, { expose: __expose, emit: __emit }) {
|
|
@@ -322,6 +325,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
322
325
|
"filter-node-method": filterNodeFn,
|
|
323
326
|
props: elTreeProps.value,
|
|
324
327
|
"node-key": String(props.nodeKey),
|
|
328
|
+
"check-strictly": __props.checkStrictly,
|
|
329
|
+
accordion: __props.accordion,
|
|
330
|
+
indent: __props.indent,
|
|
325
331
|
"auto-expand-parent": "",
|
|
326
332
|
onCheck: handleCheck
|
|
327
333
|
}, {
|
|
@@ -345,7 +351,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
345
351
|
], 2))
|
|
346
352
|
]),
|
|
347
353
|
_: 3
|
|
348
|
-
}, 8, ["data", "empty-text", "show-checkbox", "default-expand-all", "default-expanded-keys", "default-checked-keys", "props", "node-key"])
|
|
354
|
+
}, 8, ["data", "empty-text", "show-checkbox", "default-expand-all", "default-expanded-keys", "default-checked-keys", "props", "node-key", "check-strictly", "accordion", "indent"])
|
|
349
355
|
], 4),
|
|
350
356
|
createVNode(VcLoading, {
|
|
351
357
|
active: __props.loading,
|
|
@@ -50,6 +50,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
50
50
|
useTypes: { default: () => [] },
|
|
51
51
|
returnedType: { default: "parentOnly" },
|
|
52
52
|
tagsSquare: { type: Boolean, default: false },
|
|
53
|
+
indent: { default: 18 },
|
|
54
|
+
accordion: { type: Boolean, default: false },
|
|
55
|
+
checkStrictly: { type: Boolean, default: false },
|
|
53
56
|
clearFilterOnOptionsChange: { type: Boolean, default: true },
|
|
54
57
|
id: {},
|
|
55
58
|
disabled: { type: Boolean },
|
|
@@ -330,6 +333,9 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
330
333
|
"default-checked-keys": checkedKeys.value,
|
|
331
334
|
"expanded-keys": checkedKeys.value,
|
|
332
335
|
"clear-filter-on-options-change": __props.clearFilterOnOptionsChange,
|
|
336
|
+
"check-strictly": __props.checkStrictly,
|
|
337
|
+
accordion: __props.accordion,
|
|
338
|
+
indent: __props.indent,
|
|
333
339
|
"onUpdate:selectedNodes": onSelectedNodes
|
|
334
340
|
}, createSlots({ _: 2 }, [
|
|
335
341
|
_ctx.$slots["option-label"] ? {
|
|
@@ -348,7 +354,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
348
354
|
]),
|
|
349
355
|
key: "1"
|
|
350
356
|
} : void 0
|
|
351
|
-
]), 1032, ["config", "options", "scroll-height", "empty-text", "node-key", "color", "loading", "use-types", "default-checked-keys", "expanded-keys", "clear-filter-on-options-change"])) : (openBlock(), createElementBlock("div", _hoisted_7, toDisplayString(emptyTextMessage.value), 1))
|
|
357
|
+
]), 1032, ["config", "options", "scroll-height", "empty-text", "node-key", "color", "loading", "use-types", "default-checked-keys", "expanded-keys", "clear-filter-on-options-change", "check-strictly", "accordion", "indent"])) : (openBlock(), createElementBlock("div", _hoisted_7, toDisplayString(emptyTextMessage.value), 1))
|
|
352
358
|
])
|
|
353
359
|
], 4)), [
|
|
354
360
|
[unref(ClickOutside), onClickOutside, inputFieldRef.value]
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
import { ref, computed, watch } from "vue";
|
|
2
|
+
import { getFileSize } from "../../utils/helpers.mjs";
|
|
3
|
+
import { tVU } from "../../localization/index.mjs";
|
|
4
|
+
function useFileUploader(props, emit) {
|
|
5
|
+
const items = ref([]);
|
|
6
|
+
const innerErrorText = ref("");
|
|
7
|
+
const errorText = computed(() => innerErrorText.value || props.error || "");
|
|
8
|
+
function parseFiles(files) {
|
|
9
|
+
let _files = Array.from(files);
|
|
10
|
+
if (_files.length && props.maxLength && _files.length > props.maxLength) {
|
|
11
|
+
_files = _files.slice(0, props.maxLength);
|
|
12
|
+
}
|
|
13
|
+
items.value = _files.map((item, index) => {
|
|
14
|
+
item.id = index;
|
|
15
|
+
return item;
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function toFileUploaded(file) {
|
|
19
|
+
return Object.assign(file, { File: file });
|
|
20
|
+
}
|
|
21
|
+
function fromBase64Result(item) {
|
|
22
|
+
const blob = new File([], item.name, {
|
|
23
|
+
lastModified: item.lastModified,
|
|
24
|
+
type: item.type
|
|
25
|
+
});
|
|
26
|
+
return Object.assign(blob, {
|
|
27
|
+
id: item.id,
|
|
28
|
+
File: item.File
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function convertFilesToBase64(file, id) {
|
|
32
|
+
return new Promise((resolve) => {
|
|
33
|
+
const reader = new FileReader();
|
|
34
|
+
reader.readAsDataURL(file);
|
|
35
|
+
reader.onload = () => {
|
|
36
|
+
resolve({
|
|
37
|
+
id,
|
|
38
|
+
lastModified: file.lastModified,
|
|
39
|
+
name: file.name,
|
|
40
|
+
size: file.size,
|
|
41
|
+
type: file.type,
|
|
42
|
+
File: reader.result
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
async function getFilesInBase64(files) {
|
|
48
|
+
const _arr = [];
|
|
49
|
+
let id = 0;
|
|
50
|
+
for (const file of files) {
|
|
51
|
+
const contents = await convertFilesToBase64(file, id);
|
|
52
|
+
_arr.push(contents);
|
|
53
|
+
id++;
|
|
54
|
+
}
|
|
55
|
+
return _arr;
|
|
56
|
+
}
|
|
57
|
+
function processFilesLength(files) {
|
|
58
|
+
if (props.multiple && props.maxLength && files.length > props.maxLength) {
|
|
59
|
+
innerErrorText.value = tVU.t("voicenterUi.uploader.some.file.were.concat.files.limit");
|
|
60
|
+
return files.slice(0, props.maxLength);
|
|
61
|
+
}
|
|
62
|
+
return files;
|
|
63
|
+
}
|
|
64
|
+
function processFileSize(files) {
|
|
65
|
+
if (props.multiple) {
|
|
66
|
+
const filesSizeSum = files.map((file) => file.size).reduce((sizeSum, a) => sizeSum + a, 0);
|
|
67
|
+
if (props.fileListSizeLimit && filesSizeSum > props.fileListSizeLimit) {
|
|
68
|
+
const sizeToExceed = getFileSize(props.fileListSizeLimit);
|
|
69
|
+
innerErrorText.value = tVU.t("voicenterUi.uploader.file.size.sum.should.not.exceed", {
|
|
70
|
+
value: sizeToExceed[0],
|
|
71
|
+
measure: sizeToExceed[1]
|
|
72
|
+
});
|
|
73
|
+
return [];
|
|
74
|
+
}
|
|
75
|
+
const _fileSizeLimit = props.fileSizeLimit;
|
|
76
|
+
if (_fileSizeLimit) {
|
|
77
|
+
files = files.filter((file) => {
|
|
78
|
+
if (file.size > _fileSizeLimit) {
|
|
79
|
+
innerErrorText.value = tVU.t("voicenterUi.uploader.some.files.were.concat.size.limit");
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return files;
|
|
86
|
+
} else {
|
|
87
|
+
if (!props.fileSizeLimit) return files;
|
|
88
|
+
const limitSize = getFileSize(props.fileSizeLimit);
|
|
89
|
+
const file = files[0];
|
|
90
|
+
if (file && file.size > props.fileSizeLimit) {
|
|
91
|
+
const fileSize = getFileSize(file.size);
|
|
92
|
+
innerErrorText.value = tVU.t("voicenterUi.uploader.file.size.is.but.limit.is", {
|
|
93
|
+
fileSize: fileSize[0],
|
|
94
|
+
fileMeasure: fileSize[1],
|
|
95
|
+
limitSize: limitSize[0],
|
|
96
|
+
limitMeasure: limitSize[1]
|
|
97
|
+
});
|
|
98
|
+
return [];
|
|
99
|
+
}
|
|
100
|
+
return files;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
async function getFileArray(inputFiles) {
|
|
104
|
+
let files = [];
|
|
105
|
+
files = processFilesLength(inputFiles);
|
|
106
|
+
files = processFileSize(files);
|
|
107
|
+
if (props.fileType === "base64") {
|
|
108
|
+
return await getFilesInBase64(files);
|
|
109
|
+
}
|
|
110
|
+
return files;
|
|
111
|
+
}
|
|
112
|
+
async function processFiles(rawFiles) {
|
|
113
|
+
innerErrorText.value = "";
|
|
114
|
+
if (!rawFiles.length) return;
|
|
115
|
+
const inputFiles = rawFiles.filter(Boolean).map(toFileUploaded);
|
|
116
|
+
const files = await getFileArray(inputFiles);
|
|
117
|
+
const out = files.map((item) => {
|
|
118
|
+
if (item instanceof File) {
|
|
119
|
+
return toFileUploaded(item);
|
|
120
|
+
}
|
|
121
|
+
return fromBase64Result(item);
|
|
122
|
+
});
|
|
123
|
+
emit("input", out);
|
|
124
|
+
emit("update:modelValue", out);
|
|
125
|
+
}
|
|
126
|
+
function onTagClose(index) {
|
|
127
|
+
innerErrorText.value = "";
|
|
128
|
+
const files = items.value.filter((item) => item.id !== index);
|
|
129
|
+
emit("input", files);
|
|
130
|
+
emit("update:modelValue", files);
|
|
131
|
+
}
|
|
132
|
+
function onClear() {
|
|
133
|
+
items.value = [];
|
|
134
|
+
emit("input", []);
|
|
135
|
+
emit("update:modelValue", []);
|
|
136
|
+
}
|
|
137
|
+
watch(
|
|
138
|
+
() => props.modelValue,
|
|
139
|
+
(val) => {
|
|
140
|
+
if (val) parseFiles(val);
|
|
141
|
+
}
|
|
142
|
+
);
|
|
143
|
+
watch(
|
|
144
|
+
() => props.files,
|
|
145
|
+
(val) => {
|
|
146
|
+
if (val) parseFiles(val);
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
immediate: true
|
|
150
|
+
}
|
|
151
|
+
);
|
|
152
|
+
return {
|
|
153
|
+
items,
|
|
154
|
+
errorText,
|
|
155
|
+
parseFiles,
|
|
156
|
+
processFiles,
|
|
157
|
+
onTagClose,
|
|
158
|
+
onClear
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
export {
|
|
162
|
+
useFileUploader as default
|
|
163
|
+
};
|