@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,382 @@
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 { unsafeHTML } from 'lit/directives/unsafe-html.js';
10
+ import { LyraElement } from '../../internal/lyra-element.js';
11
+ import { defineElement } from '../../internal/prefix.js';
12
+ import { nextId } from '../../internal/a11y.js';
13
+ import { chevronIcon } from '../../internal/icons.js';
14
+ import { loadShikiHighlighter, loadShikiLanguage, loadShikiHighlighterCore, SHIKI_THEMES, } from './code-loader.js';
15
+ import { styles } from './code-block.styles.js';
16
+ import '../skeleton/skeleton.js';
17
+ /** How long the copy button's confirmation state lasts before reverting. */
18
+ const COPY_CONFIRM_MS = 1500;
19
+ /**
20
+ * Rewrites shiki's generated `<pre>`/`<code>` hast nodes so they carry this
21
+ * component's own `part="pre"`/`part="code"` hooks — the same single-pass
22
+ * "inject part attributes while rendering, not a second DOM walk after
23
+ * insertion" approach `<lyra-markdown>`'s renderer override uses, applied
24
+ * here via shiki's own transformer API instead of a custom marked renderer.
25
+ * Also strips shiki's own default `tabindex="0"` from the `<pre>` — this
26
+ * component's `[part="body"]` wrapper (see `render()`) is the single
27
+ * scrollable/focusable region for the code area, and leaving shiki's own
28
+ * tabindex in place would add a second, redundant tab stop over the same
29
+ * scrollable content.
30
+ */
31
+ const partTransformer = {
32
+ name: 'lyra-code-block-parts',
33
+ pre(node) {
34
+ node.properties.part = ['pre'];
35
+ delete node.properties.tabindex;
36
+ },
37
+ code(node) {
38
+ node.properties.part = ['code'];
39
+ },
40
+ };
41
+ /**
42
+ * `<lyra-code-block>` — fenced code display with optional lazy syntax
43
+ * highlighting and a copy button. No highlighting grammar ships in this
44
+ * component itself: it lazy-loads the optional peer dependency `shiki` (see
45
+ * `code-loader.ts`) for the actual tokenizing, and degrades to a plain
46
+ * `<pre><code>` when that peer isn't installed or `language` is unset/
47
+ * unrecognized — the exact same optional-peer shape `<lyra-markdown>` and
48
+ * `<lyra-chart>` already establish. That fallback is the *default* rendering
49
+ * path, not a degraded one: unhighlighted code is perfectly usable, and it's
50
+ * what every instance renders at zero extra bytes until shiki resolves.
51
+ *
52
+ * A `<lyra-skeleton>` placeholder stands in only while shiki itself is
53
+ * loading for the very first time on the page (cached — see
54
+ * `loadShikiHighlighter()`) and `language` is set. It's deliberately *not*
55
+ * shown again for a subsequent per-language grammar load (e.g. a second
56
+ * `<lyra-code-block>` requesting a language no earlier instance has used
57
+ * yet) — that grammar fetch is typically fast, and the plain-text fallback
58
+ * is already a perfectly readable placeholder for it, so a second
59
+ * loading-chrome state would add complexity for little practical benefit.
60
+ *
61
+ * `languages` is an additive, opt-in escape hatch from that default path for
62
+ * a consumer whose language set is fixed and known ahead of time: a map of
63
+ * language id to an already-imported shiki grammar module (e.g. `import bash
64
+ * from 'shiki/langs/bash.mjs'`). When `language` matches a key in `languages`,
65
+ * this component seeds a fine-grained `createHighlighterCore()` highlighter
66
+ * with *only* the pre-supplied grammars (see `code-loader.ts`'s
67
+ * `loadShikiHighlighterCore()`) instead of waiting on `loadShikiHighlighter()`
68
+ * and its dynamic per-language `loadLanguage()` import. The payoff isn't
69
+ * runtime cost — the default dynamic-import path is already well-optimized
70
+ * for that — it's *build output*: shiki's main entry point bundles a dynamic
71
+ * `import()` per bundled language (~200 of them) because a bundler can't
72
+ * statically narrow which of those a `loadLanguage(lang: string)` call might
73
+ * request at runtime, so it conservatively emits a build-output chunk for
74
+ * every one of them. `shiki/core`'s fine-grained API has no such table — a
75
+ * bundler only ever sees the exact grammar modules `languages` itself
76
+ * `import`s, so a consumer who pins its full language set this way trades a
77
+ * hand-maintained list for a build output scoped to just those languages
78
+ * instead of shiki's entire bundled set. A language requested but absent
79
+ * from `languages` still falls back to the ordinary dynamic-import path
80
+ * unchanged, so this is a partial opt-in, not a replacement for it.
81
+ *
82
+ * @customElement lyra-code-block
83
+ * @event lyra-copy - The copy button was activated. `detail: { text }` is
84
+ * always the raw `code` value (never the highlighted HTML), and always
85
+ * fires regardless of whether the actual OS clipboard write succeeded —
86
+ * same convention as `<lyra-json-viewer>`'s own copy button.
87
+ * @event lyra-toggle - The collapse/expand header button was activated.
88
+ * `detail: { collapsed }` — same event name and shape convention as
89
+ * `<lyra-thinking-panel>`'s own `lyra-toggle`.
90
+ * @csspart base - The outer container.
91
+ * @csspart header - The row above the code (filename/language/copy/toggle),
92
+ * present whenever there's anything to put in it.
93
+ * @csspart filename - The `filename` text, when set.
94
+ * @csspart language - The `language` badge, when set, so the language is
95
+ * exposed to assistive tech as visible text rather than only a `language`
96
+ * attribute a screen reader would never announce.
97
+ * @csspart copy-button - The copy-to-clipboard button, when `copyable`.
98
+ * @csspart toggle - The collapse/expand chevron button, when `collapsible`.
99
+ * @csspart body - The scrollable region wrapping the code (or the loading
100
+ * skeleton); respects `max-height`, `hidden` while `collapsible` and
101
+ * `collapsed`.
102
+ * @csspart pre - The rendered `<pre>` — shiki's own in the highlighted path,
103
+ * this component's own plain one in the fallback path.
104
+ * @csspart code - The rendered `<code>`, same split as `pre` above.
105
+ */
106
+ export class LyraCodeBlock extends LyraElement {
107
+ constructor() {
108
+ super(...arguments);
109
+ /** The raw source text. */
110
+ this.code = '';
111
+ /** A shiki-recognized language id or alias (e.g. `"javascript"`,
112
+ * `"python"`, `"json"`). When unset, or when shiki doesn't recognize it,
113
+ * the code renders as plain unhighlighted text regardless of whether
114
+ * shiki itself is available. */
115
+ this.language = '';
116
+ /** Shown in the header above the code, when set. */
117
+ this.filename = '';
118
+ /** Whether the code region can be collapsed via a header toggle. */
119
+ this.collapsible = false;
120
+ /** Whether the code region is currently hidden. Only has a visible effect
121
+ * while `collapsible` is also true. */
122
+ this.collapsed = false;
123
+ /** Shows a copy-to-clipboard button in the header. */
124
+ this.copyable = true;
125
+ /** A CSS length (e.g. `"20rem"`); once set, the code scrolls internally
126
+ * past this height instead of growing the page. */
127
+ this.maxHeight = '';
128
+ // `null` covers every reason the plain-text fallback is showing: shiki
129
+ // isn't installed, `language` is unset, or `language` isn't shiki-
130
+ // recognized -- `render()` doesn't need to (and can't usefully) tell these
131
+ // apart, same rationale as <lyra-markdown>'s identically-shaped field.
132
+ this.highlightedHtml = null;
133
+ // Becomes true once the shared shiki-loading promise has settled, whether
134
+ // or not it actually resolved to a highlighter -- gates the skeleton (see
135
+ // the class doc's second paragraph), not the highlighting itself.
136
+ this.shikiReady = false;
137
+ this.justCopied = false;
138
+ // Guards the async per-language load in syncHighlight() against a
139
+ // `code`/`language` change that arrives before a previous load resolves --
140
+ // only the result matching the *current* token is ever applied.
141
+ this.highlightToken = 0;
142
+ this.bodyId = nextId('code-block-body');
143
+ this.copy = () => {
144
+ this.writeClipboard(this.code);
145
+ this.emit('lyra-copy', { text: this.code });
146
+ this.justCopied = true;
147
+ clearTimeout(this.copyTimeoutId);
148
+ this.copyTimeoutId = setTimeout(() => {
149
+ this.justCopied = false;
150
+ }, COPY_CONFIRM_MS);
151
+ };
152
+ this.toggleCollapsed = () => {
153
+ this.collapsed = !this.collapsed;
154
+ this.emit('lyra-toggle', { collapsed: this.collapsed });
155
+ };
156
+ }
157
+ static { this.styles = [LyraElement.styles, styles]; }
158
+ connectedCallback() {
159
+ super.connectedCallback();
160
+ void loadShikiHighlighter().then((hl) => {
161
+ this.highlighter = hl;
162
+ this.shikiReady = true;
163
+ this.syncHighlight();
164
+ });
165
+ }
166
+ disconnectedCallback() {
167
+ super.disconnectedCallback();
168
+ clearTimeout(this.copyTimeoutId);
169
+ }
170
+ // The `languages` entry for the *current* `language`, if any -- shared by
171
+ // `willUpdate()`/`updated()`/`render()`/`syncHighlight()` so they all agree
172
+ // on whether this render is taking the fine-grained `languages` path or
173
+ // the default `loadShikiHighlighter()` one.
174
+ preSuppliedGrammar() {
175
+ return this.languages?.[this.language];
176
+ }
177
+ // Mutating `highlightedHtml` here (rather than in `updated()`) absorbs the
178
+ // synchronous case -- language already loaded, see `syncHighlight()` --
179
+ // into this same update cycle instead of scheduling a second one, Lit's
180
+ // documented pattern for deriving one reactive property from a change to
181
+ // others (same approach <lyra-markdown>'s `willUpdate` takes).
182
+ willUpdate(changed) {
183
+ if (!(changed.has('code') || changed.has('language') || changed.has('languages')))
184
+ return;
185
+ // The default path still waits on `shikiReady` (the shared
186
+ // `loadShikiHighlighter()` singleton), same as always. A `language`
187
+ // covered by `languages` doesn't need that singleton at all, so it can
188
+ // sync as soon as the relevant property actually changes, instead of
189
+ // waiting on an unrelated (and, for a `languages`-only consumer,
190
+ // possibly never-needed) full-bundle load to finish first.
191
+ if (this.shikiReady || this.preSuppliedGrammar()) {
192
+ this.syncHighlight();
193
+ }
194
+ }
195
+ updated() {
196
+ const showingSkeleton = !this.shikiReady && !!this.language && !this.preSuppliedGrammar();
197
+ if (showingSkeleton)
198
+ this.setAttribute('aria-busy', 'true');
199
+ else
200
+ this.removeAttribute('aria-busy');
201
+ }
202
+ syncHighlight() {
203
+ // Bumped unconditionally -- on *every* call, not just the async branch
204
+ // below -- so that a call landing on the synchronous already-loaded
205
+ // branch still invalidates any earlier in-flight load from a previous
206
+ // call. Without this, a load kicked off by an older call can resolve
207
+ // after a newer call has already rendered correct synchronous output,
208
+ // and overwrite it with stale tokenization.
209
+ const token = ++this.highlightToken;
210
+ const lang = this.language;
211
+ if (!lang) {
212
+ this.highlightedHtml = null;
213
+ return;
214
+ }
215
+ const languages = this.languages;
216
+ if (languages?.[lang]) {
217
+ // Fine-grained opt-in path -- entirely separate from `this.highlighter`
218
+ // below, see `loadShikiHighlighterCore()`'s doc comment for why.
219
+ this.highlightedHtml = null;
220
+ void loadShikiHighlighterCore(languages).then((hl) => {
221
+ if (token !== this.highlightToken)
222
+ return; // superseded by a newer code/language/languages change
223
+ this.highlightedHtml = hl ? this.tokenize(hl, lang) : null;
224
+ });
225
+ return;
226
+ }
227
+ const hl = this.highlighter;
228
+ if (!hl) {
229
+ this.highlightedHtml = null;
230
+ return;
231
+ }
232
+ if (hl.getLoadedLanguages().includes(lang)) {
233
+ this.highlightedHtml = this.tokenize(hl, lang);
234
+ return;
235
+ }
236
+ // Grammar not loaded yet -- show the plain-text fallback in the
237
+ // meantime rather than leaving a *previous* code/language value's stale
238
+ // highlighted markup on screen while this one loads.
239
+ this.highlightedHtml = null;
240
+ void loadShikiLanguage(hl, lang).then((ok) => {
241
+ if (token !== this.highlightToken)
242
+ return; // superseded by a newer code/language change
243
+ this.highlightedHtml = ok ? this.tokenize(hl, lang) : null;
244
+ });
245
+ }
246
+ tokenize(hl, lang) {
247
+ try {
248
+ return hl.codeToHtml(this.code, {
249
+ lang,
250
+ // shiki's generated per-token colors are theme-specific inline
251
+ // styles/CSS variables (from SHIKI_THEMES's github-light/github-dark
252
+ // theme data), not this library's --lyra-* design tokens -- the one
253
+ // deliberate exception to every other color in this component being
254
+ // a --lyra-* token. See the dark-mode override in
255
+ // code-block.styles.ts for how the dark half of this activates.
256
+ themes: SHIKI_THEMES,
257
+ transformers: [partTransformer],
258
+ });
259
+ }
260
+ catch {
261
+ // Malformed input for this grammar, or any other shiki-internal
262
+ // failure -- fall back to plain text rather than a blank code block.
263
+ return null;
264
+ }
265
+ }
266
+ writeClipboard(text) {
267
+ try {
268
+ // navigator.clipboard is absent in insecure contexts / older browsers,
269
+ // and some engines throw synchronously rather than rejecting -- either
270
+ // way this is best-effort; copy() below always emits lyra-copy
271
+ // regardless of whether the OS clipboard was actually reached. Same
272
+ // precedent as <lyra-json-viewer>'s own copy button.
273
+ void navigator.clipboard?.writeText(text)?.catch(() => { });
274
+ }
275
+ catch {
276
+ // see above
277
+ }
278
+ }
279
+ renderHeader() {
280
+ return html `
281
+ <div part="header">
282
+ ${this.collapsible
283
+ ? html `
284
+ <button
285
+ part="toggle"
286
+ type="button"
287
+ aria-expanded=${this.collapsed ? 'false' : 'true'}
288
+ aria-controls=${this.bodyId}
289
+ aria-label=${this.collapsed ? 'Expand code' : 'Collapse code'}
290
+ @click=${this.toggleCollapsed}
291
+ >
292
+ <span class="chevron" aria-hidden="true">${chevronIcon()}</span>
293
+ </button>
294
+ `
295
+ : nothing}
296
+ ${this.filename ? html `<span part="filename">${this.filename}</span>` : nothing}
297
+ ${this.language ? html `<span part="language">${this.language}</span>` : nothing}
298
+ ${this.copyable
299
+ ? html `
300
+ <button
301
+ part="copy-button"
302
+ type="button"
303
+ aria-label=${this.justCopied ? 'Copied to clipboard' : 'Copy code'}
304
+ @click=${this.copy}
305
+ >
306
+ ${this.justCopied ? 'Copied!' : 'Copy'}
307
+ </button>
308
+ `
309
+ : nothing}
310
+ </div>
311
+ `;
312
+ }
313
+ // `[part="body"]` is `tabindex="0"` because it's the scrollable region for
314
+ // arbitrarily-wide/tall code (max-height, plus horizontal overflow from
315
+ // long lines) -- a scrollable region with no other focusable content of
316
+ // its own is otherwise unreachable by keyboard, same reasoning
317
+ // lyra-virtual-list's own `[part="base"]` documents for its identical
318
+ // tabindex. `role="group"` (rather than e.g. `region`, a page landmark
319
+ // role) plus `aria-label` gives it an accessible name without claiming
320
+ // landmark/navigation significance for what is, structurally, just one
321
+ // small piece of a larger document.
322
+ render() {
323
+ const hasHeader = !!this.filename || !!this.language || this.copyable || this.collapsible;
324
+ const showSkeleton = !this.shikiReady && !!this.language && !this.preSuppliedGrammar();
325
+ const bodyHidden = this.collapsible && this.collapsed;
326
+ const bodyLabel = this.filename || (this.language ? `${this.language} code` : 'Code');
327
+ return html `
328
+ <div part="base">
329
+ ${hasHeader ? this.renderHeader() : nothing}
330
+ <div
331
+ part="body"
332
+ id=${this.bodyId}
333
+ role="group"
334
+ aria-label=${bodyLabel}
335
+ tabindex="0"
336
+ ?hidden=${bodyHidden}
337
+ style=${this.maxHeight ? `--lyra-code-block-max-height:${this.maxHeight}` : nothing}
338
+ >
339
+ ${showSkeleton
340
+ ? html `<lyra-skeleton variant="rect"></lyra-skeleton>`
341
+ : this.highlightedHtml !== null
342
+ ? unsafeHTML(this.highlightedHtml)
343
+ : html `<pre part="pre"><code part="code">${this.code}</code></pre>`}
344
+ </div>
345
+ </div>
346
+ `;
347
+ }
348
+ }
349
+ __decorate([
350
+ property()
351
+ ], LyraCodeBlock.prototype, "code", void 0);
352
+ __decorate([
353
+ property()
354
+ ], LyraCodeBlock.prototype, "language", void 0);
355
+ __decorate([
356
+ property()
357
+ ], LyraCodeBlock.prototype, "filename", void 0);
358
+ __decorate([
359
+ property({ type: Boolean, reflect: true })
360
+ ], LyraCodeBlock.prototype, "collapsible", void 0);
361
+ __decorate([
362
+ property({ type: Boolean, reflect: true })
363
+ ], LyraCodeBlock.prototype, "collapsed", void 0);
364
+ __decorate([
365
+ property({ type: Boolean, reflect: true })
366
+ ], LyraCodeBlock.prototype, "copyable", void 0);
367
+ __decorate([
368
+ property({ attribute: 'max-height' })
369
+ ], LyraCodeBlock.prototype, "maxHeight", void 0);
370
+ __decorate([
371
+ property({ attribute: false })
372
+ ], LyraCodeBlock.prototype, "languages", void 0);
373
+ __decorate([
374
+ state()
375
+ ], LyraCodeBlock.prototype, "highlightedHtml", void 0);
376
+ __decorate([
377
+ state()
378
+ ], LyraCodeBlock.prototype, "shikiReady", void 0);
379
+ __decorate([
380
+ state()
381
+ ], LyraCodeBlock.prototype, "justCopied", void 0);
382
+ defineElement('code-block', LyraCodeBlock);
@@ -0,0 +1 @@
1
+ export declare const styles: import("lit").CSSResult;
@@ -0,0 +1,187 @@
1
+ import { css } from 'lit';
2
+ export const styles = css `
3
+ :host {
4
+ display: block;
5
+ /* Consumer-tunable scroll cap -- 'none' means the block grows with its
6
+ content, matching every other block-level component in this library
7
+ until a caller opts in via the max-height attribute (same convention
8
+ as --lyra-json-viewer-max-height). */
9
+ --lyra-code-block-max-height: none;
10
+ /* Contained here rather than left as a bare font-family literal so a
11
+ host page can retheme it -- same rationale as --lyra-markdown-font-mono
12
+ and --lyra-json-viewer-font, no shared --wa-*/--lyra-* monospace token
13
+ exists to resolve through. */
14
+ --lyra-code-block-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
15
+ font-size: 0.8125rem;
16
+ }
17
+ [part='base'] {
18
+ border: 1px solid var(--lyra-color-border);
19
+ border-radius: var(--lyra-radius);
20
+ background: var(--lyra-color-surface);
21
+ overflow: hidden;
22
+ }
23
+ [part='header'] {
24
+ display: flex;
25
+ align-items: center;
26
+ gap: var(--lyra-space-xs);
27
+ padding: var(--lyra-space-xs) var(--lyra-space-s);
28
+ border-block-end: 1px solid var(--lyra-color-border);
29
+ /* --lyra-color-surface (not -brand-quiet) -- pairing
30
+ --lyra-color-text-quiet (the toggle/copy-button color below) against
31
+ --lyra-color-brand-quiet fails WCAG AA contrast in this token
32
+ palette; --lyra-color-surface is the same header background
33
+ lyra-json-viewer's own toolbar already uses with that same text
34
+ color. */
35
+ background: var(--lyra-color-surface);
36
+ font-family: var(--lyra-font);
37
+ }
38
+ [part='toggle'] {
39
+ /* Deliberately smaller than the shared --lyra-icon-button-size (2.5rem,
40
+ meant for a standalone icon-only button) -- this sits inline in a
41
+ dense header row, same reasoning as lyra-json-viewer's own toggle. */
42
+ inline-size: 1.25rem;
43
+ block-size: 1.25rem;
44
+ flex: 0 0 auto;
45
+ display: inline-flex;
46
+ align-items: center;
47
+ justify-content: center;
48
+ padding: 0;
49
+ border: none;
50
+ background: none;
51
+ color: var(--lyra-color-text-quiet);
52
+ border-radius: var(--lyra-radius);
53
+ cursor: pointer;
54
+ }
55
+ [part='toggle']:hover {
56
+ background: var(--lyra-color-brand-quiet);
57
+ color: var(--lyra-color-brand);
58
+ }
59
+ [part='toggle'] .chevron {
60
+ display: inline-flex;
61
+ transition: transform var(--lyra-transition-fast);
62
+ }
63
+ /* Chevron points at the content: rotated (pointing down) while expanded,
64
+ resting (pointing right) while collapsed -- same rotation direction as
65
+ lyra-thinking-panel's and lyra-json-viewer's own toggles. */
66
+ :host(:not([collapsed])) [part='toggle'] .chevron {
67
+ transform: rotate(90deg);
68
+ }
69
+ [part='filename'] {
70
+ flex: 1 1 auto;
71
+ min-inline-size: 0;
72
+ overflow: hidden;
73
+ text-overflow: ellipsis;
74
+ white-space: nowrap;
75
+ font-family: var(--lyra-code-block-font);
76
+ font-size: 0.75rem;
77
+ font-weight: 600;
78
+ color: var(--lyra-color-text);
79
+ }
80
+ [part='language'] {
81
+ flex: 0 0 auto;
82
+ padding: 0.0625rem 0.4375rem;
83
+ border-radius: 999px;
84
+ /* --lyra-color-brand + -brand-quiet (not -text-quiet + -surface) --
85
+ this pill needs to read as distinct from the [part="header"]
86
+ background it sits on (also -surface as of the comment above), and
87
+ -brand on -brand-quiet is a pairing already relied on elsewhere in
88
+ this library (e.g. hover states below) that passes contrast, unlike
89
+ -text-quiet on -brand-quiet. */
90
+ background: var(--lyra-color-brand-quiet);
91
+ color: var(--lyra-color-brand);
92
+ font-size: 0.6875rem;
93
+ line-height: 1.4;
94
+ text-transform: uppercase;
95
+ letter-spacing: 0.02em;
96
+ }
97
+ /* Pushed to the end of the header whether or not filename/language
98
+ precede it -- margin-inline-start:auto works whether this is the first
99
+ flex child (copyable alone) or the last of several. */
100
+ [part='copy-button'] {
101
+ flex: 0 0 auto;
102
+ margin-inline-start: auto;
103
+ border: none;
104
+ background: none;
105
+ color: var(--lyra-color-text-quiet);
106
+ font: inherit;
107
+ font-size: 0.75rem;
108
+ line-height: 1;
109
+ padding: 0.1875rem var(--lyra-space-xs);
110
+ border-radius: var(--lyra-radius);
111
+ cursor: pointer;
112
+ }
113
+ [part='copy-button']:hover {
114
+ background: var(--lyra-color-brand-quiet);
115
+ color: var(--lyra-color-brand);
116
+ }
117
+ [part='toggle']:focus-visible,
118
+ [part='copy-button']:focus-visible {
119
+ outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
120
+ outline-offset: var(--lyra-focus-ring-offset);
121
+ }
122
+ [part='body'] {
123
+ display: block;
124
+ max-block-size: var(--lyra-code-block-max-height);
125
+ overflow: auto;
126
+ }
127
+ [part='body'][hidden] {
128
+ display: none;
129
+ }
130
+ [part='body']:focus-visible {
131
+ outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
132
+ /* Negative (inward) so the ring isn't clipped by this element's own
133
+ overflow:auto -- same reasoning as lyra-virtual-list's [part="base"]. */
134
+ outline-offset: calc(-1 * var(--lyra-focus-ring-offset));
135
+ }
136
+ [part='body'] lyra-skeleton {
137
+ display: block;
138
+ padding: var(--lyra-space-s) var(--lyra-space-m);
139
+ --lyra-skeleton-w: 100%;
140
+ --lyra-skeleton-h: 8rem;
141
+ }
142
+ [part='pre'] {
143
+ margin: 0;
144
+ padding: var(--lyra-space-s) var(--lyra-space-m);
145
+ /* A default background so the plain-fallback path still reads as a
146
+ proper code block -- shiki's own inline background-color (part of the
147
+ generated-token-colors exception documented in code-block.ts's
148
+ tokenize()) silently overrides this the moment highlighting succeeds,
149
+ since an element's own style attribute always wins over an external
150
+ stylesheet rule at equal or lower specificity. */
151
+ background: var(--lyra-color-surface);
152
+ font-family: var(--lyra-code-block-font);
153
+ font-size: inherit;
154
+ line-height: 1.5;
155
+ white-space: pre;
156
+ }
157
+ [part='code'] {
158
+ font-family: inherit;
159
+ }
160
+ /*
161
+ * Activates shiki's "dual themes" dark variant. codeToHtml() (see
162
+ * tokenize() in code-block.ts) renders every token with its *light* color
163
+ * as a plain inline color/background-color and its *dark* color stashed in
164
+ * the --shiki-dark/--shiki-dark-bg custom properties shiki itself defines
165
+ * inline on the same elements -- shiki's own documented pattern for
166
+ * toggling them is exactly this: an external stylesheet rule that
167
+ * reassigns color/background-color from those variables. This requires
168
+ * !important because an inline style="..." attribute always outranks an
169
+ * external stylesheet at any selector specificity short of !important --
170
+ * there's no other way for a page-level rule to override an element's own
171
+ * style attribute. This is the one legitimate exception to "every color is
172
+ * a --lyra-* token" in this file: these values come from shiki's theme
173
+ * data, not this library's design tokens.
174
+ */
175
+ @media (prefers-color-scheme: dark) {
176
+ [part='pre'],
177
+ [part='pre'] span {
178
+ color: var(--shiki-dark, inherit) !important;
179
+ background-color: var(--shiki-dark-bg, transparent) !important;
180
+ }
181
+ }
182
+ @media (prefers-reduced-motion: reduce) {
183
+ [part='toggle'] .chevron {
184
+ transition: none !important;
185
+ }
186
+ }
187
+ `;
@@ -0,0 +1,87 @@
1
+ import type { Highlighter, BundledTheme, HighlighterCore, LanguageInput } from 'shiki';
2
+ /** Re-exported under a component-scoped name so importers don't need their
3
+ * own `import type { Highlighter } from 'shiki'`. */
4
+ export type ShikiHighlighter = Highlighter;
5
+ /** Re-exported under a component-scoped name — see `loadShikiHighlighterCore()`
6
+ * below. Structurally similar to `ShikiHighlighter` (both are
7
+ * `HighlighterGeneric<...>` instances providing `codeToHtml()` etc.) but
8
+ * typed with no bundled-language/theme keys of its own (`never`, since
9
+ * `createHighlighterCore()` has no built-in bundle to know about), which is
10
+ * why it's a distinct exported type rather than reusing `ShikiHighlighter`. */
11
+ export type ShikiHighlighterCore = HighlighterCore;
12
+ /** Re-exported under a component-scoped name — the shape of one pre-imported
13
+ * shiki grammar module's default export (e.g. `import bash from
14
+ * 'shiki/langs/bash.mjs'`), and what `<lyra-code-block>`'s `languages`
15
+ * property maps language ids to. See `loadShikiHighlighterCore()` below. */
16
+ export type ShikiLanguageInput = LanguageInput;
17
+ /**
18
+ * The two bundled themes every highlighter instance is seeded with, so a
19
+ * single `codeToHtml()` call can emit a light *and* dark rendering at once
20
+ * (shiki's "dual themes" feature — https://shiki.style/guide/dual-themes —
21
+ * rather than maintaining two separately-highlighted copies). `github-light`/
22
+ * `github-dark` are well-known, reasonably neutral, and already part of
23
+ * shiki's bundled theme set, so picking them costs no extra install. See the
24
+ * `prefers-color-scheme` block in `code-block.styles.ts` for how the dark
25
+ * variant actually activates.
26
+ */
27
+ export declare const SHIKI_LIGHT_THEME: BundledTheme;
28
+ export declare const SHIKI_DARK_THEME: BundledTheme;
29
+ /** Passed directly as `codeToHtml()`'s `themes` option — see `tokenize()` in `code-block.ts`. */
30
+ export declare const SHIKI_THEMES: Record<'light' | 'dark', BundledTheme>;
31
+ /**
32
+ * Lazily loads the optional peer dependency `shiki` once per page and builds
33
+ * (and caches) a single `Highlighter` instance seeded with `SHIKI_THEMES` and
34
+ * *zero* language grammars. Creating the highlighter — compiling its regex
35
+ * engine, parsing the seed themes — is the expensive part, not the dynamic
36
+ * `import()` itself, so the created instance is what's cached here rather
37
+ * than just the resolved module (one level deeper than `map-loader.ts`'s
38
+ * single-dependency cached-promise shape, which this otherwise mirrors).
39
+ * Resolves to `null` (with a one-time `console.warn`) if shiki isn't
40
+ * installed — `<lyra-code-block>` falls back to plain unhighlighted text in
41
+ * that case, which is a fully supported default, not a degraded mode. No
42
+ * language grammar is loaded up front; `loadShikiLanguage()` below loads each
43
+ * one incrementally the first time a `language` value actually requests it.
44
+ */
45
+ export declare function loadShikiHighlighter(): Promise<ShikiHighlighter | null>;
46
+ /**
47
+ * Ensures `lang` is loaded into `hl`, loading it on demand the first time
48
+ * it's requested rather than bundling every possible grammar up front —
49
+ * shiki supports this incrementally via `Highlighter.loadLanguage()`, which
50
+ * is what keeps this lazy instead of defeating the point of lazy-loading the
51
+ * peer at all. Resolves `false` (and remembers not to retry) when `lang`
52
+ * isn't a shiki-recognized grammar id or alias at all, so a caller can fall
53
+ * back to plain-text rendering instead of retrying an id that can never
54
+ * succeed on every future render.
55
+ */
56
+ export declare function loadShikiLanguage(hl: ShikiHighlighter, lang: string): Promise<boolean>;
57
+ /**
58
+ * Builds (and caches — see `highlighterCores` above) a fine-grained
59
+ * `HighlighterCore` seeded with `SHIKI_THEMES` and *only* the grammars in
60
+ * `languages`, via shiki's own "fine-grained bundle" recipe:
61
+ * `createHighlighterCore()` (`shiki/core`) plus an explicit oniguruma engine
62
+ * (`shiki/engine/oniguruma` + the `shiki/wasm` binary) instead of
63
+ * `loadShikiHighlighter()`'s `createHighlighter()` (plain `shiki`).
64
+ *
65
+ * The point isn't runtime cost — `loadShikiHighlighter()`'s per-language
66
+ * `loadLanguage()` dynamic import is already well-optimized for that (see its
67
+ * doc comment). It's *build output*: `shiki`'s main entry point (what
68
+ * `loadShikiHighlighter()` imports) bundles a lookup table of dynamic
69
+ * `import()` calls, one per shiki-supported language (~200 of them), because
70
+ * `loadLanguage(lang: string)` resolves that string against the table at
71
+ * runtime — a bundler can't statically narrow which of those ~200 entries a
72
+ * given app will ever actually request, so it conservatively emits a
73
+ * build-output chunk for every one of them. `shiki/core` has no such
74
+ * table — a bundler only ever sees the exact grammar modules a caller
75
+ * `import`s for `languages` itself, so a consumer with a known, fixed
76
+ * language set gets a build output scoped to just those languages instead of
77
+ * shiki's full bundled set.
78
+ *
79
+ * This is *only* ever consulted for languages present in `languages` — see
80
+ * `<lyra-code-block>`'s `syncHighlight()`. A language absent from it still
81
+ * falls back to the ordinary `loadShikiHighlighter()` + `loadShikiLanguage()`
82
+ * dynamic-import path entirely unchanged, so a caller can pin its own known
83
+ * set while still letting an unexpected language through. Resolves to `null`
84
+ * (with a one-time `console.warn`, same convention as `loadShikiHighlighter()`)
85
+ * if building the fine-grained highlighter fails for any reason.
86
+ */
87
+ export declare function loadShikiHighlighterCore(languages: Record<string, ShikiLanguageInput>): Promise<ShikiHighlighterCore | null>;