@aceshooting/lyra-ui 1.1.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -1
- package/custom-elements.json +21460 -8489
- package/dist/components/app-rail/app-rail.d.ts +171 -0
- package/dist/components/app-rail/app-rail.js +483 -0
- package/dist/components/app-rail/app-rail.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail.styles.js +125 -0
- package/dist/components/attachment-chip/attachment-chip.d.ts +114 -0
- package/dist/components/attachment-chip/attachment-chip.js +312 -0
- package/dist/components/attachment-chip/attachment-chip.styles.d.ts +1 -0
- package/dist/components/attachment-chip/attachment-chip.styles.js +184 -0
- package/dist/components/attachment-trigger/attachment-trigger.d.ts +83 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +258 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.d.ts +1 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +68 -0
- package/dist/components/chart/box-plot.js +11 -1
- package/dist/components/chart/chart-loader.d.ts +44 -13
- package/dist/components/chart/chart-loader.js +65 -18
- package/dist/components/chart/chart.d.ts +12 -2
- package/dist/components/chart/chart.js +121 -14
- package/dist/components/chart/histogram-bin.d.ts +4 -1
- package/dist/components/chart/histogram-bin.js +24 -14
- package/dist/components/chart/lite-chart.d.ts +63 -0
- package/dist/components/chart/lite-chart.js +181 -23
- package/dist/components/chart/lite-chart.styles.js +9 -0
- package/dist/components/chat-composer/chat-composer.d.ts +92 -0
- package/dist/components/chat-composer/chat-composer.js +285 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +1 -0
- package/dist/components/chat-composer/chat-composer.styles.js +135 -0
- package/dist/components/chat-message/chat-message.d.ts +113 -0
- package/dist/components/chat-message/chat-message.js +291 -0
- package/dist/components/chat-message/chat-message.styles.d.ts +1 -0
- package/dist/components/chat-message/chat-message.styles.js +203 -0
- package/dist/components/checkbox/checkbox.d.ts +59 -0
- package/dist/components/checkbox/checkbox.js +230 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.styles.js +70 -0
- package/dist/components/chip/chip-group.d.ts +56 -0
- package/dist/components/chip/chip-group.js +124 -0
- package/dist/components/chip/chip-group.styles.d.ts +1 -0
- package/dist/components/chip/chip-group.styles.js +57 -0
- package/dist/components/chip/chip.d.ts +64 -0
- package/dist/components/chip/chip.js +115 -0
- package/dist/components/chip/chip.styles.d.ts +1 -0
- package/dist/components/chip/chip.styles.js +115 -0
- package/dist/components/citation-badge/citation-badge.d.ts +113 -0
- package/dist/components/citation-badge/citation-badge.js +300 -0
- package/dist/components/citation-badge/citation-badge.styles.d.ts +1 -0
- package/dist/components/citation-badge/citation-badge.styles.js +96 -0
- package/dist/components/code-block/code-block.d.ts +89 -0
- package/dist/components/code-block/code-block.js +317 -0
- package/dist/components/code-block/code-block.styles.d.ts +1 -0
- package/dist/components/code-block/code-block.styles.js +187 -0
- package/dist/components/code-block/code-loader.d.ts +44 -0
- package/dist/components/code-block/code-loader.js +79 -0
- package/dist/components/combobox/combobox.d.ts +19 -1
- package/dist/components/combobox/combobox.js +84 -14
- package/dist/components/combobox/option.d.ts +5 -1
- package/dist/components/combobox/option.js +35 -0
- package/dist/components/context-meter/context-meter.d.ts +53 -0
- package/dist/components/context-meter/context-meter.js +150 -0
- package/dist/components/context-meter/context-meter.styles.d.ts +1 -0
- package/dist/components/context-meter/context-meter.styles.js +120 -0
- package/dist/components/conversation-item/conversation-item.d.ts +128 -0
- package/dist/components/conversation-item/conversation-item.js +322 -0
- package/dist/components/conversation-item/conversation-item.styles.d.ts +1 -0
- package/dist/components/conversation-item/conversation-item.styles.js +155 -0
- package/dist/components/date-picker/date-input.d.ts +24 -0
- package/dist/components/date-picker/date-input.js +134 -22
- package/dist/components/date-picker/date-picker.d.ts +7 -0
- package/dist/components/date-picker/date-picker.js +85 -16
- package/dist/components/dialog/confirm.d.ts +40 -0
- package/dist/components/dialog/confirm.js +79 -0
- package/dist/components/dialog/dialog.d.ts +85 -0
- package/dist/components/dialog/dialog.js +272 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +52 -0
- package/dist/components/dock-panel/dock-panel.d.ts +134 -0
- package/dist/components/dock-panel/dock-panel.js +345 -0
- package/dist/components/dock-panel/dock-panel.styles.d.ts +1 -0
- package/dist/components/dock-panel/dock-panel.styles.js +145 -0
- package/dist/components/document-preview/document-preview.d.ts +135 -0
- package/dist/components/document-preview/document-preview.js +372 -0
- package/dist/components/document-preview/document-preview.styles.d.ts +1 -0
- package/dist/components/document-preview/document-preview.styles.js +191 -0
- package/dist/components/export-button/csv.js +1 -1
- package/dist/components/export-button/export-button.js +2 -0
- package/dist/components/flag/flag.d.ts +42 -5
- package/dist/components/flag/flag.js +70 -3
- package/dist/components/gauge/gauge.js +19 -10
- package/dist/components/generation-status/generation-status.d.ts +109 -0
- package/dist/components/generation-status/generation-status.js +273 -0
- package/dist/components/generation-status/generation-status.styles.d.ts +1 -0
- package/dist/components/generation-status/generation-status.styles.js +84 -0
- package/dist/components/heatmap/calendar-grid.d.ts +4 -1
- package/dist/components/heatmap/calendar-grid.js +25 -12
- package/dist/components/heatmap/heatmap-scale.d.ts +6 -0
- package/dist/components/heatmap/heatmap-scale.js +7 -1
- package/dist/components/heatmap/heatmap.d.ts +89 -3
- package/dist/components/heatmap/heatmap.js +158 -29
- package/dist/components/json-viewer/json-viewer.d.ts +53 -0
- package/dist/components/json-viewer/json-viewer.js +283 -0
- package/dist/components/json-viewer/json-viewer.styles.d.ts +1 -0
- package/dist/components/json-viewer/json-viewer.styles.js +176 -0
- package/dist/components/kbd/kbd.d.ts +77 -0
- package/dist/components/kbd/kbd.js +214 -0
- package/dist/components/kbd/kbd.styles.d.ts +1 -0
- package/dist/components/kbd/kbd.styles.js +52 -0
- package/dist/components/live-region/live-region.d.ts +81 -0
- package/dist/components/live-region/live-region.js +153 -0
- package/dist/components/live-region/live-region.styles.d.ts +1 -0
- package/dist/components/live-region/live-region.styles.js +10 -0
- package/dist/components/map/map.d.ts +8 -6
- package/dist/components/map/map.js +44 -8
- package/dist/components/markdown/markdown-loader.d.ts +34 -0
- package/dist/components/markdown/markdown-loader.js +43 -0
- package/dist/components/markdown/markdown.d.ts +81 -0
- package/dist/components/markdown/markdown.js +284 -0
- package/dist/components/markdown/markdown.styles.d.ts +1 -0
- package/dist/components/markdown/markdown.styles.js +82 -0
- package/dist/components/media-card/media-card.d.ts +122 -0
- package/dist/components/media-card/media-card.js +295 -0
- package/dist/components/media-card/media-card.styles.d.ts +1 -0
- package/dist/components/media-card/media-card.styles.js +132 -0
- package/dist/components/mention-popover/mention-popover.d.ts +200 -0
- package/dist/components/mention-popover/mention-popover.js +475 -0
- package/dist/components/mention-popover/mention-popover.styles.d.ts +1 -0
- package/dist/components/mention-popover/mention-popover.styles.js +101 -0
- package/dist/components/menu/menu-item.d.ts +62 -0
- package/dist/components/menu/menu-item.js +119 -0
- package/dist/components/menu/menu-item.styles.d.ts +1 -0
- package/dist/components/menu/menu-item.styles.js +67 -0
- package/dist/components/menu/menu.d.ts +143 -0
- package/dist/components/menu/menu.js +365 -0
- package/dist/components/menu/menu.styles.d.ts +1 -0
- package/dist/components/menu/menu.styles.js +66 -0
- package/dist/components/model-select/model-select.d.ts +125 -0
- package/dist/components/model-select/model-select.js +490 -0
- package/dist/components/model-select/model-select.styles.d.ts +1 -0
- package/dist/components/model-select/model-select.styles.js +189 -0
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +69 -0
- package/dist/components/model-settings-panel/model-settings-panel.js +145 -0
- package/dist/components/model-settings-panel/model-settings-panel.styles.d.ts +1 -0
- package/dist/components/model-settings-panel/model-settings-panel.styles.js +82 -0
- package/dist/components/playback/playback.d.ts +13 -1
- package/dist/components/playback/playback.js +47 -14
- package/dist/components/responsive-panel/responsive-panel.d.ts +150 -0
- package/dist/components/responsive-panel/responsive-panel.js +365 -0
- package/dist/components/responsive-panel/responsive-panel.styles.d.ts +1 -0
- package/dist/components/responsive-panel/responsive-panel.styles.js +103 -0
- package/dist/components/result-card/result-card.d.ts +44 -0
- package/dist/components/result-card/result-card.js +83 -0
- package/dist/components/result-card/result-card.styles.d.ts +1 -0
- package/dist/components/result-card/result-card.styles.js +50 -0
- package/dist/components/result-card/result-field.d.ts +36 -0
- package/dist/components/result-card/result-field.js +87 -0
- package/dist/components/result-card/result-field.styles.d.ts +1 -0
- package/dist/components/result-card/result-field.styles.js +32 -0
- package/dist/components/select/select.d.ts +45 -1
- package/dist/components/select/select.js +114 -17
- package/dist/components/select/select.styles.js +26 -2
- package/dist/components/slider/slider.d.ts +89 -0
- package/dist/components/slider/slider.js +352 -0
- package/dist/components/slider/slider.styles.d.ts +1 -0
- package/dist/components/slider/slider.styles.js +87 -0
- package/dist/components/source-card/source-card.d.ts +92 -0
- package/dist/components/source-card/source-card.js +148 -0
- package/dist/components/source-card/source-card.styles.d.ts +1 -0
- package/dist/components/source-card/source-card.styles.js +69 -0
- package/dist/components/source-list/source-list.d.ts +63 -0
- package/dist/components/source-list/source-list.js +122 -0
- package/dist/components/source-list/source-list.styles.d.ts +1 -0
- package/dist/components/source-list/source-list.styles.js +59 -0
- package/dist/components/sparkline/sparkline.js +27 -13
- package/dist/components/split/split.d.ts +93 -1
- package/dist/components/split/split.js +284 -15
- package/dist/components/split/split.styles.js +30 -0
- package/dist/components/stat/stat.d.ts +22 -1
- package/dist/components/stat/stat.js +49 -3
- package/dist/components/stat/stat.styles.js +20 -0
- package/dist/components/stream-status/stream-status.d.ts +110 -0
- package/dist/components/stream-status/stream-status.js +210 -0
- package/dist/components/stream-status/stream-status.styles.d.ts +1 -0
- package/dist/components/stream-status/stream-status.styles.js +103 -0
- package/dist/components/streaming-text/streaming-text.d.ts +98 -0
- package/dist/components/streaming-text/streaming-text.js +209 -0
- package/dist/components/streaming-text/streaming-text.styles.d.ts +1 -0
- package/dist/components/streaming-text/streaming-text.styles.js +62 -0
- package/dist/components/switch/switch.d.ts +58 -0
- package/dist/components/switch/switch.js +179 -0
- package/dist/components/switch/switch.styles.d.ts +1 -0
- package/dist/components/switch/switch.styles.js +75 -0
- package/dist/components/table/table.d.ts +73 -4
- package/dist/components/table/table.js +169 -20
- package/dist/components/table/table.styles.js +6 -1
- package/dist/components/tabs/tabs.d.ts +51 -0
- package/dist/components/tabs/tabs.js +190 -0
- package/dist/components/tabs/tabs.styles.d.ts +1 -0
- package/dist/components/tabs/tabs.styles.js +63 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +121 -0
- package/dist/components/thinking-panel/thinking-panel.js +235 -0
- package/dist/components/thinking-panel/thinking-panel.styles.d.ts +1 -0
- package/dist/components/thinking-panel/thinking-panel.styles.js +117 -0
- package/dist/components/toast/toast-item.d.ts +1 -0
- package/dist/components/toast/toast-item.js +31 -6
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +130 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +403 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.d.ts +1 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.js +160 -0
- package/dist/components/tool-call-chip/tool-call-chip.d.ts +89 -0
- package/dist/components/tool-call-chip/tool-call-chip.js +288 -0
- package/dist/components/tool-call-chip/tool-call-chip.styles.d.ts +1 -0
- package/dist/components/tool-call-chip/tool-call-chip.styles.js +203 -0
- package/dist/components/tool-param-form/tool-param-form.d.ts +145 -0
- package/dist/components/tool-param-form/tool-param-form.js +366 -0
- package/dist/components/tool-param-form/tool-param-form.styles.d.ts +1 -0
- package/dist/components/tool-param-form/tool-param-form.styles.js +75 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.d.ts +102 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.js +393 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.d.ts +1 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.js +176 -0
- package/dist/components/tool-result-view/registry.d.ts +81 -0
- package/dist/components/tool-result-view/registry.js +84 -0
- package/dist/components/tool-result-view/tool-result-view.d.ts +55 -0
- package/dist/components/tool-result-view/tool-result-view.js +138 -0
- package/dist/components/tool-result-view/tool-result-view.styles.d.ts +1 -0
- package/dist/components/tool-result-view/tool-result-view.styles.js +13 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.d.ts +151 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.js +439 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.d.ts +1 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.js +182 -0
- package/dist/components/tree/tree-node.d.ts +11 -2
- package/dist/components/tree/tree-node.js +16 -6
- package/dist/components/tree/tree.d.ts +8 -2
- package/dist/components/tree/tree.js +18 -11
- package/dist/components/typing-indicator/typing-indicator.d.ts +60 -0
- package/dist/components/typing-indicator/typing-indicator.js +96 -0
- package/dist/components/typing-indicator/typing-indicator.styles.d.ts +1 -0
- package/dist/components/typing-indicator/typing-indicator.styles.js +132 -0
- package/dist/components/virtual-list/virtual-list.d.ts +173 -0
- package/dist/components/virtual-list/virtual-list.js +461 -0
- package/dist/components/virtual-list/virtual-list.styles.d.ts +1 -0
- package/dist/components/virtual-list/virtual-list.styles.js +44 -0
- package/dist/components/widget/widget.d.ts +10 -0
- package/dist/components/widget/widget.js +24 -1
- package/dist/components/widget/widget.styles.js +9 -2
- package/dist/components/word-cloud/word-cloud-layout.js +14 -1
- package/dist/components/word-cloud/word-cloud.d.ts +6 -0
- package/dist/components/word-cloud/word-cloud.js +25 -14
- package/dist/components/word-cloud/word-cloud.styles.js +4 -2
- package/dist/internal/announcer.d.ts +57 -0
- package/dist/internal/announcer.js +71 -0
- package/dist/internal/form-associated.d.ts +1 -0
- package/dist/internal/form-associated.js +55 -11
- package/dist/internal/group-by-recency.d.ts +50 -0
- package/dist/internal/group-by-recency.js +80 -0
- package/dist/internal/rtl.d.ts +23 -0
- package/dist/internal/rtl.js +28 -0
- package/dist/internal/scroll-lock.d.ts +10 -5
- package/dist/internal/scroll-lock.js +30 -14
- package/dist/internal/tokens.styles.js +6 -0
- package/dist/lyra.d.ts +130 -31
- package/dist/lyra.js +94 -26
- package/llms-full.txt +3921 -32
- package/llms.txt +16 -1
- package/package.json +23 -5
- package/dist/components/chart/bar-chart.stories.d.ts +0 -5
- package/dist/components/chart/bar-chart.stories.js +0 -20
- package/dist/components/chart/box-plot.stories.d.ts +0 -5
- package/dist/components/chart/box-plot.stories.js +0 -29
- package/dist/components/chart/bubble-chart.stories.d.ts +0 -5
- package/dist/components/chart/bubble-chart.stories.js +0 -26
- package/dist/components/chart/chart.stories.d.ts +0 -32
- package/dist/components/chart/chart.stories.js +0 -141
- package/dist/components/chart/doughnut-chart.stories.d.ts +0 -5
- package/dist/components/chart/doughnut-chart.stories.js +0 -26
- package/dist/components/chart/histogram.stories.d.ts +0 -5
- package/dist/components/chart/histogram.stories.js +0 -17
- package/dist/components/chart/line-chart.stories.d.ts +0 -22
- package/dist/components/chart/line-chart.stories.js +0 -99
- package/dist/components/chart/lite-chart.stories.d.ts +0 -12
- package/dist/components/chart/lite-chart.stories.js +0 -98
- package/dist/components/chart/pie-chart.stories.d.ts +0 -5
- package/dist/components/chart/pie-chart.stories.js +0 -26
- package/dist/components/chart/polar-area-chart.stories.d.ts +0 -5
- package/dist/components/chart/polar-area-chart.stories.js +0 -20
- package/dist/components/chart/radar-chart.stories.d.ts +0 -5
- package/dist/components/chart/radar-chart.stories.js +0 -20
- package/dist/components/chart/scatter-chart.stories.d.ts +0 -5
- package/dist/components/chart/scatter-chart.stories.js +0 -31
- package/dist/components/combobox/combobox.stories.d.ts +0 -24
- package/dist/components/combobox/combobox.stories.js +0 -102
- package/dist/components/date-picker/date-input.stories.d.ts +0 -10
- package/dist/components/date-picker/date-input.stories.js +0 -48
- package/dist/components/date-picker/date-picker.stories.d.ts +0 -10
- package/dist/components/date-picker/date-picker.stories.js +0 -25
- package/dist/components/empty/empty.stories.d.ts +0 -7
- package/dist/components/empty/empty.stories.js +0 -34
- package/dist/components/export-button/export-button.stories.d.ts +0 -7
- package/dist/components/export-button/export-button.stories.js +0 -37
- package/dist/components/file-input/file-input.stories.d.ts +0 -7
- package/dist/components/file-input/file-input.stories.js +0 -19
- package/dist/components/flag/flag.stories.d.ts +0 -5
- package/dist/components/flag/flag.stories.js +0 -17
- package/dist/components/gauge/gauge.stories.d.ts +0 -8
- package/dist/components/gauge/gauge.stories.js +0 -19
- package/dist/components/graph/graph.stories.d.ts +0 -8
- package/dist/components/graph/graph.stories.js +0 -68
- package/dist/components/heatmap/heatmap.stories.d.ts +0 -22
- package/dist/components/heatmap/heatmap.stories.js +0 -154
- package/dist/components/map/map.stories.d.ts +0 -15
- package/dist/components/map/map.stories.js +0 -135
- package/dist/components/playback/playback.stories.d.ts +0 -7
- package/dist/components/playback/playback.stories.js +0 -16
- package/dist/components/select/select.stories.d.ts +0 -19
- package/dist/components/select/select.stories.js +0 -75
- package/dist/components/skeleton/skeleton.stories.d.ts +0 -5
- package/dist/components/skeleton/skeleton.stories.js +0 -16
- package/dist/components/sparkline/sparkline.stories.d.ts +0 -11
- package/dist/components/sparkline/sparkline.stories.js +0 -39
- package/dist/components/split/split.stories.d.ts +0 -7
- package/dist/components/split/split.stories.js +0 -36
- package/dist/components/stat/stat.stories.d.ts +0 -8
- package/dist/components/stat/stat.stories.js +0 -64
- package/dist/components/table/table.stories.d.ts +0 -12
- package/dist/components/table/table.stories.js +0 -67
- package/dist/components/time-range/time-range.stories.d.ts +0 -8
- package/dist/components/time-range/time-range.stories.js +0 -26
- package/dist/components/toast/toast.stories.d.ts +0 -8
- package/dist/components/toast/toast.stories.js +0 -72
- package/dist/components/tree/tree.stories.d.ts +0 -9
- package/dist/components/tree/tree.stories.js +0 -52
- package/dist/components/widget/widget.stories.d.ts +0 -7
- package/dist/components/widget/widget.stories.js +0 -41
- package/dist/components/word-cloud/word-cloud.stories.d.ts +0 -10
- package/dist/components/word-cloud/word-cloud.stories.js +0 -55
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { type TemplateResult } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-result-field>` — a single label/value row, meant for use inside a
|
|
5
|
+
* `<lyra-result-card>` body (though it works standalone too). Renders as a
|
|
6
|
+
* dense "label: value" line by default — e.g. "Status: 200 OK" or
|
|
7
|
+
* "Duration: 340ms" — matching the compact, small-card presentation this
|
|
8
|
+
* pair exists for.
|
|
9
|
+
*
|
|
10
|
+
* @customElement lyra-result-field
|
|
11
|
+
* @slot - Rich value content (e.g. a `<lyra-chip>` status badge, or a plain
|
|
12
|
+
* text override), taking precedence over the `value` prop whenever it has
|
|
13
|
+
* any assigned content.
|
|
14
|
+
* @csspart base - The row container.
|
|
15
|
+
* @csspart label - The label text (including its trailing colon).
|
|
16
|
+
* @csspart value - The wrapper around the value — either the slotted
|
|
17
|
+
* content or the plain `value` prop text.
|
|
18
|
+
*/
|
|
19
|
+
export declare class LyraResultField extends LyraElement {
|
|
20
|
+
static styles: import("lit").CSSResultGroup[];
|
|
21
|
+
/** The field name, e.g. "Status". Leave unset to render a value with no label. */
|
|
22
|
+
label: string;
|
|
23
|
+
/** Plain-text value, e.g. "200 OK". Ignored once the default slot carries
|
|
24
|
+
* real content — see the `@slot` doc. */
|
|
25
|
+
value: string;
|
|
26
|
+
private hasValueSlot;
|
|
27
|
+
protected willUpdate(): void;
|
|
28
|
+
firstUpdated(): void;
|
|
29
|
+
private onSlotChange;
|
|
30
|
+
render(): TemplateResult;
|
|
31
|
+
}
|
|
32
|
+
declare global {
|
|
33
|
+
interface HTMLElementTagNameMap {
|
|
34
|
+
'lyra-result-field': LyraResultField;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html, nothing } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
11
|
+
import { styles } from './result-field.styles.js';
|
|
12
|
+
// An element always counts as real slot content, even one with no text of
|
|
13
|
+
// its own (e.g. a `<lyra-chip>` status badge whose label comes from an
|
|
14
|
+
// attribute, not slotted text) -- assignedElements()-only checks (as
|
|
15
|
+
// lyra-widget's hasActionsSlot/lyra-source-card's hasFullSlot use) would
|
|
16
|
+
// miss that case. A bare text node only counts once trimmed of whitespace,
|
|
17
|
+
// matching lyra-checkbox's hasLabelSlot. Together this catches both a
|
|
18
|
+
// plain-text value override (`<lyra-result-field label="Status">200 OK`)
|
|
19
|
+
// and a rich slotted badge.
|
|
20
|
+
function hasRealContent(nodes) {
|
|
21
|
+
return nodes.some((n) => n.nodeType === Node.ELEMENT_NODE || (n.textContent ?? '').trim().length > 0);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* `<lyra-result-field>` — a single label/value row, meant for use inside a
|
|
25
|
+
* `<lyra-result-card>` body (though it works standalone too). Renders as a
|
|
26
|
+
* dense "label: value" line by default — e.g. "Status: 200 OK" or
|
|
27
|
+
* "Duration: 340ms" — matching the compact, small-card presentation this
|
|
28
|
+
* pair exists for.
|
|
29
|
+
*
|
|
30
|
+
* @customElement lyra-result-field
|
|
31
|
+
* @slot - Rich value content (e.g. a `<lyra-chip>` status badge, or a plain
|
|
32
|
+
* text override), taking precedence over the `value` prop whenever it has
|
|
33
|
+
* any assigned content.
|
|
34
|
+
* @csspart base - The row container.
|
|
35
|
+
* @csspart label - The label text (including its trailing colon).
|
|
36
|
+
* @csspart value - The wrapper around the value — either the slotted
|
|
37
|
+
* content or the plain `value` prop text.
|
|
38
|
+
*/
|
|
39
|
+
export class LyraResultField extends LyraElement {
|
|
40
|
+
constructor() {
|
|
41
|
+
super(...arguments);
|
|
42
|
+
/** The field name, e.g. "Status". Leave unset to render a value with no label. */
|
|
43
|
+
this.label = '';
|
|
44
|
+
/** Plain-text value, e.g. "200 OK". Ignored once the default slot carries
|
|
45
|
+
* real content — see the `@slot` doc. */
|
|
46
|
+
this.value = '';
|
|
47
|
+
this.hasValueSlot = false;
|
|
48
|
+
this.onSlotChange = (e) => {
|
|
49
|
+
this.hasValueSlot = hasRealContent(e.target.assignedNodes({ flatten: true }));
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
53
|
+
willUpdate() {
|
|
54
|
+
if (!this.hasUpdated) {
|
|
55
|
+
this.hasValueSlot = hasRealContent(Array.from(this.childNodes));
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
firstUpdated() {
|
|
59
|
+
// Fallback reconciliation against the fully-resolved slot assignment,
|
|
60
|
+
// the same belt-and-suspenders pass lyra-source-card's hasFullSlot and
|
|
61
|
+
// lyra-empty's hasIcon/hasActions take -- a no-op in the common case
|
|
62
|
+
// since willUpdate already seeded the correct value above.
|
|
63
|
+
const slot = this.shadowRoot.querySelector('slot');
|
|
64
|
+
this.hasValueSlot = hasRealContent(slot.assignedNodes({ flatten: true }));
|
|
65
|
+
}
|
|
66
|
+
render() {
|
|
67
|
+
const hasLabel = this.label.length > 0;
|
|
68
|
+
return html `
|
|
69
|
+
<div part="base">
|
|
70
|
+
${hasLabel ? html `<span part="label">${this.label}:</span>` : nothing}
|
|
71
|
+
<span part="value"
|
|
72
|
+
>${this.hasValueSlot ? nothing : this.value}<slot @slotchange=${this.onSlotChange}></slot
|
|
73
|
+
></span>
|
|
74
|
+
</div>
|
|
75
|
+
`;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
__decorate([
|
|
79
|
+
property()
|
|
80
|
+
], LyraResultField.prototype, "label", void 0);
|
|
81
|
+
__decorate([
|
|
82
|
+
property()
|
|
83
|
+
], LyraResultField.prototype, "value", void 0);
|
|
84
|
+
__decorate([
|
|
85
|
+
state()
|
|
86
|
+
], LyraResultField.prototype, "hasValueSlot", void 0);
|
|
87
|
+
defineElement('result-field', LyraResultField);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
}
|
|
6
|
+
/* Dense "label: value" single-line row by default -- the compact
|
|
7
|
+
presentation short status/duration/count content (the kind this
|
|
8
|
+
component is meant for) reads best as, versus a stacked two-line
|
|
9
|
+
layout. A consumer that prefers stacked can override this from the
|
|
10
|
+
light DOM: :host { } / [part='base'] { flex-direction: column; }. */
|
|
11
|
+
[part='base'] {
|
|
12
|
+
display: flex;
|
|
13
|
+
align-items: baseline;
|
|
14
|
+
flex-wrap: wrap;
|
|
15
|
+
column-gap: var(--lyra-space-xs);
|
|
16
|
+
font-size: 0.8125rem;
|
|
17
|
+
line-height: 1.4;
|
|
18
|
+
}
|
|
19
|
+
[part='label'] {
|
|
20
|
+
flex: 0 0 auto;
|
|
21
|
+
color: var(--lyra-color-text-quiet);
|
|
22
|
+
}
|
|
23
|
+
[part='value'] {
|
|
24
|
+
flex: 1 1 auto;
|
|
25
|
+
min-inline-size: 0;
|
|
26
|
+
color: var(--lyra-color-text);
|
|
27
|
+
overflow-wrap: anywhere;
|
|
28
|
+
}
|
|
29
|
+
[part='value'] ::slotted(*) {
|
|
30
|
+
vertical-align: middle;
|
|
31
|
+
}
|
|
32
|
+
`;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
2
|
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
3
|
import '../combobox/option.js';
|
|
4
|
+
export type LyraSelectSize = 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
4
5
|
/**
|
|
5
6
|
* `<lyra-select>` — a plain closed-list dropdown: a direct `<lyra-*>`
|
|
6
7
|
* counterpart to `<wa-select>`/`<wa-option>`. Trigger is a button (not a text
|
|
@@ -20,6 +21,17 @@ import '../combobox/option.js';
|
|
|
20
21
|
* "active" row is conveyed via `aria-activedescendant`, never actual focus),
|
|
21
22
|
* matching the WAI-ARIA "select-only combobox" pattern.
|
|
22
23
|
*
|
|
24
|
+
* When exactly one option is enabled (regardless of how many disabled ones
|
|
25
|
+
* exist alongside it), the popup never opens at all: a click, Enter, Space,
|
|
26
|
+
* ArrowDown, or ArrowUp on the trigger commits that sole option directly,
|
|
27
|
+
* and the trigger renders as a plain `role="button"` with no chevron/
|
|
28
|
+
* `aria-haspopup`/`aria-expanded` rather than a combobox with a permanently
|
|
29
|
+
* inert popup state — opening a one-row list to pick the only available
|
|
30
|
+
* choice is pure friction with no real decision behind it. This never
|
|
31
|
+
* changes `value`/validity defaults on its own — an unselected single-option
|
|
32
|
+
* select stays unselected (and a `required` one stays invalid) exactly like
|
|
33
|
+
* the multi-option case, until the trigger is actually activated.
|
|
34
|
+
*
|
|
23
35
|
* @customElement lyra-select
|
|
24
36
|
* @slot - `<lyra-option>` elements.
|
|
25
37
|
* @slot label - Custom label content.
|
|
@@ -49,15 +61,20 @@ export declare class LyraSelect extends LyraElement {
|
|
|
49
61
|
value: {
|
|
50
62
|
noAccessor: boolean;
|
|
51
63
|
};
|
|
64
|
+
name: {
|
|
65
|
+
reflect: boolean;
|
|
66
|
+
noAccessor: boolean;
|
|
67
|
+
};
|
|
52
68
|
};
|
|
53
69
|
placeholder: string;
|
|
54
70
|
disabled: boolean;
|
|
55
71
|
required: boolean;
|
|
56
|
-
name: string;
|
|
57
72
|
label: string;
|
|
58
73
|
hint: string;
|
|
59
74
|
errorText: string;
|
|
60
75
|
open: boolean;
|
|
76
|
+
/** Visual size — same `xs`–`xl` scale as `lyra-toast-item`'s `size`. */
|
|
77
|
+
size: LyraSelectSize;
|
|
61
78
|
private activeIndex;
|
|
62
79
|
private options;
|
|
63
80
|
private touched;
|
|
@@ -65,6 +82,7 @@ export declare class LyraSelect extends LyraElement {
|
|
|
65
82
|
private hasErrorSlot;
|
|
66
83
|
private hasLabelSlot;
|
|
67
84
|
private internals;
|
|
85
|
+
private _fieldsetDisabled;
|
|
68
86
|
private listId;
|
|
69
87
|
private triggerId;
|
|
70
88
|
private cleanup?;
|
|
@@ -74,21 +92,47 @@ export declare class LyraSelect extends LyraElement {
|
|
|
74
92
|
private _defaultCaptured;
|
|
75
93
|
private typeAheadBuffer;
|
|
76
94
|
private typeAheadTimer?;
|
|
95
|
+
private _name;
|
|
77
96
|
constructor();
|
|
78
97
|
connectedCallback(): void;
|
|
79
98
|
protected willUpdate(): void;
|
|
99
|
+
get name(): string;
|
|
100
|
+
set name(next: string);
|
|
80
101
|
/** The selected value: a single string (empty when nothing is selected). */
|
|
81
102
|
get value(): string;
|
|
82
103
|
set value(next: string);
|
|
83
104
|
private updateValidity;
|
|
84
105
|
private syncFormValue;
|
|
106
|
+
/** Effective disabled state: this element's own `disabled` OR an ancestor
|
|
107
|
+
* `<fieldset disabled>`'s inherited state -- mirrors native `<input>`, whose
|
|
108
|
+
* own `disabled` IDL property/attribute is never mutated by a fieldset. */
|
|
109
|
+
get effectiveDisabled(): boolean;
|
|
85
110
|
formResetCallback(): void;
|
|
111
|
+
/**
|
|
112
|
+
* Called by the browser when an ancestor `<fieldset disabled>` toggles.
|
|
113
|
+
* Tracked separately from the consumer's own `disabled` (see
|
|
114
|
+
* `effectiveDisabled`) so a consumer's explicit `disabled` survives the
|
|
115
|
+
* fieldset re-enabling instead of being permanently overwritten.
|
|
116
|
+
*/
|
|
86
117
|
formDisabledCallback(disabled: boolean): void;
|
|
87
118
|
checkValidity(): boolean;
|
|
88
119
|
reportValidity(): boolean;
|
|
89
120
|
disconnectedCallback(): void;
|
|
90
121
|
private collectOptions;
|
|
91
122
|
private reflectSelected;
|
|
123
|
+
/**
|
|
124
|
+
* The sole navigable (non-disabled) option, when there's exactly one. Opening a one-row
|
|
125
|
+
* popup to pick the only available choice is pure friction with no real decision behind
|
|
126
|
+
* it, so a single-option select skips the popup entirely -- see `onTriggerClick`/`onKeyDown`,
|
|
127
|
+
* which commit this option directly on activation instead of opening the listbox, and
|
|
128
|
+
* `render()`, which drops the popup-trigger ARIA semantics (`role="combobox"`,
|
|
129
|
+
* `aria-haspopup`, `aria-expanded`, the chevron) in favor of a plain button's, since no
|
|
130
|
+
* popup can ever appear while this getter returns a value. Does not affect `value`/
|
|
131
|
+
* validity defaults in any way -- an unselected single-option select stays unselected
|
|
132
|
+
* until the trigger is actually activated, exactly like the multi-option case.
|
|
133
|
+
*/
|
|
134
|
+
private get onlyOption();
|
|
135
|
+
private onOptionChange;
|
|
92
136
|
private show;
|
|
93
137
|
private hide;
|
|
94
138
|
private onDocPointer;
|
|
@@ -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';
|
|
@@ -33,6 +33,17 @@ import '../combobox/option.js';
|
|
|
33
33
|
* "active" row is conveyed via `aria-activedescendant`, never actual focus),
|
|
34
34
|
* matching the WAI-ARIA "select-only combobox" pattern.
|
|
35
35
|
*
|
|
36
|
+
* When exactly one option is enabled (regardless of how many disabled ones
|
|
37
|
+
* exist alongside it), the popup never opens at all: a click, Enter, Space,
|
|
38
|
+
* ArrowDown, or ArrowUp on the trigger commits that sole option directly,
|
|
39
|
+
* and the trigger renders as a plain `role="button"` with no chevron/
|
|
40
|
+
* `aria-haspopup`/`aria-expanded` rather than a combobox with a permanently
|
|
41
|
+
* inert popup state — opening a one-row list to pick the only available
|
|
42
|
+
* choice is pure friction with no real decision behind it. This never
|
|
43
|
+
* changes `value`/validity defaults on its own — an unselected single-option
|
|
44
|
+
* select stays unselected (and a `required` one stays invalid) exactly like
|
|
45
|
+
* the multi-option case, until the trigger is actually activated.
|
|
46
|
+
*
|
|
36
47
|
* @customElement lyra-select
|
|
37
48
|
* @slot - `<lyra-option>` elements.
|
|
38
49
|
* @slot label - Custom label content.
|
|
@@ -60,17 +71,19 @@ export class LyraSelect extends LyraElement {
|
|
|
60
71
|
static { this.styles = [LyraElement.styles, styles]; }
|
|
61
72
|
static { this.properties = {
|
|
62
73
|
value: { noAccessor: true },
|
|
74
|
+
name: { reflect: true, noAccessor: true },
|
|
63
75
|
}; }
|
|
64
76
|
constructor() {
|
|
65
77
|
super();
|
|
66
78
|
this.placeholder = '';
|
|
67
79
|
this.disabled = false;
|
|
68
80
|
this.required = false;
|
|
69
|
-
this.name = '';
|
|
70
81
|
this.label = '';
|
|
71
82
|
this.hint = '';
|
|
72
83
|
this.errorText = '';
|
|
73
84
|
this.open = false;
|
|
85
|
+
/** Visual size — same `xs`–`xl` scale as `lyra-toast-item`'s `size`. */
|
|
86
|
+
this.size = 'm';
|
|
74
87
|
this.activeIndex = -1;
|
|
75
88
|
this.options = [];
|
|
76
89
|
// Set on the trigger button's first `blur`; gates the `data-invalid`
|
|
@@ -83,6 +96,11 @@ export class LyraSelect extends LyraElement {
|
|
|
83
96
|
this.hasHintSlot = false;
|
|
84
97
|
this.hasErrorSlot = false;
|
|
85
98
|
this.hasLabelSlot = false;
|
|
99
|
+
// Tracked separately from the consumer's own `disabled` -- a native
|
|
100
|
+
// `<input>`'s own `disabled` IDL property/attribute is never mutated by
|
|
101
|
+
// fieldset cascading, so a consumer's explicit `disabled` must survive the
|
|
102
|
+
// fieldset re-enabling (see `formDisabledCallback` below).
|
|
103
|
+
this._fieldsetDisabled = false;
|
|
86
104
|
this.listId = nextId('select-list');
|
|
87
105
|
this.triggerId = nextId('select-trigger');
|
|
88
106
|
this._isFirstUpdate = true;
|
|
@@ -99,6 +117,15 @@ export class LyraSelect extends LyraElement {
|
|
|
99
117
|
// buffer and reset ~500ms after the last one, so "b" then "a" narrows to
|
|
100
118
|
// "ba" instead of restarting the search on every keystroke.
|
|
101
119
|
this.typeAheadBuffer = '';
|
|
120
|
+
// Hand-written accessor (mirrors the `value` accessor below, and Task 2's
|
|
121
|
+
// `FormAssociated.name` in `../../internal/form-associated.ts`): a
|
|
122
|
+
// form-associated custom element's submitted entry name is resolved by the
|
|
123
|
+
// browser from the live `name` *content attribute*, read synchronously at
|
|
124
|
+
// FormData-construction/submit time (see `syncFormValue()` below) -- Lit's
|
|
125
|
+
// async (microtask-deferred) `reflect: true` alone would leave a
|
|
126
|
+
// property-only assignment like `el.name = 'b'` invisible to a same-tick
|
|
127
|
+
// `new FormData(form)`/submit, so the attribute write happens here instead.
|
|
128
|
+
this._name = '';
|
|
102
129
|
this.collectOptions = (e) => {
|
|
103
130
|
const slot = e.target;
|
|
104
131
|
const previous = new Set(this.options);
|
|
@@ -135,13 +162,24 @@ export class LyraSelect extends LyraElement {
|
|
|
135
162
|
}
|
|
136
163
|
this.reflectSelected();
|
|
137
164
|
};
|
|
165
|
+
// Fired by `option.ts`'s `lyra-option-change` (a MutationObserver on the
|
|
166
|
+
// option's own light-DOM content/attributes) when an already-slotted
|
|
167
|
+
// `<lyra-option>` mutates its own data in place -- `collectOptions()` only
|
|
168
|
+
// re-runs on `slotchange`, which never fires for such a mutation, so
|
|
169
|
+
// without this the rendered listbox row would go stale. Reassigning (not
|
|
170
|
+
// mutating) `options` gives Lit a new array reference to diff against.
|
|
171
|
+
this.onOptionChange = () => {
|
|
172
|
+
this.options = [...this.options];
|
|
173
|
+
};
|
|
138
174
|
this.onDocPointer = (e) => {
|
|
139
175
|
if (!e.composedPath().includes(this))
|
|
140
176
|
this.hide();
|
|
141
177
|
};
|
|
142
178
|
this.onTriggerClick = () => {
|
|
143
|
-
if (this.
|
|
179
|
+
if (this.effectiveDisabled)
|
|
144
180
|
return;
|
|
181
|
+
if (this.onlyOption)
|
|
182
|
+
return this.selectOption(this.onlyOption);
|
|
145
183
|
this.open ? this.hide() : this.show();
|
|
146
184
|
};
|
|
147
185
|
this.onTriggerBlur = () => {
|
|
@@ -166,12 +204,16 @@ export class LyraSelect extends LyraElement {
|
|
|
166
204
|
switch (e.key) {
|
|
167
205
|
case 'ArrowDown':
|
|
168
206
|
e.preventDefault();
|
|
207
|
+
if (this.onlyOption)
|
|
208
|
+
return this.selectOption(this.onlyOption);
|
|
169
209
|
if (!this.open)
|
|
170
210
|
return this.show();
|
|
171
211
|
this.activeIndex = Math.min(navigable.length - 1, this.activeIndex + 1);
|
|
172
212
|
break;
|
|
173
213
|
case 'ArrowUp':
|
|
174
214
|
e.preventDefault();
|
|
215
|
+
if (this.onlyOption)
|
|
216
|
+
return this.selectOption(this.onlyOption);
|
|
175
217
|
if (!this.open)
|
|
176
218
|
return this.show();
|
|
177
219
|
this.activeIndex = Math.max(0, this.activeIndex - 1);
|
|
@@ -251,6 +293,20 @@ export class LyraSelect extends LyraElement {
|
|
|
251
293
|
this.hasLabelSlot = Array.from(this.children).some((el) => el.getAttribute('slot') === 'label');
|
|
252
294
|
}
|
|
253
295
|
}
|
|
296
|
+
get name() {
|
|
297
|
+
return this._name;
|
|
298
|
+
}
|
|
299
|
+
set name(next) {
|
|
300
|
+
const old = this._name;
|
|
301
|
+
this._name = next ?? '';
|
|
302
|
+
if (this._name) {
|
|
303
|
+
this.setAttribute('name', this._name);
|
|
304
|
+
}
|
|
305
|
+
else {
|
|
306
|
+
this.removeAttribute('name');
|
|
307
|
+
}
|
|
308
|
+
this.requestUpdate('name', old);
|
|
309
|
+
}
|
|
254
310
|
/** The selected value: a single string (empty when nothing is selected). */
|
|
255
311
|
get value() {
|
|
256
312
|
return this._selected;
|
|
@@ -274,11 +330,24 @@ export class LyraSelect extends LyraElement {
|
|
|
274
330
|
syncFormValue() {
|
|
275
331
|
this.internals.setFormValue(this._selected);
|
|
276
332
|
}
|
|
333
|
+
/** Effective disabled state: this element's own `disabled` OR an ancestor
|
|
334
|
+
* `<fieldset disabled>`'s inherited state -- mirrors native `<input>`, whose
|
|
335
|
+
* own `disabled` IDL property/attribute is never mutated by a fieldset. */
|
|
336
|
+
get effectiveDisabled() {
|
|
337
|
+
return this.disabled || this._fieldsetDisabled;
|
|
338
|
+
}
|
|
277
339
|
formResetCallback() {
|
|
278
340
|
this.value = this._defaultSelected;
|
|
279
341
|
}
|
|
342
|
+
/**
|
|
343
|
+
* Called by the browser when an ancestor `<fieldset disabled>` toggles.
|
|
344
|
+
* Tracked separately from the consumer's own `disabled` (see
|
|
345
|
+
* `effectiveDisabled`) so a consumer's explicit `disabled` survives the
|
|
346
|
+
* fieldset re-enabling instead of being permanently overwritten.
|
|
347
|
+
*/
|
|
280
348
|
formDisabledCallback(disabled) {
|
|
281
|
-
this.
|
|
349
|
+
this._fieldsetDisabled = disabled;
|
|
350
|
+
this.requestUpdate();
|
|
282
351
|
}
|
|
283
352
|
checkValidity() {
|
|
284
353
|
return this.internals.checkValidity();
|
|
@@ -289,15 +358,37 @@ export class LyraSelect extends LyraElement {
|
|
|
289
358
|
disconnectedCallback() {
|
|
290
359
|
super.disconnectedCallback();
|
|
291
360
|
this.cleanup?.();
|
|
361
|
+
this.cleanup = undefined;
|
|
292
362
|
clearTimeout(this.typeAheadTimer);
|
|
293
363
|
document.removeEventListener('pointerdown', this.onDocPointer);
|
|
364
|
+
// Reset so a reconnect (e.g. a drag-drop reparent) re-triggers
|
|
365
|
+
// `updated()`'s `open`-driven branch -- without this, `open` stays
|
|
366
|
+
// `true` across the disconnect/reconnect and `changed.has('open')` never
|
|
367
|
+
// fires again, leaving the listbox rendered open with no positioning and
|
|
368
|
+
// no outside-click listener.
|
|
369
|
+
this.open = false;
|
|
294
370
|
}
|
|
295
371
|
reflectSelected() {
|
|
296
372
|
for (const o of this.options)
|
|
297
373
|
o.selected = o.value === this._selected;
|
|
298
374
|
}
|
|
375
|
+
/**
|
|
376
|
+
* The sole navigable (non-disabled) option, when there's exactly one. Opening a one-row
|
|
377
|
+
* popup to pick the only available choice is pure friction with no real decision behind
|
|
378
|
+
* it, so a single-option select skips the popup entirely -- see `onTriggerClick`/`onKeyDown`,
|
|
379
|
+
* which commit this option directly on activation instead of opening the listbox, and
|
|
380
|
+
* `render()`, which drops the popup-trigger ARIA semantics (`role="combobox"`,
|
|
381
|
+
* `aria-haspopup`, `aria-expanded`, the chevron) in favor of a plain button's, since no
|
|
382
|
+
* popup can ever appear while this getter returns a value. Does not affect `value`/
|
|
383
|
+
* validity defaults in any way -- an unselected single-option select stays unselected
|
|
384
|
+
* until the trigger is actually activated, exactly like the multi-option case.
|
|
385
|
+
*/
|
|
386
|
+
get onlyOption() {
|
|
387
|
+
const navigable = this.options.filter((o) => !o.disabled);
|
|
388
|
+
return navigable.length === 1 ? navigable[0] : undefined;
|
|
389
|
+
}
|
|
299
390
|
show() {
|
|
300
|
-
if (this.open || this.
|
|
391
|
+
if (this.open || this.effectiveDisabled)
|
|
301
392
|
return;
|
|
302
393
|
this.open = true;
|
|
303
394
|
}
|
|
@@ -424,6 +515,12 @@ export class LyraSelect extends LyraElement {
|
|
|
424
515
|
const hasHint = this.hasHintSlot || this.hint.length > 0;
|
|
425
516
|
const hasError = this.hasErrorSlot || this.errorText.length > 0;
|
|
426
517
|
const hasLabel = this.hasLabelSlot || this.label.length > 0;
|
|
518
|
+
// A single navigable option has no popup to expand into -- the trigger commits it
|
|
519
|
+
// directly on activation (see onTriggerClick/onKeyDown) instead of opening the listbox,
|
|
520
|
+
// so it's exposed as a plain button rather than a combobox with a permanently-closed
|
|
521
|
+
// popup: no aria-haspopup/aria-expanded/aria-controls/aria-activedescendant (all
|
|
522
|
+
// meaningless without a popup that can ever appear) and no chevron.
|
|
523
|
+
const isSingleOption = navigable.length === 1;
|
|
427
524
|
return html `
|
|
428
525
|
<div part="form-control">
|
|
429
526
|
<label part="form-control-label" for=${this.triggerId} ?hidden=${!hasLabel}>
|
|
@@ -433,15 +530,15 @@ export class LyraSelect extends LyraElement {
|
|
|
433
530
|
id=${this.triggerId}
|
|
434
531
|
part="trigger"
|
|
435
532
|
type="button"
|
|
436
|
-
role
|
|
437
|
-
aria-haspopup
|
|
438
|
-
aria-expanded=${this.open ? 'true' : 'false'}
|
|
439
|
-
aria-controls=${this.listId}
|
|
440
|
-
aria-activedescendant=${activeId}
|
|
441
|
-
aria-label=${this.label || this.placeholder || 'Select'}
|
|
533
|
+
role=${isSingleOption ? 'button' : 'combobox'}
|
|
534
|
+
aria-haspopup=${isSingleOption ? nothing : 'listbox'}
|
|
535
|
+
aria-expanded=${isSingleOption ? nothing : this.open ? 'true' : 'false'}
|
|
536
|
+
aria-controls=${isSingleOption ? nothing : this.listId}
|
|
537
|
+
aria-activedescendant=${isSingleOption ? nothing : activeId}
|
|
538
|
+
aria-label=${this.getAttribute('aria-label') || (hasLabel ? nothing : this.placeholder || 'Select')}
|
|
442
539
|
aria-required=${this.required ? 'true' : 'false'}
|
|
443
540
|
aria-invalid=${this.touched && !this.internals.validity.valid ? 'true' : 'false'}
|
|
444
|
-
?disabled=${this.
|
|
541
|
+
?disabled=${this.effectiveDisabled}
|
|
445
542
|
@click=${this.onTriggerClick}
|
|
446
543
|
@keydown=${this.onKeyDown}
|
|
447
544
|
@blur=${this.onTriggerBlur}
|
|
@@ -449,7 +546,7 @@ export class LyraSelect extends LyraElement {
|
|
|
449
546
|
<span class="trigger-label" ?data-placeholder=${!hasValue}
|
|
450
547
|
>${hasValue ? selectedLabel : this.placeholder}</span
|
|
451
548
|
>
|
|
452
|
-
|
|
549
|
+
${isSingleOption ? nothing : html `<span part="expand-icon" aria-hidden="true">${chevronIcon()}</span>`}
|
|
453
550
|
</button>
|
|
454
551
|
<div
|
|
455
552
|
part="listbox"
|
|
@@ -467,7 +564,7 @@ export class LyraSelect extends LyraElement {
|
|
|
467
564
|
${this.hint}<slot name="hint" @slotchange=${this.onHintSlotChange}></slot>
|
|
468
565
|
</div>
|
|
469
566
|
</div>
|
|
470
|
-
<slot @slotchange=${this.collectOptions} hidden></slot>
|
|
567
|
+
<slot @slotchange=${this.collectOptions} @lyra-option-change=${this.onOptionChange} hidden></slot>
|
|
471
568
|
`;
|
|
472
569
|
}
|
|
473
570
|
}
|
|
@@ -480,9 +577,6 @@ __decorate([
|
|
|
480
577
|
__decorate([
|
|
481
578
|
property({ type: Boolean, reflect: true })
|
|
482
579
|
], LyraSelect.prototype, "required", void 0);
|
|
483
|
-
__decorate([
|
|
484
|
-
property()
|
|
485
|
-
], LyraSelect.prototype, "name", void 0);
|
|
486
580
|
__decorate([
|
|
487
581
|
property()
|
|
488
582
|
], LyraSelect.prototype, "label", void 0);
|
|
@@ -495,6 +589,9 @@ __decorate([
|
|
|
495
589
|
__decorate([
|
|
496
590
|
property({ type: Boolean, reflect: true })
|
|
497
591
|
], LyraSelect.prototype, "open", void 0);
|
|
592
|
+
__decorate([
|
|
593
|
+
property({ reflect: true })
|
|
594
|
+
], LyraSelect.prototype, "size", void 0);
|
|
498
595
|
__decorate([
|
|
499
596
|
state()
|
|
500
597
|
], LyraSelect.prototype, "activeIndex", void 0);
|
|
@@ -2,6 +2,29 @@ import { css } from 'lit';
|
|
|
2
2
|
export const styles = css `
|
|
3
3
|
:host {
|
|
4
4
|
display: block;
|
|
5
|
+
--lyra-select-trigger-padding: var(--lyra-space-xs) var(--lyra-space-s);
|
|
6
|
+
--lyra-select-trigger-min-height: 2.5rem;
|
|
7
|
+
--lyra-select-font-size: 1rem;
|
|
8
|
+
}
|
|
9
|
+
:host([size='xs']) {
|
|
10
|
+
--lyra-select-trigger-padding: 0.125rem var(--lyra-space-xs);
|
|
11
|
+
--lyra-select-trigger-min-height: 1.5rem;
|
|
12
|
+
--lyra-select-font-size: 0.75rem;
|
|
13
|
+
}
|
|
14
|
+
:host([size='s']) {
|
|
15
|
+
--lyra-select-trigger-padding: var(--lyra-space-xs) var(--lyra-space-xs);
|
|
16
|
+
--lyra-select-trigger-min-height: 1.875rem;
|
|
17
|
+
--lyra-select-font-size: 0.8125rem;
|
|
18
|
+
}
|
|
19
|
+
:host([size='l']) {
|
|
20
|
+
--lyra-select-trigger-padding: var(--lyra-space-s) var(--lyra-space-m);
|
|
21
|
+
--lyra-select-trigger-min-height: 3rem;
|
|
22
|
+
--lyra-select-font-size: 1.125rem;
|
|
23
|
+
}
|
|
24
|
+
:host([size='xl']) {
|
|
25
|
+
--lyra-select-trigger-padding: var(--lyra-space-m) var(--lyra-space-l);
|
|
26
|
+
--lyra-select-trigger-min-height: 3.5rem;
|
|
27
|
+
--lyra-select-font-size: 1.25rem;
|
|
5
28
|
}
|
|
6
29
|
[part='form-control-label'] {
|
|
7
30
|
display: block;
|
|
@@ -30,13 +53,14 @@ export const styles = css `
|
|
|
30
53
|
justify-content: space-between;
|
|
31
54
|
gap: var(--lyra-space-xs);
|
|
32
55
|
inline-size: 100%;
|
|
33
|
-
min-block-size:
|
|
34
|
-
padding: var(--lyra-
|
|
56
|
+
min-block-size: var(--lyra-select-trigger-min-height);
|
|
57
|
+
padding: var(--lyra-select-trigger-padding);
|
|
35
58
|
border: 1px solid var(--lyra-color-border);
|
|
36
59
|
border-radius: var(--lyra-radius);
|
|
37
60
|
background: var(--lyra-color-surface);
|
|
38
61
|
color: inherit;
|
|
39
62
|
font: inherit;
|
|
63
|
+
font-size: var(--lyra-select-font-size);
|
|
40
64
|
text-align: start;
|
|
41
65
|
cursor: pointer;
|
|
42
66
|
}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
declare const LyraSlider_base: typeof LyraElement & (new (...args: any[]) => import("../../internal/form-associated.js").FormAssociatedInterface);
|
|
4
|
+
/**
|
|
5
|
+
* `<lyra-slider>` — a numeric range control (e.g. an LLM "temperature"
|
|
6
|
+
* setting), form-associated. Mirrors native `<input type="range">`
|
|
7
|
+
* semantics: `value` is the string form-submitted via `FormAssociated`,
|
|
8
|
+
* `valueAsNumber` is the ergonomic numeric accessor (mirroring the native
|
|
9
|
+
* `<input type=range>` IDL attribute of the same name) kept in sync with it
|
|
10
|
+
* in both directions — reads parse `value`, writes stringify back to it.
|
|
11
|
+
*
|
|
12
|
+
* Unlike the mixin's other consumers, an unset `value` is eagerly defaulted
|
|
13
|
+
* — on connect, and again after `form.reset()` — to the midpoint of
|
|
14
|
+
* `[min, max]` snapped to `step`, the same "range sanitization algorithm"
|
|
15
|
+
* default a native range input applies. A slider always represents *some*
|
|
16
|
+
* number, so `required` (inherited from `FormAssociated`) only has a window
|
|
17
|
+
* to block submission before that default lands, matching how `required`
|
|
18
|
+
* isn't a meaningful constraint on a native range input either.
|
|
19
|
+
*
|
|
20
|
+
* @customElement lyra-slider
|
|
21
|
+
* @event lyra-input - Fired continuously during an active drag or a
|
|
22
|
+
* keyboard step (including OS key-repeat while a key is held), mirroring
|
|
23
|
+
* native `<input type=range>`'s own `input` event. `detail: { value: number }`.
|
|
24
|
+
* @event lyra-change - Fired once an interaction commits: on pointerup for a
|
|
25
|
+
* drag, or on keyup for a keyboard step — so a single Arrow/Home/End/
|
|
26
|
+
* PageUp/PageDown press fires both `lyra-input` and `lyra-change`,
|
|
27
|
+
* mirroring how native `<input type=range>` fires `change` on every
|
|
28
|
+
* committed step too. `detail: { value: number }`.
|
|
29
|
+
* @csspart base - The row wrapping the track and the optional value readout.
|
|
30
|
+
* @csspart track - The full-width background line.
|
|
31
|
+
* @csspart fill - The filled portion of the track from `min` up to the current value.
|
|
32
|
+
* @csspart thumb - The draggable handle (`role="slider"`).
|
|
33
|
+
* @csspart value - The visible numeric readout, rendered when `show-value` is true.
|
|
34
|
+
*/
|
|
35
|
+
export declare class LyraSlider extends LyraSlider_base {
|
|
36
|
+
static styles: import("lit").CSSResultGroup[];
|
|
37
|
+
min: number;
|
|
38
|
+
max: number;
|
|
39
|
+
step: number;
|
|
40
|
+
/** Accessible name for the slider, used when no visible label context
|
|
41
|
+
* exists around it (e.g. no wrapping `<label>` or adjacent heading). Set
|
|
42
|
+
* as `aria-label` on the interactive `role="slider"` element. A plain
|
|
43
|
+
* `aria-label` attribute on the host itself is honored as a fallback when
|
|
44
|
+
* this is left unset, matching `<lyra-checkbox>`/`<lyra-switch>`. */
|
|
45
|
+
label: string;
|
|
46
|
+
/** Whether to render the current numeric value as visible text next to
|
|
47
|
+
* the track. Like `<lyra-markdown>`'s `sanitize`/`gfm`, this is a plain
|
|
48
|
+
* `type: Boolean` property defaulting `true` — turn it off via the
|
|
49
|
+
* `.showValue=${false}` property binding (a bare `show-value="false"`
|
|
50
|
+
* content attribute is still truthy, since presence is all Lit's default
|
|
51
|
+
* boolean converter checks). */
|
|
52
|
+
showValue: boolean;
|
|
53
|
+
private activePointers;
|
|
54
|
+
connectedCallback(): void;
|
|
55
|
+
disconnectedCallback(): void;
|
|
56
|
+
/** The numeric counterpart of `value`, mirroring native `<input
|
|
57
|
+
* type=range>.valueAsNumber`. Reading always returns a finite, clamped,
|
|
58
|
+
* step-snapped number — even if `value` is momentarily `""` (e.g. right
|
|
59
|
+
* after `form.reset()` restores an undeclared default) — by falling back
|
|
60
|
+
* to the midpoint of `[min, max]`. Writing stringifies the clamped result
|
|
61
|
+
* back into `value`. */
|
|
62
|
+
get valueAsNumber(): number;
|
|
63
|
+
set valueAsNumber(next: number);
|
|
64
|
+
/** If `value` is still unset, seed it with the sanitized default — the
|
|
65
|
+
* midpoint of `[min, max]`, snapped to `step` — so `value`/`valueAsNumber`
|
|
66
|
+
* and rendering never have to treat "" as a real, distinct state. */
|
|
67
|
+
private ensureValue;
|
|
68
|
+
private domain;
|
|
69
|
+
private defaultNumericValue;
|
|
70
|
+
private percentOf;
|
|
71
|
+
private clampValue;
|
|
72
|
+
private formatValue;
|
|
73
|
+
private setValue;
|
|
74
|
+
private onKeyDown;
|
|
75
|
+
private onKeyUp;
|
|
76
|
+
private onPointerDown;
|
|
77
|
+
private onPointerMove;
|
|
78
|
+
private onPointerUp;
|
|
79
|
+
/** Stop the drag owned by `pointerId`, optionally committing a final lyra-change. */
|
|
80
|
+
private endDrag;
|
|
81
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
82
|
+
render(): TemplateResult;
|
|
83
|
+
}
|
|
84
|
+
declare global {
|
|
85
|
+
interface HTMLElementTagNameMap {
|
|
86
|
+
'lyra-slider': LyraSlider;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
export {};
|