@tartaguti/ui-components 0.0.0-stage → 0.1.0

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 (392) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +21 -0
  3. package/README.md +192 -2
  4. package/THIRD-PARTY-NOTICES.md +29 -0
  5. package/custom-elements.json +16731 -0
  6. package/dist/accordion/tt-accordion-item.d.ts +32 -0
  7. package/dist/accordion/tt-accordion-item.d.ts.map +1 -0
  8. package/dist/accordion/tt-accordion-item.js +247 -0
  9. package/dist/accordion/tt-accordion-item.js.map +1 -0
  10. package/dist/accordion/tt-accordion.d.ts +28 -0
  11. package/dist/accordion/tt-accordion.d.ts.map +1 -0
  12. package/dist/accordion/tt-accordion.js +148 -0
  13. package/dist/accordion/tt-accordion.js.map +1 -0
  14. package/dist/bento/tt-bento-item.d.ts +35 -0
  15. package/dist/bento/tt-bento-item.d.ts.map +1 -0
  16. package/dist/bento/tt-bento-item.js +201 -0
  17. package/dist/bento/tt-bento-item.js.map +1 -0
  18. package/dist/bento/tt-bento.d.ts +25 -0
  19. package/dist/bento/tt-bento.d.ts.map +1 -0
  20. package/dist/bento/tt-bento.js +314 -0
  21. package/dist/bento/tt-bento.js.map +1 -0
  22. package/dist/floating.d.ts +61 -0
  23. package/dist/floating.d.ts.map +1 -0
  24. package/dist/floating.js +120 -0
  25. package/dist/floating.js.map +1 -0
  26. package/dist/index.d.ts +92 -0
  27. package/dist/index.d.ts.map +1 -0
  28. package/dist/index.js +96 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/interaction/tt-draggable.d.ts +29 -0
  31. package/dist/interaction/tt-draggable.d.ts.map +1 -0
  32. package/dist/interaction/tt-draggable.js +66 -0
  33. package/dist/interaction/tt-draggable.js.map +1 -0
  34. package/dist/interaction/tt-droppable.d.ts +37 -0
  35. package/dist/interaction/tt-droppable.d.ts.map +1 -0
  36. package/dist/interaction/tt-droppable.js +108 -0
  37. package/dist/interaction/tt-droppable.js.map +1 -0
  38. package/dist/interaction/tt-resizable.d.ts +45 -0
  39. package/dist/interaction/tt-resizable.d.ts.map +1 -0
  40. package/dist/interaction/tt-resizable.js +210 -0
  41. package/dist/interaction/tt-resizable.js.map +1 -0
  42. package/dist/interaction/tt-reveal.d.ts +54 -0
  43. package/dist/interaction/tt-reveal.d.ts.map +1 -0
  44. package/dist/interaction/tt-reveal.js +302 -0
  45. package/dist/interaction/tt-reveal.js.map +1 -0
  46. package/dist/motion.d.ts +8 -0
  47. package/dist/motion.d.ts.map +1 -0
  48. package/dist/motion.js +49 -0
  49. package/dist/motion.js.map +1 -0
  50. package/dist/overlay.d.ts +7 -0
  51. package/dist/overlay.d.ts.map +1 -0
  52. package/dist/overlay.js +121 -0
  53. package/dist/overlay.js.map +1 -0
  54. package/dist/safe-url.d.ts +14 -0
  55. package/dist/safe-url.d.ts.map +1 -0
  56. package/dist/safe-url.js +46 -0
  57. package/dist/safe-url.js.map +1 -0
  58. package/dist/scroll-lock.d.ts +22 -0
  59. package/dist/scroll-lock.d.ts.map +1 -0
  60. package/dist/scroll-lock.js +56 -0
  61. package/dist/scroll-lock.js.map +1 -0
  62. package/dist/sidebar/tt-menu-group.d.ts +69 -0
  63. package/dist/sidebar/tt-menu-group.d.ts.map +1 -0
  64. package/dist/sidebar/tt-menu-group.js +358 -0
  65. package/dist/sidebar/tt-menu-group.js.map +1 -0
  66. package/dist/sidebar/tt-menu-item.d.ts +70 -0
  67. package/dist/sidebar/tt-menu-item.d.ts.map +1 -0
  68. package/dist/sidebar/tt-menu-item.js +502 -0
  69. package/dist/sidebar/tt-menu-item.js.map +1 -0
  70. package/dist/sidebar/tt-sidebar-footer.d.ts +39 -0
  71. package/dist/sidebar/tt-sidebar-footer.d.ts.map +1 -0
  72. package/dist/sidebar/tt-sidebar-footer.js +205 -0
  73. package/dist/sidebar/tt-sidebar-footer.js.map +1 -0
  74. package/dist/sidebar/tt-sidebar-header.d.ts +31 -0
  75. package/dist/sidebar/tt-sidebar-header.d.ts.map +1 -0
  76. package/dist/sidebar/tt-sidebar-header.js +150 -0
  77. package/dist/sidebar/tt-sidebar-header.js.map +1 -0
  78. package/dist/sidebar/tt-sidebar.d.ts +72 -0
  79. package/dist/sidebar/tt-sidebar.d.ts.map +1 -0
  80. package/dist/sidebar/tt-sidebar.js +539 -0
  81. package/dist/sidebar/tt-sidebar.js.map +1 -0
  82. package/dist/sr-only.d.ts +15 -0
  83. package/dist/sr-only.d.ts.map +1 -0
  84. package/dist/sr-only.js +27 -0
  85. package/dist/sr-only.js.map +1 -0
  86. package/dist/tokens.css +1124 -0
  87. package/dist/tt-alert.d.ts +26 -0
  88. package/dist/tt-alert.d.ts.map +1 -0
  89. package/dist/tt-alert.js +165 -0
  90. package/dist/tt-alert.js.map +1 -0
  91. package/dist/tt-aspect-ratio.d.ts +40 -0
  92. package/dist/tt-aspect-ratio.d.ts.map +1 -0
  93. package/dist/tt-aspect-ratio.js +98 -0
  94. package/dist/tt-aspect-ratio.js.map +1 -0
  95. package/dist/tt-auth.d.ts +75 -0
  96. package/dist/tt-auth.d.ts.map +1 -0
  97. package/dist/tt-auth.js +520 -0
  98. package/dist/tt-auth.js.map +1 -0
  99. package/dist/tt-avatar.d.ts +26 -0
  100. package/dist/tt-avatar.d.ts.map +1 -0
  101. package/dist/tt-avatar.js +169 -0
  102. package/dist/tt-avatar.js.map +1 -0
  103. package/dist/tt-badge.d.ts +36 -0
  104. package/dist/tt-badge.d.ts.map +1 -0
  105. package/dist/tt-badge.js +135 -0
  106. package/dist/tt-badge.js.map +1 -0
  107. package/dist/tt-breadcrumbs.d.ts +22 -0
  108. package/dist/tt-breadcrumbs.d.ts.map +1 -0
  109. package/dist/tt-breadcrumbs.js +144 -0
  110. package/dist/tt-breadcrumbs.js.map +1 -0
  111. package/dist/tt-button-group.d.ts +32 -0
  112. package/dist/tt-button-group.d.ts.map +1 -0
  113. package/dist/tt-button-group.js +132 -0
  114. package/dist/tt-button-group.js.map +1 -0
  115. package/dist/tt-button.d.ts +31 -0
  116. package/dist/tt-button.d.ts.map +1 -0
  117. package/dist/tt-button.js +483 -0
  118. package/dist/tt-button.js.map +1 -0
  119. package/dist/tt-card.d.ts +26 -0
  120. package/dist/tt-card.d.ts.map +1 -0
  121. package/dist/tt-card.js +429 -0
  122. package/dist/tt-card.js.map +1 -0
  123. package/dist/tt-chart.d.ts +36 -0
  124. package/dist/tt-chart.d.ts.map +1 -0
  125. package/dist/tt-chart.js +332 -0
  126. package/dist/tt-chart.js.map +1 -0
  127. package/dist/tt-checkbox-group.d.ts +38 -0
  128. package/dist/tt-checkbox-group.d.ts.map +1 -0
  129. package/dist/tt-checkbox-group.js +243 -0
  130. package/dist/tt-checkbox-group.js.map +1 -0
  131. package/dist/tt-checkbox.d.ts +35 -0
  132. package/dist/tt-checkbox.d.ts.map +1 -0
  133. package/dist/tt-checkbox.js +354 -0
  134. package/dist/tt-checkbox.js.map +1 -0
  135. package/dist/tt-code-block.d.ts +37 -0
  136. package/dist/tt-code-block.d.ts.map +1 -0
  137. package/dist/tt-code-block.js +409 -0
  138. package/dist/tt-code-block.js.map +1 -0
  139. package/dist/tt-collapsible.d.ts +71 -0
  140. package/dist/tt-collapsible.d.ts.map +1 -0
  141. package/dist/tt-collapsible.js +206 -0
  142. package/dist/tt-collapsible.js.map +1 -0
  143. package/dist/tt-combobox.d.ts +107 -0
  144. package/dist/tt-combobox.d.ts.map +1 -0
  145. package/dist/tt-combobox.js +816 -0
  146. package/dist/tt-combobox.js.map +1 -0
  147. package/dist/tt-company-card.d.ts +30 -0
  148. package/dist/tt-company-card.d.ts.map +1 -0
  149. package/dist/tt-company-card.js +382 -0
  150. package/dist/tt-company-card.js.map +1 -0
  151. package/dist/tt-comparison-table.d.ts +59 -0
  152. package/dist/tt-comparison-table.d.ts.map +1 -0
  153. package/dist/tt-comparison-table.js +441 -0
  154. package/dist/tt-comparison-table.js.map +1 -0
  155. package/dist/tt-component-doc.d.ts +63 -0
  156. package/dist/tt-component-doc.d.ts.map +1 -0
  157. package/dist/tt-component-doc.js +585 -0
  158. package/dist/tt-component-doc.js.map +1 -0
  159. package/dist/tt-confirm.d.ts +45 -0
  160. package/dist/tt-confirm.d.ts.map +1 -0
  161. package/dist/tt-confirm.js +151 -0
  162. package/dist/tt-confirm.js.map +1 -0
  163. package/dist/tt-contact-list.d.ts +18 -0
  164. package/dist/tt-contact-list.d.ts.map +1 -0
  165. package/dist/tt-contact-list.js +101 -0
  166. package/dist/tt-contact-list.js.map +1 -0
  167. package/dist/tt-copy-button.d.ts +25 -0
  168. package/dist/tt-copy-button.d.ts.map +1 -0
  169. package/dist/tt-copy-button.js +194 -0
  170. package/dist/tt-copy-button.js.map +1 -0
  171. package/dist/tt-data-table.d.ts +69 -0
  172. package/dist/tt-data-table.d.ts.map +1 -0
  173. package/dist/tt-data-table.js +542 -0
  174. package/dist/tt-data-table.js.map +1 -0
  175. package/dist/tt-divider.d.ts +19 -0
  176. package/dist/tt-divider.d.ts.map +1 -0
  177. package/dist/tt-divider.js +104 -0
  178. package/dist/tt-divider.js.map +1 -0
  179. package/dist/tt-drawer.d.ts +38 -0
  180. package/dist/tt-drawer.d.ts.map +1 -0
  181. package/dist/tt-drawer.js +433 -0
  182. package/dist/tt-drawer.js.map +1 -0
  183. package/dist/tt-dropdown-menu.d.ts +57 -0
  184. package/dist/tt-dropdown-menu.d.ts.map +1 -0
  185. package/dist/tt-dropdown-menu.js +631 -0
  186. package/dist/tt-dropdown-menu.js.map +1 -0
  187. package/dist/tt-empty-state.d.ts +13 -0
  188. package/dist/tt-empty-state.d.ts.map +1 -0
  189. package/dist/tt-empty-state.js +94 -0
  190. package/dist/tt-empty-state.js.map +1 -0
  191. package/dist/tt-example.d.ts +33 -0
  192. package/dist/tt-example.d.ts.map +1 -0
  193. package/dist/tt-example.js +250 -0
  194. package/dist/tt-example.js.map +1 -0
  195. package/dist/tt-file-upload.d.ts +85 -0
  196. package/dist/tt-file-upload.d.ts.map +1 -0
  197. package/dist/tt-file-upload.js +662 -0
  198. package/dist/tt-file-upload.js.map +1 -0
  199. package/dist/tt-filter.d.ts +62 -0
  200. package/dist/tt-filter.d.ts.map +1 -0
  201. package/dist/tt-filter.js +393 -0
  202. package/dist/tt-filter.js.map +1 -0
  203. package/dist/tt-form.d.ts +33 -0
  204. package/dist/tt-form.d.ts.map +1 -0
  205. package/dist/tt-form.js +202 -0
  206. package/dist/tt-form.js.map +1 -0
  207. package/dist/tt-grid.d.ts +22 -0
  208. package/dist/tt-grid.d.ts.map +1 -0
  209. package/dist/tt-grid.js +106 -0
  210. package/dist/tt-grid.js.map +1 -0
  211. package/dist/tt-icon.d.ts +20 -0
  212. package/dist/tt-icon.d.ts.map +1 -0
  213. package/dist/tt-icon.js +510 -0
  214. package/dist/tt-icon.js.map +1 -0
  215. package/dist/tt-image.d.ts +59 -0
  216. package/dist/tt-image.d.ts.map +1 -0
  217. package/dist/tt-image.js +314 -0
  218. package/dist/tt-image.js.map +1 -0
  219. package/dist/tt-inbox.d.ts +45 -0
  220. package/dist/tt-inbox.d.ts.map +1 -0
  221. package/dist/tt-inbox.js +275 -0
  222. package/dist/tt-inbox.js.map +1 -0
  223. package/dist/tt-input.d.ts +43 -0
  224. package/dist/tt-input.d.ts.map +1 -0
  225. package/dist/tt-input.js +476 -0
  226. package/dist/tt-input.js.map +1 -0
  227. package/dist/tt-kbd.d.ts +39 -0
  228. package/dist/tt-kbd.d.ts.map +1 -0
  229. package/dist/tt-kbd.js +145 -0
  230. package/dist/tt-kbd.js.map +1 -0
  231. package/dist/tt-key-values.d.ts +17 -0
  232. package/dist/tt-key-values.d.ts.map +1 -0
  233. package/dist/tt-key-values.js +126 -0
  234. package/dist/tt-key-values.js.map +1 -0
  235. package/dist/tt-knowledge-doc.d.ts +24 -0
  236. package/dist/tt-knowledge-doc.d.ts.map +1 -0
  237. package/dist/tt-knowledge-doc.js +120 -0
  238. package/dist/tt-knowledge-doc.js.map +1 -0
  239. package/dist/tt-layout.d.ts +36 -0
  240. package/dist/tt-layout.d.ts.map +1 -0
  241. package/dist/tt-layout.js +318 -0
  242. package/dist/tt-layout.js.map +1 -0
  243. package/dist/tt-modal.d.ts +32 -0
  244. package/dist/tt-modal.d.ts.map +1 -0
  245. package/dist/tt-modal.js +553 -0
  246. package/dist/tt-modal.js.map +1 -0
  247. package/dist/tt-navbar.d.ts +33 -0
  248. package/dist/tt-navbar.d.ts.map +1 -0
  249. package/dist/tt-navbar.js +390 -0
  250. package/dist/tt-navbar.js.map +1 -0
  251. package/dist/tt-page-header.d.ts +28 -0
  252. package/dist/tt-page-header.d.ts.map +1 -0
  253. package/dist/tt-page-header.js +166 -0
  254. package/dist/tt-page-header.js.map +1 -0
  255. package/dist/tt-page.d.ts +14 -0
  256. package/dist/tt-page.d.ts.map +1 -0
  257. package/dist/tt-page.js +163 -0
  258. package/dist/tt-page.js.map +1 -0
  259. package/dist/tt-pagination.d.ts +27 -0
  260. package/dist/tt-pagination.d.ts.map +1 -0
  261. package/dist/tt-pagination.js +194 -0
  262. package/dist/tt-pagination.js.map +1 -0
  263. package/dist/tt-preview.d.ts +11 -0
  264. package/dist/tt-preview.d.ts.map +1 -0
  265. package/dist/tt-preview.js +68 -0
  266. package/dist/tt-preview.js.map +1 -0
  267. package/dist/tt-product.d.ts +40 -0
  268. package/dist/tt-product.d.ts.map +1 -0
  269. package/dist/tt-product.js +590 -0
  270. package/dist/tt-product.js.map +1 -0
  271. package/dist/tt-profile-card.d.ts +23 -0
  272. package/dist/tt-profile-card.d.ts.map +1 -0
  273. package/dist/tt-profile-card.js +199 -0
  274. package/dist/tt-profile-card.js.map +1 -0
  275. package/dist/tt-progress.d.ts +26 -0
  276. package/dist/tt-progress.d.ts.map +1 -0
  277. package/dist/tt-progress.js +156 -0
  278. package/dist/tt-progress.js.map +1 -0
  279. package/dist/tt-quantity.d.ts +36 -0
  280. package/dist/tt-quantity.d.ts.map +1 -0
  281. package/dist/tt-quantity.js +396 -0
  282. package/dist/tt-quantity.js.map +1 -0
  283. package/dist/tt-radio-group.d.ts +50 -0
  284. package/dist/tt-radio-group.d.ts.map +1 -0
  285. package/dist/tt-radio-group.js +372 -0
  286. package/dist/tt-radio-group.js.map +1 -0
  287. package/dist/tt-rating.d.ts +54 -0
  288. package/dist/tt-rating.d.ts.map +1 -0
  289. package/dist/tt-rating.js +312 -0
  290. package/dist/tt-rating.js.map +1 -0
  291. package/dist/tt-search.d.ts +47 -0
  292. package/dist/tt-search.d.ts.map +1 -0
  293. package/dist/tt-search.js +360 -0
  294. package/dist/tt-search.js.map +1 -0
  295. package/dist/tt-section.d.ts +13 -0
  296. package/dist/tt-section.d.ts.map +1 -0
  297. package/dist/tt-section.js +98 -0
  298. package/dist/tt-section.js.map +1 -0
  299. package/dist/tt-select.d.ts +62 -0
  300. package/dist/tt-select.d.ts.map +1 -0
  301. package/dist/tt-select.js +662 -0
  302. package/dist/tt-select.js.map +1 -0
  303. package/dist/tt-skeleton.d.ts +20 -0
  304. package/dist/tt-skeleton.d.ts.map +1 -0
  305. package/dist/tt-skeleton.js +143 -0
  306. package/dist/tt-skeleton.js.map +1 -0
  307. package/dist/tt-slider.d.ts +74 -0
  308. package/dist/tt-slider.d.ts.map +1 -0
  309. package/dist/tt-slider.js +426 -0
  310. package/dist/tt-slider.js.map +1 -0
  311. package/dist/tt-social-links.d.ts +34 -0
  312. package/dist/tt-social-links.d.ts.map +1 -0
  313. package/dist/tt-social-links.js +242 -0
  314. package/dist/tt-social-links.js.map +1 -0
  315. package/dist/tt-sparkline.d.ts +19 -0
  316. package/dist/tt-sparkline.d.ts.map +1 -0
  317. package/dist/tt-sparkline.js +191 -0
  318. package/dist/tt-sparkline.js.map +1 -0
  319. package/dist/tt-spinner.d.ts +19 -0
  320. package/dist/tt-spinner.d.ts.map +1 -0
  321. package/dist/tt-spinner.js +93 -0
  322. package/dist/tt-spinner.js.map +1 -0
  323. package/dist/tt-stack.d.ts +42 -0
  324. package/dist/tt-stack.d.ts.map +1 -0
  325. package/dist/tt-stack.js +158 -0
  326. package/dist/tt-stack.js.map +1 -0
  327. package/dist/tt-stat.d.ts +17 -0
  328. package/dist/tt-stat.d.ts.map +1 -0
  329. package/dist/tt-stat.js +134 -0
  330. package/dist/tt-stat.js.map +1 -0
  331. package/dist/tt-switch.d.ts +39 -0
  332. package/dist/tt-switch.d.ts.map +1 -0
  333. package/dist/tt-switch.js +254 -0
  334. package/dist/tt-switch.js.map +1 -0
  335. package/dist/tt-switcher.d.ts +23 -0
  336. package/dist/tt-switcher.d.ts.map +1 -0
  337. package/dist/tt-switcher.js +203 -0
  338. package/dist/tt-switcher.js.map +1 -0
  339. package/dist/tt-table-cell.d.ts +26 -0
  340. package/dist/tt-table-cell.d.ts.map +1 -0
  341. package/dist/tt-table-cell.js +121 -0
  342. package/dist/tt-table-cell.js.map +1 -0
  343. package/dist/tt-table-row.d.ts +31 -0
  344. package/dist/tt-table-row.d.ts.map +1 -0
  345. package/dist/tt-table-row.js +72 -0
  346. package/dist/tt-table-row.js.map +1 -0
  347. package/dist/tt-table.d.ts +44 -0
  348. package/dist/tt-table.d.ts.map +1 -0
  349. package/dist/tt-table.js +270 -0
  350. package/dist/tt-table.js.map +1 -0
  351. package/dist/tt-tabs.d.ts +31 -0
  352. package/dist/tt-tabs.d.ts.map +1 -0
  353. package/dist/tt-tabs.js +223 -0
  354. package/dist/tt-tabs.js.map +1 -0
  355. package/dist/tt-tag-list.d.ts +19 -0
  356. package/dist/tt-tag-list.d.ts.map +1 -0
  357. package/dist/tt-tag-list.js +136 -0
  358. package/dist/tt-tag-list.js.map +1 -0
  359. package/dist/tt-text.d.ts +52 -0
  360. package/dist/tt-text.d.ts.map +1 -0
  361. package/dist/tt-text.js +337 -0
  362. package/dist/tt-text.js.map +1 -0
  363. package/dist/tt-textarea.d.ts +43 -0
  364. package/dist/tt-textarea.d.ts.map +1 -0
  365. package/dist/tt-textarea.js +356 -0
  366. package/dist/tt-textarea.js.map +1 -0
  367. package/dist/tt-thread.d.ts +62 -0
  368. package/dist/tt-thread.d.ts.map +1 -0
  369. package/dist/tt-thread.js +374 -0
  370. package/dist/tt-thread.js.map +1 -0
  371. package/dist/tt-toast.d.ts +49 -0
  372. package/dist/tt-toast.d.ts.map +1 -0
  373. package/dist/tt-toast.js +440 -0
  374. package/dist/tt-toast.js.map +1 -0
  375. package/dist/tt-toggle-group.d.ts +73 -0
  376. package/dist/tt-toggle-group.d.ts.map +1 -0
  377. package/dist/tt-toggle-group.js +273 -0
  378. package/dist/tt-toggle-group.js.map +1 -0
  379. package/dist/tt-toggle.d.ts +54 -0
  380. package/dist/tt-toggle.d.ts.map +1 -0
  381. package/dist/tt-toggle.js +232 -0
  382. package/dist/tt-toggle.js.map +1 -0
  383. package/dist/tt-toolbar.d.ts +26 -0
  384. package/dist/tt-toolbar.d.ts.map +1 -0
  385. package/dist/tt-toolbar.js +164 -0
  386. package/dist/tt-toolbar.js.map +1 -0
  387. package/dist/tt-tooltip.d.ts +42 -0
  388. package/dist/tt-tooltip.d.ts.map +1 -0
  389. package/dist/tt-tooltip.js +299 -0
  390. package/dist/tt-tooltip.js.map +1 -0
  391. package/package.json +84 -4
  392. package/vscode.html-custom-data.json +2907 -0
