@aceshooting/lyra-ui 1.2.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 +11 -0
- package/custom-elements.json +23341 -11202
- 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 +1 -2
- package/dist/components/chart/chart.js +67 -12
- 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 +54 -0
- package/dist/components/chart/lite-chart.js +140 -22
- 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 +29 -13
- package/dist/components/flag/flag.js +39 -13
- 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 +74 -0
- package/dist/components/heatmap/heatmap.js +135 -23
- 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 +43 -2
- package/dist/components/select/select.js +150 -17
- 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 +6 -1
- package/dist/components/stat/stat.js +8 -2
- 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/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 +3 -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 +3836 -17
- 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 -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,120 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
inline-size: 100%;
|
|
6
|
+
}
|
|
7
|
+
:host([variant='ring']) {
|
|
8
|
+
display: inline-block;
|
|
9
|
+
inline-size: 8em;
|
|
10
|
+
block-size: 8em;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
[part='base'] {
|
|
14
|
+
display: flex;
|
|
15
|
+
flex-direction: column;
|
|
16
|
+
gap: var(--lyra-space-xs);
|
|
17
|
+
}
|
|
18
|
+
:host([variant='ring']) [part='base'] {
|
|
19
|
+
inline-size: 100%;
|
|
20
|
+
block-size: 100%;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
[part='label'] {
|
|
24
|
+
font-size: 0.75rem;
|
|
25
|
+
color: var(--lyra-color-text-quiet);
|
|
26
|
+
font-family: var(--lyra-font);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/* --- bar variant ------------------------------------------------- */
|
|
30
|
+
[part='track'] {
|
|
31
|
+
position: relative;
|
|
32
|
+
display: flex;
|
|
33
|
+
align-items: stretch;
|
|
34
|
+
overflow: hidden;
|
|
35
|
+
block-size: 0.5rem;
|
|
36
|
+
border-radius: calc(var(--lyra-radius) * 0.5);
|
|
37
|
+
/* Quiet neutral fill for the unfilled remainder -- deliberately lighter
|
|
38
|
+
than a 'neutral'-tone segment (var(--lyra-color-border) at full
|
|
39
|
+
strength below) so "counted but uncolored" data still reads as
|
|
40
|
+
visually distinct from "not counted at all". */
|
|
41
|
+
background: color-mix(in srgb, var(--lyra-color-border) 30%, transparent);
|
|
42
|
+
}
|
|
43
|
+
[part='segment'] {
|
|
44
|
+
display: block;
|
|
45
|
+
flex: 0 0 auto;
|
|
46
|
+
block-size: 100%;
|
|
47
|
+
background: var(--lyra-color-border);
|
|
48
|
+
transition: flex-basis var(--lyra-transition-base);
|
|
49
|
+
}
|
|
50
|
+
/* A hairline seam between adjacent segments -- painted in the surface
|
|
51
|
+
color rather than as real gap spacing, so two same-tone segments next
|
|
52
|
+
to each other (e.g. two 'neutral' entries) still read as separate
|
|
53
|
+
quantities instead of merging into one block. Logical property keeps it
|
|
54
|
+
RTL-correct without extra math. */
|
|
55
|
+
[part='segment']:not(:first-of-type) {
|
|
56
|
+
border-inline-start: 1px solid var(--lyra-color-surface);
|
|
57
|
+
}
|
|
58
|
+
[part='segment'][data-tone='brand'] {
|
|
59
|
+
background: var(--lyra-color-brand);
|
|
60
|
+
}
|
|
61
|
+
[part='segment'][data-tone='success'] {
|
|
62
|
+
background: var(--lyra-color-success);
|
|
63
|
+
}
|
|
64
|
+
[part='segment'][data-tone='warning'] {
|
|
65
|
+
background: var(--lyra-color-warning);
|
|
66
|
+
}
|
|
67
|
+
[part='segment'][data-tone='danger'] {
|
|
68
|
+
background: var(--lyra-color-danger);
|
|
69
|
+
}
|
|
70
|
+
[part='segment'][data-tone='neutral'] {
|
|
71
|
+
background: var(--lyra-color-border);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/* --- ring variant -------------------------------------------------- */
|
|
75
|
+
:host([variant='ring']) svg[part='base'] {
|
|
76
|
+
display: block;
|
|
77
|
+
overflow: visible;
|
|
78
|
+
}
|
|
79
|
+
:host([variant='ring']) [part='track'] {
|
|
80
|
+
fill: none;
|
|
81
|
+
stroke: color-mix(in srgb, var(--lyra-color-border) 30%, transparent);
|
|
82
|
+
}
|
|
83
|
+
:host([variant='ring']) [part='segment'] {
|
|
84
|
+
fill: none;
|
|
85
|
+
stroke: var(--lyra-color-border);
|
|
86
|
+
/* Butt (not round) caps -- round caps on tightly-packed segmented arcs
|
|
87
|
+
bleed past the exact boundary and overlap the next segment's color. */
|
|
88
|
+
stroke-linecap: butt;
|
|
89
|
+
transition:
|
|
90
|
+
stroke-dasharray var(--lyra-transition-base),
|
|
91
|
+
stroke-dashoffset var(--lyra-transition-base);
|
|
92
|
+
}
|
|
93
|
+
:host([variant='ring']) [part='segment'][data-tone='brand'] {
|
|
94
|
+
stroke: var(--lyra-color-brand);
|
|
95
|
+
}
|
|
96
|
+
:host([variant='ring']) [part='segment'][data-tone='success'] {
|
|
97
|
+
stroke: var(--lyra-color-success);
|
|
98
|
+
}
|
|
99
|
+
:host([variant='ring']) [part='segment'][data-tone='warning'] {
|
|
100
|
+
stroke: var(--lyra-color-warning);
|
|
101
|
+
}
|
|
102
|
+
:host([variant='ring']) [part='segment'][data-tone='danger'] {
|
|
103
|
+
stroke: var(--lyra-color-danger);
|
|
104
|
+
}
|
|
105
|
+
:host([variant='ring']) [part='segment'][data-tone='neutral'] {
|
|
106
|
+
stroke: var(--lyra-color-border);
|
|
107
|
+
}
|
|
108
|
+
:host([variant='ring']) [part='label'] {
|
|
109
|
+
text-anchor: middle;
|
|
110
|
+
fill: var(--lyra-color-text-quiet);
|
|
111
|
+
font-size: 0.625rem;
|
|
112
|
+
text-transform: uppercase;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
@media (prefers-reduced-motion: reduce) {
|
|
116
|
+
[part='segment'] {
|
|
117
|
+
transition: none !important;
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
`;
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
export interface ConversationItemRenameDetail {
|
|
4
|
+
title: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* `<lyra-conversation-item>` — a selectable row representing one chat
|
|
8
|
+
* session in a history sidebar list. Usable standalone or as the
|
|
9
|
+
* `renderItem()` payload of a sibling virtualized-list component; this
|
|
10
|
+
* module has no dependency on that (or any) other component.
|
|
11
|
+
*
|
|
12
|
+
* Takes `title`/`excerpt`/`timestamp` as individual primitive props rather
|
|
13
|
+
* than one opaque bound object, deliberately consistent with how
|
|
14
|
+
* `<lyra-chat-message>` takes individual props instead of a single
|
|
15
|
+
* `.message` blob -- every other component in this family follows that
|
|
16
|
+
* shape, so this one does too even though a single bound `.session` object
|
|
17
|
+
* would also have been a reasonable design.
|
|
18
|
+
*
|
|
19
|
+
* Identifying *which* session a `lyra-select` click/keypress was about: this
|
|
20
|
+
* reuses the platform's own `id` attribute (every element already has one)
|
|
21
|
+
* rather than inventing a second, differently-named id-carrying prop --
|
|
22
|
+
* consumers already have the event's `target`/`currentTarget` (and thus
|
|
23
|
+
* `.id`), the same reasoning `<lyra-attachment-chip>` documents for its own
|
|
24
|
+
* identically-shaped choice. `lyra-select` therefore carries no detail
|
|
25
|
+
* payload at all.
|
|
26
|
+
*
|
|
27
|
+
* `role="option"` (not `"button"`) on `[part="option"]`, since this is meant
|
|
28
|
+
* to live inside a `role="listbox"` history list (that future list
|
|
29
|
+
* component supplies the listbox/group ancestor `role="option"` requires)
|
|
30
|
+
* rather than stand in for a single push-button action. Used truly
|
|
31
|
+
* standalone -- with no listbox/group ancestor -- it's still fully
|
|
32
|
+
* operable, just technically missing that ARIA parent context; wrap it in a
|
|
33
|
+
* `role="listbox"` (or `role="group"`) container to satisfy that when
|
|
34
|
+
* accessibility-auditing a standalone usage.
|
|
35
|
+
*
|
|
36
|
+
* `role="option"` (like native `<option>`/`role="button"`) forbids focusable
|
|
37
|
+
* descendants -- verified against axe-core's `nested-interactive` rule,
|
|
38
|
+
* which flags it. That's why the rename button and the `actions` slot are
|
|
39
|
+
* rendered as DOM *siblings* of `[part="option"]` (both inside
|
|
40
|
+
* `[part="base"]`) rather than nested inside it: `[part="option"]` only ever
|
|
41
|
+
* contains plain text/`<time>` content. The in-place rename `<input>` is the
|
|
42
|
+
* same problem one level deeper -- it replaces the title *inside*
|
|
43
|
+
* `[part="option"]` while renaming -- so `[part="option"]` sheds its
|
|
44
|
+
* `role`/`tabindex`/`aria-selected`/`aria-label` entirely for the duration
|
|
45
|
+
* of an edit. This isn't just an ARIA-compliance workaround: a row mid-edit
|
|
46
|
+
* genuinely isn't a selectable listbox choice at that moment, it's a text
|
|
47
|
+
* field, so suspending the option semantics is also the more accurate
|
|
48
|
+
* description of what's on screen.
|
|
49
|
+
*
|
|
50
|
+
* Inline rename is a dedicated pencil/edit icon button (not a double-click
|
|
51
|
+
* on the title) -- double-click has no keyboard/screen-reader equivalent
|
|
52
|
+
* and would silently swallow the row's own single-click `lyra-select`,
|
|
53
|
+
* whereas a button is independently focusable, has its own accessible name,
|
|
54
|
+
* and composes cleanly with click-to-select.
|
|
55
|
+
*
|
|
56
|
+
* @customElement lyra-conversation-item
|
|
57
|
+
* @slot actions - Overflow/icon-button controls (e.g. a future pin/delete
|
|
58
|
+
* button) rendered at the trailing edge of the row. `lyra-menu` doesn't
|
|
59
|
+
* exist yet in this phase, so this is a plain slot for whatever a consumer
|
|
60
|
+
* wants to put there today.
|
|
61
|
+
* @event lyra-select - The row was activated: a click on `[part="option"]`
|
|
62
|
+
* (i.e. outside the rename button and the `actions` slot), or Enter/Space
|
|
63
|
+
* while it's focused -- in both cases only while not currently renaming. No
|
|
64
|
+
* detail payload -- see the class doc's "Identifying which session" note.
|
|
65
|
+
* @event lyra-rename - An in-place rename was committed (Enter, or blur
|
|
66
|
+
* while editing). `detail: { title }`. Does not mutate `title` itself --
|
|
67
|
+
* this is a controlled component, the same convention
|
|
68
|
+
* `<lyra-chat-message>` follows by not clearing its own state on retry; the
|
|
69
|
+
* consumer applies the new title once it's actually persisted. Not fired
|
|
70
|
+
* when the trimmed draft is empty or unchanged from the original `title`
|
|
71
|
+
* (that's treated as an implicit cancel).
|
|
72
|
+
* @csspart base - The outer row wrapper (plain, no ARIA role) laying out `[part="option"]`, the rename button, and `actions`.
|
|
73
|
+
* @csspart option - The selectable region (`role="option"`, removed while renaming -- see the class doc). Wraps `content` and `timestamp`.
|
|
74
|
+
* @csspart content - Wrapper around the title and excerpt.
|
|
75
|
+
* @csspart title - The title text, shown while not renaming.
|
|
76
|
+
* @csspart title-input - The in-place rename `<input>`, shown only while renaming.
|
|
77
|
+
* @csspart rename-button - The pencil/edit affordance that starts a rename (only rendered while `editable` and not already renaming).
|
|
78
|
+
* @csspart excerpt - The last-message preview snippet. Only rendered when `excerpt` is non-empty.
|
|
79
|
+
* @csspart timestamp - The formatted `timestamp`, rendered in a `<time>` element. Only rendered when `timestamp` is set and valid.
|
|
80
|
+
* @csspart actions - The wrapper around the `actions` slot.
|
|
81
|
+
*/
|
|
82
|
+
export declare class LyraConversationItem extends LyraElement {
|
|
83
|
+
static styles: import("lit").CSSResultGroup[];
|
|
84
|
+
/** The session's display title. */
|
|
85
|
+
title: string;
|
|
86
|
+
/** A short preview snippet of the last message. Omit for no excerpt line. */
|
|
87
|
+
excerpt: string;
|
|
88
|
+
/** When the session was last active. Accepts a `Date` or anything
|
|
89
|
+
* `new Date()` can parse (e.g. an ISO 8601 string); invalid input is
|
|
90
|
+
* treated the same as unset (no timestamp rendered) -- mirrors
|
|
91
|
+
* `<lyra-chat-message>`'s identical `timestamp` prop. */
|
|
92
|
+
timestamp?: Date | string;
|
|
93
|
+
/** Overrides the default absolute-time rendering of `timestamp` -- this
|
|
94
|
+
* library has no i18n system of its own, so an overridable formatter is
|
|
95
|
+
* the established way to hand locale-sensitive display back to the
|
|
96
|
+
* consumer (mirrors `<lyra-chat-message>`'s identical `formatTimestamp`). */
|
|
97
|
+
formatTimestamp?: (date: Date) => string;
|
|
98
|
+
/** Whether this is the currently-selected/open session. Drives the
|
|
99
|
+
* brand-quiet background treatment. */
|
|
100
|
+
active: boolean;
|
|
101
|
+
/** Whether inline-rename is available at all. When `false`, the rename
|
|
102
|
+
* button never renders and the row can never enter its editing state. */
|
|
103
|
+
editable: boolean;
|
|
104
|
+
private renaming;
|
|
105
|
+
private draftTitle;
|
|
106
|
+
private hasActionsSlot;
|
|
107
|
+
private titleInput?;
|
|
108
|
+
protected willUpdate(): void;
|
|
109
|
+
protected updated(changed: PropertyValues): void;
|
|
110
|
+
private get normalizedTimestamp();
|
|
111
|
+
private select;
|
|
112
|
+
private startRename;
|
|
113
|
+
private commitRename;
|
|
114
|
+
private cancelRename;
|
|
115
|
+
private onOptionClick;
|
|
116
|
+
private onOptionKeyDown;
|
|
117
|
+
private onRenameButtonClick;
|
|
118
|
+
private onTitleInputChange;
|
|
119
|
+
private onTitleInputKeyDown;
|
|
120
|
+
private onTitleInputBlur;
|
|
121
|
+
private onActionsSlotChange;
|
|
122
|
+
render(): TemplateResult;
|
|
123
|
+
}
|
|
124
|
+
declare global {
|
|
125
|
+
interface HTMLElementTagNameMap {
|
|
126
|
+
'lyra-conversation-item': LyraConversationItem;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
@@ -0,0 +1,322 @@
|
|
|
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 { styles } from './conversation-item.styles.js';
|
|
12
|
+
// Mirrors the shared icon set's viewBox/stroke conventions
|
|
13
|
+
// (internal/icons.ts's chevronIcon()/closeIcon()/etc.) without adding a
|
|
14
|
+
// pencil/edit glyph to that module -- it's off limits here -- so this
|
|
15
|
+
// one-off icon still reads as part of the same visual language as the rest
|
|
16
|
+
// of the library's inline icons. Same approach lyra-checkbox's own local
|
|
17
|
+
// checkmark/indeterminate glyphs and lyra-chat-message's local retryIcon()
|
|
18
|
+
// take for the identical reason.
|
|
19
|
+
const ICON_VIEW_BOX = '0 0 24 24';
|
|
20
|
+
const ICON_STROKE_WIDTH = '1.75';
|
|
21
|
+
function pencilIcon() {
|
|
22
|
+
return svg `
|
|
23
|
+
<svg
|
|
24
|
+
width="1em"
|
|
25
|
+
height="1em"
|
|
26
|
+
viewBox=${ICON_VIEW_BOX}
|
|
27
|
+
fill="none"
|
|
28
|
+
stroke="currentColor"
|
|
29
|
+
stroke-width=${ICON_STROKE_WIDTH}
|
|
30
|
+
stroke-linecap="round"
|
|
31
|
+
stroke-linejoin="round"
|
|
32
|
+
aria-hidden="true"
|
|
33
|
+
focusable="false"
|
|
34
|
+
><path d="M12 20h9"></path><path d="M16.5 3.5a2.121 2.121 0 0 1 3 3L7 19l-4 1 1-4Z"></path></svg>
|
|
35
|
+
`;
|
|
36
|
+
}
|
|
37
|
+
/** `Intl.DateTimeFormat`-based absolute formatter -- clock time ("3:45 PM")
|
|
38
|
+
* for a timestamp that falls on the same calendar day as `now`, otherwise a
|
|
39
|
+
* calendar date ("Jul 10", or "Jul 10, 2024" once it's not the current
|
|
40
|
+
* year). Deliberately not a fuzzy "2 hours ago" relative string -- bucketed
|
|
41
|
+
* relative time (grouping a whole history list into "Today"/"Yesterday"/
|
|
42
|
+
* "Last 7 days" sections) is a separate, later-phase concern at the list
|
|
43
|
+
* level, not this single row's job. `formatTimestamp` overrides this
|
|
44
|
+
* entirely, mirroring `<lyra-chat-message>`'s identical override hook. */
|
|
45
|
+
function defaultFormatTimestamp(date, now = new Date()) {
|
|
46
|
+
const sameDay = date.toDateString() === now.toDateString();
|
|
47
|
+
if (sameDay) {
|
|
48
|
+
return new Intl.DateTimeFormat(undefined, { hour: 'numeric', minute: '2-digit' }).format(date);
|
|
49
|
+
}
|
|
50
|
+
const sameYear = date.getFullYear() === now.getFullYear();
|
|
51
|
+
return new Intl.DateTimeFormat(undefined, sameYear ? { month: 'short', day: 'numeric' } : { month: 'short', day: 'numeric', year: 'numeric' }).format(date);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* `<lyra-conversation-item>` — a selectable row representing one chat
|
|
55
|
+
* session in a history sidebar list. Usable standalone or as the
|
|
56
|
+
* `renderItem()` payload of a sibling virtualized-list component; this
|
|
57
|
+
* module has no dependency on that (or any) other component.
|
|
58
|
+
*
|
|
59
|
+
* Takes `title`/`excerpt`/`timestamp` as individual primitive props rather
|
|
60
|
+
* than one opaque bound object, deliberately consistent with how
|
|
61
|
+
* `<lyra-chat-message>` takes individual props instead of a single
|
|
62
|
+
* `.message` blob -- every other component in this family follows that
|
|
63
|
+
* shape, so this one does too even though a single bound `.session` object
|
|
64
|
+
* would also have been a reasonable design.
|
|
65
|
+
*
|
|
66
|
+
* Identifying *which* session a `lyra-select` click/keypress was about: this
|
|
67
|
+
* reuses the platform's own `id` attribute (every element already has one)
|
|
68
|
+
* rather than inventing a second, differently-named id-carrying prop --
|
|
69
|
+
* consumers already have the event's `target`/`currentTarget` (and thus
|
|
70
|
+
* `.id`), the same reasoning `<lyra-attachment-chip>` documents for its own
|
|
71
|
+
* identically-shaped choice. `lyra-select` therefore carries no detail
|
|
72
|
+
* payload at all.
|
|
73
|
+
*
|
|
74
|
+
* `role="option"` (not `"button"`) on `[part="option"]`, since this is meant
|
|
75
|
+
* to live inside a `role="listbox"` history list (that future list
|
|
76
|
+
* component supplies the listbox/group ancestor `role="option"` requires)
|
|
77
|
+
* rather than stand in for a single push-button action. Used truly
|
|
78
|
+
* standalone -- with no listbox/group ancestor -- it's still fully
|
|
79
|
+
* operable, just technically missing that ARIA parent context; wrap it in a
|
|
80
|
+
* `role="listbox"` (or `role="group"`) container to satisfy that when
|
|
81
|
+
* accessibility-auditing a standalone usage.
|
|
82
|
+
*
|
|
83
|
+
* `role="option"` (like native `<option>`/`role="button"`) forbids focusable
|
|
84
|
+
* descendants -- verified against axe-core's `nested-interactive` rule,
|
|
85
|
+
* which flags it. That's why the rename button and the `actions` slot are
|
|
86
|
+
* rendered as DOM *siblings* of `[part="option"]` (both inside
|
|
87
|
+
* `[part="base"]`) rather than nested inside it: `[part="option"]` only ever
|
|
88
|
+
* contains plain text/`<time>` content. The in-place rename `<input>` is the
|
|
89
|
+
* same problem one level deeper -- it replaces the title *inside*
|
|
90
|
+
* `[part="option"]` while renaming -- so `[part="option"]` sheds its
|
|
91
|
+
* `role`/`tabindex`/`aria-selected`/`aria-label` entirely for the duration
|
|
92
|
+
* of an edit. This isn't just an ARIA-compliance workaround: a row mid-edit
|
|
93
|
+
* genuinely isn't a selectable listbox choice at that moment, it's a text
|
|
94
|
+
* field, so suspending the option semantics is also the more accurate
|
|
95
|
+
* description of what's on screen.
|
|
96
|
+
*
|
|
97
|
+
* Inline rename is a dedicated pencil/edit icon button (not a double-click
|
|
98
|
+
* on the title) -- double-click has no keyboard/screen-reader equivalent
|
|
99
|
+
* and would silently swallow the row's own single-click `lyra-select`,
|
|
100
|
+
* whereas a button is independently focusable, has its own accessible name,
|
|
101
|
+
* and composes cleanly with click-to-select.
|
|
102
|
+
*
|
|
103
|
+
* @customElement lyra-conversation-item
|
|
104
|
+
* @slot actions - Overflow/icon-button controls (e.g. a future pin/delete
|
|
105
|
+
* button) rendered at the trailing edge of the row. `lyra-menu` doesn't
|
|
106
|
+
* exist yet in this phase, so this is a plain slot for whatever a consumer
|
|
107
|
+
* wants to put there today.
|
|
108
|
+
* @event lyra-select - The row was activated: a click on `[part="option"]`
|
|
109
|
+
* (i.e. outside the rename button and the `actions` slot), or Enter/Space
|
|
110
|
+
* while it's focused -- in both cases only while not currently renaming. No
|
|
111
|
+
* detail payload -- see the class doc's "Identifying which session" note.
|
|
112
|
+
* @event lyra-rename - An in-place rename was committed (Enter, or blur
|
|
113
|
+
* while editing). `detail: { title }`. Does not mutate `title` itself --
|
|
114
|
+
* this is a controlled component, the same convention
|
|
115
|
+
* `<lyra-chat-message>` follows by not clearing its own state on retry; the
|
|
116
|
+
* consumer applies the new title once it's actually persisted. Not fired
|
|
117
|
+
* when the trimmed draft is empty or unchanged from the original `title`
|
|
118
|
+
* (that's treated as an implicit cancel).
|
|
119
|
+
* @csspart base - The outer row wrapper (plain, no ARIA role) laying out `[part="option"]`, the rename button, and `actions`.
|
|
120
|
+
* @csspart option - The selectable region (`role="option"`, removed while renaming -- see the class doc). Wraps `content` and `timestamp`.
|
|
121
|
+
* @csspart content - Wrapper around the title and excerpt.
|
|
122
|
+
* @csspart title - The title text, shown while not renaming.
|
|
123
|
+
* @csspart title-input - The in-place rename `<input>`, shown only while renaming.
|
|
124
|
+
* @csspart rename-button - The pencil/edit affordance that starts a rename (only rendered while `editable` and not already renaming).
|
|
125
|
+
* @csspart excerpt - The last-message preview snippet. Only rendered when `excerpt` is non-empty.
|
|
126
|
+
* @csspart timestamp - The formatted `timestamp`, rendered in a `<time>` element. Only rendered when `timestamp` is set and valid.
|
|
127
|
+
* @csspart actions - The wrapper around the `actions` slot.
|
|
128
|
+
*/
|
|
129
|
+
export class LyraConversationItem extends LyraElement {
|
|
130
|
+
constructor() {
|
|
131
|
+
super(...arguments);
|
|
132
|
+
/** The session's display title. */
|
|
133
|
+
this.title = '';
|
|
134
|
+
/** A short preview snippet of the last message. Omit for no excerpt line. */
|
|
135
|
+
this.excerpt = '';
|
|
136
|
+
/** Whether this is the currently-selected/open session. Drives the
|
|
137
|
+
* brand-quiet background treatment. */
|
|
138
|
+
this.active = false;
|
|
139
|
+
/** Whether inline-rename is available at all. When `false`, the rename
|
|
140
|
+
* button never renders and the row can never enter its editing state. */
|
|
141
|
+
this.editable = true;
|
|
142
|
+
this.renaming = false;
|
|
143
|
+
this.draftTitle = '';
|
|
144
|
+
this.hasActionsSlot = false;
|
|
145
|
+
this.onOptionClick = () => {
|
|
146
|
+
// While renaming, `[part="option"]` has no role/selection semantics
|
|
147
|
+
// (see the class doc) -- a click inside it (e.g. to place the caret in
|
|
148
|
+
// the input) must not also select the row.
|
|
149
|
+
if (this.renaming)
|
|
150
|
+
return;
|
|
151
|
+
this.select();
|
|
152
|
+
};
|
|
153
|
+
this.onOptionKeyDown = (e) => {
|
|
154
|
+
if (this.renaming)
|
|
155
|
+
return;
|
|
156
|
+
if (e.key === 'Enter' || e.key === ' ' || e.key === 'Spacebar') {
|
|
157
|
+
// Space would otherwise scroll the page, same as lyra-checkbox/lyra-switch.
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
this.select();
|
|
160
|
+
}
|
|
161
|
+
};
|
|
162
|
+
this.onRenameButtonClick = () => {
|
|
163
|
+
// No stopPropagation() needed here: the rename button is a DOM sibling
|
|
164
|
+
// of `[part="option"]` (see the class doc), not a descendant of it, so
|
|
165
|
+
// this click was never going to reach onOptionClick's listener anyway.
|
|
166
|
+
this.startRename();
|
|
167
|
+
};
|
|
168
|
+
this.onTitleInputChange = (e) => {
|
|
169
|
+
this.draftTitle = e.target.value;
|
|
170
|
+
};
|
|
171
|
+
this.onTitleInputKeyDown = (e) => {
|
|
172
|
+
// The input is a descendant of `[part="option"]` (unlike the rename
|
|
173
|
+
// button/actions slot, which are siblings of it) -- its keydown would
|
|
174
|
+
// otherwise bubble into onOptionKeyDown above. Stopping it here avoids a
|
|
175
|
+
// race where commitRename() (called below) has already flipped
|
|
176
|
+
// `renaming` back to `false` by the time that bubbled event reaches
|
|
177
|
+
// onOptionKeyDown's own `if (this.renaming) return;` guard, which would
|
|
178
|
+
// otherwise wrongly let the same Enter keystroke also fire lyra-select.
|
|
179
|
+
e.stopPropagation();
|
|
180
|
+
if (e.key === 'Enter') {
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
this.commitRename();
|
|
183
|
+
}
|
|
184
|
+
else if (e.key === 'Escape') {
|
|
185
|
+
e.preventDefault();
|
|
186
|
+
this.cancelRename();
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
this.onTitleInputBlur = () => {
|
|
190
|
+
// If Escape already ended the edit synchronously (cancelRename() runs
|
|
191
|
+
// before this fires), `renaming` is already false by the time the
|
|
192
|
+
// now-removed input's blur event reaches here -- skip so Escape can't
|
|
193
|
+
// also commit.
|
|
194
|
+
if (!this.renaming)
|
|
195
|
+
return;
|
|
196
|
+
this.commitRename();
|
|
197
|
+
};
|
|
198
|
+
this.onActionsSlotChange = (e) => {
|
|
199
|
+
this.hasActionsSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
200
|
+
};
|
|
201
|
+
}
|
|
202
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
203
|
+
willUpdate() {
|
|
204
|
+
if (!this.hasUpdated) {
|
|
205
|
+
this.hasActionsSlot = Array.from(this.children).some((el) => el.getAttribute('slot') === 'actions');
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
updated(changed) {
|
|
209
|
+
if (changed.has('renaming') && this.renaming) {
|
|
210
|
+
// Runs after render, so the input already exists in the DOM.
|
|
211
|
+
this.titleInput?.focus();
|
|
212
|
+
this.titleInput?.select();
|
|
213
|
+
}
|
|
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
|
+
select() {
|
|
222
|
+
this.emit('lyra-select');
|
|
223
|
+
}
|
|
224
|
+
startRename() {
|
|
225
|
+
if (!this.editable || this.renaming)
|
|
226
|
+
return;
|
|
227
|
+
this.draftTitle = this.title;
|
|
228
|
+
this.renaming = true;
|
|
229
|
+
}
|
|
230
|
+
commitRename() {
|
|
231
|
+
this.renaming = false;
|
|
232
|
+
const next = this.draftTitle.trim();
|
|
233
|
+
// An empty or unchanged draft has nothing meaningful to commit -- treat
|
|
234
|
+
// it the same as Escape rather than firing a no-op (or blanking) rename
|
|
235
|
+
// for the consumer to deal with.
|
|
236
|
+
if (!next || next === this.title)
|
|
237
|
+
return;
|
|
238
|
+
this.emit('lyra-rename', { title: next });
|
|
239
|
+
}
|
|
240
|
+
cancelRename() {
|
|
241
|
+
this.renaming = false;
|
|
242
|
+
}
|
|
243
|
+
render() {
|
|
244
|
+
const ts = this.normalizedTimestamp;
|
|
245
|
+
const formatter = this.formatTimestamp ?? defaultFormatTimestamp;
|
|
246
|
+
const displayTitle = this.title || 'Untitled conversation';
|
|
247
|
+
const showRenameButton = this.editable && !this.renaming;
|
|
248
|
+
return html `
|
|
249
|
+
<div part="base">
|
|
250
|
+
<div
|
|
251
|
+
part="option"
|
|
252
|
+
role=${this.renaming ? nothing : 'option'}
|
|
253
|
+
tabindex=${this.renaming ? nothing : '0'}
|
|
254
|
+
aria-selected=${this.renaming ? nothing : this.active ? 'true' : 'false'}
|
|
255
|
+
aria-label=${this.renaming ? nothing : this.getAttribute('aria-label') || displayTitle}
|
|
256
|
+
@click=${this.onOptionClick}
|
|
257
|
+
@keydown=${this.onOptionKeyDown}
|
|
258
|
+
>
|
|
259
|
+
<div part="content">
|
|
260
|
+
${this.renaming
|
|
261
|
+
? html `<input
|
|
262
|
+
part="title-input"
|
|
263
|
+
type="text"
|
|
264
|
+
.value=${this.draftTitle}
|
|
265
|
+
aria-label="Rename conversation"
|
|
266
|
+
@input=${this.onTitleInputChange}
|
|
267
|
+
@keydown=${this.onTitleInputKeyDown}
|
|
268
|
+
@blur=${this.onTitleInputBlur}
|
|
269
|
+
/>`
|
|
270
|
+
: html `<span part="title" title=${displayTitle}>${displayTitle}</span>`}
|
|
271
|
+
${this.excerpt ? html `<span part="excerpt">${this.excerpt}</span>` : nothing}
|
|
272
|
+
</div>
|
|
273
|
+
${ts ? html `<time part="timestamp" datetime=${ts.toISOString()}>${formatter(ts)}</time>` : nothing}
|
|
274
|
+
</div>
|
|
275
|
+
${showRenameButton
|
|
276
|
+
? html `<button
|
|
277
|
+
part="rename-button"
|
|
278
|
+
type="button"
|
|
279
|
+
aria-label=${`Rename ${displayTitle}`}
|
|
280
|
+
@click=${this.onRenameButtonClick}
|
|
281
|
+
>
|
|
282
|
+
${pencilIcon()}
|
|
283
|
+
</button>`
|
|
284
|
+
: nothing}
|
|
285
|
+
<span part="actions" ?hidden=${!this.hasActionsSlot}>
|
|
286
|
+
<slot name="actions" @slotchange=${this.onActionsSlotChange}></slot>
|
|
287
|
+
</span>
|
|
288
|
+
</div>
|
|
289
|
+
`;
|
|
290
|
+
}
|
|
291
|
+
}
|
|
292
|
+
__decorate([
|
|
293
|
+
property()
|
|
294
|
+
], LyraConversationItem.prototype, "title", void 0);
|
|
295
|
+
__decorate([
|
|
296
|
+
property()
|
|
297
|
+
], LyraConversationItem.prototype, "excerpt", void 0);
|
|
298
|
+
__decorate([
|
|
299
|
+
property({ attribute: false })
|
|
300
|
+
], LyraConversationItem.prototype, "timestamp", void 0);
|
|
301
|
+
__decorate([
|
|
302
|
+
property({ attribute: false })
|
|
303
|
+
], LyraConversationItem.prototype, "formatTimestamp", void 0);
|
|
304
|
+
__decorate([
|
|
305
|
+
property({ type: Boolean, reflect: true })
|
|
306
|
+
], LyraConversationItem.prototype, "active", void 0);
|
|
307
|
+
__decorate([
|
|
308
|
+
property({ type: Boolean, reflect: true })
|
|
309
|
+
], LyraConversationItem.prototype, "editable", void 0);
|
|
310
|
+
__decorate([
|
|
311
|
+
state()
|
|
312
|
+
], LyraConversationItem.prototype, "renaming", void 0);
|
|
313
|
+
__decorate([
|
|
314
|
+
state()
|
|
315
|
+
], LyraConversationItem.prototype, "draftTitle", void 0);
|
|
316
|
+
__decorate([
|
|
317
|
+
state()
|
|
318
|
+
], LyraConversationItem.prototype, "hasActionsSlot", void 0);
|
|
319
|
+
__decorate([
|
|
320
|
+
query('[part="title-input"]')
|
|
321
|
+
], LyraConversationItem.prototype, "titleInput", void 0);
|
|
322
|
+
defineElement('conversation-item', LyraConversationItem);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|