@aceshooting/lyra-ui 29.0.2 → 29.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/CHANGELOG.md +37 -0
- package/README.md +19 -26
- package/design-tokens.json +1 -1
- package/dist/cli/migrate-wa.mjs +2 -0
- package/dist/components/agent-tools/activity-feed/activity-feed.class.d.ts +5 -3
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +4 -3
- package/dist/components/agent-tools/activity-feed/activity-feed.styles.js +1 -1
- package/dist/components/agent-tools/agent-trace/agent-trace.class.d.ts +21 -5
- package/dist/components/agent-tools/agent-trace/agent-trace.class.js +14 -11
- package/dist/components/agent-tools/agent-trace/agent-trace.styles.js +1 -1
- package/dist/components/agent-tools/confirm-bar/confirm-bar.class.js +2 -2
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.d.ts +34 -7
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +25 -11
- package/dist/components/agent-tools/eval-result/eval-result-source.js +1 -0
- package/dist/components/agent-tools/eval-result/eval-result.class.d.ts +31 -11
- package/dist/components/agent-tools/eval-result/eval-result.class.js +29 -15
- package/dist/components/agent-tools/eval-result/eval-result.styles.js +1 -1
- package/dist/components/agent-tools/eval-result/eval-run-result.d.ts +10 -0
- package/dist/components/agent-tools/span-waterfall/span-waterfall.class.d.ts +26 -5
- package/dist/components/agent-tools/span-waterfall/span-waterfall.class.js +16 -6
- package/dist/components/agent-tools/span-waterfall/span-waterfall.d.ts +1 -1
- package/dist/components/agent-tools/span-waterfall/span-waterfall.js +1 -1
- package/dist/components/agent-tools/span-waterfall/span-waterfall.styles.js +1 -1
- package/dist/components/agent-tools/task-list/task-list.class.d.ts +29 -6
- package/dist/components/agent-tools/task-list/task-list.class.js +13 -7
- package/dist/components/agent-tools/task-list/task-list.d.ts +1 -1
- package/dist/components/agent-tools/task-list/task-list.js +1 -1
- package/dist/components/agent-tools/task-list/task-list.styles.js +1 -1
- package/dist/components/agent-tools/terminal/terminal.class.d.ts +9 -5
- package/dist/components/agent-tools/terminal/terminal.class.js +8 -8
- package/dist/components/agent-tools/test-results/test-results.class.d.ts +16 -4
- package/dist/components/agent-tools/test-results/test-results.class.js +15 -6
- package/dist/components/agent-tools/test-results/test-results.d.ts +1 -0
- package/dist/components/agent-tools/test-results/test-results.js +1 -1
- package/dist/components/agent-tools/test-results/test-results.styles.js +1 -1
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +7 -4
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.js +2 -1
- package/dist/components/agent-tools/trace-tree/span-projection.js +1 -0
- package/dist/components/agent-tools/trace-tree/span-shared.d.ts +29 -0
- package/dist/components/agent-tools/trace-tree/span-shared.js +1 -0
- package/dist/components/agent-tools/trace-tree/span.d.ts +5 -35
- package/dist/components/agent-tools/trace-tree/span.js +1 -1
- package/dist/components/agent-tools/trace-tree/trace-tree.class.d.ts +27 -5
- package/dist/components/agent-tools/trace-tree/trace-tree.class.js +19 -9
- package/dist/components/agent-tools/trace-tree/trace-tree.d.ts +1 -1
- package/dist/components/agent-tools/trace-tree/trace-tree.js +1 -1
- package/dist/components/agent-tools/trace-tree/trace-tree.styles.js +1 -1
- package/dist/components/charts/chart/bar-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/box-plot.class.d.ts +2 -2
- package/dist/components/charts/chart/box-plot.class.js +3 -3
- package/dist/components/charts/chart/bubble-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/chart-prepared-data.d.ts +9 -0
- package/dist/components/charts/chart/chart-prepared-data.js +1 -0
- package/dist/components/charts/chart/chart-spatial-data.js +2 -0
- package/dist/components/charts/chart/chart-sync.js +1 -1
- package/dist/components/charts/chart/chart-table-sampling.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +56 -6
- package/dist/components/charts/chart/chart.class.js +18 -8
- package/dist/components/charts/chart/chart.styles.js +1 -1
- package/dist/components/charts/chart/doughnut-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/histogram-buckets.d.ts +1 -1
- package/dist/components/charts/chart/histogram-buckets.js +1 -1
- package/dist/components/charts/chart/histogram.class.d.ts +19 -4
- package/dist/components/charts/chart/histogram.class.js +1 -1
- package/dist/components/charts/chart/line-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/lite-chart.class.d.ts +51 -11
- package/dist/components/charts/chart/lite-chart.class.js +33 -27
- package/dist/components/charts/chart/lite-chart.styles.js +1 -1
- package/dist/components/charts/chart/pie-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/polar-area-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/radar-chart.class.d.ts +5 -1
- package/dist/components/charts/chart/scatter-chart.class.d.ts +5 -1
- package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +6 -3
- package/dist/components/conversation/agent-workspace/agent-workspace.class.js +6 -5
- package/dist/components/conversation/agent-workspace/agent-workspace.styles.js +1 -1
- package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +8 -0
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-base.class.d.ts +5 -3
- package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-core.class.d.ts +4 -1
- package/dist/components/conversation/code-block/code-block-core.class.js +1 -1
- package/dist/components/conversation/code-block/code-block-shared.d.ts +6 -4
- package/dist/components/conversation/code-block/code-block-shared.js +3 -2
- package/dist/components/conversation/code-block/code-block.class.d.ts +11 -4
- package/dist/components/conversation/code-block/code-block.class.js +1 -1
- package/dist/components/conversation/code-block/code-block.d.ts +1 -1
- package/dist/components/conversation/code-block/code-block.styles.js +1 -1
- package/dist/components/conversation/code-block/shiki-types.d.ts +2 -0
- package/dist/components/conversation/code-block/shiki-types.js +1 -1
- package/dist/components/conversation/markdown/markdown-base.class.d.ts +6 -4
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-code-header.d.ts +2 -2
- package/dist/components/conversation/markdown/markdown-code-header.js +1 -1
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +8 -3
- package/dist/components/conversation/markdown/markdown-progressive.js +2 -2
- package/dist/components/conversation/markdown/markdown-shared.d.ts +5 -10
- package/dist/components/conversation/markdown/markdown-shared.js +5 -5
- package/dist/components/conversation/markdown/markdown-streaming-tail.js +1 -1
- package/dist/components/conversation/markdown/markdown.class.d.ts +17 -10
- package/dist/components/conversation/markdown/markdown.class.js +1 -1
- package/dist/components/conversation/markdown/markdown.styles.js +1 -1
- package/dist/components/conversation/model-select/model-select.class.d.ts +4 -3
- package/dist/components/conversation/model-select/model-select.class.js +3 -2
- package/dist/components/conversation/model-select/model-select.styles.js +1 -1
- package/dist/components/conversation/model-settings-panel/model-settings-panel.class.d.ts +2 -1
- package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +2 -1
- package/dist/components/conversation/model-settings-panel/model-settings-panel.styles.js +1 -1
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +3 -2
- package/dist/components/conversation/prompt-input/prompt-input.class.js +2 -1
- package/dist/components/conversation/prompt-input/prompt-input.styles.js +1 -1
- package/dist/components/conversation/prompt-queue/prompt-queue.class.d.ts +10 -2
- package/dist/components/conversation/prompt-queue/prompt-queue.class.js +15 -6
- package/dist/components/conversation/prompt-queue/prompt-queue.styles.js +1 -1
- package/dist/components/conversation/realtime-session/realtime-session.class.d.ts +3 -1
- package/dist/components/conversation/realtime-session/realtime-session.class.js +2 -1
- package/dist/components/conversation/realtime-session/realtime-session.styles.js +1 -1
- package/dist/components/conversation/streaming-text/markdown-detection.d.ts +2 -0
- package/dist/components/conversation/streaming-text/markdown-detection.js +4 -1
- package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +6 -2
- package/dist/components/conversation/streaming-text/streaming-text-base.class.js +3 -3
- package/dist/components/conversation/streaming-text/streaming-text-core.class.js +1 -1
- package/dist/components/conversation/streaming-text/streaming-text.class.js +1 -0
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +34 -4
- package/dist/components/conversation/thread-list/thread-list.class.js +22 -15
- package/dist/components/conversation/thread-list/thread-list.d.ts +1 -1
- package/dist/components/conversation/thread-list/thread-list.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.styles.js +1 -1
- package/dist/components/conversation/transcript-feed/transcript-feed.class.d.ts +6 -2
- package/dist/components/conversation/transcript-feed/transcript-feed.class.js +3 -2
- package/dist/components/conversation/transcript-feed/transcript-feed.styles.js +1 -1
- package/dist/components/conversation/voice-picker/voice-picker.class.d.ts +3 -2
- package/dist/components/conversation/voice-picker/voice-picker.class.js +3 -2
- package/dist/components/conversation/voice-picker/voice-picker.styles.js +1 -1
- package/dist/components/data/calendar/calendar.class.d.ts +5 -2
- package/dist/components/data/calendar/calendar.class.js +1 -1
- package/dist/components/data/data-grid/data-grid-processing.js +2 -2
- package/dist/components/data/data-grid/data-grid.class.d.ts +22 -8
- package/dist/components/data/data-grid/data-grid.class.js +20 -19
- package/dist/components/data/data-grid/data-grid.styles.js +1 -1
- package/dist/components/data/document-library/document-library.class.d.ts +31 -4
- package/dist/components/data/document-library/document-library.class.js +25 -12
- package/dist/components/data/document-library/document-library.styles.js +1 -1
- package/dist/components/data/file-tree/file-tree.class.d.ts +30 -6
- package/dist/components/data/file-tree/file-tree.class.js +4 -3
- package/dist/components/data/file-tree/file-tree.d.ts +1 -0
- package/dist/components/data/file-tree/file-tree.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +31 -6
- package/dist/components/data/flow-canvas/flow-canvas.class.js +40 -19
- package/dist/components/data/flow-canvas/flow-canvas.styles.js +1 -1
- package/dist/components/data/flow-canvas/flow-model.js +1 -1
- package/dist/components/data/flow-canvas/flow-source.js +1 -0
- package/dist/components/data/flow-canvas/flow-types.d.ts +4 -2
- package/dist/components/data/flow-canvas/flow-viewport-index.js +1 -0
- package/dist/components/data/flow-minimap/flow-minimap.class.d.ts +9 -3
- package/dist/components/data/flow-minimap/flow-minimap.class.js +11 -2
- package/dist/components/data/flow-minimap/flow-minimap.styles.js +1 -1
- package/dist/components/data/funnel/funnel.class.d.ts +7 -3
- package/dist/components/data/funnel/funnel.class.js +2 -2
- package/dist/components/data/heatmap/calendar-grid.d.ts +1 -1
- package/dist/components/data/heatmap/calendar-grid.js +1 -1
- package/dist/components/data/heatmap/heatmap-grid-navigation.js +1 -1
- package/dist/components/data/heatmap/heatmap-limits.d.ts +1 -1
- package/dist/components/data/heatmap/heatmap-matrix-source-controller.js +1 -0
- package/dist/components/data/heatmap/heatmap-matrix-source.d.ts +5 -0
- package/dist/components/data/heatmap/heatmap-matrix-source.js +1 -0
- package/dist/components/data/heatmap/heatmap-scale.d.ts +0 -16
- package/dist/components/data/heatmap/heatmap-scale.js +1 -1
- package/dist/components/data/heatmap/heatmap.class.d.ts +40 -11
- package/dist/components/data/heatmap/heatmap.class.js +26 -6
- package/dist/components/data/heatmap/heatmap.styles.js +1 -1
- package/dist/components/data/pagination/pagination.class.js +1 -1
- package/dist/components/data/sequence-strip/sequence-strip-item.d.ts +17 -0
- package/dist/components/data/sequence-strip/sequence-strip-source-controller.js +1 -0
- package/dist/components/data/sequence-strip/sequence-strip-source.d.ts +5 -0
- package/dist/components/data/sequence-strip/sequence-strip-source.js +1 -0
- package/dist/components/data/sequence-strip/sequence-strip.class.d.ts +24 -19
- package/dist/components/data/sequence-strip/sequence-strip.class.js +23 -4
- package/dist/components/data/sequence-strip/sequence-strip.styles.js +1 -1
- package/dist/components/data/sparkline/sparkline.class.d.ts +17 -4
- package/dist/components/data/sparkline/sparkline.class.js +3 -3
- package/dist/components/data/sparkline/sparkline.styles.js +1 -1
- package/dist/components/data/table/table.class.d.ts +14 -10
- package/dist/components/data/table/table.class.js +17 -16
- package/dist/components/data/timeline/timeline.class.d.ts +5 -2
- package/dist/components/data/timeline/timeline.class.js +1 -1
- package/dist/components/data/tree/tree-item.class.js +1 -1
- package/dist/components/data/tree/tree-owner-controller.js +1 -1
- package/dist/components/data/tree/tree.class.d.ts +28 -6
- package/dist/components/data/tree/tree.class.js +3 -3
- package/dist/components/data/tree/tree.d.ts +1 -0
- package/dist/components/data/tree/tree.js +1 -1
- package/dist/components/data/word-cloud/word-cloud.class.d.ts +17 -7
- package/dist/components/data/word-cloud/word-cloud.class.js +6 -4
- package/dist/components/data/word-cloud/word-cloud.styles.js +1 -1
- package/dist/components/forms/catalog-picker-base.d.ts +1 -1
- package/dist/components/forms/catalog-picker-base.js +6 -6
- package/dist/components/forms/catalog-picker-base.styles.js +1 -1
- package/dist/components/forms/combobox/combobox.class.d.ts +7 -3
- package/dist/components/forms/combobox/combobox.class.js +1 -1
- package/dist/components/forms/combobox/option.class.d.ts +4 -2
- package/dist/components/forms/combobox/option.class.js +2 -2
- package/dist/components/forms/country-picker/country-picker.class.d.ts +3 -1
- package/dist/components/forms/country-picker/country-picker.class.js +1 -1
- package/dist/components/forms/currency-picker/currency-picker.class.d.ts +2 -0
- package/dist/components/forms/currency-picker/currency-picker.class.js +1 -1
- package/dist/components/forms/currency-picker/currency-presentation.js +1 -1
- package/dist/components/forms/emoji-picker/emoji-picker.class.d.ts +6 -2
- package/dist/components/forms/emoji-picker/emoji-picker.class.js +3 -2
- package/dist/components/forms/emoji-picker/emoji-picker.styles.js +1 -1
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +8 -2
- package/dist/components/forms/locale-picker/locale-picker.class.js +5 -4
- package/dist/components/forms/locale-picker/locale-picker.styles.js +1 -1
- package/dist/components/forms/select/select.class.d.ts +11 -3
- package/dist/components/forms/select/select.class.js +4 -4
- package/dist/components/forms/time-zone-picker/time-zone-picker.class.d.ts +2 -0
- package/dist/components/forms/time-zone-picker/time-zone-picker.class.js +1 -1
- package/dist/components/forms/token-input/token-input.class.d.ts +6 -1
- package/dist/components/forms/token-input/token-input.class.js +15 -13
- package/dist/components/forms/unit-picker/unit-picker.class.d.ts +2 -0
- package/dist/components/forms/unit-picker/unit-picker.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.class.d.ts +1 -1
- package/dist/components/layout/app-rail/app-rail.class.js +1 -1
- package/dist/components/layout/command-palette/command-palette.class.d.ts +5 -2
- package/dist/components/layout/command-palette/command-palette.class.js +2 -1
- package/dist/components/layout/command-palette/command-palette.styles.js +1 -1
- package/dist/components/layout/menu/menu-item.class.d.ts +2 -2
- package/dist/components/layout/menu/menu-item.class.js +2 -2
- package/dist/components/layout/menu/menu.class.d.ts +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/menubar/menubar.class.d.ts +1 -1
- package/dist/components/layout/menubar/menubar.class.js +1 -1
- package/dist/components/layout/reorder-list/reorder-item.class.d.ts +2 -2
- package/dist/components/layout/reorder-list/reorder-item.class.js +2 -2
- package/dist/components/layout/reorder-list/reorder-list.class.d.ts +1 -1
- package/dist/components/layout/reorder-list/reorder-list.class.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.class.d.ts +13 -9
- package/dist/components/layout/virtual-list/virtual-list.class.js +21 -17
- package/dist/components/media/av-player/av-cue-index.js +1 -0
- package/dist/components/media/av-player/av-cue-source.d.ts +13 -0
- package/dist/components/media/av-player/av-cue-source.js +1 -0
- package/dist/components/media/av-player/av-metadata.d.ts +2 -2
- package/dist/components/media/av-player/av-metadata.js +1 -1
- package/dist/components/media/av-player/av-player-cue-source-controller.js +1 -0
- package/dist/components/media/av-player/av-player.class.d.ts +34 -12
- package/dist/components/media/av-player/av-player.class.js +15 -10
- package/dist/components/media/flag/flag.class.js +1 -1
- package/dist/components/media/flag/language-map.js +1 -1
- package/dist/components/media/lightbox/lightbox-source.js +1 -0
- package/dist/components/media/lightbox/lightbox-types.d.ts +15 -0
- package/dist/components/media/lightbox/lightbox.class.d.ts +22 -21
- package/dist/components/media/lightbox/lightbox.class.js +6 -4
- package/dist/components/media/lightbox/lightbox.styles.js +1 -1
- package/dist/components/media/map/map-geojson-diff.d.ts +6 -6
- package/dist/components/media/map/map-geojson-diff.js +1 -1
- package/dist/components/media/map/map-loader.d.ts +5 -1
- package/dist/components/media/map/map.class.d.ts +24 -6
- package/dist/components/media/map/map.class.js +2 -2
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/video-playlist/video-playlist.class.d.ts +2 -1
- package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
- package/dist/components/overlays/chip/chip.class.d.ts +1 -1
- package/dist/components/overlays/chip/chip.class.js +1 -1
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.d.ts +30 -8
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +22 -8
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +1 -1
- package/dist/components/retrieval/graph/graph-canvas.js +1 -1
- package/dist/components/retrieval/graph/graph-source-composition.js +1 -0
- package/dist/components/retrieval/graph/graph-source-controller.js +1 -0
- package/dist/components/retrieval/graph/graph-spatial-controller.js +2 -2
- package/dist/components/retrieval/graph/graph-spatial-model.js +1 -0
- package/dist/components/retrieval/graph/graph-spatial.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +31 -6
- package/dist/components/retrieval/graph/graph.class.js +26 -5
- package/dist/components/retrieval/graph/graph.d.ts +1 -1
- package/dist/components/retrieval/graph/graph.js +1 -1
- package/dist/components/retrieval/graph/graph.styles.js +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +33 -4
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +27 -17
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.d.ts +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.js +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +1 -1
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.d.ts +27 -4
- package/dist/components/retrieval/knowledge-base/knowledge-base.class.js +29 -14
- package/dist/components/retrieval/knowledge-base/knowledge-base.styles.js +1 -1
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.d.ts +17 -3
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.class.js +15 -10
- package/dist/components/retrieval/knowledge-base-admin/knowledge-base-admin.styles.js +1 -1
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +24 -5
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +17 -10
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.d.ts +1 -1
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.js +1 -1
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.styles.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map-layout.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map-model.js +1 -0
- package/dist/components/retrieval/mind-map/mind-map.class.d.ts +27 -4
- package/dist/components/retrieval/mind-map/mind-map.class.js +11 -7
- package/dist/components/retrieval/mind-map/mind-map.d.ts +1 -0
- package/dist/components/retrieval/mind-map/mind-map.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map.styles.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +24 -2
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +17 -3
- package/dist/components/retrieval/neighbor-list/neighbor-list.d.ts +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.styles.js +1 -1
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +8 -4
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +11 -7
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.styles.js +1 -1
- package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.d.ts +12 -6
- package/dist/components/retrieval/retrieval-compare/retrieval-compare.class.js +30 -17
- package/dist/components/retrieval/retrieval-compare/retrieval-compare.styles.js +1 -1
- package/dist/components/retrieval/retrieval-results/retrieval-results-model.js +1 -0
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.d.ts +46 -5
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +31 -9
- package/dist/components/retrieval/retrieval-results/retrieval-results.d.ts +1 -1
- package/dist/components/retrieval/retrieval-results/retrieval-results.js +1 -1
- package/dist/components/retrieval/retrieval-results/retrieval-results.styles.js +1 -1
- package/dist/components/utility/diff-view/diff-view.class.d.ts +16 -8
- package/dist/components/utility/diff-view/diff-view.class.js +3 -2
- package/dist/components/utility/diff-view/diff-view.styles.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.class.d.ts +31 -3
- package/dist/components/utility/json-viewer/json-viewer.class.js +13 -4
- package/dist/components/utility/json-viewer/json-viewer.d.ts +1 -0
- package/dist/components/utility/json-viewer/json-viewer.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.d.ts +6 -4
- package/dist/components/utility/mention-popover/mention-popover.class.js +6 -5
- package/dist/components/viewers/csv-viewer/csv-viewer.class.d.ts +34 -7
- package/dist/components/viewers/csv-viewer/csv-viewer.class.js +9 -7
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.d.ts +28 -4
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +12 -11
- package/dist/components/viewers/geojson-view/geojson-viewer.class.d.ts +3 -1
- package/dist/components/viewers/geojson-view/geojson-viewer.class.js +17 -16
- package/dist/components/viewers/geojson-view/geojson-viewer.d.ts +1 -1
- package/dist/components/viewers/geojson-view/geojson-viewer.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.d.ts +31 -5
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +11 -8
- package/dist/components/viewers/table-viewer-shared.js +19 -3
- package/dist/components/viewers/viewer-search-limits.js +1 -1
- package/dist/components/viewers/xml-viewer/xml-viewer.class.d.ts +35 -3
- package/dist/components/viewers/xml-viewer/xml-viewer.class.js +20 -5
- package/dist/components/viewers/xml-viewer/xml-viewer.d.ts +1 -1
- package/dist/components/viewers/xml-viewer/xml-viewer.js +1 -1
- package/dist/components/viewers/xml-viewer/xml-viewer.styles.js +1 -1
- package/dist/countries.js +1 -1
- package/dist/data-sources.d.ts +34 -0
- package/dist/data-sources.js +1 -0
- package/dist/events.d.ts +51 -7
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/accessibility-visibility.d.ts +4 -2
- package/dist/internal/accessibility-visibility.js +1 -1
- package/dist/internal/accessible-text-controller.js +1 -1
- package/dist/internal/anchor-target.js +2 -2
- package/dist/internal/catalog-picker.d.ts +1 -7
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/collection-snapshot.js +1 -1
- package/dist/internal/default-strings/agent-tools.generated.js +1 -1
- package/dist/internal/default-strings/charts.generated.js +1 -1
- package/dist/internal/default-strings/conversation.generated.js +1 -1
- package/dist/internal/default-strings/data.generated.js +1 -1
- package/dist/internal/default-strings/forms.generated.js +1 -1
- package/dist/internal/default-strings/layout.generated.js +1 -1
- package/dist/internal/default-strings/media.generated.js +1 -1
- package/dist/internal/default-strings/retrieval.generated.js +1 -1
- package/dist/internal/default-strings/shared.generated.js +1 -1
- package/dist/internal/default-strings/utility.generated.js +1 -1
- package/dist/internal/delimited-data.js +1 -1
- package/dist/internal/fixed-containing-block.js +1 -1
- package/dist/internal/flow-scene-envelope.js +1 -0
- package/dist/internal/graph-scene-controller.js +1 -0
- package/dist/internal/hierarchy-source-controller.js +1 -0
- package/dist/internal/hierarchy-source-view.js +29 -0
- package/dist/internal/hierarchy-source-view.styles.js +1 -0
- package/dist/internal/inherited-attribute-hub.d.ts +6 -0
- package/dist/internal/inherited-attribute-hub.js +1 -1
- package/dist/internal/intl-cache.js +1 -1
- package/dist/internal/keyed-index.js +1 -0
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +2 -2
- package/dist/internal/lyra-element.d.ts +2 -2
- package/dist/internal/lyra-element.js +3 -2
- package/dist/internal/native-modal-context.js +1 -1
- package/dist/internal/option-selection.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/positioner.js +1 -1
- package/dist/internal/resource-loader.d.ts +2 -0
- package/dist/internal/resource-loader.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/search-haystack.js +1 -0
- package/dist/internal/selection-catalog.d.ts +5 -0
- package/dist/internal/selection-catalog.js +1 -1
- package/dist/internal/shiki-language-sources.js +1 -0
- package/dist/internal/source-page-controller.js +1 -0
- package/dist/internal/source-page-scope.js +1 -0
- package/dist/internal/source-request-controller.js +1 -0
- package/dist/internal/source-window-controller.js +1 -0
- package/dist/internal/spatial-source-controller.js +1 -0
- package/dist/internal/text-quote.d.ts +2 -6
- package/dist/internal/text-quote.js +1 -1
- package/dist/internal/theme-watcher.js +1 -1
- package/dist/internal/virtual-list-composition.js +1 -0
- package/dist/lyra.d.ts +1 -1
- package/dist/lyra.js +1 -1
- package/dist/testing/interaction-drivers.js +1 -1
- package/dist/testing/lyra-tag-event-map.js +1 -1
- package/dist/units.js +1 -1
- package/dist/utilities/data-preparation.d.ts +56 -0
- package/dist/utilities/data-preparation.js +1 -0
- package/dist/utilities/data-spatial.d.ts +26 -0
- package/dist/utilities/data-spatial.js +1 -0
- package/dist/utilities/index.d.ts +1 -1
- package/dist/utilities/index.js +1 -1
- package/llms/components/lr-activity-feed.md +7 -2
- package/llms/components/lr-agent-trace.md +49 -9
- package/llms/components/lr-agent-workspace.md +15 -8
- package/llms/components/lr-av-player.md +180 -10
- package/llms/components/lr-bar-chart.md +1 -1
- package/llms/components/lr-box-plot.md +8 -0
- package/llms/components/lr-bubble-chart.md +1 -1
- package/llms/components/lr-calendar.md +26 -3
- package/llms/components/lr-chart.md +310 -23
- package/llms/components/lr-chat-viewport.md +6 -0
- package/llms/components/lr-code-block-core.md +12 -7
- package/llms/components/lr-code-block.md +23 -9
- package/llms/components/lr-combobox.md +27 -15
- package/llms/components/lr-command-palette.md +16 -3
- package/llms/components/lr-country-picker.md +23 -6
- package/llms/components/lr-csv-viewer.md +95 -12
- package/llms/components/lr-currency-picker.md +23 -3
- package/llms/components/lr-data-grid.md +24 -6
- package/llms/components/lr-dataset-viewer.md +92 -11
- package/llms/components/lr-dialog.md +1 -1
- package/llms/components/lr-diff-view.md +19 -6
- package/llms/components/lr-document-library.md +60 -5
- package/llms/components/lr-doughnut-chart.md +1 -1
- package/llms/components/lr-embedding-explorer.md +89 -9
- package/llms/components/lr-emoji-picker.md +7 -2
- package/llms/components/lr-eval-dataset.md +56 -7
- package/llms/components/lr-eval-result.md +89 -4
- package/llms/components/lr-export-button.md +1 -1
- package/llms/components/lr-file-tree.md +60 -6
- package/llms/components/lr-flag.md +5 -2
- package/llms/components/lr-flow-canvas.md +152 -14
- package/llms/components/lr-flow-minimap.md +32 -4
- package/llms/components/lr-funnel.md +14 -0
- package/llms/components/lr-geojson-viewer.md +27 -10
- package/llms/components/lr-graph.md +43 -7
- package/llms/components/lr-heatmap.md +161 -5
- package/llms/components/lr-histogram.md +55 -9
- package/llms/components/lr-ingestion-queue.md +54 -3
- package/llms/components/lr-json-viewer.md +87 -7
- package/llms/components/lr-knowledge-base-admin.md +60 -4
- package/llms/components/lr-knowledge-base.md +121 -9
- package/llms/components/lr-knowledge-graph-explorer.md +106 -11
- package/llms/components/lr-lightbox.md +42 -6
- package/llms/components/lr-line-chart.md +28 -5
- package/llms/components/lr-lite-chart.md +96 -31
- package/llms/components/lr-locale-picker.md +6 -4
- package/llms/components/lr-map.md +67 -8
- package/llms/components/lr-markdown-core.md +10 -5
- package/llms/components/lr-markdown.md +23 -6
- package/llms/components/lr-mention-popover.md +11 -6
- package/llms/components/lr-mind-map.md +91 -10
- package/llms/components/lr-model-select.md +8 -4
- package/llms/components/lr-model-settings-panel.md +10 -2
- package/llms/components/lr-navigation-menu.md +1 -1
- package/llms/components/lr-neighbor-list.md +69 -2
- package/llms/components/lr-pie-chart.md +1 -1
- package/llms/components/lr-polar-area-chart.md +1 -1
- package/llms/components/lr-prompt-input.md +9 -2
- package/llms/components/lr-prompt-queue.md +11 -3
- package/llms/components/lr-radar-chart.md +1 -1
- package/llms/components/lr-rag-eval-dashboard.md +9 -2
- package/llms/components/lr-realtime-session.md +6 -2
- package/llms/components/lr-reorder-list.md +4 -0
- package/llms/components/lr-retrieval-compare.md +9 -4
- package/llms/components/lr-retrieval-results.md +104 -6
- package/llms/components/lr-scatter-chart.md +1 -1
- package/llms/components/lr-select.md +20 -10
- package/llms/components/lr-sequence-strip.md +92 -2
- package/llms/components/lr-span-waterfall.md +78 -8
- package/llms/components/lr-sparkline.md +42 -11
- package/llms/components/lr-spreadsheet-viewer.md +109 -14
- package/llms/components/lr-streaming-text-core.md +4 -2
- package/llms/components/lr-streaming-text.md +5 -1
- package/llms/components/lr-table.md +96 -115
- package/llms/components/lr-task-list.md +93 -9
- package/llms/components/lr-terminal.md +9 -0
- package/llms/components/lr-test-results.md +77 -3
- package/llms/components/lr-thread-list.md +86 -1
- package/llms/components/lr-time-zone-picker.md +8 -3
- package/llms/components/lr-timeline.md +5 -0
- package/llms/components/lr-token-input.md +7 -2
- package/llms/components/lr-tool-timeline.md +13 -4
- package/llms/components/lr-trace-tree.md +96 -10
- package/llms/components/lr-transcript-feed.md +9 -2
- package/llms/components/lr-tree.md +87 -15
- package/llms/components/lr-unit-picker.md +8 -3
- package/llms/components/lr-video-playlist.md +2 -0
- package/llms/components/lr-virtual-list.md +17 -8
- package/llms/components/lr-voice-picker.md +8 -3
- package/llms/components/lr-word-cloud.md +128 -12
- package/llms/components/lr-xml-viewer.md +106 -9
- package/llms/index.md +1 -1
- package/llms/peers.md +1 -1
- package/llms/shared/events-and-types.md +725 -264
- package/llms/shared/forms-and-accessibility.md +3 -17
- package/llms/shared/imports-and-registration.md +3 -17
- package/llms/shared/localization-and-rtl.md +0 -2
- package/llms/shared/styles-and-tokens.md +27 -36
- package/llms/shared/testing-and-utilities.md +4 -5
- package/llms/shared.md +770 -349
- package/llms.txt +1 -2
- package/locales.json +139 -139
- package/package.json +13 -4
- package/registrations.json +1 -1
- package/skills/compose-lyra-interfaces/SKILL.md +6 -8
- package/skills/lyra-ui/SKILL.md +20 -51
- package/skills/lyra-ui/commands/review.md +16 -33
- package/skills/lyra-ui/commands/update.md +6 -5
- package/skills/lyra-ui/online-api.md +15 -0
- package/skills/lyra-ui/reporting.md +2 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-host-tokens.styles.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{syncAriaDescribedByElements}from"../../../internal/aria-reflection.js";import{isRtl}from"../../../internal/rtl.js";import{getScratchCtx}from"../../../internal/canvas.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteNumber,finiteRange}from"../../../internal/numbers.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{devWarn}from"../../../internal/dev-mode-attribute-warning.js";import{layoutWordCloud,MAX_FONT_SIZE_PX,MAX_WORDS,MIN_SANE_FONT_SIZE}from"./word-cloud-layout.js";import{styles}from"./word-cloud.styles.js";import{LYRA_DEFAULT_wordCloud,LYRA_DEFAULT_wordCloudLegend,LYRA_DEFAULT_wordCloudWord,LYRA_DEFAULT_wordCloudWordAnnouncement,LYRA_DEFAULT_wordCloudWords}from"../../../internal/default-strings/data.generated.js";import{LYRA_DEFAULT_items,LYRA_DEFAULT_noData,LYRA_DEFAULT_paginationSummary}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_MIN_FONT_SIZE=12,DEFAULT_MAX_FONT_SIZE=48,PALETTE_SIZE=8,FALLBACK_PALETTE=["#0969da","#1a7f37","#9a6700","#cf222e","#8250df","#bf3989","#0a7d91","#57606a"],DEFAULT_WORD_FONT_WEIGHT="600",NAV_KEYS=new Set(["ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End"]),FOCUS_RING_PAD=2,MAX_INPUT_WORDS=1e4,MAX_WORD_TEXT=256,MAX_TOTAL_WORD_TEXT=16384,MAX_LEGEND_ITEMS=100,MAX_LEGEND_TEXT=256,MAX_TOTAL_LEGEND_TEXT=8192,MAX_PALETTE_ITEMS=64;function warnSkippedWords(count,warnedSkipCounts){warnedSkipCounts.has(count)||(warnedSkipCounts.add(count),devWarn(`<lr-word-cloud> could not place ${count} word(s) (blank text, over the ${MAX_WORDS}-word cap, or the layout search was exhausted) -- they were dropped, not rendered.`))}function boundedText(value,limit){return value.length<=limit?value:`${value.slice(0,Math.max(0,limit-1))}…`}function normalizeWords(value){let input;try{input=Array.isArray(value)?value:[]}catch{input=[]}let inputCount=0;try{inputCount=Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,input.length))}catch{inputCount=0}const scanCount=Math.min(inputCount,MAX_INPUT_WORDS),words=[];let dropped=Math.max(0,inputCount-scanCount),truncated=0,characters=0;for(let index=0;index<scanCount;index++)try{const candidate=input[index];if(typeof candidate!="object"||candidate===null){dropped++;continue}const rawText=candidate.text,rawWeight=candidate.weight,rawColor=candidate.color,rawGroup=candidate.group;if(typeof rawText!="string"){dropped++;continue}const remaining=MAX_TOTAL_WORD_TEXT-characters;if(remaining<=0){dropped+=scanCount-index;break}const textLimit=Math.min(MAX_WORD_TEXT,remaining),text=boundedText(rawText,textLimit);if(!text.trim()){dropped++;continue}let itemTruncated=rawText.length>textLimit;characters+=text.length;const boundedOptionalText=raw=>{if(typeof raw!="string")return;const available=MAX_TOTAL_WORD_TEXT-characters;if(available<=0){raw.length>0&&(itemTruncated=!0);return}const limit=Math.min(MAX_WORD_TEXT,available),result=boundedText(raw,limit);return raw.length>limit&&(itemTruncated=!0),characters+=result.length,result},color=boundedOptionalText(rawColor),group=boundedOptionalText(rawGroup),word={text,weight:Math.max(0,finiteNumber(typeof rawWeight=="number"?rawWeight:0,0)),...color===void 0?{}:{color},...group===void 0?{}:{group}};itemTruncated&&truncated++,words.push(Object.freeze(word))}catch{dropped++}return{items:Object.freeze(words),dropped,truncated,inputCount}}function normalizeLegend(value){let input;try{input=Array.isArray(value)?value:[]}catch{input=[]}let inputCount=0;try{inputCount=Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,input.length))}catch{inputCount=0}const length=Math.min(inputCount,MAX_LEGEND_ITEMS),legend=[];let dropped=Math.max(0,inputCount-length),truncated=0,characters=0;for(let index=0;index<length;index++)try{const item=input[index];if(typeof item!="object"||item===null){dropped++;continue}const rawLabel=item.label,rawColor=item.color;if(typeof rawLabel!="string"||typeof rawColor!="string"){dropped++;continue}const remaining=MAX_TOTAL_LEGEND_TEXT-characters;if(remaining<=0){dropped+=length-index;break}const labelLimit=Math.min(MAX_LEGEND_TEXT,remaining),label=boundedText(rawLabel,labelLimit);if(!label.trim()){dropped++;continue}let itemTruncated=rawLabel.length>labelLimit;characters+=label.length;const colorRemaining=MAX_TOTAL_LEGEND_TEXT-characters,colorLimit=Math.min(MAX_WORD_TEXT,Math.max(0,colorRemaining)),color=colorLimit>0?boundedText(rawColor,colorLimit):"";rawColor.length>colorLimit&&(itemTruncated=!0),characters+=color.length,itemTruncated&&truncated++,legend.push(Object.freeze({label,color}))}catch{dropped++}return{items:Object.freeze(legend),dropped,truncated,inputCount}}function normalizePalette(value){let input;try{input=Array.isArray(value)?value:[]}catch{return}let length=0;try{length=Math.min(input.length,MAX_PALETTE_ITEMS)}catch{return}const palette=[];for(let index=0;index<length;index++)try{const entry=input[index];typeof entry=="string"&&palette.push(boundedText(entry,MAX_WORD_TEXT))}catch{}return Object.freeze(palette)}class LyraWordCloud extends LyraElement{static{this.defaultStrings={...super.defaultStrings,items:LYRA_DEFAULT_items,noData:LYRA_DEFAULT_noData,paginationSummary:LYRA_DEFAULT_paginationSummary,wordCloud:LYRA_DEFAULT_wordCloud,wordCloudLegend:LYRA_DEFAULT_wordCloudLegend,wordCloudWord:LYRA_DEFAULT_wordCloudWord,wordCloudWordAnnouncement:LYRA_DEFAULT_wordCloudWordAnnouncement,wordCloudWords:LYRA_DEFAULT_wordCloudWords}}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}get words(){return this._words}set words(value){if(value===this._words||value===this.lastWordsInput)return;this.lastWordsInput=value;const previous=this._words,normalized=normalizeWords(value);this._words=normalized.items,this.inputDroppedCount=normalized.dropped,this.inputTruncatedCount=normalized.truncated,this.inputWordCount=normalized.inputCount,this.requestUpdate("words",previous)}get scale(){return this._scale}set scale(value){const normalized=value==="sqrt"?"sqrt":"linear",previous=this._scale;if(previous===normalized){value!==normalized&&this.requestUpdate("scale",previous);return}this._scale=normalized,this.requestUpdate("scale",previous)}get wordRotation(){return this._wordRotation}set wordRotation(value){const normalized=value==="mixed"?"mixed":"none",previous=this._wordRotation;if(previous===normalized){value!==normalized&&this.requestUpdate("wordRotation",previous);return}this._wordRotation=normalized,this.requestUpdate("wordRotation",previous)}get palette(){return this._palette}set palette(value){if(value===this._palette||value===this.lastPaletteInput)return;this.lastPaletteInput=value;const previous=this._palette;this._palette=normalizePalette(value),this.paint=void 0,this.requestUpdate("palette",previous)}get legend(){return this._legend}set legend(value){if(value===this._legend||value===this.lastLegendInput)return;this.lastLegendInput=value;const previous=this._legend,normalized=normalizeLegend(value);this._legend=normalized.items,this.legendDroppedCount=normalized.dropped,this.legendTruncatedCount=normalized.truncated,this.legendInputCount=normalized.inputCount,this.paint=void 0,this.requestUpdate("legend",previous)}constructor(){super(),this._words=[],this.inputDroppedCount=0,this.inputTruncatedCount=0,this.inputWordCount=0,this.minFontSize=DEFAULT_MIN_FONT_SIZE,this.maxFontSize=DEFAULT_MAX_FONT_SIZE,this._scale="linear",this._wordRotation="none",this._legend=[],this.legendDroppedCount=0,this.legendTruncatedCount=0,this.legendInputCount=0,this.withLegend=!1,this.cachedLayout={placed:[],skipped:[],skippedCount:0,width:0,height:0},this.order=[],this.focusedIndex=null,this.liveText="",this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null,this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this.warnedSkipCounts=new Set,this.typographyThemeSignature="",this.paletteThemeSignature="",this.hasSyncedDescribedByElements=!1,this.onThemeInvalidated=()=>{const typography=`${this.fontWeight()}\0${this.fontFamily()}`,palette=this.paletteColors().join("\0");if(!this.typographyThemeSignature||typography!==this.typographyThemeSignature){this.refreshTheme();return}palette!==this.paletteThemeSignature&&(this.paletteThemeSignature=palette,this.paint=void 0,this.requestUpdate())},this.onSvgFocus=()=>{this.focusedIndex===null&&this.cachedLayout.placed.length>0&&(this.focusedIndex=0)},this.onSvgPointerDown=event=>{const word=this.nearestWord(event);if(!word)return;const index=this.wordIndex(word);index<0||(this.focusedIndex=index,this.pressedOriginalIndex=word.originalIndex,this.svgEl?.focus())},this.onSvgPointerMove=event=>{this.hoveredOriginalIndex=this.nearestWord(event)?.originalIndex??null},this.clearPointerPress=()=>{this.pressedOriginalIndex=null},this.onSvgPointerLeave=()=>{this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null},this.onSvgClick=event=>{const word=this.nearestWord(event);word&&this.onWordClick(word)},this.onWordClick=word=>{const order=this.order,idx=order.findIndex(w=>w.originalIndex===word.originalIndex);this.focusedIndex=idx===-1?null:idx,idx!==-1&&this.announce(order[idx]),this.svgEl?.focus(),this.activate(word)},this.onKeyDown=e=>{const order=this.order;if(order.length===0)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.focusedIndex!==null&&this.activate(order[this.focusedIndex]);return}if(!NAV_KEYS.has(e.key))return;if(e.preventDefault(),this.focusedIndex===null){const next2=e.key==="End"?order.length-1:0;this.focusedIndex=next2,this.announce(order[next2]);return}const rtl=isRtl(this),forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft";let next=this.focusedIndex;e.key===forwardKey||e.key==="ArrowDown"?next=Math.min(order.length-1,this.focusedIndex+1):e.key===backwardKey||e.key==="ArrowUp"?next=Math.max(0,this.focusedIndex-1):e.key==="Home"?next=0:e.key==="End"&&(next=order.length-1),this.focusedIndex=next,this.announce(order[next])},new ThemeWatcher(this,this.onThemeInvalidated)}disconnectedCallback(){super.disconnectedCallback(),this.focusedIndex=null,this.liveText="",this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}updated(changed){super.updated(changed);const describedBy=this.getAttribute("aria-describedby");!describedBy&&!this.hasSyncedDescribedByElements||(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,this.svgEl,describedBy))}fontFamily(){return this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue("--lr-font").trim()||"sans-serif"}fontWeight(){return this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue("--lr-font-weight-semibold").trim()||DEFAULT_WORD_FONT_WEIGHT}paletteColors(){if(this.palette?.length){const colors2=this.palette.map(sanitizeCssColor).filter(color=>color!==void 0);if(colors2.length)return colors2}const cs=this.ownerDocument.defaultView?.getComputedStyle(this),colors=[];for(let i=0;i<PALETTE_SIZE;i++)colors.push(cs?.getPropertyValue(`--lr-word-cloud-color-${i+1}`).trim()||cs?.getPropertyValue(`--_lr-word-cloud-color-${i+1}-default`).trim()||FALLBACK_PALETTE[i]);return colors}resolvePaint(){const placed=this.cachedLayout.placed,colors=this.paletteColors(),groupColor=new Map,fills=placed.map(word=>{const ownColor=sanitizeCssColor(word.color);return ownColor||(word.group?(groupColor.has(word.group)||groupColor.set(word.group,colors[groupColor.size%colors.length]),groupColor.get(word.group)):colors[word.originalIndex%colors.length])}),entries=this.legendInputCount>0?this.legend:placed.reduce((items,word,index)=>{if(!word.group&&!word.color)return items;const label=word.group||word.text,color=fills[index];return items.some(item=>item.label===label&&item.color===color)||items.push({label,color}),items},[]);return{fills,legend:entries.map(({label,color})=>({label,color:sanitizeCssColor(color)??"transparent"}))}}willUpdate(changed){super.willUpdate(changed),(changed.has("words")||changed.has("minFontSize")||changed.has("maxFontSize")||changed.has("domain")||changed.has("scale")||changed.has("wordRotation"))&&this.relayout()}relayout(preserveInteraction=!1){const focusedOriginalIndex=preserveInteraction&&this.focusedIndex!==null?this.order[this.focusedIndex]?.originalIndex:void 0,priorLiveText=this.liveText,fontWeight=this.fontWeight(),fontFamily=this.fontFamily(),measureText=(text,fontSize)=>{const ctx=getScratchCtx(this.ownerDocument);return ctx?(ctx.font=`${fontWeight} ${fontSize}px ${fontFamily}`,ctx.measureText(text).width):text.length*fontSize*.6},minFontSize=finiteRange(this.minFontSize,DEFAULT_MIN_FONT_SIZE,MIN_SANE_FONT_SIZE,MAX_FONT_SIZE_PX),maxFontSize=finiteRange(this.maxFontSize,DEFAULT_MAX_FONT_SIZE,MIN_SANE_FONT_SIZE,MAX_FONT_SIZE_PX);this.cachedLayout=layoutWordCloud(this.words,{minFontSize,maxFontSize,domain:this.domain,scale:this.scale,wordRotation:this.wordRotation,measureText}),this.order=[...this.cachedLayout.placed].sort((a,b)=>a.originalIndex-b.originalIndex),this.paint=void 0;const skippedCount=this.inputDroppedCount+this.cachedLayout.skippedCount;if(skippedCount>0&&warnSkippedWords(skippedCount,this.warnedSkipCounts),focusedOriginalIndex!==void 0){const nextIndex=this.order.findIndex(word=>word.originalIndex===focusedOriginalIndex);this.focusedIndex=nextIndex<0?null:nextIndex,this.liveText=nextIndex<0?"":priorLiveText}else this.focusedIndex=null,this.liveText="";this.hoveredOriginalIndex=null}refreshTheme(){this.relayout(!0),this.captureThemeSignatures(),this.requestUpdate()}captureThemeSignatures(){this.typographyThemeSignature=`${this.fontWeight()}\0${this.fontFamily()}`,this.paletteThemeSignature=this.paletteColors().join("\0")}firstUpdated(changed){super.firstUpdated(changed),this.captureThemeSignatures()}activate(word){this.emit("lr-word-activate",Object.freeze({text:word.text,weight:word.weight,group:word.group}))}announce(word){const text=this.localize("wordCloudWordAnnouncement",void 0,{text:word.text,weight:getNumberFormat(this.effectiveLocale).format(word.weight)});this.liveText=text,this.announcements.announcePolite(text)}wordIndex(word){return this.order.findIndex(candidate=>candidate.originalIndex===word.originalIndex)}nearestWord(event){const svgElement=this.svgEl;if(!svgElement||this.cachedLayout.placed.length===0)return;let x,y;try{const matrix=svgElement.getScreenCTM(),DOMPointCtor=this.ownerDocument.defaultView?.DOMPoint;if(!matrix||!DOMPointCtor)throw new Error("No SVG transform");const point=new DOMPointCtor(event.clientX,event.clientY).matrixTransform(matrix.inverse());x=point.x,y=point.y}catch{const rect=svgElement.getBoundingClientRect();if(rect.width<=0||rect.height<=0)return;x=(event.clientX-rect.left)/rect.width*this.cachedLayout.width,y=(event.clientY-rect.top)/rect.height*this.cachedLayout.height}let nearest,distance=Number.POSITIVE_INFINITY;for(const word of this.cachedLayout.placed){const box=this.focusRingRect(word),dx=Math.max(box.x-x,0,x-box.x-box.width),dy=Math.max(box.y-y,0,y-box.y-box.height),candidateDistance=dx*dx+dy*dy;candidateDistance<distance&&(distance=candidateDistance,nearest=word)}return nearest}collectionSummary(shown,total,itemLabel){return this.localize("paginationSummary",void 0,{start:this.formatCount(shown===0?0:1),end:this.formatCount(shown),total:this.formatCount(total),itemLabel})}renderLegend(entries,explicitInput){if(!this.withLegend)return nothing;const hasLimit=explicitInput&&(this.legendDroppedCount>0||this.legendTruncatedCount>0);if(entries.length===0&&!hasLimit)return nothing;const limitText=hasLimit?this.collectionSummary(entries.length,this.legendInputCount,this.localize("items")):"";return html`
|
|
1
|
+
import{__decorate}from"tslib";import{sourceCount,sourceRevision}from"../../../internal/source-request-controller.js";import{CollectionSourceTracker}from"../../../internal/collection-source-tracker.js";import{html,nothing,svg}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{specialistTokens}from"../../../internal/specialist-host-tokens.styles.js";import{hostAriaLabel,srOnly}from"../../../internal/a11y.js";import{syncAriaDescribedByElements,updateDescriptionBaseline}from"../../../internal/aria-reflection.js";import{isRtl}from"../../../internal/rtl.js";import{getScratchCtx}from"../../../internal/canvas.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{finiteNumber,finiteRange}from"../../../internal/numbers.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{ThemeWatcher}from"../../../internal/theme-watcher.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{devWarn}from"../../../internal/dev-mode-attribute-warning.js";import{layoutWordCloud,MAX_FONT_SIZE_PX,MAX_WORDS,MIN_SANE_FONT_SIZE}from"./word-cloud-layout.js";import{styles}from"./word-cloud.styles.js";import{LYRA_DEFAULT_wordCloud,LYRA_DEFAULT_wordCloudLegend,LYRA_DEFAULT_wordCloudPreparedSummary,LYRA_DEFAULT_wordCloudPreparedUnavailable,LYRA_DEFAULT_wordCloudWord,LYRA_DEFAULT_wordCloudWordAnnouncement,LYRA_DEFAULT_wordCloudWords}from"../../../internal/default-strings/data.generated.js";import{LYRA_DEFAULT_items,LYRA_DEFAULT_noData,LYRA_DEFAULT_paginationSummary}from"../../../internal/default-strings/shared.generated.js";const DEFAULT_MIN_FONT_SIZE=12,DEFAULT_MAX_FONT_SIZE=48,PALETTE_SIZE=8,FALLBACK_PALETTE=["#0969da","#1a7f37","#9a6700","#cf222e","#8250df","#bf3989","#0a7d91","#57606a"],DEFAULT_WORD_FONT_WEIGHT="600",NAV_KEYS=new Set(["ArrowRight","ArrowDown","ArrowLeft","ArrowUp","Home","End"]),FOCUS_RING_PAD=2,MAX_INPUT_WORDS=1e4,MAX_WORD_TEXT=256,MAX_TOTAL_WORD_TEXT=16384,MAX_LEGEND_ITEMS=100,MAX_LEGEND_TEXT=256,MAX_TOTAL_LEGEND_TEXT=8192,MAX_PALETTE_ITEMS=64;function preparedField(value,key){if(typeof value!="object"||value===null)throw new TypeError("Invalid prepared word record");const descriptor=Object.getOwnPropertyDescriptor(value,key);if(!descriptor||!("value"in descriptor))throw new TypeError("Prepared word fields must be own data properties");return descriptor.value}function preparedWeight(value){if(typeof value!="number"||!Number.isFinite(value)||value<0)throw new TypeError("Invalid prepared word weight");return value}function preparedText(value){if(typeof value!="string"||value.length>MAX_WORD_TEXT||!value.trim())throw new TypeError("Invalid prepared word text");return value}function snapshotPreparedWords(value){const revision=sourceRevision(preparedField(value,"revision")),rawCounts=preparedField(value,"counts"),source=sourceCount(preparedField(rawCounts,"sourceCount")),valid=sourceCount(preparedField(rawCounts,"validCount")),invalid=sourceCount(preparedField(rawCounts,"invalidCount"));if(!Number.isSafeInteger(valid+invalid)||valid+invalid!==source)throw new RangeError("Prepared word counts do not conserve observations");const totalWeight=preparedWeight(preparedField(value,"totalWeight")),retainedWeight=preparedWeight(preparedField(value,"retainedWeight")),raw=preparedField(value,"words");if(!Array.isArray(raw))throw new TypeError("Invalid prepared words");const length=sourceCount(preparedField(raw,"length"));if(length>MAX_WORDS||length>valid||valid>0&&length===0)throw new RangeError("Prepared word capacity exceeded");const words=[],ids=new Set;let weightSum=0,textUnits=0,largestWeight=0;for(let index=0;index<length;index++){const word=preparedField(raw,String(index)),id=preparedText(preparedField(word,"id")),text=preparedText(preparedField(word,"text")),weight=preparedWeight(preparedField(word,"weight"));if(ids.has(id))throw new TypeError("Duplicate prepared word ID");if(ids.add(id),textUnits+=text.length,weightSum+=weight,largestWeight=Math.max(largestWeight,weight),textUnits>MAX_TOTAL_WORD_TEXT||!Number.isFinite(weightSum))throw new RangeError("Prepared word budget exceeded");words.push(Object.freeze({id,text,weight}))}if(weightSum!==retainedWeight||totalWeight<largestWeight||valid===0&&(totalWeight!==0||retainedWeight!==0))throw new RangeError("Inconsistent prepared word weights");if(retainedWeight>totalWeight||valid===length&&totalWeight>retainedWeight){const rounding=((valid===length?valid:source)+length)*(Number.EPSILON/2),gamma=rounding<1?rounding/(1-rounding):1,relativeDifference=Math.abs(retainedWeight-totalWeight)/Math.max(retainedWeight,totalWeight);if(totalWeight===0||relativeDifference>gamma)throw new RangeError("Inconsistent prepared total weight")}return Object.freeze({revision,counts:Object.freeze({sourceCount:source,validCount:valid,invalidCount:invalid}),totalWeight,retainedWeight,words:Object.freeze(words)})}function warnSkippedWords(count,warnedSkipCounts){warnedSkipCounts.has(count)||(warnedSkipCounts.add(count),devWarn(`<lr-word-cloud> could not place ${count} word(s) (blank text, over the ${MAX_WORDS}-word cap, or the layout search was exhausted) -- they were dropped, not rendered.`))}function boundedText(value,limit){return value.length<=limit?value:`${value.slice(0,Math.max(0,limit-1))}…`}function normalizeWords(value){let input;try{input=Array.isArray(value)?value:[]}catch{input=[]}let inputCount=0;try{inputCount=Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,input.length))}catch{inputCount=0}const scanCount=Math.min(inputCount,MAX_INPUT_WORDS),words=[];let dropped=Math.max(0,inputCount-scanCount),truncated=0,characters=0;for(let index=0;index<scanCount;index++)try{const candidate=input[index];if(typeof candidate!="object"||candidate===null){dropped++;continue}const rawText=candidate.text,rawWeight=candidate.weight,rawColor=candidate.color,rawGroup=candidate.group;if(typeof rawText!="string"){dropped++;continue}const remaining=MAX_TOTAL_WORD_TEXT-characters;if(remaining<=0){dropped+=scanCount-index;break}const textLimit=Math.min(MAX_WORD_TEXT,remaining),text=boundedText(rawText,textLimit);if(!text.trim()){dropped++;continue}let itemTruncated=rawText.length>textLimit;characters+=text.length;const boundedOptionalText=raw=>{if(typeof raw!="string")return;const available=MAX_TOTAL_WORD_TEXT-characters;if(available<=0){raw.length>0&&(itemTruncated=!0);return}const limit=Math.min(MAX_WORD_TEXT,available),result=boundedText(raw,limit);return raw.length>limit&&(itemTruncated=!0),characters+=result.length,result},color=boundedOptionalText(rawColor),group=boundedOptionalText(rawGroup),word={text,weight:Math.max(0,finiteNumber(typeof rawWeight=="number"?rawWeight:0,0)),...color===void 0?{}:{color},...group===void 0?{}:{group}};itemTruncated&&truncated++,words.push(Object.freeze(word))}catch{dropped++}return{items:Object.freeze(words),dropped,truncated,inputCount}}function normalizeLegend(value){let input;try{input=Array.isArray(value)?value:[]}catch{input=[]}let inputCount=0;try{inputCount=Math.max(0,Math.min(Number.MAX_SAFE_INTEGER,input.length))}catch{inputCount=0}const length=Math.min(inputCount,MAX_LEGEND_ITEMS),legend=[];let dropped=Math.max(0,inputCount-length),truncated=0,characters=0;for(let index=0;index<length;index++)try{const item=input[index];if(typeof item!="object"||item===null){dropped++;continue}const rawLabel=item.label,rawColor=item.color;if(typeof rawLabel!="string"||typeof rawColor!="string"){dropped++;continue}const remaining=MAX_TOTAL_LEGEND_TEXT-characters;if(remaining<=0){dropped+=length-index;break}const labelLimit=Math.min(MAX_LEGEND_TEXT,remaining),label=boundedText(rawLabel,labelLimit);if(!label.trim()){dropped++;continue}let itemTruncated=rawLabel.length>labelLimit;characters+=label.length;const colorRemaining=MAX_TOTAL_LEGEND_TEXT-characters,colorLimit=Math.min(MAX_WORD_TEXT,Math.max(0,colorRemaining)),color=colorLimit>0?boundedText(rawColor,colorLimit):"";rawColor.length>colorLimit&&(itemTruncated=!0),characters+=color.length,itemTruncated&&truncated++,legend.push(Object.freeze({label,color}))}catch{dropped++}return{items:Object.freeze(legend),dropped,truncated,inputCount}}function normalizePalette(value){let input;try{input=Array.isArray(value)?value:[]}catch{return}let length=0;try{length=Math.min(input.length,MAX_PALETTE_ITEMS)}catch{return}const palette=[];for(let index=0;index<length;index++)try{const entry=input[index];typeof entry=="string"&&palette.push(boundedText(entry,MAX_WORD_TEXT))}catch{}return Object.freeze(palette)}class LyraWordCloud extends LyraElement{static{this.defaultStrings={...super.defaultStrings,items:LYRA_DEFAULT_items,noData:LYRA_DEFAULT_noData,paginationSummary:LYRA_DEFAULT_paginationSummary,wordCloud:LYRA_DEFAULT_wordCloud,wordCloudLegend:LYRA_DEFAULT_wordCloudLegend,wordCloudPreparedSummary:LYRA_DEFAULT_wordCloudPreparedSummary,wordCloudPreparedUnavailable:LYRA_DEFAULT_wordCloudPreparedUnavailable,wordCloudWord:LYRA_DEFAULT_wordCloudWord,wordCloudWordAnnouncement:LYRA_DEFAULT_wordCloudWordAnnouncement,wordCloudWords:LYRA_DEFAULT_wordCloudWords}}static{this.styles=[LyraElement.styles,specialistTokens,styles,srOnly]}get preparedWords(){return this._preparedWords}set preparedWords(value){const previous=this._preparedWords;this._preparedWords=value,this.requestUpdate("preparedWords",previous),previous===value&&this.requestUpdate()}requestUpdate(...args){(args[0]==="preparedWords"||args[0]===void 0&&this._preparedWords!==null)&&(this.preparedDirty=!0,this.preparedGeneration=(this.preparedGeneration??0)+1),super.requestUpdate(...args)}refreshPreparedWords(){if(!this.preparedDirty)return!1;this.preparedDirty=!1;const input=this._preparedWords,generation=this.preparedGeneration;let snapshot,invalid=!1;if(input!==null)try{snapshot=snapshotPreparedWords(input)}catch{invalid=!0}return generation!==this.preparedGeneration||input!==this._preparedWords?!1:(this.preparedActive=input!==null,this.preparedInvalid=invalid,this.preparedSnapshot=snapshot,!0)}preparedMessage(){if(this.preparedInvalid)return this.localize("wordCloudPreparedUnavailable");const model=this.preparedSnapshot;return model?this.localize("wordCloudPreparedSummary",void 0,{retainedCount:this.formatCount(model.words.length),validCount:this.formatCount(model.counts.validCount),invalidCount:this.formatCount(model.counts.invalidCount),retainedWeight:this.formatCount(model.retainedWeight),totalWeight:this.formatCount(model.totalWeight)}):""}get words(){return this._words}set words(value){if(this.assignedSources.isRebind("words",value,this._words))return;const previous=this._words,normalized=normalizeWords(value);this._words=normalized.items,this.inputDroppedCount=normalized.dropped,this.inputTruncatedCount=normalized.truncated,this.inputWordCount=normalized.inputCount,this.requestUpdate("words",previous)}get scale(){return this._scale}set scale(value){const normalized=value==="sqrt"?"sqrt":"linear",previous=this._scale;if(previous===normalized){value!==normalized&&this.requestUpdate("scale",previous);return}this._scale=normalized,this.requestUpdate("scale",previous)}get wordRotation(){return this._wordRotation}set wordRotation(value){const normalized=value==="mixed"?"mixed":"none",previous=this._wordRotation;if(previous===normalized){value!==normalized&&this.requestUpdate("wordRotation",previous);return}this._wordRotation=normalized,this.requestUpdate("wordRotation",previous)}get palette(){return this._palette}set palette(value){if(this.assignedSources.isRebind("palette",value,this._palette))return;const previous=this._palette;this._palette=normalizePalette(value),this.paint=void 0,this.requestUpdate("palette",previous)}get legend(){return this._legend}set legend(value){if(this.assignedSources.isRebind("legend",value,this._legend))return;const previous=this._legend,normalized=normalizeLegend(value);this._legend=normalized.items,this.legendDroppedCount=normalized.dropped,this.legendTruncatedCount=normalized.truncated,this.legendInputCount=normalized.inputCount,this.paint=void 0,this.requestUpdate("legend",previous)}constructor(){super(),this._preparedWords=null,this.preparedDirty=!0,this.preparedGeneration=0,this.preparedContinuationQueued=!1,this.preparedActive=!1,this.preparedInvalid=!1,this.preparedAnnouncementMounted=!1,this.previousPreparedMessage="",this._words=[],this.assignedSources=new CollectionSourceTracker,this.inputDroppedCount=0,this.inputTruncatedCount=0,this.inputWordCount=0,this.minFontSize=DEFAULT_MIN_FONT_SIZE,this.maxFontSize=DEFAULT_MAX_FONT_SIZE,this._scale="linear",this._wordRotation="none",this._legend=[],this.legendDroppedCount=0,this.legendTruncatedCount=0,this.legendInputCount=0,this.withLegend=!1,this.cachedLayout={placed:[],skipped:[],skippedCount:0,width:0,height:0},this.order=[],this.focusedIndex=null,this.liveText="",this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null,this.announcements=new AnnouncementSinkController(this,{eager:["polite"]}),this.warnedSkipCounts=new Set,this.typographyThemeSignature="",this.paletteThemeSignature="",this.hasSyncedDescribedByElements=!1,this.onThemeInvalidated=()=>{const typography=`${this.fontWeight()}\0${this.fontFamily()}`,palette=this.paletteColors().join("\0");if(!this.typographyThemeSignature||typography!==this.typographyThemeSignature){this.refreshTheme();return}palette!==this.paletteThemeSignature&&(this.paletteThemeSignature=palette,this.paint=void 0,this.requestUpdate("paletteTheme",null))},this.onSvgFocus=()=>{this.focusedIndex===null&&this.cachedLayout.placed.length>0&&(this.focusedIndex=0)},this.onSvgPointerDown=event=>{const word=this.nearestWord(event);if(!word)return;const index=this.wordIndex(word);index<0||(this.focusedIndex=index,this.pressedOriginalIndex=word.originalIndex,this.svgEl?.focus())},this.onSvgPointerMove=event=>{this.hoveredOriginalIndex=this.nearestWord(event)?.originalIndex??null},this.clearPointerPress=()=>{this.pressedOriginalIndex=null},this.onSvgPointerLeave=()=>{this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null},this.onSvgClick=event=>{const word=this.nearestWord(event);word&&this.onWordClick(word)},this.onWordClick=word=>{if(!this.isConnected||!this.cachedLayout.placed.includes(word))return;const order=this.order,idx=order.findIndex(w=>w.originalIndex===word.originalIndex);this.focusedIndex=idx===-1?null:idx,idx!==-1&&this.announce(order[idx]),this.svgEl?.focus(),this.activate(word)},this.onKeyDown=e=>{const order=this.order;if(order.length===0)return;if(e.key==="Enter"||e.key===" "){e.preventDefault(),this.focusedIndex!==null&&this.activate(order[this.focusedIndex]);return}if(!NAV_KEYS.has(e.key))return;if(e.preventDefault(),this.focusedIndex===null){const next2=e.key==="End"?order.length-1:0;this.focusedIndex=next2,this.announce(order[next2]);return}const rtl=isRtl(this),forwardKey=rtl?"ArrowLeft":"ArrowRight",backwardKey=rtl?"ArrowRight":"ArrowLeft";let next=this.focusedIndex;e.key===forwardKey||e.key==="ArrowDown"?next=Math.min(order.length-1,this.focusedIndex+1):e.key===backwardKey||e.key==="ArrowUp"?next=Math.max(0,this.focusedIndex-1):e.key==="Home"?next=0:e.key==="End"&&(next=order.length-1),this.focusedIndex=next,this.announce(order[next])},this.hitRects=new WeakMap,new ThemeWatcher(this,this.onThemeInvalidated)}connectedCallback(){super.connectedCallback(),this.preparedAnnouncementMounted=!1,this._preparedWords!==null&&(this.preparedDirty=!0,this.requestUpdate("preparedReconnect",null))}disconnectedCallback(){super.disconnectedCallback(),this.focusedIndex=null,this.liveText="",this.pressedOriginalIndex=null,this.hoveredOriginalIndex=null,this.preparedAnnouncementMounted=!1,this.previousPreparedMessage=""}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted(),this.preparedAnnouncementMounted=!1,this._preparedWords!==null&&(this.preparedDirty=!0,this.requestUpdate("preparedAdoption",null))}updated(changed){super.updated(changed),this.preparedDirty&&this.isConnected&&!this.preparedContinuationQueued&&(this.preparedContinuationQueued=!0,queueMicrotask(()=>{this.preparedContinuationQueued=!1,this.preparedDirty&&this.isConnected&&this.requestUpdate("preparedContinuation",null)}));const message=this.preparedMessage();this.preparedAnnouncementMounted&&message&&message!==this.previousPreparedMessage&&(this.preparedInvalid?this.announcements.announceAssertive(message):this.announcements.announcePolite(message)),this.previousPreparedMessage=message,this.preparedAnnouncementMounted=!0;const describedBy=this.getAttribute("aria-describedby");if(!describedBy&&!this.hasSyncedDescribedByElements&&!this.preparedSnapshot)return;this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,this.svgEl,describedBy);const control=this.svgEl;if(control&&"ariaDescribedByElements"in control){const references=[...control.ariaDescribedByElements??[]];for(const id of["prepared-summary","word-limit"]){const own=this.shadowRoot?.getElementById(id);own&&references.push(own)}updateDescriptionBaseline(control,()=>{control.ariaDescribedByElements=references}),this.hasSyncedDescribedByElements||=references.length>0}}fontFamily(){return this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue("--lr-font").trim()||"sans-serif"}fontWeight(){return this.ownerDocument.defaultView?.getComputedStyle(this).getPropertyValue("--lr-font-weight-semibold").trim()||DEFAULT_WORD_FONT_WEIGHT}paletteColors(){if(this.palette?.length){const colors2=this.palette.map(sanitizeCssColor).filter(color=>color!==void 0);if(colors2.length)return colors2}const cs=this.ownerDocument.defaultView?.getComputedStyle(this),colors=[];for(let i=0;i<PALETTE_SIZE;i++)colors.push(cs?.getPropertyValue(`--lr-word-cloud-color-${i+1}`).trim()||cs?.getPropertyValue(`--_lr-word-cloud-color-${i+1}-default`).trim()||FALLBACK_PALETTE[i]);return colors}resolvePaint(){const placed=this.cachedLayout.placed,colors=this.paletteColors(),groupColor=new Map,fills=placed.map(word=>{const ownColor=sanitizeCssColor(word.color);return ownColor||(word.group?(groupColor.has(word.group)||groupColor.set(word.group,colors[groupColor.size%colors.length]),groupColor.get(word.group)):colors[word.originalIndex%colors.length])}),entries=this.legendInputCount>0?this.legend:placed.reduce((items,word,index)=>{if(!word.group&&!word.color)return items;const label=word.group||word.text,color=fills[index];return items.some(item=>item.label===label&&item.color===color)||items.push({label,color}),items},[]);return{fills,legend:entries.map(({label,color})=>({label,color:sanitizeCssColor(color)??"transparent"}))}}willUpdate(changed){super.willUpdate(changed),(this.refreshPreparedWords()||!this.preparedActive&&changed.has("words")||changed.has("minFontSize")||changed.has("maxFontSize")||changed.has("domain")||changed.has("scale")||changed.has("wordRotation"))&&this.relayout()}relayout(preserveInteraction=!1){const focusedOriginalIndex=preserveInteraction&&this.focusedIndex!==null?this.order[this.focusedIndex]?.originalIndex:void 0,priorLiveText=this.liveText,fontWeight=this.fontWeight(),fontFamily=this.fontFamily(),measureText=(text,fontSize)=>{const ctx=getScratchCtx(this.ownerDocument);return ctx?(ctx.font=`${fontWeight} ${fontSize}px ${fontFamily}`,ctx.measureText(text).width):text.length*fontSize*.6},minFontSize=finiteRange(this.minFontSize,DEFAULT_MIN_FONT_SIZE,MIN_SANE_FONT_SIZE,MAX_FONT_SIZE_PX),maxFontSize=finiteRange(this.maxFontSize,DEFAULT_MAX_FONT_SIZE,MIN_SANE_FONT_SIZE,MAX_FONT_SIZE_PX);this.committedPrepared=this.preparedSnapshot,this.cachedLayout=layoutWordCloud(this.preparedActive?this.preparedSnapshot?.words??[]:this.words,{minFontSize,maxFontSize,domain:this.domain,scale:this.scale,wordRotation:this.wordRotation,measureText}),this.hitRects=new WeakMap(this.cachedLayout.placed.map(word=>[word,this.focusRingRect(word)])),this.order=[...this.cachedLayout.placed].sort((a,b)=>a.originalIndex-b.originalIndex),this.paint=void 0;const skippedCount=(this.preparedActive?0:this.inputDroppedCount)+this.cachedLayout.skippedCount;if(skippedCount>0&&warnSkippedWords(skippedCount,this.warnedSkipCounts),focusedOriginalIndex!==void 0){const nextIndex=this.order.findIndex(word=>word.originalIndex===focusedOriginalIndex);this.focusedIndex=nextIndex<0?null:nextIndex,this.liveText=nextIndex<0?"":priorLiveText}else this.focusedIndex=null,this.liveText="";this.hoveredOriginalIndex=null}refreshTheme(){if(this.preparedDirty&&this._preparedWords!==null){this.requestUpdate("typographyTheme",null);return}this.relayout(!0),this.captureThemeSignatures(),this.requestUpdate("typographyTheme",null)}captureThemeSignatures(){this.typographyThemeSignature=`${this.fontWeight()}\0${this.fontFamily()}`,this.paletteThemeSignature=this.paletteColors().join("\0")}firstUpdated(changed){super.firstUpdated(changed),this.captureThemeSignatures()}activate(word){if(!this.isConnected||!this.cachedLayout.placed.includes(word))return;const model=this.committedPrepared,original=model?.words[word.originalIndex];this.emit("lr-word-activate",Object.freeze({text:word.text,weight:word.weight,group:word.group,...original?{id:original.id,revision:model.revision}:{}}))}announce(word){const text=this.localize("wordCloudWordAnnouncement",void 0,{text:word.text,weight:getNumberFormat(this.effectiveLocale).format(word.weight)});this.liveText=text,this.announcements.announcePolite(text)}wordIndex(word){return this.order.findIndex(candidate=>candidate.originalIndex===word.originalIndex)}nearestWord(event){const svgElement=this.svgEl;if(!svgElement||this.cachedLayout.placed.length===0)return;let x,y;try{const matrix=svgElement.getScreenCTM(),DOMPointCtor=this.ownerDocument.defaultView?.DOMPoint;if(!matrix||!DOMPointCtor)throw new Error("No SVG transform");const point=new DOMPointCtor(event.clientX,event.clientY).matrixTransform(matrix.inverse());x=point.x,y=point.y}catch{const rect=svgElement.getBoundingClientRect();if(rect.width<=0||rect.height<=0)return;x=(event.clientX-rect.left)/rect.width*this.cachedLayout.width,y=(event.clientY-rect.top)/rect.height*this.cachedLayout.height}let nearest,distance=Number.POSITIVE_INFINITY;for(const word of this.cachedLayout.placed){const box=this.hitRects.get(word),dx=Math.max(box.x-x,0,x-box.x-box.width),dy=Math.max(box.y-y,0,y-box.y-box.height),candidateDistance=dx*dx+dy*dy;candidateDistance<distance&&(distance=candidateDistance,nearest=word)}return nearest}collectionSummary(shown,total,itemLabel){return this.localize("paginationSummary",void 0,{start:this.formatCount(shown===0?0:1),end:this.formatCount(shown),total:this.formatCount(total),itemLabel})}renderLegend(entries,explicitInput){if(!this.withLegend)return nothing;const hasLimit=explicitInput&&(this.legendDroppedCount>0||this.legendTruncatedCount>0);if(entries.length===0&&!hasLimit)return nothing;const limitText=hasLimit?this.collectionSummary(entries.length,this.legendInputCount,this.localize("items")):"";return html`
|
|
2
2
|
${entries.length?html`<div
|
|
3
3
|
part="legend"
|
|
4
4
|
role="list"
|
|
@@ -17,16 +17,18 @@ import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property,
|
|
|
17
17
|
`)}
|
|
18
18
|
</div>`:nothing}
|
|
19
19
|
${hasLimit?html`<div id="legend-limit" part="legend-limit">${limitText}</div>`:nothing}
|
|
20
|
-
`}focusRingRect(w){const boxW=w.rotated?w.height:w.width,boxH=w.rotated?w.width:w.height;return{x:w.x-boxW/2-FOCUS_RING_PAD,y:w.y-boxH/2-FOCUS_RING_PAD,width:boxW+2*FOCUS_RING_PAD,height:boxH+2*FOCUS_RING_PAD}}render(){const layout=this.cachedLayout,inputCount=Math.max(this.inputWordCount,this.words.length),hasWordLimit=this.inputDroppedCount+layout.skippedCount>0
|
|
20
|
+
`}focusRingRect(w){const boxW=w.rotated?w.height:w.width,boxH=w.rotated?w.width:w.height;return{x:w.x-boxW/2-FOCUS_RING_PAD,y:w.y-boxH/2-FOCUS_RING_PAD,width:boxW+2*FOCUS_RING_PAD,height:boxH+2*FOCUS_RING_PAD}}render(){const layout=this.cachedLayout;if(this.preparedInvalid)return html`<div part="base"><div part="error">${this.preparedMessage()}</div></div>`;const preparedSummary=this.preparedSnapshot?html`<div id="prepared-summary" part="summary">${this.preparedMessage()}</div>`:nothing,inputCount=this.preparedActive?this.preparedSnapshot?.words.length??0:Math.max(this.inputWordCount,this.words.length),hasWordLimit=(this.preparedActive?0:this.inputDroppedCount)+layout.skippedCount>0||!this.preparedActive&&this.inputTruncatedCount>0,wordLimitText=hasWordLimit?this.collectionSummary(layout.placed.length,inputCount,this.localize(layout.placed.length===1&&inputCount===1?"wordCloudWord":"wordCloudWords")):"";if(layout.placed.length===0)return html`<div part="base">
|
|
21
|
+
${preparedSummary}
|
|
21
22
|
<div part="empty">${this.localize("noData")}</div>
|
|
22
23
|
${hasWordLimit?html`<div id="word-limit" part="limit">${wordLimitText}</div>`:nothing}
|
|
23
24
|
</div>`;const{fills,legend}=this.paint??=this.resolvePaint(),order=this.order,focused=this.focusedIndex!==null?order[this.focusedIndex]:void 0,ring=focused?this.focusRingRect(focused):void 0,generatedLabel=this.localize("wordCloud",void 0,{count:this.formatCount(layout.placed.length),word:this.localize(layout.placed.length===1?"wordCloudWord":"wordCloudWords")}),accessibleLabel=hostAriaLabel(this)??generatedLabel;return html`
|
|
24
25
|
<div part="base">
|
|
26
|
+
${preparedSummary}
|
|
25
27
|
<svg
|
|
26
28
|
part="svg"
|
|
27
29
|
role="application"
|
|
28
30
|
aria-label=${accessibleLabel}
|
|
29
|
-
aria-describedby=${[this.getAttribute("aria-describedby")??"",hasWordLimit?"word-limit":""].filter(Boolean).join(" ")||nothing}
|
|
31
|
+
aria-describedby=${[this.getAttribute("aria-describedby")??"",this.preparedSnapshot?"prepared-summary":"",hasWordLimit?"word-limit":""].filter(Boolean).join(" ")||nothing}
|
|
30
32
|
tabindex="0"
|
|
31
33
|
viewBox="0 0 ${layout.width} ${layout.height}"
|
|
32
34
|
@focus=${this.onSvgFocus}
|
|
@@ -60,4 +62,4 @@ import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property,
|
|
|
60
62
|
${hasWordLimit?html`<div id="word-limit" part="limit">${wordLimitText}</div>`:nothing}
|
|
61
63
|
${this.renderLegend(legend,this.legendInputCount>0)}
|
|
62
64
|
</div>
|
|
63
|
-
`}formatCount(value){return getNumberFormat(this.effectiveLocale).format(value)}}__decorate([property({attribute:!1})],LyraWordCloud.prototype,"words",null),__decorate([property({attribute:"min-font-size",type:Number})],LyraWordCloud.prototype,"minFontSize",void 0),__decorate([property({attribute:"max-font-size",type:Number})],LyraWordCloud.prototype,"maxFontSize",void 0),__decorate([property({attribute:!1,hasChanged:(value,previous)=>value?.[0]!==previous?.[0]||value?.[1]!==previous?.[1]})],LyraWordCloud.prototype,"domain",void 0),__decorate([property({reflect:!0})],LyraWordCloud.prototype,"scale",null),__decorate([property({attribute:"word-rotation",reflect:!0})],LyraWordCloud.prototype,"wordRotation",null),__decorate([property({attribute:!1})],LyraWordCloud.prototype,"palette",null),__decorate([property({attribute:!1})],LyraWordCloud.prototype,"legend",null),__decorate([property({type:Boolean,reflect:!0,attribute:"with-legend"})],LyraWordCloud.prototype,"withLegend",void 0),__decorate([query('[part="svg"]')],LyraWordCloud.prototype,"svgEl",void 0),__decorate([state()],LyraWordCloud.prototype,"focusedIndex",void 0),__decorate([state()],LyraWordCloud.prototype,"liveText",void 0),__decorate([state()],LyraWordCloud.prototype,"pressedOriginalIndex",void 0),__decorate([state()],LyraWordCloud.prototype,"hoveredOriginalIndex",void 0);export{LyraWordCloud};
|
|
65
|
+
`}formatCount(value){return getNumberFormat(this.effectiveLocale).format(value)}}__decorate([property({attribute:!1})],LyraWordCloud.prototype,"preparedWords",null),__decorate([property({attribute:!1})],LyraWordCloud.prototype,"words",null),__decorate([property({attribute:"min-font-size",type:Number})],LyraWordCloud.prototype,"minFontSize",void 0),__decorate([property({attribute:"max-font-size",type:Number})],LyraWordCloud.prototype,"maxFontSize",void 0),__decorate([property({attribute:!1,hasChanged:(value,previous)=>value?.[0]!==previous?.[0]||value?.[1]!==previous?.[1]})],LyraWordCloud.prototype,"domain",void 0),__decorate([property({reflect:!0})],LyraWordCloud.prototype,"scale",null),__decorate([property({attribute:"word-rotation",reflect:!0})],LyraWordCloud.prototype,"wordRotation",null),__decorate([property({attribute:!1})],LyraWordCloud.prototype,"palette",null),__decorate([property({attribute:!1})],LyraWordCloud.prototype,"legend",null),__decorate([property({type:Boolean,reflect:!0,attribute:"with-legend"})],LyraWordCloud.prototype,"withLegend",void 0),__decorate([query('[part="svg"]')],LyraWordCloud.prototype,"svgEl",void 0),__decorate([state()],LyraWordCloud.prototype,"focusedIndex",void 0),__decorate([state()],LyraWordCloud.prototype,"liveText",void 0),__decorate([state()],LyraWordCloud.prototype,"pressedOriginalIndex",void 0),__decorate([state()],LyraWordCloud.prototype,"hoveredOriginalIndex",void 0);export{LyraWordCloud};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{iconHitTarget,focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: block; --_lr-word-cloud-color-1-default: var(--lr-color-brand); --_lr-word-cloud-color-2-default: var(--lr-color-success); --_lr-word-cloud-color-3-default: var(--lr-color-warning); --_lr-word-cloud-color-4-default: var(--lr-color-danger); --_lr-word-cloud-color-5-default: var(--lr-color-chart-1); --_lr-word-cloud-color-6-default: var(--lr-color-chart-2); --_lr-word-cloud-color-7-default: var(--lr-color-chart-3); --_lr-word-cloud-color-8-default: var(--lr-color-chart-4); } [part='base'] { display: flex; flex-direction: column; gap: var(--lr-space-xs); block-size: 100%; } svg { display: block; inline-size: 100%; block-size: 100%; ${iconHitTarget} cursor: pointer; } svg:hover { outline: var(--lr-border-width-thin) solid var(--lr-color-border-strong); outline-offset: var(--lr-focus-ring-offset); } svg:focus-visible { ${focusRing} } [part='word'] { pointer-events: none; font-family: var(--lr-font); font-weight: var(--lr-font-weight-semibold); text-anchor: middle; dominant-baseline: middle; transition: text-decoration-color var(--lr-transition-fast); text-decoration: underline transparent; } [part='word'][data-hovered] { text-decoration-color: currentColor; } [part='focus-ring'] { fill: none; stroke: var(--lr-focus-ring-color); stroke-width: var(--lr-focus-ring-width); pointer-events: none; } [part='focus-ring'][data-pressed] { stroke-width: var(--lr-border-width-thick); stroke-dasharray: var(--lr-size-4px) var(--lr-size-2px); } [part='empty'] { color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-md-sm); } [part='legend'] { display: flex; flex-wrap: wrap; min-inline-size: 0; max-inline-size: 100%; gap: var(--lr-space-s); align-items: center; color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-sm); } [part='legend-item'] { display: inline-flex; align-items: center; min-inline-size: 0; max-inline-size: 100%; gap: var(--lr-space-2xs); } [part='legend-swatch'] { inline-size: var(--lr-size-0-75rem); block-size: var(--lr-size-0-75rem); border-radius: var(--lr-radius-xs); flex: none; } [part='legend-label'] { min-inline-size: 0; overflow-wrap: anywhere; } [part='limit'], [part='legend-limit'] { color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-xs); font-variant-numeric: tabular-nums; text-align: end; } @media (prefers-reduced-motion: reduce) { [part='word'] { transition: none !important; } } @media (forced-colors: active) { [part='word'] { fill: CanvasText; } [part='focus-ring'] { stroke: Highlight; } [part='focus-ring'][data-pressed] { fill: Highlight; fill-opacity: 0.2; } } `;export{styles};
|
|
1
|
+
import{iconHitTarget,focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: block; --_lr-word-cloud-color-1-default: var(--lr-color-brand); --_lr-word-cloud-color-2-default: var(--lr-color-success); --_lr-word-cloud-color-3-default: var(--lr-color-warning); --_lr-word-cloud-color-4-default: var(--lr-color-danger); --_lr-word-cloud-color-5-default: var(--lr-color-chart-1); --_lr-word-cloud-color-6-default: var(--lr-color-chart-2); --_lr-word-cloud-color-7-default: var(--lr-color-chart-3); --_lr-word-cloud-color-8-default: var(--lr-color-chart-4); } [part='base'] { display: flex; flex-direction: column; gap: var(--lr-space-xs); block-size: 100%; } svg { display: block; inline-size: 100%; block-size: 100%; ${iconHitTarget} cursor: pointer; } svg:hover { outline: var(--lr-border-width-thin) solid var(--lr-color-border-strong); outline-offset: var(--lr-focus-ring-offset); } svg:focus-visible { ${focusRing} } [part='word'] { pointer-events: none; font-family: var(--lr-font); font-weight: var(--lr-font-weight-semibold); text-anchor: middle; dominant-baseline: middle; transition: text-decoration-color var(--lr-transition-fast); text-decoration: underline transparent; } [part='word'][data-hovered] { text-decoration-color: currentColor; } [part='focus-ring'] { fill: none; stroke: var(--lr-focus-ring-color); stroke-width: var(--lr-focus-ring-width); pointer-events: none; } [part='focus-ring'][data-pressed] { stroke-width: var(--lr-border-width-thick); stroke-dasharray: var(--lr-size-4px) var(--lr-size-2px); } [part='summary'], [part='error'], [part='empty'] { color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-md-sm); } [part='summary'], [part='error'] { overflow-wrap: anywhere; } [part='legend'] { display: flex; flex-wrap: wrap; min-inline-size: 0; max-inline-size: 100%; gap: var(--lr-space-s); align-items: center; color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-sm); } [part='legend-item'] { display: inline-flex; align-items: center; min-inline-size: 0; max-inline-size: 100%; gap: var(--lr-space-2xs); } [part='legend-swatch'] { inline-size: var(--lr-size-0-75rem); block-size: var(--lr-size-0-75rem); border-radius: var(--lr-radius-xs); flex: none; } [part='legend-label'] { min-inline-size: 0; overflow-wrap: anywhere; } [part='limit'], [part='legend-limit'] { color: var(--lr-color-text-quiet); font-size: var(--lr-font-size-xs); font-variant-numeric: tabular-nums; text-align: end; } @media (prefers-reduced-motion: reduce) { [part='word'] { transition: none !important; } } @media (forced-colors: active) { [part='word'] { fill: CanvasText; } [part='focus-ring'] { stroke: Highlight; } [part='focus-ring'][data-pressed] { fill: Highlight; fill-opacity: 0.2; } } `;export{styles};
|
|
@@ -41,7 +41,7 @@ get value():string;set value(next:string);
|
|
|
41
41
|
/** Normalized reset default; null removes the value attribute without restoring stale content. */
|
|
42
42
|
get defaultValue():string;set defaultValue(next:string|null);
|
|
43
43
|
/** Native filter input, or null in compact mode. Dispatch native input after direct value edits to refilter. */
|
|
44
|
-
get input():HTMLInputElement|null;private readonly slots;private labelLease?;private descriptionLease?;private validationChild?;private validationDocument?;private projectedAnchor?;private projectionToken;private restoreFocus;private replacingControl?;private focusReplacement?;private readonly validationController;protected get control():PickerControl|undefined;private get combobox();private get liveDisabled();private get rows();constructor();protected updateValidity():void;
|
|
44
|
+
get input():HTMLInputElement|null;private readonly resolvedRows;private optionsMounted;private readonly inputLimitAnnouncements;private get inputLimitMessage();private rowPresentationEpoch;requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;private readonly mountOptions;private readonly onControlShow;private readonly slots;private labelLease?;private descriptionLease?;private validationChild?;private validationDocument?;private projectedAnchor?;private projectionToken;private restoreFocus;private replacingControl?;private focusReplacement?;private readonly validationController;protected get control():PickerControl|undefined;private get combobox();private get liveDisabled();private get rows();constructor();protected updateValidity():void;
|
|
45
45
|
/** Focus the visible trigger or optional filter when enabled. */
|
|
46
46
|
focus(options?:FocusOptions):void;
|
|
47
47
|
/** Blur the visible control. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{noChange,nothing}from"lit";import{html,unsafeStatic}from"lit/static-html.js";import{property}from"lit/decorators.js";import{LyraElement}from"../../internal/lyra-element.js";import{FormAssociated,isBarredFromValidation}from"../../internal/form-associated.js";import{resolveValidityAnchor,SET_ANCHORED_VALIDITY,VALIDITY_ANCHOR}from"../../internal/anchored-validity.js";import{acquireResolvedAriaRelationship}from"../../internal/aria-controls.js";import{collectionSupport}from"../../internal/collection-snapshot.js";import{autocorrectConverter,spellcheckConverter}from"../../internal/converters.js";import{dispatchNativeEvent,relayNativeEvent}from"../../internal/native-event-relay.js";import{deepActiveElementIn,shadowFocusTarget}from"../../internal/active-element.js";import{submitOnEnter}from"../../internal/submit-on-enter.js";import{SlotPresenceController}from"../../internal/slot-presence-controller.js";import{tag}from"../../internal/prefix.js";import{resolveEffectivePositioningStrategy}from"../../internal/positioning-strategy.js";import{hasCustomState}from"../../internal/custom-states.js";import{normalizeSelectionValue}from"../../internal/selection-catalog.js";import{styles}from"./catalog-picker-base.styles.js";class CatalogPickerElement extends LyraElement{}const resolvedRows=new WeakMap,pickerSpellcheckConverter={...spellcheckConverter,fromAttribute:value=>value===null?!1:spellcheckConverter.fromAttribute(value,Boolean)};class LyraCatalogPickerBase extends FormAssociated(CatalogPickerElement){static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-change"])}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=!!next,this.requestUpdate()}normalizeValue(value){return normalizeSelectionValue(value)}renderAdornment(_row){return nothing}optionDisplay(row){return{label:row.label,sub:[row.code,row.symbol].filter(text=>!!text&&text!==row.label).join(" · ")}}renderStart(row){const content=this.renderAdornment(row);return content===nothing?nothing:html`<span slot="start">${content}</span>`}get value(){return super.value}set value(next){super.value=this.normalizeValue(next)}get defaultValue(){return super.defaultValue}set defaultValue(next){super.defaultValue=next===null?null:this.normalizeValue(next)}get input(){return this.searchable?this.combobox?.input??null:null}get control(){return this.renderRoot?.querySelector(`${tag("select")},${tag("combobox")}`)??void 0}get combobox(){return this.renderRoot?.querySelector(tag("combobox"))??void 0}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}get rows(){const entries=this.entries,locale=this.effectiveLocale;let byLocale=resolvedRows.get(entries);byLocale||resolvedRows.set(entries,byLocale=new Map);let rows=byLocale.get(locale);return rows||byLocale.set(locale,rows=this.resolveRows()),rows}constructor(){super(),this.label="",this.hint="",this.errorText="",this.accessibleLabel=null,this.size="m",this.clearable=!1,this.searchable=!1,this.topLayer=!1,this.autocomplete="off",this.inputMode="",this.enterKeyHint="",this.spellcheck=!1,this.autocapitalize="",this.autocorrectValue=!0,this.slots=new SlotPresenceController(this),this.projectionToken=0,this.restoreFocus=!1,this.validationController={hostUpdated:()=>this.projectValidation()},this.onControlEvent=event=>{const child=this.control;if(!child||event.target!==child||(event.stopPropagation(),event.type!=="lr-change"))return;const raw=event.detail.value,next=raw===null?"":raw;if(this.liveDisabled||typeof next!="string"||next&&!this.entries.some(row=>row.code===next&&!row.disabled)){this.syncChildValue(child);return}if(next===this.value)return;const previousValue=this.value;this.value=next;const detail={value:this.value,previousValue};dispatchNativeEvent(this,"input"),this.emit("lr-input",detail),dispatchNativeEvent(this,"change"),this.emit("lr-change",detail)},this.onControlFocus=event=>{event.target===this.control&&(event.stopPropagation(),this.replacingControl||relayNativeEvent(this,event))},this.onControlFocusOut=event=>{event.target===this.replacingControl&&event.stopPropagation()},this.onControlKeyDown=event=>{!this.liveDisabled&&this.searchable&&event.target===this.control&&event.composedPath()[0]===this.input&&submitOnEnter(this,event)},this.usingCombobox=!1,this.addEventListener("invalid",()=>this.projectValidation())}updateValidity(){this.internals&&(isBarredFromValidation(this,this.internals)?this[SET_ANCHORED_VALIDITY]({}):this.value&&!this.entries.some(row=>row.code===this.value&&!row.disabled)?this[SET_ANCHORED_VALIDITY]({customError:!0},this.localize("notInCatalog")):this.required&&!this.value?this[SET_ANCHORED_VALIDITY]({valueMissing:!0},this.localize("fieldRequired")):this[SET_ANCHORED_VALIDITY]({}))}[VALIDITY_ANCHOR](){return resolveValidityAnchor(this.control)??null}focus(options){this.liveDisabled||this.control?.focus(options)}blur(){this.control?.blur()}click(){this.liveDisabled||this.control?.click()}syncChildValue(child){child.value="inputValue"in child?this.value||null:this.value}clearTransientState(){const child=this.control;child&&(child.open=!1,child.formResetCallback(),this.syncChildValue(child))}projectValidation(){const child=this.validationChild;!child||!this.isConnected||child!==this.control||this.validationDocument!==this.ownerDocument||resolveValidityAnchor(child)?.setAttribute("aria-invalid",hasCustomState(this.internals,"user-invalid")?"true":"false")}syncRelationships(){const anchor=this[VALIDITY_ANCHOR]();this.descriptionLease?this.descriptionLease.update(anchor):this.descriptionLease=acquireResolvedAriaRelationship(this,anchor,"aria-describedby"),this.accessibleLabel!==null?(this.labelLease?.release(),this.labelLease=void 0):this.labelLease?this.labelLease.update(anchor):this.labelLease=acquireResolvedAriaRelationship(this,anchor,"aria-labelledby"),anchor&&this.projectedAnchor!==anchor&&(this.projectedAnchor=anchor,this.requestUpdate())}get comboboxDefined(){return globalThis.customElements?.get(tag("combobox"))!==void 0}async getUpdateComplete(){const done=await super.getUpdateComplete(),load=this.comboboxLoad;return load?(await load,this.getUpdateComplete()):done}willUpdate(changed){if(super.willUpdate(changed),this.searchable&&!this.comboboxDefined&&!this.comboboxLoad){const load=import("./combobox/combobox-catalog.js").then(()=>this.requestUpdate(),()=>{});this.comboboxLoad=load,load.then(()=>{this.comboboxLoad===load&&(this.comboboxLoad=void 0)})}const child=this.control,combobox=this.searchable&&this.comboboxDefined;combobox!==this.usingCombobox&&child&&(this.replacingControl=child,this.restoreFocus=shadowFocusTarget(this)===child||this.focusReplacement===child,this.focusReplacement=void 0,this.clearTransientState()),this.usingCombobox=combobox}updated(changed){super.updated(changed);const child=this.control;this.restoreFocus&&(this.focusReplacement=child),this.restoreFocus=!1,this.replacingControl=void 0,(this.validationChild!==child||this.validationDocument!==this.ownerDocument)&&(this.validationChild?.removeController(this.validationController),this.validationChild=child,this.validationDocument=this.ownerDocument,child?.addController(this.validationController)),this.projectValidation();const token=++this.projectionToken,document=this.ownerDocument;child&&child.updateComplete.then(()=>{if(!(token!==this.projectionToken||!this.isConnected||this.ownerDocument!==document||child!==this.control)&&(this.syncRelationships(),this.focusReplacement===child)){this.focusReplacement=void 0;const active=deepActiveElementIn(document);!this.liveDisabled&&(!active||active===document.body||active===this||active===child)&&(child.focus({preventScroll:!0}),child.hide())}})}connectedCallback(){super.connectedCallback(),this.requestUpdate()}adoptedCallback(){super.adoptedCallback(),this.requestUpdate()}formResetCallback(){super.formResetCallback(),this.clearTransientState(),this.projectValidation()}formStateRestoreCallback(state,reason){super.formStateRestoreCallback(state,reason),this.clearTransientState(),this.projectValidation()}disconnectedCallback(){++this.projectionToken,this.clearTransientState(),this.restoreFocus=!1,this.focusReplacement=void 0,this.replacingControl=void 0,this.validationChild?.removeController(this.validationController),this.validationChild=void 0,this.validationDocument=void 0,this.projectedAnchor=void 0,this.labelLease?.release(),this.labelLease=void 0,this.descriptionLease?.release(),this.descriptionLease=void 0,super.disconnectedCallback()}render(){const controlTag=unsafeStatic(tag(this.usingCombobox?"combobox":"select")),optionTag=unsafeStatic(tag("option")),hasLabel=!!this.label||this.slots.has("label"),current=this.rows.find(row=>row.code===this.value),exportParts=["form-control,form-control-label",this.usingCombobox?"combobox:select-trigger,combobox-input:select-display-input":"trigger:select-trigger,display-input:select-display-input","listbox:select-listbox,option:select-option,option-sub:select-option-sub,group-label:select-group-label,clear-button:select-clear-button,flag,hint,error"].join(",");return html`<${controlTag}
|
|
1
|
+
import{__decorate}from"tslib";import{MAX_RENDERED_OPTION_ROWS}from"../../internal/option-selection.js";import{guard}from"lit/directives/guard.js";import{noChange,nothing}from"lit";import{html,unsafeStatic}from"lit/static-html.js";import{property}from"lit/decorators.js";import{LyraElement}from"../../internal/lyra-element.js";import{FormAssociated,isBarredFromValidation}from"../../internal/form-associated.js";import{resolveValidityAnchor,SET_ANCHORED_VALIDITY,VALIDITY_ANCHOR}from"../../internal/anchored-validity.js";import{acquireResolvedAriaRelationship}from"../../internal/aria-controls.js";import{AnnouncementSinkController}from"../../internal/announcer.js";import{collectionSupport}from"../../internal/collection-snapshot.js";import{autocorrectConverter,spellcheckConverter}from"../../internal/converters.js";import{dispatchNativeEvent,relayNativeEvent}from"../../internal/native-event-relay.js";import{deepActiveElementIn,shadowFocusTarget}from"../../internal/active-element.js";import{submitOnEnter}from"../../internal/submit-on-enter.js";import{SlotPresenceController}from"../../internal/slot-presence-controller.js";import{tag}from"../../internal/prefix.js";import{resolveEffectivePositioningStrategy}from"../../internal/positioning-strategy.js";import{hasCustomState}from"../../internal/custom-states.js";import{normalizeSelectionValue,selectionCatalogTruncation}from"../../internal/selection-catalog.js";import{styles}from"./catalog-picker-base.styles.js";class CatalogPickerElement extends LyraElement{}const pickerSpellcheckConverter={...spellcheckConverter,fromAttribute:value=>value===null?!1:spellcheckConverter.fromAttribute(value,Boolean)};class LyraCatalogPickerBase extends FormAssociated(CatalogPickerElement){static{this.styles=[LyraElement.styles,styles]}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-change"])}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=!!next,this.requestUpdate()}normalizeValue(value){return normalizeSelectionValue(value)}renderAdornment(_row){return nothing}optionDisplay(row){return{label:row.label,sub:[row.code,row.symbol].filter(text=>!!text&&text!==row.label).join(" · ")}}renderStart(row){const content=this.renderAdornment(row);return content===nothing?nothing:html`<span slot="start">${content}</span>`}get value(){return super.value}set value(next){super.value=this.normalizeValue(next)}get defaultValue(){return super.defaultValue}set defaultValue(next){super.defaultValue=next===null?null:this.normalizeValue(next)}get input(){return this.searchable?this.combobox?.input??null:null}get inputLimitMessage(){return selectionCatalogTruncation(this.entries)?this.localize("catalogPickerInputLimit"):""}requestUpdate(...args){const name=args[0];name===void 0&&this.hasUpdated&&this.resolvedRows.delete(this.entries),(name===void 0||!["value","defaultValue","label","hint","errorText","placeholder","accessibleLabel","required","disabled","size","clearable","topLayer","name"].includes(String(name)))&&(this.rowPresentationEpoch=(this.rowPresentationEpoch??0)+1),super.requestUpdate(...args)}get control(){return this.renderRoot?.querySelector(`${tag("select")},${tag("combobox")}`)??void 0}get combobox(){return this.renderRoot?.querySelector(tag("combobox"))??void 0}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}get rows(){const entries=this.entries,locale=this.effectiveLocale;let byLocale=this.resolvedRows.get(entries);byLocale||this.resolvedRows.set(entries,byLocale=new Map);let rows=byLocale.get(locale);return rows||byLocale.set(locale,rows=this.resolveRows()),rows}constructor(){super(),this.label="",this.hint="",this.errorText="",this.accessibleLabel=null,this.size="m",this.clearable=!1,this.searchable=!1,this.topLayer=!1,this.autocomplete="off",this.inputMode="",this.enterKeyHint="",this.spellcheck=!1,this.autocapitalize="",this.autocorrectValue=!0,this.resolvedRows=new WeakMap,this.optionsMounted=!1,this.inputLimitAnnouncements=new AnnouncementSinkController(this),this.rowPresentationEpoch=0,this.mountOptions=()=>{this.optionsMounted||(this.optionsMounted=!0,this.requestUpdate("optionsMounted",!1))},this.onControlShow=event=>{event.target===this.control&&this.mountOptions()},this.slots=new SlotPresenceController(this),this.projectionToken=0,this.restoreFocus=!1,this.validationController={hostUpdated:()=>this.projectValidation()},this.onControlEvent=event=>{const child=this.control;if(!child||event.target!==child||(event.stopPropagation(),event.type!=="lr-change"))return;const raw=event.detail.value,next=raw===null?"":raw;if(this.liveDisabled||typeof next!="string"||next&&!this.entries.some(row=>row.code===next&&!row.disabled)){this.syncChildValue(child);return}if(next===this.value)return;const previousValue=this.value;this.value=next;const detail={value:this.value,previousValue};dispatchNativeEvent(this,"input"),this.emit("lr-input",detail),dispatchNativeEvent(this,"change"),this.emit("lr-change",detail)},this.onControlFocus=event=>{event.target===this.control&&(event.type==="focus"&&this.mountOptions(),event.stopPropagation(),this.replacingControl||relayNativeEvent(this,event))},this.onControlFocusOut=event=>{event.target===this.replacingControl&&event.stopPropagation()},this.onControlKeyDown=event=>{!this.liveDisabled&&this.searchable&&event.target===this.control&&event.composedPath()[0]===this.input&&submitOnEnter(this,event)},this.usingCombobox=!1,this.addEventListener("invalid",()=>this.projectValidation())}updateValidity(){this.internals&&(isBarredFromValidation(this,this.internals)?this[SET_ANCHORED_VALIDITY]({}):this.value&&!this.entries.some(row=>row.code===this.value&&!row.disabled)?this[SET_ANCHORED_VALIDITY]({customError:!0},this.localize("notInCatalog")):this.required&&!this.value?this[SET_ANCHORED_VALIDITY]({valueMissing:!0},this.localize("fieldRequired")):this[SET_ANCHORED_VALIDITY]({}))}[VALIDITY_ANCHOR](){return resolveValidityAnchor(this.control)??null}focus(options){this.liveDisabled||this.control?.focus(options)}blur(){this.control?.blur()}click(){this.liveDisabled||this.control?.click()}syncChildValue(child){child.value="inputValue"in child?this.value||null:this.value}clearTransientState(){const child=this.control;child&&(child.open=!1,child.formResetCallback(),this.syncChildValue(child))}projectValidation(){const child=this.validationChild;!child||!this.isConnected||child!==this.control||this.validationDocument!==this.ownerDocument||resolveValidityAnchor(child)?.setAttribute("aria-invalid",hasCustomState(this.internals,"user-invalid")?"true":"false")}syncRelationships(){const anchor=this[VALIDITY_ANCHOR]();this.descriptionLease?this.descriptionLease.update(anchor):this.descriptionLease=acquireResolvedAriaRelationship(this,anchor,"aria-describedby"),this.accessibleLabel!==null?(this.labelLease?.release(),this.labelLease=void 0):this.labelLease?this.labelLease.update(anchor):this.labelLease=acquireResolvedAriaRelationship(this,anchor,"aria-labelledby"),anchor&&this.projectedAnchor!==anchor&&(this.projectedAnchor=anchor,this.requestUpdate())}get comboboxDefined(){return globalThis.customElements?.get(tag("combobox"))!==void 0}async getUpdateComplete(){const done=await super.getUpdateComplete(),load=this.comboboxLoad;return load?(await load,this.getUpdateComplete()):done}willUpdate(changed){if(super.willUpdate(changed),this.searchable&&!this.comboboxDefined&&!this.comboboxLoad){const load=import("./combobox/combobox-catalog.js").then(()=>this.requestUpdate(),()=>{});this.comboboxLoad=load,load.then(()=>{this.comboboxLoad===load&&(this.comboboxLoad=void 0)})}const child=this.control,combobox=this.searchable&&this.comboboxDefined;combobox!==this.usingCombobox&&child&&(this.replacingControl=child,this.restoreFocus=shadowFocusTarget(this)===child||this.focusReplacement===child,this.focusReplacement=void 0,this.clearTransientState()),this.usingCombobox=combobox}updated(changed){super.updated(changed);const loss=selectionCatalogTruncation(this.entries);this.inputLimitAnnouncements.transition("input-limit",loss?`${loss.source}:${loss.retained}:${loss.omitted}`:"",this.inputLimitMessage,"polite");const child=this.control;this.restoreFocus&&(this.focusReplacement=child),this.restoreFocus=!1,this.replacingControl=void 0,(this.validationChild!==child||this.validationDocument!==this.ownerDocument)&&(this.validationChild?.removeController(this.validationController),this.validationChild=child,this.validationDocument=this.ownerDocument,child?.addController(this.validationController)),this.projectValidation();const token=++this.projectionToken,document=this.ownerDocument;child&&child.updateComplete.then(()=>{if(!(token!==this.projectionToken||!this.isConnected||this.ownerDocument!==document||child!==this.control)&&(this.syncRelationships(),this.focusReplacement===child)){this.focusReplacement=void 0;const active=deepActiveElementIn(document);!this.liveDisabled&&(!active||active===document.body||active===this||active===child)&&(child.focus({preventScroll:!0}),child.hide())}})}connectedCallback(){super.connectedCallback(),this.requestUpdate()}adoptedCallback(){super.adoptedCallback(),this.inputLimitAnnouncements.adopted(),this.requestUpdate()}formResetCallback(){super.formResetCallback(),this.clearTransientState(),this.projectValidation()}formStateRestoreCallback(state,reason){super.formStateRestoreCallback(state,reason),this.clearTransientState(),this.projectValidation()}disconnectedCallback(){++this.projectionToken,this.clearTransientState(),this.restoreFocus=!1,this.focusReplacement=void 0,this.replacingControl=void 0,this.validationChild?.removeController(this.validationController),this.validationChild=void 0,this.validationDocument=void 0,this.projectedAnchor=void 0,this.labelLease?.release(),this.labelLease=void 0,this.descriptionLease?.release(),this.descriptionLease=void 0,super.disconnectedCallback()}render(){const controlTag=unsafeStatic(tag(this.usingCombobox?"combobox":"select")),optionTag=unsafeStatic(tag("option")),hasLabel=!!this.label||this.slots.has("label"),current=this.rows.find(row=>row.code===this.value),optionRows=this.optionsMounted?this.rows:current?[current]:[],exportParts=["form-control,form-control-label",this.usingCombobox?"combobox:select-trigger,combobox-input:select-display-input":"trigger:select-trigger,display-input:select-display-input","listbox:select-listbox,option:select-option,option-overflow:select-option-overflow,option-sub:select-option-sub,group-label:select-group-label,clear-button:select-clear-button,flag,hint,error"].join(",");return html`<${controlTag}
|
|
2
2
|
exportparts=${exportParts}
|
|
3
3
|
.positioningStrategy=${this.ownerDocument?resolveEffectivePositioningStrategy(this,this.positioningStrategy,"absolute"):this.positioningStrategy}
|
|
4
4
|
.strings=${this.strings} .customError=${this.validity.valid?null:this.validationMessage}
|
|
@@ -8,7 +8,7 @@ import{__decorate}from"tslib";import{noChange,nothing}from"lit";import{html,unsa
|
|
|
8
8
|
aria-label=${this.accessibleLabel??(hasLabel?nothing:this.pickerLabel)}
|
|
9
9
|
.required=${this.required} .disabled=${this.effectiveDisabled} .size=${this.size}
|
|
10
10
|
.clearable=${this.clearable} .topLayer=${this.topLayer}
|
|
11
|
-
.maxRender=${
|
|
11
|
+
.maxRender=${Math.min(this.rows.length||1,MAX_RENDERED_OPTION_ROWS)}
|
|
12
12
|
.autocomplete=${this.usingCombobox?this.autocomplete:noChange}
|
|
13
13
|
.inputMode=${this.usingCombobox?this.inputMode:noChange} .enterKeyHint=${this.usingCombobox?this.enterKeyHint:noChange}
|
|
14
14
|
.spellcheck=${this.usingCombobox?this.spellcheck:noChange}
|
|
@@ -17,13 +17,13 @@ import{__decorate}from"tslib";import{noChange,nothing}from"lit";import{html,unsa
|
|
|
17
17
|
@input=${this.onControlEvent} @lr-input=${this.onControlEvent} @lr-filter=${this.onControlEvent}
|
|
18
18
|
@change=${this.onControlEvent} @lr-change=${this.onControlEvent}
|
|
19
19
|
@focus=${this.onControlFocus} @blur=${this.onControlFocus} @focusout=${this.onControlFocusOut}
|
|
20
|
-
@keydown=${this.onControlKeyDown}
|
|
21
|
-
>${this.
|
|
20
|
+
@keydown=${this.onControlKeyDown} @lr-show=${this.onControlShow}
|
|
21
|
+
>${guard([optionRows,this.rowPresentationEpoch],()=>optionRows.map(row=>{const{label,sub}=this.optionDisplay(row);return html`<${optionTag} .value=${row.code} .label=${label} .sub=${sub}
|
|
22
22
|
.searchText=${row.searchText} .group=${row.group??""} .disabled=${!!row.disabled}>
|
|
23
|
-
${this.renderStart(row)}${label}</${optionTag}>`})}
|
|
23
|
+
${this.renderStart(row)}${label}</${optionTag}>`}))}
|
|
24
24
|
${current?this.renderStart(current):nothing}
|
|
25
25
|
${current?.disabled?html`<span slot="end">${this.localize("notInCatalog")}</span>`:nothing}
|
|
26
26
|
${this.slots.has("label")?html`<slot name="label" slot="label"></slot>`:nothing}
|
|
27
27
|
${this.slots.has("hint")?html`<slot name="hint" slot="hint"></slot>`:nothing}
|
|
28
28
|
${this.slots.has("error")?html`<slot name="error" slot="error"></slot>`:nothing}
|
|
29
|
-
</${controlTag}
|
|
29
|
+
</${controlTag}>${this.inputLimitMessage?html`<p part="limit">${this.inputLimitMessage}</p>`:nothing}`}}__decorate([property()],LyraCatalogPickerBase.prototype,"label",void 0),__decorate([property()],LyraCatalogPickerBase.prototype,"hint",void 0),__decorate([property({attribute:"error-text"})],LyraCatalogPickerBase.prototype,"errorText",void 0),__decorate([property()],LyraCatalogPickerBase.prototype,"placeholder",void 0),__decorate([property({attribute:"aria-label"})],LyraCatalogPickerBase.prototype,"accessibleLabel",void 0),__decorate([property({reflect:!0})],LyraCatalogPickerBase.prototype,"size",void 0),__decorate([property({type:Boolean})],LyraCatalogPickerBase.prototype,"clearable",void 0),__decorate([property({type:Boolean})],LyraCatalogPickerBase.prototype,"searchable",void 0),__decorate([property({type:Boolean,attribute:"top-layer"})],LyraCatalogPickerBase.prototype,"topLayer",void 0),__decorate([property({attribute:"positioning-strategy"})],LyraCatalogPickerBase.prototype,"positioningStrategy",void 0),__decorate([property()],LyraCatalogPickerBase.prototype,"autocomplete",void 0),__decorate([property({attribute:"inputmode"})],LyraCatalogPickerBase.prototype,"inputMode",void 0),__decorate([property({attribute:"enterkeyhint"})],LyraCatalogPickerBase.prototype,"enterKeyHint",void 0),__decorate([property({converter:pickerSpellcheckConverter,useDefault:!0})],LyraCatalogPickerBase.prototype,"spellcheck",void 0),__decorate([property()],LyraCatalogPickerBase.prototype,"autocapitalize",void 0),__decorate([property({converter:autocorrectConverter})],LyraCatalogPickerBase.prototype,"autocorrect",null);export{LyraCatalogPickerBase};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{css}from"lit";const styles=css`:host{--_lr-catalog-picker-invalid-border:var(--lr-color-danger);min-inline-size:0;display:block}[exportparts]{inline-size:100%;min-inline-size:0}:host(:where(:state(user-invalid))) [exportparts]::part(trigger),:host(:where(:state(user-invalid))) [exportparts]::part(combobox){border-color:var(--_lr-catalog-picker-invalid-border)}[exportparts]::part(display-input),[exportparts]::part(combobox-input),[exportparts]::part(option-label),[exportparts]::part(option-sub){unicode-bidi:isolate}[part=flag]{font-size:var(--lr-font-size-lg);flex-shrink:0;align-items:center;line-height:1;display:inline-flex}`;export{styles};
|
|
1
|
+
import{css}from"lit";const styles=css`:host{--_lr-catalog-picker-invalid-border:var(--lr-color-danger);min-inline-size:0;display:block}[exportparts]{inline-size:100%;min-inline-size:0}:host(:where(:state(user-invalid))) [exportparts]::part(trigger),:host(:where(:state(user-invalid))) [exportparts]::part(combobox){border-color:var(--_lr-catalog-picker-invalid-border)}[exportparts]::part(display-input),[exportparts]::part(combobox-input),[exportparts]::part(option-label),[exportparts]::part(option-sub){unicode-bidi:isolate}[part=flag]{font-size:var(--lr-font-size-lg);flex-shrink:0;align-items:center;line-height:1;display:inline-flex}[part=limit]{padding:var(--lr-space-xs) var(--lr-space-s);color:var(--lr-color-text-quiet);font-size:var(--lr-font-size-sm);overflow-wrap:anywhere;margin:0}`;export{styles};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{type TemplateResult,type PropertyValues}from'lit';import{type LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{LyraFormControlElement}from'../../../internal/form-control-element.js';import type{LyraAppearance,LyraSize}from'../../../internal/variants.js';import type{LyraSelectionDirection}from'../../../internal/shared-unions.js';import type{LyraOption}from'./option.class.js';import type{PlaceStrategy,PlaceSync}from'../../../internal/positioner.js';import{type FormOwnerValue}from'../../../internal/form-associated.js';import type{LyraPickerDetailValue,LyraPickerValue}from'../../../internal/picker-value.js';export type OptionFilter=(option:LyraOption,query:string)=>boolean;export type LyraComboboxPlacement='top'|'bottom';export type LyraComboboxTagRenderer=(option:LyraOption,index:number)=>unknown;
|
|
1
|
+
import{type TemplateResult,type PropertyValues}from'lit';import{LyraElement,type LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{LyraFormControlElement}from'../../../internal/form-control-element.js';import type{LyraAppearance,LyraSize}from'../../../internal/variants.js';import type{LyraSelectionDirection}from'../../../internal/shared-unions.js';import type{LyraOption}from'./option.class.js';import type{PlaceStrategy,PlaceSync}from'../../../internal/positioner.js';import{type FormOwnerValue}from'../../../internal/form-associated.js';import type{LyraPickerDetailValue,LyraPickerValue}from'../../../internal/picker-value.js';export type OptionFilter=(option:LyraOption,query:string)=>boolean;export type LyraComboboxPlacement='top'|'bottom';export type LyraComboboxTagRenderer=(option:LyraOption,index:number)=>unknown;
|
|
2
2
|
/** What a `validators` entry may return: nothing/`true` passes, a string is the message, `false` is
|
|
3
3
|
* a generic failure, and an object of {@linkcode ValidityStateFlags} names the flags to raise. */
|
|
4
4
|
export type LyraComboboxValidatorResult=void|boolean|string|ValidityStateFlags;
|
|
@@ -56,6 +56,9 @@ export type LyraComboboxChangeEvent<Multiple extends boolean=boolean> =LyraCombo
|
|
|
56
56
|
* `<lr-combobox>` — a filterable single/multi select that combines a text
|
|
57
57
|
* input with a listbox. Mirrors the core `<wa-combobox>` API under `lr-`.
|
|
58
58
|
*
|
|
59
|
+
* Programmatic option `selected` writes update the option immediately and reconcile parent
|
|
60
|
+
* selection once in the next microtask, without emitting parent value-change events.
|
|
61
|
+
*
|
|
59
62
|
* Options are `<lr-option value>` children. Emits native-style `change`/`input`
|
|
60
63
|
* (like Web Awesome) plus `lr-show`/`lr-hide`/`lr-clear`.
|
|
61
64
|
* Enter commits the highlighted option while the listbox has one; with nothing highlighted it
|
|
@@ -561,7 +564,8 @@ get value():LyraPickerValue<Multiple>;set value(next:LyraPickerValue<Multiple> |
|
|
|
561
564
|
* @default 3 */
|
|
562
565
|
get maxOptionsVisible():number;set maxOptionsVisible(next:number);
|
|
563
566
|
/** Maximum number of suggestion rows **rendered into the DOM at all** before the rest collapse
|
|
564
|
-
* behind the overflow indicator
|
|
567
|
+
* behind the overflow indicator. Selected and active rows share an absolute 1,000-row ceiling;
|
|
568
|
+
* the active row has priority, so oversized selections cannot all remain mounted. This
|
|
565
569
|
* is a performance ceiling, not a visible-height affordance: rows past it do not exist and
|
|
566
570
|
* cannot be scrolled to. Use `visibleOptions` to bound the popup's height while keeping every
|
|
567
571
|
* row reachable, and `maxOptionsVisible` for the selected-tag cap. Sanitized to a finite,
|
|
@@ -614,7 +618,7 @@ formDisabledCallback(disabled:boolean):void;private markInteracted;checkValidity
|
|
|
614
618
|
*
|
|
615
619
|
* The message is caller-supplied content, so it is used verbatim and never localized here.
|
|
616
620
|
*/
|
|
617
|
-
setCustomValidity(message:string):void;disconnectedCallback():void;private collectOptions;private collectOptionsFromSlot;private refreshOptionDefaults;private optionRefreshPending;private onOptionChange;private reflectSelected;private labelFor;private isUnknownValue;private adornmentClones;private adornmentMarkup;private adornmentsFor;private rowForOption;private get hasSelectionSourceRows();private applySelectedRowValues;private applyPendingSelectedRows;private get unknownRows();private get createRow();private capRows;private get renderedRows();private normalizeActiveIndex;private get filtered();private get displayValue();private announceOpenTransition;
|
|
621
|
+
setCustomValidity(message:string):void;disconnectedCallback():void;private collectOptions;private collectOptionsFromSlot;private refreshOptionDefaults;private callbackRefreshEpoch;requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;private optionMemo;private memoOption;private get optionIndex();private get asyncIndex();private get searchCorpus();private pendingSelectedWrites;private selectedWritesQueued;private flushSelectedWrites;private optionRefreshPending;private onOptionChange;private reflectSelected;private labelFor;private isUnknownValue;private adornmentClones;private adornmentMarkup;private adornmentsFor;private rowForOption;private get hasSelectionSourceRows();private applySelectedRowValues;private applyPendingSelectedRows;private get unknownRows();private get createRow();private capRows;private lastRenderedRows;private get renderedRows();private computeRenderedRows;private normalizeActiveIndex;private get filtered();private get displayValue();private announceOpenTransition;
|
|
618
622
|
/** Opens the listbox and resolves after `lr-after-show`. */
|
|
619
623
|
show():Promise<void>;
|
|
620
624
|
/** Closes the listbox and resolves after `lr-after-hide`. */
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{emitValueEvents}from"../../../internal/value-events.js";import{setNativeRangeText,nativeAutocorrectAttribute}from"../../../internal/native-text-control.js";import{renderFormControlHintError}from"../../../internal/form-control-template.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{loadAnchoredOverlayRuntime,syncTopLayerRelease,topLayerPlacement}from"../../../internal/anchored-overlay-runtime.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{chevronIcon,closeIcon}from"../../../internal/icons.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState,syncValidityStates}from"../../../internal/custom-states.js";import{submitOnEnter}from"../../../internal/submit-on-enter.js";import{finiteCount,finiteDuration}from"../../../internal/numbers.js";import{PopupController,emitPopupEvent}from"../../../internal/popup-controller.js";import{revealRow}from"../../../internal/reveal-row.js";import{DebounceController}from"../../../internal/debounce-controller.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./combobox.styles.js";import{autocorrectConverter,literalSetConverter,omittedEmptyStringConverter,optionalLiteralSetConverter,spellcheckConverter}from"../../../internal/converters.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{tag}from"../../../internal/prefix.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{renderDataState}from"../../../internal/data-state-renderer.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{activateNonmodalOverlay}from"../../../internal/nonmodal-overlay-manager.js";import{isOptionSelectedDirty,isOptionSelectedWrite,wasOptionInitiallySelected,RESET_OPTION_SELECTED_FROM_OWNER,SET_OPTION_SELECTED_FROM_OWNER}from"../../../internal/option-selection.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_comboboxCreate,LYRA_DEFAULT_comboboxLabel,LYRA_DEFAULT_comboboxLoadError,LYRA_DEFAULT_comboboxOverflow,LYRA_DEFAULT_comboboxRequired,LYRA_DEFAULT_comboboxSelectedOverflow}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_removeWithContext,LYRA_DEFAULT_restore,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_tableLoadFailed,LYRA_DEFAULT_valueInvalid}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();function isLyraOptionElement(value){return isHtmlElement(value)&&value.localName===tag("option")}function normalizeSelectionValues(next){return Array.isArray(next)?next.filter(value=>typeof value=="string"):typeof next=="string"?[next]:[]}const POSITIONING_STRATEGY=optionalLiteralSetConverter(["absolute","fixed"]),APPEARANCE=literalSetConverter(["accent","filled","outlined","filled-outlined","plain"],"outlined"),VALIDITY_FLAG_KEYS=new Set(["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"]),comboboxSpellcheckConverter={...spellcheckConverter,fromAttribute:(value,type)=>value===null?void 0:spellcheckConverter.fromAttribute?.(value,type)};function adornmentContent(value){return typeof value=="string"||typeof value=="number"?html`<span>${value}</span>`:value}function isValidityFlagKey(value){return typeof value=="string"&&VALIDITY_FLAG_KEYS.has(value)}const MAX_SOURCE_ROWS=2e3,MAX_SOURCE_TEXT_UNITS=25e4,MAX_SOURCE_FIELD_UNITS=4096,MAX_RENDER_ROWS=1e3;function isRenderable(value,nested=!1){if(typeof value=="string"||typeof value=="number")return!0;if(typeof value!="object"||value===null)return!1;if(Array.isArray(value))return!nested&&value.every(item=>isRenderable(item,!0));const{nodeType,cloneNode,strings}=value;return typeof nodeType=="number"&&typeof cloneNode=="function"||Array.isArray(strings)&&Object.hasOwn(strings,"raw")}function normalizeSourceResult(input){let candidateRows,candidateTotal;try{Array.isArray(input)?candidateRows=input:typeof input=="object"&&input!==null&&(candidateRows=input.rows,candidateTotal=input.total)}catch{throw new TypeError("Invalid combobox source result")}if(!Array.isArray(candidateRows))throw new TypeError("Invalid combobox source result");const providerTotal=typeof candidateTotal=="number"&&Number.isFinite(candidateTotal)&&candidateTotal>=0?Math.trunc(candidateTotal):candidateRows.length,rows=[];let textUnits=0;const limit=Math.min(candidateRows.length,MAX_SOURCE_ROWS);for(let index=0;index<limit;index++)try{const value=candidateRows[index]?.value,label=candidateRows[index]?.label;if(typeof value!="string"||typeof label!="string"||value.length>MAX_SOURCE_FIELD_UNITS||label.length>MAX_SOURCE_FIELD_UNITS)continue;const source=candidateRows[index],optionalText=key=>{const candidate=source[key];return typeof candidate=="string"&&candidate.length<=MAX_SOURCE_FIELD_UNITS?candidate:void 0},content=key=>{const candidate=source[key];return isRenderable(candidate)?candidate:void 0},icon=content("icon"),start=content("start"),end=content("end"),sub=optionalText("sub"),accessibleLabel=optionalText("accessibleLabel"),dotColor=optionalText("dotColor"),title=optionalText("title"),group=optionalText("group"),badgeCandidate=source.badge,badge=typeof badgeCandidate=="string"&&badgeCandidate.length<=MAX_SOURCE_FIELD_UNITS||typeof badgeCandidate=="number"&&Number.isFinite(badgeCandidate)?badgeCandidate:void 0,units=value.length+label.length+(sub?.length??0)+(accessibleLabel?.length??0)+(dotColor?.length??0)+(title?.length??0)+(group?.length??0)+(typeof badge=="string"?badge.length:0);if(textUnits+units>MAX_SOURCE_TEXT_UNITS)break;textUnits+=units,rows.push({value,label,...sub===void 0?{}:{sub},...icon===void 0?{}:{icon},...start===void 0?{}:{start},...end===void 0?{}:{end},...badge===void 0?{}:{badge},...accessibleLabel===void 0?{}:{accessibleLabel},...source.data===void 0?{}:{data:source.data},...dotColor===void 0?{}:{dotColor},...title===void 0?{}:{title},...group===void 0?{}:{group},...typeof source.disabled=="boolean"?{disabled:source.disabled}:{}})}catch{}const total=Math.max(providerTotal,candidateRows.length);return{rows,total,truncated:total>rows.length}}class LyraCombobox extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,collapse:LYRA_DEFAULT_collapse,comboboxCreate:LYRA_DEFAULT_comboboxCreate,comboboxLabel:LYRA_DEFAULT_comboboxLabel,comboboxLoadError:LYRA_DEFAULT_comboboxLoadError,comboboxOverflow:LYRA_DEFAULT_comboboxOverflow,comboboxRequired:LYRA_DEFAULT_comboboxRequired,comboboxSelectedOverflow:LYRA_DEFAULT_comboboxSelectedOverflow,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,noMatches:LYRA_DEFAULT_noMatches,notInCatalog:LYRA_DEFAULT_notInCatalog,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,removeWithContext:LYRA_DEFAULT_removeWithContext,restore:LYRA_DEFAULT_restore,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,tableLoadFailed:LYRA_DEFAULT_tableLoadFailed,valueInvalid:LYRA_DEFAULT_valueInvalid}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-change"])}static{this.identityEventDetailCollectionItems=Object.freeze({"lr-input":Object.freeze(["data"]),"lr-change":Object.freeze(["data"])})}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,styles,srOnly]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},multiple:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},readonly:{type:Boolean,reflect:!0,noAccessor:!0},value:{noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},maxOptionsVisible:{type:Number,attribute:"max-options-visible",noAccessor:!0},maxRender:{type:Number,attribute:"max-render",noAccessor:!0},sourceDelay:{type:Number,attribute:"source-delay",noAccessor:!0}}}get open(){return this._open}set open(next){const old=this._open,liveDisabled=this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled");if(this._open=!!next&&!this.readonly&&!liveDisabled,this._open===old){next&&!this._open&&this.hasAttribute("open")&&this.removeAttribute("open");return}this.requestUpdate("open",old)}get appearance(){return this._appearance}set appearance(next){const normalized=APPEARANCE.normalizeReflected(this,"appearance",next),old=this._appearance;this._appearance=normalized,normalized!==old&&this.requestUpdate("appearance",old)}get positioningStrategy(){return this._positioningStrategy??"fixed"}set positioningStrategy(next){const normalized=POSITIONING_STRATEGY.normalize(next)??"fixed",old=this.positioningStrategy;this._positioningStrategy=normalized,normalized!==old&&this.requestUpdate("positioningStrategy",old)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=!!next,this.requestUpdate()}get inputmode(){return this.inputMode}set inputmode(next){this.inputMode=next??""}get enterkeyhint(){return this.enterKeyHint}set enterkeyhint(next){this.enterKeyHint=next??""}get inputValue(){return this.query}set inputValue(next){this.explicitInputValue=!0,this.query=next??"",this.activeIndex=-1,this.source&&this.runSource(this.query),this.requestUpdate()}constructor(){super(),this.placeholder="",this.label="",this.hint="",this.errorText="",this.allowCreate=!1,this.allowCustomValue=!1,this.withUnknownOption=!1,this.loading=!1,this._appearance="outlined",this.placement="bottom",this.topLayer=!1,this.size="m",this.pill=!1,this.clearable=!1,this.withClear=!1,this.withLabel=!1,this.withHint=!1,this.validators=[],this.autocomplete="off",this.inputMode="",this.enterKeyHint="",this.spellcheck=!1,this.autocapitalize="",this.autocorrectValue=!0,this.filter=null,this.source=null,this.query="",this.explicitInputValue=!1,this.activeIndex=-1,this.options=[],this.optionsObserved=!1,this.touched=!1,this.validityRevision=0,this.slotPresence=new SlotPresenceController(this),this.sourceLoading=!1,this.sourceFailed=!1,this.sourceEverSettled=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.sourceErrorAnnouncements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.sourceDebounce=new DebounceController(0,request=>this.runSourceRequest(request),()=>this.ownerDocument.defaultView),this.sourceToken=0,this.refreshQueued=!1,this._sourceWarmed=!1,this._selectedLabelCache=new Map,this._selectedRowCache=new Map,this._renderedRows=[],this._open=!1,this._fieldsetDisabled=!1,this.listId=nextId("combobox-list"),this.inputId=nextId("combobox-input"),this.listboxPositioned=!1,this.positioningGeneration=0,this.positioningReady=Promise.resolve(!1),this.restoreFocusOnClose=!0,this.restoringOverlayFocus=!1,this.popupController=new PopupController({host:this,popup:()=>this.renderRoot.querySelector('[part="listbox"]'),emit:(name,cancelable)=>emitPopupEvent(this,name,cancelable),onPointer:event=>this.onDocPointer(event)}),this.listboxHidden=!0,this.listboxRendered=!1,this._isFirstUpdate=!0,this.openVetoed=!1,this.closeAfterPositioningFailure=!1,this.closeCleanupPending=!1,this._selected=[],this.sourceOptionsByRow=new WeakMap,this._valueDirty=!1,this._multiple=!1,this._disabled=!1,this._required=!1,this._readonly=!1,this._defaultSelected=[],this._defaultCaptured=!1,this._restoredStateActive=!1,this._name="",this._maxOptionsVisible=3,this._maxRender=200,this._sourceDelay=200,this.localDescriptionIds="",this.previousSelection=[],this.markInteracted=()=>{this.touched||(this.touched=!0,this.updateValidity(),this.syncCustomStates())},this.collectOptions=e=>{this.collectOptionsFromSlot(e.target)},this.optionRefreshPending=!1,this.onOptionChange=e=>{e.stopPropagation();const option=e.composedPath().find(isLyraOptionElement);if(isOptionSelectedWrite(e)&&isLyraOptionElement(option)&&this.options.includes(option)){if(this.multiple){const next=option.selected?this._selected.includes(option.value)?this._selected:[...this._selected,option.value]:this._selected.filter(value=>value!==option.value);this.assignValue(next)}else{if(this._valueDirty=!0,this._restoredStateActive=!1,!option.selected&&this.singleSelectedOption!==option)return;this.setValue(option.selected?option.value:[],!0,option.selected?option:void 0)}return}if(isLyraOptionElement(option)){const cached=this.adornmentClones.get(option);cached&&cached.markup!==this.adornmentMarkup(option)&&this.adornmentClones.delete(option)}this.optionRefreshPending||(this.optionRefreshPending=!0,queueMicrotask(()=>{this.optionRefreshPending=!1,this.refreshOptionDefaults(),this.reflectSelected(),this.options=[...this.options],this.normalizeActiveIndex()}))},this.adornmentClones=new WeakMap,this.onDocPointer=e=>{if(!e.composedPath().includes(this)){if(this.overlayHandle?.isActive()){this.overlayHandle.dismissBackdrop();return}this.restoreFocusOnClose=!1,this.hide()}},this.onInput=e=>{this.liveDisabled||this.readonly||(this.explicitInputValue=!1,this.query=e.target.value,this.activeIndex=-1,this.show(),this.source&&this.runSource(this.query),this.emit("lr-filter",{value:this.query}))},this.onInputBlur=event=>{this.liveDisabled||(this.touched=!0),this.syncCustomStates(),this.onComboFocusOut(event),relayNativeEvent(this,event)},this.onComboFocusOut=event=>{const trigger=this.renderRoot.querySelector('[part="combobox"]'),target=event.relatedTarget;target&&typeof target.nodeType=="number"&&trigger?.contains(target)||(this.restoreFocusOnClose=!1,this.hide())},this.onInputFocus=event=>{if(this.liveDisabled){event.stopPropagation();return}this.restoringOverlayFocus||this.show(),relayNativeEvent(this,event)},this.onKeyDown=e=>{if(e.isComposing||e.keyCode===229||this.liveDisabled||this.readonly)return;const navigable=["ArrowDown","ArrowUp","Enter","End"].includes(e.key)?this.renderedRows.rows.filter(r=>!r.disabled):[];switch(e.key){case"ArrowDown":case"ArrowUp":if(e.preventDefault(),!this.open){this.activeIndex=navigable.findIndex(row=>this.committed.includes(row.value)),this.show();return}if(e.key==="ArrowDown"){this.activeIndex=Math.min(navigable.length-1,this.activeIndex+1);break}this.activeIndex=Math.max(0,this.activeIndex-1);break;case"Enter":{const activeRow=navigable[this.activeIndex];if(this.open&&this.activeIndex>=0&&activeRow){e.preventDefault(),this.pickRow(activeRow);break}const create=this.createRow;if(this.open&&create){e.preventDefault(),this.createOption(create.createInput);break}if(this.open&&this.allowCustomValue&&!this.multiple&&this.query.trim()){e.preventDefault(),this.commitCustomValue(this.query.trim());break}submitOnEnter(this,e);break}case"Escape":this.open&&(!this.overlayHandle?.isActive()||this.overlayHandle.isTopmost())&&(e.preventDefault(),this.hide());break;case"Home":this.open&&(e.preventDefault(),this.activeIndex=0);break;case"End":this.open&&(e.preventDefault(),this.activeIndex=navigable.length-1);break;case"Backspace":this.multiple&&!this.query&&this._selected.length&&this.removeValueAt(this._selected.length-1);break}},this.onComboMouseDown=e=>{this.liveDisabled||e.composedPath()[0]!==this.inputEl&&(e.target.closest("button")||(e.preventDefault(),this.inputEl?.focus(),this.show()))},this.onListboxMouseDown=e=>{e.preventDefault()},this.onListboxClick=e=>{const optionEl=e.target.closest('[part="option"]'),row=this._renderedRows[Number(optionEl?.dataset.index)];row&&this.pickRow(row)},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,new GlassScrollLayer(this,'[part="listbox"]',()=>this.open)}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}get validationTarget(){return this.validationTargetOverride??this.inputEl??void 0}set validationTarget(next){this.validationTargetOverride=next??void 0,this.validityController.refreshAnchor()}resetValidity(){this.validityController.setCustomValidity(""),this.updateValidity()}get input(){return this.inputEl??null}get selectionStart(){return this.inputEl?.selectionStart??null}set selectionStart(value){this.inputEl&&(this.inputEl.selectionStart=value)}get selectionEnd(){return this.inputEl?.selectionEnd??null}set selectionEnd(value){this.inputEl&&(this.inputEl.selectionEnd=value)}get selectionDirection(){return this.inputEl?.selectionDirection}set selectionDirection(value){this.inputEl&&(this.inputEl.selectionDirection=value)}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}get interactionBarred(){return this.liveDisabled||this.readonly}focus(options){this.liveDisabled||this.inputEl?.focus(options)}blur(){this.inputEl?.blur()}click(){this.liveDisabled||(this.inputEl?.focus(),this.show())}select(){this.inputEl?.select()}setSelectionRange(start,end,direction){this.inputEl?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const input=this.inputEl;input&&(setNativeRangeText(input,replacement,start,end,selectMode),this.explicitInputValue=!0,this.query=input.value,this.activeIndex=-1,this.source&&this.runSource(this.query))}[VALIDITY_ANCHOR](){return this.validationTarget}syncExternalDescription(){if(!this.isConnected)return;const target=this.renderRoot.querySelector('[part="combobox-input"]');target&&(this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds))}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription(),this.updateValidity(),this.hasUpdated&&this.syncValidatorAttributeObserver(),this.hasUpdated&&queueMicrotask(()=>{this.open?this.reconnectOpenPopup():this.source&&this._selected.length&&this.asyncRows.length===0&&this.runSource("")})}adoptedCallback(){super.adoptedCallback(),this.popupController.cancel(),this.releaseExternalDescription(),this.hasUpdated&&this.syncExternalDescription(),this.listboxPositioned=!1,this.invalidateListboxPositioning(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.popupController.unbindPointer(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceErrorAnnouncements.adopted()}willUpdate(changed){super.willUpdate(changed),this._isFirstUpdate=!this.hasUpdated,this.announceOpenTransition(changed),this.open?(this.listboxHidden=!1,this.listboxRendered=!0):changed.has("open")&&this.interactionBarred&&(this.listboxHidden=!0),changed.has("open")&&!this.openVetoed&&(this.listboxPositioned=!1),changed.has("open")&&this.openVetoed?this.closeCleanupPending=!1:changed.has("open")&&!this.open&&this.finalizeCloseState(),changed.has("source")&&(this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceToken++,this.sourceLoading=!1,this.sourceFailed=!1,this.sourceEverSettled=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this._sourceWarmed=!1,this.source&&this.open&&this.runSource(this.query)),!this._sourceWarmed&&this.source&&(this._selected.length>0||(this.pendingSelectedRowValues?.length??0)>0)&&this.asyncRows.length===0&&(this._sourceWarmed=!0,this.runSource(""))}firstUpdated(changed){super.firstUpdated(changed);const slot=this.optionsSlot;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>{this.optionsObserved=!0,s.assignedElements({flatten:!0}).some(isLyraOptionElement)&&this.collectOptionsFromSlot(s)})})}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.syncFormValue(),this.requestUpdate("name",old)}get multiple(){return this._multiple}set multiple(next){const old=this._multiple;this._multiple=!!next,this.toggleAttribute("multiple",this._multiple),this.reflectSelected(),this.syncFormValue(),this.requestUpdate("multiple",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this._disabled&&this.hide(),this.updateValidity(),this.requestUpdate("disabled",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get readonly(){return this._readonly}set readonly(next){const old=this._readonly;this._readonly=!!next,this.toggleAttribute("readonly",this._readonly),this._readonly&&this.hide(),this.updateValidity(),this.requestUpdate("readonly",old)}get value(){return this.multiple?[...this._selected]:this._selected[0]??""}set value(next){this.setValue(next,!0)}setValue(next,dirty,preferred){const old=this._selected;this.previousSelection=old,this.singleSelectedOption=preferred,dirty&&(this._restoredStateActive=!1,this._valueDirty=!0),this._selected=normalizeSelectionValues(next);const selected=new Set(this._selected);if(selected.size>0){const rows=this.rowsByValue(selected);for(const value of selected){const row=rows.get(value);row&&this._selectedRowCache.set(value,row)}}for(const value of this._selectedRowCache.keys())selected.has(value)||this._selectedRowCache.delete(value);for(const value of this._selectedLabelCache.keys())selected.has(value)||this._selectedLabelCache.delete(value);this.syncFormValue(),this.reflectSelected(),this.updateValidity(),this.requestUpdate("value",old)}get maxOptionsVisible(){return this._maxOptionsVisible}set maxOptionsVisible(next){const old=this._maxOptionsVisible;this._maxOptionsVisible=finiteCount(next,3),this.requestUpdate("maxOptionsVisible",old)}get maxRender(){return this._maxRender}get sourceDelay(){return this._sourceDelay}set sourceDelay(next){const old=this._sourceDelay;this._sourceDelay=finiteDuration(next,200),this.requestUpdate("sourceDelay",old)}set maxRender(next){const old=this._maxRender;this._maxRender=Math.min(finiteCount(next,200),MAX_RENDER_ROWS),this.requestUpdate("maxRender",old)}get sourceTotal(){return this._sourceTotal}get sourceTruncated(){return this._sourceTruncated}get selectedRows(){return this.resolveSelectedRowSlots().filter(row=>row!=null).map(row=>({...row}))}resolveSelectedRowSlots(){let rows;return this.committed.map(value=>this._selectedRowCache.get(value)??(rows??=this.rowsByValue(new Set(this.committed))).get(value))}get committed(){return this.multiple?this._selected:this._selected.slice(0,1)}rowsByValue(values){const rows=this.source?new Map:this.localRowsByValue(values,this.options);for(const row of this.asyncRows)values.has(row.value)&&!rows.has(row.value)&&rows.set(row.value,row);return rows}localRowsByValue(values,options){const rows=new Map;if(values.size===0)return rows;for(const option of options){const value=option.value;values.has(value)&&!rows.has(value)&&rows.set(value,this.rowForOption(option))}return rows}set selectedRows(next){const values=[],seen=new Set;if(Array.isArray(next))for(const candidate of next){let value;try{value=candidate?.value}catch{continue}typeof value!="string"||seen.has(value)||(seen.add(value),values.push(value))}if(values.length>0&&!this.hasSelectionSourceRows){this.pendingSelectedRowValues=values,this.source&&this.isConnected&&(this._sourceWarmed=!0,this.runSource(""));return}this.pendingSelectedRowValues=void 0,this.applySelectedRowValues(values)}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}validatorResult(){const self=this,current=self.value;for(const validator of Array.isArray(this.validators)?this.validators:[]){let result;try{if(typeof validator=="object"&&validator!==null&&"checkValidity"in validator){const checked=validator.checkValidity(this);if(checked?.isValid===!0)continue;const flags={};for(const key of Array.isArray(checked?.invalidKeys)?checked.invalidKeys:[])isValidityFlagKey(key)&&(flags[key]=!0);Object.values(flags).some(Boolean)||(flags.customError=!0);let message=typeof checked?.message=="string"?checked.message:"";return!message&&typeof validator.message=="string"&&(message=validator.message),!message&&typeof validator.message=="function"&&(message=validator.message(this)),{flags,message:message||this.localize("valueInvalid")}}result=typeof validator=="function"?validator(current,self):validator?.validate(current,self)}catch{return{flags:{customError:!0},message:this.localize("valueInvalid")}}if(!(result===void 0||result===!0)){if(typeof result=="string")return{flags:{customError:!0},message:result};if(result===!1)return{flags:{customError:!0},message:this.localize("valueInvalid")};if(result&&typeof result=="object"&&Object.values(result).some(Boolean))return{flags:result,message:this.localize("valueInvalid")}}}return{}}syncValidatorAttributeObserver(){this.disconnectValidatorAttributeObserver();const owner=this.ownerDocument.defaultView,MutationObserverCtor=owner?.MutationObserver;if(!this.isConnected||!owner||typeof MutationObserverCtor!="function")return;const attributes=new Set;for(const validator of Array.isArray(this.validators)?this.validators:[]){if(typeof validator!="object"||validator===null||!("checkValidity"in validator))continue;let observed;try{observed=validator.observedAttributes}catch{continue}if(Array.isArray(observed))for(const name of observed)typeof name=="string"&&name.length>0&&attributes.add(name)}if(attributes.size===0)return;const binding={},observer=new MutationObserverCtor(()=>{this.validatorAttributeObserver!==binding||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.updateValidity(),this.validityRevision++)});binding.observer=observer,binding.owner=owner;try{observer.observe(this,{attributes:!0,attributeFilter:[...attributes]}),this.validatorAttributeObserver=binding}catch{observer.disconnect()}}disconnectValidatorAttributeObserver(){const binding=this.validatorAttributeObserver;this.validatorAttributeObserver=void 0,binding?.observer.disconnect()}updateValidity(){if(this.barredFromValidation){this.validityController.setValidity({}),this.syncCustomStates();return}const flags={};let message="";this.required&&this._selected.length===0&&(flags.valueMissing=!0,message=this.localize("comboboxRequired"));const configured=this.validatorResult();configured.flags&&Object.assign(flags,configured.flags),configured.message&&(message=configured.message),this.validityController.setValidity(flags,message),this.syncCustomStates()}syncCustomStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this.touched,barred:this.barredFromValidation}),setCustomState(this.internals,"blank",this._selected.length===0),setCustomState(this.internals,"disabled",this.effectiveDisabled)}syncFormValue(){const state2=JSON.stringify(this._selected);if(this.multiple){if(!this.name){this.internals.setFormValue(null,state2);return}const fd=new FormData;for(const v of this._selected)fd.append(this.name,v);this.internals.setFormValue(fd,state2)}else this.internals.setFormValue(this._selected[0]??"",state2)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}formResetCallback(){this.touched=!1,this._restoredStateActive=!1,this._valueDirty=!1;const resetValues=this._defaultSelected.length>0?this._defaultSelected:this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value);this._defaultSelected.length===0&&resetValues.length>0&&(this._defaultSelected=[...resetValues]);const defaults=new Set(resetValues);for(const option of this.options)option[RESET_OPTION_SELECTED_FROM_OWNER](defaults.has(option.value));this.setValue(this.multiple?[...resetValues]:resetValues.slice(0,1),!1),this.query="",this.explicitInputValue=!1}formStateRestoreCallback(state2,reason){let selected=[];if(typeof state2=="string")try{const parsed=JSON.parse(state2);Array.isArray(parsed)&&parsed.every(value=>typeof value=="string")&&(selected=parsed)}catch{}this.assignValue(this.multiple?selected:selected.slice(0,1)),this._restoredStateActive=!0}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(disabled&&this.hide(),this.updateValidity(),this.requestUpdate())}checkValidity(){return this.validityController.checkValidity(()=>this.updateValidity())}reportValidity(){return this.validityController.syncConstraints(),this.touched=!0,this.updateValidity(),this.syncCustomStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncCustomStates()}disconnectedCallback(){this.listboxHidden=!0,this.releaseExternalDescription(),this.popupController.cancel(),this.listboxPositioned=!1,this.disconnectValidatorAttributeObserver(),super.disconnectedCallback(),this.invalidateListboxPositioning(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.popupController.unbindPointer(),this.open=!1}collectOptionsFromSlot(slot){const previous=new Set(this.options);if(this.optionsObserved=!0,this.options=slot.assignedElements({flatten:!0}).filter(isLyraOptionElement),this.adornmentClones=new WeakMap,this.normalizeActiveIndex(),this.applyPendingSelectedRows(),this._defaultCaptured){const newDefaults=this.options.filter(option=>!previous.has(option)&&option.defaultSelected),newLive=this.options.filter(option=>!previous.has(option)&&option.selected&&!option.defaultSelected);this.refreshOptionDefaults();const eligible=[...!this._restoredStateActive&&!this._valueDirty?newDefaults:[],...this._restoredStateActive?[]:newLive];if(eligible.length){const values=eligible.map(option=>option.value),next=this.multiple?[...new Set([...this._selected,...values])]:values[values.length-1];newLive.length>0?this.assignValue(next):this.setValue(next,!1);return}}else{this._defaultCaptured=!0;const allDefaults=this.options.filter(option=>option.defaultSelected).map(option=>option.value),allLive=this.options.filter(option=>option.selected).map(option=>option.value),defaults=this.multiple?allDefaults:allDefaults.slice(0,1),live=this.multiple?allLive:allLive.slice(0,1),initialLive=this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value),optionDirty=this.options.some(option=>isOptionSelectedDirty(option)),dirtyValues=this.options.filter(option=>isOptionSelectedDirty(option)&&option.selected).map(option=>option.value);this._defaultSelected=[...defaults.length>0?defaults:initialLive.length>0?initialLive:live];const fromDefaults=defaults.length>0,initial=optionDirty?this.multiple?allLive:dirtyValues.slice(-1)[0]?dirtyValues.slice(-1):live:fromDefaults?defaults:live;if(initial.length&&!this._restoredStateActive&&!this._valueDirty){const next=this.multiple?initial:initial[0];fromDefaults&&!optionDirty?this.setValue(next,!1):this.assignValue(next);return}optionDirty&&(this._valueDirty=!0)}this.reflectSelected()}refreshOptionDefaults(){const declared=this.options.filter(option=>option.defaultSelected).map(option=>option.value);this._defaultSelected=this.multiple?declared:declared.slice(0,1),!this._valueDirty&&!this._restoredStateActive&&this.setValue([...this._defaultSelected],!1)}reflectSelected(){const value=this._selected[0];(!this.singleSelectedOption||!this.options.includes(this.singleSelectedOption)||this.singleSelectedOption.value!==value)&&(this.singleSelectedOption=this.options.find(option=>option.value===value));const selected=new Set(this._selected);for(const option of this.options)option[SET_OPTION_SELECTED_FROM_OWNER](this.multiple?selected.has(option.value):option===this.singleSelectedOption)}labelFor(value){const nonBlank=label=>label!==void 0&&label.trim().length>0?label:void 0;if(this.getUnknownLabel&&this.isUnknownValue(value)){const override=nonBlank(this.getUnknownLabel(value));if(override!==void 0)return override}return(!this.source&&!this.multiple&&this.singleSelectedOption?.value===value?nonBlank(this.singleSelectedOption.label):void 0)??nonBlank(this._selectedLabelCache.get(value))??nonBlank(this.options.find(o=>o.value===value)?.label)??nonBlank(this.asyncRows.find(r=>r.value===value)?.label)??(this.loading||this.source&&!this.sourceEverSettled?this.statusText("loading",this.loadingText):void 0)??value}isUnknownValue(value){return!this.source&&!this.optionsObserved||this.loading||this.source&&!this.sourceEverSettled?!1:!(!this.source&&!this.multiple&&this.singleSelectedOption?.value===value||this._selectedLabelCache.has(value)||this.options.some(option=>option.value===value)||this.asyncRows.some(row=>row.value===value))}adornmentMarkup(option){return Array.from(option.children).filter(child=>["start","end","prefix","suffix"].includes(child.getAttribute("slot")??"")).map(child=>child.outerHTML).join("")}adornmentsFor(option){const cached=this.adornmentClones.get(option);if(cached)return cached;const cloneSlot=selector=>{const nodes=Array.from(option.querySelectorAll(selector));if(nodes.length!==0)return nodes.map(node=>node.cloneNode(!0))},resolved={markup:this.adornmentMarkup(option),start:cloneSlot(':scope > [slot="start"], :scope > [slot="prefix"]'),end:cloneSlot(':scope > [slot="end"], :scope > [slot="suffix"]')};return this.adornmentClones.set(option,resolved),resolved}rowForOption(option){const adornments=this.adornmentsFor(option),row={value:option.value,label:option.label||option.value,sub:option.sub||void 0,dotColor:option.dotColor||void 0,title:option.title||void 0,group:option.group||void 0,disabled:option.disabled||option.inert||option.closest("[inert]")!==null,data:option.data,...adornments.start===void 0?{}:{start:adornments.start},...adornments.end===void 0?{}:{end:adornments.end}};return this.sourceOptionsByRow.set(row,option),row}get hasSelectionSourceRows(){return(this.source?this.asyncRows.length:this.options.length)>0}applySelectedRowValues(values){const requested=new Set(values),rowsByValue=this.source?this.rowsByValue(requested):this.localRowsByValue(requested,this.options),rows=values.map(value=>rowsByValue.get(value)).filter(row=>row!==void 0),limited=this.multiple?rows:rows.slice(0,1);this.assignValue(limited.map(row=>row.value));for(const row of limited)this._selectedRowCache.set(row.value,row)}applyPendingSelectedRows(acceptEmptySource=!1){if(this.pendingSelectedRowValues===void 0||!acceptEmptySource&&!this.hasSelectionSourceRows)return!1;const values=this.pendingSelectedRowValues;return this.pendingSelectedRowValues=void 0,this.applySelectedRowValues(values),!0}get unknownRows(){if(!this.withUnknownOption)return[];const locale=this.effectiveLocale,query2=this.query.trim().toLocaleLowerCase(locale);return this.committed.filter(value=>this.isUnknownValue(value)).map(value=>({value,label:this.labelFor(value),badge:this.localize("notInCatalog"),unknownValue:value})).filter(row=>!query2||row.label.toLocaleLowerCase(locale).includes(query2)||row.value.toLocaleLowerCase(locale).includes(query2))}get createRow(){if(!this.allowCreate)return;const inputValue=this.query.trim();if(!inputValue)return;const locale=this.effectiveLocale,folded=inputValue.toLocaleLowerCase(locale);if(!(this.source?this.asyncRows:this.options.map(option=>({value:option.value,label:option.label}))).some(row=>row.value.toLocaleLowerCase(locale)===folded||row.label.toLocaleLowerCase(locale)===folded))return{value:inputValue,label:this.localize("comboboxCreate",void 0,{value:inputValue}),createInput:inputValue}}capRows(all){if(all.length<=this.maxRender)return{rows:[...all],overflow:0};const originalIndex=new Map(all.map((r,i)=>[r,i])),capped=all.slice(0,this.maxRender),cappedValues=new Set(capped.map(r=>r.value));let appendedOutOfCap=!1;for(const v of this.committed)if(!cappedValues.has(v)){const selectedRow=all.find(r=>r.value===v);selectedRow&&(capped.push(selectedRow),appendedOutOfCap=!0)}return appendedOutOfCap&&capped.sort((a,b)=>originalIndex.get(a)-originalIndex.get(b)),{rows:capped,overflow:all.length-capped.length}}get renderedRows(){let rows,overflow;if(this.source)({rows,overflow}=this.capRows(this.asyncRows)),overflow+=Math.max(0,this._sourceTotal-this.asyncRows.length);else{const capped=this.capRows(this.filtered);rows=capped.rows.map(option=>this.rowForOption(option)),overflow=capped.overflow}const create=this.createRow;return rows.push(...this.unknownRows),create&&rows.push(create),{rows,overflow}}normalizeActiveIndex(){if(this.activeIndex<0)return;const navigableCount=this.renderedRows.rows.filter(row=>!row.disabled).length,next=navigableCount>0?Math.min(this.activeIndex,navigableCount-1):-1;next!==this.activeIndex&&(this.activeIndex=next)}get filtered(){const locale=this.effectiveLocale,q=this.query.trim().toLocaleLowerCase(locale),selectedLabel=this.multiple?"":this.labelFor(this._selected[0]??"")??"",effective=q&&q===selectedLabel.toLocaleLowerCase(locale)?"":q;if(!effective)return this.options;const fn=this.filter??((o,query2)=>o.label.toLocaleLowerCase(locale).includes(query2)||o.searchText.toLocaleLowerCase(locale).includes(query2));return this.options.filter(o=>fn(o,effective))}get displayValue(){return this.multiple||this.open||this.explicitInputValue?this.query:this._selected[0]?this.labelFor(this._selected[0]):""}announceOpenTransition(changed){this.openVetoed=!1;const closeAfterPositioningFailure=!this.open&&this.closeAfterPositioningFailure;if(this.closeAfterPositioningFailure=!1,!(!changed.has("open")||this._isFirstUpdate||!this.open&&this.interactionBarred)){if(!this.isConnected||closeAfterPositioningFailure){emitPopupEvent(this,"lr-hide",!1);return}this.openVetoed=this.popupController.announce(this.open,()=>{this.open=!this.open})}}show(){if(this.open||this.interactionBarred)return Promise.resolve();const settled=this.popupController.wait(!0);return this.open=!0,settled}hide(){if(!this.open)return Promise.resolve();const settled=this.popupController.wait(!1);return this.closeCleanupPending=!0,this.open=!1,settled}finalizeCloseState(){if(this.closeCleanupPending&&(this.closeCleanupPending=!1,this.activeIndex=-1,!this.multiple)){const queryChanged=this.query!=="";this.query="",this.explicitInputValue=!1,queryChanged&&this.source&&(this.asyncRows=[],this.sourceFailed=!1,this._sourceTotal=0,this._sourceTruncated=!1)}}activateListboxOverlay(){this.invalidateListboxPositioning(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.restoreFocusOnClose=!0,this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="listbox"]'),onEscape:()=>{this.hide()},onBackdrop:()=>{this.restoreFocusOnClose=!1,this.hide()},restoreFocusTo:this.inputEl??null}),this.popupController.bindPointer(),this.beginListboxPositioning()}beginListboxPositioning(){const anchor=this.renderRoot.querySelector('[part="combobox"]'),listbox=this.renderRoot.querySelector('[part="listbox"]');if(anchor&&listbox){const generation=this.positioningGeneration;this.positioningReady=new Promise(resolve=>{this.resolvePositioningReady=resolve}),this.startListboxPositioning(generation,anchor,listbox)}}invalidateListboxPositioning(){this.positioningGeneration++,this.cleanup?.(),this.cleanup=void 0,this.resolvePositioningReady?.(!1),this.resolvePositioningReady=void 0}resolveCurrentPositioning(positioned){const resolve=this.resolvePositioningReady;this.resolvePositioningReady=void 0,resolve?.(positioned)}async startListboxPositioning(generation,anchor,listbox){try{const runtime=await loadAnchoredOverlayRuntime(),{place}=runtime;if(generation!==this.positioningGeneration||!this.open||!this.isConnected||this.renderRoot.querySelector('[part="combobox"]')!==anchor||this.renderRoot.querySelector('[part="listbox"]')!==listbox)return;this.placedTopLayer=syncTopLayerRelease(listbox,this.placedTopLayer,this.topLayer,runtime);const cleanup=place(anchor,listbox,{placement:`${this.placement}-start`,...topLayerPlacement(this.topLayer,resolveEffectivePositioningStrategy(this,this._positioningStrategy,"fixed")),sync:this.sync,onPlaced:()=>{generation===this.positioningGeneration&&(this.listboxPositioned=!0,this.updateComplete.then(()=>{generation!==this.positioningGeneration||!this.open||this.resolveCurrentPositioning(!0)}))}});generation!==this.positioningGeneration?cleanup():this.cleanup=cleanup}catch{if(generation!==this.positioningGeneration||!this.open)return;this.resolveCurrentPositioning(!1),this.closeAfterPositioningFailure=!0,this.hide()}}teardownListboxOverlay(restoreFocus=this.restoreFocusOnClose){this.invalidateListboxPositioning(),this.restoringOverlayFocus=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.restoringOverlayFocus=!1}this.overlayHandle=void 0,this.popupController.unbindPointer(),this.restoreFocusOnClose=!0}reconnectOpenPopup(){!this.isConnected||!this.open||(this.activateListboxOverlay(),this.source&&this.asyncRows.length===0&&this.runSource(this.query))}syncVisibleOptionsCap(){const listbox=this.renderRoot?.querySelector('[part="listbox"]');if(!listbox)return;const clear=()=>{listbox.style.removeProperty("max-block-size")},requested=typeof this.visibleOptions=="number"?finiteCount(this.visibleOptions,0):0;if(requested<=0)return clear();const rows=listbox.querySelectorAll('[part="option"]');if(rows.length<=requested)return clear();const boundary=rows[requested];if(!boundary)return clear();const cap=boundary.getBoundingClientRect().top-listbox.getBoundingClientRect().top;if(!Number.isFinite(cap)||cap<=0)return clear();listbox.style.setProperty("max-block-size",`min(${Math.ceil(cap)}px, var(--lr-positioner-available-block-size, var(--lr-size-18rem)))`)}updated(changed){if(super.updated(changed),this.syncExternalDescription(),this.syncVisibleOptionsCap(),changed.has("open")&&!this.openVetoed?this.open&&this.isConnected?(this.activateListboxOverlay(),this._isFirstUpdate||this.settleTransition("lr-after-show"),this.refreshQueued?(this.refreshQueued=!1,this.runSource(this.query)):this.source&&this.asyncRows.length===0&&this.runSource(this.query)):this.open?this.teardownListboxOverlay(!1):(this.teardownListboxOverlay(),this.interactionBarred?this.popupController.cancel():this._isFirstUpdate||this.settleTransition("lr-after-hide")):changed.has("open")&&this.openVetoed&&(this.restoreFocusOnClose=!0),changed.has("topLayer")&&!changed.has("open")&&this.open&&this.isConnected&&(this.invalidateListboxPositioning(),this.beginListboxPositioning()),changed.has("name")&&this.syncFormValue(),changed.has("validators")&&(this.updateValidity(),this.syncValidatorAttributeObserver()),(changed.has("touched")||changed.has("required")||changed.has("value")||changed.has("validators")||changed.has("validityRevision"))&&this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid),changed.has("activeIndex")||changed.has("listboxPositioned")){const listbox=this.renderRoot.querySelector('[part="listbox"]'),row=listbox?.querySelector('[part="option"][data-active]');listbox&&row&&revealRow(listbox,row)}}settleTransition(event){return this.popupController.settle(event,{waitForPosition:async stale=>{for(;this.open&&!this.listboxPositioned;){const readiness=this.positioningReady,positioned=await readiness;if(stale())return!1;if(positioned)break;if(readiness===this.positioningReady)return!1}return!0},conceal:()=>{this.listboxHidden=!0}})}emitValueEvents(){const self=this,data=this.resolveSelectedRowSlots().map(row=>row?.data),previousValue=this.multiple?[...this.previousSelection]:this.previousSelection[0]??"",detail={value:self.value,previousValue,data};emitValueEvents(self,"input",detail,detail2=>self.emit("lr-input",detail2)),emitValueEvents(self,"change",detail,detail2=>self.emit("lr-change",detail2))}assignValue(next){this.value=next}createOption(inputValue){if(this.liveDisabled||this.readonly||this.emit("lr-create",{inputValue},{cancelable:!0}).defaultPrevented)return;const option=this.ownerDocument.createElement(tag("option"));option.setAttribute("value",inputValue),option.textContent=inputValue,this.append(option),this.pickRow({value:inputValue,label:inputValue})}commitCustomValue(inputValue){if(this.liveDisabled||this.readonly||this.multiple||!inputValue)return;const selectionChanged=this._selected[0]!==inputValue;this.touched=!0,this._selectedLabelCache.set(inputValue,inputValue),this.assignValue(inputValue),this.query="",this.explicitInputValue=!1,this.hide(),selectionChanged&&this.emitValueEvents()}pickRow(row){const sourceOption=this.sourceOptionsByRow.get(row);if(this.liveDisabled||this.readonly||row.disabled||sourceOption&&(sourceOption.disabled||sourceOption.closest("[inert]")))return;if(row.createInput!==void 0){this.createOption(row.createInput);return}this.touched=!0;const synthetic=row.unknownValue!==void 0,selectionChanged=this.multiple||this._selected[0]!==row.value;if(this.multiple){const set=new Set(this._selected);set.has(row.value)?(set.delete(row.value),this._selectedRowCache.delete(row.value)):(set.add(row.value),synthetic||(this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.set(row.value,row))),this.assignValue([...set]),this.query="",this.explicitInputValue=!1}else synthetic||(this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.clear(),this._selectedRowCache.set(row.value,row)),this.setValue(row.value,!0,sourceOption),this.query="",this.explicitInputValue=!1,this.hide();this.source&&this.runSource(this.query),selectionChanged&&this.emitValueEvents(),this.emit("lr-activate",{value:row.value})}removeValueAt(index){if(this.liveDisabled||this.readonly||index<0||index>=this._selected.length)return;const next=this._selected.filter((_,i)=>i!==index);this.touched=!0,this.assignValue(next),this.emitValueEvents()}clear(){if(this.liveDisabled||this.readonly)return;const hadSelection=this._selected.length>0,queryChanged=this.query!=="";!hadSelection&&!queryChanged||(hadSelection&&(this.touched=!0,this.assignValue([])),this.query="",this.explicitInputValue=!1,this.source&&this.runSource(this.query),hadSelection&&(this.emitValueEvents(),this.emit("lr-clear")),queryChanged&&this.emit("lr-filter",{value:this.query}))}refresh(){if(this.source){if(!this.open){this.refreshQueued=!0;return}this.refreshQueued=!1,this.runSource(this.query,{immediate:!0})}}runSource(query2,options){const source=this.source;if(!source)return;this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0;const token=++this.sourceToken,ownerWindow=this.ownerDocument.defaultView;if(!this.isConnected||!ownerWindow)return;const request={query:query2,token,owner:ownerWindow,source};if(options?.immediate){this.runSourceRequest(request);return}this.sourceDebounce.delayMs=this._sourceDelay,this.sourceDebounce.push(request)}runSourceRequest({query:query2,token,owner:ownerWindow,source}){if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const controller=new ownerWindow.AbortController;this.sourceAbort=controller,this.sourceLoading=!0,this.sourceFailed=!1,Promise.resolve().then(()=>source(query2,{signal:controller.signal,limit:MAX_SOURCE_ROWS})).then(result=>{if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const normalized=normalizeSourceResult(result);this._sourceTotal=normalized.total,this._sourceTruncated=normalized.truncated,this.asyncRows=normalized.rows,this.sourceFailed=!1,this.sourceEverSettled=!0,this.normalizeActiveIndex(),this.applyPendingSelectedRows(!0);const selected=new Set(this._selected);for(const row of normalized.rows)selected.has(row.value)&&this._selectedRowCache.set(row.value,row)}).catch(err=>{token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||typeof err=="object"&&err!==null&&"name"in err&&err.name==="AbortError"||(this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this.sourceFailed=!0,this.sourceEverSettled=!0,this.sourceErrorAnnouncements.announceAssertive(this.localize("comboboxLoadError")),this.emit("lr-source-error",{error:err,query:query2}),console.warn("<lr-combobox> source() rejected:",err))}).finally(()=>{token===this.sourceToken&&(this.sourceLoading=!1)})}clearSourceTimer(){this.sourceDebounce.cancel()}renderRows(rows,activeId){const out=[];let currentGroup,currentGroupRows=[],groupIndex=0;const selectedSet=new Set(this.committed),flushGroup=()=>{if(currentGroupRows.length){if(currentGroup){const labelId=`${this.listId}-group-${groupIndex++}`;out.push(html`<div role="group" aria-labelledby=${labelId}>
|
|
1
|
+
import{__decorate}from"tslib";import{capOptionRows}from"../../../internal/option-selection.js";import{emitValueEvents}from"../../../internal/value-events.js";import{setNativeRangeText,nativeAutocorrectAttribute}from"../../../internal/native-text-control.js";import{renderFormControlHintError}from"../../../internal/form-control-template.js";import{installFormControlLabelSupport}from"../../../internal/form-control-labels.js";import{FormControlController,reflectFormName}from"../../../internal/form-control-controller.js";import{GlassScrollLayer}from"../../../internal/glass-scroll-layer.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{acquireNativeControlDescription}from"../../../internal/native-control-description.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{LyraFormControlElement}from"../../../internal/form-control-element.js";import{loadAnchoredOverlayRuntime,syncTopLayerRelease,topLayerPlacement}from"../../../internal/anchored-overlay-runtime.js";import{hostAriaLabel,nextId,srOnly}from"../../../internal/a11y.js";import{chevronIcon,closeIcon}from"../../../internal/icons.js";import{VALIDITY_ANCHOR}from"../../../internal/anchored-validity.js";import{setCustomState,syncValidityStates}from"../../../internal/custom-states.js";import{submitOnEnter}from"../../../internal/submit-on-enter.js";import{finiteCount,finiteDuration}from"../../../internal/numbers.js";import{PopupController,emitPopupEvent}from"../../../internal/popup-controller.js";import{revealRow}from"../../../internal/reveal-row.js";import{DebounceController}from"../../../internal/debounce-controller.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./combobox.styles.js";import{autocorrectConverter,literalSetConverter,omittedEmptyStringConverter,optionalLiteralSetConverter,spellcheckConverter}from"../../../internal/converters.js";import{resolveEffectivePositioningStrategy}from"../../../internal/positioning-strategy.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{sanitizeCssColor}from"../../../internal/safe-css.js";import{getFormOwner,isBarredFromValidation,setFormOwner}from"../../../internal/form-associated.js";import{tag}from"../../../internal/prefix.js";import{renderInertPresentation}from"../../../internal/inert-presentation.js";import{collectInitialSlotAssignment}from"../../../internal/initial-slot-collection.js";import{renderDataState}from"../../../internal/data-state-renderer.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{AnnouncementSinkController}from"../../../internal/announcer.js";import{activateNonmodalOverlay}from"../../../internal/nonmodal-overlay-manager.js";import{isOptionSelectedDirty,isOptionSelectedWrite,wasOptionInitiallySelected,RESET_OPTION_SELECTED_FROM_OWNER,SET_OPTION_SELECTED_FROM_OWNER}from"../../../internal/option-selection.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{LYRA_DEFAULT_comboboxCreate,LYRA_DEFAULT_comboboxLabel,LYRA_DEFAULT_comboboxLoadError,LYRA_DEFAULT_comboboxOverflow,LYRA_DEFAULT_comboboxRequired,LYRA_DEFAULT_comboboxSelectedOverflow}from"../../../internal/default-strings/forms.generated.js";import{LYRA_DEFAULT_clear,LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_fieldRequired,LYRA_DEFAULT_loading,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_noData,LYRA_DEFAULT_noMatches,LYRA_DEFAULT_notInCatalog,LYRA_DEFAULT_open,LYRA_DEFAULT_progress,LYRA_DEFAULT_removeWithContext,LYRA_DEFAULT_restore,LYRA_DEFAULT_retry,LYRA_DEFAULT_search,LYRA_DEFAULT_select,LYRA_DEFAULT_tableLoadFailed,LYRA_DEFAULT_valueInvalid}from"../../../internal/default-strings/shared.generated.js";installFormControlLabelSupport();function isLyraOptionElement(value){return isHtmlElement(value)&&value.localName===tag("option")}function normalizeSelectionValues(next){return Array.isArray(next)?next.filter(value=>typeof value=="string"):typeof next=="string"?[next]:[]}const POSITIONING_STRATEGY=optionalLiteralSetConverter(["absolute","fixed"]),APPEARANCE=literalSetConverter(["accent","filled","outlined","filled-outlined","plain"],"outlined"),VALIDITY_FLAG_KEYS=new Set(["badInput","customError","patternMismatch","rangeOverflow","rangeUnderflow","stepMismatch","tooLong","tooShort","typeMismatch","valueMissing"]),comboboxSpellcheckConverter={...spellcheckConverter,fromAttribute:(value,type)=>value===null?void 0:spellcheckConverter.fromAttribute?.(value,type)};function adornmentContent(value){return typeof value=="string"||typeof value=="number"?html`<span>${value}</span>`:value}function isValidityFlagKey(value){return typeof value=="string"&&VALIDITY_FLAG_KEYS.has(value)}const MAX_SOURCE_ROWS=2e3,MAX_SOURCE_TEXT_UNITS=25e4,MAX_SOURCE_FIELD_UNITS=4096,MAX_RENDER_ROWS=1e3;function isRenderable(value,nested=!1){if(typeof value=="string"||typeof value=="number")return!0;if(typeof value!="object"||value===null)return!1;if(Array.isArray(value))return!nested&&value.every(item=>isRenderable(item,!0));const{nodeType,cloneNode,strings}=value;return typeof nodeType=="number"&&typeof cloneNode=="function"||Array.isArray(strings)&&Object.hasOwn(strings,"raw")}function normalizeSourceResult(input){let candidateRows,candidateTotal;try{Array.isArray(input)?candidateRows=input:typeof input=="object"&&input!==null&&(candidateRows=input.rows,candidateTotal=input.total)}catch{throw new TypeError("Invalid combobox source result")}if(!Array.isArray(candidateRows))throw new TypeError("Invalid combobox source result");const providerTotal=typeof candidateTotal=="number"&&Number.isFinite(candidateTotal)&&candidateTotal>=0?Math.trunc(candidateTotal):candidateRows.length,rows=[];let textUnits=0;const limit=Math.min(candidateRows.length,MAX_SOURCE_ROWS);for(let index=0;index<limit;index++)try{const value=candidateRows[index]?.value,label=candidateRows[index]?.label;if(typeof value!="string"||typeof label!="string"||value.length>MAX_SOURCE_FIELD_UNITS||label.length>MAX_SOURCE_FIELD_UNITS)continue;const source=candidateRows[index],optionalText=key=>{const candidate=source[key];return typeof candidate=="string"&&candidate.length<=MAX_SOURCE_FIELD_UNITS?candidate:void 0},content=key=>{const candidate=source[key];return isRenderable(candidate)?candidate:void 0},icon=content("icon"),start=content("start"),end=content("end"),sub=optionalText("sub"),accessibleLabel=optionalText("accessibleLabel"),dotColor=optionalText("dotColor"),title=optionalText("title"),group=optionalText("group"),badgeCandidate=source.badge,badge=typeof badgeCandidate=="string"&&badgeCandidate.length<=MAX_SOURCE_FIELD_UNITS||typeof badgeCandidate=="number"&&Number.isFinite(badgeCandidate)?badgeCandidate:void 0,units=value.length+label.length+(sub?.length??0)+(accessibleLabel?.length??0)+(dotColor?.length??0)+(title?.length??0)+(group?.length??0)+(typeof badge=="string"?badge.length:0);if(textUnits+units>MAX_SOURCE_TEXT_UNITS)break;textUnits+=units,rows.push({value,label,...sub===void 0?{}:{sub},...icon===void 0?{}:{icon},...start===void 0?{}:{start},...end===void 0?{}:{end},...badge===void 0?{}:{badge},...accessibleLabel===void 0?{}:{accessibleLabel},...source.data===void 0?{}:{data:source.data},...dotColor===void 0?{}:{dotColor},...title===void 0?{}:{title},...group===void 0?{}:{group},...typeof source.disabled=="boolean"?{disabled:source.disabled}:{}})}catch{}const total=Math.max(providerTotal,candidateRows.length);return{rows,total,truncated:total>rows.length}}class LyraCombobox extends LyraFormControlElement{static{this.defaultStrings={...super.defaultStrings,clear:LYRA_DEFAULT_clear,collapse:LYRA_DEFAULT_collapse,comboboxCreate:LYRA_DEFAULT_comboboxCreate,comboboxLabel:LYRA_DEFAULT_comboboxLabel,comboboxLoadError:LYRA_DEFAULT_comboboxLoadError,comboboxOverflow:LYRA_DEFAULT_comboboxOverflow,comboboxRequired:LYRA_DEFAULT_comboboxRequired,comboboxSelectedOverflow:LYRA_DEFAULT_comboboxSelectedOverflow,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,fieldRequired:LYRA_DEFAULT_fieldRequired,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,noData:LYRA_DEFAULT_noData,noMatches:LYRA_DEFAULT_noMatches,notInCatalog:LYRA_DEFAULT_notInCatalog,open:LYRA_DEFAULT_open,progress:LYRA_DEFAULT_progress,removeWithContext:LYRA_DEFAULT_removeWithContext,restore:LYRA_DEFAULT_restore,retry:LYRA_DEFAULT_retry,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select,tableLoadFailed:LYRA_DEFAULT_tableLoadFailed,valueInvalid:LYRA_DEFAULT_valueInvalid}}static{this.collectionSupport=collectionSupport}static{this.immutableEventDetails=Object.freeze(["lr-input","lr-change"])}static{this.identityEventDetailCollectionItems=Object.freeze({"lr-input":Object.freeze(["data"]),"lr-change":Object.freeze(["data"])})}static{this.formAssociated=!0}static{this.styles=[LyraElement.styles,sizes,styles,srOnly]}static{this.properties={customError:{attribute:"custom-error",reflect:!0,noAccessor:!0},multiple:{type:Boolean,reflect:!0,noAccessor:!0},disabled:{type:Boolean,reflect:!0,noAccessor:!0},required:{type:Boolean,reflect:!0,noAccessor:!0},readonly:{type:Boolean,reflect:!0,noAccessor:!0},value:{noAccessor:!0},name:{reflect:!0,noAccessor:!0,converter:omittedEmptyStringConverter},maxOptionsVisible:{type:Number,attribute:"max-options-visible",noAccessor:!0},maxRender:{type:Number,attribute:"max-render",noAccessor:!0},sourceDelay:{type:Number,attribute:"source-delay",noAccessor:!0}}}get open(){return this._open}set open(next){const old=this._open,liveDisabled=this.effectiveDisabled||typeof this.matches=="function"&&this.matches(":disabled");if(this._open=!!next&&!this.readonly&&!liveDisabled,this._open===old){next&&!this._open&&this.hasAttribute("open")&&this.removeAttribute("open");return}this.requestUpdate("open",old)}get appearance(){return this._appearance}set appearance(next){const normalized=APPEARANCE.normalizeReflected(this,"appearance",next),old=this._appearance;this._appearance=normalized,normalized!==old&&this.requestUpdate("appearance",old)}get positioningStrategy(){return this._positioningStrategy??"fixed"}set positioningStrategy(next){const normalized=POSITIONING_STRATEGY.normalize(next)??"fixed",old=this.positioningStrategy;this._positioningStrategy=normalized,normalized!==old&&this.requestUpdate("positioningStrategy",old)}get autocorrect(){return this.autocorrectValue}set autocorrect(next){this.autocorrectValue=!!next,this.requestUpdate()}get inputmode(){return this.inputMode}set inputmode(next){this.inputMode=next??""}get enterkeyhint(){return this.enterKeyHint}set enterkeyhint(next){this.enterKeyHint=next??""}get inputValue(){return this.query}set inputValue(next){this.explicitInputValue=!0,this.query=next??"",this.activeIndex=-1,this.source&&this.runSource(this.query),this.requestUpdate()}constructor(){super(),this.placeholder="",this.label="",this.hint="",this.errorText="",this.allowCreate=!1,this.allowCustomValue=!1,this.withUnknownOption=!1,this.loading=!1,this._appearance="outlined",this.placement="bottom",this.topLayer=!1,this.size="m",this.pill=!1,this.clearable=!1,this.withClear=!1,this.withLabel=!1,this.withHint=!1,this.validators=[],this.autocomplete="off",this.inputMode="",this.enterKeyHint="",this.spellcheck=!1,this.autocapitalize="",this.autocorrectValue=!0,this.filter=null,this.source=null,this.query="",this.explicitInputValue=!1,this.activeIndex=-1,this.options=[],this.optionsObserved=!1,this.touched=!1,this.validityRevision=0,this.slotPresence=new SlotPresenceController(this),this.sourceLoading=!1,this.sourceFailed=!1,this.sourceEverSettled=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.sourceErrorAnnouncements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.sourceDebounce=new DebounceController(0,request=>this.runSourceRequest(request),()=>this.ownerDocument.defaultView),this.sourceToken=0,this.refreshQueued=!1,this._sourceWarmed=!1,this._selectedLabelCache=new Map,this._selectedRowCache=new Map,this._renderedRows=[],this._open=!1,this._fieldsetDisabled=!1,this.listId=nextId("combobox-list"),this.inputId=nextId("combobox-input"),this.listboxPositioned=!1,this.positioningGeneration=0,this.positioningReady=Promise.resolve(!1),this.restoreFocusOnClose=!0,this.restoringOverlayFocus=!1,this.popupController=new PopupController({host:this,popup:()=>this.renderRoot.querySelector('[part="listbox"]'),emit:(name,cancelable)=>emitPopupEvent(this,name,cancelable),onPointer:event=>this.onDocPointer(event)}),this.listboxHidden=!0,this.listboxRendered=!1,this._isFirstUpdate=!0,this.openVetoed=!1,this.closeAfterPositioningFailure=!1,this.closeCleanupPending=!1,this._selected=[],this.sourceOptionsByRow=new WeakMap,this._valueDirty=!1,this._multiple=!1,this._disabled=!1,this._required=!1,this._readonly=!1,this._defaultSelected=[],this._defaultCaptured=!1,this._restoredStateActive=!1,this._name="",this._maxOptionsVisible=3,this._maxRender=200,this._sourceDelay=200,this.localDescriptionIds="",this.previousSelection=[],this.markInteracted=()=>{this.touched||(this.touched=!0,this.updateValidity(),this.syncCustomStates())},this.collectOptions=e=>{this.collectOptionsFromSlot(e.target)},this.callbackRefreshEpoch=0,this.optionMemo=new Map,this.pendingSelectedWrites=new Map,this.selectedWritesQueued=!1,this.optionRefreshPending=!1,this.onOptionChange=e=>{e.stopPropagation();const option=e.composedPath().find(isLyraOptionElement);if(isOptionSelectedWrite(e)&&isLyraOptionElement(option)&&this.optionIndex.members.has(option)){this._valueDirty=!0,this._restoredStateActive=!1,this.pendingSelectedWrites.delete(option),this.pendingSelectedWrites.set(option,{selected:option.selected,value:option.value}),this.selectedWritesQueued||(this.selectedWritesQueued=!0,queueMicrotask(()=>this.flushSelectedWrites()));return}if(isLyraOptionElement(option)){const cached=this.adornmentClones.get(option);cached&&cached.markup!==this.adornmentMarkup(option)&&this.adornmentClones.delete(option)}this.optionRefreshPending||(this.optionRefreshPending=!0,queueMicrotask(()=>{this.optionRefreshPending=!1,this.refreshOptionDefaults(),this.reflectSelected(),this.options=[...this.options],this.normalizeActiveIndex()}))},this.adornmentClones=new WeakMap,this.lastRenderedRows=[],this.onDocPointer=e=>{if(!e.composedPath().includes(this)){if(this.overlayHandle?.isActive()){this.overlayHandle.dismissBackdrop();return}this.restoreFocusOnClose=!1,this.hide()}},this.onInput=e=>{this.liveDisabled||this.readonly||(this.explicitInputValue=!1,this.query=e.target.value,this.activeIndex=-1,this.show(),this.source&&this.runSource(this.query),this.emit("lr-filter",{value:this.query}))},this.onInputBlur=event=>{this.liveDisabled||(this.touched=!0),this.syncCustomStates(),this.onComboFocusOut(event),relayNativeEvent(this,event)},this.onComboFocusOut=event=>{const trigger=this.renderRoot.querySelector('[part="combobox"]'),target=event.relatedTarget;target&&typeof target.nodeType=="number"&&trigger?.contains(target)||(this.restoreFocusOnClose=!1,this.hide())},this.onInputFocus=event=>{if(this.liveDisabled){event.stopPropagation();return}this.restoringOverlayFocus||this.show(),relayNativeEvent(this,event)},this.onKeyDown=e=>{if(e.isComposing||e.keyCode===229||this.liveDisabled||this.readonly)return;const navigable=["ArrowDown","ArrowUp","Enter","End"].includes(e.key)?this.renderedRows.rows.filter(r=>!r.disabled):[];switch(e.key){case"ArrowDown":case"ArrowUp":if(e.preventDefault(),!this.open){this.activeIndex=navigable.findIndex(row=>this.committed.includes(row.value)),this.show();return}if(e.key==="ArrowDown"){this.activeIndex=Math.min(navigable.length-1,this.activeIndex+1);break}this.activeIndex=Math.max(0,this.activeIndex-1);break;case"Enter":{const activeRow=navigable[this.activeIndex];if(this.open&&this.activeIndex>=0&&activeRow){e.preventDefault(),this.pickRow(activeRow);break}const create=this.createRow;if(this.open&&create){e.preventDefault(),this.createOption(create.createInput);break}if(this.open&&this.allowCustomValue&&!this.multiple&&this.query.trim()){e.preventDefault(),this.commitCustomValue(this.query.trim());break}submitOnEnter(this,e);break}case"Escape":this.open&&(!this.overlayHandle?.isActive()||this.overlayHandle.isTopmost())&&(e.preventDefault(),this.hide());break;case"Home":this.open&&(e.preventDefault(),this.activeIndex=0);break;case"End":this.open&&(e.preventDefault(),this.activeIndex=navigable.length-1);break;case"Backspace":this.multiple&&!this.query&&this._selected.length&&this.removeValueAt(this._selected.length-1);break}},this.onComboMouseDown=e=>{this.liveDisabled||e.composedPath()[0]!==this.inputEl&&(e.target.closest("button")||(e.preventDefault(),this.inputEl?.focus(),this.show()))},this.onListboxMouseDown=e=>{e.preventDefault()},this.onListboxClick=e=>{const optionEl=e.target.closest('[part="option"]'),row=this._renderedRows[Number(optionEl?.dataset.index)];row&&this.pickRow(row)},this.validityController=new FormControlController(this,{invalid:init=>this.emit("lr-invalid",null,init),interacted:this.markInteracted,customError:()=>this.validityController.customValidityMessage}),this.internals=this.validityController.formInternals,new GlassScrollLayer(this,'[part="listbox"]',()=>this.open)}get form(){return getFormOwner(this.internals)}set form(owner){setFormOwner(this,owner)}get validationTarget(){return this.validationTargetOverride??this.inputEl??void 0}set validationTarget(next){this.validationTargetOverride=next??void 0,this.validityController.refreshAnchor()}resetValidity(){this.validityController.setCustomValidity(""),this.updateValidity()}get input(){return this.inputEl??null}get selectionStart(){return this.inputEl?.selectionStart??null}set selectionStart(value){this.inputEl&&(this.inputEl.selectionStart=value)}get selectionEnd(){return this.inputEl?.selectionEnd??null}set selectionEnd(value){this.inputEl&&(this.inputEl.selectionEnd=value)}get selectionDirection(){return this.inputEl?.selectionDirection}set selectionDirection(value){this.inputEl&&(this.inputEl.selectionDirection=value)}get liveDisabled(){return this.effectiveDisabled||this.matches(":disabled")}get interactionBarred(){return this.liveDisabled||this.readonly}focus(options){this.liveDisabled||this.inputEl?.focus(options)}blur(){this.inputEl?.blur()}click(){this.liveDisabled||(this.inputEl?.focus(),this.show())}select(){this.inputEl?.select()}setSelectionRange(start,end,direction){this.inputEl?.setSelectionRange(start,end,direction)}setRangeText(replacement,start,end,selectMode){const input=this.inputEl;input&&(setNativeRangeText(input,replacement,start,end,selectMode),this.explicitInputValue=!0,this.query=input.value,this.activeIndex=-1,this.source&&this.runSource(this.query))}[VALIDITY_ANCHOR](){return this.validationTarget}syncExternalDescription(){if(!this.isConnected)return;const target=this.renderRoot.querySelector('[part="combobox-input"]');target&&(this.externalDescriptionLease?this.externalDescriptionLease.update(target):this.externalDescriptionLease=acquireNativeControlDescription(this,target,()=>this.localDescriptionIds))}releaseExternalDescription(){this.externalDescriptionLease?.release(),this.externalDescriptionLease=void 0}connectedCallback(){super.connectedCallback(),this.hasUpdated&&this.syncExternalDescription(),this.updateValidity(),this.hasUpdated&&this.syncValidatorAttributeObserver(),this.hasUpdated&&queueMicrotask(()=>{this.open?this.reconnectOpenPopup():this.source&&this._selected.length&&this.asyncRows.length===0&&this.runSource("")})}adoptedCallback(){super.adoptedCallback(),this.popupController.cancel(),this.releaseExternalDescription(),this.hasUpdated&&this.syncExternalDescription(),this.listboxPositioned=!1,this.invalidateListboxPositioning(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.popupController.unbindPointer(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceErrorAnnouncements.adopted()}willUpdate(changed){super.willUpdate(changed),this._isFirstUpdate=!this.hasUpdated,this.announceOpenTransition(changed),this.open?(this.listboxHidden=!1,this.listboxRendered=!0):changed.has("open")&&this.interactionBarred&&(this.listboxHidden=!0),changed.has("open")&&!this.openVetoed&&(this.listboxPositioned=!1),changed.has("open")&&this.openVetoed?this.closeCleanupPending=!1:changed.has("open")&&!this.open&&this.finalizeCloseState(),changed.has("source")&&(this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0,this.sourceToken++,this.sourceLoading=!1,this.sourceFailed=!1,this.sourceEverSettled=!1,this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this._sourceWarmed=!1,this.source&&this.open&&this.runSource(this.query)),!this._sourceWarmed&&this.source&&(this._selected.length>0||(this.pendingSelectedRowValues?.length??0)>0)&&this.asyncRows.length===0&&(this._sourceWarmed=!0,this.runSource(""))}firstUpdated(changed){super.firstUpdated(changed);const slot=this.optionsSlot;queueMicrotask(()=>{collectInitialSlotAssignment(slot,s=>{this.optionsObserved=!0,s.assignedElements({flatten:!0}).some(isLyraOptionElement)&&this.collectOptionsFromSlot(s)})})}get name(){return this._name}set name(next){const old=this._name;this._name=next??"",reflectFormName(this,this._name),this.syncFormValue(),this.requestUpdate("name",old)}get multiple(){return this._multiple}set multiple(next){const old=this._multiple;this._multiple=!!next,this.toggleAttribute("multiple",this._multiple),this.reflectSelected(),this.syncFormValue(),this.requestUpdate("multiple",old)}get disabled(){return this._disabled}set disabled(next){const old=this._disabled;this._disabled=!!next,this.toggleAttribute("disabled",this._disabled),this._fieldsetDisabled=this.validityController?.fieldsetDisabled(this._fieldsetDisabled)??this._fieldsetDisabled,this._disabled&&this.hide(),this.updateValidity(),this.requestUpdate("disabled",old)}get required(){return this._required}set required(next){const old=this._required;this._required=!!next,this.toggleAttribute("required",this._required),this.updateValidity(),this.requestUpdate("required",old)}get readonly(){return this._readonly}set readonly(next){const old=this._readonly;this._readonly=!!next,this.toggleAttribute("readonly",this._readonly),this._readonly&&this.hide(),this.updateValidity(),this.requestUpdate("readonly",old)}get value(){return this.multiple?[...this._selected]:this._selected[0]??""}set value(next){this.setValue(next,!0)}setValue(next,dirty,preferred){this.pendingSelectedWrites.clear();const old=this._selected;this.previousSelection=old,this.singleSelectedOption=preferred,dirty&&(this._restoredStateActive=!1,this._valueDirty=!0),this._selected=normalizeSelectionValues(next);const selected=new Set(this._selected);if(selected.size>0){const rows=this.rowsByValue(selected);for(const value of selected){const row=rows.get(value);row&&this._selectedRowCache.set(value,row)}}for(const value of this._selectedRowCache.keys())selected.has(value)||this._selectedRowCache.delete(value);for(const value of this._selectedLabelCache.keys())selected.has(value)||this._selectedLabelCache.delete(value);this.syncFormValue(),this.reflectSelected(),this.updateValidity(),this.requestUpdate("value",old)}get maxOptionsVisible(){return this._maxOptionsVisible}set maxOptionsVisible(next){const old=this._maxOptionsVisible;this._maxOptionsVisible=finiteCount(next,3),this.requestUpdate("maxOptionsVisible",old)}get maxRender(){return this._maxRender}get sourceDelay(){return this._sourceDelay}set sourceDelay(next){const old=this._sourceDelay;this._sourceDelay=finiteDuration(next,200),this.requestUpdate("sourceDelay",old)}set maxRender(next){const old=this._maxRender;this._maxRender=Math.min(finiteCount(next,200),MAX_RENDER_ROWS),this.requestUpdate("maxRender",old)}get sourceTotal(){return this._sourceTotal}get sourceTruncated(){return this._sourceTruncated}get selectedRows(){return this.resolveSelectedRowSlots().filter(row=>row!=null).map(row=>{const option=this.sourceOptionsByRow.get(row);return{...row,...option?this.adornmentsFor(option):{}}})}resolveSelectedRowSlots(){let rows;return this.committed.map(value=>this._selectedRowCache.get(value)??(rows??=this.rowsByValue(new Set(this.committed))).get(value))}get committed(){return this.multiple?this._selected:this._selected.slice(0,1)}rowsByValue(values){const rows=this.source?new Map:this.localRowsByValue(values,this.options);for(const row of this.asyncRows)values.has(row.value)&&!rows.has(row.value)&&rows.set(row.value,row);return rows}localRowsByValue(values,options){const rows=new Map;if(values.size===0)return rows;for(const option of options){const value=option.value;values.has(value)&&!rows.has(value)&&rows.set(value,this.rowForOption(option,!1))}return rows}set selectedRows(next){const values=[],seen=new Set;if(Array.isArray(next))for(const candidate of next){let value;try{value=candidate?.value}catch{continue}typeof value!="string"||seen.has(value)||(seen.add(value),values.push(value))}if(values.length>0&&!this.hasSelectionSourceRows){this.pendingSelectedRowValues=values,this.source&&this.isConnected&&(this._sourceWarmed=!0,this.runSource(""));return}this.pendingSelectedRowValues=void 0,this.applySelectedRowValues(values)}get barredFromValidation(){return isBarredFromValidation(this,this.internals)}validatorResult(){const self=this,current=self.value;for(const validator of Array.isArray(this.validators)?this.validators:[]){let result;try{if(typeof validator=="object"&&validator!==null&&"checkValidity"in validator){const checked=validator.checkValidity(this);if(checked?.isValid===!0)continue;const flags={};for(const key of Array.isArray(checked?.invalidKeys)?checked.invalidKeys:[])isValidityFlagKey(key)&&(flags[key]=!0);Object.values(flags).some(Boolean)||(flags.customError=!0);let message=typeof checked?.message=="string"?checked.message:"";return!message&&typeof validator.message=="string"&&(message=validator.message),!message&&typeof validator.message=="function"&&(message=validator.message(this)),{flags,message:message||this.localize("valueInvalid")}}result=typeof validator=="function"?validator(current,self):validator?.validate(current,self)}catch{return{flags:{customError:!0},message:this.localize("valueInvalid")}}if(!(result===void 0||result===!0)){if(typeof result=="string")return{flags:{customError:!0},message:result};if(result===!1)return{flags:{customError:!0},message:this.localize("valueInvalid")};if(result&&typeof result=="object"&&Object.values(result).some(Boolean))return{flags:result,message:this.localize("valueInvalid")}}}return{}}syncValidatorAttributeObserver(){this.disconnectValidatorAttributeObserver();const owner=this.ownerDocument.defaultView,MutationObserverCtor=owner?.MutationObserver;if(!this.isConnected||!owner||typeof MutationObserverCtor!="function")return;const attributes=new Set;for(const validator of Array.isArray(this.validators)?this.validators:[]){if(typeof validator!="object"||validator===null||!("checkValidity"in validator))continue;let observed;try{observed=validator.observedAttributes}catch{continue}if(Array.isArray(observed))for(const name of observed)typeof name=="string"&&name.length>0&&attributes.add(name)}if(attributes.size===0)return;const binding={},observer=new MutationObserverCtor(()=>{this.validatorAttributeObserver!==binding||!this.isConnected||this.ownerDocument.defaultView!==owner||(this.updateValidity(),this.validityRevision++)});binding.observer=observer,binding.owner=owner;try{observer.observe(this,{attributes:!0,attributeFilter:[...attributes]}),this.validatorAttributeObserver=binding}catch{observer.disconnect()}}disconnectValidatorAttributeObserver(){const binding=this.validatorAttributeObserver;this.validatorAttributeObserver=void 0,binding?.observer.disconnect()}updateValidity(){if(this.barredFromValidation){this.validityController.setValidity({}),this.syncCustomStates();return}const flags={};let message="";this.required&&this._selected.length===0&&(flags.valueMissing=!0,message=this.localize("comboboxRequired"));const configured=this.validatorResult();configured.flags&&Object.assign(flags,configured.flags),configured.message&&(message=configured.message),this.validityController.setValidity(flags,message),this.syncCustomStates()}syncCustomStates(){syncValidityStates(this.internals,{required:this.required,hasInteracted:this.touched,barred:this.barredFromValidation}),setCustomState(this.internals,"blank",this._selected.length===0),setCustomState(this.internals,"disabled",this.effectiveDisabled)}syncFormValue(){const state2=JSON.stringify(this._selected);if(this.multiple){if(!this.name){this.internals.setFormValue(null,state2);return}const fd=new FormData;for(const v of this._selected)fd.append(this.name,v);this.internals.setFormValue(fd,state2)}else this.internals.setFormValue(this._selected[0]??"",state2)}get effectiveDisabled(){return this.disabled||this._fieldsetDisabled}formResetCallback(){this.touched=!1,this._restoredStateActive=!1,this._valueDirty=!1;const resetValues=this._defaultSelected.length>0?this._defaultSelected:this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value);this._defaultSelected.length===0&&resetValues.length>0&&(this._defaultSelected=[...resetValues]);const defaults=new Set(resetValues);for(const option of this.options)option[RESET_OPTION_SELECTED_FROM_OWNER](defaults.has(option.value));this.setValue(this.multiple?[...resetValues]:resetValues.slice(0,1),!1),this.query="",this.explicitInputValue=!1}formStateRestoreCallback(state2,reason){let selected=[];if(typeof state2=="string")try{const parsed=JSON.parse(state2);Array.isArray(parsed)&&parsed.every(value=>typeof value=="string")&&(selected=parsed)}catch{}this.assignValue(this.multiple?selected:selected.slice(0,1)),this._restoredStateActive=!0}formDisabledCallback(disabled){if(this.validityController?.reflectingDisabled)return;const wasDisabled=this.effectiveDisabled;this._fieldsetDisabled=disabled,wasDisabled!==this.effectiveDisabled&&(disabled&&this.hide(),this.updateValidity(),this.requestUpdate())}checkValidity(){return this.validityController.checkValidity(()=>this.updateValidity())}reportValidity(){return this.validityController.syncConstraints(),this.touched=!0,this.updateValidity(),this.syncCustomStates(),this.internals.reportValidity()}setCustomValidity(message){this.validityController.setCustomValidity(message??""),this.syncCustomStates()}disconnectedCallback(){this.pendingSelectedWrites.clear(),this.listboxHidden=!0,this.releaseExternalDescription(),this.popupController.cancel(),this.listboxPositioned=!1,this.disconnectValidatorAttributeObserver(),super.disconnectedCallback(),this.invalidateListboxPositioning(),this.clearSourceTimer(),this.sourceToken+=1,this.sourceAbort?.abort(),this.sourceAbort=void 0,this.overlayHandle?.deactivate({restoreFocus:!1}),this.overlayHandle=void 0,this.popupController.unbindPointer(),this.open=!1}collectOptionsFromSlot(slot){const previous=new Set(this.options);if(this.optionsObserved=!0,this.options=slot.assignedElements({flatten:!0}).filter(isLyraOptionElement),this.adornmentClones=new WeakMap,this.normalizeActiveIndex(),this.applyPendingSelectedRows(),this._defaultCaptured){const newDefaults=this.options.filter(option=>!previous.has(option)&&option.defaultSelected),newLive=this.options.filter(option=>!previous.has(option)&&option.selected&&!option.defaultSelected);this.refreshOptionDefaults();const eligible=[...!this._restoredStateActive&&!this._valueDirty?newDefaults:[],...this._restoredStateActive?[]:newLive];if(eligible.length){const values=eligible.map(option=>option.value),next=this.multiple?[...new Set([...this._selected,...values])]:values[values.length-1];newLive.length>0?this.assignValue(next):this.setValue(next,!1);return}}else{this._defaultCaptured=!0;const allDefaults=this.options.filter(option=>option.defaultSelected).map(option=>option.value),allLive=this.options.filter(option=>option.selected).map(option=>option.value),defaults=this.multiple?allDefaults:allDefaults.slice(0,1),live=this.multiple?allLive:allLive.slice(0,1),initialLive=this.options.filter(option=>wasOptionInitiallySelected(option)).map(option=>option.value),optionDirty=this.options.some(option=>isOptionSelectedDirty(option)),dirtyValues=this.options.filter(option=>isOptionSelectedDirty(option)&&option.selected).map(option=>option.value);this._defaultSelected=[...defaults.length>0?defaults:initialLive.length>0?initialLive:live];const fromDefaults=defaults.length>0,initial=optionDirty?this.multiple?allLive:dirtyValues.slice(-1)[0]?dirtyValues.slice(-1):live:fromDefaults?defaults:live;if(initial.length&&!this._restoredStateActive&&!this._valueDirty){const next=this.multiple?initial:initial[0];fromDefaults&&!optionDirty?this.setValue(next,!1):this.assignValue(next);return}optionDirty&&(this._valueDirty=!0)}this.reflectSelected()}refreshOptionDefaults(){const declared=this.options.filter(option=>option.defaultSelected).map(option=>option.value);this._defaultSelected=this.multiple?declared:declared.slice(0,1),!this._valueDirty&&!this._restoredStateActive&&this.setValue([...this._defaultSelected],!1)}requestUpdate(...args){args[0]===void 0&&(this.callbackRefreshEpoch=(this.callbackRefreshEpoch??0)+1),super.requestUpdate(...args)}memoOption(key,inputs,compute){const previous=this.optionMemo.get(key);if(previous&&previous.inputs.length===inputs.length&&previous.inputs.every((input,index)=>Object.is(input,inputs[index])))return previous.value;const value=compute();return this.optionMemo.set(key,{inputs,value}),value}get optionIndex(){return this.memoOption("index",[this.options],()=>{const values=new Map;for(const option of this.options)values.has(option.value)||values.set(option.value,option);return{values,members:new Set(this.options)}})}get asyncIndex(){return this.memoOption("asyncIndex",[this.asyncRows],()=>{const values=new Map;for(const row of this.asyncRows)values.has(row.value)||values.set(row.value,row);return values})}get searchCorpus(){return this.memoOption("corpus",[this.options,this.effectiveLocale],()=>this.options.map(option=>({label:option.label.toLocaleLowerCase(this.effectiveLocale),search:option.searchText.toLocaleLowerCase(this.effectiveLocale),value:option.value.toLocaleLowerCase(this.effectiveLocale)})))}flushSelectedWrites(){this.selectedWritesQueued=!1;const writes=[...this.pendingSelectedWrites];if(this.pendingSelectedWrites.clear(),!(!this.isConnected||writes.length===0))if(this.multiple){const values=new Set(this._selected);for(const[option,write]of writes)this.optionIndex.members.has(option)&&(write.selected?values.add(write.value):values.delete(write.value));this.setValue([...values],!0)}else{let value=this._selected[0],option=this.singleSelectedOption;for(const[candidate,write]of writes)this.optionIndex.members.has(candidate)&&(write.selected?(value=write.value,option=candidate):candidate===option&&(value=void 0,option=void 0));this.setValue(value===void 0?[]:value,!0,option)}}reflectSelected(){const value=this._selected[0];(!this.singleSelectedOption||!this.optionIndex.members.has(this.singleSelectedOption)||this.singleSelectedOption.value!==value)&&(this.singleSelectedOption=value===void 0?void 0:this.optionIndex.values.get(value));const selected=new Set(this._selected);for(const option of this.options)option[SET_OPTION_SELECTED_FROM_OWNER](this.multiple?selected.has(option.value):option===this.singleSelectedOption)}labelFor(value){const nonBlank=label=>label!==void 0&&label.trim().length>0?label:void 0;if(this.getUnknownLabel&&this.isUnknownValue(value)){const override=nonBlank(this.getUnknownLabel(value));if(override!==void 0)return override}return(!this.source&&!this.multiple&&this.singleSelectedOption?.value===value?nonBlank(this.singleSelectedOption.label):void 0)??nonBlank(this._selectedLabelCache.get(value))??nonBlank(this.optionIndex.values.get(value)?.label)??nonBlank(this.asyncIndex.get(value)?.label)??(this.loading||this.source&&!this.sourceEverSettled?this.statusText("loading",this.loadingText):void 0)??value}isUnknownValue(value){return!this.source&&!this.optionsObserved||this.loading||this.source&&!this.sourceEverSettled?!1:!(!this.source&&!this.multiple&&this.singleSelectedOption?.value===value||this._selectedLabelCache.has(value)||this.optionIndex.values.has(value)||this.asyncIndex.has(value))}adornmentMarkup(option){return Array.from(option.children).filter(child=>["start","end","prefix","suffix"].includes(child.getAttribute("slot")??"")).map(child=>child.outerHTML).join("")}adornmentsFor(option){const cached=this.adornmentClones.get(option);if(cached)return cached;const cloneSlot=selector=>{const nodes=Array.from(option.querySelectorAll(selector));if(nodes.length!==0)return nodes.map(node=>node.cloneNode(!0))},resolved={markup:this.adornmentMarkup(option),start:cloneSlot(':scope > [slot="start"], :scope > [slot="prefix"]'),end:cloneSlot(':scope > [slot="end"], :scope > [slot="suffix"]')};return this.adornmentClones.set(option,resolved),resolved}rowForOption(option,withAdornments=!0){const adornments=withAdornments?this.adornmentsFor(option):{},row={value:option.value,label:option.label||option.value,sub:option.sub||void 0,dotColor:option.dotColor||void 0,title:option.title||void 0,group:option.group||void 0,disabled:option.disabled||option.inert||option.closest("[inert]")!==null,data:option.data,...adornments.start===void 0?{}:{start:adornments.start},...adornments.end===void 0?{}:{end:adornments.end}};return this.sourceOptionsByRow.set(row,option),row}get hasSelectionSourceRows(){return(this.source?this.asyncRows.length:this.options.length)>0}applySelectedRowValues(values){const requested=new Set(values),rowsByValue=this.source?this.rowsByValue(requested):this.localRowsByValue(requested,this.options),rows=values.map(value=>rowsByValue.get(value)).filter(row=>row!==void 0),limited=this.multiple?rows:rows.slice(0,1);this.assignValue(limited.map(row=>row.value));for(const row of limited)this._selectedRowCache.set(row.value,row)}applyPendingSelectedRows(acceptEmptySource=!1){if(this.pendingSelectedRowValues===void 0||!acceptEmptySource&&!this.hasSelectionSourceRows)return!1;const values=this.pendingSelectedRowValues;return this.pendingSelectedRowValues=void 0,this.applySelectedRowValues(values),!0}get unknownRows(){if(!this.withUnknownOption)return[];const locale=this.effectiveLocale,query2=this.query.trim().toLocaleLowerCase(locale);return this.committed.filter(value=>this.isUnknownValue(value)).map(value=>({value,label:this.labelFor(value),badge:this.localize("notInCatalog"),unknownValue:value})).filter(row=>!query2||row.label.toLocaleLowerCase(locale).includes(query2)||row.value.toLocaleLowerCase(locale).includes(query2))}get createRow(){if(!this.allowCreate)return;const inputValue=this.query.trim();if(!inputValue)return;const locale=this.effectiveLocale,folded=inputValue.toLocaleLowerCase(locale);if(!(this.source?this.memoOption("asyncExact",[this.asyncRows,locale],()=>new Set(this.asyncRows.flatMap(row=>[row.value.toLocaleLowerCase(locale),row.label.toLocaleLowerCase(locale)]))).has(folded):this.searchCorpus.some(row=>row.value===folded||row.label===folded)))return{value:inputValue,label:this.localize("comboboxCreate",void 0,{value:inputValue}),createInput:inputValue}}capRows(all,activeValue){return this.memoOption("capRows",[all,this.maxRender,this._selected,this.multiple,activeValue],()=>{const selected=new Set(this.committed),retained=all.filter(row=>selected.has(row.value)),active=activeValue===void 0?void 0:all.find(row=>row.value===activeValue);return capOptionRows(all,this.maxRender,active?[active,...retained]:retained)})}get renderedRows(){const active=this.lastRenderedRows.filter(row=>!row.disabled)[this.activeIndex]?.value,result=this.memoOption("renderedRows",[this.callbackRefreshEpoch,this.options,this.asyncRows,this.source,this.query,this._selected,this.multiple,this.maxRender,this._sourceTotal,this.withUnknownOption,this.allowCreate,this.filter,this.getUnknownLabel,this.loading,this.sourceEverSettled,this.effectiveLocale,this.strings,active],()=>this.computeRenderedRows(active));return this.lastRenderedRows=result.rows,result}computeRenderedRows(active){let rows,overflow;if(this.source){const capped=this.capRows(this.asyncRows,active);rows=[...capped.rows],overflow=capped.overflow,overflow+=Math.max(0,this._sourceTotal-this.asyncRows.length)}else{const capped=this.capRows(this.filtered,active);rows=capped.rows.map(option=>this.rowForOption(option)),overflow=capped.overflow}rows=[...rows];const create=this.createRow;rows.push(...this.unknownRows),create&&rows.push(create);const selected=new Set(this.committed),retained=rows.filter(row=>selected.has(row.value)),activeRow=rows.find(row=>row.value===active),bounded=capOptionRows(rows,MAX_RENDER_ROWS,activeRow?[activeRow,...retained]:retained);return{rows:bounded.rows,overflow:overflow+bounded.overflow}}normalizeActiveIndex(){if(this.activeIndex<0)return;const navigableCount=this.renderedRows.rows.filter(row=>!row.disabled).length,next=navigableCount>0?Math.min(this.activeIndex,navigableCount-1):-1;next!==this.activeIndex&&(this.activeIndex=next)}get filtered(){const locale=this.effectiveLocale,q=this.query.trim().toLocaleLowerCase(locale),selectedLabel=this.multiple?"":this.labelFor(this._selected[0]??"")??"",effective=q&&q===selectedLabel.toLocaleLowerCase(locale)?"":q;return effective?this.memoOption("filtered",[this.options,this.filter,effective,locale,this.callbackRefreshEpoch],()=>{const filter=this.filter;if(filter)return this.options.filter(option=>filter(option,effective));const corpus=this.searchCorpus;return this.options.filter((_option,index)=>corpus[index].label.includes(effective)||corpus[index].search.includes(effective))}):this.options}get displayValue(){return this.multiple||this.open||this.explicitInputValue?this.query:this._selected[0]?this.labelFor(this._selected[0]):""}announceOpenTransition(changed){this.openVetoed=!1;const closeAfterPositioningFailure=!this.open&&this.closeAfterPositioningFailure;if(this.closeAfterPositioningFailure=!1,!(!changed.has("open")||this._isFirstUpdate||!this.open&&this.interactionBarred)){if(!this.isConnected||closeAfterPositioningFailure){emitPopupEvent(this,"lr-hide",!1);return}this.openVetoed=this.popupController.announce(this.open,()=>{this.open=!this.open})}}show(){if(this.open||this.interactionBarred)return Promise.resolve();const settled=this.popupController.wait(!0);return this.open=!0,settled}hide(){if(!this.open)return Promise.resolve();const settled=this.popupController.wait(!1);return this.closeCleanupPending=!0,this.open=!1,settled}finalizeCloseState(){if(this.closeCleanupPending&&(this.closeCleanupPending=!1,this.activeIndex=-1,!this.multiple)){const queryChanged=this.query!=="";this.query="",this.explicitInputValue=!1,queryChanged&&this.source&&(this.asyncRows=[],this.sourceFailed=!1,this._sourceTotal=0,this._sourceTruncated=!1)}}activateListboxOverlay(){this.invalidateListboxPositioning(),this.overlayHandle?.deactivate({restoreFocus:!1}),this.restoreFocusOnClose=!0,this.overlayHandle=activateNonmodalOverlay({host:this,panel:()=>this.renderRoot.querySelector('[part="listbox"]'),onEscape:()=>{this.hide()},onBackdrop:()=>{this.restoreFocusOnClose=!1,this.hide()},restoreFocusTo:this.inputEl??null}),this.popupController.bindPointer(),this.beginListboxPositioning()}beginListboxPositioning(){const anchor=this.renderRoot.querySelector('[part="combobox"]'),listbox=this.renderRoot.querySelector('[part="listbox"]');if(anchor&&listbox){const generation=this.positioningGeneration;this.positioningReady=new Promise(resolve=>{this.resolvePositioningReady=resolve}),this.startListboxPositioning(generation,anchor,listbox)}}invalidateListboxPositioning(){this.positioningGeneration++,this.cleanup?.(),this.cleanup=void 0,this.resolvePositioningReady?.(!1),this.resolvePositioningReady=void 0}resolveCurrentPositioning(positioned){const resolve=this.resolvePositioningReady;this.resolvePositioningReady=void 0,resolve?.(positioned)}async startListboxPositioning(generation,anchor,listbox){try{const runtime=await loadAnchoredOverlayRuntime(),{place}=runtime;if(generation!==this.positioningGeneration||!this.open||!this.isConnected||this.renderRoot.querySelector('[part="combobox"]')!==anchor||this.renderRoot.querySelector('[part="listbox"]')!==listbox)return;this.placedTopLayer=syncTopLayerRelease(listbox,this.placedTopLayer,this.topLayer,runtime);const cleanup=place(anchor,listbox,{placement:`${this.placement}-start`,...topLayerPlacement(this.topLayer,resolveEffectivePositioningStrategy(this,this._positioningStrategy,"fixed")),sync:this.sync,onPlaced:()=>{generation===this.positioningGeneration&&(this.listboxPositioned=!0,this.updateComplete.then(()=>{generation!==this.positioningGeneration||!this.open||this.resolveCurrentPositioning(!0)}))}});generation!==this.positioningGeneration?cleanup():this.cleanup=cleanup}catch{if(generation!==this.positioningGeneration||!this.open)return;this.resolveCurrentPositioning(!1),this.closeAfterPositioningFailure=!0,this.hide()}}teardownListboxOverlay(restoreFocus=this.restoreFocusOnClose){this.invalidateListboxPositioning(),this.restoringOverlayFocus=restoreFocus;try{this.overlayHandle?.deactivate({restoreFocus})}finally{this.restoringOverlayFocus=!1}this.overlayHandle=void 0,this.popupController.unbindPointer(),this.restoreFocusOnClose=!0}reconnectOpenPopup(){!this.isConnected||!this.open||(this.activateListboxOverlay(),this.source&&this.asyncRows.length===0&&this.runSource(this.query))}syncVisibleOptionsCap(){const listbox=this.renderRoot?.querySelector('[part="listbox"]');if(!listbox)return;const clear=()=>{listbox.style.removeProperty("max-block-size")},requested=typeof this.visibleOptions=="number"?finiteCount(this.visibleOptions,0):0;if(requested<=0)return clear();const rows=listbox.querySelectorAll('[part="option"]');if(rows.length<=requested)return clear();const boundary=rows[requested];if(!boundary)return clear();const cap=boundary.getBoundingClientRect().top-listbox.getBoundingClientRect().top;if(!Number.isFinite(cap)||cap<=0)return clear();listbox.style.setProperty("max-block-size",`min(${Math.ceil(cap)}px, var(--lr-positioner-available-block-size, var(--lr-size-18rem)))`)}updated(changed){if(super.updated(changed),this.syncExternalDescription(),(changed.has("visibleOptions")||changed.has("open")||changed.has("query")||changed.has("options")||changed.has("asyncRows")||changed.has("maxRender")||changed.has("value")||changed.has("listboxPositioned")||changed.has("strings")||changed.has("lang")||changed.has("size")||changed.has("filter")||changed.has("allowCreate")||changed.has("withUnknownOption"))&&this.syncVisibleOptionsCap(),changed.has("open")&&!this.openVetoed?this.open&&this.isConnected?(this.activateListboxOverlay(),this._isFirstUpdate||this.settleTransition("lr-after-show"),this.refreshQueued?(this.refreshQueued=!1,this.runSource(this.query)):this.source&&this.asyncRows.length===0&&this.runSource(this.query)):this.open?this.teardownListboxOverlay(!1):(this.teardownListboxOverlay(),this.interactionBarred?this.popupController.cancel():this._isFirstUpdate||this.settleTransition("lr-after-hide")):changed.has("open")&&this.openVetoed&&(this.restoreFocusOnClose=!0),changed.has("topLayer")&&!changed.has("open")&&this.open&&this.isConnected&&(this.invalidateListboxPositioning(),this.beginListboxPositioning()),changed.has("name")&&this.syncFormValue(),changed.has("validators")&&(this.updateValidity(),this.syncValidatorAttributeObserver()),(changed.has("touched")||changed.has("required")||changed.has("value")||changed.has("validators")||changed.has("validityRevision"))&&this.toggleAttribute("data-invalid",this.touched&&!this.internals.validity.valid),changed.has("activeIndex")||changed.has("listboxPositioned")){const listbox=this.renderRoot.querySelector('[part="listbox"]'),row=listbox?.querySelector('[part="option"][data-active]');listbox&&row&&revealRow(listbox,row)}}settleTransition(event){return this.popupController.settle(event,{waitForPosition:async stale=>{for(;this.open&&!this.listboxPositioned;){const readiness=this.positioningReady,positioned=await readiness;if(stale())return!1;if(positioned)break;if(readiness===this.positioningReady)return!1}return!0},conceal:()=>{this.listboxHidden=!0,this.listboxRendered=!1}})}emitValueEvents(){const self=this,data=this.resolveSelectedRowSlots().map(row=>row?.data),previousValue=this.multiple?[...this.previousSelection]:this.previousSelection[0]??"",detail={value:self.value,previousValue,data};emitValueEvents(self,"input",detail,detail2=>self.emit("lr-input",detail2)),emitValueEvents(self,"change",detail,detail2=>self.emit("lr-change",detail2))}assignValue(next){this.value=next}createOption(inputValue){if(this.liveDisabled||this.readonly||this.emit("lr-create",{inputValue},{cancelable:!0}).defaultPrevented)return;const option=this.ownerDocument.createElement(tag("option"));option.setAttribute("value",inputValue),option.textContent=inputValue,this.append(option),this.pickRow({value:inputValue,label:inputValue})}commitCustomValue(inputValue){if(this.liveDisabled||this.readonly||this.multiple||!inputValue)return;const selectionChanged=this._selected[0]!==inputValue;this.touched=!0,this._selectedLabelCache.set(inputValue,inputValue),this.assignValue(inputValue),this.query="",this.explicitInputValue=!1,this.hide(),selectionChanged&&this.emitValueEvents()}pickRow(row){const sourceOption=this.sourceOptionsByRow.get(row);if(this.liveDisabled||this.readonly||row.disabled||sourceOption&&(sourceOption.disabled||sourceOption.closest("[inert]")))return;if(row.createInput!==void 0){this.createOption(row.createInput);return}this.touched=!0;const synthetic=row.unknownValue!==void 0,selectionChanged=this.multiple||this._selected[0]!==row.value;if(this.multiple){const set=new Set(this._selected);set.has(row.value)?(set.delete(row.value),this._selectedRowCache.delete(row.value)):(set.add(row.value),synthetic||(this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.set(row.value,row))),this.assignValue([...set]),this.query="",this.explicitInputValue=!1}else synthetic||(this._selectedLabelCache.set(row.value,row.label),this._selectedRowCache.clear(),this._selectedRowCache.set(row.value,row)),this.setValue(row.value,!0,sourceOption),this.query="",this.explicitInputValue=!1,this.hide();this.source&&this.runSource(this.query),selectionChanged&&this.emitValueEvents(),this.emit("lr-activate",{value:row.value})}removeValueAt(index){if(this.liveDisabled||this.readonly||index<0||index>=this._selected.length)return;const next=this._selected.filter((_,i)=>i!==index);this.touched=!0,this.assignValue(next),this.emitValueEvents()}clear(){if(this.liveDisabled||this.readonly)return;const hadSelection=this._selected.length>0,queryChanged=this.query!=="";!hadSelection&&!queryChanged||(hadSelection&&(this.touched=!0,this.assignValue([])),this.query="",this.explicitInputValue=!1,this.source&&this.runSource(this.query),hadSelection&&(this.emitValueEvents(),this.emit("lr-clear")),queryChanged&&this.emit("lr-filter",{value:this.query}))}refresh(){if(this.source){if(!this.open){this.refreshQueued=!0;return}this.refreshQueued=!1,this.runSource(this.query,{immediate:!0})}}runSource(query2,options){const source=this.source;if(!source)return;this.clearSourceTimer(),this.sourceAbort?.abort(),this.sourceAbort=void 0;const token=++this.sourceToken,ownerWindow=this.ownerDocument.defaultView;if(!this.isConnected||!ownerWindow)return;const request={query:query2,token,owner:ownerWindow,source};if(options?.immediate){this.runSourceRequest(request);return}this.sourceDebounce.delayMs=this._sourceDelay,this.sourceDebounce.push(request)}runSourceRequest({query:query2,token,owner:ownerWindow,source}){if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const controller=new ownerWindow.AbortController;this.sourceAbort=controller,this.sourceLoading=!0,this.sourceFailed=!1,Promise.resolve().then(()=>source(query2,{signal:controller.signal,limit:MAX_SOURCE_ROWS})).then(result=>{if(token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow)return;const normalized=normalizeSourceResult(result);this._sourceTotal=normalized.total,this._sourceTruncated=normalized.truncated,this.asyncRows=normalized.rows,this.sourceFailed=!1,this.sourceEverSettled=!0,this.normalizeActiveIndex(),this.applyPendingSelectedRows(!0);const selected=new Set(this._selected);for(const row of normalized.rows)selected.has(row.value)&&this._selectedRowCache.set(row.value,row)}).catch(err=>{token!==this.sourceToken||!this.isConnected||this.ownerDocument.defaultView!==ownerWindow||typeof err=="object"&&err!==null&&"name"in err&&err.name==="AbortError"||(this.asyncRows=[],this._sourceTotal=0,this._sourceTruncated=!1,this.activeIndex=-1,this.sourceFailed=!0,this.sourceEverSettled=!0,this.sourceErrorAnnouncements.announceAssertive(this.localize("comboboxLoadError")),this.emit("lr-source-error",{error:err,query:query2}),console.warn("<lr-combobox> source() rejected:",err))}).finally(()=>{token===this.sourceToken&&(this.sourceLoading=!1)})}clearSourceTimer(){this.sourceDebounce.cancel()}renderRows(rows,activeId){const out=[];let currentGroup,currentGroupRows=[],groupIndex=0;const selectedSet=new Set(this.committed),flushGroup=()=>{if(currentGroupRows.length){if(currentGroup){const labelId=`${this.listId}-group-${groupIndex++}`;out.push(html`<div role="group" aria-labelledby=${labelId}>
|
|
2
2
|
<div id=${labelId} part="group-label" class="group-label">${currentGroup}</div>
|
|
3
3
|
${currentGroupRows}
|
|
4
4
|
</div>`)}else out.push(...currentGroupRows);currentGroupRows=[]}};return rows.forEach((o,i)=>{o.group!==currentGroup&&(flushGroup(),currentGroup=o.group);const id=`${this.listId}-opt-${i}`,selected=this.multiple||this.source?selectedSet.has(o.value):this.singleSelectedOption!==void 0&&this.sourceOptionsByRow.get(o)===this.singleSelectedOption;selected&&!this.multiple&&selectedSet.delete(o.value),currentGroupRows.push(html`<div
|