@aceshooting/lyra-ui 29.2.2 → 30.0.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 (440) hide show
  1. package/CHANGELOG.md +126 -106
  2. package/README.md +8 -7
  3. package/dist/ai/snapshot.js +1 -1
  4. package/dist/all.d.ts +1 -1
  5. package/dist/all.js +1 -1
  6. package/dist/autoloader.js +1 -1
  7. package/dist/cli/component-inventory.mjs +1 -1
  8. package/dist/cli/lyra-rename-ledger.mjs +1 -1
  9. package/dist/cli/migrate-wa.mjs +7 -3
  10. package/dist/cli/migration-analysis.mjs +1 -1
  11. package/dist/cli/migration-contract.json +1 -1
  12. package/dist/cli/migration-contract.mjs +1 -1
  13. package/dist/cli/migration-immutable-collections.mjs +6 -0
  14. package/dist/cli/migration-renames.mjs +1 -1
  15. package/dist/cli/migration-transforms.mjs +1 -1
  16. package/dist/components/agent-tools/activity-feed/activity-feed.class.d.ts +1 -1
  17. package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.d.ts +1 -2
  18. package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.js +1 -1
  19. package/dist/components/agent-tools/agent-run/agent-run.class.d.ts +3 -4
  20. package/dist/components/agent-tools/agent-run/agent-run.class.js +1 -1
  21. package/dist/components/agent-tools/agent-trace/agent-trace.class.d.ts +1 -1
  22. package/dist/components/agent-tools/agent-trace/agent-trace.class.js +2 -2
  23. package/dist/components/agent-tools/background-runs/background-runs.class.d.ts +1 -2
  24. package/dist/components/agent-tools/background-runs/background-runs.class.js +1 -1
  25. package/dist/components/agent-tools/change-review/change-review.class.d.ts +1 -2
  26. package/dist/components/agent-tools/change-review/change-review.class.js +1 -1
  27. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.d.ts +3 -2
  28. package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
  29. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +7 -1
  30. package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -1
  31. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.d.ts +2 -2
  32. package/dist/components/agent-tools/prompt-studio/prompt-studio.class.js +3 -3
  33. package/dist/components/agent-tools/span-waterfall/span-waterfall.class.d.ts +1 -1
  34. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.d.ts +1 -2
  35. package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +2 -2
  36. package/dist/components/agent-tools/task-list/task-list.class.d.ts +1 -1
  37. package/dist/components/agent-tools/test-results/test-results.class.d.ts +1 -1
  38. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +3 -4
  39. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +1 -5
  40. package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +3 -3
  41. package/dist/components/agent-tools/trace-tree/trace-tree.class.d.ts +1 -0
  42. package/dist/components/agent-tools/trace-tree/trace-tree.class.js +1 -1
  43. package/dist/components/charts/chart/chart.class.js +3 -3
  44. package/dist/components/charts/chart-3d/chart-3d-data.d.ts +50 -0
  45. package/dist/components/charts/chart-3d/chart-3d-data.js +1 -0
  46. package/dist/components/charts/chart-3d/chart-3d-engine.js +1 -0
  47. package/dist/components/charts/chart-3d/chart-3d.class.d.ts +96 -0
  48. package/dist/components/charts/chart-3d/chart-3d.class.js +47 -0
  49. package/dist/components/charts/chart-3d/chart-3d.d.ts +1 -0
  50. package/dist/components/charts/chart-3d/chart-3d.js +1 -0
  51. package/dist/components/charts/chart-3d/chart-3d.styles.js +1 -0
  52. package/dist/components/charts/index.d.ts +1 -1
  53. package/dist/components/charts/index.js +1 -1
  54. package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +3 -3
  55. package/dist/components/conversation/agent-workspace/agent-workspace.class.js +4 -5
  56. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  57. package/dist/components/conversation/code-block/shiki-oniguruma.d.ts +3 -0
  58. package/dist/components/conversation/code-block/shiki-oniguruma.js +1 -0
  59. package/dist/components/conversation/code-block/shiki-types.d.ts +3 -5
  60. package/dist/components/conversation/code-block/shiki-types.js +1 -1
  61. package/dist/components/conversation/generation-metrics/generation-metrics.class.js +1 -1
  62. package/dist/components/conversation/markdown/markdown-progressive.js +1 -1
  63. package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
  64. package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
  65. package/dist/components/conversation/model-select/model-select.class.js +1 -1
  66. package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +1 -1
  67. package/dist/components/conversation/prompt-input/prompt-input.class.js +3 -4
  68. package/dist/components/conversation/prompt-queue/prompt-queue.class.d.ts +1 -1
  69. package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
  70. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
  71. package/dist/components/conversation/thread-list/thread-list.class.d.ts +2 -2
  72. package/dist/components/conversation/thread-list/thread-list.class.js +1 -1
  73. package/dist/components/conversation/widget-renderer/registry.js +1 -1
  74. package/dist/components/conversation/widget-renderer/resolve.js +1 -1
  75. package/dist/components/data/calendar/calendar.class.d.ts +3 -1
  76. package/dist/components/data/data-grid/data-grid.class.js +2 -2
  77. package/dist/components/data/flow-canvas/flow-canvas.class.js +2 -2
  78. package/dist/components/data/flow-canvas/flow-source.js +1 -1
  79. package/dist/components/data/flow-node/flow-node.class.d.ts +2 -3
  80. package/dist/components/data/flow-node/flow-node.class.js +2 -4
  81. package/dist/components/data/heatmap/heatmap.class.js +1 -1
  82. package/dist/components/data/sparkline/sparkline.class.d.ts +0 -1
  83. package/dist/components/data/sparkline/sparkline.class.js +1 -1
  84. package/dist/components/data/table/table.class.js +1 -1
  85. package/dist/components/forms/color-picker/color-core.js +1 -1
  86. package/dist/components/forms/date-picker/calendar-core.js +1 -1
  87. package/dist/components/forms/otp-input/otp-input.class.js +1 -1
  88. package/dist/components/forms/signature-pad/signature-pad.class.d.ts +4 -3
  89. package/dist/components/forms/signature-pad/signature-pad.class.js +1 -1
  90. package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +3 -2
  91. package/dist/components/forms/swatch-picker/swatch-picker.class.js +1 -1
  92. package/dist/components/layout/app-rail/app-rail-item.class.d.ts +0 -2
  93. package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
  94. package/dist/components/layout/app-rail/app-rail.class.d.ts +3 -3
  95. package/dist/components/layout/command-palette/command-palette.class.d.ts +1 -1
  96. package/dist/components/layout/details/accordion-item.class.d.ts +1 -2
  97. package/dist/components/layout/details/accordion-item.class.js +1 -1
  98. package/dist/components/layout/dock-panel/dock-panel.class.d.ts +4 -11
  99. package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
  100. package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +1 -1
  101. package/dist/components/layout/menu/menu.class.js +1 -1
  102. package/dist/components/layout/menubar/menubar-item.class.d.ts +1 -1
  103. package/dist/components/layout/menubar/menubar.class.d.ts +1 -1
  104. package/dist/components/layout/multi-split/multi-split.class.d.ts +1 -1
  105. package/dist/components/layout/multi-split/multi-split.class.js +1 -1
  106. package/dist/components/layout/navigation-menu/navigation-menu.class.d.ts +2 -6
  107. package/dist/components/layout/navigation-menu/navigation-menu.class.js +1 -1
  108. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  109. package/dist/components/layout/virtual-list/virtual-list.class.d.ts +3 -2
  110. package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
  111. package/dist/components/layout/widget/widget.class.d.ts +5 -14
  112. package/dist/components/layout/widget/widget.class.js +2 -2
  113. package/dist/components/lr-chart-3d.js +1 -0
  114. package/dist/components/lr-model-viewer.js +1 -0
  115. package/dist/components/media/av-player/av-metadata.d.ts +1 -13
  116. package/dist/components/media/av-player/av-metadata.js +1 -1
  117. package/dist/components/media/av-player/av-player.class.js +1 -1
  118. package/dist/components/media/file-input/file-input.class.d.ts +10 -13
  119. package/dist/components/media/file-input/file-input.class.js +3 -3
  120. package/dist/components/media/file-input/file-input.styles.js +1 -1
  121. package/dist/components/media/image-viewer/image-viewer-panorama.d.ts +5 -0
  122. package/dist/components/media/image-viewer/image-viewer-panorama.js +8 -0
  123. package/dist/components/media/image-viewer/image-viewer-panorama.styles.js +1 -0
  124. package/dist/components/media/image-viewer/image-viewer.class.d.ts +29 -5
  125. package/dist/components/media/image-viewer/image-viewer.class.js +8 -5
  126. package/dist/components/media/image-viewer/image-viewer.styles.js +1 -1
  127. package/dist/components/media/map/map-anchor-controller.js +1 -0
  128. package/dist/components/media/map/map-anchor-options.d.ts +14 -0
  129. package/dist/components/media/map/map-anchor-options.js +1 -0
  130. package/dist/components/media/map/map-camera.d.ts +34 -0
  131. package/dist/components/media/map/map-camera.js +1 -0
  132. package/dist/components/media/map/map-construction-scheduler.d.ts +13 -0
  133. package/dist/components/media/map/map-construction-scheduler.js +1 -0
  134. package/dist/components/media/map/map-control-options.d.ts +39 -0
  135. package/dist/components/media/map/map-control-options.js +1 -0
  136. package/dist/components/media/map/map-controls-lifecycle.js +1 -0
  137. package/dist/components/media/map/map-cursor.js +1 -0
  138. package/dist/components/media/map/map-data-layer-model.d.ts +40 -0
  139. package/dist/components/media/map/map-data-layer-model.js +1 -0
  140. package/dist/components/media/map/map-drawing-controller.js +1 -0
  141. package/dist/components/media/map/map-drawing-gesture.js +1 -0
  142. package/dist/components/media/map/map-drawing-pan.js +1 -0
  143. package/dist/components/media/map/map-drawing-pointer.js +1 -0
  144. package/dist/components/media/map/map-drawing.d.ts +29 -0
  145. package/dist/components/media/map/map-drawing.js +1 -0
  146. package/dist/components/media/map/map-empty-style.d.ts +8 -0
  147. package/dist/components/media/map/map-empty-style.js +1 -0
  148. package/dist/components/media/map/map-engine-events.js +1 -0
  149. package/dist/components/media/map/map-export-attribution.js +1 -0
  150. package/dist/components/media/map/map-external-source-effects.js +1 -0
  151. package/dist/components/media/map/map-feature-loader-core.js +1 -0
  152. package/dist/components/media/map/map-feature-loader.js +1 -0
  153. package/dist/components/media/map/map-feature-state-router.d.ts +16 -0
  154. package/dist/components/media/map/map-feature-state-router.js +1 -0
  155. package/dist/components/media/map/map-feature-state-routes.js +1 -0
  156. package/dist/components/media/map/map-feature-state.d.ts +16 -0
  157. package/dist/components/media/map/map-feature-state.js +1 -0
  158. package/dist/components/media/map/map-hash-option.js +1 -0
  159. package/dist/components/media/map/map-hash-owner.js +1 -0
  160. package/dist/components/media/map/map-hash.js +1 -0
  161. package/dist/components/media/map/map-hit-test.d.ts +17 -0
  162. package/dist/components/media/map/map-hit-test.js +1 -0
  163. package/dist/components/media/map/map-image-admission.d.ts +7 -0
  164. package/dist/components/media/map/map-image-admission.js +1 -0
  165. package/dist/components/media/map/map-image-export-controller.js +1 -0
  166. package/dist/components/media/map/map-image-export-error.d.ts +3 -0
  167. package/dist/components/media/map/map-image-export-error.js +1 -0
  168. package/dist/components/media/map/map-image-export.d.ts +15 -0
  169. package/dist/components/media/map/map-image-export.js +5 -0
  170. package/dist/components/media/map/map-image-limits.d.ts +4 -0
  171. package/dist/components/media/map/map-image-limits.js +1 -0
  172. package/dist/components/media/map/map-image-metadata.js +3 -0
  173. package/dist/components/media/map/map-image-provider.d.ts +33 -0
  174. package/dist/components/media/map/map-image-provider.js +1 -0
  175. package/dist/components/media/map/map-images.d.ts +9 -0
  176. package/dist/components/media/map/map-images.js +1 -0
  177. package/dist/components/media/map/map-interaction-options.d.ts +26 -0
  178. package/dist/components/media/map/map-interaction-options.js +1 -0
  179. package/dist/components/media/map/map-layer-order.js +1 -0
  180. package/dist/components/media/map/map-loader.d.ts +35 -5
  181. package/dist/components/media/map/map-loader.js +1 -1
  182. package/dist/components/media/map/map-local-image-url.js +1 -0
  183. package/dist/components/media/map/map-local-image.js +1 -0
  184. package/dist/components/media/map/map-overlay-admission.d.ts +13 -0
  185. package/dist/components/media/map/map-overlay-admission.js +1 -0
  186. package/dist/components/media/map/map-owned-feature-input.js +1 -0
  187. package/dist/components/media/map/map-owned-features.js +1 -0
  188. package/dist/components/media/map/map-owned-resources.js +1 -0
  189. package/dist/components/media/map/map-paint-batch.js +1 -0
  190. package/dist/components/media/map/map-readers.js +1 -0
  191. package/dist/components/media/map/map-readiness.js +1 -0
  192. package/dist/components/media/map/map-resource-feature-loaders.js +1 -0
  193. package/dist/components/media/map/map-source-updates.js +1 -0
  194. package/dist/components/media/map/map-style-input.js +1 -0
  195. package/dist/components/media/map/map-style-lifecycle.js +1 -0
  196. package/dist/components/media/map/map-style-override-admission.d.ts +10 -0
  197. package/dist/components/media/map/map-style-override-admission.js +1 -0
  198. package/dist/components/media/map/map-style-overrides.js +1 -0
  199. package/dist/components/media/map/map-style-value.d.ts +3 -0
  200. package/dist/components/media/map/map-style-value.js +1 -0
  201. package/dist/components/media/map/map-vector-style.d.ts +10 -0
  202. package/dist/components/media/map/map-vector-style.js +1 -0
  203. package/dist/components/media/map/map.class.d.ts +558 -51
  204. package/dist/components/media/map/map.class.js +58 -11
  205. package/dist/components/media/map/map.styles.js +1 -1
  206. package/dist/components/media/qr-code/qr-code.class.d.ts +1 -3
  207. package/dist/components/media/qr-code/qr-code.class.js +1 -1
  208. package/dist/components/media/qr-code/qr-code.styles.js +1 -1
  209. package/dist/components/media/video/video.class.d.ts +25 -4
  210. package/dist/components/media/video/video.class.js +11 -3
  211. package/dist/components/media/video/video.styles.js +1 -1
  212. package/dist/components/media/video-playlist/video-playlist.class.d.ts +0 -1
  213. package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
  214. package/dist/components/overlays/chip/chip-group.class.d.ts +1 -1
  215. package/dist/components/overlays/chip/chip-group.class.js +1 -1
  216. package/dist/components/overlays/dialog/confirm.js +1 -1
  217. package/dist/components/overlays/overlay/popover.class.d.ts +1 -1
  218. package/dist/components/overlays/overlay/popover.class.js +2 -1
  219. package/dist/components/overlays/overlay/tooltip.class.js +1 -1
  220. package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.d.ts +4 -7
  221. package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.js +2 -2
  222. package/dist/components/retrieval/claim-evidence/claim-evidence.class.d.ts +2 -2
  223. package/dist/components/retrieval/community-card/community-card.class.d.ts +1 -4
  224. package/dist/components/retrieval/community-card/community-card.class.js +1 -1
  225. package/dist/components/retrieval/embedding-explorer/embedding-explorer-data.d.ts +12 -0
  226. package/dist/components/retrieval/embedding-explorer/embedding-explorer-data.js +1 -0
  227. package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -0
  228. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.d.ts +26 -7
  229. package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +35 -4
  230. package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +1 -1
  231. package/dist/components/retrieval/entity-dossier/entity-dossier.class.d.ts +3 -9
  232. package/dist/components/retrieval/graph/graph-builtin-3d-engine.js +1 -0
  233. package/dist/components/retrieval/graph/graph-engine-adapter.js +1 -0
  234. package/dist/components/retrieval/graph/graph-engine-columns.js +1 -0
  235. package/dist/components/retrieval/graph/graph-model.js +1 -1
  236. package/dist/components/retrieval/graph/graph-spatial-controller.js +13 -8
  237. package/dist/components/retrieval/graph/graph-webgl-engine.js +1 -0
  238. package/dist/components/retrieval/graph/graph.class.d.ts +18 -5
  239. package/dist/components/retrieval/graph/graph.class.js +4 -4
  240. package/dist/components/retrieval/graph/graph.styles.js +1 -1
  241. package/dist/components/retrieval/grounding-summary/grounding-summary.class.d.ts +1 -1
  242. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +1 -1
  243. package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +2 -2
  244. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +6 -3
  245. package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +3 -3
  246. package/dist/components/retrieval/memory-panel/memory-panel.class.d.ts +3 -10
  247. package/dist/components/retrieval/memory-panel/memory-panel.class.js +1 -1
  248. package/dist/components/retrieval/node-palette/node-palette.class.d.ts +1 -1
  249. package/dist/components/retrieval/path-strip/path-strip.class.d.ts +1 -4
  250. package/dist/components/retrieval/path-strip/path-strip.class.js +1 -1
  251. package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +2 -8
  252. package/dist/components/retrieval/rag-answer/rag-answer.class.d.ts +2 -2
  253. package/dist/components/retrieval/rag-answer/rag-answer.class.js +2 -3
  254. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +1 -11
  255. package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +1 -1
  256. package/dist/components/retrieval/retrieval-results/retrieval-results.class.d.ts +8 -12
  257. package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +5 -6
  258. package/dist/components/retrieval/retrieval-search/retrieval-search.class.d.ts +1 -1
  259. package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.d.ts +4 -7
  260. package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +2 -3
  261. package/dist/components/retrieval/source-card/source-card.class.d.ts +6 -9
  262. package/dist/components/retrieval/source-card/source-card.class.js +1 -1
  263. package/dist/components/retrieval/source-picker/source-picker.class.d.ts +1 -4
  264. package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
  265. package/dist/components/utility/diff-view/diff-view.class.js +1 -1
  266. package/dist/components/utility/format/format-options.js +1 -1
  267. package/dist/components/utility/icon/icon.class.d.ts +0 -5
  268. package/dist/components/utility/icon/icon.class.js +2 -2
  269. package/dist/components/utility/icon/icon.styles.js +1 -1
  270. package/dist/components/utility/json-viewer/json-viewer.class.js +1 -1
  271. package/dist/components/utility/known-date/known-date.class.d.ts +0 -3
  272. package/dist/components/utility/known-date/known-date.class.js +1 -1
  273. package/dist/components/utility/mention-popover/mention-popover.class.d.ts +3 -2
  274. package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
  275. package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
  276. package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
  277. package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
  278. package/dist/components/viewers/document-preview/document-preview.class.js +1 -1
  279. package/dist/components/viewers/document-viewer/document-viewer-kinds.d.ts +1 -1
  280. package/dist/components/viewers/document-viewer/document-viewer-kinds.js +1 -1
  281. package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
  282. package/dist/components/viewers/document-viewer/registry.d.ts +1 -69
  283. package/dist/components/viewers/document-viewer/registry.js +1 -1
  284. package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
  285. package/dist/components/viewers/email-viewer/email-viewer.class.js +1 -1
  286. package/dist/components/viewers/html-viewer/html-viewer.class.js +1 -1
  287. package/dist/components/viewers/include/include.class.js +1 -1
  288. package/dist/components/viewers/index.d.ts +1 -1
  289. package/dist/components/viewers/index.js +1 -1
  290. package/dist/components/viewers/model-viewer/model-viewer-document.js +1 -0
  291. package/dist/components/viewers/model-viewer/model-viewer-loader.js +1 -0
  292. package/dist/components/viewers/model-viewer/model-viewer-register.d.ts +1 -0
  293. package/dist/components/viewers/model-viewer/model-viewer-register.js +1 -0
  294. package/dist/components/viewers/model-viewer/model-viewer-source.d.ts +1 -0
  295. package/dist/components/viewers/model-viewer/model-viewer-source.js +1 -0
  296. package/dist/components/viewers/model-viewer/model-viewer.class.d.ts +61 -0
  297. package/dist/components/viewers/model-viewer/model-viewer.class.js +9 -0
  298. package/dist/components/viewers/model-viewer/model-viewer.d.ts +1 -0
  299. package/dist/components/viewers/model-viewer/model-viewer.js +1 -0
  300. package/dist/components/viewers/model-viewer/model-viewer.styles.js +1 -0
  301. package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +2 -2
  302. package/dist/components/viewers/page-rail/page-rail.class.js +1 -1
  303. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +1 -1
  304. package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +3 -3
  305. package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
  306. package/dist/components/viewers/table-viewer-shared.js +1 -1
  307. package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
  308. package/dist/custom-elements-jsx.d.ts +1 -1
  309. package/dist/events.d.ts +137 -92
  310. package/dist/framework-types.d.ts +2 -2
  311. package/dist/hydration.d.ts +1 -1
  312. package/dist/internal/ansi.d.ts +3 -1
  313. package/dist/internal/ansi.js +1 -1
  314. package/dist/internal/autoloader-manifest.js +1 -1
  315. package/dist/internal/autoloader-tags.d.ts +1 -1
  316. package/dist/internal/autoloader-tags.js +1 -1
  317. package/dist/internal/av-metadata.d.ts +13 -0
  318. package/dist/internal/av-metadata.js +1 -0
  319. package/dist/internal/collection-snapshot.js +1 -1
  320. package/dist/internal/component-loaders.generated.js +1 -1
  321. package/dist/internal/data-descriptors.d.ts +30 -0
  322. package/dist/internal/default-strings/agent-tools.generated.js +1 -1
  323. package/dist/internal/default-strings/charts.generated.js +1 -1
  324. package/dist/internal/default-strings/conversation.generated.js +1 -1
  325. package/dist/internal/default-strings/media.generated.js +1 -1
  326. package/dist/internal/default-strings/shared.generated.js +1 -1
  327. package/dist/internal/default-strings/viewers.generated.js +1 -1
  328. package/dist/internal/document-renderer-registry.d.ts +75 -0
  329. package/dist/internal/document-renderer-registry.js +1 -0
  330. package/dist/internal/drop-session-controller.js +1 -1
  331. package/dist/internal/engine-3d-loader.d.ts +47 -0
  332. package/dist/internal/engine-3d-loader.js +1 -0
  333. package/dist/internal/engine-3d.d.ts +57 -0
  334. package/dist/internal/engine-3d.js +1 -0
  335. package/dist/internal/hierarchy-source-controller.js +1 -1
  336. package/dist/internal/localization-runtime.js +1 -1
  337. package/dist/internal/localization-types.d.ts +1 -1
  338. package/dist/internal/localization.js +1 -1
  339. package/dist/internal/lyra-element.d.ts +2 -2
  340. package/dist/internal/lyra-element.js +1 -1
  341. package/dist/internal/model-viewer-contract.d.ts +5 -0
  342. package/dist/internal/model-viewer-contract.js +1 -0
  343. package/dist/internal/package-metadata.js +1 -1
  344. package/dist/internal/positioner.js +1 -1
  345. package/dist/internal/rendered-state.js +1 -1
  346. package/dist/internal/root-registration-allowlist.js +1 -1
  347. package/dist/internal/scoped-definitions.generated.js +1 -1
  348. package/dist/internal/typed-columns.d.ts +39 -0
  349. package/dist/internal/typed-columns.js +1 -0
  350. package/dist/localization.js +1 -1
  351. package/dist/lyra.d.ts +1 -1
  352. package/dist/lyra.js +1 -1
  353. package/dist/ssr/all.d.ts +1 -1
  354. package/dist/ssr/all.js +1 -1
  355. package/dist/ssr.d.ts +4 -4
  356. package/dist/ssr.js +1 -1
  357. package/dist/svelte.d.ts +1 -1
  358. package/dist/testing/lyra-tag-event-map.d.ts +2 -2
  359. package/dist/testing/lyra-tag-event-map.js +1 -1
  360. package/dist/theme/theme-bootstrap.js +1 -1
  361. package/dist/theme/theme.js +1 -1
  362. package/dist/vue.d.ts +1 -1
  363. package/llms/components/lr-accordion-item.md +2 -2
  364. package/llms/components/lr-agent-eval-dashboard.md +3 -3
  365. package/llms/components/lr-agent-run.md +3 -3
  366. package/llms/components/lr-agent-trace.md +1 -1
  367. package/llms/components/lr-agent-workspace.md +1 -1
  368. package/llms/components/lr-app-rail-item.md +1 -1
  369. package/llms/components/lr-app-rail.md +5 -6
  370. package/llms/components/lr-background-runs.md +4 -4
  371. package/llms/components/lr-calendar.md +1 -1
  372. package/llms/components/lr-change-review.md +5 -5
  373. package/llms/components/lr-chart-3d.md +164 -0
  374. package/llms/components/lr-chunk-inspector.md +4 -5
  375. package/llms/components/lr-citation-badge.md +1 -1
  376. package/llms/components/lr-code-block-core.md +2 -4
  377. package/llms/components/lr-command-palette.md +3 -3
  378. package/llms/components/lr-community-card.md +2 -2
  379. package/llms/components/lr-date-picker.md +1 -1
  380. package/llms/components/lr-details.md +2 -2
  381. package/llms/components/lr-diff-view.md +2 -2
  382. package/llms/components/lr-dock-panel.md +5 -10
  383. package/llms/components/lr-document-viewer.md +21 -14
  384. package/llms/components/lr-embedding-explorer.md +24 -4
  385. package/llms/components/lr-entity-dossier.md +3 -4
  386. package/llms/components/lr-eval-dataset.md +3 -3
  387. package/llms/components/lr-eval-run.md +7 -1
  388. package/llms/components/lr-file-input.md +10 -11
  389. package/llms/components/lr-flow-node.md +2 -3
  390. package/llms/components/lr-geojson-viewer.md +1 -1
  391. package/llms/components/lr-graph.md +21 -2
  392. package/llms/components/lr-grounding-summary.md +1 -1
  393. package/llms/components/lr-icon.md +1 -3
  394. package/llms/components/lr-image-viewer.md +29 -2
  395. package/llms/components/lr-ingestion-queue.md +1 -1
  396. package/llms/components/lr-knowledge-base-admin.md +2 -2
  397. package/llms/components/lr-knowledge-graph-explorer.md +7 -1
  398. package/llms/components/lr-known-date.md +3 -10
  399. package/llms/components/lr-lite-chart.md +1 -1
  400. package/llms/components/lr-map.md +861 -49
  401. package/llms/components/lr-markdown-core.md +1 -2
  402. package/llms/components/lr-memory-panel.md +4 -8
  403. package/llms/components/lr-model-viewer.md +170 -0
  404. package/llms/components/lr-navigation-menu.md +3 -4
  405. package/llms/components/lr-node-palette.md +1 -1
  406. package/llms/components/lr-path-strip.md +2 -3
  407. package/llms/components/lr-provenance-panel.md +3 -5
  408. package/llms/components/lr-qr-code.md +3 -4
  409. package/llms/components/lr-rag-answer.md +1 -1
  410. package/llms/components/lr-rag-eval-dashboard.md +2 -5
  411. package/llms/components/lr-retrieval-results.md +6 -7
  412. package/llms/components/lr-retrieval-trace.md +3 -4
  413. package/llms/components/lr-signature-pad.md +4 -3
  414. package/llms/components/lr-source-card.md +1 -1
  415. package/llms/components/lr-source-list.md +5 -5
  416. package/llms/components/lr-source-picker.md +2 -3
  417. package/llms/components/lr-span-waterfall.md +4 -3
  418. package/llms/components/lr-sparkline.md +3 -3
  419. package/llms/components/lr-subagent-panel.md +3 -3
  420. package/llms/components/lr-tool-call-chip.md +6 -6
  421. package/llms/components/lr-tool-timeline.md +1 -1
  422. package/llms/components/lr-video-playlist.md +3 -3
  423. package/llms/components/lr-video.md +29 -2
  424. package/llms/components/lr-virtual-list.md +3 -2
  425. package/llms/components/lr-widget.md +6 -13
  426. package/llms/index.md +98 -95
  427. package/llms/migration.md +27 -38
  428. package/llms/peers.md +7 -6
  429. package/llms/shared/ai-and-peers.md +1 -1
  430. package/llms/shared/events-and-types.md +8 -0
  431. package/llms/shared/imports-and-registration.md +2 -2
  432. package/llms/shared/v29-to-v30-migration.md +256 -0
  433. package/llms/shared.md +11 -3
  434. package/llms.txt +4 -4
  435. package/locales.json +1 -2328
  436. package/package.json +41 -13
  437. package/registrations.json +1 -1
  438. package/skills/lyra-ui/SKILL.md +4 -3
  439. /package/dist/{components/viewers/document-viewer → internal}/deferred-teardown.js +0 -0
  440. /package/dist/{components/viewers/document-viewer/registry-ownership.js → internal/document-renderer-registry-ownership.js} +0 -0
