ideaz-element
Version:
<p align="center"> <a href="" target="_blank" rel="noopener noreferrer"> <img src="./docs/public/logo.svg" alt="Ideaz Element" width="180" style="width: 180px;" /> </a> </p>
53 lines (52 loc) • 1.91 kB
JavaScript
import { getCurrentInstance as u } from "vue";
import "../../../../node_modules/.pnpm/lodash-unified@1.0.3_@types_lodash-es@4.17.12_lodash-es@4.17.21_lodash@4.17.21/node_modules/lodash-unified/import.mjs";
import "../../../../utils/index.mjs";
import { isObject as d, isFunction as y } from "../../../../utils/is.mjs";
import F from "../../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/cloneDeep.mjs";
function T(t) {
const { proxy: e } = u(), i = d(t) && d(t.modelValue) ? F(t.modelValue) : null, n = (r, a, l) => {
Object.keys(e.$refs).forEach((s) => {
s.includes("arrayForm") && e.$refs[s][r](a, l);
});
};
return { resetFields: () => {
t && t.type === "array" ? n("resetFields") : ((e == null ? void 0 : e.$refs.formRef).resetFields(), i && Object.keys(i).forEach((r) => {
t.modelValue[r] = i[r];
}));
}, validate: async (r) => {
try {
if (t && t.type === "array") {
let a = !0;
const l = Object.keys(e.$refs);
let s = {};
for (let o = 0; o < l.length; o++) {
const f = l[o];
f.includes("arrayForm") && e.$refs[f] && await e.$refs[f].validate((c, m) => {
c || (a = !1, s = { ...s, ...m });
});
}
return y(r) ? r(a, s) : a;
} else
return await (e == null ? void 0 : e.$refs.formRef).validate(r);
} catch {
return !1;
}
}, validateField: async (r, a) => {
try {
return await (e == null ? void 0 : e.$refs.formRef).validateField(
r,
a
);
} catch {
return !1;
}
}, clearValidate: (r) => {
t && t.type === "array" ? n("clearValidate", t) : (e == null ? void 0 : e.$refs.formRef).clearValidate(r);
}, scrollToField: (r) => {
(e == null ? void 0 : e.$refs.formRef).scrollToField(r);
} };
}
export {
T as useFormMethods
};
//# sourceMappingURL=useFormMethods.mjs.map