lkt-menu 1.0.6 → 1.0.7
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 +11 -11
- package/dist/build.js +73 -68
- package/dist/lib-components/LktMenu.vue.d.ts +2 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/lib-components/LktMenu.vue +8 -4
package/dist/build.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare class
|
|
1
|
+
declare class D {
|
|
2
2
|
constructor(t: any, s: any, d: any);
|
|
3
3
|
key: any;
|
|
4
4
|
href: any;
|
|
@@ -17,7 +17,7 @@ declare class W {
|
|
|
17
17
|
setIcon(t: any): this;
|
|
18
18
|
doClose(): void;
|
|
19
19
|
}
|
|
20
|
-
declare function
|
|
20
|
+
declare function he(n: any, t: any, s: any): {
|
|
21
21
|
key: any;
|
|
22
22
|
href: any;
|
|
23
23
|
label: any;
|
|
@@ -25,18 +25,18 @@ declare function me(n: any, t: any, s: any): {
|
|
|
25
25
|
isOpened: boolean;
|
|
26
26
|
isActive: boolean;
|
|
27
27
|
children: any[];
|
|
28
|
-
setChildren: (t: any) =>
|
|
29
|
-
setOnClick: (t: any) =>
|
|
28
|
+
setChildren: (t: any) => D;
|
|
29
|
+
setOnClick: (t: any) => D;
|
|
30
30
|
onClick: any;
|
|
31
|
-
setIsActiveChecker: (t: any) =>
|
|
31
|
+
setIsActiveChecker: (t: any) => D;
|
|
32
32
|
isActiveChecker: any;
|
|
33
|
-
setIsActive: (t?: boolean) =>
|
|
34
|
-
setLabel: (t: any) =>
|
|
35
|
-
setIcon: (t: any) =>
|
|
33
|
+
setIsActive: (t?: boolean) => D;
|
|
34
|
+
setLabel: (t: any) => D;
|
|
35
|
+
setIcon: (t: any) => D;
|
|
36
36
|
doClose: () => void;
|
|
37
37
|
};
|
|
38
|
-
declare namespace
|
|
38
|
+
declare namespace ve {
|
|
39
39
|
function install(n: any): void;
|
|
40
40
|
}
|
|
41
|
-
declare function
|
|
42
|
-
export {
|
|
41
|
+
declare function me(n: any): boolean;
|
|
42
|
+
export { D as MenuEntry, he as createMenuEntry, ve as default, me as setMenuToggleSlot };
|
package/dist/build.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { defineComponent as
|
|
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";
|
|
2
2
|
import { __ as Y } from "lkt-i18n";
|
|
3
3
|
import { useRouter as Z } from "vue-router";
|
|
4
|
-
class
|
|
4
|
+
class D {
|
|
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,12 +27,12 @@ class W {
|
|
|
27
27
|
this.isOpened = !1;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
const
|
|
31
|
-
n.includes(s.key) || n.push(s.key), s.children.length > 0 &&
|
|
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);
|
|
32
32
|
}), n), A = class A {
|
|
33
33
|
};
|
|
34
34
|
A.toggleSlot = "", A.debugEnabled = !1;
|
|
35
|
-
let
|
|
35
|
+
let k = A;
|
|
36
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"
|
|
@@ -42,28 +42,28 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
|
|
|
42
42
|
}, se = {
|
|
43
43
|
key: 0,
|
|
44
44
|
class: "lkt-menu-entry-children"
|
|
45
|
-
}, ue = /* @__PURE__ */
|
|
45
|
+
}, ue = /* @__PURE__ */ K({
|
|
46
46
|
__name: "MenuItem",
|
|
47
47
|
props: {
|
|
48
|
-
modelValue: { default: () => new
|
|
48
|
+
modelValue: { default: () => new D("", "", "") }
|
|
49
49
|
},
|
|
50
50
|
emits: ["update:modelValue"],
|
|
51
51
|
setup(n, { emit: t }) {
|
|
52
|
-
const s = t, d = n, e =
|
|
52
|
+
const s = t, d = n, e = I(d.modelValue), o = N(), O = Z(), p = I(!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
|
-
}), 1),
|
|
56
|
+
}), 1), v = r(() => o["icon-" + e.value.key] || e.value.icon !== ""), S = r(() => {
|
|
57
57
|
let l = [];
|
|
58
|
-
return
|
|
59
|
-
}),
|
|
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(() => {
|
|
60
60
|
let l = [];
|
|
61
|
-
for (let c in
|
|
62
|
-
c.startsWith("icon-") &&
|
|
61
|
+
for (let c in o)
|
|
62
|
+
c.startsWith("icon-") && y.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), z = r(() => !!
|
|
66
|
+
}) : !1), z = r(() => !!k.toggleSlot), F = r(() => k.toggleSlot);
|
|
67
67
|
return C(() => d.modelValue, (l) => {
|
|
68
68
|
e.value = l;
|
|
69
69
|
}, { deep: !0 }), C(e, (l) => {
|
|
@@ -74,31 +74,31 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
|
|
|
74
74
|
e.value.isOpened = !0;
|
|
75
75
|
else if (e.value.children.length > 0) {
|
|
76
76
|
let c = !1;
|
|
77
|
-
e.value.children.forEach((
|
|
78
|
-
l.value.path ===
|
|
77
|
+
e.value.children.forEach((E) => {
|
|
78
|
+
l.value.path === E.href && (c = !0);
|
|
79
79
|
}), c && (e.value.isOpened = !0);
|
|
80
80
|
}
|
|
81
81
|
}), (l, c) => {
|
|
82
|
-
const
|
|
82
|
+
const E = B("lkt-anchor"), q = B("menu-item", !0);
|
|
83
83
|
return u(), a("div", {
|
|
84
|
-
class:
|
|
84
|
+
class: _(["lkt-menu-entry", S.value])
|
|
85
85
|
}, [
|
|
86
86
|
V("div", ee, [
|
|
87
|
-
H(
|
|
87
|
+
H(E, {
|
|
88
88
|
to: e.value.href,
|
|
89
|
-
"on-click":
|
|
89
|
+
"on-click": i,
|
|
90
90
|
"is-active": x.value,
|
|
91
|
-
onActive: c[0] || (c[0] = (
|
|
91
|
+
onActive: c[0] || (c[0] = (R) => p.value = l.$e)
|
|
92
92
|
}, {
|
|
93
|
-
default:
|
|
93
|
+
default: $(() => [
|
|
94
94
|
V("div", te, [
|
|
95
|
-
|
|
96
|
-
J(
|
|
95
|
+
v.value ? (u(), a("div", le, [
|
|
96
|
+
J(o)["icon-" + e.value.key] ? M(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:
|
|
101
|
+
class: _(e.value.icon)
|
|
102
102
|
}, null, 2)) : m("", !0)
|
|
103
103
|
])) : m("", !0),
|
|
104
104
|
e.value.label !== "" ? (u(), a("div", ne, P(j.value), 1)) : m("", !0)
|
|
@@ -109,27 +109,27 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
|
|
|
109
109
|
e.value.children.length > 0 ? (u(), a("div", {
|
|
110
110
|
key: 0,
|
|
111
111
|
class: "lkt-menu-entry-toggle",
|
|
112
|
-
onClick:
|
|
112
|
+
onClick: f
|
|
113
113
|
}, [
|
|
114
|
-
z.value ? (u(),
|
|
114
|
+
z.value ? (u(), L(Q(F.value), {
|
|
115
115
|
key: 0,
|
|
116
|
-
class:
|
|
116
|
+
class: _(["lkt-menu-entry-toggle-inner", e.value.isOpened ? "is-opened" : ""])
|
|
117
117
|
}, null, 8, ["class"])) : (u(), a("div", {
|
|
118
118
|
key: 1,
|
|
119
|
-
class:
|
|
119
|
+
class: _(["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(
|
|
125
|
-
modelValue: e.value.children[
|
|
126
|
-
"onUpdate:modelValue": (
|
|
127
|
-
key:
|
|
128
|
-
},
|
|
129
|
-
b(
|
|
130
|
-
name:
|
|
131
|
-
fn:
|
|
132
|
-
|
|
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
|
|
128
|
+
}, W({ _: 2 }, [
|
|
129
|
+
b(h.value, (g) => ({
|
|
130
|
+
name: g,
|
|
131
|
+
fn: $(() => [
|
|
132
|
+
M(l.$slots, g)
|
|
133
133
|
])
|
|
134
134
|
}))
|
|
135
135
|
]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
|
|
@@ -137,49 +137,54 @@ const ee = { class: "lkt-menu-entry-main" }, te = { class: "lkt-entry-content" }
|
|
|
137
137
|
], 2);
|
|
138
138
|
};
|
|
139
139
|
}
|
|
140
|
-
}),
|
|
140
|
+
}), ie = { class: "lkt-menu-container" }, oe = { class: "lkt-menu" }, re = /* @__PURE__ */ K({
|
|
141
141
|
__name: "LktMenu",
|
|
142
142
|
props: {
|
|
143
143
|
modelValue: { default: () => [] }
|
|
144
144
|
},
|
|
145
|
-
emits: ["update:modelValue"],
|
|
145
|
+
emits: ["update:modelValue", "click-outside"],
|
|
146
146
|
setup(n, { emit: t }) {
|
|
147
|
-
const s = n, d = t, e =
|
|
148
|
-
let
|
|
147
|
+
const s = n, d = t, e = N(), o = I(s.modelValue), O = r(() => w([], o.value)), p = r(() => {
|
|
148
|
+
let i = [];
|
|
149
149
|
for (let v in e)
|
|
150
|
-
v.startsWith("icon-") && O.value.includes(v.substring(5)) &&
|
|
151
|
-
return
|
|
152
|
-
})
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
}, { deep: !0 }), (o,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
150
|
+
v.startsWith("icon-") && O.value.includes(v.substring(5)) && i.push(v);
|
|
151
|
+
return i;
|
|
152
|
+
}), f = () => {
|
|
153
|
+
d("click-outside");
|
|
154
|
+
};
|
|
155
|
+
return C(() => s.modelValue, (i) => {
|
|
156
|
+
o.value = i;
|
|
157
|
+
}, { deep: !0 }), C(o, (i) => {
|
|
158
|
+
d("update:modelValue", i);
|
|
159
|
+
}, { deep: !0 }), (i, v) => (u(), a("div", ie, [
|
|
160
|
+
V("div", oe, [
|
|
161
|
+
(u(!0), a(T, null, b(o.value, (S, y) => (u(), L(ue, {
|
|
162
|
+
modelValue: o.value[y],
|
|
163
|
+
"onUpdate:modelValue": (h) => o.value[y] = h,
|
|
164
|
+
key: S.key
|
|
165
|
+
}, W({ _: 2 }, [
|
|
166
|
+
b(p.value, (h) => ({
|
|
165
167
|
name: h,
|
|
166
|
-
fn:
|
|
167
|
-
|
|
168
|
+
fn: $(() => [
|
|
169
|
+
M(i.$slots, h)
|
|
168
170
|
])
|
|
169
171
|
}))
|
|
170
172
|
]), 1032, ["modelValue", "onUpdate:modelValue"]))), 128))
|
|
171
173
|
]),
|
|
172
|
-
|
|
174
|
+
V("div", {
|
|
175
|
+
class: "lkt-menu-outside",
|
|
176
|
+
onClick: f
|
|
177
|
+
})
|
|
173
178
|
]));
|
|
174
179
|
}
|
|
175
|
-
}),
|
|
180
|
+
}), ve = {
|
|
176
181
|
install: (n) => {
|
|
177
|
-
n.component("lkt-menu") === void 0 && n.component("lkt-menu",
|
|
182
|
+
n.component("lkt-menu") === void 0 && n.component("lkt-menu", re);
|
|
178
183
|
}
|
|
179
|
-
},
|
|
184
|
+
}, he = (n, t, s) => X(new D(n, t, s)), me = (n) => (k.toggleSlot = n, !0);
|
|
180
185
|
export {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
186
|
+
D as MenuEntry,
|
|
187
|
+
he as createMenuEntry,
|
|
188
|
+
ve as default,
|
|
189
|
+
me as setMenuToggleSlot
|
|
185
190
|
};
|
|
@@ -5,12 +5,14 @@ declare const _default: __VLS_WithTemplateSlots<import("vue").DefineComponent<__
|
|
|
5
5
|
modelValue: () => never[];
|
|
6
6
|
}>, {}, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
7
|
"update:modelValue": (...args: any[]) => void;
|
|
8
|
+
"click-outside": (...args: any[]) => void;
|
|
8
9
|
}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<__VLS_WithDefaults<__VLS_TypePropsToRuntimeProps<{
|
|
9
10
|
modelValue?: MenuEntry[] | undefined;
|
|
10
11
|
}>, {
|
|
11
12
|
modelValue: () => never[];
|
|
12
13
|
}>>> & {
|
|
13
14
|
"onUpdate:modelValue"?: ((...args: any[]) => any) | undefined;
|
|
15
|
+
"onClick-outside"?: ((...args: any[]) => any) | undefined;
|
|
14
16
|
}, {
|
|
15
17
|
modelValue: MenuEntry[];
|
|
16
18
|
}, {}>, Partial<Record<any, (_: {}) => any>>>;
|
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%;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)}
|
|
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;position:relative}.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
|
@@ -6,12 +6,12 @@ import {LktObject} from "lkt-ts-interfaces";
|
|
|
6
6
|
import {fetchKeys} from "../functions/helpers";
|
|
7
7
|
|
|
8
8
|
const props = withDefaults(defineProps<{
|
|
9
|
-
modelValue?: MenuEntry[]
|
|
9
|
+
modelValue?: MenuEntry[],
|
|
10
10
|
}>(), {
|
|
11
|
-
modelValue: () => []
|
|
11
|
+
modelValue: () => [],
|
|
12
12
|
});
|
|
13
13
|
|
|
14
|
-
const emit = defineEmits(['update:modelValue']);
|
|
14
|
+
const emit = defineEmits(['update:modelValue', 'click-outside']);
|
|
15
15
|
|
|
16
16
|
const slots = useSlots();
|
|
17
17
|
|
|
@@ -33,6 +33,10 @@ const availableKeys = computed(() => {
|
|
|
33
33
|
return r;
|
|
34
34
|
});
|
|
35
35
|
|
|
36
|
+
const onClickOutside = () => {
|
|
37
|
+
emit('click-outside');
|
|
38
|
+
}
|
|
39
|
+
|
|
36
40
|
watch(() => props.modelValue, (v) => {
|
|
37
41
|
entries.value = v;
|
|
38
42
|
}, {deep: true})
|
|
@@ -51,7 +55,7 @@ watch(entries, (v) => {
|
|
|
51
55
|
</template>
|
|
52
56
|
</menu-item>
|
|
53
57
|
</div>
|
|
54
|
-
<div class="lkt-menu-outside"/>
|
|
58
|
+
<div class="lkt-menu-outside" v-on:click="onClickOutside"/>
|
|
55
59
|
</div>
|
|
56
60
|
</template>
|
|
57
61
|
|