@aceshooting/lyra-ui 1.2.0 → 2.1.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 +98 -14
- package/custom-elements.json +30279 -12124
- package/dist/components/app-rail/app-rail-item.d.ts +30 -0
- package/dist/components/app-rail/app-rail-item.js +68 -0
- package/dist/components/app-rail/app-rail-item.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail-item.styles.js +65 -0
- package/dist/components/app-rail/app-rail.d.ts +168 -0
- package/dist/components/app-rail/app-rail.js +419 -0
- package/dist/components/app-rail/app-rail.styles.d.ts +1 -0
- package/dist/components/app-rail/app-rail.styles.js +128 -0
- package/dist/components/attachment-chip/attachment-chip.d.ts +141 -0
- package/dist/components/attachment-chip/attachment-chip.js +356 -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 +96 -0
- package/dist/components/attachment-trigger/attachment-trigger.js +270 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.d.ts +1 -0
- package/dist/components/attachment-trigger/attachment-trigger.styles.js +90 -0
- package/dist/components/chart/bar-chart.js +2 -18
- package/dist/components/chart/box-plot.d.ts +25 -1
- package/dist/components/chart/box-plot.js +147 -7
- package/dist/components/chart/box-plot.styles.js +13 -0
- package/dist/components/chart/bubble-chart.js +2 -18
- 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 +55 -12
- package/dist/components/chart/chart.js +247 -49
- package/dist/components/chart/doughnut-chart.js +2 -18
- package/dist/components/chart/histogram-bin.d.ts +7 -1
- package/dist/components/chart/histogram-bin.js +32 -14
- package/dist/components/chart/histogram.js +8 -16
- package/dist/components/chart/line-chart.js +2 -18
- package/dist/components/chart/lite-chart.d.ts +134 -3
- package/dist/components/chart/lite-chart.js +382 -67
- package/dist/components/chart/lite-chart.styles.js +9 -0
- package/dist/components/chart/pie-chart.js +2 -18
- package/dist/components/chart/polar-area-chart.js +2 -18
- package/dist/components/chart/radar-chart.js +2 -18
- package/dist/components/chart/scatter-chart.js +2 -18
- package/dist/components/chat-composer/chat-composer.d.ts +133 -0
- package/dist/components/chat-composer/chat-composer.js +366 -0
- package/dist/components/chat-composer/chat-composer.styles.d.ts +1 -0
- package/dist/components/chat-composer/chat-composer.styles.js +145 -0
- package/dist/components/chat-message/chat-message.d.ts +141 -0
- package/dist/components/chat-message/chat-message.js +331 -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 +117 -0
- package/dist/components/checkbox/checkbox.js +353 -0
- package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
- package/dist/components/checkbox/checkbox.styles.js +77 -0
- package/dist/components/chip/chip-group.d.ts +56 -0
- package/dist/components/chip/chip-group.js +130 -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 +122 -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 +318 -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 +127 -0
- package/dist/components/code-block/code-block.js +382 -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 +87 -0
- package/dist/components/code-block/code-loader.js +142 -0
- package/dist/components/combobox/combobox.d.ts +65 -6
- package/dist/components/combobox/combobox.js +258 -48
- package/dist/components/combobox/combobox.styles.js +3 -3
- 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 +159 -0
- package/dist/components/context-meter/context-meter.styles.d.ts +1 -0
- package/dist/components/context-meter/context-meter.styles.js +114 -0
- package/dist/components/conversation-item/conversation-item.d.ts +125 -0
- package/dist/components/conversation-item/conversation-item.js +331 -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/calendar-core.d.ts +24 -0
- package/dist/components/date-picker/calendar-core.js +51 -4
- package/dist/components/date-picker/date-input.d.ts +100 -9
- package/dist/components/date-picker/date-input.js +383 -66
- package/dist/components/date-picker/date-picker.d.ts +35 -4
- package/dist/components/date-picker/date-picker.js +171 -44
- package/dist/components/dialog/confirm.d.ts +40 -0
- package/dist/components/dialog/confirm.js +76 -0
- package/dist/components/dialog/dialog.d.ts +129 -0
- package/dist/components/dialog/dialog.js +288 -0
- package/dist/components/dialog/dialog.styles.d.ts +1 -0
- package/dist/components/dialog/dialog.styles.js +96 -0
- package/dist/components/dock-panel/dock-panel.d.ts +142 -0
- package/dist/components/dock-panel/dock-panel.js +359 -0
- package/dist/components/dock-panel/dock-panel.styles.d.ts +1 -0
- package/dist/components/dock-panel/dock-panel.styles.js +159 -0
- package/dist/components/document-preview/document-preview.d.ts +143 -0
- package/dist/components/document-preview/document-preview.js +388 -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/empty/empty.d.ts +1 -2
- package/dist/components/empty/empty.js +18 -12
- package/dist/components/empty/empty.styles.js +0 -3
- package/dist/components/export-button/csv.js +1 -1
- package/dist/components/export-button/export-button.d.ts +12 -0
- package/dist/components/export-button/export-button.js +35 -5
- package/dist/components/export-button/export-button.styles.js +5 -1
- package/dist/components/file-input/accept.js +2 -0
- package/dist/components/file-input/file-input.d.ts +10 -1
- package/dist/components/file-input/file-input.js +36 -5
- package/dist/components/flag/flag.d.ts +29 -13
- package/dist/components/flag/flag.js +54 -14
- package/dist/components/flag/flag.styles.js +1 -1
- package/dist/components/flag/language-map.d.ts +4 -1
- package/dist/components/flag/language-map.js +6 -3
- package/dist/components/gauge/gauge.d.ts +10 -1
- package/dist/components/gauge/gauge.js +41 -13
- package/dist/components/generation-status/generation-status.d.ts +117 -0
- package/dist/components/generation-status/generation-status.js +327 -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/graph/graph.d.ts +37 -3
- package/dist/components/graph/graph.js +132 -20
- package/dist/components/heatmap/calendar-grid.d.ts +19 -7
- package/dist/components/heatmap/calendar-grid.js +42 -18
- package/dist/components/heatmap/heatmap-scale.d.ts +11 -1
- package/dist/components/heatmap/heatmap-scale.js +14 -2
- package/dist/components/heatmap/heatmap.d.ts +227 -12
- package/dist/components/heatmap/heatmap.js +488 -93
- package/dist/components/json-viewer/json-viewer.d.ts +70 -0
- package/dist/components/json-viewer/json-viewer.js +361 -0
- package/dist/components/json-viewer/json-viewer.styles.d.ts +1 -0
- package/dist/components/json-viewer/json-viewer.styles.js +177 -0
- package/dist/components/kbd/kbd.d.ts +77 -0
- package/dist/components/kbd/kbd.js +231 -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 +90 -0
- package/dist/components/live-region/live-region.js +189 -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 +32 -7
- package/dist/components/map/map.js +133 -32
- package/dist/components/markdown/markdown-loader.d.ts +58 -0
- package/dist/components/markdown/markdown-loader.js +77 -0
- package/dist/components/markdown/markdown.d.ts +119 -0
- package/dist/components/markdown/markdown.js +389 -0
- package/dist/components/markdown/markdown.styles.d.ts +1 -0
- package/dist/components/markdown/markdown.styles.js +88 -0
- package/dist/components/media-card/media-card.d.ts +130 -0
- package/dist/components/media-card/media-card.js +273 -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 +203 -0
- package/dist/components/mention-popover/mention-popover.js +493 -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 +91 -0
- package/dist/components/menu/menu-item.js +206 -0
- package/dist/components/menu/menu-item.styles.d.ts +1 -0
- package/dist/components/menu/menu-item.styles.js +75 -0
- package/dist/components/menu/menu.d.ts +167 -0
- package/dist/components/menu/menu.js +461 -0
- package/dist/components/menu/menu.styles.d.ts +1 -0
- package/dist/components/menu/menu.styles.js +67 -0
- package/dist/components/model-select/model-select.d.ts +170 -0
- package/dist/components/model-select/model-select.js +588 -0
- package/dist/components/model-select/model-select.styles.d.ts +1 -0
- package/dist/components/model-select/model-select.styles.js +203 -0
- package/dist/components/model-settings-panel/model-settings-panel.d.ts +93 -0
- package/dist/components/model-settings-panel/model-settings-panel.js +209 -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 +19 -3
- package/dist/components/playback/playback.js +109 -33
- package/dist/components/playback/playback.styles.js +6 -1
- package/dist/components/responsive-panel/responsive-panel.d.ts +163 -0
- package/dist/components/responsive-panel/responsive-panel.js +363 -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 +50 -0
- package/dist/components/result-card/result-card.js +89 -0
- package/dist/components/result-card/result-card.styles.d.ts +1 -0
- package/dist/components/result-card/result-card.styles.js +49 -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 +84 -4
- package/dist/components/select/select.js +251 -36
- package/dist/components/skeleton/skeleton.d.ts +3 -0
- package/dist/components/skeleton/skeleton.js +7 -1
- package/dist/components/skeleton/skeleton.styles.js +5 -4
- package/dist/components/slider/slider.d.ts +141 -0
- package/dist/components/slider/slider.js +467 -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 +104 -0
- package/dist/components/source-card/source-card.js +195 -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 +130 -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 +58 -20
- package/dist/components/split/split.d.ts +224 -5
- package/dist/components/split/split.js +617 -43
- package/dist/components/split/split.styles.js +47 -0
- package/dist/components/stat/stat.d.ts +15 -4
- package/dist/components/stat/stat.js +53 -12
- package/dist/components/stream-status/stream-status.d.ts +126 -0
- package/dist/components/stream-status/stream-status.js +292 -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 +104 -0
- package/dist/components/streaming-text/streaming-text.js +224 -0
- package/dist/components/streaming-text/streaming-text.styles.d.ts +1 -0
- package/dist/components/streaming-text/streaming-text.styles.js +63 -0
- package/dist/components/switch/switch.d.ts +103 -0
- package/dist/components/switch/switch.js +250 -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 +89 -5
- package/dist/components/table/table.js +243 -26
- package/dist/components/table/table.styles.js +6 -1
- package/dist/components/tabs/tabs.d.ts +74 -0
- package/dist/components/tabs/tabs.js +254 -0
- package/dist/components/tabs/tabs.styles.d.ts +1 -0
- package/dist/components/tabs/tabs.styles.js +74 -0
- package/dist/components/thinking-panel/thinking-panel.d.ts +123 -0
- package/dist/components/thinking-panel/thinking-panel.js +260 -0
- package/dist/components/thinking-panel/thinking-panel.styles.d.ts +1 -0
- package/dist/components/thinking-panel/thinking-panel.styles.js +123 -0
- package/dist/components/time-range/time-range.d.ts +59 -2
- package/dist/components/time-range/time-range.js +163 -67
- package/dist/components/toast/toast-item.d.ts +12 -2
- package/dist/components/toast/toast-item.js +106 -44
- package/dist/components/toast/toast-item.styles.js +59 -28
- package/dist/components/toast/toast.js +17 -5
- package/dist/components/toast/toaster.js +10 -1
- package/dist/components/tool-approval-dialog/tool-approval-dialog.d.ts +131 -0
- package/dist/components/tool-approval-dialog/tool-approval-dialog.js +329 -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 +105 -0
- package/dist/components/tool-call-chip/tool-call-chip.js +349 -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 +206 -0
- package/dist/components/tool-param-form/tool-param-form.js +610 -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 +122 -0
- package/dist/components/tool-result-dialog/tool-result-dialog.js +358 -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 +73 -0
- package/dist/components/tool-result-view/registry.js +89 -0
- package/dist/components/tool-result-view/tool-result-view.d.ts +58 -0
- package/dist/components/tool-result-view/tool-result-view.js +152 -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 +350 -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 +191 -0
- package/dist/components/tree/tree-node.d.ts +15 -3
- package/dist/components/tree/tree-node.js +20 -7
- package/dist/components/tree/tree.d.ts +25 -10
- package/dist/components/tree/tree.js +39 -31
- package/dist/components/typing-indicator/typing-indicator.d.ts +70 -0
- package/dist/components/typing-indicator/typing-indicator.js +108 -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 +210 -0
- package/dist/components/virtual-list/virtual-list.js +607 -0
- package/dist/components/virtual-list/virtual-list.styles.d.ts +1 -0
- package/dist/components/virtual-list/virtual-list.styles.js +56 -0
- package/dist/components/widget/widget.d.ts +5 -4
- package/dist/components/widget/widget.js +54 -120
- package/dist/components/widget/widget.styles.js +8 -2
- package/dist/components/word-cloud/word-cloud-layout.d.ts +7 -0
- package/dist/components/word-cloud/word-cloud-layout.js +29 -2
- package/dist/components/word-cloud/word-cloud.d.ts +28 -2
- package/dist/components/word-cloud/word-cloud.js +69 -19
- package/dist/components/word-cloud/word-cloud.styles.js +16 -3
- package/dist/internal/anchored-validity.d.ts +1 -0
- package/dist/internal/anchored-validity.js +86 -0
- package/dist/internal/announcer.d.ts +57 -0
- package/dist/internal/announcer.js +71 -0
- package/dist/internal/form-associated.d.ts +8 -0
- package/dist/internal/form-associated.js +98 -15
- package/dist/internal/group-by-recency.d.ts +50 -0
- package/dist/internal/group-by-recency.js +80 -0
- package/dist/internal/numbers.d.ts +12 -0
- package/dist/internal/numbers.js +26 -0
- package/dist/internal/overlay-manager.d.ts +51 -0
- package/dist/internal/overlay-manager.js +523 -0
- package/dist/internal/positioner.js +27 -3
- package/dist/internal/rtl.d.ts +23 -0
- package/dist/internal/rtl.js +28 -0
- package/dist/internal/safe-url.d.ts +12 -0
- package/dist/internal/safe-url.js +41 -0
- package/dist/internal/scroll-lock.d.ts +10 -5
- package/dist/internal/scroll-lock.js +30 -14
- package/dist/internal/tokens.styles.js +22 -10
- package/dist/lyra.d.ts +133 -31
- package/dist/lyra.js +96 -26
- package/llms-full.txt +4546 -183
- package/llms.txt +21 -5
- package/package.json +41 -6
- 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
|
@@ -2,44 +2,44 @@ import { css } from 'lit';
|
|
|
2
2
|
export const styles = css `
|
|
3
3
|
:host {
|
|
4
4
|
display: block;
|
|
5
|
-
--accent-width: 4px;
|
|
6
|
-
--show-duration: var(--lyra-transition-base, 180ms ease-out);
|
|
7
|
-
--hide-duration: var(--lyra-transition-base, 180ms ease-out);
|
|
8
|
-
--padding: var(--lyra-space-m);
|
|
9
|
-
--font-size: 1rem;
|
|
10
|
-
--accent-color: var(--lyra-color-border);
|
|
5
|
+
--lyra-toast-accent-width: 4px;
|
|
6
|
+
--lyra-toast-show-duration: var(--lyra-transition-base, 180ms ease-out);
|
|
7
|
+
--lyra-toast-hide-duration: var(--lyra-transition-base, 180ms ease-out);
|
|
8
|
+
--lyra-toast-padding: var(--lyra-space-m);
|
|
9
|
+
--lyra-toast-font-size: 1rem;
|
|
10
|
+
--lyra-toast-accent-color: var(--lyra-color-border);
|
|
11
11
|
}
|
|
12
12
|
:host([variant='brand']) {
|
|
13
|
-
--accent-color: var(--lyra-color-brand);
|
|
13
|
+
--lyra-toast-accent-color: var(--lyra-color-brand);
|
|
14
14
|
}
|
|
15
15
|
:host([variant='success']) {
|
|
16
|
-
--accent-color: var(--lyra-color-success);
|
|
16
|
+
--lyra-toast-accent-color: var(--lyra-color-success);
|
|
17
17
|
}
|
|
18
18
|
:host([variant='warning']) {
|
|
19
|
-
--accent-color: var(--lyra-color-warning);
|
|
19
|
+
--lyra-toast-accent-color: var(--lyra-color-warning);
|
|
20
20
|
}
|
|
21
21
|
:host([variant='danger']) {
|
|
22
|
-
--accent-color: var(--lyra-color-danger);
|
|
22
|
+
--lyra-toast-accent-color: var(--lyra-color-danger);
|
|
23
23
|
}
|
|
24
24
|
:host([size='xs']) {
|
|
25
|
-
--padding: var(--lyra-space-xs);
|
|
26
|
-
--font-size: 0.75rem;
|
|
25
|
+
--lyra-toast-padding: var(--lyra-space-xs);
|
|
26
|
+
--lyra-toast-font-size: 0.75rem;
|
|
27
27
|
}
|
|
28
28
|
:host([size='s']) {
|
|
29
|
-
--padding: var(--lyra-space-s);
|
|
30
|
-
--font-size: 0.875rem;
|
|
29
|
+
--lyra-toast-padding: var(--lyra-space-s);
|
|
30
|
+
--lyra-toast-font-size: 0.875rem;
|
|
31
31
|
}
|
|
32
32
|
:host([size='m']) {
|
|
33
|
-
--padding: var(--lyra-space-m);
|
|
34
|
-
--font-size: 1rem;
|
|
33
|
+
--lyra-toast-padding: var(--lyra-space-m);
|
|
34
|
+
--lyra-toast-font-size: 1rem;
|
|
35
35
|
}
|
|
36
36
|
:host([size='l']) {
|
|
37
|
-
--padding: var(--lyra-space-l);
|
|
38
|
-
--font-size: 1.125rem;
|
|
37
|
+
--lyra-toast-padding: var(--lyra-space-l);
|
|
38
|
+
--lyra-toast-font-size: 1.125rem;
|
|
39
39
|
}
|
|
40
40
|
:host([size='xl']) {
|
|
41
|
-
--padding: calc(var(--lyra-space-l) * 1.5);
|
|
42
|
-
--font-size: 1.25rem;
|
|
41
|
+
--lyra-toast-padding: calc(var(--lyra-space-l) * 1.5);
|
|
42
|
+
--lyra-toast-font-size: 1.25rem;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
[part='toast-item'] {
|
|
@@ -48,9 +48,9 @@ export const styles = css `
|
|
|
48
48
|
align-items: start;
|
|
49
49
|
gap: var(--lyra-space-s);
|
|
50
50
|
inline-size: 100%;
|
|
51
|
-
padding: var(--padding);
|
|
52
|
-
padding-inline-start: calc(var(--padding) + var(--accent-width));
|
|
53
|
-
font-size: var(--font-size);
|
|
51
|
+
padding: var(--lyra-toast-padding);
|
|
52
|
+
padding-inline-start: calc(var(--lyra-toast-padding) + var(--lyra-toast-accent-width));
|
|
53
|
+
font-size: var(--lyra-toast-font-size);
|
|
54
54
|
background: var(--lyra-color-surface);
|
|
55
55
|
color: var(--lyra-color-text);
|
|
56
56
|
border: 1px solid var(--lyra-color-border);
|
|
@@ -59,8 +59,13 @@ export const styles = css `
|
|
|
59
59
|
opacity: 0;
|
|
60
60
|
transform: translateY(-8px);
|
|
61
61
|
transition:
|
|
62
|
-
opacity var(--show-duration),
|
|
63
|
-
transform var(--show-duration);
|
|
62
|
+
opacity var(--lyra-toast-show-duration),
|
|
63
|
+
transform var(--lyra-toast-show-duration);
|
|
64
|
+
}
|
|
65
|
+
:host([data-hiding]) [part='toast-item'] {
|
|
66
|
+
transition:
|
|
67
|
+
opacity var(--lyra-toast-hide-duration),
|
|
68
|
+
transform var(--lyra-toast-hide-duration);
|
|
64
69
|
}
|
|
65
70
|
:host([data-visible]) [part='toast-item'] {
|
|
66
71
|
opacity: 1;
|
|
@@ -76,20 +81,46 @@ export const styles = css `
|
|
|
76
81
|
position: absolute;
|
|
77
82
|
inset-block: 0;
|
|
78
83
|
inset-inline-start: 0;
|
|
79
|
-
inline-size: var(--accent-width);
|
|
80
|
-
background: var(--accent-color);
|
|
84
|
+
inline-size: var(--lyra-toast-accent-width);
|
|
85
|
+
background: var(--lyra-toast-accent-color);
|
|
81
86
|
border-start-start-radius: var(--lyra-radius);
|
|
82
87
|
border-end-start-radius: var(--lyra-radius);
|
|
83
88
|
}
|
|
84
89
|
[part='icon'] {
|
|
85
90
|
display: inline-flex;
|
|
86
91
|
flex: 0 0 auto;
|
|
87
|
-
color: var(--accent-color);
|
|
92
|
+
color: var(--lyra-toast-accent-color);
|
|
88
93
|
}
|
|
89
94
|
[part='content'] {
|
|
90
95
|
flex: 1 1 auto;
|
|
91
96
|
min-inline-size: 0;
|
|
92
97
|
}
|
|
98
|
+
/* toaster.ts's action option (and the WithIcon/Triggers stories) append a
|
|
99
|
+
plain light-DOM button as a sibling of the message text -- without
|
|
100
|
+
this, it renders with the browser's unstyled default button chrome,
|
|
101
|
+
clashing with the rest of the token-driven design. Styled as an inline
|
|
102
|
+
text action (matching the toast's own accent color) rather than a
|
|
103
|
+
boxed button, since it sits directly after the message inside the
|
|
104
|
+
content part rather than in its own layout slot. */
|
|
105
|
+
::slotted(button) {
|
|
106
|
+
display: inline-block;
|
|
107
|
+
margin-inline-start: var(--lyra-space-s);
|
|
108
|
+
padding: 0;
|
|
109
|
+
border: none;
|
|
110
|
+
background: none;
|
|
111
|
+
font: inherit;
|
|
112
|
+
font-weight: bold;
|
|
113
|
+
color: var(--lyra-toast-accent-color);
|
|
114
|
+
text-decoration: underline;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
}
|
|
117
|
+
::slotted(button:hover) {
|
|
118
|
+
color: var(--lyra-color-text);
|
|
119
|
+
}
|
|
120
|
+
::slotted(button:focus-visible) {
|
|
121
|
+
outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
|
|
122
|
+
outline-offset: var(--lyra-focus-ring-offset);
|
|
123
|
+
}
|
|
93
124
|
[part='close-button'] {
|
|
94
125
|
flex: 0 0 auto;
|
|
95
126
|
margin-inline-start: auto;
|
|
@@ -29,17 +29,29 @@ export class LyraToast extends LyraElement {
|
|
|
29
29
|
/** Create and append a toast item programmatically; resolves to the item. */
|
|
30
30
|
async create(message, options = {}) {
|
|
31
31
|
const item = document.createElement('lyra-toast-item');
|
|
32
|
-
|
|
33
|
-
item
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
// Only assign what the caller actually specified -- a freshly-created
|
|
33
|
+
// <lyra-toast-item> already carries its own property defaults, so
|
|
34
|
+
// falling back to a literal here (e.g. `?? 5000`) would duplicate those
|
|
35
|
+
// defaults in a second place that has no way of staying in sync if the
|
|
36
|
+
// property declaration in toast-item.ts ever changes.
|
|
37
|
+
if (options.variant !== undefined)
|
|
38
|
+
item.variant = options.variant;
|
|
39
|
+
if (options.duration !== undefined)
|
|
40
|
+
item.duration = options.duration;
|
|
41
|
+
if (options.size !== undefined)
|
|
42
|
+
item.size = options.size;
|
|
43
|
+
if (options.withIcon !== undefined)
|
|
44
|
+
item.withIcon = options.withIcon;
|
|
36
45
|
item.textContent = message;
|
|
37
46
|
this.appendChild(item);
|
|
38
47
|
await item.updateComplete;
|
|
39
48
|
return item;
|
|
40
49
|
}
|
|
41
50
|
render() {
|
|
42
|
-
|
|
51
|
+
// Each toast item owns its own status/alert role. Keeping a live region on
|
|
52
|
+
// the stack as well would nest assertive alerts inside a polite region and
|
|
53
|
+
// can cause duplicate or out-of-order announcements.
|
|
54
|
+
return html `<div part="stack"><slot></slot></div>`;
|
|
43
55
|
}
|
|
44
56
|
}
|
|
45
57
|
__decorate([
|
|
@@ -27,8 +27,17 @@ function getRegion(placement = DEFAULT_PLACEMENT) {
|
|
|
27
27
|
*/
|
|
28
28
|
export function toast(input) {
|
|
29
29
|
const opts = typeof input === 'string' ? { message: input } : input;
|
|
30
|
+
// An action must remain available until the user can reach it. Callers can
|
|
31
|
+
// still opt into a finite duration explicitly; the convenience API makes
|
|
32
|
+
// only the omitted-duration/action combination persistent.
|
|
33
|
+
const createOptions = {
|
|
34
|
+
variant: opts.variant,
|
|
35
|
+
duration: opts.duration ?? (opts.action ? 0 : undefined),
|
|
36
|
+
size: opts.size,
|
|
37
|
+
withIcon: opts.withIcon,
|
|
38
|
+
};
|
|
30
39
|
const item = getRegion(opts.placement)
|
|
31
|
-
.create(opts.message,
|
|
40
|
+
.create(opts.message, createOptions)
|
|
32
41
|
.then((el) => {
|
|
33
42
|
if (opts.action) {
|
|
34
43
|
const btn = document.createElement('button');
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
import '../json-viewer/json-viewer.js';
|
|
4
|
+
/**
|
|
5
|
+
* Reason the dialog was dismissed, forwarded as the `lyra-close` event detail
|
|
6
|
+
* -- mirrors `<lyra-dialog>`'s own `DialogCloseReason` shape. `'escape'`/
|
|
7
|
+
* `'backdrop'` come from the dialog's own built-in dismiss triggers,
|
|
8
|
+
* `'approve'`/`'deny'` from the built-in action buttons (fired in addition
|
|
9
|
+
* to, and immediately after, their own dedicated `lyra-approve`/`lyra-deny`
|
|
10
|
+
* event -- see the class doc), and any other string is whatever a caller
|
|
11
|
+
* passes to `close()` directly.
|
|
12
|
+
*/
|
|
13
|
+
export type ToolApprovalDialogCloseReason = 'escape' | 'backdrop' | 'approve' | 'deny' | 'api' | string;
|
|
14
|
+
/**
|
|
15
|
+
* `<lyra-tool-approval-dialog>` — a human-in-the-loop gate: presents one
|
|
16
|
+
* proposed tool/function call (`toolName` + `args`) and blocks an agent from
|
|
17
|
+
* executing it until a person explicitly approves or denies it, with an
|
|
18
|
+
* optional inline "edit the arguments before approving" step.
|
|
19
|
+
*
|
|
20
|
+
* This renders its own dialog panel rather than nesting a `<lyra-dialog>` in
|
|
21
|
+
* its shadow template. Shared overlay infrastructure coordinates stacking,
|
|
22
|
+
* focus trapping, Escape/backdrop dismissal, and focus return with every
|
|
23
|
+
* other overlay in the same document.
|
|
24
|
+
*
|
|
25
|
+
* Approve/Deny/Edit are built-in chrome (not a `footer` slot a consumer must
|
|
26
|
+
* assemble) — this component's interaction shape is fixed enough (there is
|
|
27
|
+
* exactly one correct set of actions for "approve this call") that requiring
|
|
28
|
+
* every consumer to re-build it would just be boilerplate. A `footer` slot is
|
|
29
|
+
* still offered for *supplementary* content a consumer wants alongside those
|
|
30
|
+
* buttons (e.g. a "remember this choice for this tool" checkbox) — its
|
|
31
|
+
* content renders to the start of the action row, before Deny/Edit/Approve.
|
|
32
|
+
*
|
|
33
|
+
* Editing: while `editable`, an Edit button swaps the read-only
|
|
34
|
+
* `<lyra-json-viewer>` for a plain `<textarea>` pre-filled with
|
|
35
|
+
* `JSON.stringify(args, null, 2)`. Every keystroke is re-validated with
|
|
36
|
+
* `JSON.parse` — the Approve button is `disabled` for as long as the current
|
|
37
|
+
* textarea content fails to parse, so a malformed edit can never be silently
|
|
38
|
+
* approved as either the broken text or a stale copy of the original args.
|
|
39
|
+
* The same button relabels to "Cancel" while editing; clicking it discards
|
|
40
|
+
* the draft entirely and returns to the read-only view of the *original*
|
|
41
|
+
* `args` — there is no separate "save" step independent of Approve itself.
|
|
42
|
+
* Both `editing` and any in-progress draft reset back to the read-only view
|
|
43
|
+
* every time the dialog transitions from closed to open, so a reused
|
|
44
|
+
* instance never leaks one proposal's half-finished edit into the next.
|
|
45
|
+
* `editable` flipping to `false` mid-edit does the same (see `willUpdate()`)
|
|
46
|
+
* and, if the textarea it unmounts still held focus, `updated()` refocuses
|
|
47
|
+
* Deny so the focus trap keeps engaging instead of silently letting focus
|
|
48
|
+
* fall through to the document.
|
|
49
|
+
*
|
|
50
|
+
* Initial focus deliberately does *not* land on Approve:
|
|
51
|
+
* approving a tool call is a consequential, potentially irreversible action,
|
|
52
|
+
* so a user who opens this dialog and reflexively presses Enter/Space before
|
|
53
|
+
* reading anything should deny, not approve. Deny gets the initial focus
|
|
54
|
+
* instead — the same "focus the safe action" convention a native destructive-
|
|
55
|
+
* confirmation dialog (delete, discard, etc.) typically follows for its own
|
|
56
|
+
* Cancel button — rather than the inert dialog panel, which would need an
|
|
57
|
+
* extra Tab press before *any* action is reachable at all.
|
|
58
|
+
*
|
|
59
|
+
* @customElement lyra-tool-approval-dialog
|
|
60
|
+
* @slot footer - Optional supplementary content (e.g. a "remember this
|
|
61
|
+
* choice" checkbox), rendered before the built-in Deny/Edit/Approve buttons.
|
|
62
|
+
* @event lyra-approve - The call was approved. `detail: { args }` — the
|
|
63
|
+
* current, already-parsed arguments object: the original `args` prop, or (if
|
|
64
|
+
* an edit was in progress) the user's edited-and-validated version. Always
|
|
65
|
+
* followed by `lyra-close` with reason `'approve'`.
|
|
66
|
+
* @event lyra-deny - The call was denied (no detail). Always followed by
|
|
67
|
+
* `lyra-close` with reason `'deny'`.
|
|
68
|
+
* @event lyra-close - `detail: ToolApprovalDialogCloseReason`. Fired exactly
|
|
69
|
+
* once per dismissal — via Escape, a backdrop click, the Approve/Deny
|
|
70
|
+
* buttons, or a `close()` call — so there is one consistent "this dialog is
|
|
71
|
+
* now closed" signal regardless of which path triggered it.
|
|
72
|
+
* @csspart backdrop - The full-viewport scrim behind the panel.
|
|
73
|
+
* @csspart panel - The dialog panel itself (`role="dialog"` while open).
|
|
74
|
+
* @csspart header - The wrapper around the heading.
|
|
75
|
+
* @csspart tool-name - The `toolName` text within the heading.
|
|
76
|
+
* @csspart body - The wrapper around the args view/editor.
|
|
77
|
+
* @csspart args-view - The read-only `<lyra-json-viewer>` shown while not editing.
|
|
78
|
+
* @csspart args-editor - The raw-JSON `<textarea>` shown while editing.
|
|
79
|
+
* @csspart error - The inline "invalid JSON" message, shown only while editing with unparseable content.
|
|
80
|
+
* @csspart footer - The action row wrapping the `footer` slot and the built-in buttons.
|
|
81
|
+
* @csspart deny-button - The built-in Deny button.
|
|
82
|
+
* @csspart edit-button - The built-in Edit/Cancel toggle button (only rendered while `editable`).
|
|
83
|
+
* @csspart approve-button - The built-in Approve button — `disabled` while an in-progress edit is invalid JSON.
|
|
84
|
+
*/
|
|
85
|
+
export declare class LyraToolApprovalDialog extends LyraElement {
|
|
86
|
+
static styles: import("lit").CSSResultGroup[];
|
|
87
|
+
/** Whether the dialog is open. Set this (or call `close()`) — there is no separate `show()`/`hide()` pair. */
|
|
88
|
+
open: boolean;
|
|
89
|
+
/** The proposed tool/function's name, e.g. `web_search`. Drives the heading and the dialog's accessible name. */
|
|
90
|
+
toolName: string;
|
|
91
|
+
/** The proposed call's arguments — any JSON-serializable value, rendered via `<lyra-json-viewer>` (or, while editing, stringified into the textarea). */
|
|
92
|
+
args: unknown;
|
|
93
|
+
/** Whether an "Edit" affordance is offered at all. When `false`, `args` is always shown read-only and can never be changed before approval. */
|
|
94
|
+
editable: boolean;
|
|
95
|
+
private editing;
|
|
96
|
+
/** The textarea's current raw text while editing — deliberately independent of `args` until Approve is pressed, so a malformed in-progress edit never overwrites it. */
|
|
97
|
+
private draftText;
|
|
98
|
+
/** `JSON.parse` failure message for `draftText`, or `''` while it parses cleanly. Empty string (not `undefined`) so it can drive `?hidden` directly. */
|
|
99
|
+
private draftError;
|
|
100
|
+
private releaseScrollLock?;
|
|
101
|
+
private overlay?;
|
|
102
|
+
private readonly titleId;
|
|
103
|
+
private readonly errorId;
|
|
104
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
105
|
+
protected updated(changed: PropertyValues): void;
|
|
106
|
+
connectedCallback(): void;
|
|
107
|
+
disconnectedCallback(): void;
|
|
108
|
+
private activateOverlay;
|
|
109
|
+
/**
|
|
110
|
+
* Close the dialog and return focus to whatever had it before the dialog
|
|
111
|
+
* opened. `reason` is forwarded as the `lyra-close` detail — built-in
|
|
112
|
+
* triggers pass `'escape'`/`'backdrop'`/`'approve'`/`'deny'`; a consumer's
|
|
113
|
+
* own close affordance (e.g. a footer-slotted button) should call this
|
|
114
|
+
* directly with its own reason string, so every dismissal path funnels
|
|
115
|
+
* through the same event instead of the consumer having to also toggle
|
|
116
|
+
* `open` itself.
|
|
117
|
+
*/
|
|
118
|
+
close(reason?: ToolApprovalDialogCloseReason): void;
|
|
119
|
+
private onBackdropClick;
|
|
120
|
+
private stringifyArgs;
|
|
121
|
+
private toggleEdit;
|
|
122
|
+
private onDraftInput;
|
|
123
|
+
private onApprove;
|
|
124
|
+
private onDeny;
|
|
125
|
+
render(): TemplateResult;
|
|
126
|
+
}
|
|
127
|
+
declare global {
|
|
128
|
+
interface HTMLElementTagNameMap {
|
|
129
|
+
'lyra-tool-approval-dialog': LyraToolApprovalDialog;
|
|
130
|
+
}
|
|
131
|
+
}
|
|
@@ -0,0 +1,329 @@
|
|
|
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 { activateOverlay } from '../../internal/overlay-manager.js';
|
|
11
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
12
|
+
import { lockScroll } from '../../internal/scroll-lock.js';
|
|
13
|
+
import { nextId } from '../../internal/a11y.js';
|
|
14
|
+
import { styles } from './tool-approval-dialog.styles.js';
|
|
15
|
+
import '../json-viewer/json-viewer.js';
|
|
16
|
+
/**
|
|
17
|
+
* `<lyra-tool-approval-dialog>` — a human-in-the-loop gate: presents one
|
|
18
|
+
* proposed tool/function call (`toolName` + `args`) and blocks an agent from
|
|
19
|
+
* executing it until a person explicitly approves or denies it, with an
|
|
20
|
+
* optional inline "edit the arguments before approving" step.
|
|
21
|
+
*
|
|
22
|
+
* This renders its own dialog panel rather than nesting a `<lyra-dialog>` in
|
|
23
|
+
* its shadow template. Shared overlay infrastructure coordinates stacking,
|
|
24
|
+
* focus trapping, Escape/backdrop dismissal, and focus return with every
|
|
25
|
+
* other overlay in the same document.
|
|
26
|
+
*
|
|
27
|
+
* Approve/Deny/Edit are built-in chrome (not a `footer` slot a consumer must
|
|
28
|
+
* assemble) — this component's interaction shape is fixed enough (there is
|
|
29
|
+
* exactly one correct set of actions for "approve this call") that requiring
|
|
30
|
+
* every consumer to re-build it would just be boilerplate. A `footer` slot is
|
|
31
|
+
* still offered for *supplementary* content a consumer wants alongside those
|
|
32
|
+
* buttons (e.g. a "remember this choice for this tool" checkbox) — its
|
|
33
|
+
* content renders to the start of the action row, before Deny/Edit/Approve.
|
|
34
|
+
*
|
|
35
|
+
* Editing: while `editable`, an Edit button swaps the read-only
|
|
36
|
+
* `<lyra-json-viewer>` for a plain `<textarea>` pre-filled with
|
|
37
|
+
* `JSON.stringify(args, null, 2)`. Every keystroke is re-validated with
|
|
38
|
+
* `JSON.parse` — the Approve button is `disabled` for as long as the current
|
|
39
|
+
* textarea content fails to parse, so a malformed edit can never be silently
|
|
40
|
+
* approved as either the broken text or a stale copy of the original args.
|
|
41
|
+
* The same button relabels to "Cancel" while editing; clicking it discards
|
|
42
|
+
* the draft entirely and returns to the read-only view of the *original*
|
|
43
|
+
* `args` — there is no separate "save" step independent of Approve itself.
|
|
44
|
+
* Both `editing` and any in-progress draft reset back to the read-only view
|
|
45
|
+
* every time the dialog transitions from closed to open, so a reused
|
|
46
|
+
* instance never leaks one proposal's half-finished edit into the next.
|
|
47
|
+
* `editable` flipping to `false` mid-edit does the same (see `willUpdate()`)
|
|
48
|
+
* and, if the textarea it unmounts still held focus, `updated()` refocuses
|
|
49
|
+
* Deny so the focus trap keeps engaging instead of silently letting focus
|
|
50
|
+
* fall through to the document.
|
|
51
|
+
*
|
|
52
|
+
* Initial focus deliberately does *not* land on Approve:
|
|
53
|
+
* approving a tool call is a consequential, potentially irreversible action,
|
|
54
|
+
* so a user who opens this dialog and reflexively presses Enter/Space before
|
|
55
|
+
* reading anything should deny, not approve. Deny gets the initial focus
|
|
56
|
+
* instead — the same "focus the safe action" convention a native destructive-
|
|
57
|
+
* confirmation dialog (delete, discard, etc.) typically follows for its own
|
|
58
|
+
* Cancel button — rather than the inert dialog panel, which would need an
|
|
59
|
+
* extra Tab press before *any* action is reachable at all.
|
|
60
|
+
*
|
|
61
|
+
* @customElement lyra-tool-approval-dialog
|
|
62
|
+
* @slot footer - Optional supplementary content (e.g. a "remember this
|
|
63
|
+
* choice" checkbox), rendered before the built-in Deny/Edit/Approve buttons.
|
|
64
|
+
* @event lyra-approve - The call was approved. `detail: { args }` — the
|
|
65
|
+
* current, already-parsed arguments object: the original `args` prop, or (if
|
|
66
|
+
* an edit was in progress) the user's edited-and-validated version. Always
|
|
67
|
+
* followed by `lyra-close` with reason `'approve'`.
|
|
68
|
+
* @event lyra-deny - The call was denied (no detail). Always followed by
|
|
69
|
+
* `lyra-close` with reason `'deny'`.
|
|
70
|
+
* @event lyra-close - `detail: ToolApprovalDialogCloseReason`. Fired exactly
|
|
71
|
+
* once per dismissal — via Escape, a backdrop click, the Approve/Deny
|
|
72
|
+
* buttons, or a `close()` call — so there is one consistent "this dialog is
|
|
73
|
+
* now closed" signal regardless of which path triggered it.
|
|
74
|
+
* @csspart backdrop - The full-viewport scrim behind the panel.
|
|
75
|
+
* @csspart panel - The dialog panel itself (`role="dialog"` while open).
|
|
76
|
+
* @csspart header - The wrapper around the heading.
|
|
77
|
+
* @csspart tool-name - The `toolName` text within the heading.
|
|
78
|
+
* @csspart body - The wrapper around the args view/editor.
|
|
79
|
+
* @csspart args-view - The read-only `<lyra-json-viewer>` shown while not editing.
|
|
80
|
+
* @csspart args-editor - The raw-JSON `<textarea>` shown while editing.
|
|
81
|
+
* @csspart error - The inline "invalid JSON" message, shown only while editing with unparseable content.
|
|
82
|
+
* @csspart footer - The action row wrapping the `footer` slot and the built-in buttons.
|
|
83
|
+
* @csspart deny-button - The built-in Deny button.
|
|
84
|
+
* @csspart edit-button - The built-in Edit/Cancel toggle button (only rendered while `editable`).
|
|
85
|
+
* @csspart approve-button - The built-in Approve button — `disabled` while an in-progress edit is invalid JSON.
|
|
86
|
+
*/
|
|
87
|
+
export class LyraToolApprovalDialog extends LyraElement {
|
|
88
|
+
constructor() {
|
|
89
|
+
super(...arguments);
|
|
90
|
+
/** Whether the dialog is open. Set this (or call `close()`) — there is no separate `show()`/`hide()` pair. */
|
|
91
|
+
this.open = false;
|
|
92
|
+
/** The proposed tool/function's name, e.g. `web_search`. Drives the heading and the dialog's accessible name. */
|
|
93
|
+
this.toolName = '';
|
|
94
|
+
/** The proposed call's arguments — any JSON-serializable value, rendered via `<lyra-json-viewer>` (or, while editing, stringified into the textarea). */
|
|
95
|
+
this.args = {};
|
|
96
|
+
/** Whether an "Edit" affordance is offered at all. When `false`, `args` is always shown read-only and can never be changed before approval. */
|
|
97
|
+
this.editable = true;
|
|
98
|
+
this.editing = false;
|
|
99
|
+
/** The textarea's current raw text while editing — deliberately independent of `args` until Approve is pressed, so a malformed in-progress edit never overwrites it. */
|
|
100
|
+
this.draftText = '';
|
|
101
|
+
/** `JSON.parse` failure message for `draftText`, or `''` while it parses cleanly. Empty string (not `undefined`) so it can drive `?hidden` directly. */
|
|
102
|
+
this.draftError = '';
|
|
103
|
+
this.titleId = nextId('tool-approval-dialog-title');
|
|
104
|
+
this.errorId = nextId('tool-approval-dialog-error');
|
|
105
|
+
this.onBackdropClick = () => {
|
|
106
|
+
this.overlay?.dismissBackdrop();
|
|
107
|
+
};
|
|
108
|
+
this.toggleEdit = () => {
|
|
109
|
+
if (this.editing) {
|
|
110
|
+
this.editing = false;
|
|
111
|
+
this.draftText = '';
|
|
112
|
+
this.draftError = '';
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
this.editing = true;
|
|
116
|
+
this.draftText = this.stringifyArgs();
|
|
117
|
+
this.draftError = '';
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
this.onDraftInput = (e) => {
|
|
121
|
+
const value = e.target.value;
|
|
122
|
+
this.draftText = value;
|
|
123
|
+
try {
|
|
124
|
+
JSON.parse(value);
|
|
125
|
+
this.draftError = '';
|
|
126
|
+
}
|
|
127
|
+
catch (err) {
|
|
128
|
+
this.draftError = err instanceof Error ? err.message : 'Invalid JSON.';
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
this.onApprove = () => {
|
|
132
|
+
let currentArgs = this.args;
|
|
133
|
+
if (this.editing) {
|
|
134
|
+
// The Approve button is disabled whenever draftError is non-empty, so
|
|
135
|
+
// this should always succeed -- the try/catch is defense-in-depth
|
|
136
|
+
// against a state desync rather than an expected path.
|
|
137
|
+
try {
|
|
138
|
+
currentArgs = JSON.parse(this.draftText);
|
|
139
|
+
}
|
|
140
|
+
catch {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
this.emit('lyra-approve', { args: currentArgs });
|
|
145
|
+
this.close('approve');
|
|
146
|
+
};
|
|
147
|
+
this.onDeny = () => {
|
|
148
|
+
this.emit('lyra-deny');
|
|
149
|
+
this.close('deny');
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
153
|
+
willUpdate(changed) {
|
|
154
|
+
if (changed.has('open')) {
|
|
155
|
+
if (this.open) {
|
|
156
|
+
this.releaseScrollLock ??= lockScroll(this.ownerDocument);
|
|
157
|
+
this.activateOverlay();
|
|
158
|
+
// Every open starts fresh in the read-only view -- a reused instance
|
|
159
|
+
// must never carry a half-finished edit (or its error state) over
|
|
160
|
+
// from whatever the previous proposal was.
|
|
161
|
+
this.editing = false;
|
|
162
|
+
this.draftText = '';
|
|
163
|
+
this.draftError = '';
|
|
164
|
+
}
|
|
165
|
+
else {
|
|
166
|
+
this.releaseScrollLock?.();
|
|
167
|
+
this.releaseScrollLock = undefined;
|
|
168
|
+
this.overlay?.deactivate();
|
|
169
|
+
this.overlay = undefined;
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
// A consumer flipping editable off mid-edit (e.g. a policy change
|
|
173
|
+
// pushed while this dialog happens to be open) must not leave an
|
|
174
|
+
// unreachable edit UI on screen with no Edit/Cancel button left to
|
|
175
|
+
// dismiss it.
|
|
176
|
+
if (changed.has('editable') && !this.editable && this.editing) {
|
|
177
|
+
this.editing = false;
|
|
178
|
+
this.draftText = '';
|
|
179
|
+
this.draftError = '';
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Runs after render (not willUpdate) so [part="panel"]/[part="deny-button"]
|
|
183
|
+
// have already landed in the DOM before the focus calls below can rely on
|
|
184
|
+
// them -- mirrors lyra-dialog's identical ordering rationale.
|
|
185
|
+
updated(changed) {
|
|
186
|
+
if (changed.has('open') && this.open) {
|
|
187
|
+
this.overlay?.focusInitial();
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
if (changed.has('editing')) {
|
|
191
|
+
if (this.editing) {
|
|
192
|
+
// Entering edit mode is a deliberate request to start typing --
|
|
193
|
+
// steering focus into the textarea beats leaving it on the Edit
|
|
194
|
+
// button the click already left it on.
|
|
195
|
+
this.shadowRoot?.querySelector('[part="args-editor"]')?.focus();
|
|
196
|
+
}
|
|
197
|
+
else if (this.open && !this.shadowRoot?.activeElement) {
|
|
198
|
+
// Reached when editing was turned off some way other than clicking
|
|
199
|
+
// Cancel (e.g. `editable` flipping to false while the textarea held
|
|
200
|
+
// focus, in willUpdate above) -- the textarea that held focus was
|
|
201
|
+
// just unmounted without anything else claiming it, which would
|
|
202
|
+
// otherwise drop focus to <body> and silently stop the Tab trap
|
|
203
|
+
// from engaging. Refocus a stable target inside the panel instead.
|
|
204
|
+
this.shadowRoot?.querySelector('[part="deny-button"]')?.focus();
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
connectedCallback() {
|
|
209
|
+
super.connectedCallback();
|
|
210
|
+
if (this.hasUpdated && this.open) {
|
|
211
|
+
this.releaseScrollLock ??= lockScroll(this.ownerDocument);
|
|
212
|
+
this.activateOverlay();
|
|
213
|
+
queueMicrotask(() => this.overlay?.focusInitial());
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
disconnectedCallback() {
|
|
217
|
+
super.disconnectedCallback();
|
|
218
|
+
this.releaseScrollLock?.();
|
|
219
|
+
this.releaseScrollLock = undefined;
|
|
220
|
+
this.overlay?.suspend();
|
|
221
|
+
}
|
|
222
|
+
activateOverlay() {
|
|
223
|
+
if (this.overlay?.isActive()) {
|
|
224
|
+
this.overlay.resume();
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
this.overlay = activateOverlay({
|
|
228
|
+
host: this,
|
|
229
|
+
panel: () => this.shadowRoot?.querySelector('[part="panel"]') ?? null,
|
|
230
|
+
onEscape: () => this.close('escape'),
|
|
231
|
+
onBackdrop: () => this.close('backdrop'),
|
|
232
|
+
preferredInitialFocus: () => this.shadowRoot?.querySelector('[part="deny-button"]') ?? null,
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Close the dialog and return focus to whatever had it before the dialog
|
|
237
|
+
* opened. `reason` is forwarded as the `lyra-close` detail — built-in
|
|
238
|
+
* triggers pass `'escape'`/`'backdrop'`/`'approve'`/`'deny'`; a consumer's
|
|
239
|
+
* own close affordance (e.g. a footer-slotted button) should call this
|
|
240
|
+
* directly with its own reason string, so every dismissal path funnels
|
|
241
|
+
* through the same event instead of the consumer having to also toggle
|
|
242
|
+
* `open` itself.
|
|
243
|
+
*/
|
|
244
|
+
close(reason = 'api') {
|
|
245
|
+
if (!this.open)
|
|
246
|
+
return;
|
|
247
|
+
this.open = false;
|
|
248
|
+
this.emit('lyra-close', reason);
|
|
249
|
+
}
|
|
250
|
+
stringifyArgs() {
|
|
251
|
+
try {
|
|
252
|
+
// JSON.stringify(undefined, ...) returns the *value* undefined, not a
|
|
253
|
+
// string -- the ?? covers that alongside the try/catch's circular-
|
|
254
|
+
// reference case, so the textarea always opens with real text.
|
|
255
|
+
return JSON.stringify(this.args, null, 2) ?? 'null';
|
|
256
|
+
}
|
|
257
|
+
catch {
|
|
258
|
+
return 'null';
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
render() {
|
|
262
|
+
const hasError = this.editing && this.draftError.length > 0;
|
|
263
|
+
return html `
|
|
264
|
+
<div part="backdrop" @click=${this.onBackdropClick}></div>
|
|
265
|
+
<div
|
|
266
|
+
part="panel"
|
|
267
|
+
role=${this.open ? 'dialog' : nothing}
|
|
268
|
+
aria-modal=${this.open ? 'true' : nothing}
|
|
269
|
+
aria-labelledby=${this.titleId}
|
|
270
|
+
tabindex="-1"
|
|
271
|
+
>
|
|
272
|
+
<div part="header">
|
|
273
|
+
<h2 id=${this.titleId}>Approve <span part="tool-name">${this.toolName || 'tool'}</span> call?</h2>
|
|
274
|
+
</div>
|
|
275
|
+
<div part="body">
|
|
276
|
+
${this.editing
|
|
277
|
+
? html `
|
|
278
|
+
<textarea
|
|
279
|
+
part="args-editor"
|
|
280
|
+
spellcheck="false"
|
|
281
|
+
autocomplete="off"
|
|
282
|
+
aria-label="Tool call arguments (JSON)"
|
|
283
|
+
aria-invalid=${hasError ? 'true' : 'false'}
|
|
284
|
+
aria-describedby=${hasError ? this.errorId : nothing}
|
|
285
|
+
.value=${this.draftText}
|
|
286
|
+
@input=${this.onDraftInput}
|
|
287
|
+
></textarea>
|
|
288
|
+
<p part="error" id=${this.errorId} role="alert" ?hidden=${!hasError}>${this.draftError}</p>
|
|
289
|
+
`
|
|
290
|
+
: html `<lyra-json-viewer part="args-view" .data=${this.args}></lyra-json-viewer>`}
|
|
291
|
+
</div>
|
|
292
|
+
<div part="footer">
|
|
293
|
+
<slot name="footer"></slot>
|
|
294
|
+
<button part="deny-button" type="button" @click=${this.onDeny}>Deny</button>
|
|
295
|
+
${this.editable
|
|
296
|
+
? html `<button part="edit-button" type="button" @click=${this.toggleEdit}>
|
|
297
|
+
${this.editing ? 'Cancel' : 'Edit'}
|
|
298
|
+
</button>`
|
|
299
|
+
: nothing}
|
|
300
|
+
<button part="approve-button" type="button" ?disabled=${hasError} @click=${this.onApprove}>
|
|
301
|
+
Approve
|
|
302
|
+
</button>
|
|
303
|
+
</div>
|
|
304
|
+
</div>
|
|
305
|
+
`;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
__decorate([
|
|
309
|
+
property({ type: Boolean, reflect: true })
|
|
310
|
+
], LyraToolApprovalDialog.prototype, "open", void 0);
|
|
311
|
+
__decorate([
|
|
312
|
+
property({ attribute: 'tool-name' })
|
|
313
|
+
], LyraToolApprovalDialog.prototype, "toolName", void 0);
|
|
314
|
+
__decorate([
|
|
315
|
+
property({ attribute: false })
|
|
316
|
+
], LyraToolApprovalDialog.prototype, "args", void 0);
|
|
317
|
+
__decorate([
|
|
318
|
+
property({ type: Boolean, reflect: true })
|
|
319
|
+
], LyraToolApprovalDialog.prototype, "editable", void 0);
|
|
320
|
+
__decorate([
|
|
321
|
+
state()
|
|
322
|
+
], LyraToolApprovalDialog.prototype, "editing", void 0);
|
|
323
|
+
__decorate([
|
|
324
|
+
state()
|
|
325
|
+
], LyraToolApprovalDialog.prototype, "draftText", void 0);
|
|
326
|
+
__decorate([
|
|
327
|
+
state()
|
|
328
|
+
], LyraToolApprovalDialog.prototype, "draftError", void 0);
|
|
329
|
+
defineElement('tool-approval-dialog', LyraToolApprovalDialog);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|