@aceshooting/lyra-ui 19.0.1 → 20.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (418) hide show
  1. package/CHANGELOG.md +159 -0
  2. package/custom-elements.json +1 -1
  3. package/dist/cli/migration-contract.json +1 -1
  4. package/dist/components/agent-tools/activity-feed/activity-feed.class.d.ts +14 -4
  5. package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +1 -1
  6. package/dist/components/agent-tools/approval-queue/approval-queue.class.d.ts +1 -0
  7. package/dist/components/agent-tools/approval-queue/approval-queue.class.js +4 -3
  8. package/dist/components/agent-tools/approval-queue/approval-queue.styles.js +1 -1
  9. package/dist/components/agent-tools/artifact-panel/artifact-panel.class.d.ts +3 -1
  10. package/dist/components/agent-tools/context-inspector/context-inspector.class.d.ts +1 -0
  11. package/dist/components/agent-tools/context-inspector/context-inspector.class.js +4 -3
  12. package/dist/components/agent-tools/context-inspector/context-inspector.styles.js +1 -1
  13. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
  14. package/dist/components/agent-tools/eval-result/eval-result.class.js +1 -1
  15. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +1 -0
  16. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +4 -3
  17. package/dist/components/agent-tools/evaluation-run/evaluation-run.styles.js +1 -1
  18. package/dist/components/agent-tools/policy-summary/policy-summary.class.d.ts +1 -0
  19. package/dist/components/agent-tools/policy-summary/policy-summary.class.js +4 -3
  20. package/dist/components/agent-tools/policy-summary/policy-summary.styles.js +1 -1
  21. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.js +1 -1
  22. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.d.ts +10 -1
  23. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.js +3 -3
  24. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +1 -1
  25. package/dist/components/agent-tools/thinking-panel/thinking-panel.class.d.ts +6 -3
  26. package/dist/components/agent-tools/thinking-panel/thinking-panel.styles.js +1 -1
  27. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +14 -3
  28. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +2 -2
  29. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.d.ts +12 -2
  30. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +3 -1
  31. package/dist/components/charts/chart/box-plot.class.d.ts +15 -3
  32. package/dist/components/charts/chart/box-plot.class.js +3 -3
  33. package/dist/components/charts/chart/box-plot.styles.js +1 -1
  34. package/dist/components/charts/chart/chart.class.d.ts +23 -5
  35. package/dist/components/charts/chart/chart.class.js +2 -2
  36. package/dist/components/charts/chart/chart.styles.js +1 -1
  37. package/dist/components/charts/chart/lite-chart.class.js +1 -1
  38. package/dist/components/charts/chart/lite-chart.styles.js +1 -1
  39. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.d.ts +4 -2
  40. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.js +1 -1
  41. package/dist/components/conversation/branch-picker/branch-picker.class.d.ts +4 -2
  42. package/dist/components/conversation/branch-picker/branch-picker.class.js +1 -1
  43. package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +4 -3
  44. package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
  45. package/dist/components/conversation/code-block/code-block-core.class.d.ts +6 -11
  46. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  47. package/dist/components/conversation/code-block/code-block-shared.d.ts +29 -1
  48. package/dist/components/conversation/code-block/code-block-shared.js +1 -1
  49. package/dist/components/conversation/code-block/code-block.class.d.ts +6 -11
  50. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  51. package/dist/components/conversation/markdown/markdown-shared.js +2 -2
  52. package/dist/components/conversation/message-actions/message-actions.class.d.ts +4 -2
  53. package/dist/components/conversation/message-actions/message-actions.class.js +2 -2
  54. package/dist/components/conversation/message-parts/message-parts.class.d.ts +17 -2
  55. package/dist/components/conversation/model-select/model-select.class.js +1 -0
  56. package/dist/components/conversation/model-select/model-select.styles.js +1 -1
  57. package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +5 -1
  58. package/dist/components/conversation/prompt-input/prompt-input.class.js +2 -2
  59. package/dist/components/conversation/prompt-queue/prompt-queue.class.d.ts +6 -1
  60. package/dist/components/conversation/prompt-queue/prompt-queue.class.js +2 -2
  61. package/dist/components/conversation/realtime-session/realtime-session.class.d.ts +5 -1
  62. package/dist/components/conversation/realtime-session/realtime-session.class.js +1 -1
  63. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +5 -1
  64. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  65. package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +13 -2
  66. package/dist/components/conversation/voice-picker/voice-picker.class.js +5 -3
  67. package/dist/components/conversation/voice-picker/voice-picker.styles.js +1 -1
  68. package/dist/components/data/calendar/calendar.class.d.ts +9 -0
  69. package/dist/components/data/calendar/calendar.class.js +2 -2
  70. package/dist/components/data/calendar/calendar.styles.js +1 -1
  71. package/dist/components/data/condition-builder/condition-builder.class.d.ts +5 -1
  72. package/dist/components/data/context-meter/context-meter.class.d.ts +4 -0
  73. package/dist/components/data/context-meter/context-meter.styles.js +1 -1
  74. package/dist/components/data/data-grid/data-grid.class.d.ts +8 -2
  75. package/dist/components/data/data-grid/data-grid.class.js +1 -2
  76. package/dist/components/data/flow-node/flow-node.class.d.ts +7 -4
  77. package/dist/components/data/flow-node/flow-node.styles.js +1 -1
  78. package/dist/components/data/funnel/funnel.class.d.ts +5 -0
  79. package/dist/components/data/funnel/funnel.class.js +4 -3
  80. package/dist/components/data/funnel/funnel.styles.js +1 -1
  81. package/dist/components/data/gauge/gauge.class.d.ts +12 -1
  82. package/dist/components/data/gauge/gauge.styles.js +1 -1
  83. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +50 -13
  84. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +2 -2
  85. package/dist/components/data/graph-query-builder/graph-query-builder.styles.js +1 -1
  86. package/dist/components/data/heatmap/heatmap.class.d.ts +27 -9
  87. package/dist/components/data/heatmap/heatmap.class.js +5 -3
  88. package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +2 -0
  89. package/dist/components/data/sequence-strip/sequence-strip.styles.js +1 -1
  90. package/dist/components/data/table/table.class.d.ts +8 -0
  91. package/dist/components/data/table/table.class.js +2 -1
  92. package/dist/components/data/tree/tree.class.d.ts +20 -1
  93. package/dist/components/data/tree/tree.class.js +1 -1
  94. package/dist/components/data/word-cloud/word-cloud.class.d.ts +4 -1
  95. package/dist/components/data/word-cloud/word-cloud.class.js +2 -2
  96. package/dist/components/forms/button/button.class.js +1 -1
  97. package/dist/components/forms/checkbox/checkbox.class.d.ts +11 -8
  98. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  99. package/dist/components/forms/checkbox/checkbox.styles.js +1 -1
  100. package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +2 -2
  101. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  102. package/dist/components/forms/code-editor/code-editor.class.d.ts +2 -0
  103. package/dist/components/forms/code-editor/code-editor.class.js +1 -1
  104. package/dist/components/forms/code-editor/code-editor.styles.js +1 -1
  105. package/dist/components/forms/color-picker/color-picker.class.d.ts +11 -1
  106. package/dist/components/forms/color-picker/color-picker.class.js +4 -3
  107. package/dist/components/forms/combobox/combobox.class.d.ts +67 -18
  108. package/dist/components/forms/combobox/combobox.class.js +7 -6
  109. package/dist/components/forms/combobox/combobox.styles.js +1 -1
  110. package/dist/components/forms/date-picker/date-input.class.d.ts +22 -2
  111. package/dist/components/forms/date-picker/date-input.class.js +4 -2
  112. package/dist/components/forms/date-picker/date-input.styles.js +1 -1
  113. package/dist/components/forms/emoji-picker/emoji-data-loader.d.ts +18 -4
  114. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  115. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +18 -4
  116. package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
  117. package/dist/components/forms/emoji-picker/emoji-picker.styles.js +1 -1
  118. package/dist/components/forms/icon-button/icon-button.class.d.ts +1 -1
  119. package/dist/components/forms/input/time-input.class.d.ts +11 -1
  120. package/dist/components/forms/input/time-input.class.js +4 -3
  121. package/dist/components/forms/input/time-input.styles.js +1 -1
  122. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +17 -3
  123. package/dist/components/forms/locale-picker/locale-picker.class.js +3 -2
  124. package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
  125. package/dist/components/forms/otp-input/otp-input.class.d.ts +13 -5
  126. package/dist/components/forms/otp-input/otp-input.class.js +2 -2
  127. package/dist/components/forms/otp-input/otp-input.styles.js +1 -1
  128. package/dist/components/forms/phone-input/phone-input.class.d.ts +10 -3
  129. package/dist/components/forms/phone-input/phone-input.class.js +6 -2
  130. package/dist/components/forms/phone-input/phone-input.styles.js +1 -1
  131. package/dist/components/forms/radio/radio-group.class.d.ts +1 -1
  132. package/dist/components/forms/radio/radio-group.class.js +2 -2
  133. package/dist/components/forms/rubric-form/rubric-form.class.d.ts +9 -1
  134. package/dist/components/forms/rubric-form/rubric-form.class.js +5 -3
  135. package/dist/components/forms/select/select.class.d.ts +4 -0
  136. package/dist/components/forms/select/select.styles.js +1 -1
  137. package/dist/components/forms/slider/slider.class.d.ts +5 -1
  138. package/dist/components/forms/slider/slider.class.js +3 -3
  139. package/dist/components/forms/switch/switch.class.d.ts +6 -5
  140. package/dist/components/forms/switch/switch.class.js +1 -1
  141. package/dist/components/forms/time-range/time-range.class.d.ts +2 -2
  142. package/dist/components/forms/token-input/token-input.class.d.ts +13 -3
  143. package/dist/components/forms/token-input/token-input.class.js +3 -1
  144. package/dist/components/layout/carousel/carousel.class.d.ts +4 -1
  145. package/dist/components/layout/carousel/carousel.class.js +1 -1
  146. package/dist/components/layout/command-palette/command-palette.class.d.ts +8 -2
  147. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  148. package/dist/components/layout/command-palette/command-palette.styles.js +1 -1
  149. package/dist/components/layout/details/accordion.class.js +1 -1
  150. package/dist/components/layout/dock-panel/dock-panel.class.d.ts +10 -7
  151. package/dist/components/layout/dock-panel/dock-panel.class.js +2 -2
  152. package/dist/components/layout/dock-panel/dock-panel.styles.js +1 -1
  153. package/dist/components/layout/menu/menu.class.d.ts +13 -3
  154. package/dist/components/layout/menu/menu.class.js +4 -3
  155. package/dist/components/layout/menu/menu.styles.js +1 -1
  156. package/dist/components/layout/page/page.class.d.ts +7 -1
  157. package/dist/components/layout/reorder-list/reorder-list.class.d.ts +1 -1
  158. package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
  159. package/dist/components/layout/segmented/segmented.class.d.ts +2 -0
  160. package/dist/components/layout/segmented/segmented.styles.js +1 -1
  161. package/dist/components/layout/virtual-list/virtual-list.styles.js +1 -1
  162. package/dist/components/layout/widget/widget.class.d.ts +15 -2
  163. package/dist/components/layout/widget/widget.class.js +1 -1
  164. package/dist/components/layout/widget/widget.styles.js +1 -1
  165. package/dist/components/media/avatar/avatar.class.d.ts +4 -0
  166. package/dist/components/media/avatar/avatar.styles.js +1 -1
  167. package/dist/components/media/avatar-group/avatar-group.class.d.ts +8 -1
  168. package/dist/components/media/avatar-group/avatar-group.styles.js +1 -1
  169. package/dist/components/media/drop-zone/drop-zone.class.d.ts +10 -4
  170. package/dist/components/media/drop-zone/drop-zone.class.js +2 -2
  171. package/dist/components/media/drop-zone/drop-zone.styles.js +1 -1
  172. package/dist/components/media/flag/flag.class.js +1 -1
  173. package/dist/components/media/map/map.class.d.ts +19 -5
  174. package/dist/components/media/map/map.class.js +3 -3
  175. package/dist/components/media/video-playlist/video-playlist.class.d.ts +6 -3
  176. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  177. package/dist/components/overlays/callout/callout.class.d.ts +4 -1
  178. package/dist/components/overlays/dialog/dialog.class.d.ts +4 -1
  179. package/dist/components/overlays/overlay/overlay.styles.js +1 -1
  180. package/dist/components/overlays/overlay/popover.class.d.ts +9 -1
  181. package/dist/components/overlays/overlay/popover.class.js +3 -2
  182. package/dist/components/overlays/overlay/tooltip.class.d.ts +14 -4
  183. package/dist/components/overlays/overlay/tooltip.class.js +3 -2
  184. package/dist/components/overlays/popup/popup.class.d.ts +15 -1
  185. package/dist/components/overlays/popup/popup.class.js +3 -3
  186. package/dist/components/overlays/popup/popup.styles.js +1 -1
  187. package/dist/components/overlays/progress/progress-bar.class.d.ts +2 -0
  188. package/dist/components/overlays/progress/progress.styles.js +1 -1
  189. package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +4 -2
  190. package/dist/components/retrieval/citation-badge/citation-badge.class.js +1 -1
  191. package/dist/components/retrieval/claim-evidence/claim-evidence.class.d.ts +4 -0
  192. package/dist/components/retrieval/claim-evidence/claim-evidence.class.js +4 -3
  193. package/dist/components/retrieval/claim-evidence/claim-evidence.styles.js +1 -1
  194. package/dist/components/retrieval/community-card/community-card.class.d.ts +6 -1
  195. package/dist/components/retrieval/community-card/community-card.styles.js +1 -1
  196. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.d.ts +9 -1
  197. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +4 -3
  198. package/dist/components/retrieval/entity-card/entity-card.styles.js +1 -1
  199. package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +4 -2
  200. package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
  201. package/dist/components/retrieval/entity-dossier/entity-dossier.class.js +2 -2
  202. package/dist/components/retrieval/graph-legend/graph-legend.class.d.ts +18 -4
  203. package/dist/components/retrieval/graph-legend/graph-legend.class.js +2 -2
  204. package/dist/components/retrieval/grounding-summary/grounding-summary.class.d.ts +7 -0
  205. package/dist/components/retrieval/grounding-summary/grounding-summary.class.js +4 -3
  206. package/dist/components/retrieval/grounding-summary/grounding-summary.styles.js +1 -1
  207. package/dist/components/retrieval/memory-panel/memory-panel.class.d.ts +6 -0
  208. package/dist/components/retrieval/memory-panel/memory-panel.class.js +4 -3
  209. package/dist/components/retrieval/memory-panel/memory-panel.styles.js +1 -1
  210. package/dist/components/retrieval/mind-map/mind-map-layout.d.ts +17 -1
  211. package/dist/components/retrieval/mind-map/mind-map-layout.js +1 -1
  212. package/dist/components/retrieval/mind-map/mind-map.class.d.ts +8 -1
  213. package/dist/components/retrieval/mind-map/mind-map.class.js +3 -2
  214. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +5 -0
  215. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +6 -5
  216. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.styles.js +1 -1
  217. package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.js +5 -5
  218. package/dist/components/retrieval/retrieval-compare/retrieval-compare.styles.js +1 -1
  219. package/dist/components/retrieval/source-list/source-list.class.d.ts +21 -2
  220. package/dist/components/retrieval/source-list/source-list.class.js +2 -2
  221. package/dist/components/retrieval/source-list/source-list.styles.js +1 -1
  222. package/dist/components/retrieval/source-picker/source-picker.class.d.ts +3 -1
  223. package/dist/components/retrieval/source-picker/source-picker.class.js +2 -2
  224. package/dist/components/utility/diff-view/diff-view.class.d.ts +105 -8
  225. package/dist/components/utility/diff-view/diff-view.class.js +21 -5
  226. package/dist/components/utility/diff-view/diff-view.styles.js +1 -1
  227. package/dist/components/utility/export-button/export-button.class.d.ts +26 -2
  228. package/dist/components/utility/export-button/export-button.class.js +4 -2
  229. package/dist/components/utility/export-button/export-button.styles.js +1 -1
  230. package/dist/components/utility/mention-popover/mention-popover.class.d.ts +19 -1
  231. package/dist/components/utility/mention-popover/mention-popover.class.js +3 -2
  232. package/dist/components/utility/mention-popover/mention-popover.styles.js +1 -1
  233. package/dist/components/utility/tour/tour.class.d.ts +1 -3
  234. package/dist/components/utility/tour/tour.class.js +1 -1
  235. package/dist/components/viewers/archive-viewer/archive-viewer.class.d.ts +20 -3
  236. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  237. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  238. package/dist/components/viewers/geojson-view/geojson-view.styles.js +1 -1
  239. package/dist/components/viewers/geojson-view/geojson-viewer.class.d.ts +5 -0
  240. package/dist/components/viewers/geojson-view/geojson-viewer.class.js +6 -3
  241. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +7 -1
  242. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +1 -1
  243. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.d.ts +7 -1
  244. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
  245. package/dist/components/viewers/xml-viewer/xml-viewer.class.d.ts +5 -0
  246. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
  247. package/dist/custom-elements-jsx.d.ts +1 -1
  248. package/dist/events.d.ts +79 -30
  249. package/dist/internal/accessibility-visibility.js +1 -1
  250. package/dist/internal/aria-reflection.js +1 -1
  251. package/dist/internal/catalog-picker.d.ts +14 -3
  252. package/dist/internal/catalog-picker.js +1 -1
  253. package/dist/internal/default-strings.generated.d.ts +1 -1
  254. package/dist/internal/default-strings.generated.js +2 -2
  255. package/dist/internal/localization-types.d.ts +1 -1
  256. package/dist/internal/localization.js +2 -2
  257. package/dist/internal/lyra-element.d.ts +17 -0
  258. package/dist/internal/lyra-element.js +2 -2
  259. package/dist/internal/package-metadata.d.ts +1 -1
  260. package/dist/internal/package-metadata.js +1 -1
  261. package/dist/svelte.d.ts +1 -1
  262. package/dist/testing/lyra-tag-event-map.js +1 -1
  263. package/dist/translations/ar/agent-tools.js +1 -1
  264. package/dist/translations/ar/data.js +1 -1
  265. package/dist/translations/ar/retrieval.js +1 -1
  266. package/dist/translations/ar/shared.js +1 -1
  267. package/dist/translations/ar/viewers.js +1 -1
  268. package/dist/translations/de/agent-tools.js +1 -1
  269. package/dist/translations/de/data.js +1 -1
  270. package/dist/translations/de/retrieval.js +1 -1
  271. package/dist/translations/de/shared.js +1 -1
  272. package/dist/translations/de/viewers.js +1 -1
  273. package/dist/translations/es/agent-tools.js +1 -1
  274. package/dist/translations/es/data.js +1 -1
  275. package/dist/translations/es/retrieval.js +1 -1
  276. package/dist/translations/es/shared.js +1 -1
  277. package/dist/translations/es/viewers.js +1 -1
  278. package/dist/translations/fa/agent-tools.js +1 -1
  279. package/dist/translations/fa/data.js +1 -1
  280. package/dist/translations/fa/retrieval.js +1 -1
  281. package/dist/translations/fa/shared.js +1 -1
  282. package/dist/translations/fa/viewers.js +1 -1
  283. package/dist/translations/fr/agent-tools.js +1 -1
  284. package/dist/translations/fr/data.js +1 -1
  285. package/dist/translations/fr/retrieval.js +1 -1
  286. package/dist/translations/fr/shared.js +1 -1
  287. package/dist/translations/fr/viewers.js +1 -1
  288. package/dist/translations/he/agent-tools.js +1 -1
  289. package/dist/translations/he/data.js +1 -1
  290. package/dist/translations/he/retrieval.js +1 -1
  291. package/dist/translations/he/shared.js +1 -1
  292. package/dist/translations/he/viewers.js +1 -1
  293. package/dist/translations/it/agent-tools.js +1 -1
  294. package/dist/translations/it/data.js +1 -1
  295. package/dist/translations/it/retrieval.js +1 -1
  296. package/dist/translations/it/shared.js +1 -1
  297. package/dist/translations/it/viewers.js +1 -1
  298. package/dist/translations/ja/agent-tools.js +1 -1
  299. package/dist/translations/ja/data.js +1 -1
  300. package/dist/translations/ja/retrieval.js +1 -1
  301. package/dist/translations/ja/shared.js +1 -1
  302. package/dist/translations/ja/viewers.js +1 -1
  303. package/dist/translations/pt-BR/agent-tools.js +1 -1
  304. package/dist/translations/pt-BR/data.js +1 -1
  305. package/dist/translations/pt-BR/retrieval.js +1 -1
  306. package/dist/translations/pt-BR/shared.js +1 -1
  307. package/dist/translations/pt-BR/viewers.js +1 -1
  308. package/dist/translations/ro/agent-tools.js +1 -1
  309. package/dist/translations/ro/data.js +1 -1
  310. package/dist/translations/ro/retrieval.js +1 -1
  311. package/dist/translations/ro/shared.js +1 -1
  312. package/dist/translations/ro/viewers.js +1 -1
  313. package/dist/translations/ru/agent-tools.js +1 -1
  314. package/dist/translations/ru/data.js +1 -1
  315. package/dist/translations/ru/retrieval.js +1 -1
  316. package/dist/translations/ru/shared.js +1 -1
  317. package/dist/translations/ru/viewers.js +1 -1
  318. package/dist/translations/zh-CN/agent-tools.js +1 -1
  319. package/dist/translations/zh-CN/data.js +1 -1
  320. package/dist/translations/zh-CN/retrieval.js +1 -1
  321. package/dist/translations/zh-CN/shared.js +1 -1
  322. package/dist/translations/zh-CN/viewers.js +1 -1
  323. package/dist/vue.d.ts +1 -1
  324. package/llms/components/lr-activity-feed.md +20 -9
  325. package/llms/components/lr-approval-queue.md +3 -2
  326. package/llms/components/lr-archive-viewer.md +8 -1
  327. package/llms/components/lr-artifact-panel.md +3 -1
  328. package/llms/components/lr-audio-visualizer.md +3 -1
  329. package/llms/components/lr-avatar-group.md +13 -6
  330. package/llms/components/lr-avatar.md +6 -2
  331. package/llms/components/lr-bar-chart.md +6 -3
  332. package/llms/components/lr-box-plot.md +6 -2
  333. package/llms/components/lr-branch-picker.md +3 -1
  334. package/llms/components/lr-bubble-chart.md +6 -3
  335. package/llms/components/lr-calendar.md +10 -3
  336. package/llms/components/lr-carousel.md +4 -2
  337. package/llms/components/lr-chart.md +12 -4
  338. package/llms/components/lr-chat-viewport.md +3 -2
  339. package/llms/components/lr-checkbox.md +8 -5
  340. package/llms/components/lr-citation-badge.md +2 -0
  341. package/llms/components/lr-claim-evidence.md +6 -2
  342. package/llms/components/lr-code-editor.md +3 -1
  343. package/llms/components/lr-color-picker.md +20 -8
  344. package/llms/components/lr-combobox.md +26 -3
  345. package/llms/components/lr-command-palette.md +6 -3
  346. package/llms/components/lr-community-card.md +7 -4
  347. package/llms/components/lr-context-inspector.md +3 -2
  348. package/llms/components/lr-context-meter.md +13 -5
  349. package/llms/components/lr-data-grid.md +2 -0
  350. package/llms/components/lr-date-input.md +12 -3
  351. package/llms/components/lr-date-picker.md +11 -2
  352. package/llms/components/lr-diff-view.md +46 -5
  353. package/llms/components/lr-doughnut-chart.md +6 -3
  354. package/llms/components/lr-drop-zone.md +7 -3
  355. package/llms/components/lr-embedding-explorer.md +8 -2
  356. package/llms/components/lr-emoji-picker.md +5 -1
  357. package/llms/components/lr-entity-chip.md +2 -0
  358. package/llms/components/lr-eval-run.md +3 -2
  359. package/llms/components/lr-export-button.md +5 -2
  360. package/llms/components/lr-flow-node.md +7 -4
  361. package/llms/components/lr-funnel.md +7 -2
  362. package/llms/components/lr-gauge.md +7 -2
  363. package/llms/components/lr-geojson-view.md +10 -2
  364. package/llms/components/lr-geojson-viewer.md +10 -2
  365. package/llms/components/lr-graph-legend.md +6 -3
  366. package/llms/components/lr-graph-query-builder.md +21 -11
  367. package/llms/components/lr-grounding-summary.md +8 -2
  368. package/llms/components/lr-heatmap.md +5 -2
  369. package/llms/components/lr-histogram.md +4 -2
  370. package/llms/components/lr-json-schema-viewer.md +7 -5
  371. package/llms/components/lr-line-chart.md +6 -3
  372. package/llms/components/lr-locale-picker.md +4 -1
  373. package/llms/components/lr-map.md +5 -3
  374. package/llms/components/lr-memory-panel.md +6 -2
  375. package/llms/components/lr-mention-popover.md +7 -4
  376. package/llms/components/lr-message-actions.md +3 -1
  377. package/llms/components/lr-message-parts.md +8 -2
  378. package/llms/components/lr-mind-map.md +11 -2
  379. package/llms/components/lr-option.md +25 -2
  380. package/llms/components/lr-otp-input.md +3 -1
  381. package/llms/components/lr-phone-input.md +9 -5
  382. package/llms/components/lr-pie-chart.md +6 -3
  383. package/llms/components/lr-polar-area-chart.md +6 -3
  384. package/llms/components/lr-policy-summary.md +3 -2
  385. package/llms/components/lr-progress-bar.md +4 -1
  386. package/llms/components/lr-prompt-input.md +4 -1
  387. package/llms/components/lr-prompt-queue.md +5 -2
  388. package/llms/components/lr-radar-chart.md +6 -3
  389. package/llms/components/lr-rag-eval-dashboard.md +7 -2
  390. package/llms/components/lr-realtime-session.md +3 -1
  391. package/llms/components/lr-rubric-form.md +6 -1
  392. package/llms/components/lr-scatter-chart.md +6 -3
  393. package/llms/components/lr-segmented.md +3 -1
  394. package/llms/components/lr-select.md +7 -1
  395. package/llms/components/lr-selection-toolbar.md +4 -1
  396. package/llms/components/lr-sequence-strip.md +7 -3
  397. package/llms/components/lr-source-card.md +16 -1
  398. package/llms/components/lr-source-list.md +17 -2
  399. package/llms/components/lr-source-picker.md +3 -1
  400. package/llms/components/lr-subagent-panel.md +6 -3
  401. package/llms/components/lr-switch.md +4 -3
  402. package/llms/components/lr-table.md +6 -1
  403. package/llms/components/lr-thinking-panel.md +8 -5
  404. package/llms/components/lr-token-input.md +15 -1
  405. package/llms/components/lr-tool-call-chip.md +2 -0
  406. package/llms/components/lr-tool-param-form.md +15 -4
  407. package/llms/components/lr-tooltip.md +8 -4
  408. package/llms/components/lr-trace-tree.md +7 -4
  409. package/llms/components/lr-video-playlist.md +7 -5
  410. package/llms/components/lr-voice-picker.md +7 -4
  411. package/llms/components/lr-widget.md +15 -2
  412. package/llms/migration.md +4 -4
  413. package/llms-full.txt +552 -159
  414. package/package.json +11 -9
  415. package/registrations.json +1 -1
  416. package/vscode-css-data.json +1 -1
  417. package/vscode-html-data.json +1 -1
  418. package/web-types.json +1 -1
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{tag}from"../../../internal/prefix.js";import{isRtl}from"../../../internal/rtl.js";import{styles}from"./tree.styles.js";import{cascadeUpdateComplete}from"./update-cascade.js";import{configureTreeItemOwner,setTreeItemSelection,treeItemOwnerContext}from"./tree-owner-controller.js";import"./tree-item.class.js";import{TREE_MAX_RENDER_DEPTH,TREE_MAX_RENDER_NODES}from"./tree-types.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_noData,LYRA_DEFAULT_treeNodeMoved}from"../../../internal/default-strings.generated.js";const TREE_SELECTIONS=new Set(["single","multiple","leaf","leaf-multiple"]),TREE_BADGE_LIMIT=100,TREE_MAX_INSPECTED_POSITIONS=1e4,EMPTY_TREE_DATA=Object.freeze([]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function arrayLength(value){if(!Array.isArray(value))return 0;try{return Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,Math.trunc(value.length)))}catch{return 0}}function normalizeBadges(value){if(!Array.isArray(value))return{truncated:value!==void 0};const badges=[],length=arrayLength(value);for(let index=0;index<Math.min(length,TREE_BADGE_LIMIT);index++){const raw=ownValue(value,String(index));if(!raw||typeof raw!="object"||Array.isArray(raw))continue;const text=ownValue(raw,"text");if(typeof text!="string")continue;const rawTone=ownValue(raw,"tone"),tone=rawTone==="brand"||rawTone==="success"||rawTone==="warning"||rawTone==="danger"?rawTone:"neutral",rawLabel=ownValue(raw,"label");badges.push(Object.freeze({text,tone,...typeof rawLabel=="string"?{label:rawLabel}:{}}))}return{badges:Object.freeze(badges),truncated:length>TREE_BADGE_LIMIT}}function normalizeTreeData(input){if(!Array.isArray(input))return{data:EMPTY_TREE_DATA,declaredChildrenAtPath:new Map,declaredRootCount:0,truncated:input!=null};const root=[],declaredChildrenAtPath=new Map,created=[],rootLength=arrayLength(input);let truncated=!1,accepted=0,inspected=0;const seenIds=new Set,identityFilteredCollections=new Set,jobs=[{source:input,index:0,length:rootLength,target:root,parentPath:"",depth:0,ancestors:new Set}];for(;jobs.length>0;){const job=jobs[jobs.length-1];if(job.index>=job.length){jobs.pop();continue}if(accepted>=TREE_MAX_RENDER_NODES||inspected>=TREE_MAX_INSPECTED_POSITIONS){truncated=!0;break}const raw=ownValue(job.source,String(job.index++));if(inspected++,inspected===TREE_MAX_INSPECTED_POSITIONS&&(truncated=!0),!raw||typeof raw!="object"||Array.isArray(raw)){truncated=!0,identityFilteredCollections.add(job.target);continue}const id=ownValue(raw,"id"),label=ownValue(raw,"label");if(typeof id!="string"||id.trim()===""||seenIds.has(id)||typeof label!="string"){truncated=!0,identityFilteredCollections.add(job.target);continue}seenIds.add(id);const node={id,label},selected=ownValue(raw,"selected"),disabled=ownValue(raw,"disabled"),lazy=ownValue(raw,"lazy");typeof selected=="boolean"&&(node.selected=selected),typeof disabled=="boolean"&&(node.disabled=disabled),typeof lazy=="boolean"&&(node.lazy=lazy);const icon=ownValue(raw,"icon");icon!==void 0&&(node.icon=icon);const description=ownValue(raw,"description");typeof description=="string"&&(node.description=description);const accessibleLabel=ownValue(raw,"accessibleLabel");typeof accessibleLabel=="string"&&(node.accessibleLabel=accessibleLabel);const normalizedBadges=normalizeBadges(ownValue(raw,"badges"));normalizedBadges.badges?.length&&(node.badges=normalizedBadges.badges),truncated||=normalizedBadges.truncated;const ownIndex=job.target.length,path=job.parentPath===""?String(ownIndex):`${job.parentPath}/${ownIndex}`;job.target.push(node),created.push(node),accepted++;const rawChildren=ownValue(raw,"children"),childCount=arrayLength(rawChildren);if(childCount===0)continue;if(declaredChildrenAtPath.set(path,childCount),job.depth>=TREE_MAX_RENDER_DEPTH||job.ancestors.has(raw)){truncated=!0;continue}const children=[];node.children=children;const ancestors=new Set(job.ancestors);ancestors.add(raw),jobs.push({source:rawChildren,index:0,length:childCount,target:children,parentPath:path,depth:job.depth+1,ancestors})}for(let index=created.length-1;index>=0;index--){const node=created[index];node.children&&Object.freeze(node.children),Object.freeze(node)}const normalizedJobs=root.map((node,index)=>({node,path:String(index)}));for(;normalizedJobs.length>0;){const{node,path}=normalizedJobs.pop(),children=node.children??[];identityFilteredCollections.has(children)&&declaredChildrenAtPath.set(path,children.length);for(let index=children.length-1;index>=0;index--)normalizedJobs.push({node:children[index],path:`${path}/${index}`})}return{data:Object.freeze(root),declaredChildrenAtPath,declaredRootCount:identityFilteredCollections.has(root)?root.length:rootLength,truncated}}function isInertWithin(node,root){for(let current=node;current&&current!==root;current=current.parentElement)if(current.hasAttribute("inert"))return!0;return!1}class LyraTree extends LyraElement{constructor(){super(...arguments),this._data=EMPTY_TREE_DATA,this.declaredChildrenAtPath=new Map,this.declaredRootCount=0,this._dataTruncated=!1,this.label="",this.reorderable=!1,this._selection="single",this.activeId=null,this.hasAuthoredItems=!1,this.pendingFocusId=null,this.generatedNodes=new WeakSet,this.dataIdOwnerPaths=new Map,this.dataIdCollisions=new Set,this.selectionSyncPending=!0,this.dataSyncPending=!1,this.inertMutationPending=!1,this.lastFocusedNodeId=null,this.onTreeFocusIn=e=>{const item=e.composedPath().find(target=>target.nodeType===1&&target.localName===tag("tree-item"));item&&(this.lastFocusedNodeId=item.nodeId)},this.onChildrenChanged=()=>{const wasAuthored=this.hasAuthoredItems;this.refreshAuthoredItems(),wasAuthored&&!this.hasAuthoredItems&&(this.dataSyncPending=!0),this.selectionSyncPending=!0,this.requestUpdate()},this.childObserverGeneration=0,this.onChildMutations=records=>{records.some(record=>record.attributeName==="inert")&&(this.inertMutationPending=!0),this.onChildrenChanged()},this.onNodeActivate=e=>{const id=e.detail.nodeId,node=this.allNodeElements().find(candidate=>candidate.nodeId===id);node&&!node.isDisabled&&(this.activeId=id,e.type==="lr-node-toggle"&&(this.selectionSyncPending=!0,this.requestUpdate()))},this.onNodeSelect=event=>{const id=event.detail.nodeId,node=this.allNodeElements().find(candidate=>candidate.nodeId===id);!node||node.isDisabled||(this.activeId=id,this.updateSelectionFrom(node)&&this.emit("lr-selection-change",Object.freeze({selection:this.selectedItems})))},this.onTreeKeyDown=e=>{const visible=this.visibleNodeElements();if(visible.length===0)return;const currentIndex=visible.findIndex(n=>n.nodeId===this.activeId),current=currentIndex>=0?visible[currentIndex]:visible[0];if(!current)return;if(this.reorderable&&(e.ctrlKey||e.metaKey)&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this.requestReorder(current,e.key==="ArrowDown"?1:-1);return}const rtl=isRtl(this),expandKey=rtl?"ArrowLeft":"ArrowRight",collapseKey=rtl?"ArrowRight":"ArrowLeft";switch(e.key){case"ArrowDown":e.preventDefault(),this.focusNode(visible[Math.min(visible.length-1,currentIndex+1)]);break;case"ArrowUp":e.preventDefault(),this.focusNode(visible[Math.max(0,currentIndex-1)]);break;case"Home":e.preventDefault(),this.focusNode(visible[0]);break;case"End":e.preventDefault(),this.focusNode(visible[visible.length-1]);break;case expandKey:if(e.preventDefault(),!current.hasChildren)break;if(!current.expanded)current.expand();else{const child=visible[currentIndex+1];child&&treeItemOwnerContext(child).depth>treeItemOwnerContext(current).depth&&this.focusNode(child)}break;case collapseKey:if(e.preventDefault(),current.hasChildren&&current.expanded)current.collapse();else for(let i=currentIndex-1;i>=0;i--){const sibling=visible[i];if(sibling&&treeItemOwnerContext(sibling).depth<treeItemOwnerContext(current).depth){this.focusNode(sibling);break}}break;case"Enter":case" ":e.preventDefault(),current.select();break;default:return}}}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,noData:LYRA_DEFAULT_noData,treeNodeMoved:LYRA_DEFAULT_treeNodeMoved}}static{this.immutableEventDetails=Object.freeze(["lr-selection-change"])}static{this.identityEventDetailProperties=Object.freeze({"lr-selection-change":Object.freeze(["selection"])})}static{this.styles=[LyraElement.styles,styles]}get data(){return this._data}set data(value){const previous=this._data,normalized=normalizeTreeData(value);this._data=normalized.data,this.declaredChildrenAtPath=normalized.declaredChildrenAtPath,this.declaredRootCount=normalized.declaredRootCount,this._dataTruncated=normalized.truncated,this.requestUpdate("data",previous)}get dataTruncated(){return this._dataTruncated}get selection(){return this._selection}set selection(value){const old=this._selection,normalized=TREE_SELECTIONS.has(value)?value:"single";old!==normalized&&(this._selection=normalized,this.selectionSyncPending=!0,this.requestUpdate("selection",old))}get nodeElements(){return[...this.querySelectorAll(`:scope > ${tag("tree-item")}`)]}childrenOf(node){return node.childItems()}isNavigable(node){return!node.isDisabled&&!isInertWithin(node,this)}allNodeElements(){const result=[],seen=new Set,stack=this.nodeElements.map(node=>({node,depth:0})).reverse();for(;stack.length>0&&result.length<TREE_MAX_RENDER_NODES;){const{node,depth}=stack.pop();if(seen.has(node)||(seen.add(node),result.push(node),depth>=TREE_MAX_RENDER_DEPTH))continue;const children=this.childrenOf(node);for(let index=children.length-1;index>=0;index--)stack.push({node:children[index],depth:depth+1})}return result}get selectedItems(){return Object.freeze(this.allNodeElements().filter(node=>node.selected))}iconSource(name){return this.querySelector(`:scope > [slot="${name}"]`)}applyTreeContext(){const expandIcon=this.iconSource("expand-icon"),collapseIcon=this.iconSource("collapse-icon"),roots=this.nodeElements,rootCount=this.hasAuthoredItems?roots.length:this.declaredRootCount,stack=[];for(let index=roots.length-1;index>=0;index--)stack.push({node:roots[index],ancestry:[],depth:0,setSize:rootCount,posInSet:index+1,identity:this.hasAuthoredItems?void 0:this.treeIdentityAt(String(index))});const seen=new Set;for(;stack.length>0&&seen.size<TREE_MAX_RENDER_NODES;){const frame=stack.pop();if(seen.has(frame.node)||(seen.add(frame.node),configureTreeItemOwner(frame.node,{...treeItemOwnerContext(frame.node),activeId:this.activeId,ancestry:frame.ancestry,depth:frame.depth,setSize:frame.setSize,posInSet:frame.posInSet,selection:this.selection,ownsSelection:!0,identity:frame.identity,expandIcon,collapseIcon}),frame.depth>=TREE_MAX_RENDER_DEPTH))continue;const children=this.childrenOf(frame.node),declaredCount=frame.identity?.declaredChildrenAtPath.get(frame.identity.path)??frame.node.item?.children?.length??children.length,childAncestry=frame.node.item?[...frame.ancestry,frame.node.item]:frame.ancestry;for(let index=children.length-1;index>=0;index--){const identity=frame.identity?{path:`${frame.identity.path}/${index}`,ownerPaths:frame.identity.ownerPaths,collisionIds:frame.identity.collisionIds,declaredChildrenAtPath:frame.identity.declaredChildrenAtPath}:void 0;stack.push({node:children[index],ancestry:childAncestry,depth:frame.depth+1,setSize:declaredCount,posInSet:index+1,identity})}}}selectableInSingleMode(node){return!node.isDisabled&&(this.selection!=="leaf"||!node.hasChildren)}normalizeSingleSelection(){let kept=!1;for(const node of this.allNodeElements()){const selected=!kept&&node.selected&&this.selectableInSingleMode(node);setTreeItemSelection(node,selected,!1),selected&&(kept=!0)}}setBranchSelection(node,selected,leavesOnly){const stack=[node],seen=new Set;for(;stack.length>0&&seen.size<TREE_MAX_RENDER_NODES;){const current=stack.pop();if(seen.has(current)||current.isDisabled)continue;seen.add(current);const children=this.childrenOf(current).filter(child=>!child.isDisabled);!leavesOnly||children.length===0?setTreeItemSelection(current,leavesOnly&&current.hasChildren?!1:selected,!1):setTreeItemSelection(current,!1,!1);for(let index=children.length-1;index>=0;index--)stack.push(children[index])}}deriveMultipleSelection(node,leavesOnly){const states=new Map,stack=[{item:node,visited:!1}],queued=new Set;for(;stack.length>0;){const entry=stack.pop();if(entry.visited){const current=entry.item;if(current.isDisabled){setTreeItemSelection(current,!1,!1),states.set(current,"ignored");continue}const children2=this.childrenOf(current).filter(child=>!child.isDisabled);if(children2.length===0){leavesOnly&&current.hasChildren?(setTreeItemSelection(current,!1,!1),states.set(current,"none")):(setTreeItemSelection(current,current.selected,!1),states.set(current,current.selected?"all":"none"));continue}const childStates=children2.map(child=>states.get(child)??"ignored").filter(state2=>state2!=="ignored");if(childStates.length===0){setTreeItemSelection(current,!1,!1),states.set(current,"none");continue}const all=childStates.every(state2=>state2==="all"),none=childStates.every(state2=>state2==="none");setTreeItemSelection(current,all,!all&&!none),states.set(current,all?"all":none?"none":"some");continue}if(queued.size>=TREE_MAX_RENDER_NODES||queued.has(entry.item))continue;queued.add(entry.item),stack.push({item:entry.item,visited:!0});const children=this.childrenOf(entry.item);for(let index=children.length-1;index>=0;index--)queued.has(children[index])||stack.push({item:children[index],visited:!1})}return states.get(node)??"none"}normalizeMultipleSelection(){const leavesOnly=this.selection==="leaf-multiple";for(const node of this.allNodeElements())node.selected&&this.childrenOf(node).length>0&&this.setBranchSelection(node,!0,leavesOnly);for(const root of this.nodeElements)this.deriveMultipleSelection(root,leavesOnly)}normalizeSelection(){this.selection==="single"||this.selection==="leaf"?this.normalizeSingleSelection():this.normalizeMultipleSelection()}selectionSignature(){return this.allNodeElements().map(node=>`${node.nodeId}:${node.selected?1:0}:${node.indeterminate?1:0}`).join("|")}updateSelectionFrom(node){if(node.isDisabled)return!1;const before=this.selectionSignature();if(this.selection==="single"||this.selection==="leaf"){if(!this.selectableInSingleMode(node))return!1;for(const candidate of this.allNodeElements())setTreeItemSelection(candidate,candidate===node,!1)}else{const select=node.indeterminate||!node.selected;this.setBranchSelection(node,select,this.selection==="leaf-multiple");for(const root of this.nodeElements)this.deriveMultipleSelection(root,this.selection==="leaf-multiple")}return before!==this.selectionSignature()}refreshAuthoredItems(){const nodes=this.nodeElements;for(const node of nodes)node.hasAttribute("slot")&&node.removeAttribute("slot");const authored=nodes.some(node=>!this.generatedNodes.has(node));if(authored)for(const node of nodes)this.generatedNodes.has(node)&&node.remove();this.hasAuthoredItems=authored}visibleNodeElements(){const acc=[],seen=new Set,stack=this.nodeElements.map(node=>({node,depth:0})).reverse();for(;stack.length>0&&acc.length<TREE_MAX_RENDER_NODES;){const{node,depth}=stack.pop();if(seen.has(node)||(seen.add(node),!this.isNavigable(node))||(acc.push(node),!node.expanded||depth>=TREE_MAX_RENDER_DEPTH))continue;const children=this.childrenOf(node);for(let index=children.length-1;index>=0;index--)stack.push({node:children[index],depth:depth+1})}return acc}findItem(items,id){const stack=[...items].reverse(),seen=new Set;for(;stack.length>0;){const item=stack.pop();if(!seen.has(item)){if(seen.add(item),item.id===id)return item;if(item.children)for(let i=item.children.length-1;i>=0;i--){const child=item.children[i];child&&stack.push(child)}}}}isDuplicateDataPath(item,path){return this.dataIdCollisions.has(item.id)&&this.dataIdOwnerPaths.get(item.id)!==path}rebuildDataIdentity(){const ownerPaths=new Map,collisionIds=new Set,ancestry=new Set,stack=[{items:this.data,index:0,parentPath:"",depth:0}];for(;stack.length>0;){const frame=stack[stack.length-1];if(frame.index>=frame.items.length){frame.owner&&ancestry.delete(frame.owner),stack.pop();continue}const index=frame.index++,item=frame.items[index];if(!item)continue;const path=frame.parentPath===""?String(index):`${frame.parentPath}/${index}`;ownerPaths.has(item.id)?collisionIds.add(item.id):ownerPaths.set(item.id,path),!(frame.depth>=TREE_MAX_RENDER_DEPTH||ancestry.has(item)||!item.children?.length)&&(ancestry.add(item),stack.push({items:item.children,index:0,parentPath:path,depth:frame.depth+1,owner:item}))}this.dataIdOwnerPaths=ownerPaths,this.dataIdCollisions=collisionIds}treeIdentityAt(path){return{path,ownerPaths:this.dataIdOwnerPaths,collisionIds:this.dataIdCollisions,declaredChildrenAtPath:this.declaredChildrenAtPath}}firstEnabledId(items){for(let index=0;index<items.length;index++){const item=items[index];if(!(!item||item.disabled||this.isDuplicateDataPath(item,String(index))))return item.id}return null}isEnabledReachableId(items,id){const stack=items.map((item,index)=>({item,path:String(index)})).reverse(),seen=new Set;for(;stack.length>0;){const{item,path}=stack.pop();if(!seen.has(item)&&(seen.add(item),!(item.disabled||this.isDuplicateDataPath(item,path)))){if(item.id===id)return!0;if(item.children)for(let i=item.children.length-1;i>=0;i--){const child=item.children[i];child&&stack.push({item:child,path:`${path}/${i}`})}}}return!1}findRenderedSiblings(node){const root=node.getRootNode(),shadowHost="host"in root?root.host:null,shadowParent=shadowHost?.localName===tag("tree-item")?shadowHost:null,lightParent=node.parentElement?.localName===tag("tree-item")?node.parentElement:null,parentItem=shadowParent??lightParent,siblings=parentItem?parentItem.childItems():this.nodeElements,index=siblings.indexOf(node);if(!(index<0))return{parent:parentItem,siblings,index}}deepFocusedNode(){const active=deepActiveElementIn(this.ownerDocument);if(!active||active.localName!==tag("tree-item"))return null;const node=active;return this.visibleNodeElements().some(n=>n.nodeId===node.nodeId)?node:null}resolveActiveFromDom(){const inertMutation=this.inertMutationPending;this.inertMutationPending=!1;const visible=this.visibleNodeElements();if(visible.some(node=>node.nodeId===this.activeId))return;const displaced=this.activeId;if(this.activeId=visible[0]?.nodeId??null,!inertMutation||this.activeId==null||displaced==null||displaced!==this.lastFocusedNodeId)return;const ownerDocument=this.ownerDocument,active=deepActiveElementIn(ownerDocument),strandedOnDisplaced=active?.nodeType===1&&active.localName===tag("tree-item")&&active.nodeId===displaced;active!==null&&active!==ownerDocument.body&&!strandedOnDisplaced||(this.pendingFocusId=this.activeId)}willUpdate(changed){if(super.willUpdate(changed),this.refreshAuthoredItems(),(changed.has("data")||changed.has("selection"))&&(this.selectionSyncPending=!0),this.hasAuthoredItems){this.resolveActiveFromDom();return}if(changed.has("data")||this.dataSyncPending){this.dataSyncPending=!1;const focused=this.deepFocusedNode(),focusedId=focused?.nodeId??null;this.rebuildDataIdentity(),this.syncNodes();const activeItem=this.activeId?this.findItem(this.data,this.activeId):void 0;(!this.activeId||!activeItem||activeItem.disabled||!this.isEnabledReachableId(this.data,this.activeId))&&(this.activeId=this.firstEnabledId(this.data)),this.pendingFocusId=focused==null?null:focusedId!=null&&this.findItem(this.data,focusedId)?focusedId:this.activeId}this.inertMutationPending&&this.resolveActiveFromDom()}updated(changed){if(super.updated(changed),changed.has("activeId")||changed.has("data")||this.hasAuthoredItems){const nodes=this.nodeElements,count=this.hasAuthoredItems?nodes.length:this.declaredRootCount;nodes.forEach((node,i)=>{configureTreeItemOwner(node,{...treeItemOwnerContext(node),activeId:this.activeId,ancestry:[],depth:0,setSize:count,posInSet:i+1,selection:this.selection,ownsSelection:!0,identity:this.hasAuthoredItems?void 0:this.treeIdentityAt(String(i)),expandIcon:this.iconSource("expand-icon"),collapseIcon:this.iconSource("collapse-icon")})})}}connectedCallback(){super.connectedCallback(),this.armChildObserver()}armChildObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.childObserver&&this.childObserverDocument===ownerDocument)return;this.resetChildObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.childObserverGeneration,observer=new MutationObserverCtor(records=>{this.childObserver!==observer||this.childObserverDocument!==ownerDocument||this.childObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onChildMutations(records)});this.childObserver=observer,this.childObserverDocument=ownerDocument,observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["selected","disabled","inert","lazy"]})}disconnectedCallback(){super.disconnectedCallback(),this.pendingReorder=void 0,this.resetChildObserver()}adoptedCallback(){super.adoptedCallback(),this.resetChildObserver()}resetChildObserver(){this.childObserverGeneration+=1,this.childObserver?.disconnect(),this.childObserver=void 0,this.childObserverDocument=void 0}syncNodes(){const existingById=new Map;for(const node of this.nodeElements){if(!node.item)continue;const matches=existingById.get(node.item.id)??[];matches.push(node),existingById.set(node.item.id,matches)}let previousSibling=null;for(let index=0;index<this.data.length;index++){const item=this.data[index];let node=existingById.get(item.id)?.shift();node||(node=this.ownerDocument.createElement(tag("tree-item")),this.generatedNodes.add(node)),node.item=item,configureTreeItemOwner(node,{...treeItemOwnerContext(node),ancestry:[],depth:0,setSize:this.declaredRootCount,posInSet:index+1,selection:this.selection,ownsSelection:!0,identity:this.treeIdentityAt(String(index)),expandIcon:this.iconSource("expand-icon"),collapseIcon:this.iconSource("collapse-icon")});const targetPosition=previousSibling?previousSibling.nextElementSibling:this.firstElementChild;targetPosition!==node&&this.insertBefore(node,targetPosition),previousSibling=node}for(const nodes of existingById.values())for(const node of nodes)node.remove()}focusNode(node){node&&(this.activeId=node.nodeId,node.focus())}async getUpdateComplete(){const result=await super.getUpdateComplete();if(await cascadeUpdateComplete(this.nodeElements),this.applyTreeContext(),this.selectionSyncPending&&(this.selectionSyncPending=!1,this.normalizeSelection()),await cascadeUpdateComplete(this.nodeElements),this.confirmPendingReorder(),this.pendingFocusId!=null){const id=this.pendingFocusId;this.pendingFocusId=null;const visible=this.visibleNodeElements();(visible.find(n=>n.nodeId===id)??visible.find(n=>n.nodeId===this.activeId))?.focus()}return result}requestReorder(node,delta){const id=node.nodeId,found=this.findRenderedSiblings(node);if(!found)return;const{parent,siblings,index}=found,total=siblings.length,toIndex=index+delta;toIndex<0||toIndex>=total||(this.pendingReorder={node,parent,originalSiblings:[...siblings],targetSibling:siblings[toIndex],fromIndex:index,toIndex},this.emit("lr-reorder",{nodeId:id,parentNodeId:parent?.nodeId??null,fromIndex:index,toIndex}))}confirmPendingReorder(){const pending=this.pendingReorder;if(!pending)return;const found=this.findRenderedSiblings(pending.node);if(!found){this.pendingReorder=void 0;return}(found.siblings.length!==pending.originalSiblings.length||found.siblings.some((node,index)=>node!==pending.originalSiblings[index]))&&(this.pendingReorder=void 0,!(found.parent!==pending.parent||found.index!==pending.toIndex||found.siblings[pending.fromIndex]!==pending.targetSibling)&&this.liveRegion?.announce(this.localize("treeNodeMoved",void 0,{label:pending.node.nodeLabel,index:this.formatCount(found.index+1),total:this.formatCount(found.siblings.length)}),{force:!0}))}async expandAll(){const queue=this.nodeElements.map(node=>({node,depth:0})),seen=new Set;for(let index=0;index<queue.length&&seen.size<TREE_MAX_RENDER_NODES;index++){const{node,depth}=queue[index];seen.has(node)||(seen.add(node),node.isDisabled?node.expanded=!1:node.hasChildren&&node.expand(),await node.updateComplete,depth<TREE_MAX_RENDER_DEPTH&&queue.push(...this.childrenOf(node).map(child=>({node:child,depth:depth+1}))))}}async collapseAll(){const focused=this.deepFocusedNode(),topLevel=this.nodeElements,nodes=this.allNodeElements();for(let index=nodes.length-1;index>=0;index--){const node=nodes[index];node.isDisabled?node.expanded=!1:node.collapse()}(this.hasAuthoredItems?topLevel.some(node=>this.isNavigable(node)&&node.nodeId===this.activeId):this.data.some(item=>!item.disabled&&item.id===this.activeId))||(this.activeId=this.hasAuthoredItems?topLevel.find(node=>this.isNavigable(node))?.nodeId??null:this.firstEnabledId(this.data)),focused&&(this.pendingFocusId=this.activeId),await cascadeUpdateComplete(topLevel)}render(){return html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{tag}from"../../../internal/prefix.js";import{isRtl}from"../../../internal/rtl.js";import{styles}from"./tree.styles.js";import{cascadeUpdateComplete}from"./update-cascade.js";import{configureTreeItemOwner,setTreeItemSelection,treeItemOwnerContext}from"./tree-owner-controller.js";import"./tree-item.class.js";import{TREE_MAX_RENDER_DEPTH,TREE_MAX_RENDER_NODES}from"./tree-types.js";import{deepActiveElementIn}from"../../../internal/active-element.js";import{LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_noData,LYRA_DEFAULT_treeNodeMoved}from"../../../internal/default-strings.generated.js";const TREE_SELECTIONS=new Set(["single","multiple","leaf","leaf-multiple"]),TREE_BADGE_LIMIT=100,TREE_MAX_INSPECTED_POSITIONS=1e4,EMPTY_TREE_DATA=Object.freeze([]);function ownValue(record,key){try{const descriptor=Object.getOwnPropertyDescriptor(record,key);return descriptor&&"value"in descriptor?descriptor.value:void 0}catch{return}}function arrayLength(value){if(!Array.isArray(value))return 0;try{return Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,Math.trunc(value.length)))}catch{return 0}}function normalizeBadges(value){if(!Array.isArray(value))return{truncated:value!==void 0};const badges=[],length=arrayLength(value);for(let index=0;index<Math.min(length,TREE_BADGE_LIMIT);index++){const raw=ownValue(value,String(index));if(!raw||typeof raw!="object"||Array.isArray(raw))continue;const text=ownValue(raw,"text");if(typeof text!="string")continue;const rawTone=ownValue(raw,"tone"),tone=rawTone==="brand"||rawTone==="success"||rawTone==="warning"||rawTone==="danger"?rawTone:"neutral",rawLabel=ownValue(raw,"label");badges.push(Object.freeze({text,tone,...typeof rawLabel=="string"?{label:rawLabel}:{}}))}return{badges:Object.freeze(badges),truncated:length>TREE_BADGE_LIMIT}}function normalizeTreeData(input){if(!Array.isArray(input))return{data:EMPTY_TREE_DATA,declaredChildrenAtPath:new Map,declaredRootCount:0,truncated:input!=null};const root=[],declaredChildrenAtPath=new Map,created=[],rootLength=arrayLength(input);let truncated=!1,accepted=0,inspected=0;const seenIds=new Set,identityFilteredCollections=new Set,jobs=[{source:input,index:0,length:rootLength,target:root,parentPath:"",depth:0,ancestors:new Set}];for(;jobs.length>0;){const job=jobs[jobs.length-1];if(job.index>=job.length){jobs.pop();continue}if(accepted>=TREE_MAX_RENDER_NODES||inspected>=TREE_MAX_INSPECTED_POSITIONS){truncated=!0;break}const raw=ownValue(job.source,String(job.index++));if(inspected++,inspected===TREE_MAX_INSPECTED_POSITIONS&&(truncated=!0),!raw||typeof raw!="object"||Array.isArray(raw)){truncated=!0,identityFilteredCollections.add(job.target);continue}const id=ownValue(raw,"id"),label=ownValue(raw,"label");if(typeof id!="string"||id.trim()===""||seenIds.has(id)||typeof label!="string"){truncated=!0,identityFilteredCollections.add(job.target);continue}seenIds.add(id);const node={id,label},selected=ownValue(raw,"selected"),disabled=ownValue(raw,"disabled"),lazy=ownValue(raw,"lazy");typeof selected=="boolean"&&(node.selected=selected),typeof disabled=="boolean"&&(node.disabled=disabled),typeof lazy=="boolean"&&(node.lazy=lazy);const icon=ownValue(raw,"icon");icon!==void 0&&(node.icon=icon);const description=ownValue(raw,"description");typeof description=="string"&&(node.description=description);const accessibleLabel=ownValue(raw,"accessibleLabel");typeof accessibleLabel=="string"&&(node.accessibleLabel=accessibleLabel);const normalizedBadges=normalizeBadges(ownValue(raw,"badges"));normalizedBadges.badges?.length&&(node.badges=normalizedBadges.badges),truncated||=normalizedBadges.truncated;const ownIndex=job.target.length,path=job.parentPath===""?String(ownIndex):`${job.parentPath}/${ownIndex}`;job.target.push(node),created.push(node),accepted++;const rawChildren=ownValue(raw,"children"),childCount=arrayLength(rawChildren);if(childCount===0)continue;if(declaredChildrenAtPath.set(path,childCount),job.depth>=TREE_MAX_RENDER_DEPTH||job.ancestors.has(raw)){truncated=!0;continue}const children=[];node.children=children;const ancestors=new Set(job.ancestors);ancestors.add(raw),jobs.push({source:rawChildren,index:0,length:childCount,target:children,parentPath:path,depth:job.depth+1,ancestors})}for(let index=created.length-1;index>=0;index--){const node=created[index];node.children&&Object.freeze(node.children),Object.freeze(node)}const normalizedJobs=root.map((node,index)=>({node,path:String(index)}));for(;normalizedJobs.length>0;){const{node,path}=normalizedJobs.pop(),children=node.children??[];identityFilteredCollections.has(children)&&declaredChildrenAtPath.set(path,children.length);for(let index=children.length-1;index>=0;index--)normalizedJobs.push({node:children[index],path:`${path}/${index}`})}return{data:Object.freeze(root),declaredChildrenAtPath,declaredRootCount:identityFilteredCollections.has(root)?root.length:rootLength,truncated}}function isInertWithin(node,root){for(let current=node;current&&current!==root;current=current.parentElement)if(current.hasAttribute("inert"))return!0;return!1}class LyraTree extends LyraElement{constructor(){super(...arguments),this._data=EMPTY_TREE_DATA,this.declaredChildrenAtPath=new Map,this.declaredRootCount=0,this._dataTruncated=!1,this.label="",this.reorderable=!1,this._selection="single",this.activeId=null,this.hasAuthoredItems=!1,this.pendingFocusId=null,this.generatedNodes=new WeakSet,this.dataIdOwnerPaths=new Map,this.dataIdCollisions=new Set,this.selectionSyncPending=!0,this.dataSyncPending=!1,this.inertMutationPending=!1,this.dirtyConfigureRoots=new Set,this.lastFocusedNodeId=null,this.onTreeFocusIn=e=>{const item=e.composedPath().find(target=>target.nodeType===1&&target.localName===tag("tree-item"));item&&(this.lastFocusedNodeId=item.nodeId)},this.onChildrenChanged=()=>{const wasAuthored=this.hasAuthoredItems;this.refreshAuthoredItems(),wasAuthored&&!this.hasAuthoredItems&&(this.dataSyncPending=!0),this.selectionSyncPending=!0,this.requestUpdate()},this.childObserverGeneration=0,this.onChildMutations=records=>{if(records.some(record=>record.attributeName==="inert")&&(this.inertMutationPending=!0),records.every(record=>record.type==="attributes")){const itemTag=tag("tree-item");for(const record of records){const target=record.target;if(!(target instanceof Element)||target.localName!==itemTag)continue;const root=this.rootTreeItemAncestor(target);root&&this.dirtyConfigureRoots.add(root)}}else this.dirtyConfigureRoots.clear();this.onChildrenChanged()},this.onNodeActivate=e=>{const id=e.detail.nodeId,node=this.allNodeElements().find(candidate=>candidate.nodeId===id);node&&!node.isDisabled&&(this.activeId=id,e.type==="lr-node-toggle"&&(this.selectionSyncPending=!0,this.requestUpdate()))},this.onNodeSelect=event=>{const id=event.detail.nodeId,node=this.allNodeElements().find(candidate=>candidate.nodeId===id);!node||node.isDisabled||(this.activeId=id,this.updateSelectionFrom(node)&&this.emit("lr-selection-change",Object.freeze({selection:this.selectedItems})))},this.onTreeKeyDown=e=>{const visible=this.visibleNodeElements();if(visible.length===0)return;const currentIndex=visible.findIndex(n=>n.nodeId===this.activeId),current=currentIndex>=0?visible[currentIndex]:visible[0];if(!current)return;if(this.reorderable&&(e.ctrlKey||e.metaKey)&&(e.key==="ArrowUp"||e.key==="ArrowDown")){e.preventDefault(),this.requestReorder(current,e.key==="ArrowDown"?1:-1);return}const rtl=isRtl(this),expandKey=rtl?"ArrowLeft":"ArrowRight",collapseKey=rtl?"ArrowRight":"ArrowLeft";switch(e.key){case"ArrowDown":e.preventDefault(),this.focusNode(visible[Math.min(visible.length-1,currentIndex+1)]);break;case"ArrowUp":e.preventDefault(),this.focusNode(visible[Math.max(0,currentIndex-1)]);break;case"Home":e.preventDefault(),this.focusNode(visible[0]);break;case"End":e.preventDefault(),this.focusNode(visible[visible.length-1]);break;case expandKey:if(e.preventDefault(),!current.hasChildren)break;if(!current.expanded)current.expand();else{const child=visible[currentIndex+1];child&&treeItemOwnerContext(child).depth>treeItemOwnerContext(current).depth&&this.focusNode(child)}break;case collapseKey:if(e.preventDefault(),current.hasChildren&&current.expanded)current.collapse();else for(let i=currentIndex-1;i>=0;i--){const sibling=visible[i];if(sibling&&treeItemOwnerContext(sibling).depth<treeItemOwnerContext(current).depth){this.focusNode(sibling);break}}break;case"Enter":case" ":e.preventDefault(),current.select();break;default:return}}}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,noData:LYRA_DEFAULT_noData,treeNodeMoved:LYRA_DEFAULT_treeNodeMoved}}static{this.immutableEventDetails=Object.freeze(["lr-selection-change"])}static{this.identityEventDetailProperties=Object.freeze({"lr-selection-change":Object.freeze(["selection"])})}static{this.styles=[LyraElement.styles,styles]}get data(){return this._data}set data(value){const previous=this._data,normalized=normalizeTreeData(value);this._data=normalized.data,this.declaredChildrenAtPath=normalized.declaredChildrenAtPath,this.declaredRootCount=normalized.declaredRootCount,this._dataTruncated=normalized.truncated,this.requestUpdate("data",previous)}get dataTruncated(){return this._dataTruncated}get selection(){return this._selection}set selection(value){const old=this._selection,normalized=TREE_SELECTIONS.has(value)?value:"single";old!==normalized&&(this._selection=normalized,this.selectionSyncPending=!0,this.requestUpdate("selection",old))}get nodeElements(){return[...this.querySelectorAll(`:scope > ${tag("tree-item")}`)]}childrenOf(node){return node.childItems()}isNavigable(node){return!node.isDisabled&&!isInertWithin(node,this)}allNodeElements(){const result=[],seen=new Set,stack=this.nodeElements.map(node=>({node,depth:0})).reverse();for(;stack.length>0&&result.length<TREE_MAX_RENDER_NODES;){const{node,depth}=stack.pop();if(seen.has(node)||(seen.add(node),result.push(node),depth>=TREE_MAX_RENDER_DEPTH))continue;const children=this.childrenOf(node);for(let index=children.length-1;index>=0;index--)stack.push({node:children[index],depth:depth+1})}return result}get selectedItems(){return Object.freeze(this.allNodeElements().filter(node=>node.selected))}iconSource(name){return this.querySelector(`:scope > [slot="${name}"]`)}applyTreeContext(){const expandIcon=this.iconSource("expand-icon"),collapseIcon=this.iconSource("collapse-icon"),roots=this.nodeElements,rootCount=this.hasAuthoredItems?roots.length:this.declaredRootCount,stack=[];for(let index=roots.length-1;index>=0;index--)stack.push({node:roots[index],ancestry:[],depth:0,setSize:rootCount,posInSet:index+1,identity:this.hasAuthoredItems?void 0:this.treeIdentityAt(String(index))});const seen=new Set;for(;stack.length>0&&seen.size<TREE_MAX_RENDER_NODES;){const frame=stack.pop();if(seen.has(frame.node)||(seen.add(frame.node),configureTreeItemOwner(frame.node,{...treeItemOwnerContext(frame.node),activeId:this.activeId,ancestry:frame.ancestry,depth:frame.depth,setSize:frame.setSize,posInSet:frame.posInSet,selection:this.selection,ownsSelection:!0,identity:frame.identity,expandIcon,collapseIcon}),frame.depth>=TREE_MAX_RENDER_DEPTH))continue;const children=this.childrenOf(frame.node),declaredCount=frame.identity?.declaredChildrenAtPath.get(frame.identity.path)??frame.node.item?.children?.length??children.length,childAncestry=frame.node.item?[...frame.ancestry,frame.node.item]:frame.ancestry;for(let index=children.length-1;index>=0;index--){const identity=frame.identity?{path:`${frame.identity.path}/${index}`,ownerPaths:frame.identity.ownerPaths,collisionIds:frame.identity.collisionIds,declaredChildrenAtPath:frame.identity.declaredChildrenAtPath}:void 0;stack.push({node:children[index],ancestry:childAncestry,depth:frame.depth+1,setSize:declaredCount,posInSet:index+1,identity})}}}selectableInSingleMode(node){return!node.isDisabled&&(this.selection!=="leaf"||!node.hasChildren)}normalizeSingleSelection(){let kept=!1;for(const node of this.allNodeElements()){const selected=!kept&&node.selected&&this.selectableInSingleMode(node);setTreeItemSelection(node,selected,!1),selected&&(kept=!0)}}setBranchSelection(node,selected,leavesOnly){const stack=[node],seen=new Set;for(;stack.length>0&&seen.size<TREE_MAX_RENDER_NODES;){const current=stack.pop();if(seen.has(current)||current.isDisabled)continue;seen.add(current);const children=this.childrenOf(current).filter(child=>!child.isDisabled);!leavesOnly||children.length===0?setTreeItemSelection(current,leavesOnly&&current.hasChildren?!1:selected,!1):setTreeItemSelection(current,!1,!1);for(let index=children.length-1;index>=0;index--)stack.push(children[index])}}deriveMultipleSelection(node,leavesOnly){const states=new Map,stack=[{item:node,visited:!1}],queued=new Set;for(;stack.length>0;){const entry=stack.pop();if(entry.visited){const current=entry.item;if(current.isDisabled){setTreeItemSelection(current,!1,!1),states.set(current,"ignored");continue}const children2=this.childrenOf(current).filter(child=>!child.isDisabled);if(children2.length===0){leavesOnly&&current.hasChildren?(setTreeItemSelection(current,!1,!1),states.set(current,"none")):(setTreeItemSelection(current,current.selected,!1),states.set(current,current.selected?"all":"none"));continue}const childStates=children2.map(child=>states.get(child)??"ignored").filter(state2=>state2!=="ignored");if(childStates.length===0){setTreeItemSelection(current,!1,!1),states.set(current,"none");continue}const all=childStates.every(state2=>state2==="all"),none=childStates.every(state2=>state2==="none");setTreeItemSelection(current,all,!all&&!none),states.set(current,all?"all":none?"none":"some");continue}if(queued.size>=TREE_MAX_RENDER_NODES||queued.has(entry.item))continue;queued.add(entry.item),stack.push({item:entry.item,visited:!0});const children=this.childrenOf(entry.item);for(let index=children.length-1;index>=0;index--)queued.has(children[index])||stack.push({item:children[index],visited:!1})}return states.get(node)??"none"}normalizeMultipleSelection(){const leavesOnly=this.selection==="leaf-multiple";for(const node of this.allNodeElements())node.selected&&this.childrenOf(node).length>0&&this.setBranchSelection(node,!0,leavesOnly);for(const root of this.nodeElements)this.deriveMultipleSelection(root,leavesOnly)}normalizeSelection(){this.selection==="single"||this.selection==="leaf"?this.normalizeSingleSelection():this.normalizeMultipleSelection()}selectionSignature(){return this.allNodeElements().map(node=>`${node.nodeId}:${node.selected?1:0}:${node.indeterminate?1:0}`).join("|")}updateSelectionFrom(node){if(node.isDisabled)return!1;const before=this.selectionSignature();if(this.selection==="single"||this.selection==="leaf"){if(!this.selectableInSingleMode(node))return!1;for(const candidate of this.allNodeElements())setTreeItemSelection(candidate,candidate===node,!1)}else{const select=node.indeterminate||!node.selected;this.setBranchSelection(node,select,this.selection==="leaf-multiple");for(const root of this.nodeElements)this.deriveMultipleSelection(root,this.selection==="leaf-multiple")}return before!==this.selectionSignature()}refreshAuthoredItems(){const nodes=this.nodeElements;for(const node of nodes)node.hasAttribute("slot")&&node.removeAttribute("slot");const authored=nodes.some(node=>!this.generatedNodes.has(node));if(authored)for(const node of nodes)this.generatedNodes.has(node)&&node.remove();this.hasAuthoredItems=authored}visibleNodeElements(){const acc=[],seen=new Set,stack=this.nodeElements.map(node=>({node,depth:0})).reverse();for(;stack.length>0&&acc.length<TREE_MAX_RENDER_NODES;){const{node,depth}=stack.pop();if(seen.has(node)||(seen.add(node),!this.isNavigable(node))||(acc.push(node),!node.expanded||depth>=TREE_MAX_RENDER_DEPTH))continue;const children=this.childrenOf(node);for(let index=children.length-1;index>=0;index--)stack.push({node:children[index],depth:depth+1})}return acc}findItem(items,id){const stack=[...items].reverse(),seen=new Set;for(;stack.length>0;){const item=stack.pop();if(!seen.has(item)){if(seen.add(item),item.id===id)return item;if(item.children)for(let i=item.children.length-1;i>=0;i--){const child=item.children[i];child&&stack.push(child)}}}}isDuplicateDataPath(item,path){return this.dataIdCollisions.has(item.id)&&this.dataIdOwnerPaths.get(item.id)!==path}rebuildDataIdentity(){const ownerPaths=new Map,collisionIds=new Set,ancestry=new Set,stack=[{items:this.data,index:0,parentPath:"",depth:0}];for(;stack.length>0;){const frame=stack[stack.length-1];if(frame.index>=frame.items.length){frame.owner&&ancestry.delete(frame.owner),stack.pop();continue}const index=frame.index++,item=frame.items[index];if(!item)continue;const path=frame.parentPath===""?String(index):`${frame.parentPath}/${index}`;ownerPaths.has(item.id)?collisionIds.add(item.id):ownerPaths.set(item.id,path),!(frame.depth>=TREE_MAX_RENDER_DEPTH||ancestry.has(item)||!item.children?.length)&&(ancestry.add(item),stack.push({items:item.children,index:0,parentPath:path,depth:frame.depth+1,owner:item}))}this.dataIdOwnerPaths=ownerPaths,this.dataIdCollisions=collisionIds}treeIdentityAt(path){return{path,ownerPaths:this.dataIdOwnerPaths,collisionIds:this.dataIdCollisions,declaredChildrenAtPath:this.declaredChildrenAtPath}}firstEnabledId(items){for(let index=0;index<items.length;index++){const item=items[index];if(!(!item||item.disabled||this.isDuplicateDataPath(item,String(index))))return item.id}return null}isEnabledReachableId(items,id){const stack=items.map((item,index)=>({item,path:String(index)})).reverse(),seen=new Set;for(;stack.length>0;){const{item,path}=stack.pop();if(!seen.has(item)&&(seen.add(item),!(item.disabled||this.isDuplicateDataPath(item,path)))){if(item.id===id)return!0;if(item.children)for(let i=item.children.length-1;i>=0;i--){const child=item.children[i];child&&stack.push({item:child,path:`${path}/${i}`})}}}return!1}findRenderedSiblings(node){const root=node.getRootNode(),shadowHost="host"in root?root.host:null,shadowParent=shadowHost?.localName===tag("tree-item")?shadowHost:null,lightParent=node.parentElement?.localName===tag("tree-item")?node.parentElement:null,parentItem=shadowParent??lightParent,siblings=parentItem?parentItem.childItems():this.nodeElements,index=siblings.indexOf(node);if(!(index<0))return{parent:parentItem,siblings,index}}deepFocusedNode(){const active=deepActiveElementIn(this.ownerDocument);if(!active||active.localName!==tag("tree-item"))return null;const node=active;return this.visibleNodeElements().some(n=>n.nodeId===node.nodeId)?node:null}resolveActiveFromDom(){const inertMutation=this.inertMutationPending;this.inertMutationPending=!1;const visible=this.visibleNodeElements();if(visible.some(node=>node.nodeId===this.activeId))return;const displaced=this.activeId;if(this.activeId=visible[0]?.nodeId??null,!inertMutation||this.activeId==null||displaced==null||displaced!==this.lastFocusedNodeId)return;const ownerDocument=this.ownerDocument,active=deepActiveElementIn(ownerDocument),strandedOnDisplaced=active?.nodeType===1&&active.localName===tag("tree-item")&&active.nodeId===displaced;active!==null&&active!==ownerDocument.body&&!strandedOnDisplaced||(this.pendingFocusId=this.activeId)}willUpdate(changed){if(super.willUpdate(changed),this.refreshAuthoredItems(),(changed.has("data")||changed.has("selection"))&&(this.selectionSyncPending=!0),this.hasAuthoredItems){this.resolveActiveFromDom();return}if(changed.has("data")||this.dataSyncPending){this.dataSyncPending=!1;const focused=this.deepFocusedNode(),focusedId=focused?.nodeId??null;this.rebuildDataIdentity(),this.syncNodes();const activeItem=this.activeId?this.findItem(this.data,this.activeId):void 0;(!this.activeId||!activeItem||activeItem.disabled||!this.isEnabledReachableId(this.data,this.activeId))&&(this.activeId=this.firstEnabledId(this.data)),this.pendingFocusId=focused==null?null:focusedId!=null&&this.findItem(this.data,focusedId)?focusedId:this.activeId}this.inertMutationPending&&this.resolveActiveFromDom()}updated(changed){if(super.updated(changed),changed.size===0&&this.hasAuthoredItems&&this.dirtyConfigureRoots.size>0){const nodes=this.nodeElements,count=nodes.length;for(const node of this.dirtyConfigureRoots){const i=nodes.indexOf(node);i<0||configureTreeItemOwner(node,{...treeItemOwnerContext(node),activeId:this.activeId,ancestry:[],depth:0,setSize:count,posInSet:i+1,selection:this.selection,ownsSelection:!0,identity:void 0,expandIcon:this.iconSource("expand-icon"),collapseIcon:this.iconSource("collapse-icon")})}}else if(changed.has("activeId")||changed.has("data")||this.hasAuthoredItems){const nodes=this.nodeElements,count=this.hasAuthoredItems?nodes.length:this.declaredRootCount;nodes.forEach((node,i)=>{configureTreeItemOwner(node,{...treeItemOwnerContext(node),activeId:this.activeId,ancestry:[],depth:0,setSize:count,posInSet:i+1,selection:this.selection,ownsSelection:!0,identity:this.hasAuthoredItems?void 0:this.treeIdentityAt(String(i)),expandIcon:this.iconSource("expand-icon"),collapseIcon:this.iconSource("collapse-icon")})})}this.dirtyConfigureRoots.clear()}rootTreeItemAncestor(node){const itemTag=tag("tree-item");let current=node;for(;current&&current.parentElement&&current.parentElement!==this;)current=current.parentElement;return current&&current.parentElement===this&&current.localName===itemTag?current:null}connectedCallback(){super.connectedCallback(),this.armChildObserver()}armChildObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.childObserver&&this.childObserverDocument===ownerDocument)return;this.resetChildObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.childObserverGeneration,observer=new MutationObserverCtor(records=>{this.childObserver!==observer||this.childObserverDocument!==ownerDocument||this.childObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onChildMutations(records)});this.childObserver=observer,this.childObserverDocument=ownerDocument,observer.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["selected","disabled","inert","lazy"]})}disconnectedCallback(){super.disconnectedCallback(),this.pendingReorder=void 0,this.resetChildObserver()}adoptedCallback(){super.adoptedCallback(),this.resetChildObserver()}resetChildObserver(){this.childObserverGeneration+=1,this.childObserver?.disconnect(),this.childObserver=void 0,this.childObserverDocument=void 0}syncNodes(){const existingById=new Map;for(const node of this.nodeElements){if(!node.item)continue;const matches=existingById.get(node.item.id)??[];matches.push(node),existingById.set(node.item.id,matches)}let previousSibling=null;for(let index=0;index<this.data.length;index++){const item=this.data[index];let node=existingById.get(item.id)?.shift();node||(node=this.ownerDocument.createElement(tag("tree-item")),this.generatedNodes.add(node)),node.item=item,configureTreeItemOwner(node,{...treeItemOwnerContext(node),ancestry:[],depth:0,setSize:this.declaredRootCount,posInSet:index+1,selection:this.selection,ownsSelection:!0,identity:this.treeIdentityAt(String(index)),expandIcon:this.iconSource("expand-icon"),collapseIcon:this.iconSource("collapse-icon")});const targetPosition=previousSibling?previousSibling.nextElementSibling:this.firstElementChild;targetPosition!==node&&this.insertBefore(node,targetPosition),previousSibling=node}for(const nodes of existingById.values())for(const node of nodes)node.remove()}focusNode(node){node&&(this.activeId=node.nodeId,node.focus())}async getUpdateComplete(){const result=await super.getUpdateComplete();if(await cascadeUpdateComplete(this.nodeElements),this.applyTreeContext(),this.selectionSyncPending&&(this.selectionSyncPending=!1,this.normalizeSelection()),await cascadeUpdateComplete(this.nodeElements),this.confirmPendingReorder(),this.pendingFocusId!=null){const id=this.pendingFocusId;this.pendingFocusId=null;const visible=this.visibleNodeElements();(visible.find(n=>n.nodeId===id)??visible.find(n=>n.nodeId===this.activeId))?.focus()}return result}requestReorder(node,delta){const id=node.nodeId,found=this.findRenderedSiblings(node);if(!found)return;const{parent,siblings,index}=found,total=siblings.length,toIndex=index+delta;toIndex<0||toIndex>=total||(this.pendingReorder={node,parent,originalSiblings:[...siblings],targetSibling:siblings[toIndex],fromIndex:index,toIndex},this.emit("lr-reorder",{nodeId:id,parentNodeId:parent?.nodeId??null,fromIndex:index,toIndex}))}confirmPendingReorder(){const pending=this.pendingReorder;if(!pending)return;const found=this.findRenderedSiblings(pending.node);if(!found){this.pendingReorder=void 0;return}(found.siblings.length!==pending.originalSiblings.length||found.siblings.some((node,index)=>node!==pending.originalSiblings[index]))&&(this.pendingReorder=void 0,!(found.parent!==pending.parent||found.index!==pending.toIndex||found.siblings[pending.fromIndex]!==pending.targetSibling)&&this.liveRegion?.announce(this.localize("treeNodeMoved",void 0,{label:pending.node.nodeLabel,index:this.formatCount(found.index+1),total:this.formatCount(found.siblings.length)}),{force:!0}))}async expandAll(){const queue=this.nodeElements.map(node=>({node,depth:0})),seen=new Set;for(let index=0;index<queue.length&&seen.size<TREE_MAX_RENDER_NODES;index++){const{node,depth}=queue[index];seen.has(node)||(seen.add(node),node.isDisabled?node.expanded=!1:node.hasChildren&&node.expand(),await node.updateComplete,depth<TREE_MAX_RENDER_DEPTH&&queue.push(...this.childrenOf(node).map(child=>({node:child,depth:depth+1}))))}}async collapseAll(){const focused=this.deepFocusedNode(),topLevel=this.nodeElements,nodes=this.allNodeElements();for(let index=nodes.length-1;index>=0;index--){const node=nodes[index];node.isDisabled?node.expanded=!1:node.collapse()}(this.hasAuthoredItems?topLevel.some(node=>this.isNavigable(node)&&node.nodeId===this.activeId):this.data.some(item=>!item.disabled&&item.id===this.activeId))||(this.activeId=this.hasAuthoredItems?topLevel.find(node=>this.isNavigable(node))?.nodeId??null:this.firstEnabledId(this.data)),focused&&(this.pendingFocusId=this.activeId),await cascadeUpdateComplete(topLevel)}render(){return html`
2
2
  <div
