@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,47 @@
1
+ import { type PropertyDeclarations, type PropertyValues } from 'lit';
2
+ import { PmFormControl } from './form-control.js';
3
+ /**
4
+ * Date picker: a text field that accepts typed dates (ISO or the locale's format) plus a calendar popup.
5
+ *
6
+ * The popup has month and year views (click its title), side-by-side `months`, quick `presets` and Today / Clear.
7
+ * Value is always "YYYY-MM-DD" (or "start/end" with `range`), submitted with forms.
8
+ * @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).
9
+ * @tag pm-date-picker
10
+ * @example <pm-date-picker label="Due date" min="2026-01-01"></pm-date-picker>
11
+ */
12
+ export declare class PmDatePicker extends PmFormControl {
13
+ #private;
14
+ static componentName: string;
15
+ static styles: import("lit").CSSResult[];
16
+ static properties: PropertyDeclarations;
17
+ min?: string;
18
+ max?: string;
19
+ locale?: string;
20
+ range: boolean;
21
+ placeholder?: string;
22
+ isDateDisabled?: (iso: string) => boolean;
23
+ /** Months shown side by side in the popup (1–3). */
24
+ months?: number;
25
+ /**
26
+ * Quick picks beside the calendar: [{ label, value }]. Values are ISO dates or relative tokens (`today`, `-7d`,
27
+ * `+1w`, `-3m`, `-1y`, `month-start`, `month-end`, `year-start`, `year-end`), joined with "/" for ranges.
28
+ */
29
+ presets?: {
30
+ label: string;
31
+ value: string;
32
+ }[];
33
+ /** Hide the Today / Clear footer. */
34
+ hideFooter: boolean;
35
+ _open: boolean;
36
+ _text?: string;
37
+ constructor();
38
+ /** Resolve a preset token ("today", "-7d", "month-start", ISO…) to an ISO date. */
39
+ static resolveDate(token: string, today?: string): string | undefined;
40
+ protected syncValidity(): void;
41
+ open(): void;
42
+ close(focus?: boolean): void;
43
+ protected updated(changed: PropertyValues<this>): void;
44
+ disconnectedCallback(): void;
45
+ protected willUpdate(changed: PropertyValues<this>): void;
46
+ render(): import("lit").TemplateResult<1>;
47
+ }
@@ -0,0 +1,267 @@
1
+ var _a;
2
+ import { css, html, nothing } from 'lit';
3
+ import { ifDefined } from 'lit/directives/if-defined.js';
4
+ import { live } from 'lit/directives/live.js';
5
+ import { defineElement } from '../base.js';
6
+ import { attachBelow, hidePopup, showPopup } from '../floating.js';
7
+ import { enableSheetDrag } from '../sheet.js';
8
+ import sheetCss from '../styles/sheet.js';
9
+ import inputCss from '../styles/input.js';
10
+ import listboxCss from '../styles/listbox.js';
11
+ import { PmCalendar, parseISODate, toISODate, todayISO } from './calendar.js';
12
+ import { PmFormControl } from './form-control.js';
13
+ /**
14
+ * Date picker: a text field that accepts typed dates (ISO or the locale's format) plus a calendar popup.
15
+ *
16
+ * The popup has month and year views (click its title), side-by-side `months`, quick `presets` and Today / Clear.
17
+ * Value is always "YYYY-MM-DD" (or "start/end" with `range`), submitted with forms.
18
+ * @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).
19
+ * @tag pm-date-picker
20
+ * @example <pm-date-picker label="Due date" min="2026-01-01"></pm-date-picker>
21
+ */
22
+ export class PmDatePicker extends PmFormControl {
23
+ static { this.componentName = 'date-picker'; }
24
+ static { this.styles = [...PmFormControl.styles, inputCss, listboxCss, sheetCss, css `
25
+ .popup { padding: var(--pm-space-3); }
26
+ .popup[data-sheet] { padding: 1.75rem var(--pm-space-4) max(var(--pm-space-4), var(--pm-safe-bottom, 0px)); }
27
+ .popup[data-sheet]:popover-open { display: grid; justify-items: center; }
28
+ .pm-input-group > .pm-input { padding-inline-end: var(--pm-control-height-md); }
29
+ .trigger { position: absolute; inset-inline-end: var(--pm-space-1); }
30
+ .body { display: flex; gap: var(--pm-space-3); }
31
+ .presets { display: grid; align-content: start; gap: 2px; padding-inline-end: var(--pm-space-3); border-inline-end: 1px solid var(--pm-color-border); min-inline-size: 9rem; }
32
+ .presets button, .foot button { padding: .4rem .6rem; min-block-size: 2rem; border: 0; border-radius: var(--pm-radius-md); background: none; color: inherit; font: inherit; font-size: var(--pm-font-size-sm); text-align: start; cursor: pointer; }
33
+ .presets button:hover, .foot button:hover:not(:disabled) { background: var(--pm-color-bg-hover); }
34
+ .presets button[aria-pressed="true"] { background: var(--pm-color-accent-soft); color: var(--pm-color-accent-text); font-weight: var(--pm-font-weight-semibold); }
35
+ .presets button:focus-visible, .foot button:focus-visible { outline: 2px solid var(--pm-color-ring); }
36
+ .foot { display: flex; justify-content: space-between; gap: var(--pm-space-2); margin-block-start: var(--pm-space-2); padding-block-start: var(--pm-space-2); border-block-start: 1px solid var(--pm-color-border); }
37
+ .foot button { color: var(--pm-color-accent-text); font-weight: var(--pm-font-weight-medium); }
38
+ .foot button:disabled { opacity: .4; cursor: not-allowed; }
39
+ @media (width < 40rem) { .body { flex-direction: column; } .presets { border: 0; padding: 0; grid-template-columns: repeat(auto-fill, minmax(8rem, 1fr)); } }
40
+ `]; }
41
+ static { this.properties = {
42
+ min: {}, max: {}, locale: {}, range: { type: Boolean }, placeholder: {}, isDateDisabled: { attribute: false },
43
+ months: { type: Number }, presets: { type: Array }, hideFooter: { type: Boolean, attribute: 'hide-footer' },
44
+ _open: { state: true }, _text: { state: true },
45
+ }; }
46
+ #detach;
47
+ constructor() { super(); this.range = false; this._open = false; this.hideFooter = false; }
48
+ /** Resolve a preset token ("today", "-7d", "month-start", ISO…) to an ISO date. */
49
+ static resolveDate(token, today = todayISO()) {
50
+ const t = token.trim();
51
+ if (parseISODate(t))
52
+ return t;
53
+ const d = parseISODate(today);
54
+ const y = d.getUTCFullYear();
55
+ const m = d.getUTCMonth();
56
+ if (t === 'today')
57
+ return today;
58
+ if (t === 'month-start')
59
+ return toISODate(new Date(Date.UTC(y, m, 1)));
60
+ if (t === 'month-end')
61
+ return toISODate(new Date(Date.UTC(y, m + 1, 0)));
62
+ if (t === 'year-start')
63
+ return toISODate(new Date(Date.UTC(y, 0, 1)));
64
+ if (t === 'year-end')
65
+ return toISODate(new Date(Date.UTC(y, 11, 31)));
66
+ const r = t.match(/^([+-]\d+)([dwmy])$/);
67
+ if (!r)
68
+ return undefined;
69
+ const n = +r[1];
70
+ if (r[2] === 'd' || r[2] === 'w')
71
+ return toISODate(new Date(d.getTime() + n * (r[2] === 'w' ? 7 : 1) * 864e5));
72
+ const months = r[2] === 'y' ? n * 12 : n;
73
+ const last = new Date(Date.UTC(y, m + months + 1, 0)).getUTCDate();
74
+ return toISODate(new Date(Date.UTC(y, m + months, Math.min(d.getUTCDate(), last))));
75
+ }
76
+ #resolve(v) {
77
+ const parts = v.split('/').map((p) => _a.resolveDate(p));
78
+ if (parts.some((p) => !p))
79
+ return undefined;
80
+ return this.range ? (parts.length === 2 ? parts.sort().join('/') : undefined) : parts[0];
81
+ }
82
+ #setValue(v, closeIt = true) {
83
+ this._text = undefined;
84
+ if (v !== this.value) {
85
+ this.value = v;
86
+ this.emit('pm-change', { value: v });
87
+ }
88
+ if (closeIt)
89
+ this.close(true);
90
+ }
91
+ get #locale() { return this.locale || this.closest('[lang]')?.getAttribute('lang') || navigator.language || 'en-US'; }
92
+ #fmt(iso) {
93
+ const d = parseISODate(iso);
94
+ return d ? new Intl.DateTimeFormat(this.#locale, { dateStyle: 'medium', timeZone: 'UTC' }).format(d) : '';
95
+ }
96
+ get #display() {
97
+ if (!this.value)
98
+ return '';
99
+ if (!this.range)
100
+ return this.#fmt(this.value);
101
+ const [a, b] = this.value.split('/');
102
+ return b ? `${this.#fmt(a)} – ${this.#fmt(b)}` : this.#fmt(a);
103
+ }
104
+ /** Parse "2026-12-02" or the locale's numeric order (e.g. 12/2/2026, 2.12.2026). */
105
+ #parse(text) {
106
+ const t = text.trim();
107
+ if (parseISODate(t))
108
+ return t;
109
+ const nums = t.split(/[^\d]+/).filter(Boolean).map(Number);
110
+ if (nums.length !== 3)
111
+ return undefined;
112
+ const order = new Intl.DateTimeFormat(this.#locale, { timeZone: 'UTC' }).formatToParts(new Date(Date.UTC(2000, 0, 2)))
113
+ .filter((p) => p.type === 'year' || p.type === 'month' || p.type === 'day').map((p) => p.type);
114
+ const get = (k) => nums[order.indexOf(k)];
115
+ let y = get('year');
116
+ if (y < 100)
117
+ y += 2000;
118
+ const iso = `${String(y).padStart(4, '0')}-${String(get('month')).padStart(2, '0')}-${String(get('day')).padStart(2, '0')}`;
119
+ return parseISODate(iso) ? iso : undefined;
120
+ }
121
+ syncValidity() {
122
+ const c = this.control;
123
+ if (!c)
124
+ return;
125
+ const [a, b] = this.value.split('/');
126
+ let msg = '';
127
+ if (this.error)
128
+ msg = this.error;
129
+ else if (this._text !== undefined && this._text.trim() && !this.#parse(this._text))
130
+ msg = 'Enter a valid date.';
131
+ else if (this.required && !this.value)
132
+ msg = '';
133
+ else if (a && ((this.min && a < this.min) || (this.max && (b || a) > this.max)))
134
+ msg = `Choose a date between ${this.#fmt(this.min) || '…'} and ${this.#fmt(this.max) || '…'}.`;
135
+ if (msg)
136
+ this.internals.setValidity({ customError: true }, msg, c);
137
+ else if (this.required && !this.value)
138
+ this.internals.setValidity({ valueMissing: true }, 'Please choose a date.', c);
139
+ else
140
+ this.internals.setValidity({});
141
+ }
142
+ #commitText() {
143
+ if (this._text === undefined || this.range)
144
+ return;
145
+ const t = this._text.trim();
146
+ if (!t) {
147
+ if (this.value) {
148
+ this.value = '';
149
+ this.emit('pm-change', { value: '' });
150
+ }
151
+ this._text = undefined;
152
+ return;
153
+ }
154
+ const iso = this.#parse(t);
155
+ if (iso) {
156
+ this._text = undefined;
157
+ if (iso !== this.value) {
158
+ this.value = iso;
159
+ this.emit('pm-change', { value: iso });
160
+ }
161
+ }
162
+ }
163
+ open() { if (!this.disabled && !this.readonly)
164
+ this._open = true; }
165
+ close(focus = false) { this._open = false; if (focus)
166
+ this.control?.focus(); }
167
+ updated(changed) {
168
+ super.updated(changed);
169
+ const popup = this.renderRoot.querySelector('.popup');
170
+ const anchor = this.renderRoot.querySelector('.pm-input-group');
171
+ if (!popup || !anchor)
172
+ return;
173
+ if (this._open) {
174
+ showPopup(popup);
175
+ if (!this.#detach) {
176
+ const off = attachBelow(popup, anchor, { matchWidth: false, sheet: true });
177
+ const drag = enableSheetDrag(popup, () => this.close(true));
178
+ this.#detach = () => { off(); drag(); };
179
+ }
180
+ if (changed.has('_open'))
181
+ this.updateComplete.then(() => this.renderRoot.querySelector('pm-calendar')?.renderRoot.querySelector('.pm-day[tabindex="0"]')?.focus());
182
+ }
183
+ else {
184
+ this.#detach?.();
185
+ this.#detach = undefined;
186
+ hidePopup(popup);
187
+ }
188
+ }
189
+ disconnectedCallback() { super.disconnectedCallback(); this.#detach?.(); }
190
+ #onCal(e) {
191
+ e.stopPropagation();
192
+ this.value = e.detail.value;
193
+ this._text = undefined;
194
+ this.emit('pm-change', { value: this.value });
195
+ if (!this.range || /\/\d/.test(this.value))
196
+ this.close(true);
197
+ }
198
+ #popup() {
199
+ const presets = (this.presets ?? []).map((p) => ({ ...p, iso: this.#resolve(p.value) })).filter((p) => p.iso);
200
+ const today = todayISO();
201
+ const todayOk = !((this.min && today < this.min) || (this.max && today > this.max) || this.isDateDisabled?.(today));
202
+ return html `<div class="body">
203
+ ${presets.length ? html `<div class="presets" role="group" aria-label="Quick picks">${presets.map((p) => html `<button type="button"
204
+ aria-pressed=${p.iso === this.value ? 'true' : 'false'} @click=${() => this.#setValue(p.iso)}>${p.label}</button>`)}</div>` : nothing}
205
+ <div>
206
+ <pm-calendar .value=${this.value} .min=${this.min} .max=${this.max} .locale=${this.locale} .range=${this.range} .months=${this.months ?? 1}
207
+ .isDateDisabled=${this.isDateDisabled} @pm-change=${this.#onCal}></pm-calendar>
208
+ ${this.hideFooter ? nothing : html `<div class="foot">
209
+ <button type="button" ?disabled=${!todayOk} @click=${() => {
210
+ if (this.range)
211
+ this.renderRoot.querySelector('pm-calendar')?.showDate(today);
212
+ else
213
+ this.#setValue(today);
214
+ }}>${this.range ? 'Go to today' : 'Today'}</button>
215
+ <button type="button" ?disabled=${!this.value} @click=${() => this.#setValue('', false)}>Clear</button>
216
+ </div>`}
217
+ </div>
218
+ </div>`;
219
+ }
220
+ willUpdate(changed) {
221
+ super.willUpdate(changed);
222
+ if (changed.has('presets') && typeof this.presets === 'string') {
223
+ try {
224
+ this.presets = JSON.parse(this.presets);
225
+ }
226
+ catch {
227
+ this.presets = [];
228
+ }
229
+ }
230
+ }
231
+ render() {
232
+ return this.field(html `<div class="pm-input-group">
233
+ <input data-control part="control" class="pm-input" id=${this.controlId} type="text" autocomplete="off"
234
+ .value=${live(this._text ?? this.#display)} placeholder=${ifDefined(this.placeholder)}
235
+ data-size=${ifDefined(this.size)} ?required=${this.required} ?disabled=${this.disabled} ?readonly=${this.readonly} style=${this.range ? 'cursor: pointer' : ''}
236
+ @beforeinput=${(e) => { if (this.range)
237
+ e.preventDefault(); }}
238
+ aria-invalid=${this.showInvalid ? 'true' : nothing} aria-describedby=${ifDefined(this.describedBy())} role="combobox" aria-haspopup="dialog" aria-expanded=${this._open ? 'true' : 'false'}
239
+ @input=${(e) => { this._text = e.target.value; }} @change=${() => this.#commitText()} @blur=${() => { this.#commitText(); this.onBlur(); }}
240
+ @click=${() => { if (this.range)
241
+ this.open(); }}
242
+ @keydown=${(e) => { if (e.key === 'ArrowDown' && e.altKey || e.key === 'ArrowDown' && this.range) {
243
+ e.preventDefault();
244
+ this.open();
245
+ }
246
+ else if (e.key === 'Enter')
247
+ this.#commitText(); }} />
248
+ <button type="button" class="pm-input-action trigger" part="trigger" aria-label="Choose date" ?disabled=${this.disabled || this.readonly}
249
+ @click=${() => (this._open ? this.close() : this.open())}>
250
+ <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"><rect x="3.5" y="5" width="17" height="15" rx="2"/><path d="M3.5 10h17M8 3v4M16 3v4"/></svg>
251
+ </button>
252
+ </div>
253
+ <div class="pm-listbox-popup popup" popover="manual" part="popup" role="dialog" aria-modal="false" aria-label=${this.label ? `Choose ${this.label}` : 'Choose date'}
254
+ @keydown=${(e) => { if (e.key === 'Escape') {
255
+ e.preventDefault();
256
+ e.stopPropagation();
257
+ this.close(true);
258
+ } }}
259
+ @focusout=${(e) => { const t = e.relatedTarget; if (t && (this.renderRoot.contains(t) || this.contains(t)))
260
+ return; requestAnimationFrame(() => { if (this.getRootNode().activeElement !== this)
261
+ this.close(); }); }}>
262
+ ${this._open ? this.#popup() : nothing}
263
+ </div>`);
264
+ }
265
+ }
266
+ _a = PmDatePicker;
267
+ defineElement('pm-date-picker', PmDatePicker);
@@ -0,0 +1,38 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmElement } from '../base.js';
3
+ /**
4
+ * Description list: label and value pairs for detail views (an order, a profile, an invoice).
5
+ *
6
+ * Labels sit beside values, and stack above them on phones or with `layout="vertical"`. Plain HTML alternative: `<dl
7
+ * class="pm-dl"><div><dt>Plan</dt><dd>Pro</dd></div></dl>`.
8
+ * @tag pm-description-list
9
+ * @slot - `<pm-description-item>` elements.
10
+ * @example <pm-description-list divided><pm-description-item label="Plan">Pro</pm-description-item><pm-description-item label="Renews">1 March 2027</pm-description-item></pm-description-list>
11
+ */
12
+ export declare class PmDescriptionList extends PmElement {
13
+ static componentName: string;
14
+ static styles: import("lit").CSSResult[];
15
+ static properties: PropertyDeclarations;
16
+ /** horizontal (default: label beside value) or vertical (label above value). */
17
+ layout?: 'horizontal' | 'vertical';
18
+ /** Number of columns of pairs on wide screens (default 1). */
19
+ columns?: number;
20
+ /** Draw a line between rows. */
21
+ divided?: boolean;
22
+ /** Accessible name for the list. */
23
+ label?: string;
24
+ render(): import("lit").TemplateResult<1>;
25
+ }
26
+ /**
27
+ * One label and value pair in a `<pm-description-list>`.
28
+ * @tag pm-description-item
29
+ * @slot - The value (text, a badge, a link).
30
+ * @slot label - Rich label, instead of the `label` attribute.
31
+ */
32
+ export declare class PmDescriptionItem extends PmElement {
33
+ static styles: import("lit").CSSResult[];
34
+ static properties: PropertyDeclarations;
35
+ label?: string;
36
+ connectedCallback(): void;
37
+ render(): import("lit").TemplateResult<1>;
38
+ }
@@ -0,0 +1,41 @@
1
+ import { css, html, nothing } from 'lit';
2
+ import { PmElement, defineElement } from '../base.js';
3
+ import dlCss from '../styles/description-list.js';
4
+ /**
5
+ * Description list: label and value pairs for detail views (an order, a profile, an invoice).
6
+ *
7
+ * Labels sit beside values, and stack above them on phones or with `layout="vertical"`. Plain HTML alternative: `<dl
8
+ * class="pm-dl"><div><dt>Plan</dt><dd>Pro</dd></div></dl>`.
9
+ * @tag pm-description-list
10
+ * @slot - `<pm-description-item>` elements.
11
+ * @example <pm-description-list divided><pm-description-item label="Plan">Pro</pm-description-item><pm-description-item label="Renews">1 March 2027</pm-description-item></pm-description-list>
12
+ */
13
+ export class PmDescriptionList extends PmElement {
14
+ static { this.componentName = 'description-list'; }
15
+ static { this.styles = [...PmElement.styles, dlCss, css `:host { display: block; min-inline-size: 0; } :host([hidden]) { display: none; }`]; }
16
+ static { this.properties = { layout: { reflect: true }, columns: { type: Number, reflect: true }, divided: { type: Boolean, reflect: true }, label: {} }; }
17
+ render() {
18
+ return html `<div class="pm-dl" part="base" role="list" aria-label=${this.label ?? nothing} style=${this.columns ? `--pm-dl-columns:${this.columns}` : nothing}><slot></slot></div>`;
19
+ }
20
+ }
21
+ /**
22
+ * One label and value pair in a `<pm-description-list>`.
23
+ * @tag pm-description-item
24
+ * @slot - The value (text, a badge, a link).
25
+ * @slot label - Rich label, instead of the `label` attribute.
26
+ */
27
+ export class PmDescriptionItem extends PmElement {
28
+ static { this.styles = [...PmElement.styles, dlCss, css `:host { display: block; min-inline-size: 0; } :host([hidden]) { display: none; }`]; }
29
+ static { this.properties = { label: {} }; }
30
+ connectedCallback() { super.connectedCallback(); if (!this.hasAttribute('role'))
31
+ this.setAttribute('role', 'listitem'); }
32
+ render() {
33
+ const list = this.closest('pm-description-list');
34
+ return html `<div class="pm-dl-item" part="base" data-layout=${list?.layout ?? nothing} ?data-divided=${!!list?.divided && this.previousElementSibling !== null}>
35
+ <span class="pm-dl-label" part="label"><slot name="label">${this.label}</slot></span>
36
+ <span class="pm-dl-value" part="value"><slot></slot></span>
37
+ </div>`;
38
+ }
39
+ }
40
+ defineElement('pm-description-list', PmDescriptionList);
41
+ defineElement('pm-description-item', PmDescriptionItem);
@@ -0,0 +1,47 @@
1
+ import { type PropertyDeclarations, type PropertyValues } from 'lit';
2
+ import { PmElement } from '../base.js';
3
+ /**
4
+ * Modal dialog built on native `<dialog>` (focus containment, inert page, Esc, focus return).
5
+ *
6
+ * Open with `el.show()`, the `open` attribute, or an invoker: `<button commandfor="id" command="--open">`.
7
+ * Responsive by default (fits narrow screens). With native mobile on (`mobile` here or on an ancestor such as `<html
8
+ * mobile>`, or `setMobile(true)`), phones get a bottom sheet you can swipe down; `mobile-variant="center"` keeps it
9
+ * centred and `mobile-variant="fullscreen"` fills the screen. Same markup on every device.
10
+ * @attr {boolean} mobile - Native mobile patterns on phones (inherits from ancestors; `mobile="false"` opts out).
11
+ * @tag pm-dialog
12
+ * @slot - Body.
13
+ * @slot footer - Actions.
14
+ * @fires pm-open - Opened.
15
+ * @fires pm-close - Closed. detail: { returnValue }
16
+ * @csspart dialog - The native `<dialog>` box (size, padding, background).
17
+ * @example <pm-dialog id="confirm" heading="Delete project?" description="This cannot be undone.">…</pm-dialog>
18
+ */
19
+ export declare class PmDialog extends PmElement {
20
+ #private;
21
+ static componentName: string;
22
+ static styles: import("lit").CSSResult[];
23
+ static properties: PropertyDeclarations;
24
+ open: boolean;
25
+ heading?: string;
26
+ description?: string;
27
+ size?: 'sm' | 'md' | 'lg' | 'full';
28
+ /** `any` = click outside or Esc · `closerequest` = Esc only · `none` = only explicit close. */
29
+ dismiss: 'any' | 'closerequest' | 'none';
30
+ /** Phone layout when native mobile is on: bottom `sheet` (default), `center`, or `fullscreen`. */
31
+ mobile?: string;
32
+ mobileVariant?: 'sheet' | 'center' | 'fullscreen';
33
+ _compact: boolean;
34
+ /** True when this dialog renders as a bottom sheet right now. */
35
+ protected get sheet(): boolean;
36
+ protected side?: string;
37
+ protected cls: string;
38
+ constructor();
39
+ get dialog(): HTMLDialogElement | null;
40
+ show(): void;
41
+ close(returnValue?: string): Promise<void>;
42
+ connectedCallback(): void;
43
+ disconnectedCallback(): void;
44
+ protected willUpdate(changed: PropertyValues<this>): void;
45
+ protected updated(changed: PropertyValues<this>): void;
46
+ render(): import("lit").TemplateResult<1>;
47
+ }
@@ -0,0 +1,189 @@
1
+ import { css, html, nothing } from 'lit';
2
+ import { ifDefined } from 'lit/directives/if-defined.js';
3
+ import { PmElement, nextId, defineElement } from '../base.js';
4
+ import { closeTopLayer } from '../top-layer.js';
5
+ import overlayCss from '../styles/overlay.js';
6
+ import buttonCss from '../styles/button.js';
7
+ import dialogCss from '../styles/dialog.js';
8
+ import sheetCss from '../styles/sheet.js';
9
+ import { COMPACT_QUERY, enableSheetDrag, isMobile, onMobileChange } from '../sheet.js';
10
+ /**
11
+ * Modal dialog built on native `<dialog>` (focus containment, inert page, Esc, focus return).
12
+ *
13
+ * Open with `el.show()`, the `open` attribute, or an invoker: `<button commandfor="id" command="--open">`.
14
+ * Responsive by default (fits narrow screens). With native mobile on (`mobile` here or on an ancestor such as `<html
15
+ * mobile>`, or `setMobile(true)`), phones get a bottom sheet you can swipe down; `mobile-variant="center"` keeps it
16
+ * centred and `mobile-variant="fullscreen"` fills the screen. Same markup on every device.
17
+ * @attr {boolean} mobile - Native mobile patterns on phones (inherits from ancestors; `mobile="false"` opts out).
18
+ * @tag pm-dialog
19
+ * @slot - Body.
20
+ * @slot footer - Actions.
21
+ * @fires pm-open - Opened.
22
+ * @fires pm-close - Closed. detail: { returnValue }
23
+ * @csspart dialog - The native `<dialog>` box (size, padding, background).
24
+ * @example <pm-dialog id="confirm" heading="Delete project?" description="This cannot be undone.">…</pm-dialog>
25
+ */
26
+ export class PmDialog extends PmElement {
27
+ static { this.componentName = 'dialog'; }
28
+ static { this.styles = [...PmElement.styles, overlayCss, buttonCss, dialogCss, sheetCss, css `:host { display: contents; }`]; }
29
+ static { this.properties = {
30
+ open: { type: Boolean, reflect: true },
31
+ heading: {},
32
+ description: {},
33
+ size: { reflect: true },
34
+ dismiss: { reflect: true },
35
+ mobile: {},
36
+ mobileVariant: { attribute: 'mobile-variant', reflect: true },
37
+ _compact: { state: true },
38
+ }; }
39
+ #mq;
40
+ #undrag;
41
+ #onMq;
42
+ /** True when this dialog renders as a bottom sheet right now. */
43
+ get sheet() { return this._compact && (this.mobileVariant ?? 'sheet') === 'sheet'; }
44
+ #titleId;
45
+ #descId;
46
+ constructor() {
47
+ super();
48
+ this.#onMq = () => { this._compact = !!this.#mq?.matches && isMobile(this); };
49
+ this.cls = 'pm-dialog';
50
+ this.#titleId = nextId('dlg-title');
51
+ this.#descId = nextId('dlg-desc');
52
+ this.#hasFooter = false;
53
+ this.#onFooterSlot = (e) => {
54
+ const has = e.target.assignedElements().length > 0;
55
+ if (has !== this.#hasFooter) {
56
+ this.#hasFooter = has;
57
+ this.requestUpdate();
58
+ }
59
+ };
60
+ this.#onClose = () => {
61
+ const d = this.dialog;
62
+ this.open = false;
63
+ this.emit('pm-close', { returnValue: d?.returnValue ?? '' });
64
+ if (d)
65
+ d.returnValue = '';
66
+ };
67
+ this.#onCancel = (e) => {
68
+ if (this.dismiss === 'none') {
69
+ e.preventDefault();
70
+ return;
71
+ }
72
+ e.preventDefault();
73
+ void this.close();
74
+ };
75
+ this.#onPointer = (() => {
76
+ let downOutside = false;
77
+ const outside = (e) => {
78
+ const r = this.dialog.getBoundingClientRect();
79
+ return e.clientX < r.left || e.clientX > r.right || e.clientY < r.top || e.clientY > r.bottom;
80
+ };
81
+ return {
82
+ down: (e) => { downOutside = this.dismiss === 'any' && outside(e); },
83
+ up: (e) => { if (downOutside && outside(e))
84
+ void this.close(); },
85
+ };
86
+ })();
87
+ this.open = false;
88
+ this._compact = false;
89
+ this.dismiss = 'closerequest';
90
+ // Invoker commands: <button commandfor="my-dialog" command="--open|--close|--toggle">
91
+ this.addEventListener('command', (e) => {
92
+ const cmd = e.command;
93
+ if (cmd === '--open' || cmd === 'show-modal')
94
+ this.show();
95
+ else if (cmd === '--close' || cmd === 'close' || cmd === 'request-close')
96
+ this.close();
97
+ else if (cmd === '--toggle')
98
+ this.open ? this.close() : this.show();
99
+ });
100
+ }
101
+ get dialog() {
102
+ return this.renderRoot?.querySelector('dialog') ?? null;
103
+ }
104
+ show() { this.#onMq(); this.open = true; }
105
+ async close(returnValue = '') {
106
+ const d = this.dialog;
107
+ if (!d?.open) {
108
+ this.open = false;
109
+ return;
110
+ }
111
+ await closeTopLayer(d, () => d.close(returnValue));
112
+ }
113
+ connectedCallback() {
114
+ super.connectedCallback();
115
+ if (typeof matchMedia === 'function') {
116
+ this.#mq ??= matchMedia(COMPACT_QUERY);
117
+ this.#mq.addEventListener('change', this.#onMq);
118
+ this.#onMq();
119
+ }
120
+ this.#offMobile = onMobileChange(this.#onMq);
121
+ }
122
+ #offMobile;
123
+ disconnectedCallback() {
124
+ super.disconnectedCallback();
125
+ this.#mq?.removeEventListener('change', this.#onMq);
126
+ this.#offMobile?.();
127
+ this.#undrag?.();
128
+ this.#undrag = undefined;
129
+ }
130
+ willUpdate(changed) {
131
+ super.willUpdate(changed);
132
+ if (changed.has('mobile'))
133
+ this.#onMq();
134
+ }
135
+ updated(changed) {
136
+ super.updated(changed);
137
+ const d = this.dialog;
138
+ if (d && !this.#undrag)
139
+ this.#undrag = enableSheetDrag(d, () => void this.close(), { enabled: () => this.dismiss !== 'none' });
140
+ if (!d || !changed.has('open'))
141
+ return;
142
+ if (this.open && !d.open) {
143
+ d.showModal();
144
+ this.emit('pm-open');
145
+ }
146
+ else if (!this.open && d.open) {
147
+ void this.close();
148
+ }
149
+ }
150
+ #hasFooter;
151
+ #onFooterSlot;
152
+ #onClose;
153
+ #onCancel;
154
+ #onPointer;
155
+ render() {
156
+ return html `<dialog
157
+ part="dialog"
158
+ class=${this.cls}
159
+ data-size=${ifDefined(this.size)}
160
+ data-side=${ifDefined(this.side)}
161
+ ?data-sheet=${this.sheet}
162
+ ?data-fullscreen=${this._compact && this.mobileVariant === 'fullscreen'}
163
+ aria-labelledby=${ifDefined(this.heading ? this.#titleId : undefined)}
164
+ aria-describedby=${ifDefined(this.description ? this.#descId : undefined)}
165
+ closedby=${this.dismiss}
166
+ @close=${this.#onClose}
167
+ @cancel=${this.#onCancel}
168
+ @pointerdown=${this.#onPointer.down}
169
+ @pointerup=${this.#onPointer.up}
170
+ >
171
+ ${this.heading || this.description
172
+ ? html `<header style="padding-inline-end:${this.dismiss === 'none' ? '0' : '2.25rem'}">
173
+ ${this.heading ? html `<h1 class="pm-dialog-title" id=${this.#titleId} part="title">${this.heading}</h1>` : nothing}
174
+ ${this.description ? html `<p class="pm-dialog-description" id=${this.#descId}>${this.description}</p>` : nothing}
175
+ </header>`
176
+ : nothing}
177
+ ${this.dismiss === 'none'
178
+ ? nothing
179
+ : html `<button type="button" part="close" class="pm-button" data-variant="ghost" data-tone="neutral" data-size="sm" data-icon
180
+ aria-label="Close" style="position:absolute;inset-block-start:var(--pm-space-3);inset-inline-end:var(--pm-space-3)"
181
+ @click=${() => void this.close()}>✕</button>`}
182
+ <slot></slot>
183
+ <footer part="footer" ?hidden=${!this.#hasFooter} style="display:flex;gap:var(--pm-space-2);justify-content:flex-end;flex-wrap:wrap;margin-block-start:var(--pm-space-6)">
184
+ <slot name="footer" @slotchange=${this.#onFooterSlot}></slot>
185
+ </footer>
186
+ </dialog>`;
187
+ }
188
+ }
189
+ defineElement('pm-dialog', PmDialog);
@@ -0,0 +1,16 @@
1
+ import { type PropertyDeclarations } from 'lit';
2
+ import { PmElement } from '../base.js';
3
+ /**
4
+ * Divider (separator), optionally labelled.
5
+ * @tag pm-divider
6
+ * @slot - Optional label, e.g. "or".
7
+ * @example <pm-divider>or continue with</pm-divider>
8
+ */
9
+ export declare class PmDivider extends PmElement {
10
+ static componentName: string;
11
+ static styles: import("lit").CSSResult[];
12
+ static properties: PropertyDeclarations;
13
+ orientation: 'horizontal' | 'vertical';
14
+ constructor();
15
+ render(): import("lit").TemplateResult<1>;
16
+ }