tyrell-components 1.0.0-RC13 → 1.0.0-RC15

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 (358) hide show
  1. package/README.md +10 -2
  2. package/css/tyrell-theme.css +192 -180
  3. package/css/tyrell.css +23 -0
  4. package/dist/tyrell-colors-static.css +1 -316
  5. package/dist/tyrell-theme.css +1 -1454
  6. package/dist/tyrell.css +1 -1371
  7. package/dist/tyrell.js +1 -1
  8. package/lib/base/ty-component.d.ts +20 -10
  9. package/lib/base/ty-component.js +196 -319
  10. package/lib/components/button.d.ts +3 -17
  11. package/lib/components/button.js +261 -295
  12. package/lib/components/calendar-month.d.ts +4 -50
  13. package/lib/components/calendar-month.js +443 -582
  14. package/lib/components/calendar-navigation.d.ts +3 -48
  15. package/lib/components/calendar-navigation.js +239 -362
  16. package/lib/components/calendar.d.ts +8 -83
  17. package/lib/components/calendar.js +616 -829
  18. package/lib/components/checkbox.d.ts +5 -72
  19. package/lib/components/checkbox.js +273 -416
  20. package/lib/components/copy.d.ts +4 -57
  21. package/lib/components/copy.js +280 -397
  22. package/lib/components/date-picker.d.ts +21 -163
  23. package/lib/components/date-picker.js +1143 -1674
  24. package/lib/components/file-upload.d.ts +9 -15
  25. package/lib/components/file-upload.js +404 -426
  26. package/lib/components/icon.d.ts +3 -24
  27. package/lib/components/icon.js +141 -230
  28. package/lib/components/input.d.ts +8 -108
  29. package/lib/components/input.js +593 -784
  30. package/lib/components/modal.d.ts +17 -26
  31. package/lib/components/modal.js +340 -484
  32. package/lib/components/option.d.ts +2 -9
  33. package/lib/components/option.js +168 -216
  34. package/lib/components/popup.d.ts +2 -17
  35. package/lib/components/popup.js +249 -380
  36. package/lib/components/radio.d.ts +5 -25
  37. package/lib/components/radio.js +407 -461
  38. package/lib/components/resize-observer.d.ts +3 -30
  39. package/lib/components/resize-observer.js +69 -103
  40. package/lib/components/scroll-container.d.ts +2 -12
  41. package/lib/components/scroll-container.js +293 -338
  42. package/lib/components/select.d.ts +87 -159
  43. package/lib/components/select.js +1609 -2090
  44. package/lib/components/selected-tags.d.ts +5 -48
  45. package/lib/components/selected-tags.js +188 -276
  46. package/lib/components/step.d.ts +1 -6
  47. package/lib/components/step.js +62 -68
  48. package/lib/components/switch.d.ts +1 -12
  49. package/lib/components/switch.js +214 -247
  50. package/lib/components/tab.d.ts +1 -6
  51. package/lib/components/tab.js +62 -69
  52. package/lib/components/tabs.d.ts +6 -63
  53. package/lib/components/tabs.js +545 -777
  54. package/lib/components/tag.d.ts +3 -37
  55. package/lib/components/tag.js +236 -335
  56. package/lib/components/textarea.d.ts +7 -87
  57. package/lib/components/textarea.js +457 -627
  58. package/lib/components/tooltip.d.ts +3 -11
  59. package/lib/components/tooltip.js +307 -443
  60. package/lib/components/wizard.d.ts +6 -54
  61. package/lib/components/wizard.js +405 -618
  62. package/lib/icons/fontawesome/brands.d.ts +0 -1
  63. package/lib/icons/fontawesome/brands.js +0 -8
  64. package/lib/icons/fontawesome/regular.d.ts +0 -1
  65. package/lib/icons/fontawesome/regular.js +0 -8
  66. package/lib/icons/fontawesome/solid.d.ts +0 -1
  67. package/lib/icons/fontawesome/solid.js +0 -8
  68. package/lib/icons/heroicons/micro.d.ts +0 -1
  69. package/lib/icons/heroicons/micro.js +392 -400
  70. package/lib/icons/heroicons/mini.d.ts +0 -1
  71. package/lib/icons/heroicons/mini.js +382 -390
  72. package/lib/icons/heroicons/outline.d.ts +0 -1
  73. package/lib/icons/heroicons/outline.js +337 -345
  74. package/lib/icons/heroicons/solid.d.ts +0 -1
  75. package/lib/icons/heroicons/solid.js +407 -415
  76. package/lib/icons/lucide.d.ts +0 -1
  77. package/lib/icons/lucide.js +24479 -26351
  78. package/lib/icons/material/filled.d.ts +0 -1
  79. package/lib/icons/material/filled.js +9653 -9663
  80. package/lib/icons/material/outlined.d.ts +0 -1
  81. package/lib/icons/material/outlined.js +10271 -10281
  82. package/lib/icons/material/round.d.ts +0 -1
  83. package/lib/icons/material/round.js +10495 -10505
  84. package/lib/icons/material/sharp.d.ts +0 -1
  85. package/lib/icons/material/sharp.js +9905 -9915
  86. package/lib/icons/material/two-tone.d.ts +0 -1
  87. package/lib/icons/material/two-tone.js +12792 -12802
  88. package/lib/index.d.ts +0 -1
  89. package/lib/index.js +21 -41
  90. package/lib/styles/button.d.ts +2 -20
  91. package/lib/styles/button.js +202 -404
  92. package/lib/styles/calendar-month.d.ts +1 -5
  93. package/lib/styles/calendar-month.js +127 -244
  94. package/lib/styles/calendar-navigation.d.ts +2 -6
  95. package/lib/styles/calendar-navigation.js +64 -104
  96. package/lib/styles/calendar.d.ts +1 -2
  97. package/lib/styles/calendar.js +9 -22
  98. package/lib/styles/checkbox.d.ts +0 -1
  99. package/lib/styles/checkbox.js +45 -94
  100. package/lib/styles/copy.d.ts +0 -1
  101. package/lib/styles/copy.js +67 -106
  102. package/lib/styles/custom-scrollbar.d.ts +1 -2
  103. package/lib/styles/custom-scrollbar.js +80 -115
  104. package/lib/styles/date-picker.d.ts +1 -5
  105. package/lib/styles/date-picker.js +261 -335
  106. package/lib/styles/field-size.d.ts +6 -0
  107. package/lib/styles/field-size.js +91 -0
  108. package/lib/styles/file-upload.d.ts +1 -2
  109. package/lib/styles/file-upload.js +143 -188
  110. package/lib/styles/icon.d.ts +2 -6
  111. package/lib/styles/icon.js +92 -170
  112. package/lib/styles/input.d.ts +1 -6
  113. package/lib/styles/input.js +125 -290
  114. package/lib/styles/modal.d.ts +1 -2
  115. package/lib/styles/modal.js +71 -108
  116. package/lib/styles/option.d.ts +2 -6
  117. package/lib/styles/option.js +49 -64
  118. package/lib/styles/popup.d.ts +1 -2
  119. package/lib/styles/popup.js +42 -77
  120. package/lib/styles/radio.d.ts +0 -1
  121. package/lib/styles/radio.js +69 -110
  122. package/lib/styles/resize-observer.d.ts +1 -2
  123. package/lib/styles/resize-observer.js +2 -12
  124. package/lib/styles/scroll-container.d.ts +1 -2
  125. package/lib/styles/scroll-container.js +100 -149
  126. package/lib/styles/select-base.d.ts +0 -1
  127. package/lib/styles/select-base.js +597 -785
  128. package/lib/styles/select.d.ts +1 -2
  129. package/lib/styles/select.js +140 -236
  130. package/lib/styles/step.d.ts +1 -2
  131. package/lib/styles/step.js +22 -33
  132. package/lib/styles/switch.d.ts +0 -1
  133. package/lib/styles/switch.js +34 -73
  134. package/lib/styles/tab.d.ts +1 -2
  135. package/lib/styles/tab.js +22 -34
  136. package/lib/styles/tabs.d.ts +3 -11
  137. package/lib/styles/tabs.js +190 -222
  138. package/lib/styles/tag.d.ts +1 -5
  139. package/lib/styles/tag.js +136 -218
  140. package/lib/styles/textarea.d.ts +1 -2
  141. package/lib/styles/textarea.js +210 -319
  142. package/lib/styles/tooltip.d.ts +0 -1
  143. package/lib/styles/tooltip.js +3 -13
  144. package/lib/styles/wizard.d.ts +5 -21
  145. package/lib/styles/wizard.js +170 -306
  146. package/lib/types/common.d.ts +2 -2
  147. package/lib/types/common.js +6 -17
  148. package/lib/utils/calendar-utils.d.ts +4 -21
  149. package/lib/utils/calendar-utils.js +100 -273
  150. package/lib/utils/custom-scrollbar.d.ts +6 -20
  151. package/lib/utils/custom-scrollbar.js +273 -317
  152. package/lib/utils/flavor-sheet.d.ts +0 -1
  153. package/lib/utils/flavor-sheet.js +14 -37
  154. package/lib/utils/icon-registry.d.ts +0 -2
  155. package/lib/utils/icon-registry.js +137 -243
  156. package/lib/utils/icons.d.ts +0 -1
  157. package/lib/utils/icons.js +0 -9
  158. package/lib/utils/loader-registry.d.ts +0 -1
  159. package/lib/utils/loader-registry.js +3 -35
  160. package/lib/utils/locale.d.ts +2 -23
  161. package/lib/utils/locale.js +34 -120
  162. package/lib/utils/mobile.d.ts +0 -1
  163. package/lib/utils/mobile.js +1 -18
  164. package/lib/utils/number-format.d.ts +6 -3
  165. package/lib/utils/number-format.js +54 -110
  166. package/lib/utils/positioning.d.ts +50 -7
  167. package/lib/utils/positioning.js +224 -234
  168. package/lib/utils/property-capture.d.ts +5 -27
  169. package/lib/utils/property-capture.js +36 -144
  170. package/lib/utils/property-manager.d.ts +0 -1
  171. package/lib/utils/property-manager.js +126 -196
  172. package/lib/utils/resize-observer.d.ts +0 -1
  173. package/lib/utils/resize-observer.js +23 -59
  174. package/lib/utils/scroll-lock.d.ts +4 -11
  175. package/lib/utils/scroll-lock.js +65 -172
  176. package/lib/utils/styles.d.ts +0 -1
  177. package/lib/utils/styles.js +17 -41
  178. package/lib/version.d.ts +1 -2
  179. package/lib/version.js +1 -11
  180. package/package.json +4 -4
  181. package/lib/base/ty-component.d.ts.map +0 -1
  182. package/lib/base/ty-component.js.map +0 -1
  183. package/lib/components/button.d.ts.map +0 -1
  184. package/lib/components/button.js.map +0 -1
  185. package/lib/components/calendar-month.d.ts.map +0 -1
  186. package/lib/components/calendar-month.js.map +0 -1
  187. package/lib/components/calendar-navigation.d.ts.map +0 -1
  188. package/lib/components/calendar-navigation.js.map +0 -1
  189. package/lib/components/calendar.d.ts.map +0 -1
  190. package/lib/components/calendar.js.map +0 -1
  191. package/lib/components/checkbox.d.ts.map +0 -1
  192. package/lib/components/checkbox.js.map +0 -1
  193. package/lib/components/copy.d.ts.map +0 -1
  194. package/lib/components/copy.js.map +0 -1
  195. package/lib/components/date-picker.d.ts.map +0 -1
  196. package/lib/components/date-picker.js.map +0 -1
  197. package/lib/components/file-upload.d.ts.map +0 -1
  198. package/lib/components/file-upload.js.map +0 -1
  199. package/lib/components/icon.d.ts.map +0 -1
  200. package/lib/components/icon.js.map +0 -1
  201. package/lib/components/input.d.ts.map +0 -1
  202. package/lib/components/input.js.map +0 -1
  203. package/lib/components/modal.d.ts.map +0 -1
  204. package/lib/components/modal.js.map +0 -1
  205. package/lib/components/option.d.ts.map +0 -1
  206. package/lib/components/option.js.map +0 -1
  207. package/lib/components/popup.d.ts.map +0 -1
  208. package/lib/components/popup.js.map +0 -1
  209. package/lib/components/radio.d.ts.map +0 -1
  210. package/lib/components/radio.js.map +0 -1
  211. package/lib/components/resize-observer.d.ts.map +0 -1
  212. package/lib/components/resize-observer.js.map +0 -1
  213. package/lib/components/scroll-container.d.ts.map +0 -1
  214. package/lib/components/scroll-container.js.map +0 -1
  215. package/lib/components/select.d.ts.map +0 -1
  216. package/lib/components/select.js.map +0 -1
  217. package/lib/components/selected-tags.d.ts.map +0 -1
  218. package/lib/components/selected-tags.js.map +0 -1
  219. package/lib/components/step.d.ts.map +0 -1
  220. package/lib/components/step.js.map +0 -1
  221. package/lib/components/switch.d.ts.map +0 -1
  222. package/lib/components/switch.js.map +0 -1
  223. package/lib/components/tab.d.ts.map +0 -1
  224. package/lib/components/tab.js.map +0 -1
  225. package/lib/components/tabs.d.ts.map +0 -1
  226. package/lib/components/tabs.js.map +0 -1
  227. package/lib/components/tag.d.ts.map +0 -1
  228. package/lib/components/tag.js.map +0 -1
  229. package/lib/components/textarea.d.ts.map +0 -1
  230. package/lib/components/textarea.js.map +0 -1
  231. package/lib/components/tooltip.d.ts.map +0 -1
  232. package/lib/components/tooltip.js.map +0 -1
  233. package/lib/components/wizard.d.ts.map +0 -1
  234. package/lib/components/wizard.js.map +0 -1
  235. package/lib/icons/fontawesome/brands.d.ts.map +0 -1
  236. package/lib/icons/fontawesome/brands.js.map +0 -1
  237. package/lib/icons/fontawesome/regular.d.ts.map +0 -1
  238. package/lib/icons/fontawesome/regular.js.map +0 -1
  239. package/lib/icons/fontawesome/solid.d.ts.map +0 -1
  240. package/lib/icons/fontawesome/solid.js.map +0 -1
  241. package/lib/icons/heroicons/micro.d.ts.map +0 -1
  242. package/lib/icons/heroicons/micro.js.map +0 -1
  243. package/lib/icons/heroicons/mini.d.ts.map +0 -1
  244. package/lib/icons/heroicons/mini.js.map +0 -1
  245. package/lib/icons/heroicons/outline.d.ts.map +0 -1
  246. package/lib/icons/heroicons/outline.js.map +0 -1
  247. package/lib/icons/heroicons/solid.d.ts.map +0 -1
  248. package/lib/icons/heroicons/solid.js.map +0 -1
  249. package/lib/icons/lucide.d.ts.map +0 -1
  250. package/lib/icons/lucide.js.map +0 -1
  251. package/lib/icons/material/filled.d.ts.map +0 -1
  252. package/lib/icons/material/filled.js.map +0 -1
  253. package/lib/icons/material/outlined.d.ts.map +0 -1
  254. package/lib/icons/material/outlined.js.map +0 -1
  255. package/lib/icons/material/round.d.ts.map +0 -1
  256. package/lib/icons/material/round.js.map +0 -1
  257. package/lib/icons/material/sharp.d.ts.map +0 -1
  258. package/lib/icons/material/sharp.js.map +0 -1
  259. package/lib/icons/material/two-tone.d.ts.map +0 -1
  260. package/lib/icons/material/two-tone.js.map +0 -1
  261. package/lib/index.d.ts.map +0 -1
  262. package/lib/index.js.map +0 -1
  263. package/lib/styles/button.d.ts.map +0 -1
  264. package/lib/styles/button.js.map +0 -1
  265. package/lib/styles/calendar-month.d.ts.map +0 -1
  266. package/lib/styles/calendar-month.js.map +0 -1
  267. package/lib/styles/calendar-navigation.d.ts.map +0 -1
  268. package/lib/styles/calendar-navigation.js.map +0 -1
  269. package/lib/styles/calendar.d.ts.map +0 -1
  270. package/lib/styles/calendar.js.map +0 -1
  271. package/lib/styles/checkbox.d.ts.map +0 -1
  272. package/lib/styles/checkbox.js.map +0 -1
  273. package/lib/styles/copy.d.ts.map +0 -1
  274. package/lib/styles/copy.js.map +0 -1
  275. package/lib/styles/custom-scrollbar.d.ts.map +0 -1
  276. package/lib/styles/custom-scrollbar.js.map +0 -1
  277. package/lib/styles/date-picker.d.ts.map +0 -1
  278. package/lib/styles/date-picker.js.map +0 -1
  279. package/lib/styles/file-upload.d.ts.map +0 -1
  280. package/lib/styles/file-upload.js.map +0 -1
  281. package/lib/styles/icon.d.ts.map +0 -1
  282. package/lib/styles/icon.js.map +0 -1
  283. package/lib/styles/input.d.ts.map +0 -1
  284. package/lib/styles/input.js.map +0 -1
  285. package/lib/styles/modal.d.ts.map +0 -1
  286. package/lib/styles/modal.js.map +0 -1
  287. package/lib/styles/multiselect.d.ts +0 -8
  288. package/lib/styles/multiselect.d.ts.map +0 -1
  289. package/lib/styles/multiselect.js +0 -849
  290. package/lib/styles/multiselect.js.map +0 -1
  291. package/lib/styles/option.d.ts.map +0 -1
  292. package/lib/styles/option.js.map +0 -1
  293. package/lib/styles/popup.d.ts.map +0 -1
  294. package/lib/styles/popup.js.map +0 -1
  295. package/lib/styles/radio.d.ts.map +0 -1
  296. package/lib/styles/radio.js.map +0 -1
  297. package/lib/styles/resize-observer.d.ts.map +0 -1
  298. package/lib/styles/resize-observer.js.map +0 -1
  299. package/lib/styles/scroll-container.d.ts.map +0 -1
  300. package/lib/styles/scroll-container.js.map +0 -1
  301. package/lib/styles/select-base.d.ts.map +0 -1
  302. package/lib/styles/select-base.js.map +0 -1
  303. package/lib/styles/select.d.ts.map +0 -1
  304. package/lib/styles/select.js.map +0 -1
  305. package/lib/styles/step.d.ts.map +0 -1
  306. package/lib/styles/step.js.map +0 -1
  307. package/lib/styles/switch.d.ts.map +0 -1
  308. package/lib/styles/switch.js.map +0 -1
  309. package/lib/styles/tab.d.ts.map +0 -1
  310. package/lib/styles/tab.js.map +0 -1
  311. package/lib/styles/tabs.d.ts.map +0 -1
  312. package/lib/styles/tabs.js.map +0 -1
  313. package/lib/styles/tag.d.ts.map +0 -1
  314. package/lib/styles/tag.js.map +0 -1
  315. package/lib/styles/textarea.d.ts.map +0 -1
  316. package/lib/styles/textarea.js.map +0 -1
  317. package/lib/styles/tooltip.d.ts.map +0 -1
  318. package/lib/styles/tooltip.js.map +0 -1
  319. package/lib/styles/wizard.d.ts.map +0 -1
  320. package/lib/styles/wizard.js.map +0 -1
  321. package/lib/types/common.d.ts.map +0 -1
  322. package/lib/types/common.js.map +0 -1
  323. package/lib/utils/calendar-utils.d.ts.map +0 -1
  324. package/lib/utils/calendar-utils.js.map +0 -1
  325. package/lib/utils/custom-scrollbar.d.ts.map +0 -1
  326. package/lib/utils/custom-scrollbar.js.map +0 -1
  327. package/lib/utils/flavor-sheet.d.ts.map +0 -1
  328. package/lib/utils/flavor-sheet.js.map +0 -1
  329. package/lib/utils/icon-registry.d.ts.map +0 -1
  330. package/lib/utils/icon-registry.js.map +0 -1
  331. package/lib/utils/icons.d.ts.map +0 -1
  332. package/lib/utils/icons.js.map +0 -1
  333. package/lib/utils/loader-registry.d.ts.map +0 -1
  334. package/lib/utils/loader-registry.js.map +0 -1
  335. package/lib/utils/locale.d.ts.map +0 -1
  336. package/lib/utils/locale.js.map +0 -1
  337. package/lib/utils/mobile.d.ts.map +0 -1
  338. package/lib/utils/mobile.js.map +0 -1
  339. package/lib/utils/number-format.d.ts.map +0 -1
  340. package/lib/utils/number-format.js.map +0 -1
  341. package/lib/utils/parse-boolean.d.ts +0 -39
  342. package/lib/utils/parse-boolean.d.ts.map +0 -1
  343. package/lib/utils/parse-boolean.js +0 -58
  344. package/lib/utils/parse-boolean.js.map +0 -1
  345. package/lib/utils/positioning.d.ts.map +0 -1
  346. package/lib/utils/positioning.js.map +0 -1
  347. package/lib/utils/property-capture.d.ts.map +0 -1
  348. package/lib/utils/property-capture.js.map +0 -1
  349. package/lib/utils/property-manager.d.ts.map +0 -1
  350. package/lib/utils/property-manager.js.map +0 -1
  351. package/lib/utils/resize-observer.d.ts.map +0 -1
  352. package/lib/utils/resize-observer.js.map +0 -1
  353. package/lib/utils/scroll-lock.d.ts.map +0 -1
  354. package/lib/utils/scroll-lock.js.map +0 -1
  355. package/lib/utils/styles.d.ts.map +0 -1
  356. package/lib/utils/styles.js.map +0 -1
  357. package/lib/version.d.ts.map +0 -1
  358. package/lib/version.js.map +0 -1
