@aceshooting/lyra-ui 14.0.0 → 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 (475) hide show
  1. package/CHANGELOG.md +149 -19
  2. package/custom-elements.json +1 -1
  3. package/dist/components/agent-tools/commit-card/commit-card.class.d.ts +3 -1
  4. package/dist/components/agent-tools/commit-card/commit-card.class.js +2 -2
  5. package/dist/components/agent-tools/compare-panel/compare-panel.class.d.ts +2 -1
  6. package/dist/components/agent-tools/compare-panel/compare-panel.styles.js +1 -1
  7. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.d.ts +6 -2
  8. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.js +4 -4
  9. package/dist/components/agent-tools/result-card/result-card.class.d.ts +1 -1
  10. package/dist/components/agent-tools/result-card/result-card.class.js +1 -1
  11. package/dist/components/agent-tools/result-card/result-field.class.d.ts +1 -1
  12. package/dist/components/agent-tools/result-card/result-field.class.js +1 -1
  13. package/dist/components/agent-tools/stack-trace/stack-trace.class.d.ts +1 -1
  14. package/dist/components/agent-tools/stack-trace/stack-trace.class.js +1 -1
  15. package/dist/components/agent-tools/terminal/terminal.class.d.ts +1 -1
  16. package/dist/components/agent-tools/terminal/terminal.class.js +2 -2
  17. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +2 -2
  18. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +1 -1
  19. package/dist/components/agent-tools/tool-param-form/tool-param-form.class.js +1 -1
  20. package/dist/components/agent-tools/tool-result-dialog/tool-result-dialog.class.js +2 -2
  21. package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +4 -4
  22. package/dist/components/agent-tools/trace-tree/span.d.ts +3 -1
  23. package/dist/components/agent-tools/trace-tree/span.js +1 -1
  24. package/dist/components/charts/chart/box-plot.class.d.ts +2 -0
  25. package/dist/components/charts/chart/box-plot.class.js +1 -1
  26. package/dist/components/charts/chart/chart.class.d.ts +6 -1
  27. package/dist/components/charts/chart/chart.class.js +1 -1
  28. package/dist/components/charts/chart/lite-chart.class.d.ts +20 -11
  29. package/dist/components/charts/chart/lite-chart.class.js +10 -8
  30. package/dist/components/conversation/chat-message/chat-message.class.d.ts +4 -3
  31. package/dist/components/conversation/code-block/code-block-core.class.d.ts +4 -3
  32. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  33. package/dist/components/conversation/code-block/code-block-shared.d.ts +3 -3
  34. package/dist/components/conversation/code-block/code-block-shared.js +2 -2
  35. package/dist/components/conversation/code-block/code-block.class.d.ts +4 -3
  36. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  37. package/dist/components/conversation/code-block/shiki-types.d.ts +2 -0
  38. package/dist/components/conversation/code-block/shiki-types.js +1 -1
  39. package/dist/components/conversation/conversation-item/conversation-item.class.js +1 -1
  40. package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
  41. package/dist/components/conversation/markdown/markdown-core.class.d.ts +1 -1
  42. package/dist/components/conversation/markdown/markdown.class.d.ts +1 -1
  43. package/dist/components/conversation/message-actions/message-actions.class.d.ts +2 -0
  44. package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
  45. package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +3 -1
  46. package/dist/components/conversation/message-feedback/message-feedback.class.js +2 -2
  47. package/dist/components/conversation/message-parts/message-parts.class.d.ts +3 -0
  48. package/dist/components/conversation/model-select/model-select.class.js +3 -3
  49. package/dist/components/conversation/thread-list/thread-list.class.js +1 -1
  50. package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +2 -0
  51. package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
  52. package/dist/components/conversation/typing-indicator/typing-indicator.class.d.ts +2 -1
  53. package/dist/components/conversation/typing-indicator/typing-indicator.class.js +1 -1
  54. package/dist/components/conversation/usage-badge/usage-badge-overlay-runtime.d.ts +3 -0
  55. package/dist/components/conversation/usage-badge/usage-badge-overlay-runtime.js +1 -0
  56. package/dist/components/conversation/usage-badge/usage-badge.class.d.ts +4 -2
  57. package/dist/components/conversation/usage-badge/usage-badge.class.js +1 -1
  58. package/dist/components/conversation/voice-picker/voice-picker.class.js +3 -3
  59. package/dist/components/conversation/widget-renderer/resolve.d.ts +4 -6
  60. package/dist/components/conversation/widget-renderer/resolve.js +1 -1
  61. package/dist/components/data/calendar/calendar.class.d.ts +6 -3
  62. package/dist/components/data/calendar/calendar.class.js +1 -1
  63. package/dist/components/data/calendar/calendar.styles.js +1 -1
  64. package/dist/components/data/condition-builder/condition-builder.class.d.ts +3 -1
  65. package/dist/components/data/condition-builder/condition-builder.class.js +15 -1
  66. package/dist/components/data/context-meter/context-meter.class.js +2 -2
  67. package/dist/components/data/data-grid/data-grid.class.d.ts +6 -2
  68. package/dist/components/data/data-grid/data-grid.class.js +1 -1
  69. package/dist/components/data/document-library/document-library.class.d.ts +5 -2
  70. package/dist/components/data/document-library/document-library.class.js +1 -1
  71. package/dist/components/data/file-tree/file-tree.class.d.ts +2 -1
  72. package/dist/components/data/file-tree/file-tree.class.js +1 -1
  73. package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +5 -2
  74. package/dist/components/data/flow-canvas/flow-canvas.styles.js +1 -1
  75. package/dist/components/data/flow-canvas/flow-model.js +1 -1
  76. package/dist/components/data/flow-canvas/flow-types.d.ts +2 -1
  77. package/dist/components/data/funnel/funnel.class.d.ts +1 -0
  78. package/dist/components/data/funnel/funnel.class.js +1 -1
  79. package/dist/components/data/gauge/gauge.class.d.ts +4 -1
  80. package/dist/components/data/gauge/gauge.class.js +6 -6
  81. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +5 -2
  82. package/dist/components/data/graph-query-builder/graph-query-builder.class.js +15 -1
  83. package/dist/components/data/heatmap/heatmap.class.d.ts +7 -4
  84. package/dist/components/data/heatmap/heatmap.class.js +1 -1
  85. package/dist/components/data/sparkline/sparkline.class.d.ts +2 -1
  86. package/dist/components/data/sparkline/sparkline.class.js +1 -1
  87. package/dist/components/data/stat/stat.class.d.ts +6 -2
  88. package/dist/components/data/stat/stat.class.js +1 -1
  89. package/dist/components/data/table/table.class.d.ts +5 -2
  90. package/dist/components/data/table/table.class.js +2 -2
  91. package/dist/components/data/timeline/timeline.class.d.ts +7 -2
  92. package/dist/components/data/timeline/timeline.class.js +1 -1
  93. package/dist/components/data/timeline/timeline.styles.js +1 -1
  94. package/dist/components/data/tree/tree-item.class.d.ts +3 -1
  95. package/dist/components/data/tree/tree-item.class.js +1 -1
  96. package/dist/components/data/tree/tree.class.d.ts +4 -1
  97. package/dist/components/data/tree/tree.class.js +1 -1
  98. package/dist/components/data/word-cloud/word-cloud-layout.d.ts +2 -1
  99. package/dist/components/data/word-cloud/word-cloud-layout.js +1 -1
  100. package/dist/components/data/word-cloud/word-cloud.class.d.ts +2 -1
  101. package/dist/components/forms/button/button.class.d.ts +5 -3
  102. package/dist/components/forms/button/button.class.js +1 -1
  103. package/dist/components/forms/checkbox/checkbox.class.d.ts +3 -0
  104. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  105. package/dist/components/forms/code-editor/code-editor.class.d.ts +11 -3
  106. package/dist/components/forms/code-editor/code-editor.class.js +6 -7
  107. package/dist/components/forms/code-editor/code-editor.styles.js +1 -1
  108. package/dist/components/forms/color-picker/color-picker.class.d.ts +5 -1
  109. package/dist/components/forms/color-picker/color-picker.class.js +4 -4
  110. package/dist/components/forms/combobox/combobox.class.d.ts +19 -8
  111. package/dist/components/forms/combobox/combobox.class.js +3 -3
  112. package/dist/components/forms/combobox/option.class.d.ts +4 -0
  113. package/dist/components/forms/combobox/option.class.js +2 -2
  114. package/dist/components/forms/date-picker/calendar-core.d.ts +1 -1
  115. package/dist/components/forms/date-picker/calendar-core.js +1 -1
  116. package/dist/components/forms/date-picker/date-input.class.d.ts +20 -10
  117. package/dist/components/forms/date-picker/date-input.class.js +4 -4
  118. package/dist/components/forms/date-picker/date-picker.class.d.ts +24 -13
  119. package/dist/components/forms/date-picker/date-picker.class.js +7 -7
  120. package/dist/components/forms/date-picker/date-picker.styles.js +1 -1
  121. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +11 -3
  122. package/dist/components/forms/emoji-picker/emoji-picker.class.js +3 -3
  123. package/dist/components/forms/emoji-picker/emoji-types.d.ts +2 -2
  124. package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -2
  125. package/dist/components/forms/icon-button/icon-button.class.js +1 -1
  126. package/dist/components/forms/input/input.class.d.ts +5 -1
  127. package/dist/components/forms/input/input.class.js +1 -1
  128. package/dist/components/forms/input/native-time-input.class.d.ts +3 -0
  129. package/dist/components/forms/input/number-input.class.d.ts +3 -0
  130. package/dist/components/forms/input/time-input.class.d.ts +3 -0
  131. package/dist/components/forms/input/time-input.class.js +1 -1
  132. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +5 -1
  133. package/dist/components/forms/locale-picker/locale-picker.class.js +2 -2
  134. package/dist/components/forms/otp-input/otp-input.class.d.ts +5 -1
  135. package/dist/components/forms/otp-input/otp-input.class.js +1 -1
  136. package/dist/components/forms/phone-input/phone-input.class.d.ts +21 -8
  137. package/dist/components/forms/phone-input/phone-input.class.js +1 -1
  138. package/dist/components/forms/radio/radio-button.class.d.ts +4 -0
  139. package/dist/components/forms/radio/radio-group.class.d.ts +4 -1
  140. package/dist/components/forms/radio/radio-group.class.js +1 -1
  141. package/dist/components/forms/radio/radio.class.d.ts +6 -2
  142. package/dist/components/forms/radio/radio.class.js +1 -1
  143. package/dist/components/forms/rubric-form/rubric-form.class.d.ts +7 -1
  144. package/dist/components/forms/rubric-form/rubric-form.class.js +3 -3
  145. package/dist/components/forms/select/select.class.d.ts +8 -2
  146. package/dist/components/forms/select/select.class.js +2 -2
  147. package/dist/components/forms/slider/slider.class.d.ts +12 -6
  148. package/dist/components/forms/slider/slider.class.js +2 -2
  149. package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +4 -0
  150. package/dist/components/forms/swatch-picker/swatch-picker.class.js +1 -1
  151. package/dist/components/forms/switch/switch.class.d.ts +5 -1
  152. package/dist/components/forms/switch/switch.class.js +1 -1
  153. package/dist/components/forms/textarea/textarea.class.d.ts +3 -0
  154. package/dist/components/forms/textarea/textarea.class.js +1 -1
  155. package/dist/components/forms/time-range/time-range.class.d.ts +3 -0
  156. package/dist/components/forms/time-range/time-range.class.js +1 -1
  157. package/dist/components/forms/token-input/token-input.class.d.ts +8 -2
  158. package/dist/components/forms/token-input/token-input.class.js +2 -2
  159. package/dist/components/forms/token-input/token-input.styles.js +1 -1
  160. package/dist/components/layout/app-rail/app-rail.class.d.ts +3 -1
  161. package/dist/components/layout/app-rail/app-rail.class.js +1 -1
  162. package/dist/components/layout/carousel/carousel.class.d.ts +3 -2
  163. package/dist/components/layout/carousel/carousel.class.js +1 -1
  164. package/dist/components/layout/command-palette/command-palette.class.js +1 -1
  165. package/dist/components/layout/dashboard-grid/dashboard-grid.class.d.ts +2 -0
  166. package/dist/components/layout/dashboard-grid/dashboard-grid.class.js +1 -1
  167. package/dist/components/layout/details/details.class.d.ts +3 -3
  168. package/dist/components/layout/filter-bar/filter-bar.class.d.ts +3 -1
  169. package/dist/components/layout/filter-bar/filter-bar.class.js +1 -1
  170. package/dist/components/layout/menu/menu-label.class.d.ts +3 -3
  171. package/dist/components/layout/menu/menu.class.d.ts +4 -1
  172. package/dist/components/layout/menu/menu.class.js +1 -1
  173. package/dist/components/layout/multi-split/multi-split.class.d.ts +9 -3
  174. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  175. package/dist/components/layout/multi-split/multi-split.styles.js +1 -1
  176. package/dist/components/layout/reorder-list/reorder-item.class.d.ts +2 -1
  177. package/dist/components/layout/reorder-list/reorder-item.class.js +1 -1
  178. package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
  179. package/dist/components/layout/reorder-list/reorder-owner.js +1 -1
  180. package/dist/components/layout/split-panel/split-panel.class.d.ts +2 -1
  181. package/dist/components/layout/split-panel/split-panel.class.js +1 -1
  182. package/dist/components/layout/tab-group/tab-group.class.d.ts +3 -1
  183. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  184. package/dist/components/layout/widget/widget.class.d.ts +6 -2
  185. package/dist/components/layout/widget/widget.class.js +1 -1
  186. package/dist/components/media/animation/animation.class.d.ts +3 -2
  187. package/dist/components/media/animation/animation.class.js +1 -1
  188. package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +4 -3
  189. package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
  190. package/dist/components/media/av-player/av-metadata.d.ts +3 -2
  191. package/dist/components/media/av-player/av-player.class.d.ts +4 -3
  192. package/dist/components/media/av-player/av-player.class.js +3 -3
  193. package/dist/components/media/av-player/av-player.styles.js +1 -1
  194. package/dist/components/media/avatar/avatar.class.d.ts +2 -1
  195. package/dist/components/media/avatar/avatar.class.js +1 -1
  196. package/dist/components/media/file-input/file-input.class.d.ts +4 -2
  197. package/dist/components/media/file-input/file-input.class.js +1 -1
  198. package/dist/components/media/file-input/file-input.styles.js +1 -1
  199. package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -1
  200. package/dist/components/media/image-viewer/image-viewer.class.js +1 -1
  201. package/dist/components/media/image-viewer/image-viewer.styles.js +1 -1
  202. package/dist/components/media/map/map.class.d.ts +5 -3
  203. package/dist/components/media/map/map.class.js +1 -1
  204. package/dist/components/media/map/map.styles.js +1 -1
  205. package/dist/components/media/media-card/media-card.class.d.ts +1 -1
  206. package/dist/components/media/media-card/media-card.class.js +1 -1
  207. package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
  208. package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +1 -1
  209. package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
  210. package/dist/components/media/video/video.class.d.ts +2 -1
  211. package/dist/components/media/video/video.styles.js +1 -1
  212. package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +3 -2
  213. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
  214. package/dist/components/overlays/chip/chip-group.class.d.ts +2 -0
  215. package/dist/components/overlays/chip/chip-group.class.js +1 -1
  216. package/dist/components/overlays/dialog/dialog.class.d.ts +2 -0
  217. package/dist/components/overlays/dialog/dialog.class.js +1 -1
  218. package/dist/components/overlays/empty/empty.class.d.ts +2 -0
  219. package/dist/components/overlays/empty/empty.class.js +1 -1
  220. package/dist/components/overlays/kbd/kbd.class.d.ts +2 -0
  221. package/dist/components/overlays/kbd/kbd.class.js +1 -1
  222. package/dist/components/overlays/overlay/popover.class.d.ts +3 -1
  223. package/dist/components/overlays/overlay/popover.class.js +1 -1
  224. package/dist/components/overlays/overlay/tooltip.class.d.ts +3 -1
  225. package/dist/components/overlays/overlay/tooltip.class.js +1 -1
  226. package/dist/components/overlays/rating/rating.class.d.ts +2 -0
  227. package/dist/components/overlays/rating/rating.class.js +1 -1
  228. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +2 -2
  229. package/dist/components/retrieval/entity-card/entity-card.class.d.ts +5 -2
  230. package/dist/components/retrieval/entity-card/entity-card.class.js +1 -1
  231. package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +4 -2
  232. package/dist/components/retrieval/entity-chip/entity-chip.class.js +1 -1
  233. package/dist/components/retrieval/graph/graph-canvas.js +1 -1
  234. package/dist/components/retrieval/graph/graph.class.d.ts +9 -7
  235. package/dist/components/retrieval/graph/graph.class.js +1 -1
  236. package/dist/components/retrieval/grounding-summary/grounding-summary.class.d.ts +1 -3
  237. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +2 -0
  238. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +1 -1
  239. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +3 -2
  240. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +7 -3
  241. package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +2 -1
  242. package/dist/components/retrieval/provenance-panel/provenance-panel.class.js +1 -1
  243. package/dist/components/retrieval/source-picker/source-picker.class.d.ts +2 -1
  244. package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
  245. package/dist/components/utility/format/format-number.class.d.ts +3 -1
  246. package/dist/components/utility/format/format-options.js +1 -1
  247. package/dist/components/utility/json-viewer/json-viewer.class.d.ts +3 -2
  248. package/dist/components/utility/json-viewer/json-viewer.class.js +2 -2
  249. package/dist/components/utility/known-date/known-date.class.d.ts +9 -5
  250. package/dist/components/utility/known-date/known-date.class.js +2 -2
  251. package/dist/components/utility/known-date/known-date.styles.js +1 -1
  252. package/dist/components/utility/mention-popover/mention-popover.class.d.ts +3 -1
  253. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  254. package/dist/components/utility/poll-status/poll-status.class.d.ts +3 -0
  255. package/dist/components/utility/poll-status/poll-status.styles.js +1 -1
  256. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.d.ts +1 -0
  257. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
  258. package/dist/components/viewers/dataset-viewer/dataset-viewer.class.d.ts +2 -1
  259. package/dist/components/viewers/dataset-viewer/dataset-viewer.styles.js +1 -1
  260. package/dist/components/viewers/document-preview/document-preview.class.d.ts +4 -2
  261. package/dist/components/viewers/document-preview/document-preview.class.js +1 -1
  262. package/dist/components/viewers/document-preview/document-preview.styles.js +1 -1
  263. package/dist/components/viewers/document-viewer/document-viewer.class.d.ts +3 -2
  264. package/dist/components/viewers/document-viewer/document-viewer.class.js +2 -2
  265. package/dist/components/viewers/document-viewer/registry-ownership.d.ts +1 -0
  266. package/dist/components/viewers/document-viewer/registry-ownership.js +1 -0
  267. package/dist/components/viewers/document-viewer/registry.js +1 -1
  268. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.d.ts +7 -1
  269. package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
  270. package/dist/components/viewers/email-viewer/email-viewer.class.d.ts +2 -1
  271. package/dist/components/viewers/email-viewer/email-viewer.class.js +2 -2
  272. package/dist/components/viewers/include/include-resource.js +1 -1
  273. package/dist/components/viewers/include/include.class.d.ts +3 -1
  274. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.d.ts +4 -2
  275. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +4 -4
  276. package/dist/components/viewers/notebook-viewer/notebook-viewer.styles.js +1 -1
  277. package/dist/components/viewers/passive-markup.js +1 -1
  278. package/dist/components/viewers/svg-viewer/svg-viewer.class.d.ts +2 -1
  279. package/dist/components/viewers/svg-viewer/svg-viewer.styles.js +1 -1
  280. package/dist/components/viewers/xml-viewer/xml-viewer.class.d.ts +2 -1
  281. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
  282. package/dist/components/viewers/xml-viewer/xml-viewer.js +1 -1
  283. package/dist/custom-elements-jsx.d.ts +1 -1
  284. package/dist/internal/aria-reflection.js +1 -1
  285. package/dist/internal/catalog-picker.js +1 -1
  286. package/dist/internal/default-strings.generated.d.ts +1 -1
  287. package/dist/internal/default-strings.generated.js +1 -1
  288. package/dist/internal/dev-mode-attribute-warning.d.ts +3 -0
  289. package/dist/internal/dev-mode-attribute-warning.js +1 -1
  290. package/dist/internal/form-associated.js +1 -1
  291. package/dist/internal/localization-types.d.ts +1 -1
  292. package/dist/internal/localization.js +1 -1
  293. package/dist/internal/lyra-element.js +1 -1
  294. package/dist/internal/native-control-description.d.ts +7 -0
  295. package/dist/internal/native-control-description.js +1 -0
  296. package/dist/internal/option-selection.js +1 -1
  297. package/dist/internal/overlay-order.d.ts +6 -0
  298. package/dist/internal/overlay-order.js +1 -0
  299. package/dist/internal/overlay-stack.d.ts +1 -1
  300. package/dist/internal/overlay-stack.js +1 -1
  301. package/dist/internal/package-metadata.d.ts +1 -1
  302. package/dist/internal/package-metadata.js +1 -1
  303. package/dist/internal/positioner.d.ts +5 -4
  304. package/dist/internal/reactive-property-writes.d.ts +1 -0
  305. package/dist/internal/reactive-property-writes.js +1 -0
  306. package/dist/internal/svg-title.d.ts +3 -0
  307. package/dist/internal/svg-title.js +1 -0
  308. package/dist/svelte.d.ts +1 -1
  309. package/dist/translations/ar.js +1 -1
  310. package/dist/translations/de.js +1 -1
  311. package/dist/translations/es.js +1 -1
  312. package/dist/translations/fa.js +1 -1
  313. package/dist/translations/fr.js +1 -1
  314. package/dist/translations/he.js +1 -1
  315. package/dist/translations/ja.js +1 -1
  316. package/dist/translations/pt-BR.js +1 -1
  317. package/dist/translations/ru.js +1 -1
  318. package/dist/translations/zh-CN.js +1 -1
  319. package/dist/vue.d.ts +1 -1
  320. package/llms/components/lr-accordion-item.md +4 -0
  321. package/llms/components/lr-accordion.md +4 -0
  322. package/llms/components/lr-agent-trace.md +3 -0
  323. package/llms/components/lr-animation.md +4 -0
  324. package/llms/components/lr-app-rail-item.md +4 -2
  325. package/llms/components/lr-app-rail.md +4 -2
  326. package/llms/components/lr-attachment-chip.md +6 -0
  327. package/llms/components/lr-av-player.md +14 -0
  328. package/llms/components/lr-avatar.md +4 -0
  329. package/llms/components/lr-box-plot.md +6 -0
  330. package/llms/components/lr-button.md +11 -3
  331. package/llms/components/lr-calendar-viewer.md +4 -0
  332. package/llms/components/lr-calendar.md +5 -0
  333. package/llms/components/lr-carousel.md +5 -0
  334. package/llms/components/lr-chart.md +13 -4
  335. package/llms/components/lr-chat-message.md +4 -0
  336. package/llms/components/lr-checkbox.md +3 -0
  337. package/llms/components/lr-chip-group.md +3 -0
  338. package/llms/components/lr-chip.md +3 -0
  339. package/llms/components/lr-code-block-core.md +16 -4
  340. package/llms/components/lr-code-block.md +7 -0
  341. package/llms/components/lr-code-editor.md +18 -5
  342. package/llms/components/lr-color-picker.md +9 -0
  343. package/llms/components/lr-combobox.md +35 -4
  344. package/llms/components/lr-command-palette.md +4 -0
  345. package/llms/components/lr-commit-card.md +3 -0
  346. package/llms/components/lr-compare-panel.md +7 -0
  347. package/llms/components/lr-condition-builder.md +5 -0
  348. package/llms/components/lr-conversation-item.md +3 -0
  349. package/llms/components/lr-copy-button.md +6 -0
  350. package/llms/components/lr-dashboard-grid.md +5 -0
  351. package/llms/components/lr-data-grid.md +11 -1
  352. package/llms/components/lr-dataset-viewer.md +3 -2
  353. package/llms/components/lr-date-input.md +46 -6
  354. package/llms/components/lr-date-picker.md +46 -6
  355. package/llms/components/lr-details.md +4 -0
  356. package/llms/components/lr-dialog.md +4 -0
  357. package/llms/components/lr-document-library.md +4 -0
  358. package/llms/components/lr-document-preview.md +7 -1
  359. package/llms/components/lr-document-viewer.md +9 -3
  360. package/llms/components/lr-dropdown-item.md +4 -0
  361. package/llms/components/lr-dropdown.md +3 -0
  362. package/llms/components/lr-ebook-viewer.md +4 -0
  363. package/llms/components/lr-email-viewer.md +5 -0
  364. package/llms/components/lr-emoji-picker.md +17 -3
  365. package/llms/components/lr-empty.md +3 -0
  366. package/llms/components/lr-entity-card.md +3 -0
  367. package/llms/components/lr-entity-chip.md +4 -0
  368. package/llms/components/lr-file-input.md +7 -0
  369. package/llms/components/lr-file-tree.md +5 -1
  370. package/llms/components/lr-filter-bar.md +5 -0
  371. package/llms/components/lr-flow-canvas.md +8 -1
  372. package/llms/components/lr-flow-node.md +2 -1
  373. package/llms/components/lr-flow-run-status.md +1 -1
  374. package/llms/components/lr-format-number.md +4 -0
  375. package/llms/components/lr-funnel.md +4 -0
  376. package/llms/components/lr-gauge.md +4 -0
  377. package/llms/components/lr-generation-metrics.md +5 -0
  378. package/llms/components/lr-graph-query-builder.md +6 -0
  379. package/llms/components/lr-graph.md +8 -2
  380. package/llms/components/lr-heatmap.md +13 -0
  381. package/llms/components/lr-icon-button.md +7 -0
  382. package/llms/components/lr-image-viewer.md +9 -0
  383. package/llms/components/lr-include.md +5 -0
  384. package/llms/components/lr-ingestion-queue.md +4 -0
  385. package/llms/components/lr-input.md +22 -8
  386. package/llms/components/lr-json-viewer.md +4 -0
  387. package/llms/components/lr-kbd.md +3 -0
  388. package/llms/components/lr-knowledge-graph-explorer.md +7 -0
  389. package/llms/components/lr-known-date.md +7 -0
  390. package/llms/components/lr-lite-chart.md +21 -4
  391. package/llms/components/lr-live-region.md +3 -0
  392. package/llms/components/lr-locale-picker.md +6 -0
  393. package/llms/components/lr-map.md +8 -0
  394. package/llms/components/lr-markdown-core.md +4 -0
  395. package/llms/components/lr-markdown.md +8 -4
  396. package/llms/components/lr-media-card.md +5 -2
  397. package/llms/components/lr-mention-popover.md +5 -0
  398. package/llms/components/lr-menu-item.md +4 -0
  399. package/llms/components/lr-menu-label.md +4 -3
  400. package/llms/components/lr-menu.md +4 -0
  401. package/llms/components/lr-message-actions.md +3 -0
  402. package/llms/components/lr-message-feedback.md +4 -0
  403. package/llms/components/lr-message-parts.md +3 -2
  404. package/llms/components/lr-model-select.md +8 -0
  405. package/llms/components/lr-multi-split.md +15 -6
  406. package/llms/components/lr-native-time-input.md +10 -0
  407. package/llms/components/lr-node-palette.md +3 -0
  408. package/llms/components/lr-notebook-viewer.md +4 -1
  409. package/llms/components/lr-number-input.md +12 -1
  410. package/llms/components/lr-option.md +35 -4
  411. package/llms/components/lr-otp-input.md +10 -0
  412. package/llms/components/lr-pan-zoom.md +1 -2
  413. package/llms/components/lr-phone-input.md +20 -5
  414. package/llms/components/lr-poll-status.md +4 -0
  415. package/llms/components/lr-popover.md +3 -0
  416. package/llms/components/lr-popup.md +3 -2
  417. package/llms/components/lr-prompt-studio.md +7 -0
  418. package/llms/components/lr-provenance-panel.md +3 -0
  419. package/llms/components/lr-push-to-talk.md +3 -0
  420. package/llms/components/lr-radio-button.md +13 -4
  421. package/llms/components/lr-radio-group.md +5 -0
  422. package/llms/components/lr-radio.md +9 -0
  423. package/llms/components/lr-rating.md +3 -0
  424. package/llms/components/lr-reorder-item.md +6 -0
  425. package/llms/components/lr-reorder-list.md +6 -0
  426. package/llms/components/lr-result-card.md +3 -0
  427. package/llms/components/lr-result-field.md +3 -0
  428. package/llms/components/lr-rubric-form.md +12 -0
  429. package/llms/components/lr-select.md +9 -0
  430. package/llms/components/lr-sequence-playback.md +4 -0
  431. package/llms/components/lr-slider.md +16 -4
  432. package/llms/components/lr-source-picker.md +4 -0
  433. package/llms/components/lr-span-waterfall.md +3 -0
  434. package/llms/components/lr-sparkline.md +4 -0
  435. package/llms/components/lr-split-panel.md +4 -0
  436. package/llms/components/lr-stack-trace.md +3 -0
  437. package/llms/components/lr-stat.md +10 -0
  438. package/llms/components/lr-subagent-panel.md +3 -2
  439. package/llms/components/lr-svg-viewer.md +3 -0
  440. package/llms/components/lr-swatch-picker.md +4 -0
  441. package/llms/components/lr-switch.md +6 -0
  442. package/llms/components/lr-tab-group.md +4 -0
  443. package/llms/components/lr-table.md +10 -2
  444. package/llms/components/lr-terminal.md +3 -0
  445. package/llms/components/lr-textarea.md +9 -0
  446. package/llms/components/lr-thread-list.md +6 -3
  447. package/llms/components/lr-time-input.md +3 -0
  448. package/llms/components/lr-time-range.md +5 -0
  449. package/llms/components/lr-timeline-item.md +6 -0
  450. package/llms/components/lr-timeline.md +6 -0
  451. package/llms/components/lr-token-input.md +14 -0
  452. package/llms/components/lr-tool-call-chip.md +5 -3
  453. package/llms/components/lr-tool-param-form.md +4 -0
  454. package/llms/components/lr-tool-result-dialog.md +4 -0
  455. package/llms/components/lr-tool-select-dialog.md +4 -0
  456. package/llms/components/lr-tooltip.md +6 -0
  457. package/llms/components/lr-trace-tree.md +3 -0
  458. package/llms/components/lr-transcript-feed.md +3 -0
  459. package/llms/components/lr-tree-item.md +12 -5
  460. package/llms/components/lr-tree.md +12 -5
  461. package/llms/components/lr-typing-indicator.md +3 -0
  462. package/llms/components/lr-usage-badge.md +4 -0
  463. package/llms/components/lr-video.md +8 -2
  464. package/llms/components/lr-virtual-list.md +5 -3
  465. package/llms/components/lr-voice-picker.md +8 -0
  466. package/llms/components/lr-widget-renderer.md +9 -0
  467. package/llms/components/lr-widget.md +4 -2
  468. package/llms/components/lr-word-cloud.md +4 -0
  469. package/llms/components/lr-xml-viewer.md +9 -2
  470. package/llms/components/lr-zoomable-frame.md +6 -3
  471. package/llms-full.txt +4080 -2711
  472. package/package.json +2 -2
  473. package/vscode-css-data.json +1 -1
  474. package/vscode-html-data.json +1 -1
  475. package/web-types.json +1 -1
