@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,119 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
import { html } from 'lit';
|
|
8
|
+
import { property, state } from 'lit/decorators.js';
|
|
9
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
10
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
11
|
+
import { styles } from './menu-item.styles.js';
|
|
12
|
+
/**
|
|
13
|
+
* `<lyra-menu-item>` — a single action row inside `<lyra-menu>`'s default
|
|
14
|
+
* slot. Not meaningful on its own (there is no standalone "click a menu item"
|
|
15
|
+
* use case) — it exists purely as `<lyra-menu>`'s light-DOM child, the same
|
|
16
|
+
* relationship `<lyra-option>` has to `<lyra-combobox>`/`<lyra-select>`.
|
|
17
|
+
*
|
|
18
|
+
* `role="menuitem"` and the roving `tabindex` both live on *this host
|
|
19
|
+
* element*, not an internal shadow-DOM button — mirroring `<lyra-tree-node>`'s
|
|
20
|
+
* identical choice (see that class's doc). `<lyra-menu>` is the sole owner of
|
|
21
|
+
* this element's `tabIndex`: it flips exactly one navigable item's `tabIndex`
|
|
22
|
+
* to `0` (the rest sit at `-1`) as its roving-tabindex highlight moves, and
|
|
23
|
+
* calls `.focus()` directly on this host to move real DOM focus there.
|
|
24
|
+
* `[part="base"]` is purely a visual box with no interactive semantics of its
|
|
25
|
+
* own — see the class doc on `<lyra-menu>` for why real DOM focus (rather
|
|
26
|
+
* than `aria-activedescendant`) was chosen for this pair.
|
|
27
|
+
*
|
|
28
|
+
* Enter/Space activation is handled by `<lyra-menu>`'s own delegated
|
|
29
|
+
* `keydown` listener calling `select()` on whichever item is currently
|
|
30
|
+
* roving-focused (mirrors `<lyra-tree>` calling `current.select()` from its
|
|
31
|
+
* own keydown handler) — this element only wires a plain `click` listener
|
|
32
|
+
* itself, so `select()` fires identically whether the item was reached by
|
|
33
|
+
* mouse or keyboard.
|
|
34
|
+
*
|
|
35
|
+
* @customElement lyra-menu-item
|
|
36
|
+
* @slot - The item's label content.
|
|
37
|
+
* @slot icon - Optional leading icon.
|
|
38
|
+
* @event lyra-menu-item-select - This item was activated (click, or the
|
|
39
|
+
* parent `<lyra-menu>`'s own Enter/Space handling of the roving-focused
|
|
40
|
+
* item). No detail payload — a listener already has `event.target` (this
|
|
41
|
+
* element) to read `value` off of, and `<lyra-menu>` itself consumes this
|
|
42
|
+
* event to close and re-fire it as its own consolidated `lyra-menu-select`
|
|
43
|
+
* (`detail: { value }`) rather than requiring a consumer to listen on every
|
|
44
|
+
* individual item — listen there instead unless you specifically need a
|
|
45
|
+
* per-item handler.
|
|
46
|
+
* @csspart base - The row (`role` lives on the host — see the class doc).
|
|
47
|
+
* @csspart icon - Wrapper around the `icon` slot. Not rendered at all when the slot is empty.
|
|
48
|
+
* @csspart label - Wrapper around the default slot.
|
|
49
|
+
*/
|
|
50
|
+
export class LyraMenuItem extends LyraElement {
|
|
51
|
+
constructor() {
|
|
52
|
+
super(...arguments);
|
|
53
|
+
/** An id/value the parent `<lyra-menu>`'s `lyra-menu-select` detail keys off of. */
|
|
54
|
+
this.value = '';
|
|
55
|
+
/** Disables selection and excludes this item from `<lyra-menu>`'s roving-tabindex nav entirely. */
|
|
56
|
+
this.disabled = false;
|
|
57
|
+
/** Visual treatment for a dangerous action (e.g. "Delete") — tints the row with `--lyra-color-danger`. */
|
|
58
|
+
this.destructive = false;
|
|
59
|
+
// [part='icon'] never matches a bare :empty selector -- see menu-item.styles.ts's
|
|
60
|
+
// own comment on that part. Same fix as lyra-tool-call-chip's hasDetailSlot.
|
|
61
|
+
this.hasIconSlot = false;
|
|
62
|
+
this.onIconSlotChange = (e) => {
|
|
63
|
+
this.hasIconSlot = e.target.assignedElements({ flatten: true }).length > 0;
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
67
|
+
connectedCallback() {
|
|
68
|
+
super.connectedCallback();
|
|
69
|
+
// A safe, focusable-but-out-of-tab-order baseline before <lyra-menu> ever
|
|
70
|
+
// gets a chance to assign roving-tabindex state (e.g. a standalone
|
|
71
|
+
// fixture in a test, or the brief window before the parent's own
|
|
72
|
+
// slotchange handler runs). <lyra-menu> is the sole subsequent owner of
|
|
73
|
+
// this property -- see the class doc.
|
|
74
|
+
if (this.tabIndex !== 0)
|
|
75
|
+
this.tabIndex = -1;
|
|
76
|
+
}
|
|
77
|
+
willUpdate() {
|
|
78
|
+
// role/aria-disabled live on the host (see the class doc), so they're
|
|
79
|
+
// plain imperative attribute writes here rather than part of render()'s
|
|
80
|
+
// shadow-DOM template -- mirrors lyra-tree-node's identical willUpdate.
|
|
81
|
+
this.setAttribute('role', 'menuitem');
|
|
82
|
+
if (this.disabled) {
|
|
83
|
+
this.setAttribute('aria-disabled', 'true');
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
this.removeAttribute('aria-disabled');
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
/** Fires `lyra-menu-item-select` (no-op while `disabled`). Called by this element's own
|
|
90
|
+
* click handler, and by `<lyra-menu>`'s Enter/Space keydown handling of the active item. */
|
|
91
|
+
select() {
|
|
92
|
+
if (this.disabled)
|
|
93
|
+
return;
|
|
94
|
+
this.emit('lyra-menu-item-select');
|
|
95
|
+
}
|
|
96
|
+
render() {
|
|
97
|
+
return html `
|
|
98
|
+
<span part="base" @click=${() => this.select()}>
|
|
99
|
+
<span part="icon" aria-hidden="true" ?hidden=${!this.hasIconSlot}>
|
|
100
|
+
<slot name="icon" @slotchange=${this.onIconSlotChange}></slot>
|
|
101
|
+
</span>
|
|
102
|
+
<span part="label"><slot></slot></span>
|
|
103
|
+
</span>
|
|
104
|
+
`;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
__decorate([
|
|
108
|
+
property()
|
|
109
|
+
], LyraMenuItem.prototype, "value", void 0);
|
|
110
|
+
__decorate([
|
|
111
|
+
property({ type: Boolean, reflect: true })
|
|
112
|
+
], LyraMenuItem.prototype, "disabled", void 0);
|
|
113
|
+
__decorate([
|
|
114
|
+
property({ type: Boolean, reflect: true })
|
|
115
|
+
], LyraMenuItem.prototype, "destructive", void 0);
|
|
116
|
+
__decorate([
|
|
117
|
+
state()
|
|
118
|
+
], LyraMenuItem.prototype, "hasIconSlot", void 0);
|
|
119
|
+
defineElement('menu-item', LyraMenuItem);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
/* The host itself is the focusable role="menuitem" target (see the class
|
|
6
|
+
doc) -- the ring paints on [part='base'] instead of the host's own
|
|
7
|
+
box, matching lyra-tree-node's identical :host(:focus-visible)
|
|
8
|
+
delegation, so it always hugs the visible row rather than any
|
|
9
|
+
host-level margin/inline layout quirks. */
|
|
10
|
+
outline: none;
|
|
11
|
+
border-radius: var(--lyra-radius);
|
|
12
|
+
}
|
|
13
|
+
:host(:focus-visible) [part='base'] {
|
|
14
|
+
outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
|
|
15
|
+
outline-offset: calc(-1 * var(--lyra-focus-ring-width));
|
|
16
|
+
}
|
|
17
|
+
[part='base'] {
|
|
18
|
+
display: flex;
|
|
19
|
+
align-items: center;
|
|
20
|
+
gap: var(--lyra-space-xs);
|
|
21
|
+
padding: var(--lyra-space-xs) var(--lyra-space-s);
|
|
22
|
+
border-radius: var(--lyra-radius);
|
|
23
|
+
cursor: pointer;
|
|
24
|
+
font: inherit;
|
|
25
|
+
color: inherit;
|
|
26
|
+
line-height: 1.3;
|
|
27
|
+
}
|
|
28
|
+
[part='base']:hover {
|
|
29
|
+
background: var(--lyra-color-brand-quiet);
|
|
30
|
+
}
|
|
31
|
+
:host([disabled]) [part='base'] {
|
|
32
|
+
/* Shared library-wide disabled-state token -- see lyra-checkbox/lyra-select. */
|
|
33
|
+
opacity: var(--lyra-opacity-disabled);
|
|
34
|
+
cursor: not-allowed;
|
|
35
|
+
}
|
|
36
|
+
:host([disabled]) [part='base']:hover {
|
|
37
|
+
background: none;
|
|
38
|
+
}
|
|
39
|
+
:host([destructive]) [part='base'] {
|
|
40
|
+
color: var(--lyra-color-danger);
|
|
41
|
+
}
|
|
42
|
+
:host([destructive]) [part='base']:hover {
|
|
43
|
+
background: var(--lyra-color-danger-quiet);
|
|
44
|
+
}
|
|
45
|
+
[part='icon'] {
|
|
46
|
+
display: inline-flex;
|
|
47
|
+
flex: 0 0 auto;
|
|
48
|
+
align-items: center;
|
|
49
|
+
justify-content: center;
|
|
50
|
+
line-height: 1;
|
|
51
|
+
}
|
|
52
|
+
/* [part='icon'][hidden] rather than a bare :empty selector -- the part
|
|
53
|
+
always contains a literal <slot> child element regardless of assigned
|
|
54
|
+
content, so :empty never matches (same fix as lyra-select's
|
|
55
|
+
[part='hint']/[part='error']). Real emptiness is tracked in JS
|
|
56
|
+
(hasIconSlot) and reflected via the hidden attribute instead. */
|
|
57
|
+
[part='icon'][hidden] {
|
|
58
|
+
display: none;
|
|
59
|
+
}
|
|
60
|
+
[part='label'] {
|
|
61
|
+
flex: 1 1 auto;
|
|
62
|
+
min-inline-size: 0;
|
|
63
|
+
overflow: hidden;
|
|
64
|
+
text-overflow: ellipsis;
|
|
65
|
+
white-space: nowrap;
|
|
66
|
+
}
|
|
67
|
+
`;
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
|
+
import type { Placement } from '@floating-ui/dom';
|
|
3
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
4
|
+
import './menu-item.js';
|
|
5
|
+
export interface MenuSelectDetail {
|
|
6
|
+
value: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* `<lyra-menu>` — an anchored dropdown of `<lyra-menu-item>` actions, opened
|
|
10
|
+
* from a consumer-supplied trigger (typically an icon button). A close, drop-
|
|
11
|
+
* in-shaped replacement for reaching outside this library for a third-party
|
|
12
|
+
* dropdown to build a gear menu, an avatar menu, or a history row's overflow
|
|
13
|
+
* menu: click the trigger, a positioned menu appears, clicking an item both
|
|
14
|
+
* performs the action *and* closes the menu.
|
|
15
|
+
*
|
|
16
|
+
* **ARIA pattern — `role="menu"`/`role="menuitem"` with real roving DOM
|
|
17
|
+
* focus, not a listbox.** Two coherent, mutually-exclusive shapes were
|
|
18
|
+
* available here: (a) `role="listbox"`/`role="option"` with
|
|
19
|
+
* `aria-activedescendant`, the pattern `<lyra-select>`'s trigger-button +
|
|
20
|
+
* popup listbox uses, where DOM focus never leaves the trigger; or (b)
|
|
21
|
+
* `role="menu"`/`role="menuitem"` with real focus moving between actual
|
|
22
|
+
* focusable rows, the WAI-ARIA "menu button" pattern. This picks (b):
|
|
23
|
+
* `<lyra-menu-item>` rows are real, independently-focusable elements (see
|
|
24
|
+
* that class's own doc), which is the more natural fit for a menu
|
|
25
|
+
* specifically — unlike a listbox's rows, a menu's rows are conventionally
|
|
26
|
+
* button-/link-shaped, and every well-known native/OS menu (and this
|
|
27
|
+
* family's own `<lyra-tree>`/`<lyra-tree-node>` pair, which this component's
|
|
28
|
+
* roving-tabindex plumbing directly mirrors) already moves real focus rather
|
|
29
|
+
* than merely a virtual `aria-activedescendant` pointer. `role`/`tabIndex`
|
|
30
|
+
* are consistently the menu-button shape throughout — never mixed with
|
|
31
|
+
* listbox/option.
|
|
32
|
+
*
|
|
33
|
+
* Interaction contract (mirrors the WAI-ARIA APG "menu button" pattern):
|
|
34
|
+
* - Click the trigger (or Enter/Space on it, via the trigger's own native
|
|
35
|
+
* `click` activation) toggles the menu, moving focus to the first
|
|
36
|
+
* non-disabled item on open.
|
|
37
|
+
* - ArrowDown/ArrowUp on the trigger while closed also open it, focusing the
|
|
38
|
+
* first/last non-disabled item respectively.
|
|
39
|
+
* - Once open, ArrowDown/ArrowUp move the roving focus among non-disabled
|
|
40
|
+
* items (wrapping past either end — the recommended, and more common,
|
|
41
|
+
* menu-widget behavior, unlike `<lyra-select>`'s clamped listbox nav).
|
|
42
|
+
* Home/End jump to the first/last non-disabled item. Enter/Space activate
|
|
43
|
+
* the focused item. Escape closes and returns focus to the trigger. Tab
|
|
44
|
+
* closes the menu without trapping focus (the browser's own default Tab
|
|
45
|
+
* behavior proceeds untouched).
|
|
46
|
+
* - A click outside both the trigger and the open popup closes it (mirrors
|
|
47
|
+
* `<lyra-select>`'s `onDocPointer` exactly) — this does *not* refocus the
|
|
48
|
+
* trigger, since the outside click itself already moved focus somewhere
|
|
49
|
+
* the user chose; Escape and a committed selection *do* refocus the
|
|
50
|
+
* trigger, since those are dismissals with nowhere else for focus to go.
|
|
51
|
+
*
|
|
52
|
+
* The trigger element itself is read from the `trigger` slot's assigned
|
|
53
|
+
* element (first one, if several are assigned) and enhanced imperatively
|
|
54
|
+
* with `aria-haspopup="menu"`/`aria-expanded`/`aria-controls` — the same
|
|
55
|
+
* "reach into a consumer-owned light-DOM element to complete its a11y
|
|
56
|
+
* wiring" approach `<lyra-dialog>` documents for its own heading detection,
|
|
57
|
+
* necessary here because those attributes belong on the actual interactive
|
|
58
|
+
* trigger, which lives outside this component's own shadow root.
|
|
59
|
+
*
|
|
60
|
+
* The popup is always rendered (never `display:none`) so `.focus()` calls on
|
|
61
|
+
* its content work synchronously the instant it opens — visually hidden via
|
|
62
|
+
* `visibility`/`opacity` instead (identical to `<lyra-select>`'s own
|
|
63
|
+
* `[part="listbox"]`). `visibility` is an inherited CSS property that
|
|
64
|
+
* pierces the `<slot>` projection boundary, so every closed-state
|
|
65
|
+
* `<lyra-menu-item>` is automatically excluded from sequential (Tab-key)
|
|
66
|
+
* navigation with no separate JS bookkeeping.
|
|
67
|
+
*
|
|
68
|
+
* @customElement lyra-menu
|
|
69
|
+
* @slot trigger - The consumer's own trigger element (typically an icon
|
|
70
|
+
* button). Clicking it toggles the menu; it's positioned against via
|
|
71
|
+
* `internal/positioner.js`'s `place()`.
|
|
72
|
+
* @slot - `<lyra-menu-item>` elements, plus optionally plain `<hr>` dividers
|
|
73
|
+
* between groups (native `<hr>` already carries an implicit `separator`
|
|
74
|
+
* role, matching what `role="menu"` expects between item groups).
|
|
75
|
+
* @event lyra-show - The menu opened. Not fired for markup that renders
|
|
76
|
+
* `open` true from the start (mirrors `<lyra-select>`'s identical guard).
|
|
77
|
+
* @event lyra-hide - The menu closed. Same first-render guard as `lyra-show`.
|
|
78
|
+
* @event lyra-menu-select - A `<lyra-menu-item>` was activated. `detail: {
|
|
79
|
+
* value }` — the consolidated re-fire of that item's own
|
|
80
|
+
* `lyra-menu-item-select` (see `<lyra-menu-item>`'s doc for why listening
|
|
81
|
+
* here, rather than on every item, is the recommended approach). Always
|
|
82
|
+
* followed by the menu closing and focus returning to the trigger.
|
|
83
|
+
* @csspart trigger - The wrapper around the `trigger` slot (the positioning anchor).
|
|
84
|
+
* @csspart popup - The positioned floating panel.
|
|
85
|
+
* @csspart list - The `role="menu"` container wrapping the default slot.
|
|
86
|
+
*/
|
|
87
|
+
export declare class LyraMenu extends LyraElement {
|
|
88
|
+
static styles: import("lit").CSSResultGroup[];
|
|
89
|
+
/** Whether the menu is open. */
|
|
90
|
+
open: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Optional placement override forwarded to `place()`. Defaults to whatever `place()` itself
|
|
93
|
+
* defaults to. A `left`/`right` side is resolved through `rtlAwareSide` semantics (see
|
|
94
|
+
* `internal/rtl.ts`) so e.g. `placement="left-start"` still anchors to the menu's trailing edge
|
|
95
|
+
* under RTL rather than pinning to the physical left.
|
|
96
|
+
*/
|
|
97
|
+
placement?: Placement;
|
|
98
|
+
/** Accessible name for the `role="menu"` popup — override with something
|
|
99
|
+
* specific (e.g. "Row actions") when a page has more than one menu. */
|
|
100
|
+
label: string;
|
|
101
|
+
private items;
|
|
102
|
+
private activeIndex;
|
|
103
|
+
private triggerEl?;
|
|
104
|
+
private cleanup?;
|
|
105
|
+
private _isFirstUpdate;
|
|
106
|
+
private pendingFocus;
|
|
107
|
+
private readonly listId;
|
|
108
|
+
protected willUpdate(): void;
|
|
109
|
+
protected updated(changed: PropertyValues): void;
|
|
110
|
+
private reposition;
|
|
111
|
+
disconnectedCallback(): void;
|
|
112
|
+
private show;
|
|
113
|
+
/** `refocusTrigger` is only ever `true` for a dismissal with nowhere else
|
|
114
|
+
* for focus to land (Escape, a committed selection) -- see the class
|
|
115
|
+
* doc's interaction contract for why an outside click deliberately omits it. */
|
|
116
|
+
private hide;
|
|
117
|
+
private onDocPointer;
|
|
118
|
+
private onTriggerClick;
|
|
119
|
+
private onTriggerKeyDown;
|
|
120
|
+
private onTriggerSlotChange;
|
|
121
|
+
/** `aria-haspopup`/`aria-expanded`/`aria-controls` belong on the actual
|
|
122
|
+
* interactive trigger, which is consumer-owned light-DOM content outside
|
|
123
|
+
* this component's own shadow root -- see the class doc. */
|
|
124
|
+
private syncTriggerA11y;
|
|
125
|
+
private onItemsSlotChange;
|
|
126
|
+
private onItemSelect;
|
|
127
|
+
/** Flips exactly one non-disabled item's `tabIndex` to `0` (the roving
|
|
128
|
+
* target) and every other item's to `-1` -- see `<lyra-menu-item>`'s doc
|
|
129
|
+
* for why this is the sole authority over that property. */
|
|
130
|
+
private applyRovingTabIndex;
|
|
131
|
+
/** Moves the roving focus (and real DOM focus) to the first/last
|
|
132
|
+
* non-disabled item. A no-op when there are none -- focus then simply
|
|
133
|
+
* stays on the trigger (see onTriggerKeyDown's Escape safety net). */
|
|
134
|
+
private focusRoving;
|
|
135
|
+
private setActiveItem;
|
|
136
|
+
private onListKeyDown;
|
|
137
|
+
render(): TemplateResult;
|
|
138
|
+
}
|
|
139
|
+
declare global {
|
|
140
|
+
interface HTMLElementTagNameMap {
|
|
141
|
+
'lyra-menu': LyraMenu;
|
|
142
|
+
}
|
|
143
|
+
}
|