@@ -1,479 +1,425 @@
1
- /**
2
- * TyRadio + TyRadioGroup Web Components
3
- *
4
- * Exclusive selection within a group. ty-radio-group manages the selection
5
- * value and form integration; ty-radio is the individual choice element.
6
- *
7
- * Composition (container + children, like ty-select + ty-option):
8
- * <ty-radio-group name="plan" value="pro" label="Plan">
9
- * <ty-radio value="free">Free</ty-radio>
10
- * <ty-radio value="pro">Pro</ty-radio>
11
- * <ty-radio value="team">Team</ty-radio>
12
- * </ty-radio-group>
13
- *
14
- * Keyboard:
15
- * - Tab focuses the group's currently-selected (or first) radio
16
- * - Arrow keys move focus AND selection within the group (per W3C ARIA)
17
- * - Space/Enter selects the focused radio
18
- */
1
+ import { DEFAULT_SIZE } from "../types/common.js";
19
2
  import { TyComponent } from "../base/ty-component.js";
20
3
  import { ensureStyles } from "../utils/styles.js";
21
4
  import { syncCustomFlavorSheet } from "../utils/flavor-sheet.js";
22
5
  import { radioStyles, radioCustomFlavorCss } from "../styles/radio.js";
23
6
  import { REQUIRED_ICON_SVG } from "../utils/icons.js";
