@aceshooting/lyra-ui 1.1.0 → 2.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.
- package/README.md +12 -1
- package/custom-elements.json +21460 -8489
- package/dist/components/app-rail/app-rail.d.ts +171 -0
- package/dist/components/app-rail/app-rail.js +483 -0
- package/dist/components/app-rail/app-rail.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail.styles.js +125 -0
- package/dist/components/attachment-chip/attachment-chip.d.ts +114 -0
- package/dist/components/attachment-chip/attachment-chip.js +312 -0
- package/dist/components/attachment-chip/attachment-chip.styles.d.ts +1 -0
- package/dist/components/attachment-chip/attachment-chip.styles.js +184 -0
- package/dist/components/attachment-trigger/attachment-trigger.d.ts +83 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +258 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.d.ts +1 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +68 -0
- package/dist/components/chart/box-plot.js +11 -1
- package/dist/components/chart/chart-loader.d.ts +44 -13
- package/dist/components/chart/chart-loader.js +65 -18
- package/dist/components/chart/chart.d.ts +12 -2
- package/dist/components/chart/chart.js +121 -14
- package/dist/components/chart/histogram-bin.d.ts +4 -1
- package/dist/components/chart/histogram-bin.js +24 -14
- package/dist/components/chart/lite-chart.d.ts +63 -0
- package/dist/components/chart/lite-chart.js +181 -23
- package/dist/components/chart/lite-chart.styles.js +9 -0
- package/dist/components/chat-composer/chat-composer.d.ts +92 -0
- package/dist/components/chat-composer/chat-composer.js +285 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +1 -0
- package/dist/components/chat-composer/chat-composer.styles.js +135 -0
- package/dist/components/chat-message/chat-message.d.ts +113 -0
- package/dist/components/chat-message/chat-message.js +291 -0
- package/dist/components/chat-message/chat-message.styles.d.ts +1 -0
- package/dist/components/chat-message/chat-message.styles.js +203 -0
- package/dist/components/checkbox/checkbox.d.ts +59 -0
- package/dist/components/checkbox/checkbox.js +230 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.styles.js +70 -0
- package/dist/components/chip/chip-group.d.ts +56 -0
- package/dist/components/chip/chip-group.js +124 -0
- package/dist/components/chip/chip-group.styles.d.ts +1 -0
- package/dist/components/chip/chip-group.styles.js +57 -0
- package/dist/components/chip/chip.d.ts +64 -0
- package/dist/components/chip/chip.js +115 -0
- package/dist/components/chip/chip.styles.d.ts +1 -0
- package/dist/components/chip/chip.styles.js +115 -0
- package/dist/components/citation-badge/citation-badge.d.ts +113 -0
- package/dist/components/citation-badge/citation-badge.js +300 -0
- package/dist/components/citation-badge/citation-badge.styles.d.ts +1 -0
- package/dist/components/citation-badge/citation-badge.styles.js +96 -0
- package/dist/components/code-block/code-block.d.ts +89 -0
- package/dist/components/code-block/code-block.js +317 -0
- package/dist/components/code-block/code-block.styles.d.ts +1 -0
- package/dist/components/code-block/code-block.styles.js +187 -0
- package/dist/components/code-block/code-loader.d.ts +44 -0
- package/dist/components/code-block/code-loader.js +79 -0
- package/dist/components/combobox/combobox.d.ts +19 -1
- package/dist/components/combobox/combobox.js +84 -14
- package/dist/components/combobox/option.d.ts +5 -1
- package/dist/components/combobox/option.js +35 -0
- package/dist/components/context-meter/context-meter.d.ts +53 -0
- package/dist/components/context-meter/context-meter.js +150 -0
- package/dist/components/context-meter/context-meter.styles.d.ts +1 -0
- package/dist/components/context-meter/context-meter.styles.js +120 -0
- package/dist/components/conversation-item/conversation-item.d.ts +128 -0
- package/dist/components/conversation-item/conversation-item.js +322 -0
- package/dist/components/conversation-item/conversation-item.styles.d.ts +1 -0
- package/dist/components/conversation-item/conversation-item.styles.js +155 -0
- package/dist/components/date-picker/date-input.d.ts +24 -0
- package/dist/components/date-picker/date-input.js +134 -22
- package/dist/components/date-picker/date-picker.d.ts +7 -0
- package/dist/components/date-picker/date-picker.js +85 -16
- package/dist/components/dialog/confirm.d.ts +40 -0
- package/dist/components/dialog/confirm.js +79 -0
- package/dist/components/dialog/dialog.d.ts +85 -0
- package/dist/components/dialog/dialog.js +272 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +52 -0
- package/dist/components/dock-panel/dock-panel.d.ts +134 -0
- package/dist/components/dock-panel/dock-panel.js +345 -0
- package/dist/components/dock-panel/dock-panel.styles.d.ts +1 -0
- package/dist/components/dock-panel/dock-panel.styles.js +145 -0
- package/dist/components/document-preview/document-preview.d.ts +135 -0
- package/dist/components/document-preview/document-preview.js +372 -0
- package/dist/components/document-preview/document-preview.styles.d.ts +1 -0
- package/dist/components/document-preview/document-preview.styles.js +191 -0
- package/dist/components/export-button/csv.js +1 -1
- package/dist/components/export-button/export-button.js +2 -0
- package/dist/components/flag/flag.d.ts +42 -5
- package/dist/components/flag/flag.js +70 -3
- package/dist/components/gauge/gauge.js +19 -10
- package/dist/components/generation-status/generation-status.d.ts +109 -0
- package/dist/components/generation-status/generation-status.js +273 -0
- package/dist/components/generation-status/generation-status.styles.d.ts +1 -0
- package/dist/components/generation-status/generation-status.styles.js +84 -0
- package/dist/components/heatmap/calendar-grid.d.ts +4 -1
- package/dist/components/heatmap/calendar-grid.js +25 -12
- package/dist/components/heatmap/heatmap-scale.d.ts +6 -0
- package/dist/components/heatmap/heatmap-scale.js +7 -1
- package/dist/components/heatmap/heatmap.d.ts +89 -3
- package/dist/components/heatmap/heatmap.js +158 -29
- package/dist/components/json-viewer/json-viewer.d.ts +53 -0
- package/dist/components/json-viewer/json-viewer.js +283 -0
- package/dist/components/json-viewer/json-viewer.styles.d.ts +1 -0
- package/dist/components/json-viewer/json-viewer.styles.js +176 -0
- package/dist/components/kbd/kbd.d.ts +77 -0
- package/dist/components/kbd/kbd.js +214 -0
- package/dist/components/kbd/kbd.styles.d.ts +1 -0
- package/dist/components/kbd/kbd.styles.js +52 -0
- package/dist/components/live-region/live-region.d.ts +81 -0
- package/dist/components/live-region/live-region.js +153 -0
- package/dist/components/live-region/live-region.styles.d.ts +1 -0
- package/dist/components/live-region/live-region.styles.js +10 -0
- package/dist/components/map/map.d.ts +8 -6
- package/dist/components/map/map.js +44 -8
- package/dist/components/markdown/markdown-loader.d.ts +34 -0
- package/dist/components/markdown/markdown-loader.js +43 -0
- package/dist/components/markdown/markdown.d.ts +81 -0
- package/dist/components/markdown/markdown.js +284 -0
- package/dist/components/markdown/markdown.styles.d.ts +1 -0
- package/dist/components/markdown/markdown.styles.js +82 -0
- package/dist/components/media-card/media-card.d.ts +122 -0
- package/dist/components/media-card/media-card.js +295 -0
- package/dist/components/media-card/media-card.styles.d.ts +1 -0
- package/dist/components/media-card/media-card.styles.js +132 -0
- package/dist/components/mention-popover/mention-popover.d.ts +200 -0
- package/dist/components/mention-popover/mention-popover.js +475 -0
- package/dist/components/mention-popover/mention-popover.styles.d.ts +1 -0
- package/dist/components/mention-popover/mention-popover.styles.js +101 -0
- package/dist/components/menu/menu-item.d.ts +62 -0
- package/dist/components/menu/menu-item.js +119 -0
- package/dist/components/menu/menu-item.styles.d.ts +1 -0
- package/dist/components/menu/menu-item.styles.js +67 -0
- package/dist/components/menu/menu.d.ts +143 -0
- package/dist/components/menu/menu.js +365 -0
- package/dist/components/menu/menu.styles.d.ts +1 -0
- package/dist/components/menu/menu.styles.js +66 -0
- package/dist/components/model-select/model-select.d.ts +125 -0
- package/dist/components/model-select/model-select.js +490 -0
- package/dist/components/model-select/model-select.styles.d.ts +1 -0
- package/dist/components/model-select/model-select.styles.js +189 -0
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +69 -0
- package/dist/components/model-settings-panel/model-settings-panel.js +145 -0
- package/dist/components/model-settings-panel/model-settings-panel.styles.d.ts +1 -0
- package/dist/components/model-settings-panel/model-settings-panel.styles.js +82 -0
- package/dist/components/playback/playback.d.ts +13 -1
- package/dist/components/playback/playback.js +47 -14
- package/dist/components/responsive-panel/responsive-panel.d.ts +150 -0
- package/dist/components/responsive-panel/responsive-panel.js +365 -0
- package/dist/components/responsive-panel/responsive-panel.styles.d.ts +1 -0
- package/dist/components/responsive-panel/responsive-panel.styles.js +103 -0
- package/dist/components/result-card/result-card.d.ts +44 -0
- package/dist/components/result-card/result-card.js +83 -0
- package/dist/components/result-card/result-card.styles.d.ts +1 -0
- package/dist/components/result-card/result-card.styles.js +50 -0
- package/dist/components/result-card/result-field.d.ts +36 -0
- package/dist/components/result-card/result-field.js +87 -0
- package/dist/components/result-card/result-field.styles.d.ts +1 -0
- package/dist/components/result-card/result-field.styles.js +32 -0
- package/dist/components/select/select.d.ts +45 -1
- package/dist/components/select/select.js +114 -17
- package/dist/components/select/select.styles.js +26 -2
- package/dist/components/slider/slider.d.ts +89 -0
- package/dist/components/slider/slider.js +352 -0
- package/dist/components/slider/slider.styles.d.ts +1 -0
- package/dist/components/slider/slider.styles.js +87 -0
- package/dist/components/source-card/source-card.d.ts +92 -0
- package/dist/components/source-card/source-card.js +148 -0
- package/dist/components/source-card/source-card.styles.d.ts +1 -0
- package/dist/components/source-card/source-card.styles.js +69 -0
- package/dist/components/source-list/source-list.d.ts +63 -0
- package/dist/components/source-list/source-list.js +122 -0
- package/dist/components/source-list/source-list.styles.d.ts +1 -0
- package/dist/components/source-list/source-list.styles.js +59 -0
- package/dist/components/sparkline/sparkline.js +27 -13
- package/dist/components/split/split.d.ts +93 -1
- package/dist/components/split/split.js +284 -15
- package/dist/components/split/split.styles.js +30 -0
- package/dist/components/stat/stat.d.ts +22 -1
- package/dist/components/stat/stat.js +49 -3
- package/dist/components/stat/stat.styles.js +20 -0
- package/dist/components/stream-status/stream-status.d.ts +110 -0
- package/dist/components/stream-status/stream-status.js +210 -0
- package/dist/components/stream-status/stream-status.styles.d.ts +1 -0
- package/dist/components/stream-status/stream-status.styles.js +103 -0
- package/dist/components/streaming-text/streaming-text.d.ts +98 -0
- package/dist/components/streaming-text/streaming-text.js +209 -0
- package/dist/components/streaming-text/streaming-text.styles.d.ts +1 -0
- package/dist/components/streaming-text/streaming-text.styles.js +62 -0
- package/dist/components/switch/switch.d.ts +58 -0
- package/dist/components/switch/switch.js +179 -0
- package/dist/components/switch/switch.styles.d.ts +1 -0
- package/dist/components/switch/switch.styles.js +75 -0
- package/dist/components/table/table.d.ts +73 -4
- package/dist/components/table/table.js +169 -20
- package/dist/components/table/table.styles.js +6 -1
- package/dist/components/tabs/tabs.d.ts +51 -0
- package/dist/components/tabs/tabs.js +190 -0
- package/dist/components/tabs/tabs.styles.d.ts +1 -0
- package/dist/components/tabs/tabs.styles.js +63 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +121 -0
- package/dist/components/thinking-panel/thinking-panel.js +235 -0
- package/dist/components/thinking-panel/thinking-panel.styles.d.ts +1 -0
- package/dist/components/thinking-panel/thinking-panel.styles.js +117 -0
- package/dist/components/toast/toast-item.d.ts +1 -0
- package/dist/components/toast/toast-item.js +31 -6
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +130 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +403 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.d.ts +1 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.js +160 -0
- package/dist/components/tool-call-chip/tool-call-chip.d.ts +89 -0
- package/dist/components/tool-call-chip/tool-call-chip.js +288 -0
- package/dist/components/tool-call-chip/tool-call-chip.styles.d.ts +1 -0
- package/dist/components/tool-call-chip/tool-call-chip.styles.js +203 -0
- package/dist/components/tool-param-form/tool-param-form.d.ts +145 -0
- package/dist/components/tool-param-form/tool-param-form.js +366 -0
- package/dist/components/tool-param-form/tool-param-form.styles.d.ts +1 -0
- package/dist/components/tool-param-form/tool-param-form.styles.js +75 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.d.ts +102 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.js +393 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.d.ts +1 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.js +176 -0
- package/dist/components/tool-result-view/registry.d.ts +81 -0
- package/dist/components/tool-result-view/registry.js +84 -0
- package/dist/components/tool-result-view/tool-result-view.d.ts +55 -0
- package/dist/components/tool-result-view/tool-result-view.js +138 -0
- package/dist/components/tool-result-view/tool-result-view.styles.d.ts +1 -0
- package/dist/components/tool-result-view/tool-result-view.styles.js +13 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.d.ts +151 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.js +439 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.d.ts +1 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.js +182 -0
- package/dist/components/tree/tree-node.d.ts +11 -2
- package/dist/components/tree/tree-node.js +16 -6
- package/dist/components/tree/tree.d.ts +8 -2
- package/dist/components/tree/tree.js +18 -11
- package/dist/components/typing-indicator/typing-indicator.d.ts +60 -0
- package/dist/components/typing-indicator/typing-indicator.js +96 -0
- package/dist/components/typing-indicator/typing-indicator.styles.d.ts +1 -0
- package/dist/components/typing-indicator/typing-indicator.styles.js +132 -0
- package/dist/components/virtual-list/virtual-list.d.ts +173 -0
- package/dist/components/virtual-list/virtual-list.js +461 -0
- package/dist/components/virtual-list/virtual-list.styles.d.ts +1 -0
- package/dist/components/virtual-list/virtual-list.styles.js +44 -0
- package/dist/components/widget/widget.d.ts +10 -0
- package/dist/components/widget/widget.js +24 -1
- package/dist/components/widget/widget.styles.js +9 -2
- package/dist/components/word-cloud/word-cloud-layout.js +14 -1
- package/dist/components/word-cloud/word-cloud.d.ts +6 -0
- package/dist/components/word-cloud/word-cloud.js +25 -14
- package/dist/components/word-cloud/word-cloud.styles.js +4 -2
- package/dist/internal/announcer.d.ts +57 -0
- package/dist/internal/announcer.js +71 -0
- package/dist/internal/form-associated.d.ts +1 -0
- package/dist/internal/form-associated.js +55 -11
- package/dist/internal/group-by-recency.d.ts +50 -0
- package/dist/internal/group-by-recency.js +80 -0
- package/dist/internal/rtl.d.ts +23 -0
- package/dist/internal/rtl.js +28 -0
- package/dist/internal/scroll-lock.d.ts +10 -5
- package/dist/internal/scroll-lock.js +30 -14
- package/dist/internal/tokens.styles.js +6 -0
- package/dist/lyra.d.ts +130 -31
- package/dist/lyra.js +94 -26
- package/llms-full.txt +3921 -32
- package/llms.txt +16 -1
- package/package.json +23 -5
- package/dist/components/chart/bar-chart.stories.d.ts +0 -5
- package/dist/components/chart/bar-chart.stories.js +0 -20
- package/dist/components/chart/box-plot.stories.d.ts +0 -5
- package/dist/components/chart/box-plot.stories.js +0 -29
- package/dist/components/chart/bubble-chart.stories.d.ts +0 -5
- package/dist/components/chart/bubble-chart.stories.js +0 -26
- package/dist/components/chart/chart.stories.d.ts +0 -32
- package/dist/components/chart/chart.stories.js +0 -141
- package/dist/components/chart/doughnut-chart.stories.d.ts +0 -5
- package/dist/components/chart/doughnut-chart.stories.js +0 -26
- package/dist/components/chart/histogram.stories.d.ts +0 -5
- package/dist/components/chart/histogram.stories.js +0 -17
- package/dist/components/chart/line-chart.stories.d.ts +0 -22
- package/dist/components/chart/line-chart.stories.js +0 -99
- package/dist/components/chart/lite-chart.stories.d.ts +0 -12
- package/dist/components/chart/lite-chart.stories.js +0 -98
- package/dist/components/chart/pie-chart.stories.d.ts +0 -5
- package/dist/components/chart/pie-chart.stories.js +0 -26
- package/dist/components/chart/polar-area-chart.stories.d.ts +0 -5
- package/dist/components/chart/polar-area-chart.stories.js +0 -20
- package/dist/components/chart/radar-chart.stories.d.ts +0 -5
- package/dist/components/chart/radar-chart.stories.js +0 -20
- package/dist/components/chart/scatter-chart.stories.d.ts +0 -5
- package/dist/components/chart/scatter-chart.stories.js +0 -31
- package/dist/components/combobox/combobox.stories.d.ts +0 -24
- package/dist/components/combobox/combobox.stories.js +0 -102
- package/dist/components/date-picker/date-input.stories.d.ts +0 -10
- package/dist/components/date-picker/date-input.stories.js +0 -48
- package/dist/components/date-picker/date-picker.stories.d.ts +0 -10
- package/dist/components/date-picker/date-picker.stories.js +0 -25
- package/dist/components/empty/empty.stories.d.ts +0 -7
- package/dist/components/empty/empty.stories.js +0 -34
- package/dist/components/export-button/export-button.stories.d.ts +0 -7
- package/dist/components/export-button/export-button.stories.js +0 -37
- package/dist/components/file-input/file-input.stories.d.ts +0 -7
- package/dist/components/file-input/file-input.stories.js +0 -19
- package/dist/components/flag/flag.stories.d.ts +0 -5
- package/dist/components/flag/flag.stories.js +0 -17
- package/dist/components/gauge/gauge.stories.d.ts +0 -8
- package/dist/components/gauge/gauge.stories.js +0 -19
- package/dist/components/graph/graph.stories.d.ts +0 -8
- package/dist/components/graph/graph.stories.js +0 -68
- package/dist/components/heatmap/heatmap.stories.d.ts +0 -22
- package/dist/components/heatmap/heatmap.stories.js +0 -154
- package/dist/components/map/map.stories.d.ts +0 -15
- package/dist/components/map/map.stories.js +0 -135
- package/dist/components/playback/playback.stories.d.ts +0 -7
- package/dist/components/playback/playback.stories.js +0 -16
- package/dist/components/select/select.stories.d.ts +0 -19
- package/dist/components/select/select.stories.js +0 -75
- package/dist/components/skeleton/skeleton.stories.d.ts +0 -5
- package/dist/components/skeleton/skeleton.stories.js +0 -16
- package/dist/components/sparkline/sparkline.stories.d.ts +0 -11
- package/dist/components/sparkline/sparkline.stories.js +0 -39
- package/dist/components/split/split.stories.d.ts +0 -7
- package/dist/components/split/split.stories.js +0 -36
- package/dist/components/stat/stat.stories.d.ts +0 -8
- package/dist/components/stat/stat.stories.js +0 -64
- package/dist/components/table/table.stories.d.ts +0 -12
- package/dist/components/table/table.stories.js +0 -67
- package/dist/components/time-range/time-range.stories.d.ts +0 -8
- package/dist/components/time-range/time-range.stories.js +0 -26
- package/dist/components/toast/toast.stories.d.ts +0 -8
- package/dist/components/toast/toast.stories.js +0 -72
- package/dist/components/tree/tree.stories.d.ts +0 -9
- package/dist/components/tree/tree.stories.js +0 -52
- package/dist/components/widget/widget.stories.d.ts +0 -7
- package/dist/components/widget/widget.stories.js +0 -41
- package/dist/components/word-cloud/word-cloud.stories.d.ts +0 -10
- package/dist/components/word-cloud/word-cloud.stories.js +0 -55
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: inline-flex;
|
|
5
|
+
vertical-align: baseline;
|
|
6
|
+
line-height: 1;
|
|
7
|
+
/* Per-status accent -- one pair of custom properties swapped by the
|
|
8
|
+
:host([status]) rules below rather than repeating background/color
|
|
9
|
+
per part per status. 'default' (and any unrecognized status) stays
|
|
10
|
+
plain/neutral -- transparent background, quiet text -- rather than
|
|
11
|
+
inventing a seventh visual tone for "no signal at all". */
|
|
12
|
+
--lyra-citation-badge-accent: var(--lyra-color-text-quiet);
|
|
13
|
+
--lyra-citation-badge-bg: transparent;
|
|
14
|
+
--lyra-citation-badge-border: transparent;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
:host([status='high']),
|
|
18
|
+
:host([status='verified']) {
|
|
19
|
+
--lyra-citation-badge-accent: var(--lyra-color-success);
|
|
20
|
+
--lyra-citation-badge-bg: var(--lyra-color-success-quiet);
|
|
21
|
+
}
|
|
22
|
+
:host([status='medium']),
|
|
23
|
+
:host([status='low']) {
|
|
24
|
+
--lyra-citation-badge-accent: var(--lyra-color-warning);
|
|
25
|
+
--lyra-citation-badge-bg: var(--lyra-color-warning-quiet);
|
|
26
|
+
}
|
|
27
|
+
/* Deliberately its own danger tone, not grouped with 'low' -- see the
|
|
28
|
+
component doc's status-coloring note: "hasn't been checked" reads as a
|
|
29
|
+
distinct (riskier) claim from "checked but uncertain". */
|
|
30
|
+
:host([status='unverified']) {
|
|
31
|
+
--lyra-citation-badge-accent: var(--lyra-color-danger);
|
|
32
|
+
--lyra-citation-badge-bg: var(--lyra-color-danger-quiet);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.wrapper {
|
|
36
|
+
display: inline-flex;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
[part='base'] {
|
|
40
|
+
display: inline-flex;
|
|
41
|
+
align-items: baseline;
|
|
42
|
+
box-sizing: border-box;
|
|
43
|
+
padding: 0 0.3em;
|
|
44
|
+
border: 1px solid var(--lyra-citation-badge-border);
|
|
45
|
+
border-radius: calc(var(--lyra-radius) * 0.6);
|
|
46
|
+
background: var(--lyra-citation-badge-bg);
|
|
47
|
+
color: var(--lyra-citation-badge-accent);
|
|
48
|
+
font: inherit;
|
|
49
|
+
font-size: 0.75em;
|
|
50
|
+
font-weight: 600;
|
|
51
|
+
font-variant-numeric: tabular-nums;
|
|
52
|
+
line-height: 1.5;
|
|
53
|
+
cursor: pointer;
|
|
54
|
+
-webkit-tap-highlight-color: transparent;
|
|
55
|
+
transition:
|
|
56
|
+
background-color var(--lyra-transition-fast),
|
|
57
|
+
border-color var(--lyra-transition-fast);
|
|
58
|
+
}
|
|
59
|
+
[part='base']:hover {
|
|
60
|
+
border-color: var(--lyra-citation-badge-accent);
|
|
61
|
+
}
|
|
62
|
+
[part='base']:focus-visible {
|
|
63
|
+
outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
|
|
64
|
+
outline-offset: var(--lyra-focus-ring-offset);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
[part='bracket'] {
|
|
68
|
+
opacity: 0.7;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/* Positioned by internal/positioner.js's place() -- same fixed/z-index/
|
|
72
|
+
max-size shape as lyra-tool-call-chip's own [part='tooltip']. No open/
|
|
73
|
+
close transition, for the same reason that one has none: a preview
|
|
74
|
+
that tracks the pointer/focus target should appear instantly, not
|
|
75
|
+
chase a fade. */
|
|
76
|
+
[part='popover'] {
|
|
77
|
+
position: fixed;
|
|
78
|
+
z-index: 900;
|
|
79
|
+
box-sizing: border-box;
|
|
80
|
+
max-inline-size: min(90vw, 22rem);
|
|
81
|
+
padding: var(--lyra-space-s) var(--lyra-space-m);
|
|
82
|
+
background: var(--lyra-color-surface);
|
|
83
|
+
border: 1px solid var(--lyra-color-border);
|
|
84
|
+
border-radius: var(--lyra-radius);
|
|
85
|
+
box-shadow: var(--lyra-shadow);
|
|
86
|
+
font-size: 0.8125rem;
|
|
87
|
+
line-height: 1.4;
|
|
88
|
+
color: var(--lyra-color-text);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
@media (prefers-reduced-motion: reduce) {
|
|
92
|
+
[part='base'] {
|
|
93
|
+
transition: none !important;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
import '../skeleton/skeleton.js';
|
|
4
|
+
/**
|
|
5
|
+
* `<lyra-code-block>` — fenced code display with optional lazy syntax
|
|
6
|
+
* highlighting and a copy button. No highlighting grammar ships in this
|
|
7
|
+
* component itself: it lazy-loads the optional peer dependency `shiki` (see
|
|
8
|
+
* `code-loader.ts`) for the actual tokenizing, and degrades to a plain
|
|
9
|
+
* `<pre><code>` when that peer isn't installed or `language` is unset/
|
|
10
|
+
* unrecognized — the exact same optional-peer shape `<lyra-markdown>` and
|
|
11
|
+
* `<lyra-chart>` already establish. That fallback is the *default* rendering
|
|
12
|
+
* path, not a degraded one: unhighlighted code is perfectly usable, and it's
|
|
13
|
+
* what every instance renders at zero extra bytes until shiki resolves.
|
|
14
|
+
*
|
|
15
|
+
* A `<lyra-skeleton>` placeholder stands in only while shiki itself is
|
|
16
|
+
* loading for the very first time on the page (cached — see
|
|
17
|
+
* `loadShikiHighlighter()`) and `language` is set. It's deliberately *not*
|
|
18
|
+
* shown again for a subsequent per-language grammar load (e.g. a second
|
|
19
|
+
* `<lyra-code-block>` requesting a language no earlier instance has used
|
|
20
|
+
* yet) — that grammar fetch is typically fast, and the plain-text fallback
|
|
21
|
+
* is already a perfectly readable placeholder for it, so a second
|
|
22
|
+
* loading-chrome state would add complexity for little practical benefit.
|
|
23
|
+
*
|
|
24
|
+
* @customElement lyra-code-block
|
|
25
|
+
* @event lyra-copy - The copy button was activated. `detail: { text }` is
|
|
26
|
+
* always the raw `code` value (never the highlighted HTML), and always
|
|
27
|
+
* fires regardless of whether the actual OS clipboard write succeeded —
|
|
28
|
+
* same convention as `<lyra-json-viewer>`'s own copy button.
|
|
29
|
+
* @csspart base - The outer container.
|
|
30
|
+
* @csspart header - The row above the code (filename/language/copy/toggle),
|
|
31
|
+
* present whenever there's anything to put in it.
|
|
32
|
+
* @csspart filename - The `filename` text, when set.
|
|
33
|
+
* @csspart language - The `language` badge, when set, so the language is
|
|
34
|
+
* exposed to assistive tech as visible text rather than only a `language`
|
|
35
|
+
* attribute a screen reader would never announce.
|
|
36
|
+
* @csspart copy-button - The copy-to-clipboard button, when `copyable`.
|
|
37
|
+
* @csspart toggle - The collapse/expand chevron button, when `collapsible`.
|
|
38
|
+
* @csspart body - The scrollable region wrapping the code (or the loading
|
|
39
|
+
* skeleton); respects `max-height`, `hidden` while `collapsible` and
|
|
40
|
+
* `collapsed`.
|
|
41
|
+
* @csspart pre - The rendered `<pre>` — shiki's own in the highlighted path,
|
|
42
|
+
* this component's own plain one in the fallback path.
|
|
43
|
+
* @csspart code - The rendered `<code>`, same split as `pre` above.
|
|
44
|
+
*/
|
|
45
|
+
export declare class LyraCodeBlock extends LyraElement {
|
|
46
|
+
static styles: import("lit").CSSResultGroup[];
|
|
47
|
+
/** The raw source text. */
|
|
48
|
+
code: string;
|
|
49
|
+
/** A shiki-recognized language id or alias (e.g. `"javascript"`,
|
|
50
|
+
* `"python"`, `"json"`). When unset, or when shiki doesn't recognize it,
|
|
51
|
+
* the code renders as plain unhighlighted text regardless of whether
|
|
52
|
+
* shiki itself is available. */
|
|
53
|
+
language: string;
|
|
54
|
+
/** Shown in the header above the code, when set. */
|
|
55
|
+
filename: string;
|
|
56
|
+
/** Whether the code region can be collapsed via a header toggle. */
|
|
57
|
+
collapsible: boolean;
|
|
58
|
+
/** Whether the code region is currently hidden. Only has a visible effect
|
|
59
|
+
* while `collapsible` is also true. */
|
|
60
|
+
collapsed: boolean;
|
|
61
|
+
/** Shows a copy-to-clipboard button in the header. */
|
|
62
|
+
copyable: boolean;
|
|
63
|
+
/** A CSS length (e.g. `"20rem"`); once set, the code scrolls internally
|
|
64
|
+
* past this height instead of growing the page. */
|
|
65
|
+
maxHeight: string;
|
|
66
|
+
private highlightedHtml;
|
|
67
|
+
private shikiReady;
|
|
68
|
+
private justCopied;
|
|
69
|
+
private highlighter?;
|
|
70
|
+
private highlightToken;
|
|
71
|
+
private copyTimeoutId?;
|
|
72
|
+
private readonly bodyId;
|
|
73
|
+
connectedCallback(): void;
|
|
74
|
+
disconnectedCallback(): void;
|
|
75
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
76
|
+
protected updated(): void;
|
|
77
|
+
private syncHighlight;
|
|
78
|
+
private tokenize;
|
|
79
|
+
private writeClipboard;
|
|
80
|
+
private copy;
|
|
81
|
+
private toggleCollapsed;
|
|
82
|
+
private renderHeader;
|
|
83
|
+
render(): TemplateResult;
|
|
84
|
+
}
|
|
85
|
+
declare global {
|
|
86
|
+
interface HTMLElementTagNameMap {
|
|
87
|
+
'lyra-code-block': LyraCodeBlock;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
@@ -0,0 +1,317 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { unsafeHTML } from 'lit/directives/unsafe-html.js';
|
|
10
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
11
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
12
|
+
import { nextId } from '../../internal/a11y.js';
|
|
13
|
+
import { chevronIcon } from '../../internal/icons.js';
|
|
14
|
+
import { loadShikiHighlighter, loadShikiLanguage, SHIKI_THEMES } from './code-loader.js';
|
|
15
|
+
import { styles } from './code-block.styles.js';
|
|
16
|
+
import '../skeleton/skeleton.js';
|
|
17
|
+
/** How long the copy button's confirmation state lasts before reverting. */
|
|
18
|
+
const COPY_CONFIRM_MS = 1500;
|
|
19
|
+
/**
|
|
20
|
+
* Rewrites shiki's generated `<pre>`/`<code>` hast nodes so they carry this
|
|
21
|
+
* component's own `part="pre"`/`part="code"` hooks — the same single-pass
|
|
22
|
+
* "inject part attributes while rendering, not a second DOM walk after
|
|
23
|
+
* insertion" approach `<lyra-markdown>`'s renderer override uses, applied
|
|
24
|
+
* here via shiki's own transformer API instead of a custom marked renderer.
|
|
25
|
+
* Also strips shiki's own default `tabindex="0"` from the `<pre>` — this
|
|
26
|
+
* component's `[part="body"]` wrapper (see `render()`) is the single
|
|
27
|
+
* scrollable/focusable region for the code area, and leaving shiki's own
|
|
28
|
+
* tabindex in place would add a second, redundant tab stop over the same
|
|
29
|
+
* scrollable content.
|
|
30
|
+
*/
|
|
31
|
+
const partTransformer = {
|
|
32
|
+
name: 'lyra-code-block-parts',
|
|
33
|
+
pre(node) {
|
|
34
|
+
node.properties.part = ['pre'];
|
|
35
|
+
delete node.properties.tabindex;
|
|
36
|
+
},
|
|
37
|
+
code(node) {
|
|
38
|
+
node.properties.part = ['code'];
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* `<lyra-code-block>` — fenced code display with optional lazy syntax
|
|
43
|
+
* highlighting and a copy button. No highlighting grammar ships in this
|
|
44
|
+
* component itself: it lazy-loads the optional peer dependency `shiki` (see
|
|
45
|
+
* `code-loader.ts`) for the actual tokenizing, and degrades to a plain
|
|
46
|
+
* `<pre><code>` when that peer isn't installed or `language` is unset/
|
|
47
|
+
* unrecognized — the exact same optional-peer shape `<lyra-markdown>` and
|
|
48
|
+
* `<lyra-chart>` already establish. That fallback is the *default* rendering
|
|
49
|
+
* path, not a degraded one: unhighlighted code is perfectly usable, and it's
|
|
50
|
+
* what every instance renders at zero extra bytes until shiki resolves.
|
|
51
|
+
*
|
|
52
|
+
* A `<lyra-skeleton>` placeholder stands in only while shiki itself is
|
|
53
|
+
* loading for the very first time on the page (cached — see
|
|
54
|
+
* `loadShikiHighlighter()`) and `language` is set. It's deliberately *not*
|
|
55
|
+
* shown again for a subsequent per-language grammar load (e.g. a second
|
|
56
|
+
* `<lyra-code-block>` requesting a language no earlier instance has used
|
|
57
|
+
* yet) — that grammar fetch is typically fast, and the plain-text fallback
|
|
58
|
+
* is already a perfectly readable placeholder for it, so a second
|
|
59
|
+
* loading-chrome state would add complexity for little practical benefit.
|
|
60
|
+
*
|
|
61
|
+
* @customElement lyra-code-block
|
|
62
|
+
* @event lyra-copy - The copy button was activated. `detail: { text }` is
|
|
63
|
+
* always the raw `code` value (never the highlighted HTML), and always
|
|
64
|
+
* fires regardless of whether the actual OS clipboard write succeeded —
|
|
65
|
+
* same convention as `<lyra-json-viewer>`'s own copy button.
|
|
66
|
+
* @csspart base - The outer container.
|
|
67
|
+
* @csspart header - The row above the code (filename/language/copy/toggle),
|
|
68
|
+
* present whenever there's anything to put in it.
|
|
69
|
+
* @csspart filename - The `filename` text, when set.
|
|
70
|
+
* @csspart language - The `language` badge, when set, so the language is
|
|
71
|
+
* exposed to assistive tech as visible text rather than only a `language`
|
|
72
|
+
* attribute a screen reader would never announce.
|
|
73
|
+
* @csspart copy-button - The copy-to-clipboard button, when `copyable`.
|
|
74
|
+
* @csspart toggle - The collapse/expand chevron button, when `collapsible`.
|
|
75
|
+
* @csspart body - The scrollable region wrapping the code (or the loading
|
|
76
|
+
* skeleton); respects `max-height`, `hidden` while `collapsible` and
|
|
77
|
+
* `collapsed`.
|
|
78
|
+
* @csspart pre - The rendered `<pre>` — shiki's own in the highlighted path,
|
|
79
|
+
* this component's own plain one in the fallback path.
|
|
80
|
+
* @csspart code - The rendered `<code>`, same split as `pre` above.
|
|
81
|
+
*/
|
|
82
|
+
export class LyraCodeBlock extends LyraElement {
|
|
83
|
+
constructor() {
|
|
84
|
+
super(...arguments);
|
|
85
|
+
/** The raw source text. */
|
|
86
|
+
this.code = '';
|
|
87
|
+
/** A shiki-recognized language id or alias (e.g. `"javascript"`,
|
|
88
|
+
* `"python"`, `"json"`). When unset, or when shiki doesn't recognize it,
|
|
89
|
+
* the code renders as plain unhighlighted text regardless of whether
|
|
90
|
+
* shiki itself is available. */
|
|
91
|
+
this.language = '';
|
|
92
|
+
/** Shown in the header above the code, when set. */
|
|
93
|
+
this.filename = '';
|
|
94
|
+
/** Whether the code region can be collapsed via a header toggle. */
|
|
95
|
+
this.collapsible = false;
|
|
96
|
+
/** Whether the code region is currently hidden. Only has a visible effect
|
|
97
|
+
* while `collapsible` is also true. */
|
|
98
|
+
this.collapsed = false;
|
|
99
|
+
/** Shows a copy-to-clipboard button in the header. */
|
|
100
|
+
this.copyable = true;
|
|
101
|
+
/** A CSS length (e.g. `"20rem"`); once set, the code scrolls internally
|
|
102
|
+
* past this height instead of growing the page. */
|
|
103
|
+
this.maxHeight = '';
|
|
104
|
+
// `null` covers every reason the plain-text fallback is showing: shiki
|
|
105
|
+
// isn't installed, `language` is unset, or `language` isn't shiki-
|
|
106
|
+
// recognized -- `render()` doesn't need to (and can't usefully) tell these
|
|
107
|
+
// apart, same rationale as <lyra-markdown>'s identically-shaped field.
|
|
108
|
+
this.highlightedHtml = null;
|
|
109
|
+
// Becomes true once the shared shiki-loading promise has settled, whether
|
|
110
|
+
// or not it actually resolved to a highlighter -- gates the skeleton (see
|
|
111
|
+
// the class doc's second paragraph), not the highlighting itself.
|
|
112
|
+
this.shikiReady = false;
|
|
113
|
+
this.justCopied = false;
|
|
114
|
+
// Guards the async per-language load in syncHighlight() against a
|
|
115
|
+
// `code`/`language` change that arrives before a previous load resolves --
|
|
116
|
+
// only the result matching the *current* token is ever applied.
|
|
117
|
+
this.highlightToken = 0;
|
|
118
|
+
this.bodyId = nextId('code-block-body');
|
|
119
|
+
this.copy = () => {
|
|
120
|
+
this.writeClipboard(this.code);
|
|
121
|
+
this.emit('lyra-copy', { text: this.code });
|
|
122
|
+
this.justCopied = true;
|
|
123
|
+
clearTimeout(this.copyTimeoutId);
|
|
124
|
+
this.copyTimeoutId = setTimeout(() => {
|
|
125
|
+
this.justCopied = false;
|
|
126
|
+
}, COPY_CONFIRM_MS);
|
|
127
|
+
};
|
|
128
|
+
this.toggleCollapsed = () => {
|
|
129
|
+
this.collapsed = !this.collapsed;
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
133
|
+
connectedCallback() {
|
|
134
|
+
super.connectedCallback();
|
|
135
|
+
void loadShikiHighlighter().then((hl) => {
|
|
136
|
+
this.highlighter = hl;
|
|
137
|
+
this.shikiReady = true;
|
|
138
|
+
this.syncHighlight();
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
disconnectedCallback() {
|
|
142
|
+
super.disconnectedCallback();
|
|
143
|
+
clearTimeout(this.copyTimeoutId);
|
|
144
|
+
}
|
|
145
|
+
// Mutating `highlightedHtml` here (rather than in `updated()`) absorbs the
|
|
146
|
+
// synchronous case -- language already loaded, see `syncHighlight()` --
|
|
147
|
+
// into this same update cycle instead of scheduling a second one, Lit's
|
|
148
|
+
// documented pattern for deriving one reactive property from a change to
|
|
149
|
+
// others (same approach <lyra-markdown>'s `willUpdate` takes).
|
|
150
|
+
willUpdate(changed) {
|
|
151
|
+
if (this.shikiReady && (changed.has('code') || changed.has('language'))) {
|
|
152
|
+
this.syncHighlight();
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
updated() {
|
|
156
|
+
const showingSkeleton = !this.shikiReady && !!this.language;
|
|
157
|
+
if (showingSkeleton)
|
|
158
|
+
this.setAttribute('aria-busy', 'true');
|
|
159
|
+
else
|
|
160
|
+
this.removeAttribute('aria-busy');
|
|
161
|
+
}
|
|
162
|
+
syncHighlight() {
|
|
163
|
+
const hl = this.highlighter;
|
|
164
|
+
const lang = this.language;
|
|
165
|
+
if (!hl || !lang) {
|
|
166
|
+
this.highlightedHtml = null;
|
|
167
|
+
return;
|
|
168
|
+
}
|
|
169
|
+
if (hl.getLoadedLanguages().includes(lang)) {
|
|
170
|
+
this.highlightedHtml = this.tokenize(hl, lang);
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
// Grammar not loaded yet -- show the plain-text fallback in the
|
|
174
|
+
// meantime rather than leaving a *previous* code/language value's stale
|
|
175
|
+
// highlighted markup on screen while this one loads.
|
|
176
|
+
this.highlightedHtml = null;
|
|
177
|
+
const token = ++this.highlightToken;
|
|
178
|
+
void loadShikiLanguage(hl, lang).then((ok) => {
|
|
179
|
+
if (token !== this.highlightToken)
|
|
180
|
+
return; // superseded by a newer code/language change
|
|
181
|
+
this.highlightedHtml = ok ? this.tokenize(hl, lang) : null;
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
tokenize(hl, lang) {
|
|
185
|
+
try {
|
|
186
|
+
return hl.codeToHtml(this.code, {
|
|
187
|
+
lang,
|
|
188
|
+
// shiki's generated per-token colors are theme-specific inline
|
|
189
|
+
// styles/CSS variables (from SHIKI_THEMES's github-light/github-dark
|
|
190
|
+
// theme data), not this library's --lyra-* design tokens -- the one
|
|
191
|
+
// deliberate exception to every other color in this component being
|
|
192
|
+
// a --lyra-* token. See the dark-mode override in
|
|
193
|
+
// code-block.styles.ts for how the dark half of this activates.
|
|
194
|
+
themes: SHIKI_THEMES,
|
|
195
|
+
transformers: [partTransformer],
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// Malformed input for this grammar, or any other shiki-internal
|
|
200
|
+
// failure -- fall back to plain text rather than a blank code block.
|
|
201
|
+
return null;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
writeClipboard(text) {
|
|
205
|
+
try {
|
|
206
|
+
// navigator.clipboard is absent in insecure contexts / older browsers,
|
|
207
|
+
// and some engines throw synchronously rather than rejecting -- either
|
|
208
|
+
// way this is best-effort; copy() below always emits lyra-copy
|
|
209
|
+
// regardless of whether the OS clipboard was actually reached. Same
|
|
210
|
+
// precedent as <lyra-json-viewer>'s own copy button.
|
|
211
|
+
void navigator.clipboard?.writeText(text)?.catch(() => { });
|
|
212
|
+
}
|
|
213
|
+
catch {
|
|
214
|
+
// see above
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
renderHeader() {
|
|
218
|
+
return html `
|
|
219
|
+
<div part="header">
|
|
220
|
+
${this.collapsible
|
|
221
|
+
? html `
|
|
222
|
+
<button
|
|
223
|
+
part="toggle"
|
|
224
|
+
type="button"
|
|
225
|
+
aria-expanded=${this.collapsed ? 'false' : 'true'}
|
|
226
|
+
aria-controls=${this.bodyId}
|
|
227
|
+
aria-label=${this.collapsed ? 'Expand code' : 'Collapse code'}
|
|
228
|
+
@click=${this.toggleCollapsed}
|
|
229
|
+
>
|
|
230
|
+
<span class="chevron" aria-hidden="true">${chevronIcon()}</span>
|
|
231
|
+
</button>
|
|
232
|
+
`
|
|
233
|
+
: nothing}
|
|
234
|
+
${this.filename ? html `<span part="filename">${this.filename}</span>` : nothing}
|
|
235
|
+
${this.language ? html `<span part="language">${this.language}</span>` : nothing}
|
|
236
|
+
${this.copyable
|
|
237
|
+
? html `
|
|
238
|
+
<button
|
|
239
|
+
part="copy-button"
|
|
240
|
+
type="button"
|
|
241
|
+
aria-label=${this.justCopied ? 'Copied to clipboard' : 'Copy code'}
|
|
242
|
+
@click=${this.copy}
|
|
243
|
+
>
|
|
244
|
+
${this.justCopied ? 'Copied!' : 'Copy'}
|
|
245
|
+
</button>
|
|
246
|
+
`
|
|
247
|
+
: nothing}
|
|
248
|
+
</div>
|
|
249
|
+
`;
|
|
250
|
+
}
|
|
251
|
+
// `[part="body"]` is `tabindex="0"` because it's the scrollable region for
|
|
252
|
+
// arbitrarily-wide/tall code (max-height, plus horizontal overflow from
|
|
253
|
+
// long lines) -- a scrollable region with no other focusable content of
|
|
254
|
+
// its own is otherwise unreachable by keyboard, same reasoning
|
|
255
|
+
// lyra-virtual-list's own `[part="base"]` documents for its identical
|
|
256
|
+
// tabindex. `role="group"` (rather than e.g. `region`, a page landmark
|
|
257
|
+
// role) plus `aria-label` gives it an accessible name without claiming
|
|
258
|
+
// landmark/navigation significance for what is, structurally, just one
|
|
259
|
+
// small piece of a larger document.
|
|
260
|
+
render() {
|
|
261
|
+
const hasHeader = !!this.filename || !!this.language || this.copyable || this.collapsible;
|
|
262
|
+
const showSkeleton = !this.shikiReady && !!this.language;
|
|
263
|
+
const bodyHidden = this.collapsible && this.collapsed;
|
|
264
|
+
const bodyLabel = this.filename || (this.language ? `${this.language} code` : 'Code');
|
|
265
|
+
return html `
|
|
266
|
+
<div part="base">
|
|
267
|
+
${hasHeader ? this.renderHeader() : nothing}
|
|
268
|
+
<div
|
|
269
|
+
part="body"
|
|
270
|
+
id=${this.bodyId}
|
|
271
|
+
role="group"
|
|
272
|
+
aria-label=${bodyLabel}
|
|
273
|
+
tabindex="0"
|
|
274
|
+
?hidden=${bodyHidden}
|
|
275
|
+
style=${this.maxHeight ? `--lyra-code-block-max-height:${this.maxHeight}` : nothing}
|
|
276
|
+
>
|
|
277
|
+
${showSkeleton
|
|
278
|
+
? html `<lyra-skeleton variant="rect"></lyra-skeleton>`
|
|
279
|
+
: this.highlightedHtml !== null
|
|
280
|
+
? unsafeHTML(this.highlightedHtml)
|
|
281
|
+
: html `<pre part="pre"><code part="code">${this.code}</code></pre>`}
|
|
282
|
+
</div>
|
|
283
|
+
</div>
|
|
284
|
+
`;
|
|
285
|
+
}
|
|
286
|
+
}
|
|
287
|
+
__decorate([
|
|
288
|
+
property()
|
|
289
|
+
], LyraCodeBlock.prototype, "code", void 0);
|
|
290
|
+
__decorate([
|
|
291
|
+
property()
|
|
292
|
+
], LyraCodeBlock.prototype, "language", void 0);
|
|
293
|
+
__decorate([
|
|
294
|
+
property()
|
|
295
|
+
], LyraCodeBlock.prototype, "filename", void 0);
|
|
296
|
+
__decorate([
|
|
297
|
+
property({ type: Boolean, reflect: true })
|
|
298
|
+
], LyraCodeBlock.prototype, "collapsible", void 0);
|
|
299
|
+
__decorate([
|
|
300
|
+
property({ type: Boolean, reflect: true })
|
|
301
|
+
], LyraCodeBlock.prototype, "collapsed", void 0);
|
|
302
|
+
__decorate([
|
|
303
|
+
property({ type: Boolean, reflect: true })
|
|
304
|
+
], LyraCodeBlock.prototype, "copyable", void 0);
|
|
305
|
+
__decorate([
|
|
306
|
+
property({ attribute: 'max-height' })
|
|
307
|
+
], LyraCodeBlock.prototype, "maxHeight", void 0);
|
|
308
|
+
__decorate([
|
|
309
|
+
state()
|
|
310
|
+
], LyraCodeBlock.prototype, "highlightedHtml", void 0);
|
|
311
|
+
__decorate([
|
|
312
|
+
state()
|
|
313
|
+
], LyraCodeBlock.prototype, "shikiReady", void 0);
|
|
314
|
+
__decorate([
|
|
315
|
+
state()
|
|
316
|
+
], LyraCodeBlock.prototype, "justCopied", void 0);
|
|
317
|
+
defineElement('code-block', LyraCodeBlock);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|