tyrell-components 1.0.0-TC9 → 1.0.0-rc.22

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 (393) hide show
  1. package/AGENTS.md +122 -0
  2. package/CHANGELOG.md +1541 -0
  3. package/README.md +71 -53
  4. package/bin/tyrell.mjs +77 -0
  5. package/css/tyrell-colors-static.css +1 -0
  6. package/css/tyrell-theme.css +1 -0
  7. package/css/tyrell.css +1 -1783
  8. package/dist/tyrell-colors-static.css +1 -0
  9. package/dist/tyrell-theme.css +1 -0
  10. package/dist/tyrell.css +1 -1783
  11. package/dist/tyrell.js +1 -1
  12. package/guides/AGENT_INSTRUCTIONS.md +124 -0
  13. package/guides/AI_GUIDE.md +53 -0
  14. package/guides/CSS_GUIDE.md +1016 -0
  15. package/guides/DATASTAR_TY_GUIDE.md +657 -0
  16. package/guides/ICONS_GUIDE.md +212 -0
  17. package/guides/TY_GUIDE.md +937 -0
  18. package/guides/clj/CLOJURESCRIPT_GUIDE.md +300 -0
  19. package/guides/clj/CODE_SPLITTING.md +279 -0
  20. package/guides/clj/COMPONENT_GUIDE.md +391 -0
  21. package/guides/clj/HELIX_TY_GUIDE.md +428 -0
  22. package/guides/clj/I18N_GUIDE.md +478 -0
  23. package/guides/clj/LAYOUT_GUIDE.md +273 -0
  24. package/guides/clj/QUICKSTART.md +266 -0
  25. package/guides/clj/REAGENT_TY_GUIDE.md +408 -0
  26. package/guides/clj/REPLICANT_TY_GUIDE.md +623 -0
  27. package/guides/clj/ROUTING_GUIDE.md +346 -0
  28. package/guides/clj/UIX_TY_GUIDE.md +319 -0
  29. package/guides/js/HTMX_TY_GUIDE.md +252 -0
  30. package/guides/js/JAVASCRIPT_GUIDE.md +388 -0
  31. package/guides/js/REACT_TY_GUIDE.md +983 -0
  32. package/guides/js/SVELTE_TY_GUIDE.md +682 -0
  33. package/guides/js/TYCOMPONENT_GUIDE.md +962 -0
  34. package/guides/js/VUE_TY_GUIDE.md +738 -0
  35. package/lib/base/ty-component.d.ts +57 -13
  36. package/lib/base/ty-component.js +266 -292
  37. package/lib/components/button.d.ts +33 -18
  38. package/lib/components/button.js +317 -267
  39. package/lib/components/calendar-month.d.ts +30 -47
  40. package/lib/components/calendar-month.js +455 -429
  41. package/lib/components/calendar-navigation.d.ts +41 -49
  42. package/lib/components/calendar-navigation.js +287 -346
  43. package/lib/components/calendar.d.ts +73 -83
  44. package/lib/components/calendar.js +837 -762
  45. package/lib/components/checkbox.d.ts +26 -75
  46. package/lib/components/checkbox.js +298 -391
  47. package/lib/components/copy.d.ts +20 -60
  48. package/lib/components/copy.js +276 -380
  49. package/lib/components/date-picker.d.ts +100 -183
  50. package/lib/components/date-picker.js +1155 -1570
  51. package/lib/components/file-upload.d.ts +16 -15
  52. package/lib/components/file-upload.js +436 -426
  53. package/lib/components/icon.d.ts +3 -24
  54. package/lib/components/icon.js +141 -230
  55. package/lib/components/input.d.ts +93 -108
  56. package/lib/components/input.js +734 -710
  57. package/lib/components/modal.d.ts +39 -29
  58. package/lib/components/modal.js +419 -438
  59. package/lib/components/option.d.ts +20 -35
  60. package/lib/components/option.js +184 -309
  61. package/lib/components/popup.d.ts +2 -17
  62. package/lib/components/popup.js +353 -347
  63. package/lib/components/radio.d.ts +33 -25
  64. package/lib/components/radio.js +433 -422
  65. package/lib/components/resize-observer.d.ts +3 -30
  66. package/lib/components/resize-observer.js +71 -103
  67. package/lib/components/scroll-container.d.ts +21 -14
  68. package/lib/components/scroll-container.js +292 -234
  69. package/lib/components/select.d.ts +458 -0
  70. package/lib/components/select.js +1458 -0
  71. package/lib/components/selected-tags.d.ts +60 -0
  72. package/lib/components/selected-tags.js +225 -0
  73. package/lib/components/sortable.d.ts +175 -0
  74. package/lib/components/sortable.js +1844 -0
  75. package/lib/components/step.d.ts +1 -6
  76. package/lib/components/step.js +62 -68
  77. package/lib/components/switch.d.ts +15 -15
  78. package/lib/components/switch.js +237 -231
  79. package/lib/components/tab.d.ts +50 -7
  80. package/lib/components/tab.js +203 -69
  81. package/lib/components/tabs.d.ts +19 -64
  82. package/lib/components/tabs.js +600 -618
  83. package/lib/components/tag.d.ts +14 -52
  84. package/lib/components/tag.js +231 -306
  85. package/lib/components/textarea.d.ts +58 -89
  86. package/lib/components/textarea.js +523 -573
  87. package/lib/components/tooltip.d.ts +8 -13
  88. package/lib/components/tooltip.js +322 -409
  89. package/lib/components/wizard.d.ts +7 -54
  90. package/lib/components/wizard.js +376 -606
  91. package/lib/icons/fontawesome/brands.d.ts +0 -1
  92. package/lib/icons/fontawesome/brands.js +0 -8
  93. package/lib/icons/fontawesome/regular.d.ts +0 -1
  94. package/lib/icons/fontawesome/regular.js +0 -8
  95. package/lib/icons/fontawesome/solid.d.ts +0 -1
  96. package/lib/icons/fontawesome/solid.js +0 -8
  97. package/lib/icons/heroicons/micro.d.ts +0 -1
  98. package/lib/icons/heroicons/micro.js +392 -400
  99. package/lib/icons/heroicons/mini.d.ts +0 -1
  100. package/lib/icons/heroicons/mini.js +382 -390
  101. package/lib/icons/heroicons/outline.d.ts +0 -1
  102. package/lib/icons/heroicons/outline.js +337 -345
  103. package/lib/icons/heroicons/solid.d.ts +0 -1
  104. package/lib/icons/heroicons/solid.js +407 -415
  105. package/lib/icons/lucide.d.ts +0 -1
  106. package/lib/icons/lucide.js +24479 -26351
  107. package/lib/icons/material/filled.d.ts +0 -1
  108. package/lib/icons/material/filled.js +9653 -9663
  109. package/lib/icons/material/outlined.d.ts +0 -1
  110. package/lib/icons/material/outlined.js +10271 -10281
  111. package/lib/icons/material/round.d.ts +0 -1
  112. package/lib/icons/material/round.js +10495 -10505
  113. package/lib/icons/material/sharp.d.ts +0 -1
  114. package/lib/icons/material/sharp.js +9905 -9915
  115. package/lib/icons/material/two-tone.d.ts +0 -1
  116. package/lib/icons/material/two-tone.js +12792 -12802
  117. package/lib/index.d.ts +7 -4
  118. package/lib/index.js +26 -39
  119. package/lib/styles/button.d.ts +24 -7
  120. package/lib/styles/button.js +285 -445
  121. package/lib/styles/calendar-month.d.ts +7 -6
  122. package/lib/styles/calendar-month.js +158 -226
  123. package/lib/styles/calendar-navigation.d.ts +2 -6
  124. package/lib/styles/calendar-navigation.js +108 -127
  125. package/lib/styles/calendar.d.ts +3 -3
  126. package/lib/styles/calendar.js +87 -23
  127. package/lib/styles/checkbox.d.ts +7 -6
  128. package/lib/styles/checkbox.js +101 -15
  129. package/lib/styles/copy.d.ts +3 -2
  130. package/lib/styles/copy.js +91 -71
  131. package/lib/styles/custom-scrollbar.d.ts +1 -2
  132. package/lib/styles/custom-scrollbar.js +80 -115
  133. package/lib/styles/date-picker.d.ts +4 -6
  134. package/lib/styles/date-picker.js +321 -388
  135. package/lib/styles/field-size.d.ts +6 -0
  136. package/lib/styles/field-size.js +91 -0
  137. package/lib/styles/file-upload.d.ts +1 -2
  138. package/lib/styles/file-upload.js +143 -188
  139. package/lib/styles/icon.d.ts +2 -6
  140. package/lib/styles/icon.js +92 -170
  141. package/lib/styles/input.d.ts +4 -7
  142. package/lib/styles/input.js +148 -643
  143. package/lib/styles/modal.d.ts +1 -2
  144. package/lib/styles/modal.js +127 -108
  145. package/lib/styles/option.d.ts +2 -6
  146. package/lib/styles/option.js +53 -96
  147. package/lib/styles/popup.d.ts +1 -2
  148. package/lib/styles/popup.js +47 -77
  149. package/lib/styles/radio.d.ts +3 -2
  150. package/lib/styles/radio.js +90 -116
  151. package/lib/styles/resize-observer.d.ts +1 -2
  152. package/lib/styles/resize-observer.js +2 -12
  153. package/lib/styles/scroll-container.d.ts +1 -2
  154. package/lib/styles/scroll-container.js +103 -146
  155. package/lib/styles/select-base.d.ts +8 -0
  156. package/lib/styles/select-base.js +752 -0
  157. package/lib/styles/select.d.ts +11 -0
  158. package/lib/styles/select.js +229 -0
  159. package/lib/styles/sortable.d.ts +16 -0
  160. package/lib/styles/sortable.js +85 -0
  161. package/lib/styles/step.d.ts +1 -2
  162. package/lib/styles/step.js +15 -34
  163. package/lib/styles/switch.d.ts +3 -2
  164. package/lib/styles/switch.js +52 -68
  165. package/lib/styles/tab.d.ts +1 -2
  166. package/lib/styles/tab.js +86 -34
  167. package/lib/styles/tabs.d.ts +3 -11
  168. package/lib/styles/tabs.js +204 -162
  169. package/lib/styles/tag.d.ts +2 -6
  170. package/lib/styles/tag.js +168 -362
  171. package/lib/styles/textarea.d.ts +1 -2
  172. package/lib/styles/textarea.js +238 -306
  173. package/lib/styles/tooltip.d.ts +4 -3
  174. package/lib/styles/tooltip.js +3 -131
  175. package/lib/styles/wizard.d.ts +8 -20
  176. package/lib/styles/wizard.js +306 -295
  177. package/lib/types/common.d.ts +9 -8
  178. package/lib/types/common.js +8 -5
  179. package/lib/utils/calendar-utils.d.ts +49 -65
  180. package/lib/utils/calendar-utils.js +158 -343
  181. package/lib/utils/custom-scrollbar.d.ts +6 -20
  182. package/lib/utils/custom-scrollbar.js +273 -317
  183. package/lib/utils/flavor-sheet.d.ts +31 -0
  184. package/lib/utils/flavor-sheet.js +17 -0
  185. package/lib/utils/icon-registry.d.ts +0 -15
  186. package/lib/utils/icon-registry.js +138 -279
  187. package/lib/utils/icons.d.ts +9 -0
  188. package/lib/utils/icons.js +1 -0
  189. package/lib/utils/loader-registry.d.ts +2 -3
  190. package/lib/utils/loader-registry.js +3 -35
  191. package/lib/utils/locale.d.ts +2 -80
  192. package/lib/utils/locale.js +30 -205
  193. package/lib/utils/mobile.d.ts +0 -1
  194. package/lib/utils/mobile.js +1 -18
  195. package/lib/utils/number-format.d.ts +6 -24
  196. package/lib/utils/number-format.js +53 -136
  197. package/lib/utils/positioning.d.ts +72 -22
  198. package/lib/utils/positioning.js +224 -298
  199. package/lib/utils/property-capture.d.ts +5 -27
  200. package/lib/utils/property-capture.js +36 -144
  201. package/lib/utils/property-manager.d.ts +6 -6
  202. package/lib/utils/property-manager.js +127 -196
  203. package/lib/utils/resize-observer.d.ts +0 -1
  204. package/lib/utils/resize-observer.js +23 -59
  205. package/lib/utils/scroll-lock.d.ts +10 -11
  206. package/lib/utils/scroll-lock.js +165 -173
  207. package/lib/utils/styles.d.ts +0 -6
  208. package/lib/utils/styles.js +17 -48
  209. package/lib/utils/upgrade-properties.d.ts +21 -0
  210. package/lib/utils/upgrade-properties.js +47 -0
  211. package/lib/utils/validity.d.ts +122 -0
  212. package/lib/utils/validity.js +289 -0
  213. package/lib/version.d.ts +1 -2
  214. package/lib/version.js +1 -11
  215. package/package.json +66 -18
  216. package/lib/base/ty-component.d.ts.map +0 -1
  217. package/lib/base/ty-component.js.map +0 -1
  218. package/lib/components/button.d.ts.map +0 -1
  219. package/lib/components/button.js.map +0 -1
  220. package/lib/components/calendar-month.d.ts.map +0 -1
  221. package/lib/components/calendar-month.js.map +0 -1
  222. package/lib/components/calendar-navigation.d.ts.map +0 -1
  223. package/lib/components/calendar-navigation.js.map +0 -1
  224. package/lib/components/calendar.d.ts.map +0 -1
  225. package/lib/components/calendar.js.map +0 -1
  226. package/lib/components/checkbox.d.ts.map +0 -1
  227. package/lib/components/checkbox.js.map +0 -1
  228. package/lib/components/copy.d.ts.map +0 -1
  229. package/lib/components/copy.js.map +0 -1
  230. package/lib/components/date-picker.d.ts.map +0 -1
  231. package/lib/components/date-picker.js.map +0 -1
  232. package/lib/components/dropdown.d.ts +0 -404
  233. package/lib/components/dropdown.d.ts.map +0 -1
  234. package/lib/components/dropdown.js +0 -1563
  235. package/lib/components/dropdown.js.map +0 -1
  236. package/lib/components/file-upload.d.ts.map +0 -1
  237. package/lib/components/file-upload.js.map +0 -1
  238. package/lib/components/icon.d.ts.map +0 -1
  239. package/lib/components/icon.js.map +0 -1
  240. package/lib/components/input.d.ts.map +0 -1
  241. package/lib/components/input.js.map +0 -1
  242. package/lib/components/modal.d.ts.map +0 -1
  243. package/lib/components/modal.js.map +0 -1
  244. package/lib/components/multiselect.d.ts +0 -408
  245. package/lib/components/multiselect.d.ts.map +0 -1
  246. package/lib/components/multiselect.js +0 -1611
  247. package/lib/components/multiselect.js.map +0 -1
  248. package/lib/components/option.d.ts.map +0 -1
  249. package/lib/components/option.js.map +0 -1
  250. package/lib/components/popup.d.ts.map +0 -1
  251. package/lib/components/popup.js.map +0 -1
  252. package/lib/components/radio.d.ts.map +0 -1
  253. package/lib/components/radio.js.map +0 -1
  254. package/lib/components/resize-observer.d.ts.map +0 -1
  255. package/lib/components/resize-observer.js.map +0 -1
  256. package/lib/components/scroll-container.d.ts.map +0 -1
  257. package/lib/components/scroll-container.js.map +0 -1
  258. package/lib/components/step.d.ts.map +0 -1
  259. package/lib/components/step.js.map +0 -1
  260. package/lib/components/switch.d.ts.map +0 -1
  261. package/lib/components/switch.js.map +0 -1
  262. package/lib/components/tab.d.ts.map +0 -1
  263. package/lib/components/tab.js.map +0 -1
  264. package/lib/components/tabs.d.ts.map +0 -1
  265. package/lib/components/tabs.js.map +0 -1
  266. package/lib/components/tag.d.ts.map +0 -1
  267. package/lib/components/tag.js.map +0 -1
  268. package/lib/components/textarea.d.ts.map +0 -1
  269. package/lib/components/textarea.js.map +0 -1
  270. package/lib/components/tooltip.d.ts.map +0 -1
  271. package/lib/components/tooltip.js.map +0 -1
  272. package/lib/components/wizard.d.ts.map +0 -1
  273. package/lib/components/wizard.js.map +0 -1
  274. package/lib/icons/fontawesome/brands.d.ts.map +0 -1
  275. package/lib/icons/fontawesome/brands.js.map +0 -1
  276. package/lib/icons/fontawesome/regular.d.ts.map +0 -1
  277. package/lib/icons/fontawesome/regular.js.map +0 -1
  278. package/lib/icons/fontawesome/solid.d.ts.map +0 -1
  279. package/lib/icons/fontawesome/solid.js.map +0 -1
  280. package/lib/icons/heroicons/micro.d.ts.map +0 -1
  281. package/lib/icons/heroicons/micro.js.map +0 -1
  282. package/lib/icons/heroicons/mini.d.ts.map +0 -1
  283. package/lib/icons/heroicons/mini.js.map +0 -1
  284. package/lib/icons/heroicons/outline.d.ts.map +0 -1
  285. package/lib/icons/heroicons/outline.js.map +0 -1
  286. package/lib/icons/heroicons/solid.d.ts.map +0 -1
  287. package/lib/icons/heroicons/solid.js.map +0 -1
  288. package/lib/icons/lucide.d.ts.map +0 -1
  289. package/lib/icons/lucide.js.map +0 -1
  290. package/lib/icons/material/filled.d.ts.map +0 -1
  291. package/lib/icons/material/filled.js.map +0 -1
  292. package/lib/icons/material/outlined.d.ts.map +0 -1
  293. package/lib/icons/material/outlined.js.map +0 -1
  294. package/lib/icons/material/round.d.ts.map +0 -1
  295. package/lib/icons/material/round.js.map +0 -1
  296. package/lib/icons/material/sharp.d.ts.map +0 -1
  297. package/lib/icons/material/sharp.js.map +0 -1
  298. package/lib/icons/material/two-tone.d.ts.map +0 -1
  299. package/lib/icons/material/two-tone.js.map +0 -1
  300. package/lib/index.d.ts.map +0 -1
  301. package/lib/index.js.map +0 -1
  302. package/lib/styles/button.d.ts.map +0 -1
  303. package/lib/styles/button.js.map +0 -1
  304. package/lib/styles/calendar-month.d.ts.map +0 -1
  305. package/lib/styles/calendar-month.js.map +0 -1
  306. package/lib/styles/calendar-navigation.d.ts.map +0 -1
  307. package/lib/styles/calendar-navigation.js.map +0 -1
  308. package/lib/styles/calendar.d.ts.map +0 -1
  309. package/lib/styles/calendar.js.map +0 -1
  310. package/lib/styles/checkbox.d.ts.map +0 -1
  311. package/lib/styles/checkbox.js.map +0 -1
  312. package/lib/styles/copy.d.ts.map +0 -1
  313. package/lib/styles/copy.js.map +0 -1
  314. package/lib/styles/custom-scrollbar.d.ts.map +0 -1
  315. package/lib/styles/custom-scrollbar.js.map +0 -1
  316. package/lib/styles/date-picker.d.ts.map +0 -1
  317. package/lib/styles/date-picker.js.map +0 -1
  318. package/lib/styles/dropdown.d.ts +0 -12
  319. package/lib/styles/dropdown.d.ts.map +0 -1
  320. package/lib/styles/dropdown.js +0 -1048
  321. package/lib/styles/dropdown.js.map +0 -1
  322. package/lib/styles/file-upload.d.ts.map +0 -1
  323. package/lib/styles/file-upload.js.map +0 -1
  324. package/lib/styles/icon.d.ts.map +0 -1
  325. package/lib/styles/icon.js.map +0 -1
  326. package/lib/styles/input.d.ts.map +0 -1
  327. package/lib/styles/input.js.map +0 -1
  328. package/lib/styles/modal.d.ts.map +0 -1
  329. package/lib/styles/modal.js.map +0 -1
  330. package/lib/styles/multiselect.d.ts +0 -6
  331. package/lib/styles/multiselect.d.ts.map +0 -1
  332. package/lib/styles/multiselect.js +0 -837
  333. package/lib/styles/multiselect.js.map +0 -1
  334. package/lib/styles/option.d.ts.map +0 -1
  335. package/lib/styles/option.js.map +0 -1
  336. package/lib/styles/popup.d.ts.map +0 -1
  337. package/lib/styles/popup.js.map +0 -1
  338. package/lib/styles/radio.d.ts.map +0 -1
  339. package/lib/styles/radio.js.map +0 -1
  340. package/lib/styles/resize-observer.d.ts.map +0 -1
  341. package/lib/styles/resize-observer.js.map +0 -1
  342. package/lib/styles/scroll-container.d.ts.map +0 -1
  343. package/lib/styles/scroll-container.js.map +0 -1
  344. package/lib/styles/step.d.ts.map +0 -1
  345. package/lib/styles/step.js.map +0 -1
  346. package/lib/styles/switch.d.ts.map +0 -1
  347. package/lib/styles/switch.js.map +0 -1
  348. package/lib/styles/tab.d.ts.map +0 -1
  349. package/lib/styles/tab.js.map +0 -1
  350. package/lib/styles/tabs.d.ts.map +0 -1
  351. package/lib/styles/tabs.js.map +0 -1
  352. package/lib/styles/tag.d.ts.map +0 -1
  353. package/lib/styles/tag.js.map +0 -1
  354. package/lib/styles/textarea.d.ts.map +0 -1
  355. package/lib/styles/textarea.js.map +0 -1
  356. package/lib/styles/tooltip.d.ts.map +0 -1
  357. package/lib/styles/tooltip.js.map +0 -1
  358. package/lib/styles/wizard.d.ts.map +0 -1
  359. package/lib/styles/wizard.js.map +0 -1
  360. package/lib/types/common.d.ts.map +0 -1
  361. package/lib/types/common.js.map +0 -1
  362. package/lib/utils/calendar-utils.d.ts.map +0 -1
  363. package/lib/utils/calendar-utils.js.map +0 -1
  364. package/lib/utils/custom-scrollbar.d.ts.map +0 -1
  365. package/lib/utils/custom-scrollbar.js.map +0 -1
  366. package/lib/utils/icon-registry.d.ts.map +0 -1
  367. package/lib/utils/icon-registry.js.map +0 -1
  368. package/lib/utils/loader-registry.d.ts.map +0 -1
  369. package/lib/utils/loader-registry.js.map +0 -1
  370. package/lib/utils/locale.d.ts.map +0 -1
  371. package/lib/utils/locale.js.map +0 -1
  372. package/lib/utils/mobile.d.ts.map +0 -1
  373. package/lib/utils/mobile.js.map +0 -1
  374. package/lib/utils/number-format.d.ts.map +0 -1
  375. package/lib/utils/number-format.js.map +0 -1
  376. package/lib/utils/parse-boolean.d.ts +0 -39
  377. package/lib/utils/parse-boolean.d.ts.map +0 -1
  378. package/lib/utils/parse-boolean.js +0 -58
  379. package/lib/utils/parse-boolean.js.map +0 -1
  380. package/lib/utils/positioning.d.ts.map +0 -1
  381. package/lib/utils/positioning.js.map +0 -1
  382. package/lib/utils/property-capture.d.ts.map +0 -1
  383. package/lib/utils/property-capture.js.map +0 -1
  384. package/lib/utils/property-manager.d.ts.map +0 -1
  385. package/lib/utils/property-manager.js.map +0 -1
  386. package/lib/utils/resize-observer.d.ts.map +0 -1
  387. package/lib/utils/resize-observer.js.map +0 -1
  388. package/lib/utils/scroll-lock.d.ts.map +0 -1
  389. package/lib/utils/scroll-lock.js.map +0 -1
  390. package/lib/utils/styles.d.ts.map +0 -1
  391. package/lib/utils/styles.js.map +0 -1
  392. package/lib/version.d.ts.map +0 -1
  393. package/lib/version.js.map +0 -1
