tyrell-components 1.0.0-TC8 → 1.0.0-rc.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (386) hide show
  1. package/AGENTS.md +122 -0
  2. package/CHANGELOG.md +1531 -0
  3. package/README.md +71 -53
  4. package/css/tyrell-colors-static.css +1 -0
  5. package/css/tyrell-theme.css +1 -0
  6. package/css/tyrell.css +1 -1783
  7. package/dist/tyrell-colors-static.css +1 -0
  8. package/dist/tyrell-theme.css +1 -0
  9. package/dist/tyrell.css +1 -1783
  10. package/dist/tyrell.js +1 -1
  11. package/guides/AGENT_INSTRUCTIONS.md +124 -0
  12. package/guides/AI_GUIDE.md +53 -0
  13. package/guides/CSS_GUIDE.md +1016 -0
  14. package/guides/DATASTAR_TY_GUIDE.md +657 -0
  15. package/guides/ICONS_GUIDE.md +212 -0
  16. package/guides/TY_GUIDE.md +935 -0
  17. package/guides/clj/CLOJURESCRIPT_GUIDE.md +300 -0
  18. package/guides/clj/CODE_SPLITTING.md +279 -0
  19. package/guides/clj/COMPONENT_GUIDE.md +391 -0
  20. package/guides/clj/HELIX_TY_GUIDE.md +428 -0
  21. package/guides/clj/I18N_GUIDE.md +478 -0
  22. package/guides/clj/LAYOUT_GUIDE.md +273 -0
  23. package/guides/clj/QUICKSTART.md +266 -0
  24. package/guides/clj/REAGENT_TY_GUIDE.md +408 -0
  25. package/guides/clj/REPLICANT_TY_GUIDE.md +623 -0
  26. package/guides/clj/ROUTING_GUIDE.md +346 -0
  27. package/guides/clj/UIX_TY_GUIDE.md +319 -0
  28. package/guides/js/HTMX_TY_GUIDE.md +252 -0
  29. package/guides/js/JAVASCRIPT_GUIDE.md +388 -0
  30. package/guides/js/REACT_TY_GUIDE.md +983 -0
  31. package/guides/js/SVELTE_TY_GUIDE.md +682 -0
  32. package/guides/js/TYCOMPONENT_GUIDE.md +962 -0
  33. package/guides/js/VUE_TY_GUIDE.md +738 -0
  34. package/lib/base/ty-component.d.ts +57 -13
  35. package/lib/base/ty-component.js +266 -292
  36. package/lib/components/button.d.ts +42 -18
  37. package/lib/components/button.js +318 -235
  38. package/lib/components/calendar-month.d.ts +30 -47
  39. package/lib/components/calendar-month.js +455 -429
  40. package/lib/components/calendar-navigation.d.ts +41 -49
  41. package/lib/components/calendar-navigation.js +287 -346
  42. package/lib/components/calendar.d.ts +73 -83
  43. package/lib/components/calendar.js +837 -762
  44. package/lib/components/checkbox.d.ts +26 -75
  45. package/lib/components/checkbox.js +298 -391
  46. package/lib/components/copy.d.ts +20 -60
  47. package/lib/components/copy.js +276 -380
  48. package/lib/components/date-picker.d.ts +100 -183
  49. package/lib/components/date-picker.js +1155 -1570
  50. package/lib/components/file-upload.d.ts +122 -0
  51. package/lib/components/file-upload.js +451 -0
  52. package/lib/components/icon.d.ts +3 -24
  53. package/lib/components/icon.js +141 -230
  54. package/lib/components/input.d.ts +93 -108
  55. package/lib/components/input.js +734 -710
  56. package/lib/components/modal.d.ts +39 -29
  57. package/lib/components/modal.js +419 -438
  58. package/lib/components/option.d.ts +20 -35
  59. package/lib/components/option.js +184 -309
  60. package/lib/components/popup.d.ts +2 -17
  61. package/lib/components/popup.js +353 -347
  62. package/lib/components/radio.d.ts +33 -25
  63. package/lib/components/radio.js +433 -422
  64. package/lib/components/resize-observer.d.ts +3 -30
  65. package/lib/components/resize-observer.js +71 -103
  66. package/lib/components/scroll-container.d.ts +21 -14
  67. package/lib/components/scroll-container.js +292 -234
  68. package/lib/components/select.d.ts +446 -0
  69. package/lib/components/select.js +1381 -0
  70. package/lib/components/selected-tags.d.ts +60 -0
  71. package/lib/components/selected-tags.js +225 -0
  72. package/lib/components/sortable.d.ts +175 -0
  73. package/lib/components/sortable.js +1844 -0
  74. package/lib/components/step.d.ts +1 -6
  75. package/lib/components/step.js +62 -68
  76. package/lib/components/switch.d.ts +15 -15
  77. package/lib/components/switch.js +237 -231
  78. package/lib/components/tab.d.ts +50 -7
  79. package/lib/components/tab.js +203 -69
  80. package/lib/components/tabs.d.ts +19 -64
  81. package/lib/components/tabs.js +600 -618
  82. package/lib/components/tag.d.ts +17 -55
  83. package/lib/components/tag.js +235 -308
  84. package/lib/components/textarea.d.ts +58 -89
  85. package/lib/components/textarea.js +523 -573
  86. package/lib/components/tooltip.d.ts +8 -13
  87. package/lib/components/tooltip.js +322 -409
  88. package/lib/components/wizard.d.ts +7 -54
  89. package/lib/components/wizard.js +376 -606
  90. package/lib/icons/fontawesome/brands.d.ts +0 -1
  91. package/lib/icons/fontawesome/brands.js +0 -8
  92. package/lib/icons/fontawesome/regular.d.ts +0 -1
  93. package/lib/icons/fontawesome/regular.js +0 -8
  94. package/lib/icons/fontawesome/solid.d.ts +0 -1
  95. package/lib/icons/fontawesome/solid.js +0 -8
  96. package/lib/icons/heroicons/micro.d.ts +0 -1
  97. package/lib/icons/heroicons/micro.js +392 -400
  98. package/lib/icons/heroicons/mini.d.ts +0 -1
  99. package/lib/icons/heroicons/mini.js +382 -390
  100. package/lib/icons/heroicons/outline.d.ts +0 -1
  101. package/lib/icons/heroicons/outline.js +337 -345
  102. package/lib/icons/heroicons/solid.d.ts +0 -1
  103. package/lib/icons/heroicons/solid.js +407 -415
  104. package/lib/icons/lucide.d.ts +0 -1
  105. package/lib/icons/lucide.js +24479 -26351
  106. package/lib/icons/material/filled.d.ts +0 -1
  107. package/lib/icons/material/filled.js +9653 -9663
  108. package/lib/icons/material/outlined.d.ts +0 -1
  109. package/lib/icons/material/outlined.js +10271 -10281
  110. package/lib/icons/material/round.d.ts +0 -1
  111. package/lib/icons/material/round.js +10495 -10505
  112. package/lib/icons/material/sharp.d.ts +0 -1
  113. package/lib/icons/material/sharp.js +9905 -9915
  114. package/lib/icons/material/two-tone.d.ts +0 -1
  115. package/lib/icons/material/two-tone.js +12792 -12802
  116. package/lib/index.d.ts +15 -4
  117. package/lib/index.js +28 -38
  118. package/lib/styles/button.d.ts +24 -7
  119. package/lib/styles/button.js +298 -417
  120. package/lib/styles/calendar-month.d.ts +7 -6
  121. package/lib/styles/calendar-month.js +157 -179
  122. package/lib/styles/calendar-navigation.d.ts +2 -6
  123. package/lib/styles/calendar-navigation.js +108 -109
  124. package/lib/styles/calendar.d.ts +3 -3
  125. package/lib/styles/calendar.js +87 -23
  126. package/lib/styles/checkbox.d.ts +7 -6
  127. package/lib/styles/checkbox.js +101 -15
  128. package/lib/styles/copy.d.ts +3 -2
  129. package/lib/styles/copy.js +91 -71
  130. package/lib/styles/custom-scrollbar.d.ts +1 -2
  131. package/lib/styles/custom-scrollbar.js +80 -115
  132. package/lib/styles/date-picker.d.ts +4 -6
  133. package/lib/styles/date-picker.js +320 -352
  134. package/lib/styles/field-size.d.ts +6 -0
  135. package/lib/styles/field-size.js +91 -0
  136. package/lib/styles/file-upload.d.ts +1 -0
  137. package/lib/styles/file-upload.js +196 -0
  138. package/lib/styles/icon.d.ts +2 -6
  139. package/lib/styles/icon.js +92 -170
  140. package/lib/styles/input.d.ts +4 -7
  141. package/lib/styles/input.js +148 -643
  142. package/lib/styles/modal.d.ts +1 -2
  143. package/lib/styles/modal.js +127 -108
  144. package/lib/styles/option.d.ts +2 -6
  145. package/lib/styles/option.js +53 -96
  146. package/lib/styles/popup.d.ts +1 -2
  147. package/lib/styles/popup.js +47 -77
  148. package/lib/styles/radio.d.ts +3 -2
  149. package/lib/styles/radio.js +90 -116
  150. package/lib/styles/resize-observer.d.ts +1 -2
  151. package/lib/styles/resize-observer.js +2 -12
  152. package/lib/styles/scroll-container.d.ts +1 -2
  153. package/lib/styles/scroll-container.js +103 -146
  154. package/lib/styles/select-base.d.ts +8 -0
  155. package/lib/styles/select-base.js +747 -0
  156. package/lib/styles/select.d.ts +11 -0
  157. package/lib/styles/select.js +229 -0
  158. package/lib/styles/sortable.d.ts +16 -0
  159. package/lib/styles/sortable.js +85 -0
  160. package/lib/styles/step.d.ts +1 -2
  161. package/lib/styles/step.js +15 -34
  162. package/lib/styles/switch.d.ts +3 -2
  163. package/lib/styles/switch.js +52 -68
  164. package/lib/styles/tab.d.ts +1 -2
  165. package/lib/styles/tab.js +86 -34
  166. package/lib/styles/tabs.d.ts +3 -11
  167. package/lib/styles/tabs.js +204 -162
  168. package/lib/styles/tag.d.ts +2 -6
  169. package/lib/styles/tag.js +170 -359
  170. package/lib/styles/textarea.d.ts +1 -2
  171. package/lib/styles/textarea.js +238 -306
  172. package/lib/styles/tooltip.d.ts +4 -3
  173. package/lib/styles/tooltip.js +3 -131
  174. package/lib/styles/wizard.d.ts +8 -20
  175. package/lib/styles/wizard.js +306 -295
  176. package/lib/types/common.d.ts +9 -8
  177. package/lib/types/common.js +8 -5
  178. package/lib/utils/calendar-utils.d.ts +49 -65
  179. package/lib/utils/calendar-utils.js +158 -343
  180. package/lib/utils/custom-scrollbar.d.ts +6 -20
  181. package/lib/utils/custom-scrollbar.js +273 -317
  182. package/lib/utils/flavor-sheet.d.ts +31 -0
  183. package/lib/utils/flavor-sheet.js +17 -0
  184. package/lib/utils/icon-registry.d.ts +0 -15
  185. package/lib/utils/icon-registry.js +138 -279
  186. package/lib/utils/icons.d.ts +9 -0
  187. package/lib/utils/icons.js +1 -0
  188. package/lib/utils/loader-registry.d.ts +34 -0
  189. package/lib/utils/loader-registry.js +11 -0
  190. package/lib/utils/locale.d.ts +2 -80
  191. package/lib/utils/locale.js +30 -205
  192. package/lib/utils/mobile.d.ts +0 -1
  193. package/lib/utils/mobile.js +1 -18
  194. package/lib/utils/number-format.d.ts +6 -24
  195. package/lib/utils/number-format.js +53 -136
  196. package/lib/utils/positioning.d.ts +72 -22
  197. package/lib/utils/positioning.js +224 -298
  198. package/lib/utils/property-capture.d.ts +5 -27
  199. package/lib/utils/property-capture.js +36 -144
  200. package/lib/utils/property-manager.d.ts +6 -6
  201. package/lib/utils/property-manager.js +127 -196
  202. package/lib/utils/resize-observer.d.ts +0 -1
  203. package/lib/utils/resize-observer.js +23 -59
  204. package/lib/utils/scroll-lock.d.ts +10 -11
  205. package/lib/utils/scroll-lock.js +165 -173
  206. package/lib/utils/styles.d.ts +0 -6
  207. package/lib/utils/styles.js +17 -48
  208. package/lib/utils/upgrade-properties.d.ts +21 -0
  209. package/lib/utils/upgrade-properties.js +47 -0
  210. package/lib/utils/validity.d.ts +122 -0
  211. package/lib/utils/validity.js +289 -0
  212. package/lib/version.d.ts +1 -2
  213. package/lib/version.js +1 -11
  214. package/package.json +66 -18
  215. package/lib/base/ty-component.d.ts.map +0 -1
  216. package/lib/base/ty-component.js.map +0 -1
  217. package/lib/components/button.d.ts.map +0 -1
  218. package/lib/components/button.js.map +0 -1
  219. package/lib/components/calendar-month.d.ts.map +0 -1
  220. package/lib/components/calendar-month.js.map +0 -1
  221. package/lib/components/calendar-navigation.d.ts.map +0 -1
  222. package/lib/components/calendar-navigation.js.map +0 -1
  223. package/lib/components/calendar.d.ts.map +0 -1
  224. package/lib/components/calendar.js.map +0 -1
  225. package/lib/components/checkbox.d.ts.map +0 -1
  226. package/lib/components/checkbox.js.map +0 -1
  227. package/lib/components/copy.d.ts.map +0 -1
  228. package/lib/components/copy.js.map +0 -1
  229. package/lib/components/date-picker.d.ts.map +0 -1
  230. package/lib/components/date-picker.js.map +0 -1
  231. package/lib/components/dropdown.d.ts +0 -402
  232. package/lib/components/dropdown.d.ts.map +0 -1
  233. package/lib/components/dropdown.js +0 -1564
  234. package/lib/components/dropdown.js.map +0 -1
  235. package/lib/components/icon.d.ts.map +0 -1
  236. package/lib/components/icon.js.map +0 -1
  237. package/lib/components/input.d.ts.map +0 -1
  238. package/lib/components/input.js.map +0 -1
  239. package/lib/components/modal.d.ts.map +0 -1
  240. package/lib/components/modal.js.map +0 -1
  241. package/lib/components/multiselect.d.ts +0 -397
  242. package/lib/components/multiselect.d.ts.map +0 -1
  243. package/lib/components/multiselect.js +0 -1580
  244. package/lib/components/multiselect.js.map +0 -1
  245. package/lib/components/option.d.ts.map +0 -1
  246. package/lib/components/option.js.map +0 -1
  247. package/lib/components/popup.d.ts.map +0 -1
  248. package/lib/components/popup.js.map +0 -1
  249. package/lib/components/radio.d.ts.map +0 -1
  250. package/lib/components/radio.js.map +0 -1
  251. package/lib/components/resize-observer.d.ts.map +0 -1
  252. package/lib/components/resize-observer.js.map +0 -1
  253. package/lib/components/scroll-container.d.ts.map +0 -1
  254. package/lib/components/scroll-container.js.map +0 -1
  255. package/lib/components/step.d.ts.map +0 -1
  256. package/lib/components/step.js.map +0 -1
  257. package/lib/components/switch.d.ts.map +0 -1
  258. package/lib/components/switch.js.map +0 -1
  259. package/lib/components/tab.d.ts.map +0 -1
  260. package/lib/components/tab.js.map +0 -1
  261. package/lib/components/tabs.d.ts.map +0 -1
  262. package/lib/components/tabs.js.map +0 -1
  263. package/lib/components/tag.d.ts.map +0 -1
  264. package/lib/components/tag.js.map +0 -1
  265. package/lib/components/textarea.d.ts.map +0 -1
  266. package/lib/components/textarea.js.map +0 -1
  267. package/lib/components/tooltip.d.ts.map +0 -1
  268. package/lib/components/tooltip.js.map +0 -1
  269. package/lib/components/wizard.d.ts.map +0 -1
  270. package/lib/components/wizard.js.map +0 -1
  271. package/lib/icons/fontawesome/brands.d.ts.map +0 -1
  272. package/lib/icons/fontawesome/brands.js.map +0 -1
  273. package/lib/icons/fontawesome/regular.d.ts.map +0 -1
  274. package/lib/icons/fontawesome/regular.js.map +0 -1
  275. package/lib/icons/fontawesome/solid.d.ts.map +0 -1
  276. package/lib/icons/fontawesome/solid.js.map +0 -1
  277. package/lib/icons/heroicons/micro.d.ts.map +0 -1
  278. package/lib/icons/heroicons/micro.js.map +0 -1
  279. package/lib/icons/heroicons/mini.d.ts.map +0 -1
  280. package/lib/icons/heroicons/mini.js.map +0 -1
  281. package/lib/icons/heroicons/outline.d.ts.map +0 -1
  282. package/lib/icons/heroicons/outline.js.map +0 -1
  283. package/lib/icons/heroicons/solid.d.ts.map +0 -1
  284. package/lib/icons/heroicons/solid.js.map +0 -1
  285. package/lib/icons/lucide.d.ts.map +0 -1
  286. package/lib/icons/lucide.js.map +0 -1
  287. package/lib/icons/material/filled.d.ts.map +0 -1
  288. package/lib/icons/material/filled.js.map +0 -1
  289. package/lib/icons/material/outlined.d.ts.map +0 -1
  290. package/lib/icons/material/outlined.js.map +0 -1
  291. package/lib/icons/material/round.d.ts.map +0 -1
  292. package/lib/icons/material/round.js.map +0 -1
  293. package/lib/icons/material/sharp.d.ts.map +0 -1
  294. package/lib/icons/material/sharp.js.map +0 -1
  295. package/lib/icons/material/two-tone.d.ts.map +0 -1
  296. package/lib/icons/material/two-tone.js.map +0 -1
  297. package/lib/index.d.ts.map +0 -1
  298. package/lib/index.js.map +0 -1
  299. package/lib/styles/button.d.ts.map +0 -1
  300. package/lib/styles/button.js.map +0 -1
  301. package/lib/styles/calendar-month.d.ts.map +0 -1
  302. package/lib/styles/calendar-month.js.map +0 -1
  303. package/lib/styles/calendar-navigation.d.ts.map +0 -1
  304. package/lib/styles/calendar-navigation.js.map +0 -1
  305. package/lib/styles/calendar.d.ts.map +0 -1
  306. package/lib/styles/calendar.js.map +0 -1
  307. package/lib/styles/checkbox.d.ts.map +0 -1
  308. package/lib/styles/checkbox.js.map +0 -1
  309. package/lib/styles/copy.d.ts.map +0 -1
  310. package/lib/styles/copy.js.map +0 -1
  311. package/lib/styles/custom-scrollbar.d.ts.map +0 -1
  312. package/lib/styles/custom-scrollbar.js.map +0 -1
  313. package/lib/styles/date-picker.d.ts.map +0 -1
  314. package/lib/styles/date-picker.js.map +0 -1
  315. package/lib/styles/dropdown.d.ts +0 -12
  316. package/lib/styles/dropdown.d.ts.map +0 -1
  317. package/lib/styles/dropdown.js +0 -983
  318. package/lib/styles/dropdown.js.map +0 -1
  319. package/lib/styles/icon.d.ts.map +0 -1
  320. package/lib/styles/icon.js.map +0 -1
  321. package/lib/styles/input.d.ts.map +0 -1
  322. package/lib/styles/input.js.map +0 -1
  323. package/lib/styles/modal.d.ts.map +0 -1
  324. package/lib/styles/modal.js.map +0 -1
  325. package/lib/styles/multiselect.d.ts +0 -6
  326. package/lib/styles/multiselect.d.ts.map +0 -1
  327. package/lib/styles/multiselect.js +0 -774
  328. package/lib/styles/multiselect.js.map +0 -1
  329. package/lib/styles/option.d.ts.map +0 -1
  330. package/lib/styles/option.js.map +0 -1
  331. package/lib/styles/popup.d.ts.map +0 -1
  332. package/lib/styles/popup.js.map +0 -1
  333. package/lib/styles/radio.d.ts.map +0 -1
  334. package/lib/styles/radio.js.map +0 -1
  335. package/lib/styles/resize-observer.d.ts.map +0 -1
  336. package/lib/styles/resize-observer.js.map +0 -1
  337. package/lib/styles/scroll-container.d.ts.map +0 -1
  338. package/lib/styles/scroll-container.js.map +0 -1
  339. package/lib/styles/step.d.ts.map +0 -1
  340. package/lib/styles/step.js.map +0 -1
  341. package/lib/styles/switch.d.ts.map +0 -1
  342. package/lib/styles/switch.js.map +0 -1
  343. package/lib/styles/tab.d.ts.map +0 -1
  344. package/lib/styles/tab.js.map +0 -1
  345. package/lib/styles/tabs.d.ts.map +0 -1
  346. package/lib/styles/tabs.js.map +0 -1
  347. package/lib/styles/tag.d.ts.map +0 -1
  348. package/lib/styles/tag.js.map +0 -1
  349. package/lib/styles/textarea.d.ts.map +0 -1
  350. package/lib/styles/textarea.js.map +0 -1
  351. package/lib/styles/tooltip.d.ts.map +0 -1
  352. package/lib/styles/tooltip.js.map +0 -1
  353. package/lib/styles/wizard.d.ts.map +0 -1
  354. package/lib/styles/wizard.js.map +0 -1
  355. package/lib/types/common.d.ts.map +0 -1
  356. package/lib/types/common.js.map +0 -1
  357. package/lib/utils/calendar-utils.d.ts.map +0 -1
  358. package/lib/utils/calendar-utils.js.map +0 -1
  359. package/lib/utils/custom-scrollbar.d.ts.map +0 -1
  360. package/lib/utils/custom-scrollbar.js.map +0 -1
  361. package/lib/utils/icon-registry.d.ts.map +0 -1
  362. package/lib/utils/icon-registry.js.map +0 -1
  363. package/lib/utils/locale.d.ts.map +0 -1
  364. package/lib/utils/locale.js.map +0 -1
  365. package/lib/utils/mobile.d.ts.map +0 -1
  366. package/lib/utils/mobile.js.map +0 -1
  367. package/lib/utils/number-format.d.ts.map +0 -1
  368. package/lib/utils/number-format.js.map +0 -1
  369. package/lib/utils/parse-boolean.d.ts +0 -39
  370. package/lib/utils/parse-boolean.d.ts.map +0 -1
  371. package/lib/utils/parse-boolean.js +0 -58
  372. package/lib/utils/parse-boolean.js.map +0 -1
  373. package/lib/utils/positioning.d.ts.map +0 -1
  374. package/lib/utils/positioning.js.map +0 -1
  375. package/lib/utils/property-capture.d.ts.map +0 -1
  376. package/lib/utils/property-capture.js.map +0 -1
  377. package/lib/utils/property-manager.d.ts.map +0 -1
  378. package/lib/utils/property-manager.js.map +0 -1
  379. package/lib/utils/resize-observer.d.ts.map +0 -1
  380. package/lib/utils/resize-observer.js.map +0 -1
  381. package/lib/utils/scroll-lock.d.ts.map +0 -1
  382. package/lib/utils/scroll-lock.js.map +0 -1
  383. package/lib/utils/styles.d.ts.map +0 -1
  384. package/lib/utils/styles.js.map +0 -1
  385. package/lib/version.d.ts.map +0 -1
  386. package/lib/version.js.map +0 -1