@@ -0,0 +1,440 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { LitElement, html, css, nothing } from "lit";
8
+ import { customElement, property, state } from "lit/decorators.js";
9
+ import { repeat } from "lit/directives/repeat.js";
10
+ import { srOnly } from "./sr-only.js";
11
+ import { afterTransitions } from "./motion.js";
12
+ import "./tt-icon.js";
13
+ let toastId = 0;
14
+ /*
15
+ The most toasts shown at once.
16
+
17
+ Without a cap, holding down a button that toasts builds a column that
18
+ eventually fills the viewport, and since each toast takes pointer
19
+ events, the page underneath stops being clickable. Three is enough to
20
+ show that several things happened without becoming the page.
21
+ */
22
+ const MAX_VISIBLE = 3;
23
+ /**
24
+ * Drop one of these anywhere in the app, then call the module-level
25
+ * toast() from anywhere else. Notifications are global by nature, so
26
+ * routing every message down through props would mean every component
27
+ * in the tree carrying a notify callback it does not otherwise need.
28
+ */
29
+ let TTToast = class TTToast extends LitElement {
30
+ constructor() {
31
+ super(...arguments);
32
+ /*
33
+ REFLECTED, and that is not optional here. Every position rule is a
34
+ :host([position="..."]) selector, and a selector matches an ATTRIBUTE,
35
+ never a property. Without reflect, setting toastEl.position = "top-right"
36
+ in script changed the property, matched no rule, and left the element
37
+ with position: fixed and no offsets at all, so it sat wherever the
38
+ layout happened to put it. Writing it as an attribute in HTML worked,
39
+ which is exactly the kind of split that hides a bug.
40
+
41
+ Top by default. A toast at the bottom of a phone lands under the
42
+ thumb, over the home indicator, and on top of whatever action just
43
+ triggered it. All four values remain available, and on screens up to
44
+ 768px wide the bottom ones move to the top anyway (see the styles).
45
+ */
46
+ this.position = "top-right";
47
+ this.items = [];
48
+ /*
49
+ Toasts on their way out: dismissed, timed out, or pushed off by the
50
+ cap. Kept apart from `items` because they are no longer toasts, only
51
+ the picture of one fading. They cannot be hovered, focused or counted,
52
+ and they leave once afterTransitions says their transition is done.
53
+ */
54
+ this.leaving = [];
55
+ this.exits = new Map();
56
+ /*
57
+ What the two live regions below currently say. See render().
58
+ */
59
+ this.politeText = "";
60
+ this.alertText = "";
61
+ this.timers = new Map();
62
+ }
63
+ connectedCallback() {
64
+ super.connectedCallback();
65
+ registry.add(this);
66
+ }
67
+ disconnectedCallback() {
68
+ registry.delete(this);
69
+ this.timers.forEach((timer) => clearTimeout(timer));
70
+ this.timers.clear();
71
+ this.exits.forEach((cancel) => cancel());
72
+ this.exits.clear();
73
+ this.leaving = [];
74
+ super.disconnectedCallback();
75
+ }
76
+ // Each leaving toast is timed once, after the render that gave it its
77
+ // exit styles, so the durations read are the exit ones.
78
+ updated() {
79
+ for (const item of this.leaving) {
80
+ if (this.exits.has(item.id))
81
+ continue;
82
+ const node = this.renderRoot.querySelector(`[data-toast="${item.id}"]`);
83
+ this.exits.set(item.id, afterTransitions([node], () => {
84
+ this.exits.delete(item.id);
85
+ this.leaving = this.leaving.filter((gone) => gone !== item);
86
+ }));
87
+ }
88
+ }
89
+ show(options) {
90
+ const variant = options.variant ?? "neutral";
91
+ const duration = options.duration ?? 4000;
92
+ /*
93
+ The same message twice is one message that happened twice.
94
+
95
+ Pressing Add to basket five times used to stack five identical
96
+ toasts. Now the existing one counts up and its timer restarts, so
97
+ the feedback still says "that registered" without the screen
98
+ filling. Matched on message AND variant, since the same words as a
99
+ success and as an error are different events.
100
+ */
101
+ const existing = this.items.find((item) => item.message === options.message && item.variant === variant);
102
+ if (existing) {
103
+ this.items = this.items.map((item) => item === existing ? { ...item, count: item.count + 1 } : item);
104
+ this.restartTimer(existing.id, duration);
105
+ this.announce(options.message, variant);
106
+ return;
107
+ }
108
+ const item = {
109
+ id: ++toastId,
110
+ message: options.message,
111
+ variant,
112
+ duration,
113
+ count: 1,
114
+ };
115
+ /*
116
+ Oldest out once the cap is reached, rather than refusing the new
117
+ one: the newest message is the one the user just caused, so it is
118
+ the one that must be visible.
119
+ */
120
+ const next = [...this.items, item].slice(-MAX_VISIBLE);
121
+ const dropped = this.items.filter((old) => !next.includes(old));
122
+ dropped.forEach((old) => this.clearTimer(old.id));
123
+ this.items = next;
124
+ this.leaving = [...this.leaving, ...dropped];
125
+ this.restartTimer(item.id, duration);
126
+ this.announce(item.message, variant);
127
+ }
128
+ clearTimer(id) {
129
+ const timer = this.timers.get(id);
130
+ if (timer) {
131
+ clearTimeout(timer);
132
+ this.timers.delete(id);
133
+ }
134
+ }
135
+ /* A repeat of the same message should get its full time again, not
136
+ inherit whatever was left of the first one's. */
137
+ restartTimer(id, duration) {
138
+ this.clearTimer(id);
139
+ if (duration > 0) {
140
+ this.timers.set(id, setTimeout(() => this.dismiss(id), duration));
141
+ }
142
+ }
143
+ /*
144
+ Cleared first, then written on the next render. A live region only
145
+ speaks when its text CHANGES, so the same message twice in a row
146
+ ("Saved", "Saved") would otherwise be heard once.
147
+ */
148
+ announce(message, variant) {
149
+ const key = variant === "danger" ? "alertText" : "politeText";
150
+ this[key] = "";
151
+ this.updateComplete.then(() => {
152
+ this[key] = message;
153
+ });
154
+ }
155
+ /*
156
+ A toast the pointer or focus is on stays until they leave it. Four
157
+ seconds is not long enough for everyone to read a message, and one
158
+ that vanishes while you are reaching for its Dismiss button is worse.
159
+ */
160
+ hold(id) {
161
+ this.clearTimer(id);
162
+ }
163
+ release(item) {
164
+ if (this.items.includes(item))
165
+ this.restartTimer(item.id, item.duration);
166
+ }
167
+ dismiss(id) {
168
+ this.clearTimer(id);
169
+ const gone = this.items.find((item) => item.id === id);
170
+ this.items = this.items.filter((item) => item.id !== id);
171
+ if (gone)
172
+ this.leaving = [...this.leaving, gone];
173
+ // The live regions stay on the page, so empty them too. Otherwise a
174
+ // screen-reader user reading the page later meets a message for
175
+ // something that has already gone away.
176
+ if (gone && this.politeText === gone.message)
177
+ this.politeText = "";
178
+ if (gone && this.alertText === gone.message)
179
+ this.alertText = "";
180
+ }
181
+ static { this.styles = [srOnly, css `
182
+ /* The browser's own [hidden] rule loses to any :host display, so a
183
+ hidden element would still show. Important, so it always wins. */
184
+ :host([hidden]) {
185
+ display: none !important;
186
+ }
187
+
188
+ :host {
189
+ position: fixed;
190
+ z-index: var(--tt-z-toast);
191
+
192
+ display: flex;
193
+ flex-direction: column;
194
+ gap: var(--tt-space-2);
195
+
196
+ /* The container spans the edge but must not swallow clicks on the
197
+ page behind it. Individual toasts opt back in. */
198
+ pointer-events: none;
199
+
200
+ font-family: var(--tt-font-sans);
201
+ }
202
+
203
+ :host([position="bottom-right"]) {
204
+ /* Clear of the home indicator on a phone. */
205
+ bottom: calc(var(--tt-space-5) + env(safe-area-inset-bottom));
206
+ right: var(--tt-space-5);
207
+ align-items: flex-end;
208
+ }
209
+
210
+ :host([position="bottom-center"]) {
211
+ bottom: calc(var(--tt-space-5) + env(safe-area-inset-bottom));
212
+ left: 50%;
213
+ transform: translateX(-50%);
214
+ align-items: center;
215
+ }
216
+
217
+ :host([position="top-right"]) {
218
+ /* Clear of the notch. */
219
+ top: calc(var(--tt-space-5) + env(safe-area-inset-top));
220
+ right: var(--tt-space-5);
221
+ align-items: flex-end;
222
+ }
223
+
224
+ :host([position="top-center"]) {
225
+ top: calc(var(--tt-space-5) + env(safe-area-inset-top));
226
+ left: 50%;
227
+ transform: translateX(-50%);
228
+ align-items: center;
229
+ }
230
+
231
+ /*
232
+ On a phone every toast goes to the TOP, whatever position says. At
233
+ the bottom it sits over the action bar or dock that triggered it,
234
+ under the thumb that is about to press the next button, so the
235
+ message blocks the work it is reporting on. A desktop keeps the
236
+ corner the app asked for.
237
+ */
238
+ @media (max-width: 768px) {
239
+ :host([position="bottom-right"]),
240
+ :host([position="bottom-center"]) {
241
+ bottom: auto;
242
+ top: calc(var(--tt-space-3) + env(safe-area-inset-top));
243
+ }
244
+ }
245
+
246
+ /* Quiet: it is a repetition marker, not part of the message. */
247
+ .count {
248
+ flex: 0 0 auto;
249
+ align-self: center;
250
+ font-size: var(--tt-text-xs);
251
+ font-variant-numeric: tabular-nums;
252
+ color: var(--tt-muted-foreground);
253
+ }
254
+
255
+ .toast,
256
+ .leaving {
257
+ pointer-events: auto;
258
+
259
+ display: flex;
260
+ align-items: flex-start;
261
+ gap: var(--tt-space-3);
262
+
263
+ max-width: 360px;
264
+ box-sizing: border-box;
265
+
266
+ padding: var(--tt-space-3) var(--tt-space-4);
267
+
268
+ border: 1px solid var(--tt-border);
269
+ border-left: 3px solid var(--_accent, var(--tt-border));
270
+ border-radius: var(--tt-radius);
271
+
272
+ background: var(--tt-popover);
273
+ color: var(--tt-popover-foreground);
274
+
275
+ box-shadow: var(--tt-elevation-2);
276
+
277
+ font-size: var(--tt-text-sm);
278
+ line-height: var(--tt-leading-normal);
279
+
280
+ transition:
281
+ opacity var(--tt-duration-slow) var(--tt-ease-out),
282
+ translate var(--tt-duration-slow) var(--tt-ease-out),
283
+ scale var(--tt-duration-slow) var(--tt-ease-out);
284
+ }
285
+
286
+ /*
287
+ In: rises from just below as it is first drawn. Out: shrinks a
288
+ touch and fades, the same in every corner, quicker and accelerating
289
+ away. Click-through while it goes, so the page underneath is never
290
+ blocked by a toast that is already leaving. Reduced motion is the
291
+ 1ms durations in tokens.css.
292
+ */
293
+ @starting-style {
294
+ .toast {
295
+ opacity: 0;
296
+ translate: 0 8px;
297
+ }
298
+ }
299
+
300
+ .leaving {
301
+ opacity: 0;
302
+ scale: 0.96;
303
+ pointer-events: none;
304
+
305
+ transition-duration: var(--tt-duration-normal);
306
+ transition-timing-function: var(--tt-ease-in);
307
+ }
308
+
309
+ .success { --_accent: var(--tt-success); }
310
+ .warning { --_accent: var(--tt-warning); }
311
+ .danger { --_accent: var(--tt-destructive); }
312
+
313
+ .message {
314
+ flex: 1;
315
+ min-width: 0;
316
+ overflow-wrap: anywhere;
317
+ }
318
+
319
+ .close {
320
+ flex: 0 0 auto;
321
+
322
+ width: 20px;
323
+ height: 20px;
324
+ padding: 0;
325
+ margin: -2px -4px 0 0;
326
+
327
+ border: none;
328
+ background: transparent;
329
+ color: var(--tt-muted-foreground);
330
+
331
+ font: inherit;
332
+ font-size: var(--tt-text-sm);
333
+ line-height: 1;
334
+ cursor: pointer;
335
+ border-radius: var(--tt-radius-sm);
336
+ }
337
+
338
+ .close:hover {
339
+ color: var(--tt-foreground);
340
+ }
341
+
342
+ .close:focus-visible {
343
+ outline: var(--tt-ring-width) solid var(--tt-ring);
344
+ outline-offset: var(--tt-ring-offset);
345
+ }
346
+
347
+ `]; }
348
+ render() {
349
+ return html `
350
+ <!--
351
+ TWO LIVE REGIONS that are always on the page, and the toasts
352
+ themselves are not live at all.
353
+
354
+ Each toast used to be its own role="status", created already
355
+ holding its message. A screen reader watches a live region for
356
+ CHANGES, and a region that arrives with its text in it has not
357
+ changed, so NVDA and VoiceOver regularly said nothing. These two
358
+ exist from the start and only their text changes.
359
+
360
+ Polite for most messages: a "Saved" should not interrupt what is
361
+ being read. Assertive (role="alert") for danger, which should.
362
+ -->
363
+ <div class="sr-only" role="status">${this.politeText}</div>
364
+ <div class="sr-only" role="alert">${this.alertText}</div>
365
+
366
+ <!--
367
+ Keyed by id, and in id order with the leaving ones still in their
368
+ place. Without the key Lit reuses nodes by POSITION: dismissing the
369
+ first toast would hand its node to the second and play the exit on
370
+ the wrong message.
371
+ -->
372
+ ${repeat([...this.items, ...this.leaving].sort((a, b) => a.id - b.id), (item) => item.id, (item) => html `
373
+ <div
374
+ class="${this.leaving.includes(item) ? "leaving" : "toast"} ${item.variant}"
375
+ data-toast=${item.id}
376
+ ?inert=${this.leaving.includes(item)}
377
+ @mouseenter=${() => this.hold(item.id)}
378
+ @mouseleave=${() => this.release(item)}
379
+ @focusin=${() => this.hold(item.id)}
380
+ @focusout=${() => this.release(item)}
381
+ >
382
+ <span class="message">${item.message}</span>
383
+
384
+ <!-- Only past one. "x1" on every toast would be noise. -->
385
+ ${item.count > 1
386
+ ? html `<span class="count" aria-hidden="true"
387
+ >&times;${item.count}</span
388
+ >`
389
+ : nothing}
390
+
391
+ <button
392
+ class="close"
393
+ aria-label="Dismiss"
394
+ @click=${() => this.dismiss(item.id)}
395
+ >
396
+ <tt-icon name="x" size="16px"></tt-icon>
397
+ </button>
398
+ </div>
399
+ `)}
400
+ `;
401
+ }
402
+ };
403
+ __decorate([
404
+ property({ type: String, reflect: true })
405
+ ], TTToast.prototype, "position", void 0);
406
+ __decorate([
407
+ state()
408
+ ], TTToast.prototype, "items", void 0);
409
+ __decorate([
410
+ state()
411
+ ], TTToast.prototype, "leaving", void 0);
412
+ __decorate([
413
+ state()
414
+ ], TTToast.prototype, "politeText", void 0);
415
+ __decorate([
416
+ state()
417
+ ], TTToast.prototype, "alertText", void 0);
418
+ TTToast = __decorate([
419
+ customElement("tt-toast")
420
+ ], TTToast);
421
+ export { TTToast };
422
+ // Every mounted tt-toast, so the helper below can find one without the
423
+ // caller holding a reference.
424
+ const registry = new Set();
425
+ /**
426
+ * Show a toast from anywhere:
427
+ *
428
+ * toast({ message: "Request posted", variant: "success" });
429
+ *
430
+ * Requires a <tt-toast> mounted somewhere in the page.
431
+ */
432
+ export function toast(options) {
433
+ const target = registry.values().next().value;
434
+ if (!target) {
435
+ console.warn("toast() called but no <tt-toast> is mounted.");
436
+ return;
437
+ }
438
+ target.show(options);
439
+ }
440
+ //# sourceMappingURL=tt-toast.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tt-toast.js","sourceRoot":"","sources":["../src/tt-toast.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,MAAM,0BAA0B,CAAC;AAElD,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,cAAc,CAAC;AAmBtB,IAAI,OAAO,GAAG,CAAC,CAAC;AAEhB;;;;;;;EAOE;AACF,MAAM,WAAW,GAAG,CAAC,CAAC;AAEtB;;;;;GAKG;AAEI,IAAM,OAAO,GAAb,MAAM,OAAQ,SAAQ,UAAU;IAAhC;;QACL;;;;;;;;;;;;;UAaE;QAEF,aAAQ,GACN,WAAW,CAAC;QAEG,UAAK,GAAgB,EAAE,CAAC;QAEzC;;;;;UAKE;QACe,YAAO,GAAgB,EAAE,CAAC;QACnC,UAAK,GAAG,IAAI,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,CAAC,IAAI,CAAA;4BACQ,IAAI,CAAC,KAAK;kBACpB;YACJ,CAAC,CAAC,OAAO;;;;;uBAKA,GAAG,EAAE,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC;;;;;SAKzC,CACF;KACF,CAAC;IACJ,CAAC;;AAzYD;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;yCAE5B;AAEG;IAAhB,KAAK,EAAE;sCAAiC;AAQxB;IAAhB,KAAK,EAAE;wCAAmC;AAM1B;IAAhB,KAAK,EAAE;2CAAyB;AAChB;IAAhB,KAAK,EAAE;0CAAwB;AAlCrB,OAAO;IADnB,aAAa,CAAC,UAAU,CAAC;GACb,OAAO,CA0ZnB;;AAED,uEAAuE;AACvE,8BAA8B;AAC9B,MAAM,QAAQ,GAAG,IAAI,GAAG,EAAW,CAAC;AAEpC;;;;;;GAMG;AACH,MAAM,UAAU,KAAK,CAAC,OAAqB;IACzC,MAAM,MAAM,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC;IAE9C,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,OAAO,CAAC,IAAI,CAAC,8CAA8C,CAAC,CAAC;QAC7D,OAAO;IACT,CAAC;IAED,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACvB,CAAC"}
@@ -0,0 +1,73 @@
1
+ import { LitElement } from "lit";
2
+ import type { PropertyValues } from "lit";
3
+ import "./tt-toggle.js";
4
+ export type ToggleGroupType = "single" | "multiple";
5
+ /**
6
+ * A row of tt-toggle that agree with each other.
7
+ *
8
+ * ---------------------------------------------------------------------
9
+ * `values` IS ALWAYS AN ARRAY, EVEN IN SINGLE MODE.
10
+ *
11
+ * The obvious API is `value: string` for single and `values: string[]`
12
+ * for multiple, which is what most libraries do. It is rejected here.
13
+ *
14
+ * A property whose TYPE depends on another property is a property you
15
+ * have to think about at every call site, and it makes the change event
16
+ * carry two shapes as well. Every consumer then needs a branch, and half
17
+ * of them will forget it.
18
+ *
19
+ * One shape instead: a single-select group holds an array of zero or one
20
+ * entries. `values[0] ?? null` is the whole cost, paid once by whoever
21
+ * actually wants a scalar, and `tt-change` always carries the complete
22
+ * new array. Same contract as tt-checkbox-group.
23
+ *
24
+ * ---------------------------------------------------------------------
25
+ * WHO OWNS THE SELECTION.
26
+ *
27
+ * Both. `values` comes in, and `tt-change` goes out with the whole new
28
+ * set. The group also keeps that new set itself (Oct 2026). It used to
29
+ * store nothing and wait for the page to echo `values` back, which
30
+ * meant a group with no listener (a pasted snippet, a generated
31
+ * component) started every click from the old set: `multiple` acted
32
+ * like single, and `allow-empty` cleared instead of selecting. A page
33
+ * that sets `values` still wins, the same as with a native input.
34
+ *
35
+ * But it does WRITE to its children, immediately, in its own handler,
36
+ * rather than waiting for the page to echo `values` back. That is the
37
+ * one thing worth understanding here.
38
+ *
39
+ * A tt-toggle flips itself when clicked. In single mode that leaves two
40
+ * pressed toggles for as long as it takes the page to respond, and if
41
+ * the page ignores the event it leaves them pressed forever. So the
42
+ * group corrects its children on the spot: the click is the child's, the
43
+ * ANSWER is the group's.
44
+ *
45
+ * That makes it work whether or not the page echoes the value back, and
46
+ * `updated()` re-applies the same result when it does, which is
47
+ * idempotent (applying it twice is the same as applying it once).
48
+ */
49
+ export declare class TTToggleGroup extends LitElement {
50
+ multiple: boolean;
51
+ /** The older spelling of `multiple`; type="multiple" still works. */
52
+ type: ToggleGroupType;
53
+ values: string[];
54
+ disabled: boolean;
55
+ label: string;
56
+ detached: boolean;
57
+ private toggles;
58
+ allowEmpty: boolean;
59
+ private handleChange;
60
+ /** Writes a selection onto every child. Safe to call repeatedly. */
61
+ private disabledByGroup;
62
+ private applyTo;
63
+ updated(changed: PropertyValues): void;
64
+ private handleSlotChange;
65
+ static styles: import("lit").CSSResult;
66
+ render(): import("lit-html").TemplateResult<1>;
67
+ }
68
+ declare global {
69
+ interface HTMLElementTagNameMap {
70
+ "tt-toggle-group": TTToggleGroup;
71
+ }
72
+ }
73
+ //# sourceMappingURL=tt-toggle-group.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tt-toggle-group.d.ts","sourceRoot":"","sources":["../src/tt-toggle-group.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAC;AAQ1C,OAAO,gBAAgB,CAAC;AAExB,MAAM,MAAM,eAAe,GAAG,QAAQ,GAAG,UAAU,CAAC;AAEpD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2CG;AACH,qBACa,aAAc,SAAQ,UAAU;IAQC,QAAQ,UAAS;IAE7D,qEAAqE;IAC1B,IAAI,EAAE,eAAe,CAAY;IAEjD,MAAM,EAAE,MAAM,EAAE,CAAM;IAEL,QAAQ,UAAS;IAOjC,KAAK,SAAM;IAWV,QAAQ,UAAS;IAG9C,OAAO,CAAC,OAAO,CAAc;IAO0B,UAAU,UAAS;IAE1E,OAAO,CAAC,YAAY;IA6CpB,oEAAoE;IAUpE,OAAO,CAAC,eAAe,CAA2B;IAElD,OAAO,CAAC,OAAO;IAcf,OAAO,CAAC,OAAO,EAAE,cAAc;IAS/B,OAAO,CAAC,gBAAgB;IAIxB,MAAM,CAAC,MAAM,0BAiEX;IAEF,MAAM;CAaP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,iBAAiB,EAAE,aAAa,CAAC;KAClC;CACF"}