@sondor-technology/sondor-components 1.0.9 → 1.0.10

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 (431) hide show
  1. package/dist/components/accordion/accordion.constants.d.ts +5 -0
  2. package/dist/components/accordion/accordion.constants.d.ts.map +1 -0
  3. package/dist/components/accordion/accordion.constants.js +3 -0
  4. package/dist/components/accordion/accordion.constants.js.map +1 -0
  5. package/dist/components/accordion/accordion.d.ts +29 -0
  6. package/dist/components/accordion/accordion.d.ts.map +1 -0
  7. package/dist/components/accordion/accordion.js +226 -0
  8. package/dist/components/accordion/accordion.js.map +1 -0
  9. package/dist/components/alert/alert.constants.d.ts +2 -0
  10. package/dist/components/alert/alert.constants.d.ts.map +1 -1
  11. package/dist/components/alert/alert.d.ts +50 -2
  12. package/dist/components/alert/alert.d.ts.map +1 -1
  13. package/dist/components/alert/alert.js +285 -16
  14. package/dist/components/alert/alert.js.map +1 -1
  15. package/dist/components/avatar/avatar.d.ts +20 -0
  16. package/dist/components/avatar/avatar.d.ts.map +1 -0
  17. package/dist/components/avatar/avatar.js +100 -0
  18. package/dist/components/avatar/avatar.js.map +1 -0
  19. package/dist/components/back-to-top/back-to-top.d.ts +29 -0
  20. package/dist/components/back-to-top/back-to-top.d.ts.map +1 -0
  21. package/dist/components/back-to-top/back-to-top.js +149 -0
  22. package/dist/components/back-to-top/back-to-top.js.map +1 -0
  23. package/dist/components/bar-chart/bar-chart.d.ts +42 -0
  24. package/dist/components/bar-chart/bar-chart.d.ts.map +1 -0
  25. package/dist/components/bar-chart/bar-chart.js +298 -0
  26. package/dist/components/bar-chart/bar-chart.js.map +1 -0
  27. package/dist/components/breadcrumb/breadcrumb.js +2 -2
  28. package/dist/components/button/button.d.ts +1 -0
  29. package/dist/components/button/button.d.ts.map +1 -1
  30. package/dist/components/button/button.js +8 -8
  31. package/dist/components/button/button.js.map +1 -1
  32. package/dist/components/button-group/button-group.js +4 -4
  33. package/dist/components/calendar/calendar.d.ts.map +1 -1
  34. package/dist/components/calendar/calendar.js +11 -9
  35. package/dist/components/calendar/calendar.js.map +1 -1
  36. package/dist/components/chart/chart-base.d.ts +59 -0
  37. package/dist/components/chart/chart-base.d.ts.map +1 -0
  38. package/dist/components/chart/chart-base.js +261 -0
  39. package/dist/components/chart/chart-base.js.map +1 -0
  40. package/dist/components/chart/chart.utils.d.ts +27 -0
  41. package/dist/components/chart/chart.utils.d.ts.map +1 -0
  42. package/dist/components/chart/chart.utils.js +117 -0
  43. package/dist/components/chart/chart.utils.js.map +1 -0
  44. package/dist/components/code-block/code-block.d.ts +5 -0
  45. package/dist/components/code-block/code-block.d.ts.map +1 -1
  46. package/dist/components/code-block/code-block.js +34 -24
  47. package/dist/components/code-block/code-block.js.map +1 -1
  48. package/dist/components/consent/consent.d.ts +63 -0
  49. package/dist/components/consent/consent.d.ts.map +1 -0
  50. package/dist/components/consent/consent.js +327 -0
  51. package/dist/components/consent/consent.js.map +1 -0
  52. package/dist/components/consent/consent.utils.d.ts +36 -0
  53. package/dist/components/consent/consent.utils.d.ts.map +1 -0
  54. package/dist/components/consent/consent.utils.js +82 -0
  55. package/dist/components/consent/consent.utils.js.map +1 -0
  56. package/dist/components/contact/contact.d.ts +22 -0
  57. package/dist/components/contact/contact.d.ts.map +1 -0
  58. package/dist/components/contact/contact.js +83 -0
  59. package/dist/components/contact/contact.js.map +1 -0
  60. package/dist/components/container/container.d.ts +20 -0
  61. package/dist/components/container/container.d.ts.map +1 -0
  62. package/dist/components/container/container.js +68 -0
  63. package/dist/components/container/container.js.map +1 -0
  64. package/dist/components/content-card/content-card.js +4 -4
  65. package/dist/components/context-menu/context-menu.d.ts +89 -0
  66. package/dist/components/context-menu/context-menu.d.ts.map +1 -0
  67. package/dist/components/context-menu/context-menu.js +414 -0
  68. package/dist/components/context-menu/context-menu.js.map +1 -0
  69. package/dist/components/cron-builder/cron-builder.d.ts.map +1 -1
  70. package/dist/components/cron-builder/cron-builder.js +13 -11
  71. package/dist/components/cron-builder/cron-builder.js.map +1 -1
  72. package/dist/components/cta/cta.d.ts +20 -0
  73. package/dist/components/cta/cta.d.ts.map +1 -0
  74. package/dist/components/cta/cta.js +64 -0
  75. package/dist/components/cta/cta.js.map +1 -0
  76. package/dist/components/drawer/drawer.js +6 -6
  77. package/dist/components/faq/faq-item.d.ts +22 -0
  78. package/dist/components/faq/faq-item.d.ts.map +1 -0
  79. package/dist/components/faq/faq-item.js +117 -0
  80. package/dist/components/faq/faq-item.js.map +1 -0
  81. package/dist/components/faq/faq.d.ts +18 -0
  82. package/dist/components/faq/faq.d.ts.map +1 -0
  83. package/dist/components/faq/faq.js +38 -0
  84. package/dist/components/faq/faq.js.map +1 -0
  85. package/dist/components/feature-grid/feature-grid.d.ts +22 -0
  86. package/dist/components/feature-grid/feature-grid.d.ts.map +1 -0
  87. package/dist/components/feature-grid/feature-grid.js +55 -0
  88. package/dist/components/feature-grid/feature-grid.js.map +1 -0
  89. package/dist/components/feature-grid/feature.d.ts +18 -0
  90. package/dist/components/feature-grid/feature.d.ts.map +1 -0
  91. package/dist/components/feature-grid/feature.js +91 -0
  92. package/dist/components/feature-grid/feature.js.map +1 -0
  93. package/dist/components/field/field.js +2 -2
  94. package/dist/components/footer/footer.js +4 -4
  95. package/dist/components/form/form-reset.d.ts +7 -0
  96. package/dist/components/form/form-reset.d.ts.map +1 -0
  97. package/dist/components/form/form-reset.js +47 -0
  98. package/dist/components/form/form-reset.js.map +1 -0
  99. package/dist/components/form/form.d.ts +5 -0
  100. package/dist/components/form/form.d.ts.map +1 -1
  101. package/dist/components/form/form.js +17 -3
  102. package/dist/components/form/form.js.map +1 -1
  103. package/dist/components/grid/grid.d.ts +5 -0
  104. package/dist/components/grid/grid.d.ts.map +1 -1
  105. package/dist/components/grid/grid.js +86 -4
  106. package/dist/components/grid/grid.js.map +1 -1
  107. package/dist/components/heat-map/heat-map.d.ts +39 -0
  108. package/dist/components/heat-map/heat-map.d.ts.map +1 -0
  109. package/dist/components/heat-map/heat-map.js +306 -0
  110. package/dist/components/heat-map/heat-map.js.map +1 -0
  111. package/dist/components/hero/hero.d.ts +26 -0
  112. package/dist/components/hero/hero.d.ts.map +1 -0
  113. package/dist/components/hero/hero.js +132 -0
  114. package/dist/components/hero/hero.js.map +1 -0
  115. package/dist/components/icon/icon-paths.d.ts +84 -0
  116. package/dist/components/icon/icon-paths.d.ts.map +1 -1
  117. package/dist/components/icon/icon-paths.js +89 -0
  118. package/dist/components/icon/icon-paths.js.map +1 -1
  119. package/dist/components/icon/icon.d.ts +2 -0
  120. package/dist/components/icon/icon.d.ts.map +1 -1
  121. package/dist/components/icon/icon.js +10 -1
  122. package/dist/components/icon/icon.js.map +1 -1
  123. package/dist/components/image/image.d.ts +31 -0
  124. package/dist/components/image/image.d.ts.map +1 -0
  125. package/dist/components/image/image.js +179 -0
  126. package/dist/components/image/image.js.map +1 -0
  127. package/dist/components/input/input.js +4 -4
  128. package/dist/components/lazy/lazy.d.ts +34 -0
  129. package/dist/components/lazy/lazy.d.ts.map +1 -0
  130. package/dist/components/lazy/lazy.js +104 -0
  131. package/dist/components/lazy/lazy.js.map +1 -0
  132. package/dist/components/line-chart/line-chart.d.ts +37 -0
  133. package/dist/components/line-chart/line-chart.d.ts.map +1 -0
  134. package/dist/components/line-chart/line-chart.js +271 -0
  135. package/dist/components/line-chart/line-chart.js.map +1 -0
  136. package/dist/components/list/list-item.d.ts +45 -0
  137. package/dist/components/list/list-item.d.ts.map +1 -0
  138. package/dist/components/list/list-item.js +263 -0
  139. package/dist/components/list/list-item.js.map +1 -0
  140. package/dist/components/list/list.d.ts +50 -0
  141. package/dist/components/list/list.d.ts.map +1 -0
  142. package/dist/components/list/list.js +161 -0
  143. package/dist/components/list/list.js.map +1 -0
  144. package/dist/components/logo-cloud/logo-cloud.d.ts +19 -0
  145. package/dist/components/logo-cloud/logo-cloud.d.ts.map +1 -0
  146. package/dist/components/logo-cloud/logo-cloud.js +66 -0
  147. package/dist/components/logo-cloud/logo-cloud.js.map +1 -0
  148. package/dist/components/modal/modal.d.ts +12 -0
  149. package/dist/components/modal/modal.d.ts.map +1 -1
  150. package/dist/components/modal/modal.js +40 -11
  151. package/dist/components/modal/modal.js.map +1 -1
  152. package/dist/components/page-layout/page-layout.js +8 -8
  153. package/dist/components/pagination/pagination.d.ts +15 -0
  154. package/dist/components/pagination/pagination.d.ts.map +1 -0
  155. package/dist/components/pagination/pagination.js +126 -0
  156. package/dist/components/pagination/pagination.js.map +1 -0
  157. package/dist/components/pagination/pagination.utils.d.ts +3 -0
  158. package/dist/components/pagination/pagination.utils.d.ts.map +1 -0
  159. package/dist/components/pagination/pagination.utils.js +19 -0
  160. package/dist/components/pagination/pagination.utils.js.map +1 -0
  161. package/dist/components/pie-chart/pie-chart.d.ts +33 -0
  162. package/dist/components/pie-chart/pie-chart.d.ts.map +1 -0
  163. package/dist/components/pie-chart/pie-chart.js +233 -0
  164. package/dist/components/pie-chart/pie-chart.js.map +1 -0
  165. package/dist/components/pin-input/pin-input.js +4 -4
  166. package/dist/components/popover/popover.d.ts.map +1 -1
  167. package/dist/components/popover/popover.js +1 -3
  168. package/dist/components/popover/popover.js.map +1 -1
  169. package/dist/components/post-list/post-card.d.ts +16 -0
  170. package/dist/components/post-list/post-card.d.ts.map +1 -0
  171. package/dist/components/post-list/post-card.js +22 -0
  172. package/dist/components/post-list/post-card.js.map +1 -0
  173. package/dist/components/post-list/post-list.d.ts +17 -0
  174. package/dist/components/post-list/post-list.d.ts.map +1 -0
  175. package/dist/components/post-list/post-list.js +23 -0
  176. package/dist/components/post-list/post-list.js.map +1 -0
  177. package/dist/components/pricing/pricing-tier.d.ts +23 -0
  178. package/dist/components/pricing/pricing-tier.d.ts.map +1 -0
  179. package/dist/components/pricing/pricing-tier.js +144 -0
  180. package/dist/components/pricing/pricing-tier.js.map +1 -0
  181. package/dist/components/pricing/pricing.d.ts +18 -0
  182. package/dist/components/pricing/pricing.d.ts.map +1 -0
  183. package/dist/components/pricing/pricing.js +38 -0
  184. package/dist/components/pricing/pricing.js.map +1 -0
  185. package/dist/components/progress/progress.d.ts +17 -0
  186. package/dist/components/progress/progress.d.ts.map +1 -0
  187. package/dist/components/progress/progress.js +109 -0
  188. package/dist/components/progress/progress.js.map +1 -0
  189. package/dist/components/project-grid/project-card.d.ts +17 -0
  190. package/dist/components/project-grid/project-card.d.ts.map +1 -0
  191. package/dist/components/project-grid/project-card.js +23 -0
  192. package/dist/components/project-grid/project-card.js.map +1 -0
  193. package/dist/components/project-grid/project-grid.d.ts +17 -0
  194. package/dist/components/project-grid/project-grid.d.ts.map +1 -0
  195. package/dist/components/project-grid/project-grid.js +23 -0
  196. package/dist/components/project-grid/project-grid.js.map +1 -0
  197. package/dist/components/radio/radio.js +1 -1
  198. package/dist/components/reveal/reveal.constants.d.ts +10 -0
  199. package/dist/components/reveal/reveal.constants.d.ts.map +1 -0
  200. package/dist/components/reveal/reveal.constants.js +11 -0
  201. package/dist/components/reveal/reveal.constants.js.map +1 -0
  202. package/dist/components/reveal/reveal.d.ts +64 -0
  203. package/dist/components/reveal/reveal.d.ts.map +1 -0
  204. package/dist/components/reveal/reveal.js +352 -0
  205. package/dist/components/reveal/reveal.js.map +1 -0
  206. package/dist/components/scroll-progress/scroll-progress.d.ts +32 -0
  207. package/dist/components/scroll-progress/scroll-progress.d.ts.map +1 -0
  208. package/dist/components/scroll-progress/scroll-progress.js +120 -0
  209. package/dist/components/scroll-progress/scroll-progress.js.map +1 -0
  210. package/dist/components/section/card-row.d.ts +30 -0
  211. package/dist/components/section/card-row.d.ts.map +1 -0
  212. package/dist/components/section/card-row.js +174 -0
  213. package/dist/components/section/card-row.js.map +1 -0
  214. package/dist/components/section/card.d.ts +27 -0
  215. package/dist/components/section/card.d.ts.map +1 -0
  216. package/dist/components/section/card.js +205 -0
  217. package/dist/components/section/card.js.map +1 -0
  218. package/dist/components/section/row-item.d.ts +22 -0
  219. package/dist/components/section/row-item.d.ts.map +1 -0
  220. package/dist/components/section/row-item.js +53 -0
  221. package/dist/components/section/row-item.js.map +1 -0
  222. package/dist/components/section/section.d.ts +70 -0
  223. package/dist/components/section/section.d.ts.map +1 -0
  224. package/dist/components/section/section.js +240 -0
  225. package/dist/components/section/section.js.map +1 -0
  226. package/dist/components/select/select.js +3 -3
  227. package/dist/components/series-nav/series-nav.d.ts +29 -0
  228. package/dist/components/series-nav/series-nav.d.ts.map +1 -0
  229. package/dist/components/series-nav/series-nav.js +178 -0
  230. package/dist/components/series-nav/series-nav.js.map +1 -0
  231. package/dist/components/site-header/site-header.d.ts +51 -0
  232. package/dist/components/site-header/site-header.d.ts.map +1 -0
  233. package/dist/components/site-header/site-header.js +296 -0
  234. package/dist/components/site-header/site-header.js.map +1 -0
  235. package/dist/components/skeleton/skeleton.js +7 -7
  236. package/dist/components/sparkline/sparkline.d.ts +19 -0
  237. package/dist/components/sparkline/sparkline.d.ts.map +1 -0
  238. package/dist/components/sparkline/sparkline.js +99 -0
  239. package/dist/components/sparkline/sparkline.js.map +1 -0
  240. package/dist/components/spinner/spinner.d.ts +13 -0
  241. package/dist/components/spinner/spinner.d.ts.map +1 -0
  242. package/dist/components/spinner/spinner.js +65 -0
  243. package/dist/components/spinner/spinner.js.map +1 -0
  244. package/dist/components/split/split.d.ts +23 -0
  245. package/dist/components/split/split.d.ts.map +1 -0
  246. package/dist/components/split/split.js +104 -0
  247. package/dist/components/split/split.js.map +1 -0
  248. package/dist/components/stack/stack.d.ts +21 -0
  249. package/dist/components/stack/stack.d.ts.map +1 -0
  250. package/dist/components/stack/stack.js +102 -0
  251. package/dist/components/stack/stack.js.map +1 -0
  252. package/dist/components/stat-card/stat-card.d.ts +35 -0
  253. package/dist/components/stat-card/stat-card.d.ts.map +1 -0
  254. package/dist/components/stat-card/stat-card.js +199 -0
  255. package/dist/components/stat-card/stat-card.js.map +1 -0
  256. package/dist/components/stats/stat.d.ts +16 -0
  257. package/dist/components/stats/stat.d.ts.map +1 -0
  258. package/dist/components/stats/stat.js +51 -0
  259. package/dist/components/stats/stat.js.map +1 -0
  260. package/dist/components/stats/stats.d.ts +19 -0
  261. package/dist/components/stats/stats.d.ts.map +1 -0
  262. package/dist/components/stats/stats.js +45 -0
  263. package/dist/components/stats/stats.js.map +1 -0
  264. package/dist/components/switch/switch.js +2 -2
  265. package/dist/components/table/data-table.d.ts +115 -27
  266. package/dist/components/table/data-table.d.ts.map +1 -1
  267. package/dist/components/table/data-table.js +1012 -411
  268. package/dist/components/table/data-table.js.map +1 -1
  269. package/dist/components/table/data-table.utils.d.ts +81 -0
  270. package/dist/components/table/data-table.utils.d.ts.map +1 -0
  271. package/dist/components/table/data-table.utils.js +208 -0
  272. package/dist/components/table/data-table.utils.js.map +1 -0
  273. package/dist/components/table/table.d.ts +28 -0
  274. package/dist/components/table/table.d.ts.map +1 -1
  275. package/dist/components/table/table.js +161 -33
  276. package/dist/components/table/table.js.map +1 -1
  277. package/dist/components/team/person.d.ts +19 -0
  278. package/dist/components/team/person.d.ts.map +1 -0
  279. package/dist/components/team/person.js +123 -0
  280. package/dist/components/team/person.js.map +1 -0
  281. package/dist/components/team/team.d.ts +18 -0
  282. package/dist/components/team/team.d.ts.map +1 -0
  283. package/dist/components/team/team.js +36 -0
  284. package/dist/components/team/team.js.map +1 -0
  285. package/dist/components/testimonials/testimonial.d.ts +18 -0
  286. package/dist/components/testimonials/testimonial.d.ts.map +1 -0
  287. package/dist/components/testimonials/testimonial.js +115 -0
  288. package/dist/components/testimonials/testimonial.js.map +1 -0
  289. package/dist/components/testimonials/testimonials.d.ts +18 -0
  290. package/dist/components/testimonials/testimonials.d.ts.map +1 -0
  291. package/dist/components/testimonials/testimonials.js +36 -0
  292. package/dist/components/testimonials/testimonials.js.map +1 -0
  293. package/dist/components/textarea/textarea.js +3 -3
  294. package/dist/components/theme-toggle/theme-toggle.js +1 -1
  295. package/dist/components/time-picker/time-picker.js +3 -3
  296. package/dist/components/timeline/timeline-item.d.ts +18 -0
  297. package/dist/components/timeline/timeline-item.d.ts.map +1 -0
  298. package/dist/components/timeline/timeline-item.js +102 -0
  299. package/dist/components/timeline/timeline-item.js.map +1 -0
  300. package/dist/components/timeline/timeline.d.ts +18 -0
  301. package/dist/components/timeline/timeline.d.ts.map +1 -0
  302. package/dist/components/timeline/timeline.js +30 -0
  303. package/dist/components/timeline/timeline.js.map +1 -0
  304. package/dist/components/toast/toast.d.ts +33 -0
  305. package/dist/components/toast/toast.d.ts.map +1 -0
  306. package/dist/components/toast/toast.js +147 -0
  307. package/dist/components/toast/toast.js.map +1 -0
  308. package/dist/components/toggle-group/toggle-button.d.ts +2 -0
  309. package/dist/components/toggle-group/toggle-button.d.ts.map +1 -1
  310. package/dist/components/toggle-group/toggle-button.js +12 -4
  311. package/dist/components/toggle-group/toggle-button.js.map +1 -1
  312. package/dist/components/toggle-group/toggle-group.js +4 -4
  313. package/dist/components/tooltip/tooltip.js +21 -21
  314. package/dist/components/vertical-nav/vertical-nav-group.js +3 -3
  315. package/dist/components/vertical-nav/vertical-nav-item.js +4 -4
  316. package/dist/components/video-embed/video-embed.d.ts +37 -0
  317. package/dist/components/video-embed/video-embed.d.ts.map +1 -0
  318. package/dist/components/video-embed/video-embed.js +183 -0
  319. package/dist/components/video-embed/video-embed.js.map +1 -0
  320. package/dist/index.d.ts +107 -0
  321. package/dist/index.d.ts.map +1 -0
  322. package/dist/index.js +104 -0
  323. package/dist/index.js.map +1 -0
  324. package/dist/styles/index.css +205 -2
  325. package/dist/styles/reset.d.ts.map +1 -1
  326. package/dist/styles/reset.js +5 -0
  327. package/dist/styles/reset.js.map +1 -1
  328. package/package.json +210 -7
  329. package/src/components/accordion/accordion.constants.ts +5 -0
  330. package/src/components/accordion/accordion.ts +209 -0
  331. package/src/components/alert/alert.constants.ts +3 -0
  332. package/src/components/alert/alert.ts +284 -17
  333. package/src/components/avatar/avatar.ts +84 -0
  334. package/src/components/back-to-top/back-to-top.ts +140 -0
  335. package/src/components/bar-chart/bar-chart.ts +295 -0
  336. package/src/components/breadcrumb/breadcrumb.ts +2 -2
  337. package/src/components/button/button.ts +9 -8
  338. package/src/components/button-group/button-group.ts +4 -4
  339. package/src/components/calendar/calendar.ts +12 -9
  340. package/src/components/chart/chart-base.ts +275 -0
  341. package/src/components/chart/chart.utils.ts +140 -0
  342. package/src/components/code-block/code-block.ts +35 -24
  343. package/src/components/consent/consent.ts +312 -0
  344. package/src/components/consent/consent.utils.ts +110 -0
  345. package/src/components/contact/contact.ts +83 -0
  346. package/src/components/container/container.ts +60 -0
  347. package/src/components/content-card/content-card.ts +4 -4
  348. package/src/components/context-menu/context-menu.ts +426 -0
  349. package/src/components/cron-builder/cron-builder.ts +21 -18
  350. package/src/components/cta/cta.ts +64 -0
  351. package/src/components/drawer/drawer.ts +6 -6
  352. package/src/components/faq/faq-item.ts +110 -0
  353. package/src/components/faq/faq.ts +40 -0
  354. package/src/components/feature-grid/feature-grid.ts +52 -0
  355. package/src/components/feature-grid/feature.ts +84 -0
  356. package/src/components/field/field.ts +2 -2
  357. package/src/components/footer/footer.ts +4 -4
  358. package/src/components/form/form-reset.ts +45 -0
  359. package/src/components/form/form.ts +17 -3
  360. package/src/components/grid/grid.ts +73 -4
  361. package/src/components/heat-map/heat-map.ts +292 -0
  362. package/src/components/hero/hero.ts +132 -0
  363. package/src/components/icon/icon-paths.ts +92 -1
  364. package/src/components/icon/icon.ts +8 -1
  365. package/src/components/image/image.ts +165 -0
  366. package/src/components/input/input.ts +4 -4
  367. package/src/components/lazy/lazy.ts +94 -0
  368. package/src/components/line-chart/line-chart.ts +271 -0
  369. package/src/components/list/list-item.ts +225 -0
  370. package/src/components/list/list.ts +157 -0
  371. package/src/components/logo-cloud/logo-cloud.ts +65 -0
  372. package/src/components/modal/modal.ts +37 -11
  373. package/src/components/page-layout/page-layout.ts +8 -8
  374. package/src/components/pagination/pagination.ts +120 -0
  375. package/src/components/pagination/pagination.utils.ts +14 -0
  376. package/src/components/pie-chart/pie-chart.ts +230 -0
  377. package/src/components/pin-input/pin-input.ts +4 -4
  378. package/src/components/popover/popover.ts +1 -3
  379. package/src/components/post-list/post-card.ts +18 -0
  380. package/src/components/post-list/post-list.ts +19 -0
  381. package/src/components/pricing/pricing-tier.ts +132 -0
  382. package/src/components/pricing/pricing.ts +39 -0
  383. package/src/components/progress/progress.ts +95 -0
  384. package/src/components/project-grid/project-card.ts +19 -0
  385. package/src/components/project-grid/project-grid.ts +19 -0
  386. package/src/components/radio/radio.ts +1 -1
  387. package/src/components/reveal/reveal.constants.ts +20 -0
  388. package/src/components/reveal/reveal.ts +344 -0
  389. package/src/components/scroll-progress/scroll-progress.ts +119 -0
  390. package/src/components/section/card-row.ts +152 -0
  391. package/src/components/section/card.ts +197 -0
  392. package/src/components/section/row-item.ts +38 -0
  393. package/src/components/section/section.ts +232 -0
  394. package/src/components/select/select.ts +3 -3
  395. package/src/components/series-nav/series-nav.ts +164 -0
  396. package/src/components/site-header/site-header.ts +276 -0
  397. package/src/components/skeleton/skeleton.ts +7 -7
  398. package/src/components/sparkline/sparkline.ts +83 -0
  399. package/src/components/spinner/spinner.ts +55 -0
  400. package/src/components/split/split.ts +106 -0
  401. package/src/components/stack/stack.ts +88 -0
  402. package/src/components/stat-card/stat-card.ts +179 -0
  403. package/src/components/stats/stat.ts +49 -0
  404. package/src/components/stats/stats.ts +47 -0
  405. package/src/components/switch/switch.ts +2 -2
  406. package/src/components/table/data-table.ts +1015 -425
  407. package/src/components/table/data-table.utils.ts +276 -0
  408. package/src/components/table/table.ts +168 -38
  409. package/src/components/team/person.ts +113 -0
  410. package/src/components/team/team.ts +37 -0
  411. package/src/components/testimonials/testimonial.ts +108 -0
  412. package/src/components/testimonials/testimonials.ts +37 -0
  413. package/src/components/textarea/textarea.ts +3 -3
  414. package/src/components/theme-toggle/theme-toggle.ts +1 -1
  415. package/src/components/time-picker/time-picker.ts +3 -3
  416. package/src/components/timeline/timeline-item.ts +100 -0
  417. package/src/components/timeline/timeline.ts +31 -0
  418. package/src/components/toast/toast.ts +153 -0
  419. package/src/components/toggle-group/toggle-button.ts +9 -4
  420. package/src/components/toggle-group/toggle-group.ts +4 -4
  421. package/src/components/tooltip/tooltip.ts +21 -21
  422. package/src/components/vertical-nav/vertical-nav-group.ts +3 -3
  423. package/src/components/vertical-nav/vertical-nav-item.ts +4 -4
  424. package/src/components/video-embed/video-embed.ts +162 -0
  425. package/src/index.ts +108 -0
  426. package/src/styles/globals.css +63 -0
  427. package/src/styles/index.css +3 -1
  428. package/src/styles/prose.css +154 -0
  429. package/src/styles/reset.ts +5 -0
  430. package/src/styles/theme.css +53 -1
  431. package/src/styles/typography.css +1 -0