@@ -1,45 +1,8 @@
1
- /**
2
- * TyCalendarNavigation Web Component
3
- * PORTED FROM: cljs/ty/components/calendar_navigation.cljs
4
- *
5
- * A pure presentation component for calendar month/year navigation.
6
- * Stateless - all state comes from properties, changes emitted via events.
7
- *
8
- * Features:
9
- * - Year/Month navigation (prev/next month, prev/next year)
10
- * - Localized month name display
11
- * - Custom event emission on navigation
12
- * - Property-driven API (no internal state)
13
- * - Inline SVG icons
14
- * - Shadow DOM encapsulation
15
- *
16
- * @example
17
- * ```html
18
- * <!-- Basic usage -->
19
- * <ty-calendar-navigation
20
- * display-month="10"
21
- * display-year="2025"
22
- * locale="en-US">
23
- * </ty-calendar-navigation>
24
- *
25
- * <!-- Listen for changes -->
26
- * <script type="module">
27
- * const nav = document.querySelector('ty-calendar-navigation');
28
- * nav.addEventListener('change', (e) => {
29
- * console.log('New month:', e.detail.month);
30
- * console.log('New year:', e.detail.year);
31
- * });
32
- * </script>
33
- * ```
34
- */
35
1
  import { ensureStyles } from '../utils/styles.js';
