@prismora/elements 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (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,228 @@
1
+ var _a;
2
+ import { css, html, nothing } from 'lit';
3
+ import { PmElement, defineElement } from '../base.js';
4
+ import navCss from '../styles/nav.js';
5
+ import sheetCss from '../styles/sheet.js';
6
+ import { COMPACT_QUERY, isMobile, onMobileChange } from '../sheet.js';
7
+ import { countLabel, formatCount } from '../count.js';
8
+ import { namedIcon } from '../named-icon.js';
9
+ /**
10
+ * App sidebar navigation: a `<nav>` landmark with labelled groups, icons, badges, collapsible sub-menus and a
11
+ * `collapsed` icon rail.
12
+ *
13
+ * `auto-current` marks the item whose `href` matches the current URL (and opens its parents). With native mobile on
14
+ * (`mobile` here or on an ancestor, or `setMobile(true)`), the same markup becomes a bottom tab bar on phones:
15
+ * top-level items, icons over labels, safe-area aware; parents open their sub-items in a sheet.
16
+ * `mobile-variant="sidebar"` keeps the sidebar and `mobile-variant="none"` hides it on phones.
17
+ * @attr {boolean} mobile - Native mobile patterns on phones (inherits from ancestors; `mobile="false"` opts out).
18
+ * @tag pm-nav
19
+ * @slot - `pm-nav-group` and/or `pm-nav-item` elements.
20
+ * @example <pm-nav label="Main"><pm-nav-item href="/" label="Home" current></pm-nav-item><pm-nav-item href="/inbox" label="Inbox"></pm-nav-item></pm-nav>
21
+ */
22
+ export class PmNav extends PmElement {
23
+ static { this.componentName = 'nav'; }
24
+ static { this.styles = [...PmElement.styles, navCss, css `:host { display: block; }
25
+ .pm-nav-list { display: contents; }
26
+ @media (width < 40rem) { :host([mobile-variant='none'][data-native]) { display: none; } }
27
+ :host([data-bar]) { position: fixed; z-index: var(--pm-z-sticky, 100); inset: auto 0 0 0; inline-size: auto !important; }`]; }
28
+ static { this.properties = {
29
+ label: {}, collapsed: { type: Boolean, reflect: true }, autoCurrent: { type: Boolean, attribute: 'auto-current' },
30
+ mobile: {}, mobileVariant: { attribute: 'mobile-variant', reflect: true }, _bar: { state: true },
31
+ }; }
32
+ #mq;
33
+ #onMq = () => { this._bar = (this.mobileVariant ?? 'bar') === 'bar' && !!this.#mq?.matches && isMobile(this); };
34
+ constructor() { super(); this.collapsed = false; this.autoCurrent = false; this._bar = false; }
35
+ connectedCallback() {
36
+ super.connectedCallback();
37
+ if (this.autoCurrent)
38
+ queueMicrotask(() => this.syncCurrent());
39
+ if (typeof matchMedia === 'function') {
40
+ this.#mq ??= matchMedia(COMPACT_QUERY);
41
+ this.#mq.addEventListener('change', this.#onMq);
42
+ this.#onMq();
43
+ }
44
+ // A `mobile` switch on any ancestor (or setMobile) must move between sidebar and tab bar at once.
45
+ this.#offMobile = onMobileChange(() => { this.#onMq(); this.requestUpdate(); });
46
+ }
47
+ #offMobile;
48
+ disconnectedCallback() {
49
+ super.disconnectedCallback();
50
+ this.#mq?.removeEventListener('change', this.#onMq);
51
+ this.#offMobile?.();
52
+ if (this.#ownsInset)
53
+ document.documentElement.style.removeProperty('--pm-bottom-inset');
54
+ }
55
+ willUpdate(changed) {
56
+ super.willUpdate(changed);
57
+ if (changed.has('mobile') || changed.has('mobileVariant'))
58
+ this.#onMq();
59
+ }
60
+ /** Set `current` on the item whose href best matches `path` (defaults to the page URL). */
61
+ syncCurrent(path = location.pathname) {
62
+ const items = [...this.querySelectorAll('pm-nav-item[href]')];
63
+ let best;
64
+ let len = -1;
65
+ for (const it of items) {
66
+ const h = new URL(it.href, location.href).pathname;
67
+ if ((path === h || path.startsWith(h.endsWith('/') ? h : `${h}/`)) && h.length > len) {
68
+ best = it;
69
+ len = h.length;
70
+ }
71
+ }
72
+ for (const it of items)
73
+ it.current = it === best;
74
+ }
75
+ updated() {
76
+ for (const el of this.querySelectorAll('pm-nav-item, pm-nav-group')) {
77
+ // Only top-level items become tabs; nested items stay normal links inside their parent's sheet.
78
+ el.toggleAttribute('data-bar', this._bar && !el.parentElement?.closest('pm-nav-item'));
79
+ el.requestUpdate();
80
+ }
81
+ this.toggleAttribute('data-bar', this._bar);
82
+ this.toggleAttribute('data-native', !!this.#mq?.matches && isMobile(this));
83
+ // Let toasts, FABs and page padding clear the tab bar: --pm-bottom-inset on the root.
84
+ const root = document.documentElement.style;
85
+ if (this._bar)
86
+ requestAnimationFrame(() => root.setProperty('--pm-bottom-inset', `${this.offsetHeight}px`));
87
+ else if (this.#ownsInset)
88
+ root.removeProperty('--pm-bottom-inset');
89
+ this.#ownsInset = this._bar;
90
+ }
91
+ #ownsInset = false;
92
+ render() {
93
+ // Items placed directly in the nav (no pm-nav-group) are role="listitem": give them their list.
94
+ const flat = this.children.length > 0 && [...this.children].every((c) => c.localName === 'pm-nav-item');
95
+ const slot = html `<slot @slotchange=${() => this.requestUpdate()}></slot>`;
96
+ return html `<nav class="pm-nav" part="base" aria-label=${this.label ?? nothing} ?data-collapsed=${this.collapsed && !this._bar} ?data-bar=${this._bar}>${flat ? html `<div role="list" class="pm-nav-list">${slot}</div>` : slot}</nav>`;
97
+ }
98
+ }
99
+ /**
100
+ * A labelled section of a `pm-nav`.
101
+ * @tag pm-nav-group
102
+ * @slot - `pm-nav-item` elements.
103
+ * @example <pm-nav-group label="Workspace"><pm-nav-item href="/projects" label="Projects"></pm-nav-item></pm-nav-group>
104
+ */
105
+ export class PmNavGroup extends PmElement {
106
+ static { this.componentName = 'nav-group'; }
107
+ static { this.styles = [...PmElement.styles, navCss, css `:host { display: block; } :host([data-bar]) { display: contents; }
108
+ :host([data-bar]) .pm-nav-group { display: contents; } :host([data-bar]) .pm-nav-heading { display: none; } :host([data-bar]) [role="list"] { display: contents; }`]; }
109
+ static { this.properties = { label: {} }; }
110
+ #id = `nav-g-${Math.random().toString(36).slice(2, 8)}`;
111
+ render() {
112
+ const collapsed = !!this.closest('pm-nav')?.hasAttribute('collapsed');
113
+ return html `<div class="pm-nav-group" part="base">
114
+ ${this.label ? html `<div class="pm-nav-heading" part="heading" id=${this.#id} ?data-collapsed=${collapsed}>${this.label}</div>` : nothing}
115
+ <div role="list" aria-labelledby=${this.label ? this.#id : nothing}><slot></slot></div>
116
+ </div>`;
117
+ }
118
+ }
119
+ /**
120
+ * Navigation link, or a collapsible parent when it contains `pm-nav-item` children.
121
+ * @tag pm-nav-item
122
+ * @slot icon - Leading icon.
123
+ * Set `count` for unread or pending items (a pill at the end; on the icon in the phone tab bar; a dot on the
124
+ * collapsed rail), with `count-label` saying what it means to screen readers ("{count} unread").
125
+ * @slot end - Trailing badge or content (the `count` pill comes first).
126
+ * @slot - Child `pm-nav-item` elements (makes this a collapsible parent).
127
+ * @fires pm-toggle - A parent opened or closed. detail: { expanded }
128
+ * @example <pm-nav-item href="/inbox" label="Inbox"><pm-icon slot="icon" name="inbox"></pm-icon><pm-badge slot="end">4</pm-badge></pm-nav-item>
129
+ */
130
+ export class PmNavItem extends PmElement {
131
+ static { this.componentName = 'nav-item'; }
132
+ static { this.styles = [...PmElement.styles, navCss, sheetCss, css `:host { display: block; }
133
+ :host([data-bar]) { flex: 1 1 0; min-inline-size: 0; }
134
+ :host([data-bar]) .pm-nav-children[data-sheet] { padding-inline: var(--pm-space-2); background: var(--pm-color-bg-surface); color: var(--pm-color-fg); border: 1px solid var(--pm-color-border); }
135
+ :host([data-bar]) .pm-nav-children[data-sheet]:not(:popover-open) { display: none; }
136
+ :host([data-bar]) .pm-nav-children[data-sheet]:popover-open { display: grid; }
137
+ :host([data-bar]) .pm-nav-children[data-sheet] .pm-nav-link { min-block-size: 3rem; font-size: var(--pm-font-size-md); }`]; }
138
+ static { this.properties = { icon: { reflect: true },
139
+ href: {}, label: {}, current: { type: Boolean, reflect: true }, expanded: { type: Boolean, reflect: true }, disabled: { type: Boolean, reflect: true },
140
+ count: { type: Number, reflect: true }, max: { type: Number }, countLabel: { attribute: 'count-label' }, dot: { type: Boolean, reflect: true },
141
+ }; }
142
+ constructor() { super(); this.current = false; this.expanded = false; this.disabled = false; this.dot = false; }
143
+ /** Count pill plus its screen reader text ("Inbox, 3 unread"). */
144
+ #count() {
145
+ const text = formatCount(this.count, this.max ?? 99);
146
+ const show = this.dot || (!!text && text !== '0');
147
+ if (!show)
148
+ return { badge: nothing, spoken: '' };
149
+ const spoken = this.dot && !text ? (this.countLabel ? countLabel(this.countLabel, undefined) : 'new') : countLabel(this.countLabel ?? '{count}', this.count, this.max ?? 99);
150
+ return { badge: html `<span class="pm-nav-count" part="count" aria-hidden="true" ?data-dot=${this.dot}>${this.dot ? '' : text}</span>`, spoken };
151
+ }
152
+ connectedCallback() { super.connectedCallback(); this.setAttribute('role', 'listitem'); }
153
+ /** A nav shown in a drawer (a `popover` ancestor, as in the app shell on phones) closes it when a link is followed. */
154
+ #closeDrawer = () => {
155
+ const drawer = this.closest('[popover]');
156
+ try {
157
+ if (drawer?.matches(':popover-open'))
158
+ drawer.hidePopover();
159
+ }
160
+ catch { /* not a popover in this browser */ }
161
+ };
162
+ get #children() { return [...this.children].filter((c) => c instanceof _a); }
163
+ get #depth() { let d = 0; let p = this.parentElement?.closest('pm-nav-item'); while (p) {
164
+ d++;
165
+ p = p.parentElement?.closest('pm-nav-item');
166
+ } return d; }
167
+ willUpdate(changed) {
168
+ super.willUpdate(changed);
169
+ if (!this.hasUpdated && this.#children.length && this.querySelector('pm-nav-item[current]'))
170
+ this.expanded = true;
171
+ if (changed.has('current') && this.current) {
172
+ let p = this.parentElement?.closest('pm-nav-item');
173
+ while (p) {
174
+ p.expanded = true;
175
+ p = p.parentElement?.closest('pm-nav-item');
176
+ }
177
+ }
178
+ }
179
+ /** Bottom tab bar cell; parents open their children in a sheet above the bar. */
180
+ #barRender(inner, parent) {
181
+ const sheetId = 'children';
182
+ const cur = this.current || !!this.querySelector('pm-nav-item[current]');
183
+ const link = parent
184
+ ? html `<button type="button" class="pm-nav-link" part="link" data-bar popovertarget=${sheetId} aria-haspopup="true" ?data-has-current=${cur}
185
+ aria-current=${cur ? 'true' : nothing}>${inner}</button>`
186
+ : html `<a class="pm-nav-link" part="link" data-bar href=${this.href ?? nothing} aria-current=${this.current ? 'page' : nothing}>${inner}</a>`;
187
+ return html `<div class="pm-nav-item" part="base">${link}
188
+ ${parent ? html `<div id=${sheetId} class="pm-nav-children" role="list" popover="auto" data-sheet aria-label=${this.label ?? nothing}
189
+ @click=${(e) => { if (e.target.closest?.('pm-nav-item'))
190
+ e.currentTarget.hidePopover(); }}><slot></slot></div>` : nothing}
191
+ </div>`;
192
+ }
193
+ #toggle() {
194
+ if (this.disabled)
195
+ return;
196
+ this.expanded = !this.expanded;
197
+ this.emit('pm-toggle', { expanded: this.expanded });
198
+ }
199
+ render() {
200
+ const bar = this.hasAttribute('data-bar');
201
+ const collapsed = !bar && !!this.closest('pm-nav')?.hasAttribute('collapsed');
202
+ const parent = this.#children.length > 0;
203
+ const hasIcon = !!this.icon || !!this.querySelector(':scope > [slot="icon"]');
204
+ const { badge, spoken } = this.#count();
205
+ const inner = html `<span class="pm-nav-icon" part="icon" ?hidden=${!hasIcon}><slot name="icon" @slotchange=${() => this.requestUpdate()}>${namedIcon(this.icon)}</slot>${collapsed ? badge : nothing}</span>
206
+ <span class="pm-nav-label" part="label">${this.label}</span>${spoken ? html `<span class="pm-visually-hidden">, ${spoken}</span>` : nothing}
207
+ <span class="pm-nav-end" part="end">${collapsed ? nothing : badge}<slot name="end"></slot></span>
208
+ ${parent ? html `<svg class="pm-nav-chevron" viewBox="0 0 24 24" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true"><path d="M9 6l6 6-6 6"/></svg>` : nothing}`;
209
+ const style = `--_depth: ${this.parentElement?.closest('pm-nav-item')?.hasAttribute('data-bar') ? 0 : this.#depth}`;
210
+ const name = collapsed ? (spoken ? `${this.label}, ${spoken}` : this.label) : undefined;
211
+ if (bar)
212
+ return this.#barRender(inner, parent);
213
+ const link = parent
214
+ ? html `<button type="button" class="pm-nav-link" part="link" style=${style} aria-expanded=${this.expanded ? 'true' : 'false'} ?disabled=${this.disabled}
215
+ title=${name ?? nothing} aria-label=${name ?? nothing} ?data-has-current=${!!this.querySelector('pm-nav-item[current]')} @click=${this.#toggle}>${inner}</button>`
216
+ : this.disabled
217
+ ? html `<a class="pm-nav-link" part="link" style=${style} aria-disabled="true" role="link" title=${name ?? nothing} aria-label=${name ?? nothing}>${inner}</a>`
218
+ : html `<a class="pm-nav-link" part="link" style=${style} href=${this.href ?? nothing} aria-current=${this.current ? 'page' : nothing}
219
+ title=${name ?? nothing} aria-label=${name ?? nothing} @click=${this.#closeDrawer}>${inner}</a>`;
220
+ return html `<div class="pm-nav-item" part="base" ?data-collapsed=${collapsed}>${link}
221
+ ${parent ? html `<div role="list" class="pm-nav-children" ?hidden=${!this.expanded || collapsed}><slot @slotchange=${() => this.requestUpdate()}></slot></div>` : html `<slot hidden></slot>`}
222
+ </div>`;
223
+ }
224
+ }
225
+ _a = PmNavItem;
226
+ defineElement('pm-nav', PmNav);
227
+ defineElement('pm-nav-group', PmNavGroup);
228
+ defineElement('pm-nav-item', PmNavItem);
@@ -0,0 +1,26 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmFormControl } from './form-control.js';
3
+ /**
4
+ * Number input with − / + steppers. Arrow keys step, Page Up/Down step ×10; min/max/step are validated natively.
5
+ * @tag pm-number-input
6
+ * @csspart control - The native input.
7
+ * @example <pm-number-input label="Seats" value="3" min="1" max="50"></pm-number-input>
8
+ */
9
+ export declare class PmNumberInput extends PmFormControl {
10
+ #private;
11
+ static componentName: string;
12
+ static styles: import("lit").CSSResult[];
13
+ static properties: PropertyDeclarations;
14
+ min?: number;
15
+ max?: number;
16
+ step: number;
17
+ placeholder?: string;
18
+ /** Hide the − / + buttons. */
19
+ hideButtons: boolean;
20
+ constructor();
21
+ get valueAsNumber(): number;
22
+ set valueAsNumber(n: number);
23
+ /** Step by `n` steps (negative steps down), clamped to min/max. */
24
+ stepBy(n: number): void;
25
+ render(): import("lit").TemplateResult<1>;
26
+ }
@@ -0,0 +1,70 @@
1
+ import { css, 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 inputCss from '../styles/input.js';
6
+ import numberCss from '../styles/number-input.js';
7
+ import { PmFormControl } from './form-control.js';
8
+ /**
9
+ * Number input with − / + steppers. Arrow keys step, Page Up/Down step ×10; min/max/step are validated natively.
10
+ * @tag pm-number-input
11
+ * @csspart control - The native input.
12
+ * @example <pm-number-input label="Seats" value="3" min="1" max="50"></pm-number-input>
13
+ */
14
+ export class PmNumberInput extends PmFormControl {
15
+ static { this.componentName = 'number-input'; }
16
+ static { this.styles = [...PmFormControl.styles, inputCss, numberCss, css ``]; }
17
+ static { this.properties = {
18
+ min: { type: Number }, max: { type: Number }, step: { type: Number }, placeholder: {}, hideButtons: { type: Boolean, attribute: 'hide-buttons' },
19
+ }; }
20
+ constructor() { super(); this.step = 1; this.hideButtons = false; }
21
+ get valueAsNumber() { return this.value === '' ? Number.NaN : Number(this.value); }
22
+ set valueAsNumber(n) { this.value = Number.isFinite(n) ? String(n) : ''; }
23
+ /** Step by `n` steps (negative steps down), clamped to min/max. */
24
+ stepBy(n) {
25
+ if (this.disabled || this.readonly)
26
+ return;
27
+ const cur = Number.isFinite(this.valueAsNumber) ? this.valueAsNumber : (this.min ?? 0);
28
+ const decimals = (String(this.step).split('.')[1] ?? '').length;
29
+ let next = +(cur + n * this.step).toFixed(decimals);
30
+ if (this.min !== undefined)
31
+ next = Math.max(this.min, next);
32
+ if (this.max !== undefined)
33
+ next = Math.min(this.max, next);
34
+ if (String(next) === this.value)
35
+ return;
36
+ this.value = String(next);
37
+ this.emit('pm-input', { value: this.value });
38
+ this.emit('pm-change', { value: this.value });
39
+ }
40
+ #onKey(e) {
41
+ if (e.key === 'PageUp' || e.key === 'PageDown') {
42
+ e.preventDefault();
43
+ this.stepBy(e.key === 'PageUp' ? 10 : -10);
44
+ }
45
+ else if (e.key === 'ArrowUp' || e.key === 'ArrowDown') {
46
+ e.preventDefault();
47
+ this.stepBy(e.key === 'ArrowUp' ? 1 : -1);
48
+ }
49
+ }
50
+ render() {
51
+ const n = this.valueAsNumber;
52
+ const atMin = this.min !== undefined && Number.isFinite(n) && n <= this.min;
53
+ const atMax = this.max !== undefined && Number.isFinite(n) && n >= this.max;
54
+ const off = this.disabled || this.readonly;
55
+ return this.field(html `<div class="pm-number" data-size=${this.size ?? nothing}>
56
+ ${this.hideButtons ? nothing : html `<button type="button" class="pm-number-step" data-dir="down" tabindex="-1" aria-label="Decrease"
57
+ ?disabled=${off || atMin} @click=${() => this.stepBy(-1)}>−</button>`}
58
+ <input data-control part="control" class="pm-input" data-custom-controls id=${this.controlId} type="number"
59
+ name=${ifDefined(this.name)} .value=${live(this.value)} min=${ifDefined(this.min)} max=${ifDefined(this.max)} step=${this.step}
60
+ placeholder=${ifDefined(this.placeholder)} inputmode="decimal" data-size=${ifDefined(this.size)}
61
+ style=${this.hideButtons ? 'padding-inline: var(--_px); text-align: start' : ''}
62
+ ?required=${this.required} ?disabled=${this.disabled} ?readonly=${this.readonly}
63
+ aria-invalid=${this.showInvalid ? 'true' : nothing} aria-describedby=${ifDefined(this.describedBy())}
64
+ @keydown=${this.#onKey} @input=${this.onInput} @change=${this.onChange} @blur=${this.onBlur} />
65
+ ${this.hideButtons ? nothing : html `<button type="button" class="pm-number-step" data-dir="up" tabindex="-1" aria-label="Increase"
66
+ ?disabled=${off || atMax} @click=${() => this.stepBy(1)}>+</button>`}
67
+ </div>`);
68
+ }
69
+ }
70
+ defineElement('pm-number-input', PmNumberInput);
@@ -0,0 +1,44 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmElement } from '../base.js';
3
+ type Item = number | 'gap';
4
+ /** Page numbers to show: first/last `boundaries`, `siblings` around the current page, gaps in between. */
5
+ export declare function pageItems(page: number, pages: number, siblings?: number, boundaries?: number): Item[];
6
+ /**
7
+ * Pagination. Give `pages`, or `total` items with `page-size`. Buttons by default; links with `href-template`.
8
+ * @tag pm-pagination
9
+ * @fires pm-change - Page changed. detail: { page }
10
+ * @example <pm-pagination page="4" pages="12"></pm-pagination>
11
+ */
12
+ export declare class PmPagination extends PmElement {
13
+ #private;
14
+ static componentName: string;
15
+ static styles: import("lit").CSSResult[];
16
+ static properties: PropertyDeclarations;
17
+ /** Current page (1-based). */
18
+ page: number;
19
+ /** Number of pages (or use `total` + `page-size`). */
20
+ pages?: number;
21
+ /** Total number of items. */
22
+ total?: number;
23
+ /** Rows per page, used with `total` to count pages. */
24
+ pageSize: number;
25
+ /** Pages shown either side of the current one. */
26
+ siblings: number;
27
+ /** Pages always shown at the start and end. */
28
+ boundaries: number;
29
+ /** `simple`: Previous · Page x of y · Next. */
30
+ variant: 'full' | 'simple';
31
+ /** Render links, e.g. "?page={page}". */
32
+ hrefTemplate?: string;
33
+ label: string;
34
+ /** Every page control is disabled (e.g. while a page loads). */
35
+ disabled: boolean;
36
+ /** Control size. */
37
+ size?: 'sm' | 'md' | 'lg';
38
+ constructor();
39
+ get pageCount(): number;
40
+ /** Go to a page (clamped) and emit pm-change. */
41
+ goTo(page: number): void;
42
+ render(): import("lit").TemplateResult<1>;
43
+ }
44
+ export {};
@@ -0,0 +1,94 @@
1
+ import { css, html, nothing } from 'lit';
2
+ import { PmElement, defineElement } from '../base.js';
3
+ import paginationCss from '../styles/pagination.js';
4
+ /** Page numbers to show: first/last `boundaries`, `siblings` around the current page, gaps in between. */
5
+ export function pageItems(page, pages, siblings = 1, boundaries = 1) {
6
+ const set = new Set();
7
+ for (let i = 1; i <= Math.min(boundaries, pages); i++)
8
+ set.add(i);
9
+ for (let i = Math.max(1, pages - boundaries + 1); i <= pages; i++)
10
+ set.add(i);
11
+ for (let i = Math.max(1, page - siblings); i <= Math.min(pages, page + siblings); i++)
12
+ set.add(i);
13
+ const sorted = [...set].sort((a, b) => a - b);
14
+ const out = [];
15
+ sorted.forEach((n, i) => {
16
+ const prev = sorted[i - 1];
17
+ if (prev !== undefined && n - prev === 2)
18
+ out.push(prev + 1);
19
+ else if (prev !== undefined && n - prev > 2)
20
+ out.push('gap');
21
+ out.push(n);
22
+ });
23
+ return out;
24
+ }
25
+ /**
26
+ * Pagination. Give `pages`, or `total` items with `page-size`. Buttons by default; links with `href-template`.
27
+ * @tag pm-pagination
28
+ * @fires pm-change - Page changed. detail: { page }
29
+ * @example <pm-pagination page="4" pages="12"></pm-pagination>
30
+ */
31
+ export class PmPagination extends PmElement {
32
+ static { this.componentName = 'pagination'; }
33
+ static { this.styles = [...PmElement.styles, paginationCss, css `:host { display: block; }`]; }
34
+ static { this.properties = {
35
+ page: { type: Number, reflect: true },
36
+ pages: { type: Number },
37
+ total: { type: Number },
38
+ pageSize: { type: Number, attribute: 'page-size' },
39
+ siblings: { type: Number },
40
+ boundaries: { type: Number },
41
+ variant: { reflect: true },
42
+ hrefTemplate: { attribute: 'href-template' },
43
+ label: {},
44
+ disabled: { type: Boolean, reflect: true },
45
+ size: { reflect: true },
46
+ }; }
47
+ constructor() {
48
+ super();
49
+ this.page = 1;
50
+ this.pageSize = 10;
51
+ this.siblings = 1;
52
+ this.boundaries = 1;
53
+ this.variant = 'full';
54
+ this.label = 'Pagination';
55
+ this.disabled = false;
56
+ }
57
+ get pageCount() {
58
+ return Math.max(1, this.pages ?? Math.ceil((this.total ?? 0) / Math.max(1, this.pageSize)));
59
+ }
60
+ /** Go to a page (clamped) and emit pm-change. */
61
+ goTo(page) {
62
+ const p = Math.min(this.pageCount, Math.max(1, Math.round(page)));
63
+ if (p === this.page)
64
+ return;
65
+ this.page = p;
66
+ this.emit('pm-change', { page: p });
67
+ }
68
+ #item(page, content, opts = {}) {
69
+ if (this.disabled)
70
+ opts = { ...opts, disabled: true };
71
+ if (this.hrefTemplate && !opts.disabled && !opts.current) {
72
+ return html `<a class="pm-page" part="page" href=${this.hrefTemplate.replace('{page}', String(page))} aria-label=${opts.label ?? nothing}
73
+ @click=${() => { this.page = page; this.emit('pm-change', { page }); }}>${content}</a>`;
74
+ }
75
+ return html `<button type="button" class="pm-page" part="page" aria-label=${opts.label ?? nothing}
76
+ aria-current=${opts.current ? 'page' : nothing} ?disabled=${opts.disabled} @click=${() => !opts.current && this.goTo(page)}>${content}</button>`;
77
+ }
78
+ render() {
79
+ const n = this.pageCount;
80
+ const page = Math.min(n, Math.max(1, this.page));
81
+ const arrow = (d) => html `<svg viewBox="0 0 24 24" width="1em" height="1em" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" style=${d === 'prev' ? '' : 'scale: -1 1'}><path d="M15 6l-6 6 6 6"/></svg>`;
82
+ const prev = this.#item(page - 1, html `${arrow('prev')}<span>Previous</span>`, { label: 'Previous page', disabled: page <= 1 });
83
+ const next = this.#item(page + 1, html `<span>Next</span>${arrow('next')}`, { label: 'Next page', disabled: page >= n });
84
+ const middle = this.variant === 'simple'
85
+ ? html `<span class="pm-page-status" aria-live="polite">Page ${page} of ${n}</span>`
86
+ : pageItems(page, n, this.siblings, this.boundaries).map((it) => it === 'gap'
87
+ ? html `<span class="pm-page-gap" aria-hidden="true">…</span>`
88
+ : this.#item(it, it, { label: `Page ${it}`, current: it === page }));
89
+ // Phones: numbers collapse to "Page x of n" (CSS), same markup.
90
+ const compact = this.variant === 'simple' ? nothing : html `<span class="pm-page-status pm-page-compact" aria-hidden="true">${page} / ${n}</span>`;
91
+ return html `<nav class="pm-pagination" part="base" aria-label=${this.label} data-size=${this.size ?? nothing}>${prev}${middle}${compact}${next}</nav>`;
92
+ }
93
+ }
94
+ defineElement('pm-pagination', PmPagination);
@@ -0,0 +1,25 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmFormControl } from './form-control.js';
3
+ /**
4
+ * PIN / one-time code input: one box per character, paste-aware, autofills SMS codes (`autocomplete="one-time-code"`).
5
+ * @tag pm-pin-input
6
+ * @fires pm-complete - Every box is filled. detail: { value }
7
+ * @example <pm-pin-input label="Verification code" length="6"></pm-pin-input>
8
+ */
9
+ export declare class PmPinInput extends PmFormControl {
10
+ #private;
11
+ static componentName: string;
12
+ static styles: import("lit").CSSResult[];
13
+ static properties: PropertyDeclarations;
14
+ /** Number of characters. */
15
+ length: number;
16
+ /** `numeric` (default) or `alphanumeric`. */
17
+ type: 'numeric' | 'alphanumeric';
18
+ /** Hide characters like a password. */
19
+ mask: boolean;
20
+ /** Visual separator after this many boxes (e.g. 3 → "123-456"). */
21
+ separator?: number;
22
+ constructor();
23
+ protected syncValidity(): void;
24
+ render(): import("lit").TemplateResult<1>;
25
+ }
@@ -0,0 +1,128 @@
1
+ import { css, html, nothing } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+ import { defineElement } from '../base.js';
4
+ import inputCss from '../styles/input.js';
5
+ import pinCss from '../styles/pin-input.js';
6
+ import { PmFormControl } from './form-control.js';
7
+ /**
8
+ * PIN / one-time code input: one box per character, paste-aware, autofills SMS codes (`autocomplete="one-time-code"`).
9
+ * @tag pm-pin-input
10
+ * @fires pm-complete - Every box is filled. detail: { value }
11
+ * @example <pm-pin-input label="Verification code" length="6"></pm-pin-input>
12
+ */
13
+ export class PmPinInput extends PmFormControl {
14
+ static { this.componentName = 'pin-input'; }
15
+ static { this.styles = [...PmFormControl.styles, inputCss, pinCss, css ``]; }
16
+ static { this.properties = {
17
+ length: { type: Number }, type: {}, mask: { type: Boolean }, separator: { type: Number },
18
+ }; }
19
+ constructor() { super(); this.length = 6; this.type = 'numeric'; this.mask = false; }
20
+ #cells() { return [...this.renderRoot.querySelectorAll('.pm-pin-cell')]; }
21
+ #allowed(ch) { return this.type === 'numeric' ? /^\d$/.test(ch) : /^[a-z0-9]$/i.test(ch); }
22
+ syncValidity() {
23
+ const first = this.#cells()[0];
24
+ if (!first)
25
+ return;
26
+ if (this.error)
27
+ this.internals.setValidity({ customError: true }, this.error, first);
28
+ else if (this.required && this.value.length < this.length)
29
+ this.internals.setValidity({ valueMissing: true }, `Enter all ${this.length} characters.`, first);
30
+ else
31
+ this.internals.setValidity({});
32
+ }
33
+ #setFrom(chars, focusIndex) {
34
+ const value = chars.join('').slice(0, this.length);
35
+ const changed = value !== this.value;
36
+ this.value = value;
37
+ if (changed)
38
+ this.emit('pm-input', { value });
39
+ if (focusIndex !== undefined)
40
+ this.updateComplete.then(() => this.#cells()[Math.min(focusIndex, this.length - 1)]?.focus());
41
+ if (changed && value.length === this.length) {
42
+ this.emit('pm-change', { value });
43
+ this.emit('pm-complete', { value });
44
+ }
45
+ }
46
+ #onInput(i, e) {
47
+ const input = e.target;
48
+ const typed = [...input.value].filter((c) => this.#allowed(c));
49
+ const chars = [...this.value];
50
+ if (!typed.length) {
51
+ input.value = chars[i] ?? '';
52
+ return;
53
+ }
54
+ // Typing (or autofill) can deliver several characters at once: spread them forward.
55
+ typed.forEach((c, k) => { chars[i + k] = this.type === 'alphanumeric' ? c.toUpperCase() : c; });
56
+ const compact = chars.slice(0, this.length).map((c) => c ?? '');
57
+ this.#setFrom(compact, i + typed.length);
58
+ }
59
+ #onKey(i, e) {
60
+ const chars = [...this.value];
61
+ const rtl = getComputedStyle(this).direction === 'rtl';
62
+ const back = rtl ? 'ArrowRight' : 'ArrowLeft';
63
+ const fwd = rtl ? 'ArrowLeft' : 'ArrowRight';
64
+ if (e.key === 'Backspace') {
65
+ e.preventDefault();
66
+ if (chars[i]) {
67
+ chars.splice(i, 1);
68
+ this.#setFrom(chars, i);
69
+ }
70
+ else if (i > 0) {
71
+ chars.splice(i - 1, 1);
72
+ this.#setFrom(chars, i - 1);
73
+ }
74
+ }
75
+ else if (e.key === 'Delete') {
76
+ e.preventDefault();
77
+ chars.splice(i, 1);
78
+ this.#setFrom(chars, i);
79
+ }
80
+ else if (e.key === back && i > 0) {
81
+ e.preventDefault();
82
+ this.#cells()[i - 1].focus();
83
+ }
84
+ else if (e.key === fwd && i < this.length - 1) {
85
+ e.preventDefault();
86
+ this.#cells()[i + 1].focus();
87
+ }
88
+ else if (e.key === 'Home') {
89
+ e.preventDefault();
90
+ this.#cells()[0].focus();
91
+ }
92
+ else if (e.key === 'End') {
93
+ e.preventDefault();
94
+ this.#cells()[Math.min(this.value.length, this.length - 1)].focus();
95
+ }
96
+ }
97
+ #onPaste(i, e) {
98
+ e.preventDefault();
99
+ const text = [...(e.clipboardData?.getData('text') ?? '')].filter((c) => this.#allowed(c));
100
+ if (!text.length)
101
+ return;
102
+ const chars = [...this.value];
103
+ text.forEach((c, k) => { chars[i + k] = this.type === 'alphanumeric' ? c.toUpperCase() : c; });
104
+ this.#setFrom(chars.slice(0, this.length), i + text.length);
105
+ }
106
+ /** Clicking an empty box focuses the first empty one (codes fill left to right). */
107
+ #onFocus(i, e) {
108
+ const firstEmpty = Math.min(this.value.length, this.length - 1);
109
+ if (i > firstEmpty)
110
+ this.#cells()[firstEmpty].focus();
111
+ else
112
+ e.target.select();
113
+ }
114
+ render() {
115
+ const chars = [...this.value];
116
+ const cells = Array.from({ length: this.length }, (_, i) => html `
117
+ ${this.separator && i > 0 && i % this.separator === 0 ? html `<span class="pm-pin-sep" aria-hidden="true">–</span>` : nothing}
118
+ <input class="pm-input pm-pin-cell" part="cell" id=${i === 0 ? this.controlId : `${this.controlId}-${i}`}
119
+ ?data-control=${i === 0} type=${this.mask ? 'password' : 'text'} inputmode=${this.type === 'numeric' ? 'numeric' : 'text'}
120
+ autocomplete=${i === 0 ? 'one-time-code' : 'off'} maxlength=${i === 0 ? this.length : 1} .value=${chars[i] ?? ''}
121
+ aria-label=${`Character ${i + 1} of ${this.length}`} ?disabled=${this.disabled} ?readonly=${this.readonly}
122
+ aria-invalid=${this.showInvalid ? 'true' : nothing} aria-describedby=${ifDefined(i === 0 ? this.describedBy() : undefined)}
123
+ @input=${(e) => this.#onInput(i, e)} @keydown=${(e) => this.#onKey(i, e)}
124
+ @paste=${(e) => this.#onPaste(i, e)} @focus=${(e) => this.#onFocus(i, e)} @blur=${this.onBlur} />`);
125
+ return this.field(html `<div class="pm-pin" part="group" role="group" aria-label=${ifDefined(this.label)} data-size=${this.size ?? nothing}>${cells}</div>`);
126
+ }
127
+ }
128
+ defineElement('pm-pin-input', PmPinInput);
@@ -0,0 +1,23 @@
1
+ import { SafeHTMLElement } from '../base.js';
2
+ /**
3
+ * Non-modal popover panel. Trigger with native `popovertarget="id"` on any button.
4
+ *
5
+ * `trigger="hover"` turns it into a hover card: it opens when the element named by `for` is hovered or focused and
6
+ * stays open while the pointer is over the card, so its content can be read and clicked. Keep hover cards
7
+ * supplementary: touch users reach the same content by following the link. `class="pm-mega"` lays the panel out as
8
+ * a wide grid of link groups for a navigation (mega) menu.
9
+ * @tag pm-popover
10
+ * @attr {'auto' | 'manual'} popover - Light-dismiss behaviour (default auto).
11
+ * @attr {'click' | 'hover'} trigger - How it opens: by its `popovertarget` button (default), or on hover and focus of the `for` element.
12
+ * @attr {string} for - id of the element that opens a hover card.
13
+ * @attr {'bottom' | 'top' | 'start' | 'end'} placement - Side of the trigger it opens on (default bottom); flips when there is no room.
14
+ * @slot - Panel content.
15
+ * @example <button popovertarget="share">Share</button><pm-popover id="share">…</pm-popover>
16
+ */
17
+ export declare class PmPopover extends SafeHTMLElement {
18
+ #private;
19
+ static get observedAttributes(): string[];
20
+ connectedCallback(): void;
21
+ disconnectedCallback(): void;
22
+ attributeChangedCallback(): void;
23
+ }