adverich-kun-ui 0.1.618 → 0.1.620

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/AGENTS.md CHANGED
@@ -145,6 +145,7 @@ Selector con autocompletado y búsqueda.
145
145
  | itemSubtitle | String/Array | null | Campo(s) para subtítulo |
146
146
  | returnObject | Boolean | false | Retorna objeto completo |
147
147
  | multiple | Boolean | false | Selección múltiple |
148
+ | disabled | Boolean | false | Deshabilita el campo y sus acciones |
148
149
  | clearable | Boolean | false | Botón de limpiar |
149
150
  | searchableKeys | Array | [] | Campos para búsqueda |
150
151
  | hasCreateItem | Boolean | false | Muestra botón de crear |
package/dist/AGENTS.md CHANGED
@@ -145,6 +145,7 @@ Selector con autocompletado y búsqueda.
145
145
  | itemSubtitle | String/Array | null | Campo(s) para subtítulo |
146
146
  | returnObject | Boolean | false | Retorna objeto completo |
147
147
  | multiple | Boolean | false | Selección múltiple |
148
+ | disabled | Boolean | false | Deshabilita el campo y sus acciones |
148
149
  | clearable | Boolean | false | Botón de limpiar |
149
150
  | searchableKeys | Array | [] | Campos para búsqueda |
150
151
  | hasCreateItem | Boolean | false | Muestra botón de crear |
@@ -1,246 +1,250 @@
1
- import { useModel as z, onMounted as se, ref as A, watch as ue, nextTick as E, openBlock as c, createElementBlock as h, createVNode as s, unref as t, withKeys as de, withModifiers as F, isRef as x, createSlots as ce, withCtx as r, normalizeClass as fe, createTextVNode as g, toDisplayString as D, createCommentVNode as C, createBlock as p, Fragment as me, renderList as pe, createElementVNode as ve, mergeModels as O } from "vue";
1
+ import { useModel as E, onMounted as ue, ref as F, watch as O, nextTick as R, openBlock as c, createElementBlock as y, createVNode as s, unref as t, withKeys as de, withModifiers as V, isRef as x, createSlots as ce, withCtx as a, normalizeClass as fe, createTextVNode as h, toDisplayString as D, createCommentVNode as g, createBlock as p, Fragment as me, renderList as pe, createElementVNode as ve, mergeModels as B } from "vue";
2
2
  import { icons as v } from "../../../../icons/index.js";
3
- import { isNotEmpty as R, isArray as B } from "../../../../utils/utils.js";
4
- import ke from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
5
- import ye from "../../../KunList/src/components/KunList.vue.js";
6
- import N from "../../../KunListItem/src/components/KunListItem.vue.js";
7
- import T from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
8
- import he from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
9
- import ge from "../../../KunMenu/src/components/KunMenu.vue.js";
10
- import { useAutocomplete as Ce } from "../composables/useAutocomplete.js";
11
- import { KunAutocompleteProps as be } from "../composables/KunAutocompleteProps.js";
3
+ import { isNotEmpty as N, isArray as T } from "../../../../utils/utils.js";
4
+ import be from "../../../KunInfiniteScroll/src/components/KunInfiniteScroll.vue.js";
5
+ import ke from "../../../KunList/src/components/KunList.vue.js";
6
+ import U from "../../../KunListItem/src/components/KunListItem.vue.js";
7
+ import j from "../../../KunListItemTitle/src/components/KunListItemTitle.vue.js";
8
+ import ye from "../../../KunListItemSubtitle/src/components/KunListItemSubtitle.vue.js";
9
+ import he from "../../../KunMenu/src/components/KunMenu.vue.js";
10
+ import { useAutocomplete as ge } from "../composables/useAutocomplete.js";
11
+ import { KunAutocompleteProps as Ce } from "../composables/KunAutocompleteProps.js";
12
12
  import we from "../../../KunTextField/src/components/KunTextField.vue.js";
13
13
  import Se from "../../../KunBtn/src/components/KunBtn.vue.js";
14
14
  import Ve from "../../../KunChip/src/components/KunChip.vue.js";
