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 l, provide as s, createElementBlock as h, openBlock as y, mergeProps as x, withModifiers as S, renderSlot as w } from "vue";
2
- const b = {
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(o, { expose: u, emit: f }) {
20
- const i = o, d = f, a = l([]), r = l(!0);
21
- function p(e) {
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 c(e) {
34
+ function y(e) {
25
35
  a.value = a.value.filter((t) => t !== e);
26
36
  }
27
- async function n() {
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 r.value = e.every((t) => t === !0), { valid: r.value };
41
+ return l.value = e.every((t) => t === !0), n("update:modelValue", l.value), { valid: l.value };
32
42
  }
33
- function m() {
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 v() {
48
+ function r() {
39
49
  a.value.forEach((e) => {
40
- e.resetValidation && e.resetValidation();
41
- });
42
- }
43
- function g(e) {
44
- e && typeof e.preventDefault == "function" && e.preventDefault(), n().then(({ valid: t }) => {
45
- t && d("submit", e);
46
- });
47
- }
48
- return s("registerField", p), s("unregisterField", c), u({
49
- validate: n,
50
- reset: m,
51
- resetValidation: v
52
- }), (e, t) => (y(), h("form", x({
53
- onSubmit: S(g, ["prevent"]),
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
- class: `flex flex-col w-full ${i.gap} ${i.padding} ${i.maxWidth}`
81
+ onSubmit: O(h, ["prevent"])
56
82
  }, e.$attrs), [
57
- w(e.$slots, "default")
83
+ _(e.$slots, "default")
58
84
  ], 16));
59
85
  }
60
86
  };
61
87
  export {
62
- b as default
88
+ k as default
63
89
  };
@@ -58,7 +58,7 @@ const e = {
58
58
  hour: "2-digit",
59
59
  minute: "2-digit",
60
60
  second: "2-digit",
61
- hourCycle: "h24"
61
+ hourCycle: "h23"
62
62
  }).format(n);
63
63
  },
64
64
  secondsToTime: (t) => m(t ?? 0)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.478",
3
+ "version": "0.1.480",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",