36
2
  import { calendarNavigationStyles } from '../styles/calendar-navigation.js';
37
- import { getMonthName } from '../utils/calendar-utils.js';
3
+ import { getMonthName, parseDateDay } from '../utils/calendar-utils.js';
38
4
  import { getEffectiveLocale, observeLocaleChanges } from '../utils/locale.js';
39
5
  import { TyComponent } from '../base/ty-component.js';
40
- // ============================================================================
41
- // SVG Icons (Material Design)
42
- // ============================================================================
43
6
  const CHEVRON_LEFT_SVG = `<?xml version='1.0' encoding='UTF-8'?>
44
7
  <svg width='24' viewBox='0 0 24 24' height='24' xmlns='http://www.w3.org/2000/svg' stroke-width='0' stroke='currentColor' fill='currentColor'>
45
8
  <path fill='none' d='M0 0h24v24H0V0z'/>
@@ -50,317 +13,295 @@ const CHEVRON_RIGHT_SVG = `<?xml version='1.0' encoding='UTF-8'?>
50
13
  <path fill='none' d='M0 0h24v24H0V0z'/>
51
14
  <path d='M8.59 16.59L13.17 12 8.59 7.41 10 6l6 6-6 6-1.41-1.41z'/>
52
15
  </svg>`;
53
- const CHEVRONS_LEFT_SVG = `<?xml version='1.0' encoding='UTF-8'?>
54
- <svg width='24' viewBox='0 0 24 24' height='24' enable-background='new 0 0 24 24' xmlns='http://www.w3.org/2000/svg' stroke-width='0' stroke='currentColor' fill='currentColor'>
55
- <g>
56
- <rect width='24' height='24' fill='none'/>
57
- </g>
58
- <g>
59
- <g>
60
- <polygon points='17.59,18 19,16.59 14.42,12 19,7.41 17.59,6 11.59,12'/>
61
- <polygon points='11,18 12.41,16.59 7.83,12 12.41,7.41 11,6 5,12'/>
62
- </g>
63
- </g>
16
+ const CARET_DOWN_SVG = `<svg width='24' viewBox='0 0 24 24' height='24' xmlns='http://www.w3.org/2000/svg' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'>
17
+ <path d='m6 9 6 6 6-6'/>
64
18
  </svg>`;
