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