3
3
  part="base tree"
4
4
  role="tree"
@@ -86,7 +86,10 @@ showLegend:boolean;private svgEl?;private cachedLayout;
86
86
  /** Roving-focus cursor -- an index into `navOrder()`, not into `cachedLayout.placed`. */
87
87
  private focusedIndex;
88
88
  /** Text mirrored in `[part="live-region"]`. */
89
- private liveText;private pressedOriginalIndex;private hoveredOriginalIndex;private announcementSink?;private readonly warnedSkipCounts;private typographyThemeSignature;private paletteThemeSignature;constructor();connectedCallback():void;disconnectedCallback():void;private releaseAnnouncementSink;private syncAnnouncementSink;private fontFamily;
89
+ private liveText;private pressedOriginalIndex;private hoveredOriginalIndex;private announcementSink?;private readonly warnedSkipCounts;private typographyThemeSignature;private paletteThemeSignature;
90
+ /** Whether a host `aria-describedby` was last reflected onto `[part="svg"]` -- see
91
+ * `checkbox.class.ts`'s identically-named field for why the sync call must stay guarded. */
92
+ private hasSyncedDescribedByElements;constructor();connectedCallback():void;disconnectedCallback():void;protected updated(changed:PropertyValues):void;private releaseAnnouncementSink;private syncAnnouncementSink;private fontFamily;
90
93
  /** Reads the actual `--lr-font-weight-semibold` value the same way
91
94
  * `fontFamily()` reads `--lr-font` -- must match `[part='word']`'s
92
95
  * `font-weight` in word-cloud.styles.ts, so a theme/consumer override of
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing,svg}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{isRtl}from"../../../internal/rtl.js";import{getScratchCtx}from"../../../internal/canvas.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteNumber,finiteRange}from"../../../internal/numbers.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{devWarn}from"../../../internal/dev-mode-attribute-warning.js";import{layoutWordCloud,MAX_FONT_SIZE_PX,MAX_WORDS,MIN_SANE_FONT_SIZE}from"./word-cloud-layout.js";import{styles}from"./word-cloud.styles.js";import{LYRA_DEFAULT_items,LYRA_DEFAULT_noData,LYRA_DEFAULT_paginationSummary,LYRA_DEFAULT_wordCloud,LYRA_DEFAULT_wordCloudLegend,LYRA_DEFAULT_wordCloudWord,LYRA_DEFAULT_wordCloudWordAnnouncement,LYRA_DEFAULT_wordCloudWords}from"../../../internal/default-strings.generated.js";const DEFAULT_MIN_FONT_SIZE=12,DEFAULT_MAX_FONT_SIZE=48,PALETTE_SIZE=8,FALLBACK_PALETTE=["#0969da","#1a7f37","#9a6700","#cf222e","#8250df","#bf3989","#0a7d91","#57606a"],DEFAULT_WORD_FONT_WEIGHT="600",NAV_KEYS=new Set(["ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End"]),FOCUS_RING_PAD=2,MAX_INPUT_WORDS=1e4,MAX_WORD_TEXT=256,MAX_TOTAL_WORD_TEXT=16384,MAX_LEGEND_ITEMS=100,MAX_LEGEND_TEXT=256,MAX_TOTAL_LEGEND_TEXT=8192,MAX_PALETTE_ITEMS=64;function warnSkippedWords(count,warnedSkipCounts){warnedSkipCounts.has(count)||(warnedSkipCounts.add(count),devWarn(`<lr-word-cloud> could not place ${count} word(s) (blank text, over the ${MAX_WORDS}-word cap, or the layout search was exhausted) -- they were dropped, not rendered.`))}function boundedText(value,limit){return value.length<=limit?value:`${value.slice(0,Math.max(0,limit-1))}…`}function normalizeWords(value){let input;try{input=Array.isArray(value)?value:[]}catch{input=[]}let inputCount=0;try{inputCount=Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,input.length))}catch{inputCount=0}const scanCount=Math.min(inputCount,MAX_INPUT_WORDS),words=[];let dropped=Math.max(0,inputCount-scanCount),truncated=0,characters=0;for(let index=0;index<scanCount;index++)try{const candidate=input[index];if(typeof candidate!="object"||candidate===null){dropped++;continue}const rawText=candidate.text,rawWeight=candidate.weight,rawColor=candidate.color,rawGroup=candidate.group;if(typeof rawText!="string"){dropped++;continue}const remaining=MAX_TOTAL_WORD_TEXT-characters;if(remaining<=0){dropped+=scanCount-index;break}const textLimit=Math.min(MAX_WORD_TEXT,remaining),text=boundedText(rawText,textLimit);if(!text.trim()){dropped++;continue}let itemTruncated=rawText.length>textLimit;characters+=text.length;const boundedOptionalText=raw=>{if(typeof raw!="string")return;const available=MAX_TOTAL_WORD_TEXT-characters;if(available<=0){raw.length>0&&(itemTruncated=!0);return}const limit=Math.min(MAX_WORD_TEXT,available),result=boundedText(raw,limit);return raw.length>limit&&(itemTruncated=!0),characters+=result.length,result},color=boundedOptionalText(rawColor),group=boundedOptionalText(rawGroup),word={text,weight:Math.max(0,finiteNumber(typeof rawWeight=="number"?rawWeight:0,0)),...color===void 0?{}:{color},...group===void 0?{}:{group}};itemTruncated&&truncated++,words.push(Object.freeze(word))}catch{dropped++}return{items:Object.freeze(words),dropped,truncated,inputCount}}function normalizeLegend(value){let input;try{input=Array.isArray(value)?value:[]}catch{input=[]}let inputCount=0;try{inputCount=Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,input.length))}catch{inputCount=0}const length=Math.min(inputCount,MAX_LEGEND_ITEMS),legend=[];let dropped=Math.max(0,inputCount-length),truncated=0,characters=0;for(let index=0;index<length;index++)try{const item=input[index];if(typeof item!="object"||item===null){dropped++;continue}const rawLabel=item.label,rawColor=item.color;if(typeof rawLabel!="string"||typeof rawColor!="string"){dropped++;continue}const remaining=MAX_TOTAL_LEGEND_TEXT-characters;if(remaining<=0){dropped+=length-index;break}const labelLimit=Math.min(MAX_LEGEND_TEXT,remaining),label=boundedText(rawLabel,labelLimit);if(!label.trim()){dropped++;continue}let itemTruncated=rawLabel.length>labelLimit;characters+=label.length;const colorRemaining=MAX_TOTAL_LEGEND_TEXT-characters,colorLimit=Math.min(MAX_WORD_TEXT,Math.max(0,colorRemaining)),color=colorLimit>0?boundedText(rawColor,colorLimit):"";rawColor.length>colorLimit&&(itemTruncated=!0),characters+=color.length,itemTruncated&&truncated++,legend.push(Object.freeze({label,color}))}catch{dropped++}return{items:Object.freeze(legend),dropped,truncated,inputCount}}function normalizePalette(value){let input;try{input=Array.isArray(value)?value:[]}catch{return}let length=0;try{length=Math.min(input.length,MAX_PALETTE_ITEMS)}catch{return}const palette=[];for(let index=0;index<length;index++)try{const entry=input[index];typeof entry=="string"&&palette.push(boundedText(entry,MAX_WORD_TEXT))}catch{}return Object.freeze(palette)}class LyraWordCloud extends LyraElement{static{this.defaultStrings={...super.defaultStrings,items:LYRA_DEFAULT_items,noData:LYRA_DEFAULT_noData,paginationSummary:LYRA_DEFAULT_paginationSummary,wordCloud:LYRA_DEFAULT_wordCloud,wordCloudLegend:LYRA_DEFAULT_wordCloudLegend,wordCloudWord:LYRA_DEFAULT_wordCloudWord,wordCloudWordAnnouncement:LYRA_DEFAULT_wordCloudWordAnnouncement,wordCloudWords:LYRA_DEFAULT_wordCloudWords}}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}get words(){return this._words}set words(value){const previous=this._words,normalized=normalizeWords(value);this._words=normalized.items,this.inputDroppedCount=normalized.dropped,this.inputTruncatedCount=normalized.truncated,this.inputWordCount=normalized.inputCount,this.requestUpdate("words",previous)}get scale(){return this._scale}set scale(value){const normalized=value==="sqrt"?"sqrt":"linear",previous=this._scale;if(previous===normalized){value!==normalized&&this.requestUpdate("scale",previous);return}this._scale=normalized,this.requestUpdate("scale",previous)}get wordRotation(){return this._wordRotation}set wordRotation(value){const normalized=value==="mixed"?"mixed":"none",previous=this._wordRotation;if(previous===normalized){value!==normalized&&this.requestUpdate("wordRotation",previous);return}this._wordRotation=normalized,this.requestUpdate("wordRotation",previous)}get palette(){return this._palette}set palette(value){const previous=this._palette;this._palette=normalizePalette(value),this.requestUpdate("palette",previous)}get legend(){return this._legend}set legend(value){const previous=this._legend,normalized=normalizeLegend(value);this._legend=normalized.items,this.legendDroppedCount=normalized.dropped,this.legendTruncatedCount=normalized.truncated,this.legendInputCount=normalized.inputCount,this.requestUpdate("legend",previous)}constructor(){super(),this._words=[],this.inputDroppedCount=0,this.inputTruncatedCount=0,this.inputWordCount=0,this.minFontSize=DEFAULT_MIN_FONT_SIZE,this.maxFontSize=DEFAULT_MAX_FONT_SIZE,this._scale="linear",this._wordRotation="none",this._legend=[],this.legendDroppedCount=0,this.legendTruncatedCount=0,this.legendInputCount=0,this.showLegend=!1,this.cachedLayout={placed:[],skipped:[],skippedCount:0,width:0,height:0},this.focusedIndex=null,this.liveText="",this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null,this.warnedSkipCounts=new Set,this.typographyThemeSignature="",this.paletteThemeSignature="",this.onThemeInvalidated=()=>{const typography=`${this.fontWeight()}\0${this.fontFamily()}`,palette=this.paletteColors().join("\0");if(!this.typographyThemeSignature||typography!==this.typographyThemeSignature){this.refreshTheme();return}palette!==this.paletteThemeSignature&&(this.paletteThemeSignature=palette,this.requestUpdate())},this.onSvgFocus=()=>{this.focusedIndex===null&&this.cachedLayout.placed.length>0&&(this.focusedIndex=0)},this.onSvgPointerDown=event=>{const word=this.nearestWord(event);if(!word)return;const index=this.wordIndex(word);index<0||(this.focusedIndex=index,this.pressedOriginalIndex=word.originalIndex,this.svgEl?.focus())},this.onSvgPointerMove=event=>{this.hoveredOriginalIndex=this.nearestWord(event)?.originalIndex??null},this.clearPointerPress=()=>{this.pressedOriginalIndex=null},this.onSvgPointerLeave=()=>{this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null},this.onSvgClick=event=>{const word=this.nearestWord(event);word&&this.onWordClick(word)},this.onWordClick=word=>{const order=this.navOrder(),idx=order.findIndex(w=>w.originalIndex===word.originalIndex);this.focusedIndex=idx===-1?null:idx,idx!==-1&&this.announce(order[idx]),this.svgEl?.focus(),this.activate(word)},this.onKeyDown=e=>{const order=this.navOrder();if(order.length===0)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.focusedIndex!==null&&this.activate(order[this.focusedIndex]);return}if(!NAV_KEYS.has(e.key))return;if(e.preventDefault(),this.focusedIndex===null){const next2=e.key==="End"?order.length-1:0;this.focusedIndex=next2,this.announce(order[next2]);return}const rtl=isRtl(this),forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft";let next=this.focusedIndex;e.key===forwardKey||e.key==="ArrowDown"?next=Math.min(order.length-1,this.focusedIndex+1):e.key===backwardKey||e.key==="ArrowUp"?next=Math.max(0,this.focusedIndex-1):e.key==="Home"?next=0:e.key==="End"&&(next=order.length-1),this.focusedIndex=next,this.announce(order[next])},new ThemeWatcher(this,this.onThemeInvalidated)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink()}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink(),this.focusedIndex=null,this.liveText="",this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}fontFamily(){return getComputedStyle(this).getPropertyValue("--lr-font").trim()||"sans-serif"}fontWeight(){return getComputedStyle(this).getPropertyValue("--lr-font-weight-semibold").trim()||DEFAULT_WORD_FONT_WEIGHT}paletteColors(){if(this.palette?.length){const colors2=this.palette.map(sanitizeCssColor).filter(color=>color!==void 0);if(colors2.length)return colors2}const cs=getComputedStyle(this),colors=[];for(let i=0;i<PALETTE_SIZE;i++)colors.push(cs.getPropertyValue(`--lr-word-cloud-color-${i+1}`).trim()||cs.getPropertyValue(`--_lr-word-cloud-color-${i+1}-default`).trim()||FALLBACK_PALETTE[i]);return colors}navOrder(){return[...this.cachedLayout.placed].sort((a,b)=>a.originalIndex-b.originalIndex)}willUpdate(changed){super.willUpdate(changed),(changed.has("words")||changed.has("minFontSize")||changed.has("maxFontSize")||changed.has("domain")||changed.has("scale")||changed.has("wordRotation"))&&this.relayout()}relayout(preserveInteraction=!1){const focusedOriginalIndex=preserveInteraction&&this.focusedIndex!==null?this.navOrder()[this.focusedIndex]?.originalIndex:void 0,priorLiveText=this.liveText,fontWeight=this.fontWeight(),fontFamily=this.fontFamily(),measureText=(text,fontSize)=>{const ctx=getScratchCtx();return ctx?(ctx.font=`${fontWeight} ${fontSize}px ${fontFamily}`,ctx.measureText(text).width):text.length*fontSize*.6},minFontSize=finiteRange(this.minFontSize,DEFAULT_MIN_FONT_SIZE,MIN_SANE_FONT_SIZE,MAX_FONT_SIZE_PX),maxFontSize=finiteRange(this.maxFontSize,DEFAULT_MAX_FONT_SIZE,MIN_SANE_FONT_SIZE,MAX_FONT_SIZE_PX);this.cachedLayout=layoutWordCloud(this.words,{minFontSize,maxFontSize,domain:this.domain,scale:this.scale,wordRotation:this.wordRotation,measureText});const skippedCount=this.inputDroppedCount+this.cachedLayout.skippedCount;if(skippedCount>0&&warnSkippedWords(skippedCount,this.warnedSkipCounts),focusedOriginalIndex!==void 0){const nextIndex=this.navOrder().findIndex(word=>word.originalIndex===focusedOriginalIndex);this.focusedIndex=nextIndex<0?null:nextIndex,this.liveText=nextIndex<0?"":priorLiveText}else this.focusedIndex=null,this.liveText="";this.hoveredOriginalIndex=null}refreshTheme(){this.relayout(!0),this.captureThemeSignatures(),this.requestUpdate()}captureThemeSignatures(){this.typographyThemeSignature=`${this.fontWeight()}\0${this.fontFamily()}`,this.paletteThemeSignature=this.paletteColors().join("\0")}firstUpdated(changed){super.firstUpdated(changed),this.captureThemeSignatures()}activate(word){this.emit("lr-word-activate",Object.freeze({text:word.text,weight:word.weight,group:word.group}))}announce(word){const text=this.localize("wordCloudWordAnnouncement",void 0,{text:word.text,weight:getNumberFormat(this.effectiveLocale).format(word.weight)});this.liveText=text,this.announcementSink?.announce(text)}wordIndex(word){return this.navOrder().findIndex(candidate=>candidate.originalIndex===word.originalIndex)}nearestWord(event){const svgElement=this.svgEl;if(!svgElement||this.cachedLayout.placed.length===0)return;let x,y;try{const matrix=svgElement.getScreenCTM(),DOMPointCtor=this.ownerDocument.defaultView?.DOMPoint;if(!matrix||!DOMPointCtor)throw new Error("No SVG transform");const point=new DOMPointCtor(event.clientX,event.clientY).matrixTransform(matrix.inverse());x=point.x,y=point.y}catch{const rect=svgElement.getBoundingClientRect();if(rect.width<=0||rect.height<=0)return;x=(event.clientX-rect.left)/rect.width*this.cachedLayout.width,y=(event.clientY-rect.top)/rect.height*this.cachedLayout.height}let nearest,distance=Number.POSITIVE_INFINITY;for(const word of this.cachedLayout.placed){const dx=word.x-x,dy=word.y-y,candidateDistance=dx*dx+dy*dy;candidateDistance<distance&&(distance=candidateDistance,nearest=word)}return nearest}collectionSummary(shown,total,itemLabel){return this.localize("paginationSummary",void 0,{start:this.formatCount(shown===0?0:1),end:this.formatCount(shown),total:this.formatCount(total),itemLabel})}renderLegend(entries,explicitInput){if(!this.showLegend)return nothing;const hasLimit=explicitInput&&(this.legendDroppedCount>0||this.legendTruncatedCount>0);if(entries.length===0&&!hasLimit)return nothing;const limitText=hasLimit?this.collectionSummary(entries.length,this.legendInputCount,this.localize("items")):"";return html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing,svg}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-tokens.styles.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{syncAriaDescribedByElements}from"../../../internal/aria-reflection.js";import{isRtl}from"../../../internal/rtl.js";import{getScratchCtx}from"../../../internal/canvas.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteNumber,finiteRange}from"../../../internal/numbers.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{devWarn}from"../../../internal/dev-mode-attribute-warning.js";import{layoutWordCloud,MAX_FONT_SIZE_PX,MAX_WORDS,MIN_SANE_FONT_SIZE}from"./word-cloud-layout.js";import{styles}from"./word-cloud.styles.js";import{LYRA_DEFAULT_items,LYRA_DEFAULT_noData,LYRA_DEFAULT_paginationSummary,LYRA_DEFAULT_wordCloud,LYRA_DEFAULT_wordCloudLegend,LYRA_DEFAULT_wordCloudWord,LYRA_DEFAULT_wordCloudWordAnnouncement,LYRA_DEFAULT_wordCloudWords}from"../../../internal/default-strings.generated.js";const DEFAULT_MIN_FONT_SIZE=12,DEFAULT_MAX_FONT_SIZE=48,PALETTE_SIZE=8,FALLBACK_PALETTE=["#0969da","#1a7f37","#9a6700","#cf222e","#8250df","#bf3989","#0a7d91","#57606a"],DEFAULT_WORD_FONT_WEIGHT="600",NAV_KEYS=new Set(["ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End"]),FOCUS_RING_PAD=2,MAX_INPUT_WORDS=1e4,MAX_WORD_TEXT=256,MAX_TOTAL_WORD_TEXT=16384,MAX_LEGEND_ITEMS=100,MAX_LEGEND_TEXT=256,MAX_TOTAL_LEGEND_TEXT=8192,MAX_PALETTE_ITEMS=64;function warnSkippedWords(count,warnedSkipCounts){warnedSkipCounts.has(count)||(warnedSkipCounts.add(count),devWarn(`<lr-word-cloud> could not place ${count} word(s) (blank text, over the ${MAX_WORDS}-word cap, or the layout search was exhausted) -- they were dropped, not rendered.`))}function boundedText(value,limit){return value.length<=limit?value:`${value.slice(0,Math.max(0,limit-1))}…`}function normalizeWords(value){let input;try{input=Array.isArray(value)?value:[]}catch{input=[]}let inputCount=0;try{inputCount=Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,input.length))}catch{inputCount=0}const scanCount=Math.min(inputCount,MAX_INPUT_WORDS),words=[];let dropped=Math.max(0,inputCount-scanCount),truncated=0,characters=0;for(let index=0;index<scanCount;index++)try{const candidate=input[index];if(typeof candidate!="object"||candidate===null){dropped++;continue}const rawText=candidate.text,rawWeight=candidate.weight,rawColor=candidate.color,rawGroup=candidate.group;if(typeof rawText!="string"){dropped++;continue}const remaining=MAX_TOTAL_WORD_TEXT-characters;if(remaining<=0){dropped+=scanCount-index;break}const textLimit=Math.min(MAX_WORD_TEXT,remaining),text=boundedText(rawText,textLimit);if(!text.trim()){dropped++;continue}let itemTruncated=rawText.length>textLimit;characters+=text.length;const boundedOptionalText=raw=>{if(typeof raw!="string")return;const available=MAX_TOTAL_WORD_TEXT-characters;if(available<=0){raw.length>0&&(itemTruncated=!0);return}const limit=Math.min(MAX_WORD_TEXT,available),result=boundedText(raw,limit);return raw.length>limit&&(itemTruncated=!0),characters+=result.length,result},color=boundedOptionalText(rawColor),group=boundedOptionalText(rawGroup),word={text,weight:Math.max(0,finiteNumber(typeof rawWeight=="number"?rawWeight:0,0)),...color===void 0?{}:{color},...group===void 0?{}:{group}};itemTruncated&&truncated++,words.push(Object.freeze(word))}catch{dropped++}return{items:Object.freeze(words),dropped,truncated,inputCount}}function normalizeLegend(value){let input;try{input=Array.isArray(value)?value:[]}catch{input=[]}let inputCount=0;try{inputCount=Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,input.length))}catch{inputCount=0}const length=Math.min(inputCount,MAX_LEGEND_ITEMS),legend=[];let dropped=Math.max(0,inputCount-length),truncated=0,characters=0;for(let index=0;index<length;index++)try{const item=input[index];if(typeof item!="object"||item===null){dropped++;continue}const rawLabel=item.label,rawColor=item.color;if(typeof rawLabel!="string"||typeof rawColor!="string"){dropped++;continue}const remaining=MAX_TOTAL_LEGEND_TEXT-characters;if(remaining<=0){dropped+=length-index;break}const labelLimit=Math.min(MAX_LEGEND_TEXT,remaining),label=boundedText(rawLabel,labelLimit);if(!label.trim()){dropped++;continue}let itemTruncated=rawLabel.length>labelLimit;characters+=label.length;const colorRemaining=MAX_TOTAL_LEGEND_TEXT-characters,colorLimit=Math.min(MAX_WORD_TEXT,Math.max(0,colorRemaining)),color=colorLimit>0?boundedText(rawColor,colorLimit):"";rawColor.length>colorLimit&&(itemTruncated=!0),characters+=color.length,itemTruncated&&truncated++,legend.push(Object.freeze({label,color}))}catch{dropped++}return{items:Object.freeze(legend),dropped,truncated,inputCount}}function normalizePalette(value){let input;try{input=Array.isArray(value)?value:[]}catch{return}let length=0;try{length=Math.min(input.length,MAX_PALETTE_ITEMS)}catch{return}const palette=[];for(let index=0;index<length;index++)try{const entry=input[index];typeof entry=="string"&&palette.push(boundedText(entry,MAX_WORD_TEXT))}catch{}return Object.freeze(palette)}class LyraWordCloud extends LyraElement{static{this.defaultStrings={...super.defaultStrings,items:LYRA_DEFAULT_items,noData:LYRA_DEFAULT_noData,paginationSummary:LYRA_DEFAULT_paginationSummary,wordCloud:LYRA_DEFAULT_wordCloud,wordCloudLegend:LYRA_DEFAULT_wordCloudLegend,wordCloudWord:LYRA_DEFAULT_wordCloudWord,wordCloudWordAnnouncement:LYRA_DEFAULT_wordCloudWordAnnouncement,wordCloudWords:LYRA_DEFAULT_wordCloudWords}}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}get words(){return this._words}set words(value){const previous=this._words,normalized=normalizeWords(value);this._words=normalized.items,this.inputDroppedCount=normalized.dropped,this.inputTruncatedCount=normalized.truncated,this.inputWordCount=normalized.inputCount,this.requestUpdate("words",previous)}get scale(){return this._scale}set scale(value){const normalized=value==="sqrt"?"sqrt":"linear",previous=this._scale;if(previous===normalized){value!==normalized&&this.requestUpdate("scale",previous);return}this._scale=normalized,this.requestUpdate("scale",previous)}get wordRotation(){return this._wordRotation}set wordRotation(value){const normalized=value==="mixed"?"mixed":"none",previous=this._wordRotation;if(previous===normalized){value!==normalized&&this.requestUpdate("wordRotation",previous);return}this._wordRotation=normalized,this.requestUpdate("wordRotation",previous)}get palette(){return this._palette}set palette(value){const previous=this._palette;this._palette=normalizePalette(value),this.requestUpdate("palette",previous)}get legend(){return this._legend}set legend(value){const previous=this._legend,normalized=normalizeLegend(value);this._legend=normalized.items,this.legendDroppedCount=normalized.dropped,this.legendTruncatedCount=normalized.truncated,this.legendInputCount=normalized.inputCount,this.requestUpdate("legend",previous)}constructor(){super(),this._words=[],this.inputDroppedCount=0,this.inputTruncatedCount=0,this.inputWordCount=0,this.minFontSize=DEFAULT_MIN_FONT_SIZE,this.maxFontSize=DEFAULT_MAX_FONT_SIZE,this._scale="linear",this._wordRotation="none",this._legend=[],this.legendDroppedCount=0,this.legendTruncatedCount=0,this.legendInputCount=0,this.showLegend=!1,this.cachedLayout={placed:[],skipped:[],skippedCount:0,width:0,height:0},this.focusedIndex=null,this.liveText="",this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null,this.warnedSkipCounts=new Set,this.typographyThemeSignature="",this.paletteThemeSignature="",this.hasSyncedDescribedByElements=!1,this.onThemeInvalidated=()=>{const typography=`${this.fontWeight()}\0${this.fontFamily()}`,palette=this.paletteColors().join("\0");if(!this.typographyThemeSignature||typography!==this.typographyThemeSignature){this.refreshTheme();return}palette!==this.paletteThemeSignature&&(this.paletteThemeSignature=palette,this.requestUpdate())},this.onSvgFocus=()=>{this.focusedIndex===null&&this.cachedLayout.placed.length>0&&(this.focusedIndex=0)},this.onSvgPointerDown=event=>{const word=this.nearestWord(event);if(!word)return;const index=this.wordIndex(word);index<0||(this.focusedIndex=index,this.pressedOriginalIndex=word.originalIndex,this.svgEl?.focus())},this.onSvgPointerMove=event=>{this.hoveredOriginalIndex=this.nearestWord(event)?.originalIndex??null},this.clearPointerPress=()=>{this.pressedOriginalIndex=null},this.onSvgPointerLeave=()=>{this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null},this.onSvgClick=event=>{const word=this.nearestWord(event);word&&this.onWordClick(word)},this.onWordClick=word=>{const order=this.navOrder(),idx=order.findIndex(w=>w.originalIndex===word.originalIndex);this.focusedIndex=idx===-1?null:idx,idx!==-1&&this.announce(order[idx]),this.svgEl?.focus(),this.activate(word)},this.onKeyDown=e=>{const order=this.navOrder();if(order.length===0)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.focusedIndex!==null&&this.activate(order[this.focusedIndex]);return}if(!NAV_KEYS.has(e.key))return;if(e.preventDefault(),this.focusedIndex===null){const next2=e.key==="End"?order.length-1:0;this.focusedIndex=next2,this.announce(order[next2]);return}const rtl=isRtl(this),forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft";let next=this.focusedIndex;e.key===forwardKey||e.key==="ArrowDown"?next=Math.min(order.length-1,this.focusedIndex+1):e.key===backwardKey||e.key==="ArrowUp"?next=Math.max(0,this.focusedIndex-1):e.key==="Home"?next=0:e.key==="End"&&(next=order.length-1),this.focusedIndex=next,this.announce(order[next])},new ThemeWatcher(this,this.onThemeInvalidated)}connectedCallback(){super.connectedCallback(),this.syncAnnouncementSink()}disconnectedCallback(){super.disconnectedCallback(),this.releaseAnnouncementSink(),this.focusedIndex=null,this.liveText="",this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null}updated(changed){super.updated(changed);const describedBy=this.getAttribute("aria-describedby");!describedBy&&!this.hasSyncedDescribedByElements||(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,this.svgEl,describedBy))}releaseAnnouncementSink(){this.announcementSink?.release(),this.announcementSink=void 0}syncAnnouncementSink(){if(!this.isConnected){this.releaseAnnouncementSink();return}this.announcementSink?.element.ownerDocument!==this.ownerDocument&&(this.releaseAnnouncementSink(),this.announcementSink=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this}))}fontFamily(){return getComputedStyle(this).getPropertyValue("--lr-font").trim()||"sans-serif"}fontWeight(){return getComputedStyle(this).getPropertyValue("--lr-font-weight-semibold").trim()||DEFAULT_WORD_FONT_WEIGHT}paletteColors(){if(this.palette?.length){const colors2=this.palette.map(sanitizeCssColor).filter(color=>color!==void 0);if(colors2.length)return colors2}const cs=getComputedStyle(this),colors=[];for(let i=0;i<PALETTE_SIZE;i++)colors.push(cs.getPropertyValue(`--lr-word-cloud-color-${i+1}`).trim()||cs.getPropertyValue(`--_lr-word-cloud-color-${i+1}-default`).trim()||FALLBACK_PALETTE[i]);return colors}navOrder(){return[...this.cachedLayout.placed].sort((a,b)=>a.originalIndex-b.originalIndex)}willUpdate(changed){super.willUpdate(changed),(changed.has("words")||changed.has("minFontSize")||changed.has("maxFontSize")||changed.has("domain")||changed.has("scale")||changed.has("wordRotation"))&&this.relayout()}relayout(preserveInteraction=!1){const focusedOriginalIndex=preserveInteraction&&this.focusedIndex!==null?this.navOrder()[this.focusedIndex]?.originalIndex:void 0,priorLiveText=this.liveText,fontWeight=this.fontWeight(),fontFamily=this.fontFamily(),measureText=(text,fontSize)=>{const ctx=getScratchCtx();return ctx?(ctx.font=`${fontWeight} ${fontSize}px ${fontFamily}`,ctx.measureText(text).width):text.length*fontSize*.6},minFontSize=finiteRange(this.minFontSize,DEFAULT_MIN_FONT_SIZE,MIN_SANE_FONT_SIZE,MAX_FONT_SIZE_PX),maxFontSize=finiteRange(this.maxFontSize,DEFAULT_MAX_FONT_SIZE,MIN_SANE_FONT_SIZE,MAX_FONT_SIZE_PX);this.cachedLayout=layoutWordCloud(this.words,{minFontSize,maxFontSize,domain:this.domain,scale:this.scale,wordRotation:this.wordRotation,measureText});const skippedCount=this.inputDroppedCount+this.cachedLayout.skippedCount;if(skippedCount>0&&warnSkippedWords(skippedCount,this.warnedSkipCounts),focusedOriginalIndex!==void 0){const nextIndex=this.navOrder().findIndex(word=>word.originalIndex===focusedOriginalIndex);this.focusedIndex=nextIndex<0?null:nextIndex,this.liveText=nextIndex<0?"":priorLiveText}else this.focusedIndex=null,this.liveText="";this.hoveredOriginalIndex=null}refreshTheme(){this.relayout(!0),this.captureThemeSignatures(),this.requestUpdate()}captureThemeSignatures(){this.typographyThemeSignature=`${this.fontWeight()}\0${this.fontFamily()}`,this.paletteThemeSignature=this.paletteColors().join("\0")}firstUpdated(changed){super.firstUpdated(changed),this.captureThemeSignatures()}activate(word){this.emit("lr-word-activate",Object.freeze({text:word.text,weight:word.weight,group:word.group}))}announce(word){const text=this.localize("wordCloudWordAnnouncement",void 0,{text:word.text,weight:getNumberFormat(this.effectiveLocale).format(word.weight)});this.liveText=text,this.announcementSink?.announce(text)}wordIndex(word){return this.navOrder().findIndex(candidate=>candidate.originalIndex===word.originalIndex)}nearestWord(event){const svgElement=this.svgEl;if(!svgElement||this.cachedLayout.placed.length===0)return;let x,y;try{const matrix=svgElement.getScreenCTM(),DOMPointCtor=this.ownerDocument.defaultView?.DOMPoint;if(!matrix||!DOMPointCtor)throw new Error("No SVG transform");const point=new DOMPointCtor(event.clientX,event.clientY).matrixTransform(matrix.inverse());x=point.x,y=point.y}catch{const rect=svgElement.getBoundingClientRect();if(rect.width<=0||rect.height<=0)return;x=(event.clientX-rect.left)/rect.width*this.cachedLayout.width,y=(event.clientY-rect.top)/rect.height*this.cachedLayout.height}let nearest,distance=Number.POSITIVE_INFINITY;for(const word of this.cachedLayout.placed){const dx=word.x-x,dy=word.y-y,candidateDistance=dx*dx+dy*dy;candidateDistance<distance&&(distance=candidateDistance,nearest=word)}return nearest}collectionSummary(shown,total,itemLabel){return this.localize("paginationSummary",void 0,{start:this.formatCount(shown===0?0:1),end:this.formatCount(shown),total:this.formatCount(total),itemLabel})}renderLegend(entries,explicitInput){if(!this.showLegend)return nothing;const hasLimit=explicitInput&&(this.legendDroppedCount>0||this.legendTruncatedCount>0);if(entries.length===0&&!hasLimit)return nothing;const limitText=hasLimit?this.collectionSummary(entries.length,this.legendInputCount,this.localize("items")):"";return html`
2
2
  ${entries.length?html`<div
3
3
  part="legend"
4
4
  role="list"
@@ -26,7 +26,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
26
26
  part="svg"
27
27
  role="application"
28
28
  aria-label=${accessibleLabel}
29
- aria-describedby=${hasWordLimit?"word-limit":nothing}
29
+ aria-describedby=${[this.getAttribute("aria-describedby")??"",hasWordLimit?"word-limit":""].filter(Boolean).join(" ")||nothing}
30
30
  tabindex="0"
31
31
  viewBox="0 0 ${layout.width} ${layout.height}"
32
32
  @focus=${this.onSvgFocus}
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_a;import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{FORM_CONTROL_LABEL_FACTORY,LyraElement}from"../../../internal/lyra-element.js";import{installFormControlInternalsCapture}from"../../../internal/form-control-labels.js";import{chevronIcon,spinnerIcon}from"../../../internal/icons.js";import{tag}from"../../../internal/prefix.js";import{safeDownloadHref,safeLinkHref}from"../../../internal/safe-url.js";import{syncAriaControlsElements}from"../../../internal/aria-reflection.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{sizes}from"../../../internal/sizes.styles.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./button.styles.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{getFormOwner,installCustomErrorProperty,setFormOwner}from"../../../internal/direct-form-associated.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState}from"../../../internal/custom-states.js";import{omittedEmptyStringConverter}from"../../../internal/converters.js";import{currentValidityValidator}from"../form-validator.js";import{createButtonExternalLabelController}from"./button-external-label.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";installFormControlInternalsCapture();function isVisuallyHidden(element){if(element.localName===tag("visually-hidden"))return!0;const view=element.ownerDocument.defaultView;if(!view)return!1;const style=view.getComputedStyle(element);return style.display==="none"||style.visibility==="hidden"?!0:style.position==="absolute"&&style.clipPath.startsWith("inset(50%")}class LyraButton extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","loading","href","value")]}static{this.styles=[LyraElement.styles,sizes,variants,styles]}static{this.formAssociated=!0}static{this[_a]=createButtonExternalLabelController}static{this.properties={disabled:{type:Boolean,reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},customError:{attribute:"custom-error",reflect:!0,noAccessor:!0}}}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old),this.updateValidity()}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get effectiveDisabled(){return this._disabled||this._fieldsetDisabled}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}constructor(){super(),this._fieldsetDisabled=!1,this._disabled=!1,this._name="",this._value="",this._required=!1,this._variant="neutral",this.localDescriptionIds="",this.customValidityMessage="",this.reflectingCustomError=!1,this.accessibleLabel=null,this.triggerHasPopup=null,this.triggerExpanded=null,this.triggerPressed=null,this.triggerCurrent=null,this.triggerControls=null,this.triggerDescribedBy=null,this.appearance="accent",this.size="m",this.pill=!1,this.circle=!1,this.outline=!1,this.withCaret=!1,this.withStart=!1,this.withEnd=!1,this.wrap=!1,this.type="button",this.formNoValidate=!1,this.loading=!1,this.hasStartSlot=!1,this.hasEndSlot=!1,this.isIconButton=!1,this.onClick=event=>{if(this.type!=="submit"&&this.type!=="reset")return;const ownerWindow=this.ownerDocument.defaultView;let settled=!1;const finish=()=>{settled||(settled=!0,ownerWindow?.removeEventListener("click",finishAtWindow),!(event.defaultPrevented||this.effectiveDisabled||this.loading)&&this.runClickDefaultAction())},finishAtWindow=candidate=>{candidate===event&&finish()};ownerWindow?.addEventListener("click",finishAtWindow),queueMicrotask(finish)},this.onFocus=event=>{relayNativeEvent(this,event)},this.onBlur=event=>{relayNativeEvent(this,event)},this.onStartSlotChange=()=>{this.syncAdornmentSlots()},this.onEndSlotChange=()=>{this.syncAdornmentSlots()},this.onDefaultSlotChange=()=>{this.isIconButton=this.hasIconOnlyDefaultContent(),this.syncButtonStates()},installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.customValidityMessage),this.updateValidity(),this.syncButtonStates()}get variant(){return this._variant}set variant(next){next==="primary"?this._variant="brand":next==="default"||next==="text"?this._variant="neutral":this._variant=next,next==="text"&&(this.appearance="plain")}get caret(){return this.withCaret}set caret(next){this.withCaret=!!next}get value(){return this._value}set value(next){this._value=next??"",this.updateValidity()}get required(){return this._required}set required(next){this._required=!!next,this.updateValidity()}get resolvedRel(){const authored=(this.rel??"").split(/\s+/).filter(token=>token!==""&&token.toLowerCase()!=="opener"),tokens=new Set(authored);return this.target&&(tokens.add("noopener"),tokens.add("noreferrer")),tokens.size>0?[...tokens].join(" "):void 0}click(){this.effectiveDisabled||this.loading||this.baseEl?.click()}focus(options){!this.effectiveDisabled&&!this.loading&&this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}[(_a=FORM_CONTROL_LABEL_FACTORY,VALIDITY_ANCHOR)](){return this.baseEl??null}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}setCustomValidity(message){const old=this.customValidityMessage||null,next=message??"";if(this.customValidityMessage=next,this.validityController.setCustomValidity(this.isValidationBarred?"":next),!this.reflectingCustomError){this.reflectingCustomError=!0;try{next?this.setAttribute("custom-error",next):this.removeAttribute("custom-error")}finally{this.reflectingCustomError=!1}}this.requestUpdate("customError",old)}resetValidity(){this.customValidityMessage="",this.validityController.setCustomValidity(""),this.updateValidity()}formStateRestoreCallback(state2,reason){this.value=typeof state2=="string"?state2:""}runClickDefaultAction(){if(this.type==="submit"){const form=this.getForm();if(!form)return;this.hasSubmitterOverrides?this.submitAsNamedSubmitter(form):form.requestSubmit()}else this.type==="reset"&&this.getForm()?.reset()}get hasSubmitterOverrides(){return!!(this.name||this.value||this.formNoValidate)||this.formAction!==void 0||this.formEnctype!==void 0||this.formMethod!==void 0||this.formTarget!==void 0}submitAsNamedSubmitter(form){const submitter=this.ownerDocument.createElement("button");submitter.type="submit",submitter.hidden=!0,submitter.tabIndex=-1,this.name&&(submitter.name=this.name,submitter.value=this.value),this.formAction!==void 0&&submitter.setAttribute("formaction",this.formAction),this.formEnctype!==void 0&&submitter.setAttribute("formenctype",this.formEnctype),this.formMethod!==void 0&&submitter.setAttribute("formmethod",this.formMethod),this.formNoValidate&&(submitter.formNoValidate=!0),this.formTarget!==void 0&&submitter.setAttribute("formtarget",this.formTarget),this.parentElement&&this.closest("form")===form?this.insertAdjacentElement("afterend",submitter):form.append(submitter);try{form.requestSubmit(submitter)}finally{submitter.remove()}}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.updateValidity(),this.syncButtonStates(),this.requestUpdate()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncDescribedByElements(),this.updateValidity(),this.syncButtonStates(),this.hasUpdated&&this.armIconOnlyResizeObserver()}disconnectedCallback(){this.releaseExternalDescription(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.iconOnlyResizeRaf!==void 0&&this.iconOnlyResizeRafOwner?.cancelAnimationFrame(this.iconOnlyResizeRaf),this.iconOnlyResizeRaf=void 0,this.iconOnlyResizeRafOwner=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncDescribedByElements()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.syncAdornmentSlots(),this.isIconButton=this.hasIconOnlyDefaultContent())}syncAdornmentSlots(){const collection=this.children,children=collection?Array.from(collection):[];this.hasStartSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="start"||slot==="prefix"}),this.hasEndSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="end"||slot==="suffix"})}hasIconOnlyDefaultContent(){const childElements=this.children,elements=(childElements?Array.from(childElements):[]).filter(element=>!element.getAttribute("slot")).filter(element=>!isVisuallyHidden(element));if(elements.length!==1)return!1;const childNodes=this.childNodes;return(childNodes?Array.from(childNodes):[]).filter(node=>node.nodeType===3).map(node=>node.textContent??"").join("").trim()===""&&(elements[0]?.textContent??"").trim()===""}armIconOnlyResizeObserver(){const labelEl=this.labelEl;if(this.resizeObserver||!labelEl)return;const view=this.ownerDocument.defaultView,ResizeObserverCtor=view?.ResizeObserver;!view||!ResizeObserverCtor||(this.resizeObserver=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==view||(this.iconOnlyResizeRaf!==void 0&&this.iconOnlyResizeRafOwner?.cancelAnimationFrame(this.iconOnlyResizeRaf),this.iconOnlyResizeRafOwner=view,this.iconOnlyResizeRaf=view.requestAnimationFrame(()=>{if(this.iconOnlyResizeRaf=void 0,this.iconOnlyResizeRafOwner=void 0,!this.isConnected||this.ownerDocument.defaultView!==view)return;const next=this.hasIconOnlyDefaultContent();next!==this.isIconButton&&(this.isIconButton=next,this.syncButtonStates())}))}),this.resizeObserver.observe(labelEl))}get labelGrows(){return this.withCaret||this.hasEndSlot||this.withEnd}updated(changed){super.updated(changed),syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements(),this.armIconOnlyResizeObserver(),this.updateValidity(),this.syncButtonStates()}updateValidity(){if(this.validityController){if(this.isValidationBarred){this.validityController.setCustomValidity(""),this.validityController.setValidity({});return}this.required&&!this.value?this.validityController.setValidity({valueMissing:!0},this.localize("fieldRequired")):this.validityController.setValidity({}),this.validityController.setCustomValidity(this.customValidityMessage)}}get isValidationBarred(){return this.effectiveDisabled||this.loading||this.baseEl?.localName==="a"}syncButtonStates(){this.internals&&(setCustomState(this.internals,"disabled",this.effectiveDisabled||this.loading),setCustomState(this.internals,"icon-button",this.isIconButton),setCustomState(this.internals,"link",this.baseEl?.localName==="a"),setCustomState(this.internals,"loading",this.loading))}syncDescribedByElements(){const target=this.isConnected?this.baseEl:void 0;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}render(){const pressed=["true","false","mixed"].includes(this.triggerPressed??"")?this.triggerPressed:nothing,current=["page","step","location","date","time","true","false"].includes(this.triggerCurrent??"")?this.triggerCurrent:nothing,content=html`
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_a;import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{FORM_CONTROL_LABEL_FACTORY,LyraElement}from"../../../internal/lyra-element.js";import{installFormControlInternalsCapture}from"../../../internal/form-control-labels.js";import{chevronIcon,spinnerIcon}from"../../../internal/icons.js";import{tag}from"../../../internal/prefix.js";import{safeDownloadHref,safeLinkHref}from"../../../internal/safe-url.js";import{syncAriaControlsElements}from"../../../internal/aria-reflection.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{sizes}from"../../../internal/sizes.styles.js";import{variants}from"../../../internal/variants.styles.js";import{styles}from"./button.styles.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{getFormOwner,installCustomErrorProperty,setFormOwner}from"../../../internal/direct-form-associated.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{AnchoredValidityController,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState}from"../../../internal/custom-states.js";import{omittedEmptyStringConverter}from"../../../internal/converters.js";import{currentValidityValidator}from"../form-validator.js";import{createButtonExternalLabelController}from"./button-external-label.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";installFormControlInternalsCapture();function isVisuallyHidden(element){if(element.localName===tag("visually-hidden"))return!0;const view=element.ownerDocument.defaultView;if(!view)return!1;const style=view.getComputedStyle(element);return style.display==="none"||style.visibility==="hidden"?!0:style.position==="absolute"&&style.clipPath.startsWith("inset(50%")}class LyraButton extends LyraElement{static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","loading","href","value")]}static{this.styles=[LyraElement.styles,sizes,variants,styles]}static{this.formAssociated=!0}static{this[_a]=createButtonExternalLabelController}static{this.properties={disabled:{type:Boolean,reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},customError:{attribute:"custom-error",reflect:!0,noAccessor:!0}}}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.requestUpdate("disabled",old),this.updateValidity()}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get effectiveDisabled(){return this._disabled||this._fieldsetDisabled}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}constructor(){super(),this._fieldsetDisabled=!1,this._disabled=!1,this._name="",this._value="",this._required=!1,this._variant="neutral",this.localDescriptionIds="",this.customValidityMessage="",this.reflectingCustomError=!1,this.accessibleLabel=null,this.triggerHasPopup=null,this.triggerExpanded=null,this.triggerPressed=null,this.triggerCurrent=null,this.triggerControls=null,this.triggerDescribedBy=null,this.appearance="accent",this.size="m",this.pill=!1,this.circle=!1,this.outline=!1,this.withCaret=!1,this.withStart=!1,this.withEnd=!1,this.wrap=!1,this.type="button",this.formNoValidate=!1,this.loading=!1,this.hasStartSlot=!1,this.hasEndSlot=!1,this.isIconButton=!1,this.onClick=event=>{if(this.type!=="submit"&&this.type!=="reset")return;const ownerWindow=this.ownerDocument.defaultView;let settled=!1;const finish=()=>{settled||(settled=!0,ownerWindow?.removeEventListener("click",finishAtWindow),!(event.defaultPrevented||this.effectiveDisabled||this.loading)&&this.runClickDefaultAction())},finishAtWindow=candidate=>{candidate===event&&finish()};ownerWindow?.addEventListener("click",finishAtWindow),queueMicrotask(finish)},this.onFocus=event=>{relayNativeEvent(this,event)},this.onBlur=event=>{relayNativeEvent(this,event)},this.onStartSlotChange=()=>{this.syncAdornmentSlots()},this.onEndSlotChange=()=>{this.syncAdornmentSlots()},this.onDefaultSlotChange=()=>{this.isIconButton=this.hasIconOnlyDefaultContent(),this.syncButtonStates()},installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.customValidityMessage),this.updateValidity(),this.syncButtonStates()}get variant(){return this._variant}set variant(next){next==="primary"?this._variant="brand":next==="default"||next==="text"?this._variant="neutral":this._variant=next,next==="text"&&(this.appearance="plain")}get caret(){return this.withCaret}set caret(next){this.withCaret=!!next}get value(){return this._value}set value(next){this._value=next??"",this.updateValidity()}get required(){return this._required}set required(next){this._required=!!next,this.updateValidity()}get resolvedRel(){const authored=(this.rel??"").split(/\s+/).filter(token=>token!==""&&token.toLowerCase()!=="opener"),tokens=new Set(authored);return this.target&&(tokens.add("noopener"),tokens.add("noreferrer")),tokens.size>0?[...tokens].join(" "):void 0}click(){this.effectiveDisabled||this.loading||this.baseEl?.click()}focus(options){!this.effectiveDisabled&&!this.loading&&this.baseEl?.focus(options)}blur(){this.baseEl?.blur()}[(_a=FORM_CONTROL_LABEL_FACTORY,VALIDITY_ANCHOR)](){return this.baseEl??null}checkValidity(){return this.internals.checkValidity()}reportValidity(){return this.internals.reportValidity()}setCustomValidity(message){const old=this.customValidityMessage||null,next=message??"";if(this.customValidityMessage=next,this.validityController.setCustomValidity(this.isValidationBarred?"":next),!this.reflectingCustomError){this.reflectingCustomError=!0;try{next?this.setAttribute("custom-error",next):this.removeAttribute("custom-error")}finally{this.reflectingCustomError=!1}}this.requestUpdate("customError",old)}resetValidity(){this.customValidityMessage="",this.validityController.setCustomValidity(""),this.updateValidity()}formStateRestoreCallback(state2,reason){this.value=typeof state2=="string"?state2:""}runClickDefaultAction(){if(this.type==="submit"){const form=this.getForm();if(!form)return;this.hasSubmitterOverrides?this.submitAsNamedSubmitter(form):form.requestSubmit()}else this.type==="reset"&&this.getForm()?.reset()}get hasSubmitterOverrides(){return!!(this.name||this.value||this.formNoValidate)||this.formAction!==void 0||this.formEnctype!==void 0||this.formMethod!==void 0||this.formTarget!==void 0}submitAsNamedSubmitter(form){const submitter=this.ownerDocument.createElement("button");submitter.type="submit",submitter.hidden=!0,submitter.tabIndex=-1,this.name&&(submitter.name=this.name,submitter.value=this.value),this.formAction!==void 0&&submitter.setAttribute("formaction",this.formAction),this.formEnctype!==void 0&&submitter.setAttribute("formenctype",this.formEnctype),this.formMethod!==void 0&&submitter.setAttribute("formmethod",this.formMethod),this.formNoValidate&&(submitter.formNoValidate=!0),this.formTarget!==void 0&&submitter.setAttribute("formtarget",this.formTarget),this.parentElement&&this.closest("form")===form?this.insertAdjacentElement("afterend",submitter):form.append(submitter);try{form.requestSubmit(submitter)}finally{submitter.remove()}}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.updateValidity(),this.syncButtonStates(),this.requestUpdate()}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncDescribedByElements(),this.updateValidity(),this.syncButtonStates(),this.hasUpdated&&this.armIconOnlyResizeObserver()}disconnectedCallback(){this.releaseExternalDescription(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.iconOnlyResizeRaf!==void 0&&this.iconOnlyResizeRafOwner?.cancelAnimationFrame(this.iconOnlyResizeRaf),this.iconOnlyResizeRaf=void 0,this.iconOnlyResizeRafOwner=void 0,super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.isConnected&&this.hasUpdated&&this.syncDescribedByElements()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||this.seedFirstRenderState(()=>{this.syncAdornmentSlots(),this.isIconButton=this.hasIconOnlyDefaultContent()})}syncAdornmentSlots(){const collection=this.children,children=collection?Array.from(collection):[];this.hasStartSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="start"||slot==="prefix"}),this.hasEndSlot=children.some(element=>{const slot=element.getAttribute("slot");return slot==="end"||slot==="suffix"})}hasIconOnlyDefaultContent(){const childElements=this.children,elements=(childElements?Array.from(childElements):[]).filter(element=>!element.getAttribute("slot")).filter(element=>!isVisuallyHidden(element));if(elements.length!==1)return!1;const childNodes=this.childNodes;return(childNodes?Array.from(childNodes):[]).filter(node=>node.nodeType===3).map(node=>node.textContent??"").join("").trim()===""&&(elements[0]?.textContent??"").trim()===""}armIconOnlyResizeObserver(){const labelEl=this.labelEl;if(this.resizeObserver||!labelEl)return;const view=this.ownerDocument.defaultView,ResizeObserverCtor=view?.ResizeObserver;!view||!ResizeObserverCtor||(this.resizeObserver=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==view||(this.iconOnlyResizeRaf!==void 0&&this.iconOnlyResizeRafOwner?.cancelAnimationFrame(this.iconOnlyResizeRaf),this.iconOnlyResizeRafOwner=view,this.iconOnlyResizeRaf=view.requestAnimationFrame(()=>{if(this.iconOnlyResizeRaf=void 0,this.iconOnlyResizeRafOwner=void 0,!this.isConnected||this.ownerDocument.defaultView!==view)return;const next=this.hasIconOnlyDefaultContent();next!==this.isIconButton&&(this.isIconButton=next,this.syncButtonStates())}))}),this.resizeObserver.observe(labelEl))}get labelGrows(){return this.withCaret||this.hasEndSlot||this.withEnd}updated(changed){super.updated(changed),syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements(),this.armIconOnlyResizeObserver(),this.updateValidity(),this.syncButtonStates()}updateValidity(){if(this.validityController){if(this.isValidationBarred){this.validityController.setCustomValidity(""),this.validityController.setValidity({});return}this.required&&!this.value?this.validityController.setValidity({valueMissing:!0},this.localize("fieldRequired")):this.validityController.setValidity({}),this.validityController.setCustomValidity(this.customValidityMessage)}}get isValidationBarred(){return this.effectiveDisabled||this.loading||this.baseEl?.localName==="a"}syncButtonStates(){this.internals&&(setCustomState(this.internals,"disabled",this.effectiveDisabled||this.loading),setCustomState(this.internals,"icon-button",this.isIconButton),setCustomState(this.internals,"link",this.baseEl?.localName==="a"),setCustomState(this.internals,"loading",this.loading))}syncDescribedByElements(){const target=this.isConnected?this.baseEl:void 0;if(!target){this.releaseExternalDescription();return}this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}render(){const pressed=["true","false","mixed"].includes(this.triggerPressed??"")?this.triggerPressed:nothing,current=["page","step","location","date","time","true","false"].includes(this.triggerCurrent??"")?this.triggerCurrent:nothing,content=html`
2
2
  <span
3
3
  part="start prefix"
4
4
  ?hidden=${!(this.hasStartSlot||this.withStart)}
@@ -1,4 +1,4 @@
1
- import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraSize}from'../../../internal/variants.js';import{type FormOwnerValue}from'../../../internal/form-associated.js';import{type LyraFormValidator}from'../form-validator.js';export interface LyraCheckboxEventMap{input:Event;change:Event;'lr-input':CustomEvent<{checked:boolean;}>;'lr-change':CustomEvent<{checked:boolean;}>;focus:FocusEvent;blur:FocusEvent;'lr-invalid':CustomEvent<null>;'lr-checkbox-toggle-request':CustomEvent<{checked:boolean;}>;}
1
+ import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraSize}from'../../../internal/variants.js';import{type FormOwnerValue}from'../../../internal/form-associated.js';import{type LyraFormValidator}from'../form-validator.js';export interface LyraCheckboxEventMap{input:Event;change:Event;'lr-input':CustomEvent<{checked:boolean;value:string;}>;'lr-change':CustomEvent<{checked:boolean;value:string;}>;focus:FocusEvent;blur:FocusEvent;'lr-invalid':CustomEvent<null>;'lr-checkbox-toggle-request':CustomEvent<{checked:boolean;value:string;}>;}
2
2
  /**
3
3
  * `<lr-checkbox>` — a boolean form control. Structurally the same idea as
4
4
  * `<lr-switch>` (form-associated via `ElementInternals`, click and
@@ -41,16 +41,17 @@ import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from
41
41
  * `ariaDescribedByElements` so externally-owned descriptions remain valid across the shadow
42
42
  * boundary.
43
43
  * @event input - The user toggled the checkbox; bubbling and composed like a native form event.
44
- * @event lr-input - Prefixed compatibility alias for `input`; `detail: { checked }`.
44
+ * @event lr-input - Prefixed compatibility alias for `input`; `detail: { checked, value }`.
45
45
  * @event change - Fired immediately after `input` for the same user toggle.
46
46
  * @event lr-change - Compatibility alias fired after `input` and `change` (click or Space).
47
- * `detail: { checked }`. Not fired for a programmatic `.checked` assignment, nor for a user toggle
48
- * a listener refused through `lr-checkbox-toggle-request`.
47
+ * `detail: { checked, value }`. Not fired for a programmatic `.checked` assignment, nor for a user
48
+ * toggle a listener refused through `lr-checkbox-toggle-request`.
49
49
  * @event lr-checkbox-toggle-request - A user toggle (click or Space) is about to change `checked`;
50
- * `detail: { checked }` carries the state the control *would* take, and `checked` itself still
51
- * holds the old value while this dispatches. Cancelable: calling `preventDefault()` keeps the
52
- * current state, so the control never flips at all rather than flipping and snapping back, and
53
- * none of `input`/`lr-input`/`change`/`lr-change` fire. A listener may instead resolve the request
50
+ * `detail: { checked, value }` carries the state the control *would* take (`value` is the current
51
+ * `.value`, unaffected by the toggle), and `checked` itself still holds the old value while this
52
+ * dispatches. Cancelable: calling `preventDefault()` keeps the current state, so the control never
53
+ * flips at all rather than flipping and snapping back, and none of
54
+ * `input`/`lr-input`/`change`/`lr-change` fire. A listener may instead resolve the request
54
55
  * by assigning `checked` itself during the dispatch, which suppresses the built-in write the same
55
56
  * way. Not fired for a programmatic `.checked` assignment, nor while the control is disabled. An
56
57
  * `<lr-checkbox-group>` owner consumes this event and republishes it as its own
@@ -115,6 +116,8 @@ import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from
115
116
  * @cssprop [--lr-checkbox-active-ring=var(--lr-color-brand-quiet)] - Outer box ring while pressed.
116
117
  * @cssprop [--lr-checkbox-invalid-border=var(--lr-color-danger)] - Box border while invalid chrome
117
118
  * is visible.
119
+ * @cssprop [--lr-checkbox-box-radius=calc(var(--lr-form-control-radius) * 0.6)] - Corner radius of
120
+ * `[part='box']`. Retune it without a `::part(box)` rule.
118
121
  * @cssprop [--checked-icon-color=currentColor] - WA-compatible color of the checked or
119
122
  * indeterminate glyph.
120
123
  * @cssprop [--checked-icon-scale=1] - WA-compatible scale of the checked or indeterminate glyph.
@@ -26,7 +26,7 @@ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3
26
26
  aria-hidden="true"
27
27
  focusable="false"
28
28
  ><line x1="5" y1="12" x2="19" y2="12"></line></svg>
29
- `}class LyraCheckbox extends LyraElement{static{this.defaultStrings={...super.defaultStrings,checkboxRequired:LYRA_DEFAULT_checkboxRequired,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","checked")]}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.formAssociated=!0}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},checked:{attribute:!1,noAccessor:!0},defaultChecked:{attribute:"checked",type:Boolean,reflect:!0,useDefault:!0,noAccessor:!0},indeterminate:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},required:{type:Boolean,reflect:!0,noAccessor:!0},size:{reflect:!0},value:{reflect:!0,noAccessor:!0}}}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled||this._groupDisabled}get checked(){return this._checked}set checked(next){const old=this._checked;this.settingDefaultChecked||(this._checkedDirty=!0),this._checked=!!next,markVetoGuardWrite(this.toggleGuard),this.syncFormState(),this.notifyOwningGroup(),this.requestUpdate("checked",old)}get defaultChecked(){return this._defaultChecked}set defaultChecked(next){if(this.reflectingDefaultChecked)return;const old=this._defaultChecked;this._defaultChecked=!!next,this.reflectingDefaultChecked=!0;try{this.toggleAttribute("checked",this._defaultChecked)}finally{this.reflectingDefaultChecked=!1}this._checkedDirty||this.restoreCheckedFromDefault(),this.requestUpdate("defaultChecked",old)}get indeterminate(){return this._indeterminate}set indeterminate(next){const old=this._indeterminate;this._indeterminate=!!next,this.syncFormState(),this.notifyOwningGroup(),this.requestUpdate("indeterminate",old)}notifyOwningGroup(){this.closest?.("lr-checkbox-group")?.notifyCheckboxStateChange?.(this)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.updateValidity(),this.requestUpdate("disabled",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get value(){return this._value}set value(next){const old=this._value;this._value=next??"on",next==null?this.hasAttribute("value")&&this.removeAttribute("value"):this.getAttribute("value")!==this._value&&this.setAttribute("value",this._value),this.syncFormState(),this.notifyOwningGroup(),this.requestUpdate("value",old,{reflect:!1})}constructor(){super(),this.size="m",this.hint="",this.helpText="",this.errorText="",this.hasLabelSlot=!1,this.hasHintSlot=!1,this.hasHelpTextSlot=!1,this.hasErrorSlot=!1,this.touched=!1,this.hasInteracted=!1,this.hasSyncedDescribedByElements=!1,this._defaultChecked=!1,this._checkedDirty=!1,this.settingDefaultChecked=!1,this.reflectingDefaultChecked=!1,this._fieldsetDisabled=!1,this._groupDisabled=!1,this._name="",this._checked=!1,this._indeterminate=!1,this._disabled=!1,this._required=!1,this._value="on",this.toggleGuard=new VetoWriteGuard,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.reflectInvalid())},this.onClick=event=>{const owner=this[VALIDITY_ANCHOR]();for(const target of event.composedPath()){if(target===event.currentTarget)break;if(target&&typeof target=="object"&&target.nodeType===1&&target!==owner&&isActionableElement(target))return}this.toggle()},this.onKeyDown=e=>{this.effectiveDisabled||e.repeat||(e.key===" "||e.key==="Spacebar")&&(e.preventDefault(),this.toggle())},this.onSlotChange=event=>this.handleLabelSlotChange(event),this.onHintSlotChange=()=>{this.hasHintSlot=this.hasLightDomChildWithSlot("hint")},this.onHelpTextSlotChange=()=>{this.hasHelpTextSlot=this.hasLightDomChildWithSlot("help-text")},this.onErrorSlotChange=()=>{this.hasErrorSlot=this.hasLightDomChildWithSlot("error")},this.onLabelSlotChange=event=>this.handleLabelSlotChange(event),this.onBlur=event=>{!this.effectiveDisabled&&!this.matches(":disabled")&&(this.touched=!0,this.hasInteracted=!0,this.reflectInvalid()),relayNativeEvent(this,event)},this.onFocus=event=>{relayNativeEvent(this,event)},installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),installInteractionOnInvalid(this,this.markInteracted),this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),this.syncFormState()}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}[VALIDITY_ANCHOR](){return this.renderRoot?.querySelector(".checkbox-owner")??null}connectedCallback(){super.connectedCallback(),this.updateValidity();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;this.labelObserver=MutationObserverCtor?new MutationObserverCtor(()=>{this.bindLabelObserverTargets(),this.recomputeHasLabelSlot()}):void 0,this.addEventListener("slotchange",this.onLabelSlotChange),this.bindLabelObserverTargets(),this.hasUpdated?(this.recomputeHasLabelSlot(),this.refreshNamedSlotState()):this.seedFirstRenderState(()=>{this.recomputeHasLabelSlot(),this.refreshNamedSlotState()})}hasLightDomChildWithSlot(name){const children=this.children;return children?Array.from(children).some(element=>element.getAttribute("slot")===name):!1}refreshNamedSlotState(){this.hasHintSlot=this.hasLightDomChildWithSlot("hint"),this.hasHelpTextSlot=this.hasLightDomChildWithSlot("help-text"),this.hasErrorSlot=this.hasLightDomChildWithSlot("error")}disconnectedCallback(){this.removeEventListener("slotchange",this.onLabelSlotChange),this.labelObserver?.disconnect(),this.labelObserver=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed)}updated(changed){super.updated(changed);const describedBy=this.getAttribute("aria-describedby"),hint=this.renderRoot.querySelector("#checkbox-hint"),error=this.renderRoot.querySelector("#checkbox-error");if(!describedBy&&!this.hasSyncedDescribedByElements&&(!hint||hint.hidden)&&(!error||error.hidden))return;const control=this.renderRoot.querySelector('[part~="base"]')??void 0;if(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,control,describedBy),control&&"ariaDescribedByElements"in control){const reflected=control,current=reflected.ariaDescribedByElements??[],internal=[error,hint].filter(element=>!!(element&&!element.hidden));reflected.ariaDescribedByElements=[...current.filter(element=>element!==hint&&element!==error),...internal]}}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}updateValidity(){this.barredFromValidation?this.validityController.setValidity({}):this.required&&!this.checked?this.validityController.setValidity({valueMissing:!0},this.localize("checkboxRequired")):this.validityController.setValidity({}),this.reflectInvalid()}reflectInvalid(){const barred=this.barredFromValidation;this.toggleAttribute("data-invalid",!barred&&this.touched&&!this.internals.validity.valid),syncValidityStates(this.internals,{required:this.required,hasInteracted:this.hasInteracted,barred}),setCustomState(this.internals,"checked",this.checked),setCustomState(this.internals,"indeterminate",this.indeterminate),setCustomState(this.internals,"disabled",this.effectiveDisabled)}syncFormState(){const state2=`${this.checked?"checked":"unchecked"}${this.indeterminate?"/indeterminate":""}`;this.internals.setFormValue(this.checked?this.value:null,state2),this.updateValidity()}formResetCallback(){this.restoreCheckedFromDefault(),this.touched=!1,this.hasInteracted=!1,this.reflectInvalid()}formStateRestoreCallback(state2,reason){const oldChecked=this._checked,oldIndeterminate=this._indeterminate;this._checked=state2==="checked"||state2==="checked/indeterminate",this._checkedDirty=!0,this._indeterminate=state2==="checked/indeterminate"||state2==="unchecked/indeterminate",this.syncFormState(),this.requestUpdate("checked",oldChecked),this.requestUpdate("indeterminate",oldIndeterminate)}resetFromGroup(){this.restoreCheckedFromDefault()}restoreCheckedFromDefault(){this.settingDefaultChecked=!0;try{this.checked=this._defaultChecked}finally{this.settingDefaultChecked=!1}this._checkedDirty=!1}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.updateValidity(),this.requestUpdate()}setGroupDisabled(value){this._groupDisabled!==value&&(this._groupDisabled=value,this.updateValidity(),this.requestUpdate())}checkValidity(){return this.updateValidity(),withStaticValidityCheck(this,()=>this.internals.checkValidity())}reportValidity(){return this.updateValidity(),this.hasInteracted=!0,this.reflectInvalid(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.reflectInvalid(),this.requestUpdate()}resetValidity(){this.setCustomValidity("")}click(){this.effectiveDisabled||this[VALIDITY_ANCHOR]()?.click()}focus(options){this.effectiveDisabled||this[VALIDITY_ANCHOR]()?.focus(options)}blur(){this[VALIDITY_ANCHOR]()?.blur()}toggle(){if(this.effectiveDisabled)return;const proposed=!this.checked;requestThenCommit({requestDetail:{checked:proposed},emitRequest:(detail,init)=>this.emit("lr-checkbox-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{this.hasInteracted=!0,this.checked=proposed,this.indeterminate=!1,dispatchNativeEvent(this,"input"),this.emit("lr-input",{checked:this.checked}),dispatchNativeEvent(this,"change"),this.emit("lr-change",{checked:this.checked})}})}isDefaultLabelNode(node){if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName===null||slotName===""}labelForwardingSlots(){return Array.from(this.querySelectorAll("slot")).filter(slot=>{let top=slot;for(;top.parentNode&&top.parentNode!==this;)top=top.parentNode;return top.parentNode===this&&this.isDefaultLabelNode(top)})}observeLabelNode(node){if(this.labelObserver){if(node.nodeType===3){this.labelObserver.observe(node,{characterData:!0});return}node.nodeType===1&&this.labelObserver.observe(node,{attributes:!0,attributeFilter:["aria-hidden","aria-label","class","hidden","inert","slot","style"],childList:!0,characterData:!0,subtree:!0})}}bindLabelObserverTargets(){if(this.labelObserver){this.labelObserver.disconnect(),this.observeLabelNode(this);for(const slot of this.labelForwardingSlots())if(slot.assignedNodes().length!==0)for(const assigned of slot.assignedNodes({flatten:!0}))this.observeLabelNode(assigned)}}handleLabelSlotChange(event){const target=event.target;target?.nodeType!==1||target.localName!=="slot"||target.getRootNode()!==this.renderRoot&&!this.labelForwardingSlots().includes(target)||(this.bindLabelObserverTargets(),this.recomputeHasLabelSlot())}recomputeHasLabelSlot(){const renderRoot=this.renderRoot,childNodes=this.childNodes;if(!renderRoot||!childNodes)return;const slot=renderRoot.querySelector("slot:not([name])"),nodes=slot?slot.assignedNodes({flatten:!0}):Array.from(childNodes).filter(node=>this.isDefaultLabelNode(node)).flatMap(node=>{if(node.nodeType!==1||node.localName!=="slot")return[node];const forwardingSlot=node;return forwardingSlot.assignedNodes().length>0?forwardingSlot.assignedNodes({flatten:!0}):Array.from(forwardingSlot.childNodes)});this.hasLabelSlot=hasRealContent(nodes)}render(){const mixed=this.indeterminate,hasHint=this.hasHintSlot||this.hasHelpTextSlot||!!(this.hint||this.helpText),hasError=this.hasErrorSlot||(this.errorText??"").length>0,controlParts=["box","control",this.checked?"checked control--checked":"",mixed?"indeterminate control--indeterminate":""].filter(Boolean).join(" "),describedBy=[this.getAttribute("aria-describedby")??"",hasError?"checkbox-error":"",hasHint?"checkbox-hint":""].filter(Boolean).join(" "),invalid=hasError||this.touched&&!this.internals.validity.valid;return html`
29
+ `}class LyraCheckbox extends LyraElement{static{this.defaultStrings={...super.defaultStrings,checkboxRequired:LYRA_DEFAULT_checkboxRequired,fieldRequired:LYRA_DEFAULT_fieldRequired}}static get validators(){return[currentValidityValidator("required","disabled","checked")]}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.formAssociated=!0}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},checked:{attribute:!1,noAccessor:!0},defaultChecked:{attribute:"checked",type:Boolean,reflect:!0,useDefault:!0,noAccessor:!0},indeterminate:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},required:{type:Boolean,reflect:!0,noAccessor:!0},size:{reflect:!0},value:{reflect:!0,noAccessor:!0}}}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled||this._groupDisabled}get checked(){return this._checked}set checked(next){const old=this._checked;this.settingDefaultChecked||(this._checkedDirty=!0),this._checked=!!next,markVetoGuardWrite(this.toggleGuard),this.syncFormState(),this.notifyOwningGroup(),this.requestUpdate("checked",old)}get defaultChecked(){return this._defaultChecked}set defaultChecked(next){if(this.reflectingDefaultChecked)return;const old=this._defaultChecked;this._defaultChecked=!!next,this.reflectingDefaultChecked=!0;try{this.toggleAttribute("checked",this._defaultChecked)}finally{this.reflectingDefaultChecked=!1}this._checkedDirty||this.restoreCheckedFromDefault(),this.requestUpdate("defaultChecked",old)}get indeterminate(){return this._indeterminate}set indeterminate(next){const old=this._indeterminate;this._indeterminate=!!next,this.syncFormState(),this.notifyOwningGroup(),this.requestUpdate("indeterminate",old)}notifyOwningGroup(){this.closest?.("lr-checkbox-group")?.notifyCheckboxStateChange?.(this)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.updateValidity(),this.requestUpdate("disabled",old)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get value(){return this._value}set value(next){const old=this._value;this._value=next??"on",next==null?this.hasAttribute("value")&&this.removeAttribute("value"):this.getAttribute("value")!==this._value&&this.setAttribute("value",this._value),this.syncFormState(),this.notifyOwningGroup(),this.requestUpdate("value",old,{reflect:!1})}constructor(){super(),this.size="m",this.hint="",this.helpText="",this.errorText="",this.hasLabelSlot=!1,this.hasHintSlot=!1,this.hasHelpTextSlot=!1,this.hasErrorSlot=!1,this.touched=!1,this.hasInteracted=!1,this.hasSyncedDescribedByElements=!1,this._defaultChecked=!1,this._checkedDirty=!1,this.settingDefaultChecked=!1,this.reflectingDefaultChecked=!1,this._fieldsetDisabled=!1,this._groupDisabled=!1,this._name="",this._checked=!1,this._indeterminate=!1,this._disabled=!1,this._required=!1,this._value="on",this.toggleGuard=new VetoWriteGuard,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.reflectInvalid())},this.onClick=event=>{const owner=this[VALIDITY_ANCHOR]();for(const target of event.composedPath()){if(target===event.currentTarget)break;if(target&&typeof target=="object"&&target.nodeType===1&&target!==owner&&isActionableElement(target))return}this.toggle()},this.onKeyDown=e=>{this.effectiveDisabled||e.repeat||(e.key===" "||e.key==="Spacebar")&&(e.preventDefault(),this.toggle())},this.onSlotChange=event=>this.handleLabelSlotChange(event),this.onHintSlotChange=()=>{this.hasHintSlot=this.hasLightDomChildWithSlot("hint")},this.onHelpTextSlotChange=()=>{this.hasHelpTextSlot=this.hasLightDomChildWithSlot("help-text")},this.onErrorSlotChange=()=>{this.hasErrorSlot=this.hasLightDomChildWithSlot("error")},this.onLabelSlotChange=event=>this.handleLabelSlotChange(event),this.onBlur=event=>{!this.effectiveDisabled&&!this.matches(":disabled")&&(this.touched=!0,this.hasInteracted=!0,this.reflectInvalid()),relayNativeEvent(this,event)},this.onFocus=event=>{relayNativeEvent(this,event)},installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),installInteractionOnInvalid(this,this.markInteracted),this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),this.syncFormState()}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}[VALIDITY_ANCHOR](){return this.renderRoot?.querySelector(".checkbox-owner")??null}connectedCallback(){super.connectedCallback(),this.updateValidity();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;this.labelObserver=MutationObserverCtor?new MutationObserverCtor(()=>{this.bindLabelObserverTargets(),this.recomputeHasLabelSlot()}):void 0,this.addEventListener("slotchange",this.onLabelSlotChange),this.bindLabelObserverTargets(),this.hasUpdated?(this.recomputeHasLabelSlot(),this.refreshNamedSlotState()):this.seedFirstRenderState(()=>{this.recomputeHasLabelSlot(),this.refreshNamedSlotState()})}hasLightDomChildWithSlot(name){const children=this.children;return children?Array.from(children).some(element=>element.getAttribute("slot")===name):!1}refreshNamedSlotState(){this.hasHintSlot=this.hasLightDomChildWithSlot("hint"),this.hasHelpTextSlot=this.hasLightDomChildWithSlot("help-text"),this.hasErrorSlot=this.hasLightDomChildWithSlot("error")}disconnectedCallback(){this.removeEventListener("slotchange",this.onLabelSlotChange),this.labelObserver?.disconnect(),this.labelObserver=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed)}updated(changed){super.updated(changed);const describedBy=this.getAttribute("aria-describedby"),hint=this.renderRoot.querySelector("#checkbox-hint"),error=this.renderRoot.querySelector("#checkbox-error");if(!describedBy&&!this.hasSyncedDescribedByElements&&(!hint||hint.hidden)&&(!error||error.hidden))return;const control=this.renderRoot.querySelector('[part~="base"]')??void 0;if(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,control,describedBy),control&&"ariaDescribedByElements"in control){const reflected=control,current=reflected.ariaDescribedByElements??[],internal=[error,hint].filter(element=>!!(element&&!element.hidden));reflected.ariaDescribedByElements=[...current.filter(element=>element!==hint&&element!==error),...internal]}}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}updateValidity(){this.barredFromValidation?this.validityController.setValidity({}):this.required&&!this.checked?this.validityController.setValidity({valueMissing:!0},this.localize("checkboxRequired")):this.validityController.setValidity({}),this.reflectInvalid()}reflectInvalid(){const barred=this.barredFromValidation;this.toggleAttribute("data-invalid",!barred&&this.touched&&!this.internals.validity.valid),syncValidityStates(this.internals,{required:this.required,hasInteracted:this.hasInteracted,barred}),setCustomState(this.internals,"checked",this.checked),setCustomState(this.internals,"indeterminate",this.indeterminate),setCustomState(this.internals,"disabled",this.effectiveDisabled)}syncFormState(){const state2=`${this.checked?"checked":"unchecked"}${this.indeterminate?"/indeterminate":""}`;this.internals.setFormValue(this.checked?this.value:null,state2),this.updateValidity()}formResetCallback(){this.restoreCheckedFromDefault(),this.touched=!1,this.hasInteracted=!1,this.reflectInvalid()}formStateRestoreCallback(state2,reason){const oldChecked=this._checked,oldIndeterminate=this._indeterminate;this._checked=state2==="checked"||state2==="checked/indeterminate",this._checkedDirty=!0,this._indeterminate=state2==="checked/indeterminate"||state2==="unchecked/indeterminate",this.syncFormState(),this.requestUpdate("checked",oldChecked),this.requestUpdate("indeterminate",oldIndeterminate)}resetFromGroup(){this.restoreCheckedFromDefault()}restoreCheckedFromDefault(){this.settingDefaultChecked=!0;try{this.checked=this._defaultChecked}finally{this.settingDefaultChecked=!1}this._checkedDirty=!1}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.updateValidity(),this.requestUpdate()}setGroupDisabled(value){this._groupDisabled!==value&&(this._groupDisabled=value,this.updateValidity(),this.requestUpdate())}checkValidity(){return this.updateValidity(),withStaticValidityCheck(this,()=>this.internals.checkValidity())}reportValidity(){return this.updateValidity(),this.hasInteracted=!0,this.reflectInvalid(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.reflectInvalid(),this.requestUpdate()}resetValidity(){this.setCustomValidity("")}click(){this.effectiveDisabled||this[VALIDITY_ANCHOR]()?.click()}focus(options){this.effectiveDisabled||this[VALIDITY_ANCHOR]()?.focus(options)}blur(){this[VALIDITY_ANCHOR]()?.blur()}toggle(){if(this.effectiveDisabled)return;const proposed=!this.checked;requestThenCommit({requestDetail:{checked:proposed,value:this.value},emitRequest:(detail,init)=>this.emit("lr-checkbox-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{this.hasInteracted=!0,this.checked=proposed,this.indeterminate=!1,dispatchNativeEvent(this,"input"),this.emit("lr-input",{checked:this.checked,value:this.value}),dispatchNativeEvent(this,"change"),this.emit("lr-change",{checked:this.checked,value:this.value})}})}isDefaultLabelNode(node){if(node.nodeType!==1)return!0;const slotName=node.getAttribute("slot");return slotName===null||slotName===""}labelForwardingSlots(){return Array.from(this.querySelectorAll("slot")).filter(slot=>{let top=slot;for(;top.parentNode&&top.parentNode!==this;)top=top.parentNode;return top.parentNode===this&&this.isDefaultLabelNode(top)})}observeLabelNode(node){if(this.labelObserver){if(node.nodeType===3){this.labelObserver.observe(node,{characterData:!0});return}node.nodeType===1&&this.labelObserver.observe(node,{attributes:!0,attributeFilter:["aria-hidden","aria-label","class","hidden","inert","slot","style"],childList:!0,characterData:!0,subtree:!0})}}bindLabelObserverTargets(){if(this.labelObserver){this.labelObserver.disconnect(),this.observeLabelNode(this);for(const slot of this.labelForwardingSlots())if(slot.assignedNodes().length!==0)for(const assigned of slot.assignedNodes({flatten:!0}))this.observeLabelNode(assigned)}}handleLabelSlotChange(event){const target=event.target;target?.nodeType!==1||target.localName!=="slot"||target.getRootNode()!==this.renderRoot&&!this.labelForwardingSlots().includes(target)||(this.bindLabelObserverTargets(),this.recomputeHasLabelSlot())}recomputeHasLabelSlot(){const renderRoot=this.renderRoot,childNodes=this.childNodes;if(!renderRoot||!childNodes)return;const slot=renderRoot.querySelector("slot:not([name])"),nodes=slot?slot.assignedNodes({flatten:!0}):Array.from(childNodes).filter(node=>this.isDefaultLabelNode(node)).flatMap(node=>{if(node.nodeType!==1||node.localName!=="slot")return[node];const forwardingSlot=node;return forwardingSlot.assignedNodes().length>0?forwardingSlot.assignedNodes({flatten:!0}):Array.from(forwardingSlot.childNodes)});this.hasLabelSlot=hasRealContent(nodes)}render(){const mixed=this.indeterminate,hasHint=this.hasHintSlot||this.hasHelpTextSlot||!!(this.hint||this.helpText),hasError=this.hasErrorSlot||(this.errorText??"").length>0,controlParts=["box","control",this.checked?"checked control--checked":"",mixed?"indeterminate control--indeterminate":""].filter(Boolean).join(" "),describedBy=[this.getAttribute("aria-describedby")??"",hasError?"checkbox-error":"",hasHint?"checkbox-hint":""].filter(Boolean).join(" "),invalid=hasError||this.touched&&!this.internals.validity.valid;return html`
30
30
  <div part="form-control">
31
31
  <span class="checkbox-layout" part="row" @click=${this.onClick}>
32
32
  <span
@@ -1 +1 @@
1
- import{css}from"lit";const styles=css`:host{--_lr-checkbox-box-size:min(var(--lr-icon-button-size), calc(var(--lr-form-control-height) * .7));--_lr-checkbox-label-indent:calc(var(--lr-checkbox-box-size,var(--_lr-checkbox-box-size)) + var(--lr-space-s));display:inline-block}.checkbox-layout{cursor:pointer;-webkit-tap-highlight-color:transparent;align-items:center;gap:0;display:inline-flex}.checkbox-owner{min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);justify-content:flex-start;align-items:center;display:inline-flex}.checkbox-owner:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}:host(:disabled) .checkbox-layout{cursor:not-allowed;opacity:var(--lr-opacity-disabled)}[part~=box]{box-sizing:border-box;min-inline-size:var(--lr-checkbox-box-size,var(--_lr-checkbox-box-size));min-block-size:var(--lr-checkbox-box-size,var(--_lr-checkbox-box-size));font-size:var(--lr-form-control-font-size);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:calc(var(--lr-form-control-radius) * .6);background:var(--lr-color-surface);color:var(--lr-color-on-brand);transition:background-color var(--lr-transition-fast), border-color var(--lr-transition-fast);flex:none;justify-content:center;align-items:center;display:inline-flex}:host(:not(:disabled)) .checkbox-layout:hover [part~=box]{border-color:var(--lr-checkbox-hover-border,var(--lr-color-brand))}:host(:not(:disabled)) .checkbox-layout:active [part~=box]{border-color:var(--lr-checkbox-active-border,var(--lr-color-brand));box-shadow:0 0 0 var(--lr-border-width-medium) var(--lr-checkbox-active-ring,var(--lr-color-brand-quiet))}[part~=checked],[part~=indeterminate]{background:var(--lr-checkbox-checked-bg,var(--lr-color-brand));border-color:var(--lr-checkbox-checked-border,var(--lr-color-brand))}:host([data-invalid]) [part~=box]{border-color:var(--lr-checkbox-invalid-border,var(--lr-color-danger))}[part~=checkmark]{color:var(--checked-icon-color,currentColor);transform:scale(var(--checked-icon-scale,1));display:block}[part=label]{font-size:var(--lr-font-size-md-sm);color:var(--lr-color-text);margin-inline-start:calc(var(--lr-checkbox-label-indent,var(--_lr-checkbox-label-indent)) - max(var(--lr-icon-button-size), var(--lr-checkbox-box-size,var(--_lr-checkbox-box-size))))}[part~=hint]{color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-sm);margin-block-start:var(--lr-space-xs);margin-inline-start:var(--lr-checkbox-label-indent,var(--_lr-checkbox-label-indent))}[part~=hint][hidden]{display:none}[part=error]{color:var(--lr-color-danger);font-size:var(--lr-font-size-sm);margin-block-start:var(--lr-space-xs);margin-inline-start:var(--lr-checkbox-label-indent,var(--_lr-checkbox-label-indent))}[part=error][hidden]{display:none}[part=form-control],[part=label],[part~=hint],[part=error]{overflow-wrap:anywhere;min-inline-size:0;max-inline-size:100%}@media (prefers-reduced-motion:reduce){[part~=box]{transition:none!important}}`;export{styles};
1
+ import{css}from"lit";const styles=css`:host{--_lr-checkbox-box-size:min(var(--lr-icon-button-size), calc(var(--lr-form-control-height) * .7));--_lr-checkbox-label-indent:calc(var(--lr-checkbox-box-size,var(--_lr-checkbox-box-size)) + var(--lr-space-s));display:inline-block}.checkbox-layout{cursor:pointer;-webkit-tap-highlight-color:transparent;align-items:center;gap:0;display:inline-flex}.checkbox-owner{min-inline-size:var(--lr-icon-button-size);min-block-size:var(--lr-icon-button-size);justify-content:flex-start;align-items:center;display:inline-flex}.checkbox-owner:focus-visible{outline:var(--lr-focus-ring-width) solid var(--lr-focus-ring-color);outline-offset:var(--lr-focus-ring-offset)}:host(:disabled) .checkbox-layout{cursor:not-allowed;opacity:var(--lr-opacity-disabled)}[part~=box]{box-sizing:border-box;min-inline-size:var(--lr-checkbox-box-size,var(--_lr-checkbox-box-size));min-block-size:var(--lr-checkbox-box-size,var(--_lr-checkbox-box-size));font-size:var(--lr-form-control-font-size);border:var(--lr-border-width-thin) solid var(--lr-color-border);border-radius:var(--lr-checkbox-box-radius,calc(var(--lr-form-control-radius) * .6));background:var(--lr-color-surface);color:var(--lr-color-on-brand);transition:background-color var(--lr-transition-fast), border-color var(--lr-transition-fast);flex:none;justify-content:center;align-items:center;display:inline-flex}:host(:not(:disabled)) .checkbox-layout:hover [part~=box]{border-color:var(--lr-checkbox-hover-border,var(--lr-color-brand))}:host(:not(:disabled)) .checkbox-layout:active [part~=box]{border-color:var(--lr-checkbox-active-border,var(--lr-color-brand));box-shadow:0 0 0 var(--lr-border-width-medium) var(--lr-checkbox-active-ring,var(--lr-color-brand-quiet))}[part~=checked],[part~=indeterminate]{background:var(--lr-checkbox-checked-bg,var(--lr-color-brand));border-color:var(--lr-checkbox-checked-border,var(--lr-color-brand))}:host([data-invalid]) [part~=box]{border-color:var(--lr-checkbox-invalid-border,var(--lr-color-danger))}[part~=checkmark]{color:var(--checked-icon-color,currentColor);transform:scale(var(--checked-icon-scale,1));display:block}[part=label]{font-size:var(--lr-font-size-md-sm);color:var(--lr-color-text);margin-inline-start:calc(var(--lr-checkbox-label-indent,var(--_lr-checkbox-label-indent)) - max(var(--lr-icon-button-size), var(--lr-checkbox-box-size,var(--_lr-checkbox-box-size))))}[part~=hint]{color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-sm);margin-block-start:var(--lr-space-xs);margin-inline-start:var(--lr-checkbox-label-indent,var(--_lr-checkbox-label-indent))}[part~=hint][hidden]{display:none}[part=error]{color:var(--lr-color-danger);font-size:var(--lr-font-size-sm);margin-block-start:var(--lr-space-xs);margin-inline-start:var(--lr-checkbox-label-indent,var(--_lr-checkbox-label-indent))}[part=error][hidden]{display:none}[part=form-control],[part=label],[part~=hint],[part=error]{overflow-wrap:anywhere;min-inline-size:0;max-inline-size:100%}@media (prefers-reduced-motion:reduce){[part~=box]{transition:none!important}}`;export{styles};
@@ -126,7 +126,7 @@ get name():string;set name(next:string);
126
126
  * render, pointing at framework internals rather than the offending line. */