@@ -53,7 +53,9 @@ readonly items:readonly LyraTimelineItem[];}export interface LyraTimelineEventMa
53
53
  * @cssprop [--lr-timeline-time-extent=var(--lr-size-20rem)] - Distance the `scale="time"` axis
54
54
  * distributes items along: `block-size` when vertical, `inline-size` when horizontal. Time-scaled
55
55
  * items are absolutely positioned, and a percentage offset against an auto-sized track resolves
56
- * to zero, so the axis needs a definite extent. Ignored in the default `scale="flow"`.
56
+ * to zero, so the axis needs a definite extent. Horizontal overlap and stack modes measure
57
+ * actual item/lane height independently and update it when content changes. Ignored in the
58
+ * default `scale="flow"`.
57
59
  * @cssprop [--lr-scroll-fade-size=2rem] - Inline size of each edge fade while a
58
60
  * horizontal timeline overflows. Forced-colors mode disables the masks while retaining native
59
61
  * scrolling.
@@ -109,7 +111,7 @@ rangeEnd?:Date|string|number;
109
111
  * never inherits a host attribute automatically — same reasoning as `<lr-breadcrumb>`'s
110
112
  * identical property. Unset falls back to the localized default; an explicitly empty
111
113
  * `aria-label` stays empty. */
