tyrell-components 1.0.0-RC12 → 1.0.0-RC14

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 (354) hide show
  1. package/README.md +2 -1
  2. package/css/tyrell-colors-static.css +316 -0
  3. package/css/tyrell-theme.css +1443 -0
  4. package/css/tyrell.css +127 -423
  5. package/dist/tyrell-colors-static.css +316 -0
  6. package/dist/tyrell-theme.css +1443 -0
  7. package/dist/tyrell.css +127 -423
  8. package/dist/tyrell.js +1 -1
  9. package/lib/base/ty-component.d.ts +20 -10
  10. package/lib/base/ty-component.js +21 -144
  11. package/lib/components/button.d.ts +9 -16
  12. package/lib/components/button.js +12 -37
  13. package/lib/components/calendar-month.d.ts +17 -46
  14. package/lib/components/calendar-month.js +97 -145
  15. package/lib/components/calendar-navigation.d.ts +3 -48
  16. package/lib/components/calendar-navigation.js +3 -126
  17. package/lib/components/calendar.d.ts +6 -81
  18. package/lib/components/calendar.js +24 -236
  19. package/lib/components/checkbox.d.ts +8 -74
  20. package/lib/components/checkbox.js +21 -177
  21. package/lib/components/copy.d.ts +7 -59
  22. package/lib/components/copy.js +19 -137
  23. package/lib/components/date-picker.d.ts +23 -161
  24. package/lib/components/date-picker.js +127 -588
  25. package/lib/components/file-upload.d.ts +9 -15
  26. package/lib/components/file-upload.js +19 -41
  27. package/lib/components/icon.d.ts +3 -24
  28. package/lib/components/icon.js +1 -90
  29. package/lib/components/input.d.ts +10 -109
  30. package/lib/components/input.js +24 -209
  31. package/lib/components/modal.d.ts +17 -26
  32. package/lib/components/modal.js +67 -192
  33. package/lib/components/option.d.ts +2 -20
  34. package/lib/components/option.js +1 -148
  35. package/lib/components/popup.d.ts +2 -17
  36. package/lib/components/popup.js +35 -132
  37. package/lib/components/radio.d.ts +7 -24
  38. package/lib/components/radio.js +24 -68
  39. package/lib/components/resize-observer.d.ts +3 -30
  40. package/lib/components/resize-observer.js +12 -46
  41. package/lib/components/scroll-container.d.ts +2 -12
  42. package/lib/components/scroll-container.js +3 -46
  43. package/lib/components/select.d.ts +130 -151
  44. package/lib/components/select.js +327 -516
  45. package/lib/components/selected-tags.d.ts +8 -38
  46. package/lib/components/selected-tags.js +20 -78
  47. package/lib/components/step.d.ts +1 -6
  48. package/lib/components/step.js +0 -6
  49. package/lib/components/switch.d.ts +4 -14
  50. package/lib/components/switch.js +15 -61
  51. package/lib/components/tab.d.ts +1 -6
  52. package/lib/components/tab.js +0 -7
  53. package/lib/components/tabs.d.ts +5 -63
  54. package/lib/components/tabs.js +159 -267
  55. package/lib/components/tag.d.ts +2 -36
  56. package/lib/components/tag.js +5 -105
  57. package/lib/components/textarea.d.ts +6 -86
  58. package/lib/components/textarea.js +2 -173
  59. package/lib/components/tooltip.d.ts +7 -13
  60. package/lib/components/tooltip.js +83 -180
  61. package/lib/components/wizard.d.ts +6 -54
  62. package/lib/components/wizard.js +27 -221
  63. package/lib/icons/fontawesome/brands.d.ts +0 -1
  64. package/lib/icons/fontawesome/brands.js +0 -8
  65. package/lib/icons/fontawesome/regular.d.ts +0 -1
  66. package/lib/icons/fontawesome/regular.js +0 -8
  67. package/lib/icons/fontawesome/solid.d.ts +0 -1
  68. package/lib/icons/fontawesome/solid.js +0 -8
  69. package/lib/icons/heroicons/micro.d.ts +0 -1
  70. package/lib/icons/heroicons/micro.js +0 -8
  71. package/lib/icons/heroicons/mini.d.ts +0 -1
  72. package/lib/icons/heroicons/mini.js +0 -8
  73. package/lib/icons/heroicons/outline.d.ts +0 -1
  74. package/lib/icons/heroicons/outline.js +0 -8
  75. package/lib/icons/heroicons/solid.d.ts +0 -1
  76. package/lib/icons/heroicons/solid.js +0 -8
  77. package/lib/icons/lucide.d.ts +0 -1
  78. package/lib/icons/lucide.js +0 -1872
  79. package/lib/icons/material/filled.d.ts +0 -1
  80. package/lib/icons/material/filled.js +0 -10
  81. package/lib/icons/material/outlined.d.ts +0 -1
  82. package/lib/icons/material/outlined.js +0 -10
  83. package/lib/icons/material/round.d.ts +0 -1
  84. package/lib/icons/material/round.js +0 -10
  85. package/lib/icons/material/sharp.d.ts +0 -1
  86. package/lib/icons/material/sharp.js +0 -10
  87. package/lib/icons/material/two-tone.d.ts +0 -1
  88. package/lib/icons/material/two-tone.js +0 -10
  89. package/lib/index.d.ts +2 -2
  90. package/lib/index.js +2 -21
  91. package/lib/styles/button.d.ts +19 -7
  92. package/lib/styles/button.js +180 -77
  93. package/lib/styles/calendar-month.d.ts +4 -6
  94. package/lib/styles/calendar-month.js +57 -59
  95. package/lib/styles/calendar-navigation.d.ts +2 -6
  96. package/lib/styles/calendar-navigation.js +3 -28
  97. package/lib/styles/calendar.d.ts +1 -2
  98. package/lib/styles/calendar.js +1 -14
  99. package/lib/styles/checkbox.d.ts +3 -2
  100. package/lib/styles/checkbox.js +24 -68
  101. package/lib/styles/copy.d.ts +3 -2
  102. package/lib/styles/copy.js +25 -17
  103. package/lib/styles/custom-scrollbar.d.ts +1 -2
  104. package/lib/styles/custom-scrollbar.js +5 -20
  105. package/lib/styles/date-picker.d.ts +4 -6
  106. package/lib/styles/date-picker.js +80 -130
  107. package/lib/styles/file-upload.d.ts +1 -2
  108. package/lib/styles/file-upload.js +4 -19
  109. package/lib/styles/icon.d.ts +2 -6
  110. package/lib/styles/icon.js +7 -21
  111. package/lib/styles/input.d.ts +4 -7
  112. package/lib/styles/input.js +55 -160
  113. package/lib/styles/modal.d.ts +1 -2
  114. package/lib/styles/modal.js +21 -23
  115. package/lib/styles/option.d.ts +2 -6
  116. package/lib/styles/option.js +17 -63
  117. package/lib/styles/popup.d.ts +1 -2
  118. package/lib/styles/popup.js +26 -30
  119. package/lib/styles/radio.d.ts +3 -2
  120. package/lib/styles/radio.js +21 -32
  121. package/lib/styles/resize-observer.d.ts +1 -2
  122. package/lib/styles/resize-observer.js +0 -7
  123. package/lib/styles/scroll-container.d.ts +1 -2
  124. package/lib/styles/scroll-container.js +0 -19
  125. package/lib/styles/select-base.d.ts +8 -0
  126. package/lib/styles/{multiselect.js → select-base.js} +264 -127
  127. package/lib/styles/select.d.ts +3 -4
  128. package/lib/styles/select.js +103 -43
  129. package/lib/styles/step.d.ts +1 -2
  130. package/lib/styles/step.js +0 -4
  131. package/lib/styles/switch.d.ts +3 -2
  132. package/lib/styles/switch.js +20 -23
  133. package/lib/styles/tab.d.ts +1 -2
  134. package/lib/styles/tab.js +0 -5
  135. package/lib/styles/tabs.d.ts +3 -11
  136. package/lib/styles/tabs.js +77 -45
  137. package/lib/styles/tag.d.ts +1 -5
  138. package/lib/styles/tag.js +6 -32
  139. package/lib/styles/textarea.d.ts +1 -2
  140. package/lib/styles/textarea.js +7 -50
  141. package/lib/styles/tooltip.d.ts +4 -3
  142. package/lib/styles/tooltip.js +0 -125
  143. package/lib/styles/wizard.d.ts +5 -21
  144. package/lib/styles/wizard.js +23 -91
  145. package/lib/types/common.d.ts +1 -3
  146. package/lib/types/common.js +0 -10
  147. package/lib/utils/calendar-utils.d.ts +4 -21
  148. package/lib/utils/calendar-utils.js +4 -177
  149. package/lib/utils/custom-scrollbar.d.ts +6 -20
  150. package/lib/utils/custom-scrollbar.js +1 -45
  151. package/lib/utils/flavor-sheet.d.ts +0 -1
  152. package/lib/utils/flavor-sheet.js +0 -23
  153. package/lib/utils/icon-registry.d.ts +0 -2
  154. package/lib/utils/icon-registry.js +1 -107
  155. package/lib/utils/icons.d.ts +9 -0
  156. package/lib/utils/icons.js +1 -0
  157. package/lib/utils/loader-registry.d.ts +2 -3
  158. package/lib/utils/loader-registry.js +0 -32
  159. package/lib/utils/locale.d.ts +2 -23
  160. package/lib/utils/locale.js +0 -86
  161. package/lib/utils/mobile.d.ts +0 -1
  162. package/lib/utils/mobile.js +0 -17
  163. package/lib/utils/number-format.d.ts +6 -3
  164. package/lib/utils/number-format.js +11 -67
  165. package/lib/utils/positioning.d.ts +77 -3
  166. package/lib/utils/positioning.js +67 -58
  167. package/lib/utils/property-capture.d.ts +5 -27
  168. package/lib/utils/property-capture.js +0 -108
  169. package/lib/utils/property-manager.d.ts +0 -1
  170. package/lib/utils/property-manager.js +0 -70
  171. package/lib/utils/resize-observer.d.ts +0 -1
  172. package/lib/utils/resize-observer.js +0 -36
  173. package/lib/utils/scroll-lock.d.ts +4 -11
  174. package/lib/utils/scroll-lock.js +0 -107
  175. package/lib/utils/styles.d.ts +0 -1
  176. package/lib/utils/styles.js +0 -24
  177. package/lib/version.d.ts +1 -2
  178. package/lib/version.js +1 -11
  179. package/package.json +8 -5
  180. package/css/tyrell-brand.css +0 -1015
  181. package/dist/tyrell-brand.css +0 -1015
  182. package/lib/base/ty-component.d.ts.map +0 -1
  183. package/lib/base/ty-component.js.map +0 -1
  184. package/lib/components/button.d.ts.map +0 -1
  185. package/lib/components/button.js.map +0 -1
  186. package/lib/components/calendar-month.d.ts.map +0 -1
  187. package/lib/components/calendar-month.js.map +0 -1
  188. package/lib/components/calendar-navigation.d.ts.map +0 -1
  189. package/lib/components/calendar-navigation.js.map +0 -1
  190. package/lib/components/calendar.d.ts.map +0 -1
  191. package/lib/components/calendar.js.map +0 -1
  192. package/lib/components/checkbox.d.ts.map +0 -1
  193. package/lib/components/checkbox.js.map +0 -1
  194. package/lib/components/copy.d.ts.map +0 -1
  195. package/lib/components/copy.js.map +0 -1
  196. package/lib/components/date-picker.d.ts.map +0 -1
  197. package/lib/components/date-picker.js.map +0 -1
  198. package/lib/components/file-upload.d.ts.map +0 -1
  199. package/lib/components/file-upload.js.map +0 -1
  200. package/lib/components/icon.d.ts.map +0 -1
  201. package/lib/components/icon.js.map +0 -1
  202. package/lib/components/input.d.ts.map +0 -1
  203. package/lib/components/input.js.map +0 -1
  204. package/lib/components/modal.d.ts.map +0 -1
  205. package/lib/components/modal.js.map +0 -1
  206. package/lib/components/option.d.ts.map +0 -1
  207. package/lib/components/option.js.map +0 -1
  208. package/lib/components/popup.d.ts.map +0 -1
  209. package/lib/components/popup.js.map +0 -1
  210. package/lib/components/radio.d.ts.map +0 -1
  211. package/lib/components/radio.js.map +0 -1
  212. package/lib/components/resize-observer.d.ts.map +0 -1
  213. package/lib/components/resize-observer.js.map +0 -1
  214. package/lib/components/scroll-container.d.ts.map +0 -1
  215. package/lib/components/scroll-container.js.map +0 -1
  216. package/lib/components/select.d.ts.map +0 -1
  217. package/lib/components/select.js.map +0 -1
  218. package/lib/components/selected-tags.d.ts.map +0 -1
  219. package/lib/components/selected-tags.js.map +0 -1
  220. package/lib/components/step.d.ts.map +0 -1
  221. package/lib/components/step.js.map +0 -1
  222. package/lib/components/switch.d.ts.map +0 -1
  223. package/lib/components/switch.js.map +0 -1
  224. package/lib/components/tab.d.ts.map +0 -1
  225. package/lib/components/tab.js.map +0 -1
  226. package/lib/components/tabs.d.ts.map +0 -1
  227. package/lib/components/tabs.js.map +0 -1
  228. package/lib/components/tag.d.ts.map +0 -1
  229. package/lib/components/tag.js.map +0 -1
  230. package/lib/components/textarea.d.ts.map +0 -1
  231. package/lib/components/textarea.js.map +0 -1
  232. package/lib/components/tooltip.d.ts.map +0 -1
  233. package/lib/components/tooltip.js.map +0 -1
  234. package/lib/components/wizard.d.ts.map +0 -1
  235. package/lib/components/wizard.js.map +0 -1
  236. package/lib/icons/fontawesome/brands.d.ts.map +0 -1
  237. package/lib/icons/fontawesome/brands.js.map +0 -1
  238. package/lib/icons/fontawesome/regular.d.ts.map +0 -1
  239. package/lib/icons/fontawesome/regular.js.map +0 -1
  240. package/lib/icons/fontawesome/solid.d.ts.map +0 -1
  241. package/lib/icons/fontawesome/solid.js.map +0 -1
  242. package/lib/icons/heroicons/micro.d.ts.map +0 -1
  243. package/lib/icons/heroicons/micro.js.map +0 -1
  244. package/lib/icons/heroicons/mini.d.ts.map +0 -1
  245. package/lib/icons/heroicons/mini.js.map +0 -1
  246. package/lib/icons/heroicons/outline.d.ts.map +0 -1
  247. package/lib/icons/heroicons/outline.js.map +0 -1
  248. package/lib/icons/heroicons/solid.d.ts.map +0 -1
  249. package/lib/icons/heroicons/solid.js.map +0 -1
  250. package/lib/icons/lucide.d.ts.map +0 -1
  251. package/lib/icons/lucide.js.map +0 -1
  252. package/lib/icons/material/filled.d.ts.map +0 -1
  253. package/lib/icons/material/filled.js.map +0 -1
  254. package/lib/icons/material/outlined.d.ts.map +0 -1
  255. package/lib/icons/material/outlined.js.map +0 -1
  256. package/lib/icons/material/round.d.ts.map +0 -1
  257. package/lib/icons/material/round.js.map +0 -1
  258. package/lib/icons/material/sharp.d.ts.map +0 -1
  259. package/lib/icons/material/sharp.js.map +0 -1
  260. package/lib/icons/material/two-tone.d.ts.map +0 -1
  261. package/lib/icons/material/two-tone.js.map +0 -1
  262. package/lib/index.d.ts.map +0 -1
  263. package/lib/index.js.map +0 -1
  264. package/lib/styles/button.d.ts.map +0 -1
  265. package/lib/styles/button.js.map +0 -1
  266. package/lib/styles/calendar-month.d.ts.map +0 -1
  267. package/lib/styles/calendar-month.js.map +0 -1
  268. package/lib/styles/calendar-navigation.d.ts.map +0 -1
  269. package/lib/styles/calendar-navigation.js.map +0 -1
  270. package/lib/styles/calendar.d.ts.map +0 -1
  271. package/lib/styles/calendar.js.map +0 -1
  272. package/lib/styles/checkbox.d.ts.map +0 -1
  273. package/lib/styles/checkbox.js.map +0 -1
  274. package/lib/styles/copy.d.ts.map +0 -1
  275. package/lib/styles/copy.js.map +0 -1
  276. package/lib/styles/custom-scrollbar.d.ts.map +0 -1
  277. package/lib/styles/custom-scrollbar.js.map +0 -1
  278. package/lib/styles/date-picker.d.ts.map +0 -1
  279. package/lib/styles/date-picker.js.map +0 -1
  280. package/lib/styles/file-upload.d.ts.map +0 -1
  281. package/lib/styles/file-upload.js.map +0 -1
  282. package/lib/styles/icon.d.ts.map +0 -1
  283. package/lib/styles/icon.js.map +0 -1
  284. package/lib/styles/input.d.ts.map +0 -1
  285. package/lib/styles/input.js.map +0 -1
  286. package/lib/styles/modal.d.ts.map +0 -1
  287. package/lib/styles/modal.js.map +0 -1
  288. package/lib/styles/multiselect.d.ts +0 -6
  289. package/lib/styles/multiselect.d.ts.map +0 -1
  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.d.ts.map +0 -1
  302. package/lib/styles/select.js.map +0 -1
  303. package/lib/styles/step.d.ts.map +0 -1
  304. package/lib/styles/step.js.map +0 -1
  305. package/lib/styles/switch.d.ts.map +0 -1
  306. package/lib/styles/switch.js.map +0 -1
  307. package/lib/styles/tab.d.ts.map +0 -1
  308. package/lib/styles/tab.js.map +0 -1
  309. package/lib/styles/tabs.d.ts.map +0 -1
  310. package/lib/styles/tabs.js.map +0 -1
  311. package/lib/styles/tag.d.ts.map +0 -1
  312. package/lib/styles/tag.js.map +0 -1
  313. package/lib/styles/textarea.d.ts.map +0 -1
  314. package/lib/styles/textarea.js.map +0 -1
  315. package/lib/styles/tooltip.d.ts.map +0 -1
  316. package/lib/styles/tooltip.js.map +0 -1
  317. package/lib/styles/wizard.d.ts.map +0 -1
  318. package/lib/styles/wizard.js.map +0 -1
  319. package/lib/types/common.d.ts.map +0 -1
  320. package/lib/types/common.js.map +0 -1
  321. package/lib/utils/calendar-utils.d.ts.map +0 -1
  322. package/lib/utils/calendar-utils.js.map +0 -1
  323. package/lib/utils/custom-scrollbar.d.ts.map +0 -1
  324. package/lib/utils/custom-scrollbar.js.map +0 -1
  325. package/lib/utils/flavor-sheet.d.ts.map +0 -1
  326. package/lib/utils/flavor-sheet.js.map +0 -1
  327. package/lib/utils/icon-registry.d.ts.map +0 -1
  328. package/lib/utils/icon-registry.js.map +0 -1
  329. package/lib/utils/loader-registry.d.ts.map +0 -1
  330. package/lib/utils/loader-registry.js.map +0 -1
  331. package/lib/utils/locale.d.ts.map +0 -1
  332. package/lib/utils/locale.js.map +0 -1
  333. package/lib/utils/mobile.d.ts.map +0 -1
  334. package/lib/utils/mobile.js.map +0 -1
  335. package/lib/utils/number-format.d.ts.map +0 -1
  336. package/lib/utils/number-format.js.map +0 -1
  337. package/lib/utils/parse-boolean.d.ts +0 -39
  338. package/lib/utils/parse-boolean.d.ts.map +0 -1
  339. package/lib/utils/parse-boolean.js +0 -58
  340. package/lib/utils/parse-boolean.js.map +0 -1
  341. package/lib/utils/positioning.d.ts.map +0 -1
  342. package/lib/utils/positioning.js.map +0 -1
  343. package/lib/utils/property-capture.d.ts.map +0 -1
  344. package/lib/utils/property-capture.js.map +0 -1
  345. package/lib/utils/property-manager.d.ts.map +0 -1
  346. package/lib/utils/property-manager.js.map +0 -1
  347. package/lib/utils/resize-observer.d.ts.map +0 -1
  348. package/lib/utils/resize-observer.js.map +0 -1
  349. package/lib/utils/scroll-lock.d.ts.map +0 -1
  350. package/lib/utils/scroll-lock.js.map +0 -1
  351. package/lib/utils/styles.d.ts.map +0 -1
  352. package/lib/utils/styles.js.map +0 -1
  353. package/lib/version.d.ts.map +0 -1
  354. package/lib/version.js.map +0 -1