@@ -0,0 +1,209 @@
1
+ import {LitElement, html, css, nothing, PropertyValues} from "lit";
2
+ import {customElement, property} from "lit/decorators.js";
3
+ import {resetStyles} from "../../styles/reset.js";
4
+ import {AccordionColor, AccordionVariant} from "./accordion.constants.js";
5
+ import "../icon/icon.js";
6
+
7
+ let nextId = 0;
8
+
9
+ /**
10
+ * Collapsible section. The header is a disclosure button and the content is a labelled region
11
+ * that animates open and closed (respecting `prefers-reduced-motion`).
12
+ */
13
+ @customElement("st-accordion")
14
+ export class StAccordion extends LitElement {
15
+ @property({type: String}) heading = "";
16
+ @property({type: Boolean, reflect: true}) open = false;
17
+ /** Accordions sharing the same `group` close each other. */
18
+ @property({type: String}) group = "";
19
+ /** Optional icon name shown before the heading. */
20
+ @property({type: String}) icon = "";
21
+ @property({type: String, reflect: true}) color: AccordionColor = "default";
22
+ @property({type: String, reflect: true}) variant: AccordionVariant = "soft";
23
+
24
+ private readonly _id = `st-accordion-${nextId++}`;
25
+ private _hasUpdated = false;
26
+
27
+ static styles = [
28
+ resetStyles,
29
+ css`
30
+ :host {
31
+ display: block;
32
+ overflow: hidden;
33
+ border: 1px solid var(--_accent);
34
+ border-radius: var(--st-radius-md);
35
+ background: var(--st-color-bg);
36
+
37
+ /* Default (neutral) palette */
38
+ --_accent: var(--st-color-border);
39
+ --_accent-text: var(--st-color-text);
40
+ --_soft-bg: var(--st-color-surface-muted);
41
+ --_on-accent: var(--st-color-text);
42
+ }
43
+ :host([color="primary"]) {
44
+ --_accent: var(--st-color-primary);
45
+ --_accent-text: var(--st-color-primary-text);
46
+ --_soft-bg: var(--st-color-primary-bg);
47
+ --_on-accent: var(--st-color-on-primary);
48
+ }
49
+ :host([color="info"]) {
50
+ --_accent: var(--st-color-info);
51
+ --_accent-text: var(--st-color-info-text);
52
+ --_soft-bg: var(--st-color-info-bg);
53
+ --_on-accent: var(--st-color-on-info);
54
+ }
55
+ :host([color="success"]) {
56
+ --_accent: var(--st-color-success);
57
+ --_accent-text: var(--st-color-success);
58
+ --_soft-bg: var(--st-color-success-bg);
59
+ --_on-accent: var(--st-color-on-success);
60
+ }
61
+ :host([color="warning"]) {
62
+ --_accent: var(--st-color-warning);
63
+ --_accent-text: var(--st-color-warning);
64
+ --_soft-bg: var(--st-color-warning-bg);
65
+ --_on-accent: var(--st-color-on-warning);
66
+ }
67
+ :host([color="error"]) {
68
+ --_accent: var(--st-color-error);
69
+ --_accent-text: var(--st-color-error-text);
70
+ --_soft-bg: var(--st-color-error-bg);
71
+ --_on-accent: var(--st-color-on-danger);
72
+ }
73
+
74
+ /* Header colors per variant */
75
+ .header {
76
+ --_header-bg: var(--_soft-bg);
77
+ --_header-text: var(--_accent-text);
78
+ }
79
+ :host([variant="solid"]) .header {
80
+ --_header-bg: var(--_accent);
81
+ --_header-text: var(--_on-accent);
82
+ }
83
+ :host([variant="solid"][color="default"]) .header {
84
+ --_header-bg: var(--st-color-surface-hover);
85
+ --_header-text: var(--st-color-text);
86
+ }
87
+ :host([variant="outline"]) .header {
88
+ --_header-bg: transparent;
89
+ }
90
+
91
+ .header {
92
+ display: flex;
93
+ align-items: center;
94
+ gap: var(--st-spacing-sm);
95
+ width: 100%;
96
+ padding: var(--st-spacing-md);
97
+ border: 0;
98
+ background: var(--_header-bg);
99
+ color: var(--_header-text);
100
+ font-weight: var(--st-font-weight-medium);
101
+ text-align: left;
102
+ cursor: pointer;
103
+ }
104
+ .header:hover {
105
+ filter: brightness(var(--st-hover-brightness));
106
+ }
107
+ .header:focus-visible {
108
+ outline: 2px solid var(--st-color-primary);
109
+ outline-offset: -2px;
110
+ }
111
+ .title {
112
+ flex: 1;
113
+ }
114
+ .chevron {
115
+ transition: transform 0.25s ease;
116
+ }
117
+ :host([open]) .chevron {
118
+ transform: rotate(180deg);
119
+ }
120
+
121
+ /* Animated panel: grid rows animate 0fr -> 1fr without measuring heights in JS */
122
+ .panel {
123
+ display: grid;
124
+ grid-template-rows: 0fr;
125
+ visibility: hidden;
126
+ transition:
127
+ grid-template-rows 0.25s ease,
128
+ visibility 0s linear 0.25s;
129
+ }
130
+ :host([open]) .panel {
131
+ grid-template-rows: 1fr;
132
+ visibility: visible;
133
+ transition:
134
+ grid-template-rows 0.25s ease,
135
+ visibility 0s;
136
+ }
137
+ .panel-inner {
138
+ min-height: 0;
139
+ overflow: hidden;
140
+ }
141
+ /* Distinct content surface so it never blends with the header */
142
+ .content {
143
+ padding: var(--st-spacing-md);
144
+ background: var(--st-color-bg);
145
+ color: var(--st-color-text);
146
+ border-top: 1px solid var(--_accent);
147
+ }
148
+
149
+ @media (prefers-reduced-motion: reduce) {
150
+ .chevron,
151
+ .panel,
152
+ :host([open]) .panel {
153
+ transition: none;
154
+ }
155
+ }
156
+ `,
157
+ ];
158
+
159
+ protected updated(changed: PropertyValues<this>) {
160
+ if (changed.has("open") && this._hasUpdated) {
161
+ this.dispatchEvent(
162
+ new CustomEvent("st-toggle", {detail: {open: this.open}, bubbles: true, composed: true}),
163
+ );
164
+ if (this.open && this.group) this._closeGroupSiblings();
165
+ }
166
+ this._hasUpdated = true;
167
+ }
168
+
169
+ private _closeGroupSiblings() {
170
+ const root = this.getRootNode() as Document | ShadowRoot;
171
+ root
172
+ .querySelectorAll<StAccordion>(`st-accordion[group="${CSS.escape(this.group)}"]`)
173
+ .forEach((el) => {
174
+ if (el !== this) el.open = false;
175
+ });
176
+ }
177
+
178
+ render() {
179
+ const headerId = `${this._id}-header`;
180
+ const panelId = `${this._id}-panel`;
181
+ return html`
182
+ <button
183
+ class="header"
184
+ id=${headerId}
185
+ type="button"
186
+ aria-expanded=${this.open ? "true" : "false"}
187
+ aria-controls=${panelId}
188
+ @click=${() => (this.open = !this.open)}
189
+ >
190
+ ${this.icon
191
+ ? html`<st-icon name=${this.icon} size="sm" aria-hidden="true"></st-icon>`
192
+ : nothing}
193
+ <span class="title">${this.heading}</span>
194
+ <st-icon class="chevron" name="angle-down" size="sm" aria-hidden="true"></st-icon>
195
+ </button>
196
+ <div class="panel" id=${panelId} role="region" aria-labelledby=${headerId}>
197
+ <div class="panel-inner">
198
+ <div class="content"><slot></slot></div>
199
+ </div>
200
+ </div>
201
+ `;
202
+ }
203
+ }
204
+
205
+ declare global {
206
+ interface HTMLElementTagNameMap {
207
+ "st-accordion": StAccordion;
208
+ }
209
+ }
@@ -1,2 +1,5 @@
1
1
  export const alertColors = ["info", "success", "warning", "error"] as const;
