@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
|
@@ -54,12 +54,15 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
54
54
|
value: {
|
|
55
55
|
noAccessor: boolean;
|
|
56
56
|
};
|
|
57
|
+
name: {
|
|
58
|
+
reflect: boolean;
|
|
59
|
+
noAccessor: boolean;
|
|
60
|
+
};
|
|
57
61
|
};
|
|
58
62
|
multiple: boolean;
|
|
59
63
|
placeholder: string;
|
|
60
64
|
disabled: boolean;
|
|
61
65
|
required: boolean;
|
|
62
|
-
name: string;
|
|
63
66
|
label: string;
|
|
64
67
|
hint: string;
|
|
65
68
|
errorText: string;
|
|
@@ -84,6 +87,7 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
84
87
|
private _selectedLabelCache;
|
|
85
88
|
private _rowsByValue;
|
|
86
89
|
private internals;
|
|
90
|
+
private _fieldsetDisabled;
|
|
87
91
|
private listId;
|
|
88
92
|
private inputId;
|
|
89
93
|
private cleanup?;
|
|
@@ -91,20 +95,34 @@ export declare class LyraCombobox extends LyraElement {
|
|
|
91
95
|
private _selected;
|
|
92
96
|
private _defaultSelected;
|
|
93
97
|
private _defaultCaptured;
|
|
98
|
+
private _name;
|
|
94
99
|
constructor();
|
|
95
100
|
connectedCallback(): void;
|
|
96
101
|
protected willUpdate(): void;
|
|
102
|
+
get name(): string;
|
|
103
|
+
set name(next: string);
|
|
97
104
|
/** The selected value(s): a string in single mode, a string[] in `multiple` mode. */
|
|
98
105
|
get value(): string | string[];
|
|
99
106
|
set value(next: string | string[]);
|
|
100
107
|
private updateValidity;
|
|
101
108
|
private syncFormValue;
|
|
109
|
+
/** Effective disabled state: this element's own `disabled` OR an ancestor
|
|
110
|
+
* `<fieldset disabled>`'s inherited state -- mirrors native `<input>`, whose
|
|
111
|
+
* own `disabled` IDL property/attribute is never mutated by a fieldset. */
|
|
112
|
+
get effectiveDisabled(): boolean;
|
|
102
113
|
formResetCallback(): void;
|
|
114
|
+
/**
|
|
115
|
+
* Called by the browser when an ancestor `<fieldset disabled>` toggles.
|
|
116
|
+
* Tracked separately from the consumer's own `disabled` (see
|
|
117
|
+
* `effectiveDisabled`) so a consumer's explicit `disabled` survives the
|
|
118
|
+
* fieldset re-enabling instead of being permanently overwritten.
|
|
119
|
+
*/
|
|
103
120
|
formDisabledCallback(disabled: boolean): void;
|
|
104
121
|
checkValidity(): boolean;
|
|
105
122
|
reportValidity(): boolean;
|
|
106
123
|
disconnectedCallback(): void;
|
|
107
124
|
private collectOptions;
|
|
125
|
+
private onOptionChange;
|
|
108
126
|
private reflectSelected;
|
|
109
127
|
private labelFor;
|
|
110
128
|
/** The current row set in a source-agnostic shape, before capping. */
|
|
@@ -4,7 +4,7 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
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
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { html } from 'lit';
|
|
7
|
+
import { html, nothing } from 'lit';
|
|
8
8
|
import { property, state } from 'lit/decorators.js';
|
|
9
9
|
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
10
|
import { defineElement } from '../../internal/prefix.js';
|
|
@@ -54,6 +54,7 @@ export class LyraCombobox extends LyraElement {
|
|
|
54
54
|
static { this.styles = [LyraElement.styles, styles]; }
|
|
55
55
|
static { this.properties = {
|
|
56
56
|
value: { noAccessor: true },
|
|
57
|
+
name: { reflect: true, noAccessor: true },
|
|
57
58
|
}; }
|
|
58
59
|
constructor() {
|
|
59
60
|
super();
|
|
@@ -61,7 +62,6 @@ export class LyraCombobox extends LyraElement {
|
|
|
61
62
|
this.placeholder = '';
|
|
62
63
|
this.disabled = false;
|
|
63
64
|
this.required = false;
|
|
64
|
-
this.name = '';
|
|
65
65
|
this.label = '';
|
|
66
66
|
this.hint = '';
|
|
67
67
|
this.errorText = '';
|
|
@@ -97,6 +97,11 @@ export class LyraCombobox extends LyraElement {
|
|
|
97
97
|
// handlers' data-value lookup below, instead of each option row closing
|
|
98
98
|
// over its own row object.
|
|
99
99
|
this._rowsByValue = new Map();
|
|
100
|
+
// Tracked separately from the consumer's own `disabled` -- a native
|
|
101
|
+
// `<input>`'s own `disabled` IDL property/attribute is never mutated by
|
|
102
|
+
// fieldset cascading, so a consumer's explicit `disabled` must survive the
|
|
103
|
+
// fieldset re-enabling (see `formDisabledCallback` below).
|
|
104
|
+
this._fieldsetDisabled = false;
|
|
100
105
|
this.listId = nextId('combobox-list');
|
|
101
106
|
this.inputId = nextId('combobox-input');
|
|
102
107
|
this._isFirstUpdate = true;
|
|
@@ -111,6 +116,15 @@ export class LyraCombobox extends LyraElement {
|
|
|
111
116
|
// property assignment never does).
|
|
112
117
|
this._defaultSelected = [];
|
|
113
118
|
this._defaultCaptured = false;
|
|
119
|
+
// Hand-written accessor (mirrors the `value` accessor below, and Task 2's
|
|
120
|
+
// `FormAssociated.name` in `../../internal/form-associated.ts`): a
|
|
121
|
+
// form-associated custom element's submitted entry name is resolved by the
|
|
122
|
+
// browser from the live `name` *content attribute*, read synchronously at
|
|
123
|
+
// FormData-construction/submit time (see `syncFormValue()` below) -- Lit's
|
|
124
|
+
// async (microtask-deferred) `reflect: true` alone would leave a
|
|
125
|
+
// property-only assignment like `el.name = 'b'` invisible to a same-tick
|
|
126
|
+
// `new FormData(form)`/submit, so the attribute write happens here instead.
|
|
127
|
+
this._name = '';
|
|
114
128
|
this.collectOptions = (e) => {
|
|
115
129
|
const slot = e.target;
|
|
116
130
|
const previous = new Set(this.options);
|
|
@@ -149,6 +163,14 @@ export class LyraCombobox extends LyraElement {
|
|
|
149
163
|
}
|
|
150
164
|
this.reflectSelected();
|
|
151
165
|
};
|
|
166
|
+
this.onOptionChange = () => {
|
|
167
|
+
// Touch the `options` array reference so Lit's change-detection sees a
|
|
168
|
+
// "new" value and re-renders `renderRows()`/`filtered`/`labelFor()` off
|
|
169
|
+
// the options' now-current data -- the *set* of options is unchanged,
|
|
170
|
+
// only one member's own properties are, so this skips
|
|
171
|
+
// collectOptions()'s selection-seeding logic entirely.
|
|
172
|
+
this.options = [...this.options];
|
|
173
|
+
};
|
|
152
174
|
this.onDocPointer = (e) => {
|
|
153
175
|
if (!e.composedPath().includes(this))
|
|
154
176
|
this.hide();
|
|
@@ -226,7 +248,7 @@ export class LyraCombobox extends LyraElement {
|
|
|
226
248
|
}
|
|
227
249
|
};
|
|
228
250
|
this.onComboMouseDown = (e) => {
|
|
229
|
-
if (this.
|
|
251
|
+
if (this.effectiveDisabled)
|
|
230
252
|
return;
|
|
231
253
|
if (e.target.closest('button'))
|
|
232
254
|
return;
|
|
@@ -268,6 +290,20 @@ export class LyraCombobox extends LyraElement {
|
|
|
268
290
|
this.hasLabelSlot = Array.from(this.children).some((el) => el.getAttribute('slot') === 'label');
|
|
269
291
|
}
|
|
270
292
|
}
|
|
293
|
+
get name() {
|
|
294
|
+
return this._name;
|
|
295
|
+
}
|
|
296
|
+
set name(next) {
|
|
297
|
+
const old = this._name;
|
|
298
|
+
this._name = next ?? '';
|
|
299
|
+
if (this._name) {
|
|
300
|
+
this.setAttribute('name', this._name);
|
|
301
|
+
}
|
|
302
|
+
else {
|
|
303
|
+
this.removeAttribute('name');
|
|
304
|
+
}
|
|
305
|
+
this.requestUpdate('name', old);
|
|
306
|
+
}
|
|
271
307
|
/** The selected value(s): a string in single mode, a string[] in `multiple` mode. */
|
|
272
308
|
get value() {
|
|
273
309
|
return this.multiple ? [...this._selected] : (this._selected[0] ?? '');
|
|
@@ -309,12 +345,25 @@ export class LyraCombobox extends LyraElement {
|
|
|
309
345
|
this.internals.setFormValue(this._selected[0] ?? '');
|
|
310
346
|
}
|
|
311
347
|
}
|
|
348
|
+
/** Effective disabled state: this element's own `disabled` OR an ancestor
|
|
349
|
+
* `<fieldset disabled>`'s inherited state -- mirrors native `<input>`, whose
|
|
350
|
+
* own `disabled` IDL property/attribute is never mutated by a fieldset. */
|
|
351
|
+
get effectiveDisabled() {
|
|
352
|
+
return this.disabled || this._fieldsetDisabled;
|
|
353
|
+
}
|
|
312
354
|
formResetCallback() {
|
|
313
355
|
this.value = [...this._defaultSelected];
|
|
314
356
|
this.query = '';
|
|
315
357
|
}
|
|
358
|
+
/**
|
|
359
|
+
* Called by the browser when an ancestor `<fieldset disabled>` toggles.
|
|
360
|
+
* Tracked separately from the consumer's own `disabled` (see
|
|
361
|
+
* `effectiveDisabled`) so a consumer's explicit `disabled` survives the
|
|
362
|
+
* fieldset re-enabling instead of being permanently overwritten.
|
|
363
|
+
*/
|
|
316
364
|
formDisabledCallback(disabled) {
|
|
317
|
-
this.
|
|
365
|
+
this._fieldsetDisabled = disabled;
|
|
366
|
+
this.requestUpdate();
|
|
318
367
|
}
|
|
319
368
|
checkValidity() {
|
|
320
369
|
return this.internals.checkValidity();
|
|
@@ -325,8 +374,15 @@ export class LyraCombobox extends LyraElement {
|
|
|
325
374
|
disconnectedCallback() {
|
|
326
375
|
super.disconnectedCallback();
|
|
327
376
|
this.cleanup?.();
|
|
377
|
+
this.cleanup = undefined;
|
|
328
378
|
clearTimeout(this.sourceTimer);
|
|
329
379
|
document.removeEventListener('pointerdown', this.onDocPointer);
|
|
380
|
+
// Reset so a reconnect (e.g. a drag-drop reparent) re-triggers
|
|
381
|
+
// `updated()`'s `open`-driven branch -- without this, `open` stays
|
|
382
|
+
// `true` across the disconnect/reconnect and `changed.has('open')` never
|
|
383
|
+
// fires again, leaving the listbox rendered open with no positioning and
|
|
384
|
+
// no outside-click listener.
|
|
385
|
+
this.open = false;
|
|
330
386
|
}
|
|
331
387
|
reflectSelected() {
|
|
332
388
|
const sel = new Set(this._selected);
|
|
@@ -381,7 +437,7 @@ export class LyraCombobox extends LyraElement {
|
|
|
381
437
|
return this._selected[0] ? this.labelFor(this._selected[0]) : '';
|
|
382
438
|
}
|
|
383
439
|
show() {
|
|
384
|
-
if (this.open || this.
|
|
440
|
+
if (this.open || this.effectiveDisabled)
|
|
385
441
|
return;
|
|
386
442
|
this.open = true;
|
|
387
443
|
}
|
|
@@ -422,6 +478,8 @@ export class LyraCombobox extends LyraElement {
|
|
|
422
478
|
}
|
|
423
479
|
if (changed.has('required'))
|
|
424
480
|
this.updateValidity();
|
|
481
|
+
if (changed.has('name') || changed.has('multiple'))
|
|
482
|
+
this.syncFormValue();
|
|
425
483
|
if (changed.has('touched') || changed.has('required') || changed.has('value')) {
|
|
426
484
|
this.toggleAttribute('data-invalid', this.touched && !this.internals.validity.valid);
|
|
427
485
|
}
|
|
@@ -469,11 +527,22 @@ export class LyraCombobox extends LyraElement {
|
|
|
469
527
|
this.sourceTimer = setTimeout(() => {
|
|
470
528
|
const token = ++this.sourceToken;
|
|
471
529
|
this.loading = true;
|
|
472
|
-
this.source(query)
|
|
530
|
+
// `Promise.resolve().then(() => this.source!(query))` moves the call
|
|
531
|
+
// itself inside a `.then()` callback, so a *synchronous* throw from
|
|
532
|
+
// `this.source(query)` becomes a normal promise rejection the
|
|
533
|
+
// following `.catch()` handles, instead of escaping this `setTimeout`
|
|
534
|
+
// callback as an uncaught exception.
|
|
535
|
+
Promise.resolve()
|
|
536
|
+
.then(() => this.source(query))
|
|
473
537
|
.then((rows) => {
|
|
474
538
|
if (token !== this.sourceToken || !this.isConnected)
|
|
475
539
|
return;
|
|
476
540
|
this.asyncRows = rows;
|
|
541
|
+
})
|
|
542
|
+
.catch((err) => {
|
|
543
|
+
if (token !== this.sourceToken || !this.isConnected)
|
|
544
|
+
return;
|
|
545
|
+
console.warn('<lyra-combobox> source() rejected:', err);
|
|
477
546
|
})
|
|
478
547
|
.finally(() => {
|
|
479
548
|
if (token === this.sourceToken)
|
|
@@ -523,6 +592,7 @@ export class LyraCombobox extends LyraElement {
|
|
|
523
592
|
const hasHint = this.hasHintSlot || this.hint.length > 0;
|
|
524
593
|
const hasError = this.hasErrorSlot || this.errorText.length > 0;
|
|
525
594
|
const hasLabel = this.hasLabelSlot || this.label.length > 0;
|
|
595
|
+
const describedBy = [hasError ? 'combobox-error' : '', hasHint ? 'combobox-hint' : ''].filter(Boolean).join(' ');
|
|
526
596
|
return html `
|
|
527
597
|
<div part="form-control">
|
|
528
598
|
<label part="form-control-label" for=${this.inputId} ?hidden=${!hasLabel}>
|
|
@@ -534,6 +604,7 @@ export class LyraCombobox extends LyraElement {
|
|
|
534
604
|
>${this.labelFor(v)}<button
|
|
535
605
|
part="tag__remove-button"
|
|
536
606
|
type="button"
|
|
607
|
+
?disabled=${this.effectiveDisabled}
|
|
537
608
|
aria-label="Remove ${this.labelFor(v)}"
|
|
538
609
|
@click=${(e) => {
|
|
539
610
|
e.stopPropagation();
|
|
@@ -549,7 +620,8 @@ export class LyraCombobox extends LyraElement {
|
|
|
549
620
|
id=${this.inputId}
|
|
550
621
|
part="combobox-input"
|
|
551
622
|
role="combobox"
|
|
552
|
-
aria-label=${this.getAttribute('aria-label') ||
|
|
623
|
+
aria-label=${this.getAttribute('aria-label') || (hasLabel ? nothing : this.placeholder || 'Combobox')}
|
|
624
|
+
aria-describedby=${describedBy || nothing}
|
|
553
625
|
aria-expanded=${this.open ? 'true' : 'false'}
|
|
554
626
|
aria-controls=${this.listId}
|
|
555
627
|
aria-activedescendant=${activeId}
|
|
@@ -559,7 +631,7 @@ export class LyraCombobox extends LyraElement {
|
|
|
559
631
|
autocomplete="off"
|
|
560
632
|
.value=${this.displayValue}
|
|
561
633
|
placeholder=${hasValue && !this.multiple ? '' : this.placeholder}
|
|
562
|
-
?disabled=${this.
|
|
634
|
+
?disabled=${this.effectiveDisabled}
|
|
563
635
|
@input=${this.onInput}
|
|
564
636
|
@keydown=${this.onKeyDown}
|
|
565
637
|
@focus=${() => this.show()}
|
|
@@ -569,6 +641,7 @@ export class LyraCombobox extends LyraElement {
|
|
|
569
641
|
? html `<button
|
|
570
642
|
part="clear-button"
|
|
571
643
|
type="button"
|
|
644
|
+
?disabled=${this.effectiveDisabled}
|
|
572
645
|
aria-label="Clear"
|
|
573
646
|
@click=${(e) => {
|
|
574
647
|
e.stopPropagation();
|
|
@@ -597,14 +670,14 @@ export class LyraCombobox extends LyraElement {
|
|
|
597
670
|
? html `<div part="option-overflow">+${overflow} more — refine your search</div>`
|
|
598
671
|
: ''}`}
|
|
599
672
|
</div>
|
|
600
|
-
<div part="error" ?hidden=${!hasError}>
|
|
673
|
+
<div id="combobox-error" part="error" ?hidden=${!hasError}>
|
|
601
674
|
${this.errorText}<slot name="error" @slotchange=${this.onErrorSlotChange}></slot>
|
|
602
675
|
</div>
|
|
603
|
-
<div part="hint" ?hidden=${!hasHint}>
|
|
676
|
+
<div id="combobox-hint" part="hint" ?hidden=${!hasHint}>
|
|
604
677
|
${this.hint}<slot name="hint" @slotchange=${this.onHintSlotChange}></slot>
|
|
605
678
|
</div>
|
|
606
679
|
</div>
|
|
607
|
-
<slot @slotchange=${this.collectOptions} hidden></slot>
|
|
680
|
+
<slot @slotchange=${this.collectOptions} @lyra-option-change=${this.onOptionChange} hidden></slot>
|
|
608
681
|
`;
|
|
609
682
|
}
|
|
610
683
|
}
|
|
@@ -620,9 +693,6 @@ __decorate([
|
|
|
620
693
|
__decorate([
|
|
621
694
|
property({ type: Boolean, reflect: true })
|
|
622
695
|
], LyraCombobox.prototype, "required", void 0);
|
|
623
|
-
__decorate([
|
|
624
|
-
property()
|
|
625
|
-
], LyraCombobox.prototype, "name", void 0);
|
|
626
696
|
__decorate([
|
|
627
697
|
property()
|
|
628
698
|
], LyraCombobox.prototype, "label", void 0);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type TemplateResult } from 'lit';
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
2
|
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
3
|
/**
|
|
4
4
|
* `<lyra-option>` — a selectable option for `<lyra-combobox>`.
|
|
@@ -27,6 +27,10 @@ export declare class LyraOption extends LyraElement {
|
|
|
27
27
|
dotColor: string;
|
|
28
28
|
/** Resolved label: explicit non-empty `label` attribute wins, else trimmed text content. */
|
|
29
29
|
get label(): string;
|
|
30
|
+
private labelObserver?;
|
|
31
|
+
connectedCallback(): void;
|
|
32
|
+
disconnectedCallback(): void;
|
|
33
|
+
protected updated(changed: PropertyValues): void;
|
|
30
34
|
render(): TemplateResult;
|
|
31
35
|
}
|
|
32
36
|
declare global {
|
|
@@ -48,6 +48,41 @@ export class LyraOption extends LyraElement {
|
|
|
48
48
|
const attr = this.getAttribute('label');
|
|
49
49
|
return (attr ? attr : (this.textContent ?? '')).trim();
|
|
50
50
|
}
|
|
51
|
+
connectedCallback() {
|
|
52
|
+
super.connectedCallback();
|
|
53
|
+
// `label` is derived from either the `label` attribute or `textContent` --
|
|
54
|
+
// neither is a Lit reactive property, so a direct mutation of either
|
|
55
|
+
// (e.g. `option.textContent = 'New label'`) needs its own observer to
|
|
56
|
+
// notify the parent combobox/select that its cached row data is stale.
|
|
57
|
+
this.labelObserver = new MutationObserver(() => this.emit('lyra-option-change'));
|
|
58
|
+
this.labelObserver.observe(this, {
|
|
59
|
+
attributes: true,
|
|
60
|
+
attributeFilter: ['label'],
|
|
61
|
+
childList: true,
|
|
62
|
+
characterData: true,
|
|
63
|
+
subtree: true,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
disconnectedCallback() {
|
|
67
|
+
super.disconnectedCallback();
|
|
68
|
+
this.labelObserver?.disconnect();
|
|
69
|
+
this.labelObserver = undefined;
|
|
70
|
+
}
|
|
71
|
+
updated(changed) {
|
|
72
|
+
// `selected` is deliberately excluded -- the parent combobox/select
|
|
73
|
+
// already sets `selected` itself as *part of* rendering the current
|
|
74
|
+
// selection, so echoing that back as a `lyra-option-change` notification
|
|
75
|
+
// would trigger a redundant re-render on every selection change, rather
|
|
76
|
+
// than signal a genuine "this option's own data changed externally".
|
|
77
|
+
if (changed.has('value') ||
|
|
78
|
+
changed.has('disabled') ||
|
|
79
|
+
changed.has('group') ||
|
|
80
|
+
changed.has('searchText') ||
|
|
81
|
+
changed.has('sub') ||
|
|
82
|
+
changed.has('dotColor')) {
|
|
83
|
+
this.emit('lyra-option-change');
|
|
84
|
+
}
|
|
85
|
+
}
|
|
51
86
|
render() {
|
|
52
87
|
return html `<slot></slot>`;
|
|
53
88
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
export type ContextMeterTone = 'brand' | 'success' | 'warning' | 'danger' | 'neutral';
|
|
4
|
+
export type ContextMeterVariant = 'ring' | 'bar';
|
|
5
|
+
export interface ContextMeterSegment {
|
|
6
|
+
label: string;
|
|
7
|
+
/** Absolute quantity (e.g. tokens), not a pre-computed percentage. */
|
|
8
|
+
value: number;
|
|
9
|
+
tone?: ContextMeterTone;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* `<lyra-context-meter>` — a segmented occupancy meter (bar or ring) for
|
|
13
|
+
* showing how a fixed capacity (a model's context window, a token budget,
|
|
14
|
+
* any consumable quota) is divided across labeled categories. First-party
|
|
15
|
+
* invention; no equivalent exists in Web Awesome.
|
|
16
|
+
*
|
|
17
|
+
* Pure data visualization: it renders `segments`/`total` as given and never
|
|
18
|
+
* computes token counts, costs, or any other domain-specific estimate
|
|
19
|
+
* itself — the one exception is the plain arithmetic sum of the segment
|
|
20
|
+
* values used to build the accessible "X of Y used" summary below.
|
|
21
|
+
*
|
|
22
|
+
* @customElement lyra-context-meter
|
|
23
|
+
* @csspart base - The component's root wrapper (a `<div>` for `bar`, an `<svg>` for `ring`).
|
|
24
|
+
* @csspart track - The unfilled/empty capacity track.
|
|
25
|
+
* @csspart segment - One occupied segment. Carries `data-tone` for styling.
|
|
26
|
+
* @csspart label - The visible caption, when `label` is set.
|
|
27
|
+
*/
|
|
28
|
+
export declare class LyraContextMeter extends LyraElement {
|
|
29
|
+
static styles: import("lit").CSSResultGroup[];
|
|
30
|
+
/** Occupied segments, each an absolute quantity against `total` — never a percentage. */
|
|
31
|
+
segments: ContextMeterSegment[];
|
|
32
|
+
/** The full capacity segments are measured against (e.g. a model's context window size). */
|
|
33
|
+
total: number;
|
|
34
|
+
variant: ContextMeterVariant;
|
|
35
|
+
/** Overall accessible label/caption, e.g. `"128K context window"`. */
|
|
36
|
+
label: string;
|
|
37
|
+
/** Sum of segment values, clamped so a negative/NaN entry can't produce a negative total. */
|
|
38
|
+
private get usedTotal();
|
|
39
|
+
/** Per-segment ratio of `value` to `total`, clamped to [0,1] and capped so the
|
|
40
|
+
* running sum across all segments never overflows past 1 — a `segments` array
|
|
41
|
+
* that sums to more than `total` still renders a fully (not over-) filled meter. */
|
|
42
|
+
private ratios;
|
|
43
|
+
private get summary();
|
|
44
|
+
protected willUpdate(): void;
|
|
45
|
+
private renderBar;
|
|
46
|
+
private renderRing;
|
|
47
|
+
render(): TemplateResult;
|
|
48
|
+
}
|
|
49
|
+
declare global {
|
|
50
|
+
interface HTMLElementTagNameMap {
|
|
51
|
+
'lyra-context-meter': LyraContextMeter;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,150 @@
|
|
|
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, svg, nothing } from 'lit';
|
|
8
|
+
import { property } from 'lit/decorators.js';
|
|
9
|
+
import { styleMap } from 'lit/directives/style-map.js';
|
|
10
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
11
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
12
|
+
import { styles } from './context-meter.styles.js';
|
|
13
|
+
// Ring geometry, matching lyra-gauge's radial numbers so the two "circular
|
|
14
|
+
// meter" components in the library share one visual scale.
|
|
15
|
+
const RADIUS = 40;
|
|
16
|
+
const CENTER = 50;
|
|
17
|
+
const STROKE = 12;
|
|
18
|
+
const CIRCUMFERENCE = 2 * Math.PI * RADIUS;
|
|
19
|
+
function formatCount(n) {
|
|
20
|
+
return Number.isFinite(n) ? Math.round(n).toLocaleString() : '0';
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* `<lyra-context-meter>` — a segmented occupancy meter (bar or ring) for
|
|
24
|
+
* showing how a fixed capacity (a model's context window, a token budget,
|
|
25
|
+
* any consumable quota) is divided across labeled categories. First-party
|
|
26
|
+
* invention; no equivalent exists in Web Awesome.
|
|
27
|
+
*
|
|
28
|
+
* Pure data visualization: it renders `segments`/`total` as given and never
|
|
29
|
+
* computes token counts, costs, or any other domain-specific estimate
|
|
30
|
+
* itself — the one exception is the plain arithmetic sum of the segment
|
|
31
|
+
* values used to build the accessible "X of Y used" summary below.
|
|
32
|
+
*
|
|
33
|
+
* @customElement lyra-context-meter
|
|
34
|
+
* @csspart base - The component's root wrapper (a `<div>` for `bar`, an `<svg>` for `ring`).
|
|
35
|
+
* @csspart track - The unfilled/empty capacity track.
|
|
36
|
+
* @csspart segment - One occupied segment. Carries `data-tone` for styling.
|
|
37
|
+
* @csspart label - The visible caption, when `label` is set.
|
|
38
|
+
*/
|
|
39
|
+
export class LyraContextMeter extends LyraElement {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
/** Occupied segments, each an absolute quantity against `total` — never a percentage. */
|
|
43
|
+
this.segments = [];
|
|
44
|
+
/** The full capacity segments are measured against (e.g. a model's context window size). */
|
|
45
|
+
this.total = 0;
|
|
46
|
+
this.variant = 'bar';
|
|
47
|
+
/** Overall accessible label/caption, e.g. `"128K context window"`. */
|
|
48
|
+
this.label = '';
|
|
49
|
+
}
|
|
50
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
51
|
+
/** Sum of segment values, clamped so a negative/NaN entry can't produce a negative total. */
|
|
52
|
+
get usedTotal() {
|
|
53
|
+
return this.segments.reduce((sum, s) => sum + (Number.isFinite(s.value) ? Math.max(0, s.value) : 0), 0);
|
|
54
|
+
}
|
|
55
|
+
/** Per-segment ratio of `value` to `total`, clamped to [0,1] and capped so the
|
|
56
|
+
* running sum across all segments never overflows past 1 — a `segments` array
|
|
57
|
+
* that sums to more than `total` still renders a fully (not over-) filled meter. */
|
|
58
|
+
ratios() {
|
|
59
|
+
const total = Number.isFinite(this.total) ? this.total : 0;
|
|
60
|
+
if (total <= 0)
|
|
61
|
+
return [];
|
|
62
|
+
const out = [];
|
|
63
|
+
let cumulative = 0;
|
|
64
|
+
for (const segment of this.segments) {
|
|
65
|
+
const raw = Number.isFinite(segment.value) ? Math.max(0, segment.value) : 0;
|
|
66
|
+
const available = Math.max(0, 1 - cumulative);
|
|
67
|
+
const ratio = Math.min(raw / total, available);
|
|
68
|
+
cumulative += ratio;
|
|
69
|
+
out.push({ segment, ratio });
|
|
70
|
+
}
|
|
71
|
+
return out;
|
|
72
|
+
}
|
|
73
|
+
get summary() {
|
|
74
|
+
const used = formatCount(this.usedTotal);
|
|
75
|
+
const total = Number.isFinite(this.total) && this.total > 0 ? formatCount(this.total) : null;
|
|
76
|
+
const phrase = total ? `${used} of ${total} used` : `${used} used`;
|
|
77
|
+
return this.label ? `${this.label} — ${phrase}` : phrase;
|
|
78
|
+
}
|
|
79
|
+
willUpdate() {
|
|
80
|
+
// role="img" + aria-label (rather than exposing the SVG/bar internals to
|
|
81
|
+
// the accessibility tree) mirrors lyra-gauge's "meter" role convention:
|
|
82
|
+
// one computed string carries the whole occupancy summary, so a screen
|
|
83
|
+
// reader gets meaningful text instead of silence or a bare "graphic".
|
|
84
|
+
this.setAttribute('role', 'img');
|
|
85
|
+
this.setAttribute('aria-label', this.summary);
|
|
86
|
+
}
|
|
87
|
+
renderBar() {
|
|
88
|
+
const ratios = this.ratios();
|
|
89
|
+
return html `
|
|
90
|
+
<div part="base">
|
|
91
|
+
${this.label ? html `<div part="label" aria-hidden="true">${this.label}</div>` : nothing}
|
|
92
|
+
<div part="track" aria-hidden="true">
|
|
93
|
+
${ratios.map(({ segment, ratio }) => html `
|
|
94
|
+
<span
|
|
95
|
+
part="segment"
|
|
96
|
+
data-tone=${segment.tone ?? 'neutral'}
|
|
97
|
+
title=${`${segment.label}: ${formatCount(segment.value)}`}
|
|
98
|
+
style=${styleMap({ flexBasis: `${(ratio * 100).toFixed(4)}%` })}
|
|
99
|
+
></span>
|
|
100
|
+
`)}
|
|
101
|
+
</div>
|
|
102
|
+
</div>
|
|
103
|
+
`;
|
|
104
|
+
}
|
|
105
|
+
renderRing() {
|
|
106
|
+
const ratios = this.ratios();
|
|
107
|
+
let cumulative = 0;
|
|
108
|
+
const arcs = ratios.map(({ segment, ratio }) => {
|
|
109
|
+
const segLen = ratio * CIRCUMFERENCE;
|
|
110
|
+
const dashoffset = -cumulative * CIRCUMFERENCE;
|
|
111
|
+
cumulative += ratio;
|
|
112
|
+
return svg `
|
|
113
|
+
<circle
|
|
114
|
+
part="segment"
|
|
115
|
+
data-tone=${segment.tone ?? 'neutral'}
|
|
116
|
+
cx=${CENTER}
|
|
117
|
+
cy=${CENTER}
|
|
118
|
+
r=${RADIUS}
|
|
119
|
+
stroke-width=${STROKE}
|
|
120
|
+
stroke-dasharray=${`${segLen} ${CIRCUMFERENCE - segLen}`}
|
|
121
|
+
stroke-dashoffset=${dashoffset}
|
|
122
|
+
transform="rotate(-90 ${CENTER} ${CENTER})"
|
|
123
|
+
><title>${`${segment.label}: ${formatCount(segment.value)}`}</title></circle>
|
|
124
|
+
`;
|
|
125
|
+
});
|
|
126
|
+
return html `
|
|
127
|
+
<svg part="base" viewBox="0 0 100 100" aria-hidden="true">
|
|
128
|
+
<circle part="track" cx=${CENTER} cy=${CENTER} r=${RADIUS} stroke-width=${STROKE}></circle>
|
|
129
|
+
${arcs}
|
|
130
|
+
${this.label ? svg `<text part="label" x=${CENTER} y=${CENTER + 4} aria-hidden="true">${this.label}</text>` : nothing}
|
|
131
|
+
</svg>
|
|
132
|
+
`;
|
|
133
|
+
}
|
|
134
|
+
render() {
|
|
135
|
+
return this.variant === 'ring' ? this.renderRing() : this.renderBar();
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
__decorate([
|
|
139
|
+
property({ attribute: false })
|
|
140
|
+
], LyraContextMeter.prototype, "segments", void 0);
|
|
141
|
+
__decorate([
|
|
142
|
+
property({ type: Number })
|
|
143
|
+
], LyraContextMeter.prototype, "total", void 0);
|
|
144
|
+
__decorate([
|
|
145
|
+
property({ reflect: true })
|
|
146
|
+
], LyraContextMeter.prototype, "variant", void 0);
|
|
147
|
+
__decorate([
|
|
148
|
+
property()
|
|
149
|
+
], LyraContextMeter.prototype, "label", void 0);
|
|
150
|
+
defineElement('context-meter', LyraContextMeter);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|