@aceshooting/lyra-ui 13.0.1 → 14.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (723) hide show
  1. package/CHANGELOG.md +329 -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 +23 -15
  5. package/dist/components/agent-tools/activity-feed/activity-feed.class.js +9 -6
  6. package/dist/components/agent-tools/agent-trace/agent-trace.class.d.ts +12 -3
  7. package/dist/components/agent-tools/agent-trace/agent-trace.class.js +2 -1
  8. package/dist/components/agent-tools/approval-queue/approval-queue.class.d.ts +4 -2
  9. package/dist/components/agent-tools/approval-queue/approval-queue.class.js +1 -1
  10. package/dist/components/agent-tools/artifact-panel/artifact-panel.styles.js +1 -1
  11. package/dist/components/agent-tools/commit-card/commit-card.class.d.ts +3 -1
  12. package/dist/components/agent-tools/commit-card/commit-card.class.js +2 -2
  13. package/dist/components/agent-tools/compare-panel/compare-panel.class.d.ts +2 -1
  14. package/dist/components/agent-tools/compare-panel/compare-panel.styles.js +1 -1
  15. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.d.ts +6 -2
  16. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.js +8 -8
  17. package/dist/components/agent-tools/result-card/result-card.class.d.ts +1 -1
  18. package/dist/components/agent-tools/result-card/result-card.class.js +1 -1
  19. package/dist/components/agent-tools/result-card/result-field.class.d.ts +1 -1
  20. package/dist/components/agent-tools/result-card/result-field.class.js +1 -1
  21. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.d.ts +5 -5
  22. package/dist/components/agent-tools/schema-viewer/schema-viewer.class.js +23 -10
  23. package/dist/components/agent-tools/span-waterfall/span-waterfall.class.d.ts +13 -6
  24. package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +3 -3
  25. package/dist/components/agent-tools/span-waterfall/span-waterfall.styles.js +1 -1
  26. package/dist/components/agent-tools/stack-trace/stack-trace-parse.js +3 -3
  27. package/dist/components/agent-tools/stack-trace/stack-trace.class.d.ts +1 -1
  28. package/dist/components/agent-tools/stack-trace/stack-trace.class.js +1 -1
  29. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +1 -1
  30. package/dist/components/agent-tools/subagent-panel/subagent-panel.styles.js +1 -1
  31. package/dist/components/agent-tools/task-list/task-list.class.d.ts +1 -2
  32. package/dist/components/agent-tools/task-list/task-list.class.js +2 -2
  33. package/dist/components/agent-tools/terminal/terminal.class.d.ts +11 -2
  34. package/dist/components/agent-tools/terminal/terminal.class.js +5 -5
  35. package/dist/components/agent-tools/terminal/terminal.styles.js +1 -1
  36. package/dist/components/agent-tools/test-results/test-results.class.d.ts +4 -2
  37. package/dist/components/agent-tools/test-results/test-results.class.js +2 -2
  38. package/dist/components/agent-tools/thinking-panel/thinking-panel.class.d.ts +2 -0
  39. package/dist/components/agent-tools/thinking-panel/thinking-panel.styles.js +1 -1
  40. package/dist/components/agent-tools/tool-approval-dialog/tool-approval-dialog.class.js +1 -1
  41. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +2 -2
  42. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +1 -1
  43. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +3 -2
  44. package/dist/components/agent-tools/tool-param-form/tool-param-form.d.ts +1 -1
  45. package/dist/components/agent-tools/tool-param-form/tool-param-form.js +1 -1
  46. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.js +2 -2
  47. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.styles.js +1 -1
  48. package/dist/components/agent-tools/tool-result-view/registry.d.ts +2 -1
  49. package/dist/components/agent-tools/tool-result-view/tool-result-view.class.d.ts +1 -1
  50. package/dist/components/agent-tools/tool-result-view/tool-result-view.class.js +1 -1
  51. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.d.ts +18 -12
  52. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +7 -7
  53. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +9 -3
  54. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +1 -1
  55. package/dist/components/agent-tools/trace-tree/span.d.ts +3 -1
  56. package/dist/components/agent-tools/trace-tree/span.js +1 -1
  57. package/dist/components/agent-tools/trace-tree/trace-tree.styles.js +1 -1
  58. package/dist/components/charts/chart/box-plot.class.d.ts +12 -3
  59. package/dist/components/charts/chart/box-plot.class.js +9 -9
  60. package/dist/components/charts/chart/box-plot.styles.js +1 -1
  61. package/dist/components/charts/chart/chart-core-loader.js +1 -1
  62. package/dist/components/charts/chart/chart-feature-loader.js +1 -1
  63. package/dist/components/charts/chart/chart-preload.d.ts +1 -1
  64. package/dist/components/charts/chart/chart-preload.js +1 -1
  65. package/dist/components/charts/chart/chart.class.d.ts +33 -10
  66. package/dist/components/charts/chart/chart.class.js +23 -14
  67. package/dist/components/charts/chart/chart.styles.js +1 -1
  68. package/dist/components/charts/chart/histogram-bin.js +1 -1
  69. package/dist/components/charts/chart/lite-chart.class.d.ts +20 -11
  70. package/dist/components/charts/chart/lite-chart.class.js +17 -11
  71. package/dist/components/charts/chart/lite-chart.styles.js +1 -1
  72. package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +1 -1
  73. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +2 -2
  74. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.d.ts +10 -5
  75. package/dist/components/conversation/audio-visualizer/audio-visualizer.class.js +1 -1
  76. package/dist/components/conversation/branch-picker/branch-picker.class.d.ts +4 -2
  77. package/dist/components/conversation/branch-picker/branch-picker.class.js +1 -1
  78. package/dist/components/conversation/branch-picker/branch-picker.styles.js +1 -1
  79. package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +6 -2
  80. package/dist/components/conversation/chat-composer/chat-composer.class.js +3 -3
  81. package/dist/components/conversation/chat-composer/chat-composer.styles.js +1 -1
  82. package/dist/components/conversation/chat-message/chat-message.class.d.ts +4 -3
  83. package/dist/components/conversation/chat-message/chat-message.class.js +2 -2
  84. package/dist/components/conversation/chat-message/chat-message.styles.js +1 -1
  85. package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +1 -1
  86. package/dist/components/conversation/code-block/code-block-core.class.d.ts +4 -3
  87. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  88. package/dist/components/conversation/code-block/code-block-shared.d.ts +3 -3
  89. package/dist/components/conversation/code-block/code-block-shared.js +2 -2
  90. package/dist/components/conversation/code-block/code-block.class.d.ts +4 -3
  91. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  92. package/dist/components/conversation/code-block/code-block.styles.js +1 -1
  93. package/dist/components/conversation/code-block/code-loader.d.ts +1 -1
  94. package/dist/components/conversation/code-block/code-loader.js +1 -1
  95. package/dist/components/conversation/code-block/shiki-types.d.ts +2 -0
  96. package/dist/components/conversation/code-block/shiki-types.js +1 -1
  97. package/dist/components/conversation/conversation-item/conversation-item.class.js +1 -1
  98. package/dist/components/conversation/conversation-item/conversation-item.styles.js +1 -1
  99. package/dist/components/conversation/generation-metrics/generation-metrics.styles.js +1 -1
  100. package/dist/components/conversation/markdown/katex-loader.d.ts +4 -4
  101. package/dist/components/conversation/markdown/katex-loader.js +1 -1
  102. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  103. package/dist/components/conversation/markdown/markdown-core.class.d.ts +1 -1
  104. package/dist/components/conversation/markdown/markdown-loader.d.ts +1 -1
  105. package/dist/components/conversation/markdown/markdown-loader.js +1 -1
  106. package/dist/components/conversation/markdown/markdown-shared.d.ts +6 -1
  107. package/dist/components/conversation/markdown/markdown-shared.js +5 -4
  108. package/dist/components/conversation/markdown/markdown.class.d.ts +1 -1
  109. package/dist/components/conversation/message-actions/message-actions.class.d.ts +18 -3
  110. package/dist/components/conversation/message-actions/message-actions.class.js +2 -2
  111. package/dist/components/conversation/message-actions/message-actions.styles.js +1 -1
  112. package/dist/components/conversation/message-actions/toolbar-actions.d.ts +3 -1
  113. package/dist/components/conversation/message-actions/toolbar-actions.js +1 -1
  114. package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +40 -15
  115. package/dist/components/conversation/message-feedback/message-feedback.class.js +7 -3
  116. package/dist/components/conversation/message-feedback/message-feedback.styles.js +1 -1
  117. package/dist/components/conversation/message-parts/message-parts.class.d.ts +10 -4
  118. package/dist/components/conversation/message-parts/message-parts.class.js +2 -2
  119. package/dist/components/conversation/message-parts/message-parts.styles.js +1 -1
  120. package/dist/components/conversation/model-select/model-select.class.d.ts +5 -2
  121. package/dist/components/conversation/model-select/model-select.class.js +8 -5
  122. package/dist/components/conversation/model-settings-panel/model-settings-panel.class.d.ts +3 -5
  123. package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +2 -1
  124. package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +9 -2
  125. package/dist/components/conversation/prompt-input/prompt-input.class.js +3 -3
  126. package/dist/components/conversation/prompt-input/prompt-input.styles.js +1 -1
  127. package/dist/components/conversation/prompt-queue/prompt-queue.class.d.ts +20 -4
  128. package/dist/components/conversation/prompt-queue/prompt-queue.class.js +1 -1
  129. package/dist/components/conversation/prompt-queue/prompt-queue.styles.js +1 -1
  130. package/dist/components/conversation/push-to-talk/push-to-talk.class.d.ts +17 -8
  131. package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
  132. package/dist/components/conversation/push-to-talk/push-to-talk.styles.js +1 -1
  133. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +6 -3
  134. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  135. package/dist/components/conversation/selection-toolbar/selection-toolbar.styles.js +1 -1
  136. package/dist/components/conversation/thread-list/thread-list.class.d.ts +14 -4
  137. package/dist/components/conversation/thread-list/thread-list.class.js +11 -11
  138. package/dist/components/conversation/thread-list/thread-list.styles.js +1 -1
  139. package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +2 -0
  140. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  141. package/dist/components/conversation/transcript-feed/transcript-feed.styles.js +1 -1
  142. package/dist/components/conversation/typing-indicator/typing-indicator.class.d.ts +2 -1
  143. package/dist/components/conversation/typing-indicator/typing-indicator.class.js +1 -1
  144. package/dist/components/conversation/usage-badge/usage-badge-overlay-runtime.d.ts +3 -0
  145. package/dist/components/conversation/usage-badge/usage-badge-overlay-runtime.js +1 -0
  146. package/dist/components/conversation/usage-badge/usage-badge.class.d.ts +4 -2
  147. package/dist/components/conversation/usage-badge/usage-badge.class.js +1 -1
  148. package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +12 -4
  149. package/dist/components/conversation/voice-picker/voice-picker.class.js +8 -5
  150. package/dist/components/conversation/voice-picker/voice-picker.styles.js +1 -1
  151. package/dist/components/conversation/widget-renderer/resolve.d.ts +4 -6
  152. package/dist/components/conversation/widget-renderer/resolve.js +1 -1
  153. package/dist/components/data/calendar/calendar.class.d.ts +16 -5
  154. package/dist/components/data/calendar/calendar.class.js +2 -2
  155. package/dist/components/data/calendar/calendar.styles.js +1 -1
  156. package/dist/components/data/condition-builder/condition-builder.class.d.ts +3 -1
  157. package/dist/components/data/condition-builder/condition-builder.class.js +15 -1
  158. package/dist/components/data/context-meter/context-meter.class.d.ts +3 -1
  159. package/dist/components/data/context-meter/context-meter.class.js +4 -4
  160. package/dist/components/data/data-grid/data-grid.class.d.ts +51 -6
  161. package/dist/components/data/data-grid/data-grid.class.js +25 -11
  162. package/dist/components/data/data-grid/data-grid.styles.js +1 -1
  163. package/dist/components/data/document-library/document-library.class.d.ts +5 -2
  164. package/dist/components/data/document-library/document-library.class.js +1 -1
  165. package/dist/components/data/env-list/env-list.class.js +1 -1
  166. package/dist/components/data/file-tree/file-tree.class.d.ts +2 -1
  167. package/dist/components/data/file-tree/file-tree.class.js +1 -1
  168. package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +24 -14
  169. package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -2
  170. package/dist/components/data/flow-canvas/flow-canvas.styles.js +1 -1
  171. package/dist/components/data/flow-canvas/flow-model.js +1 -1
  172. package/dist/components/data/flow-canvas/flow-types.d.ts +2 -1
  173. package/dist/components/data/flow-controls/flow-controls.styles.js +1 -1
  174. package/dist/components/data/flow-run-status/flow-run-status.class.js +1 -1
  175. package/dist/components/data/funnel/funnel.class.d.ts +1 -0
  176. package/dist/components/data/funnel/funnel.class.js +1 -1
  177. package/dist/components/data/gauge/gauge.class.d.ts +4 -1
  178. package/dist/components/data/gauge/gauge.class.js +6 -6
  179. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +5 -2
  180. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +15 -1
  181. package/dist/components/data/graph-query-builder/graph-query-builder.styles.js +1 -1
  182. package/dist/components/data/heatmap/heatmap.class.d.ts +7 -4
  183. package/dist/components/data/heatmap/heatmap.class.js +1 -1
  184. package/dist/components/data/sequence-strip/sequence-strip.class.js +1 -1
  185. package/dist/components/data/sparkline/sparkline.class.d.ts +2 -1
  186. package/dist/components/data/sparkline/sparkline.class.js +1 -1
  187. package/dist/components/data/stat/stat.class.d.ts +6 -2
  188. package/dist/components/data/stat/stat.class.js +1 -1
  189. package/dist/components/data/table/table.class.d.ts +15 -16
  190. package/dist/components/data/table/table.class.js +5 -4
  191. package/dist/components/data/table/table.styles.js +1 -1
  192. package/dist/components/data/timeline/timeline.class.d.ts +7 -2
  193. package/dist/components/data/timeline/timeline.class.js +1 -1
  194. package/dist/components/data/timeline/timeline.styles.js +1 -1
  195. package/dist/components/data/tree/tree-item.class.d.ts +3 -1
  196. package/dist/components/data/tree/tree-item.class.js +1 -1
  197. package/dist/components/data/tree/tree-item.styles.js +1 -1
  198. package/dist/components/data/tree/tree.class.d.ts +4 -1
  199. package/dist/components/data/tree/tree.class.js +1 -1
  200. package/dist/components/data/word-cloud/word-cloud-layout.d.ts +2 -1
  201. package/dist/components/data/word-cloud/word-cloud-layout.js +1 -1
  202. package/dist/components/data/word-cloud/word-cloud.class.d.ts +2 -1
  203. package/dist/components/data/word-cloud/word-cloud.class.js +1 -1
  204. package/dist/components/forms/button/button.class.d.ts +5 -3
  205. package/dist/components/forms/button/button.class.js +1 -1
  206. package/dist/components/forms/checkbox/checkbox.class.d.ts +3 -0
  207. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  208. package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +7 -2
  209. package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
  210. package/dist/components/forms/code-editor/code-editor.class.d.ts +16 -4
  211. package/dist/components/forms/code-editor/code-editor.class.js +19 -9
  212. package/dist/components/forms/code-editor/code-editor.styles.js +1 -1
  213. package/dist/components/forms/color-picker/color-picker.class.d.ts +6 -2
  214. package/dist/components/forms/color-picker/color-picker.class.js +4 -4
  215. package/dist/components/forms/combobox/combobox.class.d.ts +19 -8
  216. package/dist/components/forms/combobox/combobox.class.js +3 -3
  217. package/dist/components/forms/combobox/combobox.styles.js +1 -1
  218. package/dist/components/forms/combobox/option.class.d.ts +4 -0
  219. package/dist/components/forms/combobox/option.class.js +2 -2
  220. package/dist/components/forms/date-picker/calendar-core.d.ts +1 -1
  221. package/dist/components/forms/date-picker/calendar-core.js +1 -1
  222. package/dist/components/forms/date-picker/date-input.class.d.ts +20 -10
  223. package/dist/components/forms/date-picker/date-input.class.js +4 -4
  224. package/dist/components/forms/date-picker/date-picker.class.d.ts +33 -15
  225. package/dist/components/forms/date-picker/date-picker.class.js +8 -8
  226. package/dist/components/forms/date-picker/date-picker.styles.js +1 -1
  227. package/dist/components/forms/emoji-picker/emoji-data-loader.js +1 -1
  228. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +11 -3
  229. package/dist/components/forms/emoji-picker/emoji-picker.class.js +3 -3
  230. package/dist/components/forms/emoji-picker/emoji-types.d.ts +2 -2
  231. package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -2
  232. package/dist/components/forms/icon-button/icon-button.class.js +1 -1
  233. package/dist/components/forms/input/input.class.d.ts +16 -5
  234. package/dist/components/forms/input/input.class.js +7 -1
  235. package/dist/components/forms/input/native-time-input.class.d.ts +3 -0
  236. package/dist/components/forms/input/number-input.class.d.ts +3 -0
  237. package/dist/components/forms/input/time-input.class.d.ts +11 -2
  238. package/dist/components/forms/input/time-input.class.js +2 -2
  239. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +22 -4
  240. package/dist/components/forms/locale-picker/locale-picker.class.js +2 -2
  241. package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
  242. package/dist/components/forms/otp-input/otp-input.class.d.ts +5 -1
  243. package/dist/components/forms/otp-input/otp-input.class.js +1 -1
  244. package/dist/components/forms/phone-input/phone-input.class.d.ts +21 -8
  245. package/dist/components/forms/phone-input/phone-input.class.js +1 -1
  246. package/dist/components/forms/radio/radio-button.class.d.ts +4 -0
  247. package/dist/components/forms/radio/radio-group.class.d.ts +4 -1
  248. package/dist/components/forms/radio/radio-group.class.js +1 -1
  249. package/dist/components/forms/radio/radio.class.d.ts +6 -2
  250. package/dist/components/forms/radio/radio.class.js +1 -1
  251. package/dist/components/forms/rubric-form/rubric-form.class.d.ts +7 -1
  252. package/dist/components/forms/rubric-form/rubric-form.class.js +3 -3
  253. package/dist/components/forms/select/select.class.d.ts +8 -2
  254. package/dist/components/forms/select/select.class.js +2 -2
  255. package/dist/components/forms/select/select.styles.js +1 -1
  256. package/dist/components/forms/slider/slider.class.d.ts +12 -6
  257. package/dist/components/forms/slider/slider.class.js +2 -2
  258. package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +4 -0
  259. package/dist/components/forms/swatch-picker/swatch-picker.class.js +1 -1
  260. package/dist/components/forms/switch/switch.class.d.ts +5 -1
  261. package/dist/components/forms/switch/switch.class.js +1 -1
  262. package/dist/components/forms/textarea/textarea.class.d.ts +3 -0
  263. package/dist/components/forms/textarea/textarea.class.js +1 -1
  264. package/dist/components/forms/time-range/time-range.class.d.ts +3 -0
  265. package/dist/components/forms/time-range/time-range.class.js +1 -1
  266. package/dist/components/forms/token-input/token-input.class.d.ts +8 -2
  267. package/dist/components/forms/token-input/token-input.class.js +2 -2
  268. package/dist/components/forms/token-input/token-input.styles.js +1 -1
  269. package/dist/components/layout/app-rail/app-rail.class.d.ts +9 -5
  270. package/dist/components/layout/app-rail/app-rail.class.js +4 -3
  271. package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
  272. package/dist/components/layout/carousel/carousel.class.d.ts +3 -2
  273. package/dist/components/layout/carousel/carousel.class.js +1 -1
  274. package/dist/components/layout/command-palette/command-palette.class.d.ts +2 -2
  275. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  276. package/dist/components/layout/command-palette/command-palette.styles.js +1 -1
  277. package/dist/components/layout/dashboard-grid/dashboard-grid.class.d.ts +2 -0
  278. package/dist/components/layout/dashboard-grid/dashboard-grid.class.js +1 -1
  279. package/dist/components/layout/details/details.class.d.ts +16 -15
  280. package/dist/components/layout/details/details.class.js +43 -34
  281. package/dist/components/layout/details/details.styles.js +1 -1
  282. package/dist/components/layout/dock-panel/dock-panel.class.d.ts +4 -3
  283. package/dist/components/layout/dock-panel/dock-panel.class.js +2 -1
  284. package/dist/components/layout/filter-bar/filter-bar.class.d.ts +3 -1
  285. package/dist/components/layout/filter-bar/filter-bar.class.js +2 -2
  286. package/dist/components/layout/menu/menu-item.class.js +2 -2
  287. package/dist/components/layout/menu/menu-label.class.d.ts +3 -3
  288. package/dist/components/layout/menu/menu.class.d.ts +4 -1
  289. package/dist/components/layout/menu/menu.class.js +1 -1
  290. package/dist/components/layout/multi-split/multi-split.class.d.ts +19 -8
  291. package/dist/components/layout/multi-split/multi-split.class.js +2 -1
  292. package/dist/components/layout/multi-split/multi-split.styles.js +1 -1
  293. package/dist/components/layout/reorder-list/reorder-item.class.d.ts +2 -1
  294. package/dist/components/layout/reorder-list/reorder-item.class.js +1 -1
  295. package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
  296. package/dist/components/layout/reorder-list/reorder-owner.js +1 -1
  297. package/dist/components/layout/scroller/scroller.class.d.ts +4 -4
  298. package/dist/components/layout/scroller/scroller.styles.js +1 -1
  299. package/dist/components/layout/split-panel/split-panel.class.d.ts +5 -3
  300. package/dist/components/layout/split-panel/split-panel.class.js +3 -2
  301. package/dist/components/layout/tab-group/tab-group.class.d.ts +3 -1
  302. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  303. package/dist/components/layout/tab-group/tab-group.styles.js +1 -1
  304. package/dist/components/layout/virtual-list/virtual-list.class.js +2 -2
  305. package/dist/components/layout/widget/widget.class.d.ts +6 -2
  306. package/dist/components/layout/widget/widget.class.js +1 -1
  307. package/dist/components/layout/widget/widget.styles.js +1 -1
  308. package/dist/components/media/animation/animation.class.d.ts +3 -2
  309. package/dist/components/media/animation/animation.class.js +1 -1
  310. package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +4 -3
  311. package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
  312. package/dist/components/media/av-player/av-metadata.d.ts +3 -2
  313. package/dist/components/media/av-player/av-player.class.d.ts +4 -3
  314. package/dist/components/media/av-player/av-player.class.js +3 -3
  315. package/dist/components/media/av-player/av-player.styles.js +1 -1
  316. package/dist/components/media/avatar/avatar.class.d.ts +2 -1
  317. package/dist/components/media/avatar/avatar.class.js +1 -1
  318. package/dist/components/media/file-input/file-input.class.d.ts +4 -2
  319. package/dist/components/media/file-input/file-input.class.js +1 -1
  320. package/dist/components/media/file-input/file-input.styles.js +1 -1
  321. package/dist/components/media/flag/flag.class.js +1 -1
  322. package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -1
  323. package/dist/components/media/image-viewer/image-viewer.class.js +1 -1
  324. package/dist/components/media/image-viewer/image-viewer.styles.js +1 -1
  325. package/dist/components/media/lightbox/lightbox.styles.js +1 -1
  326. package/dist/components/media/map/map-loader.js +1 -1
  327. package/dist/components/media/map/map.class.d.ts +22 -34
  328. package/dist/components/media/map/map.class.js +1 -1
  329. package/dist/components/media/map/map.styles.js +1 -1
  330. package/dist/components/media/media-card/media-card.class.d.ts +1 -1
  331. package/dist/components/media/media-card/media-card.class.js +1 -1
  332. package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
  333. package/dist/components/media/qr-code/qr-code-loader.js +1 -1
  334. package/dist/components/media/qr-code/qr-code.class.d.ts +5 -2
  335. package/dist/components/media/qr-code/qr-code.class.js +2 -2
  336. package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +3 -3
  337. package/dist/components/media/sequence-playback/sequence-playback.class.js +1 -1
  338. package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
  339. package/dist/components/media/video/video.class.d.ts +2 -1
  340. package/dist/components/media/video/video.styles.js +1 -1
  341. package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +3 -2
  342. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
  343. package/dist/components/overlays/alert/alert.styles.js +1 -1
  344. package/dist/components/overlays/callout/callout.styles.js +1 -1
  345. package/dist/components/overlays/chip/chip-group.class.d.ts +2 -0
  346. package/dist/components/overlays/chip/chip-group.class.js +1 -1
  347. package/dist/components/overlays/dialog/dialog.class.d.ts +2 -0
  348. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  349. package/dist/components/overlays/dialog/dialog.styles.js +1 -1
  350. package/dist/components/overlays/empty/empty.class.d.ts +2 -0
  351. package/dist/components/overlays/empty/empty.class.js +1 -1
  352. package/dist/components/overlays/kbd/kbd.class.d.ts +2 -0
  353. package/dist/components/overlays/kbd/kbd.class.js +1 -1
  354. package/dist/components/overlays/overlay/popover.class.d.ts +3 -1
  355. package/dist/components/overlays/overlay/popover.class.js +1 -1
  356. package/dist/components/overlays/overlay/tooltip.class.d.ts +3 -1
  357. package/dist/components/overlays/overlay/tooltip.class.js +1 -1
  358. package/dist/components/overlays/rating/rating.class.d.ts +2 -0
  359. package/dist/components/overlays/rating/rating.class.js +1 -1
  360. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  361. package/dist/components/retrieval/claim-evidence/claim-evidence.class.d.ts +11 -5
  362. package/dist/components/retrieval/claim-evidence/claim-evidence.class.js +3 -3
  363. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +2 -2
  364. package/dist/components/retrieval/entity-card/entity-card.class.d.ts +5 -2
  365. package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
  366. package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +4 -2
  367. package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
  368. package/dist/components/retrieval/graph/graph-canvas.js +1 -1
  369. package/dist/components/retrieval/graph/graph-loader.js +1 -1
  370. package/dist/components/retrieval/graph/graph.class.d.ts +10 -8
  371. package/dist/components/retrieval/graph/graph.class.js +10 -10
  372. package/dist/components/retrieval/graph-legend/graph-legend.class.d.ts +4 -2
  373. package/dist/components/retrieval/graph-legend/graph-legend.class.js +1 -1
  374. package/dist/components/retrieval/grounding-summary/grounding-summary.class.d.ts +15 -9
  375. package/dist/components/retrieval/grounding-summary/grounding-summary.class.js +7 -5
  376. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +2 -0
  377. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +1 -1
  378. package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +3 -2
  379. package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +4 -3
  380. package/dist/components/retrieval/knowledge-base/knowledge-base.styles.js +1 -1
  381. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +7 -3
  382. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +8 -3
  383. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +1 -1
  384. package/dist/components/retrieval/memory-panel/memory-panel.class.d.ts +15 -6
  385. package/dist/components/retrieval/memory-panel/memory-panel.class.js +1 -1
  386. package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +1 -1
  387. package/dist/components/retrieval/neighbor-list/neighbor-list.styles.js +1 -1
  388. package/dist/components/retrieval/node-palette/node-palette.class.d.ts +17 -12
  389. package/dist/components/retrieval/node-palette/node-palette.class.js +2 -2
  390. package/dist/components/retrieval/node-palette/node-palette.styles.js +1 -1
  391. package/dist/components/retrieval/path-strip/path-strip.class.js +1 -1
  392. package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +2 -1
  393. package/dist/components/retrieval/provenance-panel/provenance-panel.class.js +1 -1
  394. package/dist/components/retrieval/retrieval-results/retrieval-results.class.d.ts +1 -1
  395. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +5 -5
  396. package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +1 -1
  397. package/dist/components/retrieval/source-picker/source-picker.class.d.ts +2 -1
  398. package/dist/components/retrieval/source-picker/source-picker.class.js +2 -2
  399. package/dist/components/utility/copy-button/copy-button.class.d.ts +2 -1
  400. package/dist/components/utility/copy-button/copy-button.class.js +1 -1
  401. package/dist/components/utility/diff-view/diff-view.class.d.ts +4 -1
  402. package/dist/components/utility/diff-view/diff-view.class.js +1 -1
  403. package/dist/components/utility/export-button/export-button.class.d.ts +2 -2
  404. package/dist/components/utility/export-button/export-button.class.js +1 -1
  405. package/dist/components/utility/export-button/export-button.styles.js +1 -1
  406. package/dist/components/utility/format/format-date.class.js +1 -1
  407. package/dist/components/utility/format/format-number.class.d.ts +3 -1
  408. package/dist/components/utility/format/format-options.js +1 -1
  409. package/dist/components/utility/format/relative-time.class.js +1 -1
  410. package/dist/components/utility/icon/dompurify-loader.js +1 -1
  411. package/dist/components/utility/icon/icon-library.js +1 -1
  412. package/dist/components/utility/intersection-observer/intersection-observer.class.js +1 -1
  413. package/dist/components/utility/json-viewer/json-viewer.class.d.ts +6 -3
  414. package/dist/components/utility/json-viewer/json-viewer.class.js +5 -5
  415. package/dist/components/utility/known-date/known-date.class.d.ts +9 -5
  416. package/dist/components/utility/known-date/known-date.class.js +2 -2
  417. package/dist/components/utility/known-date/known-date.styles.js +1 -1
  418. package/dist/components/utility/mention-popover/mention-popover.class.d.ts +32 -45
  419. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  420. package/dist/components/utility/mutation-observer/mutation-observer.class.js +1 -1
  421. package/dist/components/utility/poll-status/poll-status.class.d.ts +3 -0
  422. package/dist/components/utility/poll-status/poll-status.styles.js +1 -1
  423. package/dist/components/viewers/calendar-viewer/calendar-loader.js +1 -1
  424. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.d.ts +1 -0
  425. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
  426. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.d.ts +2 -1
  427. package/dist/components/viewers/dataset-viewer/dataset-viewer.styles.js +1 -1
  428. package/dist/components/viewers/document-compare/document-compare.class.d.ts +11 -8
  429. package/dist/components/viewers/document-compare/document-compare.class.js +2 -2
  430. package/dist/components/viewers/document-preview/document-preview.class.d.ts +8 -4
  431. package/dist/components/viewers/document-preview/document-preview.class.js +4 -4
  432. package/dist/components/viewers/document-preview/document-preview.styles.js +1 -1
  433. package/dist/components/viewers/document-viewer/document-viewer.class.d.ts +5 -2
  434. package/dist/components/viewers/document-viewer/document-viewer.class.js +2 -2
  435. package/dist/components/viewers/document-viewer/document-viewer.styles.js +1 -1
  436. package/dist/components/viewers/document-viewer/registry-ownership.d.ts +1 -0
  437. package/dist/components/viewers/document-viewer/registry-ownership.js +1 -0
  438. package/dist/components/viewers/document-viewer/registry.js +1 -1
  439. package/dist/components/viewers/docx-viewer/docx-loader.js +1 -1
  440. package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
  441. package/dist/components/viewers/ebook-viewer/ebook-loader.d.ts +1 -1
  442. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.d.ts +8 -2
  443. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  444. package/dist/components/viewers/email-viewer/email-loader.js +1 -1
  445. package/dist/components/viewers/email-viewer/email-viewer.class.d.ts +3 -2
  446. package/dist/components/viewers/email-viewer/email-viewer.class.js +2 -2
  447. package/dist/components/viewers/html-viewer/dompurify-loader.js +1 -1
  448. package/dist/components/viewers/include/include-resource.js +1 -1
  449. package/dist/components/viewers/include/include.class.d.ts +3 -1
  450. package/dist/components/viewers/notebook-viewer/dompurify-loader.js +1 -1
  451. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.d.ts +4 -2
  452. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +4 -4
  453. package/dist/components/viewers/notebook-viewer/notebook-viewer.styles.js +1 -1
  454. package/dist/components/viewers/passive-markup.js +1 -1
  455. package/dist/components/viewers/pdf-viewer/pdf-loader.js +1 -1
  456. package/dist/components/viewers/pptx-viewer/pptx-loader.js +1 -1
  457. package/dist/components/viewers/spreadsheet-viewer/spreadsheet-loader.js +1 -1
  458. package/dist/components/viewers/svg-viewer/dompurify-loader.js +1 -1
  459. package/dist/components/viewers/svg-viewer/svg-viewer.class.d.ts +2 -1
  460. package/dist/components/viewers/svg-viewer/svg-viewer.styles.js +1 -1
  461. package/dist/components/viewers/viewer-loading.js +1 -1
  462. package/dist/components/viewers/viewer-search-limits.d.ts +2 -0
  463. package/dist/components/viewers/viewer-search-limits.js +1 -1
  464. package/dist/components/viewers/xml-viewer/xml-viewer.class.d.ts +2 -1
  465. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
  466. package/dist/components/viewers/xml-viewer/xml-viewer.js +1 -1
  467. package/dist/custom-elements-jsx.d.ts +1 -1
  468. package/dist/events.d.ts +13 -6
  469. package/dist/internal/aria-controls.d.ts +16 -13
  470. package/dist/internal/aria-controls.js +1 -1
  471. package/dist/internal/aria-reflection.js +1 -1
  472. package/dist/internal/catalog-picker.d.ts +2 -2
  473. package/dist/internal/catalog-picker.js +1 -1
  474. package/dist/internal/chart-annotation-registration.d.ts +1 -0
  475. package/dist/internal/chart-annotation-registration.js +1 -0
  476. package/dist/internal/data-descriptors.d.ts +13 -0
  477. package/dist/internal/data-descriptors.js +1 -0
  478. package/dist/internal/default-strings.generated.d.ts +1 -1
  479. package/dist/internal/default-strings.generated.js +2 -2
  480. package/dist/internal/dev-mode-attribute-warning.d.ts +3 -0
  481. package/dist/internal/dev-mode-attribute-warning.js +1 -1
  482. package/dist/internal/element-internals.d.ts +4 -3
  483. package/dist/internal/element-internals.js +1 -1
  484. package/dist/internal/form-associated.js +1 -1
  485. package/dist/internal/highlight-collection.d.ts +2 -0
  486. package/dist/internal/highlight-collection.js +1 -1
  487. package/dist/internal/localization-types.d.ts +1 -1
  488. package/dist/internal/localization.js +2 -2
  489. package/dist/internal/lyra-element.d.ts +10 -1
  490. package/dist/internal/lyra-element.js +2 -1
  491. package/dist/internal/native-control-description.d.ts +7 -0
  492. package/dist/internal/native-control-description.js +1 -0
  493. package/dist/internal/option-selection.js +1 -1
  494. package/dist/internal/overlay-order.d.ts +6 -0
  495. package/dist/internal/overlay-order.js +1 -0
  496. package/dist/internal/overlay-stack.d.ts +1 -1
  497. package/dist/internal/overlay-stack.js +1 -1
  498. package/dist/internal/package-metadata.d.ts +1 -1
  499. package/dist/internal/package-metadata.js +1 -1
  500. package/dist/internal/papaparse-loader.js +1 -1
  501. package/dist/internal/positioner.d.ts +5 -4
  502. package/dist/internal/pseudo-localization.js +1 -1
  503. package/dist/internal/reactive-property-writes.d.ts +1 -0
  504. package/dist/internal/reactive-property-writes.js +1 -0
  505. package/dist/internal/safe-css.js +1 -1
  506. package/dist/internal/step-value.d.ts +6 -0
  507. package/dist/internal/step-value.js +1 -0
  508. package/dist/internal/svg-title.d.ts +3 -0
  509. package/dist/internal/svg-title.js +1 -0
  510. package/dist/internal/text-quote.js +1 -1
  511. package/dist/lyra.d.ts +1 -1
  512. package/dist/svelte.d.ts +1 -1
  513. package/dist/translations/ar.js +2 -2
  514. package/dist/translations/de.js +2 -2
  515. package/dist/translations/es.js +2 -2
  516. package/dist/translations/fa.js +2 -2
  517. package/dist/translations/fr.js +2 -2
  518. package/dist/translations/he.js +2 -2
  519. package/dist/translations/ja.js +2 -2
  520. package/dist/translations/pseudo/ar-XB.js +1 -1
  521. package/dist/translations/pt-BR.js +2 -2
  522. package/dist/translations/ru.js +2 -2
  523. package/dist/translations/zh-CN.js +2 -2
  524. package/dist/vue.d.ts +1 -1
  525. package/llms/components/lr-accordion-item.md +10 -5
  526. package/llms/components/lr-accordion.md +10 -5
  527. package/llms/components/lr-activity-feed.md +6 -5
  528. package/llms/components/lr-agent-run.md +1 -1
  529. package/llms/components/lr-agent-trace.md +3 -0
  530. package/llms/components/lr-agent-workspace.md +3 -2
  531. package/llms/components/lr-animation.md +4 -0
  532. package/llms/components/lr-app-rail-item.md +4 -2
  533. package/llms/components/lr-app-rail.md +4 -2
  534. package/llms/components/lr-attachment-chip.md +8 -3
  535. package/llms/components/lr-audio-visualizer.md +9 -6
  536. package/llms/components/lr-av-player.md +14 -0
  537. package/llms/components/lr-avatar.md +4 -0
  538. package/llms/components/lr-bar-chart.md +2 -2
  539. package/llms/components/lr-box-plot.md +15 -6
  540. package/llms/components/lr-bubble-chart.md +2 -2
  541. package/llms/components/lr-button.md +11 -3
  542. package/llms/components/lr-calendar-viewer.md +4 -0
  543. package/llms/components/lr-calendar.md +15 -4
  544. package/llms/components/lr-carousel.md +5 -0
  545. package/llms/components/lr-chart.md +24 -9
  546. package/llms/components/lr-chat-composer.md +2 -1
  547. package/llms/components/lr-chat-message.md +4 -0
  548. package/llms/components/lr-checkbox.md +3 -0
  549. package/llms/components/lr-chip-group.md +3 -0
  550. package/llms/components/lr-chip.md +3 -0
  551. package/llms/components/lr-chunk-inspector.md +2 -2
  552. package/llms/components/lr-code-block-core.md +20 -8
  553. package/llms/components/lr-code-block.md +17 -14
  554. package/llms/components/lr-code-editor.md +20 -5
  555. package/llms/components/lr-color-picker.md +9 -0
  556. package/llms/components/lr-combobox.md +35 -4
  557. package/llms/components/lr-command-palette.md +4 -0
  558. package/llms/components/lr-commit-card.md +3 -0
  559. package/llms/components/lr-compare-panel.md +7 -0
  560. package/llms/components/lr-condition-builder.md +5 -0
  561. package/llms/components/lr-conversation-item.md +3 -0
  562. package/llms/components/lr-copy-button.md +10 -1
  563. package/llms/components/lr-dashboard-grid.md +5 -0
  564. package/llms/components/lr-data-grid.md +22 -3
  565. package/llms/components/lr-dataset-viewer.md +3 -2
  566. package/llms/components/lr-date-input.md +50 -6
  567. package/llms/components/lr-date-picker.md +51 -7
  568. package/llms/components/lr-details.md +10 -5
  569. package/llms/components/lr-dialog.md +4 -0
  570. package/llms/components/lr-diff-view.md +6 -0
  571. package/llms/components/lr-document-compare.md +6 -2
  572. package/llms/components/lr-document-library.md +4 -0
  573. package/llms/components/lr-document-preview.md +18 -4
  574. package/llms/components/lr-document-viewer.md +14 -4
  575. package/llms/components/lr-docx-viewer.md +6 -0
  576. package/llms/components/lr-doughnut-chart.md +2 -2
  577. package/llms/components/lr-dropdown-item.md +4 -0
  578. package/llms/components/lr-dropdown.md +3 -0
  579. package/llms/components/lr-ebook-viewer.md +12 -3
  580. package/llms/components/lr-email-viewer.md +10 -0
  581. package/llms/components/lr-emoji-picker.md +17 -3
  582. package/llms/components/lr-empty.md +3 -0
  583. package/llms/components/lr-entity-card.md +3 -0
  584. package/llms/components/lr-entity-chip.md +4 -0
  585. package/llms/components/lr-eval-dataset.md +2 -2
  586. package/llms/components/lr-export-button.md +9 -0
  587. package/llms/components/lr-file-input.md +12 -8
  588. package/llms/components/lr-file-tree.md +5 -1
  589. package/llms/components/lr-filter-bar.md +5 -0
  590. package/llms/components/lr-flow-canvas.md +8 -1
  591. package/llms/components/lr-flow-node.md +2 -1
  592. package/llms/components/lr-flow-run-status.md +1 -1
  593. package/llms/components/lr-format-date.md +3 -1
  594. package/llms/components/lr-format-number.md +4 -0
  595. package/llms/components/lr-funnel.md +4 -0
  596. package/llms/components/lr-gauge.md +4 -0
  597. package/llms/components/lr-generation-metrics.md +5 -0
  598. package/llms/components/lr-graph-legend.md +4 -2
  599. package/llms/components/lr-graph-query-builder.md +6 -0
  600. package/llms/components/lr-graph.md +8 -2
  601. package/llms/components/lr-grounding-summary.md +8 -8
  602. package/llms/components/lr-heatmap.md +13 -0
  603. package/llms/components/lr-histogram.md +2 -2
  604. package/llms/components/lr-icon-button.md +7 -0
  605. package/llms/components/lr-image-viewer.md +9 -0
  606. package/llms/components/lr-include.md +5 -0
  607. package/llms/components/lr-ingestion-queue.md +5 -1
  608. package/llms/components/lr-input.md +22 -8
  609. package/llms/components/lr-intersection-observer.md +9 -0
  610. package/llms/components/lr-json-viewer.md +10 -1
  611. package/llms/components/lr-kbd.md +3 -0
  612. package/llms/components/lr-knowledge-base.md +10 -1
  613. package/llms/components/lr-knowledge-graph-explorer.md +7 -0
  614. package/llms/components/lr-known-date.md +7 -0
  615. package/llms/components/lr-line-chart.md +2 -2
  616. package/llms/components/lr-lite-chart.md +29 -9
  617. package/llms/components/lr-live-region.md +3 -0
  618. package/llms/components/lr-locale-picker.md +12 -0
  619. package/llms/components/lr-map.md +23 -5
  620. package/llms/components/lr-markdown-core.md +4 -0
  621. package/llms/components/lr-markdown.md +15 -8
  622. package/llms/components/lr-media-card.md +5 -8
  623. package/llms/components/lr-mention-popover.md +17 -10
  624. package/llms/components/lr-menu-item.md +4 -0
  625. package/llms/components/lr-menu-label.md +4 -3
  626. package/llms/components/lr-menu.md +4 -0
  627. package/llms/components/lr-message-actions.md +13 -3
  628. package/llms/components/lr-message-feedback.md +24 -7
  629. package/llms/components/lr-message-parts.md +6 -3
  630. package/llms/components/lr-model-select.md +13 -2
  631. package/llms/components/lr-multi-split.md +20 -7
  632. package/llms/components/lr-mutation-observer.md +8 -0
  633. package/llms/components/lr-native-time-input.md +10 -0
  634. package/llms/components/lr-node-palette.md +8 -2
  635. package/llms/components/lr-notebook-viewer.md +4 -1
  636. package/llms/components/lr-number-input.md +12 -1
  637. package/llms/components/lr-option.md +35 -4
  638. package/llms/components/lr-otp-input.md +10 -0
  639. package/llms/components/lr-pan-zoom.md +1 -2
  640. package/llms/components/lr-phone-input.md +20 -5
  641. package/llms/components/lr-pie-chart.md +2 -2
  642. package/llms/components/lr-polar-area-chart.md +2 -2
  643. package/llms/components/lr-poll-status.md +4 -0
  644. package/llms/components/lr-popover.md +3 -0
  645. package/llms/components/lr-popup.md +3 -2
  646. package/llms/components/lr-prompt-input.md +7 -3
  647. package/llms/components/lr-prompt-queue.md +6 -0
  648. package/llms/components/lr-prompt-studio.md +7 -0
  649. package/llms/components/lr-provenance-panel.md +3 -0
  650. package/llms/components/lr-push-to-talk.md +8 -0
  651. package/llms/components/lr-qr-code.md +6 -0
  652. package/llms/components/lr-radar-chart.md +2 -2
  653. package/llms/components/lr-radio-button.md +13 -4
  654. package/llms/components/lr-radio-group.md +5 -0
  655. package/llms/components/lr-radio.md +9 -0
  656. package/llms/components/lr-rating.md +8 -0
  657. package/llms/components/lr-relative-time.md +2 -0
  658. package/llms/components/lr-reorder-item.md +6 -0
  659. package/llms/components/lr-reorder-list.md +6 -0
  660. package/llms/components/lr-result-card.md +6 -3
  661. package/llms/components/lr-result-field.md +6 -3
  662. package/llms/components/lr-retrieval-results.md +1 -1
  663. package/llms/components/lr-rubric-form.md +12 -0
  664. package/llms/components/lr-scatter-chart.md +2 -2
  665. package/llms/components/lr-scroller.md +5 -5
  666. package/llms/components/lr-select.md +9 -0
  667. package/llms/components/lr-sequence-playback.md +5 -2
  668. package/llms/components/lr-slider.md +19 -5
  669. package/llms/components/lr-source-picker.md +4 -0
  670. package/llms/components/lr-span-waterfall.md +3 -0
  671. package/llms/components/lr-sparkline.md +4 -0
  672. package/llms/components/lr-split-panel.md +4 -0
  673. package/llms/components/lr-stack-trace.md +3 -0
  674. package/llms/components/lr-stat.md +10 -0
  675. package/llms/components/lr-streaming-text.md +2 -3
  676. package/llms/components/lr-subagent-panel.md +3 -2
  677. package/llms/components/lr-svg-viewer.md +3 -0
  678. package/llms/components/lr-swatch-picker.md +4 -0
  679. package/llms/components/lr-switch.md +6 -0
  680. package/llms/components/lr-tab-group.md +4 -0
  681. package/llms/components/lr-table.md +10 -2
  682. package/llms/components/lr-terminal.md +17 -5
  683. package/llms/components/lr-textarea.md +9 -0
  684. package/llms/components/lr-thinking-panel.md +3 -1
  685. package/llms/components/lr-thread-list.md +26 -4
  686. package/llms/components/lr-time-input.md +3 -0
  687. package/llms/components/lr-time-range.md +5 -0
  688. package/llms/components/lr-timeline-item.md +6 -0
  689. package/llms/components/lr-timeline.md +6 -0
  690. package/llms/components/lr-token-input.md +14 -0
  691. package/llms/components/lr-tool-call-chip.md +7 -5
  692. package/llms/components/lr-tool-param-form.md +6 -2
  693. package/llms/components/lr-tool-result-dialog.md +4 -0
  694. package/llms/components/lr-tool-result-view.md +2 -3
  695. package/llms/components/lr-tool-select-dialog.md +6 -2
  696. package/llms/components/lr-tooltip.md +6 -0
  697. package/llms/components/lr-trace-tree.md +3 -0
  698. package/llms/components/lr-transcript-feed.md +3 -0
  699. package/llms/components/lr-tree-item.md +12 -5
  700. package/llms/components/lr-tree.md +12 -5
  701. package/llms/components/lr-typing-indicator.md +3 -0
  702. package/llms/components/lr-usage-badge.md +4 -0
  703. package/llms/components/lr-video.md +8 -2
  704. package/llms/components/lr-virtual-list.md +5 -3
  705. package/llms/components/lr-voice-picker.md +15 -2
  706. package/llms/components/lr-widget-renderer.md +21 -13
  707. package/llms/components/lr-widget.md +4 -2
  708. package/llms/components/lr-word-cloud.md +4 -0
  709. package/llms/components/lr-xml-viewer.md +9 -2
  710. package/llms/components/lr-zoomable-frame.md +6 -3
  711. package/llms/peers.md +5 -5
  712. package/llms/shared.md +74 -63
  713. package/llms-full.txt +4705 -2954
  714. package/package.json +19 -14
  715. package/vscode-css-data.json +1 -1
  716. package/vscode-html-data.json +1 -1
  717. package/web-types.json +1 -1
  718. package/dist/components/viewers/docx-viewer/fixtures/minimal-docx-fixture.d.ts +0 -1
  719. package/dist/components/viewers/docx-viewer/fixtures/minimal-docx-fixture.js +0 -1
  720. package/dist/components/viewers/ebook-viewer/fixtures/minimal-epub-fixture.d.ts +0 -1
  721. package/dist/components/viewers/ebook-viewer/fixtures/minimal-epub-fixture.js +0 -1
  722. package/dist/components/viewers/spreadsheet-viewer/fixtures/minimal-xlsx-fixture.d.ts +0 -1
  723. package/dist/components/viewers/spreadsheet-viewer/fixtures/minimal-xlsx-fixture.js +0 -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,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;const seenIds=new Set,identityFilteredCollections=new Set,jobs=[],rootScanLength=Math.min(rootLength,TREE_MAX_RENDER_NODES);rootLength>rootScanLength&&(truncated=!0);for(let index=rootScanLength-1;index>=0;index--)jobs.push({source:ownValue(input,String(index)),target:root,parentPath:"",depth:0,ancestors:new Set});for(;jobs.length>0;){if(accepted>=TREE_MAX_RENDER_NODES){truncated=!0;break}const job=jobs.pop(),raw=job.source;if(!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);for(let index=childCount-1;index>=0;index--)jobs.push({source:ownValue(rawChildren,String(index)),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.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`
2
2
  <div
3
3
  part="base tree"
4
4
  role="tree"
@@ -22,7 +22,8 @@ export type WordCloudScale='linear'|'sqrt';
22
22
  /** Rotation mode for placed words. `mixed` lets some render rotated 90° for denser packing. */
23
23
  export type WordCloudRotation='none'|'mixed';export interface WordCloudLayoutOptions{readonly minFontSize:number;readonly maxFontSize:number;
24
24
  /** Optional weight-domain endpoints. A valid pair pins the input scale instead of deriving it
25
- * from this cloud's own lightest/heaviest eligible words. */
25
+ * from this cloud's own lightest/heaviest eligible words. Opposite-sign finite endpoints
26
+ * retain bounded fractions even when their subtraction would overflow. */
26
27
  readonly domain?:readonly[number,number];readonly scale:WordCloudScale;readonly wordRotation:WordCloudRotation;
27
28
  /** Measures the rendered width of `text` set at `fontSize`, e.g. via a canvas 2D
28
29
  * context — the font string passed to the context must match the actual
@@ -1 +1 @@
1
- const MAX_WORDS=150,MAX_SKIPPED_DIAGNOSTICS=32,MAX_FONT_SIZE_PX=512,MAX_SPIRAL_ITERATIONS=4096,GAP=3,ROTATE_PROBABILITY=.25,ANGLE_STEP=.15,RADIUS_STEP_PER_RADIAN=3,MAX_RADIUS_AREA_FACTOR=6,MIN_SANE_FONT_SIZE=1;function resolveFontSizeBounds(minFontSize,maxFontSize){const min=Number.isFinite(minFontSize)&&minFontSize>0?Math.min(minFontSize,512):1,max=Number.isFinite(maxFontSize)&&maxFontSize>0?Math.min(maxFontSize,512):1;return min<=max?[min,max]:[max,min]}function effectiveWeight(weight){return Number.isFinite(weight)?Math.max(0,weight):0}function isWorse(a,b){const aw=effectiveWeight(a.weight),bw=effectiveWeight(b.weight);return aw<bw||aw===bw&&a.originalIndex>b.originalIndex}function heapPushWorstFirst(heap,value){heap.push(value);let index=heap.length-1;for(;index>0;){const parent=Math.floor((index-1)/2);if(!isWorse(heap[index],heap[parent]))break;[heap[index],heap[parent]]=[heap[parent],heap[index]],index=parent}}function heapReplaceWorst(heap,value){const removed=heap[0];heap[0]=value;let index=0;for(;;){const left=index*2+1,right=left+1;let worst=index;if(left<heap.length&&isWorse(heap[left],heap[worst])&&(worst=left),right<heap.length&&isWorse(heap[right],heap[worst])&&(worst=right),worst===index)break;[heap[index],heap[worst]]=[heap[worst],heap[index]],index=worst}return removed}function scaledWeight(weight,minWeight,maxWeight,scale){const span=maxWeight-minWeight||1,t=Math.min(1,Math.max(0,(weight-minWeight)/span));return scale==="sqrt"?Math.sqrt(t):t}function rectsOverlap(ax,ay,aw,ah,bx,by,bw,bh){return Math.abs(ax-bx)<(aw+bw)/2+3&&Math.abs(ay-by)<(ah+bh)/2+3}function layoutWordCloud(words,options){const{scale,wordRotation,measureText}=options,[minFontSize,maxFontSize]=resolveFontSizeBounds(options.minFontSize,options.maxFontSize),random=options.random??Math.random,skipped=[];let skippedCount=0;const recordSkip=word=>{skippedCount++,skipped.length<32&&skipped.push({...word,weight:effectiveWeight(word.weight)})},heap=[];for(let originalIndex=0;originalIndex<words.length;originalIndex++){const word=words[originalIndex];if(word.text.trim().length===0){recordSkip(word);continue}const decorated={...word,weight:effectiveWeight(word.weight),originalIndex};if(heap.length<150){heapPushWorstFirst(heap,decorated);continue}isWorse(heap[0],decorated)?recordSkip(heapReplaceWorst(heap,decorated)):recordSkip(word)}const eligible=heap.sort((a,b)=>effectiveWeight(b.weight)-effectiveWeight(a.weight)||a.originalIndex-b.originalIndex);if(eligible.length===0)return{placed:[],skipped,skippedCount,width:0,height:0};let minWeight=effectiveWeight(eligible[0].weight),maxWeight=minWeight;for(const w of eligible){const ew=effectiveWeight(w.weight);ew<minWeight&&(minWeight=ew),ew>maxWeight&&(maxWeight=ew)}const pinnedDomain=options.domain;if(pinnedDomain){const[first,second]=pinnedDomain;Number.isFinite(first)&&Number.isFinite(second)&&first!==second&&(minWeight=Math.min(first,second),maxWeight=Math.max(first,second))}const placed=[];let totalArea=0;for(const word of eligible){const t=scaledWeight(effectiveWeight(word.weight),minWeight,maxWeight,scale),fontSize=minFontSize+t*(maxFontSize-minFontSize),measuredWidth=Math.max(1,measureText(word.text,fontSize)),measuredHeight=fontSize,rotated=wordRotation==="mixed"&&random()<.25,boxW=rotated?measuredHeight:measuredWidth,boxH=rotated?measuredWidth:measuredHeight;totalArea+=boxW*boxH;const maxRadius=Math.sqrt(totalArea*6)+Math.max(boxW,boxH);let theta=0,radius=0,x=0,y=0,foundSpot=placed.length===0,iterations=0;for(;!foundSpot&&radius<maxRadius&&iterations<4096;){iterations++,x=radius*Math.cos(theta),y=radius*Math.sin(theta);let collides=!1;for(const other of placed){const otherW=other.rotated?other.height:other.width,otherH=other.rotated?other.width:other.height;if(rectsOverlap(x,y,boxW,boxH,other.x,other.y,otherW,otherH)){collides=!0;break}}if(!collides){foundSpot=!0;break}theta+=.15,radius+=3*.15}if(!foundSpot){recordSkip(word);continue}placed.push({...word,x,y,fontSize,rotated,width:measuredWidth,height:measuredHeight})}if(placed.length===0)return{placed,skipped,skippedCount,width:0,height:0};let minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0;for(const p of placed){const w=p.rotated?p.height:p.width,h=p.rotated?p.width:p.height;minX=Math.min(minX,p.x-w/2),maxX=Math.max(maxX,p.x+w/2),minY=Math.min(minY,p.y-h/2),maxY=Math.max(maxY,p.y+h/2)}minX-=3,minY-=3,maxX+=3,maxY+=3;for(const p of placed)p.x-=minX,p.y-=minY;return{placed,skipped,skippedCount,width:maxX-minX,height:maxY-minY}}export{GAP,MAX_FONT_SIZE_PX,MAX_SKIPPED_DIAGNOSTICS,MAX_SPIRAL_ITERATIONS,MAX_WORDS,MIN_SANE_FONT_SIZE,layoutWordCloud};
1
+ import{finiteRatio}from"../../../internal/numbers.js";const MAX_WORDS=150,MAX_SKIPPED_DIAGNOSTICS=32,MAX_FONT_SIZE_PX=512,MAX_SPIRAL_ITERATIONS=4096,GAP=3,ROTATE_PROBABILITY=.25,ANGLE_STEP=.15,RADIUS_STEP_PER_RADIAN=3,MAX_RADIUS_AREA_FACTOR=6,MIN_SANE_FONT_SIZE=1;function resolveFontSizeBounds(minFontSize,maxFontSize){const min=Number.isFinite(minFontSize)&&minFontSize>0?Math.min(minFontSize,MAX_FONT_SIZE_PX):MIN_SANE_FONT_SIZE,max=Number.isFinite(maxFontSize)&&maxFontSize>0?Math.min(maxFontSize,MAX_FONT_SIZE_PX):MIN_SANE_FONT_SIZE;return min<=max?[min,max]:[max,min]}function effectiveWeight(weight){return Number.isFinite(weight)?Math.max(0,weight):0}function isWorse(a,b){const aw=effectiveWeight(a.weight),bw=effectiveWeight(b.weight);return aw<bw||aw===bw&&a.originalIndex>b.originalIndex}function heapPushWorstFirst(heap,value){heap.push(value);let index=heap.length-1;for(;index>0;){const parent=Math.floor((index-1)/2);if(!isWorse(heap[index],heap[parent]))break;[heap[index],heap[parent]]=[heap[parent],heap[index]],index=parent}}function heapReplaceWorst(heap,value){const removed=heap[0];heap[0]=value;let index=0;for(;;){const left=index*2+1,right=left+1;let worst=index;if(left<heap.length&&isWorse(heap[left],heap[worst])&&(worst=left),right<heap.length&&isWorse(heap[right],heap[worst])&&(worst=right),worst===index)break;[heap[index],heap[worst]]=[heap[worst],heap[index]],index=worst}return removed}function scaledWeight(weight,minWeight,maxWeight,scale){const t=finiteRatio(weight,minWeight,maxWeight);return scale==="sqrt"?Math.sqrt(t):t}function rectsOverlap(ax,ay,aw,ah,bx,by,bw,bh){return Math.abs(ax-bx)<(aw+bw)/2+GAP&&Math.abs(ay-by)<(ah+bh)/2+GAP}function layoutWordCloud(words,options){const{scale,wordRotation,measureText}=options,[minFontSize,maxFontSize]=resolveFontSizeBounds(options.minFontSize,options.maxFontSize),random=options.random??Math.random,skipped=[];let skippedCount=0;const recordSkip=word=>{skippedCount++,skipped.length<MAX_SKIPPED_DIAGNOSTICS&&skipped.push({...word,weight:effectiveWeight(word.weight)})},heap=[];for(let originalIndex=0;originalIndex<words.length;originalIndex++){const word=words[originalIndex];if(word.text.trim().length===0){recordSkip(word);continue}const decorated={...word,weight:effectiveWeight(word.weight),originalIndex};if(heap.length<MAX_WORDS){heapPushWorstFirst(heap,decorated);continue}isWorse(heap[0],decorated)?recordSkip(heapReplaceWorst(heap,decorated)):recordSkip(word)}const eligible=heap.sort((a,b)=>effectiveWeight(b.weight)-effectiveWeight(a.weight)||a.originalIndex-b.originalIndex);if(eligible.length===0)return{placed:[],skipped,skippedCount,width:0,height:0};let minWeight=effectiveWeight(eligible[0].weight),maxWeight=minWeight;for(const w of eligible){const ew=effectiveWeight(w.weight);ew<minWeight&&(minWeight=ew),ew>maxWeight&&(maxWeight=ew)}const pinnedDomain=options.domain;if(pinnedDomain){const[first,second]=pinnedDomain;Number.isFinite(first)&&Number.isFinite(second)&&first!==second&&(minWeight=Math.min(first,second),maxWeight=Math.max(first,second))}const placed=[];let totalArea=0;for(const word of eligible){const t=scaledWeight(effectiveWeight(word.weight),minWeight,maxWeight,scale),fontSize=minFontSize+t*(maxFontSize-minFontSize),measuredWidth=Math.max(1,measureText(word.text,fontSize)),measuredHeight=fontSize,rotated=wordRotation==="mixed"&&random()<ROTATE_PROBABILITY,boxW=rotated?measuredHeight:measuredWidth,boxH=rotated?measuredWidth:measuredHeight;totalArea+=boxW*boxH;const maxRadius=Math.sqrt(totalArea*MAX_RADIUS_AREA_FACTOR)+Math.max(boxW,boxH);let theta=0,radius=0,x=0,y=0,foundSpot=placed.length===0,iterations=0;for(;!foundSpot&&radius<maxRadius&&iterations<MAX_SPIRAL_ITERATIONS;){iterations++,x=radius*Math.cos(theta),y=radius*Math.sin(theta);let collides=!1;for(const other of placed){const otherW=other.rotated?other.height:other.width,otherH=other.rotated?other.width:other.height;if(rectsOverlap(x,y,boxW,boxH,other.x,other.y,otherW,otherH)){collides=!0;break}}if(!collides){foundSpot=!0;break}theta+=ANGLE_STEP,radius+=RADIUS_STEP_PER_RADIAN*ANGLE_STEP}if(!foundSpot){recordSkip(word);continue}placed.push({...word,x,y,fontSize,rotated,width:measuredWidth,height:measuredHeight})}if(placed.length===0)return{placed,skipped,skippedCount,width:0,height:0};let minX=1/0,maxX=-1/0,minY=1/0,maxY=-1/0;for(const p of placed){const w=p.rotated?p.height:p.width,h=p.rotated?p.width:p.height;minX=Math.min(minX,p.x-w/2),maxX=Math.max(maxX,p.x+w/2),minY=Math.min(minY,p.y-h/2),maxY=Math.max(maxY,p.y+h/2)}minX-=GAP,minY-=GAP,maxX+=GAP,maxY+=GAP;for(const p of placed)p.x-=minX,p.y-=minY;return{placed,skipped,skippedCount,width:maxX-minX,height:maxY-minY}}export{GAP,MAX_FONT_SIZE_PX,MAX_SKIPPED_DIAGNOSTICS,MAX_SPIRAL_ITERATIONS,MAX_WORDS,MIN_SANE_FONT_SIZE,layoutWordCloud};
@@ -64,7 +64,8 @@ minFontSize:number;
64
64
  maxFontSize:number;
65
65
  /** Pins the weight-to-font-size input domain to `[min, max]`, so separate clouds can share one
66
66
  * scale instead of each deriving it from its own lightest/heaviest word. Reversed endpoints are
67
- * normalized; a degenerate or non-finite pair falls back to the data-derived range. */
67
+ * normalized; a degenerate or non-finite pair falls back to the data-derived range. Scaling
68
+ * stays finite when opposite-sign finite endpoints would overflow on subtraction. */
68
69
  domain?:[number,number];private _scale;
69
70
  /** `sqrt` compresses the weight->font-size mapping so one heavy word doesn't dwarf the rest. */
70
71
  get scale():WordCloudScale;set scale(value:WordCloudScale);
@@ -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{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),console.warn(`<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))}\u2026`}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{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{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),console.warn(`<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`
2
2
  ${entries.length?html`<div
