tyrell-components 1.0.0-RC14 → 1.0.0-RC16
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/README.md +53 -53
- package/css/tyrell-theme.css +32 -4
- package/css/tyrell.css +10 -15
- package/dist/tyrell-colors-static.css +1 -316
- package/dist/tyrell-theme.css +1 -1443
- package/dist/tyrell.css +1 -1390
- package/dist/tyrell.js +1 -1
- package/lib/base/ty-component.d.ts +14 -0
- package/lib/base/ty-component.d.ts.map +1 -0
- package/lib/base/ty-component.js +223 -196
- package/lib/base/ty-component.js.map +1 -0
- package/lib/components/button.d.ts +1 -1
- package/lib/components/button.d.ts.map +1 -0
- package/lib/components/button.js +267 -259
- package/lib/components/button.js.map +1 -0
- package/lib/components/calendar-month.d.ts +2 -2
- package/lib/components/calendar-month.d.ts.map +1 -0
- package/lib/components/calendar-month.js +440 -416
- package/lib/components/calendar-month.js.map +1 -0
- package/lib/components/calendar-navigation.d.ts +11 -0
- package/lib/components/calendar-navigation.d.ts.map +1 -0
- package/lib/components/calendar-navigation.js +272 -261
- package/lib/components/calendar-navigation.js.map +1 -0
- package/lib/components/calendar.d.ts +31 -3
- package/lib/components/calendar.d.ts.map +1 -0
- package/lib/components/calendar.js +785 -603
- package/lib/components/calendar.js.map +1 -0
- package/lib/components/checkbox.d.ts +1 -1
- package/lib/components/checkbox.d.ts.map +1 -0
- package/lib/components/checkbox.js +273 -272
- package/lib/components/checkbox.js.map +1 -0
- package/lib/components/copy.d.ts +1 -1
- package/lib/components/copy.d.ts.map +1 -0
- package/lib/components/copy.js +287 -278
- package/lib/components/copy.js.map +1 -0
- package/lib/components/date-picker.d.ts +16 -10
- package/lib/components/date-picker.d.ts.map +1 -0
- package/lib/components/date-picker.js +1068 -1122
- package/lib/components/date-picker.js.map +1 -0
- package/lib/components/dropdown.d.ts +403 -0
- package/lib/components/dropdown.d.ts.map +1 -0
- package/lib/components/dropdown.js +1315 -0
- package/lib/components/dropdown.js.map +1 -0
- package/lib/components/file-upload.d.ts +4 -0
- package/lib/components/file-upload.js +418 -404
- package/lib/components/icon.d.ts.map +1 -0
- package/lib/components/icon.js +141 -141
- package/lib/components/icon.js.map +1 -0
- package/lib/components/input.d.ts +1 -1
- package/lib/components/input.d.ts.map +1 -0
- package/lib/components/input.js +593 -596
- package/lib/components/input.js.map +1 -0
- package/lib/components/modal.d.ts +2 -8
- package/lib/components/modal.d.ts.map +1 -0
- package/lib/components/modal.js +309 -319
- package/lib/components/modal.js.map +1 -0
- package/lib/components/multiselect.d.ts +389 -0
- package/lib/components/multiselect.d.ts.map +1 -0
- package/lib/components/multiselect.js +1301 -0
- package/lib/components/multiselect.js.map +1 -0
- package/lib/components/option.d.ts.map +1 -0
- package/lib/components/option.js +167 -167
- package/lib/components/option.js.map +1 -0
- package/lib/components/popup.d.ts.map +1 -0
- package/lib/components/popup.js +236 -233
- package/lib/components/popup.js.map +1 -0
- package/lib/components/radio.d.ts +17 -2
- package/lib/components/radio.js +437 -406
- package/lib/components/resize-observer.d.ts.map +1 -0
- package/lib/components/resize-observer.js +67 -67
- package/lib/components/resize-observer.js.map +1 -0
- package/lib/components/scroll-container.d.ts +3 -2
- package/lib/components/scroll-container.d.ts.map +1 -0
- package/lib/components/scroll-container.js +289 -294
- package/lib/components/scroll-container.js.map +1 -0
- package/lib/components/select.d.ts +85 -18
- package/lib/components/select.js +1647 -1529
- package/lib/components/selected-tags.d.ts +1 -1
- package/lib/components/selected-tags.js +188 -182
- package/lib/components/step.d.ts.map +1 -0
- package/lib/components/step.js +62 -62
- package/lib/components/step.js.map +1 -0
- package/lib/components/switch.d.ts +1 -1
- package/lib/components/switch.js +214 -213
- package/lib/components/tab.d.ts +49 -1
- package/lib/components/tab.d.ts.map +1 -0
- package/lib/components/tab.js +203 -62
- package/lib/components/tab.js.map +1 -0
- package/lib/components/tabs.d.ts +15 -2
- package/lib/components/tabs.d.ts.map +1 -0
- package/lib/components/tabs.js +576 -496
- package/lib/components/tabs.js.map +1 -0
- package/lib/components/tag.d.ts +5 -8
- package/lib/components/tag.d.ts.map +1 -0
- package/lib/components/tag.js +235 -235
- package/lib/components/tag.js.map +1 -0
- package/lib/components/textarea.d.ts +5 -4
- package/lib/components/textarea.d.ts.map +1 -0
- package/lib/components/textarea.js +458 -456
- package/lib/components/textarea.js.map +1 -0
- package/lib/components/tooltip.d.ts +4 -3
- package/lib/components/tooltip.d.ts.map +1 -0
- package/lib/components/tooltip.js +293 -283
- package/lib/components/tooltip.js.map +1 -0
- package/lib/components/wizard.d.ts +5 -4
- package/lib/components/wizard.d.ts.map +1 -0
- package/lib/components/wizard.js +359 -395
- package/lib/components/wizard.js.map +1 -0
- package/lib/icons/fontawesome/brands.d.ts.map +1 -0
- package/lib/icons/fontawesome/brands.js.map +1 -0
- package/lib/icons/fontawesome/regular.d.ts.map +1 -0
- package/lib/icons/fontawesome/regular.js.map +1 -0
- package/lib/icons/fontawesome/solid.d.ts.map +1 -0
- package/lib/icons/fontawesome/solid.js.map +1 -0
- package/lib/icons/heroicons/micro.d.ts.map +1 -0
- package/lib/icons/heroicons/micro.js +392 -392
- package/lib/icons/heroicons/micro.js.map +1 -0
- package/lib/icons/heroicons/mini.d.ts.map +1 -0
- package/lib/icons/heroicons/mini.js +382 -382
- package/lib/icons/heroicons/mini.js.map +1 -0
- package/lib/icons/heroicons/outline.d.ts.map +1 -0
- package/lib/icons/heroicons/outline.js +337 -337
- package/lib/icons/heroicons/outline.js.map +1 -0
- package/lib/icons/heroicons/solid.d.ts.map +1 -0
- package/lib/icons/heroicons/solid.js +407 -407
- package/lib/icons/heroicons/solid.js.map +1 -0
- package/lib/icons/lucide.d.ts.map +1 -0
- package/lib/icons/lucide.js +22843 -22843
- package/lib/icons/lucide.js.map +1 -0
- package/lib/icons/material/filled.d.ts.map +1 -0
- package/lib/icons/material/filled.js +9653 -9653
- package/lib/icons/material/filled.js.map +1 -0
- package/lib/icons/material/outlined.d.ts.map +1 -0
- package/lib/icons/material/outlined.js +10271 -10271
- package/lib/icons/material/outlined.js.map +1 -0
- package/lib/icons/material/round.d.ts.map +1 -0
- package/lib/icons/material/round.js +10495 -10495
- package/lib/icons/material/round.js.map +1 -0
- package/lib/icons/material/sharp.d.ts.map +1 -0
- package/lib/icons/material/sharp.js +9905 -9905
- package/lib/icons/material/sharp.js.map +1 -0
- package/lib/icons/material/two-tone.d.ts.map +1 -0
- package/lib/icons/material/two-tone.js +12792 -12792
- package/lib/icons/material/two-tone.js.map +1 -0
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -21
- package/lib/index.js.map +1 -0
- package/lib/styles/button.d.ts.map +1 -0
- package/lib/styles/button.js +200 -302
- package/lib/styles/button.js.map +1 -0
- package/lib/styles/calendar-month.d.ts +3 -0
- package/lib/styles/calendar-month.d.ts.map +1 -0
- package/lib/styles/calendar-month.js +141 -185
- package/lib/styles/calendar-month.js.map +1 -0
- package/lib/styles/calendar-navigation.d.ts +1 -1
- package/lib/styles/calendar-navigation.d.ts.map +1 -0
- package/lib/styles/calendar-navigation.js +100 -86
- package/lib/styles/calendar-navigation.js.map +1 -0
- package/lib/styles/calendar.d.ts +3 -2
- package/lib/styles/calendar.d.ts.map +1 -0
- package/lib/styles/calendar.js +83 -9
- package/lib/styles/calendar.js.map +1 -0
- package/lib/styles/checkbox.js +62 -77
- package/lib/styles/copy.d.ts.map +1 -0
- package/lib/styles/copy.js +71 -91
- package/lib/styles/copy.js.map +1 -0
- package/lib/styles/custom-scrollbar.js +80 -100
- package/lib/styles/date-picker.d.ts.map +1 -0
- package/lib/styles/date-picker.js +295 -335
- package/lib/styles/date-picker.js.map +1 -0
- package/lib/styles/dropdown.d.ts +12 -0
- package/lib/styles/dropdown.d.ts.map +1 -0
- package/lib/styles/dropdown.js +725 -0
- package/lib/styles/dropdown.js.map +1 -0
- package/lib/styles/field-size.d.ts +6 -0
- package/lib/styles/field-size.js +91 -0
- package/lib/styles/file-upload.js +139 -169
- package/lib/styles/icon.d.ts.map +1 -0
- package/lib/styles/icon.js +92 -156
- package/lib/styles/icon.js.map +1 -0
- package/lib/styles/input.d.ts.map +1 -0
- package/lib/styles/input.js +125 -241
- package/lib/styles/input.js.map +1 -0
- package/lib/styles/modal.d.ts.map +1 -0
- package/lib/styles/modal.js +67 -102
- package/lib/styles/modal.js.map +1 -0
- package/lib/styles/multiselect.d.ts +6 -0
- package/lib/styles/multiselect.d.ts.map +1 -0
- package/lib/styles/multiselect.js +568 -0
- package/lib/styles/multiselect.js.map +1 -0
- package/lib/styles/option.d.ts +1 -1
- package/lib/styles/option.d.ts.map +1 -0
- package/lib/styles/option.js +47 -67
- package/lib/styles/option.js.map +1 -0
- package/lib/styles/popup.d.ts +1 -1
- package/lib/styles/popup.d.ts.map +1 -0
- package/lib/styles/popup.js +37 -65
- package/lib/styles/popup.js.map +1 -0
- package/lib/styles/radio.js +75 -96
- package/lib/styles/resize-observer.d.ts.map +1 -0
- package/lib/styles/resize-observer.js +2 -5
- package/lib/styles/resize-observer.js.map +1 -0
- package/lib/styles/scroll-container.d.ts +1 -1
- package/lib/styles/scroll-container.d.ts.map +1 -0
- package/lib/styles/scroll-container.js +101 -131
- package/lib/styles/scroll-container.js.map +1 -0
- package/lib/styles/select-base.js +596 -773
- package/lib/styles/select.d.ts +1 -1
- package/lib/styles/select.js +146 -228
- package/lib/styles/step.d.ts +1 -1
- package/lib/styles/step.d.ts.map +1 -0
- package/lib/styles/step.js +15 -30
- package/lib/styles/step.js.map +1 -0
- package/lib/styles/switch.js +37 -55
- package/lib/styles/tab.d.ts +1 -1
- package/lib/styles/tab.d.ts.map +1 -0
- package/lib/styles/tab.js +86 -29
- package/lib/styles/tab.js.map +1 -0
- package/lib/styles/tabs.d.ts +1 -1
- package/lib/styles/tabs.d.ts.map +1 -0
- package/lib/styles/tabs.js +190 -180
- package/lib/styles/tabs.js.map +1 -0
- package/lib/styles/tag.d.ts.map +1 -0
- package/lib/styles/tag.js +137 -191
- package/lib/styles/tag.js.map +1 -0
- package/lib/styles/textarea.d.ts +1 -1
- package/lib/styles/textarea.d.ts.map +1 -0
- package/lib/styles/textarea.js +205 -271
- package/lib/styles/textarea.js.map +1 -0
- package/lib/styles/tooltip.d.ts.map +1 -0
- package/lib/styles/tooltip.js +3 -3
- package/lib/styles/tooltip.js.map +1 -0
- package/lib/styles/wizard.d.ts +9 -5
- package/lib/styles/wizard.d.ts.map +1 -0
- package/lib/styles/wizard.js +301 -245
- package/lib/styles/wizard.js.map +1 -0
- package/lib/types/common.d.ts +4 -2
- package/lib/types/common.d.ts.map +1 -0
- package/lib/types/common.js +6 -5
- package/lib/types/common.js.map +1 -0
- package/lib/utils/calendar-utils.d.ts.map +1 -0
- package/lib/utils/calendar-utils.js +100 -100
- package/lib/utils/calendar-utils.js.map +1 -0
- package/lib/utils/custom-scrollbar.js +272 -272
- package/lib/utils/flavor-sheet.js +14 -14
- package/lib/utils/icon-registry.d.ts.map +1 -0
- package/lib/utils/icon-registry.js +127 -127
- package/lib/utils/icon-registry.js.map +1 -0
- package/lib/utils/loader-registry.js +3 -3
- package/lib/utils/locale.d.ts.map +1 -0
- package/lib/utils/locale.js +34 -34
- package/lib/utils/locale.js.map +1 -0
- package/lib/utils/mobile.js +1 -1
- package/lib/utils/number-format.d.ts.map +1 -0
- package/lib/utils/number-format.js +54 -54
- package/lib/utils/number-format.js.map +1 -0
- package/lib/utils/parse-boolean.d.ts +39 -0
- package/lib/utils/parse-boolean.d.ts.map +1 -0
- package/lib/utils/parse-boolean.js +23 -0
- package/lib/utils/parse-boolean.js.map +1 -0
- package/lib/utils/positioning.d.ts.map +1 -0
- package/lib/utils/positioning.js +212 -212
- package/lib/utils/positioning.js.map +1 -0
- package/lib/utils/property-capture.d.ts.map +1 -0
- package/lib/utils/property-capture.js +36 -36
- package/lib/utils/property-capture.js.map +1 -0
- package/lib/utils/property-manager.d.ts +1 -1
- package/lib/utils/property-manager.d.ts.map +1 -0
- package/lib/utils/property-manager.js +127 -125
- package/lib/utils/property-manager.js.map +1 -0
- package/lib/utils/resize-observer.d.ts.map +1 -0
- package/lib/utils/resize-observer.js +23 -23
- package/lib/utils/resize-observer.js.map +1 -0
- package/lib/utils/scroll-lock.d.ts.map +1 -0
- package/lib/utils/scroll-lock.js +57 -57
- package/lib/utils/scroll-lock.js.map +1 -0
- package/lib/utils/styles.d.ts.map +1 -0
- package/lib/utils/styles.js +17 -17
- package/lib/utils/styles.js.map +1 -0
- package/lib/utils/validity.d.ts +26 -0
- package/lib/utils/validity.js +53 -0
- package/lib/version.d.ts +1 -1
- package/lib/version.d.ts.map +1 -0
- package/lib/version.js +1 -1
- package/lib/version.js.map +1 -0
- package/package.json +28 -7
package/lib/components/wizard.js
CHANGED
|
@@ -1,442 +1,406 @@
|
|
|
1
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
2
2
|
import { wizardStyles } from '../styles/wizard.js';
|
|
3
3
|
const eventHandlers = new WeakMap();
|
|
4
|
-
const resizeObservers = new WeakMap();
|
|
5
4
|
function getWizardAttributes(el) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
return {
|
|
6
|
+
width: el.getAttribute('width') || '100%',
|
|
7
|
+
height: el.getAttribute('height') || '',
|
|
8
|
+
active: el.getAttribute('active'),
|
|
9
|
+
completed: el.getAttribute('completed') || '',
|
|
10
|
+
orientation: (el.getAttribute('orientation') || 'horizontal'),
|
|
11
|
+
};
|
|
13
12
|
}
|
|
14
13
|
function getChildSteps(el) {
|
|
15
|
-
|
|
14
|
+
return Array.from(el.querySelectorAll('ty-step'));
|
|
16
15
|
}
|
|
17
16
|
function getStepId(step) {
|
|
18
|
-
|
|
17
|
+
return step.getAttribute('id');
|
|
19
18
|
}
|
|
20
19
|
function getCompletedStepIds(el) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
20
|
+
const completedAttr = el.getAttribute('completed') || '';
|
|
21
|
+
if (!completedAttr.trim())
|
|
22
|
+
return new Set();
|
|
23
|
+
return new Set(completedAttr.split(',').map(id => id.trim()).filter(Boolean));
|
|
25
24
|
}
|
|
26
25
|
function hasCustomIndicator(wizardEl, stepId) {
|
|
27
|
-
|
|
26
|
+
return wizardEl.querySelector(`[slot='indicator-${stepId}']`) !== null;
|
|
28
27
|
}
|
|
29
28
|
function isStepDisabled(step) {
|
|
30
|
-
|
|
29
|
+
return step.hasAttribute('disabled');
|
|
31
30
|
}
|
|
32
31
|
function findStepIndex(steps, stepId) {
|
|
33
|
-
|
|
34
|
-
|
|
32
|
+
const index = steps.findIndex(step => getStepId(step) === stepId);
|
|
33
|
+
return index >= 0 ? index : undefined;
|
|
35
34
|
}
|
|
36
35
|
function getActiveStepId(el, steps) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
if (steps.length > 0) {
|
|
42
|
-
return getStepId(steps[0]);
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
36
|
+
const activeAttr = el.getAttribute('active');
|
|
37
|
+
if (activeAttr && findStepIndex(steps, activeAttr) !== undefined) {
|
|
38
|
+
return activeAttr;
|
|
45
39
|
}
|
|
46
|
-
|
|
47
|
-
|
|
40
|
+
if (steps.length > 0) {
|
|
41
|
+
return getStepId(steps[0]);
|
|
48
42
|
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return (activeIndex / (steps.length - 1)) * 100;
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
function setActiveStep(el, stepId) {
|
|
46
|
+
el.setAttribute('active', stepId);
|
|
54
47
|
}
|
|
55
48
|
function dispatchStepChangeEvent(el, activeId, activeIndex, previousId, previousIndex) {
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
49
|
+
const direction = previousIndex === null ? 'none'
|
|
50
|
+
: activeIndex > previousIndex ? 'forward'
|
|
51
|
+
: activeIndex < previousIndex ? 'backward'
|
|
52
|
+
: 'none';
|
|
53
|
+
const event = new CustomEvent('ty-wizard-step-change', {
|
|
54
|
+
detail: {
|
|
55
|
+
activeId,
|
|
56
|
+
activeIndex,
|
|
57
|
+
previousId,
|
|
58
|
+
previousIndex,
|
|
59
|
+
direction,
|
|
60
|
+
},
|
|
61
|
+
bubbles: true,
|
|
62
|
+
cancelable: false,
|
|
63
|
+
});
|
|
64
|
+
el.dispatchEvent(event);
|
|
72
65
|
}
|
|
73
66
|
function handleStepClick(el, stepId, event) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
67
|
+
event.preventDefault();
|
|
68
|
+
event.stopPropagation();
|
|
69
|
+
const steps = getChildSteps(el);
|
|
70
|
+
const targetIndex = steps.findIndex(s => getStepId(s) === stepId);
|
|
71
|
+
if (targetIndex < 0)
|
|
72
|
+
return;
|
|
73
|
+
const currentActive = getActiveStepId(el, steps);
|
|
74
|
+
const currentIndex = currentActive ? findStepIndex(steps, currentActive) ?? null : null;
|
|
75
|
+
const direction = currentIndex === null ? 'none'
|
|
76
|
+
: targetIndex > currentIndex ? 'forward'
|
|
77
|
+
: targetIndex < currentIndex ? 'backward'
|
|
78
|
+
: 'none';
|
|
79
|
+
const event2 = new CustomEvent('ty-wizard-step-change', {
|
|
80
|
+
detail: {
|
|
81
|
+
activeId: stepId,
|
|
82
|
+
activeIndex: targetIndex,
|
|
83
|
+
previousId: currentActive,
|
|
84
|
+
previousIndex: currentIndex,
|
|
85
|
+
direction,
|
|
86
|
+
},
|
|
87
|
+
bubbles: true,
|
|
88
|
+
cancelable: false,
|
|
89
|
+
});
|
|
90
|
+
el.dispatchEvent(event2);
|
|
98
91
|
}
|
|
99
92
|
function cleanupEventListeners(el) {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
93
|
+
const handlers = eventHandlers.get(el);
|
|
94
|
+
if (!handlers)
|
|
95
|
+
return;
|
|
96
|
+
const shadowRoot = el.shadowRoot;
|
|
97
|
+
if (!shadowRoot)
|
|
98
|
+
return;
|
|
99
|
+
handlers.stepClickHandlers.forEach((handler, stepId) => {
|
|
100
|
+
const button = shadowRoot.querySelector(`[data-step-id='${stepId}']`);
|
|
101
|
+
if (button) {
|
|
102
|
+
button.removeEventListener('pointerdown', handler);
|
|
103
|
+
button.removeEventListener('click', handler);
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
handlers.stepClickHandlers.clear();
|
|
113
107
|
}
|
|
114
108
|
function setupEventListeners(el, shadowRoot, steps) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
const panelsWrapper = shadowRoot.querySelector('.panels-wrapper');
|
|
137
|
-
if (!panelsWrapper)
|
|
138
|
-
return;
|
|
139
|
-
const containerWidth = el.offsetWidth;
|
|
140
|
-
const offsetPx = activeIndex * containerWidth;
|
|
141
|
-
panelsWrapper.style.transform = `translateX(-${offsetPx}px)`;
|
|
142
|
-
}
|
|
143
|
-
function updateProgressLine(el) {
|
|
144
|
-
const shadowRoot = el.shadowRoot;
|
|
145
|
-
if (!shadowRoot)
|
|
146
|
-
return;
|
|
147
|
-
const progressOverlay = shadowRoot.querySelector('.progress-overlay');
|
|
148
|
-
if (!progressOverlay)
|
|
149
|
-
return;
|
|
150
|
-
const steps = getChildSteps(el);
|
|
151
|
-
const activeId = getActiveStepId(el, steps);
|
|
152
|
-
const completedIds = getCompletedStepIds(el);
|
|
153
|
-
const progressPercent = calculateProgressPercent(steps, activeId, completedIds);
|
|
154
|
-
progressOverlay.style.width = `${progressPercent}%`;
|
|
109
|
+
cleanupEventListeners(el);
|
|
110
|
+
const handlers = {
|
|
111
|
+
stepClickHandlers: new Map(),
|
|
112
|
+
};
|
|
113
|
+
steps.forEach((step) => {
|
|
114
|
+
const stepId = getStepId(step);
|
|
115
|
+
if (!stepId)
|
|
116
|
+
return;
|
|
117
|
+
const button = shadowRoot.querySelector(`[data-step-id='${stepId}']`);
|
|
118
|
+
if (button) {
|
|
119
|
+
const handler = (e) => {
|
|
120
|
+
if (e.type === 'click' && e.detail !== 0)
|
|
121
|
+
return;
|
|
122
|
+
handleStepClick(el, stepId, e);
|
|
123
|
+
};
|
|
124
|
+
button.addEventListener('pointerdown', handler);
|
|
125
|
+
button.addEventListener('click', handler);
|
|
126
|
+
handlers.stepClickHandlers.set(stepId, handler);
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
eventHandlers.set(el, handlers);
|
|
155
130
|
}
|
|
156
131
|
function updateStepIndicators(el, shadowRoot, activeId) {
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}
|
|
180
|
-
});
|
|
132
|
+
const steps = getChildSteps(el);
|
|
133
|
+
const completedIds = getCompletedStepIds(el);
|
|
134
|
+
steps.forEach((step) => {
|
|
135
|
+
const stepId = getStepId(step);
|
|
136
|
+
if (!stepId)
|
|
137
|
+
return;
|
|
138
|
+
const button = shadowRoot.querySelector(`[data-step-id='${stepId}']`);
|
|
139
|
+
const circle = shadowRoot.querySelector(`[data-step-id='${stepId}'] .step-circle`);
|
|
140
|
+
const isActive = stepId === activeId;
|
|
141
|
+
if (button) {
|
|
142
|
+
button.setAttribute('aria-selected', String(isActive));
|
|
143
|
+
button.setAttribute('tabindex', isActive ? '0' : '-1');
|
|
144
|
+
button.setAttribute('data-active', String(isActive));
|
|
145
|
+
}
|
|
146
|
+
const state = getStepStatus(step, stepId, activeId, completedIds);
|
|
147
|
+
button?.setAttribute('data-state', state);
|
|
148
|
+
circle?.setAttribute('data-state', state);
|
|
149
|
+
const slottedIndicator = el.querySelector(`[slot='indicator-${stepId}']`);
|
|
150
|
+
if (slottedIndicator) {
|
|
151
|
+
slottedIndicator.setAttribute('data-active', String(isActive));
|
|
152
|
+
}
|
|
153
|
+
});
|
|
181
154
|
}
|
|
182
155
|
function updatePanelInteraction(el, activeId) {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
step.setAttribute('data-active', String(isActive));
|
|
190
|
-
if (isActive) {
|
|
191
|
-
step.style.pointerEvents = 'auto';
|
|
192
|
-
step.style.opacity = '1';
|
|
193
|
-
}
|
|
194
|
-
else {
|
|
195
|
-
step.style.pointerEvents = 'none';
|
|
196
|
-
step.style.opacity = '0';
|
|
197
|
-
}
|
|
198
|
-
});
|
|
156
|
+
getChildSteps(el).forEach((step) => {
|
|
157
|
+
const stepId = getStepId(step);
|
|
158
|
+
if (!stepId)
|
|
159
|
+
return;
|
|
160
|
+
step.setAttribute('data-active', String(stepId === activeId));
|
|
161
|
+
});
|
|
199
162
|
}
|
|
200
163
|
function updateActiveStepState(el, stepId) {
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
}
|
|
219
|
-
dispatchStepChangeEvent(el, stepId, newIndex, currentActive, currentIndex ?? null);
|
|
220
|
-
}
|
|
221
|
-
function setupResizeObserver(el) {
|
|
222
|
-
const oldObserver = resizeObservers.get(el);
|
|
223
|
-
if (oldObserver) {
|
|
224
|
-
oldObserver.disconnect();
|
|
225
|
-
}
|
|
226
|
-
const { width } = getWizardAttributes(el);
|
|
227
|
-
if (width.includes('%')) {
|
|
228
|
-
const observer = new ResizeObserver((entries) => {
|
|
229
|
-
const entry = entries[0];
|
|
230
|
-
const measuredWidth = entry.contentRect.width;
|
|
231
|
-
const steps = getChildSteps(el);
|
|
232
|
-
const activeId = getActiveStepId(el, steps);
|
|
233
|
-
const activeIndex = activeId ? findStepIndex(steps, activeId) : 0;
|
|
234
|
-
el.style.setProperty('--ty-wizard-width', `${measuredWidth}px`);
|
|
235
|
-
if (activeIndex !== undefined) {
|
|
236
|
-
updateTransform(el, activeIndex);
|
|
237
|
-
}
|
|
238
|
-
});
|
|
239
|
-
observer.observe(el);
|
|
240
|
-
resizeObservers.set(el, observer);
|
|
241
|
-
}
|
|
242
|
-
}
|
|
243
|
-
function cleanupResizeObserver(el) {
|
|
244
|
-
const observer = resizeObservers.get(el);
|
|
245
|
-
if (observer) {
|
|
246
|
-
observer.disconnect();
|
|
247
|
-
resizeObservers.delete(el);
|
|
248
|
-
}
|
|
164
|
+
const steps = getChildSteps(el);
|
|
165
|
+
const shadowRoot = el.shadowRoot;
|
|
166
|
+
if (!shadowRoot)
|
|
167
|
+
return;
|
|
168
|
+
const currentActive = getActiveStepId(el, steps);
|
|
169
|
+
const currentIndex = currentActive ? findStepIndex(steps, currentActive) : undefined;
|
|
170
|
+
const newIndex = findStepIndex(steps, stepId);
|
|
171
|
+
if (currentActive === stepId || newIndex === undefined)
|
|
172
|
+
return;
|
|
173
|
+
el.style.setProperty('--ty-wizard-active-index', String(newIndex));
|
|
174
|
+
updateStepIndicators(el, shadowRoot, stepId);
|
|
175
|
+
updatePanelInteraction(el, stepId);
|
|
176
|
+
const newPanel = steps[newIndex];
|
|
177
|
+
if (newPanel?.resetScroll) {
|
|
178
|
+
newPanel.resetScroll();
|
|
179
|
+
}
|
|
180
|
+
dispatchStepChangeEvent(el, stepId, newIndex, currentActive, currentIndex ?? null);
|
|
249
181
|
}
|
|
250
182
|
function getStepStatus(step, stepId, activeId, completedIds) {
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
183
|
+
const explicitStatus = step.getAttribute('status');
|
|
184
|
+
if (explicitStatus && ['completed', 'active', 'pending', 'error'].includes(explicitStatus)) {
|
|
185
|
+
return explicitStatus;
|
|
186
|
+
}
|
|
187
|
+
const isActive = stepId === activeId;
|
|
188
|
+
const isCompleted = completedIds.has(stepId);
|
|
189
|
+
return isActive ? 'active' : isCompleted ? 'completed' : 'pending';
|
|
258
190
|
}
|
|
191
|
+
const CHECK_SVG = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><polyline points="20 6 9 17 4 12"></polyline></svg>`;
|
|
192
|
+
const ALERT_SVG = `<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3" stroke-linecap="round" aria-hidden="true"><line x1="12" y1="5" x2="12" y2="13"></line><line x1="12" y1="18.5" x2="12" y2="18.6"></line></svg>`;
|
|
193
|
+
const STATE_TEXT = {
|
|
194
|
+
completed: 'completed',
|
|
195
|
+
active: 'current',
|
|
196
|
+
pending: 'not started',
|
|
197
|
+
error: 'has an error',
|
|
198
|
+
};
|
|
259
199
|
function renderStepIndicators(wizardEl, steps, activeId, completedIds) {
|
|
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
|
-
|
|
200
|
+
const total = steps.length;
|
|
201
|
+
const activeIndex = Math.max(0, activeId ? steps.findIndex(s => getStepId(s) === activeId) : 0);
|
|
202
|
+
const indicators = steps.map((step, index) => {
|
|
203
|
+
const stepId = getStepId(step);
|
|
204
|
+
if (!stepId)
|
|
205
|
+
return '';
|
|
206
|
+
const label = step.getAttribute('label') || `Step ${index + 1}`;
|
|
207
|
+
const description = step.getAttribute('description') || '';
|
|
208
|
+
const disabled = isStepDisabled(step);
|
|
209
|
+
const isActive = stepId === activeId;
|
|
210
|
+
const state = getStepStatus(step, stepId, activeId, completedIds);
|
|
211
|
+
const circleContent = hasCustomIndicator(wizardEl, stepId)
|
|
212
|
+
? `<slot name="indicator-${stepId}"></slot>`
|
|
213
|
+
: state === 'completed' ? CHECK_SVG
|
|
214
|
+
: state === 'error' ? ALERT_SVG
|
|
215
|
+
: `<span aria-hidden="true">${index + 1}</span>`;
|
|
216
|
+
return `<button
|
|
217
|
+
class="step-indicator"
|
|
218
|
+
role="tab"
|
|
219
|
+
type="button"
|
|
220
|
+
data-step-id="${stepId}"
|
|
221
|
+
id="step-${stepId}"
|
|
222
|
+
data-state="${state}"
|
|
223
|
+
data-done="${state === 'completed' || (state === 'active' && completedIds.has(stepId))}"
|
|
224
|
+
aria-selected="${isActive}"
|
|
225
|
+
tabindex="${isActive ? '0' : '-1'}"
|
|
226
|
+
data-active="${isActive}"
|
|
227
|
+
${disabled ? 'disabled aria-disabled="true"' : ''}
|
|
228
|
+
>
|
|
229
|
+
<span class="step-circle" data-state="${state}" part="step-circle">${circleContent}</span>
|
|
230
|
+
<span class="step-text">
|
|
231
|
+
<span class="step-label">${label}</span>
|
|
232
|
+
${description ? `<span class="step-description">${description}</span>` : ''}
|
|
233
|
+
<span class="sr-only">, step ${index + 1} of ${total}, ${STATE_TEXT[state] ?? state}</span>
|
|
234
|
+
</span>
|
|
235
|
+
</button>`;
|
|
236
|
+
}).join('');
|
|
237
|
+
const active = steps[activeIndex];
|
|
238
|
+
const activeLabel = active ? (active.getAttribute('label') || `Step ${activeIndex + 1}`) : '';
|
|
239
|
+
const activeDescription = active?.getAttribute('description') || '';
|
|
240
|
+
const segments = steps.map((step) => {
|
|
241
|
+
const stepId = getStepId(step) || '';
|
|
242
|
+
return `<span class="compact-segment" data-state="${getStepStatus(step, stepId, activeId, completedIds)}"></span>`;
|
|
243
|
+
}).join('');
|
|
244
|
+
return `
|
|
245
|
+
<div class="step-indicators-wrapper" part="indicators-wrapper">
|
|
246
|
+
<div class="step-indicators" role="tablist" aria-label="Steps">
|
|
247
|
+
${indicators}
|
|
248
|
+
</div>
|
|
249
|
+
<div class="step-compact">
|
|
250
|
+
<div class="compact-top">
|
|
251
|
+
<span class="compact-where">
|
|
252
|
+
<span class="compact-count">Step ${total ? activeIndex + 1 : 0} of ${total}</span>
|
|
253
|
+
<span class="compact-label">${activeLabel}</span>
|
|
254
|
+
</span>
|
|
255
|
+
${activeDescription ? `<span class="compact-description">${activeDescription}</span>` : ''}
|
|
256
|
+
</div>
|
|
257
|
+
<div class="compact-segments" part="progress">${segments}</div>
|
|
258
|
+
</div>
|
|
259
|
+
</div>
|
|
260
|
+
`;
|
|
317
261
|
}
|
|
318
262
|
function render(el) {
|
|
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
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
updateProgressLine(el);
|
|
383
|
-
});
|
|
384
|
-
setupEventListeners(el, shadowRoot, steps);
|
|
385
|
-
updateStepIndicators(el, shadowRoot, activeId || '');
|
|
386
|
-
setupResizeObserver(el);
|
|
387
|
-
if (activeId) {
|
|
388
|
-
updatePanelInteraction(el, activeId);
|
|
389
|
-
}
|
|
390
|
-
}
|
|
263
|
+
const shadowRoot = el.shadowRoot;
|
|
264
|
+
if (!shadowRoot)
|
|
265
|
+
return;
|
|
266
|
+
const { width, height } = getWizardAttributes(el);
|
|
267
|
+
const steps = getChildSteps(el);
|
|
268
|
+
const activeId = getActiveStepId(el, steps);
|
|
269
|
+
const completedIds = getCompletedStepIds(el);
|
|
270
|
+
steps.forEach((step) => {
|
|
271
|
+
const stepId = getStepId(step);
|
|
272
|
+
if (!stepId)
|
|
273
|
+
return;
|
|
274
|
+
step.setAttribute('role', 'tabpanel');
|
|
275
|
+
step.setAttribute('aria-labelledby', `step-${stepId}`);
|
|
276
|
+
step.setAttribute('tabindex', '0');
|
|
277
|
+
});
|
|
278
|
+
ensureStyles(shadowRoot, { css: wizardStyles, id: 'ty-wizard' });
|
|
279
|
+
el.style.setProperty('--ty-wizard-width', width);
|
|
280
|
+
el.style.setProperty('--ty-wizard-active-index', String(Math.max(0, activeId ? steps.findIndex(s => getStepId(s) === activeId) : 0)));
|
|
281
|
+
if (height)
|
|
282
|
+
el.style.setProperty('--ty-wizard-panel-height', height);
|
|
283
|
+
else
|
|
284
|
+
el.style.removeProperty('--ty-wizard-panel-height');
|
|
285
|
+
let container = shadowRoot.querySelector('.wizard-container');
|
|
286
|
+
let viewport = shadowRoot.querySelector('.panels-viewport');
|
|
287
|
+
if (!container || !viewport) {
|
|
288
|
+
shadowRoot.innerHTML = `
|
|
289
|
+
<div class="wizard-container">
|
|
290
|
+
<div class="panels-viewport" part="panels-container">
|
|
291
|
+
<div class="panels-wrapper">
|
|
292
|
+
<slot></slot>
|
|
293
|
+
</div>
|
|
294
|
+
</div>
|
|
295
|
+
</div>
|
|
296
|
+
`;
|
|
297
|
+
container = shadowRoot.querySelector('.wizard-container');
|
|
298
|
+
viewport = shadowRoot.querySelector('.panels-viewport');
|
|
299
|
+
}
|
|
300
|
+
shadowRoot.querySelector('.step-indicators-wrapper')?.remove();
|
|
301
|
+
const tmp = document.createElement('div');
|
|
302
|
+
tmp.innerHTML = renderStepIndicators(el, steps, activeId, completedIds);
|
|
303
|
+
container.insertBefore(tmp.firstElementChild, viewport);
|
|
304
|
+
setupEventListeners(el, shadowRoot, steps);
|
|
305
|
+
updateStepIndicators(el, shadowRoot, activeId || '');
|
|
306
|
+
if (activeId)
|
|
307
|
+
updatePanelInteraction(el, activeId);
|
|
308
|
+
if (!resizeObservers.has(el)) {
|
|
309
|
+
const ro = new ResizeObserver(() => updateCompact(el));
|
|
310
|
+
ro.observe(el);
|
|
311
|
+
resizeObservers.set(el, ro);
|
|
312
|
+
document.fonts?.ready.then(() => el.isConnected && updateCompact(el));
|
|
313
|
+
}
|
|
314
|
+
updateCompact(el);
|
|
315
|
+
}
|
|
316
|
+
function updateCompact(el) {
|
|
317
|
+
const shadowRoot = el.shadowRoot;
|
|
318
|
+
const container = shadowRoot?.querySelector('.wizard-container');
|
|
319
|
+
const wrapper = shadowRoot?.querySelector('.step-indicators-wrapper');
|
|
320
|
+
const rail = shadowRoot?.querySelector('.step-indicators');
|
|
321
|
+
if (!container || !wrapper || !rail)
|
|
322
|
+
return;
|
|
323
|
+
let compact;
|
|
324
|
+
if (el.getAttribute('orientation') === 'vertical') {
|
|
325
|
+
compact = el.clientWidth < 360;
|
|
391
326
|
}
|
|
327
|
+
else {
|
|
328
|
+
const buttons = Array.from(rail.querySelectorAll('.step-indicator'));
|
|
329
|
+
const px = (v) => parseFloat(v) || 0;
|
|
330
|
+
let natural = px(getComputedStyle(rail).columnGap) * Math.max(0, buttons.length - 1);
|
|
331
|
+
buttons.forEach((b, i) => {
|
|
332
|
+
const circle = b.querySelector('.step-circle');
|
|
333
|
+
const texts = Array.from(b.querySelectorAll('.step-label, .step-description'));
|
|
334
|
+
natural += (circle?.offsetWidth ?? 0) + px(getComputedStyle(b).columnGap)
|
|
335
|
+
+ Math.max(0, ...texts.map((t) => t.scrollWidth));
|
|
336
|
+
if (i < buttons.length - 1) {
|
|
337
|
+
const after = getComputedStyle(b, '::after');
|
|
338
|
+
natural += px(getComputedStyle(b).columnGap) + px(after.minWidth) + px(after.marginLeft);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
const cs = getComputedStyle(wrapper);
|
|
342
|
+
const available = wrapper.clientWidth - parseFloat(cs.paddingLeft) - parseFloat(cs.paddingRight);
|
|
343
|
+
compact = natural > available + 0.5;
|
|
344
|
+
}
|
|
345
|
+
container.classList.toggle('compact', compact);
|
|
346
|
+
}
|
|
347
|
+
const resizeObservers = new WeakMap();
|
|
392
348
|
function cleanup(el) {
|
|
393
|
-
|
|
394
|
-
|
|
349
|
+
cleanupEventListeners(el);
|
|
350
|
+
resizeObservers.get(el)?.disconnect();
|
|
351
|
+
resizeObservers.delete(el);
|
|
395
352
|
}
|
|
396
353
|
export class TyWizard extends HTMLElement {
|
|
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
|
-
|
|
354
|
+
static get observedAttributes() {
|
|
355
|
+
return ['width', 'height', 'active', 'completed', 'orientation'];
|
|
356
|
+
}
|
|
357
|
+
constructor() {
|
|
358
|
+
super();
|
|
359
|
+
this._childObserver = null;
|
|
360
|
+
this._childRenderQueued = false;
|
|
361
|
+
this.attachShadow({ mode: 'open' });
|
|
362
|
+
}
|
|
363
|
+
connectedCallback() {
|
|
364
|
+
render(this);
|
|
365
|
+
this._childObserver = new MutationObserver((records) => {
|
|
366
|
+
const relevant = records.some((r) => (r.type === 'childList' && r.target === this) ||
|
|
367
|
+
(r.target.tagName === 'TY-STEP' && r.target.parentElement === this));
|
|
368
|
+
if (!relevant || this._childRenderQueued)
|
|
369
|
+
return;
|
|
370
|
+
this._childRenderQueued = true;
|
|
371
|
+
queueMicrotask(() => {
|
|
372
|
+
this._childRenderQueued = false;
|
|
373
|
+
if (this.isConnected)
|
|
374
|
+
render(this);
|
|
375
|
+
});
|
|
376
|
+
});
|
|
377
|
+
this._childObserver.observe(this, {
|
|
378
|
+
childList: true,
|
|
379
|
+
subtree: true,
|
|
380
|
+
attributes: true,
|
|
381
|
+
attributeFilter: ['status', 'label', 'description', 'disabled'],
|
|
382
|
+
});
|
|
383
|
+
}
|
|
384
|
+
disconnectedCallback() {
|
|
385
|
+
this._childObserver?.disconnect();
|
|
386
|
+
this._childObserver = null;
|
|
387
|
+
cleanup(this);
|
|
388
|
+
}
|
|
389
|
+
attributeChangedCallback(name, oldValue, newValue) {
|
|
390
|
+
if (name === 'active') {
|
|
391
|
+
if (newValue) {
|
|
392
|
+
updateActiveStepState(this, newValue);
|
|
393
|
+
}
|
|
394
|
+
render(this);
|
|
395
|
+
}
|
|
396
|
+
else if (name === 'completed') {
|
|
397
|
+
render(this);
|
|
398
|
+
}
|
|
399
|
+
else {
|
|
400
|
+
render(this);
|
|
401
|
+
}
|
|
402
|
+
}
|
|
439
403
|
}
|
|
440
404
|
if (!customElements.get('ty-wizard')) {
|
|
441
|
-
|
|
405
|
+
customElements.define('ty-wizard', TyWizard);
|
|
442
406
|
}
|