@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
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type TemplateResult, type PropertyValues } from 'lit';
|
|
2
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
3
|
+
/**
|
|
4
|
+
* `<lyra-json-viewer>` — a collapsible, copyable tree view for an arbitrary
|
|
5
|
+
* JSON-serializable value (object/array/string/number/boolean/null/
|
|
6
|
+
* undefined). Serves as the fallback renderer wherever a raw payload (tool
|
|
7
|
+
* call arguments, a tool result, an API response) needs inspecting without a
|
|
8
|
+
* bespoke view.
|
|
9
|
+
*
|
|
10
|
+
* Expand/collapse state is keyed by structural path (not by object identity),
|
|
11
|
+
* so it survives a `data` reassignment that keeps the same shape -- e.g. a
|
|
12
|
+
* streaming tool result being patched in place.
|
|
13
|
+
*
|
|
14
|
+
* @customElement lyra-json-viewer
|
|
15
|
+
* @event lyra-copy - `detail: { text }` -- fired by the top-level copy button or a per-node one. Fires even when `navigator.clipboard` silently failed or is unavailable (insecure context, older browser, stubbed-out test environment), so a consumer can still observe copy *intent*.
|
|
16
|
+
* @csspart base - The root scroll container; respects `max-height`.
|
|
17
|
+
* @csspart toolbar - The wrapper around the top-level copy button (only rendered when `copyable`).
|
|
18
|
+
* @csspart tree - The wrapper around the rendered node tree.
|
|
19
|
+
* @csspart key - An object property key or array index label.
|
|
20
|
+
* @csspart value - A primitive value's text -- carries `data-type` (`string`/`number`/`boolean`/`null`/`undefined`, or `circular` for a self-reference marker in place of a re-visited container's subtree) for per-type coloring, and `data-match` while it matches `search`.
|
|
21
|
+
* @csspart bracket - A `{`, `}`, `[`, or `]` delimiter.
|
|
22
|
+
* @csspart toggle - A container node's expand/collapse button (hidden, but present for row alignment, on leaf/empty nodes).
|
|
23
|
+
* @csspart copy-button - A copy-to-clipboard button -- the top-level one (in `toolbar`, labelled "Copy JSON to clipboard") or a per-node one (only rendered when `copyable`; labelled with its own key/type, e.g. "Copy age", so assistive tech can tell rows apart).
|
|
24
|
+
*/
|
|
25
|
+
export declare class LyraJsonViewer extends LyraElement {
|
|
26
|
+
static styles: import("lit").CSSResultGroup[];
|
|
27
|
+
/** The value to render. Any JSON-serializable value, plus `undefined`. */
|
|
28
|
+
data: unknown;
|
|
29
|
+
/** Nodes at or beyond this nesting depth (root = 0) start collapsed. Omit/undefined: nothing auto-collapses. */
|
|
30
|
+
collapsedDepth?: number;
|
|
31
|
+
/** A CSS length (e.g. `"20rem"`); once set, the viewer scrolls internally past this height instead of growing the page. */
|
|
32
|
+
maxHeight: string;
|
|
33
|
+
/** Shows copy-to-clipboard affordances: one for the whole value, plus one per node. */
|
|
34
|
+
copyable: boolean;
|
|
35
|
+
/** Case-insensitive substring match against keys/values; matches are highlighted and their ancestors auto-expanded. */
|
|
36
|
+
search: string;
|
|
37
|
+
/**
|
|
38
|
+
* Per-path (`JSON.stringify(path)`) explicit expand/collapse, overriding
|
|
39
|
+
* the `collapsedDepth`/search defaults once a node's toggle has been used.
|
|
40
|
+
* Pruned in `willUpdate()` (to the paths still reachable in the tree)
|
|
41
|
+
* whenever `data` changes, so a long-lived instance bound to reshaping
|
|
42
|
+
* data -- this component's own stated streaming use case -- doesn't
|
|
43
|
+
* accumulate one entry per path ever toggled for the life of the instance.
|
|
44
|
+
*/
|
|
45
|
+
private expandedOverrides;
|
|
46
|
+
/** Memoized result of the last `computeSearch()` walk -- see `willUpdate()`. */
|
|
47
|
+
private searchState;
|
|
48
|
+
private isExpanded;
|
|
49
|
+
private toggleNode;
|
|
50
|
+
private writeClipboard;
|
|
51
|
+
private copy;
|
|
52
|
+
/**
|
|
53
|
+
* Builds the key/value-match sets, the ancestor-paths-of-a-match set that
|
|
54
|
+
* `search` drives, and the full set of path keys reachable in the tree
|
|
55
|
+
* (`paths`, used to prune `expandedOverrides` -- see `willUpdate()`).
|
|
56
|
+
* Guards against a self-referencing `data` the same way `renderNode()`
|
|
57
|
+
* does: a container value already on the current recursion path is
|
|
58
|
+
* treated as a leaf instead of being walked again.
|
|
59
|
+
*/
|
|
60
|
+
private computeSearch;
|
|
61
|
+
private renderCopyButton;
|
|
62
|
+
private renderNode;
|
|
63
|
+
protected willUpdate(changed: PropertyValues): void;
|
|
64
|
+
render(): TemplateResult;
|
|
65
|
+
}
|
|
66
|
+
declare global {
|
|
67
|
+
interface HTMLElementTagNameMap {
|
|
68
|
+
'lyra-json-viewer': LyraJsonViewer;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,361 @@
|
|
|
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 { repeat } from 'lit/directives/repeat.js';
|
|
10
|
+
import { LyraElement } from '../../internal/lyra-element.js';
|
|
11
|
+
import { defineElement } from '../../internal/prefix.js';
|
|
12
|
+
import { chevronIcon } from '../../internal/icons.js';
|
|
13
|
+
import { styles } from './json-viewer.styles.js';
|
|
14
|
+
const EMPTY_SEARCH = {
|
|
15
|
+
keyMatches: new Set(),
|
|
16
|
+
valueMatches: new Set(),
|
|
17
|
+
forceExpand: new Set(),
|
|
18
|
+
paths: new Set(),
|
|
19
|
+
};
|
|
20
|
+
function isPlainContainer(value) {
|
|
21
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
22
|
+
}
|
|
23
|
+
/** `[key, value]` pairs for an object's own enumerable properties or an array's indices; `[]` for anything else. */
|
|
24
|
+
function entriesOf(value) {
|
|
25
|
+
if (Array.isArray(value))
|
|
26
|
+
return value.map((v, i) => [i, v]);
|
|
27
|
+
if (isPlainContainer(value))
|
|
28
|
+
return Object.entries(value);
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
function valueType(value) {
|
|
32
|
+
if (value === null)
|
|
33
|
+
return 'null';
|
|
34
|
+
if (value === undefined)
|
|
35
|
+
return 'undefined';
|
|
36
|
+
if (Array.isArray(value))
|
|
37
|
+
return 'array';
|
|
38
|
+
const t = typeof value;
|
|
39
|
+
if (t === 'string' || t === 'number' || t === 'boolean')
|
|
40
|
+
return t;
|
|
41
|
+
if (t === 'object')
|
|
42
|
+
return 'object';
|
|
43
|
+
// function/symbol/bigint -- not valid JSON, but rendering *something*
|
|
44
|
+
// sensible beats throwing on a value a caller handed us by mistake.
|
|
45
|
+
return 'string';
|
|
46
|
+
}
|
|
47
|
+
function formatPrimitive(value, type) {
|
|
48
|
+
switch (type) {
|
|
49
|
+
case 'string':
|
|
50
|
+
// `type` here also covers valueType()'s function/symbol/bigint
|
|
51
|
+
// fallback (see the comment there) -- JSON.stringify() throws a
|
|
52
|
+
// TypeError for a BigInt, so only an actual string gets the
|
|
53
|
+
// quoted/escaped treatment; everything else falls back to a plain
|
|
54
|
+
// String() coercion, which renders "sensibly" without throwing.
|
|
55
|
+
return typeof value === 'string' ? JSON.stringify(value) : String(value);
|
|
56
|
+
case 'null':
|
|
57
|
+
return 'null';
|
|
58
|
+
case 'undefined':
|
|
59
|
+
return 'undefined';
|
|
60
|
+
default:
|
|
61
|
+
return String(value);
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
function previewText(value, type, count) {
|
|
65
|
+
if (type === 'array')
|
|
66
|
+
return `${count} ${count === 1 ? 'item' : 'items'}`;
|
|
67
|
+
return `${count} ${count === 1 ? 'key' : 'keys'}`;
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* `<lyra-json-viewer>` — a collapsible, copyable tree view for an arbitrary
|
|
71
|
+
* JSON-serializable value (object/array/string/number/boolean/null/
|
|
72
|
+
* undefined). Serves as the fallback renderer wherever a raw payload (tool
|
|
73
|
+
* call arguments, a tool result, an API response) needs inspecting without a
|
|
74
|
+
* bespoke view.
|
|
75
|
+
*
|
|
76
|
+
* Expand/collapse state is keyed by structural path (not by object identity),
|
|
77
|
+
* so it survives a `data` reassignment that keeps the same shape -- e.g. a
|
|
78
|
+
* streaming tool result being patched in place.
|
|
79
|
+
*
|
|
80
|
+
* @customElement lyra-json-viewer
|
|
81
|
+
* @event lyra-copy - `detail: { text }` -- fired by the top-level copy button or a per-node one. Fires even when `navigator.clipboard` silently failed or is unavailable (insecure context, older browser, stubbed-out test environment), so a consumer can still observe copy *intent*.
|
|
82
|
+
* @csspart base - The root scroll container; respects `max-height`.
|
|
83
|
+
* @csspart toolbar - The wrapper around the top-level copy button (only rendered when `copyable`).
|
|
84
|
+
* @csspart tree - The wrapper around the rendered node tree.
|
|
85
|
+
* @csspart key - An object property key or array index label.
|
|
86
|
+
* @csspart value - A primitive value's text -- carries `data-type` (`string`/`number`/`boolean`/`null`/`undefined`, or `circular` for a self-reference marker in place of a re-visited container's subtree) for per-type coloring, and `data-match` while it matches `search`.
|
|
87
|
+
* @csspart bracket - A `{`, `}`, `[`, or `]` delimiter.
|
|
88
|
+
* @csspart toggle - A container node's expand/collapse button (hidden, but present for row alignment, on leaf/empty nodes).
|
|
89
|
+
* @csspart copy-button - A copy-to-clipboard button -- the top-level one (in `toolbar`, labelled "Copy JSON to clipboard") or a per-node one (only rendered when `copyable`; labelled with its own key/type, e.g. "Copy age", so assistive tech can tell rows apart).
|
|
90
|
+
*/
|
|
91
|
+
export class LyraJsonViewer extends LyraElement {
|
|
92
|
+
constructor() {
|
|
93
|
+
super(...arguments);
|
|
94
|
+
/** A CSS length (e.g. `"20rem"`); once set, the viewer scrolls internally past this height instead of growing the page. */
|
|
95
|
+
this.maxHeight = '';
|
|
96
|
+
/** Shows copy-to-clipboard affordances: one for the whole value, plus one per node. */
|
|
97
|
+
this.copyable = false;
|
|
98
|
+
/** Case-insensitive substring match against keys/values; matches are highlighted and their ancestors auto-expanded. */
|
|
99
|
+
this.search = '';
|
|
100
|
+
/**
|
|
101
|
+
* Per-path (`JSON.stringify(path)`) explicit expand/collapse, overriding
|
|
102
|
+
* the `collapsedDepth`/search defaults once a node's toggle has been used.
|
|
103
|
+
* Pruned in `willUpdate()` (to the paths still reachable in the tree)
|
|
104
|
+
* whenever `data` changes, so a long-lived instance bound to reshaping
|
|
105
|
+
* data -- this component's own stated streaming use case -- doesn't
|
|
106
|
+
* accumulate one entry per path ever toggled for the life of the instance.
|
|
107
|
+
*/
|
|
108
|
+
this.expandedOverrides = new Map();
|
|
109
|
+
/** Memoized result of the last `computeSearch()` walk -- see `willUpdate()`. */
|
|
110
|
+
this.searchState = EMPTY_SEARCH;
|
|
111
|
+
}
|
|
112
|
+
static { this.styles = [LyraElement.styles, styles]; }
|
|
113
|
+
isExpanded(pathKey, depth, forceExpand) {
|
|
114
|
+
const override = this.expandedOverrides.get(pathKey);
|
|
115
|
+
if (override !== undefined)
|
|
116
|
+
return override;
|
|
117
|
+
if (forceExpand.has(pathKey))
|
|
118
|
+
return true;
|
|
119
|
+
if (this.collapsedDepth !== undefined && depth >= this.collapsedDepth)
|
|
120
|
+
return false;
|
|
121
|
+
return true;
|
|
122
|
+
}
|
|
123
|
+
toggleNode(pathKey, currentlyExpanded) {
|
|
124
|
+
const next = new Map(this.expandedOverrides);
|
|
125
|
+
next.set(pathKey, !currentlyExpanded);
|
|
126
|
+
this.expandedOverrides = next;
|
|
127
|
+
}
|
|
128
|
+
writeClipboard(text) {
|
|
129
|
+
try {
|
|
130
|
+
// navigator.clipboard is absent in insecure contexts / older browsers,
|
|
131
|
+
// and some engines throw synchronously rather than rejecting -- either
|
|
132
|
+
// way this is best-effort; copy() below always emits lyra-copy
|
|
133
|
+
// regardless of whether the OS clipboard was actually reached.
|
|
134
|
+
void navigator.clipboard?.writeText(text)?.catch(() => { });
|
|
135
|
+
}
|
|
136
|
+
catch {
|
|
137
|
+
// see above
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
copy(value) {
|
|
141
|
+
const text = value === undefined
|
|
142
|
+
? 'undefined'
|
|
143
|
+
: // A BigInt anywhere inside `value` (not just at the root) throws a
|
|
144
|
+
// TypeError from the default JSON.stringify() serializer the same
|
|
145
|
+
// way formatPrimitive()'s unguarded call used to -- the replacer
|
|
146
|
+
// downgrades it to its decimal string form instead.
|
|
147
|
+
JSON.stringify(value, (_key, v) => (typeof v === 'bigint' ? v.toString() : v), 2);
|
|
148
|
+
this.writeClipboard(text);
|
|
149
|
+
this.emit('lyra-copy', { text });
|
|
150
|
+
}
|
|
151
|
+
/**
|
|
152
|
+
* Builds the key/value-match sets, the ancestor-paths-of-a-match set that
|
|
153
|
+
* `search` drives, and the full set of path keys reachable in the tree
|
|
154
|
+
* (`paths`, used to prune `expandedOverrides` -- see `willUpdate()`).
|
|
155
|
+
* Guards against a self-referencing `data` the same way `renderNode()`
|
|
156
|
+
* does: a container value already on the current recursion path is
|
|
157
|
+
* treated as a leaf instead of being walked again.
|
|
158
|
+
*/
|
|
159
|
+
computeSearch() {
|
|
160
|
+
const query = this.search.trim().toLowerCase();
|
|
161
|
+
const keyMatches = new Set();
|
|
162
|
+
const valueMatches = new Set();
|
|
163
|
+
const forceExpand = new Set();
|
|
164
|
+
const paths = new Set();
|
|
165
|
+
const ancestors = new WeakSet();
|
|
166
|
+
const markAncestors = (path) => {
|
|
167
|
+
for (let i = path.length - 1; i >= 0; i--)
|
|
168
|
+
forceExpand.add(JSON.stringify(path.slice(0, i)));
|
|
169
|
+
};
|
|
170
|
+
const walk = (value, path, keyLabel) => {
|
|
171
|
+
const pathKey = JSON.stringify(path);
|
|
172
|
+
paths.add(pathKey);
|
|
173
|
+
const type = valueType(value);
|
|
174
|
+
if (query) {
|
|
175
|
+
let hit = false;
|
|
176
|
+
if (keyLabel !== undefined && keyLabel.toLowerCase().includes(query)) {
|
|
177
|
+
keyMatches.add(pathKey);
|
|
178
|
+
hit = true;
|
|
179
|
+
}
|
|
180
|
+
if (type !== 'object' && type !== 'array' && formatPrimitive(value, type).toLowerCase().includes(query)) {
|
|
181
|
+
valueMatches.add(pathKey);
|
|
182
|
+
hit = true;
|
|
183
|
+
}
|
|
184
|
+
if (hit)
|
|
185
|
+
markAncestors(path);
|
|
186
|
+
}
|
|
187
|
+
if ((type === 'object' || type === 'array') && !ancestors.has(value)) {
|
|
188
|
+
ancestors.add(value);
|
|
189
|
+
for (const [k, v] of entriesOf(value))
|
|
190
|
+
walk(v, [...path, k], String(k));
|
|
191
|
+
ancestors.delete(value);
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
walk(this.data, []);
|
|
195
|
+
return { keyMatches, valueMatches, forceExpand, paths };
|
|
196
|
+
}
|
|
197
|
+
renderCopyButton(value, label) {
|
|
198
|
+
if (!this.copyable)
|
|
199
|
+
return nothing;
|
|
200
|
+
return html `
|
|
201
|
+
<button
|
|
202
|
+
part="copy-button"
|
|
203
|
+
type="button"
|
|
204
|
+
aria-label="Copy ${label ?? 'value'}"
|
|
205
|
+
@click=${(e) => {
|
|
206
|
+
e.stopPropagation();
|
|
207
|
+
this.copy(value);
|
|
208
|
+
}}
|
|
209
|
+
>
|
|
210
|
+
Copy
|
|
211
|
+
</button>
|
|
212
|
+
`;
|
|
213
|
+
}
|
|
214
|
+
renderNode(value, path, keyLabel, depth, search, ancestors) {
|
|
215
|
+
const pathKey = JSON.stringify(path);
|
|
216
|
+
const type = valueType(value);
|
|
217
|
+
// A container value already on the current recursion path (i.e. `data`
|
|
218
|
+
// self-references, directly or through a longer cycle) gets rendered as
|
|
219
|
+
// a leaf marker instead of recursing again -- recursing would blow the
|
|
220
|
+
// stack instead of degrading gracefully.
|
|
221
|
+
const isCircular = (type === 'object' || type === 'array') && ancestors.has(value);
|
|
222
|
+
const isContainer = (type === 'object' || type === 'array') && !isCircular;
|
|
223
|
+
const entries = isContainer ? entriesOf(value) : [];
|
|
224
|
+
const hasEntries = entries.length > 0;
|
|
225
|
+
const expanded = hasEntries && this.isExpanded(pathKey, depth, search.forceExpand);
|
|
226
|
+
const indentStyle = `padding-inline-start:calc(${depth} * var(--lyra-space-l))`;
|
|
227
|
+
const toggleLabel = keyLabel ?? (type === 'array' ? 'array' : type === 'object' ? 'object' : 'value');
|
|
228
|
+
const openBracket = type === 'array' ? '[' : '{';
|
|
229
|
+
const closeBracket = type === 'array' ? ']' : '}';
|
|
230
|
+
// Computed eagerly -- in this same synchronous call, rather than left for
|
|
231
|
+
// lit-html's `repeat` directive to invoke lazily during commit -- so the
|
|
232
|
+
// `ancestors.add()`/`.delete()` pair below brackets exactly the values on
|
|
233
|
+
// the real recursive descent through *this* subtree, regardless of
|
|
234
|
+
// whenever lit-html itself gets around to resolving the directive.
|
|
235
|
+
let childRows = [];
|
|
236
|
+
if (isContainer && expanded) {
|
|
237
|
+
ancestors.add(value);
|
|
238
|
+
childRows = entries.map(([k, v]) => this.renderNode(v, [...path, k], String(k), depth + 1, search, ancestors));
|
|
239
|
+
ancestors.delete(value);
|
|
240
|
+
}
|
|
241
|
+
const headRow = html `
|
|
242
|
+
<div class="row" style=${indentStyle}>
|
|
243
|
+
<button
|
|
244
|
+
part="toggle"
|
|
245
|
+
type="button"
|
|
246
|
+
?hidden=${!hasEntries}
|
|
247
|
+
tabindex=${hasEntries ? nothing : -1}
|
|
248
|
+
aria-hidden=${hasEntries ? nothing : 'true'}
|
|
249
|
+
aria-expanded=${hasEntries ? (expanded ? 'true' : 'false') : nothing}
|
|
250
|
+
aria-label=${hasEntries ? `${expanded ? 'Collapse' : 'Expand'} ${toggleLabel}` : nothing}
|
|
251
|
+
@click=${() => hasEntries && this.toggleNode(pathKey, expanded)}
|
|
252
|
+
>
|
|
253
|
+
<span class="chevron" style=${`transform:rotate(${expanded ? '90deg' : '0deg'})`}>${chevronIcon()}</span>
|
|
254
|
+
</button>
|
|
255
|
+
${keyLabel !== undefined
|
|
256
|
+
? html `<span part="key" ?data-match=${search.keyMatches.has(pathKey)}>${keyLabel}</span
|
|
257
|
+
><span class="colon">:</span>`
|
|
258
|
+
: nothing}
|
|
259
|
+
${isCircular
|
|
260
|
+
? html `
|
|
261
|
+
<span part="bracket">${openBracket}</span>
|
|
262
|
+
<span part="value" data-type="circular">Circular reference</span>
|
|
263
|
+
<span part="bracket">${closeBracket}</span>
|
|
264
|
+
`
|
|
265
|
+
: isContainer
|
|
266
|
+
? html `
|
|
267
|
+
<span part="bracket">${openBracket}</span>
|
|
268
|
+
${hasEntries && !expanded
|
|
269
|
+
? html `<span class="preview">${previewText(value, type, entries.length)}</span>`
|
|
270
|
+
: nothing}
|
|
271
|
+
${!expanded ? html `<span part="bracket">${closeBracket}</span>` : nothing}
|
|
272
|
+
`
|
|
273
|
+
: html `<span part="value" data-type=${type} ?data-match=${search.valueMatches.has(pathKey)}
|
|
274
|
+
>${formatPrimitive(value, type)}</span
|
|
275
|
+
>`}
|
|
276
|
+
${this.renderCopyButton(value, toggleLabel)}
|
|
277
|
+
</div>
|
|
278
|
+
`;
|
|
279
|
+
// Always returned from this one call site, with a single conditional
|
|
280
|
+
// hole for the children block -- switching between *returning headRow
|
|
281
|
+
// bare* and *wrapping it in a bigger template* (two different template
|
|
282
|
+
// shapes at the same tree position) would make lit-html tear down and
|
|
283
|
+
// recreate the whole subtree on every expand/collapse instead of
|
|
284
|
+
// patching in place, destroying the toggle button's DOM identity (and
|
|
285
|
+
// with it, real DOM focus) on every click.
|
|
286
|
+
return html `
|
|
287
|
+
${headRow}
|
|
288
|
+
${isContainer && expanded
|
|
289
|
+
? html `
|
|
290
|
+
<div class="children">
|
|
291
|
+
${repeat(entries, ([k]) => JSON.stringify([...path, k]), (_entry, i) => childRows[i])}
|
|
292
|
+
</div>
|
|
293
|
+
<div class="row" style=${indentStyle}>
|
|
294
|
+
<span class="toggle-space" aria-hidden="true"></span>
|
|
295
|
+
<span part="bracket">${closeBracket}</span>
|
|
296
|
+
</div>
|
|
297
|
+
`
|
|
298
|
+
: nothing}
|
|
299
|
+
`;
|
|
300
|
+
}
|
|
301
|
+
willUpdate(changed) {
|
|
302
|
+
if (!this.hasUpdated || changed.has('data') || changed.has('search')) {
|
|
303
|
+
const next = this.computeSearch();
|
|
304
|
+
if (!this.hasUpdated || changed.has('data')) {
|
|
305
|
+
// A path with no entry in `next.paths` no longer exists anywhere in
|
|
306
|
+
// the new tree, so its override has nothing left to apply to --
|
|
307
|
+
// dropping it here (rather than never, as before) is what keeps a
|
|
308
|
+
// long-lived instance bound to reshaping data from accumulating one
|
|
309
|
+
// Map entry per distinct path ever toggled over its whole lifetime.
|
|
310
|
+
let pruned = null;
|
|
311
|
+
for (const key of this.expandedOverrides.keys()) {
|
|
312
|
+
if (!next.paths.has(key)) {
|
|
313
|
+
pruned ??= new Map(this.expandedOverrides);
|
|
314
|
+
pruned.delete(key);
|
|
315
|
+
}
|
|
316
|
+
}
|
|
317
|
+
if (pruned)
|
|
318
|
+
this.expandedOverrides = pruned;
|
|
319
|
+
}
|
|
320
|
+
this.searchState = next;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
render() {
|
|
324
|
+
return html `
|
|
325
|
+
<div part="base" style=${this.maxHeight ? `--lyra-json-viewer-max-height:${this.maxHeight}` : nothing}>
|
|
326
|
+
${this.copyable
|
|
327
|
+
? html `<div part="toolbar">
|
|
328
|
+
<button
|
|
329
|
+
part="copy-button"
|
|
330
|
+
type="button"
|
|
331
|
+
aria-label="Copy JSON to clipboard"
|
|
332
|
+
@click=${() => this.copy(this.data)}
|
|
333
|
+
>
|
|
334
|
+
Copy
|
|
335
|
+
</button>
|
|
336
|
+
</div>`
|
|
337
|
+
: nothing}
|
|
338
|
+
<div part="tree">${this.renderNode(this.data, [], undefined, 0, this.searchState, new WeakSet())}</div>
|
|
339
|
+
</div>
|
|
340
|
+
`;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
__decorate([
|
|
344
|
+
property({ attribute: false })
|
|
345
|
+
], LyraJsonViewer.prototype, "data", void 0);
|
|
346
|
+
__decorate([
|
|
347
|
+
property({ type: Number, attribute: 'collapsed-depth' })
|
|
348
|
+
], LyraJsonViewer.prototype, "collapsedDepth", void 0);
|
|
349
|
+
__decorate([
|
|
350
|
+
property({ attribute: 'max-height' })
|
|
351
|
+
], LyraJsonViewer.prototype, "maxHeight", void 0);
|
|
352
|
+
__decorate([
|
|
353
|
+
property({ type: Boolean, reflect: true })
|
|
354
|
+
], LyraJsonViewer.prototype, "copyable", void 0);
|
|
355
|
+
__decorate([
|
|
356
|
+
property()
|
|
357
|
+
], LyraJsonViewer.prototype, "search", void 0);
|
|
358
|
+
__decorate([
|
|
359
|
+
state()
|
|
360
|
+
], LyraJsonViewer.prototype, "expandedOverrides", void 0);
|
|
361
|
+
defineElement('json-viewer', LyraJsonViewer);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const styles: import("lit").CSSResult;
|
|
@@ -0,0 +1,177 @@
|
|
|
1
|
+
import { css } from 'lit';
|
|
2
|
+
export const styles = css `
|
|
3
|
+
:host {
|
|
4
|
+
display: block;
|
|
5
|
+
/* Consumer-tunable scroll cap -- 'none' means the viewer grows with its
|
|
6
|
+
content, matching every other block-level component in this library
|
|
7
|
+
until a caller opts into an internal scrollbar via the max-height
|
|
8
|
+
attribute. */
|
|
9
|
+
--lyra-json-viewer-max-height: none;
|
|
10
|
+
/* Contained here (rather than left as a bare font-family literal) so a
|
|
11
|
+
host page can retheme it, same rationale as --lyra-widget-overlay-color
|
|
12
|
+
in widget.styles.ts -- no shared --wa-*/--lyra-* monospace token exists
|
|
13
|
+
to resolve through. */
|
|
14
|
+
--lyra-json-viewer-font: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
|
|
15
|
+
font-family: var(--lyra-json-viewer-font);
|
|
16
|
+
font-size: 0.8125rem;
|
|
17
|
+
line-height: 1.6;
|
|
18
|
+
}
|
|
19
|
+
[part='base'] {
|
|
20
|
+
display: block;
|
|
21
|
+
max-block-size: var(--lyra-json-viewer-max-height);
|
|
22
|
+
overflow: auto;
|
|
23
|
+
border: 1px solid var(--lyra-color-border);
|
|
24
|
+
border-radius: var(--lyra-radius);
|
|
25
|
+
background: var(--lyra-color-surface);
|
|
26
|
+
}
|
|
27
|
+
[part='toolbar'] {
|
|
28
|
+
position: sticky;
|
|
29
|
+
inset-block-start: 0;
|
|
30
|
+
z-index: 1;
|
|
31
|
+
display: flex;
|
|
32
|
+
justify-content: flex-end;
|
|
33
|
+
padding: var(--lyra-space-xs) var(--lyra-space-s);
|
|
34
|
+
border-block-end: 1px solid var(--lyra-color-border);
|
|
35
|
+
background: var(--lyra-color-surface);
|
|
36
|
+
}
|
|
37
|
+
[part='tree'] {
|
|
38
|
+
padding: var(--lyra-space-s);
|
|
39
|
+
}
|
|
40
|
+
.row {
|
|
41
|
+
display: flex;
|
|
42
|
+
align-items: flex-start;
|
|
43
|
+
gap: var(--lyra-space-xs);
|
|
44
|
+
min-inline-size: 0;
|
|
45
|
+
border-radius: var(--lyra-radius);
|
|
46
|
+
}
|
|
47
|
+
.row:hover {
|
|
48
|
+
background: var(--lyra-color-brand-quiet);
|
|
49
|
+
}
|
|
50
|
+
.row:hover [part='copy-button'],
|
|
51
|
+
.row:focus-within [part='copy-button'] {
|
|
52
|
+
opacity: 1;
|
|
53
|
+
}
|
|
54
|
+
[part='toggle'] {
|
|
55
|
+
/* Deliberately smaller than the shared --lyra-icon-button-size (2.5rem,
|
|
56
|
+
meant for a standalone icon-only button) -- this sits inline in a
|
|
57
|
+
dense, arbitrarily-deep tree row, same reasoning as lyra-tree-node's
|
|
58
|
+
own toggle. */
|
|
59
|
+
inline-size: 1.25rem;
|
|
60
|
+
block-size: 1.25rem;
|
|
61
|
+
margin-block-start: 0.1875rem;
|
|
62
|
+
flex: 0 0 auto;
|
|
63
|
+
display: inline-flex;
|
|
64
|
+
align-items: center;
|
|
65
|
+
justify-content: center;
|
|
66
|
+
padding: 0;
|
|
67
|
+
border: none;
|
|
68
|
+
background: none;
|
|
69
|
+
color: var(--lyra-color-text-quiet);
|
|
70
|
+
border-radius: var(--lyra-radius);
|
|
71
|
+
cursor: pointer;
|
|
72
|
+
}
|
|
73
|
+
/* The UA '[hidden] { display: none }' rule is author-overridable by any
|
|
74
|
+
same-origin declaration for that element regardless of specificity --
|
|
75
|
+
author rules always win over user-agent rules unless !important is
|
|
76
|
+
involved -- so this only needs to add visibility, not re-declare
|
|
77
|
+
display. Keeping the box (rather than display:none) preserves this
|
|
78
|
+
leaf/empty row's alignment with sibling rows that do have a chevron. */
|
|
79
|
+
[part='toggle'][hidden] {
|
|
80
|
+
visibility: hidden;
|
|
81
|
+
}
|
|
82
|
+
[part='toggle'] .chevron {
|
|
83
|
+
display: inline-flex;
|
|
84
|
+
transition: transform var(--lyra-transition-fast);
|
|
85
|
+
}
|
|
86
|
+
[part='toggle']:not([hidden]):hover {
|
|
87
|
+
background: var(--lyra-color-brand-quiet);
|
|
88
|
+
color: var(--lyra-color-brand);
|
|
89
|
+
}
|
|
90
|
+
[part='toggle']:focus-visible,
|
|
91
|
+
[part='copy-button']:focus-visible {
|
|
92
|
+
outline: var(--lyra-focus-ring-width) solid var(--lyra-focus-ring-color);
|
|
93
|
+
outline-offset: var(--lyra-focus-ring-offset);
|
|
94
|
+
}
|
|
95
|
+
.toggle-space {
|
|
96
|
+
inline-size: 1.25rem;
|
|
97
|
+
flex: 0 0 auto;
|
|
98
|
+
}
|
|
99
|
+
[part='key'] {
|
|
100
|
+
flex: 0 0 auto;
|
|
101
|
+
font-weight: 600;
|
|
102
|
+
color: var(--lyra-color-text);
|
|
103
|
+
}
|
|
104
|
+
.colon {
|
|
105
|
+
flex: 0 0 auto;
|
|
106
|
+
color: var(--lyra-color-text-quiet);
|
|
107
|
+
margin-inline-end: var(--lyra-space-xs);
|
|
108
|
+
}
|
|
109
|
+
[part='bracket'] {
|
|
110
|
+
flex: 0 0 auto;
|
|
111
|
+
color: var(--lyra-color-text-quiet);
|
|
112
|
+
}
|
|
113
|
+
[part='key'][data-match],
|
|
114
|
+
[part='value'][data-match] {
|
|
115
|
+
background: var(--lyra-color-warning-quiet);
|
|
116
|
+
border-radius: 0.1875rem;
|
|
117
|
+
box-shadow: 0 0 0 0.125rem var(--lyra-color-warning-quiet);
|
|
118
|
+
}
|
|
119
|
+
[part='value'] {
|
|
120
|
+
min-inline-size: 0;
|
|
121
|
+
overflow-wrap: anywhere;
|
|
122
|
+
word-break: break-word;
|
|
123
|
+
white-space: pre-wrap;
|
|
124
|
+
}
|
|
125
|
+
[part='value'][data-type='string'] {
|
|
126
|
+
color: var(--lyra-color-success);
|
|
127
|
+
}
|
|
128
|
+
[part='value'][data-type='number'] {
|
|
129
|
+
color: var(--lyra-color-brand);
|
|
130
|
+
}
|
|
131
|
+
[part='value'][data-type='boolean'] {
|
|
132
|
+
color: var(--lyra-color-warning);
|
|
133
|
+
}
|
|
134
|
+
[part='value'][data-type='null'],
|
|
135
|
+
[part='value'][data-type='undefined'],
|
|
136
|
+
[part='value'][data-type='circular'] {
|
|
137
|
+
color: var(--lyra-color-text-quiet);
|
|
138
|
+
font-style: italic;
|
|
139
|
+
}
|
|
140
|
+
.preview {
|
|
141
|
+
flex: 0 0 auto;
|
|
142
|
+
color: var(--lyra-color-text-quiet);
|
|
143
|
+
font-style: italic;
|
|
144
|
+
margin-inline: var(--lyra-space-xs);
|
|
145
|
+
}
|
|
146
|
+
[part='copy-button'] {
|
|
147
|
+
flex: 0 0 auto;
|
|
148
|
+
margin-inline-start: auto;
|
|
149
|
+
border: none;
|
|
150
|
+
background: none;
|
|
151
|
+
color: var(--lyra-color-text-quiet);
|
|
152
|
+
font: inherit;
|
|
153
|
+
font-size: 0.75rem;
|
|
154
|
+
line-height: 1;
|
|
155
|
+
padding: 0.125rem var(--lyra-space-xs);
|
|
156
|
+
border-radius: var(--lyra-radius);
|
|
157
|
+
cursor: pointer;
|
|
158
|
+
}
|
|
159
|
+
[part='copy-button']:hover {
|
|
160
|
+
background: var(--lyra-color-brand-quiet);
|
|
161
|
+
color: var(--lyra-color-brand);
|
|
162
|
+
}
|
|
163
|
+
/* Per-node copy buttons stay out of the way until the row is actually
|
|
164
|
+
being interacted with -- the toolbar's own top-level copy button is
|
|
165
|
+
exempt (it has no ancestor .row, so this rule never matches it). */
|
|
166
|
+
.row [part='copy-button'] {
|
|
167
|
+
opacity: 0;
|
|
168
|
+
}
|
|
169
|
+
.row [part='copy-button']:focus-visible {
|
|
170
|
+
opacity: 1;
|
|
171
|
+
}
|
|
172
|
+
@media (prefers-reduced-motion: reduce) {
|
|
173
|
+
[part='toggle'] .chevron {
|
|
174
|
+
transition: none !important;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
`;
|