@@ -1,56 +1,11 @@
1
- /**
2
- * TyCalendarMonth Web Component
3
- * PORTED FROM: cljs/ty/components/calendar_month.cljs
4
- *
5
- * A stateless, property-driven calendar month renderer with customizable
6
- * day content and styling.
7
- *
8
- * Features:
9
- * - 42-day grid (6 weeks × 7 days) with Monday-first ordering
10
- * - Localized weekday headers
11
- * - Custom day content rendering via dayContentFn
12
- * - Custom day classes via dayClassesFn
13
- * - Custom CSS injection via customCSS
14
- * - Responsive width system (width, minWidth, maxWidth)
15
- * - Rich day-click events with full context
16
- *
17
- * @example
18
- * ```html
19
- * <!-- Basic usage -->
20
- * <ty-calendar-month
21
- * display-year="2025"
22
- * display-month="10"
23
- * locale="en-US">
24
- * </ty-calendar-month>
25
- *
26
- * <!-- With custom rendering -->
27
- * <ty-calendar-month id="custom"></ty-calendar-month>
28
- * <script type="module">
29
- * const cal = document.getElementById('custom');
30
- * cal.dayContentFn = (ctx) => {
31
- * const el = document.createElement('div');
32
- * el.textContent = ctx.dayInMonth;
33
- * return el;
34
- * };
35
- * </script>
36
- * ```
37
- */
38
1
  import { ensureStyles } from '../utils/styles.js';