2
2
  export type AlertColor = typeof alertColors[number];
3
+
4
+ /** Why an alert closed, reported in `st-close`. */
5
+ export type AlertCloseReason = "dismiss" | "timeout" | "api";
@@ -1,21 +1,57 @@
1
- import {LitElement, html, css} from "lit";
2
- import {customElement, property} from "lit/decorators.js";
1
+ import {LitElement, html, css, nothing, PropertyValues} from "lit";
2
+ import {customElement, property, state} from "lit/decorators.js";
3
3
  import {resetStyles} from "../../styles/reset.js";
4
- import { AlertColor } from "./alert.constants.js";
4
+ import {AlertColor, AlertCloseReason} from "./alert.constants.js";
5
+ import "../icon/icon.js";
5
6
 
7
+ type Phase = "open" | "closing" | "closed";
8
+
9
+ /** Longest we wait for the hide transition before closing anyway. */
10
+ const TRANSITION_FALLBACK_MS = 400;
11
+
12
+ /**
13
+ * Inline message with an icon, content, a `confirm` action under the message and a dismiss
14
+ * `action` at the end. It can also hide itself after `timeout` milliseconds. Hiding always
15
+ * animates (unless the user prefers reduced motion).
16
+ *
17
+ * Slots: `icon` (start), default (message), `confirm` (below the message, bottom-left, e.g. a
18
+ * "Renew" or "Undo" button) and `action` (top-right, the dismiss control). Set `dismissible` for
19
+ * a ready-made dismiss button, or slot your own into `action`.
20
+ * Dismissing: call `dismiss()`, set `open = false`, click the built-in button, or add a
21
+ * `data-dismiss` attribute to any slotted element, which closes the alert when clicked.
22
+ * Events: `st-close` (bubbles, composed) with `detail.reason` of "dismiss", "timeout" or "api",
23
+ * fired once the alert has finished hiding.
24
+ */
6
25
  @customElement("st-alert")