24
7
  export class TyRadio extends TyComponent {
25
- constructor() {
26
- super();
27
- this._customFlavorSheet = null;
28
- this._listenersSetup = false;
29
- this._clickHandler = null;
30
- this._focusHandler = null;
31
- this._blurHandler = null;
32
- const shadow = this.shadowRoot;
33
- ensureStyles(shadow, { css: radioStyles, id: "ty-radio" });
34
- }
35
- onConnect() {
36
- // Re-arm listeners on RE-connect (base skips render() when already
37
- // rendered; onDisconnect removed them). No-op on first connect.
38
- this.setupEventListeners();
39
- // Tell the group we exist. During HTML parsing the group connects BEFORE
40
- // its children, so its own onConnect sync sees an empty group — each
41
- // radio announcing itself lets the group re-sync as children arrive.
42
- this.dispatchEvent(new CustomEvent("ty-radio-connected", { bubbles: true }));
43
- this._syncCustomFlavor();
44
- }
45
- onDisconnect() {
46
- this.removeEventListeners();
47
- }
48
- onPropertiesChanged(changes) {
49
- if (changes.some((c) => c.name === "flavor")) {
50
- this._syncCustomFlavor();
51
- }
52
- }
53
- /** Custom (non-built-in) flavors — see utils/flavor-sheet.ts. */
54
- _syncCustomFlavor() {
55
- this._customFlavorSheet = syncCustomFlavorSheet(this.shadowRoot, this._customFlavorSheet, this.flavor, ({ base }) => radioCustomFlavorCss(base));
56
- }
57
- buildClassList() {
58
- const classes = [this.size];
59
- if (this.disabled)
60
- classes.push("disabled");
61
- return classes.join(" ");
62
- }
63
- handleClick(e) {
64
- if (this.disabled)
65
- return;
66
- e.stopPropagation();
67
- // Notify the group — group will set checked attribute on this and clear others
68
- this.dispatchEvent(new CustomEvent("ty-radio-select", {
69
- detail: { value: this.value },
70
- bubbles: true,
71
- composed: true,
72
- }));
73
- }
74
- removeEventListeners() {
75
- if (!this._listenersSetup)
76
- return;
77
- // Click lives on the HOST (label delegation + full-element trigger) —
78
- // remove it before the shadow-container guard below.
79
- if (this._clickHandler) {
80
- this.removeEventListener("click", this._clickHandler);
81
- this._clickHandler = null;
82
- }
83
- const el = this.shadowRoot?.querySelector(".radio-container");
84
- if (!el) {
85
- this._listenersSetup = false;
86
- return;
87
- }
88
- if (this._focusHandler) {
89
- el.removeEventListener("focus", this._focusHandler);
90
- this._focusHandler = null;
91
- }
92
- if (this._blurHandler) {
93
- el.removeEventListener("blur", this._blurHandler);
94
- this._blurHandler = null;
95
- }
96
- this._listenersSetup = false;
97
- }
98
- setupEventListeners() {
99
- if (this._listenersSetup)
100
- return;
101
- const el = this.shadowRoot.querySelector(".radio-container");
102
- if (!el)
103
- return;
104
- this._clickHandler = (e) => this.handleClick(e);
105
- this._focusHandler = () => el.classList.add("focused");
106
- this._blurHandler = () => el.classList.remove("focused");
107
- // Click on the HOST: whole element is a trigger and a wrapping <label>
108
- // delegates (the synthetic click lands on the host, not the shadow).
109
- this.addEventListener("click", this._clickHandler);
110
- el.addEventListener("focus", this._focusHandler);
111
- el.addEventListener("blur", this._blurHandler);
112
- this._listenersSetup = true;
113
- }
114
- render() {
115
- const shadow = this.shadowRoot;
116
- let radioEl = shadow.querySelector(".radio-container");
117
- const classes = this.buildClassList();
118
- if (!radioEl) {
119
- radioEl = document.createElement("div");
120
- radioEl.className = "radio-container " + classes;
121
- radioEl.tabIndex = this.disabled ? -1 : 0;
122
- radioEl.setAttribute("role", "radio");
123
- radioEl.setAttribute("aria-checked", String(this.checked));
124
- radioEl.setAttribute("aria-disabled", String(this.disabled));
125
- const circle = document.createElement("div");
126
- circle.className = "radio-circle";
127
- radioEl.appendChild(circle);
128
- shadow.appendChild(radioEl);
129
- }
130
- else {
131
- radioEl.className = "radio-container " + classes;
132
- radioEl.tabIndex = this.disabled ? -1 : 0;
133
- radioEl.setAttribute("aria-checked", String(this.checked));
134
- radioEl.setAttribute("aria-disabled", String(this.disabled));
135
- }
136
- // (Re)attach listeners — onDisconnect removes them, so a reconnected
137
- // element needs them again even though the container already exists.
138
- this.setupEventListeners();
139
- // a11y: name the role="radio" element from its wrapping <label>.
140
- this.applyLabelName(radioEl);
141
- }
142
- // Property accessors
143
- get value() { return this.getProperty("value"); }
144
- set value(v) { this.setProperty("value", v); }
145
- get checked() { return this.getProperty("checked"); }
146
- set checked(v) { this.setProperty("checked", v); }
147
- get disabled() { return this.getProperty("disabled"); }
148
- set disabled(v) { this.setProperty("disabled", v); }
149
- get size() { return this.getProperty("size"); }
150
- set size(v) { this.setProperty("size", v); }
151
- get flavor() { return this.getProperty("flavor"); }
152
- set flavor(v) { this.setProperty("flavor", v); }
8
+ constructor() {
9
+ super();
10
+ this._customFlavorSheet = null;
11
+ this._listenersSetup = false;
12
+ this._clickHandler = null;
13
+ this._focusHandler = null;
14
+ this._blurHandler = null;
15
+ const shadow = this.shadowRoot;
16
+ ensureStyles(shadow, { css: radioStyles, id: "ty-radio" });
17
+ }
18
+ onConnect() {
19
+ this.setupEventListeners();
20
+ this.dispatchEvent(new CustomEvent("ty-radio-connected", { bubbles: true }));
21
+ this._syncCustomFlavor();
22
+ }
23
+ onDisconnect() {
24
+ this.removeEventListeners();
25
+ }
26
+ onPropertiesChanged(changes) {
27
+ if (changes.some((c) => c.name === "flavor")) {
28
+ this._syncCustomFlavor();
29
+ }
30
+ }
31
+ _syncCustomFlavor() {
32
+ this._customFlavorSheet = syncCustomFlavorSheet(this.shadowRoot, this._customFlavorSheet, this.flavor, ({ base }) => radioCustomFlavorCss(base));
33
+ }
34
+ buildClassList() {
35
+ const classes = [this.size];
36
+ if (this.disabled)
37
+ classes.push("disabled");
38
+ return classes.join(" ");
39
+ }
40
+ handleClick(e) {
41
+ if (this.disabled)
42
+ return;
43
+ e.stopPropagation();
44
+ this.dispatchEvent(new CustomEvent("ty-radio-select", {
45
+ detail: { value: this.value },
46
+ bubbles: true,
47
+ composed: true,
48
+ }));
49
+ }
50
+ removeEventListeners() {
51
+ if (!this._listenersSetup)
52
+ return;
53
+ if (this._clickHandler) {
54
+ this.removeEventListener("click", this._clickHandler);
55
+ this._clickHandler = null;
56
+ }
57
+ const el = this.shadowRoot?.querySelector(".radio-container");
58
+ if (!el) {
59
+ this._listenersSetup = false;
60
+ return;
61
+ }
62
+ if (this._focusHandler) {
63
+ el.removeEventListener("focus", this._focusHandler);
64
+ this._focusHandler = null;
65
+ }
66
+ if (this._blurHandler) {
67
+ el.removeEventListener("blur", this._blurHandler);
68
+ this._blurHandler = null;
69
+ }
70
+ this._listenersSetup = false;
71
+ }
72
+ setupEventListeners() {
73
+ if (this._listenersSetup)
74
+ return;
75
+ const el = this.shadowRoot.querySelector(".radio-container");
76
+ if (!el)
77
+ return;
78
+ this._clickHandler = (e) => this.handleClick(e);
79
+ this._focusHandler = () => el.classList.add("focused");
80
+ this._blurHandler = () => el.classList.remove("focused");
81
+ this.addEventListener("click", this._clickHandler);
82
+ el.addEventListener("focus", this._focusHandler);
83
+ el.addEventListener("blur", this._blurHandler);
84
+ this._listenersSetup = true;
85
+ }
86
+ render() {
87
+ const shadow = this.shadowRoot;
88
+ let radioEl = shadow.querySelector(".radio-container");
89
+ const classes = this.buildClassList();
90
+ if (!radioEl) {
91
+ radioEl = document.createElement("div");
92
+ radioEl.className = "radio-container " + classes;
93
+ radioEl.tabIndex = this.disabled ? -1 : 0;
94
+ radioEl.setAttribute("role", "radio");
95
+ radioEl.setAttribute("aria-checked", String(this.checked));
96
+ radioEl.setAttribute("aria-disabled", String(this.disabled));
97
+ const circle = document.createElement("div");
98
+ circle.className = "radio-circle";
99
+ radioEl.appendChild(circle);
100
+ shadow.appendChild(radioEl);
101
+ }
102
+ else {
103
+ radioEl.className = "radio-container " + classes;
104
+ radioEl.tabIndex = this.disabled ? -1 : 0;
105
+ radioEl.setAttribute("aria-checked", String(this.checked));
106
+ radioEl.setAttribute("aria-disabled", String(this.disabled));
107
+ }
108
+ this.setupEventListeners();
109
+ this.applyLabelName(radioEl);
110
+ }
111
+ get value() { return this.getProperty("value"); }
112
+ set value(v) { this.setProperty("value", v); }
113
+ get checked() { return this.getProperty("checked"); }
114
+ set checked(v) { this.setProperty("checked", v); }
115
+ get disabled() { return this.getProperty("disabled"); }
116
+ set disabled(v) { this.setProperty("disabled", v); }
117
+ get size() { return this.getProperty("size"); }
118
+ set size(v) { this.setProperty("size", v); }
119
+ get flavor() { return this.getProperty("flavor"); }
120
+ set flavor(v) { this.setProperty("flavor", v); }
153
121
  }
