vft 0.0.358 → 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 +9 -7
- 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
|
@@ -4,7 +4,7 @@ import { get as ot, cloneDeep as m, uniqBy as at, isEqual as ct, set as X } from
|
|
|
4
4
|
import { unref as n, toRaw as x, nextTick as W } from "vue";
|
|
5
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
|
-
function
|
|
7
|
+
function T(h, y) {
|
|
8
8
|
const { show: o, ifShow: c } = h;
|
|
9
9
|
let p = !0, f = !0;
|
|
10
10
|
return typeof o == "boolean" ? p = o : typeof o == "function" && (p = o({
|
|
@@ -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);
|
|
@@ -192,7 +192,7 @@ function Et({
|
|
|
192
192
|
const s = B(x(n(o)));
|
|
193
193
|
if (t)
|
|
194
194
|
return s;
|
|
195
|
-
const r = n(c).filter((l) =>
|
|
195
|
+
const r = n(c).filter((l) => T(l, n(o))).map((l) => l.field).filter(Boolean), a = {};
|
|
196
196
|
return r.forEach((l) => {
|
|
197
197
|
l in s && (a[l] = s[l]);
|
|
198
198
|
}), a;
|
|
@@ -204,17 +204,19 @@ function Et({
|
|
|
204
204
|
return n(c).some((e) => e.field === t ? ut(e.type) : !1);
|
|
205
205
|
}
|
|
206
206
|
async function $(t) {
|
|
207
|
-
return t || (t = n(c).filter((s) =>
|
|
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
209
|
async function P(t) {
|
|
210
|
-
return t || (t = n(c).filter((s) =>
|
|
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
|
}
|
|
213
213
|
async function D(t) {
|
|
214
214
|
await n(f)?.clearValidate(t);
|
|
215
215
|
}
|
|
216
216
|
async function tt(t, e) {
|
|
217
|
-
await D(t),
|
|
217
|
+
await D(t), setTimeout(async () => {
|
|
218
|
+
await N([{ field: t, itemProps: { error: e } }]);
|
|
219
|
+
});
|
|
218
220
|
}
|
|
219
221
|
async function et(t, e) {
|
|
220
222
|
await n(f)?.scrollToField(t, e);
|
|
@@ -233,7 +235,7 @@ function Et({
|
|
|
233
235
|
return;
|
|
234
236
|
const u = g();
|
|
235
237
|
if (s) {
|
|
236
|
-
const b = ct(
|
|
238
|
+
const b = ct(_.value, u), C = rt(_.value, u);
|
|
237
239
|
h("submit", u, !b, C);
|
|
238
240
|
} else
|
|
239
241
|
h("submit", u);
|
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 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
|
|
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",
|
|
@@ -55,12 +55,12 @@
|
|
|
55
55
|
"resize-detector": "0.3.0",
|
|
56
56
|
"sortablejs": "1.15.0",
|
|
57
57
|
"photoswipe": "5.4.4",
|
|
58
|
+
"@vft/router": "0.0.65",
|
|
59
|
+
"@vft/use": "0.0.76",
|
|
58
60
|
"@vft/constants": "0.0.72",
|
|
59
61
|
"@vft/store": "0.0.54",
|
|
60
|
-
"@vft/router": "0.0.65",
|
|
61
62
|
"@vft/utils": "0.0.128",
|
|
62
|
-
"@vft/directives": "0.0.33"
|
|
63
|
-
"@vft/use": "0.0.76"
|
|
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":{}}}
|