adverich-kun-ui 0.1.478 → 0.1.480
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ref as
|
|
2
|
-
const
|
|
1
|
+
import { ref as u, computed as b, provide as w, watch as x, createElementBlock as S, openBlock as E, mergeProps as F, withModifiers as O, renderSlot as _ } from "vue";
|
|
2
|
+
const k = {
|
|
3
3
|
__name: "KunForm",
|
|
4
4
|
props: {
|
|
5
5
|
gap: {
|
|
@@ -13,51 +13,77 @@ const b = {
|
|
|
13
13
|
maxWidth: {
|
|
14
14
|
type: String,
|
|
15
15
|
default: "max-w-full"
|
|
16
|
+
},
|
|
17
|
+
modelValue: {
|
|
18
|
+
// v-model para exponer validez
|
|
19
|
+
type: Boolean,
|
|
20
|
+
default: !0
|
|
21
|
+
},
|
|
22
|
+
validateOn: {
|
|
23
|
+
// submit, lazy, input
|
|
24
|
+
type: String,
|
|
25
|
+
default: "submit"
|
|
16
26
|
}
|
|
17
27
|
},
|
|
18
|
-
emits: ["submit"],
|
|
19
|
-
setup(
|
|
20
|
-
const i =
|
|
21
|
-
function
|
|
22
|
-
a.value.push(e);
|
|
28
|
+
emits: ["update:modelValue", "submit"],
|
|
29
|
+
setup(s, { expose: d, emit: f }) {
|
|
30
|
+
const i = s, n = f, a = u([]), l = u(!0), c = u(!1), p = u(null), m = b(() => l.value);
|
|
31
|
+
function v(e) {
|
|
32
|
+
a.value.includes(e) || a.value.push(e);
|
|
23
33
|
}
|
|
24
|
-
function
|
|
34
|
+
function y(e) {
|
|
25
35
|
a.value = a.value.filter((t) => t !== e);
|
|
26
36
|
}
|
|
27
|
-
async function
|
|
37
|
+
async function o() {
|
|
28
38
|
const e = await Promise.all(
|
|
29
|
-
a.value.map(async (t) => await t.validate())
|
|
39
|
+
a.value.map(async (t) => typeof t.validate == "function" ? await t.validate() : !0)
|
|
30
40
|
);
|
|
31
|
-
return
|
|
41
|
+
return l.value = e.every((t) => t === !0), n("update:modelValue", l.value), { valid: l.value };
|
|
32
42
|
}
|
|
33
|
-
function
|
|
43
|
+
function g() {
|
|
34
44
|
a.value.forEach((e) => {
|
|
35
|
-
e.reset && e.reset();
|
|
36
|
-
});
|
|
45
|
+
typeof e.reset == "function" && e.reset();
|
|
46
|
+
}), r();
|
|
37
47
|
}
|
|
38
|
-
function
|
|
48
|
+
function r() {
|
|
39
49
|
a.value.forEach((e) => {
|
|
40
|
-
e.resetValidation && e.resetValidation();
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
function
|
|
44
|
-
|
|
45
|
-
t
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
|
|
50
|
+
typeof e.resetValidation == "function" && e.resetValidation();
|
|
51
|
+
}), l.value = !0, n("update:modelValue", !0);
|
|
52
|
+
}
|
|
53
|
+
async function h(e) {
|
|
54
|
+
if (i.validateOn === "submit") {
|
|
55
|
+
const { valid: t } = await o();
|
|
56
|
+
t && n("submit", e);
|
|
57
|
+
} else
|
|
58
|
+
n("submit", e);
|
|
59
|
+
}
|
|
60
|
+
function V() {
|
|
61
|
+
i.validateOn === "input" && o();
|
|
62
|
+
}
|
|
63
|
+
return w("kunForm", {
|
|
64
|
+
registerField: v,
|
|
65
|
+
unregisterField: y,
|
|
66
|
+
onFieldChange: V,
|
|
67
|
+
validateOn: i.validateOn
|
|
68
|
+
}), d({
|
|
69
|
+
validate: o,
|
|
70
|
+
reset: g,
|
|
71
|
+
resetValidation: r,
|
|
72
|
+
valid: m,
|
|
73
|
+
isDirty: c
|
|
74
|
+
}), x(l, (e) => {
|
|
75
|
+
n("update:modelValue", e);
|
|
76
|
+
}), (e, t) => (E(), S("form", F({
|
|
77
|
+
ref_key: "formEl",
|
|
78
|
+
ref: p,
|
|
79
|
+
class: `flex flex-col w-full ${i.gap} ${i.padding} ${i.maxWidth}`,
|
|
54
80
|
novalidate: "",
|
|
55
|
-
|
|
81
|
+
onSubmit: O(h, ["prevent"])
|
|
56
82
|
}, e.$attrs), [
|
|
57
|
-
|
|
83
|
+
_(e.$slots, "default")
|
|
58
84
|
], 16));
|
|
59
85
|
}
|
|
60
86
|
};
|
|
61
87
|
export {
|
|
62
|
-
|
|
88
|
+
k as default
|
|
63
89
|
};
|