@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.mjs
CHANGED
|
@@ -1,606 +1,858 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { EventEmitter } from
|
|
3
|
-
import { VCLink } from
|
|
4
|
-
import { defineComponent,
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const manager = createComponentOptionsManager({
|
|
8
|
-
name: 'navigation'
|
|
9
|
-
});
|
|
10
|
-
return {
|
|
11
|
-
groupClass: mergeOption('class', manager.get('groupClass'), 'vc-nav-items'),
|
|
12
|
-
groupTag: manager.get('groupTag') || 'ul',
|
|
13
|
-
itemClass: mergeOption('class', manager.get('itemClass'), 'vc-nav-item'),
|
|
14
|
-
itemNestedClass: mergeOption('class', manager.get('itemNestedClass'), 'vc-nav-item-nested'),
|
|
15
|
-
itemTag: manager.get('itemTag') || 'li',
|
|
16
|
-
separatorTag: manager.get('separatorTag') || 'div',
|
|
17
|
-
separatorClass: mergeOption('class', manager.get('linkIconClass'), 'vc-nav-separator'),
|
|
18
|
-
linkIconTag: manager.get('linkIconTag') || 'div',
|
|
19
|
-
linkIconClass: mergeOption('class', manager.get('linkIconClass'), 'vc-nav-link-icon'),
|
|
20
|
-
linkClass: mergeOption('class', manager.get('linkClass'), 'vc-nav-link'),
|
|
21
|
-
linkRootClass: mergeOption('class', manager.get('linkRootClass'), 'vc-nav-link-root'),
|
|
22
|
-
linkTextTag: manager.get('linkTextTag') || 'div',
|
|
23
|
-
linkTextClass: mergeOption('class', manager.get('linkTextClass'), 'vc-nav-link-text')
|
|
24
|
-
};
|
|
25
|
-
}
|
|
26
|
-
|
|
1
|
+
import { hasNormalizedSlot, inject, installDefaultsManager, installThemeManager, normalizeSlot, provide, useArrowNavigation, useComponentTheme } from "@vuecs/core";
|
|
2
|
+
import { EventEmitter } from "@posva/event-emitter";
|
|
3
|
+
import { VCLink } from "@vuecs/link";
|
|
4
|
+
import { computed, defineComponent, h, inject as inject$1, mergeProps, onMounted, onUnmounted, provide as provide$1, ref, resolveComponent, toRef } from "vue";
|
|
5
|
+
import { StepperDescription, StepperIndicator, StepperItem, StepperRoot, StepperSeparator, StepperTitle, StepperTrigger } from "reka-ui";
|
|
6
|
+
//#region src/helpers/match.ts
|
|
27
7
|
function calculateItemScoreForPath(item, currentPath) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
if (item.url) {
|
|
40
|
-
if (item.url === currentPath) {
|
|
41
|
-
return 3;
|
|
42
|
-
}
|
|
43
|
-
if (currentPath.startsWith(item.url)) {
|
|
44
|
-
return 2;
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
return 0;
|
|
8
|
+
if (item.url === "/") return 1;
|
|
9
|
+
if (item.activeMatch) {
|
|
10
|
+
if (item.activeMatch === currentPath) return 6;
|
|
11
|
+
if (currentPath.startsWith(item.activeMatch)) return 4;
|
|
12
|
+
}
|
|
13
|
+
if (item.url) {
|
|
14
|
+
if (item.url === currentPath) return 3;
|
|
15
|
+
if (currentPath.startsWith(item.url)) return 2;
|
|
16
|
+
}
|
|
17
|
+
return 0;
|
|
48
18
|
}
|
|
49
19
|
function findItemMatchesIF(items, options, parent) {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
}
|
|
66
|
-
output.push({
|
|
67
|
-
data: item,
|
|
68
|
-
score
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
return output.sort((a, b)=>b.score - a.score);
|
|
20
|
+
const output = [];
|
|
21
|
+
for (const item of items) {
|
|
22
|
+
let { score } = parent;
|
|
23
|
+
if (options.path) score += calculateItemScoreForPath(item, options.path);
|
|
24
|
+
if (item.default) score += 1;
|
|
25
|
+
if (item.children) {
|
|
26
|
+
const childMatches = findItemMatchesIF(item.children, options, { score });
|
|
27
|
+
output.push(...childMatches);
|
|
28
|
+
}
|
|
29
|
+
output.push({
|
|
30
|
+
data: item,
|
|
31
|
+
score
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
return output.sort((a, b) => b.score - a.score);
|
|
72
35
|
}
|
|
73
36
|
function findBestItemMatches(items, options = {}) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (!first) {
|
|
79
|
-
return [];
|
|
80
|
-
}
|
|
81
|
-
return result.filter((match)=>match.score === first.score).map((match)=>match.data);
|
|
37
|
+
const result = findItemMatchesIF(items, options, { score: 0 });
|
|
38
|
+
const [first] = result;
|
|
39
|
+
if (!first) return [];
|
|
40
|
+
return result.filter((match) => match.score === first.score).map((match) => match.data);
|
|
82
41
|
}
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
item.name
|
|
97
|
-
],
|
|
98
|
-
meta: item.meta || {}
|
|
99
|
-
};
|
|
100
|
-
if (!item.children) {
|
|
101
|
-
return output;
|
|
102
|
-
}
|
|
103
|
-
for(let i = 0; i < item.children.length; i++){
|
|
104
|
-
output.children.push(normalizeItemIF(item.children[i], defaults, output.trace));
|
|
105
|
-
}
|
|
106
|
-
return output;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/helpers/normalize.ts
|
|
44
|
+
function normalizeItemIF(item, defaults, trace) {
|
|
45
|
+
const output = {
|
|
46
|
+
...item,
|
|
47
|
+
level: defaults.level,
|
|
48
|
+
children: [],
|
|
49
|
+
trace: [...trace, item.name],
|
|
50
|
+
meta: item.meta || {}
|
|
51
|
+
};
|
|
52
|
+
if (!item.children) return output;
|
|
53
|
+
for (let i = 0; i < item.children.length; i++) output.children.push(normalizeItemIF(item.children[i], defaults, output.trace));
|
|
54
|
+
return output;
|
|
107
55
|
}
|
|
108
56
|
function normalizeItem(item, defaults) {
|
|
109
|
-
|
|
57
|
+
return normalizeItemIF(item, defaults, []);
|
|
110
58
|
}
|
|
111
59
|
function normalizeItems(items, options) {
|
|
112
|
-
|
|
60
|
+
return items.map((item) => normalizeItem(item, options));
|
|
113
61
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
*/ function isTraceEqual(a, b) {
|
|
121
|
-
if (a.length !== b.length) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
for(let i = 0; i < a.length; i++){
|
|
125
|
-
if (a[i] !== b[i]) {
|
|
126
|
-
return false;
|
|
127
|
-
}
|
|
128
|
-
}
|
|
129
|
-
return true;
|
|
62
|
+
//#endregion
|
|
63
|
+
//#region src/helpers/trace.ts
|
|
64
|
+
function isTraceEqual(a, b) {
|
|
65
|
+
if (a.length !== b.length) return false;
|
|
66
|
+
for (const [i, element] of a.entries()) if (element !== b[i]) return false;
|
|
67
|
+
return true;
|
|
130
68
|
}
|
|
131
69
|
function isTracePartOf(item, parent) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
return false;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return true;
|
|
70
|
+
for (const [i, element] of item.entries()) if (parent[i] !== element) return false;
|
|
71
|
+
return true;
|
|
138
72
|
}
|
|
139
|
-
|
|
73
|
+
//#endregion
|
|
74
|
+
//#region src/helpers/reset.ts
|
|
140
75
|
function resetItemsByTraceIF(items, trace) {
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
}
|
|
151
|
-
item.children = resetItemsByTraceIF(item.children, trace);
|
|
152
|
-
}
|
|
153
|
-
return items;
|
|
76
|
+
for (const item of items) {
|
|
77
|
+
const isEqual = isTraceEqual(item.trace, trace);
|
|
78
|
+
item.active = isEqual;
|
|
79
|
+
item.display = true;
|
|
80
|
+
if (isEqual) item.displayChildren = true;
|
|
81
|
+
else item.displayChildren = isTracePartOf(item.trace, trace);
|
|
82
|
+
item.children = resetItemsByTraceIF(item.children, trace);
|
|
83
|
+
}
|
|
84
|
+
return items;
|
|
154
85
|
}
|
|
155
86
|
function resetItemsByTrace(items, trace) {
|
|
156
|
-
|
|
87
|
+
return resetItemsByTraceIF(items, trace);
|
|
157
88
|
}
|
|
158
|
-
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/helpers/level.ts
|
|
159
91
|
function findItemsWithLevel(items, tier) {
|
|
160
|
-
|
|
92
|
+
return items.filter((item) => item.level === tier);
|
|
161
93
|
}
|
|
162
94
|
function findItemWithLevel(tier, items) {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
return data[0];
|
|
166
|
-
}
|
|
167
|
-
return undefined;
|
|
95
|
+
const data = findItemsWithLevel(items, tier);
|
|
96
|
+
if (data.length >= 1) return data[0];
|
|
168
97
|
}
|
|
169
98
|
function removeItemsWithLevel(tier, items) {
|
|
170
|
-
|
|
99
|
+
return items.filter((item) => item.level !== tier);
|
|
171
100
|
}
|
|
172
101
|
function replaceLevelItem(tier, input, next) {
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
];
|
|
180
|
-
}
|
|
181
|
-
return output;
|
|
102
|
+
const output = removeItemsWithLevel(tier, input);
|
|
103
|
+
if (next) {
|
|
104
|
+
next.level = tier;
|
|
105
|
+
return [...output, next];
|
|
106
|
+
}
|
|
107
|
+
return output;
|
|
182
108
|
}
|
|
183
109
|
function replaceLevelItems(tier, src, next) {
|
|
184
|
-
|
|
185
|
-
return [
|
|
186
|
-
...componentsExisting,
|
|
187
|
-
...next
|
|
188
|
-
];
|
|
110
|
+
return [...removeItemsWithLevel(tier, src), ...next];
|
|
189
111
|
}
|
|
190
|
-
|
|
112
|
+
//#endregion
|
|
113
|
+
//#region src/helpers/url.ts
|
|
191
114
|
function isAbsoluteURL(str) {
|
|
192
|
-
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
class NavigationManager extends EventEmitter {
|
|
196
|
-
getItems(tier) {
|
|
197
|
-
if (typeof tier === 'undefined') {
|
|
198
|
-
return this.items;
|
|
199
|
-
}
|
|
200
|
-
return this.items.filter((item)=>item.level === tier);
|
|
201
|
-
}
|
|
202
|
-
reset() {
|
|
203
|
-
this.built = false;
|
|
204
|
-
this.items = [];
|
|
205
|
-
this.itemsActive = [];
|
|
206
|
-
}
|
|
207
|
-
async build(options) {
|
|
208
|
-
if (this.built || this.building) {
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
this.building = true;
|
|
212
|
-
this.emit('building');
|
|
213
|
-
let parent;
|
|
214
|
-
let level = 0;
|
|
215
|
-
while(true){
|
|
216
|
-
const raw = await this.itemsFn({
|
|
217
|
-
level,
|
|
218
|
-
parent
|
|
219
|
-
});
|
|
220
|
-
if (!raw || raw.length === 0) {
|
|
221
|
-
break;
|
|
222
|
-
}
|
|
223
|
-
const items = normalizeItems(raw, {
|
|
224
|
-
level
|
|
225
|
-
});
|
|
226
|
-
const matches = findBestItemMatches(items, {
|
|
227
|
-
path: options.path
|
|
228
|
-
});
|
|
229
|
-
const [match] = matches;
|
|
230
|
-
if (!match) {
|
|
231
|
-
break;
|
|
232
|
-
}
|
|
233
|
-
this.itemsActive.push(match);
|
|
234
|
-
await this.buildLevel(level);
|
|
235
|
-
parent = match;
|
|
236
|
-
level++;
|
|
237
|
-
}
|
|
238
|
-
this.building = false;
|
|
239
|
-
this.built = true;
|
|
240
|
-
this.emit('built');
|
|
241
|
-
this.emit('updated', this.items);
|
|
242
|
-
}
|
|
243
|
-
async select(level, itemNew) {
|
|
244
|
-
const itemOld = findItemWithLevel(level, this.itemsActive);
|
|
245
|
-
if (itemOld && isTraceEqual(itemOld.trace, itemNew.trace)) {
|
|
246
|
-
return;
|
|
247
|
-
}
|
|
248
|
-
this.itemsActive = this.itemsActive.filter((el)=>el.level < level);
|
|
249
|
-
this.itemsActive.push(itemNew);
|
|
250
|
-
const startLevel = level;
|
|
251
|
-
while(true){
|
|
252
|
-
const built = await this.buildLevel(level, startLevel === level);
|
|
253
|
-
if (!built) {
|
|
254
|
-
break;
|
|
255
|
-
}
|
|
256
|
-
level++;
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
async toggle(level, item) {
|
|
260
|
-
let isMatch;
|
|
261
|
-
if (item.displayChildren) {
|
|
262
|
-
isMatch = true;
|
|
263
|
-
} else {
|
|
264
|
-
const itemOld = findItemWithLevel(level, this.itemsActive);
|
|
265
|
-
isMatch = !!itemOld && isTraceEqual(item.trace, itemOld.trace);
|
|
266
|
-
}
|
|
267
|
-
if (isMatch) {
|
|
268
|
-
this.itemsActive = removeItemsWithLevel(level, this.itemsActive);
|
|
269
|
-
} else {
|
|
270
|
-
this.itemsActive = replaceLevelItem(level, this.itemsActive, item);
|
|
271
|
-
}
|
|
272
|
-
await this.buildLevel(level, true);
|
|
273
|
-
}
|
|
274
|
-
async buildLevel(level, useCache) {
|
|
275
|
-
let items;
|
|
276
|
-
if (useCache) {
|
|
277
|
-
items = findItemsWithLevel(this.items, level);
|
|
278
|
-
} else {
|
|
279
|
-
const parent = findItemWithLevel(level - 1, this.itemsActive);
|
|
280
|
-
const raw = await this.itemsFn({
|
|
281
|
-
level,
|
|
282
|
-
parent
|
|
283
|
-
});
|
|
284
|
-
items = raw && raw.length > 0 ? normalizeItems(raw, {
|
|
285
|
-
level
|
|
286
|
-
}) : [];
|
|
287
|
-
}
|
|
288
|
-
if (!items || items.length === 0) {
|
|
289
|
-
this.items = this.items.filter((item)=>item.level < level);
|
|
290
|
-
this.emit('levelUpdated', level, []);
|
|
291
|
-
return false;
|
|
292
|
-
}
|
|
293
|
-
let trace = [];
|
|
294
|
-
const item = findItemWithLevel(level, this.itemsActive);
|
|
295
|
-
if (item) {
|
|
296
|
-
trace = item.trace;
|
|
297
|
-
}
|
|
298
|
-
resetItemsByTrace(items, trace);
|
|
299
|
-
this.items = replaceLevelItems(level, this.items, items);
|
|
300
|
-
this.emit('levelUpdated', level, items);
|
|
301
|
-
return true;
|
|
302
|
-
}
|
|
303
|
-
constructor(options){
|
|
304
|
-
super();
|
|
305
|
-
let itemsFn;
|
|
306
|
-
if (typeof options.items === 'function') {
|
|
307
|
-
itemsFn = options.items;
|
|
308
|
-
} else {
|
|
309
|
-
itemsFn = async ({ level })=>{
|
|
310
|
-
if (level > 0) {
|
|
311
|
-
return [];
|
|
312
|
-
}
|
|
313
|
-
return options.items;
|
|
314
|
-
};
|
|
315
|
-
}
|
|
316
|
-
this.itemsFn = itemsFn;
|
|
317
|
-
this.items = [];
|
|
318
|
-
this.itemsActive = [];
|
|
319
|
-
this.built = false;
|
|
320
|
-
this.building = false;
|
|
321
|
-
}
|
|
115
|
+
return str.substring(0, 7) === "http://" || str.substring(0, 8) === "https://";
|
|
322
116
|
}
|
|
323
|
-
|
|
324
|
-
|
|
117
|
+
//#endregion
|
|
118
|
+
//#region src/manager/module.ts
|
|
119
|
+
var NavigationManager = class extends EventEmitter {
|
|
120
|
+
itemsActive;
|
|
121
|
+
items;
|
|
122
|
+
itemsFn;
|
|
123
|
+
built;
|
|
124
|
+
building;
|
|
125
|
+
constructor(options) {
|
|
126
|
+
super();
|
|
127
|
+
let itemsFn;
|
|
128
|
+
if (typeof options.items === "function") itemsFn = options.items;
|
|
129
|
+
else itemsFn = async ({ level }) => {
|
|
130
|
+
if (level > 0) return [];
|
|
131
|
+
return options.items;
|
|
132
|
+
};
|
|
133
|
+
this.itemsFn = itemsFn;
|
|
134
|
+
this.items = [];
|
|
135
|
+
this.itemsActive = [];
|
|
136
|
+
this.built = false;
|
|
137
|
+
this.building = false;
|
|
138
|
+
}
|
|
139
|
+
getItems(tier) {
|
|
140
|
+
if (typeof tier === "undefined") return this.items;
|
|
141
|
+
return this.items.filter((item) => item.level === tier);
|
|
142
|
+
}
|
|
143
|
+
reset() {
|
|
144
|
+
this.built = false;
|
|
145
|
+
this.items = [];
|
|
146
|
+
this.itemsActive = [];
|
|
147
|
+
}
|
|
148
|
+
async build(options) {
|
|
149
|
+
if (this.built || this.building) return;
|
|
150
|
+
this.building = true;
|
|
151
|
+
this.emit("building");
|
|
152
|
+
let parent;
|
|
153
|
+
let level = 0;
|
|
154
|
+
while (true) {
|
|
155
|
+
const raw = await this.itemsFn({
|
|
156
|
+
level,
|
|
157
|
+
parent
|
|
158
|
+
});
|
|
159
|
+
if (!raw || raw.length === 0) break;
|
|
160
|
+
const [match] = findBestItemMatches(normalizeItems(raw, { level }), { path: options.path });
|
|
161
|
+
if (!match) break;
|
|
162
|
+
this.itemsActive.push(match);
|
|
163
|
+
await this.buildLevel(level);
|
|
164
|
+
parent = match;
|
|
165
|
+
level++;
|
|
166
|
+
}
|
|
167
|
+
this.building = false;
|
|
168
|
+
this.built = true;
|
|
169
|
+
this.emit("built");
|
|
170
|
+
this.emit("updated", this.items);
|
|
171
|
+
}
|
|
172
|
+
async select(level, itemNew) {
|
|
173
|
+
const itemOld = findItemWithLevel(level, this.itemsActive);
|
|
174
|
+
if (itemOld && isTraceEqual(itemOld.trace, itemNew.trace)) return;
|
|
175
|
+
this.itemsActive = this.itemsActive.filter((el) => el.level < level);
|
|
176
|
+
this.itemsActive.push(itemNew);
|
|
177
|
+
const startLevel = level;
|
|
178
|
+
while (true) {
|
|
179
|
+
if (!await this.buildLevel(level, startLevel === level)) break;
|
|
180
|
+
level++;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
async toggle(level, item) {
|
|
184
|
+
let isMatch;
|
|
185
|
+
if (item.displayChildren) isMatch = true;
|
|
186
|
+
else {
|
|
187
|
+
const itemOld = findItemWithLevel(level, this.itemsActive);
|
|
188
|
+
isMatch = !!itemOld && isTraceEqual(item.trace, itemOld.trace);
|
|
189
|
+
}
|
|
190
|
+
if (isMatch) this.itemsActive = removeItemsWithLevel(level, this.itemsActive);
|
|
191
|
+
else this.itemsActive = replaceLevelItem(level, this.itemsActive, item);
|
|
192
|
+
await this.buildLevel(level, true);
|
|
193
|
+
}
|
|
194
|
+
async buildLevel(level, useCache) {
|
|
195
|
+
let items;
|
|
196
|
+
if (useCache) items = findItemsWithLevel(this.items, level);
|
|
197
|
+
else {
|
|
198
|
+
const parent = findItemWithLevel(level - 1, this.itemsActive);
|
|
199
|
+
const raw = await this.itemsFn({
|
|
200
|
+
level,
|
|
201
|
+
parent
|
|
202
|
+
});
|
|
203
|
+
items = raw && raw.length > 0 ? normalizeItems(raw, { level }) : [];
|
|
204
|
+
}
|
|
205
|
+
if (!items || items.length === 0) {
|
|
206
|
+
this.items = this.items.filter((item) => item.level < level);
|
|
207
|
+
this.emit("levelUpdated", level, []);
|
|
208
|
+
return false;
|
|
209
|
+
}
|
|
210
|
+
let trace = [];
|
|
211
|
+
const item = findItemWithLevel(level, this.itemsActive);
|
|
212
|
+
if (item) trace = item.trace;
|
|
213
|
+
resetItemsByTrace(items, trace);
|
|
214
|
+
this.items = replaceLevelItems(level, this.items, items);
|
|
215
|
+
this.emit("levelUpdated", level, items);
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
};
|
|
219
|
+
//#endregion
|
|
220
|
+
//#region src/manager/singleton.ts
|
|
221
|
+
const sym = Symbol.for("VCNavigationManager");
|
|
325
222
|
function injectNavigationManager(app) {
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
}
|
|
330
|
-
return instance;
|
|
223
|
+
const instance = inject(sym, app);
|
|
224
|
+
if (!instance) throw new Error("A navigation provider has not been provided.");
|
|
225
|
+
return instance;
|
|
331
226
|
}
|
|
332
227
|
function provideNavigationManager(manager, app) {
|
|
333
|
-
|
|
228
|
+
provide(sym, manager, app);
|
|
334
229
|
}
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
230
|
+
//#endregion
|
|
231
|
+
//#region src/components/items/theme.ts
|
|
232
|
+
/**
|
|
233
|
+
* Default classes for the `navigation` theme entry. Shared between
|
|
234
|
+
* `<VCNavItems>` (the container) and `<VCNavItem>` (the per-row
|
|
235
|
+
* component) — both call `useComponentTheme('navigation', …)` with
|
|
236
|
+
* the same slot defaults, so the source of truth lives here.
|
|
237
|
+
*/
|
|
238
|
+
const navigationThemeDefaults = { classes: {
|
|
239
|
+
group: "vc-nav-items",
|
|
240
|
+
item: "vc-nav-item",
|
|
241
|
+
itemNested: "vc-nav-item-nested",
|
|
242
|
+
separator: "vc-nav-separator",
|
|
243
|
+
link: "vc-nav-link",
|
|
244
|
+
linkRoot: "vc-nav-link-root",
|
|
245
|
+
linkIcon: "vc-nav-link-icon",
|
|
246
|
+
linkText: "vc-nav-link-text"
|
|
247
|
+
} };
|
|
351
248
|
const VCNavItem = defineComponent({
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
] : [],
|
|
473
|
-
h(options.linkTextTag, {
|
|
474
|
-
class: options.linkTextClass
|
|
475
|
-
}, [
|
|
476
|
-
data.value.name
|
|
477
|
-
])
|
|
478
|
-
]);
|
|
479
|
-
}
|
|
480
|
-
if (!hasChildren.value) {
|
|
481
|
-
return title;
|
|
482
|
-
}
|
|
483
|
-
let vNodes;
|
|
484
|
-
if (hasNormalizedSlot(SlotName.SUB_ITEMS, slots)) {
|
|
485
|
-
vNodes = normalizeSlot(SlotName.SUB_ITEMS, {
|
|
486
|
-
data: data.value,
|
|
487
|
-
select,
|
|
488
|
-
toggle
|
|
489
|
-
});
|
|
490
|
-
} else {
|
|
491
|
-
vNodes = h(itemsNode, {
|
|
492
|
-
level: data.value.level,
|
|
493
|
-
data: data.value.children
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
return [
|
|
497
|
-
title,
|
|
498
|
-
vNodes
|
|
499
|
-
];
|
|
500
|
-
};
|
|
501
|
-
return h(options.itemTag, {
|
|
502
|
-
class: [
|
|
503
|
-
options.itemClass,
|
|
504
|
-
...hasChildren.value ? [
|
|
505
|
-
options.itemNestedClass
|
|
506
|
-
] : [],
|
|
507
|
-
{
|
|
508
|
-
active: data.value.active || data.value.displayChildren
|
|
509
|
-
}
|
|
510
|
-
]
|
|
511
|
-
}, [
|
|
512
|
-
buildItem()
|
|
513
|
-
]);
|
|
514
|
-
};
|
|
515
|
-
}
|
|
249
|
+
name: "VCNavItem",
|
|
250
|
+
props: {
|
|
251
|
+
data: {
|
|
252
|
+
type: Object,
|
|
253
|
+
required: true
|
|
254
|
+
},
|
|
255
|
+
themeClass: {
|
|
256
|
+
type: Object,
|
|
257
|
+
default: void 0
|
|
258
|
+
},
|
|
259
|
+
themeVariant: {
|
|
260
|
+
type: Object,
|
|
261
|
+
default: void 0
|
|
262
|
+
}
|
|
263
|
+
},
|
|
264
|
+
slots: Object,
|
|
265
|
+
setup(props, { slots }) {
|
|
266
|
+
const itemsNode = resolveComponent("VCNavItems");
|
|
267
|
+
const theme = useComponentTheme("navigation", props, navigationThemeDefaults);
|
|
268
|
+
const manager = injectNavigationManager();
|
|
269
|
+
const data = toRef(props, "data");
|
|
270
|
+
const hasChildren = computed(() => data.value.children && data.value.children.length > 0);
|
|
271
|
+
const select = async (value) => {
|
|
272
|
+
await manager.select(data.value.level, value);
|
|
273
|
+
};
|
|
274
|
+
const renderIcon = (icon) => {
|
|
275
|
+
if (icon.includes(":")) return h(resolveComponent("VCIcon"), { name: icon });
|
|
276
|
+
return h("i", { class: icon });
|
|
277
|
+
};
|
|
278
|
+
const toggle = async (value) => {
|
|
279
|
+
await manager.toggle(data.value.level, value);
|
|
280
|
+
};
|
|
281
|
+
return () => {
|
|
282
|
+
const resolved = theme.value;
|
|
283
|
+
const buildItem = () => {
|
|
284
|
+
if (data.value.type === "separator") {
|
|
285
|
+
if (hasNormalizedSlot("separator", slots)) return normalizeSlot("separator", { data: data.value }, slots);
|
|
286
|
+
return h("div", { class: resolved.separator || void 0 }, data.value.name);
|
|
287
|
+
}
|
|
288
|
+
if (!hasChildren.value) {
|
|
289
|
+
if (hasNormalizedSlot("link", slots)) return normalizeSlot("link", {
|
|
290
|
+
data: data.value,
|
|
291
|
+
select,
|
|
292
|
+
isActive: data.value.active
|
|
293
|
+
}, slots);
|
|
294
|
+
const linkProps = {
|
|
295
|
+
active: data.value.active,
|
|
296
|
+
disabled: false,
|
|
297
|
+
prefetch: true
|
|
298
|
+
};
|
|
299
|
+
if (data.value.url) if (isAbsoluteURL(data.value.url) || data.value.url.startsWith("#")) {
|
|
300
|
+
linkProps.href = data.value.url;
|
|
301
|
+
if (data.value.urlTarget) linkProps.target = data.value.urlTarget;
|
|
302
|
+
} else linkProps.to = data.value.url;
|
|
303
|
+
return h(VCLink, {
|
|
304
|
+
class: [resolved.link],
|
|
305
|
+
"data-vc-collection-item": "",
|
|
306
|
+
...linkProps,
|
|
307
|
+
onClicked() {
|
|
308
|
+
if (!data.value.url) return select.call(null, data.value);
|
|
309
|
+
},
|
|
310
|
+
onClick() {
|
|
311
|
+
return select.call(null, data.value);
|
|
312
|
+
}
|
|
313
|
+
}, { default: () => [...data.value.icon ? [h("div", { class: resolved.linkIcon || void 0 }, [renderIcon(data.value.icon)])] : [], h("div", { class: resolved.linkText || void 0 }, [data.value.name])] });
|
|
314
|
+
}
|
|
315
|
+
if (hasNormalizedSlot("sub", slots)) return normalizeSlot("sub", {
|
|
316
|
+
data: data.value,
|
|
317
|
+
select,
|
|
318
|
+
toggle
|
|
319
|
+
}, slots);
|
|
320
|
+
let title;
|
|
321
|
+
if (hasNormalizedSlot("sub-title", slots)) title = normalizeSlot("sub-title", {
|
|
322
|
+
data: data.value,
|
|
323
|
+
select,
|
|
324
|
+
toggle
|
|
325
|
+
});
|
|
326
|
+
else title = h("div", {
|
|
327
|
+
class: resolved.link,
|
|
328
|
+
"data-vc-collection-item": "",
|
|
329
|
+
"data-state": data.value.displayChildren ? "open" : "closed",
|
|
330
|
+
"data-active": data.value.active ? "" : void 0,
|
|
331
|
+
tabindex: 0,
|
|
332
|
+
role: "button",
|
|
333
|
+
"aria-expanded": data.value.displayChildren ? "true" : "false",
|
|
334
|
+
onClick($event) {
|
|
335
|
+
$event.preventDefault();
|
|
336
|
+
return toggle(data.value);
|
|
337
|
+
},
|
|
338
|
+
onKeydown($event) {
|
|
339
|
+
if ($event.key === "Enter" || $event.key === " ") {
|
|
340
|
+
$event.preventDefault();
|
|
341
|
+
return toggle(data.value);
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
}, [...data.value.icon ? [h("div", { class: resolved.linkIcon || void 0 }, [renderIcon(data.value.icon)])] : [], h("div", { class: resolved.linkText || void 0 }, [data.value.name])]);
|
|
345
|
+
if (!hasChildren.value) return title;
|
|
346
|
+
let vNodes;
|
|
347
|
+
if (hasNormalizedSlot("sub-items", slots)) vNodes = normalizeSlot("sub-items", {
|
|
348
|
+
data: data.value,
|
|
349
|
+
select,
|
|
350
|
+
toggle
|
|
351
|
+
});
|
|
352
|
+
else vNodes = h(itemsNode, {
|
|
353
|
+
level: data.value.level,
|
|
354
|
+
data: data.value.children
|
|
355
|
+
});
|
|
356
|
+
return [title, vNodes];
|
|
357
|
+
};
|
|
358
|
+
return h("li", {
|
|
359
|
+
class: [
|
|
360
|
+
resolved.item,
|
|
361
|
+
...hasChildren.value ? [resolved.itemNested] : [],
|
|
362
|
+
{ active: data.value.active || data.value.displayChildren }
|
|
363
|
+
],
|
|
364
|
+
"data-active": data.value.active || data.value.displayChildren ? "" : void 0,
|
|
365
|
+
...hasChildren.value ? { "data-state": data.value.displayChildren ? "open" : "closed" } : {}
|
|
366
|
+
}, [buildItem()]);
|
|
367
|
+
};
|
|
368
|
+
}
|
|
516
369
|
});
|
|
517
|
-
|
|
518
370
|
const VCNavItems = defineComponent({
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
371
|
+
name: "VCNavItems",
|
|
372
|
+
props: {
|
|
373
|
+
level: {
|
|
374
|
+
type: Number,
|
|
375
|
+
default: 0
|
|
376
|
+
},
|
|
377
|
+
data: {
|
|
378
|
+
type: Array,
|
|
379
|
+
default: void 0
|
|
380
|
+
},
|
|
381
|
+
themeClass: {
|
|
382
|
+
type: Object,
|
|
383
|
+
default: void 0
|
|
384
|
+
},
|
|
385
|
+
themeVariant: {
|
|
386
|
+
type: Object,
|
|
387
|
+
default: void 0
|
|
388
|
+
}
|
|
389
|
+
},
|
|
390
|
+
slots: Object,
|
|
391
|
+
setup(props, { slots }) {
|
|
392
|
+
const theme = useComponentTheme("navigation", props, navigationThemeDefaults);
|
|
393
|
+
const rootRef = ref(null);
|
|
394
|
+
const onKeyDown = (event) => {
|
|
395
|
+
useArrowNavigation(event, event.target, rootRef.value, {
|
|
396
|
+
arrowKeyOptions: "vertical",
|
|
397
|
+
focus: true,
|
|
398
|
+
loop: true
|
|
399
|
+
});
|
|
400
|
+
};
|
|
401
|
+
const manager = injectNavigationManager();
|
|
402
|
+
const managerItems = ref([]);
|
|
403
|
+
if (!props.data) managerItems.value = manager.getItems(props.level);
|
|
404
|
+
const counter = ref(0);
|
|
405
|
+
let removeListener;
|
|
406
|
+
onMounted(() => {
|
|
407
|
+
removeListener = manager.on("levelUpdated", (level, items) => {
|
|
408
|
+
if (level !== props.level) return;
|
|
409
|
+
managerItems.value = items;
|
|
410
|
+
counter.value++;
|
|
411
|
+
});
|
|
412
|
+
});
|
|
413
|
+
onUnmounted(() => {
|
|
414
|
+
if (typeof removeListener === "function") {
|
|
415
|
+
removeListener();
|
|
416
|
+
removeListener = void 0;
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
const items = computed(() => {
|
|
420
|
+
if (typeof props.data !== "undefined") return props.data;
|
|
421
|
+
return managerItems.value;
|
|
422
|
+
});
|
|
423
|
+
return () => {
|
|
424
|
+
const resolved = theme.value;
|
|
425
|
+
const vNodes = [];
|
|
426
|
+
for (let i = 0; i < items.value.length; i++) {
|
|
427
|
+
if (!items.value[i].display && !items.value[i].displayChildren) continue;
|
|
428
|
+
let vNode;
|
|
429
|
+
if (hasNormalizedSlot("item", slots)) vNode = normalizeSlot("item", { data: items.value[i] }, slots);
|
|
430
|
+
else vNode = h(VCNavItem, {
|
|
431
|
+
key: `${i}:${counter.value}`,
|
|
432
|
+
data: items.value[i]
|
|
433
|
+
});
|
|
434
|
+
vNodes.push(vNode);
|
|
435
|
+
}
|
|
436
|
+
const isRoot = props.level === 0;
|
|
437
|
+
return h("ul", {
|
|
438
|
+
class: resolved.group || void 0,
|
|
439
|
+
...isRoot ? {
|
|
440
|
+
ref: rootRef,
|
|
441
|
+
onKeydown: onKeyDown
|
|
442
|
+
} : {}
|
|
443
|
+
}, vNodes);
|
|
444
|
+
};
|
|
445
|
+
}
|
|
583
446
|
});
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
provideNavigationManager(manager, instance);
|
|
590
|
-
const storeManager = installStoreManager(instance);
|
|
591
|
-
if (options.storeManager) {
|
|
592
|
-
applyStoreManagerOptions(storeManager, options.storeManager);
|
|
593
|
-
}
|
|
594
|
-
Object.entries({
|
|
595
|
-
VCNavItem,
|
|
596
|
-
VCNavItems
|
|
597
|
-
}).forEach(([componentName, component])=>{
|
|
598
|
-
instance.component(componentName, component);
|
|
599
|
-
});
|
|
447
|
+
//#endregion
|
|
448
|
+
//#region src/components/stepper/context.ts
|
|
449
|
+
const STEPPER_CONTEXT_KEY = Symbol("vcStepperContext");
|
|
450
|
+
function provideStepperContext(ctx) {
|
|
451
|
+
provide$1(STEPPER_CONTEXT_KEY, ctx);
|
|
600
452
|
}
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}
|
|
453
|
+
function useStepperContext() {
|
|
454
|
+
return inject$1(STEPPER_CONTEXT_KEY, null);
|
|
455
|
+
}
|
|
456
|
+
//#endregion
|
|
457
|
+
//#region src/components/stepper/theme.ts
|
|
458
|
+
const stepperThemeDefaults = { classes: {
|
|
459
|
+
root: "vc-stepper",
|
|
460
|
+
item: "vc-stepper-item",
|
|
461
|
+
trigger: "vc-stepper-trigger",
|
|
462
|
+
indicator: "vc-stepper-indicator",
|
|
463
|
+
title: "vc-stepper-title",
|
|
464
|
+
description: "vc-stepper-description",
|
|
465
|
+
separator: "vc-stepper-separator"
|
|
466
|
+
} };
|
|
467
|
+
//#endregion
|
|
468
|
+
//#region src/components/stepper/Stepper.vue
|
|
469
|
+
var Stepper_default = defineComponent({
|
|
470
|
+
name: "VCStepper",
|
|
471
|
+
inheritAttrs: false,
|
|
472
|
+
props: {
|
|
473
|
+
/** Active step (1-based). v-modeled. */
|
|
474
|
+
modelValue: {
|
|
475
|
+
type: Number,
|
|
476
|
+
default: void 0
|
|
477
|
+
},
|
|
478
|
+
/** Initial active step for uncontrolled usage. */
|
|
479
|
+
defaultValue: {
|
|
480
|
+
type: Number,
|
|
481
|
+
default: 1
|
|
482
|
+
},
|
|
483
|
+
/** Layout direction. */
|
|
484
|
+
orientation: {
|
|
485
|
+
type: String,
|
|
486
|
+
default: "horizontal"
|
|
487
|
+
},
|
|
488
|
+
/** Reading direction. Falls back to the ConfigManager's `dir` value when omitted. */
|
|
489
|
+
dir: {
|
|
490
|
+
type: String,
|
|
491
|
+
default: void 0
|
|
492
|
+
},
|
|
493
|
+
/** When `true`, steps must be completed in order — Reka blocks navigation past the next incomplete step. */
|
|
494
|
+
linear: {
|
|
495
|
+
type: Boolean,
|
|
496
|
+
default: true
|
|
497
|
+
},
|
|
498
|
+
/** Theme-class overrides for this component instance. */
|
|
499
|
+
themeClass: {
|
|
500
|
+
type: Object,
|
|
501
|
+
default: void 0
|
|
502
|
+
},
|
|
503
|
+
/** Theme-variant values for this component instance. */
|
|
504
|
+
themeVariant: {
|
|
505
|
+
type: Object,
|
|
506
|
+
default: void 0
|
|
507
|
+
}
|
|
508
|
+
},
|
|
509
|
+
emits: ["update:modelValue"],
|
|
510
|
+
setup(props, { attrs, slots, emit }) {
|
|
511
|
+
provideStepperContext({
|
|
512
|
+
themeClass: () => props.themeClass,
|
|
513
|
+
themeVariant: () => props.themeVariant
|
|
514
|
+
});
|
|
515
|
+
const theme = useComponentTheme("stepper", props, stepperThemeDefaults);
|
|
516
|
+
return () => h(StepperRoot, mergeProps(attrs, {
|
|
517
|
+
modelValue: props.modelValue,
|
|
518
|
+
defaultValue: props.defaultValue,
|
|
519
|
+
orientation: props.orientation,
|
|
520
|
+
dir: props.dir,
|
|
521
|
+
linear: props.linear,
|
|
522
|
+
"onUpdate:modelValue": (value) => emit("update:modelValue", value),
|
|
523
|
+
class: theme.value.root || void 0
|
|
524
|
+
}), { default: () => slots.default?.() });
|
|
525
|
+
}
|
|
526
|
+
});
|
|
527
|
+
//#endregion
|
|
528
|
+
//#region src/components/stepper/StepperItem.vue
|
|
529
|
+
var StepperItem_default = defineComponent({
|
|
530
|
+
name: "VCStepperItem",
|
|
531
|
+
inheritAttrs: false,
|
|
532
|
+
props: {
|
|
533
|
+
/** 1-based step index. Required by Reka — used to determine completion / active state. */
|
|
534
|
+
step: {
|
|
535
|
+
type: Number,
|
|
536
|
+
required: true
|
|
537
|
+
},
|
|
538
|
+
/** Block interaction with this step. */
|
|
539
|
+
disabled: {
|
|
540
|
+
type: Boolean,
|
|
541
|
+
default: false
|
|
542
|
+
},
|
|
543
|
+
/** Force completion state. Reka derives this automatically when `false`. */
|
|
544
|
+
completed: {
|
|
545
|
+
type: Boolean,
|
|
546
|
+
default: false
|
|
547
|
+
},
|
|
548
|
+
/** Theme-class overrides for this component instance. */
|
|
549
|
+
themeClass: {
|
|
550
|
+
type: Object,
|
|
551
|
+
default: void 0
|
|
552
|
+
},
|
|
553
|
+
/** Theme-variant values for this component instance. */
|
|
554
|
+
themeVariant: {
|
|
555
|
+
type: Object,
|
|
556
|
+
default: void 0
|
|
557
|
+
}
|
|
558
|
+
},
|
|
559
|
+
slots: Object,
|
|
560
|
+
setup(props, { attrs, slots }) {
|
|
561
|
+
const ctx = useStepperContext();
|
|
562
|
+
const theme = useComponentTheme("stepper", {
|
|
563
|
+
get themeClass() {
|
|
564
|
+
return {
|
|
565
|
+
...ctx?.themeClass() ?? {},
|
|
566
|
+
...props.themeClass ?? {}
|
|
567
|
+
};
|
|
568
|
+
},
|
|
569
|
+
get themeVariant() {
|
|
570
|
+
return {
|
|
571
|
+
...ctx?.themeVariant() ?? {},
|
|
572
|
+
...props.themeVariant ?? {}
|
|
573
|
+
};
|
|
574
|
+
}
|
|
575
|
+
}, stepperThemeDefaults);
|
|
576
|
+
return () => h(StepperItem, {
|
|
577
|
+
step: props.step,
|
|
578
|
+
disabled: props.disabled,
|
|
579
|
+
completed: props.completed,
|
|
580
|
+
...mergeProps(attrs, { class: ["group", theme.value.item || void 0] })
|
|
581
|
+
}, { default: ({ state }) => slots.default?.({ state }) });
|
|
582
|
+
}
|
|
583
|
+
});
|
|
584
|
+
//#endregion
|
|
585
|
+
//#region src/components/stepper/StepperTrigger.vue
|
|
586
|
+
var StepperTrigger_default = defineComponent({
|
|
587
|
+
name: "VCStepperTrigger",
|
|
588
|
+
inheritAttrs: false,
|
|
589
|
+
props: {
|
|
590
|
+
/** Render the consumer's slot child as the trigger root (Reka `asChild` pattern). */
|
|
591
|
+
asChild: {
|
|
592
|
+
type: Boolean,
|
|
593
|
+
default: false
|
|
594
|
+
},
|
|
595
|
+
/** HTML tag to render. */
|
|
596
|
+
as: {
|
|
597
|
+
type: [String, Object],
|
|
598
|
+
default: "button"
|
|
599
|
+
},
|
|
600
|
+
/** Theme-class overrides for this component instance. */
|
|
601
|
+
themeClass: {
|
|
602
|
+
type: Object,
|
|
603
|
+
default: void 0
|
|
604
|
+
},
|
|
605
|
+
/** Theme-variant values for this component instance. */
|
|
606
|
+
themeVariant: {
|
|
607
|
+
type: Object,
|
|
608
|
+
default: void 0
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
setup(props, { attrs, slots }) {
|
|
612
|
+
const ctx = useStepperContext();
|
|
613
|
+
const theme = useComponentTheme("stepper", {
|
|
614
|
+
get themeClass() {
|
|
615
|
+
return {
|
|
616
|
+
...ctx?.themeClass() ?? {},
|
|
617
|
+
...props.themeClass ?? {}
|
|
618
|
+
};
|
|
619
|
+
},
|
|
620
|
+
get themeVariant() {
|
|
621
|
+
return {
|
|
622
|
+
...ctx?.themeVariant() ?? {},
|
|
623
|
+
...props.themeVariant ?? {}
|
|
624
|
+
};
|
|
625
|
+
}
|
|
626
|
+
}, stepperThemeDefaults);
|
|
627
|
+
return () => h(StepperTrigger, mergeProps(props.as === "button" ? { type: "button" } : {}, attrs, {
|
|
628
|
+
as: props.as,
|
|
629
|
+
asChild: props.asChild,
|
|
630
|
+
class: theme.value.trigger || void 0
|
|
631
|
+
}), { default: () => slots.default?.() });
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
//#endregion
|
|
635
|
+
//#region src/components/stepper/StepperIndicator.vue
|
|
636
|
+
var StepperIndicator_default = defineComponent({
|
|
637
|
+
name: "VCStepperIndicator",
|
|
638
|
+
inheritAttrs: false,
|
|
639
|
+
props: {
|
|
640
|
+
/** Render the consumer's slot child as the indicator root (Reka `asChild` pattern). */
|
|
641
|
+
asChild: {
|
|
642
|
+
type: Boolean,
|
|
643
|
+
default: false
|
|
644
|
+
},
|
|
645
|
+
/** HTML tag to render. */
|
|
646
|
+
as: {
|
|
647
|
+
type: [String, Object],
|
|
648
|
+
default: "div"
|
|
649
|
+
},
|
|
650
|
+
/** Theme-class overrides for this component instance. */
|
|
651
|
+
themeClass: {
|
|
652
|
+
type: Object,
|
|
653
|
+
default: void 0
|
|
654
|
+
},
|
|
655
|
+
/** Theme-variant values for this component instance. */
|
|
656
|
+
themeVariant: {
|
|
657
|
+
type: Object,
|
|
658
|
+
default: void 0
|
|
659
|
+
}
|
|
660
|
+
},
|
|
661
|
+
setup(props, { attrs, slots }) {
|
|
662
|
+
const ctx = useStepperContext();
|
|
663
|
+
const theme = useComponentTheme("stepper", {
|
|
664
|
+
get themeClass() {
|
|
665
|
+
return {
|
|
666
|
+
...ctx?.themeClass() ?? {},
|
|
667
|
+
...props.themeClass ?? {}
|
|
668
|
+
};
|
|
669
|
+
},
|
|
670
|
+
get themeVariant() {
|
|
671
|
+
return {
|
|
672
|
+
...ctx?.themeVariant() ?? {},
|
|
673
|
+
...props.themeVariant ?? {}
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
}, stepperThemeDefaults);
|
|
677
|
+
return () => h(StepperIndicator, mergeProps(attrs, {
|
|
678
|
+
as: props.as,
|
|
679
|
+
asChild: props.asChild,
|
|
680
|
+
class: theme.value.indicator || void 0
|
|
681
|
+
}), { default: () => slots.default?.() });
|
|
682
|
+
}
|
|
683
|
+
});
|
|
684
|
+
//#endregion
|
|
685
|
+
//#region src/components/stepper/StepperTitle.vue
|
|
686
|
+
var StepperTitle_default = defineComponent({
|
|
687
|
+
name: "VCStepperTitle",
|
|
688
|
+
inheritAttrs: false,
|
|
689
|
+
props: {
|
|
690
|
+
/** Render the consumer's slot child as the title root (Reka `asChild` pattern). */
|
|
691
|
+
asChild: {
|
|
692
|
+
type: Boolean,
|
|
693
|
+
default: false
|
|
694
|
+
},
|
|
695
|
+
/** HTML tag to render. */
|
|
696
|
+
as: {
|
|
697
|
+
type: [String, Object],
|
|
698
|
+
default: "h4"
|
|
699
|
+
},
|
|
700
|
+
/** Theme-class overrides for this component instance. */
|
|
701
|
+
themeClass: {
|
|
702
|
+
type: Object,
|
|
703
|
+
default: void 0
|
|
704
|
+
},
|
|
705
|
+
/** Theme-variant values for this component instance. */
|
|
706
|
+
themeVariant: {
|
|
707
|
+
type: Object,
|
|
708
|
+
default: void 0
|
|
709
|
+
}
|
|
710
|
+
},
|
|
711
|
+
setup(props, { attrs, slots }) {
|
|
712
|
+
const ctx = useStepperContext();
|
|
713
|
+
const theme = useComponentTheme("stepper", {
|
|
714
|
+
get themeClass() {
|
|
715
|
+
return {
|
|
716
|
+
...ctx?.themeClass() ?? {},
|
|
717
|
+
...props.themeClass ?? {}
|
|
718
|
+
};
|
|
719
|
+
},
|
|
720
|
+
get themeVariant() {
|
|
721
|
+
return {
|
|
722
|
+
...ctx?.themeVariant() ?? {},
|
|
723
|
+
...props.themeVariant ?? {}
|
|
724
|
+
};
|
|
725
|
+
}
|
|
726
|
+
}, stepperThemeDefaults);
|
|
727
|
+
return () => h(StepperTitle, mergeProps(attrs, {
|
|
728
|
+
as: props.as,
|
|
729
|
+
asChild: props.asChild,
|
|
730
|
+
class: theme.value.title || void 0
|
|
731
|
+
}), { default: () => slots.default?.() });
|
|
732
|
+
}
|
|
733
|
+
});
|
|
734
|
+
//#endregion
|
|
735
|
+
//#region src/components/stepper/StepperDescription.vue
|
|
736
|
+
var StepperDescription_default = defineComponent({
|
|
737
|
+
name: "VCStepperDescription",
|
|
738
|
+
inheritAttrs: false,
|
|
739
|
+
props: {
|
|
740
|
+
/** Render the consumer's slot child as the description root (Reka `asChild` pattern). */
|
|
741
|
+
asChild: {
|
|
742
|
+
type: Boolean,
|
|
743
|
+
default: false
|
|
744
|
+
},
|
|
745
|
+
/** HTML tag to render. */
|
|
746
|
+
as: {
|
|
747
|
+
type: [String, Object],
|
|
748
|
+
default: "p"
|
|
749
|
+
},
|
|
750
|
+
/** Theme-class overrides for this component instance. */
|
|
751
|
+
themeClass: {
|
|
752
|
+
type: Object,
|
|
753
|
+
default: void 0
|
|
754
|
+
},
|
|
755
|
+
/** Theme-variant values for this component instance. */
|
|
756
|
+
themeVariant: {
|
|
757
|
+
type: Object,
|
|
758
|
+
default: void 0
|
|
759
|
+
}
|
|
760
|
+
},
|
|
761
|
+
setup(props, { attrs, slots }) {
|
|
762
|
+
const ctx = useStepperContext();
|
|
763
|
+
const theme = useComponentTheme("stepper", {
|
|
764
|
+
get themeClass() {
|
|
765
|
+
return {
|
|
766
|
+
...ctx?.themeClass() ?? {},
|
|
767
|
+
...props.themeClass ?? {}
|
|
768
|
+
};
|
|
769
|
+
},
|
|
770
|
+
get themeVariant() {
|
|
771
|
+
return {
|
|
772
|
+
...ctx?.themeVariant() ?? {},
|
|
773
|
+
...props.themeVariant ?? {}
|
|
774
|
+
};
|
|
775
|
+
}
|
|
776
|
+
}, stepperThemeDefaults);
|
|
777
|
+
return () => h(StepperDescription, mergeProps(attrs, {
|
|
778
|
+
as: props.as,
|
|
779
|
+
asChild: props.asChild,
|
|
780
|
+
class: theme.value.description || void 0
|
|
781
|
+
}), { default: () => slots.default?.() });
|
|
782
|
+
}
|
|
783
|
+
});
|
|
784
|
+
//#endregion
|
|
785
|
+
//#region src/components/stepper/StepperSeparator.vue
|
|
786
|
+
var StepperSeparator_default = defineComponent({
|
|
787
|
+
name: "VCStepperSeparator",
|
|
788
|
+
inheritAttrs: false,
|
|
789
|
+
props: {
|
|
790
|
+
/** Render the consumer's slot child as the separator root (Reka `asChild` pattern). */
|
|
791
|
+
asChild: {
|
|
792
|
+
type: Boolean,
|
|
793
|
+
default: false
|
|
794
|
+
},
|
|
795
|
+
/** HTML tag to render. */
|
|
796
|
+
as: {
|
|
797
|
+
type: [String, Object],
|
|
798
|
+
default: "div"
|
|
799
|
+
},
|
|
800
|
+
/** Theme-class overrides for this component instance. */
|
|
801
|
+
themeClass: {
|
|
802
|
+
type: Object,
|
|
803
|
+
default: void 0
|
|
804
|
+
},
|
|
805
|
+
/** Theme-variant values for this component instance. */
|
|
806
|
+
themeVariant: {
|
|
807
|
+
type: Object,
|
|
808
|
+
default: void 0
|
|
809
|
+
}
|
|
810
|
+
},
|
|
811
|
+
setup(props, { attrs, slots }) {
|
|
812
|
+
const ctx = useStepperContext();
|
|
813
|
+
const theme = useComponentTheme("stepper", {
|
|
814
|
+
get themeClass() {
|
|
815
|
+
return {
|
|
816
|
+
...ctx?.themeClass() ?? {},
|
|
817
|
+
...props.themeClass ?? {}
|
|
818
|
+
};
|
|
819
|
+
},
|
|
820
|
+
get themeVariant() {
|
|
821
|
+
return {
|
|
822
|
+
...ctx?.themeVariant() ?? {},
|
|
823
|
+
...props.themeVariant ?? {}
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
}, stepperThemeDefaults);
|
|
827
|
+
return () => h(StepperSeparator, mergeProps(attrs, {
|
|
828
|
+
as: props.as,
|
|
829
|
+
asChild: props.asChild,
|
|
830
|
+
class: theme.value.separator || void 0
|
|
831
|
+
}), { default: () => slots.default?.() });
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
//#endregion
|
|
835
|
+
//#region src/index.ts
|
|
836
|
+
function install(instance, options = {}) {
|
|
837
|
+
provideNavigationManager(new NavigationManager({ items: options.items ?? [] }), instance);
|
|
838
|
+
installThemeManager(instance, options);
|
|
839
|
+
installDefaultsManager(instance, options);
|
|
840
|
+
Object.entries({
|
|
841
|
+
VCNavItem,
|
|
842
|
+
VCNavItems,
|
|
843
|
+
VCStepper: Stepper_default,
|
|
844
|
+
VCStepperItem: StepperItem_default,
|
|
845
|
+
VCStepperTrigger: StepperTrigger_default,
|
|
846
|
+
VCStepperIndicator: StepperIndicator_default,
|
|
847
|
+
VCStepperTitle: StepperTitle_default,
|
|
848
|
+
VCStepperDescription: StepperDescription_default,
|
|
849
|
+
VCStepperSeparator: StepperSeparator_default
|
|
850
|
+
}).forEach(([componentName, component]) => {
|
|
851
|
+
instance.component(componentName, component);
|
|
852
|
+
});
|
|
853
|
+
}
|
|
854
|
+
var src_default = { install };
|
|
855
|
+
//#endregion
|
|
856
|
+
export { NavigationManager, VCNavItem, VCNavItems, Stepper_default as VCStepper, StepperDescription_default as VCStepperDescription, StepperIndicator_default as VCStepperIndicator, StepperItem_default as VCStepperItem, StepperSeparator_default as VCStepperSeparator, StepperTitle_default as VCStepperTitle, StepperTrigger_default as VCStepperTrigger, src_default as default, injectNavigationManager, install, navigationThemeDefaults, provideNavigationManager, provideStepperContext, stepperThemeDefaults, useStepperContext };
|
|
604
857
|
|
|
605
|
-
|
|
606
|
-
//# sourceMappingURL=index.mjs.map
|
|
858
|
+
//# sourceMappingURL=index.mjs.map
|