lkt-menu 1.0.10 → 1.0.11

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
1
  declare class x {
2
- constructor(t: any, n: any, i: any);
2
+ constructor(t: any, r: any, i: any);
3
3
  key: any;
4
4
  href: any;
5
5
  label: any;
@@ -17,7 +17,7 @@ declare class x {
17
17
  setIcon(t: any): this;
18
18
  doClose(): void;
19
19
  }
20
- declare function ke(o: any, t: any, n: any): {
20
+ declare function ke(o: any, t: any, r: any): {
21
21
  key: any;
22
22
  href: any;
23
23
  label: any;
package/dist/build.js CHANGED
@@ -1,14 +1,14 @@
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";
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
2
  import { __ as Y } from "lkt-i18n";
3
3
  import { useRouter as Z } from "vue-router";
4
4
  import { DataState as ee } from "lkt-data-state";
5
5
  import { httpCall as te } from "lkt-http-client";
6
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
+ 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;
9
9
  }
10
10
  setChildren(t) {
11
- return t.forEach((n) => n.parent = this), this.children = t, this;
11
+ return t.forEach((r) => r.parent = this), this.children = t, this;
12
12
  }
13
13
  setOnClick(t) {
14
14
  return this.onClick = t, this;
@@ -29,12 +29,12 @@ class x {
29
29
  this.isOpened = !1;
30
30
  }
31
31
  }
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 {
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 {
35
35
  };
36
- A.toggleSlot = "", A.debugEnabled = !1;
37
- let k = A;
36
+ I.toggleSlot = "", I.debugEnabled = !1;
37
+ let y = I;
38
38
  const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }, re = {
39
39
  key: 0,
40
40
  class: "lkt-menu-entry-icon"
@@ -51,59 +51,61 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
51
51
  },
52
52
  emits: ["update:modelValue"],
53
53
  setup(o, { emit: t }) {
54
- const n = t, i = o, e = $(i.modelValue), a = K(), I = Z(), m = $(!1), y = () => {
54
+ const r = t, i = o, e = $(i.modelValue), a = K(), f = Z(), m = $(!1), g = () => {
55
55
  e.value.isOpened = !e.value.isOpened;
56
- }, E = () => (e.value.children.length > 0 && y(), typeof e.value.onClick == "function" && e.value.onClick({
56
+ }, E = () => (e.value.children.length > 0 && g(), typeof e.value.onClick == "function" && e.value.onClick({
57
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(" ");
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
61
  }), s = c(() => j([], e.value.children)), l = c(() => {
62
- let r = [];
62
+ let n = [];
63
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({
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
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);
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
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);
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) {
79
+ let v = !1;
80
+ e.value.children.forEach((M) => {
81
+ n.value.path === M.href && (v = !0);
82
+ }), v && (e.value.isOpened = !0);
83
+ }
82
84
  }
83
- }), (r, v) => {
85
+ }), (n, v) => {
84
86
  const M = B("lkt-anchor"), z = B("menu-item", !0);
85
87
  return u(), d("div", {
86
- class: V(["lkt-menu-entry", D.value])
88
+ class: b(["lkt-menu-entry", D.value])
87
89
  }, [
88
- O("div", le, [
90
+ S("div", le, [
89
91
  G(M, {
90
92
  to: e.value.href,
91
93
  "on-click": E,
92
- "is-active": _.value,
94
+ "is-active": C.value,
93
95
  onActive: v[0] || (v[0] = (U) => m.value = U)
94
96
  }, {
95
97
  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, {
98
+ S("div", ne, [
99
+ _.value ? (u(), d("div", re, [
100
+ H(a)["icon-" + e.value.key] ? L(n.$slots, "icon-" + e.value.key, {
99
101
  key: e.value.key,
100
102
  entry: e.value
101
103
  }) : e.value.icon !== "" ? (u(), d("i", {
102
104
  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)
105
+ class: b(e.value.icon)
106
+ }, null, 2)) : k("", !0)
107
+ ])) : k("", !0),
108
+ e.value.label !== "" ? (u(), d("div", se, P(h.value), 1)) : k("", !0)
107
109
  ])
108
110
  ]),
109
111
  _: 3
@@ -111,31 +113,31 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
111
113
  e.value.children.length > 0 ? (u(), d("div", {
112
114
  key: 0,
113
115
  class: "lkt-menu-entry-toggle",
114
- onClick: y
116
+ onClick: g
115
117
  }, [
116
118
  p.value ? (u(), R(Q(F.value), {
117
119
  key: 0,
118
- class: V(["lkt-menu-entry-toggle-inner", e.value.isOpened ? "is-opened" : ""])
120
+ class: b(["lkt-menu-entry-toggle-inner", e.value.isOpened ? "is-opened" : ""])
119
121
  }, null, 8, ["class"])) : (u(), d("div", {
120
122
  key: 1,
121
- class: V(["lkt-menu-entry-toggle-inner lkt-menu-entry-toggle-triangle", e.value.isOpened ? "is-opened" : ""])
123
+ class: b(["lkt-menu-entry-toggle-inner lkt-menu-entry-toggle-triangle", e.value.isOpened ? "is-opened" : ""])
122
124
  }, null, 2))
123
- ])) : f("", !0)
125
+ ])) : k("", !0)
124
126
  ]),
125
127
  e.value.isOpened ? (u(), d("div", oe, [
126
- (u(!0), d(T, null, S(e.value.children, (U, N) => (u(), R(z, {
128
+ (u(!0), d(T, null, A(e.value.children, (U, N) => (u(), R(z, {
127
129
  modelValue: e.value.children[N],
128
- "onUpdate:modelValue": (C) => e.value.children[N] = C,
130
+ "onUpdate:modelValue": (V) => e.value.children[N] = V,
129
131
  key: e.value.children[N].key
130
132
  }, W({ _: 2 }, [
131
- S(l.value, (C) => ({
132
- name: C,
133
+ A(l.value, (V) => ({
134
+ name: V,
133
135
  fn: w(() => [
134
- L(r.$slots, C)
136
+ L(n.$slots, V)
135
137
  ])
136
138
  }))
137
139
  ]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
138
- ])) : f("", !0)
140
+ ])) : k("", !0)
139
141
  ], 2);
140
142
  };
141
143
  }
@@ -148,7 +150,7 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
148
150
  },
149
151
  emits: ["update:modelValue", "click-outside", "loading", "results", "response", "error"],
150
152
  setup(o, { emit: t }) {
151
- const n = o, i = t, e = K(), a = $(n.modelValue), I = (s) => {
153
+ const r = o, i = t, e = K(), a = $(r.modelValue), f = (s) => {
152
154
  let l = {};
153
155
  typeof s == "object" && Object.keys(s).length > 0 && (l = JSON.parse(JSON.stringify(s)));
154
156
  for (let h in l)
@@ -156,17 +158,16 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
156
158
  return l;
157
159
  };
158
160
  let m = new ee({});
159
- m.increment(I(n.resourceData));
160
- const y = c(() => j([], a.value)), E = c(() => {
161
+ m.increment(f(r.resourceData));
162
+ const g = c(() => j([], a.value)), E = c(() => {
161
163
  let s = [];
162
164
  for (let l in e)
163
- l.startsWith("icon-") && y.value.includes(l.substring(5)) && s.push(l);
165
+ l.startsWith("icon-") && g.value.includes(l.substring(5)) && s.push(l);
164
166
  return s;
165
- }), g = () => {
166
- if (!n.resource)
167
- return;
167
+ }), _ = () => {
168
+ if (!r.resource) return;
168
169
  let s = m.getData();
169
- i("loading"), te(n.resource, s).then((l) => {
170
+ i("loading"), te(r.resource, s).then((l) => {
170
171
  m.turnStoredIntoOriginal(), a.value = l.data, i("results", l.data), i("response", l);
171
172
  }).catch((l) => {
172
173
  i("error", l);
@@ -174,18 +175,18 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
174
175
  }, D = () => {
175
176
  i("click-outside");
176
177
  };
177
- return b(() => n.modelValue, (s) => {
178
+ return O(() => r.modelValue, (s) => {
178
179
  a.value = s;
179
- }, { deep: !0 }), b(a, (s) => {
180
+ }, { deep: !0 }), O(a, (s) => {
180
181
  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,
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,
186
187
  key: h.key
187
188
  }, W({ _: 2 }, [
188
- S(E.value, (p) => ({
189
+ A(E.value, (p) => ({
189
190
  name: p,
190
191
  fn: w(() => [
191
192
  L(s.$slots, p)
@@ -193,7 +194,7 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
193
194
  }))
194
195
  ]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
195
196
  ]),
196
- O("div", {
197
+ S("div", {
197
198
  class: "lkt-menu-outside",
198
199
  onClick: D
199
200
  })
@@ -203,7 +204,7 @@ const le = { class: "lkt-menu-entry-main" }, ne = { class: "lkt-entry-content" }
203
204
  install: (o) => {
204
205
  o.component("lkt-menu") === void 0 && o.component("lkt-menu", ce);
205
206
  }
206
- }, ke = (o, t, n) => X(new x(o, t, n)), ye = (o) => (k.toggleSlot = o, !0);
207
+ }, ke = (o, t, r) => X(new x(o, t, r)), ye = (o) => (y.toggleSlot = o, !0);
207
208
  export {
208
209
  x as MenuEntry,
209
210
  ke as createMenuEntry,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lkt-menu",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "",
5
5
  "keywords": [
6
6
  "lkt",
@@ -22,7 +22,7 @@
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",
@@ -93,17 +93,19 @@ watch(entry, (v) => {
93
93
  }, {deep: true});
94
94
 
95
95
  onMounted(() => {
96
- let currentRoute = router.currentRoute;
97
- if (currentRoute.value.path === entry.value.href) {
98
- entry.value.isOpened = true;
96
+ let currentRoute = router?.currentRoute;
97
+ if (currentRoute) {
98
+ if (currentRoute.value.path === entry.value.href) {
99
+ entry.value.isOpened = true;
99
100
 
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
- });
101
+ } else if (entry.value.children.length > 0) {
102
+ let opened = false;
103
+ entry.value.children.forEach((child) => {
104
+ if (currentRoute.value.path === child.href) opened = true;
105
+ });
105
106
 
106
- if (opened) entry.value.isOpened = true;
107
+ if (opened) entry.value.isOpened = true;
108
+ }
107
109
  }
108
110
  });
109
111
  </script>
@@ -1,20 +0,0 @@
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
- }
@@ -1,60 +0,0 @@
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, (_: {
17
- key: string;
18
- entry: {
19
- key: string;
20
- href: string;
21
- label: string;
22
- icon: string;
23
- onClick: Function | undefined;
24
- isActiveChecker: Function | undefined;
25
- isOpened: boolean;
26
- isActive: boolean;
27
- parent: any | undefined;
28
- children: any[];
29
- setChildren: (children: MenuEntry[]) => MenuEntry;
30
- setOnClick: (fn: Function) => MenuEntry;
31
- setIsActiveChecker: (fn: Function) => MenuEntry;
32
- setIsActive: (enabled?: boolean) => MenuEntry;
33
- setLabel: (str: string) => MenuEntry;
34
- setIcon: (str: string) => MenuEntry;
35
- doClose: () => void;
36
- };
37
- }) => any>> & Partial<Record<any, (_: {}) => any>>>;
38
- 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 & {
57
- new (): {
58
- $slots: S;
59
- };
60
- };
@@ -1,2 +0,0 @@
1
- import { MenuEntry } from "../classes/MenuEntry";
2
- export declare const fetchKeys: (r: string[], entries: MenuEntry[]) => string[];
package/dist/index.d.ts DELETED
@@ -1,8 +0,0 @@
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 };
@@ -1,60 +0,0 @@
1
- import { MenuEntry } from "../classes/MenuEntry";
2
- 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;
6
- resourceData: LktObject;
7
- }>, {
8
- modelValue: () => never[];
9
- resource: string;
10
- resourceData: () => {};
11
- }>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
12
- error: (...args: any[]) => void;
13
- loading: (...args: any[]) => void;
14
- results: (...args: any[]) => void;
15
- "update:modelValue": (...args: any[]) => void;
16
- "click-outside": (...args: any[]) => void;
17
- 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;
22
- }>, {
23
- modelValue: () => never[];
24
- resource: string;
25
- resourceData: () => {};
26
- }>>> & {
27
- onError?: ((...args: any[]) => any) | undefined;
28
- "onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
29
- onLoading?: ((...args: any[]) => any) | undefined;
30
- onResults?: ((...args: any[]) => any) | undefined;
31
- "onClick-outside"?: ((...args: any[]) => any) | undefined;
32
- onResponse?: ((...args: any[]) => any) | undefined;
33
- }, {
34
- resource: string;
35
- modelValue: MenuEntry[];
36
- resourceData: LktObject;
37
- }, {}>, Partial<Record<any, (_: {}) => any>>>;
38
- 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 & {
57
- new (): {
58
- $slots: S;
59
- };
60
- };
@@ -1,5 +0,0 @@
1
- import { Component } from "vue";
2
- export declare class Settings {
3
- static toggleSlot: string | Component;
4
- static debugEnabled: boolean;
5
- }