@aceshooting/lyra-ui 1.2.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/custom-elements.json +23341 -11202
- package/dist/components/app-rail/app-rail.d.ts +171 -0
- package/dist/components/app-rail/app-rail.js +483 -0
- package/dist/components/app-rail/app-rail.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail.styles.js +125 -0
- package/dist/components/attachment-chip/attachment-chip.d.ts +114 -0
- package/dist/components/attachment-chip/attachment-chip.js +312 -0
- package/dist/components/attachment-chip/attachment-chip.styles.d.ts +1 -0
- package/dist/components/attachment-chip/attachment-chip.styles.js +184 -0
- package/dist/components/attachment-trigger/attachment-trigger.d.ts +83 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +258 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.d.ts +1 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +68 -0
- package/dist/components/chart/box-plot.js +11 -1
- package/dist/components/chart/chart-loader.d.ts +44 -13
- package/dist/components/chart/chart-loader.js +65 -18
- package/dist/components/chart/chart.d.ts +1 -2
- package/dist/components/chart/chart.js +67 -12
- package/dist/components/chart/histogram-bin.d.ts +4 -1
- package/dist/components/chart/histogram-bin.js +24 -14
- package/dist/components/chart/lite-chart.d.ts +54 -0
- package/dist/components/chart/lite-chart.js +140 -22
- package/dist/components/chart/lite-chart.styles.js +9 -0
- package/dist/components/chat-composer/chat-composer.d.ts +92 -0
- package/dist/components/chat-composer/chat-composer.js +285 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +1 -0
- package/dist/components/chat-composer/chat-composer.styles.js +135 -0
- package/dist/components/chat-message/chat-message.d.ts +113 -0
- package/dist/components/chat-message/chat-message.js +291 -0
- package/dist/components/chat-message/chat-message.styles.d.ts +1 -0
- package/dist/components/chat-message/chat-message.styles.js +203 -0
- package/dist/components/checkbox/checkbox.d.ts +59 -0
- package/dist/components/checkbox/checkbox.js +230 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.styles.js +70 -0
- package/dist/components/chip/chip-group.d.ts +56 -0
- package/dist/components/chip/chip-group.js +124 -0
- package/dist/components/chip/chip-group.styles.d.ts +1 -0
- package/dist/components/chip/chip-group.styles.js +57 -0
- package/dist/components/chip/chip.d.ts +64 -0
- package/dist/components/chip/chip.js +115 -0
- package/dist/components/chip/chip.styles.d.ts +1 -0
- package/dist/components/chip/chip.styles.js +115 -0
- package/dist/components/citation-badge/citation-badge.d.ts +113 -0
- package/dist/components/citation-badge/citation-badge.js +300 -0
- package/dist/components/citation-badge/citation-badge.styles.d.ts +1 -0
- package/dist/components/citation-badge/citation-badge.styles.js +96 -0
- package/dist/components/code-block/code-block.d.ts +89 -0
- package/dist/components/code-block/code-block.js +317 -0
- package/dist/components/code-block/code-block.styles.d.ts +1 -0
- package/dist/components/code-block/code-block.styles.js +187 -0
- package/dist/components/code-block/code-loader.d.ts +44 -0
- package/dist/components/code-block/code-loader.js +79 -0
- package/dist/components/combobox/combobox.d.ts +19 -1
- package/dist/components/combobox/combobox.js +84 -14
- package/dist/components/combobox/option.d.ts +5 -1
- package/dist/components/combobox/option.js +35 -0
- package/dist/components/context-meter/context-meter.d.ts +53 -0
- package/dist/components/context-meter/context-meter.js +150 -0
- package/dist/components/context-meter/context-meter.styles.d.ts +1 -0
- package/dist/components/context-meter/context-meter.styles.js +120 -0
- package/dist/components/conversation-item/conversation-item.d.ts +128 -0
- package/dist/components/conversation-item/conversation-item.js +322 -0
- package/dist/components/conversation-item/conversation-item.styles.d.ts +1 -0
- package/dist/components/conversation-item/conversation-item.styles.js +155 -0
- package/dist/components/date-picker/date-input.d.ts +24 -0
- package/dist/components/date-picker/date-input.js +134 -22
- package/dist/components/date-picker/date-picker.d.ts +7 -0
- package/dist/components/date-picker/date-picker.js +85 -16
- package/dist/components/dialog/confirm.d.ts +40 -0
- package/dist/components/dialog/confirm.js +79 -0
- package/dist/components/dialog/dialog.d.ts +85 -0
- package/dist/components/dialog/dialog.js +272 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +52 -0
- package/dist/components/dock-panel/dock-panel.d.ts +134 -0
- package/dist/components/dock-panel/dock-panel.js +345 -0
- package/dist/components/dock-panel/dock-panel.styles.d.ts +1 -0
- package/dist/components/dock-panel/dock-panel.styles.js +145 -0
- package/dist/components/document-preview/document-preview.d.ts +135 -0
- package/dist/components/document-preview/document-preview.js +372 -0
- package/dist/components/document-preview/document-preview.styles.d.ts +1 -0
- package/dist/components/document-preview/document-preview.styles.js +191 -0
- package/dist/components/export-button/csv.js +1 -1
- package/dist/components/export-button/export-button.js +2 -0
- package/dist/components/flag/flag.d.ts +29 -13
- package/dist/components/flag/flag.js +39 -13
- package/dist/components/gauge/gauge.js +19 -10
- package/dist/components/generation-status/generation-status.d.ts +109 -0
- package/dist/components/generation-status/generation-status.js +273 -0
- package/dist/components/generation-status/generation-status.styles.d.ts +1 -0
- package/dist/components/generation-status/generation-status.styles.js +84 -0
- package/dist/components/heatmap/calendar-grid.d.ts +4 -1
- package/dist/components/heatmap/calendar-grid.js +25 -12
- package/dist/components/heatmap/heatmap-scale.d.ts +6 -0
- package/dist/components/heatmap/heatmap-scale.js +7 -1
- package/dist/components/heatmap/heatmap.d.ts +74 -0
- package/dist/components/heatmap/heatmap.js +135 -23
- package/dist/components/json-viewer/json-viewer.d.ts +53 -0
- package/dist/components/json-viewer/json-viewer.js +283 -0
- package/dist/components/json-viewer/json-viewer.styles.d.ts +1 -0
- package/dist/components/json-viewer/json-viewer.styles.js +176 -0
- package/dist/components/kbd/kbd.d.ts +77 -0
- package/dist/components/kbd/kbd.js +214 -0
- package/dist/components/kbd/kbd.styles.d.ts +1 -0
- package/dist/components/kbd/kbd.styles.js +52 -0
- package/dist/components/live-region/live-region.d.ts +81 -0
- package/dist/components/live-region/live-region.js +153 -0
- package/dist/components/live-region/live-region.styles.d.ts +1 -0
- package/dist/components/live-region/live-region.styles.js +10 -0
- package/dist/components/map/map.d.ts +8 -6
- package/dist/components/map/map.js +44 -8
- package/dist/components/markdown/markdown-loader.d.ts +34 -0
- package/dist/components/markdown/markdown-loader.js +43 -0
- package/dist/components/markdown/markdown.d.ts +81 -0
- package/dist/components/markdown/markdown.js +284 -0
- package/dist/components/markdown/markdown.styles.d.ts +1 -0
- package/dist/components/markdown/markdown.styles.js +82 -0
- package/dist/components/media-card/media-card.d.ts +122 -0
- package/dist/components/media-card/media-card.js +295 -0
- package/dist/components/media-card/media-card.styles.d.ts +1 -0
- package/dist/components/media-card/media-card.styles.js +132 -0
- package/dist/components/mention-popover/mention-popover.d.ts +200 -0
- package/dist/components/mention-popover/mention-popover.js +475 -0
- package/dist/components/mention-popover/mention-popover.styles.d.ts +1 -0
- package/dist/components/mention-popover/mention-popover.styles.js +101 -0
- package/dist/components/menu/menu-item.d.ts +62 -0
- package/dist/components/menu/menu-item.js +119 -0
- package/dist/components/menu/menu-item.styles.d.ts +1 -0
- package/dist/components/menu/menu-item.styles.js +67 -0
- package/dist/components/menu/menu.d.ts +143 -0
- package/dist/components/menu/menu.js +365 -0
- package/dist/components/menu/menu.styles.d.ts +1 -0
- package/dist/components/menu/menu.styles.js +66 -0
- package/dist/components/model-select/model-select.d.ts +125 -0
- package/dist/components/model-select/model-select.js +490 -0
- package/dist/components/model-select/model-select.styles.d.ts +1 -0
- package/dist/components/model-select/model-select.styles.js +189 -0
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +69 -0
- package/dist/components/model-settings-panel/model-settings-panel.js +145 -0
- package/dist/components/model-settings-panel/model-settings-panel.styles.d.ts +1 -0
- package/dist/components/model-settings-panel/model-settings-panel.styles.js +82 -0
- package/dist/components/playback/playback.d.ts +13 -1
- package/dist/components/playback/playback.js +47 -14
- package/dist/components/responsive-panel/responsive-panel.d.ts +150 -0
- package/dist/components/responsive-panel/responsive-panel.js +365 -0
- package/dist/components/responsive-panel/responsive-panel.styles.d.ts +1 -0
- package/dist/components/responsive-panel/responsive-panel.styles.js +103 -0
- package/dist/components/result-card/result-card.d.ts +44 -0
- package/dist/components/result-card/result-card.js +83 -0
- package/dist/components/result-card/result-card.styles.d.ts +1 -0
- package/dist/components/result-card/result-card.styles.js +50 -0
- package/dist/components/result-card/result-field.d.ts +36 -0
- package/dist/components/result-card/result-field.js +87 -0
- package/dist/components/result-card/result-field.styles.d.ts +1 -0
- package/dist/components/result-card/result-field.styles.js +32 -0
- package/dist/components/select/select.d.ts +43 -2
- package/dist/components/select/select.js +150 -17
- package/dist/components/slider/slider.d.ts +89 -0
- package/dist/components/slider/slider.js +352 -0
- package/dist/components/slider/slider.styles.d.ts +1 -0
- package/dist/components/slider/slider.styles.js +87 -0
- package/dist/components/source-card/source-card.d.ts +92 -0
- package/dist/components/source-card/source-card.js +148 -0
- package/dist/components/source-card/source-card.styles.d.ts +1 -0
- package/dist/components/source-card/source-card.styles.js +69 -0
- package/dist/components/source-list/source-list.d.ts +63 -0
- package/dist/components/source-list/source-list.js +122 -0
- package/dist/components/source-list/source-list.styles.d.ts +1 -0
- package/dist/components/source-list/source-list.styles.js +59 -0
- package/dist/components/sparkline/sparkline.js +27 -13
- package/dist/components/split/split.d.ts +93 -1
- package/dist/components/split/split.js +284 -15
- package/dist/components/split/split.styles.js +30 -0
- package/dist/components/stat/stat.d.ts +6 -1
- package/dist/components/stat/stat.js +8 -2
- package/dist/components/stream-status/stream-status.d.ts +110 -0
- package/dist/components/stream-status/stream-status.js +210 -0
- package/dist/components/stream-status/stream-status.styles.d.ts +1 -0
- package/dist/components/stream-status/stream-status.styles.js +103 -0
- package/dist/components/streaming-text/streaming-text.d.ts +98 -0
- package/dist/components/streaming-text/streaming-text.js +209 -0
- package/dist/components/streaming-text/streaming-text.styles.d.ts +1 -0
- package/dist/components/streaming-text/streaming-text.styles.js +62 -0
- package/dist/components/switch/switch.d.ts +58 -0
- package/dist/components/switch/switch.js +179 -0
- package/dist/components/switch/switch.styles.d.ts +1 -0
- package/dist/components/switch/switch.styles.js +75 -0
- package/dist/components/table/table.d.ts +73 -4
- package/dist/components/table/table.js +169 -20
- package/dist/components/table/table.styles.js +6 -1
- package/dist/components/tabs/tabs.d.ts +51 -0
- package/dist/components/tabs/tabs.js +190 -0
- package/dist/components/tabs/tabs.styles.d.ts +1 -0
- package/dist/components/tabs/tabs.styles.js +63 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +121 -0
- package/dist/components/thinking-panel/thinking-panel.js +235 -0
- package/dist/components/thinking-panel/thinking-panel.styles.d.ts +1 -0
- package/dist/components/thinking-panel/thinking-panel.styles.js +117 -0
- package/dist/components/toast/toast-item.d.ts +1 -0
- package/dist/components/toast/toast-item.js +31 -6
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +130 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +403 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.d.ts +1 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.styles.js +160 -0
- package/dist/components/tool-call-chip/tool-call-chip.d.ts +89 -0
- package/dist/components/tool-call-chip/tool-call-chip.js +288 -0
- package/dist/components/tool-call-chip/tool-call-chip.styles.d.ts +1 -0
- package/dist/components/tool-call-chip/tool-call-chip.styles.js +203 -0
- package/dist/components/tool-param-form/tool-param-form.d.ts +145 -0
- package/dist/components/tool-param-form/tool-param-form.js +366 -0
- package/dist/components/tool-param-form/tool-param-form.styles.d.ts +1 -0
- package/dist/components/tool-param-form/tool-param-form.styles.js +75 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.d.ts +102 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.js +393 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.d.ts +1 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.styles.js +176 -0
- package/dist/components/tool-result-view/registry.d.ts +81 -0
- package/dist/components/tool-result-view/registry.js +84 -0
- package/dist/components/tool-result-view/tool-result-view.d.ts +55 -0
- package/dist/components/tool-result-view/tool-result-view.js +138 -0
- package/dist/components/tool-result-view/tool-result-view.styles.d.ts +1 -0
- package/dist/components/tool-result-view/tool-result-view.styles.js +13 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.d.ts +151 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.js +439 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.d.ts +1 -0
- package/dist/components/tool-select-dialog/tool-select-dialog.styles.js +182 -0
- package/dist/components/tree/tree-node.d.ts +11 -2
- package/dist/components/tree/tree-node.js +16 -6
- package/dist/components/tree/tree.d.ts +8 -2
- package/dist/components/tree/tree.js +18 -11
- package/dist/components/typing-indicator/typing-indicator.d.ts +60 -0
- package/dist/components/typing-indicator/typing-indicator.js +96 -0
- package/dist/components/typing-indicator/typing-indicator.styles.d.ts +1 -0
- package/dist/components/typing-indicator/typing-indicator.styles.js +132 -0
- package/dist/components/virtual-list/virtual-list.d.ts +173 -0
- package/dist/components/virtual-list/virtual-list.js +461 -0
- package/dist/components/virtual-list/virtual-list.styles.d.ts +1 -0
- package/dist/components/virtual-list/virtual-list.styles.js +44 -0
- package/dist/components/word-cloud/word-cloud-layout.js +14 -1
- package/dist/components/word-cloud/word-cloud.d.ts +6 -0
- package/dist/components/word-cloud/word-cloud.js +25 -14
- package/dist/components/word-cloud/word-cloud.styles.js +3 -2
- package/dist/internal/announcer.d.ts +57 -0
- package/dist/internal/announcer.js +71 -0
- package/dist/internal/form-associated.d.ts +1 -0
- package/dist/internal/form-associated.js +55 -11
- package/dist/internal/group-by-recency.d.ts +50 -0
- package/dist/internal/group-by-recency.js +80 -0
- package/dist/internal/rtl.d.ts +23 -0
- package/dist/internal/rtl.js +28 -0
- package/dist/internal/scroll-lock.d.ts +10 -5
- package/dist/internal/scroll-lock.js +30 -14
- package/dist/internal/tokens.styles.js +6 -0
- package/dist/lyra.d.ts +130 -31
- package/dist/lyra.js +94 -26
- package/llms-full.txt +3836 -17
- package/llms.txt +16 -1
- package/package.json +23 -5
- package/dist/components/chart/bar-chart.stories.d.ts +0 -5
- package/dist/components/chart/bar-chart.stories.js +0 -20
- package/dist/components/chart/box-plot.stories.d.ts +0 -5
- package/dist/components/chart/box-plot.stories.js +0 -29
- package/dist/components/chart/bubble-chart.stories.d.ts +0 -5
- package/dist/components/chart/bubble-chart.stories.js +0 -26
- package/dist/components/chart/chart.stories.d.ts +0 -32
- package/dist/components/chart/chart.stories.js +0 -141
- package/dist/components/chart/doughnut-chart.stories.d.ts +0 -5
- package/dist/components/chart/doughnut-chart.stories.js +0 -26
- package/dist/components/chart/histogram.stories.d.ts +0 -5
- package/dist/components/chart/histogram.stories.js +0 -17
- package/dist/components/chart/line-chart.stories.d.ts +0 -22
- package/dist/components/chart/line-chart.stories.js +0 -99
- package/dist/components/chart/lite-chart.stories.d.ts +0 -14
- package/dist/components/chart/lite-chart.stories.js +0 -114
- package/dist/components/chart/pie-chart.stories.d.ts +0 -5
- package/dist/components/chart/pie-chart.stories.js +0 -26
- package/dist/components/chart/polar-area-chart.stories.d.ts +0 -5
- package/dist/components/chart/polar-area-chart.stories.js +0 -20
- package/dist/components/chart/radar-chart.stories.d.ts +0 -5
- package/dist/components/chart/radar-chart.stories.js +0 -20
- package/dist/components/chart/scatter-chart.stories.d.ts +0 -5
- package/dist/components/chart/scatter-chart.stories.js +0 -31
- package/dist/components/combobox/combobox.stories.d.ts +0 -24
- package/dist/components/combobox/combobox.stories.js +0 -102
- package/dist/components/date-picker/date-input.stories.d.ts +0 -10
- package/dist/components/date-picker/date-input.stories.js +0 -48
- package/dist/components/date-picker/date-picker.stories.d.ts +0 -10
- package/dist/components/date-picker/date-picker.stories.js +0 -25
- package/dist/components/empty/empty.stories.d.ts +0 -7
- package/dist/components/empty/empty.stories.js +0 -34
- package/dist/components/export-button/export-button.stories.d.ts +0 -7
- package/dist/components/export-button/export-button.stories.js +0 -37
- package/dist/components/file-input/file-input.stories.d.ts +0 -7
- package/dist/components/file-input/file-input.stories.js +0 -19
- package/dist/components/flag/flag.stories.d.ts +0 -6
- package/dist/components/flag/flag.stories.js +0 -31
- package/dist/components/gauge/gauge.stories.d.ts +0 -8
- package/dist/components/gauge/gauge.stories.js +0 -19
- package/dist/components/graph/graph.stories.d.ts +0 -8
- package/dist/components/graph/graph.stories.js +0 -68
- package/dist/components/heatmap/heatmap.stories.d.ts +0 -27
- package/dist/components/heatmap/heatmap.stories.js +0 -179
- package/dist/components/map/map.stories.d.ts +0 -15
- package/dist/components/map/map.stories.js +0 -135
- package/dist/components/playback/playback.stories.d.ts +0 -7
- package/dist/components/playback/playback.stories.js +0 -16
- package/dist/components/select/select.stories.d.ts +0 -21
- package/dist/components/select/select.stories.js +0 -91
- package/dist/components/skeleton/skeleton.stories.d.ts +0 -5
- package/dist/components/skeleton/skeleton.stories.js +0 -16
- package/dist/components/sparkline/sparkline.stories.d.ts +0 -11
- package/dist/components/sparkline/sparkline.stories.js +0 -39
- package/dist/components/split/split.stories.d.ts +0 -7
- package/dist/components/split/split.stories.js +0 -36
- package/dist/components/stat/stat.stories.d.ts +0 -9
- package/dist/components/stat/stat.stories.js +0 -81
- package/dist/components/table/table.stories.d.ts +0 -12
- package/dist/components/table/table.stories.js +0 -67
- package/dist/components/time-range/time-range.stories.d.ts +0 -8
- package/dist/components/time-range/time-range.stories.js +0 -26
- package/dist/components/toast/toast.stories.d.ts +0 -8
- package/dist/components/toast/toast.stories.js +0 -72
- package/dist/components/tree/tree.stories.d.ts +0 -9
- package/dist/components/tree/tree.stories.js +0 -52
- package/dist/components/widget/widget.stories.d.ts +0 -9
- package/dist/components/widget/widget.stories.js +0 -74
- package/dist/components/word-cloud/word-cloud.stories.d.ts +0 -10
- package/dist/components/word-cloud/word-cloud.stories.js +0 -55
|
@@ -0,0 +1,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.
|
|
@@ -42,7 +54,6 @@ import '../combobox/option.js';
|
|
|
42
54
|
* @csspart error - The error message.
|
|
43
55
|
* @csspart hint - The hint message.
|
|
44
56
|
*/
|
|
45
|
-
export type LyraSelectSize = 'xs' | 's' | 'm' | 'l' | 'xl';
|
|
46
57
|
export declare class LyraSelect extends LyraElement {
|
|
47
58
|
static formAssociated: boolean;
|
|
48
59
|
static styles: import("lit").CSSResultGroup[];
|
|
@@ -50,11 +61,14 @@ export declare class LyraSelect extends LyraElement {
|
|
|
50
61
|
value: {
|
|
51
62
|
noAccessor: boolean;
|
|
52
63
|
};
|
|
64
|
+
name: {
|
|
65
|
+
reflect: boolean;
|
|
66
|
+
noAccessor: boolean;
|
|
67
|
+
};
|
|
53
68
|
};
|
|
54
69
|
placeholder: string;
|
|
55
70
|
disabled: boolean;
|
|
56
71
|
required: boolean;
|
|
57
|
-
name: string;
|
|
58
72
|
label: string;
|
|
59
73
|
hint: string;
|
|
60
74
|
errorText: string;
|
|
@@ -68,6 +82,7 @@ export declare class LyraSelect extends LyraElement {
|
|
|
68
82
|
private hasErrorSlot;
|
|
69
83
|
private hasLabelSlot;
|
|
70
84
|
private internals;
|
|
85
|
+
private _fieldsetDisabled;
|
|
71
86
|
private listId;
|
|
72
87
|
private triggerId;
|
|
73
88
|
private cleanup?;
|
|
@@ -77,21 +92,47 @@ export declare class LyraSelect extends LyraElement {
|
|
|
77
92
|
private _defaultCaptured;
|
|
78
93
|
private typeAheadBuffer;
|
|
79
94
|
private typeAheadTimer?;
|
|
95
|
+
private _name;
|
|
80
96
|
constructor();
|
|
81
97
|
connectedCallback(): void;
|
|
82
98
|
protected willUpdate(): void;
|
|
99
|
+
get name(): string;
|
|
100
|
+
set name(next: string);
|
|
83
101
|
/** The selected value: a single string (empty when nothing is selected). */
|
|
84
102
|
get value(): string;
|
|
85
103
|
set value(next: string);
|
|
86
104
|
private updateValidity;
|
|
87
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;
|
|
88
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
|
+
*/
|
|
89
117
|
formDisabledCallback(disabled: boolean): void;
|
|
90
118
|
checkValidity(): boolean;
|
|
91
119
|
reportValidity(): boolean;
|
|
92
120
|
disconnectedCallback(): void;
|
|
93
121
|
private collectOptions;
|
|
94
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;
|
|
95
136
|
private show;
|
|
96
137
|
private hide;
|
|
97
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';
|
|
@@ -14,18 +14,70 @@ import { chevronIcon } from '../../internal/icons.js';
|
|
|
14
14
|
import { styles } from './select.styles.js';
|
|
15
15
|
import { LyraOption } from '../combobox/option.js';
|
|
16
16
|
import '../combobox/option.js';
|
|
17
|
+
/**
|
|
18
|
+
* `<lyra-select>` — a plain closed-list dropdown: a direct `<lyra-*>`
|
|
19
|
+
* counterpart to `<wa-select>`/`<wa-option>`. Trigger is a button (not a text
|
|
20
|
+
* input) -- click/Enter/Space/ArrowDown opens it, there's no typing-to-filter.
|
|
21
|
+
* A printable keypress instead jumps (or, while closed, directly selects) the
|
|
22
|
+
* next option whose label starts with what's been typed, like a native
|
|
23
|
+
* `<select>`'s type-ahead.
|
|
24
|
+
*
|
|
25
|
+
* Options are `<lyra-option value>` children, the same element `<lyra-combobox>`
|
|
26
|
+
* uses. Unlike `lyra-combobox` this is single-select only, with no filter/
|
|
27
|
+
* source/with-clear/max-options-visible/empty-text/max-render/multiple surface
|
|
28
|
+
* -- see `<lyra-combobox>` for the filterable/multi-select case.
|
|
29
|
+
*
|
|
30
|
+
* Reuses `lyra-combobox`'s popup positioning (`internal/positioner.js`) and
|
|
31
|
+
* click-outside/Escape/Home/End/Arrow-key listbox navigation patterns,
|
|
32
|
+
* adapted to a trigger button that keeps DOM focus throughout (the listbox's
|
|
33
|
+
* "active" row is conveyed via `aria-activedescendant`, never actual focus),
|
|
34
|
+
* matching the WAI-ARIA "select-only combobox" pattern.
|
|
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
|
+
*
|
|
47
|
+
* @customElement lyra-select
|
|
48
|
+
* @slot - `<lyra-option>` elements.
|
|
49
|
+
* @slot label - Custom label content.
|
|
50
|
+
* @slot hint - Custom hint content.
|
|
51
|
+
* @slot error - Custom error content.
|
|
52
|
+
* @event change - The selection changed.
|
|
53
|
+
* @event input - Fired alongside `change` on every selection change (native
|
|
54
|
+
* `<select>` doesn't meaningfully distinguish the two either).
|
|
55
|
+
* @event lyra-show - The listbox opened.
|
|
56
|
+
* @event lyra-hide - The listbox closed.
|
|
57
|
+
* @csspart form-control - The outer wrapper around label, trigger, listbox, error and hint.
|
|
58
|
+
* @csspart form-control-label - The `<label>` element.
|
|
59
|
+
* @csspart trigger - The trigger button (positioning anchor).
|
|
60
|
+
* @csspart listbox - The options popover.
|
|
61
|
+
* @csspart option - An option row.
|
|
62
|
+
* @csspart option-dot - An option row's leading status dot (when `dot-color` is set).
|
|
63
|
+
* @csspart option-label - An option row's label/sub wrapper.
|
|
64
|
+
* @csspart option-sub - An option row's secondary line (when `sub` is set).
|
|
65
|
+
* @csspart expand-icon - The dropdown indicator.
|
|
66
|
+
* @csspart error - The error message.
|
|
67
|
+
* @csspart hint - The hint message.
|
|
68
|
+
*/
|
|
17
69
|
export class LyraSelect extends LyraElement {
|
|
18
70
|
static { this.formAssociated = true; }
|
|
19
71
|
static { this.styles = [LyraElement.styles, styles]; }
|
|
20
72
|
static { this.properties = {
|
|
21
73
|
value: { noAccessor: true },
|
|
74
|
+
name: { reflect: true, noAccessor: true },
|
|
22
75
|
}; }
|
|
23
76
|
constructor() {
|
|
24
77
|
super();
|
|
25
78
|
this.placeholder = '';
|
|
26
79
|
this.disabled = false;
|
|
27
80
|
this.required = false;
|
|
28
|
-
this.name = '';
|
|
29
81
|
this.label = '';
|
|
30
82
|
this.hint = '';
|
|
31
83
|
this.errorText = '';
|
|
@@ -44,6 +96,11 @@ export class LyraSelect extends LyraElement {
|
|
|
44
96
|
this.hasHintSlot = false;
|
|
45
97
|
this.hasErrorSlot = false;
|
|
46
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;
|
|
47
104
|
this.listId = nextId('select-list');
|
|
48
105
|
this.triggerId = nextId('select-trigger');
|
|
49
106
|
this._isFirstUpdate = true;
|
|
@@ -60,6 +117,15 @@ export class LyraSelect extends LyraElement {
|
|
|
60
117
|
// buffer and reset ~500ms after the last one, so "b" then "a" narrows to
|
|
61
118
|
// "ba" instead of restarting the search on every keystroke.
|
|
62
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 = '';
|
|
63
129
|
this.collectOptions = (e) => {
|
|
64
130
|
const slot = e.target;
|
|
65
131
|
const previous = new Set(this.options);
|
|
@@ -96,13 +162,24 @@ export class LyraSelect extends LyraElement {
|
|
|
96
162
|
}
|
|
97
163
|
this.reflectSelected();
|
|
98
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
|
+
};
|
|
99
174
|
this.onDocPointer = (e) => {
|
|
100
175
|
if (!e.composedPath().includes(this))
|
|
101
176
|
this.hide();
|
|
102
177
|
};
|
|
103
178
|
this.onTriggerClick = () => {
|
|
104
|
-
if (this.
|
|
179
|
+
if (this.effectiveDisabled)
|
|
105
180
|
return;
|
|
181
|
+
if (this.onlyOption)
|
|
182
|
+
return this.selectOption(this.onlyOption);
|
|
106
183
|
this.open ? this.hide() : this.show();
|
|
107
184
|
};
|
|
108
185
|
this.onTriggerBlur = () => {
|
|
@@ -127,12 +204,16 @@ export class LyraSelect extends LyraElement {
|
|
|
127
204
|
switch (e.key) {
|
|
128
205
|
case 'ArrowDown':
|
|
129
206
|
e.preventDefault();
|
|
207
|
+
if (this.onlyOption)
|
|
208
|
+
return this.selectOption(this.onlyOption);
|
|
130
209
|
if (!this.open)
|
|
131
210
|
return this.show();
|
|
132
211
|
this.activeIndex = Math.min(navigable.length - 1, this.activeIndex + 1);
|
|
133
212
|
break;
|
|
134
213
|
case 'ArrowUp':
|
|
135
214
|
e.preventDefault();
|
|
215
|
+
if (this.onlyOption)
|
|
216
|
+
return this.selectOption(this.onlyOption);
|
|
136
217
|
if (!this.open)
|
|
137
218
|
return this.show();
|
|
138
219
|
this.activeIndex = Math.max(0, this.activeIndex - 1);
|
|
@@ -212,6 +293,20 @@ export class LyraSelect extends LyraElement {
|
|
|
212
293
|
this.hasLabelSlot = Array.from(this.children).some((el) => el.getAttribute('slot') === 'label');
|
|
213
294
|
}
|
|
214
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
|
+
}
|
|
215
310
|
/** The selected value: a single string (empty when nothing is selected). */
|
|
216
311
|
get value() {
|
|
217
312
|
return this._selected;
|
|
@@ -235,11 +330,24 @@ export class LyraSelect extends LyraElement {
|
|
|
235
330
|
syncFormValue() {
|
|
236
331
|
this.internals.setFormValue(this._selected);
|
|
237
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
|
+
}
|
|
238
339
|
formResetCallback() {
|
|
239
340
|
this.value = this._defaultSelected;
|
|
240
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
|
+
*/
|
|
241
348
|
formDisabledCallback(disabled) {
|
|
242
|
-
this.
|
|
349
|
+
this._fieldsetDisabled = disabled;
|
|
350
|
+
this.requestUpdate();
|
|
243
351
|
}
|
|
244
352
|
checkValidity() {
|
|
245
353
|
return this.internals.checkValidity();
|
|
@@ -250,15 +358,37 @@ export class LyraSelect extends LyraElement {
|
|
|
250
358
|
disconnectedCallback() {
|
|
251
359
|
super.disconnectedCallback();
|
|
252
360
|
this.cleanup?.();
|
|
361
|
+
this.cleanup = undefined;
|
|
253
362
|
clearTimeout(this.typeAheadTimer);
|
|
254
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;
|
|
255
370
|
}
|
|
256
371
|
reflectSelected() {
|
|
257
372
|
for (const o of this.options)
|
|
258
373
|
o.selected = o.value === this._selected;
|
|
259
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
|
+
}
|
|
260
390
|
show() {
|
|
261
|
-
if (this.open || this.
|
|
391
|
+
if (this.open || this.effectiveDisabled)
|
|
262
392
|
return;
|
|
263
393
|
this.open = true;
|
|
264
394
|
}
|
|
@@ -385,6 +515,12 @@ export class LyraSelect extends LyraElement {
|
|
|
385
515
|
const hasHint = this.hasHintSlot || this.hint.length > 0;
|
|
386
516
|
const hasError = this.hasErrorSlot || this.errorText.length > 0;
|
|
387
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;
|
|
388
524
|
return html `
|
|
389
525
|
<div part="form-control">
|
|
390
526
|
<label part="form-control-label" for=${this.triggerId} ?hidden=${!hasLabel}>
|
|
@@ -394,15 +530,15 @@ export class LyraSelect extends LyraElement {
|
|
|
394
530
|
id=${this.triggerId}
|
|
395
531
|
part="trigger"
|
|
396
532
|
type="button"
|
|
397
|
-
role
|
|
398
|
-
aria-haspopup
|
|
399
|
-
aria-expanded=${this.open ? 'true' : 'false'}
|
|
400
|
-
aria-controls=${this.listId}
|
|
401
|
-
aria-activedescendant=${activeId}
|
|
402
|
-
aria-label=${this.getAttribute('aria-label') ||
|
|
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')}
|
|
403
539
|
aria-required=${this.required ? 'true' : 'false'}
|
|
404
540
|
aria-invalid=${this.touched && !this.internals.validity.valid ? 'true' : 'false'}
|
|
405
|
-
?disabled=${this.
|
|
541
|
+
?disabled=${this.effectiveDisabled}
|
|
406
542
|
@click=${this.onTriggerClick}
|
|
407
543
|
@keydown=${this.onKeyDown}
|
|
408
544
|
@blur=${this.onTriggerBlur}
|
|
@@ -410,7 +546,7 @@ export class LyraSelect extends LyraElement {
|
|
|
410
546
|
<span class="trigger-label" ?data-placeholder=${!hasValue}
|
|
411
547
|
>${hasValue ? selectedLabel : this.placeholder}</span
|
|
412
548
|
>
|
|
413
|
-
|
|
549
|
+
${isSingleOption ? nothing : html `<span part="expand-icon" aria-hidden="true">${chevronIcon()}</span>`}
|
|
414
550
|
</button>
|
|
415
551
|
<div
|
|
416
552
|
part="listbox"
|
|
@@ -428,7 +564,7 @@ export class LyraSelect extends LyraElement {
|
|
|
428
564
|
${this.hint}<slot name="hint" @slotchange=${this.onHintSlotChange}></slot>
|
|
429
565
|
</div>
|
|
430
566
|
</div>
|
|
431
|
-
<slot @slotchange=${this.collectOptions} hidden></slot>
|
|
567
|
+
<slot @slotchange=${this.collectOptions} @lyra-option-change=${this.onOptionChange} hidden></slot>
|
|
432
568
|
`;
|
|
433
569
|
}
|
|
434
570
|
}
|
|
@@ -441,9 +577,6 @@ __decorate([
|
|
|
441
577
|
__decorate([
|
|
442
578
|
property({ type: Boolean, reflect: true })
|
|
443
579
|
], LyraSelect.prototype, "required", void 0);
|
|
444
|
-
__decorate([
|
|
445
|
-
property()
|
|
446
|
-
], LyraSelect.prototype, "name", void 0);
|
|
447
580
|
__decorate([
|
|
448
581
|
property()
|
|
449
582
|
], LyraSelect.prototype, "label", void 0);
|
|
@@ -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 {};
|