lkt-menu 1.0.10 → 1.2.0

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/dist/build.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- declare class x {
2
- constructor(t: any, n: any, i: any);
1
+ declare class H {
2
+ constructor(r: any, a: any, s: any);
3
3
  key: any;
4
4
  href: any;
5
5
  label: any;
@@ -7,17 +7,17 @@ declare class x {
7
7
  isOpened: boolean;
8
8
  isActive: boolean;
9
9
  children: any[];
10
- setChildren(t: any): this;
11
- setOnClick(t: any): this;
10
+ setChildren(r: any): this;
11
+ setOnClick(r: any): this;
12
12
  onClick: any;
13
- setIsActiveChecker(t: any): this;
13
+ setIsActiveChecker(r: any): this;
14
14
  isActiveChecker: any;
15
- setIsActive(t?: boolean): this;
16
- setLabel(t: any): this;
17
- setIcon(t: any): this;
15
+ setIsActive(r?: boolean): this;
16
+ setLabel(r: any): this;
17
+ setIcon(r: any): this;
18
18
  doClose(): void;
19
19
  }
20
- declare function ke(o: any, t: any, n: any): {
20
+ declare function Xe(e: any, r: any, a: any): {
21
21
  key: any;
22
22
  href: any;
23
23
  label: any;
@@ -25,18 +25,18 @@ declare function ke(o: any, t: any, n: any): {
25
25
  isOpened: boolean;
26
26
  isActive: boolean;
27
27
  children: any[];
28
- setChildren: (t: any) => x;
29
- setOnClick: (t: any) => x;
28
+ setChildren: (r: any) => H;
29
+ setOnClick: (r: any) => H;
30
30
  onClick: any;
31
- setIsActiveChecker: (t: any) => x;
31
+ setIsActiveChecker: (r: any) => H;
32
32
  isActiveChecker: any;
33
- setIsActive: (t?: boolean) => x;
34
- setLabel: (t: any) => x;
35
- setIcon: (t: any) => x;
33
+ setIsActive: (r?: boolean) => H;
34
+ setLabel: (r: any) => H;
35
+ setIcon: (r: any) => H;
36
36
  doClose: () => void;
37
37
  };
38
- declare namespace fe {
39
- function install(o: any): void;
38
+ declare namespace Qe {
39
+ function install(e: any): void;
40
40
  }
41
- declare function ye(o: any): boolean;
42
- export { x as MenuEntry, ke as createMenuEntry, fe as default, ye as setMenuToggleSlot };
41
+ declare function Ye(e: any): boolean;
42
+ export { H as MenuEntry, Xe as createMenuEntry, Qe as default, Ye as setMenuToggleSlot };
package/dist/build.js CHANGED
@@ -1,145 +1,152 @@
1
- import { defineComponent as J, ref as $, useSlots as K, computed as c, watch as b, onMounted as q, resolveComponent as B, openBlock as u, createElementBlock as d, normalizeClass as V, createElementVNode as O, createVNode as G, withCtx as w, unref as H, renderSlot as L, createCommentVNode as f, toDisplayString as P, createBlock as R, resolveDynamicComponent as Q, Fragment as T, renderList as S, createSlots as W, reactive as X } from "vue";
2
- import { __ as Y } from "lkt-i18n";
3
- import { useRouter as Z } from "vue-router";
1
+ import { defineComponent as B, ref as O, useSlots as U, computed as c, watch as x, onMounted as J, resolveComponent as z, createElementBlock as d, openBlock as i, normalizeClass as S, createElementVNode as A, createCommentVNode as k, createVNode as W, withCtx as V, renderSlot as D, unref as q, toDisplayString as G, createBlock as R, resolveDynamicComponent as Q, Fragment as F, renderList as M, createSlots as $, reactive as X } from "vue";
2
+ import { useRouter as Y } from "vue-router";
3
+ import "lkt-string-tools";
4
+ import { __ as Z } from "lkt-i18n";
4
5
  import { DataState as ee } from "lkt-data-state";
5
6
  import { httpCall as te } from "lkt-http-client";
6
- class x {
7
- constructor(t, n, i) {
8
- this.key = "", this.href = "", this.label = "", this.icon = "", this.onClick = void 0, this.isActiveChecker = void 0, this.isOpened = !1, this.isActive = !1, this.parent = void 0, this.children = [], this.key = t, this.href = n, this.label = i;
7
+ class H {
8
+ constructor(r, a, s) {
9
+ this.key = "", this.href = "", this.label = "", this.icon = "", this.onClick = void 0, this.isActiveChecker = void 0, this.isOpened = !1, this.isActive = !1, this.parent = void 0, this.children = [], this.key = r, this.href = a, this.label = s;
9
10
  }
10
- setChildren(t) {
11
- return t.forEach((n) => n.parent = this), this.children = t, this;
11
+ setChildren(r) {
12
+ return r.forEach((a) => a.parent = this), this.children = r, this;
12
13
  }
13
- setOnClick(t) {
14
- return this.onClick = t, this;
14
+ setOnClick(r) {
15
+ return this.onClick = r, this;
15
16
  }
16
- setIsActiveChecker(t) {
17
- return this.isActiveChecker = t, this;
17
+ setIsActiveChecker(r) {
18
+ return this.isActiveChecker = r, this;
18
19
  }
19
- setIsActive(t = !0) {
20
- return this.isActive = t, this;
20
+ setIsActive(r = !0) {
21
+ return this.isActive = r, this;
21
22
  }
22
- setLabel(t) {
23
- return this.label = t, this;
23
+ setLabel(r) {
24
+ return this.label = r, this;
24
25
  }
25
- setIcon(t) {
26
- return this.icon = t, this;
26
+ setIcon(r) {
27
+ return this.icon = r, this;
27
28
  }
28
29
  doClose() {
29
30
  this.isOpened = !1;
30
31
  }
31
32
  }
32
- const j = (o, t) => (t.forEach((n) => {
33
- o.includes(n.key) || o.push(n.key), n.children.length > 0 && j(o, n.children);
34
- }), o), A = class A {
33
+ const T = (e, r) => (r.forEach((a) => {
34
+ e.includes(a.key) || e.push(a.key), a.children.length > 0 && T(e, a.children);
35
+ }), e), w = class w {
35
36
  };
36
- A.toggleSlot = "", A.debugEnabled = !1;
37
- let k = A;
38
- const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }, re = {
37
+ w.toggleSlot = "", w.debugEnabled = !1;
38
+ let y = w;
39
+ var re = ((e) => (e.Button = "button", e.Submit = "submit", e.Reset = "reset", e.Anchor = "anchor", e.Content = "content", e.Switch = "switch", e.HiddenSwitch = "hidden-switch", e.Split = "split", e.SplitLazy = "split-lazy", e.SplitEver = "split-ever", e.Tooltip = "tooltip", e.TooltipLazy = "tooltip-lazy", e.TooltipEver = "tooltip-ever", e))(re || {}), ne = ((e) => (e.Text = "text", e.Email = "email", e.Tel = "tel", e.Password = "password", e.Search = "search", e.Number = "number", e.Color = "color", e.Range = "range", e.Textarea = "textarea", e.Html = "html", e.Date = "date", e.File = "file", e.Image = "image", e.Select = "select", e.Check = "check", e.Switch = "switch", e.Calc = "calc", e.Card = "card", e.Elements = "elements", e))(ne || {}), le = ((e) => (e.Auto = "auto", e.Always = "always", e.Lazy = "lazy", e.Ever = "ever", e))(le || {}), ae = ((e) => (e.Transform = "transform", e.Height = "height", e.Display = "display", e))(ae || {}), oe = ((e) => (e.Href = "href", e.RouterLink = "router-link", e.RouterLinkBack = "router-link-back", e.Mail = "mail", e.Tel = "tel", e.Tab = "tab", e.Download = "download", e.Action = "action", e.Legacy = "", e))(oe || {}), ie = ((e) => (e.None = "", e.Field = "field", e.Button = "button", e.Anchor = "anchor", e))(ie || {}), se = ((e) => (e.List = "list", e.Inline = "inline", e.Count = "count", e))(se || {}), ue = ((e) => (e.None = "", e.Focus = "focus", e.Blur = "blur", e.Always = "always", e))(ue || {}), ce = ((e) => (e.MinStringLength = "min-str", e.MinNumber = "min-num", e.MaxStringLength = "max-str", e.MaxNumber = "max-num", e.Email = "email", e.Empty = "empty", e.EqualTo = "equal-to", e.MinNumbers = "min-numbers", e.MaxNumbers = "max-numbers", e.MinChars = "min-chars", e.MaxChars = "max-chars", e.MinUpperChars = "min-upper-chars", e.MaxUpperChars = "max-upper-chars", e.MinLowerChars = "min-lower-chars", e.MaxLowerChars = "max-lower-chars", e.MinSpecialChars = "min-special-chars", e.MaxSpecialChars = "max-special-chars", e))(ce || {}), de = ((e) => (e.Ok = "ok", e.Ko = "ko", e.Info = "info", e))(de || {}), ve = ((e) => (e.Create = "create", e.Update = "update", e.Read = "read", e))(ve || {}), me = ((e) => (e.Inline = "inline", e.Modal = "modal", e))(me || {}), he = ((e) => (e.Top = "top", e.Bottom = "bottom", e))(he || {}), pe = ((e) => (e.Changed = "changed", e.Always = "always", e.Never = "never", e))(pe || {}), fe = ((e) => (e.Manual = "manual", e.Auto = "auto", e.Delay = "delay", e))(fe || {}), ke = ((e) => (e.Toast = "toast", e.Inline = "inline", e))(ke || {}), ye = ((e) => (e.Pages = "pages", e.PrevNext = "prev-next", e.PagesPrevNext = "pages-prev-next", e.PagesPrevNextFirstLast = "pages-prev-next-first-last", e.LoadMore = "load-more", e.Infinite = "infinite", e))(ye || {}), ge = ((e) => (e.Table = "table", e.Item = "item", e.Ul = "ul", e.Ol = "ol", e))(ge || {}), Ce = ((e) => (e[e.Auto = 0] = "Auto", e[e.PreferItem = 1] = "PreferItem", e[e.PreferCustomItem = 2] = "PreferCustomItem", e[e.PreferColumns = 3] = "PreferColumns", e))(Ce || {}), be = ((e) => (e.NotDefined = "", e.ActionIcon = "action-icon", e))(be || {}), _e = ((e) => (e.Message = "message", e.Button = "button", e))(_e || {}), Se = ((e) => (e.Left = "left", e.Center = "center", e.Right = "right", e))(Se || {}), xe = ((e) => (e.Fixed = "fixed", e.Absolute = "absolute", e))(xe || {}), Ae = ((e) => (e.Top = "top", e.Bottom = "bottom", e.Center = "center", e.ReferrerCenter = "referrer-center", e))(Ae || {}), Me = ((e) => (e.Left = "left", e.Right = "right", e.Center = "center", e.LeftCorner = "left-corner", e.RightCorner = "right-corner", e))(Me || {}), we = ((e) => (e.Refresh = "refresh", e.Close = "close", e.ReOpen = "reOpen", e.Exec = "exec", e.Open = "open", e))(we || {}), Ie = ((e) => (e.Modal = "modal", e.Confirm = "confirm", e))(Ie || {}), Ee = ((e) => (e.None = "", e.Incremental = "incremental", e.Decremental = "decremental", e))(Ee || {}), Le = ((e) => (e.NotDefined = "", e.Hidden = "hidden", e.Integer = "integer", e.Decimal = "decimal", e.Auto = "auto", e))(Le || {}), Ne = ((e) => (e.Asc = "asc", e.Desc = "desc", e))(Ne || {}), Oe = ((e) => (e.Create = "create", e.Update = "update", e.Edit = "edit", e.Drop = "drop", e.Sort = "sort", e.SwitchEditMode = "switch-edit-mode", e.InlineEdit = "inline-edit", e.InlineCreate = "inline-create", e.ModalCreate = "modal-create", e.InlineCreateEver = "inline-create-ever", e))(Oe || {}), Ve = ((e) => (e.Lazy = "lazy", e.Ever = "ever", e))(Ve || {}), De = (e) => {
40
+ let r = String(e);
41
+ return r.startsWith("__:") ? Z(r.substring(3)) : r;
42
+ };
43
+ const Re = { class: "lkt-menu-entry-main" }, Te = { class: "lkt-entry-content" }, Pe = {
39
44
  key: 0,
40
45
  class: "lkt-menu-entry-icon"
41
- }, se = {
46
+ }, ze = {
42
47
  key: 1,
43
48
  class: "lkt-menu-entry-text"
44
- }, oe = {
49
+ }, Be = {
45
50
  key: 0,
46
51
  class: "lkt-menu-entry-children"
47
- }, ue = /* @__PURE__ */ J({
52
+ }, Ue = /* @__PURE__ */ B({
48
53
  __name: "MenuItem",
49
54
  props: {
50
- modelValue: { default: () => new x("", "", "") }
55
+ modelValue: { default: () => new H("", "", "") }
51
56
  },
52
57
  emits: ["update:modelValue"],
53
- setup(o, { emit: t }) {
54
- const n = t, i = o, e = $(i.modelValue), a = K(), I = Z(), m = $(!1), y = () => {
55
- e.value.isOpened = !e.value.isOpened;
56
- }, E = () => (e.value.children.length > 0 && y(), typeof e.value.onClick == "function" && e.value.onClick({
57
- entry: e.value
58
- }), 1), g = c(() => a["icon-" + e.value.key] || e.value.icon !== ""), D = c(() => {
59
- let r = [];
60
- return g.value && r.push("has-icon"), m.value && r.push("is-active"), r.join(" ");
61
- }), s = c(() => j([], e.value.children)), l = c(() => {
62
- let r = [];
63
- for (let v in a)
64
- v.startsWith("icon-") && s.value.includes(v.substring(5)) && r.push(v);
65
- return r;
66
- }), h = c(() => e.value.label.startsWith("__:") ? Y(e.value.label.substring(3)) : e.value.label), _ = c(() => e.value.isActive ? !0 : typeof e.value.isActiveChecker == "function" ? !!e.value.isActiveChecker({
67
- entry: e.value
68
- }) : !1), p = c(() => !!k.toggleSlot), F = c(() => k.toggleSlot);
69
- return b(() => i.modelValue, (r) => {
70
- e.value = r;
71
- }, { deep: !0 }), b(e, (r) => {
72
- n("update:modelValue", r);
73
- }, { deep: !0 }), q(() => {
74
- let r = I.currentRoute;
75
- if (r.value.path === e.value.href)
76
- e.value.isOpened = !0;
77
- else if (e.value.children.length > 0) {
78
- let v = !1;
79
- e.value.children.forEach((M) => {
80
- r.value.path === M.href && (v = !0);
81
- }), v && (e.value.isOpened = !0);
58
+ setup(e, { emit: r }) {
59
+ const a = r, s = e, t = O(s.modelValue), u = U(), f = Y(), h = O(!1), g = () => {
60
+ t.value.isOpened = !t.value.isOpened;
61
+ }, I = () => (t.value.children.length > 0 && g(), typeof t.value.onClick == "function" && t.value.onClick({
62
+ entry: t.value
63
+ }), 1), C = c(() => u["icon-" + t.value.key] || t.value.icon !== ""), E = c(() => {
64
+ let l = [];
65
+ return C.value && l.push("has-icon"), h.value && l.push("is-active"), l.join(" ");
66
+ }), o = c(() => T([], t.value.children)), n = c(() => {
67
+ let l = [];
68
+ for (let v in u)
69
+ v.startsWith("icon-") && o.value.includes(v.substring(5)) && l.push(v);
70
+ return l;
71
+ }), m = c(() => De(t.value.label)), b = c(() => t.value.isActive ? !0 : typeof t.value.isActiveChecker == "function" ? !!t.value.isActiveChecker({
72
+ entry: t.value
73
+ }) : !1), p = c(() => !!y.toggleSlot), j = c(() => y.toggleSlot);
74
+ return x(() => s.modelValue, (l) => {
75
+ t.value = l;
76
+ }, { deep: !0 }), x(t, (l) => {
77
+ a("update:modelValue", l);
78
+ }, { deep: !0 }), J(() => {
79
+ let l = f == null ? void 0 : f.currentRoute;
80
+ if (l) {
81
+ if (l.value.path === t.value.href)
82
+ t.value.isOpened = !0;
83
+ else if (t.value.children.length > 0) {
84
+ let v = !1;
85
+ t.value.children.forEach((L) => {
86
+ l.value.path === L.href && (v = !0);
87
+ }), v && (t.value.isOpened = !0);
88
+ }
82
89
  }
83
- }), (r, v) => {
84
- const M = B("lkt-anchor"), z = B("menu-item", !0);
85
- return u(), d("div", {
86
- class: V(["lkt-menu-entry", D.value])
90
+ }), (l, v) => {
91
+ const L = z("lkt-anchor"), K = z("menu-item", !0);
92
+ return i(), d("div", {
93
+ class: S(["lkt-menu-entry", E.value])
87
94
  }, [
88
- O("div", le, [
89
- G(M, {
90
- to: e.value.href,
91
- "on-click": E,
92
- "is-active": _.value,
93
- onActive: v[0] || (v[0] = (U) => m.value = U)
95
+ A("div", Re, [
96
+ W(L, {
97
+ to: t.value.href,
98
+ "on-click": I,
99
+ "is-active": b.value,
100
+ onActive: v[0] || (v[0] = (P) => h.value = P)
94
101
  }, {
95
- default: w(() => [
96
- O("div", ne, [
97
- g.value ? (u(), d("div", re, [
98
- H(a)["icon-" + e.value.key] ? L(r.$slots, "icon-" + e.value.key, {
99
- key: e.value.key,
100
- entry: e.value
101
- }) : e.value.icon !== "" ? (u(), d("i", {
102
+ default: V(() => [
103
+ A("div", Te, [
104
+ C.value ? (i(), d("div", Pe, [
105
+ q(u)["icon-" + t.value.key] ? D(l.$slots, "icon-" + t.value.key, {
106
+ key: t.value.key,
107
+ entry: t.value
108
+ }) : t.value.icon !== "" ? (i(), d("i", {
102
109
  key: 1,
103
- class: V(e.value.icon)
104
- }, null, 2)) : f("", !0)
105
- ])) : f("", !0),
106
- e.value.label !== "" ? (u(), d("div", se, P(h.value), 1)) : f("", !0)
110
+ class: S(t.value.icon)
111
+ }, null, 2)) : k("", !0)
112
+ ])) : k("", !0),
113
+ t.value.label !== "" ? (i(), d("div", ze, G(m.value), 1)) : k("", !0)
107
114
  ])
108
115
  ]),
109
116
  _: 3
110
117
  }, 8, ["to", "is-active"]),
111
- e.value.children.length > 0 ? (u(), d("div", {
118
+ t.value.children.length > 0 ? (i(), d("div", {
112
119
  key: 0,
113
120
  class: "lkt-menu-entry-toggle",
114
- onClick: y
121
+ onClick: g
115
122
  }, [
116
- p.value ? (u(), R(Q(F.value), {
123
+ p.value ? (i(), R(Q(j.value), {
117
124
  key: 0,
118
- class: V(["lkt-menu-entry-toggle-inner", e.value.isOpened ? "is-opened" : ""])
119
- }, null, 8, ["class"])) : (u(), d("div", {
125
+ class: S(["lkt-menu-entry-toggle-inner", t.value.isOpened ? "is-opened" : ""])
126
+ }, null, 8, ["class"])) : (i(), d("div", {
120
127
  key: 1,
121
- class: V(["lkt-menu-entry-toggle-inner lkt-menu-entry-toggle-triangle", e.value.isOpened ? "is-opened" : ""])
128
+ class: S(["lkt-menu-entry-toggle-inner lkt-menu-entry-toggle-triangle", t.value.isOpened ? "is-opened" : ""])
122
129
  }, null, 2))
123
- ])) : f("", !0)
130
+ ])) : k("", !0)
124
131
  ]),
125
- e.value.isOpened ? (u(), d("div", oe, [
126
- (u(!0), d(T, null, S(e.value.children, (U, N) => (u(), R(z, {
127
- modelValue: e.value.children[N],
128
- "onUpdate:modelValue": (C) => e.value.children[N] = C,
129
- key: e.value.children[N].key
130
- }, W({ _: 2 }, [
131
- S(l.value, (C) => ({
132
- name: C,
133
- fn: w(() => [
134
- L(r.$slots, C)
132
+ t.value.isOpened ? (i(), d("div", Be, [
133
+ (i(!0), d(F, null, M(t.value.children, (P, N) => (i(), R(K, {
134
+ modelValue: t.value.children[N],
135
+ "onUpdate:modelValue": (_) => t.value.children[N] = _,
136
+ key: t.value.children[N].key
137
+ }, $({ _: 2 }, [
138
+ M(n.value, (_) => ({
139
+ name: _,
140
+ fn: V(() => [
141
+ D(l.$slots, _)
135
142
  ])
136
143
  }))
137
144
  ]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
138
- ])) : f("", !0)
145
+ ])) : k("", !0)
139
146
  ], 2);
140
147
  };
141
148
  }
142
- }), ie = { class: "lkt-menu-container" }, ae = { class: "lkt-menu" }, ce = /* @__PURE__ */ J({
149
+ }), Fe = { class: "lkt-menu-container" }, $e = { class: "lkt-menu" }, He = /* @__PURE__ */ B({
143
150
  __name: "LktMenu",
144
151
  props: {
145
152
  modelValue: { default: () => [] },
@@ -147,66 +154,65 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
147
154
  resourceData: { default: () => ({}) }
148
155
  },
149
156
  emits: ["update:modelValue", "click-outside", "loading", "results", "response", "error"],
150
- setup(o, { emit: t }) {
151
- const n = o, i = t, e = K(), a = $(n.modelValue), I = (s) => {
152
- let l = {};
153
- typeof s == "object" && Object.keys(s).length > 0 && (l = JSON.parse(JSON.stringify(s)));
154
- for (let h in l)
155
- (Array.isArray(l[h]) || typeof l[h] == "object") && (l[h] = JSON.stringify(l[h]));
156
- return l;
157
+ setup(e, { emit: r }) {
158
+ const a = e, s = r, t = U(), u = O(a.modelValue), f = (o) => {
159
+ let n = {};
160
+ typeof o == "object" && Object.keys(o).length > 0 && (n = JSON.parse(JSON.stringify(o)));
161
+ for (let m in n)
162
+ (Array.isArray(n[m]) || typeof n[m] == "object") && (n[m] = JSON.stringify(n[m]));
163
+ return n;
157
164
  };
158
- let m = new ee({});
159
- m.increment(I(n.resourceData));
160
- const y = c(() => j([], a.value)), E = c(() => {
161
- let s = [];
162
- for (let l in e)
163
- l.startsWith("icon-") && y.value.includes(l.substring(5)) && s.push(l);
164
- return s;
165
- }), g = () => {
166
- if (!n.resource)
167
- return;
168
- let s = m.getData();
169
- i("loading"), te(n.resource, s).then((l) => {
170
- m.turnStoredIntoOriginal(), a.value = l.data, i("results", l.data), i("response", l);
171
- }).catch((l) => {
172
- i("error", l);
165
+ let h = new ee({});
166
+ h.increment(f(a.resourceData));
167
+ const g = c(() => T([], u.value)), I = c(() => {
168
+ let o = [];
169
+ for (let n in t)
170
+ n.startsWith("icon-") && g.value.includes(n.substring(5)) && o.push(n);
171
+ return o;
172
+ }), C = () => {
173
+ if (!a.resource) return;
174
+ let o = h.getData();
175
+ s("loading"), te(a.resource, o).then((n) => {
176
+ h.turnStoredIntoOriginal(), u.value = n.data, s("results", n.data), s("response", n);
177
+ }).catch((n) => {
178
+ s("error", n);
173
179
  });
174
- }, D = () => {
175
- i("click-outside");
180
+ }, E = () => {
181
+ s("click-outside");
176
182
  };
177
- return b(() => n.modelValue, (s) => {
178
- a.value = s;
179
- }, { deep: !0 }), b(a, (s) => {
180
- i("update:modelValue", s);
181
- }, { deep: !0 }), g(), (s, l) => (u(), d("div", ie, [
182
- O("div", ae, [
183
- (u(!0), d(T, null, S(a.value, (h, _) => (u(), R(ue, {
184
- modelValue: a.value[_],
185
- "onUpdate:modelValue": (p) => a.value[_] = p,
186
- key: h.key
187
- }, W({ _: 2 }, [
188
- S(E.value, (p) => ({
183
+ return x(() => a.modelValue, (o) => {
184
+ u.value = o;
185
+ }, { deep: !0 }), x(u, (o) => {
186
+ s("update:modelValue", o);
187
+ }, { deep: !0 }), C(), (o, n) => (i(), d("div", Fe, [
188
+ A("div", $e, [
189
+ (i(!0), d(F, null, M(u.value, (m, b) => (i(), R(Ue, {
190
+ modelValue: u.value[b],
191
+ "onUpdate:modelValue": (p) => u.value[b] = p,
192
+ key: m.key
193
+ }, $({ _: 2 }, [
194
+ M(I.value, (p) => ({
189
195
  name: p,
190
- fn: w(() => [
191
- L(s.$slots, p)
196
+ fn: V(() => [
197
+ D(o.$slots, p)
192
198
  ])
193
199
  }))
194
200
  ]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
195
201
  ]),
196
- O("div", {
202
+ A("div", {
197
203
  class: "lkt-menu-outside",
198
- onClick: D
204
+ onClick: E
199
205
  })
200
206
  ]));
201
207
  }
202
- }), fe = {
203
- install: (o) => {
204
- o.component("lkt-menu") === void 0 && o.component("lkt-menu", ce);
208
+ }), Qe = {
209
+ install: (e) => {
210
+ e.component("lkt-menu") === void 0 && e.component("lkt-menu", He);
205
211
  }
206
- }, ke = (o, t, n) => X(new x(o, t, n)), ye = (o) => (k.toggleSlot = o, !0);
212
+ }, Xe = (e, r, a) => X(new H(e, r, a)), Ye = (e) => (y.toggleSlot = e, !0);
207
213
  export {
208
- x as MenuEntry,
209
- ke as createMenuEntry,
210
- fe as default,
211
- ye as setMenuToggleSlot
214
+ H as MenuEntry,
215
+ Xe as createMenuEntry,
216
+ Qe as default,
217
+ Ye as setMenuToggleSlot
212
218
  };
@@ -1,19 +1,52 @@
1
- import { MenuEntry } from "../classes/MenuEntry";
2
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
3
- modelValue?: MenuEntry | undefined;
4
- }>, {
5
- modelValue: () => MenuEntry;
6
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
7
- "update:modelValue": (...args: any[]) => void;
8
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
9
- modelValue?: MenuEntry | undefined;
10
- }>, {
11
- modelValue: () => MenuEntry;
12
- }>>> & {
13
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
14
- }, {
15
- modelValue: MenuEntry;
16
- }, {}>, Partial<Record<string, (_: {
1
+ import { MenuEntry } from '../classes/MenuEntry';
2
+ import { LktObject } from 'lkt-ts-interfaces';
3
+ type __VLS_Props = {
4
+ modelValue?: MenuEntry;
5
+ };
6
+ declare const entry: import("vue").Ref<{
7
+ key: string;
8
+ href: string;
9
+ label: string;
10
+ icon: string;
11
+ onClick: Function | undefined;
12
+ isActiveChecker: Function | undefined;
13
+ isOpened: boolean;
14
+ isActive: boolean;
15
+ parent: /*elided*/ any | undefined;
16
+ children: /*elided*/ any[];
17
+ setChildren: (children: MenuEntry[]) => MenuEntry;
18
+ setOnClick: (fn: Function) => MenuEntry;
19
+ setIsActiveChecker: (fn: Function) => MenuEntry;
20
+ setIsActive: (enabled?: boolean) => MenuEntry;
21
+ setLabel: (str: string) => MenuEntry;
22
+ setIcon: (str: string) => MenuEntry;
23
+ doClose: () => void;
24
+ }, MenuEntry | {
25
+ key: string;
26
+ href: string;
27
+ label: string;
28
+ icon: string;
29
+ onClick: Function | undefined;
30
+ isActiveChecker: Function | undefined;
31
+ isOpened: boolean;
32
+ isActive: boolean;
33
+ parent: /*elided*/ any | undefined;
34
+ children: /*elided*/ any[];
35
+ setChildren: (children: MenuEntry[]) => MenuEntry;
36
+ setOnClick: (fn: Function) => MenuEntry;
37
+ setIsActiveChecker: (fn: Function) => MenuEntry;
38
+ setIsActive: (enabled?: boolean) => MenuEntry;
39
+ setLabel: (str: string) => MenuEntry;
40
+ setIcon: (str: string) => MenuEntry;
41
+ doClose: () => void;
42
+ }>, slots: Readonly<{
43
+ [name: string]: import("vue").Slot<any> | undefined;
44
+ }>, isActive: import("vue").Ref<boolean, boolean>;
45
+ declare const onClickToggle: () => void, onClick: () => number;
46
+ declare const canRenderIcon: import("vue").ComputedRef<boolean | import("vue").Slot<any>>, classes: import("vue").ComputedRef<string>;
47
+ declare const entryIconSlots: import("vue").ComputedRef<LktObject>, computedLabel: import("vue").ComputedRef<any>, computedIsActive: import("vue").ComputedRef<boolean>, hasToggleSlot: import("vue").ComputedRef<boolean>, toggleSlot: import("vue").ComputedRef<string | import("vue").Component>;
48
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
49
+ declare var __VLS_10: string, __VLS_11: {
17
50
  key: string;
18
51
  entry: {
19
52
  key: string;
@@ -24,8 +57,8 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
24
57
  isActiveChecker: Function | undefined;
25
58
  isOpened: boolean;
26
59
  isActive: boolean;
27
- parent: any | undefined;
28
- children: any[];
60
+ parent: /*elided*/ any | undefined;
61
+ children: /*elided*/ any[];
29
62
  setChildren: (children: MenuEntry[]) => MenuEntry;
30
63
  setOnClick: (fn: Function) => MenuEntry;
31
64
  setIsActiveChecker: (fn: Function) => MenuEntry;
@@ -34,26 +67,42 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
34
67
  setIcon: (str: string) => MenuEntry;
35
68
  doClose: () => void;
36
69
  };
37
- }) => any>> & Partial<Record<any, (_: {}) => any>>>;
70
+ }, __VLS_22: any, __VLS_23: {};
71
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
72
+ [K in NonNullable<typeof __VLS_10>]?: (props: typeof __VLS_11) => any;
73
+ } & {
74
+ [K in NonNullable<typeof __VLS_22>]?: (props: typeof __VLS_23) => any;
75
+ }>;
76
+ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
77
+ entry: typeof entry;
78
+ slots: typeof slots;
79
+ isActive: typeof isActive;
80
+ onClickToggle: typeof onClickToggle;
81
+ onClick: typeof onClick;
82
+ canRenderIcon: typeof canRenderIcon;
83
+ classes: typeof classes;
84
+ entryIconSlots: typeof entryIconSlots;
85
+ computedLabel: typeof computedLabel;
86
+ computedIsActive: typeof computedIsActive;
87
+ hasToggleSlot: typeof hasToggleSlot;
88
+ toggleSlot: typeof toggleSlot;
89
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
90
+ "update:modelValue": (...args: any[]) => void;
91
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
92
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
93
+ }>, {
94
+ modelValue: MenuEntry;
95
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
96
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
97
+ "update:modelValue": (...args: any[]) => void;
98
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
99
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
100
+ }>, {
101
+ modelValue: MenuEntry;
102
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
103
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
38
104
  export default _default;
39
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
40
- type __VLS_TypePropsToRuntimeProps<T> = {
41
- [K in keyof T]-?: {} extends Pick<T, K> ? {
42
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
43
- } : {
44
- type: import('vue').PropType<T[K]>;
45
- required: true;
46
- };
47
- };
48
- type __VLS_WithDefaults<P, D> = {
49
- [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
50
- default: D[K];
51
- }> : P[K];
52
- };
53
- type __VLS_Prettify<T> = {
54
- [K in keyof T]: T[K];
55
- } & {};
56
- type __VLS_WithTemplateSlots<T, S> = T & {
105
+ type __VLS_WithSlots<T, S> = T & {
57
106
  new (): {
58
107
  $slots: S;
59
108
  };
@@ -1,59 +1,101 @@
1
1
  import { MenuEntry } from "../classes/MenuEntry";
2
+ import MenuItem from "../components/MenuItem.vue";
2
3
  import { LktObject } from "lkt-ts-interfaces";
3
- declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
4
- modelValue?: MenuEntry[] | undefined;
5
- resource?: string | undefined;
4
+ type __VLS_Props = {
5
+ modelValue?: MenuEntry[];
6
+ resource?: string;
6
7
  resourceData: LktObject;
7
- }>, {
8
- modelValue: () => never[];
9
- resource: string;
10
- resourceData: () => {};
11
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
8
+ };
9
+ declare const entries: import("vue").Ref<{
10
+ key: string;
11
+ href: string;
12
+ label: string;
13
+ icon: string;
14
+ onClick: Function | undefined;
15
+ isActiveChecker: Function | undefined;
16
+ isOpened: boolean;
17
+ isActive: boolean;
18
+ parent: /*elided*/ any | undefined;
19
+ children: /*elided*/ any[];
20
+ setChildren: (children: MenuEntry[]) => MenuEntry;
21
+ setOnClick: (fn: Function) => MenuEntry;
22
+ setIsActiveChecker: (fn: Function) => MenuEntry;
23
+ setIsActive: (enabled?: boolean) => MenuEntry;
24
+ setLabel: (str: string) => MenuEntry;
25
+ setIcon: (str: string) => MenuEntry;
26
+ doClose: () => void;
27
+ }[], MenuEntry[] | {
28
+ key: string;
29
+ href: string;
30
+ label: string;
31
+ icon: string;
32
+ onClick: Function | undefined;
33
+ isActiveChecker: Function | undefined;
34
+ isOpened: boolean;
35
+ isActive: boolean;
36
+ parent: /*elided*/ any | undefined;
37
+ children: /*elided*/ any[];
38
+ setChildren: (children: MenuEntry[]) => MenuEntry;
39
+ setOnClick: (fn: Function) => MenuEntry;
40
+ setIsActiveChecker: (fn: Function) => MenuEntry;
41
+ setIsActive: (enabled?: boolean) => MenuEntry;
42
+ setLabel: (str: string) => MenuEntry;
43
+ setIcon: (str: string) => MenuEntry;
44
+ doClose: () => void;
45
+ }[]>;
46
+ declare const entryIconSlots: import("vue").ComputedRef<LktObject>;
47
+ declare const onClickOutside: () => void;
48
+ declare const __VLS_ctx: InstanceType<__VLS_PickNotAny<typeof __VLS_self, new () => {}>>;
49
+ declare var __VLS_5: any, __VLS_6: {};
50
+ type __VLS_Slots = __VLS_PrettifyGlobal<__VLS_OmitStringIndex<typeof __VLS_ctx.$slots> & {
51
+ [K in NonNullable<typeof __VLS_5>]?: (props: typeof __VLS_6) => any;
52
+ }>;
53
+ declare const __VLS_self: import("vue").DefineComponent<__VLS_Props, {
54
+ MenuItem: typeof MenuItem;
55
+ entries: typeof entries;
56
+ entryIconSlots: typeof entryIconSlots;
57
+ onClickOutside: typeof onClickOutside;
58
+ }, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
59
  error: (...args: any[]) => void;
13
60
  loading: (...args: any[]) => void;
14
61
  results: (...args: any[]) => void;
15
62
  "update:modelValue": (...args: any[]) => void;
16
63
  "click-outside": (...args: any[]) => void;
17
64
  response: (...args: any[]) => void;
18
- }, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
19
- modelValue?: MenuEntry[] | undefined;
20
- resource?: string | undefined;
21
- resourceData: LktObject;
65
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
66
+ onError?: ((...args: any[]) => any) | undefined;
67
+ onLoading?: ((...args: any[]) => any) | undefined;
68
+ onResults?: ((...args: any[]) => any) | undefined;
69
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
70
+ "onClick-outside"?: ((...args: any[]) => any) | undefined;
71
+ onResponse?: ((...args: any[]) => any) | undefined;
22
72
  }>, {
23
- modelValue: () => never[];
24
73
  resource: string;
25
- resourceData: () => {};
26
- }>>> & {
74
+ resourceData: LktObject;
75
+ modelValue: MenuEntry[];
76
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
77
+ declare const __VLS_component: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
78
+ error: (...args: any[]) => void;
79
+ loading: (...args: any[]) => void;
80
+ results: (...args: any[]) => void;
81
+ "update:modelValue": (...args: any[]) => void;
82
+ "click-outside": (...args: any[]) => void;
83
+ response: (...args: any[]) => void;
84
+ }, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
27
85
  onError?: ((...args: any[]) => any) | undefined;
28
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
29
86
  onLoading?: ((...args: any[]) => any) | undefined;
30
87
  onResults?: ((...args: any[]) => any) | undefined;
88
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
31
89
  "onClick-outside"?: ((...args: any[]) => any) | undefined;
32
90
  onResponse?: ((...args: any[]) => any) | undefined;
33
- }, {
91
+ }>, {
34
92
  resource: string;
35
- modelValue: MenuEntry[];
36
93
  resourceData: LktObject;
37
- }, {}>, Partial<Record<any, (_: {}) => any>>>;
94
+ modelValue: MenuEntry[];
95
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
96
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
38
97
  export default _default;
39
- type __VLS_NonUndefinedable<T> = T extends undefined ? never : T;
40
- type __VLS_TypePropsToRuntimeProps<T> = {
41
- [K in keyof T]-?: {} extends Pick<T, K> ? {
42
- type: import('vue').PropType<__VLS_NonUndefinedable<T[K]>>;
43
- } : {
44
- type: import('vue').PropType<T[K]>;
45
- required: true;
46
- };
47
- };
48
- type __VLS_WithDefaults<P, D> = {
49
- [K in keyof Pick<P, keyof P>]: K extends keyof D ? __VLS_Prettify<P[K] & {
50
- default: D[K];
51
- }> : P[K];
52
- };
53
- type __VLS_Prettify<T> = {
54
- [K in keyof T]: T[K];
55
- } & {};
56
- type __VLS_WithTemplateSlots<T, S> = T & {
98
+ type __VLS_WithSlots<T, S> = T & {
57
99
  new (): {
58
100
  $slots: S;
59
101
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-menu",
3
- "version": "1.0.10",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -18,11 +18,11 @@
18
18
  ".": {
19
19
  "import": "./dist/build.js"
20
20
  },
21
- "./styles": "./dist/style.css",
21
+ "./styles": "./dist/build.css",
22
22
  "./theme": "./theme/default.css",
23
23
  "./theme/default": "./theme/default.css"
24
24
  },
25
- "types": "./dist/index.d.ts",
25
+ "types": "./dist/build.d.ts",
26
26
  "files": [
27
27
  "dist/*",
28
28
  "src/**/*.vue",
@@ -31,34 +31,30 @@
31
31
  "license": "MIT",
32
32
  "sideEffects": false,
33
33
  "scripts": {
34
- "build": "rm -rf dist/*; vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/"
34
+ "build": "vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/",
35
+ "rebuild": "rm -rf dist/*; vue-tsc --declaration --emitDeclarationOnly; vite build; tsc --project tsconfig.build.json; cp build/* dist/"
35
36
  },
36
37
  "author": "Antonio Ibáñez",
38
+ "engines": {
39
+ "node": ">=18"
40
+ },
37
41
  "devDependencies": {
38
42
  "@babel/types": "^7.23.6",
39
43
  "@types/node": "^20.11.19",
40
44
  "@types/rollup": "^0.54.0",
41
45
  "@vitejs/plugin-vue": "^5.0.4",
42
- "rollup": "^4.9.6",
43
- "typescript": "^5.3.3",
44
- "vite": "^5.1.3",
46
+ "rollup": "^4.34.8",
47
+ "typescript": "^5.7.3",
48
+ "vite": "^6.1.1",
45
49
  "vue": "^3.3.0",
46
- "vue-tsc": "^1.8.27"
47
- },
48
- "engines": {
49
- "node": ">=18"
50
+ "vue-tsc": "^2.2.0"
50
51
  },
51
- "dependencies": {
52
+ "peerDependencies": {
52
53
  "lkt-anchor": "^1.1.4",
53
- "lkt-control-tools": "^1.0.3",
54
54
  "lkt-data-state": "^1.0.10",
55
- "lkt-events": "^1.0.2",
56
55
  "lkt-http-client": "^1.0.31",
57
56
  "lkt-i18n": "^1.0.4",
58
- "lkt-loader": "^1.0.1",
59
- "lkt-modal-confirm": "^1.0.0",
60
- "lkt-string-tools": "^1.0.1",
61
- "lkt-ts-interfaces": "^1.0.0",
57
+ "lkt-vue-kernel": "^1.0.0",
62
58
  "vue": "^3.3.0",
63
59
  "vue-router": "^4.3.3"
64
60
  }
@@ -1,13 +1,13 @@
1
1
  <script setup lang="ts">
2
- import {MenuEntry} from "../classes/MenuEntry";
3
- import {computed, onMounted, ref, useSlots, watch} from "vue";
4
- import {LktObject} from "lkt-ts-interfaces";
5
- import {fetchKeys} from "../functions/helpers";
6
- import {__} from "lkt-i18n";
7
- import {useRouter} from "vue-router";
8
- import {Settings} from "../settings/Settings";
2
+ import { MenuEntry } from '../classes/MenuEntry';
3
+ import { computed, onMounted, ref, useSlots, watch } from 'vue';
4
+ import { LktObject } from 'lkt-ts-interfaces';
5
+ import { fetchKeys } from '../functions/helpers';
6
+ import { useRouter } from 'vue-router';
7
+ import { Settings } from '../settings/Settings';
8
+ import { extractI18nValue } from 'lkt-vue-kernel';
9
9
 
10
- const emit = defineEmits(['update:modelValue']);
10
+ const emit = defineEmits(['update:modelValue']);
11
11
 
12
12
  const props = withDefaults(defineProps<{
13
13
  modelValue?: MenuEntry
@@ -60,10 +60,7 @@ const availableKeys = computed(() => {
60
60
  return r;
61
61
  }),
62
62
  computedLabel = computed(() => {
63
- if (entry.value.label.startsWith('__:')) {
64
- return __(entry.value.label.substring(3));
65
- }
66
- return entry.value.label;
63
+ return extractI18nValue(entry.value.label);
67
64
  }),
68
65
  computedIsActive = computed(() => {
69
66
  if (entry.value.isActive) return true;
@@ -93,17 +90,19 @@ watch(entry, (v) => {
93
90
  }, {deep: true});
94
91
 
95
92
  onMounted(() => {
96
- let currentRoute = router.currentRoute;
97
- if (currentRoute.value.path === entry.value.href) {
98
- entry.value.isOpened = true;
93
+ let currentRoute = router?.currentRoute;
94
+ if (currentRoute) {
95
+ if (currentRoute.value.path === entry.value.href) {
96
+ entry.value.isOpened = true;
99
97
 
100
- } else if (entry.value.children.length > 0) {
101
- let opened = false;
102
- entry.value.children.forEach((child) => {
103
- if (currentRoute.value.path === child.href) opened = true;
104
- });
98
+ } else if (entry.value.children.length > 0) {
99
+ let opened = false;
100
+ entry.value.children.forEach((child) => {
101
+ if (currentRoute.value.path === child.href) opened = true;
102
+ });
105
103
 
106
- if (opened) entry.value.isOpened = true;
104
+ if (opened) entry.value.isOpened = true;
105
+ }
107
106
  }
108
107
  });
109
108
  </script>
@@ -8,9 +8,9 @@ import {DataState} from "lkt-data-state";
8
8
  import {httpCall, HTTPResponse} from "lkt-http-client";
9
9
 
10
10
  const props = withDefaults(defineProps<{
11
- modelValue?: MenuEntry[],
11
+ modelValue?: MenuEntry[]
12
12
  resource?: string
13
- resourceData: LktObject,
13
+ resourceData: LktObject
14
14
  }>(), {
15
15
  modelValue: () => [],
16
16
  resource: '',
@@ -97,8 +97,4 @@ loadResource();
97
97
  </div>
98
98
  <div class="lkt-menu-outside" v-on:click="onClickOutside"/>
99
99
  </div>
100
- </template>
101
-
102
- <style scoped>
103
-
104
- </style>
100
+ </template>
File without changes