@gsc-basic/components 1.0.2 → 1.0.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/dist/es/index.js +43 -29
- package/dist/es/node_modules/@codemirror/autocomplete/dist/index.js +15 -15
- package/dist/es/node_modules/@codemirror/commands/dist/index.js +5 -5
- package/dist/es/node_modules/@codemirror/lang-java/dist/index.js +3 -3
- package/dist/es/node_modules/@codemirror/lang-javascript/dist/index.js +8 -8
- package/dist/es/node_modules/@codemirror/lang-json/dist/index.js +1 -1
- package/dist/es/node_modules/@codemirror/lang-python/dist/index.js +1 -1
- package/dist/es/node_modules/@codemirror/lang-sql/dist/index.js +6 -6
- package/dist/es/node_modules/@codemirror/lang-xml/dist/index.js +3 -3
- package/dist/es/node_modules/@codemirror/lang-yaml/dist/index.js +1 -1
- package/dist/es/node_modules/@codemirror/language/dist/index.js +1 -1
- package/dist/es/node_modules/@codemirror/lint/dist/index.js +7 -7
- package/dist/es/node_modules/@codemirror/search/dist/index.js +9 -9
- package/dist/es/node_modules/@codemirror/view/dist/index.js +7 -7
- package/dist/es/node_modules/@lezer/lr/dist/index.js +4 -2
- package/dist/es/node_modules/@tanstack/form-core/dist/esm/FormApi.js +146 -142
- package/dist/es/node_modules/@tanstack/vue-table/build/lib/index.js +7 -7
- package/dist/es/node_modules/@vueuse/core/dist/index.js +1 -1
- package/dist/es/node_modules/codemirror/dist/index.js +3 -3
- package/dist/es/src/Button/index.js +6 -0
- package/dist/es/src/Button/src/Button.css +1 -0
- package/dist/es/src/Button/src/Button.vue.js +41 -0
- package/dist/es/src/Button/src/Button2.css +1 -0
- package/dist/es/src/CodeEditor/src/index.css +1 -1
- package/dist/es/src/CodeEditor/src/index.vue.js +54 -51
- package/dist/es/src/CodeEditor/src/index2.css +1 -1
- package/dist/es/src/ConfigProvider/index.js +1 -2
- package/dist/es/src/ConfigProvider/src/useGlobalConfig.js +9 -9
- package/dist/es/src/Form/index.js +6 -0
- package/dist/es/src/Form/src/Form.css +1 -0
- package/dist/es/src/Form/src/Form.vue.js +208 -0
- package/dist/es/src/Form/src/styles/form.css +1 -0
- package/dist/es/src/Grid/src/Grid.css +1 -1
- package/dist/es/src/Grid/src/Grid.vue.js +77 -83
- package/dist/es/src/Grid/src/components/ActionBar.css +1 -1
- package/dist/es/src/Grid/src/components/ActionBar.vue.js +43 -36
- package/dist/es/src/Grid/src/components/CellEditor.css +1 -1
- package/dist/es/src/Grid/src/components/CellEditor.vue.js +80 -69
- package/dist/es/src/Grid/src/components/CellEditor2.css +1 -1
- package/dist/es/src/Grid/src/components/ColumnFilter.css +1 -1
- package/dist/es/src/Grid/src/components/ColumnFilter.vue.js +45 -34
- package/dist/es/src/Grid/src/components/ColumnSettings.css +1 -1
- package/dist/es/src/Grid/src/components/ColumnSettings.vue.js +72 -49
- package/dist/es/src/Grid/src/components/DataTable.css +1 -1
- package/dist/es/src/Grid/src/components/DataTable.vue.js +251 -228
- package/dist/es/src/Grid/src/components/Pager.css +1 -1
- package/dist/es/src/Grid/src/components/Pager.vue.js +40 -31
- package/dist/es/src/Grid/src/components/QueryBar.css +1 -1
- package/dist/es/src/Grid/src/components/QueryBar.vue.js +119 -147
- package/dist/es/src/Grid/src/composables/useGridTable.js +45 -44
- package/dist/es/src/Grid/src/styles/table.css +1 -0
- package/dist/es/src/Overlay/index.js +61 -0
- package/dist/es/src/Overlay/src/Message.css +1 -0
- package/dist/es/src/Overlay/src/Message.vue.js +36 -0
- package/dist/es/src/Overlay/src/Message2.css +1 -0
- package/dist/es/src/Overlay/src/Modal.css +1 -0
- package/dist/es/src/Overlay/src/Modal.vue.js +67 -0
- package/dist/es/src/Overlay/src/Modal2.css +1 -0
- package/dist/es/src/Overlay/src/Notice.css +1 -0
- package/dist/es/src/Overlay/src/Notice.vue.js +37 -0
- package/dist/es/src/Overlay/src/Notice2.css +1 -0
- package/dist/es/src/ScaleScreen/src/index.vue.js +2 -2
- package/dist/es/src/VideoBackground/src/index.vue.js +8 -8
- package/dist/es/src/index.js +39 -25
- package/dist/es/src/styles/tokens.css +1 -1
- package/dist/lib/index.js +1 -1
- package/dist/lib/node_modules/@lezer/lr/dist/index.js +1 -1
- package/dist/lib/node_modules/@tanstack/form-core/dist/esm/FormApi.js +1 -1
- package/dist/lib/src/Button/index.js +1 -0
- package/dist/lib/src/Button/src/Button.css +1 -0
- package/dist/lib/src/Button/src/Button.vue.js +1 -0
- package/dist/lib/src/Button/src/Button2.css +1 -0
- package/dist/lib/src/CodeEditor/src/index.css +1 -1
- package/dist/lib/src/CodeEditor/src/index.vue.js +1 -1
- package/dist/lib/src/CodeEditor/src/index2.css +1 -1
- package/dist/lib/src/ConfigProvider/index.js +1 -1
- package/dist/lib/src/Form/index.js +1 -0
- package/dist/lib/src/Form/src/Form.css +1 -0
- package/dist/lib/src/Form/src/Form.vue.js +1 -0
- package/dist/lib/src/Form/src/styles/form.css +1 -0
- package/dist/lib/src/Grid/src/Grid.css +1 -1
- package/dist/lib/src/Grid/src/Grid.vue.js +1 -1
- package/dist/lib/src/Grid/src/components/ActionBar.css +1 -1
- package/dist/lib/src/Grid/src/components/ActionBar.vue.js +1 -1
- package/dist/lib/src/Grid/src/components/CellEditor.css +1 -1
- package/dist/lib/src/Grid/src/components/CellEditor.vue.js +1 -1
- package/dist/lib/src/Grid/src/components/CellEditor2.css +1 -1
- package/dist/lib/src/Grid/src/components/ColumnFilter.css +1 -1
- package/dist/lib/src/Grid/src/components/ColumnFilter.vue.js +1 -1
- package/dist/lib/src/Grid/src/components/ColumnSettings.css +1 -1
- package/dist/lib/src/Grid/src/components/ColumnSettings.vue.js +1 -1
- package/dist/lib/src/Grid/src/components/DataTable.css +1 -1
- package/dist/lib/src/Grid/src/components/DataTable.vue.js +1 -1
- package/dist/lib/src/Grid/src/components/Pager.css +1 -1
- package/dist/lib/src/Grid/src/components/Pager.vue.js +1 -1
- package/dist/lib/src/Grid/src/components/QueryBar.css +1 -1
- package/dist/lib/src/Grid/src/components/QueryBar.vue.js +1 -1
- package/dist/lib/src/Grid/src/composables/useGridTable.js +1 -1
- package/dist/lib/src/Grid/src/styles/table.css +1 -0
- package/dist/lib/src/Overlay/index.js +1 -0
- package/dist/lib/src/Overlay/src/Message.css +1 -0
- package/dist/lib/src/Overlay/src/Message.vue.js +1 -0
- package/dist/lib/src/Overlay/src/Message2.css +1 -0
- package/dist/lib/src/Overlay/src/Modal.css +1 -0
- package/dist/lib/src/Overlay/src/Modal.vue.js +1 -0
- package/dist/lib/src/Overlay/src/Modal2.css +1 -0
- package/dist/lib/src/Overlay/src/Notice.css +1 -0
- package/dist/lib/src/Overlay/src/Notice.vue.js +1 -0
- package/dist/lib/src/Overlay/src/Notice2.css +1 -0
- package/dist/lib/src/index.js +1 -1
- package/dist/lib/src/styles/tokens.css +1 -1
- package/package.json +9 -9
- package/dist/es/src/Grid/src/styles/antd.css +0 -1
- package/dist/es/src/Grid/src/utils/exportCsv.js +0 -15
- package/dist/lib/src/Grid/src/styles/antd.css +0 -1
- package/dist/lib/src/Grid/src/utils/exportCsv.js +0 -3
|
@@ -32,7 +32,7 @@ class ut {
|
|
|
32
32
|
*/
|
|
33
33
|
constructor(p) {
|
|
34
34
|
this.options = {}, this.fieldInfo = {}, this.prevTransformArray = [], this.mount = () => {
|
|
35
|
-
const t = this.fieldMetaDerived.mount(),
|
|
35
|
+
const t = this.fieldMetaDerived.mount(), s = this.store.mount(), i = this.store.subscribe(() => {
|
|
36
36
|
H(this);
|
|
37
37
|
}), e = y.on(
|
|
38
38
|
"request-form-state",
|
|
@@ -54,7 +54,7 @@ class ut {
|
|
|
54
54
|
n.payload.id === this._formId && (this._devtoolsSubmissionOverride = !0, this.handleSubmit(), this._devtoolsSubmissionOverride = !1);
|
|
55
55
|
}
|
|
56
56
|
), r = () => {
|
|
57
|
-
a(), o(), e(),
|
|
57
|
+
a(), o(), e(), i(), t(), s(), y.emit("form-unmounted", {
|
|
58
58
|
id: this._formId
|
|
59
59
|
});
|
|
60
60
|
};
|
|
@@ -67,12 +67,12 @@ class ut {
|
|
|
67
67
|
}), l && this.validateSync("mount"), r;
|
|
68
68
|
}, this.update = (t) => {
|
|
69
69
|
if (!t) return;
|
|
70
|
-
const
|
|
70
|
+
const s = this.options;
|
|
71
71
|
this.options = t;
|
|
72
|
-
const
|
|
72
|
+
const i = !!t.transform?.deps?.some(
|
|
73
73
|
(a, r) => a !== this.prevTransformArray[r]
|
|
74
|
-
), e = t.defaultValues && !w(t.defaultValues,
|
|
75
|
-
!e && !o && !
|
|
74
|
+
), e = t.defaultValues && !w(t.defaultValues, s.defaultValues) && !this.state.isTouched, o = !w(t.defaultState, s.defaultState) && !this.state.isTouched;
|
|
75
|
+
!e && !o && !i || (A(() => {
|
|
76
76
|
this.baseStore.setState(
|
|
77
77
|
() => R(
|
|
78
78
|
Object.assign(
|
|
@@ -82,7 +82,7 @@ class ut {
|
|
|
82
82
|
e ? {
|
|
83
83
|
values: t.defaultValues
|
|
84
84
|
} : {},
|
|
85
|
-
|
|
85
|
+
i ? { _force_re_eval: !this.state._force_re_eval } : {}
|
|
86
86
|
)
|
|
87
87
|
)
|
|
88
88
|
);
|
|
@@ -91,9 +91,9 @@ class ut {
|
|
|
91
91
|
state: this.store.state,
|
|
92
92
|
options: this.options
|
|
93
93
|
}));
|
|
94
|
-
}, this.reset = (t,
|
|
95
|
-
const { fieldMeta:
|
|
96
|
-
t && !
|
|
94
|
+
}, this.reset = (t, s) => {
|
|
95
|
+
const { fieldMeta: i } = this.state, e = this.resetFieldMeta(i);
|
|
96
|
+
t && !s?.keepDefaultValues && (this.options = {
|
|
97
97
|
...this.options,
|
|
98
98
|
defaultValues: t
|
|
99
99
|
}), this.baseStore.setState(
|
|
@@ -104,13 +104,13 @@ class ut {
|
|
|
104
104
|
})
|
|
105
105
|
);
|
|
106
106
|
}, this.validateAllFields = async (t) => {
|
|
107
|
-
const
|
|
107
|
+
const s = [];
|
|
108
108
|
return A(() => {
|
|
109
109
|
Object.values(this.fieldInfo).forEach(
|
|
110
110
|
(e) => {
|
|
111
111
|
if (!e.instance) return;
|
|
112
112
|
const o = e.instance;
|
|
113
|
-
|
|
113
|
+
s.push(
|
|
114
114
|
// Remember, `validate` is either a sync operation or a promise
|
|
115
115
|
Promise.resolve().then(
|
|
116
116
|
() => o.validate(t, { skipFormValidation: !0 })
|
|
@@ -118,34 +118,38 @@ class ut {
|
|
|
118
118
|
), e.instance.state.meta.isTouched || e.instance.setMeta((a) => ({ ...a, isTouched: !0 }));
|
|
119
119
|
}
|
|
120
120
|
);
|
|
121
|
-
}), (await Promise.all(
|
|
122
|
-
}, this.validateArrayFieldsStartingFrom = async (t,
|
|
123
|
-
const e = this.getFieldValue(t), o = Array.isArray(e) ? Math.max(e.length - 1, 0) : null, a = [`${t}[${
|
|
124
|
-
for (let d =
|
|
121
|
+
}), (await Promise.all(s)).flat();
|
|
122
|
+
}, this.validateArrayFieldsStartingFrom = async (t, s, i) => {
|
|
123
|
+
const e = this.getFieldValue(t), o = Array.isArray(e) ? Math.max(e.length - 1, 0) : null, a = [`${t}[${s}]`];
|
|
124
|
+
for (let d = s + 1; d <= (o ?? 0); d++)
|
|
125
125
|
a.push(`${t}[${d}]`);
|
|
126
126
|
const r = Object.keys(this.fieldInfo).filter(
|
|
127
|
-
(d) => a.some((
|
|
127
|
+
(d) => a.some((h) => d.startsWith(h))
|
|
128
128
|
), l = [];
|
|
129
129
|
return A(() => {
|
|
130
130
|
r.forEach((d) => {
|
|
131
131
|
l.push(
|
|
132
|
-
Promise.resolve().then(() => this.validateField(d,
|
|
132
|
+
Promise.resolve().then(() => this.validateField(d, i))
|
|
133
133
|
);
|
|
134
134
|
});
|
|
135
135
|
}), (await Promise.all(l)).flat();
|
|
136
|
-
}, this.validateField = (t,
|
|
137
|
-
const
|
|
138
|
-
|
|
136
|
+
}, this.validateField = (t, s) => {
|
|
137
|
+
const i = this.fieldInfo[t]?.instance;
|
|
138
|
+
if (!i) {
|
|
139
|
+
const { hasErrored: e } = this.validateSync(s);
|
|
140
|
+
return e && !this.options.asyncAlways ? this.getFieldMeta(t)?.errors ?? [] : this.validateAsync(s).then(() => this.getFieldMeta(t)?.errors ?? []);
|
|
141
|
+
}
|
|
142
|
+
return i.state.meta.isTouched || i.setMeta((e) => ({ ...e, isTouched: !0 })), i.validate(s);
|
|
139
143
|
}, this.validateSync = (t) => {
|
|
140
|
-
const
|
|
144
|
+
const s = J(t, {
|
|
141
145
|
...this.options,
|
|
142
146
|
form: this,
|
|
143
147
|
validationLogic: this.options.validationLogic || z
|
|
144
148
|
});
|
|
145
|
-
let
|
|
149
|
+
let i = !1;
|
|
146
150
|
const e = {};
|
|
147
151
|
return A(() => {
|
|
148
|
-
for (const r of
|
|
152
|
+
for (const r of s) {
|
|
149
153
|
if (!r.validate) continue;
|
|
150
154
|
const l = this.runValidator({
|
|
151
155
|
validate: r.validate,
|
|
@@ -155,7 +159,7 @@ class ut {
|
|
|
155
159
|
validationSource: "form"
|
|
156
160
|
},
|
|
157
161
|
type: "validate"
|
|
158
|
-
}), { formError: n, fieldErrors: d } = k(l),
|
|
162
|
+
}), { formError: n, fieldErrors: d } = k(l), h = j(r.cause), m = /* @__PURE__ */ new Set([
|
|
159
163
|
...Object.keys(this.state.fieldMeta),
|
|
160
164
|
...Object.keys(d || {})
|
|
161
165
|
]);
|
|
@@ -164,43 +168,43 @@ class ut {
|
|
|
164
168
|
continue;
|
|
165
169
|
const S = this.getFieldMeta(v) ?? $, {
|
|
166
170
|
errorMap: M,
|
|
167
|
-
errorSourceMap:
|
|
171
|
+
errorSourceMap: c
|
|
168
172
|
} = S, V = d?.[v], { newErrorValue: F, newSource: b } = q({
|
|
169
173
|
newFormValidatorError: V,
|
|
170
174
|
isPreviousErrorFromFormValidator: (
|
|
171
175
|
// These conditional checks are required, otherwise we get runtime errors.
|
|
172
176
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
173
|
-
|
|
177
|
+
c?.[h] === "form"
|
|
174
178
|
),
|
|
175
179
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
176
|
-
previousErrorValue: M?.[
|
|
180
|
+
previousErrorValue: M?.[h]
|
|
177
181
|
});
|
|
178
182
|
b === "form" && (e[v] = {
|
|
179
183
|
...e[v],
|
|
180
|
-
[
|
|
181
|
-
}), M?.[
|
|
184
|
+
[h]: V
|
|
185
|
+
}), M?.[h] !== F && this.setFieldMeta(v, (g = $) => ({
|
|
182
186
|
...g,
|
|
183
187
|
errorMap: {
|
|
184
188
|
...g.errorMap,
|
|
185
|
-
[
|
|
189
|
+
[h]: F
|
|
186
190
|
},
|
|
187
191
|
errorSourceMap: {
|
|
188
192
|
...g.errorSourceMap,
|
|
189
|
-
[
|
|
193
|
+
[h]: b
|
|
190
194
|
}
|
|
191
195
|
}));
|
|
192
196
|
}
|
|
193
|
-
this.state.errorMap?.[
|
|
197
|
+
this.state.errorMap?.[h] !== n && this.baseStore.setState((v) => ({
|
|
194
198
|
...v,
|
|
195
199
|
errorMap: {
|
|
196
200
|
...v.errorMap,
|
|
197
|
-
[
|
|
201
|
+
[h]: n
|
|
198
202
|
}
|
|
199
|
-
})), (n || d) && (
|
|
203
|
+
})), (n || d) && (i = !0);
|
|
200
204
|
}
|
|
201
205
|
const o = j("submit");
|
|
202
206
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
203
|
-
this.state.errorMap?.[o] && t !== "submit" && !
|
|
207
|
+
this.state.errorMap?.[o] && t !== "submit" && !i && this.baseStore.setState((r) => ({
|
|
204
208
|
...r,
|
|
205
209
|
errorMap: {
|
|
206
210
|
...r.errorMap,
|
|
@@ -209,39 +213,39 @@ class ut {
|
|
|
209
213
|
}));
|
|
210
214
|
const a = j("server");
|
|
211
215
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
212
|
-
this.state.errorMap?.[a] && t !== "server" && !
|
|
216
|
+
this.state.errorMap?.[a] && t !== "server" && !i && this.baseStore.setState((r) => ({
|
|
213
217
|
...r,
|
|
214
218
|
errorMap: {
|
|
215
219
|
...r.errorMap,
|
|
216
220
|
[a]: void 0
|
|
217
221
|
}
|
|
218
222
|
}));
|
|
219
|
-
}), { hasErrored:
|
|
223
|
+
}), { hasErrored: i, fieldsErrorMap: e };
|
|
220
224
|
}, this.validateAsync = async (t) => {
|
|
221
|
-
const
|
|
225
|
+
const s = Q(t, {
|
|
222
226
|
...this.options,
|
|
223
227
|
form: this,
|
|
224
228
|
validationLogic: this.options.validationLogic || z
|
|
225
229
|
});
|
|
226
230
|
this.state.isFormValidating || this.baseStore.setState((r) => ({ ...r, isFormValidating: !0 }));
|
|
227
|
-
const
|
|
231
|
+
const i = [];
|
|
228
232
|
let e;
|
|
229
|
-
for (const r of
|
|
233
|
+
for (const r of s) {
|
|
230
234
|
if (!r.validate) continue;
|
|
231
235
|
const l = j(r.cause);
|
|
232
236
|
this.state.validationMetaMap[l]?.lastAbortController.abort();
|
|
233
237
|
const d = new AbortController();
|
|
234
238
|
this.state.validationMetaMap[l] = {
|
|
235
239
|
lastAbortController: d
|
|
236
|
-
},
|
|
237
|
-
new Promise(async (
|
|
240
|
+
}, i.push(
|
|
241
|
+
new Promise(async (h) => {
|
|
238
242
|
let m;
|
|
239
243
|
try {
|
|
240
|
-
m = await new Promise((
|
|
244
|
+
m = await new Promise((c, V) => {
|
|
241
245
|
setTimeout(async () => {
|
|
242
|
-
if (d.signal.aborted) return
|
|
246
|
+
if (d.signal.aborted) return c(void 0);
|
|
243
247
|
try {
|
|
244
|
-
|
|
248
|
+
c(
|
|
245
249
|
await this.runValidator({
|
|
246
250
|
validate: r.validate,
|
|
247
251
|
value: {
|
|
@@ -258,8 +262,8 @@ class ut {
|
|
|
258
262
|
}
|
|
259
263
|
}, r.debounceMs);
|
|
260
264
|
});
|
|
261
|
-
} catch (
|
|
262
|
-
m =
|
|
265
|
+
} catch (c) {
|
|
266
|
+
m = c;
|
|
263
267
|
}
|
|
264
268
|
const { formError: v, fieldErrors: S } = k(m);
|
|
265
269
|
S && (e = e ? {
|
|
@@ -267,17 +271,17 @@ class ut {
|
|
|
267
271
|
...S
|
|
268
272
|
} : S);
|
|
269
273
|
const M = j(r.cause);
|
|
270
|
-
for (const
|
|
274
|
+
for (const c of Object.keys(
|
|
271
275
|
this.state.fieldMeta
|
|
272
276
|
)) {
|
|
273
|
-
if (this.baseStore.state.fieldMetaBase[
|
|
277
|
+
if (this.baseStore.state.fieldMetaBase[c] === void 0)
|
|
274
278
|
continue;
|
|
275
|
-
const V = this.getFieldMeta(
|
|
279
|
+
const V = this.getFieldMeta(c);
|
|
276
280
|
if (!V) continue;
|
|
277
281
|
const {
|
|
278
282
|
errorMap: F,
|
|
279
283
|
errorSourceMap: b
|
|
280
|
-
} = V, g = e?.[
|
|
284
|
+
} = V, g = e?.[c], { newErrorValue: I, newSource: L } = q({
|
|
281
285
|
newFormValidatorError: g,
|
|
282
286
|
isPreviousErrorFromFormValidator: (
|
|
283
287
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
@@ -287,7 +291,7 @@ class ut {
|
|
|
287
291
|
previousErrorValue: F?.[M]
|
|
288
292
|
});
|
|
289
293
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
290
|
-
F?.[M] !== I && this.setFieldMeta(
|
|
294
|
+
F?.[M] !== I && this.setFieldMeta(c, (O) => ({
|
|
291
295
|
...O,
|
|
292
296
|
errorMap: {
|
|
293
297
|
...O.errorMap,
|
|
@@ -299,13 +303,13 @@ class ut {
|
|
|
299
303
|
}
|
|
300
304
|
}));
|
|
301
305
|
}
|
|
302
|
-
this.baseStore.setState((
|
|
303
|
-
...
|
|
306
|
+
this.baseStore.setState((c) => ({
|
|
307
|
+
...c,
|
|
304
308
|
errorMap: {
|
|
305
|
-
...
|
|
309
|
+
...c.errorMap,
|
|
306
310
|
[M]: v
|
|
307
311
|
}
|
|
308
|
-
})),
|
|
312
|
+
})), h(
|
|
309
313
|
e ? { fieldErrors: e, errorMapKey: M } : void 0
|
|
310
314
|
);
|
|
311
315
|
})
|
|
@@ -313,8 +317,8 @@ class ut {
|
|
|
313
317
|
}
|
|
314
318
|
let o = [];
|
|
315
319
|
const a = {};
|
|
316
|
-
if (
|
|
317
|
-
o = await Promise.all(
|
|
320
|
+
if (i.length) {
|
|
321
|
+
o = await Promise.all(i);
|
|
318
322
|
for (const r of o)
|
|
319
323
|
if (r?.fieldErrors) {
|
|
320
324
|
const { errorMapKey: l } = r;
|
|
@@ -334,8 +338,8 @@ class ut {
|
|
|
334
338
|
isFormValidating: !1
|
|
335
339
|
})), a;
|
|
336
340
|
}, this.validate = (t) => {
|
|
337
|
-
const { hasErrored:
|
|
338
|
-
return
|
|
341
|
+
const { hasErrored: s, fieldsErrorMap: i } = this.validateSync(t);
|
|
342
|
+
return s && !this.options.asyncAlways ? i : this.validateAsync(t);
|
|
339
343
|
}, this._handleSubmit = async (t) => {
|
|
340
344
|
this.baseStore.setState((e) => ({
|
|
341
345
|
...e,
|
|
@@ -352,24 +356,24 @@ class ut {
|
|
|
352
356
|
}
|
|
353
357
|
);
|
|
354
358
|
});
|
|
355
|
-
const
|
|
359
|
+
const s = t ?? this.options.onSubmitMeta;
|
|
356
360
|
if (!this.state.canSubmit && !this._devtoolsSubmissionOverride) {
|
|
357
361
|
this.options.onSubmitInvalid?.({
|
|
358
362
|
value: this.state.values,
|
|
359
363
|
formApi: this,
|
|
360
|
-
meta:
|
|
364
|
+
meta: s
|
|
361
365
|
});
|
|
362
366
|
return;
|
|
363
367
|
}
|
|
364
368
|
this.baseStore.setState((e) => ({ ...e, isSubmitting: !0 }));
|
|
365
|
-
const
|
|
369
|
+
const i = () => {
|
|
366
370
|
this.baseStore.setState((e) => ({ ...e, isSubmitting: !1 }));
|
|
367
371
|
};
|
|
368
372
|
if (await this.validateAllFields("submit"), !this.state.isFieldsValid) {
|
|
369
|
-
|
|
373
|
+
i(), this.options.onSubmitInvalid?.({
|
|
370
374
|
value: this.state.values,
|
|
371
375
|
formApi: this,
|
|
372
|
-
meta:
|
|
376
|
+
meta: s
|
|
373
377
|
}), y.emit("form-submission", {
|
|
374
378
|
id: this._formId,
|
|
375
379
|
submissionAttempt: this.state.submissionAttempts,
|
|
@@ -380,10 +384,10 @@ class ut {
|
|
|
380
384
|
return;
|
|
381
385
|
}
|
|
382
386
|
if (await this.validate("submit"), !this.state.isValid) {
|
|
383
|
-
|
|
387
|
+
i(), this.options.onSubmitInvalid?.({
|
|
384
388
|
value: this.state.values,
|
|
385
389
|
formApi: this,
|
|
386
|
-
meta:
|
|
390
|
+
meta: s
|
|
387
391
|
}), y.emit("form-submission", {
|
|
388
392
|
id: this._formId,
|
|
389
393
|
submissionAttempt: this.state.submissionAttempts,
|
|
@@ -402,12 +406,12 @@ class ut {
|
|
|
402
406
|
});
|
|
403
407
|
}
|
|
404
408
|
);
|
|
405
|
-
}), this.options.listeners?.onSubmit?.({ formApi: this, meta:
|
|
409
|
+
}), this.options.listeners?.onSubmit?.({ formApi: this, meta: s });
|
|
406
410
|
try {
|
|
407
411
|
await this.options.onSubmit?.({
|
|
408
412
|
value: this.state.values,
|
|
409
413
|
formApi: this,
|
|
410
|
-
meta:
|
|
414
|
+
meta: s
|
|
411
415
|
}), A(() => {
|
|
412
416
|
this.baseStore.setState((e) => ({
|
|
413
417
|
...e,
|
|
@@ -418,7 +422,7 @@ class ut {
|
|
|
418
422
|
id: this._formId,
|
|
419
423
|
submissionAttempt: this.state.submissionAttempts,
|
|
420
424
|
successful: !0
|
|
421
|
-
}),
|
|
425
|
+
}), i();
|
|
422
426
|
});
|
|
423
427
|
} catch (e) {
|
|
424
428
|
throw this.baseStore.setState((o) => ({
|
|
@@ -431,7 +435,7 @@ class ut {
|
|
|
431
435
|
successful: !1,
|
|
432
436
|
stage: "inflight",
|
|
433
437
|
onError: e
|
|
434
|
-
}),
|
|
438
|
+
}), i(), e;
|
|
435
439
|
}
|
|
436
440
|
}, this.getFieldValue = (t) => T(this.state.values, t), this.getFieldMeta = (t) => this.state.fieldMeta[t], this.getFieldInfo = (t) => this.fieldInfo[t] ||= {
|
|
437
441
|
instance: null,
|
|
@@ -443,25 +447,25 @@ class ut {
|
|
|
443
447
|
onServer: void 0,
|
|
444
448
|
onDynamic: void 0
|
|
445
449
|
}
|
|
446
|
-
}, this.setFieldMeta = (t,
|
|
447
|
-
this.baseStore.setState((
|
|
448
|
-
...
|
|
450
|
+
}, this.setFieldMeta = (t, s) => {
|
|
451
|
+
this.baseStore.setState((i) => ({
|
|
452
|
+
...i,
|
|
449
453
|
fieldMetaBase: {
|
|
450
|
-
...
|
|
454
|
+
...i.fieldMetaBase,
|
|
451
455
|
[t]: X(
|
|
452
|
-
|
|
453
|
-
|
|
456
|
+
s,
|
|
457
|
+
i.fieldMetaBase[t]
|
|
454
458
|
)
|
|
455
459
|
}
|
|
456
460
|
}));
|
|
457
461
|
}, this.resetFieldMeta = (t) => Object.keys(t).reduce(
|
|
458
|
-
(
|
|
459
|
-
const e =
|
|
460
|
-
return
|
|
462
|
+
(s, i) => {
|
|
463
|
+
const e = i;
|
|
464
|
+
return s[e] = $, s;
|
|
461
465
|
},
|
|
462
466
|
{}
|
|
463
|
-
), this.setFieldValue = (t,
|
|
464
|
-
const e =
|
|
467
|
+
), this.setFieldValue = (t, s, i) => {
|
|
468
|
+
const e = i?.dontUpdateMeta ?? !1, o = i?.dontRunListeners ?? !1, a = i?.dontValidate ?? !1;
|
|
465
469
|
A(() => {
|
|
466
470
|
e || this.setFieldMeta(t, (r) => ({
|
|
467
471
|
...r,
|
|
@@ -474,104 +478,104 @@ class ut {
|
|
|
474
478
|
}
|
|
475
479
|
})), this.baseStore.setState((r) => ({
|
|
476
480
|
...r,
|
|
477
|
-
values: _(r.values, t,
|
|
481
|
+
values: _(r.values, t, s)
|
|
478
482
|
}));
|
|
479
483
|
}), o || this.getFieldInfo(t).instance?.triggerOnChangeListener(), a || this.validateField(t, "change");
|
|
480
484
|
}, this.deleteField = (t) => {
|
|
481
|
-
const
|
|
485
|
+
const i = [...Object.keys(this.fieldInfo).filter((e) => {
|
|
482
486
|
const o = t.toString();
|
|
483
487
|
return e !== o && e.startsWith(o);
|
|
484
488
|
}), t];
|
|
485
489
|
this.baseStore.setState((e) => {
|
|
486
490
|
const o = { ...e };
|
|
487
|
-
return
|
|
491
|
+
return i.forEach((a) => {
|
|
488
492
|
o.values = Y(o.values, a), delete this.fieldInfo[a], delete o.fieldMetaBase[a];
|
|
489
493
|
}), o;
|
|
490
494
|
});
|
|
491
|
-
}, this.pushFieldValue = (t,
|
|
495
|
+
}, this.pushFieldValue = (t, s, i) => {
|
|
492
496
|
this.setFieldValue(
|
|
493
497
|
t,
|
|
494
|
-
(e) => [...Array.isArray(e) ? e : [],
|
|
495
|
-
|
|
498
|
+
(e) => [...Array.isArray(e) ? e : [], s],
|
|
499
|
+
i
|
|
496
500
|
);
|
|
497
|
-
}, this.insertFieldValue = async (t,
|
|
501
|
+
}, this.insertFieldValue = async (t, s, i, e) => {
|
|
498
502
|
this.setFieldValue(
|
|
499
503
|
t,
|
|
500
504
|
(a) => [
|
|
501
|
-
...a.slice(0,
|
|
502
|
-
|
|
503
|
-
...a.slice(
|
|
505
|
+
...a.slice(0, s),
|
|
506
|
+
i,
|
|
507
|
+
...a.slice(s)
|
|
504
508
|
],
|
|
505
509
|
B(e, { dontValidate: !0 })
|
|
506
510
|
);
|
|
507
511
|
const o = e?.dontValidate ?? !1;
|
|
508
|
-
o || await this.validateField(t, "change"), P(this).handleArrayInsert(t,
|
|
509
|
-
}, this.replaceFieldValue = async (t,
|
|
512
|
+
o || await this.validateField(t, "change"), P(this).handleArrayInsert(t, s), o || await this.validateArrayFieldsStartingFrom(t, s, "change");
|
|
513
|
+
}, this.replaceFieldValue = async (t, s, i, e) => {
|
|
510
514
|
this.setFieldValue(
|
|
511
515
|
t,
|
|
512
516
|
(a) => a.map(
|
|
513
|
-
(r, l) => l ===
|
|
517
|
+
(r, l) => l === s ? i : r
|
|
514
518
|
),
|
|
515
519
|
B(e, { dontValidate: !0 })
|
|
516
|
-
), (e?.dontValidate ?? !1) || (await this.validateField(t, "change"), await this.validateArrayFieldsStartingFrom(t,
|
|
517
|
-
}, this.removeFieldValue = async (t,
|
|
520
|
+
), (e?.dontValidate ?? !1) || (await this.validateField(t, "change"), await this.validateArrayFieldsStartingFrom(t, s, "change"));
|
|
521
|
+
}, this.removeFieldValue = async (t, s, i) => {
|
|
518
522
|
const e = this.getFieldValue(t), o = Array.isArray(e) ? Math.max(e.length - 1, 0) : null;
|
|
519
523
|
if (this.setFieldValue(
|
|
520
524
|
t,
|
|
521
525
|
(r) => r.filter(
|
|
522
|
-
(l, n) => n !==
|
|
526
|
+
(l, n) => n !== s
|
|
523
527
|
),
|
|
524
|
-
B(
|
|
525
|
-
), P(this).handleArrayRemove(t,
|
|
528
|
+
B(i, { dontValidate: !0 })
|
|
529
|
+
), P(this).handleArrayRemove(t, s), o !== null) {
|
|
526
530
|
const r = `${t}[${o}]`;
|
|
527
531
|
this.deleteField(r);
|
|
528
532
|
}
|
|
529
|
-
(
|
|
530
|
-
}, this.swapFieldValues = (t,
|
|
533
|
+
(i?.dontValidate ?? !1) || (await this.validateField(t, "change"), await this.validateArrayFieldsStartingFrom(t, s, "change"));
|
|
534
|
+
}, this.swapFieldValues = (t, s, i, e) => {
|
|
531
535
|
this.setFieldValue(
|
|
532
536
|
t,
|
|
533
537
|
(a) => {
|
|
534
|
-
const r = a[
|
|
535
|
-
return _(_(a, `${
|
|
538
|
+
const r = a[s], l = a[i];
|
|
539
|
+
return _(_(a, `${s}`, l), `${i}`, r);
|
|
536
540
|
},
|
|
537
541
|
B(e, { dontValidate: !0 })
|
|
538
|
-
), P(this).handleArraySwap(t,
|
|
539
|
-
}, this.moveFieldValues = (t,
|
|
542
|
+
), P(this).handleArraySwap(t, s, i), (e?.dontValidate ?? !1) || (this.validateField(t, "change"), this.validateField(`${t}[${s}]`, "change"), this.validateField(`${t}[${i}]`, "change"));
|
|
543
|
+
}, this.moveFieldValues = (t, s, i, e) => {
|
|
540
544
|
this.setFieldValue(
|
|
541
545
|
t,
|
|
542
546
|
(a) => {
|
|
543
547
|
const r = [...a];
|
|
544
|
-
return r.splice(
|
|
548
|
+
return r.splice(i, 0, r.splice(s, 1)[0]), r;
|
|
545
549
|
},
|
|
546
550
|
B(e, { dontValidate: !0 })
|
|
547
|
-
), P(this).handleArrayMove(t,
|
|
548
|
-
}, this.clearFieldValues = (t,
|
|
549
|
-
const
|
|
551
|
+
), P(this).handleArrayMove(t, s, i), (e?.dontValidate ?? !1) || (this.validateField(t, "change"), this.validateField(`${t}[${s}]`, "change"), this.validateField(`${t}[${i}]`, "change"));
|
|
552
|
+
}, this.clearFieldValues = (t, s) => {
|
|
553
|
+
const i = this.getFieldValue(t), e = Array.isArray(i) ? Math.max(i.length - 1, 0) : null;
|
|
550
554
|
if (this.setFieldValue(
|
|
551
555
|
t,
|
|
552
556
|
[],
|
|
553
|
-
B(
|
|
557
|
+
B(s, { dontValidate: !0 })
|
|
554
558
|
), e !== null)
|
|
555
559
|
for (let a = 0; a <= e; a++) {
|
|
556
560
|
const r = `${t}[${a}]`;
|
|
557
561
|
this.deleteField(r);
|
|
558
562
|
}
|
|
559
|
-
(
|
|
563
|
+
(s?.dontValidate ?? !1) || this.validateField(t, "change");
|
|
560
564
|
}, this.resetField = (t) => {
|
|
561
|
-
this.baseStore.setState((
|
|
562
|
-
...
|
|
565
|
+
this.baseStore.setState((s) => ({
|
|
566
|
+
...s,
|
|
563
567
|
fieldMetaBase: {
|
|
564
|
-
...
|
|
568
|
+
...s.fieldMetaBase,
|
|
565
569
|
[t]: $
|
|
566
570
|
},
|
|
567
|
-
values: this.options.defaultValues ? _(
|
|
571
|
+
values: this.options.defaultValues ? _(s.values, t, T(this.options.defaultValues, t)) : s.values
|
|
568
572
|
}));
|
|
569
573
|
}, this.setErrorMap = (t) => {
|
|
570
574
|
A(() => {
|
|
571
|
-
Object.entries(t).forEach(([
|
|
572
|
-
const e =
|
|
573
|
-
if (W(
|
|
574
|
-
const { formError: o, fieldErrors: a } = k(
|
|
575
|
+
Object.entries(t).forEach(([s, i]) => {
|
|
576
|
+
const e = s;
|
|
577
|
+
if (W(i)) {
|
|
578
|
+
const { formError: o, fieldErrors: a } = k(i);
|
|
575
579
|
for (const r of Object.keys(
|
|
576
580
|
this.fieldInfo
|
|
577
581
|
))
|
|
@@ -598,7 +602,7 @@ class ut {
|
|
|
598
602
|
...o,
|
|
599
603
|
errorMap: {
|
|
600
604
|
...o.errorMap,
|
|
601
|
-
[e]:
|
|
605
|
+
[e]: i
|
|
602
606
|
}
|
|
603
607
|
}));
|
|
604
608
|
});
|
|
@@ -609,9 +613,9 @@ class ut {
|
|
|
609
613
|
errorMap: this.state.errorMap
|
|
610
614
|
},
|
|
611
615
|
fields: Object.entries(this.state.fieldMeta).reduce(
|
|
612
|
-
(t, [
|
|
613
|
-
errors:
|
|
614
|
-
errorMap:
|
|
616
|
+
(t, [s, i]) => (Object.keys(i).length && i.errors.length && (t[s] = {
|
|
617
|
+
errors: i.errors,
|
|
618
|
+
errorMap: i.errorMap
|
|
615
619
|
}), t),
|
|
616
620
|
{}
|
|
617
621
|
)
|
|
@@ -632,23 +636,23 @@ class ut {
|
|
|
632
636
|
})
|
|
633
637
|
), this.fieldMetaDerived = new N({
|
|
634
638
|
deps: [this.baseStore],
|
|
635
|
-
fn: ({ prevDepVals: t, currDepVals:
|
|
636
|
-
const e =
|
|
639
|
+
fn: ({ prevDepVals: t, currDepVals: s, prevVal: i }) => {
|
|
640
|
+
const e = i, o = t?.[0], a = s[0];
|
|
637
641
|
let r = 0;
|
|
638
642
|
const l = {};
|
|
639
643
|
for (const n of Object.keys(
|
|
640
644
|
a.fieldMetaBase
|
|
641
645
|
)) {
|
|
642
|
-
const d = a.fieldMetaBase[n],
|
|
646
|
+
const d = a.fieldMetaBase[n], h = o?.fieldMetaBase[n], m = e?.[n], v = T(a.values, n);
|
|
643
647
|
let S = m?.errors;
|
|
644
|
-
if (!
|
|
648
|
+
if (!h || d.errorMap !== h.errorMap) {
|
|
645
649
|
S = Object.values(d.errorMap ?? {}).filter(
|
|
646
650
|
(b) => b !== void 0
|
|
647
651
|
);
|
|
648
652
|
const F = this.getFieldInfo(n)?.instance;
|
|
649
|
-
F
|
|
653
|
+
(!F || !F.options.disableErrorFlat) && (S = S.flat(1));
|
|
650
654
|
}
|
|
651
|
-
const M = !x(S),
|
|
655
|
+
const M = !x(S), c = !d.isDirty, V = w(
|
|
652
656
|
v,
|
|
653
657
|
T(this.options.defaultValues, n)
|
|
654
658
|
) || w(
|
|
@@ -656,14 +660,14 @@ class ut {
|
|
|
656
660
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
657
661
|
this.getFieldInfo(n)?.instance?.options.defaultValue
|
|
658
662
|
);
|
|
659
|
-
if (m && m.isPristine ===
|
|
663
|
+
if (m && m.isPristine === c && m.isValid === M && m.isDefaultValue === V && m.errors === S && d === h) {
|
|
660
664
|
l[n] = m, r++;
|
|
661
665
|
continue;
|
|
662
666
|
}
|
|
663
667
|
l[n] = {
|
|
664
668
|
...d,
|
|
665
669
|
errors: S ?? [],
|
|
666
|
-
isPristine:
|
|
670
|
+
isPristine: c,
|
|
667
671
|
isValid: M,
|
|
668
672
|
isDefaultValue: V
|
|
669
673
|
};
|
|
@@ -672,26 +676,26 @@ class ut {
|
|
|
672
676
|
}
|
|
673
677
|
}), this.store = new N({
|
|
674
678
|
deps: [this.baseStore, this.fieldMetaDerived],
|
|
675
|
-
fn: ({ prevDepVals: t, currDepVals:
|
|
676
|
-
const e =
|
|
679
|
+
fn: ({ prevDepVals: t, currDepVals: s, prevVal: i }) => {
|
|
680
|
+
const e = i, o = t?.[0], a = s[0], r = s[1], l = Object.values(r).filter(
|
|
677
681
|
Boolean
|
|
678
682
|
), n = l.some(
|
|
679
683
|
(u) => u.isValidating
|
|
680
|
-
), d = l.every((u) => u.isValid),
|
|
684
|
+
), d = l.every((u) => u.isValid), h = l.some((u) => u.isTouched), m = l.some((u) => u.isBlurred), v = l.every(
|
|
681
685
|
(u) => u.isDefaultValue
|
|
682
686
|
), S = (
|
|
683
687
|
// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
684
|
-
|
|
685
|
-
), M = l.some((u) => u.isDirty),
|
|
688
|
+
h && a.errorMap?.onMount
|
|
689
|
+
), M = l.some((u) => u.isDirty), c = !M, V = !!// eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
686
690
|
(a.errorMap?.onMount || // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition
|
|
687
691
|
l.some((u) => u?.errorMap?.onMount)), F = !!n;
|
|
688
692
|
let b = e?.errors ?? [];
|
|
689
693
|
(!o || a.errorMap !== o.errorMap) && (b = Object.values(a.errorMap).reduce((u, E) => E === void 0 ? u : E && W(E) ? (u.push(E.form), u) : (u.push(E), u), []));
|
|
690
|
-
const g = b.length === 0, I = d && g, L = this.options.canSubmitWhenInvalid ?? !1, O = a.submissionAttempts === 0 && !
|
|
694
|
+
const g = b.length === 0, I = d && g, L = this.options.canSubmitWhenInvalid ?? !1, O = a.submissionAttempts === 0 && !h && !V || !F && !a.isSubmitting && I || L;
|
|
691
695
|
let D = a.errorMap;
|
|
692
696
|
if (S && (b = b.filter(
|
|
693
697
|
(u) => u !== a.errorMap.onMount
|
|
694
|
-
), D = Object.assign(D, { onMount: void 0 })), e && o && e.errorMap === D && e.fieldMeta === this.fieldMetaDerived.state && e.errors === b && e.isFieldsValidating === n && e.isFieldsValid === d && e.isFormValid === g && e.isValid === I && e.canSubmit === O && e.isTouched ===
|
|
698
|
+
), D = Object.assign(D, { onMount: void 0 })), e && o && e.errorMap === D && e.fieldMeta === this.fieldMetaDerived.state && e.errors === b && e.isFieldsValidating === n && e.isFieldsValid === d && e.isFormValid === g && e.isValid === I && e.canSubmit === O && e.isTouched === h && e.isBlurred === m && e.isPristine === c && e.isDefaultValue === v && e.isDirty === M && w(o, a))
|
|
695
699
|
return e;
|
|
696
700
|
let K = {
|
|
697
701
|
...a,
|
|
@@ -703,9 +707,9 @@ class ut {
|
|
|
703
707
|
isFormValid: g,
|
|
704
708
|
isValid: I,
|
|
705
709
|
canSubmit: O,
|
|
706
|
-
isTouched:
|
|
710
|
+
isTouched: h,
|
|
707
711
|
isBlurred: m,
|
|
708
|
-
isPristine:
|
|
712
|
+
isPristine: c,
|
|
709
713
|
isDefaultValue: v,
|
|
710
714
|
isDirty: M
|
|
711
715
|
};
|