@aceshooting/lyra-ui 32.0.0 → 32.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 (419) hide show
  1. package/CHANGELOG.md +203 -0
  2. package/README.md +24 -6
  3. package/design-tokens.json +1 -1
  4. package/dist/all.d.ts +1 -1
  5. package/dist/all.js +1 -1
  6. package/dist/autoloader.d.ts +10 -0
  7. package/dist/autoloader.js +1 -1
  8. package/dist/cli/migrate-wa.mjs +45 -37
  9. package/dist/cli/migration-contract.json.gz +0 -0
  10. package/dist/components/agent-tools/budget-meter/budget-meter.class.d.ts +1 -0
  11. package/dist/components/agent-tools/budget-meter/budget-meter.styles.js +1 -1
  12. package/dist/components/charts/chart/box-plot.class.d.ts +3 -0
  13. package/dist/components/charts/chart/chart-band.js +1 -1
  14. package/dist/components/charts/chart/chart-input-projection.js +1 -1
  15. package/dist/components/charts/chart/chart-surface.styles.js +1 -1
  16. package/dist/components/charts/chart/chart-types.d.ts +16 -2
  17. package/dist/components/charts/chart/chart.class.d.ts +4 -1
  18. package/dist/components/charts/chart/chart.class.js +3 -3
  19. package/dist/components/charts/chart/lite-chart.class.d.ts +3 -0
  20. package/dist/components/charts/chart/lite-chart.styles.js +1 -1
  21. package/dist/components/conversation/code-block/code-block-base.class.d.ts +29 -3
  22. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  23. package/dist/components/conversation/code-block/code-block-core.class.d.ts +46 -2
  24. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  25. package/dist/components/conversation/code-block/code-block-shared.d.ts +6 -2
  26. package/dist/components/conversation/code-block/code-block-shared.js +5 -4
  27. package/dist/components/conversation/code-block/code-block.class.d.ts +45 -1
  28. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  29. package/dist/components/conversation/code-block/code-block.styles.js +1 -1
  30. package/dist/components/conversation/markdown/markdown-core.class.d.ts +12 -0
  31. package/dist/components/conversation/markdown/markdown.class.d.ts +12 -0
  32. package/dist/components/conversation/markdown/markdown.styles.js +1 -1
  33. package/dist/components/conversation/model-select/model-select.class.d.ts +6 -0
  34. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +1 -0
  35. package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
  36. package/dist/components/conversation/thread-list/thread-list.class.d.ts +3 -0
  37. package/dist/components/conversation/thread-list/thread-list.styles.js +1 -1
  38. package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +6 -0
  39. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +4 -0
  40. package/dist/components/data/heatmap/heatmap.class.d.ts +21 -2
  41. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  42. package/dist/components/data/heatmap/heatmap.styles.js +1 -1
  43. package/dist/components/data/stat/stat.class.d.ts +24 -1
  44. package/dist/components/data/stat/stat.class.js +2 -2
  45. package/dist/components/data/stat/stat.styles.js +1 -1
  46. package/dist/components/data/table/table-row-attributes.js +1 -0
  47. package/dist/components/data/table/table-support.d.ts +65 -5
  48. package/dist/components/data/table/table-support.js +1 -1
  49. package/dist/components/data/table/table.class.d.ts +77 -7
  50. package/dist/components/data/table/table.class.js +10 -10
  51. package/dist/components/data/table/table.styles.js +1 -1
  52. package/dist/components/data/timeline/timeline-item.class.d.ts +27 -5
  53. package/dist/components/data/timeline/timeline-item.class.js +11 -7
  54. package/dist/components/data/timeline/timeline-item.styles.js +1 -1
  55. package/dist/components/data/timeline/timeline.class.d.ts +40 -5
  56. package/dist/components/data/timeline/timeline.class.js +11 -7
  57. package/dist/components/data/timeline/timeline.styles.js +1 -1
  58. package/dist/components/data/tree/tree-item.class.d.ts +2 -0
  59. package/dist/components/data/tree/tree-item.class.js +2 -2
  60. package/dist/components/data/tree/tree-item.styles.js +1 -1
  61. package/dist/components/forms/button/button.class.d.ts +13 -0
  62. package/dist/components/forms/button/button.styles.js +1 -1
  63. package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +29 -2
  64. package/dist/components/forms/checkbox-group/checkbox-group.class.js +3 -3
  65. package/dist/components/forms/checkbox-group/checkbox-group.styles.js +1 -1
  66. package/dist/components/forms/code-editor/code-editor.class.d.ts +6 -0
  67. package/dist/components/forms/color-picker/color-picker.class.d.ts +9 -0
  68. package/dist/components/forms/color-picker/color-picker.class.js +3 -3
  69. package/dist/components/forms/color-picker/color-picker.styles.js +1 -1
  70. package/dist/components/forms/combobox/combobox.class.d.ts +114 -7
  71. package/dist/components/forms/combobox/combobox.class.js +9 -7
  72. package/dist/components/forms/combobox/combobox.styles.js +1 -1
  73. package/dist/components/forms/country-picker/country-picker.class.d.ts +2 -0
  74. package/dist/components/forms/currency-picker/currency-picker.class.d.ts +2 -0
  75. package/dist/components/forms/date-picker/date-input.class.d.ts +41 -0
  76. package/dist/components/forms/date-picker/date-input.class.js +2 -2
  77. package/dist/components/forms/date-picker/date-input.styles.js +1 -1
  78. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +4 -0
  79. package/dist/components/forms/icon-button/icon-button.styles.js +1 -1
  80. package/dist/components/forms/input/input-shared.d.ts +12 -0
  81. package/dist/components/forms/input/input.styles.js +1 -1
  82. package/dist/components/forms/input/time-input.class.d.ts +6 -0
  83. package/dist/components/forms/input/time-input.styles.js +1 -1
  84. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +11 -0
  85. package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
  86. package/dist/components/forms/otp-input/otp-input.class.d.ts +6 -0
  87. package/dist/components/forms/phone-input/phone-input.class.d.ts +6 -0
  88. package/dist/components/forms/phone-input/phone-input.styles.js +1 -1
  89. package/dist/components/forms/radio/radio-group.class.d.ts +24 -2
  90. package/dist/components/forms/radio/radio-group.class.js +2 -2
  91. package/dist/components/forms/radio/radio-group.styles.js +1 -1
  92. package/dist/components/forms/rubric-form/rubric-form.class.d.ts +4 -0
  93. package/dist/components/forms/select/select.class.d.ts +13 -0
  94. package/dist/components/forms/select/select.class.js +1 -1
  95. package/dist/components/forms/select/select.styles.js +1 -1
  96. package/dist/components/forms/signature-pad/signature-pad.class.d.ts +6 -0
  97. package/dist/components/forms/signature-pad/signature-pad.styles.js +1 -1
  98. package/dist/components/forms/slider/slider.class.d.ts +28 -2
  99. package/dist/components/forms/slider/slider.class.js +3 -3
  100. package/dist/components/forms/slider/slider.styles.js +1 -1
  101. package/dist/components/forms/switch/switch.class.d.ts +2 -0
  102. package/dist/components/forms/switch/switch.styles.js +1 -1
  103. package/dist/components/forms/textarea/textarea.class.d.ts +8 -0
  104. package/dist/components/forms/textarea/textarea.styles.js +1 -1
  105. package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +2 -0
  106. package/dist/components/forms/token-input/token-input.class.d.ts +96 -18
  107. package/dist/components/forms/token-input/token-input.class.js +11 -8
  108. package/dist/components/forms/token-input/token-input.styles.js +1 -1
  109. package/dist/components/forms/unit-picker/unit-picker.class.d.ts +2 -0
  110. package/dist/components/layout/app-rail/app-rail.class.d.ts +3 -0
  111. package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
  112. package/dist/components/layout/button-group/button-group.class.d.ts +4 -0
  113. package/dist/components/layout/button-group/button-group.class.js +1 -1
  114. package/dist/components/layout/card/card.class.d.ts +15 -1
  115. package/dist/components/layout/card/card.styles.js +1 -1
  116. package/dist/components/layout/details/details.class.d.ts +6 -0
  117. package/dist/components/layout/details/details.styles.js +1 -1
  118. package/dist/components/layout/filter-bar/filter-bar.class.d.ts +6 -0
  119. package/dist/components/layout/filter-bar/filter-bar.styles.js +1 -1
  120. package/dist/components/layout/index.d.ts +1 -1
  121. package/dist/components/layout/index.js +1 -1
  122. package/dist/components/layout/menu/dropdown-item.class.d.ts +8 -2
  123. package/dist/components/layout/menu/dropdown-item.class.js +1 -1
  124. package/dist/components/layout/menu/menu-item.class.d.ts +7 -0
  125. package/dist/components/layout/menu/menu-item.styles.js +1 -1
  126. package/dist/components/layout/menu/menu-label.class.d.ts +5 -0
  127. package/dist/components/layout/menu/menu-label.class.js +1 -1
  128. package/dist/components/layout/menu/menu.class.d.ts +3 -0
  129. package/dist/components/layout/menu/menu.styles.js +1 -1
  130. package/dist/components/layout/page/page.class.d.ts +9 -1
  131. package/dist/components/layout/page/page.class.js +2 -2
  132. package/dist/components/layout/segmented/segmented.class.d.ts +22 -3
  133. package/dist/components/layout/segmented/segmented.class.js +3 -4
  134. package/dist/components/layout/segmented/segmented.styles.js +1 -1
  135. package/dist/components/layout/stepper/step.class.d.ts +89 -0
  136. package/dist/components/layout/stepper/step.class.js +18 -0
  137. package/dist/components/layout/stepper/step.styles.js +1 -0
  138. package/dist/components/layout/stepper/stepper.class.d.ts +106 -13
  139. package/dist/components/layout/stepper/stepper.class.js +6 -2
  140. package/dist/components/layout/stepper/stepper.styles.js +1 -1
  141. package/dist/components/layout/tab-group/tab-group.class.d.ts +10 -1
  142. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  143. package/dist/components/layout/tab-group/tab-group.styles.js +1 -1
  144. package/dist/components/layout/tab-group/tab-panel.class.d.ts +1 -0
  145. package/dist/components/layout/tab-group/tab-panel.class.js +1 -1
  146. package/dist/components/layout/tab-group/tab.class.d.ts +4 -0
  147. package/dist/components/layout/widget/widget.class.d.ts +1 -0
  148. package/dist/components/layout/widget/widget.styles.js +1 -1
  149. package/dist/components/lr-code-block-core.d.ts +1 -1
  150. package/dist/components/lr-code-block.d.ts +1 -1
  151. package/dist/components/lr-counter.d.ts +1 -0
  152. package/dist/components/lr-counter.js +1 -0
  153. package/dist/components/lr-lightbox-item.d.ts +1 -0
  154. package/dist/components/lr-lightbox-item.js +1 -0
  155. package/dist/components/lr-lightbox.d.ts +1 -1
  156. package/dist/components/lr-lightbox.js +1 -1
  157. package/dist/components/lr-number-ticker.d.ts +1 -0
  158. package/dist/components/lr-number-ticker.js +1 -0
  159. package/dist/components/lr-step.d.ts +1 -0
  160. package/dist/components/lr-step.js +1 -0
  161. package/dist/components/media/file-input/file-input.class.d.ts +7 -1
  162. package/dist/components/media/file-input/file-input.class.js +2 -2
  163. package/dist/components/media/file-input/file-input.styles.js +1 -1
  164. package/dist/components/media/index.d.ts +1 -1
  165. package/dist/components/media/index.js +1 -1
  166. package/dist/components/media/lightbox/lightbox-item.class.d.ts +57 -0
  167. package/dist/components/media/lightbox/lightbox-item.class.js +9 -0
  168. package/dist/components/media/lightbox/lightbox-item.styles.js +1 -0
  169. package/dist/components/media/lightbox/lightbox.class.d.ts +90 -20
  170. package/dist/components/media/lightbox/lightbox.class.js +17 -12
  171. package/dist/components/media/lightbox/lightbox.styles.js +1 -1
  172. package/dist/components/media/map/map-anchor-avoid.js +1 -1
  173. package/dist/components/media/map/map-drawing-controller.js +1 -1
  174. package/dist/components/media/map/map.class.d.ts +137 -7
  175. package/dist/components/media/map/map.class.js +6 -6
  176. package/dist/components/media/map/map.styles.js +1 -1
  177. package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +9 -0
  178. package/dist/components/media/sequence-playback/sequence-playback.class.js +2 -2
  179. package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
  180. package/dist/components/media/video/video.class.d.ts +4 -0
  181. package/dist/components/media/video/video.class.js +2 -2
  182. package/dist/components/media/video/video.styles.js +1 -1
  183. package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +15 -0
  184. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
  185. package/dist/components/overlays/badge/badge.class.d.ts +2 -0
  186. package/dist/components/overlays/badge/badge.styles.js +1 -1
  187. package/dist/components/overlays/badge/tag.class.d.ts +2 -0
  188. package/dist/components/overlays/badge/tag.class.js +1 -1
  189. package/dist/components/overlays/chip/chip-group.class.d.ts +31 -4
  190. package/dist/components/overlays/chip/chip-group.class.js +3 -3
  191. package/dist/components/overlays/context-menu/context-menu.class.d.ts +5 -0
  192. package/dist/components/overlays/context-menu/context-menu.class.js +1 -1
  193. package/dist/components/overlays/dialog/dialog.class.d.ts +36 -4
  194. package/dist/components/overlays/dialog/dialog.class.js +3 -3
  195. package/dist/components/overlays/dialog/dialog.styles.js +1 -1
  196. package/dist/components/overlays/dialog/prompt.d.ts +60 -0
  197. package/dist/components/overlays/dialog/prompt.js +1 -0
  198. package/dist/components/overlays/drawer/drawer.class.d.ts +16 -1
  199. package/dist/components/overlays/drawer/drawer.class.js +1 -1
  200. package/dist/components/overlays/empty/empty.class.d.ts +1 -0
  201. package/dist/components/overlays/empty/empty.class.js +1 -1
  202. package/dist/components/overlays/overlay/dropdown.class.d.ts +4 -0
  203. package/dist/components/overlays/overlay/dropdown.class.js +1 -1
  204. package/dist/components/overlays/overlay/overlay.styles.js +1 -1
  205. package/dist/components/overlays/overlay/popover.class.d.ts +29 -3
  206. package/dist/components/overlays/overlay/popover.class.js +2 -2
  207. package/dist/components/overlays/overlay/tooltip.class.d.ts +2 -0
  208. package/dist/components/overlays/overlay/tooltip.class.js +2 -2
  209. package/dist/components/overlays/toast/toast-item.class.d.ts +1 -0
  210. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  211. package/dist/components/overlays/toast/toast-item.styles.js +1 -1
  212. package/dist/components/overlays/toast/toast.class.d.ts +6 -0
  213. package/dist/components/overlays/toast/toast.class.js +1 -1
  214. package/dist/components/utility/copy-button/copy-button.class.d.ts +2 -0
  215. package/dist/components/utility/copy-button/copy-button.class.js +2 -2
  216. package/dist/components/utility/counter/counter-time.d.ts +15 -0
  217. package/dist/components/utility/counter/counter-time.js +1 -0
  218. package/dist/components/utility/counter/counter.class.d.ts +67 -0
  219. package/dist/components/utility/counter/counter.class.js +1 -0
  220. package/dist/components/utility/counter/counter.styles.js +1 -0
  221. package/dist/components/utility/divider/divider.class.d.ts +21 -3
  222. package/dist/components/utility/divider/divider.class.js +5 -1
  223. package/dist/components/utility/export-button/export-button.class.d.ts +5 -0
  224. package/dist/components/utility/export-button/export-button.styles.js +1 -1
  225. package/dist/components/utility/icon/icon-library.d.ts +14 -1
  226. package/dist/components/utility/icon/icon-library.js +1 -1
  227. package/dist/components/utility/icon/icon-sprite.js +1 -0
  228. package/dist/components/utility/icon/icon.class.d.ts +4 -2
  229. package/dist/components/utility/icon/icon.class.js +2 -2
  230. package/dist/components/utility/index.d.ts +1 -1
  231. package/dist/components/utility/index.js +1 -1
  232. package/dist/components/utility/known-date/known-date.class.d.ts +4 -0
  233. package/dist/components/utility/number-ticker/number-ticker.class.d.ts +58 -0
  234. package/dist/components/utility/number-ticker/number-ticker.class.js +1 -0
  235. package/dist/components/utility/number-ticker/number-ticker.styles.js +1 -0
  236. package/dist/components/viewers/include/include.class.d.ts +4 -1
  237. package/dist/components/viewers/include/include.class.js +1 -1
  238. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +10 -1
  239. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
  240. package/dist/components/viewers/pdf-viewer/pdf-viewer.styles.js +1 -1
  241. package/dist/custom-elements-jsx.d.ts +1 -1
  242. package/dist/event-classes.d.ts +2342 -0
  243. package/dist/event-classes.js +1 -0
  244. package/dist/events.d.ts +48 -22
  245. package/dist/framework-types.d.ts +2 -2
  246. package/dist/internal/all-defined-arguments.d.ts +19 -0
  247. package/dist/internal/all-defined-arguments.js +1 -0
  248. package/dist/internal/autoloader-tags.d.ts +1 -1
  249. package/dist/internal/autoloader-tags.js +1 -1
  250. package/dist/internal/checked-control-label.js +1 -1
  251. package/dist/internal/component-loaders.generated.js +1 -1
  252. package/dist/internal/dedent.js +7 -0
  253. package/dist/internal/default-strings/forms.generated.js +1 -1
  254. package/dist/internal/default-strings/layout.generated.js +1 -1
  255. package/dist/internal/dev-mode-attribute-warning.development.js +1 -1
  256. package/dist/internal/document-tokens.generated.js +3 -3
  257. package/dist/internal/form-control/chrome.styles.js +1 -1
  258. package/dist/internal/form-control.styles.js +1 -1
  259. package/dist/internal/interactive-control.styles.js +2 -2
  260. package/dist/internal/labeled-group.js +1 -1
  261. package/dist/internal/localization-runtime.d.ts +5 -0
  262. package/dist/internal/localization-runtime.js +1 -1
  263. package/dist/internal/localization-types.d.ts +1 -1
  264. package/dist/internal/localization.js +2 -2
  265. package/dist/internal/lyra-element.js +2 -2
  266. package/dist/internal/lyra-event.d.ts +22 -0
  267. package/dist/internal/lyra-event.js +1 -0
  268. package/dist/internal/overlay-shared.d.ts +5 -2
  269. package/dist/internal/overlay-shared.js +1 -1
  270. package/dist/internal/package-metadata.js +1 -1
  271. package/dist/internal/root-registration-allowlist.js +1 -1
  272. package/dist/internal/scoped-definitions.generated.js +1 -1
  273. package/dist/internal/shiki/core.d.ts +4 -1
  274. package/dist/internal/shiki/tokenize.js +1 -1
  275. package/dist/internal/srcset.js +1 -0
  276. package/dist/lyra.d.ts +1 -1
  277. package/dist/lyra.js +1 -1
  278. package/dist/ssr/all.d.ts +1 -1
  279. package/dist/ssr/all.js +1 -1
  280. package/dist/ssr.d.ts +5 -5
  281. package/dist/ssr.js +1 -1
  282. package/dist/styles/native.css +1 -1
  283. package/dist/styles/palette.css +1 -0
  284. package/dist/styles/tokens-root.css +1 -1
  285. package/dist/styles/utilities.css +1 -1
  286. package/dist/svelte.d.ts +1 -1
  287. package/dist/testing/happy-dom-shims.d.ts +11 -2
  288. package/dist/testing/happy-dom-shims.js +1 -1
  289. package/dist/testing/index.d.ts +1 -1
  290. package/dist/testing/index.js +1 -1
  291. package/dist/testing/lyra-tag-event-map.d.ts +2 -2
  292. package/dist/testing/lyra-tag-event-map.js +1 -1
  293. package/dist/theme-core.css +1 -1
  294. package/dist/theme.css +1 -1
  295. package/dist/utilities/defined.d.ts +10 -1
  296. package/dist/utilities/defined.js +1 -1
  297. package/dist/utilities/form.d.ts +9 -0
  298. package/dist/utilities/form.js +1 -0
  299. package/dist/utilities/index.d.ts +1 -1
  300. package/dist/utilities/index.js +1 -1
  301. package/dist/vue.d.ts +1 -1
  302. package/llms/components/lr-app-rail.md +4 -2
  303. package/llms/components/lr-badge.md +4 -4
  304. package/llms/components/lr-bar-chart.md +1 -1
  305. package/llms/components/lr-box-plot.md +6 -1
  306. package/llms/components/lr-bubble-chart.md +1 -1
  307. package/llms/components/lr-budget-meter.md +2 -2
  308. package/llms/components/lr-button-group.md +7 -3
  309. package/llms/components/lr-button.md +11 -1
  310. package/llms/components/lr-card.md +11 -1
  311. package/llms/components/lr-chart.md +21 -7
  312. package/llms/components/lr-checkbox-group.md +11 -1
  313. package/llms/components/lr-chip.md +11 -1
  314. package/llms/components/lr-code-block-core.md +36 -8
  315. package/llms/components/lr-code-block.md +45 -6
  316. package/llms/components/lr-code-editor.md +11 -1
  317. package/llms/components/lr-color-picker.md +17 -4
  318. package/llms/components/lr-combobox.md +62 -6
  319. package/llms/components/lr-context-menu.md +5 -3
  320. package/llms/components/lr-copy-button.md +2 -1
  321. package/llms/components/lr-counter.md +60 -0
  322. package/llms/components/lr-country-picker.md +5 -1
  323. package/llms/components/lr-currency-picker.md +5 -1
  324. package/llms/components/lr-date-input.md +1 -1
  325. package/llms/components/lr-date-picker.md +25 -1
  326. package/llms/components/lr-details.md +6 -2
  327. package/llms/components/lr-dialog.md +72 -8
  328. package/llms/components/lr-divider.md +14 -5
  329. package/llms/components/lr-doughnut-chart.md +1 -1
  330. package/llms/components/lr-drawer.md +26 -7
  331. package/llms/components/lr-dropdown-item.md +1 -1
  332. package/llms/components/lr-dropdown.md +8 -4
  333. package/llms/components/lr-emoji-picker.md +10 -1
  334. package/llms/components/lr-empty.md +3 -2
  335. package/llms/components/lr-export-button.md +5 -2
  336. package/llms/components/lr-file-input.md +13 -1
  337. package/llms/components/lr-filter-bar.md +6 -2
  338. package/llms/components/lr-graph-query-builder.md +10 -1
  339. package/llms/components/lr-heatmap.md +20 -3
  340. package/llms/components/lr-histogram.md +7 -2
  341. package/llms/components/lr-icon-button.md +3 -1
  342. package/llms/components/lr-icon.md +8 -0
  343. package/llms/components/lr-include.md +3 -0
  344. package/llms/components/lr-input.md +9 -1
  345. package/llms/components/lr-known-date.md +10 -1
  346. package/llms/components/lr-lightbox-item.md +14 -0
  347. package/llms/components/lr-lightbox.md +84 -5
  348. package/llms/components/lr-line-chart.md +7 -2
  349. package/llms/components/lr-lite-chart.md +3 -2
  350. package/llms/components/lr-locale-picker.md +17 -1
  351. package/llms/components/lr-map.md +122 -11
  352. package/llms/components/lr-markdown-core.md +15 -4
  353. package/llms/components/lr-markdown.md +13 -4
  354. package/llms/components/lr-menu-item.md +1 -1
  355. package/llms/components/lr-menu-label.md +5 -2
  356. package/llms/components/lr-menu.md +21 -6
  357. package/llms/components/lr-model-select.md +11 -1
  358. package/llms/components/lr-native-time-input.md +11 -1
  359. package/llms/components/lr-number-input.md +11 -1
  360. package/llms/components/lr-number-ticker.md +55 -0
  361. package/llms/components/lr-otp-input.md +11 -1
  362. package/llms/components/lr-page.md +7 -1
  363. package/llms/components/lr-pagination.md +18 -0
  364. package/llms/components/lr-pdf-viewer.md +6 -1
  365. package/llms/components/lr-phone-input.md +11 -1
  366. package/llms/components/lr-pie-chart.md +1 -1
  367. package/llms/components/lr-polar-area-chart.md +1 -1
  368. package/llms/components/lr-popover.md +25 -5
  369. package/llms/components/lr-radar-chart.md +1 -1
  370. package/llms/components/lr-radio-group.md +11 -1
  371. package/llms/components/lr-rubric-form.md +7 -1
  372. package/llms/components/lr-scatter-chart.md +1 -1
  373. package/llms/components/lr-segmented.md +20 -2
  374. package/llms/components/lr-select.md +10 -2
  375. package/llms/components/lr-sequence-playback.md +8 -2
  376. package/llms/components/lr-signature-pad.md +8 -1
  377. package/llms/components/lr-slider.md +17 -4
  378. package/llms/components/lr-stat.md +20 -5
  379. package/llms/components/lr-step.md +61 -0
  380. package/llms/components/lr-stepper.md +64 -8
  381. package/llms/components/lr-suggestion-chips.md +3 -2
  382. package/llms/components/lr-switch.md +4 -3
  383. package/llms/components/lr-tab-group.md +10 -3
  384. package/llms/components/lr-tab-panel.md +2 -2
  385. package/llms/components/lr-table.md +87 -8
  386. package/llms/components/lr-tag.md +1 -1
  387. package/llms/components/lr-textarea.md +17 -1
  388. package/llms/components/lr-thread-list.md +4 -2
  389. package/llms/components/lr-time-input.md +8 -1
  390. package/llms/components/lr-time-zone-picker.md +5 -1
  391. package/llms/components/lr-timeline-item.md +1 -1
  392. package/llms/components/lr-timeline.md +38 -1
  393. package/llms/components/lr-toast-item.md +1 -1
  394. package/llms/components/lr-toast.md +7 -2
  395. package/llms/components/lr-token-input.md +64 -8
  396. package/llms/components/lr-tooltip.md +3 -3
  397. package/llms/components/lr-tree-item.md +1 -1
  398. package/llms/components/lr-tree.md +2 -1
  399. package/llms/components/lr-unit-picker.md +5 -1
  400. package/llms/components/lr-video.md +5 -4
  401. package/llms/components/lr-voice-picker.md +8 -1
  402. package/llms/components/lr-widget.md +2 -2
  403. package/llms/components/lr-zoomable-frame.md +8 -0
  404. package/llms/index.md +145 -141
  405. package/llms/migration.md +20 -12
  406. package/llms/peers.md +2 -2
  407. package/llms/shared/events-and-types.md +36 -0
  408. package/llms/shared/imports-and-registration.md +60 -1
  409. package/llms/shared/native-styles-and-utilities.md +109 -3
  410. package/llms/shared/styles-and-tokens.md +2 -2
  411. package/llms/shared/testing-and-utilities.md +21 -0
  412. package/llms/shared.md +227 -6
  413. package/llms/tokens.md +6 -1
  414. package/llms.txt +3 -3
  415. package/locales.json +1 -1
  416. package/package.json +38 -9
  417. package/registrations.json +1 -1
  418. package/skills/compose-lyra-interfaces/SKILL.md +1 -1
  419. package/skills/lyra-ui/SKILL.md +1 -1