3
3
  part="legend"
4
4
  role="list"
@@ -48,6 +48,8 @@ export type ButtonFormMethod='get'|'post'|'dialog';export interface LyraButtonEv
48
48
  * as a literal string (for an icon-only button with no visible label). Host `aria-describedby`
49
49
  * IDREFs are resolved through `ariaDescribedByElements`; external `aria-labelledby` is not copied
50
50
  * across the shadow boundary.
51
+ * Description targets follow same-ID replacement, removal, reinsertion, reconnection and document
52
+ * adoption, including transitions between the native button and anchor.
51
53
  * Host `aria-haspopup` and `aria-expanded` values are likewise forwarded to the internal semantic
52
54
  * control. When host `aria-controls` names elements in the host's own root, the controls
53
55
  * relationship is resolved onto the internal control through the reflected element-reference API
@@ -183,7 +185,7 @@ export type ButtonFormMethod='get'|'post'|'dialog';export interface LyraButtonEv
183
185
  */
184
186
  export declare class LyraButton extends LyraElement<LyraButtonEventMap>{
185
187
  /** Public WA-compatible intrinsic validator catalog. */
186
- static get validators():LyraFormValidator<LyraButton>[];static styles:import("lit").CSSResultGroup[];static formAssociated:boolean;static properties:{disabled:{type:BooleanConstructor;reflect:boolean;noAccessor:boolean;};name:{reflect:boolean;noAccessor:boolean;converter:import("lit").ComplexAttributeConverter<string,unknown>;};customError:{attribute:string;reflect:boolean;noAccessor:boolean;};};private _fieldsetDisabled;private _disabled;private _name;private _value;private _required;private _variant;private hasSyncedDescribedByElements;private internals;private validityController;
188
+ static get validators():LyraFormValidator<LyraButton>[];static styles:import("lit").CSSResultGroup[];static formAssociated:boolean;static properties:{disabled:{type:BooleanConstructor;reflect:boolean;noAccessor:boolean;};name:{reflect:boolean;noAccessor:boolean;converter:import("lit").ComplexAttributeConverter<string,unknown>;};customError:{attribute:string;reflect:boolean;noAccessor:boolean;};};private _fieldsetDisabled;private _disabled;private _name;private _value;private _required;private _variant;private readonly localDescriptionIds;private externalDescriptionLease?;private internals;private validityController;
187
189
  /** Consumer validity retained while a non-action mode is barred from validation. */
188
190
  private customValidityMessage;private reflectingCustomError;
189
191
  /** Consumer-supplied validation message reflected through `custom-error`.
@@ -372,6 +374,6 @@ private submitAsNamedSubmitter;
372
374
  * `disabled` survives the fieldset re-enabling instead of being permanently overwritten --
373
375
  * mirrors `<lr-checkbox>`'s/`<lr-switch>`'s identical `_fieldsetDisabled` pattern.
374
376
  */
375
- formDisabledCallback(disabled:boolean):void;connectedCallback():void;protected willUpdate(changed:PropertyValues):void;private syncAdornmentSlots;private onStartSlotChange;private onEndSlotChange;private hasIconOnlyDefaultContent;private onDefaultSlotChange;protected updated(changed:PropertyValues):void;private updateValidity;
377
+ formDisabledCallback(disabled:boolean):void;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;private syncAdornmentSlots;private onStartSlotChange;private onEndSlotChange;private hasIconOnlyDefaultContent;private onDefaultSlotChange;protected updated(changed:PropertyValues):void;private updateValidity;
376
378
  /** Disabled/loading controls and a link-rendering button are not form actions. */
377
- private get isValidationBarred();private syncButtonStates;private syncDescribedByElements;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-button':LyraButton;}}
379
+ private get isValidationBarred();private syncButtonStates;private syncDescribedByElements;private releaseExternalDescription;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-button':LyraButton;}}
@@ -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{safeDownloadHref,safeLinkHref}from"../../../internal/safe-url.js";import{syncAriaControlsElements,syncAriaDescribedByElements}from"../../../internal/aria-reflection.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();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.hasSyncedDescribedByElements=!1,this.customValidityMessage="",this.reflectingCustomError=!1,this.accessibleLabel=null,this.triggerHasPopup=null,this.triggerExpanded=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.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.updateValidity(),this.syncButtonStates()}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"));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()===""}updated(changed){super.updated(changed),syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements(),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(){!this.triggerDescribedBy&&!this.hasSyncedDescribedByElements||(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,this.baseEl,this.triggerDescribedBy))}render(){const 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{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();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.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.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()}disconnectedCallback(){this.releaseExternalDescription(),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"));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()===""}updated(changed){super.updated(changed),syncAriaControlsElements(this,this.baseEl,this.triggerControls),this.syncDescribedByElements(),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 content=html`
2
2
  <span
3
3
  part="start prefix"
4
4
  ?hidden=${!(this.hasStartSlot||this.withStart)}
@@ -24,6 +24,9 @@ import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement}from
24
24
  * The internal checkbox role exposes explicit stateful `aria-invalid`: visible error chrome wins
25
25
  * immediately, while intrinsic/custom invalidity is exposed only after user interaction.
26
26
  *
27
+ * Removing `error-text` safely omits the message while preserving native null property readback.
28
+ * Explicit empty text stays empty; later supplied text renders normally.
29
+ *
27
30
  * @customElement lr-checkbox
28
31
  * @slot - Label text, rendered next to the box. Clicking it toggles the
29
32
  * checkbox, the same as clicking a native checkbox's associated `<label>`.
@@ -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,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.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=event=>{this.hasHintSlot=event.target.assignedElements({flatten:!0}).length>0},this.onHelpTextSlotChange=event=>{this.hasHelpTextSlot=event.target.assignedElements({flatten:!0}).length>0},this.onErrorSlotChange=event=>{this.hasErrorSlot=event.target.assignedElements({flatten:!0}).length>0},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)),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()})}refreshNamedSlotState(){const children=this.children;if(!children)return;const elements=Array.from(children);this.hasHintSlot=elements.some(element=>element.getAttribute("slot")==="hint"),this.hasHelpTextSlot=elements.some(element=>element.getAttribute("slot")==="help-text"),this.hasErrorSlot=elements.some(element=>element.getAttribute("slot")==="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(),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(){this.effectiveDisabled||(this.hasInteracted=!0,this.checked=!this.checked,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,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.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=event=>{this.hasHintSlot=event.target.assignedElements({flatten:!0}).length>0},this.onHelpTextSlotChange=event=>{this.hasHelpTextSlot=event.target.assignedElements({flatten:!0}).length>0},this.onErrorSlotChange=event=>{this.hasErrorSlot=event.target.assignedElements({flatten:!0}).length>0},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)),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()})}refreshNamedSlotState(){const children=this.children;if(!children)return;const elements=Array.from(children);this.hasHintSlot=elements.some(element=>element.getAttribute("slot")==="hint"),this.hasHelpTextSlot=elements.some(element=>element.getAttribute("slot")==="help-text"),this.hasErrorSlot=elements.some(element=>element.getAttribute("slot")==="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(),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(){this.effectiveDisabled||(this.hasInteracted=!0,this.checked=!this.checked,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`
30
30
  <div part="form-control">
31
31
  <span class="checkbox-layout" part="row" @click=${this.onClick}>
32
32
  <span
@@ -5,7 +5,10 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from
5
5
  * RTL allocation; options wrap without shrinking their checkbox targets.
6
6
  * Its fieldset owns aggregate `aria-invalid` state and, while required, a localized hidden
7
7
  * requiredness description that composes with existing hint/error relationships without marking
8
- * every child checkbox required.
8
+ * every child checkbox required. A host `aria-describedby` is resolved onto that fieldset before
9
+ * its own hint/error/required descriptions, preserving external guidance across the shadow
10
+ * boundary. Host `aria-labelledby` is deliberately not projected: the native legend supplies the
11
+ * group's visible label relationship.
9
12
  *
10
13
  * @customElement lr-checkbox-group
11
14
  * @slot - `<lr-checkbox>` children.
@@ -80,7 +83,7 @@ withHint:boolean;errorText:string;accessibleLabel:string;private touched;
80
83
  * `render()` reads it. */
81
84
  private hasInteracted;private hasLabelSlot;private hasHintSlot;private hasErrorSlot;private internals;private validityController;
82
85
  /** Consumer-supplied validation message reflected through `custom-error`. */
83
- customError:string|null;private labelId;private hintId;private errorId;private requiredDescriptionId;private requiredDescriptionLease?;private requiredDescriptionTarget?;private _fieldsetDisabled;private _name;private _required;private _disabled;private _value;private _warnedDuplicateValues;private pendingRestoreValues?;
86
+ customError:string|null;private labelId;private hintId;private errorId;private requiredDescriptionId;private externalDescriptionLease?;private requiredDescriptionLease?;private requiredDescriptionTarget?;private _fieldsetDisabled;private _name;private _required;private _disabled;private _value;private pendingRestoreValues?;
84
87
  /** A `value` assignment made before any checkbox child existed; applied on the next slotchange. */
85
88
  private pendingValues?;private childObserver?;private childObserverDocument?;private childObserverGeneration;private childControllers;private authoredChildSizes;
86
89
  /** The form submission key each checked child checkbox's value is grouped under in the group's
@@ -117,6 +120,8 @@ private applyValues;
117
120
  private applyPendingRestore;
118
121
  /** Applies a `value` assignment that arrived before any checkbox child existed. */
119
122
  private applyPendingValues;connectedCallback():void;private armChildObserver;disconnectedCallback():void;adoptedCallback():void;private resetChildObserver;protected firstUpdated(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;
123
+ /** Resolves host-owned descriptions ahead of the fieldset's own form-control descriptions. */
124
+ private syncExternalDescription;private releaseExternalDescription;
120
125
  /** Owns only the aggregate requiredness text; hint and error remain Lit's baseline relationship. */
121
126
  private syncRequiredDescription;private releaseRequiredDescription;get form():HTMLFormElement|null;set form(owner:FormOwnerValue);getForm():HTMLFormElement|null;get labels():NodeList;get validity():ValidityState;get validationMessage():string;get willValidate():boolean;checkValidity():boolean;reportValidity():boolean;
122
127
  /**
@@ -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}from"../../../internal/aria-controls.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{installInvalidEventAlias}from"../../../internal/invalid-event-alias.js";import{LYRA_DEFAULT_checkboxGroupRequired,LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";function warnDuplicateValue(group,value){console.warn(`<lr-checkbox-group> has more than one <lr-checkbox> child with value="${value}"${group.name?` (name="${group.name}")`:""}; every checked one contributes an identical FormData entry, so the submitted data cannot say which was checked. 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.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){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._warnedDuplicateValues=new Set,this.childObserverGeneration=0,this.childControllers=new Map,this.authoredChildSizes=new Map,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.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))}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}this._warnedDuplicateValues.has(value)||(this._warnedDuplicateValues.add(value),warnDuplicateValue(this,value))}}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)}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.onSlotChange(),this.armChildObserver(),this.hasUpdated&&this.syncRequiredDescription()}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.releaseRequiredDescription(),this.removeEventListener("input",this.onChildEvent,{capture:!0}),this.removeEventListener("change",this.onChildEvent,{capture:!0}),this.removeEventListener("lr-change",this.onChildEvent,{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.resetChildObserver()}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()}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 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{installInvalidEventAlias}from"../../../internal/invalid-event-alias.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.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){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.authoredChildSizes=new Map,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.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))}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)}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.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.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 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
2
2
  part="form-control"
3
3
  ?disabled=${this.effectiveDisabled}
4
4
  aria-label=${hostAriaLabel(this)??nothing}