@aceshooting/lyra-ui 29.2.2 → 30.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +126 -106
- package/README.md +8 -7
- package/dist/ai/snapshot.js +1 -1
- package/dist/all.d.ts +1 -1
- package/dist/all.js +1 -1
- package/dist/autoloader.js +1 -1
- package/dist/cli/component-inventory.mjs +1 -1
- package/dist/cli/lyra-rename-ledger.mjs +1 -1
- package/dist/cli/migrate-wa.mjs +7 -3
- package/dist/cli/migration-analysis.mjs +1 -1
- package/dist/cli/migration-contract.json +1 -1
- package/dist/cli/migration-contract.mjs +1 -1
- package/dist/cli/migration-immutable-collections.mjs +6 -0
- package/dist/cli/migration-renames.mjs +1 -1
- package/dist/cli/migration-transforms.mjs +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.d.ts +1 -1
- package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.d.ts +1 -2
- package/dist/components/agent-tools/agent-eval-dashboard/agent-eval-dashboard.class.js +1 -1
- package/dist/components/agent-tools/agent-run/agent-run.class.d.ts +3 -4
- package/dist/components/agent-tools/agent-run/agent-run.class.js +1 -1
- package/dist/components/agent-tools/agent-trace/agent-trace.class.d.ts +1 -1
- package/dist/components/agent-tools/agent-trace/agent-trace.class.js +2 -2
- package/dist/components/agent-tools/background-runs/background-runs.class.d.ts +1 -2
- package/dist/components/agent-tools/background-runs/background-runs.class.js +1 -1
- package/dist/components/agent-tools/change-review/change-review.class.d.ts +1 -2
- package/dist/components/agent-tools/change-review/change-review.class.js +1 -1
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.d.ts +3 -2
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
- package/dist/components/agent-tools/evaluation-run/evaluation-run.class.d.ts +7 -1
- package/dist/components/agent-tools/evaluation-run/evaluation-run.class.js +1 -1
- package/dist/components/agent-tools/prompt-studio/prompt-studio.class.d.ts +2 -2
- package/dist/components/agent-tools/prompt-studio/prompt-studio.class.js +3 -3
- package/dist/components/agent-tools/span-waterfall/span-waterfall.class.d.ts +1 -1
- package/dist/components/agent-tools/subagent-panel/subagent-panel.class.d.ts +1 -2
- package/dist/components/agent-tools/subagent-panel/subagent-panel.class.js +2 -2
- package/dist/components/agent-tools/task-list/task-list.class.d.ts +1 -1
- package/dist/components/agent-tools/test-results/test-results.class.d.ts +1 -1
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.d.ts +3 -4
- package/dist/components/agent-tools/tool-call-chip/tool-call-chip.class.js +1 -5
- package/dist/components/agent-tools/tool-timeline/tool-timeline.class.d.ts +3 -3
- package/dist/components/agent-tools/trace-tree/trace-tree.class.d.ts +1 -0
- package/dist/components/agent-tools/trace-tree/trace-tree.class.js +1 -1
- package/dist/components/charts/chart/chart.class.js +3 -3
- package/dist/components/charts/chart-3d/chart-3d-data.d.ts +50 -0
- package/dist/components/charts/chart-3d/chart-3d-data.js +1 -0
- package/dist/components/charts/chart-3d/chart-3d-engine.js +1 -0
- package/dist/components/charts/chart-3d/chart-3d.class.d.ts +96 -0
- package/dist/components/charts/chart-3d/chart-3d.class.js +47 -0
- package/dist/components/charts/chart-3d/chart-3d.d.ts +1 -0
- package/dist/components/charts/chart-3d/chart-3d.js +1 -0
- package/dist/components/charts/chart-3d/chart-3d.styles.js +1 -0
- package/dist/components/charts/index.d.ts +1 -1
- package/dist/components/charts/index.js +1 -1
- package/dist/components/conversation/agent-workspace/agent-workspace.class.d.ts +3 -3
- package/dist/components/conversation/agent-workspace/agent-workspace.class.js +4 -5
- package/dist/components/conversation/code-block/code-block-base.class.js +1 -1
- package/dist/components/conversation/code-block/shiki-oniguruma.d.ts +3 -0
- package/dist/components/conversation/code-block/shiki-oniguruma.js +1 -0
- package/dist/components/conversation/code-block/shiki-types.d.ts +3 -5
- package/dist/components/conversation/code-block/shiki-types.js +1 -1
- package/dist/components/conversation/generation-metrics/generation-metrics.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-progressive.js +1 -1
- package/dist/components/conversation/message-actions/message-actions.class.js +1 -1
- package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
- package/dist/components/conversation/model-select/model-select.class.js +1 -1
- package/dist/components/conversation/model-settings-panel/model-settings-panel.class.js +1 -1
- package/dist/components/conversation/prompt-input/prompt-input.class.js +3 -4
- package/dist/components/conversation/prompt-queue/prompt-queue.class.d.ts +1 -1
- package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
- package/dist/components/conversation/selection-toolbar/selection-toolbar.class.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +2 -2
- package/dist/components/conversation/thread-list/thread-list.class.js +1 -1
- package/dist/components/conversation/widget-renderer/registry.js +1 -1
- package/dist/components/conversation/widget-renderer/resolve.js +1 -1
- package/dist/components/data/calendar/calendar.class.d.ts +3 -1
- package/dist/components/data/data-grid/data-grid.class.js +2 -2
- package/dist/components/data/flow-canvas/flow-canvas.class.js +2 -2
- package/dist/components/data/flow-canvas/flow-source.js +1 -1
- package/dist/components/data/flow-node/flow-node.class.d.ts +2 -3
- package/dist/components/data/flow-node/flow-node.class.js +2 -4
- package/dist/components/data/heatmap/heatmap.class.js +1 -1
- package/dist/components/data/sparkline/sparkline.class.d.ts +0 -1
- package/dist/components/data/sparkline/sparkline.class.js +1 -1
- package/dist/components/data/table/table.class.js +1 -1
- package/dist/components/forms/color-picker/color-core.js +1 -1
- package/dist/components/forms/date-picker/calendar-core.js +1 -1
- package/dist/components/forms/otp-input/otp-input.class.js +1 -1
- package/dist/components/forms/signature-pad/signature-pad.class.d.ts +4 -3
- package/dist/components/forms/signature-pad/signature-pad.class.js +1 -1
- package/dist/components/forms/swatch-picker/swatch-picker.class.d.ts +3 -2
- package/dist/components/forms/swatch-picker/swatch-picker.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail-item.class.d.ts +0 -2
- package/dist/components/layout/app-rail/app-rail-item.class.js +1 -1
- package/dist/components/layout/app-rail/app-rail.class.d.ts +3 -3
- package/dist/components/layout/command-palette/command-palette.class.d.ts +1 -1
- package/dist/components/layout/details/accordion-item.class.d.ts +1 -2
- package/dist/components/layout/details/accordion-item.class.js +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.d.ts +4 -11
- package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
- package/dist/components/layout/drilldown-panel/drilldown-panel.class.js +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/menubar/menubar-item.class.d.ts +1 -1
- package/dist/components/layout/menubar/menubar.class.d.ts +1 -1
- package/dist/components/layout/multi-split/multi-split.class.d.ts +1 -1
- package/dist/components/layout/multi-split/multi-split.class.js +1 -1
- package/dist/components/layout/navigation-menu/navigation-menu.class.d.ts +2 -6
- package/dist/components/layout/navigation-menu/navigation-menu.class.js +1 -1
- package/dist/components/layout/tab-group/tab-group.class.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.class.d.ts +3 -2
- package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
- package/dist/components/layout/widget/widget.class.d.ts +5 -14
- package/dist/components/layout/widget/widget.class.js +2 -2
- package/dist/components/lr-chart-3d.js +1 -0
- package/dist/components/lr-model-viewer.js +1 -0
- package/dist/components/media/av-player/av-metadata.d.ts +1 -13
- package/dist/components/media/av-player/av-metadata.js +1 -1
- package/dist/components/media/av-player/av-player.class.js +1 -1
- package/dist/components/media/file-input/file-input.class.d.ts +10 -13
- package/dist/components/media/file-input/file-input.class.js +3 -3
- package/dist/components/media/file-input/file-input.styles.js +1 -1
- package/dist/components/media/image-viewer/image-viewer-panorama.d.ts +5 -0
- package/dist/components/media/image-viewer/image-viewer-panorama.js +8 -0
- package/dist/components/media/image-viewer/image-viewer-panorama.styles.js +1 -0
- package/dist/components/media/image-viewer/image-viewer.class.d.ts +29 -5
- package/dist/components/media/image-viewer/image-viewer.class.js +8 -5
- package/dist/components/media/image-viewer/image-viewer.styles.js +1 -1
- package/dist/components/media/map/map-anchor-controller.js +1 -0
- package/dist/components/media/map/map-anchor-options.d.ts +14 -0
- package/dist/components/media/map/map-anchor-options.js +1 -0
- package/dist/components/media/map/map-camera.d.ts +34 -0
- package/dist/components/media/map/map-camera.js +1 -0
- package/dist/components/media/map/map-construction-scheduler.d.ts +13 -0
- package/dist/components/media/map/map-construction-scheduler.js +1 -0
- package/dist/components/media/map/map-control-options.d.ts +39 -0
- package/dist/components/media/map/map-control-options.js +1 -0
- package/dist/components/media/map/map-controls-lifecycle.js +1 -0
- package/dist/components/media/map/map-cursor.js +1 -0
- package/dist/components/media/map/map-data-layer-model.d.ts +40 -0
- package/dist/components/media/map/map-data-layer-model.js +1 -0
- package/dist/components/media/map/map-drawing-controller.js +1 -0
- package/dist/components/media/map/map-drawing-gesture.js +1 -0
- package/dist/components/media/map/map-drawing-pan.js +1 -0
- package/dist/components/media/map/map-drawing-pointer.js +1 -0
- package/dist/components/media/map/map-drawing.d.ts +29 -0
- package/dist/components/media/map/map-drawing.js +1 -0
- package/dist/components/media/map/map-empty-style.d.ts +8 -0
- package/dist/components/media/map/map-empty-style.js +1 -0
- package/dist/components/media/map/map-engine-events.js +1 -0
- package/dist/components/media/map/map-export-attribution.js +1 -0
- package/dist/components/media/map/map-external-source-effects.js +1 -0
- package/dist/components/media/map/map-feature-loader-core.js +1 -0
- package/dist/components/media/map/map-feature-loader.js +1 -0
- package/dist/components/media/map/map-feature-state-router.d.ts +16 -0
- package/dist/components/media/map/map-feature-state-router.js +1 -0
- package/dist/components/media/map/map-feature-state-routes.js +1 -0
- package/dist/components/media/map/map-feature-state.d.ts +16 -0
- package/dist/components/media/map/map-feature-state.js +1 -0
- package/dist/components/media/map/map-hash-option.js +1 -0
- package/dist/components/media/map/map-hash-owner.js +1 -0
- package/dist/components/media/map/map-hash.js +1 -0
- package/dist/components/media/map/map-hit-test.d.ts +17 -0
- package/dist/components/media/map/map-hit-test.js +1 -0
- package/dist/components/media/map/map-image-admission.d.ts +7 -0
- package/dist/components/media/map/map-image-admission.js +1 -0
- package/dist/components/media/map/map-image-export-controller.js +1 -0
- package/dist/components/media/map/map-image-export-error.d.ts +3 -0
- package/dist/components/media/map/map-image-export-error.js +1 -0
- package/dist/components/media/map/map-image-export.d.ts +15 -0
- package/dist/components/media/map/map-image-export.js +5 -0
- package/dist/components/media/map/map-image-limits.d.ts +4 -0
- package/dist/components/media/map/map-image-limits.js +1 -0
- package/dist/components/media/map/map-image-metadata.js +3 -0
- package/dist/components/media/map/map-image-provider.d.ts +33 -0
- package/dist/components/media/map/map-image-provider.js +1 -0
- package/dist/components/media/map/map-images.d.ts +9 -0
- package/dist/components/media/map/map-images.js +1 -0
- package/dist/components/media/map/map-interaction-options.d.ts +26 -0
- package/dist/components/media/map/map-interaction-options.js +1 -0
- package/dist/components/media/map/map-layer-order.js +1 -0
- package/dist/components/media/map/map-loader.d.ts +35 -5
- package/dist/components/media/map/map-loader.js +1 -1
- package/dist/components/media/map/map-local-image-url.js +1 -0
- package/dist/components/media/map/map-local-image.js +1 -0
- package/dist/components/media/map/map-overlay-admission.d.ts +13 -0
- package/dist/components/media/map/map-overlay-admission.js +1 -0
- package/dist/components/media/map/map-owned-feature-input.js +1 -0
- package/dist/components/media/map/map-owned-features.js +1 -0
- package/dist/components/media/map/map-owned-resources.js +1 -0
- package/dist/components/media/map/map-paint-batch.js +1 -0
- package/dist/components/media/map/map-readers.js +1 -0
- package/dist/components/media/map/map-readiness.js +1 -0
- package/dist/components/media/map/map-resource-feature-loaders.js +1 -0
- package/dist/components/media/map/map-source-updates.js +1 -0
- package/dist/components/media/map/map-style-input.js +1 -0
- package/dist/components/media/map/map-style-lifecycle.js +1 -0
- package/dist/components/media/map/map-style-override-admission.d.ts +10 -0
- package/dist/components/media/map/map-style-override-admission.js +1 -0
- package/dist/components/media/map/map-style-overrides.js +1 -0
- package/dist/components/media/map/map-style-value.d.ts +3 -0
- package/dist/components/media/map/map-style-value.js +1 -0
- package/dist/components/media/map/map-vector-style.d.ts +10 -0
- package/dist/components/media/map/map-vector-style.js +1 -0
- package/dist/components/media/map/map.class.d.ts +558 -51
- package/dist/components/media/map/map.class.js +58 -11
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/qr-code/qr-code.class.d.ts +1 -3
- package/dist/components/media/qr-code/qr-code.class.js +1 -1
- package/dist/components/media/qr-code/qr-code.styles.js +1 -1
- package/dist/components/media/video/video.class.d.ts +25 -4
- package/dist/components/media/video/video.class.js +11 -3
- package/dist/components/media/video/video.styles.js +1 -1
- package/dist/components/media/video-playlist/video-playlist.class.d.ts +0 -1
- package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
- package/dist/components/overlays/chip/chip-group.class.d.ts +1 -1
- package/dist/components/overlays/chip/chip-group.class.js +1 -1
- package/dist/components/overlays/dialog/confirm.js +1 -1
- package/dist/components/overlays/overlay/popover.class.d.ts +1 -1
- package/dist/components/overlays/overlay/popover.class.js +2 -1
- package/dist/components/overlays/overlay/tooltip.class.js +1 -1
- package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.d.ts +4 -7
- package/dist/components/retrieval/chunk-inspector/chunk-inspector.class.js +2 -2
- package/dist/components/retrieval/claim-evidence/claim-evidence.class.d.ts +2 -2
- package/dist/components/retrieval/community-card/community-card.class.d.ts +1 -4
- package/dist/components/retrieval/community-card/community-card.class.js +1 -1
- package/dist/components/retrieval/embedding-explorer/embedding-explorer-data.d.ts +12 -0
- package/dist/components/retrieval/embedding-explorer/embedding-explorer-data.js +1 -0
- package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -0
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.d.ts +26 -7
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.class.js +35 -4
- package/dist/components/retrieval/embedding-explorer/embedding-explorer.styles.js +1 -1
- package/dist/components/retrieval/entity-dossier/entity-dossier.class.d.ts +3 -9
- package/dist/components/retrieval/graph/graph-builtin-3d-engine.js +1 -0
- package/dist/components/retrieval/graph/graph-engine-adapter.js +1 -0
- package/dist/components/retrieval/graph/graph-engine-columns.js +1 -0
- package/dist/components/retrieval/graph/graph-model.js +1 -1
- package/dist/components/retrieval/graph/graph-spatial-controller.js +13 -8
- package/dist/components/retrieval/graph/graph-webgl-engine.js +1 -0
- package/dist/components/retrieval/graph/graph.class.d.ts +18 -5
- package/dist/components/retrieval/graph/graph.class.js +4 -4
- package/dist/components/retrieval/graph/graph.styles.js +1 -1
- package/dist/components/retrieval/grounding-summary/grounding-summary.class.d.ts +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +2 -2
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.d.ts +6 -3
- package/dist/components/retrieval/knowledge-graph-explorer/knowledge-graph-explorer.class.js +3 -3
- package/dist/components/retrieval/memory-panel/memory-panel.class.d.ts +3 -10
- package/dist/components/retrieval/memory-panel/memory-panel.class.js +1 -1
- package/dist/components/retrieval/node-palette/node-palette.class.d.ts +1 -1
- package/dist/components/retrieval/path-strip/path-strip.class.d.ts +1 -4
- package/dist/components/retrieval/path-strip/path-strip.class.js +1 -1
- package/dist/components/retrieval/provenance-panel/provenance-panel.class.d.ts +2 -8
- package/dist/components/retrieval/rag-answer/rag-answer.class.d.ts +2 -2
- package/dist/components/retrieval/rag-answer/rag-answer.class.js +2 -3
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.d.ts +1 -11
- package/dist/components/retrieval/rag-eval-dashboard/rag-eval-dashboard.class.js +1 -1
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.d.ts +8 -12
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +5 -6
- package/dist/components/retrieval/retrieval-search/retrieval-search.class.d.ts +1 -1
- package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.d.ts +4 -7
- package/dist/components/retrieval/retrieval-trace/retrieval-trace.class.js +2 -3
- package/dist/components/retrieval/source-card/source-card.class.d.ts +6 -9
- package/dist/components/retrieval/source-card/source-card.class.js +1 -1
- package/dist/components/retrieval/source-picker/source-picker.class.d.ts +1 -4
- package/dist/components/retrieval/source-picker/source-picker.class.js +1 -1
- package/dist/components/utility/diff-view/diff-view.class.js +1 -1
- package/dist/components/utility/format/format-options.js +1 -1
- package/dist/components/utility/icon/icon.class.d.ts +0 -5
- package/dist/components/utility/icon/icon.class.js +2 -2
- package/dist/components/utility/icon/icon.styles.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.class.js +1 -1
- package/dist/components/utility/known-date/known-date.class.d.ts +0 -3
- package/dist/components/utility/known-date/known-date.class.js +1 -1
- package/dist/components/utility/mention-popover/mention-popover.class.d.ts +3 -2
- package/dist/components/utility/mention-popover/mention-popover.class.js +1 -1
- package/dist/components/viewers/archive-viewer/archive-viewer.class.js +1 -1
- package/dist/components/viewers/calendar-viewer/calendar-viewer.class.js +1 -1
- package/dist/components/viewers/contact-viewer/contact-viewer.class.js +1 -1
- package/dist/components/viewers/document-preview/document-preview.class.js +1 -1
- package/dist/components/viewers/document-viewer/document-viewer-kinds.d.ts +1 -1
- package/dist/components/viewers/document-viewer/document-viewer-kinds.js +1 -1
- package/dist/components/viewers/document-viewer/document-viewer.class.js +1 -1
- package/dist/components/viewers/document-viewer/registry.d.ts +1 -69
- package/dist/components/viewers/document-viewer/registry.js +1 -1
- package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
- package/dist/components/viewers/email-viewer/email-viewer.class.js +1 -1
- package/dist/components/viewers/html-viewer/html-viewer.class.js +1 -1
- package/dist/components/viewers/include/include.class.js +1 -1
- package/dist/components/viewers/index.d.ts +1 -1
- package/dist/components/viewers/index.js +1 -1
- package/dist/components/viewers/model-viewer/model-viewer-document.js +1 -0
- package/dist/components/viewers/model-viewer/model-viewer-loader.js +1 -0
- package/dist/components/viewers/model-viewer/model-viewer-register.d.ts +1 -0
- package/dist/components/viewers/model-viewer/model-viewer-register.js +1 -0
- package/dist/components/viewers/model-viewer/model-viewer-source.d.ts +1 -0
- package/dist/components/viewers/model-viewer/model-viewer-source.js +1 -0
- package/dist/components/viewers/model-viewer/model-viewer.class.d.ts +61 -0
- package/dist/components/viewers/model-viewer/model-viewer.class.js +9 -0
- package/dist/components/viewers/model-viewer/model-viewer.d.ts +1 -0
- package/dist/components/viewers/model-viewer/model-viewer.js +1 -0
- package/dist/components/viewers/model-viewer/model-viewer.styles.js +1 -0
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +2 -2
- package/dist/components/viewers/page-rail/page-rail.class.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +1 -1
- package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +3 -3
- package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
- package/dist/components/viewers/table-viewer-shared.js +1 -1
- package/dist/components/viewers/xml-viewer/xml-viewer.class.js +1 -1
- package/dist/custom-elements-jsx.d.ts +1 -1
- package/dist/events.d.ts +137 -92
- package/dist/framework-types.d.ts +2 -2
- package/dist/hydration.d.ts +1 -1
- package/dist/internal/ansi.d.ts +3 -1
- package/dist/internal/ansi.js +1 -1
- package/dist/internal/autoloader-manifest.js +1 -1
- package/dist/internal/autoloader-tags.d.ts +1 -1
- package/dist/internal/autoloader-tags.js +1 -1
- package/dist/internal/av-metadata.d.ts +13 -0
- package/dist/internal/av-metadata.js +1 -0
- package/dist/internal/collection-snapshot.js +1 -1
- package/dist/internal/component-loaders.generated.js +1 -1
- package/dist/internal/data-descriptors.d.ts +30 -0
- 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/media.generated.js +1 -1
- package/dist/internal/default-strings/shared.generated.js +1 -1
- package/dist/internal/default-strings/viewers.generated.js +1 -1
- package/dist/internal/document-renderer-registry.d.ts +75 -0
- package/dist/internal/document-renderer-registry.js +1 -0
- package/dist/internal/drop-session-controller.js +1 -1
- package/dist/internal/engine-3d-loader.d.ts +47 -0
- package/dist/internal/engine-3d-loader.js +1 -0
- package/dist/internal/engine-3d.d.ts +57 -0
- package/dist/internal/engine-3d.js +1 -0
- package/dist/internal/hierarchy-source-controller.js +1 -1
- package/dist/internal/localization-runtime.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/lyra-element.d.ts +2 -2
- package/dist/internal/lyra-element.js +1 -1
- package/dist/internal/model-viewer-contract.d.ts +5 -0
- package/dist/internal/model-viewer-contract.js +1 -0
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/positioner.js +1 -1
- package/dist/internal/rendered-state.js +1 -1
- package/dist/internal/root-registration-allowlist.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/typed-columns.d.ts +39 -0
- package/dist/internal/typed-columns.js +1 -0
- package/dist/localization.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/lyra.js +1 -1
- package/dist/ssr/all.d.ts +1 -1
- package/dist/ssr/all.js +1 -1
- package/dist/ssr.d.ts +4 -4
- package/dist/ssr.js +1 -1
- package/dist/svelte.d.ts +1 -1
- package/dist/testing/lyra-tag-event-map.d.ts +2 -2
- package/dist/testing/lyra-tag-event-map.js +1 -1
- package/dist/theme/theme-bootstrap.js +1 -1
- package/dist/theme/theme.js +1 -1
- package/dist/vue.d.ts +1 -1
- package/llms/components/lr-accordion-item.md +2 -2
- package/llms/components/lr-agent-eval-dashboard.md +3 -3
- package/llms/components/lr-agent-run.md +3 -3
- package/llms/components/lr-agent-trace.md +1 -1
- package/llms/components/lr-agent-workspace.md +1 -1
- package/llms/components/lr-app-rail-item.md +1 -1
- package/llms/components/lr-app-rail.md +5 -6
- package/llms/components/lr-background-runs.md +4 -4
- package/llms/components/lr-calendar.md +1 -1
- package/llms/components/lr-change-review.md +5 -5
- package/llms/components/lr-chart-3d.md +164 -0
- package/llms/components/lr-chunk-inspector.md +4 -5
- package/llms/components/lr-citation-badge.md +1 -1
- package/llms/components/lr-code-block-core.md +2 -4
- package/llms/components/lr-command-palette.md +3 -3
- package/llms/components/lr-community-card.md +2 -2
- package/llms/components/lr-date-picker.md +1 -1
- package/llms/components/lr-details.md +2 -2
- package/llms/components/lr-diff-view.md +2 -2
- package/llms/components/lr-dock-panel.md +5 -10
- package/llms/components/lr-document-viewer.md +21 -14
- package/llms/components/lr-embedding-explorer.md +24 -4
- package/llms/components/lr-entity-dossier.md +3 -4
- package/llms/components/lr-eval-dataset.md +3 -3
- package/llms/components/lr-eval-run.md +7 -1
- package/llms/components/lr-file-input.md +10 -11
- package/llms/components/lr-flow-node.md +2 -3
- package/llms/components/lr-geojson-viewer.md +1 -1
- package/llms/components/lr-graph.md +21 -2
- package/llms/components/lr-grounding-summary.md +1 -1
- package/llms/components/lr-icon.md +1 -3
- package/llms/components/lr-image-viewer.md +29 -2
- package/llms/components/lr-ingestion-queue.md +1 -1
- package/llms/components/lr-knowledge-base-admin.md +2 -2
- package/llms/components/lr-knowledge-graph-explorer.md +7 -1
- package/llms/components/lr-known-date.md +3 -10
- package/llms/components/lr-lite-chart.md +1 -1
- package/llms/components/lr-map.md +861 -49
- package/llms/components/lr-markdown-core.md +1 -2
- package/llms/components/lr-memory-panel.md +4 -8
- package/llms/components/lr-model-viewer.md +170 -0
- package/llms/components/lr-navigation-menu.md +3 -4
- package/llms/components/lr-node-palette.md +1 -1
- package/llms/components/lr-path-strip.md +2 -3
- package/llms/components/lr-provenance-panel.md +3 -5
- package/llms/components/lr-qr-code.md +3 -4
- package/llms/components/lr-rag-answer.md +1 -1
- package/llms/components/lr-rag-eval-dashboard.md +2 -5
- package/llms/components/lr-retrieval-results.md +6 -7
- package/llms/components/lr-retrieval-trace.md +3 -4
- package/llms/components/lr-signature-pad.md +4 -3
- package/llms/components/lr-source-card.md +1 -1
- package/llms/components/lr-source-list.md +5 -5
- package/llms/components/lr-source-picker.md +2 -3
- package/llms/components/lr-span-waterfall.md +4 -3
- package/llms/components/lr-sparkline.md +3 -3
- package/llms/components/lr-subagent-panel.md +3 -3
- package/llms/components/lr-tool-call-chip.md +6 -6
- package/llms/components/lr-tool-timeline.md +1 -1
- package/llms/components/lr-video-playlist.md +3 -3
- package/llms/components/lr-video.md +29 -2
- package/llms/components/lr-virtual-list.md +3 -2
- package/llms/components/lr-widget.md +6 -13
- package/llms/index.md +98 -95
- package/llms/migration.md +27 -38
- package/llms/peers.md +7 -6
- package/llms/shared/ai-and-peers.md +1 -1
- package/llms/shared/events-and-types.md +8 -0
- package/llms/shared/imports-and-registration.md +2 -2
- package/llms/shared/v29-to-v30-migration.md +256 -0
- package/llms/shared.md +11 -3
- package/llms.txt +4 -4
- package/locales.json +1 -2328
- package/package.json +41 -13
- package/registrations.json +1 -1
- package/skills/lyra-ui/SKILL.md +4 -3
- /package/dist/{components/viewers/document-viewer → internal}/deferred-teardown.js +0 -0
- /package/dist/{components/viewers/document-viewer/registry-ownership.js → internal/document-renderer-registry-ownership.js} +0 -0
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{literalSetConverter}from"../../../internal/converters.js";import{resolveCssLength}from"../../../internal/css-length.js";import{setCustomState}from"../../../internal/custom-states.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{isComposedFocusAvailable}from"../../../internal/focus-navigation.js";import{menuIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{finiteDuration,finiteRange}from"../../../internal/numbers.js";import{collectFocusableElements}from"../../../internal/overlay-stack.js";import{tag}from"../../../internal/prefix.js";import{bindNavigationMenuItem,navigationMenuItemController,releaseNavigationMenuItem}from"./navigation-menu-owner.js";import{styles}from"./navigation-menu.styles.js";import{LYRA_DEFAULT_menuLabel,LYRA_DEFAULT_navigation}from"../../../internal/default-strings/shared.generated.js";const PANEL_ANCHOR=literalSetConverter(["menu","item"],"menu"),DEFAULT_SHOW_DELAY=200,DEFAULT_HIDE_DELAY=150,DEFAULT_SKIP_DELAY=300,DEFAULT_DISTANCE=6,PANEL_KEY_ORIGIN='a[href], button, [role="link"], [role="button"]',IGNORED_CHILDREN=new Set(["template","script","style"]);function isElementNode(value){return typeof value=="object"&&value!==null&&value.nodeType===1}function isAnchorWithHref(value){return isElementNode(value)&&value.localName==="a"&&value.hasAttribute("href")}class LyraNavigationMenu extends LyraElement{constructor(){super(...arguments),this._expanded=!1,this.expansionWriteGuard=new VetoWriteGuard,this.expansionNotificationSequence=0,this.indicator=!1,this._panelAnchor="menu",this.showDelay=DEFAULT_SHOW_DELAY,this.hideDelay=DEFAULT_HIDE_DELAY,this.skipDelay=DEFAULT_SKIP_DELAY,this.distance=DEFAULT_DISTANCE,this.topLayer=!1,this.collapsedLayout=!1,this.listId=nextId("navigation-menu-list"),this.menuInternals=attachInternalsSafely(this),this.ownedRoles=new WeakSet,this.context={owner:this,layout:()=>this.layout,anchor:item=>this._panelAnchor==="item"?this.controllerFor(item)?.base()??null:this.listElement,distance:()=>finiteRange(this.distance,DEFAULT_DISTANCE,0),topLayer:()=>this.topLayer,activate:item=>this.activateItem(item),willOpen:item=>this.itemWillOpen(item),changed:(item,open,source)=>this.itemChanged(item,open,source),escape:item=>this.itemEscape(item)},this.items=[],this.lastCloseAt=Number.NEGATIVE_INFINITY,this.pressActive=!1,this.observedIndicatorTargets=new Set,this.indicatorQueued=!1,this.onSlotChange=()=>{this.updateBrowserDerivedState(()=>this.bindItems())},this.onPointerOver=event=>{if(event.pointerType!=="mouse"||this.layout!=="bar")return;const target=event.composedPath()[0],item=this.itemContaining(target),controller=this.controllerFor(item);if(!item||!controller||!isElementNode(target))return;if(this.openItem===item){this.hideTimer?.item===item&&this.cancelHide();return}const base=controller.base();!base||!composedContains(base,target)||(controller.isTrigger()?this.hoverTrigger(item):this.hoverNonTrigger())},this.onPointerOut=event=>{if(event.pointerType!=="mouse"||this.layout!=="bar")return;const item=this.itemContaining(event.composedPath()[0]);if(!item)return;const next=event.relatedTarget;isElementNode(next)&&composedContains(item,next)||(this.showTimer?.item===item&&this.cancelShow(),this.requestHoverClose(item))},this.onDocumentPointerDown=event=>{const open=this.openItem,controller=this.controllerFor(open);if(!open||!controller||this.layout!=="bar"||!controller.isTopmost())return;const path=event.composedPath();if(!path.includes(open)){for(const item of this.items){if(item===open)continue;const other=this.controllerFor(item),base=other?.base();if(other?.isTrigger()&&base&&path.includes(base))return}this.cancelShow(),this.cancelHide(),controller.close("user",{repairFocus:!1})}},this.onPointerDownCapture=event=>{if(event.button!==0||!event.isPrimary)return;this.clearPressTimer(),this.pressActive=!0,this.pressOpenItem=this.openItem;const doc=this.ownerDocument;this.pressDocument!==doc&&(this.stopPressListeners(),doc.addEventListener("pointerup",this.onPressEnd,!0),doc.addEventListener("pointercancel",this.onPressEnd,!0),this.pressDocument=doc)},this.onPressEnd=()=>{this.stopPressListeners(),this.clearPressTimer();const view=this.ownerDocument.defaultView;if(!view){this.clearPress();return}const id=view.setTimeout(()=>{this.pressTimer?.id===id&&(this.pressTimer=void 0,this.reevaluatePress())},0);this.pressTimer={id,view}},this.onFocusOut=event=>{const open=this.openItem;if(!open||this.layout!=="bar")return;const target=event.composedPath()[0];if(!isElementNode(target)||!composedContains(open,target))return;const next=event.relatedTarget;!isElementNode(next)||composedContains(open,next)||this.pressActive||(this.cancelShow(),this.cancelHide(),this.controllerFor(open)?.close("user",{repairFocus:!1}))},this.onClickCapture=event=>{if(event.button!==0||event.ctrlKey||event.metaKey||event.shiftKey||event.altKey)return;const path=event.composedPath();if(!this.items.some(item=>{const controller=this.controllerFor(item);if(!controller)return!1;const base=controller.base();if(controller.isLink()&&base&&path.includes(base))return!0;const panel=controller.panel();if(!panel)return!1;const panelIndex=path.indexOf(panel);return panelIndex===-1?!1:path.slice(0,panelIndex).some(isAnchorWithHref)}))return;this.cancelShow(),this.cancelHide();const listHides=this.layout==="stacked"&&this._expanded;this.closeOpenItem("user",listHides?{focusTarget:this.toggleElement}:{}),listHides&&this.setExpanded(!1,"user")},this.onKeyDown=event=>{if(event.defaultPrevented||event.isComposing||event.altKey||event.ctrlKey||event.metaKey)return;if(this.layout==="stacked"){event.key==="Escape"&&this.handleStackedEscape(event);return}const origin=event.composedPath()[0];if(!isElementNode(origin))return;const topLevel=this.items.find(item=>this.controllerFor(item)?.base()===origin);if(topLevel){this.handleBaseKey(event,topLevel);return}const panel=this.controllerFor(this.openItem)?.panel();panel&&composedContains(panel,origin)&&this.handlePanelKey(event,panel,origin)},this.requestingExpansion=!1,this.onToggleClick=()=>{this.setExpanded(!this._expanded,"user")}}static{this.defaultStrings={...super.defaultStrings,menuLabel:LYRA_DEFAULT_menuLabel,navigation:LYRA_DEFAULT_navigation}}static{this.styles=[LyraElement.styles,styles]}get expanded(){return this._expanded}set expanded(next){markVetoGuardWrite(this.expansionWriteGuard),this.setExpanded(!!next,this.hasUpdated?"programmatic":null)}get panelAnchor(){return this._panelAnchor}set panelAnchor(next){const normalized=PANEL_ANCHOR.normalizeReflected(this,"panel-anchor",next);if(normalized===this._panelAnchor)return;const old=this._panelAnchor;this._panelAnchor=normalized,this.requestUpdate("panelAnchor",old)}get collapsed(){return this.collapsedLayout}get layout(){return this.collapsedLayout?"stacked":"bar"}get listElement(){return this.renderRoot?.querySelector('[part~="list"]')??null}get toggleElement(){return this.renderRoot?.querySelector('[part~="toggle"]')??null}controllerFor(item){return item?navigationMenuItemController(item):void 0}connectedCallback(){super.connectedCallback(),this.addEventListener("pointerover",this.onPointerOver),this.addEventListener("pointerout",this.onPointerOut),this.addEventListener("pointerdown",this.onPointerDownCapture,!0),this.addEventListener("click",this.onClickCapture,!0),this.addEventListener("keydown",this.onKeyDown),this.addEventListener("focusout",this.onFocusOut),this.observeAllocation(),this.hasUpdated&&this.updateBrowserDerivedState(()=>this.bindItems())}disconnectedCallback(){this.removeEventListener("pointerover",this.onPointerOver),this.removeEventListener("pointerout",this.onPointerOut),this.removeEventListener("pointerdown",this.onPointerDownCapture,!0),this.removeEventListener("click",this.onClickCapture,!0),this.removeEventListener("keydown",this.onKeyDown),this.removeEventListener("focusout",this.onFocusOut),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.cancelAllocationFrame(),this.observedIndicatorTargets.clear(),this.stopLightDismiss(),this.cancelShow(),this.cancelHide(),this.clearPress();for(const item of this.items)this.releaseItem(item);this.items=[],super.disconnectedCallback()}close(){this.cancelShow(),this.cancelHide();const listHides=this.collapsedLayout&&this._expanded;this.closeOpenItem("programmatic",listHides?{focusTarget:this.toggleElement}:{}),this.setExpanded(!1,"programmatic")}show(){this.setExpanded(!0,"programmatic")}hide(){this.close()}firstUpdated(changed){super.firstUpdated(changed),queueMicrotask(()=>{this.isConnected&&this.updateBrowserDerivedState(()=>this.bindItems())})}willUpdate(changed){super.willUpdate(changed),changed.has("mobileBreakpoint")&&this.hasUpdated&&this.applyAllocation(this.measureContentInlineSize())}updated(changed){super.updated(changed);const pending=this.pendingFocus;this.pendingFocus=void 0,pending==="toggle"?this.toggleElement?.focus({preventScroll:!0}):pending==="first-base"&&this.firstNavigableBase()?.focus({preventScroll:!0});const direction=this.effectiveDirection,directionChanged=this.lastDirection!==void 0&&direction!==this.lastDirection;this.lastDirection=direction,(changed.has("distance")||changed.has("topLayer")||changed.has("panelAnchor")||directionChanged)&&this.controllerFor(this.openItem)?.reposition(),(changed.has("indicator")||changed.has("panelAnchor")||changed.has("collapsedLayout")||directionChanged)&&(this.observeIndicatorTargets(),this.queueIndicatorMeasure())}bindItems(){if(!this.isConnected)return;const slot=this.renderRoot?.querySelector('[part~="list"] > slot'),assigned=slot?slot.assignedElements():[...this.children].filter(child=>!child.hasAttribute("slot")),itemTag=tag("navigation-menu-item"),next=[];for(const child of assigned)child.localName===itemTag?next.push(child):IGNORED_CHILDREN.has(child.localName)||devWarnOnce("lr-navigation-menu:non-item-child",`<${tag("navigation-menu")}> received <${child.localName}> in its default slot, which renders inside its list without a list item role. Only <${itemTag}> children belong there; place header chrome such as a logo, search or actions outside the menu.`);const kept=new Set(next);for(const previous of this.items)kept.has(previous)||this.releaseItem(previous);for(const item of next)bindNavigationMenuItem(item,this.context),item.hasAttribute("role")||(item.setAttribute("role","listitem"),this.ownedRoles.add(item));this.items=next,this.openItem&&(!kept.has(this.openItem)||!this.controllerFor(this.openItem)?.isOpen())&&(this.openItem=void 0);for(const item of next){const controller=this.controllerFor(item);controller?.isOpen()&&(this.openItem?this.openItem!==item&&controller.close(null,{repairFocus:!1,instant:!0}):this.openItem=item)}this.openItem&&this.layout==="bar"?this.startLightDismiss():this.stopLightDismiss(),this.observeIndicatorTargets(),this.queueIndicatorMeasure()}releaseItem(item){releaseNavigationMenuItem(item,this),this.ownedRoles.has(item)&&(item.getAttribute("role")==="listitem"&&item.removeAttribute("role"),this.ownedRoles.delete(item)),this.showTimer?.item===item&&this.cancelShow(),this.hideTimer?.item===item&&this.cancelHide(),this.openItem===item&&(this.openItem=void 0,this.stopLightDismiss())}now(){return this.ownerDocument.defaultView?.performance.now()??Date.now()}isNavigable(item){if(item.hidden||item.inert||item.closest("[inert]")!==null||item.getAttribute("aria-hidden")==="true")return!1;const base=this.controllerFor(item)?.base();return base!=null&&isComposedFocusAvailable(base)}firstNavigableBase(){const item=this.items.find(candidate=>this.isNavigable(candidate));return this.controllerFor(item)?.base()??null}itemContaining(target){if(isElementNode(target))return this.items.find(item=>composedContains(item,target))}focusWithinPanel(item){const active=deepActiveElement(this.ownerDocument);if(!active||!composedContains(item,active))return!1;const base=this.controllerFor(item)?.base();return!(base&&composedContains(base,active))}closeOpenItem(source,options={}){this.controllerFor(this.openItem)?.close(source,options)}activateItem(item){const controller=this.controllerFor(item);if(controller){if(this.cancelShow(),this.cancelHide(),controller.isTrigger()){controller.isOpen()?this.layout==="bar"&&controller.mode()==="hover"?controller.pin():controller.close("user"):controller.open("pinned","user");return}this.closeOpenItem("user"),this.layout==="stacked"&&this.setExpanded(!1,"user")}}itemWillOpen(item){this.showTimer?.item!==item&&this.cancelShow();const current=this.openItem;if(!current||current===item)return;const currentController=this.controllerFor(current);let morph;if(this.layout==="bar"&&this._panelAnchor==="menu"&&!prefersReducedMotion(this)){const panel=currentController?.panel(),from=panel&&!panel.hidden?panel.getBoundingClientRect():void 0;from&&from.width>0&&from.height>0&&(morph={from,direction:this.items.indexOf(item)>this.items.indexOf(current)?"end":"start"})}return currentController?.close("peer",{instant:!0,focusTarget:this.controllerFor(item)?.base()??null}),morph}itemChanged(item,open,source){open?(this.openItem=item,this.hideTimer?.item===item&&this.cancelHide(),this.layout==="bar"&&this.startLightDismiss()):this.openItem===item&&(this.openItem=void 0,this.layout==="bar"&&source!=="peer"&&(this.lastCloseAt=this.now()),this.hideTimer?.item===item&&this.cancelHide(),this.stopLightDismiss()),this.observeIndicatorTargets(),this.queueIndicatorMeasure()}itemEscape(item){this.cancelShow(),this.cancelHide();const within=composedContains(item,deepActiveElement(this.ownerDocument));this.controllerFor(item)?.close("user",{repairFocus:!1,restoreFocus:within})}hoverTrigger(item){this.cancelHide();const open=this.openItem;if(open&&open!==item){if(this.focusWithinPanel(open))return;this.cancelShow(),this.controllerFor(item)?.open("hover","user");return}if(this.showTimer?.item===item)return;const skip=finiteDuration(this.skipDelay,DEFAULT_SKIP_DELAY);if(skip>0&&this.now()-this.lastCloseAt<=skip){this.cancelShow(),this.controllerFor(item)?.open("hover","user");return}this.scheduleShow(item)}hoverNonTrigger(){this.cancelShow();const open=this.openItem;open&&this.requestHoverClose(open)}requestHoverClose(item){this.openItem===item&&(this.controllerFor(item)?.mode()!=="hover"||this.focusWithinPanel(item)||this.scheduleHide(item))}scheduleShow(item){this.cancelShow();const delay=finiteDuration(this.showDelay,DEFAULT_SHOW_DELAY),view=this.ownerDocument.defaultView,commit=()=>{if(this.layout!=="bar"||!this.items.includes(item))return;const open=this.openItem;open&&open!==item&&this.focusWithinPanel(open)||this.controllerFor(item)?.open("hover","user")};if(!view||delay<=0){commit();return}const id=view.setTimeout(()=>{this.showTimer?.id===id&&(this.showTimer=void 0,commit())},delay);this.showTimer={item,id,view}}scheduleHide(item){this.cancelHide();const delay=finiteDuration(this.hideDelay,DEFAULT_HIDE_DELAY),view=this.ownerDocument.defaultView,commit=()=>{if(this.openItem!==item)return;const controller=this.controllerFor(item);controller?.mode()!=="hover"||this.focusWithinPanel(item)||controller.close("user")};if(!view||delay<=0){commit();return}const id=view.setTimeout(()=>{this.hideTimer?.id===id&&(this.hideTimer=void 0,commit())},delay);this.hideTimer={item,id,view}}cancelShow(){const timer=this.showTimer;this.showTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}cancelHide(){const timer=this.hideTimer;this.hideTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}startLightDismiss(){const doc=this.ownerDocument;!this.isConnected||this.lightDismissDocument===doc||(this.stopLightDismiss(),doc.addEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=doc)}stopLightDismiss(){this.lightDismissDocument?.removeEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=void 0}reevaluatePress(){const pressed=this.pressOpenItem;if(this.pressActive=!1,this.pressOpenItem=void 0,!pressed||pressed!==this.openItem||this.layout!=="bar")return;const controller=this.controllerFor(pressed);if(!controller?.isOpen())return;const doc=this.ownerDocument,active=deepActiveElement(doc);!active||active===doc.body||active===doc.documentElement||composedContains(pressed,active)||controller.close("user",{repairFocus:!1})}stopPressListeners(){this.pressDocument?.removeEventListener("pointerup",this.onPressEnd,!0),this.pressDocument?.removeEventListener("pointercancel",this.onPressEnd,!0),this.pressDocument=void 0}clearPressTimer(){const timer=this.pressTimer;this.pressTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}clearPress(){this.stopPressListeners(),this.clearPressTimer(),this.pressActive=!1,this.pressOpenItem=void 0}handleBaseKey(event,item){const rtl=this.effectiveDirection==="rtl";switch(event.key){case"ArrowRight":case"ArrowLeft":{event.preventDefault();const forward=event.key==="ArrowRight"!==rtl;this.focusSibling(item,forward?1:-1);return}case"Home":case"End":{event.preventDefault();const navigable=this.items.filter(candidate=>this.isNavigable(candidate)),target=event.key==="Home"?navigable[0]:navigable.at(-1);this.controllerFor(target)?.base()?.focus();return}case"ArrowDown":{const controller=this.controllerFor(item);if(!controller?.isTrigger()||!controller.isOpen())return;event.preventDefault(),this.enterPanel(controller);return}}}focusSibling(item,step){const navigable=this.items.filter(candidate=>this.isNavigable(candidate)),index=navigable.indexOf(item);index!==-1&&this.controllerFor(navigable[index+step])?.base()?.focus()}async enterPanel(controller){if(await controller.placementReady(),!controller.isOpen())return;const panel=controller.panel();panel&&collectFocusableElements(panel)[0]?.focus()}handlePanelKey(event,panel,origin){if(!["ArrowDown","ArrowUp","Home","End"].includes(event.key)||!origin.matches(PANEL_KEY_ORIGIN))return;event.preventDefault();const focusable=collectFocusableElements(panel),index=focusable.findIndex(candidate=>candidate===origin);let target;event.key==="Home"?target=focusable[0]:event.key==="End"?target=focusable.at(-1):event.key==="ArrowDown"?target=focusable[index+1]:index>0&&(target=focusable[index-1]),target?.focus()}handleStackedEscape(event){const open=this.openItem,active=deepActiveElement(this.ownerDocument);if(open&&active&&composedContains(open,active)){event.preventDefault();const controller=this.controllerFor(open),base=controller?.base();controller?.close("user"),base?.focus();return}this._expanded&&(event.preventDefault(),this.setExpanded(!1,"user"),this.toggleElement?.focus())}setExpanded(next,source){if(next===this._expanded)return;if(source==="user"){if(this.requestingExpansion)return;const previous=this._expanded;this.requestingExpansion=!0;try{let accepted=!1;if(requestThenCommit({requestDetail:{expanded:next,source},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.expansionWriteGuard,commit:()=>{accepted=this._expanded===previous}}),!accepted)return}finally{this.requestingExpansion=!1}}if(!next&&this.collapsedLayout){const list=this.listElement,active=deepActiveElement(this.ownerDocument);list&&active&&composedContains(list,active)&&this.toggleElement?.focus({preventScroll:!0}),this.closeOpenItem(source,{repairFocus:!1})}const old=this._expanded;this._expanded=next;const notificationSequence=++this.expansionNotificationSequence;this.requestUpdate("expanded",old),source!==null&&this.updateComplete.then(()=>{!this.isConnected||this._expanded!==next||this.expansionNotificationSequence!==notificationSequence||(this.emit("lr-expanded-change",{expanded:next,source}),!(!this.isConnected||this._expanded!==next||this.expansionNotificationSequence!==notificationSequence)&&this.emit("lr-toggle",{expanded:next,source}))})}observeAllocation(){const ResizeObserverConstructor=this.ownerDocument.defaultView?.ResizeObserver;ResizeObserverConstructor&&(this.resizeObserver??=new ResizeObserverConstructor(entries=>this.onResize(entries)),this.resizeObserver.observe(this),this.observedIndicatorTargets.clear(),this.observeIndicatorTargets())}onResize(entries){for(const entry of entries)entry.target===this&&(this.lastInlineSize=entry.contentBoxSize?.[0]?.inlineSize??entry.contentRect.width,this.scheduleAllocation());this.queueIndicatorMeasure()}scheduleAllocation(){if(this.allocationFrame)return;const view=this.ownerDocument.defaultView;if(!view){this.applyAllocation(this.lastInlineSize);return}const id=view.requestAnimationFrame(()=>{this.allocationFrame?.id===id&&(this.allocationFrame=void 0,this.isConnected&&this.applyAllocation(this.lastInlineSize))});this.allocationFrame={id,view}}cancelAllocationFrame(){const frame=this.allocationFrame;this.allocationFrame=void 0,frame&&frame.view.cancelAnimationFrame(frame.id)}measureContentInlineSize(){const view=this.ownerDocument.defaultView;if(!view||!this.isConnected)return this.lastInlineSize;const style=view.getComputedStyle(this),edges=["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"];let width=this.getBoundingClientRect().width;for(const edge of edges)width-=Number.parseFloat(style[edge])||0;return Math.max(0,width)}applyAllocation(width){if(width===void 0||!Number.isFinite(width))return;const breakpoint=resolveCssLength(this.mobileBreakpoint,{host:this}),next=breakpoint!==void 0&&Number.isFinite(breakpoint)&&width<=breakpoint;this.updateBrowserDerivedState(()=>this.setCollapsed(next))}setCollapsed(next){if(next===this.collapsedLayout)return;this.cancelShow(),this.cancelHide();const active=deepActiveElement(this.ownerDocument),open=this.openItem;if(next){const list=this.listElement,listHides=!this._expanded,focusInList=!!(active&&list&&composedContains(list,active));this.controllerFor(open)?.close("programmatic",{instant:!0,repairFocus:!listHides}),listHides&&focusInList&&(this.pendingFocus="toggle"),this.stopLightDismiss()}else{const toggle=this.toggleElement,onToggle=!!(active&&toggle&&composedContains(toggle,active));this.controllerFor(open)?.close("programmatic",{instant:!0}),onToggle&&(this.pendingFocus="first-base")}this.collapsedLayout=next,setCustomState(this.menuInternals,"collapsed",next);for(const item of this.items)item.requestUpdate?.();!next&&this._expanded&&this.setExpanded(!1,"programmatic")}observeIndicatorTargets(){const observer=this.resizeObserver;if(!observer)return;const wanted=new Set;if(this.indicator){const list=this.listElement;list&&wanted.add(list);for(const item of this.items)wanted.add(item)}for(const target of this.observedIndicatorTargets)wanted.has(target)||observer.unobserve(target);for(const target of wanted)this.observedIndicatorTargets.has(target)||observer.observe(target);this.observedIndicatorTargets=wanted}queueIndicatorMeasure(){this.indicatorQueued||!this.indicator||(this.indicatorQueued=!0,queueMicrotask(()=>{const open=this.openItem;Promise.all([this.updateComplete,open?.updateComplete]).then(()=>{this.indicatorQueued=!1,this.measureIndicator()})}))}measureIndicator(){if(!this.indicator||this.collapsedLayout||!this.isConnected)return;const nav=this.renderRoot.querySelector('[part~="base"]'),base=this.controllerFor(this.openItem)?.base(),previous=this.indicatorBox;if(!nav||!base){previous?.visible&&(this.indicatorBox={...previous,visible:!1});return}const navRect=nav.getBoundingClientRect(),trigger=base.getBoundingClientRect(),list=this.listElement,rtl=this.effectiveDirection==="rtl",bottom=this._panelAnchor==="menu"&&list?list.getBoundingClientRect().bottom:trigger.bottom,next={start:rtl?navRect.right-trigger.right:trigger.left-navRect.left,size:trigger.width,top:bottom-navRect.top,visible:!0};previous&&previous.visible===next.visible&&Math.abs(previous.start-next.start)<.5&&Math.abs(previous.size-next.size)<.5&&Math.abs(previous.top-next.top)<.5||(this.indicatorBox=next)}render(){const label=hostAriaLabel(this)??this.label??this.localize("navigation"),collapsed=this.collapsedLayout,box=this.indicatorBox;return html`<nav part="base" aria-label=${label}>
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{styleMap}from"lit/directives/style-map.js";import{hostAriaLabel,nextId}from"../../../internal/a11y.js";import{literalSetConverter}from"../../../internal/converters.js";import{resolveCssLength}from"../../../internal/css-length.js";import{setCustomState}from"../../../internal/custom-states.js";import{devWarnOnce}from"../../../internal/dev-mode-attribute-warning.js";import{attachInternalsSafely}from"../../../internal/element-internals.js";import{isComposedFocusAvailable}from"../../../internal/focus-navigation.js";import{menuIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{requestThenCommit}from"../../../internal/request-commit.js";import{markVetoGuardWrite,VetoWriteGuard}from"../../../internal/veto-write-guard.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{composedContains,deepActiveElement}from"../../../internal/nonmodal-overlay-manager.js";import{finiteDuration,finiteRange}from"../../../internal/numbers.js";import{collectFocusableElements}from"../../../internal/overlay-stack.js";import{tag}from"../../../internal/prefix.js";import{bindNavigationMenuItem,navigationMenuItemController,releaseNavigationMenuItem}from"./navigation-menu-owner.js";import{styles}from"./navigation-menu.styles.js";import{LYRA_DEFAULT_menuLabel,LYRA_DEFAULT_navigation}from"../../../internal/default-strings/shared.generated.js";const PANEL_ANCHOR=literalSetConverter(["menu","item"],"menu"),DEFAULT_SHOW_DELAY=200,DEFAULT_HIDE_DELAY=150,DEFAULT_SKIP_DELAY=300,DEFAULT_DISTANCE=6,PANEL_KEY_ORIGIN='a[href], button, [role="link"], [role="button"]',IGNORED_CHILDREN=new Set(["template","script","style"]);function isElementNode(value){return typeof value=="object"&&value!==null&&value.nodeType===1}function isAnchorWithHref(value){return isElementNode(value)&&value.localName==="a"&&value.hasAttribute("href")}class LyraNavigationMenu extends LyraElement{constructor(){super(...arguments),this._expanded=!1,this.expansionWriteGuard=new VetoWriteGuard,this.expansionNotificationSequence=0,this.indicator=!1,this._panelAnchor="menu",this.showDelay=DEFAULT_SHOW_DELAY,this.hideDelay=DEFAULT_HIDE_DELAY,this.skipDelay=DEFAULT_SKIP_DELAY,this.distance=DEFAULT_DISTANCE,this.topLayer=!1,this.collapsedLayout=!1,this.listId=nextId("navigation-menu-list"),this.menuInternals=attachInternalsSafely(this),this.ownedRoles=new WeakSet,this.context={owner:this,layout:()=>this.layout,anchor:item=>this._panelAnchor==="item"?this.controllerFor(item)?.base()??null:this.listElement,distance:()=>finiteRange(this.distance,DEFAULT_DISTANCE,0),topLayer:()=>this.topLayer,activate:item=>this.activateItem(item),willOpen:item=>this.itemWillOpen(item),changed:(item,open,source)=>this.itemChanged(item,open,source),escape:item=>this.itemEscape(item)},this.items=[],this.lastCloseAt=Number.NEGATIVE_INFINITY,this.pressActive=!1,this.observedIndicatorTargets=new Set,this.indicatorQueued=!1,this.onSlotChange=()=>{this.updateBrowserDerivedState(()=>this.bindItems())},this.onPointerOver=event=>{if(event.pointerType!=="mouse"||this.layout!=="bar")return;const target=event.composedPath()[0],item=this.itemContaining(target),controller=this.controllerFor(item);if(!item||!controller||!isElementNode(target))return;if(this.openItem===item){this.hideTimer?.item===item&&this.cancelHide();return}const base=controller.base();!base||!composedContains(base,target)||(controller.isTrigger()?this.hoverTrigger(item):this.hoverNonTrigger())},this.onPointerOut=event=>{if(event.pointerType!=="mouse"||this.layout!=="bar")return;const item=this.itemContaining(event.composedPath()[0]);if(!item)return;const next=event.relatedTarget;isElementNode(next)&&composedContains(item,next)||(this.showTimer?.item===item&&this.cancelShow(),this.requestHoverClose(item))},this.onDocumentPointerDown=event=>{const open=this.openItem,controller=this.controllerFor(open);if(!open||!controller||this.layout!=="bar"||!controller.isTopmost())return;const path=event.composedPath();if(!path.includes(open)){for(const item of this.items){if(item===open)continue;const other=this.controllerFor(item),base=other?.base();if(other?.isTrigger()&&base&&path.includes(base))return}this.cancelShow(),this.cancelHide(),controller.close("user",{repairFocus:!1})}},this.onPointerDownCapture=event=>{if(event.button!==0||!event.isPrimary)return;this.clearPressTimer(),this.pressActive=!0,this.pressOpenItem=this.openItem;const doc=this.ownerDocument;this.pressDocument!==doc&&(this.stopPressListeners(),doc.addEventListener("pointerup",this.onPressEnd,!0),doc.addEventListener("pointercancel",this.onPressEnd,!0),this.pressDocument=doc)},this.onPressEnd=()=>{this.stopPressListeners(),this.clearPressTimer();const view=this.ownerDocument.defaultView;if(!view){this.clearPress();return}const id=view.setTimeout(()=>{this.pressTimer?.id===id&&(this.pressTimer=void 0,this.reevaluatePress())},0);this.pressTimer={id,view}},this.onFocusOut=event=>{const open=this.openItem;if(!open||this.layout!=="bar")return;const target=event.composedPath()[0];if(!isElementNode(target)||!composedContains(open,target))return;const next=event.relatedTarget;!isElementNode(next)||composedContains(open,next)||this.pressActive||(this.cancelShow(),this.cancelHide(),this.controllerFor(open)?.close("user",{repairFocus:!1}))},this.onClickCapture=event=>{if(event.button!==0||event.ctrlKey||event.metaKey||event.shiftKey||event.altKey)return;const path=event.composedPath();if(!this.items.some(item=>{const controller=this.controllerFor(item);if(!controller)return!1;const base=controller.base();if(controller.isLink()&&base&&path.includes(base))return!0;const panel=controller.panel();if(!panel)return!1;const panelIndex=path.indexOf(panel);return panelIndex===-1?!1:path.slice(0,panelIndex).some(isAnchorWithHref)}))return;this.cancelShow(),this.cancelHide();const listHides=this.layout==="stacked"&&this._expanded;this.closeOpenItem("user",listHides?{focusTarget:this.toggleElement}:{}),listHides&&this.setExpanded(!1,"user")},this.onKeyDown=event=>{if(event.defaultPrevented||event.isComposing||event.altKey||event.ctrlKey||event.metaKey)return;if(this.layout==="stacked"){event.key==="Escape"&&this.handleStackedEscape(event);return}const origin=event.composedPath()[0];if(!isElementNode(origin))return;const topLevel=this.items.find(item=>this.controllerFor(item)?.base()===origin);if(topLevel){this.handleBaseKey(event,topLevel);return}const panel=this.controllerFor(this.openItem)?.panel();panel&&composedContains(panel,origin)&&this.handlePanelKey(event,panel,origin)},this.requestingExpansion=!1,this.onToggleClick=()=>{this.setExpanded(!this._expanded,"user")}}static{this.defaultStrings={...super.defaultStrings,menuLabel:LYRA_DEFAULT_menuLabel,navigation:LYRA_DEFAULT_navigation}}static{this.styles=[LyraElement.styles,styles]}get expanded(){return this._expanded}set expanded(next){markVetoGuardWrite(this.expansionWriteGuard),this.setExpanded(!!next,this.hasUpdated?"programmatic":null)}get panelAnchor(){return this._panelAnchor}set panelAnchor(next){const normalized=PANEL_ANCHOR.normalizeReflected(this,"panel-anchor",next);if(normalized===this._panelAnchor)return;const old=this._panelAnchor;this._panelAnchor=normalized,this.requestUpdate("panelAnchor",old)}get collapsed(){return this.collapsedLayout}get layout(){return this.collapsedLayout?"stacked":"bar"}get listElement(){return this.renderRoot?.querySelector('[part~="list"]')??null}get toggleElement(){return this.renderRoot?.querySelector('[part~="toggle"]')??null}controllerFor(item){return item?navigationMenuItemController(item):void 0}connectedCallback(){super.connectedCallback(),this.addEventListener("pointerover",this.onPointerOver),this.addEventListener("pointerout",this.onPointerOut),this.addEventListener("pointerdown",this.onPointerDownCapture,!0),this.addEventListener("click",this.onClickCapture,!0),this.addEventListener("keydown",this.onKeyDown),this.addEventListener("focusout",this.onFocusOut),this.observeAllocation(),this.hasUpdated&&this.updateBrowserDerivedState(()=>this.bindItems())}disconnectedCallback(){this.removeEventListener("pointerover",this.onPointerOver),this.removeEventListener("pointerout",this.onPointerOut),this.removeEventListener("pointerdown",this.onPointerDownCapture,!0),this.removeEventListener("click",this.onClickCapture,!0),this.removeEventListener("keydown",this.onKeyDown),this.removeEventListener("focusout",this.onFocusOut),this.resizeObserver?.disconnect(),this.resizeObserver=void 0,this.cancelAllocationFrame(),this.observedIndicatorTargets.clear(),this.stopLightDismiss(),this.cancelShow(),this.cancelHide(),this.clearPress();for(const item of this.items)this.releaseItem(item);this.items=[],super.disconnectedCallback()}close(){this.cancelShow(),this.cancelHide();const listHides=this.collapsedLayout&&this._expanded;this.closeOpenItem("programmatic",listHides?{focusTarget:this.toggleElement}:{}),this.setExpanded(!1,"programmatic")}show(){this.setExpanded(!0,"programmatic")}hide(){this.close()}firstUpdated(changed){super.firstUpdated(changed),queueMicrotask(()=>{this.isConnected&&this.updateBrowserDerivedState(()=>this.bindItems())})}willUpdate(changed){super.willUpdate(changed),changed.has("mobileBreakpoint")&&this.hasUpdated&&this.applyAllocation(this.measureContentInlineSize())}updated(changed){super.updated(changed);const pending=this.pendingFocus;this.pendingFocus=void 0,pending==="toggle"?this.toggleElement?.focus({preventScroll:!0}):pending==="first-base"&&this.firstNavigableBase()?.focus({preventScroll:!0});const direction=this.effectiveDirection,directionChanged=this.lastDirection!==void 0&&direction!==this.lastDirection;this.lastDirection=direction,(changed.has("distance")||changed.has("topLayer")||changed.has("panelAnchor")||directionChanged)&&this.controllerFor(this.openItem)?.reposition(),(changed.has("indicator")||changed.has("panelAnchor")||changed.has("collapsedLayout")||directionChanged)&&(this.observeIndicatorTargets(),this.queueIndicatorMeasure())}bindItems(){if(!this.isConnected)return;const slot=this.renderRoot?.querySelector('[part~="list"] > slot'),assigned=slot?slot.assignedElements():[...this.children].filter(child=>!child.hasAttribute("slot")),itemTag=tag("navigation-menu-item"),next=[];for(const child of assigned)child.localName===itemTag?next.push(child):IGNORED_CHILDREN.has(child.localName)||devWarnOnce("lr-navigation-menu:non-item-child",`<${tag("navigation-menu")}> received <${child.localName}> in its default slot, which renders inside its list without a list item role. Only <${itemTag}> children belong there; place header chrome such as a logo, search or actions outside the menu.`);const kept=new Set(next);for(const previous of this.items)kept.has(previous)||this.releaseItem(previous);for(const item of next)bindNavigationMenuItem(item,this.context),item.hasAttribute("role")||(item.setAttribute("role","listitem"),this.ownedRoles.add(item));this.items=next,this.openItem&&(!kept.has(this.openItem)||!this.controllerFor(this.openItem)?.isOpen())&&(this.openItem=void 0);for(const item of next){const controller=this.controllerFor(item);controller?.isOpen()&&(this.openItem?this.openItem!==item&&controller.close(null,{repairFocus:!1,instant:!0}):this.openItem=item)}this.openItem&&this.layout==="bar"?this.startLightDismiss():this.stopLightDismiss(),this.observeIndicatorTargets(),this.queueIndicatorMeasure()}releaseItem(item){releaseNavigationMenuItem(item,this),this.ownedRoles.has(item)&&(item.getAttribute("role")==="listitem"&&item.removeAttribute("role"),this.ownedRoles.delete(item)),this.showTimer?.item===item&&this.cancelShow(),this.hideTimer?.item===item&&this.cancelHide(),this.openItem===item&&(this.openItem=void 0,this.stopLightDismiss())}now(){return this.ownerDocument.defaultView?.performance.now()??Date.now()}isNavigable(item){if(item.hidden||item.inert||item.closest("[inert]")!==null||item.getAttribute("aria-hidden")==="true")return!1;const base=this.controllerFor(item)?.base();return base!=null&&isComposedFocusAvailable(base)}firstNavigableBase(){const item=this.items.find(candidate=>this.isNavigable(candidate));return this.controllerFor(item)?.base()??null}itemContaining(target){if(isElementNode(target))return this.items.find(item=>composedContains(item,target))}focusWithinPanel(item){const active=deepActiveElement(this.ownerDocument);if(!active||!composedContains(item,active))return!1;const base=this.controllerFor(item)?.base();return!(base&&composedContains(base,active))}closeOpenItem(source,options={}){this.controllerFor(this.openItem)?.close(source,options)}activateItem(item){const controller=this.controllerFor(item);if(controller){if(this.cancelShow(),this.cancelHide(),controller.isTrigger()){controller.isOpen()?this.layout==="bar"&&controller.mode()==="hover"?controller.pin():controller.close("user"):controller.open("pinned","user");return}this.closeOpenItem("user"),this.layout==="stacked"&&this.setExpanded(!1,"user")}}itemWillOpen(item){this.showTimer?.item!==item&&this.cancelShow();const current=this.openItem;if(!current||current===item)return;const currentController=this.controllerFor(current);let morph;if(this.layout==="bar"&&this._panelAnchor==="menu"&&!prefersReducedMotion(this)){const panel=currentController?.panel(),from=panel&&!panel.hidden?panel.getBoundingClientRect():void 0;from&&from.width>0&&from.height>0&&(morph={from,direction:this.items.indexOf(item)>this.items.indexOf(current)?"end":"start"})}return currentController?.close("peer",{instant:!0,focusTarget:this.controllerFor(item)?.base()??null}),morph}itemChanged(item,open,source){open?(this.openItem=item,this.hideTimer?.item===item&&this.cancelHide(),this.layout==="bar"&&this.startLightDismiss()):this.openItem===item&&(this.openItem=void 0,this.layout==="bar"&&source!=="peer"&&(this.lastCloseAt=this.now()),this.hideTimer?.item===item&&this.cancelHide(),this.stopLightDismiss()),this.observeIndicatorTargets(),this.queueIndicatorMeasure()}itemEscape(item){this.cancelShow(),this.cancelHide();const within=composedContains(item,deepActiveElement(this.ownerDocument));this.controllerFor(item)?.close("user",{repairFocus:!1,restoreFocus:within})}hoverTrigger(item){this.cancelHide();const open=this.openItem;if(open&&open!==item){if(this.focusWithinPanel(open))return;this.cancelShow(),this.controllerFor(item)?.open("hover","user");return}if(this.showTimer?.item===item)return;const skip=finiteDuration(this.skipDelay,DEFAULT_SKIP_DELAY);if(skip>0&&this.now()-this.lastCloseAt<=skip){this.cancelShow(),this.controllerFor(item)?.open("hover","user");return}this.scheduleShow(item)}hoverNonTrigger(){this.cancelShow();const open=this.openItem;open&&this.requestHoverClose(open)}requestHoverClose(item){this.openItem===item&&(this.controllerFor(item)?.mode()!=="hover"||this.focusWithinPanel(item)||this.scheduleHide(item))}scheduleShow(item){this.cancelShow();const delay=finiteDuration(this.showDelay,DEFAULT_SHOW_DELAY),view=this.ownerDocument.defaultView,commit=()=>{if(this.layout!=="bar"||!this.items.includes(item))return;const open=this.openItem;open&&open!==item&&this.focusWithinPanel(open)||this.controllerFor(item)?.open("hover","user")};if(!view||delay<=0){commit();return}const id=view.setTimeout(()=>{this.showTimer?.id===id&&(this.showTimer=void 0,commit())},delay);this.showTimer={item,id,view}}scheduleHide(item){this.cancelHide();const delay=finiteDuration(this.hideDelay,DEFAULT_HIDE_DELAY),view=this.ownerDocument.defaultView,commit=()=>{if(this.openItem!==item)return;const controller=this.controllerFor(item);controller?.mode()!=="hover"||this.focusWithinPanel(item)||controller.close("user")};if(!view||delay<=0){commit();return}const id=view.setTimeout(()=>{this.hideTimer?.id===id&&(this.hideTimer=void 0,commit())},delay);this.hideTimer={item,id,view}}cancelShow(){const timer=this.showTimer;this.showTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}cancelHide(){const timer=this.hideTimer;this.hideTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}startLightDismiss(){const doc=this.ownerDocument;!this.isConnected||this.lightDismissDocument===doc||(this.stopLightDismiss(),doc.addEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=doc)}stopLightDismiss(){this.lightDismissDocument?.removeEventListener("pointerdown",this.onDocumentPointerDown,!0),this.lightDismissDocument=void 0}reevaluatePress(){const pressed=this.pressOpenItem;if(this.pressActive=!1,this.pressOpenItem=void 0,!pressed||pressed!==this.openItem||this.layout!=="bar")return;const controller=this.controllerFor(pressed);if(!controller?.isOpen())return;const doc=this.ownerDocument,active=deepActiveElement(doc);!active||active===doc.body||active===doc.documentElement||composedContains(pressed,active)||controller.close("user",{repairFocus:!1})}stopPressListeners(){this.pressDocument?.removeEventListener("pointerup",this.onPressEnd,!0),this.pressDocument?.removeEventListener("pointercancel",this.onPressEnd,!0),this.pressDocument=void 0}clearPressTimer(){const timer=this.pressTimer;this.pressTimer=void 0,timer&&timer.view.clearTimeout(timer.id)}clearPress(){this.stopPressListeners(),this.clearPressTimer(),this.pressActive=!1,this.pressOpenItem=void 0}handleBaseKey(event,item){const rtl=this.effectiveDirection==="rtl";switch(event.key){case"ArrowRight":case"ArrowLeft":{event.preventDefault();const forward=event.key==="ArrowRight"!==rtl;this.focusSibling(item,forward?1:-1);return}case"Home":case"End":{event.preventDefault();const navigable=this.items.filter(candidate=>this.isNavigable(candidate)),target=event.key==="Home"?navigable[0]:navigable.at(-1);this.controllerFor(target)?.base()?.focus();return}case"ArrowDown":{const controller=this.controllerFor(item);if(!controller?.isTrigger()||!controller.isOpen())return;event.preventDefault(),this.enterPanel(controller);return}}}focusSibling(item,step){const navigable=this.items.filter(candidate=>this.isNavigable(candidate)),index=navigable.indexOf(item);index!==-1&&this.controllerFor(navigable[index+step])?.base()?.focus()}async enterPanel(controller){if(await controller.placementReady(),!controller.isOpen())return;const panel=controller.panel();panel&&collectFocusableElements(panel)[0]?.focus()}handlePanelKey(event,panel,origin){if(!["ArrowDown","ArrowUp","Home","End"].includes(event.key)||!origin.matches(PANEL_KEY_ORIGIN))return;event.preventDefault();const focusable=collectFocusableElements(panel),index=focusable.findIndex(candidate=>candidate===origin);let target;event.key==="Home"?target=focusable[0]:event.key==="End"?target=focusable.at(-1):event.key==="ArrowDown"?target=focusable[index+1]:index>0&&(target=focusable[index-1]),target?.focus()}handleStackedEscape(event){const open=this.openItem,active=deepActiveElement(this.ownerDocument);if(open&&active&&composedContains(open,active)){event.preventDefault();const controller=this.controllerFor(open),base=controller?.base();controller?.close("user"),base?.focus();return}this._expanded&&(event.preventDefault(),this.setExpanded(!1,"user"),this.toggleElement?.focus())}setExpanded(next,source){if(next===this._expanded)return;if(source==="user"){if(this.requestingExpansion)return;const previous=this._expanded;this.requestingExpansion=!0;try{let accepted=!1;if(requestThenCommit({requestDetail:{expanded:next,source},emitRequest:(detail,init)=>this.emit("lr-toggle-request",detail,init),guard:this.expansionWriteGuard,commit:()=>{accepted=this._expanded===previous}}),!accepted)return}finally{this.requestingExpansion=!1}}if(!next&&this.collapsedLayout){const list=this.listElement,active=deepActiveElement(this.ownerDocument);list&&active&&composedContains(list,active)&&this.toggleElement?.focus({preventScroll:!0}),this.closeOpenItem(source,{repairFocus:!1})}const old=this._expanded;this._expanded=next;const notificationSequence=++this.expansionNotificationSequence;this.requestUpdate("expanded",old),source!==null&&this.updateComplete.then(()=>{!this.isConnected||this._expanded!==next||this.expansionNotificationSequence!==notificationSequence||this.emit("lr-toggle",{expanded:next,source})})}observeAllocation(){const ResizeObserverConstructor=this.ownerDocument.defaultView?.ResizeObserver;ResizeObserverConstructor&&(this.resizeObserver??=new ResizeObserverConstructor(entries=>this.onResize(entries)),this.resizeObserver.observe(this),this.observedIndicatorTargets.clear(),this.observeIndicatorTargets())}onResize(entries){for(const entry of entries)entry.target===this&&(this.lastInlineSize=entry.contentBoxSize?.[0]?.inlineSize??entry.contentRect.width,this.scheduleAllocation());this.queueIndicatorMeasure()}scheduleAllocation(){if(this.allocationFrame)return;const view=this.ownerDocument.defaultView;if(!view){this.applyAllocation(this.lastInlineSize);return}const id=view.requestAnimationFrame(()=>{this.allocationFrame?.id===id&&(this.allocationFrame=void 0,this.isConnected&&this.applyAllocation(this.lastInlineSize))});this.allocationFrame={id,view}}cancelAllocationFrame(){const frame=this.allocationFrame;this.allocationFrame=void 0,frame&&frame.view.cancelAnimationFrame(frame.id)}measureContentInlineSize(){const view=this.ownerDocument.defaultView;if(!view||!this.isConnected)return this.lastInlineSize;const style=view.getComputedStyle(this),edges=["paddingLeft","paddingRight","borderLeftWidth","borderRightWidth"];let width=this.getBoundingClientRect().width;for(const edge of edges)width-=Number.parseFloat(style[edge])||0;return Math.max(0,width)}applyAllocation(width){if(width===void 0||!Number.isFinite(width))return;const breakpoint=resolveCssLength(this.mobileBreakpoint,{host:this}),next=breakpoint!==void 0&&Number.isFinite(breakpoint)&&width<=breakpoint;this.updateBrowserDerivedState(()=>this.setCollapsed(next))}setCollapsed(next){if(next===this.collapsedLayout)return;this.cancelShow(),this.cancelHide();const active=deepActiveElement(this.ownerDocument),open=this.openItem;if(next){const list=this.listElement,listHides=!this._expanded,focusInList=!!(active&&list&&composedContains(list,active));this.controllerFor(open)?.close("programmatic",{instant:!0,repairFocus:!listHides}),listHides&&focusInList&&(this.pendingFocus="toggle"),this.stopLightDismiss()}else{const toggle=this.toggleElement,onToggle=!!(active&&toggle&&composedContains(toggle,active));this.controllerFor(open)?.close("programmatic",{instant:!0}),onToggle&&(this.pendingFocus="first-base")}this.collapsedLayout=next,setCustomState(this.menuInternals,"collapsed",next);for(const item of this.items)item.requestUpdate?.();!next&&this._expanded&&this.setExpanded(!1,"programmatic")}observeIndicatorTargets(){const observer=this.resizeObserver;if(!observer)return;const wanted=new Set;if(this.indicator){const list=this.listElement;list&&wanted.add(list);for(const item of this.items)wanted.add(item)}for(const target of this.observedIndicatorTargets)wanted.has(target)||observer.unobserve(target);for(const target of wanted)this.observedIndicatorTargets.has(target)||observer.observe(target);this.observedIndicatorTargets=wanted}queueIndicatorMeasure(){this.indicatorQueued||!this.indicator||(this.indicatorQueued=!0,queueMicrotask(()=>{const open=this.openItem;Promise.all([this.updateComplete,open?.updateComplete]).then(()=>{this.indicatorQueued=!1,this.measureIndicator()})}))}measureIndicator(){if(!this.indicator||this.collapsedLayout||!this.isConnected)return;const nav=this.renderRoot.querySelector('[part~="base"]'),base=this.controllerFor(this.openItem)?.base(),previous=this.indicatorBox;if(!nav||!base){previous?.visible&&(this.indicatorBox={...previous,visible:!1});return}const navRect=nav.getBoundingClientRect(),trigger=base.getBoundingClientRect(),list=this.listElement,rtl=this.effectiveDirection==="rtl",bottom=this._panelAnchor==="menu"&&list?list.getBoundingClientRect().bottom:trigger.bottom,next={start:rtl?navRect.right-trigger.right:trigger.left-navRect.left,size:trigger.width,top:bottom-navRect.top,visible:!0};previous&&previous.visible===next.visible&&Math.abs(previous.start-next.start)<.5&&Math.abs(previous.size-next.size)<.5&&Math.abs(previous.top-next.top)<.5||(this.indicatorBox=next)}render(){const label=hostAriaLabel(this)??this.label??this.localize("navigation"),collapsed=this.collapsedLayout,box=this.indicatorBox;return html`<nav part="base" aria-label=${label}>
|
|
2
2
|
${collapsed?html`<button
|
|
3
3
|
type="button"
|
|
4
4
|
part="toggle"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveListMove}from"../../../internal/list-navigation.js";import{nextId}from"../../../internal/a11y.js";import{composedAccessibilityText}from"../../../internal/accessibility-visibility.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{chevronIcon}from"../../../internal/icons.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{tag}from"../../../internal/prefix.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{styles}from"./tab-group.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_scrollNext,LYRA_DEFAULT_scrollPrevious}from"../../../internal/default-strings/layout.generated.js";function isInertChild(child){return isHtmlElement(child)&&child.inert}function isTabLabelSubtreeExcludedWithoutInert(element){if(element.hasAttribute("hidden")||element.getAttribute("aria-hidden")?.trim().toLowerCase()==="true")return!0;const rendered=element.ownerDocument.defaultView?.getComputedStyle(element);return rendered?.display==="none"||rendered?.contentVisibility==="hidden"}const SYNTHETIC_PANEL_PREFIX="lr-tab-",SCROLL_STEP_RATIO=.8;class LyraTabGroup extends LyraElement{constructor(){super(...arguments),this.active="",this.accessibleLabel=null,this.placement="top",this.activation="auto",this.withoutScrollControls=!1,this.noScrollControls=!1,this.fixedScrollControls=!1,this.tabs=[],this.focusedTab="",this.baseId=nextId("tab-group"),this.nextOpaqueId=0,this.idsBySlot=new Map,this.mutationObserverGeneration=0,this.projectionGeneration=0,this.projectionPending=!1,this.stagingSlotName="tab-group-sources",this.pendingDescriptorUpdates=new WeakSet,this.excludedUnnamedDescriptors=new Set,this.descriptorUpgrades=new CustomElementUpgradeObserver(()=>{this.excludedUnnamedDescriptors.clear(),this.queueProjectionReconciliation()}),this.restoredSourceInertWrites=new Map,this.restoredSlotWrites=new Map,this.projectedSourceSnapshots=new Map,this.projectedSlotSnapshots=new Map,this.projectedSourceObserverGeneration=0,this.rehomeTabFocus=!1,this.scrollStartAvailable=!1,this.scrollEndAvailable=!1,this.scrollOverflow=observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part~="tablist"]'),()=>this.measureTabScrollEdges()),this.queueProjectionReconciliation=()=>{if(!this.isConnected||this.projectionTimer!==void 0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow)return;const generation=this.projectionGeneration;this.beginProjectionSettlement(),this.projectionTimerWindow=ownerWindow,this.projectionTimer=ownerWindow.setTimeout(()=>{generation!==this.projectionGeneration||this.ownerDocument!==ownerDocument||!this.isConnected||(this.projectionTimer=void 0,this.projectionTimerWindow=void 0,this.updateBrowserDerivedState(this.syncTabs))},0)},this.syncTabs=()=>{const children=Array.from(this.children);this.adoptProjectedSourceInertStates(),this.adoptProjectedSlotStates();const projectedSlots=new Set,wasPending=this.projectionPending,next=this.readElementModel(children,projectedSlots);this.syncProjectedSlots(projectedSlots),this.syncProjectedSources(next.filter(tab=>tab.element.parentNode===this));const liveSlots=new Set(next.map(tab=>tab.slotName));for(const slotName of this.idsBySlot.keys())liveSlots.has(slotName)||this.idsBySlot.delete(slotName);(next.length!==this.tabs.length||wasPending&&!this.projectionPending||next.some((tab,index)=>{const previous=this.tabs[index];return tab.element!==previous.element||tab.slotName!==previous.slotName||tab.label!==previous.label||tab.disabled!==previous.disabled||tab.inert!==previous.inert}))&&(this.tabs=next),this.projectionPending||this.projectionTimer!==void 0?this.beginProjectionSettlement():this.settleProjection()},this.onTabListKeyDown=e=>{if(e.altKey||e.ctrlKey||e.metaKey||e.isComposing)return;const navigable=this.tabs.filter(t=>this.isNavigable(t));if(navigable.length===0)return;const origin=this.keyboardOriginTab(e,navigable),currentIndex=origin?navigable.indexOf(origin):-1;if(e.key==="Delete"){if(!origin?.element.closable)return;e.preventDefault(),origin.element.requestCloseFromOwner();return}if(this.activation==="manual"&&(e.key==="Enter"||e.key===" "||e.key==="Spacebar")){if(!origin)return;e.preventDefault(),this.activateTab(origin);return}const targetIndex=resolveListMove(e,{count:navigable.length,current:currentIndex,orientation:this.isVertical?"vertical":"horizontal",direction:this.effectiveDirection});if(targetIndex===null)return;e.preventDefault();const target=navigable[targetIndex];if(this.activation==="manual"){this.focusOnly(target);return}this.activateTab(target),this.focusTab(target.slotName)},this.onTabListScroll=()=>{this.measureTabScrollEdges()},this.onScrollControlMouseDown=event=>{event.preventDefault()},this.onScrollControlPointerDown=event=>{const control=event.currentTarget;control instanceof HTMLElement&&(control.setAttribute("data-pressed",""),control.setPointerCapture(event.pointerId))},this.onScrollControlPointerEnd=event=>{const control=event.currentTarget;control instanceof HTMLElement&&(control.removeAttribute("data-pressed"),control.hasPointerCapture(event.pointerId)&&control.releasePointerCapture(event.pointerId))}}static{this.defaultStrings={...super.defaultStrings,scrollNext:LYRA_DEFAULT_scrollNext,scrollPrevious:LYRA_DEFAULT_scrollPrevious}}static{this.styles=[LyraElement.styles,scrollOverflowFadeStyles,styles]}connectedCallback(){super.connectedCallback(),this.hasUpdated?this.syncTabs():this.seedFirstRenderState(this.syncTabs),this.resetMutationObserver();const ownerDocument=this.ownerDocument,MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.mutationObserverGeneration,observer=new MutationObserverCtor(records=>{if(this.mutationObserver!==observer||this.mutationObserverDocument!==ownerDocument||this.mutationObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument)return;const isDirectChild=node=>node.parentNode===this,isElementTabContent=node=>{let current=node.nodeType===1?node:node.parentElement;for(;current&¤t!==this;){if(current.localName===tag("tab")&¤t.parentNode===this)return!0;current=current.parentElement}return!1},relevant=records.some(record=>{if(record.type==="childList")return record.target===this||isElementTabContent(record.target);if(record.type==="characterData")return isElementTabContent(record.target);if(record.attributeName==="inert"&&this.projectedSourceSnapshots.has(record.target)||record.attributeName==="inert"&&this.restoredSourceInertWrites.has(record.target)&&record.target.getAttribute("inert")===this.restoredSourceInertWrites.get(record.target))return!1;if(record.attributeName==="slot"){if(this.restoredSlotWrites.has(record.target)&&record.target.getAttribute("slot")===this.restoredSlotWrites.get(record.target))return!1;const snapshot=this.projectedSlotSnapshots.get(record.target);if(snapshot&&record.target.getAttribute("slot")===snapshot.appliedSlot)return!1}return isDirectChild(record.target)||isElementTabContent(record.target)});this.restoredSourceInertWrites.clear(),this.restoredSlotWrites.clear(),relevant&&(this.excludedUnnamedDescriptors.clear(),this.syncTabs())});this.mutationObserver=observer,this.mutationObserverDocument=ownerDocument,observer.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0,attributeFilter:["alt","aria-hidden","aria-label","aria-labelledby","class","closable","disabled","hidden","inert","id","label","name","open","panel","slot","style"]})}disconnectedCallback(){this.resetProjectionReconciliation(),this.resetMutationObserver(),this.resetProjectedSourceObserver(),this.restoreProjectedSources(),this.restoreProjectedSlots(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetMutationObserver(),this.resetProjectedSourceObserver(),this.resetProjectionReconciliation()}resetProjectionReconciliation(){this.projectionGeneration+=1,this.projectionTimer!==void 0&&this.projectionTimerWindow?.clearTimeout(this.projectionTimer),this.projectionTimer=void 0,this.projectionTimerWindow=void 0,this.projectionPending=!1,this.pendingDescriptorUpdates=new WeakSet,this.descriptorUpgrades.disconnect(),this.restoredSourceInertWrites.clear(),this.restoredSlotWrites.clear(),this.excludedUnnamedDescriptors.clear(),this.settleProjection()}beginProjectionSettlement(){this.projectionSettlement||(this.projectionSettlement=new Promise(resolve=>{this.resolveProjectionSettlement=resolve}))}settleProjection(){const resolve=this.resolveProjectionSettlement;this.resolveProjectionSettlement=void 0,this.projectionSettlement=void 0,resolve?.()}async getUpdateComplete(){const generation=this.projectionGeneration,ownerDocument=this.ownerDocument;let complete=await super.getUpdateComplete();if(this.renderSlotPresence(!1)||!ownerDocument.defaultView)return complete;const current=()=>this.isConnected&&generation===this.projectionGeneration&&this.ownerDocument===ownerDocument;for(;current();){const settlement=this.projectionSettlement;if(settlement){if(await settlement,!current())return complete;complete=await super.getUpdateComplete()}else if(this.isUpdatePending)complete=await super.getUpdateComplete();else return complete}return complete}waitForDescriptorUpdate(tab){if(tab.hasUpdated===!0)return!1;const updateComplete=tab.updateComplete;if(!updateComplete)return this.descriptorUpgrades.observeElement(tab),!1;if(!this.pendingDescriptorUpdates.has(tab)){this.pendingDescriptorUpdates.add(tab);const generation=this.projectionGeneration,ownerDocument=this.ownerDocument;updateComplete.then(()=>{generation===this.projectionGeneration&&this.ownerDocument===ownerDocument&&(this.pendingDescriptorUpdates.delete(tab),tab.parentNode===this&&this.queueProjectionReconciliation())})}return!0}resetMutationObserver(){this.mutationObserverGeneration+=1,this.mutationObserver?.disconnect(),this.mutationObserver=void 0,this.mutationObserverDocument=void 0}readElementModel(children,projectedSlots){this.projectionPending=!1;const seen=new Set,next=[],panelsByName=new Map;for(const child of children){if(child.localName!==tag("tab-panel"))continue;const name=child.getAttribute("name");name!==null&&!panelsByName.has(name)&&panelsByName.set(name,child)}const authoredNames=new Set(children.flatMap(child=>{if(child.localName===tag("tab")){const name=child.getAttribute("panel");return name?[name]:[]}if(child.localName===tag("tab-panel")){const name=child.getAttribute("name");return name?[name]:[]}return[]}));let stagingName="tab-group-sources";for(;authoredNames.has(stagingName);)stagingName+="-sources";this.stagingSlotName=stagingName;let index=0;for(const child of children){if(child.localName!==tag("tab"))continue;const authoredPanel=child.getAttribute("panel")||void 0;let slotName=authoredPanel??`${SYNTHETIC_PANEL_PREFIX}${index}`;if(!authoredPanel){let collision=0;for(;authoredNames.has(slotName)||seen.has(slotName);)collision+=1,slotName=`${SYNTHETIC_PANEL_PREFIX}${index}-${collision}`}if(index+=1,seen.has(slotName))continue;seen.add(slotName);const tabSlot=this.tabSlotName(slotName),assignedSlot=child.assignedSlot,assignedHere=assignedSlot?.getRootNode()===this.renderRoot&&(assignedSlot.name===tabSlot||assignedSlot.name===this.stagingSlotName);if(!assignedHere||!authoredPanel&&this.excludedUnnamedDescriptors.has(child)){this.projectSlot(child,this.stagingSlotName,projectedSlots),assignedHere||(this.projectionPending=!0);continue}if(this.waitForDescriptorUpdate(child)){this.projectionPending=!0,this.projectSlot(child,this.stagingSlotName,projectedSlots);continue}const visibleLabel=this.readElementLabel(child);if(!authoredPanel&&!visibleLabel){this.excludedUnnamedDescriptors.add(child),this.projectSlot(child,this.stagingSlotName,projectedSlots);continue}projectedSlots.add(child);const label=visibleLabel||slotName,panel=panelsByName.get(slotName);panel&&this.projectSlot(panel,slotName,projectedSlots),next.push({slotName,label,disabled:child.hasAttribute("disabled"),inert:isInertChild(child),element:child}),!this.active&&child.hasAttribute("active")&&(this.active=slotName)}if(this.projectionPending){for(const child of children)this.projectedSlotSnapshots.has(child)&&projectedSlots.add(child);return this.tabs}for(const tab of next)this.projectSlot(tab.element,this.tabSlotName(tab.slotName),projectedSlots);return next}readElementLabel(tab){const labelNodes=Array.from(tab.childNodes).filter(node=>node.nodeType!==Node.ELEMENT_NODE||node.getAttribute("slot")===null||node.getAttribute("slot")==="");return composedAccessibilityText(labelNodes,{ancestorBoundary:tab,isSubtreeExcluded:element=>this.isTabLabelSubtreeExcluded(element),ignoreInheritedVisibility:!0}).replace(/\s+/g," ").trim()}libraryOwnsSourceInert(element){return this.projectedSourceSnapshots.get(element)?.libraryOwnsInert===!0}isTabLabelSubtreeExcluded(element){return isTabLabelSubtreeExcludedWithoutInert(element)||element.hasAttribute("inert")&&!this.libraryOwnsSourceInert(element)}snapshotProjectedSource(source){const inert=source.getAttribute("inert");return{inert,appliedInert:inert,libraryOwnsInert:!1}}adoptProjectedSourceInert(source,snapshot){const current=source.getAttribute("inert");current!==snapshot.appliedInert&&(snapshot.inert=current,snapshot.libraryOwnsInert=!1)}makeProjectedSourceInert(source,snapshot){source.hasAttribute("inert")||(source.setAttribute("inert",""),snapshot.libraryOwnsInert=!0),snapshot.appliedInert=source.getAttribute("inert")}restoreProjectedSource(source,snapshot){this.adoptProjectedSourceInert(source,snapshot);const before=source.getAttribute("inert");snapshot.inert===null?source.removeAttribute("inert"):source.setAttribute("inert",snapshot.inert),this.mutationObserver&&this.contains(source)&&source.getAttribute("inert")!==before&&this.restoredSourceInertWrites.set(source,source.getAttribute("inert"))}restoreProjectedSources(){for(const[source,snapshot]of this.projectedSourceSnapshots)this.restoreProjectedSource(source,snapshot);this.projectedSourceSnapshots.clear()}resetProjectedSourceObserver(){this.projectedSourceObserverGeneration+=1,this.projectedSourceObserver?.disconnect(),this.projectedSourceObserver=void 0,this.projectedSourceObserverDocument=void 0}observeProjectedSources(){this.resetProjectedSourceObserver();const ownerDocument=this.ownerDocument,MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor||!this.isConnected||this.projectedSourceSnapshots.size===0)return;const generation=this.projectedSourceObserverGeneration,observer=new MutationObserverCtor(records=>{this.projectedSourceObserver!==observer||this.projectedSourceObserverDocument!==ownerDocument||this.projectedSourceObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||records.some(record=>this.projectedSourceSnapshots.has(record.target))&&this.syncTabs()});this.projectedSourceObserver=observer,this.projectedSourceObserverDocument=ownerDocument;for(const source of this.projectedSourceSnapshots.keys())observer.observe(source,{attributes:!0,attributeFilter:["inert"]})}projectedSources(tabs){const sources=new Set;for(const tab of tabs)for(const child of Array.from(tab.element.children))(child.getAttribute("slot")??"")===""&&sources.add(child);return sources}syncProjectedSources(tabs){const sources=this.projectedSources(tabs);for(const[source,snapshot]of this.projectedSourceSnapshots)this.adoptProjectedSourceInert(source,snapshot),sources.has(source)||(this.restoreProjectedSource(source,snapshot),this.projectedSourceSnapshots.delete(source));for(const source of sources){const snapshot=this.projectedSourceSnapshots.get(source)??this.snapshotProjectedSource(source);this.projectedSourceSnapshots.set(source,snapshot),this.adoptProjectedSourceInert(source,snapshot),this.makeProjectedSourceInert(source,snapshot)}this.observeProjectedSources()}adoptProjectedSourceInertStates(){for(const[source,snapshot]of this.projectedSourceSnapshots)this.adoptProjectedSourceInert(source,snapshot)}snapshotProjectedSlot(source){const slot=source.getAttribute("slot");return{slot,appliedSlot:slot,libraryOwnsSlot:!1}}adoptProjectedSlot(source,snapshot){const current=source.getAttribute("slot");current!==snapshot.appliedSlot&&(snapshot.slot=current,snapshot.libraryOwnsSlot=!1)}projectSlot(source,slot,projectedSlots){const snapshot=this.projectedSlotSnapshots.get(source)??this.snapshotProjectedSlot(source);this.projectedSlotSnapshots.set(source,snapshot),this.adoptProjectedSlot(source,snapshot),source.getAttribute("slot")!==slot&&(source.setAttribute("slot",slot),snapshot.libraryOwnsSlot=!0),snapshot.appliedSlot=source.getAttribute("slot"),projectedSlots.add(source)}restoreProjectedSlot(source,snapshot){this.adoptProjectedSlot(source,snapshot);const before=source.getAttribute("slot");snapshot.slot===null?source.removeAttribute("slot"):source.setAttribute("slot",snapshot.slot),this.mutationObserver&&this.contains(source)&&source.getAttribute("slot")!==before&&this.restoredSlotWrites.set(source,source.getAttribute("slot"))}syncProjectedSlots(projectedSlots){for(const[source,snapshot]of this.projectedSlotSnapshots)projectedSlots.has(source)||(this.restoreProjectedSlot(source,snapshot),this.projectedSlotSnapshots.delete(source))}restoreProjectedSlots(){for(const[source,snapshot]of this.projectedSlotSnapshots)this.restoreProjectedSlot(source,snapshot);this.projectedSlotSnapshots.clear()}adoptProjectedSlotStates(){for(const[source,snapshot]of this.projectedSlotSnapshots)this.adoptProjectedSlot(source,snapshot)}isNavigable(tab){return!tab.disabled&&!tab.inert}willUpdate(changed){if(super.willUpdate(changed),this.projectionPending||!changed.has("tabs")&&!changed.has("active"))return;const focused=shadowFocusTarget(this),focusedSlot=focused?.getAttribute("part")==="tab"?focused.getAttribute("data-slot"):null;focusedSlot!==null&&!this.tabs.some(tab=>tab.slotName===focusedSlot&&this.isNavigable(tab))&&(this.rehomeTabFocus=!0,this.focusedTab=this.active);const current=this.tabs.find(t=>t.slotName===this.active);if(current&&this.isNavigable(current))return;this.rehomeTabFocus=this.rehomeTabFocus||focusedSlot!==null;const outgoing=this.active,before=changed.get("tabs")??this.tabs,at=this.hasUpdated&&changed.has("tabs")&&!changed.has("active")?before.findIndex(t=>t.slotName===outgoing):-1,renamed=at<0?void 0:this.tabs.find(t=>t.element===before[at].element&&this.isNavigable(t));let candidates=this.tabs;if(at>=0){const liveByName=new Map;for(const tab of this.tabs)liveByName.has(tab.slotName)||liveByName.set(tab.slotName,tab);candidates=[...before.slice(at+1),...before.slice(0,at).reverse()].map(tab=>liveByName.get(tab.slotName))}this.active=(renamed??candidates.find(t=>t&&this.isNavigable(t)))?.slotName??"",this.focusedTab=this.active,at>=0&&!renamed&&(this.emit("lr-tab-hide",{name:outgoing}),this.active&&this.emit("lr-tab-show",{name:this.active}))}updated(changed){super.updated(changed),changed.has("tabs")&&this.queueProjectionReconciliation(),!this.projectionPending&&(changed.has("active")||changed.has("tabs"))&&this.syncElementActiveState(),this.scrollOverflow.observeExtra(this.renderRoot.querySelectorAll('[part="tab"]')),this.measureTabScrollEdges(),this.rehomeTabFocus&&(this.rehomeTabFocus=!1,this.renderRoot.querySelector('[part="tab"][tabindex="0"]')?.focus())}selectTab(tab){if(!this.isNavigable(tab)||tab.slotName===this.active)return;const previous=this.active;this.active=tab.slotName,this.focusedTab=tab.slotName,previous&&this.emit("lr-tab-hide",{name:previous}),this.emit("lr-tab-show",{name:tab.slotName})}activateTab(tab){this.isNavigable(tab)&&(this.selectTab(tab),this.emit("lr-activate",{value:tab.slotName}))}show(panel){const tab=this.tabs.find(candidate=>candidate.slotName===panel);tab&&this.selectTab(tab)}syncElementActiveState(){const definitions=new Map;for(const tab of this.tabs)definitions.has(tab.element)||definitions.set(tab.element,tab);for(const child of Array.from(this.children))if(child.localName===tag("tab")){const definition=definitions.get(child);child.toggleAttribute("active",definition?.slotName===this.active)}else child.localName===tag("tab-panel")&&child.toggleAttribute("active",child.getAttribute("name")===this.active)}focusOnly(tab){this.focusedTab=tab.slotName,this.focusTab(tab.slotName)}get rovingTab(){if(this.activation!=="manual")return this.active;const candidate=this.tabs.find(t=>t.slotName===this.focusedTab&&this.isNavigable(t));return candidate?candidate.slotName:this.active}keyboardOriginTab(event,navigable){const eventButton=event.composedPath().find(candidate=>candidate.nodeType===1&&candidate.getAttribute?.("part")==="tab"&&candidate.getRootNode()===this.renderRoot),focused=shadowFocusTarget(this),owned=(eventButton??(focused?.getAttribute("part")==="tab"?focused:void 0))?.dataset.slot;return navigable.find(tab=>tab.slotName===owned)??navigable.find(tab=>tab.slotName===this.rovingTab)}focusTab(slotName){const buttons=this.renderRoot.querySelectorAll('[part="tab"]');for(const button of Array.from(buttons))if(button.dataset.slot===slotName){button.focus();return}}get isVertical(){return this.placement==="start"||this.placement==="end"}tabId(slotName){return this.idsFor(slotName).tab}panelId(slotName){return this.idsFor(slotName).panel}idsFor(slotName){const existing=this.idsBySlot.get(slotName);if(existing)return existing;const token=`${this.baseId}-${this.nextOpaqueId++}`,ids={tab:`${token}-tab`,panel:`${token}-panel`};return this.idsBySlot.set(slotName,ids),ids}tabSlotName(slotName){return`${slotName}-tab`}get scrollControlsSuppressed(){return this.withoutScrollControls||this.noScrollControls}measureTabScrollEdges(){const tablist=this.renderRoot.querySelector('[part~="tablist"]');if(!tablist||this.isVertical){this.setTabScrollEdges(!1,!1,tablist);return}const maximum=Math.max(0,tablist.scrollWidth-tablist.clientWidth),position=Math.max(0,Math.min(maximum,this.effectiveDirection==="rtl"?-tablist.scrollLeft:tablist.scrollLeft));this.setTabScrollEdges(position>1,position<maximum-1,tablist)}setTabScrollEdges(start,end,tablist){tablist?.toggleAttribute("data-scroll-start",start),tablist?.toggleAttribute("data-scroll-end",end),!(start===this.scrollStartAvailable&&end===this.scrollEndAvailable)&&(this.scrollStartAvailable=start,this.scrollEndAvailable=end)}scrollTabs(edge){const tablist=this.renderRoot.querySelector('[part~="tablist"]');if(!tablist||!isHtmlElement(tablist)||typeof tablist.scrollBy!="function")return;const step=Math.max(1,tablist.clientWidth*SCROLL_STEP_RATIO),towardEnd=edge==="end"?1:-1,physical=this.effectiveDirection==="rtl"?-towardEnd:towardEnd;tablist.scrollBy({left:step*physical,behavior:prefersReducedMotion(this)?"instant":"smooth"})}renderScrollControl(edge){if(this.isVertical||this.scrollControlsSuppressed)return nothing;const available=edge==="start"?this.scrollStartAvailable:this.scrollEndAvailable;return html`<button
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{resolveListMove}from"../../../internal/list-navigation.js";import{nextId}from"../../../internal/a11y.js";import{composedAccessibilityText}from"../../../internal/accessibility-visibility.js";import{CustomElementUpgradeObserver}from"../../../internal/custom-element-upgrade-observer.js";import{isHtmlElement}from"../../../internal/dom-guards.js";import{chevronIcon}from"../../../internal/icons.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{tag}from"../../../internal/prefix.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{styles}from"./tab-group.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";import{LYRA_DEFAULT_scrollNext,LYRA_DEFAULT_scrollPrevious}from"../../../internal/default-strings/layout.generated.js";function isInertChild(child){return isHtmlElement(child)&&child.inert}function isTabLabelSubtreeExcludedWithoutInert(element){if(element.hasAttribute("hidden")||element.getAttribute("aria-hidden")?.trim().toLowerCase()==="true")return!0;const rendered=element.ownerDocument.defaultView?.getComputedStyle(element);return rendered?.display==="none"||rendered?.contentVisibility==="hidden"}const SYNTHETIC_PANEL_PREFIX="lr-tab-",SCROLL_STEP_RATIO=.8;class LyraTabGroup extends LyraElement{constructor(){super(...arguments),this.active="",this.accessibleLabel=null,this.placement="top",this.activation="auto",this.withoutScrollControls=!1,this.noScrollControls=!1,this.fixedScrollControls=!1,this.tabs=[],this.focusedTab="",this.baseId=nextId("tab-group"),this.nextOpaqueId=0,this.idsBySlot=new Map,this.mutationObserverGeneration=0,this.projectionGeneration=0,this.projectionPending=!1,this.stagingSlotName="tab-group-sources",this.pendingDescriptorUpdates=new WeakSet,this.excludedUnnamedDescriptors=new Set,this.descriptorUpgrades=new CustomElementUpgradeObserver(()=>{this.excludedUnnamedDescriptors.clear(),this.queueProjectionReconciliation()}),this.restoredSourceInertWrites=new Map,this.restoredSlotWrites=new Map,this.projectedSourceSnapshots=new Map,this.projectedSlotSnapshots=new Map,this.projectedSourceObserverGeneration=0,this.rehomeTabFocus=!1,this.scrollStartAvailable=!1,this.scrollEndAvailable=!1,this.scrollOverflow=observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part~="tablist"]'),()=>this.measureTabScrollEdges()),this.queueProjectionReconciliation=()=>{if(!this.isConnected||this.projectionTimer!==void 0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow)return;const generation=this.projectionGeneration;this.beginProjectionSettlement(),this.projectionTimerWindow=ownerWindow,this.projectionTimer=ownerWindow.setTimeout(()=>{generation!==this.projectionGeneration||this.ownerDocument!==ownerDocument||!this.isConnected||(this.projectionTimer=void 0,this.projectionTimerWindow=void 0,this.updateBrowserDerivedState(this.syncTabs))},0)},this.syncTabs=()=>{const children=Array.from(this.children);this.adoptProjectedSourceInertStates(),this.adoptProjectedSlotStates();const projectedSlots=new Set,wasPending=this.projectionPending,next=this.readElementModel(children,projectedSlots);this.syncProjectedSlots(projectedSlots),this.syncProjectedSources(next.filter(tab=>tab.element.parentNode===this));const liveSlots=new Set(next.map(tab=>tab.slotName));for(const slotName of this.idsBySlot.keys())liveSlots.has(slotName)||this.idsBySlot.delete(slotName);(next.length!==this.tabs.length||wasPending&&!this.projectionPending||next.some((tab,index)=>{const previous=this.tabs[index];return tab.element!==previous.element||tab.slotName!==previous.slotName||tab.label!==previous.label||tab.disabled!==previous.disabled||tab.inert!==previous.inert}))&&(this.tabs=next),this.projectionPending||this.projectionTimer!==void 0?this.beginProjectionSettlement():this.settleProjection()},this.onTabListKeyDown=e=>{if(e.altKey||e.ctrlKey||e.metaKey||e.isComposing)return;const navigable=this.tabs.filter(t=>this.isNavigable(t));if(navigable.length===0)return;const origin=this.keyboardOriginTab(e,navigable),currentIndex=origin?navigable.indexOf(origin):-1;if(e.key==="Delete"){if(!origin?.element.closable)return;e.preventDefault(),origin.element.requestCloseFromOwner();return}if(this.activation==="manual"&&(e.key==="Enter"||e.key===" "||e.key==="Spacebar")){if(!origin)return;e.preventDefault(),this.activateTab(origin);return}const targetIndex=resolveListMove(e,{count:navigable.length,current:currentIndex,orientation:this.isVertical?"vertical":"horizontal",direction:this.effectiveDirection});if(targetIndex===null)return;e.preventDefault();const target=navigable[targetIndex];if(this.activation==="manual"){this.focusOnly(target);return}this.activateTab(target),this.focusTab(target.slotName)},this.onTabListScroll=()=>{this.measureTabScrollEdges()},this.onScrollControlMouseDown=event=>{event.preventDefault()},this.onScrollControlPointerDown=event=>{const control=event.currentTarget;control instanceof HTMLElement&&(control.setAttribute("data-pressed",""),control.setPointerCapture(event.pointerId))},this.onScrollControlPointerEnd=event=>{const control=event.currentTarget;control instanceof HTMLElement&&(control.removeAttribute("data-pressed"),control.hasPointerCapture(event.pointerId)&&control.releasePointerCapture(event.pointerId))}}static{this.defaultStrings={...super.defaultStrings,scrollNext:LYRA_DEFAULT_scrollNext,scrollPrevious:LYRA_DEFAULT_scrollPrevious}}static{this.styles=[LyraElement.styles,scrollOverflowFadeStyles,styles]}connectedCallback(){super.connectedCallback(),this.hasUpdated?this.syncTabs():this.seedFirstRenderState(this.syncTabs),this.resetMutationObserver();const ownerDocument=this.ownerDocument,MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor)return;const generation=this.mutationObserverGeneration,observer=new MutationObserverCtor(records=>{if(this.mutationObserver!==observer||this.mutationObserverDocument!==ownerDocument||this.mutationObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument)return;const isDirectChild=node=>node.parentNode===this,isElementTabContent=node=>{let current=node.nodeType===1?node:node.parentElement;for(;current&¤t!==this;){if(current.localName===tag("tab")&¤t.parentNode===this)return!0;current=current.parentElement}return!1},relevant=records.some(record=>{if(record.type==="childList")return record.target===this||isElementTabContent(record.target);if(record.type==="characterData")return isElementTabContent(record.target);if(record.attributeName==="inert"&&this.projectedSourceSnapshots.has(record.target)||record.attributeName==="inert"&&this.restoredSourceInertWrites.has(record.target)&&record.target.getAttribute("inert")===this.restoredSourceInertWrites.get(record.target))return!1;if(record.attributeName==="slot"){if(this.restoredSlotWrites.has(record.target)&&record.target.getAttribute("slot")===this.restoredSlotWrites.get(record.target))return!1;const snapshot=this.projectedSlotSnapshots.get(record.target);if(snapshot&&record.target.getAttribute("slot")===snapshot.appliedSlot)return!1}return isDirectChild(record.target)||isElementTabContent(record.target)});this.restoredSourceInertWrites.clear(),this.restoredSlotWrites.clear(),relevant&&(this.excludedUnnamedDescriptors.clear(),this.syncTabs())});this.mutationObserver=observer,this.mutationObserverDocument=ownerDocument,observer.observe(this,{childList:!0,subtree:!0,attributes:!0,characterData:!0,attributeFilter:["alt","aria-hidden","aria-label","aria-labelledby","class","closable","disabled","hidden","inert","id","label","name","open","panel","slot","style"]})}disconnectedCallback(){this.resetProjectionReconciliation(),this.resetMutationObserver(),this.resetProjectedSourceObserver(),this.restoreProjectedSources(),this.restoreProjectedSlots(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.resetMutationObserver(),this.resetProjectedSourceObserver(),this.resetProjectionReconciliation()}resetProjectionReconciliation(){this.projectionGeneration+=1,this.projectionTimer!==void 0&&this.projectionTimerWindow?.clearTimeout(this.projectionTimer),this.projectionTimer=void 0,this.projectionTimerWindow=void 0,this.projectionPending=!1,this.pendingDescriptorUpdates=new WeakSet,this.descriptorUpgrades.disconnect(),this.restoredSourceInertWrites.clear(),this.restoredSlotWrites.clear(),this.excludedUnnamedDescriptors.clear(),this.settleProjection()}beginProjectionSettlement(){this.projectionSettlement||(this.projectionSettlement=new Promise(resolve=>{this.resolveProjectionSettlement=resolve}))}settleProjection(){const resolve=this.resolveProjectionSettlement;this.resolveProjectionSettlement=void 0,this.projectionSettlement=void 0,resolve?.()}async getUpdateComplete(){const generation=this.projectionGeneration,ownerDocument=this.ownerDocument;let complete=await super.getUpdateComplete();if(this.renderSlotPresence(!1)||!ownerDocument.defaultView)return complete;const current=()=>this.isConnected&&generation===this.projectionGeneration&&this.ownerDocument===ownerDocument;for(;current();){const settlement=this.projectionSettlement;if(settlement){if(await settlement,!current())return complete;complete=await super.getUpdateComplete()}else if(this.isUpdatePending)complete=await super.getUpdateComplete();else return complete}return complete}waitForDescriptorUpdate(tab){if(tab.hasUpdated===!0)return!1;const updateComplete=tab.updateComplete;if(updateComplete==null)return this.descriptorUpgrades.observeElement(tab),!1;if(!this.pendingDescriptorUpdates.has(tab)){this.pendingDescriptorUpdates.add(tab);const generation=this.projectionGeneration,ownerDocument=this.ownerDocument;updateComplete.then(()=>{generation===this.projectionGeneration&&this.ownerDocument===ownerDocument&&(this.pendingDescriptorUpdates.delete(tab),tab.parentNode===this&&this.queueProjectionReconciliation())})}return!0}resetMutationObserver(){this.mutationObserverGeneration+=1,this.mutationObserver?.disconnect(),this.mutationObserver=void 0,this.mutationObserverDocument=void 0}readElementModel(children,projectedSlots){this.projectionPending=!1;const seen=new Set,next=[],panelsByName=new Map;for(const child of children){if(child.localName!==tag("tab-panel"))continue;const name=child.getAttribute("name");name!==null&&!panelsByName.has(name)&&panelsByName.set(name,child)}const authoredNames=new Set(children.flatMap(child=>{if(child.localName===tag("tab")){const name=child.getAttribute("panel");return name?[name]:[]}if(child.localName===tag("tab-panel")){const name=child.getAttribute("name");return name?[name]:[]}return[]}));let stagingName="tab-group-sources";for(;authoredNames.has(stagingName);)stagingName+="-sources";this.stagingSlotName=stagingName;let index=0;for(const child of children){if(child.localName!==tag("tab"))continue;const authoredPanel=child.getAttribute("panel")||void 0;let slotName=authoredPanel??`${SYNTHETIC_PANEL_PREFIX}${index}`;if(!authoredPanel){let collision=0;for(;authoredNames.has(slotName)||seen.has(slotName);)collision+=1,slotName=`${SYNTHETIC_PANEL_PREFIX}${index}-${collision}`}if(index+=1,seen.has(slotName))continue;seen.add(slotName);const tabSlot=this.tabSlotName(slotName),assignedSlot=child.assignedSlot,assignedHere=assignedSlot?.getRootNode()===this.renderRoot&&(assignedSlot.name===tabSlot||assignedSlot.name===this.stagingSlotName);if(!assignedHere||!authoredPanel&&this.excludedUnnamedDescriptors.has(child)){this.projectSlot(child,this.stagingSlotName,projectedSlots),assignedHere||(this.projectionPending=!0);continue}if(this.waitForDescriptorUpdate(child)){this.projectionPending=!0,this.projectSlot(child,this.stagingSlotName,projectedSlots);continue}const visibleLabel=this.readElementLabel(child);if(!authoredPanel&&!visibleLabel){this.excludedUnnamedDescriptors.add(child),this.projectSlot(child,this.stagingSlotName,projectedSlots);continue}projectedSlots.add(child);const label=visibleLabel||slotName,panel=panelsByName.get(slotName);panel&&this.projectSlot(panel,slotName,projectedSlots),next.push({slotName,label,disabled:child.hasAttribute("disabled"),inert:isInertChild(child),element:child}),!this.active&&child.hasAttribute("active")&&(this.active=slotName)}if(this.projectionPending){for(const child of children)this.projectedSlotSnapshots.has(child)&&projectedSlots.add(child);return this.tabs}for(const tab of next)this.projectSlot(tab.element,this.tabSlotName(tab.slotName),projectedSlots);return next}readElementLabel(tab){const labelNodes=Array.from(tab.childNodes).filter(node=>node.nodeType!==Node.ELEMENT_NODE||node.getAttribute("slot")===null||node.getAttribute("slot")==="");return composedAccessibilityText(labelNodes,{ancestorBoundary:tab,isSubtreeExcluded:element=>this.isTabLabelSubtreeExcluded(element),ignoreInheritedVisibility:!0}).replace(/\s+/g," ").trim()}libraryOwnsSourceInert(element){return this.projectedSourceSnapshots.get(element)?.libraryOwnsInert===!0}isTabLabelSubtreeExcluded(element){return isTabLabelSubtreeExcludedWithoutInert(element)||element.hasAttribute("inert")&&!this.libraryOwnsSourceInert(element)}snapshotProjectedSource(source){const inert=source.getAttribute("inert");return{inert,appliedInert:inert,libraryOwnsInert:!1}}adoptProjectedSourceInert(source,snapshot){const current=source.getAttribute("inert");current!==snapshot.appliedInert&&(snapshot.inert=current,snapshot.libraryOwnsInert=!1)}makeProjectedSourceInert(source,snapshot){source.hasAttribute("inert")||(source.setAttribute("inert",""),snapshot.libraryOwnsInert=!0),snapshot.appliedInert=source.getAttribute("inert")}restoreProjectedSource(source,snapshot){this.adoptProjectedSourceInert(source,snapshot);const before=source.getAttribute("inert");snapshot.inert===null?source.removeAttribute("inert"):source.setAttribute("inert",snapshot.inert),this.mutationObserver&&this.contains(source)&&source.getAttribute("inert")!==before&&this.restoredSourceInertWrites.set(source,source.getAttribute("inert"))}restoreProjectedSources(){for(const[source,snapshot]of this.projectedSourceSnapshots)this.restoreProjectedSource(source,snapshot);this.projectedSourceSnapshots.clear()}resetProjectedSourceObserver(){this.projectedSourceObserverGeneration+=1,this.projectedSourceObserver?.disconnect(),this.projectedSourceObserver=void 0,this.projectedSourceObserverDocument=void 0}observeProjectedSources(){this.resetProjectedSourceObserver();const ownerDocument=this.ownerDocument,MutationObserverCtor=ownerDocument.defaultView?.MutationObserver;if(!MutationObserverCtor||!this.isConnected||this.projectedSourceSnapshots.size===0)return;const generation=this.projectedSourceObserverGeneration,observer=new MutationObserverCtor(records=>{this.projectedSourceObserver!==observer||this.projectedSourceObserverDocument!==ownerDocument||this.projectedSourceObserverGeneration!==generation||!this.isConnected||this.ownerDocument!==ownerDocument||records.some(record=>this.projectedSourceSnapshots.has(record.target))&&this.syncTabs()});this.projectedSourceObserver=observer,this.projectedSourceObserverDocument=ownerDocument;for(const source of this.projectedSourceSnapshots.keys())observer.observe(source,{attributes:!0,attributeFilter:["inert"]})}projectedSources(tabs){const sources=new Set;for(const tab of tabs)for(const child of Array.from(tab.element.children))(child.getAttribute("slot")??"")===""&&sources.add(child);return sources}syncProjectedSources(tabs){const sources=this.projectedSources(tabs);for(const[source,snapshot]of this.projectedSourceSnapshots)this.adoptProjectedSourceInert(source,snapshot),sources.has(source)||(this.restoreProjectedSource(source,snapshot),this.projectedSourceSnapshots.delete(source));for(const source of sources){const snapshot=this.projectedSourceSnapshots.get(source)??this.snapshotProjectedSource(source);this.projectedSourceSnapshots.set(source,snapshot),this.adoptProjectedSourceInert(source,snapshot),this.makeProjectedSourceInert(source,snapshot)}this.observeProjectedSources()}adoptProjectedSourceInertStates(){for(const[source,snapshot]of this.projectedSourceSnapshots)this.adoptProjectedSourceInert(source,snapshot)}snapshotProjectedSlot(source){const slot=source.getAttribute("slot");return{slot,appliedSlot:slot,libraryOwnsSlot:!1}}adoptProjectedSlot(source,snapshot){const current=source.getAttribute("slot");current!==snapshot.appliedSlot&&(snapshot.slot=current,snapshot.libraryOwnsSlot=!1)}projectSlot(source,slot,projectedSlots){const snapshot=this.projectedSlotSnapshots.get(source)??this.snapshotProjectedSlot(source);this.projectedSlotSnapshots.set(source,snapshot),this.adoptProjectedSlot(source,snapshot),source.getAttribute("slot")!==slot&&(source.setAttribute("slot",slot),snapshot.libraryOwnsSlot=!0),snapshot.appliedSlot=source.getAttribute("slot"),projectedSlots.add(source)}restoreProjectedSlot(source,snapshot){this.adoptProjectedSlot(source,snapshot);const before=source.getAttribute("slot");snapshot.slot===null?source.removeAttribute("slot"):source.setAttribute("slot",snapshot.slot),this.mutationObserver&&this.contains(source)&&source.getAttribute("slot")!==before&&this.restoredSlotWrites.set(source,source.getAttribute("slot"))}syncProjectedSlots(projectedSlots){for(const[source,snapshot]of this.projectedSlotSnapshots)projectedSlots.has(source)||(this.restoreProjectedSlot(source,snapshot),this.projectedSlotSnapshots.delete(source))}restoreProjectedSlots(){for(const[source,snapshot]of this.projectedSlotSnapshots)this.restoreProjectedSlot(source,snapshot);this.projectedSlotSnapshots.clear()}adoptProjectedSlotStates(){for(const[source,snapshot]of this.projectedSlotSnapshots)this.adoptProjectedSlot(source,snapshot)}isNavigable(tab){return!tab.disabled&&!tab.inert}willUpdate(changed){if(super.willUpdate(changed),this.projectionPending||!changed.has("tabs")&&!changed.has("active"))return;const focused=shadowFocusTarget(this),focusedSlot=focused?.getAttribute("part")==="tab"?focused.getAttribute("data-slot"):null;focusedSlot!==null&&!this.tabs.some(tab=>tab.slotName===focusedSlot&&this.isNavigable(tab))&&(this.rehomeTabFocus=!0,this.focusedTab=this.active);const current=this.tabs.find(t=>t.slotName===this.active);if(current&&this.isNavigable(current))return;this.rehomeTabFocus=this.rehomeTabFocus||focusedSlot!==null;const outgoing=this.active,before=changed.get("tabs")??this.tabs,at=this.hasUpdated&&changed.has("tabs")&&!changed.has("active")?before.findIndex(t=>t.slotName===outgoing):-1,renamed=at<0?void 0:this.tabs.find(t=>t.element===before[at].element&&this.isNavigable(t));let candidates=this.tabs;if(at>=0){const liveByName=new Map;for(const tab of this.tabs)liveByName.has(tab.slotName)||liveByName.set(tab.slotName,tab);candidates=[...before.slice(at+1),...before.slice(0,at).reverse()].map(tab=>liveByName.get(tab.slotName))}this.active=(renamed??candidates.find(t=>t&&this.isNavigable(t)))?.slotName??"",this.focusedTab=this.active,at>=0&&!renamed&&(this.emit("lr-tab-hide",{name:outgoing}),this.active&&this.emit("lr-tab-show",{name:this.active}))}updated(changed){super.updated(changed),changed.has("tabs")&&this.queueProjectionReconciliation(),!this.projectionPending&&(changed.has("active")||changed.has("tabs"))&&this.syncElementActiveState(),this.scrollOverflow.observeExtra(this.renderRoot.querySelectorAll('[part="tab"]')),this.measureTabScrollEdges(),this.rehomeTabFocus&&(this.rehomeTabFocus=!1,this.renderRoot.querySelector('[part="tab"][tabindex="0"]')?.focus())}selectTab(tab){if(!this.isNavigable(tab)||tab.slotName===this.active)return;const previous=this.active;this.active=tab.slotName,this.focusedTab=tab.slotName,previous&&this.emit("lr-tab-hide",{name:previous}),this.emit("lr-tab-show",{name:tab.slotName})}activateTab(tab){this.isNavigable(tab)&&(this.selectTab(tab),this.emit("lr-activate",{value:tab.slotName}))}show(panel){const tab=this.tabs.find(candidate=>candidate.slotName===panel);tab&&this.selectTab(tab)}syncElementActiveState(){const definitions=new Map;for(const tab of this.tabs)definitions.has(tab.element)||definitions.set(tab.element,tab);for(const child of Array.from(this.children))if(child.localName===tag("tab")){const definition=definitions.get(child);child.toggleAttribute("active",definition?.slotName===this.active)}else child.localName===tag("tab-panel")&&child.toggleAttribute("active",child.getAttribute("name")===this.active)}focusOnly(tab){this.focusedTab=tab.slotName,this.focusTab(tab.slotName)}get rovingTab(){if(this.activation!=="manual")return this.active;const candidate=this.tabs.find(t=>t.slotName===this.focusedTab&&this.isNavigable(t));return candidate?candidate.slotName:this.active}keyboardOriginTab(event,navigable){const eventButton=event.composedPath().find(candidate=>candidate.nodeType===1&&candidate.getAttribute?.("part")==="tab"&&candidate.getRootNode()===this.renderRoot),focused=shadowFocusTarget(this),owned=(eventButton??(focused?.getAttribute("part")==="tab"?focused:void 0))?.dataset.slot;return navigable.find(tab=>tab.slotName===owned)??navigable.find(tab=>tab.slotName===this.rovingTab)}focusTab(slotName){const buttons=this.renderRoot.querySelectorAll('[part="tab"]');for(const button of Array.from(buttons))if(button.dataset.slot===slotName){button.focus();return}}get isVertical(){return this.placement==="start"||this.placement==="end"}tabId(slotName){return this.idsFor(slotName).tab}panelId(slotName){return this.idsFor(slotName).panel}idsFor(slotName){const existing=this.idsBySlot.get(slotName);if(existing)return existing;const token=`${this.baseId}-${this.nextOpaqueId++}`,ids={tab:`${token}-tab`,panel:`${token}-panel`};return this.idsBySlot.set(slotName,ids),ids}tabSlotName(slotName){return`${slotName}-tab`}get scrollControlsSuppressed(){return this.withoutScrollControls||this.noScrollControls}measureTabScrollEdges(){const tablist=this.renderRoot.querySelector('[part~="tablist"]');if(!tablist||this.isVertical){this.setTabScrollEdges(!1,!1,tablist);return}const maximum=Math.max(0,tablist.scrollWidth-tablist.clientWidth),position=Math.max(0,Math.min(maximum,this.effectiveDirection==="rtl"?-tablist.scrollLeft:tablist.scrollLeft));this.setTabScrollEdges(position>1,position<maximum-1,tablist)}setTabScrollEdges(start,end,tablist){tablist?.toggleAttribute("data-scroll-start",start),tablist?.toggleAttribute("data-scroll-end",end),!(start===this.scrollStartAvailable&&end===this.scrollEndAvailable)&&(this.scrollStartAvailable=start,this.scrollEndAvailable=end)}scrollTabs(edge){const tablist=this.renderRoot.querySelector('[part~="tablist"]');if(!tablist||!isHtmlElement(tablist)||typeof tablist.scrollBy!="function")return;const step=Math.max(1,tablist.clientWidth*SCROLL_STEP_RATIO),towardEnd=edge==="end"?1:-1,physical=this.effectiveDirection==="rtl"?-towardEnd:towardEnd;tablist.scrollBy({left:step*physical,behavior:prefersReducedMotion(this)?"instant":"smooth"})}renderScrollControl(edge){if(this.isVertical||this.scrollControlsSuppressed)return nothing;const available=edge==="start"?this.scrollStartAvailable:this.scrollEndAvailable;return html`<button
|
|
2
2
|
type="button"
|
|
3
3
|
part=${edge==="start"?"scroll-button scroll-button__base scroll-button-start scroll-button--start":"scroll-button scroll-button__base scroll-button-end scroll-button--end"}
|
|
4
4
|
tabindex="-1"
|
|
@@ -261,12 +261,13 @@ protected static readonly identityCollectionObjectProperties:readonly string[];s
|
|
|
261
261
|
/**
|
|
262
262
|
* The full (non-windowed) item collection. Preserved as the array-compatible source when
|
|
263
263
|
* `source` is unset.
|
|
264
|
+
* Assign a new array to update: mutating an array and assigning it again does not.
|
|
264
265
|
*/
|
|
265
266
|
items:readonly unknown[];
|
|
266
267
|
/**
|
|
267
268
|
* A readonly array or count/index-backed collection. An array assignment is copied, bounded,
|
|
268
|
-
* and frozen while retaining each generic row's identity;
|
|
269
|
-
* changes. Indexed-source objects pass through by identity. When set, this takes precedence over
|
|
269
|
+
* and frozen while retaining each generic row's identity; assign a new array after sequence
|
|
270
|
+
* changes (assigning the same mutated array does not update). Indexed-source objects pass through by identity. When set, this takes precedence over
|
|
270
271
|
* `items`; an indexed source lets synthetic or remote models expose a large row count without
|
|
271
272
|
* allocating an `Array(0…count)` merely to feed the virtualizer. After mutating an indexed
|
|
272
273
|
* source's count or callback closures, call `requestUpdate()` to refresh identities, active-key
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{devWarnOnce}from"../../../internal/dev-warning.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{VirtualListCompositionController}from"../../../internal/virtual-list-composition.js";import{html,nothing,render}from"lit";import{html as staticHtml,unsafeStatic}from"lit/static-html.js";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{literalSetConverter}from"../../../internal/converters.js";import{tag}from"../../../internal/prefix.js";import{VIRTUAL_LIST_ROW_ATTRIBUTE}from"./virtual-list-attributes.js";import{VIRTUAL_LIST_ROW_ATTRIBUTE as VIRTUAL_LIST_ROW_ATTRIBUTE2,VIRTUAL_LIST_STICKY_ATTRIBUTE}from"./virtual-list-attributes.js";import{MAX_OVERSCAN_ROWS}from"./virtual-list-limits.js";import{MAX_OVERSCAN_ROWS as MAX_OVERSCAN_ROWS2}from"./virtual-list-limits.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{nativePopoverSupported}from"../../../internal/native-popover.js";import{finiteAdd,finiteCount,finiteInteger,finiteNumber}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{composedParentElement,deepActiveElementIn}from"../../../internal/active-element.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{styles}from"./virtual-list.styles.js";const DEFAULT_ROW_ESTIMATE_PX=48,MAX_SCROLL_EXTENT_PX=8e6,DEFAULT_GROUP_ESTIMATE_PX=32,DEFAULT_OVERSCAN_ROWS=6,MAX_VIRTUAL_LIST_GROUPS=1e4,EMPTY_VIRTUAL_LIST_GROUPS=Object.freeze([]);function normalizeOverscan(value){if(value===null)return DEFAULT_OVERSCAN_ROWS;const numeric=typeof value=="number"?value:Number(value);return Number.isFinite(numeric)?Math.min(MAX_OVERSCAN_ROWS,Math.max(0,Math.floor(numeric))):DEFAULT_OVERSCAN_ROWS}const overscanConverter={fromAttribute(value){return normalizeOverscan(value)}};function virtualListGroupsChanged(value,oldValue){if(value===oldValue)return!1;const next=value,previous=oldValue;if(next==null||previous==null)return next!==previous;if(next.length!==previous.length)return!0;for(let index=0;index<next.length;index+=1){const a=next[index],b=previous[index];if(a.key!==b.key||a.label!==b.label||a.startIndex!==b.startIndex)return!0}return!1}const ROW_PROJECTION=literalSetConverter(["shadow","light"],"shadow"),ROW_ATTRIBUTE_STATIC=unsafeStatic(VIRTUAL_LIST_ROW_ATTRIBUTE),PROJECTION_ANCHOR_MARKER=`${tag("virtual-list")}-projection`;function normalizeRowHeight(value){if(value==="auto")return"auto";const numeric=typeof value=="number"?value:Number(value);return Number.isFinite(numeric)&&numeric>0?numeric:"auto"}const rowHeightConverter={fromAttribute(value){return value===null?"auto":normalizeRowHeight(value)}};function isIndexedSource(source){return!Array.isArray(source)}function sameSequence(a,b){return Array.isArray(a)&&Array.isArray(b)&&a.length===b.length&&a.every((item,index)=>item===b[index])}const ELEMENT_NODE_TYPE=1;function isWindowScroller(target){return target.window===target}function domKeyToken(key){if(typeof key=="number"){if(Number.isNaN(key))return"number:NaN";if(Object.is(key,-0))return"number:-0"}return`${typeof key}:${String(key)}`}const SCROLL_KEYS=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);class LyraVirtualList extends LyraElement{constructor(){super(...arguments),this.items=[],this.renderItem=()=>nothing,this.rowHeight="auto",this.itemRole="listitem",this._rowProjection="shadow",this.rowIndexOffset=0,this.overscan=DEFAULT_OVERSCAN_ROWS,this.activeItemId="",this.loading=!1,this.hasMore=!1,this.partCache=new Map,this.invalidateExternalGeometry=()=>{this.externalGeometry=void 0,this.isConnected&&this.syncExternalScrollMetrics()},this.scrollMetricsRefreshPending=!1,this.containerScrollTop=0,this.viewportHeight=0,this.renderUnmeasuredWindow=!0,this.offsets=[0],this.offsetDirtyStart=0,this.appendIdentityStart=-1,this.identityIndices=new Map,this.keyIndices=new Map,this.keyOccurrences=new Map,this.groupPrefixDirty=!0,this.rowKeys=[],this.rowIdentities=[],this.fixedRowHeight=null,this.measuredHeights=new Map,this.measuredIndices=new Map,this.indexedMeasurementIndices=[],this.indexedMeasurementDeltaPrefix=[0],this.indexedMeasurementIndexDirty=!0,this.offsetsDirty=!0,this.identitiesDirty=!0,this.itemsChangedPendingPrune=!1,this.compositionVersion=0,this.composition=new VirtualListCompositionController(this,()=>{const previous=this.compositionVersion;this.compositionVersion++,this.composition.profile||(this.compositionScrollTarget=void 0),this.requestUpdate("compositionVersion",previous)}),this.renderStart=0,this.renderEnd=-1,this.pinnedRow=-1,this.renderedWindow=[],this.rowElements=new Map,this.groupElements=new Map,this.projectionDeferred=!0,this.releaseRowProjection=()=>{this.projectionDeferred=!1,super.requestUpdate()},this.visibleStart=0,this.visibleEnd=-1,this.lastEmittedStart=-1,this.lastEmittedEnd=-1,this.loadMoreArmed=!0,this.measurementGeneration=0,this.isFirstUpdate=!0,this.stickyHeight=0,this.noTopLayer=!1,this.observedRows=new Map,this.observedRowKeys=new WeakMap,this.observedRowIndices=new WeakMap,this.observedGroups=new Map,this.observedGroupIndices=new WeakMap,this.externalMetricsPending=!1,this.ownerRealmGeneration=0,this.inResizeDelivery=!1,this.pendingRowMeasurements=new Map,this.pendingGroupMeasurements=new Map,this.deferredRowObservations=new Map,this.deferredGroupObservations=new Map,this.activeIndexForLength=-1,this.activeIndexForId="",this.activeIndexCache=-1,this.pendingScrollTop=null,this.normalizedGroups=EMPTY_VIRTUAL_LIST_GROUPS,this.normalizedGroupByIndex=new Map,this.measuredGroupHeights=new Map,this.groupHeightPrefix=[0],this.contentRefreshPending=!1,this.onExternalViewportResize=()=>{this.externalGeometry=void 0,this.syncExternalScrollMetrics()},this.onUserScrollIntent=event=>{event instanceof KeyboardEvent&&!SCROLL_KEYS.has(event.key)||(this.pendingScrollCorrection=void 0,this.compositionScrollTarget=void 0,this.scrollRoundingAnchor=void 0)},this.onScroll=e=>{if(this.externalScroller?(this.pendingScrollTop=null,this.externalMetricsPending=!0):this.pendingScrollTop=this.logicalScroll(e.currentTarget.scrollTop),this.scrollRafId!==void 0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow||!this.isConnected)return;const generation=this.ownerRealmGeneration,handle=ownerWindow.requestAnimationFrame(()=>{if(!(this.scrollRafId!==handle||this.scrollRafOwner!==ownerWindow||this.scrollRafDocument!==ownerDocument||!this.isCurrentOwnerWork(ownerDocument,generation))){if(this.scrollRafId=void 0,this.scrollRafOwner=void 0,this.scrollRafDocument=void 0,this.externalMetricsPending){this.externalMetricsPending=!1;const metrics=this.readScrollMetrics();metrics&&(this.pendingScrollTop=metrics.scrollTop,this.viewportHeight!==metrics.viewportHeight&&(this.viewportHeight=metrics.viewportHeight))}if(this.pendingScrollTop!==null){const scrollTop=this.pendingScrollTop;this.pendingScrollTop=null;const moved=this.containerScrollTop!==scrollTop;this.containerScrollTop=scrollTop,moved&&this.emit("lr-virtual-scroll",{scrollTop,viewportHeight:this.viewportHeight})}}});this.scrollRafId=handle,this.scrollRafOwner=ownerWindow,this.scrollRafDocument=ownerDocument},this.onRowsResized=entries=>{if(this.beginResizeDelivery(),this.fixedRowHeight==null){for(const entry of entries){const row=entry.target,key=this.observedRowKeys.get(row),index=this.observedRowIndices.get(row);if(key===void 0||index===void 0)continue;const height=entry.borderBoxSize?.[0]?.blockSize??entry.target.getBoundingClientRect().height;this.pendingRowMeasurements.set(key,{index,height})}this.defersMeasurementApplication||this.applyPendingRowMeasurements()}},this.onGroupsResized=entries=>{this.beginResizeDelivery();for(const entry of entries){const marker=entry.target,index=this.observedGroupIndices.get(marker);if(index===void 0||!this.normalizedGroupByIndex.has(index))continue;const height=entry.borderBoxSize?.[0]?.blockSize??entry.target.getBoundingClientRect().height;!Number.isFinite(height)||height<0||this.pendingGroupMeasurements.set(index,height)}this.defersMeasurementApplication||this.applyPendingGroupMeasurements()},this.onFocusOut=event=>{const next=event.relatedTarget;this.pinnedRow>=0&&!(next&&(this.contains(next)||this.renderRoot.contains(next)))&&super.requestUpdate()},this.onStickyResized=entries=>{this.beginResizeDelivery();const entry=entries[0];if(!entry)return;const height=entry.borderBoxSize?.[0]?.blockSize??entry.contentRect.height;Math.abs(this.stickyHeight-height)>.5&&(this.stickyHeight=height)}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["items","source","groups"])}static{this.identityCollectionProperties=Object.freeze(["items","source"])}static{this.identityCollectionObjectProperties=Object.freeze(["source"])}static{this.styles=[LyraElement.styles,styles]}get rowProjection(){return this._rowProjection}set rowProjection(next){const normalized=ROW_PROJECTION.normalize(next),previous=this._rowProjection;previous!==normalized&&(this._rowProjection=normalized,this.requestUpdate("rowProjection",previous))}get scrollContainer(){return this.cachedPart("base")}cachedPart(name){let element=this.partCache.get(name);return element?.isConnected||(element=this.renderRoot?.querySelector(`[part="${name}"]`)??void 0,element?this.partCache.set(name,element):this.partCache.delete(name)),element}get renderedRows(){const root=this.renderRoot;return root?[...root.querySelectorAll('[part="row"]')]:[]}get projectedRows(){const rows=[];for(const child of this.children)child.hasAttribute(VIRTUAL_LIST_ROW_ATTRIBUTE)&&rows.push(child);return rows}get externalScroller(){const target=this.scrollElement;if(target!=null)return isWindowScroller(target)||target.nodeType===ELEMENT_NODE_TYPE?target:void 0}get spacerElement(){return this.cachedPart("spacer")}scrollScale(viewport=this.viewportHeight){const total=this.offsetAt(this.itemCount);return total<=MAX_SCROLL_EXTENT_PX?1:Math.max(1,(total-viewport)/Math.max(1,MAX_SCROLL_EXTENT_PX-viewport))}logicalScroll(physical,viewport=this.viewportHeight){if(this.scrollRoundingAnchor){if(Math.abs(physical-this.scrollRoundingAnchor.physical)<.01)return this.scrollRoundingAnchor.logical;this.scrollRoundingAnchor=void 0}return physical<0?physical:physical*this.scrollScale(viewport)}physicalScroll(logical,viewport=this.viewportHeight){return logical<0?logical:logical/this.scrollScale(viewport)}physicalRowOffset(logical){return this.scrollScale()===1?logical:(this.scrollRoundingAnchor?.logical===this.containerScrollTop?this.scrollRoundingAnchor.physical:this.physicalScroll(this.containerScrollTop))+logical-this.containerScrollTop}captureScrollRounding(logical){this.scrollRoundingAnchor=void 0;const metrics=this.readPhysicalScrollMetrics();if(!metrics||this.scrollScale(metrics.viewportHeight)===1)return;const physical=this.physicalScroll(logical,metrics.viewportHeight);Math.abs(physical-metrics.rawScrollTop)<=1.1&&(this.scrollRoundingAnchor={physical:metrics.rawScrollTop,logical})}readScrollMetrics(){const metrics=this.readPhysicalScrollMetrics();if(!metrics)return metrics;const rawScrollTop=this.logicalScroll(metrics.rawScrollTop,metrics.viewportHeight);return{...metrics,rawScrollTop,scrollTop:Math.max(0,rawScrollTop)}}readPhysicalScrollMetrics(){const base=this.scrollContainer;if(!base)return null;const external=this.externalScroller;if(!external)return{scrollTop:base.scrollTop,rawScrollTop:base.scrollTop,viewportHeight:base.clientHeight,scrollDeltaScale:1};const spacer=this.spacerElement??base,spacerRect=spacer.getBoundingClientRect(),extent=this.offsetAt(this.itemCount),cached=this.externalGeometry,valid=cached?.spacer===spacer&&cached.external===external&&cached.height===spacerRect.height&&cached.extent===extent,spacerScale=valid?cached.spacerScale:this.visualBlockScale(spacer,spacerRect),spacerTop=spacerRect.top;if(isWindowScroller(external)){this.externalGeometry={spacer,external,height:spacerRect.height,extent,spacerScale,scrollerScale:1,borderTop:0};const documentHeight=finiteNumber(external.document?.documentElement?.clientHeight??0,0),rawScrollTop2=finiteNumber(-spacerTop/spacerScale,0);return{scrollTop:Math.max(0,rawScrollTop2),rawScrollTop:rawScrollTop2,viewportHeight:(documentHeight>0?documentHeight:finiteNumber(external.innerHeight,0))/spacerScale,scrollDeltaScale:spacerScale}}const scrollerRect=external.getBoundingClientRect(),relativeScale=valid?null:this.relativeBlockScale(spacer,external),inferredScrollerScale=relativeScale===null?0:spacerScale/relativeScale,scrollerScale=valid?cached.scrollerScale:Number.isFinite(inferredScrollerScale)&&inferredScrollerScale>0?inferredScrollerScale:this.visualBlockScale(external,scrollerRect),scrollerStyle=valid?void 0:external.ownerDocument.defaultView?.getComputedStyle(external),borderTop=valid?cached.borderTop:Number.parseFloat(scrollerStyle?.borderTopWidth??"");this.externalGeometry={spacer,external,height:spacerRect.height,extent,spacerScale,scrollerScale,borderTop};const scrollerTop=scrollerRect.top+(Number.isFinite(borderTop)?borderTop:external.clientTop)*scrollerScale,rawScrollTop=finiteNumber((scrollerTop-spacerTop)/spacerScale,0);return{scrollTop:Math.max(0,rawScrollTop),rawScrollTop,viewportHeight:finiteNumber(external.clientHeight*scrollerScale/spacerScale,0),scrollDeltaScale:spacerScale/scrollerScale}}visualBlockScale(element,rect){const style=element.ownerDocument.defaultView?.getComputedStyle(element);if(!style)return 1;const borderBoxHeight=Number.parseFloat(style.height)+(style.boxSizing==="border-box"?0:Number.parseFloat(style.paddingTop)+Number.parseFloat(style.paddingBottom)+Number.parseFloat(style.borderTopWidth)+Number.parseFloat(style.borderBottomWidth)),layoutHeight=borderBoxHeight>0&&Number.isFinite(borderBoxHeight)?borderBoxHeight:"offsetHeight"in element&&typeof element.offsetHeight=="number"?element.offsetHeight:0,scale=rect.height/layoutHeight;return scale>0&&Number.isFinite(scale)?scale:1}relativeBlockScale(descendant,ancestor){let scale=1,current=descendant;for(;current&¤t!==ancestor;){const style=current.ownerDocument.defaultView?.getComputedStyle(current);if(!style)return null;const zoom=style.zoom?style.zoom.endsWith("%")?Number.parseFloat(style.zoom)/100:Number.parseFloat(style.zoom):1;if(!Number.isFinite(zoom)||zoom<=0)return null;scale*=zoom;const transformable=style.display!=="contents"&&style.display!=="inline";if(transformable&&style.scale&&style.scale!=="none"){const values=style.scale.split(/\s+/).map(Number),blockScale=values[1]??values[0]??Number.NaN;if(!Number.isFinite(blockScale)||blockScale<=0)return null;scale*=blockScale}if(transformable&&style.rotate&&style.rotate!=="none"&&style.rotate!=="0deg")return null;if(transformable&&style.transform!=="none"){const Matrix=current.ownerDocument.defaultView?.DOMMatrixReadOnly;if(!Matrix)return null;const matrix=new Matrix(style.transform);if(matrix.m12!==0||matrix.m13!==0||matrix.m14!==0||matrix.m21!==0||matrix.m23!==0||matrix.m24!==0||matrix.m31!==0||matrix.m32!==0||matrix.m34!==0||matrix.m44!==1||matrix.m22<=0)return null;scale*=matrix.m22}const parent=current.assignedSlot??current.parentNode;current=parent?.nodeType===Node.ELEMENT_NODE?parent:parent?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in parent?parent.host:null}return current===ancestor&&Number.isFinite(scale)&&scale>0?scale:null}applyScrollPosition(top,behavior){const external=this.externalScroller;if(!external){const base=this.scrollContainer;if(!base)return;const next2=Math.max(0,this.physicalScroll(finiteNumber(top,0),base.clientHeight));behavior===void 0?base.scrollTop=next2:base.scrollTo({top:next2,behavior}),behavior!=="smooth"&&(this.captureScrollRounding(top),this.scheduleScrollMetricsRefresh());return}const metrics=this.readPhysicalScrollMetrics();if(!metrics)return;const delta=(this.physicalScroll(finiteNumber(top,metrics.rawScrollTop),metrics.viewportHeight)-metrics.rawScrollTop)*metrics.scrollDeltaScale;if(isWindowScroller(external)){const options={top:Math.max(0,finiteNumber(external.scrollY+delta,0))};behavior!==void 0&&(options.behavior=behavior),external.scrollTo(options),behavior!=="smooth"&&(this.captureScrollRounding(top),this.scheduleScrollMetricsRefresh());return}const next=Math.max(0,finiteNumber(external.scrollTop+delta,0));behavior===void 0?external.scrollTop=next:external.scrollTo({top:next,behavior}),behavior!=="smooth"&&(this.captureScrollRounding(top),this.scheduleScrollMetricsRefresh())}scheduleScrollMetricsRefresh(){if(this.scrollMetricsRefreshPending)return;this.scrollMetricsRefreshPending=!0;const owner=this.ownerDocument.defaultView;queueMicrotask(()=>{this.scrollMetricsRefreshPending=!1,this.isConnected&&this.ownerDocument.defaultView===owner&&this.syncExternalScrollMetrics()})}syncExternalScrollMetrics(){const metrics=this.readScrollMetrics();metrics&&(this.viewportHeight!==metrics.viewportHeight&&(this.viewportHeight=metrics.viewportHeight),this.containerScrollTop!==metrics.scrollTop&&(this.containerScrollTop=metrics.scrollTop))}get safeRowIndexOffset(){return finiteCount(this.rowIndexOffset)}computedAriaRowIndex(index){return finiteInteger(finiteAdd(index+1,this.safeRowIndexOffset),1,1,Number.MAX_SAFE_INTEGER)}get activeIndex(){if(this.activeItemId==="")return-1;const source=this.effectiveSource,count=this.itemCount;if(this.activeIndexFor===source&&this.activeIndexForLength===count&&Object.is(this.activeIndexForId,this.activeItemId)&&this.activeIndexForKeyFn===this.keyFunction)return this.activeIndexCache;if(this.activeIndexFor=source,this.activeIndexForLength=count,this.activeIndexForId=this.activeItemId,this.activeIndexForKeyFn=this.keyFunction,this.activeIndexCache=-1,isIndexedSource(source)){if(!this.keyFunction&&source.indexOfKey){const candidate=source.indexOfKey(this.activeItemId);Number.isInteger(candidate)&&candidate>=0&&candidate<count&&(this.activeIndexCache=candidate)}return this.activeIndexCache}return this.activeIndexCache=this.keyIndices.get(domKeyToken(this.activeItemId))??-1,this.activeIndexCache}connectedCallback(){super.connectedCallback(),this.ownerDocument.defaultView&&(this.seedFirstRenderState(()=>{this.renderUnmeasuredWindow=!1,super.requestUpdate()}),this.seedFirstRenderState(this.releaseRowProjection),this.hasUpdated&&(this.projectionDeferred=!1)),this.resetOwnerRealmWork();const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView,generation=this.ownerRealmGeneration,ResizeObserverCtor=ownerWindow?.ResizeObserver;if(ResizeObserverCtor){const rowObserver=new ResizeObserverCtor(entries=>{this.rowResizeObserver!==rowObserver||!this.isCurrentOwnerWork(ownerDocument,generation)||this.onRowsResized(entries)}),groupObserver=new ResizeObserverCtor(entries=>{this.groupResizeObserver!==groupObserver||!this.isCurrentOwnerWork(ownerDocument,generation)||this.onGroupsResized(entries)}),stickyObserver=new ResizeObserverCtor(entries=>{this.stickyResizeObserver!==stickyObserver||!this.isCurrentOwnerWork(ownerDocument,generation)||this.onStickyResized(entries)});this.rowResizeObserver=rowObserver,this.groupResizeObserver=groupObserver,this.stickyResizeObserver=stickyObserver}this.hasUpdated&&(this.syncRowProjection(),this.attachContainerListeners(),this.syncRowObservers(),this.syncGroupObservers(),this.syncStickyOverlay())}disconnectedCallback(){this.teardownRowProjection(),this.resetOwnerRealmWork(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.teardownRowProjection(),this.resetOwnerRealmWork()}isCurrentOwnerWork(ownerDocument,generation){return this.ownerRealmGeneration===generation&&this.isConnected&&this.ownerDocument===ownerDocument}resetOwnerRealmWork(){this.ownerRealmGeneration+=1,this.rowResizeObserver?.disconnect(),this.rowResizeObserver=void 0,this.groupResizeObserver?.disconnect(),this.groupResizeObserver=void 0,this.observedRows.clear(),this.observedGroups.clear(),this.deferredRowObservations.clear(),this.deferredGroupObservations.clear(),this.inResizeDelivery=!1,this.pendingRowMeasurements.clear(),this.pendingGroupMeasurements.clear(),this.rowObserveRafId!==void 0&&this.rowObserveRafOwner?.cancelAnimationFrame(this.rowObserveRafId),this.rowObserveRafId=void 0,this.rowObserveRafOwner=void 0,this.rowObserveRafDocument=void 0,this.containerResizeObserver?.disconnect(),this.containerResizeObserver=void 0,this.stickyResizeObserver?.disconnect(),this.stickyResizeObserver=void 0,this.observedSticky=void 0,this.scrollRafId!==void 0&&this.scrollRafOwner?.cancelAnimationFrame(this.scrollRafId),this.scrollRafId=void 0,this.scrollRafOwner=void 0,this.scrollRafDocument=void 0,this.pendingScrollTop=null,this.externalMetricsPending=!1,this.pendingScrollCorrection=void 0,this.detachContainerListeners(),this.scrollListenerTarget=void 0}firstUpdated(changed){super.firstUpdated(changed),this.attachContainerListeners(),queueMicrotask(()=>{this.isConnected&&(this.noTopLayer=!nativePopoverSupported())})}requestUpdate(...args){args[0]===void 0&&(this.contentRefreshPending=!0),super.requestUpdate(...args)}willUpdate(changed){super.willUpdate(changed),this.projectionDeferred&&!this.hasUpdated&&this.ownerDocument?.defaultView&&this.seedFirstRenderState(this.releaseRowProjection),this.isFirstUpdate=!this.hasUpdated,this.hasUpdated&&(this.noTopLayer=!nativePopoverSupported());const contentRefresh=this.contentRefreshPending;this.contentRefreshPending=!1,contentRefresh&&(this.activeIndexFor=void 0);const sequence=contentRefresh||changed.has("items")&&!sameSequence(changed.get("items"),this.items)||changed.has("source")&&!sameSequence(changed.get("source"),this.source);sequence||changed.has("keyFunction")||changed.has("rowHeight")||changed.has("groups")||changed.has("activeItemId")||changed.has("scrollElement")?this.pendingScrollCorrection=void 0:this.pendingScrollCorrection&&(this.pendingScrollCorrection.source=this.effectiveSource),this.appendIdentityStart=-1;const previous=changed.has("source")?changed.get("source"):changed.get("items"),current=this.effectiveSource;if(sequence&&Array.isArray(previous)&&Array.isArray(current)&&previous.length<current.length&&previous.length===this.rowIdentities.length&&!changed.has("keyFunction")&&!changed.has("groups")&&!changed.has("rowHeight")&&previous.every((item,index)=>Object.is(item,current[index]))&&(this.appendIdentityStart=previous.length),(sequence||changed.has("keyFunction"))&&(this.identitiesDirty=!0),(sequence||changed.has("rowHeight")||changed.has("keyFunction")||changed.has("groups"))&&(this.offsetsDirty=!0,this.offsetDirtyStart=Math.min(this.offsetDirtyStart,this.appendIdentityStart>=0?this.appendIdentityStart:0)),sequence&&(this.compositionScrollTarget=void 0,this.itemsChangedPendingPrune=!0),changed.has("keyFunction")||isIndexedSource(this.effectiveSource)&&sequence){this.measuredHeights.clear(),this.measuredIndices.clear(),this.pendingRowMeasurements.clear(),this.indexedMeasurementIndexDirty=!0;for(const row of this.observedRows.values())this.rowResizeObserver?.unobserve(row);this.observedRows.clear(),this.deferredRowObservations.clear()}if(changed.has("groups")){this.measuredGroupHeights.clear(),this.pendingGroupMeasurements.clear();for(const marker of this.observedGroups.values())this.groupResizeObserver?.unobserve(marker);this.observedGroups.clear(),this.deferredGroupObservations.clear()}if((sequence||changed.has("groups"))&&this.recomputeGroups(),changed.has("rowHeight")&&(this.fixedRowHeight=this.parseRowHeight(this.rowHeight),this.fixedRowHeight!=null&&(this.measuredHeights.clear(),this.measuredIndices.clear(),this.pendingRowMeasurements.clear(),this.indexedMeasurementIndexDirty=!0)),this.offsetsDirty&&(this.recomputeOffsets(),this.offsetsDirty=!1,this.offsetDirtyStart=1/0),changed.has("activeItemId")&&!this.isFirstUpdate&&this.composition.profile){const index=this.activeIndex;index>=0&&(this.compositionScrollTarget=index)}this.computeRange(),this.limitCompositionWindow()}updated(changed){super.updated(changed),this.syncRowProjection(),this.syncRowObservers(),this.syncGroupObservers(),this.syncStickyOverlay(),changed.has("scrollElement")&&!this.isFirstUpdate&&this.attachContainerListeners(),changed.has("activeItemId")&&!this.isFirstUpdate&&this.scrollActiveIntoView(),this.emitRangeChangeIfNeeded(),this.maybeFireLoadMore(),this.maybeCorrectPendingScroll()}parseRowHeight(value){const normalized=normalizeRowHeight(value);return normalized==="auto"?null:normalized}get effectiveSource(){return this.source??this.items}get itemCount(){const source=this.effectiveSource;return isIndexedSource(source)?finiteCount(source.count):source.length}itemAt(index){const source=this.effectiveSource;return isIndexedSource(source)?source.itemAt(index):source[index]}keyOf(item,index){const source=this.effectiveSource,key=this.keyFunction?this.keyFunction(item,index):isIndexedSource(source)?source.keyAt?.(index)??index:index;return typeof key=="string"||typeof key=="number"?key:index}rowIdentity(key,occurrence){const token=domKeyToken(key);return`${token.length}:${token}:${occurrence}`}identityAt(index,item){return arguments.length<2&&this.keyFunction&&(item=this.itemAt(index)),isIndexedSource(this.effectiveSource)?this.rowIdentity(this.keyOf(item,index),index):this.rowIdentities[index]??this.rowIdentity(this.keyOf(item,index),index)}groupHeightAt(index){const group=this.normalizedGroupByIndex.get(index);return!group||group.label===""?0:this.measuredGroupHeights.get(index)??DEFAULT_GROUP_ESTIMATE_PX}rowHeightAt(index){return this.fixedRowHeight!=null?this.fixedRowHeight:this.measuredHeights.get(this.identityAt(index))??DEFAULT_ROW_ESTIMATE_PX}groupContributionThrough(index){return this.groupHeightPrefix[this.groupCountThrough(index)]??0}groupCountThrough(index){let low=0,high=this.normalizedGroups.length;for(;low<high;){const middle=low+high>>1;this.normalizedGroups[middle].startIndex<=index?low=middle+1:high=middle}return low}recomputeGroupHeightPrefix(){const prefix=new Array(this.normalizedGroups.length+1);prefix[0]=0;for(let index=0;index<this.normalizedGroups.length;index++){const group=this.normalizedGroups[index],height=group.label===""?0:this.measuredGroupHeights.get(group.startIndex)??DEFAULT_GROUP_ESTIMATE_PX;prefix[index+1]=finiteAdd(prefix[index],height)}this.groupHeightPrefix=prefix}indexedOffsetForIndex(index){const baseHeight=this.fixedRowHeight??DEFAULT_ROW_ESTIMATE_PX;let offset=index>Number.MAX_VALUE/baseHeight?Number.MAX_VALUE:index*baseHeight;if(this.fixedRowHeight==null){this.rebuildIndexedMeasurementIndex();let low=0,high=this.indexedMeasurementIndices.length;for(;low<high;){const middle=low+high>>1;this.indexedMeasurementIndices[middle]<index?low=middle+1:high=middle}offset=finiteAdd(offset,this.indexedMeasurementDeltaPrefix[low]??0)}return Math.max(0,finiteAdd(offset,this.groupContributionThrough(index)))}rebuildIndexedMeasurementIndex(){if(!this.indexedMeasurementIndexDirty)return;const retained=[];for(const[identity,index]of this.measuredIndices){const height=this.measuredHeights.get(identity);height!==void 0&&retained.push({index,delta:height-DEFAULT_ROW_ESTIMATE_PX})}retained.sort((a,b)=>a.index-b.index);const indices=new Array(retained.length),prefix=new Array(retained.length+1);prefix[0]=0;for(let position=0;position<retained.length;position++){const measurement=retained[position];indices[position]=measurement.index,prefix[position+1]=finiteAdd(prefix[position],measurement.delta)}this.indexedMeasurementIndices=indices,this.indexedMeasurementDeltaPrefix=prefix,this.indexedMeasurementIndexDirty=!1}pruneIndexedMeasurements(){if(!isIndexedSource(this.effectiveSource)||this.fixedRowHeight!=null||this.renderEnd<this.renderStart)return!1;const renderedCount=this.renderEnd-this.renderStart+1,retentionRows=Math.max(renderedCount,normalizeOverscan(this.overscan)*4),firstRetained=Math.max(0,this.renderStart-retentionRows),lastRetained=Math.min(this.itemCount-1,this.renderEnd+retentionRows);let removedDeltaBeforeWindow=0,pruned=!1;for(const[identity,measuredIndex]of this.measuredIndices)if(measuredIndex<firstRetained||measuredIndex>lastRetained){const height=this.measuredHeights.get(identity);height!==void 0&&measuredIndex<firstRetained&&(removedDeltaBeforeWindow=finiteAdd(removedDeltaBeforeWindow,height-DEFAULT_ROW_ESTIMATE_PX)),this.measuredIndices.delete(identity),this.measuredHeights.delete(identity),pruned=!0}if(pruned&&(this.indexedMeasurementIndexDirty=!0,removedDeltaBeforeWindow!==0)){const nextScrollTop=(this.readScrollMetrics()?.rawScrollTop??this.containerScrollTop)-removedDeltaBeforeWindow;this.applyScrollPosition(nextScrollTop),this.containerScrollTop=Math.max(0,nextScrollTop),this.pendingScrollTop=null}return pruned}offsetAt(index){return isIndexedSource(this.effectiveSource)?this.indexedOffsetForIndex(index):this.offsets[index]??0}recomputeOffsets(){const n=this.itemCount;if(this.groupPrefixDirty&&(this.recomputeGroupHeightPrefix(),this.groupPrefixDirty=!1),isIndexedSource(this.effectiveSource)){this.offsets=[0],this.rowIdentities=[],this.rowKeys=[],this.identityIndices.clear(),this.keyIndices.clear(),this.keyOccurrences.clear(),this.itemsChangedPendingPrune=!1;return}const append=this.appendIdentityStart>=0,start=this.identitiesDirty&&!append?0:Math.min(n,this.offsetDirtyStart),offsets=start>0?this.offsets:new Array(n+1);let cursor=start>0?finiteAdd(this.offsets[start-1],this.rowHeightAt(start-1)):0;const liveKeys=this.itemsChangedPendingPrune&&!append&&this.fixedRowHeight==null?new Set:null,occurrences=append?this.keyOccurrences:new Map;this.identitiesDirty&&!append&&(this.identityIndices.clear(),this.keyIndices.clear(),this.rowKeys=[]);const reuse=!this.identitiesDirty&&this.rowIdentities.length===n,identities=reuse||append?this.rowIdentities:new Array(n);for(let i=start;i<n;i++){if(cursor=finiteAdd(cursor,this.groupHeightAt(i)),offsets[i]=cursor,!reuse){const key=this.keyOf(this.itemAt(i),i),token=domKeyToken(key),occurrence=occurrences.get(token)??0;occurrences.set(token,occurrence+1),identities[i]=this.rowIdentity(key,occurrence),this.rowKeys[i]=key,this.identityIndices.set(identities[i],i),this.keyIndices.has(token)||this.keyIndices.set(token,i)}const identity=identities[i];let h;this.fixedRowHeight!=null?h=this.fixedRowHeight:(liveKeys?.add(identity),h=this.measuredHeights.get(identity)??DEFAULT_ROW_ESTIMATE_PX),cursor=finiteAdd(cursor,h)}if(offsets[n]=cursor,this.offsets=offsets,this.rowIdentities=identities,reuse||(this.keyOccurrences=occurrences),this.identitiesDirty=!1,this.itemsChangedPendingPrune=!1,liveKeys){for(const key of this.measuredHeights.keys())liveKeys.has(key)||(this.measuredHeights.delete(key),this.measuredIndices.delete(key),this.indexedMeasurementIndexDirty=!0);for(const key of this.measuredIndices.keys())liveKeys.has(key)||(this.measuredIndices.delete(key),this.indexedMeasurementIndexDirty=!0)}}groupTopAt(index){return Math.max(0,this.offsetAt(index)-this.groupHeightAt(index))}rowBottomAt(index){return finiteAdd(this.offsetAt(index),this.rowHeightAt(index))}entryTopAt(index){return this.groupTopAt(index)}findIndexAtOrAfter(offset){let lo=0,hi=this.itemCount-1;for(;lo<hi;){const mid=lo+Math.floor((hi-lo)/2);this.rowBottomAt(mid)<=offset?lo=mid+1:hi=mid}return lo}findIndexAtOrBefore(offset){let lo=0,hi=this.itemCount-1;for(;lo<hi;){const mid=lo+Math.ceil((hi-lo)/2);this.entryTopAt(mid)<offset?lo=mid:hi=mid-1}return lo}offsetForIndex(index){const clamped=Math.min(this.itemCount,Math.max(0,Math.trunc(index)||0));return this.offsetAt(clamped)}indexAtOffset(px){const n=this.itemCount;return n===0?-1:Number.isFinite(px)?Math.min(n-1,Math.max(0,this.findIndexAtOrAfter(px))):px>0?n-1:0}computeRange(){const n=this.itemCount;if(n===0){this.visibleStart=0,this.visibleEnd=-1,this.renderStart=0,this.renderEnd=-1;return}if(this.viewportHeight<=0){if(!this.renderUnmeasuredWindow){this.visibleStart=0,this.visibleEnd=-1,this.renderStart=0,this.renderEnd=-1;return}this.visibleStart=0,this.visibleEnd=0,this.renderStart=0,this.renderEnd=Math.min(n-1,normalizeOverscan(this.overscan));return}const viewTop=this.containerScrollTop,viewBottom=viewTop+this.viewportHeight;this.visibleStart=this.findIndexAtOrAfter(viewTop),this.visibleEnd=this.findIndexAtOrBefore(viewBottom);const overscan=normalizeOverscan(this.overscan);this.renderStart=Math.max(0,this.visibleStart-overscan),this.renderEnd=Math.min(n-1,this.visibleEnd+overscan),this.pruneIndexedMeasurements()&&this.computeRange()}limitCompositionWindow(){const profile=this.composition.profile;if(!profile||this.renderEnd<this.renderStart)return;const start=this.renderStart,end=this.renderEnd,focused=this.focusedRowOutsideWindow(!0),requested=this.compositionScrollTarget,anchor=requested!==void 0&&requested>=start&&requested<=end?requested:Math.max(start,this.visibleStart),range=budget=>{this.renderStart=Math.max(start,Math.min(anchor-Math.min(normalizeOverscan(this.overscan),budget-1),end-budget+1)),this.renderEnd=Math.min(end,this.renderStart+budget-1)};range(profile.maxRows),focused>=0&&(focused<this.renderStart||focused>this.renderEnd)&&range(profile.maxRows-1)}setCompositionScrollTarget(index){if(!this.composition.profile||this.compositionScrollTarget===index)return;const previous=this.compositionScrollTarget;this.compositionScrollTarget=index,this.requestUpdate("compositionScrollTarget",previous)}attachContainerListeners(){const base=this.scrollContainer,ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!base||!this.isConnected||!ownerWindow)return;this.containerResizeObserver?.disconnect(),this.containerResizeObserver=void 0,this.detachContainerListeners();const external=this.externalScroller;if(external&&ownerWindow.MutationObserver){const observer=new ownerWindow.MutationObserver(this.invalidateExternalGeometry);for(let ancestor=this;ancestor;ancestor=composedParentElement(ancestor))observer.observe(ancestor,{attributes:!0,attributeFilter:["style","class"]});this.externalStyleObserver=observer}const scrollTarget=external??base,generation=this.ownerRealmGeneration,ResizeObserverCtor=ownerWindow.ResizeObserver;if(ResizeObserverCtor){const observer=new ResizeObserverCtor(entries=>{if(this.containerResizeObserver!==observer||this.scrollListenerTarget!==scrollTarget||!this.isCurrentOwnerWork(ownerDocument,generation))return;if(this.beginResizeDelivery(),external){this.externalGeometry=void 0,this.syncExternalScrollMetrics();return}const entry=entries[0];entry&&(this.viewportHeight=entry.borderBoxSize?.[0]?.blockSize??entry.contentRect.height)});this.containerResizeObserver=observer,observer.observe(base),external&&!isWindowScroller(external)&&observer.observe(external)}scrollTarget.addEventListener("scroll",this.onScroll,{passive:!0}),scrollTarget.addEventListener("wheel",this.onUserScrollIntent,{passive:!0}),scrollTarget.addEventListener("pointerdown",this.onUserScrollIntent,{passive:!0}),scrollTarget.addEventListener("touchstart",this.onUserScrollIntent,{passive:!0}),scrollTarget.addEventListener("keydown",this.onUserScrollIntent),this.scrollListenerTarget=scrollTarget,external&&isWindowScroller(external)&&(external.addEventListener("resize",this.onExternalViewportResize,{passive:!0}),this.viewportResizeTarget=external),ownerWindow.queueMicrotask(()=>{if(this.scrollListenerTarget!==scrollTarget||this.scrollContainer!==base||!this.isCurrentOwnerWork(ownerDocument,generation))return;const metrics=this.readScrollMetrics();metrics&&(this.viewportHeight!==metrics.viewportHeight&&(this.viewportHeight=metrics.viewportHeight),this.containerScrollTop!==metrics.scrollTop&&(this.containerScrollTop=metrics.scrollTop))})}detachContainerListeners(){this.scrollRoundingAnchor=void 0,this.externalStyleObserver?.disconnect(),this.externalStyleObserver=void 0,this.externalGeometry=void 0;const viewportTarget=this.viewportResizeTarget;viewportTarget&&(viewportTarget.removeEventListener("resize",this.onExternalViewportResize),this.viewportResizeTarget=void 0);const target=this.scrollListenerTarget;target&&(target.removeEventListener("scroll",this.onScroll),target.removeEventListener("wheel",this.onUserScrollIntent),target.removeEventListener("pointerdown",this.onUserScrollIntent),target.removeEventListener("touchstart",this.onUserScrollIntent),target.removeEventListener("keydown",this.onUserScrollIntent))}applyPendingRowMeasurements(){if(this.pendingRowMeasurements.size===0)return;const observations=[...this.pendingRowMeasurements];if(this.pendingRowMeasurements.clear(),this.fixedRowHeight!=null)return;const base=this.scrollContainer,oldScrollTop=this.readScrollMetrics()?.rawScrollTop??this.containerScrollTop;let scrollAdjustment=0,changed=!1;const indexed=isIndexedSource(this.effectiveSource),measuredByIndex=indexed?new Map:void 0;if(measuredByIndex)for(const[identity,index]of this.measuredIndices)measuredByIndex.set(index,identity);for(const[key,{index,height}]of observations){if(indexed&&(index<0||index>=this.itemCount||this.identityAt(index)!==key))continue;const previousKey=measuredByIndex?.get(index)??key,prev=this.measuredHeights.get(previousKey),replaced=previousKey!==key;if(replaced||prev===void 0||Math.abs(prev-height)>.5){const oldHeight=prev??DEFAULT_ROW_ESTIMATE_PX,oldBottom=indexed?finiteAdd(this.offsetAt(index),oldHeight):this.rowBottomAt(index);this.offsetDirtyStart=Math.min(this.offsetDirtyStart,index),replaced&&(this.measuredHeights.delete(previousKey),this.measuredIndices.delete(previousKey)),this.measuredHeights.set(key,height),this.measuredIndices.set(key,index),measuredByIndex?.set(index,key),oldBottom<=oldScrollTop&&(scrollAdjustment+=height-oldHeight),changed=!0}}if(changed){if(this.indexedMeasurementIndexDirty=!0,base&&scrollAdjustment!==0){const nextScrollTop=oldScrollTop+scrollAdjustment;this.applyScrollPosition(nextScrollTop),this.containerScrollTop=Math.max(0,nextScrollTop),this.pendingScrollTop=null}this.offsetsDirty=!0,this.measurementGeneration+=1,super.requestUpdate()}}applyPendingGroupMeasurements(){if(this.pendingGroupMeasurements.size===0)return;const observations=[...this.pendingGroupMeasurements];this.pendingGroupMeasurements.clear();const base=this.scrollContainer,oldScrollTop=this.readScrollMetrics()?.rawScrollTop??this.containerScrollTop;let scrollAdjustment=0,changed=!1;for(const[index,height]of observations){if(!this.normalizedGroupByIndex.has(index))continue;const previous=this.measuredGroupHeights.get(index)??DEFAULT_GROUP_ESTIMATE_PX;if(Math.abs(previous-height)<=.5)continue;const oldRowTop=this.offsetAt(index);this.offsetDirtyStart=Math.min(this.offsetDirtyStart,index),this.groupPrefixDirty=!0,this.measuredGroupHeights.set(index,height),oldRowTop<=oldScrollTop&&(scrollAdjustment+=height-previous),changed=!0}if(changed){if(base&&scrollAdjustment!==0){const nextScrollTop=oldScrollTop+scrollAdjustment;this.applyScrollPosition(nextScrollTop),this.containerScrollTop=Math.max(0,nextScrollTop),this.pendingScrollTop=null}this.offsetsDirty=!0,this.measurementGeneration+=1,super.requestUpdate()}}get defersMeasurementApplication(){return this.inResizeDelivery&&this.externalScroller!==void 0}beginResizeDelivery(){if(this.inResizeDelivery=!0,this.rowObserveRafId!==void 0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow||!this.isConnected){this.inResizeDelivery=!1;return}const generation=this.ownerRealmGeneration,handle=ownerWindow.requestAnimationFrame(()=>{if(this.rowObserveRafId!==handle||this.rowObserveRafOwner!==ownerWindow||this.rowObserveRafDocument!==ownerDocument||!this.isCurrentOwnerWork(ownerDocument,generation))return;this.rowObserveRafId=void 0,this.rowObserveRafOwner=void 0,this.rowObserveRafDocument=void 0,this.inResizeDelivery=!1;const ro=this.rowResizeObserver;for(const[identity,el]of this.deferredRowObservations)ro&&this.observedRows.get(identity)===el&&ro.observe(el);this.deferredRowObservations.clear();const groupObserver=this.groupResizeObserver;for(const[index,el]of this.deferredGroupObservations)groupObserver&&this.observedGroups.get(index)===el&&groupObserver.observe(el);this.deferredGroupObservations.clear(),this.applyPendingRowMeasurements(),this.applyPendingGroupMeasurements()});this.rowObserveRafId=handle,this.rowObserveRafOwner=ownerWindow,this.rowObserveRafDocument=ownerDocument}syncRowObservers(){const ro=this.rowResizeObserver;if(!ro)return;if(this.fixedRowHeight!=null){for(const el of this.observedRows.values())ro.unobserve(el);this.observedRows.clear(),this.deferredRowObservations.clear();return}const current=new Map;for(const{identity,index}of this.renderedWindow){const el=this.rowElements.get(identity);el&&(current.set(identity,el),this.observedRowKeys.set(el,identity),this.observedRowIndices.set(el,index))}for(const[identity,el]of this.observedRows)current.get(identity)!==el&&(ro.unobserve(el),this.observedRows.delete(identity),this.deferredRowObservations.delete(identity));for(const[identity,el]of current)this.observedRows.has(identity)||(this.observedRows.set(identity,el),this.inResizeDelivery?this.deferredRowObservations.set(identity,el):ro.observe(el))}syncGroupObservers(){const observer=this.groupResizeObserver;if(!observer)return;const current=new Map;for(const[index,marker]of this.groupElements)current.set(index,marker),this.observedGroupIndices.set(marker,index);for(const[index,marker]of this.observedGroups)current.get(index)!==marker&&(observer.unobserve(marker),this.observedGroups.delete(index),this.deferredGroupObservations.delete(index));for(const[index,marker]of current)this.observedGroups.has(index)||(this.observedGroups.set(index,marker),this.inResizeDelivery?this.deferredGroupObservations.set(index,marker):observer.observe(marker))}get stickyInset(){return this.renderStickyGroup?this.stickyHeight:0}scrollActiveIntoView(){const index=this.activeIndex;if(index<0)return;const behavior=prefersReducedMotion(this)?"auto":"smooth";this.performScrollTo(index,"auto",behavior)&&this.beginPendingScrollCorrection(index,"auto",behavior,this.activeItemId)}scrollToIndex(index,options){const n=this.itemCount;if(n===0)return;const clamped=finiteInteger(index,0,0,n-1);this.setCompositionScrollTarget(clamped);const align=options?.align??"auto",behavior=prefersReducedMotion(this)?"auto":options?.behavior??"smooth";this.performScrollTo(clamped,align,behavior)?this.beginPendingScrollCorrection(clamped,align,behavior):this.pendingScrollCorrection=void 0}hasUnmeasuredGroupThrough(index){return this.normalizedGroups.some(group=>group.startIndex<=index&&group.label!==""&&!this.measuredGroupHeights.has(group.startIndex))}beginPendingScrollCorrection(index,align,behavior,activeItemId){if(this.fixedRowHeight!=null&&!this.hasUnmeasuredGroupThrough(index)){this.pendingScrollCorrection=void 0;return}this.pendingScrollCorrection={identity:this.identityAt(index),index,align,behavior,source:this.effectiveSource,keyFunction:this.keyFunction,activeItemId:activeItemId===""?void 0:activeItemId,lastMeasurementGeneration:this.measurementGeneration}}performScrollTo(index,align,behavior){const metrics=this.readScrollMetrics();if(!metrics)return!1;const inset=this.stickyInset,top=this.offsetAt(index),bottom=this.rowBottomAt(index),viewTop=metrics.rawScrollTop,viewBottom=viewTop+metrics.viewportHeight;let target=null;return align==="start"?target=top-inset:align==="end"?target=bottom-metrics.viewportHeight:top-inset<viewTop?target=top-inset:bottom>viewBottom&&(target=bottom-metrics.viewportHeight),target===null?!1:(this.applyScrollPosition(target,behavior),!0)}maybeCorrectPendingScroll(){const pending=this.pendingScrollCorrection;if(!pending||pending.lastMeasurementGeneration>=this.measurementGeneration)return;if(pending.source!==this.effectiveSource||pending.keyFunction!==this.keyFunction||pending.activeItemId!==void 0&&!Object.is(pending.activeItemId,this.activeItemId)){this.pendingScrollCorrection=void 0;return}const index=pending.activeItemId!==void 0?this.activeIndex:isIndexedSource(this.effectiveSource)?pending.index:this.identityIndices.get(pending.identity)??-1;if(index<0||index>=this.itemCount||this.identityAt(index)!==pending.identity){this.pendingScrollCorrection=void 0;return}this.performScrollTo(index,pending.align,pending.behavior),pending.index=index,pending.lastMeasurementGeneration=this.measurementGeneration,(this.fixedRowHeight!=null||this.measuredHeights.has(pending.identity))&&!this.hasUnmeasuredGroupThrough(index)&&(this.pendingScrollCorrection=void 0)}emitRangeChangeIfNeeded(){if(this.visibleEnd<this.visibleStart){this.lastEmittedStart=-1,this.lastEmittedEnd=-1;return}this.visibleStart===this.lastEmittedStart&&this.visibleEnd===this.lastEmittedEnd||(this.lastEmittedStart=this.visibleStart,this.lastEmittedEnd=this.visibleEnd,this.emit("lr-visible-range-change",{start:this.visibleStart,end:this.visibleEnd}))}maybeFireLoadMore(){const n=this.itemCount;if(!(n>0&&this.visibleEnd>=n-1)){this.loadMoreArmed=!0;return}!this.hasMore||this.loading||!this.loadMoreArmed||(this.loadMoreArmed=!1,this.emit("lr-load-more"))}get projectionActive(){return!this.projectionDeferred&&this.rowProjection==="light"}rowSlotName(identity){return`${tag("virtual-list")}-row-${identity}`}syncRowProjection(){if(!this.projectionActive||!this.isConnected){this.projectionAnchor!==void 0&&this.teardownRowProjection();return}const anchor=this.ensureProjectionAnchor();this.projectionPart=render(this.renderProjectedRows(),this,{renderBefore:anchor,host:this})}ensureProjectionAnchor(){const existing=this.projectionAnchor;if(existing!==void 0&&existing.parentNode===this&&existing.ownerDocument===this.ownerDocument)return existing;existing!==void 0&&this.teardownRowProjection();const anchor=this.ownerDocument.createComment(PROJECTION_ANCHOR_MARKER);return this.append(anchor),this.projectionAnchor=anchor,this.projectionPart=void 0,anchor}teardownRowProjection(){const anchor=this.projectionAnchor,part=this.projectionPart;if(this.projectionAnchor=void 0,this.projectionPart=void 0,anchor!==void 0){if(part!==void 0){const container=anchor.parentNode;container!==null&&render(nothing,container,{renderBefore:anchor,host:this});const start=part.startNode;start?.parentNode?.removeChild(start)}anchor.parentNode?.removeChild(anchor)}}renderProjectedRows(){return repeat(this.renderedWindow,w=>w.identity,w=>staticHtml`<div
|
|
1
|
+
import{__decorate}from"tslib";import{devWarnOnce}from"../../../internal/dev-warning.js";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{VirtualListCompositionController}from"../../../internal/virtual-list-composition.js";import{html,nothing,render}from"lit";import{html as staticHtml,unsafeStatic}from"lit/static-html.js";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{ref}from"lit/directives/ref.js";import{styleMap}from"lit/directives/style-map.js";import{LyraElement}from"../../../internal/lyra-element.js";import{literalSetConverter}from"../../../internal/converters.js";import{tag}from"../../../internal/prefix.js";import{VIRTUAL_LIST_ROW_ATTRIBUTE}from"./virtual-list-attributes.js";import{VIRTUAL_LIST_ROW_ATTRIBUTE as VIRTUAL_LIST_ROW_ATTRIBUTE2,VIRTUAL_LIST_STICKY_ATTRIBUTE}from"./virtual-list-attributes.js";import{MAX_OVERSCAN_ROWS}from"./virtual-list-limits.js";import{MAX_OVERSCAN_ROWS as MAX_OVERSCAN_ROWS2}from"./virtual-list-limits.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{nativePopoverSupported}from"../../../internal/native-popover.js";import{finiteAdd,finiteCount,finiteInteger,finiteNumber}from"../../../internal/numbers.js";import{getNumberFormat}from"../../../internal/intl-cache.js";import{composedParentElement,deepActiveElementIn}from"../../../internal/active-element.js";import{getOwnDataDescriptor,MISSING_OWN_DATA_DESCRIPTOR,UNSAFE_OWN_DATA_DESCRIPTOR}from"../../../internal/data-descriptors.js";import{styles}from"./virtual-list.styles.js";const DEFAULT_ROW_ESTIMATE_PX=48,MAX_SCROLL_EXTENT_PX=8e6,DEFAULT_GROUP_ESTIMATE_PX=32,DEFAULT_OVERSCAN_ROWS=6,MAX_VIRTUAL_LIST_GROUPS=1e4,EMPTY_VIRTUAL_LIST_GROUPS=Object.freeze([]);function normalizeOverscan(value){if(value===null)return DEFAULT_OVERSCAN_ROWS;const numeric=typeof value=="number"?value:Number(value);return Number.isFinite(numeric)?Math.min(MAX_OVERSCAN_ROWS,Math.max(0,Math.floor(numeric))):DEFAULT_OVERSCAN_ROWS}const overscanConverter={fromAttribute(value){return normalizeOverscan(value)}};function virtualListGroupsChanged(value,oldValue){if(value===oldValue)return!1;const next=value,previous=oldValue;if(next==null||previous==null)return next!==previous;if(next.length!==previous.length)return!0;for(let index=0;index<next.length;index+=1){const a=next[index],b=previous[index];if(a.key!==b.key||a.label!==b.label||a.startIndex!==b.startIndex)return!0}return!1}const ROW_PROJECTION=literalSetConverter(["shadow","light"],"shadow"),ROW_ATTRIBUTE_STATIC=unsafeStatic(VIRTUAL_LIST_ROW_ATTRIBUTE),PROJECTION_ANCHOR_MARKER=`${tag("virtual-list")}-projection`;function normalizeRowHeight(value){if(value==="auto")return"auto";const numeric=typeof value=="number"?value:Number(value);return Number.isFinite(numeric)&&numeric>0?numeric:"auto"}const rowHeightConverter={fromAttribute(value){return value===null?"auto":normalizeRowHeight(value)}};function isIndexedSource(source){return!Array.isArray(source)}function sameSequence(a,b){return Array.isArray(a)&&Array.isArray(b)&&a.length===b.length&&a.every((item,index)=>item===b[index])}const ELEMENT_NODE_TYPE=1;function isWindowScroller(target){return target.window===target}function domKeyToken(key){if(typeof key=="number"){if(Number.isNaN(key))return"number:NaN";if(Object.is(key,-0))return"number:-0"}return`${typeof key}:${String(key)}`}const SCROLL_KEYS=new Set(["ArrowUp","ArrowDown","PageUp","PageDown","Home","End"," "]);class LyraVirtualList extends LyraElement{constructor(){super(...arguments),this.items=[],this.renderItem=()=>nothing,this.rowHeight="auto",this.itemRole="listitem",this._rowProjection="shadow",this.rowIndexOffset=0,this.overscan=DEFAULT_OVERSCAN_ROWS,this.activeItemId="",this.loading=!1,this.hasMore=!1,this.partCache=new Map,this.invalidateExternalGeometry=()=>{this.externalGeometry=void 0,this.isConnected&&this.syncExternalScrollMetrics()},this.scrollMetricsRefreshPending=!1,this.containerScrollTop=0,this.viewportHeight=0,this.renderUnmeasuredWindow=!0,this.offsets=[0],this.offsetDirtyStart=0,this.appendIdentityStart=-1,this.identityIndices=new Map,this.keyIndices=new Map,this.keyOccurrences=new Map,this.groupPrefixDirty=!0,this.rowKeys=[],this.rowIdentities=[],this.fixedRowHeight=null,this.measuredHeights=new Map,this.measuredIndices=new Map,this.indexedMeasurementIndices=[],this.indexedMeasurementDeltaPrefix=[0],this.indexedMeasurementIndexDirty=!0,this.offsetsDirty=!0,this.identitiesDirty=!0,this.itemsChangedPendingPrune=!1,this.compositionVersion=0,this.composition=new VirtualListCompositionController(this,()=>{const previous=this.compositionVersion;this.compositionVersion++,this.composition.profile||(this.compositionScrollTarget=void 0),this.requestUpdate("compositionVersion",previous)}),this.renderStart=0,this.renderEnd=-1,this.pinnedRow=-1,this.renderedWindow=[],this.rowElements=new Map,this.groupElements=new Map,this.projectionDeferred=!0,this.releaseRowProjection=()=>{this.projectionDeferred=!1,super.requestUpdate()},this.visibleStart=0,this.visibleEnd=-1,this.lastEmittedStart=-1,this.lastEmittedEnd=-1,this.loadMoreArmed=!0,this.measurementGeneration=0,this.isFirstUpdate=!0,this.stickyHeight=0,this.noTopLayer=!1,this.observedRows=new Map,this.observedRowKeys=new WeakMap,this.observedRowIndices=new WeakMap,this.observedGroups=new Map,this.observedGroupIndices=new WeakMap,this.externalMetricsPending=!1,this.ownerRealmGeneration=0,this.inResizeDelivery=!1,this.pendingRowMeasurements=new Map,this.pendingGroupMeasurements=new Map,this.deferredRowObservations=new Map,this.deferredGroupObservations=new Map,this.activeIndexForLength=-1,this.activeIndexForId="",this.activeIndexCache=-1,this.pendingScrollTop=null,this.normalizedGroups=EMPTY_VIRTUAL_LIST_GROUPS,this.normalizedGroupByIndex=new Map,this.measuredGroupHeights=new Map,this.groupHeightPrefix=[0],this.contentRefreshPending=!1,this.onExternalViewportResize=()=>{this.externalGeometry=void 0,this.syncExternalScrollMetrics()},this.onUserScrollIntent=event=>{event instanceof KeyboardEvent&&!SCROLL_KEYS.has(event.key)||(this.pendingScrollCorrection=void 0,this.compositionScrollTarget=void 0,this.scrollRoundingAnchor=void 0)},this.onScroll=e=>{if(this.externalScroller?(this.pendingScrollTop=null,this.externalMetricsPending=!0):this.pendingScrollTop=this.logicalScroll(e.currentTarget.scrollTop),this.scrollRafId!==void 0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow||!this.isConnected)return;const generation=this.ownerRealmGeneration,handle=ownerWindow.requestAnimationFrame(()=>{if(!(this.scrollRafId!==handle||this.scrollRafOwner!==ownerWindow||this.scrollRafDocument!==ownerDocument||!this.isCurrentOwnerWork(ownerDocument,generation))){if(this.scrollRafId=void 0,this.scrollRafOwner=void 0,this.scrollRafDocument=void 0,this.externalMetricsPending){this.externalMetricsPending=!1;const metrics=this.readScrollMetrics();metrics&&(this.pendingScrollTop=metrics.scrollTop,this.viewportHeight!==metrics.viewportHeight&&(this.viewportHeight=metrics.viewportHeight))}if(this.pendingScrollTop!==null){const scrollTop=this.pendingScrollTop;this.pendingScrollTop=null;const moved=this.containerScrollTop!==scrollTop;this.containerScrollTop=scrollTop,moved&&this.emit("lr-virtual-scroll",{scrollTop,viewportHeight:this.viewportHeight})}}});this.scrollRafId=handle,this.scrollRafOwner=ownerWindow,this.scrollRafDocument=ownerDocument},this.onRowsResized=entries=>{if(this.beginResizeDelivery(),this.fixedRowHeight==null){for(const entry of entries){const row=entry.target,key=this.observedRowKeys.get(row),index=this.observedRowIndices.get(row);if(key===void 0||index===void 0)continue;const height=entry.borderBoxSize?.[0]?.blockSize??entry.target.getBoundingClientRect().height;this.pendingRowMeasurements.set(key,{index,height})}this.defersMeasurementApplication||this.applyPendingRowMeasurements()}},this.onGroupsResized=entries=>{this.beginResizeDelivery();for(const entry of entries){const marker=entry.target,index=this.observedGroupIndices.get(marker);if(index===void 0||!this.normalizedGroupByIndex.has(index))continue;const height=entry.borderBoxSize?.[0]?.blockSize??entry.target.getBoundingClientRect().height;!Number.isFinite(height)||height<0||this.pendingGroupMeasurements.set(index,height)}this.defersMeasurementApplication||this.applyPendingGroupMeasurements()},this.onFocusOut=event=>{const next=event.relatedTarget;this.pinnedRow>=0&&!(next&&(this.contains(next)||this.renderRoot.contains(next)))&&super.requestUpdate()},this.onStickyResized=entries=>{this.beginResizeDelivery();const entry=entries[0];if(!entry)return;const height=entry.borderBoxSize?.[0]?.blockSize??entry.contentRect.height;Math.abs(this.stickyHeight-height)>.5&&(this.stickyHeight=height)}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["items","source","groups"])}static{this.identityCollectionProperties=Object.freeze(["items","source"])}static{this.identityCollectionObjectProperties=Object.freeze(["source"])}static{this.styles=[LyraElement.styles,styles]}get rowProjection(){return this._rowProjection}set rowProjection(next){const normalized=ROW_PROJECTION.normalize(next),previous=this._rowProjection;previous!==normalized&&(this._rowProjection=normalized,this.requestUpdate("rowProjection",previous))}get scrollContainer(){return this.cachedPart("base")}cachedPart(name){let element=this.partCache.get(name);return element?.isConnected||(element=this.renderRoot?.querySelector(`[part="${name}"]`)??void 0,element?this.partCache.set(name,element):this.partCache.delete(name)),element}get renderedRows(){const root=this.renderRoot;return root?[...root.querySelectorAll('[part="row"]')]:[]}get projectedRows(){const rows=[];for(const child of this.children)child.hasAttribute(VIRTUAL_LIST_ROW_ATTRIBUTE)&&rows.push(child);return rows}get externalScroller(){const target=this.scrollElement;if(target!=null)return isWindowScroller(target)||target.nodeType===ELEMENT_NODE_TYPE?target:void 0}get spacerElement(){return this.cachedPart("spacer")}scrollScale(viewport=this.viewportHeight){const total=this.offsetAt(this.itemCount);return total<=MAX_SCROLL_EXTENT_PX?1:Math.max(1,(total-viewport)/Math.max(1,MAX_SCROLL_EXTENT_PX-viewport))}logicalScroll(physical,viewport=this.viewportHeight){if(this.scrollRoundingAnchor){if(Math.abs(physical-this.scrollRoundingAnchor.physical)<.01)return this.scrollRoundingAnchor.logical;this.scrollRoundingAnchor=void 0}return physical<0?physical:physical*this.scrollScale(viewport)}physicalScroll(logical,viewport=this.viewportHeight){return logical<0?logical:logical/this.scrollScale(viewport)}physicalRowOffset(logical){return this.scrollScale()===1?logical:(this.scrollRoundingAnchor?.logical===this.containerScrollTop?this.scrollRoundingAnchor.physical:this.physicalScroll(this.containerScrollTop))+logical-this.containerScrollTop}captureScrollRounding(logical){this.scrollRoundingAnchor=void 0;const metrics=this.readPhysicalScrollMetrics();if(!metrics||this.scrollScale(metrics.viewportHeight)===1)return;const physical=this.physicalScroll(logical,metrics.viewportHeight);Math.abs(physical-metrics.rawScrollTop)<=1.1&&(this.scrollRoundingAnchor={physical:metrics.rawScrollTop,logical})}readScrollMetrics(){const metrics=this.readPhysicalScrollMetrics();if(!metrics)return metrics;const rawScrollTop=this.logicalScroll(metrics.rawScrollTop,metrics.viewportHeight);return{...metrics,rawScrollTop,scrollTop:Math.max(0,rawScrollTop)}}readPhysicalScrollMetrics(){const base=this.scrollContainer;if(!base)return null;const external=this.externalScroller;if(!external)return{scrollTop:base.scrollTop,rawScrollTop:base.scrollTop,viewportHeight:base.clientHeight,scrollDeltaScale:1};const spacer=this.spacerElement??base,spacerRect=spacer.getBoundingClientRect(),extent=this.offsetAt(this.itemCount),cached=this.externalGeometry,valid=cached?.spacer===spacer&&cached.external===external&&cached.height===spacerRect.height&&cached.extent===extent,spacerScale=valid?cached.spacerScale:this.visualBlockScale(spacer,spacerRect),spacerTop=spacerRect.top;if(isWindowScroller(external)){this.externalGeometry={spacer,external,height:spacerRect.height,extent,spacerScale,scrollerScale:1,borderTop:0};const documentHeight=finiteNumber(external.document?.documentElement?.clientHeight??0,0),rawScrollTop2=finiteNumber(-spacerTop/spacerScale,0);return{scrollTop:Math.max(0,rawScrollTop2),rawScrollTop:rawScrollTop2,viewportHeight:(documentHeight>0?documentHeight:finiteNumber(external.innerHeight,0))/spacerScale,scrollDeltaScale:spacerScale}}const scrollerRect=external.getBoundingClientRect(),relativeScale=valid?null:this.relativeBlockScale(spacer,external),inferredScrollerScale=relativeScale===null?0:spacerScale/relativeScale,scrollerScale=valid?cached.scrollerScale:Number.isFinite(inferredScrollerScale)&&inferredScrollerScale>0?inferredScrollerScale:this.visualBlockScale(external,scrollerRect),scrollerStyle=valid?void 0:external.ownerDocument.defaultView?.getComputedStyle(external),borderTop=valid?cached.borderTop:Number.parseFloat(scrollerStyle?.borderTopWidth??"");this.externalGeometry={spacer,external,height:spacerRect.height,extent,spacerScale,scrollerScale,borderTop};const scrollerTop=scrollerRect.top+(Number.isFinite(borderTop)?borderTop:external.clientTop)*scrollerScale,rawScrollTop=finiteNumber((scrollerTop-spacerTop)/spacerScale,0);return{scrollTop:Math.max(0,rawScrollTop),rawScrollTop,viewportHeight:finiteNumber(external.clientHeight*scrollerScale/spacerScale,0),scrollDeltaScale:spacerScale/scrollerScale}}visualBlockScale(element,rect){const style=element.ownerDocument.defaultView?.getComputedStyle(element);if(!style)return 1;const borderBoxHeight=Number.parseFloat(style.height)+(style.boxSizing==="border-box"?0:Number.parseFloat(style.paddingTop)+Number.parseFloat(style.paddingBottom)+Number.parseFloat(style.borderTopWidth)+Number.parseFloat(style.borderBottomWidth)),layoutHeight=borderBoxHeight>0&&Number.isFinite(borderBoxHeight)?borderBoxHeight:"offsetHeight"in element&&typeof element.offsetHeight=="number"?element.offsetHeight:0,scale=rect.height/layoutHeight;return scale>0&&Number.isFinite(scale)?scale:1}relativeBlockScale(descendant,ancestor){let scale=1,current=descendant;for(;current&¤t!==ancestor;){const style=current.ownerDocument.defaultView?.getComputedStyle(current);if(!style)return null;const zoom=style.zoom?style.zoom.endsWith("%")?Number.parseFloat(style.zoom)/100:Number.parseFloat(style.zoom):1;if(!Number.isFinite(zoom)||zoom<=0)return null;scale*=zoom;const transformable=style.display!=="contents"&&style.display!=="inline";if(transformable&&style.scale&&style.scale!=="none"){const values=style.scale.split(/\s+/).map(Number),blockScale=values[1]??values[0]??Number.NaN;if(!Number.isFinite(blockScale)||blockScale<=0)return null;scale*=blockScale}if(transformable&&style.rotate&&style.rotate!=="none"&&style.rotate!=="0deg")return null;if(transformable&&style.transform!=="none"){const Matrix=current.ownerDocument.defaultView?.DOMMatrixReadOnly;if(!Matrix)return null;const matrix=new Matrix(style.transform);if(matrix.m12!==0||matrix.m13!==0||matrix.m14!==0||matrix.m21!==0||matrix.m23!==0||matrix.m24!==0||matrix.m31!==0||matrix.m32!==0||matrix.m34!==0||matrix.m44!==1||matrix.m22<=0)return null;scale*=matrix.m22}const parent=current.assignedSlot??current.parentNode;current=parent?.nodeType===Node.ELEMENT_NODE?parent:parent?.nodeType===Node.DOCUMENT_FRAGMENT_NODE&&"host"in parent?parent.host:null}return current===ancestor&&Number.isFinite(scale)&&scale>0?scale:null}applyScrollPosition(top,behavior){const external=this.externalScroller;if(!external){const base=this.scrollContainer;if(!base)return;const next2=Math.max(0,this.physicalScroll(finiteNumber(top,0),base.clientHeight));behavior===void 0?base.scrollTop=next2:base.scrollTo({top:next2,behavior}),behavior!=="smooth"&&(this.captureScrollRounding(top),this.scheduleScrollMetricsRefresh());return}const metrics=this.readPhysicalScrollMetrics();if(!metrics)return;const delta=(this.physicalScroll(finiteNumber(top,metrics.rawScrollTop),metrics.viewportHeight)-metrics.rawScrollTop)*metrics.scrollDeltaScale;if(isWindowScroller(external)){const options={top:Math.max(0,finiteNumber(external.scrollY+delta,0))};behavior!==void 0&&(options.behavior=behavior),external.scrollTo(options),behavior!=="smooth"&&(this.captureScrollRounding(top),this.scheduleScrollMetricsRefresh());return}const next=Math.max(0,finiteNumber(external.scrollTop+delta,0));behavior===void 0?external.scrollTop=next:external.scrollTo({top:next,behavior}),behavior!=="smooth"&&(this.captureScrollRounding(top),this.scheduleScrollMetricsRefresh())}scheduleScrollMetricsRefresh(){if(this.scrollMetricsRefreshPending)return;this.scrollMetricsRefreshPending=!0;const owner=this.ownerDocument.defaultView;queueMicrotask(()=>{this.scrollMetricsRefreshPending=!1,this.isConnected&&this.ownerDocument.defaultView===owner&&this.syncExternalScrollMetrics()})}syncExternalScrollMetrics(){const metrics=this.readScrollMetrics();metrics&&(this.viewportHeight!==metrics.viewportHeight&&(this.viewportHeight=metrics.viewportHeight),this.containerScrollTop!==metrics.scrollTop&&(this.containerScrollTop=metrics.scrollTop))}get safeRowIndexOffset(){return finiteCount(this.rowIndexOffset)}computedAriaRowIndex(index){return finiteInteger(finiteAdd(index+1,this.safeRowIndexOffset),1,1,Number.MAX_SAFE_INTEGER)}get activeIndex(){if(this.activeItemId==="")return-1;const source=this.effectiveSource,count=this.itemCount;if(this.activeIndexFor===source&&this.activeIndexForLength===count&&Object.is(this.activeIndexForId,this.activeItemId)&&this.activeIndexForKeyFn===this.keyFunction)return this.activeIndexCache;if(this.activeIndexFor=source,this.activeIndexForLength=count,this.activeIndexForId=this.activeItemId,this.activeIndexForKeyFn=this.keyFunction,this.activeIndexCache=-1,isIndexedSource(source)){if(!this.keyFunction&&source.indexOfKey){const candidate=source.indexOfKey(this.activeItemId);Number.isInteger(candidate)&&candidate>=0&&candidate<count&&(this.activeIndexCache=candidate)}return this.activeIndexCache}return this.activeIndexCache=this.keyIndices.get(domKeyToken(this.activeItemId))??-1,this.activeIndexCache}connectedCallback(){super.connectedCallback(),this.ownerDocument.defaultView&&(this.seedFirstRenderState(()=>{this.renderUnmeasuredWindow=!1,super.requestUpdate()}),this.seedFirstRenderState(this.releaseRowProjection),this.hasUpdated&&(this.projectionDeferred=!1)),this.resetOwnerRealmWork();const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView,generation=this.ownerRealmGeneration,ResizeObserverCtor=ownerWindow?.ResizeObserver;if(ResizeObserverCtor){const rowObserver=new ResizeObserverCtor(entries=>{this.rowResizeObserver!==rowObserver||!this.isCurrentOwnerWork(ownerDocument,generation)||this.onRowsResized(entries)}),groupObserver=new ResizeObserverCtor(entries=>{this.groupResizeObserver!==groupObserver||!this.isCurrentOwnerWork(ownerDocument,generation)||this.onGroupsResized(entries)}),stickyObserver=new ResizeObserverCtor(entries=>{this.stickyResizeObserver!==stickyObserver||!this.isCurrentOwnerWork(ownerDocument,generation)||this.onStickyResized(entries)});this.rowResizeObserver=rowObserver,this.groupResizeObserver=groupObserver,this.stickyResizeObserver=stickyObserver}this.hasUpdated&&(this.syncRowProjection(),this.attachContainerListeners(),this.syncRowObservers(),this.syncGroupObservers(),this.syncStickyOverlay())}disconnectedCallback(){this.teardownRowProjection(),this.resetOwnerRealmWork(),super.disconnectedCallback()}adoptedCallback(){super.adoptedCallback(),this.teardownRowProjection(),this.resetOwnerRealmWork()}isCurrentOwnerWork(ownerDocument,generation){return this.ownerRealmGeneration===generation&&this.isConnected&&this.ownerDocument===ownerDocument}resetOwnerRealmWork(){this.ownerRealmGeneration+=1,this.rowResizeObserver?.disconnect(),this.rowResizeObserver=void 0,this.groupResizeObserver?.disconnect(),this.groupResizeObserver=void 0,this.observedRows.clear(),this.observedGroups.clear(),this.deferredRowObservations.clear(),this.deferredGroupObservations.clear(),this.inResizeDelivery=!1,this.pendingRowMeasurements.clear(),this.pendingGroupMeasurements.clear(),this.rowObserveRafId!==void 0&&this.rowObserveRafOwner?.cancelAnimationFrame(this.rowObserveRafId),this.rowObserveRafId=void 0,this.rowObserveRafOwner=void 0,this.rowObserveRafDocument=void 0,this.containerResizeObserver?.disconnect(),this.containerResizeObserver=void 0,this.stickyResizeObserver?.disconnect(),this.stickyResizeObserver=void 0,this.observedSticky=void 0,this.scrollRafId!==void 0&&this.scrollRafOwner?.cancelAnimationFrame(this.scrollRafId),this.scrollRafId=void 0,this.scrollRafOwner=void 0,this.scrollRafDocument=void 0,this.pendingScrollTop=null,this.externalMetricsPending=!1,this.pendingScrollCorrection=void 0,this.detachContainerListeners(),this.scrollListenerTarget=void 0}firstUpdated(changed){super.firstUpdated(changed),this.attachContainerListeners(),queueMicrotask(()=>{this.isConnected&&(this.noTopLayer=!nativePopoverSupported())})}requestUpdate(...args){args[0]===void 0&&(this.contentRefreshPending=!0),super.requestUpdate(...args)}willUpdate(changed){super.willUpdate(changed),this.projectionDeferred&&!this.hasUpdated&&this.ownerDocument?.defaultView&&this.seedFirstRenderState(this.releaseRowProjection),this.isFirstUpdate=!this.hasUpdated,this.hasUpdated&&(this.noTopLayer=!nativePopoverSupported());const contentRefresh=this.contentRefreshPending;this.contentRefreshPending=!1,contentRefresh&&(this.activeIndexFor=void 0);const sequence=contentRefresh||changed.has("items")&&!sameSequence(changed.get("items"),this.items)||changed.has("source")&&!sameSequence(changed.get("source"),this.source);sequence||changed.has("keyFunction")||changed.has("rowHeight")||changed.has("groups")||changed.has("activeItemId")||changed.has("scrollElement")?this.pendingScrollCorrection=void 0:this.pendingScrollCorrection&&(this.pendingScrollCorrection.source=this.effectiveSource),this.appendIdentityStart=-1;const previous=changed.has("source")?changed.get("source"):changed.get("items"),current=this.effectiveSource;if(sequence&&Array.isArray(previous)&&Array.isArray(current)&&previous.length<current.length&&previous.length===this.rowIdentities.length&&!changed.has("keyFunction")&&!changed.has("groups")&&!changed.has("rowHeight")&&previous.every((item,index)=>Object.is(item,current[index]))&&(this.appendIdentityStart=previous.length),(sequence||changed.has("keyFunction"))&&(this.identitiesDirty=!0),(sequence||changed.has("rowHeight")||changed.has("keyFunction")||changed.has("groups"))&&(this.offsetsDirty=!0,this.offsetDirtyStart=Math.min(this.offsetDirtyStart,this.appendIdentityStart>=0?this.appendIdentityStart:0)),sequence&&(this.compositionScrollTarget=void 0,this.itemsChangedPendingPrune=!0),changed.has("keyFunction")||isIndexedSource(this.effectiveSource)&&sequence){this.measuredHeights.clear(),this.measuredIndices.clear(),this.pendingRowMeasurements.clear(),this.indexedMeasurementIndexDirty=!0;for(const row of this.observedRows.values())this.rowResizeObserver?.unobserve(row);this.observedRows.clear(),this.deferredRowObservations.clear()}if(changed.has("groups")){this.measuredGroupHeights.clear(),this.pendingGroupMeasurements.clear();for(const marker of this.observedGroups.values())this.groupResizeObserver?.unobserve(marker);this.observedGroups.clear(),this.deferredGroupObservations.clear()}if((sequence||changed.has("groups"))&&this.recomputeGroups(),changed.has("rowHeight")&&(this.fixedRowHeight=this.parseRowHeight(this.rowHeight),this.fixedRowHeight!=null&&(this.measuredHeights.clear(),this.measuredIndices.clear(),this.pendingRowMeasurements.clear(),this.indexedMeasurementIndexDirty=!0)),this.offsetsDirty&&(this.recomputeOffsets(),this.offsetsDirty=!1,this.offsetDirtyStart=1/0),changed.has("activeItemId")&&!this.isFirstUpdate&&this.composition.profile){const index=this.activeIndex;index>=0&&(this.compositionScrollTarget=index)}this.computeRange(),this.limitCompositionWindow()}updated(changed){super.updated(changed),this.syncRowProjection(),this.syncRowObservers(),this.syncGroupObservers(),this.syncStickyOverlay(),changed.has("scrollElement")&&!this.isFirstUpdate&&this.attachContainerListeners(),changed.has("activeItemId")&&!this.isFirstUpdate&&this.scrollActiveIntoView(),this.emitRangeChangeIfNeeded(),this.maybeFireLoadMore(),this.maybeCorrectPendingScroll()}parseRowHeight(value){const normalized=normalizeRowHeight(value);return normalized==="auto"?null:normalized}get effectiveSource(){return this.source??this.items}get itemCount(){const source=this.effectiveSource;return isIndexedSource(source)?finiteCount(source.count):source.length}itemAt(index){const source=this.effectiveSource;return isIndexedSource(source)?source.itemAt(index):source[index]}keyOf(item,index){const source=this.effectiveSource,key=this.keyFunction?this.keyFunction(item,index):isIndexedSource(source)?source.keyAt?.(index)??index:index;return typeof key=="string"||typeof key=="number"?key:index}rowIdentity(key,occurrence){const token=domKeyToken(key);return`${token.length}:${token}:${occurrence}`}identityAt(index,item){return arguments.length<2&&this.keyFunction&&(item=this.itemAt(index)),isIndexedSource(this.effectiveSource)?this.rowIdentity(this.keyOf(item,index),index):this.rowIdentities[index]??this.rowIdentity(this.keyOf(item,index),index)}groupHeightAt(index){const group=this.normalizedGroupByIndex.get(index);return!group||group.label===""?0:this.measuredGroupHeights.get(index)??DEFAULT_GROUP_ESTIMATE_PX}rowHeightAt(index){return this.fixedRowHeight!=null?this.fixedRowHeight:this.measuredHeights.get(this.identityAt(index))??DEFAULT_ROW_ESTIMATE_PX}groupContributionThrough(index){return this.groupHeightPrefix[this.groupCountThrough(index)]??0}groupCountThrough(index){let low=0,high=this.normalizedGroups.length;for(;low<high;){const middle=low+high>>1;this.normalizedGroups[middle].startIndex<=index?low=middle+1:high=middle}return low}recomputeGroupHeightPrefix(){const prefix=new Array(this.normalizedGroups.length+1);prefix[0]=0;for(let index=0;index<this.normalizedGroups.length;index++){const group=this.normalizedGroups[index],height=group.label===""?0:this.measuredGroupHeights.get(group.startIndex)??DEFAULT_GROUP_ESTIMATE_PX;prefix[index+1]=finiteAdd(prefix[index],height)}this.groupHeightPrefix=prefix}indexedOffsetForIndex(index){const baseHeight=this.fixedRowHeight??DEFAULT_ROW_ESTIMATE_PX;let offset=index>Number.MAX_VALUE/baseHeight?Number.MAX_VALUE:index*baseHeight;if(this.fixedRowHeight==null){this.rebuildIndexedMeasurementIndex();let low=0,high=this.indexedMeasurementIndices.length;for(;low<high;){const middle=low+high>>1;this.indexedMeasurementIndices[middle]<index?low=middle+1:high=middle}offset=finiteAdd(offset,this.indexedMeasurementDeltaPrefix[low]??0)}return Math.max(0,finiteAdd(offset,this.groupContributionThrough(index)))}rebuildIndexedMeasurementIndex(){if(!this.indexedMeasurementIndexDirty)return;const retained=[];for(const[identity,index]of this.measuredIndices){const height=this.measuredHeights.get(identity);height!==void 0&&retained.push({index,delta:height-DEFAULT_ROW_ESTIMATE_PX})}retained.sort((a,b)=>a.index-b.index);const indices=new Array(retained.length),prefix=new Array(retained.length+1);prefix[0]=0;for(let position=0;position<retained.length;position++){const measurement=retained[position];indices[position]=measurement.index,prefix[position+1]=finiteAdd(prefix[position],measurement.delta)}this.indexedMeasurementIndices=indices,this.indexedMeasurementDeltaPrefix=prefix,this.indexedMeasurementIndexDirty=!1}pruneIndexedMeasurements(){if(!isIndexedSource(this.effectiveSource)||this.fixedRowHeight!=null||this.renderEnd<this.renderStart)return!1;const renderedCount=this.renderEnd-this.renderStart+1,retentionRows=Math.max(renderedCount,normalizeOverscan(this.overscan)*4),firstRetained=Math.max(0,this.renderStart-retentionRows),lastRetained=Math.min(this.itemCount-1,this.renderEnd+retentionRows);let removedDeltaBeforeWindow=0,pruned=!1;for(const[identity,measuredIndex]of this.measuredIndices)if(measuredIndex<firstRetained||measuredIndex>lastRetained){const height=this.measuredHeights.get(identity);height!==void 0&&measuredIndex<firstRetained&&(removedDeltaBeforeWindow=finiteAdd(removedDeltaBeforeWindow,height-DEFAULT_ROW_ESTIMATE_PX)),this.measuredIndices.delete(identity),this.measuredHeights.delete(identity),pruned=!0}if(pruned&&(this.indexedMeasurementIndexDirty=!0,removedDeltaBeforeWindow!==0)){const nextScrollTop=(this.readScrollMetrics()?.rawScrollTop??this.containerScrollTop)-removedDeltaBeforeWindow;this.applyScrollPosition(nextScrollTop),this.containerScrollTop=Math.max(0,nextScrollTop),this.pendingScrollTop=null}return pruned}offsetAt(index){return isIndexedSource(this.effectiveSource)?this.indexedOffsetForIndex(index):this.offsets[index]??0}recomputeOffsets(){const n=this.itemCount;if(this.groupPrefixDirty&&(this.recomputeGroupHeightPrefix(),this.groupPrefixDirty=!1),isIndexedSource(this.effectiveSource)){this.offsets=[0],this.rowIdentities=[],this.rowKeys=[],this.identityIndices.clear(),this.keyIndices.clear(),this.keyOccurrences.clear(),this.itemsChangedPendingPrune=!1;return}const append=this.appendIdentityStart>=0,start=this.identitiesDirty&&!append?0:Math.min(n,this.offsetDirtyStart),offsets=start>0?this.offsets:new Array(n+1);let cursor=start>0?finiteAdd(this.offsets[start-1],this.rowHeightAt(start-1)):0;const liveKeys=this.itemsChangedPendingPrune&&!append&&this.fixedRowHeight==null?new Set:null,occurrences=append?this.keyOccurrences:new Map;this.identitiesDirty&&!append&&(this.identityIndices.clear(),this.keyIndices.clear(),this.rowKeys=[]);const reuse=!this.identitiesDirty&&this.rowIdentities.length===n,identities=reuse||append?this.rowIdentities:new Array(n);for(let i=start;i<n;i++){if(cursor=finiteAdd(cursor,this.groupHeightAt(i)),offsets[i]=cursor,!reuse){const key=this.keyOf(this.itemAt(i),i),token=domKeyToken(key),occurrence=occurrences.get(token)??0;occurrences.set(token,occurrence+1),identities[i]=this.rowIdentity(key,occurrence),this.rowKeys[i]=key,this.identityIndices.set(identities[i],i),this.keyIndices.has(token)||this.keyIndices.set(token,i)}const identity=identities[i];let h;this.fixedRowHeight!=null?h=this.fixedRowHeight:(liveKeys?.add(identity),h=this.measuredHeights.get(identity)??DEFAULT_ROW_ESTIMATE_PX),cursor=finiteAdd(cursor,h)}if(offsets[n]=cursor,this.offsets=offsets,this.rowIdentities=identities,reuse||(this.keyOccurrences=occurrences),this.identitiesDirty=!1,this.itemsChangedPendingPrune=!1,liveKeys)for(const key of this.measuredHeights.keys())liveKeys.has(key)||(this.measuredHeights.delete(key),this.measuredIndices.delete(key),this.indexedMeasurementIndexDirty=!0)}groupTopAt(index){return Math.max(0,this.offsetAt(index)-this.groupHeightAt(index))}rowBottomAt(index){return finiteAdd(this.offsetAt(index),this.rowHeightAt(index))}entryTopAt(index){return this.groupTopAt(index)}findIndexAtOrAfter(offset){let lo=0,hi=this.itemCount-1;for(;lo<hi;){const mid=lo+Math.floor((hi-lo)/2);this.rowBottomAt(mid)<=offset?lo=mid+1:hi=mid}return lo}findIndexAtOrBefore(offset){let lo=0,hi=this.itemCount-1;for(;lo<hi;){const mid=lo+Math.ceil((hi-lo)/2);this.entryTopAt(mid)<offset?lo=mid:hi=mid-1}return lo}offsetForIndex(index){const clamped=Math.min(this.itemCount,Math.max(0,Math.trunc(index)||0));return this.offsetAt(clamped)}indexAtOffset(px){const n=this.itemCount;return n===0?-1:Number.isFinite(px)?Math.min(n-1,Math.max(0,this.findIndexAtOrAfter(px))):px>0?n-1:0}computeRange(){const n=this.itemCount;if(n===0){this.visibleStart=0,this.visibleEnd=-1,this.renderStart=0,this.renderEnd=-1;return}if(this.viewportHeight<=0){if(!this.renderUnmeasuredWindow){this.visibleStart=0,this.visibleEnd=-1,this.renderStart=0,this.renderEnd=-1;return}this.visibleStart=0,this.visibleEnd=0,this.renderStart=0,this.renderEnd=Math.min(n-1,normalizeOverscan(this.overscan));return}const viewTop=this.containerScrollTop,viewBottom=viewTop+this.viewportHeight;this.visibleStart=this.findIndexAtOrAfter(viewTop),this.visibleEnd=this.findIndexAtOrBefore(viewBottom);const overscan=normalizeOverscan(this.overscan);this.renderStart=Math.max(0,this.visibleStart-overscan),this.renderEnd=Math.min(n-1,this.visibleEnd+overscan),this.pruneIndexedMeasurements()&&this.computeRange()}limitCompositionWindow(){const profile=this.composition.profile;if(!profile||this.renderEnd<this.renderStart)return;const start=this.renderStart,end=this.renderEnd,focused=this.focusedRowOutsideWindow(!0),requested=this.compositionScrollTarget,anchor=requested!==void 0&&requested>=start&&requested<=end?requested:Math.max(start,this.visibleStart),range=budget=>{this.renderStart=Math.max(start,Math.min(anchor-Math.min(normalizeOverscan(this.overscan),budget-1),end-budget+1)),this.renderEnd=Math.min(end,this.renderStart+budget-1)};range(profile.maxRows),focused>=0&&(focused<this.renderStart||focused>this.renderEnd)&&range(profile.maxRows-1)}setCompositionScrollTarget(index){if(!this.composition.profile||this.compositionScrollTarget===index)return;const previous=this.compositionScrollTarget;this.compositionScrollTarget=index,this.requestUpdate("compositionScrollTarget",previous)}attachContainerListeners(){const base=this.scrollContainer,ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!base||!this.isConnected||!ownerWindow)return;this.containerResizeObserver?.disconnect(),this.containerResizeObserver=void 0,this.detachContainerListeners();const external=this.externalScroller;if(external&&ownerWindow.MutationObserver){const observer=new ownerWindow.MutationObserver(this.invalidateExternalGeometry);for(let ancestor=this;ancestor;ancestor=composedParentElement(ancestor))observer.observe(ancestor,{attributes:!0,attributeFilter:["style","class"]});this.externalStyleObserver=observer}const scrollTarget=external??base,generation=this.ownerRealmGeneration,ResizeObserverCtor=ownerWindow.ResizeObserver;if(ResizeObserverCtor){const observer=new ResizeObserverCtor(entries=>{if(this.containerResizeObserver!==observer||this.scrollListenerTarget!==scrollTarget||!this.isCurrentOwnerWork(ownerDocument,generation))return;if(this.beginResizeDelivery(),external){this.externalGeometry=void 0,this.syncExternalScrollMetrics();return}const entry=entries[0];entry&&(this.viewportHeight=entry.borderBoxSize?.[0]?.blockSize??entry.contentRect.height)});this.containerResizeObserver=observer,observer.observe(base),external&&!isWindowScroller(external)&&observer.observe(external)}scrollTarget.addEventListener("scroll",this.onScroll,{passive:!0}),scrollTarget.addEventListener("wheel",this.onUserScrollIntent,{passive:!0}),scrollTarget.addEventListener("pointerdown",this.onUserScrollIntent,{passive:!0}),scrollTarget.addEventListener("touchstart",this.onUserScrollIntent,{passive:!0}),scrollTarget.addEventListener("keydown",this.onUserScrollIntent),this.scrollListenerTarget=scrollTarget,external&&isWindowScroller(external)&&(external.addEventListener("resize",this.onExternalViewportResize,{passive:!0}),this.viewportResizeTarget=external),ownerWindow.queueMicrotask(()=>{if(this.scrollListenerTarget!==scrollTarget||this.scrollContainer!==base||!this.isCurrentOwnerWork(ownerDocument,generation))return;const metrics=this.readScrollMetrics();metrics&&(this.viewportHeight!==metrics.viewportHeight&&(this.viewportHeight=metrics.viewportHeight),this.containerScrollTop!==metrics.scrollTop&&(this.containerScrollTop=metrics.scrollTop))})}detachContainerListeners(){this.scrollRoundingAnchor=void 0,this.externalStyleObserver?.disconnect(),this.externalStyleObserver=void 0,this.externalGeometry=void 0;const viewportTarget=this.viewportResizeTarget;viewportTarget&&(viewportTarget.removeEventListener("resize",this.onExternalViewportResize),this.viewportResizeTarget=void 0);const target=this.scrollListenerTarget;target&&(target.removeEventListener("scroll",this.onScroll),target.removeEventListener("wheel",this.onUserScrollIntent),target.removeEventListener("pointerdown",this.onUserScrollIntent),target.removeEventListener("touchstart",this.onUserScrollIntent),target.removeEventListener("keydown",this.onUserScrollIntent))}applyPendingRowMeasurements(){if(this.pendingRowMeasurements.size===0)return;const observations=[...this.pendingRowMeasurements];if(this.pendingRowMeasurements.clear(),this.fixedRowHeight!=null)return;const base=this.scrollContainer,oldScrollTop=this.readScrollMetrics()?.rawScrollTop??this.containerScrollTop;let scrollAdjustment=0,changed=!1;const indexed=isIndexedSource(this.effectiveSource),measuredByIndex=indexed?new Map:void 0;if(measuredByIndex)for(const[identity,index]of this.measuredIndices)measuredByIndex.set(index,identity);for(const[key,{index,height}]of observations){if(indexed&&(index<0||index>=this.itemCount||this.identityAt(index)!==key))continue;const previousKey=measuredByIndex?.get(index)??key,prev=this.measuredHeights.get(previousKey),replaced=previousKey!==key;if(replaced||prev===void 0||Math.abs(prev-height)>.5){const oldHeight=prev??DEFAULT_ROW_ESTIMATE_PX,oldBottom=indexed?finiteAdd(this.offsetAt(index),oldHeight):this.rowBottomAt(index);this.offsetDirtyStart=Math.min(this.offsetDirtyStart,index),replaced&&(this.measuredHeights.delete(previousKey),this.measuredIndices.delete(previousKey)),this.measuredHeights.set(key,height),this.measuredIndices.set(key,index),measuredByIndex?.set(index,key),oldBottom<=oldScrollTop&&(scrollAdjustment+=height-oldHeight),changed=!0}}if(changed){if(this.indexedMeasurementIndexDirty=!0,base&&scrollAdjustment!==0){const nextScrollTop=oldScrollTop+scrollAdjustment;this.applyScrollPosition(nextScrollTop),this.containerScrollTop=Math.max(0,nextScrollTop),this.pendingScrollTop=null}this.offsetsDirty=!0,this.measurementGeneration+=1,super.requestUpdate()}}applyPendingGroupMeasurements(){if(this.pendingGroupMeasurements.size===0)return;const observations=[...this.pendingGroupMeasurements];this.pendingGroupMeasurements.clear();const base=this.scrollContainer,oldScrollTop=this.readScrollMetrics()?.rawScrollTop??this.containerScrollTop;let scrollAdjustment=0,changed=!1;for(const[index,height]of observations){if(!this.normalizedGroupByIndex.has(index))continue;const previous=this.measuredGroupHeights.get(index)??DEFAULT_GROUP_ESTIMATE_PX;if(Math.abs(previous-height)<=.5)continue;const oldRowTop=this.offsetAt(index);this.offsetDirtyStart=Math.min(this.offsetDirtyStart,index),this.groupPrefixDirty=!0,this.measuredGroupHeights.set(index,height),oldRowTop<=oldScrollTop&&(scrollAdjustment+=height-previous),changed=!0}if(changed){if(base&&scrollAdjustment!==0){const nextScrollTop=oldScrollTop+scrollAdjustment;this.applyScrollPosition(nextScrollTop),this.containerScrollTop=Math.max(0,nextScrollTop),this.pendingScrollTop=null}this.offsetsDirty=!0,this.measurementGeneration+=1,super.requestUpdate()}}get defersMeasurementApplication(){return this.inResizeDelivery&&this.externalScroller!==void 0}beginResizeDelivery(){if(this.inResizeDelivery=!0,this.rowObserveRafId!==void 0)return;const ownerDocument=this.ownerDocument,ownerWindow=ownerDocument.defaultView;if(!ownerWindow||!this.isConnected){this.inResizeDelivery=!1;return}const generation=this.ownerRealmGeneration,handle=ownerWindow.requestAnimationFrame(()=>{if(this.rowObserveRafId!==handle||this.rowObserveRafOwner!==ownerWindow||this.rowObserveRafDocument!==ownerDocument||!this.isCurrentOwnerWork(ownerDocument,generation))return;this.rowObserveRafId=void 0,this.rowObserveRafOwner=void 0,this.rowObserveRafDocument=void 0,this.inResizeDelivery=!1;const ro=this.rowResizeObserver;for(const[identity,el]of this.deferredRowObservations)ro&&this.observedRows.get(identity)===el&&ro.observe(el);this.deferredRowObservations.clear();const groupObserver=this.groupResizeObserver;for(const[index,el]of this.deferredGroupObservations)groupObserver&&this.observedGroups.get(index)===el&&groupObserver.observe(el);this.deferredGroupObservations.clear(),this.applyPendingRowMeasurements(),this.applyPendingGroupMeasurements()});this.rowObserveRafId=handle,this.rowObserveRafOwner=ownerWindow,this.rowObserveRafDocument=ownerDocument}syncRowObservers(){const ro=this.rowResizeObserver;if(!ro)return;if(this.fixedRowHeight!=null){for(const el of this.observedRows.values())ro.unobserve(el);this.observedRows.clear(),this.deferredRowObservations.clear();return}const current=new Map;for(const{identity,index}of this.renderedWindow){const el=this.rowElements.get(identity);el&&(current.set(identity,el),this.observedRowKeys.set(el,identity),this.observedRowIndices.set(el,index))}for(const[identity,el]of this.observedRows)current.get(identity)!==el&&(ro.unobserve(el),this.observedRows.delete(identity),this.deferredRowObservations.delete(identity));for(const[identity,el]of current)this.observedRows.has(identity)||(this.observedRows.set(identity,el),this.inResizeDelivery?this.deferredRowObservations.set(identity,el):ro.observe(el))}syncGroupObservers(){const observer=this.groupResizeObserver;if(!observer)return;const current=new Map;for(const[index,marker]of this.groupElements)current.set(index,marker),this.observedGroupIndices.set(marker,index);for(const[index,marker]of this.observedGroups)current.get(index)!==marker&&(observer.unobserve(marker),this.observedGroups.delete(index),this.deferredGroupObservations.delete(index));for(const[index,marker]of current)this.observedGroups.has(index)||(this.observedGroups.set(index,marker),this.inResizeDelivery?this.deferredGroupObservations.set(index,marker):observer.observe(marker))}get stickyInset(){return this.renderStickyGroup?this.stickyHeight:0}scrollActiveIntoView(){const index=this.activeIndex;if(index<0)return;const behavior=prefersReducedMotion(this)?"auto":"smooth";this.performScrollTo(index,"auto",behavior)&&this.beginPendingScrollCorrection(index,"auto",behavior,this.activeItemId)}scrollToIndex(index,options){const n=this.itemCount;if(n===0)return;const clamped=finiteInteger(index,0,0,n-1);this.setCompositionScrollTarget(clamped);const align=options?.align??"auto",behavior=prefersReducedMotion(this)?"auto":options?.behavior??"smooth";this.performScrollTo(clamped,align,behavior)?this.beginPendingScrollCorrection(clamped,align,behavior):this.pendingScrollCorrection=void 0}hasUnmeasuredGroupThrough(index){return this.normalizedGroups.some(group=>group.startIndex<=index&&group.label!==""&&!this.measuredGroupHeights.has(group.startIndex))}beginPendingScrollCorrection(index,align,behavior,activeItemId){if(this.fixedRowHeight!=null&&!this.hasUnmeasuredGroupThrough(index)){this.pendingScrollCorrection=void 0;return}this.pendingScrollCorrection={identity:this.identityAt(index),index,align,behavior,source:this.effectiveSource,keyFunction:this.keyFunction,activeItemId:activeItemId===""?void 0:activeItemId,lastMeasurementGeneration:this.measurementGeneration}}performScrollTo(index,align,behavior){const metrics=this.readScrollMetrics();if(!metrics)return!1;const inset=this.stickyInset,top=this.offsetAt(index),bottom=this.rowBottomAt(index),viewTop=metrics.rawScrollTop,viewBottom=viewTop+metrics.viewportHeight;let target=null;return align==="start"?target=top-inset:align==="end"?target=bottom-metrics.viewportHeight:top-inset<viewTop?target=top-inset:bottom>viewBottom&&(target=bottom-metrics.viewportHeight),target===null?!1:(this.applyScrollPosition(target,behavior),!0)}maybeCorrectPendingScroll(){const pending=this.pendingScrollCorrection;if(!pending||pending.lastMeasurementGeneration>=this.measurementGeneration)return;if(pending.source!==this.effectiveSource||pending.keyFunction!==this.keyFunction||pending.activeItemId!==void 0&&!Object.is(pending.activeItemId,this.activeItemId)){this.pendingScrollCorrection=void 0;return}const index=pending.activeItemId!==void 0?this.activeIndex:isIndexedSource(this.effectiveSource)?pending.index:this.identityIndices.get(pending.identity)??-1;if(index<0||index>=this.itemCount||this.identityAt(index)!==pending.identity){this.pendingScrollCorrection=void 0;return}this.performScrollTo(index,pending.align,pending.behavior),pending.index=index,pending.lastMeasurementGeneration=this.measurementGeneration,(this.fixedRowHeight!=null||this.measuredHeights.has(pending.identity))&&!this.hasUnmeasuredGroupThrough(index)&&(this.pendingScrollCorrection=void 0)}emitRangeChangeIfNeeded(){if(this.visibleEnd<this.visibleStart){this.lastEmittedStart=-1,this.lastEmittedEnd=-1;return}this.visibleStart===this.lastEmittedStart&&this.visibleEnd===this.lastEmittedEnd||(this.lastEmittedStart=this.visibleStart,this.lastEmittedEnd=this.visibleEnd,this.emit("lr-visible-range-change",{start:this.visibleStart,end:this.visibleEnd}))}maybeFireLoadMore(){const n=this.itemCount;if(!(n>0&&this.visibleEnd>=n-1)){this.loadMoreArmed=!0;return}!this.hasMore||this.loading||!this.loadMoreArmed||(this.loadMoreArmed=!1,this.emit("lr-load-more"))}get projectionActive(){return!this.projectionDeferred&&this.rowProjection==="light"}rowSlotName(identity){return`${tag("virtual-list")}-row-${identity}`}syncRowProjection(){if(!this.projectionActive||!this.isConnected){this.projectionAnchor!==void 0&&this.teardownRowProjection();return}const anchor=this.ensureProjectionAnchor();this.projectionPart=render(this.renderProjectedRows(),this,{renderBefore:anchor,host:this})}ensureProjectionAnchor(){const existing=this.projectionAnchor;if(existing!==void 0&&existing.parentNode===this&&existing.ownerDocument===this.ownerDocument)return existing;existing!==void 0&&this.teardownRowProjection();const anchor=this.ownerDocument.createComment(PROJECTION_ANCHOR_MARKER);return this.append(anchor),this.projectionAnchor=anchor,this.projectionPart=void 0,anchor}teardownRowProjection(){const anchor=this.projectionAnchor,part=this.projectionPart;if(this.projectionAnchor=void 0,this.projectionPart=void 0,anchor!==void 0){if(part!==void 0){const container=anchor.parentNode;container!==null&&render(nothing,container,{renderBefore:anchor,host:this});const start=part.startNode;start?.parentNode?.removeChild(start)}anchor.parentNode?.removeChild(anchor)}}renderProjectedRows(){return repeat(this.renderedWindow,w=>w.identity,w=>staticHtml`<div
|
|
2
2
|
${ROW_ATTRIBUTE_STATIC}
|
|
3
3
|
slot=${this.rowSlotName(w.identity)}
|
|
4
4
|
data-row-index=${w.index}
|
|
@@ -15,11 +15,7 @@ icon?:unknown;
|
|
|
15
15
|
* since the visible label text already supplies the accessible name. If both `label` and
|
|
16
16
|
* `ariaLabel` are omitted, the button falls back to its own `viewId` as a last-resort accessible name:
|
|
17
17
|
* not silently unlabeled, but not a good name either, so set one of the two for any icon-only view. */
|
|
18
|
-
ariaLabel?:string;}export interface LyraWidgetEventMap{
|
|
19
|
-
/** @deprecated Use `lr-toggle-request`; its detail uses expanded polarity. */
|
|
20
|
-
'lr-collapse-request':CustomEvent<{collapsed:boolean;}>;
|
|
21
|
-
/** @deprecated Use `lr-toggle`; its detail uses expanded polarity. */
|
|
22
|
-
'lr-collapse-change':CustomEvent<{collapsed:boolean;}>;'lr-toggle-request':CustomEvent<{expanded:boolean;}>;'lr-toggle':CustomEvent<{expanded:boolean;}>;'lr-fullscreen-request':CustomEvent<{fullscreen:boolean;}>;'lr-fullscreen-change':CustomEvent<{fullscreen:boolean;}>;'lr-view-request':CustomEvent<{viewId:string;}>;'lr-view-change':CustomEvent<{viewId:string;}>;'lr-activate':CustomEvent<{value:string;}>;}
|
|
18
|
+
ariaLabel?:string;}export interface LyraWidgetEventMap{'lr-toggle-request':CustomEvent<{expanded:boolean;}>;'lr-toggle':CustomEvent<{expanded:boolean;}>;'lr-fullscreen-request':CustomEvent<{fullscreen:boolean;}>;'lr-fullscreen-change':CustomEvent<{fullscreen:boolean;}>;'lr-view-request':CustomEvent<{viewId:string;}>;'lr-view-change':CustomEvent<{viewId:string;}>;'lr-activate':CustomEvent<{value:string;}>;}
|
|
23
19
|
/**
|
|
24
20
|
* `<lr-widget>` — a titled panel shell with an optional collapse toggle and
|
|
25
21
|
* an optional fullscreen-expand toggle. Fullscreen promotes the same host
|
|
@@ -30,8 +26,6 @@ ariaLabel?:string;}export interface LyraWidgetEventMap{
|
|
|
30
26
|
* @slot - The panel body.
|
|
31
27
|
* @slot start - Optional decorative leading icon in the title row. Its flattened subtree is inert
|
|
32
28
|
* and hidden from assistive technology.
|
|
33
|
-
* @slot icon - Legacy slot content is deprecated; use `start`. Its flattened subtree is inert and
|
|
34
|
-
* hidden from assistive technology.
|
|
35
29
|
* @slot label - Rich label content (overrides the `label` attribute).
|
|
36
30
|
* @slot sublabel - Rich sublabel content (overrides the `sublabel` attribute).
|
|
37
31
|
* @slot actions - Header action controls, rendered before the collapse/expand buttons.
|
|
@@ -48,14 +42,11 @@ ariaLabel?:string;}export interface LyraWidgetEventMap{
|
|
|
48
42
|
* while `expandable`.
|
|
49
43
|
* @slot view-{viewId} - Content for the view whose `LyraWidgetView.viewId` matches `{viewId}`, rendered when
|
|
50
44
|
* `views` is non-empty.
|
|
51
|
-
* @event lr-collapse-request - A cancelable proposed `collapsed` state from the built-in collapse
|
|
52
|
-
* toggle. Call `preventDefault()` to keep `collapsed` and persistence unchanged. Not fired when
|
|
53
|
-
* a consumer sets `collapsed` directly. `detail: { collapsed }`.
|
|
54
|
-
* @event lr-collapse-change - Non-cancelable post-commit notification from the built-in collapse
|
|
55
|
-
* toggle. Not fired when a consumer sets `collapsed` directly. `detail: { collapsed }` (the new
|
|
56
|
-
* `collapsed` state).
|
|
57
45
|
* @event lr-toggle-request - Cancelable proposed `detail: { expanded }` before the built-in toggle commits.
|
|
58
|
-
*
|
|
46
|
+
* Call `preventDefault()` to keep `collapsed` and persistence unchanged. Not fired when a consumer
|
|
47
|
+
* sets `collapsed` directly.
|
|
48
|
+
* @event lr-toggle - Accepted built-in disclosure change with `detail: { expanded }`. Not fired when a
|
|
49
|
+
* consumer sets `collapsed` directly.
|
|
59
50
|
* @event lr-fullscreen-request - A cancelable proposed `fullscreen` state from the fullscreen
|
|
60
51
|
* toggle, Escape, or a backdrop click. Call `preventDefault()` to leave `fullscreen` unchanged.
|
|
61
52
|
* Not fired when a consumer sets `fullscreen` directly. `detail: { fullscreen }`.
|