@aceshooting/lyra-ui 32.0.0 → 33.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (468) hide show
  1. package/CHANGELOG.md +224 -1380
  2. package/README.md +36 -7
  3. package/custom-elements.slim.json +1 -0
  4. package/design-tokens.json +1 -1
  5. package/dist/accent-roles.css +1 -0
  6. package/dist/all.d.ts +1 -1
  7. package/dist/all.js +1 -1
  8. package/dist/autoloader.d.ts +10 -0
  9. package/dist/autoloader.js +1 -1
  10. package/dist/cli/migrate-wa.mjs +54 -44
  11. package/dist/cli/migration-contract.json.gz +0 -0
  12. package/dist/components/agent-tools/budget-meter/budget-meter.class.d.ts +1 -0
  13. package/dist/components/agent-tools/budget-meter/budget-meter.styles.js +1 -1
  14. package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +1 -1
  15. package/dist/components/charts/chart/box-plot.class.d.ts +3 -0
  16. package/dist/components/charts/chart/chart-band.js +1 -1
  17. package/dist/components/charts/chart/chart-input-projection.js +1 -1
  18. package/dist/components/charts/chart/chart-surface.styles.js +1 -1
  19. package/dist/components/charts/chart/chart-types.d.ts +16 -2
  20. package/dist/components/charts/chart/chart.class.d.ts +4 -1
  21. package/dist/components/charts/chart/chart.class.js +3 -3
  22. package/dist/components/charts/chart/lite-chart.class.d.ts +3 -0
  23. package/dist/components/charts/chart/lite-chart.styles.js +1 -1
  24. package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +10 -0
  25. package/dist/components/conversation/code-block/code-block-base.class.d.ts +31 -3
  26. package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
  27. package/dist/components/conversation/code-block/code-block-core.class.d.ts +46 -2
  28. package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
  29. package/dist/components/conversation/code-block/code-block-shared.d.ts +6 -2
  30. package/dist/components/conversation/code-block/code-block-shared.js +5 -4
  31. package/dist/components/conversation/code-block/code-block.class.d.ts +48 -3
  32. package/dist/components/conversation/code-block/code-block.class.js +1 -1
  33. package/dist/components/conversation/code-block/code-block.styles.js +1 -1
  34. package/dist/components/conversation/code-block/code-grammar-registry.d.ts +35 -0
  35. package/dist/components/conversation/code-block/code-grammar-registry.js +1 -0
  36. package/dist/components/conversation/markdown/markdown-core.class.d.ts +12 -0
  37. package/dist/components/conversation/markdown/markdown.class.d.ts +12 -0
  38. package/dist/components/conversation/markdown/markdown.styles.js +1 -1
  39. package/dist/components/conversation/model-select/model-select.class.d.ts +12 -5
  40. package/dist/components/conversation/selection-toolbar/selection-toolbar.class.d.ts +1 -1
  41. package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +1 -0
  42. package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
  43. package/dist/components/conversation/thread-list/thread-list.class.d.ts +3 -0
  44. package/dist/components/conversation/thread-list/thread-list.styles.js +1 -1
  45. package/dist/components/conversation/usage-badge/usage-badge.class.d.ts +1 -1
  46. package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +12 -5
  47. package/dist/components/data/graph-query-builder/graph-query-builder.class.d.ts +4 -0
  48. package/dist/components/data/heatmap/heatmap.class.d.ts +21 -2
  49. package/dist/components/data/heatmap/heatmap.class.js +2 -2
  50. package/dist/components/data/heatmap/heatmap.styles.js +1 -1
  51. package/dist/components/data/stat/stat.class.d.ts +24 -1
  52. package/dist/components/data/stat/stat.class.js +2 -2
  53. package/dist/components/data/stat/stat.styles.js +1 -1
  54. package/dist/components/data/table/table-row-attributes.js +1 -0
  55. package/dist/components/data/table/table-support.d.ts +64 -5
  56. package/dist/components/data/table/table-support.js +1 -1
  57. package/dist/components/data/table/table.class.d.ts +78 -7
  58. package/dist/components/data/table/table.class.js +10 -10
  59. package/dist/components/data/table/table.styles.js +1 -1
  60. package/dist/components/data/timeline/timeline-item.class.d.ts +27 -5
  61. package/dist/components/data/timeline/timeline-item.class.js +11 -7
  62. package/dist/components/data/timeline/timeline-item.styles.js +1 -1
  63. package/dist/components/data/timeline/timeline.class.d.ts +54 -8
  64. package/dist/components/data/timeline/timeline.class.js +11 -7
  65. package/dist/components/data/timeline/timeline.styles.js +1 -1
  66. package/dist/components/data/tree/tree-item.class.d.ts +2 -0
  67. package/dist/components/data/tree/tree-item.class.js +2 -2
  68. package/dist/components/data/tree/tree-item.styles.js +1 -1
  69. package/dist/components/forms/button/button.class.d.ts +13 -0
  70. package/dist/components/forms/button/button.styles.js +1 -1
  71. package/dist/components/forms/catalog-picker-base.d.ts +14 -1
  72. package/dist/components/forms/checkbox/checkbox.class.js +1 -1
  73. package/dist/components/forms/checkbox-group/checkbox-group.class.d.ts +28 -2
  74. package/dist/components/forms/checkbox-group/checkbox-group.class.js +3 -3
  75. package/dist/components/forms/checkbox-group/checkbox-group.styles.js +1 -1
  76. package/dist/components/forms/code-editor/code-editor.class.d.ts +18 -3
  77. package/dist/components/forms/code-editor/code-editor.styles.js +1 -1
  78. package/dist/components/forms/color-picker/color-picker.class.d.ts +25 -5
  79. package/dist/components/forms/color-picker/color-picker.class.js +3 -3
  80. package/dist/components/forms/color-picker/color-picker.styles.js +1 -1
  81. package/dist/components/forms/combobox/combobox-option-html.js +1 -0
  82. package/dist/components/forms/combobox/combobox.class.d.ts +140 -12
  83. package/dist/components/forms/combobox/combobox.class.js +113 -22
  84. package/dist/components/forms/combobox/combobox.styles.js +1 -1
  85. package/dist/components/forms/country-picker/country-picker.class.d.ts +4 -3
  86. package/dist/components/forms/currency-picker/currency-picker.class.d.ts +4 -3
  87. package/dist/components/forms/date-picker/date-input.class.d.ts +53 -3
  88. package/dist/components/forms/date-picker/date-input.class.js +2 -2
  89. package/dist/components/forms/date-picker/date-input.styles.js +1 -1
  90. package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +14 -0
  91. package/dist/components/forms/emoji-picker/emoji-picker.class.js +1 -1
  92. package/dist/components/forms/icon-button/icon-button.class.d.ts +2 -1
  93. package/dist/components/forms/icon-button/icon-button.styles.js +1 -1
  94. package/dist/components/forms/input/input-shared.d.ts +24 -3
  95. package/dist/components/forms/input/input.styles.js +1 -1
  96. package/dist/components/forms/input/time-input.class.d.ts +19 -4
  97. package/dist/components/forms/input/time-input.styles.js +1 -1
  98. package/dist/components/forms/locale-picker/locale-picker.class.d.ts +17 -5
  99. package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
  100. package/dist/components/forms/otp-input/otp-input.class.d.ts +8 -3
  101. package/dist/components/forms/otp-input/otp-input.styles.js +1 -1
  102. package/dist/components/forms/phone-input/phone-input.class.d.ts +18 -3
  103. package/dist/components/forms/phone-input/phone-input.styles.js +1 -1
  104. package/dist/components/forms/radio/radio-group.class.d.ts +23 -2
  105. package/dist/components/forms/radio/radio-group.class.js +2 -2
  106. package/dist/components/forms/radio/radio-group.styles.js +1 -1
  107. package/dist/components/forms/radio/radio.class.js +2 -2
  108. package/dist/components/forms/rubric-form/rubric-form.class.d.ts +4 -0
  109. package/dist/components/forms/select/select.class.d.ts +16 -4
  110. package/dist/components/forms/select/select.class.js +1 -1
  111. package/dist/components/forms/select/select.styles.js +1 -1
  112. package/dist/components/forms/signature-pad/signature-pad.class.d.ts +8 -3
  113. package/dist/components/forms/signature-pad/signature-pad.styles.js +1 -1
  114. package/dist/components/forms/slider/slider.class.d.ts +29 -2
  115. package/dist/components/forms/slider/slider.class.js +3 -3
  116. package/dist/components/forms/slider/slider.styles.js +1 -1
  117. package/dist/components/forms/switch/switch.class.d.ts +2 -0
  118. package/dist/components/forms/switch/switch.styles.js +1 -1
  119. package/dist/components/forms/textarea/textarea.class.d.ts +20 -3
  120. package/dist/components/forms/textarea/textarea.styles.js +1 -1
  121. package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +4 -3
  122. package/dist/components/forms/token-input/token-input.class.d.ts +99 -21
  123. package/dist/components/forms/token-input/token-input.class.js +11 -8
  124. package/dist/components/forms/token-input/token-input.styles.js +1 -1
  125. package/dist/components/forms/unit-picker/unit-picker.class.d.ts +4 -3
  126. package/dist/components/layout/app-rail/app-rail.class.d.ts +3 -0
  127. package/dist/components/layout/app-rail/app-rail.styles.js +1 -1
  128. package/dist/components/layout/button-group/button-group.class.d.ts +4 -0
  129. package/dist/components/layout/button-group/button-group.class.js +1 -1
  130. package/dist/components/layout/card/card.class.d.ts +15 -1
  131. package/dist/components/layout/card/card.styles.js +1 -1
  132. package/dist/components/layout/command-palette/command-palette.class.d.ts +1 -1
  133. package/dist/components/layout/details/details.class.d.ts +6 -0
  134. package/dist/components/layout/details/details.styles.js +1 -1
  135. package/dist/components/layout/filter-bar/filter-bar.class.d.ts +6 -0
  136. package/dist/components/layout/filter-bar/filter-bar.styles.js +1 -1
  137. package/dist/components/layout/index.d.ts +1 -1
  138. package/dist/components/layout/index.js +1 -1
  139. package/dist/components/layout/menu/dropdown-item.class.d.ts +8 -2
  140. package/dist/components/layout/menu/dropdown-item.class.js +1 -1
  141. package/dist/components/layout/menu/menu-item.class.d.ts +7 -0
  142. package/dist/components/layout/menu/menu-item.styles.js +1 -1
  143. package/dist/components/layout/menu/menu-label.class.d.ts +5 -0
  144. package/dist/components/layout/menu/menu-label.class.js +1 -1
  145. package/dist/components/layout/menu/menu.class.d.ts +4 -1
  146. package/dist/components/layout/menu/menu.styles.js +1 -1
  147. package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.d.ts +1 -1
  148. package/dist/components/layout/page/page.class.d.ts +9 -1
  149. package/dist/components/layout/page/page.class.js +2 -2
  150. package/dist/components/layout/segmented/segmented.class.d.ts +22 -3
  151. package/dist/components/layout/segmented/segmented.class.js +3 -4
  152. package/dist/components/layout/segmented/segmented.styles.js +1 -1
  153. package/dist/components/layout/stepper/step.class.d.ts +102 -0
  154. package/dist/components/layout/stepper/step.class.js +18 -0
  155. package/dist/components/layout/stepper/step.styles.js +1 -0
  156. package/dist/components/layout/stepper/stepper.class.d.ts +106 -13
  157. package/dist/components/layout/stepper/stepper.class.js +6 -2
  158. package/dist/components/layout/stepper/stepper.styles.js +1 -1
  159. package/dist/components/layout/tab-group/tab-group.class.d.ts +10 -1
  160. package/dist/components/layout/tab-group/tab-group.class.js +1 -1
  161. package/dist/components/layout/tab-group/tab-group.styles.js +1 -1
  162. package/dist/components/layout/tab-group/tab-panel.class.d.ts +1 -0
  163. package/dist/components/layout/tab-group/tab-panel.class.js +1 -1
  164. package/dist/components/layout/tab-group/tab.class.d.ts +4 -0
  165. package/dist/components/layout/widget/widget.class.d.ts +1 -0
  166. package/dist/components/layout/widget/widget.styles.js +1 -1
  167. package/dist/components/lr-code-block-core.d.ts +1 -1
  168. package/dist/components/lr-code-block.d.ts +1 -1
  169. package/dist/components/lr-counter.d.ts +1 -0
  170. package/dist/components/lr-counter.js +1 -0
  171. package/dist/components/lr-lightbox-item.d.ts +1 -0
  172. package/dist/components/lr-lightbox-item.js +1 -0
  173. package/dist/components/lr-lightbox.d.ts +1 -1
  174. package/dist/components/lr-lightbox.js +1 -1
  175. package/dist/components/lr-number-ticker.d.ts +1 -0
  176. package/dist/components/lr-number-ticker.js +1 -0
  177. package/dist/components/lr-step.d.ts +1 -0
  178. package/dist/components/lr-step.js +1 -0
  179. package/dist/components/media/file-input/file-input.class.d.ts +8 -1
  180. package/dist/components/media/file-input/file-input.class.js +2 -2
  181. package/dist/components/media/file-input/file-input.styles.js +1 -1
  182. package/dist/components/media/index.d.ts +1 -1
  183. package/dist/components/media/index.js +1 -1
  184. package/dist/components/media/lightbox/lightbox-item.class.d.ts +67 -0
  185. package/dist/components/media/lightbox/lightbox-item.class.js +9 -0
  186. package/dist/components/media/lightbox/lightbox-item.styles.js +1 -0
  187. package/dist/components/media/lightbox/lightbox-source.js +1 -1
  188. package/dist/components/media/lightbox/lightbox-types.d.ts +4 -1
  189. package/dist/components/media/lightbox/lightbox.class.d.ts +123 -30
  190. package/dist/components/media/lightbox/lightbox.class.js +18 -12
  191. package/dist/components/media/lightbox/lightbox.styles.js +1 -1
  192. package/dist/components/media/map/map-anchor-avoid.js +1 -1
  193. package/dist/components/media/map/map-drawing-controller.js +1 -1
  194. package/dist/components/media/map/map.class.d.ts +137 -7
  195. package/dist/components/media/map/map.class.js +6 -6
  196. package/dist/components/media/map/map.styles.js +1 -1
  197. package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +9 -0
  198. package/dist/components/media/sequence-playback/sequence-playback.class.js +2 -2
  199. package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
  200. package/dist/components/media/video/video.class.d.ts +4 -0
  201. package/dist/components/media/video/video.class.js +2 -2
  202. package/dist/components/media/video/video.styles.js +1 -1
  203. package/dist/components/media/zoomable-frame/zoomable-frame.class.d.ts +15 -0
  204. package/dist/components/media/zoomable-frame/zoomable-frame.class.js +2 -2
  205. package/dist/components/overlays/badge/badge.class.d.ts +2 -0
  206. package/dist/components/overlays/badge/badge.styles.js +1 -1
  207. package/dist/components/overlays/badge/tag.class.d.ts +2 -0
  208. package/dist/components/overlays/badge/tag.class.js +1 -1
  209. package/dist/components/overlays/chip/chip-group.class.d.ts +31 -4
  210. package/dist/components/overlays/chip/chip-group.class.js +3 -3
  211. package/dist/components/overlays/context-menu/context-menu.class.d.ts +6 -1
  212. package/dist/components/overlays/context-menu/context-menu.class.js +1 -1
  213. package/dist/components/overlays/dialog/dialog.class.d.ts +54 -6
  214. package/dist/components/overlays/dialog/dialog.class.js +3 -3
  215. package/dist/components/overlays/dialog/dialog.styles.js +1 -1
  216. package/dist/components/overlays/dialog/prompt.d.ts +60 -0
  217. package/dist/components/overlays/dialog/prompt.js +1 -0
  218. package/dist/components/overlays/drawer/drawer.class.d.ts +22 -1
  219. package/dist/components/overlays/drawer/drawer.class.js +1 -1
  220. package/dist/components/overlays/empty/empty.class.d.ts +1 -0
  221. package/dist/components/overlays/empty/empty.class.js +1 -1
  222. package/dist/components/overlays/overlay/dropdown.class.d.ts +5 -1
  223. package/dist/components/overlays/overlay/dropdown.class.js +1 -1
  224. package/dist/components/overlays/overlay/overlay.styles.js +1 -1
  225. package/dist/components/overlays/overlay/popover.class.d.ts +30 -4
  226. package/dist/components/overlays/overlay/popover.class.js +2 -2
  227. package/dist/components/overlays/overlay/tooltip.class.d.ts +7 -0
  228. package/dist/components/overlays/overlay/tooltip.class.js +4 -4
  229. package/dist/components/overlays/toast/toast-item.class.d.ts +3 -2
  230. package/dist/components/overlays/toast/toast-item.class.js +1 -1
  231. package/dist/components/overlays/toast/toast-item.styles.js +1 -1
  232. package/dist/components/overlays/toast/toast.class.d.ts +6 -0
  233. package/dist/components/overlays/toast/toast.class.js +1 -1
  234. package/dist/components/retrieval/citation-badge/citation-badge.class.d.ts +1 -1
  235. package/dist/components/retrieval/entity-chip/entity-chip.class.d.ts +1 -1
  236. package/dist/components/utility/copy-button/copy-button.class.d.ts +4 -1
  237. package/dist/components/utility/copy-button/copy-button.class.js +2 -2
  238. package/dist/components/utility/counter/counter-time.d.ts +15 -0
  239. package/dist/components/utility/counter/counter-time.js +1 -0
  240. package/dist/components/utility/counter/counter.class.d.ts +67 -0
  241. package/dist/components/utility/counter/counter.class.js +1 -0
  242. package/dist/components/utility/counter/counter.styles.js +1 -0
  243. package/dist/components/utility/divider/divider.class.d.ts +21 -3
  244. package/dist/components/utility/divider/divider.class.js +5 -1
  245. package/dist/components/utility/export-button/export-button.class.d.ts +6 -1
  246. package/dist/components/utility/export-button/export-button.styles.js +1 -1
  247. package/dist/components/utility/icon/icon-library-bootstrap.d.ts +50 -0
  248. package/dist/components/utility/icon/icon-library-bootstrap.js +1 -0
  249. package/dist/components/utility/icon/icon-library-font-awesome.d.ts +68 -0
  250. package/dist/components/utility/icon/icon-library-font-awesome.js +1 -0
  251. package/dist/components/utility/icon/icon-library.d.ts +14 -1
  252. package/dist/components/utility/icon/icon-library.js +1 -1
  253. package/dist/components/utility/icon/icon-sprite.js +1 -0
  254. package/dist/components/utility/icon/icon.class.d.ts +4 -2
  255. package/dist/components/utility/icon/icon.class.js +2 -2
  256. package/dist/components/utility/index.d.ts +1 -1
  257. package/dist/components/utility/index.js +1 -1
  258. package/dist/components/utility/known-date/known-date.class.d.ts +14 -0
  259. package/dist/components/utility/mention-popover/mention-popover.class.d.ts +1 -1
  260. package/dist/components/utility/number-ticker/number-ticker.class.d.ts +66 -0
  261. package/dist/components/utility/number-ticker/number-ticker.class.js +1 -0
  262. package/dist/components/utility/number-ticker/number-ticker.styles.js +1 -0
  263. package/dist/components/utility/tour/tour.class.d.ts +1 -1
  264. package/dist/components/viewers/include/include.class.d.ts +4 -1
  265. package/dist/components/viewers/include/include.class.js +1 -1
  266. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +10 -1
  267. package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
  268. package/dist/components/viewers/pdf-viewer/pdf-viewer.styles.js +1 -1
  269. package/dist/custom-elements-jsx.d.ts +1 -1
  270. package/dist/event-classes.d.ts +2342 -0
  271. package/dist/event-classes.js +1 -0
  272. package/dist/events.d.ts +48 -22
  273. package/dist/framework-types.d.ts +2 -2
  274. package/dist/internal/accessibility-visibility.js +1 -1
  275. package/dist/internal/all-defined-arguments.d.ts +19 -0
  276. package/dist/internal/all-defined-arguments.js +1 -0
  277. package/dist/internal/autoloader-manifest.js +1 -1
  278. package/dist/internal/autoloader-tags.d.ts +1 -1
  279. package/dist/internal/autoloader-tags.js +1 -1
  280. package/dist/internal/checked-control-label.js +1 -1
  281. package/dist/internal/component-loaders.generated.js +1 -1
  282. package/dist/internal/declarative-overlay-action.js +1 -0
  283. package/dist/internal/dedent.js +7 -0
  284. package/dist/internal/default-strings/forms.generated.js +1 -1
  285. package/dist/internal/default-strings/layout.generated.js +1 -1
  286. package/dist/internal/dev-mode-attribute-warning.development.js +1 -1
  287. package/dist/internal/document-token-css.generated.js +10 -0
  288. package/dist/internal/document-tokens.generated.js +2 -11
  289. package/dist/internal/document-tokens.js +2 -2
  290. package/dist/internal/dom-guards.js +1 -1
  291. package/dist/internal/external-label-association.js +1 -0
  292. package/dist/internal/focus-navigation.js +1 -1
  293. package/dist/internal/form-control/chrome.styles.js +1 -1
  294. package/dist/internal/form-control-labels.js +1 -1
  295. package/dist/internal/form-control.styles.js +1 -1
  296. package/dist/internal/interactive-control.styles.js +2 -2
  297. package/dist/internal/labeled-group.js +1 -1
  298. package/dist/internal/localization-runtime.d.ts +5 -0
  299. package/dist/internal/localization-runtime.js +1 -1
  300. package/dist/internal/localization-types.d.ts +1 -1
  301. package/dist/internal/localization.js +2 -2
  302. package/dist/internal/lyra-element.d.ts +11 -2
  303. package/dist/internal/lyra-element.js +2 -2
  304. package/dist/internal/lyra-event.d.ts +22 -0
  305. package/dist/internal/lyra-event.js +1 -0
  306. package/dist/internal/overlay-shared.d.ts +5 -2
  307. package/dist/internal/overlay-shared.js +1 -1
  308. package/dist/internal/package-metadata.js +1 -1
  309. package/dist/internal/root-registration-allowlist.js +1 -1
  310. package/dist/internal/scoped-definitions.generated.js +1 -1
  311. package/dist/internal/shiki/core.d.ts +4 -1
  312. package/dist/internal/shiki/tokenize.js +1 -1
  313. package/dist/internal/srcset.js +1 -0
  314. package/dist/internal/theme-observation.js +1 -1
  315. package/dist/lyra.d.ts +1 -1
  316. package/dist/lyra.js +1 -1
  317. package/dist/ssr/all.d.ts +1 -1
  318. package/dist/ssr/all.js +1 -1
  319. package/dist/ssr.d.ts +5 -5
  320. package/dist/ssr.js +1 -1
  321. package/dist/styles/native.css +1 -1
  322. package/dist/styles/palette.css +1 -0
  323. package/dist/styles/tokens-root.css +1 -1
  324. package/dist/styles/utilities.css +1 -1
  325. package/dist/svelte.d.ts +1 -1
  326. package/dist/testing/happy-dom-shims.d.ts +11 -2
  327. package/dist/testing/happy-dom-shims.js +1 -1
  328. package/dist/testing/index.d.ts +1 -1
  329. package/dist/testing/index.js +1 -1
  330. package/dist/testing/lyra-tag-event-map.d.ts +2 -2
  331. package/dist/testing/lyra-tag-event-map.js +1 -1
  332. package/dist/theme-core.css +1 -1
  333. package/dist/theme.css +1 -1
  334. package/dist/utilities/defined.d.ts +10 -1
  335. package/dist/utilities/defined.js +1 -1
  336. package/dist/utilities/form.d.ts +9 -0
  337. package/dist/utilities/form.js +1 -0
  338. package/dist/utilities/index.d.ts +1 -1
  339. package/dist/utilities/index.js +1 -1
  340. package/dist/vue.d.ts +1 -1
  341. package/llms/components/lr-app-rail.md +4 -2
  342. package/llms/components/lr-badge.md +4 -4
  343. package/llms/components/lr-bar-chart.md +1 -1
  344. package/llms/components/lr-box-plot.md +6 -1
  345. package/llms/components/lr-bubble-chart.md +1 -1
  346. package/llms/components/lr-budget-meter.md +2 -2
  347. package/llms/components/lr-button-group.md +7 -3
  348. package/llms/components/lr-button.md +11 -1
  349. package/llms/components/lr-card.md +11 -1
  350. package/llms/components/lr-chart.md +21 -7
  351. package/llms/components/lr-checkbox-group.md +11 -1
  352. package/llms/components/lr-chip.md +11 -1
  353. package/llms/components/lr-citation-badge.md +1 -1
  354. package/llms/components/lr-code-block-core.md +39 -9
  355. package/llms/components/lr-code-block.md +59 -6
  356. package/llms/components/lr-code-editor.md +11 -1
  357. package/llms/components/lr-color-picker.md +19 -6
  358. package/llms/components/lr-combobox.md +81 -9
  359. package/llms/components/lr-context-menu.md +6 -4
  360. package/llms/components/lr-copy-button.md +6 -4
  361. package/llms/components/lr-counter.md +60 -0
  362. package/llms/components/lr-country-picker.md +4 -0
  363. package/llms/components/lr-currency-picker.md +4 -0
  364. package/llms/components/lr-date-input.md +1 -1
  365. package/llms/components/lr-date-picker.md +25 -1
  366. package/llms/components/lr-details.md +6 -2
  367. package/llms/components/lr-dialog.md +101 -9
  368. package/llms/components/lr-divider.md +14 -5
  369. package/llms/components/lr-doughnut-chart.md +1 -1
  370. package/llms/components/lr-drawer.md +32 -7
  371. package/llms/components/lr-dropdown-item.md +1 -1
  372. package/llms/components/lr-dropdown.md +8 -4
  373. package/llms/components/lr-emoji-picker.md +10 -1
  374. package/llms/components/lr-empty.md +3 -2
  375. package/llms/components/lr-entity-chip.md +1 -1
  376. package/llms/components/lr-export-button.md +6 -3
  377. package/llms/components/lr-file-input.md +13 -1
  378. package/llms/components/lr-filter-bar.md +6 -2
  379. package/llms/components/lr-graph-query-builder.md +10 -1
  380. package/llms/components/lr-heatmap.md +20 -3
  381. package/llms/components/lr-histogram.md +7 -2
  382. package/llms/components/lr-icon-button.md +3 -1
  383. package/llms/components/lr-icon.md +104 -0
  384. package/llms/components/lr-include.md +3 -0
  385. package/llms/components/lr-input.md +9 -1
  386. package/llms/components/lr-known-date.md +10 -1
  387. package/llms/components/lr-lightbox-item.md +14 -0
  388. package/llms/components/lr-lightbox.md +119 -14
  389. package/llms/components/lr-line-chart.md +7 -2
  390. package/llms/components/lr-lite-chart.md +3 -2
  391. package/llms/components/lr-locale-picker.md +17 -1
  392. package/llms/components/lr-map.md +122 -11
  393. package/llms/components/lr-markdown-core.md +15 -4
  394. package/llms/components/lr-markdown.md +13 -4
  395. package/llms/components/lr-mention-popover.md +1 -1
  396. package/llms/components/lr-menu-item.md +1 -1
  397. package/llms/components/lr-menu-label.md +5 -2
  398. package/llms/components/lr-menu.md +22 -7
  399. package/llms/components/lr-model-select.md +13 -3
  400. package/llms/components/lr-native-time-input.md +11 -1
  401. package/llms/components/lr-number-input.md +11 -1
  402. package/llms/components/lr-number-ticker.md +60 -0
  403. package/llms/components/lr-otp-input.md +11 -1
  404. package/llms/components/lr-page.md +7 -1
  405. package/llms/components/lr-pagination.md +18 -0
  406. package/llms/components/lr-pdf-viewer.md +6 -1
  407. package/llms/components/lr-phone-input.md +11 -1
  408. package/llms/components/lr-pie-chart.md +1 -1
  409. package/llms/components/lr-polar-area-chart.md +1 -1
  410. package/llms/components/lr-popover.md +26 -6
  411. package/llms/components/lr-radar-chart.md +1 -1
  412. package/llms/components/lr-radio-group.md +11 -1
  413. package/llms/components/lr-rubric-form.md +7 -1
  414. package/llms/components/lr-scatter-chart.md +1 -1
  415. package/llms/components/lr-segmented.md +20 -2
  416. package/llms/components/lr-select.md +11 -3
  417. package/llms/components/lr-selection-toolbar.md +1 -1
  418. package/llms/components/lr-sequence-playback.md +8 -2
  419. package/llms/components/lr-signature-pad.md +8 -1
  420. package/llms/components/lr-slider.md +17 -4
  421. package/llms/components/lr-stat.md +20 -5
  422. package/llms/components/lr-step.md +67 -0
  423. package/llms/components/lr-stepper.md +64 -8
  424. package/llms/components/lr-suggestion-chips.md +3 -2
  425. package/llms/components/lr-switch.md +4 -3
  426. package/llms/components/lr-tab-group.md +10 -3
  427. package/llms/components/lr-tab-panel.md +2 -2
  428. package/llms/components/lr-table.md +87 -8
  429. package/llms/components/lr-tag.md +1 -1
  430. package/llms/components/lr-textarea.md +17 -1
  431. package/llms/components/lr-thread-list.md +4 -2
  432. package/llms/components/lr-time-input.md +9 -2
  433. package/llms/components/lr-time-zone-picker.md +4 -0
  434. package/llms/components/lr-timeline-item.md +1 -1
  435. package/llms/components/lr-timeline.md +47 -3
  436. package/llms/components/lr-toast-item.md +1 -1
  437. package/llms/components/lr-toast.md +8 -3
  438. package/llms/components/lr-token-input.md +68 -11
  439. package/llms/components/lr-tool-call-chip.md +1 -1
  440. package/llms/components/lr-tooltip.md +8 -3
  441. package/llms/components/lr-tree-item.md +1 -1
  442. package/llms/components/lr-tree.md +2 -1
  443. package/llms/components/lr-unit-picker.md +4 -0
  444. package/llms/components/lr-usage-badge.md +1 -1
  445. package/llms/components/lr-video.md +5 -4
  446. package/llms/components/lr-voice-picker.md +10 -2
  447. package/llms/components/lr-widget.md +2 -2
  448. package/llms/components/lr-zoomable-frame.md +8 -0
  449. package/llms/index.md +205 -201
  450. package/llms/migration.md +103 -16
  451. package/llms/peers.md +3 -3
  452. package/llms/shared/events-and-types.md +36 -0
  453. package/llms/shared/forms-and-accessibility.md +4 -1
  454. package/llms/shared/frameworks-and-ssr.md +10 -1
  455. package/llms/shared/imports-and-registration.md +68 -2
  456. package/llms/shared/localization-and-rtl.md +5 -0
  457. package/llms/shared/native-styles-and-utilities.md +142 -7
  458. package/llms/shared/styles-and-tokens.md +60 -6
  459. package/llms/shared/testing-and-utilities.md +30 -0
  460. package/llms/shared.md +354 -17
  461. package/llms/tokens.md +6 -1
  462. package/llms.txt +3 -3
  463. package/locales.json +1 -1
  464. package/package.json +48 -10
  465. package/registrations.json +1 -1
  466. package/skills/compose-lyra-interfaces/SKILL.md +1 -1
  467. package/skills/lyra-ui/SKILL.md +1 -1
  468. package/skills/lyra-ui/commands/migrate.md +1 -1
