@aceshooting/lyra-ui 30.9.0 → 31.1.1
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 +361 -335
- package/dist/ai/adapters/ag-ui.js +1 -1
- package/dist/autoloader-cdn.js +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
- package/dist/components/agent-tools/budget-meter/budget-meter.class.d.ts +12 -1
- package/dist/components/agent-tools/budget-meter/budget-meter.class.js +4 -4
- package/dist/components/agent-tools/compare-panel/compare-panel.class.js +1 -1
- package/dist/components/agent-tools/eval-dataset/eval-dataset.class.js +1 -1
- package/dist/components/agent-tools/thinking-panel/thinking-panel.class.js +1 -1
- package/dist/components/agent-tools/tool-select-dialog/tool-select-dialog.class.js +1 -1
- package/dist/components/charts/chart/box-plot.class.js +2 -2
- package/dist/components/charts/chart/chart-sync.js +1 -1
- package/dist/components/charts/chart/chart.class.d.ts +1 -1
- package/dist/components/charts/chart/chart.class.js +4 -4
- package/dist/components/charts/chart/lite-chart-axis-layout.js +1 -1
- package/dist/components/charts/chart/lite-chart.class.js +2 -2
- package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +26 -11
- package/dist/components/conversation/chat-composer/chat-composer.class.js +11 -9
- package/dist/components/conversation/chat-composer/chat-composer.styles.js +1 -1
- package/dist/components/conversation/chat-message/chat-message.class.d.ts +27 -3
- package/dist/components/conversation/chat-message/chat-message.class.js +14 -12
- package/dist/components/conversation/chat-message/chat-message.styles.js +1 -1
- package/dist/components/conversation/chat-viewport/chat-viewport.class.d.ts +29 -2
- package/dist/components/conversation/chat-viewport/chat-viewport.class.js +2 -2
- package/dist/components/conversation/chat-viewport/chat-viewport.styles.js +1 -1
- package/dist/components/conversation/code-block/code-block-shared.js +1 -1
- package/dist/components/conversation/markdown/markdown-base.class.d.ts +1 -1
- package/dist/components/conversation/markdown/markdown-base.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-code-header.js +1 -1
- package/dist/components/conversation/markdown/markdown-core.class.d.ts +10 -0
- package/dist/components/conversation/markdown/markdown-core.class.js +1 -1
- package/dist/components/conversation/markdown/markdown-shared.d.ts +7 -2
- package/dist/components/conversation/markdown/markdown-shared.js +3 -3
- package/dist/components/conversation/markdown/markdown.class.d.ts +10 -0
- package/dist/components/conversation/markdown/markdown.class.js +1 -1
- package/dist/components/conversation/message-feedback/message-feedback.class.d.ts +11 -3
- package/dist/components/conversation/message-feedback/message-feedback.class.js +12 -6
- package/dist/components/conversation/message-feedback/message-feedback.styles.js +1 -1
- package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +8 -4
- package/dist/components/conversation/prompt-input/prompt-input.class.js +3 -2
- package/dist/components/conversation/push-to-talk/push-to-talk.class.js +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-base.class.d.ts +4 -0
- package/dist/components/conversation/streaming-text/streaming-text-base.class.js +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-core.class.d.ts +1 -1
- package/dist/components/conversation/streaming-text/streaming-text-core.class.js +1 -0
- package/dist/components/conversation/streaming-text/streaming-text.class.d.ts +1 -1
- package/dist/components/conversation/streaming-text/streaming-text.class.js +1 -0
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.d.ts +17 -3
- package/dist/components/conversation/suggestion-chips/suggestion-chips.class.js +3 -3
- package/dist/components/conversation/suggestion-chips/suggestion-chips.d.ts +1 -1
- package/dist/components/conversation/suggestion-chips/suggestion-chips.js +1 -1
- package/dist/components/conversation/suggestion-chips/suggestion-chips.styles.js +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.d.ts +1 -1
- package/dist/components/conversation/thread-list/thread-list.class.js +3 -3
- package/dist/components/conversation/transcript-feed/transcript-feed.class.js +1 -1
- package/dist/components/data/data-grid/data-grid.class.d.ts +10 -10
- package/dist/components/data/data-grid/data-grid.class.js +1 -1
- package/dist/components/data/document-library/document-library-cursor.js +1 -0
- package/dist/components/data/document-library/document-library-types.d.ts +20 -0
- package/dist/components/data/document-library/document-library.class.d.ts +37 -26
- package/dist/components/data/document-library/document-library.class.js +20 -11
- package/dist/components/data/document-library/document-library.styles.js +1 -1
- package/dist/components/data/file-tree/file-tree.class.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.d.ts +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.js +2 -2
- package/dist/components/data/heatmap/heatmap.class.d.ts +1 -1
- package/dist/components/data/heatmap/heatmap.class.js +1 -1
- package/dist/components/data/pagination/pagination.class.js +1 -1
- package/dist/components/data/table/table.class.d.ts +31 -2
- package/dist/components/data/table/table.class.js +3 -3
- package/dist/components/data/table/table.styles.js +1 -1
- package/dist/components/data/timeline/timeline-cluster.js +1 -1
- package/dist/components/data/timeline/timeline-item.class.d.ts +10 -3
- package/dist/components/data/timeline/timeline-item.class.js +16 -12
- package/dist/components/data/timeline/timeline-item.styles.js +1 -1
- package/dist/components/data/timeline/timeline.class.d.ts +14 -2
- package/dist/components/data/timeline/timeline.class.js +9 -5
- package/dist/components/data/tree/tree-item.class.js +1 -1
- package/dist/components/data/tree/tree.class.d.ts +2 -0
- package/dist/components/data/tree/tree.class.js +1 -1
- package/dist/components/forms/button/button.class.d.ts +8 -6
- package/dist/components/forms/button/button.class.js +2 -2
- package/dist/components/forms/checkbox-group/checkbox-group.class.js +1 -1
- package/dist/components/forms/color-picker/color-core.js +1 -1
- package/dist/components/forms/combobox/combobox.class.d.ts +20 -12
- package/dist/components/forms/combobox/combobox.class.js +2 -2
- package/dist/components/forms/date-picker/date-input.class.d.ts +1 -1
- package/dist/components/forms/date-picker/date-input.class.js +1 -1
- package/dist/components/forms/icon-button/icon-button.class.d.ts +4 -2
- package/dist/components/forms/icon-button/icon-button.class.js +2 -2
- package/dist/components/forms/input/input-shared.js +2 -2
- package/dist/components/forms/input/number-input-locale.js +1 -0
- package/dist/components/forms/input/number-input.class.d.ts +19 -2
- package/dist/components/forms/input/number-input.class.js +2 -2
- package/dist/components/forms/locale-picker/locale-picker.class.d.ts +3 -3
- package/dist/components/forms/locale-picker/locale-picker.class.js +1 -1
- package/dist/components/layout/app-rail-group/app-rail-group.class.js +1 -1
- package/dist/components/layout/details/accordion-item.class.js +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.d.ts +1 -1
- package/dist/components/layout/dock-panel/dock-panel.class.js +1 -1
- package/dist/components/layout/menu/menu.class.js +1 -1
- package/dist/components/layout/multi-split/multi-split.class.js +1 -1
- package/dist/components/layout/navigation-menu-item/navigation-menu-item.class.js +1 -1
- package/dist/components/layout/page/page.class.d.ts +3 -3
- package/dist/components/layout/page/page.class.js +1 -1
- package/dist/components/layout/segmented/segmented.class.d.ts +20 -7
- package/dist/components/layout/segmented/segmented.class.js +34 -24
- package/dist/components/layout/segmented/segmented.styles.js +1 -1
- package/dist/components/layout/stepper/stepper.styles.js +1 -1
- package/dist/components/layout/tab-group/tab-group.class.d.ts +8 -1
- package/dist/components/layout/tab-group/tab-group.class.js +1 -1
- package/dist/components/layout/tab-group/tab.class.d.ts +7 -1
- package/dist/components/layout/tab-group/tab.class.js +1 -1
- package/dist/components/layout/virtual-list/virtual-list.class.d.ts +2 -2
- package/dist/components/layout/virtual-list/virtual-list.class.js +1 -1
- package/dist/components/media/animated-image/animated-image.class.js +1 -1
- package/dist/components/media/attachment-chip/attachment-chip.class.d.ts +21 -14
- package/dist/components/media/attachment-chip/attachment-chip.class.js +1 -1
- package/dist/components/media/attachment-trigger/attachment-trigger.class.d.ts +36 -12
- package/dist/components/media/attachment-trigger/attachment-trigger.class.js +3 -3
- package/dist/components/media/drop-zone/drop-zone.class.d.ts +23 -5
- package/dist/components/media/drop-zone/drop-zone.class.js +2 -2
- package/dist/components/media/drop-zone/drop-zone.styles.js +1 -1
- package/dist/components/media/file-icon/file-icon.class.js +1 -1
- package/dist/components/media/flag/flag-url-resolver.js +1 -1
- package/dist/components/media/image-viewer/image-viewer.class.d.ts +2 -2
- package/dist/components/media/image-viewer/image-viewer.class.js +1 -1
- package/dist/components/media/map/map-anchor-controller.js +1 -1
- package/dist/components/media/map/map-canvas-target.js +1 -0
- package/dist/components/media/map/map-owned-features.js +1 -1
- package/dist/components/media/map/map-scene-elevated-lines.js +2 -2
- package/dist/components/media/map/map-scene-render-controller.js +1 -1
- package/dist/components/media/map/map.class.d.ts +15 -6
- package/dist/components/media/map/map.class.js +4 -4
- package/dist/components/media/map/map.styles.js +1 -1
- package/dist/components/media/pan-zoom/pan-zoom.class.js +1 -1
- package/dist/components/media/sequence-playback/sequence-playback.class.d.ts +21 -9
- package/dist/components/media/sequence-playback/sequence-playback.class.js +7 -6
- package/dist/components/media/sequence-playback/sequence-playback.styles.js +1 -1
- package/dist/components/media/video/video.class.d.ts +3 -3
- package/dist/components/media/video/video.class.js +3 -1
- package/dist/components/media/video-playlist/video-playlist.class.js +1 -1
- package/dist/components/overlays/chip/chip.class.js +1 -1
- package/dist/components/overlays/overlay/dropdown.class.js +1 -1
- package/dist/components/overlays/overlay/overlay.styles.js +1 -1
- package/dist/components/overlays/overlay/tooltip.class.d.ts +5 -1
- package/dist/components/overlays/overlay/tooltip.class.js +3 -3
- package/dist/components/retrieval/embedding-explorer/embedding-explorer-engine.js +1 -1
- package/dist/components/retrieval/graph/graph-node-renderer.js +1 -1
- package/dist/components/retrieval/graph/graph-spatial-controller.js +1 -1
- package/dist/components/retrieval/graph/graph.class.d.ts +1 -1
- package/dist/components/retrieval/graph/graph.class.js +1 -1
- package/dist/components/retrieval/ingestion-queue/ingestion-queue-presentation.d.ts +11 -0
- package/dist/components/retrieval/ingestion-queue/ingestion-queue-presentation.js +1 -0
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.d.ts +18 -7
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.class.js +13 -26
- package/dist/components/retrieval/ingestion-queue/ingestion-queue.styles.js +1 -1
- package/dist/components/retrieval/mind-map/mind-map.class.js +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.d.ts +1 -1
- package/dist/components/retrieval/neighbor-list/neighbor-list.class.js +3 -3
- package/dist/components/retrieval/retrieval-results/retrieval-results.class.js +1 -1
- package/dist/components/utility/diff-view/diff-view.class.d.ts +5 -5
- package/dist/components/utility/diff-view/diff-view.class.js +1 -1
- package/dist/components/utility/icon/icon.class.js +1 -1
- package/dist/components/utility/json-viewer/json-viewer.class.d.ts +16 -1
- package/dist/components/utility/json-viewer/json-viewer.class.js +4 -4
- package/dist/components/utility/json-viewer/json-viewer.styles.js +1 -1
- package/dist/components/utility/known-date/known-date.class.js +1 -1
- 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/csv-viewer/csv-viewer.class.js +1 -1
- package/dist/components/viewers/dataset-viewer/dataset-viewer.class.js +1 -1
- package/dist/components/viewers/document-preview/document-preview.class.js +2 -2
- package/dist/components/viewers/docx-viewer/docx-viewer.class.d.ts +1 -1
- package/dist/components/viewers/docx-viewer/docx-viewer.class.js +2 -2
- package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
- package/dist/components/viewers/email-viewer/email-viewer.class.d.ts +1 -1
- package/dist/components/viewers/email-viewer/email-viewer.class.js +2 -2
- 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/model-viewer/model-viewer.class.js +1 -1
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.d.ts +2 -2
- package/dist/components/viewers/pdf-viewer/pdf-viewer.class.js +2 -2
- package/dist/components/viewers/pptx-viewer/pptx-viewer.class.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
- package/dist/components/viewers/svg-viewer/svg-viewer.class.js +1 -1
- package/dist/components/viewers/table-viewer-shared.js +4 -4
- package/dist/components/viewers/xml-viewer/xml-viewer.class.js +2 -2
- package/dist/data-sources.d.ts +10 -0
- package/dist/events.d.ts +9 -4
- package/dist/framework-types.d.ts +1 -1
- package/dist/internal/anchored-overlay-runtime.js +1 -1
- package/dist/internal/catalog-picker.js +1 -1
- package/dist/internal/default-strings/conversation.generated.js +1 -1
- package/dist/internal/default-strings/data.generated.js +1 -1
- package/dist/internal/default-strings/retrieval.generated.js +1 -1
- package/dist/internal/document-tokens.js +2 -2
- package/dist/internal/drop-session-controller.js +1 -1
- package/dist/internal/engine-3d.js +1 -1
- package/dist/internal/icon-only-content.js +1 -1
- package/dist/internal/layered-layout.js +1 -1
- package/dist/internal/localization-types.d.ts +1 -1
- package/dist/internal/localization.js +1 -1
- package/dist/internal/lyra-element.js +2 -2
- package/dist/internal/map-custom-layer-controller.js +1 -1
- package/dist/internal/media-panorama.js +1 -1
- package/dist/internal/native-modal-context.js +1 -1
- package/dist/internal/overlay-manager.js +1 -1
- package/dist/internal/overlay-order.js +1 -1
- package/dist/internal/overlay-stack.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/runtime-diagnostics.js +1 -0
- package/dist/internal/safe-url.js +1 -1
- package/dist/internal/scoped-definitions.generated.js +1 -1
- package/dist/internal/scroll-overflow.js +1 -1
- package/dist/internal/source-cursor-controller.js +1 -0
- package/dist/internal/source-cursor-projection.js +1 -0
- package/dist/internal/source-page-scope.js +1 -1
- package/dist/internal/source-window-controller.js +1 -1
- package/dist/internal/text-quote.js +1 -1
- package/dist/internal/viewer-search.js +1 -1
- package/dist/lyra.d.ts +1 -1
- package/dist/sequence-time-binding.js +1 -1
- package/dist/simulation-clock.js +1 -1
- package/dist/styles/reservations.css +1 -1
- package/dist/styles/reservations.styles.js +1 -1
- package/dist/testing/happy-dom-shims.js +1 -1
- package/dist/theme/theme-bootstrap.js +1 -1
- package/dist/theme/theme.js +1 -1
- package/dist/utilities/overlay-manager.d.ts +2 -0
- package/llms/components/lr-attachment-chip.md +27 -12
- package/llms/components/lr-attachment-trigger.md +27 -7
- package/llms/components/lr-budget-meter.md +31 -0
- package/llms/components/lr-button.md +6 -4
- package/llms/components/lr-chat-composer.md +26 -9
- package/llms/components/lr-chat-message.md +44 -3
- package/llms/components/lr-chat-viewport.md +39 -2
- package/llms/components/lr-combobox.md +27 -1
- package/llms/components/lr-data-grid.md +2 -0
- package/llms/components/lr-dialog.md +10 -0
- package/llms/components/lr-diff-view.md +6 -0
- package/llms/components/lr-document-library.md +90 -6
- package/llms/components/lr-drop-zone.md +26 -2
- package/llms/components/lr-graph.md +5 -0
- package/llms/components/lr-icon-button.md +2 -1
- package/llms/components/lr-ingestion-queue.md +76 -8
- package/llms/components/lr-json-viewer.md +51 -0
- package/llms/components/lr-lite-chart.md +2 -1
- package/llms/components/lr-locale-picker.md +5 -0
- package/llms/components/lr-map.md +33 -0
- package/llms/components/lr-markdown-core.md +2 -1
- package/llms/components/lr-markdown.md +20 -4
- package/llms/components/lr-menu.md +3 -1
- package/llms/components/lr-message-feedback.md +38 -3
- package/llms/components/lr-number-input.md +28 -1
- package/llms/components/lr-page.md +4 -2
- package/llms/components/lr-prompt-input.md +6 -3
- package/llms/components/lr-segmented.md +30 -10
- package/llms/components/lr-sequence-playback.md +47 -12
- package/llms/components/lr-streaming-text-core.md +3 -2
- package/llms/components/lr-streaming-text.md +4 -1
- package/llms/components/lr-suggestion-chips.md +28 -5
- package/llms/components/lr-tab-group.md +13 -1
- package/llms/components/lr-tab.md +5 -0
- package/llms/components/lr-table.md +25 -4
- package/llms/components/lr-timeline-item.md +1 -1
- package/llms/components/lr-timeline.md +38 -4
- package/llms/components/lr-tooltip.md +3 -1
- package/llms/components/lr-tree.md +4 -0
- package/llms/components/lr-virtual-list.md +4 -1
- package/llms/peers.md +2 -2
- package/llms/shared/events-and-types.md +61 -2
- package/llms/shared/forms-and-accessibility.md +46 -4
- package/llms/shared/imports-and-registration.md +154 -110
- package/llms/shared/testing-and-utilities.md +5 -1
- package/llms/shared.md +266 -117
- package/locales.json +1 -1
- package/package.json +22 -21
- package/registrations.json +1 -1
|
@@ -1,25 +1,35 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{sizes}from"../../../internal/sizes.styles.js";import{resolveListMove}from"../../../internal/list-navigation.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{styles}from"./segmented.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";const MAX_SEGMENTED_ITEMS=256;function snapshotSegmentedItems(value){try{if(!Array.isArray(value))return Object.freeze([])}catch{return Object.freeze([])}const seenValues=new Set,normalized=[];let length=0;try{length=Math.min(value.length,MAX_SEGMENTED_ITEMS)}catch{return Object.freeze(normalized)}for(let index=0;index<length;index+=1)try{const candidate=value[index];if(!candidate||typeof candidate!="object")continue;const record=candidate,itemValue=record.value,label=record.label,disabled=record.disabled,icon=record.icon;if(typeof itemValue!="string"||itemValue.length===0||itemValue!==itemValue.trim()||seenValues.has(itemValue)||typeof label!="string"||label.trim()===""||disabled!==void 0&&typeof disabled!="boolean")continue;seenValues.add(itemValue),normalized.push(Object.freeze({value:itemValue,label,...icon!==void 0?{icon}:{},...disabled!==void 0?{disabled}:{}}))}catch{}return Object.freeze(normalized)}class LyraSegmented extends LyraElement{constructor(){super(...arguments),this.effectiveItems=Object.freeze([]),this.value="",this.label="",this.disabled=!1,this.size="m",this.rehomeSegmentFocus=!1,this.scrollOverflow=observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part="base"]')),this.onKeyDown=e=>{if(this.disabled)return;const navigable=this.items.map((item,index)=>({item,index})).filter(({item})=>!item.disabled);if(navigable.length===0)return;const focusedIndex=this.keyboardOriginIndex(e),selectedIndex=this.items.indexOf(this.selectedItem),originIndex=focusedIndex>=0?focusedIndex:selectedIndex,currentIndex=selectedIndex<0&&this.segmentButtonAt(originIndex)?.tabIndex===0?-1:navigable.findIndex(({index})=>index===originIndex),targetIndex=resolveListMove(e,{count:navigable.length,current:currentIndex,orientation:"both",direction:this.effectiveDirection});if(targetIndex===null)return;e.preventDefault();const target=navigable[targetIndex];this.select(target.item),this.focusItem(target.index)}}static{this.styles=[LyraElement.styles,sizes,scrollOverflowFadeStyles,styles]}get items(){return this.effectiveItems}set items(value){if(value===this.itemsSource||value===this.effectiveItems)return;this.itemsSource=value;const previous=this.effectiveItems;this.effectiveItems=snapshotSegmentedItems(value),this.requestUpdate("items",previous)}select(item){if(!(item.disabled||this.disabled)){if(item!==this.selectedItem){const valueChanged=item.value!==this.value;this.selectedItem=item,valueChanged&&(this.value=item.value,this.emit("lr-change",{value:item.value}))}this.emit("lr-activate",{value:item.value})}}segmentButtonAt(index){return this.renderRoot.querySelector(`[part="segment"][data-index="${index}"]`)}focusItem(index){this.segmentButtonAt(index)?.focus()}scrollToValue(value){const base=this.renderRoot.querySelector('[part="base"]'),segment=this.segmentButtonAt(this.items.findIndex(item=>item.value===value));if(!base||!segment)return;const track=base.getBoundingClientRect(),rect=segment.getBoundingClientRect(),left=rect.left<track.left?rect.left-track.left:Math.max(0,rect.right-track.right);left&&base.scrollBy({left,behavior:prefersReducedMotion(this)?"auto":"smooth"})}updated(changed){super.updated(changed),this.scrollOverflow.observeExtra(this.renderRoot.querySelectorAll('[part="segment"]')),this.rehomeSegmentFocus&&(this.rehomeSegmentFocus=!1,this.renderRoot.querySelector('[part="segment"][tabindex="0"]')?.focus()),changed.has("value")&&changed.get("value")!==void 0&&this.value&&this.scrollToValue(this.value)}willUpdate(changed){super.willUpdate(changed),changed.has("items")&&shadowFocusTarget(this)?.getAttribute("part")==="segment"&&(this.rehomeSegmentFocus=!0),(changed.has("value")||changed.has("items")&&(!this.selectedItem||!this.items.includes(this.selectedItem)||this.selectedItem.value!==this.value||this.selectedItem.disabled))&&(this.selectedItem=this.items.find(item=>item.value===this.value&&!item.disabled))}keyboardOriginIndex(event){const fromEvent=event.composedPath().find(candidate2=>candidate2.nodeType===1&&candidate2.getAttribute?.("part")==="segment"&&candidate2.getRootNode()===this.renderRoot),focused=shadowFocusTarget(this),candidate=fromEvent??(focused?.getAttribute("part")==="segment"?focused:void 0),index=Number(candidate?.dataset.index);return Number.isInteger(index)&&index>=0&&index<this.items.length?index:-1}render(){const
|
|
2
|
-
<div
|
|
3
|
-
part="
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property,state}from"lit/decorators.js";import{repeat}from"lit/directives/repeat.js";import{LyraElement}from"../../../internal/lyra-element.js";import{sizes}from"../../../internal/sizes.styles.js";import{SlotPresenceController}from"../../../internal/slot-presence-controller.js";import{resolveListMove}from"../../../internal/list-navigation.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{observeScrollOverflow}from"../../../internal/scroll-overflow.js";import{scrollOverflowFadeStyles}from"../../../internal/scroll-overflow.styles.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{styles}from"./segmented.styles.js";import{shadowFocusTarget}from"../../../internal/active-element.js";const MAX_SEGMENTED_ITEMS=256;function snapshotSegmentedItems(value){try{if(!Array.isArray(value))return Object.freeze([])}catch{return Object.freeze([])}const seenValues=new Set,normalized=[];let length=0;try{length=Math.min(value.length,MAX_SEGMENTED_ITEMS)}catch{return Object.freeze(normalized)}for(let index=0;index<length;index+=1)try{const candidate=value[index];if(!candidate||typeof candidate!="object")continue;const record=candidate,itemValue=record.value,label=record.label,disabled=record.disabled,icon=record.icon;if(typeof itemValue!="string"||itemValue.length===0||itemValue!==itemValue.trim()||seenValues.has(itemValue)||typeof label!="string"||label.trim()===""||disabled!==void 0&&typeof disabled!="boolean")continue;seenValues.add(itemValue),normalized.push(Object.freeze({value:itemValue,label,...icon!==void 0?{icon}:{},...disabled!==void 0?{disabled}:{}}))}catch{}return Object.freeze(normalized)}class LyraSegmented extends LyraElement{constructor(){super(...arguments),this.effectiveItems=Object.freeze([]),this.value="",this.label="",this.labelDisplay="hidden",this.hint="",this.slotPresence=new SlotPresenceController(this),this.hasNativeLabelAssignment=!1,this.hasNativeHintAssignment=!1,this.syncNativeFieldAssignments=()=>{const assigned=name=>{const slot=this.renderRoot?.querySelector(`slot[name="${name}"]`);return slot?slot.assignedNodes().length>0:Array.from(this.children).some(child=>child.getAttribute("slot")===name)};this.hasNativeLabelAssignment=assigned("label"),this.hasNativeHintAssignment=assigned("hint")},this.onFieldSlotChange=()=>{this.updateBrowserDerivedState(this.syncNativeFieldAssignments)},this.disabled=!1,this.size="m",this.rehomeSegmentFocus=!1,this.scrollOverflow=observeScrollOverflow(this,()=>this.renderRoot.querySelector('[part="base"]')),this.onKeyDown=e=>{if(this.disabled)return;const navigable=this.items.map((item,index)=>({item,index})).filter(({item})=>!item.disabled);if(navigable.length===0)return;const focusedIndex=this.keyboardOriginIndex(e),selectedIndex=this.items.indexOf(this.selectedItem),originIndex=focusedIndex>=0?focusedIndex:selectedIndex,currentIndex=selectedIndex<0&&this.segmentButtonAt(originIndex)?.tabIndex===0?-1:navigable.findIndex(({index})=>index===originIndex),targetIndex=resolveListMove(e,{count:navigable.length,current:currentIndex,orientation:"both",direction:this.effectiveDirection});if(targetIndex===null)return;e.preventDefault();const target=navigable[targetIndex];this.select(target.item),this.focusItem(target.index)}}static{this.styles=[LyraElement.styles,sizes,scrollOverflowFadeStyles,styles]}get items(){return this.effectiveItems}set items(value){if(value===this.itemsSource||value===this.effectiveItems)return;this.itemsSource=value;const previous=this.effectiveItems;this.effectiveItems=snapshotSegmentedItems(value),this.requestUpdate("items",previous)}connectedCallback(){super.connectedCallback(),this.updateBrowserDerivedState(this.syncNativeFieldAssignments)}select(item){if(!(item.disabled||this.disabled)){if(item!==this.selectedItem){const valueChanged=item.value!==this.value;this.selectedItem=item,valueChanged&&(this.value=item.value,this.emit("lr-change",{value:item.value}))}this.emit("lr-activate",{value:item.value})}}segmentButtonAt(index){return this.renderRoot.querySelector(`[part="segment"][data-index="${index}"]`)}focusItem(index){this.segmentButtonAt(index)?.focus()}scrollToValue(value){const base=this.renderRoot.querySelector('[part="base"]'),segment=this.segmentButtonAt(this.items.findIndex(item=>item.value===value));if(!base||!segment)return;const track=base.getBoundingClientRect(),rect=segment.getBoundingClientRect(),left=rect.left<track.left?rect.left-track.left:Math.max(0,rect.right-track.right);left&&base.scrollBy({left,behavior:prefersReducedMotion(this)?"auto":"smooth"})}updated(changed){super.updated(changed),this.scrollOverflow.observeExtra(this.renderRoot.querySelectorAll('[part="segment"]')),this.rehomeSegmentFocus&&(this.rehomeSegmentFocus=!1,this.renderRoot.querySelector('[part="segment"][tabindex="0"]')?.focus()),changed.has("value")&&changed.get("value")!==void 0&&this.value&&this.scrollToValue(this.value)}willUpdate(changed){super.willUpdate(changed),changed.has("items")&&shadowFocusTarget(this)?.getAttribute("part")==="segment"&&(this.rehomeSegmentFocus=!0),(changed.has("value")||changed.has("items")&&(!this.selectedItem||!this.items.includes(this.selectedItem)||this.selectedItem.value!==this.value||this.selectedItem.disabled))&&(this.selectedItem=this.items.find(item=>item.value===this.value&&!item.disabled))}keyboardOriginIndex(event){const fromEvent=event.composedPath().find(candidate2=>candidate2.nodeType===1&&candidate2.getAttribute?.("part")==="segment"&&candidate2.getRootNode()===this.renderRoot),focused=shadowFocusTarget(this),candidate=fromEvent??(focused?.getAttribute("part")==="segment"?focused:void 0),index=Number(candidate?.dataset.index);return Number.isInteger(index)&&index>=0&&index<this.items.length?index:-1}render(){const hostLabel=hostAriaLabel(this),hasLabelSlot=this.hasNativeLabelAssignment||this.slotPresence.has("label"),hasLabel=hasLabelSlot||(this.label??"").length>0,hasHint=this.hasNativeHintAssignment||this.slotPresence.has("hint")||(this.hint??"").length>0,ariaLabel=hostLabel??(hasLabelSlot?nothing:this.label||nothing),selectedIndex=this.items.indexOf(this.selectedItem),fallbackSelectedIndex=selectedIndex>=0?selectedIndex:this.items.findIndex(item=>item.value===this.value&&!item.disabled),tabbableIndex=fallbackSelectedIndex!==-1?fallbackSelectedIndex:this.items.findIndex(item=>!item.disabled);return html`
|
|
2
|
+
<div part="form-control">
|
|
3
|
+
<div id="segmented-label" part="form-control-label" ?hidden=${!hasLabel}
|
|
4
|
+
><slot name="label" @slotchange=${this.onFieldSlotChange}>${this.label}</slot></div
|
|
5
|
+
>
|
|
6
|
+
<div
|
|
7
|
+
part="base"
|
|
8
|
+
role="radiogroup"
|
|
9
|
+
aria-label=${ariaLabel}
|
|
10
|
+
aria-labelledby=${hostLabel===null&&hasLabelSlot?"segmented-label":nothing}
|
|
11
|
+
aria-describedby=${hasHint?"segmented-hint":nothing}
|
|
12
|
+
aria-disabled=${this.disabled?"true":nothing}
|
|
13
|
+
@keydown=${this.onKeyDown}
|
|
14
|
+
>
|
|
15
|
+
${repeat(this.items,item=>item.value,(item,index)=>html`<button
|
|
16
|
+
type="button"
|
|
17
|
+
part="segment"
|
|
18
|
+
data-value=${item.value}
|
|
19
|
+
data-index=${index}
|
|
20
|
+
role="radio"
|
|
21
|
+
aria-checked=${index===fallbackSelectedIndex?"true":"false"}
|
|
22
|
+
aria-disabled=${item.disabled||this.disabled?"true":"false"}
|
|
23
|
+
tabindex=${index===tabbableIndex?"0":"-1"}
|
|
24
|
+
@click=${()=>this.select(item)}
|
|
25
|
+
>
|
|
26
|
+
${item.icon!==void 0?html`<span part="segment-icon" aria-hidden="true" inert
|
|
27
|
+
>${item.icon}</span
|
|
28
|
+
>`:nothing}<span part="segment-label">${item.label}</span>
|
|
29
|
+
</button>`)}
|
|
30
|
+
</div>
|
|
31
|
+
<div id="segmented-hint" part="hint" ?hidden=${!hasHint}
|
|
32
|
+
><slot name="hint" @slotchange=${this.onFieldSlotChange}>${this.hint}</slot></div
|
|
33
|
+
>
|
|
24
34
|
</div>
|
|
25
|
-
`}}__decorate([property({attribute:!1})],LyraSegmented.prototype,"items",null),__decorate([property()],LyraSegmented.prototype,"value",void 0),__decorate([property()],LyraSegmented.prototype,"label",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraSegmented.prototype,"disabled",void 0),__decorate([property({reflect:!0})],LyraSegmented.prototype,"size",void 0),__decorate([state()],LyraSegmented.prototype,"selectedItem",void 0);export{LyraSegmented};
|
|
35
|
+
`}}__decorate([property({attribute:!1})],LyraSegmented.prototype,"items",null),__decorate([property()],LyraSegmented.prototype,"value",void 0),__decorate([property()],LyraSegmented.prototype,"label",void 0),__decorate([property({attribute:"label-display",reflect:!0})],LyraSegmented.prototype,"labelDisplay",void 0),__decorate([property()],LyraSegmented.prototype,"hint",void 0),__decorate([state()],LyraSegmented.prototype,"hasNativeLabelAssignment",void 0),__decorate([state()],LyraSegmented.prototype,"hasNativeHintAssignment",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraSegmented.prototype,"disabled",void 0),__decorate([property({reflect:!0})],LyraSegmented.prototype,"size",void 0),__decorate([state()],LyraSegmented.prototype,"selectedItem",void 0);export{LyraSegmented};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";const styles=css` :host { display: inline-flex; min-inline-size: 0; max-inline-size: 100%; --_lr-segmented-track-min-height: var(--lr-form-control-height); --_lr-segmented-segment-padding: var(--lr-form-control-padding-block) var(--lr-form-control-padding-inline); --_lr-segmented-font-size: var(--lr-form-control-font-size); } [part="base"] { display: inline-flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; min-inline-size: 0; min-block-size: var( --lr-segmented-track-height, var( --lr-segmented-track-min-height, var(--_lr-segmented-track-min-height) ) ); block-size: var(--lr-segmented-track-height, auto); box-sizing: border-box; background: var(--lr-segmented-track-bg, transparent); border: var(--lr-border-width-thin) solid var(--lr-segmented-track-border-color, var(--lr-color-border)); border-radius: var(--lr-segmented-track-radius, var(--lr-radius)); padding: var(--lr-segmented-track-padding, var(--lr-size-0-125rem)); gap: var(--lr-segmented-track-gap, var(--lr-size-0-125rem)); } [part="segment"] { min-inline-size: 0; border: none; border-radius: var( --lr-segmented-segment-radius, calc(var(--lr-form-control-radius) * 0.7) ); background: transparent; color: var(--lr-color-text-quiet); font: inherit; font-size: var(--lr-segmented-font-size, var(--_lr-segmented-font-size)); padding: var( --lr-segmented-segment-padding, var(--_lr-segmented-segment-padding) ); cursor: pointer; transition: background-color var(--lr-transition-fast), color var(--lr-transition-fast); } :host([size="2xs"]) [part="segment"], :host([size="xs"]) [part="segment"] { min-inline-size: var(--lr-size-1-5rem); min-block-size: var(--lr-size-1-5rem); } [part="segment-icon"] { display: inline-flex; align-items: center; margin-inline-end: var(--lr-space-xs); block-size: var(--lr-size-1em); max-inline-size: var(--lr-size-2-5rem); } [part="segment"][aria-disabled="true"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } :where([part="segment"]):hover:where( :not([aria-disabled="true"]):not([aria-checked="true"]) ) { color: var(--lr-segmented-hover-color, var(--lr-color-text)); background: var(--lr-segmented-hover-bg, transparent); box-shadow: var(--lr-segmented-hover-shadow, none); } :where([part="segment"]):active:where( :not([aria-disabled="true"]):not([aria-checked="true"]) ) { background: var( --lr-segmented-active-bg, color-mix( in oklab, transparent, var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); color: var( --lr-segmented-active-color, var(--lr-segmented-hover-color, var(--lr-color-text)) ); } [part="segment"]:focus-visible { ${focusRing} } [part="segment"][aria-checked="true"] { background: var(--lr-segmented-selected-bg, var(--lr-color-text)); color: var(--lr-segmented-selected-color, var(--lr-color-surface)); font-weight: var( --lr-segmented-selected-font-weight, var(--lr-font-weight-semibold) ); box-shadow: var(--lr-segmented-selected-shadow, var(--lr-shadow-xs)); } `;export{styles};
|
|
1
|
+
import{focusRing}from"../../../internal/interactive-control.styles.js";import{css}from"lit";import{visuallyHidden}from"../../../internal/a11y.js";import{formControlChrome,formControlTextWrap}from"../../../internal/form-control.styles.js";const styles=css` :host { display: inline-flex; min-inline-size: 0; max-inline-size: 100%; --_lr-segmented-track-min-height: var(--lr-form-control-height); --_lr-segmented-segment-padding: var(--lr-form-control-padding-block) var(--lr-form-control-padding-inline); --_lr-segmented-font-size: var(--lr-form-control-font-size); } ${formControlChrome} [part="form-control"] { position: relative; display: flex; flex-direction: column; min-inline-size: 0; max-inline-size: 100%; } [part="form-control-label"], [part="hint"] { ${formControlTextWrap} } :host(:not([label-display='visible'])) [part="form-control-label"] { ${visuallyHidden} } [part="base"] { display: inline-flex; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; min-inline-size: 0; min-block-size: var( --lr-segmented-track-height, var( --lr-segmented-track-min-height, var(--_lr-segmented-track-min-height) ) ); block-size: var(--lr-segmented-track-height, auto); box-sizing: border-box; background: var(--lr-segmented-track-bg, transparent); border: var(--lr-border-width-thin) solid var(--lr-segmented-track-border-color, var(--lr-color-border)); border-radius: var(--lr-segmented-track-radius, var(--lr-radius)); padding: var(--lr-segmented-track-padding, var(--lr-size-0-125rem)); gap: var(--lr-segmented-track-gap, var(--lr-size-0-125rem)); } [part="segment"] { min-inline-size: 0; border: none; border-radius: var( --lr-segmented-segment-radius, calc(var(--lr-form-control-radius) * 0.7) ); background: transparent; color: var(--lr-color-text-quiet); font: inherit; font-size: var(--lr-segmented-font-size, var(--_lr-segmented-font-size)); padding: var( --lr-segmented-segment-padding, var(--_lr-segmented-segment-padding) ); cursor: pointer; transition: background-color var(--lr-transition-fast), color var(--lr-transition-fast); } :host([size="2xs"]) [part="segment"], :host([size="xs"]) [part="segment"] { min-inline-size: var(--lr-size-1-5rem); min-block-size: var(--lr-size-1-5rem); } [part="segment-icon"] { display: inline-flex; align-items: center; margin-inline-end: var(--lr-space-xs); block-size: var(--lr-size-1em); max-inline-size: var(--lr-size-2-5rem); } [part="segment"][aria-disabled="true"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } :where([part="segment"]):hover:where( :not([aria-disabled="true"]):not([aria-checked="true"]) ) { color: var(--lr-segmented-hover-color, var(--lr-color-text)); background: var(--lr-segmented-hover-bg, transparent); box-shadow: var(--lr-segmented-hover-shadow, none); } :where([part="segment"]):active:where( :not([aria-disabled="true"]):not([aria-checked="true"]) ) { background: var( --lr-segmented-active-bg, color-mix( in oklab, transparent, var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); color: var( --lr-segmented-active-color, var(--lr-segmented-hover-color, var(--lr-color-text)) ); } [part="segment"]:focus-visible { ${focusRing} } [part="segment"][aria-checked="true"] { background: var(--lr-segmented-selected-bg, var(--lr-color-text)); color: var(--lr-segmented-selected-color, var(--lr-color-surface)); font-weight: var( --lr-segmented-selected-font-weight, var(--lr-font-weight-semibold) ); box-shadow: var(--lr-segmented-selected-shadow, var(--lr-shadow-xs)); } `;export{styles};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{focusRing}from"../../../internal/interactive-control.styles.js";import{scrollOverflowFade}from"../../../internal/scroll-overflow.styles.js";import{css}from"lit";const styles=css` :host { display: block; min-inline-size: 0; max-inline-size: 100%; } [part="base"] { display: flex; min-inline-size: 0; max-inline-size: 100%; gap: var(--lr-space-m); overflow-x: auto; overflow-y: hidden; } [part="base"]:focus-visible { ${focusRing} } [part="step-item"] { display: contents; } :host([orientation="vertical"]) [part="base"] { flex-direction: column; overflow-x: visible; overflow-y: visible; -webkit-mask-image: none; mask-image: none; } :host([data-effective-orientation="vertical"]) [part="base"] { flex-direction: column; overflow-x: visible; overflow-y: visible; -webkit-mask-image: none; mask-image: none; } :host([data-effective-orientation="horizontal"]) [part="base"] { flex-direction: row; overflow-x: auto; overflow-y: hidden; -webkit-mask-image: none; mask-image: none; } ${scrollOverflowFade(':host([data-effective-orientation="horizontal"]) [part="base"][data-scroll-overflow]',':host(:dir(rtl)[data-effective-orientation="horizontal"]) [part="base"][data-scroll-overflow]')} [part="step"] { display: flex; align-items: center; gap: var(--lr-space-xs); flex: 0 0 auto; border: none; background: transparent; color: var(--lr-color-text-quiet); font: inherit; cursor: pointer; padding: var(--lr-space-2xs); border-radius: var(--lr-radius); transition: background-color var(--lr-transition-fast), color var(--lr-transition-fast); } [part="step"][aria-disabled="true"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } :host([readonly]) [part="step"] { cursor: default; } :where(button[part="step"]):hover:where(:not([aria-disabled="true"])) { background: var(--lr-stepper-hover-bg, var(--lr-color-brand-quiet)); color: var(--lr-stepper-hover-color, var(--lr-color-text)); } :where(button[part="step"]):active:where(:not([aria-disabled="true"])) { background: var( --lr-stepper-active-bg, color-mix( in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); color: var(--lr-stepper-active-color, var(--lr-color-text)); } [part="step"]:focus-visible { ${focusRing} } [part="step"][data-state="current"] { color: var(--lr-stepper-current-color, var(--lr-color-text)); font-weight: var( --lr-stepper-current-font-weight, var(--lr-font-weight-semibold) ); } [part="step"][data-state="error"] { color: var(--lr-stepper-error-color, var(--lr-color-danger)); } [part="step-icon"] { display: inline-flex; align-items: center; flex: 0 0 auto; block-size: var(--lr-size-1em); max-inline-size: var(--lr-size-2-5rem); } [part="step-index"] { display: inline-flex; align-items: center; justify-content: center; inline-size: var(--lr-size-1-5rem); block-size: var(--lr-size-1-5rem); border-radius: var(--lr-radius-pill); background: var(--lr-color-neutral-fill-normal); color: var(--lr-color-neutral-on-normal); font-size: var(--lr-font-size-xs); flex: 0 0 auto; } [part="step"][data-state="current"] [part="step-index"] { background: var(--lr-stepper-current-index-bg, var(--lr-color-brand)); color: var(--lr-stepper-current-index-color, var(--lr-color-on-brand)); } [part="step-check"] { color: var(--lr-color-success); flex: 0 0 auto; } [part="step-label"] { white-space: nowrap; } :host([wrap-labels][orientation="vertical"]) [part="step-label"], :host([wrap-labels][data-effective-orientation="vertical"]) [part="step-label"] { min-inline-size: 0; white-space: normal; overflow-wrap: anywhere; } :host([wrap-labels][data-effective-orientation="horizontal"]) [part="step-label"] { min-inline-size: auto; white-space: nowrap; overflow-wrap: normal; } @media (forced-colors: active) { [part="base"], [part="base"][data-scroll-overflow], :host(:dir(rtl)) [part="base"][data-scroll-overflow], :host([data-effective-orientation="horizontal"]) [part="base"][data-scroll-overflow], :host(:dir(rtl)[data-effective-orientation="horizontal"]) [part="base"][data-scroll-overflow] { -webkit-mask-image: none; mask-image: none; } } `;export{styles};
|
|
1
|
+
import{focusRing}from"../../../internal/interactive-control.styles.js";import{scrollOverflowFade}from"../../../internal/scroll-overflow.styles.js";import{css}from"lit";const styles=css` :host { display: block; min-inline-size: 0; max-inline-size: 100%; } [part="base"] { display: flex; min-inline-size: 0; max-inline-size: 100%; gap: var(--lr-space-m); overflow-x: auto; overflow-y: hidden; } [part="base"]:focus-visible { ${focusRing} } [part="step-item"] { display: contents; } :host([orientation="vertical"]) [part="base"] { flex-direction: column; overflow-x: visible; overflow-y: visible; -webkit-mask-image: none; mask-image: none; } :host([data-effective-orientation="vertical"]) [part="base"] { flex-direction: column; overflow-x: visible; overflow-y: visible; -webkit-mask-image: none; mask-image: none; } :host([data-effective-orientation="horizontal"]) [part="base"] { flex-direction: row; overflow-x: auto; overflow-y: hidden; -webkit-mask-image: none; mask-image: none; } ${scrollOverflowFade(':host([data-effective-orientation="horizontal"]) [part="base"][data-scroll-overflow]',':host(:dir(rtl)[data-effective-orientation="horizontal"]) [part="base"][data-scroll-overflow]')} [part="step"] { display: flex; align-items: center; gap: var(--lr-space-xs); flex: 0 0 auto; border: none; background: transparent; color: var(--lr-color-text-quiet); font: inherit; cursor: pointer; padding: var(--lr-space-2xs); border-radius: var(--lr-radius); transition: background-color var(--lr-transition-fast), color var(--lr-transition-fast); } [part="step"][aria-disabled="true"] { opacity: var(--lr-opacity-disabled); cursor: not-allowed; } :host([readonly]) [part="step"] { cursor: default; } :where(button[part="step"]):hover:where(:not([aria-disabled="true"])) { background: var(--lr-stepper-hover-bg, var(--lr-color-brand-quiet)); color: var(--lr-stepper-hover-color, var(--lr-color-text)); } :where(button[part="step"]):active:where(:not([aria-disabled="true"])) { background: var( --lr-stepper-active-bg, color-mix( in oklab, var(--lr-color-brand-quiet), var(--lr-color-mix-partner) var(--lr-color-mix-active) ) ); color: var(--lr-stepper-active-color, var(--lr-color-text)); } [part="step"]:focus-visible { ${focusRing} } :host(:where(:not([orientation="vertical"]))) [part="step"]:focus-visible, :host(:where([data-effective-orientation="horizontal"])) [part="step"]:focus-visible { outline-offset: calc(-1 * var(--lr-focus-ring-width)); } :host(:where([data-effective-orientation="vertical"])) [part="step"]:focus-visible { outline-offset: var(--lr-focus-ring-offset); } [part="step"][data-state="current"] { color: var(--lr-stepper-current-color, var(--lr-color-text)); font-weight: var( --lr-stepper-current-font-weight, var(--lr-font-weight-semibold) ); } [part="step"][data-state="error"] { color: var(--lr-stepper-error-color, var(--lr-color-danger)); } [part="step-icon"] { display: inline-flex; align-items: center; flex: 0 0 auto; block-size: var(--lr-size-1em); max-inline-size: var(--lr-size-2-5rem); } [part="step-index"] { display: inline-flex; align-items: center; justify-content: center; inline-size: var(--lr-size-1-5rem); block-size: var(--lr-size-1-5rem); border-radius: var(--lr-radius-pill); background: var(--lr-color-neutral-fill-normal); color: var(--lr-color-neutral-on-normal); font-size: var(--lr-font-size-xs); flex: 0 0 auto; } [part="step"][data-state="current"] [part="step-index"] { background: var(--lr-stepper-current-index-bg, var(--lr-color-brand)); color: var(--lr-stepper-current-index-color, var(--lr-color-on-brand)); } [part="step-check"] { color: var(--lr-color-success); flex: 0 0 auto; } [part="step-label"] { white-space: nowrap; } :host([wrap-labels][orientation="vertical"]) [part="step-label"], :host([wrap-labels][data-effective-orientation="vertical"]) [part="step-label"] { min-inline-size: 0; white-space: normal; overflow-wrap: anywhere; } :host([wrap-labels][data-effective-orientation="horizontal"]) [part="step-label"] { min-inline-size: auto; white-space: nowrap; overflow-wrap: normal; } @media (forced-colors: active) { [part="base"], [part="base"][data-scroll-overflow], :host(:dir(rtl)) [part="base"][data-scroll-overflow], :host([data-effective-orientation="horizontal"]) [part="base"][data-scroll-overflow], :host(:dir(rtl)[data-effective-orientation="horizontal"]) [part="base"][data-scroll-overflow] { -webkit-mask-image: none; mask-image: none; } } `;export{styles};
|
|
@@ -167,4 +167,11 @@ defaultSlot:HTMLSlotElement;private tabs;private focusedTab;private baseId;priva
|
|
|
167
167
|
/** Keeps `active` resolved to a real, navigable tab -- covers the initial default, a tab disappearing/becoming disabled or inert underneath the current selection, and a consumer assigning `.active` directly. Only a rendered selection displaced by its tab leaving reports `lr-tab-hide`/`lr-tab-show`, moving to the following tab (else the preceding one); the initial default and a direct `.active` write stay silent. Reading the focused element *before* the render that marks the outgoing button `inert` is what lets `updated()` rehome real focus rather than leaving it stranded on `<body>`.*/
|
|
168
168
|
protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private selectTab;private activateTab;
|
|
169
169
|
/** Show the panel named by an `<lr-tab panel>`.*/
|
|
170
|
-
show(panel:string):void;private syncElementActiveState;private focusOnly;private get rovingTab();private keyboardOriginTab;private
|
|
170
|
+
show(panel:string):void;private syncElementActiveState;private focusOnly;private get rovingTab();private keyboardOriginTab;private focusTabButton;private tabButton;
|
|
171
|
+
/** Moves keyboard focus to the real tab button of the enabled, non-inert tab whose `panel` is
|
|
172
|
+
* `panel`, and moves the roving tab stop with it. Under `activation="auto"` focus and selection
|
|
173
|
+
* move together, so focusing an unselected tab also selects it exactly as `show()` does
|
|
174
|
+
* (`lr-tab-hide`/`lr-tab-show`, never `lr-activate`); under `manual` only focus moves. A missing,
|
|
175
|
+
* disabled or inert tab leaves focus and selection unchanged, and so does a tab added since the
|
|
176
|
+
* group last read its children (await `updateComplete` first). Returns `true` when focus moved. */
|
|
177
|
+
focusTab(panel:string,options?:FocusOptions):boolean;private focusTabDefinition;private get isVertical();private onTabListKeyDown;private tabId;private panelId;private idsFor;private tabSlotName;private get scrollControlsSuppressed();private measureTabScrollEdges;private setTabScrollEdges;private onTabListScroll;private scrollTabs;private renderScrollControl;private onScrollControlMouseDown;private onScrollControlPointerDown;private onScrollControlPointerEnd;private renderTab;private renderPanel;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-tab-group':LyraTabGroup;}}
|
|
@@ -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==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
|
|
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.focusTabButton(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.focusTabButton(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)}focusTabButton(slotName,options){const button=this.tabButton(slotName);return button?(button.focus(options),!0):!1}tabButton(slotName){const buttons=this.renderRoot.querySelectorAll('[part="tab"]');return Array.from(buttons).find(button=>button.dataset.slot===slotName)}focusTab(panel,options){const tab=this.tabs.find(candidate=>candidate.slotName===panel);return tab?this.focusTabDefinition(tab,options):!1}focusTabElement(element,options){const tab=this.tabs.find(candidate=>candidate.element===element);return tab?this.focusTabDefinition(tab,options):!1}blurTabElement(element){const tab=this.tabs.find(candidate=>candidate.element===element),button=tab?this.tabButton(tab.slotName):void 0;button&&shadowFocusTarget(this)===button&&button.blur()}focusTabDefinition(tab,options){return this.isNavigable(tab)?(this.activation==="manual"?this.focusedTab=tab.slotName:this.selectTab(tab),this.focusTabButton(tab.slotName,options)):!1}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"
|
|
@@ -43,4 +43,10 @@ active:boolean;
|
|
|
43
43
|
/** Shows a localized close affordance. Clicking it or pressing Delete on the focused owning tab
|
|
44
44
|
* emits `lr-close`; it never removes the tab. The visual affordance is non-focusable because the
|
|
45
45
|
* group projects it into the real tab button. */
|
|
46
|
-
closable:boolean;connectedCallback():void;private onClosePointerDown;private onCloseClick;
|
|
46
|
+
closable:boolean;connectedCallback():void;private onClosePointerDown;private onCloseClick;private get owner();
|
|
47
|
+
/** Focuses the real `role="tab"` button the owning group renders for this descriptor, exactly
|
|
48
|
+
* as the group's `focusTab(panel)` does (under `activation="auto"` that also selects it). A
|
|
49
|
+
* disabled or inert tab, or one outside an upgraded group, is not focusable and is left alone. */
|
|
50
|
+
focus(options?:FocusOptions):void;
|
|
51
|
+
/** Removes focus from the owning group's real tab button when it is focused.*/
|
|
52
|
+
blur():void;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-tab':LyraTab;}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{closeIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{styles}from"./tab.styles.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings/shared.generated.js";class LyraTab extends LyraElement{constructor(){super(...arguments),this.panel="",this.disabled=!1,this.active=!1,this.closable=!1,this.onClosePointerDown=event=>{event.preventDefault(),event.stopPropagation()},this.onCloseClick=event=>{event.stopPropagation(),this.requestCloseFromOwner()}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close}}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback(),this.hasAttribute("slot")||(this.slot="nav")}requestCloseFromOwner(){!this.closable||this.disabled||this.emit("lr-close",null)}render(){return html`
|
|
1
|
+
import{__decorate}from"tslib";import{html,nothing}from"lit";import{property}from"lit/decorators.js";import{closeIcon}from"../../../internal/icons.js";import{LyraElement}from"../../../internal/lyra-element.js";import{tag}from"../../../internal/prefix.js";import{styles}from"./tab.styles.js";import{LYRA_DEFAULT_close}from"../../../internal/default-strings/shared.generated.js";class LyraTab extends LyraElement{constructor(){super(...arguments),this.panel="",this.disabled=!1,this.active=!1,this.closable=!1,this.onClosePointerDown=event=>{event.preventDefault(),event.stopPropagation()},this.onCloseClick=event=>{event.stopPropagation(),this.requestCloseFromOwner()}}static{this.defaultStrings={...super.defaultStrings,close:LYRA_DEFAULT_close}}static{this.styles=[LyraElement.styles,styles]}connectedCallback(){super.connectedCallback(),this.hasAttribute("slot")||(this.slot="nav")}get owner(){const parent=this.parentElement;return parent&&parent.localName===tag("tab-group")&&typeof parent.focusTabElement=="function"?parent:void 0}focus(options){this.owner?.focusTabElement(this,options)||super.focus(options)}blur(){const owner=this.owner;owner?owner.blurTabElement(this):super.blur()}requestCloseFromOwner(){!this.closable||this.disabled||this.emit("lr-close",null)}render(){return html`
|
|
2
2
|
<slot part="base tab"></slot>
|
|
3
3
|
${this.closable?html`
|
|
4
4
|
<span
|
|
@@ -411,7 +411,7 @@ get renderedRows():HTMLElement[];
|
|
|
411
411
|
* returned elements as read-only: their lifetime belongs to the windowing math, and any of them
|
|
412
412
|
* can be recycled or removed on the next update.
|
|
413
413
|
*/
|
|
414
|
-
get projectedRows():HTMLElement[];private get externalScroller();private get spacerElement();private externalGeometry?;private externalStyleObserver?;private invalidateExternalGeometry;private scrollRoundingAnchor?;private scrollScale;private logicalScroll;private physicalScroll;private physicalRowOffset;private captureScrollRounding;private readScrollMetrics;private readPhysicalScrollMetrics;private visualBlockScale;private relativeBlockScale;private applyScrollPosition;private scrollMetricsRefreshPending;private scheduleScrollMetricsRefresh;private syncExternalScrollMetrics;private get safeRowIndexOffset();private computedAriaRowIndex;private containerScrollTop;private viewportHeight;private renderUnmeasuredWindow;private offsets;private offsetDirtyStart;private appendIdentityStart;private identityIndices;private keyIndices;private keyOccurrences;private groupPrefixDirty;private rowKeys;private rowIdentities;private fixedRowHeight;private readonly measuredHeights;private readonly measuredIndices;private indexedMeasurementIndices;private indexedMeasurementDeltaPrefix;private indexedMeasurementIndexDirty;private offsetsDirty;private identitiesDirty;private itemsChangedPendingPrune;private compositionVersion;private compositionScrollTarget?;private readonly composition;private renderStart;private renderEnd;private pinnedRow;private renderedWindow;private rowElements;private groupElements;private stickyElement?;private projectionAnchor?;private projectionPart?;private projectionDeferred;private readonly releaseRowProjection;private visibleStart;private visibleEnd;private lastEmittedStart;private lastEmittedEnd;private loadMoreArmed;private pendingScrollCorrection?;private measurementGeneration;private isFirstUpdate;private stickyHeight;private noTopLayer;private rowResizeObserver?;private groupResizeObserver?;private containerResizeObserver?;private stickyResizeObserver?;private observedSticky?;private readonly observedRows;private readonly observedRowKeys;private readonly observedRowIndices;private readonly observedGroups;private readonly observedGroupIndices;private scrollRafId?;private scrollRafOwner?;private scrollRafDocument?;private scrollListenerTarget?;private viewportResizeTarget?;private externalMetricsPending;private ownerRealmGeneration;private inResizeDelivery;private readonly pendingRowMeasurements;private readonly pendingGroupMeasurements;private readonly deferredRowObservations;private readonly deferredGroupObservations;private rowObserveRafId?;private rowObserveRafOwner?;private rowObserveRafDocument?;private activeIndexFor?;private activeIndexForLength;private activeIndexForId;private activeIndexForKeyFn?;private activeIndexCache;private get activeIndex();private pendingScrollTop;private normalizedGroups;private readonly normalizedGroupByIndex;private readonly measuredGroupHeights;private groupHeightPrefix;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private isCurrentOwnerWork;private resetOwnerRealmWork;firstUpdated(changed:PropertyValues):void;private contentRefreshPending;requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private parseRowHeight;private get effectiveSource();private get itemCount();private itemAt;private keyOf;private rowIdentity;private identityAt;private groupHeightAt;private rowHeightAt;private groupContributionThrough;private groupCountThrough;private recomputeGroupHeightPrefix;private indexedOffsetForIndex;private rebuildIndexedMeasurementIndex;private pruneIndexedMeasurements;private offsetAt;private recomputeOffsets;private groupTopAt;private rowBottomAt;private entryTopAt;private findIndexAtOrAfter;private findIndexAtOrBefore;
|
|
414
|
+
get projectedRows():HTMLElement[];private get externalScroller();private get spacerElement();private externalGeometry?;private externalStyleObserver?;private invalidateExternalGeometry;private scrollRoundingAnchor?;private scrollScale;private logicalScroll;private physicalScroll;private physicalRowOffset;private captureScrollRounding;private readScrollMetrics;private readPhysicalScrollMetrics;private visualBlockScale;private relativeBlockScale;private applyScrollPosition;private scrollMetricsRefreshPending;private scheduleScrollMetricsRefresh;private syncExternalScrollMetrics;private get safeRowIndexOffset();private computedAriaRowIndex;private containerScrollTop;private viewportHeight;private renderUnmeasuredWindow;private offsets;private offsetDirtyStart;private appendIdentityStart;private identityIndices;private keyIndices;private keyOccurrences;private groupPrefixDirty;private rowKeys;private rowIdentities;private fixedRowHeight;private readonly measuredHeights;private readonly measuredIndices;private indexedMeasurementIndices;private indexedMeasurementDeltaPrefix;private indexedMeasurementIndexDirty;private offsetsDirty;private identitiesDirty;private itemsChangedPendingPrune;private compositionVersion;private compositionScrollTarget?;private readonly composition;private renderStart;private renderEnd;private pinnedRow;private renderedWindow;private rowElements;private groupElements;private stickyElement?;private projectionAnchor?;private projectionPart?;private projectionDeferred;private readonly releaseRowProjection;private visibleStart;private visibleEnd;private lastEmittedStart;private lastEmittedEnd;private loadMoreArmed;private pendingScrollCorrection?;private measurementGeneration;private smoothScrollWait?;private isFirstUpdate;private stickyHeight;private noTopLayer;private rowResizeObserver?;private groupResizeObserver?;private containerResizeObserver?;private stickyResizeObserver?;private observedSticky?;private readonly observedRows;private readonly observedRowKeys;private readonly observedRowIndices;private readonly observedGroups;private readonly observedGroupIndices;private scrollRafId?;private scrollRafOwner?;private scrollRafDocument?;private scrollListenerTarget?;private viewportResizeTarget?;private externalMetricsPending;private ownerRealmGeneration;private inResizeDelivery;private readonly pendingRowMeasurements;private readonly pendingGroupMeasurements;private readonly deferredRowObservations;private readonly deferredGroupObservations;private rowObserveRafId?;private rowObserveRafOwner?;private rowObserveRafDocument?;private activeIndexFor?;private activeIndexForLength;private activeIndexForId;private activeIndexForKeyFn?;private activeIndexCache;private get activeIndex();private pendingScrollTop;private normalizedGroups;private readonly normalizedGroupByIndex;private readonly measuredGroupHeights;private groupHeightPrefix;connectedCallback():void;disconnectedCallback():void;adoptedCallback():void;private isCurrentOwnerWork;private resetOwnerRealmWork;firstUpdated(changed:PropertyValues):void;private contentRefreshPending;requestUpdate(...args:Parameters<LyraElement['requestUpdate']>):void;protected willUpdate(changed:PropertyValues):void;protected updated(changed:PropertyValues):void;private parseRowHeight;private get effectiveSource();private get itemCount();private itemAt;private keyOf;private rowIdentity;private identityAt;private groupHeightAt;private rowHeightAt;private groupContributionThrough;private groupCountThrough;private recomputeGroupHeightPrefix;private indexedOffsetForIndex;private rebuildIndexedMeasurementIndex;private pruneIndexedMeasurements;private offsetAt;private recomputeOffsets;private groupTopAt;private rowBottomAt;private entryTopAt;private findIndexAtOrAfter;private findIndexAtOrBefore;
|
|
415
415
|
/**
|
|
416
416
|
* Row `index`'s logical pixel top in this list's own scroll-coordinate space.
|
|
417
417
|
* Above 8,000,000 pixels, native scrollbar travel and row transforms use a scaled extent;
|
|
@@ -448,4 +448,4 @@ indexAtOffset(px:number):number;private computeRange;private limitCompositionWin
|
|
|
448
448
|
* and key function, and is canceled by replacement data, a new target, manual scroll intent, or
|
|
449
449
|
* disconnect, so a late observation can never drag a newer view back to a stale row.
|
|
450
450
|
*/
|
|
451
|
-
scrollToIndex(index:number,options?:{align?:'start'|'end'|'auto';behavior?:'auto'|'smooth';}):void;private hasUnmeasuredGroupThrough;private beginPendingScrollCorrection;private performScrollTo;private maybeCorrectPendingScroll;private emitRangeChangeIfNeeded;private maybeFireLoadMore;private get projectionActive();private rowSlotName;private syncRowProjection;private ensureProjectionAnchor;private teardownRowProjection;private renderProjectedRows;private focusedRowOutsideWindow;private onFocusOut;private renderRow;private recomputeGroups;private renderGroups;private currentStickyGroup;private renderStickyLayer;private syncStickyOverlay;private onStickyResized;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-virtual-list':LyraVirtualList;}}
|
|
451
|
+
scrollToIndex(index:number,options?:{align?:'start'|'end'|'auto';behavior?:'auto'|'smooth';}):void;private hasUnmeasuredGroupThrough;private beginPendingScrollCorrection;private performScrollTo;private cancelSmoothScrollWait;private waitForSmoothScroll;private maybeCorrectPendingScroll;private emitRangeChangeIfNeeded;private maybeFireLoadMore;private get projectionActive();private rowSlotName;private syncRowProjection;private ensureProjectionAnchor;private teardownRowProjection;private renderProjectedRows;private focusedRowOutsideWindow;private onFocusOut;private renderRow;private recomputeGroups;private renderGroups;private currentStickyGroup;private renderStickyLayer;private syncStickyOverlay;private onStickyResized;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-virtual-list':LyraVirtualList;}}
|
|
@@ -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)}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.type==="keydown"&&!SCROLL_KEYS.has(event.key)||(this.waitForSmoothScroll(),this.pendingScrollCorrection=void 0,this.compositionScrollTarget=void 0,this.scrollRoundingAnchor=void 0)},this.onScroll=e=>{if(this.smoothScrollWait&&this.waitForSmoothScroll(),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.readScrollMetrics()?.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=>{const entry=entries.find(entry2=>entry2.target===this.observedSticky);if(!entry)return;this.beginResizeDelivery();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?.scrollingElement?.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.cancelSmoothScrollWait()):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();const ownerDocument=this.ownerDocument,ownerGeneration=this.ownerRealmGeneration;this.emitRangeChangeIfNeeded(),this.isCurrentOwnerWork(ownerDocument,ownerGeneration)&&(this.maybeFireLoadMore(),this.isCurrentOwnerWork(ownerDocument,ownerGeneration)&&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&&!this.smoothScrollWait)){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.cancelSmoothScrollWait(),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,observation]of observations){const index=indexed?observation.index:this.identityIndices.get(key);if(index===void 0)continue;const{height}=observation;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&&!this.smoothScrollWait){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&&!this.smoothScrollWait){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}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.normalizedGroups.length>0?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",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):this.pendingScrollCorrection=void 0}hasUnmeasuredGroupThrough(index){return this.normalizedGroups.some(group=>group.startIndex<=index&&group.label!==""&&!this.measuredGroupHeights.has(group.startIndex))}beginPendingScrollCorrection(index,align,activeItemId){if(this.fixedRowHeight!=null&&!this.hasUnmeasuredGroupThrough(index)){this.pendingScrollCorrection=void 0;return}this.pendingScrollCorrection={identity:this.identityAt(index),index,align,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:(behavior==="smooth"?this.waitForSmoothScroll():this.cancelSmoothScrollWait(),this.applyScrollPosition(target,behavior),!0)}cancelSmoothScrollWait(){const waiting=this.smoothScrollWait;this.smoothScrollWait=void 0,waiting&&waiting.owner.clearTimeout(waiting.handle)}waitForSmoothScroll(){this.cancelSmoothScrollWait();const owner=this.ownerDocument.defaultView;if(!owner||!this.isConnected)return;const waiting={owner,handle:owner.setTimeout(()=>{this.smoothScrollWait===waiting&&(this.smoothScrollWait=void 0,this.maybeCorrectPendingScroll())},150)};this.smoothScrollWait=waiting}maybeCorrectPendingScroll(){const pending=this.pendingScrollCorrection;if(!pending||this.smoothScrollWait||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,"auto"),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}
|