15
- import b from "../../../KunIcon/src/components/KunIcon.vue.js";
15
+ import C from "../../../KunIcon/src/components/KunIcon.vue.js";
16
16
  const De = { class: "flex items-center" }, Ie = {
17
17
  key: 0,
18
18
  class: "sticky top-0 z-10 p-2 border-b bg-select-background"
19
19
  }, je = {
20
20
  __name: "KunAutocomplete",
21
- props: /* @__PURE__ */ O(be, {
21
+ props: /* @__PURE__ */ B(Ce, {
22
22
  modelValue: { default: null },
23
23
  modelModifiers: {},
24
24
  items: { default: [], type: Array, required: !0 },
25
25
  itemsModifiers: {}
26
26
  }),
27
- emits: /* @__PURE__ */ O(["update:modelValue", "selectedItem", "createItem", "validation", "search", "keyDown", "keyDownEnter", "notFound", "cleared"], ["update:modelValue", "update:items"]),
28
- setup(w, { expose: U, emit: j }) {
29
- const u = z(w, "modelValue"), m = z(w, "items"), a = w, f = j, {
30
- textFieldRef: k,
27
+ emits: /* @__PURE__ */ B(["update:modelValue", "selectedItem", "createItem", "validation", "search", "keyDown", "keyDownEnter", "notFound", "cleared"], ["update:modelValue", "update:items"]),
28
+ setup(w, { expose: H, emit: q }) {
29
+ const u = E(w, "modelValue"), m = E(w, "items"), n = w, f = q, {
30
+ textFieldRef: b,
31
31
  listRef: I,
32
32
  menuModel: d,
33
- search: n,
34
- removeItem: H,
35
- clearSelection: _,
36
- lightReset: q,
33
+ search: r,
34
+ removeItem: _,
35
+ clearSelection: P,
36
+ lightReset: W,
37
37
  openMenu: S,
38
- closeMenu: P,
39
- toggleMenu: V,
40
- onMenuKeydown: W,
41
- getSelectedItem: K,
42
- textArr: G,
43
- getArrayText: J,
44
- isAlphanumeric: Q,
45
- createItem: X,
46
- checkDisabled: Y,
47
- itemToString: L,
48
- placeholder: Z
49
- } = Ce(a, f, u, m);
50
- se(() => {
51
- a.focusOnRender && k.value.focus();
38
+ closeMenu: K,
39
+ toggleMenu: L,
40
+ onMenuKeydown: G,
41
+ getSelectedItem: M,
42
+ textArr: J,
43
+ getArrayText: Q,
44
+ isAlphanumeric: X,
45
+ createItem: Y,
46
+ checkDisabled: Z,
47
+ itemToString: $,
48
+ placeholder: ee
49
+ } = ge(n, f, u, m);
50
+ ue(() => {
51
+ n.focusOnRender && b.value.focus();
52
52
  });
53
- const M = A(null), y = A(""), $ = (e) => {
54
- for (const o of a.rules) {
53
+ const z = F(null), k = F(""), A = (e) => {
54
+ for (const o of n.rules) {
55
55
  const l = o(e);
56
56
  if (l !== !0)
57
- return y.value = l, f("validation", !1), !1;
57
+ return k.value = l, f("validation", !1), !1;
58
58
  }
59
- return y.value = "", f("validation", !0), !0;
59
+ return k.value = "", f("validation", !0), !0;
60
60
  };
61
- ue(() => u.value, (e, o) => {
62
- R(a.rules) && $(e);
61
+ O(() => u.value, (e, o) => {
62
+ N(n.rules) && A(e);
63
+ }), O(() => n.disabled, (e) => {
64
+ e && K();
63
65
  });
64
- function ee() {
66
+ function le() {
65
67
  var e;
66
- d.value = !1, (e = k.value.inputField) == null || e.focus();
68
+ d.value = !1, (e = b.value.inputField) == null || e.focus();
67
69
  }
68
- function le(e) {
70
+ function te(e) {
69
71
  var l, i;
72
+ if (n.disabled) return;
70
73
  const o = e.key;
71
74
  if (o === "Tab" || o === "Shift" || o === "Escape") {
72
- P(), f("keyDown", o);
75
+ K(), f("keyDown", o);
73
76
  return;
74
77
  }
75
- (Q(o) || o === "Backspace") && S(), ["ArrowUp", "ArrowDown"].includes(o) && (e.preventDefault(), d.value || S(), (i = (l = I.value) == null ? void 0 : l.focusWithKey) == null || i.call(l, o));
78
+ (X(o) || o === "Backspace") && S(), ["ArrowUp", "ArrowDown"].includes(o) && (e.preventDefault(), d.value || S(), (i = (l = I.value) == null ? void 0 : l.focusWithKey) == null || i.call(l, o));
76
79
  }
77
- function te(e) {
78
- f("search", n);
80
+ function oe(e) {
81
+ f("search", r);
79
82
  }
80
- function oe() {
81
- $(u);
83
+ function ne() {
84
+ n.disabled || A(u);
82
85
  }
83
- function ne(e) {
84
- W(e);
86
+ function re(e) {
87
+ G(e);
85
88
  }
86
- function re() {
89
+ function ae() {
87
90
  }
88
- function ae(e) {
89
- if (!n.value) return;
91
+ function ie(e) {
92
+ if (n.disabled || !r.value) return;
90
93
  let o = null;
91
- a.returnObject ? o = m.value.find(
94
+ n.returnObject ? o = m.value.find(
92
95
  (l) => Object.values(l).some(
93
- (i) => String(i).toLowerCase() === String(n.value).toLowerCase()
96
+ (i) => String(i).toLowerCase() === String(r.value).toLowerCase()
94
97
  )
95
- ) : a.itemValue ? o = m.value.find(
96
- (l) => String(l[a.itemValue]).toLowerCase() === String(n.value).toLowerCase()
98
+ ) : n.itemValue ? o = m.value.find(
99
+ (l) => String(l[n.itemValue]).toLowerCase() === String(r.value).toLowerCase()
97
100
  ) : o = m.value.find(
98
- (l) => typeof l == "object" ? Object.values(l).some((i) => String(i).toLowerCase() === String(n.value).toLowerCase()) : String(l).toLowerCase() === String(n.value).toLowerCase()
99
- ), o ? K(o) : (f("notFound", n.value), a.clearOnNotFound && (n.value = "", d.value = !1)), E(() => {
101
+ (l) => typeof l == "object" ? Object.values(l).some((i) => String(i).toLowerCase() === String(r.value).toLowerCase()) : String(l).toLowerCase() === String(r.value).toLowerCase()
102
+ ), o ? M(o) : (f("notFound", r.value), n.clearOnNotFound && (r.value = "", d.value = !1)), R(() => {
100
103
  f("keyDownEnter", e);
101
104
  });
102
105
  }
103
- return U({
104
- focus: () => E(() => {
106
+ return H({
107
+ focus: () => !n.disabled && R(() => {
105
108
  var e;
106
- return (e = k.value) == null ? void 0 : e.focus();
109
+ return (e = b.value) == null ? void 0 : e.focus();
107
110
  })
108
- }), (e, o) => (c(), h("div", {
111
+ }), (e, o) => (c(), y("div", {
109
112
  class: "w-full h-fit",
110
113
  ref_key: "parentRef",
111
- ref: M
114
+ ref: z
112
115
  }, [
113
116
  s(we, {
114
- modelValue: t(n),
117
+ modelValue: t(r),
115
118
  "onUpdate:modelValue": [
116
- o[2] || (o[2] = (l) => x(n) ? n.value = l : null),
117
- te
119
+ o[2] || (o[2] = (l) => x(r) ? r.value = l : null),
120
+ oe
118
121
  ],
119
122
  label: e.label,
123
+ disabled: e.disabled,
120
124
  dirty: "",
121
125
  "hide-details": e.hideDetails,
122
126
  density: e.density,
123
127
  ref_key: "textFieldRef",
124
- ref: k,
128
+ ref: b,
125
129
  autocomplete: "off",
126
- onFocusInput: oe,
127
- onHandleClick: t(V),
130
+ onFocusInput: ne,
131
+ onHandleClick: t(L),
128
132
  rounded: t(d) ? "rounded-t" : "rounded",
129
- onBlur: re,
133
+ onBlur: ae,
130
134
  onKeyDown: [
131
- le,
132
- de(F(ae, ["prevent"]), ["enter"])
135
+ te,
136
+ de(V(ie, ["prevent"]), ["enter"])
133
137
  ],
134
- placeholder: a.multiple && t(B)(u.value) && u.value.length ? "" : t(Z),
135
- error: !!y.value,
136
- "error-messages": y.value
138
+ placeholder: n.multiple && t(T)(u.value) && u.value.length ? "" : t(ee),
139
+ error: !!k.value,
140
+ "error-messages": k.value
137
141
  }, ce({
138
- "prepend-input-content": r(() => [
139
- t(B)(u.value) && t(R)(u.value) ? (c(), h("div", {
142
+ "prepend-input-content": a(() => [
143
+ t(T)(u.value) && t(N)(u.value) ? (c(), y("div", {
140
144
  key: 0,
141
145
  class: "flex flex-nowrap items-center space-x-1 min-w-[calc(100%-56px)] overflow-x-auto overflow-y-hidden",
142
- onClick: o[0] || (o[0] = (...l) => t(V) && t(V)(...l))
146
+ onClick: o[0] || (o[0] = (l) => !e.disabled && t(L)())
143
147
  }, [
144
- (c(!0), h(me, null, pe(u.value, (l) => (c(), p(Ve, {
148
+ (c(!0), y(me, null, pe(u.value, (l) => (c(), p(Ve, {
145
149
  key: l.id ?? l.name,
146
150
  size: "small",
147
151
  variant: "pill"
148
152
  }, {
149
- default: r(() => [
153
+ default: a(() => [
150
154
  ve("div", De, [
151
- g(D(t(J)(l)) + " ", 1),
152
- s(b, {
155
+ h(D(t(Q)(l)) + " ", 1),
156
+ s(C, {
153
157
  color: "error",
154
158
  icon: t(v).close,
155
159
  size: "small",
156
160
  class: "ml-1",
157
- onClick: (i) => t(H)(l)
161
+ onClick: V((i) => t(_)(l), ["stop"])
158
162
  }, null, 8, ["icon", "onClick"])
159
163
  ])
160
164
  ]),
161
165
  _: 2
162
166
  }, 1024))), 128))
163
- ])) : C("", !0)
167
+ ])) : g("", !0)
164
168
  ]),
165
- default: r(() => [
166
- s(ge, {
169
+ default: a(() => [
170
+ s(he, {
167
171
  transition: "fade",
168
- "onClick:outside": t(q),
172
+ "onClick:outside": t(W),
169
173
  modelValue: t(d),
170
174
  "onUpdate:modelValue": o[1] || (o[1] = (l) => x(d) ? d.value = l : null),
171
175
  activator: "parent",
172
176
  "z-index": e.zIndex,
173
- "parent-ref": M.value,
177
+ "parent-ref": z.value,
174
178
  origin: e.menuOrigin,
175
- onHandleEscape: ee,
179
+ onHandleEscape: le,
176
180
  bgColor: e.bgMenuColor,
177
181
  "close-on-content-click": e.closeOnSelect,
178
182
  width: "w-full",
179
183
  "max-height": e.maxHeight,
180
184
  "hide-details": e.hideDetails
181
185
  }, {
182
- default: r(() => [
183
- e.hasCreateItem ? (c(), h("div", Ie, [
186
+ default: a(() => [
187
+ e.hasCreateItem ? (c(), y("div", Ie, [
184
188
  s(Se, {
185
- onClick: t(X),
189
+ onClick: t(Y),
186
190
  bgColor: e.btnCreateBg,
187
191
  class: fe(e.btnCreateClass)
188
192
  }, {
189
- default: r(() => [
190
- g(D(e.btnCreateText), 1)
193
+ default: a(() => [
194
+ h(D(e.btnCreateText), 1)
191
195
  ]),
192
196
  _: 1
193
197
  }, 8, ["onClick", "bgColor", "class"])
194
- ])) : C("", !0),
195
- s(ye, {
196
- "onClick:select": t(K),
198
+ ])) : g("", !0),
199
+ s(ke, {
200
+ "onClick:select": t(M),
197
201
  ref_key: "listRef",
198
202
  ref: I,
199
- onKeyDown: ne,
203
+ onKeyDown: re,
200
204
  selectable: !0
201
205
  }, {
202
- default: r(() => [
203
- s(ke, {
206
+ default: a(() => [
207
+ s(be, {
204
208
  items: m.value,
205
- search: t(n),
206
- "searchable-keys": a.searchableKeys,
209
+ search: t(r),
210
+ "searchable-keys": n.searchableKeys,
207
211
  virtual: !1,
208
212
  "items-per-intersection": 10,
209
213
  enabled: t(d),
210
214
  "item-height": 48
211
215
  }, {
212
- default: r(({ item: l, index: i, empty: ie }) => [
213
- !ie && l != null ? (c(), p(N, {
216
+ default: a(({ item: l, index: i, empty: se }) => [
217
+ !se && l != null ? (c(), p(U, {
214
218
  value: l,
215
219
  key: `kun-list-${i + 1}`,
216
220
  id: `kun-item-${i + 1}`,
217
- disabled: t(Y)(l),
221
+ disabled: t(Z)(l),
218
222
  "bg-items": e.bgItemListColor,
219
223
  "hover-bg": e.hoverItemListColor,
220
224
  activeClass: e.selectedItemListColor,
221
225
  density: e.density,
222
226
  selectable: !0
223
227
  }, {
224
- default: r(() => [
225
- s(T, { class: "text-wrap" }, {
226
- default: r(() => [
227
- g(D(t(L)(l, e.itemTitle ?? t(G), "hasDefault")), 1)
228
+ default: a(() => [
229
+ s(j, { class: "text-wrap" }, {
230
+ default: a(() => [
231
+ h(D(t($)(l, e.itemTitle ?? t(J), "hasDefault")), 1)
228
232
  ]),
229
233
  _: 2
230
234
  }, 1024),
231
- s(he, {
232
- text: e.itemSubtitle ? t(L)(l, e.itemSubtitle) : ""
235
+ s(ye, {
236
+ text: e.itemSubtitle ? t($)(l, e.itemSubtitle) : ""
233
237
  }, null, 8, ["text"])
234
238
  ]),
235
239
  _: 2
236
- }, 1032, ["value", "id", "disabled", "bg-items", "hover-bg", "activeClass", "density"])) : (c(), p(N, {
240
+ }, 1032, ["value", "id", "disabled", "bg-items", "hover-bg", "activeClass", "density"])) : (c(), p(U, {
237
241
  key: 1,
238
242
  disabled: ""
239
243
  }, {
240
- default: r(() => [
241
- s(T, { class: "text-center w-full text-gray-500" }, {
242
- default: r(() => [...o[3] || (o[3] = [
243
- g(" No hay elementos disponibles ", -1)
244
+ default: a(() => [
245
+ s(j, { class: "text-center w-full text-gray-500" }, {
246
+ default: a(() => [...o[3] || (o[3] = [
247
+ h(" No hay elementos disponibles ", -1)
244
248
  ])]),
245
249
  _: 1
246
250
  })
@@ -261,33 +265,33 @@ const De = { class: "flex items-center" }, Ie = {
261
265
  }, [
262
266
  e.hasIcons ? {
263
267
  name: "append-inner",
264
- fn: r(() => [
265
- e.clearable && u.value ? (c(), p(b, {
268
+ fn: a(() => [
269
+ e.clearable && u.value ? (c(), p(C, {
266
270
  key: 0,
267
- onClick: t(_),
271
+ onClick: t(P),
268
272
  size: "small",
269
273
  color: "error",
270
274
  icon: t(v).close,
271
275
  class: "mr-1 mt-1"
272
- }, null, 8, ["onClick", "icon"])) : C("", !0),
273
- s(b, {
276
+ }, null, 8, ["onClick", "icon"])) : g("", !0),
277
+ s(C, {
274
278
  color: "teal-darken-1",
275
279
  size: "large",
276
280
  class: "cursor-pointer",
277
281
  icon: t(d) ? t(v).menuUpOutline : t(v).menuDownOutline,
278
- onClick: F(t(S), ["stop"])
282
+ onClick: V(t(S), ["stop"])
279
283
  }, null, 8, ["icon", "onClick"]),
280
- e.required ? (c(), p(b, {
284
+ e.required ? (c(), p(C, {
281
285
  key: 1,
282
286
  color: "teal-darken-1",
283
287
  size: "x-small",
284
288
  class: "mb-4",
285
289
  icon: t(v).asterisk
286
- }, null, 8, ["icon"])) : C("", !0)
290
+ }, null, 8, ["icon"])) : g("", !0)
287
291
  ]),
288
292
  key: "0"
289
293
  } : void 0
290
- ]), 1032, ["modelValue", "label", "hide-details", "density", "onHandleClick", "rounded", "onKeyDown", "placeholder", "error", "error-messages"])
294
+ ]), 1032, ["modelValue", "label", "disabled", "hide-details", "density", "onHandleClick", "rounded", "onKeyDown", "placeholder", "error", "error-messages"])
291
295
  ], 512));
292
296
  }
293
297
  };
@@ -61,6 +61,10 @@ const e = {
61
61
  type: Boolean,
62
62
  default: !1
63
63
  },
64
+ disabled: {
65
+ type: Boolean,
66
+ default: !1
67
+ },
64
68
  // ***** STYLE ***** //
65
69
  height: { default: "h-[500px]" },
66
70
  maxHeight: { default: void 0 },
@@ -1,24 +1,24 @@
1
- import { ref as d, computed as F, watch as P, nextTick as N } from "vue";
1
+ import { ref as d, computed as N, watch as P, nextTick as R } from "vue";
2
2
  import { isArray as S, isObject as v, fullCopy as T } from "../../../../utils/utils.js";
3
- function W(t, y, c, g) {
4
- const l = d(null), h = d(null), I = d(null), f = d(!1), b = d(""), R = (e, n) => {
5
- if (t.returnObject) return s(e, t.itemTitle);
6
- const u = l.value.find((i) => i[t.itemValue] === e);
7
- return s(u, t.itemTitle);
8
- }, B = F(() => l.value !== null && l.value !== void 0 ? S(l.value) ? l.value.length ? s(l.value, t.itemTitle, "hasDefault") : t.placeholderText : v(l.value) ? s(l.value, t.itemTitle, "hasDefault") : l.value.toString() : g.value.length ? t.placeholderText : t.textNoItems), C = F(() => {
3
+ function W(t, b, i, y) {
4
+ const l = d(null), g = d(null), I = d(null), f = d(!1), h = d(""), B = (e, n) => {
5
+ if (t.returnObject) return o(e, t.itemTitle);
6
+ const u = l.value.find((c) => c[t.itemValue] === e);
7
+ return o(u, t.itemTitle);
8
+ }, C = N(() => l.value !== null && l.value !== void 0 ? S(l.value) ? l.value.length ? o(l.value, t.itemTitle, "hasDefault") : t.placeholderText : v(l.value) ? o(l.value, t.itemTitle, "hasDefault") : l.value.toString() : y.value.length ? t.placeholderText : t.textNoItems), D = N(() => {
9
9
  const e = t.itemText;
10
10
  return typeof e == "string" && e.includes(",") ? e.split(",") : e;
11
11
  });
12
- function s(e, n, u) {
13
- var i;
12
+ function o(e, n, u) {
13
+ var c;
14
14
  if (v(e)) {
15
15
  if (n) {
16
16
  if (S(n))
17
17
  return n.map((r) => {
18
18
  if (r.includes(".")) {
19
- const o = r.split(".");
19
+ const s = r.split(".");
20
20
  let a = e;
21
- for (const j of o)
21
+ for (const j of s)
22
22
  a = a != null ? a[j] : "";
23
23
  return a ?? "No definido";
24
24
  }
@@ -28,56 +28,57 @@ function W(t, y, c, g) {
28
28
  return n.split(",").map((r) => e[r]).join(" - ");
29
29
  if (n.includes(".")) {
30
30
  const r = n.split(".");
31
- let o = e;
31
+ let s = e;
32
32
  for (const a of r)
33
- o = o != null ? o[a] : "";
34
- return o;
33
+ s = s != null ? s[a] : "";
34
+ return s;
35
35
  }
36
36
  return !t.returnObject && typeof e[n] == "number" || e[n] !== void 0 && e[n] !== null ? e[n].toString() : "";
37
37
  }
38
38
  if (u)
39
39
  return Object.values(e)[0];
40
40
  }
41
- return S(e) ? t.returnObject ? e.map((r) => r[n]).join(" - ") : e.map((r) => r).join(" - ") : u && typeof e != "number" ? e.includes(",") ? e.split(",") : e : ((i = e == null ? void 0 : e.toString) == null ? void 0 : i.call(e)) ?? "";
42
- }
43
- function D(e) {
44
- try {
45
- let n = null;
46
- if (l.value = T(e), !t.multiple)
47
- t.returnObject ? n = T(e) : v(e) ? t.itemValue ? n = e[t.itemValue] : n = Object.values(e)[0] : n = e, f.value = !1, x();
48
- else if (k(e)) {
49
- e && A(e);
50
- return;
51
- } else {
52
- const u = t.returnObject ? T(e) : v(e) ? t.itemValue ? e[t.itemValue] : Object.values(e)[0] : e;
53
- n = [...c.value || [], u];
41
+ return S(e) ? t.returnObject ? e.map((r) => r[n]).join(" - ") : e.map((r) => r).join(" - ") : u && typeof e != "number" ? e.includes(",") ? e.split(",") : e : ((c = e == null ? void 0 : e.toString) == null ? void 0 : c.call(e)) ?? "";
42
+ }
43
+ function J(e) {
44
+ if (!(t.disabled || F(e)))
45
+ try {
46
+ let n = null;
47
+ if (l.value = T(e), !t.multiple)
48
+ t.returnObject ? n = T(e) : v(e) ? t.itemValue ? n = e[t.itemValue] : n = Object.values(e)[0] : n = e, f.value = !1, x();
49
+ else if (k(e)) {
50
+ e && A(e);
51
+ return;
52
+ } else {
53
+ const u = t.returnObject ? T(e) : v(e) ? t.itemValue ? e[t.itemValue] : Object.values(e)[0] : e;
54
+ n = [...i.value || [], u];
55
+ }
56
+ i.value === n ? b("update:modelValue", n) : i.value = n, b("selectedItem", l.value);
57
+ } catch (n) {
58
+ console.log(n);
59
+ } finally {
60
+ R(() => {
61
+ K();
62
+ });
54
63
  }
55
- c.value === n ? y("update:modelValue", n) : c.value = n, y("selectedItem", l.value);
56
- } catch (n) {
57
- console.log(n);
58
- } finally {
59
- N(() => {
60
- K();
61
- });
62
- }
63
64
  }
64
65
  P(
65
- [() => c.value, () => g.value],
66
+ [() => i.value, () => y.value],
66
67
  ([e]) => {
67
- const n = J(e);
68
+ const n = V(e);
68
69
  JSON.stringify(l.value) !== JSON.stringify(n) && (l.value = n);
69
70
  },
70
71
  { immediate: !0 }
71
72
  );
72
- function J(e) {
73
- return e == null ? null : t.multiple && Array.isArray(e) ? t.returnObject ? e : e.map((u) => g.value.find((i) => i[t.itemValue] === u)).filter(Boolean) : t.returnObject ? e : g.value.find(
73
+ function V(e) {
74
+ return e == null ? null : t.multiple && Array.isArray(e) ? t.returnObject ? e : e.map((u) => y.value.find((c) => c[t.itemValue] === u)).filter(Boolean) : t.returnObject ? e : y.value.find(
74
75
  (u) => typeof u == "object" ? u[t.itemValue] === e : u === e
75
76
  ) ?? e;
76
77
  }
77
78
  function k(e) {
78
- if (!c.value || !e) return !1;
79
+ if (!i.value || !e) return !1;
79
80
  const n = O(e);
80
- return c.value.some((u) => O(u) === n);
81
+ return i.value.some((u) => O(u) === n);
81
82
  }
82
83
  function O(e) {
83
84
  if (!v(e))
@@ -90,78 +91,80 @@ function W(t, y, c, g) {
90
91
  return n.length > 0 ? n[0] : e;
91
92
  }
92
93
  function A(e) {
93
- if (!c.value) return;
94
+ if (!i.value) return;
94
95
  const n = O(e);
95
- c.value = c.value.filter((u) => O(u) !== n);
96
+ i.value = i.value.filter((u) => O(u) !== n);
96
97
  }
97
98
  function K(e) {
98
- t.clearSearchOnSelect && (b.value = ""), t.clearOnSelect && M(), t.focusOnSelect && x();
99
+ t.clearSearchOnSelect && (h.value = ""), t.clearOnSelect && M(), t.focusOnSelect && x();
99
100
  }
100
101
  function w() {
101
- f.value || (f.value = !0);
102
+ t.disabled || f.value || (f.value = !0);
102
103
  }
103
- function V() {
104
+ function $() {
104
105
  f.value && (f.value = !1);
105
106
  }
106
- function $() {
107
- f.value = !f.value;
107
+ function q() {
108
+ t.disabled || (f.value = !f.value);
108
109
  }
109
110
  function E(e) {
110
111
  return e.length === 1 && e.match(/\w/);
111
112
  }
112
113
  function x() {
113
- h.value.inputField.focus();
114
+ g.value.inputField.focus();
114
115
  }
115
- function q() {
116
- f.value = !0, I.value && h.value.$el.focus();
116
+ function z() {
117
+ f.value = !0, I.value && g.value.$el.focus();
117
118
  }
118
- function z(e) {
119
+ function G(e) {
120
+ if (t.disabled) return;
119
121
  const n = e.key;
120
- (E(n) || n === "Backspace") && (w(), x(), N(() => {
121
- var i;
122
- const u = (i = h.value) == null ? void 0 : i.inputField;
122
+ (E(n) || n === "Backspace") && (w(), x(), R(() => {
123
+ var c;
124
+ const u = (c = g.value) == null ? void 0 : c.inputField;
123
125
  if (u) {
124
- const r = u.selectionStart, o = u.selectionEnd, a = u.value, j = e.key.length === 1 ? e.key : "";
125
- u.value = a.slice(0, r) + j + a.slice(o), u.selectionStart = u.selectionEnd = r + j.length, u.dispatchEvent(new Event("input", { bubbles: !0 }));
126
+ const r = u.selectionStart, s = u.selectionEnd, a = u.value, j = e.key.length === 1 ? e.key : "";
127
+ u.value = a.slice(0, r) + j + a.slice(s), u.selectionStart = u.selectionEnd = r + j.length, u.dispatchEvent(new Event("input", { bubbles: !0 }));
126
128
  }
127
129
  }));
128
130
  }
129
- function G() {
130
- f.value = !1, y("createItem");
131
+ function H() {
132
+ t.disabled || (f.value = !1, b("createItem"));
131
133
  }
132
- function H(e) {
133
- let n = c.value.indexOf(e);
134
- c.value.splice(n, 1);
134
+ function L(e) {
135
+ if (t.disabled) return;
136
+ let n = i.value.indexOf(e);
137
+ i.value.splice(n, 1);
135
138
  }
136
139
  function M() {
137
- b.value !== "" && (b.value = ""), c.value !== null && (c.value = null), l.value !== null && (l.value = null), y("cleared");
140
+ t.disabled || (h.value !== "" && (h.value = ""), i.value !== null && (i.value = null), l.value !== null && (l.value = null), b("cleared"));
138
141
  }
139
- function L(e) {
142
+ function F(e) {
140
143
  return !!e.disabled;
141
144
  }
142
145
  return {
143
146
  selectedItem: l,
144
- textFieldRef: h,
147
+ textFieldRef: g,
145
148
  listRef: I,
146
149
  menuModel: f,
147
- search: b,
148
- getArrayText: R,
149
- placeholder: B,
150
- textArr: C,
151
- itemToString: s,
152
- getSelectedItem: D,
150
+ search: h,
151
+ getArrayText: B,
152
+ placeholder: C,
153
+ textArr: D,
154
+ itemToString: o,
155
+ getSelectedItem: J,
153
156
  checkIfValueExist: k,
154
157
  removeFromArray: A,
155
158
  lightReset: K,
156
159
  openMenu: w,
157
- closeMenu: V,
158
- toggleMenu: $,
159
- focusOnMenu: q,
160
- onMenuKeydown: z,
161
- createItem: G,
162
- removeItem: H,
160
+ closeMenu: $,
161
+ toggleMenu: q,
162
+ focusOnMenu: z,
163
+ onMenuKeydown: G,
164
+ createItem: H,
165
+ removeItem: L,
163
166
  clearSelection: M,
164
- checkDisabled: L,
167
+ checkDisabled: F,
165
168
  isAlphanumeric: E
166
169
  };
167
170
  }
@@ -1,85 +1,78 @@
1
- import { ref as m, computed as T, onMounted as N, onBeforeUnmount as P, openBlock as $, createElementBlock as _, Fragment as D, createElementVNode as E, mergeProps as F, renderSlot as S, createBlock as I, Teleport as K, createVNode as U, Transition as X, withCtx as Y, withDirectives as j, normalizeStyle as q, normalizeClass as A, createTextVNode as G, toDisplayString as H, vShow as J, createCommentVNode as Q, nextTick as W } from "vue";
2
- import { kunTooltipProps as Z } from "../composables/kunTooltipProps.js";
3
- const ee = "absolute px-3 py-2 shadow", ne = {
1
+ import { ref as c, computed as m, onBeforeUnmount as x, openBlock as d, createElementBlock as V, Fragment as B, createElementVNode as T, mergeProps as M, renderSlot as v, createBlock as P, Teleport as z, createVNode as N, Transition as R, withCtx as _, withDirectives as D, normalizeStyle as E, unref as O, normalizeClass as F, createTextVNode as $, toDisplayString as I, vShow as K, createCommentVNode as L, nextTick as U } from "vue";
2
+ import { kunTooltipProps as j } from "../composables/kunTooltipProps.js";
3
+ import { useTooltipPosition as q } from "../composables/useTooltipPosition.js";
4
+ const A = "fixed px-3 py-2 shadow", W = {
4
5
  __name: "KunTooltip",
5
- props: Z,
6
- setup(z) {
7
- const t = z, B = "tooltip-" + Math.random().toString(36).slice(2, 11), o = m(!1), v = m(null), w = m(null), g = m({});
8
- let a = null, l = null, i = null, r = !1;
9
- function h() {
10
- t.disabled || o.value || r || (clearTimeout(a), clearTimeout(l), clearTimeout(i), r = !0, a = setTimeout(async () => {
11
- r = !1, v.value && (o.value = !0, await W(), x(), i = setTimeout(() => {
12
- s();
6
+ props: j,
7
+ setup(y) {
8
+ const e = y, h = "tooltip-" + Math.random().toString(36).slice(2, 11), t = c(!1), s = c(null), f = c(null), { tooltipStyle: k, updatePosition: g } = q(
9
+ s,
10
+ f,
11
+ t,
12
+ () => ({
13
+ location: e.location,
14
+ flip: e.flip,
15
+ dist: e.dist
16
+ })
17
+ );
18
+ let a = null, l = null, i = null, n = !1;
19
+ function u() {
20
+ e.disabled || t.value || n || (clearTimeout(a), clearTimeout(l), clearTimeout(i), n = !0, a = setTimeout(async () => {
21
+ n = !1, s.value && (t.value = !0, await U(), g(), i = setTimeout(() => {
22
+ r();
13
23
  }, 5e3));
14
- }, +t.delay));
24
+ }, +e.delay));
15
25
  }
16
- function s() {
17
- clearTimeout(a), clearTimeout(l), clearTimeout(i), !(!o.value && !r) && (l = setTimeout(() => {
18
- o.value = !1, r = !1;
19
- }, +t.closeDelay));
26
+ function r() {
27
+ clearTimeout(a), clearTimeout(l), clearTimeout(i), !(!t.value && !n) && (l = setTimeout(() => {
28
+ t.value = !1, n = !1;
29
+ }, +e.closeDelay));
20
30
  }
21
- function L() {
22
- o.value ? s() : h();
31
+ function b() {
32
+ t.value ? r() : u();
23
33
  }
24
- function R() {
34
+ function C() {
25
35
  clearTimeout(l), clearTimeout(i);
26
36
  }
27
- function M() {
28
- s();
37
+ function S() {
38
+ r();
29
39
  }
30
- const y = T(() => {
31
- if (t.disabled) return {};
32
- const e = {};
33
- return t.openOn === "hover" && (e.onMouseenter = h, e.onMouseleave = s), t.openOn === "click" && (e.onClick = L), t.openOn === "focus" && (e.onFocus = h, e.onBlur = s), e;
34
- }), O = T(() => [ee, t.textColor, t.bgColor, t.textSize, t.rounded, t.class]), V = T(() => typeof t.dist == "number" ? { x: 0, y: t.dist } : { x: t.dist.x ?? 0, y: t.dist.y ?? 0 });
35
- function x() {
36
- var k, C;
37
- const e = (k = v.value) == null ? void 0 : k.getBoundingClientRect(), n = (C = w.value) == null ? void 0 : C.getBoundingClientRect();
38
- if (!e || !n) return;
39
- const c = window.pageYOffset || document.documentElement.scrollTop, p = window.pageXOffset || document.documentElement.scrollLeft, { x: d, y: f } = V.value, b = {
40
- top: { top: `${e.top + c - n.height - f}px`, left: `${e.left + p + e.width / 2 - n.width / 2 + d}px` },
41
- bottom: { top: `${e.bottom + c + f}px`, left: `${e.left + p + e.width / 2 - n.width / 2 + d}px` },
42
- left: { top: `${e.top + c + e.height / 2 - n.height / 2 + f}px`, left: `${e.left + p - n.width - d}px` },
43
- right: { top: `${e.top + c + e.height / 2 - n.height / 2 + f}px`, left: `${e.right + p + d}px` }
44
- };
45
- g.value = b[t.location] || b.top;
46
- }
47
- const u = () => {
48
- o.value && x();
49
- };
50
- return N(() => {
51
- window.addEventListener("scroll", u), window.addEventListener("resize", u);
52
- }), P(() => {
53
- clearTimeout(a), clearTimeout(l), clearTimeout(i), o.value = !1, window.removeEventListener("scroll", u), window.removeEventListener("resize", u);
54
- }), (e, n) => ($(), _(D, null, [
55
- E("span", F({
40
+ const p = m(() => {
41
+ if (e.disabled) return {};
42
+ const o = {};
43
+ return e.openOn === "hover" && (o.onMouseenter = u, o.onMouseleave = r), e.openOn === "click" && (o.onClick = b), e.openOn === "focus" && (o.onFocus = u, o.onBlur = r), o;
44
+ }), w = m(() => [A, e.textColor, e.bgColor, e.textSize, e.rounded, e.class]);
45
+ return x(() => {
46
+ clearTimeout(a), clearTimeout(l), clearTimeout(i), t.value = !1;
47
+ }), (o, G) => (d(), V(B, null, [
48
+ T("span", M({
56
49
  ref_key: "activatorRef",
57
- ref: v
58
- }, y.value), [
59
- S(e.$slots, "activator", { props: y.value })
50
+ ref: s
51
+ }, p.value), [
52
+ v(o.$slots, "activator", { props: p.value })
60
53
  ], 16),
61
- e.disabled ? Q("", !0) : ($(), I(K, {
54
+ o.disabled ? L("", !0) : (d(), P(z, {
62
55
  key: 0,
63
56
  to: "body"
64
57
  }, [
65
- U(X, { name: e.transition }, {
66
- default: Y(() => [
67
- j(E("div", {
68
- id: B,
58
+ N(R, { name: o.transition }, {
59
+ default: _(() => [
60
+ D(T("div", {
61
+ id: h,
69
62
  ref_key: "tooltipRef",
70
- ref: w,
71
- class: A(O.value),
72
- style: q([g.value, { "z-index": "9999" }]),
63
+ ref: f,
64
+ class: F(w.value),
65
+ style: E([O(k), { "z-index": "9999" }]),
73
66
  role: "tooltip",
74
67
  "aria-hidden": "!isVisible",
75
- onMouseenter: R,
76
- onMouseleave: M
68
+ onMouseenter: C,
69
+ onMouseleave: S
77
70
  }, [
78
- S(e.$slots, "default", {}, () => [
79
- G(H(e.text), 1)
71
+ v(o.$slots, "default", {}, () => [
72
+ $(I(o.text), 1)
80
73
  ])
81
74
  ], 38), [
82
- [J, o.value]
75
+ [K, t.value]
83
76
  ])
84
77
  ]),
85
78
  _: 3
@@ -89,5 +82,5 @@ const ee = "absolute px-3 py-2 shadow", ne = {
89
82
  }
90
83
  };
91
84
  export {
92
- ne as default
85
+ W as default
93
86
  };
@@ -11,7 +11,8 @@ const t = {
11
11
  bgColor: { type: String, default: "bg-gray-600/75 dark:bg-gray-700/75" },
12
12
  rounded: { type: String, default: "rounded" },
13
13
  textSize: { type: String, default: "text-sm" },
14
- dist: { type: [Number, Object], default: () => ({ x: 0, y: 8 }) }
14
+ dist: { type: [Number, Object], default: () => ({ x: 0, y: 8 }) },
15
+ flip: { type: Boolean, default: !0 }
15
16
  };
16
17
  export {
17
18
  t as kunTooltipProps
@@ -0,0 +1,102 @@
1
+ import { ref as C, onMounted as T, onBeforeUnmount as z } from "vue";
2
+ const s = 8;
3
+ function H(n) {
4
+ const o = [];
5
+ let t = n == null ? void 0 : n.parentElement;
6
+ for (; t; ) {
7
+ const { overflowY: u, overflowX: i, overflow: e } = window.getComputedStyle(t);
8
+ (["auto", "scroll", "overlay"].includes(u) || ["auto", "scroll", "overlay"].includes(i) || ["auto", "scroll", "overlay"].includes(e)) && o.push(t), t = t.parentElement;
9
+ }
10
+ return o;
11
+ }
12
+ function O(n) {
13
+ return typeof n == "number" ? { x: 0, y: n } : { x: (n == null ? void 0 : n.x) ?? 0, y: (n == null ? void 0 : n.y) ?? 0 };
14
+ }
15
+ function y(n, o, t) {
16
+ return Math.min(Math.max(n, o), t);
17
+ }
18
+ function W(n, o, t, u, i) {
19
+ const { x: e, y: r } = i, g = window.innerWidth, h = window.innerHeight;
20
+ if (!o) return n;
21
+ if (n === "top") {
22
+ const l = t.top - r - s, f = h - t.bottom - r - s;
23
+ if (l < u.height && f > l) return "bottom";
24
+ } else if (n === "bottom") {
25
+ const l = h - t.bottom - r - s, f = t.top - r - s;
26
+ if (l < u.height && f > l) return "top";
27
+ } else if (n === "left") {
28
+ const l = t.left - e - s, f = g - t.right - e - s;
29
+ if (l < u.width && f > l) return "right";
30
+ } else if (n === "right") {
31
+ const l = g - t.right - e - s, f = t.left - e - s;
32
+ if (l < u.width && f > l) return "left";
33
+ }
34
+ return n;
35
+ }
36
+ function $(n, o, t, u) {
37
+ const { x: i, y: e } = u;
38
+ switch (n) {
39
+ case "bottom":
40
+ return {
41
+ top: o.bottom + e,
42
+ left: o.left + o.width / 2 - t.width / 2 + i
43
+ };
44
+ case "left":
45
+ return {
46
+ top: o.top + o.height / 2 - t.height / 2 + e,
47
+ left: o.left - t.width - i
48
+ };
49
+ case "right":
50
+ return {
51
+ top: o.top + o.height / 2 - t.height / 2 + e,
52
+ left: o.right + i
53
+ };
54
+ case "top":
55
+ default:
56
+ return {
57
+ top: o.top - t.height - e,
58
+ left: o.left + o.width / 2 - t.width / 2 + i
59
+ };
60
+ }
61
+ }
62
+ function F(n, o, t, u) {
63
+ const i = C({});
64
+ let e = [], r = null;
65
+ function g() {
66
+ const w = n.value, c = o.value;
67
+ if (!w || !c) return;
68
+ const a = w.getBoundingClientRect(), p = c.getBoundingClientRect(), { location: b, flip: L, dist: E } = u(), x = O(E), v = window.innerWidth, A = window.innerHeight, M = W(b, L, a, p, x);
69
+ let { top: d, left: m } = $(M, a, p, x);
70
+ const S = Math.max(s, v - p.width - s), B = Math.max(s, A - p.height - s);
71
+ m = y(m, s, S), d = y(d, s, B), i.value = {
72
+ position: "fixed",
73
+ top: `${d}px`,
74
+ left: `${m}px`,
75
+ maxWidth: `${v - s * 2}px`
76
+ };
77
+ }
78
+ function h() {
79
+ t.value && (r || (r = requestAnimationFrame(() => {
80
+ r = null, g();
81
+ })));
82
+ }
83
+ function l() {
84
+ f();
85
+ const w = n.value;
86
+ if (!w) return;
87
+ const c = { capture: !0, passive: !0 };
88
+ window.addEventListener("scroll", h, c), e.push({ target: window, event: "scroll", handler: h, options: c }), window.addEventListener("resize", h, c), e.push({ target: window, event: "resize", handler: h, options: c }), H(w).forEach((a) => {
89
+ const p = { passive: !0 };
90
+ a.addEventListener("scroll", h, p), e.push({ target: a, event: "scroll", handler: h, options: p });
91
+ });
92
+ }
93
+ function f() {
94
+ r && (cancelAnimationFrame(r), r = null), e.forEach(({ target: w, event: c, handler: a, options: p }) => {
95
+ w.removeEventListener(c, a, p);
96
+ }), e = [];
97
+ }
98
+ return T(() => l()), z(() => f()), { tooltipStyle: i, updatePosition: g, startScrollTracking: l };
99
+ }
100
+ export {
101
+ F as useTooltipPosition
102
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "adverich-kun-ui",
3
- "version": "0.1.618",
3
+ "version": "0.1.620",
4
4
  "type": "module",
5
5
  "description": "Una librería de componentes Vue.js con Tailwind CSS",
6
6
  "main": "dist/index.js",