7
26
  export class StAlert extends LitElement {
8
27
  @property({type: String, reflect: true}) color: AlertColor = "info";
28
+ /** Whether the alert is shown. Setting it to false hides it with an animation. */
29
+ @property({type: Boolean, reflect: true}) open = true;
30
+ /**
31
+ * Hides the alert automatically after this many milliseconds (0 keeps it). The countdown
32
+ * pauses while the pointer or keyboard focus is inside, so people have time to read and act.
33
+ */
34
+ @property({type: Number}) timeout = 0;
35
+ /** Shows a built-in dismiss button in the `action` slot (your own slotted content replaces it). */
36
+ @property({type: Boolean, reflect: true}) dismissible = false;
37
+ @property({type: String, attribute: "dismiss-label"}) dismissLabel = "Dismiss";
38
+
39
+ @state() private _phase: Phase = "open";
40
+ @state() private _hasAction = false;
41
+ @state() private _hasConfirm = false;
42
+
43
+ private _reason: AlertCloseReason = "api";
44
+ private _timer?: number;
45
+ private _fallback?: number;
46
+ private _remaining = 0;
47
+ private _deadline = 0;
48
+ private _paused = false;
9
49
 
10
50
  static styles = [
11
51
  resetStyles,
12
52
  css`
13
53
  :host {
14
- display: flex;
15
- gap: var(--st-spacing-md);
16
- padding: var(--st-spacing-md);
17
- border-radius: 6px;
18
- border: 1px solid transparent;
54
+ display: block;
19
55
  font-size: var(--st-font-size-base);
20
56
  line-height: 1.5;
21
57
 
@@ -25,7 +61,7 @@ export class StAlert extends LitElement {
25
61
  --_alert-text: var(--st-color-info);
26
62
  --_alert-icon: var(--st-color-info);
27
63
  }
28
-
64
+
29
65
  /* State Modifiers */
30
66
  :host([color="error"]) {
31
67
  --_alert-bg: var(--st-color-error-bg);
@@ -48,10 +84,44 @@ export class StAlert extends LitElement {
48
84
  --_alert-text: var(--st-color-warning);
49
85
  }
50
86
 
51
- /* Apply the variables */
52
- :host {
87
+ /*
88
+ * Hiding animates grid rows from 1fr to 0fr, which collapses the alert's height smoothly
89
+ * without measuring it in JavaScript. The padding and border live one level deeper so they
90
+ * collapse too.
91
+ */
92
+ .wrap {
93
+ display: grid;
94
+ grid-template-rows: 1fr;
95
+ opacity: 1;
96
+ transition:
97
+ grid-template-rows 0.25s ease,
98
+ opacity 0.2s ease;
99
+ }
100
+
101
+ .wrap.closing {
102
+ grid-template-rows: 0fr;
103
+ opacity: 0;
104
+ }
105
+
106
+ @media (prefers-reduced-motion: reduce) {
107
+ .wrap {
108
+ transition: none;
109
+ }
110
+ }
111
+
112
+ .clip {
113
+ min-height: 0;
114
+ overflow: hidden;
115
+ }
116
+
117
+ .alert {
118
+ display: flex;
119
+ align-items: flex-start;
120
+ gap: var(--st-spacing-md);
121
+ padding: var(--st-spacing-md);
122
+ border: 1px solid var(--_alert-border);
123
+ border-radius: var(--st-radius-sm);
53
124
  background-color: var(--_alert-bg);
54
- border-color: var(--_alert-border);
55
125
  color: var(--_alert-text);
56
126
  }
57
127
 
@@ -79,6 +149,49 @@ export class StAlert extends LitElement {
79
149
  flex-direction: column;
80
150
  gap: var(--st-spacing-xs);
81
151
  flex: 1;
152
+ min-width: 0;
153
+ }
154
+
155
+ /* Confirm Slot: sits under the message, bottom-left */
156
+ .confirm {
157
+ display: flex;
158
+ flex-wrap: wrap;
159
+ align-items: center;
160
+ gap: var(--st-spacing-sm);
161
+ margin-top: var(--st-spacing-xs);
162
+ }
163
+
164
+ /* Action Slot: the dismiss control, top-right */
165
+ .action {
166
+ display: flex;
167
+ flex-shrink: 0;
168
+ align-items: center;
169
+ gap: var(--st-spacing-sm);
170
+ align-self: flex-start;
171
+ margin: calc(var(--st-spacing-xs) * -1) calc(var(--st-spacing-xs) * -1) 0 0;
172
+ }
173
+
174
+ [hidden] {
175
+ display: none !important;
176
+ }
177
+
178
+ .dismiss {
179
+ display: inline-flex;
180
+ padding: var(--st-spacing-xs);
181
+ border: 0;
182
+ border-radius: var(--st-radius-sm);
183
+ background: none;
184
+ color: inherit;
185
+ cursor: pointer;
186
+ }
187
+
188
+ .dismiss:hover {
189
+ background: color-mix(in srgb, var(--_alert-border) 18%, transparent);
190
+ }
191
+
192
+ .dismiss:focus-visible {
193
+ outline: 2px solid var(--_alert-border);
194
+ outline-offset: 1px;
82
195
  }
83
196
  `,
84
197
  ];
@@ -89,15 +202,169 @@ export class StAlert extends LitElement {
89
202
  if (!this.hasAttribute("role")) {
90
203
  this.setAttribute("role", "alert");
91
204
  }
205
+ this.addEventListener("click", this._onClick);
206
+ this.addEventListener("pointerenter", this._pause);
207
+ this.addEventListener("pointerleave", this._resume);
208
+ this.addEventListener("focusin", this._pause);
209
+ this.addEventListener("focusout", this._onFocusOut);
210
+ }
211
+
212
+ disconnectedCallback() {
213
+ this.removeEventListener("click", this._onClick);
214
+ this.removeEventListener("pointerenter", this._pause);
215
+ this.removeEventListener("pointerleave", this._resume);
216
+ this.removeEventListener("focusin", this._pause);
217
+ this.removeEventListener("focusout", this._onFocusOut);
218
+ this._clearTimers();
219
+ super.disconnectedCallback();
220
+ }
221
+
222
+ /** Hides the alert with an animation. Resolves nothing; listen for `st-close`. */
223
+ dismiss(reason: AlertCloseReason = "api") {
224
+ if (this._phase !== "open") return;
225
+ this._reason = reason;
226
+ this.open = false;
227
+ }
228
+
229
+ protected willUpdate(changed: PropertyValues<this>) {
230
+ if (changed.has("open")) {
231
+ if (!this.open && this._phase === "open") {
232
+ // The first render of an alert that starts closed should not animate.
233
+ this._phase = this.hasUpdated ? "closing" : "closed";
234
+ } else if (this.open) {
235
+ this._phase = "open";
236
+ }
237
+ }
238
+ }
239
+
240
+ protected updated(changed: PropertyValues<this>) {
241
+ this.toggleAttribute("hidden", this._phase === "closed");
242
+
243
+ if (changed.has("open") || changed.has("timeout")) this._restartTimer();
244
+
245
+ if (this._phase === "closing" && !this._fallback) this._beginClose();
246
+ }
247
+
248
+ // ----------------------------------------------------------------- closing
249
+
250
+ private _beginClose() {
251
+ this._clearTimers();
252
+ const reduce = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
253
+ if (reduce) {
254
+ this._finishClose();
255
+ return;
256
+ }
257
+ // transitionend normally finishes the close; this guarantees it if it never fires.
258
+ this._fallback = window.setTimeout(() => this._finishClose(), TRANSITION_FALLBACK_MS);
92
259
  }
93
260
 
261
+ private _onTransitionEnd = (e: TransitionEvent) => {
262
+ if (e.propertyName === "grid-template-rows" && this._phase === "closing") this._finishClose();
263
+ };
264
+
265
+ private _finishClose() {
266
+ window.clearTimeout(this._fallback);
267
+ this._fallback = undefined;
268
+ if (this._phase !== "closing") return;
269
+ this._phase = "closed";
270
+ const reason = this._reason;
271
+ this._reason = "api";
272
+ this.dispatchEvent(
273
+ new CustomEvent("st-close", {detail: {reason}, bubbles: true, composed: true}),
274
+ );
275
+ }
276
+
277
+ private _clearTimers() {
278
+ window.clearTimeout(this._timer);
279
+ window.clearTimeout(this._fallback);
280
+ this._timer = undefined;
281
+ this._fallback = undefined;
282
+ }
283
+
284
+ // ----------------------------------------------------------------- timeout
285
+
286
+ private _restartTimer() {
287
+ window.clearTimeout(this._timer);
288
+ this._timer = undefined;
289
+ if (!this.open || this.timeout <= 0 || this._phase !== "open") return;
290
+ this._remaining = this.timeout;
291
+ // A timer that restarts while the user is already interacting stays paused.
292
+ if (!this._paused) this._startTimer();
293
+ }
294
+
295
+ private _startTimer() {
296
+ window.clearTimeout(this._timer);
297
+ this._deadline = Date.now() + this._remaining;
298
+ this._timer = window.setTimeout(() => this.dismiss("timeout"), this._remaining);
299
+ }
300
+
301
+ private _pause = () => {
302
+ this._paused = true;
303
+ if (this._timer === undefined) return;
304
+ window.clearTimeout(this._timer);
305
+ this._timer = undefined;
306
+ this._remaining = Math.max(this._deadline - Date.now(), 0);
307
+ };
308
+
309
+ private _resume = () => {
310
+ this._paused = false;
311
+ if (this.open && this.timeout > 0 && this._phase === "open" && this._timer === undefined) {
312
+ this._startTimer();
313
+ }
314
+ };
315
+
316
+ private _onFocusOut = (e: FocusEvent) => {
317
+ // Only resume once focus has left the alert entirely.
318
+ if (!this.contains(e.relatedTarget as Node | null)) this._resume();
319
+ };
320
+
321
+ // ---------------------------------------------------------------- actions
322
+
323
+ private _onClick = (e: MouseEvent) => {
324
+ const hit = e
325
+ .composedPath()
326
+ .find((el) => el instanceof HTMLElement && el !== this && el.hasAttribute("data-dismiss"));
327
+ if (hit) this.dismiss("dismiss");
328
+ };
329
+
94
330
  render() {
95
331
  return html`
96
- <div class="icon-container">
97
- <slot name="icon"></slot>
98
- </div>
99
- <div class="content">
100
- <slot></slot>
332
+ <div class="wrap ${this._phase === "closing" ? "closing" : ""}" @transitionend=${this._onTransitionEnd}>
333
+ <div class="clip">
334
+ <div class="alert">
335
+ <div class="icon-container">
336
+ <slot name="icon"></slot>
337
+ </div>
338
+ <div class="content">
339
+ <slot></slot>
340
+ <div class="confirm" ?hidden=${!this._hasConfirm}>
341
+ <slot
342
+ name="confirm"
343
+ @slotchange=${(e: Event) =>
344
+ (this._hasConfirm = (e.target as HTMLSlotElement).assignedNodes().length > 0)}
345
+ ></slot>
346
+ </div>
347
+ </div>
348
+ <div class="action" ?hidden=${!this._hasAction && !this.dismissible}>
349
+ <slot
350
+ name="action"
351
+ @slotchange=${(e: Event) =>
352
+ (this._hasAction = (e.target as HTMLSlotElement).assignedNodes().length > 0)}
353
+ >
354
+ ${this.dismissible
355
+ ? html`<button
356
+ class="dismiss"
357
+ type="button"
358
+ aria-label=${this.dismissLabel}
359
+ @click=${() => this.dismiss("dismiss")}
360
+ >
361
+ <st-icon name="x" size="sm" aria-hidden="true"></st-icon>
362
+ </button>`
363
+ : nothing}
364
+ </slot>
365
+ </div>
366
+ </div>
367
+ </div>
101
368
  </div>
102
369
  `;
103
370
  }
@@ -0,0 +1,84 @@
1
+ import {LitElement, html, css} from "lit";
2
+ import {customElement, property, state} from "lit/decorators.js";
3
+ import {resetStyles} from "../../styles/reset.js";
4
+ import "../icon/icon.js";
5
+
6
+ @customElement("st-avatar")
7
+ export class StAvatar extends LitElement {
8
+ @property({type: String}) src = "";
9
+ /** Full name; used for the accessible name and to derive initials when there is no image. */
10
+ @property({type: String}) name = "";
11
+ @property({type: String, reflect: true}) size: "sm" | "md" | "lg" = "md";
12
+ @state() private _failed = false;
13
+
14
+ static styles = [
15
+ resetStyles,
16
+ css`
17
+ :host {
18
+ display: inline-flex;
19
+ --_size: 2.5rem;
20
+ width: var(--_size);
21
+ height: var(--_size);
22
+ flex-shrink: 0;
23
+ }
24
+ :host([size="sm"]) {
25
+ --_size: 1.75rem;
26
+ font-size: var(--st-font-size-xs);
27
+ }
28
+ :host([size="lg"]) {
29
+ --_size: 3.5rem;
30
+ font-size: 1.25rem;
31
+ }
32
+ .avatar {
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ width: 100%;
37
+ height: 100%;
38
+ overflow: hidden;
39
+ border-radius: 50%;
40
+ background: var(--st-color-primary-bg);
41
+ color: var(--st-color-primary-text);
42
+ border: 1px solid var(--st-color-border);
43
+ font-weight: var(--st-font-weight-medium);
44
+ user-select: none;
45
+ }
46
+ img {
47
+ width: 100%;
48
+ height: 100%;
49
+ object-fit: cover;
50
+ }
51
+ `,
52
+ ];
53
+
54
+ protected willUpdate(changed: Map<string, unknown>) {
55
+ if (changed.has("src")) this._failed = false;
56
+ }
57
+
58
+ /** First letters of the first and last words, uppercased. */
59
+ get initials() {
60
+ const parts = this.name.trim().split(/\s+/).filter(Boolean);
61
+ if (!parts.length) return "";
62
+ const last = parts.length > 1 ? parts[parts.length - 1][0] : "";
63
+ return (parts[0][0] + last).toUpperCase();
64
+ }
65
+
66
+ render() {
67
+ const showImage = this.src && !this._failed;
68
+ return html`
69
+ <div class="avatar" role="img" aria-label=${this.name || "Avatar"}>
70
+ ${showImage
71
+ ? html`<img src=${this.src} alt="" @error=${() => (this._failed = true)} />`
72
+ : this.initials
73
+ ? html`<span aria-hidden="true">${this.initials}</span>`
74
+ : html`<st-icon name="user" size="sm" aria-hidden="true"></st-icon>`}
75
+ </div>
76
+ `;
77
+ }
78
+ }
79
+
80
+ declare global {
81
+ interface HTMLElementTagNameMap {
82
+ "st-avatar": StAvatar;
83
+ }
84
+ }