@@ -11,7 +11,7 @@ import{__decorate}from"tslib";import{relayNativeEvent}from"../../../internal/nat
11
11
  aria-valuemax=${aria.max}
12
12
  @pointerdown=${this.onResizePointerDown}
13
13
  @keydown=${this.onResizeKeyDown}
14
- ></span>`}syncResizeHandleValues(writes){const measurements=[];for(const handle of this.renderRoot.querySelectorAll('[part="resize-handle"]')){const key=handle.dataset.colKey;if(!key)continue;const column=this.columnsByKey.get(key);if(!column||this.resizedColumnWidths.has(key)||this.parsePixelLength(column.width)!==void 0)continue;const rendered=handle.closest("th[data-col-key]")?.getBoundingClientRect().width;if(rendered&&rendered>0){const width=Math.round(rendered);measurements.push({handle,width})}}const apply=()=>{for(const{handle,width}of measurements)handle.setAttribute("aria-valuenow",String(width)),handle.setAttribute("aria-valuetext",this.resizeValueText(width))};writes?writes.push(apply):apply()}rollbackResizePreview(state2){const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted;const column=this.columnsByKey.get(state2.key),col=this.renderRoot.querySelector(`col[data-col-key="${CSS.escape(state2.key)}"]`),width=column?this.renderedColumnWidth(column):void 0;width?col?.style.setProperty("inline-size",width):col?.style.removeProperty("inline-size");const hasWidths=this.columns.some(column2=>column2.width||this.resizedColumnWidths.has(column2.key)),table=this.renderRoot.querySelector("table");table?.toggleAttribute("data-has-column-widths",hasWidths),table?.setAttribute("data-layout",this.layout==="fixed"||hasWidths||this.resizeState?"fixed":"auto")}cancelResizeGesture(){const state2=this.resizeState;this.resizeState=void 0,this.resizePointer.stop(),state2&&(state2.handle.removeAttribute("data-resizing"),this.rollbackResizePreview(state2))}syncLayoutGeometry(){const writes=[];this.syncAutoScrollMode(writes),this.applyStickyOffsets(writes),this.syncResizeHandleValues(writes),this.recomputeHiddenPriorityColumns(writes);for(const apply of writes)apply()}firstUpdated(changed){super.firstUpdated(changed),!this.hasAttribute("aria-label")&&!this.caption&&devWarnOnce(MISSING_ACCESSIBLE_NAME_WARNING,"<lr-table> has no accessible name: set a host `aria-label` or `caption` so assistive technology can identify the grid.")}connectedCallback(){super.connectedCallback();const owner=this.ownerDocument.defaultView,ResizeObserverCtor=owner?.ResizeObserver;let observer;ResizeObserverCtor&&(observer=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.resizeObserver!==observer||this.scheduleLayoutSync()})),this.resizeObserver=observer;const base=this.renderRoot?.querySelector('[part="base"]');base&&(this.observeBase(base),this.observeTable(this.renderRoot.querySelector('[part="table"]')??void 0),this.observeHeaders())}disconnectedCallback(){super.disconnectedCallback(),this.cancelResizeGesture(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0;const frame=this.layoutFrame;frame&&frame.owner.cancelAnimationFrame(frame.handle),this.layoutFrame=null,this.observedBase=void 0,this.observedTable=void 0,this.observedHeaders.clear()}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}localizedOverride(key,override){return override??this.localize(TABLE_OVERRIDE_MESSAGE_KEYS[key])}loadingText(){return this.localizedOverride("tableLoading",this.loadingLabel)}loadingMoreText(){return this.localizedOverride("tableLoadingMore",this.loadingMoreLabel)}onLoadMore(){this.loadingMore||this.emit("lr-load-more")}observeBase(base){this.observedBase!==base&&(this.observedBase&&this.resizeObserver?.unobserve(this.observedBase),this.resizeObserver?.observe(base),this.observedBase=base)}observeTable(table){this.observedTable!==table&&(this.observedTable&&this.resizeObserver?.unobserve(this.observedTable),table&&this.resizeObserver?.observe(table),this.observedTable=table)}syncAutoScrollMode(writes){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return;const overflows=(this.scrollMode==="auto"||this.scrollMode==="page")&&base.scrollWidth-base.clientWidth>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,apply=()=>base.toggleAttribute("data-scroll-overflow",overflows);writes?writes.push(apply):apply()}observeHeaders(){const headers=new Set(this.columns.some(column=>column.sticky||column.resizable)?this.renderRoot.querySelectorAll("th[data-col-key]"):[]);for(const header of this.observedHeaders)headers.has(header)||(this.resizeObserver?.unobserve(header),this.observedHeaders.delete(header));for(const header of headers)this.observedHeaders.has(header)||(this.observedHeaders.add(header),this.resizeObserver?.observe(header))}priorityTierHeaders(tier){return[...this.renderRoot.querySelectorAll(`th[data-priority="${tier}"]`)]}recomputeHiddenPriorityColumns(writes){const hasLowColumn=this.columns.some(col=>col.priority==="low"),hasMediumColumn=this.columns.some(col=>col.priority==="medium"),base=this.renderRoot.querySelector('[part="base"]');if(!hasLowColumn&&!hasMediumColumn){this.priorityTierNaturalWidth.clear(),this.alwaysVisibleNaturalWidth=void 0,this.priorityTierHiddenAllocation.clear(),this.priorityTierRevealAllocation.clear();const visible=this.activeColKey===null?[]:this.visibleHeaders(),apply=()=>{base?.removeAttribute("data-hide-priority-low"),base?.removeAttribute("data-hide-priority-medium"),this.rehomeFocusedColumn(visible)};writes?writes.push(apply):apply(),this.priorityToggleAvailable&&(this.priorityToggleAvailable=!1),this.hasHiddenPriorityColumns&&(this.hasHiddenPriorityColumns=!1);return}if(!base||base.clientWidth<=0){this.rehomeFocusedColumn();return}const genuineOverflow=base.scrollWidth-base.clientWidth>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,lowHeaders=hasLowColumn?this.priorityTierHeaders("low"):[],mediumHeaders=hasMediumColumn?this.priorityTierHeaders("medium"):[],refreshNaturalWidth=(tier,headers)=>{if(headers.length===0)return!1;const currentlyHidden=headers.every(header=>header.offsetParent===null);if(!currentlyHidden&&genuineOverflow){const width=headers.reduce((sum,header)=>sum+header.getBoundingClientRect().width,0);width>0&&this.priorityTierNaturalWidth.set(tier,width)}return currentlyHidden},lowActuallyHidden=refreshNaturalWidth("low",lowHeaders),mediumActuallyHidden=refreshNaturalWidth("medium",mediumHeaders);if(genuineOverflow){const alwaysWidth=[...this.renderRoot.querySelectorAll('[part="head"] > tr > th')].filter(header=>!header.hasAttribute("data-priority")).reduce((sum,header)=>sum+header.getBoundingClientRect().width,0);alwaysWidth>0&&(this.alwaysVisibleNaturalWidth=alwaysWidth)}const lowNaturalWidth=this.priorityTierNaturalWidth.get("low")??0,mediumNaturalWidth=this.priorityTierNaturalWidth.get("medium")??0,overflowAtFull=(lowActuallyHidden||mediumActuallyHidden?(this.alwaysVisibleNaturalWidth??0)+lowNaturalWidth+mediumNaturalWidth:base.scrollWidth)-base.clientWidth,measuredLow=hasLowColumn&&overflowAtFull>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,overflowAfterLow=measuredLow?overflowAtFull-lowNaturalWidth:overflowAtFull,measuredMedium=hasMediumColumn&&overflowAfterLow>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,allocation=base.offsetWidth,needsMedium=this.settlePriorityTier(base,"medium",measuredMedium,mediumActuallyHidden,allocation,writes),needsLow=this.settlePriorityTier(base,"low",hasLowColumn&&(measuredLow||needsMedium),lowActuallyHidden,allocation,writes);if(this.activeColKey!==null){const visible=this.visibleHeaders().filter(header=>this.priorityColumnsVisible||!(header.dataset.priority==="low"&&needsLow)&&!(header.dataset.priority==="medium"&&needsMedium)),apply=()=>this.rehomeFocusedColumn(visible);writes?writes.push(apply):apply()}const toggleAvailable=needsLow||needsMedium,anyPriorityHidden=toggleAvailable&&!this.priorityColumnsVisible;this.priorityToggleAvailable!==toggleAvailable&&(this.priorityToggleAvailable=toggleAvailable),this.hasHiddenPriorityColumns!==anyPriorityHidden&&(this.hasHiddenPriorityColumns=anyPriorityHidden)}settlePriorityTier(base,tier,measured,actuallyHidden,allocation,writes){const attribute=tier==="low"?"data-hide-priority-low":"data-hide-priority-medium",wasMarked=base.hasAttribute(attribute),revealedAt=this.priorityTierRevealAllocation.get(tier);this.priorityTierRevealAllocation.delete(tier);const hiddenAt=this.priorityTierHiddenAllocation.get(tier),held=actuallyHidden&&hiddenAt!==void 0&&allocation<=hiddenAt+TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,hide=measured||held;hide?(!wasMarked||hiddenAt===void 0)&&this.priorityTierHiddenAllocation.set(tier,Math.max(allocation,revealedAt??allocation)):(this.priorityTierHiddenAllocation.delete(tier),wasMarked&&actuallyHidden&&this.priorityTierRevealAllocation.set(tier,allocation));const apply=()=>base.toggleAttribute(attribute,hide);return writes?writes.push(apply):apply(),hide}rehomeFocusedColumn(headers){if(this.activeColKey===null)return;const visible=headers??this.visibleHeaders();visible.length!==0&&(visible.some(header=>header.dataset.colKey===this.activeColKey)||(this.activeColKey=visible[0].dataset.colKey??null))}keyOf(row,index){try{const key=this.rowKey?this.rowKey(row):index;return typeof key=="string"?key.trim().length===0?void 0:key:typeof key=="number"?key:void 0}catch{return}}canonicalRowEntries(){const inputs=this.canonicalRowEntriesInputs;if(this.cachedCanonicalRowEntries!==null&&inputs?.rows===this.rows&&inputs.rowKey===this.rowKey)return this.cachedCanonicalRowEntries;const entries=[],seen=new Set;return this.rows.forEach((row,index)=>{const key=this.keyOf(row,index);if(key===void 0)return;const encoded=encodeKey(key);seen.has(encoded)||(seen.add(encoded),entries.push({row,index,key,token:encoded}))}),this.canonicalRowEntriesInputs={rows:this.rows,rowKey:this.rowKey},this.cachedCanonicalRowEntries=entries,entries}matchingEntries(){const text=(this.filterText??"").trim(),locale=text===""?"":this.effectiveLocale,canonicalEntries=this.sortedCanonicalEntries(),inputs=this.matchingEntriesInputs;if(this.cachedMatchingEntries!==null&&inputs!==null&&inputs.entries===canonicalEntries&&inputs.filter===this.filter&&inputs.text===text&&inputs.locale===locale)return this.cachedMatchingEntries;let entries;if(text==="")entries=canonicalEntries;else{const stringify=createFilterStringifier(),intlLocale=this.effectiveLocale,normalized=text.toLocaleLowerCase(intlLocale);entries=canonicalEntries.filter(entry=>{if(this.filter)return this.filter(entry.row,text);let haystack=entry.search?.locale===intlLocale?entry.search.text:void 0;return haystack===void 0&&(haystack=stringify(entry.row).toLocaleLowerCase(intlLocale),isImmutableSearchRow(entry.row)&&(entry.search={locale:intlLocale,text:haystack})),haystack.includes(normalized)})}return this.matchingEntriesInputs={entries:canonicalEntries,filter:this.filter,text,locale},this.cachedMatchingEntries=entries,entries}get normalizedPageSize(){return finiteInteger(this.pageSize,DEFAULT_PAGE_SIZE,1,MAX_PAGE_SIZE)}get effectiveSkeletonRows(){const explicit=finiteCount(this.skeletonRows,0,MAX_SKELETON_ROWS);if(explicit>0)return explicit;const pageSize=this.normalizedPageSize;return pageSize===DEFAULT_PAGE_SIZE?DEFAULT_SKELETON_ROWS:Math.min(pageSize,MAX_SKELETON_ROWS)}get matchingTotalItems(){const totalItems=finiteInteger(this.totalItems,-1);return totalItems>=0?totalItems:this.matchingEntries().length}get serverUnknownTotal(){return this.paginationMode==="server"&&this.unknownTotal}get pageCount(){const pageSize=this.normalizedPageSize;return pageSize>0?Math.ceil(this.matchingTotalItems/pageSize):0}get appliedPage(){return this.pageCount===0?1:finiteInteger(this.page,1,1,this.pageCount)}sortedEntries(){return this.matchingEntries()}sortedCanonicalEntries(){const entries=this.canonicalRowEntries();if(this.sortMode!=="client"||this.sortKey==="")return entries;const col=this.columnsByKey.get(this.sortKey);if(!col?.sortable)return entries;const locale=this.effectiveLocale,inputs=this.sortedEntriesInputs;if(this.cachedSortedEntries!==null&&inputs!==null&&inputs.entries===entries&&inputs.columns===this.columns&&inputs.mode===this.sortMode&&inputs.key===this.sortKey&&inputs.dir===this.sortDir&&inputs.locale===locale&&inputs.groupBy===this.groupBy)return this.cachedSortedEntries;const collator=getCollator(locale,{numeric:!0}),dir=this.sortDir==="desc"?-1:1,decorated=entries.map(entry=>{const raw=typeof col.sortValue=="function"?col.sortValue(entry.row):typeof col.cell=="function"?String(col.cell(entry.row)??""):"";return{entry,value:typeof raw=="number"&&!Number.isFinite(raw)?null:raw}}),compare=(a,b)=>{const av=a.value,bv=b.value;return av==null&&bv==null?0:av==null?1:bv==null?-1:typeof av=="number"&&typeof bv=="number"?(av-bv)*dir:collator.compare(String(av),String(bv))*dir};let sorted;const groupBy=this.groupBy;if(groupBy===void 0)decorated.sort(compare),sorted=decorated.map(decoration=>decoration.entry);else{const buckets=new Map;for(const decoration of decorated){const groupKey=groupBy(decoration.entry.row),bucket=buckets.get(groupKey);bucket===void 0?buckets.set(groupKey,[decoration]):bucket.push(decoration)}const ordered=[...buckets.values()],constantWithinEveryGroup=ordered.every(bucket=>bucket.every(decoration=>compare(decoration,bucket[0])===0));constantWithinEveryGroup&&ordered.sort((a,b)=>compare(a[0],b[0])),sorted=[];for(const bucket of ordered){constantWithinEveryGroup||bucket.sort(compare);for(const decoration of bucket)sorted.push(decoration.entry)}}return this.sortedEntriesInputs={entries,columns:this.columns,mode:this.sortMode,key:this.sortKey,dir:this.sortDir,locale,groupBy},this.cachedSortedEntries=sorted,sorted}renderedEntries(){const entries=this.sortedEntries(),size=this.normalizedPageSize,start=this.paginationMode==="server"?0:(this.appliedPage-1)*size,cached=this.pageEntriesMemo;if(cached&&cached.entries===entries&&cached.start===start&&cached.size===size)return cached.result;const result=entries.slice(start,start+size);return this.pageEntriesMemo={entries,start,size,result},result}publicRows(entries){let rows=this.publicRowsMemo.get(entries);return rows||(rows=Object.freeze(entries.map(entry=>entry.row)),this.publicRowsMemo.set(entries,rows)),rows}aggregate(callback,key=callback,receiver=this){if(!callback)return"";const rows=this.viewRows;return(rows!==this.aggregateRows||this.columns!==this.aggregateColumns||this.effectiveLocale!==this.aggregateLocale)&&(this.aggregateRows=rows,this.aggregateColumns=this.columns,this.aggregateLocale=this.effectiveLocale,this.aggregateValues.clear()),this.aggregateValues.has(key)||this.aggregateValues.set(key,callback.call(receiver,rows)),this.aggregateValues.get(key)}get viewRows(){return this.publicRows(this.sortedEntries())}get pageRows(){return this.publicRows(this.renderedEntries())}focusedColKey(displayed){const visibleKeys=displayed??this.visibleHeaders().map(el=>el.dataset.colKey).filter(key=>key!==void 0&&this.columnsByKey.has(key));return this.activeColKey!==null&&this.columnsByKey.has(this.activeColKey)&&(visibleKeys.length===0||visibleKeys.includes(this.activeColKey))?this.activeColKey:visibleKeys[0]??this.columns[0]?.key??null}displayedColumnKeys(){const base=this.renderRoot?.querySelector?.('[part="base"]'),hideLow=!this.priorityColumnsVisible&&!!base?.hasAttribute("data-hide-priority-low"),hideMedium=!this.priorityColumnsVisible&&!!base?.hasAttribute("data-hide-priority-medium");return this.columns.filter(col=>!(hideLow&&col.priority==="low")&&!(hideMedium&&col.priority==="medium")).map(col=>col.key)}focusedRowKey(){if(this.activeRowKey!==null&&this.rowsByKey.has(this.activeRowKey))return this.activeRowKey;const selectedKey=this._selectedKeys.values().next().value;if(selectedKey!==void 0){const selected=encodeKey(selectedKey);if(this.rowsByKey.has(selected))return selected}const first=this.renderedEntries()[0];return first?encodeKey(first.key):null}rowsAffectingRovingFocusChanged(changed){return changed.has("rows")||changed.has("rowKey")||changed.has("filterText")||changed.has("filter")||changed.has("page")||changed.has("pageSize")||changed.has("paginationMode")||changed.has("totalItems")||changed.has("columns")||changed.has("sortKey")||changed.has("sortDir")||changed.has("sortMode")||changed.has("groupBy")||this.rowsLocale!==this.effectiveLocale}captureRovingFocus(changed){this.rovingFocusSnapshot=null;const active=shadowFocusTarget(this),HTMLElementCtor=this.ownerDocument?.defaultView?.HTMLElement;if(!(!HTMLElementCtor||!(active instanceof HTMLElementCtor))){if(changed.has("columns")&&active.matches("th[data-col-key]")){const headers=this.visibleHeaders(),key=active.dataset.colKey,index=headers.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"header",key,index,targetKey:null,element:active});return}if(this.rowsAffectingRovingFocusChanged(changed)&&active.matches("tr[data-row-key]")){const renderedRows=[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],key=active.dataset.rowKey,index=renderedRows.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"row",key,index,targetKey:null,element:active})}}}resolveRovingFocusTarget(){const snapshot=this.rovingFocusSnapshot;if(snapshot===null)return;const keys=snapshot.kind==="header"?this.columns.map(column=>column.key):[...this.rowsByKey.keys()];snapshot.targetKey=keys.includes(snapshot.key)?snapshot.key:keys[Math.min(snapshot.index,keys.length-1)]??null,snapshot.kind==="header"?this.activeColKey=snapshot.targetKey:this.activeRowKey=snapshot.targetKey}willUpdate(changed){if(super.willUpdate(changed),this.themedResizeMinWidth=void 0,this.captureRovingFocus(changed),this.selectionMode==="single"&&this._selectedKeys.size>1&&(changed.has("selectionMode")||changed.has("selectedRowKeys"))){const first=this._selectedKeys.values().next().value;if(this.selectedRowKeys=this.asKeySet(first===void 0?new Set:new Set([first])),this.hasUpdated){const rowKeys=this.asKeyList(Object.freeze(first===void 0?[]:[first]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}}if(this.expansionMode==="single"&&this._expandedKeys.size>1&&(changed.has("expansionMode")||changed.has("expandedRowKeys"))){const first=this._expandedKeys.values().next().value;this.expandedRowKeys=this.asKeySet(first===void 0?new Set:new Set([first]))}if(!this.hasUpdated){const parsed=readPersistedState(this.storageFullKey,v=>typeof v=="object"&&v!==null);parsed&&typeof parsed.priorityColumnsVisible=="boolean"&&!isPersistedPropertyExplicitlySet(this,"priorityColumnsVisible")&&(this.priorityColumnsVisible=parsed.priorityColumnsVisible)}if(changed.has("columns")&&(this.columnsByKey=new Map(this.columns.map(c=>[c.key,c]))),this.rowsAffectingRovingFocusChanged(changed)&&(this.rowsByKey=new Map(this.renderedEntries().map(entry=>[entry.token,entry])),this.rowsLocale=this.effectiveLocale),this.resolveRovingFocusTarget(),this.editingCell!==null){const column=this.columnsByKey.get(this.editingCell.columnKey);(!this.rowsByKey.has(this.editingCell.rowKey)||normalizedEditTrigger(column?.editTrigger)!=="double-click")&&(this.editingCell=null)}this.editorHadFocusBeforeUpdate=this.focusedEditorCell!==null&&shadowFocusTarget(this)===this.editorElementFor(this.focusedEditorCell.rowKey,this.focusedEditorCell.columnKey)}stickyOffsets(){const offsets=new Map,headerWidths=new Map;for(const el of this.renderRoot.querySelectorAll("th[data-col-key]")){const key=el.dataset.colKey;key!==void 0&&!headerWidths.has(key)&&headerWidths.set(key,el.offsetWidth)}const headerWidth=key=>headerWidths.get(key)??0;let runningStart=0;for(const col of this.columns)stickyDirection(col.sticky)==="start"&&(offsets.set(col.key,runningStart),runningStart+=headerWidth(col.key));let runningEnd=0;for(let i=this.columns.length-1;i>=0;i--){const col=this.columns[i];col&&stickyDirection(col.sticky)==="end"&&(offsets.set(col.key,runningEnd),runningEnd+=headerWidth(col.key))}return offsets}computeHeatDomain(hasHeatTint){if(!hasHeatTint)return null;const entries=this.matchingEntries(),min=this.heatTintScale?.min,max=this.heatTintScale?.max,cached=this.heatDomainCache;if(cached&&cached.entries===entries&&cached.columns===this.columns&&cached.min===min&&cached.max===max)return cached.domain;const domain=this.deriveHeatDomain(entries);return this.heatDomainCache={entries,columns:this.columns,min,max,domain},domain}deriveHeatDomain(entries){const values=[];for(const entry of entries)for(const col of this.columns){const v=col.heatValue?.(entry.row);v!=null&&Number.isFinite(v)&&values.push(v)}const auto=minMax(values),lo=this.heatTintScale?.min??auto?.[0],hi=this.heatTintScale?.max??auto?.[1];return lo===void 0||hi===void 0?null:[lo,hi]}heatShare(col,row,domain){if(!col.heatValue||!domain)return null;const v=col.heatValue(row);if(v==null||!Number.isFinite(v))return null;const[lo,hi]=domain;return`${(finiteRatio(v,lo,hi)*100).toFixed(2)}%`}applyStickyOffsets(writes){if(!this.columns.some(c=>c.sticky))return;const offsets=this.stickyOffsets(),cells=this.renderRoot.querySelectorAll("th[data-col-key], td[data-col-key]"),apply=()=>cells.forEach(el=>{const key=el.dataset.colKey;key!==void 0&&offsets.has(key)&&el.style.setProperty("--lr-table-sticky-offset",`${offsets.get(key)}px`)});writes?writes.push(apply):apply()}updated(changed){super.updated(changed),this.firstUpdateAnnouncementsReady&&this.rowsTruncated&&(changed.has("rows")||changed.has("maxRows"))&&this.announcements.announcePolite(this.localize("tableRowLimit",void 0,{count:getNumberFormat(this.effectiveLocale).format(this.rows.length)})),this.firstUpdateAnnouncementsReady&&changed.has("loading")&&this.loading&&this.announcements.announcePolite(this.loadingText()),this.firstUpdateAnnouncementsReady&&changed.has("loadingMore")&&this.loadingMore&&!this.loading&&this.shadowRoot?.querySelector('[part="more-button"]')&&this.announcements.announcePolite(this.loadingMoreText());const announcesErrorTransition=this.firstUpdateAnnouncementsReady&&changed.has("error")&&this.error,announcesMountedError=!this.firstUpdateAnnouncementsReady&&this.announce&&this.error;if((announcesErrorTransition||announcesMountedError)&&this.announcements.announceAssertive(this.localizedOverride("tableLoadFailed",this.errorHeading)),this.firstUpdateAnnouncementsReady=!0,this.persistReady&&changed.has("priorityColumnsVisible")&&writePersistedState(this.storageFullKey,{priorityColumnsVisible:this.priorityColumnsVisible}),this.persistReady=!0,changed.has("columns")||changed.has("revealColumnsLabel")||changed.has("columnsHideLabel")||changed.has("priorityColumnsVisible")||changed.has("storageKey")){const inertMembers=[],labelsInert=this.revealColumnsLabel!==void 0||this.columnsHideLabel!==void 0;labelsInert&&inertMembers.push("`revealColumnsLabel`/`columnsHideLabel`"),isPersistedPropertyExplicitlySet(this,"priorityColumnsVisible")&&inertMembers.push("`priorityColumnsVisible`"),this.storageKey&&inertMembers.push("`storageKey`"),inertMembers.length>0&&this.columns.length>0&&!this.columns.some(col=>col.priority)&&devWarnOnce(INERT_PRIORITY_COLUMN_CONFIG_WARNING,`<lr-table>: ${inertMembers.join(", ")} `+(inertMembers.length>1||labelsInert?"have":"has")+" no effect unless at least one column declares `priority`.")}const geometryChanged=changed.size===0||[...changed.keys()].some(key=>key!=="selectedRowKeys"&&key!=="selectionMode"&&key!=="activeRowKey"&&key!=="activeColKey"),base=this.renderRoot.querySelector('[part="base"]');if(base&&this.observeBase(base),this.observeTable(this.renderRoot.querySelector('[part="table"]')??void 0),geometryChanged&&this.observeHeaders(),this.restoreRovingFocus(),this.hasAlwaysOnEditors&&this.restoreAlwaysOnEditorFocus(),changed.has("editingCell"))if(this.editingCell){const{rowKey,columnKey}=this.editingCell;queueMicrotask(()=>this.editorElementFor(rowKey,columnKey)?.focus())}else{const previous=changed.get("editingCell");if(previous){const{rowKey,columnKey}=previous;queueMicrotask(()=>this.cellElementForToken(rowKey,columnKey)?.focus())}}geometryChanged&&queueMicrotask(()=>this.syncLayoutGeometry())}restoreRovingFocus(){const snapshot=this.rovingFocusSnapshot;if(this.rovingFocusSnapshot=null,snapshot===null)return;const internalActive=shadowFocusTarget(this);if(internalActive!==null&&internalActive!==snapshot.element)return;const documentActive=activeElementIn(this.ownerDocument);if(documentActive!==null&&documentActive!==this&&documentActive!==this.ownerDocument.body)return;const candidates=snapshot.kind==="header"?this.visibleHeaders():[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],target=candidates.find(candidate=>snapshot.kind==="header"?candidate.dataset.colKey===snapshot.targetKey:candidate.dataset.rowKey===snapshot.targetKey)??candidates[Math.min(snapshot.index,candidates.length-1)]??null;snapshot.kind==="header"?this.focusHeader(target):this.focusRow(target)}activateColumn(key){this.activeColKey=key;const col=this.columnsByKey.get(key);if(!col?.sortable)return;const sortDir=this.sortKey===key?this.sortDir==="asc"?"desc":"asc":col.defaultSortDir??this.defaultSortDir,request=Object.freeze({phase:"request",sortKey:col.key,sortDir});this.emit("lr-sort-request",request,{cancelable:!0}).defaultPrevented||(this.sortMode==="client"&&(this.sortKey=col.key,this.sortDir=sortDir),this.emit("lr-sort",Object.freeze({phase:"commit",sortKey:col.key,sortDir})))}commitSelectedKeys(next){next.size>this.maxRows&&(next=keySet(next,this.maxRows));const previous=this._selectedKeys;this.isRebind("selectedRowKeys",next,previous),this._selectedKeys=next,this.requestUpdate("selectedRowKeys",previous)}activateRow(key){this.activeRowKey=key;const entry=this.rowsByKey.get(key);if(entry===void 0)return;const{row,key:selectedKey}=entry;if(this.emit("lr-row-activate",Object.freeze({row})),this.selectionMode==="single"){this.commitSelectedKeys(new Set([selectedKey]));const rowKeys=this.asKeyList(Object.freeze([selectedKey]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}else if(this.selectionMode==="multiple"){const rawKey=selectedKey,next=new Set(this._selectedKeys);next.has(rawKey)?next.delete(rawKey):next.add(rawKey),this.commitSelectedKeys(next);const rowKeys=this.asKeyList(Object.freeze([...this._selectedKeys]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}}get hasAlwaysOnEditors(){return this.columns.some(col=>normalizedEditTrigger(col.editTrigger)==="always")}editorValue(row,column){const value=column.editValue?.(row)??row[column.key]??"";return String(value)}startEditing(rowKey,columnKey){const column=this.columnsByKey.get(columnKey);normalizedEditTrigger(column?.editTrigger)!=="double-click"||!this.rowsByKey.has(rowKey)||(this.editingCell={rowKey,columnKey})}commitEdit(event,rowKey,columnKey){event.stopPropagation();const field=event.currentTarget,entry=this.rowsByKey.get(rowKey),column=this.columnsByKey.get(columnKey),isTransient=this.editingCell?.rowKey===rowKey&&this.editingCell.columnKey===columnKey;if(!entry||!column||normalizedEditTrigger(column.editTrigger)===void 0){isTransient&&(this.editingCell=null);return}const value=column.editType==="number"&&field.value!==""?Number(field.value):field.value;this.emit("lr-cell-edit",Object.freeze({row:entry.row,columnKey,value})),isTransient&&(this.editingCell=null)}editorElementFor(rowKey,columnKey){return this.cellElementForToken(rowKey,columnKey)?.querySelector('[part="cell-editor"]')??null}restoreAlwaysOnEditorFocus(){const cell=this.focusedEditorCell;if(cell===null)return;const editor=this.editorElementFor(cell.rowKey,cell.columnKey);editor===null?this.focusedEditorCell=null:this.editorHadFocusBeforeUpdate&&shadowFocusTarget(this)!==editor&&editor.focus(),this.editorHadFocusBeforeUpdate=!1}activateExpandToggle(key){const entry=this.rowsByKey.get(encodeKey(key));if(entry===void 0)return;const expanded=!this._expandedKeys.has(key),detail=Object.freeze({row:entry.row,rowKey:key,expanded});if(this.expansionMode!=="single"&&this.expansionMode!=="multiple"){this.emit("lr-row-expand-toggle",detail);return}requestThenCommit({requestDetail:detail,emitRequest:(requestDetail,init)=>this.emit("lr-row-expand-request",requestDetail,init),commit:()=>{let next=this.expansionMode==="single"?new Set:new Set(this._expandedKeys);expanded?next.add(key):next.delete(key),next.size>this.maxRows&&(next=keySet(next,this.maxRows));const displaced=[...this._expandedKeys].filter(other=>other!==key&&!next.has(other)),previous=this._expandedKeys;this.isRebind("expandedRowKeys",next,previous),this._expandedKeys=next,this.requestUpdate("expandedRowKeys",previous);for(const other of displaced){const displacedEntry=this.rowsByKey.get(encodeKey(other));displacedEntry!==void 0&&this.emit("lr-row-expand-toggle",Object.freeze({row:displacedEntry.row,rowKey:other,expanded:!1}))}this.emit("lr-row-expand-toggle",Object.freeze({...detail,expanded:next.has(key)}))}})}rowElement(rowKey){return this.rowElementForToken(encodeKey(rowKey))}cellElement(rowKey,columnKey){return this.cellElementForToken(encodeKey(rowKey),columnKey)}editCell(rowKey,columnKey){const token=encodeKey(rowKey),trigger=normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger);if(!(trigger===void 0||!this.rowsByKey.has(token))){if(trigger==="always"){this.editorElementFor(token,columnKey)?.focus();return}this.startEditing(token,columnKey)}}expandedContentElement(rowKey){const token=encodeKey(rowKey);return[...this.renderRoot.querySelectorAll("tbody tr[data-expanded-row-key]")].find(el=>el.dataset.expandedRowKey===token)?.querySelector('[part="expanded-cell"]')??null}rowElementForToken(token){return[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")].find(el=>el.dataset.rowKey===token)??null}cellElementForToken(token,columnKey){return[...this.rowElementForToken(token)?.querySelectorAll("td[data-col-key]")??[]].find(el=>el.dataset.colKey===columnKey)??null}visibleHeaders(){return[...this.renderRoot?.querySelectorAll("th[data-col-key]")??[]].filter(el=>el.offsetParent!==null)}focusHeader(el){el?.dataset.colKey&&(this.activeColKey=el.dataset.colKey,el.focus())}focusRow(el){el?.dataset.rowKey&&(this.activeRowKey=el.dataset.rowKey,el.focus())}onHeaderKeyDown(e,th){if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateColumn(th.dataset.colKey);return}const headers=this.visibleHeaders(),index=headers.indexOf(th);if(index<0)return;const rtl=isRtl(this);switch(e.key){case"ArrowLeft":e.preventDefault(),this.focusHeader(headers[rtl?Math.min(headers.length-1,index+1):Math.max(0,index-1)]??null);return;case"ArrowRight":e.preventDefault(),this.focusHeader(headers[rtl?Math.max(0,index-1):Math.min(headers.length-1,index+1)]??null);return;case"Home":e.preventDefault(),this.focusHeader(headers[0]??null);return;case"End":e.preventDefault(),this.focusHeader(headers[headers.length-1]??null);return;case"ArrowDown":{e.preventDefault();const rows=[...this.renderRoot.querySelectorAll("[data-row-key]")],key=this.focusedRowKey();this.focusRow(rows.find(r=>r.dataset.rowKey===key)??rows[0]??null);return}default:return}}editableCellFor(target){const columnKey=target.dataset.colKey;return target.tagName!=="TD"||columnKey===void 0?null:normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="double-click"?{element:target,columnKey}:null}editableCellsInRow(tr){return[...tr.querySelectorAll("td[data-editable]")].filter(td=>td.offsetParent!==null&&!td.inert&&!td.closest("[inert]"))}onRowKeyDown(e,tr){const cell=this.editableCellFor(e.target);if((e.key==="Enter"||e.key==="F2")&&cell){e.preventDefault(),this.startEditing(tr.dataset.rowKey,cell.columnKey);return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateRow(tr.dataset.rowKey);return}if(e.key==="ArrowLeft"||e.key==="ArrowRight"){this.onRowLateralKeyDown(e,tr,cell);return}const bodyRows=[...this.renderRoot.querySelectorAll("[data-row-key]")],index=bodyRows.indexOf(tr);if(!(index<0))switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(bodyRows[Math.min(bodyRows.length-1,index+1)]??null);return;case"ArrowUp":if(e.preventDefault(),index===0){const headers=this.visibleHeaders(),key=this.focusedColKey();this.focusHeader(headers.find(h=>h.dataset.colKey===key)??headers[0]??null)}else this.focusRow(bodyRows[index-1]??null);return;case"Home":e.preventDefault(),this.focusRow(bodyRows[0]??null);return;case"End":e.preventDefault(),this.focusRow(bodyRows[bodyRows.length-1]??null);return;default:return}}onRowLateralKeyDown(e,tr,cell){const cells=this.editableCellsInRow(tr);if(cells.length===0)return;e.preventDefault();const forward=e.key===(isRtl(this)?"ArrowLeft":"ArrowRight");if(cell===null){(forward?cells[0]:cells[cells.length-1])?.focus();return}const index=cells.indexOf(cell.element);forward?cells[index+1]?.focus():index<=0?this.focusRow(tr):cells[index-1]?.focus()}renderCellValue(col,row){return typeof col.cell=="function"?col.cell(row):(devWarnOnce(MISSING_CELL_RENDERER_WARNING,"<lr-table>: a column has no required `cell` renderer, so its cells render empty. Supply a `cell` callback for every column."),nothing)}renderCellEditor(row,col,rowKey,alwaysOn){const type=col.editType??"text",value=this.editorValue(row,col),label=col.editLabel?.(row)??this.localize("tableEditCell",void 0,{column:col.label}),onChange=event=>this.commitEdit(event,rowKey,col.key),onKeyDown=event=>this.onEditorKeyDown(event,rowKey,col.key);if(type==="select"){const options=col.editOptions??[];return html`<select
14
+ ></span>`}syncResizeHandleValues(writes){const measurements=[];for(const handle of this.renderRoot.querySelectorAll('[part="resize-handle"]')){const key=handle.dataset.colKey;if(!key)continue;const column=this.columnsByKey.get(key);if(!column||this.resizedColumnWidths.has(key)||this.parsePixelLength(column.width)!==void 0)continue;const rendered=handle.closest("th[data-col-key]")?.getBoundingClientRect().width;if(rendered&&rendered>0){const width=Math.round(rendered);measurements.push({handle,width})}}const apply=()=>{for(const{handle,width}of measurements)handle.setAttribute("aria-valuenow",String(width)),handle.setAttribute("aria-valuetext",this.resizeValueText(width))};writes.push(apply)}rollbackResizePreview(state2){const reverted=new Map(this.resizedColumnWidths);state2.previousWidth===void 0?reverted.delete(state2.key):reverted.set(state2.key,state2.previousWidth),this.resizedColumnWidths=reverted;const column=this.columnsByKey.get(state2.key),col=this.renderRoot.querySelector(`col[data-col-key="${CSS.escape(state2.key)}"]`),width=column?this.renderedColumnWidth(column):void 0;width?col?.style.setProperty("inline-size",width):col?.style.removeProperty("inline-size");const hasWidths=this.columns.some(column2=>column2.width||this.resizedColumnWidths.has(column2.key)),table=this.renderRoot.querySelector("table");table?.toggleAttribute("data-has-column-widths",hasWidths),table?.setAttribute("data-layout",this.layout==="fixed"||hasWidths||this.resizeState?"fixed":"auto")}cancelResizeGesture(){const state2=this.resizeState;this.resizeState=void 0,this.resizePointer.stop(),state2&&(state2.handle.removeAttribute("data-resizing"),this.rollbackResizePreview(state2))}syncLayoutGeometry(){const writes=[];this.syncAutoScrollMode(writes),this.applyStickyOffsets(writes),this.syncResizeHandleValues(writes),this.recomputeHiddenPriorityColumns(writes);for(const apply of writes)apply()}firstUpdated(changed){super.firstUpdated(changed),!this.hasAttribute("aria-label")&&!this.caption&&devWarnOnce(MISSING_ACCESSIBLE_NAME_WARNING,"<lr-table> has no accessible name: set a host `aria-label` or `caption` so assistive technology can identify the grid.")}connectedCallback(){super.connectedCallback();const owner=this.ownerDocument.defaultView,ResizeObserverCtor=owner?.ResizeObserver;let observer;ResizeObserverCtor&&(observer=new ResizeObserverCtor(()=>{!this.isConnected||this.ownerDocument.defaultView!==owner||this.resizeObserver!==observer||this.scheduleLayoutSync()})),this.resizeObserver=observer;const base=this.renderRoot?.querySelector('[part="base"]');base&&(this.observeBase(base),this.observeTable(this.renderRoot.querySelector('[part="table"]')??void 0),this.observeHeaders())}disconnectedCallback(){super.disconnectedCallback(),this.cancelResizeGesture(),this.resizeObserver?.disconnect(),this.resizeObserver=void 0;const frame=this.layoutFrame;frame&&frame.owner.cancelAnimationFrame(frame.handle),this.layoutFrame=null,this.observedBase=void 0,this.observedTable=void 0,this.observedHeaders.clear()}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}localizedOverride(key,override){return override??this.localize(TABLE_OVERRIDE_MESSAGE_KEYS[key])}loadingText(){return this.localizedOverride("tableLoading",this.loadingLabel)}loadingMoreText(){return this.localizedOverride("tableLoadingMore",this.loadingMoreLabel)}onLoadMore(){this.loadingMore||this.emit("lr-load-more")}observeBase(base){this.observedBase!==base&&(this.observedBase&&this.resizeObserver?.unobserve(this.observedBase),this.resizeObserver?.observe(base),this.observedBase=base)}observeTable(table){this.observedTable!==table&&(this.observedTable&&this.resizeObserver?.unobserve(this.observedTable),table&&this.resizeObserver?.observe(table),this.observedTable=table)}syncAutoScrollMode(writes){const base=this.renderRoot.querySelector('[part="base"]');if(!base)return;const overflows=(this.scrollMode==="auto"||this.scrollMode==="page")&&base.scrollWidth-base.clientWidth>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,apply=()=>base.toggleAttribute("data-scroll-overflow",overflows);writes.push(apply)}observeHeaders(){const headers=new Set(this.columns.some(column=>column.sticky||column.resizable)?this.renderRoot.querySelectorAll("th[data-col-key]"):[]);for(const header of this.observedHeaders)headers.has(header)||(this.resizeObserver?.unobserve(header),this.observedHeaders.delete(header));for(const header of headers)this.observedHeaders.has(header)||(this.observedHeaders.add(header),this.resizeObserver?.observe(header))}priorityTierHeaders(tier){return[...this.renderRoot.querySelectorAll(`th[data-priority="${tier}"]`)]}recomputeHiddenPriorityColumns(writes){const hasLowColumn=this.columns.some(col=>col.priority==="low"),hasMediumColumn=this.columns.some(col=>col.priority==="medium"),base=this.renderRoot.querySelector('[part="base"]');if(!hasLowColumn&&!hasMediumColumn){this.priorityTierNaturalWidth.clear(),this.alwaysVisibleNaturalWidth=void 0,this.priorityTierHiddenAllocation.clear(),this.priorityTierRevealAllocation.clear();const visible=this.activeColKey===null?[]:this.visibleHeaders(),apply=()=>{base?.removeAttribute("data-hide-priority-low"),base?.removeAttribute("data-hide-priority-medium"),this.rehomeFocusedColumn(visible)};writes.push(apply),this.priorityToggleAvailable&&(this.priorityToggleAvailable=!1),this.hasHiddenPriorityColumns&&(this.hasHiddenPriorityColumns=!1);return}if(!base||base.clientWidth<=0){this.rehomeFocusedColumn();return}const genuineOverflow=base.scrollWidth-base.clientWidth>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,lowHeaders=hasLowColumn?this.priorityTierHeaders("low"):[],mediumHeaders=hasMediumColumn?this.priorityTierHeaders("medium"):[],refreshNaturalWidth=(tier,headers)=>{if(headers.length===0)return!1;const currentlyHidden=headers.every(header=>header.offsetParent===null);if(!currentlyHidden&&genuineOverflow){const width=headers.reduce((sum,header)=>sum+header.getBoundingClientRect().width,0);width>0&&this.priorityTierNaturalWidth.set(tier,width)}return currentlyHidden},lowActuallyHidden=refreshNaturalWidth("low",lowHeaders),mediumActuallyHidden=refreshNaturalWidth("medium",mediumHeaders);if(genuineOverflow){const alwaysWidth=[...this.renderRoot.querySelectorAll('[part="head"] > tr > th')].filter(header=>!header.hasAttribute("data-priority")).reduce((sum,header)=>sum+header.getBoundingClientRect().width,0);alwaysWidth>0&&(this.alwaysVisibleNaturalWidth=alwaysWidth)}const lowNaturalWidth=this.priorityTierNaturalWidth.get("low")??0,mediumNaturalWidth=this.priorityTierNaturalWidth.get("medium")??0,overflowAtFull=(lowActuallyHidden||mediumActuallyHidden?(this.alwaysVisibleNaturalWidth??0)+lowNaturalWidth+mediumNaturalWidth:base.scrollWidth)-base.clientWidth,measuredLow=hasLowColumn&&overflowAtFull>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,overflowAfterLow=measuredLow?overflowAtFull-lowNaturalWidth:overflowAtFull,measuredMedium=hasMediumColumn&&overflowAfterLow>TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,allocation=base.offsetWidth,needsMedium=this.settlePriorityTier(base,"medium",measuredMedium,mediumActuallyHidden,allocation,writes),needsLow=this.settlePriorityTier(base,"low",hasLowColumn&&(measuredLow||needsMedium),lowActuallyHidden,allocation,writes);if(this.activeColKey!==null){const visible=this.visibleHeaders().filter(header=>this.priorityColumnsVisible||!(header.dataset.priority==="low"&&needsLow)&&!(header.dataset.priority==="medium"&&needsMedium)),apply=()=>this.rehomeFocusedColumn(visible);writes.push(apply)}const toggleAvailable=needsLow||needsMedium,anyPriorityHidden=toggleAvailable&&!this.priorityColumnsVisible;this.priorityToggleAvailable!==toggleAvailable&&(this.priorityToggleAvailable=toggleAvailable),this.hasHiddenPriorityColumns!==anyPriorityHidden&&(this.hasHiddenPriorityColumns=anyPriorityHidden)}settlePriorityTier(base,tier,measured,actuallyHidden,allocation,writes){const attribute=tier==="low"?"data-hide-priority-low":"data-hide-priority-medium",wasMarked=base.hasAttribute(attribute),revealedAt=this.priorityTierRevealAllocation.get(tier);this.priorityTierRevealAllocation.delete(tier);const hiddenAt=this.priorityTierHiddenAllocation.get(tier),held=actuallyHidden&&hiddenAt!==void 0&&allocation<=hiddenAt+TABLE_SCROLL_OVERFLOW_TOLERANCE_PX,hide=measured||held;hide?(!wasMarked||hiddenAt===void 0)&&this.priorityTierHiddenAllocation.set(tier,Math.max(allocation,revealedAt??allocation)):(this.priorityTierHiddenAllocation.delete(tier),wasMarked&&actuallyHidden&&this.priorityTierRevealAllocation.set(tier,allocation));const apply=()=>base.toggleAttribute(attribute,hide);return writes.push(apply),hide}rehomeFocusedColumn(headers){if(this.activeColKey===null)return;const visible=headers??this.visibleHeaders();visible.length!==0&&(visible.some(header=>header.dataset.colKey===this.activeColKey)||(this.activeColKey=visible[0].dataset.colKey??null))}keyOf(row,index){try{const key=this.rowKey?this.rowKey(row):index;return typeof key=="string"?key.trim().length===0?void 0:key:typeof key=="number"?key:void 0}catch{return}}canonicalRowEntries(){const inputs=this.canonicalRowEntriesInputs;if(this.cachedCanonicalRowEntries!==null&&inputs?.rows===this.rows&&inputs.rowKey===this.rowKey)return this.cachedCanonicalRowEntries;const entries=[],seen=new Set;return this.rows.forEach((row,index)=>{const key=this.keyOf(row,index);if(key===void 0)return;const encoded=encodeKey(key);seen.has(encoded)||(seen.add(encoded),entries.push({row,index,key,token:encoded}))}),this.canonicalRowEntriesInputs={rows:this.rows,rowKey:this.rowKey},this.cachedCanonicalRowEntries=entries,entries}matchingEntries(){const text=(this.filterText??"").trim(),locale=text===""?"":this.effectiveLocale,canonicalEntries=this.sortedCanonicalEntries(),inputs=this.matchingEntriesInputs;if(this.cachedMatchingEntries!==null&&inputs!==null&&inputs.entries===canonicalEntries&&inputs.filter===this.filter&&inputs.text===text&&inputs.locale===locale)return this.cachedMatchingEntries;let entries;if(text==="")entries=canonicalEntries;else{const stringify=createFilterStringifier(),intlLocale=this.effectiveLocale,normalized=text.toLocaleLowerCase(intlLocale);entries=canonicalEntries.filter(entry=>{if(this.filter)return this.filter(entry.row,text);let haystack=entry.search?.locale===intlLocale?entry.search.text:void 0;return haystack===void 0&&(haystack=stringify(entry.row).toLocaleLowerCase(intlLocale),isImmutableSearchRow(entry.row)&&(entry.search={locale:intlLocale,text:haystack})),haystack.includes(normalized)})}return this.matchingEntriesInputs={entries:canonicalEntries,filter:this.filter,text,locale},this.cachedMatchingEntries=entries,entries}get normalizedPageSize(){return finiteInteger(this.pageSize,DEFAULT_PAGE_SIZE,1,MAX_PAGE_SIZE)}get effectiveSkeletonRows(){const explicit=finiteCount(this.skeletonRows,0,MAX_SKELETON_ROWS);if(explicit>0)return explicit;const pageSize=this.normalizedPageSize;return pageSize===DEFAULT_PAGE_SIZE?DEFAULT_SKELETON_ROWS:Math.min(pageSize,MAX_SKELETON_ROWS)}get matchingTotalItems(){const totalItems=finiteInteger(this.totalItems,-1);return totalItems>=0?totalItems:this.matchingEntries().length}get serverUnknownTotal(){return this.paginationMode==="server"&&this.unknownTotal}get pageCount(){const pageSize=this.normalizedPageSize;return pageSize>0?Math.ceil(this.matchingTotalItems/pageSize):0}get appliedPage(){return this.pageCount===0?1:finiteInteger(this.page,1,1,this.pageCount)}sortedEntries(){return this.matchingEntries()}sortedCanonicalEntries(){const entries=this.canonicalRowEntries();if(this.sortMode!=="client"||this.sortKey==="")return entries;const col=this.columnsByKey.get(this.sortKey);if(!col?.sortable)return entries;const locale=this.effectiveLocale,inputs=this.sortedEntriesInputs;if(this.cachedSortedEntries!==null&&inputs!==null&&inputs.entries===entries&&inputs.columns===this.columns&&inputs.mode===this.sortMode&&inputs.key===this.sortKey&&inputs.dir===this.sortDir&&inputs.locale===locale&&inputs.groupBy===this.groupBy)return this.cachedSortedEntries;const collator=getCollator(locale,{numeric:!0}),dir=this.sortDir==="desc"?-1:1,decorated=entries.map(entry=>{const raw=typeof col.sortValue=="function"?col.sortValue(entry.row):typeof col.cell=="function"?String(col.cell(entry.row)??""):"";return{entry,value:typeof raw=="number"&&!Number.isFinite(raw)?null:raw}}),compare=(a,b)=>{const av=a.value,bv=b.value;return av==null&&bv==null?0:av==null?1:bv==null?-1:typeof av=="number"&&typeof bv=="number"?(av-bv)*dir:collator.compare(String(av),String(bv))*dir};let sorted;const groupBy=this.groupBy;if(groupBy===void 0)decorated.sort(compare),sorted=decorated.map(decoration=>decoration.entry);else{const buckets=new Map;for(const decoration of decorated){const groupKey=groupBy(decoration.entry.row),bucket=buckets.get(groupKey);bucket===void 0?buckets.set(groupKey,[decoration]):bucket.push(decoration)}const ordered=[...buckets.values()],constantWithinEveryGroup=ordered.every(bucket=>bucket.every(decoration=>compare(decoration,bucket[0])===0));constantWithinEveryGroup&&ordered.sort((a,b)=>compare(a[0],b[0])),sorted=[];for(const bucket of ordered){constantWithinEveryGroup||bucket.sort(compare);for(const decoration of bucket)sorted.push(decoration.entry)}}return this.sortedEntriesInputs={entries,columns:this.columns,mode:this.sortMode,key:this.sortKey,dir:this.sortDir,locale,groupBy},this.cachedSortedEntries=sorted,sorted}renderedEntries(){const entries=this.sortedEntries(),size=this.normalizedPageSize,start=this.paginationMode==="server"?0:(this.appliedPage-1)*size,cached=this.pageEntriesMemo;if(cached&&cached.entries===entries&&cached.start===start&&cached.size===size)return cached.result;const result=entries.slice(start,start+size);return this.pageEntriesMemo={entries,start,size,result},result}publicRows(entries){let rows=this.publicRowsMemo.get(entries);return rows||(rows=Object.freeze(entries.map(entry=>entry.row)),this.publicRowsMemo.set(entries,rows)),rows}aggregate(callback,key=callback,receiver=this){if(!callback)return"";const rows=this.viewRows;return(rows!==this.aggregateRows||this.columns!==this.aggregateColumns||this.effectiveLocale!==this.aggregateLocale)&&(this.aggregateRows=rows,this.aggregateColumns=this.columns,this.aggregateLocale=this.effectiveLocale,this.aggregateValues.clear()),this.aggregateValues.has(key)||this.aggregateValues.set(key,callback.call(receiver,rows)),this.aggregateValues.get(key)}get viewRows(){return this.publicRows(this.sortedEntries())}get pageRows(){return this.publicRows(this.renderedEntries())}focusedColKey(displayed){const visibleKeys=displayed??this.visibleHeaders().map(el=>el.dataset.colKey).filter(key=>key!==void 0&&this.columnsByKey.has(key));return this.activeColKey!==null&&this.columnsByKey.has(this.activeColKey)&&(visibleKeys.length===0||visibleKeys.includes(this.activeColKey))?this.activeColKey:visibleKeys[0]??this.columns[0]?.key??null}displayedColumnKeys(){const base=this.renderRoot?.querySelector?.('[part="base"]'),hideLow=!this.priorityColumnsVisible&&!!base?.hasAttribute("data-hide-priority-low"),hideMedium=!this.priorityColumnsVisible&&!!base?.hasAttribute("data-hide-priority-medium");return this.columns.filter(col=>!(hideLow&&col.priority==="low")&&!(hideMedium&&col.priority==="medium")).map(col=>col.key)}focusedRowKey(){if(this.activeRowKey!==null&&this.rowsByKey.has(this.activeRowKey))return this.activeRowKey;const selectedKey=this._selectedKeys.values().next().value;if(selectedKey!==void 0){const selected=encodeKey(selectedKey);if(this.rowsByKey.has(selected))return selected}const first=this.renderedEntries()[0];return first?encodeKey(first.key):null}rowsAffectingRovingFocusChanged(changed){return changed.has("rows")||changed.has("rowKey")||changed.has("filterText")||changed.has("filter")||changed.has("page")||changed.has("pageSize")||changed.has("paginationMode")||changed.has("totalItems")||changed.has("columns")||changed.has("sortKey")||changed.has("sortDir")||changed.has("sortMode")||changed.has("groupBy")||this.rowsLocale!==this.effectiveLocale}captureRovingFocus(changed){this.rovingFocusSnapshot=null;const active=shadowFocusTarget(this),HTMLElementCtor=this.ownerDocument?.defaultView?.HTMLElement;if(!(!HTMLElementCtor||!(active instanceof HTMLElementCtor))){if(changed.has("columns")&&active.matches("th[data-col-key]")){const headers=this.visibleHeaders(),key=active.dataset.colKey,index=headers.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"header",key,index,targetKey:null,element:active});return}if(this.rowsAffectingRovingFocusChanged(changed)&&active.matches("tr[data-row-key]")){const renderedRows=[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],key=active.dataset.rowKey,index=renderedRows.indexOf(active);key!==void 0&&index>=0&&(this.rovingFocusSnapshot={kind:"row",key,index,targetKey:null,element:active})}}}resolveRovingFocusTarget(){const snapshot=this.rovingFocusSnapshot;if(snapshot===null)return;const keys=snapshot.kind==="header"?this.columns.map(column=>column.key):[...this.rowsByKey.keys()];snapshot.targetKey=keys.includes(snapshot.key)?snapshot.key:keys[Math.min(snapshot.index,keys.length-1)]??null,snapshot.kind==="header"?this.activeColKey=snapshot.targetKey:this.activeRowKey=snapshot.targetKey}willUpdate(changed){if(super.willUpdate(changed),this.themedResizeMinWidth=void 0,this.captureRovingFocus(changed),this.selectionMode==="single"&&this._selectedKeys.size>1&&(changed.has("selectionMode")||changed.has("selectedRowKeys"))){const first=this._selectedKeys.values().next().value;if(this.selectedRowKeys=this.asKeySet(first===void 0?new Set:new Set([first])),this.hasUpdated){const rowKeys=this.asKeyList(Object.freeze(first===void 0?[]:[first]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}}if(this.expansionMode==="single"&&this._expandedKeys.size>1&&(changed.has("expansionMode")||changed.has("expandedRowKeys"))){const first=this._expandedKeys.values().next().value;this.expandedRowKeys=this.asKeySet(first===void 0?new Set:new Set([first]))}if(!this.hasUpdated){const parsed=readPersistedState(this.storageFullKey,v=>typeof v=="object"&&v!==null);parsed&&typeof parsed.priorityColumnsVisible=="boolean"&&!isPersistedPropertyExplicitlySet(this,"priorityColumnsVisible")&&(this.priorityColumnsVisible=parsed.priorityColumnsVisible)}if(changed.has("columns")&&(this.columnsByKey=new Map(this.columns.map(c=>[c.key,c]))),this.rowsAffectingRovingFocusChanged(changed)&&(this.rowsByKey=new Map(this.renderedEntries().map(entry=>[entry.token,entry])),this.rowsLocale=this.effectiveLocale),this.resolveRovingFocusTarget(),this.editingCell!==null){const column=this.columnsByKey.get(this.editingCell.columnKey);(!this.rowsByKey.has(this.editingCell.rowKey)||normalizedEditTrigger(column?.editTrigger)!=="double-click")&&(this.editingCell=null)}this.editorHadFocusBeforeUpdate=this.focusedEditorCell!==null&&shadowFocusTarget(this)===this.editorElementFor(this.focusedEditorCell.rowKey,this.focusedEditorCell.columnKey)}stickyOffsets(){const offsets=new Map,headerWidths=new Map;for(const el of this.renderRoot.querySelectorAll("th[data-col-key]")){const key=el.dataset.colKey;key!==void 0&&!headerWidths.has(key)&&headerWidths.set(key,el.offsetWidth)}const headerWidth=key=>headerWidths.get(key)??0;let runningStart=0;for(const col of this.columns)stickyDirection(col.sticky)==="start"&&(offsets.set(col.key,runningStart),runningStart+=headerWidth(col.key));let runningEnd=0;for(let i=this.columns.length-1;i>=0;i--){const col=this.columns[i];col&&stickyDirection(col.sticky)==="end"&&(offsets.set(col.key,runningEnd),runningEnd+=headerWidth(col.key))}return offsets}computeHeatDomain(hasHeatTint){if(!hasHeatTint)return null;const entries=this.matchingEntries(),min=this.heatTintScale?.min,max=this.heatTintScale?.max,cached=this.heatDomainCache;if(cached&&cached.entries===entries&&cached.columns===this.columns&&cached.min===min&&cached.max===max)return cached.domain;const domain=this.deriveHeatDomain(entries);return this.heatDomainCache={entries,columns:this.columns,min,max,domain},domain}deriveHeatDomain(entries){const values=[];for(const entry of entries)for(const col of this.columns){const v=col.heatValue?.(entry.row);v!=null&&Number.isFinite(v)&&values.push(v)}const auto=minMax(values),lo=this.heatTintScale?.min??auto?.[0],hi=this.heatTintScale?.max??auto?.[1];return lo===void 0||hi===void 0?null:[lo,hi]}heatShare(col,row,domain){if(!col.heatValue||!domain)return null;const v=col.heatValue(row);if(v==null||!Number.isFinite(v))return null;const[lo,hi]=domain;return`${(finiteRatio(v,lo,hi)*100).toFixed(2)}%`}applyStickyOffsets(writes){if(!this.columns.some(c=>c.sticky))return;const offsets=this.stickyOffsets(),cells=this.renderRoot.querySelectorAll("th[data-col-key], td[data-col-key]"),apply=()=>cells.forEach(el=>{const key=el.dataset.colKey;key!==void 0&&offsets.has(key)&&el.style.setProperty("--lr-table-sticky-offset",`${offsets.get(key)}px`)});writes.push(apply)}updated(changed){super.updated(changed),this.firstUpdateAnnouncementsReady&&this.rowsTruncated&&(changed.has("rows")||changed.has("maxRows"))&&this.announcements.announcePolite(this.localize("tableRowLimit",void 0,{count:getNumberFormat(this.effectiveLocale).format(this.rows.length)})),this.firstUpdateAnnouncementsReady&&changed.has("loading")&&this.loading&&this.announcements.announcePolite(this.loadingText()),this.firstUpdateAnnouncementsReady&&changed.has("loadingMore")&&this.loadingMore&&!this.loading&&this.shadowRoot?.querySelector('[part="more-button"]')&&this.announcements.announcePolite(this.loadingMoreText());const announcesErrorTransition=this.firstUpdateAnnouncementsReady&&changed.has("error")&&this.error,announcesMountedError=!this.firstUpdateAnnouncementsReady&&this.announce&&this.error;if((announcesErrorTransition||announcesMountedError)&&this.announcements.announceAssertive(this.localizedOverride("tableLoadFailed",this.errorHeading)),this.firstUpdateAnnouncementsReady=!0,this.persistReady&&changed.has("priorityColumnsVisible")&&writePersistedState(this.storageFullKey,{priorityColumnsVisible:this.priorityColumnsVisible}),this.persistReady=!0,changed.has("columns")||changed.has("revealColumnsLabel")||changed.has("columnsHideLabel")||changed.has("priorityColumnsVisible")||changed.has("storageKey")){const inertMembers=[],labelsInert=this.revealColumnsLabel!==void 0||this.columnsHideLabel!==void 0;labelsInert&&inertMembers.push("`revealColumnsLabel`/`columnsHideLabel`"),isPersistedPropertyExplicitlySet(this,"priorityColumnsVisible")&&inertMembers.push("`priorityColumnsVisible`"),this.storageKey&&inertMembers.push("`storageKey`"),inertMembers.length>0&&this.columns.length>0&&!this.columns.some(col=>col.priority)&&devWarnOnce(INERT_PRIORITY_COLUMN_CONFIG_WARNING,`<lr-table>: ${inertMembers.join(", ")} `+(inertMembers.length>1||labelsInert?"have":"has")+" no effect unless at least one column declares `priority`.")}const geometryChanged=changed.size===0||[...changed.keys()].some(key=>key!=="selectedRowKeys"&&key!=="selectionMode"&&key!=="activeRowKey"&&key!=="activeColKey"),base=this.renderRoot.querySelector('[part="base"]');if(base&&this.observeBase(base),this.observeTable(this.renderRoot.querySelector('[part="table"]')??void 0),geometryChanged&&this.observeHeaders(),this.restoreRovingFocus(),this.hasAlwaysOnEditors&&this.restoreAlwaysOnEditorFocus(),changed.has("editingCell"))if(this.editingCell){const{rowKey,columnKey}=this.editingCell;queueMicrotask(()=>this.editorElementFor(rowKey,columnKey)?.focus())}else{const previous=changed.get("editingCell");if(previous){const{rowKey,columnKey}=previous;queueMicrotask(()=>this.cellElementForToken(rowKey,columnKey)?.focus())}}geometryChanged&&queueMicrotask(()=>this.syncLayoutGeometry())}restoreRovingFocus(){const snapshot=this.rovingFocusSnapshot;if(this.rovingFocusSnapshot=null,snapshot===null)return;const internalActive=shadowFocusTarget(this);if(internalActive!==null&&internalActive!==snapshot.element)return;const documentActive=activeElementIn(this.ownerDocument);if(documentActive!==null&&documentActive!==this&&documentActive!==this.ownerDocument.body)return;const candidates=snapshot.kind==="header"?this.visibleHeaders():[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")],target=candidates.find(candidate=>snapshot.kind==="header"?candidate.dataset.colKey===snapshot.targetKey:candidate.dataset.rowKey===snapshot.targetKey)??candidates[Math.min(snapshot.index,candidates.length-1)]??null;snapshot.kind==="header"?this.focusHeader(target):this.focusRow(target)}activateColumn(key){this.activeColKey=key;const col=this.columnsByKey.get(key);if(!col?.sortable)return;const sortDir=this.sortKey===key?this.sortDir==="asc"?"desc":"asc":col.defaultSortDir??this.defaultSortDir,request=Object.freeze({phase:"request",sortKey:col.key,sortDir});this.emit("lr-sort-request",request,{cancelable:!0}).defaultPrevented||(this.sortMode==="client"&&(this.sortKey=col.key,this.sortDir=sortDir),this.emit("lr-sort",Object.freeze({phase:"commit",sortKey:col.key,sortDir})))}commitSelectedKeys(next){next.size>this.maxRows&&(next=keySet(next,this.maxRows));const previous=this._selectedKeys;this.isRebind("selectedRowKeys",next,previous),this._selectedKeys=next,this.requestUpdate("selectedRowKeys",previous)}activateRow(key){this.activeRowKey=key;const entry=this.rowsByKey.get(key);if(entry===void 0)return;const{row,key:selectedKey}=entry;if(this.emit("lr-row-activate",Object.freeze({row})),this.selectionMode==="single"){this.commitSelectedKeys(new Set([selectedKey]));const rowKeys=this.asKeyList(Object.freeze([selectedKey]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}else if(this.selectionMode==="multiple"){const rawKey=selectedKey,next=new Set(this._selectedKeys);next.has(rawKey)?next.delete(rawKey):next.add(rawKey),this.commitSelectedKeys(next);const rowKeys=this.asKeyList(Object.freeze([...this._selectedKeys]));this.emit("lr-selection-change",Object.freeze({selectedRowKeys:rowKeys}))}}get hasAlwaysOnEditors(){return this.columns.some(col=>normalizedEditTrigger(col.editTrigger)==="always")}editorValue(row,column){const value=column.editValue?.(row)??row[column.key]??"";return String(value)}startEditing(rowKey,columnKey){const column=this.columnsByKey.get(columnKey);normalizedEditTrigger(column?.editTrigger)!=="double-click"||!this.rowsByKey.has(rowKey)||(this.editingCell={rowKey,columnKey})}commitEdit(event,rowKey,columnKey){event.stopPropagation();const field=event.currentTarget,entry=this.rowsByKey.get(rowKey),column=this.columnsByKey.get(columnKey),isTransient=this.editingCell?.rowKey===rowKey&&this.editingCell.columnKey===columnKey;if(!entry||!column||normalizedEditTrigger(column.editTrigger)===void 0){isTransient&&(this.editingCell=null);return}const value=column.editType==="number"&&field.value!==""?Number(field.value):field.value;this.emit("lr-cell-edit",Object.freeze({row:entry.row,columnKey,value})),isTransient&&(this.editingCell=null)}editorElementFor(rowKey,columnKey){return this.cellElementForToken(rowKey,columnKey)?.querySelector('[part="cell-editor"]')??null}restoreAlwaysOnEditorFocus(){const cell=this.focusedEditorCell;if(cell===null)return;const editor=this.editorElementFor(cell.rowKey,cell.columnKey);editor===null?this.focusedEditorCell=null:this.editorHadFocusBeforeUpdate&&shadowFocusTarget(this)!==editor&&editor.focus(),this.editorHadFocusBeforeUpdate=!1}activateExpandToggle(key){const entry=this.rowsByKey.get(encodeKey(key));if(entry===void 0)return;const expanded=!this._expandedKeys.has(key),detail=Object.freeze({row:entry.row,rowKey:key,expanded});if(this.expansionMode!=="single"&&this.expansionMode!=="multiple"){this.emit("lr-row-expand-toggle",detail);return}requestThenCommit({requestDetail:detail,emitRequest:(requestDetail,init)=>this.emit("lr-row-expand-request",requestDetail,init),commit:()=>{let next=this.expansionMode==="single"?new Set:new Set(this._expandedKeys);expanded?next.add(key):next.delete(key),next.size>this.maxRows&&(next=keySet(next,this.maxRows));const displaced=[...this._expandedKeys].filter(other=>other!==key&&!next.has(other)),previous=this._expandedKeys;this.isRebind("expandedRowKeys",next,previous),this._expandedKeys=next,this.requestUpdate("expandedRowKeys",previous);for(const other of displaced){const displacedEntry=this.rowsByKey.get(encodeKey(other));displacedEntry!==void 0&&this.emit("lr-row-expand-toggle",Object.freeze({row:displacedEntry.row,rowKey:other,expanded:!1}))}this.emit("lr-row-expand-toggle",Object.freeze({...detail,expanded:next.has(key)}))}})}rowElement(rowKey){return this.rowElementForToken(encodeKey(rowKey))}cellElement(rowKey,columnKey){return this.cellElementForToken(encodeKey(rowKey),columnKey)}editCell(rowKey,columnKey){const token=encodeKey(rowKey),trigger=normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger);if(!(trigger===void 0||!this.rowsByKey.has(token))){if(trigger==="always"){this.editorElementFor(token,columnKey)?.focus();return}this.startEditing(token,columnKey)}}expandedContentElement(rowKey){const token=encodeKey(rowKey);return[...this.renderRoot.querySelectorAll("tbody tr[data-expanded-row-key]")].find(el=>el.dataset.expandedRowKey===token)?.querySelector('[part="expanded-cell"]')??null}rowElementForToken(token){return[...this.renderRoot.querySelectorAll("tbody tr[data-row-key]")].find(el=>el.dataset.rowKey===token)??null}cellElementForToken(token,columnKey){return[...this.rowElementForToken(token)?.querySelectorAll("td[data-col-key]")??[]].find(el=>el.dataset.colKey===columnKey)??null}visibleHeaders(){return[...this.renderRoot?.querySelectorAll("th[data-col-key]")??[]].filter(el=>el.offsetParent!==null)}focusHeader(el){el?.dataset.colKey&&(this.activeColKey=el.dataset.colKey,el.focus())}focusRow(el){el?.dataset.rowKey&&(this.activeRowKey=el.dataset.rowKey,el.focus())}onHeaderKeyDown(e,th){if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateColumn(th.dataset.colKey);return}const headers=this.visibleHeaders(),index=headers.indexOf(th);if(index<0)return;const rtl=isRtl(this);switch(e.key){case"ArrowLeft":e.preventDefault(),this.focusHeader(headers[rtl?Math.min(headers.length-1,index+1):Math.max(0,index-1)]??null);return;case"ArrowRight":e.preventDefault(),this.focusHeader(headers[rtl?Math.max(0,index-1):Math.min(headers.length-1,index+1)]??null);return;case"Home":e.preventDefault(),this.focusHeader(headers[0]??null);return;case"End":e.preventDefault(),this.focusHeader(headers[headers.length-1]??null);return;case"ArrowDown":{e.preventDefault();const rows=[...this.renderRoot.querySelectorAll("[data-row-key]")],key=this.focusedRowKey();this.focusRow(rows.find(r=>r.dataset.rowKey===key)??rows[0]??null);return}default:return}}editableCellFor(target){const columnKey=target.dataset.colKey;return target.tagName!=="TD"||columnKey===void 0?null:normalizedEditTrigger(this.columnsByKey.get(columnKey)?.editTrigger)==="double-click"?{element:target,columnKey}:null}editableCellsInRow(tr){return[...tr.querySelectorAll("td[data-editable]")].filter(td=>td.offsetParent!==null&&!td.inert&&!td.closest("[inert]"))}onRowKeyDown(e,tr){const cell=this.editableCellFor(e.target);if((e.key==="Enter"||e.key==="F2")&&cell){e.preventDefault(),this.startEditing(tr.dataset.rowKey,cell.columnKey);return}if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.activateRow(tr.dataset.rowKey);return}if(e.key==="ArrowLeft"||e.key==="ArrowRight"){this.onRowLateralKeyDown(e,tr,cell);return}const bodyRows=[...this.renderRoot.querySelectorAll("[data-row-key]")],index=bodyRows.indexOf(tr);if(!(index<0))switch(e.key){case"ArrowDown":e.preventDefault(),this.focusRow(bodyRows[Math.min(bodyRows.length-1,index+1)]??null);return;case"ArrowUp":if(e.preventDefault(),index===0){const headers=this.visibleHeaders(),key=this.focusedColKey();this.focusHeader(headers.find(h=>h.dataset.colKey===key)??headers[0]??null)}else this.focusRow(bodyRows[index-1]??null);return;case"Home":e.preventDefault(),this.focusRow(bodyRows[0]??null);return;case"End":e.preventDefault(),this.focusRow(bodyRows[bodyRows.length-1]??null);return;default:return}}onRowLateralKeyDown(e,tr,cell){const cells=this.editableCellsInRow(tr);if(cells.length===0)return;e.preventDefault();const forward=e.key===(isRtl(this)?"ArrowLeft":"ArrowRight");if(cell===null){(forward?cells[0]:cells[cells.length-1])?.focus();return}const index=cells.indexOf(cell.element);forward?cells[index+1]?.focus():index<=0?this.focusRow(tr):cells[index-1]?.focus()}renderCellValue(col,row){return typeof col.cell=="function"?col.cell(row):(devWarnOnce(MISSING_CELL_RENDERER_WARNING,"<lr-table>: a column has no required `cell` renderer, so its cells render empty. Supply a `cell` callback for every column."),nothing)}renderCellEditor(row,col,rowKey,alwaysOn){const type=col.editType??"text",value=this.editorValue(row,col),label=col.editLabel?.(row)??this.localize("tableEditCell",void 0,{column:col.label}),onChange=event=>this.commitEdit(event,rowKey,col.key),onKeyDown=event=>this.onEditorKeyDown(event,rowKey,col.key);if(type==="select"){const options=col.editOptions??[];return html`<select
15
15
  part="cell-editor"