154
122
  TyRadio.properties = {
155
- value: { type: "string", default: "" },
156
- checked: {
157
- type: "boolean",
158
- visual: true,
159
- default: false,
160
- },
161
- disabled: {
162
- type: "boolean",
163
- visual: true,
164
- default: false,
165
- },
166
- size: {
167
- type: "string",
168
- visual: true,
169
- default: "md",
170
- },
171
- flavor: {
172
- type: "string",
173
- visual: true,
174
- default: "primary",
175
- },
123
+ value: { type: "string", default: "" },
124
+ checked: {
125
+ type: "boolean",
126
+ visual: true,
127
+ default: false,
128
+ },
129
+ disabled: {
130
+ type: "boolean",
131
+ visual: true,
132
+ default: false,
133
+ },
134
+ size: {
135
+ type: "string",
136
+ visual: true,
137
+ default: DEFAULT_SIZE,
138
+ },
139
+ flavor: {
140
+ type: "string",
141
+ visual: true,
142
+ default: "primary",
143
+ },
176
144
  };
177
145
  if (!customElements.get("ty-radio")) {
178
- customElements.define("ty-radio", TyRadio);
146
+ customElements.define("ty-radio", TyRadio);
179
147
  }
180
148
  export class TyRadioGroup extends TyComponent {
181
- constructor() {
182
- super();
183
- this._listenersSetup = false;
184
- this._selectHandler = null;
185
- this._keydownHandler = null;
186
- this._connectedHandler = null;
187
- const shadow = this.shadowRoot;
188
- ensureStyles(shadow, { css: radioStyles, id: "ty-radio-group" });
189
- }
190
- onConnect() {
191
- // Re-arm listeners on RE-connect; no-op on first (setup runs in render too)
192
- this.setupEventListeners();
193
- // Sync radio children with current value once light DOM is ready.
194
- // NOTE: during HTML parsing this runs before children are parsed — the
195
- // ty-radio-connected listener covers late-arriving radios.
196
- queueMicrotask(() => this.syncChildren());
197
- }
198
- onDisconnect() {
199
- this.removeEventListeners();
200
- }
201
- onPropertiesChanged(changes) {
202
- if (changes.some((c) => c.name === "value" || c.name === "size" || c.name === "flavor" || c.name === "disabled")) {
203
- this.syncChildren();
204
- }
205
- }
206
- getFormValue() {
207
- return this.value || null;
208
- }
209
- /**
210
- * Find ty-radio descendants in this group's light DOM. Searches deeply
211
- * because consumers may wrap each radio in a `<label>` for click delegation.
212
- */
213
- getRadios() {
214
- return Array.from(this.querySelectorAll("ty-radio"));
215
- }
216
- /**
217
- * Push group state down to each radio child.
218
- */
219
- syncChildren() {
220
- const radios = this.getRadios();
221
- for (const radio of radios) {
222
- radio.checked = radio.value === this.value;
223
- // Inherit size/flavor/disabled from group unless radio set its own
224
- if (this.disabled)
225
- radio.disabled = true;
226
- radio.size = this.size;
227
- radio.flavor = this.flavor;
228
- }
229
- }
230
- /**
231
- * Handle a child's select request — update value, sync, emit change.
232
- */
233
- handleRadioSelect(e) {
234
- if (this.disabled)
235
- return;
236
- const detail = e.detail;
237
- const newValue = detail?.value;
238
- if (typeof newValue !== "string" || newValue === this.value)
239
- return;
240
- this.value = newValue;
241
- this.syncChildren();
242
- setTimeout(() => {
243
- const eventDetail = {
244
- value: newValue,
245
- formValue: newValue,
246
- originalEvent: e,
247
- };
248
- this.dispatchEvent(new CustomEvent("input", { detail: eventDetail, bubbles: true, composed: true }));
249
- this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
250
- }, 0);
251
- }
252
- /**
253
- * Arrow-key navigation within group (W3C radio practice: arrow keys move
254
- * focus and selection together).
255
- */
256
- handleKeydown(e) {
257
- if (this.disabled)
258
- return;
259
- const radios = this.getRadios().filter((r) => !r.disabled);
260
- if (radios.length === 0)
261
- return;
262
- const active = document.activeElement;
263
- const current = radios.find((r) => r === active || r.contains(active));
264
- let nextIndex = -1;
265
- if (["ArrowDown", "ArrowRight"].includes(e.key)) {
266
- e.preventDefault();
267
- nextIndex = current ? (radios.indexOf(current) + 1) % radios.length : 0;
268
- }
269
- else if (["ArrowUp", "ArrowLeft"].includes(e.key)) {
270
- e.preventDefault();
271
- nextIndex = current
272
- ? (radios.indexOf(current) - 1 + radios.length) % radios.length
273
- : radios.length - 1;
274
- }
275
- else if (["Space", " ", "Enter"].includes(e.key)) {
276
- if (current) {
277
- e.preventDefault();
278
- this.value = current.value;
279
- this.syncChildren();
280
- const eventDetail = {
281
- value: current.value,
282
- formValue: current.value,
283
- originalEvent: e,
284
- };
285
- setTimeout(() => {
286
- this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
287
- }, 0);
288
- }
289
- return;
290
- }
291
- else {
292
- return;
293
- }
294
- const next = radios[nextIndex];
295
- if (next) {
296
- next.focus();
297
- // Per W3C: arrow keys also change selection
298
- this.value = next.value;
299
- this.syncChildren();
300
- const eventDetail = {
301
- value: next.value,
302
- formValue: next.value,
303
- originalEvent: e,
304
- };
305
- setTimeout(() => {
306
- this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
307
- }, 0);
308
- }
309
- }
310
- removeEventListeners() {
311
- if (!this._listenersSetup)
312
- return;
313
- if (this._selectHandler) {
314
- this.removeEventListener("ty-radio-select", this._selectHandler);
315
- this._selectHandler = null;
316
- }
317
- if (this._keydownHandler) {
318
- this.removeEventListener("keydown", this._keydownHandler);
319
- this._keydownHandler = null;
320
- }
321
- if (this._connectedHandler) {
322
- this.removeEventListener("ty-radio-connected", this._connectedHandler);
323
- this._connectedHandler = null;
324
- }
325
- this._listenersSetup = false;
326
- }
327
- setupEventListeners() {
328
- if (this._listenersSetup)
329
- return;
330
- this._selectHandler = (e) => this.handleRadioSelect(e);
331
- this._keydownHandler = (e) => this.handleKeydown(e);
332
- // Radios announce themselves on connect — re-sync so radios parsed AFTER
333
- // the group's own onConnect still receive the group's value/size/flavor.
334
- this._connectedHandler = () => this.syncChildren();
335
- this.addEventListener("ty-radio-select", this._selectHandler);
336
- this.addEventListener("keydown", this._keydownHandler);
337
- this.addEventListener("ty-radio-connected", this._connectedHandler);
338
- this._listenersSetup = true;
339
- }
340
- render() {
341
- const shadow = this.shadowRoot;
342
- let container = shadow.querySelector(".radio-group-container");
343
- if (!container) {
344
- container = document.createElement("div");
345
- container.className = "radio-group-container";
346
- container.setAttribute("role", "radiogroup");
347
- container.setAttribute("aria-disabled", String(this.disabled));
348
- // Label
349
- if (this.label) {
350
- const labelEl = document.createElement("div");
351
- labelEl.className = "radio-group-label";
352
- labelEl.textContent = this.label;
353
- if (this.required) {
354
- const req = document.createElement("span");
355
- req.className = "required-icon";
356
- req.innerHTML = REQUIRED_ICON_SVG;
357
- labelEl.appendChild(req);
358
- }
359
- container.appendChild(labelEl);
360
- }
361
- // List wrapper that hosts the slot
362
- const list = document.createElement("div");
363
- list.className = "radio-group-list " + this.orientation;
364
- const slot = document.createElement("slot");
365
- list.appendChild(slot);
366
- container.appendChild(list);
367
- if (this.error) {
368
- const errorEl = document.createElement("div");
369
- errorEl.className = "radio-group-error";
370
- errorEl.textContent = this.error;
371
- container.appendChild(errorEl);
372
- }
373
- shadow.appendChild(container);
374
- this.setupEventListeners();
375
- }
376
- else {
377
- // Update label
378
- let labelEl = container.querySelector(".radio-group-label");
379
- if (this.label) {
380
- if (!labelEl) {
381
- labelEl = document.createElement("div");
382
- labelEl.className = "radio-group-label";
383
- container.insertBefore(labelEl, container.firstChild);
384
- }
385
- labelEl.textContent = this.label;
386
- if (this.required && !labelEl.querySelector(".required-icon")) {
387
- const req = document.createElement("span");
388
- req.className = "required-icon";
389
- req.innerHTML = REQUIRED_ICON_SVG;
390
- labelEl.appendChild(req);
391
- }
392
- else if (!this.required) {
393
- labelEl.querySelector(".required-icon")?.remove();
394
- }
395
- }
396
- else if (labelEl) {
397
- labelEl.remove();
398
- }
399
- // Update orientation
400
- const list = container.querySelector(".radio-group-list");
401
- if (list)
402
- list.className = "radio-group-list " + this.orientation;
403
- // Update error
404
- let errorEl = container.querySelector(".radio-group-error");
405
- if (this.error) {
406
- if (!errorEl) {
407
- errorEl = document.createElement("div");
408
- errorEl.className = "radio-group-error";
409
- container.appendChild(errorEl);
410
- }
411
- errorEl.textContent = this.error;
412
- }
413
- else if (errorEl) {
414
- errorEl.remove();
415
- }
416
- container.setAttribute("aria-disabled", String(this.disabled));
417
- }
418
- // Always sync child radios after render
419
- this.syncChildren();
420
- }
421
- // Property accessors
422
- get value() { return this.getProperty("value"); }
423
- set value(v) { this.setProperty("value", v); }
424
- get name() { return this.getProperty("name"); }
425
- set name(v) { this.setProperty("name", v); }
426
- get label() { return this.getProperty("label"); }
427
- set label(v) { this.setProperty("label", v); }
428
- get disabled() { return this.getProperty("disabled"); }
429
- set disabled(v) { this.setProperty("disabled", v); }
430
- get required() { return this.getProperty("required"); }
431
- set required(v) { this.setProperty("required", v); }
432
- get error() { return this.getProperty("error"); }
433
- set error(v) { this.setProperty("error", v); }
434
- get orientation() {
435
- return this.getProperty("orientation");
436
- }
437
- set orientation(v) {
438
- this.setProperty("orientation", v);
439
- }
440
- get size() { return this.getProperty("size"); }
441
- set size(v) { this.setProperty("size", v); }
442
- get flavor() { return this.getProperty("flavor"); }
443
- set flavor(v) { this.setProperty("flavor", v); }
444
- get form() { return this._internals.form; }
149
+ constructor() {
150
+ super();
151
+ this._listenersSetup = false;
152
+ this._selectHandler = null;
153
+ this._keydownHandler = null;
154
+ this._connectedHandler = null;
155
+ const shadow = this.shadowRoot;
156
+ ensureStyles(shadow, { css: radioStyles, id: "ty-radio-group" });
157
+ }
158
+ onConnect() {
159
+ this.setupEventListeners();
160
+ queueMicrotask(() => this.syncChildren());
161
+ }
162
+ onDisconnect() {
163
+ this.removeEventListeners();
164
+ }
165
+ onPropertiesChanged(changes) {
166
+ if (changes.some((c) => c.name === "value" || c.name === "size" || c.name === "flavor" || c.name === "disabled")) {
167
+ this.syncChildren();
168
+ }
169
+ }
170
+ getFormValue() {
171
+ return this.value || null;
172
+ }
173
+ getRadios() {
174
+ return Array.from(this.querySelectorAll("ty-radio"));
175
+ }
176
+ syncChildren() {
177
+ const radios = this.getRadios();
178
+ for (const radio of radios) {
179
+ radio.checked = radio.value === this.value;
180
+ if (this.disabled) {
181
+ if (!radio.disabled) {
182
+ radio.disabled = true;
183
+ radio.dataset.tyGroupDisabled = "";
184
+ }
185
+ }
186
+ else if ("tyGroupDisabled" in radio.dataset) {
187
+ radio.disabled = false;
188
+ delete radio.dataset.tyGroupDisabled;
189
+ }
190
+ radio.size = this.size;
191
+ radio.flavor = this.flavor;
192
+ }
193
+ }
194
+ handleRadioSelect(e) {
195
+ if (this.disabled)
196
+ return;
197
+ const detail = e.detail;
198
+ const newValue = detail?.value;
199
+ if (typeof newValue !== "string" || newValue === this.value)
200
+ return;
201
+ this.value = newValue;
202
+ this.syncChildren();
203
+ setTimeout(() => {
204
+ const eventDetail = {
205
+ value: newValue,
206
+ formValue: newValue,
207
+ originalEvent: e,
208
+ };
209
+ this.dispatchEvent(new CustomEvent("input", { detail: eventDetail, bubbles: true, composed: true }));
210
+ this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
211
+ }, 0);
212
+ }
213
+ handleKeydown(e) {
214
+ if (this.disabled)
215
+ return;
216
+ const radios = this.getRadios().filter((r) => !r.disabled);
217
+ if (radios.length === 0)
218
+ return;
219
+ const active = document.activeElement;
220
+ const current = radios.find((r) => r === active || r.contains(active));
221
+ let nextIndex = -1;
222
+ if (["ArrowDown", "ArrowRight"].includes(e.key)) {
223
+ e.preventDefault();
224
+ nextIndex = current ? (radios.indexOf(current) + 1) % radios.length : 0;
225
+ }
226
+ else if (["ArrowUp", "ArrowLeft"].includes(e.key)) {
227
+ e.preventDefault();
228
+ nextIndex = current
229
+ ? (radios.indexOf(current) - 1 + radios.length) % radios.length
230
+ : radios.length - 1;
231
+ }
232
+ else if (["Space", " ", "Enter"].includes(e.key)) {
233
+ if (current) {
234
+ e.preventDefault();
235
+ this.value = current.value;
236
+ this.syncChildren();
237
+ const eventDetail = {
238
+ value: current.value,
239
+ formValue: current.value,
240
+ originalEvent: e,
241
+ };
242
+ setTimeout(() => {
243
+ this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
244
+ }, 0);
245
+ }
246
+ return;
247
+ }
248
+ else {
249
+ return;
250
+ }
251
+ const next = radios[nextIndex];
252
+ if (next) {
253
+ next.focus();
254
+ this.value = next.value;
255
+ this.syncChildren();
256
+ const eventDetail = {
257
+ value: next.value,
258
+ formValue: next.value,
259
+ originalEvent: e,
260
+ };
261
+ setTimeout(() => {
262
+ this.dispatchEvent(new CustomEvent("change", { detail: eventDetail, bubbles: true, composed: true }));
263
+ }, 0);
264
+ }
265
+ }
266
+ removeEventListeners() {
267
+ if (!this._listenersSetup)
268
+ return;
269
+ if (this._selectHandler) {
270
+ this.removeEventListener("ty-radio-select", this._selectHandler);
271
+ this._selectHandler = null;
272
+ }
273
+ if (this._keydownHandler) {
274
+ this.removeEventListener("keydown", this._keydownHandler);
275
+ this._keydownHandler = null;
276
+ }
277
+ if (this._connectedHandler) {
278
+ this.removeEventListener("ty-radio-connected", this._connectedHandler);
279
+ this._connectedHandler = null;
280
+ }
281
+ this._listenersSetup = false;
282
+ }
283
+ setupEventListeners() {
284
+ if (this._listenersSetup)
285
+ return;
286
+ this._selectHandler = (e) => this.handleRadioSelect(e);
287
+ this._keydownHandler = (e) => this.handleKeydown(e);
288
+ this._connectedHandler = () => this.syncChildren();
289
+ this.addEventListener("ty-radio-select", this._selectHandler);
290
+ this.addEventListener("keydown", this._keydownHandler);
291
+ this.addEventListener("ty-radio-connected", this._connectedHandler);
292
+ this._listenersSetup = true;
293
+ }
294
+ render() {
295
+ const shadow = this.shadowRoot;
296
+ let container = shadow.querySelector(".radio-group-container");
297
+ if (!container) {
298
+ container = document.createElement("div");
299
+ container.className = "radio-group-container";
300
+ container.setAttribute("role", "radiogroup");
301
+ container.setAttribute("aria-disabled", String(this.disabled));
302
+ if (this.label) {
303
+ const labelEl = document.createElement("div");
304
+ labelEl.className = "radio-group-label";
305
+ labelEl.textContent = this.label;
306
+ if (this.required) {
307
+ const req = document.createElement("span");
308
+ req.className = "required-icon";
309
+ req.innerHTML = REQUIRED_ICON_SVG;
310
+ labelEl.appendChild(req);
311
+ }
312
+ container.appendChild(labelEl);
313
+ }
314
+ const list = document.createElement("div");
315
+ list.className = "radio-group-list " + this.orientation;
316
+ const slot = document.createElement("slot");
317
+ list.appendChild(slot);
318
+ container.appendChild(list);
319
+ if (this.error) {
320
+ const errorEl = document.createElement("div");
321
+ errorEl.className = "radio-group-error";
322
+ errorEl.textContent = this.error;
323
+ container.appendChild(errorEl);
324
+ }
325
+ shadow.appendChild(container);
326
+ this.setupEventListeners();
327
+ }
328
+ else {
329
+ let labelEl = container.querySelector(".radio-group-label");
330
+ if (this.label) {
331
+ if (!labelEl) {
332
+ labelEl = document.createElement("div");
333
+ labelEl.className = "radio-group-label";
334
+ container.insertBefore(labelEl, container.firstChild);
335
+ }
336
+ labelEl.textContent = this.label;
337
+ if (this.required && !labelEl.querySelector(".required-icon")) {
338
+ const req = document.createElement("span");
339
+ req.className = "required-icon";
340
+ req.innerHTML = REQUIRED_ICON_SVG;
341
+ labelEl.appendChild(req);
342
+ }
343
+ else if (!this.required) {
344
+ labelEl.querySelector(".required-icon")?.remove();
345
+ }
346
+ }
347
+ else if (labelEl) {
348
+ labelEl.remove();
349
+ }
350
+ const list = container.querySelector(".radio-group-list");
351
+ if (list)
352
+ list.className = "radio-group-list " + this.orientation;
353
+ let errorEl = container.querySelector(".radio-group-error");
354
+ if (this.error) {
355
+ if (!errorEl) {
356
+ errorEl = document.createElement("div");
357
+ errorEl.className = "radio-group-error";
358
+ container.appendChild(errorEl);
359
+ }
360
+ errorEl.textContent = this.error;
361
+ }
362
+ else if (errorEl) {
363
+ errorEl.remove();
364
+ }
365
+ container.setAttribute("aria-disabled", String(this.disabled));
366
+ }
367
+ this.syncChildren();
368
+ }
369
+ get value() { return this.getProperty("value"); }
370
+ set value(v) { this.setProperty("value", v); }
371
+ get name() { return this.getProperty("name"); }
372
+ set name(v) { this.setProperty("name", v); }
373
+ get label() { return this.getProperty("label"); }
374
+ set label(v) { this.setProperty("label", v); }
375
+ get disabled() { return this.getProperty("disabled"); }
376
+ set disabled(v) { this.setProperty("disabled", v); }
377
+ get required() { return this.getProperty("required"); }
378
+ set required(v) { this.setProperty("required", v); }
379
+ get error() { return this.getProperty("error"); }
380
+ set error(v) { this.setProperty("error", v); }
381
+ get orientation() {
382
+ return this.getProperty("orientation");
383
+ }
384
+ set orientation(v) {
385
+ this.setProperty("orientation", v);
386
+ }
387
+ get size() { return this.getProperty("size"); }
388
+ set size(v) { this.setProperty("size", v); }
389
+ get flavor() { return this.getProperty("flavor"); }
390
+ set flavor(v) { this.setProperty("flavor", v); }
391
+ get form() { return this._internals.form; }
445
392
  }
