@schukai/monster 4.43.9 → 4.43.11
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/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/source/components/form/password.mjs +140 -140
- package/source/components/navigation/site-navigation.mjs +487 -487
- package/source/components/navigation/style/site-navigation.pcss +1 -0
- package/source/components/navigation/stylesheet/site-navigation.mjs +14 -7
- package/source/components/navigation/stylesheet/wizard-navigation.mjs +13 -6
- package/source/components/navigation/wizard-navigation.mjs +391 -391
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { instanceSymbol } from "../../constants.mjs";
|
|
2
2
|
import { ATTRIBUTE_ROLE } from "../../dom/constants.mjs";
|
|
3
3
|
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
assembleMethodSymbol,
|
|
5
|
+
CustomElement,
|
|
6
|
+
getSlottedElements,
|
|
7
|
+
registerCustomElement,
|
|
8
8
|
} from "../../dom/customelement.mjs";
|
|
9
9
|
import {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
findTargetElementFromEvent,
|
|
11
|
+
fireCustomEvent,
|
|
12
12
|
} from "../../dom/events.mjs";
|
|
13
13
|
import { isFunction } from "../../types/is.mjs";
|
|
14
14
|
import { WizardNavigationStyleSheet } from "./stylesheet/wizard-navigation.mjs";
|
|
@@ -34,407 +34,407 @@ const currentSubStepIndexSymbol = Symbol("currentSubStepIndex");
|
|
|
34
34
|
* @fires monster-wizard-completed - Fired when the entire wizard is marked as complete via completeAll().
|
|
35
35
|
*/
|
|
36
36
|
class WizardNavigation extends CustomElement {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
37
|
+
static get [instanceSymbol]() {
|
|
38
|
+
return Symbol.for(
|
|
39
|
+
"@schukai/monster/components/navigation/wizard-navigation@@instance",
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
[assembleMethodSymbol]() {
|
|
44
|
+
super[assembleMethodSymbol]();
|
|
45
|
+
this[isTransitioningSymbol] = false;
|
|
46
|
+
this[currentStepIndexSymbol] = -1;
|
|
47
|
+
this[currentSubStepIndexSymbol] = -1;
|
|
48
|
+
|
|
49
|
+
initControlReferences.call(this);
|
|
50
|
+
initEventHandler.call(this);
|
|
51
|
+
|
|
52
|
+
queueMicrotask(() => {
|
|
53
|
+
importContent.call(this);
|
|
54
|
+
this.activate(0, 0, { force: true });
|
|
55
|
+
});
|
|
56
|
+
|
|
57
|
+
return this;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* To set the options via the HTML Tag, the attribute `data-monster-options` must be used.
|
|
62
|
+
* @see {@link https://monsterjs.org/en/doc/#configurate-a-monster-control}
|
|
63
|
+
*
|
|
64
|
+
* The individual configuration values can be found in the table.
|
|
65
|
+
*
|
|
66
|
+
* @property {Object} templates Template definitions
|
|
67
|
+
* @property {string} templates.main Main template
|
|
68
|
+
* @property {Object} actions Action callbacks
|
|
69
|
+
* @property {function(number, number):(boolean|Promise<boolean>)} actions.beforeStepChange - Callback fired before a main step change. Must return `true` or a Promise that resolves to `true` to allow the transition. Parameters are `fromIndex` and `toIndex`.
|
|
70
|
+
* @property {function} actions.click - General click handler callback.
|
|
71
|
+
*/
|
|
72
|
+
get defaults() {
|
|
73
|
+
return Object.assign({}, super.defaults, {
|
|
74
|
+
templates: {
|
|
75
|
+
main: getTemplate(),
|
|
76
|
+
},
|
|
77
|
+
actions: {
|
|
78
|
+
beforeStepChange: (fromIndex, toIndex) => true,
|
|
79
|
+
click: () => {},
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Navigates to the specified main step if the transition logic allows it.
|
|
86
|
+
* @param {number} index The index of the target step.
|
|
87
|
+
* @param {object} [options={}] Additional options.
|
|
88
|
+
* @param {boolean} [options.force=false] If true, the `beforeStepChange` callback is skipped.
|
|
89
|
+
* @returns {Promise<void>}
|
|
90
|
+
* @fires monster-wizard-step-changed
|
|
91
|
+
*/
|
|
92
|
+
async goToStep(index, options = {}) {
|
|
93
|
+
if (typeof index !== "number") {
|
|
94
|
+
console.error("WizardNavigation.goToStep: index must be a number.");
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const { force = false } = options;
|
|
99
|
+
const stepsData = this[stepsSymbol];
|
|
100
|
+
const oldIndex = this[currentStepIndexSymbol];
|
|
101
|
+
|
|
102
|
+
if (
|
|
103
|
+
!stepsData ||
|
|
104
|
+
index < 0 ||
|
|
105
|
+
index >= stepsData.length ||
|
|
106
|
+
index === oldIndex ||
|
|
107
|
+
this[isTransitioningSymbol]
|
|
108
|
+
) {
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
this[isTransitioningSymbol] = true;
|
|
113
|
+
|
|
114
|
+
if (!force) {
|
|
115
|
+
const callback = this.getOption("actions.beforeStepChange");
|
|
116
|
+
if (isFunction(callback)) {
|
|
117
|
+
const isAllowed = await Promise.resolve(
|
|
118
|
+
callback.call(this, oldIndex, index),
|
|
119
|
+
);
|
|
120
|
+
if (!isAllowed) {
|
|
121
|
+
this[isTransitioningSymbol] = false;
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
stepsData.forEach((stepData, i) => {
|
|
128
|
+
stepData.element.classList.remove("step-active");
|
|
129
|
+
stepData.element.setAttribute("aria-selected", "false");
|
|
130
|
+
|
|
131
|
+
if (stepData.subStepList) {
|
|
132
|
+
stepData.subStepList.style.maxHeight =
|
|
133
|
+
i === index ? stepData.subStepList.scrollHeight + "px" : "0px";
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
if (i < index) {
|
|
137
|
+
stepData.element.classList.add("step-completed");
|
|
138
|
+
stepData.subSteps.forEach((sub) =>
|
|
139
|
+
sub.classList.add("sub-item-completed"),
|
|
140
|
+
);
|
|
141
|
+
} else {
|
|
142
|
+
stepData.element.classList.remove("step-completed");
|
|
143
|
+
stepData.subSteps.forEach((sub) =>
|
|
144
|
+
sub.classList.remove("sub-item-completed"),
|
|
145
|
+
);
|
|
146
|
+
}
|
|
147
|
+
});
|
|
148
|
+
|
|
149
|
+
if (oldIndex !== -1 && stepsData[oldIndex]) {
|
|
150
|
+
stepsData[oldIndex].subSteps.forEach((sub) =>
|
|
151
|
+
sub.classList.remove("sub-item-active"),
|
|
152
|
+
);
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
this[currentSubStepIndexSymbol] = -1;
|
|
156
|
+
this[currentStepIndexSymbol] = index;
|
|
157
|
+
|
|
158
|
+
const currentStepData = stepsData[index];
|
|
159
|
+
currentStepData.element.classList.remove("step-completed");
|
|
160
|
+
currentStepData.element.classList.add("step-active");
|
|
161
|
+
currentStepData.element.setAttribute("aria-selected", "true");
|
|
162
|
+
|
|
163
|
+
fireCustomEvent(this, "monster-wizard-step-changed", {
|
|
164
|
+
newIndex: index,
|
|
165
|
+
oldIndex: oldIndex,
|
|
166
|
+
element: currentStepData.element,
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
this[isTransitioningSymbol] = false;
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
/**
|
|
173
|
+
* Activates a specific main step and sub-step.
|
|
174
|
+
* @param {number} mainIndex The index of the main step.
|
|
175
|
+
* @param {number} subIndex The index of the sub-step.
|
|
176
|
+
* @param {object} [options={}] Additional options.
|
|
177
|
+
* @param {boolean} [options.force=false] If true, the `beforeStepChange` callback is skipped.
|
|
178
|
+
* @returns {Promise<void>}
|
|
179
|
+
* @fires monster-wizard-substep-changed
|
|
180
|
+
*/
|
|
181
|
+
async activate(mainIndex, subIndex, options = {}) {
|
|
182
|
+
if (typeof mainIndex !== "number" || typeof subIndex !== "number") {
|
|
183
|
+
console.error(
|
|
184
|
+
"WizardNavigation.activate: mainIndex and subIndex must be numbers.",
|
|
185
|
+
);
|
|
186
|
+
return;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
await this.goToStep(mainIndex, options);
|
|
190
|
+
|
|
191
|
+
const stepsData = this[stepsSymbol];
|
|
192
|
+
if (!stepsData || !stepsData[mainIndex]) return;
|
|
193
|
+
|
|
194
|
+
const targetStep = stepsData[mainIndex];
|
|
195
|
+
if (
|
|
196
|
+
!targetStep.subSteps ||
|
|
197
|
+
subIndex < 0 ||
|
|
198
|
+
subIndex >= targetStep.subSteps.length
|
|
199
|
+
) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
stepsData.forEach((step) => {
|
|
204
|
+
step.subSteps.forEach((subStep) =>
|
|
205
|
+
subStep.classList.remove("sub-item-active"),
|
|
206
|
+
);
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
for (let i = 0; i < subIndex; i++) {
|
|
210
|
+
if (targetStep.subSteps[i]) {
|
|
211
|
+
targetStep.subSteps[i].classList.add("sub-item-completed");
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
const targetSubStep = targetStep.subSteps[subIndex];
|
|
216
|
+
targetSubStep.classList.remove("sub-item-completed");
|
|
217
|
+
targetSubStep.classList.add("sub-item-active");
|
|
218
|
+
this[currentSubStepIndexSymbol] = subIndex;
|
|
219
|
+
|
|
220
|
+
fireCustomEvent(this, "monster-wizard-substep-changed", {
|
|
221
|
+
mainIndex,
|
|
222
|
+
subIndex,
|
|
223
|
+
element: targetSubStep,
|
|
224
|
+
});
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/**
|
|
228
|
+
* Navigates to the next step or sub-step in sequence.
|
|
229
|
+
* @returns {Promise<void>}
|
|
230
|
+
*/
|
|
231
|
+
async next() {
|
|
232
|
+
const mainIndex = this[currentStepIndexSymbol];
|
|
233
|
+
const subIndex = this[currentSubStepIndexSymbol];
|
|
234
|
+
const stepsData = this[stepsSymbol];
|
|
235
|
+
|
|
236
|
+
if (mainIndex === -1 || !stepsData || !stepsData[mainIndex]) return;
|
|
237
|
+
|
|
238
|
+
const currentStepData = stepsData[mainIndex];
|
|
239
|
+
const hasSubSteps = currentStepData.subSteps.length > 0;
|
|
240
|
+
|
|
241
|
+
if (hasSubSteps && subIndex < currentStepData.subSteps.length - 1) {
|
|
242
|
+
await this.activate(mainIndex, subIndex + 1);
|
|
243
|
+
return;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
const nextMainIndex = mainIndex + 1;
|
|
247
|
+
if (nextMainIndex < stepsData.length) {
|
|
248
|
+
if (stepsData[nextMainIndex].subSteps.length > 0) {
|
|
249
|
+
await this.activate(nextMainIndex, 0);
|
|
250
|
+
} else {
|
|
251
|
+
await this.goToStep(nextMainIndex);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* Navigates to the previous step or sub-step in sequence.
|
|
258
|
+
* @returns {Promise<void>}
|
|
259
|
+
*/
|
|
260
|
+
async previous() {
|
|
261
|
+
const mainIndex = this[currentStepIndexSymbol];
|
|
262
|
+
const subIndex = this[currentSubStepIndexSymbol];
|
|
263
|
+
const stepsData = this[stepsSymbol];
|
|
264
|
+
|
|
265
|
+
if (subIndex > 0) {
|
|
266
|
+
await this.activate(mainIndex, subIndex - 1);
|
|
267
|
+
return;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
const prevMainIndex = mainIndex - 1;
|
|
271
|
+
if (prevMainIndex >= 0) {
|
|
272
|
+
const prevStepData = stepsData[prevMainIndex];
|
|
273
|
+
if (prevStepData.subSteps.length > 0) {
|
|
274
|
+
await this.activate(prevMainIndex, prevStepData.subSteps.length - 1);
|
|
275
|
+
} else {
|
|
276
|
+
await this.goToStep(prevMainIndex);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Marks the current step as completed and automatically navigates to the next step.
|
|
283
|
+
* @returns {Promise<void>}
|
|
284
|
+
*/
|
|
285
|
+
async completeAndNext() {
|
|
286
|
+
const currentIndex = this[currentStepIndexSymbol];
|
|
287
|
+
const stepsData = this[stepsSymbol];
|
|
288
|
+
|
|
289
|
+
if (currentIndex === -1 || !stepsData || !stepsData[currentIndex]) {
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
const currentStepData = stepsData[currentIndex];
|
|
294
|
+
currentStepData.element.classList.add("step-completed");
|
|
295
|
+
currentStepData.element.classList.remove("step-active");
|
|
296
|
+
|
|
297
|
+
currentStepData.subSteps.forEach((sub) => {
|
|
298
|
+
sub.classList.add("sub-item-completed");
|
|
299
|
+
sub.classList.remove("sub-item-active");
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
await this.next();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/**
|
|
306
|
+
* Marks the entire wizard workflow as completed.
|
|
307
|
+
* @fires monster-wizard-completed
|
|
308
|
+
*/
|
|
309
|
+
completeAll() {
|
|
310
|
+
const stepsData = this[stepsSymbol];
|
|
311
|
+
if (!stepsData) return;
|
|
312
|
+
|
|
313
|
+
stepsData.forEach((stepData) => {
|
|
314
|
+
stepData.element.classList.add("step-completed");
|
|
315
|
+
stepData.element.classList.remove("step-active");
|
|
316
|
+
stepData.element.setAttribute("aria-selected", "false");
|
|
317
|
+
|
|
318
|
+
stepData.subSteps.forEach((sub) => {
|
|
319
|
+
sub.classList.add("sub-item-completed");
|
|
320
|
+
sub.classList.remove("sub-item-active");
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
if (stepData.subStepList) {
|
|
324
|
+
stepData.subStepList.style.maxHeight = "0px";
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
|
|
328
|
+
this[currentStepIndexSymbol] = -1;
|
|
329
|
+
this[currentSubStepIndexSymbol] = -1;
|
|
330
|
+
|
|
331
|
+
fireCustomEvent(this, "monster-wizard-completed", {
|
|
332
|
+
detail: { message: "All steps completed." },
|
|
333
|
+
});
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Gets the index of the currently active main step.
|
|
338
|
+
* @returns {number} The index of the current step, or -1 if none is active.
|
|
339
|
+
*/
|
|
340
|
+
getCurrentStepIndex() {
|
|
341
|
+
return this[currentStepIndexSymbol];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/**
|
|
345
|
+
* Gets the index of the currently active sub-step within the main step.
|
|
346
|
+
* @returns {number} The index of the current sub-step, or -1 if none is active.
|
|
347
|
+
*/
|
|
348
|
+
getCurrentSubStepIndex() {
|
|
349
|
+
return this[currentSubStepIndexSymbol];
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
static getTag() {
|
|
353
|
+
return "monster-wizard-navigation";
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
static getCSSStyleSheet() {
|
|
357
|
+
return [WizardNavigationStyleSheet];
|
|
358
|
+
}
|
|
359
359
|
}
|
|
360
360
|
|
|
361
361
|
/** @private */
|
|
362
362
|
function initEventHandler() {
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
363
|
+
const self = this;
|
|
364
|
+
this[wizardNavigationElementSymbol].addEventListener(
|
|
365
|
+
"click",
|
|
366
|
+
function (event) {
|
|
367
|
+
const targetStepElement = findTargetElementFromEvent(event, "li.step");
|
|
368
|
+
if (!targetStepElement) return;
|
|
369
|
+
|
|
370
|
+
const targetIndex = self[stepsSymbol].findIndex(
|
|
371
|
+
(stepData) => stepData.element === targetStepElement,
|
|
372
|
+
);
|
|
373
|
+
|
|
374
|
+
if (targetIndex !== -1) {
|
|
375
|
+
self.goToStep(targetIndex);
|
|
376
|
+
}
|
|
377
|
+
},
|
|
378
|
+
);
|
|
379
379
|
}
|
|
380
380
|
|
|
381
381
|
/** @private */
|
|
382
382
|
function initControlReferences() {
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
383
|
+
this[wizardNavigationElementSymbol] = this.shadowRoot.querySelector(
|
|
384
|
+
`[${ATTRIBUTE_ROLE}="control"]`,
|
|
385
|
+
);
|
|
386
|
+
this[wizardNavigationListElementSymbol] = this.shadowRoot.querySelector(
|
|
387
|
+
`[${ATTRIBUTE_ROLE}="list"]`,
|
|
388
|
+
);
|
|
389
389
|
}
|
|
390
390
|
|
|
391
391
|
/** @private */
|
|
392
392
|
function importContent() {
|
|
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
|
-
|
|
393
|
+
const elements = getSlottedElements.call(this, "ol.wizard-steps");
|
|
394
|
+
elements.forEach((element) => {
|
|
395
|
+
const clonedContent = element.cloneNode(true);
|
|
396
|
+
this[wizardNavigationListElementSymbol].innerHTML = "";
|
|
397
|
+
this[wizardNavigationListElementSymbol].appendChild(clonedContent);
|
|
398
|
+
|
|
399
|
+
const stepElements =
|
|
400
|
+
this[wizardNavigationListElementSymbol].querySelectorAll("li.step");
|
|
401
|
+
|
|
402
|
+
this[stepsSymbol] = Array.from(stepElements).map((stepEl) => {
|
|
403
|
+
const subStepList = stepEl.querySelector("ul");
|
|
404
|
+
const subSteps = subStepList
|
|
405
|
+
? Array.from(subStepList.querySelectorAll("li"))
|
|
406
|
+
: [];
|
|
407
|
+
|
|
408
|
+
if (subStepList) {
|
|
409
|
+
subStepList.style.maxHeight = "0px";
|
|
410
|
+
subStepList.style.overflow = "hidden";
|
|
411
|
+
subStepList.style.transition = "max-height 0.4s ease-in-out";
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
return {
|
|
415
|
+
element: stepEl,
|
|
416
|
+
subStepList: subStepList,
|
|
417
|
+
subSteps: subSteps,
|
|
418
|
+
};
|
|
419
|
+
});
|
|
420
|
+
|
|
421
|
+
this[currentStepIndexSymbol] = -1;
|
|
422
|
+
this[currentSubStepIndexSymbol] = -1;
|
|
423
|
+
|
|
424
|
+
this[wizardNavigationListElementSymbol]
|
|
425
|
+
.querySelector("ol")
|
|
426
|
+
?.setAttribute("role", "tablist");
|
|
427
|
+
|
|
428
|
+
this[stepsSymbol].forEach((stepData) => {
|
|
429
|
+
stepData.element.setAttribute("role", "tab");
|
|
430
|
+
stepData.element.setAttribute("aria-selected", "false");
|
|
431
|
+
});
|
|
432
|
+
});
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
/** @private */
|
|
436
436
|
function getTemplate() {
|
|
437
|
-
|
|
437
|
+
return `
|
|
438
438
|
<div data-monster-role="control" part="control">
|
|
439
439
|
<slot style="display: none;"></slot>
|
|
440
440
|
<div data-monster-role="list"></div>
|