@@ -1,3 +1,3 @@
1
- import{__decorate}from"tslib";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{composedAccessibilityText,isAccessibilitySubtreeExcluded}from"../../../internal/accessibility-visibility.js";import{applyComposedFocusRepair,captureComposedFocusRepair,nearestExternalFocusTarget,repairComposedFocus}from"../../../internal/focus-navigation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{closeIcon}from"../../../internal/icons.js";import{variants}from"../../../internal/variants.styles.js";import{LyraBadge}from"./badge.class.js";import{styles as badgeStyles}from"./badge.styles.js";import{styles as tagStyles}from"./tag.styles.js";import{LYRA_DEFAULT_remove,LYRA_DEFAULT_removeWithContext}from"../../../internal/default-strings/shared.generated.js";function sourceParent(node){if(node.parentElement)return node.parentElement;const root=node.getRootNode();return"host"in root?root.host:null}function isClosedSourceDetailsBranch(details,branch){return details.localName!=="details"||details.hasAttribute("open")||branch===null?!1:Array.from(details.children).find(child=>child.localName==="summary")!==branch}function isSourceLabelAvailable(node){const target=node.nodeType===1?node:sourceParent(node);if(!target?.isConnected)return!1;let branch=target,current=sourceParent(target);if(isAccessibilitySubtreeExcluded(target))return!1;for(;current;){if(isAccessibilitySubtreeExcluded(current)||isClosedSourceDetailsBranch(current,branch))return!1;branch=current,current=sourceParent(current)}return!0}class LyraTag extends LyraBadge{constructor(){super(...arguments),this.disabled=!1,this.removeEnabled=!1,this.changingRemoveAliasAttribute=!1,this.labelTextObserver=new AccessibleTextController(this,[""],()=>{this.syncHostActionRole(),this.updateBrowserDerivedState(()=>this.recomputeLabelText())},["slot","role"],!1),this.managedActionGroupRole=!1,this.labelText="",this.onLabelSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||(this.labelTextObserver.bind(),this.withRemove&&this.updateBrowserDerivedState(()=>this.recomputeLabelText()))},this.onRemoveClick=()=>{if(!this.withRemove||this.disabled)return;const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));this.emit("lr-remove",{value:this.value}),repair&&(!this.isConnected||!this.withRemove)&&applyComposedFocusRepair(repair)}}static{this.defaultStrings={...super.defaultStrings,remove:LYRA_DEFAULT_remove,removeWithContext:LYRA_DEFAULT_removeWithContext}}static{this.styles=[LyraElement.styles,variants,badgeStyles,tagStyles]}static{this.properties={withRemove:{attribute:"with-remove",type:Boolean,noAccessor:!0},removable:{attribute:"removable",type:Boolean,noAccessor:!0}}}get effectiveVariant(){return this.variant==="text"?"neutral":super.effectiveVariant}get withRemove(){return this.removeEnabled}set withRemove(next){this.setRemoveEnabled(!!next,"with-remove")}get removable(){return this.removeEnabled}set removable(next){this.setRemoveEnabled(!!next,"removable")}attributeChangedCallback(name,oldValue,value){const isRemoveAlias=name==="with-remove"||name==="removable";isRemoveAlias&&(this.changingRemoveAliasAttribute=!0);try{super.attributeChangedCallback(name,oldValue,value)}finally{isRemoveAlias&&(this.changingRemoveAliasAttribute=!1)}}setRemoveEnabled(next,preferredAttribute){const old=this.removeEnabled;this.changingRemoveAliasAttribute?this.removeEnabled=this.hasAttribute("with-remove")||this.hasAttribute("removable"):next?(this.setAttribute(preferredAttribute,""),this.removeEnabled=!0):(this.removeAttribute("with-remove"),this.removeAttribute("removable"),this.removeEnabled=!1),old!==this.removeEnabled&&(this.requestUpdate("withRemove",old),this.requestUpdate("removable",old))}connectedCallback(){super.connectedCallback(),this.addEventListener("slotchange",this.onLabelSlotChange),this.syncLabelObserver(),this.hasUpdated?(this.withRemove&&this.recomputeLabelText(!0),this.ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.withRemove&&this.recomputeLabelText()})):this.seedFirstRenderState(()=>this.recomputeLabelText(!0))}disconnectedCallback(){this.removeEventListener("slotchange",this.onLabelSlotChange),this.releaseHostActionRole(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}syncLabelObserver(){this.labelTextObserver.setEnabled(this.withRemove)}recomputeLabelText(preferLightDom=!1){const slot=this.renderRoot?.querySelector("slot:not([name])"),lightDomNodes=this.childNodes,nodes=slot?slot.assignedNodes({flatten:!0}):Array.from(lightDomNodes??[]).filter(node=>{if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName!=="start"&&slotName!=="end"});this.labelText=nodes.map(node=>composedAccessibilityText(node,{ancestorBoundary:this,isSubtreeExcluded:element=>element.getRootNode()===this.renderRoot&&element.getAttribute("part")?.split(/\s+/).includes("content")?!1:isAccessibilitySubtreeExcluded(element),requireRendered:preferLightDom?!1:node.nodeType!==1||node.localName!=="slot",shouldPruneNode:candidate=>!this.contains(candidate)&&!isSourceLabelAvailable(candidate),ignoreInheritedVisibility:!0})).join(" ").replace(/\s+/g," ").trim()}get accessibleRemoveLabel(){const text=this.labelText;return text?this.localize("removeWithContext",void 0,{label:text}):this.localize("remove")}focus(options){this.deferFocusUntilRendered(options)||this.withRemove&&this.removeButtonEl?.focus(options)}blur(){this.removeButtonEl?.blur()}click(){if(!this.withRemove){super.click();return}this.removeButtonEl?.click()}willUpdate(changed){if(super.willUpdate(changed),changed.has("withRemove")&&!this.withRemove||changed.has("disabled")&&this.disabled){const button=this.removeButtonEl;button&&repairComposedFocus(button,()=>[nearestExternalFocusTarget(this)])}changed.has("withRemove")&&(this.syncLabelObserver(),this.withRemove&&this.hasUpdated&&this.recomputeLabelText())}updated(changed){super.updated(changed),this.syncHostActionRole()}syncHostActionRole(){const needsGroup=this.withRemove&&this.hasAttribute("aria-label");needsGroup&&!this.hasAttribute("role")?(this.setAttribute("role","group"),this.managedActionGroupRole=!0):needsGroup||this.releaseHostActionRole()}releaseHostActionRole(){this.managedActionGroupRole&&this.getAttribute("role")==="group"&&this.removeAttribute("role"),this.managedActionGroupRole=!1}renderTrailing(){return this.withRemove?html`<button part="remove-button remove-button__base" type="button" ?disabled=${this.disabled} aria-label=${this.accessibleRemoveLabel} @click=${this.onRemoveClick} >
1
+ import{__decorate}from"tslib";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{composedAccessibilityText,isAccessibilitySubtreeExcluded}from"../../../internal/accessibility-visibility.js";import{applyComposedFocusRepair,captureComposedFocusRepair,nearestExternalFocusTarget,repairComposedFocus}from"../../../internal/focus-navigation.js";import{LyraElement}from"../../../internal/lyra-element.js";import{closeIcon}from"../../../internal/icons.js";import{variants}from"../../../internal/variants.styles.js";import{LyraBadge}from"./badge.class.js";import{styles as badgeStyles}from"./badge.styles.js";import{styles as tagStyles}from"./tag.styles.js";import{LYRA_DEFAULT_remove,LYRA_DEFAULT_removeWithContext}from"../../../internal/default-strings/shared.generated.js";function sourceParent(node){if(node.parentElement)return node.parentElement;const root=node.getRootNode();return"host"in root?root.host:null}function isClosedSourceDetailsBranch(details,branch){return details.localName!=="details"||details.hasAttribute("open")||branch===null?!1:Array.from(details.children).find(child=>child.localName==="summary")!==branch}function isSourceLabelAvailable(node){const target=node.nodeType===1?node:sourceParent(node);if(!target?.isConnected)return!1;let branch=target,current=sourceParent(target);if(isAccessibilitySubtreeExcluded(target))return!1;for(;current;){if(isAccessibilitySubtreeExcluded(current)||isClosedSourceDetailsBranch(current,branch))return!1;branch=current,current=sourceParent(current)}return!0}class LyraTag extends LyraBadge{constructor(){super(...arguments),this.disabled=!1,this.removeEnabled=!1,this.changingRemoveAliasAttribute=!1,this.labelTextObserver=new AccessibleTextController(this,[""],()=>{this.syncHostActionRole(),this.updateBrowserDerivedState(()=>this.recomputeLabelText())},["slot","role"],!1),this.managedActionGroupRole=!1,this.labelText="",this.onLabelSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||(this.labelTextObserver.bind(),this.withRemove&&this.updateBrowserDerivedState(()=>this.recomputeLabelText()))},this.onRemoveClick=()=>{if(!this.withRemove||this.disabled)return;const repair=captureComposedFocusRepair(this,()=>nearestExternalFocusTarget(this));this.emit("lr-remove",{value:this.value}),repair&&(!this.isConnected||!this.withRemove)&&applyComposedFocusRepair(repair)}}static{this.defaultStrings={...super.defaultStrings,remove:LYRA_DEFAULT_remove,removeWithContext:LYRA_DEFAULT_removeWithContext}}static{this.styles=[LyraElement.styles,variants,badgeStyles,tagStyles]}static{this.properties={withRemove:{attribute:"with-remove",type:Boolean,noAccessor:!0},removable:{attribute:"removable",type:Boolean,noAccessor:!0}}}get effectiveVariant(){return this.variant==="text"?"neutral":super.effectiveVariant}get withRemove(){return this.removeEnabled}set withRemove(next){this.setRemoveEnabled(!!next,"with-remove")}get removable(){return this.removeEnabled}set removable(next){this.setRemoveEnabled(!!next,"removable")}attributeChangedCallback(name,oldValue,value){const isRemoveAlias=name==="with-remove"||name==="removable";isRemoveAlias&&(this.changingRemoveAliasAttribute=!0);try{super.attributeChangedCallback(name,oldValue,value)}finally{isRemoveAlias&&(this.changingRemoveAliasAttribute=!1)}}setRemoveEnabled(next,preferredAttribute){const old=this.removeEnabled;this.changingRemoveAliasAttribute?this.removeEnabled=this.hasAttribute("with-remove")||this.hasAttribute("removable"):next?(this.setAttribute(preferredAttribute,""),this.removeEnabled=!0):(this.removeAttribute("with-remove"),this.removeAttribute("removable"),this.removeEnabled=!1),old!==this.removeEnabled&&(this.requestUpdate("withRemove",old),this.requestUpdate("removable",old))}connectedCallback(){super.connectedCallback(),this.addEventListener("slotchange",this.onLabelSlotChange),this.syncLabelObserver(),this.hasUpdated?(this.withRemove&&this.recomputeLabelText(!0),this.ownerDocument.defaultView?.queueMicrotask(()=>{this.isConnected&&this.withRemove&&this.recomputeLabelText()})):this.seedFirstRenderState(()=>this.recomputeLabelText(!0))}disconnectedCallback(){this.removeEventListener("slotchange",this.onLabelSlotChange),this.releaseHostActionRole(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}syncLabelObserver(){this.labelTextObserver.setEnabled(this.withRemove)}recomputeLabelText(preferLightDom=!1){const slot=this.renderRoot?.querySelector("slot:not([name])"),lightDomNodes=this.childNodes,nodes=slot?slot.assignedNodes({flatten:!0}):Array.from(lightDomNodes??[]).filter(node=>{if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName!=="start"&&slotName!=="end"});this.labelText=nodes.map(node=>composedAccessibilityText(node,{ancestorBoundary:this,isSubtreeExcluded:element=>element.getRootNode()===this.renderRoot&&element.getAttribute("part")?.split(/\s+/).includes("content")?!1:isAccessibilitySubtreeExcluded(element),requireRendered:preferLightDom?!1:node.nodeType!==1||node.localName!=="slot",shouldPruneNode:candidate=>!this.contains(candidate)&&!isSourceLabelAvailable(candidate),ignoreInheritedVisibility:!0})).join(" ").replace(/\s+/g," ").trim()}get accessibleRemoveLabel(){const text=this.labelText;return text?this.localize("removeWithContext",void 0,{label:text}):this.localize("remove")}focus(options){this.deferFocusUntilRendered(options)||this.withRemove&&this.removeButtonEl?.focus(options)}blur(){this.removeButtonEl?.blur()}click(){if(!this.withRemove){super.click();return}this.removeButtonEl?.click()}willUpdate(changed){if(super.willUpdate(changed),changed.has("withRemove")&&!this.withRemove||changed.has("disabled")&&this.disabled){const button=this.removeButtonEl;button&&repairComposedFocus(button,()=>[nearestExternalFocusTarget(this)])}changed.has("withRemove")&&(this.syncLabelObserver(),this.withRemove&&this.hasUpdated&&this.recomputeLabelText())}updated(changed){super.updated(changed),this.syncHostActionRole()}syncHostActionRole(){const needsGroup=this.withRemove&&this.hasAttribute("aria-label");needsGroup&&!this.hasAttribute("role")?(this.setAttribute("role","group"),this.managedActionGroupRole=!0):needsGroup||this.releaseHostActionRole()}releaseHostActionRole(){this.managedActionGroupRole&&this.getAttribute("role")==="group"&&this.removeAttribute("role"),this.managedActionGroupRole=!1}renderTrailing(){return this.withRemove?html`<button part="remove-button remove-button__base remove-button__button" type="button" ?disabled=${this.disabled} aria-label=${this.accessibleRemoveLabel} @click=${this.onRemoveClick} >
2
2
  ${closeIcon()}
3
3
  </button>`:nothing}}__decorate([property()],LyraTag.prototype,"value",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraTag.prototype,"disabled",void 0),__decorate([state()],LyraTag.prototype,"labelText",void 0),__decorate([query('[part~="remove-button"]')],LyraTag.prototype,"removeButtonEl",void 0);export{LyraTag};
@@ -1,4 +1,8 @@
1
- import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';export interface ChipGroupOverflowToggleDetail{expanded:boolean;}export interface LyraChipGroupEventMap{'lr-overflow-toggle':CustomEvent<ChipGroupOverflowToggleDetail>;}
1
+ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';export interface ChipGroupOverflowToggleDetail{expanded:boolean;}
2
+ /** How a chip group manages its toggleable chips: `none` (default) leaves them alone.*/
3
+ export type LyraChipGroupSelection='none'|'single'|'multiple';export interface ChipGroupChangeDetail{
4
+ /** The new selection: a string (empty when nothing is selected) in `single`, an array in `multiple`.*/
5
+ value:string|string[];}export interface LyraChipGroupEventMap{'lr-overflow-toggle':CustomEvent<ChipGroupOverflowToggleDetail>;'lr-change':CustomEvent<ChipGroupChangeDetail>;}
2
6
  /**
3
7
  * `<lr-chip-group>` — a flex-wrap container for a set of `<lr-chip>`
4
8
  * children (plain light-DOM composition — direct children are the chips,
@@ -24,11 +28,24 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from
24
28
  *
25
29
  * Collapsed groups reapply max-visible when assigned children are replaced or reordered at the same count, preserving authored hidden/inert state and releasing departed visibility leases.
26
30
  *
31
+ * An opt-in selection model turns the group into a filter bar. `selection="single"` or `"multiple"`
32
+ * makes the group own the pressed state of every direct `<lr-chip>` child that has a `value`: it
33
+ * sets them `toggleable`, presses the ones named by `value`, and, in `single`, releases the others
34
+ * when one is pressed. Pressing a pressed chip releases it, so the selection may be empty. A chip
35
+ * without a `value` is left alone. `value` is a string in `single` and an array in `multiple`; as an
36
+ * attribute it is the string, comma-separated in `multiple`. An unknown value is kept (it simply
37
+ * presses no chip). Setting `value` is silent; `lr-change` fires only from a user press.
38
+ * `all-value` names an optional "all" chip, the child whose `value` equals it: it is pressed while
39
+ * the selection is empty, pressing it clears the selection, and it cannot be un-pressed. It is never
40
+ * part of `value`. With `selection` unset the group behaves exactly as before.
41
+ *
27
42
  * @customElement lr-chip-group
28
43
  * @slot - `<lr-chip>` elements (or any content, though the chip pairing is
29
44
  * the intended usage).
30
45
  * @event lr-overflow-toggle - The overflow indicator was activated,
31
46
  * revealing or re-collapsing the excess children. `detail: { expanded }`.
47
+ * @event lr-change - A user press changed the selection (`selection` is `single` or `multiple`).
48
+ * `detail: { value }`.
32
49
  * @csspart base - The flex-wrap container (holds both the slot and the overflow indicator).
33
50
  * Carries `role="group"` and the accessible name when one is supplied -- see `accessibleLabel`.
34
51
  * @csspart overflow-indicator - The "+N" / "Show less" toggle button. Only rendered while `max-visible` is actively causing an overflow.
@@ -55,14 +72,24 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from
55
72
  * @status stable
56
73
  * @since 4.0.0
57
74
  */
