tyrell-components 1.0.0-TC9 → 1.0.0-rc.21
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/AGENTS.md +122 -0
- package/CHANGELOG.md +1531 -0
- package/README.md +71 -53
- package/css/tyrell-colors-static.css +1 -0
- package/css/tyrell-theme.css +1 -0
- package/css/tyrell.css +1 -1783
- package/dist/tyrell-colors-static.css +1 -0
- package/dist/tyrell-theme.css +1 -0
- package/dist/tyrell.css +1 -1783
- package/dist/tyrell.js +1 -1
- package/guides/AGENT_INSTRUCTIONS.md +124 -0
- package/guides/AI_GUIDE.md +53 -0
- package/guides/CSS_GUIDE.md +1016 -0
- package/guides/DATASTAR_TY_GUIDE.md +657 -0
- package/guides/ICONS_GUIDE.md +212 -0
- package/guides/TY_GUIDE.md +935 -0
- package/guides/clj/CLOJURESCRIPT_GUIDE.md +300 -0
- package/guides/clj/CODE_SPLITTING.md +279 -0
- package/guides/clj/COMPONENT_GUIDE.md +391 -0
- package/guides/clj/HELIX_TY_GUIDE.md +428 -0
- package/guides/clj/I18N_GUIDE.md +478 -0
- package/guides/clj/LAYOUT_GUIDE.md +273 -0
- package/guides/clj/QUICKSTART.md +266 -0
- package/guides/clj/REAGENT_TY_GUIDE.md +408 -0
- package/guides/clj/REPLICANT_TY_GUIDE.md +623 -0
- package/guides/clj/ROUTING_GUIDE.md +346 -0
- package/guides/clj/UIX_TY_GUIDE.md +319 -0
- package/guides/js/HTMX_TY_GUIDE.md +252 -0
- package/guides/js/JAVASCRIPT_GUIDE.md +388 -0
- package/guides/js/REACT_TY_GUIDE.md +983 -0
- package/guides/js/SVELTE_TY_GUIDE.md +682 -0
- package/guides/js/TYCOMPONENT_GUIDE.md +962 -0
- package/guides/js/VUE_TY_GUIDE.md +738 -0
- package/lib/base/ty-component.d.ts +57 -13
- package/lib/base/ty-component.js +266 -292
- package/lib/components/button.d.ts +33 -18
- package/lib/components/button.js +317 -267
- package/lib/components/calendar-month.d.ts +30 -47
- package/lib/components/calendar-month.js +455 -429
- package/lib/components/calendar-navigation.d.ts +41 -49
- package/lib/components/calendar-navigation.js +287 -346
- package/lib/components/calendar.d.ts +73 -83
- package/lib/components/calendar.js +837 -762
- package/lib/components/checkbox.d.ts +26 -75
- package/lib/components/checkbox.js +298 -391
- package/lib/components/copy.d.ts +20 -60
- package/lib/components/copy.js +276 -380
- package/lib/components/date-picker.d.ts +100 -183
- package/lib/components/date-picker.js +1155 -1570
- package/lib/components/file-upload.d.ts +16 -15
- package/lib/components/file-upload.js +436 -426
- package/lib/components/icon.d.ts +3 -24
- package/lib/components/icon.js +141 -230
- package/lib/components/input.d.ts +93 -108
- package/lib/components/input.js +734 -710
- package/lib/components/modal.d.ts +39 -29
- package/lib/components/modal.js +419 -438
- package/lib/components/option.d.ts +20 -35
- package/lib/components/option.js +184 -309
- package/lib/components/popup.d.ts +2 -17
- package/lib/components/popup.js +353 -347
- package/lib/components/radio.d.ts +33 -25
- package/lib/components/radio.js +433 -422
- package/lib/components/resize-observer.d.ts +3 -30
- package/lib/components/resize-observer.js +71 -103
- package/lib/components/scroll-container.d.ts +21 -14
- package/lib/components/scroll-container.js +292 -234
- package/lib/components/select.d.ts +446 -0
- package/lib/components/select.js +1381 -0
- package/lib/components/selected-tags.d.ts +60 -0
- package/lib/components/selected-tags.js +225 -0
- package/lib/components/sortable.d.ts +175 -0
- package/lib/components/sortable.js +1844 -0
- package/lib/components/step.d.ts +1 -6
- package/lib/components/step.js +62 -68
- package/lib/components/switch.d.ts +15 -15
- package/lib/components/switch.js +237 -231
- package/lib/components/tab.d.ts +50 -7
- package/lib/components/tab.js +203 -69
- package/lib/components/tabs.d.ts +19 -64
- package/lib/components/tabs.js +600 -618
- package/lib/components/tag.d.ts +14 -52
- package/lib/components/tag.js +231 -306
- package/lib/components/textarea.d.ts +58 -89
- package/lib/components/textarea.js +523 -573
- package/lib/components/tooltip.d.ts +8 -13
- package/lib/components/tooltip.js +322 -409
- package/lib/components/wizard.d.ts +7 -54
- package/lib/components/wizard.js +376 -606
- package/lib/icons/fontawesome/brands.d.ts +0 -1
- package/lib/icons/fontawesome/brands.js +0 -8
- package/lib/icons/fontawesome/regular.d.ts +0 -1
- package/lib/icons/fontawesome/regular.js +0 -8
- package/lib/icons/fontawesome/solid.d.ts +0 -1
- package/lib/icons/fontawesome/solid.js +0 -8
- package/lib/icons/heroicons/micro.d.ts +0 -1
- package/lib/icons/heroicons/micro.js +392 -400
- package/lib/icons/heroicons/mini.d.ts +0 -1
- package/lib/icons/heroicons/mini.js +382 -390
- package/lib/icons/heroicons/outline.d.ts +0 -1
- package/lib/icons/heroicons/outline.js +337 -345
- package/lib/icons/heroicons/solid.d.ts +0 -1
- package/lib/icons/heroicons/solid.js +407 -415
- package/lib/icons/lucide.d.ts +0 -1
- package/lib/icons/lucide.js +24479 -26351
- package/lib/icons/material/filled.d.ts +0 -1
- package/lib/icons/material/filled.js +9653 -9663
- package/lib/icons/material/outlined.d.ts +0 -1
- package/lib/icons/material/outlined.js +10271 -10281
- package/lib/icons/material/round.d.ts +0 -1
- package/lib/icons/material/round.js +10495 -10505
- package/lib/icons/material/sharp.d.ts +0 -1
- package/lib/icons/material/sharp.js +9905 -9915
- package/lib/icons/material/two-tone.d.ts +0 -1
- package/lib/icons/material/two-tone.js +12792 -12802
- package/lib/index.d.ts +7 -4
- package/lib/index.js +26 -39
- package/lib/styles/button.d.ts +24 -7
- package/lib/styles/button.js +285 -445
- package/lib/styles/calendar-month.d.ts +7 -6
- package/lib/styles/calendar-month.js +158 -226
- package/lib/styles/calendar-navigation.d.ts +2 -6
- package/lib/styles/calendar-navigation.js +108 -127
- package/lib/styles/calendar.d.ts +3 -3
- package/lib/styles/calendar.js +87 -23
- package/lib/styles/checkbox.d.ts +7 -6
- package/lib/styles/checkbox.js +101 -15
- package/lib/styles/copy.d.ts +3 -2
- package/lib/styles/copy.js +91 -71
- package/lib/styles/custom-scrollbar.d.ts +1 -2
- package/lib/styles/custom-scrollbar.js +80 -115
- package/lib/styles/date-picker.d.ts +4 -6
- package/lib/styles/date-picker.js +321 -388
- package/lib/styles/field-size.d.ts +6 -0
- package/lib/styles/field-size.js +91 -0
- package/lib/styles/file-upload.d.ts +1 -2
- package/lib/styles/file-upload.js +143 -188
- package/lib/styles/icon.d.ts +2 -6
- package/lib/styles/icon.js +92 -170
- package/lib/styles/input.d.ts +4 -7
- package/lib/styles/input.js +148 -643
- package/lib/styles/modal.d.ts +1 -2
- package/lib/styles/modal.js +127 -108
- package/lib/styles/option.d.ts +2 -6
- package/lib/styles/option.js +53 -96
- package/lib/styles/popup.d.ts +1 -2
- package/lib/styles/popup.js +47 -77
- package/lib/styles/radio.d.ts +3 -2
- package/lib/styles/radio.js +90 -116
- package/lib/styles/resize-observer.d.ts +1 -2
- package/lib/styles/resize-observer.js +2 -12
- package/lib/styles/scroll-container.d.ts +1 -2
- package/lib/styles/scroll-container.js +103 -146
- package/lib/styles/select-base.d.ts +8 -0
- package/lib/styles/select-base.js +747 -0
- package/lib/styles/select.d.ts +11 -0
- package/lib/styles/select.js +229 -0
- package/lib/styles/sortable.d.ts +16 -0
- package/lib/styles/sortable.js +85 -0
- package/lib/styles/step.d.ts +1 -2
- package/lib/styles/step.js +15 -34
- package/lib/styles/switch.d.ts +3 -2
- package/lib/styles/switch.js +52 -68
- package/lib/styles/tab.d.ts +1 -2
- package/lib/styles/tab.js +86 -34
- package/lib/styles/tabs.d.ts +3 -11
- package/lib/styles/tabs.js +204 -162
- package/lib/styles/tag.d.ts +2 -6
- package/lib/styles/tag.js +168 -362
- package/lib/styles/textarea.d.ts +1 -2
- package/lib/styles/textarea.js +238 -306
- package/lib/styles/tooltip.d.ts +4 -3
- package/lib/styles/tooltip.js +3 -131
- package/lib/styles/wizard.d.ts +8 -20
- package/lib/styles/wizard.js +306 -295
- package/lib/types/common.d.ts +9 -8
- package/lib/types/common.js +8 -5
- package/lib/utils/calendar-utils.d.ts +49 -65
- package/lib/utils/calendar-utils.js +158 -343
- package/lib/utils/custom-scrollbar.d.ts +6 -20
- package/lib/utils/custom-scrollbar.js +273 -317
- package/lib/utils/flavor-sheet.d.ts +31 -0
- package/lib/utils/flavor-sheet.js +17 -0
- package/lib/utils/icon-registry.d.ts +0 -15
- package/lib/utils/icon-registry.js +138 -279
- package/lib/utils/icons.d.ts +9 -0
- package/lib/utils/icons.js +1 -0
- package/lib/utils/loader-registry.d.ts +2 -3
- package/lib/utils/loader-registry.js +3 -35
- package/lib/utils/locale.d.ts +2 -80
- package/lib/utils/locale.js +30 -205
- package/lib/utils/mobile.d.ts +0 -1
- package/lib/utils/mobile.js +1 -18
- package/lib/utils/number-format.d.ts +6 -24
- package/lib/utils/number-format.js +53 -136
- package/lib/utils/positioning.d.ts +72 -22
- package/lib/utils/positioning.js +224 -298
- package/lib/utils/property-capture.d.ts +5 -27
- package/lib/utils/property-capture.js +36 -144
- package/lib/utils/property-manager.d.ts +6 -6
- package/lib/utils/property-manager.js +127 -196
- package/lib/utils/resize-observer.d.ts +0 -1
- package/lib/utils/resize-observer.js +23 -59
- package/lib/utils/scroll-lock.d.ts +10 -11
- package/lib/utils/scroll-lock.js +165 -173
- package/lib/utils/styles.d.ts +0 -6
- package/lib/utils/styles.js +17 -48
- package/lib/utils/upgrade-properties.d.ts +21 -0
- package/lib/utils/upgrade-properties.js +47 -0
- package/lib/utils/validity.d.ts +122 -0
- package/lib/utils/validity.js +289 -0
- package/lib/version.d.ts +1 -2
- package/lib/version.js +1 -11
- package/package.json +62 -18
- package/lib/base/ty-component.d.ts.map +0 -1
- package/lib/base/ty-component.js.map +0 -1
- package/lib/components/button.d.ts.map +0 -1
- package/lib/components/button.js.map +0 -1
- package/lib/components/calendar-month.d.ts.map +0 -1
- package/lib/components/calendar-month.js.map +0 -1
- package/lib/components/calendar-navigation.d.ts.map +0 -1
- package/lib/components/calendar-navigation.js.map +0 -1
- package/lib/components/calendar.d.ts.map +0 -1
- package/lib/components/calendar.js.map +0 -1
- package/lib/components/checkbox.d.ts.map +0 -1
- package/lib/components/checkbox.js.map +0 -1
- package/lib/components/copy.d.ts.map +0 -1
- package/lib/components/copy.js.map +0 -1
- package/lib/components/date-picker.d.ts.map +0 -1
- package/lib/components/date-picker.js.map +0 -1
- package/lib/components/dropdown.d.ts +0 -404
- package/lib/components/dropdown.d.ts.map +0 -1
- package/lib/components/dropdown.js +0 -1563
- package/lib/components/dropdown.js.map +0 -1
- package/lib/components/file-upload.d.ts.map +0 -1
- package/lib/components/file-upload.js.map +0 -1
- package/lib/components/icon.d.ts.map +0 -1
- package/lib/components/icon.js.map +0 -1
- package/lib/components/input.d.ts.map +0 -1
- package/lib/components/input.js.map +0 -1
- package/lib/components/modal.d.ts.map +0 -1
- package/lib/components/modal.js.map +0 -1
- package/lib/components/multiselect.d.ts +0 -408
- package/lib/components/multiselect.d.ts.map +0 -1
- package/lib/components/multiselect.js +0 -1611
- package/lib/components/multiselect.js.map +0 -1
- package/lib/components/option.d.ts.map +0 -1
- package/lib/components/option.js.map +0 -1
- package/lib/components/popup.d.ts.map +0 -1
- package/lib/components/popup.js.map +0 -1
- package/lib/components/radio.d.ts.map +0 -1
- package/lib/components/radio.js.map +0 -1
- package/lib/components/resize-observer.d.ts.map +0 -1
- package/lib/components/resize-observer.js.map +0 -1
- package/lib/components/scroll-container.d.ts.map +0 -1
- package/lib/components/scroll-container.js.map +0 -1
- package/lib/components/step.d.ts.map +0 -1
- package/lib/components/step.js.map +0 -1
- package/lib/components/switch.d.ts.map +0 -1
- package/lib/components/switch.js.map +0 -1
- package/lib/components/tab.d.ts.map +0 -1
- package/lib/components/tab.js.map +0 -1
- package/lib/components/tabs.d.ts.map +0 -1
- package/lib/components/tabs.js.map +0 -1
- package/lib/components/tag.d.ts.map +0 -1
- package/lib/components/tag.js.map +0 -1
- package/lib/components/textarea.d.ts.map +0 -1
- package/lib/components/textarea.js.map +0 -1
- package/lib/components/tooltip.d.ts.map +0 -1
- package/lib/components/tooltip.js.map +0 -1
- package/lib/components/wizard.d.ts.map +0 -1
- package/lib/components/wizard.js.map +0 -1
- package/lib/icons/fontawesome/brands.d.ts.map +0 -1
- package/lib/icons/fontawesome/brands.js.map +0 -1
- package/lib/icons/fontawesome/regular.d.ts.map +0 -1
- package/lib/icons/fontawesome/regular.js.map +0 -1
- package/lib/icons/fontawesome/solid.d.ts.map +0 -1
- package/lib/icons/fontawesome/solid.js.map +0 -1
- package/lib/icons/heroicons/micro.d.ts.map +0 -1
- package/lib/icons/heroicons/micro.js.map +0 -1
- package/lib/icons/heroicons/mini.d.ts.map +0 -1
- package/lib/icons/heroicons/mini.js.map +0 -1
- package/lib/icons/heroicons/outline.d.ts.map +0 -1
- package/lib/icons/heroicons/outline.js.map +0 -1
- package/lib/icons/heroicons/solid.d.ts.map +0 -1
- package/lib/icons/heroicons/solid.js.map +0 -1
- package/lib/icons/lucide.d.ts.map +0 -1
- package/lib/icons/lucide.js.map +0 -1
- package/lib/icons/material/filled.d.ts.map +0 -1
- package/lib/icons/material/filled.js.map +0 -1
- package/lib/icons/material/outlined.d.ts.map +0 -1
- package/lib/icons/material/outlined.js.map +0 -1
- package/lib/icons/material/round.d.ts.map +0 -1
- package/lib/icons/material/round.js.map +0 -1
- package/lib/icons/material/sharp.d.ts.map +0 -1
- package/lib/icons/material/sharp.js.map +0 -1
- package/lib/icons/material/two-tone.d.ts.map +0 -1
- package/lib/icons/material/two-tone.js.map +0 -1
- package/lib/index.d.ts.map +0 -1
- package/lib/index.js.map +0 -1
- package/lib/styles/button.d.ts.map +0 -1
- package/lib/styles/button.js.map +0 -1
- package/lib/styles/calendar-month.d.ts.map +0 -1
- package/lib/styles/calendar-month.js.map +0 -1
- package/lib/styles/calendar-navigation.d.ts.map +0 -1
- package/lib/styles/calendar-navigation.js.map +0 -1
- package/lib/styles/calendar.d.ts.map +0 -1
- package/lib/styles/calendar.js.map +0 -1
- package/lib/styles/checkbox.d.ts.map +0 -1
- package/lib/styles/checkbox.js.map +0 -1
- package/lib/styles/copy.d.ts.map +0 -1
- package/lib/styles/copy.js.map +0 -1
- package/lib/styles/custom-scrollbar.d.ts.map +0 -1
- package/lib/styles/custom-scrollbar.js.map +0 -1
- package/lib/styles/date-picker.d.ts.map +0 -1
- package/lib/styles/date-picker.js.map +0 -1
- package/lib/styles/dropdown.d.ts +0 -12
- package/lib/styles/dropdown.d.ts.map +0 -1
- package/lib/styles/dropdown.js +0 -1048
- package/lib/styles/dropdown.js.map +0 -1
- package/lib/styles/file-upload.d.ts.map +0 -1
- package/lib/styles/file-upload.js.map +0 -1
- package/lib/styles/icon.d.ts.map +0 -1
- package/lib/styles/icon.js.map +0 -1
- package/lib/styles/input.d.ts.map +0 -1
- package/lib/styles/input.js.map +0 -1
- package/lib/styles/modal.d.ts.map +0 -1
- package/lib/styles/modal.js.map +0 -1
- package/lib/styles/multiselect.d.ts +0 -6
- package/lib/styles/multiselect.d.ts.map +0 -1
- package/lib/styles/multiselect.js +0 -837
- package/lib/styles/multiselect.js.map +0 -1
- package/lib/styles/option.d.ts.map +0 -1
- package/lib/styles/option.js.map +0 -1
- package/lib/styles/popup.d.ts.map +0 -1
- package/lib/styles/popup.js.map +0 -1
- package/lib/styles/radio.d.ts.map +0 -1
- package/lib/styles/radio.js.map +0 -1
- package/lib/styles/resize-observer.d.ts.map +0 -1
- package/lib/styles/resize-observer.js.map +0 -1
- package/lib/styles/scroll-container.d.ts.map +0 -1
- package/lib/styles/scroll-container.js.map +0 -1
- package/lib/styles/step.d.ts.map +0 -1
- package/lib/styles/step.js.map +0 -1
- package/lib/styles/switch.d.ts.map +0 -1
- package/lib/styles/switch.js.map +0 -1
- package/lib/styles/tab.d.ts.map +0 -1
- package/lib/styles/tab.js.map +0 -1
- package/lib/styles/tabs.d.ts.map +0 -1
- package/lib/styles/tabs.js.map +0 -1
- package/lib/styles/tag.d.ts.map +0 -1
- package/lib/styles/tag.js.map +0 -1
- package/lib/styles/textarea.d.ts.map +0 -1
- package/lib/styles/textarea.js.map +0 -1
- package/lib/styles/tooltip.d.ts.map +0 -1
- package/lib/styles/tooltip.js.map +0 -1
- package/lib/styles/wizard.d.ts.map +0 -1
- package/lib/styles/wizard.js.map +0 -1
- package/lib/types/common.d.ts.map +0 -1
- package/lib/types/common.js.map +0 -1
- package/lib/utils/calendar-utils.d.ts.map +0 -1
- package/lib/utils/calendar-utils.js.map +0 -1
- package/lib/utils/custom-scrollbar.d.ts.map +0 -1
- package/lib/utils/custom-scrollbar.js.map +0 -1
- package/lib/utils/icon-registry.d.ts.map +0 -1
- package/lib/utils/icon-registry.js.map +0 -1
- package/lib/utils/loader-registry.d.ts.map +0 -1
- package/lib/utils/loader-registry.js.map +0 -1
- package/lib/utils/locale.d.ts.map +0 -1
- package/lib/utils/locale.js.map +0 -1
- package/lib/utils/mobile.d.ts.map +0 -1
- package/lib/utils/mobile.js.map +0 -1
- package/lib/utils/number-format.d.ts.map +0 -1
- package/lib/utils/number-format.js.map +0 -1
- package/lib/utils/parse-boolean.d.ts +0 -39
- package/lib/utils/parse-boolean.d.ts.map +0 -1
- package/lib/utils/parse-boolean.js +0 -58
- package/lib/utils/parse-boolean.js.map +0 -1
- package/lib/utils/positioning.d.ts.map +0 -1
- package/lib/utils/positioning.js.map +0 -1
- package/lib/utils/property-capture.d.ts.map +0 -1
- package/lib/utils/property-capture.js.map +0 -1
- package/lib/utils/property-manager.d.ts.map +0 -1
- package/lib/utils/property-manager.js.map +0 -1
- package/lib/utils/resize-observer.d.ts.map +0 -1
- package/lib/utils/resize-observer.js.map +0 -1
- package/lib/utils/scroll-lock.d.ts.map +0 -1
- package/lib/utils/scroll-lock.js.map +0 -1
- package/lib/utils/styles.d.ts.map +0 -1
- package/lib/utils/styles.js.map +0 -1
- package/lib/version.d.ts.map +0 -1
- package/lib/version.js.map +0 -1
package/lib/components/wizard.js
CHANGED
|
@@ -1,636 +1,406 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Wizard Component
|
|
3
|
-
*
|
|
4
|
-
* A carousel-based wizard/stepper component with smooth animations, progress tracking, and completion state.
|
|
5
|
-
* Features horizontal sliding transitions between steps, animated progress line, and step completion tracking.
|
|
6
|
-
* Behaves like tabs - a "dumb" component that only renders and fires events. All navigation and validation
|
|
7
|
-
* is controlled by the user.
|
|
8
|
-
*
|
|
9
|
-
* Features:
|
|
10
|
-
* - Carousel animation with smooth sliding transitions between steps
|
|
11
|
-
* - Fixed dimensions prevent layout shift between steps
|
|
12
|
-
* - Animated progress line showing completion status
|
|
13
|
-
* - Step indicators with completed/active/pending states
|
|
14
|
-
* - Rich indicator support via slots (icons, custom content)
|
|
15
|
-
* - Independent panel scrolling with scroll position reset
|
|
16
|
-
* - ResizeObserver for responsive percentage widths
|
|
17
|
-
* - Smart rendering - only updates DOM when necessary
|
|
18
|
-
* - Accessibility with ARIA roles and attributes
|
|
19
|
-
* - Fires events on step clicks - user controls navigation
|
|
20
|
-
*
|
|
21
|
-
* @example
|
|
22
|
-
* <!-- Basic wizard with text labels -->
|
|
23
|
-
* <ty-wizard width="900px" height="600px" active="welcome">
|
|
24
|
-
* <ty-step id="welcome" label="Welcome">
|
|
25
|
-
* <div class="p-6">
|
|
26
|
-
* <h1>Welcome!</h1>
|
|
27
|
-
* <button onclick="goToStep('account')">Next</button>
|
|
28
|
-
* </div>
|
|
29
|
-
* </ty-step>
|
|
30
|
-
* <ty-step id="account" label="Account Setup">
|
|
31
|
-
* <div class="p-6">
|
|
32
|
-
* <h2>Account Setup</h2>
|
|
33
|
-
* <button onclick="goToStep('welcome')">Previous</button>
|
|
34
|
-
* <button onclick="goToStep('complete')">Next</button>
|
|
35
|
-
* </div>
|
|
36
|
-
* </ty-step>
|
|
37
|
-
* </ty-wizard>
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* <!-- Wizard with custom indicators -->
|
|
41
|
-
* <ty-wizard width="100%" height="700px" active="welcome" completed="welcome,account">
|
|
42
|
-
* <!-- Custom indicator icons -->
|
|
43
|
-
* <div slot="indicator-welcome">
|
|
44
|
-
* <ty-icon name="hand" size="sm"></ty-icon>
|
|
45
|
-
* </div>
|
|
46
|
-
* <div slot="indicator-account">
|
|
47
|
-
* <span class="text-lg font-bold">1</span>
|
|
48
|
-
* </div>
|
|
49
|
-
*
|
|
50
|
-
* <ty-step id="welcome" label="Welcome">...</ty-step>
|
|
51
|
-
* <ty-step id="account" label="Account">...</ty-step>
|
|
52
|
-
* <ty-step id="profile" label="Profile">...</ty-step>
|
|
53
|
-
* </ty-wizard>
|
|
54
|
-
*/
|
|
55
1
|
import { ensureStyles } from '../utils/styles.js';
|
|
56
2
|
import { wizardStyles } from '../styles/wizard.js';
|
|
57
|
-
// ============================================================================
|
|
58
|
-
// WeakMaps for State Management
|
|
59
|
-
// ============================================================================
|
|
60
3
|
const eventHandlers = new WeakMap();
|
|
61
|
-
const resizeObservers = new WeakMap();
|
|
62
|
-
// ============================================================================
|
|
63
|
-
// Helper Functions - Attribute Parsing
|
|
64
|
-
// ============================================================================
|
|
65
|
-
/**
|
|
66
|
-
* Extract wizard configuration from element attributes
|
|
67
|
-
*/
|
|
68
4
|
function getWizardAttributes(el) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
/**
|
|
78
|
-
* Get all ty-step child elements
|
|
79
|
-
*/
|
|
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
|
+
};
|
|
12
|
+
}
|
|
80
13
|
function getChildSteps(el) {
|
|
81
|
-
|
|
14
|
+
return Array.from(el.querySelectorAll('ty-step'));
|
|
82
15
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Get ID from a ty-step element
|
|
85
|
-
*/
|
|
86
16
|
function getStepId(step) {
|
|
87
|
-
|
|
17
|
+
return step.getAttribute('id');
|
|
88
18
|
}
|
|
89
|
-
/**
|
|
90
|
-
* Get completed step IDs as a Set
|
|
91
|
-
*/
|
|
92
19
|
function getCompletedStepIds(el) {
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* Check if wizard has a direct child indicator slot for this step-id.
|
|
100
|
-
* Looks in ty-wizard's light DOM for slot='indicator-{step-id}' elements.
|
|
101
|
-
*/
|
|
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));
|
|
24
|
+
}
|
|
102
25
|
function hasCustomIndicator(wizardEl, stepId) {
|
|
103
|
-
|
|
26
|
+
return wizardEl.querySelector(`[slot='indicator-${stepId}']`) !== null;
|
|
104
27
|
}
|
|
105
|
-
/**
|
|
106
|
-
* Check if step is disabled
|
|
107
|
-
*/
|
|
108
28
|
function isStepDisabled(step) {
|
|
109
|
-
|
|
110
|
-
}
|
|
111
|
-
// ============================================================================
|
|
112
|
-
// Helper Functions - Active Step Management
|
|
113
|
-
// ============================================================================
|
|
114
|
-
/**
|
|
115
|
-
* Find index of step with given ID
|
|
116
|
-
*/
|
|
29
|
+
return step.hasAttribute('disabled');
|
|
30
|
+
}
|
|
117
31
|
function findStepIndex(steps, stepId) {
|
|
118
|
-
|
|
119
|
-
|
|
32
|
+
const index = steps.findIndex(step => getStepId(step) === stepId);
|
|
33
|
+
return index >= 0 ? index : undefined;
|
|
120
34
|
}
|
|
121
|
-
/**
|
|
122
|
-
* Get the active step ID, defaulting to first step if not specified
|
|
123
|
-
*/
|
|
124
35
|
function getActiveStepId(el, steps) {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
}
|
|
135
|
-
/**
|
|
136
|
-
* Set the active step by ID
|
|
137
|
-
*/
|
|
36
|
+
const activeAttr = el.getAttribute('active');
|
|
37
|
+
if (activeAttr && findStepIndex(steps, activeAttr) !== undefined) {
|
|
38
|
+
return activeAttr;
|
|
39
|
+
}
|
|
40
|
+
if (steps.length > 0) {
|
|
41
|
+
return getStepId(steps[0]);
|
|
42
|
+
}
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
138
45
|
function setActiveStep(el, stepId) {
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* Calculate progress percentage for the progress line overlay
|
|
143
|
-
*/
|
|
144
|
-
function calculateProgressPercent(steps, activeId, completedIds) {
|
|
145
|
-
if (steps.length <= 1 || !activeId)
|
|
146
|
-
return 0;
|
|
147
|
-
const activeIndex = steps.findIndex(s => getStepId(s) === activeId);
|
|
148
|
-
// Progress bar shows progress up to the currently active step
|
|
149
|
-
return (activeIndex / (steps.length - 1)) * 100;
|
|
150
|
-
}
|
|
151
|
-
/**
|
|
152
|
-
* Dispatch ty-wizard-step-change event
|
|
153
|
-
*/
|
|
46
|
+
el.setAttribute('active', stepId);
|
|
47
|
+
}
|
|
154
48
|
function dispatchStepChangeEvent(el, activeId, activeIndex, previousId, previousIndex) {
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
// ============================================================================
|
|
173
|
-
// Event Handlers - Step Indicator Click
|
|
174
|
-
// ============================================================================
|
|
175
|
-
/**
|
|
176
|
-
* Handle step indicator click - only dispatch event (like tabs)
|
|
177
|
-
*/
|
|
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);
|
|
65
|
+
}
|
|
178
66
|
function handleStepClick(el, stepId, event) {
|
|
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
|
-
* Cleanup existing event listeners
|
|
207
|
-
*/
|
|
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);
|
|
91
|
+
}
|
|
208
92
|
function cleanupEventListeners(el) {
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Setup event listeners for step indicator clicks
|
|
226
|
-
*/
|
|
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();
|
|
107
|
+
}
|
|
227
108
|
function setupEventListeners(el, shadowRoot, steps) {
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
// Transform & Positioning Updates
|
|
251
|
-
// ============================================================================
|
|
252
|
-
/**
|
|
253
|
-
* Update the transform on panels-wrapper based on active index and measured width
|
|
254
|
-
*/
|
|
255
|
-
function updateTransform(el, activeIndex) {
|
|
256
|
-
const shadowRoot = el.shadowRoot;
|
|
257
|
-
if (!shadowRoot)
|
|
258
|
-
return;
|
|
259
|
-
const panelsWrapper = shadowRoot.querySelector('.panels-wrapper');
|
|
260
|
-
if (!panelsWrapper)
|
|
261
|
-
return;
|
|
262
|
-
// Measure the actual width of the container
|
|
263
|
-
const containerWidth = el.offsetWidth;
|
|
264
|
-
const offsetPx = activeIndex * containerWidth;
|
|
265
|
-
// Apply transform directly in pixels
|
|
266
|
-
panelsWrapper.style.transform = `translateX(-${offsetPx}px)`;
|
|
267
|
-
}
|
|
268
|
-
/**
|
|
269
|
-
* Update progress line overlay width
|
|
270
|
-
*/
|
|
271
|
-
function updateProgressLine(el) {
|
|
272
|
-
const shadowRoot = el.shadowRoot;
|
|
273
|
-
if (!shadowRoot)
|
|
274
|
-
return;
|
|
275
|
-
const progressOverlay = shadowRoot.querySelector('.progress-overlay');
|
|
276
|
-
if (!progressOverlay)
|
|
277
|
-
return;
|
|
278
|
-
const steps = getChildSteps(el);
|
|
279
|
-
const activeId = getActiveStepId(el, steps);
|
|
280
|
-
const completedIds = getCompletedStepIds(el);
|
|
281
|
-
const progressPercent = calculateProgressPercent(steps, activeId, completedIds);
|
|
282
|
-
progressOverlay.style.width = `${progressPercent}%`;
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* Update ARIA attributes on step indicators without re-rendering
|
|
286
|
-
*/
|
|
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);
|
|
130
|
+
}
|
|
287
131
|
function updateStepIndicators(el, shadowRoot, activeId) {
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
slottedIndicator.setAttribute('data-active', String(isActive));
|
|
312
|
-
}
|
|
313
|
-
});
|
|
314
|
-
}
|
|
315
|
-
/**
|
|
316
|
-
* Update pointer-events, opacity, and data-active on step panels without re-rendering
|
|
317
|
-
*/
|
|
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
|
+
});
|
|
154
|
+
}
|
|
318
155
|
function updatePanelInteraction(el, activeId) {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
step.setAttribute('data-active', String(isActive));
|
|
327
|
-
if (isActive) {
|
|
328
|
-
step.style.pointerEvents = 'auto';
|
|
329
|
-
step.style.opacity = '1';
|
|
330
|
-
}
|
|
331
|
-
else {
|
|
332
|
-
step.style.pointerEvents = 'none';
|
|
333
|
-
step.style.opacity = '0';
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
}
|
|
337
|
-
/**
|
|
338
|
-
* Update only the active step state without re-rendering DOM.
|
|
339
|
-
* This is called when only the active or completed attribute changes.
|
|
340
|
-
*/
|
|
156
|
+
getChildSteps(el).forEach((step) => {
|
|
157
|
+
const stepId = getStepId(step);
|
|
158
|
+
if (!stepId)
|
|
159
|
+
return;
|
|
160
|
+
step.setAttribute('data-active', String(stepId === activeId));
|
|
161
|
+
});
|
|
162
|
+
}
|
|
341
163
|
function updateActiveStepState(el, stepId) {
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
// Update pointer-events on panels
|
|
361
|
-
updatePanelInteraction(el, stepId);
|
|
362
|
-
// Reset scroll position of new active panel
|
|
363
|
-
const newPanel = steps[newIndex];
|
|
364
|
-
if (newPanel?.resetScroll) {
|
|
365
|
-
newPanel.resetScroll();
|
|
366
|
-
}
|
|
367
|
-
// Dispatch change event
|
|
368
|
-
dispatchStepChangeEvent(el, stepId, newIndex, currentActive, currentIndex ?? null);
|
|
369
|
-
}
|
|
370
|
-
// ============================================================================
|
|
371
|
-
// ResizeObserver for Responsive Width
|
|
372
|
-
// ============================================================================
|
|
373
|
-
/**
|
|
374
|
-
* Setup ResizeObserver for percentage widths
|
|
375
|
-
*/
|
|
376
|
-
function setupResizeObserver(el) {
|
|
377
|
-
// Clean up old observer
|
|
378
|
-
const oldObserver = resizeObservers.get(el);
|
|
379
|
-
if (oldObserver) {
|
|
380
|
-
oldObserver.disconnect();
|
|
381
|
-
}
|
|
382
|
-
const { width } = getWizardAttributes(el);
|
|
383
|
-
// Only setup observer for percentage widths
|
|
384
|
-
if (width.includes('%')) {
|
|
385
|
-
const observer = new ResizeObserver((entries) => {
|
|
386
|
-
const entry = entries[0];
|
|
387
|
-
const measuredWidth = entry.contentRect.width;
|
|
388
|
-
const steps = getChildSteps(el);
|
|
389
|
-
const activeId = getActiveStepId(el, steps);
|
|
390
|
-
const activeIndex = activeId ? findStepIndex(steps, activeId) : 0;
|
|
391
|
-
// Update CSS variable with measured width
|
|
392
|
-
el.style.setProperty('--wizard-width', `${measuredWidth}px`);
|
|
393
|
-
// Update transform with new width
|
|
394
|
-
if (activeIndex !== undefined) {
|
|
395
|
-
updateTransform(el, activeIndex);
|
|
396
|
-
}
|
|
397
|
-
});
|
|
398
|
-
observer.observe(el);
|
|
399
|
-
resizeObservers.set(el, observer);
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
/**
|
|
403
|
-
* Cleanup ResizeObserver
|
|
404
|
-
*/
|
|
405
|
-
function cleanupResizeObserver(el) {
|
|
406
|
-
const observer = resizeObservers.get(el);
|
|
407
|
-
if (observer) {
|
|
408
|
-
observer.disconnect();
|
|
409
|
-
resizeObservers.delete(el);
|
|
410
|
-
}
|
|
411
|
-
}
|
|
412
|
-
// ============================================================================
|
|
413
|
-
// Rendering Functions
|
|
414
|
-
// ============================================================================
|
|
415
|
-
/**
|
|
416
|
-
* Get step status - use user's explicit status attribute or fall back to automatic detection
|
|
417
|
-
*/
|
|
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);
|
|
181
|
+
}
|
|
418
182
|
function getStepStatus(step, stepId, activeId, completedIds) {
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
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';
|
|
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
|
+
};
|
|
432
199
|
function renderStepIndicators(wizardEl, steps, activeId, completedIds) {
|
|
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
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
495
|
-
/**
|
|
496
|
-
* Render the wizard container with step indicators and panel viewport.
|
|
497
|
-
* Smart rendering: checks if structure exists and only updates when needed.
|
|
498
|
-
*/
|
|
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
|
+
`;
|
|
261
|
+
}
|
|
499
262
|
function render(el) {
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
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
|
-
|
|
583
|
-
}
|
|
584
|
-
|
|
585
|
-
* Cleanup when wizard component is disconnected
|
|
586
|
-
*/
|
|
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;
|
|
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();
|
|
587
348
|
function cleanup(el) {
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
// Component Definition
|
|
593
|
-
// ============================================================================
|
|
594
|
-
/**
|
|
595
|
-
* TyWizard Web Component
|
|
596
|
-
*/
|
|
349
|
+
cleanupEventListeners(el);
|
|
350
|
+
resizeObservers.get(el)?.disconnect();
|
|
351
|
+
resizeObservers.delete(el);
|
|
352
|
+
}
|
|
597
353
|
export class TyWizard extends HTMLElement {
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
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
|
+
}
|
|
403
|
+
}
|
|
633
404
|
if (!customElements.get('ty-wizard')) {
|
|
634
|
-
|
|
405
|
+
customElements.define('ty-wizard', TyWizard);
|
|
635
406
|
}
|
|
636
|
-
//# sourceMappingURL=wizard.js.map
|