lkt-menu 1.0.11 → 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, r: 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, r: 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, r: 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,139 +1,144 @@
1
- import { defineComponent as J, ref as $, useSlots as K, computed as c, watch as O, onMounted as q, resolveComponent as B, openBlock as u, createElementBlock as d, normalizeClass as b, createElementVNode as S, createVNode as G, withCtx as w, unref as H, renderSlot as L, createCommentVNode as k, toDisplayString as P, createBlock as R, resolveDynamicComponent as Q, Fragment as T, renderList as A, 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, r, 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 = r, 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((r) => r.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((r) => {
33
- o.includes(r.key) || o.push(r.key), r.children.length > 0 && j(o, r.children);
34
- }), o), I = class I {
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
- I.toggleSlot = "", I.debugEnabled = !1;
37
- let y = I;
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 r = t, i = o, e = $(i.modelValue), a = K(), f = Z(), m = $(!1), g = () => {
55
- e.value.isOpened = !e.value.isOpened;
56
- }, E = () => (e.value.children.length > 0 && g(), typeof e.value.onClick == "function" && e.value.onClick({
57
- entry: e.value
58
- }), 1), _ = c(() => a["icon-" + e.value.key] || e.value.icon !== ""), D = c(() => {
59
- let n = [];
60
- return _.value && n.push("has-icon"), m.value && n.push("is-active"), n.join(" ");
61
- }), s = c(() => j([], e.value.children)), l = c(() => {
62
- let n = [];
63
- for (let v in a)
64
- v.startsWith("icon-") && s.value.includes(v.substring(5)) && n.push(v);
65
- return n;
66
- }), h = c(() => e.value.label.startsWith("__:") ? Y(e.value.label.substring(3)) : e.value.label), C = c(() => e.value.isActive ? !0 : typeof e.value.isActiveChecker == "function" ? !!e.value.isActiveChecker({
67
- entry: e.value
68
- }) : !1), p = c(() => !!y.toggleSlot), F = c(() => y.toggleSlot);
69
- return O(() => i.modelValue, (n) => {
70
- e.value = n;
71
- }, { deep: !0 }), O(e, (n) => {
72
- r("update:modelValue", n);
73
- }, { deep: !0 }), q(() => {
74
- let n = f == null ? void 0 : f.currentRoute;
75
- if (n) {
76
- if (n.value.path === e.value.href)
77
- e.value.isOpened = !0;
78
- else if (e.value.children.length > 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) {
79
84
  let v = !1;
80
- e.value.children.forEach((M) => {
81
- n.value.path === M.href && (v = !0);
82
- }), v && (e.value.isOpened = !0);
85
+ t.value.children.forEach((L) => {
86
+ l.value.path === L.href && (v = !0);
87
+ }), v && (t.value.isOpened = !0);
83
88
  }
84
89
  }
85
- }), (n, v) => {
86
- const M = B("lkt-anchor"), z = B("menu-item", !0);
87
- return u(), d("div", {
88
- class: b(["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])
89
94
  }, [
90
- S("div", le, [
91
- G(M, {
92
- to: e.value.href,
93
- "on-click": E,
94
- "is-active": C.value,
95
- 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)
96
101
  }, {
97
- default: w(() => [
98
- S("div", ne, [
99
- _.value ? (u(), d("div", re, [
100
- H(a)["icon-" + e.value.key] ? L(n.$slots, "icon-" + e.value.key, {
101
- key: e.value.key,
102
- entry: e.value
103
- }) : 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", {
104
109
  key: 1,
105
- class: b(e.value.icon)
110
+ class: S(t.value.icon)
106
111
  }, null, 2)) : k("", !0)
107
112
  ])) : k("", !0),
108
- e.value.label !== "" ? (u(), d("div", se, P(h.value), 1)) : k("", !0)
113
+ t.value.label !== "" ? (i(), d("div", ze, G(m.value), 1)) : k("", !0)
109
114
  ])
110
115
  ]),
111
116
  _: 3
112
117
  }, 8, ["to", "is-active"]),
113
- e.value.children.length > 0 ? (u(), d("div", {
118
+ t.value.children.length > 0 ? (i(), d("div", {
114
119
  key: 0,
115
120
  class: "lkt-menu-entry-toggle",
116
121
  onClick: g
117
122
  }, [
118
- p.value ? (u(), R(Q(F.value), {
123
+ p.value ? (i(), R(Q(j.value), {
119
124
  key: 0,
120
- class: b(["lkt-menu-entry-toggle-inner", e.value.isOpened ? "is-opened" : ""])
121
- }, 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", {
122
127
  key: 1,
123
- class: b(["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" : ""])
124
129
  }, null, 2))
125
130
  ])) : k("", !0)
126
131
  ]),
127
- e.value.isOpened ? (u(), d("div", oe, [
128
- (u(!0), d(T, null, A(e.value.children, (U, N) => (u(), R(z, {
129
- modelValue: e.value.children[N],
130
- "onUpdate:modelValue": (V) => e.value.children[N] = V,
131
- key: e.value.children[N].key
132
- }, W({ _: 2 }, [
133
- A(l.value, (V) => ({
134
- name: V,
135
- fn: w(() => [
136
- L(n.$slots, V)
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, _)
137
142
  ])
138
143
  }))
139
144
  ]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
@@ -141,7 +146,7 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
141
146
  ], 2);
142
147
  };
143
148
  }
144
- }), 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({
145
150
  __name: "LktMenu",
146
151
  props: {
147
152
  modelValue: { default: () => [] },
@@ -149,65 +154,65 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
149
154
  resourceData: { default: () => ({}) }
150
155
  },
151
156
  emits: ["update:modelValue", "click-outside", "loading", "results", "response", "error"],
152
- setup(o, { emit: t }) {
153
- const r = o, i = t, e = K(), a = $(r.modelValue), f = (s) => {
154
- let l = {};
155
- typeof s == "object" && Object.keys(s).length > 0 && (l = JSON.parse(JSON.stringify(s)));
156
- for (let h in l)
157
- (Array.isArray(l[h]) || typeof l[h] == "object") && (l[h] = JSON.stringify(l[h]));
158
- 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;
159
164
  };
160
- let m = new ee({});
161
- m.increment(f(r.resourceData));
162
- const g = c(() => j([], a.value)), E = c(() => {
163
- let s = [];
164
- for (let l in e)
165
- l.startsWith("icon-") && g.value.includes(l.substring(5)) && s.push(l);
166
- return s;
167
- }), _ = () => {
168
- if (!r.resource) return;
169
- let s = m.getData();
170
- i("loading"), te(r.resource, s).then((l) => {
171
- m.turnStoredIntoOriginal(), a.value = l.data, i("results", l.data), i("response", l);
172
- }).catch((l) => {
173
- 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);
174
179
  });
175
- }, D = () => {
176
- i("click-outside");
180
+ }, E = () => {
181
+ s("click-outside");
177
182
  };
178
- return O(() => r.modelValue, (s) => {
179
- a.value = s;
180
- }, { deep: !0 }), O(a, (s) => {
181
- i("update:modelValue", s);
182
- }, { deep: !0 }), _(), (s, l) => (u(), d("div", ie, [
183
- S("div", ae, [
184
- (u(!0), d(T, null, A(a.value, (h, C) => (u(), R(ue, {
185
- modelValue: a.value[C],
186
- "onUpdate:modelValue": (p) => a.value[C] = p,
187
- key: h.key
188
- }, W({ _: 2 }, [
189
- A(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) => ({
190
195
  name: p,
191
- fn: w(() => [
192
- L(s.$slots, p)
196
+ fn: V(() => [
197
+ D(o.$slots, p)
193
198
  ])
194
199
  }))
195
200
  ]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
196
201
  ]),
197
- S("div", {
202
+ A("div", {
198
203
  class: "lkt-menu-outside",
199
- onClick: D
204
+ onClick: E
200
205
  })
201
206
  ]));
202
207
  }
203
- }), fe = {
204
- install: (o) => {
205
- 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);
206
211
  }
207
- }, ke = (o, t, r) => X(new x(o, t, r)), ye = (o) => (y.toggleSlot = o, !0);
212
+ }, Xe = (e, r, a) => X(new H(e, r, a)), Ye = (e) => (y.toggleSlot = e, !0);
208
213
  export {
209
- x as MenuEntry,
210
- ke as createMenuEntry,
211
- fe as default,
212
- ye as setMenuToggleSlot
214
+ H as MenuEntry,
215
+ Xe as createMenuEntry,
216
+ Qe as default,
217
+ Ye as setMenuToggleSlot
213
218
  };
@@ -0,0 +1,20 @@
1
+ export declare class MenuEntry {
2
+ key: string;
3
+ href: string;
4
+ label: string;
5
+ icon: string;
6
+ onClick: Function | undefined;
7
+ isActiveChecker: Function | undefined;
8
+ isOpened: boolean;
9
+ isActive: boolean;
10
+ parent: MenuEntry | undefined;
11
+ children: MenuEntry[];
12
+ constructor(key: string, href: string, label: string);
13
+ setChildren(children: MenuEntry[]): this;
14
+ setOnClick(fn: Function): this;
15
+ setIsActiveChecker(fn: Function): this;
16
+ setIsActive(enabled?: boolean): this;
17
+ setLabel(str: string): this;
18
+ setIcon(str: string): this;
19
+ doClose(): void;
20
+ }
@@ -0,0 +1,109 @@
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: {
50
+ key: string;
51
+ entry: {
52
+ key: string;
53
+ href: string;
54
+ label: string;
55
+ icon: string;
56
+ onClick: Function | undefined;
57
+ isActiveChecker: Function | undefined;
58
+ isOpened: boolean;
59
+ isActive: boolean;
60
+ parent: /*elided*/ any | undefined;
61
+ children: /*elided*/ any[];
62
+ setChildren: (children: MenuEntry[]) => MenuEntry;
63
+ setOnClick: (fn: Function) => MenuEntry;
64
+ setIsActiveChecker: (fn: Function) => MenuEntry;
65
+ setIsActive: (enabled?: boolean) => MenuEntry;
66
+ setLabel: (str: string) => MenuEntry;
67
+ setIcon: (str: string) => MenuEntry;
68
+ doClose: () => void;
69
+ };
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>;
104
+ export default _default;
105
+ type __VLS_WithSlots<T, S> = T & {
106
+ new (): {
107
+ $slots: S;
108
+ };
109
+ };
@@ -0,0 +1,2 @@
1
+ import { MenuEntry } from "../classes/MenuEntry";
2
+ export declare const fetchKeys: (r: string[], entries: MenuEntry[]) => string[];
@@ -0,0 +1,8 @@
1
+ import { Component, Plugin } from 'vue';
2
+ import "../style.css";
3
+ import { MenuEntry } from "./classes/MenuEntry";
4
+ declare const LktMenu: Plugin;
5
+ export default LktMenu;
6
+ export declare const createMenuEntry: (key: string, href: string, label: string) => MenuEntry;
7
+ export declare const setMenuToggleSlot: (component: string | Component) => boolean;
8
+ export { MenuEntry };
@@ -0,0 +1,102 @@
1
+ import { MenuEntry } from "../classes/MenuEntry";
2
+ import MenuItem from "../components/MenuItem.vue";
3
+ import { LktObject } from "lkt-ts-interfaces";
4
+ type __VLS_Props = {
5
+ modelValue?: MenuEntry[];
6
+ resource?: string;
7
+ resourceData: LktObject;
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, {
59
+ error: (...args: any[]) => void;
60
+ loading: (...args: any[]) => void;
61
+ results: (...args: any[]) => void;
62
+ "update:modelValue": (...args: any[]) => void;
63
+ "click-outside": (...args: any[]) => void;
64
+ response: (...args: any[]) => void;
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;
72
+ }>, {
73
+ resource: string;
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<{
85
+ onError?: ((...args: any[]) => any) | undefined;
86
+ onLoading?: ((...args: any[]) => any) | undefined;
87
+ onResults?: ((...args: any[]) => any) | undefined;
88
+ "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
89
+ "onClick-outside"?: ((...args: any[]) => any) | undefined;
90
+ onResponse?: ((...args: any[]) => any) | undefined;
91
+ }>, {
92
+ resource: string;
93
+ resourceData: LktObject;
94
+ modelValue: MenuEntry[];
95
+ }, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
96
+ declare const _default: __VLS_WithSlots<typeof __VLS_component, __VLS_Slots>;
97
+ export default _default;
98
+ type __VLS_WithSlots<T, S> = T & {
99
+ new (): {
100
+ $slots: S;
101
+ };
102
+ };
@@ -0,0 +1,5 @@
1
+ import { Component } from "vue";
2
+ export declare class Settings {
3
+ static toggleSlot: string | Component;
4
+ static debugEnabled: boolean;
5
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-menu",
3
- "version": "1.0.11",
3
+ "version": "1.2.0",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -18,7 +18,7 @@
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
  },
@@ -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;
@@ -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