adverich-kun-ui 0.1.91 → 0.1.92

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,58 +1,59 @@
1
- import { mergeModels as E, useModel as L, onMounted as te, ref as le, watch as oe, createBlock as d, openBlock as i, unref as e, isRef as R, createSlots as ne, withCtx as r, createElementBlock as U, createCommentVNode as h, createVNode as a, Fragment as re, renderList as ie, createElementVNode as ae, createTextVNode as b, toDisplayString as V, normalizeClass as se, withModifiers as ue } from "vue";
1
+ import { mergeModels as A, useModel as E, onMounted as le, ref as oe, watch as ne, createBlock as d, openBlock as i, unref as e, isRef as L, createSlots as re, withCtx as r, createElementBlock as R, createCommentVNode as h, createVNode as a, Fragment as ie, renderList as ae, createElementVNode as se, createTextVNode as b, toDisplayString as V, normalizeClass as ue, withModifiers as de } from "vue";
2
2
  import { icons as f } from "../../../../icons/index.js";
3
- import { isNotEmpty as de, isArray as z } from "../../../../utils/utils.js";
4
- import ce from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
5
- import me from "../../../KunList/src/components/KunList.vue.js";
6
- import B from "../../../KunListItem/src/components/KunListItem.vue.js";
7
- import fe from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
8
- import pe from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
9
- import ke from "../../../kunMenu/src/components/kunMenu.vue.js";
10
- import { useAutocomplete as ye } from "../composables/useAutocomplete.js";
11
- import { KunAutocompleteProps as he } from "../composables/KunAutocompleteProps.js";
12
- import ve from "../../../KunTextField/src/components/KunTextField.vue.js";
3
+ import { isNotEmpty as ce, isArray as U } from "../../../../utils/utils.js";
4
+ import me from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
5
+ import fe from "../../../KunList/src/components/KunList.vue.js";
6
+ import z from "../../../KunListItem/src/components/KunListItem.vue.js";
7
+ import pe from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
8
+ import ke from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
9
+ import ye from "../../../kunMenu/src/components/kunMenu.vue.js";
10
+ import { useAutocomplete as he } from "../composables/useAutocomplete.js";
11
+ import { KunAutocompleteProps as ve } from "../composables/KunAutocompleteProps.js";
12
+ import ge from "../../../KunTextField/src/components/KunTextField.vue.js";
13
13
  import Ce from "../../../KunBtn/src/components/KunBtn.vue.js";
14
- import ge from "../../../KunChip/src/components/KunChip.vue.js";
14
+ import be from "../../../KunChip/src/components/KunChip.vue.js";
15
15
  import v from "../../../KunIcon/src/components/KunIcon.vue.js";