127
127
  get value():readonly string[];set value(next:readonly string[]|null|undefined);get required():boolean;set required(next:boolean);get disabled():boolean;set disabled(next:boolean);constructor();private markInteracted;private checkboxGroupOwner;private ownsCheckbox;private get boxes();
128
128
  /** Whether the group is disabled explicitly or by an ancestor fieldset. */
129
- get effectiveDisabled():boolean;private propagateDisabled;private propagateSize;private readValue;private warnOnDuplicateValues;private sync;
129
+ get effectiveDisabled():boolean;private propagateDisabled;private propagateSize;private readValue;private warnOnDuplicateValues;private sync;private suppressCheckboxSync;
130
130
  /** Shared with every other form control: disabled (own or fieldset-cascaded) bars validation. */
131
131
  private get barredFromValidation();
132
132
  /** Republishes the six validity custom states (`required`/`optional`, `valid`/`invalid`,
@@ -135,7 +135,7 @@ private get barredFromValidation();
135
135
  * validity or the interaction flag. */
136
136
  private reflectValidityStates;private isOwnedCheckbox;private onChildEvent;
137
137
  /** The group value that would result if `option` took `proposed`, in DOM order. */
138
- private projectedValue;private onChildToggleRequest;private reconcileChildControllers;private onChildMutations;private hasDirectSupportSlot;private onSlotChange;
138
+ private projectedValue;private onChildToggleRequest;private reconcileChildControllers;private onChildMutations;private hasDirectSupportSlot;private syncSupportSlotFlags;private onSlotChange;
139
139
  /** Checks exactly the children named by `values`, matching duplicates one-for-one, then re-syncs
140
140
  * the owned value/validity. Shared by the `value` setter and by form restore. */
