vft 0.0.359 → 0.0.360
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/es/components/super-form/use/use-form-events.js +38 -38
- package/es/package.json.d.ts +1 -1
- package/es/package.json.js +1 -1
- package/lib/components/super-form/use/use-form-events.cjs +1 -1
- package/lib/package.json.cjs +1 -1
- package/lib/package.json.d.ts +1 -1
- package/package.json +4 -4
- package/web-types.json +1 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { isDef as
|
|
2
|
-
import { formatToDate as
|
|
1
|
+
import { isDef as H, isFunction as j, isString as A, isObject as V, isArray as I, deepMerge as nt, findDifferentValuesForObj as rt, isNullOrUndefined as J, isEmpty as st, isEmptyObject as lt } from "@vft/utils";
|
|
2
|
+
import { formatToDate as Q } from "@vft/utils/date";
|
|
3
3
|
import { get as ot, cloneDeep as m, uniqBy as at, isEqual as ct, set as X } from "lodash-es";
|
|
4
|
-
import {
|
|
5
|
-
import { isInput as ft, FormCompEnum as
|
|
4
|
+
import { unref as n, toRaw as x, nextTick as W } from "vue";
|
|
5
|
+
import { isInput as ft, FormCompEnum as S, isDatePicker as ut } from "../component-map.js";
|
|
6
6
|
import { handleInputNumberValue as dt } from "./helper.js";
|
|
7
7
|
function T(h, y) {
|
|
8
8
|
const { show: o, ifShow: c } = h;
|
|
@@ -62,7 +62,7 @@ function Et({
|
|
|
62
62
|
formElRef: f,
|
|
63
63
|
schemaRef: F,
|
|
64
64
|
handleFormValues: B,
|
|
65
|
-
initValues:
|
|
65
|
+
initValues: _
|
|
66
66
|
}) {
|
|
67
67
|
async function Y(t) {
|
|
68
68
|
const { resetFunc: e, submitOnReset: s } = n(y);
|
|
@@ -74,10 +74,10 @@ function Et({
|
|
|
74
74
|
Object.keys(o).forEach((a) => {
|
|
75
75
|
const l = n(c).find((u) => u.field === a), i = m(p.value[a]);
|
|
76
76
|
o[a] = ft(l?.type) ? i || "" : i;
|
|
77
|
-
}),
|
|
77
|
+
}), W(() => D()), h("reset", x(o)), s && await U();
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
|
-
async function
|
|
80
|
+
async function q(t, e = !0) {
|
|
81
81
|
const s = n(c).map((i) => i.field).filter(Boolean), r = ".", a = s.filter(
|
|
82
82
|
(i) => String(i).indexOf(r) >= 0
|
|
83
83
|
), l = [];
|
|
@@ -86,20 +86,20 @@ function Et({
|
|
|
86
86
|
let b = ot(t, i);
|
|
87
87
|
const C = Reflect.has(t, i);
|
|
88
88
|
b = dt(u?.type, b);
|
|
89
|
-
const { componentProps:
|
|
90
|
-
let w =
|
|
91
|
-
typeof
|
|
92
|
-
const
|
|
93
|
-
if (C ||
|
|
94
|
-
const d =
|
|
89
|
+
const { componentProps: z } = u || {};
|
|
90
|
+
let w = z;
|
|
91
|
+
typeof z == "function" && (w = w({ formModel: n(o) }));
|
|
92
|
+
const G = ht(i, t) || pt(i, t);
|
|
93
|
+
if (C || G) {
|
|
94
|
+
const d = G || b;
|
|
95
95
|
if (M(i))
|
|
96
96
|
if (Array.isArray(d)) {
|
|
97
97
|
const v = [];
|
|
98
98
|
for (const E of d)
|
|
99
|
-
v.push(E ?
|
|
99
|
+
v.push(E ? Q(E) : null);
|
|
100
100
|
n(o)[i] = v;
|
|
101
101
|
} else
|
|
102
|
-
n(o)[i] = d ? w?.valueFormat ? d :
|
|
102
|
+
n(o)[i] = d ? w?.valueFormat ? d : Q(d) : null;
|
|
103
103
|
else
|
|
104
104
|
n(o)[i] = d;
|
|
105
105
|
w?.onChange && w?.onChange(d), l.push(i);
|
|
@@ -107,15 +107,15 @@ function Et({
|
|
|
107
107
|
a.forEach((d) => {
|
|
108
108
|
try {
|
|
109
109
|
const v = d.split(".").reduce((E, it) => E[it], t);
|
|
110
|
-
|
|
110
|
+
H(v) && (n(o)[d] = n(v), l.push(d));
|
|
111
111
|
} catch {
|
|
112
|
-
|
|
112
|
+
H(p.value[d]) && (n(o)[d] = m(
|
|
113
113
|
n(p.value[d])
|
|
114
114
|
));
|
|
115
115
|
}
|
|
116
116
|
});
|
|
117
|
-
}), e &&
|
|
118
|
-
await
|
|
117
|
+
}), e && W(async () => {
|
|
118
|
+
await $(l).catch((i) => {
|
|
119
119
|
});
|
|
120
120
|
});
|
|
121
121
|
}
|
|
@@ -146,7 +146,7 @@ function Et({
|
|
|
146
146
|
async function R(t) {
|
|
147
147
|
let e = [];
|
|
148
148
|
if (V(t) && e.push(t), I(t) && (e = [...t]), !e.every(
|
|
149
|
-
(r) => r.type ===
|
|
149
|
+
(r) => r.type === S.DIVIDER || Reflect.has(r, "field") && r.field
|
|
150
150
|
)) {
|
|
151
151
|
console.error(
|
|
152
152
|
"All children of the form Schema array that need to be updated must contain the `field` field"
|
|
@@ -155,10 +155,10 @@ function Et({
|
|
|
155
155
|
}
|
|
156
156
|
F.value = e;
|
|
157
157
|
}
|
|
158
|
-
async function
|
|
158
|
+
async function N(t) {
|
|
159
159
|
let e = [];
|
|
160
160
|
if (V(t) && e.push(t), I(t) && (e = [...t]), !e.every(
|
|
161
|
-
(l) => l.type ===
|
|
161
|
+
(l) => l.type === S.DIVIDER || Reflect.has(l, "field") && l.field
|
|
162
162
|
)) {
|
|
163
163
|
console.error(
|
|
164
164
|
"All children of the form Schema array that need to be updated must contain the `field` field"
|
|
@@ -184,12 +184,12 @@ function Et({
|
|
|
184
184
|
V(t) && r.push(t), I(t) && (r = [...t]);
|
|
185
185
|
const a = {}, l = g();
|
|
186
186
|
r.forEach((i) => {
|
|
187
|
-
i.type !==
|
|
188
|
-
}), lt(a) ||
|
|
187
|
+
i.type !== S.DIVIDER && Reflect.has(i, "field") && i.field && !J(i.defaultValue) && (!(i.field in l) || J(l[i.field]) || st(l[i.field])) && (a[i.field] = i.defaultValue);
|
|
188
|
+
}), lt(a) || q(a, s);
|
|
189
189
|
}
|
|
190
190
|
function g(t = !1) {
|
|
191
191
|
if (!n(f)) return {};
|
|
192
|
-
const s = B(
|
|
192
|
+
const s = B(x(n(o)));
|
|
193
193
|
if (t)
|
|
194
194
|
return s;
|
|
195
195
|
const r = n(c).filter((l) => T(l, n(o))).map((l) => l.field).filter(Boolean), a = {};
|
|
@@ -198,15 +198,15 @@ function Et({
|
|
|
198
198
|
}), a;
|
|
199
199
|
}
|
|
200
200
|
function k(t) {
|
|
201
|
-
return n(f) ?
|
|
201
|
+
return n(f) ? x(n(o))[t] : {};
|
|
202
202
|
}
|
|
203
203
|
function M(t) {
|
|
204
204
|
return n(c).some((e) => e.field === t ? ut(e.type) : !1);
|
|
205
205
|
}
|
|
206
|
-
async function
|
|
206
|
+
async function $(t) {
|
|
207
207
|
return t || (t = n(c).filter((s) => T(s, n(o))).map((s) => s.field).filter(Boolean)), n(f)?.validateField(t);
|
|
208
208
|
}
|
|
209
|
-
async function
|
|
209
|
+
async function P(t) {
|
|
210
210
|
return t || (t = n(c).filter((s) => T(s, n(o))).map((s) => s.field).filter(Boolean)), await n(f)?.validate(t, () => {
|
|
211
211
|
});
|
|
212
212
|
}
|
|
@@ -214,14 +214,14 @@ function Et({
|
|
|
214
214
|
await n(f)?.clearValidate(t);
|
|
215
215
|
}
|
|
216
216
|
async function tt(t, e) {
|
|
217
|
-
await D(t),
|
|
218
|
-
await
|
|
217
|
+
await D(t), setTimeout(async () => {
|
|
218
|
+
await N([{ field: t, itemProps: { error: e } }]);
|
|
219
219
|
});
|
|
220
220
|
}
|
|
221
221
|
async function et(t, e) {
|
|
222
222
|
await n(f)?.scrollToField(t, e);
|
|
223
223
|
}
|
|
224
|
-
async function
|
|
224
|
+
async function U(t) {
|
|
225
225
|
const { autoCleanErrorMessage: e, watchDataIsChange: s } = n(y);
|
|
226
226
|
t && t.preventDefault(), e && await D();
|
|
227
227
|
const { submitFunc: r, beforeSubmitFunc: a } = n(y);
|
|
@@ -231,11 +231,11 @@ function Et({
|
|
|
231
231
|
}
|
|
232
232
|
if (n(f))
|
|
233
233
|
try {
|
|
234
|
-
if (!await
|
|
234
|
+
if (!await P())
|
|
235
235
|
return;
|
|
236
236
|
const u = g();
|
|
237
237
|
if (s) {
|
|
238
|
-
const b = ct(
|
|
238
|
+
const b = ct(_.value, u), C = rt(_.value, u);
|
|
239
239
|
h("submit", u, !b, C);
|
|
240
240
|
} else
|
|
241
241
|
h("submit", u);
|
|
@@ -246,17 +246,17 @@ function Et({
|
|
|
246
246
|
}
|
|
247
247
|
}
|
|
248
248
|
return {
|
|
249
|
-
handleSubmit:
|
|
249
|
+
handleSubmit: U,
|
|
250
250
|
clearValidate: D,
|
|
251
|
-
validate:
|
|
252
|
-
validateField:
|
|
251
|
+
validate: P,
|
|
252
|
+
validateField: $,
|
|
253
253
|
getFieldsValue: g,
|
|
254
|
-
updateSchema:
|
|
254
|
+
updateSchema: N,
|
|
255
255
|
resetSchema: R,
|
|
256
256
|
appendSchemaByField: K,
|
|
257
257
|
removeSchemaByField: Z,
|
|
258
258
|
resetFields: Y,
|
|
259
|
-
setFieldsValue:
|
|
259
|
+
setFieldsValue: q,
|
|
260
260
|
scrollToField: et,
|
|
261
261
|
getFieldValue: k,
|
|
262
262
|
setFormItemError: tt
|
package/es/package.json.d.ts
CHANGED
package/es/package.json.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@vft/utils"),U=require("@vft/utils/date"),b=require("lodash-es"),i=require("vue"),V=require("../component-map.cjs"),L=require("./helper.cjs");function C(p,F){const{show:l,ifShow:o}=p;let y=!0,c=!0;return typeof l=="boolean"?y=l:typeof l=="function"&&(y=l({field:p.field,model:F,values:{...F},schema:p})),typeof o=="boolean"?c=o:typeof o=="function"&&(c=o({field:p.field,model:F,values:{...F},schema:p})),y&&c}function K(p,F={}){const l=/^\[(.+)\]$/;if(l.test(p)){const o=p.match(l);if(o&&o[1]){const y=o[1].split(",");if(!y.length)return;const c=[];return y.forEach((v,g)=>{b.set(c,g,F[v.trim()])}),c.filter(Boolean).length?c:void 0}}}function R(p,F={}){const l=/^\{(.+)\}$/;if(l.test(p)){const o=p.match(l);if(o&&o[1]){const y=o[1].split(",");if(!y.length)return;const c={};return y.forEach(v=>{b.set(c,v.trim(),F[v.trim()])}),Object.values(c).filter(Boolean).length?c:void 0}}}function k({emit:p,getProps:F,formModel:l,getSchema:o,defaultValueRef:y,formElRef:c,schemaRef:v,handleFormValues:g,initValues:S}){async function $(e){const{resetFunc:n,submitOnReset:s}=i.unref(F);n&&a.isFunction(n)&&await n();const r=i.unref(c);if(r){if(e?.length)return r.resetFields(e);Object.keys(l).forEach(f=>{const u=i.unref(o).find(d=>d.field===f),t=b.cloneDeep(y.value[f]);l[f]=V.isInput(u?.type)?t||"":t}),i.nextTick(()=>O()),p("reset",i.toRaw(l)),s&&await _()}}async function
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const a=require("@vft/utils"),U=require("@vft/utils/date"),b=require("lodash-es"),i=require("vue"),V=require("../component-map.cjs"),L=require("./helper.cjs");function C(p,F){const{show:l,ifShow:o}=p;let y=!0,c=!0;return typeof l=="boolean"?y=l:typeof l=="function"&&(y=l({field:p.field,model:F,values:{...F},schema:p})),typeof o=="boolean"?c=o:typeof o=="function"&&(c=o({field:p.field,model:F,values:{...F},schema:p})),y&&c}function K(p,F={}){const l=/^\[(.+)\]$/;if(l.test(p)){const o=p.match(l);if(o&&o[1]){const y=o[1].split(",");if(!y.length)return;const c=[];return y.forEach((v,g)=>{b.set(c,g,F[v.trim()])}),c.filter(Boolean).length?c:void 0}}}function R(p,F={}){const l=/^\{(.+)\}$/;if(l.test(p)){const o=p.match(l);if(o&&o[1]){const y=o[1].split(",");if(!y.length)return;const c={};return y.forEach(v=>{b.set(c,v.trim(),F[v.trim()])}),Object.values(c).filter(Boolean).length?c:void 0}}}function k({emit:p,getProps:F,formModel:l,getSchema:o,defaultValueRef:y,formElRef:c,schemaRef:v,handleFormValues:g,initValues:S}){async function $(e){const{resetFunc:n,submitOnReset:s}=i.unref(F);n&&a.isFunction(n)&&await n();const r=i.unref(c);if(r){if(e?.length)return r.resetFields(e);Object.keys(l).forEach(f=>{const u=i.unref(o).find(d=>d.field===f),t=b.cloneDeep(y.value[f]);l[f]=V.isInput(u?.type)?t||"":t}),i.nextTick(()=>O()),p("reset",i.toRaw(l)),s&&await _()}}async function m(e,n=!0){const s=i.unref(o).map(t=>t.field).filter(Boolean),r=".",f=s.filter(t=>String(t).indexOf(r)>=0),u=[];s.forEach(t=>{const d=i.unref(o).find(h=>h.field===t);let E=b.get(e,t);const B=Reflect.has(e,t);E=L.handleInputNumberValue(d?.type,E);const{componentProps:N}=d||{};let w=N;typeof N=="function"&&(w=w({formModel:i.unref(l)}));const P=K(t,e)||R(t,e);if(B||P){const h=P||E;if(W(t))if(Array.isArray(h)){const D=[];for(const I of h)D.push(I?U.formatToDate(I):null);i.unref(l)[t]=D}else i.unref(l)[t]=h?w?.valueFormat?h:U.formatToDate(h):null;else i.unref(l)[t]=h;w?.onChange&&w?.onChange(h),u.push(t)}else f.forEach(h=>{try{const D=h.split(".").reduce((I,Z)=>I[Z],e);a.isDef(D)&&(i.unref(l)[h]=i.unref(D),u.push(h))}catch{a.isDef(y.value[h])&&(i.unref(l)[h]=b.cloneDeep(i.unref(y.value[h])))}})}),n&&i.nextTick(async()=>{await q(u).catch(t=>{})})}async function z(e){const n=b.cloneDeep(i.unref(o));if(!e)return;let s=a.isString(e)?[e]:e;a.isString(e)&&(s=[e]);for(const r of s)G(r,n);v.value=n}function G(e,n){if(a.isString(e)){const s=n.findIndex(r=>r.field===e);s!==-1&&(delete l[e],n.splice(s,1))}}async function H(e,n,s=!1){const r=b.cloneDeep(i.unref(o)),f=r.findIndex(t=>t.field===n),u=a.isObject(e)?[e]:e;if(!n||f===-1||s){s?r.unshift(...u):r.push(...u),v.value=r,j(e);return}f!==-1&&r.splice(f+1,0,...u),j(e),v.value=r}async function J(e){let n=[];if(a.isObject(e)&&n.push(e),a.isArray(e)&&(n=[...e]),!n.every(r=>r.type===V.FormCompEnum.DIVIDER||Reflect.has(r,"field")&&r.field)){console.error("All children of the form Schema array that need to be updated must contain the `field` field");return}v.value=n}async function T(e){let n=[];if(a.isObject(e)&&n.push(e),a.isArray(e)&&(n=[...e]),!n.every(u=>u.type===V.FormCompEnum.DIVIDER||Reflect.has(u,"field")&&u.field)){console.error("All children of the form Schema array that need to be updated must contain the `field` field");return}const r=[],f=[];i.unref(o).forEach(u=>{let t;if(n.forEach(d=>{u.field===d.field&&(t=d),d.defaultValue&&d.field&&r.push(d.field)}),t!==void 0&&u.field===t.field){const d=a.deepMerge(u,t);f.push(d)}else f.push(u)}),j(f,r),v.value=b.uniqBy(f,"field")}function j(e,n,s=!0){if(a.isArray(n)&&n?.length===0)return;let r=[];a.isObject(e)&&r.push(e),a.isArray(e)&&(r=[...e]);const f={},u=A();r.forEach(t=>{t.type!==V.FormCompEnum.DIVIDER&&Reflect.has(t,"field")&&t.field&&!a.isNullOrUndefined(t.defaultValue)&&(!(t.field in u)||a.isNullOrUndefined(u[t.field])||a.isEmpty(u[t.field]))&&(f[t.field]=t.defaultValue)}),a.isEmptyObject(f)||m(f,s)}function A(e=!1){if(!i.unref(c))return{};const s=g(i.toRaw(i.unref(l)));if(e)return s;const r=i.unref(o).filter(u=>C(u,i.unref(l))).map(u=>u.field).filter(Boolean),f={};return r.forEach(u=>{u in s&&(f[u]=s[u])}),f}function Q(e){return i.unref(c)?i.toRaw(i.unref(l))[e]:{}}function W(e){return i.unref(o).some(n=>n.field===e?V.isDatePicker(n.type):!1)}async function q(e){return e||(e=i.unref(o).filter(s=>C(s,i.unref(l))).map(s=>s.field).filter(Boolean)),i.unref(c)?.validateField(e)}async function x(e){return e||(e=i.unref(o).filter(s=>C(s,i.unref(l))).map(s=>s.field).filter(Boolean)),await i.unref(c)?.validate(e,()=>{})}async function O(e){await i.unref(c)?.clearValidate(e)}async function X(e,n){await O(e),setTimeout(async()=>{await T([{field:e,itemProps:{error:n}}])})}async function Y(e,n){await i.unref(c)?.scrollToField(e,n)}async function _(e){const{autoCleanErrorMessage:n,watchDataIsChange:s}=i.unref(F);e&&e.preventDefault(),n&&await O();const{submitFunc:r,beforeSubmitFunc:f}=i.unref(F);if(f&&a.isFunction(f)&&await f(),r&&a.isFunction(r)){await r();return}if(i.unref(c))try{if(!await x())return;const d=A();if(s){const E=b.isEqual(S.value,d),B=a.findDifferentValuesForObj(S.value,d);p("submit",d,!E,B)}else p("submit",d)}catch(t){if(t?.outOfDate===!1&&t?.errorFields)return;throw new Error(t.message)}}return{handleSubmit:_,clearValidate:O,validate:x,validateField:q,getFieldsValue:A,updateSchema:T,resetSchema:J,appendSchemaByField:H,removeSchemaByField:z,resetFields:$,setFieldsValue:m,scrollToField:Y,getFieldValue:Q,setFormItemError:X}}exports.useFormEvents=k;
|
package/lib/package.json.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e="0.0.360";exports.version=e;
|
package/lib/package.json.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vft",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.360",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.cjs",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -57,10 +57,10 @@
|
|
|
57
57
|
"photoswipe": "5.4.4",
|
|
58
58
|
"@vft/router": "0.0.65",
|
|
59
59
|
"@vft/use": "0.0.76",
|
|
60
|
-
"@vft/
|
|
61
|
-
"@vft/directives": "0.0.33",
|
|
60
|
+
"@vft/constants": "0.0.72",
|
|
62
61
|
"@vft/store": "0.0.54",
|
|
63
|
-
"@vft/
|
|
62
|
+
"@vft/utils": "0.0.128",
|
|
63
|
+
"@vft/directives": "0.0.33"
|
|
64
64
|
},
|
|
65
65
|
"vetur": {
|
|
66
66
|
"tags": "tags.json",
|
package/web-types.json
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"$schema":"http://json.schemastore.org/web-types","framework":"vue","name":"vft","version":"0.0.
|
|
1
|
+
{"$schema":"http://json.schemastore.org/web-types","framework":"vue","name":"vft","version":"0.0.360","js-types-syntax":"typescript","description-markup":"markdown","contributions":{"html":{}}}
|