@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,409 @@
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 } from "lit";
8
+ import { customElement, property, state } from "lit/decorators.js";
9
+ import { unsafeHTML } from "lit/directives/unsafe-html.js";
10
+ import { srOnly } from "./sr-only.js";
11
+ import Prism from "prismjs";
12
+ import "prismjs/components/prism-typescript";
13
+ import "prismjs/components/prism-javascript";
14
+ import "prismjs/components/prism-css";
15
+ import "prismjs/components/prism-json";
16
+ import "prismjs/components/prism-markup"; // HTML
17
+ import "./tt-icon.js";
18
+ let TTCodeBlock = class TTCodeBlock extends LitElement {
19
+ constructor() {
20
+ super(...arguments);
21
+ this.code = "";
22
+ this.language = "";
23
+ this.filename = "";
24
+ // Opt-in, like show-value on tt-progress, tt-rating and tt-slider.
25
+ this.showLineNumbers = false;
26
+ this.tabs = [];
27
+ this.activeTabIndex = 0;
28
+ this.copied = false;
29
+ }
30
+ disconnectedCallback() {
31
+ clearTimeout(this.copyTimer);
32
+ super.disconnectedCallback();
33
+ }
34
+ get currentCode() {
35
+ if (this.tabs.length > 0) {
36
+ return this.tabs[this.activeTabIndex]?.code ?? "";
37
+ }
38
+ return this.code;
39
+ }
40
+ get currentLanguage() {
41
+ if (this.tabs.length > 0) {
42
+ return this.tabs[this.activeTabIndex]?.language ?? this.language;
43
+ }
44
+ return this.language;
45
+ }
46
+ // Highlighting happens during render rather than by poking innerHTML in
47
+ // updated(), so the markup is correct on first paint and Lit stays in
48
+ // charge of the DOM.
49
+ get highlighted() {
50
+ const lang = this.currentLanguage.toLowerCase();
51
+ const grammar = Prism.languages[lang] ??
52
+ Prism.languages.clike ??
53
+ Prism.languages.markup;
54
+ return Prism.highlight(this.currentCode.trim(), grammar, lang);
55
+ }
56
+ async copyCode() {
57
+ try {
58
+ await navigator.clipboard.writeText(this.currentCode);
59
+ this.copied = true;
60
+ clearTimeout(this.copyTimer);
61
+ this.copyTimer = setTimeout(() => {
62
+ this.copied = false;
63
+ }, 2000);
64
+ }
65
+ catch {
66
+ // Clipboard access can be denied (insecure context, permissions).
67
+ // Failing silently is better than throwing out of an event handler.
68
+ }
69
+ }
70
+ renderLineNumbers() {
71
+ if (!this.showLineNumbers)
72
+ return null;
73
+ const lineCount = this.currentCode.trim().split("\n").length;
74
+ return html `
75
+ <div class="line-numbers" aria-hidden="true">
76
+ ${Array.from({ length: lineCount }, (_, i) => html `<span>${i + 1}</span>`)}
77
+ </div>
78
+ `;
79
+ }
80
+ static { this.styles = [srOnly, css `
81
+ /* The browser's own [hidden] rule loses to any :host display, so a
82
+ hidden element would still show. Important, so it always wins. */
83
+ :host([hidden]) {
84
+ display: none !important;
85
+ }
86
+
87
+ /*
88
+ The code surface is intentionally theme-independent: it stays dark in
89
+ both light and dark mode so one syntax palette stays readable.
90
+ Override the --tt-code-* tokens for a light code surface.
91
+ */
92
+ :host {
93
+ display: block;
94
+ font-family: var(--tt-font-sans);
95
+ }
96
+
97
+ .container {
98
+ overflow: hidden;
99
+ background: var(--tt-code-background);
100
+ border: 1px solid var(--tt-code-border);
101
+ border-radius: var(--tt-radius-lg);
102
+ }
103
+
104
+ /* Header */
105
+
106
+ .header {
107
+ height: 42px;
108
+ display: flex;
109
+ align-items: center;
110
+ justify-content: space-between;
111
+ padding: 0 var(--tt-space-3) 0 var(--tt-space-4);
112
+ background: var(--tt-code-surface);
113
+ border-bottom: 1px solid var(--tt-code-border);
114
+ }
115
+
116
+ /* min-width: 0 lets this side shrink and scroll beside the copy
117
+ button; without it a flex item will not shrink below its content,
118
+ so on a phone the tabs wrapped and slid under the button. */
119
+ .header-left {
120
+ display: flex;
121
+ align-items: center;
122
+ gap: var(--tt-space-3);
123
+ min-width: 0;
124
+ overflow-x: auto;
125
+ }
126
+
127
+ /* Decorative window buttons */
128
+
129
+ .window-dots {
130
+ display: flex;
131
+ gap: 6px;
132
+ }
133
+
134
+ .window-dot {
135
+ width: 10px;
136
+ height: 10px;
137
+ border-radius: var(--tt-radius-full);
138
+ }
139
+
140
+ .window-dot.close { background: #ff5f56; }
141
+ .window-dot.minimize { background: #ffbd2e; }
142
+ .window-dot.maximize { background: #27c93f; }
143
+
144
+ /* File tabs */
145
+
146
+ .tabs {
147
+ display: flex;
148
+ gap: 4px;
149
+ white-space: nowrap;
150
+ }
151
+
152
+ .tab {
153
+ background: transparent;
154
+ border: none;
155
+ color: var(--tt-code-muted);
156
+ padding: 4px 10px;
157
+ font-family: inherit;
158
+ font-size: var(--tt-text-xs);
159
+ font-weight: var(--tt-weight-medium);
160
+ border-radius: var(--tt-radius);
161
+ cursor: pointer;
162
+ transition:
163
+ color var(--tt-duration-normal) var(--tt-ease),
164
+ background var(--tt-duration-normal) var(--tt-ease);
165
+ }
166
+
167
+ .tab:hover {
168
+ color: var(--tt-code-foreground);
169
+ background: rgb(255 255 255 / 0.05);
170
+ }
171
+
172
+ .tab.active {
173
+ color: var(--tt-code-foreground);
174
+ background: rgb(255 255 255 / 0.1);
175
+ }
176
+
177
+ .tab:focus-visible {
178
+ outline: var(--tt-ring-width) solid var(--tt-code-muted);
179
+ outline-offset: calc(var(--tt-ring-width) * -1);
180
+ }
181
+
182
+ .meta-info {
183
+ font-size: var(--tt-text-xs);
184
+ font-weight: var(--tt-weight-semibold);
185
+ letter-spacing: 0.04em;
186
+ color: var(--tt-code-muted);
187
+ text-transform: uppercase;
188
+ }
189
+
190
+ /* Copy button */
191
+
192
+ .copy-btn {
193
+ display: inline-flex;
194
+ align-items: center;
195
+ gap: 6px;
196
+ border: 1px solid var(--tt-code-border);
197
+ background: rgb(255 255 255 / 0.03);
198
+ color: var(--tt-code-foreground);
199
+ cursor: pointer;
200
+ font-family: inherit;
201
+ font-size: var(--tt-text-xs);
202
+ font-weight: var(--tt-weight-medium);
203
+ padding: 4px 10px;
204
+ border-radius: var(--tt-radius);
205
+ transition:
206
+ background var(--tt-duration-normal) var(--tt-ease),
207
+ border-color var(--tt-duration-normal) var(--tt-ease);
208
+ }
209
+
210
+ .copy-btn:hover {
211
+ background: rgb(255 255 255 / 0.08);
212
+ border-color: var(--tt-code-muted);
213
+ }
214
+
215
+ .copy-btn:focus-visible {
216
+ outline: var(--tt-ring-width) solid var(--tt-code-muted);
217
+ outline-offset: var(--tt-ring-offset);
218
+ }
219
+
220
+ .copy-btn.copied {
221
+ border-color: #2ea043;
222
+ color: #3fb950;
223
+ background: rgb(46 160 67 / 0.1);
224
+ }
225
+
226
+ /* Code body */
227
+
228
+ .code-viewport {
229
+ display: flex;
230
+ position: relative;
231
+ overflow-x: auto;
232
+ }
233
+
234
+ .line-numbers {
235
+ display: flex;
236
+ flex-direction: column;
237
+ padding: var(--tt-space-4) 0 var(--tt-space-4) var(--tt-space-4);
238
+ font-family: var(--tt-font-mono);
239
+ font-size: 13px;
240
+ line-height: var(--tt-leading-relaxed);
241
+ color: var(--tt-code-muted);
242
+ opacity: 0.5;
243
+ user-select: none;
244
+ text-align: right;
245
+ min-width: 24px;
246
+ }
247
+
248
+ pre {
249
+ margin: 0;
250
+ padding: var(--tt-space-4);
251
+ flex-grow: 1;
252
+ overflow-x: auto;
253
+ font-family: var(--tt-font-mono);
254
+ font-size: 13px;
255
+ line-height: var(--tt-leading-relaxed);
256
+ color: var(--tt-code-foreground);
257
+ tab-size: 2;
258
+ }
259
+
260
+ code {
261
+ font-family: inherit;
262
+ }
263
+
264
+ /* Prism tokens */
265
+
266
+ .token.comment,
267
+ .token.prolog,
268
+ .token.doctype,
269
+ .token.cdata {
270
+ color: var(--tt-code-comment);
271
+ font-style: italic;
272
+ }
273
+
274
+ .token.punctuation { color: var(--tt-code-punctuation); }
275
+
276
+ .token.property,
277
+ .token.tag,
278
+ .token.boolean,
279
+ .token.number,
280
+ .token.constant,
281
+ .token.symbol { color: var(--tt-code-constant); }
282
+
283
+ .token.selector,
284
+ .token.attr-name,
285
+ .token.string,
286
+ .token.char,
287
+ .token.builtin { color: var(--tt-code-string); }
288
+
289
+ .token.operator,
290
+ .token.entity,
291
+ .token.url,
292
+ .token.variable { color: var(--tt-code-operator); }
293
+
294
+ .token.atrule,
295
+ .token.attr-value,
296
+ .token.keyword { color: var(--tt-code-keyword); }
297
+
298
+ .token.function,
299
+ .token.class-name { color: var(--tt-code-function); }
300
+
301
+ .token.regex,
302
+ .token.important { color: var(--tt-code-regex); }
303
+
304
+ /* Scrollbars */
305
+
306
+ pre::-webkit-scrollbar,
307
+ .code-viewport::-webkit-scrollbar {
308
+ height: 8px;
309
+ width: 8px;
310
+ }
311
+
312
+ pre::-webkit-scrollbar-thumb,
313
+ .code-viewport::-webkit-scrollbar-thumb {
314
+ background: var(--tt-code-border);
315
+ border-radius: var(--tt-radius-sm);
316
+ }
317
+
318
+ `]; }
319
+ render() {
320
+ const hasTabs = this.tabs.length > 0;
321
+ return html `
322
+ <div class="container" part="container">
323
+ <div class="header" part="header">
324
+ <div class="header-left">
325
+ <div class="window-dots" aria-hidden="true">
326
+ <span class="window-dot close"></span>
327
+ <span class="window-dot minimize"></span>
328
+ <span class="window-dot maximize"></span>
329
+ </div>
330
+
331
+ ${hasTabs
332
+ ? html `
333
+ <!--
334
+ Toggle buttons, not tabs. role="tab" promises arrow keys, one
335
+ Tab stop and a tabpanel, and none of those existed, so a screen
336
+ reader announced a tab list that did not behave like one.
337
+ aria-pressed is the honest name for "one of these is on".
338
+ -->
339
+ <div class="tabs" role="group" aria-label="Files">
340
+ ${this.tabs.map((tab, index) => html `
341
+ <button
342
+ class="tab ${this.activeTabIndex === index
343
+ ? "active"
344
+ : ""}"
345
+ type="button"
346
+ aria-pressed=${this.activeTabIndex === index
347
+ ? "true"
348
+ : "false"}
349
+ @click=${() => (this.activeTabIndex = index)}
350
+ >
351
+ ${tab.label || tab.language || `Tab ${index + 1}`}
352
+ </button>
353
+ `)}
354
+ </div>
355
+ `
356
+ : html `
357
+ <span class="meta-info">
358
+ ${this.filename ? this.filename : this.currentLanguage}
359
+ </span>
360
+ `}
361
+ </div>
362
+
363
+ <button
364
+ part="copy"
365
+ class="copy-btn ${this.copied ? "copied" : ""}"
366
+ @click=${this.copyCode}
367
+ aria-label="Copy code to clipboard"
368
+ >
369
+ ${this.copied
370
+ ? html `<tt-icon name="check" size="12px"></tt-icon> Copied`
371
+ : "Copy"}
372
+ </button>
373
+ <span class="sr-only" role="status">${this.copied ? "Copied" : ""}</span>
374
+ </div>
375
+
376
+ <div class="code-viewport">
377
+ ${this.renderLineNumbers()}
378
+ <pre part="code"><code>${unsafeHTML(this.highlighted)}</code></pre>
379
+ </div>
380
+ </div>
381
+ `;
382
+ }
383
+ };
384
+ __decorate([
385
+ property({ type: String })
386
+ ], TTCodeBlock.prototype, "code", void 0);
387
+ __decorate([
388
+ property({ type: String })
389
+ ], TTCodeBlock.prototype, "language", void 0);
390
+ __decorate([
391
+ property({ type: String })
392
+ ], TTCodeBlock.prototype, "filename", void 0);
393
+ __decorate([
394
+ property({ type: Boolean, attribute: "show-line-numbers" })
395
+ ], TTCodeBlock.prototype, "showLineNumbers", void 0);
396
+ __decorate([
397
+ property({ type: Array })
398
+ ], TTCodeBlock.prototype, "tabs", void 0);
399
+ __decorate([
400
+ state()
401
+ ], TTCodeBlock.prototype, "activeTabIndex", void 0);
402
+ __decorate([
403
+ state()
404
+ ], TTCodeBlock.prototype, "copied", void 0);
405
+ TTCodeBlock = __decorate([
406
+ customElement("tt-code-block")
407
+ ], TTCodeBlock);
408
+ export { TTCodeBlock };
409
+ //# sourceMappingURL=tt-code-block.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tt-code-block.js","sourceRoot":"","sources":["../src/tt-code-block.ts"],"names":[],"mappings":";;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AACnE,OAAO,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAC3D,OAAO,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,MAAM,SAAS,CAAC;AAE5B,OAAO,qCAAqC,CAAC;AAC7C,OAAO,qCAAqC,CAAC;AAC7C,OAAO,8BAA8B,CAAC;AACtC,OAAO,+BAA+B,CAAC;AACvC,OAAO,iCAAiC,CAAC,CAAC,OAAO;AAEjD,OAAO,cAAc,CAAC;AASf,IAAM,WAAW,G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I,EAAE,MAAM,EAAE,CAAC;6CAAe;AACd;IAA3B,QAAQ,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;6CAAe;AAG1C;IADC,QAAQ,CAAC,EAAE,IAAI,EAAE,OAAO,EAAE,SAAS,EAAE,mBAAmB,EAAE,CAAC;oDACpC;AACG;IAA1B,QAAQ,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;yCAAsB;AAE/B;IAAhB,KAAK,EAAE;mDAA4B;AACnB;IAAhB,KAAK,EAAE;2CAAwB;AAVrB,WAAW;IADvB,aAAa,CAAC,eAAe,CAAC;GAClB,WAAW,CAgYvB"}
@@ -0,0 +1,71 @@
1
+ import { LitElement } from "lit";
2
+ /**
3
+ * One section that opens and closes. The plainest member of a family of
4
+ * three, and the differences matter:
5
+ *
6
+ * tt-collapsible ONE section, no heading of its own, no styling.
7
+ * You supply the trigger. Use it to hide detail
8
+ * inside something else: "show 3 more", an advanced
9
+ * block in a form, a nested panel.
10
+ * tt-accordion-item a section WITH a styled heading button, meant to
11
+ * sit in a tt-accordion that coordinates siblings.
12
+ * tt-menu-group the sidebar's version, with its own uppercase
13
+ * heading and rail behaviour.
14
+ *
15
+ * Reach for this one when you already have something to click and only
16
+ * need the opening part.
17
+ *
18
+ * ---------------------------------------------------------------------
19
+ * IT OWNS ITS OWN `open`, and that is deliberate.
20
+ *
21
+ * The house rule is that a component reports intent and the owner
22
+ * decides, which is why tt-accordion-item refuses to open itself: an
23
+ * accordion may need to close a sibling first, so the decision is not
24
+ * the item's to make.
25
+ *
26
+ * Nothing coordinates a collapsible. There is no sibling to close and no
27
+ * parent to ask, so a component that would not open itself would need a
28
+ * listener on every single use to do the one thing it is for. It flips
29
+ * and then announces, the same shape as tt-switch and tt-menu-group.
30
+ *
31
+ * Set `open` from outside whenever you do want to own it; the property
32
+ * is the source of truth either way.
33
+ *
34
+ * ---------------------------------------------------------------------
35
+ * THE HEIGHT ANIMATION.
36
+ *
37
+ * A grid track from 0fr to 1fr, because nothing here knows how tall the
38
+ * content is and every max-height guess is either too small, which
39
+ * clips, or too large, which makes the close look slow and the open look
40
+ * late.
41
+ *
42
+ * The `overflow: hidden` on the inner element is NOT decoration. An fr
43
+ * track keeps an automatic minimum equal to its content unless the item
44
+ * inside opts out of it, so without that line the panel never collapses
45
+ * at all. That exact bug shipped in tt-menu-group and hid behind an
46
+ * opacity fade for a week.
47
+ *
48
+ * The events, for the custom-elements manifest. Its analyzer reads event
49
+ * names from string literals at the dispatch site, and these are chosen at
50
+ * run time, so without the tags the manifest listed a bogus event instead.
51
+ * @fires tt-toggle - { open } on every change.
52
+ * @fires tt-open - When it expands.
53
+ * @fires tt-close - When it collapses.
54
+ */
55
+ export declare class TTCollapsible extends LitElement {
56
+ open: boolean;
57
+ disabled: boolean;
58
+ /** Flips it and announces. The same call the trigger makes. */
59
+ toggle(): void;
60
+ private wireTrigger;
61
+ private markTrigger;
62
+ updated(): void;
63
+ static styles: import("lit").CSSResult;
64
+ render(): import("lit-html").TemplateResult<1>;
65
+ }
66
+ declare global {
67
+ interface HTMLElementTagNameMap {
68
+ "tt-collapsible": TTCollapsible;
69
+ }
70
+ }
71
+ //# sourceMappingURL=tt-collapsible.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tt-collapsible.d.ts","sourceRoot":"","sources":["../src/tt-collapsible.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAa,MAAM,KAAK,CAAC;AAG5C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AACH,qBACa,aAAc,SAAQ,UAAU;IACC,IAAI,UAAS;IAEb,QAAQ,UAAS;IAE7D,+DAA+D;IAC/D,MAAM;IAyCN,OAAO,CAAC,WAAW;IAYnB,OAAO,CAAC,WAAW;IAUnB,OAAO;IAYP,MAAM,CAAC,MAAM,0BAwCX;IAEF,MAAM;CAoBP;AAED,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,qBAAqB;QAC7B,gBAAgB,EAAE,aAAa,CAAC;KACjC;CACF"}
@@ -0,0 +1,206 @@
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 } from "lit";
8
+ import { property, customElement } from "lit/decorators.js";
9
+ /**
10
+ * One section that opens and closes. The plainest member of a family of
11
+ * three, and the differences matter:
12
+ *
13
+ * tt-collapsible ONE section, no heading of its own, no styling.
14
+ * You supply the trigger. Use it to hide detail
15
+ * inside something else: "show 3 more", an advanced
16
+ * block in a form, a nested panel.
17
+ * tt-accordion-item a section WITH a styled heading button, meant to
18
+ * sit in a tt-accordion that coordinates siblings.
19
+ * tt-menu-group the sidebar's version, with its own uppercase
20
+ * heading and rail behaviour.
21
+ *
22
+ * Reach for this one when you already have something to click and only
23
+ * need the opening part.
24
+ *
25
+ * ---------------------------------------------------------------------
26
+ * IT OWNS ITS OWN `open`, and that is deliberate.
27
+ *
28
+ * The house rule is that a component reports intent and the owner
29
+ * decides, which is why tt-accordion-item refuses to open itself: an
30
+ * accordion may need to close a sibling first, so the decision is not
31
+ * the item's to make.
32
+ *
33
+ * Nothing coordinates a collapsible. There is no sibling to close and no
34
+ * parent to ask, so a component that would not open itself would need a
35
+ * listener on every single use to do the one thing it is for. It flips
36
+ * and then announces, the same shape as tt-switch and tt-menu-group.
37
+ *
38
+ * Set `open` from outside whenever you do want to own it; the property
39
+ * is the source of truth either way.
40
+ *
41
+ * ---------------------------------------------------------------------
42
+ * THE HEIGHT ANIMATION.
43
+ *
44
+ * A grid track from 0fr to 1fr, because nothing here knows how tall the
45
+ * content is and every max-height guess is either too small, which
46
+ * clips, or too large, which makes the close look slow and the open look
47
+ * late.
48
+ *
49
+ * The `overflow: hidden` on the inner element is NOT decoration. An fr
50
+ * track keeps an automatic minimum equal to its content unless the item
51
+ * inside opts out of it, so without that line the panel never collapses
52
+ * at all. That exact bug shipped in tt-menu-group and hid behind an
53
+ * opacity fade for a week.
54
+ *
55
+ * The events, for the custom-elements manifest. Its analyzer reads event
56
+ * names from string literals at the dispatch site, and these are chosen at
57
+ * run time, so without the tags the manifest listed a bogus event instead.
58
+ * @fires tt-toggle - { open } on every change.
59
+ * @fires tt-open - When it expands.
60
+ * @fires tt-close - When it collapses.
61
+ */
62
+ let TTCollapsible = class TTCollapsible extends LitElement {
63
+ constructor() {
64
+ super(...arguments);
65
+ this.open = false;
66
+ this.disabled = false;
67
+ }
68
+ /** Flips it and announces. The same call the trigger makes. */
69
+ toggle() {
70
+ if (this.disabled)
71
+ return;
72
+ this.open = !this.open;
73
+ this.dispatchEvent(new CustomEvent(this.open ? "tt-open" : "tt-close", {
74
+ bubbles: true,
75
+ composed: true,
76
+ }));
77
+ this.dispatchEvent(new CustomEvent("tt-toggle", {
78
+ detail: { open: this.open },
79
+ bubbles: true,
80
+ composed: true,
81
+ }));
82
+ }
83
+ /*
84
+ The trigger is slotted, so it is the consumer's element and this
85
+ component must not restyle it. All it does is make it work: a click
86
+ toggles, and aria-expanded is written onto whatever was slotted so a
87
+ screen reader is told the state.
88
+
89
+ NO aria-controls, and that is not an omission.
90
+
91
+ aria-controls takes the id of another element, and an id reference
92
+ does not cross a shadow boundary. The panel lives in THIS component's
93
+ shadow root; the trigger lives in the consumer's light DOM. Pointing
94
+ one at the other produces an attribute that resolves to nothing,
95
+ which axe reports as a critical aria-valid-attr-value failure and a
96
+ screen reader simply ignores.
97
+
98
+ Same rule that made tt-accordion-item put aria-expanded on its own
99
+ real button rather than on a wrapper. aria-expanded alone is a
100
+ complete disclosure pattern; aria-controls is optional in it and
101
+ support was always patchy.
102
+ */
103
+ wireTrigger(event) {
104
+ const slot = event.target;
105
+ this.markTrigger(slot.assignedElements({ flatten: true })[0]);
106
+ }
107
+ /*
108
+ A tt-button trigger gets its `expanded` PROPERTY, not the attribute.
109
+ The host of a custom element has no role, so aria-expanded written on
110
+ it reaches nothing: the real <button> is inside tt-button's shadow
111
+ root. tt-button forwards `expanded` to it, the same way it forwards
112
+ `label`.
113
+ */
114
+ markTrigger(el) {
115
+ if (!el)
116
+ return;
117
+ if (el.tagName === "TT-BUTTON") {
118
+ el.expanded = String(this.open);
119
+ el.removeAttribute("aria-expanded");
120
+ }
121
+ else {
122
+ el.setAttribute("aria-expanded", String(this.open));
123
+ }
124
+ }
125
+ updated() {
126
+ /*
127
+ Re-applied on every update rather than only on slotchange, because
128
+ `open` can change without the slot changing, and an aria-expanded
129
+ that says "false" over an open panel is worse than none at all.
130
+ */
131
+ const slot = this.renderRoot.querySelector('slot[name="trigger"]');
132
+ this.markTrigger(slot?.assignedElements({ flatten: true })[0]);
133
+ }
134
+ static { this.styles = css `
135
+ /* The browser's own [hidden] rule loses to any :host display, so a
136
+ hidden element would still show. Important, so it always wins. */
137
+ :host([hidden]) {
138
+ display: none !important;
139
+ }
140
+
141
+ :host {
142
+ display: block;
143
+
144
+ font-family: var(--tt-font-sans);
145
+ -webkit-font-smoothing: antialiased;
146
+ }
147
+
148
+ .trigger {
149
+ display: contents;
150
+ }
151
+
152
+ .content {
153
+ display: grid;
154
+ grid-template-rows: 0fr;
155
+
156
+ transition: grid-template-rows var(--tt-duration-normal)
157
+ var(--tt-ease-out);
158
+ }
159
+
160
+ :host([open]) .content {
161
+ grid-template-rows: 1fr;
162
+ }
163
+
164
+ /* Load-bearing. See the note at the top: without this the fr track
165
+ keeps a content-sized minimum and the panel never closes. */
166
+ .inner {
167
+ overflow: hidden;
168
+ }
169
+
170
+ :host([disabled]) .trigger {
171
+ opacity: var(--tt-opacity-disabled);
172
+ pointer-events: none;
173
+ }
174
+ `; }
175
+ render() {
176
+ return html `
177
+ <div class="trigger" part="trigger" @click=${this.toggle}>
178
+ <slot name="trigger" @slotchange=${this.wireTrigger}></slot>
179
+ </div>
180
+
181
+ <!--
182
+ inert while closed. The panel is squeezed to zero height, which
183
+ hides it from the EYE only: its links and fields stayed in the Tab
184
+ order, so a keyboard user tabbed onto controls they could not see,
185
+ and a screen reader read the closed panel aloud. Same as
186
+ tt-accordion-item.
187
+ -->
188
+ <div class="content" part="content" ?inert=${!this.open}>
189
+ <div class="inner">
190
+ <slot></slot>
191
+ </div>
192
+ </div>
193
+ `;
194
+ }
195
+ };
196
+ __decorate([
197
+ property({ type: Boolean, reflect: true })
198
+ ], TTCollapsible.prototype, "open", void 0);
199
+ __decorate([
200
+ property({ type: Boolean, reflect: true })
201
+ ], TTCollapsible.prototype, "disabled", void 0);
202
+ TTCollapsible = __decorate([
203
+ customElement("tt-collapsible")
204
+ ], TTCollapsible);
205
+ export { TTCollapsible };
206
+ //# sourceMappingURL=tt-collapsible.js.map