lkt-menu 2.0.6 → 2.0.8
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 +3 -3
- package/dist/build.js +122 -122
- package/dist/components/MenuItem.vue.d.ts +4500 -1500
- package/dist/lib-components/LktMenu.vue.d.ts +2593 -593
- package/package.json +1 -2
- package/src/components/MenuItem.vue +0 -177
- package/src/lib-components/LktMenu.vue +0 -111
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "lkt-menu",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"description": "",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"lkt",
|
|
@@ -25,7 +25,6 @@
|
|
|
25
25
|
"types": "./dist/build.d.ts",
|
|
26
26
|
"files": [
|
|
27
27
|
"dist/*",
|
|
28
|
-
"src/**/*.vue",
|
|
29
28
|
"theme/**/*.css"
|
|
30
29
|
],
|
|
31
30
|
"license": "MIT",
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import { MenuEntryConfig, MenuEntryType } from 'lkt-vue-kernel';
|
|
3
|
-
import { computed, onMounted, ref, useSlots, watch } from 'vue';
|
|
4
|
-
import { fetchKeys } from '../functions/helpers';
|
|
5
|
-
import { useRouter } from 'vue-router';
|
|
6
|
-
import { Settings } from '../settings/Settings';
|
|
7
|
-
|
|
8
|
-
const emit = defineEmits([
|
|
9
|
-
'update:modelValue',
|
|
10
|
-
]);
|
|
11
|
-
|
|
12
|
-
const props = withDefaults(defineProps<{
|
|
13
|
-
modelValue?: MenuEntryConfig
|
|
14
|
-
}>(), {
|
|
15
|
-
modelValue: () => ({}),
|
|
16
|
-
});
|
|
17
|
-
|
|
18
|
-
const entry = ref(<MenuEntryConfig>props.modelValue),
|
|
19
|
-
slots = useSlots(),
|
|
20
|
-
router = useRouter(),
|
|
21
|
-
isActive = ref(false);
|
|
22
|
-
|
|
23
|
-
const onClickToggle = () => {
|
|
24
|
-
entry.value.isOpened = !entry.value.isOpened;
|
|
25
|
-
},
|
|
26
|
-
onClick = () => {
|
|
27
|
-
if (typeof entry.value.children !== 'undefined' && entry.value.children?.length > 0 && !entry.value.keepOpenOnChildClick) onClickToggle();
|
|
28
|
-
|
|
29
|
-
if (typeof entry.value.events?.click === 'function') {
|
|
30
|
-
entry.value.events.click({
|
|
31
|
-
entry: entry.value,
|
|
32
|
-
});
|
|
33
|
-
return 1;
|
|
34
|
-
}
|
|
35
|
-
return 1;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
const canRenderIcon = computed(() => {
|
|
39
|
-
return slots['icon-' + entry.value.key]
|
|
40
|
-
|| entry.value.icon !== '';
|
|
41
|
-
}),
|
|
42
|
-
classes = computed(() => {
|
|
43
|
-
let r = [];
|
|
44
|
-
if (canRenderIcon.value) r.push('has-icon');
|
|
45
|
-
if (isActive.value) r.push('is-active');
|
|
46
|
-
if (entry.value.type) r.push(`is-${entry.value.type}`);
|
|
47
|
-
return r.join(' ');
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const availableKeys = computed(() => {
|
|
51
|
-
let r: string[] = [];
|
|
52
|
-
return fetchKeys(r, entry.value?.children ?? []);
|
|
53
|
-
}),
|
|
54
|
-
entryIconSlots = computed((): Array<string> => {
|
|
55
|
-
let r = [];
|
|
56
|
-
for (let k in slots) {
|
|
57
|
-
if (k.startsWith('icon-')) {
|
|
58
|
-
if (availableKeys.value.includes(k.substring(5))) {
|
|
59
|
-
r.push(k);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
return r;
|
|
64
|
-
}),
|
|
65
|
-
computedIsActive = computed(() => {
|
|
66
|
-
if (entry.value.isActive) return true;
|
|
67
|
-
|
|
68
|
-
if (typeof entry.value.isActiveChecker === 'function') {
|
|
69
|
-
let r = entry.value.isActiveChecker({
|
|
70
|
-
entry: entry.value,
|
|
71
|
-
});
|
|
72
|
-
return !!r;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
return false;
|
|
76
|
-
}),
|
|
77
|
-
hasToggleSlot = computed(() => {
|
|
78
|
-
return !!Settings.toggleSlot;
|
|
79
|
-
}),
|
|
80
|
-
toggleSlot = computed(() => {
|
|
81
|
-
return Settings.toggleSlot;
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
watch(() => props.modelValue, (v) => {
|
|
85
|
-
entry.value = v;
|
|
86
|
-
}, { deep: true });
|
|
87
|
-
|
|
88
|
-
watch(entry, (v) => {
|
|
89
|
-
emit('update:modelValue', v);
|
|
90
|
-
}, { deep: true });
|
|
91
|
-
|
|
92
|
-
onMounted(() => {
|
|
93
|
-
let currentRoute = router?.currentRoute;
|
|
94
|
-
if (currentRoute) {
|
|
95
|
-
if (currentRoute.value.path === entry.value.anchor?.to) {
|
|
96
|
-
entry.value.isOpened = true;
|
|
97
|
-
|
|
98
|
-
} else if (typeof entry.value.children !== 'undefined' && entry.value.children?.length > 0) {
|
|
99
|
-
let opened = false;
|
|
100
|
-
entry.value.children?.forEach((child) => {
|
|
101
|
-
if (currentRoute.value.path === child.anchor?.to) opened = true;
|
|
102
|
-
});
|
|
103
|
-
|
|
104
|
-
if (opened) entry.value.isOpened = true;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
</script>
|
|
109
|
-
|
|
110
|
-
<template>
|
|
111
|
-
<div class="lkt-menu-entry" :class="classes">
|
|
112
|
-
<div class="lkt-menu-entry-main">
|
|
113
|
-
<lkt-button
|
|
114
|
-
v-if="entry.type === MenuEntryType.Button"
|
|
115
|
-
v-bind="entry.button"
|
|
116
|
-
>
|
|
117
|
-
<template v-if="slots.tooltip" #tooltip>
|
|
118
|
-
<slot name="tooltip" />
|
|
119
|
-
</template>
|
|
120
|
-
<template v-if="slots.split" #split>
|
|
121
|
-
<slot name="split" />
|
|
122
|
-
</template>
|
|
123
|
-
</lkt-button>
|
|
124
|
-
|
|
125
|
-
<lkt-anchor
|
|
126
|
-
v-else-if="entry.type === MenuEntryType.Anchor"
|
|
127
|
-
v-bind="entry.anchor"
|
|
128
|
-
/>
|
|
129
|
-
<lkt-anchor
|
|
130
|
-
v-else
|
|
131
|
-
v-bind="entry.anchor"
|
|
132
|
-
:on-click="onClick"
|
|
133
|
-
:is-active="computedIsActive"
|
|
134
|
-
@active="($e: any) => isActive = $e"
|
|
135
|
-
>
|
|
136
|
-
<template #text="{text}">
|
|
137
|
-
<div class="lkt-entry-content">
|
|
138
|
-
<div class="lkt-menu-entry-icon" v-if="canRenderIcon">
|
|
139
|
-
<template v-if="slots['icon-'+entry.key]">
|
|
140
|
-
<slot :name="'icon-'+entry.key"
|
|
141
|
-
:key="entry.key"
|
|
142
|
-
:entry="entry" />
|
|
143
|
-
</template>
|
|
144
|
-
<template v-else-if="entry.icon !== ''">
|
|
145
|
-
<i :class="entry.icon" />
|
|
146
|
-
</template>
|
|
147
|
-
</div>
|
|
148
|
-
<div class="lkt-menu-entry-text" v-if="text !== ''">
|
|
149
|
-
{{ text }}
|
|
150
|
-
</div>
|
|
151
|
-
</div>
|
|
152
|
-
</template>
|
|
153
|
-
</lkt-anchor>
|
|
154
|
-
|
|
155
|
-
<div class="lkt-menu-entry-toggle"
|
|
156
|
-
v-if="entry.type !== MenuEntryType.Button && entry.children && entry.children?.length > 0"
|
|
157
|
-
@click="onClickToggle">
|
|
158
|
-
<template v-if="hasToggleSlot">
|
|
159
|
-
<component :is="toggleSlot" class="lkt-menu-entry-toggle-inner"
|
|
160
|
-
:class="entry.isOpened ? 'is-opened' : '' " />
|
|
161
|
-
</template>
|
|
162
|
-
<div v-else class="lkt-menu-entry-toggle-inner" :class="entry.isOpened ? 'is-opened' : '' ">
|
|
163
|
-
<i class="lkt-icn-angle-bottom" />
|
|
164
|
-
</div>
|
|
165
|
-
</div>
|
|
166
|
-
</div>
|
|
167
|
-
<div class="lkt-menu-entry-children" v-if="entry.isOpened">
|
|
168
|
-
<menu-item v-for="(_, i) in entry.children"
|
|
169
|
-
v-model="entry.children[i]"
|
|
170
|
-
:key="entry.children[i].key">
|
|
171
|
-
<template v-for="slot in entryIconSlots" v-slot:[slot]>
|
|
172
|
-
<slot :name="slot" />
|
|
173
|
-
</template>
|
|
174
|
-
</menu-item>
|
|
175
|
-
</div>
|
|
176
|
-
</div>
|
|
177
|
-
</template>
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
<script setup lang="ts">
|
|
2
|
-
import MenuItem from '../components/MenuItem.vue';
|
|
3
|
-
import { computed, ref, useSlots, watch } from 'vue';
|
|
4
|
-
import { getDefaultValues, LktObject, Menu, MenuConfig } from 'lkt-vue-kernel';
|
|
5
|
-
import { fetchKeys } from '../functions/helpers';
|
|
6
|
-
import { DataState } from 'lkt-data-state';
|
|
7
|
-
import { httpCall, HTTPResponse } from 'lkt-http-client';
|
|
8
|
-
|
|
9
|
-
const props = withDefaults(defineProps<MenuConfig>(), getDefaultValues(Menu));
|
|
10
|
-
|
|
11
|
-
const emit = defineEmits([
|
|
12
|
-
'update:modelValue',
|
|
13
|
-
'click-outside',
|
|
14
|
-
'loading',
|
|
15
|
-
'results',
|
|
16
|
-
'response',
|
|
17
|
-
'error',
|
|
18
|
-
]);
|
|
19
|
-
|
|
20
|
-
const slots = useSlots();
|
|
21
|
-
|
|
22
|
-
const entries = ref(props.modelValue);
|
|
23
|
-
|
|
24
|
-
const parseFilters = (filters: LktObject) => {
|
|
25
|
-
let d: LktObject = {};
|
|
26
|
-
if (typeof filters === 'object' && Object.keys(filters).length > 0) {
|
|
27
|
-
d = JSON.parse(JSON.stringify(filters));
|
|
28
|
-
}
|
|
29
|
-
for (let k in d) {
|
|
30
|
-
if (Array.isArray(d[k]) || typeof d[k] === 'object') {
|
|
31
|
-
d[k] = JSON.stringify(d[k]);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return d;
|
|
35
|
-
};
|
|
36
|
-
let resourceDataState = new DataState({});
|
|
37
|
-
resourceDataState.increment(parseFilters(props.http?.data ?? {}));
|
|
38
|
-
|
|
39
|
-
const availableKeys = computed(() => {
|
|
40
|
-
let r: string[] = [];
|
|
41
|
-
return fetchKeys(r, entries.value);
|
|
42
|
-
}),
|
|
43
|
-
entryIconSlots = computed((): LktObject => {
|
|
44
|
-
let r = [];
|
|
45
|
-
for (let k in slots) {
|
|
46
|
-
if (k.startsWith('icon-')) {
|
|
47
|
-
if (availableKeys.value.includes(k.substring(5))) {
|
|
48
|
-
r.push(k);
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
return r;
|
|
53
|
-
}),
|
|
54
|
-
loadResource = () => {
|
|
55
|
-
if (!props.http?.resource) return;
|
|
56
|
-
|
|
57
|
-
let d = resourceDataState.getData();
|
|
58
|
-
emit('loading');
|
|
59
|
-
|
|
60
|
-
httpCall(props.http?.resource, d).then((r: HTTPResponse) => {
|
|
61
|
-
resourceDataState.turnStoredIntoOriginal();
|
|
62
|
-
//@ts-ignore
|
|
63
|
-
entries.value = r.data;
|
|
64
|
-
emit('results', r.data);
|
|
65
|
-
emit('response', r);
|
|
66
|
-
|
|
67
|
-
}).catch((r: any) => {
|
|
68
|
-
emit('error', r);
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
|
|
72
|
-
const onClickOutside = () => {
|
|
73
|
-
emit('click-outside');
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
watch(() => props.modelValue, (v) => {
|
|
77
|
-
entries.value = v;
|
|
78
|
-
}, { deep: true });
|
|
79
|
-
|
|
80
|
-
watch(entries, (v) => {
|
|
81
|
-
emit('update:modelValue', v);
|
|
82
|
-
}, { deep: true });
|
|
83
|
-
|
|
84
|
-
loadResource();
|
|
85
|
-
</script>
|
|
86
|
-
|
|
87
|
-
<template>
|
|
88
|
-
<div class="lkt-menu">
|
|
89
|
-
<div class="lkt-menu-main">
|
|
90
|
-
<template v-if="slots.before">
|
|
91
|
-
<slot name="before"/>
|
|
92
|
-
</template>
|
|
93
|
-
<div class="lkt-menu-entries">
|
|
94
|
-
<menu-item v-for="(entry, i) in entries" v-model="entries[i]" :key="entry.key" :class="entry.class">
|
|
95
|
-
<template v-for="slot in entryIconSlots" v-slot:[slot]>
|
|
96
|
-
<slot :name="slot" />
|
|
97
|
-
</template>
|
|
98
|
-
|
|
99
|
-
<template v-if="slots[`tooltip-${entry.key}`]" #tooltip>
|
|
100
|
-
<slot :name="`tooltip-${entry.key}`"/>
|
|
101
|
-
</template>
|
|
102
|
-
|
|
103
|
-
<template v-if="slots[`split-${entry.key}`]" #split>
|
|
104
|
-
<slot :name="`split-${entry.key}`"/>
|
|
105
|
-
</template>
|
|
106
|
-
</menu-item>
|
|
107
|
-
</div>
|
|
108
|
-
</div>
|
|
109
|
-
<div class="lkt-menu-outside" v-on:click="onClickOutside" />
|
|
110
|
-
</div>
|
|
111
|
-
</template>
|