@@ -134,6 +134,16 @@ export type ChatComposerToolbarAlign='start'|'end';export interface LyraChatComp
134
134
  * entirely to a consumer-drawn wrapper -- chosen over a third `frame` value, since every other
135
135
  * piece of this card's paint (background/border-color/radius above) is already a cssprop hook
136
136
  * rather than a `frame` variant, and `none` already reads naturally as "I'll draw my own".
137
+ * @cssstate required - Matches while `required` is set. Style with `lr-chat-composer:state(required)`.
138
+ * @cssstate optional - Matches while `required` is not set — the complement of `required`.
139
+ * @cssstate valid - Matches while the control satisfies its constraints, including any
140
+ * `setCustomValidity()` error. Never matches while disabled or readonly.
141
+ * @cssstate invalid - Matches while it does not — from the very first render, before the user has
142
+ * touched anything. Never matches while disabled or readonly.
143
+ * @cssstate user-valid - `valid`, but only after the user has interacted: an edit, a blur,
144
+ * `reportValidity()`, or a submission attempt.
145
+ * @cssstate user-invalid - `invalid` after that same interaction. Style validation errors with this
146
+ * rather than `invalid`, so a pristine required field is not painted red before the user acts.
137
147
  * @status stable
138
148
  * @since 4.0.0
139
149
  */
@@ -1,18 +1,46 @@
1
1
  import type{PropertyValues,TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraHighlight,LyraAnchor,TextSelectRect}from'../../../internal/document-anchors.js';import{type ShikiHighlighter}from'./shiki-types.js';import{CodeBlockInteractionController}from'./code-block-shared.js';import type{LyraClipboardWriteFailure,LyraClipboardWriteSuccess}from'../../../internal/clipboard.js';import type{LyraCodeBlockCopyAppearance,LyraCodeBlockToggleDetail}from'./code-block-shared.js';
2
+ /** Payload of `lr-load`: whether the code was highlighted (`true`) or no grammar exists for the
3
+ * current `language` and the code renders as plain text (`false`). */
4
+ export interface LyraCodeBlockLoadDetail{highlighted:boolean;}
2
5
  /** Shared event contract retained by both public event-map names.*/
3
- export interface LyraCodeBlockBaseEventMap{'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-error':CustomEvent<null>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;'lr-toggle-request':CustomEvent<LyraCodeBlockToggleDetail>;'lr-toggle':CustomEvent<LyraCodeBlockToggleDetail>;'lr-line-activate':CustomEvent<{line:number;}>;'lr-text-select':CustomEvent<{readonly text:string;readonly anchor:LyraAnchor;readonly rects:readonly TextSelectRect[];}>;}
6
+ export interface LyraCodeBlockBaseEventMap{'lr-copy':CustomEvent<LyraClipboardWriteSuccess>;'lr-error':CustomEvent<null>;'lr-load':CustomEvent<LyraCodeBlockLoadDetail>;'lr-copy-error':CustomEvent<LyraClipboardWriteFailure>;'lr-toggle-request':CustomEvent<LyraCodeBlockToggleDetail>;'lr-toggle':CustomEvent<LyraCodeBlockToggleDetail>;'lr-line-activate':CustomEvent<{line:number;}>;'lr-text-select':CustomEvent<{readonly text:string;readonly anchor:LyraAnchor;readonly rects:readonly TextSelectRect[];}>;}
4
7
  /** Owns the shared behavior and template for the regular and build-lean code blocks.
5
8
  * Subclasses supply their optional-peer loading policy and retain decorated public properties. */
