@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,310 @@
1
+ import { css, html } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+ import { PmElement, nextId, SafeHTMLElement, defineElement } from '../base.js';
4
+ import { countLabel, formatCount } from '../count.js';
5
+ import tabsCss from '../styles/tabs.js';
6
+ /**
7
+ * Tabs that switch between panels of related content, with keyboard support, overflow scrolling and closable tabs.
8
+ *
9
+ * Children: `<pm-tab>` (tabs) and `<pm-tab-panel>` (panels), matched by order. Arrow keys, Home/End; selection
10
+ * follows focus (`activation="manual"`: Enter/Space selects). Horizontal or `orientation="vertical"`. Overflowing
11
+ * tab lists scroll and show arrow buttons. `closable` tabs close with their ✕ or the Delete key; disabled tabs are
12
+ * skipped. Panels use hidden="until-found" (find-in-page).
13
+ * @tag pm-tabs
14
+ * @fires pm-change - detail: { index }
15
+ * @fires pm-close - Cancelable; by default the tab and its panel are removed. detail: { index, tab }
16
+ * @example <pm-tabs label="Settings"><pm-tab>Profile</pm-tab><pm-tab>Billing</pm-tab><pm-tab-panel>…</pm-tab-panel><pm-tab-panel>…</pm-tab-panel></pm-tabs>
17
+ */
18
+ export class PmTabs extends PmElement {
19
+ static { this.componentName = 'tabs'; }
20
+ static { this.styles = [...PmElement.styles, tabsCss,
21
+ css `
22
+ :host { display: block; }
23
+ ::slotted(pm-tab-panel) { display: block; }
24
+ ::slotted(pm-tab-panel[hidden]:not([hidden='until-found'])) { display: none; }
25
+ .pm-tabs[data-orientation='vertical'] { grid-template-columns: auto minmax(0, 1fr); align-items: start; }
26
+ .pm-tablist-wrap { position: relative; display: flex; align-items: stretch; min-inline-size: 0; }
27
+ .pm-tablist-wrap > .pm-tablist { flex: 1; min-inline-size: 0; scroll-behavior: smooth; }
28
+ /* Pills hug their tabs (still scrolling when the row is too narrow); underline tabs span the row. */
29
+ .pm-tablist-wrap > .pm-tablist[data-variant="pills"] { flex: 0 1 auto; }
30
+ [data-orientation='vertical'] .pm-tablist { flex-direction: column; overflow: visible; border-block-end: 0; border-inline-end: 1px solid var(--pm-color-border); }
31
+ .pm-tab-scroll { flex: none; display: grid; place-items: center; inline-size: 1.75rem; padding: 0; border: 0; border-block-end: 1px solid var(--pm-color-border);
32
+ background: var(--pm-color-bg-canvas, transparent); color: var(--pm-color-fg-muted); cursor: pointer; }
33
+ .pm-tab-scroll:hover { color: var(--pm-color-fg); }
34
+ .pm-tab-scroll[hidden] { display: none; }
35
+ @media (prefers-reduced-motion: reduce) { .pm-tablist-wrap > .pm-tablist { scroll-behavior: auto; } }
36
+ .pm-tablist[data-variant='pills'] ::slotted(pm-tab) { border-radius: var(--pm-radius-md); min-block-size: var(--pm-control-height-sm); }
37
+ .pm-tablist[data-variant='pills'] ::slotted(pm-tab[aria-selected='true']) {
38
+ background: var(--pm-color-bg-surface);
39
+ color: var(--pm-color-fg);
40
+ box-shadow: var(--pm-sf-raise, var(--pm-elevation-1));
41
+ outline: 1px solid var(--pm-color-border);
42
+ }
43
+ `,
44
+ ]; }
45
+ static { this.properties = {
46
+ selected: { type: Number, reflect: true }, label: {}, variant: { reflect: true }, orientation: { reflect: true }, activation: {},
47
+ _over: { state: true },
48
+ }; }
49
+ #ro;
50
+ constructor() {
51
+ super();
52
+ this.selected = 0;
53
+ this._over = { start: false, end: false };
54
+ }
55
+ /** Tab attributes that change what `#sync` renders (count badges, close buttons, disabled state). */
56
+ #mo;
57
+ connectedCallback() {
58
+ super.connectedCallback();
59
+ this.#mo = new MutationObserver((records) => { if (records.some((r) => r.target.localName === 'pm-tab'))
60
+ this.#sync(); });
61
+ this.#mo.observe(this, { subtree: true, attributes: true, attributeFilter: ['count', 'max', 'show-zero', 'count-label', 'closable', 'disabled'] });
62
+ }
63
+ disconnectedCallback() { super.disconnectedCallback(); this.#ro?.disconnect(); this.#ro = undefined; this.#mo?.disconnect(); this.#mo = undefined; }
64
+ get #vertical() { return this.orientation === 'vertical'; }
65
+ #list() { return this.renderRoot.querySelector('.pm-tablist'); }
66
+ #measure = () => {
67
+ const l = this.#list();
68
+ if (!l || this.#vertical) {
69
+ if (this._over.start || this._over.end)
70
+ this._over = { start: false, end: false };
71
+ return;
72
+ }
73
+ const max = l.scrollWidth - l.clientWidth;
74
+ const x = Math.abs(l.scrollLeft);
75
+ const next = { start: x > 1, end: max - x > 1 };
76
+ if (next.start !== this._over.start || next.end !== this._over.end)
77
+ this._over = next;
78
+ };
79
+ #scrollBy(dir) {
80
+ const l = this.#list();
81
+ if (!l)
82
+ return;
83
+ const rtl = getComputedStyle(this).direction === 'rtl' ? -1 : 1;
84
+ l.scrollBy({ left: dir * rtl * l.clientWidth * 0.75 });
85
+ }
86
+ #enabled(i) { const t = this.tabs[i]; return !!t && !t.hasAttribute('disabled'); }
87
+ #step(from, dir) {
88
+ const n = this.tabs.length;
89
+ for (let k = 1; k <= n; k++) {
90
+ const i = (from + dir * k + n * k) % n;
91
+ if (this.#enabled(i))
92
+ return i;
93
+ }
94
+ return from;
95
+ }
96
+ /** Close a tab (fires cancelable pm-close; removes tab and panel unless prevented). */
97
+ close(index) {
98
+ const tab = this.tabs[index];
99
+ if (!tab)
100
+ return;
101
+ if (!this.emit('pm-close', { index, tab }, { cancelable: true }))
102
+ return;
103
+ const wasSelected = index === this.selected;
104
+ const hadFocus = tab.matches(':focus-within');
105
+ this.panels[index]?.remove();
106
+ tab.remove();
107
+ const n = this.tabs.length;
108
+ if (!n)
109
+ return;
110
+ if (index < this.selected || (wasSelected && index >= n))
111
+ this.selected = Math.max(0, this.selected - 1);
112
+ this.#sync();
113
+ if (wasSelected)
114
+ this.emit('pm-change', { index: this.selected });
115
+ if (hadFocus)
116
+ this.tabs[this.selected]?.focus();
117
+ }
118
+ get tabs() { return [...this.querySelectorAll(':scope > pm-tab')]; }
119
+ get panels() { return [...this.querySelectorAll(':scope > pm-tab-panel')]; }
120
+ render() {
121
+ const arrow = (d) => html `<button type="button" class="pm-tab-scroll" part="scroll-button" tabindex="-1" aria-hidden="true" ?hidden=${d < 0 ? !this._over.start : !this._over.end}
122
+ @click=${() => this.#scrollBy(d)}><svg viewBox="0 0 24 24" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" style=${d > 0 ? 'scale:-1 1' : ''}><path d="M15 6l-6 6 6 6"/></svg></button>`;
123
+ return html `<div class="pm-tabs" data-orientation=${this.#vertical ? 'vertical' : 'horizontal'}>
124
+ <div class="pm-tablist-wrap">
125
+ ${arrow(-1)}
126
+ <div part="tablist" class="pm-tablist" role="tablist" aria-label=${ifDefined(this.label)} aria-orientation=${this.#vertical ? 'vertical' : 'horizontal'}
127
+ data-variant=${ifDefined(this.variant ?? this.defaultFor('variant'))}
128
+ @keydown=${this.#onKey} @click=${this.#onClick} @scroll=${this.#measure}>
129
+ <slot name="tab" @slotchange=${this.#sync}></slot>
130
+ </div>
131
+ ${arrow(1)}
132
+ </div>
133
+ <div part="panels"><slot @slotchange=${this.#sync}></slot></div>
134
+ </div>`;
135
+ }
136
+ updated(changed) {
137
+ super.updated(changed);
138
+ if (changed.has('selected'))
139
+ this.#sync();
140
+ const l = this.#list();
141
+ if (l && !this.#ro && typeof ResizeObserver !== 'undefined') {
142
+ this.#ro = new ResizeObserver(() => this.#measure());
143
+ this.#ro.observe(l);
144
+ }
145
+ this.#measure();
146
+ }
147
+ #sync = () => {
148
+ const tabs = this.tabs;
149
+ const panels = this.panels;
150
+ tabs.forEach((tab, i) => {
151
+ tab.slot = 'tab';
152
+ tab.classList.add('pm-tab');
153
+ tab.setAttribute('role', 'tab');
154
+ tab.id ||= nextId('tab');
155
+ const on = i === this.selected;
156
+ tab.setAttribute('aria-selected', String(on));
157
+ if (!tab.matches(':focus'))
158
+ tab.tabIndex = on ? 0 : -1;
159
+ if (tab.hasAttribute('disabled'))
160
+ tab.setAttribute('aria-disabled', 'true');
161
+ else
162
+ tab.removeAttribute('aria-disabled');
163
+ const count = tab.getAttribute('count');
164
+ let badge = tab.querySelector(':scope > .pm-tab-count');
165
+ const text = count === null ? '' : formatCount(Number(count), Number(tab.getAttribute('max') ?? 99));
166
+ if (text && (text !== '0' || tab.hasAttribute('show-zero'))) {
167
+ if (!badge) {
168
+ badge = document.createElement('span');
169
+ badge.className = 'pm-tab-count';
170
+ tab.querySelector(':scope > .pm-tab-close')?.before(badge) ?? tab.append(badge);
171
+ }
172
+ badge.textContent = text;
173
+ // Read as part of the tab name ("Inbox 3"); an optional label explains it ("Inbox, 3 unread").
174
+ const label = tab.getAttribute('count-label');
175
+ if (label) {
176
+ badge.setAttribute('aria-hidden', 'true');
177
+ tab.setAttribute('aria-description', countLabel(label, Number(count)));
178
+ }
179
+ else {
180
+ badge.removeAttribute('aria-hidden');
181
+ tab.removeAttribute('aria-description');
182
+ }
183
+ }
184
+ else if (badge) {
185
+ badge.remove();
186
+ tab.removeAttribute('aria-description');
187
+ }
188
+ const closable = tab.hasAttribute('closable');
189
+ let x = tab.querySelector(':scope > .pm-tab-close');
190
+ if (closable && !x) {
191
+ x = document.createElement('span');
192
+ x.className = 'pm-tab-close';
193
+ x.setAttribute('aria-hidden', 'true');
194
+ x.innerHTML = '<svg viewBox="0 0 24 24" width="0.9em" height="0.9em" fill="none" stroke="currentColor" stroke-width="2.2" stroke-linecap="round"><path d="M17 7L7 17M7 7l10 10"/></svg>';
195
+ tab.append(x);
196
+ tab.setAttribute('aria-keyshortcuts', 'Delete');
197
+ }
198
+ else if (!closable && x) {
199
+ x.remove();
200
+ tab.removeAttribute('aria-keyshortcuts');
201
+ }
202
+ const panel = panels[i];
203
+ if (panel) {
204
+ panel.id ||= nextId('panel');
205
+ panel.setAttribute('role', 'tabpanel');
206
+ panel.setAttribute('aria-labelledby', tab.id);
207
+ panel.classList.add('pm-tabpanel');
208
+ if (on) {
209
+ panel.removeAttribute('hidden');
210
+ if (!panel.querySelector('a, button, input, select, textarea, [tabindex]'))
211
+ panel.tabIndex = 0;
212
+ }
213
+ else {
214
+ // until-found keeps hidden panels searchable; plain `hidden` where unsupported.
215
+ panel.setAttribute('hidden', 'onbeforematch' in HTMLElement.prototype ? 'until-found' : '');
216
+ panel.removeAttribute('tabindex');
217
+ }
218
+ panel.onbeforematch = () => this.select(i);
219
+ }
220
+ });
221
+ };
222
+ select(index, focus = false) {
223
+ const max = this.tabs.length - 1;
224
+ const next = Math.max(0, Math.min(index, max));
225
+ if (!this.#enabled(next))
226
+ return;
227
+ if (focus)
228
+ this.tabs[next]?.focus();
229
+ if (next === this.selected)
230
+ return;
231
+ this.selected = next;
232
+ if (focus)
233
+ this.updateComplete.then(() => this.tabs[next]?.focus());
234
+ this.tabs[next]?.scrollIntoView({ block: 'nearest', inline: 'nearest' });
235
+ this.emit('pm-change', { index: next });
236
+ }
237
+ #onClick = (e) => {
238
+ const target = e.target;
239
+ const tab = target.closest('pm-tab');
240
+ const i = tab ? this.tabs.indexOf(tab) : -1;
241
+ if (i < 0)
242
+ return;
243
+ if (target.closest('.pm-tab-close')) {
244
+ e.stopPropagation();
245
+ this.close(i);
246
+ return;
247
+ }
248
+ this.select(i);
249
+ };
250
+ #onKey = (e) => {
251
+ const rtl = getComputedStyle(this).direction === 'rtl';
252
+ const tabs = this.tabs;
253
+ const n = tabs.length;
254
+ const current = tabs.indexOf(e.target.closest('pm-tab'));
255
+ const from = current >= 0 ? current : this.selected;
256
+ const map = this.#vertical ? { ArrowDown: 1, ArrowUp: -1 } : { ArrowRight: rtl ? -1 : 1, ArrowLeft: rtl ? 1 : -1 };
257
+ let to = -1;
258
+ if (e.key in map)
259
+ to = this.#step(from, map[e.key]);
260
+ else if (e.key === 'Home')
261
+ to = this.#step(n - 1, 1);
262
+ else if (e.key === 'End')
263
+ to = this.#step(0, -1);
264
+ else if ((e.key === 'Enter' || e.key === ' ') && current >= 0) {
265
+ e.preventDefault();
266
+ this.select(current);
267
+ return;
268
+ }
269
+ else if (e.key === 'Delete' && current >= 0 && tabs[current].hasAttribute('closable')) {
270
+ e.preventDefault();
271
+ this.close(current);
272
+ return;
273
+ }
274
+ if (to < 0)
275
+ return;
276
+ e.preventDefault();
277
+ if (this.activation === 'manual') {
278
+ for (const t of tabs)
279
+ t.tabIndex = -1;
280
+ tabs[to].tabIndex = 0;
281
+ tabs[to].focus();
282
+ tabs[to].scrollIntoView({ block: 'nearest', inline: 'nearest' });
283
+ }
284
+ else
285
+ this.select(to, true);
286
+ };
287
+ }
288
+ /**
289
+ * A tab in `pm-tabs`; matched to the `pm-tab-panel` at the same index.
290
+ * @tag pm-tab
291
+ * @attr {boolean} closable - Show a close button (also closes with Delete).
292
+ * @attr {boolean} disabled - Skipped by keyboard and not selectable.
293
+ * @attr {number} count - Count badge after the label (unread, results); hidden at 0 unless `show-zero`.
294
+ * @attr {number} max - Highest count shown before "+" (default 99).
295
+ * @attr {boolean} show-zero - Keep the count badge at 0.
296
+ * @attr {string} count-label - What the count means for screen readers; `{count}` is filled in ("{count} unread").
297
+ * @slot - Tab label (add an icon or a pm-badge for counts).
298
+ */
299
+ export class PmTab extends SafeHTMLElement {
300
+ }
301
+ /**
302
+ * Panel for the `pm-tab` at the same index. Hidden with `hidden=until-found` when supported.
303
+ * @tag pm-tab-panel
304
+ * @slot - Panel content.
305
+ */
306
+ export class PmTabPanel extends SafeHTMLElement {
307
+ }
308
+ defineElement('pm-tabs', PmTabs);
309
+ defineElement('pm-tab', PmTab, [tabsCss]);
310
+ defineElement('pm-tab-panel', PmTabPanel);
@@ -0,0 +1,32 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmElement } from '../base.js';
3
+ /**
4
+ * Tag / chip. Static label, removable token, or toggleable filter chip (`selectable`).
5
+ * @tag pm-tag
6
+ * @slot - Label.
7
+ * @slot start - Leading icon or avatar.
8
+ * @fires pm-remove - Remove button pressed (call `event.preventDefault()` to keep the tag). detail: { value }
9
+ * @fires pm-change - Filter chip toggled. detail: { selected, value }
10
+ * @csspart base - The tag.
11
+ * @example <pm-tag tone="success" removable>Design</pm-tag>
12
+ */
13
+ export declare class PmTag extends PmElement {
14
+ #private;
15
+ static componentName: string;
16
+ static styles: import("lit").CSSResult[];
17
+ static properties: PropertyDeclarations;
18
+ /** Registered icon name shown before the content (see `registerIcons`); a `start` slot overrides it. */
19
+ iconStart?: string;
20
+ variant?: 'soft' | 'solid' | 'outline';
21
+ size?: 'sm' | 'md' | 'lg';
22
+ /** Shows a remove button; removes the tag unless `pm-remove` is cancelled. */
23
+ removable: boolean;
24
+ /** Toggleable filter chip (button with aria-pressed). */
25
+ selectable: boolean;
26
+ selected: boolean;
27
+ disabled: boolean;
28
+ /** Value reported in events (defaults to the text). */
29
+ value?: string;
30
+ constructor();
31
+ render(): import("lit").TemplateResult<1>;
32
+ }
@@ -0,0 +1,58 @@
1
+ import { css, html, nothing } from 'lit';
2
+ import { PmElement, defineElement } from '../base.js';
3
+ import tagCss from '../styles/tag.js';
4
+ import { namedIcon } from '../named-icon.js';
5
+ /**
6
+ * Tag / chip. Static label, removable token, or toggleable filter chip (`selectable`).
7
+ * @tag pm-tag
8
+ * @slot - Label.
9
+ * @slot start - Leading icon or avatar.
10
+ * @fires pm-remove - Remove button pressed (call `event.preventDefault()` to keep the tag). detail: { value }
11
+ * @fires pm-change - Filter chip toggled. detail: { selected, value }
12
+ * @csspart base - The tag.
13
+ * @example <pm-tag tone="success" removable>Design</pm-tag>
14
+ */
15
+ export class PmTag extends PmElement {
16
+ static { this.componentName = 'tag'; }
17
+ static { this.styles = [...PmElement.styles, tagCss, css `:host { display: inline-flex; vertical-align: middle; max-inline-size: 100%; } :host([hidden]) { display: none; }`]; }
18
+ static { this.properties = { iconStart: { attribute: 'icon-start', reflect: true },
19
+ variant: { reflect: true },
20
+ size: { reflect: true },
21
+ removable: { type: Boolean, reflect: true },
22
+ selectable: { type: Boolean, reflect: true },
23
+ selected: { type: Boolean, reflect: true },
24
+ disabled: { type: Boolean, reflect: true },
25
+ value: {},
26
+ }; }
27
+ constructor() {
28
+ super();
29
+ this.removable = false;
30
+ this.selectable = false;
31
+ this.selected = false;
32
+ this.disabled = false;
33
+ }
34
+ get #value() { return this.value ?? this.textContent?.trim() ?? ''; }
35
+ render() {
36
+ const variant = this.variant ?? this.defaultFor('variant');
37
+ const inner = html `<slot name="start">${namedIcon(this.iconStart)}</slot><span class="pm-tag-label"><slot></slot></span>`;
38
+ if (this.selectable) {
39
+ return html `<button type="button" class="pm-tag" part="base" data-variant=${variant ?? nothing} data-size=${this.size ?? nothing}
40
+ aria-pressed=${this.selected ? 'true' : 'false'} ?disabled=${this.disabled} @click=${this.#toggle}>${inner}</button>`;
41
+ }
42
+ return html `<span class="pm-tag" part="base" data-variant=${variant ?? nothing} data-size=${this.size ?? nothing}>
43
+ ${inner}
44
+ ${this.removable
45
+ ? html `<button type="button" class="pm-tag-remove" part="remove" aria-label=${`Remove ${this.#value}`} ?disabled=${this.disabled} @click=${this.#remove}>✕</button>`
46
+ : nothing}
47
+ </span>`;
48
+ }
49
+ #toggle() {
50
+ this.selected = !this.selected;
51
+ this.emit('pm-change', { selected: this.selected, value: this.#value });
52
+ }
53
+ #remove() {
54
+ if (this.emit('pm-remove', { value: this.#value }))
55
+ this.remove();
56
+ }
57
+ }
58
+ defineElement('pm-tag', PmTag);
@@ -0,0 +1,25 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmFormControl } from './form-control.js';
3
+ /**
4
+ * Multi-line text input that grows with content (between `rows` and `max-rows`). `show-count` adds a live
5
+ * character counter (announced politely near the limit). Ctrl/⌘+Enter submits the form.
6
+ * @tag pm-textarea
7
+ * @example <pm-textarea label="Message" rows="4"></pm-textarea>
8
+ */
9
+ export declare class PmTextarea extends PmFormControl {
10
+ #private;
11
+ static styles: import("lit").CSSResult[];
12
+ static componentName: string;
13
+ static properties: PropertyDeclarations;
14
+ placeholder?: string;
15
+ /** Visible lines before it starts to grow. */
16
+ rows?: number;
17
+ maxlength?: number;
18
+ /** Stop growing after this many lines (then scroll). */
19
+ maxRows?: number;
20
+ /** Show "n / max" under the field. */
21
+ showCount: boolean;
22
+ autocomplete?: string;
23
+ constructor();
24
+ render(): import("lit").TemplateResult<1>;
25
+ }
@@ -0,0 +1,56 @@
1
+ import { html, nothing } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+ import { live } from 'lit/directives/live.js';
4
+ import { defineElement } from '../base.js';
5
+ import { PmFormControl } from './form-control.js';
6
+ import inputCss from '../styles/input.js';
7
+ /**
8
+ * Multi-line text input that grows with content (between `rows` and `max-rows`). `show-count` adds a live
9
+ * character counter (announced politely near the limit). Ctrl/⌘+Enter submits the form.
10
+ * @tag pm-textarea
11
+ * @example <pm-textarea label="Message" rows="4"></pm-textarea>
12
+ */
13
+ export class PmTextarea extends PmFormControl {
14
+ static { this.styles = [...PmFormControl.styles, inputCss]; }
15
+ static { this.componentName = 'textarea'; }
16
+ static { this.properties = {
17
+ placeholder: {}, rows: { type: Number }, maxlength: { type: Number }, maxRows: { type: Number, attribute: 'max-rows' },
18
+ showCount: { type: Boolean, attribute: 'show-count' }, autocomplete: {},
19
+ }; }
20
+ constructor() { super(); this.showCount = false; }
21
+ #onKey = (e) => {
22
+ if (e.key === 'Enter' && (e.ctrlKey || e.metaKey) && this.internals.form) {
23
+ e.preventDefault();
24
+ this.internals.form.requestSubmit();
25
+ }
26
+ };
27
+ render() {
28
+ const n = this.value.length;
29
+ const near = !!this.maxlength && n >= this.maxlength * 0.9;
30
+ return this.field(html `<textarea
31
+ data-control
32
+ part="control"
33
+ class="pm-input"
34
+ id=${this.controlId}
35
+ name=${ifDefined(this.name)}
36
+ .value=${live(this.value)}
37
+ placeholder=${ifDefined(this.placeholder)}
38
+ rows=${ifDefined(this.rows)}
39
+ style=${this.maxRows ? `max-block-size: calc(${this.maxRows}lh + 1rem)` : nothing}
40
+ maxlength=${ifDefined(this.maxlength)}
41
+ autocomplete=${ifDefined(this.autocomplete)}
42
+ ?required=${this.required}
43
+ ?disabled=${this.disabled}
44
+ ?readonly=${this.readonly}
45
+ aria-invalid=${this.showInvalid ? 'true' : nothing}
46
+ aria-describedby=${ifDefined([this.describedBy(), this.showCount ? `${this.controlId}-count` : ''].filter(Boolean).join(' ') || undefined)}
47
+ @input=${this.onInput}
48
+ @change=${this.onChange}
49
+ @blur=${this.onBlur}
50
+ @keydown=${this.#onKey}
51
+ ></textarea>
52
+ ${this.showCount ? html `<span class="pm-input-counter" part="counter" id=${`${this.controlId}-count`} ?data-over=${!!this.maxlength && n >= this.maxlength}
53
+ aria-live=${near ? 'polite' : 'off'}>${this.maxlength ? `${n} / ${this.maxlength}` : n}</span>` : nothing}`);
54
+ }
55
+ }
56
+ defineElement('pm-textarea', PmTextarea);
@@ -0,0 +1,51 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmElement } from '../base.js';
3
+ type Mode = 'light' | 'dark' | 'system';
4
+ interface Controller {
5
+ state: {
6
+ mode: Mode;
7
+ };
8
+ set(patch: {
9
+ mode: Mode;
10
+ }): unknown;
11
+ subscribe(fn: (s: {
12
+ mode: Mode;
13
+ }) => void): () => void;
14
+ }
15
+ /**
16
+ * Light / dark / system switch.
17
+ *
18
+ * On its own it sets `data-mode` on `<html>` and saves the choice where the no-flash script and `ThemeController`
19
+ * read it. Give it a `controller` (a `ThemeController`) to stay in sync with the rest of your app and across tabs.
20
+ *
21
+ * `variant="toggle"` is one button that flips between light and dark; the default shows all three choices.
22
+ * @tag pm-theme-switch
23
+ * @fires pm-change - The mode changed. detail: { mode }
24
+ * @example <pm-theme-switch></pm-theme-switch>
25
+ */
26
+ export declare class PmThemeSwitch extends PmElement {
27
+ #private;
28
+ static componentName: string;
29
+ static styles: import("lit").CSSResult[];
30
+ static properties: PropertyDeclarations;
31
+ /** segmented (default: light, dark, system) or toggle (one button, light ↔ dark). */
32
+ variant?: 'segmented' | 'toggle';
33
+ size?: 'sm' | 'md';
34
+ /** Accessible name (default "Colour mode"). */
35
+ label?: string;
36
+ /** Show the words next to the icons. */
37
+ showLabels?: boolean;
38
+ /** A `ThemeController` to drive instead of the built-in storage. */
39
+ controller?: Controller;
40
+ _mode: Mode;
41
+ constructor();
42
+ /** The current choice: light, dark or system. */
43
+ get mode(): Mode;
44
+ /** What is showing now: light or dark. */
45
+ get resolved(): 'light' | 'dark';
46
+ connectedCallback(): void;
47
+ disconnectedCallback(): void;
48
+ protected willUpdate(changed: Map<PropertyKey, unknown>): void;
49
+ render(): import("lit").TemplateResult<1>;
50
+ }
51
+ export {};
@@ -0,0 +1,85 @@
1
+ import { css, html } from 'lit';
2
+ import { PmElement, defineElement } from '../base.js';
3
+ import buttonCss from '../styles/button.js';
4
+ import segmentedCss from '../styles/segmented.js';
5
+ const ICONS = {
6
+ light: 'M12 3v2M12 19v2M5.6 5.6l1.4 1.4M17 17l1.4 1.4M3 12h2M19 12h2M5.6 18.4L7 17M17 7l1.4-1.4M12 8a4 4 0 1 0 0 8 4 4 0 0 0 0-8z',
7
+ dark: 'M20 14.5A8 8 0 0 1 9.5 4a8 8 0 1 0 10.5 10.5z',
8
+ system: 'M4 5h16v11H4zM9 20h6M12 16v4',
9
+ };
10
+ /**
11
+ * Light / dark / system switch.
12
+ *
13
+ * On its own it sets `data-mode` on `<html>` and saves the choice where the no-flash script and `ThemeController`
14
+ * read it. Give it a `controller` (a `ThemeController`) to stay in sync with the rest of your app and across tabs.
15
+ *
16
+ * `variant="toggle"` is one button that flips between light and dark; the default shows all three choices.
17
+ * @tag pm-theme-switch
18
+ * @fires pm-change - The mode changed. detail: { mode }
19
+ * @example <pm-theme-switch></pm-theme-switch>
20
+ */
21
+ export class PmThemeSwitch extends PmElement {
22
+ static { this.componentName = 'theme-switch'; }
23
+ static { this.styles = [...PmElement.styles, buttonCss, segmentedCss, css `:host { display: inline-block; } :host([hidden]) { display: none; }
24
+ .pm-segment { position: relative; } input { position: absolute; inset: 0; margin: 0; opacity: 0; cursor: pointer; }
25
+ .pm-segment:has(:focus-visible) { outline: 2px solid var(--pm-color-ring); outline-offset: 2px; }`]; }
26
+ static { this.properties = { variant: { reflect: true }, size: { reflect: true }, label: {}, showLabels: { type: Boolean, attribute: 'show-labels' }, controller: { attribute: false }, _mode: { state: true } }; }
27
+ #off;
28
+ #mq;
29
+ constructor() { super(); this._mode = 'system'; }
30
+ /** The current choice: light, dark or system. */
31
+ get mode() { return this._mode; }
32
+ /** What is showing now: light or dark. */
33
+ get resolved() { return this._mode === 'system' ? (this.#mq?.matches ? 'dark' : 'light') : this._mode; }
34
+ #onMq = () => this.requestUpdate();
35
+ connectedCallback() {
36
+ super.connectedCallback();
37
+ this.#mq = matchMedia('(prefers-color-scheme: dark)');
38
+ this.#mq.addEventListener('change', this.#onMq);
39
+ const attr = document.documentElement.dataset.mode;
40
+ this._mode = attr === 'light' || attr === 'dark' ? attr : 'system';
41
+ }
42
+ disconnectedCallback() { super.disconnectedCallback(); this.#mq?.removeEventListener('change', this.#onMq); this.#off?.(); this.#off = undefined; }
43
+ willUpdate(changed) {
44
+ super.willUpdate(changed);
45
+ if (changed.has('controller')) {
46
+ this.#off?.();
47
+ this.#off = this.controller?.subscribe((s) => { this._mode = s.mode; });
48
+ if (this.controller)
49
+ this._mode = this.controller.state.mode;
50
+ }
51
+ }
52
+ #set(mode) {
53
+ if (mode === this._mode)
54
+ return;
55
+ this._mode = mode;
56
+ if (this.controller)
57
+ void this.controller.set({ mode });
58
+ else {
59
+ if (mode === 'system')
60
+ delete document.documentElement.dataset.mode;
61
+ else
62
+ document.documentElement.dataset.mode = mode;
63
+ try {
64
+ const s = JSON.parse(localStorage.getItem('pm-theme') ?? '{}');
65
+ localStorage.setItem('pm-theme', JSON.stringify({ ...s, mode }));
66
+ }
67
+ catch { /* storage blocked: applies for this visit */ }
68
+ }
69
+ this.emit('pm-change', { mode });
70
+ }
71
+ render() {
72
+ const icon = (m) => html `<svg viewBox="0 0 24 24" width="1.1em" height="1.1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d=${ICONS[m]}></path></svg>`;
73
+ const NAMES = { light: 'Light', dark: 'Dark', system: 'System' };
74
+ if (this.variant === 'toggle') {
75
+ const next = this.resolved === 'dark' ? 'light' : 'dark';
76
+ return html `<button type="button" part="base" class="pm-button" data-variant="ghost" data-tone="neutral" data-size=${this.size ?? 'md'} ?data-icon=${!this.showLabels}
77
+ aria-label=${`Switch to ${next} mode`} @click=${() => this.#set(next)}>${icon(this.resolved)}${this.showLabels ? NAMES[this.resolved] : ''}</button>`;
78
+ }
79
+ return html `<div part="base" class="pm-segmented" data-size=${this.size ?? 'sm'} role="radiogroup" aria-label=${this.label ?? 'Colour mode'}>
80
+ ${['light', 'dark', 'system'].map((m) => html `<label class="pm-segment" ?data-checked=${this._mode === m} title=${NAMES[m]}>
81
+ <input type="radio" name="mode" value=${m} .checked=${this._mode === m} aria-label=${NAMES[m]} @change=${() => this.#set(m)} />${icon(m)}${this.showLabels ? NAMES[m] : ''}</label>`)}
82
+ </div>`;
83
+ }
84
+ }
85
+ defineElement('pm-theme-switch', PmThemeSwitch);
@@ -0,0 +1,39 @@
1
+ import { type PropertyDeclarations, type PropertyValues } from 'lit';
2
+ import { PmFormControl } from './form-control.js';
3
+ /** Parse "14:30", "2:30 pm", "1430", "9" into "HH:MM" (24 h), or undefined. */
4
+ export declare function parseTime(text: string): string | undefined;
5
+ /**
6
+ * Time picker: type a time ("14:30", "2:30 pm") or pick hours and minutes from a popup.
7
+ *
8
+ * 12/24-hour display follows the locale (override with `hour-cycle`).
9
+ * Value is always "HH:MM" (24 h) and is submitted with forms. Columns are listboxes: ↑/↓ move, Enter picks, ←/→
10
+ * switch column, Esc closes.
11
+ * @attr {boolean} mobile - Native mobile pattern on phones: opens as a swipeable bottom sheet (inherits from ancestors such as `<html mobile>`; `mobile="false"` opts out).
12
+ * @tag pm-time-picker
13
+ * @example <pm-time-picker label="Start time" value="09:30" step="15"></pm-time-picker>
14
+ */
15
+ export declare class PmTimePicker extends PmFormControl {
16
+ #private;
17
+ static componentName: string;
18
+ static styles: import("lit").CSSResult[];
19
+ static properties: PropertyDeclarations;
20
+ /** Earliest time, "HH:MM". */
21
+ min?: string;
22
+ /** Latest time, "HH:MM". */
23
+ max?: string;
24
+ /** Minute step in the popup (1–60). Typed values may be any minute. */
25
+ step: number;
26
+ locale?: string;
27
+ /** Force 12- or 24-hour display. */
28
+ hourCycle?: '12' | '24';
29
+ placeholder?: string;
30
+ _open: boolean;
31
+ _text?: string;
32
+ constructor();
33
+ protected syncValidity(): void;
34
+ open(): void;
35
+ close(focus?: boolean): void;
36
+ protected updated(changed: PropertyValues<this>): void;
37
+ disconnectedCallback(): void;
38
+ render(): import("lit").TemplateResult<1>;
39
+ }