@prismora/elements 0.0.0-stage → 0.1.1

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 (393) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +21 -2
  3. package/components.json +15600 -0
  4. package/custom-elements.json +56320 -0
  5. package/dist/base.d.ts +42 -0
  6. package/dist/base.js +62 -0
  7. package/dist/catalog.d.ts +33 -0
  8. package/dist/catalog.js +803 -0
  9. package/dist/components/accordion.d.ts +31 -0
  10. package/dist/components/accordion.js +63 -0
  11. package/dist/components/alert.d.ts +27 -0
  12. package/dist/components/alert.js +40 -0
  13. package/dist/components/avatar-group.d.ts +23 -0
  14. package/dist/components/avatar-group.js +43 -0
  15. package/dist/components/avatar.d.ts +24 -0
  16. package/dist/components/avatar.js +43 -0
  17. package/dist/components/back-to-top.d.ts +32 -0
  18. package/dist/components/back-to-top.js +50 -0
  19. package/dist/components/badge.d.ts +17 -0
  20. package/dist/components/badge.js +20 -0
  21. package/dist/components/banner.d.ts +34 -0
  22. package/dist/components/banner.js +54 -0
  23. package/dist/components/breadcrumb.d.ts +42 -0
  24. package/dist/components/breadcrumb.js +63 -0
  25. package/dist/components/button-group.d.ts +14 -0
  26. package/dist/components/button-group.js +28 -0
  27. package/dist/components/button.d.ts +59 -0
  28. package/dist/components/button.js +162 -0
  29. package/dist/components/calendar.d.ts +48 -0
  30. package/dist/components/calendar.js +296 -0
  31. package/dist/components/card.d.ts +23 -0
  32. package/dist/components/card.js +44 -0
  33. package/dist/components/carousel.d.ts +41 -0
  34. package/dist/components/carousel.js +156 -0
  35. package/dist/components/cascader.d.ts +70 -0
  36. package/dist/components/cascader.js +220 -0
  37. package/dist/components/chart.d.ts +59 -0
  38. package/dist/components/chart.js +267 -0
  39. package/dist/components/chat.d.ts +98 -0
  40. package/dist/components/chat.js +134 -0
  41. package/dist/components/checkbox-group.d.ts +48 -0
  42. package/dist/components/checkbox-group.js +111 -0
  43. package/dist/components/checkbox.d.ts +23 -0
  44. package/dist/components/checkbox.js +70 -0
  45. package/dist/components/code-block.d.ts +46 -0
  46. package/dist/components/code-block.js +86 -0
  47. package/dist/components/color-picker.d.ts +46 -0
  48. package/dist/components/color-picker.js +292 -0
  49. package/dist/components/combobox.d.ts +89 -0
  50. package/dist/components/combobox.js +384 -0
  51. package/dist/components/command.d.ts +96 -0
  52. package/dist/components/command.js +289 -0
  53. package/dist/components/context-menu.d.ts +23 -0
  54. package/dist/components/context-menu.js +110 -0
  55. package/dist/components/copy-button.d.ts +33 -0
  56. package/dist/components/copy-button.js +62 -0
  57. package/dist/components/countdown.d.ts +36 -0
  58. package/dist/components/countdown.js +56 -0
  59. package/dist/components/data-table.d.ts +180 -0
  60. package/dist/components/data-table.js +1060 -0
  61. package/dist/components/date-picker.d.ts +47 -0
  62. package/dist/components/date-picker.js +267 -0
  63. package/dist/components/description-list.d.ts +38 -0
  64. package/dist/components/description-list.js +41 -0
  65. package/dist/components/dialog.d.ts +47 -0
  66. package/dist/components/dialog.js +189 -0
  67. package/dist/components/divider.d.ts +16 -0
  68. package/dist/components/divider.js +23 -0
  69. package/dist/components/drawer.d.ts +19 -0
  70. package/dist/components/drawer.js +27 -0
  71. package/dist/components/editor.d.ts +50 -0
  72. package/dist/components/editor.js +474 -0
  73. package/dist/components/empty-state.d.ts +24 -0
  74. package/dist/components/empty-state.js +27 -0
  75. package/dist/components/file-upload.d.ts +56 -0
  76. package/dist/components/file-upload.js +176 -0
  77. package/dist/components/form-control.d.ts +69 -0
  78. package/dist/components/form-control.js +134 -0
  79. package/dist/components/form.d.ts +38 -0
  80. package/dist/components/form.js +161 -0
  81. package/dist/components/format-number.d.ts +37 -0
  82. package/dist/components/format-number.js +86 -0
  83. package/dist/components/icon.d.ts +34 -0
  84. package/dist/components/icon.js +47 -0
  85. package/dist/components/image.d.ts +44 -0
  86. package/dist/components/image.js +53 -0
  87. package/dist/components/indicator.d.ts +41 -0
  88. package/dist/components/indicator.js +65 -0
  89. package/dist/components/inline-edit.d.ts +45 -0
  90. package/dist/components/inline-edit.js +129 -0
  91. package/dist/components/input.d.ts +55 -0
  92. package/dist/components/input.js +186 -0
  93. package/dist/components/kbd.d.ts +15 -0
  94. package/dist/components/kbd.js +18 -0
  95. package/dist/components/list.d.ts +68 -0
  96. package/dist/components/list.js +180 -0
  97. package/dist/components/menu.d.ts +22 -0
  98. package/dist/components/menu.js +182 -0
  99. package/dist/components/menubar.d.ts +20 -0
  100. package/dist/components/menubar.js +120 -0
  101. package/dist/components/meter.d.ts +38 -0
  102. package/dist/components/meter.js +48 -0
  103. package/dist/components/nav.d.ts +91 -0
  104. package/dist/components/nav.js +228 -0
  105. package/dist/components/number-input.d.ts +26 -0
  106. package/dist/components/number-input.js +70 -0
  107. package/dist/components/pagination.d.ts +44 -0
  108. package/dist/components/pagination.js +94 -0
  109. package/dist/components/pin-input.d.ts +25 -0
  110. package/dist/components/pin-input.js +128 -0
  111. package/dist/components/popover.d.ts +23 -0
  112. package/dist/components/popover.js +140 -0
  113. package/dist/components/progress.d.ts +26 -0
  114. package/dist/components/progress.js +66 -0
  115. package/dist/components/pull-refresh.d.ts +41 -0
  116. package/dist/components/pull-refresh.js +101 -0
  117. package/dist/components/qr-code.d.ts +33 -0
  118. package/dist/components/qr-code.js +54 -0
  119. package/dist/components/radio-group.d.ts +37 -0
  120. package/dist/components/radio-group.js +82 -0
  121. package/dist/components/range-slider.d.ts +46 -0
  122. package/dist/components/range-slider.js +95 -0
  123. package/dist/components/rating.d.ts +38 -0
  124. package/dist/components/rating.js +80 -0
  125. package/dist/components/relative-time.d.ts +31 -0
  126. package/dist/components/relative-time.js +51 -0
  127. package/dist/components/scheduler.d.ts +84 -0
  128. package/dist/components/scheduler.js +187 -0
  129. package/dist/components/segmented.d.ts +58 -0
  130. package/dist/components/segmented.js +129 -0
  131. package/dist/components/select.d.ts +62 -0
  132. package/dist/components/select.js +140 -0
  133. package/dist/components/share-button.d.ts +37 -0
  134. package/dist/components/share-button.js +60 -0
  135. package/dist/components/signature.d.ts +54 -0
  136. package/dist/components/signature.js +152 -0
  137. package/dist/components/skeleton.d.ts +21 -0
  138. package/dist/components/skeleton.js +26 -0
  139. package/dist/components/slider.d.ts +31 -0
  140. package/dist/components/slider.js +80 -0
  141. package/dist/components/sortable.d.ts +22 -0
  142. package/dist/components/sortable.js +196 -0
  143. package/dist/components/sparkline.d.ts +28 -0
  144. package/dist/components/sparkline.js +46 -0
  145. package/dist/components/spinner.d.ts +16 -0
  146. package/dist/components/spinner.js +22 -0
  147. package/dist/components/splitter.d.ts +28 -0
  148. package/dist/components/splitter.js +89 -0
  149. package/dist/components/stat.d.ts +28 -0
  150. package/dist/components/stat.js +33 -0
  151. package/dist/components/steps.d.ts +53 -0
  152. package/dist/components/steps.js +91 -0
  153. package/dist/components/switch.d.ts +12 -0
  154. package/dist/components/switch.js +18 -0
  155. package/dist/components/table.d.ts +58 -0
  156. package/dist/components/table.js +96 -0
  157. package/dist/components/tabs.d.ts +62 -0
  158. package/dist/components/tabs.js +310 -0
  159. package/dist/components/tag.d.ts +32 -0
  160. package/dist/components/tag.js +58 -0
  161. package/dist/components/textarea.d.ts +25 -0
  162. package/dist/components/textarea.js +56 -0
  163. package/dist/components/theme-switch.d.ts +51 -0
  164. package/dist/components/theme-switch.js +85 -0
  165. package/dist/components/time-picker.d.ts +39 -0
  166. package/dist/components/time-picker.js +257 -0
  167. package/dist/components/timeline.d.ts +38 -0
  168. package/dist/components/timeline.js +56 -0
  169. package/dist/components/toaster.d.ts +25 -0
  170. package/dist/components/toaster.js +44 -0
  171. package/dist/components/toggle-group.d.ts +70 -0
  172. package/dist/components/toggle-group.js +172 -0
  173. package/dist/components/toolbar.d.ts +23 -0
  174. package/dist/components/toolbar.js +81 -0
  175. package/dist/components/tooltip.d.ts +18 -0
  176. package/dist/components/tooltip.js +92 -0
  177. package/dist/components/tour.d.ts +41 -0
  178. package/dist/components/tour.js +197 -0
  179. package/dist/components/transfer.d.ts +57 -0
  180. package/dist/components/transfer.js +161 -0
  181. package/dist/components/tree-select.d.ts +66 -0
  182. package/dist/components/tree-select.js +282 -0
  183. package/dist/components/tree.d.ts +129 -0
  184. package/dist/components/tree.js +427 -0
  185. package/dist/components/virtual-list.d.ts +41 -0
  186. package/dist/components/virtual-list.js +77 -0
  187. package/dist/confirm.d.ts +21 -0
  188. package/dist/confirm.js +69 -0
  189. package/dist/count.d.ts +5 -0
  190. package/dist/count.js +12 -0
  191. package/dist/data-table/icons.d.ts +8 -0
  192. package/dist/data-table/icons.js +10 -0
  193. package/dist/data-table/logic.d.ts +33 -0
  194. package/dist/data-table/logic.js +141 -0
  195. package/dist/data-table/strings.d.ts +37 -0
  196. package/dist/data-table/strings.js +36 -0
  197. package/dist/data-table/types.d.ts +76 -0
  198. package/dist/data-table/types.js +1 -0
  199. package/dist/define.d.ts +2 -0
  200. package/dist/define.js +2 -0
  201. package/dist/field-validity.d.ts +42 -0
  202. package/dist/field-validity.js +58 -0
  203. package/dist/floating.d.ts +13 -0
  204. package/dist/floating.js +65 -0
  205. package/dist/highlight.d.ts +11 -0
  206. package/dist/highlight.js +103 -0
  207. package/dist/id.d.ts +2 -0
  208. package/dist/id.js +3 -0
  209. package/dist/index.d.ts +102 -0
  210. package/dist/index.js +102 -0
  211. package/dist/manifest.d.ts +51 -0
  212. package/dist/manifest.js +11 -0
  213. package/dist/named-icon.d.ts +8 -0
  214. package/dist/named-icon.js +8 -0
  215. package/dist/patterns/account.d.ts +6 -0
  216. package/dist/patterns/account.js +137 -0
  217. package/dist/patterns/app.d.ts +7 -0
  218. package/dist/patterns/app.js +351 -0
  219. package/dist/patterns/commerce.d.ts +4 -0
  220. package/dist/patterns/commerce.js +200 -0
  221. package/dist/patterns/flows.d.ts +3 -0
  222. package/dist/patterns/flows.js +100 -0
  223. package/dist/patterns/index.d.ts +9 -0
  224. package/dist/patterns/index.js +29 -0
  225. package/dist/patterns/marketing.d.ts +4 -0
  226. package/dist/patterns/marketing.js +173 -0
  227. package/dist/patterns/more.d.ts +15 -0
  228. package/dist/patterns/more.js +581 -0
  229. package/dist/patterns/shell.d.ts +9 -0
  230. package/dist/patterns/shell.js +48 -0
  231. package/dist/patterns/types.d.ts +19 -0
  232. package/dist/patterns/types.js +1 -0
  233. package/dist/position.d.ts +2 -0
  234. package/dist/position.js +33 -0
  235. package/dist/prismora.standalone.js +5222 -0
  236. package/dist/prismora.standalone.js.map +199 -0
  237. package/dist/qr.d.ts +14 -0
  238. package/dist/qr.js +258 -0
  239. package/dist/register.d.ts +8 -0
  240. package/dist/register.js +21 -0
  241. package/dist/registry.d.ts +203 -0
  242. package/dist/registry.js +203 -0
  243. package/dist/remote.d.ts +58 -0
  244. package/dist/remote.js +130 -0
  245. package/dist/sheet.d.ts +34 -0
  246. package/dist/sheet.js +153 -0
  247. package/dist/styles/accordion.d.ts +2 -0
  248. package/dist/styles/accordion.js +3 -0
  249. package/dist/styles/alert.d.ts +2 -0
  250. package/dist/styles/alert.js +3 -0
  251. package/dist/styles/avatar.d.ts +2 -0
  252. package/dist/styles/avatar.js +3 -0
  253. package/dist/styles/badge.d.ts +2 -0
  254. package/dist/styles/badge.js +3 -0
  255. package/dist/styles/banner.d.ts +2 -0
  256. package/dist/styles/banner.js +3 -0
  257. package/dist/styles/breadcrumb.d.ts +2 -0
  258. package/dist/styles/breadcrumb.js +3 -0
  259. package/dist/styles/button.d.ts +2 -0
  260. package/dist/styles/button.js +3 -0
  261. package/dist/styles/calendar.d.ts +2 -0
  262. package/dist/styles/calendar.js +3 -0
  263. package/dist/styles/card.d.ts +2 -0
  264. package/dist/styles/card.js +3 -0
  265. package/dist/styles/carousel.d.ts +2 -0
  266. package/dist/styles/carousel.js +3 -0
  267. package/dist/styles/chart.d.ts +2 -0
  268. package/dist/styles/chart.js +3 -0
  269. package/dist/styles/chat.d.ts +2 -0
  270. package/dist/styles/chat.js +3 -0
  271. package/dist/styles/checkbox.d.ts +2 -0
  272. package/dist/styles/checkbox.js +3 -0
  273. package/dist/styles/color-picker.d.ts +2 -0
  274. package/dist/styles/color-picker.js +3 -0
  275. package/dist/styles/combobox.d.ts +2 -0
  276. package/dist/styles/combobox.js +3 -0
  277. package/dist/styles/command.d.ts +2 -0
  278. package/dist/styles/command.js +3 -0
  279. package/dist/styles/data-table.d.ts +2 -0
  280. package/dist/styles/data-table.js +3 -0
  281. package/dist/styles/description-list.d.ts +2 -0
  282. package/dist/styles/description-list.js +3 -0
  283. package/dist/styles/dialog.d.ts +2 -0
  284. package/dist/styles/dialog.js +3 -0
  285. package/dist/styles/drawer.d.ts +2 -0
  286. package/dist/styles/drawer.js +3 -0
  287. package/dist/styles/editor.d.ts +2 -0
  288. package/dist/styles/editor.js +3 -0
  289. package/dist/styles/empty-state.d.ts +2 -0
  290. package/dist/styles/empty-state.js +3 -0
  291. package/dist/styles/extras.d.ts +2 -0
  292. package/dist/styles/extras.js +3 -0
  293. package/dist/styles/field.d.ts +2 -0
  294. package/dist/styles/field.js +3 -0
  295. package/dist/styles/file-upload.d.ts +2 -0
  296. package/dist/styles/file-upload.js +3 -0
  297. package/dist/styles/foundation.d.ts +2 -0
  298. package/dist/styles/foundation.js +3 -0
  299. package/dist/styles/helpers.d.ts +2 -0
  300. package/dist/styles/helpers.js +3 -0
  301. package/dist/styles/icon.d.ts +2 -0
  302. package/dist/styles/icon.js +3 -0
  303. package/dist/styles/image.d.ts +2 -0
  304. package/dist/styles/image.js +3 -0
  305. package/dist/styles/indicator.d.ts +2 -0
  306. package/dist/styles/indicator.js +3 -0
  307. package/dist/styles/input.d.ts +2 -0
  308. package/dist/styles/input.js +3 -0
  309. package/dist/styles/kbd.d.ts +2 -0
  310. package/dist/styles/kbd.js +3 -0
  311. package/dist/styles/list.d.ts +2 -0
  312. package/dist/styles/list.js +3 -0
  313. package/dist/styles/listbox.d.ts +2 -0
  314. package/dist/styles/listbox.js +3 -0
  315. package/dist/styles/meter.d.ts +2 -0
  316. package/dist/styles/meter.js +3 -0
  317. package/dist/styles/nav.d.ts +2 -0
  318. package/dist/styles/nav.js +3 -0
  319. package/dist/styles/number-input.d.ts +2 -0
  320. package/dist/styles/number-input.js +3 -0
  321. package/dist/styles/overlay.d.ts +2 -0
  322. package/dist/styles/overlay.js +3 -0
  323. package/dist/styles/pagination.d.ts +2 -0
  324. package/dist/styles/pagination.js +3 -0
  325. package/dist/styles/pickers.d.ts +2 -0
  326. package/dist/styles/pickers.js +3 -0
  327. package/dist/styles/pin-input.d.ts +2 -0
  328. package/dist/styles/pin-input.js +3 -0
  329. package/dist/styles/popover.d.ts +2 -0
  330. package/dist/styles/popover.js +3 -0
  331. package/dist/styles/progress.d.ts +2 -0
  332. package/dist/styles/progress.js +3 -0
  333. package/dist/styles/pull-refresh.d.ts +2 -0
  334. package/dist/styles/pull-refresh.js +3 -0
  335. package/dist/styles/range-slider.d.ts +2 -0
  336. package/dist/styles/range-slider.js +3 -0
  337. package/dist/styles/rating.d.ts +2 -0
  338. package/dist/styles/rating.js +3 -0
  339. package/dist/styles/scheduler.d.ts +2 -0
  340. package/dist/styles/scheduler.js +3 -0
  341. package/dist/styles/segmented.d.ts +2 -0
  342. package/dist/styles/segmented.js +3 -0
  343. package/dist/styles/select.d.ts +2 -0
  344. package/dist/styles/select.js +3 -0
  345. package/dist/styles/separator.d.ts +2 -0
  346. package/dist/styles/separator.js +3 -0
  347. package/dist/styles/sheet.d.ts +2 -0
  348. package/dist/styles/sheet.js +3 -0
  349. package/dist/styles/skeleton.d.ts +2 -0
  350. package/dist/styles/skeleton.js +3 -0
  351. package/dist/styles/slider.d.ts +2 -0
  352. package/dist/styles/slider.js +3 -0
  353. package/dist/styles/sortable.d.ts +2 -0
  354. package/dist/styles/sortable.js +3 -0
  355. package/dist/styles/spinner.d.ts +2 -0
  356. package/dist/styles/spinner.js +3 -0
  357. package/dist/styles/splitter.d.ts +2 -0
  358. package/dist/styles/splitter.js +3 -0
  359. package/dist/styles/stat.d.ts +2 -0
  360. package/dist/styles/stat.js +3 -0
  361. package/dist/styles/steps.d.ts +2 -0
  362. package/dist/styles/steps.js +3 -0
  363. package/dist/styles/surface.d.ts +2 -0
  364. package/dist/styles/surface.js +3 -0
  365. package/dist/styles/switch.d.ts +2 -0
  366. package/dist/styles/switch.js +3 -0
  367. package/dist/styles/table.d.ts +2 -0
  368. package/dist/styles/table.js +3 -0
  369. package/dist/styles/tabs.d.ts +2 -0
  370. package/dist/styles/tabs.js +3 -0
  371. package/dist/styles/tag.d.ts +2 -0
  372. package/dist/styles/tag.js +3 -0
  373. package/dist/styles/time-picker.d.ts +2 -0
  374. package/dist/styles/time-picker.js +3 -0
  375. package/dist/styles/timeline.d.ts +2 -0
  376. package/dist/styles/timeline.js +3 -0
  377. package/dist/styles/toast.d.ts +2 -0
  378. package/dist/styles/toast.js +3 -0
  379. package/dist/styles/toggle.d.ts +2 -0
  380. package/dist/styles/toggle.js +3 -0
  381. package/dist/styles/toolbar.d.ts +2 -0
  382. package/dist/styles/toolbar.js +3 -0
  383. package/dist/styles/tooltip.d.ts +2 -0
  384. package/dist/styles/tooltip.js +3 -0
  385. package/dist/styles/tree.d.ts +2 -0
  386. package/dist/styles/tree.js +3 -0
  387. package/dist/table-core.d.ts +75 -0
  388. package/dist/table-core.js +205 -0
  389. package/dist/toast.d.ts +42 -0
  390. package/dist/toast.js +206 -0
  391. package/dist/top-layer.d.ts +4 -0
  392. package/dist/top-layer.js +33 -0
  393. package/package.json +101 -4