6
9
  export declare abstract class LyraCodeBlockBase extends LyraElement<LyraCodeBlockBaseEventMap>{protected static collectionSupport:import("../../../internal/lyra-element.js").LyraCollectionSupport;protected static readonly immutableEventDetails:readonly string[];abstract code:string;abstract language:string;abstract filename:string;abstract accessibleLabel:string|null;abstract collapsible:boolean;abstract withoutCopyButton:boolean;abstract copyAppearance:LyraCodeBlockCopyAppearance;abstract maxHeight:string;abstract lineNumbers:boolean;abstract highlightLines:string;abstract activatableLines:boolean;abstract get highlights():readonly LyraHighlight[];abstract set highlights(value:readonly LyraHighlight[]);abstract activeHighlightId:string|null;private readonly collapseWrites;private collapsedValue;
7
10
  /** Whether the code region is currently hidden. Only has a visible effect
8
11
  * while `collapsible` is also true.
9
12
  * @default false */
10
- get collapsed():boolean;set collapsed(value:boolean);protected hasHeaderActions:boolean;protected focusedLine:number;protected highlightedHtml:string|null;protected shikiReady:boolean;protected justCopied:boolean;protected copyFailed:boolean;protected isDarkTheme:boolean;protected restoreFocusedLineAfterUpdate:boolean;protected highlightToken:number;private plainTemplate?;private plainKey;private countedCode?;private countedLines;private paintedCode?;private plainDomChanged;private paintedLines;private previousHighlighted;private previousActive;protected get highlightLimited():boolean;protected readonly bodyId:string;protected resumedMove:boolean;private readonly teardown;private readonly announcements;protected readonly interactions:CodeBlockInteractionController;private readonly headerActions;constructor();connectedCallback():void;disconnectedCallback():void;protected releaseHighlight():void;adoptedCallback():void;private readonly toggleCollapsed;
13
+ get collapsed():boolean;set collapsed(value:boolean);
14
+ /** Source text read from the light DOM (`code` wins while it is non-empty).*/
15
+ protected slottedCode:string;private slottedObserver?;private withoutDedentValue;private labelValue;
16
+ /** Wraps long lines instead of scrolling horizontally. Unset keeps the horizontal scrollport.
17
+ * @default false */
18
+ wrap:boolean;
19
+ /** Keeps code given as light-DOM content exactly as written, ignoring only the newline right
20
+ * after the opening tag. By default that content is dedented. The `code` property is never
21
+ * dedented either way.
22
+ * @default false */
23
+ get withoutDedent():boolean;set withoutDedent(value:boolean);
24
+ /** Accessible name of the code region, as an alias of the host `aria-label`, which wins when
25
+ * both are set. */
26
+ get label():string;set label(value:string);
27
+ /** Alias of `withoutCopyButton`, accepted as the `without-copy` attribute. Reads and writes
28
+ * that same state, and the attribute reflects it whichever spelling set it.
29
+ * @default false */
30
+ get withoutCopy():boolean;set withoutCopy(value:boolean);private readSlottedCode;private syncSlottedCode;protected hasHeaderActions:boolean;protected focusedLine:number;protected highlightedHtml:string|null;protected shikiReady:boolean;protected justCopied:boolean;protected copyFailed:boolean;protected isDarkTheme:boolean;
31
+ /** Set when the current language has no usable grammar, so the code renders as plain text.
32
+ * Each subclass sets it when a highlight attempt settles without output. */
33
+ protected grammarUnavailable:boolean;private readonly highlightInternals;private reportedGrammarError;protected restoreFocusedLineAfterUpdate:boolean;protected highlightToken:number;private plainTemplate?;private plainKey;private countedCode?;private countedLines;private paintedCode?;private plainDomChanged;private paintedLines;private previousHighlighted;private previousActive;protected get highlightLimited():boolean;protected readonly bodyId:string;protected resumedMove:boolean;private readonly teardown;private readonly announcements;protected readonly interactions:CodeBlockInteractionController;private readonly headerActions;constructor();connectedCallback():void;disconnectedCallback():void;private stopGrammarSubscription?;private handleCodeGrammarChange;
34
+ /** Re-resolves the current language after the registry changed.*/
35
+ protected refreshRegisteredGrammar():void;protected releaseHighlight():void;adoptedCallback():void;private readonly toggleCollapsed;
11
36
  /** Resolves a `line-range` anchor (or a `highlights` id string resolving to one) by scrolling
12
37
  * its start line into view within `[part="body"]`. Resolves `false` when the anchor isn't a
13
38
  * `line-range`, the id isn't found, or the start line is out of bounds. */
14
39
  scrollToAnchor(target:LyraAnchor|string):Promise<boolean>;
15
40
  /** Recomputes Shiki palette selection after an imperative CSSOM theme change.*/
16
- refreshTheme():void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;protected beforeHighlightUpdate(_changed:PropertyValues):void;protected abstract preSuppliedGrammar():unknown;
41
+ refreshTheme():void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private syncHighlightStates;
42
+ /** Whether a grammar for the current language could still arrive. The regular code block can
43
+ * always try its dynamic grammar table; the build-lean one only knows its `languages` map. */
44
+ protected grammarMayLoad():boolean;protected beforeHighlightUpdate(_changed:PropertyValues):void;protected abstract preSuppliedGrammar():unknown;
17
45
  /** Whether the active language has an explicitly supplied grammar or loader.*/
18
46
  protected hasPreSuppliedGrammar():boolean;protected abstract syncHighlight():void;protected abstract showsSkeleton():boolean;protected lineHighlightSet():Set<number>;protected activeHighlightLineSet():Set<number>;protected lineCount():number;protected tokenize(hl:ShikiHighlighter,lang:string):string|null;protected renderPlainCode():TemplateResult;private patchLineState;private cachedPlainCode;render():TemplateResult;}
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import{reportCopyOutcome}from"../../../internal/record-copy-feedback.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{DeferredTeardown}from"../../../internal/deferred-teardown.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{nextId}from"../../../internal/a11y.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{SHIKI_SOURCE_MAX_CODE_UNITS}from"./shiki-types.js";import{CodeBlockHeaderActionsController,CodeBlockInteractionController,applyCodeBlockAriaBusy,clampCodeBlockFocusedLine,codeBlockActiveHighlightLineSet,codeBlockLineHasFocus,codeBlockLineCount,codeBlockLineHighlightSet,renderCodeBlockPlainCode,renderCodeBlockShell,restoreCodeBlockLineFocus,scrollCodeBlockToAnchor,tokenizeCodeBlock}from"./code-block-shared.js";import{LYRA_DEFAULT_codeBlockActiveLine,LYRA_DEFAULT_codeBlockHighlightLimit,LYRA_DEFAULT_codeBlockHighlightedLine,LYRA_DEFAULT_codeBlockLineLabel,LYRA_DEFAULT_codeBlockToggle,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copyCode}from"../../../internal/default-strings/conversation.generated.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";class LyraCodeBlockBase extends LyraElement{static{this.defaultStrings={...super.defaultStrings,codeBlockActiveLine:LYRA_DEFAULT_codeBlockActiveLine,codeBlockHighlightLimit:LYRA_DEFAULT_codeBlockHighlightLimit,codeBlockHighlightedLine:LYRA_DEFAULT_codeBlockHighlightedLine,codeBlockLineLabel:LYRA_DEFAULT_codeBlockLineLabel,codeBlockToggle:LYRA_DEFAULT_codeBlockToggle,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}get collapsed(){return this.collapsedValue}set collapsed(value){this.collapsedValue=value,markVetoGuardWrite(this.collapseWrites)}get highlightLimited(){return(this.code??"").length>SHIKI_SOURCE_MAX_CODE_UNITS}constructor(){super(),this.collapseWrites=new VetoWriteGuard,this.collapsedValue=!1,this.hasHeaderActions=!1,this.focusedLine=1,this.highlightedHtml=null,this.shikiReady=!1,this.justCopied=!1,this.copyFailed=!1,this.isDarkTheme=!1,this.restoreFocusedLineAfterUpdate=!1,this.highlightToken=0,this.plainKey=[],this.countedLines=1,this.plainDomChanged=!1,this.paintedLines=new Map,this.previousHighlighted=new Set,this.previousActive=new Set,this.bodyId=nextId("code-block-body"),this.resumedMove=!1,this.teardown=new DeferredTeardown(()=>this.releaseHighlight()),this.announcements=new AnnouncementSinkController(this),this.interactions=new CodeBlockInteractionController({host:this,setFocusedLine:line=>{this.focusedLine=line},setJustCopied:value=>{this.justCopied=value},setCopyFailed:value=>{this.copyFailed=value},setDarkTheme:value=>{this.isDarkTheme=value},emitLineActivate:line=>this.emit("lr-line-activate",{line}),reportCopy:outcome=>reportCopyOutcome({emit:(name,detail)=>this.emit(name,detail??null),announce:ok=>this.announcements.announcePolite(ok?this.localize("copiedToClipboard"):this.localize("copyFailed"))},outcome,()=>this.isConnected&&(this.code??"")===outcome.text),emitTextSelect:selection=>this.emit("lr-text-select",selection)}),this.headerActions=new CodeBlockHeaderActionsController({host:this,setHasHeaderActions:value=>{this.hasHeaderActions=value}}),this.toggleCollapsed=()=>{if(!this.isConnected||!this.collapsible)return;const expanded=this.collapsed;requestThenCommit({guard:this.collapseWrites,requestDetail:{expanded},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),commit:()=>{!this.isConnected||!this.collapsible||(this.collapsed=!expanded,this.emit("lr-toggle",{expanded}))}})},new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.refreshTheme(),this.headerActions.observe(),this.resumedMove=this.teardown.cancel()}disconnectedCallback(){super.disconnectedCallback(),this.teardown.schedule(),this.headerActions.disconnect(),this.interactions.disconnect()}releaseHighlight(){this.highlightToken++,this.highlightedHtml=null}adoptedCallback(){this.teardown.flush(),super.adoptedCallback(),this.announcements.adopted(),this.interactions.disconnect()}async scrollToAnchor(target){return scrollCodeBlockToAnchor(this,target)}refreshTheme(){this.interactions.refreshTheme()}willUpdate(changed){super.willUpdate(changed),this.announcements.setExclusiveChannel(this.withoutCopyButton?void 0:"polite"),this.seedFirstRenderState(()=>this.refreshTheme()),this.headerActions.sync(),this.restoreFocusedLineAfterUpdate=codeBlockLineHasFocus(this),changed.has("code")&&(this.plainTemplate=void 0,this.plainKey=[],this.focusedLine=clampCodeBlockFocusedLine(this.focusedLine,this.lineCount())),this.beforeHighlightUpdate(changed),this.interactions.needsHighlightResync(changed,this.effectiveLocale,this.localize("codeBlockLineLabel"))&&(this.highlightLimited?(this.highlightToken++,this.highlightedHtml=null):this.shikiReady||this.hasPreSuppliedGrammar()?this.syncHighlight():this.highlightedHtml=null)}updated(changed){super.updated(changed),applyCodeBlockAriaBusy(this,!this.highlightLimited&&this.showsSkeleton()),this.patchLineState(),this.interactions.syncLineButtons(this.focusedLine,this.plainDomChanged),this.plainDomChanged=!1,this.restoreFocusedLineAfterUpdate&&(restoreCodeBlockLineFocus(this,this.focusedLine),this.restoreFocusedLineAfterUpdate=!1)}beforeHighlightUpdate(_changed){}hasPreSuppliedGrammar(){return!!this.preSuppliedGrammar()}lineHighlightSet(){return codeBlockLineHighlightSet(this.highlightLines??"",this.highlights,this.lineCount())}activeHighlightLineSet(){return codeBlockActiveHighlightLineSet(this.highlights,this.activeHighlightId,this.lineCount())}lineCount(){const code=this.code??"";return code!==this.countedCode&&(this.countedCode=code,this.countedLines=codeBlockLineCount(code)),this.countedLines}tokenize(hl,lang){return this.highlightLimited?null:tokenizeCodeBlock(hl,{code:this.code??"",lang,lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line)})}renderPlainCode(){return renderCodeBlockPlainCode({code:this.code??"",lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),localize:this.localize.bind(this),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line),onLineActivate:line=>this.interactions.onLineActivate(line),onLineKeyDown:(event,line)=>this.interactions.onLineKeyDown(event,line)})}patchLineState(){const code=this.renderRoot.querySelector("code");if(code!==this.paintedCode||this.plainDomChanged){this.paintedCode=code,this.paintedLines.clear();for(const line of code?.querySelectorAll(".line[data-line]")??[])line.removeAttribute("data-highlighted"),line.removeAttribute("data-active"),line.part?.remove("line-highlight"),this.paintedLines.set(Number(line.dataset.line),line)}const highlighted=this.lineHighlightSet(),active=this.activeHighlightLineSet(),changed=new Set([...this.previousHighlighted,...highlighted,...this.previousActive,...active]);for(const number of changed){const line=this.paintedLines.get(number);if(!line)continue;line.toggleAttribute("data-highlighted",highlighted.has(number)),line.toggleAttribute("data-active",active.has(number)),line.part?.toggle("line-highlight",highlighted.has(number));const gutter=line.querySelector("button.line-gutter");if(highlighted.has(number)){const description=active.has(number)?this.localize("codeBlockActiveLine"):this.localize("codeBlockHighlightedLine");line.setAttribute("role","mark"),line.setAttribute("aria-roledescription",description),gutter?.setAttribute("aria-description",description)}else line.removeAttribute("role"),line.removeAttribute("aria-roledescription"),gutter?.removeAttribute("aria-description")}this.previousHighlighted=highlighted,this.previousActive=active}cachedPlainCode(){const key=[this.code,this.lineNumbers,this.activatableLines,this.effectiveLocale,this.localize("codeBlockLineLabel")];return(!this.plainTemplate||key.some((value,index)=>value!==this.plainKey[index]))&&(this.plainDomChanged=!0,this.plainKey=key,this.plainTemplate=this.renderPlainCode()),this.plainTemplate}render(){return renderCodeBlockShell({filename:this.filename,language:this.language,copyable:!this.withoutCopyButton,copyAppearance:this.copyAppearance,hasHeaderActions:this.hasHeaderActions,collapsible:this.collapsible,collapsed:this.collapsed,justCopied:this.justCopied,copyFailed:this.copyFailed,bodyId:this.bodyId,accessibleLabel:this.accessibleLabel,maxHeight:this.maxHeight,isDarkTheme:this.isDarkTheme,showSkeleton:!this.highlightLimited&&this.showsSkeleton(),highlightLimited:this.highlightLimited&&!!this.language,highlightedHtml:this.highlightedHtml,lineNumbers:this.lineNumbers,localize:this.localize.bind(this),renderPlainCode:()=>this.cachedPlainCode(),onToggle:this.toggleCollapsed,onCopy:()=>{this.interactions.copy()},bindSelectionBody:this.interactions.bindSelectionBody,onBodyClick:this.interactions.onBodyClick,onBodyKeyDown:this.interactions.onBodyKeyDown,onBodyFocusIn:this.interactions.onBodyFocusIn})}}__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlockBase.prototype,"collapsed",null),__decorate([state()],LyraCodeBlockBase.prototype,"hasHeaderActions",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"highlightedHtml",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"shikiReady",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"justCopied",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"copyFailed",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"isDarkTheme",void 0);export{LyraCodeBlockBase};
1
+ import{__decorate}from"tslib";import{reportCopyOutcome}from"../../../internal/record-copy-feedback.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{DeferredTeardown}from"../../../internal/deferred-teardown.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{property,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{setCustomState}from"../../../internal/custom-states.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{nextId}from"../../../internal/a11y.js";import{dedent,stripLeadingNewline}from"../../../internal/dedent.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{SHIKI_SOURCE_MAX_CODE_UNITS}from"./shiki-types.js";import{normalizeShikiLanguage}from"../../../internal/shiki/core.js";import{subscribeCodeGrammars}from"./code-grammar-registry.js";import{CodeBlockHeaderActionsController,CodeBlockInteractionController,applyCodeBlockAriaBusy,clampCodeBlockFocusedLine,codeBlockActiveHighlightLineSet,codeBlockLineHasFocus,codeBlockLineCount,codeBlockLineHighlightSet,renderCodeBlockPlainCode,renderCodeBlockShell,restoreCodeBlockLineFocus,scrollCodeBlockToAnchor,tokenizeCodeBlock}from"./code-block-shared.js";import{LYRA_DEFAULT_codeBlockActiveLine,LYRA_DEFAULT_codeBlockHighlightLimit,LYRA_DEFAULT_codeBlockHighlightedLine,LYRA_DEFAULT_codeBlockLineLabel,LYRA_DEFAULT_codeBlockToggle,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copyCode}from"../../../internal/default-strings/conversation.generated.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";class LyraCodeBlockBase extends LyraElement{static{this.defaultStrings={...super.defaultStrings,codeBlockActiveLine:LYRA_DEFAULT_codeBlockActiveLine,codeBlockHighlightLimit:LYRA_DEFAULT_codeBlockHighlightLimit,codeBlockHighlightedLine:LYRA_DEFAULT_codeBlockHighlightedLine,codeBlockLineLabel:LYRA_DEFAULT_codeBlockLineLabel,codeBlockToggle:LYRA_DEFAULT_codeBlockToggle,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}get collapsed(){return this.collapsedValue}set collapsed(value){this.collapsedValue=value,markVetoGuardWrite(this.collapseWrites)}get withoutDedent(){return this.withoutDedentValue}set withoutDedent(value){const previous=this.withoutDedentValue;this.withoutDedentValue=value,this.requestUpdate("withoutDedent",previous),this.syncSlottedCode()}get label(){return this.labelValue}set label(value){const previous=this.labelValue;this.labelValue=value??"",this.requestUpdate("label",previous)}get withoutCopy(){return this.withoutCopyButton}set withoutCopy(value){this.withoutCopyButton=value}get sourceCode(){const code=this.code??"";return code===""?this.slottedCode:code}readSlottedCode(){let text="";for(const node of this.childNodes)if(node.nodeType===3)text+=node.nodeValue??"";else if(node.nodeType===1){const element=node;if(element.hasAttribute("slot"))continue;element.localName==="template"?text+=element.content.textContent??"":text+=element.textContent??""}return this.withoutDedentValue?stripLeadingNewline(text):dedent(text)}syncSlottedCode(){if(!this.isConnected)return;const next=this.readSlottedCode();next!==this.slottedCode&&(this.slottedCode=next)}get highlightLimited(){return this.sourceCode.length>SHIKI_SOURCE_MAX_CODE_UNITS}constructor(){super(),this.collapseWrites=new VetoWriteGuard,this.collapsedValue=!1,this.slottedCode="",this.withoutDedentValue=!1,this.labelValue="",this.wrap=!1,this.hasHeaderActions=!1,this.focusedLine=1,this.highlightedHtml=null,this.shikiReady=!1,this.justCopied=!1,this.copyFailed=!1,this.isDarkTheme=!1,this.grammarUnavailable=!1,this.highlightInternals=attachInternalsSafely(this),this.reportedGrammarError=!1,this.restoreFocusedLineAfterUpdate=!1,this.highlightToken=0,this.plainKey=[],this.countedLines=1,this.plainDomChanged=!1,this.paintedLines=new Map,this.previousHighlighted=new Set,this.previousActive=new Set,this.bodyId=nextId("code-block-body"),this.resumedMove=!1,this.teardown=new DeferredTeardown(()=>this.releaseHighlight()),this.announcements=new AnnouncementSinkController(this),this.interactions=new CodeBlockInteractionController({host:this,setFocusedLine:line=>{this.focusedLine=line},setJustCopied:value=>{this.justCopied=value},setCopyFailed:value=>{this.copyFailed=value},setDarkTheme:value=>{this.isDarkTheme=value},emitLineActivate:line=>this.emit("lr-line-activate",{line}),reportCopy:outcome=>reportCopyOutcome({emit:(name,detail)=>this.emit(name,detail??null),announce:ok=>this.announcements.announcePolite(ok?this.localize("copiedToClipboard"):this.localize("copyFailed"))},outcome,()=>this.isConnected&&this.sourceCode===outcome.text),emitTextSelect:selection=>this.emit("lr-text-select",selection)}),this.headerActions=new CodeBlockHeaderActionsController({host:this,setHasHeaderActions:value=>{this.hasHeaderActions=value}}),this.toggleCollapsed=()=>{if(!this.isConnected||!this.collapsible)return;const expanded=this.collapsed;requestThenCommit({guard:this.collapseWrites,requestDetail:{expanded},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),commit:()=>{!this.isConnected||!this.collapsible||(this.collapsed=!expanded,this.emit("lr-toggle",{expanded}))}})},new ThemeWatcher(this,()=>this.refreshTheme())}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.refreshTheme(),this.headerActions.observe();const Observer=this.ownerDocument.defaultView?.MutationObserver;Observer&&!this.slottedObserver&&(this.slottedObserver=new Observer(()=>this.syncSlottedCode()),this.slottedObserver.observe(this,{childList:!0,characterData:!0,subtree:!0})),this.syncSlottedCode(),this.resumedMove=this.teardown.cancel(),this.stopGrammarSubscription??=subscribeCodeGrammars(keys=>this.handleCodeGrammarChange(keys))}disconnectedCallback(){super.disconnectedCallback(),this.stopGrammarSubscription?.(),this.stopGrammarSubscription=void 0,this.teardown.schedule(),this.headerActions.disconnect(),this.interactions.disconnect(),this.slottedObserver?.disconnect(),this.slottedObserver=void 0}handleCodeGrammarChange(keys){!this.isConnected||!this.language||!keys.has(normalizeShikiLanguage(this.language))&&!keys.has(this.language)||(this.grammarUnavailable=!1,this.refreshRegisteredGrammar())}refreshRegisteredGrammar(){this.syncHighlight()}releaseHighlight(){this.highlightToken++,this.highlightedHtml=null}adoptedCallback(){this.teardown.flush(),super.adoptedCallback(),this.announcements.adopted(),this.interactions.disconnect()}async scrollToAnchor(target){return scrollCodeBlockToAnchor(this,target)}refreshTheme(){this.interactions.refreshTheme()}willUpdate(changed){super.willUpdate(changed),this.announcements.setExclusiveChannel(this.withoutCopyButton?void 0:"polite"),changed.has("withoutCopyButton")&&this.requestUpdate("withoutCopy",changed.get("withoutCopyButton")),this.seedFirstRenderState(()=>this.refreshTheme()),this.headerActions.sync(),this.restoreFocusedLineAfterUpdate=codeBlockLineHasFocus(this),(changed.has("code")||changed.has("slottedCode"))&&(this.plainTemplate=void 0,this.plainKey=[],this.focusedLine=clampCodeBlockFocusedLine(this.focusedLine,this.lineCount())),(changed.has("language")||changed.has("languages"))&&(this.grammarUnavailable=!1),this.beforeHighlightUpdate(changed),this.interactions.needsHighlightResync(changed,this.effectiveLocale,this.localize("codeBlockLineLabel"))&&(this.highlightLimited?(this.highlightToken++,this.highlightedHtml=null,this.grammarUnavailable=!1):this.shikiReady||this.hasPreSuppliedGrammar()?this.syncHighlight():this.highlightedHtml=null)}updated(changed){super.updated(changed),applyCodeBlockAriaBusy(this,!this.highlightLimited&&this.showsSkeleton()),this.syncHighlightStates(changed),this.patchLineState(),this.interactions.syncLineButtons(this.focusedLine,this.plainDomChanged),this.plainDomChanged=!1,this.restoreFocusedLineAfterUpdate&&(restoreCodeBlockLineFocus(this,this.focusedLine),this.restoreFocusedLineAfterUpdate=!1)}syncHighlightStates(changed){const highlighted=this.highlightedHtml!==null,wanted=normalizeShikiLanguage(this.language??"")!==""&&!this.highlightLimited,error=wanted&&!highlighted&&(this.grammarUnavailable||!this.grammarMayLoad());setCustomState(this.highlightInternals,"highlighted",highlighted),setCustomState(this.highlightInternals,"error",error),setCustomState(this.highlightInternals,"loading",wanted&&!highlighted&&!error),changed.has("highlightedHtml")&&highlighted&&this.emit("lr-load",{highlighted:!0}),error&&!this.reportedGrammarError&&this.emit("lr-load",{highlighted:!1}),this.reportedGrammarError=error}grammarMayLoad(){return!0}beforeHighlightUpdate(_changed){}hasPreSuppliedGrammar(){return!!this.preSuppliedGrammar()}lineHighlightSet(){return codeBlockLineHighlightSet(this.highlightLines??"",this.highlights,this.lineCount())}activeHighlightLineSet(){return codeBlockActiveHighlightLineSet(this.highlights,this.activeHighlightId,this.lineCount())}lineCount(){const code=this.sourceCode;return code!==this.countedCode&&(this.countedCode=code,this.countedLines=codeBlockLineCount(code)),this.countedLines}tokenize(hl,lang){return this.highlightLimited?null:tokenizeCodeBlock(hl,{code:this.sourceCode,lang,lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line)})}renderPlainCode(){return renderCodeBlockPlainCode({code:this.sourceCode,lineNumbers:this.lineNumbers,activatableLines:this.activatableLines,focusedLine:this.focusedLine,highlightedLines:this.lineHighlightSet(),activeLines:this.activeHighlightLineSet(),localize:this.localize.bind(this),lineLabel:line=>this.localize("codeBlockLineLabel",void 0,{line:getNumberFormat(this.effectiveLocale).format(line)}),lineNumberText:line=>getNumberFormat(this.effectiveLocale).format(line),onLineActivate:line=>this.interactions.onLineActivate(line),onLineKeyDown:(event,line)=>this.interactions.onLineKeyDown(event,line)})}patchLineState(){const code=this.renderRoot.querySelector("code");if(code!==this.paintedCode||this.plainDomChanged){this.paintedCode=code,this.paintedLines.clear();for(const line of code?.querySelectorAll(".line[data-line]")??[])line.removeAttribute("data-highlighted"),line.removeAttribute("data-active"),line.part?.remove("line-highlight"),this.paintedLines.set(Number(line.dataset.line),line)}const highlighted=this.lineHighlightSet(),active=this.activeHighlightLineSet(),changed=new Set([...this.previousHighlighted,...highlighted,...this.previousActive,...active]);for(const number of changed){const line=this.paintedLines.get(number);if(!line)continue;line.toggleAttribute("data-highlighted",highlighted.has(number)),line.toggleAttribute("data-active",active.has(number)),line.part?.toggle("line-highlight",highlighted.has(number));const gutter=line.querySelector("button.line-gutter");if(highlighted.has(number)){const description=active.has(number)?this.localize("codeBlockActiveLine"):this.localize("codeBlockHighlightedLine");line.setAttribute("role","mark"),line.setAttribute("aria-roledescription",description),gutter?.setAttribute("aria-description",description)}else line.removeAttribute("role"),line.removeAttribute("aria-roledescription"),gutter?.removeAttribute("aria-description")}this.previousHighlighted=highlighted,this.previousActive=active}cachedPlainCode(){const key=[this.sourceCode,this.lineNumbers,this.activatableLines,this.effectiveLocale,this.localize("codeBlockLineLabel")];return(!this.plainTemplate||key.some((value,index)=>value!==this.plainKey[index]))&&(this.plainDomChanged=!0,this.plainKey=key,this.plainTemplate=this.renderPlainCode()),this.plainTemplate}render(){return renderCodeBlockShell({filename:this.filename,language:this.language,copyable:!this.withoutCopyButton,copyAppearance:this.copyAppearance,hasHeaderActions:this.hasHeaderActions,collapsible:this.collapsible,collapsed:this.collapsed,justCopied:this.justCopied,copyFailed:this.copyFailed,bodyId:this.bodyId,accessibleLabel:this.accessibleLabel??(this.label||null),maxHeight:this.maxHeight,isDarkTheme:this.isDarkTheme,showSkeleton:!this.highlightLimited&&this.showsSkeleton(),highlightLimited:this.highlightLimited&&!!this.language,highlightedHtml:this.highlightedHtml,lineNumbers:this.lineNumbers,localize:this.localize.bind(this),renderPlainCode:()=>this.cachedPlainCode(),onToggle:this.toggleCollapsed,onCopy:()=>{this.interactions.copy()},bindSelectionBody:this.interactions.bindSelectionBody,onBodyClick:this.interactions.onBodyClick,onBodyKeyDown:this.interactions.onBodyKeyDown,onBodyFocusIn:this.interactions.onBodyFocusIn})}}__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlockBase.prototype,"collapsed",null),__decorate([state()],LyraCodeBlockBase.prototype,"slottedCode",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlockBase.prototype,"wrap",void 0),__decorate([property({type:Boolean,attribute:"without-dedent",reflect:!0})],LyraCodeBlockBase.prototype,"withoutDedent",null),__decorate([property()],LyraCodeBlockBase.prototype,"label",null),__decorate([property({type:Boolean,attribute:"without-copy",reflect:!0})],LyraCodeBlockBase.prototype,"withoutCopy",null),__decorate([state()],LyraCodeBlockBase.prototype,"hasHeaderActions",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"highlightedHtml",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"shikiReady",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"justCopied",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"copyFailed",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"isDarkTheme",void 0),__decorate([state()],LyraCodeBlockBase.prototype,"grammarUnavailable",void 0);export{LyraCodeBlockBase};
@@ -1,4 +1,4 @@
1
- import type{PropertyValues}from'lit';import{type ShikiLanguageSource}from'./shiki-types.js';import type{LyraCodeBlockCopyAppearance}from'./code-block-shared.js';import{LyraCodeBlockBase,type LyraCodeBlockBaseEventMap}from'./code-block-base.class.js';export type{LyraCodeBlockToggleDetail}from'./code-block-shared.js';import type{LyraAnchor,LyraHighlight}from'../../../internal/document-anchors.js';import'../../overlays/skeleton/skeleton.class.js';export interface LyraCodeBlockCoreEventMap extends LyraCodeBlockBaseEventMap{}
1
+ import type{PropertyValues}from'lit';import{type ShikiLanguageSource}from'./shiki-types.js';import type{LyraCodeBlockCopyAppearance}from'./code-block-shared.js';import{LyraCodeBlockBase,type LyraCodeBlockBaseEventMap}from'./code-block-base.class.js';export type{LyraCodeBlockToggleDetail}from'./code-block-shared.js';export type{LyraCodeBlockLoadDetail}from'./code-block-base.class.js';import type{LyraAnchor,LyraHighlight}from'../../../internal/document-anchors.js';import'../../overlays/skeleton/skeleton.class.js';export interface LyraCodeBlockCoreEventMap extends LyraCodeBlockBaseEventMap{}
2
2
  /**
3
3
  * `<lr-code-block-core>` — a build-lean variant of `<lr-code-block>` for
4
4
  * a consumer whose `languages` map already covers every language it will
@@ -28,6 +28,13 @@ import type{PropertyValues}from'lit';import{type ShikiLanguageSource}from'./shik
28
28
  * the matching `accessibleLabel` property) is forwarded to the internal
29
29
  * focusable element that owns the named `group` role.
30
30
  *
31
+ * Source can also be given as the element's light-DOM text (text nodes, a `<script type="text/plain">`
32
+ * or a `<template>`; children with a `slot` attribute are excluded). It is dedented, and
33
+ * `without-dedent` keeps it as written apart from the newline right after the opening tag. A
34
+ * non-empty `code` property wins and is never dedented. `wrap` wraps long lines instead of
35
+ * scrolling; both plain and highlighted rendering honor it. `label` aliases the host `aria-label`
36
+ * and `without-copy` aliases `without-copy-button`.
37
+ *
31
38
  * Adopts the `line-range` slice of this library's shared anchor-target contract, identical to
32
39
  * `<lr-code-block>`: `highlights`/`activeHighlightId` paint (and `highlight-lines` additionally
33
40
  * marks) per-line emphasis in both the shiki and plain-text-fallback rendering paths identically,
@@ -48,7 +55,13 @@ import type{PropertyValues}from'lit';import{type ShikiLanguageSource}from'./shik
48
55
  * @customElement lr-code-block-core
49
56
  * @event lr-copy - The raw `code` was written to the clipboard. Frozen detail:
50
57
  * `{ ok: true, text }`.
58
+ * @slot - The code to display, as text (or a `<script type="text/plain">` or `<template>`) when
59
+ * `code` is empty. Read as source rather than projected; dedented unless `without-dedent`.
51
60
  * @event lr-error - Clipboard writing failed; generic no-detail notification.
61
+ * @event lr-load - Highlighting settled for the current `language`. `detail: { highlighted }` is
62
+ * `true` when the grammar loaded and the code was highlighted (fired again each time new
63
+ * highlighted output replaces the old), and `false` once when no grammar exists and the code
64
+ * renders as plain text, alongside `:state(error)`.
52
65
  * @event lr-copy-error - Clipboard writing failed. Frozen detail:
53
66
  * `{ ok: false, text, reason, error }`, where `reason` is
54
67
  * `'unsupported' | 'denied' | 'failed'`.
@@ -77,6 +90,17 @@ import type{PropertyValues}from'lit';import{type ShikiLanguageSource}from'./shik
77
90
  * @csspart copy-button-icon - The copy control while `copyAppearance` is `'icon'`.
78
91
  * @csspart copy-button-control - The copy control's own native `<button>`, forwarded because the
79
92
  * painted surface sits one shadow boundary deeper than `copy-button`.
93
+ * @csspart copy-button__button - Alias of `copy-button-control`.
94
+ * @csspart copy-button__copy-icon - The copy glyph at rest while `copyAppearance` is `'icon'`.
95
+ * @csspart copy-button__success-icon - The check glyph after a successful copy while
96
+ * `copyAppearance` is `'icon'`.
97
+ * @csspart copy-button__error-icon - The error glyph after a failed copy while `copyAppearance` is
98
+ * `'icon'`.
99
+ * @csspart copy-button__feedback - Visually hidden, `aria-hidden` mirror of the copy outcome text;
100
+ * empty at rest.
101
+ * @cssstate loading - A `language` is set and its grammar (or the highlighter) is still loading.
102
+ * @cssstate error - No grammar exists for the current `language`; the code renders as plain text.
103
+ * @cssstate highlighted - The code is rendered with syntax highlighting.
80
104
  * @csspart header-actions - The wrapper around the `header-actions` slot, at the trailing end of
81
105
  * the header row.
82
106
  * @slot header-actions - Extra controls for the header row, rendered after the copy control. Their
@@ -96,8 +120,28 @@ import type{PropertyValues}from'lit';import{type ShikiLanguageSource}from'./shik
96
120
  * @csspart line-button - A gutter line-number button, only rendered while `activatable-lines` and
97
121
  * `line-numbers` are both set.
98
122
  * @cssprop [--lr-code-block-padding=var(--lr-space-s) var(--lr-space-m)] - Code padding.
123
+ * @cssprop --comment-color - Color of highlighted comments and quotes. Unset keeps the theme color.
124
+ * @cssprop --keyword-color - Color of highlighted keywords, storage modifiers, doctypes and headings. Unset keeps the theme color.
125
+ * @cssprop --operator-color - Color of highlighted operators and punctuation. Unset keeps the theme color.
126
+ * @cssprop --string-color - Color of highlighted strings, regular expressions, links and raw text. Unset keeps the theme color.
127
+ * @cssprop --constant-color - Color of highlighted numbers, booleans, constants and entities. Unset keeps the theme color.
128
+ * @cssprop --function-color - Color of highlighted functions and decorators. Unset keeps the theme color.
129
+ * @cssprop --type-color - Color of highlighted types, classes and built-ins. Unset keeps the theme color.
130
+ * @cssprop --variable-color - Color of highlighted variables and interpolations. Unset keeps the theme color.
131
+ * @cssprop --property-color - Color of highlighted properties, keys and attribute names. Unset keeps the theme color.
132
+ * @cssprop --tag-color - Color of highlighted markup tags. Unset keeps the theme color.
133
+ * @cssprop --selector-color - Color of highlighted CSS selectors. Unset keeps the theme color.
134
+ * @cssprop --inserted-color - Color of highlighted inserted diff lines. Unset keeps the theme color.
135
+ * @cssprop --deleted-color - Color of highlighted deleted diff lines. Unset keeps the theme color.
99
136
  * @cssprop [--lr-code-block-radius=var(--lr-radius)] - Frame corner radius.
137
+ * @cssprop [--lr-code-block-border=var(--lr-border-width-thin) solid var(--lr-color-border-subtle)] -
138
+ * Frame border shorthand.
139
+ * @cssprop [--lr-code-block-bg=var(--lr-color-surface)] - Frame and plain-code fill; highlighted
140
+ * code paints its theme background over it.
100
141
  * @cssprop [--lr-code-block-header-bg=var(--lr-color-surface)] - Header background.
142
+ * @cssprop [--lr-code-block-header-padding=var(--lr-space-xs) var(--lr-space-s)] - Header padding.
143
+ * @cssprop [--lr-code-block-header-border=var(--lr-border-width-thin) solid var(--lr-color-border-subtle)] -
144
+ * Rule between the header and the code (shorthand).
101
145
  * @cssprop [--lr-code-block-header-color=var(--lr-color-text)] - Filename color.
102
146
  * @cssprop [--lr-code-block-toggle-bg=transparent] - Disclosure control background at rest.
103
147
  * @cssprop [--lr-code-block-toggle-hover-bg=var(--lr-color-brand-quiet)] - Disclosure control hover background.
@@ -209,7 +253,7 @@ readonly anchorKinds:readonly LyraAnchor['kind'][];
209
253
  * highlighted output. For a TypeScript annotation, use `import type { ShikiLanguageSource } from
210
254
  * '@aceshooting/lyra-ui/components/lr-code-block-core.js'`; this granular
211
255
  * type-only import emits no registration side effect. */
