@vuecs/navigation 2.4.1 → 3.0.1
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/LICENSE +201 -21
- package/README.md +10 -167
- package/dist/components/index.d.ts +2 -0
- package/dist/components/index.d.ts.map +1 -1
- package/dist/components/item/module.d.ts +48 -4
- package/dist/components/item/module.d.ts.map +1 -1
- package/dist/components/items/index.d.ts +1 -0
- package/dist/components/items/index.d.ts.map +1 -1
- package/dist/components/items/module.d.ts +45 -2
- package/dist/components/items/module.d.ts.map +1 -1
- package/dist/components/items/theme.d.ts +10 -0
- package/dist/components/items/theme.d.ts.map +1 -0
- package/dist/components/stepper/Stepper.vue.d.ts +129 -0
- package/dist/components/stepper/Stepper.vue.d.ts.map +1 -0
- package/dist/components/stepper/StepperDescription.vue.d.ts +79 -0
- package/dist/components/stepper/StepperDescription.vue.d.ts.map +1 -0
- package/dist/components/stepper/StepperIndicator.vue.d.ts +79 -0
- package/dist/components/stepper/StepperIndicator.vue.d.ts.map +1 -0
- package/dist/components/stepper/StepperItem.vue.d.ts +99 -0
- package/dist/components/stepper/StepperItem.vue.d.ts.map +1 -0
- package/dist/components/stepper/StepperSeparator.vue.d.ts +79 -0
- package/dist/components/stepper/StepperSeparator.vue.d.ts.map +1 -0
- package/dist/components/stepper/StepperTitle.vue.d.ts +79 -0
- package/dist/components/stepper/StepperTitle.vue.d.ts.map +1 -0
- package/dist/components/stepper/StepperTrigger.vue.d.ts +79 -0
- package/dist/components/stepper/StepperTrigger.vue.d.ts.map +1 -0
- package/dist/components/stepper/context.d.ts +19 -0
- package/dist/components/stepper/context.d.ts.map +1 -0
- package/dist/components/stepper/index.d.ts +19 -0
- package/dist/components/stepper/index.d.ts.map +1 -0
- package/dist/components/stepper/theme.d.ts +4 -0
- package/dist/components/stepper/theme.d.ts.map +1 -0
- package/dist/components/stepper/types.d.ts +23 -0
- package/dist/components/stepper/types.d.ts.map +1 -0
- package/dist/components/type.d.ts +22 -0
- package/dist/components/type.d.ts.map +1 -0
- package/dist/helpers/component/index.d.ts +0 -1
- package/dist/helpers/component/index.d.ts.map +1 -1
- package/dist/helpers/component/types.d.ts +15 -15
- package/dist/helpers/component/types.d.ts.map +1 -1
- package/dist/helpers/match.d.ts.map +1 -1
- package/dist/helpers/reset.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +818 -566
- package/dist/index.mjs.map +1 -1
- package/dist/manager/module.d.ts.map +1 -1
- package/dist/style.css +100 -0
- package/dist/types.d.ts +8 -4
- package/dist/types.d.ts.map +1 -1
- package/dist/vue.d.ts +8 -1
- package/dist/vue.d.ts.map +1 -1
- package/package.json +24 -27
- package/core/index.cjs +0 -1
- package/core/index.d.ts +0 -2
- package/core/index.mjs +0 -1
- package/core/package.json +0 -5
- package/dist/helpers/component/build.d.ts +0 -3
- package/dist/helpers/component/build.d.ts.map +0 -1
- package/dist/index.cjs +0 -617
- package/dist/index.cjs.map +0 -1
- package/dist/index.css +0 -82
package/dist/index.cjs
DELETED
|
@@ -1,617 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@vuecs/core');
|
|
6
|
-
var eventEmitter = require('@posva/event-emitter');
|
|
7
|
-
var link = require('@vuecs/link');
|
|
8
|
-
var vue = require('vue');
|
|
9
|
-
|
|
10
|
-
function buildComponentOptions() {
|
|
11
|
-
const manager = core.createComponentOptionsManager({
|
|
12
|
-
name: 'navigation'
|
|
13
|
-
});
|
|
14
|
-
return {
|
|
15
|
-
groupClass: core.mergeOption('class', manager.get('groupClass'), 'vc-nav-items'),
|
|
16
|
-
groupTag: manager.get('groupTag') || 'ul',
|
|
17
|
-
itemClass: core.mergeOption('class', manager.get('itemClass'), 'vc-nav-item'),
|
|
18
|
-
itemNestedClass: core.mergeOption('class', manager.get('itemNestedClass'), 'vc-nav-item-nested'),
|
|
19
|
-
itemTag: manager.get('itemTag') || 'li',
|
|
20
|
-
separatorTag: manager.get('separatorTag') || 'div',
|
|
21
|
-
separatorClass: core.mergeOption('class', manager.get('linkIconClass'), 'vc-nav-separator'),
|
|
22
|
-
linkIconTag: manager.get('linkIconTag') || 'div',
|
|
23
|
-
linkIconClass: core.mergeOption('class', manager.get('linkIconClass'), 'vc-nav-link-icon'),
|
|
24
|
-
linkClass: core.mergeOption('class', manager.get('linkClass'), 'vc-nav-link'),
|
|
25
|
-
linkRootClass: core.mergeOption('class', manager.get('linkRootClass'), 'vc-nav-link-root'),
|
|
26
|
-
linkTextTag: manager.get('linkTextTag') || 'div',
|
|
27
|
-
linkTextClass: core.mergeOption('class', manager.get('linkTextClass'), 'vc-nav-link-text')
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function calculateItemScoreForPath(item, currentPath) {
|
|
32
|
-
if (item.url === '/') {
|
|
33
|
-
return 1;
|
|
34
|
-
}
|
|
35
|
-
if (item.activeMatch) {
|
|
36
|
-
if (item.activeMatch === currentPath) {
|
|
37
|
-
return 6;
|
|
38
|
-
}
|
|
39
|
-
if (currentPath.startsWith(item.activeMatch)) {
|
|
40
|
-
return 4;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
if (item.url) {
|
|
44
|
-
if (item.url === currentPath) {
|
|
45
|
-
return 3;
|
|
46
|
-
}
|
|
47
|
-
if (currentPath.startsWith(item.url)) {
|
|
48
|
-
return 2;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
return 0;
|
|
52
|
-
}
|
|
53
|
-
function findItemMatchesIF(items, options, parent) {
|
|
54
|
-
const output = [];
|
|
55
|
-
for(let i = 0; i < items.length; i++){
|
|
56
|
-
const item = items[i];
|
|
57
|
-
let { score } = parent;
|
|
58
|
-
if (options.path) {
|
|
59
|
-
score += calculateItemScoreForPath(item, options.path);
|
|
60
|
-
}
|
|
61
|
-
if (item.default) {
|
|
62
|
-
score += 1;
|
|
63
|
-
}
|
|
64
|
-
if (item.children) {
|
|
65
|
-
const childMatches = findItemMatchesIF(item.children, options, {
|
|
66
|
-
score
|
|
67
|
-
});
|
|
68
|
-
output.push(...childMatches);
|
|
69
|
-
}
|
|
70
|
-
output.push({
|
|
71
|
-
data: item,
|
|
72
|
-
score
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
return output.sort((a, b)=>b.score - a.score);
|
|
76
|
-
}
|
|
77
|
-
function findBestItemMatches(items, options = {}) {
|
|
78
|
-
const result = findItemMatchesIF(items, options, {
|
|
79
|
-
score: 0
|
|
80
|
-
});
|
|
81
|
-
const [first] = result;
|
|
82
|
-
if (!first) {
|
|
83
|
-
return [];
|
|
84
|
-
}
|
|
85
|
-
return result.filter((match)=>match.score === first.score).map((match)=>match.data);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/*
|
|
89
|
-
* Copyright (c) 2024.
|
|
90
|
-
* Author Peter Placzek (tada5hi)
|
|
91
|
-
* For the full copyright and license information,
|
|
92
|
-
* view the LICENSE file that was distributed with this source code.
|
|
93
|
-
*/ function normalizeItemIF(item, defaults, trace) {
|
|
94
|
-
const output = {
|
|
95
|
-
...item,
|
|
96
|
-
level: defaults.level,
|
|
97
|
-
children: [],
|
|
98
|
-
trace: [
|
|
99
|
-
...trace,
|
|
100
|
-
item.name
|
|
101
|
-
],
|
|
102
|
-
meta: item.meta || {}
|
|
103
|
-
};
|
|
104
|
-
if (!item.children) {
|
|
105
|
-
return output;
|
|
106
|
-
}
|
|
107
|
-
for(let i = 0; i < item.children.length; i++){
|
|
108
|
-
output.children.push(normalizeItemIF(item.children[i], defaults, output.trace));
|
|
109
|
-
}
|
|
110
|
-
return output;
|
|
111
|
-
}
|
|
112
|
-
function normalizeItem(item, defaults) {
|
|
113
|
-
return normalizeItemIF(item, defaults, []);
|
|
114
|
-
}
|
|
115
|
-
function normalizeItems(items, options) {
|
|
116
|
-
return items.map((item)=>normalizeItem(item, options));
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
/*
|
|
120
|
-
* Copyright (c) 2024.
|
|
121
|
-
* Author Peter Placzek (tada5hi)
|
|
122
|
-
* For the full copyright and license information,
|
|
123
|
-
* view the LICENSE file that was distributed with this source code.
|
|
124
|
-
*/ function isTraceEqual(a, b) {
|
|
125
|
-
if (a.length !== b.length) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
for(let i = 0; i < a.length; i++){
|
|
129
|
-
if (a[i] !== b[i]) {
|
|
130
|
-
return false;
|
|
131
|
-
}
|
|
132
|
-
}
|
|
133
|
-
return true;
|
|
134
|
-
}
|
|
135
|
-
function isTracePartOf(item, parent) {
|
|
136
|
-
for(let i = 0; i < item.length; i++){
|
|
137
|
-
if (parent[i] !== item[i]) {
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
function resetItemsByTraceIF(items, trace) {
|
|
145
|
-
for(let i = 0; i < items.length; i++){
|
|
146
|
-
const item = items[i];
|
|
147
|
-
const isEqual = isTraceEqual(items[i].trace, trace);
|
|
148
|
-
item.active = isEqual;
|
|
149
|
-
item.display = true;
|
|
150
|
-
if (isEqual) {
|
|
151
|
-
item.displayChildren = true;
|
|
152
|
-
} else {
|
|
153
|
-
item.displayChildren = isTracePartOf(item.trace, trace);
|
|
154
|
-
}
|
|
155
|
-
item.children = resetItemsByTraceIF(item.children, trace);
|
|
156
|
-
}
|
|
157
|
-
return items;
|
|
158
|
-
}
|
|
159
|
-
function resetItemsByTrace(items, trace) {
|
|
160
|
-
return resetItemsByTraceIF(items, trace);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function findItemsWithLevel(items, tier) {
|
|
164
|
-
return items.filter((item)=>item.level === tier);
|
|
165
|
-
}
|
|
166
|
-
function findItemWithLevel(tier, items) {
|
|
167
|
-
const data = findItemsWithLevel(items, tier);
|
|
168
|
-
if (data.length >= 1) {
|
|
169
|
-
return data[0];
|
|
170
|
-
}
|
|
171
|
-
return undefined;
|
|
172
|
-
}
|
|
173
|
-
function removeItemsWithLevel(tier, items) {
|
|
174
|
-
return items.filter((item)=>item.level !== tier);
|
|
175
|
-
}
|
|
176
|
-
function replaceLevelItem(tier, input, next) {
|
|
177
|
-
const output = removeItemsWithLevel(tier, input);
|
|
178
|
-
if (next) {
|
|
179
|
-
next.level = tier;
|
|
180
|
-
return [
|
|
181
|
-
...output,
|
|
182
|
-
next
|
|
183
|
-
];
|
|
184
|
-
}
|
|
185
|
-
return output;
|
|
186
|
-
}
|
|
187
|
-
function replaceLevelItems(tier, src, next) {
|
|
188
|
-
const componentsExisting = removeItemsWithLevel(tier, src);
|
|
189
|
-
return [
|
|
190
|
-
...componentsExisting,
|
|
191
|
-
...next
|
|
192
|
-
];
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function isAbsoluteURL(str) {
|
|
196
|
-
return str.substring(0, 7) === 'http://' || str.substring(0, 8) === 'https://';
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
class NavigationManager extends eventEmitter.EventEmitter {
|
|
200
|
-
getItems(tier) {
|
|
201
|
-
if (typeof tier === 'undefined') {
|
|
202
|
-
return this.items;
|
|
203
|
-
}
|
|
204
|
-
return this.items.filter((item)=>item.level === tier);
|
|
205
|
-
}
|
|
206
|
-
reset() {
|
|
207
|
-
this.built = false;
|
|
208
|
-
this.items = [];
|
|
209
|
-
this.itemsActive = [];
|
|
210
|
-
}
|
|
211
|
-
async build(options) {
|
|
212
|
-
if (this.built || this.building) {
|
|
213
|
-
return;
|
|
214
|
-
}
|
|
215
|
-
this.building = true;
|
|
216
|
-
this.emit('building');
|
|
217
|
-
let parent;
|
|
218
|
-
let level = 0;
|
|
219
|
-
while(true){
|
|
220
|
-
const raw = await this.itemsFn({
|
|
221
|
-
level,
|
|
222
|
-
parent
|
|
223
|
-
});
|
|
224
|
-
if (!raw || raw.length === 0) {
|
|
225
|
-
break;
|
|
226
|
-
}
|
|
227
|
-
const items = normalizeItems(raw, {
|
|
228
|
-
level
|
|
229
|
-
});
|
|
230
|
-
const matches = findBestItemMatches(items, {
|
|
231
|
-
path: options.path
|
|
232
|
-
});
|
|
233
|
-
const [match] = matches;
|
|
234
|
-
if (!match) {
|
|
235
|
-
break;
|
|
236
|
-
}
|
|
237
|
-
this.itemsActive.push(match);
|
|
238
|
-
await this.buildLevel(level);
|
|
239
|
-
parent = match;
|
|
240
|
-
level++;
|
|
241
|
-
}
|
|
242
|
-
this.building = false;
|
|
243
|
-
this.built = true;
|
|
244
|
-
this.emit('built');
|
|
245
|
-
this.emit('updated', this.items);
|
|
246
|
-
}
|
|
247
|
-
async select(level, itemNew) {
|
|
248
|
-
const itemOld = findItemWithLevel(level, this.itemsActive);
|
|
249
|
-
if (itemOld && isTraceEqual(itemOld.trace, itemNew.trace)) {
|
|
250
|
-
return;
|
|
251
|
-
}
|
|
252
|
-
this.itemsActive = this.itemsActive.filter((el)=>el.level < level);
|
|
253
|
-
this.itemsActive.push(itemNew);
|
|
254
|
-
const startLevel = level;
|
|
255
|
-
while(true){
|
|
256
|
-
const built = await this.buildLevel(level, startLevel === level);
|
|
257
|
-
if (!built) {
|
|
258
|
-
break;
|
|
259
|
-
}
|
|
260
|
-
level++;
|
|
261
|
-
}
|
|
262
|
-
}
|
|
263
|
-
async toggle(level, item) {
|
|
264
|
-
let isMatch;
|
|
265
|
-
if (item.displayChildren) {
|
|
266
|
-
isMatch = true;
|
|
267
|
-
} else {
|
|
268
|
-
const itemOld = findItemWithLevel(level, this.itemsActive);
|
|
269
|
-
isMatch = !!itemOld && isTraceEqual(item.trace, itemOld.trace);
|
|
270
|
-
}
|
|
271
|
-
if (isMatch) {
|
|
272
|
-
this.itemsActive = removeItemsWithLevel(level, this.itemsActive);
|
|
273
|
-
} else {
|
|
274
|
-
this.itemsActive = replaceLevelItem(level, this.itemsActive, item);
|
|
275
|
-
}
|
|
276
|
-
await this.buildLevel(level, true);
|
|
277
|
-
}
|
|
278
|
-
async buildLevel(level, useCache) {
|
|
279
|
-
let items;
|
|
280
|
-
if (useCache) {
|
|
281
|
-
items = findItemsWithLevel(this.items, level);
|
|
282
|
-
} else {
|
|
283
|
-
const parent = findItemWithLevel(level - 1, this.itemsActive);
|
|
284
|
-
const raw = await this.itemsFn({
|
|
285
|
-
level,
|
|
286
|
-
parent
|
|
287
|
-
});
|
|
288
|
-
items = raw && raw.length > 0 ? normalizeItems(raw, {
|
|
289
|
-
level
|
|
290
|
-
}) : [];
|
|
291
|
-
}
|
|
292
|
-
if (!items || items.length === 0) {
|
|
293
|
-
this.items = this.items.filter((item)=>item.level < level);
|
|
294
|
-
this.emit('levelUpdated', level, []);
|
|
295
|
-
return false;
|
|
296
|
-
}
|
|
297
|
-
let trace = [];
|
|
298
|
-
const item = findItemWithLevel(level, this.itemsActive);
|
|
299
|
-
if (item) {
|
|
300
|
-
trace = item.trace;
|
|
301
|
-
}
|
|
302
|
-
resetItemsByTrace(items, trace);
|
|
303
|
-
this.items = replaceLevelItems(level, this.items, items);
|
|
304
|
-
this.emit('levelUpdated', level, items);
|
|
305
|
-
return true;
|
|
306
|
-
}
|
|
307
|
-
constructor(options){
|
|
308
|
-
super();
|
|
309
|
-
let itemsFn;
|
|
310
|
-
if (typeof options.items === 'function') {
|
|
311
|
-
itemsFn = options.items;
|
|
312
|
-
} else {
|
|
313
|
-
itemsFn = async ({ level })=>{
|
|
314
|
-
if (level > 0) {
|
|
315
|
-
return [];
|
|
316
|
-
}
|
|
317
|
-
return options.items;
|
|
318
|
-
};
|
|
319
|
-
}
|
|
320
|
-
this.itemsFn = itemsFn;
|
|
321
|
-
this.items = [];
|
|
322
|
-
this.itemsActive = [];
|
|
323
|
-
this.built = false;
|
|
324
|
-
this.building = false;
|
|
325
|
-
}
|
|
326
|
-
}
|
|
327
|
-
|
|
328
|
-
const sym = Symbol.for('VCNavigationManager');
|
|
329
|
-
function injectNavigationManager(app) {
|
|
330
|
-
const instance = core.inject(sym, app);
|
|
331
|
-
if (!instance) {
|
|
332
|
-
throw new Error('A navigation provider has not been provided.');
|
|
333
|
-
}
|
|
334
|
-
return instance;
|
|
335
|
-
}
|
|
336
|
-
function provideNavigationManager(manager, app) {
|
|
337
|
-
core.provide(sym, manager, app);
|
|
338
|
-
}
|
|
339
|
-
|
|
340
|
-
var SlotName = /*#__PURE__*/ function(SlotName) {
|
|
341
|
-
SlotName["ITEM"] = "item";
|
|
342
|
-
SlotName["SEPARATOR"] = "separator";
|
|
343
|
-
SlotName["LINK"] = "link";
|
|
344
|
-
SlotName["SUB"] = "sub";
|
|
345
|
-
SlotName["SUB_TITLE"] = "sub-title";
|
|
346
|
-
SlotName["SUB_ITEMS"] = "sub-items";
|
|
347
|
-
return SlotName;
|
|
348
|
-
}({});
|
|
349
|
-
var ElementType = /*#__PURE__*/ function(ElementType) {
|
|
350
|
-
ElementType["LINK"] = "link";
|
|
351
|
-
ElementType["SEPARATOR"] = "separator";
|
|
352
|
-
return ElementType;
|
|
353
|
-
}({});
|
|
354
|
-
|
|
355
|
-
const VCNavItem = vue.defineComponent({
|
|
356
|
-
props: {
|
|
357
|
-
data: {
|
|
358
|
-
type: Object,
|
|
359
|
-
required: true
|
|
360
|
-
}
|
|
361
|
-
},
|
|
362
|
-
setup (props, { slots }) {
|
|
363
|
-
const itemsNode = vue.resolveComponent('VCNavItems');
|
|
364
|
-
const options = buildComponentOptions();
|
|
365
|
-
const manager = injectNavigationManager();
|
|
366
|
-
const data = vue.toRef(props, 'data');
|
|
367
|
-
const hasChildren = vue.computed(()=>data.value.children && data.value.children.length > 0);
|
|
368
|
-
const select = async (value)=>{
|
|
369
|
-
await manager.select(data.value.level, value);
|
|
370
|
-
};
|
|
371
|
-
const toggle = async (value)=>{
|
|
372
|
-
await manager.toggle(data.value.level, value);
|
|
373
|
-
};
|
|
374
|
-
return ()=>{
|
|
375
|
-
const buildItem = ()=>{
|
|
376
|
-
// type: separator
|
|
377
|
-
if (data.value.type === ElementType.SEPARATOR) {
|
|
378
|
-
const hasSlot = core.hasNormalizedSlot(SlotName.SEPARATOR, slots);
|
|
379
|
-
if (hasSlot) {
|
|
380
|
-
return core.normalizeSlot(SlotName.SEPARATOR, {
|
|
381
|
-
data: data.value
|
|
382
|
-
}, slots);
|
|
383
|
-
}
|
|
384
|
-
return vue.h(options.separatorTag, {
|
|
385
|
-
class: options.separatorClass
|
|
386
|
-
}, data.value.name);
|
|
387
|
-
}
|
|
388
|
-
// type: group
|
|
389
|
-
if (!hasChildren.value) {
|
|
390
|
-
const hasSlot = core.hasNormalizedSlot(SlotName.LINK, slots);
|
|
391
|
-
if (hasSlot) {
|
|
392
|
-
return core.normalizeSlot(SlotName.LINK, {
|
|
393
|
-
data: data.value,
|
|
394
|
-
select,
|
|
395
|
-
isActive: data.value.active
|
|
396
|
-
}, slots);
|
|
397
|
-
}
|
|
398
|
-
const linkProps = {
|
|
399
|
-
active: data.value.active,
|
|
400
|
-
disabled: false,
|
|
401
|
-
prefetch: true
|
|
402
|
-
};
|
|
403
|
-
if (data.value.url) {
|
|
404
|
-
if (isAbsoluteURL(data.value.url) || data.value.url.startsWith('#')) {
|
|
405
|
-
linkProps.href = data.value.url;
|
|
406
|
-
if (data.value.urlTarget) {
|
|
407
|
-
linkProps.target = data.value.urlTarget;
|
|
408
|
-
}
|
|
409
|
-
} else {
|
|
410
|
-
linkProps.to = data.value.url;
|
|
411
|
-
}
|
|
412
|
-
}
|
|
413
|
-
return vue.h(link.VCLink, {
|
|
414
|
-
class: [
|
|
415
|
-
options.linkClass
|
|
416
|
-
],
|
|
417
|
-
...linkProps,
|
|
418
|
-
onClicked () {
|
|
419
|
-
if (!data.value.url) {
|
|
420
|
-
return select.call(null, data.value);
|
|
421
|
-
}
|
|
422
|
-
return undefined;
|
|
423
|
-
},
|
|
424
|
-
onClick () {
|
|
425
|
-
return select.call(null, data.value);
|
|
426
|
-
}
|
|
427
|
-
}, {
|
|
428
|
-
default: ()=>[
|
|
429
|
-
...data.value.icon ? [
|
|
430
|
-
vue.h(options.linkIconTag, {
|
|
431
|
-
class: options.linkIconClass
|
|
432
|
-
}, [
|
|
433
|
-
vue.h('i', {
|
|
434
|
-
class: data.value.icon
|
|
435
|
-
})
|
|
436
|
-
])
|
|
437
|
-
] : [],
|
|
438
|
-
vue.h(options.linkTextTag, {
|
|
439
|
-
class: options.linkTextClass
|
|
440
|
-
}, [
|
|
441
|
-
data.value.name
|
|
442
|
-
])
|
|
443
|
-
]
|
|
444
|
-
});
|
|
445
|
-
}
|
|
446
|
-
if (core.hasNormalizedSlot(SlotName.SUB, slots)) {
|
|
447
|
-
return core.normalizeSlot(SlotName.SUB, {
|
|
448
|
-
data: data.value,
|
|
449
|
-
select,
|
|
450
|
-
toggle
|
|
451
|
-
}, slots);
|
|
452
|
-
}
|
|
453
|
-
let title;
|
|
454
|
-
if (core.hasNormalizedSlot(SlotName.SUB_TITLE, slots)) {
|
|
455
|
-
title = core.normalizeSlot(SlotName.SUB_TITLE, {
|
|
456
|
-
data: data.value,
|
|
457
|
-
select,
|
|
458
|
-
toggle
|
|
459
|
-
});
|
|
460
|
-
} else {
|
|
461
|
-
title = vue.h('div', {
|
|
462
|
-
class: options.linkClass,
|
|
463
|
-
onClick ($event) {
|
|
464
|
-
$event.preventDefault();
|
|
465
|
-
return toggle(data.value);
|
|
466
|
-
}
|
|
467
|
-
}, [
|
|
468
|
-
...data.value.icon ? [
|
|
469
|
-
vue.h(options.linkIconTag, {
|
|
470
|
-
class: options.linkIconClass
|
|
471
|
-
}, [
|
|
472
|
-
vue.h('i', {
|
|
473
|
-
class: data.value.icon
|
|
474
|
-
})
|
|
475
|
-
])
|
|
476
|
-
] : [],
|
|
477
|
-
vue.h(options.linkTextTag, {
|
|
478
|
-
class: options.linkTextClass
|
|
479
|
-
}, [
|
|
480
|
-
data.value.name
|
|
481
|
-
])
|
|
482
|
-
]);
|
|
483
|
-
}
|
|
484
|
-
if (!hasChildren.value) {
|
|
485
|
-
return title;
|
|
486
|
-
}
|
|
487
|
-
let vNodes;
|
|
488
|
-
if (core.hasNormalizedSlot(SlotName.SUB_ITEMS, slots)) {
|
|
489
|
-
vNodes = core.normalizeSlot(SlotName.SUB_ITEMS, {
|
|
490
|
-
data: data.value,
|
|
491
|
-
select,
|
|
492
|
-
toggle
|
|
493
|
-
});
|
|
494
|
-
} else {
|
|
495
|
-
vNodes = vue.h(itemsNode, {
|
|
496
|
-
level: data.value.level,
|
|
497
|
-
data: data.value.children
|
|
498
|
-
});
|
|
499
|
-
}
|
|
500
|
-
return [
|
|
501
|
-
title,
|
|
502
|
-
vNodes
|
|
503
|
-
];
|
|
504
|
-
};
|
|
505
|
-
return vue.h(options.itemTag, {
|
|
506
|
-
class: [
|
|
507
|
-
options.itemClass,
|
|
508
|
-
...hasChildren.value ? [
|
|
509
|
-
options.itemNestedClass
|
|
510
|
-
] : [],
|
|
511
|
-
{
|
|
512
|
-
active: data.value.active || data.value.displayChildren
|
|
513
|
-
}
|
|
514
|
-
]
|
|
515
|
-
}, [
|
|
516
|
-
buildItem()
|
|
517
|
-
]);
|
|
518
|
-
};
|
|
519
|
-
}
|
|
520
|
-
});
|
|
521
|
-
|
|
522
|
-
const VCNavItems = vue.defineComponent({
|
|
523
|
-
props: {
|
|
524
|
-
level: {
|
|
525
|
-
type: Number,
|
|
526
|
-
default: 0
|
|
527
|
-
},
|
|
528
|
-
data: {
|
|
529
|
-
type: Array,
|
|
530
|
-
default: undefined
|
|
531
|
-
}
|
|
532
|
-
},
|
|
533
|
-
setup (props, { slots }) {
|
|
534
|
-
const options = buildComponentOptions();
|
|
535
|
-
const manager = injectNavigationManager();
|
|
536
|
-
const managerItems = vue.ref([]);
|
|
537
|
-
if (!props.data) {
|
|
538
|
-
managerItems.value = manager.getItems(props.level);
|
|
539
|
-
}
|
|
540
|
-
const counter = vue.ref(0);
|
|
541
|
-
let removeListener;
|
|
542
|
-
vue.onMounted(()=>{
|
|
543
|
-
removeListener = manager.on('levelUpdated', (level, items)=>{
|
|
544
|
-
if (level !== props.level) {
|
|
545
|
-
return;
|
|
546
|
-
}
|
|
547
|
-
managerItems.value = items;
|
|
548
|
-
counter.value++;
|
|
549
|
-
});
|
|
550
|
-
});
|
|
551
|
-
vue.onUnmounted(()=>{
|
|
552
|
-
if (typeof removeListener === 'function') {
|
|
553
|
-
removeListener();
|
|
554
|
-
removeListener = undefined;
|
|
555
|
-
}
|
|
556
|
-
});
|
|
557
|
-
const items = vue.computed(()=>{
|
|
558
|
-
if (typeof props.data !== 'undefined') {
|
|
559
|
-
return props.data;
|
|
560
|
-
}
|
|
561
|
-
return managerItems.value;
|
|
562
|
-
});
|
|
563
|
-
return ()=>{
|
|
564
|
-
const vNodes = [];
|
|
565
|
-
for(let i = 0; i < items.value.length; i++){
|
|
566
|
-
if (!items.value[i].display && !items.value[i].displayChildren) {
|
|
567
|
-
continue;
|
|
568
|
-
}
|
|
569
|
-
let vNode;
|
|
570
|
-
if (core.hasNormalizedSlot(SlotName.ITEM, slots)) {
|
|
571
|
-
vNode = core.normalizeSlot(SlotName.ITEM, {
|
|
572
|
-
data: items.value[i]
|
|
573
|
-
}, slots);
|
|
574
|
-
} else {
|
|
575
|
-
vNode = vue.h(VCNavItem, {
|
|
576
|
-
key: `${i}:${counter.value}`,
|
|
577
|
-
data: items.value[i]
|
|
578
|
-
});
|
|
579
|
-
}
|
|
580
|
-
vNodes.push(vNode);
|
|
581
|
-
}
|
|
582
|
-
return vue.h(options.groupTag, {
|
|
583
|
-
class: options.groupClass
|
|
584
|
-
}, vNodes);
|
|
585
|
-
};
|
|
586
|
-
}
|
|
587
|
-
});
|
|
588
|
-
|
|
589
|
-
function install(instance, options) {
|
|
590
|
-
const manager = new NavigationManager({
|
|
591
|
-
items: options.items
|
|
592
|
-
});
|
|
593
|
-
provideNavigationManager(manager, instance);
|
|
594
|
-
const storeManager = core.installStoreManager(instance);
|
|
595
|
-
if (options.storeManager) {
|
|
596
|
-
core.applyStoreManagerOptions(storeManager, options.storeManager);
|
|
597
|
-
}
|
|
598
|
-
Object.entries({
|
|
599
|
-
VCNavItem,
|
|
600
|
-
VCNavItems
|
|
601
|
-
}).forEach(([componentName, component])=>{
|
|
602
|
-
instance.component(componentName, component);
|
|
603
|
-
});
|
|
604
|
-
}
|
|
605
|
-
var index = {
|
|
606
|
-
install
|
|
607
|
-
};
|
|
608
|
-
|
|
609
|
-
exports.NavigationManager = NavigationManager;
|
|
610
|
-
exports.VCNavItem = VCNavItem;
|
|
611
|
-
exports.VCNavItems = VCNavItems;
|
|
612
|
-
exports.default = index;
|
|
613
|
-
exports.injectNavigationManager = injectNavigationManager;
|
|
614
|
-
exports.install = install;
|
|
615
|
-
exports.provideNavigationManager = provideNavigationManager;
|
|
616
|
-
module.exports = Object.assign(exports.default, exports);
|
|
617
|
-
//# sourceMappingURL=index.cjs.map
|