39
- import { calendarMonthStyles } from '../styles/calendar-month.js';
2
+ import { syncCustomFlavorSheet } from '../utils/flavor-sheet.js';
3
+ import { calendarMonthStyles, calendarMonthCustomFlavorCss } from '../styles/calendar-month.js';
40
4
  import { getCalendarMonthDays, getLocalizedWeekdays, parseISODate } from '../utils/calendar-utils.js';
41
5
  import { getEffectiveLocale, observeLocaleChanges } from '../utils/locale.js';
42
- // ============================================================================
43
- // Default Render Functions
44
- // ============================================================================
45
- /**
46
- * Default day content renderer - just the day number
47
- */
48
6
  function defaultDayContent(dayContext) {
49
7
  return dayContext.dayInMonth.toString();
50
8
  }
51
- /**
52
- * Default day classes based on day context
53
- */
54
9
  function getDefaultDayClasses(dayContext) {
55
10
  const classes = ['calendar-day'];
56
11
  if (dayContext.today)
@@ -63,19 +18,9 @@ function getDefaultDayClasses(dayContext) {
63
18
  classes.push('selected');
64
19
  return classes;
65
20
  }
66
- // ============================================================================
67
- // Helper Functions
68
- // ============================================================================
69
- /**
70
- * Check if value is a DOM element
71
- */
72
21
  function isDOMElement(value) {
73
22
  return value instanceof HTMLElement;
74
23
  }
75
- /**
76
- * ISO date string ("YYYY-MM-DD") → UTC-midnight timestamp, matching
77
- * DayContext.value semantics. null when unset/invalid.
78
- */
79
24
  function isoToUTCTimestamp(iso) {
80
25
  if (!iso)
81
26
  return null;
@@ -84,49 +29,32 @@ function isoToUTCTimestamp(iso) {
84
29
  return null;
85
30
  return Date.UTC(parsed.year, parsed.month - 1, parsed.day);
86
31
  }
87
- /**
88
- * Normalize size value - add 'px' if just a number
89
- */
90
32
  function normalizeSizeValue(value) {
91
33
  if (!value || value === '')
92
34
  return null;
93
35
  const strValue = String(value);
94
- // If it's just a number, add 'px'
95
36
  if (/^\d+(\.\d+)?$/.test(strValue)) {
96
37
  return `${strValue}px`;
97
38
  }
98
- // Otherwise use as-is (supports %, rem, vw, etc.)
99
39
  return strValue;
100
40
  }
101
- // ============================================================================
102
- // Component Implementation
103
- // ============================================================================
104
- /**
105
- * TyCalendarMonth Web Component
106
- */
107
41
  export class TyCalendarMonth extends HTMLElement {
108
- /**
109
- * Observed attributes (minimal - mainly for debugging)
110
- * Properties are the primary API
111
- */
112
42
  static get observedAttributes() {
113
- return ['locale', 'size', 'min', 'max'];
43
+ return ['locale', 'size', 'min', 'max', 'flavor'];
114
44
  }
115
45
  constructor() {
116
46
  super();
117
47
  this._locale = 'en-US';
118
48
  this._size = 'md';
119
- // Initialize with current date
49
+ this._customFlavorSheet = null;
50
+ this._focusedIndex = null;
51
+ this._cellElements = [];
120
52
  const today = new Date();
121
53
  this._displayYear = today.getFullYear();
122
- this._displayMonth = today.getMonth() + 1; // 1-based month
54
+ this._displayMonth = today.getMonth() + 1;
123
55
  this.attachShadow({ mode: 'open' });
124
56
  }
125
- // ==========================================================================
126
- // Lifecycle Methods
127
- // ==========================================================================
128
57
  connectedCallback() {
129
- // Set defaults if not already set
130
58
  if (!this._displayMonth) {
131
59
  this._displayMonth = new Date().getMonth() + 1;
132
60
  }
@@ -136,31 +64,27 @@ export class TyCalendarMonth extends HTMLElement {
136
64
  if (!this._locale) {
137
65
  this._locale = this.getAttribute('locale') || 'en-US';
138
66
  }
139
- // Read size attribute if present
140
67
  const sizeAttr = this.getAttribute('size');
141
68
  if (sizeAttr && (sizeAttr === 'sm' || sizeAttr === 'md' || sizeAttr === 'lg')) {
142
69
  this._size = sizeAttr;
143
70
  }
144
- // Check for dayContentFn set before upgrade
145
71
  const plainDayContentFn = this.dayContentFn;
146
72
  if (plainDayContentFn && !this._dayContentFn) {
147
73
  this._dayContentFn = plainDayContentFn;
148
- delete this.dayContentFn; // Clean up plain property
74
+ delete this.dayContentFn;
149
75
  }
150
- // Check for customCSS set before upgrade
151
76
  const plainCustomCSS = this.customCSS;
152
77
  if (plainCustomCSS && !this._customCSS) {
153
78
  this._customCSS = plainCustomCSS;
154
- delete this.customCSS; // Clean up plain property
79
+ delete this.customCSS;
155
80
  }
156
- // Setup locale observer to watch for ancestor lang changes
157
81
  this._localeObserver = observeLocaleChanges(this, () => {
158
82
  this.render();
159
83
  });
84
+ this._syncCustomFlavor();
160
85
  this.render();
161
86
  }
162
87
  disconnectedCallback() {
163
- // Cleanup locale observer
164
88
  if (this._localeObserver) {
165
89
  this._localeObserver();
166
90
  this._localeObserver = undefined;
@@ -181,16 +105,20 @@ export class TyCalendarMonth extends HTMLElement {
181
105
  this[name === 'min' ? '_min' : '_max'] = newValue ?? undefined;
182
106
  this.render();
183
107
  }
108
+ else if (name === 'flavor') {
109
+ this._syncCustomFlavor();
110
+ }
111
+ }
112
+ _syncCustomFlavor() {
113
+ this._customFlavorSheet = syncCustomFlavorSheet(this.shadowRoot, this._customFlavorSheet, this.getAttribute('flavor'), ({ base }) => calendarMonthCustomFlavorCss(base));
184
114
  }
185
- // ==========================================================================
186
- // Property Getters/Setters
187
- // ==========================================================================
188
115
  get displayYear() {
189
116
  return this._displayYear;
190
117
  }
191
118
  set displayYear(value) {
192
119
  if (this._displayYear !== value) {
193
120
  this._displayYear = value;
121
+ this._focusedIndex = null;
194
122
  this.render();
195
123
  }
196
124
  }
@@ -200,6 +128,7 @@ export class TyCalendarMonth extends HTMLElement {
200
128
  set displayMonth(value) {
201
129
  if (this._displayMonth !== value) {
202
130
  this._displayMonth = value;
131
+ this._focusedIndex = null;
203
132
  this.render();
204
133
  }
205
134
  }
@@ -221,6 +150,15 @@ export class TyCalendarMonth extends HTMLElement {
221
150
  this.render();
222
151
  }
223
152
  }
153
+ get flavor() {
154
+ return this.getAttribute('flavor') || 'primary';
155
+ }
156
+ set flavor(value) {
157
+ if (value)
158
+ this.setAttribute('flavor', value);
159
+ else
160
+ this.removeAttribute('flavor');
161
+ }
224
162
  get width() {
225
163
  return this._width;
226
164
  }
@@ -294,12 +232,6 @@ export class TyCalendarMonth extends HTMLElement {
294
232
  this.render();
295
233
  }
296
234
  }
297
- // ==========================================================================
298
- // Width Property System
299
- // ==========================================================================
300
- /**
301
- * Apply width-related properties as CSS custom properties
302
- */
303
235
  applyWidthProperties() {
304
236
  const normalizedWidth = normalizeSizeValue(this._width);
305
237
  const normalizedMinWidth = normalizeSizeValue(this._minWidth);
@@ -323,9 +255,6 @@ export class TyCalendarMonth extends HTMLElement {
323
255
  this.style.removeProperty('--calendar-max-width');
324
256
  }
325
257
  }
326
- /**
327
- * Apply custom CSS to shadow root
328
- */
329
258
  applyCustomCSS() {
330
259
  if (!this._customCSS || !this.shadowRoot)
331
260
  return;
@@ -334,23 +263,10 @@ export class TyCalendarMonth extends HTMLElement {
334
263
  this.shadowRoot.adoptedStyleSheets = [...existing, this._customCSS];
335
264
  }
336
265
  }
337
- // ==========================================================================
338
- // Public Methods
339
- // ==========================================================================
340
- /**
341
- * Force re-render of the calendar month
342
- * Useful when external data changes (e.g., async event loading)
343
- */
344
266
  refresh() {
345
267
  this.render();
346
268
  }
347
- // ==========================================================================
348
- // Event Dispatching
349
- // ==========================================================================
350
- /**
351
- * Dispatch day-click custom event with day context
352
- */
353
- dispatchDayClick(dayContext, domEvent) {
269
+ dispatchDayClick(dayContext, _domEvent) {
354
270
  const detail = {
355
271
  dayContext,
356
272
  value: dayContext.value,
@@ -362,7 +278,6 @@ export class TyCalendarMonth extends HTMLElement {
362
278
  isWeekend: dayContext.weekend,
363
279
  isOtherMonth: dayContext.otherMonth,
364
280
  };
365
- // Dispatch both 'day-click' and 'day-select' (alias)
366
281
  for (const eventType of ['day-click', 'day-select']) {
367
282
  const event = new CustomEvent(eventType, {
368
283
  detail,
@@ -372,112 +287,149 @@ export class TyCalendarMonth extends HTMLElement {
372
287
  this.dispatchEvent(event);
373
288
  }
374
289
  }
375
- // ==========================================================================
376
- // Rendering
377
- // ==========================================================================
378
- /**
379
- * Render a single day cell
380
- */
381
- renderDayCell(dayContext, disabled) {
290
+ renderDayCell(dayContext, disabled, isRoving) {
382
291
  const dayElement = document.createElement('div');
383
- // Get content using custom or default function
384
292
  const content = this._dayContentFn
385
293
  ? this._dayContentFn(dayContext)
386
294
  : defaultDayContent(dayContext);
387
- // STRICT DOM-ONLY CHECK for custom functions
388
295
  if (this._dayContentFn && content && !isDOMElement(content) && typeof content !== 'string') {
389
296
  throw new Error(`Custom dayContentFn must return a DOM element or string, got: ${typeof content}. ` +
390
297
  `Use document.createElement() to create DOM elements.`);
391
298
  }
392
- // Apply default classes
393
299
  const classes = getDefaultDayClasses(dayContext);
394
300
  if (disabled)
395
301
  classes.push('disabled');
396
302
  dayElement.className = classes.join(' ');
397
- // Set content
398
303
  if (typeof content === 'string') {
399
304
  dayElement.textContent = content;
400
305
  }
401
306
  else if (isDOMElement(content)) {
402
307
  dayElement.appendChild(content);
403
308
  }
404
- // Add click handler (disabled days don't emit)
405
- if (!disabled) {
309
+ dayElement.setAttribute('role', 'gridcell');
310
+ dayElement.setAttribute('aria-label', new Intl.DateTimeFormat(this._locale, { weekday: 'long', year: 'numeric', month: 'long', day: 'numeric' })
311
+ .format(new Date(dayContext.localValue)));
312
+ dayElement.setAttribute('aria-selected', String(!!dayContext.isSelected));
313
+ if (dayContext.today)
314
+ dayElement.setAttribute('aria-current', 'date');
315
+ if (disabled) {
316
+ dayElement.setAttribute('aria-disabled', 'true');
317
+ dayElement.setAttribute('tabindex', '-1');
318
+ }
319
+ else {
320
+ dayElement.setAttribute('tabindex', isRoving ? '0' : '-1');
406
321
  dayElement.addEventListener('pointerdown', (event) => {
407
322
  event.preventDefault();
408
323
  this.dispatchDayClick(dayContext, event);
409
324
  });
325
+ dayElement.addEventListener('keydown', (event) => {
326
+ const ke = event;
327
+ if (ke.key === 'Enter' || ke.key === ' ') {
328
+ ke.preventDefault();
329
+ this.dispatchDayClick(dayContext, event);
330
+ }
331
+ });
410
332
  }
411
333
  return dayElement;
412
334
  }
413
- /**
414
- * Main render function - property-based approach
415
- */
416
335
  render() {
417
336
  const root = this.shadowRoot;
418
337
  if (!root)
419
338
  return;
420
- // Ensure styles are loaded
421
339
  ensureStyles(root, { css: calendarMonthStyles, id: 'ty-calendar-month' });
422
- // Apply custom CSS if provided
423
340
  this.applyCustomCSS();
424
- // Apply width properties
425
341
  this.applyWidthProperties();
426
- // Convert timestamp to selection info
427
342
  let selection;
428
343
  if (this._value) {
429
344
  const date = new Date(this._value);
430
345
  selection = {
431
346
  year: date.getFullYear(),
432
- month: date.getMonth() + 1, // Convert to 1-based
347
+ month: date.getMonth() + 1,
433
348
  day: date.getDate()
434
349
  };
435
350
  }
436
- // Generate calendar days with selection info
437
351
  const days = getCalendarMonthDays(this._displayYear, this._displayMonth, selection);
438
- // Get localized weekday names
439
352
  const weekdays = getLocalizedWeekdays(this._locale, 'short');
440
- // Clear and rebuild
441
353
  root.innerHTML = '';
442
- // Create unified flex container
443
354
  const calendarContainer = document.createElement('div');
444
355
  calendarContainer.className = `calendar-flex-container calendar-size-${this._size}`;
445
- // Create header row with weekday names
356
+ calendarContainer.setAttribute('role', 'grid');
357
+ calendarContainer.setAttribute('aria-label', new Intl.DateTimeFormat(this._locale, { month: 'long', year: 'numeric' })
358
+ .format(new Date(this._displayYear, this._displayMonth - 1, 1)));
446
359
  const headerRow = document.createElement('div');
447
360
  headerRow.className = 'calendar-row calendar-header-row';
361
+ headerRow.setAttribute('role', 'row');
448
362
  weekdays.forEach(weekday => {
449
363
  const headerCell = document.createElement('div');
450
364
  headerCell.className = 'calendar-cell calendar-header-cell';
365
+ headerCell.setAttribute('role', 'columnheader');
451
366
  headerCell.textContent = weekday;
452
367
  headerRow.appendChild(headerCell);
453
368
  });
454
369
  calendarContainer.appendChild(headerRow);
455
- // Create day rows (6 weeks of 7 days each)
456
370
  const dayWeeks = [];
457
371
  for (let i = 0; i < 42; i += 7) {
458
372
  dayWeeks.push(days.slice(i, i + 7));
459
373
  }
460
- // Bounds for disabling days (UTC-midnight, same space as DayContext.value)
461
374
  const minTs = isoToUTCTimestamp(this._min);
462
375
  const maxTs = isoToUTCTimestamp(this._max);
376
+ const disabledAt = (i) => {
377
+ const v = days[i].value;
378
+ return (minTs !== null && v < minTs) || (maxTs !== null && v > maxTs);
379
+ };
380
+ let defaultIndex = days.findIndex(d => d.isSelected);
381
+ if (defaultIndex === -1)
382
+ defaultIndex = days.findIndex(d => d.today);
383
+ if (defaultIndex === -1)
384
+ defaultIndex = 0;
385
+ if (this._focusedIndex === null ||
386
+ this._focusedIndex < 0 ||
387
+ this._focusedIndex > 41 ||
388
+ disabledAt(this._focusedIndex)) {
389
+ this._focusedIndex = defaultIndex;
390
+ }
391
+ this._cellElements = [];
392
+ let flatIndex = 0;
463
393
  dayWeeks.forEach(week => {
464
394
  const dayRow = document.createElement('div');
465
395
  dayRow.className = 'calendar-row calendar-day-row';
396
+ dayRow.setAttribute('role', 'row');
466
397
  week.forEach(dayContext => {
467
398
  const disabled = (minTs !== null && dayContext.value < minTs) ||
468
399
  (maxTs !== null && dayContext.value > maxTs);
469
- const dayCell = this.renderDayCell(dayContext, disabled);
470
- // Add unified cell classes for flex layout
400
+ const dayCell = this.renderDayCell(dayContext, disabled, flatIndex === this._focusedIndex);
471
401
  dayCell.className = `${dayCell.className} calendar-cell calendar-day-cell`;
472
402
  dayRow.appendChild(dayCell);
403
+ this._cellElements[flatIndex] = dayCell;
404
+ flatIndex++;
473
405
  });
474
406
  calendarContainer.appendChild(dayRow);
475
407
  });
408
+ calendarContainer.addEventListener('keydown', (event) => {
409
+ const ke = event;
410
+ const delta = ke.key === 'ArrowLeft' ? -1 :
411
+ ke.key === 'ArrowRight' ? 1 :
412
+ ke.key === 'ArrowUp' ? -7 :
413
+ ke.key === 'ArrowDown' ? 7 :
414
+ 0;
415
+ if (delta === 0)
416
+ return;
417
+ const currentIndex = this._focusedIndex ?? defaultIndex;
418
+ const nextIndex = currentIndex + delta;
419
+ if (nextIndex < 0 || nextIndex > 41 || disabledAt(nextIndex))
420
+ return;
421
+ ke.preventDefault();
422
+ this._cellElements[currentIndex]?.setAttribute('tabindex', '-1');
423
+ this._focusedIndex = nextIndex;
424
+ const nextCell = this._cellElements[nextIndex];
425
+ if (nextCell) {
426
+ nextCell.setAttribute('tabindex', '0');
427
+ nextCell.focus();
428
+ }
429
+ });
476
430
  root.appendChild(calendarContainer);
477
431
  }
478
432
  }
479
- // Register the custom element
480
433
  if (!customElements.get('ty-calendar-month')) {
481
434
  customElements.define('ty-calendar-month', TyCalendarMonth);
482
435
  }
483
- //# sourceMappingURL=calendar-month.js.map
@@ -1,36 +1,7 @@
1
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
- * ```
2
+ * TyCalendarNavigation Web Component — pure presentation for calendar
3
+ * month/year navigation. Stateless: all state comes from properties,
4
+ * changes are emitted via events.
34
5
  */
35
6
  import { TyComponent } from '../base/ty-component.js';
36
7
  import type { PropertyChange } from '../utils/property-manager.js';
@@ -98,13 +69,7 @@ export declare class TyCalendarNavigation extends TyComponent<NavigationState> {
98
69
  private _state;
99
70
  private _localeObserver?;
100
71
  constructor();
101
- /**
102
- * Called when component connects to DOM
103
- */
104
72
  protected onConnect(): void;
105
- /**
106
- * Called when component disconnects from DOM
107
- */
108
73
  protected onDisconnect(): void;
109
74
  /**
110
75
  * Called when properties change
@@ -125,9 +90,6 @@ export declare class TyCalendarNavigation extends TyComponent<NavigationState> {
125
90
  set min(value: string);
126
91
  get max(): string;
127
92
  set max(value: string);
128
- /**
129
- * Emit change event with new month/year
130
- */
131
93
  private emitChangeEvent;
132
94
  /**
133
95
  * Month index (year * 12 + month - 1) — flat, comparable month math.
@@ -150,14 +112,7 @@ export declare class TyCalendarNavigation extends TyComponent<NavigationState> {
150
112
  * True when navigating by deltaMonths can't move the display (bound reached)
151
113
  */
152
114
  private isNavDisabled;
153
- /**
154
- * Create navigation button
155
- */
156
115
  private createButton;
157
- /**
158
- * Main render function
159
- */
160
116
  protected render(): void;
161
117
  }
162
118
  export {};
163
- //# sourceMappingURL=calendar-navigation.d.ts.map