212
- languages:Readonly<Record<string,ShikiLanguageSource>>;private highlighterGeneration;private activeLanguages?;connectedCallback():void;protected releaseHighlight():void;protected preSuppliedGrammar():ShikiLanguageSource|undefined;protected beforeHighlightUpdate(changed:PropertyValues):void;
256
+ languages:Readonly<Record<string,ShikiLanguageSource>>;private highlighterGeneration;private activeLanguages?;private effectiveLanguages;connectedCallback():void;protected releaseHighlight():void;protected preSuppliedGrammar():ShikiLanguageSource|undefined;protected grammarMayLoad():boolean;protected beforeHighlightUpdate(changed:PropertyValues):void;
213
257
  /** Whether this render shows the loading skeleton instead of the code. Unlike `<lr-code-block>`,
214
258
  * the only highlighter this variant ever waits on is the fine-grained one seeded from
215
259
  * `languages` -- so a `language` absent from that map has nothing pending and never shows the
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{snapshotLyraHighlights}from"../../../internal/highlight-collection.js";import{ensureShikiLanguageLoaded,loadShikiHighlighterCore,normalizeShikiLanguage,resolvedShikiLanguages}from"./shiki-types.js";import{styles}from"./code-block.styles.js";import{LyraCodeBlockBase}from"./code-block-base.class.js";import{codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton}from"./code-block-shared.js";import"../../overlays/skeleton/skeleton.class.js";import{LYRA_DEFAULT_codeBlockHighlightLimit,LYRA_DEFAULT_codeBlockToggle,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copyCode}from"../../../internal/default-strings/conversation.generated.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";class LyraCodeBlockCore extends LyraCodeBlockBase{constructor(){super(...arguments),this.code="",this.language="",this.filename="",this.accessibleLabel=null,this.collapsible=!1,this.withoutCopyButton=!1,this.copyAppearance="text",this.maxHeight="",this.lineNumbers=!1,this.highlightLines="",this.activatableLines=!1,this._highlights=snapshotLyraHighlights([]),this.activeHighlightId=null,this.anchorKinds=["line-range"],this.languages={},this.highlighterGeneration=0}static{this.defaultStrings={...super.defaultStrings,codeBlockHighlightLimit:LYRA_DEFAULT_codeBlockHighlightLimit,codeBlockToggle:LYRA_DEFAULT_codeBlockToggle,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.ownedCollectionProperties=Object.freeze(["languages"])}static{this.styles=[LyraElement.styles,styles]}get highlights(){return this._highlights}set highlights(value){const previous=this._highlights;this._highlights=snapshotLyraHighlights(value),this.requestUpdate("highlights",previous)}connectedCallback(){if(super.connectedCallback(),this.resumedMove)return;const languages=this.languages,generation=this.activateLanguages(languages);!languages||Object.keys(languages).length===0||loadShikiHighlighterCore(resolvedShikiLanguages(languages)).then(()=>{!this.isConnected||generation!==this.highlighterGeneration||languages!==this.languages||(this.shikiReady=!0,this.syncHighlight())})}releaseHighlight(){super.releaseHighlight(),this.activeLanguages=void 0,this.highlighterGeneration+=1,this.shikiReady=!1}preSuppliedGrammar(){return codeBlockPreSuppliedGrammar(this.languages,this.language??"")}beforeHighlightUpdate(changed){changed.has("languages")&&this.activateLanguages(this.languages)}showsSkeleton(){return codeBlockShowsSkeleton(this.shikiReady,this.language,!!this.preSuppliedGrammar())}activateLanguages(languages){return this.activeLanguages===languages?this.highlighterGeneration:(this.activeLanguages=languages,this.highlighterGeneration+=1,this.highlightToken+=1,this.shikiReady=!1,this.highlightedHtml=null,this.highlighterGeneration)}syncHighlight(){const languages=this.languages,generation=this.activateLanguages(languages),token=++this.highlightToken,lang=normalizeShikiLanguage(this.language??"");if(!lang||this.highlightLimited){this.highlightedHtml=null;return}const source=languages?.[lang]??languages?.[this.language];if(source===void 0){this.highlightedHtml=null;return}this.highlightedHtml=null,loadShikiHighlighterCore(resolvedShikiLanguages(languages)).then(async hl=>{if(token!==this.highlightToken||generation!==this.highlighterGeneration||languages!==this.languages)return;if(!hl){if(!this.isConnected)return;this.shikiReady=!0,this.highlightedHtml=null;return}const loaded=await ensureShikiLanguageLoaded(hl,lang,source);token===this.highlightToken&&(generation!==this.highlighterGeneration||languages!==this.languages||this.isConnected&&(this.shikiReady=!0,this.highlightedHtml=loaded?this.tokenize(hl,lang):null))})}}__decorate([property()],LyraCodeBlockCore.prototype,"code",void 0),__decorate([property()],LyraCodeBlockCore.prototype,"language",void 0),__decorate([property()],LyraCodeBlockCore.prototype,"filename",void 0),__decorate([property({attribute:"aria-label"})],LyraCodeBlockCore.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlockCore.prototype,"collapsible",void 0),__decorate([property({type:Boolean,attribute:"without-copy-button",reflect:!0})],LyraCodeBlockCore.prototype,"withoutCopyButton",void 0),__decorate([property({attribute:"copy-appearance",reflect:!0})],LyraCodeBlockCore.prototype,"copyAppearance",void 0),__decorate([property({attribute:"max-height"})],LyraCodeBlockCore.prototype,"maxHeight",void 0),__decorate([property({type:Boolean,attribute:"line-numbers",reflect:!0})],LyraCodeBlockCore.prototype,"lineNumbers",void 0),__decorate([property({attribute:"highlight-lines"})],LyraCodeBlockCore.prototype,"highlightLines",void 0),__decorate([property({type:Boolean,attribute:"activatable-lines"})],LyraCodeBlockCore.prototype,"activatableLines",void 0),__decorate([property({attribute:!1})],LyraCodeBlockCore.prototype,"highlights",null),__decorate([property({attribute:"active-highlight-id"})],LyraCodeBlockCore.prototype,"activeHighlightId",void 0),__decorate([property({attribute:!1})],LyraCodeBlockCore.prototype,"languages",void 0);export{LyraCodeBlockCore};
1
+ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{snapshotLyraHighlights}from"../../../internal/highlight-collection.js";import{ensureShikiLanguageLoaded,loadShikiHighlighterCore,normalizeShikiLanguage,resolvedShikiLanguages}from"./shiki-types.js";import{withRegisteredCodeGrammars}from"./code-grammar-registry.js";import{styles}from"./code-block.styles.js";import{LyraCodeBlockBase}from"./code-block-base.class.js";import{codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton}from"./code-block-shared.js";import"../../overlays/skeleton/skeleton.class.js";import{LYRA_DEFAULT_codeBlockHighlightLimit,LYRA_DEFAULT_codeBlockToggle,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copyCode}from"../../../internal/default-strings/conversation.generated.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";class LyraCodeBlockCore extends LyraCodeBlockBase{constructor(){super(...arguments),this.code="",this.language="",this.filename="",this.accessibleLabel=null,this.collapsible=!1,this.withoutCopyButton=!1,this.copyAppearance="text",this.maxHeight="",this.lineNumbers=!1,this.highlightLines="",this.activatableLines=!1,this._highlights=snapshotLyraHighlights([]),this.activeHighlightId=null,this.anchorKinds=["line-range"],this.languages={},this.highlighterGeneration=0}static{this.defaultStrings={...super.defaultStrings,codeBlockHighlightLimit:LYRA_DEFAULT_codeBlockHighlightLimit,codeBlockToggle:LYRA_DEFAULT_codeBlockToggle,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.ownedCollectionProperties=Object.freeze(["languages"])}static{this.styles=[LyraElement.styles,styles]}get highlights(){return this._highlights}set highlights(value){const previous=this._highlights;this._highlights=snapshotLyraHighlights(value),this.requestUpdate("highlights",previous)}effectiveLanguages(){return withRegisteredCodeGrammars(this.languages)}connectedCallback(){if(super.connectedCallback(),this.resumedMove)return;const languages=this.effectiveLanguages(),generation=this.activateLanguages(languages);!languages||Object.keys(languages).length===0||loadShikiHighlighterCore(resolvedShikiLanguages(languages)).then(()=>{!this.isConnected||generation!==this.highlighterGeneration||languages!==this.effectiveLanguages()||(this.shikiReady=!0,this.syncHighlight())})}releaseHighlight(){super.releaseHighlight(),this.activeLanguages=void 0,this.highlighterGeneration+=1,this.shikiReady=!1}preSuppliedGrammar(){return codeBlockPreSuppliedGrammar(this.effectiveLanguages(),this.language??"")}grammarMayLoad(){return this.preSuppliedGrammar()!==void 0}beforeHighlightUpdate(changed){changed.has("languages")&&this.activateLanguages(this.effectiveLanguages())}showsSkeleton(){return codeBlockShowsSkeleton(this.shikiReady,this.language,!!this.preSuppliedGrammar())}activateLanguages(languages){return this.activeLanguages===languages?this.highlighterGeneration:(this.activeLanguages=languages,this.highlighterGeneration+=1,this.highlightToken+=1,this.shikiReady=!1,this.highlightedHtml=null,this.highlighterGeneration)}syncHighlight(){const languages=this.effectiveLanguages(),generation=this.activateLanguages(languages),token=++this.highlightToken,lang=normalizeShikiLanguage(this.language??"");if(!lang||this.highlightLimited){this.highlightedHtml=null;return}const source=languages?.[lang]??languages?.[this.language];if(source===void 0){this.highlightedHtml=null,this.grammarUnavailable=!0;return}this.highlightedHtml=null,loadShikiHighlighterCore(resolvedShikiLanguages(languages)).then(async hl=>{if(token!==this.highlightToken||generation!==this.highlighterGeneration||languages!==this.effectiveLanguages())return;if(!hl){if(!this.isConnected)return;this.shikiReady=!0,this.highlightedHtml=null,this.grammarUnavailable=!0;return}const loaded=await ensureShikiLanguageLoaded(hl,lang,source);token===this.highlightToken&&(generation!==this.highlighterGeneration||languages!==this.effectiveLanguages()||this.isConnected&&(this.shikiReady=!0,this.highlightedHtml=loaded?this.tokenize(hl,lang):null,this.grammarUnavailable=this.highlightedHtml===null))})}}__decorate([property()],LyraCodeBlockCore.prototype,"code",void 0),__decorate([property()],LyraCodeBlockCore.prototype,"language",void 0),__decorate([property()],LyraCodeBlockCore.prototype,"filename",void 0),__decorate([property({attribute:"aria-label"})],LyraCodeBlockCore.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlockCore.prototype,"collapsible",void 0),__decorate([property({type:Boolean,attribute:"without-copy-button",reflect:!0})],LyraCodeBlockCore.prototype,"withoutCopyButton",void 0),__decorate([property({attribute:"copy-appearance",reflect:!0})],LyraCodeBlockCore.prototype,"copyAppearance",void 0),__decorate([property({attribute:"max-height"})],LyraCodeBlockCore.prototype,"maxHeight",void 0),__decorate([property({type:Boolean,attribute:"line-numbers",reflect:!0})],LyraCodeBlockCore.prototype,"lineNumbers",void 0),__decorate([property({attribute:"highlight-lines"})],LyraCodeBlockCore.prototype,"highlightLines",void 0),__decorate([property({type:Boolean,attribute:"activatable-lines"})],LyraCodeBlockCore.prototype,"activatableLines",void 0),__decorate([property({attribute:!1})],LyraCodeBlockCore.prototype,"highlights",null),__decorate([property({attribute:"active-highlight-id"})],LyraCodeBlockCore.prototype,"activeHighlightId",void 0),__decorate([property({attribute:!1})],LyraCodeBlockCore.prototype,"languages",void 0);export{LyraCodeBlockCore};
@@ -47,7 +47,7 @@ export declare function codeBlockActiveHighlightLineSet(highlights:readonly Lyra
47
47
  export declare function codeBlockPreSuppliedGrammar<T>(languages:Record<string,T> |undefined,language:string):T|undefined;
48
48
  /** The LitElement surface `scrollCodeBlockToAnchor()` reads -- everything it touches is public on
49
49
  * both components, so neither needs to widen a private field to route through this. */
