lkt-menu 1.0.4 → 1.0.6
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 +22 -22
- package/dist/build.js +81 -79
- package/dist/index.d.ts +1 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/MenuItem.vue +4 -0
- package/theme/default.css +1 -0
package/dist/build.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
declare
|
|
1
|
+
declare class W {
|
|
2
|
+
constructor(t: any, s: any, d: any);
|
|
2
3
|
key: any;
|
|
3
4
|
href: any;
|
|
4
5
|
label: any;
|
|
@@ -6,22 +7,17 @@ declare function he(n: any, t: any, s: any): {
|
|
|
6
7
|
isOpened: boolean;
|
|
7
8
|
isActive: boolean;
|
|
8
9
|
children: any[];
|
|
9
|
-
setChildren
|
|
10
|
-
setOnClick
|
|
10
|
+
setChildren(t: any): this;
|
|
11
|
+
setOnClick(t: any): this;
|
|
11
12
|
onClick: any;
|
|
12
|
-
setIsActiveChecker
|
|
13
|
+
setIsActiveChecker(t: any): this;
|
|
13
14
|
isActiveChecker: any;
|
|
14
|
-
setIsActive
|
|
15
|
-
setLabel
|
|
16
|
-
setIcon
|
|
17
|
-
doClose
|
|
18
|
-
};
|
|
19
|
-
declare namespace ve {
|
|
20
|
-
function install(n: any): void;
|
|
15
|
+
setIsActive(t?: boolean): this;
|
|
16
|
+
setLabel(t: any): this;
|
|
17
|
+
setIcon(t: any): this;
|
|
18
|
+
doClose(): void;
|
|
21
19
|
}
|
|
22
|
-
declare function me(n: any):
|
|
23
|
-
declare class T {
|
|
24
|
-
constructor(t: any, s: any, v: any);
|
|
20
|
+
declare function me(n: any, t: any, s: any): {
|
|
25
21
|
key: any;
|
|
26
22
|
href: any;
|
|
27
23
|
label: any;
|
|
@@ -29,14 +25,18 @@ declare class T {
|
|
|
29
25
|
isOpened: boolean;
|
|
30
26
|
isActive: boolean;
|
|
31
27
|
children: any[];
|
|
32
|
-
setChildren(t: any)
|
|
33
|
-
setOnClick(t: any)
|
|
28
|
+
setChildren: (t: any) => W;
|
|
29
|
+
setOnClick: (t: any) => W;
|
|
34
30
|
onClick: any;
|
|
35
|
-
setIsActiveChecker(t: any)
|
|
31
|
+
setIsActiveChecker: (t: any) => W;
|
|
36
32
|
isActiveChecker: any;
|
|
37
|
-
setIsActive(t?: boolean)
|
|
38
|
-
setLabel(t: any)
|
|
39
|
-
setIcon(t: any)
|
|
40
|
-
doClose()
|
|
33
|
+
setIsActive: (t?: boolean) => W;
|
|
34
|
+
setLabel: (t: any) => W;
|
|
35
|
+
setIcon: (t: any) => W;
|
|
36
|
+
doClose: () => void;
|
|
37
|
+
};
|
|
38
|
+
declare namespace he {
|
|
39
|
+
function install(n: any): void;
|
|
41
40
|
}
|
|
42
|
-
|
|
41
|
+
declare function pe(n: any): boolean;
|
|
42
|
+
export { W as MenuEntry, me as createMenuEntry, he as default, pe as setMenuToggleSlot };
|
package/dist/build.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { defineComponent as
|
|
2
|
-
import { __ as
|
|
3
|
-
import { useRouter as
|
|
4
|
-
class
|
|
5
|
-
constructor(t, s,
|
|
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 =
|
|
1
|
+
import { defineComponent as B, ref as $, useSlots as K, computed as r, watch as C, onMounted as G, resolveComponent as U, openBlock as u, createElementBlock as a, normalizeClass as g, createElementVNode as V, createVNode as H, withCtx as E, unref as J, renderSlot as I, createCommentVNode as m, toDisplayString as P, createBlock as M, resolveDynamicComponent as Q, Fragment as N, renderList as b, createSlots as T, reactive as X } from "vue";
|
|
2
|
+
import { __ as Y } from "lkt-i18n";
|
|
3
|
+
import { useRouter as Z } from "vue-router";
|
|
4
|
+
class W {
|
|
5
|
+
constructor(t, s, d) {
|
|
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
|
}
|
|
8
8
|
setChildren(t) {
|
|
9
9
|
return t.forEach((s) => s.parent = this), this.children = t, this;
|
|
@@ -27,80 +27,81 @@ class T {
|
|
|
27
27
|
this.isOpened = !1;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
n.includes(s.key) || n.push(s.key), s.children.length > 0 &&
|
|
32
|
-
}), n),
|
|
30
|
+
const L = (n, t) => (t.forEach((s) => {
|
|
31
|
+
n.includes(s.key) || n.push(s.key), s.children.length > 0 && L(n, s.children);
|
|
32
|
+
}), n), A = class A {
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
let
|
|
36
|
-
const
|
|
34
|
+
A.toggleSlot = "", A.debugEnabled = !1;
|
|
35
|
+
let p = A;
|
|
36
|
+
const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }, le = {
|
|
37
37
|
key: 0,
|
|
38
38
|
class: "lkt-menu-entry-icon"
|
|
39
|
-
},
|
|
39
|
+
}, ne = {
|
|
40
40
|
key: 1,
|
|
41
41
|
class: "lkt-menu-entry-text"
|
|
42
|
-
},
|
|
42
|
+
}, se = {
|
|
43
43
|
key: 0,
|
|
44
44
|
class: "lkt-menu-entry-children"
|
|
45
|
-
},
|
|
45
|
+
}, ue = /* @__PURE__ */ B({
|
|
46
46
|
__name: "MenuItem",
|
|
47
47
|
props: {
|
|
48
|
-
modelValue: { default: () => new
|
|
48
|
+
modelValue: { default: () => new W("", "", "") }
|
|
49
49
|
},
|
|
50
50
|
emits: ["update:modelValue"],
|
|
51
51
|
setup(n, { emit: t }) {
|
|
52
|
-
const s = t,
|
|
52
|
+
const s = t, d = n, e = $(d.modelValue), i = K(), O = Z(), k = $(!1), o = () => {
|
|
53
53
|
e.value.isOpened = !e.value.isOpened;
|
|
54
|
-
},
|
|
54
|
+
}, v = () => (e.value.children.length > 0 && o(), typeof e.value.onClick == "function" && e.value.onClick({
|
|
55
55
|
entry: e.value
|
|
56
|
-
}), 1),
|
|
56
|
+
}), 1), f = r(() => i["icon-" + e.value.key] || e.value.icon !== ""), y = r(() => {
|
|
57
57
|
let l = [];
|
|
58
|
-
return
|
|
59
|
-
}),
|
|
58
|
+
return f.value && l.push("has-icon"), k.value && l.push("is-active"), l.join(" ");
|
|
59
|
+
}), h = r(() => L([], e.value.children)), D = r(() => {
|
|
60
60
|
let l = [];
|
|
61
|
-
for (let
|
|
62
|
-
|
|
61
|
+
for (let c in i)
|
|
62
|
+
c.startsWith("icon-") && h.value.includes(c.substring(5)) && l.push(c);
|
|
63
63
|
return l;
|
|
64
|
-
}),
|
|
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({
|
|
65
65
|
entry: e.value
|
|
66
|
-
}) : !1),
|
|
67
|
-
return
|
|
66
|
+
}) : !1), z = r(() => !!p.toggleSlot), F = r(() => p.toggleSlot);
|
|
67
|
+
return C(() => d.modelValue, (l) => {
|
|
68
68
|
e.value = l;
|
|
69
|
-
}, { deep: !0 }),
|
|
69
|
+
}, { deep: !0 }), C(e, (l) => {
|
|
70
70
|
s("update:modelValue", l);
|
|
71
|
-
}, { deep: !0 }),
|
|
72
|
-
let l =
|
|
71
|
+
}, { deep: !0 }), G(() => {
|
|
72
|
+
let l = O.currentRoute;
|
|
73
73
|
if (l.value.path === e.value.href)
|
|
74
74
|
e.value.isOpened = !0;
|
|
75
75
|
else if (e.value.children.length > 0) {
|
|
76
|
-
let
|
|
76
|
+
let c = !1;
|
|
77
77
|
e.value.children.forEach((S) => {
|
|
78
|
-
l.value.path === S.href && (
|
|
79
|
-
}),
|
|
78
|
+
l.value.path === S.href && (c = !0);
|
|
79
|
+
}), c && (e.value.isOpened = !0);
|
|
80
80
|
}
|
|
81
|
-
}), (l,
|
|
82
|
-
const S =
|
|
81
|
+
}), (l, c) => {
|
|
82
|
+
const S = U("lkt-anchor"), q = U("menu-item", !0);
|
|
83
83
|
return u(), a("div", {
|
|
84
|
-
class:
|
|
84
|
+
class: g(["lkt-menu-entry", y.value])
|
|
85
85
|
}, [
|
|
86
|
-
|
|
87
|
-
|
|
86
|
+
V("div", ee, [
|
|
87
|
+
H(S, {
|
|
88
88
|
to: e.value.href,
|
|
89
|
-
"on-click":
|
|
90
|
-
"is-active": x.value
|
|
89
|
+
"on-click": v,
|
|
90
|
+
"is-active": x.value,
|
|
91
|
+
onActive: c[0] || (c[0] = (w) => k.value = l.$e)
|
|
91
92
|
}, {
|
|
92
93
|
default: E(() => [
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
94
|
+
V("div", te, [
|
|
95
|
+
f.value ? (u(), a("div", le, [
|
|
96
|
+
J(i)["icon-" + e.value.key] ? I(l.$slots, "icon-" + e.value.key, {
|
|
96
97
|
key: e.value.key,
|
|
97
98
|
entry: e.value
|
|
98
99
|
}) : e.value.icon !== "" ? (u(), a("i", {
|
|
99
100
|
key: 1,
|
|
100
|
-
class:
|
|
101
|
+
class: g(e.value.icon)
|
|
101
102
|
}, null, 2)) : m("", !0)
|
|
102
103
|
])) : m("", !0),
|
|
103
|
-
e.value.label !== "" ? (u(), a("div",
|
|
104
|
+
e.value.label !== "" ? (u(), a("div", ne, P(j.value), 1)) : m("", !0)
|
|
104
105
|
])
|
|
105
106
|
]),
|
|
106
107
|
_: 3
|
|
@@ -108,27 +109,27 @@ const Z = { class: "lkt-menu-entry-main" }, ee = { class: "lkt-entry-content" },
|
|
|
108
109
|
e.value.children.length > 0 ? (u(), a("div", {
|
|
109
110
|
key: 0,
|
|
110
111
|
class: "lkt-menu-entry-toggle",
|
|
111
|
-
onClick:
|
|
112
|
+
onClick: o
|
|
112
113
|
}, [
|
|
113
|
-
|
|
114
|
+
z.value ? (u(), M(Q(F.value), {
|
|
114
115
|
key: 0,
|
|
115
|
-
class:
|
|
116
|
+
class: g(["lkt-menu-entry-toggle-inner", e.value.isOpened ? "is-opened" : ""])
|
|
116
117
|
}, null, 8, ["class"])) : (u(), a("div", {
|
|
117
118
|
key: 1,
|
|
118
|
-
class:
|
|
119
|
+
class: g(["lkt-menu-entry-toggle-inner lkt-menu-entry-toggle-triangle", e.value.isOpened ? "is-opened" : ""])
|
|
119
120
|
}, null, 2))
|
|
120
121
|
])) : m("", !0)
|
|
121
122
|
]),
|
|
122
|
-
e.value.isOpened ? (u(), a("div",
|
|
123
|
-
(u(!0), a(
|
|
124
|
-
modelValue: e.value.children[
|
|
125
|
-
"onUpdate:modelValue": (
|
|
126
|
-
key:
|
|
127
|
-
},
|
|
128
|
-
|
|
129
|
-
name:
|
|
123
|
+
e.value.isOpened ? (u(), a("div", se, [
|
|
124
|
+
(u(!0), a(N, null, b(e.value.children, (w, R) => (u(), M(q, {
|
|
125
|
+
modelValue: e.value.children[R],
|
|
126
|
+
"onUpdate:modelValue": (_) => e.value.children[R] = _,
|
|
127
|
+
key: w.key
|
|
128
|
+
}, T({ _: 2 }, [
|
|
129
|
+
b(D.value, (_) => ({
|
|
130
|
+
name: _,
|
|
130
131
|
fn: E(() => [
|
|
131
|
-
I(l.$slots,
|
|
132
|
+
I(l.$slots, _)
|
|
132
133
|
])
|
|
133
134
|
}))
|
|
134
135
|
]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
|
|
@@ -136,31 +137,31 @@ const Z = { class: "lkt-menu-entry-main" }, ee = { class: "lkt-entry-content" },
|
|
|
136
137
|
], 2);
|
|
137
138
|
};
|
|
138
139
|
}
|
|
139
|
-
}),
|
|
140
|
+
}), oe = { class: "lkt-menu-container" }, ie = { class: "lkt-menu" }, re = /* @__PURE__ */ V("div", { class: "lkt-menu-outside" }, null, -1), ae = /* @__PURE__ */ B({
|
|
140
141
|
__name: "LktMenu",
|
|
141
142
|
props: {
|
|
142
143
|
modelValue: { default: () => [] }
|
|
143
144
|
},
|
|
144
145
|
emits: ["update:modelValue"],
|
|
145
146
|
setup(n, { emit: t }) {
|
|
146
|
-
const s = n,
|
|
147
|
+
const s = n, d = t, e = K(), i = $(s.modelValue), O = r(() => L([], i.value)), k = r(() => {
|
|
147
148
|
let o = [];
|
|
148
|
-
for (let
|
|
149
|
-
|
|
149
|
+
for (let v in e)
|
|
150
|
+
v.startsWith("icon-") && O.value.includes(v.substring(5)) && o.push(v);
|
|
150
151
|
return o;
|
|
151
152
|
});
|
|
152
|
-
return
|
|
153
|
-
|
|
154
|
-
}, { deep: !0 }),
|
|
155
|
-
|
|
156
|
-
}, { deep: !0 }), (o,
|
|
157
|
-
|
|
158
|
-
(u(!0), a(
|
|
159
|
-
modelValue:
|
|
160
|
-
"onUpdate:modelValue": (h) =>
|
|
161
|
-
key:
|
|
162
|
-
},
|
|
163
|
-
|
|
153
|
+
return C(() => s.modelValue, (o) => {
|
|
154
|
+
i.value = o;
|
|
155
|
+
}, { deep: !0 }), C(i, (o) => {
|
|
156
|
+
d("update:modelValue", o);
|
|
157
|
+
}, { deep: !0 }), (o, v) => (u(), a("div", oe, [
|
|
158
|
+
V("div", ie, [
|
|
159
|
+
(u(!0), a(N, null, b(i.value, (f, y) => (u(), M(ue, {
|
|
160
|
+
modelValue: i.value[y],
|
|
161
|
+
"onUpdate:modelValue": (h) => i.value[y] = h,
|
|
162
|
+
key: f.key
|
|
163
|
+
}, T({ _: 2 }, [
|
|
164
|
+
b(k.value, (h) => ({
|
|
164
165
|
name: h,
|
|
165
166
|
fn: E(() => [
|
|
166
167
|
I(o.$slots, h)
|
|
@@ -171,13 +172,14 @@ const Z = { class: "lkt-menu-entry-main" }, ee = { class: "lkt-entry-content" },
|
|
|
171
172
|
re
|
|
172
173
|
]));
|
|
173
174
|
}
|
|
174
|
-
}),
|
|
175
|
+
}), he = {
|
|
175
176
|
install: (n) => {
|
|
176
|
-
n.component("lkt-menu") === void 0 && n.component("lkt-menu",
|
|
177
|
+
n.component("lkt-menu") === void 0 && n.component("lkt-menu", ae);
|
|
177
178
|
}
|
|
178
|
-
},
|
|
179
|
+
}, me = (n, t, s) => X(new W(n, t, s)), pe = (n) => (p.toggleSlot = n, !0);
|
|
179
180
|
export {
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
181
|
+
W as MenuEntry,
|
|
182
|
+
me as createMenuEntry,
|
|
183
|
+
he as default,
|
|
184
|
+
pe as setMenuToggleSlot
|
|
183
185
|
};
|
package/dist/index.d.ts
CHANGED
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
.lkt-menu{background:var(--lkt-menu-bg);padding:var(--lkt-menu-padding);max-width:var(--lkt-menu-max-width);width:var(--lkt-menu-width);height:100
|
|
1
|
+
.lkt-menu{background:var(--lkt-menu-bg);padding:var(--lkt-menu-padding);max-width:var(--lkt-menu-max-width);width:var(--lkt-menu-width);height:100%;display:flex;flex-direction:column;align-items:stretch;gap:var(--lkt-menu-gap-entries)}.lkt-menu-entry-toggle-inner{transition:all linear .2s}.lkt-menu-entry-toggle-inner.is-opened{transform:rotate(180deg)}.lkt-menu-entry-toggle-triangle{width:0;height:0;border-style:solid;border-width:10px 10px 0 10px;border-color:var(--lkt-menu-color-toggle) transparent transparent transparent;transform:rotate(0);transition:all linear .2s}.lkt-entry-content{display:inline-flex;flex-direction:row;gap:var(--lkt-menu-gap)}.lkt-menu-entry-toggle{display:inline-flex;flex-direction:row;align-items:center;justify-content:center}.lkt-menu-entry{padding:var(--lkt-menu-padding-entry)}.lkt-menu-entry .lkt-anchor{width:100%}.lkt-menu-entry-main{display:flex;justify-content:space-between}.lkt-entry-content{font-size:var(--lkt-menu-font-size);width:100%}.lkt-menu-outside{position:fixed;top:64px;right:0;left:0;bottom:0;background:var(--lkt-menu-bg-outside);z-index:-1}.lkt-menu-entry-children{padding:var(--lkt-menu-padding-children)}.lkt-menu-entry-text{padding:var(--lkt-menu-padding-text-without-icon)}.lkt-menu.has-icon .lkt-menu-entry-text{padding:var(--lkt-menu-padding-text)}.lkt-menu.has-icon .lkt-menu-entry-icon+.lkt-menu-entry-text{padding:var(--lkt-menu-padding-text-with-icon)}
|
package/package.json
CHANGED
|
@@ -21,6 +21,8 @@ const slots = useSlots();
|
|
|
21
21
|
|
|
22
22
|
const router = useRouter();
|
|
23
23
|
|
|
24
|
+
const isActive = ref(false);
|
|
25
|
+
|
|
24
26
|
const onClickToggle = () => {
|
|
25
27
|
entry.value.isOpened = !entry.value.isOpened;
|
|
26
28
|
},
|
|
@@ -41,6 +43,7 @@ const canRenderIcon = computed(() => {
|
|
|
41
43
|
classes = computed(() => {
|
|
42
44
|
let r = [];
|
|
43
45
|
if (canRenderIcon.value) r.push('has-icon');
|
|
46
|
+
if (isActive.value) r.push('is-active');
|
|
44
47
|
return r.join(' ');
|
|
45
48
|
});
|
|
46
49
|
|
|
@@ -113,6 +116,7 @@ onMounted(() => {
|
|
|
113
116
|
:to="entry.href"
|
|
114
117
|
:on-click="onClick"
|
|
115
118
|
:is-active="computedIsActive"
|
|
119
|
+
@active="isActive = $e"
|
|
116
120
|
>
|
|
117
121
|
<div class="lkt-entry-content">
|
|
118
122
|
<div class="lkt-menu-entry-icon" v-if="canRenderIcon">
|