@aceshooting/lyra-ui 1.2.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -14
- package/custom-elements.json +30279 -12124
- package/dist/components/app-rail/app-rail-item.d.ts +30 -0
- package/dist/components/app-rail/app-rail-item.js +68 -0
- package/dist/components/app-rail/app-rail-item.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail-item.styles.js +65 -0
- package/dist/components/app-rail/app-rail.d.ts +168 -0
- package/dist/components/app-rail/app-rail.js +419 -0
- package/dist/components/app-rail/app-rail.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail.styles.js +128 -0
- package/dist/components/attachment-chip/attachment-chip.d.ts +141 -0
- package/dist/components/attachment-chip/attachment-chip.js +356 -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 +96 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +270 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.d.ts +1 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +90 -0
- package/dist/components/chart/bar-chart.js +2 -18
- package/dist/components/chart/box-plot.d.ts +25 -1
- package/dist/components/chart/box-plot.js +147 -7
- package/dist/components/chart/box-plot.styles.js +13 -0
- package/dist/components/chart/bubble-chart.js +2 -18
- 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 +55 -12
- package/dist/components/chart/chart.js +247 -49
- package/dist/components/chart/doughnut-chart.js +2 -18
- package/dist/components/chart/histogram-bin.d.ts +7 -1
- package/dist/components/chart/histogram-bin.js +32 -14
- package/dist/components/chart/histogram.js +8 -16
- package/dist/components/chart/line-chart.js +2 -18
- package/dist/components/chart/lite-chart.d.ts +134 -3
- package/dist/components/chart/lite-chart.js +382 -67
- package/dist/components/chart/lite-chart.styles.js +9 -0
- package/dist/components/chart/pie-chart.js +2 -18
- package/dist/components/chart/polar-area-chart.js +2 -18
- package/dist/components/chart/radar-chart.js +2 -18
- package/dist/components/chart/scatter-chart.js +2 -18
- package/dist/components/chat-composer/chat-composer.d.ts +133 -0
- package/dist/components/chat-composer/chat-composer.js +366 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +1 -0
- package/dist/components/chat-composer/chat-composer.styles.js +145 -0
- package/dist/components/chat-message/chat-message.d.ts +141 -0
- package/dist/components/chat-message/chat-message.js +331 -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 +117 -0
- package/dist/components/checkbox/checkbox.js +353 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.styles.js +77 -0
- package/dist/components/chip/chip-group.d.ts +56 -0
- package/dist/components/chip/chip-group.js +130 -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 +122 -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 +318 -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 +127 -0
- package/dist/components/code-block/code-block.js +382 -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 +87 -0
- package/dist/components/code-block/code-loader.js +142 -0
- package/dist/components/combobox/combobox.d.ts +65 -6
- package/dist/components/combobox/combobox.js +258 -48
- package/dist/components/combobox/combobox.styles.js +3 -3
- 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 +159 -0
- package/dist/components/context-meter/context-meter.styles.d.ts +1 -0
- package/dist/components/context-meter/context-meter.styles.js +114 -0
- package/dist/components/conversation-item/conversation-item.d.ts +125 -0
- package/dist/components/conversation-item/conversation-item.js +331 -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/calendar-core.d.ts +24 -0
- package/dist/components/date-picker/calendar-core.js +51 -4
- package/dist/components/date-picker/date-input.d.ts +100 -9
- package/dist/components/date-picker/date-input.js +383 -66
- package/dist/components/date-picker/date-picker.d.ts +35 -4
- package/dist/components/date-picker/date-picker.js +171 -44
- package/dist/components/dialog/confirm.d.ts +40 -0
- package/dist/components/dialog/confirm.js +76 -0
- package/dist/components/dialog/dialog.d.ts +129 -0
- package/dist/components/dialog/dialog.js +288 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +96 -0
- package/dist/components/dock-panel/dock-panel.d.ts +142 -0
- package/dist/components/dock-panel/dock-panel.js +359 -0
- package/dist/components/dock-panel/dock-panel.styles.d.ts +1 -0
- package/dist/components/dock-panel/dock-panel.styles.js +159 -0
- package/dist/components/document-preview/document-preview.d.ts +143 -0
- package/dist/components/document-preview/document-preview.js +388 -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/empty/empty.d.ts +1 -2
- package/dist/components/empty/empty.js +18 -12
- package/dist/components/empty/empty.styles.js +0 -3
- package/dist/components/export-button/csv.js +1 -1
- package/dist/components/export-button/export-button.d.ts +12 -0
- package/dist/components/export-button/export-button.js +35 -5
- package/dist/components/export-button/export-button.styles.js +5 -1
- package/dist/components/file-input/accept.js +2 -0
- package/dist/components/file-input/file-input.d.ts +10 -1
- package/dist/components/file-input/file-input.js +36 -5
- package/dist/components/flag/flag.d.ts +29 -13
- package/dist/components/flag/flag.js +54 -14
- package/dist/components/flag/flag.styles.js +1 -1
- package/dist/components/flag/language-map.d.ts +4 -1
- package/dist/components/flag/language-map.js +6 -3
- package/dist/components/gauge/gauge.d.ts +10 -1
- package/dist/components/gauge/gauge.js +41 -13
- package/dist/components/generation-status/generation-status.d.ts +117 -0
- package/dist/components/generation-status/generation-status.js +327 -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/graph/graph.d.ts +37 -3
- package/dist/components/graph/graph.js +132 -20
- package/dist/components/heatmap/calendar-grid.d.ts +19 -7
- package/dist/components/heatmap/calendar-grid.js +42 -18
- package/dist/components/heatmap/heatmap-scale.d.ts +11 -1
- package/dist/components/heatmap/heatmap-scale.js +14 -2
- package/dist/components/heatmap/heatmap.d.ts +227 -12
- package/dist/components/heatmap/heatmap.js +488 -93
- package/dist/components/json-viewer/json-viewer.d.ts +70 -0
- package/dist/components/json-viewer/json-viewer.js +361 -0
- package/dist/components/json-viewer/json-viewer.styles.d.ts +1 -0
- package/dist/components/json-viewer/json-viewer.styles.js +177 -0
- package/dist/components/kbd/kbd.d.ts +77 -0
- package/dist/components/kbd/kbd.js +231 -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 +90 -0
- package/dist/components/live-region/live-region.js +189 -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 +32 -7
- package/dist/components/map/map.js +133 -32
- package/dist/components/markdown/markdown-loader.d.ts +58 -0
- package/dist/components/markdown/markdown-loader.js +77 -0
- package/dist/components/markdown/markdown.d.ts +119 -0
- package/dist/components/markdown/markdown.js +389 -0
- package/dist/components/markdown/markdown.styles.d.ts +1 -0
- package/dist/components/markdown/markdown.styles.js +88 -0
- package/dist/components/media-card/media-card.d.ts +130 -0
- package/dist/components/media-card/media-card.js +273 -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 +203 -0
- package/dist/components/mention-popover/mention-popover.js +493 -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 +91 -0
- package/dist/components/menu/menu-item.js +206 -0
- package/dist/components/menu/menu-item.styles.d.ts +1 -0
- package/dist/components/menu/menu-item.styles.js +75 -0
- package/dist/components/menu/menu.d.ts +167 -0
- package/dist/components/menu/menu.js +461 -0
- package/dist/components/menu/menu.styles.d.ts +1 -0
- package/dist/components/menu/menu.styles.js +67 -0
- package/dist/components/model-select/model-select.d.ts +170 -0
- package/dist/components/model-select/model-select.js +588 -0
- package/dist/components/model-select/model-select.styles.d.ts +1 -0
- package/dist/components/model-select/model-select.styles.js +203 -0
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +93 -0
- package/dist/components/model-settings-panel/model-settings-panel.js +209 -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 +19 -3
- package/dist/components/playback/playback.js +109 -33
- package/dist/components/playback/playback.styles.js +6 -1
- package/dist/components/responsive-panel/responsive-panel.d.ts +163 -0
- package/dist/components/responsive-panel/responsive-panel.js +363 -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 +50 -0
- package/dist/components/result-card/result-card.js +89 -0
- package/dist/components/result-card/result-card.styles.d.ts +1 -0
- package/dist/components/result-card/result-card.styles.js +49 -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 +84 -4
- package/dist/components/select/select.js +251 -36
- package/dist/components/skeleton/skeleton.d.ts +3 -0
- package/dist/components/skeleton/skeleton.js +7 -1
- package/dist/components/skeleton/skeleton.styles.js +5 -4
- package/dist/components/slider/slider.d.ts +141 -0
- package/dist/components/slider/slider.js +467 -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 +104 -0
- package/dist/components/source-card/source-card.js +195 -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 +130 -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 +58 -20
- package/dist/components/split/split.d.ts +224 -5
- package/dist/components/split/split.js +617 -43
- package/dist/components/split/split.styles.js +47 -0
- package/dist/components/stat/stat.d.ts +15 -4
- package/dist/components/stat/stat.js +53 -12
- package/dist/components/stream-status/stream-status.d.ts +126 -0
- package/dist/components/stream-status/stream-status.js +292 -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 +104 -0
- package/dist/components/streaming-text/streaming-text.js +224 -0
- package/dist/components/streaming-text/streaming-text.styles.d.ts +1 -0
- package/dist/components/streaming-text/streaming-text.styles.js +63 -0
- package/dist/components/switch/switch.d.ts +103 -0
- package/dist/components/switch/switch.js +250 -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 +89 -5
- package/dist/components/table/table.js +243 -26
- package/dist/components/table/table.styles.js +6 -1
- package/dist/components/tabs/tabs.d.ts +74 -0
- package/dist/components/tabs/tabs.js +254 -0
- package/dist/components/tabs/tabs.styles.d.ts +1 -0
- package/dist/components/tabs/tabs.styles.js +74 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +123 -0
- package/dist/components/thinking-panel/thinking-panel.js +260 -0
- package/dist/components/thinking-panel/thinking-panel.styles.d.ts +1 -0
- package/dist/components/thinking-panel/thinking-panel.styles.js +123 -0
- package/dist/components/time-range/time-range.d.ts +59 -2
- package/dist/components/time-range/time-range.js +163 -67
- package/dist/components/toast/toast-item.d.ts +12 -2
- package/dist/components/toast/toast-item.js +106 -44
- package/dist/components/toast/toast-item.styles.js +59 -28
- package/dist/components/toast/toast.js +17 -5
- package/dist/components/toast/toaster.js +10 -1
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +131 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +329 -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 +105 -0
- package/dist/components/tool-call-chip/tool-call-chip.js +349 -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 +206 -0
- package/dist/components/tool-param-form/tool-param-form.js +610 -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 +122 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.js +358 -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 +73 -0
- package/dist/components/tool-result-view/registry.js +89 -0
- package/dist/components/tool-result-view/tool-result-view.d.ts +58 -0
- package/dist/components/tool-result-view/tool-result-view.js +152 -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 +350 -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 +191 -0
- package/dist/components/tree/tree-node.d.ts +15 -3
- package/dist/components/tree/tree-node.js +20 -7
- package/dist/components/tree/tree.d.ts +25 -10
- package/dist/components/tree/tree.js +39 -31
- package/dist/components/typing-indicator/typing-indicator.d.ts +70 -0
- package/dist/components/typing-indicator/typing-indicator.js +108 -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 +210 -0
- package/dist/components/virtual-list/virtual-list.js +607 -0
- package/dist/components/virtual-list/virtual-list.styles.d.ts +1 -0
- package/dist/components/virtual-list/virtual-list.styles.js +56 -0
- package/dist/components/widget/widget.d.ts +5 -4
- package/dist/components/widget/widget.js +54 -120
- package/dist/components/widget/widget.styles.js +8 -2
- package/dist/components/word-cloud/word-cloud-layout.d.ts +7 -0
- package/dist/components/word-cloud/word-cloud-layout.js +29 -2
- package/dist/components/word-cloud/word-cloud.d.ts +28 -2
- package/dist/components/word-cloud/word-cloud.js +69 -19
- package/dist/components/word-cloud/word-cloud.styles.js +16 -3
- package/dist/internal/anchored-validity.d.ts +1 -0
- package/dist/internal/anchored-validity.js +86 -0
- package/dist/internal/announcer.d.ts +57 -0
- package/dist/internal/announcer.js +71 -0
- package/dist/internal/form-associated.d.ts +8 -0
- package/dist/internal/form-associated.js +98 -15
- package/dist/internal/group-by-recency.d.ts +50 -0
- package/dist/internal/group-by-recency.js +80 -0
- package/dist/internal/numbers.d.ts +12 -0
- package/dist/internal/numbers.js +26 -0
- package/dist/internal/overlay-manager.d.ts +51 -0
- package/dist/internal/overlay-manager.js +523 -0
- package/dist/internal/positioner.js +27 -3
- package/dist/internal/rtl.d.ts +23 -0
- package/dist/internal/rtl.js +28 -0
- package/dist/internal/safe-url.d.ts +12 -0
- package/dist/internal/safe-url.js +41 -0
- package/dist/internal/scroll-lock.d.ts +10 -5
- package/dist/internal/scroll-lock.js +30 -14
- package/dist/internal/tokens.styles.js +22 -10
- package/dist/lyra.d.ts +133 -31
- package/dist/lyra.js +96 -26
- package/llms-full.txt +4546 -183
- package/llms.txt +21 -5
- package/package.json +41 -6
- 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 -14
- package/dist/components/chart/lite-chart.stories.js +0 -114
- 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 -6
- package/dist/components/flag/flag.stories.js +0 -31
- 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 -27
- package/dist/components/heatmap/heatmap.stories.js +0 -179
- 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 -21
- package/dist/components/select/select.stories.js +0 -91
- 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 -9
- package/dist/components/stat/stat.stories.js +0 -81
- 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 -9
- package/dist/components/widget/widget.stories.js +0 -74
- 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,145 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
[part='base'] {
|
|
7
|
+
display: flex;
|
|
8
|
+
flex-direction: column;
|
|
9
|
+
gap: var(--lyra-space-xs);
|
|
10
|
+
box-sizing: border-box;
|
|
11
|
+
border: 1px solid var(--lyra-color-border);
|
|
12
|
+
border-radius: var(--lyra-radius);
|
|
13
|
+
background: var(--lyra-color-surface);
|
|
14
|
+
padding: var(--lyra-space-s);
|
|
15
|
+
transition: border-color var(--lyra-transition-fast);
|
|
16
|
+
}
|
|
17
|
+
[part='base']:focus-within {
|
|
18
|
+
border-color: var(--lyra-color-brand);
|
|
19
|
+
}
|
|
20
|
+
/* :host(:disabled), not :host([disabled]) -- this is a form-associated
|
|
21
|
+
custom element (FormAssociated mixin -> static formAssociated = true),
|
|
22
|
+
so the UA computes its disabled state (and therefore :disabled/:enabled
|
|
23
|
+
matching) the same way it does for a native form control: from its own
|
|
24
|
+
disabled content attribute *or* an ancestor <fieldset disabled>'s
|
|
25
|
+
cascade. Keying this off the attribute selector only ever matched the
|
|
26
|
+
first case -- a composer disabled purely via an ancestor fieldset had
|
|
27
|
+
effectiveDisabled correctly gating the textarea/button underneath, but
|
|
28
|
+
the card around them still rendered at full opacity with a normal
|
|
29
|
+
cursor. */
|
|
30
|
+
:host(:disabled) [part='base'] {
|
|
31
|
+
opacity: var(--lyra-opacity-disabled);
|
|
32
|
+
cursor: not-allowed;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* :empty never matches [part='chips'] -- it always contains a literal
|
|
36
|
+
<slot> child regardless of assigned content -- so real emptiness is
|
|
37
|
+
tracked in JS (hasChipsSlot) and reflected via [hidden] instead (same
|
|
38
|
+
fix as lyra-date-input's hint/error parts). Author-level display rules
|
|
39
|
+
always beat the UA stylesheet's [hidden] rule regardless of source
|
|
40
|
+
order/specificity (different cascade origins), so the override below is
|
|
41
|
+
required, not redundant. */
|
|
42
|
+
[part='chips'] {
|
|
43
|
+
display: flex;
|
|
44
|
+
flex-wrap: wrap;
|
|
45
|
+
gap: var(--lyra-space-xs);
|
|
46
|
+
}
|
|
47
|
+
[part='chips'][hidden] {
|
|
48
|
+
display: none;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
[part='row'] {
|
|
52
|
+
display: flex;
|
|
53
|
+
align-items: flex-end;
|
|
54
|
+
gap: var(--lyra-space-s);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
[part='leading'] {
|
|
58
|
+
display: flex;
|
|
59
|
+
flex: 0 0 auto;
|
|
60
|
+
align-items: center;
|
|
61
|
+
/* Matches the textarea's own first-line box so a leading icon button
|
|
62
|
+
sits level with placeholder/typed text at min-rows, not glued to the
|
|
63
|
+
row's cross-axis edge. */
|
|
64
|
+
padding-block-end: var(--lyra-space-xs);
|
|
65
|
+
}
|
|
66
|
+
[part='leading'][hidden] {
|
|
67
|
+
display: none;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
[part='textarea'] {
|
|
71
|
+
flex: 1 1 auto;
|
|
72
|
+
min-inline-size: 0;
|
|
73
|
+
box-sizing: border-box;
|
|
74
|
+
resize: none;
|
|
75
|
+
border: none;
|
|
76
|
+
outline: none;
|
|
77
|
+
background: transparent;
|
|
78
|
+
color: inherit;
|
|
79
|
+
font: inherit;
|
|
80
|
+
/* A concrete, unitless line-height so the runtime auto-resize logic
|
|
81
|
+
(chat-composer.ts's resizeTextarea()) can read a real pixel value
|
|
82
|
+
back out of getComputedStyle() -- the UA default of "normal" has no
|
|
83
|
+
single resolved px figure to measure rows against. */
|
|
84
|
+
line-height: 1.5;
|
|
85
|
+
padding-block: var(--lyra-space-xs);
|
|
86
|
+
overflow-y: hidden;
|
|
87
|
+
}
|
|
88
|
+
[part='textarea']::placeholder {
|
|
89
|
+
color: var(--lyra-color-text-quiet);
|
|
90
|
+
}
|
|
91
|
+
[part='textarea']:disabled {
|
|
92
|
+
cursor: not-allowed;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
[part='trailing'] {
|
|
96
|
+
display: flex;
|
|
97
|
+
flex: 0 0 auto;
|
|
98
|
+
align-items: center;
|
|
99
|
+
gap: var(--lyra-space-xs);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
[part='action-button'] {
|
|
103
|
+
display: inline-flex;
|
|
104
|
+
align-items: center;
|
|
105
|
+
justify-content: center;
|
|
106
|
+
flex: 0 0 auto;
|
|
107
|
+
box-sizing: border-box;
|
|
108
|
+
min-inline-size: var(--lyra-icon-button-size);
|
|
109
|
+
min-block-size: var(--lyra-icon-button-size);
|
|
110
|
+
border: none;
|
|
111
|
+
border-radius: var(--lyra-radius);
|
|
112
|
+
background: var(--lyra-color-brand);
|
|
113
|
+
color: var(--lyra-color-on-brand);
|
|
114
|
+
font-size: 1.125rem;
|
|
115
|
+
line-height: 1;
|
|
116
|
+
cursor: pointer;
|
|
117
|
+
transition: background-color var(--lyra-transition-fast);
|
|
118
|
+
}
|
|
119
|
+
[part='action-button']:hover {
|
|
120
|
+
background: var(--lyra-color-brand);
|
|
121
|
+
filter: brightness(1.1);
|
|
122
|
+
}
|
|
123
|
+
[part='action-button']:focus-visible {
|
|
124
|
+
outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
|
|
125
|
+
outline-offset: var(--lyra-focus-ring-offset);
|
|
126
|
+
}
|
|
127
|
+
[part='action-button']:disabled {
|
|
128
|
+
cursor: not-allowed;
|
|
129
|
+
opacity: var(--lyra-opacity-disabled);
|
|
130
|
+
}
|
|
131
|
+
/* Stop affordance while generating -- a neutral/quiet treatment rather
|
|
132
|
+
than the resting brand fill, so it doesn't read as "send is still
|
|
133
|
+
available" while a response is in flight. */
|
|
134
|
+
:host([status='sending']) [part='action-button'],
|
|
135
|
+
:host([status='streaming']) [part='action-button'] {
|
|
136
|
+
background: var(--lyra-color-text-quiet);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
@media (prefers-reduced-motion: reduce) {
|
|
140
|
+
[part='base'],
|
|
141
|
+
[part='action-button'] {
|
|
142
|
+
transition: none !important;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
`;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
import '../live-region/live-region.js';
|
|
4
|
+
export type ChatMessageRole = 'user' | 'assistant' | 'system';
|
|
5
|
+
export type ChatMessageStatus = 'sending' | 'sent' | 'failed' | 'streaming';
|
|
6
|
+
/**
|
|
7
|
+
* `<lyra-chat-message>` — a role-based message bubble *shell* for a chat/
|
|
8
|
+
* agent conversation surface. It renders none of the message content itself:
|
|
9
|
+
* the default slot carries whatever a consumer wants to display (plain
|
|
10
|
+
* text, a `<lyra-markdown>`, a custom template, anything at all) and this
|
|
11
|
+
* component only supplies the surrounding chrome — alignment/coloring by
|
|
12
|
+
* `role`, an avatar/badges header row, an optional collapse toggle, an
|
|
13
|
+
* attachments strip, and a status-aware footer (a live-updating status dot +
|
|
14
|
+
* text, the formatted `timestamp`, a built-in retry affordance for
|
|
15
|
+
* `status="failed"`, and an `actions` slot for everything else).
|
|
16
|
+
*
|
|
17
|
+
* No built-in copy button is rendered. Deciding what "the copyable text" of
|
|
18
|
+
* an arbitrary slotted message even means (plain text? the rendered
|
|
19
|
+
* markdown source? something else?) is exactly the kind of content
|
|
20
|
+
* interpretation this shell deliberately stays out of — slot a copy control
|
|
21
|
+
* into `actions` instead. Firing `lyra-copy` (`detail: { text }`) from that
|
|
22
|
+
* control keeps the event name consistent with `<lyra-json-viewer>`'s own
|
|
23
|
+
* copy affordance, for anything listening at the conversation-surface level.
|
|
24
|
+
*
|
|
25
|
+
* Accessibility of `status`: the current status is always available as
|
|
26
|
+
* plain visible text (`[part="status-text"]`), never color alone. A
|
|
27
|
+
* transition *to* `"failed"`, or *from* `"streaming"` to `"sent"` (a stream
|
|
28
|
+
* finishing), is additionally announced through an internal
|
|
29
|
+
* `<lyra-live-region>` (see that component's header for the throttled-
|
|
30
|
+
* announcement wiring this composes) so a screen-reader user who isn't
|
|
31
|
+
* currently focused on this message still learns about it. This differs
|
|
32
|
+
* from `<lyra-typing-indicator>`'s deliberately simpler `role="status"`
|
|
33
|
+
* approach — that component only ever has one thing to announce (its own
|
|
34
|
+
* mount); this one has a `status` that can flip between several values
|
|
35
|
+
* across a single element's lifetime, which is exactly the coalescing job
|
|
36
|
+
* `<lyra-live-region>` exists for.
|
|
37
|
+
*
|
|
38
|
+
* `role` is a message-author role (`user`/`assistant`/`system`, matching
|
|
39
|
+
* the vocabulary of every chat/completion API), *not* a WAI-ARIA role, so
|
|
40
|
+
* it reflects to a `data-role` attribute rather than the bare `role`
|
|
41
|
+
* attribute — `role="user"` would collide with `Element`'s own ARIA `role`
|
|
42
|
+
* accessor and is not a valid ARIA role token to begin with.
|
|
43
|
+
*
|
|
44
|
+
* @customElement lyra-chat-message
|
|
45
|
+
* @slot - The message body.
|
|
46
|
+
* @slot avatar - An avatar/icon for the message author.
|
|
47
|
+
* @slot badges - Small status/metric chips (e.g. token count, latency, model name) — entirely app-supplied; this component computes none of that itself.
|
|
48
|
+
* @slot actions - Action controls (e.g. copy, retry), rendered at the end of the footer.
|
|
49
|
+
* @slot attachments - File/image attachment chips, rendered below the message body.
|
|
50
|
+
* @event lyra-retry - Fired by the built-in retry button, only rendered when `status="failed"`.
|
|
51
|
+
* @event lyra-collapse-toggle - `detail: boolean` (the new `collapsed` state) — fired when the user activates the built-in collapse button.
|
|
52
|
+
* @csspart bubble - The message bubble root. Programmatically focusable (`tabindex="-1"`) so focus has a stable place to land when the built-in retry button is removed (e.g. a `lyra-retry` listener flipping `status` away from `"failed"`).
|
|
53
|
+
* @csspart header - The row above the message body — avatar, badges, and the collapse toggle. Hidden entirely when none of those have anything to show.
|
|
54
|
+
* @csspart avatar - The wrapper around the `avatar` slot.
|
|
55
|
+
* @csspart badges - The wrapper around the `badges` slot.
|
|
56
|
+
* @csspart collapse-button - The built-in collapse/expand toggle (only rendered when `collapsible`).
|
|
57
|
+
* @csspart body - The wrapper around the default slot (the message content). Hidden while `collapsed`.
|
|
58
|
+
* @csspart attachments - The wrapper around the `attachments` slot.
|
|
59
|
+
* @csspart footer - The row below the message body — status, timestamp, retry, and actions. Hidden entirely when none of those have anything to show.
|
|
60
|
+
* @csspart status-indicator - A small decorative (`aria-hidden`) dot reflecting `status`; absent while `status="sent"`.
|
|
61
|
+
* @csspart status-text - The visible text twin of `status-indicator` — carries the state in text, not just color.
|
|
62
|
+
* @csspart timestamp - The formatted `timestamp`, rendered in a `<time>` element.
|
|
63
|
+
* @csspart retry-button - The built-in retry button (only rendered when `status="failed"`).
|
|
64
|
+
* @csspart actions - The wrapper around the `actions` slot.
|
|
65
|
+
*/
|
|
66
|
+
export declare class LyraChatMessage extends LyraElement {
|
|
67
|
+
static styles: import("lit").CSSResultGroup[];
|
|
68
|
+
static properties: {
|
|
69
|
+
status: {
|
|
70
|
+
reflect: boolean;
|
|
71
|
+
noAccessor: boolean;
|
|
72
|
+
};
|
|
73
|
+
};
|
|
74
|
+
/** Who authored the message. Reflects to `data-role` — see the class doc. */
|
|
75
|
+
role: ChatMessageRole;
|
|
76
|
+
/** When the message was sent/received. Accepts a `Date` or anything
|
|
77
|
+
* `new Date()` can parse (e.g. an ISO 8601 string); invalid input is
|
|
78
|
+
* treated the same as unset (no timestamp rendered). */
|
|
79
|
+
timestamp?: Date | string;
|
|
80
|
+
/** Overrides the default `hour:minute` rendering of `timestamp` — this
|
|
81
|
+
* library has no i18n system of its own, so an overridable formatter is
|
|
82
|
+
* the established way to hand locale-sensitive display back to the
|
|
83
|
+
* consumer (mirrors `lyra-heatmap`'s `cellText`). */
|
|
84
|
+
formatTimestamp?: (date: Date) => string;
|
|
85
|
+
/** Shows the built-in collapse/expand toggle in the header. */
|
|
86
|
+
collapsible: boolean;
|
|
87
|
+
/** Whether the message body is currently hidden. Effective whenever set,
|
|
88
|
+
* independent of `collapsible` — `collapsible` only controls whether the
|
|
89
|
+
* built-in toggle button is rendered, mirroring `lyra-widget`'s identical
|
|
90
|
+
* `collapsible`/`collapsed` pair. */
|
|
91
|
+
collapsed: boolean;
|
|
92
|
+
private hasAvatarSlot;
|
|
93
|
+
private hasBadgesSlot;
|
|
94
|
+
private hasAttachmentsSlot;
|
|
95
|
+
private hasActionsSlot;
|
|
96
|
+
private liveRegion?;
|
|
97
|
+
private bubbleEl?;
|
|
98
|
+
private readonly bodyId;
|
|
99
|
+
private _status;
|
|
100
|
+
/** The value `status` held immediately before its current one, recorded
|
|
101
|
+
* at the point of assignment in the setter below -- *not* derived from
|
|
102
|
+
* Lit's `changed`/`changedProperties`, which only ever remembers the
|
|
103
|
+
* single oldest value seen since the last completed update. Without this,
|
|
104
|
+
* setting `status` to `"streaming"` and then immediately overwriting it
|
|
105
|
+
* (e.g. to `"sent"`) within the same task, with no render in between,
|
|
106
|
+
* would silently lose the `"streaming"` intermediate value before
|
|
107
|
+
* `announceStatusChange` ever gets to see it. */
|
|
108
|
+
private previousStatus;
|
|
109
|
+
/** True only until the component's first completed update -- gates the
|
|
110
|
+
* status-change announcement below so a message never announces
|
|
111
|
+
* whatever status it happens to mount with (mirrors the same "not on
|
|
112
|
+
* first paint" intent `willUpdate`'s `!this.hasUpdated` check has for the
|
|
113
|
+
* slot-presence flags, except `this.hasUpdated` itself is already `true`
|
|
114
|
+
* by the time `updated()` runs for the first time, so it can't be reused
|
|
115
|
+
* here). */
|
|
116
|
+
private isMounting;
|
|
117
|
+
/** Delivery/generation state. Drives the footer's status dot/text and,
|
|
118
|
+
* for `"failed"`, the bubble's danger treatment and the built-in retry
|
|
119
|
+
* button. Declared via `static properties` above with a hand-written
|
|
120
|
+
* accessor (see `previousStatus`). */
|
|
121
|
+
get status(): ChatMessageStatus;
|
|
122
|
+
set status(value: ChatMessageStatus);
|
|
123
|
+
protected willUpdate(): void;
|
|
124
|
+
protected updated(changed: PropertyValues): void;
|
|
125
|
+
private hasSlotted;
|
|
126
|
+
private get normalizedTimestamp();
|
|
127
|
+
private get statusText();
|
|
128
|
+
private announceStatusChange;
|
|
129
|
+
private onAvatarSlotChange;
|
|
130
|
+
private onBadgesSlotChange;
|
|
131
|
+
private onAttachmentsSlotChange;
|
|
132
|
+
private onActionsSlotChange;
|
|
133
|
+
private toggleCollapsed;
|
|
134
|
+
private onRetryClick;
|
|
135
|
+
render(): TemplateResult;
|
|
136
|
+
}
|
|
137
|
+
declare global {
|
|
138
|
+
interface HTMLElementTagNameMap {
|
|
139
|
+
'lyra-chat-message': LyraChatMessage;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,331 @@
|
|
|
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, svg } from 'lit';
|
|
8
|
+
import { property, state, query } from 'lit/decorators.js';
|
|
9
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
11
|
+
import { nextId } from '../../internal/a11y.js';
|
|
12
|
+
import { chevronIcon } from '../../internal/icons.js';
|
|
13
|
+
import '../live-region/live-region.js';
|
|
14
|
+
import { styles } from './chat-message.styles.js';
|
|
15
|
+
// Mirrors the shared icon set's viewBox/stroke conventions
|
|
16
|
+
// (internal/icons.ts's chevronIcon()/closeIcon()/etc.) without adding a
|
|
17
|
+
// retry glyph to that module -- it's off limits here -- so this one-off icon
|
|
18
|
+
// still reads as part of the same visual language as the rest of the
|
|
19
|
+
// library's inline icons. Same approach lyra-checkbox's own local
|
|
20
|
+
// checkmark/indeterminate glyphs take for the identical reason.
|
|
21
|
+
const ICON_VIEW_BOX = '0 0 24 24';
|
|
22
|
+
const ICON_STROKE_WIDTH = '1.75';
|
|
23
|
+
function retryIcon() {
|
|
24
|
+
return svg `
|
|
25
|
+
<svg
|
|
26
|
+
width="1em"
|
|
27
|
+
height="1em"
|
|
28
|
+
viewBox=${ICON_VIEW_BOX}
|
|
29
|
+
fill="none"
|
|
30
|
+
stroke="currentColor"
|
|
31
|
+
stroke-width=${ICON_STROKE_WIDTH}
|
|
32
|
+
stroke-linecap="round"
|
|
33
|
+
stroke-linejoin="round"
|
|
34
|
+
aria-hidden="true"
|
|
35
|
+
focusable="false"
|
|
36
|
+
><polyline points="1 4 1 10 7 10"></polyline><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path></svg>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
/** `hour:minute` in the runtime's default locale -- the sensible baseline
|
|
40
|
+
* this library (with no i18n system of its own) can offer without
|
|
41
|
+
* hardcoding English strings; `formatTimestamp` overrides it. */
|
|
42
|
+
function defaultFormatTimestamp(date) {
|
|
43
|
+
return new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' }).format(date);
|
|
44
|
+
}
|
|
45
|
+
/** Visible (not just color-coded) text for every non-resting status --
|
|
46
|
+
* `'sent'` renders nothing here, it's the resting state. */
|
|
47
|
+
const STATUS_TEXT = {
|
|
48
|
+
sending: 'Sending…',
|
|
49
|
+
streaming: 'Responding…',
|
|
50
|
+
failed: 'Failed to send',
|
|
51
|
+
};
|
|
52
|
+
/**
|
|
53
|
+
* `<lyra-chat-message>` — a role-based message bubble *shell* for a chat/
|
|
54
|
+
* agent conversation surface. It renders none of the message content itself:
|
|
55
|
+
* the default slot carries whatever a consumer wants to display (plain
|
|
56
|
+
* text, a `<lyra-markdown>`, a custom template, anything at all) and this
|
|
57
|
+
* component only supplies the surrounding chrome — alignment/coloring by
|
|
58
|
+
* `role`, an avatar/badges header row, an optional collapse toggle, an
|
|
59
|
+
* attachments strip, and a status-aware footer (a live-updating status dot +
|
|
60
|
+
* text, the formatted `timestamp`, a built-in retry affordance for
|
|
61
|
+
* `status="failed"`, and an `actions` slot for everything else).
|
|
62
|
+
*
|
|
63
|
+
* No built-in copy button is rendered. Deciding what "the copyable text" of
|
|
64
|
+
* an arbitrary slotted message even means (plain text? the rendered
|
|
65
|
+
* markdown source? something else?) is exactly the kind of content
|
|
66
|
+
* interpretation this shell deliberately stays out of — slot a copy control
|
|
67
|
+
* into `actions` instead. Firing `lyra-copy` (`detail: { text }`) from that
|
|
68
|
+
* control keeps the event name consistent with `<lyra-json-viewer>`'s own
|
|
69
|
+
* copy affordance, for anything listening at the conversation-surface level.
|
|
70
|
+
*
|
|
71
|
+
* Accessibility of `status`: the current status is always available as
|
|
72
|
+
* plain visible text (`[part="status-text"]`), never color alone. A
|
|
73
|
+
* transition *to* `"failed"`, or *from* `"streaming"` to `"sent"` (a stream
|
|
74
|
+
* finishing), is additionally announced through an internal
|
|
75
|
+
* `<lyra-live-region>` (see that component's header for the throttled-
|
|
76
|
+
* announcement wiring this composes) so a screen-reader user who isn't
|
|
77
|
+
* currently focused on this message still learns about it. This differs
|
|
78
|
+
* from `<lyra-typing-indicator>`'s deliberately simpler `role="status"`
|
|
79
|
+
* approach — that component only ever has one thing to announce (its own
|
|
80
|
+
* mount); this one has a `status` that can flip between several values
|
|
81
|
+
* across a single element's lifetime, which is exactly the coalescing job
|
|
82
|
+
* `<lyra-live-region>` exists for.
|
|
83
|
+
*
|
|
84
|
+
* `role` is a message-author role (`user`/`assistant`/`system`, matching
|
|
85
|
+
* the vocabulary of every chat/completion API), *not* a WAI-ARIA role, so
|
|
86
|
+
* it reflects to a `data-role` attribute rather than the bare `role`
|
|
87
|
+
* attribute — `role="user"` would collide with `Element`'s own ARIA `role`
|
|
88
|
+
* accessor and is not a valid ARIA role token to begin with.
|
|
89
|
+
*
|
|
90
|
+
* @customElement lyra-chat-message
|
|
91
|
+
* @slot - The message body.
|
|
92
|
+
* @slot avatar - An avatar/icon for the message author.
|
|
93
|
+
* @slot badges - Small status/metric chips (e.g. token count, latency, model name) — entirely app-supplied; this component computes none of that itself.
|
|
94
|
+
* @slot actions - Action controls (e.g. copy, retry), rendered at the end of the footer.
|
|
95
|
+
* @slot attachments - File/image attachment chips, rendered below the message body.
|
|
96
|
+
* @event lyra-retry - Fired by the built-in retry button, only rendered when `status="failed"`.
|
|
97
|
+
* @event lyra-collapse-toggle - `detail: boolean` (the new `collapsed` state) — fired when the user activates the built-in collapse button.
|
|
98
|
+
* @csspart bubble - The message bubble root. Programmatically focusable (`tabindex="-1"`) so focus has a stable place to land when the built-in retry button is removed (e.g. a `lyra-retry` listener flipping `status` away from `"failed"`).
|
|
99
|
+
* @csspart header - The row above the message body — avatar, badges, and the collapse toggle. Hidden entirely when none of those have anything to show.
|
|
100
|
+
* @csspart avatar - The wrapper around the `avatar` slot.
|
|
101
|
+
* @csspart badges - The wrapper around the `badges` slot.
|
|
102
|
+
* @csspart collapse-button - The built-in collapse/expand toggle (only rendered when `collapsible`).
|
|
103
|
+
* @csspart body - The wrapper around the default slot (the message content). Hidden while `collapsed`.
|
|
104
|
+
* @csspart attachments - The wrapper around the `attachments` slot.
|
|
105
|
+
* @csspart footer - The row below the message body — status, timestamp, retry, and actions. Hidden entirely when none of those have anything to show.
|
|
106
|
+
* @csspart status-indicator - A small decorative (`aria-hidden`) dot reflecting `status`; absent while `status="sent"`.
|
|
107
|
+
* @csspart status-text - The visible text twin of `status-indicator` — carries the state in text, not just color.
|
|
108
|
+
* @csspart timestamp - The formatted `timestamp`, rendered in a `<time>` element.
|
|
109
|
+
* @csspart retry-button - The built-in retry button (only rendered when `status="failed"`).
|
|
110
|
+
* @csspart actions - The wrapper around the `actions` slot.
|
|
111
|
+
*/
|
|
112
|
+
export class LyraChatMessage extends LyraElement {
|
|
113
|
+
constructor() {
|
|
114
|
+
super(...arguments);
|
|
115
|
+
/** Who authored the message. Reflects to `data-role` — see the class doc. */
|
|
116
|
+
this.role = 'assistant';
|
|
117
|
+
/** Shows the built-in collapse/expand toggle in the header. */
|
|
118
|
+
this.collapsible = false;
|
|
119
|
+
/** Whether the message body is currently hidden. Effective whenever set,
|
|
120
|
+
* independent of `collapsible` — `collapsible` only controls whether the
|
|
121
|
+
* built-in toggle button is rendered, mirroring `lyra-widget`'s identical
|
|
122
|
+
* `collapsible`/`collapsed` pair. */
|
|
123
|
+
this.collapsed = false;
|
|
124
|
+
this.hasAvatarSlot = false;
|
|
125
|
+
this.hasBadgesSlot = false;
|
|
126
|
+
this.hasAttachmentsSlot = false;
|
|
127
|
+
this.hasActionsSlot = false;
|
|
128
|
+
this.bodyId = nextId('chat-message-body');
|
|
129
|
+
this._status = 'sent';
|
|
130
|
+
/** The value `status` held immediately before its current one, recorded
|
|
131
|
+
* at the point of assignment in the setter below -- *not* derived from
|
|
132
|
+
* Lit's `changed`/`changedProperties`, which only ever remembers the
|
|
133
|
+
* single oldest value seen since the last completed update. Without this,
|
|
134
|
+
* setting `status` to `"streaming"` and then immediately overwriting it
|
|
135
|
+
* (e.g. to `"sent"`) within the same task, with no render in between,
|
|
136
|
+
* would silently lose the `"streaming"` intermediate value before
|
|
137
|
+
* `announceStatusChange` ever gets to see it. */
|
|
138
|
+
this.previousStatus = 'sent';
|
|
139
|
+
/** True only until the component's first completed update -- gates the
|
|
140
|
+
* status-change announcement below so a message never announces
|
|
141
|
+
* whatever status it happens to mount with (mirrors the same "not on
|
|
142
|
+
* first paint" intent `willUpdate`'s `!this.hasUpdated` check has for the
|
|
143
|
+
* slot-presence flags, except `this.hasUpdated` itself is already `true`
|
|
144
|
+
* by the time `updated()` runs for the first time, so it can't be reused
|
|
145
|
+
* here). */
|
|
146
|
+
this.isMounting = true;
|
|
147
|
+
this.onAvatarSlotChange = (e) => {
|
|
148
|
+
this.hasAvatarSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
149
|
+
};
|
|
150
|
+
this.onBadgesSlotChange = (e) => {
|
|
151
|
+
this.hasBadgesSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
152
|
+
};
|
|
153
|
+
this.onAttachmentsSlotChange = (e) => {
|
|
154
|
+
this.hasAttachmentsSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
155
|
+
};
|
|
156
|
+
this.onActionsSlotChange = (e) => {
|
|
157
|
+
this.hasActionsSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
158
|
+
};
|
|
159
|
+
this.toggleCollapsed = () => {
|
|
160
|
+
this.collapsed = !this.collapsed;
|
|
161
|
+
this.emit('lyra-collapse-toggle', this.collapsed);
|
|
162
|
+
};
|
|
163
|
+
this.onRetryClick = () => {
|
|
164
|
+
// A `lyra-retry` listener is documented to respond by flipping `status`
|
|
165
|
+
// away from `"failed"`, which removes this very button on the next
|
|
166
|
+
// render. Move focus to the always-rendered bubble first, synchronously,
|
|
167
|
+
// so it lands somewhere stable inside the message instead of silently
|
|
168
|
+
// reverting to `<body>` once the button it was on disappears.
|
|
169
|
+
this.bubbleEl?.focus();
|
|
170
|
+
this.emit('lyra-retry');
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
174
|
+
// `status` needs a hand-written accessor (see `previousStatus` below) so
|
|
175
|
+
// it's declared via `static properties` + `noAccessor` rather than
|
|
176
|
+
// `@property()` directly -- the same pattern `lyra-playback`'s `playing`
|
|
177
|
+
// uses for the identical reason (a property whose setter must run real
|
|
178
|
+
// logic on every assignment, not just on the next completed render).
|
|
179
|
+
static { this.properties = {
|
|
180
|
+
status: { reflect: true, noAccessor: true },
|
|
181
|
+
}; }
|
|
182
|
+
/** Delivery/generation state. Drives the footer's status dot/text and,
|
|
183
|
+
* for `"failed"`, the bubble's danger treatment and the built-in retry
|
|
184
|
+
* button. Declared via `static properties` above with a hand-written
|
|
185
|
+
* accessor (see `previousStatus`). */
|
|
186
|
+
get status() {
|
|
187
|
+
return this._status;
|
|
188
|
+
}
|
|
189
|
+
set status(value) {
|
|
190
|
+
const old = this._status;
|
|
191
|
+
if (value === old)
|
|
192
|
+
return;
|
|
193
|
+
this.previousStatus = old;
|
|
194
|
+
this._status = value;
|
|
195
|
+
this.requestUpdate('status', old);
|
|
196
|
+
}
|
|
197
|
+
willUpdate() {
|
|
198
|
+
if (!this.hasUpdated) {
|
|
199
|
+
this.hasAvatarSlot = this.hasSlotted('avatar');
|
|
200
|
+
this.hasBadgesSlot = this.hasSlotted('badges');
|
|
201
|
+
this.hasAttachmentsSlot = this.hasSlotted('attachments');
|
|
202
|
+
this.hasActionsSlot = this.hasSlotted('actions');
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
updated(changed) {
|
|
206
|
+
const wasMounting = this.isMounting;
|
|
207
|
+
this.isMounting = false;
|
|
208
|
+
if (!wasMounting && changed.has('status')) {
|
|
209
|
+
this.announceStatusChange(this.previousStatus);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
hasSlotted(name) {
|
|
213
|
+
return Array.from(this.children).some((el) => el.getAttribute('slot') === name);
|
|
214
|
+
}
|
|
215
|
+
get normalizedTimestamp() {
|
|
216
|
+
if (this.timestamp === undefined)
|
|
217
|
+
return undefined;
|
|
218
|
+
const date = this.timestamp instanceof Date ? this.timestamp : new Date(this.timestamp);
|
|
219
|
+
return Number.isNaN(date.getTime()) ? undefined : date;
|
|
220
|
+
}
|
|
221
|
+
get statusText() {
|
|
222
|
+
return this.status === 'sent' ? undefined : STATUS_TEXT[this.status];
|
|
223
|
+
}
|
|
224
|
+
announceStatusChange(previous) {
|
|
225
|
+
if (previous === this.status)
|
|
226
|
+
return;
|
|
227
|
+
const region = this.liveRegion;
|
|
228
|
+
if (!region)
|
|
229
|
+
return;
|
|
230
|
+
if (this.status === 'failed') {
|
|
231
|
+
region.mode = 'assertive';
|
|
232
|
+
region.announce('Message failed to send.', { force: true });
|
|
233
|
+
}
|
|
234
|
+
else if (previous === 'streaming' && this.status === 'sent') {
|
|
235
|
+
region.mode = 'polite';
|
|
236
|
+
region.announce('Message complete.', { force: true });
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
render() {
|
|
240
|
+
const ts = this.normalizedTimestamp;
|
|
241
|
+
const formatter = this.formatTimestamp ?? defaultFormatTimestamp;
|
|
242
|
+
const statusText = this.statusText;
|
|
243
|
+
const showHeader = this.hasAvatarSlot || this.hasBadgesSlot || this.collapsible;
|
|
244
|
+
// `statusText` is already truthy whenever `status === 'failed'`, so it
|
|
245
|
+
// alone covers that case here too.
|
|
246
|
+
const showFooter = Boolean(statusText) || Boolean(ts) || this.hasActionsSlot;
|
|
247
|
+
return html `
|
|
248
|
+
<div part="bubble" tabindex="-1">
|
|
249
|
+
<div part="header" ?hidden=${!showHeader}>
|
|
250
|
+
<span part="avatar" ?hidden=${!this.hasAvatarSlot}
|
|
251
|
+
><slot name="avatar" @slotchange=${this.onAvatarSlotChange}></slot
|
|
252
|
+
></span>
|
|
253
|
+
<span part="badges" ?hidden=${!this.hasBadgesSlot}
|
|
254
|
+
><slot name="badges" @slotchange=${this.onBadgesSlotChange}></slot
|
|
255
|
+
></span>
|
|
256
|
+
${this.collapsible
|
|
257
|
+
? html `<button
|
|
258
|
+
part="collapse-button"
|
|
259
|
+
type="button"
|
|
260
|
+
aria-expanded=${this.collapsed ? 'false' : 'true'}
|
|
261
|
+
aria-controls=${this.bodyId}
|
|
262
|
+
aria-label=${this.collapsed ? 'Expand message' : 'Collapse message'}
|
|
263
|
+
@click=${this.toggleCollapsed}
|
|
264
|
+
>
|
|
265
|
+
<span class="chevron" style=${`transform:rotate(${this.collapsed ? '0deg' : '90deg'})`}
|
|
266
|
+
>${chevronIcon()}</span
|
|
267
|
+
>
|
|
268
|
+
</button>`
|
|
269
|
+
: nothing}
|
|
270
|
+
</div>
|
|
271
|
+
<div part="body" id=${this.bodyId} ?hidden=${this.collapsed}>
|
|
272
|
+
<slot></slot>
|
|
273
|
+
</div>
|
|
274
|
+
<div part="attachments" ?hidden=${!this.hasAttachmentsSlot}>
|
|
275
|
+
<slot name="attachments" @slotchange=${this.onAttachmentsSlotChange}></slot>
|
|
276
|
+
</div>
|
|
277
|
+
<div part="footer" ?hidden=${!showFooter}>
|
|
278
|
+
${statusText
|
|
279
|
+
? html `<span part="status-indicator" aria-hidden="true"></span><span part="status-text"
|
|
280
|
+
>${statusText}</span
|
|
281
|
+
>`
|
|
282
|
+
: nothing}
|
|
283
|
+
${ts ? html `<time part="timestamp" datetime=${ts.toISOString()}>${formatter(ts)}</time>` : nothing}
|
|
284
|
+
${this.status === 'failed'
|
|
285
|
+
? html `<button part="retry-button" type="button" @click=${this.onRetryClick}>
|
|
286
|
+
${retryIcon()}<span>Retry</span>
|
|
287
|
+
</button>`
|
|
288
|
+
: nothing}
|
|
289
|
+
<span part="actions" ?hidden=${!this.hasActionsSlot}
|
|
290
|
+
><slot name="actions" @slotchange=${this.onActionsSlotChange}></slot
|
|
291
|
+
></span>
|
|
292
|
+
</div>
|
|
293
|
+
<lyra-live-region></lyra-live-region>
|
|
294
|
+
</div>
|
|
295
|
+
`;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
__decorate([
|
|
299
|
+
property({ reflect: true, attribute: 'data-role' })
|
|
300
|
+
], LyraChatMessage.prototype, "role", void 0);
|
|
301
|
+
__decorate([
|
|
302
|
+
property({ attribute: false })
|
|
303
|
+
], LyraChatMessage.prototype, "timestamp", void 0);
|
|
304
|
+
__decorate([
|
|
305
|
+
property({ attribute: false })
|
|
306
|
+
], LyraChatMessage.prototype, "formatTimestamp", void 0);
|
|
307
|
+
__decorate([
|
|
308
|
+
property({ type: Boolean, reflect: true })
|
|
309
|
+
], LyraChatMessage.prototype, "collapsible", void 0);
|
|
310
|
+
__decorate([
|
|
311
|
+
property({ type: Boolean, reflect: true })
|
|
312
|
+
], LyraChatMessage.prototype, "collapsed", void 0);
|
|
313
|
+
__decorate([
|
|
314
|
+
state()
|
|
315
|
+
], LyraChatMessage.prototype, "hasAvatarSlot", void 0);
|
|
316
|
+
__decorate([
|
|
317
|
+
state()
|
|
318
|
+
], LyraChatMessage.prototype, "hasBadgesSlot", void 0);
|
|
319
|
+
__decorate([
|
|
320
|
+
state()
|
|
321
|
+
], LyraChatMessage.prototype, "hasAttachmentsSlot", void 0);
|
|
322
|
+
__decorate([
|
|
323
|
+
state()
|
|
324
|
+
], LyraChatMessage.prototype, "hasActionsSlot", void 0);
|
|
325
|
+
__decorate([
|
|
326
|
+
query('lyra-live-region')
|
|
327
|
+
], LyraChatMessage.prototype, "liveRegion", void 0);
|
|
328
|
+
__decorate([
|
|
329
|
+
query('[part="bubble"]')
|
|
330
|
+
], LyraChatMessage.prototype, "bubbleEl", void 0);
|
|
331
|
+
defineElement('chat-message', LyraChatMessage);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|