@aceshooting/lyra-ui 1.2.0 → 2.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (384) hide show
  1. package/README.md +98 -14
  2. package/custom-elements.json +30279 -12124
  3. package/dist/components/app-rail/app-rail-item.d.ts +30 -0
  4. package/dist/components/app-rail/app-rail-item.js +68 -0
  5. package/dist/components/app-rail/app-rail-item.styles.d.ts +1 -0
  6. package/dist/components/app-rail/app-rail-item.styles.js +65 -0
  7. package/dist/components/app-rail/app-rail.d.ts +168 -0
  8. package/dist/components/app-rail/app-rail.js +419 -0
  9. package/dist/components/app-rail/app-rail.styles.d.ts +1 -0
  10. package/dist/components/app-rail/app-rail.styles.js +128 -0
  11. package/dist/components/attachment-chip/attachment-chip.d.ts +141 -0
  12. package/dist/components/attachment-chip/attachment-chip.js +356 -0
  13. package/dist/components/attachment-chip/attachment-chip.styles.d.ts +1 -0
  14. package/dist/components/attachment-chip/attachment-chip.styles.js +184 -0
  15. package/dist/components/attachment-trigger/attachment-trigger.d.ts +96 -0
  16. package/dist/components/attachment-trigger/attachment-trigger.js +270 -0
  17. package/dist/components/attachment-trigger/attachment-trigger.styles.d.ts +1 -0
  18. package/dist/components/attachment-trigger/attachment-trigger.styles.js +90 -0
  19. package/dist/components/chart/bar-chart.js +2 -18
  20. package/dist/components/chart/box-plot.d.ts +25 -1
  21. package/dist/components/chart/box-plot.js +147 -7
  22. package/dist/components/chart/box-plot.styles.js +13 -0
  23. package/dist/components/chart/bubble-chart.js +2 -18
  24. package/dist/components/chart/chart-loader.d.ts +44 -13
  25. package/dist/components/chart/chart-loader.js +65 -18
  26. package/dist/components/chart/chart.d.ts +55 -12
  27. package/dist/components/chart/chart.js +247 -49
  28. package/dist/components/chart/doughnut-chart.js +2 -18
  29. package/dist/components/chart/histogram-bin.d.ts +7 -1
  30. package/dist/components/chart/histogram-bin.js +32 -14
  31. package/dist/components/chart/histogram.js +8 -16
  32. package/dist/components/chart/line-chart.js +2 -18
  33. package/dist/components/chart/lite-chart.d.ts +134 -3
  34. package/dist/components/chart/lite-chart.js +382 -67
  35. package/dist/components/chart/lite-chart.styles.js +9 -0
  36. package/dist/components/chart/pie-chart.js +2 -18
  37. package/dist/components/chart/polar-area-chart.js +2 -18
  38. package/dist/components/chart/radar-chart.js +2 -18
  39. package/dist/components/chart/scatter-chart.js +2 -18
  40. package/dist/components/chat-composer/chat-composer.d.ts +133 -0
  41. package/dist/components/chat-composer/chat-composer.js +366 -0
  42. package/dist/components/chat-composer/chat-composer.styles.d.ts +1 -0
  43. package/dist/components/chat-composer/chat-composer.styles.js +145 -0
  44. package/dist/components/chat-message/chat-message.d.ts +141 -0
  45. package/dist/components/chat-message/chat-message.js +331 -0
  46. package/dist/components/chat-message/chat-message.styles.d.ts +1 -0
  47. package/dist/components/chat-message/chat-message.styles.js +203 -0
  48. package/dist/components/checkbox/checkbox.d.ts +117 -0
  49. package/dist/components/checkbox/checkbox.js +353 -0
  50. package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
  51. package/dist/components/checkbox/checkbox.styles.js +77 -0
  52. package/dist/components/chip/chip-group.d.ts +56 -0
  53. package/dist/components/chip/chip-group.js +130 -0
  54. package/dist/components/chip/chip-group.styles.d.ts +1 -0
  55. package/dist/components/chip/chip-group.styles.js +57 -0
  56. package/dist/components/chip/chip.d.ts +64 -0
  57. package/dist/components/chip/chip.js +122 -0
  58. package/dist/components/chip/chip.styles.d.ts +1 -0
  59. package/dist/components/chip/chip.styles.js +115 -0
  60. package/dist/components/citation-badge/citation-badge.d.ts +113 -0
  61. package/dist/components/citation-badge/citation-badge.js +318 -0
  62. package/dist/components/citation-badge/citation-badge.styles.d.ts +1 -0
  63. package/dist/components/citation-badge/citation-badge.styles.js +96 -0
  64. package/dist/components/code-block/code-block.d.ts +127 -0
  65. package/dist/components/code-block/code-block.js +382 -0
  66. package/dist/components/code-block/code-block.styles.d.ts +1 -0
  67. package/dist/components/code-block/code-block.styles.js +187 -0
  68. package/dist/components/code-block/code-loader.d.ts +87 -0
  69. package/dist/components/code-block/code-loader.js +142 -0
  70. package/dist/components/combobox/combobox.d.ts +65 -6
  71. package/dist/components/combobox/combobox.js +258 -48
  72. package/dist/components/combobox/combobox.styles.js +3 -3
  73. package/dist/components/combobox/option.d.ts +5 -1
  74. package/dist/components/combobox/option.js +35 -0
  75. package/dist/components/context-meter/context-meter.d.ts +53 -0
  76. package/dist/components/context-meter/context-meter.js +159 -0
  77. package/dist/components/context-meter/context-meter.styles.d.ts +1 -0
  78. package/dist/components/context-meter/context-meter.styles.js +114 -0
  79. package/dist/components/conversation-item/conversation-item.d.ts +125 -0
  80. package/dist/components/conversation-item/conversation-item.js +331 -0
  81. package/dist/components/conversation-item/conversation-item.styles.d.ts +1 -0
  82. package/dist/components/conversation-item/conversation-item.styles.js +155 -0
  83. package/dist/components/date-picker/calendar-core.d.ts +24 -0
  84. package/dist/components/date-picker/calendar-core.js +51 -4
  85. package/dist/components/date-picker/date-input.d.ts +100 -9
  86. package/dist/components/date-picker/date-input.js +383 -66
  87. package/dist/components/date-picker/date-picker.d.ts +35 -4
  88. package/dist/components/date-picker/date-picker.js +171 -44
  89. package/dist/components/dialog/confirm.d.ts +40 -0
  90. package/dist/components/dialog/confirm.js +76 -0
  91. package/dist/components/dialog/dialog.d.ts +129 -0
  92. package/dist/components/dialog/dialog.js +288 -0
  93. package/dist/components/dialog/dialog.styles.d.ts +1 -0
  94. package/dist/components/dialog/dialog.styles.js +96 -0
  95. package/dist/components/dock-panel/dock-panel.d.ts +142 -0
  96. package/dist/components/dock-panel/dock-panel.js +359 -0
  97. package/dist/components/dock-panel/dock-panel.styles.d.ts +1 -0
  98. package/dist/components/dock-panel/dock-panel.styles.js +159 -0
  99. package/dist/components/document-preview/document-preview.d.ts +143 -0
  100. package/dist/components/document-preview/document-preview.js +388 -0
  101. package/dist/components/document-preview/document-preview.styles.d.ts +1 -0
  102. package/dist/components/document-preview/document-preview.styles.js +191 -0
  103. package/dist/components/empty/empty.d.ts +1 -2
  104. package/dist/components/empty/empty.js +18 -12
  105. package/dist/components/empty/empty.styles.js +0 -3
  106. package/dist/components/export-button/csv.js +1 -1
  107. package/dist/components/export-button/export-button.d.ts +12 -0
  108. package/dist/components/export-button/export-button.js +35 -5
  109. package/dist/components/export-button/export-button.styles.js +5 -1
  110. package/dist/components/file-input/accept.js +2 -0
  111. package/dist/components/file-input/file-input.d.ts +10 -1
  112. package/dist/components/file-input/file-input.js +36 -5
  113. package/dist/components/flag/flag.d.ts +29 -13
  114. package/dist/components/flag/flag.js +54 -14
  115. package/dist/components/flag/flag.styles.js +1 -1
  116. package/dist/components/flag/language-map.d.ts +4 -1
  117. package/dist/components/flag/language-map.js +6 -3
  118. package/dist/components/gauge/gauge.d.ts +10 -1
  119. package/dist/components/gauge/gauge.js +41 -13
  120. package/dist/components/generation-status/generation-status.d.ts +117 -0
  121. package/dist/components/generation-status/generation-status.js +327 -0
  122. package/dist/components/generation-status/generation-status.styles.d.ts +1 -0
  123. package/dist/components/generation-status/generation-status.styles.js +84 -0
  124. package/dist/components/graph/graph.d.ts +37 -3
  125. package/dist/components/graph/graph.js +132 -20
  126. package/dist/components/heatmap/calendar-grid.d.ts +19 -7
  127. package/dist/components/heatmap/calendar-grid.js +42 -18
  128. package/dist/components/heatmap/heatmap-scale.d.ts +11 -1
  129. package/dist/components/heatmap/heatmap-scale.js +14 -2
  130. package/dist/components/heatmap/heatmap.d.ts +227 -12
  131. package/dist/components/heatmap/heatmap.js +488 -93
  132. package/dist/components/json-viewer/json-viewer.d.ts +70 -0
  133. package/dist/components/json-viewer/json-viewer.js +361 -0
  134. package/dist/components/json-viewer/json-viewer.styles.d.ts +1 -0
  135. package/dist/components/json-viewer/json-viewer.styles.js +177 -0
  136. package/dist/components/kbd/kbd.d.ts +77 -0
  137. package/dist/components/kbd/kbd.js +231 -0
  138. package/dist/components/kbd/kbd.styles.d.ts +1 -0
  139. package/dist/components/kbd/kbd.styles.js +52 -0
  140. package/dist/components/live-region/live-region.d.ts +90 -0
  141. package/dist/components/live-region/live-region.js +189 -0
  142. package/dist/components/live-region/live-region.styles.d.ts +1 -0
  143. package/dist/components/live-region/live-region.styles.js +10 -0
  144. package/dist/components/map/map.d.ts +32 -7
  145. package/dist/components/map/map.js +133 -32
  146. package/dist/components/markdown/markdown-loader.d.ts +58 -0
  147. package/dist/components/markdown/markdown-loader.js +77 -0
  148. package/dist/components/markdown/markdown.d.ts +119 -0
  149. package/dist/components/markdown/markdown.js +389 -0
  150. package/dist/components/markdown/markdown.styles.d.ts +1 -0
  151. package/dist/components/markdown/markdown.styles.js +88 -0
  152. package/dist/components/media-card/media-card.d.ts +130 -0
  153. package/dist/components/media-card/media-card.js +273 -0
  154. package/dist/components/media-card/media-card.styles.d.ts +1 -0
  155. package/dist/components/media-card/media-card.styles.js +132 -0
  156. package/dist/components/mention-popover/mention-popover.d.ts +203 -0
  157. package/dist/components/mention-popover/mention-popover.js +493 -0
  158. package/dist/components/mention-popover/mention-popover.styles.d.ts +1 -0
  159. package/dist/components/mention-popover/mention-popover.styles.js +101 -0
  160. package/dist/components/menu/menu-item.d.ts +91 -0
  161. package/dist/components/menu/menu-item.js +206 -0
  162. package/dist/components/menu/menu-item.styles.d.ts +1 -0
  163. package/dist/components/menu/menu-item.styles.js +75 -0
  164. package/dist/components/menu/menu.d.ts +167 -0
  165. package/dist/components/menu/menu.js +461 -0
  166. package/dist/components/menu/menu.styles.d.ts +1 -0
  167. package/dist/components/menu/menu.styles.js +67 -0
  168. package/dist/components/model-select/model-select.d.ts +170 -0
  169. package/dist/components/model-select/model-select.js +588 -0
  170. package/dist/components/model-select/model-select.styles.d.ts +1 -0
  171. package/dist/components/model-select/model-select.styles.js +203 -0
  172. package/dist/components/model-settings-panel/model-settings-panel.d.ts +93 -0
  173. package/dist/components/model-settings-panel/model-settings-panel.js +209 -0
  174. package/dist/components/model-settings-panel/model-settings-panel.styles.d.ts +1 -0
  175. package/dist/components/model-settings-panel/model-settings-panel.styles.js +82 -0
  176. package/dist/components/playback/playback.d.ts +19 -3
  177. package/dist/components/playback/playback.js +109 -33
  178. package/dist/components/playback/playback.styles.js +6 -1
  179. package/dist/components/responsive-panel/responsive-panel.d.ts +163 -0
  180. package/dist/components/responsive-panel/responsive-panel.js +363 -0
  181. package/dist/components/responsive-panel/responsive-panel.styles.d.ts +1 -0
  182. package/dist/components/responsive-panel/responsive-panel.styles.js +103 -0
  183. package/dist/components/result-card/result-card.d.ts +50 -0
  184. package/dist/components/result-card/result-card.js +89 -0
  185. package/dist/components/result-card/result-card.styles.d.ts +1 -0
  186. package/dist/components/result-card/result-card.styles.js +49 -0
  187. package/dist/components/result-card/result-field.d.ts +36 -0
  188. package/dist/components/result-card/result-field.js +87 -0
  189. package/dist/components/result-card/result-field.styles.d.ts +1 -0
  190. package/dist/components/result-card/result-field.styles.js +32 -0
  191. package/dist/components/select/select.d.ts +84 -4
  192. package/dist/components/select/select.js +251 -36
  193. package/dist/components/skeleton/skeleton.d.ts +3 -0
  194. package/dist/components/skeleton/skeleton.js +7 -1
  195. package/dist/components/skeleton/skeleton.styles.js +5 -4
  196. package/dist/components/slider/slider.d.ts +141 -0
  197. package/dist/components/slider/slider.js +467 -0
  198. package/dist/components/slider/slider.styles.d.ts +1 -0
  199. package/dist/components/slider/slider.styles.js +87 -0
  200. package/dist/components/source-card/source-card.d.ts +104 -0
  201. package/dist/components/source-card/source-card.js +195 -0
  202. package/dist/components/source-card/source-card.styles.d.ts +1 -0
  203. package/dist/components/source-card/source-card.styles.js +69 -0
  204. package/dist/components/source-list/source-list.d.ts +63 -0
  205. package/dist/components/source-list/source-list.js +130 -0
  206. package/dist/components/source-list/source-list.styles.d.ts +1 -0
  207. package/dist/components/source-list/source-list.styles.js +59 -0
  208. package/dist/components/sparkline/sparkline.js +58 -20
  209. package/dist/components/split/split.d.ts +224 -5
  210. package/dist/components/split/split.js +617 -43
  211. package/dist/components/split/split.styles.js +47 -0
  212. package/dist/components/stat/stat.d.ts +15 -4
  213. package/dist/components/stat/stat.js +53 -12
  214. package/dist/components/stream-status/stream-status.d.ts +126 -0
  215. package/dist/components/stream-status/stream-status.js +292 -0
  216. package/dist/components/stream-status/stream-status.styles.d.ts +1 -0
  217. package/dist/components/stream-status/stream-status.styles.js +103 -0
  218. package/dist/components/streaming-text/streaming-text.d.ts +104 -0
  219. package/dist/components/streaming-text/streaming-text.js +224 -0
  220. package/dist/components/streaming-text/streaming-text.styles.d.ts +1 -0
  221. package/dist/components/streaming-text/streaming-text.styles.js +63 -0
  222. package/dist/components/switch/switch.d.ts +103 -0
  223. package/dist/components/switch/switch.js +250 -0
  224. package/dist/components/switch/switch.styles.d.ts +1 -0
  225. package/dist/components/switch/switch.styles.js +75 -0
  226. package/dist/components/table/table.d.ts +89 -5
  227. package/dist/components/table/table.js +243 -26
  228. package/dist/components/table/table.styles.js +6 -1
  229. package/dist/components/tabs/tabs.d.ts +74 -0
  230. package/dist/components/tabs/tabs.js +254 -0
  231. package/dist/components/tabs/tabs.styles.d.ts +1 -0
  232. package/dist/components/tabs/tabs.styles.js +74 -0
  233. package/dist/components/thinking-panel/thinking-panel.d.ts +123 -0
  234. package/dist/components/thinking-panel/thinking-panel.js +260 -0
  235. package/dist/components/thinking-panel/thinking-panel.styles.d.ts +1 -0
  236. package/dist/components/thinking-panel/thinking-panel.styles.js +123 -0
  237. package/dist/components/time-range/time-range.d.ts +59 -2
  238. package/dist/components/time-range/time-range.js +163 -67
  239. package/dist/components/toast/toast-item.d.ts +12 -2
  240. package/dist/components/toast/toast-item.js +106 -44
  241. package/dist/components/toast/toast-item.styles.js +59 -28
  242. package/dist/components/toast/toast.js +17 -5
  243. package/dist/components/toast/toaster.js +10 -1
  244. package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +131 -0
  245. package/dist/components/tool-approval-dialog/tool-approval-dialog.js +329 -0
  246. package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.d.ts +1 -0
  247. package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.js +160 -0
  248. package/dist/components/tool-call-chip/tool-call-chip.d.ts +105 -0
  249. package/dist/components/tool-call-chip/tool-call-chip.js +349 -0
  250. package/dist/components/tool-call-chip/tool-call-chip.styles.d.ts +1 -0
  251. package/dist/components/tool-call-chip/tool-call-chip.styles.js +203 -0
  252. package/dist/components/tool-param-form/tool-param-form.d.ts +206 -0
  253. package/dist/components/tool-param-form/tool-param-form.js +610 -0
  254. package/dist/components/tool-param-form/tool-param-form.styles.d.ts +1 -0
  255. package/dist/components/tool-param-form/tool-param-form.styles.js +75 -0
  256. package/dist/components/tool-result-dialog/tool-result-dialog.d.ts +122 -0
  257. package/dist/components/tool-result-dialog/tool-result-dialog.js +358 -0
  258. package/dist/components/tool-result-dialog/tool-result-dialog.styles.d.ts +1 -0
  259. package/dist/components/tool-result-dialog/tool-result-dialog.styles.js +176 -0
  260. package/dist/components/tool-result-view/registry.d.ts +73 -0
  261. package/dist/components/tool-result-view/registry.js +89 -0
  262. package/dist/components/tool-result-view/tool-result-view.d.ts +58 -0
  263. package/dist/components/tool-result-view/tool-result-view.js +152 -0
  264. package/dist/components/tool-result-view/tool-result-view.styles.d.ts +1 -0
  265. package/dist/components/tool-result-view/tool-result-view.styles.js +13 -0
  266. package/dist/components/tool-select-dialog/tool-select-dialog.d.ts +151 -0
  267. package/dist/components/tool-select-dialog/tool-select-dialog.js +350 -0
  268. package/dist/components/tool-select-dialog/tool-select-dialog.styles.d.ts +1 -0
  269. package/dist/components/tool-select-dialog/tool-select-dialog.styles.js +191 -0
  270. package/dist/components/tree/tree-node.d.ts +15 -3
  271. package/dist/components/tree/tree-node.js +20 -7
  272. package/dist/components/tree/tree.d.ts +25 -10
  273. package/dist/components/tree/tree.js +39 -31
  274. package/dist/components/typing-indicator/typing-indicator.d.ts +70 -0
  275. package/dist/components/typing-indicator/typing-indicator.js +108 -0
  276. package/dist/components/typing-indicator/typing-indicator.styles.d.ts +1 -0
  277. package/dist/components/typing-indicator/typing-indicator.styles.js +132 -0
  278. package/dist/components/virtual-list/virtual-list.d.ts +210 -0
  279. package/dist/components/virtual-list/virtual-list.js +607 -0
  280. package/dist/components/virtual-list/virtual-list.styles.d.ts +1 -0
  281. package/dist/components/virtual-list/virtual-list.styles.js +56 -0
  282. package/dist/components/widget/widget.d.ts +5 -4
  283. package/dist/components/widget/widget.js +54 -120
  284. package/dist/components/widget/widget.styles.js +8 -2
  285. package/dist/components/word-cloud/word-cloud-layout.d.ts +7 -0
  286. package/dist/components/word-cloud/word-cloud-layout.js +29 -2
  287. package/dist/components/word-cloud/word-cloud.d.ts +28 -2
  288. package/dist/components/word-cloud/word-cloud.js +69 -19
  289. package/dist/components/word-cloud/word-cloud.styles.js +16 -3
  290. package/dist/internal/anchored-validity.d.ts +1 -0
  291. package/dist/internal/anchored-validity.js +86 -0
  292. package/dist/internal/announcer.d.ts +57 -0
  293. package/dist/internal/announcer.js +71 -0
  294. package/dist/internal/form-associated.d.ts +8 -0
  295. package/dist/internal/form-associated.js +98 -15
  296. package/dist/internal/group-by-recency.d.ts +50 -0
  297. package/dist/internal/group-by-recency.js +80 -0
  298. package/dist/internal/numbers.d.ts +12 -0
  299. package/dist/internal/numbers.js +26 -0
  300. package/dist/internal/overlay-manager.d.ts +51 -0
  301. package/dist/internal/overlay-manager.js +523 -0
  302. package/dist/internal/positioner.js +27 -3
  303. package/dist/internal/rtl.d.ts +23 -0
  304. package/dist/internal/rtl.js +28 -0
  305. package/dist/internal/safe-url.d.ts +12 -0
  306. package/dist/internal/safe-url.js +41 -0
  307. package/dist/internal/scroll-lock.d.ts +10 -5
  308. package/dist/internal/scroll-lock.js +30 -14
  309. package/dist/internal/tokens.styles.js +22 -10
  310. package/dist/lyra.d.ts +133 -31
  311. package/dist/lyra.js +96 -26
  312. package/llms-full.txt +4546 -183
  313. package/llms.txt +21 -5
  314. package/package.json +41 -6
  315. package/dist/components/chart/bar-chart.stories.d.ts +0 -5
  316. package/dist/components/chart/bar-chart.stories.js +0 -20
  317. package/dist/components/chart/box-plot.stories.d.ts +0 -5
  318. package/dist/components/chart/box-plot.stories.js +0 -29
  319. package/dist/components/chart/bubble-chart.stories.d.ts +0 -5
  320. package/dist/components/chart/bubble-chart.stories.js +0 -26
  321. package/dist/components/chart/chart.stories.d.ts +0 -32
  322. package/dist/components/chart/chart.stories.js +0 -141
  323. package/dist/components/chart/doughnut-chart.stories.d.ts +0 -5
  324. package/dist/components/chart/doughnut-chart.stories.js +0 -26
  325. package/dist/components/chart/histogram.stories.d.ts +0 -5
  326. package/dist/components/chart/histogram.stories.js +0 -17
  327. package/dist/components/chart/line-chart.stories.d.ts +0 -22
  328. package/dist/components/chart/line-chart.stories.js +0 -99
  329. package/dist/components/chart/lite-chart.stories.d.ts +0 -14
  330. package/dist/components/chart/lite-chart.stories.js +0 -114
  331. package/dist/components/chart/pie-chart.stories.d.ts +0 -5
  332. package/dist/components/chart/pie-chart.stories.js +0 -26
  333. package/dist/components/chart/polar-area-chart.stories.d.ts +0 -5
  334. package/dist/components/chart/polar-area-chart.stories.js +0 -20
  335. package/dist/components/chart/radar-chart.stories.d.ts +0 -5
  336. package/dist/components/chart/radar-chart.stories.js +0 -20
  337. package/dist/components/chart/scatter-chart.stories.d.ts +0 -5
  338. package/dist/components/chart/scatter-chart.stories.js +0 -31
  339. package/dist/components/combobox/combobox.stories.d.ts +0 -24
  340. package/dist/components/combobox/combobox.stories.js +0 -102
  341. package/dist/components/date-picker/date-input.stories.d.ts +0 -10
  342. package/dist/components/date-picker/date-input.stories.js +0 -48
  343. package/dist/components/date-picker/date-picker.stories.d.ts +0 -10
  344. package/dist/components/date-picker/date-picker.stories.js +0 -25
  345. package/dist/components/empty/empty.stories.d.ts +0 -7
  346. package/dist/components/empty/empty.stories.js +0 -34
  347. package/dist/components/export-button/export-button.stories.d.ts +0 -7
  348. package/dist/components/export-button/export-button.stories.js +0 -37
  349. package/dist/components/file-input/file-input.stories.d.ts +0 -7
  350. package/dist/components/file-input/file-input.stories.js +0 -19
  351. package/dist/components/flag/flag.stories.d.ts +0 -6
  352. package/dist/components/flag/flag.stories.js +0 -31
  353. package/dist/components/gauge/gauge.stories.d.ts +0 -8
  354. package/dist/components/gauge/gauge.stories.js +0 -19
  355. package/dist/components/graph/graph.stories.d.ts +0 -8
  356. package/dist/components/graph/graph.stories.js +0 -68
  357. package/dist/components/heatmap/heatmap.stories.d.ts +0 -27
  358. package/dist/components/heatmap/heatmap.stories.js +0 -179
  359. package/dist/components/map/map.stories.d.ts +0 -15
  360. package/dist/components/map/map.stories.js +0 -135
  361. package/dist/components/playback/playback.stories.d.ts +0 -7
  362. package/dist/components/playback/playback.stories.js +0 -16
  363. package/dist/components/select/select.stories.d.ts +0 -21
  364. package/dist/components/select/select.stories.js +0 -91
  365. package/dist/components/skeleton/skeleton.stories.d.ts +0 -5
  366. package/dist/components/skeleton/skeleton.stories.js +0 -16
  367. package/dist/components/sparkline/sparkline.stories.d.ts +0 -11
  368. package/dist/components/sparkline/sparkline.stories.js +0 -39
  369. package/dist/components/split/split.stories.d.ts +0 -7
  370. package/dist/components/split/split.stories.js +0 -36
  371. package/dist/components/stat/stat.stories.d.ts +0 -9
  372. package/dist/components/stat/stat.stories.js +0 -81
  373. package/dist/components/table/table.stories.d.ts +0 -12
  374. package/dist/components/table/table.stories.js +0 -67
  375. package/dist/components/time-range/time-range.stories.d.ts +0 -8
  376. package/dist/components/time-range/time-range.stories.js +0 -26
  377. package/dist/components/toast/toast.stories.d.ts +0 -8
  378. package/dist/components/toast/toast.stories.js +0 -72
  379. package/dist/components/tree/tree.stories.d.ts +0 -9
  380. package/dist/components/tree/tree.stories.js +0 -52
  381. package/dist/components/widget/widget.stories.d.ts +0 -9
  382. package/dist/components/widget/widget.stories.js +0 -74
  383. package/dist/components/word-cloud/word-cloud.stories.d.ts +0 -10
  384. package/dist/components/word-cloud/word-cloud.stories.js +0 -55