@@ -1,239 +1,297 @@
1
- /**
2
- * TyScrollContainer Web Component
3
- *
4
- * A scroll container with shadow indicators and an optional custom-rendered scrollbar.
5
- * Uses the CustomScrollbar utility internally.
6
- *
7
- * @example Custom scrollbar
8
- * ```html
9
- * <ty-scroll-container max-height="300px" custom-scrollbar>
10
- * <div>Long content...</div>
11
- * </ty-scroll-container>
12
- * ```
13
- */
14
1
  import { ensureStyles } from '../utils/styles.js';
15
2
  import { scrollContainerStyles } from '../styles/scroll-container.js';
16
3
  import { CustomScrollbar } from '../utils/custom-scrollbar.js';
4
+ import { upgradeProperties } from '../utils/upgrade-properties.js';
17
5
  export class TyScrollContainer extends HTMLElement {
18
- static get observedAttributes() {
19
- return ['shadow', 'max-height', 'hide-scrollbar', 'custom-scrollbar', 'overflow-x'];
20
- }
21
- // ============ Property Accessors ============
22
- get shadow() {
23
- return this.getAttribute('shadow') !== 'false';
24
- }
25
- set shadow(value) {
26
- if (value)
27
- this.removeAttribute('shadow');
28
- else
29
- this.setAttribute('shadow', 'false');
30
- }
31
- get maxHeight() {
32
- return this.getAttribute('max-height');
33
- }
34
- set maxHeight(value) {
35
- if (value)
36
- this.setAttribute('max-height', value);
37
- else
38
- this.removeAttribute('max-height');
39
- this._updateMaxHeight();
40
- }
41
- get hideScrollbar() {
42
- return this.hasAttribute('hide-scrollbar');
43
- }
44
- set hideScrollbar(value) {
45
- if (value)
46
- this.setAttribute('hide-scrollbar', '');
47
- else
48
- this.removeAttribute('hide-scrollbar');
49
- }
50
- get customScrollbar() {
51
- return this.hasAttribute('custom-scrollbar');
52
- }
53
- set customScrollbar(value) {
54
- if (value)
55
- this.setAttribute('custom-scrollbar', '');
56
- else
57
- this.removeAttribute('custom-scrollbar');
58
- }
59
- get overflowX() {
60
- return this.hasAttribute('overflow-x');
61
- }
62
- set overflowX(value) {
63
- if (value)
64
- this.setAttribute('overflow-x', '');
65
- else
66
- this.removeAttribute('overflow-x');
67
- }
68
- constructor() {
69
- super();
70
- this._scrollWrapper = null;
71
- this._shadowTop = null;
72
- this._shadowBottom = null;
73
- this._shadowLeft = null;
74
- this._shadowRight = null;
75
- this._scrollbar = null;
76
- this._resizeObserver = null;
77
- this._rafId = null;
78
- // ============ Private: Scroll Handling ============
79
- this._onScroll = () => {
80
- if (this._rafId !== null)
81
- return;
82
- this._rafId = requestAnimationFrame(() => {
83
- this._rafId = null;
84
- this._updateShadowState();
85
- });
86
- };
87
- this._onSlotChange = () => {
88
- this._scrollbar?.update();
89
- this._updateShadowState();
90
- };
91
- const shadow = this.attachShadow({ mode: 'open' });
92
- ensureStyles(shadow, { css: scrollContainerStyles, id: 'ty-scroll-container' });
93
- shadow.innerHTML = `
94
- <div class="scroll-wrapper">
95
- <slot></slot>
96
- </div>
97
- <div class="shadow-overlay">
98
- <div class="shadow-top"></div>
99
- <div class="shadow-bottom"></div>
100
- <div class="shadow-left"></div>
101
- <div class="shadow-right"></div>
102
- </div>
103
- `;
104
- this._scrollWrapper = shadow.querySelector('.scroll-wrapper');
105
- this._shadowTop = shadow.querySelector('.shadow-top');
106
- this._shadowBottom = shadow.querySelector('.shadow-bottom');
107
- this._shadowLeft = shadow.querySelector('.shadow-left');
108
- this._shadowRight = shadow.querySelector('.shadow-right');
109
- }
110
- connectedCallback() {
111
- this._scrollWrapper?.addEventListener('scroll', this._onScroll, { passive: true });
112
- this._resizeObserver = new ResizeObserver(() => {
113
- this._scrollbar?.update();
114
- this._updateShadowState();
115
- });
116
- if (this._scrollWrapper) {
117
- this._resizeObserver.observe(this._scrollWrapper);
118
- const slot = this._scrollWrapper.querySelector('slot');
119
- if (slot) {
120
- slot.addEventListener('slotchange', this._onSlotChange);
121
- }
122
- }
123
- this._updateMaxHeight();
124
- this._updateShadowState();
125
- this._setupScrollbar();
126
- }
127
- disconnectedCallback() {
128
- this._scrollWrapper?.removeEventListener('scroll', this._onScroll);
129
- this._destroyScrollbar();
130
- if (this._resizeObserver) {
131
- this._resizeObserver.disconnect();
132
- this._resizeObserver = null;
133
- }
134
- if (this._rafId !== null) {
135
- cancelAnimationFrame(this._rafId);
136
- this._rafId = null;
137
- }
138
- }
139
- attributeChangedCallback(name, oldValue, newValue) {
140
- if (oldValue === newValue)
141
- return;
142
- if (name === 'max-height') {
143
- this._updateMaxHeight();
144
- this._updateShadowState();
145
- this._scrollbar?.update();
146
- }
147
- if (name === 'custom-scrollbar' || name === 'overflow-x') {
148
- this._destroyScrollbar();
149
- this._setupScrollbar();
150
- this._updateShadowState();
151
- }
152
- }
153
- // ============ Private: Scrollbar Setup ============
154
- _setupScrollbar() {
155
- if (!this._scrollWrapper || !this.customScrollbar)
156
- return;
157
- this._scrollbar = new CustomScrollbar(this._scrollWrapper, {
158
- vertical: true,
159
- horizontal: this.overflowX
160
- });
161
- // Append track elements to shadow DOM
162
- const shadowRoot = this.shadowRoot;
163
- if (this._scrollbar.trackY)
164
- shadowRoot.appendChild(this._scrollbar.trackY);
165
- if (this._scrollbar.trackX)
166
- shadowRoot.appendChild(this._scrollbar.trackX);
167
- }
168
- _destroyScrollbar() {
169
- if (this._scrollbar) {
170
- // Remove track elements from DOM
171
- this._scrollbar.trackY?.remove();
172
- this._scrollbar.trackX?.remove();
173
- this._scrollbar.destroy();
174
- this._scrollbar = null;
175
- }
176
- }
177
- // ============ Private: Max Height ============
178
- _updateMaxHeight() {
179
- if (this._scrollWrapper) {
180
- const maxHeight = this.maxHeight;
181
- if (maxHeight) {
182
- this._scrollWrapper.style.setProperty('--scroll-max-height', maxHeight);
183
- this._scrollWrapper.style.maxHeight = maxHeight;
184
- }
185
- else {
186
- this._scrollWrapper.style.removeProperty('--scroll-max-height');
187
- this._scrollWrapper.style.maxHeight = '';
188
- }
189
- }
190
- }
191
- // ============ Private: Shadow State ============
192
- _updateShadowState() {
193
- if (!this._scrollWrapper)
194
- return;
195
- const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = this._scrollWrapper;
196
- const threshold = 2;
197
- if (this._shadowTop) {
198
- this._shadowTop.classList.toggle('visible', scrollTop > threshold);
199
- }
200
- if (this._shadowBottom) {
201
- this._shadowBottom.classList.toggle('visible', scrollTop + clientHeight < scrollHeight - threshold);
202
- }
203
- if (this.overflowX) {
204
- if (this._shadowLeft) {
205
- this._shadowLeft.classList.toggle('visible', scrollLeft > threshold);
206
- }
207
- if (this._shadowRight) {
208
- this._shadowRight.classList.toggle('visible', scrollLeft + clientWidth < scrollWidth - threshold);
209
- }
210
- }
211
- }
212
- // ============ Public API ============
213
- updateShadows() {
214
- this._updateShadowState();
215
- this._scrollbar?.update();
216
- }
217
- scrollToTop(smooth = true) {
218
- this._scrollWrapper?.scrollTo({ top: 0, behavior: smooth ? 'smooth' : 'auto' });
219
- }
220
- scrollToBottom(smooth = true) {
221
- if (this._scrollWrapper) {
222
- this._scrollWrapper.scrollTo({ top: this._scrollWrapper.scrollHeight, behavior: smooth ? 'smooth' : 'auto' });
223
- }
224
- }
225
- scrollToLeft(smooth = true) {
226
- this._scrollWrapper?.scrollTo({ left: 0, behavior: smooth ? 'smooth' : 'auto' });
227
- }
228
- scrollToRight(smooth = true) {
229
- if (this._scrollWrapper) {
230
- this._scrollWrapper.scrollTo({ left: this._scrollWrapper.scrollWidth, behavior: smooth ? 'smooth' : 'auto' });
231
- }
232
- }
233
- get scrollElement() {
234
- return this._scrollWrapper;
235
- }
236
- }
237
- // Register custom element
6
+ static get observedAttributes() {
7
+ return ['no-shadow', 'max-height', 'hide-scrollbar', 'custom-scrollbar', 'overflow-x', 'scroll-anchoring'];
8
+ }
9
+ get noShadow() {
10
+ return this.hasAttribute('no-shadow');
11
+ }
12
+ set noShadow(value) {
13
+ value ? this.setAttribute('no-shadow', '') : this.removeAttribute('no-shadow');
14
+ }
15
+ get maxHeight() {
16
+ return this.getAttribute('max-height');
17
+ }
18
+ set maxHeight(value) {
19
+ if (value)
20
+ this.setAttribute('max-height', value);
21
+ else
22
+ this.removeAttribute('max-height');
23
+ this._updateMaxHeight();
24
+ }
25
+ get hideScrollbar() {
26
+ return this.hasAttribute('hide-scrollbar');
27
+ }
28
+ set hideScrollbar(value) {
29
+ if (value)
30
+ this.setAttribute('hide-scrollbar', '');
31
+ else
32
+ this.removeAttribute('hide-scrollbar');
33
+ }
34
+ get customScrollbar() {
35
+ return this.hasAttribute('custom-scrollbar');
36
+ }
37
+ set customScrollbar(value) {
38
+ if (value)
39
+ this.setAttribute('custom-scrollbar', '');
40
+ else
41
+ this.removeAttribute('custom-scrollbar');
42
+ }
43
+ get overflowX() {
44
+ return this.hasAttribute('overflow-x');
45
+ }
46
+ set overflowX(value) {
47
+ if (value)
48
+ this.setAttribute('overflow-x', '');
49
+ else
50
+ this.removeAttribute('overflow-x');
51
+ }
52
+ get nearEdgeThreshold() {
53
+ const v = parseInt(this.getAttribute('near-edge-threshold') || '', 10);
54
+ return Number.isFinite(v) ? v : 100;
55
+ }
56
+ set nearEdgeThreshold(value) {
57
+ if (value == null)
58
+ this.removeAttribute('near-edge-threshold');
59
+ else
60
+ this.setAttribute('near-edge-threshold', String(value));
61
+ }
62
+ get scrollAnchoring() {
63
+ return this.hasAttribute('scroll-anchoring');
64
+ }
65
+ set scrollAnchoring(value) {
66
+ if (value)
67
+ this.setAttribute('scroll-anchoring', '');
68
+ else
69
+ this.removeAttribute('scroll-anchoring');
70
+ }
71
+ constructor() {
72
+ super();
73
+ this._scrollWrapper = null;
74
+ this._shadowTop = null;
75
+ this._shadowBottom = null;
76
+ this._shadowLeft = null;
77
+ this._shadowRight = null;
78
+ this._scrollbar = null;
79
+ this._resizeObserver = null;
80
+ this._contentObserver = null;
81
+ this._rafId = null;
82
+ this._nearStartFired = false;
83
+ this._nearEndFired = false;
84
+ this._onScroll = () => {
85
+ if (this._rafId !== null)
86
+ return;
87
+ this._rafId = requestAnimationFrame(() => {
88
+ this._rafId = null;
89
+ this._updateShadowState();
90
+ });
91
+ };
92
+ this._onSlotChange = () => {
93
+ this._scrollbar?.update();
94
+ this._updateShadowState();
95
+ };
96
+ const shadow = this.attachShadow({ mode: 'open' });
97
+ ensureStyles(shadow, { css: scrollContainerStyles, id: 'ty-scroll-container' });
98
+ shadow.innerHTML = `
99
+ <div class="scroll-wrapper">
100
+ <slot></slot>
101
+ </div>
102
+ <div class="shadow-overlay">
103
+ <div class="shadow-top"></div>
104
+ <div class="shadow-bottom"></div>
105
+ <div class="shadow-left"></div>
106
+ <div class="shadow-right"></div>
107
+ </div>
108
+ `;
109
+ this._scrollWrapper = shadow.querySelector('.scroll-wrapper');
110
+ this._shadowTop = shadow.querySelector('.shadow-top');
111
+ this._shadowBottom = shadow.querySelector('.shadow-bottom');
112
+ this._shadowLeft = shadow.querySelector('.shadow-left');
113
+ this._shadowRight = shadow.querySelector('.shadow-right');
114
+ }
115
+ connectedCallback() {
116
+ upgradeProperties(this);
117
+ this._scrollWrapper?.addEventListener('scroll', this._onScroll, { passive: true });
118
+ this._resizeObserver = new ResizeObserver(() => {
119
+ this._scrollbar?.update();
120
+ this._updateShadowState();
121
+ });
122
+ if (this._scrollWrapper) {
123
+ this._resizeObserver.observe(this._scrollWrapper);
124
+ const slot = this._scrollWrapper.querySelector('slot');
125
+ if (slot) {
126
+ slot.addEventListener('slotchange', this._onSlotChange);
127
+ }
128
+ }
129
+ this._updateMaxHeight();
130
+ this._updateShadowState();
131
+ this._setupScrollbar();
132
+ this._setupAnchoring();
133
+ }
134
+ disconnectedCallback() {
135
+ this._scrollWrapper?.removeEventListener('scroll', this._onScroll);
136
+ this._destroyScrollbar();
137
+ this._teardownAnchoring();
138
+ if (this._resizeObserver) {
139
+ this._resizeObserver.disconnect();
140
+ this._resizeObserver = null;
141
+ }
142
+ if (this._rafId !== null) {
143
+ cancelAnimationFrame(this._rafId);
144
+ this._rafId = null;
145
+ }
146
+ }
147
+ attributeChangedCallback(name, oldValue, newValue) {
148
+ if (oldValue === newValue)
149
+ return;
150
+ if (name === 'max-height') {
151
+ this._updateMaxHeight();
152
+ this._updateShadowState();
153
+ this._scrollbar?.update();
154
+ }
155
+ if (name === 'custom-scrollbar' || name === 'overflow-x') {
156
+ this._destroyScrollbar();
157
+ this._setupScrollbar();
158
+ this._updateShadowState();
159
+ }
160
+ if (name === 'scroll-anchoring') {
161
+ this._teardownAnchoring();
162
+ this._setupAnchoring();
163
+ }
164
+ }
165
+ _setupAnchoring() {
166
+ if (this._contentObserver || !this.scrollAnchoring)
167
+ return;
168
+ this._contentObserver = new MutationObserver((records) => {
169
+ const wrap = this._scrollWrapper;
170
+ if (!wrap)
171
+ return;
172
+ const added = new Set();
173
+ for (const r of records)
174
+ r.addedNodes.forEach((n) => added.add(n));
175
+ if (added.size === 0)
176
+ return;
177
+ let addedAbove = 0;
178
+ for (const child of Array.from(this.children)) {
179
+ if (!added.has(child))
180
+ break;
181
+ addedAbove += child.offsetHeight;
182
+ }
183
+ if (addedAbove > 0) {
184
+ wrap.scrollTop += addedAbove;
185
+ this._scrollbar?.update();
186
+ }
187
+ });
188
+ this._contentObserver.observe(this, { childList: true });
189
+ }
190
+ _teardownAnchoring() {
191
+ this._contentObserver?.disconnect();
192
+ this._contentObserver = null;
193
+ }
194
+ _setupScrollbar() {
195
+ if (this._scrollbar)
196
+ return;
197
+ if (!this._scrollWrapper || !this.customScrollbar)
198
+ return;
199
+ this._scrollbar = new CustomScrollbar(this._scrollWrapper, {
200
+ vertical: true,
201
+ horizontal: this.overflowX
202
+ });
203
+ const shadowRoot = this.shadowRoot;
204
+ if (this._scrollbar.trackY)
205
+ shadowRoot.appendChild(this._scrollbar.trackY);
206
+ if (this._scrollbar.trackX)
207
+ shadowRoot.appendChild(this._scrollbar.trackX);
208
+ }
209
+ _destroyScrollbar() {
210
+ if (this._scrollbar) {
211
+ this._scrollbar.trackY?.remove();
212
+ this._scrollbar.trackX?.remove();
213
+ this._scrollbar.destroy();
214
+ this._scrollbar = null;
215
+ }
216
+ }
217
+ _updateMaxHeight() {
218
+ if (this._scrollWrapper) {
219
+ const maxHeight = this.maxHeight;
220
+ if (maxHeight) {
221
+ this._scrollWrapper.style.setProperty('--scroll-max-height', maxHeight);
222
+ this._scrollWrapper.style.maxHeight = maxHeight;
223
+ }
224
+ else {
225
+ this._scrollWrapper.style.removeProperty('--scroll-max-height');
226
+ this._scrollWrapper.style.maxHeight = '';
227
+ }
228
+ }
229
+ }
230
+ _updateShadowState() {
231
+ if (!this._scrollWrapper)
232
+ return;
233
+ const { scrollTop, scrollLeft, scrollHeight, scrollWidth, clientHeight, clientWidth } = this._scrollWrapper;
234
+ const threshold = 2;
235
+ if (this._shadowTop) {
236
+ this._shadowTop.classList.toggle('visible', scrollTop > threshold);
237
+ }
238
+ if (this._shadowBottom) {
239
+ this._shadowBottom.classList.toggle('visible', scrollTop + clientHeight < scrollHeight - threshold);
240
+ }
241
+ if (this.overflowX) {
242
+ if (this._shadowLeft) {
243
+ this._shadowLeft.classList.toggle('visible', scrollLeft > threshold);
244
+ }
245
+ if (this._shadowRight) {
246
+ this._shadowRight.classList.toggle('visible', scrollLeft + clientWidth < scrollWidth - threshold);
247
+ }
248
+ }
249
+ const scrollable = scrollHeight - clientHeight;
250
+ if (scrollable > 0) {
251
+ const t = this.nearEdgeThreshold;
252
+ const distEnd = scrollable - scrollTop;
253
+ this._nearEndFired = this._maybeEmitEdge('nearend', distEnd, t, this._nearEndFired, { distance: distEnd, scrollTop, scrollHeight, clientHeight });
254
+ this._nearStartFired = this._maybeEmitEdge('nearstart', scrollTop, t, this._nearStartFired, { distance: scrollTop, scrollTop, scrollHeight, clientHeight });
255
+ }
256
+ else {
257
+ this._nearStartFired = false;
258
+ this._nearEndFired = false;
259
+ }
260
+ }
261
+ _maybeEmitEdge(name, distance, threshold, fired, detail) {
262
+ if (distance > threshold)
263
+ return false;
264
+ if (!fired) {
265
+ this.dispatchEvent(new CustomEvent(name, { detail, bubbles: true, composed: true }));
266
+ }
267
+ return true;
268
+ }
269
+ updateShadows() {
270
+ this._updateShadowState();
271
+ this._scrollbar?.update();
272
+ }
273
+ scrollToTop(smooth = true) {
274
+ this._scrollWrapper?.scrollTo({ top: 0, behavior: smooth ? 'smooth' : 'auto' });
275
+ }
276
+ scrollToBottom(smooth = true) {
277
+ if (this._scrollWrapper) {
278
+ this._scrollWrapper.scrollTo({ top: this._scrollWrapper.scrollHeight, behavior: smooth ? 'smooth' : 'auto' });
279
+ }
280
+ }
281
+ scrollToLeft(smooth = true) {
282
+ this._scrollWrapper?.scrollTo({ left: 0, behavior: smooth ? 'smooth' : 'auto' });
283
+ }
284
+ scrollToRight(smooth = true) {
285
+ if (this._scrollWrapper) {
286
+ this._scrollWrapper.scrollTo({ left: this._scrollWrapper.scrollWidth, behavior: smooth ? 'smooth' : 'auto' });
287
+ }
288
+ }
289
+ scrollToElement(target, smooth = true) {
290
+ const el = typeof target === 'string' ? this.querySelector(target) : target;
291
+ el?.scrollIntoView({ behavior: smooth ? 'smooth' : 'auto', block: 'nearest' });
292
+ }
293
+ get scrollElement() {
294
+ return this._scrollWrapper;
295
+ }
296
+ }
238
297
  customElements.define('ty-scroll-container', TyScrollContainer);
239
- //# sourceMappingURL=scroll-container.js.map