446
393
  TyRadioGroup.formAssociated = true;
447
394
  TyRadioGroup.properties = {
448
- value: {
449
- type: "string",
450
- visual: true,
451
- formValue: true,
452
- emitChange: true,
453
- default: "",
454
- },
455
- name: { type: "string", default: "" },
456
- label: { type: "string", visual: true, default: "" },
457
- disabled: { type: "boolean", visual: true, default: false },
458
- required: { type: "boolean", visual: true, default: false },
459
- error: { type: "string", visual: true, default: "" },
460
- orientation: {
461
- type: "string",
462
- visual: true,
463
- default: "vertical",
464
- },
465
- size: {
466
- type: "string",
467
- visual: true,
468
- default: "md",
469
- },
470
- flavor: {
471
- type: "string",
472
- visual: true,
473
- default: "primary",
474
- },
395
+ value: {
396
+ type: "string",
397
+ visual: true,
398
+ formValue: true,
399
+ emitChange: true,
400
+ default: "",
401
+ },
402
+ name: { type: "string", default: "" },
403
+ label: { type: "string", visual: true, default: "" },
404
+ disabled: { type: "boolean", visual: true, default: false },
405
+ required: { type: "boolean", visual: true, default: false },
406
+ error: { type: "string", visual: true, default: "" },
407
+ orientation: {
408
+ type: "string",
409
+ visual: true,
410
+ default: "vertical",
411
+ },
412
+ size: {
413
+ type: "string",
414
+ visual: true,
415
+ default: DEFAULT_SIZE,
416
+ },
417
+ flavor: {
418
+ type: "string",
419
+ visual: true,
420
+ default: "primary",
421
+ },
475
422
  };
476
423
  if (!customElements.get("ty-radio-group")) {
477
- customElements.define("ty-radio-group", TyRadioGroup);
424
+ customElements.define("ty-radio-group", TyRadioGroup);
478
425
  }
479
- //# sourceMappingURL=radio.js.map