adverich-kun-ui 0.1.124 → 0.1.126

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,133 +1,135 @@
1
- import { ref as a, computed as F, watch as m, nextTick as J } from "vue";
2
- import { isArray as g, isObject as o } from "../../../../utils/utils.js";
3
- function W(t, j, u, s, L) {
4
- const r = a(null), v = a(null), y = a(null), c = a(!1), h = a(""), B = (e, n) => n.split(".").reduce((l, i) => l && l[i] !== void 0 ? l[i] : null, e), R = F(() => r.value ? g(r.value) ? r.value.length ? d(r.value, t.itemTitle, "hasDefault") : t.placeholderText : o(r.value) ? d(r.value, t.itemTitle, "hasDefault") : r.value.toString() : s.value.length ? t.placeholderText : t.textNoItems), D = F(() => t.itemText.includes(",") ? t.itemText.split(",") : t.itemText);
5
- function d(e, n, l) {
6
- if (o(e)) {
7
- if (n) {
8
- if (g(n))
9
- return n.map((i) => e[i] ?? "No definido").join(" - ");
10
- if (n.includes(","))
11
- return n.split(",").map((i) => e[i]).join(" - ");
12
- if (n.includes(".")) {
13
- const i = n.split(".");
1
+ import { ref as a, computed as m, nextTick as G } from "vue";
2
+ import { isArray as O, isObject as d } from "../../../../utils/utils.js";
3
+ function L(n, s, c, w) {
4
+ const i = a(null), o = a(null), g = a(null), r = a(!1), v = a(""), A = (e, t) => t.split(".").reduce((u, l) => u && u[l] !== void 0 ? u[l] : null, e), F = m(() => i.value ? O(i.value) ? i.value.length ? h(i.value, n.itemTitle, "hasDefault") : n.placeholderText : d(i.value) ? h(i.value, n.itemTitle, "hasDefault") : i.value.toString() : w.value.length ? n.placeholderText : n.textNoItems), V = m(() => n.itemText.includes(",") ? n.itemText.split(",") : n.itemText);
5
+ function h(e, t, u) {
6
+ if (d(e)) {
7
+ if (t) {
8
+ if (O(t))
9
+ return t.map((l) => e[l] ?? "No definido").join(" - ");
10
+ if (t.includes(","))
11
+ return t.split(",").map((l) => e[l]).join(" - ");
12
+ if (t.includes(".")) {
13
+ const l = t.split(".");
14
14
  let f = e;
15
- for (const O of i)
16
- f = f[O];
15
+ for (const b of l)
16
+ f = f[b];
17
17
  return f;
18
18
  }
19
- return !t.returnObject && typeof e[n] == "number" || e[n] ? e[n].toString() : "";
19
+ return !n.returnObject && typeof e[t] == "number" || e[t] ? e[t].toString() : "";
20
20
  }
21
- if (l)
21
+ if (u)
22
22
  return Object.values(e)[0];
23
23
  }
24
- return g(e) ? t.returnObject ? e.map((i) => i[n]).join(" - ") : e.map((i) => i).join(" - ") : l && typeof e != "number" && e.includes(",") ? e.split(",") : e;
24
+ return O(e) ? n.returnObject ? e.map((l) => l[t]).join(" - ") : e.map((l) => l).join(" - ") : u && typeof e != "number" && e.includes(",") ? e.split(",") : e;
25
25
  }
26
- function N(e) {
26
+ function R(e) {
27
27
  try {
28
- x.value = !1, r.value = e, t.multiple ? (u.value || (u.value = []), S(e) ? e && T(e) : t.returnObject ? u.value.push(e) : o(e) ? t.itemValue ? u.value.push(e[t.itemValue]) : u.value.push(Object.values(e)[0]) : u.value.push(e)) : (t.returnObject ? u.value = e : o(e) ? t.itemValue ? u.value = e[t.itemValue] : u.value = Object.values(e)[0] : u.value = e, c.value = !1), j("selectedItem", r.value), t.clearOnSelect && k(), x.value = !0;
29
- } catch (n) {
30
- console.log(n);
28
+ if (j.value = !1, i.value = e, !n.multiple)
29
+ n.returnObject ? c.value = e : d(e) ? n.itemValue ? c.value = e[n.itemValue] : c.value = Object.values(e)[0] : c.value = e, r.value = !1;
30
+ else if (S(e))
31
+ e && T(e);
32
+ else {
33
+ const t = n.returnObject ? e : d(e) ? n.itemValue ? e[n.itemValue] : Object.values(e)[0] : e, u = [...c.value || [], t];
34
+ s("update:modelValue", u);
35
+ }
36
+ s("selectedItem", i.value), n.clearOnSelect && M(), j.value = !0;
37
+ } catch (t) {
38
+ console.log(t);
31
39
  } finally {
32
- b();
40
+ x();
33
41
  }
34
42
  }
35
- const x = a(!0);
36
- m(() => u.value, (e) => {
37
- x.value && (r.value = I(e));
38
- }, { immediate: !0 }), m(() => s.value, () => {
39
- r.value = I(u.value);
40
- }, { immediate: !0 });
41
- function I(e) {
42
- return e ? t.returnObject ? e : t.multiple && Array.isArray(e) ? e.map((l) => s.value.find((i) => i[t.itemValue] === l)).filter(Boolean) : s.value.find((l) => l[t.itemValue] === e) || null : null;
43
- }
43
+ const j = a(!0);
44
44
  function S(e) {
45
- return u.value === null ? !1 : e ? u.value.some(
46
- (n) => t.returnObject ? n[t.itemValue] === e[t.itemValue] : n === e[t.itemValue]
45
+ return c.value === null ? !1 : e ? c.value.some(
46
+ (t) => n.returnObject ? t[n.itemValue] === e[n.itemValue] : t === e[n.itemValue]
47
47
  ) : !0;
48
48
  }
49
49
  function T(e) {
50
- if (t.returnObject) {
51
- const n = u.value.find(
52
- (i) => i[t.itemValue] === e[t.itemValue]
53
- ), l = u.value.indexOf(n);
54
- u.value.splice(l, 1);
50
+ let t = c.value;
51
+ if (n.returnObject) {
52
+ const u = t.find(
53
+ (f) => f[n.itemValue] === e[n.itemValue]
54
+ ), l = t.indexOf(u);
55
+ t.splice(l, 1);
55
56
  } else {
56
- const n = u.value.indexOf(e[t.itemValue]);
57
- u.value.splice(n, 1);
57
+ const u = t.indexOf(e[n.itemValue]);
58
+ t.splice(u, 1);
58
59
  }
60
+ s("update:modelValue", t);
59
61
  }
60
- function C(e) {
61
- t.clearSearchOnSelect && (h.value = ""), t.focusOnSelect && b();
62
+ function D(e) {
63
+ n.clearSearchOnSelect && (v.value = ""), n.focusOnSelect && x();
62
64
  }
63
- function A() {
64
- c.value || (c.value = !0);
65
+ function y() {
66
+ r.value || (r.value = !0);
65
67
  }
66
- function K() {
67
- c.value && (c.value = !1);
68
+ function N() {
69
+ r.value && (r.value = !1);
68
70
  }
69
- function P() {
70
- c.value = !c.value;
71
+ function B() {
72
+ r.value = !r.value;
71
73
  }
72
- function M(e) {
74
+ function I(e) {
73
75
  return e.length === 1 && e.match(/\w/);
74
76
  }
75
- function b() {
76
- v.value.inputField.focus();
77
+ function x() {
78
+ o.value.inputField.focus();
77
79
  }
78
- function $() {
79
- c.value = !0, y.value && v.value.$el.focus();
80
+ function C() {
81
+ r.value = !0, g.value && o.value.$el.focus();
80
82
  }
81
- function q(e) {
82
- const n = e.key;
83
- (M(n) || n === "Backspace") && (A(), b(), J(() => {
84
- var i;
85
- const l = (i = v.value) == null ? void 0 : i.inputField;
86
- if (l) {
87
- const f = l.selectionStart, O = l.selectionEnd, w = l.value, E = e.key.length === 1 ? e.key : "";
88
- l.value = w.slice(0, f) + E + w.slice(O), l.selectionStart = l.selectionEnd = f + E.length, l.dispatchEvent(new Event("input", { bubbles: !0 }));
83
+ function K(e) {
84
+ const t = e.key;
85
+ (I(t) || t === "Backspace") && (y(), x(), G(() => {
86
+ var l;
87
+ const u = (l = o.value) == null ? void 0 : l.inputField;
88
+ if (u) {
89
+ const f = u.selectionStart, b = u.selectionEnd, k = u.value, E = e.key.length === 1 ? e.key : "";
90
+ u.value = k.slice(0, f) + E + k.slice(b), u.selectionStart = u.selectionEnd = f + E.length, u.dispatchEvent(new Event("input", { bubbles: !0 }));
89
91
  }
90
92
  }));
91
93
  }
92
- function z() {
93
- c.value = !1, j("createItem");
94
+ function $() {
95
+ r.value = !1, s("createItem");
94
96
  }
95
- function G(e) {
96
- let n = u.value.indexOf(e);
97
- u.value.splice(n, 1);
97
+ function q(e) {
98
+ let t = c.value.indexOf(e);
99
+ c.value.splice(t, 1);
98
100
  }
99
- function k() {
100
- h.value = "", u.value = null, r.value = null;
101
+ function M() {
102
+ v.value = "", c.value = null, i.value = null;
101
103
  }
102
- function H(e) {
103
- return !!e.disabledItem;
104
+ function z(e) {
105
+ return !!e.disabled;
104
106
  }
105
107
  return {
106
- selectedItem: r,
107
- textFieldRef: v,
108
- listRef: y,
109
- menuModel: c,
110
- search: h,
111
- getItemText: B,
112
- placeholder: R,
113
- textArr: D,
114
- itemToString: d,
115
- getSelectedItem: N,
108
+ selectedItem: i,
109
+ textFieldRef: o,
110
+ listRef: g,
111
+ menuModel: r,
112
+ search: v,
113
+ getItemText: A,
114
+ placeholder: F,
115
+ textArr: V,
116
+ itemToString: h,
117
+ getSelectedItem: R,
116
118
  checkIfValueExist: S,
117
119
  removeFromArray: T,
118
- lightReset: C,
119
- openMenu: A,
120
- closeMenu: K,
121
- toggleMenu: P,
122
- focusOnMenu: $,
123
- onMenuKeydown: q,
124
- createItem: z,
125
- removeItem: G,
126
- clearSelection: k,
127
- checkDisabled: H,
128
- isAlphanumeric: M
120
+ lightReset: D,
121
+ openMenu: y,
122
+ closeMenu: N,
123
+ toggleMenu: B,
124
+ focusOnMenu: C,
125
+ onMenuKeydown: K,
126
+ createItem: $,
127
+ removeItem: q,
128
+ clearSelection: M,
129
+ checkDisabled: z,
130
+ isAlphanumeric: I
129
131
  };
130
132
  }
131
133
  export {
132
- W as useAutocomplete
134
+ L as useAutocomplete
133
135
  };
@@ -1,4 +1,4 @@
1
- import { computed as o, createBlock as x, openBlock as a, resolveDynamicComponent as y, mergeProps as b, withCtx as v, createElementBlock as r, createCommentVNode as u, renderSlot as S, normalizeClass as s, toDisplayString as d } from "vue";
1
+ import { computed as l, createBlock as x, openBlock as r, resolveDynamicComponent as y, mergeProps as b, withCtx as v, createElementBlock as s, createCommentVNode as u, renderSlot as S, normalizeClass as a, toDisplayString as d } from "vue";
2
2
  const k = ["src", "alt"], w = {
3
3
  __name: "KunAvatar",
4
4
  props: {
@@ -19,48 +19,48 @@ const k = ["src", "alt"], w = {
19
19
  variant: { type: String, default: "flat" }
20
20
  },
21
21
  emits: ["click", "hover", "contextmenu", "focus"],
22
- setup(e) {
23
- const i = {
22
+ setup(m) {
23
+ const e = m, i = {
24
24
  "x-small": "w-6 h-6 text-xs",
25
25
  small: "w-8 h-8 text-sm",
26
26
  default: "w-12 h-12 text-base",
27
27
  large: "w-16 h-16 text-lg",
28
28
  "x-large": "w-24 h-24 text-xl"
29
- }, m = o(() => [
29
+ }, c = l(() => [
30
30
  "relative flex items-center justify-center overflow-hidden cursor-pointer transition-all",
31
- i[size] || i.default,
32
- rounded ? "rounded-full" : tile ? "rounded-none" : "rounded",
33
- border ? `border border-${border}` : "",
34
- color ? `bg-${color}` : "bg-gray-200",
35
- density === "compact" ? "p-1" : density === "comfortable" ? "p-2" : "p-3",
36
- start ? "ms-2" : "",
37
- end ? "me-2" : ""
38
- ]), c = o(() => [
31
+ i[e.size] || i.default,
32
+ e.rounded ? "rounded-full" : e.tile ? "rounded-none" : "rounded",
33
+ e.border ? `border border-${e.border}` : "",
34
+ e.color ? `bg-${e.color}` : "bg-gray-200",
35
+ e.density === "compact" ? "p-1" : e.density === "comfortable" ? "p-2" : "p-3",
36
+ e.start ? "ms-2" : "",
37
+ e.end ? "me-2" : ""
38
+ ]), f = l(() => [
39
39
  "w-full h-full object-cover"
40
- ]), f = o(() => [
40
+ ]), p = l(() => [
41
41
  "absolute text-white text-xl"
42
- ]), g = o(() => [
42
+ ]), g = l(() => [
43
43
  "text-center font-semibold"
44
44
  ]);
45
- return (n, t) => (a(), x(y(e.tag), b(n.$attrs, {
46
- class: m.value,
47
- onClick: t[0] || (t[0] = (l) => n.$emit("click", l)),
48
- onMouseover: t[1] || (t[1] = (l) => n.$emit("hover", l)),
49
- onContextmenu: t[2] || (t[2] = (l) => n.$emit("contextmenu", l)),
50
- onFocus: t[3] || (t[3] = (l) => n.$emit("focus", l))
45
+ return (n, t) => (r(), x(y(e.tag), b(n.$attrs, {
46
+ class: c.value,
47
+ onClick: t[0] || (t[0] = (o) => n.$emit("click", o)),
48
+ onMouseover: t[1] || (t[1] = (o) => n.$emit("hover", o)),
49
+ onContextmenu: t[2] || (t[2] = (o) => n.$emit("contextmenu", o)),
50
+ onFocus: t[3] || (t[3] = (o) => n.$emit("focus", o))
51
51
  }), {
52
52
  default: v(() => [
53
- e.image ? (a(), r("img", {
53
+ e.image ? (r(), s("img", {
54
54
  key: 0,
55
55
  src: e.image,
56
56
  alt: e.alt,
57
- class: s(c.value)
58
- }, null, 10, k)) : e.icon ? (a(), r("span", {
57
+ class: a(f.value)
58
+ }, null, 10, k)) : e.icon ? (r(), s("span", {
59
59
  key: 1,
60
- class: s(f.value)
61
- }, d(e.icon), 3)) : e.text ? (a(), r("span", {
60
+ class: a(p.value)
61
+ }, d(e.icon), 3)) : e.text ? (r(), s("span", {
62
62
  key: 2,
63
- class: s(g.value)
63
+ class: a(g.value)
64
64
  }, d(e.text), 3)) : u("", !0),
65
65
  !e.image && !e.icon && !e.text ? S(n.$slots, "default", { key: 3 }) : u("", !0)
66
66
  ]),
@@ -1,6 +1,6 @@
1
- import { ref as o, computed as a, onMounted as y, createElementBlock as c, openBlock as n, createBlock as v, createElementVNode as I, resolveDynamicComponent as b, unref as u, withCtx as x, renderSlot as m, Fragment as _, renderList as S } from "vue";
2
- import { useIntersectionObserver as g } from "../composables/useIntersectionObserver.js";
3
- import { useKunInfiniteScroll as k } from "../composables/useKunInfiniteScroll.js";
1
+ import { ref as c, computed as f, onMounted as v, createElementBlock as a, openBlock as o, createBlock as I, createElementVNode as g, resolveDynamicComponent as b, unref as t, withCtx as k, renderSlot as u, Fragment as d, renderList as x } from "vue";
2
+ import { useIntersectionObserver as S } from "../composables/useIntersectionObserver.js";
3
+ import { useKunInfiniteScroll as _ } from "../composables/useKunInfiniteScroll.js";
4
4
  import B from "../../../KunVirtualScroller/src/components/KunVirtualScroller.vue.js";
5
5
  /* empty css */
6
6
  import K from "../../../../_virtual/_plugin-vue_export-helper.js";
@@ -39,49 +39,60 @@ const N = {
39
39
  }
40
40
  },
41
41
  emits: ["update:items"],
42
- setup(e, { emit: w }) {
43
- const t = e, i = o(null), f = o(null), {
44
- visibleItems: s,
45
- loadNextBatch: d,
46
- lastBatchReached: p
47
- } = k({
48
- items: a(() => t.items),
49
- search: a(() => t.search),
50
- searchableKeys: t.searchableKeys,
51
- itemsPerIntersection: t.itemsPerIntersection
42
+ setup(r, { emit: w }) {
43
+ const n = r, m = c(null), h = c(null), {
44
+ visibleItems: e,
45
+ loadNextBatch: p,
46
+ lastBatchReached: y
47
+ } = _({
48
+ items: f(() => n.items),
49
+ search: f(() => n.search),
50
+ searchableKeys: n.searchableKeys,
51
+ itemsPerIntersection: n.itemsPerIntersection
52
52
  });
53
- return y(() => {
54
- g(i.value, ([r]) => {
55
- r.isIntersecting && (p.value || d());
53
+ return v(() => {
54
+ S(m.value, ([l]) => {
55
+ l.isIntersecting && (y.value || p());
56
56
  });
57
- }), (r, C) => (n(), c("div", {
57
+ }), (l, C) => (o(), a("div", {
58
58
  class: "w-full h-full overflow-auto",
59
59
  ref_key: "scrollContainer",
60
- ref: f
60
+ ref: h
61
61
  }, [
62
- e.virtual ? (n(), v(b(B), {
62
+ r.virtual ? (o(), I(b(B), {
63
63
  key: 0,
64
- items: u(s),
65
- "estimated-item-height": e.itemSize,
66
- "scroll-to-index": e.scrollToIndex,
64
+ items: t(e).length ? t(e) : [{}],
65
+ "estimated-item-height": r.itemSize,
66
+ "scroll-to-index": r.scrollToIndex,
67
67
  class: "virtual-list"
68
68
  }, {
69
- default: x(({ item: l, index: h }) => [
70
- m(r.$slots, "default", {
71
- item: l,
72
- index: h
69
+ default: k(({ item: i, index: s }) => [
70
+ u(l.$slots, "default", {
71
+ item: t(e).length ? i : null,
72
+ index: t(e).length ? s : null,
73
+ empty: !t(e).length
73
74
  }, void 0, !0)
74
75
  ]),
75
76
  _: 3
76
- }, 8, ["items", "estimated-item-height", "scroll-to-index"])) : (n(!0), c(_, { key: 1 }, S(u(s), (l) => m(r.$slots, "default", { item: l }, void 0, !0)), 256)),
77
- I("div", {
77
+ }, 8, ["items", "estimated-item-height", "scroll-to-index"])) : (o(), a(d, { key: 1 }, [
78
+ t(e).length ? (o(!0), a(d, { key: 0 }, x(t(e), (i, s) => u(l.$slots, "default", {
79
+ key: i.id ?? s,
80
+ item: i,
81
+ index: s,
82
+ visibleItems: t(e)
83
+ }, void 0, !0)), 128)) : u(l.$slots, "default", {
84
+ key: 1,
85
+ visibleItems: t(e)
86
+ }, void 0, !0)
87
+ ], 64)),
88
+ g("div", {
78
89
  ref_key: "sentinel",
79
- ref: i,
90
+ ref: m,
80
91
  class: "w-full h-1"
81
92
  }, null, 512)
82
93
  ], 512));
83
94
  }
84
- }, T = /* @__PURE__ */ K(N, [["__scopeId", "data-v-98c7f11d"]]);
95
+ }, T = /* @__PURE__ */ K(N, [["__scopeId", "data-v-ecaa5fae"]]);
85
96
  export {
86
97
  T as default
87
98
  };