50
- interface CodeBlockAnchorHost{readonly code:string;readonly highlights:readonly LyraHighlight[];readonly renderRoot:HTMLElement|DocumentFragment;readonly updateComplete:Promise<boolean>;}
50
+ interface CodeBlockAnchorHost{readonly sourceCode:string;readonly highlights:readonly LyraHighlight[];readonly renderRoot:HTMLElement|DocumentFragment;readonly updateComplete:Promise<boolean>;}
51
51
  /** Resolves a `line-range` anchor (or a `highlights` id string resolving to one) by scrolling its
52
52
  * start line into view within `[part="body"]`. Resolves `false` when the anchor isn't a
53
53
  * `line-range`, the id isn't found, or the start line is out of bounds. */
@@ -144,7 +144,11 @@ export declare function renderCodeBlockShell(options:CodeBlockShellOptions):Temp
144
144
  /** The element surface {@linkcode CodeBlockInteractionController} reads. Every member is either
145
145
  * native to `HTMLElement` or already public on both code-block variants, so routing through the
146
146
  * controller widens neither component's own API. */
147
- interface CodeBlockInteractionHost extends HTMLElement{readonly renderRoot:HTMLElement|DocumentFragment;readonly updateComplete:Promise<boolean>;readonly code:string;}
147
+ interface CodeBlockInteractionHost extends HTMLElement{readonly renderRoot:HTMLElement|DocumentFragment;readonly updateComplete:Promise<boolean>;
148
+ /** The authored `code` property; kept on this published host contract.*/
149
+ readonly code:string;
150
+ /** The effective source (the `code` property, else the slotted text) the interactions read.*/
151
+ readonly sourceCode:string;}
148
152
  /** Reactive writes and typed events supplied by the code-block host.*/
149
153
  interface CodeBlockInteractionOptions{host:CodeBlockInteractionHost;setFocusedLine:(line:number)=>void;setJustCopied:(value:boolean)=>void;setCopyFailed:(value:boolean)=>void;setDarkTheme:(value:boolean)=>void;emitLineActivate:(line:number)=>void;reportCopy:(outcome:CopyOutcome)=>void;emitTextSelect:(selection:CodeBlockSelection)=>void;}
150
154
  /** Owns gutter navigation, selection, collapse and theme interactions for both code blocks.*/