16
16
  aria-label=${label}
17
17
  @change=${onChange}
@@ -1 +1 @@
1
- import{finiteRange}from"../../../internal/numbers.js";const CSS_WIDE_KEYWORDS=/^(?:inherit|initial|unset|revert|revert-layer|currentcolor)$/i,HEX_PATTERN=/^#([0-9a-f]+)$/i,FUNCTION_PATTERN=/^([a-z]+)\(([^()]*)\)$/i,NUMBER_PATTERN=/^([-+]?(?:\d+(?:\.\d*)?|\.\d+))(%?)$/,ANGLE_PATTERN=/^([-+]?(?:\d+(?:\.\d*)?|\.\d+))(deg|grad|rad|turn)?$/i,clamp=(value,min,max)=>finiteRange(value,min,min,max);function normalizeHue(hue){if(!Number.isFinite(hue))return 0;if(hue===360)return 360;const wrapped=hue%360;return wrapped<0?wrapped+360:wrapped}function hsva(h,s,v,a=1){return{h:normalizeHue(h),s:clamp(s,0,100),v:clamp(v,0,100),a:clamp(a,0,1)}}function hsvToRgb(h,s,v){const sector=normalizeHue(h)/60,saturation=clamp(s,0,100)/100,value=clamp(v,0,100)/100,chroma=value*saturation,secondary=chroma*(1-Math.abs(sector%2-1)),base=value-chroma;let r=0,g=0,b=0;return sector<1?[r,g,b]=[chroma,secondary,0]:sector<2?[r,g,b]=[secondary,chroma,0]:sector<3?[r,g,b]=[0,chroma,secondary]:sector<4?[r,g,b]=[0,secondary,chroma]:sector<5?[r,g,b]=[secondary,0,chroma]:[r,g,b]=[chroma,0,secondary],{r:(r+base)*255,g:(g+base)*255,b:(b+base)*255}}function rgbToHsv(r,g,b){const red=clamp(r,0,255)/255,green=clamp(g,0,255)/255,blue=clamp(b,0,255)/255,max=Math.max(red,green,blue),min=Math.min(red,green,blue),chroma=max-min;let hue=0;return chroma!==0&&(max===red?hue=60*((green-blue)/chroma%6):max===green?hue=60*((blue-red)/chroma+2):hue=60*((red-green)/chroma+4)),{h:normalizeHue(hue),s:max===0?0:chroma/max*100,v:max*100}}function hsvToHsl(h,s,v){const value=clamp(v,0,100)/100,saturation=clamp(s,0,100)/100,lightness=value*(1-saturation/2),denominator=Math.min(lightness,1-lightness);return{h:normalizeHue(h),s:denominator===0?0:(value-lightness)/denominator*100,l:lightness*100}}function hslToHsv(h,s,l){const lightness=clamp(l,0,100)/100,saturation=clamp(s,0,100)/100,value=lightness+saturation*Math.min(lightness,1-lightness);return{h:normalizeHue(h),s:value===0?0:2*(1-lightness/value)*100,v:value*100}}function parseNumber(text,percentBase){if(text===void 0)return null;const match=NUMBER_PATTERN.exec(text.trim());if(!match)return null;const raw=Number(match[1]);return Number.isFinite(raw)?match[2]==="%"?raw/100*percentBase:raw:null}function parseAngle(text){if(text===void 0)return null;const match=ANGLE_PATTERN.exec(text.trim());if(!match)return null;const raw=Number(match[1]);if(!Number.isFinite(raw))return null;switch((match[2]??"deg").toLowerCase()){case"grad":return raw*360/400;case"rad":return raw*180/Math.PI;case"turn":return raw*360;default:return raw}}function splitArguments(body){const[head="",tail]=body.split("/"),channels=head.split(/[,\s]+/).map(entry=>entry.trim()).filter(Boolean);return tail!==void 0?{channels,alpha:tail.trim()}:channels.length===4?{channels:channels.slice(0,3),alpha:channels[3]}:{channels}}function parseHex(text){const match=HEX_PATTERN.exec(text);if(!match)return null;const digits=match[1],short=digits.length===3||digits.length===4,long=digits.length===6||digits.length===8;if(!short&&!long)return null;const size=short?1:2,channel=index=>{const slice=digits.slice(index*size,index*size+size);return Number.parseInt(short?slice+slice:slice,16)},hasAlpha=digits.length===4||digits.length===8,{h,s,v}=rgbToHsv(channel(0),channel(1),channel(2));return hsva(h,s,v,hasAlpha?channel(3)/255:1)}function parseFunctional(text){const match=FUNCTION_PATTERN.exec(text);if(!match)return null;const name=match[1].toLowerCase(),{channels,alpha}=splitArguments(match[2]??"");if(channels.length!==3)return null;const alphaValue=alpha===void 0?1:parseNumber(alpha,1);if(alphaValue===null)return null;if(name==="rgb"||name==="rgba"){const r=parseNumber(channels[0],255),g=parseNumber(channels[1],255),b=parseNumber(channels[2],255);if(r===null||g===null||b===null)return null;const converted=rgbToHsv(r,g,b);return hsva(converted.h,converted.s,converted.v,alphaValue)}if(name==="hsl"||name==="hsla"||name==="hsv"||name==="hsva"){const h=parseAngle(channels[0]),second=parseNumber(channels[1],100),third=parseNumber(channels[2],100);if(h===null||second===null||third===null)return null;if(name.startsWith("hsv"))return hsva(h,second,third,alphaValue);const converted=hslToHsv(h,second,third);return hsva(converted.h,converted.s,converted.v,alphaValue)}return null}function parseViaCssom(text){if(typeof document>"u"||CSS_WIDE_KEYWORDS.test(text))return null;const cached=cssomCache.get(text);if(cached!==void 0)return cached;const resolved=resolveViaCssom(text);return cssomCache.size>=CSSOM_CACHE_LIMIT&&cssomCache.clear(),cssomCache.set(text,resolved),resolved}const CSSOM_CACHE_LIMIT=64,cssomCache=new Map;function resolveViaCssom(text){const probe=document.createElement("span");if(probe.style.color=text,probe.style.color==="")return null;probe.style.position="absolute",probe.style.visibility="hidden",probe.style.pointerEvents="none",document.body.append(probe);const computed=getComputedStyle(probe).color;probe.remove();const serialized=computed.trim(),functional=parseFunctional(serialized);if(functional)return functional;const canvas=document.createElement("canvas");canvas.width=1,canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0});if(!context)return null;context.clearRect(0,0,1,1),context.fillStyle=serialized,context.fillRect(0,0,1,1);const[red=0,green=0,blue=0,alpha=0]=context.getImageData(0,0,1,1).data,converted=rgbToHsv(red,green,blue);return hsva(converted.h,converted.s,converted.v,alpha/255)}function parseColor(input){const text=(input??"").trim();return text===""?null:parseHex(text)??parseFunctional(text)??parseViaCssom(text)}const hexByte=channel=>Math.round(clamp(channel,0,255)).toString(16).padStart(2,"0"),round=value=>String(Math.round(value)),alphaText=alpha=>clamp(alpha,0,1).toFixed(2);function formatColor(color,format,uppercase=!1){const{r,g,b}=hsvToRgb(color.h,color.s,color.v);let text;switch(format){case"hex":text=`#${hexByte(r)}${hexByte(g)}${hexByte(b)}`;break;case"hexa":text=`#${hexByte(r)}${hexByte(g)}${hexByte(b)}${hexByte(color.a*255)}`;break;case"rgb":text=`rgb(${round(r)}, ${round(g)}, ${round(b)})`;break;case"rgba":text=`rgba(${round(r)}, ${round(g)}, ${round(b)}, ${alphaText(color.a)})`;break;case"hsv":text=`hsv(${round(color.h)}, ${round(color.s)}%, ${round(color.v)}%)`;break;case"hsva":text=`hsva(${round(color.h)}, ${round(color.s)}%, ${round(color.v)}%, ${alphaText(color.a)})`;break;default:{const hsl=hsvToHsl(color.h,color.s,color.v);text=format==="hsla"?`hsla(${round(hsl.h)}, ${round(hsl.s)}%, ${round(hsl.l)}%, ${alphaText(color.a)})`:`hsl(${round(hsl.h)}, ${round(hsl.s)}%, ${round(hsl.l)}%)`;break}}return uppercase?text.toUpperCase():text}function withAlphaFormat(format,includeAlpha){return includeAlpha?`${format}a`:format}function cssColor(color){const{r,g,b}=hsvToRgb(color.h,color.s,color.v);return`rgba(${round(r)}, ${round(g)}, ${round(b)}, ${alphaText(color.a)})`}function sameColor(left,right){return formatColor(left,"hexa")===formatColor(right,"hexa")}export{cssColor,formatColor,hslToHsv,hsvToHsl,hsvToRgb,hsva,parseColor,rgbToHsv,sameColor,withAlphaFormat};
1
+ import{finiteRange}from"../../../internal/numbers.js";const CSS_WIDE_KEYWORDS=/^(?:inherit|initial|unset|revert|revert-layer|currentcolor)$/i,HEX_PATTERN=/^#([0-9a-f]+)$/i,FUNCTION_PATTERN=/^([a-z]+)\(([^()]*)\)$/i,NUMBER_PATTERN=/^([-+]?(?:\d+(?:\.\d*)?|\.\d+))(%?)$/,ANGLE_PATTERN=/^([-+]?(?:\d+(?:\.\d*)?|\.\d+))(deg|grad|rad|turn)?$/i,clamp=(value,min,max)=>finiteRange(value,min,min,max);function normalizeHue(hue){if(!Number.isFinite(hue))return 0;if(hue===360)return 360;const wrapped=hue%360;return wrapped<0?wrapped+360:wrapped}function hsva(h,s,v,a=1){return{h:normalizeHue(h),s:clamp(s,0,100),v:clamp(v,0,100),a:clamp(a,0,1)}}function hsvToRgb(h,s,v){const sector=normalizeHue(h)/60,saturation=clamp(s,0,100)/100,value=clamp(v,0,100)/100,chroma=value*saturation,secondary=chroma*(1-Math.abs(sector%2-1)),base=value-chroma;let r=0,g=0,b=0;return sector<1?[r,g,b]=[chroma,secondary,0]:sector<2?[r,g,b]=[secondary,chroma,0]:sector<3?[r,g,b]=[0,chroma,secondary]:sector<4?[r,g,b]=[0,secondary,chroma]:sector<5?[r,g,b]=[secondary,0,chroma]:[r,g,b]=[chroma,0,secondary],{r:(r+base)*255,g:(g+base)*255,b:(b+base)*255}}function rgbToHsv(r,g,b){const red=clamp(r,0,255)/255,green=clamp(g,0,255)/255,blue=clamp(b,0,255)/255,max=Math.max(red,green,blue),min=Math.min(red,green,blue),chroma=max-min;let hue=0;return chroma!==0&&(max===red?hue=60*((green-blue)/chroma%6):max===green?hue=60*((blue-red)/chroma+2):hue=60*((red-green)/chroma+4)),{h:normalizeHue(hue),s:max===0?0:chroma/max*100,v:max*100}}function hsvToHsl(h,s,v){const value=clamp(v,0,100)/100,saturation=clamp(s,0,100)/100,lightness=value*(1-saturation/2),denominator=Math.min(lightness,1-lightness);return{h:normalizeHue(h),s:denominator===0?0:(value-lightness)/denominator*100,l:lightness*100}}function hslToHsv(h,s,l){const lightness=clamp(l,0,100)/100,saturation=clamp(s,0,100)/100,value=lightness+saturation*Math.min(lightness,1-lightness);return{h:normalizeHue(h),s:value===0?0:2*(1-lightness/value)*100,v:value*100}}function parseNumber(text,percentBase){if(text===void 0)return null;const match=NUMBER_PATTERN.exec(text.trim());if(!match)return null;const raw=Number(match[1]);return Number.isFinite(raw)?match[2]==="%"?raw/100*percentBase:raw:null}function parseAngle(text){if(text===void 0)return null;const match=ANGLE_PATTERN.exec(text.trim());if(!match)return null;const raw=Number(match[1]);if(!Number.isFinite(raw))return null;switch((match[2]??"deg").toLowerCase()){case"grad":return raw*360/400;case"rad":return raw*180/Math.PI;case"turn":return raw*360;default:return raw}}function splitArguments(body){const[head="",tail]=body.split("/"),channels=head.split(/[,\s]+/).map(entry=>entry.trim()).filter(Boolean);return tail!==void 0?{channels,alpha:tail.trim()}:channels.length===4?{channels:channels.slice(0,3),alpha:channels[3]}:{channels}}function parseHex(text){const match=HEX_PATTERN.exec(text);if(!match)return null;const digits=match[1],short=digits.length===3||digits.length===4,long=digits.length===6||digits.length===8;if(!short&&!long)return null;const size=short?1:2,channel=index=>{const slice=digits.slice(index*size,index*size+size);return Number.parseInt(short?slice+slice:slice,16)},hasAlpha=digits.length===4||digits.length===8,{h,s,v}=rgbToHsv(channel(0),channel(1),channel(2));return hsva(h,s,v,hasAlpha?channel(3)/255:1)}const float32=Math.fround,BROWSER_ROUNDING_EPSILON=float32(1e-7),BYTE_MARGIN=1e-9;function browserHslBytes(hue,saturation,lightness){const h=float32(normalizeHue(hue)),s=float32(clamp(saturation,0,100)/100),l=float32(clamp(lightness,0,100)/100),channel=offset=>{let value=l;if(s!==0){const k=float32(offset+float32(h/30))%12,a=float32(s*Math.min(l,float32(1-l))),t=Math.max(-1,Math.min(float32(k-3),float32(9-k),1));value=float32(l-float32(a*t))}return Math.round(clamp(float32(float32(value+BROWSER_ROUNDING_EPSILON)*255),0,255))};return[channel(0),channel(8),channel(4)]}function settleOnBytes(color,bytes){const{r,g,b}=hsvToRgb(color.h,color.s,color.v),channels=[r,g,b];if(channels.every((channel,index)=>Math.round(channel)===bytes[index]))return color;const[red=0,green=0,blue=0]=channels.map((channel,index)=>{const byte=bytes[index]??0;return clamp(channel,byte-.5+BYTE_MARGIN,byte+.5-BYTE_MARGIN)}),settled=rgbToHsv(red,green,blue),keepHue=settled.s===0||settled.h===0&&color.h===360;return hsva(keepHue?color.h:settled.h,settled.s,settled.v,color.a)}function parseFunctional(text){const match=FUNCTION_PATTERN.exec(text);if(!match)return null;const name=match[1].toLowerCase(),{channels,alpha}=splitArguments(match[2]??"");if(channels.length!==3)return null;const alphaValue=alpha===void 0?1:parseNumber(alpha,1);if(alphaValue===null)return null;if(name==="rgb"||name==="rgba"){const r=parseNumber(channels[0],255),g=parseNumber(channels[1],255),b=parseNumber(channels[2],255);if(r===null||g===null||b===null)return null;const converted=rgbToHsv(r,g,b);return hsva(converted.h,converted.s,converted.v,alphaValue)}if(name==="hsl"||name==="hsla"||name==="hsv"||name==="hsva"){const h=parseAngle(channels[0]),second=parseNumber(channels[1],100),third=parseNumber(channels[2],100);if(h===null||second===null||third===null)return null;if(name.startsWith("hsv"))return hsva(h,second,third,alphaValue);const converted=hslToHsv(h,second,third);return settleOnBytes(hsva(converted.h,converted.s,converted.v,alphaValue),browserHslBytes(h,second,third))}return null}function parseViaCssom(text){if(typeof document>"u"||CSS_WIDE_KEYWORDS.test(text))return null;const cached=cssomCache.get(text);if(cached!==void 0)return cached;const resolved=resolveViaCssom(text);return cssomCache.size>=CSSOM_CACHE_LIMIT&&cssomCache.clear(),cssomCache.set(text,resolved),resolved}const CSSOM_CACHE_LIMIT=64,cssomCache=new Map;function resolveViaCssom(text){const probe=document.createElement("span");if(probe.style.color=text,probe.style.color==="")return null;probe.style.position="absolute",probe.style.visibility="hidden",probe.style.pointerEvents="none",document.body.append(probe);const computed=getComputedStyle(probe).color;probe.remove();const serialized=computed.trim(),functional=parseFunctional(serialized);if(functional)return functional;const canvas=document.createElement("canvas");canvas.width=1,canvas.height=1;const context=canvas.getContext("2d",{willReadFrequently:!0});if(!context)return null;context.clearRect(0,0,1,1),context.fillStyle=serialized,context.fillRect(0,0,1,1);const[red=0,green=0,blue=0,alpha=0]=context.getImageData(0,0,1,1).data,converted=rgbToHsv(red,green,blue);return hsva(converted.h,converted.s,converted.v,alpha/255)}function parseColor(input){const text=(input??"").trim();return text===""?null:parseHex(text)??parseFunctional(text)??parseViaCssom(text)}const hexByte=channel=>Math.round(clamp(channel,0,255)).toString(16).padStart(2,"0"),round=value=>String(Math.round(value)),alphaText=alpha=>clamp(alpha,0,1).toFixed(2);function formatColor(color,format,uppercase=!1){const{r,g,b}=hsvToRgb(color.h,color.s,color.v);let text;switch(format){case"hex":text=`#${hexByte(r)}${hexByte(g)}${hexByte(b)}`;break;case"hexa":text=`#${hexByte(r)}${hexByte(g)}${hexByte(b)}${hexByte(color.a*255)}`;break;case"rgb":text=`rgb(${round(r)}, ${round(g)}, ${round(b)})`;break;case"rgba":text=`rgba(${round(r)}, ${round(g)}, ${round(b)}, ${alphaText(color.a)})`;break;case"hsv":text=`hsv(${round(color.h)}, ${round(color.s)}%, ${round(color.v)}%)`;break;case"hsva":text=`hsva(${round(color.h)}, ${round(color.s)}%, ${round(color.v)}%, ${alphaText(color.a)})`;break;default:{const hsl=hsvToHsl(color.h,color.s,color.v);text=format==="hsla"?`hsla(${round(hsl.h)}, ${round(hsl.s)}%, ${round(hsl.l)}%, ${alphaText(color.a)})`:`hsl(${round(hsl.h)}, ${round(hsl.s)}%, ${round(hsl.l)}%)`;break}}return uppercase?text.toUpperCase():text}function withAlphaFormat(format,includeAlpha){return includeAlpha?`${format}a`:format}function cssColor(color){const{r,g,b}=hsvToRgb(color.h,color.s,color.v);return`rgba(${round(r)}, ${round(g)}, ${round(b)}, ${alphaText(color.a)})`}function sameColor(left,right){return formatColor(left,"hexa")===formatColor(right,"hexa")}export{cssColor,formatColor,hslToHsv,hsvToHsl,hsvToRgb,hsva,parseColor,rgbToHsv,sameColor,withAlphaFormat};
@@ -1 +1 @@
1
- import{getDateTimeFormat}from"../../../internal/intl-cache.js";function normalizeCalendarMonths(value){const numeric=typeof value=="number"?value:Number(value);return Number.isFinite(numeric)?Math.min(2,Math.max(1,Math.trunc(numeric))):1}function normalizeWeekdayFormat(value){return value==="narrow"||value==="long"?value:"short"}function normalizeCalendarMode(value){return value==="range"?"range":"single"}function dateTimeFormat(locale,options){try{return getDateTimeFormat(typeof locale=="string"&&locale?locale:void 0,{calendar:"gregory",...options})}catch{return getDateTimeFormat(void 0,{calendar:"gregory",...options})}}function localDate(year,month=0,day=1){const date=new Date(0);return date.setHours(0,0,0,0),date.setFullYear(year,month,day),date}function utcDate(year,month=0,day=1){const date=new Date(0);return date.setUTCHours(0,0,0,0),date.setUTCFullYear(year,month,day),date}function parseISO(s){if(!s)return null;const m=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s.trim());if(!m)return null;const year=Number(m[1]),month=Number(m[2]),day=Number(m[3]),d=localDate(year,month-1,day);return!Number.isFinite(d.getTime())||d.getFullYear()!==year||d.getMonth()!==month-1||d.getDate()!==day?null:d}function formatISO(d){if(!Number.isFinite(d.getTime())||d.getFullYear()<0||d.getFullYear()>9999)return"";const mm=String(d.getMonth()+1).padStart(2,"0"),dd=String(d.getDate()).padStart(2,"0");return`${String(d.getFullYear()).padStart(4,"0")}-${mm}-${dd}`}function isSameDay(a,b){return a.getFullYear()===b.getFullYear()&&a.getMonth()===b.getMonth()&&a.getDate()===b.getDate()}function addMonths(d,n){return localDate(d.getFullYear(),d.getMonth()+n,1)}function addMonthsClampingDay(d,n){const targetMonth=d.getMonth()+n,lastDayOfTargetMonth=localDate(d.getFullYear(),targetMonth+1,0).getDate();return localDate(d.getFullYear(),targetMonth,Math.min(d.getDate(),lastDayOfTargetMonth))}function clampDate(d,min,max){return min&&d<min?min:max&&d>max?max:d}function monthMatrix(year,month,firstDayOfWeek=0){const offset=(localDate(year,month,1).getDay()-firstDayOfWeek+7)%7,cursor=localDate(year,month,1-offset),weeks=[];for(let w=0;w<6;w++){const row=[];for(let d=0;d<7;d++)row.push(new Date(cursor)),cursor.setDate(cursor.getDate()+1);weeks.push(row)}return weeks}function weekdayLabels(firstDayOfWeek=0,format="short",locale){const numericFirstDay=Number(firstDayOfWeek),start=Number.isFinite(numericFirstDay)?(Math.trunc(numericFirstDay)%7+7)%7:0,fmt=dateTimeFormat(locale,{weekday:normalizeWeekdayFormat(format)}),labels=[];for(let i=0;i<7;i++){const day=(start+i)%7;labels.push(fmt.format(new Date(2021,7,1+day)))}return labels}function monthTitle(year,month,locale){return dateTimeFormat(locale,{month:"long",year:"numeric"}).format(localDate(year,month,1))}const FDOW={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6};function localeFirstDayOfWeek(locale){try{const l=new Intl.Locale(locale),firstDay=l.weekInfo?.firstDay??l.getWeekInfo?.().firstDay;return firstDay?firstDay%7:null}catch{return null}}function resolveFirstDayOfWeek(value,locale){return!value||value==="auto"?(locale?localeFirstDayOfWeek(locale):null)??0:typeof value=="string"?FDOW[value.toLowerCase()]??0:0}export{addMonths,addMonthsClampingDay,clampDate,dateTimeFormat,formatISO,isSameDay,localDate,monthMatrix,monthTitle,normalizeCalendarMode,normalizeCalendarMonths,normalizeWeekdayFormat,parseISO,resolveFirstDayOfWeek,utcDate,weekdayLabels};
1
+ import{getDateTimeFormat}from"../../../internal/intl-cache.js";function normalizeCalendarMonths(value){const numeric=typeof value=="number"?value:Number(value);return Number.isFinite(numeric)?Math.min(2,Math.max(1,Math.trunc(numeric))):1}function normalizeWeekdayFormat(value){return value==="narrow"||value==="long"?value:"short"}function normalizeCalendarMode(value){return value==="range"?"range":"single"}function dateTimeFormat(locale,options){try{return getDateTimeFormat(typeof locale=="string"&&locale?locale:void 0,{calendar:"gregory",...options})}catch{return getDateTimeFormat(void 0,{calendar:"gregory",...options})}}function localDate(year,month=0,day=1){const date=new Date(0);return date.setHours(0,0,0,0),date.setFullYear(year,month,day),date}function utcDate(year,month=0,day=1){const date=new Date(0);return date.setUTCHours(0,0,0,0),date.setUTCFullYear(year,month,day),date}function parseISO(s){if(!s)return null;const m=/^(\d{4})-(\d{2})-(\d{2})$/.exec(s.trim());if(!m)return null;const year=Number(m[1]),month=Number(m[2]),day=Number(m[3]),d=localDate(year,month-1,day);return!Number.isFinite(d.getTime())||d.getFullYear()!==year||d.getMonth()!==month-1||d.getDate()!==day?null:d}function formatISO(d){if(!Number.isFinite(d.getTime())||d.getFullYear()<0||d.getFullYear()>9999)return"";const mm=String(d.getMonth()+1).padStart(2,"0"),dd=String(d.getDate()).padStart(2,"0");return`${String(d.getFullYear()).padStart(4,"0")}-${mm}-${dd}`}function isSameDay(a,b){return a.getFullYear()===b.getFullYear()&&a.getMonth()===b.getMonth()&&a.getDate()===b.getDate()}function addMonths(d,n){return localDate(d.getFullYear(),d.getMonth()+n,1)}function addMonthsClampingDay(d,n){const targetMonth=d.getMonth()+n,lastDayOfTargetMonth=localDate(d.getFullYear(),targetMonth+1,0).getDate();return localDate(d.getFullYear(),targetMonth,Math.min(d.getDate(),lastDayOfTargetMonth))}function clampDate(d,min,max){return min&&d<min?min:max&&d>max?max:d}function monthMatrix(year,month,firstDayOfWeek=0){const offset=(localDate(year,month,1).getDay()-firstDayOfWeek+7)%7,cursor=localDate(year,month,1-offset),weeks=[];for(let w=0;w<6;w++){const row=[];for(let d=0;d<7;d++)row.push(new Date(cursor)),cursor.setDate(cursor.getDate()+1);weeks.push(row)}return weeks}function weekdayLabels(firstDayOfWeek=0,format="short",locale){const numericFirstDay=Number(firstDayOfWeek),start=Number.isFinite(numericFirstDay)?(Math.trunc(numericFirstDay)%7+7)%7:0,fmt=dateTimeFormat(locale,{weekday:normalizeWeekdayFormat(format)}),labels=[];for(let i=0;i<7;i++){const day=(start+i)%7;labels.push(fmt.format(new Date(2021,7,1+day)))}return labels}function monthTitle(year,month,locale){return dateTimeFormat(locale,{month:"long",year:"numeric"}).format(localDate(year,month,1))}const FDOW={sun:0,mon:1,tue:2,wed:3,thu:4,fri:5,sat:6};function localeFirstDayOfWeek(locale){try{const l=new Intl.Locale(locale),firstDay=l.weekInfo?.firstDay??l.getWeekInfo?.().firstDay;return firstDay?firstDay%7:null}catch{return null}}function resolveFirstDayOfWeek(value,locale){if(!value||value==="auto")return(locale?localeFirstDayOfWeek(locale):null)??0;if(typeof value!="string")return 0;const name=value.toLowerCase();return Object.hasOwn(FDOW,name)?FDOW[name]:0}export{addMonths,addMonthsClampingDay,clampDate,dateTimeFormat,formatISO,isSameDay,localDate,monthMatrix,monthTitle,normalizeCalendarMode,normalizeCalendarMonths,normalizeWeekdayFormat,parseISO,resolveFirstDayOfWeek,utcDate,weekdayLabels};
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{setNativeRangeText}from"../../../internal/native-text-control.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{FormAssociated,isBarredFromValidation}from"../../../internal/form-associated.js";import{SET_ANCHORED_VALIDITY}from"../../../internal/anchored-validity.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{finiteInteger}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{contextualSizes}from"../../../internal/contextual-vocabulary.styles.js";import{submitFormImplicitly,submitOnEnter}from"../../../internal/submit-on-enter.js";import{styles}from"./otp-input.styles.js";import{dispatchNativeEvent,dispatchNativeInputEvent,relayNativeEvent}from"../../../internal/native-event-relay.js";import{currentValidityValidator}from"../form-validator.js";import{declaredDefaultConverter,literalSetConverter}from"../../../internal/converters.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{LYRA_DEFAULT_otpInputIncomplete,LYRA_DEFAULT_otpInputLabel}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";const APPEARANCE=literalSetConverter(["outlined","filled","filled-outlined","contained"],"outlined"),ACCEPTED={numeric:/[0-9]/,alpha:/[a-zA-Z]/,alphanumeric:/[a-zA-Z0-9]/},DEFAULT_LENGTH=6,MAX_LENGTH=32,MAX_FORMAT_SOURCE_LENGTH=4096,MAX_VALUE_SOURCE_LENGTH=4096;class LyraOtpInputBase extends LyraElement{static{this.styles=[LyraElement.styles,contextualSizes,scrollOverflowFadeStyles,styles]}}class LyraOtpInput extends FormAssociated(LyraOtpInputBase){static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,otpInputIncomplete:LYRA_DEFAULT_otpInputIncomplete,otpInputLabel:LYRA_DEFAULT_otpInputLabel}}static get validators(){return[currentValidityValidator("required","disabled","readonly","value","length","pattern")]}get appearance(){return this._appearance}set appearance(next){const normalized=APPEARANCE.normalizeReflected(this,"appearance",next),old=this._appearance;this._appearance=normalized,normalized!==old&&this.requestUpdate("appearance",old)}get hasLabelSlot(){return this.slotPresence.has("label")}get hasHintSlot(){return this.slotPresence.has("hint")}get hasErrorSlot(){return this.slotPresence.has("error")}constructor(){super(),this.label="",this.hint="",this.errorText="",this.withLabel=!1,this.withHint=!1,this._appearance="outlined",this.autofocus=!1,this.autosubmit=!1,this.size="m",this.length=DEFAULT_LENGTH,this.format="",this.type="numeric",this.case="preserve",this.mask=!1,this.withMask=!1,this.readonly=!1,this.autocomplete="one-time-code",this.focused=!1,this.slotPresence=new SlotPresenceController(this),this.touched=!1,this.labelId=nextId("otp-input-label"),this.hintId=nextId("otp-input-hint"),this.errorId=nextId("otp-input-error"),this.activeSegmentIndex=0,this.segmentValues=[],this.rawValue="",this.segmentEditPendingChange=!1,this.autosubmitToken=0,this.hostDescription=new HostDescriptionController(this,()=>this.control??null),this.onInput=event=>{if(event.isComposing===!0){event.stopPropagation();return}const raw=event.target.value,next=this.sanitize(raw),previousFilled=this.filledSegmentCount,layoutChanged=Array.from({length:this.renderedSegmentCount},(_,index)=>next[index]??"").some((value,index)=>value!==this.segmentValues[index]);if(this.control&&this.control.value!==next&&(this.control.value=next),next===this.value&&!layoutChanged){event.stopImmediatePropagation();return}this.touched=!0,this.value=next,relayNativeEvent(this,event),this.emit("lr-input",{value:next}),this.completeIfTransition(previousFilled)},this.onKeyDown=event=>{if(this.effectiveDisabled)return;if(event.key==="ArrowLeft"||event.key==="ArrowRight"){event.preventDefault();const physical=event.key==="ArrowRight"?1:-1,delta=this.effectiveDirection==="rtl"?-physical:physical;this.setActiveSegment(this.activeSegmentIndex+delta);return}if(event.key==="Enter"){this.readonly||submitOnEnter(this,event,{beforeSubmit:()=>this.flushPendingChange()});return}if(this.readonly||event.isComposing)return;const selection=this.selectedSegmentRange;if(event.key==="Backspace"||event.key==="Delete"){event.preventDefault();const values2=this.normalizedSegmentValues();if(selection){for(const index of selection.indices)values2[index]="";this.commitSegmentEdit(values2,event.key==="Backspace"?"deleteContentBackward":"deleteContentForward"),this.setActiveSegment(selection.first);return}const changed=!!values2[this.activeSegmentIndex];values2[this.activeSegmentIndex]="",changed&&this.commitSegmentEdit(values2,event.key==="Backspace"?"deleteContentBackward":"deleteContentForward"),event.key==="Backspace"&&this.setActiveSegment(this.activeSegmentIndex-1);return}if(event.ctrlKey||event.metaKey||event.altKey||event.key.length!==1)return;event.preventDefault();const accepted=this.sanitize(event.key).slice(0,1);if(!accepted)return;const values=this.normalizedSegmentValues(),targetIndex=selection?.first??this.activeSegmentIndex;if(selection)for(const index of selection.indices)values[index]="";values[targetIndex]=accepted,this.commitSegmentEdit(values,"insertText",accepted),this.setActiveSegment(targetIndex+1)},this.onPaste=event=>{if(this.effectiveDisabled||this.readonly)return;const pasted=this.sanitize(event.clipboardData?.getData("text")??"");if(event.preventDefault(),!pasted)return;const values=Array.from({length:this.renderedSegmentCount},(_,index)=>pasted[index]??"");this.commitSegmentEdit(values,"insertFromPaste",pasted),this.setActiveSegment(Math.min(pasted.length,this.renderedSegmentCount-1))},this.onChange=event=>{this.segmentEditPendingChange=!1;const value=this.value;relayNativeEvent(this,event),this.emit("lr-change",{value})},this.onFocus=event=>{this.focused=!0,relayNativeEvent(this,event)},this.onBlur=event=>{this.focused=!1,this.effectiveDisabled||(this.touched=!0),this.flushPendingChange(),relayNativeEvent(this,event)},observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part~="segments"]'))}get input(){return this.control??null}get validationTarget(){return this.control??null}get value(){return super.value}set value(next){this.autosubmitToken+=1,this.rawValue=next??"";const normalized=this.sanitize(this.rawValue);this.packSegmentValues(normalized),super.value=normalized}get defaultValue(){return super.defaultValue}set defaultValue(next){this.autosubmitToken+=1,super.defaultValue=next}get formattedCells(){if(this.parsedFormatSource===this.format)return this.parsedFormatCells??null;if(this.parsedFormatSource=this.format,!this.format)return this.parsedFormatCells=null,null;const cells=[];let segments=0,literal="";const flushLiteral=()=>{literal&&(cells.push({kind:"separator",text:literal}),literal="")};for(const char of this.format.slice(0,MAX_FORMAT_SOURCE_LENGTH)){if(char!=="#"){literal+=char;continue}if(segments>=MAX_LENGTH)break;flushLiteral(),cells.push({kind:"segment"}),segments+=1}return flushLiteral(),this.parsedFormatCells=segments>0?cells:null,this.parsedFormatCells}get renderedSegmentCount(){const formatted=this.formattedCells;return formatted?formatted.filter(cell=>cell.kind==="segment").length:Math.min(MAX_LENGTH,Math.max(1,finiteInteger(this.length,DEFAULT_LENGTH)))}get effectiveLength(){return this.renderedSegmentCount}get cells(){return this.formattedCells??Array.from({length:this.renderedSegmentCount},()=>({kind:"segment"}))}sanitize(raw){const accepted=ACCEPTED[this.type]??ACCEPTED.numeric,limit=this.renderedSegmentCount;let out="";for(const char of(raw??"").slice(0,MAX_VALUE_SOURCE_LENGTH))if(accepted.test(char)&&(out+=char),out.length>=limit)break;return this.case==="upper"?out=out.toUpperCase():this.case==="lower"&&(out=out.toLowerCase()),out.slice(0,limit)}packSegmentValues(value){const count=this.renderedSegmentCount;this.segmentValues=Array.from({length:count},(_,index)=>value[index]??""),this.activeSegmentIndex=Math.min(value.length,count-1)}get filledSegmentCount(){return Array.isArray(this.segmentValues)?this.segmentValues.reduce((count,value)=>count+(value?1:0),0):this.value.length}normalizedSegmentValues(values=this.segmentValues){return Array.from({length:this.renderedSegmentCount},(_,index)=>values[index]??"")}setActiveSegment(index){const next=Math.min(this.renderedSegmentCount-1,Math.max(0,index));this.activeSegmentIndex=next;const caret=this.normalizedSegmentValues().slice(0,next).filter(Boolean).length;this.control?.setSelectionRange(caret,caret),this.updateComplete.then(()=>{this.renderRoot.querySelectorAll('[part~="segment"]')[next]?.scrollIntoView({block:"nearest",inline:"nearest"})})}submitOwningForm(){const form=this.getForm();form&&submitFormImplicitly(form)}completeIfTransition(previousFilled){if(previousFilled>=this.renderedSegmentCount||this.filledSegmentCount!==this.renderedSegmentCount)return;const completionValue=this.value,token=this.autosubmitToken,completeEvent=this.emit("lr-complete",{value:completionValue},{cancelable:!0});this.autosubmit&&setTimeout(()=>{token!==this.autosubmitToken||completeEvent.defaultPrevented||!this.isConnected||!this.autosubmit||this.effectiveDisabled||this.readonly||this.value!==completionValue||this.filledSegmentCount!==this.renderedSegmentCount||this.submitOwningForm()})}commitSegmentEdit(values,inputType,data=null){this.autosubmitToken+=1;const previousFilled=this.filledSegmentCount;this.segmentValues=this.normalizedSegmentValues(values);const nextValue=this.segmentValues.join("");super.value=nextValue,this.control&&(this.control.value=nextValue),this.touched=!0,dispatchNativeInputEvent(this,{data,inputType}),this.emit("lr-input",{value:nextValue}),this.segmentEditPendingChange=!0,this.completeIfTransition(previousFilled),this.requestUpdate()}get selectedSegmentRange(){const start=this.control?.selectionStart,end=this.control?.selectionEnd;if(start==null||end===void 0||end===null||start===end)return null;const indices=this.normalizedSegmentValues().map((value,index)=>value?index:-1).filter(index=>index>=0).slice(start,end),first=indices[0];return first===void 0?null:{indices,first}}segmentIndexAtCompactOffset(offset){const values=this.normalizedSegmentValues();let occupied=0;for(let index=0;index<values.length;index+=1){if(occupied>=offset)return index;values[index]&&(occupied+=1)}return Math.max(0,values.length-1)}syncActiveSegmentFromSelection(){const control=this.control;if(!control||control.selectionStart===null)return;const selected=this.selectedSegmentRange;this.activeSegmentIndex=selected?.first??this.segmentIndexAtCompactOffset(control.selectionStart)}get selectionStart(){return this.control?.selectionStart??null}set selectionStart(value){this.control&&(this.control.selectionStart=value,this.syncActiveSegmentFromSelection())}get selectionEnd(){return this.control?.selectionEnd??null}set selectionEnd(value){this.control&&(this.control.selectionEnd=value,this.syncActiveSegmentFromSelection())}get selectionDirection(){return this.control?.selectionDirection??null}set selectionDirection(value){this.control&&(this.control.selectionDirection=value)}focus(options){this.effectiveDisabled||this.control?.focus(options)}blur(){this.control?.blur()}click(){this.effectiveDisabled||this.control?.click()}select(){this.control?.select()}setSelectionRange(start,end,direction){this.control&&(this.control.setSelectionRange(start,end,direction),this.syncActiveSegmentFromSelection())}setRangeText(replacement,start,end,selectMode){const control=this.control;if(!control)return;const selectionPrefixLength=(value,offset)=>{if(offset===null)return null;const boundedOffset=Math.min(MAX_VALUE_SOURCE_LENGTH,Math.max(0,offset));return this.sanitize(value.slice(0,boundedOffset)).length},currentRaw=control.value,currentSelectionStart=selectionPrefixLength(currentRaw,control.selectionStart),currentSelectionEnd=selectionPrefixLength(currentRaw,control.selectionEnd),currentSelectionDirection=control.selectionDirection,boundedCurrent=this.sanitize(currentRaw);currentRaw!==boundedCurrent&&(control.value=boundedCurrent,currentSelectionStart!==null&&currentSelectionEnd!==null&&control.setSelectionRange(currentSelectionStart,currentSelectionEnd,currentSelectionDirection??void 0));const boundedReplacement=this.sanitize(replacement);setNativeRangeText(control,boundedReplacement,start,end,selectMode);const raw=control.value,selectionStart=selectionPrefixLength(raw,control.selectionStart),selectionEnd=selectionPrefixLength(raw,control.selectionEnd),selectionDirection=control.selectionDirection,normalized=this.sanitize(raw);this.value=normalized,control.value=normalized,selectionStart!==null&&selectionEnd!==null&&control.setSelectionRange(selectionStart,selectionEnd,selectionDirection??void 0),this.syncActiveSegmentFromSelection()}clear(){!this.value||this.effectiveDisabled||this.readonly||(this.value="",this.control&&(this.control.value=""),dispatchNativeInputEvent(this,{inputType:"deleteContentBackward"}),this.emit("lr-input",{value:""}),dispatchNativeEvent(this,"change"),this.emit("lr-change",{value:""}),this.emit("lr-clear"))}formResetCallback(){this.autosubmitToken+=1,super.formResetCallback(),this.touched=!1,this.segmentEditPendingChange=!1}formStateRestoreCallback(state2,reason){this.autosubmitToken+=1,super.formStateRestoreCallback(state2,reason)}disconnectedCallback(){super.disconnectedCallback(),this.autosubmitToken+=1}reportValidity(){return this.touched=!0,super.reportValidity()}firstUpdated(changed){super.firstUpdated(changed),this.autofocus&&this.scheduleAfterUpdate(()=>this.focus(),"otp-autofocus")}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted()}updated(changed){super.updated(changed),this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid)}willUpdate(changed){if(super.willUpdate(changed),changed.has("type")||changed.has("case")||changed.has("length")||changed.has("format")){const next=this.sanitize(this.rawValue);next!==this.value?this.value=next:this.packSegmentValues(next)}(changed.has("value")||changed.has("required")||changed.has("readonly")||changed.has("length")||changed.has("format"))&&this.updateValidity(),this.syncOtpStates()}syncOtpStates(){setCustomState(this.internals,"blank",this.value.length===0),setCustomState(this.internals,"--blank",this.value.length===0),setCustomState(this.internals,"--filled",this.filledSegmentCount===this.renderedSegmentCount),setCustomState(this.internals,"disabled",this.effectiveDisabled),setCustomState(this.internals,"readonly",this.readonly)}updateValidity(){if(isBarredFromValidation(this,this.internals)){this[SET_ANCHORED_VALIDITY]({});return}const total=this.renderedSegmentCount,filled=this.filledSegmentCount,complete=filled===total;if(this.required&&filled===0){this[SET_ANCHORED_VALIDITY]({valueMissing:!0},this.localize("fieldRequired"));return}if(filled>0&&!complete){this[SET_ANCHORED_VALIDITY]({tooShort:!0},this.localize("otpInputIncomplete",void 0,{total}));return}this[SET_ANCHORED_VALIDITY]({})}flushPendingChange(){if(!this.segmentEditPendingChange)return;this.segmentEditPendingChange=!1;const value=this.value;dispatchNativeEvent(this,"change"),this.emit("lr-change",{value})}renderSegment(index,invalid){const char=this.segmentValues[index]??"",filled=char!=="",active=this.focused&&!this.effectiveDisabled&&index===this.activeSegmentIndex,masked=filled&&this.mask,placeholderMask=!filled&&this.withMask,parts=["segment"];return active&&parts.push("active"),masked&&parts.push("masked"),placeholderMask&&parts.push("placeholder-mask"),invalid&&parts.push("invalid"),html`<div part=${parts.join(" ")} aria-hidden="true">${masked?nothing:placeholderMask?nothing:char}</div>`}render(){const hasLabel=!!this.label||this.hasLabelSlot||this.withLabel,hasHint=!!this.hint||this.hasHintSlot||this.withHint,hasError=!!this.errorText||this.hasErrorSlot,intrinsicInvalid=this.touched&&!this.validity.valid,ariaInvalid=hasError||intrinsicInvalid,describedBy=[hasError?this.errorId:"",hasHint?this.hintId:""].filter(Boolean).join(" "),labelledBy=hasLabel&&!this.getAttribute("aria-label")?this.labelId:nothing;let segmentIndex=-1;return html`
1
+ import{__decorate}from"tslib";import{setNativeRangeText}from"../../../internal/native-text-control.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{HostDescriptionController}from"../../../internal/aria-controls.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{FormAssociated,isBarredFromValidation}from"../../../internal/form-associated.js";import{SET_ANCHORED_VALIDITY}from"../../../internal/anchored-validity.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{finiteInteger}from"../../../internal/numbers.js";import{setCustomState}from"../../../internal/custom-states.js";import{contextualSizes}from"../../../internal/contextual-vocabulary.styles.js";import{submitFormImplicitly,submitOnEnter}from"../../../internal/submit-on-enter.js";import{styles}from"./otp-input.styles.js";import{dispatchNativeEvent,dispatchNativeInputEvent,relayNativeEvent}from"../../../internal/native-event-relay.js";import{currentValidityValidator}from"../form-validator.js";import{declaredDefaultConverter,literalSetConverter}from"../../../internal/converters.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{LYRA_DEFAULT_otpInputIncomplete,LYRA_DEFAULT_otpInputLabel}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";const APPEARANCE=literalSetConverter(["outlined","filled","filled-outlined","contained"],"outlined"),ACCEPTED={numeric:/[0-9]/,alpha:/[a-zA-Z]/,alphanumeric:/[a-zA-Z0-9]/},DEFAULT_LENGTH=6,MAX_LENGTH=32,MAX_FORMAT_SOURCE_LENGTH=4096,MAX_VALUE_SOURCE_LENGTH=4096;class LyraOtpInputBase extends LyraElement{static{this.styles=[LyraElement.styles,contextualSizes,scrollOverflowFadeStyles,styles]}}class LyraOtpInput extends FormAssociated(LyraOtpInputBase){static{this.defaultStrings={...super.defaultStrings,fieldRequired:LYRA_DEFAULT_fieldRequired,otpInputIncomplete:LYRA_DEFAULT_otpInputIncomplete,otpInputLabel:LYRA_DEFAULT_otpInputLabel}}static get validators(){return[currentValidityValidator("required","disabled","readonly","value","length","pattern")]}get appearance(){return this._appearance}set appearance(next){const normalized=APPEARANCE.normalizeReflected(this,"appearance",next),old=this._appearance;this._appearance=normalized,normalized!==old&&this.requestUpdate("appearance",old)}get hasLabelSlot(){return this.slotPresence.has("label")}get hasHintSlot(){return this.slotPresence.has("hint")}get hasErrorSlot(){return this.slotPresence.has("error")}constructor(){super(),this.label="",this.hint="",this.errorText="",this.withLabel=!1,this.withHint=!1,this._appearance="outlined",this.autofocus=!1,this.autosubmit=!1,this.size="m",this.length=DEFAULT_LENGTH,this.format="",this.type="numeric",this.case="preserve",this.mask=!1,this.withMask=!1,this.readonly=!1,this.autocomplete="one-time-code",this.focused=!1,this.slotPresence=new SlotPresenceController(this),this.touched=!1,this.labelId=nextId("otp-input-label"),this.hintId=nextId("otp-input-hint"),this.errorId=nextId("otp-input-error"),this.activeSegmentIndex=0,this.segmentValues=[],this.rawValue="",this.segmentEditPendingChange=!1,this.autosubmitToken=0,this.hostDescription=new HostDescriptionController(this,()=>this.control??null),this.onInput=event=>{if(event.isComposing===!0){event.stopPropagation();return}const raw=event.target.value,next=this.sanitize(raw),previousFilled=this.filledSegmentCount,layoutChanged=Array.from({length:this.renderedSegmentCount},(_,index)=>next[index]??"").some((value,index)=>value!==this.segmentValues[index]);if(this.control&&this.control.value!==next&&(this.control.value=next),next===this.value&&!layoutChanged){event.stopImmediatePropagation();return}this.touched=!0,this.value=next,relayNativeEvent(this,event),this.emit("lr-input",{value:next}),this.completeIfTransition(previousFilled)},this.onKeyDown=event=>{if(this.effectiveDisabled)return;if(event.key==="ArrowLeft"||event.key==="ArrowRight"){event.preventDefault();const physical=event.key==="ArrowRight"?1:-1,delta=this.effectiveDirection==="rtl"?-physical:physical;this.setActiveSegment(this.activeSegmentIndex+delta);return}if(event.key==="Enter"){this.readonly||submitOnEnter(this,event,{beforeSubmit:()=>this.flushPendingChange()});return}if(this.readonly||event.isComposing)return;const selection=this.selectedSegmentRange;if(event.key==="Backspace"||event.key==="Delete"){event.preventDefault();const values2=this.normalizedSegmentValues();if(selection){for(const index of selection.indices)values2[index]="";this.commitSegmentEdit(values2,event.key==="Backspace"?"deleteContentBackward":"deleteContentForward"),this.setActiveSegment(selection.first);return}const changed=!!values2[this.activeSegmentIndex];values2[this.activeSegmentIndex]="",changed&&this.commitSegmentEdit(values2,event.key==="Backspace"?"deleteContentBackward":"deleteContentForward"),event.key==="Backspace"&&this.setActiveSegment(this.activeSegmentIndex-1);return}if(event.ctrlKey||event.metaKey||event.altKey||event.key.length!==1)return;event.preventDefault();const accepted=this.sanitize(event.key).slice(0,1);if(!accepted)return;const values=this.normalizedSegmentValues(),targetIndex=selection?.first??this.activeSegmentIndex;if(selection)for(const index of selection.indices)values[index]="";values[targetIndex]=accepted,this.commitSegmentEdit(values,"insertText",accepted),this.setActiveSegment(targetIndex+1)},this.onPaste=event=>{if(this.effectiveDisabled||this.readonly)return;const pasted=this.sanitize(event.clipboardData?.getData("text")??"");if(event.preventDefault(),!pasted)return;const values=Array.from({length:this.renderedSegmentCount},(_,index)=>pasted[index]??"");this.commitSegmentEdit(values,"insertFromPaste",pasted),this.setActiveSegment(Math.min(pasted.length,this.renderedSegmentCount-1))},this.onChange=event=>{this.segmentEditPendingChange=!1;const value=this.value;relayNativeEvent(this,event),this.emit("lr-change",{value})},this.onFocus=event=>{this.focused=!0,relayNativeEvent(this,event)},this.onBlur=event=>{this.focused=!1,this.effectiveDisabled||(this.touched=!0),this.flushPendingChange(),relayNativeEvent(this,event)},observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part~="segments"]'))}get input(){return this.control??null}get validationTarget(){return this.control??null}get value(){return super.value}set value(next){this.autosubmitToken+=1,this.rawValue=next??"";const normalized=this.sanitize(this.rawValue);this.packSegmentValues(normalized),super.value=normalized}get defaultValue(){return super.defaultValue}set defaultValue(next){this.autosubmitToken+=1,super.defaultValue=next}get formattedCells(){if(this.parsedFormatSource===this.format)return this.parsedFormatCells??null;if(this.parsedFormatSource=this.format,!this.format)return this.parsedFormatCells=null,null;const cells=[];let segments=0,literal="";const flushLiteral=()=>{literal&&(cells.push({kind:"separator",text:literal}),literal="")};for(const char of this.format.slice(0,MAX_FORMAT_SOURCE_LENGTH)){if(char!=="#"){literal+=char;continue}if(segments>=MAX_LENGTH)break;flushLiteral(),cells.push({kind:"segment"}),segments+=1}return flushLiteral(),this.parsedFormatCells=segments>0?cells:null,this.parsedFormatCells}get renderedSegmentCount(){const formatted=this.formattedCells;return formatted?formatted.filter(cell=>cell.kind==="segment").length:Math.min(MAX_LENGTH,Math.max(1,finiteInteger(this.length,DEFAULT_LENGTH)))}get effectiveLength(){return this.renderedSegmentCount}get cells(){return this.formattedCells??Array.from({length:this.renderedSegmentCount},()=>({kind:"segment"}))}sanitize(raw){const accepted=Object.hasOwn(ACCEPTED,this.type)?ACCEPTED[this.type]:ACCEPTED.numeric,limit=this.renderedSegmentCount;let out="";for(const char of(raw??"").slice(0,MAX_VALUE_SOURCE_LENGTH))if(accepted.test(char)&&(out+=char),out.length>=limit)break;return this.case==="upper"?out=out.toUpperCase():this.case==="lower"&&(out=out.toLowerCase()),out.slice(0,limit)}packSegmentValues(value){const count=this.renderedSegmentCount;this.segmentValues=Array.from({length:count},(_,index)=>value[index]??""),this.activeSegmentIndex=Math.min(value.length,count-1)}get filledSegmentCount(){return Array.isArray(this.segmentValues)?this.segmentValues.reduce((count,value)=>count+(value?1:0),0):this.value.length}normalizedSegmentValues(values=this.segmentValues){return Array.from({length:this.renderedSegmentCount},(_,index)=>values[index]??"")}setActiveSegment(index){const next=Math.min(this.renderedSegmentCount-1,Math.max(0,index));this.activeSegmentIndex=next;const caret=this.normalizedSegmentValues().slice(0,next).filter(Boolean).length;this.control?.setSelectionRange(caret,caret),this.updateComplete.then(()=>{this.renderRoot.querySelectorAll('[part~="segment"]')[next]?.scrollIntoView({block:"nearest",inline:"nearest"})})}submitOwningForm(){const form=this.getForm();form&&submitFormImplicitly(form)}completeIfTransition(previousFilled){if(previousFilled>=this.renderedSegmentCount||this.filledSegmentCount!==this.renderedSegmentCount)return;const completionValue=this.value,token=this.autosubmitToken,completeEvent=this.emit("lr-complete",{value:completionValue},{cancelable:!0});this.autosubmit&&setTimeout(()=>{token!==this.autosubmitToken||completeEvent.defaultPrevented||!this.isConnected||!this.autosubmit||this.effectiveDisabled||this.readonly||this.value!==completionValue||this.filledSegmentCount!==this.renderedSegmentCount||this.submitOwningForm()})}commitSegmentEdit(values,inputType,data=null){this.autosubmitToken+=1;const previousFilled=this.filledSegmentCount;this.segmentValues=this.normalizedSegmentValues(values);const nextValue=this.segmentValues.join("");super.value=nextValue,this.control&&(this.control.value=nextValue),this.touched=!0,dispatchNativeInputEvent(this,{data,inputType}),this.emit("lr-input",{value:nextValue}),this.segmentEditPendingChange=!0,this.completeIfTransition(previousFilled),this.requestUpdate()}get selectedSegmentRange(){const start=this.control?.selectionStart,end=this.control?.selectionEnd;if(start==null||end===void 0||end===null||start===end)return null;const indices=this.normalizedSegmentValues().map((value,index)=>value?index:-1).filter(index=>index>=0).slice(start,end),first=indices[0];return first===void 0?null:{indices,first}}segmentIndexAtCompactOffset(offset){const values=this.normalizedSegmentValues();let occupied=0;for(let index=0;index<values.length;index+=1){if(occupied>=offset)return index;values[index]&&(occupied+=1)}return Math.max(0,values.length-1)}syncActiveSegmentFromSelection(){const control=this.control;if(!control||control.selectionStart===null)return;const selected=this.selectedSegmentRange;this.activeSegmentIndex=selected?.first??this.segmentIndexAtCompactOffset(control.selectionStart)}get selectionStart(){return this.control?.selectionStart??null}set selectionStart(value){this.control&&(this.control.selectionStart=value,this.syncActiveSegmentFromSelection())}get selectionEnd(){return this.control?.selectionEnd??null}set selectionEnd(value){this.control&&(this.control.selectionEnd=value,this.syncActiveSegmentFromSelection())}get selectionDirection(){return this.control?.selectionDirection??null}set selectionDirection(value){this.control&&(this.control.selectionDirection=value)}focus(options){this.effectiveDisabled||this.control?.focus(options)}blur(){this.control?.blur()}click(){this.effectiveDisabled||this.control?.click()}select(){this.control?.select()}setSelectionRange(start,end,direction){this.control&&(this.control.setSelectionRange(start,end,direction),this.syncActiveSegmentFromSelection())}setRangeText(replacement,start,end,selectMode){const control=this.control;if(!control)return;const selectionPrefixLength=(value,offset)=>{if(offset===null)return null;const boundedOffset=Math.min(MAX_VALUE_SOURCE_LENGTH,Math.max(0,offset));return this.sanitize(value.slice(0,boundedOffset)).length},currentRaw=control.value,currentSelectionStart=selectionPrefixLength(currentRaw,control.selectionStart),currentSelectionEnd=selectionPrefixLength(currentRaw,control.selectionEnd),currentSelectionDirection=control.selectionDirection,boundedCurrent=this.sanitize(currentRaw);currentRaw!==boundedCurrent&&(control.value=boundedCurrent,currentSelectionStart!==null&&currentSelectionEnd!==null&&control.setSelectionRange(currentSelectionStart,currentSelectionEnd,currentSelectionDirection??void 0));const boundedReplacement=this.sanitize(replacement);setNativeRangeText(control,boundedReplacement,start,end,selectMode);const raw=control.value,selectionStart=selectionPrefixLength(raw,control.selectionStart),selectionEnd=selectionPrefixLength(raw,control.selectionEnd),selectionDirection=control.selectionDirection,normalized=this.sanitize(raw);this.value=normalized,control.value=normalized,selectionStart!==null&&selectionEnd!==null&&control.setSelectionRange(selectionStart,selectionEnd,selectionDirection??void 0),this.syncActiveSegmentFromSelection()}clear(){!this.value||this.effectiveDisabled||this.readonly||(this.value="",this.control&&(this.control.value=""),dispatchNativeInputEvent(this,{inputType:"deleteContentBackward"}),this.emit("lr-input",{value:""}),dispatchNativeEvent(this,"change"),this.emit("lr-change",{value:""}),this.emit("lr-clear"))}formResetCallback(){this.autosubmitToken+=1,super.formResetCallback(),this.touched=!1,this.segmentEditPendingChange=!1}formStateRestoreCallback(state2,reason){this.autosubmitToken+=1,super.formStateRestoreCallback(state2,reason)}disconnectedCallback(){super.disconnectedCallback(),this.autosubmitToken+=1}reportValidity(){return this.touched=!0,super.reportValidity()}firstUpdated(changed){super.firstUpdated(changed),this.autofocus&&this.scheduleAfterUpdate(()=>this.focus(),"otp-autofocus")}adoptedCallback(){super.adoptedCallback(),this.hostDescription.adopted()}updated(changed){super.updated(changed),this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid)}willUpdate(changed){if(super.willUpdate(changed),changed.has("type")||changed.has("case")||changed.has("length")||changed.has("format")){const next=this.sanitize(this.rawValue);next!==this.value?this.value=next:this.packSegmentValues(next)}(changed.has("value")||changed.has("required")||changed.has("readonly")||changed.has("length")||changed.has("format"))&&this.updateValidity(),this.syncOtpStates()}syncOtpStates(){setCustomState(this.internals,"blank",this.value.length===0),setCustomState(this.internals,"--blank",this.value.length===0),setCustomState(this.internals,"--filled",this.filledSegmentCount===this.renderedSegmentCount),setCustomState(this.internals,"disabled",this.effectiveDisabled),setCustomState(this.internals,"readonly",this.readonly)}updateValidity(){if(isBarredFromValidation(this,this.internals)){this[SET_ANCHORED_VALIDITY]({});return}const total=this.renderedSegmentCount,filled=this.filledSegmentCount,complete=filled===total;if(this.required&&filled===0){this[SET_ANCHORED_VALIDITY]({valueMissing:!0},this.localize("fieldRequired"));return}if(filled>0&&!complete){this[SET_ANCHORED_VALIDITY]({tooShort:!0},this.localize("otpInputIncomplete",void 0,{total}));return}this[SET_ANCHORED_VALIDITY]({})}flushPendingChange(){if(!this.segmentEditPendingChange)return;this.segmentEditPendingChange=!1;const value=this.value;dispatchNativeEvent(this,"change"),this.emit("lr-change",{value})}renderSegment(index,invalid){const char=this.segmentValues[index]??"",filled=char!=="",active=this.focused&&!this.effectiveDisabled&&index===this.activeSegmentIndex,masked=filled&&this.mask,placeholderMask=!filled&&this.withMask,parts=["segment"];return active&&parts.push("active"),masked&&parts.push("masked"),placeholderMask&&parts.push("placeholder-mask"),invalid&&parts.push("invalid"),html`<div part=${parts.join(" ")} aria-hidden="true">${masked?nothing:placeholderMask?nothing:char}</div>`}render(){const hasLabel=!!this.label||this.hasLabelSlot||this.withLabel,hasHint=!!this.hint||this.hasHintSlot||this.withHint,hasError=!!this.errorText||this.hasErrorSlot,intrinsicInvalid=this.touched&&!this.validity.valid,ariaInvalid=hasError||intrinsicInvalid,describedBy=[hasError?this.errorId:"",hasHint?this.hintId:""].filter(Boolean).join(" "),labelledBy=hasLabel&&!this.getAttribute("aria-label")?this.labelId:nothing;let segmentIndex=-1;return html`
2
2
  <div part="base form-control">