58
- export declare class LyraChipGroup extends LyraElement<LyraChipGroupEventMap>{static styles:import("lit").CSSResultGroup[];private _maxVisible?;
75
+ export declare class LyraChipGroup extends LyraElement<LyraChipGroupEventMap>{protected static collectionSupport:import("../../../internal/lyra-element.js").LyraCollectionSupport;protected static readonly immutableEventDetails:readonly string[];static styles:import("lit").CSSResultGroup[];private _maxVisible?;
59
76
  /** Maximum number of assigned children shown before the rest collapse behind a "+N"
60
77
  * indicator. Flattened slot-forwarded children count the same as direct light-DOM children.
61
78
  * Unset (the default) means no limit — every child is always shown. Any explicitly assigned
62
79
  * value is sanitized to a finite, non-negative integer via `finiteCount` — this feeds the
63
80
  * `hasOverflow`/`syncChildVisibility` index comparisons below directly, so a NaN/negative value
64
81
  * must never reach them. */
65
- get maxVisible():number|undefined;set maxVisible(next:number|undefined|null);
82
+ get maxVisible():number|undefined;set maxVisible(next:number|undefined|null);private _selection;
83
+ /** `none` (default): the group does not manage chip state. `single` allows zero or one pressed
84
+ * chip, `multiple` any number. Unsupported values fall back to `none`. */
85
+ get selection():LyraChipGroupSelection;set selection(next:LyraChipGroupSelection);private selectedValues;private rawValue;private parseSelection;
86
+ /** The pressed chips' values: a string in `single` (empty when none), an array otherwise. In
87
+ * `single` an array assignment keeps its first entry; in `multiple` a string is read as a
88
+ * comma-separated list. `null`/`undefined` clears. Silent: never fires `lr-change`.
89
+ * @default '' */
90
+ get value():string|string[];set value(next:string|readonly string[]|null|undefined);
91
+ /** The `value` of the optional "all" chip (selection mode only). Unset means no all chip.*/
92
+ allValue?:string;
66
93
  /**
67
94
  * Accessible name for the group, forwarded to `[part="base"]`.
68
95
  *
@@ -77,4 +104,4 @@ get maxVisible():number|undefined;set maxVisible(next:number|undefined|null);
77
104
  * verbosity without adding information, and applying it unconditionally would change the
78
105
  * accessibility tree of every decorative chip row already shipped.
79
106
  */
80
- accessibleLabel:string;private childCount;private expanded;private readonly authorHidden;private readonly observedChildren;private readonly pendingHiddenWrites;private visibilityObserver?;private visibilityObserverDocument?;private trackedChipFocus?;private overflowFocusRepair?;connectedCallback():void;private armVisibilityObserver;protected willUpdate(changed:PropertyValues<this>):void;firstUpdated(changed:PropertyValues<this>):void;protected updated(changed:PropertyValues<this>):void;disconnectedCallback():void;adoptedCallback():void;private resetVisibilityObserver;private get hasOverflow();private assignedChildren;private isAuthorHidden;private isCapacityEligible;private eligibleChildren;private childWillBeVisible;private focusRepairBeforeVisibility;private focusTargetAfterVisibility;private reconcileChildVisibilityAndFocus;private syncChildVisibility;private observeChildren;private drainVisibilityRecords;private processHiddenMutations;private recordHiddenWrite;private setManagedHidden;private restoreChildVisibility;private onSlotChange;private onFocusIn;private onFocusOut;private onToggleOverflow;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-chip-group':LyraChipGroup;}}
107
+ accessibleLabel:string;private childCount;private expanded;private readonly authorHidden;private readonly observedChildren;private readonly pendingHiddenWrites;private visibilityObserver?;private visibilityObserverDocument?;private trackedChipFocus?;private overflowFocusRepair?;connectedCallback():void;private armVisibilityObserver;protected willUpdate(changed:PropertyValues<this>):void;firstUpdated(changed:PropertyValues<this>):void;protected updated(changed:PropertyValues<this>):void;disconnectedCallback():void;adoptedCallback():void;private resetVisibilityObserver;private get hasOverflow();private assignedChildren;private isAuthorHidden;private isCapacityEligible;private eligibleChildren;private childWillBeVisible;private focusRepairBeforeVisibility;private focusTargetAfterVisibility;private reconcileChildVisibilityAndFocus;private syncChildVisibility;private observeChildren;private drainVisibilityRecords;private processHiddenMutations;private recordHiddenWrite;private setManagedHidden;private restoreChildVisibility;private onSlotChange;private onFocusIn;private onFocusOut;private managedChips;private isAllChip;private syncSelectedChips;private onChipToggleRequest;private onChipChange;private onToggleOverflow;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-chip-group':LyraChipGroup;}}
@@ -1,8 +1,8 @@
1
- import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteCount}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{applyComposedFocusRepair,captureComposedFocusRepair,collectComposedFocusTargets}from"../../../internal/focus-navigation.js";import{composedContains}from"../../../internal/overlay-manager.js";import{styles}from"./chip-group.styles.js";import{blankNumberConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_showLess,LYRA_DEFAULT_showMoreCollapsed,LYRA_DEFAULT_showMoreOverflowLabel}from"../../../internal/default-strings/shared.generated.js";class LyraChipGroup extends LyraElement{constructor(){super(...arguments),this.accessibleLabel="",this.childCount=0,this.expanded=!1,this.authorHidden=new Map,this.observedChildren=new Set,this.pendingHiddenWrites=new Map,this.onSlotChange=e=>{const slot=e.target;this.updateBrowserDerivedState(()=>{this.isConnected&&(this.childCount=slot.assignedElements({flatten:!0}).length,this.requestUpdate())})},this.onFocusIn=()=>{const active=deepActiveElementIn(this.ownerDocument),children=this.assignedChildren(),index=children.findIndex(child2=>composedContains(child2,active)),base=this.renderRoot.querySelector('[part="base"]');if(index<0||!base){this.trackedChipFocus=void 0;return}const child=children[index];if(!("focus"in child)){this.trackedChipFocus=void 0;return}const repair=captureComposedFocusRepair(child,base);this.trackedChipFocus=repair?{child,index,repair}:void 0},this.onFocusOut=()=>{const tracked=this.trackedChipFocus;tracked&&queueMicrotask(()=>{if(this.trackedChipFocus!==tracked)return;const active=deepActiveElementIn(this.ownerDocument);if(active!==null&&composedContains(tracked.child,active))return;!tracked.child.isConnected&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement)||(this.trackedChipFocus=void 0)})},this.onToggleOverflow=()=>{this.expanded=!this.expanded,this.emit("lr-overflow-toggle",{expanded:this.expanded})}}static{this.defaultStrings={...super.defaultStrings,showLess:LYRA_DEFAULT_showLess,showMoreCollapsed:LYRA_DEFAULT_showMoreCollapsed,showMoreOverflowLabel:LYRA_DEFAULT_showMoreOverflowLabel}}static{this.styles=[LyraElement.styles,styles]}get maxVisible(){return this._maxVisible}set maxVisible(next){const old=this._maxVisible;this._maxVisible=next==null?void 0:finiteCount(next),this.requestUpdate("maxVisible",old)}connectedCallback(){super.connectedCallback(),this.armVisibilityObserver(),this.hasUpdated&&this.reconcileChildVisibilityAndFocus()}armVisibilityObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.visibilityObserver&&this.visibilityObserverDocument===ownerDocument)return;this.resetVisibilityObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const observer=new MutationObserverCtor(records=>{this.processHiddenMutations(records)&&(this.reconcileChildVisibilityAndFocus(),this.requestUpdate())});this.visibilityObserver=observer,this.visibilityObserverDocument=ownerDocument}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||this.seedFirstRenderState(()=>{this.childCount=this.children.length}),!this.hasOverflow){this.expanded=!1;const disclosure=this.shadowRoot?.querySelector('[part="overflow-indicator"]');disclosure&&(this.overflowFocusRepair=captureComposedFocusRepair(disclosure,disclosure)??void 0)}}firstUpdated(changed){super.firstUpdated(changed);const slot=this.shadowRoot.querySelector("slot");queueMicrotask(()=>{this.isConnected&&this.updateBrowserDerivedState(()=>{this.childCount=slot.assignedElements({flatten:!0}).length})})}updated(changed){super.updated(changed);const overflowRepair=this.overflowFocusRepair;this.overflowFocusRepair=void 0,this.reconcileChildVisibilityAndFocus(overflowRepair)}disconnectedCallback(){this.resetVisibilityObserver(),this.observedChildren.clear(),this.pendingHiddenWrites.clear(),this.trackedChipFocus=void 0,this.restoreChildVisibility(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetVisibilityObserver(),this.observedChildren.clear(),this.pendingHiddenWrites.clear(),this.trackedChipFocus=void 0}resetVisibilityObserver(){this.drainVisibilityRecords(),this.visibilityObserver?.disconnect(),this.visibilityObserver=void 0,this.visibilityObserverDocument=void 0}get hasOverflow(){const max=this.maxVisible;return max!=null&&this.childCount>0&&this.eligibleChildren().length>max}assignedChildren(){return this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:!0})??Array.from(this.children)}isAuthorHidden(child){return this.authorHidden.get(child)??child.hasAttribute("hidden")}isCapacityEligible(child){return!this.isAuthorHidden(child)&&!child.hasAttribute("inert")}eligibleChildren(children=this.assignedChildren()){return children.filter(child=>this.isCapacityEligible(child))}childWillBeVisible(child,assignedChildren){if(!this.isCapacityEligible(child))return!this.isAuthorHidden(child);const eligibleIndex=this.eligibleChildren(assignedChildren).indexOf(child);return!(this.hasOverflow&&!this.expanded&&eligibleIndex>=this.maxVisible)}focusRepairBeforeVisibility(assignedChildren){const tracked=this.trackedChipFocus;if(!tracked)return null;const currentIndex=assignedChildren.indexOf(tracked.child);if(currentIndex>=0&&this.childWillBeVisible(tracked.child,assignedChildren))return tracked.index=currentIndex,null;const active=deepActiveElementIn(this.ownerDocument),stillOwnsFocus=active!==null&&composedContains(tracked.child,active),focusWasLostWithRemovedBranch=currentIndex<0&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement),focusWasLostWithAlreadyHiddenBranch=tracked.child.hasAttribute("hidden")&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement);return!stillOwnsFocus&&!focusWasLostWithRemovedBranch&&!focusWasLostWithAlreadyHiddenBranch?null:{index:currentIndex>=0?currentIndex:tracked.index,repair:tracked.repair}}focusTargetAfterVisibility(assignedChildren,originIndex){const chipTargets=assignedChildren.map((child,index)=>({index,target:collectComposedFocusTargets(child,{includeRoot:!1,mode:"programmatic"}).elements[0]})).filter(entry=>entry.target!==void 0).sort((first,second)=>Math.abs(first.index-originIndex)-Math.abs(second.index-originIndex)||first.index-second.index);if(chipTargets[0])return chipTargets[0].target;const disclosure=this.renderRoot.querySelector('[part="overflow-indicator"]');if(disclosure){const available=collectComposedFocusTargets(disclosure,{mode:"programmatic"}).elements[0];if(available)return available}const base=this.renderRoot.querySelector('[part="base"]');return base?collectComposedFocusTargets(base,{mode:"programmatic"}).elements.find(target=>target===base)??null:null}reconcileChildVisibilityAndFocus(overflowRepair){const assignedChildren=this.assignedChildren(),focusRepair=overflowRepair?{index:assignedChildren.length,repair:overflowRepair}:this.focusRepairBeforeVisibility(assignedChildren);if(this.syncChildVisibility(assignedChildren),!focusRepair)return;const candidate=this.focusTargetAfterVisibility(assignedChildren,focusRepair.index);this.trackedChipFocus=void 0,candidate&&applyComposedFocusRepair(focusRepair.repair,candidate)}syncChildVisibility(assignedChildren=this.assignedChildren()){const max=this.maxVisible,overflowing=this.hasOverflow;this.observeChildren(assignedChildren);const current=new Set(assignedChildren);for(const[child,hidden]of this.authorHidden)current.has(child)||(child.toggleAttribute("hidden",hidden),this.authorHidden.delete(child));let eligibleIndex=0;assignedChildren.forEach(element=>{this.authorHidden.has(element)||this.authorHidden.set(element,element.hasAttribute("hidden"));const authored=this.authorHidden.get(element)??!1,eligible=!authored&&!element.hasAttribute("inert"),managed=eligible&&overflowing&&!this.expanded&&eligibleIndex>=max;this.setManagedHidden(element,authored||managed),eligible&&(eligibleIndex+=1)})}observeChildren(children){const next=new Set(children);if(!(next.size===this.observedChildren.size&&[...next].every(child=>this.observedChildren.has(child)))){this.drainVisibilityRecords(),this.visibilityObserver?.disconnect(),this.observedChildren.clear();for(const child of children)this.visibilityObserver?.observe(child,{attributes:!0,attributeFilter:["hidden","inert"],attributeOldValue:!0}),this.observedChildren.add(child)}}drainVisibilityRecords(){const records=this.visibilityObserver?.takeRecords();records?.length&&this.processHiddenMutations(records)}processHiddenMutations(records){let authorChanged=!1;const hiddenTargets=new Set;for(const record of records){if(record.type!=="attributes")continue;const child=record.target;if(this.authorHidden.has(child)){if(record.attributeName==="inert"){authorChanged=!0;continue}record.attributeName==="hidden"&&(hiddenTargets.has(child)&&this.recordHiddenWrite(child,record.oldValue!==null)&&(authorChanged=!0),hiddenTargets.add(child))}}for(const child of hiddenTargets)this.recordHiddenWrite(child,child.hasAttribute("hidden"))&&(authorChanged=!0);return authorChanged}recordHiddenWrite(child,hidden){const pending=this.pendingHiddenWrites.get(child);return pending&&pending.values[pending.cursor]===hidden?(++pending.cursor===pending.values.length&&this.pendingHiddenWrites.delete(child),!1):(this.authorHidden.set(child,hidden),!0)}setManagedHidden(child,hidden){if(child.hasAttribute("hidden")===hidden)return;let pending=this.pendingHiddenWrites.get(child);pending||(pending={values:[],cursor:0},this.pendingHiddenWrites.set(child,pending)),pending.values.push(hidden),child.toggleAttribute("hidden",hidden)}restoreChildVisibility(){for(const[child,hidden]of this.authorHidden)child.toggleAttribute("hidden",hidden);this.authorHidden.clear()}render(){const hasAccessibleLabel=this.hasAttribute("aria-label")||!!this.accessibleLabel,overflowing=this.hasOverflow,hiddenCount=overflowing?this.eligibleChildren().length-this.maxVisible:0,formattedHiddenCount=getNumberFormat(this.effectiveLocale).format(hiddenCount),visible=overflowing?this.expanded?this.localize("showLess"):this.localize("showMoreCollapsed",void 0,{count:formattedHiddenCount}):"";return html`
2
- <div part="base" tabindex="-1" role=${hasAccessibleLabel?"group":nothing} aria-label=${hasAccessibleLabel?this.accessibleLabel:nothing} @focusin=${this.onFocusIn} @focusout=${this.onFocusOut} >
1
+ import{__decorate}from"tslib";import{html,nothing}from"lit";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{finiteCount}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{applyComposedFocusRepair,captureComposedFocusRepair,collectComposedFocusTargets}from"../../../internal/focus-navigation.js";import{composedContains}from"../../../internal/overlay-manager.js";import{styles}from"./chip-group.styles.js";import{blankNumberConverter,literalSetConverter}from"../../../internal/converters.js";import{LYRA_DEFAULT_showLess,LYRA_DEFAULT_showMoreCollapsed,LYRA_DEFAULT_showMoreOverflowLabel}from"../../../internal/default-strings/shared.generated.js";const SELECTION=literalSetConverter(["none","single","multiple"],"none");class LyraChipGroup extends LyraElement{constructor(){super(...arguments),this._selection="none",this.selectedValues=[],this.accessibleLabel="",this.childCount=0,this.expanded=!1,this.authorHidden=new Map,this.observedChildren=new Set,this.pendingHiddenWrites=new Map,this.onSlotChange=e=>{const slot=e.target;this.updateBrowserDerivedState(()=>{this.isConnected&&(this.childCount=slot.assignedElements({flatten:!0}).length,this.requestUpdate())})},this.onFocusIn=()=>{const active=deepActiveElementIn(this.ownerDocument),children=this.assignedChildren(),index=children.findIndex(child2=>composedContains(child2,active)),base=this.renderRoot.querySelector('[part="base"]');if(index<0||!base){this.trackedChipFocus=void 0;return}const child=children[index];if(!("focus"in child)){this.trackedChipFocus=void 0;return}const repair=captureComposedFocusRepair(child,base);this.trackedChipFocus=repair?{child,index,repair}:void 0},this.onFocusOut=()=>{const tracked=this.trackedChipFocus;tracked&&queueMicrotask(()=>{if(this.trackedChipFocus!==tracked)return;const active=deepActiveElementIn(this.ownerDocument);if(active!==null&&composedContains(tracked.child,active))return;!tracked.child.isConnected&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement)||(this.trackedChipFocus=void 0)})},this.onChipToggleRequest=event=>{const chip=event.target;this.managedChips().includes(chip)&&this.isAllChip(chip)&&chip.selected&&event.preventDefault()},this.onChipChange=event=>{const chip=event.target;if(!this.managedChips().includes(chip))return;const value=chip.value;this.isAllChip(chip)?this.selectedValues=[]:chip.selected?this.selectedValues=this.selection==="single"?[value]:[...this.selectedValues,value]:this.selectedValues=this.selectedValues.filter(entry=>entry!==value),this.rawValue=[...this.selectedValues],this.syncSelectedChips(),this.requestUpdate("value"),this.emit("lr-change",{value:this.value})},this.onToggleOverflow=()=>{this.expanded=!this.expanded,this.emit("lr-overflow-toggle",{expanded:this.expanded})}}static{this.defaultStrings={...super.defaultStrings,showLess:LYRA_DEFAULT_showLess,showMoreCollapsed:LYRA_DEFAULT_showMoreCollapsed,showMoreOverflowLabel:LYRA_DEFAULT_showMoreOverflowLabel}}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-change"])}static{this.styles=[LyraElement.styles,styles]}get maxVisible(){return this._maxVisible}set maxVisible(next){const old=this._maxVisible;this._maxVisible=next==null?void 0:finiteCount(next),this.requestUpdate("maxVisible",old)}get selection(){return this._selection}set selection(next){const normalized=SELECTION.normalizeReflected(this,"selection",next),old=this._selection;old!==normalized&&(this._selection=normalized,this.selectedValues=this.parseSelection(this.rawValue),this.requestUpdate("selection",old))}parseSelection(next){const list=next==null?[]:typeof next=="string"?this.selection==="multiple"?next.split(","):[next]:[...next],cleaned=[...new Set(list.map(entry=>String(entry).trim()).filter(entry=>entry!==""))];return this.selection==="multiple"?cleaned:cleaned.slice(0,1)}get value(){return this.selection==="multiple"?[...this.selectedValues]:this.selectedValues[0]??""}set value(next){const old=this.value;this.rawValue=next,this.selectedValues=this.parseSelection(next),this.requestUpdate("value",old)}connectedCallback(){super.connectedCallback(),this.armVisibilityObserver(),this.hasUpdated&&this.reconcileChildVisibilityAndFocus()}armVisibilityObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.visibilityObserver&&this.visibilityObserverDocument===ownerDocument)return;this.resetVisibilityObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const observer=new MutationObserverCtor(records=>{this.processHiddenMutations(records)&&(this.reconcileChildVisibilityAndFocus(),this.requestUpdate())});this.visibilityObserver=observer,this.visibilityObserverDocument=ownerDocument}willUpdate(changed){if(super.willUpdate(changed),this.hasUpdated||this.seedFirstRenderState(()=>{this.childCount=this.children.length}),!this.hasOverflow){this.expanded=!1;const disclosure=this.shadowRoot?.querySelector('[part="overflow-indicator"]');disclosure&&(this.overflowFocusRepair=captureComposedFocusRepair(disclosure,disclosure)??void 0)}}firstUpdated(changed){super.firstUpdated(changed);const slot=this.shadowRoot.querySelector("slot");queueMicrotask(()=>{this.isConnected&&this.updateBrowserDerivedState(()=>{this.childCount=slot.assignedElements({flatten:!0}).length})})}updated(changed){super.updated(changed),this.syncSelectedChips();const overflowRepair=this.overflowFocusRepair;this.overflowFocusRepair=void 0,this.reconcileChildVisibilityAndFocus(overflowRepair)}disconnectedCallback(){this.resetVisibilityObserver(),this.observedChildren.clear(),this.pendingHiddenWrites.clear(),this.trackedChipFocus=void 0,this.restoreChildVisibility(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetVisibilityObserver(),this.observedChildren.clear(),this.pendingHiddenWrites.clear(),this.trackedChipFocus=void 0}resetVisibilityObserver(){this.drainVisibilityRecords(),this.visibilityObserver?.disconnect(),this.visibilityObserver=void 0,this.visibilityObserverDocument=void 0}get hasOverflow(){const max=this.maxVisible;return max!=null&&this.childCount>0&&this.eligibleChildren().length>max}assignedChildren(){return this.shadowRoot?.querySelector("slot")?.assignedElements({flatten:!0})??Array.from(this.children)}isAuthorHidden(child){return this.authorHidden.get(child)??child.hasAttribute("hidden")}isCapacityEligible(child){return!this.isAuthorHidden(child)&&!child.hasAttribute("inert")}eligibleChildren(children=this.assignedChildren()){return children.filter(child=>this.isCapacityEligible(child))}childWillBeVisible(child,assignedChildren){if(!this.isCapacityEligible(child))return!this.isAuthorHidden(child);const eligibleIndex=this.eligibleChildren(assignedChildren).indexOf(child);return!(this.hasOverflow&&!this.expanded&&eligibleIndex>=this.maxVisible)}focusRepairBeforeVisibility(assignedChildren){const tracked=this.trackedChipFocus;if(!tracked)return null;const currentIndex=assignedChildren.indexOf(tracked.child);if(currentIndex>=0&&this.childWillBeVisible(tracked.child,assignedChildren))return tracked.index=currentIndex,null;const active=deepActiveElementIn(this.ownerDocument),stillOwnsFocus=active!==null&&composedContains(tracked.child,active),focusWasLostWithRemovedBranch=currentIndex<0&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement),focusWasLostWithAlreadyHiddenBranch=tracked.child.hasAttribute("hidden")&&(active===null||active===this.ownerDocument.body||active===this.ownerDocument.documentElement);return!stillOwnsFocus&&!focusWasLostWithRemovedBranch&&!focusWasLostWithAlreadyHiddenBranch?null:{index:currentIndex>=0?currentIndex:tracked.index,repair:tracked.repair}}focusTargetAfterVisibility(assignedChildren,originIndex){const chipTargets=assignedChildren.map((child,index)=>({index,target:collectComposedFocusTargets(child,{includeRoot:!1,mode:"programmatic"}).elements[0]})).filter(entry=>entry.target!==void 0).sort((first,second)=>Math.abs(first.index-originIndex)-Math.abs(second.index-originIndex)||first.index-second.index);if(chipTargets[0])return chipTargets[0].target;const disclosure=this.renderRoot.querySelector('[part="overflow-indicator"]');if(disclosure){const available=collectComposedFocusTargets(disclosure,{mode:"programmatic"}).elements[0];if(available)return available}const base=this.renderRoot.querySelector('[part="base"]');return base?collectComposedFocusTargets(base,{mode:"programmatic"}).elements.find(target=>target===base)??null:null}reconcileChildVisibilityAndFocus(overflowRepair){const assignedChildren=this.assignedChildren(),focusRepair=overflowRepair?{index:assignedChildren.length,repair:overflowRepair}:this.focusRepairBeforeVisibility(assignedChildren);if(this.syncChildVisibility(assignedChildren),!focusRepair)return;const candidate=this.focusTargetAfterVisibility(assignedChildren,focusRepair.index);this.trackedChipFocus=void 0,candidate&&applyComposedFocusRepair(focusRepair.repair,candidate)}syncChildVisibility(assignedChildren=this.assignedChildren()){const max=this.maxVisible,overflowing=this.hasOverflow;this.observeChildren(assignedChildren);const current=new Set(assignedChildren);for(const[child,hidden]of this.authorHidden)current.has(child)||(child.toggleAttribute("hidden",hidden),this.authorHidden.delete(child));let eligibleIndex=0;assignedChildren.forEach(element=>{this.authorHidden.has(element)||this.authorHidden.set(element,element.hasAttribute("hidden"));const authored=this.authorHidden.get(element)??!1,eligible=!authored&&!element.hasAttribute("inert"),managed=eligible&&overflowing&&!this.expanded&&eligibleIndex>=max;this.setManagedHidden(element,authored||managed),eligible&&(eligibleIndex+=1)})}observeChildren(children){const next=new Set(children);if(!(next.size===this.observedChildren.size&&[...next].every(child=>this.observedChildren.has(child)))){this.drainVisibilityRecords(),this.visibilityObserver?.disconnect(),this.observedChildren.clear();for(const child of children)this.visibilityObserver?.observe(child,{attributes:!0,attributeFilter:["hidden","inert"],attributeOldValue:!0}),this.observedChildren.add(child)}}drainVisibilityRecords(){const records=this.visibilityObserver?.takeRecords();records?.length&&this.processHiddenMutations(records)}processHiddenMutations(records){let authorChanged=!1;const hiddenTargets=new Set;for(const record of records){if(record.type!=="attributes")continue;const child=record.target;if(this.authorHidden.has(child)){if(record.attributeName==="inert"){authorChanged=!0;continue}record.attributeName==="hidden"&&(hiddenTargets.has(child)&&this.recordHiddenWrite(child,record.oldValue!==null)&&(authorChanged=!0),hiddenTargets.add(child))}}for(const child of hiddenTargets)this.recordHiddenWrite(child,child.hasAttribute("hidden"))&&(authorChanged=!0);return authorChanged}recordHiddenWrite(child,hidden){const pending=this.pendingHiddenWrites.get(child);return pending&&pending.values[pending.cursor]===hidden?(++pending.cursor===pending.values.length&&this.pendingHiddenWrites.delete(child),!1):(this.authorHidden.set(child,hidden),!0)}setManagedHidden(child,hidden){if(child.hasAttribute("hidden")===hidden)return;let pending=this.pendingHiddenWrites.get(child);pending||(pending={values:[],cursor:0},this.pendingHiddenWrites.set(child,pending)),pending.values.push(hidden),child.toggleAttribute("hidden",hidden)}restoreChildVisibility(){for(const[child,hidden]of this.authorHidden)child.toggleAttribute("hidden",hidden);this.authorHidden.clear()}managedChips(){return this.selection==="none"?[]:this.assignedChildren().filter(child=>"toggleable"in child&&"selected"in child&&typeof child.value=="string")}isAllChip(chip){return this.allValue!=null&&chip.value===this.allValue}syncSelectedChips(){const chosen=new Set(this.selectedValues);for(const chip of this.managedChips()){chip.toggleable||(chip.toggleable=!0);const pressed=this.isAllChip(chip)?chosen.size===0:chosen.has(chip.value);chip.selected!==pressed&&(chip.selected=pressed)}}render(){const hasAccessibleLabel=this.hasAttribute("aria-label")||!!this.accessibleLabel,overflowing=this.hasOverflow,hiddenCount=overflowing?this.eligibleChildren().length-this.maxVisible:0,formattedHiddenCount=getNumberFormat(this.effectiveLocale).format(hiddenCount),visible=overflowing?this.expanded?this.localize("showLess"):this.localize("showMoreCollapsed",void 0,{count:formattedHiddenCount}):"";return html`
2
+ <div part="base" tabindex="-1" role=${hasAccessibleLabel?"group":nothing} aria-label=${hasAccessibleLabel?this.accessibleLabel:nothing} @focusin=${this.onFocusIn} @focusout=${this.onFocusOut} @lr-chip-toggle-request=${this.onChipToggleRequest} @lr-chip-change=${this.onChipChange} >
3
3
  <slot @slotchange=${this.onSlotChange}></slot>
4
4
  ${overflowing?html`<button part="overflow-indicator" type="button" aria-expanded=${this.expanded?"true":"false"} aria-label=${this.expanded?visible:this.localize("showMoreOverflowLabel",void 0,{visible,count:formattedHiddenCount})} @click=${this.onToggleOverflow} >
5
5
  ${visible}
6
6
  </button>`:nothing}
7
7
  </div>
8
- `}}__decorate([property({converter:blankNumberConverter(void 0),attribute:"max-visible"})],LyraChipGroup.prototype,"maxVisible",null),__decorate([property({attribute:"aria-label"})],LyraChipGroup.prototype,"accessibleLabel",void 0),__decorate([state()],LyraChipGroup.prototype,"childCount",void 0),__decorate([state()],LyraChipGroup.prototype,"expanded",void 0);export{LyraChipGroup};
8
+ `}}__decorate([property({converter:blankNumberConverter(void 0),attribute:"max-visible"})],LyraChipGroup.prototype,"maxVisible",null),__decorate([property({reflect:!0,useDefault:!0,converter:SELECTION})],LyraChipGroup.prototype,"selection",null),__decorate([property()],LyraChipGroup.prototype,"value",null),__decorate([property({attribute:"all-value"})],LyraChipGroup.prototype,"allValue",void 0),__decorate([property({attribute:"aria-label"})],LyraChipGroup.prototype,"accessibleLabel",void 0),__decorate([state()],LyraChipGroup.prototype,"childCount",void 0),__decorate([state()],LyraChipGroup.prototype,"expanded",void 0);export{LyraChipGroup};
@@ -83,6 +83,11 @@ export interface LyraContextMenuPoint{x:number;y:number;contextElement?:Element;
83
83
  * @cssprop [--lr-overlay-shadow-anchored=var(--lr-shadow-m)] - Elevation of the anchored popup.
84
84
  * @cssprop [--lr-overlay-max-inline-size=var(--lr-size-20rem)] - Maximum inline size fallback of
85
85
  * the popup.
86
+ * @cssprop [--lr-context-menu-min-inline-size=var(--lr-overlay-min-inline-size, 0px)] - Minimum
87
+ * inline size of the menu, capped by the available viewport space. Wins over the shared
88
+ * `--lr-overlay-min-inline-size`, so a menu can be floored without widening other popups.
89
+ * @cssprop [--lr-overlay-min-inline-size=0px] - Shared minimum inline size of anchored popups,
90
+ * read when `--lr-context-menu-min-inline-size` is unset.
86
91
  * @status experimental
87
92
  * @since 21.0.0
88
93
  */
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{listenUntilPointerEnd}from"../../../internal/document-pointer.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{isHandledOrComposingKey}from"../../../internal/list-navigation.js";import{html}from"lit";import{property,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveAccessibleName}from"../../../internal/accessible-name.js";import{composedParentElement}from"../../../internal/active-element.js";import{setCustomState}from"../../../internal/custom-states.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{tag}from"../../../internal/prefix.js";import{css as lyraStaticStyleCss}from"lit";const styles=lyraStaticStyleCss`:host,.trigger{display:contents}:host(:not([disabled])) .trigger{-webkit-touch-callout:none}.shell{display:contents}.shell::part(trigger){display:none}`;import{LYRA_DEFAULT_menuLabel}from"../../../internal/default-strings/shared.generated.js";const LONG_PRESS_TOLERANCE_PX=10,GESTURE_WINDOW_MS=1e3,POINTER_GAP_PX=2,ANCHOR_MOVE_TOLERANCE_PX=2,claimed=new WeakSet,now=()=>Date.now();function isElementNode(value){return typeof value=="object"&&value!==null&&value.nodeType===1}function firstElement(path){for(const entry of path)if(isElementNode(entry))return entry;return null}function isEditableTarget(element){return element?element.localName==="input"||element.localName==="textarea"?!0:isHtmlElement(element)&&element.isContentEditable:!1}function isContextMenuKey(event){return event.ctrlKey||event.altKey||event.metaKey?!1:event.key==="F10"&&event.shiftKey||event.key==="ContextMenu"}class LyraContextMenu extends LyraElement{constructor(){super(...arguments),this.disabled=!1,this.size="m",this.topLayer=!1,this.contextMenuInternals=attachInternalsSafely(this),this.swallowClickUntil=0,this.expectingInnerShow=!1,this.silentClose=!1,this.closingForMove=!1,this.onRegionContextMenu=event=>{if(claimed.has(event)||event.defaultPrevented||this.disabled||this.inForeignOpenSurface(event))return;if(claimed.add(event),this.open){event.preventDefault();return}const gesture=this.gesture;if(gesture&&now()<gesture.until&&gesture.vetoed){this.gesture=void 0;return}if(this.press?.decided==="vetoed")return;this.press&&!this.press.decided&&(this.press.decided="open",this.cancelPress());const path=event.composedPath(),target=firstElement(path);if(!target)return;const rect=target.getBoundingClientRect(),pointInside=event.clientX>=rect.left-1&&event.clientX<=rect.right+1&&event.clientY>=rect.top-1&&event.clientY<=rect.bottom+1;let source,x=event.clientX,y=event.clientY;pointInside?source=event.pointerType==="touch"?"long-press":"pointer":(source="keyboard",[x,y]=this.elementPoint(target)),this.requestOpen({source,target,path:this.regionPath(path),x,y,anchor:target,originalEvent:event})&&event.preventDefault()},this.onRegionKeyDown=event=>{if(this.gesture=void 0,claimed.has(event)||isHandledOrComposingKey(event)||this.inForeignOpenSurface(event)||!isContextMenuKey(event)||this.disabled)return;claimed.add(event);const path=event.composedPath(),anchor=firstElement(path);if(!anchor)return;const[x,y]=this.elementPoint(anchor);if(this.open){event.preventDefault(),this.shell?.showAt({x,y,contextElement:anchor},{returnFocusTo:this.returnFocusTo}),this.startWatching(anchor),this.gesture={kind:"keyboard",vetoed:!1,until:now()+GESTURE_WINDOW_MS};return}const opened=this.requestOpen({source:"keyboard",target:anchor,path:this.regionPath(path),x,y,anchor,originalEvent:event});opened&&event.preventDefault(),this.gesture={kind:"keyboard",vetoed:!opened,until:now()+GESTURE_WINDOW_MS}},this.onRegionPointerDown=event=>{if(this.gesture=void 0,this.swallowClickUntil=0,this.press&&this.cancelPress(),claimed.has(event)||this.disabled||this.inForeignOpenSurface(event)||event.pointerType!=="touch"&&event.pointerType!=="pen"||!event.isPrimary||event.button!==0)return;claimed.add(event);const path=event.composedPath(),target=firstElement(path),ownerDocument=this.ownerDocument,view=ownerDocument.defaultView;if(!target||!view)return;const selection=ownerDocument.getSelection(),press={pointerId:event.pointerId,startX:event.clientX,startY:event.clientY,target,path:this.regionPath(path),down:event,selectionWasCollapsed:!selection||selection.rangeCount===0||selection.isCollapsed,editableTarget:isEditableTarget(target),view},onMove=move=>{if(move.pointerId!==press.pointerId)return;Math.hypot(move.clientX-press.startX,move.clientY-press.startY)>LONG_PRESS_TOLERANCE_PX&&this.endPress(press)},onEnd=end=>{end.pointerId===press.pointerId&&this.endPress(press)},onScroll=()=>this.endPress(press);press.release=listenUntilPointerEnd(ownerDocument,onEnd,{capture:!0,passive:!0,extra:{pointermove:event2=>onMove(event2),scroll:onScroll}}),press.timer=view.setTimeout(()=>this.onPressTimer(press),LyraContextMenu.longPressDelayMs),this.press=press},this.onRegionClick=event=>{now()>=this.swallowClickUntil||(this.swallowClickUntil=0,event.preventDefault(),event.stopPropagation())},this.onSurfacePointerDown=event=>{claimed.add(event)},this.onSurfaceKeyDown=event=>{claimed.add(event),isContextMenuKey(event)&&event.preventDefault()},this.onSurfaceContextMenu=event=>{claimed.add(event),isEditableTarget(firstElement(event.composedPath()))||event.preventDefault()},this.onSurfaceFocusOut=event=>{const shell=this.shell,next=event.relatedTarget;!shell||!this.open||!isElementNode(next)||composedContains(shell,next)||this.hide({focusTrigger:!1})},this.onInnerShow=event=>{event.target===this.shell&&(event.stopPropagation(),this.expectingInnerShow||event.preventDefault())},this.onInnerAfterShow=event=>{event.target===this.shell&&(event.stopPropagation(),this.silentClose||this.emit("lr-after-show"))},this.onInnerHide=event=>{if(event.target!==this.shell||(event.stopPropagation(),this.silentClose))return;if(this.emit("lr-hide",null,{cancelable:!0}).defaultPrevented){event.preventDefault(),this.closingForMove&&this.stopWatching();return}setCustomState(this.contextMenuInternals,"open",!1),this.stopWatching()},this.onInnerAfterHide=event=>{event.target===this.shell&&(event.stopPropagation(),this.returnFocusTo=void 0,this.anchorElement=void 0,this.anchorRect=void 0,this.silentClose?this.silentClose=!1:this.emit("lr-after-hide"))}}static{this.defaultStrings={...super.defaultStrings,menuLabel:LYRA_DEFAULT_menuLabel}}static{this.longPressDelayMs=500}static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-show"])}static{this.identityEventDetailProperties=Object.freeze({"lr-show":Object.freeze(["target","originalEvent"])})}static{this.identityEventDetailCollectionItems=Object.freeze({"lr-show":Object.freeze(["path"])})}get open(){return this.shell?.open??!1}showAt(point,options){if(!Number.isFinite(point.x)||!Number.isFinite(point.y)||this.disabled||!this.isConnected)return;const contextElement=point.contextElement;if(this.open){options?.returnFocusTo&&(this.returnFocusTo=options.returnFocusTo),this.shell?.showAt({x:point.x,y:point.y,contextElement},{returnFocusTo:this.returnFocusTo}),contextElement?this.startWatching(contextElement):this.stopWatching();return}this.requestOpen({source:"programmatic",target:contextElement??null,path:contextElement?this.contextElementPath(contextElement):[],x:point.x,y:point.y,anchor:contextElement,originalEvent:null,returnFocusTo:options?.returnFocusTo})}hide(options){return this.shell?.hide(options)??Promise.resolve()}get resolvedLabel(){return resolveAccessibleName(this,this.label,this.localize("menuLabel"))}disconnectedCallback(){this.cancelPress(),this.gesture=void 0,this.swallowClickUntil=0,this.stopWatching();const shell=this.shell;shell?.open&&(this.silentClose=!0,shell.hide({focusTrigger:!1})),setCustomState(this.contextMenuInternals,"open",!1),this.returnFocusTo=void 0,this.anchorElement=void 0,this.anchorRect=void 0,this.pendingOpen=void 0,this.expectingInnerShow=!1,this.closingForMove=!1,super.disconnectedCallback()}updated(changed){super.updated(changed),changed.has("disabled")&&this.disabled&&this.cancelPress()}inForeignOpenSurface(event){const path=event.composedPath(),surfaceTags=new Set([tag("popover"),tag("dropdown")]);for(let index=0;index<path.length;index+=1){const entry=path[index];if(entry===this)break;if(!isElementNode(entry)||!surfaceTags.has(entry.localName)||entry.open!==!0)continue;const child=path.slice(0,index).find(node=>isElementNode(node)&&node.parentElement===entry);if(!child||child.getAttribute("slot")!=="trigger")return!0}return!1}regionPath(path){const elements=[];for(const entry of path)if(isElementNode(entry)&&(elements.push(entry),entry.parentElement===this))break;return elements}contextElementPath(contextElement){const elements=[];let current=contextElement;for(;current;){if(elements.push(current),current.parentElement===this&&current.getAttribute("slot")==="trigger")return elements;if(current===this)break;current=composedParentElement(current)}return[contextElement]}onPressTimer(press){if(this.press!==press)return;if(press.timer=void 0,this.open){press.decided="open",this.endPress(press);return}const opened=this.requestOpen({source:"long-press",target:press.target,path:press.path,x:press.startX,y:press.startY,anchor:press.target,originalEvent:press.down});press.decided=opened?"open":"vetoed",opened?(this.clearPressSelection(press),this.swallowClickUntil=now()+GESTURE_WINDOW_MS):this.gesture={kind:"long-press",vetoed:!0,until:now()+GESTURE_WINDOW_MS}}clearPressSelection(press){if(!press.selectionWasCollapsed||press.editableTarget)return;const selection=this.ownerDocument.getSelection();if(!selection||selection.rangeCount===0||selection.isCollapsed)return;const anchorNode=selection.anchorNode,anchorElement=isElementNode(anchorNode)?anchorNode:anchorNode?.parentElement??null;anchorElement&&composedContains(this,anchorElement)&&selection.removeAllRanges()}endPress(press){press.timer!==void 0&&press.view?.clearTimeout(press.timer),press.timer=void 0,press.release?.(),press.release=void 0,this.press===press&&!press.decided&&(this.press=void 0)}cancelPress(){const press=this.press;press&&(this.endPress(press),this.press=void 0)}requestOpen(request){const shell=this.shell;if(this.disabled||!this.isConnected||this.open||!shell)return!1;request={...request,returnFocusTo:request.returnFocusTo??this.relatedFocusTarget(request)};const inPreflight=this.pendingOpen!==void 0;if(this.pendingOpen=request,inPreflight)return!1;this.silentClose=!1;const event=this.emit("lr-show",{source:request.source,target:request.target,path:Object.freeze([...request.path]),clientX:request.x,clientY:request.y,originalEvent:request.originalEvent},{cancelable:!0}),accepted=this.pendingOpen;if(this.pendingOpen=void 0,event.defaultPrevented||!accepted||this.disabled||!this.isConnected)return!1;const{x,y,anchor,returnFocusTo}=accepted;this.expectingInnerShow=!0;try{shell.showAt({x,y,contextElement:anchor},{returnFocusTo})}finally{this.expectingInnerShow=!1}return shell.open?(this.returnFocusTo=returnFocusTo,setCustomState(this.contextMenuInternals,"open",!0),anchor?this.startWatching(anchor):this.stopWatching(),!0):!1}relatedFocusTarget(request){const ownerDocument=this.ownerDocument,active=deepActiveElement(ownerDocument);if(!(!isHtmlElement(active)||active===ownerDocument.body)&&active.ownerDocument===ownerDocument&&(composedContains(this,active)||request.source==="programmatic"&&request.anchor&&composedContains(request.anchor,active)))return active}elementPoint(anchor){const rect=anchor.getBoundingClientRect(),root=this.ownerDocument.documentElement,width=root.clientWidth,height=root.clientHeight;let left=Math.max(rect.left,0),right=Math.min(rect.right,width),top=Math.max(rect.top,0),bottom=Math.min(rect.bottom,height);return(left>right||top>bottom)&&(left=Math.min(Math.max(rect.left,0),width),right=Math.min(Math.max(rect.right,0),width),top=Math.min(Math.max(rect.top,0),height),bottom=Math.min(Math.max(rect.bottom,0),height)),[this.effectiveDirection==="rtl"?right:left,bottom]}startWatching(anchor){this.stopWatching();const ownerDocument=anchor.ownerDocument,view=ownerDocument.defaultView;this.anchorElement=anchor,this.anchorRect=anchor.getBoundingClientRect();const roots=new Set([ownerDocument]);for(let current=anchor;current;current=composedParentElement(current)){const root=current.getRootNode();root!==ownerDocument&&root.host&&roots.add(root)}const onScroll=event=>{const target=event.target;(target?.nodeType===9||isElementNode(target)&&composedContains(target,anchor))&&this.checkAnchor(anchor)},onResize=()=>this.checkAnchor(anchor),listen={capture:!0,passive:!0};for(const root of roots)root.addEventListener("scroll",onScroll,listen);view?.addEventListener("resize",onResize,{passive:!0});const visualViewport=view?.visualViewport;visualViewport?.addEventListener("resize",onResize,{passive:!0});const ResizeObserverCtor=view?.ResizeObserver,observer=ResizeObserverCtor?new ResizeObserverCtor(()=>{anchor.isConnected||this.checkAnchor(anchor)}):void 0;observer?.observe(anchor),this.watchCleanup=()=>{for(const root of roots)root.removeEventListener("scroll",onScroll,listen);view?.removeEventListener("resize",onResize),visualViewport?.removeEventListener("resize",onResize),observer?.disconnect()}}stopWatching(){const cleanup=this.watchCleanup;this.watchCleanup=void 0,cleanup?.()}checkAnchor(anchor){if(!(!this.open||this.anchorElement!==anchor)){if(anchor.isConnected){const baseline=this.anchorRect,current=anchor.getBoundingClientRect();if(baseline&&Math.abs(current.left-baseline.left)<=ANCHOR_MOVE_TOLERANCE_PX&&Math.abs(current.top-baseline.top)<=ANCHOR_MOVE_TOLERANCE_PX)return}this.closeForMove()}}closeForMove(){const shell=this.shell;if(!shell)return;const focusWasInMenu=composedContains(shell,deepActiveElement(this.ownerDocument)),returnFocusTo=this.returnFocusTo;this.closingForMove=!0;try{shell.hide({focusTrigger:!1})}finally{this.closingForMove=!1}!shell.open&&focusWasInMenu&&returnFocusTo?.isConnected&&returnFocusTo.focus({preventScroll:!0})}render(){return html`
1
+ import{__decorate}from"tslib";import{listenUntilPointerEnd}from"../../../internal/document-pointer.js";import{eventCollectionSupport}from"../../../internal/collection-snapshot.js";import{isHandledOrComposingKey}from"../../../internal/list-navigation.js";import{html}from"lit";import{property,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveAccessibleName}from"../../../internal/accessible-name.js";import{composedParentElement}from"../../../internal/active-element.js";import{setCustomState}from"../../../internal/custom-states.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{tag}from"../../../internal/prefix.js";import{css as lyraStaticStyleCss}from"lit";const styles=lyraStaticStyleCss`:host,.trigger{display:contents}:host(:not([disabled])) .trigger{-webkit-touch-callout:none}.shell{--_lr-popup-min-inline-size:var(--lr-context-menu-min-inline-size);display:contents}.shell::part(trigger){display:none}`;import{LYRA_DEFAULT_menuLabel}from"../../../internal/default-strings/shared.generated.js";const LONG_PRESS_TOLERANCE_PX=10,GESTURE_WINDOW_MS=1e3,POINTER_GAP_PX=2,ANCHOR_MOVE_TOLERANCE_PX=2,claimed=new WeakSet,now=()=>Date.now();function isElementNode(value){return typeof value=="object"&&value!==null&&value.nodeType===1}function firstElement(path){for(const entry of path)if(isElementNode(entry))return entry;return null}function isEditableTarget(element){return element?element.localName==="input"||element.localName==="textarea"?!0:isHtmlElement(element)&&element.isContentEditable:!1}function isContextMenuKey(event){return event.ctrlKey||event.altKey||event.metaKey?!1:event.key==="F10"&&event.shiftKey||event.key==="ContextMenu"}class LyraContextMenu extends LyraElement{constructor(){super(...arguments),this.disabled=!1,this.size="m",this.topLayer=!1,this.contextMenuInternals=attachInternalsSafely(this),this.swallowClickUntil=0,this.expectingInnerShow=!1,this.silentClose=!1,this.closingForMove=!1,this.onRegionContextMenu=event=>{if(claimed.has(event)||event.defaultPrevented||this.disabled||this.inForeignOpenSurface(event))return;if(claimed.add(event),this.open){event.preventDefault();return}const gesture=this.gesture;if(gesture&&now()<gesture.until&&gesture.vetoed){this.gesture=void 0;return}if(this.press?.decided==="vetoed")return;this.press&&!this.press.decided&&(this.press.decided="open",this.cancelPress());const path=event.composedPath(),target=firstElement(path);if(!target)return;const rect=target.getBoundingClientRect(),pointInside=event.clientX>=rect.left-1&&event.clientX<=rect.right+1&&event.clientY>=rect.top-1&&event.clientY<=rect.bottom+1;let source,x=event.clientX,y=event.clientY;pointInside?source=event.pointerType==="touch"?"long-press":"pointer":(source="keyboard",[x,y]=this.elementPoint(target)),this.requestOpen({source,target,path:this.regionPath(path),x,y,anchor:target,originalEvent:event})&&event.preventDefault()},this.onRegionKeyDown=event=>{if(this.gesture=void 0,claimed.has(event)||isHandledOrComposingKey(event)||this.inForeignOpenSurface(event)||!isContextMenuKey(event)||this.disabled)return;claimed.add(event);const path=event.composedPath(),anchor=firstElement(path);if(!anchor)return;const[x,y]=this.elementPoint(anchor);if(this.open){event.preventDefault(),this.shell?.showAt({x,y,contextElement:anchor},{returnFocusTo:this.returnFocusTo}),this.startWatching(anchor),this.gesture={kind:"keyboard",vetoed:!1,until:now()+GESTURE_WINDOW_MS};return}const opened=this.requestOpen({source:"keyboard",target:anchor,path:this.regionPath(path),x,y,anchor,originalEvent:event});opened&&event.preventDefault(),this.gesture={kind:"keyboard",vetoed:!opened,until:now()+GESTURE_WINDOW_MS}},this.onRegionPointerDown=event=>{if(this.gesture=void 0,this.swallowClickUntil=0,this.press&&this.cancelPress(),claimed.has(event)||this.disabled||this.inForeignOpenSurface(event)||event.pointerType!=="touch"&&event.pointerType!=="pen"||!event.isPrimary||event.button!==0)return;claimed.add(event);const path=event.composedPath(),target=firstElement(path),ownerDocument=this.ownerDocument,view=ownerDocument.defaultView;if(!target||!view)return;const selection=ownerDocument.getSelection(),press={pointerId:event.pointerId,startX:event.clientX,startY:event.clientY,target,path:this.regionPath(path),down:event,selectionWasCollapsed:!selection||selection.rangeCount===0||selection.isCollapsed,editableTarget:isEditableTarget(target),view},onMove=move=>{if(move.pointerId!==press.pointerId)return;Math.hypot(move.clientX-press.startX,move.clientY-press.startY)>LONG_PRESS_TOLERANCE_PX&&this.endPress(press)},onEnd=end=>{end.pointerId===press.pointerId&&this.endPress(press)},onScroll=()=>this.endPress(press);press.release=listenUntilPointerEnd(ownerDocument,onEnd,{capture:!0,passive:!0,extra:{pointermove:event2=>onMove(event2),scroll:onScroll}}),press.timer=view.setTimeout(()=>this.onPressTimer(press),LyraContextMenu.longPressDelayMs),this.press=press},this.onRegionClick=event=>{now()>=this.swallowClickUntil||(this.swallowClickUntil=0,event.preventDefault(),event.stopPropagation())},this.onSurfacePointerDown=event=>{claimed.add(event)},this.onSurfaceKeyDown=event=>{claimed.add(event),isContextMenuKey(event)&&event.preventDefault()},this.onSurfaceContextMenu=event=>{claimed.add(event),isEditableTarget(firstElement(event.composedPath()))||event.preventDefault()},this.onSurfaceFocusOut=event=>{const shell=this.shell,next=event.relatedTarget;!shell||!this.open||!isElementNode(next)||composedContains(shell,next)||this.hide({focusTrigger:!1})},this.onInnerShow=event=>{event.target===this.shell&&(event.stopPropagation(),this.expectingInnerShow||event.preventDefault())},this.onInnerAfterShow=event=>{event.target===this.shell&&(event.stopPropagation(),this.silentClose||this.emit("lr-after-show"))},this.onInnerHide=event=>{if(event.target!==this.shell||(event.stopPropagation(),this.silentClose))return;if(this.emit("lr-hide",null,{cancelable:!0}).defaultPrevented){event.preventDefault(),this.closingForMove&&this.stopWatching();return}setCustomState(this.contextMenuInternals,"open",!1),this.stopWatching()},this.onInnerAfterHide=event=>{event.target===this.shell&&(event.stopPropagation(),this.returnFocusTo=void 0,this.anchorElement=void 0,this.anchorRect=void 0,this.silentClose?this.silentClose=!1:this.emit("lr-after-hide"))}}static{this.defaultStrings={...super.defaultStrings,menuLabel:LYRA_DEFAULT_menuLabel}}static{this.longPressDelayMs=500}static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=eventCollectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-show"])}static{this.identityEventDetailProperties=Object.freeze({"lr-show":Object.freeze(["target","originalEvent"])})}static{this.identityEventDetailCollectionItems=Object.freeze({"lr-show":Object.freeze(["path"])})}get open(){return this.shell?.open??!1}showAt(point,options){if(!Number.isFinite(point.x)||!Number.isFinite(point.y)||this.disabled||!this.isConnected)return;const contextElement=point.contextElement;if(this.open){options?.returnFocusTo&&(this.returnFocusTo=options.returnFocusTo),this.shell?.showAt({x:point.x,y:point.y,contextElement},{returnFocusTo:this.returnFocusTo}),contextElement?this.startWatching(contextElement):this.stopWatching();return}this.requestOpen({source:"programmatic",target:contextElement??null,path:contextElement?this.contextElementPath(contextElement):[],x:point.x,y:point.y,anchor:contextElement,originalEvent:null,returnFocusTo:options?.returnFocusTo})}hide(options){return this.shell?.hide(options)??Promise.resolve()}get resolvedLabel(){return resolveAccessibleName(this,this.label,this.localize("menuLabel"))}disconnectedCallback(){this.cancelPress(),this.gesture=void 0,this.swallowClickUntil=0,this.stopWatching();const shell=this.shell;shell?.open&&(this.silentClose=!0,shell.hide({focusTrigger:!1})),setCustomState(this.contextMenuInternals,"open",!1),this.returnFocusTo=void 0,this.anchorElement=void 0,this.anchorRect=void 0,this.pendingOpen=void 0,this.expectingInnerShow=!1,this.closingForMove=!1,super.disconnectedCallback()}updated(changed){super.updated(changed),changed.has("disabled")&&this.disabled&&this.cancelPress()}inForeignOpenSurface(event){const path=event.composedPath(),surfaceTags=new Set([tag("popover"),tag("dropdown")]);for(let index=0;index<path.length;index+=1){const entry=path[index];if(entry===this)break;if(!isElementNode(entry)||!surfaceTags.has(entry.localName)||entry.open!==!0)continue;const child=path.slice(0,index).find(node=>isElementNode(node)&&node.parentElement===entry);if(!child||child.getAttribute("slot")!=="trigger")return!0}return!1}regionPath(path){const elements=[];for(const entry of path)if(isElementNode(entry)&&(elements.push(entry),entry.parentElement===this))break;return elements}contextElementPath(contextElement){const elements=[];let current=contextElement;for(;current;){if(elements.push(current),current.parentElement===this&&current.getAttribute("slot")==="trigger")return elements;if(current===this)break;current=composedParentElement(current)}return[contextElement]}onPressTimer(press){if(this.press!==press)return;if(press.timer=void 0,this.open){press.decided="open",this.endPress(press);return}const opened=this.requestOpen({source:"long-press",target:press.target,path:press.path,x:press.startX,y:press.startY,anchor:press.target,originalEvent:press.down});press.decided=opened?"open":"vetoed",opened?(this.clearPressSelection(press),this.swallowClickUntil=now()+GESTURE_WINDOW_MS):this.gesture={kind:"long-press",vetoed:!0,until:now()+GESTURE_WINDOW_MS}}clearPressSelection(press){if(!press.selectionWasCollapsed||press.editableTarget)return;const selection=this.ownerDocument.getSelection();if(!selection||selection.rangeCount===0||selection.isCollapsed)return;const anchorNode=selection.anchorNode,anchorElement=isElementNode(anchorNode)?anchorNode:anchorNode?.parentElement??null;anchorElement&&composedContains(this,anchorElement)&&selection.removeAllRanges()}endPress(press){press.timer!==void 0&&press.view?.clearTimeout(press.timer),press.timer=void 0,press.release?.(),press.release=void 0,this.press===press&&!press.decided&&(this.press=void 0)}cancelPress(){const press=this.press;press&&(this.endPress(press),this.press=void 0)}requestOpen(request){const shell=this.shell;if(this.disabled||!this.isConnected||this.open||!shell)return!1;request={...request,returnFocusTo:request.returnFocusTo??this.relatedFocusTarget(request)};const inPreflight=this.pendingOpen!==void 0;if(this.pendingOpen=request,inPreflight)return!1;this.silentClose=!1;const event=this.emit("lr-show",{source:request.source,target:request.target,path:Object.freeze([...request.path]),clientX:request.x,clientY:request.y,originalEvent:request.originalEvent},{cancelable:!0}),accepted=this.pendingOpen;if(this.pendingOpen=void 0,event.defaultPrevented||!accepted||this.disabled||!this.isConnected)return!1;const{x,y,anchor,returnFocusTo}=accepted;this.expectingInnerShow=!0;try{shell.showAt({x,y,contextElement:anchor},{returnFocusTo})}finally{this.expectingInnerShow=!1}return shell.open?(this.returnFocusTo=returnFocusTo,setCustomState(this.contextMenuInternals,"open",!0),anchor?this.startWatching(anchor):this.stopWatching(),!0):!1}relatedFocusTarget(request){const ownerDocument=this.ownerDocument,active=deepActiveElement(ownerDocument);if(!(!isHtmlElement(active)||active===ownerDocument.body)&&active.ownerDocument===ownerDocument&&(composedContains(this,active)||request.source==="programmatic"&&request.anchor&&composedContains(request.anchor,active)))return active}elementPoint(anchor){const rect=anchor.getBoundingClientRect(),root=this.ownerDocument.documentElement,width=root.clientWidth,height=root.clientHeight;let left=Math.max(rect.left,0),right=Math.min(rect.right,width),top=Math.max(rect.top,0),bottom=Math.min(rect.bottom,height);return(left>right||top>bottom)&&(left=Math.min(Math.max(rect.left,0),width),right=Math.min(Math.max(rect.right,0),width),top=Math.min(Math.max(rect.top,0),height),bottom=Math.min(Math.max(rect.bottom,0),height)),[this.effectiveDirection==="rtl"?right:left,bottom]}startWatching(anchor){this.stopWatching();const ownerDocument=anchor.ownerDocument,view=ownerDocument.defaultView;this.anchorElement=anchor,this.anchorRect=anchor.getBoundingClientRect();const roots=new Set([ownerDocument]);for(let current=anchor;current;current=composedParentElement(current)){const root=current.getRootNode();root!==ownerDocument&&root.host&&roots.add(root)}const onScroll=event=>{const target=event.target;(target?.nodeType===9||isElementNode(target)&&composedContains(target,anchor))&&this.checkAnchor(anchor)},onResize=()=>this.checkAnchor(anchor),listen={capture:!0,passive:!0};for(const root of roots)root.addEventListener("scroll",onScroll,listen);view?.addEventListener("resize",onResize,{passive:!0});const visualViewport=view?.visualViewport;visualViewport?.addEventListener("resize",onResize,{passive:!0});const ResizeObserverCtor=view?.ResizeObserver,observer=ResizeObserverCtor?new ResizeObserverCtor(()=>{anchor.isConnected||this.checkAnchor(anchor)}):void 0;observer?.observe(anchor),this.watchCleanup=()=>{for(const root of roots)root.removeEventListener("scroll",onScroll,listen);view?.removeEventListener("resize",onResize),visualViewport?.removeEventListener("resize",onResize),observer?.disconnect()}}stopWatching(){const cleanup=this.watchCleanup;this.watchCleanup=void 0,cleanup?.()}checkAnchor(anchor){if(!(!this.open||this.anchorElement!==anchor)){if(anchor.isConnected){const baseline=this.anchorRect,current=anchor.getBoundingClientRect();if(baseline&&Math.abs(current.left-baseline.left)<=ANCHOR_MOVE_TOLERANCE_PX&&Math.abs(current.top-baseline.top)<=ANCHOR_MOVE_TOLERANCE_PX)return}this.closeForMove()}}closeForMove(){const shell=this.shell;if(!shell)return;const focusWasInMenu=composedContains(shell,deepActiveElement(this.ownerDocument)),returnFocusTo=this.returnFocusTo;this.closingForMove=!0;try{shell.hide({focusTrigger:!1})}finally{this.closingForMove=!1}!shell.open&&focusWasInMenu&&returnFocusTo?.isConnected&&returnFocusTo.focus({preventScroll:!0})}render(){return html`
2
2
  <span class="trigger" @contextmenu=${this.onRegionContextMenu} @keydown=${this.onRegionKeyDown} @pointerdown=${this.onRegionPointerDown} @click=${{handleEvent:this.onRegionClick,capture:!0}} ><slot name="trigger"></slot
3
3
  ></span>
4
4
  <lr-dropdown without-arrow class="shell" exportparts="popup, content" trigger="manual" placement="right-start" positioning-strategy="fixed" .topLayer=${this.topLayer} .distance=${POINTER_GAP_PX} .size=${this.size} .disabled=${this.disabled} .accessibleLabel=${this.resolvedLabel} @lr-show=${this.onInnerShow} @lr-after-show=${this.onInnerAfterShow} @lr-hide=${this.onInnerHide} @lr-after-hide=${this.onInnerAfterHide} @pointerdown=${this.onSurfacePointerDown} @keydown=${this.onSurfaceKeyDown} @contextmenu=${this.onSurfaceContextMenu} @focusout=${this.onSurfaceFocusOut} ><slot></slot
@@ -143,6 +143,8 @@ export interface LyraDialogCloseDetail{reason:DialogCloseReason;}export interfac
143
143
  * @csspart close-button - The built-in close button, rendered inside `header`
144
144
  * unless `without-close-button` is set.
145
145
  * @csspart close-button__base - Exported mapped alias on the close button, on the same node.
146
+ * @csspart close-button__button - Web Awesome-named alias of `close-button-control`: the close button's
147
+ * own native control.
146
148
  * @csspart close-button-control - The composed `<lr-icon-button>`'s own native control, forwarded
147
149
  * because the painted surface now sits one shadow boundary deeper than `close-button`. As of
148
150
  * 16.0.0 the close button IS an `<lr-icon-button>`, so its background, radius, hover/press mixes,
@@ -155,6 +157,8 @@ export interface LyraDialogCloseDetail{reason:DialogCloseReason;}export interfac
155
157
  * @csspart body - The wrapper around the default slot.
156
158
  * @csspart footer - The wrapper around the `footer` slot.
157
159
  * @cssprop [--lr-dialog-overlay-color=var(--lr-color-overlay)] - Backdrop scrim color.
160
+ * @cssprop [--backdrop-color=var(--lr-color-overlay)] - Mapped alias of `--lr-dialog-overlay-color`; the
161
+ * `--lr-*` name wins when both are set.
158
162
  * @cssprop [--lr-dialog-backdrop-filter=none] - `backdrop-filter` applied to the scrim, for a
159
163
  * frosted-glass treatment over the page behind it.
160
164
  * @cssprop [--backdrop-filter=var(--lr-dialog-backdrop-filter,none)] - Mapped backdrop-filter
@@ -181,11 +185,28 @@ export interface LyraDialogCloseDetail{reason:DialogCloseReason;}export interfac
181
185
  * slotted content a definite, fillable block size -- `header` and `footer` keep their natural
182
186
  * size and only `body` grows or shrinks into the remaining space. Add `fill-body` to make `body` a
183
187
  * column flex container whose slotted children fill that space.
188
+ * @cssprop [--lr-dialog-max-height=100%] - Cap on the panel's block size, the block-axis twin of
189
+ * `--lr-dialog-max-width`. The viewport (`100%`) stays a hard limit on top, so a value larger
190
+ * than the viewport is a no-op.
191
+ * @cssprop [--lr-dialog-viewport-inset=var(--lr-space-l)] - Gap between the viewport edges and the
192
+ * panel, on all four sides. The device safe-area insets still win wherever they are larger.
193
+ * @cssprop [--lr-dialog-panel-bg=var(--lr-overlay-surface)] - Fill of this panel only. Unlike
194
+ * `--lr-overlay-surface`, it does not reach the popups, menus and listboxes opened inside the
195
+ * dialog. The glass surface treatment applies to it in the same way.
196
+ * @cssprop [--lr-dialog-divider-color=var(--lr-overlay-border)] - Colour of the header's and footer's
197
+ * dividing rules. Left unset they follow the panel edge colour.
184
198
  * @cssprop [--lr-dialog-heading-font-family=var(--lr-font-heading)] - Font family of the visible
185
199
  * header title.
186
200
  * @cssprop [--lr-dialog-heading-font-size=inherit] - Font size of the visible header title.
187
201
  * @cssprop [--lr-dialog-heading-font-weight=var(--lr-font-weight-semibold)] - Font weight of the
188
202
  * visible header title.
203
+ * @cssprop [--lr-dialog-heading-letter-spacing=normal] - Letter spacing of the visible header title.
204
+ * @cssprop [--lr-dialog-heading-line-height=inherit] - Line height of the visible header title.
205
+ * @cssprop [--lr-dialog-header-border=var(--lr-border-width-thin) solid var(--lr-dialog-divider-color)] -
206
+ * Border shorthand of the header's bottom rule; `none` removes it. The footer rule keeps
207
+ * `--lr-dialog-divider-color`.
208
+ * @cssprop [--lr-dialog-body-overflow=auto] - `overflow` of the body region, for example `hidden`
209
+ * when slotted content manages its own scrolling.
189
210
  * @cssprop [--lr-dialog-spacing=var(--lr-space-l)] - Padding inside the body, and the inline
190
211
  * padding of the header and footer rows.
191
212
  * @cssprop [--lr-dialog-spacing-block=var(--lr-space-m)] - Block padding of the header and footer
@@ -196,9 +217,10 @@ export interface LyraDialogCloseDetail{reason:DialogCloseReason;}export interfac
196
217
  * fade.
197
218
  * @cssprop [--lr-overlay-surface=var(--lr-color-surface-container-highest)] - Shared floating-surface fill,
198
219
  * on the panel. The same family every anchored popup now reads, so one declaration retints the
199
- * dialog and the popups opened from it together.
220
+ * dialog and the popups opened from it together; `--lr-dialog-panel-bg` retints the panel alone.
200
221
  * @cssprop [--lr-overlay-border=var(--lr-color-border-subtle)] - Shared floating-surface edge
201
- * colour, on the panel and on the header's and footer's dividing rules.
222
+ * colour, on the panel and, unless `--lr-dialog-divider-color` is set, on the header's and
223
+ * footer's dividing rules.
202
224
  * @cssprop [--lr-overlay-radius=var(--lr-radius)] - Shared floating-surface corner radius, on the
203
225
  * panel and on the close button.
204
226
  * @cssprop [--lr-overlay-shadow-modal=var(--lr-shadow-xl)] - Elevation of a modal panel. A separate
@@ -241,6 +263,12 @@ noHeader:boolean;
241
263
  * space; wrap several in one element, or set `flex: none` on the ones that should keep their
242
264
  * natural size. */
243
265
  fillBody:boolean;
266
+ /** Opt-in full-screen layout for narrow viewports. While the viewport is at most `40rem` wide
267
+ * the panel drops its viewport inset, corner radius and size caps and fills the viewport,
268
+ * carrying the device safe-area insets as its own padding; at wider viewports it renders exactly
269
+ * as without the attribute. The breakpoint is evaluated with `matchMedia()` and followed live
270
+ * while the dialog is connected. */
271
+ fullscreenNarrow:boolean;
244
272
  /** SSR hint that keeps the footer wrapper rendered before slot assignment is observable.*/
245
273
  withFooter:boolean;
246
274
  /** Visual width tier for the panel, on the library's shared six-step size ladder. `'m'` (the
@@ -254,12 +282,16 @@ size:LyraSize;private hostAriaLabel;
254
282
  * backdrop dismissal on, so a mechanical `wa-dialog` → `lr-dialog` rename silently flipped the
255
283
  * behaviour of every migrated dialog. A rename that changes what the markup does with nothing
256
284
  * to warn on is worse than no rename at all, so the polarity now matches upstream exactly. */
257
- lightDismiss:boolean;private hasFooterSlot;private hasLabelSlot;private hasHeaderActionsSlot;private headingText?;private overlay?;private focusReturnOpener;private hideSettled?;private readonly nativeModal;private readonly modalPresentation;private pendingScrollLockRelease?;private readonly hostDescription;private headingReferences?;private readonly headingObserver;private headingObserverOpen?;private readonly bodyOverflowObserver;private bodyOverflowObservedBody?;private transitionToken;private readonly openRequest;private transitionAnimations;private initialFocusDecision?;private readonly headingId;private externalModalDepth;
285
+ lightDismiss:boolean;private releaseFullscreenQuery?;
286
+ /** Server-rendering hint: set it when a `label` slot child is provided so the server markup
287
+ * already carries the titled header before hydration. In the browser only the real label
288
+ * content decides, so a `with-label` dialog with no label renders no empty heading. */
289
+ withLabel:boolean;private hasFooterSlot;private hasLabelSlot;private hasHeaderActionsSlot;private headingText?;private overlay?;private focusReturnOpener;private hideSettled?;private readonly nativeModal;private readonly modalPresentation;private pendingScrollLockRelease?;private readonly hostDescription;private headingReferences?;private readonly headingObserver;private headingObserverOpen?;private readonly bodyOverflowObserver;private bodyOverflowObservedBody?;private transitionToken;private readonly openRequest;private transitionAnimations;private initialFocusDecision?;private readonly headingId;private externalModalDepth;
258
290
  /** Shoelace-compatible modal controller. External activation suspends this dialog's focus/Escape
259
291
  * ownership without changing its logical `open` state; deactivation restores it. */
260
292
  modal:LyraDialogModalController;
261
293
  /** Drawer overrides this for its nonmodal `contained` mode.*/
262
- protected get modalSurface():boolean;protected willUpdate(changed:PropertyValues):void;private flushPendingScrollLockRelease;protected updated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private headingChanged;private armHeadingObserver;private resetHeadingObserver;private syncBodyTabIndex;private armBodyOverflowObserver;private resetBodyOverflowObserver;private defaultSlotElements;
294
+ protected get modalSurface():boolean;private syncFullscreenQuery;protected willUpdate(changed:PropertyValues):void;private flushPendingScrollLockRelease;protected updated(changed:PropertyValues):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private headingChanged;private armHeadingObserver;private resetHeadingObserver;private syncBodyTabIndex;private armBodyOverflowObserver;private resetBodyOverflowObserver;private defaultSlotElements;
263
295
  /** Whether an external-removal hide request can preserve open state for a later reconnect.*/
264
296
  protected get disconnectHideCancelable():boolean;private onDefaultSlotChange;private onFooterSlotChange;private detectLightDomChrome;
265
297
  /**
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{OwnedMutationObserver,OwnedResizeObserver}from"../../../internal/owned-observer.js";import{ModalOpenRequest}from"../../../internal/modal-open-request.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveHeadingLevel}from"../../../internal/heading-level.js";import{activateOverlay,collectFocusableElements,composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{cancelDeferredFocusReturn,captureFocusReturnOpener,scheduleDeferredFocusReturn}from"../../../internal/deferred-focus-return.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{nextId}from"../../../internal/a11y.js";import{composedAccessibilityText,composedAccessibilityTextResult,observeAccessibleTextReferences,releaseAccessibleTextReferences,isAccessibilitySubtreeExcluded}from"../../../internal/accessibility-visibility.js";import{closeIcon}from"../../../internal/icons.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{styles}from"./dialog.styles.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings/shared.generated.js";const HEADING_SELECTOR='h1, h2, h3, h4, h5, h6, [role="heading"]';class LyraDialog extends LyraElement{static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close}}constructor(){super(),this._open=!1,this.label="",this.headingLevel="3",this.withoutCloseButton=!1,this.withoutHeader=!1,this.noHeader=!1,this.fillBody=!1,this.withFooter=!1,this.size="m",this.hostAriaLabel=null,this.lightDismiss=!1,this.hasFooterSlot=!1,this.hasLabelSlot=!1,this.hasHeaderActionsSlot=!1,this.focusReturnOpener=null,this.nativeModal=new NativeModalCarrier(this,{onCancel:event=>this.onNativeCancel(event),onUnexpectedClose:carrier=>{!this.open||!this.modalSurface||(this.closeFrom("api",carrier),this.open&&this.enterTopLayer())}}),this.modalPresentation=new ModalSurfaceController(this,this.nativeModal),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector('[role="dialog"]')),this.headingObserver=new OwnedMutationObserver(this,()=>this.headingChanged()),this.bodyOverflowObserver=new OwnedResizeObserver(this,()=>this.syncBodyTabIndex()),this.transitionToken=0,this.openRequest=new ModalOpenRequest,this.transitionAnimations=[],this.headingId=nextId("dialog-heading"),this.externalModalDepth=0,this.modal={activateExternal:()=>{this.externalModalDepth++,this.externalModalDepth===1&&this.overlay?.suspend()},deactivateExternal:()=>{this.externalModalDepth!==0&&(this.externalModalDepth--,this.externalModalDepth===0&&this.open&&this.modalSurface&&(this.overlay?.resume(),queueMicrotask(()=>this.focusInitial())))}},this.onDefaultSlotChange=()=>{this.detectLightDomChrome(),this.syncBodyTabIndex(),this.resetBodyOverflowObserver(),this.armBodyOverflowObserver()},this.onFooterSlotChange=()=>{this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")},this.onNativeCancel=event=>{if(event.preventDefault(),!this.open||!this.overlay?.isTopmost())return;const panel=this.renderRoot.querySelector('[part~="panel"]')??this;this.requestClose("keyboard","escape",panel)},this.onBackdropClick=()=>{this.lightDismiss&&this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{const button=this.renderRoot.querySelector('[part~="close-button"]')??this;this.requestClose("close-button","close-button",button)},new GlassScrollLayer(this,'[part~="panel"]',()=>this.open)}static{this.styles=[LyraElement.styles,styles,nativeModalCarrierStyles]}get open(){return this._open}set open(next){const normalized=!!next;if(!this.openRequest.coalesce(normalized)&&normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.close("api")}}get modalSurface(){return!0}willUpdate(changed){if(super.willUpdate(changed),(!this.hasUpdated||changed.has("open")&&this.open)&&(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer"),this.detectLightDomChrome()),this.open&&(changed.has("open")||changed.has("contained"))&&this.nativeModal.prepare(this.modalSurface),changed.has("open")){if(this.flushPendingScrollLockRelease(),this.open)cancelDeferredFocusReturn(this),this.focusReturnOpener=captureFocusReturnOpener(this),this.isConnected&&this.modalSurface&&this.activateOverlay();else{this.modalPresentation.beginClose();const returnsFocus=this.overlay!==void 0||composedContains(this,deepActiveElement(this.ownerDocument));this.pendingScrollLockRelease=this.deactivateOverlay({deferScrollLockRelease:!0});const opener=this.focusReturnOpener;this.focusReturnOpener=null,returnsFocus&&opener&&this.isConnected&&scheduleDeferredFocusReturn({host:this,candidates:()=>[opener],settled:this.hideSettled,isCurrent:()=>!this.open})}this.hideSettled=void 0}}flushPendingScrollLockRelease(){const release=this.pendingScrollLockRelease;this.pendingScrollLockRelease=void 0,release?.()}updated(changed){super.updated(changed),changed.has("open")&&this.armHeadingObserver(),this.syncBodyTabIndex(),this.armBodyOverflowObserver(),changed.has("open")&&this.open&&this.isConnected&&(this.modalSurface&&(this.enterTopLayer(),this.focusInitial()),queueMicrotask(()=>{this.open&&this.isConnected&&this.detectLightDomChrome()}))}connectedCallback(){super.connectedCallback(),this.armHeadingObserver(),this.syncBodyTabIndex(),this.armBodyOverflowObserver(),this.hasUpdated&&this.open&&(this.modalSurface&&(this.overlay?.isActive()?this.externalModalDepth===0&&this.overlay.resume():this.activateOverlay(),this.enterTopLayer()),queueMicrotask(()=>{!this.open||!this.isConnected||(this.detectLightDomChrome(),this.modalSurface&&this.focusInitial())}))}disconnectedCallback(){this.resetHeadingObserver(),this.resetBodyOverflowObserver(),super.disconnectedCallback(),this.modalPresentation.disconnect(),this.overlay?.suspend(),cancelDeferredFocusReturn(this),this.transitionToken++,this.flushPendingScrollLockRelease(),this.cancelTransitionAnimations(),this.removeAttribute("data-closing"),this.open&&queueMicrotask(()=>{if(!this.isConnected&&this.open){if(this.emit("lr-hide",{source:this},{cancelable:this.disconnectHideCancelable}).defaultPrevented){this.syncOpenAttribute();return}this.applyOpenState(!1),this.emit("lr-close",{reason:"unmount"}),this.emit("lr-after-hide")}})}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted(),this.resetHeadingObserver(),this.resetBodyOverflowObserver(),this.isConnected&&(this.armHeadingObserver(),this.armBodyOverflowObserver(),this.syncBodyTabIndex())}headingChanged(){this.detectLightDomChrome(),this.syncBodyTabIndex(),this.resetHeadingObserver(),this.armHeadingObserver()}armHeadingObserver(){if(!this.isConnected||this.headingObserver.active&&this.headingObserverOpen===this.open)return;this.resetHeadingObserver();const observer=this.headingObserver;if(this.headingObserverOpen=this.open,observer.observe(this,{childList:!0}),this.open){for(const child of this.children)observer.observe(child,{attributes:!0,attributeFilter:["slot"]});const heading=Array.from(this.children).find(child=>child.getAttribute("slot")===null&&child.matches(HEADING_SELECTOR));if(!heading)return;observer.observe(heading,{attributes:!0,attributeFilter:["aria-label","aria-labelledby","aria-hidden","hidden","inert","class","style","slot"],characterData:!0,childList:!0,subtree:!0}),heading.hasAttribute("aria-labelledby")&&(this.headingReferences={releases:[],changed:()=>this.headingChanged()},observeAccessibleTextReferences(observer,heading,composedAccessibilityTextResult(heading,{ancestorBoundary:this,requireRendered:!1}),this.headingReferences))}}resetHeadingObserver(){this.headingReferences&&releaseAccessibleTextReferences(this.headingReferences),this.headingReferences=void 0,this.headingObserver.clear(),this.headingObserverOpen=void 0}syncBodyTabIndex(){const body=this.renderRoot?.querySelector('[part="body"]');if(!body)return;const next=this.open&&(body.scrollHeight>body.clientHeight&&body.scrollHeight>0||body.scrollWidth>body.clientWidth&&body.scrollWidth>0)?0:-1;body.tabIndex!==next&&(body.tabIndex=next)}armBodyOverflowObserver(){const body=this.renderRoot?.querySelector('[part="body"]');if(!body||!this.isConnected||this.bodyOverflowObservedBody===body)return;this.resetBodyOverflowObserver();const observer=this.bodyOverflowObserver;this.bodyOverflowObservedBody=body,observer.observe(body);for(const element of this.defaultSlotElements())observer.observe(element)}resetBodyOverflowObserver(){this.bodyOverflowObserver.clear(),this.bodyOverflowObservedBody=void 0}defaultSlotElements(){return this.renderRoot?.querySelector('[part="body"] slot:not([name])')?.assignedElements({flatten:!0})??[]}get disconnectHideCancelable(){return!1}detectLightDomChrome(){const children=Array.from(this.children),heading=children.find(el=>el.getAttribute("slot")===null&&el.matches(HEADING_SELECTOR));!heading||isAccessibilitySubtreeExcluded(heading)?this.headingText=void 0:heading.hasAttribute("aria-label")?this.headingText=heading.getAttribute("aria-label")??"":heading.hasAttribute("aria-labelledby")?this.headingText=composedAccessibilityText(heading,{ancestorBoundary:this}).trim()||void 0:this.headingText=composedAccessibilityText(Array.from(heading.childNodes),{ancestorBoundary:heading}).trim()||void 0,this.hasLabelSlot=children.some(el=>el.getAttribute("slot")==="label"),this.hasHeaderActionsSlot=children.some(el=>el.getAttribute("slot")==="header-actions")}show(){if(this.openRequest.coalesce(!0)||this._open)return Promise.resolve();this.openRequest.begin(!0);const prevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented,superseded=this.openRequest.superseded(!0);return this.openRequest.finish(),prevented||superseded?(this.syncOpenAttribute(),Promise.resolve()):(this.cancelTransitionAnimations(),this.removeAttribute("data-closing"),this.applyOpenState(!0),this.settleTransition("lr-after-show"))}hide(){return this.close("api")}close(reason="api"){return this.closeFrom(reason,this)}closeFrom(reason,source){if(this.openRequest.coalesce(!1)||!this._open)return Promise.resolve();if(this.openRequest.begin(!1),this.emit("lr-hide",{source},{cancelable:!0}).defaultPrevented||this.openRequest.superseded(!1))return this.openRequest.finish(),this.syncOpenAttribute(),Promise.resolve();if(this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented||this.openRequest.superseded(!1))return this.openRequest.finish(),this.syncOpenAttribute(),Promise.resolve();this.openRequest.finish(),this.cancelTransitionAnimations(),this.isConnected&&this.setAttribute("data-closing",""),this.applyOpenState(!1);const settled=this.settleTransition("lr-after-hide");return this.hideSettled=settled,this.emit("lr-close",{reason}),settled}applyOpenState(next){const old=this._open;this._open=next,next&&(this.initialFocusDecision=void 0),this.requestUpdate("open",old)}syncOpenAttribute(){this.toggleAttribute("open",this._open)}panelAnimationName(showing){return showing?"dialog.show":"dialog.hide"}overlayAnimationName(showing){return showing?"dialog.overlay.show":"dialog.overlay.hide"}panelAnimationSpec(showing){const offset="translateY(calc(-1 * var(--lr-size-0-5rem)))";return{keyframes:showing?[{opacity:0,transform:offset},{opacity:1,transform:"translateY(0)"}]:[{opacity:1,transform:"translateY(0)"},{opacity:0,transform:offset}],durationProperties:[showing?"--show-duration":"--hide-duration","--lr-dialog-panel-duration","--lr-duration-base"],easingProperties:["--lr-easing-standard"]}}overlayAnimationSpec(showing){return{keyframes:showing?[{opacity:0},{opacity:1}]:[{opacity:1},{opacity:0}],durationProperties:[showing?"--show-duration":"--hide-duration","--lr-dialog-backdrop-duration","--lr-duration-fast"],easingProperties:["--lr-easing-standard"]}}cancelTransitionAnimations(){for(const animation of this.transitionAnimations)animation.cancel();this.transitionAnimations=[]}async settleTransition(event){const token=++this.transitionToken;if(await this.updateComplete,this.transitionToken===token){if(this.isConnected){const root=this.renderRoot,panel=root.querySelector('[part~="panel"]'),backdrop=root.querySelector('[part~="backdrop"]'),showing=event==="lr-after-show",animations=[panel?animateRegistered(this,panel,this.panelAnimationName(showing),this.effectiveDirection,this.panelAnimationSpec(showing)):void 0,this.modalSurface&&backdrop?animateRegistered(this,backdrop,this.overlayAnimationName(showing),this.effectiveDirection,this.overlayAnimationSpec(showing)):void 0].filter(animation=>animation!==void 0);if(this.transitionAnimations=animations,await Promise.all(animations.map(animation=>animation.finished.catch(()=>{}))),this.transitionToken!==token)return;this.cancelTransitionAnimations()}event==="lr-after-hide"&&(this.removeAttribute("data-closing"),this.leaveTopLayer(),this.flushPendingScrollLockRelease()),this.emit(event)}}enterTopLayer(){this.externalModalDepth===0&&this.overlay?.resume(),this.modalPresentation.show()}leaveTopLayer(){this.modalPresentation.hide()}requestClose(source,reason,sourceElement){this.emit("lr-request-close",{source},{cancelable:!0}).defaultPrevented||this.closeFrom(reason,sourceElement)}focusInitial(){this.overlay?.focusInitial()}activateOverlay(){!this.isConnected||this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part~="panel"]')??null,onEscape:()=>{const panel=this.renderRoot.querySelector('[part~="panel"]')??this;this.requestClose("keyboard","escape",panel)},onBackdrop:()=>{const backdrop=this.renderRoot.querySelector('[part~="backdrop"]')??this;this.requestClose("overlay","backdrop",backdrop)},preferredInitialFocus:()=>{const panel=this.renderRoot.querySelector('[part~="panel"]'),body=this.renderRoot.querySelector('[part="body"]'),stops=body?collectFocusableElements(body):[];return stops.find(stop=>stop!==body)??stops[0]??panel},beforeInitialFocus:()=>(this.initialFocusDecision===void 0&&(this.initialFocusDecision=!this.emit("lr-initial-focus",null,{cancelable:!0}).defaultPrevented),this.initialFocusDecision),lockScroll:!0,suspendWhenUnrendered:!0}),this.externalModalDepth>0&&this.overlay.suspend())}deactivateOverlay(options){const overlay=this.overlay;return this.overlay=void 0,overlay?.deactivate(options)}render(){const suppressHeader=this.withoutHeader||this.noHeader,renderHeading=!suppressHeader&&!this.headingText&&(this.hasLabelSlot||(this.label??"").length>0||!!this.heading),hasHostName=this.hostAriaLabel!==null,explicitName=hasHostName?this.hostAriaLabel:this.headingText,hasExplicitName=hasHostName||!!explicitName,useHeadingForName=!hasExplicitName&&renderHeading,showHeader=!suppressHeader&&(renderHeading||this.hasHeaderActionsSlot||!this.withoutCloseButton),headingLevel=resolveHeadingLevel(this.headingLevel);return this.nativeModal.render(html`
1
+ import{__decorate}from"tslib";import{OwnedMutationObserver,OwnedResizeObserver}from"../../../internal/owned-observer.js";import{ModalOpenRequest}from"../../../internal/modal-open-request.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{NativeModalCarrier}from"../../../internal/native-modal-carrier.js";import{ModalSurfaceController}from"../../../internal/modal-surface-controller.js";import{nativeModalCarrierStyles}from"../../../internal/native-modal-carrier.styles.js";import{html,isServer,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveHeadingLevel}from"../../../internal/heading-level.js";import{activateOverlay,collectFocusableElements,composedContains,deepActiveElement}from"../../../internal/overlay-manager.js";import{cancelDeferredFocusReturn,captureFocusReturnOpener,scheduleDeferredFocusReturn}from"../../../internal/deferred-focus-return.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{nextId}from"../../../internal/a11y.js";import{composedAccessibilityText,composedAccessibilityTextResult,observeAccessibleTextReferences,releaseAccessibleTextReferences,isAccessibilitySubtreeExcluded}from"../../../internal/accessibility-visibility.js";import{closeIcon}from"../../../internal/icons.js";import{animateRegistered}from"../../../internal/registered-animation.js";import{styles}from"./dialog.styles.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings/shared.generated.js";const HEADING_SELECTOR='h1, h2, h3, h4, h5, h6, [role="heading"]',FULLSCREEN_NARROW_QUERY="(max-width: 40rem)";class LyraDialog extends LyraElement{static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close}}constructor(){super(),this._open=!1,this.label="",this.headingLevel="3",this.withoutCloseButton=!1,this.withoutHeader=!1,this.noHeader=!1,this.fillBody=!1,this.fullscreenNarrow=!1,this.withFooter=!1,this.size="m",this.hostAriaLabel=null,this.lightDismiss=!1,this.withLabel=!1,this.hasFooterSlot=!1,this.hasLabelSlot=!1,this.hasHeaderActionsSlot=!1,this.focusReturnOpener=null,this.nativeModal=new NativeModalCarrier(this,{onCancel:event=>this.onNativeCancel(event),onUnexpectedClose:carrier=>{!this.open||!this.modalSurface||(this.closeFrom("api",carrier),this.open&&this.enterTopLayer())}}),this.modalPresentation=new ModalSurfaceController(this,this.nativeModal),this.hostDescription=new HostDescriptionController(this,()=>this.renderRoot.querySelector('[role="dialog"]')),this.headingObserver=new OwnedMutationObserver(this,()=>this.headingChanged()),this.bodyOverflowObserver=new OwnedResizeObserver(this,()=>this.syncBodyTabIndex()),this.transitionToken=0,this.openRequest=new ModalOpenRequest,this.transitionAnimations=[],this.headingId=nextId("dialog-heading"),this.externalModalDepth=0,this.modal={activateExternal:()=>{this.externalModalDepth++,this.externalModalDepth===1&&this.overlay?.suspend()},deactivateExternal:()=>{this.externalModalDepth!==0&&(this.externalModalDepth--,this.externalModalDepth===0&&this.open&&this.modalSurface&&(this.overlay?.resume(),queueMicrotask(()=>this.focusInitial())))}},this.onDefaultSlotChange=()=>{this.detectLightDomChrome(),this.syncBodyTabIndex(),this.resetBodyOverflowObserver(),this.armBodyOverflowObserver()},this.onFooterSlotChange=()=>{this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer")},this.onNativeCancel=event=>{if(event.preventDefault(),!this.open||!this.overlay?.isTopmost())return;const panel=this.renderRoot.querySelector('[part~="panel"]')??this;this.requestClose("keyboard","escape",panel)},this.onBackdropClick=()=>{this.lightDismiss&&this.overlay?.dismissBackdrop()},this.onCloseButtonClick=()=>{const button=this.renderRoot.querySelector('[part~="close-button"]')??this;this.requestClose("close-button","close-button",button)},new GlassScrollLayer(this,'[part~="panel"]',()=>this.open)}static{this.styles=[LyraElement.styles,styles,nativeModalCarrierStyles]}get open(){return this._open}set open(next){const normalized=!!next;if(!this.openRequest.coalesce(normalized)&&normalized!==this._open){if(!this.hasUpdated){this.applyOpenState(normalized);return}normalized?this.show():this.close("api")}}get modalSurface(){return!0}syncFullscreenQuery(){this.releaseFullscreenQuery?.(),this.releaseFullscreenQuery=void 0;const view=this.ownerDocument?.defaultView;if(!this.fullscreenNarrow||!this.isConnected||typeof view?.matchMedia!="function"){this.removeAttribute("data-fullscreen");return}const query=view.matchMedia(FULLSCREEN_NARROW_QUERY),apply=()=>{this.toggleAttribute("data-fullscreen",query.matches)};query.addEventListener("change",apply),this.releaseFullscreenQuery=()=>query.removeEventListener("change",apply),apply()}willUpdate(changed){if(super.willUpdate(changed),changed.has("fullscreenNarrow")&&this.syncFullscreenQuery(),(!this.hasUpdated||changed.has("open")&&this.open)&&(this.hasFooterSlot=Array.from(this.children).some(el=>el.getAttribute("slot")==="footer"),this.detectLightDomChrome()),this.open&&(changed.has("open")||changed.has("contained"))&&this.nativeModal.prepare(this.modalSurface),changed.has("open")){if(this.flushPendingScrollLockRelease(),this.open)cancelDeferredFocusReturn(this),this.focusReturnOpener=captureFocusReturnOpener(this),this.isConnected&&this.modalSurface&&this.activateOverlay();else{this.modalPresentation.beginClose();const returnsFocus=this.overlay!==void 0||composedContains(this,deepActiveElement(this.ownerDocument));this.pendingScrollLockRelease=this.deactivateOverlay({deferScrollLockRelease:!0});const opener=this.focusReturnOpener;this.focusReturnOpener=null,returnsFocus&&opener&&this.isConnected&&scheduleDeferredFocusReturn({host:this,candidates:()=>[opener],settled:this.hideSettled,isCurrent:()=>!this.open})}this.hideSettled=void 0}}flushPendingScrollLockRelease(){const release=this.pendingScrollLockRelease;this.pendingScrollLockRelease=void 0,release?.()}updated(changed){super.updated(changed),changed.has("open")&&this.armHeadingObserver(),this.syncBodyTabIndex(),this.armBodyOverflowObserver(),changed.has("open")&&this.open&&this.isConnected&&(this.modalSurface&&(this.enterTopLayer(),this.focusInitial()),queueMicrotask(()=>{this.open&&this.isConnected&&this.detectLightDomChrome()}))}connectedCallback(){super.connectedCallback(),this.syncFullscreenQuery(),this.armHeadingObserver(),this.syncBodyTabIndex(),this.armBodyOverflowObserver(),this.hasUpdated&&this.open&&(this.modalSurface&&(this.overlay?.isActive()?this.externalModalDepth===0&&this.overlay.resume():this.activateOverlay(),this.enterTopLayer()),queueMicrotask(()=>{!this.open||!this.isConnected||(this.detectLightDomChrome(),this.modalSurface&&this.focusInitial())}))}disconnectedCallback(){this.releaseFullscreenQuery?.(),this.releaseFullscreenQuery=void 0,this.removeAttribute("data-fullscreen"),this.resetHeadingObserver(),this.resetBodyOverflowObserver(),super.disconnectedCallback(),this.modalPresentation.disconnect(),this.overlay?.suspend(),cancelDeferredFocusReturn(this),this.transitionToken++,this.flushPendingScrollLockRelease(),this.cancelTransitionAnimations(),this.removeAttribute("data-closing"),this.open&&queueMicrotask(()=>{if(!this.isConnected&&this.open){if(this.emit("lr-hide",{source:this},{cancelable:this.disconnectHideCancelable}).defaultPrevented){this.syncOpenAttribute();return}this.applyOpenState(!1),this.emit("lr-close",{reason:"unmount"}),this.emit("lr-after-hide")}})}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted(),this.resetHeadingObserver(),this.resetBodyOverflowObserver(),this.isConnected&&(this.armHeadingObserver(),this.armBodyOverflowObserver(),this.syncBodyTabIndex())}headingChanged(){this.detectLightDomChrome(),this.syncBodyTabIndex(),this.resetHeadingObserver(),this.armHeadingObserver()}armHeadingObserver(){if(!this.isConnected||this.headingObserver.active&&this.headingObserverOpen===this.open)return;this.resetHeadingObserver();const observer=this.headingObserver;if(this.headingObserverOpen=this.open,observer.observe(this,{childList:!0}),this.open){for(const child of this.children)observer.observe(child,{attributes:!0,attributeFilter:["slot"]});const heading=Array.from(this.children).find(child=>child.getAttribute("slot")===null&&child.matches(HEADING_SELECTOR));if(!heading)return;observer.observe(heading,{attributes:!0,attributeFilter:["aria-label","aria-labelledby","aria-hidden","hidden","inert","class","style","slot"],characterData:!0,childList:!0,subtree:!0}),heading.hasAttribute("aria-labelledby")&&(this.headingReferences={releases:[],changed:()=>this.headingChanged()},observeAccessibleTextReferences(observer,heading,composedAccessibilityTextResult(heading,{ancestorBoundary:this,requireRendered:!1}),this.headingReferences))}}resetHeadingObserver(){this.headingReferences&&releaseAccessibleTextReferences(this.headingReferences),this.headingReferences=void 0,this.headingObserver.clear(),this.headingObserverOpen=void 0}syncBodyTabIndex(){const body=this.renderRoot?.querySelector('[part="body"]');if(!body)return;const next=this.open&&(body.scrollHeight>body.clientHeight&&body.scrollHeight>0||body.scrollWidth>body.clientWidth&&body.scrollWidth>0)?0:-1;body.tabIndex!==next&&(body.tabIndex=next)}armBodyOverflowObserver(){const body=this.renderRoot?.querySelector('[part="body"]');if(!body||!this.isConnected||this.bodyOverflowObservedBody===body)return;this.resetBodyOverflowObserver();const observer=this.bodyOverflowObserver;this.bodyOverflowObservedBody=body,observer.observe(body);for(const element of this.defaultSlotElements())observer.observe(element)}resetBodyOverflowObserver(){this.bodyOverflowObserver.clear(),this.bodyOverflowObservedBody=void 0}defaultSlotElements(){return this.renderRoot?.querySelector('[part="body"] slot:not([name])')?.assignedElements({flatten:!0})??[]}get disconnectHideCancelable(){return!1}detectLightDomChrome(){const children=Array.from(this.children),heading=children.find(el=>el.getAttribute("slot")===null&&el.matches(HEADING_SELECTOR));!heading||isAccessibilitySubtreeExcluded(heading)?this.headingText=void 0:heading.hasAttribute("aria-label")?this.headingText=heading.getAttribute("aria-label")??"":heading.hasAttribute("aria-labelledby")?this.headingText=composedAccessibilityText(heading,{ancestorBoundary:this}).trim()||void 0:this.headingText=composedAccessibilityText(Array.from(heading.childNodes),{ancestorBoundary:heading}).trim()||void 0,this.hasLabelSlot=children.some(el=>el.getAttribute("slot")==="label"),this.hasHeaderActionsSlot=children.some(el=>el.getAttribute("slot")==="header-actions")}show(){if(this.openRequest.coalesce(!0)||this._open)return Promise.resolve();this.openRequest.begin(!0);const prevented=this.emit("lr-show",null,{cancelable:!0}).defaultPrevented,superseded=this.openRequest.superseded(!0);return this.openRequest.finish(),prevented||superseded?(this.syncOpenAttribute(),Promise.resolve()):(this.cancelTransitionAnimations(),this.removeAttribute("data-closing"),this.applyOpenState(!0),this.settleTransition("lr-after-show"))}hide(){return this.close("api")}close(reason="api"){return this.closeFrom(reason,this)}closeFrom(reason,source){if(this.openRequest.coalesce(!1)||!this._open)return Promise.resolve();if(this.openRequest.begin(!1),this.emit("lr-hide",{source},{cancelable:!0}).defaultPrevented||this.openRequest.superseded(!1))return this.openRequest.finish(),this.syncOpenAttribute(),Promise.resolve();if(this.emit("lr-close-request",{reason},{cancelable:!0}).defaultPrevented||this.openRequest.superseded(!1))return this.openRequest.finish(),this.syncOpenAttribute(),Promise.resolve();this.openRequest.finish(),this.cancelTransitionAnimations(),this.isConnected&&this.setAttribute("data-closing",""),this.applyOpenState(!1);const settled=this.settleTransition("lr-after-hide");return this.hideSettled=settled,this.emit("lr-close",{reason}),settled}applyOpenState(next){const old=this._open;this._open=next,next&&(this.initialFocusDecision=void 0),this.requestUpdate("open",old)}syncOpenAttribute(){this.toggleAttribute("open",this._open)}panelAnimationName(showing){return showing?"dialog.show":"dialog.hide"}overlayAnimationName(showing){return showing?"dialog.overlay.show":"dialog.overlay.hide"}panelAnimationSpec(showing){const offset="translateY(calc(-1 * var(--lr-size-0-5rem)))";return{keyframes:showing?[{opacity:0,transform:offset},{opacity:1,transform:"translateY(0)"}]:[{opacity:1,transform:"translateY(0)"},{opacity:0,transform:offset}],durationProperties:[showing?"--show-duration":"--hide-duration","--lr-dialog-panel-duration","--lr-duration-base"],easingProperties:["--lr-easing-standard"]}}overlayAnimationSpec(showing){return{keyframes:showing?[{opacity:0},{opacity:1}]:[{opacity:1},{opacity:0}],durationProperties:[showing?"--show-duration":"--hide-duration","--lr-dialog-backdrop-duration","--lr-duration-fast"],easingProperties:["--lr-easing-standard"]}}cancelTransitionAnimations(){for(const animation of this.transitionAnimations)animation.cancel();this.transitionAnimations=[]}async settleTransition(event){const token=++this.transitionToken;if(await this.updateComplete,this.transitionToken===token){if(this.isConnected){const root=this.renderRoot,panel=root.querySelector('[part~="panel"]'),backdrop=root.querySelector('[part~="backdrop"]'),showing=event==="lr-after-show",animations=[panel?animateRegistered(this,panel,this.panelAnimationName(showing),this.effectiveDirection,this.panelAnimationSpec(showing)):void 0,this.modalSurface&&backdrop?animateRegistered(this,backdrop,this.overlayAnimationName(showing),this.effectiveDirection,this.overlayAnimationSpec(showing)):void 0].filter(animation=>animation!==void 0);if(this.transitionAnimations=animations,await Promise.all(animations.map(animation=>animation.finished.catch(()=>{}))),this.transitionToken!==token)return;this.cancelTransitionAnimations()}event==="lr-after-hide"&&(this.removeAttribute("data-closing"),this.leaveTopLayer(),this.flushPendingScrollLockRelease()),this.emit(event)}}enterTopLayer(){this.externalModalDepth===0&&this.overlay?.resume(),this.modalPresentation.show()}leaveTopLayer(){this.modalPresentation.hide()}requestClose(source,reason,sourceElement){this.emit("lr-request-close",{source},{cancelable:!0}).defaultPrevented||this.closeFrom(reason,sourceElement)}focusInitial(){this.overlay?.focusInitial()}activateOverlay(){!this.isConnected||this.overlay?.isActive()||(this.overlay=activateOverlay({host:this,panel:()=>this.shadowRoot?.querySelector('[part~="panel"]')??null,onEscape:()=>{const panel=this.renderRoot.querySelector('[part~="panel"]')??this;this.requestClose("keyboard","escape",panel)},onBackdrop:()=>{const backdrop=this.renderRoot.querySelector('[part~="backdrop"]')??this;this.requestClose("overlay","backdrop",backdrop)},preferredInitialFocus:()=>{const panel=this.renderRoot.querySelector('[part~="panel"]'),body=this.renderRoot.querySelector('[part="body"]'),stops=body?collectFocusableElements(body):[];return stops.find(stop=>stop!==body)??stops[0]??panel},beforeInitialFocus:()=>(this.initialFocusDecision===void 0&&(this.initialFocusDecision=!this.emit("lr-initial-focus",null,{cancelable:!0}).defaultPrevented),this.initialFocusDecision),lockScroll:!0,suspendWhenUnrendered:!0}),this.externalModalDepth>0&&this.overlay.suspend())}deactivateOverlay(options){const overlay=this.overlay;return this.overlay=void 0,overlay?.deactivate(options)}render(){const suppressHeader=this.withoutHeader||this.noHeader,renderHeading=!suppressHeader&&!this.headingText&&(this.hasLabelSlot||isServer&&this.withLabel||(this.label??"").length>0||!!this.heading),hasHostName=this.hostAriaLabel!==null,explicitName=hasHostName?this.hostAriaLabel:this.headingText,hasExplicitName=hasHostName||!!explicitName,useHeadingForName=!hasExplicitName&&renderHeading,showHeader=!suppressHeader&&(renderHeading||this.hasHeaderActionsSlot||!this.withoutCloseButton),headingLevel=resolveHeadingLevel(this.headingLevel);return this.nativeModal.render(html`
2
2
  <div part="backdrop overlay" @click=${this.onBackdropClick}></div>
3
3
  <div part="panel dialog" role=${this.open&&!this.nativeModal.requested?"dialog":nothing} aria-modal=${this.open&&this.modalSurface&&!this.nativeModal.requested?"true":nothing} aria-label=${!this.nativeModal.requested&&hasExplicitName?explicitName:nothing} aria-labelledby=${!this.nativeModal.requested&&useHeadingForName?this.headingId:nothing} tabindex="-1" >
4
4
  <span class="glass-scroll-layer" aria-hidden="true"></span>
@@ -8,7 +8,7 @@ import{__decorate}from"tslib";import{OwnedMutationObserver,OwnedResizeObserver}f
8
8
  >`:nothing}
9
9
  ${this.hasHeaderActionsSlot?html`<span part="header-actions"><slot name="header-actions"></slot></span>`:nothing}
10
10
  ${this.withoutCloseButton?nothing:html`
11
- <lr-icon-button part="close-button close-button__base" exportparts="button:close-button-control" aria-label=${this.localize("close")} @click=${this.onCloseButtonClick} >
11
+ <lr-icon-button part="close-button close-button__base" exportparts="button:close-button-control, button:close-button__button" aria-label=${this.localize("close")} @click=${this.onCloseButtonClick} >
12
12
  ${closeIcon()}
13
13
  </lr-icon-button>
14
14
  `}
@@ -24,4 +24,4 @@ import{__decorate}from"tslib";import{OwnedMutationObserver,OwnedResizeObserver}f
24
24
  </div>
25
25
  ${this.nativeModal.renderHelperSlot()}
26
26
  </div>
27
- `,{part:"base",label:hasExplicitName?explicitName:void 0,labelledBy:useHeadingForName?this.headingId:void 0})}}__decorate([property({type:Boolean,reflect:!0})],LyraDialog.prototype,"open",null),__decorate([property({reflect:!0})],LyraDialog.prototype,"label",void 0),__decorate([property({attribute:"heading-level",reflect:!0})],LyraDialog.prototype,"headingLevel",void 0),__decorate([property()],LyraDialog.prototype,"heading",void 0),__decorate([property({type:Boolean,attribute:"without-close-button",reflect:!0})],LyraDialog.prototype,"withoutCloseButton",void 0),__decorate([property({type:Boolean,attribute:"without-header",reflect:!0})],LyraDialog.prototype,"withoutHeader",void 0),__decorate([property({type:Boolean,attribute:"no-header",reflect:!0})],LyraDialog.prototype,"noHeader",void 0),__decorate([property({type:Boolean,attribute:"fill-body",reflect:!0})],LyraDialog.prototype,"fillBody",void 0),__decorate([property({type:Boolean,attribute:"with-footer",reflect:!0})],LyraDialog.prototype,"withFooter",void 0),__decorate([property({reflect:!0})],LyraDialog.prototype,"size",void 0),__decorate([property({attribute:"aria-label"})],LyraDialog.prototype,"hostAriaLabel",void 0),__decorate([property({type:Boolean,attribute:"light-dismiss"})],LyraDialog.prototype,"lightDismiss",void 0),__decorate([state()],LyraDialog.prototype,"hasFooterSlot",void 0),__decorate([state()],LyraDialog.prototype,"hasLabelSlot",void 0),__decorate([state()],LyraDialog.prototype,"hasHeaderActionsSlot",void 0),__decorate([state()],LyraDialog.prototype,"headingText",void 0);export{LyraDialog};
27
+ `,{part:"base",label:hasExplicitName?explicitName:void 0,labelledBy:useHeadingForName?this.headingId:void 0})}}__decorate([property({type:Boolean,reflect:!0})],LyraDialog.prototype,"open",null),__decorate([property({reflect:!0})],LyraDialog.prototype,"label",void 0),__decorate([property({attribute:"heading-level",reflect:!0})],LyraDialog.prototype,"headingLevel",void 0),__decorate([property()],LyraDialog.prototype,"heading",void 0),__decorate([property({type:Boolean,attribute:"without-close-button",reflect:!0})],LyraDialog.prototype,"withoutCloseButton",void 0),__decorate([property({type:Boolean,attribute:"without-header",reflect:!0})],LyraDialog.prototype,"withoutHeader",void 0),__decorate([property({type:Boolean,attribute:"no-header",reflect:!0})],LyraDialog.prototype,"noHeader",void 0),__decorate([property({type:Boolean,attribute:"fill-body",reflect:!0})],LyraDialog.prototype,"fillBody",void 0),__decorate([property({type:Boolean,attribute:"fullscreen-narrow",reflect:!0})],LyraDialog.prototype,"fullscreenNarrow",void 0),__decorate([property({type:Boolean,attribute:"with-footer",reflect:!0})],LyraDialog.prototype,"withFooter",void 0),__decorate([property({reflect:!0})],LyraDialog.prototype,"size",void 0),__decorate([property({attribute:"aria-label"})],LyraDialog.prototype,"hostAriaLabel",void 0),__decorate([property({type:Boolean,attribute:"light-dismiss"})],LyraDialog.prototype,"lightDismiss",void 0),__decorate([property({type:Boolean,attribute:"with-label"})],LyraDialog.prototype,"withLabel",void 0),__decorate([state()],LyraDialog.prototype,"hasFooterSlot",void 0),__decorate([state()],LyraDialog.prototype,"hasLabelSlot",void 0),__decorate([state()],LyraDialog.prototype,"hasHeaderActionsSlot",void 0),__decorate([state()],LyraDialog.prototype,"headingText",void 0);export{LyraDialog};
@@ -1 +1 @@
1
- import{modalHostStyles}from"../../../internal/native-modal-carrier.styles.js";import{dialogChrome,dialogOpenHost}from"../../../internal/modal-surface.styles.js";import{css}from"lit";import{glassSurface}from"../../../internal/glass-surface.styles.js";import{glassScrollLayerStyles}from"../../../internal/glass-scroll-layer.styles.js";import{glassIndependentRootStyles}from"../../../internal/glass-independent-root.styles.js";import{overlaySurface}from"../../../internal/overlay-surface.styles.js";import{activeFill,focusRingInwardOffset}from"../../../internal/interactive-control.styles.js";const styles=css` :host{--_lr-dialog-overlay-color:var(--lr-color-overlay);--_lr-dialog-max-width:var(--lr-size-32rem);--_lr-dialog-close-background:transparent;--_lr-dialog-close-background-hover:var(--lr-color-brand-quiet);--_lr-dialog-close-background-active: ${activeFill("var( --lr-icon-button-hover-bg, var(--lr-color-brand-quiet) )")};--_lr-dialog-close-color:var(--lr-color-text-quiet);--_lr-dialog-close-color-hover:var(--lr-color-brand);--_lr-dialog-close-color-active:var(--lr-icon-button-hover-color, var(--lr-color-brand));--_lr-dialog-close-radius:var(--lr-overlay-radius, var(--lr-radius));${modalHostStyles} ${dialogChrome}}${dialogOpenHost} :host([data-closing]){display:flex;pointer-events:none}:host([size='2xs']){--_lr-dialog-max-width:var(--lr-size-20rem)}:host([size=xs]){--_lr-dialog-max-width:var(--lr-size-24rem)}:host([size=s]),:host([size=small]){--_lr-dialog-max-width:var(--lr-size-28rem)}:host([size=l]),:host([size=large]){--_lr-dialog-max-width:var(--lr-size-38rem)}:host([size=xl]){--_lr-dialog-max-width:var(--lr-size-48rem)}[part~=base]{display:contents}[part~=backdrop]{position:absolute;inset:0;background:var(--lr-dialog-overlay-color,var(--_lr-dialog-overlay-color));backdrop-filter:var(--backdrop-filter,var(--lr-dialog-backdrop-filter,none))}[part~=panel]{position:relative;display:flex;flex-direction:column;min-inline-size:0;inline-size:var(--width,var(--lr-dialog-width,auto));max-inline-size:min(var(--lr-dialog-max-width,var(--width,var(--lr-dialog-width,var(--_lr-dialog-max-width)))),100%);block-size:var(--lr-dialog-height,auto);max-block-size:100%;--_lr-overlay-surface:var(--lr-color-surface-container-highest);${overlaySurface} box-shadow:var(--lr-overlay-shadow-modal,var(--lr-shadow-xl));overflow:auto}[part=header]{display:flex;flex-wrap:wrap;align-items:center;min-inline-size:0;max-inline-size:100%;gap:var(--lr-space-s);padding:var(--header-spacing,var(--spacing,var(--lr-dialog-spacing-block,var(--lr-space-m)) var(--lr-dialog-spacing,var(--lr-space-l))));border-block-end:var(--lr-border-width-thin) solid var(--lr-overlay-border,var(--lr-color-border-subtle))}[part~=heading]{flex:1 1 auto;min-inline-size:0;margin:0;font-family:var(--lr-dialog-heading-font-family,var(--lr-font-heading));font-size:var(--lr-dialog-heading-font-size,inherit);font-weight:var(--lr-dialog-heading-font-weight,var(--lr-font-weight-semibold));overflow:hidden;overflow-wrap:break-word;white-space:normal}[part=header-actions]{flex:1 1 auto;display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;min-inline-size:0;max-inline-size:100%;overflow-wrap:anywhere;gap:var(--lr-space-xs);margin-inline-start:auto}[part=header-actions] ::slotted(*){min-inline-size:0;max-inline-size:100%;overflow-wrap:anywhere}[part~=close-button]{flex:0 0 auto;margin-inline-start:auto;--_lr-icon-button-background-default:var(--_lr-dialog-close-background);--_lr-icon-button-background-hover-default:var(--_lr-dialog-close-background-hover);--_lr-icon-button-background-active-default:var(--_lr-dialog-close-background-active);--_lr-icon-button-color-default:var(--_lr-dialog-close-color);--_lr-icon-button-color-hover-default:var(--_lr-dialog-close-color-hover);--_lr-icon-button-color-active-default:var(--_lr-dialog-close-color-active);--_lr-icon-button-radius-default:var(--_lr-dialog-close-radius)}[part=header-actions] + [part~=close-button]{margin-inline-start:0}[part~=close-button] svg{display:block}[part=body]{flex:1 1 auto;min-inline-size:0;max-inline-size:100%;padding:var(--body-spacing,var(--spacing,var(--lr-dialog-spacing,var(--lr-space-l))));overflow:auto;overflow-wrap:anywhere}:host([fill-body]) [part=body]{display:flex;flex-direction:column;flex:1 1 auto;min-block-size:0}:host([fill-body]) [part=body] ::slotted(*){flex:1 1 auto;min-block-size:0}[part=body]:focus-visible{${focusRingInwardOffset}}[part=footer]{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;min-inline-size:0;max-inline-size:100%;gap:var(--lr-space-s);padding:var(--footer-spacing,var(--spacing,var(--lr-dialog-spacing-block,var(--lr-space-m)) var(--lr-dialog-spacing,var(--lr-space-l))));border-block-start:var(--lr-border-width-thin) solid var(--lr-overlay-border,var(--lr-color-border-subtle));overflow-wrap:anywhere}[part=footer] ::slotted(*){min-inline-size:0;max-inline-size:100%;overflow-wrap:anywhere}[part=footer][hidden]{display:none}${glassScrollLayerStyles} ${glassIndependentRootStyles} ${glassSurface('[part~="panel"]',css`var(--lr-overlay-surface, var(--_lr-overlay-surface, var(--lr-color-surface-container-highest)))`,void 0,!0)} `;export{styles};
1
+ import{modalHostStyles}from"../../../internal/native-modal-carrier.styles.js";import{dialogChrome,dialogOpenHost}from"../../../internal/modal-surface.styles.js";import{css}from"lit";import{glassSurface}from"../../../internal/glass-surface.styles.js";import{glassScrollLayerStyles}from"../../../internal/glass-scroll-layer.styles.js";import{glassIndependentRootStyles}from"../../../internal/glass-independent-root.styles.js";import{overlaySurface}from"../../../internal/overlay-surface.styles.js";import{activeFill,focusRingInwardOffset}from"../../../internal/interactive-control.styles.js";const styles=css` :host{--_lr-dialog-overlay-color:var(--lr-color-overlay);--_lr-dialog-max-width:var(--lr-size-32rem);--_lr-dialog-close-background:transparent;--_lr-dialog-close-background-hover:var(--lr-color-brand-quiet);--_lr-dialog-close-background-active: ${activeFill("var( --lr-icon-button-hover-bg, var(--lr-color-brand-quiet) )")};--_lr-dialog-close-color:var(--lr-color-text-quiet);--_lr-dialog-close-color-hover:var(--lr-color-brand);--_lr-dialog-close-color-active:var(--lr-icon-button-hover-color, var(--lr-color-brand));--_lr-dialog-close-radius:var(--lr-overlay-radius, var(--lr-radius));${modalHostStyles} ${dialogChrome} padding-block-start:max(var(--lr-dialog-viewport-inset,var(--lr-space-l)),var(--lr-safe-area-top));padding-block-end:max(var(--lr-dialog-viewport-inset,var(--lr-space-l)),var(--lr-safe-area-bottom));padding-inline-start:max(var(--lr-dialog-viewport-inset,var(--lr-space-l)),var(--lr-safe-area-inline-start));padding-inline-end:max(var(--lr-dialog-viewport-inset,var(--lr-space-l)),var(--lr-safe-area-inline-end))}${dialogOpenHost} :host([data-closing]){display:flex;pointer-events:none}:host([size='2xs']){--_lr-dialog-max-width:var(--lr-size-20rem)}:host([size=xs]){--_lr-dialog-max-width:var(--lr-size-24rem)}:host([size=s]),:host([size=small]){--_lr-dialog-max-width:var(--lr-size-28rem)}:host([size=l]),:host([size=large]){--_lr-dialog-max-width:var(--lr-size-38rem)}:host([size=xl]){--_lr-dialog-max-width:var(--lr-size-48rem)}[part~=base]{display:contents}[part~=backdrop]{position:absolute;inset:0;background:var(--lr-dialog-overlay-color,var(--backdrop-color,var(--_lr-dialog-overlay-color)));backdrop-filter:var(--backdrop-filter,var(--lr-dialog-backdrop-filter,none))}[part~=panel]{position:relative;display:flex;flex-direction:column;min-inline-size:0;inline-size:var(--width,var(--lr-dialog-width,auto));max-inline-size:min(var(--lr-dialog-max-width,var(--width,var(--lr-dialog-width,var(--_lr-dialog-max-width)))),100%);block-size:var(--lr-dialog-height,auto);max-block-size:min(var(--lr-dialog-max-height,100%),100%);--_lr-overlay-surface:var(--lr-color-surface-container-highest);--_lr-dialog-panel-fill:var( --lr-dialog-panel-bg, var(--lr-overlay-surface, var(--_lr-overlay-surface, var(--lr-color-surface-container-highest))) );${overlaySurface} box-shadow:var(--lr-overlay-shadow-modal,var(--lr-shadow-xl));overflow:auto}[part=header]{display:flex;flex-wrap:wrap;align-items:center;min-inline-size:0;max-inline-size:100%;gap:var(--lr-space-s);padding:var(--header-spacing,var(--spacing,var(--lr-dialog-spacing-block,var(--lr-space-m)) var(--lr-dialog-spacing,var(--lr-space-l))));border-block-end:var(--lr-dialog-header-border,var(--lr-border-width-thin) solid var(--lr-dialog-divider-color,var(--lr-overlay-border,var(--lr-color-border-subtle))))}[part~=heading]{flex:1 1 auto;min-inline-size:0;margin:0;font-family:var(--lr-dialog-heading-font-family,var(--lr-font-heading));font-size:var(--lr-dialog-heading-font-size,inherit);font-weight:var(--lr-dialog-heading-font-weight,var(--lr-font-weight-semibold));letter-spacing:var(--lr-dialog-heading-letter-spacing,normal);line-height:var(--lr-dialog-heading-line-height,inherit);overflow:hidden;overflow-wrap:break-word;white-space:normal}[part=header-actions]{flex:1 1 auto;display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;min-inline-size:0;max-inline-size:100%;overflow-wrap:anywhere;gap:var(--lr-space-xs);margin-inline-start:auto}[part=header-actions] ::slotted(*){min-inline-size:0;max-inline-size:100%;overflow-wrap:anywhere}[part~=close-button]{flex:0 0 auto;margin-inline-start:auto;--_lr-icon-button-background-default:var(--_lr-dialog-close-background);--_lr-icon-button-background-hover-default:var(--_lr-dialog-close-background-hover);--_lr-icon-button-background-active-default:var(--_lr-dialog-close-background-active);--_lr-icon-button-color-default:var(--_lr-dialog-close-color);--_lr-icon-button-color-hover-default:var(--_lr-dialog-close-color-hover);--_lr-icon-button-color-active-default:var(--_lr-dialog-close-color-active);--_lr-icon-button-radius-default:var(--_lr-dialog-close-radius)}[part=header-actions] + [part~=close-button]{margin-inline-start:0}[part~=close-button] svg{display:block}[part=body]{flex:1 1 auto;min-inline-size:0;max-inline-size:100%;padding:var(--body-spacing,var(--spacing,var(--lr-dialog-spacing,var(--lr-space-l))));overflow:var(--lr-dialog-body-overflow,auto);overflow-wrap:anywhere}:host([fill-body]) [part=body]{display:flex;flex-direction:column;flex:1 1 auto;min-block-size:0}:host([fill-body]) [part=body] ::slotted(*){flex:1 1 auto;min-block-size:0}[part=body]:focus-visible{${focusRingInwardOffset}}[part=footer]{display:flex;flex-wrap:wrap;align-items:center;justify-content:flex-end;min-inline-size:0;max-inline-size:100%;gap:var(--lr-space-s);padding:var(--footer-spacing,var(--spacing,var(--lr-dialog-spacing-block,var(--lr-space-m)) var(--lr-dialog-spacing,var(--lr-space-l))));border-block-start:var(--lr-border-width-thin) solid var(--lr-dialog-divider-color,var(--lr-overlay-border,var(--lr-color-border-subtle)));overflow-wrap:anywhere}[part=footer] ::slotted(*){min-inline-size:0;max-inline-size:100%;overflow-wrap:anywhere}[part=footer][hidden]{display:none}:host([fullscreen-narrow][data-fullscreen]){padding:0}:host([fullscreen-narrow][data-fullscreen]) [part~=panel]{box-sizing:border-box;inline-size:100%;max-inline-size:100%;block-size:100%;max-block-size:100%;border-radius:0;padding-block:var(--lr-safe-area-top) var(--lr-safe-area-bottom);padding-inline:var(--lr-safe-area-inline-start) var(--lr-safe-area-inline-end)}${glassScrollLayerStyles} ${glassIndependentRootStyles} ${glassSurface('[part~="panel"]',css`var(--_lr-dialog-panel-fill, var(--lr-overlay-surface, var(--_lr-overlay-surface, var(--lr-color-surface-container-highest))))`,void 0,!0)} `;export{styles};
@@ -0,0 +1,60 @@
1
+ import type{LyraSize}from'../../../internal/variants.js';import type{LyraHeadingLevel}from'../../../internal/heading-level.js';export interface PromptOptions{
2
+ /** Dialog title, rendered as the dialog's own header title (`[part~="heading"]`), which also
3
+ * names the dialog. */
4
+ title:string;
5
+ /** Visible label of the text field, which also names it.*/
6
+ label:string;
7
+ /** Optional supporting text rendered in the dialog body, above the field.*/
8
+ description?:string;
9
+ /** Initial value of the text field. Defaults to `''`.*/
10
+ value?:string;
11
+ /** Placeholder of the text field.*/
12
+ placeholder?:string;
13
+ /** Called with the current value when the user submits (the confirm button or Enter in the
14
+ * field). Return a message to reject the value: the message renders as the field's error text,
15
+ * the field is marked invalid and keeps focus, and the dialog stays open. Return `null`,
16
+ * `undefined` or `''` to accept it. The message is shown as given, so localize it yourself. */
17
+ validate?:(value:string)=>string|null|undefined;
18
+ /** Confirm button label. Defaults to the localized `'confirm'` message (`'Confirm'` in English).*/
19
+ confirmLabel?:string;
20
+ /** Cancel button label. Defaults to the localized `'cancel'` message (`'Cancel'` in English).*/
21
+ cancelLabel?:string;
22
+ /** Width tier of the dialog, forwarded to `<lr-dialog size>`. Defaults to `'m'`.*/
23
+ size?:LyraSize;
24
+ /** Semantic level of the header title, forwarded to `<lr-dialog heading-level>`. Defaults to
25
+ * `'2'`; `'none'` renders visual-only title text. */
26
+ headingLevel?:LyraHeadingLevel;
27
+ /** Space-separated classes added to the transient `<lr-dialog>`, so application styles can
28
+ * scope `--lr-dialog-*`, `--lr-input-*` and `--lr-button-*` tokens to prompts. */
29
+ className?:string;}
30
+ /**
31
+ * Ask for one line of text in a modal, resolving the submitted string, or `null` when the prompt
32
+ * is dismissed -- Escape, a backdrop click, the cancel button and removal all resolve `null`. A
33
+ * drop-in async replacement for `window.prompt()`, and the text-entry sibling of `confirm()`.
34
+ *
35
+ * The dialog holds one labelled `<lr-input>` that starts with `value` and receives focus when the
36
+ * dialog opens. Submitting -- the confirm button, or Enter in the field -- runs `validate()` first;
37
+ * a returned message renders as the field's error text, marks it invalid and keeps the dialog
38
+ * open, and typing clears it again. Like `confirm()`, it mounts a transient `<lr-dialog>` for the
39
+ * duration of the call and removes it after the exit animation, and every dismissal funnels
40
+ * through the dialog's own `close()`/`lr-close` path. Veto through `lr-hide` or `lr-close-request`
41
+ * to keep it open. Focus returns to the opener once it settles.
42
+ *
43
+ * Styling: the title is the dialog's own header title, so `--lr-dialog-heading-*` and
44
+ * `::part(heading)` apply. The field is an `<lr-input data-lr-prompt-field>`, so every
45
+ * `--lr-input-*` token applies. Both actions are `<lr-button>` elements in the `footer` slot
46
+ * (cancel is `appearance="outlined"`, confirm is `appearance="accent"` with `variant="brand"`),
47
+ * each carrying `data-lr-prompt-action="cancel" | "confirm"`. The description is a
48
+ * `<p data-lr-prompt-description>` with zero-specificity defaults. `className` adds classes to the
49
+ * dialog to scope those rules.
50
+ *
51
+ * @example
52
+ * const name = await prompt({
53
+ * title: 'Rename conversation',
54
+ * label: 'Name',
55
+ * value: conversation.name,
56
+ * validate: (value) => (value.trim() ? null : 'Enter a name'),
57
+ * });
58
+ * if (name !== null) renameConversation(name);
59
+ */
60
+ export declare function prompt(options:PromptOptions):Promise<string|null>;
@@ -0,0 +1 @@
1
+ import{LyraDialog}from"./dialog.class.js";import{defineElement,tag}from"../../../internal/prefix.js";import{LYRA_DEFAULT_cancel,LYRA_DEFAULT_confirm}from"../../../internal/default-strings/shared.generated.js";import{resolveLyraString}from"../../../internal/localization-runtime.js";import{LyraButton}from"../../forms/button/button.class.js";import{LyraInput}from"../../forms/input/input.class.js";const PROMPT_DEFAULT_STRINGS=/* @__PURE__ */(()=>Object.freeze({cancel:LYRA_DEFAULT_cancel,confirm:LYRA_DEFAULT_confirm}))(),DESCRIPTION_ATTRIBUTE=`data-${tag("prompt-description")}`,ACTION_ATTRIBUTE=`data-${tag("prompt-action")}`,FIELD_ATTRIBUTE=`data-${tag("prompt-field")}`,PROMPT_STYLE=`:where([${DESCRIPTION_ATTRIBUTE}]) { margin: 0 0 var(--lr-space-m); color: var(--lr-color-text-quiet); }`;function createAction(action,label,onClick){const button=document.createElement(tag("button"));return button.variant=action==="cancel"?"neutral":"brand",button.appearance=action==="cancel"?"outlined":"accent",button.textContent=label,button.slot="footer",button.setAttribute(ACTION_ATTRIBUTE,action),button.addEventListener("click",onClick),button}function prompt(options){defineElement("dialog",LyraDialog),defineElement("button",LyraButton),defineElement("input",LyraInput);const{title,label,description,value,placeholder,validate,confirmLabel,cancelLabel,size,headingLevel,className}=options;return new Promise(resolve=>{const dialog=document.createElement(tag("dialog"));dialog.lightDismiss=!0,dialog.withoutCloseButton=!0,dialog.label=title,dialog.headingLevel=headingLevel??"2",size&&(dialog.size=size),className&&dialog.classList.add(...className.split(/\s+/).filter(Boolean));const style=document.createElement("style");if(style.textContent=PROMPT_STYLE,dialog.append(style),description){const desc=document.createElement("p");desc.textContent=description,desc.setAttribute(DESCRIPTION_ATTRIBUTE,""),dialog.append(desc)}const field=document.createElement(tag("input"));field.label=label,field.value=value??"",placeholder&&(field.placeholder=placeholder),field.setAttribute(FIELD_ATTRIBUTE,""),dialog.append(field);let accepted=null;const submit=()=>{if(!dialog.open)return;const current=field.value,error=validate?.(current);if(error){field.errorText=error,field.focus();return}field.errorText="",accepted=current,dialog.close("confirm")};field.addEventListener("lr-input",()=>{field.errorText&&(field.errorText="")}),field.addEventListener("keydown",event=>{event.key!=="Enter"||event.isComposing||event.defaultPrevented||(event.preventDefault(),submit())}),dialog.addEventListener("lr-initial-focus",event=>{event.target===dialog&&(event.preventDefault(),field.focus())}),dialog.addEventListener("lr-close",event=>{if(event.target!==dialog)return;const reason=event.detail.reason;resolve(reason==="confirm"?accepted??field.value:null)}),dialog.addEventListener("lr-after-hide",event=>{event.target===dialog&&dialog.remove()}),dialog.append(createAction("cancel",resolveLyraString(dialog,"cancel",void 0,cancelLabel,void 0,PROMPT_DEFAULT_STRINGS),()=>{dialog.close("cancel")}),createAction("confirm",resolveLyraString(dialog,"confirm",void 0,confirmLabel,void 0,PROMPT_DEFAULT_STRINGS),submit)),dialog.open=!0,document.body.appendChild(dialog)})}export{prompt};