@@ -1,4 +1,4 @@
1
- import{countLines,splitLines}from"../../../internal/text-lines.js";import{isRepeatedActivationKey,shouldIgnoreNavigationKey}from"../../../internal/list-navigation.js";import{RecordCopyFeedback}from"../../../internal/record-copy-feedback.js";import{normalizeLabel}from"../../../internal/accessible-name.js";import{OwnedMutationObserver}from"../../../internal/owned-observer.js";import{highlightToHtml}from"../../../internal/shiki/tokenize.js";import{html,nothing}from"lit";import{unsafeHTML}from"lit/directives/unsafe-html.js";import{activeElementIn,shadowFocusTarget}from"../../../internal/active-element.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{chevronIcon,copyIcon}from"../../../internal/icons.js";import{motionScrollBehavior}from"../../../internal/motion.js";import{styleMap}from"lit/directives/style-map.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{observeTextSelection}from"../../../internal/text-selection-observer.js";import{ref}from"lit/directives/ref.js";import{normalizeShikiLanguage}from"./shiki-types.js";import{resolveIsDarkTheme}from"../../../internal/shiki/dark-theme.js";const INVALID_HIGHLIGHT_LINES_WARNING_KEY="lyra-code-block-invalid-highlight-lines",INVALID_HIGHLIGHT_LINES_WARNING="<lr-code-block> and <lr-code-block-core>: invalid highlight-lines entries are ignored; use one-based line numbers or ranges such as `3-5,7`.";function codeBlockCopyLabel(localize,justCopied,copyFailed){return localize(copyFailed?"copyFailed":justCopied?"copiedToClipboard":"copyCode")}function codeBlockBodyLabel(localize,filename,language){return normalizeLabel(filename)??(language?localize("codeRegionWithLanguage",void 0,{language}):localize("codeRegion"))}function addBoundedLineRange(lines,start,end,maxLine){if(!Number.isFinite(start)||!Number.isFinite(end)||maxLine<1)return;const low=Math.max(1,Math.min(Math.trunc(start),Math.trunc(end))),high=Math.min(Math.trunc(maxLine),Math.max(Math.trunc(start),Math.trunc(end)));for(let line=low;line<=high;line++)lines.add(line)}function codeBlockLineCount(code){return countLines(code)}function clampCodeBlockFocusedLine(focusedLine,lineCount){return Math.min(Math.max(1,focusedLine),lineCount)}function codeBlockLineHasFocus(host){return shadowFocusTarget(host)?.matches('[data-line][part~="line-button"]')??!1}function restoreCodeBlockLineFocus(host,line){const shadowActive=shadowFocusTarget(host);if(shadowActive)return shadowActive.matches('[data-line][part~="line-button"]');const documentActive=activeElementIn(host.ownerDocument);if(documentActive&&documentActive!==host.ownerDocument.body&&documentActive!==host)return!1;const target=host.renderRoot.querySelector(`[data-line="${line}"][part~="line-button"]`);return target?.focus(),shadowFocusTarget(host)===target}function codeBlockLineHighlightSet(highlightLines,highlights,maxLine){const merged=parseHighlightLines(highlightLines,maxLine);if(!Array.isArray(highlights))return merged;for(const highlight of highlights){const anchor=lineRangeAnchor(highlight);if(!anchor)continue;const end=anchor.end??anchor.start;addBoundedLineRange(merged,anchor.start,end,maxLine)}return merged}function lineRangeAnchor(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const anchor=value.anchor;return anchor===null||typeof anchor!="object"||Array.isArray(anchor)?void 0:anchor.kind==="line-range"?anchor:void 0}catch{return}}function lineRangeAnchorById(highlights,id){if(Array.isArray(highlights))for(const highlight of highlights)try{if(highlight!==null&&typeof highlight=="object"&&highlight.id===id){const anchor=lineRangeAnchor(highlight);if(anchor)return anchor}}catch{}}function codeBlockActiveHighlightLineSet(highlights,activeHighlightId,maxLine){const result=new Set,anchor=lineRangeAnchorById(highlights,activeHighlightId);if(!anchor)return result;const end=anchor.end??anchor.start;return addBoundedLineRange(result,anchor.start,end,maxLine),result}function codeBlockPreSuppliedGrammar(languages,language){const normalized=normalizeShikiLanguage(language);return languages?.[normalized]??languages?.[language]}async function scrollCodeBlockToAnchor(host,target){const anchor=typeof target=="string"?lineRangeAnchorById(host.highlights,target):target;if(!anchor||anchor.kind!=="line-range"||anchor.start<1||anchor.start>codeBlockLineCount(host.code??""))return!1;await host.updateComplete;const body=host.renderRoot.querySelector('[part="body"]'),lineEl=host.renderRoot.querySelector(`[data-line="${anchor.start}"]`);if(!body||!lineEl)return!1;const offset=lineEl.offsetTop-body.clientHeight/2,behavior=body.ownerDocument.defaultView?motionScrollBehavior(body):"instant";return body.scrollTo({top:Math.max(0,offset),behavior}),!0}function codeBlockEventLine(e){const target=e.composedPath()[0];if(typeof target!="object"||target===null||target.nodeType!==1||typeof target.localName!="string"||typeof target.closest!="function")return null;const lineElement=target.closest('[data-line][part~="line-button"]'),line=Number(lineElement?.dataset.line);return Number.isInteger(line)&&line>=1?line:null}function codeBlockLineKeyAction(key,line,total){if(key==="Enter"||key===" ")return{kind:"activate"};let next=null;return key==="ArrowDown"?next=Math.min(total,line+1):key==="ArrowUp"?next=Math.max(1,line-1):key==="Home"?next=1:key==="End"&&(next=total),next===null||next===line?null:{kind:"move",line:next}}function codeBlockLineAnchor(range){const lineOf=node=>{const attr=(node.nodeType===Node.ELEMENT_NODE?node:node.parentElement)?.closest("[data-line]")?.getAttribute("data-line");return attr==null?null:Number(attr)},start=lineOf(range.startContainer),end=lineOf(range.endContainer);return start===null||end===null?null:{kind:"line-range",start:Math.min(start,end),end:Math.max(start,end)}}function codeBlockNeedsHighlightResync(changed){return changed.has("code")||changed.has("language")||changed.has("languages")||changed.has("languageLoaders")||changed.has("lineNumbers")||changed.has("activatableLines")}function codeBlockShowsSkeleton(shikiReady,language,loaderPending){return!shikiReady&&!!language&&loaderPending}function applyCodeBlockAriaBusy(host,showingSkeleton){showingSkeleton?host.setAttribute("aria-busy","true"):host.removeAttribute("aria-busy")}function tokenizeCodeBlock(hl,options){return highlightToHtml(hl,options.code,options.lang,[codeBlockLineTransformer(options)])}function parseHighlightLines(spec,maxLine=Number.MAX_SAFE_INTEGER){const lines=new Set;for(const raw of spec.split(",")){const segment=raw.trim();if(!segment)continue;const rangeMatch=/^(\d+)\s*-\s*(\d+)$/.exec(segment);if(rangeMatch){const a=Number(rangeMatch[1]),b=Number(rangeMatch[2]);addBoundedLineRange(lines,a,b,maxLine);continue}const single=/^(\d+)$/.exec(segment);if(single){addBoundedLineRange(lines,Number(single[1]),Number(single[1]),maxLine);continue}devWarnOnce(INVALID_HIGHLIGHT_LINES_WARNING_KEY,INVALID_HIGHLIGHT_LINES_WARNING)}return lines}function codeBlockLineTransformer(options){return{name:"lr-code-block-parts",pre(node){if(node.properties.part=["pre"],options.lineNumbers){const classValue=node.properties.class,classes=Array.isArray(classValue)?classValue.map(String):classValue?[String(classValue)]:[];node.properties.class=[...classes,"line-numbers"]}delete node.properties.tabindex},code(node){node.properties.part=["code"]},line(node,line){node.properties["data-line"]=String(line);const contentNode=node;let gutter;options.activatableLines&&options.lineNumbers?gutter={type:"element",tagName:"button",properties:{type:"button",class:["line-gutter"],part:["line-button"],"data-line":String(line),tabindex:String(options.focusedLine===line?0:-1),"aria-label":options.lineLabel(line)},children:[{type:"text",value:options.lineNumberText(line)}]}:options.lineNumbers&&(gutter={type:"element",tagName:"span",properties:{class:["line-number"],"aria-hidden":"true"},children:[{type:"text",value:options.lineNumberText(line)}]});const source={type:"element",tagName:"span",properties:{class:["line-source"]},children:contentNode.children??[]};contentNode.children=gutter?[gutter,source]:[source],options.highlightedLines.has(line)&&(node.properties.part=["line-highlight"],node.properties["data-highlighted"]=""),options.activeLines.has(line)&&(node.properties["data-active"]="")}}}function renderCodeBlockPlainCode(options){const lines=splitLines(options.code),interactive=options.activatableLines&&options.lineNumbers;return html`<code part="code" class=${options.lineNumbers?"line-numbered-code":nothing} >${lines.map((line,index)=>{const lineNumber=index+1,isHighlighted=options.highlightedLines.has(lineNumber),isActive=options.activeLines.has(lineNumber),part=isHighlighted?"line-highlight":nothing,gutter=interactive?html`<button type="button" class="line-gutter" part="line-button" data-line=${lineNumber} data-inline-handler aria-label=${options.lineLabel(lineNumber)} tabindex=${options.focusedLine===lineNumber?0:-1} @click=${()=>options.onLineActivate(lineNumber)} @keydown=${e=>options.onLineKeyDown(e,lineNumber)} >${options.lineNumberText(lineNumber)}</button>`:options.lineNumbers?html`<span class="line-number" aria-hidden="true" >${options.lineNumberText(lineNumber)}</span
1
+ import{countLines,splitLines}from"../../../internal/text-lines.js";import{isRepeatedActivationKey,shouldIgnoreNavigationKey}from"../../../internal/list-navigation.js";import{RecordCopyFeedback}from"../../../internal/record-copy-feedback.js";import{normalizeLabel}from"../../../internal/accessible-name.js";import{OwnedMutationObserver}from"../../../internal/owned-observer.js";import{highlightToHtml}from"../../../internal/shiki/tokenize.js";import{html,nothing}from"lit";import{unsafeHTML}from"lit/directives/unsafe-html.js";import{activeElementIn,shadowFocusTarget}from"../../../internal/active-element.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{checkIcon,chevronIcon,copyIcon,errorCircleIcon}from"../../../internal/icons.js";import{motionScrollBehavior}from"../../../internal/motion.js";import{styleMap}from"lit/directives/style-map.js";import{sanitizeCssLength}from"../../../internal/safe-css.js";import{observeTextSelection}from"../../../internal/text-selection-observer.js";import{ref}from"lit/directives/ref.js";import{normalizeShikiLanguage}from"./shiki-types.js";import{resolveIsDarkTheme}from"../../../internal/shiki/dark-theme.js";const INVALID_HIGHLIGHT_LINES_WARNING_KEY="lyra-code-block-invalid-highlight-lines",INVALID_HIGHLIGHT_LINES_WARNING="<lr-code-block> and <lr-code-block-core>: invalid highlight-lines entries are ignored; use one-based line numbers or ranges such as `3-5,7`.";function codeBlockCopyLabel(localize,justCopied,copyFailed){return localize(copyFailed?"copyFailed":justCopied?"copiedToClipboard":"copyCode")}function codeBlockCopyGlyph(justCopied,copyFailed){return copyFailed?html`<span part="copy-button__error-icon" class="copy-glyph" aria-hidden="true">${errorCircleIcon()}</span>`:justCopied?html`<span part="copy-button__success-icon" class="copy-glyph" aria-hidden="true">${checkIcon()}</span>`:html`<span part="copy-button__copy-icon" class="copy-glyph" aria-hidden="true">${copyIcon()}</span>`}function codeBlockBodyLabel(localize,filename,language){return normalizeLabel(filename)??(language?localize("codeRegionWithLanguage",void 0,{language}):localize("codeRegion"))}function addBoundedLineRange(lines,start,end,maxLine){if(!Number.isFinite(start)||!Number.isFinite(end)||maxLine<1)return;const low=Math.max(1,Math.min(Math.trunc(start),Math.trunc(end))),high=Math.min(Math.trunc(maxLine),Math.max(Math.trunc(start),Math.trunc(end)));for(let line=low;line<=high;line++)lines.add(line)}function codeBlockLineCount(code){return countLines(code)}function clampCodeBlockFocusedLine(focusedLine,lineCount){return Math.min(Math.max(1,focusedLine),lineCount)}function codeBlockLineHasFocus(host){return shadowFocusTarget(host)?.matches('[data-line][part~="line-button"]')??!1}function restoreCodeBlockLineFocus(host,line){const shadowActive=shadowFocusTarget(host);if(shadowActive)return shadowActive.matches('[data-line][part~="line-button"]');const documentActive=activeElementIn(host.ownerDocument);if(documentActive&&documentActive!==host.ownerDocument.body&&documentActive!==host)return!1;const target=host.renderRoot.querySelector(`[data-line="${line}"][part~="line-button"]`);return target?.focus(),shadowFocusTarget(host)===target}function codeBlockLineHighlightSet(highlightLines,highlights,maxLine){const merged=parseHighlightLines(highlightLines,maxLine);if(!Array.isArray(highlights))return merged;for(const highlight of highlights){const anchor=lineRangeAnchor(highlight);if(!anchor)continue;const end=anchor.end??anchor.start;addBoundedLineRange(merged,anchor.start,end,maxLine)}return merged}function lineRangeAnchor(value){try{if(value===null||typeof value!="object"||Array.isArray(value))return;const anchor=value.anchor;return anchor===null||typeof anchor!="object"||Array.isArray(anchor)?void 0:anchor.kind==="line-range"?anchor:void 0}catch{return}}function lineRangeAnchorById(highlights,id){if(Array.isArray(highlights))for(const highlight of highlights)try{if(highlight!==null&&typeof highlight=="object"&&highlight.id===id){const anchor=lineRangeAnchor(highlight);if(anchor)return anchor}}catch{}}function codeBlockActiveHighlightLineSet(highlights,activeHighlightId,maxLine){const result=new Set,anchor=lineRangeAnchorById(highlights,activeHighlightId);if(!anchor)return result;const end=anchor.end??anchor.start;return addBoundedLineRange(result,anchor.start,end,maxLine),result}function codeBlockPreSuppliedGrammar(languages,language){const normalized=normalizeShikiLanguage(language);return languages?.[normalized]??languages?.[language]}async function scrollCodeBlockToAnchor(host,target){const anchor=typeof target=="string"?lineRangeAnchorById(host.highlights,target):target;if(!anchor||anchor.kind!=="line-range"||anchor.start<1||anchor.start>codeBlockLineCount(host.sourceCode??""))return!1;await host.updateComplete;const body=host.renderRoot.querySelector('[part="body"]'),lineEl=host.renderRoot.querySelector(`[data-line="${anchor.start}"]`);if(!body||!lineEl)return!1;const offset=lineEl.offsetTop-body.clientHeight/2,behavior=body.ownerDocument.defaultView?motionScrollBehavior(body):"instant";return body.scrollTo({top:Math.max(0,offset),behavior}),!0}function codeBlockEventLine(e){const target=e.composedPath()[0];if(typeof target!="object"||target===null||target.nodeType!==1||typeof target.localName!="string"||typeof target.closest!="function")return null;const lineElement=target.closest('[data-line][part~="line-button"]'),line=Number(lineElement?.dataset.line);return Number.isInteger(line)&&line>=1?line:null}function codeBlockLineKeyAction(key,line,total){if(key==="Enter"||key===" ")return{kind:"activate"};let next=null;return key==="ArrowDown"?next=Math.min(total,line+1):key==="ArrowUp"?next=Math.max(1,line-1):key==="Home"?next=1:key==="End"&&(next=total),next===null||next===line?null:{kind:"move",line:next}}function codeBlockLineAnchor(range){const lineOf=node=>{const attr=(node.nodeType===Node.ELEMENT_NODE?node:node.parentElement)?.closest("[data-line]")?.getAttribute("data-line");return attr==null?null:Number(attr)},start=lineOf(range.startContainer),end=lineOf(range.endContainer);return start===null||end===null?null:{kind:"line-range",start:Math.min(start,end),end:Math.max(start,end)}}function codeBlockNeedsHighlightResync(changed){return changed.has("code")||changed.has("slottedCode")||changed.has("language")||changed.has("languages")||changed.has("languageLoaders")||changed.has("lineNumbers")||changed.has("activatableLines")}function codeBlockShowsSkeleton(shikiReady,language,loaderPending){return!shikiReady&&!!language&&loaderPending}function applyCodeBlockAriaBusy(host,showingSkeleton){showingSkeleton?host.setAttribute("aria-busy","true"):host.removeAttribute("aria-busy")}function tokenizeCodeBlock(hl,options){return highlightToHtml(hl,options.code,options.lang,[codeBlockLineTransformer(options),codeBlockTokenTransformer()],{includeExplanation:"scopeName"})}const CODE_TOKEN_SCOPES=[["markup.inserted","inserted"],["markup.deleted","deleted"],["comment","comment"],["punctuation.definition.comment","comment"],["markup.quote","comment"],["entity.other.attribute-name.class","selector"],["entity.other.attribute-name.id","selector"],["entity.other.attribute-name.pseudo-class","selector"],["entity.other.attribute-name.pseudo-element","selector"],["meta.selector","selector"],["entity.other.attribute-name","property"],["entity.name.tag","tag"],["support.type.property-name","property"],["meta.object-literal.key","property"],["variable.other.property","property"],["variable.other.object.property","property"],["entity.name.function","function"],["support.function","function"],["meta.decorator","function"],["variable.parameter.keyframe-list","function"],["entity.name.type","type"],["entity.name.class","type"],["entity.name.namespace","type"],["entity.other.inherited-class","type"],["support.type","type"],["support.class","type"],["string.regexp","string"],["string","string"],["markup.underline.link","string"],["markup.inline.raw","string"],["markup.raw","string"],["constant","constant"],["support.constant","constant"],["keyword.other.unit","constant"],["punctuation.definition.template-expression","variable"],["punctuation.section.embedded","variable"],["variable","variable"],["keyword.operator","operator"],["punctuation","operator"],["keyword","keyword"],["storage","keyword"],["meta.tag.sgml.doctype","keyword"],["markup.heading","keyword"],["entity.name.section","keyword"]];function scopeCategory(scope){for(const[prefix,category]of CODE_TOKEN_SCOPES)if(scope===prefix||scope.startsWith(prefix)&&scope.charAt(prefix.length)===".")return category}function codeTokenCategory(scopes){for(let index=scopes.length-1;index>=0;index-=1){const category=scopeCategory(scopes[index]);if(category)return category}}const LIGHT_COLOR=/(?:^|;)\s*color\s*:\s*([^;]+)/u;function codeBlockTokenTransformer(){return{name:"lr-code-block-tokens",span(node,_line,_col,_lineElement,token){let best,weight=0;for(const piece of token.explanation??[]){const size=piece.content.replace(/\s+/gu,"").length;if(size<=weight)continue;const category=codeTokenCategory(piece.scopes.map(scope=>scope.scopeName));category&&(best=category,weight=size)}if(!best)return;node.properties["data-token"]=best;const style=node.properties.style;if(typeof style!="string")return;const light=LIGHT_COLOR.exec(style)?.[1]?.trim();light&&(node.properties.style=`${style};--_lr-token-color:${light}`)}}}function parseHighlightLines(spec,maxLine=Number.MAX_SAFE_INTEGER){const lines=new Set;for(const raw of spec.split(",")){const segment=raw.trim();if(!segment)continue;const rangeMatch=/^(\d+)\s*-\s*(\d+)$/.exec(segment);if(rangeMatch){const a=Number(rangeMatch[1]),b=Number(rangeMatch[2]);addBoundedLineRange(lines,a,b,maxLine);continue}const single=/^(\d+)$/.exec(segment);if(single){addBoundedLineRange(lines,Number(single[1]),Number(single[1]),maxLine);continue}devWarnOnce(INVALID_HIGHLIGHT_LINES_WARNING_KEY,INVALID_HIGHLIGHT_LINES_WARNING)}return lines}function codeBlockLineTransformer(options){return{name:"lr-code-block-parts",pre(node){if(node.properties.part=["pre"],options.lineNumbers){const classValue=node.properties.class,classes=Array.isArray(classValue)?classValue.map(String):classValue?[String(classValue)]:[];node.properties.class=[...classes,"line-numbers"]}delete node.properties.tabindex},code(node){node.properties.part=["code"]},line(node,line){node.properties["data-line"]=String(line);const contentNode=node;let gutter;options.activatableLines&&options.lineNumbers?gutter={type:"element",tagName:"button",properties:{type:"button",class:["line-gutter"],part:["line-button"],"data-line":String(line),tabindex:String(options.focusedLine===line?0:-1),"aria-label":options.lineLabel(line)},children:[{type:"text",value:options.lineNumberText(line)}]}:options.lineNumbers&&(gutter={type:"element",tagName:"span",properties:{class:["line-number"],"aria-hidden":"true"},children:[{type:"text",value:options.lineNumberText(line)}]});const source={type:"element",tagName:"span",properties:{class:["line-source"]},children:contentNode.children??[]};contentNode.children=gutter?[gutter,source]:[source],options.highlightedLines.has(line)&&(node.properties.part=["line-highlight"],node.properties["data-highlighted"]=""),options.activeLines.has(line)&&(node.properties["data-active"]="")}}}function renderCodeBlockPlainCode(options){const lines=splitLines(options.code),interactive=options.activatableLines&&options.lineNumbers;return html`<code part="code" class=${options.lineNumbers?"line-numbered-code":nothing} >${lines.map((line,index)=>{const lineNumber=index+1,isHighlighted=options.highlightedLines.has(lineNumber),isActive=options.activeLines.has(lineNumber),part=isHighlighted?"line-highlight":nothing,gutter=interactive?html`<button type="button" class="line-gutter" part="line-button" data-line=${lineNumber} data-inline-handler aria-label=${options.lineLabel(lineNumber)} tabindex=${options.focusedLine===lineNumber?0:-1} @click=${()=>options.onLineActivate(lineNumber)} @keydown=${e=>options.onLineKeyDown(e,lineNumber)} >${options.lineNumberText(lineNumber)}</button>`:options.lineNumbers?html`<span class="line-number" aria-hidden="true" >${options.lineNumberText(lineNumber)}</span
2
2
  >`:nothing,lineTemplate=html`<span class="line" part=${part} data-line=${lineNumber} ?data-highlighted=${isHighlighted} ?data-active=${isActive} >${gutter}<span class="line-source">${line}</span></span
3
3
  >`;return index>0?html`${`
4
4
  `}${lineTemplate}`:lineTemplate})}</code
@@ -12,9 +12,10 @@ import{countLines,splitLines}from"../../../internal/text-lines.js";import{isRepe
12
12
  ${options.filename?html`<span part="filename"><bdi>${options.filename}</bdi></span>`:nothing}
13
13
  ${options.language?html`<span part="language">${options.language}</span>`:nothing}
14
14
  ${options.copyable?html`
15
- <lr-icon-button part=${options.copyAppearance==="icon"?"copy-button copy-button-icon":"copy-button copy-button-text"} exportparts="button:copy-button-control" aria-label=${codeBlockCopyLabel(options.localize,options.justCopied,options.copyFailed)} @click=${options.onCopy} >
16
- ${options.copyAppearance==="icon"?copyIcon():options.copyFailed?options.localize("copyFailed"):options.justCopied?options.localize("copied"):options.localize("copy")}
15
+ <lr-icon-button part=${options.copyAppearance==="icon"?"copy-button copy-button-icon":"copy-button copy-button-text"} exportparts="button:copy-button-control, button:copy-button__button" aria-label=${codeBlockCopyLabel(options.localize,options.justCopied,options.copyFailed)} @click=${options.onCopy} >
16
+ ${options.copyAppearance==="icon"?codeBlockCopyGlyph(options.justCopied,options.copyFailed):options.copyFailed?options.localize("copyFailed"):options.justCopied?options.localize("copied"):options.localize("copy")}
17
17
  </lr-icon-button>
18
+ <span part="copy-button__feedback" class="copy-feedback" aria-hidden="true">${options.copyFailed?options.localize("copyFailed"):options.justCopied?options.localize("copiedToClipboard"):""}</span>
18
19
  `:nothing}
19
20
  <span part="header-actions" ?hidden=${!options.hasHeaderActions}><slot name="header-actions"></slot></span>
20
21
  </div>
@@ -26,4 +27,4 @@ import{countLines,splitLines}from"../../../internal/text-lines.js";import{isRepe
26
27
  ${options.highlightLimited?html`<div part="limit" role="note">${options.localize("codeBlockHighlightLimit")}</div>`:nothing}
27
28
  </div>
28
29
  </div>
29
- `}class CodeBlockInteractionController{needsHighlightResync(changed,locale,lineLabel){const localizationChanged=this.highlightedLocale!==locale||this.highlightedLineLabel!==lineLabel;return this.highlightedLocale=locale,this.highlightedLineLabel=lineLabel,localizationChanged||codeBlockNeedsHighlightResync(changed)}constructor(options){this.options=options,this.lineButtons=new Map,this.focusedLine=1,this.countedLines=1,this.copy=()=>this.feedback.write(this.options.host.code??""),this.onLineActivate=line=>{this.setFocusedLine(line),this.options.emitLineActivate(line)},this.onLineKeyDown=(e,line)=>{if(e.defaultPrevented||shouldIgnoreNavigationKey(e))return;if((e.key==="Enter"||e.key===" ")&&isRepeatedActivationKey(e)){e.preventDefault();return}const{host}=this.options;host.code!==this.countedCode&&(this.countedCode=host.code,this.countedLines=codeBlockLineCount(host.code??""));const action=codeBlockLineKeyAction(e.key,line,this.countedLines);if(action===null)return;if(e.preventDefault(),action.kind==="activate"){this.onLineActivate(line);return}const next=action.line;this.setFocusedLine(next),host.updateComplete.then(()=>{this.lineButtons.get(next)?.focus()})},this.onBodyClick=e=>{if(e.composedPath()[0]?.closest?.("button[data-inline-handler]"))return;const line=codeBlockEventLine(e);line!==null&&this.onLineActivate(line)},this.onBodyKeyDown=e=>{if(e.composedPath()[0]?.closest?.("button[data-inline-handler]"))return;const line=codeBlockEventLine(e);line!==null&&this.onLineKeyDown(e,line)},this.onBodyFocusIn=e=>{const line=codeBlockEventLine(e);line!==null&&this.setFocusedLine(line)},this.bindSelectionBody=body=>{this.releaseSelection?.(),this.releaseSelection=body&&observeTextSelection(this.options.host,body,(range,text,rects)=>{const anchor=codeBlockLineAnchor(range);anchor&&this.options.emitTextSelect({text,anchor,rects})},void 0,{mouseup:!0,legacyFallback:!0})},this.feedback=new RecordCopyFeedback(options.host,()=>options.host.code??"",options.reportCopy,status=>{options.setJustCopied(status==="success"),options.setCopyFailed(status==="error")})}cancelCopyTimer(){this.feedback.cancelTimer()}disconnect(){this.feedback.reset()}refreshTheme(){this.options.setDarkTheme(resolveIsDarkTheme(this.options.host))}setFocusedLine(line){line!==this.focusedLine&&(this.lineButtons.get(this.focusedLine)?.setAttribute("tabindex","-1"),this.focusedLine=line,this.options.setFocusedLine(line),this.lineButtons.get(line)?.setAttribute("tabindex","0"))}syncLineButtons(focusedLine,force=!1){const source=this.options.host.renderRoot.querySelector("code");if(!(!force&&source===this.lineSource)){this.lineSource=source,this.lineButtons.clear(),this.focusedLine=focusedLine,this.countedCode=this.options.host.code,this.countedLines=codeBlockLineCount(this.countedCode??"");for(const button of source?.querySelectorAll('[part~="line-button"][data-line]')??[]){const line=Number(button.dataset.line);this.lineButtons.set(line,button),button.tabIndex=line===focusedLine?0:-1}}}}function codeBlockHasHeaderActions(host){return Array.from(host.children).some(child=>child.getAttribute("slot")==="header-actions")}class CodeBlockHeaderActionsController{constructor(options){this.options=options,this.observing=!1,this.observer=new OwnedMutationObserver(options.host,()=>this.sync())}sync(){this.options.setHasHeaderActions(codeBlockHasHeaderActions(this.options.host))}observe(){this.observing||(this.observing=!0,this.sync(),this.observer.observe(this.options.host,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}disconnect(){this.observer.clear(),this.observing=!1}}export{CodeBlockHeaderActionsController,CodeBlockInteractionController,applyCodeBlockAriaBusy,clampCodeBlockFocusedLine,codeBlockActiveHighlightLineSet,codeBlockEventLine,codeBlockLineCount,codeBlockLineHasFocus,codeBlockLineHighlightSet,codeBlockLineTransformer,codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton,parseHighlightLines,renderCodeBlockPlainCode,renderCodeBlockShell,restoreCodeBlockLineFocus,scrollCodeBlockToAnchor,tokenizeCodeBlock};
30
+ `}class CodeBlockInteractionController{needsHighlightResync(changed,locale,lineLabel){const localizationChanged=this.highlightedLocale!==locale||this.highlightedLineLabel!==lineLabel;return this.highlightedLocale=locale,this.highlightedLineLabel=lineLabel,localizationChanged||codeBlockNeedsHighlightResync(changed)}constructor(options){this.options=options,this.lineButtons=new Map,this.focusedLine=1,this.countedLines=1,this.copy=()=>this.feedback.write(this.options.host.sourceCode??""),this.onLineActivate=line=>{this.setFocusedLine(line),this.options.emitLineActivate(line)},this.onLineKeyDown=(e,line)=>{if(e.defaultPrevented||shouldIgnoreNavigationKey(e))return;if((e.key==="Enter"||e.key===" ")&&isRepeatedActivationKey(e)){e.preventDefault();return}const{host}=this.options;host.sourceCode!==this.countedCode&&(this.countedCode=host.sourceCode,this.countedLines=codeBlockLineCount(host.sourceCode??""));const action=codeBlockLineKeyAction(e.key,line,this.countedLines);if(action===null)return;if(e.preventDefault(),action.kind==="activate"){this.onLineActivate(line);return}const next=action.line;this.setFocusedLine(next),host.updateComplete.then(()=>{this.lineButtons.get(next)?.focus()})},this.onBodyClick=e=>{if(e.composedPath()[0]?.closest?.("button[data-inline-handler]"))return;const line=codeBlockEventLine(e);line!==null&&this.onLineActivate(line)},this.onBodyKeyDown=e=>{if(e.composedPath()[0]?.closest?.("button[data-inline-handler]"))return;const line=codeBlockEventLine(e);line!==null&&this.onLineKeyDown(e,line)},this.onBodyFocusIn=e=>{const line=codeBlockEventLine(e);line!==null&&this.setFocusedLine(line)},this.bindSelectionBody=body=>{this.releaseSelection?.(),this.releaseSelection=body&&observeTextSelection(this.options.host,body,(range,text,rects)=>{const anchor=codeBlockLineAnchor(range);anchor&&this.options.emitTextSelect({text,anchor,rects})},void 0,{mouseup:!0,legacyFallback:!0})},this.feedback=new RecordCopyFeedback(options.host,()=>options.host.sourceCode??"",options.reportCopy,status=>{options.setJustCopied(status==="success"),options.setCopyFailed(status==="error")})}cancelCopyTimer(){this.feedback.cancelTimer()}disconnect(){this.feedback.reset()}refreshTheme(){this.options.setDarkTheme(resolveIsDarkTheme(this.options.host))}setFocusedLine(line){line!==this.focusedLine&&(this.lineButtons.get(this.focusedLine)?.setAttribute("tabindex","-1"),this.focusedLine=line,this.options.setFocusedLine(line),this.lineButtons.get(line)?.setAttribute("tabindex","0"))}syncLineButtons(focusedLine,force=!1){const source=this.options.host.renderRoot.querySelector("code");if(!(!force&&source===this.lineSource)){this.lineSource=source,this.lineButtons.clear(),this.focusedLine=focusedLine,this.countedCode=this.options.host.sourceCode,this.countedLines=codeBlockLineCount(this.countedCode??"");for(const button of source?.querySelectorAll('[part~="line-button"][data-line]')??[]){const line=Number(button.dataset.line);this.lineButtons.set(line,button),button.tabIndex=line===focusedLine?0:-1}}}}function codeBlockHasHeaderActions(host){return Array.from(host.children).some(child=>child.getAttribute("slot")==="header-actions")}class CodeBlockHeaderActionsController{constructor(options){this.options=options,this.observing=!1,this.observer=new OwnedMutationObserver(options.host,()=>this.sync())}sync(){this.options.setHasHeaderActions(codeBlockHasHeaderActions(this.options.host))}observe(){this.observing||(this.observing=!0,this.sync(),this.observer.observe(this.options.host,{childList:!0,attributes:!0,attributeFilter:["slot"],subtree:!0}))}disconnect(){this.observer.clear(),this.observing=!1}}export{CodeBlockHeaderActionsController,CodeBlockInteractionController,applyCodeBlockAriaBusy,clampCodeBlockFocusedLine,codeBlockActiveHighlightLineSet,codeBlockEventLine,codeBlockLineCount,codeBlockLineHasFocus,codeBlockLineHighlightSet,codeBlockLineTransformer,codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton,parseHighlightLines,renderCodeBlockPlainCode,renderCodeBlockShell,restoreCodeBlockLineFocus,scrollCodeBlockToAnchor,tokenizeCodeBlock};
@@ -1,4 +1,4 @@
1
- import{type ShikiLanguageInput,type ShikiLanguageLoader}from'./shiki-types.js';import type{PropertyValues}from'lit';import type{LyraCodeBlockCopyAppearance}from'./code-block-shared.js';import{LyraCodeBlockBase,type LyraCodeBlockBaseEventMap}from'./code-block-base.class.js';export type{LyraCodeBlockToggleDetail}from'./code-block-shared.js';import type{LyraAnchor,LyraHighlight}from'../../../internal/document-anchors.js';import'../../overlays/skeleton/skeleton.class.js';export interface LyraCodeBlockEventMap extends LyraCodeBlockBaseEventMap{}
1
+ import{type ShikiLanguageInput,type ShikiLanguageLoader}from'./shiki-types.js';import type{PropertyValues}from'lit';import type{LyraCodeBlockCopyAppearance}from'./code-block-shared.js';import{LyraCodeBlockBase,type LyraCodeBlockBaseEventMap}from'./code-block-base.class.js';export type{LyraCodeBlockToggleDetail}from'./code-block-shared.js';export type{LyraCodeBlockLoadDetail}from'./code-block-base.class.js';import type{LyraAnchor,LyraHighlight}from'../../../internal/document-anchors.js';import'../../overlays/skeleton/skeleton.class.js';export interface LyraCodeBlockEventMap extends LyraCodeBlockBaseEventMap{}
2
2
  /**
3
3
  * `<lr-code-block>` — fenced code display with optional lazy syntax
4
4
  * highlighting and a copy button. No highlighting grammar ships in this
@@ -45,6 +45,13 @@ import{type ShikiLanguageInput,type ShikiLanguageLoader}from'./shiki-types.js';i
45
45
  * from `languages` still falls back to the ordinary dynamic-import path
46
46
  * unchanged, so this is a partial opt-in, not a replacement for it.
47
47
  *
48
+ * Source can also be given as the element's light-DOM text (text nodes, a `<script type="text/plain">`
49
+ * or a `<template>`; children with a `slot` attribute are excluded). It is dedented, and
50
+ * `without-dedent` keeps it as written apart from the newline right after the opening tag. A
51
+ * non-empty `code` property wins and is never dedented. `wrap` wraps long lines instead of
52
+ * scrolling; both plain and highlighted rendering honor it. `label` aliases the host `aria-label`
53
+ * and `without-copy` aliases `without-copy-button`.
54
+ *
48
55
  * Adopts the `line-range` slice of this library's shared anchor-target contract:
49
56
  * `highlights`/`activeHighlightId` paint (and `highlight-lines` additionally marks) per-line
50
57
  * emphasis in both the shiki and plain-text-fallback rendering paths identically, and
@@ -65,7 +72,13 @@ import{type ShikiLanguageInput,type ShikiLanguageLoader}from'./shiki-types.js';i
65
72
  * @customElement lr-code-block
66
73
  * @event lr-copy - The raw `code` was written to the clipboard. Frozen detail:
67
74
  * `{ ok: true, text }`.
75
+ * @slot - The code to display, as text (or a `<script type="text/plain">` or `<template>`) when
76
+ * `code` is empty. Read as source rather than projected; dedented unless `without-dedent`.
68
77
  * @event lr-error - Clipboard writing failed; generic no-detail notification.
78
+ * @event lr-load - Highlighting settled for the current `language`. `detail: { highlighted }` is
79
+ * `true` when the grammar loaded and the code was highlighted (fired again each time new
80
+ * highlighted output replaces the old), and `false` once when no grammar exists and the code
81
+ * renders as plain text, alongside `:state(error)`.
69
82
  * @event lr-copy-error - Clipboard writing failed. Frozen detail:
70
83
  * `{ ok: false, text, reason, error }`, where `reason` is
71
84
  * `'unsupported' | 'denied' | 'failed'`.
@@ -94,6 +107,17 @@ import{type ShikiLanguageInput,type ShikiLanguageLoader}from'./shiki-types.js';i
94
107
  * @csspart copy-button-icon - The copy control while `copyAppearance` is `'icon'`.
95
108
  * @csspart copy-button-control - The copy control's own native `<button>`, forwarded because the
96
109
  * painted surface sits one shadow boundary deeper than `copy-button`.
110
+ * @csspart copy-button__button - Alias of `copy-button-control`.
111
+ * @csspart copy-button__copy-icon - The copy glyph at rest while `copyAppearance` is `'icon'`.
112
+ * @csspart copy-button__success-icon - The check glyph after a successful copy while
113
+ * `copyAppearance` is `'icon'`.
114
+ * @csspart copy-button__error-icon - The error glyph after a failed copy while `copyAppearance` is
115
+ * `'icon'`.
116
+ * @csspart copy-button__feedback - Visually hidden, `aria-hidden` mirror of the copy outcome text;
117
+ * empty at rest.
118
+ * @cssstate loading - A `language` is set and its grammar (or the highlighter) is still loading.
119
+ * @cssstate error - No grammar exists for the current `language`; the code renders as plain text.
120
+ * @cssstate highlighted - The code is rendered with syntax highlighting.
97
121
  * @csspart header-actions - The wrapper around the `header-actions` slot, at the trailing end of
98
122
  * the header row.
99
123
  * @slot header-actions - Extra controls for the header row, rendered after the copy control. Their
@@ -113,8 +137,28 @@ import{type ShikiLanguageInput,type ShikiLanguageLoader}from'./shiki-types.js';i
113
137
  * @csspart line-button - A gutter line-number button, only rendered while `activatable-lines` and
114
138
  * `line-numbers` are both set.
115
139
  * @cssprop [--lr-code-block-padding=var(--lr-space-s) var(--lr-space-m)] - Code padding.
140
+ * @cssprop --comment-color - Color of highlighted comments and quotes. Unset keeps the theme color.
141
+ * @cssprop --keyword-color - Color of highlighted keywords, storage modifiers, doctypes and headings. Unset keeps the theme color.
142
+ * @cssprop --operator-color - Color of highlighted operators and punctuation. Unset keeps the theme color.
143
+ * @cssprop --string-color - Color of highlighted strings, regular expressions, links and raw text. Unset keeps the theme color.
144
+ * @cssprop --constant-color - Color of highlighted numbers, booleans, constants and entities. Unset keeps the theme color.
145
+ * @cssprop --function-color - Color of highlighted functions and decorators. Unset keeps the theme color.
146
+ * @cssprop --type-color - Color of highlighted types, classes and built-ins. Unset keeps the theme color.
147
+ * @cssprop --variable-color - Color of highlighted variables and interpolations. Unset keeps the theme color.
148
+ * @cssprop --property-color - Color of highlighted properties, keys and attribute names. Unset keeps the theme color.
149
+ * @cssprop --tag-color - Color of highlighted markup tags. Unset keeps the theme color.
150
+ * @cssprop --selector-color - Color of highlighted CSS selectors. Unset keeps the theme color.
151
+ * @cssprop --inserted-color - Color of highlighted inserted diff lines. Unset keeps the theme color.
152
+ * @cssprop --deleted-color - Color of highlighted deleted diff lines. Unset keeps the theme color.
116
153
  * @cssprop [--lr-code-block-radius=var(--lr-radius)] - Frame corner radius.
154
+ * @cssprop [--lr-code-block-border=var(--lr-border-width-thin) solid var(--lr-color-border-subtle)] -
155
+ * Frame border shorthand.
156
+ * @cssprop [--lr-code-block-bg=var(--lr-color-surface)] - Frame and plain-code fill; highlighted
157
+ * code paints its theme background over it.
117
158
  * @cssprop [--lr-code-block-header-bg=var(--lr-color-surface)] - Header background.
159
+ * @cssprop [--lr-code-block-header-padding=var(--lr-space-xs) var(--lr-space-s)] - Header padding.
160
+ * @cssprop [--lr-code-block-header-border=var(--lr-border-width-thin) solid var(--lr-color-border-subtle)] -
161
+ * Rule between the header and the code (shorthand).
118
162
  * @cssprop [--lr-code-block-header-color=var(--lr-color-text)] - Filename color.
119
163
  * @cssprop [--lr-code-block-toggle-bg=transparent] - Disclosure control background at rest.
120
164
  * @cssprop [--lr-code-block-toggle-hover-bg=var(--lr-color-brand-quiet)] - Disclosure control hover background.
@@ -230,6 +274,7 @@ readonly anchorKinds:readonly LyraAnchor['kind'][];
230
274
  * this granular type-only import emits no registration side effect. */
231
275
  languages?:Readonly<Record<string,ShikiLanguageInput>>;
232
276
  /** Optional lazy grammar loaders, resolved only when their language is requested. Concrete
233
- * `languages` entries take priority on duplicate keys. Unset preserves the default highlighter
277
+ * `languages` entries take priority on duplicate keys. Both maps win over grammars registered
278
+ * library-wide with `registerCodeGrammar()`. Unset preserves the default highlighter
234
279
  * and concrete-grammar paths. Assign a new map object after changing entries. */
235
- languageLoaders?:Readonly<Record<string,ShikiLanguageLoader>>;private highlighter?;private defaultHighlighterLoading;connectedCallback():void;protected beforeHighlightUpdate(changed:PropertyValues):void;private ensureDefaultHighlighter;protected preSuppliedGrammar():ShikiLanguageInput|undefined;protected hasPreSuppliedGrammar():boolean;protected showsSkeleton():boolean;protected syncHighlight():void;}declare global{interface HTMLElementTagNameMap{'lr-code-block':LyraCodeBlock;}}
280
+ languageLoaders?:Readonly<Record<string,ShikiLanguageLoader>>;private highlighter?;private defaultHighlighterLoading;connectedCallback():void;protected beforeHighlightUpdate(changed:PropertyValues):void;private ensureDefaultHighlighter;protected preSuppliedGrammar():ShikiLanguageInput|undefined;private effectiveLanguages;protected hasPreSuppliedGrammar():boolean;protected refreshRegisteredGrammar():void;protected showsSkeleton():boolean;protected syncHighlight():void;}declare global{interface HTMLElementTagNameMap{'lr-code-block':LyraCodeBlock;}}
@@ -1 +1 @@
1
- import{__decorate}from"tslib";import{combineShikiLanguageSources}from"../../../internal/shiki-language-sources.js";import{resolvedShikiLanguages,ensureShikiLanguageLoaded}from"./shiki-types.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{snapshotLyraHighlights}from"../../../internal/highlight-collection.js";import{loadShikiHighlighter,loadShikiLanguage,loadShikiHighlighterCore,normalizeShikiLanguage,shikiHasLoadedLanguage}from"./code-loader.js";import{styles}from"./code-block.styles.js";import{LyraCodeBlockBase}from"./code-block-base.class.js";import{codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton}from"./code-block-shared.js";import"../../overlays/skeleton/skeleton.class.js";import{LYRA_DEFAULT_codeBlockHighlightLimit,LYRA_DEFAULT_codeBlockToggle,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copyCode}from"../../../internal/default-strings/conversation.generated.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";class LyraCodeBlock extends LyraCodeBlockBase{constructor(){super(...arguments),this.code="",this.language="",this.filename="",this.accessibleLabel=null,this.collapsible=!1,this.withoutCopyButton=!1,this.copyAppearance="text",this.maxHeight="",this.lineNumbers=!1,this.highlightLines="",this.activatableLines=!1,this._highlights=snapshotLyraHighlights([]),this.activeHighlightId=null,this.anchorKinds=["line-range"],this.defaultHighlighterLoading=!1}static{this.defaultStrings={...super.defaultStrings,codeBlockHighlightLimit:LYRA_DEFAULT_codeBlockHighlightLimit,codeBlockToggle:LYRA_DEFAULT_codeBlockToggle,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.styles=[LyraElement.styles,styles]}get highlights(){return this._highlights}set highlights(value){const previous=this._highlights;this._highlights=snapshotLyraHighlights(value),this.requestUpdate("highlights",previous)}connectedCallback(){super.connectedCallback(),!this.resumedMove&&(this.ensureDefaultHighlighter(),(this.hasPreSuppliedGrammar()||this.highlighter)&&this.syncHighlight())}beforeHighlightUpdate(changed){(changed.has("code")||changed.has("language")||changed.has("languages")||changed.has("languageLoaders"))&&this.ensureDefaultHighlighter()}ensureDefaultHighlighter(){!this.isConnected||!this.language||this.highlightLimited||this.hasPreSuppliedGrammar()||this.highlighter||this.defaultHighlighterLoading||(this.defaultHighlighterLoading=!0,loadShikiHighlighter().then(hl=>{this.defaultHighlighterLoading=!1,this.isConnected&&(this.highlighter=hl,this.shikiReady=!0,this.syncHighlight())}))}preSuppliedGrammar(){return codeBlockPreSuppliedGrammar(this.languages,this.language??"")}hasPreSuppliedGrammar(){return!!(this.preSuppliedGrammar()||this.languageLoaders&&codeBlockPreSuppliedGrammar(combineShikiLanguageSources(this.languages,this.languageLoaders),this.language??""))}showsSkeleton(){return codeBlockShowsSkeleton(this.shikiReady,this.language,!this.hasPreSuppliedGrammar())}syncHighlight(){const token=++this.highlightToken,lang=normalizeShikiLanguage(this.language??"");if(!lang||this.highlightLimited){this.highlightedHtml=null;return}const languages=combineShikiLanguageSources(this.languages,this.languageLoaders),source=languages?.[lang]??languages?.[this.language];if(languages&&source){this.highlightedHtml=null,loadShikiHighlighterCore(resolvedShikiLanguages(languages)).then(async hl2=>{if(token!==this.highlightToken||!this.isConnected)return;const loaded=hl2&&await ensureShikiLanguageLoaded(hl2,lang,source);token!==this.highlightToken||!this.isConnected||(this.highlightedHtml=loaded&&hl2?this.tokenize(hl2,lang):null)});return}const hl=this.highlighter;if(!hl){this.highlightedHtml=null;return}if(shikiHasLoadedLanguage(hl,lang)){this.highlightedHtml=this.tokenize(hl,lang);return}this.highlightedHtml=null,loadShikiLanguage(hl,lang).then(ok=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=ok?this.tokenize(hl,lang):null)})}}__decorate([property()],LyraCodeBlock.prototype,"code",void 0),__decorate([property()],LyraCodeBlock.prototype,"language",void 0),__decorate([property()],LyraCodeBlock.prototype,"filename",void 0),__decorate([property({attribute:"aria-label"})],LyraCodeBlock.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlock.prototype,"collapsible",void 0),__decorate([property({type:Boolean,attribute:"without-copy-button",reflect:!0})],LyraCodeBlock.prototype,"withoutCopyButton",void 0),__decorate([property({attribute:"copy-appearance",reflect:!0})],LyraCodeBlock.prototype,"copyAppearance",void 0),__decorate([property({attribute:"max-height"})],LyraCodeBlock.prototype,"maxHeight",void 0),__decorate([property({type:Boolean,attribute:"line-numbers",reflect:!0})],LyraCodeBlock.prototype,"lineNumbers",void 0),__decorate([property({attribute:"highlight-lines"})],LyraCodeBlock.prototype,"highlightLines",void 0),__decorate([property({type:Boolean,attribute:"activatable-lines"})],LyraCodeBlock.prototype,"activatableLines",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"highlights",null),__decorate([property({attribute:"active-highlight-id"})],LyraCodeBlock.prototype,"activeHighlightId",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"languages",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"languageLoaders",void 0);export{LyraCodeBlock};
1
+ import{__decorate}from"tslib";import{combineShikiLanguageSources}from"../../../internal/shiki-language-sources.js";import{resolvedShikiLanguages,ensureShikiLanguageLoaded}from"./shiki-types.js";import{withRegisteredCodeGrammars}from"./code-grammar-registry.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{property}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{snapshotLyraHighlights}from"../../../internal/highlight-collection.js";import{loadShikiHighlighter,loadShikiLanguage,loadShikiHighlighterCore,normalizeShikiLanguage,shikiHasLoadedLanguage}from"./code-loader.js";import{styles}from"./code-block.styles.js";import{LyraCodeBlockBase}from"./code-block-base.class.js";import{codeBlockPreSuppliedGrammar,codeBlockShowsSkeleton}from"./code-block-shared.js";import"../../overlays/skeleton/skeleton.class.js";import{LYRA_DEFAULT_codeBlockHighlightLimit,LYRA_DEFAULT_codeBlockToggle,LYRA_DEFAULT_codeRegion,LYRA_DEFAULT_codeRegionWithLanguage,LYRA_DEFAULT_copiedToClipboard,LYRA_DEFAULT_copyCode}from"../../../internal/default-strings/conversation.generated.js";import{LYRA_DEFAULT_copied,LYRA_DEFAULT_copy,LYRA_DEFAULT_copyFailed}from"../../../internal/default-strings/shared.generated.js";class LyraCodeBlock extends LyraCodeBlockBase{constructor(){super(...arguments),this.code="",this.language="",this.filename="",this.accessibleLabel=null,this.collapsible=!1,this.withoutCopyButton=!1,this.copyAppearance="text",this.maxHeight="",this.lineNumbers=!1,this.highlightLines="",this.activatableLines=!1,this._highlights=snapshotLyraHighlights([]),this.activeHighlightId=null,this.anchorKinds=["line-range"],this.defaultHighlighterLoading=!1}static{this.defaultStrings={...super.defaultStrings,codeBlockHighlightLimit:LYRA_DEFAULT_codeBlockHighlightLimit,codeBlockToggle:LYRA_DEFAULT_codeBlockToggle,codeRegion:LYRA_DEFAULT_codeRegion,codeRegionWithLanguage:LYRA_DEFAULT_codeRegionWithLanguage,copied:LYRA_DEFAULT_copied,copiedToClipboard:LYRA_DEFAULT_copiedToClipboard,copy:LYRA_DEFAULT_copy,copyCode:LYRA_DEFAULT_copyCode,copyFailed:LYRA_DEFAULT_copyFailed}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-text-select"])}static{this.styles=[LyraElement.styles,styles]}get highlights(){return this._highlights}set highlights(value){const previous=this._highlights;this._highlights=snapshotLyraHighlights(value),this.requestUpdate("highlights",previous)}connectedCallback(){super.connectedCallback(),!this.resumedMove&&(this.ensureDefaultHighlighter(),(this.hasPreSuppliedGrammar()||this.highlighter)&&this.syncHighlight())}beforeHighlightUpdate(changed){(changed.has("code")||changed.has("slottedCode")||changed.has("language")||changed.has("languages")||changed.has("languageLoaders"))&&this.ensureDefaultHighlighter()}ensureDefaultHighlighter(){!this.isConnected||!this.language||this.highlightLimited||this.hasPreSuppliedGrammar()||this.highlighter||this.defaultHighlighterLoading||(this.defaultHighlighterLoading=!0,loadShikiHighlighter().then(hl=>{this.defaultHighlighterLoading=!1,this.isConnected&&(this.highlighter=hl,this.shikiReady=!0,this.syncHighlight())}))}preSuppliedGrammar(){return codeBlockPreSuppliedGrammar(this.languages,this.language??"")}effectiveLanguages(){return withRegisteredCodeGrammars(combineShikiLanguageSources(this.languages,this.languageLoaders))}hasPreSuppliedGrammar(){if(this.preSuppliedGrammar())return!0;const effective=this.effectiveLanguages();return effective!==this.languages&&!!codeBlockPreSuppliedGrammar(effective,this.language??"")}refreshRegisteredGrammar(){this.ensureDefaultHighlighter(),this.hasPreSuppliedGrammar()||this.highlighter?this.syncHighlight():(this.highlightToken++,this.highlightedHtml=null)}showsSkeleton(){return codeBlockShowsSkeleton(this.shikiReady,this.language,!this.hasPreSuppliedGrammar())}syncHighlight(){const token=++this.highlightToken,lang=normalizeShikiLanguage(this.language??"");if(!lang||this.highlightLimited){this.highlightedHtml=null;return}const languages=this.effectiveLanguages(),source=languages?.[lang]??languages?.[this.language];if(languages&&source){this.highlightedHtml=null,loadShikiHighlighterCore(resolvedShikiLanguages(languages)).then(async hl2=>{if(token!==this.highlightToken||!this.isConnected)return;const loaded=hl2&&await ensureShikiLanguageLoaded(hl2,lang,source);token!==this.highlightToken||!this.isConnected||(this.highlightedHtml=loaded&&hl2?this.tokenize(hl2,lang):null,this.grammarUnavailable=this.highlightedHtml===null)});return}const hl=this.highlighter;if(!hl){this.highlightedHtml=null,hl===null&&(this.grammarUnavailable=!0);return}if(shikiHasLoadedLanguage(hl,lang)){this.highlightedHtml=this.tokenize(hl,lang),this.grammarUnavailable=this.highlightedHtml===null;return}this.highlightedHtml=null,loadShikiLanguage(hl,lang).then(ok=>{token===this.highlightToken&&this.isConnected&&(this.highlightedHtml=ok?this.tokenize(hl,lang):null,this.grammarUnavailable=this.highlightedHtml===null)})}}__decorate([property()],LyraCodeBlock.prototype,"code",void 0),__decorate([property()],LyraCodeBlock.prototype,"language",void 0),__decorate([property()],LyraCodeBlock.prototype,"filename",void 0),__decorate([property({attribute:"aria-label"})],LyraCodeBlock.prototype,"accessibleLabel",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraCodeBlock.prototype,"collapsible",void 0),__decorate([property({type:Boolean,attribute:"without-copy-button",reflect:!0})],LyraCodeBlock.prototype,"withoutCopyButton",void 0),__decorate([property({attribute:"copy-appearance",reflect:!0})],LyraCodeBlock.prototype,"copyAppearance",void 0),__decorate([property({attribute:"max-height"})],LyraCodeBlock.prototype,"maxHeight",void 0),__decorate([property({type:Boolean,attribute:"line-numbers",reflect:!0})],LyraCodeBlock.prototype,"lineNumbers",void 0),__decorate([property({attribute:"highlight-lines"})],LyraCodeBlock.prototype,"highlightLines",void 0),__decorate([property({type:Boolean,attribute:"activatable-lines"})],LyraCodeBlock.prototype,"activatableLines",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"highlights",null),__decorate([property({attribute:"active-highlight-id"})],LyraCodeBlock.prototype,"activeHighlightId",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"languages",void 0),__decorate([property({attribute:!1})],LyraCodeBlock.prototype,"languageLoaders",void 0);export{LyraCodeBlock};
@@ -1 +1 @@
1
- import{activeFill,focusRing,focusRingInsetOffset,iconHitTarget,interactiveTransition}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host{--_lr-code-block-copy-bg:transparent;--_lr-code-block-copy-bg-hover:var(--lr-color-brand-quiet);--_lr-code-block-copy-bg-active: ${activeFill("var(--lr-icon-button-hover-bg, var(--lr-color-brand-quiet))")};--_lr-code-block-copy-color:var(--lr-color-text-quiet);--_lr-code-block-copy-color-hover:var(--lr-color-brand);--_lr-code-block-copy-color-active:var(--lr-icon-button-hover-color, var(--lr-color-brand));--_lr-code-block-copy-radius:var(--lr-radius);display:block;font-size:var(--lr-font-size-sm)}[part=base]{display:flex;flex-direction:column;box-sizing:border-box;block-size:100%;border:var(--lr-border-width-thin) solid var(--lr-color-border-subtle);border-radius:var(--lr-code-block-radius,var(--lr-radius));background:var(--lr-color-surface);overflow:hidden}[part=header]{display:flex;min-inline-size:0;align-items:center;gap:var(--lr-space-xs);padding:var(--lr-space-xs) var(--lr-space-s);border-block-end:var(--lr-border-width-thin) solid var(--lr-color-border-subtle);background:var(--lr-code-block-header-bg,var(--lr-color-surface));font-family:var(--lr-font)}:host([collapsible][collapsed]) [part=header]{border-block-end:0}[part=toggle]{--_lr-code-block-toggle-bg:var(--lr-code-block-toggle-bg, transparent);--_lr-code-block-toggle-bg-hover:var(--lr-code-block-toggle-hover-bg, var(--lr-color-brand-quiet));--_lr-code-block-toggle-bg-active:var(--lr-code-block-toggle-active-bg, ${activeFill("var(--lr-color-brand-quiet)")});font:inherit;inline-size:var(--lr-size-1-25rem);block-size:var(--lr-size-1-25rem);${iconHitTarget} flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;padding:0;border:none;background:var(--_lr-code-block-toggle-bg);color:var(--lr-code-block-toggle-color,var(--lr-color-text-quiet));border-radius:var(--lr-radius);cursor:pointer;${interactiveTransition}}[part=toggle]:hover{background:var(--_lr-code-block-toggle-bg-hover);color:var(--lr-code-block-toggle-hover-color,var(--lr-color-brand))}[part=toggle]:active{background:var(--_lr-code-block-toggle-bg-active);color:var(--lr-code-block-toggle-active-color,var(--lr-code-block-toggle-hover-color,var(--lr-color-brand)))}[part=toggle] .chevron{display:inline-flex;transition:transform var(--lr-transition-fast)}:host(:not([collapsed])) [part=toggle] .chevron{transform:rotate(90deg)}:host([collapsed]:dir(rtl)) [part=toggle] .chevron{transform:scaleX(-1)}[part=filename]{flex:1 1 auto;min-inline-size:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--lr-code-block-font,var(--lr-font-mono));font-size:var(--lr-font-size-xs);font-weight:var(--lr-font-weight-semibold);color:var(--lr-code-block-header-color,var(--lr-color-text))}[part=language]{direction:ltr;unicode-bidi:isolate;flex:none;min-inline-size:0;max-inline-size:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:var(--lr-size-0-0625rem) var(--lr-size-0-4375rem);border-radius:var(--lr-radius-pill);background:var(--lr-code-block-language-bg,var(--lr-color-brand-quiet));color:var(--lr-code-block-language-color,var(--lr-color-brand));font-size:var(--lr-size-0-6875rem);line-height:var(--lr-line-height-1-4);text-transform:uppercase;letter-spacing:var(--lr-size-0-02em)}[part~=copy-button]{flex:0 0 auto;margin-inline-start:auto;font-size:var(--lr-font-size-xs);line-height:var(--lr-line-height-none);--_lr-icon-button-background-default:var(--_lr-code-block-copy-bg);--_lr-icon-button-background-hover-default:var(--_lr-code-block-copy-bg-hover);--_lr-icon-button-background-active-default:var(--_lr-code-block-copy-bg-active);--_lr-icon-button-color-default:var(--_lr-code-block-copy-color);--_lr-icon-button-color-hover-default:var(--_lr-code-block-copy-color-hover);--_lr-icon-button-color-active-default:var(--_lr-code-block-copy-color-active);--_lr-icon-button-radius-default:var(--_lr-code-block-copy-radius)}[part~=copy-button-text]::part(button){padding:var(--lr-size-0-1875rem) var(--lr-space-xs)}[part=toggle]:focus-visible{${focusRing}}[part=header-actions]{display:inline-flex;flex:0 0 auto;align-items:center;gap:var(--lr-space-2xs)}[part=header-actions][hidden]{display:none}[part=body]{direction:ltr;display:block;flex:1 1 auto;block-size:100%;max-block-size:var(--lr-code-block-max-height,none);overflow:auto;scrollbar-width:var(--lr-theme-scrollbar-width,auto);scrollbar-gutter:var(--lr-theme-scrollbar-gutter,auto);scrollbar-color:var(--lr-theme-scrollbar-color,auto)}[part=body][hidden]{display:none}[part=body]:focus-visible{${focusRingInsetOffset}}[part=body] lr-skeleton{display:block;padding:var(--lr-space-s) var(--lr-space-m);--lr-skeleton-w:100%;--lr-skeleton-h:var(--lr-size-8rem)}[part=pre]{margin:0;padding:var(--lr-code-block-padding,var(--lr-space-s) var(--lr-space-m));box-sizing:border-box;inline-size:max-content;min-inline-size:100%;direction:ltr;unicode-bidi:isolate;background:var(--lr-color-surface);font-family:var(--lr-code-block-font,var(--lr-font-mono));font-size:inherit;line-height:var(--lr-line-height-normal);white-space:pre;tab-size:var(--lr-code-block-tab-size,2)}[part=code]{display:grid;font-family:inherit}[part=pre] .line{display:block}[part=pre].line-numbers .line{line-height:max(1lh,var(--lr-size-1-5rem))}[part=pre] .line-number{display:inline-block;min-inline-size:var(--lr-size-2-5ch);margin-inline-end:var(--lr-space-s);color:var(--lr-code-block-line-number-color,var(--lr-color-text-quiet));text-align:end;user-select:none}[part=pre] [data-highlighted]{background:var(--lr-code-block-highlighted-line-bg,var(--lr-color-warning-quiet))}[part=pre] .line:where([data-highlighted]){position:relative}[part=pre] .line:where([data-highlighted])::before{content:'';position:absolute;inset-block:0;inset-inline-end:100%;border-inline-start:var(--lr-border-width-medium) solid currentColor;pointer-events:none}[part=pre] [data-active]{outline:var(--lr-border-width-thin) solid var(--lr-code-block-active-line-outline-color,var(--lr-color-brand));outline-offset:calc(-1 * var(--lr-border-width-thin))}[part=pre] button.line-gutter{--_lr-code-block-gutter-bg:var(--lr-code-block-gutter-bg, transparent);--_lr-code-block-gutter-bg-hover:var(--lr-code-block-gutter-hover-bg, var(--lr-color-brand-quiet));--_lr-code-block-gutter-bg-active:var(--lr-code-block-gutter-active-bg, ${activeFill("var(--lr-color-brand-quiet)")});display:inline-flex;align-items:center;justify-content:end;min-inline-size:var(--lr-icon-button-size);margin:0;margin-inline-end:var(--lr-space-s);padding:0;border:none;background:var(--_lr-code-block-gutter-bg);color:inherit;font:inherit;text-align:start;cursor:pointer;${interactiveTransition}}[part=pre] button.line-gutter:hover{background:var(--_lr-code-block-gutter-bg-hover);color:var(--lr-code-block-gutter-hover-color,inherit)}[part=pre] button.line-gutter:active{background:var(--_lr-code-block-gutter-bg-active)}[part=pre] button.line-gutter:focus-visible{${focusRingInsetOffset}}[part=body][data-dark-theme=true] [part=pre],[part=body][data-dark-theme=true] [part=pre] span{color:var(--shiki-dark,inherit)!important;background-color:var(--shiki-dark-bg,transparent)!important}[part=body][data-dark-theme=true] [part=pre] .line-number,[part=body][data-dark-theme=true] [part=pre] button.line-gutter{color:var(--lr-code-block-line-number-color,var(--lr-color-text-quiet))!important}[part=body][data-dark-theme=true] [part=pre] [data-highlighted]{background:var(--lr-code-block-highlighted-line-bg,var(--lr-color-warning-quiet))!important}[part=limit]{padding:var(--lr-space-s);color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-sm)}@media (prefers-reduced-motion:reduce){[part=toggle] .chevron{transition:none!important}}`;export{styles};
1
+ import{activeFill,focusRing,focusRingInsetOffset,iconHitTarget,interactiveTransition}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{visuallyHidden}from"../../../internal/a11y.js";const styles=css` :host{--_lr-code-block-copy-bg:transparent;--_lr-code-block-copy-bg-hover:var(--lr-color-brand-quiet);--_lr-code-block-copy-bg-active: ${activeFill("var(--lr-icon-button-hover-bg, var(--lr-color-brand-quiet))")};--_lr-code-block-copy-color:var(--lr-color-text-quiet);--_lr-code-block-copy-color-hover:var(--lr-color-brand);--_lr-code-block-copy-color-active:var(--lr-icon-button-hover-color, var(--lr-color-brand));--_lr-code-block-copy-radius:var(--lr-radius);display:block;font-size:var(--lr-font-size-sm)}[part=base]{display:flex;flex-direction:column;box-sizing:border-box;block-size:100%;border:var(--lr-code-block-border,var(--lr-border-width-thin) solid var(--lr-color-border-subtle));border-radius:var(--lr-code-block-radius,var(--lr-radius));background:var(--lr-code-block-bg,var(--lr-color-surface));overflow:hidden}[part=header]{display:flex;min-inline-size:0;align-items:center;gap:var(--lr-space-xs);padding:var(--lr-code-block-header-padding,var(--lr-space-xs) var(--lr-space-s));border-block-end:var(--lr-code-block-header-border,var(--lr-border-width-thin) solid var(--lr-color-border-subtle));background:var(--lr-code-block-header-bg,var(--lr-color-surface));font-family:var(--lr-font)}:host([collapsible][collapsed]) [part=header]{border-block-end:0}[part=toggle]{--_lr-code-block-toggle-bg:var(--lr-code-block-toggle-bg, transparent);--_lr-code-block-toggle-bg-hover:var(--lr-code-block-toggle-hover-bg, var(--lr-color-brand-quiet));--_lr-code-block-toggle-bg-active:var(--lr-code-block-toggle-active-bg, ${activeFill("var(--lr-color-brand-quiet)")});font:inherit;inline-size:var(--lr-size-1-25rem);block-size:var(--lr-size-1-25rem);${iconHitTarget} flex:0 0 auto;display:inline-flex;align-items:center;justify-content:center;padding:0;border:none;background:var(--_lr-code-block-toggle-bg);color:var(--lr-code-block-toggle-color,var(--lr-color-text-quiet));border-radius:var(--lr-radius);cursor:pointer;${interactiveTransition}}[part=toggle]:hover{background:var(--_lr-code-block-toggle-bg-hover);color:var(--lr-code-block-toggle-hover-color,var(--lr-color-brand))}[part=toggle]:active{background:var(--_lr-code-block-toggle-bg-active);color:var(--lr-code-block-toggle-active-color,var(--lr-code-block-toggle-hover-color,var(--lr-color-brand)))}[part=toggle] .chevron{display:inline-flex;transition:transform var(--lr-transition-fast)}:host(:not([collapsed])) [part=toggle] .chevron{transform:rotate(90deg)}:host([collapsed]:dir(rtl)) [part=toggle] .chevron{transform:scaleX(-1)}[part=filename]{flex:1 1 auto;min-inline-size:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;font-family:var(--lr-code-block-font,var(--lr-font-mono));font-size:var(--lr-font-size-xs);font-weight:var(--lr-font-weight-semibold);color:var(--lr-code-block-header-color,var(--lr-color-text))}[part=language]{direction:ltr;unicode-bidi:isolate;flex:none;min-inline-size:0;max-inline-size:100%;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;padding:var(--lr-size-0-0625rem) var(--lr-size-0-4375rem);border-radius:var(--lr-radius-pill);background:var(--lr-code-block-language-bg,var(--lr-color-brand-quiet));color:var(--lr-code-block-language-color,var(--lr-color-brand));font-size:var(--lr-size-0-6875rem);line-height:var(--lr-line-height-1-4);text-transform:uppercase;letter-spacing:var(--lr-size-0-02em)}[part~=copy-button]{flex:0 0 auto;margin-inline-start:auto;font-size:var(--lr-font-size-xs);line-height:var(--lr-line-height-none);--_lr-icon-button-background-default:var(--_lr-code-block-copy-bg);--_lr-icon-button-background-hover-default:var(--_lr-code-block-copy-bg-hover);--_lr-icon-button-background-active-default:var(--_lr-code-block-copy-bg-active);--_lr-icon-button-color-default:var(--_lr-code-block-copy-color);--_lr-icon-button-color-hover-default:var(--_lr-code-block-copy-color-hover);--_lr-icon-button-color-active-default:var(--_lr-code-block-copy-color-active);--_lr-icon-button-radius-default:var(--_lr-code-block-copy-radius)}[part~=copy-button-text]::part(button){padding:var(--lr-size-0-1875rem) var(--lr-space-xs)}.copy-glyph{display:inline-flex}.copy-feedback{${visuallyHidden}}[part=toggle]:focus-visible{${focusRing}}[part=header-actions]{display:inline-flex;flex:0 0 auto;align-items:center;gap:var(--lr-space-2xs)}[part=header-actions][hidden]{display:none}[part=body]{direction:ltr;display:block;flex:1 1 auto;block-size:100%;max-block-size:var(--lr-code-block-max-height,none);overflow:auto;scrollbar-width:var(--lr-theme-scrollbar-width,auto);scrollbar-gutter:var(--lr-theme-scrollbar-gutter,auto);scrollbar-color:var(--lr-theme-scrollbar-color,auto)}[part=body][hidden]{display:none}[part=body]:focus-visible{${focusRingInsetOffset}}[part=body] lr-skeleton{display:block;padding:var(--lr-space-s) var(--lr-space-m);--lr-skeleton-w:100%;--lr-skeleton-h:var(--lr-size-8rem)}[part=pre]{margin:0;padding:var(--lr-code-block-padding,var(--lr-space-s) var(--lr-space-m));box-sizing:border-box;inline-size:max-content;min-inline-size:100%;direction:ltr;unicode-bidi:isolate;background:var(--lr-code-block-bg,var(--lr-color-surface));font-family:var(--lr-code-block-font,var(--lr-font-mono));font-size:inherit;line-height:var(--lr-line-height-normal);white-space:pre;tab-size:var(--lr-code-block-tab-size,2)}:host([wrap]) [part=pre]{inline-size:auto;white-space:pre-wrap;overflow-wrap:anywhere}[part=code]{display:grid;font-family:inherit}[part=pre] .line{display:block}[part=pre].line-numbers .line{line-height:max(1lh,var(--lr-size-1-5rem))}[part=pre] .line-number{display:inline-block;min-inline-size:var(--lr-size-2-5ch);margin-inline-end:var(--lr-space-s);color:var(--lr-code-block-line-number-color,var(--lr-color-text-quiet));text-align:end;user-select:none}[part=pre] [data-highlighted]{background:var(--lr-code-block-highlighted-line-bg,var(--lr-color-warning-quiet))}[part=pre] .line:where([data-highlighted]){position:relative}[part=pre] .line:where([data-highlighted])::before{content:'';position:absolute;inset-block:0;inset-inline-end:100%;border-inline-start:var(--lr-border-width-medium) solid currentColor;pointer-events:none}[part=pre] [data-active]{outline:var(--lr-border-width-thin) solid var(--lr-code-block-active-line-outline-color,var(--lr-color-brand));outline-offset:calc(-1 * var(--lr-border-width-thin))}[part=pre] button.line-gutter{--_lr-code-block-gutter-bg:var(--lr-code-block-gutter-bg, transparent);--_lr-code-block-gutter-bg-hover:var(--lr-code-block-gutter-hover-bg, var(--lr-color-brand-quiet));--_lr-code-block-gutter-bg-active:var(--lr-code-block-gutter-active-bg, ${activeFill("var(--lr-color-brand-quiet)")});display:inline-flex;align-items:center;justify-content:end;min-inline-size:var(--lr-icon-button-size);margin:0;margin-inline-end:var(--lr-space-s);padding:0;border:none;background:var(--_lr-code-block-gutter-bg);color:inherit;font:inherit;text-align:start;cursor:pointer;${interactiveTransition}}[part=pre] button.line-gutter:hover{background:var(--_lr-code-block-gutter-bg-hover);color:var(--lr-code-block-gutter-hover-color,inherit)}[part=pre] button.line-gutter:active{background:var(--_lr-code-block-gutter-bg-active)}[part=pre] button.line-gutter:focus-visible{${focusRingInsetOffset}}[part=body][data-dark-theme=true] [part=pre],[part=body][data-dark-theme=true] [part=pre] span{color:var(--shiki-dark,inherit)!important;background-color:var(--shiki-dark-bg,transparent)!important}[part=pre] span[data-token]{color:var(--_lr-syntax,var(--_lr-token-color,inherit))!important}[part=body][data-dark-theme=true] [part=pre] span[data-token]{color:var(--_lr-syntax,var(--shiki-dark,inherit))!important}[data-token=comment]{--_lr-syntax:var(--comment-color)}[data-token=keyword]{--_lr-syntax:var(--keyword-color)}[data-token=operator]{--_lr-syntax:var(--operator-color)}[data-token=string]{--_lr-syntax:var(--string-color)}[data-token=constant]{--_lr-syntax:var(--constant-color)}[data-token=function]{--_lr-syntax:var(--function-color)}[data-token=type]{--_lr-syntax:var(--type-color)}[data-token=variable]{--_lr-syntax:var(--variable-color)}[data-token=property]{--_lr-syntax:var(--property-color)}[data-token=tag]{--_lr-syntax:var(--tag-color)}[data-token=selector]{--_lr-syntax:var(--selector-color)}[data-token=inserted]{--_lr-syntax:var(--inserted-color)}[data-token=deleted]{--_lr-syntax:var(--deleted-color)}[part=body][data-dark-theme=true] [part=pre] .line-number,[part=body][data-dark-theme=true] [part=pre] button.line-gutter{color:var(--lr-code-block-line-number-color,var(--lr-color-text-quiet))!important}[part=body][data-dark-theme=true] [part=pre] [data-highlighted]{background:var(--lr-code-block-highlighted-line-bg,var(--lr-color-warning-quiet))!important}[part=limit]{padding:var(--lr-space-s);color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-sm)}@media (prefers-reduced-motion:reduce){[part=toggle] .chevron{transition:none!important}}`;export{styles};