112
- accessibleLabel?:string;private slottedCount;private collisionClusters;private readonly managedClusterHiddenItems;private readonly managedClusterRepresentatives;private readonly clusterActivations;private readonly timestampObservedItems;private clusterMeasurementFrame?;private clusterMeasurementView?;private focusRepairGeneration;
114
+ accessibleLabel?:string;private slottedCount;private collisionClusters;private readonly managedClusterHiddenItems;private readonly managedClusterRepresentatives;private readonly clusterActivations;private readonly timestampObservedItems;private clusterMeasurementFrame?;private clusterMeasurementView?;private timeExtentFrame?;private timeExtentView?;private focusRepairGeneration;
113
115
  /** Gates the horizontal [part='base'] edge fade on the strip genuinely overflowing, with
114
116
  * one-sided/RTL-aware logical-edge state -- see --lr-scroll-fade-size and timeline.styles.ts.
115
117
  * Harmless in the vertical default, where the strip never scrolls inline and the attribute
@@ -155,6 +157,9 @@ private buildCollisionClusters;
155
157
  * more of the allocated axis to avoid overlapping hit targets. Re-evaluated after every cluster
156
158
  * render and by the existing owner-realm ResizeObserver attached to the base and actions. */
157
159
  private clusterCollisionThreshold;
160
+ /** Absolute time items do not contribute intrinsic height. Measure their layout boxes and
161
+ * lane offsets after layout, sharing the existing item ResizeObserver for later content changes. */
162
+ private scheduleTimeExtentMeasurement;private cancelTimeExtentMeasurement;
158
163
  /** Coalesces ResizeObserver-driven membership writes into the next owner-realm frame. Updating
159
164
  * observed cluster actions synchronously inside their observer callback would create a resize
160
165
  * notification loop whenever a larger count changes the action's footprint. */
