@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,190 @@
|
|
|
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 } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
11
|
+
import { isRtl } from '../../internal/rtl.js';
|
|
12
|
+
import { nextId } from '../../internal/a11y.js';
|
|
13
|
+
import { styles } from './tabs.styles.js';
|
|
14
|
+
/**
|
|
15
|
+
* `<lyra-tabs>` — a tab strip whose panels are direct light-DOM children,
|
|
16
|
+
* each carrying `slot="<id>"` (the panel's stable id) and `label="<text>"`
|
|
17
|
+
* (the tab button's text). One named `<slot>` is rendered per distinct
|
|
18
|
+
* `slot` name found among the current children — a child with no `label`,
|
|
19
|
+
* or a name with no matching child, simply never produces a tab.
|
|
20
|
+
*
|
|
21
|
+
* Implements the WAI-ARIA APG tabs pattern with automatic activation:
|
|
22
|
+
* Left/Right (swapped under RTL) move focus *and* selection together,
|
|
23
|
+
* Home/End jump to the first/last enabled tab, and a roving `tabindex`
|
|
24
|
+
* follows whichever tab is currently selected.
|
|
25
|
+
*
|
|
26
|
+
* @customElement lyra-tabs
|
|
27
|
+
* @slot - Direct children with `slot="<id>" label="<text>"` (and optionally `disabled`); one becomes each tab's panel.
|
|
28
|
+
* @event lyra-tabs-change - `detail: { tabId }`, fired when the active tab changes via click or keyboard.
|
|
29
|
+
* @csspart base - The root wrapper around the tablist and panels.
|
|
30
|
+
* @csspart tablist - The `role="tablist"` row of tab buttons.
|
|
31
|
+
* @csspart tab - A single tab button.
|
|
32
|
+
* @csspart panel - A single `role="tabpanel"` wrapper (one per tab, hidden unless active).
|
|
33
|
+
*/
|
|
34
|
+
export class LyraTabs extends LyraElement {
|
|
35
|
+
constructor() {
|
|
36
|
+
super(...arguments);
|
|
37
|
+
/** The active tab's `slot`/id. Falls back to the first enabled tab whenever the current value doesn't resolve to one. */
|
|
38
|
+
this.active = '';
|
|
39
|
+
this.tabs = [];
|
|
40
|
+
this.baseId = nextId('tabs');
|
|
41
|
+
/** Rebuilds `tabs` from the current direct children. First child wins when two share a `slot` name (matches native slot assignment: both would render into the one panel, but only one label can back the button). */
|
|
42
|
+
this.syncTabs = () => {
|
|
43
|
+
const seen = new Set();
|
|
44
|
+
const next = [];
|
|
45
|
+
for (const child of Array.from(this.children)) {
|
|
46
|
+
const slotName = child.getAttribute('slot');
|
|
47
|
+
const label = child.getAttribute('label');
|
|
48
|
+
if (!slotName || !label || seen.has(slotName))
|
|
49
|
+
continue;
|
|
50
|
+
seen.add(slotName);
|
|
51
|
+
next.push({ slotName, label, disabled: child.hasAttribute('disabled') });
|
|
52
|
+
}
|
|
53
|
+
this.tabs = next;
|
|
54
|
+
};
|
|
55
|
+
this.onTabListKeyDown = (e) => {
|
|
56
|
+
const navigable = this.tabs.filter((t) => !t.disabled);
|
|
57
|
+
if (navigable.length === 0)
|
|
58
|
+
return;
|
|
59
|
+
const currentIndex = navigable.findIndex((t) => t.slotName === this.active);
|
|
60
|
+
// Horizontal strip -- Up/Down aren't used. Left/Right swap under RTL,
|
|
61
|
+
// matching lyra-split/lyra-tree's physical-direction handling.
|
|
62
|
+
const rtl = isRtl(this);
|
|
63
|
+
const forwardKey = rtl ? 'ArrowLeft' : 'ArrowRight';
|
|
64
|
+
const backwardKey = rtl ? 'ArrowRight' : 'ArrowLeft';
|
|
65
|
+
let targetIndex;
|
|
66
|
+
switch (e.key) {
|
|
67
|
+
case forwardKey:
|
|
68
|
+
targetIndex = currentIndex < 0 ? 0 : (currentIndex + 1) % navigable.length;
|
|
69
|
+
break;
|
|
70
|
+
case backwardKey:
|
|
71
|
+
targetIndex = currentIndex < 0 ? navigable.length - 1 : (currentIndex - 1 + navigable.length) % navigable.length;
|
|
72
|
+
break;
|
|
73
|
+
case 'Home':
|
|
74
|
+
targetIndex = 0;
|
|
75
|
+
break;
|
|
76
|
+
case 'End':
|
|
77
|
+
targetIndex = navigable.length - 1;
|
|
78
|
+
break;
|
|
79
|
+
default:
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
e.preventDefault();
|
|
83
|
+
const target = navigable[targetIndex];
|
|
84
|
+
this.selectTab(target);
|
|
85
|
+
this.focusTab(target.slotName);
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
89
|
+
connectedCallback() {
|
|
90
|
+
super.connectedCallback();
|
|
91
|
+
this.syncTabs();
|
|
92
|
+
// Each child carries its own individual `slot` attribute (one named slot
|
|
93
|
+
// per tab, unlike lyra-split's single default-slot-of-many-panels) -- a
|
|
94
|
+
// brand-new tab's name has no matching `<slot>` to fire `slotchange` on
|
|
95
|
+
// until *this* component has already rendered one for it, and neither
|
|
96
|
+
// `slotchange` nor any Lit lifecycle hook observes a plain attribute
|
|
97
|
+
// edit (label/disabled) on a light-DOM child at all. A mutation observer
|
|
98
|
+
// on the host is the only thing that sees either case.
|
|
99
|
+
this.mutationObserver = new MutationObserver(this.syncTabs);
|
|
100
|
+
this.mutationObserver.observe(this, {
|
|
101
|
+
childList: true,
|
|
102
|
+
attributes: true,
|
|
103
|
+
attributeFilter: ['slot', 'label', 'disabled'],
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
disconnectedCallback() {
|
|
107
|
+
super.disconnectedCallback();
|
|
108
|
+
this.mutationObserver?.disconnect();
|
|
109
|
+
this.mutationObserver = undefined;
|
|
110
|
+
}
|
|
111
|
+
/** Keeps `active` resolved to a real, enabled tab -- covers the initial default, a tab disappearing/becoming disabled underneath the current selection, and a consumer assigning `.active` directly. Silent (no `lyra-tabs-change`): this corrects *invalid* state rather than responding to a user picking a different tab. */
|
|
112
|
+
willUpdate(changed) {
|
|
113
|
+
if (!changed.has('tabs') && !changed.has('active'))
|
|
114
|
+
return;
|
|
115
|
+
const current = this.tabs.find((t) => t.slotName === this.active);
|
|
116
|
+
if (current && !current.disabled)
|
|
117
|
+
return;
|
|
118
|
+
this.active = this.tabs.find((t) => !t.disabled)?.slotName ?? '';
|
|
119
|
+
}
|
|
120
|
+
/** Activates `tab` (no-op for a disabled tab or one that's already active) and emits `lyra-tabs-change`. */
|
|
121
|
+
selectTab(tab) {
|
|
122
|
+
if (tab.disabled || tab.slotName === this.active)
|
|
123
|
+
return;
|
|
124
|
+
this.active = tab.slotName;
|
|
125
|
+
this.emit('lyra-tabs-change', { tabId: tab.slotName });
|
|
126
|
+
}
|
|
127
|
+
/** Moves real DOM focus to tab `slotName`'s button. Safe to call immediately (no `updateComplete` wait): every tab button already exists in the DOM regardless of its current `tabindex`, and `tabindex="-1"` elements are still focusable via script. */
|
|
128
|
+
focusTab(slotName) {
|
|
129
|
+
const buttons = this.renderRoot.querySelectorAll('[part="tab"]');
|
|
130
|
+
for (const button of Array.from(buttons)) {
|
|
131
|
+
if (button.dataset.slot === slotName) {
|
|
132
|
+
button.focus();
|
|
133
|
+
return;
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
tabId(slotName) {
|
|
138
|
+
return `${this.baseId}-tab-${slotName}`;
|
|
139
|
+
}
|
|
140
|
+
panelId(slotName) {
|
|
141
|
+
return `${this.baseId}-panel-${slotName}`;
|
|
142
|
+
}
|
|
143
|
+
renderTab(tab) {
|
|
144
|
+
const selected = tab.slotName === this.active;
|
|
145
|
+
return html `<button
|
|
146
|
+
type="button"
|
|
147
|
+
part="tab"
|
|
148
|
+
id=${this.tabId(tab.slotName)}
|
|
149
|
+
data-slot=${tab.slotName}
|
|
150
|
+
role="tab"
|
|
151
|
+
aria-selected=${selected ? 'true' : 'false'}
|
|
152
|
+
aria-disabled=${tab.disabled ? 'true' : 'false'}
|
|
153
|
+
aria-controls=${this.panelId(tab.slotName)}
|
|
154
|
+
tabindex=${selected ? '0' : '-1'}
|
|
155
|
+
@click=${() => this.selectTab(tab)}
|
|
156
|
+
>
|
|
157
|
+
${tab.label}
|
|
158
|
+
</button>`;
|
|
159
|
+
}
|
|
160
|
+
renderPanel(tab) {
|
|
161
|
+
const selected = tab.slotName === this.active;
|
|
162
|
+
return html `<div
|
|
163
|
+
part="panel"
|
|
164
|
+
id=${this.panelId(tab.slotName)}
|
|
165
|
+
role="tabpanel"
|
|
166
|
+
aria-labelledby=${this.tabId(tab.slotName)}
|
|
167
|
+
tabindex="0"
|
|
168
|
+
?hidden=${!selected}
|
|
169
|
+
>
|
|
170
|
+
<slot name=${tab.slotName}></slot>
|
|
171
|
+
</div>`;
|
|
172
|
+
}
|
|
173
|
+
render() {
|
|
174
|
+
return html `
|
|
175
|
+
<div part="base">
|
|
176
|
+
<div part="tablist" role="tablist" aria-orientation="horizontal" @keydown=${this.onTabListKeyDown}>
|
|
177
|
+
${this.tabs.map((tab) => this.renderTab(tab))}
|
|
178
|
+
</div>
|
|
179
|
+
${this.tabs.map((tab) => this.renderPanel(tab))}
|
|
180
|
+
</div>
|
|
181
|
+
`;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
__decorate([
|
|
185
|
+
property({ reflect: true })
|
|
186
|
+
], LyraTabs.prototype, "active", void 0);
|
|
187
|
+
__decorate([
|
|
188
|
+
state()
|
|
189
|
+
], LyraTabs.prototype, "tabs", void 0);
|
|
190
|
+
defineElement('tabs', LyraTabs);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,63 @@
|
|
|
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-s);
|
|
10
|
+
}
|
|
11
|
+
[part='tablist'] {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: stretch;
|
|
14
|
+
gap: var(--lyra-space-m);
|
|
15
|
+
border-block-end: 1px solid var(--lyra-color-border);
|
|
16
|
+
overflow-x: auto;
|
|
17
|
+
}
|
|
18
|
+
[part='tab'] {
|
|
19
|
+
appearance: none;
|
|
20
|
+
background: none;
|
|
21
|
+
border: none;
|
|
22
|
+
/* Sits directly over the tablist's own border-block-end so the accent
|
|
23
|
+
underline below replaces it, pixel for pixel, when selected. */
|
|
24
|
+
border-block-end: 2px solid transparent;
|
|
25
|
+
margin-block-end: -1px;
|
|
26
|
+
padding: var(--lyra-space-s) var(--lyra-space-xs);
|
|
27
|
+
font: inherit;
|
|
28
|
+
font-weight: 500;
|
|
29
|
+
color: var(--lyra-color-text-quiet);
|
|
30
|
+
cursor: pointer;
|
|
31
|
+
white-space: nowrap;
|
|
32
|
+
transition:
|
|
33
|
+
color var(--lyra-transition-fast),
|
|
34
|
+
border-color var(--lyra-transition-fast);
|
|
35
|
+
}
|
|
36
|
+
[part='tab']:hover:not([aria-disabled='true']) {
|
|
37
|
+
color: var(--lyra-color-text);
|
|
38
|
+
}
|
|
39
|
+
[part='tab'][aria-selected='true'] {
|
|
40
|
+
color: var(--lyra-color-brand);
|
|
41
|
+
border-block-end-color: var(--lyra-color-brand);
|
|
42
|
+
}
|
|
43
|
+
[part='tab'][aria-disabled='true'] {
|
|
44
|
+
cursor: not-allowed;
|
|
45
|
+
/* No :hover color change and no pointer feedback -- the click handler
|
|
46
|
+
already no-ops on a disabled tab, this just matches it visually. */
|
|
47
|
+
pointer-events: none;
|
|
48
|
+
opacity: var(--lyra-opacity-disabled);
|
|
49
|
+
}
|
|
50
|
+
[part='tab']:focus-visible {
|
|
51
|
+
outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
|
|
52
|
+
outline-offset: calc(var(--lyra-focus-ring-offset) * -1);
|
|
53
|
+
border-radius: var(--lyra-radius);
|
|
54
|
+
}
|
|
55
|
+
[part='panel'] {
|
|
56
|
+
padding-block-start: var(--lyra-space-xs);
|
|
57
|
+
}
|
|
58
|
+
[part='panel']:focus-visible {
|
|
59
|
+
outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
|
|
60
|
+
outline-offset: var(--lyra-focus-ring-offset);
|
|
61
|
+
border-radius: var(--lyra-radius);
|
|
62
|
+
}
|
|
63
|
+
`;
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
export type ThinkingPanelMode = 'live' | 'post-hoc';
|
|
4
|
+
export interface ThinkingPanelToggleDetail {
|
|
5
|
+
expanded: boolean;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* `<lyra-thinking-panel>` — a collapsible panel for an AI agent's
|
|
9
|
+
* intermediate reasoning/"thinking" transcript, kept visually and
|
|
10
|
+
* semantically distinct from its final response. Same collapsible
|
|
11
|
+
* header-button-plus-region shape as `<lyra-source-list>`; the default slot
|
|
12
|
+
* is entirely free-form (a consumer-composed `<lyra-streaming-text>`,
|
|
13
|
+
* `<lyra-markdown>`, or plain text) — this component has no dependency on
|
|
14
|
+
* either and imposes no structure on what's slotted.
|
|
15
|
+
*
|
|
16
|
+
* `mode` (`'live'` while reasoning is actively streaming in, `'post-hoc'`
|
|
17
|
+
* once it's complete and being reviewed after the fact) drives two concrete
|
|
18
|
+
* behavior differences, not just a styling hook:
|
|
19
|
+
* - **Header hint.** While `duration-ms` is unset, `'live'` shows a pulsing
|
|
20
|
+
* "Thinking…" placeholder in `[part="duration"]`; `'post-hoc'` shows
|
|
21
|
+
* nothing there instead (a finished review with no known duration has
|
|
22
|
+
* nothing useful to say in that slot). Once `duration-ms` is set, both
|
|
23
|
+
* modes show the same static `"Thought for …"` text — a `'post-hoc'`
|
|
24
|
+
* consumer that captured a duration is free to supply it too.
|
|
25
|
+
* - **Auto-scroll.** Only `'live'` mode auto-follows new content appended to
|
|
26
|
+
* the default slot while `expanded` (see below); `'post-hoc'` never
|
|
27
|
+
* scrolls on its own, since reviewing finished reasoning is expected to
|
|
28
|
+
* start from the top like reading any other completed document. This
|
|
29
|
+
* library otherwise defaults to *not* editorializing about a host's data
|
|
30
|
+
* (see `<lyra-empty>`'s plain-`description` stance), but scroll position
|
|
31
|
+
* is presentation, not data, so this one behavior difference earns its
|
|
32
|
+
* keep rather than being left as a bare visual/semantic hint the host
|
|
33
|
+
* would have to reimplement identically itself.
|
|
34
|
+
*
|
|
35
|
+
* Live-mode auto-scroll ("stick to bottom") is the classic chat-transcript
|
|
36
|
+
* convention: while `mode="live"` and `expanded`, new content keeps the
|
|
37
|
+
* panel scrolled to its latest line — *unless* the user has manually
|
|
38
|
+
* scrolled up to (re-)read earlier content, in which case their position is
|
|
39
|
+
* never yanked away from them. This is tracked continuously via a `scroll`
|
|
40
|
+
* listener on `[part="body"]` (not recomputed from the mutation itself,
|
|
41
|
+
* which necessarily observes the DOM only *after* it has already changed):
|
|
42
|
+
* every user-driven scroll records whether the body was left within
|
|
43
|
+
* `NEAR_BOTTOM_PX` of its own max scroll position, and only a mutation that
|
|
44
|
+
* arrives while that's still true triggers a follow-up scroll-to-bottom.
|
|
45
|
+
* Opening an already-`'live'` panel (or one that later becomes `'live'`)
|
|
46
|
+
* always resets this to "anchored" and jumps to the latest content, the same
|
|
47
|
+
* way a chat app's own transcript does when you re-open it.
|
|
48
|
+
*
|
|
49
|
+
* New content is detected via a `MutationObserver` on this element's own
|
|
50
|
+
* light DOM (`childList`+`subtree`+`characterData`) rather than the default
|
|
51
|
+
* slot's `slotchange` event, because `slotchange` only fires when the set of
|
|
52
|
+
* top-level assigned nodes changes — never for a text node mutating *inside*
|
|
53
|
+
* an already-slotted element, which is the more likely shape for streamed
|
|
54
|
+
* reasoning (a consumer appending chunks to an existing node's `textContent`
|
|
55
|
+
* rather than re-slotting a whole new element per token). The one thing this
|
|
56
|
+
* can't see is a mutation entirely inside a slotted custom element's own
|
|
57
|
+
* shadow root (e.g. a `<lyra-markdown>` re-rendering its shadow tree after a
|
|
58
|
+
* `content` property change) — Shadow DOM encapsulation blocks that by
|
|
59
|
+
* design, and there is no way for this component to reach across that
|
|
60
|
+
* boundary. A slotted element whose *own* internal updates should drive this
|
|
61
|
+
* panel's auto-scroll needs to append/mutate visible light-DOM text itself
|
|
62
|
+
* (as `<lyra-streaming-text>` is expected to), or the host can call this
|
|
63
|
+
* panel's own `scrollToBottom()` directly.
|
|
64
|
+
*
|
|
65
|
+
* `aria-controls` linking the header to the body region uses `nextId()`
|
|
66
|
+
* (`../../internal/a11y.js`) for a collision-safe id, the same convention
|
|
67
|
+
* `<lyra-source-list>` and `<lyra-widget>` already establish for every
|
|
68
|
+
* toggle-controls-region pairing in this library.
|
|
69
|
+
*
|
|
70
|
+
* @customElement lyra-thinking-panel
|
|
71
|
+
* @slot - The reasoning/thinking content.
|
|
72
|
+
* @event lyra-toggle - The header was activated, expanding or collapsing the
|
|
73
|
+
* panel. `detail: { expanded }` — same event name and shape as
|
|
74
|
+
* `<lyra-source-list>`'s own `lyra-toggle`.
|
|
75
|
+
* @csspart base - The outer container.
|
|
76
|
+
* @csspart header - The clickable header (`<button>`) toggling `expanded`.
|
|
77
|
+
* @csspart label - The `label` text.
|
|
78
|
+
* @csspart duration - The formatted duration / "Thinking…" placeholder, when shown.
|
|
79
|
+
* @csspart toggle - The chevron indicator inside the header.
|
|
80
|
+
* @csspart body - The wrapper around the default slot, `hidden` while collapsed.
|
|
81
|
+
*/
|
|
82
|
+
export declare class LyraThinkingPanel extends LyraElement {
|
|
83
|
+
static styles: import("lit").CSSResultGroup[];
|
|
84
|
+
/** Header text. */
|
|
85
|
+
label: string;
|
|
86
|
+
/** Whether the reasoning transcript is currently shown. Starts collapsed,
|
|
87
|
+
* matching `<lyra-source-list>`'s default -- a consumer running `'live'`
|
|
88
|
+
* reasoning sets this `true` itself to stream it in view as it arrives. */
|
|
89
|
+
expanded: boolean;
|
|
90
|
+
/** `'live'` while reasoning is actively streaming in right now; `'post-hoc'`
|
|
91
|
+
* once it's complete and being reviewed after the fact. See the class doc
|
|
92
|
+
* for the concrete behavior differences this drives. */
|
|
93
|
+
mode: ThinkingPanelMode;
|
|
94
|
+
/** How long the reasoning took, in milliseconds, once known. Omitted
|
|
95
|
+
* entirely (nothing rendered in `'post-hoc'`, a pulsing placeholder in
|
|
96
|
+
* `'live'`) while unset. */
|
|
97
|
+
durationMs?: number;
|
|
98
|
+
private readonly bodyId;
|
|
99
|
+
private contentObserver?;
|
|
100
|
+
private scrollRafId?;
|
|
101
|
+
private stickToBottom;
|
|
102
|
+
connectedCallback(): void;
|
|
103
|
+
disconnectedCallback(): void;
|
|
104
|
+
protected updated(changed: PropertyValues): void;
|
|
105
|
+
/** Scrolls the body to its current bottom immediately (no smooth-scroll
|
|
106
|
+
* animation, deliberately -- see onContentMutated()'s rAF-coalescing
|
|
107
|
+
* comment for why an instant jump reads better than a stack of competing
|
|
108
|
+
* smooth scrolls under a fast token stream). Safe to call directly, e.g.
|
|
109
|
+
* from a host that wants to force a jump-to-latest action of its own. */
|
|
110
|
+
scrollToBottom(): void;
|
|
111
|
+
private onScroll;
|
|
112
|
+
private onContentMutated;
|
|
113
|
+
private toggle;
|
|
114
|
+
private get durationDisplay();
|
|
115
|
+
render(): TemplateResult;
|
|
116
|
+
}
|
|
117
|
+
declare global {
|
|
118
|
+
interface HTMLElementTagNameMap {
|
|
119
|
+
'lyra-thinking-panel': LyraThinkingPanel;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
@@ -0,0 +1,235 @@
|
|
|
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 } 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 { styles } from './thinking-panel.styles.js';
|
|
14
|
+
/** "Close enough to the body's own max scroll position to count as anchored
|
|
15
|
+
* there" -- comfortably larger than one line of streamed text, so a user
|
|
16
|
+
* who has barely nudged the scrollbar while reading the latest line isn't
|
|
17
|
+
* mistaken for having deliberately scrolled away to read earlier content. */
|
|
18
|
+
const NEAR_BOTTOM_PX = 48;
|
|
19
|
+
/** `820` -> `"820ms"`; `1500` -> `"1.5s"`; `2000` -> `"2s"`. Identical
|
|
20
|
+
* algorithm to lyra-tool-call-chip's and lyra-tool-result-dialog's own
|
|
21
|
+
* `formatDuration` -- duplicated rather than imported (three independent,
|
|
22
|
+
* separately-consumable components) but kept in lockstep so the same
|
|
23
|
+
* elapsed time reads identically everywhere it's shown in this library. */
|
|
24
|
+
function formatDuration(ms) {
|
|
25
|
+
if (!Number.isFinite(ms) || ms < 1000) {
|
|
26
|
+
return `${Math.round(Math.max(0, ms))}ms`;
|
|
27
|
+
}
|
|
28
|
+
const seconds = ms / 1000;
|
|
29
|
+
const rounded = Math.round(seconds * 10) / 10;
|
|
30
|
+
return `${Number.isInteger(rounded) ? rounded.toFixed(0) : rounded.toFixed(1)}s`;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* `<lyra-thinking-panel>` — a collapsible panel for an AI agent's
|
|
34
|
+
* intermediate reasoning/"thinking" transcript, kept visually and
|
|
35
|
+
* semantically distinct from its final response. Same collapsible
|
|
36
|
+
* header-button-plus-region shape as `<lyra-source-list>`; the default slot
|
|
37
|
+
* is entirely free-form (a consumer-composed `<lyra-streaming-text>`,
|
|
38
|
+
* `<lyra-markdown>`, or plain text) — this component has no dependency on
|
|
39
|
+
* either and imposes no structure on what's slotted.
|
|
40
|
+
*
|
|
41
|
+
* `mode` (`'live'` while reasoning is actively streaming in, `'post-hoc'`
|
|
42
|
+
* once it's complete and being reviewed after the fact) drives two concrete
|
|
43
|
+
* behavior differences, not just a styling hook:
|
|
44
|
+
* - **Header hint.** While `duration-ms` is unset, `'live'` shows a pulsing
|
|
45
|
+
* "Thinking…" placeholder in `[part="duration"]`; `'post-hoc'` shows
|
|
46
|
+
* nothing there instead (a finished review with no known duration has
|
|
47
|
+
* nothing useful to say in that slot). Once `duration-ms` is set, both
|
|
48
|
+
* modes show the same static `"Thought for …"` text — a `'post-hoc'`
|
|
49
|
+
* consumer that captured a duration is free to supply it too.
|
|
50
|
+
* - **Auto-scroll.** Only `'live'` mode auto-follows new content appended to
|
|
51
|
+
* the default slot while `expanded` (see below); `'post-hoc'` never
|
|
52
|
+
* scrolls on its own, since reviewing finished reasoning is expected to
|
|
53
|
+
* start from the top like reading any other completed document. This
|
|
54
|
+
* library otherwise defaults to *not* editorializing about a host's data
|
|
55
|
+
* (see `<lyra-empty>`'s plain-`description` stance), but scroll position
|
|
56
|
+
* is presentation, not data, so this one behavior difference earns its
|
|
57
|
+
* keep rather than being left as a bare visual/semantic hint the host
|
|
58
|
+
* would have to reimplement identically itself.
|
|
59
|
+
*
|
|
60
|
+
* Live-mode auto-scroll ("stick to bottom") is the classic chat-transcript
|
|
61
|
+
* convention: while `mode="live"` and `expanded`, new content keeps the
|
|
62
|
+
* panel scrolled to its latest line — *unless* the user has manually
|
|
63
|
+
* scrolled up to (re-)read earlier content, in which case their position is
|
|
64
|
+
* never yanked away from them. This is tracked continuously via a `scroll`
|
|
65
|
+
* listener on `[part="body"]` (not recomputed from the mutation itself,
|
|
66
|
+
* which necessarily observes the DOM only *after* it has already changed):
|
|
67
|
+
* every user-driven scroll records whether the body was left within
|
|
68
|
+
* `NEAR_BOTTOM_PX` of its own max scroll position, and only a mutation that
|
|
69
|
+
* arrives while that's still true triggers a follow-up scroll-to-bottom.
|
|
70
|
+
* Opening an already-`'live'` panel (or one that later becomes `'live'`)
|
|
71
|
+
* always resets this to "anchored" and jumps to the latest content, the same
|
|
72
|
+
* way a chat app's own transcript does when you re-open it.
|
|
73
|
+
*
|
|
74
|
+
* New content is detected via a `MutationObserver` on this element's own
|
|
75
|
+
* light DOM (`childList`+`subtree`+`characterData`) rather than the default
|
|
76
|
+
* slot's `slotchange` event, because `slotchange` only fires when the set of
|
|
77
|
+
* top-level assigned nodes changes — never for a text node mutating *inside*
|
|
78
|
+
* an already-slotted element, which is the more likely shape for streamed
|
|
79
|
+
* reasoning (a consumer appending chunks to an existing node's `textContent`
|
|
80
|
+
* rather than re-slotting a whole new element per token). The one thing this
|
|
81
|
+
* can't see is a mutation entirely inside a slotted custom element's own
|
|
82
|
+
* shadow root (e.g. a `<lyra-markdown>` re-rendering its shadow tree after a
|
|
83
|
+
* `content` property change) — Shadow DOM encapsulation blocks that by
|
|
84
|
+
* design, and there is no way for this component to reach across that
|
|
85
|
+
* boundary. A slotted element whose *own* internal updates should drive this
|
|
86
|
+
* panel's auto-scroll needs to append/mutate visible light-DOM text itself
|
|
87
|
+
* (as `<lyra-streaming-text>` is expected to), or the host can call this
|
|
88
|
+
* panel's own `scrollToBottom()` directly.
|
|
89
|
+
*
|
|
90
|
+
* `aria-controls` linking the header to the body region uses `nextId()`
|
|
91
|
+
* (`../../internal/a11y.js`) for a collision-safe id, the same convention
|
|
92
|
+
* `<lyra-source-list>` and `<lyra-widget>` already establish for every
|
|
93
|
+
* toggle-controls-region pairing in this library.
|
|
94
|
+
*
|
|
95
|
+
* @customElement lyra-thinking-panel
|
|
96
|
+
* @slot - The reasoning/thinking content.
|
|
97
|
+
* @event lyra-toggle - The header was activated, expanding or collapsing the
|
|
98
|
+
* panel. `detail: { expanded }` — same event name and shape as
|
|
99
|
+
* `<lyra-source-list>`'s own `lyra-toggle`.
|
|
100
|
+
* @csspart base - The outer container.
|
|
101
|
+
* @csspart header - The clickable header (`<button>`) toggling `expanded`.
|
|
102
|
+
* @csspart label - The `label` text.
|
|
103
|
+
* @csspart duration - The formatted duration / "Thinking…" placeholder, when shown.
|
|
104
|
+
* @csspart toggle - The chevron indicator inside the header.
|
|
105
|
+
* @csspart body - The wrapper around the default slot, `hidden` while collapsed.
|
|
106
|
+
*/
|
|
107
|
+
export class LyraThinkingPanel extends LyraElement {
|
|
108
|
+
constructor() {
|
|
109
|
+
super(...arguments);
|
|
110
|
+
/** Header text. */
|
|
111
|
+
this.label = 'Thinking';
|
|
112
|
+
/** Whether the reasoning transcript is currently shown. Starts collapsed,
|
|
113
|
+
* matching `<lyra-source-list>`'s default -- a consumer running `'live'`
|
|
114
|
+
* reasoning sets this `true` itself to stream it in view as it arrives. */
|
|
115
|
+
this.expanded = false;
|
|
116
|
+
/** `'live'` while reasoning is actively streaming in right now; `'post-hoc'`
|
|
117
|
+
* once it's complete and being reviewed after the fact. See the class doc
|
|
118
|
+
* for the concrete behavior differences this drives. */
|
|
119
|
+
this.mode = 'live';
|
|
120
|
+
this.bodyId = nextId('thinking-panel-body');
|
|
121
|
+
// Whether the body was left within NEAR_BOTTOM_PX of its own max scroll
|
|
122
|
+
// position the last time a real (user-driven) scroll was recorded -- see
|
|
123
|
+
// onScroll(). Starts `true` so a panel that mounts already `expanded` and
|
|
124
|
+
// `mode="live"` follows its very first streamed content by default,
|
|
125
|
+
// before any scroll event has ever fired.
|
|
126
|
+
this.stickToBottom = true;
|
|
127
|
+
this.onScroll = (e) => {
|
|
128
|
+
const body = e.currentTarget;
|
|
129
|
+
this.stickToBottom = body.scrollHeight - body.scrollTop - body.clientHeight <= NEAR_BOTTOM_PX;
|
|
130
|
+
};
|
|
131
|
+
this.onContentMutated = () => {
|
|
132
|
+
if (this.mode !== 'live' || !this.expanded || !this.stickToBottom)
|
|
133
|
+
return;
|
|
134
|
+
// Coalesce to at most one scroll-to-bottom per animation frame -- a fast
|
|
135
|
+
// token stream can otherwise fire many mutation records in quick
|
|
136
|
+
// succession, each individually cheap to react to but wasteful (and
|
|
137
|
+
// visually janky) to lay out for separately.
|
|
138
|
+
if (this.scrollRafId !== undefined)
|
|
139
|
+
return;
|
|
140
|
+
this.scrollRafId = requestAnimationFrame(() => {
|
|
141
|
+
this.scrollRafId = undefined;
|
|
142
|
+
this.scrollToBottom();
|
|
143
|
+
});
|
|
144
|
+
};
|
|
145
|
+
this.toggle = () => {
|
|
146
|
+
this.expanded = !this.expanded;
|
|
147
|
+
this.emit('lyra-toggle', { expanded: this.expanded });
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
151
|
+
connectedCallback() {
|
|
152
|
+
super.connectedCallback();
|
|
153
|
+
// Watches this element's own light-DOM subtree, not the shadow-DOM
|
|
154
|
+
// [part="body"] wrapper -- the slotted reasoning content actually lives
|
|
155
|
+
// here, as this element's children. See the class doc for why this
|
|
156
|
+
// (rather than `slotchange`) is what detects streamed-in content.
|
|
157
|
+
this.contentObserver = new MutationObserver(this.onContentMutated);
|
|
158
|
+
this.contentObserver.observe(this, { childList: true, subtree: true, characterData: true });
|
|
159
|
+
}
|
|
160
|
+
disconnectedCallback() {
|
|
161
|
+
super.disconnectedCallback();
|
|
162
|
+
this.contentObserver?.disconnect();
|
|
163
|
+
this.contentObserver = undefined;
|
|
164
|
+
if (this.scrollRafId !== undefined) {
|
|
165
|
+
cancelAnimationFrame(this.scrollRafId);
|
|
166
|
+
this.scrollRafId = undefined;
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
updated(changed) {
|
|
170
|
+
if (changed.has('expanded') && this.expanded && this.mode === 'live') {
|
|
171
|
+
// Opening a live panel always jumps straight to the newest content and
|
|
172
|
+
// resets the sticky-bottom flag, so it starts following again
|
|
173
|
+
// regardless of wherever the body happened to be scrolled the last
|
|
174
|
+
// time it was collapsed. `'post-hoc'` deliberately skips this -- see
|
|
175
|
+
// the class doc's Auto-scroll section.
|
|
176
|
+
this.stickToBottom = true;
|
|
177
|
+
this.scrollToBottom();
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/** Scrolls the body to its current bottom immediately (no smooth-scroll
|
|
181
|
+
* animation, deliberately -- see onContentMutated()'s rAF-coalescing
|
|
182
|
+
* comment for why an instant jump reads better than a stack of competing
|
|
183
|
+
* smooth scrolls under a fast token stream). Safe to call directly, e.g.
|
|
184
|
+
* from a host that wants to force a jump-to-latest action of its own. */
|
|
185
|
+
scrollToBottom() {
|
|
186
|
+
const body = this.renderRoot.querySelector('[part="body"]');
|
|
187
|
+
if (!body)
|
|
188
|
+
return;
|
|
189
|
+
body.scrollTop = body.scrollHeight;
|
|
190
|
+
}
|
|
191
|
+
get durationDisplay() {
|
|
192
|
+
if (this.durationMs != null && Number.isFinite(this.durationMs)) {
|
|
193
|
+
return { text: `Thought for ${formatDuration(this.durationMs)}`, pending: false };
|
|
194
|
+
}
|
|
195
|
+
return this.mode === 'live' ? { text: 'Thinking…', pending: true } : null;
|
|
196
|
+
}
|
|
197
|
+
render() {
|
|
198
|
+
const duration = this.durationDisplay;
|
|
199
|
+
return html `
|
|
200
|
+
<div part="base">
|
|
201
|
+
<button
|
|
202
|
+
part="header"
|
|
203
|
+
type="button"
|
|
204
|
+
aria-expanded=${this.expanded ? 'true' : 'false'}
|
|
205
|
+
aria-controls=${this.bodyId}
|
|
206
|
+
@click=${this.toggle}
|
|
207
|
+
>
|
|
208
|
+
<span part="toggle" aria-hidden="true">${chevronIcon()}</span>
|
|
209
|
+
<span part="label">${this.label}</span>
|
|
210
|
+
${duration
|
|
211
|
+
? html `<span part="duration" ?data-pending=${duration.pending}
|
|
212
|
+
>${duration.pending ? html `<span class="pending-dot" aria-hidden="true"></span>` : nothing}${duration.text}</span
|
|
213
|
+
>`
|
|
214
|
+
: nothing}
|
|
215
|
+
</button>
|
|
216
|
+
<div part="body" id=${this.bodyId} ?hidden=${!this.expanded} @scroll=${this.onScroll}>
|
|
217
|
+
<slot></slot>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
`;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
__decorate([
|
|
224
|
+
property()
|
|
225
|
+
], LyraThinkingPanel.prototype, "label", void 0);
|
|
226
|
+
__decorate([
|
|
227
|
+
property({ type: Boolean, reflect: true })
|
|
228
|
+
], LyraThinkingPanel.prototype, "expanded", void 0);
|
|
229
|
+
__decorate([
|
|
230
|
+
property({ reflect: true })
|
|
231
|
+
], LyraThinkingPanel.prototype, "mode", void 0);
|
|
232
|
+
__decorate([
|
|
233
|
+
property({ type: Number, attribute: 'duration-ms' })
|
|
234
|
+
], LyraThinkingPanel.prototype, "durationMs", void 0);
|
|
235
|
+
defineElement('thinking-panel', LyraThinkingPanel);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|