141
141
  private applyValues;
@@ -1,4 +1,4 @@
1
- var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";installFormControlLabelSupport();import{AnchoredValidityController,resolveValidityAnchor,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{acquireAriaDescription,acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./checkbox-group.styles.js";import{attachInternalsSafely,createStringArrayFormDataState,getFormOwner,installCustomErrorProperty,isBarredFromValidation,readStringArrayFormDataState,setFormOwner}from"../../../internal/form-associated.js";import{installInteractionOnInvalid,installInvalidEventAlias,withStaticValidityCheck}from"../../../internal/invalid-event-alias.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{LYRA_DEFAULT_checkboxGroupRequired,LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";const DUPLICATE_VALUE_WARNING_KEY="lyra-checkbox-group-duplicate-child-values",DUPLICATE_VALUE_WARNING="<lr-checkbox-group>: duplicate child values make submitted FormData ambiguous; give each child a distinct value.";class LyraCheckboxGroup extends LyraElement{static{this.defaultStrings={...super.defaultStrings,checkboxGroupRequired:LYRA_DEFAULT_checkboxGroupRequired,fieldRequired:LYRA_DEFAULT_fieldRequired}}static{this.immutableEventDetails=Object.freeze(["lr-checkbox-group-toggle-request"])}static{this.identityEventDetailProperties=Object.freeze({"lr-checkbox-group-toggle-request":Object.freeze(["option"])})}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,srOnly,styles]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},size:{reflect:!0},orientation:{reflect:!0},value:{attribute:!1,noAccessor:!0}}}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.sync(),this.requestUpdate("name",old)}get value(){return Object.freeze([...this._value])}set value(next){markVetoGuardWrite(this.toggleGuard);const requested=Array.isArray(next)?next.filter(entry=>typeof entry=="string"):[];if(this.boxes.length===0){this.pendingValues=requested;return}this.pendingValues=void 0,this.applyValues(requested)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.sync(),this.requestUpdate("required",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.propagateDisabled(),this.sync(),this.requestUpdate("disabled",old)}constructor(){super(),this.orientation="vertical",this.label="",this.hint="",this.withLabel=!1,this.withHint=!1,this.errorText="",this.accessibleLabel="",this.touched=!1,this.hasInteracted=!1,this.hasLabelSlot=!1,this.hasHintSlot=!1,this.hasErrorSlot=!1,this.labelId=nextId("checkbox-group-label"),this.hintId=nextId("checkbox-group-hint"),this.errorId=nextId("checkbox-group-error"),this.requiredDescriptionId=nextId("checkbox-group-required"),this._fieldsetDisabled=!1,this._name="",this._required=!1,this._disabled=!1,this._value=[],this.childObserverGeneration=0,this.childControllers=new Map,this.toggleGuard=new VetoWriteGuard,this.authoredChildSizes=new Map,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.reflectValidityStates())},this.onChildEvent=event=>{if(!this.isOwnedCheckbox(event.target)||(event.stopImmediatePropagation(),event.type!=="change"||this.effectiveDisabled))return;this.hasInteracted=!0,this.sync();const detail=()=>Object.freeze({value:this.value});this.emit("input",detail()),this.emit("change",detail()),this.emit("lr-change",detail())},this.onChildToggleRequest=event=>{if(!this.isOwnedCheckbox(event.target)||(event.stopImmediatePropagation(),this.effectiveDisabled))return;const option=event.target,proposed=event.detail.checked;let allowed=!1;requestThenCommit({requestDetail:{value:this.projectedValue(option,proposed),previousValue:this.value,option},emitRequest:(detail,init)=>this.emit("lr-checkbox-group-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{allowed=!0}}),allowed||event.preventDefault()},this.onChildMutations=records=>{if(records.some(record=>record.type==="childList"||record.attributeName==="slot")){this.onSlotChange();return}for(const record of records){if(record.attributeName!=="size"||!this.isOwnedCheckbox(record.target))continue;const box=record.target;this.size!==void 0&&box.size!==this.size&&this.authoredChildSizes.set(box,box.size)}records.some(record=>record.attributeName==="size"&&this.isOwnedCheckbox(record.target))&&this.propagateSize(),records.some(record=>this.isOwnedCheckbox(record.target))&&this.sync()},this.onSlotChange=()=>{this.hasLabelSlot=this.hasDirectSupportSlot("label"),this.hasHintSlot=this.hasDirectSupportSlot("hint"),this.hasErrorSlot=this.hasDirectSupportSlot("error"),this.reconcileChildControllers(),!this.applyPendingRestore()&&!this.applyPendingValues()&&this.sync(),this.propagateDisabled(),this.propagateSize()},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),installInteractionOnInvalid(this,this.markInteracted)}checkboxGroupOwner(element){const group=element.closest("lr-checkbox-group");if(!group)return null;let topLevelChild=element;for(;topLevelChild.parentElement&&topLevelChild.parentElement!==group;)topLevelChild=topLevelChild.parentElement;if(topLevelChild.parentElement!==group)return null;const slot=topLevelChild.getAttribute("slot");return slot==="label"||slot==="hint"||slot==="error"?null:group}ownsCheckbox(element){return element.localName==="lr-checkbox"&&this.checkboxGroupOwner(element)===this}get boxes(){const querySelectorAll=this.querySelectorAll;return typeof querySelectorAll!="function"?[]:Array.from(querySelectorAll.call(this,"lr-checkbox")).filter(box=>this.ownsCheckbox(box))}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}propagateDisabled(){const effective=this.effectiveDisabled;this.boxes.forEach(box=>box.setGroupDisabled?.(effective))}propagateSize(){for(const box of this.boxes)if(this.authoredChildSizes.has(box)||this.authoredChildSizes.set(box,box.size),this.size===void 0||this.size===null){const authored=this.authoredChildSizes.get(box);authored!==void 0&&box.size!==authored&&(box.size=authored),this.authoredChildSizes.delete(box)}else box.size!==this.size&&(box.size=this.size)}readValue(){return this.boxes.filter(box=>box.checked).map(box=>box.value??"on")}warnOnDuplicateValues(){const seen=new Set;for(const box of this.boxes){const value=box.value??box.getAttribute("value")??"on";if(!seen.has(value)){seen.add(value);continue}devWarnOnce(DUPLICATE_VALUE_WARNING_KEY,DUPLICATE_VALUE_WARNING);return}}sync(){const next=this.readValue();this.warnOnDuplicateValues();const old=this._value;this._value=next,this.requestUpdate("value",old);const data=new FormData;this.name&&next.forEach(value=>data.append(this.name,value)),this.internals.setFormValue(this.name?data:null,createStringArrayFormDataState(this.name,next)),!this.barredFromValidation&&this.required&&next.length===0?this.validityController.setValidity({valueMissing:!0},this.localize("checkboxGroupRequired")):this.validityController.setValidity({}),this.reflectValidityStates()}notifyCheckboxStateChange(checkbox){this.isConnected&&this.ownsCheckbox(checkbox)&&this.sync()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}reflectValidityStates(){const barred=this.barredFromValidation;this.toggleAttribute("data-invalid",!barred&&this.touched&&!this.internals.validity.valid),syncValidityStates(this.internals,{required:this.required,hasInteracted:this.hasInteracted,barred})}isOwnedCheckbox(target){return target?.nodeType===1&&this.ownsCheckbox(target)}projectedValue(option,proposed){return Object.freeze(this.boxes.filter(box=>box===option?proposed:box.checked).map(box=>box.value??"on"))}reconcileChildControllers(){const current=new Set(this.boxes);for(const[box,controller]of this.childControllers){if(current.has(box))continue;box.removeController(controller),this.childControllers.delete(box);const authoredSize=this.authoredChildSizes.get(box);authoredSize!==void 0&&box.size!==authoredSize&&(box.size=authoredSize),this.authoredChildSizes.delete(box);const nextOwner=this.checkboxGroupOwner(box);(!nextOwner||nextOwner===this)&&box.setGroupDisabled?.(!1)}for(const box of current){if(this.childControllers.has(box)||typeof box.addController!="function")continue;const controller={hostUpdated:()=>{this.isConnected&&this.ownsCheckbox(box)&&this.sync()}};box.addController(controller),this.childControllers.set(box,controller)}}hasDirectSupportSlot(name){return Array.from(this.children??[]).some(child=>child.getAttribute("slot")===name)}applyValues(values){const remaining=[...values];for(const box of this.boxes){const value=box.value??"on",index=remaining.indexOf(value);box.checked=index>=0,index>=0&&remaining.splice(index,1)}this.sync()}applyPendingRestore(){if(this.pendingRestoreValues===void 0||this.boxes.length===0)return!1;const values=this.pendingRestoreValues;return this.pendingRestoreValues=void 0,this.touched=!1,this.hasInteracted=!1,this.applyValues(values),!0}applyPendingValues(){if(this.pendingValues===void 0||this.boxes.length===0)return!1;const values=this.pendingValues;return this.pendingValues=void 0,this.applyValues(values),!0}connectedCallback(){super.connectedCallback(),this.addEventListener("input",this.onChildEvent,{capture:!0}),this.addEventListener("change",this.onChildEvent,{capture:!0}),this.addEventListener("lr-change",this.onChildEvent,{capture:!0}),this.addEventListener("lr-checkbox-toggle-request",this.onChildToggleRequest,{capture:!0}),this.onSlotChange(),this.armChildObserver(),this.hasUpdated&&(this.syncRequiredDescription(),this.syncExternalDescription())}armChildObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.childObserver&&this.childObserverDocument===ownerDocument)return;this.resetChildObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.childObserverGeneration,observer=new MutationObserverCtor(records=>{this.childObserver!==observer||this.childObserverDocument!==ownerDocument||this.childObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onChildMutations(records)});this.childObserver=observer,this.childObserverDocument=ownerDocument,observer.observe(this,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["checked","value","disabled","size","slot"]})}disconnectedCallback(){this.releaseExternalDescription(),this.releaseRequiredDescription(),this.removeEventListener("input",this.onChildEvent,{capture:!0}),this.removeEventListener("change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-checkbox-toggle-request",this.onChildToggleRequest,{capture:!0}),this.resetChildObserver();for(const[box,controller]of this.childControllers){box.removeController(controller),box.setGroupDisabled?.(!1);const authoredSize=this.authoredChildSizes.get(box);authoredSize!==void 0&&box.size!==authoredSize&&(box.size=authoredSize)}this.childControllers.clear(),this.authoredChildSizes.clear(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.releaseRequiredDescription(),this.resetChildObserver(),this.isConnected&&this.hasUpdated&&(this.syncRequiredDescription(),this.syncExternalDescription())}resetChildObserver(){this.childObserverGeneration+=1,this.childObserver?.disconnect(),this.childObserver=void 0,this.childObserverDocument=void 0}firstUpdated(changed){super.firstUpdated(changed),this.addEventListener("blur",event=>{const blurredControl=event.target;(typeof blurredControl?.matches=="function"?blurredControl.matches(":disabled"):this.effectiveDisabled)||(this.touched=!0,this.hasInteracted=!0),this.sync()},!0)}updated(changed){super.updated(changed),changed.has("size")&&this.propagateSize(),this.syncRequiredDescription(),this.syncExternalDescription()}syncExternalDescription(){const target=this.renderRoot.querySelector("fieldset");if(!target){this.releaseExternalDescription();return}if(!this.externalDescriptionLease){this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby");return}this.externalDescriptionLease.update(target)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}syncRequiredDescription(){const target=this.renderRoot.querySelector("fieldset"),description=this.renderRoot.querySelector(`#${this.requiredDescriptionId}`);if(!this.required||!target||!description){this.releaseRequiredDescription();return}if(this.requiredDescriptionTarget!==target){this.releaseRequiredDescription(),this.requiredDescriptionTarget=target,this.requiredDescriptionLease=acquireAriaDescription(target,[description]);return}this.requiredDescriptionLease?.update([description])}releaseRequiredDescription(){this.requiredDescriptionLease?.release(),this.requiredDescriptionLease=void 0,this.requiredDescriptionTarget=void 0}[VALIDITY_ANCHOR](){const first=this.firstEnabledBox();return resolveValidityAnchor(first)??first??null}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return withStaticValidityCheck(this,()=>this.internals.checkValidity())}reportValidity(){return this.hasInteracted=!0,this.reflectValidityStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.reflectValidityStates(),this.requestUpdate()}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}firstEnabledBox(){return this.boxes.find(box=>!box.effectiveDisabled&&!box.matches(":disabled"))}focus(options){this.liveDisabled||this.firstEnabledBox()?.focus(options)}blur(){this.boxes.find(box=>box.matches(":focus-within"))?.blur()}click(){this.liveDisabled||this.firstEnabledBox()?.click()}formResetCallback(){this.boxes.forEach(box=>box.resetFromGroup()),this.touched=!1,this.hasInteracted=!1,this.sync()}formStateRestoreCallback(state2,_mode){this.pendingRestoreValues=readStringArrayFormDataState(state2),this.applyPendingRestore()}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.propagateDisabled(),this.sync(),this.requestUpdate()}render(){const hasLabel=this.hasLabelSlot||!!this.label||this.withLabel,hasHint=this.hasHintSlot||!!this.hint||this.withHint,hasError=this.hasErrorSlot||!!this.errorText,described=[hasHint?this.hintId:"",hasError?this.errorId:""].filter(Boolean).join(" ")||nothing,invalid=hasError||this.touched&&!this.internals.validity.valid;return html`<fieldset
1
+ var __decorate=function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r};import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";installFormControlLabelSupport();import{AnchoredValidityController,resolveValidityAnchor,VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{acquireAriaDescription,acquireResolvedAriaRelationship}from"../../../internal/aria-controls.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./checkbox-group.styles.js";import{attachInternalsSafely,createStringArrayFormDataState,getFormOwner,installCustomErrorProperty,isBarredFromValidation,readStringArrayFormDataState,setFormOwner}from"../../../internal/form-associated.js";import{installInteractionOnInvalid,installInvalidEventAlias,withStaticValidityCheck}from"../../../internal/invalid-event-alias.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{LYRA_DEFAULT_checkboxGroupRequired,LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";const DUPLICATE_VALUE_WARNING_KEY="lyra-checkbox-group-duplicate-child-values",DUPLICATE_VALUE_WARNING="<lr-checkbox-group>: duplicate child values make submitted FormData ambiguous; give each child a distinct value.";class LyraCheckboxGroup extends LyraElement{static{this.defaultStrings={...super.defaultStrings,checkboxGroupRequired:LYRA_DEFAULT_checkboxGroupRequired,fieldRequired:LYRA_DEFAULT_fieldRequired}}static{this.immutableEventDetails=Object.freeze(["lr-checkbox-group-toggle-request"])}static{this.identityEventDetailProperties=Object.freeze({"lr-checkbox-group-toggle-request":Object.freeze(["option"])})}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,srOnly,styles]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},name:{reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},size:{reflect:!0},orientation:{reflect:!0},value:{attribute:!1,noAccessor:!0}}}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.sync(),this.requestUpdate("name",old)}get value(){return Object.freeze([...this._value])}set value(next){markVetoGuardWrite(this.toggleGuard);const requested=Array.isArray(next)?next.filter(entry=>typeof entry=="string"):[];if(this.boxes.length===0){this.pendingValues=requested;return}this.pendingValues=void 0,this.applyValues(requested)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.sync(),this.requestUpdate("required",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.propagateDisabled(),this.sync(),this.requestUpdate("disabled",old)}constructor(){super(),this.orientation="vertical",this.label="",this.hint="",this.withLabel=!1,this.withHint=!1,this.errorText="",this.accessibleLabel="",this.touched=!1,this.hasInteracted=!1,this.hasLabelSlot=!1,this.hasHintSlot=!1,this.hasErrorSlot=!1,this.labelId=nextId("checkbox-group-label"),this.hintId=nextId("checkbox-group-hint"),this.errorId=nextId("checkbox-group-error"),this.requiredDescriptionId=nextId("checkbox-group-required"),this._fieldsetDisabled=!1,this._name="",this._required=!1,this._disabled=!1,this._value=[],this.childObserverGeneration=0,this.childControllers=new Map,this.toggleGuard=new VetoWriteGuard,this.authoredChildSizes=new Map,this.markInteracted=()=>{this.hasInteracted||(this.hasInteracted=!0,this.reflectValidityStates())},this.suppressCheckboxSync=!1,this.onChildEvent=event=>{if(!this.isOwnedCheckbox(event.target)||(event.stopImmediatePropagation(),event.type!=="change"||this.effectiveDisabled))return;this.hasInteracted=!0,this.sync();const detail=()=>Object.freeze({value:this.value});this.emit("input",detail()),this.emit("change",detail()),this.emit("lr-change",detail())},this.onChildToggleRequest=event=>{if(!this.isOwnedCheckbox(event.target)||(event.stopImmediatePropagation(),this.effectiveDisabled))return;const option=event.target,proposed=event.detail.checked;let allowed=!1;requestThenCommit({requestDetail:{value:this.projectedValue(option,proposed),previousValue:this.value,option},emitRequest:(detail,init)=>this.emit("lr-checkbox-group-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{allowed=!0}}),allowed||event.preventDefault()},this.onChildMutations=records=>{if(records.some(record=>record.type==="childList"||record.attributeName==="slot")){this.onSlotChange();return}for(const record of records){if(record.attributeName!=="size"||!this.isOwnedCheckbox(record.target))continue;const box=record.target;this.size!==void 0&&box.size!==this.size&&this.authoredChildSizes.set(box,box.size)}records.some(record=>record.attributeName==="size"&&this.isOwnedCheckbox(record.target))&&this.propagateSize(),records.some(record=>this.isOwnedCheckbox(record.target))&&this.sync()},this.onSlotChange=()=>{this.syncSupportSlotFlags(),this.reconcileChildControllers(),!this.applyPendingRestore()&&!this.applyPendingValues()&&this.sync(),this.propagateDisabled(),this.propagateSize()},this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this[VALIDITY_ANCHOR]()),installCustomErrorProperty(this,()=>this.validityController.customValidityMessage),installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),installInteractionOnInvalid(this,this.markInteracted)}checkboxGroupOwner(element){const group=element.closest("lr-checkbox-group");if(!group)return null;let topLevelChild=element;for(;topLevelChild.parentElement&&topLevelChild.parentElement!==group;)topLevelChild=topLevelChild.parentElement;if(topLevelChild.parentElement!==group)return null;const slot=topLevelChild.getAttribute("slot");return slot==="label"||slot==="hint"||slot==="error"?null:group}ownsCheckbox(element){return element.localName==="lr-checkbox"&&this.checkboxGroupOwner(element)===this}get boxes(){const querySelectorAll=this.querySelectorAll;return typeof querySelectorAll!="function"?[]:Array.from(querySelectorAll.call(this,"lr-checkbox")).filter(box=>this.ownsCheckbox(box))}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}propagateDisabled(){const effective=this.effectiveDisabled;this.boxes.forEach(box=>box.setGroupDisabled?.(effective))}propagateSize(){for(const box of this.boxes)if(this.authoredChildSizes.has(box)||this.authoredChildSizes.set(box,box.size),this.size===void 0||this.size===null){const authored=this.authoredChildSizes.get(box);authored!==void 0&&box.size!==authored&&(box.size=authored),this.authoredChildSizes.delete(box)}else box.size!==this.size&&(box.size=this.size)}readValue(){return this.boxes.filter(box=>box.checked).map(box=>box.value??"on")}warnOnDuplicateValues(){const seen=new Set;for(const box of this.boxes){const value=box.value??box.getAttribute("value")??"on";if(!seen.has(value)){seen.add(value);continue}devWarnOnce(DUPLICATE_VALUE_WARNING_KEY,DUPLICATE_VALUE_WARNING);return}}sync(){const next=this.readValue();this.warnOnDuplicateValues();const old=this._value;this._value=next,this.requestUpdate("value",old);const data=new FormData;this.name&&next.forEach(value=>data.append(this.name,value)),this.internals.setFormValue(this.name?data:null,createStringArrayFormDataState(this.name,next)),!this.barredFromValidation&&this.required&&next.length===0?this.validityController.setValidity({valueMissing:!0},this.localize("checkboxGroupRequired")):this.validityController.setValidity({}),this.reflectValidityStates()}notifyCheckboxStateChange(checkbox){this.suppressCheckboxSync||this.isConnected&&this.ownsCheckbox(checkbox)&&this.sync()}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}reflectValidityStates(){const barred=this.barredFromValidation;this.toggleAttribute("data-invalid",!barred&&this.touched&&!this.internals.validity.valid),syncValidityStates(this.internals,{required:this.required,hasInteracted:this.hasInteracted,barred})}isOwnedCheckbox(target){return target?.nodeType===1&&this.ownsCheckbox(target)}projectedValue(option,proposed){return Object.freeze(this.boxes.filter(box=>box===option?proposed:box.checked).map(box=>box.value??"on"))}reconcileChildControllers(){const current=new Set(this.boxes);for(const[box,controller]of this.childControllers){if(current.has(box))continue;box.removeController(controller),this.childControllers.delete(box);const authoredSize=this.authoredChildSizes.get(box);authoredSize!==void 0&&box.size!==authoredSize&&(box.size=authoredSize),this.authoredChildSizes.delete(box);const nextOwner=this.checkboxGroupOwner(box);(!nextOwner||nextOwner===this)&&box.setGroupDisabled?.(!1)}for(const box of current){if(this.childControllers.has(box)||typeof box.addController!="function")continue;const controller={hostUpdated:()=>{this.isConnected&&this.ownsCheckbox(box)&&this.sync()}};box.addController(controller),this.childControllers.set(box,controller)}}hasDirectSupportSlot(name){return Array.from(this.children??[]).some(child=>child.getAttribute("slot")===name)}syncSupportSlotFlags(){this.hasLabelSlot=this.hasDirectSupportSlot("label"),this.hasHintSlot=this.hasDirectSupportSlot("hint"),this.hasErrorSlot=this.hasDirectSupportSlot("error")}applyValues(values){const remaining=[...values];this.suppressCheckboxSync=!0;try{for(const box of this.boxes){const value=box.value??"on",index=remaining.indexOf(value);box.checked=index>=0,index>=0&&remaining.splice(index,1)}}finally{this.suppressCheckboxSync=!1}this.sync()}applyPendingRestore(){if(this.pendingRestoreValues===void 0||this.boxes.length===0)return!1;const values=this.pendingRestoreValues;return this.pendingRestoreValues=void 0,this.touched=!1,this.hasInteracted=!1,this.applyValues(values),!0}applyPendingValues(){if(this.pendingValues===void 0||this.boxes.length===0)return!1;const values=this.pendingValues;return this.pendingValues=void 0,this.applyValues(values),!0}connectedCallback(){super.connectedCallback(),this.addEventListener("input",this.onChildEvent,{capture:!0}),this.addEventListener("change",this.onChildEvent,{capture:!0}),this.addEventListener("lr-change",this.onChildEvent,{capture:!0}),this.addEventListener("lr-checkbox-toggle-request",this.onChildToggleRequest,{capture:!0}),this.hasUpdated?this.onSlotChange():(this.seedFirstRenderState(()=>this.syncSupportSlotFlags()),this.reconcileChildControllers(),!this.applyPendingRestore()&&!this.applyPendingValues()&&this.sync(),this.propagateDisabled(),this.propagateSize()),this.armChildObserver(),this.hasUpdated&&(this.syncRequiredDescription(),this.syncExternalDescription())}armChildObserver(){const ownerDocument=this.ownerDocument;if(!this.isConnected||this.childObserver&&this.childObserverDocument===ownerDocument)return;this.resetChildObserver();const MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.childObserverGeneration,observer=new MutationObserverCtor(records=>{this.childObserver!==observer||this.childObserverDocument!==ownerDocument||this.childObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||this.onChildMutations(records)});this.childObserver=observer,this.childObserverDocument=ownerDocument,observer.observe(this,{attributes:!0,childList:!0,subtree:!0,attributeFilter:["checked","value","disabled","size","slot"]})}disconnectedCallback(){this.releaseExternalDescription(),this.releaseRequiredDescription(),this.removeEventListener("input",this.onChildEvent,{capture:!0}),this.removeEventListener("change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-checkbox-toggle-request",this.onChildToggleRequest,{capture:!0}),this.resetChildObserver();for(const[box,controller]of this.childControllers){box.removeController(controller),box.setGroupDisabled?.(!1);const authoredSize=this.authoredChildSizes.get(box);authoredSize!==void 0&&box.size!==authoredSize&&(box.size=authoredSize)}this.childControllers.clear(),this.authoredChildSizes.clear(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.releaseExternalDescription(),this.releaseRequiredDescription(),this.resetChildObserver(),this.isConnected&&this.hasUpdated&&(this.syncRequiredDescription(),this.syncExternalDescription())}resetChildObserver(){this.childObserverGeneration+=1,this.childObserver?.disconnect(),this.childObserver=void 0,this.childObserverDocument=void 0}firstUpdated(changed){super.firstUpdated(changed),this.addEventListener("blur",event=>{const blurredControl=event.target;(typeof blurredControl?.matches=="function"?blurredControl.matches(":disabled"):this.effectiveDisabled)||(this.touched=!0,this.hasInteracted=!0),this.sync()},!0)}updated(changed){super.updated(changed),changed.has("size")&&this.propagateSize(),this.syncRequiredDescription(),this.syncExternalDescription()}syncExternalDescription(){const target=this.renderRoot.querySelector("fieldset");if(!target){this.releaseExternalDescription();return}if(!this.externalDescriptionLease){this.externalDescriptionLease=acquireResolvedAriaRelationship(this,target,"aria-describedby");return}this.externalDescriptionLease.update(target)}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}syncRequiredDescription(){const target=this.renderRoot.querySelector("fieldset"),description=this.renderRoot.querySelector(`#${this.requiredDescriptionId}`);if(!this.required||!target||!description){this.releaseRequiredDescription();return}if(this.requiredDescriptionTarget!==target){this.releaseRequiredDescription(),this.requiredDescriptionTarget=target,this.requiredDescriptionLease=acquireAriaDescription(target,[description]);return}this.requiredDescriptionLease?.update([description])}releaseRequiredDescription(){this.requiredDescriptionLease?.release(),this.requiredDescriptionLease=void 0,this.requiredDescriptionTarget=void 0}[VALIDITY_ANCHOR](){const first=this.firstEnabledBox();return resolveValidityAnchor(first)??first??null}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}getForm(){return getFormOwner(this.internals)}get labels(){return this.internals.labels}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}get willValidate(){return this.internals.willValidate}checkValidity(){return withStaticValidityCheck(this,()=>this.internals.checkValidity())}reportValidity(){return this.hasInteracted=!0,this.reflectValidityStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.reflectValidityStates(),this.requestUpdate()}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}firstEnabledBox(){return this.boxes.find(box=>!box.effectiveDisabled&&!box.matches(":disabled"))}focus(options){this.liveDisabled||this.firstEnabledBox()?.focus(options)}blur(){this.boxes.find(box=>box.matches(":focus-within"))?.blur()}click(){this.liveDisabled||this.firstEnabledBox()?.click()}formResetCallback(){this.suppressCheckboxSync=!0;try{this.boxes.forEach(box=>box.resetFromGroup())}finally{this.suppressCheckboxSync=!1}this.touched=!1,this.hasInteracted=!1,this.sync()}formStateRestoreCallback(state2,_mode){this.pendingRestoreValues=readStringArrayFormDataState(state2),this.applyPendingRestore()}formDisabledCallback(disabled){this._fieldsetDisabled=disabled,this.propagateDisabled(),this.sync(),this.requestUpdate()}render(){const hasLabel=this.hasLabelSlot||!!this.label||this.withLabel,hasHint=this.hasHintSlot||!!this.hint||this.withHint,hasError=this.hasErrorSlot||!!this.errorText,described=[hasHint?this.hintId:"",hasError?this.errorId:""].filter(Boolean).join(" ")||nothing,invalid=hasError||this.touched&&!this.internals.validity.valid;return html`<fieldset
2
2
  part="form-control"
3
3
  ?disabled=${this.effectiveDisabled}
4
4
  aria-label=${hostAriaLabel(this)??nothing}
@@ -63,6 +63,8 @@ import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from
63
63
  * enabled surface is hovered.
64
64
  * @cssprop [--lr-code-editor-invalid-border=var(--lr-color-danger)] - Editor-frame border while
65
65
  * invalid chrome is visible.
66
+ * @cssprop [--lr-code-editor-radius=var(--lr-radius)] - Corner radius of the editor frame. Retune
67
+ * it without a `::part(editor)` rule.
66
68
  * @cssprop [--lr-form-control-required-content=' *'] - The required-field marker rendered after the
67
69
  * label. Set it to `''` to suppress the marker, or to any other quoted string (`' (required)'`, a
68
70
  * localized word) to replace it. Caller-supplied content, so it is never localized here.