@@ -0,0 +1,267 @@
1
+ import { css, html, nothing, svg } from 'lit';
2
+ import { PmElement, defineElement } from '../base.js';
3
+ import chartCss from '../styles/chart.js';
4
+ import { numberList } from './sparkline.js';
5
+ const TONES = ['accent', 'secondary', 'info', 'success', 'warning', 'danger', 'neutral'];
6
+ const json = (fallback) => ({
7
+ fromAttribute: (v) => { try {
8
+ return v ? JSON.parse(v) : fallback;
9
+ }
10
+ catch {
11
+ return fallback;
12
+ } },
13
+ });
14
+ const labelList = { fromAttribute: (v) => { const t = (v ?? '').trim(); if (t.startsWith('[')) {
15
+ try {
16
+ return JSON.parse(t);
17
+ }
18
+ catch {
19
+ return [];
20
+ }
21
+ } return t ? t.split(',').map((s) => s.trim()) : []; } };
22
+ /** Round axis steps: 1, 2 or 5 times a power of ten. */
23
+ export function niceTicks(min, max, count = 4) {
24
+ if (min === max) {
25
+ max = min + 1;
26
+ }
27
+ const raw = (max - min) / count;
28
+ const mag = 10 ** Math.floor(Math.log10(raw));
29
+ const norm = raw / mag;
30
+ const step = (norm < 1.5 ? 1 : norm < 3 ? 2 : norm < 7 ? 5 : 10) * mag;
31
+ const lo = Math.floor(min / step) * step;
32
+ const hi = Math.ceil(max / step) * step;
33
+ const out = [];
34
+ for (let v = lo; v <= hi + step / 2; v += step)
35
+ out.push(Number(v.toPrecision(12)));
36
+ return out;
37
+ }
38
+ /**
39
+ * Chart: bar, line, area and donut charts drawn as SVG, with no dependencies. Colours come from the theme's roles,
40
+ * so charts follow every theme, mode and tone.
41
+ *
42
+ * Data: `labels` (categories) and `series` (`[{ name, values, tone? }]`), as properties or JSON attributes. For one
43
+ * series, `values="4,8,6"` is enough. A donut uses the first series: one slice per label.
44
+ *
45
+ * Reading values: hover or tap shows a tooltip; focus the chart and use the arrow keys to step through the data
46
+ * (Home/End jump, Escape clears). The same data is offered to screen readers as a table.
47
+ * @tag pm-chart
48
+ * @fires pm-select - A data point was clicked or chosen with Enter. detail: { index, label, values }
49
+ * @example <pm-chart type="bar" label="Orders per day" labels="Mon,Tue,Wed,Thu,Fri" values="32,45,38,51,60"></pm-chart>
50
+ */
51
+ export class PmChart extends PmElement {
52
+ static { this.componentName = 'chart'; }
53
+ static { this.styles = [...PmElement.styles, chartCss, css `:host { display: block; min-inline-size: 0; } :host([hidden]) { display: none; }`]; }
54
+ static { this.properties = {
55
+ type: { reflect: true }, label: {}, labels: { converter: labelList }, series: { converter: json([]) }, values: { converter: numberList },
56
+ height: { type: Number }, stacked: { type: Boolean }, hideLegend: { type: Boolean, attribute: 'hide-legend' }, valuePrefix: { attribute: 'value-prefix' }, valueSuffix: { attribute: 'value-suffix' },
57
+ loading: { type: Boolean }, emptyText: { attribute: 'empty-text' }, _w: { state: true }, _active: { state: true },
58
+ }; }
59
+ #ro;
60
+ constructor() { super(); this.labels = []; this.series = []; this._w = 0; this._active = -1; }
61
+ connectedCallback() {
62
+ super.connectedCallback();
63
+ this.#ro = new ResizeObserver(([e]) => { const w = Math.round(e.contentRect.width); if (w !== this._w)
64
+ this._w = w; });
65
+ this.#ro.observe(this);
66
+ }
67
+ disconnectedCallback() { super.disconnectedCallback(); this.#ro?.disconnect(); }
68
+ get #data() {
69
+ const s = this.series?.length ? this.series : this.values?.length ? [{ name: this.label ?? 'Value', values: this.values }] : [];
70
+ return s.filter((x) => Array.isArray(x.values));
71
+ }
72
+ get #count() { return Math.max(this.labels?.length ?? 0, ...this.#data.map((s) => s.values.length), 0); }
73
+ #color(i, s) {
74
+ const data = this.#data;
75
+ if (s?.tone)
76
+ return `var(--pm-color-${s.tone}-solid)`;
77
+ return data.length === 1 && this.type !== 'donut' ? 'var(--pm-tone-solid)' : `var(--pm-color-${TONES[i % TONES.length]}-solid)`;
78
+ }
79
+ #fmt(n, compact = false) {
80
+ const f = new Intl.NumberFormat(this.closest('[lang]')?.getAttribute('lang') || undefined, compact ? { notation: 'compact', maximumFractionDigits: 1 } : { maximumFractionDigits: 2 });
81
+ return `${this.valuePrefix ?? ''}${f.format(n)}${this.valueSuffix ?? ''}`;
82
+ }
83
+ #labelAt(i) { return this.labels?.[i] ?? String(i + 1); }
84
+ #setActive(i) { if (i !== this._active)
85
+ this._active = i; }
86
+ #onKey = (e) => {
87
+ const n = this.#count;
88
+ if (!n)
89
+ return;
90
+ const rtl = getComputedStyle(this).direction === 'rtl' && this.type === 'donut';
91
+ const step = (d) => { e.preventDefault(); this.#setActive(this._active < 0 ? (d > 0 ? 0 : n - 1) : (this._active + d + n) % n); };
92
+ if (e.key === 'ArrowRight')
93
+ step(rtl ? -1 : 1);
94
+ else if (e.key === 'ArrowLeft')
95
+ step(rtl ? 1 : -1);
96
+ else if (e.key === 'Home') {
97
+ e.preventDefault();
98
+ this.#setActive(0);
99
+ }
100
+ else if (e.key === 'End') {
101
+ e.preventDefault();
102
+ this.#setActive(n - 1);
103
+ }
104
+ else if (e.key === 'Escape' && this._active >= 0) {
105
+ e.preventDefault();
106
+ this.#setActive(-1);
107
+ }
108
+ else if ((e.key === 'Enter' || e.key === ' ') && this._active >= 0) {
109
+ e.preventDefault();
110
+ this.#select(this._active);
111
+ }
112
+ };
113
+ #select(i) { this.emit('pm-select', { index: i, label: this.#labelAt(i), values: this.#data.map((s) => s.values[i]) }); }
114
+ /* ---------- Cartesian (bar, line, area) ---------- */
115
+ #cartesian(H) {
116
+ const data = this.#data;
117
+ const n = this.#count;
118
+ const W = Math.max(this._w, 120);
119
+ const type = this.type ?? 'bar';
120
+ const stacked = !!this.stacked && data.length > 1;
121
+ const totals = Array.from({ length: n }, (_, i) => data.reduce((a, s) => a + Math.max(s.values[i] ?? 0, 0), 0));
122
+ const all = data.flatMap((s) => s.values);
123
+ const ticks = niceTicks(Math.min(0, ...all), Math.max(0, ...(stacked ? totals : all)));
124
+ const lo = ticks[0];
125
+ const hi = ticks.at(-1);
126
+ const left = Math.max(...ticks.map((t) => this.#fmt(t, true).length)) * 7 + 10;
127
+ const top = 8;
128
+ const bottom = 24;
129
+ const right = 8;
130
+ const pw = Math.max(W - left - right, 10);
131
+ const ph = H - top - bottom;
132
+ const y = (v) => top + (1 - (v - lo) / (hi - lo)) * ph;
133
+ const band = pw / n;
134
+ const cx = (i) => left + band * (i + 0.5);
135
+ const active = this._active;
136
+ // X labels: thin them out so they never overlap.
137
+ const longest = Math.max(...Array.from({ length: n }, (_, i) => this.#labelAt(i).length), 1) * 7 + 12;
138
+ const every = Math.max(1, Math.ceil(longest / band));
139
+ const marks = [];
140
+ if (type === 'bar') {
141
+ const groups = stacked ? 1 : data.length;
142
+ const bw = Math.min((band * 0.72) / groups, 48);
143
+ data.forEach((s, si) => {
144
+ for (let i = 0; i < n; i++) {
145
+ const v = s.values[i] ?? 0;
146
+ const base = stacked ? data.slice(0, si).reduce((a, p) => a + Math.max(p.values[i] ?? 0, 0), 0) : 0;
147
+ const y0 = y(base);
148
+ const y1 = y(base + v);
149
+ const x = stacked ? cx(i) - bw / 2 : cx(i) - (bw * groups) / 2 + bw * si;
150
+ marks.push(svg `<rect class="pm-chart-mark" x=${x + 1} y=${Math.min(y0, y1)} width=${Math.max(bw - 2, 1)} height=${Math.max(Math.abs(y1 - y0), v ? 1 : 0)} rx="3"
151
+ fill=${this.#color(si, s)} ?data-dim=${active >= 0 && active !== i}></rect>`);
152
+ }
153
+ });
154
+ }
155
+ else {
156
+ const acc = new Array(n).fill(0);
157
+ data.forEach((s, si) => {
158
+ const pts = Array.from({ length: n }, (_, i) => {
159
+ const v = s.values[i];
160
+ if (v === undefined || v === null)
161
+ return undefined;
162
+ const base = stacked && type === 'area' ? acc[i] : 0;
163
+ if (stacked && type === 'area')
164
+ acc[i] = base + Math.max(v, 0);
165
+ return { x: cx(i), y: y(base + v), y0: y(base) };
166
+ });
167
+ const live = pts.filter((p) => !!p);
168
+ if (!live.length)
169
+ return;
170
+ const line = live.map((p, i) => `${i ? 'L' : 'M'}${p.x.toFixed(1)},${p.y.toFixed(1)}`).join('');
171
+ const color = this.#color(si, s);
172
+ if (type === 'area')
173
+ marks.push(svg `<path class="pm-chart-area" fill=${color} d=${`${line}${[...live].reverse().map((p) => `L${p.x.toFixed(1)},${p.y0.toFixed(1)}`).join('')}Z`}></path>`);
174
+ marks.push(svg `<path class="pm-chart-line" stroke=${color} d=${line}></path>`);
175
+ if (live.length === 1 || (active >= 0 && pts[active])) {
176
+ const p = pts[active >= 0 ? active : 0] ?? live[0];
177
+ marks.push(svg `<circle class="pm-chart-dot" cx=${p.x} cy=${p.y} r="4.5" fill=${color}></circle>`);
178
+ }
179
+ });
180
+ }
181
+ const move = (e) => {
182
+ const box = e.currentTarget.getBoundingClientRect();
183
+ const i = Math.floor((e.clientX - box.left - left) / band);
184
+ this.#setActive(i >= 0 && i < n ? i : -1);
185
+ };
186
+ return html `<svg width=${W} height=${H} viewBox="0 0 ${W} ${H}" aria-hidden="true"
187
+ @pointermove=${move} @pointerdown=${move} @pointerleave=${(e) => { if (e.pointerType === 'mouse')
188
+ this.#setActive(-1); }}
189
+ @click=${() => { if (this._active >= 0)
190
+ this.#select(this._active); }}>
191
+ ${ticks.map((t) => svg `<line class="pm-chart-grid ${t === 0 ? 'pm-chart-zero' : ''}" x1=${left} x2=${W - right} y1=${Math.round(y(t)) + 0.5} y2=${Math.round(y(t)) + 0.5}></line>
192
+ <text x=${left - 8} y=${y(t)} text-anchor="end" dominant-baseline="middle">${this.#fmt(t, true)}</text>`)}
193
+ ${Array.from({ length: n }, (_, i) => (i % every === 0 ? svg `<text x=${cx(i)} y=${H - 6} text-anchor="middle">${this.#labelAt(i)}</text>` : nothing))}
194
+ ${active >= 0 && type !== 'bar' ? svg `<line class="pm-chart-guide" x1=${cx(active)} x2=${cx(active)} y1=${top} y2=${top + ph}></line>` : nothing}
195
+ ${marks}
196
+ </svg>${this.#tip(active, active >= 0 ? cx(active) : 0, W)}`;
197
+ }
198
+ /* ---------- Donut ---------- */
199
+ #donut(H) {
200
+ const s = this.#data[0];
201
+ const W = Math.max(this._w, 120);
202
+ const vals = s.values.map((v) => Math.max(v, 0));
203
+ const total = vals.reduce((a, b) => a + b, 0) || 1;
204
+ const r = Math.min(W, H) / 2 - 4;
205
+ const inner = r * 0.64;
206
+ const cx = W / 2;
207
+ const cy = H / 2;
208
+ let a = -Math.PI / 2;
209
+ const arc = (v) => {
210
+ const b = a + (v / total) * Math.PI * 2;
211
+ const large = b - a > Math.PI ? 1 : 0;
212
+ const p = (rad, ang) => `${(cx + rad * Math.cos(ang)).toFixed(2)},${(cy + rad * Math.sin(ang)).toFixed(2)}`;
213
+ // A full circle cannot be one arc: stop just short of it.
214
+ const end = Math.min(b, a + Math.PI * 2 - 0.0001);
215
+ const d = `M${p(r, a)}A${r},${r} 0 ${large} 1 ${p(r, end)}L${p(inner, end)}A${inner},${inner} 0 ${large} 0 ${p(inner, a)}Z`;
216
+ a = b;
217
+ return d;
218
+ };
219
+ const active = this._active;
220
+ return html `<svg width=${W} height=${H} viewBox="0 0 ${W} ${H}" aria-hidden="true" @pointerleave=${(e) => { if (e.pointerType === 'mouse')
221
+ this.#setActive(-1); }}>
222
+ ${vals.map((v, i) => (v ? svg `<path class="pm-chart-mark pm-chart-slice" d=${arc(v)} fill=${`var(--pm-color-${TONES[i % TONES.length]}-solid)`} ?data-dim=${active >= 0 && active !== i}
223
+ @pointerenter=${() => this.#setActive(i)} @pointerdown=${() => this.#setActive(i)} @click=${() => this.#select(i)}></path>` : nothing))}
224
+ <text class="pm-chart-total" x=${cx} y=${cy - 2} text-anchor="middle" dominant-baseline="middle">${this.#fmt(active >= 0 ? vals[active] ?? 0 : total, true)}</text>
225
+ <text x=${cx} y=${cy + 20} text-anchor="middle">${active >= 0 ? this.#labelAt(active) : 'Total'}</text>
226
+ </svg>`;
227
+ }
228
+ #tip(i, x, W) {
229
+ if (i < 0)
230
+ return nothing;
231
+ const data = this.#data;
232
+ const flip = x > W / 2;
233
+ return html `<div class="pm-chart-tip" part="tooltip" style="translate: ${flip ? `max(0px, calc(${x - 12}px - 100%))` : `${x + 12}px`} 4px">
234
+ <span class="pm-chart-tip-title">${this.#labelAt(i)}</span>
235
+ ${data.map((s, si) => html `<span class="pm-chart-tip-row"><span class="pm-chart-swatch" style="inline-size:.6rem;block-size:.6rem;border-radius:2px;background:${this.#color(si, s)}"></span>${data.length > 1 ? s.name : ''}<strong>${s.values[i] === undefined ? '–' : this.#fmt(s.values[i])}</strong></span>`)}
236
+ </div>`;
237
+ }
238
+ render() {
239
+ const data = this.#data;
240
+ const n = this.#count;
241
+ const donut = this.type === 'donut';
242
+ const H = this.height ?? (donut ? 200 : 240);
243
+ if (this.loading)
244
+ return html `<div class="pm-chart" part="base" aria-busy="true"><div class="pm-chart-loading" style="block-size:${H}px" role="status" aria-label="Loading chart"></div></div>`;
245
+ if (!data.length || !n)
246
+ return html `<div class="pm-chart" part="base"><div class="pm-chart-empty" style="block-size:${H}px">${this.emptyText ?? 'No data'}</div></div>`;
247
+ const legend = !this.hideLegend && (donut || data.length > 1);
248
+ const active = this._active;
249
+ const spoken = active >= 0 ? `${this.#labelAt(active)}: ${data.map((s) => `${data.length > 1 ? `${s.name} ` : ''}${s.values[active] === undefined ? 'no value' : this.#fmt(s.values[active])}`).join(', ')}` : '';
250
+ return html `<figure class="pm-chart" part="base" style="margin:0">
251
+ <div class="pm-chart-plot" part="plot" tabindex="0" role="group" aria-roledescription="chart"
252
+ aria-label=${`${this.label ?? 'Chart'}. Use the arrow keys to read values.`}
253
+ @keydown=${this.#onKey} @blur=${() => this.#setActive(-1)}>
254
+ ${this._w ? (donut ? this.#donut(H) : this.#cartesian(H)) : html `<div style="block-size:${H}px"></div>`}
255
+ </div>
256
+ ${legend ? html `<ul class="pm-chart-legend" part="legend">${(donut ? Array.from({ length: n }, (_, i) => ({ name: this.#labelAt(i), color: `var(--pm-color-${TONES[i % TONES.length]}-solid)`, value: this.#fmt(data[0].values[i] ?? 0) }))
257
+ : data.map((s, i) => ({ name: s.name, color: this.#color(i, s), value: '' }))).map((l) => html `<li><span class="pm-chart-swatch" style="--_c:${l.color}"></span>${l.name}${l.value ? html ` <strong>${l.value}</strong>` : nothing}</li>`)}</ul>` : nothing}
258
+ <span class="pm-visually-hidden" aria-live="polite">${spoken}</span>
259
+ <table class="pm-visually-hidden">
260
+ <caption>${this.label ?? 'Chart data'}</caption>
261
+ <thead><tr><th scope="col">${donut ? 'Segment' : 'Category'}</th>${data.slice(0, donut ? 1 : undefined).map((s) => html `<th scope="col">${s.name}</th>`)}</tr></thead>
262
+ <tbody>${Array.from({ length: n }, (_, i) => html `<tr><th scope="row">${this.#labelAt(i)}</th>${data.slice(0, donut ? 1 : undefined).map((s) => html `<td>${s.values[i] === undefined ? '' : this.#fmt(s.values[i])}</td>`)}</tr>`)}</tbody>
263
+ </table>
264
+ </figure>`;
265
+ }
266
+ }
267
+ defineElement('pm-chart', PmChart);
@@ -0,0 +1,98 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmElement } from '../base.js';
3
+ /**
4
+ * Chat message list for support chat, team messaging and AI assistants.
5
+ *
6
+ * New messages are announced to screen readers, and the list stays pinned to the latest message while the reader is
7
+ * at the bottom; after scrolling up, a "Jump to latest" button appears instead of moving the page. Give it a height
8
+ * (or put it in a flex/grid cell) so it scrolls.
9
+ * @tag pm-chat
10
+ * @slot - `<pm-chat-message>` elements (and `.pm-chat-day` date separators).
11
+ * @example <pm-chat label="Conversation with Ada"><pm-chat-message name="Ada" time="09:41">Is the invoice ready?</pm-chat-message><pm-chat-message from="me" time="09:42" status="Read">Sending it now.</pm-chat-message></pm-chat>
12
+ */
13
+ export declare class PmChat extends PmElement {
14
+ #private;
15
+ static componentName: string;
16
+ static styles: import("lit").CSSResult[];
17
+ static properties: PropertyDeclarations;
18
+ /** Accessible name of the conversation. */
19
+ label?: string;
20
+ _away: boolean;
21
+ constructor();
22
+ /** Scroll to the newest message. */
23
+ scrollToLatest(smooth?: boolean): void;
24
+ connectedCallback(): void;
25
+ disconnectedCallback(): void;
26
+ protected firstUpdated(): void;
27
+ render(): import("lit").TemplateResult<1>;
28
+ }
29
+ /**
30
+ * One chat message: a bubble with optional sender name, time, avatar and delivery status.
31
+ *
32
+ * `from="me"` puts it on the end side in the tone colour. For AI answers use `variant="plain"`; `streaming` shows a
33
+ * caret while text arrives and `typing` shows the three-dot indicator.
34
+ * @tag pm-chat-message
35
+ * @slot - Message content.
36
+ * @slot avatar - A `<pm-avatar>` for the sender.
37
+ * @slot actions - Buttons under the message (copy, retry, feedback).
38
+ * @example <pm-chat-message name="Ada" time="09:41">Is the invoice ready?</pm-chat-message>
39
+ */
40
+ export declare class PmChatMessage extends PmElement {
41
+ static componentName: string;
42
+ static styles: import("lit").CSSResult[];
43
+ static properties: PropertyDeclarations;
44
+ /** me (own message, end side) or them (default). */
45
+ from?: 'me' | 'them';
46
+ /** Sender name shown above the bubble. */
47
+ name?: string;
48
+ /** Time text, e.g. "09:41". */
49
+ time?: string;
50
+ /** Delivery status under the bubble: "Sent", "Read", "Failed"… ("Failed" is shown in the danger colour). */
51
+ status?: string;
52
+ /** bubble (default) or plain (no bubble, full width). */
53
+ variant?: 'bubble' | 'plain';
54
+ /** Text is still arriving: shows a caret and marks the message busy. */
55
+ streaming?: boolean;
56
+ /** Show the typing indicator instead of content. */
57
+ typing?: boolean;
58
+ render(): import("lit").TemplateResult<1>;
59
+ }
60
+ /**
61
+ * Message composer: a text box that grows with its content and a send button.
62
+ *
63
+ * Enter sends, Shift+Enter adds a line (on phones Enter adds a line and the button sends). While `busy`, the button
64
+ * becomes Stop and fires `pm-stop`.
65
+ * @tag pm-composer
66
+ * @slot start - Buttons before the text (attach, emoji).
67
+ * @slot top - Content above the text (attachments, a reply preview, suggestion chips).
68
+ * @fires pm-send - A message was submitted. detail: { value }. The box clears unless the event is cancelled.
69
+ * @fires pm-stop - Stop was pressed while busy.
70
+ * @fires pm-input - The text changed. detail: { value }
71
+ * @example <pm-composer label="Message Ada" placeholder="Write a message"></pm-composer>
72
+ */
73
+ export declare class PmComposer extends PmElement {
74
+ #private;
75
+ static componentName: string;
76
+ static shadowRootOptions: {
77
+ delegatesFocus: boolean;
78
+ clonable?: boolean;
79
+ customElementRegistry?: CustomElementRegistry;
80
+ mode: ShadowRootMode;
81
+ serializable?: boolean;
82
+ slotAssignment?: SlotAssignmentMode;
83
+ };
84
+ static styles: import("lit").CSSResult[];
85
+ static properties: PropertyDeclarations;
86
+ value: string;
87
+ /** Accessible name of the text box. */
88
+ label?: string;
89
+ placeholder?: string;
90
+ disabled?: boolean;
91
+ /** A reply is being produced: Send becomes Stop. */
92
+ busy?: boolean;
93
+ maxlength?: number;
94
+ /** Text of the send button's accessible name (default "Send"). */
95
+ sendLabel?: string;
96
+ constructor();
97
+ render(): import("lit").TemplateResult<1>;
98
+ }
@@ -0,0 +1,134 @@
1
+ import { css, html, nothing } from 'lit';
2
+ import { PmElement, defineElement } from '../base.js';
3
+ import buttonCss from '../styles/button.js';
4
+ import chatCss from '../styles/chat.js';
5
+ /**
6
+ * Chat message list for support chat, team messaging and AI assistants.
7
+ *
8
+ * New messages are announced to screen readers, and the list stays pinned to the latest message while the reader is
9
+ * at the bottom; after scrolling up, a "Jump to latest" button appears instead of moving the page. Give it a height
10
+ * (or put it in a flex/grid cell) so it scrolls.
11
+ * @tag pm-chat
12
+ * @slot - `<pm-chat-message>` elements (and `.pm-chat-day` date separators).
13
+ * @example <pm-chat label="Conversation with Ada"><pm-chat-message name="Ada" time="09:41">Is the invoice ready?</pm-chat-message><pm-chat-message from="me" time="09:42" status="Read">Sending it now.</pm-chat-message></pm-chat>
14
+ */
15
+ export class PmChat extends PmElement {
16
+ static { this.componentName = 'chat'; }
17
+ static { this.styles = [...PmElement.styles, buttonCss, chatCss, css `:host { display: block; min-block-size: 0; } :host([hidden]) { display: none; }`]; }
18
+ static { this.properties = { label: {}, _away: { state: true } }; }
19
+ #observer;
20
+ constructor() { super(); this._away = false; }
21
+ get #box() { return this.renderRoot.querySelector('.pm-chat'); }
22
+ #atEnd() { const b = this.#box; return !b || b.scrollHeight - b.scrollTop - b.clientHeight < 48; }
23
+ /** Scroll to the newest message. */
24
+ scrollToLatest(smooth = false) {
25
+ const b = this.#box;
26
+ b?.scrollTo({ top: b.scrollHeight, behavior: smooth && !matchMedia('(prefers-reduced-motion: reduce)').matches ? 'smooth' : 'auto' });
27
+ this._away = false;
28
+ }
29
+ connectedCallback() {
30
+ super.connectedCallback();
31
+ // Follow new and streaming content only while the reader is at the bottom.
32
+ this.#observer = new MutationObserver(() => { if (this._away)
33
+ return; requestAnimationFrame(() => this.scrollToLatest()); });
34
+ this.#observer.observe(this, { childList: true, subtree: true, characterData: true });
35
+ }
36
+ disconnectedCallback() { super.disconnectedCallback(); this.#observer?.disconnect(); }
37
+ firstUpdated() { requestAnimationFrame(() => this.scrollToLatest()); }
38
+ render() {
39
+ return html `<div class="pm-chat" part="base" role="log" aria-label=${this.label ?? 'Conversation'} aria-live="polite" aria-relevant="additions" tabindex="0"
40
+ @scroll=${() => { const away = !this.#atEnd(); if (away !== this._away)
41
+ this._away = away; }}>
42
+ <slot></slot>
43
+ ${this._away ? html `<button type="button" class="pm-button pm-chat-latest" data-size="sm" data-variant="soft" @click=${() => this.scrollToLatest(true)}>Jump to latest</button>` : nothing}
44
+ </div>`;
45
+ }
46
+ }
47
+ /**
48
+ * One chat message: a bubble with optional sender name, time, avatar and delivery status.
49
+ *
50
+ * `from="me"` puts it on the end side in the tone colour. For AI answers use `variant="plain"`; `streaming` shows a
51
+ * caret while text arrives and `typing` shows the three-dot indicator.
52
+ * @tag pm-chat-message
53
+ * @slot - Message content.
54
+ * @slot avatar - A `<pm-avatar>` for the sender.
55
+ * @slot actions - Buttons under the message (copy, retry, feedback).
56
+ * @example <pm-chat-message name="Ada" time="09:41">Is the invoice ready?</pm-chat-message>
57
+ */
58
+ export class PmChatMessage extends PmElement {
59
+ static { this.componentName = 'chat-message'; }
60
+ static { this.styles = [...PmElement.styles, chatCss, css `:host { display: flex; flex-direction: column; } :host([hidden]) { display: none; }`]; }
61
+ static { this.properties = {
62
+ from: { reflect: true }, name: {}, time: {}, status: {}, variant: { reflect: true }, streaming: { type: Boolean, reflect: true }, typing: { type: Boolean, reflect: true },
63
+ }; }
64
+ render() {
65
+ const me = this.from === 'me';
66
+ return html `<div class="pm-message" part="base" data-from=${me ? 'me' : 'them'} data-variant=${this.variant ?? nothing} aria-busy=${this.streaming || this.typing ? 'true' : nothing}>
67
+ <span class="pm-message-avatar"><slot name="avatar"></slot></span>
68
+ ${this.name || this.time ? html `<span class="pm-message-meta">${this.name ? html `<strong>${this.name}</strong>` : nothing}${this.time ? html `<span>${this.time}</span>` : nothing}</span>` : nothing}
69
+ <div class="pm-message-bubble" part="bubble">
70
+ ${me && !this.name ? html `<span class="pm-visually-hidden">You: </span>` : nothing}
71
+ ${this.typing ? html `<span class="pm-message-typing" role="img" aria-label=${`${this.name ?? 'Someone'} is typing`}><span></span><span></span><span></span></span>` : html `<slot></slot>`}
72
+ ${this.streaming && !this.typing ? html `<span class="pm-message-caret" aria-hidden="true"></span>` : nothing}
73
+ </div>
74
+ ${this.status ? html `<span class="pm-message-status" part="status" data-status=${/fail|error/i.test(this.status) ? 'failed' : nothing}>${this.status}</span>` : nothing}
75
+ <div class="pm-message-actions"><slot name="actions"></slot></div>
76
+ </div>`;
77
+ }
78
+ }
79
+ /**
80
+ * Message composer: a text box that grows with its content and a send button.
81
+ *
82
+ * Enter sends, Shift+Enter adds a line (on phones Enter adds a line and the button sends). While `busy`, the button
83
+ * becomes Stop and fires `pm-stop`.
84
+ * @tag pm-composer
85
+ * @slot start - Buttons before the text (attach, emoji).
86
+ * @slot top - Content above the text (attachments, a reply preview, suggestion chips).
87
+ * @fires pm-send - A message was submitted. detail: { value }. The box clears unless the event is cancelled.
88
+ * @fires pm-stop - Stop was pressed while busy.
89
+ * @fires pm-input - The text changed. detail: { value }
90
+ * @example <pm-composer label="Message Ada" placeholder="Write a message"></pm-composer>
91
+ */
92
+ export class PmComposer extends PmElement {
93
+ static { this.componentName = 'composer'; }
94
+ static { this.shadowRootOptions = { ...PmElement.shadowRootOptions, delegatesFocus: true }; }
95
+ static { this.styles = [...PmElement.styles, buttonCss, chatCss, css `:host { display: block; } :host([hidden]) { display: none; }`]; }
96
+ static { this.properties = {
97
+ value: {}, label: {}, placeholder: {}, disabled: { type: Boolean, reflect: true }, busy: { type: Boolean, reflect: true }, maxlength: { type: Number },
98
+ sendLabel: { attribute: 'send-label' },
99
+ }; }
100
+ constructor() { super(); this.value = ''; }
101
+ #send() {
102
+ const value = this.value.trim();
103
+ if (!value || this.disabled || this.busy)
104
+ return;
105
+ if (this.emit('pm-send', { value }))
106
+ this.value = '';
107
+ this.renderRoot.querySelector('textarea')?.focus();
108
+ }
109
+ #onKey = (e) => {
110
+ // Touch keyboards have no Shift+Enter habit: Enter is a new line there.
111
+ if (e.key !== 'Enter' || e.shiftKey || e.isComposing || matchMedia('(pointer: coarse)').matches)
112
+ return;
113
+ e.preventDefault();
114
+ this.#send();
115
+ };
116
+ render() {
117
+ const icon = (d) => html `<svg viewBox="0 0 24 24" width="1.1em" height="1.1em" fill="none" stroke="currentColor" stroke-width="2.25" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${d}></path></svg>`;
118
+ return html `<div class="pm-composer" part="base" ?data-disabled=${!!this.disabled}>
119
+ <div class="pm-composer-top"><slot name="top"></slot></div>
120
+ <div class="pm-composer-start"><slot name="start"></slot></div>
121
+ <textarea part="input" rows="1" aria-label=${this.label ?? this.placeholder ?? 'Message'} placeholder=${this.placeholder ?? nothing} maxlength=${this.maxlength ?? nothing}
122
+ .value=${this.value} ?disabled=${!!this.disabled} enterkeyhint="send"
123
+ @input=${(e) => { this.value = e.target.value; this.emit('pm-input', { value: this.value }); }} @keydown=${this.#onKey}></textarea>
124
+ <div class="pm-composer-end">
125
+ ${this.busy
126
+ ? html `<button type="button" class="pm-button" part="stop" data-icon data-size="sm" data-variant="soft" data-tone="neutral" aria-label="Stop" @click=${() => this.emit('pm-stop')}>${icon('M7 7h10v10H7z')}</button>`
127
+ : html `<button type="button" class="pm-button" part="send" data-icon data-size="sm" aria-label=${this.sendLabel ?? 'Send'} ?disabled=${!!this.disabled || !this.value.trim()} @click=${this.#send}>${icon('M12 19V5M5 12l7-7 7 7')}</button>`}
128
+ </div>
129
+ </div>`;
130
+ }
131
+ }
132
+ defineElement('pm-chat', PmChat);
133
+ defineElement('pm-chat-message', PmChatMessage);
134
+ defineElement('pm-composer', PmComposer);
@@ -0,0 +1,48 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { SafeHTMLElement } from '../base.js';
3
+ import { PmFormControl } from './form-control.js';
4
+ /**
5
+ * Checkbox group: choose any number of options under one label.
6
+ *
7
+ * Declare options as `<pm-choice value="x">` children. `value` is the chosen values joined with commas; the form
8
+ * receives one entry per chosen value under `name`. `required` needs at least one choice; `min` / `max` limit how
9
+ * many. `variant="card"` shows options as cards with an optional description.
10
+ * @tag pm-checkbox-group
11
+ * @fires pm-change - The selection changed. detail: { value, values }
12
+ * @example <pm-checkbox-group label="Notify me about" name="topics" value="mentions"><pm-choice value="mentions">Mentions</pm-choice><pm-choice value="replies">Replies</pm-choice></pm-checkbox-group>
13
+ */
14
+ export declare class PmCheckboxGroup extends PmFormControl {
15
+ #private;
16
+ static styles: import("lit").CSSResult[];
17
+ static componentName: string;
18
+ static properties: PropertyDeclarations;
19
+ orientation: 'vertical' | 'horizontal';
20
+ /** list (default) or card. */
21
+ variant?: 'list' | 'card';
22
+ /** Fewest options that must be chosen. */
23
+ min?: number;
24
+ /** Most options that can be chosen; the rest are disabled once reached. */
25
+ max?: number;
26
+ constructor();
27
+ /** The chosen values. */
28
+ get values(): string[];
29
+ set values(v: string[]);
30
+ connectedCallback(): void;
31
+ disconnectedCallback(): void;
32
+ protected get control(): HTMLInputElement | null;
33
+ protected syncFormValue(): void;
34
+ protected syncValidity(): void;
35
+ protected onChange(): void;
36
+ render(): import("lit").TemplateResult<1>;
37
+ }
38
+ /**
39
+ * Option declaration for `pm-checkbox-group` (renders nothing itself).
40
+ * @tag pm-choice
41
+ * @attr {string} value - Value submitted when chosen.
42
+ * @attr {string} description - Second line under the label (card variant).
43
+ * @attr {boolean} disabled - Disable this option.
44
+ * @slot - Option label (text).
45
+ */
46
+ export declare class PmChoice extends SafeHTMLElement {
47
+ constructor();
48
+ }