65
- const CHEVRONS_RIGHT_SVG = `<?xml version='1.0' encoding='UTF-8'?>
66
- <svg width='24' viewBox='0 0 24 24' height='24' enable-background='new 0 0 24 24' xmlns='http://www.w3.org/2000/svg' stroke-width='0' stroke='currentColor' fill='currentColor'>
67
- <g>
68
- <rect width='24' height='24' fill='none'/>
69
- </g>
70
- <g>
71
- <g>
72
- <polygon points='6.41,6 5,7.41 9.58,12 5,16.59 6.41,18 12.41,12'/>
73
- <polygon points='13,6 11.59,7.41 16.17,12 11.59,16.59 13,18 19,12'/>
74
- </g>
75
- </g>
76
- </svg>`;
77
- // ============================================================================
78
- // Component Implementation
79
- // ============================================================================
80
- /**
81
- * TyCalendarNavigation Web Component
82
- */
83
19
  export class TyCalendarNavigation extends TyComponent {
84
- constructor() {
85
- super(); // TyComponent handles attachShadow
86
- // Initialize state with current date
87
- const today = new Date();
88
- this._state = {
89
- displayMonth: today.getMonth() + 1,
90
- displayYear: today.getFullYear()
91
- };
92
- // Initialize styles in shadow root
93
- const shadow = this.shadowRoot;
94
- ensureStyles(shadow, { css: calendarNavigationStyles, id: 'ty-calendar-navigation' });
95
- }
96
- // ==========================================================================
97
- // Lifecycle Hooks (TyComponent)
98
- // ==========================================================================
99
- /**
100
- * Called when component connects to DOM
101
- */
102
- onConnect() {
103
- // Sync state from properties
104
- this._state.displayMonth = this.displayMonth;
105
- this._state.displayYear = this.displayYear;
106
- // Setup locale observer to watch for ancestor lang changes
107
- this._localeObserver = observeLocaleChanges(this, () => {
108
- this.render();
109
- });
110
- // Initial render
111
- this.render();
112
- }
113
- /**
114
- * Called when component disconnects from DOM
115
- */
116
- onDisconnect() {
117
- // Cleanup locale observer
118
- if (this._localeObserver) {
119
- this._localeObserver();
120
- this._localeObserver = undefined;
121
- }
122
- }
123
- /**
124
- * Called when properties change
125
- * Update internal state BEFORE render
126
- */
127
- onPropertiesChanged(changes) {
128
- for (const { name, newValue } of changes) {
129
- switch (name) {
130
- case 'display-month':
131
- this._state.displayMonth = newValue;
132
- break;
133
- case 'display-year':
134
- this._state.displayYear = newValue;
135
- break;
136
- case 'locale':
137
- case 'size':
138
- case 'width':
139
- // These properties just affect rendering
140
- // TyComponent will call render() automatically for visual properties
141
- break;
142
- }
143
- }
144
- }
145
- // ==========================================================================
146
- // Property Accessors - Simple wrappers using TyComponent
147
- // ==========================================================================
148
- get displayMonth() {
149
- return this.getProperty('display-month');
150
- }
151
- set displayMonth(value) {
152
- this.setProperty('display-month', value);
153
- }
154
- get displayYear() {
155
- return this.getProperty('display-year');
156
- }
157
- set displayYear(value) {
158
- this.setProperty('display-year', value);
159
- }
160
- get locale() {
161
- // Use getEffectiveLocale to check ancestor lang attributes
162
- return getEffectiveLocale(this, this.getProperty('locale'));
163
- }
164
- set locale(value) {
165
- this.setProperty('locale', value);
166
- }
167
- get size() {
168
- return this.getProperty('size');
169
- }
170
- set size(value) {
171
- this.setProperty('size', value);
172
- }
173
- get width() {
174
- return this.getProperty('width');
175
- }
176
- set width(value) {
177
- this.setProperty('width', value);
178
- }
179
- // ==========================================================================
180
- // Event Dispatching
181
- // ==========================================================================
182
- /**
183
- * Emit change event with new month/year
184
- */
185
- emitChangeEvent(month, year) {
186
- const detail = {
187
- month,
188
- year,
189
- };
190
- const event = new CustomEvent('change', {
191
- detail,
192
- bubbles: true,
193
- cancelable: true,
194
- });
195
- this.dispatchEvent(event);
196
- }
197
- // ==========================================================================
198
- // Navigation Logic
199
- // ==========================================================================
200
- /**
201
- * Navigate to previous/next month
202
- * Handles year boundary crossing
203
- */
204
- navigateMonth(direction) {
205
- const rawMonth = this._state.displayMonth + direction;
206
- let newMonth;
207
- let newYear;
208
- if (rawMonth < 1) {
209
- // Rolled back to previous year
210
- newMonth = 12;
211
- newYear = this._state.displayYear - 1;
212
- }
213
- else if (rawMonth > 12) {
214
- // Rolled forward to next year
215
- newMonth = 1;
216
- newYear = this._state.displayYear + 1;
217
- }
218
- else {
219
- newMonth = rawMonth;
220
- newYear = this._state.displayYear;
221
- }
222
- this.emitChangeEvent(newMonth, newYear);
223
- }
224
- /**
225
- * Navigate to previous/next year
226
- */
227
- navigateYear(direction) {
228
- const newYear = this._state.displayYear + direction;
229
- this.emitChangeEvent(this._state.displayMonth, newYear);
230
- }
231
- // ==========================================================================
232
- // Rendering
233
- // ==========================================================================
234
- /**
235
- * Create navigation button
236
- */
237
- createButton(className, title, svg, onClick) {
238
- const button = document.createElement('button');
239
- button.className = className;
240
- button.title = title;
241
- button.innerHTML = svg;
242
- button.addEventListener('click', onClick);
243
- return button;
244
- }
245
- /**
246
- * Main render function
247
- */
248
- render() {
249
- const root = this.shadowRoot;
250
- if (!root)
251
- return;
252
- // Ensure styles are loaded
253
- ensureStyles(root, { css: calendarNavigationStyles, id: 'ty-calendar-navigation' });
254
- // Apply size as data attribute for CSS targeting
255
- const size = this.size;
256
- this.setAttribute('data-size', size);
257
- // Apply width property as CSS custom property
258
- const width = this.width;
259
- if (width) {
260
- this.style.setProperty('--nav-width', width);
261
- }
262
- else {
263
- this.style.removeProperty('--nav-width');
264
- }
265
- // Get localized month name using current state
266
- const monthName = getMonthName(this._state.displayMonth, this.locale, 'long');
267
- // Clear and rebuild
268
- root.innerHTML = '';
269
- // Create main header container
270
- const header = document.createElement('div');
271
- header.className = 'calendar-navigation-header';
272
- // Left group: [⟪ ‹]
273
- const leftGroup = document.createElement('div');
274
- leftGroup.className = 'nav-group nav-group-left';
275
- leftGroup.appendChild(this.createButton('nav-btn nav-year-prev', 'Previous year', CHEVRONS_LEFT_SVG, () => this.navigateYear(-1)));
276
- leftGroup.appendChild(this.createButton('nav-btn nav-month-prev', 'Previous month', CHEVRON_LEFT_SVG, () => this.navigateMonth(-1)));
277
- // Center group: [Month Year]
278
- const centerGroup = document.createElement('div');
279
- centerGroup.className = 'nav-group nav-group-center';
280
- const monthYearDisplay = document.createElement('div');
281
- monthYearDisplay.className = 'month-year-display';
282
- monthYearDisplay.textContent = `${monthName} ${this._state.displayYear}`;
283
- centerGroup.appendChild(monthYearDisplay);
284
- // Right group: [› ⟫]
285
- const rightGroup = document.createElement('div');
286
- rightGroup.className = 'nav-group nav-group-right';
287
- rightGroup.appendChild(this.createButton('nav-btn nav-month-next', 'Next month', CHEVRON_RIGHT_SVG, () => this.navigateMonth(1)));
288
- rightGroup.appendChild(this.createButton('nav-btn nav-year-next', 'Next year', CHEVRONS_RIGHT_SVG, () => this.navigateYear(1)));
289
- // Assemble header
290
- header.appendChild(leftGroup);
291
- header.appendChild(centerGroup);
292
- header.appendChild(rightGroup);
293
- root.appendChild(header);
294
- }
295
- }
296
- // ============================================================================
297
- // PROPERTY CONFIGURATION - Single source of truth
298
- // ============================================================================
20
+ constructor() {
21
+ super();
22
+ const today = new Date();
23
+ this._state = {
24
+ displayMonth: today.getMonth() + 1,
25
+ displayYear: today.getFullYear()
26
+ };
27
+ const shadow = this.shadowRoot;
28
+ ensureStyles(shadow, { css: calendarNavigationStyles, id: 'ty-calendar-navigation' });
29
+ }
30
+ onConnect() {
31
+ this._state.displayMonth = this.displayMonth;
32
+ this._state.displayYear = this.displayYear;
33
+ this._localeObserver = observeLocaleChanges(this, () => {
34
+ if (!this.getProperty('locale'))
35
+ this.render();
36
+ });
37
+ this.render();
38
+ }
39
+ onDisconnect() {
40
+ if (this._localeObserver) {
41
+ this._localeObserver();
42
+ this._localeObserver = undefined;
43
+ }
44
+ }
45
+ onPropertiesChanged(changes) {
46
+ for (const { name, newValue } of changes) {
47
+ switch (name) {
48
+ case 'display-month':
49
+ this._state.displayMonth = newValue;
50
+ break;
51
+ case 'display-year':
52
+ this._state.displayYear = newValue;
53
+ break;
54
+ case 'locale':
55
+ case 'size':
56
+ case 'width':
57
+ case 'view':
58
+ break;
59
+ }
60
+ }
61
+ }
62
+ get displayMonth() {
63
+ return this.getProperty('display-month');
64
+ }
65
+ set displayMonth(value) {
66
+ this.setProperty('display-month', value);
67
+ }
68
+ get displayYear() {
69
+ return this.getProperty('display-year');
70
+ }
71
+ set displayYear(value) {
72
+ this.setProperty('display-year', value);
73
+ }
74
+ get locale() {
75
+ return getEffectiveLocale(this, this.getProperty('locale'));
76
+ }
77
+ set locale(value) {
78
+ this.setProperty('locale', value);
79
+ }
80
+ get size() {
81
+ return this.getProperty('size');
82
+ }
83
+ set size(value) {
84
+ this.setProperty('size', value);
85
+ }
86
+ get width() {
87
+ return this.getProperty('width');
88
+ }
89
+ set width(value) {
90
+ this.setProperty('width', value);
91
+ }
92
+ get view() {
93
+ return this.getProperty('view');
94
+ }
95
+ set view(value) {
96
+ this.setProperty('view', value);
97
+ }
98
+ get min() {
99
+ return this.getProperty('min');
100
+ }
101
+ set min(value) {
102
+ this.setProperty('min', value ?? '');
103
+ }
104
+ get max() {
105
+ return this.getProperty('max');
106
+ }
107
+ set max(value) {
108
+ this.setProperty('max', value ?? '');
109
+ }
110
+ emitChangeEvent(month, year) {
111
+ const detail = {
112
+ month,
113
+ year,
114
+ };
115
+ const event = new CustomEvent('change', {
116
+ detail,
117
+ bubbles: true,
118
+ cancelable: true,
119
+ });
120
+ this.dispatchEvent(event);
121
+ }
122
+ static monthIndex(year, month) {
123
+ return year * 12 + (month - 1);
124
+ }
125
+ boundIndices() {
126
+ const min = parseDateDay(this.min);
127
+ const max = parseDateDay(this.max);
128
+ return {
129
+ minIdx: min ? TyCalendarNavigation.monthIndex(min.year, min.month) : null,
130
+ maxIdx: max ? TyCalendarNavigation.monthIndex(max.year, max.month) : null,
131
+ };
132
+ }
133
+ clampIndex(idx) {
134
+ const { minIdx, maxIdx } = this.boundIndices();
135
+ if (minIdx !== null && idx < minIdx)
136
+ return minIdx;
137
+ if (maxIdx !== null && idx > maxIdx)
138
+ return maxIdx;
139
+ return idx;
140
+ }
141
+ navigateBy(deltaMonths) {
142
+ const current = TyCalendarNavigation.monthIndex(this._state.displayYear, this._state.displayMonth);
143
+ const target = this.clampIndex(current + deltaMonths);
144
+ if (target === current)
145
+ return;
146
+ this.emitChangeEvent((target % 12) + 1, Math.floor(target / 12));
147
+ }
148
+ isNavDisabled(deltaMonths) {
149
+ const current = TyCalendarNavigation.monthIndex(this._state.displayYear, this._state.displayMonth);
150
+ return this.clampIndex(current + deltaMonths) === current;
151
+ }
152
+ createButton(className, title, svg, onClick, disabled = false) {
153
+ const button = document.createElement('button');
154
+ button.type = 'button';
155
+ button.className = className;
156
+ button.title = title;
157
+ button.setAttribute('aria-label', title);
158
+ button.innerHTML = svg;
159
+ button.disabled = disabled;
160
+ button.addEventListener('click', onClick);
161
+ return button;
162
+ }
163
+ render() {
164
+ const root = this.shadowRoot;
165
+ if (!root)
166
+ return;
167
+ ensureStyles(root, { css: calendarNavigationStyles, id: 'ty-calendar-navigation' });
168
+ const size = this.size;
169
+ this.setAttribute('data-size', size);
170
+ const width = this.width;
171
+ if (width) {
172
+ this.style.setProperty('--nav-width', width);
173
+ }
174
+ else {
175
+ this.style.removeProperty('--nav-width');
176
+ }
177
+ const months = this.view === 'months';
178
+ const monthName = getMonthName(this._state.displayMonth, this.locale, 'long');
179
+ const had = root.activeElement;
180
+ const place = !had ? null
181
+ : had.classList.contains('nav-title') ? 'title'
182
+ : had.className.includes('-prev') ? 'prev'
183
+ : had.className.includes('-next') ? 'next'
184
+ : null;
185
+ root.innerHTML = '';
186
+ const header = document.createElement('div');
187
+ header.className = 'calendar-navigation-header';
188
+ const title = document.createElement('button');
189
+ title.type = 'button';
190
+ title.className = 'nav-title';
191
+ title.setAttribute('aria-expanded', String(months));
192
+ title.setAttribute('aria-label', months ? 'Back to days' : 'Choose month and year');
193
+ if (!months) {
194
+ const month = document.createElement('span');
195
+ month.className = 'nav-title-month';
196
+ month.textContent = monthName;
197
+ title.appendChild(month);
198
+ }
199
+ const year = document.createElement('span');
200
+ year.className = months ? 'nav-title-month' : 'nav-title-year';
201
+ year.textContent = String(this._state.displayYear);
202
+ title.appendChild(year);
203
+ const caret = document.createElement('span');
204
+ caret.className = 'nav-caret';
205
+ caret.innerHTML = CARET_DOWN_SVG;
206
+ title.appendChild(caret);
207
+ title.addEventListener('click', () => {
208
+ this.dispatchEvent(new CustomEvent('view-toggle', {
209
+ detail: { view: months ? 'days' : 'months' },
210
+ }));
211
+ });
212
+ const step = months ? 12 : 1;
213
+ const unit = months ? 'year' : 'month';
214
+ const arrows = document.createElement('div');
215
+ arrows.className = 'nav-group nav-arrows';
216
+ const prev = this.createButton(`nav-btn nav-${unit}-prev`, `Previous ${unit}`, CHEVRON_LEFT_SVG, () => this.navigateBy(-step), this.isNavDisabled(-step));
217
+ const next = this.createButton(`nav-btn nav-${unit}-next`, `Next ${unit}`, CHEVRON_RIGHT_SVG, () => this.navigateBy(step), this.isNavDisabled(step));
218
+ arrows.appendChild(prev);
219
+ arrows.appendChild(next);
220
+ header.appendChild(title);
221
+ header.appendChild(arrows);
222
+ root.appendChild(header);
223
+ if (place) {
224
+ const successor = place === 'prev' ? prev : place === 'next' ? next : title;
225
+ (successor.disabled ? title : successor).focus({ preventScroll: true });
226
+ }
227
+ }
228
+ }
299
229
  TyCalendarNavigation.properties = {
300
- // Display properties
301
- 'display-month': {
302
- type: 'number',
303
- visual: true,
304
- default: () => new Date().getMonth() + 1, // 1-based
305
- validate: (v) => {
306
- const num = Number(v);
307
- return Number.isInteger(num) && num >= 1 && num <= 12;
308
- },
309
- coerce: (v) => {
310
- const num = Number(v);
311
- if (isNaN(num) || num < 1 || num > 12) {
312
- console.warn(`[ty-calendar-navigation] Invalid month '${v}'. Using current month.`);
313
- return new Date().getMonth() + 1;
314
- }
315
- return num;
316
- }
317
- },
318
- 'display-year': {
319
- type: 'number',
320
- visual: true,
321
- default: () => new Date().getFullYear(),
322
- validate: (v) => {
323
- const num = Number(v);
324
- return Number.isInteger(num) && num >= 1 && num <= 9999;
325
- },
326
- coerce: (v) => {
327
- const num = Number(v);
328
- if (isNaN(num) || num < 1 || num > 9999) {
329
- console.warn(`[ty-calendar-navigation] Invalid year '${v}'. Using current year.`);
330
- return new Date().getFullYear();
331
- }
332
- return num;
333
- }
334
- },
335
- // Locale property
336
- locale: {
337
- type: 'string',
338
- visual: true,
339
- default: 'en-US'
340
- },
341
- // Size property
342
- size: {
343
- type: 'string',
344
- visual: true,
345
- default: 'md',
346
- validate: (v) => ['sm', 'md', 'lg'].includes(v),
347
- coerce: (v) => {
348
- if (!['sm', 'md', 'lg'].includes(v)) {
349
- console.warn(`[ty-calendar-navigation] Invalid size '${v}'. Using 'md'.`);
350
- return 'md';
351
- }
352
- return v;
353
- }
354
- },
355
- // Width property
356
- width: {
357
- type: 'string',
358
- visual: true,
359
- default: ''
360
- }
230
+ 'display-month': {
231
+ type: 'number',
232
+ visual: true,
233
+ default: () => new Date().getMonth() + 1,
234
+ validate: (v) => {
235
+ const num = Number(v);
236
+ return Number.isInteger(num) && num >= 1 && num <= 12;
237
+ },
238
+ coerce: (v) => {
239
+ const num = Number(v);
240
+ if (isNaN(num) || num < 1 || num > 12) {
241
+ console.warn(`[ty-calendar-navigation] Invalid month '${v}'. Using current month.`);
242
+ return new Date().getMonth() + 1;
243
+ }
244
+ return num;
245
+ }
246
+ },
247
+ 'display-year': {
248
+ type: 'number',
249
+ visual: true,
250
+ default: () => new Date().getFullYear(),
251
+ validate: (v) => {
252
+ const num = Number(v);
253
+ return Number.isInteger(num) && num >= 1 && num <= 9999;
254
+ },
255
+ coerce: (v) => {
256
+ const num = Number(v);
257
+ if (isNaN(num) || num < 1 || num > 9999) {
258
+ console.warn(`[ty-calendar-navigation] Invalid year '${v}'. Using current year.`);
259
+ return new Date().getFullYear();
260
+ }
261
+ return num;
262
+ }
263
+ },
264
+ locale: {
265
+ type: 'string',
266
+ visual: true,
267
+ default: ''
268
+ },
269
+ size: {
270
+ type: 'string',
271
+ visual: true,
272
+ default: 'md',
273
+ validate: (v) => ['sm', 'md', 'lg'].includes(v),
274
+ coerce: (v) => {
275
+ if (!['sm', 'md', 'lg'].includes(v)) {
276
+ console.warn(`[ty-calendar-navigation] Invalid size '${v}'. Using 'md'.`);
277
+ return 'md';
278
+ }
279
+ return v;
280
+ }
281
+ },
282
+ width: {
283
+ type: 'string',
284
+ visual: true,
285
+ default: ''
286
+ },
287
+ view: {
288
+ type: 'string',
289
+ visual: true,
290
+ default: 'days',
291
+ validate: (v) => v === 'days' || v === 'months',
292
+ coerce: (v) => (v === 'months' ? 'months' : 'days')
293
+ },
294
+ min: {
295
+ type: 'string',
296
+ visual: true,
297
+ default: ''
298
+ },
299
+ max: {
300
+ type: 'string',
301
+ visual: true,
302
+ default: ''
303
+ }
361
304
  };
362
- // Register the custom element
363
305
  if (!customElements.get('ty-calendar-navigation')) {
364
- customElements.define('ty-calendar-navigation', TyCalendarNavigation);
306
+ customElements.define('ty-calendar-navigation', TyCalendarNavigation);
365
307
  }
366
- //# sourceMappingURL=calendar-navigation.js.map