@@ -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}from"lit";import{property,state}from"lit/decorators.js";import{applyComposedFocusRepair,captureComposedFocusRepair,collectComposedFocusTargets}from"../../../internal/focus-navigation.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{activeElementIn}from"../../../internal/active-element.js";import{OBSERVE_TIMELINE_ITEM_TIMESTAMP,SET_TIMELINE_CLUSTER_PRESENTATION,isTimelineClusterItemContract}from"./timeline-cluster.js";import{styles}from"./timeline.styles.js";import{LYRA_DEFAULT_timeline,LYRA_DEFAULT_timelineClusterCount}from"../../../internal/default-strings.generated.js";const normalizeTimelineOrientation=value=>value==="horizontal"?"horizontal":"vertical";function isUsableActiveElement(value){if(typeof value!="object"&&typeof value!="function"||value===null)return!1;try{const candidate=value;if(candidate.nodeType!==1)return!1;const NodeConstructor=candidate.ownerDocument?.defaultView?.Node??(typeof Node>"u"?void 0:Node);return NodeConstructor?(NodeConstructor.prototype.getRootNode.call(candidate),!0):!1}catch{return!1}}function safelyDeepActiveElement(root){const initial=activeElementIn(root);if(!isUsableActiveElement(initial))return null;let active=initial;for(;;){let shadowRoot;try{shadowRoot=active.shadowRoot}catch{return null}if(!shadowRoot)return active;const nested=activeElementIn(shadowRoot);if(nested===null)return active;if(!isUsableActiveElement(nested))return null;active=nested}}function safelyContainsActive(container,candidate){if(!isUsableActiveElement(candidate))return!1;try{return container.contains(candidate)}catch{return!1}}const normalizeTimelineScale=value=>value==="time"?"time":"flow",normalizeTimelineCollision=value=>value==="stack"||value==="cluster"?value:"overlap",EMPTY_TIMELINE_CLUSTERS=Object.freeze([]),CLUSTER_HIDDEN_ATTRIBUTE="data-lr-timeline-cluster-hidden",TIMELINE_COLLISION_THRESHOLD=.015;function timelineEpochMs(raw){if(raw==null)return null;const ms=(raw instanceof Date?raw:typeof raw=="number"?new Date(raw):new Date(String(raw))).getTime();return Number.isFinite(ms)?ms:null}function itemEpochMs(element){return timelineEpochMs(element.timestamp)}class LyraTimeline extends LyraElement{constructor(){super(...arguments),this._orientation="vertical",this._scale="flow",this._collision="overlap",this.slottedCount=0,this.collisionClusters=EMPTY_TIMELINE_CLUSTERS,this.managedClusterHiddenItems=new Set,this.managedClusterRepresentatives=new Set,this.clusterActivations=new Map,this.timestampObservedItems=new Set,this.focusRepairGeneration=0,this.scrollOverflow=observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part="base"]'),()=>{this.scale==="time"&&this.collision==="cluster"&&this.scheduleClusterMeasurement()}),this.onSlotChange=e=>{this.updateBrowserDerivedState(()=>{this.slottedCount=this.countTimelineItems(e.target),this.applyTimeScale()})},this.onTimelineItemTimestampChange=()=>{this.isConnected&&this.scheduleAfterUpdate(()=>this.applyTimeScale(),"timeline-item-timestamps")}}static{this.defaultStrings={...super.defaultStrings,timeline:LYRA_DEFAULT_timeline,timelineClusterCount:LYRA_DEFAULT_timelineClusterCount}}static{this.immutableEventDetails=Object.freeze(["lr-cluster-activate"])}static{this.identityEventDetailProperties=Object.freeze({"lr-cluster-activate":Object.freeze(["items"])})}static{this.styles=[LyraElement.styles,styles]}get orientation(){return this._orientation}set orientation(value){const normalized=normalizeTimelineOrientation(value),previous=this._orientation;if(previous===normalized){value!==normalized&&this.requestUpdate("orientation",previous);return}this._orientation=normalized,this.requestUpdate("orientation",previous)}get scale(){return this._scale}set scale(value){const normalized=normalizeTimelineScale(value),previous=this._scale;if(previous===normalized){value!==normalized&&this.requestUpdate("scale",previous);return}this._scale=normalized,this.requestUpdate("scale",previous)}get collision(){return this._collision}set collision(value){const normalized=normalizeTimelineCollision(value),previous=this._collision;if(previous===normalized){value!==normalized&&this.requestUpdate("collision",previous);return}this._collision=normalized,this.requestUpdate("collision",previous)}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.scheduleAfterUpdate(()=>this.applyTimeScale(),"timeline-clusters")}disconnectedCallback(){this.cancelClusterMeasurement(),this.focusRepairGeneration+=1,this.restoreClusterPresentation(),this.restoreClusterVisibility(),this.syncTimestampObservers([]),this.collisionClusters.length>0&&(this.collisionClusters=EMPTY_TIMELINE_CLUSTERS),super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.slottedCount=Array.from(this.children).filter(element=>!element.getAttribute("slot")&&element.localName===tag("timeline-item")).length),this.hasUpdated?(changed.has("scale")||changed.has("collision")||changed.has("rangeStart")||changed.has("rangeEnd"))&&this.applyTimeScale():this.seedFirstRenderState(()=>this.applyTimeScale())}updated(changed){super.updated(changed),this.scrollOverflow.observeExtra(this.timelineItems()),changed.has("orientation")&&this.getAttribute("orientation")!==this.orientation&&this.setAttribute("orientation",this.orientation),(changed.has("collisionClusters")||changed.has("orientation"))&&this.collisionClusters.length>0&&this.scheduleAfterUpdate(()=>this.applyTimeScale(),"timeline-cluster-measurement"),this.collisionClusters.length>0&&this.syncClusterPresentations(this.collisionClusters)}countTimelineItems(slot){return slot.assignedElements({flatten:!0}).filter(element=>element.localName===tag("timeline-item")).length}firstUpdated(changed){super.firstUpdated(changed),this.scheduleAfterUpdate(()=>this.updateBrowserDerivedState(()=>{const slot=this.shadowRoot.querySelector("slot");this.slottedCount=this.countTimelineItems(slot),this.applyTimeScale()}),"timeline-first-slot-reconciliation")}get itemCount(){return this.slottedCount}syncTimestampObservers(items){const current=new Set(items);for(const item of this.timestampObservedItems)current.has(item)||(isTimelineClusterItemContract(item)&&item[OBSERVE_TIMELINE_ITEM_TIMESTAMP](this.onTimelineItemTimestampChange,!1),this.timestampObservedItems.delete(item));for(const item of current)this.timestampObservedItems.has(item)||isTimelineClusterItemContract(item)&&(item[OBSERVE_TIMELINE_ITEM_TIMESTAMP](this.onTimelineItemTimestampChange,!0),this.timestampObservedItems.add(item))}timelineItems(){const slot=this.shadowRoot?.querySelector("slot");return(slot?slot.assignedElements({flatten:!0}):Array.from(this.children).filter(element=>!element.getAttribute("slot"))).filter(element=>element.localName===tag("timeline-item"))}timeRange(stamps){const pinnedStart=timelineEpochMs(this.rangeStart),pinnedEnd=timelineEpochMs(this.rangeEnd);if(pinnedStart!==null&&pinnedEnd!==null&&pinnedEnd>pinnedStart)return[pinnedStart,pinnedEnd];const finite=stamps.filter(value=>value!==null);if(finite.length<2)return null;const lo=Math.min(...finite),hi=Math.max(...finite);return hi>lo?[lo,hi]:null}applyTimeScale(){const items=this.timelineItems();if(this.syncTimestampObservers(items),this.scale!=="time"){for(const item of items)item.style.removeProperty("--_lr-timeline-item-offset"),item.style.removeProperty("--_lr-timeline-item-lane");this.applyCollisionClusters([]);return}const stamps=items.map(item=>itemEpochMs(item)),range=this.timeRange(stamps),lastIndex=Math.max(1,items.length-1),offsets=new Array(items.length).fill(0);items.forEach((item,index)=>{const stamp=stamps[index]??null,ratio=range&&stamp!==null?(stamp-range[0])/(range[1]-range[0]):this.collision==="cluster"&&stamp!==null?0:index/lastIndex,clamped=Math.min(1,Math.max(0,ratio));offsets[index]=clamped,item.style.setProperty("--_lr-timeline-item-offset",`${clamped*100}%`)}),this.applyCollisionLanes(items,offsets),this.applyCollisionClusters(this.collision==="cluster"?this.buildCollisionClusters(items,offsets,this.clusterCollisionThreshold()):[])}applyCollisionLanes(items,offsets){if(this.collision!=="stack"){for(const item of items)item.style.removeProperty("--_lr-timeline-item-lane");return}const order=items.map((_,index)=>index).sort((a,b)=>(offsets[a]??0)-(offsets[b]??0)),laneTails=[],lanes=new Array(items.length).fill(0);for(const index of order){const offset=offsets[index]??0;let lane=laneTails.findIndex(tail=>offset-tail>=TIMELINE_COLLISION_THRESHOLD);lane===-1&&(lane=laneTails.length),laneTails[lane]=offset,lanes[index]=lane}items.forEach((item,index)=>{item.style.setProperty("--_lr-timeline-item-lane",String(lanes[index]??0))})}buildCollisionClusters(items,offsets,threshold){const order=items.map((_,index)=>index).sort((a,b)=>(offsets[a]??0)-(offsets[b]??0)||a-b),clusters=[];let window=[],windowStart=0;const flush=()=>{if(window.length<2){window=[];return}const memberIndexes=[...window].sort((a,b)=>a-b);clusters.push({offset:windowStart,items:memberIndexes.map(index=>items[index])}),window=[]};for(const index of order){const offset=offsets[index]??0;window.length>0&&offset-windowStart>=threshold&&flush(),window.length===0&&(windowStart=offset),window.push(index)}return flush(),clusters}clusterCollisionThreshold(){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return TIMELINE_COLLISION_THRESHOLD;const axisExtent=this.orientation==="horizontal"?base.clientWidth:base.clientHeight;if(!Number.isFinite(axisExtent)||axisExtent<=0)return TIMELINE_COLLISION_THRESHOLD;let markerExtent=0;for(const item of this.managedClusterRepresentatives){const marker=item.shadowRoot?.querySelector('[part="cluster"]');if(!marker)continue;const rect=marker.getBoundingClientRect();markerExtent=Math.max(markerExtent,this.orientation==="horizontal"?rect.width:rect.height)}return!Number.isFinite(markerExtent)||markerExtent<=0?TIMELINE_COLLISION_THRESHOLD:Math.max(TIMELINE_COLLISION_THRESHOLD,markerExtent/axisExtent)}scheduleClusterMeasurement(){const view=this.ownerDocument.defaultView;view&&(this.clusterMeasurementFrame!==void 0&&this.clusterMeasurementView===view||(this.cancelClusterMeasurement(),this.clusterMeasurementView=view,this.clusterMeasurementFrame=view.requestAnimationFrame(()=>{this.clusterMeasurementFrame=void 0,this.clusterMeasurementView=void 0,this.isConnected&&this.ownerDocument.defaultView===view&&this.scale==="time"&&this.collision==="cluster"&&this.applyTimeScale()})))}cancelClusterMeasurement(){this.clusterMeasurementFrame!==void 0&&this.clusterMeasurementView&&this.clusterMeasurementView.cancelAnimationFrame(this.clusterMeasurementFrame),this.clusterMeasurementFrame=void 0,this.clusterMeasurementView=void 0}sameClusters(left,right){return left.length===right.length&&left.every((cluster,index)=>cluster.offset===right[index]?.offset&&cluster.items.length===right[index]?.items.length&&cluster.items.every((item,itemIndex)=>item===right[index]?.items[itemIndex]))}captureClusterFocusRepair(clusters){const active=safelyDeepActiveElement(this.ownerDocument);if(!active)return;const focusedItem=this.timelineItems().find(item=>item===active||safelyContainsActive(item,active)||safelyDeepActiveElement(item.shadowRoot)===active);if(!focusedItem)return;const wasRepresentative=this.managedClusterRepresentatives.has(focusedItem),nextCluster=clusters.find(cluster=>cluster.items.includes(focusedItem)),nextRepresentative=nextCluster?.items[0],mode=nextCluster?"cluster":"item";if(mode==="cluster"&&wasRepresentative&&nextRepresentative===focusedItem||mode==="item"&&!wasRepresentative)return;const base=this.renderRoot.querySelector('[part="base"]');let snapshot;try{snapshot=captureComposedFocusRepair(focusedItem,base)}catch{return}if(snapshot)return{item:mode==="cluster"?nextRepresentative:focusedItem,mode,snapshot}}scheduleClusterFocusRepair(repair){const generation=++this.focusRepairGeneration;repair&&repair.item.updateComplete.then(()=>{if(generation!==this.focusRepairGeneration||!this.isConnected)return;const base=this.renderRoot.querySelector('[part="base"]'),target=repair.mode==="cluster"?repair.item.shadowRoot?.querySelector('[part="cluster"]')??null:collectComposedFocusTargets(repair.item).elements[0]??base;try{applyComposedFocusRepair(repair.snapshot,target)}catch{}})}applyCollisionClusters(clusters){const frozen=Object.freeze(clusters.map(cluster=>Object.freeze({offset:cluster.offset,items:Object.freeze([...cluster.items])}))),changed=!this.sameClusters(this.collisionClusters,frozen),focusRepair=changed?this.captureClusterFocusRepair(frozen):void 0,representatives=new Set(frozen.map(cluster=>cluster.items[0])),hiddenItems=new Set(frozen.flatMap(cluster=>cluster.items.filter(item=>!representatives.has(item))));for(const item of this.managedClusterHiddenItems){if(hiddenItems.has(item)){item.hasAttribute(CLUSTER_HIDDEN_ATTRIBUTE)||item.setAttribute(CLUSTER_HIDDEN_ATTRIBUTE,"");continue}item.getAttribute(CLUSTER_HIDDEN_ATTRIBUTE)===""&&item.removeAttribute(CLUSTER_HIDDEN_ATTRIBUTE),this.managedClusterHiddenItems.delete(item)}for(const item of hiddenItems)this.managedClusterHiddenItems.has(item)||item.hasAttribute(CLUSTER_HIDDEN_ATTRIBUTE)||(item.setAttribute(CLUSTER_HIDDEN_ATTRIBUTE,""),this.managedClusterHiddenItems.add(item));if(changed){this.restoreClusterPresentation();for(const cluster of frozen){const representative=cluster.items[0];this.clusterActivations.set(representative,()=>this.activateCluster(cluster.items)),this.managedClusterRepresentatives.add(representative)}this.collisionClusters=frozen,this.syncClusterPresentations(frozen),this.scheduleClusterFocusRepair(focusRepair)}for(const cluster of frozen)cluster.items[0].style.setProperty("--_lr-timeline-item-offset",`${cluster.offset*100}%`)}syncClusterPresentations(clusters){for(const cluster of clusters){const representative=cluster.items[0],activate=this.clusterActivations.get(representative);if(!activate)continue;const countText=getNumberFormat(this.effectiveLocale).format(cluster.items.length);isTimelineClusterItemContract(representative)&&representative[SET_TIMELINE_CLUSTER_PRESENTATION]({accessibleLabel:this.localize("timelineClusterCount",void 0,{count:countText}),countText,activate})}}restoreClusterPresentation(){for(const item of this.managedClusterRepresentatives)isTimelineClusterItemContract(item)&&item[SET_TIMELINE_CLUSTER_PRESENTATION](void 0);this.managedClusterRepresentatives.clear(),this.clusterActivations.clear()}restoreClusterVisibility(){for(const item of this.managedClusterHiddenItems)item.getAttribute(CLUSTER_HIDDEN_ATTRIBUTE)===""&&item.removeAttribute(CLUSTER_HIDDEN_ATTRIBUTE);this.managedClusterHiddenItems.clear()}activateCluster(items){const snapshot=this.ownerDocument.defaultView?.Array.from(items)??[...items];this.emit("lr-cluster-activate",Object.freeze({items:Object.freeze(snapshot)}))}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}from"lit";import{property,state}from"lit/decorators.js";import{applyComposedFocusRepair,captureComposedFocusRepair,collectComposedFocusTargets}from"../../../internal/focus-navigation.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{activeElementIn}from"../../../internal/active-element.js";import{OBSERVE_TIMELINE_ITEM_TIMESTAMP,SET_TIMELINE_CLUSTER_PRESENTATION,isTimelineClusterItemContract}from"./timeline-cluster.js";import{styles}from"./timeline.styles.js";import{LYRA_DEFAULT_timeline,LYRA_DEFAULT_timelineClusterCount}from"../../../internal/default-strings.generated.js";const normalizeTimelineOrientation=value=>value==="horizontal"?"horizontal":"vertical";function isUsableActiveElement(value){if(typeof value!="object"&&typeof value!="function"||value===null)return!1;try{const candidate=value;if(candidate.nodeType!==1)return!1;const NodeConstructor=candidate.ownerDocument?.defaultView?.Node??(typeof Node>"u"?void 0:Node);return NodeConstructor?(NodeConstructor.prototype.getRootNode.call(candidate),!0):!1}catch{return!1}}function safelyDeepActiveElement(root){const initial=activeElementIn(root);if(!isUsableActiveElement(initial))return null;let active=initial;for(;;){let shadowRoot;try{shadowRoot=active.shadowRoot}catch{return null}if(!shadowRoot)return active;const nested=activeElementIn(shadowRoot);if(nested===null)return active;if(!isUsableActiveElement(nested))return null;active=nested}}function safelyContainsActive(container,candidate){if(!isUsableActiveElement(candidate))return!1;try{return container.contains(candidate)}catch{return!1}}const normalizeTimelineScale=value=>value==="time"?"time":"flow",normalizeTimelineCollision=value=>value==="stack"||value==="cluster"?value:"overlap",EMPTY_TIMELINE_CLUSTERS=Object.freeze([]),CLUSTER_HIDDEN_ATTRIBUTE="data-lr-timeline-cluster-hidden",TIMELINE_COLLISION_THRESHOLD=.015;function timelineEpochMs(raw){if(raw==null)return null;const ms=(raw instanceof Date?raw:typeof raw=="number"?new Date(raw):new Date(String(raw))).getTime();return Number.isFinite(ms)?ms:null}function itemEpochMs(element){return timelineEpochMs(element.timestamp)}class LyraTimeline extends LyraElement{constructor(){super(...arguments),this._orientation="vertical",this._scale="flow",this._collision="overlap",this.slottedCount=0,this.collisionClusters=EMPTY_TIMELINE_CLUSTERS,this.managedClusterHiddenItems=new Set,this.managedClusterRepresentatives=new Set,this.clusterActivations=new Map,this.timestampObservedItems=new Set,this.focusRepairGeneration=0,this.scrollOverflow=observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part="base"]'),()=>{this.scheduleTimeExtentMeasurement(),this.scale==="time"&&this.collision==="cluster"&&this.scheduleClusterMeasurement()}),this.onSlotChange=e=>{this.updateBrowserDerivedState(()=>{this.slottedCount=this.countTimelineItems(e.target),this.applyTimeScale()})},this.onTimelineItemTimestampChange=()=>{this.isConnected&&this.scheduleAfterUpdate(()=>this.applyTimeScale(),"timeline-item-timestamps")}}static{this.defaultStrings={...super.defaultStrings,timeline:LYRA_DEFAULT_timeline,timelineClusterCount:LYRA_DEFAULT_timelineClusterCount}}static{this.immutableEventDetails=Object.freeze(["lr-cluster-activate"])}static{this.identityEventDetailProperties=Object.freeze({"lr-cluster-activate":Object.freeze(["items"])})}static{this.styles=[LyraElement.styles,styles]}get orientation(){return this._orientation}set orientation(value){const normalized=normalizeTimelineOrientation(value),previous=this._orientation;if(previous===normalized){value!==normalized&&this.requestUpdate("orientation",previous);return}this._orientation=normalized,this.requestUpdate("orientation",previous)}get scale(){return this._scale}set scale(value){const normalized=normalizeTimelineScale(value),previous=this._scale;if(previous===normalized){value!==normalized&&this.requestUpdate("scale",previous);return}this._scale=normalized,this.requestUpdate("scale",previous)}get collision(){return this._collision}set collision(value){const normalized=normalizeTimelineCollision(value),previous=this._collision;if(previous===normalized){value!==normalized&&this.requestUpdate("collision",previous);return}this._collision=normalized,this.requestUpdate("collision",previous)}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.scheduleAfterUpdate(()=>this.applyTimeScale(),"timeline-clusters")}disconnectedCallback(){this.cancelClusterMeasurement(),this.cancelTimeExtentMeasurement(),this.focusRepairGeneration+=1,this.restoreClusterPresentation(),this.restoreClusterVisibility(),this.syncTimestampObservers([]),this.collisionClusters.length>0&&(this.collisionClusters=EMPTY_TIMELINE_CLUSTERS),super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed),this.hasUpdated||(this.slottedCount=Array.from(this.children).filter(element=>!element.getAttribute("slot")&&element.localName===tag("timeline-item")).length),this.hasUpdated?(changed.has("scale")||changed.has("collision")||changed.has("rangeStart")||changed.has("rangeEnd"))&&this.applyTimeScale():this.seedFirstRenderState(()=>this.applyTimeScale())}updated(changed){super.updated(changed),this.scrollOverflow.observeExtra(this.timelineItems()),this.scheduleTimeExtentMeasurement(),changed.has("orientation")&&this.getAttribute("orientation")!==this.orientation&&this.setAttribute("orientation",this.orientation),(changed.has("collisionClusters")||changed.has("orientation"))&&this.collisionClusters.length>0&&this.scheduleAfterUpdate(()=>this.applyTimeScale(),"timeline-cluster-measurement"),this.collisionClusters.length>0&&this.syncClusterPresentations(this.collisionClusters)}countTimelineItems(slot){return slot.assignedElements({flatten:!0}).filter(element=>element.localName===tag("timeline-item")).length}firstUpdated(changed){super.firstUpdated(changed),this.scheduleAfterUpdate(()=>this.updateBrowserDerivedState(()=>{const slot=this.shadowRoot.querySelector("slot");this.slottedCount=this.countTimelineItems(slot),this.applyTimeScale()}),"timeline-first-slot-reconciliation")}get itemCount(){return this.slottedCount}syncTimestampObservers(items){const current=new Set(items);for(const item of this.timestampObservedItems)current.has(item)||(isTimelineClusterItemContract(item)&&item[OBSERVE_TIMELINE_ITEM_TIMESTAMP](this.onTimelineItemTimestampChange,!1),this.timestampObservedItems.delete(item));for(const item of current)this.timestampObservedItems.has(item)||isTimelineClusterItemContract(item)&&(item[OBSERVE_TIMELINE_ITEM_TIMESTAMP](this.onTimelineItemTimestampChange,!0),this.timestampObservedItems.add(item))}timelineItems(){const slot=this.shadowRoot?.querySelector("slot");return(slot?slot.assignedElements({flatten:!0}):Array.from(this.children).filter(element=>!element.getAttribute("slot"))).filter(element=>element.localName===tag("timeline-item"))}timeRange(stamps){const pinnedStart=timelineEpochMs(this.rangeStart),pinnedEnd=timelineEpochMs(this.rangeEnd);if(pinnedStart!==null&&pinnedEnd!==null&&pinnedEnd>pinnedStart)return[pinnedStart,pinnedEnd];const finite=stamps.filter(value=>value!==null);if(finite.length<2)return null;const lo=Math.min(...finite),hi=Math.max(...finite);return hi>lo?[lo,hi]:null}applyTimeScale(){this.scheduleTimeExtentMeasurement();const items=this.timelineItems();if(this.syncTimestampObservers(items),this.scale!=="time"){for(const item of items)item.style.removeProperty("--_lr-timeline-item-offset"),item.style.removeProperty("--_lr-timeline-item-lane");this.applyCollisionClusters([]);return}const stamps=items.map(item=>itemEpochMs(item)),range=this.timeRange(stamps),lastIndex=Math.max(1,items.length-1),offsets=new Array(items.length).fill(0);items.forEach((item,index)=>{const stamp=stamps[index]??null,ratio=range&&stamp!==null?(stamp-range[0])/(range[1]-range[0]):this.collision==="cluster"&&stamp!==null?0:index/lastIndex,clamped=Math.min(1,Math.max(0,ratio));offsets[index]=clamped,item.style.setProperty("--_lr-timeline-item-offset",`${clamped*100}%`)}),this.applyCollisionLanes(items,offsets),this.applyCollisionClusters(this.collision==="cluster"?this.buildCollisionClusters(items,offsets,this.clusterCollisionThreshold()):[])}applyCollisionLanes(items,offsets){if(this.collision!=="stack"){for(const item of items)item.style.removeProperty("--_lr-timeline-item-lane");return}const order=items.map((_,index)=>index).sort((a,b)=>(offsets[a]??0)-(offsets[b]??0)),laneTails=[],lanes=new Array(items.length).fill(0);for(const index of order){const offset=offsets[index]??0;let lane=laneTails.findIndex(tail=>offset-tail>=TIMELINE_COLLISION_THRESHOLD);lane===-1&&(lane=laneTails.length),laneTails[lane]=offset,lanes[index]=lane}items.forEach((item,index)=>{item.style.setProperty("--_lr-timeline-item-lane",String(lanes[index]??0))})}buildCollisionClusters(items,offsets,threshold){const order=items.map((_,index)=>index).sort((a,b)=>(offsets[a]??0)-(offsets[b]??0)||a-b),clusters=[];let window=[],windowStart=0;const flush=()=>{if(window.length<2){window=[];return}const memberIndexes=[...window].sort((a,b)=>a-b);clusters.push({offset:windowStart,items:memberIndexes.map(index=>items[index])}),window=[]};for(const index of order){const offset=offsets[index]??0;window.length>0&&offset-windowStart>=threshold&&flush(),window.length===0&&(windowStart=offset),window.push(index)}return flush(),clusters}clusterCollisionThreshold(){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return TIMELINE_COLLISION_THRESHOLD;const axisExtent=this.orientation==="horizontal"?base.clientWidth:base.clientHeight;if(!Number.isFinite(axisExtent)||axisExtent<=0)return TIMELINE_COLLISION_THRESHOLD;let markerExtent=0;for(const item of this.managedClusterRepresentatives){const marker=item.shadowRoot?.querySelector('[part="cluster"]');if(!marker)continue;const rect=marker.getBoundingClientRect();markerExtent=Math.max(markerExtent,this.orientation==="horizontal"?rect.width:rect.height)}return!Number.isFinite(markerExtent)||markerExtent<=0?TIMELINE_COLLISION_THRESHOLD:Math.max(TIMELINE_COLLISION_THRESHOLD,markerExtent/axisExtent)}scheduleTimeExtentMeasurement(){const view=this.ownerDocument?.defaultView;view&&(this.timeExtentFrame!==void 0&&this.timeExtentView===view||(this.cancelTimeExtentMeasurement(),this.timeExtentView=view,this.timeExtentFrame=view.requestAnimationFrame(()=>{if(this.timeExtentFrame=void 0,this.timeExtentView=void 0,!this.isConnected||this.ownerDocument.defaultView!==view)return;const base=this.renderRoot.querySelector('[part="base"]');if(!base)return;if(this.scale!=="time"||this.orientation!=="horizontal"||this.collision==="cluster"){base.style.removeProperty("--_lr-timeline-content-height");return}let extent=0;for(const item of this.timelineItems())item.getClientRects().length&&(extent=Math.max(extent,item.offsetTop+item.offsetHeight+1));const height=`${extent+Math.max(0,base.offsetHeight-base.clientHeight)}px`;base.style.getPropertyValue("--_lr-timeline-content-height")!==height&&base.style.setProperty("--_lr-timeline-content-height",height)})))}cancelTimeExtentMeasurement(){this.timeExtentFrame!==void 0&&this.timeExtentView&&this.timeExtentView.cancelAnimationFrame(this.timeExtentFrame),this.timeExtentFrame=void 0,this.timeExtentView=void 0}scheduleClusterMeasurement(){const view=this.ownerDocument.defaultView;view&&(this.clusterMeasurementFrame!==void 0&&this.clusterMeasurementView===view||(this.cancelClusterMeasurement(),this.clusterMeasurementView=view,this.clusterMeasurementFrame=view.requestAnimationFrame(()=>{this.clusterMeasurementFrame=void 0,this.clusterMeasurementView=void 0,this.isConnected&&this.ownerDocument.defaultView===view&&this.scale==="time"&&this.collision==="cluster"&&this.applyTimeScale()})))}cancelClusterMeasurement(){this.clusterMeasurementFrame!==void 0&&this.clusterMeasurementView&&this.clusterMeasurementView.cancelAnimationFrame(this.clusterMeasurementFrame),this.clusterMeasurementFrame=void 0,this.clusterMeasurementView=void 0}sameClusters(left,right){return left.length===right.length&&left.every((cluster,index)=>cluster.offset===right[index]?.offset&&cluster.items.length===right[index]?.items.length&&cluster.items.every((item,itemIndex)=>item===right[index]?.items[itemIndex]))}captureClusterFocusRepair(clusters){const active=safelyDeepActiveElement(this.ownerDocument);if(!active)return;const focusedItem=this.timelineItems().find(item=>item===active||safelyContainsActive(item,active)||safelyDeepActiveElement(item.shadowRoot)===active);if(!focusedItem)return;const wasRepresentative=this.managedClusterRepresentatives.has(focusedItem),nextCluster=clusters.find(cluster=>cluster.items.includes(focusedItem)),nextRepresentative=nextCluster?.items[0],mode=nextCluster?"cluster":"item";if(mode==="cluster"&&wasRepresentative&&nextRepresentative===focusedItem||mode==="item"&&!wasRepresentative)return;const base=this.renderRoot.querySelector('[part="base"]');let snapshot;try{snapshot=captureComposedFocusRepair(focusedItem,base)}catch{return}if(snapshot)return{item:mode==="cluster"?nextRepresentative:focusedItem,mode,snapshot}}scheduleClusterFocusRepair(repair){const generation=++this.focusRepairGeneration;repair&&repair.item.updateComplete.then(()=>{if(generation!==this.focusRepairGeneration||!this.isConnected)return;const base=this.renderRoot.querySelector('[part="base"]'),target=repair.mode==="cluster"?repair.item.shadowRoot?.querySelector('[part="cluster"]')??null:collectComposedFocusTargets(repair.item).elements[0]??base;try{applyComposedFocusRepair(repair.snapshot,target)}catch{}})}applyCollisionClusters(clusters){const frozen=Object.freeze(clusters.map(cluster=>Object.freeze({offset:cluster.offset,items:Object.freeze([...cluster.items])}))),changed=!this.sameClusters(this.collisionClusters,frozen),focusRepair=changed?this.captureClusterFocusRepair(frozen):void 0,representatives=new Set(frozen.map(cluster=>cluster.items[0])),hiddenItems=new Set(frozen.flatMap(cluster=>cluster.items.filter(item=>!representatives.has(item))));for(const item of this.managedClusterHiddenItems){if(hiddenItems.has(item)){item.hasAttribute(CLUSTER_HIDDEN_ATTRIBUTE)||item.setAttribute(CLUSTER_HIDDEN_ATTRIBUTE,"");continue}item.getAttribute(CLUSTER_HIDDEN_ATTRIBUTE)===""&&item.removeAttribute(CLUSTER_HIDDEN_ATTRIBUTE),this.managedClusterHiddenItems.delete(item)}for(const item of hiddenItems)this.managedClusterHiddenItems.has(item)||item.hasAttribute(CLUSTER_HIDDEN_ATTRIBUTE)||(item.setAttribute(CLUSTER_HIDDEN_ATTRIBUTE,""),this.managedClusterHiddenItems.add(item));if(changed){this.restoreClusterPresentation();for(const cluster of frozen){const representative=cluster.items[0];this.clusterActivations.set(representative,()=>this.activateCluster(cluster.items)),this.managedClusterRepresentatives.add(representative)}this.collisionClusters=frozen,this.syncClusterPresentations(frozen),this.scheduleClusterFocusRepair(focusRepair)}for(const cluster of frozen)cluster.items[0].style.setProperty("--_lr-timeline-item-offset",`${cluster.offset*100}%`)}syncClusterPresentations(clusters){for(const cluster of clusters){const representative=cluster.items[0],activate=this.clusterActivations.get(representative);if(!activate)continue;const countText=getNumberFormat(this.effectiveLocale).format(cluster.items.length);isTimelineClusterItemContract(representative)&&representative[SET_TIMELINE_CLUSTER_PRESENTATION]({accessibleLabel:this.localize("timelineClusterCount",void 0,{count:countText}),countText,activate})}}restoreClusterPresentation(){for(const item of this.managedClusterRepresentatives)isTimelineClusterItemContract(item)&&item[SET_TIMELINE_CLUSTER_PRESENTATION](void 0);this.managedClusterRepresentatives.clear(),this.clusterActivations.clear()}restoreClusterVisibility(){for(const item of this.managedClusterHiddenItems)item.getAttribute(CLUSTER_HIDDEN_ATTRIBUTE)===""&&item.removeAttribute(CLUSTER_HIDDEN_ATTRIBUTE);this.managedClusterHiddenItems.clear()}activateCluster(items){const snapshot=this.ownerDocument.defaultView?.Array.from(items)??[...items];this.emit("lr-cluster-activate",Object.freeze({items:Object.freeze(snapshot)}))}render(){return html`
2
2
  <div part="base" role="list" tabindex="-1" aria-label=${this.accessibleLabel==null?this.localize("timeline"):this.accessibleLabel}>
3
3
  <slot @slotchange=${this.onSlotChange}></slot>
4
4
  </div>
@@ -1 +1 @@
1
- import{css}from"lit";const styles=css`:host{--_lr-timeline-item-direction:row;--_lr-timeline-item-track-direction:column;--_lr-timeline-item-gap-block-end:var(--lr-timeline-gap,var(--lr-space-l));--_lr-timeline-item-gap-inline-end:0;min-inline-size:0;display:block}:host([orientation=horizontal]){--_lr-timeline-item-direction:column;--_lr-timeline-item-track-direction:row;--_lr-timeline-item-gap-block-end:0;--_lr-timeline-item-gap-inline-end:var(--lr-timeline-gap,var(--lr-space-l))}[part=base]{flex-direction:column;min-inline-size:0;margin:0;padding:0;display:flex}:host([scale=time]) [part=base]{block-size:var(--lr-timeline-time-extent,var(--lr-size-20rem));display:block;position:relative}:host([scale=time][orientation=horizontal]) [part=base]{block-size:auto;inline-size:var(--lr-timeline-time-extent,var(--lr-size-20rem))}:host([scale=time]) ::slotted(*){inline-size:100%;position:absolute;inset-block-start:var(--_lr-timeline-item-offset,0%);inset-inline-start:0}:host([scale=time][collision=stack]) ::slotted(*){--_lr-timeline-lane-indent:calc(var(--_lr-timeline-item-lane,0) * var(--lr-timeline-collision-offset,var(--lr-space-l)));inline-size:calc(100% - var(--_lr-timeline-lane-indent));inset-inline-start:var(--_lr-timeline-lane-indent)}:host([scale=time][collision=stack][orientation=horizontal]) ::slotted(*){inline-size:auto;inset-block-start:var(--_lr-timeline-lane-indent);inset-inline-start:var(--_lr-timeline-item-offset,0%)}:host([scale=time][orientation=horizontal]) ::slotted(*){inline-size:auto;inset-block-start:0;inset-inline-start:var(--_lr-timeline-item-offset,0%)}:host([scale=time][collision=cluster]) ::slotted([data-lr-timeline-cluster-hidden]){display:none!important}:host([scale=time][collision=cluster][orientation=horizontal]) [part=base]{min-block-size:max(var(--lr-icon-button-size), var(--lr-timeline-cluster-size,var(--lr-size-2rem)))}:host([orientation=horizontal]) [part=base]{flex-direction:row;overflow:auto hidden}:host([orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-start][data-scroll-end]){-webkit-mask-image:linear-gradient(to right, transparent, var(--lr-mask-opaque) var(--lr-scroll-fade-size), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent);mask-image:linear-gradient(to right, transparent, var(--lr-mask-opaque) var(--lr-scroll-fade-size), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent)}:host([orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-end]:not([data-scroll-start])){-webkit-mask-image:linear-gradient(to right, var(--lr-mask-opaque), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent);mask-image:linear-gradient(to right, var(--lr-mask-opaque), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent)}:host([orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-start]:not([data-scroll-end])),:host(:dir(rtl)[orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-end]:not([data-scroll-start])){-webkit-mask-image:linear-gradient(to right, transparent, var(--lr-mask-opaque) var(--lr-scroll-fade-size), var(--lr-mask-opaque));mask-image:linear-gradient(to right, transparent, var(--lr-mask-opaque) var(--lr-scroll-fade-size), var(--lr-mask-opaque))}:host(:dir(rtl)[orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-start]:not([data-scroll-end])){-webkit-mask-image:linear-gradient(to right, var(--lr-mask-opaque), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent);mask-image:linear-gradient(to right, var(--lr-mask-opaque), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent)}@media (forced-colors:active){:host([orientation=horizontal]) [part=base][data-scroll-overflow],:host(:dir(rtl)[orientation=horizontal]) [part=base][data-scroll-overflow]{-webkit-mask-image:none;mask-image:none}}::slotted([role=listitem]:last-child){--_lr-timeline-item-rail-visibility:hidden}`;export{styles};
1
+ import{css}from"lit";const styles=css`:host{--_lr-timeline-item-direction:row;--_lr-timeline-item-track-direction:column;--_lr-timeline-item-gap-block-end:var(--lr-timeline-gap,var(--lr-space-l));--_lr-timeline-item-gap-inline-end:0;min-inline-size:0;display:block}:host([orientation=horizontal]){--_lr-timeline-item-direction:column;--_lr-timeline-item-track-direction:row;--_lr-timeline-item-gap-block-end:0;--_lr-timeline-item-gap-inline-end:var(--lr-timeline-gap,var(--lr-space-l))}[part=base]{flex-direction:column;min-inline-size:0;margin:0;padding:0;display:flex}:host([scale=time]) [part=base]{block-size:var(--lr-timeline-time-extent,var(--lr-size-20rem));display:block;position:relative}:host([scale=time][orientation=horizontal]) [part=base]{block-size:var(--_lr-timeline-content-height,auto);inline-size:var(--lr-timeline-time-extent,var(--lr-size-20rem))}:host([scale=time]) ::slotted(*){inline-size:100%;position:absolute;inset-block-start:var(--_lr-timeline-item-offset,0%);inset-inline-start:0}:host([scale=time][collision=stack]) ::slotted(*){--_lr-timeline-lane-indent:calc(var(--_lr-timeline-item-lane,0) * var(--lr-timeline-collision-offset,var(--lr-space-l)));inline-size:calc(100% - var(--_lr-timeline-lane-indent));inset-inline-start:var(--_lr-timeline-lane-indent)}:host([scale=time][collision=stack][orientation=horizontal]) ::slotted(*){inline-size:auto;inset-block-start:var(--_lr-timeline-lane-indent);inset-inline-start:var(--_lr-timeline-item-offset,0%)}:host([scale=time][orientation=horizontal]) ::slotted(*){inline-size:auto;inset-block-start:0;inset-inline-start:var(--_lr-timeline-item-offset,0%)}:host([scale=time][collision=cluster]) ::slotted([data-lr-timeline-cluster-hidden]){display:none!important}:host([scale=time][collision=cluster][orientation=horizontal]) [part=base]{min-block-size:max(var(--lr-icon-button-size), var(--lr-timeline-cluster-size,var(--lr-size-2rem)))}:host([orientation=horizontal]) [part=base]{flex-direction:row;overflow:auto hidden}:host([orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-start][data-scroll-end]){-webkit-mask-image:linear-gradient(to right, transparent, var(--lr-mask-opaque) var(--lr-scroll-fade-size), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent);mask-image:linear-gradient(to right, transparent, var(--lr-mask-opaque) var(--lr-scroll-fade-size), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent)}:host([orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-end]:not([data-scroll-start])){-webkit-mask-image:linear-gradient(to right, var(--lr-mask-opaque), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent);mask-image:linear-gradient(to right, var(--lr-mask-opaque), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent)}:host([orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-start]:not([data-scroll-end])),:host(:dir(rtl)[orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-end]:not([data-scroll-start])){-webkit-mask-image:linear-gradient(to right, transparent, var(--lr-mask-opaque) var(--lr-scroll-fade-size), var(--lr-mask-opaque));mask-image:linear-gradient(to right, transparent, var(--lr-mask-opaque) var(--lr-scroll-fade-size), var(--lr-mask-opaque))}:host(:dir(rtl)[orientation=horizontal]) [part=base][data-scroll-overflow]:where([data-scroll-start]:not([data-scroll-end])){-webkit-mask-image:linear-gradient(to right, var(--lr-mask-opaque), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent);mask-image:linear-gradient(to right, var(--lr-mask-opaque), var(--lr-mask-opaque) calc(100% - var(--lr-scroll-fade-size)), transparent)}@media (forced-colors:active){:host([orientation=horizontal]) [part=base][data-scroll-overflow],:host(:dir(rtl)[orientation=horizontal]) [part=base][data-scroll-overflow]{-webkit-mask-image:none;mask-image:none}}::slotted([role=listitem]:last-child){--_lr-timeline-item-rail-visibility:hidden}`;export{styles};
@@ -25,7 +25,9 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement,type
25
25
  * text is resolved separately from accessibility-visible assigned content and updates through
26
26
  * forwarding slots; a host `aria-label` keeps precedence by presence in both models. A data
27
27
  * item's `accessibleLabel` is reflected only while the component owns that attribute, so an
28
- * initial or later author override survives object refreshes.
28
+ * initial or later author override survives object refreshes. A data item with no usable spoken
29
+ * label, visible label, description or badge name uses its stable ID as a semantic fallback.
30
+ * This leaves the visible content unchanged and does not apply to declarative items.
29
31
  * Every documented CSS part is forwarded under the same name through recursively rendered data-
30
32
  * model children. A consumer selector on the outer item therefore reaches matching row, label,
31
33
  * state, checkbox, badge, and disclosure parts at every rendered depth. Declarative children stay
@@ -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{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{composedParentElement,hasRealContent,isAccessibilityVisible,nextId}from"../../../internal/a11y.js";import{composedAccessibilityText}from"../../../internal/accessibility-visibility.js";import{chevronIcon}from"../../../internal/icons.js";import{finiteDuration}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/form-associated.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{cascadeUpdateComplete}from"./update-cascade.js";import{styles}from"./tree-item.styles.js";import{treeItemOwnerContext}from"./tree-owner-controller.js";import{TREE_MAX_RENDER_DEPTH,TREE_MAX_RENDER_NODES}from"./tree-types.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";const CHILDREN_SLOT="children",TREE_ITEM_EXPORT_PARTS=["base","tree-item","row","toggle","icon","content","label","description","badge","group","item","item--disabled","item--expanded","item--indeterminate","item--selected","indentation","expand-button","spinner","spinner__base","children","checkbox","checkbox__base","checkbox__control","checkbox__control--checked","checkbox__control--indeterminate","checkbox__checked-icon","checkbox__indeterminate-icon","checkbox__label"].join(", ");class LyraTreeItem extends LyraElement{constructor(){super(...arguments),this.itemInternals=attachInternalsSafely(this),this.managedItemAriaLabel=null,this.writingItemAriaLabel=!1,this.label="",this.disabled=!1,this.selected=!1,this.expanded=!1,this.lazy=!1,this._loading=!1,this.lifecycleGeneration=0,this.lazyGeneration=0,this._collapsing=!1,this.handleLabelSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||target.getRootNode()!==this.renderRoot&&!this.labelForwardingSlots().includes(target)||(this.bindChildObserverTargets(),this.requestUpdate())},this.slottedLabel=!1,this.slottedChildren=!1,this.onToggleMouseDown=e=>{e.preventDefault(),!this.isDisabled&&this.focus()},this.onTogglePointerDown=event=>{const toggle=event.currentTarget;toggle?.nodeType===1&&(toggle.setAttribute("data-pressed",""),toggle.setPointerCapture(event.pointerId))},this.onTogglePointerEnd=event=>{const toggle=event.currentTarget;toggle?.nodeType===1&&(toggle.removeAttribute("data-pressed"),toggle.hasPointerCapture(event.pointerId)&&toggle.releasePointerCapture(event.pointerId))}}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired}}static{this.immutableEventDetails=Object.freeze(["lr-expand","lr-after-expand","lr-collapse","lr-after-collapse","lr-lazy-change","lr-lazy-load"])}static{this.identityEventDetailProperties=Object.freeze({"lr-expand":Object.freeze(["item"]),"lr-after-expand":Object.freeze(["item"]),"lr-collapse":Object.freeze(["item"]),"lr-after-collapse":Object.freeze(["item"]),"lr-lazy-change":Object.freeze(["item"]),"lr-lazy-load":Object.freeze(["item"])})}static{this.styles=[LyraElement.styles,styles]}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="aria-label"&&!this.writingItemAriaLabel&&(this.managedItemAriaLabel=null)}get item(){return this._item}set item(value){const old=this._item;if(old===value)return;this._item=value,this.selected=!!value?.selected,this.lazy=!!value?.lazy;const hasResolvedChildren=!!value?.children?.length;this._loading&&(hasResolvedChildren||!this.lazy)&&this.finishLazyLoad(this.lazyGeneration,hasResolvedChildren),this.requestUpdate("item",old)}get loading(){return this._loading}get indeterminate(){return this.ownerContext.indeterminate}get ownerContext(){return treeItemOwnerContext(this)}get nodeId(){return this.item?this.item.id:this.generatedId??=nextId("tree-item")}get isDisabled(){return this.item?!!(this.item.disabled||this.hasDuplicateDataId):this.disabled}get hasDuplicateDataId(){const context=this.ownerContext.identity,item=this.item;return!!(context&&item&&context.collisionIds.has(item.id)&&context.ownerPaths.get(item.id)!==context.path)}get nodeLabel(){const ariaLabel=this.getAttribute("aria-label");return ariaLabel!==null?ariaLabel:this.item?this.item.accessibleLabel||this.item.label:this.slottedLabelText||this.label}syncItemAriaLabel(){const current=this.getAttribute("aria-label");if(this.managedItemAriaLabel===null&&current!==null)return;const next=this.item?.accessibleLabel||null;if(next===null){if(this.managedItemAriaLabel!==null&&current===this.managedItemAriaLabel){this.writingItemAriaLabel=!0;try{this.removeAttribute("aria-label")}finally{this.writingItemAriaLabel=!1}}this.managedItemAriaLabel=null;return}if(current!==next){this.writingItemAriaLabel=!0;try{this.setAttribute("aria-label",next)}finally{this.writingItemAriaLabel=!1}}this.managedItemAriaLabel=next}childItems(){return this.item?[...this.shadowRoot?.querySelectorAll(tag("tree-item"))??[]]:[...this.children].filter(child=>this.isChildItem(child))}getChildrenItems({includeDisabled=!0}={}){const children=this.childItems();return includeDisabled?children:children.filter(child=>!child.isDisabled)}isChildItem(node){return node.nodeType===1&&node.localName===tag("tree-item")}isDeclarativeLabelNode(node){if(this.isChildItem(node))return!1;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.isDeclarativeLabelNode(top)})}get slottedLabelText(){return composedAccessibilityText(this.declarativeLabelRoots(),{requireRendered:!1,shouldPruneNode:node=>{if(this.contains(node))return!1;const target=node.nodeType===1?node:node.parentElement;return target===null||!isAccessibilityVisible(target)},skipRootAncestorValidation:!0}).replace(/\s+/g," ").trim()}declarativeLabelRoots(){const childNodes=this.childNodes;return childNodes?Array.from(childNodes).filter(node=>this.isDeclarativeLabelNode(node)):[]}declarativeLabelNodes(){const renderRoot=this.renderRoot;if(!renderRoot)return[];const slot=renderRoot.querySelector("slot:not([name])");return slot?slot.assignedNodes({flatten:!0}):this.declarativeLabelRoots().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)})}get hasSlottedLabel(){return hasRealContent(this.declarativeLabelNodes())}assignChildSlots(){for(const child of this.children)this.isChildItem(child)&&child.getAttribute("slot")!==CHILDREN_SLOT&&child.setAttribute("slot",CHILDREN_SLOT)}observeLabelNode(node){if(this.childObserver){if(node.nodeType===3){this.childObserver.observe(node,{characterData:!0});return}node.nodeType===1&&this.childObserver.observe(node,{attributes:!0,attributeFilter:["alt","aria-hidden","aria-label","aria-labelledby","class","hidden","id","inert","open","slot","style"],childList:!0,characterData:!0,subtree:!0})}}composedParentForLabelNode(node){const assignedSlot=node.assignedSlot;if(assignedSlot)return assignedSlot;if(node.parentElement)return node.parentElement;const root=node.getRootNode();return"host"in root&&root.host.nodeType===1?root.host:null}observeLabelAncestors(node){const observer=this.childObserver;if(!observer)return;let ancestor=this.composedParentForLabelNode(node);for(;ancestor;)ancestor!==this&&!this.contains(ancestor)&&observer.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","class","hidden","inert","open","style"]}),ancestor=composedParentElement(ancestor)}bindChildObserverTargets(){if(this.childObserver){this.childObserver.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),this.observeLabelAncestors(assigned)}}sampleLightDomState(){this.slottedLabel=this.hasSlottedLabel,this.slottedChildren=!this.item&&this.hasChildren}connectedCallback(){super.connectedCallback(),this.assignChildSlots(),this.hasUpdated&&this.sampleLightDomState(),this.rebuildChildObserver(),this.addEventListener("slotchange",this.handleLabelSlotChange)}disconnectedCallback(){this.removeEventListener("slotchange",this.handleLabelSlotChange),this.childObserver?.disconnect(),this.childObserver=void 0,this.lifecycleGeneration++,this.lazyGeneration++,this.cancelLifecycleTimer(),this._loading=!1,this.lazy&&(this.expanded=!1),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.rebuildChildObserver()}rebuildChildObserver(){this.childObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;this.childObserver=MutationObserverCtor?new MutationObserverCtor(()=>{this.assignChildSlots(),this.bindChildObserverTargets(),this.requestUpdate(),this._loading&&this.actualChildItems().length>0&&this.finishLazyLoad(this.lazyGeneration)}):void 0,this.bindChildObserverTargets()}actualChildItems(){return this.childItems()}get hasChildren(){const context=this.ownerContext;return context.depth>=TREE_MAX_RENDER_DEPTH?!1:this.item?!!(this.lazy||this.item.children?.length&&!context.ancestry.includes(this.item)):this.lazy||this.childItems().length>0}willUpdate(changed){super.willUpdate(changed),this.assignChildSlots(),this.hasUpdated?this.sampleLightDomState():this.seedFirstRenderState(()=>this.sampleLightDomState()),(changed.has("item")||changed.has("disabled"))&&this.isDisabled&&this.expanded&&(this.expanded=!1),(changed.has("item")||changed.has("disabled"))&&this.isDisabled&&this._loading&&this.cancelLazyLoad(!0),changed.has("lazy")&&this._loading&&!this.lazy&&this.finishLazyLoad(this.lazyGeneration,this.actualChildItems().length>0),this.setAttribute("role","treeitem");const context=this.ownerContext;this.setAttribute("aria-level",String(context.depth+1)),this.setAttribute("aria-setsize",String(context.setSize)),this.setAttribute("aria-posinset",String(context.posInSet)),this.hasChildren?this.setAttribute("aria-expanded",String(this.expanded)):this.removeAttribute("aria-expanded"),this.syncItemAriaLabel(),this.multipleSelection?(this.setAttribute("aria-checked",context.indeterminate?"mixed":String(this.selected)),this.removeAttribute("aria-selected")):(this.removeAttribute("aria-checked"),context.ownsSelection||!this.item||this.item.selected!==void 0?this.setAttribute("aria-selected",String(this.selected)):this.removeAttribute("aria-selected")),this.setAttribute("aria-disabled",String(this.isDisabled)),this._loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.tabIndex=!this.isDisabled&&this.nodeId===context.activeId?0:-1,setCustomState(this.itemInternals,"disabled",this.isDisabled),setCustomState(this.itemInternals,"expanded",this.expanded),setCustomState(this.itemInternals,"indeterminate",context.indeterminate),setCustomState(this.itemInternals,"selected",this.selected)}expand(){if(!(this.isDisabled||this._loading||this.expanded)){if(this.lazy){this.beginLazyLoad();return}this.hasChildren&&this.commitExpanded(!0)}}commitExpanded(expanded){this.expanded!==expanded&&(this.lifecycleGeneration++,this.cancelLifecycleTimer(),this._collapsing=!expanded,this.expanded=expanded,this.emit(expanded?"lr-expand":"lr-collapse",{item:this}),this.emit("lr-node-toggle",{nodeId:this.nodeId,expanded}),this.scheduleAfterEvent(expanded,this.lifecycleGeneration))}beginLazyLoad(){if(this._loading||this.isDisabled)return;this._loading=!0;const generation=++this.lazyGeneration;this.emit("lr-lazy-change",{item:this,loading:!0}),this.emit("lr-lazy-load",{item:this,generation})}finishLazyLoad(generation,hasResolvedChildren=this.actualChildItems().length>0){!this._loading||generation!==this.lazyGeneration||(this._loading=!1,this.emit("lr-lazy-change",{item:this,loading:!1}),!(!this.isConnected||this.isDisabled||!hasResolvedChildren)&&this.commitExpanded(!0))}cancelLazyLoad(emitChange){this._loading&&(this.lazyGeneration++,this._loading=!1,emitChange&&this.emit("lr-lazy-change",{item:this,loading:!1}))}scheduleAfterEvent(expanded,generation){const owner=this.ownerDocument.defaultView;owner&&this.updateComplete.then(()=>{if(generation!==this.lifecycleGeneration||!this.isConnected||this.expanded!==expanded||this.ownerDocument.defaultView!==owner)return;const animationNode=this.renderRoot.querySelector('[part="children"]'),duration=this.motionDuration(expanded,owner),finish=()=>{if(this.cancelLifecycleTimer(),!(generation!==this.lifecycleGeneration||!this.isConnected||this.expanded!==expanded||this.ownerDocument.defaultView!==owner)){if(!expanded&&this._collapsing){this._collapsing=!1,this.updateComplete.then(()=>{generation===this.lifecycleGeneration&&this.isConnected&&!this.expanded&&!this._collapsing&&this.ownerDocument.defaultView===owner&&this.emit("lr-after-collapse",{item:this})});return}this.emit("lr-after-expand",{item:this})}},computedAnimation=animationNode?owner.getComputedStyle(animationNode).animationName:"none";if(!animationNode||duration===0||computedAnimation==="none"){finish();return}const listener=event=>{event.target===animationNode&&finish()};animationNode.addEventListener("animationend",listener),this.lifecycleAnimation={node:animationNode,listener};const timer={owner,handle:0};timer.handle=owner.setTimeout(finish,duration),this.lifecycleTimer=timer})}cancelLifecycleTimer(){const animation=this.lifecycleAnimation;animation&&(this.lifecycleAnimation=void 0,animation.node.removeEventListener("animationend",animation.listener));const timer=this.lifecycleTimer;timer&&(this.lifecycleTimer=void 0,timer.owner.clearTimeout(timer.handle))}motionDuration(expanded,owner){if(prefersReducedMotion(owner))return 0;const property2=expanded?"--show-duration":"--hide-duration",ownStyle=owner.getComputedStyle(this),raw=ownStyle.getPropertyValue(property2).trim()||ownStyle.getPropertyValue("--lr-duration-base").trim(),match=/^([0-9]*\.?[0-9]+)(ms|s)$/.exec(raw);if(!match)return 0;const amount=Number(match[1]);return!Number.isFinite(amount)||amount<0?0:finiteDuration(match[2]==="s"?amount*1e3:amount,0)}collapse(){this.isDisabled||!this.hasChildren||!this.expanded||this.commitExpanded(!1)}select(){this.isDisabled||(this.emit("lr-node-select",{nodeId:this.nodeId}),this.focus())}click(){if(this.isDisabled)return;const row=this.renderRoot.querySelector('[part="row"]');row?row.click():this.select()}async getUpdateComplete(){const result=await super.getUpdateComplete(),context=this.ownerContext;return context.ownsSelection&&context.depth<TREE_MAX_RENDER_DEPTH&&await cascadeUpdateComplete(this.childItems().slice(0,TREE_MAX_RENDER_NODES)),result}get multipleSelection(){const selection=this.ownerContext.selection;return selection==="multiple"||selection==="leaf-multiple"}itemPartNames(){return["item",this.isDisabled?"item--disabled":"",this.expanded?"item--expanded":"",this.indeterminate?"item--indeterminate":"",this.selected?"item--selected":""].filter(Boolean).join(" ")}inheritedIcon(source){if(!source)return nothing;const clone=source.cloneNode(!0);return clone.removeAttribute("slot"),clone.removeAttribute("id"),clone.setAttribute("aria-hidden","true"),clone}renderDisclosureIcon(){const slotName=this.expanded?"expand-icon":"collapse-icon",context=this.ownerContext,inherited=this.inheritedIcon(this.expanded?context.expandIcon:context.collapseIcon);return html`<slot name=${slotName}>${inherited===nothing?chevronIcon():inherited}</slot>`}renderSpinner(){return html`<span part="spinner" aria-hidden="true"><span part="spinner__base"></span></span>`}renderCheckbox(){if(!this.multipleSelection)return nothing;const controlParts=["checkbox__control",this.selected?"checkbox__control--checked":"",this.indeterminate?"checkbox__control--indeterminate":""].filter(Boolean).join(" ");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,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{composedParentElement,hasRealContent,isAccessibilityVisible,nextId}from"../../../internal/a11y.js";import{composedAccessibilityText}from"../../../internal/accessibility-visibility.js";import{chevronIcon}from"../../../internal/icons.js";import{finiteDuration}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/form-associated.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{cascadeUpdateComplete}from"./update-cascade.js";import{styles}from"./tree-item.styles.js";import{treeItemOwnerContext}from"./tree-owner-controller.js";import{TREE_MAX_RENDER_DEPTH,TREE_MAX_RENDER_NODES}from"./tree-types.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings.generated.js";const CHILDREN_SLOT="children",TREE_ITEM_EXPORT_PARTS=["base","tree-item","row","toggle","icon","content","label","description","badge","group","item","item--disabled","item--expanded","item--indeterminate","item--selected","indentation","expand-button","spinner","spinner__base","children","checkbox","checkbox__base","checkbox__control","checkbox__control--checked","checkbox__control--indeterminate","checkbox__checked-icon","checkbox__indeterminate-icon","checkbox__label"].join(", ");class LyraTreeItem extends LyraElement{constructor(){super(...arguments),this.itemInternals=attachInternalsSafely(this),this.managedItemAriaLabel=null,this.writingItemAriaLabel=!1,this.label="",this.disabled=!1,this.selected=!1,this.expanded=!1,this.lazy=!1,this._loading=!1,this.lifecycleGeneration=0,this.lazyGeneration=0,this._collapsing=!1,this.handleLabelSlotChange=event=>{const target=event.target;target?.nodeType!==1||target.localName!=="slot"||target.getRootNode()!==this.renderRoot&&!this.labelForwardingSlots().includes(target)||(this.bindChildObserverTargets(),this.requestUpdate())},this.slottedLabel=!1,this.slottedChildren=!1,this.onToggleMouseDown=e=>{e.preventDefault(),!this.isDisabled&&this.focus()},this.onTogglePointerDown=event=>{const toggle=event.currentTarget;toggle?.nodeType===1&&(toggle.setAttribute("data-pressed",""),toggle.setPointerCapture(event.pointerId))},this.onTogglePointerEnd=event=>{const toggle=event.currentTarget;toggle?.nodeType===1&&(toggle.removeAttribute("data-pressed"),toggle.hasPointerCapture(event.pointerId)&&toggle.releasePointerCapture(event.pointerId))}}static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired}}static{this.immutableEventDetails=Object.freeze(["lr-expand","lr-after-expand","lr-collapse","lr-after-collapse","lr-lazy-change","lr-lazy-load"])}static{this.identityEventDetailProperties=Object.freeze({"lr-expand":Object.freeze(["item"]),"lr-after-expand":Object.freeze(["item"]),"lr-collapse":Object.freeze(["item"]),"lr-after-collapse":Object.freeze(["item"]),"lr-lazy-change":Object.freeze(["item"]),"lr-lazy-load":Object.freeze(["item"])})}static{this.styles=[LyraElement.styles,styles]}attributeChangedCallback(name,oldValue,value){super.attributeChangedCallback(name,oldValue,value),name==="aria-label"&&!this.writingItemAriaLabel&&(this.managedItemAriaLabel=null)}get item(){return this._item}set item(value){const old=this._item;if(old===value)return;this._item=value,this.selected=!!value?.selected,this.lazy=!!value?.lazy;const hasResolvedChildren=!!value?.children?.length;this._loading&&(hasResolvedChildren||!this.lazy)&&this.finishLazyLoad(this.lazyGeneration,hasResolvedChildren),this.requestUpdate("item",old)}get loading(){return this._loading}get indeterminate(){return this.ownerContext.indeterminate}get ownerContext(){return treeItemOwnerContext(this)}get nodeId(){return this.item?this.item.id:this.generatedId??=nextId("tree-item")}get isDisabled(){return this.item?!!(this.item.disabled||this.hasDuplicateDataId):this.disabled}get hasDuplicateDataId(){const context=this.ownerContext.identity,item=this.item;return!!(context&&item&&context.collisionIds.has(item.id)&&context.ownerPaths.get(item.id)!==context.path)}get nodeLabel(){const ariaLabel=this.getAttribute("aria-label");return ariaLabel!==null?ariaLabel:this.item?this.item.accessibleLabel||this.item.label:this.slottedLabelText||this.label}syncItemAriaLabel(){const current=this.getAttribute("aria-label");if(this.managedItemAriaLabel===null&&current!==null)return;const item=this.item;let next=item?.accessibleLabel||null;if(item&&!this.hasAttribute("aria-labelledby")&&!next?.trim()&&!item.label.trim()&&!item.description?.trim()&&!item.badges?.some(badge=>badge.label?.trim()||badge.text.trim())&&(next=item.id),next===null){if(this.managedItemAriaLabel!==null&&current===this.managedItemAriaLabel){this.writingItemAriaLabel=!0;try{this.removeAttribute("aria-label")}finally{this.writingItemAriaLabel=!1}}this.managedItemAriaLabel=null;return}if(current!==next){this.writingItemAriaLabel=!0;try{this.setAttribute("aria-label",next)}finally{this.writingItemAriaLabel=!1}}this.managedItemAriaLabel=next}childItems(){return this.item?[...this.shadowRoot?.querySelectorAll(tag("tree-item"))??[]]:[...this.children].filter(child=>this.isChildItem(child))}getChildrenItems({includeDisabled=!0}={}){const children=this.childItems();return includeDisabled?children:children.filter(child=>!child.isDisabled)}isChildItem(node){return node.nodeType===1&&node.localName===tag("tree-item")}isDeclarativeLabelNode(node){if(this.isChildItem(node))return!1;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.isDeclarativeLabelNode(top)})}get slottedLabelText(){return composedAccessibilityText(this.declarativeLabelRoots(),{requireRendered:!1,shouldPruneNode:node=>{if(this.contains(node))return!1;const target=node.nodeType===1?node:node.parentElement;return target===null||!isAccessibilityVisible(target)},skipRootAncestorValidation:!0}).replace(/\s+/g," ").trim()}declarativeLabelRoots(){const childNodes=this.childNodes;return childNodes?Array.from(childNodes).filter(node=>this.isDeclarativeLabelNode(node)):[]}declarativeLabelNodes(){const renderRoot=this.renderRoot;if(!renderRoot)return[];const slot=renderRoot.querySelector("slot:not([name])");return slot?slot.assignedNodes({flatten:!0}):this.declarativeLabelRoots().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)})}get hasSlottedLabel(){return hasRealContent(this.declarativeLabelNodes())}assignChildSlots(){for(const child of this.children)this.isChildItem(child)&&child.getAttribute("slot")!==CHILDREN_SLOT&&child.setAttribute("slot",CHILDREN_SLOT)}observeLabelNode(node){if(this.childObserver){if(node.nodeType===3){this.childObserver.observe(node,{characterData:!0});return}node.nodeType===1&&this.childObserver.observe(node,{attributes:!0,attributeFilter:["alt","aria-hidden","aria-label","aria-labelledby","class","hidden","id","inert","open","slot","style"],childList:!0,characterData:!0,subtree:!0})}}composedParentForLabelNode(node){const assignedSlot=node.assignedSlot;if(assignedSlot)return assignedSlot;if(node.parentElement)return node.parentElement;const root=node.getRootNode();return"host"in root&&root.host.nodeType===1?root.host:null}observeLabelAncestors(node){const observer=this.childObserver;if(!observer)return;let ancestor=this.composedParentForLabelNode(node);for(;ancestor;)ancestor!==this&&!this.contains(ancestor)&&observer.observe(ancestor,{attributes:!0,attributeFilter:["aria-hidden","class","hidden","inert","open","style"]}),ancestor=composedParentElement(ancestor)}bindChildObserverTargets(){if(this.childObserver){this.childObserver.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),this.observeLabelAncestors(assigned)}}sampleLightDomState(){this.slottedLabel=this.hasSlottedLabel,this.slottedChildren=!this.item&&this.hasChildren}connectedCallback(){super.connectedCallback(),this.assignChildSlots(),this.hasUpdated&&this.sampleLightDomState(),this.rebuildChildObserver(),this.addEventListener("slotchange",this.handleLabelSlotChange)}disconnectedCallback(){this.removeEventListener("slotchange",this.handleLabelSlotChange),this.childObserver?.disconnect(),this.childObserver=void 0,this.lifecycleGeneration++,this.lazyGeneration++,this.cancelLifecycleTimer(),this._loading=!1,this.lazy&&(this.expanded=!1),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.rebuildChildObserver()}rebuildChildObserver(){this.childObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;this.childObserver=MutationObserverCtor?new MutationObserverCtor(()=>{this.assignChildSlots(),this.bindChildObserverTargets(),this.requestUpdate(),this._loading&&this.actualChildItems().length>0&&this.finishLazyLoad(this.lazyGeneration)}):void 0,this.bindChildObserverTargets()}actualChildItems(){return this.childItems()}get hasChildren(){const context=this.ownerContext;return context.depth>=TREE_MAX_RENDER_DEPTH?!1:this.item?!!(this.lazy||this.item.children?.length&&!context.ancestry.includes(this.item)):this.lazy||this.childItems().length>0}willUpdate(changed){super.willUpdate(changed),this.assignChildSlots(),this.hasUpdated?this.sampleLightDomState():this.seedFirstRenderState(()=>this.sampleLightDomState()),(changed.has("item")||changed.has("disabled"))&&this.isDisabled&&this.expanded&&(this.expanded=!1),(changed.has("item")||changed.has("disabled"))&&this.isDisabled&&this._loading&&this.cancelLazyLoad(!0),changed.has("lazy")&&this._loading&&!this.lazy&&this.finishLazyLoad(this.lazyGeneration,this.actualChildItems().length>0),this.setAttribute("role","treeitem");const context=this.ownerContext;this.setAttribute("aria-level",String(context.depth+1)),this.setAttribute("aria-setsize",String(context.setSize)),this.setAttribute("aria-posinset",String(context.posInSet)),this.hasChildren?this.setAttribute("aria-expanded",String(this.expanded)):this.removeAttribute("aria-expanded"),this.syncItemAriaLabel(),this.multipleSelection?(this.setAttribute("aria-checked",context.indeterminate?"mixed":String(this.selected)),this.removeAttribute("aria-selected")):(this.removeAttribute("aria-checked"),context.ownsSelection||!this.item||this.item.selected!==void 0?this.setAttribute("aria-selected",String(this.selected)):this.removeAttribute("aria-selected")),this.setAttribute("aria-disabled",String(this.isDisabled)),this._loading?this.setAttribute("aria-busy","true"):this.removeAttribute("aria-busy"),this.tabIndex=!this.isDisabled&&this.nodeId===context.activeId?0:-1,setCustomState(this.itemInternals,"disabled",this.isDisabled),setCustomState(this.itemInternals,"expanded",this.expanded),setCustomState(this.itemInternals,"indeterminate",context.indeterminate),setCustomState(this.itemInternals,"selected",this.selected)}expand(){if(!(this.isDisabled||this._loading||this.expanded)){if(this.lazy){this.beginLazyLoad();return}this.hasChildren&&this.commitExpanded(!0)}}commitExpanded(expanded){this.expanded!==expanded&&(this.lifecycleGeneration++,this.cancelLifecycleTimer(),this._collapsing=!expanded,this.expanded=expanded,this.emit(expanded?"lr-expand":"lr-collapse",{item:this}),this.emit("lr-node-toggle",{nodeId:this.nodeId,expanded}),this.scheduleAfterEvent(expanded,this.lifecycleGeneration))}beginLazyLoad(){if(this._loading||this.isDisabled)return;this._loading=!0;const generation=++this.lazyGeneration;this.emit("lr-lazy-change",{item:this,loading:!0}),this.emit("lr-lazy-load",{item:this,generation})}finishLazyLoad(generation,hasResolvedChildren=this.actualChildItems().length>0){!this._loading||generation!==this.lazyGeneration||(this._loading=!1,this.emit("lr-lazy-change",{item:this,loading:!1}),!(!this.isConnected||this.isDisabled||!hasResolvedChildren)&&this.commitExpanded(!0))}cancelLazyLoad(emitChange){this._loading&&(this.lazyGeneration++,this._loading=!1,emitChange&&this.emit("lr-lazy-change",{item:this,loading:!1}))}scheduleAfterEvent(expanded,generation){const owner=this.ownerDocument.defaultView;owner&&this.updateComplete.then(()=>{if(generation!==this.lifecycleGeneration||!this.isConnected||this.expanded!==expanded||this.ownerDocument.defaultView!==owner)return;const animationNode=this.renderRoot.querySelector('[part="children"]'),duration=this.motionDuration(expanded,owner),finish=()=>{if(this.cancelLifecycleTimer(),!(generation!==this.lifecycleGeneration||!this.isConnected||this.expanded!==expanded||this.ownerDocument.defaultView!==owner)){if(!expanded&&this._collapsing){this._collapsing=!1,this.updateComplete.then(()=>{generation===this.lifecycleGeneration&&this.isConnected&&!this.expanded&&!this._collapsing&&this.ownerDocument.defaultView===owner&&this.emit("lr-after-collapse",{item:this})});return}this.emit("lr-after-expand",{item:this})}},computedAnimation=animationNode?owner.getComputedStyle(animationNode).animationName:"none";if(!animationNode||duration===0||computedAnimation==="none"){finish();return}const listener=event=>{event.target===animationNode&&finish()};animationNode.addEventListener("animationend",listener),this.lifecycleAnimation={node:animationNode,listener};const timer={owner,handle:0};timer.handle=owner.setTimeout(finish,duration),this.lifecycleTimer=timer})}cancelLifecycleTimer(){const animation=this.lifecycleAnimation;animation&&(this.lifecycleAnimation=void 0,animation.node.removeEventListener("animationend",animation.listener));const timer=this.lifecycleTimer;timer&&(this.lifecycleTimer=void 0,timer.owner.clearTimeout(timer.handle))}motionDuration(expanded,owner){if(prefersReducedMotion(owner))return 0;const property2=expanded?"--show-duration":"--hide-duration",ownStyle=owner.getComputedStyle(this),raw=ownStyle.getPropertyValue(property2).trim()||ownStyle.getPropertyValue("--lr-duration-base").trim(),match=/^([0-9]*\.?[0-9]+)(ms|s)$/.exec(raw);if(!match)return 0;const amount=Number(match[1]);return!Number.isFinite(amount)||amount<0?0:finiteDuration(match[2]==="s"?amount*1e3:amount,0)}collapse(){this.isDisabled||!this.hasChildren||!this.expanded||this.commitExpanded(!1)}select(){this.isDisabled||(this.emit("lr-node-select",{nodeId:this.nodeId}),this.focus())}click(){if(this.isDisabled)return;const row=this.renderRoot.querySelector('[part="row"]');row?row.click():this.select()}async getUpdateComplete(){const result=await super.getUpdateComplete(),context=this.ownerContext;return context.ownsSelection&&context.depth<TREE_MAX_RENDER_DEPTH&&await cascadeUpdateComplete(this.childItems().slice(0,TREE_MAX_RENDER_NODES)),result}get multipleSelection(){const selection=this.ownerContext.selection;return selection==="multiple"||selection==="leaf-multiple"}itemPartNames(){return["item",this.isDisabled?"item--disabled":"",this.expanded?"item--expanded":"",this.indeterminate?"item--indeterminate":"",this.selected?"item--selected":""].filter(Boolean).join(" ")}inheritedIcon(source){if(!source)return nothing;const clone=source.cloneNode(!0);return clone.removeAttribute("slot"),clone.removeAttribute("id"),clone.setAttribute("aria-hidden","true"),clone}renderDisclosureIcon(){const slotName=this.expanded?"expand-icon":"collapse-icon",context=this.ownerContext,inherited=this.inheritedIcon(this.expanded?context.expandIcon:context.collapseIcon);return html`<slot name=${slotName}>${inherited===nothing?chevronIcon():inherited}</slot>`}renderSpinner(){return html`<span part="spinner" aria-hidden="true"><span part="spinner__base"></span></span>`}renderCheckbox(){if(!this.multipleSelection)return nothing;const controlParts=["checkbox__control",this.selected?"checkbox__control--checked":"",this.indeterminate?"checkbox__control--indeterminate":""].filter(Boolean).join(" ");return html`
2
2
  <span
3
3
  part="checkbox"
4
4
  aria-hidden="true"
@@ -71,7 +71,10 @@ export declare class LyraTree extends LyraElement<LyraTreeEventMap>{protected st
71
71
  * later duplicate occurrences fail closed as disabled rows so one public id can never own
72
72
  * multiple actions. Reassign after changes. */
73
73
  private _data;private declaredChildrenAtPath;private declaredRootCount;private _dataTruncated;
74
- /** Clone-owned/frozen object child model.
74
+ /** Clone-owned/frozen object child model. Normalization retains at most 1,000 nodes over 64
75
+ * descendant levels and inspects at most 10,000 root/child array positions in depth-first order.
76
+ * An otherwise unnamed projected row uses its stable data ID as its semantic name, without
77
+ * changing its visible label or the installed data.
75
78
  * @default [] */
76
79
  get data():readonly LyraTreeNodeData[];set data(value:readonly LyraTreeNodeData[]);
77
80
  /** Whether normalization omitted malformed, over-depth, or over-budget data. */
@@ -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);
@@ -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>`.