16
- const be = {
16
+ const Ve = {
17
17
  key: 0,
18
18
  class: "flex justify-center align-center"
19
- }, Ve = { class: "flex justify-center align-center" }, Be = {
19
+ }, Ie = { class: "flex justify-center align-center" }, Fe = {
20
20
  __name: "KunAutocomplete",
21
- props: /* @__PURE__ */ E(he, {
21
+ props: /* @__PURE__ */ A(ve, {
22
22
  modelValue: { default: null },
23
23
  modelModifiers: {},
24
24
  items: { default: [], type: Array, required: !0 },
25
25
  itemsModifiers: {}
26
26
  }),
27
- emits: /* @__PURE__ */ E(["createItem", "validation", "search"], ["update:modelValue", "update:items"]),
28
- setup(C, { emit: F }) {
29
- const u = L(C, "modelValue"), I = L(C, "items"), n = C, p = F, {
27
+ emits: /* @__PURE__ */ A(["update:model-value", "createItem", "validation", "search"], ["update:modelValue", "update:items"]),
28
+ setup(g, { emit: B }) {
29
+ const u = E(g, "modelValue"), I = E(g, "items"), n = g, p = B, {
30
30
  selectedItem: c,
31
31
  textFieldRef: k,
32
- listRef: g,
32
+ listRef: C,
33
33
  menuModel: s,
34
34
  search: m,
35
- removeItem: N,
36
- clearSelection: T,
35
+ removeItem: F,
36
+ clearSelection: N,
37
37
  lightReset: w,
38
- openMenu: K,
39
- onMenuKeydown: _,
40
- getSelectedItem: H,
41
- textArr: O,
42
- getItemText: j,
43
- createItem: q,
44
- checkDisabled: P,
45
- itemToString: S,
46
- placeholder: D,
47
- hasCreateItem: W
48
- } = ye(n, p, u, I);
49
- te(() => {
38
+ openMenu: T,
39
+ toggleMenu: H,
40
+ onMenuKeydown: K,
41
+ getSelectedItem: O,
42
+ textArr: j,
43
+ getItemText: q,
44
+ createItem: P,
45
+ checkDisabled: W,
46
+ itemToString: _,
47
+ placeholder: M,
48
+ hasCreateItem: G
49
+ } = he(n, p, u, I);
50
+ le(() => {
50
51
  n.focusOnRender && k.value.focus();
51
52
  });
52
- function G(t) {
53
- return u.value === null || u.value === void 0 ? n.bgItemListColor : n.multiple ? u.value.find((o) => o[n.itemValue] === t[n.itemValue]) ? n.selectedColor : n.bgItemListColor : D.value === t[n.itemTitle] ? n.selectedColor : n.bgItemListColor;
53
+ function J(t) {
54
+ return u.value === null || u.value === void 0 ? n.bgItemListColor : n.multiple ? u.value.find((o) => o[n.itemValue] === t[n.itemValue]) ? n.selectedColor : n.bgItemListColor : M.value === t[n.itemTitle] ? n.selectedColor : n.bgItemListColor;
54
55
  }
55
- const y = le(""), M = (t) => {
56
+ const y = oe(""), S = (t) => {
56
57
  for (const o of n.rules) {
57
58
  const l = o(t);
58
59
  if (l !== !0)
@@ -60,43 +61,43 @@ const be = {
60
61
  }
61
62
  return y.value = "", p("validation", !0), !0;
62
63
  };
63
- oe(() => u.value, (t, o) => {
64
- de(n.rules) && M(t);
64
+ ne(() => u.value, (t, o) => {
65
+ ce(n.rules) && S(t);
65
66
  });
66
- function $() {
67
+ function D() {
67
68
  var t;
68
69
  s.value = !1, (t = k.value.inputField) == null || t.focus();
69
70
  }
70
- function J(t) {
71
+ function Q(t) {
71
72
  p("search", m);
72
73
  }
73
- function Q() {
74
- M(u);
74
+ function X() {
75
+ S(u);
75
76
  }
76
- function X(t) {
77
+ function Y(t) {
77
78
  const o = t.key;
78
79
  if (o === "Escape") {
79
- $();
80
+ D();
80
81
  return;
81
82
  }
82
83
  if (["ArrowDown", "ArrowUp"].includes(o)) {
83
- if (!g.value) return;
84
- g.value.focusWithKey(o);
84
+ if (!C.value) return;
85
+ C.value.focusWithKey(o);
85
86
  return;
86
87
  }
87
- _(t);
88
+ K(t);
88
89
  }
89
- function Y(t) {
90
- _(t);
90
+ function Z(t) {
91
+ K(t);
91
92
  }
92
- function Z() {
93
+ function ee() {
93
94
  s.value = !1;
94
95
  }
95
- return (t, o) => (i(), d(ve, {
96
+ return (t, o) => (i(), d(ge, {
96
97
  modelValue: e(m),
97
98
  "onUpdate:modelValue": [
98
- o[2] || (o[2] = (l) => R(m) ? m.value = l : null),
99
- J
99
+ o[2] || (o[2] = (l) => L(m) ? m.value = l : null),
100
+ Q
100
101
  ],
101
102
  label: t.label,
102
103
  dirty: "",
@@ -105,61 +106,61 @@ const be = {
105
106
  ref_key: "textFieldRef",
106
107
  ref: k,
107
108
  autocomplete: "off",
108
- onKeyDown: X,
109
- onFocusInput: Q,
110
- onHandleClick: e(K),
111
- onBlurInput: Z,
112
- placeholder: n.multiple && e(z)(e(c)) && e(c).length ? "" : e(D),
109
+ onKeyDown: Y,
110
+ onFocusInput: X,
111
+ onHandleClick: e(H),
112
+ onBlurInput: ee,
113
+ placeholder: n.multiple && e(U)(e(c)) && e(c).length ? "" : e(M),
113
114
  error: !!y.value,
114
115
  "error-messages": y.value
115
- }, ne({
116
+ }, re({
116
117
  default: r(() => [
117
- e(z)(e(c)) ? (i(), U("div", be, [
118
- (i(!0), U(re, null, ie(e(c), (l) => (i(), d(ge, {
118
+ e(U)(e(c)) ? (i(), R("div", Ve, [
119
+ (i(!0), R(ie, null, ae(e(c), (l) => (i(), d(be, {
119
120
  key: l.id ?? l.name,
120
121
  size: "small",
121
122
  class: "ml-1"
122
123
  }, {
123
124
  default: r(() => [
124
- ae("div", Ve, [
125
- b(V(e(j)(l, t.itemTitle)) + " ", 1),
125
+ se("div", Ie, [
126
+ b(V(e(q)(l, t.itemTitle)) + " ", 1),
126
127
  a(v, {
127
128
  color: "error",
128
129
  icon: e(f).close,
129
130
  size: "small",
130
131
  class: "ml-1",
131
- onClick: (ee) => e(N)(l)
132
+ onClick: (te) => e(F)(l)
132
133
  }, null, 8, ["icon", "onClick"])
133
134
  ])
134
135
  ]),
135
136
  _: 2
136
137
  }, 1024))), 128))
137
138
  ])) : h("", !0),
138
- a(ke, {
139
+ a(ye, {
139
140
  transition: "fade",
140
141
  "onClick:outside": e(w),
141
142
  modelValue: e(s),
142
- "onUpdate:modelValue": o[1] || (o[1] = (l) => R(s) ? s.value = l : null),
143
+ "onUpdate:modelValue": o[1] || (o[1] = (l) => L(s) ? s.value = l : null),
143
144
  activator: "parent",
144
145
  "parent-ref": e(k),
145
- onHandleEscape: $,
146
+ onHandleEscape: D,
146
147
  "close-on-content-click": t.closeOnSelect,
147
148
  "max-height": t.maxHeight,
148
149
  "hide-details": t.hideDetails
149
150
  }, {
150
151
  default: r(() => [
151
- a(me, {
152
- "onUpdate:selected": e(H),
152
+ a(fe, {
153
+ "onUpdate:selected": e(O),
153
154
  "onClick:select": o[0] || (o[0] = (l) => e(w)()),
154
155
  ref_key: "listRef",
155
- ref: g,
156
- onKeyDown: Y
156
+ ref: C,
157
+ onKeyDown: Z
157
158
  }, {
158
159
  default: r(() => [
159
- e(W) ? (i(), d(B, { key: 0 }, {
160
+ e(G) ? (i(), d(z, { key: 0 }, {
160
161
  default: r(() => [
161
162
  a(Ce, {
162
- onClick: e(q),
163
+ onClick: e(P),
163
164
  class: "w-full",
164
165
  color: "bg-green-400"
165
166
  }, {
@@ -172,7 +173,7 @@ const be = {
172
173
  ]),
173
174
  _: 1
174
175
  })) : h("", !0),
175
- a(ce, {
176
+ a(me, {
176
177
  items: I.value,
177
178
  search: e(m),
178
179
  "searchable-keys": n.searchableKeys,
@@ -181,26 +182,26 @@ const be = {
181
182
  virtual: !1,
182
183
  "item-height": 48
183
184
  }, {
184
- default: r(({ item: l, index: ee }) => {
185
- var x, A;
185
+ default: r(({ item: l, index: te }) => {
186
+ var $, x;
186
187
  return [
187
- (i(), d(B, {
188
+ (i(), d(z, {
188
189
  value: l,
189
- key: ((x = l.id) == null ? void 0 : x.toString()) ?? l.name,
190
- disabled: e(P)(l),
191
- class: se(G(l)),
190
+ key: (($ = l.id) == null ? void 0 : $.toString()) ?? l.name,
191
+ disabled: e(W)(l),
192
+ class: ue(J(l)),
192
193
  density: t.density,
193
- id: ((A = l.id) == null ? void 0 : A.toString()) ?? l.name
194
+ id: ((x = l.id) == null ? void 0 : x.toString()) ?? l.name
194
195
  }, {
195
196
  default: r(() => [
196
- a(fe, { class: "text-wrap" }, {
197
+ a(pe, { class: "text-wrap" }, {
197
198
  default: r(() => [
198
- b(V(e(S)(l, e(O), "hasDefault")), 1)
199
+ b(V(e(_)(l, e(j), "hasDefault")), 1)
199
200
  ]),
200
201
  _: 2
201
202
  }, 1024),
202
- a(pe, {
203
- textContent: V(t.itemSubtitle ? e(S)(l, t.itemSubtitle) : "")
203
+ a(ke, {
204
+ textContent: V(t.itemSubtitle ? e(_)(l, t.itemSubtitle) : "")
204
205
  }, null, 8, ["textContent"])
205
206
  ]),
206
207
  _: 2
@@ -223,7 +224,7 @@ const be = {
223
224
  fn: r(() => [
224
225
  t.clearable && e(c) ? (i(), d(v, {
225
226
  key: 0,
226
- onClick: e(T),
227
+ onClick: e(N),
227
228
  size: "small",
228
229
  color: "error",
229
230
  icon: e(f).close,
@@ -234,7 +235,7 @@ const be = {
234
235
  size: "large",
235
236
  class: "cursor-pointer",
236
237
  icon: e(s) ? e(f).menuUpOutline : e(f).menuDownOutline,
237
- onClick: ue(e(K), ["stop"])
238
+ onClick: de(e(T), ["stop"])
238
239
  }, null, 8, ["icon", "onClick"]),
239
240
  t.required ? (i(), d(v, {
240
241
  key: 1,
@@ -250,5 +251,5 @@ const be = {
250
251
  }
251
252
  };
252
253
  export {
253
- Be as default
254
+ Fe as default
254
255
  };
@@ -1,143 +1,113 @@
1
- import { ref as b, computed as d } from "vue";
2
- import { isArray as o, isObject as a } from "../../../../utils/utils.js";
3
- function W(u, C, l, h, G) {
4
- const n = b(null), O = b(null), T = b(null), v = b(!1), c = b(""), g = (e, t) => t.split(".").reduce((r, i) => r && r[i] !== void 0 ? r[i] : null, e);
5
- function L() {
6
- o(l.value) && (l.value.length ? n.value = h.value.filter((e) => {
7
- let t = g(e, u.itemTitle);
8
- return a(e) ? l.value.some(
9
- (r) => g(r, u.itemTitle).includes(t)
10
- ) : l.value.some((r) => r.includes(e));
11
- }) : n.value = []), (a(l.value) && Object.keys(l.value).length || typeof l.value == "number" && l.value || typeof l.value == "string" && l.value || typeof l.value == "boolean") && (n.value = h.value.find(
12
- (e) => a(e) ? u.returnObject ? u.itemValue ? e[u.itemValue] === l.value[u.itemValue] : e[u.itemTitle] === l.value[u.itemTitle] : e[u.itemValue] === l.value : e === l.value
13
- ));
14
- }
15
- const M = d(() => n.value ? o(n.value) ? n.value.length ? x(n.value, u.itemTitle, "hasDefault") : u.placeholderText : a(n.value) ? x(n.value, u.itemTitle, "hasDefault") : n.value.toString() : h.value.length ? u.placeholderText : u.textNoItems), k = d(() => u.startEmtpy && c.value.length < 3 ? [] : h.value.filter((t) => {
16
- if (a(t)) {
17
- const r = Object.values(t).filter((f) => {
18
- if (!a(f) && !o(f))
19
- return f;
20
- }), i = [t].reduce((f, F) => u.searchableKeys.map((y) => y.includes(".") ? y.split(".").reduce((K, z) => K && K[z], F) : F[y]), []), s = u.searchableKeys.length ? i : r;
21
- return s ? s.some(
22
- (f) => f ? f.toString().toLowerCase().includes(c.value.toLowerCase()) : ""
23
- ) : c.value ? t == c.value : t;
24
- }
25
- return t.toString().toLowerCase().includes(c.value.toLowerCase());
26
- })), R = d(() => u.itemText.includes(",") ? u.itemText.split(",") : u.itemText);
27
- function x(e, t, r) {
28
- if (a(e)) {
29
- if (t) {
30
- if (o(t))
31
- return t.map((i) => e[i] ?? "No definido").join(" - ");
32
- if (t.includes(","))
33
- return t.split(",").map((i) => e[i]).join(" - ");
34
- if (t.includes(".")) {
35
- const i = t.split(".");
36
- let s = e;
37
- for (const f of i)
38
- s = s[f];
39
- return s;
1
+ import { ref as a, computed as S } from "vue";
2
+ import { isArray as o, isObject as c } from "../../../../utils/utils.js";
3
+ function z(u, O, r, T, P) {
4
+ const t = a(null), v = a(null), b = a(null), i = a(!1), s = a(""), A = (e, n) => n.split(".").reduce((f, l) => f && f[l] !== void 0 ? f[l] : null, e), M = S(() => t.value ? o(t.value) ? t.value.length ? d(t.value, u.itemTitle, "hasDefault") : u.placeholderText : c(t.value) ? d(t.value, u.itemTitle, "hasDefault") : t.value.toString() : T.value.length ? u.placeholderText : u.textNoItems), V = S(() => u.itemText.includes(",") ? u.itemText.split(",") : u.itemText);
5
+ function d(e, n, f) {
6
+ if (c(e)) {
7
+ if (n) {
8
+ if (o(n))
9
+ return n.map((l) => e[l] ?? "No definido").join(" - ");
10
+ if (n.includes(","))
11
+ return n.split(",").map((l) => e[l]).join(" - ");
12
+ if (n.includes(".")) {
13
+ const l = n.split(".");
14
+ let x = e;
15
+ for (const K of l)
16
+ x = x[K];
17
+ return x;
40
18
  }
41
- return !u.returnObject && typeof e[t] == "number" || e[t] ? e[t].toString() : "";
19
+ return !u.returnObject && typeof e[n] == "number" || e[n] ? e[n].toString() : "";
42
20
  }
43
- if (r)
21
+ if (f)
44
22
  return Object.values(e)[0];
45
23
  }
46
- return o(e) ? u.returnObject ? e.map((i) => i[t]).join(" - ") : e.map((i) => i).join(" - ") : r && typeof e != "number" && e.includes(",") ? e.split(",") : e;
24
+ return o(e) ? u.returnObject ? e.map((l) => l[n]).join(" - ") : e.map((l) => l).join(" - ") : f && typeof e != "number" && e.includes(",") ? e.split(",") : e;
47
25
  }
48
- function D(e) {
49
- let t = e[0];
50
- if (!u.multiple)
51
- n.value = e[0], u.returnObject && (l.value = t), !u.returnObject && a(t) && (u.itemValue ? l.value = t[u.itemValue] : l.value = Object.values(t)[0]), a(t) || (l.value = t), v.value = !1;
52
- else if (n.value || (n.value = []), S(t))
53
- t && I(t), l.value = n.value;
54
- else {
55
- if (u.returnObject && n.value.push(t), !u.returnObject && a(t))
56
- if (u.itemValue)
57
- n.value.push(t[u.itemValue]);
58
- else {
59
- l.value = n.value.push(Object.values(t)[0]);
60
- return;
61
- }
62
- l.value = n.value;
26
+ function F(e) {
27
+ try {
28
+ u.multiple ? (t.value || (t.value = []), m(e) ? e && g(e) : u.returnObject ? t.value.push(e) : c(e) ? u.itemValue ? t.value.push(e[u.itemValue]) : t.value.push(Object.values(e)[0]) : t.value.push(e)) : (u.returnObject ? t.value = e : c(result) ? u.itemValue ? t.value = e[u.itemValue] : t.value = Object.values(result)[0] : t.value = result, i.value = !1), O("update:model-value", t.value), u.clearOnSelect && I();
29
+ } catch (n) {
30
+ console.log(n);
31
+ } finally {
32
+ h();
63
33
  }
64
- u.clearOnSelect && w(), j();
65
34
  }
66
- function S(e) {
67
- return n.value === null ? !1 : e ? n.value.some(
68
- (t) => u.returnObject ? t[u.itemValue] === e[u.itemValue] : t === e[u.itemValue]
35
+ function m(e) {
36
+ return t.value === null ? !1 : e ? t.value.some(
37
+ (n) => u.returnObject ? n[u.itemValue] === e[u.itemValue] : n === e[u.itemValue]
69
38
  ) : !0;
70
39
  }
71
- function I(e) {
40
+ function g(e) {
72
41
  if (u.returnObject) {
73
- let t = n.value.find(
74
- (i) => i[u.itemValue] === e[u.itemValue]
75
- ), r = n.value.indexOf(t);
76
- n.value.splice(r, 1);
42
+ const n = t.value.find(
43
+ (l) => l[u.itemValue] === e[u.itemValue]
44
+ ), f = t.value.indexOf(n);
45
+ t.value.splice(f, 1);
77
46
  } else {
78
- let t = n.value.indexOf(e[u.itemValue]);
79
- n.value.splice(t, 1);
47
+ const n = t.value.indexOf(e[u.itemValue]);
48
+ t.value.splice(n, 1);
80
49
  }
81
50
  }
82
- function E(e) {
83
- u.clearSearchOnSelect && (c.value = ""), u.focusOnSelect && j();
51
+ function k(e) {
52
+ u.clearSearchOnSelect && (s.value = ""), u.focusOnSelect && h();
53
+ }
54
+ function j() {
55
+ i.value || (i.value = !0);
84
56
  }
85
- function m() {
86
- v.value = !v.value;
57
+ function R() {
58
+ i.value = !i.value;
87
59
  }
88
- function A(e) {
60
+ function y(e) {
89
61
  return e.length === 1 && e.match(/\w/);
90
62
  }
91
- function j() {
92
- O.value.inputField.focus();
63
+ function h() {
64
+ v.value.inputField.focus();
93
65
  }
94
- function N() {
95
- v.value = !0, T.value && O.value.$el.focus();
66
+ function w() {
67
+ i.value = !0, b.value && v.value.$el.focus();
96
68
  }
97
- function B(e) {
98
- const t = e.key;
99
- (A(t) || t === "Backspace") && (m(), j());
69
+ function D(e) {
70
+ const n = e.key;
71
+ (y(n) || n === "Backspace") && (j(), h());
100
72
  }
101
- function P() {
102
- v.value = !1, C("createItem");
73
+ function N() {
74
+ i.value = !1, O("createItem");
103
75
  }
104
- function $(e) {
105
- let t = n.value.indexOf(e);
106
- n.value.splice(t, 1), l.value = n.value;
76
+ function B(e) {
77
+ let n = t.value.indexOf(e);
78
+ t.value.splice(n, 1);
107
79
  }
108
- function w() {
109
- c.value = "", o(l.value) && (n.value = []), a(l.value) && (n.value = {}), typeof l.value == "number" && l.value && (n.value = null), typeof l.value == "string" && l.value && (n.value = ""), typeof l.value == "boolean" && (n.value = !1), l.value = n.value;
80
+ function I() {
81
+ s.value = "", o(r.value) && (t.value = []), c(r.value) && (t.value = null), typeof r.value == "number" && r.value && (t.value = null), typeof r.value == "string" && r.value && (t.value = null), typeof r.value == "boolean" && (t.value = !1);
110
82
  }
111
- function q(e) {
112
- if (!e.disabledItem) return !1;
113
- if (e.disabledItem) return !0;
83
+ function E(e) {
84
+ return !!e.disabledItem;
114
85
  }
115
86
  return {
116
- selectedItem: n,
117
- textFieldRef: O,
118
- listRef: T,
119
- menuModel: v,
120
- search: c,
121
- getItemText: g,
122
- setSelectedItemValue: L,
87
+ selectedItem: t,
88
+ textFieldRef: v,
89
+ listRef: b,
90
+ menuModel: i,
91
+ search: s,
92
+ getItemText: A,
123
93
  placeholder: M,
124
- filteredItems: k,
125
- textArr: R,
126
- itemToString: x,
127
- getSelectedItem: D,
128
- checkIfValueExist: S,
129
- removeFromArray: I,
130
- lightReset: E,
131
- openMenu: m,
132
- focusOnMenu: N,
133
- onMenuKeydown: B,
134
- createItem: P,
135
- removeItem: $,
136
- clearSelection: w,
137
- checkDisabled: q,
138
- isAlphanumeric: A
94
+ textArr: V,
95
+ itemToString: d,
96
+ getSelectedItem: F,
97
+ checkIfValueExist: m,
98
+ removeFromArray: g,
99
+ lightReset: k,
100
+ openMenu: j,
101
+ toggleMenu: R,
102
+ focusOnMenu: w,
103
+ onMenuKeydown: D,
104
+ createItem: N,
105
+ removeItem: B,
106
+ clearSelection: I,
107
+ checkDisabled: E,
108
+ isAlphanumeric: y
139
109
  };
140
110
  }
141
111
  export {
142
- W as useAutocomplete
112
+ z as useAutocomplete
143
113
  };
@@ -1,6 +1,6 @@
1
- import { ref as c, provide as v, createElementBlock as b, openBlock as h, mergeProps as k, renderSlot as A } from "vue";
2
- import { useKunList as B } from "../composables/useKunList.js";
3
- const K = {
1
+ import { ref as d, provide as h, createElementBlock as k, openBlock as A, mergeProps as B, renderSlot as S } from "vue";
2
+ import { useKunList as D } from "../composables/useKunList.js";
3
+ const L = {
4
4
  __name: "KunList",
5
5
  props: {
6
6
  nav: Boolean,
@@ -9,7 +9,7 @@ const K = {
9
9
  selectable: {
10
10
  type: [Boolean, String],
11
11
  default: !1,
12
- validator: (r) => ["single", "multiple", !0, !1].includes(r)
12
+ validator: (l) => ["single", "multiple", !0, !1].includes(l)
13
13
  },
14
14
  bgList: {
15
15
  type: String,
@@ -20,61 +20,69 @@ const K = {
20
20
  default: "border-gray-300 dark:border-gray-700"
21
21
  }
22
22
  },
23
- emits: ["keyDown"],
24
- setup(r, { expose: d, emit: m }) {
25
- const g = r, w = m;
26
- B(g);
27
- const u = c(null), l = c([]);
28
- d({
23
+ emits: ["keyDown", "click:select", "update:selected"],
24
+ setup(l, { expose: m, emit: g }) {
25
+ const p = l, s = g;
26
+ D(p);
27
+ const u = d(null), r = d([]);
28
+ m({
29
29
  focusWithKey: (e) => {
30
30
  var n, o;
31
- const t = l.value.filter(Boolean);
31
+ const t = r.value.filter(Boolean);
32
32
  t.length !== 0 && (e === "ArrowDown" ? (n = t[0]) == null || n.focus() : e === "ArrowUp" && ((o = t[t.length - 1]) == null || o.focus()));
33
33
  },
34
34
  focus: () => {
35
35
  var e, t;
36
36
  (t = (e = u.value) == null ? void 0 : e.focus) == null || t.call(e);
37
37
  }
38
- }), v("registerListItemRef", (e) => {
39
- e ? l.value.includes(e) || l.value.push(e) : l.value = l.value.filter((t) => t !== e);
38
+ }), h("registerListItemRef", (e) => {
39
+ e ? r.value.includes(e) || r.value.push(e) : r.value = r.value.filter((t) => t !== e);
40
40
  });
41
- function p(e) {
42
- var i, f, a;
41
+ function w(e) {
42
+ var a, c, f;
43
43
  const t = e.key;
44
- if (w("keyDown", e), !["ArrowDown", "ArrowUp"].includes(t)) return;
44
+ if (s("keyDown", e), !["ArrowDown", "ArrowUp"].includes(t)) return;
45
45
  e.preventDefault();
46
- const n = l.value.filter(Boolean);
46
+ const n = r.value.filter(Boolean);
47
47
  if (n.length === 0) return;
48
- const o = n.findIndex((y) => y === document.activeElement);
48
+ const o = n.findIndex((b) => b === document.activeElement);
49
49
  if (o === -1) {
50
- t === "ArrowDown" ? (i = n[0]) == null || i.focus() : t === "ArrowUp" && ((f = n[n.length - 1]) == null || f.focus());
50
+ t === "ArrowDown" ? (a = n[0]) == null || a.focus() : t === "ArrowUp" && ((c = n[n.length - 1]) == null || c.focus());
51
51
  return;
52
52
  }
53
- let s = o;
54
- t === "ArrowDown" ? s = (o + 1) % n.length : t === "ArrowUp" && (s = (o - 1 + n.length) % n.length), (a = n[s]) == null || a.focus();
53
+ let i = o;
54
+ t === "ArrowDown" ? i = (o + 1) % n.length : t === "ArrowUp" && (i = (o - 1 + n.length) % n.length), (f = n[i]) == null || f.focus();
55
55
  }
56
- return (e, t) => (h(), b("ul", k({
56
+ function y(e) {
57
+ s("click:select", e.detail);
58
+ }
59
+ function v(e) {
60
+ s("update:selected", e.detail);
61
+ }
62
+ return (e, t) => (A(), k("ul", B({
57
63
  role: "list",
58
64
  class: ["w-full", [
59
65
  "kun-list",
60
- r.bgList,
61
- r.borderColor,
66
+ l.bgList,
67
+ l.borderColor,
62
68
  {
63
- "space-y-1": !r.dense,
64
- "space-y-0.5": r.dense,
65
- "pl-4 border-l-2": r.sub,
66
- "p-2 rounded-md": r.nav
69
+ "space-y-1": !l.dense,
70
+ "space-y-0.5": l.dense,
71
+ "pl-4 border-l-2": l.sub,
72
+ "p-2 rounded-md": l.nav
67
73
  }
68
74
  ]],
69
75
  ref_key: "ulRef",
70
76
  ref: u,
71
77
  tabindex: "-1",
72
- onKeydown: p
78
+ onKeydown: w,
79
+ onSelect: y,
80
+ onSelected: v
73
81
  }, e.$attrs), [
74
- A(e.$slots, "default")
82
+ S(e.$slots, "default")
75
83
  ], 16));
76
84
  }
77
85
  };
78
86
  export {
79
- K as default
87
+ L as default
80
88
  };
@@ -1,5 +1,5 @@
1
- import { ref as c, inject as o, onMounted as f, onBeforeUnmount as b, computed as s, createElementBlock as g, openBlock as m, mergeProps as v, renderSlot as y } from "vue";
2
- const k = ["aria-selected", "aria-disabled"], h = {
1
+ import { ref as b, inject as d, onMounted as v, onBeforeUnmount as g, computed as c, createElementBlock as m, openBlock as y, mergeProps as k, renderSlot as h } from "vue";
2
+ const B = ["aria-selected", "aria-disabled"], p = {
3
3
  __name: "KunListItem",
4
4
  props: {
5
5
  value: {
@@ -34,25 +34,35 @@ const k = ["aria-selected", "aria-disabled"], h = {
34
34
  }
35
35
  },
36
36
  setup(e) {
37
- const a = e, i = c(null), r = o("registerListItemRef", null), t = o("kun-list", null);
38
- f(() => {
39
- r && i.value && r(i.value);
40
- }), b(() => {
41
- r && r(null);
37
+ const a = e, n = b(null), u = d("registerListItemRef", null), t = d("kun-list", null);
38
+ v(() => {
39
+ u && n.value && u(n.value);
40
+ }), g(() => {
41
+ u && u(null);
42
42
  });
43
- const n = s(() => {
43
+ const r = c(() => {
44
44
  var l;
45
45
  return ((l = t == null ? void 0 : t.isSelected) == null ? void 0 : l.call(t, a.value)) ?? !1;
46
- }), u = s(() => a.active);
47
- function d() {
48
- var l;
49
- a.disabled || t && a.value !== null && ((l = t.toggleItem) == null || l.call(t, a.value));
46
+ }), o = c(() => a.active);
47
+ function f() {
48
+ var l, i, s;
49
+ a.disabled || (t && a.value !== null && ((l = t.toggleItem) == null || l.call(t, a.value)), (i = n.value) == null || i.dispatchEvent(
50
+ new CustomEvent("select", {
51
+ detail: a.value,
52
+ bubbles: !0
53
+ })
54
+ ), (s = n.value) == null || s.dispatchEvent(
55
+ new CustomEvent("selected", {
56
+ detail: a.value,
57
+ bubbles: !0
58
+ })
59
+ ));
50
60
  }
51
- return (l, B) => (m(), g("li", v({
61
+ return (l, i) => (y(), m("li", k({
52
62
  ref_key: "liRef",
53
- ref: i,
63
+ ref: n,
54
64
  role: "option",
55
- "aria-selected": n.value || u.value,
65
+ "aria-selected": r.value || o.value,
56
66
  "aria-disabled": e.disabled,
57
67
  tabindex: "-1",
58
68
  class: ["w-full flex flex-col", [
@@ -63,16 +73,16 @@ const k = ["aria-selected", "aria-disabled"], h = {
63
73
  {
64
74
  "cursor-not-allowed opacity-50": e.disabled,
65
75
  [`cursor-pointer ${e.hoverBg}`]: !e.disabled,
66
- [e.activeClass]: n.value || u.value,
76
+ [e.activeClass]: r.value || o.value,
67
77
  "px-4 py-2": !e.noGutters
68
78
  }
69
79
  ]],
70
- onClick: d
80
+ onClick: f
71
81
  }, l.$attrs), [
72
- y(l.$slots, "default")
73
- ], 16, k));
82
+ h(l.$slots, "default")
83
+ ], 16, B));
74
84
  }
75
85
  };
76
86
  export {
77
- h as default
87
+ p as default
78
88
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.91",
3
+ "version": "0.1.92",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",