vlite3 1.3.9 → 1.3.11
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/components/AsyncSelect/createAsyncSelect.d.ts +44 -3
- package/components/AsyncSelect/createAsyncSelect.js +107 -76
- package/components/CommandPalette/CommandPaletteContent.vue2.js +1 -1
- package/components/CommandPalette/{CommandPaletteItem.vue2.js → CommandPaletteItem.vue.js} +1 -1
- package/components/Dropdown/DropdownBooleanItem.vue.js +6 -6
- package/components/Dropdown/DropdownItem.vue.js +17 -17
- package/components/Dropdown/DropdownMenu.vue.js +1 -1
- package/components/Dropdown/DropdownMenu.vue2.js +23 -23
- package/components/Form/Form.vue.d.ts +5 -5
- package/components/Form/Form.vue.js +2 -2
- package/components/Form/Form.vue2.js +263 -239
- package/components/Form/composables/useForm.js +57 -56
- package/components/Form/types.d.ts +12 -4
- package/components/ImportData/ImportData.vue.js +112 -109
- package/components/ImportData/ImportStep1.vue.js +28 -28
- package/components/ImportData/ImportStep3.vue.js +25 -6
- package/components/ImportData/types.d.ts +1 -0
- package/components/NavbarCommandPalette.vue.js +1 -1
- package/components/NumberInput.vue.js +1 -1
- package/components/NumberInput.vue2.js +47 -45
- package/components/Tabes/Tabes.vue.js +2 -2
- package/components/Tabes/Tabes.vue2.js +73 -71
- package/package.json +1 -1
- package/style.css +37 -1
- package/utils/functions.js +9 -5
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
import { deepClone as V, initializeFormValues as le, cleanSubmitValues as te, getNestedValue as J, evaluateConditional as
|
|
1
|
+
import { ref as S, shallowRef as H, computed as ee, watch as ae } from "vue";
|
|
2
|
+
import { deepClone as V, initializeFormValues as le, cleanSubmitValues as te, getNestedValue as J, evaluateConditional as $, setNestedValue as j, collectFileFields as se, filterNullCustomFields as ie } from "../utils/form.utils.js";
|
|
3
3
|
import { useFileUpload as oe } from "./useFileUpload.js";
|
|
4
4
|
import { $t as re } from "../../../utils/i18n.js";
|
|
5
5
|
function Fe(q) {
|
|
6
6
|
let { schema: K, values: b, isUpdate: F = !1, folderId: U, onSubmit: L } = q;
|
|
7
|
-
const { handleUploadFile: E } = oe(), n =
|
|
7
|
+
const { handleUploadFile: E } = oe(), n = S(b ? V(b) : {}), y = S({}), I = S(!1), g = S(!1), m = S({}), A = H(K), C = H(
|
|
8
8
|
b ? V(b) : {}
|
|
9
|
-
),
|
|
9
|
+
), x = ee(() => {
|
|
10
10
|
const e = A.value;
|
|
11
11
|
return e ? Array.isArray(e[0]) ? e.flat() : e : [];
|
|
12
12
|
}), D = async (e) => {
|
|
@@ -32,18 +32,18 @@ function Fe(q) {
|
|
|
32
32
|
a ? y.value[e] = a : delete y.value[e];
|
|
33
33
|
}, O = () => {
|
|
34
34
|
y.value = {};
|
|
35
|
-
},
|
|
36
|
-
const o = a ? `${a}.${e.name}` : e.name,
|
|
35
|
+
}, z = (e) => e.when ? $(e.when, N()) : !0, P = (e) => $(e.disabled, N()), W = (e) => $(e.readonly, N()), T = async (e, a = "") => {
|
|
36
|
+
const o = a ? `${a}.${e.name}` : e.name, i = M(o);
|
|
37
37
|
let s = "";
|
|
38
|
-
const
|
|
39
|
-
if (e.required && (
|
|
38
|
+
const l = e.labelI18n ? re(e.labelI18n) : typeof e.label == "string" ? e.label : e.name;
|
|
39
|
+
if (e.required && (i == null || i === "" || Array.isArray(i) && i.length === 0) && (s = `${l} is required`), !s && e.maxFileSize) {
|
|
40
40
|
const r = e.maxFileSize * 1024 * 1024;
|
|
41
|
-
if (
|
|
42
|
-
const
|
|
43
|
-
for (const f of
|
|
41
|
+
if (i != null && i !== "") {
|
|
42
|
+
const t = Array.isArray(i) ? i : [i];
|
|
43
|
+
for (const f of t) {
|
|
44
44
|
const v = f instanceof File ? f.size : f?.fileSize || f?.file?.size || f?.size;
|
|
45
45
|
if (v !== void 0 && v > r) {
|
|
46
|
-
s = `${
|
|
46
|
+
s = `${l} size must be less than ${e.maxFileSize}MB`;
|
|
47
47
|
break;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -51,13 +51,13 @@ function Fe(q) {
|
|
|
51
51
|
}
|
|
52
52
|
if (!s && (e.type === "file" || e.type === "fileUploader") && (e.props?.multiple || e.maxFiles)) {
|
|
53
53
|
const r = e.maxFiles || e.props?.maxFiles;
|
|
54
|
-
r && Array.isArray(
|
|
54
|
+
r && Array.isArray(i) && i.length > r && (s = `Maximum ${r} files allowed`);
|
|
55
55
|
}
|
|
56
56
|
if (!s && e.validation) {
|
|
57
57
|
m.value[o] = !0;
|
|
58
58
|
try {
|
|
59
59
|
s = await e.validation({
|
|
60
|
-
value:
|
|
60
|
+
value: i,
|
|
61
61
|
values: n.value,
|
|
62
62
|
globalValues: n.value,
|
|
63
63
|
isUpdate: F
|
|
@@ -69,12 +69,12 @@ function Fe(q) {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
if (s ? y.value[o] = s : delete y.value[o], e.type === "customFields" && e.props?.schema) {
|
|
72
|
-
const r = e.props.schema,
|
|
72
|
+
const r = e.props.schema, t = Array.isArray(i) ? i : [];
|
|
73
73
|
let f = !1;
|
|
74
|
-
for (let v = 0; v <
|
|
75
|
-
const d = { values:
|
|
74
|
+
for (let v = 0; v < t.length; v++) {
|
|
75
|
+
const d = { values: t[v] || {}, globalValues: n.value, isUpdate: F };
|
|
76
76
|
for (const u of r) {
|
|
77
|
-
const c = !u.when ||
|
|
77
|
+
const c = !u.when || $(u.when, d), w = $(u.disabled, d);
|
|
78
78
|
c && !w ? await T(u, `${o}.${v}`) && (f = !0) : delete y.value[`${o}.${v}.${u.name}`];
|
|
79
79
|
}
|
|
80
80
|
}
|
|
@@ -84,21 +84,22 @@ function Fe(q) {
|
|
|
84
84
|
}, G = async () => {
|
|
85
85
|
O();
|
|
86
86
|
let e = !0;
|
|
87
|
-
for (const a of
|
|
88
|
-
if (!
|
|
87
|
+
for (const a of x.value) {
|
|
88
|
+
if (!z(a) || P(a)) continue;
|
|
89
89
|
await T(a) && (e = !1);
|
|
90
90
|
}
|
|
91
91
|
return e;
|
|
92
92
|
}, X = async (e, a, o) => {
|
|
93
|
-
const
|
|
94
|
-
|
|
93
|
+
const i = x.value.filter((l) => l.name === e);
|
|
94
|
+
let s = i.find((l) => z(l));
|
|
95
|
+
if (!s && i.length > 0 && (s = i[0]), s && (!z(s) || P(s) || W(s))) {
|
|
95
96
|
console.warn(`[vlite3/useForm] Blocked attempted update to disabled/readonly/hidden field: ${e}`);
|
|
96
97
|
return;
|
|
97
98
|
}
|
|
98
|
-
if (n.value = j(n.value, e, a), g.value = !0, delete y.value[e],
|
|
99
|
+
if (n.value = j(n.value, e, a), g.value = !0, delete y.value[e], s?.updateValues) {
|
|
99
100
|
m.value[e] = !0;
|
|
100
101
|
try {
|
|
101
|
-
const
|
|
102
|
+
const l = await s.updateValues({
|
|
102
103
|
value: a,
|
|
103
104
|
// Exposing the explicitly requested value
|
|
104
105
|
values: n.value,
|
|
@@ -107,29 +108,29 @@ function Fe(q) {
|
|
|
107
108
|
isUpdate: F,
|
|
108
109
|
updateError: R
|
|
109
110
|
});
|
|
110
|
-
|
|
111
|
-
} catch (
|
|
112
|
-
console.error(`[useForm] Error in updateValues for ${e}:`,
|
|
111
|
+
l && typeof l == "object" && (n.value = { ...n.value, ...l });
|
|
112
|
+
} catch (l) {
|
|
113
|
+
console.error(`[useForm] Error in updateValues for ${e}:`, l);
|
|
113
114
|
} finally {
|
|
114
115
|
m.value[e] = !1;
|
|
115
116
|
}
|
|
116
117
|
}
|
|
117
118
|
}, Y = async () => {
|
|
118
|
-
const e = V(n.value), a = se(A.value, e, n.value, F), o = (
|
|
119
|
-
let
|
|
120
|
-
|
|
119
|
+
const e = V(n.value), a = se(A.value, e, n.value, F), o = (l, r) => {
|
|
120
|
+
let t = null;
|
|
121
|
+
l instanceof File ? t = l : l && typeof l == "object" && l.file instanceof File && (t = l.file);
|
|
121
122
|
const f = {
|
|
122
|
-
...typeof
|
|
123
|
-
fileName:
|
|
123
|
+
...typeof l == "object" ? l : {},
|
|
124
|
+
fileName: l?.fileName || t?.name || r.split("/").pop() || "unknown",
|
|
124
125
|
fileUrl: r,
|
|
125
|
-
fileType:
|
|
126
|
-
fileSize:
|
|
126
|
+
fileType: l?.fileType || t?.type || "application/octet-stream",
|
|
127
|
+
fileSize: l?.fileSize || t?.size || 0
|
|
127
128
|
};
|
|
128
129
|
return delete f.file, delete f.base64, f;
|
|
129
|
-
},
|
|
130
|
-
const { name: r, value:
|
|
131
|
-
if (
|
|
132
|
-
const d =
|
|
130
|
+
}, i = a.map(async (l) => {
|
|
131
|
+
const { name: r, value: t, field: f } = l;
|
|
132
|
+
if (l.type === "thumbnailSelector") {
|
|
133
|
+
const d = t, u = Array.isArray(d.images) ? d.images : [], c = d.thumbnail;
|
|
133
134
|
m.value[r] = !0;
|
|
134
135
|
try {
|
|
135
136
|
const w = await Promise.all(
|
|
@@ -151,13 +152,13 @@ function Fe(q) {
|
|
|
151
152
|
m.value[r] = !1;
|
|
152
153
|
}
|
|
153
154
|
}
|
|
154
|
-
const v = f.returnFileObject === !0, k = Array.isArray(
|
|
155
|
+
const v = f.returnFileObject === !0, k = Array.isArray(t) ? t.some(
|
|
155
156
|
(d) => d instanceof File || d && typeof d == "object" && d.file instanceof File
|
|
156
|
-
) :
|
|
157
|
+
) : t instanceof File || t && typeof t == "object" && t.file instanceof File;
|
|
157
158
|
k && (m.value[r] = !0);
|
|
158
159
|
try {
|
|
159
|
-
if (Array.isArray(
|
|
160
|
-
const d =
|
|
160
|
+
if (Array.isArray(t)) {
|
|
161
|
+
const d = t.map(async (c) => {
|
|
161
162
|
if (c instanceof File || c && typeof c == "object" && c.file instanceof File) {
|
|
162
163
|
const p = await E(c, U);
|
|
163
164
|
return p ? v ? o(c, p) : p : null;
|
|
@@ -170,12 +171,12 @@ function Fe(q) {
|
|
|
170
171
|
}), u = await Promise.all(d);
|
|
171
172
|
return { name: r, value: u };
|
|
172
173
|
} else {
|
|
173
|
-
if (
|
|
174
|
-
const u = await E(
|
|
174
|
+
if (t instanceof File || t && typeof t == "object" && t.file instanceof File) {
|
|
175
|
+
const u = await E(t, U);
|
|
175
176
|
if (u)
|
|
176
|
-
return { name: r, value: v ? o(
|
|
177
|
-
} else if (
|
|
178
|
-
const u = { ...
|
|
177
|
+
return { name: r, value: v ? o(t, u) : u };
|
|
178
|
+
} else if (t && typeof t == "object") {
|
|
179
|
+
const u = { ...t };
|
|
179
180
|
return delete u.file, delete u.base64, { name: r, value: u };
|
|
180
181
|
}
|
|
181
182
|
return null;
|
|
@@ -184,16 +185,16 @@ function Fe(q) {
|
|
|
184
185
|
k && (m.value[r] = !1);
|
|
185
186
|
}
|
|
186
187
|
});
|
|
187
|
-
return (await Promise.all(
|
|
188
|
-
|
|
188
|
+
return (await Promise.all(i)).forEach((l) => {
|
|
189
|
+
l && (Object.assign(e, j(e, l.name, l.value)), n.value = j(n.value, l.name, l.value));
|
|
189
190
|
}), e;
|
|
190
191
|
}, Z = (e) => {
|
|
191
192
|
const a = { ...e };
|
|
192
|
-
for (const o of
|
|
193
|
-
if (
|
|
194
|
-
const
|
|
195
|
-
if (Array.isArray(
|
|
196
|
-
const s = ie(
|
|
193
|
+
for (const o of x.value)
|
|
194
|
+
if (z(o) && o.type === "customFields" && o.props?.schema) {
|
|
195
|
+
const i = J(a, o.name);
|
|
196
|
+
if (Array.isArray(i)) {
|
|
197
|
+
const s = ie(i, o.props.schema);
|
|
197
198
|
Object.assign(a, j(a, o.name, s));
|
|
198
199
|
}
|
|
199
200
|
}
|
|
@@ -208,7 +209,7 @@ function Fe(q) {
|
|
|
208
209
|
handleFieldChange: X,
|
|
209
210
|
validateField: T,
|
|
210
211
|
validateAll: G,
|
|
211
|
-
isFieldVisible:
|
|
212
|
+
isFieldVisible: z,
|
|
212
213
|
isFieldDisabled: P,
|
|
213
214
|
isFieldReadonly: W,
|
|
214
215
|
getFieldValue: M,
|
|
@@ -241,7 +242,7 @@ function Fe(q) {
|
|
|
241
242
|
}
|
|
242
243
|
}
|
|
243
244
|
},
|
|
244
|
-
flatSchema:
|
|
245
|
+
flatSchema: x,
|
|
245
246
|
reinitialize: async (e, a) => {
|
|
246
247
|
e !== void 0 && (A.value = e), a !== void 0 && (b = a), await D(a !== void 0 ? a : b);
|
|
247
248
|
}
|
|
@@ -68,6 +68,14 @@ export type IFormUpdateValues = (context: IFormUpdateContext) => Record<string,
|
|
|
68
68
|
* When condition - controls field visibility
|
|
69
69
|
*/
|
|
70
70
|
export type IFormWhen = (context: IFormContext) => boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Group headings/description for grouped schemas.
|
|
73
|
+
* Accepts either a static `string[]` aligned to the schema groups,
|
|
74
|
+
* or a function that derives the strings from the current form context.
|
|
75
|
+
* The function form lets you react to form values (e.g. localize, pluralize,
|
|
76
|
+
* swap "Edit" vs "Create" labels based on `isUpdate`).
|
|
77
|
+
*/
|
|
78
|
+
export type IFormGroupsHeadings = string[] | ((context: IFormContext) => string[] | undefined | null);
|
|
71
79
|
/**
|
|
72
80
|
* CustomFields schema props
|
|
73
81
|
*/
|
|
@@ -178,10 +186,10 @@ export interface IFormProps {
|
|
|
178
186
|
footer?: boolean;
|
|
179
187
|
/** Grid columns (number or tailwind class) */
|
|
180
188
|
columns?: number | string;
|
|
181
|
-
/** Headings for grouped schemas */
|
|
182
|
-
groupsHeadings?:
|
|
183
|
-
/** Descriptions for grouped schemas */
|
|
184
|
-
groupHeadingsDescription?:
|
|
189
|
+
/** Headings for grouped schemas — static array or `(ctx) => string[]` */
|
|
190
|
+
groupsHeadings?: IFormGroupsHeadings;
|
|
191
|
+
/** Descriptions for grouped schemas — static array or `(ctx) => string[]` */
|
|
192
|
+
groupHeadingsDescription?: IFormGroupsHeadings;
|
|
185
193
|
/** Timeline steps for multi-step form mode */
|
|
186
194
|
tabs?: IFormStep[];
|
|
187
195
|
/** Submit button text */
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { defineComponent as ne, computed as h, ref as
|
|
1
|
+
import { defineComponent as ne, computed as h, ref as y, shallowRef as $, openBlock as n, createBlock as d, withCtx as b, createElementVNode as B, createTextVNode as U, toDisplayString as _, createElementBlock as N, createCommentVNode as T, createVNode as ue, unref as pe, Fragment as ce, renderList as de, renderSlot as ve } from "vue";
|
|
2
2
|
import me from "../Modal.vue.js";
|
|
3
3
|
import I from "../Button.vue.js";
|
|
4
4
|
import fe from "../Timeline/Timeline.vue.js";
|
|
5
5
|
import "@iconify/vue";
|
|
6
|
-
import { $t as
|
|
6
|
+
import { $t as E } from "../../utils/i18n.js";
|
|
7
7
|
import "../../core/config.js";
|
|
8
8
|
import he from "./ImportStep1.vue.js";
|
|
9
9
|
import ge from "./ImportStep2.vue.js";
|
|
10
|
-
import
|
|
11
|
-
import
|
|
12
|
-
import { showToast as
|
|
13
|
-
const
|
|
10
|
+
import ye from "./ImportStep3.vue.js";
|
|
11
|
+
import be from "./ImportStep4.vue.js";
|
|
12
|
+
import { showToast as j } from "../../composables/useNotifications.js";
|
|
13
|
+
const we = { class: "px-2" }, xe = { class: "min-h-[300px]" }, De = {
|
|
14
14
|
key: 0,
|
|
15
15
|
class: "mt-4 p-3 bg-destructive/10 border border-destructive/20 rounded-lg text-sm text-destructive"
|
|
16
16
|
}, ke = { class: "list-disc pl-5 space-y-1" }, _e = { class: "flex items-center justify-between w-full" }, Ie = { key: 1 }, ze = /* @__PURE__ */ ne({
|
|
@@ -27,23 +27,23 @@ const xe = { class: "px-2" }, ye = { class: "min-h-[300px]" }, De = {
|
|
|
27
27
|
show: { type: Boolean, default: !1 }
|
|
28
28
|
},
|
|
29
29
|
emits: ["update:show"],
|
|
30
|
-
setup(
|
|
31
|
-
const
|
|
32
|
-
get: () =>
|
|
33
|
-
set: (e) =>
|
|
34
|
-
}), c = (e,
|
|
35
|
-
const
|
|
36
|
-
return
|
|
37
|
-
},
|
|
38
|
-
if (
|
|
39
|
-
const e =
|
|
40
|
-
if (e !==
|
|
30
|
+
setup(w, { emit: K }) {
|
|
31
|
+
const i = w, L = K, A = h({
|
|
32
|
+
get: () => i.show,
|
|
33
|
+
set: (e) => L("update:show", e)
|
|
34
|
+
}), c = (e, r, u) => {
|
|
35
|
+
const a = u ? E(e, u) : E(e);
|
|
36
|
+
return a !== e ? a : r;
|
|
37
|
+
}, R = h(() => {
|
|
38
|
+
if (i.titleI18n) {
|
|
39
|
+
const e = E(i.titleI18n);
|
|
40
|
+
if (e !== i.titleI18n) return e;
|
|
41
41
|
}
|
|
42
|
-
return
|
|
43
|
-
}),
|
|
42
|
+
return i.title;
|
|
43
|
+
}), l = y(1), m = y(!1), C = $([]), v = y({}), q = y({
|
|
44
44
|
existing: "replace",
|
|
45
45
|
new: "create"
|
|
46
|
-
}),
|
|
46
|
+
}), M = y(""), O = $(null), S = $([]), F = $([]), x = y([]), V = {
|
|
47
47
|
total: 0,
|
|
48
48
|
processed: 0,
|
|
49
49
|
created: 0,
|
|
@@ -52,197 +52,200 @@ const xe = { class: "px-2" }, ye = { class: "min-h-[300px]" }, De = {
|
|
|
52
52
|
failed: 0,
|
|
53
53
|
percentage: 0,
|
|
54
54
|
errors: []
|
|
55
|
-
},
|
|
56
|
-
|
|
55
|
+
}, o = y({ ...V }), H = () => {
|
|
56
|
+
l.value = 1, m.value = !1, C.value = [], v.value = {}, q.value = { existing: "replace", new: "create" }, M.value = "", O.value = null, S.value = [], F.value = [], x.value = [], o.value = { ...V };
|
|
57
57
|
}, G = () => {
|
|
58
|
-
const e = [],
|
|
59
|
-
for (const t in
|
|
60
|
-
const p =
|
|
61
|
-
p && (
|
|
58
|
+
const e = [], r = {};
|
|
59
|
+
for (const t in v.value) {
|
|
60
|
+
const p = v.value[t];
|
|
61
|
+
p && (r[p] || (r[p] = []), r[p].push(t));
|
|
62
62
|
}
|
|
63
|
-
for (const t in
|
|
64
|
-
|
|
65
|
-
`Field "${t}" is mapped to multiple headers: ${
|
|
63
|
+
for (const t in r)
|
|
64
|
+
r[t].length > 1 && e.push(
|
|
65
|
+
`Field "${t}" is mapped to multiple headers: ${r[t].join(", ")}`
|
|
66
66
|
);
|
|
67
|
-
const u =
|
|
67
|
+
const u = i.fields.filter((t) => t.required).map((t) => t.field), a = Object.values(v.value);
|
|
68
68
|
for (const t of u)
|
|
69
|
-
if (!
|
|
70
|
-
const p =
|
|
69
|
+
if (!a.includes(t)) {
|
|
70
|
+
const p = i.fields.find((s) => s.field === t)?.title || t;
|
|
71
71
|
e.push(`Required field "${p}" is not mapped.`);
|
|
72
72
|
}
|
|
73
73
|
return e;
|
|
74
74
|
}, z = () => {
|
|
75
|
-
|
|
75
|
+
l.value === 2 && (x.value = G(), x.value.length > 0) || l.value < 4 && l.value++;
|
|
76
76
|
}, J = () => {
|
|
77
|
-
|
|
78
|
-
}, Q = (e,
|
|
79
|
-
const
|
|
80
|
-
for (const t in
|
|
81
|
-
const p =
|
|
77
|
+
l.value > 1 && !m.value && l.value--;
|
|
78
|
+
}, Q = (e, r) => e.map((u) => {
|
|
79
|
+
const a = {};
|
|
80
|
+
for (const t in r) {
|
|
81
|
+
const p = r[t];
|
|
82
82
|
if (!p) continue;
|
|
83
|
-
let
|
|
84
|
-
const g =
|
|
85
|
-
if ((
|
|
83
|
+
let s = u[t];
|
|
84
|
+
const g = i.fields.find((f) => f.field === p);
|
|
85
|
+
if ((s == null || s === "") && g?.defaultValue !== void 0 && (s = g.defaultValue), g?.expectedType && (g.expectedType === "number" && (s = Number(s) || 0), g.expectedType === "boolean" && (s = !!(s && s.toString().toLowerCase() !== "false" && s !== "0"))), g?.onMatch && (s = g.onMatch(s)), p.includes(".")) {
|
|
86
86
|
const f = p.split(".");
|
|
87
|
-
let D =
|
|
87
|
+
let D = a;
|
|
88
88
|
for (let k = 0; k < f.length - 1; k++)
|
|
89
89
|
D[f[k]] || (D[f[k]] = {}), D = D[f[k]];
|
|
90
|
-
D[f[f.length - 1]] =
|
|
90
|
+
D[f[f.length - 1]] = s;
|
|
91
91
|
} else
|
|
92
|
-
|
|
92
|
+
a[p] = s;
|
|
93
93
|
}
|
|
94
|
-
return
|
|
94
|
+
return a;
|
|
95
95
|
}), W = async () => {
|
|
96
|
-
|
|
96
|
+
m.value = !0, z();
|
|
97
97
|
try {
|
|
98
|
-
const e = Q(
|
|
99
|
-
|
|
100
|
-
const
|
|
101
|
-
for (let
|
|
102
|
-
|
|
98
|
+
const e = Q(C.value, v.value);
|
|
99
|
+
o.value = { ...V, total: e.length };
|
|
100
|
+
const r = [];
|
|
101
|
+
for (let a = 0; a < e.length; a += i.batchSize)
|
|
102
|
+
r.push(e.slice(a, a + i.batchSize));
|
|
103
103
|
const u = setInterval(() => {
|
|
104
|
-
|
|
104
|
+
o.value.percentage < 90 && (o.value.percentage += Math.floor(Math.random() * 5) + 1);
|
|
105
105
|
}, 1e3);
|
|
106
|
-
for (const
|
|
107
|
-
const t = await
|
|
108
|
-
data:
|
|
109
|
-
options: q.value
|
|
106
|
+
for (const a of r) {
|
|
107
|
+
const t = await i.processBatch({
|
|
108
|
+
data: a,
|
|
109
|
+
options: q.value,
|
|
110
|
+
mappings: v.value
|
|
110
111
|
});
|
|
111
|
-
|
|
112
|
+
o.value.processed += t.processed, o.value.created += t.created, o.value.updated += t.updated, o.value.skipped += t.skipped, o.value.failed += t.failed, o.value.errors = [...o.value.errors, ...t.errors || []], o.value.percentage = Math.min(
|
|
112
113
|
99,
|
|
113
|
-
Math.floor(
|
|
114
|
+
Math.floor(o.value.processed / o.value.total * 100)
|
|
114
115
|
);
|
|
115
116
|
}
|
|
116
|
-
clearInterval(u),
|
|
117
|
+
clearInterval(u), o.value.percentage = 100, o.value.failed === 0 ? j(c("vlite.importData.success", "Data imported successfully."), "success") : j(c("vlite.importData.partial", "Import completed with some errors."), "warning"), i?.onComplete && (typeof i.onComplete == "function" ? i.onComplete() : Array.isArray(i.onComplete) && i.onComplete.forEach((a) => {
|
|
118
|
+
typeof a == "function" && a();
|
|
119
|
+
}));
|
|
117
120
|
} catch (e) {
|
|
118
|
-
console.error(e),
|
|
121
|
+
console.error(e), j(c("vlite.importData.error", "A critical error occurred during import."), "error");
|
|
119
122
|
} finally {
|
|
120
|
-
|
|
123
|
+
m.value = !1;
|
|
121
124
|
}
|
|
122
|
-
}, X = h(() =>
|
|
125
|
+
}, X = h(() => i.fields.map((e) => ({ value: e.field, label: e.title, required: e.required }))), Y = h(() => [
|
|
123
126
|
{ id: 1, title: c("vlite.importData.stepUpload", "Upload"), icon: "lucide:upload" },
|
|
124
127
|
{ id: 2, title: c("vlite.importData.stepMapping", "Mapping"), icon: "lucide:git-pull-request" },
|
|
125
128
|
{ id: 3, title: c("vlite.importData.stepOptions", "Options"), icon: "lucide:settings-2" },
|
|
126
129
|
{ id: 4, title: c("vlite.importData.stepImport", "Import"), icon: "lucide:loader" }
|
|
127
130
|
]), Z = h(() => c("vlite.importData.btnBack", "Back")), ee = h(() => c("vlite.importData.btnNext", "Next")), te = h(() => c("vlite.importData.btnStart", "Start Import")), ae = h(() => c("vlite.importData.btnDone", "Done")), le = (e) => {
|
|
128
|
-
|
|
129
|
-
}, ie = (e) => {
|
|
130
|
-
O.value = e;
|
|
131
|
-
}, K = (e) => {
|
|
132
|
-
m.value = e;
|
|
131
|
+
M.value = e;
|
|
133
132
|
}, oe = (e) => {
|
|
133
|
+
O.value = e;
|
|
134
|
+
}, P = (e) => {
|
|
135
|
+
v.value = e;
|
|
136
|
+
}, ie = (e) => {
|
|
134
137
|
S.value = e;
|
|
135
138
|
}, re = (e) => {
|
|
136
139
|
F.value = e;
|
|
137
140
|
}, se = (e) => {
|
|
138
|
-
|
|
141
|
+
C.value = e;
|
|
139
142
|
};
|
|
140
|
-
return (e,
|
|
141
|
-
show:
|
|
142
|
-
"onUpdate:show":
|
|
143
|
-
title:
|
|
143
|
+
return (e, r) => (n(), d(me, {
|
|
144
|
+
show: A.value,
|
|
145
|
+
"onUpdate:show": r[0] || (r[0] = (u) => A.value = u),
|
|
146
|
+
title: R.value,
|
|
144
147
|
"max-width": "sm:max-w-4xl",
|
|
145
148
|
onClose: H,
|
|
146
|
-
"close-outside": !
|
|
149
|
+
"close-outside": !m.value
|
|
147
150
|
}, {
|
|
148
|
-
trigger:
|
|
151
|
+
trigger: b(() => [
|
|
149
152
|
ve(e.$slots, "trigger", {}, () => [
|
|
150
|
-
|
|
153
|
+
w.show ? T("", !0) : (n(), d(I, {
|
|
151
154
|
key: 0,
|
|
152
|
-
text:
|
|
153
|
-
icon:
|
|
155
|
+
text: w.buttonText,
|
|
156
|
+
icon: w.buttonIcon,
|
|
154
157
|
variant: "outline"
|
|
155
158
|
}, null, 8, ["text", "icon"]))
|
|
156
159
|
])
|
|
157
160
|
]),
|
|
158
|
-
default:
|
|
159
|
-
B("div",
|
|
161
|
+
default: b(({ close: u }) => [
|
|
162
|
+
B("div", we, [
|
|
160
163
|
ue(pe(fe), {
|
|
161
164
|
steps: Y.value,
|
|
162
|
-
"active-step":
|
|
165
|
+
"active-step": l.value - 1,
|
|
163
166
|
class: "mb-8"
|
|
164
167
|
}, null, 8, ["steps", "active-step"]),
|
|
165
|
-
B("div",
|
|
166
|
-
|
|
168
|
+
B("div", xe, [
|
|
169
|
+
l.value === 1 ? (n(), d(he, {
|
|
167
170
|
key: 0,
|
|
168
|
-
importMethod:
|
|
171
|
+
importMethod: M.value,
|
|
169
172
|
csvFile: O.value,
|
|
170
|
-
mappings:
|
|
171
|
-
fields:
|
|
173
|
+
mappings: v.value,
|
|
174
|
+
fields: w.fields,
|
|
172
175
|
headers: S.value,
|
|
173
176
|
preview: F.value,
|
|
174
|
-
importData:
|
|
177
|
+
importData: C.value,
|
|
175
178
|
"onUpdate:importMethod": le,
|
|
176
|
-
"onUpdate:csvFile":
|
|
177
|
-
"onUpdate:mappings":
|
|
178
|
-
"onUpdate:headers":
|
|
179
|
+
"onUpdate:csvFile": oe,
|
|
180
|
+
"onUpdate:mappings": P,
|
|
181
|
+
"onUpdate:headers": ie,
|
|
179
182
|
"onUpdate:preview": re,
|
|
180
183
|
"onUpdate:importData": se,
|
|
181
184
|
onNext: z
|
|
182
|
-
}, null, 8, ["importMethod", "csvFile", "mappings", "fields", "headers", "preview", "importData"])) :
|
|
185
|
+
}, null, 8, ["importMethod", "csvFile", "mappings", "fields", "headers", "preview", "importData"])) : l.value === 2 ? (n(), d(ge, {
|
|
183
186
|
key: 1,
|
|
184
|
-
mappings:
|
|
187
|
+
mappings: v.value,
|
|
185
188
|
headers: S.value,
|
|
186
189
|
preview: F.value,
|
|
187
190
|
availableFields: X.value,
|
|
188
|
-
"onUpdate:mappings":
|
|
189
|
-
}, null, 8, ["mappings", "headers", "preview", "availableFields"])) :
|
|
191
|
+
"onUpdate:mappings": P
|
|
192
|
+
}, null, 8, ["mappings", "headers", "preview", "availableFields"])) : l.value === 3 ? (n(), d(ye, {
|
|
190
193
|
key: 2,
|
|
191
194
|
importOptions: q.value
|
|
192
|
-
}, null, 8, ["importOptions"])) :
|
|
195
|
+
}, null, 8, ["importOptions"])) : l.value === 4 ? (n(), d(be, {
|
|
193
196
|
key: 3,
|
|
194
|
-
progress:
|
|
197
|
+
progress: o.value
|
|
195
198
|
}, null, 8, ["progress"])) : T("", !0)
|
|
196
199
|
]),
|
|
197
|
-
|
|
200
|
+
x.value.length > 0 && l.value === 2 ? (n(), N("div", De, [
|
|
198
201
|
B("ul", ke, [
|
|
199
|
-
(n(!0), N(ce, null, de(
|
|
202
|
+
(n(!0), N(ce, null, de(x.value, (a) => (n(), N("li", { key: a }, _(a), 1))), 128))
|
|
200
203
|
])
|
|
201
204
|
])) : T("", !0)
|
|
202
205
|
])
|
|
203
206
|
]),
|
|
204
|
-
footer:
|
|
207
|
+
footer: b(({ close: u }) => [
|
|
205
208
|
B("div", _e, [
|
|
206
|
-
|
|
209
|
+
l.value > 1 && l.value < 4 ? (n(), d(I, {
|
|
207
210
|
key: 0,
|
|
208
211
|
variant: "outline",
|
|
209
212
|
onClick: J,
|
|
210
|
-
disabled:
|
|
213
|
+
disabled: m.value,
|
|
211
214
|
icon: "lucide:arrow-left"
|
|
212
215
|
}, {
|
|
213
|
-
default:
|
|
216
|
+
default: b(() => [
|
|
214
217
|
U(_(Z.value), 1)
|
|
215
218
|
]),
|
|
216
219
|
_: 1
|
|
217
220
|
}, 8, ["disabled"])) : (n(), N("div", Ie)),
|
|
218
|
-
|
|
221
|
+
l.value < 3 ? (n(), d(I, {
|
|
219
222
|
key: 2,
|
|
220
223
|
variant: "primary",
|
|
221
224
|
onClick: z,
|
|
222
|
-
disabled:
|
|
225
|
+
disabled: l.value === 1 && !M.value || m.value,
|
|
223
226
|
"icon-right": "lucide:arrow-right"
|
|
224
227
|
}, {
|
|
225
|
-
default:
|
|
228
|
+
default: b(() => [
|
|
226
229
|
U(_(ee.value), 1)
|
|
227
230
|
]),
|
|
228
231
|
_: 1
|
|
229
|
-
}, 8, ["disabled"])) :
|
|
232
|
+
}, 8, ["disabled"])) : l.value === 3 ? (n(), d(I, {
|
|
230
233
|
key: 3,
|
|
231
234
|
variant: "primary",
|
|
232
235
|
icon: "lucide:play",
|
|
233
236
|
onClick: W,
|
|
234
|
-
loading:
|
|
237
|
+
loading: m.value
|
|
235
238
|
}, {
|
|
236
|
-
default:
|
|
239
|
+
default: b(() => [
|
|
237
240
|
U(_(te.value), 1)
|
|
238
241
|
]),
|
|
239
242
|
_: 1
|
|
240
|
-
}, 8, ["loading"])) :
|
|
243
|
+
}, 8, ["loading"])) : l.value === 4 && o.value.percentage >= 100 ? (n(), d(I, {
|
|
241
244
|
key: 4,
|
|
242
245
|
variant: "primary",
|
|
243
246
|
onClick: u
|
|
244
247
|
}, {
|
|
245
|
-
default:
|
|
248
|
+
default: b(() => [
|
|
246
249
|
U(_(ae.value), 1)
|
|
247
250
|
]),
|
|
248
251
|
_: 1
|