@@ -0,0 +1,607 @@
1
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
6
+ };
7
+ import { html, nothing } from 'lit';
8
+ import { property, state } from 'lit/decorators.js';
9
+ import { repeat } from 'lit/directives/repeat.js';
10
+ import { styleMap } from 'lit/directives/style-map.js';
11
+ import { LyraElement } from '../../internal/lyra-element.js';
12
+ import { defineElement } from '../../internal/prefix.js';
13
+ import { styles } from './virtual-list.styles.js';
14
+ /** Fallback per-row height (px) used for any row that hasn't been measured
15
+ * yet in `row-height="auto"` mode -- close enough to a typical single-line
16
+ * chat-list row that the initial scrollbar/spacer size doesn't jump wildly
17
+ * once real measurements arrive. Irrelevant in fixed-`row-height` mode. */
18
+ const DEFAULT_ROW_ESTIMATE_PX = 48;
19
+ const DEFAULT_OVERSCAN_ROWS = 6;
20
+ /** Largest accepted overscan on either side of the visible range. This keeps
21
+ * an accidental huge value from defeating virtualization. */
22
+ export const MAX_OVERSCAN_ROWS = 100;
23
+ function normalizeOverscan(value) {
24
+ if (value === null)
25
+ return DEFAULT_OVERSCAN_ROWS;
26
+ const numeric = typeof value === 'number' ? value : Number(value);
27
+ if (!Number.isFinite(numeric))
28
+ return DEFAULT_OVERSCAN_ROWS;
29
+ return Math.min(MAX_OVERSCAN_ROWS, Math.max(0, Math.floor(numeric)));
30
+ }
31
+ const overscanConverter = {
32
+ fromAttribute(value) {
33
+ return normalizeOverscan(value);
34
+ },
35
+ };
36
+ function prefersReducedMotion() {
37
+ return typeof window !== 'undefined' && !!window.matchMedia?.('(prefers-reduced-motion: reduce)').matches;
38
+ }
39
+ /** A typed key is used in maps and active-row matching; this token is only for
40
+ * DOM attributes, where every value is necessarily a string. */
41
+ function domKeyToken(key) {
42
+ if (typeof key === 'number') {
43
+ if (Number.isNaN(key))
44
+ return 'number:NaN';
45
+ if (Object.is(key, -0))
46
+ return 'number:-0';
47
+ }
48
+ return `${typeof key}:${String(key)}`;
49
+ }
50
+ /**
51
+ * `<lyra-virtual-list>` — a generic windowed/virtualized list host. Renders
52
+ * only the items within the current viewport (plus `overscan` padding rows
53
+ * on each side) as real DOM, regardless of how large `items` is, so a
54
+ * multi-thousand-row chat history sidebar or long message thread stays cheap
55
+ * to scroll.
56
+ *
57
+ * Content is entirely caller-supplied: `renderItem(item, index)` returns
58
+ * whatever `lit-html` value should represent that row (typically a
59
+ * `TemplateResult`), and `keyFunction(item, index)` gives it a stable
60
+ * identity for `repeat()`'s DOM-reconciliation key, so scroll position and
61
+ * any per-row state (e.g. an `<audio>` element's playback position) survive
62
+ * an `items` mutation instead of every row remounting from scratch.
63
+ *
64
+ * **Windowing math.** Every row — in both `row-height` modes — is positioned
65
+ * by a `transform: translateY(offset)` computed from a single cumulative
66
+ * `offsets` array (`offsets[i]` = the pixel top of row `i`), rather than by
67
+ * page flow. This is what lets only a small DOM window exist while the
68
+ * scrollbar still reflects the *true* total content height:
69
+ * - **`row-height="auto"` (default).** Each currently-rendered row is
70
+ * watched by a `ResizeObserver`; its real height lands in a per-key
71
+ * `Map`, and any row not yet measured contributes `DEFAULT_ROW_ESTIMATE_PX`
72
+ * to the offsets array until it has been. `offsets` is *not* the same
73
+ * thing as a page-count-based `padding-top`/`padding-bottom` spacer pair —
74
+ * that approach reflows every unmeasured row's position on every new
75
+ * measurement, which is exactly what per-row transform offsets avoid: only
76
+ * the rows *after* a newly-measured one shift, and even that shift is a
77
+ * cheap style recompute, not a layout-affecting padding change.
78
+ * - **Fixed numeric `row-height`.** No measurement needed — `offsets[i]` is
79
+ * just `i * rowHeightPx`, computed by the exact same cumulative-array code
80
+ * path (a dedicated "single spacer + start-index" special case was
81
+ * considered and would work too, but reusing one code path for both modes
82
+ * avoids maintaining two parallel rendering strategies for a difference
83
+ * that's otherwise just "how is row *i*'s height looked up").
84
+ *
85
+ * The `offsets` array is rebuilt only when `items`, `row-height`, or
86
+ * `keyFunction` change, or a row's measured height changes -- not on every
87
+ * update, so a pure scroll-position tick (potentially every rAF while
88
+ * scrolling) only re-runs the cheap range/visibility math in
89
+ * `computeRange()`, never the `O(n)` offsets rebuild (which, in
90
+ * `row-height="auto"` mode, also means a `keyFunction` call per item). For
91
+ * the list sizes this component is meant for (a scrollable history sidebar,
92
+ * realistically hundreds to a few thousand rows) that rebuild is a trivial
93
+ * `O(n)` arithmetic loop even when it does run; it is *not* the right
94
+ * approach for a hundred-thousand-row list without further work (e.g. a
95
+ * Fenwick/segment tree for `O(log n)` offset queries+updates), which is out
96
+ * of scope here.
97
+ *
98
+ * **Accessibility.** The scroll container is `role="list"` and each rendered
99
+ * row is `role="listitem"`, deliberately *not* `listbox`/`option` — this
100
+ * component only provides windowing, not the roving-tabindex/
101
+ * `aria-activedescendant` keyboard-interaction contract ARIA requires
102
+ * alongside a real `listbox`. A consumer that wants full single-select
103
+ * listbox semantics on top of this should compose that behavior itself (see
104
+ * `<lyra-select>`'s pattern), the same way this component's `active-id`
105
+ * only *scrolls* the matching row into view and marks it `aria-current` —
106
+ * it never claims to be a selection widget. `aria-setsize`/`aria-posinset`
107
+ * are computed from the row's real index in the full `items` array (not its
108
+ * position among the currently-rendered DOM window), so a screen reader
109
+ * still announces e.g. "item 12 of 340" correctly. `[part="base"]` itself
110
+ * carries `tabindex="0"` — `renderItem`'s content is caller-supplied and not
111
+ * guaranteed to contain a focusable element, and a scrollable region with no
112
+ * focusable content of its own is otherwise unreachable by keyboard (native
113
+ * arrow/Page Up/Page Down scrolling included).
114
+ *
115
+ * **Grouping.** When supplied, `groups` renders a labeled group marker at the
116
+ * corresponding `startIndex`. Group markers are positioned independently of
117
+ * the row window, so they remain available when the first row in a group is
118
+ * outside the current overscanned range.
119
+ *
120
+ * @customElement lyra-virtual-list
121
+ * @event lyra-load-more - Fired once per approach to the bottom of the list
122
+ * while `has-more` is true and `loading` is false. Deliberately does not
123
+ * refire on every scroll tick while still near the bottom (`loading`
124
+ * gates the in-flight case; scrolling back away from the bottom and
125
+ * returning, or `items` growing enough to move the window away from the
126
+ * end, re-arms it) — a consumer wanting an automatic retry after a failed
127
+ * fetch should surface its own retry affordance rather than relying on
128
+ * this firing again unprompted.
129
+ * @event lyra-visible-range-changed - `detail: { start, end }` (see
130
+ * `VirtualListRange`) — the current visible (non-overscanned) item index
131
+ * range, fired only when it actually changes.
132
+ * @csspart base - The scrollable container (`role="list"`).
133
+ * @csspart spacer - The full-content-height inner element that gives the
134
+ * container its true scrollable extent.
135
+ * @csspart group - A positioned group label.
136
+ * @csspart row - One rendered row's absolutely-positioned wrapper
137
+ * (`role="listitem"`); `renderItem`'s return value renders inside it.
138
+ */
139
+ export class LyraVirtualList extends LyraElement {
140
+ constructor() {
141
+ super(...arguments);
142
+ /** The full (non-windowed) item collection. */
143
+ this.items = [];
144
+ /** Renders one row's content — typically returns a `lit-html` `TemplateResult`. */
145
+ this.renderItem = () => nothing;
146
+ /** `'auto'` (default) measures each row's real height via `ResizeObserver`;
147
+ * a numeric string fixes every row to that many pixels. */
148
+ this.rowHeight = 'auto';
149
+ /** Extra rows rendered beyond the visible viewport on each side, to reduce
150
+ * blank-frame risk during fast scrolling. Normalized to a whole number in
151
+ * the inclusive range 0–`MAX_OVERSCAN_ROWS`; non-finite values use the
152
+ * default. */
153
+ this.overscan = DEFAULT_OVERSCAN_ROWS;
154
+ /** When set and it matches a row's typed `keyFunction` result, that row is
155
+ * smoothly scrolled into view whenever this changes. Attribute values are
156
+ * strings; assign the property for a numeric key. */
157
+ this.activeId = '';
158
+ this.loading = false;
159
+ /** When true, scrolling near the bottom fires `lyra-load-more`. */
160
+ this.hasMore = false;
161
+ // Named distinctly from the inherited DOM `scrollTop` (a `HTMLElement`
162
+ // property this class would otherwise shadow) -- this tracks the *scroll
163
+ // container's* scrollTop, not the host element's own (the host never
164
+ // scrolls itself; [part="base"] does).
165
+ this.containerScrollTop = 0;
166
+ this.viewportHeight = 0;
167
+ /** `offsets[i]` = row `i`'s pixel top; `offsets[items.length]` = total content height. Rebuilt only when `offsetsDirty` is set -- see `willUpdate()`. */
168
+ this.offsets = [0];
169
+ /** Parsed `rowHeight`: a positive pixel number, or `null` for `'auto'` (measured) mode. */
170
+ this.fixedRowHeight = null;
171
+ /** `row-height="auto"` per-row measured heights, keyed by
172
+ * keyFunction result. Pruned to the current `items`'
173
+ * live keys whenever `items` changes (see `recomputeOffsets()`), so a
174
+ * long-lived instance handed many wholly different `items` arrays over
175
+ * its life doesn't grow this map without bound. */
176
+ this.measuredHeights = new Map();
177
+ /** True whenever `offsets` needs rebuilding before the next render --
178
+ * set initially and whenever `items`/`rowHeight`/`keyFunction` change or
179
+ * a row's measured height changes, but *not* on a pure scroll-position
180
+ * update, so the `O(n)` rebuild (including a `keyFunction` call per item
181
+ * in `row-height="auto"` mode) only runs when something that actually
182
+ * affects row heights or ordering changed. */
183
+ this.offsetsDirty = true;
184
+ /** Set alongside `offsetsDirty` specifically when `items` changed (not
185
+ * just `rowHeight`/`keyFunction`/a measurement) -- consumed by the next
186
+ * `recomputeOffsets()` call to prune `measuredHeights` entries for keys
187
+ * no longer present in `items`. */
188
+ this.itemsChangedPendingPrune = false;
189
+ this.renderStart = 0;
190
+ this.renderEnd = -1;
191
+ this.visibleStart = 0;
192
+ this.visibleEnd = -1;
193
+ this.lastEmittedStart = -1;
194
+ this.lastEmittedEnd = -1;
195
+ /** Re-armed whenever the window moves away from the end of `items` -- see the `lyra-load-more` event doc. */
196
+ this.loadMoreArmed = true;
197
+ this.isFirstUpdate = true;
198
+ this.observedRows = new Map();
199
+ this.observedRowKeys = new WeakMap();
200
+ this.observedRowIndices = new WeakMap();
201
+ this.pendingScrollTop = null;
202
+ this.onScroll = (e) => {
203
+ this.pendingScrollTop = e.currentTarget.scrollTop;
204
+ if (this.scrollRafId !== undefined)
205
+ return;
206
+ // Coalesce to one recompute per animation frame -- native `scroll`
207
+ // events can fire far faster than that under a fast trackpad/touch
208
+ // fling, and each recompute is a full Lit update.
209
+ this.scrollRafId = requestAnimationFrame(() => {
210
+ this.scrollRafId = undefined;
211
+ if (this.pendingScrollTop !== null) {
212
+ this.containerScrollTop = this.pendingScrollTop;
213
+ this.pendingScrollTop = null;
214
+ }
215
+ });
216
+ };
217
+ this.onRowsResized = (entries) => {
218
+ if (this.fixedRowHeight != null)
219
+ return;
220
+ const base = this.renderRoot.querySelector('[part="base"]');
221
+ const oldScrollTop = base?.scrollTop ?? this.containerScrollTop;
222
+ let scrollAdjustment = 0;
223
+ let changed = false;
224
+ for (const entry of entries) {
225
+ const row = entry.target;
226
+ const key = this.observedRowKeys.get(row);
227
+ const index = this.observedRowIndices.get(row);
228
+ if (key === undefined || index === undefined)
229
+ continue;
230
+ const height = entry.borderBoxSize?.[0]?.blockSize ?? entry.target.getBoundingClientRect().height;
231
+ const prev = this.measuredHeights.get(key);
232
+ // A sub-pixel-only difference (common with fractional layout/zoom)
233
+ // isn't worth a full offsets rebuild + re-render.
234
+ if (prev === undefined || Math.abs(prev - height) > 0.5) {
235
+ this.measuredHeights.set(key, height);
236
+ // Keep the first visible row anchored while a row fully above it
237
+ // changes size. Otherwise auto-height measurement makes the viewport
238
+ // jump as soon as an earlier row is laid out.
239
+ const oldHeight = prev ?? DEFAULT_ROW_ESTIMATE_PX;
240
+ if (this.offsets[index + 1] <= oldScrollTop)
241
+ scrollAdjustment += height - oldHeight;
242
+ changed = true;
243
+ }
244
+ }
245
+ if (changed) {
246
+ if (base && scrollAdjustment !== 0) {
247
+ const nextScrollTop = Math.max(0, oldScrollTop + scrollAdjustment);
248
+ base.scrollTop = nextScrollTop;
249
+ this.containerScrollTop = nextScrollTop;
250
+ this.pendingScrollTop = null;
251
+ }
252
+ this.offsetsDirty = true;
253
+ this.requestUpdate();
254
+ }
255
+ };
256
+ }
257
+ static { this.styles = [LyraElement.styles, styles]; }
258
+ connectedCallback() {
259
+ super.connectedCallback();
260
+ this.rowResizeObserver = new ResizeObserver(this.onRowsResized);
261
+ // firstUpdated() only ever fires once per element instance -- a
262
+ // disconnect/reconnect (e.g. a reparenting drag) needs its own
263
+ // re-attach here, since the container observer/scroll listener were
264
+ // torn down in disconnectedCallback below. syncRowObservers() is called
265
+ // directly here (rather than left for the next Lit render) because a
266
+ // reconnect that doesn't also change some other reactive property never
267
+ // triggers one, which would otherwise leave every already-rendered row
268
+ // permanently unwatched by the freshly created ResizeObserver above.
269
+ if (this.hasUpdated) {
270
+ this.attachContainerListeners();
271
+ this.syncRowObservers();
272
+ }
273
+ }
274
+ disconnectedCallback() {
275
+ super.disconnectedCallback();
276
+ this.rowResizeObserver?.disconnect();
277
+ this.rowResizeObserver = undefined;
278
+ this.observedRows.clear();
279
+ this.containerResizeObserver?.disconnect();
280
+ this.containerResizeObserver = undefined;
281
+ if (this.scrollRafId !== undefined) {
282
+ cancelAnimationFrame(this.scrollRafId);
283
+ this.scrollRafId = undefined;
284
+ }
285
+ this.renderRoot.querySelector('[part="base"]')?.removeEventListener('scroll', this.onScroll);
286
+ }
287
+ firstUpdated() {
288
+ this.attachContainerListeners();
289
+ }
290
+ willUpdate(changed) {
291
+ this.isFirstUpdate = !this.hasUpdated;
292
+ if (changed.has('items') || changed.has('rowHeight') || changed.has('keyFunction')) {
293
+ this.offsetsDirty = true;
294
+ }
295
+ if (changed.has('items')) {
296
+ this.itemsChangedPendingPrune = true;
297
+ }
298
+ if (changed.has('rowHeight')) {
299
+ this.fixedRowHeight = this.parseRowHeight(this.rowHeight);
300
+ }
301
+ if (this.offsetsDirty) {
302
+ this.recomputeOffsets();
303
+ this.offsetsDirty = false;
304
+ }
305
+ // Always cheap: just arithmetic over the already-current offsets +
306
+ // scroll/viewport state, so this runs on a pure scroll-driven update too.
307
+ this.computeRange();
308
+ }
309
+ updated(changed) {
310
+ super.updated(changed);
311
+ this.syncRowObservers();
312
+ if (changed.has('activeId') && !this.isFirstUpdate)
313
+ this.scrollActiveIntoView();
314
+ this.emitRangeChangeIfNeeded();
315
+ this.maybeFireLoadMore();
316
+ }
317
+ parseRowHeight(value) {
318
+ if (value === 'auto')
319
+ return null;
320
+ const n = Number(value);
321
+ // Anything that isn't 'auto' or a positive finite number falls back to
322
+ // auto mode rather than throwing or producing a zero/negative-height
323
+ // row -- matches this library's generally-permissive attribute parsing.
324
+ return Number.isFinite(n) && n > 0 ? n : null;
325
+ }
326
+ keyOf(item, index) {
327
+ const key = this.keyFunction ? this.keyFunction(item, index) : index;
328
+ return typeof key === 'string' || typeof key === 'number' ? key : index;
329
+ }
330
+ recomputeOffsets() {
331
+ const n = this.items.length;
332
+ const offsets = new Array(n + 1);
333
+ offsets[0] = 0;
334
+ // Only build the live-keys set (and only when in row-height="auto" mode,
335
+ // where measuredHeights is actually populated) when items itself changed
336
+ // -- a measurement-only or rowHeight/keyFunction-only recompute has no
337
+ // stale entries to prune, so skipping this keeps those cases as cheap as
338
+ // before.
339
+ const pruneStale = this.itemsChangedPendingPrune && this.fixedRowHeight == null;
340
+ const liveKeys = pruneStale ? new Set() : null;
341
+ for (let i = 0; i < n; i++) {
342
+ let h;
343
+ if (this.fixedRowHeight != null) {
344
+ h = this.fixedRowHeight;
345
+ }
346
+ else {
347
+ const key = this.keyOf(this.items[i], i);
348
+ liveKeys?.add(key);
349
+ h = this.measuredHeights.get(key) ?? DEFAULT_ROW_ESTIMATE_PX;
350
+ }
351
+ offsets[i + 1] = offsets[i] + h;
352
+ }
353
+ this.offsets = offsets;
354
+ this.itemsChangedPendingPrune = false;
355
+ if (liveKeys) {
356
+ for (const key of this.measuredHeights.keys()) {
357
+ if (!liveKeys.has(key))
358
+ this.measuredHeights.delete(key);
359
+ }
360
+ }
361
+ }
362
+ /** First item index whose bottom edge is at/after `offset`. */
363
+ findIndexAtOrAfter(offset) {
364
+ const offsets = this.offsets;
365
+ let lo = 0;
366
+ let hi = offsets.length - 2;
367
+ while (lo < hi) {
368
+ const mid = (lo + hi) >> 1;
369
+ if (offsets[mid + 1] <= offset)
370
+ lo = mid + 1;
371
+ else
372
+ hi = mid;
373
+ }
374
+ return lo;
375
+ }
376
+ /** Last item index whose top edge is at/before `offset`. */
377
+ findIndexAtOrBefore(offset) {
378
+ const offsets = this.offsets;
379
+ let lo = 0;
380
+ let hi = offsets.length - 2;
381
+ while (lo < hi) {
382
+ const mid = (lo + hi + 1) >> 1;
383
+ if (offsets[mid] < offset)
384
+ lo = mid;
385
+ else
386
+ hi = mid - 1;
387
+ }
388
+ return lo;
389
+ }
390
+ computeRange() {
391
+ const n = this.items.length;
392
+ if (n === 0 || this.viewportHeight <= 0) {
393
+ this.visibleStart = 0;
394
+ this.visibleEnd = -1;
395
+ this.renderStart = 0;
396
+ this.renderEnd = -1;
397
+ return;
398
+ }
399
+ const viewTop = this.containerScrollTop;
400
+ const viewBottom = viewTop + this.viewportHeight;
401
+ this.visibleStart = this.findIndexAtOrAfter(viewTop);
402
+ this.visibleEnd = this.findIndexAtOrBefore(viewBottom);
403
+ // Property assignments bypass Lit's attribute converter, so normalize at
404
+ // the arithmetic boundary too. This preserves virtualization even when
405
+ // JavaScript writes Infinity, NaN, a negative, or an excessive number.
406
+ const overscan = normalizeOverscan(this.overscan);
407
+ this.renderStart = Math.max(0, this.visibleStart - overscan);
408
+ this.renderEnd = Math.min(n - 1, this.visibleEnd + overscan);
409
+ }
410
+ attachContainerListeners() {
411
+ const base = this.renderRoot.querySelector('[part="base"]');
412
+ if (!base)
413
+ return;
414
+ this.containerResizeObserver = new ResizeObserver((entries) => {
415
+ const entry = entries[0];
416
+ if (!entry)
417
+ return;
418
+ this.viewportHeight = entry.borderBoxSize?.[0]?.blockSize ?? entry.contentRect.height;
419
+ });
420
+ this.containerResizeObserver.observe(base);
421
+ base.addEventListener('scroll', this.onScroll, { passive: true });
422
+ // Read synchronously too -- ResizeObserver's first callback is
423
+ // asynchronous, so without this the very first render would otherwise
424
+ // sit at viewportHeight=0 (rendering no rows at all) until that callback
425
+ // eventually fires. This is called from firstUpdated(), so setting a
426
+ // reactive property here schedules a second update on top of the one
427
+ // that just finished -- Lit's dev-mode console flags that pattern, but
428
+ // it's the documented exception ("the next update can only be scheduled
429
+ // as a side effect of the previous update"): the container's real size
430
+ // genuinely isn't knowable until after the first layout.
431
+ this.viewportHeight = base.clientHeight;
432
+ this.containerScrollTop = base.scrollTop;
433
+ }
434
+ /** Keeps the row `ResizeObserver` watching exactly the currently-rendered
435
+ * rows in `row-height="auto"` mode -- rows that scroll out of the
436
+ * rendered window are unobserved so the observer doesn't accumulate
437
+ * references to detached elements it can never usefully report on again. */
438
+ syncRowObservers() {
439
+ const ro = this.rowResizeObserver;
440
+ if (!ro)
441
+ return;
442
+ if (this.fixedRowHeight != null) {
443
+ for (const el of this.observedRows.values())
444
+ ro.unobserve(el);
445
+ this.observedRows.clear();
446
+ return;
447
+ }
448
+ const current = new Map();
449
+ this.renderRoot.querySelectorAll('[part="row"]').forEach((el) => {
450
+ const index = Number(el.getAttribute('aria-posinset')) - 1;
451
+ if (!Number.isInteger(index) || index < 0 || index >= this.items.length)
452
+ return;
453
+ const key = this.keyOf(this.items[index], index);
454
+ current.set(key, el);
455
+ this.observedRowKeys.set(el, key);
456
+ this.observedRowIndices.set(el, index);
457
+ });
458
+ for (const [key, el] of this.observedRows) {
459
+ if (current.get(key) !== el) {
460
+ ro.unobserve(el);
461
+ this.observedRows.delete(key);
462
+ }
463
+ }
464
+ for (const [key, el] of current) {
465
+ if (!this.observedRows.has(key)) {
466
+ this.observedRows.set(key, el);
467
+ ro.observe(el);
468
+ }
469
+ }
470
+ }
471
+ scrollActiveIntoView() {
472
+ if (this.activeId === '')
473
+ return;
474
+ const index = this.items.findIndex((item, i) => Object.is(this.keyOf(item, i), this.activeId));
475
+ if (index < 0)
476
+ return;
477
+ const base = this.renderRoot.querySelector('[part="base"]');
478
+ if (!base)
479
+ return;
480
+ const top = this.offsets[index] ?? 0;
481
+ const bottom = this.offsets[index + 1] ?? top;
482
+ const viewTop = base.scrollTop;
483
+ const viewBottom = viewTop + base.clientHeight;
484
+ let target = null;
485
+ if (top < viewTop)
486
+ target = top;
487
+ else if (bottom > viewBottom)
488
+ target = bottom - base.clientHeight;
489
+ if (target === null)
490
+ return;
491
+ base.scrollTo({ top: Math.max(0, target), behavior: prefersReducedMotion() ? 'auto' : 'smooth' });
492
+ }
493
+ emitRangeChangeIfNeeded() {
494
+ if (this.visibleEnd < this.visibleStart)
495
+ return;
496
+ if (this.visibleStart === this.lastEmittedStart && this.visibleEnd === this.lastEmittedEnd)
497
+ return;
498
+ this.lastEmittedStart = this.visibleStart;
499
+ this.lastEmittedEnd = this.visibleEnd;
500
+ this.emit('lyra-visible-range-changed', {
501
+ start: this.visibleStart,
502
+ end: this.visibleEnd,
503
+ });
504
+ }
505
+ maybeFireLoadMore() {
506
+ const n = this.items.length;
507
+ const nearBottom = n > 0 && this.visibleEnd >= n - 1;
508
+ if (!nearBottom) {
509
+ this.loadMoreArmed = true;
510
+ return;
511
+ }
512
+ if (!this.hasMore || this.loading || !this.loadMoreArmed)
513
+ return;
514
+ this.loadMoreArmed = false;
515
+ this.emit('lyra-load-more');
516
+ }
517
+ renderRow(item, index, total) {
518
+ const key = this.keyOf(item, index);
519
+ const top = this.offsets[index] ?? 0;
520
+ const isActive = this.activeId !== '' && Object.is(key, this.activeId);
521
+ return html `
522
+ <div
523
+ part="row"
524
+ role="listitem"
525
+ data-row-key=${domKeyToken(key)}
526
+ aria-setsize=${total}
527
+ aria-posinset=${index + 1}
528
+ aria-current=${isActive ? 'true' : nothing}
529
+ style=${styleMap({ transform: `translateY(${top}px)` })}
530
+ >
531
+ ${this.renderItem(item, index)}
532
+ </div>
533
+ `;
534
+ }
535
+ renderGroups() {
536
+ const seen = new Set();
537
+ return (this.groups ?? [])
538
+ .filter((group) => {
539
+ const index = group.startIndex;
540
+ if (!Number.isInteger(index) || index < 0 || index >= this.items.length || seen.has(index))
541
+ return false;
542
+ seen.add(index);
543
+ return true;
544
+ })
545
+ .sort((a, b) => a.startIndex - b.startIndex)
546
+ .map((group) => html `
547
+ <div
548
+ part="group"
549
+ role="heading"
550
+ aria-level="2"
551
+ style=${styleMap({ transform: `translateY(${this.offsets[group.startIndex] ?? 0}px)` })}
552
+ >
553
+ ${group.label ?? String(group.key)}
554
+ </div>
555
+ `);
556
+ }
557
+ render() {
558
+ const n = this.items.length;
559
+ const totalHeight = this.offsets[n] ?? 0;
560
+ const windowed = [];
561
+ for (let i = this.renderStart; i <= this.renderEnd; i++) {
562
+ windowed.push({ item: this.items[i], index: i });
563
+ }
564
+ return html `
565
+ <div part="base" role="list" tabindex="0" aria-busy=${this.loading ? 'true' : nothing}>
566
+ <div part="spacer" style=${styleMap({ height: `${totalHeight}px` })}>
567
+ ${this.renderGroups()}
568
+ ${repeat(windowed, (w) => this.keyOf(w.item, w.index), (w) => this.renderRow(w.item, w.index, n))}
569
+ </div>
570
+ </div>
571
+ `;
572
+ }
573
+ }
574
+ __decorate([
575
+ property({ attribute: false })
576
+ ], LyraVirtualList.prototype, "items", void 0);
577
+ __decorate([
578
+ property({ attribute: false })
579
+ ], LyraVirtualList.prototype, "renderItem", void 0);
580
+ __decorate([
581
+ property({ attribute: false })
582
+ ], LyraVirtualList.prototype, "keyFunction", void 0);
583
+ __decorate([
584
+ property({ attribute: false })
585
+ ], LyraVirtualList.prototype, "groups", void 0);
586
+ __decorate([
587
+ property({ attribute: 'row-height' })
588
+ ], LyraVirtualList.prototype, "rowHeight", void 0);
589
+ __decorate([
590
+ property({ converter: overscanConverter })
591
+ ], LyraVirtualList.prototype, "overscan", void 0);
592
+ __decorate([
593
+ property({ attribute: 'active-id' })
594
+ ], LyraVirtualList.prototype, "activeId", void 0);
595
+ __decorate([
596
+ property({ type: Boolean, reflect: true })
597
+ ], LyraVirtualList.prototype, "loading", void 0);
598
+ __decorate([
599
+ property({ type: Boolean, attribute: 'has-more', reflect: true })
600
+ ], LyraVirtualList.prototype, "hasMore", void 0);
601
+ __decorate([
602
+ state()
603
+ ], LyraVirtualList.prototype, "containerScrollTop", void 0);
604
+ __decorate([
605
+ state()
606
+ ], LyraVirtualList.prototype, "viewportHeight", void 0);
607
+ defineElement('virtual-list', LyraVirtualList);
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,56 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ display: block;
5
+ /* Consumer-tunable viewport height, same pattern as --lyra-chart-height --
6
+ a virtualized list is meaningless without a bounded scroll extent, so
7
+ this ships a sane default rather than collapsing to 0 when a caller
8
+ forgets to size the host. */
9
+ --lyra-virtual-list-height: 24rem;
10
+ }
11
+ [part='base'] {
12
+ position: relative;
13
+ block-size: var(--lyra-virtual-list-height);
14
+ overflow-x: hidden;
15
+ overflow-y: auto;
16
+ /* A fast fling shouldn't also scroll the page behind this list once it
17
+ hits either end. */
18
+ overscroll-behavior: contain;
19
+ }
20
+ [part='base']:focus-visible {
21
+ outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
22
+ /* Negative (inward) so the ring isn't clipped by this element's own
23
+ overflow:auto -- an outward ring (every other component's convention)
24
+ would otherwise be cut off along the scrolling edges. */
25
+ outline-offset: calc(-1 * var(--lyra-focus-ring-offset));
26
+ }
27
+ [part='spacer'] {
28
+ position: relative;
29
+ inline-size: 100%;
30
+ }
31
+ [part='row'] {
32
+ position: absolute;
33
+ inset-inline-start: 0;
34
+ inset-block-start: 0;
35
+ inline-size: 100%;
36
+ box-sizing: border-box;
37
+ /* Every row's position updates via this transform on every scroll-driven
38
+ re-render -- hinting the compositor avoids a full repaint per frame. */
39
+ will-change: transform;
40
+ }
41
+ [part='group'] {
42
+ position: absolute;
43
+ inset-inline: 0;
44
+ inset-block-start: 0;
45
+ z-index: 1;
46
+ padding: var(--lyra-space-xs) var(--lyra-space-s);
47
+ background: var(--lyra-color-surface);
48
+ color: var(--lyra-color-text-quiet);
49
+ font-size: 0.875em;
50
+ font-weight: 600;
51
+ pointer-events: none;
52
+ }
53
+ :host([loading]) [part='base'] {
54
+ cursor: progress;
55
+ }
56
+ `;