3
3
  <label part="label form-control-label" id=${this.labelId} for="control" ?hidden=${!hasLabel}>
4
4
  ${this.label}<slot name="label"></slot>
@@ -58,9 +58,10 @@ get required():boolean;set required(next:boolean);
58
58
  get disabled():boolean;set disabled(next:boolean);
59
59
  /**
60
60
  * The signature's strokes. Assign saved strokes to restore a signature: the input is copied,
61
- * non-finite points are dropped, coordinates are clamped to 0–1, and at most
62
- * `SIGNATURE_PAD_MAX_STROKES` strokes of `SIGNATURE_PAD_MAX_POINTS` points are kept. Assigning the
63
- * current array is a no-op, and assignments fire no events.
61
+ * non-finite/accessor points are dropped and coordinates are clamped to 0–1. Only the first
62
+ * `SIGNATURE_PAD_MAX_STROKES` stroke positions and `SIGNATURE_PAD_MAX_POINTS` point positions per
63
+ * stroke are inspected through own data descriptors. Assigning the current array is a no-op,
64
+ * and assignments fire no events.
64
65
  */
65
66
  get strokes():readonly SignatureStroke[];set strokes(next:readonly SignatureStroke[]|null|undefined);
66
67
  /**
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{isBarredFromValidation}from"../../../internal/form-associated.js";import{AnchoredValidityController}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{installInteractionOnInvalid,installInvalidEventAlias,withStaticValidityCheck}from"../../../internal/invalid-event-alias.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{dispatchNativeEvent}from"../../../internal/native-event-relay.js";import{omittedEmptyStringConverter}from"../../../internal/converters.js";import{styles}from"./signature-pad.styles.js";import{SIGNATURE_PAD_MAX_STROKES,SIGNATURE_PAD_MAX_POINTS}from"./signature-pad-limits.js";import{LYRA_DEFAULT_signaturePad,LYRA_DEFAULT_signaturePadEmpty,LYRA_DEFAULT_signaturePadInstructions,LYRA_DEFAULT_signaturePadLabel,LYRA_DEFAULT_signaturePadPenDown,LYRA_DEFAULT_signaturePadPenUp,LYRA_DEFAULT_signaturePadSigned}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";import{SIGNATURE_PAD_MAX_STROKES as SIGNATURE_PAD_MAX_STROKES2,SIGNATURE_PAD_MAX_POINTS as SIGNATURE_PAD_MAX_POINTS2}from"./signature-pad-limits.js";installFormControlLabelSupport();const EMPTY=Object.freeze([]),EXPORT_SIZE=1024,MIN_DISTANCE=.002,at=(x,y)=>Object.freeze([x,y].map(v=>Math.round(Math.min(1,Math.max(0,v))*1e4)/1e4));function normalizeStrokes(input){const strokes=[];for(const raw of Array.isArray(input)?input:[]){if(strokes.length===SIGNATURE_PAD_MAX_STROKES)break;const points=[];for(const point of Array.isArray(raw)?raw:[]){if(points.length===SIGNATURE_PAD_MAX_POINTS)break;const[x,y]=Array.isArray(point)?point:[];Number.isFinite(x)&&Number.isFinite(y)&&points.push(at(x,y))}points.length&&strokes.push(Object.freeze(points))}return Object.freeze(strokes)}function pathData(stroke){const points=stroke.map(([x,y])=>`${x} ${y}`);return`M${points.join("L")}L${points[points.length-1]}`}class LyraSignaturePad extends LyraElement{static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,fieldRequired:LYRA_DEFAULT_fieldRequired,signaturePad:LYRA_DEFAULT_signaturePad,signaturePadEmpty:LYRA_DEFAULT_signaturePadEmpty,signaturePadInstructions:LYRA_DEFAULT_signaturePadInstructions,signaturePadLabel:LYRA_DEFAULT_signaturePadLabel,signaturePadPenDown:LYRA_DEFAULT_signaturePadPenDown,signaturePadPenUp:LYRA_DEFAULT_signaturePadPenUp,signaturePadSigned:LYRA_DEFAULT_signaturePadSigned}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.properties={name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},required:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},strokes:{attribute:!1,noAccessor:!0}}}constructor(){super(),this.label="",this.hint="",this.errorText="",this.penDown=!1,this.cursor=at(.5,.5),this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this.surface),this.slots=new SlotPresenceController(this),this._name="",this._required=!1,this._disabled=!1,this.fieldsetDisabled=!1,this.hasInteracted=!1,this._strokes=EMPTY,this.ratio=3,this.markInteracted=()=>{this.hasInteracted=!0,this.syncStates()},installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),installInteractionOnInvalid(this,this.markInteracted)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.syncDisabled(),this.requestUpdate("disabled",old)}get strokes(){return this._strokes}set strokes(next){next!==this._strokes&&this.applyStrokes(normalizeStrokes(next))}get value(){return this._strokes.length?this.dataUrl??=this.exportPng():""}get form(){return this.internals.form}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}clear(){this.applyStrokes(EMPTY)}checkValidity(){return withStaticValidityCheck(this,()=>this.internals.checkValidity())}reportValidity(){return this.markInteracted(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncStates()}formResetCallback(){this.hasInteracted=!1,this.applyStrokes(EMPTY)}formStateRestoreCallback(state2){let saved;try{saved=typeof state2=="string"?JSON.parse(state2):void 0}catch{}this.applyStrokes(normalizeStrokes(saved))}formDisabledCallback(disabled){this.fieldsetDisabled=disabled,this.syncDisabled()}connectedCallback(){super.connectedCallback(),this.updateValidity()}disconnectedCallback(){super.disconnectedCallback(),this.cancelStroke(),this.sink?.release(),this.sink=void 0}get inactive(){return this._disabled||this.fieldsetDisabled}get barred(){return isBarredFromValidation({disabled:this.inactive},this.internals)}get surface(){return this.renderRoot?.querySelector('[part="surface"]')}syncDisabled(){this.inactive&&this.cancelStroke(),this.updateValidity()}updateValidity(){const missing=this._required&&!this._strokes.length&&!this.barred;this.validityController.setValidity(missing?{valueMissing:!0}:{},missing?this.localize("fieldRequired"):""),this.syncStates()}syncStates(){syncValidityStates(this.internals,{required:this._required,hasInteracted:this.hasInteracted,barred:this.barred}),this.requestUpdate()}applyStrokes(strokes){const old=this._strokes;this.cancelStroke(),this._strokes=strokes,this.dataUrl=void 0;const{value}=this;value?this.internals.setFormValue(value,JSON.stringify(strokes)):this.internals.setFormValue(null),this.updateValidity(),this.requestUpdate("strokes",old)}exportPng(){const box=this.surface?.getBoundingClientRect();box?.width&&box.height&&(this.ratio=box.width/box.height);const canvas=this.ownerDocument.createElement("canvas"),width=canvas.width=Math.round(EXPORT_SIZE*Math.min(1,this.ratio)),height=canvas.height=Math.round(EXPORT_SIZE/Math.max(1,this.ratio)),context=canvas.getContext("2d");if(!context)return"";context.lineWidth=EXPORT_SIZE/256,context.lineCap=context.lineJoin="round";for(const stroke of this._strokes){context.beginPath();for(const[x,y]of stroke)context.lineTo(x*width,y*height),stroke.length===1&&context.arc(x*width,y*height,context.lineWidth/2,0,2*Math.PI);stroke.length===1?context.fill():context.stroke()}return canvas.toDataURL()}begin(point){return this._strokes.length>=SIGNATURE_PAD_MAX_STROKES?!1:(this.active=[point],this.paintActive(),!0)}extend(point){const stroke=this.active,last=stroke?.[stroke.length-1];!stroke||!last||stroke.length>=SIGNATURE_PAD_MAX_POINTS||Math.hypot(point[0]-last[0],point[1]-last[1])<MIN_DISTANCE||(stroke.push(point),this.paintActive())}commit(){const stroke=this.active;if(!stroke)return this.cancelStroke();this.applyStrokes(Object.freeze([...this._strokes,Object.freeze(stroke)])),this.userChange()}cancelStroke(){this.active=this.pointerId=void 0,this.penDown=!1,this.paintActive()}paintActive(){const path=this.renderRoot?.querySelector(".active");this.active?path?.setAttribute("d",pathData(this.active)):path?.removeAttribute("d")}userChange(){this.markInteracted(),dispatchNativeEvent(this,"change"),this.emit("lr-change")}onPointerDown(event){if(this.inactive||this.active||!event.isPrimary||event.button!==0)return;const surface=event.currentTarget,rect=this.rect=surface.getBoundingClientRect();if(!(!rect.width||!rect.height||!this.begin(this.point(event)))){this.pointerId=event.pointerId;try{surface.setPointerCapture(event.pointerId)}catch{}}}onPointerMove(event){event.pointerId===this.pointerId&&this.extend(this.point(event))}onPointerEnd(event){event.pointerId===this.pointerId&&this.commit()}point({clientX,clientY}){const{left,top,width,height}=this.rect;return at((clientX-left)/width,(clientY-top)/height)}onKeyDown(event){if(this.inactive||event.altKey||event.ctrlKey||event.metaKey)return;const step=event.shiftKey?.1:.01,[x,y]=this.cursor,move={ArrowLeft:[x-step,y],ArrowRight:[x+step,y],ArrowUp:[x,y-step],ArrowDown:[x,y+step]}[event.key];if(move)this.cursor=at(...move),this.penDown&&this.extend(this.cursor);else if(event.key===" "||event.key==="Enter"||event.key==="Escape"&&this.penDown)this.togglePen();else return;event.preventDefault()}togglePen(){this.penDown?(this.sink?.announce(this.localize("signaturePadPenUp")),this.commit()):!this.active&&this.begin(this.cursor)&&(this.penDown=!0,this.sink?.announce(this.localize("signaturePadPenDown")))}onFocus(){this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}onBlur(){this.penDown&&this.commit(),this.markInteracted()}onClear(){this.applyStrokes(EMPTY),this.userChange(),this.surface?.focus()}render(){const hasLabel=!!this.label||this.slots.has("label"),hasHint=!!this.hint||this.slots.has("hint"),hasError=!!this.errorText||this.slots.has("error"),hostLabel=this.getAttribute("aria-label"),count=this._strokes.length,[x,y]=this.cursor;return html`
1
+ import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{projectFrozenRows,readOwnDataValue}from"../../../internal/data-descriptors.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{isBarredFromValidation}from"../../../internal/form-associated.js";import{AnchoredValidityController}from"../../../internal/anchored-validity.js";import{syncValidityStates}from"../../../internal/custom-states.js";import{installInteractionOnInvalid,installInvalidEventAlias,withStaticValidityCheck}from"../../../internal/invalid-event-alias.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{acquireAnnouncementSink}from"../../../internal/announcer.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{dispatchNativeEvent}from"../../../internal/native-event-relay.js";import{omittedEmptyStringConverter}from"../../../internal/converters.js";import{styles}from"./signature-pad.styles.js";import{SIGNATURE_PAD_MAX_STROKES,SIGNATURE_PAD_MAX_POINTS}from"./signature-pad-limits.js";import{LYRA_DEFAULT_signaturePad,LYRA_DEFAULT_signaturePadEmpty,LYRA_DEFAULT_signaturePadInstructions,LYRA_DEFAULT_signaturePadLabel,LYRA_DEFAULT_signaturePadPenDown,LYRA_DEFAULT_signaturePadPenUp,LYRA_DEFAULT_signaturePadSigned}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_fieldRequired}from"../../../internal/default-strings/shared.generated.js";import{SIGNATURE_PAD_MAX_STROKES as SIGNATURE_PAD_MAX_STROKES2,SIGNATURE_PAD_MAX_POINTS as SIGNATURE_PAD_MAX_POINTS2}from"./signature-pad-limits.js";installFormControlLabelSupport();const EMPTY=Object.freeze([]),EXPORT_SIZE=1024,MIN_DISTANCE=.002,at=(x,y)=>Object.freeze([x,y].map(v=>Math.round(Math.min(1,Math.max(0,v))*1e4)/1e4));function normalizeStrokes(input){return projectFrozenRows(input,raw=>{const points=projectFrozenRows(raw,point=>{if(!Array.isArray(point))return;const x=readOwnDataValue(point,"0"),y=readOwnDataValue(point,"1");return typeof x=="number"&&typeof y=="number"&&Number.isFinite(x)&&Number.isFinite(y)?at(x,y):void 0},SIGNATURE_PAD_MAX_POINTS,Object.freeze([]));return points.length?points:void 0},SIGNATURE_PAD_MAX_STROKES,EMPTY)}function pathData(stroke){const points=stroke.map(([x,y])=>`${x} ${y}`);return`M${points.join("L")}L${points[points.length-1]}`}class LyraSignaturePad extends LyraElement{static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,fieldRequired:LYRA_DEFAULT_fieldRequired,signaturePad:LYRA_DEFAULT_signaturePad,signaturePadEmpty:LYRA_DEFAULT_signaturePadEmpty,signaturePadInstructions:LYRA_DEFAULT_signaturePadInstructions,signaturePadLabel:LYRA_DEFAULT_signaturePadLabel,signaturePadPenDown:LYRA_DEFAULT_signaturePadPenDown,signaturePadPenUp:LYRA_DEFAULT_signaturePadPenUp,signaturePadSigned:LYRA_DEFAULT_signaturePadSigned}}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,styles]}static{this.properties={name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},required:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},strokes:{attribute:!1,noAccessor:!0}}}constructor(){super(),this.label="",this.hint="",this.errorText="",this.penDown=!1,this.cursor=at(.5,.5),this.internals=attachInternalsSafely(this),this.validityController=new AnchoredValidityController(this,this.internals,()=>this.surface),this.slots=new SlotPresenceController(this),this._name="",this._required=!1,this._disabled=!1,this.fieldsetDisabled=!1,this.hasInteracted=!1,this._strokes=EMPTY,this.ratio=3,this.markInteracted=()=>{this.hasInteracted=!0,this.syncStates()},installInvalidEventAlias(this,init=>this.emit("lr-invalid",null,init)),installInteractionOnInvalid(this,this.markInteracted)}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",this._name?this.setAttribute("name",this._name):this.removeAttribute("name"),this.requestUpdate("name",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this.syncDisabled(),this.requestUpdate("disabled",old)}get strokes(){return this._strokes}set strokes(next){next!==this._strokes&&this.applyStrokes(normalizeStrokes(next))}get value(){return this._strokes.length?this.dataUrl??=this.exportPng():""}get form(){return this.internals.form}get validity(){return this.internals.validity}get validationMessage(){return this.internals.validationMessage}clear(){this.applyStrokes(EMPTY)}checkValidity(){return withStaticValidityCheck(this,()=>this.internals.checkValidity())}reportValidity(){return this.markInteracted(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncStates()}formResetCallback(){this.hasInteracted=!1,this.applyStrokes(EMPTY)}formStateRestoreCallback(state2){let saved;try{saved=typeof state2=="string"?JSON.parse(state2):void 0}catch{}this.applyStrokes(normalizeStrokes(saved))}formDisabledCallback(disabled){this.fieldsetDisabled=disabled,this.syncDisabled()}connectedCallback(){super.connectedCallback(),this.updateValidity()}disconnectedCallback(){super.disconnectedCallback(),this.cancelStroke(),this.sink?.release(),this.sink=void 0}get inactive(){return this._disabled||this.fieldsetDisabled}get barred(){return isBarredFromValidation({disabled:this.inactive},this.internals)}get surface(){return this.renderRoot?.querySelector('[part="surface"]')}syncDisabled(){this.inactive&&this.cancelStroke(),this.updateValidity()}updateValidity(){const missing=this._required&&!this._strokes.length&&!this.barred;this.validityController.setValidity(missing?{valueMissing:!0}:{},missing?this.localize("fieldRequired"):""),this.syncStates()}syncStates(){syncValidityStates(this.internals,{required:this._required,hasInteracted:this.hasInteracted,barred:this.barred}),this.requestUpdate()}applyStrokes(strokes){const old=this._strokes;this.cancelStroke(),this._strokes=strokes,this.dataUrl=void 0;const{value}=this;value?this.internals.setFormValue(value,JSON.stringify(strokes)):this.internals.setFormValue(null),this.updateValidity(),this.requestUpdate("strokes",old)}exportPng(){const box=this.surface?.getBoundingClientRect();box?.width&&box.height&&(this.ratio=box.width/box.height);const canvas=this.ownerDocument.createElement("canvas"),width=canvas.width=Math.round(EXPORT_SIZE*Math.min(1,this.ratio)),height=canvas.height=Math.round(EXPORT_SIZE/Math.max(1,this.ratio)),context=canvas.getContext("2d");if(!context)return"";context.lineWidth=EXPORT_SIZE/256,context.lineCap=context.lineJoin="round";for(const stroke of this._strokes){context.beginPath();for(const[x,y]of stroke)context.lineTo(x*width,y*height),stroke.length===1&&context.arc(x*width,y*height,context.lineWidth/2,0,2*Math.PI);stroke.length===1?context.fill():context.stroke()}return canvas.toDataURL()}begin(point){return this._strokes.length>=SIGNATURE_PAD_MAX_STROKES?!1:(this.active=[point],this.paintActive(),!0)}extend(point){const stroke=this.active,last=stroke?.[stroke.length-1];!stroke||!last||stroke.length>=SIGNATURE_PAD_MAX_POINTS||Math.hypot(point[0]-last[0],point[1]-last[1])<MIN_DISTANCE||(stroke.push(point),this.paintActive())}commit(){const stroke=this.active;if(!stroke)return this.cancelStroke();this.applyStrokes(Object.freeze([...this._strokes,Object.freeze(stroke)])),this.userChange()}cancelStroke(){this.active=this.pointerId=void 0,this.penDown=!1,this.paintActive()}paintActive(){const path=this.renderRoot?.querySelector(".active");this.active?path?.setAttribute("d",pathData(this.active)):path?.removeAttribute("d")}userChange(){this.markInteracted(),dispatchNativeEvent(this,"change"),this.emit("lr-change")}onPointerDown(event){if(this.inactive||this.active||!event.isPrimary||event.button!==0)return;const surface=event.currentTarget,rect=this.rect=surface.getBoundingClientRect();if(!(!rect.width||!rect.height||!this.begin(this.point(event)))){this.pointerId=event.pointerId;try{surface.setPointerCapture(event.pointerId)}catch{}}}onPointerMove(event){event.pointerId===this.pointerId&&this.extend(this.point(event))}onPointerEnd(event){event.pointerId===this.pointerId&&this.commit()}point({clientX,clientY}){const{left,top,width,height}=this.rect;return at((clientX-left)/width,(clientY-top)/height)}onKeyDown(event){if(this.inactive||event.altKey||event.ctrlKey||event.metaKey)return;const step=event.shiftKey?.1:.01,[x,y]=this.cursor,move={ArrowLeft:[x-step,y],ArrowRight:[x+step,y],ArrowUp:[x,y-step],ArrowDown:[x,y+step]}[event.key];if(move)this.cursor=at(...move),this.penDown&&this.extend(this.cursor);else if(event.key===" "||event.key==="Enter"||event.key==="Escape"&&this.penDown)this.togglePen();else return;event.preventDefault()}togglePen(){this.penDown?(this.sink?.announce(this.localize("signaturePadPenUp")),this.commit()):!this.active&&this.begin(this.cursor)&&(this.penDown=!0,this.sink?.announce(this.localize("signaturePadPenDown")))}onFocus(){this.sink??=acquireAnnouncementSink("polite",{document:this.ownerDocument,source:this})}onBlur(){this.penDown&&this.commit(),this.markInteracted()}onClear(){this.applyStrokes(EMPTY),this.userChange(),this.surface?.focus()}render(){const hasLabel=!!this.label||this.slots.has("label"),hasHint=!!this.hint||this.slots.has("hint"),hasError=!!this.errorText||this.slots.has("error"),hostLabel=this.getAttribute("aria-label"),count=this._strokes.length,[x,y]=this.cursor;return html`
2
2
  <div part="form-control">
3
3
  <div id="label" part="form-control-label" ?hidden=${!hasLabel}>${this.label}<slot name="label"></slot></div>
4
4
  <div part="base">
@@ -114,8 +114,9 @@ readonly disabled?:boolean;}export type LyraSwatchPickerMode='swatch'|'gemstone'
114
114
  * @status stable
115
115
  * @since 4.0.0
116
116
  */
