lkt-menu 1.0.7 → 1.0.9

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,4 +1,4 @@
1
- declare class D {
1
+ declare class x {
2
2
  constructor(t: any, s: any, d: any);
3
3
  key: any;
4
4
  href: any;
@@ -25,18 +25,18 @@ declare function he(n: any, t: any, s: any): {
25
25
  isOpened: boolean;
26
26
  isActive: boolean;
27
27
  children: any[];
28
- setChildren: (t: any) => D;
29
- setOnClick: (t: any) => D;
28
+ setChildren: (t: any) => x;
29
+ setOnClick: (t: any) => x;
30
30
  onClick: any;
31
- setIsActiveChecker: (t: any) => D;
31
+ setIsActiveChecker: (t: any) => x;
32
32
  isActiveChecker: any;
33
- setIsActive: (t?: boolean) => D;
34
- setLabel: (t: any) => D;
35
- setIcon: (t: any) => D;
33
+ setIsActive: (t?: boolean) => x;
34
+ setLabel: (t: any) => x;
35
+ setIcon: (t: any) => x;
36
36
  doClose: () => void;
37
37
  };
38
38
  declare namespace ve {
39
39
  function install(n: any): void;
40
40
  }
41
41
  declare function me(n: any): boolean;
42
- export { D as MenuEntry, he as createMenuEntry, ve as default, me as setMenuToggleSlot };
42
+ export { x as MenuEntry, he as createMenuEntry, ve as default, me as setMenuToggleSlot };
package/dist/build.js CHANGED
@@ -1,7 +1,7 @@
1
- import { defineComponent as K, ref as I, useSlots as N, computed as r, watch as C, onMounted as G, resolveComponent as B, openBlock as u, createElementBlock as a, normalizeClass as _, createElementVNode as V, createVNode as H, withCtx as $, unref as J, renderSlot as M, createCommentVNode as m, toDisplayString as P, createBlock as L, resolveDynamicComponent as Q, Fragment as T, renderList as b, createSlots as W, reactive as X } from "vue";
1
+ import { defineComponent as K, ref as M, useSlots as N, computed as r, watch as C, onMounted as G, resolveComponent as B, openBlock as u, createElementBlock as a, normalizeClass as g, createElementVNode as V, createVNode as H, withCtx as $, unref as J, renderSlot as L, createCommentVNode as m, toDisplayString as P, createBlock as w, resolveDynamicComponent as Q, Fragment as T, renderList as b, createSlots as W, reactive as X } from "vue";
2
2
  import { __ as Y } from "lkt-i18n";
3
3
  import { useRouter as Z } from "vue-router";
4
- class D {
4
+ class x {
5
5
  constructor(t, s, d) {
6
6
  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 = s, this.label = d;
7
7
  }
@@ -27,8 +27,8 @@ class D {
27
27
  this.isOpened = !1;
28
28
  }
29
29
  }
30
- const w = (n, t) => (t.forEach((s) => {
31
- n.includes(s.key) || n.push(s.key), s.children.length > 0 && w(n, s.children);
30
+ const R = (n, t) => (t.forEach((s) => {
31
+ n.includes(s.key) || n.push(s.key), s.children.length > 0 && R(n, s.children);
32
32
  }), n), A = class A {
33
33
  };
34
34
  A.toggleSlot = "", A.debugEnabled = !1;
@@ -45,23 +45,23 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
45
45
  }, ue = /* @__PURE__ */ K({
46
46
  __name: "MenuItem",
47
47
  props: {
48
- modelValue: { default: () => new D("", "", "") }
48
+ modelValue: { default: () => new x("", "", "") }
49
49
  },
50
50
  emits: ["update:modelValue"],
51
51
  setup(n, { emit: t }) {
52
- const s = t, d = n, e = I(d.modelValue), o = N(), O = Z(), p = I(!1), f = () => {
52
+ const s = t, d = n, e = M(d.modelValue), o = N(), O = Z(), p = M(!1), f = () => {
53
53
  e.value.isOpened = !e.value.isOpened;
54
54
  }, i = () => (e.value.children.length > 0 && f(), typeof e.value.onClick == "function" && e.value.onClick({
55
55
  entry: e.value
56
56
  }), 1), v = r(() => o["icon-" + e.value.key] || e.value.icon !== ""), S = r(() => {
57
57
  let l = [];
58
58
  return v.value && l.push("has-icon"), p.value && l.push("is-active"), l.join(" ");
59
- }), y = r(() => w([], e.value.children)), h = r(() => {
59
+ }), y = r(() => R([], e.value.children)), h = r(() => {
60
60
  let l = [];
61
61
  for (let c in o)
62
62
  c.startsWith("icon-") && y.value.includes(c.substring(5)) && l.push(c);
63
63
  return l;
64
- }), j = r(() => e.value.label.startsWith("__:") ? Y(e.value.label.substring(3)) : e.value.label), x = r(() => e.value.isActive ? !0 : typeof e.value.isActiveChecker == "function" ? !!e.value.isActiveChecker({
64
+ }), D = r(() => e.value.label.startsWith("__:") ? Y(e.value.label.substring(3)) : e.value.label), j = r(() => e.value.isActive ? !0 : typeof e.value.isActiveChecker == "function" ? !!e.value.isActiveChecker({
65
65
  entry: e.value
66
66
  }) : !1), z = r(() => !!k.toggleSlot), F = r(() => k.toggleSlot);
67
67
  return C(() => d.modelValue, (l) => {
@@ -81,27 +81,27 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
81
81
  }), (l, c) => {
82
82
  const E = B("lkt-anchor"), q = B("menu-item", !0);
83
83
  return u(), a("div", {
84
- class: _(["lkt-menu-entry", S.value])
84
+ class: g(["lkt-menu-entry", S.value])
85
85
  }, [
86
86
  V("div", ee, [
87
87
  H(E, {
88
88
  to: e.value.href,
89
89
  "on-click": i,
90
- "is-active": x.value,
91
- onActive: c[0] || (c[0] = (R) => p.value = l.$e)
90
+ "is-active": j.value,
91
+ onActive: c[0] || (c[0] = (U) => p.value = U)
92
92
  }, {
93
93
  default: $(() => [
94
94
  V("div", te, [
95
95
  v.value ? (u(), a("div", le, [
96
- J(o)["icon-" + e.value.key] ? M(l.$slots, "icon-" + e.value.key, {
96
+ J(o)["icon-" + e.value.key] ? L(l.$slots, "icon-" + e.value.key, {
97
97
  key: e.value.key,
98
98
  entry: e.value
99
99
  }) : e.value.icon !== "" ? (u(), a("i", {
100
100
  key: 1,
101
- class: _(e.value.icon)
101
+ class: g(e.value.icon)
102
102
  }, null, 2)) : m("", !0)
103
103
  ])) : m("", !0),
104
- e.value.label !== "" ? (u(), a("div", ne, P(j.value), 1)) : m("", !0)
104
+ e.value.label !== "" ? (u(), a("div", ne, P(D.value), 1)) : m("", !0)
105
105
  ])
106
106
  ]),
107
107
  _: 3
@@ -111,25 +111,25 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
111
111
  class: "lkt-menu-entry-toggle",
112
112
  onClick: f
113
113
  }, [
114
- z.value ? (u(), L(Q(F.value), {
114
+ z.value ? (u(), w(Q(F.value), {
115
115
  key: 0,
116
- class: _(["lkt-menu-entry-toggle-inner", e.value.isOpened ? "is-opened" : ""])
116
+ class: g(["lkt-menu-entry-toggle-inner", e.value.isOpened ? "is-opened" : ""])
117
117
  }, null, 8, ["class"])) : (u(), a("div", {
118
118
  key: 1,
119
- class: _(["lkt-menu-entry-toggle-inner lkt-menu-entry-toggle-triangle", e.value.isOpened ? "is-opened" : ""])
119
+ class: g(["lkt-menu-entry-toggle-inner lkt-menu-entry-toggle-triangle", e.value.isOpened ? "is-opened" : ""])
120
120
  }, null, 2))
121
121
  ])) : m("", !0)
122
122
  ]),
123
123
  e.value.isOpened ? (u(), a("div", se, [
124
- (u(!0), a(T, null, b(e.value.children, (R, U) => (u(), L(q, {
125
- modelValue: e.value.children[U],
126
- "onUpdate:modelValue": (g) => e.value.children[U] = g,
127
- key: R.key
124
+ (u(!0), a(T, null, b(e.value.children, (U, I) => (u(), w(q, {
125
+ modelValue: e.value.children[I],
126
+ "onUpdate:modelValue": (_) => e.value.children[I] = _,
127
+ key: e.value.children[I].key
128
128
  }, W({ _: 2 }, [
129
- b(h.value, (g) => ({
130
- name: g,
129
+ b(h.value, (_) => ({
130
+ name: _,
131
131
  fn: $(() => [
132
- M(l.$slots, g)
132
+ L(l.$slots, _)
133
133
  ])
134
134
  }))
135
135
  ]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
@@ -144,7 +144,7 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
144
144
  },
145
145
  emits: ["update:modelValue", "click-outside"],
146
146
  setup(n, { emit: t }) {
147
- const s = n, d = t, e = N(), o = I(s.modelValue), O = r(() => w([], o.value)), p = r(() => {
147
+ const s = n, d = t, e = N(), o = M(s.modelValue), O = r(() => R([], o.value)), p = r(() => {
148
148
  let i = [];
149
149
  for (let v in e)
150
150
  v.startsWith("icon-") && O.value.includes(v.substring(5)) && i.push(v);
@@ -158,7 +158,7 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
158
158
  d("update:modelValue", i);
159
159
  }, { deep: !0 }), (i, v) => (u(), a("div", ie, [
160
160
  V("div", oe, [
161
- (u(!0), a(T, null, b(o.value, (S, y) => (u(), L(ue, {
161
+ (u(!0), a(T, null, b(o.value, (S, y) => (u(), w(ue, {
162
162
  modelValue: o.value[y],
163
163
  "onUpdate:modelValue": (h) => o.value[y] = h,
164
164
  key: S.key
@@ -166,7 +166,7 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
166
166
  b(p.value, (h) => ({
167
167
  name: h,
168
168
  fn: $(() => [
169
- M(i.$slots, h)
169
+ L(i.$slots, h)
170
170
  ])
171
171
  }))
172
172
  ]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
@@ -181,9 +181,9 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
181
181
  install: (n) => {
182
182
  n.component("lkt-menu") === void 0 && n.component("lkt-menu", re);
183
183
  }
184
- }, he = (n, t, s) => X(new D(n, t, s)), me = (n) => (k.toggleSlot = n, !0);
184
+ }, he = (n, t, s) => X(new x(n, t, s)), me = (n) => (k.toggleSlot = n, !0);
185
185
  export {
186
- D as MenuEntry,
186
+ x as MenuEntry,
187
187
  he as createMenuEntry,
188
188
  ve as default,
189
189
  me as setMenuToggleSlot
@@ -1,4 +1,5 @@
1
+ import { Component } from "vue";
1
2
  export declare class Settings {
2
- static toggleSlot: string;
3
+ static toggleSlot: string | Component;
3
4
  static debugEnabled: boolean;
4
5
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-menu",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -90,6 +90,7 @@ const availableKeys = computed(() => {
90
90
  watch(() => props.modelValue, (v) => {
91
91
  entry.value = v
92
92
  }, {deep: true});
93
+
93
94
  watch(entry, (v) => {
94
95
  emit('update:modelValue', v)
95
96
  }, {deep: true});
@@ -98,6 +99,7 @@ onMounted(() => {
98
99
  let currentRoute = router.currentRoute;
99
100
  if (currentRoute.value.path === entry.value.href) {
100
101
  entry.value.isOpened = true;
102
+
101
103
  } else if (entry.value.children.length > 0) {
102
104
  let opened = false;
103
105
  entry.value.children.forEach((child) => {
@@ -106,7 +108,7 @@ onMounted(() => {
106
108
 
107
109
  if (opened) entry.value.isOpened = true;
108
110
  }
109
- })
111
+ });
110
112
  </script>
111
113
 
112
114
  <template>
@@ -116,7 +118,7 @@ onMounted(() => {
116
118
  :to="entry.href"
117
119
  :on-click="onClick"
118
120
  :is-active="computedIsActive"
119
- @active="isActive = $e"
121
+ @active="($e: any) => isActive = $e"
120
122
  >
121
123
  <div class="lkt-entry-content">
122
124
  <div class="lkt-menu-entry-icon" v-if="canRenderIcon">
@@ -143,15 +145,11 @@ onMounted(() => {
143
145
  </div>
144
146
  </div>
145
147
  <div class="lkt-menu-entry-children" v-if="entry.isOpened">
146
- <menu-item v-for="(child, i) in entry.children" v-model="entry.children[i]" :key="child.key">
148
+ <menu-item v-for="(_, i) in entry.children" v-model="entry.children[i]" :key="entry.children[i].key">
147
149
  <template v-for="slot in entryIconSlots" v-slot:[slot]>
148
150
  <slot :name="slot"/>
149
151
  </template>
150
152
  </menu-item>
151
153
  </div>
152
154
  </div>
153
- </template>
154
-
155
- <style scoped>
156
-
157
- </style>
155
+ </template>