117
- export declare class LyraSwatchPicker extends LyraElement<LyraSwatchPickerEventMap>{static styles:import("lit").CSSResultGroup[];static properties:{items:{attribute:boolean;noAccessor:boolean;};};private readonly stateInternals;private _items;private readonly itemSnapshots;
118
- /** The selectable color swatches, in display order. */
117
+ export declare class LyraSwatchPicker extends LyraElement<LyraSwatchPickerEventMap>{static styles:import("lit").CSSResultGroup[];static properties:{items:{attribute:boolean;noAccessor:boolean;};};private readonly stateInternals;private _items;private itemsSource?;private readonly itemSnapshots;
118
+ /** The selectable color swatches, in display order. Assign a new array to update: mutating an
119
+ * array and assigning it again does not. */
119
120
  get items():readonly SwatchPickerItem[];set items(next:readonly SwatchPickerItem[]);
120
121
  /** The currently selected option's `value`, or `null` when nothing is selected. */
121
122
  value:string|null;
@@ -1,4 +1,4 @@
1
- import{__decorate}from"tslib";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{setCustomState}from"../../../internal/custom-states.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{isRtl}from"../../../internal/rtl.js";import{gemstoneGlyph,gemstoneSelectedGlyphStyles}from"../../../theme/gemstones.js";import{styles}from"./swatch-picker.styles.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{literalSetConverter}from"../../../internal/converters.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{swatchKeyTarget}from"./swatch-keys.js";const SWATCH_PICKER_MODE=literalSetConverter(["swatch","gemstone"],"swatch");class LyraSwatchPicker extends LyraElement{constructor(){super(...arguments),this.stateInternals=attachInternalsSafely(this),this._items=Object.freeze([]),this.itemSnapshots=new WeakMap,this.value=null,this.size="m",this._mode="swatch",this.accessibleLabel="",this.disabled=!1,this.fallbackTabbableIndex=0,this.onKeyDown=e=>{if(this.disabled)return;const navigable=this.items;if(navigable.length===0)return;const targetIndex=swatchKeyTarget(e.key,this.keyboardOriginIndex(e),navigable.length,index=>navigable[index].disabled===!0,isRtl(this));if(targetIndex<0)return;e.preventDefault();const target=navigable[targetIndex];this.select(target,targetIndex),this.focusSwatch(targetIndex)}}static{this.styles=[LyraElement.styles,styles,gemstoneSelectedGlyphStyles]}static{this.properties={items:{attribute:!1,noAccessor:!0}}}get items(){return this._items}set items(next){const old=this._items,snapshots=[],rows=[],reserved=new Set;if(Array.isArray(next))for(let index=0;index<Math.min(next.length,512);index++)try{const raw=next[index];if(raw===null||typeof raw!="object")continue;rows.push(raw),reserved.add(this.itemSnapshots.get(raw))}catch{}const identities=new Map,identity=value=>(identities.has(value)||identities.set(value,identities.size),identities.get(value)),snapshotKey=item=>JSON.stringify([item.value,item.color,item.label,identity(item.gemstone),identity(item.icon),item.disabled===!0]),buckets=new Map;for(const item of[...old].reverse()){if(reserved.has(item))continue;const key=snapshotKey(item);let queue=buckets.get(key);queue||buckets.set(key,queue=[]),queue.push(item)}for(const raw of rows)try{let item=this.itemSnapshots.get(raw);if(item&&reserved.delete(item)){snapshots.push(item);continue}if(!item){const{value,color,label}=raw;if(typeof value!="string"||typeof color!="string"||typeof label!="string"||label.trim()==="")continue;const{icon,gemstone,disabled}=raw;item={value,color,label,...icon===void 0?{}:{icon},...gemstone===void 0?{}:{gemstone},...disabled===!0?{disabled}:{}}}const snapshot=buckets.get(snapshotKey(item))?.pop()??Object.freeze({...item});this.itemSnapshots.has(raw)||this.itemSnapshots.set(raw,snapshot),snapshots.push(snapshot)}catch{}this._items=Object.freeze(snapshots),this.requestUpdate("items",old)}get mode(){return this._mode}set mode(next){const normalized=SWATCH_PICKER_MODE.normalizeReflected(this,"mode",next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}resolveSelectedIndex(){if(this.value===null)return this.selectedOption=void 0,-1;const identityIndex=this.selectedOption?.value===this.value?this.items.indexOf(this.selectedOption):-1,selectedIndex=identityIndex>=0?identityIndex:this.items.findIndex(option=>option.value===this.value);return this.selectedOption=this.items[selectedIndex],selectedIndex}select(option,index){if(this.disabled||option.disabled)return;const previousIndex=this.resolveSelectedIndex();if(index!==previousIndex||option.value!==this.value){const previousValue=this.value;this.selectedOption=option,this.value=option.value,previousValue===option.value&&this.requestUpdate(),this.emit("lr-change",{value:option.value})}this.emit("lr-activate",{value:option.value})}focusSwatch(index){if(this.disabled)return;const button=this.renderRoot.querySelector(`[part~="swatch"][data-index="${index}"]`);this.cancelFocusReveal(),this.focusRevealFrame=requestAnimationFrame(()=>{if(this.focusRevealFrame=void 0,!this.isConnected||this.disabled)return;const focused=shadowFocusTarget(this);!(focused instanceof HTMLElement)||!focused.part.contains("swatch")||focused.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"})}),button?.focus({preventScroll:!0})}cancelFocusReveal(){this.focusRevealFrame!==void 0&&cancelAnimationFrame(this.focusRevealFrame),this.focusRevealFrame=void 0}disconnectedCallback(){this.cancelFocusReveal(),super.disconnectedCallback()}willUpdate(changed){if(super.willUpdate(changed),setCustomState(this.stateInternals,"selected",this.resolveSelectedIndex()>=0),!changed.has("items"))return;const active=shadowFocusTarget(this);if(!active?.part?.contains("swatch"))return;const previousOptions=changed.get("items"),previousIndex=Number(active.dataset.index);if(!Number.isInteger(previousIndex)||previousIndex<0)return;const focusedOption=previousOptions?.[previousIndex],identityIndex=focusedOption===void 0?-1:this.items.indexOf(focusedOption),nextIndex=identityIndex>=0?identityIndex:Math.min(previousIndex,this.items.length-1);if(nextIndex<0){this.pendingFocusIndex=void 0,this.fallbackTabbableIndex=0;return}this.pendingFocusIndex=nextIndex,this.fallbackTabbableIndex=nextIndex}updated(changed){super.updated(changed),!(!changed.has("items")||this.pendingFocusIndex===void 0)&&this.scheduleAfterUpdate(()=>{const pendingIndex=this.pendingFocusIndex;this.pendingFocusIndex=void 0,!(pendingIndex===void 0||this.items.length===0)&&this.focusSwatch(Math.min(pendingIndex,this.items.length-1))},"restore-swatch-picker-focus")}tabbableSwatch(){return this.renderRoot?.querySelector(`[part~="swatch"][data-index="${this.tabbableIndex()}"]`)??null}tabbableIndex(){const selectedIndex=this.resolveSelectedIndex(),index=selectedIndex!==-1?selectedIndex:Math.min(this.fallbackTabbableIndex,Math.max(0,this.items.length-1));return this.items[index]?.disabled?this.items.findIndex(item=>!item.disabled):index}click(){this.disabled||this.tabbableSwatch()?.click()}focus(options){this.cancelFocusReveal(),!this.disabled&&this.tabbableSwatch()?.focus(options)}blur(){this.cancelFocusReveal(),this.tabbableSwatch()?.blur()}keyboardOriginIndex(event){const fromEvent=event.composedPath().find(candidate2=>candidate2.nodeType===1&&candidate2.part?.contains("swatch")===!0&&candidate2.getRootNode()===this.renderRoot),focused=shadowFocusTarget(this),candidate=fromEvent??(focused?.part?.contains("swatch")?focused:void 0),index=Number(candidate?.dataset.index);return Number.isInteger(index)&&index>=0&&index<this.items.length?index:this.resolveSelectedIndex()}render(){const hostLabel=this.getAttribute("aria-label"),ariaLabel=hostLabel!==null?hostLabel:this.accessibleLabel||nothing,selectedIndex=this.resolveSelectedIndex(),tabbableIndex=this.tabbableIndex();return html`
1
+ import{__decorate}from"tslib";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{setCustomState}from"../../../internal/custom-states.js";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{isRtl}from"../../../internal/rtl.js";import{gemstoneGlyph,gemstoneSelectedGlyphStyles}from"../../../theme/gemstones.js";import{styles}from"./swatch-picker.styles.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{literalSetConverter}from"../../../internal/converters.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{swatchKeyTarget}from"./swatch-keys.js";const SWATCH_PICKER_MODE=literalSetConverter(["swatch","gemstone"],"swatch");class LyraSwatchPicker extends LyraElement{constructor(){super(...arguments),this.stateInternals=attachInternalsSafely(this),this._items=Object.freeze([]),this.itemSnapshots=new WeakMap,this.value=null,this.size="m",this._mode="swatch",this.accessibleLabel="",this.disabled=!1,this.fallbackTabbableIndex=0,this.onKeyDown=e=>{if(this.disabled)return;const navigable=this.items;if(navigable.length===0)return;const targetIndex=swatchKeyTarget(e.key,this.keyboardOriginIndex(e),navigable.length,index=>navigable[index].disabled===!0,isRtl(this));if(targetIndex<0)return;e.preventDefault();const target=navigable[targetIndex];this.select(target,targetIndex),this.focusSwatch(targetIndex)}}static{this.styles=[LyraElement.styles,styles,gemstoneSelectedGlyphStyles]}static{this.properties={items:{attribute:!1,noAccessor:!0}}}get items(){return this._items}set items(next){const old=this._items;if(next===this.itemsSource||next===old)return;this.itemsSource=next;const snapshots=[],rows=[],reserved=new Set;if(Array.isArray(next))for(let index=0;index<Math.min(next.length,512);index++)try{const raw=next[index];if(raw===null||typeof raw!="object")continue;rows.push(raw),reserved.add(this.itemSnapshots.get(raw))}catch{}const identities=new Map,identity=value=>(identities.has(value)||identities.set(value,identities.size),identities.get(value)),snapshotKey=item=>JSON.stringify([item.value,item.color,item.label,identity(item.gemstone),identity(item.icon),item.disabled===!0]),buckets=new Map;for(const item of[...old].reverse()){if(reserved.has(item))continue;const key=snapshotKey(item);let queue=buckets.get(key);queue||buckets.set(key,queue=[]),queue.push(item)}for(const raw of rows)try{let item=this.itemSnapshots.get(raw);if(item&&reserved.delete(item)){snapshots.push(item);continue}if(!item){const{value,color,label}=raw;if(typeof value!="string"||typeof color!="string"||typeof label!="string"||label.trim()==="")continue;const{icon,gemstone,disabled}=raw;item={value,color,label,...icon===void 0?{}:{icon},...gemstone===void 0?{}:{gemstone},...disabled===!0?{disabled}:{}}}const snapshot=buckets.get(snapshotKey(item))?.pop()??Object.freeze({...item});this.itemSnapshots.has(raw)||this.itemSnapshots.set(raw,snapshot),snapshots.push(snapshot)}catch{}this._items=Object.freeze(snapshots),this.requestUpdate("items",old)}get mode(){return this._mode}set mode(next){const normalized=SWATCH_PICKER_MODE.normalizeReflected(this,"mode",next),old=this._mode;old!==normalized&&(this._mode=normalized,this.requestUpdate("mode",old))}resolveSelectedIndex(){if(this.value===null)return this.selectedOption=void 0,-1;const identityIndex=this.selectedOption?.value===this.value?this.items.indexOf(this.selectedOption):-1,selectedIndex=identityIndex>=0?identityIndex:this.items.findIndex(option=>option.value===this.value);return this.selectedOption=this.items[selectedIndex],selectedIndex}select(option,index){if(this.disabled||option.disabled)return;const previousIndex=this.resolveSelectedIndex();if(index!==previousIndex||option.value!==this.value){const previousValue=this.value;this.selectedOption=option,this.value=option.value,previousValue===option.value&&this.requestUpdate(),this.emit("lr-change",{value:option.value})}this.emit("lr-activate",{value:option.value})}focusSwatch(index){if(this.disabled)return;const button=this.renderRoot.querySelector(`[part~="swatch"][data-index="${index}"]`);this.cancelFocusReveal(),this.focusRevealFrame=requestAnimationFrame(()=>{if(this.focusRevealFrame=void 0,!this.isConnected||this.disabled)return;const focused=shadowFocusTarget(this);!(focused instanceof HTMLElement)||!focused.part.contains("swatch")||focused.scrollIntoView({block:"nearest",inline:"nearest",behavior:"instant"})}),button?.focus({preventScroll:!0})}cancelFocusReveal(){this.focusRevealFrame!==void 0&&cancelAnimationFrame(this.focusRevealFrame),this.focusRevealFrame=void 0}disconnectedCallback(){this.cancelFocusReveal(),super.disconnectedCallback()}willUpdate(changed){if(super.willUpdate(changed),setCustomState(this.stateInternals,"selected",this.resolveSelectedIndex()>=0),!changed.has("items"))return;const active=shadowFocusTarget(this);if(!active?.part?.contains("swatch"))return;const previousOptions=changed.get("items"),previousIndex=Number(active.dataset.index);if(!Number.isInteger(previousIndex)||previousIndex<0)return;const focusedOption=previousOptions?.[previousIndex],identityIndex=focusedOption===void 0?-1:this.items.indexOf(focusedOption),nextIndex=identityIndex>=0?identityIndex:Math.min(previousIndex,this.items.length-1);if(nextIndex<0){this.pendingFocusIndex=void 0,this.fallbackTabbableIndex=0;return}this.pendingFocusIndex=nextIndex,this.fallbackTabbableIndex=nextIndex}updated(changed){super.updated(changed),!(!changed.has("items")||this.pendingFocusIndex===void 0)&&this.scheduleAfterUpdate(()=>{const pendingIndex=this.pendingFocusIndex;this.pendingFocusIndex=void 0,!(pendingIndex===void 0||this.items.length===0)&&this.focusSwatch(Math.min(pendingIndex,this.items.length-1))},"restore-swatch-picker-focus")}tabbableSwatch(){return this.renderRoot?.querySelector(`[part~="swatch"][data-index="${this.tabbableIndex()}"]`)??null}tabbableIndex(){const selectedIndex=this.resolveSelectedIndex(),index=selectedIndex!==-1?selectedIndex:Math.min(this.fallbackTabbableIndex,Math.max(0,this.items.length-1));return this.items[index]?.disabled?this.items.findIndex(item=>!item.disabled):index}click(){this.disabled||this.tabbableSwatch()?.click()}focus(options){this.cancelFocusReveal(),!this.disabled&&this.tabbableSwatch()?.focus(options)}blur(){this.cancelFocusReveal(),this.tabbableSwatch()?.blur()}keyboardOriginIndex(event){const fromEvent=event.composedPath().find(candidate2=>candidate2.nodeType===1&&candidate2.part?.contains("swatch")===!0&&candidate2.getRootNode()===this.renderRoot),focused=shadowFocusTarget(this),candidate=fromEvent??(focused?.part?.contains("swatch")?focused:void 0),index=Number(candidate?.dataset.index);return Number.isInteger(index)&&index>=0&&index<this.items.length?index:this.resolveSelectedIndex()}render(){const hostLabel=this.getAttribute("aria-label"),ariaLabel=hostLabel!==null?hostLabel:this.accessibleLabel||nothing,selectedIndex=this.resolveSelectedIndex(),tabbableIndex=this.tabbableIndex();return html`
2
2
  <div
3
3
  part="base"
4
4
  role="radiogroup"
@@ -42,8 +42,6 @@ expanded:boolean;}export interface LyraAppRailItemEventMap{'lr-toggle-request':C
42
42
  * @slot - The visible navigation label.
43
43
  * @slot start - The leading decorative icon. Its flattened subtree is inert and hidden from
44
44
  * assistive technology; the default slot or host `aria-label` names the internal control.
45
- * @slot icon - Legacy slot content is deprecated; use `start`. Its flattened subtree is inert and
46
- * hidden from assistive technology.
47
45
  * @slot meta - Secondary trailing text -- an unread count, a keyboard shortcut. Rendered as a
48
46
  * SIBLING of the internal link/button, never inside it, so it is not part of the item's
49
47
  * accessible name and a pointer landing on it does not activate the item. Visually clipped in
@@ -1,6 +1,6 @@
1
1
  import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{activateNonmodalOverlay,composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{isKeyboardFocusEvent}from"../../../internal/focus-modality.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{applyComposedFocusRepair,captureComposedFocusRepair,isComposedFocusAvailable,repairComposedFocus}from"../../../internal/focus-navigation.js";import{chevronIcon}from"../../../internal/icons.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{resolveGuardedRel}from"../../../internal/link-rel.js";import{LyraElement}from"../../../internal/lyra-element.js";import{AccessibleTextController}from"../../../internal/accessible-text-controller.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{tag}from"../../../internal/prefix.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{safeLinkHref}from"../../../internal/safe-url.js";import{deferredPlace as place,syncTopLayerRelease,topLayerPlacement}from"../../../internal/anchored-overlay-runtime.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{rtlAwarePlacement}from"../../../internal/rtl.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{styles}from"./app-rail-item.styles.js";import{LYRA_DEFAULT_appRailItemCollapse,LYRA_DEFAULT_appRailItemExpand}from"../../../internal/default-strings/layout.generated.js";class LyraAppRailItem extends LyraElement{constructor(){super(...arguments),this.href="",this.target="",this.disabled=!1,this.current=!1,this.tooltip=!1,this.topLayer=!1,this.railTopLayer=!1,this._expanded=!1,this.toggleGuard=new VetoWriteGuard,this.showTooltip=!1,this.hasEndSlot=!1,this.hasMetaSlot=!1,this.labelTextObserver=new AccessibleTextController(this,[],()=>this.requestUpdate(),[],!1),this.recoverFocusAfterIconOnly=!1,this.childrenId=nextId("app-rail-item-children"),this.onToggleClick=event=>{event.stopPropagation();const next=!this._expanded;requestThenCommit({requestDetail:{expanded:next},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.toggleGuard,commit:()=>{this.expanded=next,this.emit("lr-toggle",{expanded:next})}})},this.onFocusShow=event=>{if(this.tooltip&&this.hasAttribute("icon-only")&&(event.type!=="focus"||isKeyboardFocusEvent(event))&&(this.showTooltip=!0),event.type!=="focus")return;const related=event.relatedTarget;related&&related.nodeType===1&&isComposedFocusAvailable(related)&&(this.focusReturnTarget=related)},this.onBlurHide=()=>{this.showTooltip=!1},this.onEndSlotChange=event=>{this.applyEndSlotPresence(event.target)},this.onMetaSlotChange=event=>{this.applyMetaSlotPresence(event.target)}}static{this.defaultStrings={...super.defaultStrings,appRailItemCollapse:LYRA_DEFAULT_appRailItemCollapse,appRailItemExpand:LYRA_DEFAULT_appRailItemExpand}}static{this.styles=[LyraElement.styles,styles]}static get observedAttributes(){return[...super.observedAttributes,"icon-only"]}syncRailTopLayer(){const rail=this.closest(tag("app-rail"));this.railTopLayer=rail?.topLayer===!0}get effectiveTopLayer(){return this.topLayer||this.railTopLayer}get expanded(){return this._expanded}set expanded(next){const old=this._expanded;this._expanded=next,markVetoGuardWrite(this.toggleGuard),this.requestUpdate("expanded",old)}get hasChildrenSlotted(){return Array.from(this.children).some(el=>el.getAttribute("slot")==="children")}connectedCallback(){super.connectedCallback(),this.syncRailTopLayer(),this.armChildrenObserver(),this.syncOwnedChildren()}armChildrenObserver(){this.childrenObserver?.disconnect();const MutationObserverCtor=this.ownerDocument.defaultView?.MutationObserver;MutationObserverCtor&&(this.childrenObserver=new MutationObserverCtor(()=>{this.syncOwnedChildren(),this.requestUpdate()}),this.childrenObserver.observe(this,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["slot"]}))}syncOwnedChildren(){if(!this.isConnected)return;const iconOnly=this.hasAttribute("icon-only"),itemTag=tag("app-rail-item");for(const node of this.querySelectorAll(itemTag))(node.parentElement?.closest(itemTag)??null)===this&&node.toggleAttribute("icon-only",iconOnly)}get labelText(){return Array.from(this.childNodes).filter(node=>node.nodeType===3||node.nodeType===1&&!node.getAttribute("slot")).map(n=>n.textContent??"").join("").trim()}get tooltipText(){return hostAriaLabel(this)??(this.labelText||"")}applyEndSlotPresence(slot){this.hasEndSlot=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType!==3||(node.textContent??"").trim()!=="")}applyMetaSlotPresence(slot){this.hasMetaSlot=slot.assignedNodes({flatten:!0}).some(node=>node.nodeType!==3||(node.textContent??"").trim()!=="")}attributeChangedCallback(name,oldValue,newValue){if(super.attributeChangedCallback(name,oldValue,newValue),!(name!=="icon-only"||oldValue===newValue)){if(newValue===null)this.showTooltip=!1;else{const active=deepActiveElement(this.ownerDocument),toggle=this.renderRoot?.querySelector('[part="toggle"]');this.recoverFocusAfterIconOnly=active===toggle||Array.from(this.children).some(child=>child.getAttribute("slot")==="children"&&composedContains(child,active))}this.syncOwnedChildren(),this.requestUpdate()}}firstUpdated(changed){super.firstUpdated(changed);const metaSlot=this.metaSlot,endSlot=this.endSlot;queueMicrotask(()=>{collectInitialSlotAssignment(metaSlot,s=>this.applyMetaSlotPresence(s)),collectInitialSlotAssignment(endSlot,s=>this.applyEndSlotPresence(s))})}willUpdate(changed){super.willUpdate(changed),changed.has("tooltip")&&!this.tooltip&&(this.showTooltip=!1),this.labelTextObserver.setEnabled(this.showTooltip);const children=this.renderRoot?.querySelector('[part="children"]');if(changed.has("expanded")&&!this._expanded&&children&&repairComposedFocus(children,()=>this.renderRoot.querySelector('[part="toggle"]')),changed.has("href")||changed.has("disabled")){const previous=this.renderRoot?.querySelector('[part="base"]')??null,nextIsLink=!!safeLinkHref(this.href)&&!this.disabled,ownerReplaced=previous!==null&&previous.localName==="a"!==nextIsLink;this.semanticFocusRepair=ownerReplaced&&shadowFocusTarget(this)===previous?captureComposedFocusRepair(this,this.focusFallback()??previous)??void 0:void 0}}updated(changed){super.updated(changed),this.recoverFocusAfterIconOnly&&(this.recoverFocusAfterIconOnly=!1,this.scheduleAfterUpdate(()=>{const base=this.renderRoot.querySelector('[part="base"]');base&&isComposedFocusAvailable(base)&&!composedContains(base,deepActiveElement(this.ownerDocument))&&base.focus()},"app-rail-item-icon-only-focus"));const focusRepair=this.semanticFocusRepair;this.semanticFocusRepair=void 0,focusRepair&&this.scheduleAfterUpdate(()=>{const replacement=this.renderRoot.querySelector('[part="base"]'),target=replacement&&isComposedFocusAvailable(replacement)?replacement:this.focusFallback();applyComposedFocusRepair(focusRepair,target)},"app-rail-item-owner-focus");const popup=this.renderRoot.querySelector('[part="tooltip"]');if(!popup){this.stopPositioning?.(),this.stopPositioning=void 0,this.tooltipOverlay?.deactivate({restoreFocus:!1}),this.tooltipOverlay=void 0;return}if(this.tooltipOverlay?.isActive()||(this.tooltipOverlay=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="tooltip"]'),onEscape:()=>{this.showTooltip=!1},restoreFocusTo:null})),changed.has("showTooltip")||changed.has("topLayer")||changed.has("railTopLayer")||!this.stopPositioning){this.stopPositioning?.();const anchor=this.renderRoot.querySelector('[part="base"]'),topLayer=this.effectiveTopLayer;this.placedTopLayer=syncTopLayerRelease(popup,this.placedTopLayer,topLayer),this.stopPositioning=place(anchor,popup,{placement:rtlAwarePlacement("right",this),...topLayerPlacement(topLayer,resolveEffectivePositioningStrategy(this,void 0,"fixed"))})}}disconnectedCallback(){super.disconnectedCallback(),this.semanticFocusRepair=void 0,this.focusReturnTarget=void 0,this.childrenObserver?.disconnect(),this.childrenObserver=void 0,this.stopPositioning?.(),this.stopPositioning=void 0,this.tooltipOverlay?.deactivate({restoreFocus:!1}),this.tooltipOverlay=void 0,this.showTooltip=!1}adoptedCallback(){super.adoptedCallback(),this.labelTextObserver.adopted()}focusFallback(){if(this.focusReturnTarget&&isComposedFocusAvailable(this.focusReturnTarget))return this.focusReturnTarget;const owner=this.closest(tag("app-rail"))?.shadowRoot?.querySelector('[part~="base"], [part~="panel"]')??null;return owner&&isComposedFocusAvailable(owner)?owner:null}click(){this.disabled||this.renderRoot.querySelector('[part~="base"]')?.click()}render(){const label=hostAriaLabel(this),href=safeLinkHref(this.href),content=html`
2
2
  ${this.current?html`<span part="current-indicator" aria-hidden="true"></span>`:nothing}
3
- ${renderInertPresentation(html`<slot name="start"><slot name="icon"></slot></slot>`,{part:"icon"})}
3
+ ${renderInertPresentation(html`<slot name="start"></slot>`,{part:"icon"})}
4
4
  <span part="label"><slot></slot></span>
5
5
  `,tooltip=this.showTooltip&&this.tooltip&&this.hasAttribute("icon-only")?html`<span part="tooltip" role="tooltip" aria-hidden="true">${this.tooltipText}</span>`:nothing,adornments=html`<span part="meta" ?hidden=${!this.hasMetaSlot}
6
6
  ><slot name="meta" @slotchange=${this.onMetaSlotChange}></slot></span
@@ -237,7 +237,7 @@ export{computeAppRailMode}from'./app-rail-mode.js';export interface LyraAppRailE
237
237
  * ```html
238
238
  * <lr-app-rail>
239
239
  * <lr-app-rail-item href="/inbox" aria-label="Inbox">
240
- * <svg slot="icon" aria-hidden="true">...</svg>Inbox
240
+ * <svg slot="start" aria-hidden="true">...</svg>Inbox
241
241
  * </lr-app-rail-item>
242
242
  * </lr-app-rail>
243
243
  * ```
@@ -248,7 +248,7 @@ export{computeAppRailMode}from'./app-rail-mode.js';export interface LyraAppRailE
248
248
  * <lr-app-rail auto-hide label="Workspace" storage-key="app" persist="preferred-mode"
249
249
  * peek-open-delay="150" peek-close-delay="300">
250
250
  * <lr-app-rail-item href="/inbox" current>
251
- * <svg slot="icon" aria-hidden="true">...</svg>Inbox
251
+ * <svg slot="start" aria-hidden="true">...</svg>Inbox
252
252
  * </lr-app-rail-item>
253
253
  * </lr-app-rail>
254
254
  * ```
@@ -266,7 +266,7 @@ export{computeAppRailMode}from'./app-rail-mode.js';export interface LyraAppRailE
266
266
  * for="sidebar-trigger" hotkey="mod+b" storage-key="app" persist="preferred-mode">
267
267
  * <lr-app-rail-group heading="Platform">
268
268
  * <lr-app-rail-item href="/inbox" current tooltip>
269
- * <svg slot="icon" aria-hidden="true">...</svg>Inbox
269
+ * <svg slot="start" aria-hidden="true">...</svg>Inbox
270
270
  * </lr-app-rail-item>
271
271
  * </lr-app-rail-group>
272
272
  * <lr-divider></lr-divider>
@@ -93,7 +93,7 @@ protected static readonly identityCollectionProperties:readonly string[];protect
93
93
  get open():boolean;set open(next:boolean);
94
94
  /** Commands to search and activate. The sequence is copied, bounded, and frozen while command
95
95
  * identity is retained. `commandId` must be unique and nonempty; malformed rows and later
96
- * duplicates from untyped boundaries are omitted deterministically. */
96
+ * duplicates from untyped boundaries are omitted deterministically. Assign a new array to update: mutating an array and assigning it again does not. */
97
97
  commands:readonly LyraCommand[];
98
98
  /** Exact global activation chord. `mod` resolves to Command on macOS and Control elsewhere,
99
99
  * using Client Hints with legacy platform and reduced user-agent fallbacks. */
@@ -20,8 +20,7 @@ import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from
20
20
  * names the sole trigger button.
21
21
  * @slot icon - Optional decorative expand/collapse icon. Its flattened subtree remains visible
22
22
  * but is inert and hidden from assistive technology; the trigger button is the sole action.
23
- * @csspart base - Deprecated compatibility name for the outer wrapper; use `accordion-item`.
24
- * @csspart accordion-item - The outer wrapper. It is the same node as `base`.
23
+ * @csspart accordion-item - The outer wrapper.
25
24
  * @csspart heading - Heading around the trigger; omitted for `heading-level="none"`.
26
25
  * @csspart button - The trigger button.
27
26
  * @csspart label - Label container.
@@ -19,7 +19,7 @@ import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,stat
19
19
  </span>
20
20
  ${renderInertPresentation(html`<slot name="icon"><span class="default-icon"></span></slot>`,{part:"icon"})}
21
21
  </button>`;return html`<div
22
- part="base accordion-item"
22
+ part="accordion-item"
23
23
  data-appearance=${this.effectiveAppearance}
24
24
  data-icon-placement=${this.effectiveIconPlacement}
25
25
  >