@aceshooting/lyra-ui 30.9.0 → 31.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +236 -339
- package/dist/ai/adapters/ag-ui.js +1 -1
- package/dist/components/agent-tools/activity-feed/activity-feed.class.js +1 -1
- 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 +1 -1
- package/dist/components/conversation/chat-composer/chat-composer.class.d.ts +9 -4
- package/dist/components/conversation/chat-composer/chat-composer.class.js +1 -1
- 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.js +2 -2
- package/dist/components/conversation/message-parts/message-parts.class.js +1 -1
- package/dist/components/conversation/prompt-input/prompt-input.class.d.ts +2 -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.js +2 -2
- 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/file-tree/file-tree.class.js +1 -1
- package/dist/components/data/flow-canvas/flow-canvas.class.js +1 -1
- 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/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/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/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-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 +5 -5
- package/dist/components/media/map/map.class.js +3 -3
- package/dist/components/media/pan-zoom/pan-zoom.class.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/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/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/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/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/docx-viewer/docx-viewer.class.js +1 -1
- package/dist/components/viewers/ebook-viewer/ebook-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 +1 -1
- 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/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
- package/dist/components/viewers/table-viewer-shared.js +4 -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/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/map-custom-layer-controller.js +1 -1
- package/dist/internal/media-panorama.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- 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-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.js +1 -1
- package/llms/components/lr-attachment-chip.md +27 -12
- package/llms/components/lr-attachment-trigger.md +27 -7
- package/llms/components/lr-button.md +6 -4
- package/llms/components/lr-chat-composer.md +13 -7
- package/llms/components/lr-chat-message.md +44 -3
- package/llms/components/lr-chat-viewport.md +39 -2
- package/llms/components/lr-data-grid.md +2 -0
- package/llms/components/lr-dialog.md +10 -0
- package/llms/components/lr-drop-zone.md +26 -2
- package/llms/components/lr-icon-button.md +2 -1
- package/llms/components/lr-json-viewer.md +17 -0
- package/llms/components/lr-locale-picker.md +5 -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-number-input.md +28 -1
- package/llms/components/lr-prompt-input.md +1 -1
- 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 +1 -0
- package/llms/peers.md +2 -2
- package/llms/shared/forms-and-accessibility.md +21 -4
- package/llms/shared.md +21 -4
- package/package.json +21 -20
- package/registrations.json +1 -1
|
@@ -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=>{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?.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(),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&&!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.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}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{observeReducedMotion}from"../../../internal/motion-observer.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon,pauseIcon}from"../../../internal/icons.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./animated-image.styles.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{LYRA_DEFAULT_animatedImageDefaultAlt,LYRA_DEFAULT_pauseWithContext,LYRA_DEFAULT_playWithContext}from"../../../internal/default-strings/media.generated.js";const MAX_FROZEN_FRAME_DIMENSION=8192,MAX_FROZEN_FRAME_PIXELS=16777216;class LyraAnimatedImage extends LyraElement{constructor(){super(...arguments),this.src="",this.play=!1,this.ignoreReducedMotion=!1,this.accessibleLabel="",this.hasLoaded=!1,this.hasError=!1,this._playing=!1,this.userPlay=!1,this.connectionEventBaselinePending=!0,this.onMotionPreferenceChange=()=>{this.requestUpdate()},this.onImageLoad=event=>{if(!this.isConnected||event.currentTarget!==this.imageEl)return;this.hasError=!1,this.hasLoaded=!0;const img=this.imageEl,canvas=this.canvasEl;if(img&&canvas){const width=img.naturalWidth,height=img.naturalHeight,allocation=resolveBoundedCanvasAllocation({cssWidth:width,cssHeight:height,desiredScale:1,maxDimension:MAX_FROZEN_FRAME_DIMENSION,maxPixels:MAX_FROZEN_FRAME_PIXELS});canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight;const ctx=canvas.getContext("2d");ctx&&(ctx.scale(allocation.scaleX,allocation.scaleY),ctx.drawImage(img,0,0,width,height))}this.emit("lr-load",null)},this.onImageError=event=>{!this.isConnected||event.currentTarget!==this.imageEl||(this.hasLoaded=!1,this.hasError=!0,this.emit("lr-error",null))},this.onToggleClick=()=>{this.userPlay=this.play=!this.play},this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,animatedImageDefaultAlt:LYRA_DEFAULT_animatedImageDefaultAlt,pauseWithContext:LYRA_DEFAULT_pauseWithContext,playWithContext:LYRA_DEFAULT_playWithContext}}static{this.knownUnobservedAttributes=["playing"]}static{this.styles=[LyraElement.styles,styles]}get playing(){return this._playing}connectedCallback(){super.connectedCallback(),this.connectionEventBaselinePending=!0,this.stopMotionWatch=observeReducedMotion(this,this.onMotionPreferenceChange),this.requestUpdate()}disconnectedCallback(){this.connectionEventBaselinePending=!0,this.stopMotionWatch?.(),this.stopMotionWatch=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed);const mayEmitConnectionTransition=this.isConnected&&!this.connectionEventBaselinePending;changed.has("src")&&(this.hasLoaded=!1,this.hasError=!1,this.src
|
|
1
|
+
import{__decorate}from"tslib";import{observeReducedMotion}from"../../../internal/motion-observer.js";import{html,nothing}from"lit";import{property,query,state}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{playIcon,pauseIcon}from"../../../internal/icons.js";import{safeMediaSrc}from"../../../internal/safe-url.js";import{prefersReducedMotion}from"../../../internal/motion.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{styles}from"./animated-image.styles.js";import{resolveBoundedCanvasAllocation}from"../../../internal/canvas.js";import{hostAriaLabel}from"../../../internal/a11y.js";import{LYRA_DEFAULT_animatedImageDefaultAlt,LYRA_DEFAULT_pauseWithContext,LYRA_DEFAULT_playWithContext}from"../../../internal/default-strings/media.generated.js";const MAX_FROZEN_FRAME_DIMENSION=8192,MAX_FROZEN_FRAME_PIXELS=16777216;class LyraAnimatedImage extends LyraElement{constructor(){super(...arguments),this.src="",this.play=!1,this.ignoreReducedMotion=!1,this.accessibleLabel="",this.hasLoaded=!1,this.hasError=!1,this._playing=!1,this.userPlay=!1,this.connectionEventBaselinePending=!0,this.onMotionPreferenceChange=()=>{this.requestUpdate()},this.onImageLoad=event=>{if(!this.isConnected||event.currentTarget!==this.imageEl)return;this.hasError=!1,this.hasLoaded=!0;const img=this.imageEl,canvas=this.canvasEl;if(img&&canvas){const width=img.naturalWidth,height=img.naturalHeight,allocation=resolveBoundedCanvasAllocation({cssWidth:width,cssHeight:height,desiredScale:1,maxDimension:MAX_FROZEN_FRAME_DIMENSION,maxPixels:MAX_FROZEN_FRAME_PIXELS});canvas.width=allocation.pixelWidth,canvas.height=allocation.pixelHeight;const ctx=canvas.getContext("2d");ctx&&(ctx.scale(allocation.scaleX,allocation.scaleY),ctx.drawImage(img,0,0,width,height))}this.emit("lr-load",null)},this.onImageError=event=>{!this.isConnected||event.currentTarget!==this.imageEl||(this.hasLoaded=!1,this.hasError=!0,this.emit("lr-error",null))},this.onToggleClick=()=>{this.userPlay=this.play=!this.play},this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)}}static{this.defaultStrings={...super.defaultStrings,animatedImageDefaultAlt:LYRA_DEFAULT_animatedImageDefaultAlt,pauseWithContext:LYRA_DEFAULT_pauseWithContext,playWithContext:LYRA_DEFAULT_playWithContext}}static{this.knownUnobservedAttributes=["playing"]}static{this.styles=[LyraElement.styles,styles]}get playing(){return this._playing}connectedCallback(){super.connectedCallback(),this.connectionEventBaselinePending=!0,this.stopMotionWatch=observeReducedMotion(this,this.onMotionPreferenceChange),this.requestUpdate()}disconnectedCallback(){this.connectionEventBaselinePending=!0,this.stopMotionWatch?.(),this.stopMotionWatch=void 0,super.disconnectedCallback()}willUpdate(changed){super.willUpdate(changed);const mayEmitConnectionTransition=this.isConnected&&!this.connectionEventBaselinePending;changed.has("src")&&(this.hasLoaded=!1,this.hasError=!1,(this.src?.trim()??"")!==""&&safeMediaSrc(this.src)===null&&(this.hasError=!0,mayEmitConnectionTransition&&this.emit("lr-error",null))),this.play||(this.userPlay=!1);const nextPlaying=this.play&&(this.ignoreReducedMotion||this.userPlay||!prefersReducedMotion(this));nextPlaying!==this._playing&&(this._playing=nextPlaying,this.toggleAttribute("playing",nextPlaying),mayEmitConnectionTransition&&this.emit(nextPlaying?"lr-play":"lr-pause",null)),this.toggleAttribute("data-loaded",this.hasLoaded)}updated(changed){super.updated(changed),this.isConnected&&(this.connectionEventBaselinePending=!1)}get effectiveAlt(){return this.alt??""}get toggleLabel(){const authoredLabel=hostAriaLabel(this);if(authoredLabel)return authoredLabel;if(this.accessibleLabel)return this.accessibleLabel;const name=this.effectiveAlt||this.localize("animatedImageDefaultAlt");return this.playing?this.localize("pauseWithContext",void 0,{name}):this.localize("playWithContext",void 0,{name})}focus(options){this.playButtonEl?.focus(options)}blur(){this.playButtonEl?.blur()}click(){this.playButtonEl?.click()}render(){const src=safeMediaSrc(this.src),alt=this.effectiveAlt,frozen=this.hasLoaded&&!this.playing,showControls=this.hasLoaded&&!this.hasError;return html`
|
|
2
2
|
<div part="base">
|
|
3
3
|
<img
|
|
4
4
|
part="image"
|
|
@@ -12,12 +12,19 @@ import{type PropertyValues,type PropertyDeclaration,type TemplateResult}from'lit
|
|
|
12
12
|
* for reconstructing a chip from server-persisted attachment metadata
|
|
13
13
|
* (e.g. after a page reload, when no real `File` object exists any more).
|
|
14
14
|
*
|
|
15
|
-
* `file`
|
|
16
|
-
* The image thumbnail
|
|
17
|
-
* blob URL, created in the
|
|
18
|
-
* renders and revoked
|
|
19
|
-
* changes away from the object it was created for,
|
|
20
|
-
*
|
|
15
|
+
* `file` wins for `name`/`bytes`/`mime-type` when both are present — see each
|
|
16
|
+
* accessor's own doc. The image thumbnail and the preview source for a real
|
|
17
|
+
* `File` default to a cached `URL.createObjectURL()` blob URL, created in the
|
|
18
|
+
* update lifecycle immediately before the thumbnail renders and revoked
|
|
19
|
+
* automatically once `file` changes away from the object it was created for,
|
|
20
|
+
* once host-supplied sources make it unnecessary, and on disconnect — this
|
|
21
|
+
* component never leaks a blob URL. A non-empty, safe `thumbnail-src` (and a
|
|
22
|
+
* non-empty `preview-src`) takes precedence over that blob URL even while
|
|
23
|
+
* `file` is set, so a page whose Content-Security-Policy has no `blob:` in
|
|
24
|
+
* `img-src` can keep passing the `File` for name/size/type and supply its own
|
|
25
|
+
* `data:` or same-origin thumbnail: with both set (or `thumbnail-src` plus
|
|
26
|
+
* `without-preview`) no blob URL is ever created. Otherwise, showing a `File`'s
|
|
27
|
+
* own image needs `blob:` in `img-src`.
|
|
21
28
|
*
|
|
22
29
|
* Identifying *which* attachment a `lr-remove`/`lr-retry`/`lr-preview-request` event is about:
|
|
23
30
|
* set `attachment-id="..."` when you have a stable server-side attachment identity. The platform
|
|
@@ -98,14 +105,14 @@ name:string;private _bytes?;get bytes():number|undefined;set bytes(value:number|
|
|
|
98
105
|
attachmentId:string;
|
|
99
106
|
/** MIME type, used only while `file` is unset.*/
|
|
100
107
|
mimeType:string;
|
|
101
|
-
/** Thumbnail image URL,
|
|
102
|
-
*
|
|
103
|
-
*
|
|
104
|
-
* `
|
|
105
|
-
*
|
|
108
|
+
/** Thumbnail image URL. Rendered whenever present and safe, also while `file` is set: it then
|
|
109
|
+
* replaces the blob URL a `File`'s own image thumbnail would otherwise use (see the class doc),
|
|
110
|
+
* for example a small `data:` thumbnail under a Content-Security-Policy without `blob:`. Like
|
|
111
|
+
* the no-`file` case it renders regardless of the MIME type, since a generated thumbnail is
|
|
112
|
+
* always an image. Unsafe schemes are ignored. */
|
|
106
113
|
thumbnailSrc:string;
|
|
107
|
-
/** URL used to preview or download the attachment
|
|
108
|
-
*
|
|
114
|
+
/** URL used to preview or download the attachment. While `file` is set and this is empty, the
|
|
115
|
+
* `File` is previewed through a temporary blob URL instead; a non-empty value wins over it. */
|
|
109
116
|
previewSrc:string;
|
|
110
117
|
/** Hides the preview action, which otherwise renders whenever a `file` or `preview-src` is
|
|
111
118
|
* available. */
|
|
@@ -150,4 +157,4 @@ uploadFailedLabel?:string;
|
|
|
150
157
|
/** Override for the empty-name fallback shown (and used as the `title` tooltip) when neither
|
|
151
158
|
* `file` nor `name` supply a filename -- for i18n/locale. Defaults to `'Untitled file'`,
|
|
152
159
|
* reproducing today's exact hardcoded text byte-for-byte. */
|
|
153
|
-
untitledLabel?:string;private objectUrl?;private objectUrlFile?;private readonly announcements;private readonly fallbackId;private get effectiveName();private get effectiveSize();private get effectiveMimeType();private get effectivePreviewSrc();private get resolvedId();private get hasNumericProgress();private get clampedProgress();private get compactDensity();private get effectiveStatus();private ensureObjectUrl;private revokeObjectUrl;private connectedStatusTransition;requestUpdate(name?:PropertyKey,oldValue?:unknown,options?:PropertyDeclaration):void;connectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;disconnectedCallback():void;private get localizedUploadFailedLabel();private onRemoveClick;private onRetryClick;private onPreviewClick;private renderThumbnail;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-attachment-chip':LyraAttachmentChip;}}
|
|
160
|
+
untitledLabel?:string;private objectUrl?;private objectUrlFile?;private readonly announcements;private readonly fallbackId;private get effectiveName();private get effectiveSize();private get effectiveMimeType();private get effectivePreviewSrc();private get hostThumbnailSrc();private fileNeedsObjectUrl;private get resolvedId();private get hasNumericProgress();private get clampedProgress();private get compactDensity();private get effectiveStatus();private ensureObjectUrl;private revokeObjectUrl;private connectedStatusTransition;requestUpdate(name?:PropertyKey,oldValue?:unknown,options?:PropertyDeclaration):void;connectedCallback():void;adoptedCallback():void;protected willUpdate(changed:PropertyValues):void;disconnectedCallback():void;private get localizedUploadFailedLabel();private onRemoveClick;private onRetryClick;private onPreviewClick;private renderThumbnail;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-attachment-chip':LyraAttachmentChip;}}
|
|
@@ -11,7 +11,7 @@ import{__decorate}from"tslib";import{html,nothing,svg}from"lit";import{property}
|
|
|
11
11
|
aria-hidden="true"
|
|
12
12
|
focusable="false"
|
|
13
13
|
><polyline points="1 4 1 10 7 10"></polyline><path d="M3.51 15a9 9 0 1 0 2.13-9.36L1 10"></path></svg>
|
|
14
|
-
`}function statusText(status,uploadingText,uploadFailedLabel){return status==="error"?uploadFailedLabel:status==="uploading"?uploadingText:""}function fillMessage(message,values){return message.replace(/\{(label|percent)\}/g,(match,key)=>values[key]??match)}class LyraAttachmentChip extends LyraElement{constructor(){super(...arguments),this.name="",this.attachmentId="",this.mimeType="",this.thumbnailSrc="",this.previewSrc="",this.withoutPreview=!1,this.status="pending",this.progress=0,this.withoutRemoveButton=!1,this.thumbnailOnly=!1,this.announcements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.fallbackId=nextId("attachment-chip"),this.connectedStatusTransition=!1,this.onRemoveClick=()=>{this.emit("lr-remove",{attachmentId:this.resolvedId})},this.onRetryClick=()=>{this.emit("lr-retry",{attachmentId:this.resolvedId})},this.onPreviewClick=()=>{this.effectivePreviewSrc&&this.emit("lr-preview-request",{attachmentId:this.resolvedId,name:this.effectiveName,mimeType:this.effectiveMimeType,src:this.effectivePreviewSrc})}}static{this.defaultStrings={...super.defaultStrings,attachmentPreviewFile:LYRA_DEFAULT_attachmentPreviewFile,attachmentPreviewName:LYRA_DEFAULT_attachmentPreviewName,attachmentRetryWithContext:LYRA_DEFAULT_attachmentRetryWithContext,attachmentUntitledFile:LYRA_DEFAULT_attachmentUntitledFile,attachmentUploadFailed:LYRA_DEFAULT_attachmentUploadFailed,attachmentUploadingIndeterminate:LYRA_DEFAULT_attachmentUploadingIndeterminate,attachmentUploadingProgress:LYRA_DEFAULT_attachmentUploadingProgress,attachmentUploadingWithContext:LYRA_DEFAULT_attachmentUploadingWithContext,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,fileSizeUnitB:LYRA_DEFAULT_fileSizeUnitB,fileSizeUnitGb:LYRA_DEFAULT_fileSizeUnitGb,fileSizeUnitKb:LYRA_DEFAULT_fileSizeUnitKb,fileSizeUnitMb:LYRA_DEFAULT_fileSizeUnitMb,fileSizeUnitTb:LYRA_DEFAULT_fileSizeUnitTb,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,removeWithContext:LYRA_DEFAULT_removeWithContext,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get bytes(){return this._bytes}set bytes(value){const old=this._bytes;this._bytes=typeof value=="number"&&Number.isFinite(value)&&value>=0?finiteRange(value,0,0):void 0,this.requestUpdate("bytes",old)}get size(){return this._size}set size(next){const raw=this.getAttribute("size"),normalized=raw!==null&&optionalSizeConverter.normalize(raw)!==void 0?optionalSizeConverter.normalize(next):normalizeReflectedOptionalSize(this,next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}get effectiveName(){return this.file?this.file.name:this.name}get effectiveSize(){return this.file?Number.isFinite(this.file.size)&&this.file.size>=0?finiteRange(this.file.size,0,0):void 0:this.bytes}get effectiveMimeType(){return this.file?this.file.type:this.mimeType}get effectivePreviewSrc(){return this.file?this.objectUrl??"":this.previewSrc}get resolvedId(){return this.attachmentId.trim().length>0?this.attachmentId:this.file?`${this.file.name}:${this.file.size}:${this.file.lastModified}`:this.fallbackId}get hasNumericProgress(){return this.status==="uploading"&&this.clampedProgress>0}get clampedProgress(){return finiteRange(this.progress,0,0,100)}get compactDensity(){return isCompactSize(this.size)}get effectiveStatus(){return this.status==="uploading"||this.status==="error"||this.status==="success"?this.status:"pending"}ensureObjectUrl(file){return this.objectUrlFile===file&&this.objectUrl?this.objectUrl:(this.revokeObjectUrl(),this.objectUrl=URL.createObjectURL(file),this.objectUrlFile=file,this.objectUrl)}revokeObjectUrl(){this.objectUrl&&URL.revokeObjectURL(this.objectUrl),this.objectUrl=void 0,this.objectUrlFile=void 0}requestUpdate(name,oldValue,options){name==="status"&&this.isConnected&&this.hasUpdated&&oldValue!==this.status&&(this.connectedStatusTransition=!0),super.requestUpdate(name,oldValue,options)}connectedCallback(){super.connectedCallback(),this.connectedStatusTransition=!1,this.hasUpdated&&this.requestUpdate()}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}willUpdate(changed){super.willUpdate(changed),changed.has("status")&&this.status!==this.effectiveStatus&&(this.status=this.effectiveStatus),this.isConnected&&this.hasUpdated&&this.connectedStatusTransition&&this.status==="error"&&this.announcements.announceAssertive(this.localizedUploadFailedLabel),this.connectedStatusTransition=!1,this.isConnected&&this.file&&
|
|
14
|
+
`}function statusText(status,uploadingText,uploadFailedLabel){return status==="error"?uploadFailedLabel:status==="uploading"?uploadingText:""}function fillMessage(message,values){return message.replace(/\{(label|percent)\}/g,(match,key)=>values[key]??match)}class LyraAttachmentChip extends LyraElement{constructor(){super(...arguments),this.name="",this.attachmentId="",this.mimeType="",this.thumbnailSrc="",this.previewSrc="",this.withoutPreview=!1,this.status="pending",this.progress=0,this.withoutRemoveButton=!1,this.thumbnailOnly=!1,this.announcements=new AnnouncementSinkController(this,{eager:["assertive"]}),this.fallbackId=nextId("attachment-chip"),this.connectedStatusTransition=!1,this.onRemoveClick=()=>{this.emit("lr-remove",{attachmentId:this.resolvedId})},this.onRetryClick=()=>{this.emit("lr-retry",{attachmentId:this.resolvedId})},this.onPreviewClick=()=>{this.effectivePreviewSrc&&this.emit("lr-preview-request",{attachmentId:this.resolvedId,name:this.effectiveName,mimeType:this.effectiveMimeType,src:this.effectivePreviewSrc})}}static{this.defaultStrings={...super.defaultStrings,attachmentPreviewFile:LYRA_DEFAULT_attachmentPreviewFile,attachmentPreviewName:LYRA_DEFAULT_attachmentPreviewName,attachmentRetryWithContext:LYRA_DEFAULT_attachmentRetryWithContext,attachmentUntitledFile:LYRA_DEFAULT_attachmentUntitledFile,attachmentUploadFailed:LYRA_DEFAULT_attachmentUploadFailed,attachmentUploadingIndeterminate:LYRA_DEFAULT_attachmentUploadingIndeterminate,attachmentUploadingProgress:LYRA_DEFAULT_attachmentUploadingProgress,attachmentUploadingWithContext:LYRA_DEFAULT_attachmentUploadingWithContext,collapse:LYRA_DEFAULT_collapse,details:LYRA_DEFAULT_details,fileSizeUnitB:LYRA_DEFAULT_fileSizeUnitB,fileSizeUnitGb:LYRA_DEFAULT_fileSizeUnitGb,fileSizeUnitKb:LYRA_DEFAULT_fileSizeUnitKb,fileSizeUnitMb:LYRA_DEFAULT_fileSizeUnitMb,fileSizeUnitTb:LYRA_DEFAULT_fileSizeUnitTb,loading:LYRA_DEFAULT_loading,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,removeWithContext:LYRA_DEFAULT_removeWithContext,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.styles=[LyraElement.styles,styles]}get bytes(){return this._bytes}set bytes(value){const old=this._bytes;this._bytes=typeof value=="number"&&Number.isFinite(value)&&value>=0?finiteRange(value,0,0):void 0,this.requestUpdate("bytes",old)}get size(){return this._size}set size(next){const raw=this.getAttribute("size"),normalized=raw!==null&&optionalSizeConverter.normalize(raw)!==void 0?optionalSizeConverter.normalize(next):normalizeReflectedOptionalSize(this,next),old=this._size;old!==normalized&&(this._size=normalized,this.requestUpdate("size",old))}get effectiveName(){return this.file?this.file.name:this.name}get effectiveSize(){return this.file?Number.isFinite(this.file.size)&&this.file.size>=0?finiteRange(this.file.size,0,0):void 0:this.bytes}get effectiveMimeType(){return this.file?this.file.type:this.mimeType}get effectivePreviewSrc(){return this.previewSrc?this.previewSrc:this.file?this.objectUrl??"":""}get hostThumbnailSrc(){return safeMediaSrc(this.thumbnailSrc)}fileNeedsObjectUrl(file){const forThumbnail=file.type.startsWith("image/")&&!this.hostThumbnailSrc,forPreview=!this.withoutPreview&&!this.previewSrc;return forThumbnail||forPreview}get resolvedId(){return this.attachmentId.trim().length>0?this.attachmentId:this.file?`${this.file.name}:${this.file.size}:${this.file.lastModified}`:this.fallbackId}get hasNumericProgress(){return this.status==="uploading"&&this.clampedProgress>0}get clampedProgress(){return finiteRange(this.progress,0,0,100)}get compactDensity(){return isCompactSize(this.size)}get effectiveStatus(){return this.status==="uploading"||this.status==="error"||this.status==="success"?this.status:"pending"}ensureObjectUrl(file){return this.objectUrlFile===file&&this.objectUrl?this.objectUrl:(this.revokeObjectUrl(),this.objectUrl=URL.createObjectURL(file),this.objectUrlFile=file,this.objectUrl)}revokeObjectUrl(){this.objectUrl&&URL.revokeObjectURL(this.objectUrl),this.objectUrl=void 0,this.objectUrlFile=void 0}requestUpdate(name,oldValue,options){name==="status"&&this.isConnected&&this.hasUpdated&&oldValue!==this.status&&(this.connectedStatusTransition=!0),super.requestUpdate(name,oldValue,options)}connectedCallback(){super.connectedCallback(),this.connectedStatusTransition=!1,this.hasUpdated&&this.requestUpdate()}adoptedCallback(){super.adoptedCallback(),this.announcements.adopted()}willUpdate(changed){super.willUpdate(changed),changed.has("status")&&this.status!==this.effectiveStatus&&(this.status=this.effectiveStatus),this.isConnected&&this.hasUpdated&&this.connectedStatusTransition&&this.status==="error"&&this.announcements.announceAssertive(this.localizedUploadFailedLabel),this.connectedStatusTransition=!1,this.isConnected&&this.file&&this.fileNeedsObjectUrl(this.file)?this.ensureObjectUrl(this.file):this.objectUrlFile&&this.revokeObjectUrl()}disconnectedCallback(){super.disconnectedCallback(),this.revokeObjectUrl()}get localizedUploadFailedLabel(){return this.uploadFailedLabel??this.localize("attachmentUploadFailed")}renderThumbnail(){const hostThumbnailSrc=this.hostThumbnailSrc;if(this.file&&!hostThumbnailSrc){const fileImageSrc=this.objectUrl?safeMediaSrc(this.objectUrl):null;return this.effectiveMimeType.startsWith("image/")?fileImageSrc?html`<img src=${fileImageSrc} alt="" />`:html`${fileIcon()}`:html`${fileIcon()}`}return hostThumbnailSrc?html`<img src=${hostThumbnailSrc} alt="" />`:html`${fileIcon()}`}render(){const name=this.effectiveName,untitledLabel=this.untitledLabel??this.localize("attachmentUntitledFile"),displayName=name||untitledLabel,sizeText=this.effectiveSize!==void 0?formatFileSize(this.effectiveSize,unit=>this.localize(FILE_SIZE_UNIT_KEYS[unit]),localizedNumberLabel(this.effectiveLocale)):"",uploadFailedLabel=this.localizedUploadFailedLabel,progressPercent=getNumberFormat(this.effectiveLocale,{maximumFractionDigits:0}).format(Math.round(this.clampedProgress)),uploadingText=this.uploadingLabel!=null?fillMessage(this.uploadingLabel,{label:displayName,percent:progressPercent}):this.hasNumericProgress?this.localize("attachmentUploadingProgress",void 0,{percent:progressPercent}):this.localize("attachmentUploadingIndeterminate"),uploadingWithContext=this.uploadingLabel?uploadingText:this.localize("attachmentUploadingWithContext",void 0,{label:displayName}),retryWithContext=this.retryLabel?fillMessage(this.retryLabel,{label:displayName}):this.localize("attachmentRetryWithContext",void 0,{label:displayName}),removeWithContext=this.removeLabel?fillMessage(this.removeLabel,{label:displayName}):this.localize("removeWithContext",void 0,{label:displayName}),status=this.effectiveStatus,text=statusText(status,uploadingText,uploadFailedLabel),uploading=status==="uploading";return html`
|
|
15
15
|
<div part="base">
|
|
16
16
|
<span part="thumbnail" aria-hidden="true"
|
|
17
17
|
>${this.renderThumbnail()}</span
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
import type{LyraEventDetailSnapshot}from'../../../internal/lyra-element.js';import{type PropertyValues,type TemplateResult}from'lit';import{LyraElement}from'../../../internal/lyra-element.js';import type{LyraAppearance,LyraSize}from'../../../internal/variants.js';import type{LyraFileInputRejectedFile}from'../file-input/file-input.class.js';export type LyraAttachmentCapability='files'|'image'|'camera'|'audio';
|
|
2
2
|
/** The capabilities that resolve to a real file selection (as opposed to `camera`/`audio`, which
|
|
3
3
|
* never touch the hidden file input -- see the class doc). */
|
|
4
|
-
export type LyraFileBackedCapability=Exclude<LyraAttachmentCapability,'camera'|'audio'>;
|
|
4
|
+
export type LyraFileBackedCapability=Exclude<LyraAttachmentCapability,'camera'|'audio'>;
|
|
5
|
+
/** The native `capture` values `camera-capture` accepts: which camera a capture-capable (touch)
|
|
6
|
+
* device opens. */
|
|
7
|
+
export type LyraAttachmentCameraCapture='user'|'environment';
|
|
8
|
+
/** The capabilities an `lr-files` event can report: the file-backed ones, plus `camera` while
|
|
9
|
+
* `camera-capture` routes it through the system camera. */
|
|
10
|
+
export type LyraAttachmentFilesCapability=LyraFileBackedCapability|'camera';export interface LyraAttachmentFilesDetail{capability:LyraAttachmentFilesCapability;files:readonly File[];rejected:readonly LyraFileInputRejectedFile[];remainingFiles:number|null;remainingTotalSize:number|null;}export interface LyraAttachmentTriggerEventMap{'lr-camera-request':CustomEvent<null>;'lr-audio-request':CustomEvent<null>;'lr-files':CustomEvent<LyraEventDetailSnapshot<LyraAttachmentFilesDetail>>;blur:FocusEvent;focus:FocusEvent;}
|
|
5
11
|
/**
|
|
6
12
|
* `<lr-attachment-trigger>` — a compact attach affordance designed for a
|
|
7
13
|
* chat composer's start slot (see `<lr-chat-composer>`'s own `start`
|
|
@@ -22,25 +28,35 @@ export type LyraFileBackedCapability=Exclude<LyraAttachmentCapability,'camera'|'
|
|
|
22
28
|
* `<input type="file">` with no `accept` attribute).
|
|
23
29
|
*
|
|
24
30
|
* **`camera`/`audio` are scope-limited by design.** This component does not
|
|
25
|
-
* implement any camera or microphone capture UI itself — no `getUserMedia
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
*
|
|
29
|
-
* `
|
|
30
|
-
*
|
|
31
|
-
*
|
|
32
|
-
*
|
|
31
|
+
* implement any camera or microphone capture UI itself — no `getUserMedia` —
|
|
32
|
+
* because that's entirely a host/browser concern with no single right answer
|
|
33
|
+
* (a desktop web app, a mobile PWA, and a native wrapper all want different
|
|
34
|
+
* things here). Activating `camera` fires `lr-camera-request`; activating
|
|
35
|
+
* `audio` fires `lr-audio-request`. The host owns everything from that point
|
|
36
|
+
* on — typically opening `<lr-push-to-talk>` in a `<lr-overlay>`/popover for
|
|
37
|
+
* `audio`, then handing the resulting blob to something like
|
|
38
|
+
* `<lr-attachment-chip>`.
|
|
39
|
+
*
|
|
40
|
+
* The one opt-in exception is `camera-capture`: set it to `'environment'` or
|
|
41
|
+
* `'user'` and, on an engine that supports the native `capture` attribute
|
|
42
|
+
* (phones and tablets), `camera` opens the shared hidden file input with
|
|
43
|
+
* `accept="image/*"` and that `capture` value synchronously inside the
|
|
44
|
+
* activation, so the system camera opens, and the photo arrives as `lr-files`
|
|
45
|
+
* with `capability: 'camera'`. Where `capture` is unsupported (desktop
|
|
46
|
+
* browsers, which would only show a file picker), `camera` still fires
|
|
47
|
+
* `lr-camera-request`, so one host can keep its own camera dialog there.
|
|
33
48
|
*
|
|
34
49
|
* @customElement lr-attachment-trigger
|
|
35
50
|
* @event lr-files - A file-backed capability's hidden file input produced a real selection.
|
|
36
|
-
* `detail: { capability: 'files' | 'image', files, rejected, remainingFiles,
|
|
51
|
+
* `detail: { capability: 'files' | 'image' | 'camera', files, rejected, remainingFiles,
|
|
52
|
+
* remainingTotalSize }` (`'camera'` only while `camera-capture` routed the capture there),
|
|
37
53
|
* the same shape as `lr-file-input`'s. `files` are the picks matching `accept` (a fresh readonly
|
|
38
54
|
* owner-realm `File[]` snapshot rather than the native input's live `FileList`); the rest, which
|
|
39
55
|
* the OS dialog's "All files" filter can let through, are listed in `rejected`. No size or count
|
|
40
56
|
* limits apply here, so both `remaining*` fields are `null`.
|
|
41
57
|
* @event lr-camera-request - The `camera` capability was activated. No
|
|
42
58
|
* detail payload — see the class doc's scope note; the host implements the
|
|
43
|
-
* actual capture flow.
|
|
59
|
+
* actual capture flow. Not fired when `camera-capture` opens the system camera instead.
|
|
44
60
|
* @event lr-audio-request - The `audio` capability was activated. No
|
|
45
61
|
* detail payload — same request-only scope as `lr-camera-request`; the
|
|
46
62
|
* host implements the actual recording flow (typically `<lr-push-to-talk>`).
|
|
@@ -84,6 +100,14 @@ accept:string;private hostAccessibleLabel;
|
|
|
84
100
|
* `[part=menu-trigger]` button. Unset (the default): no `title` attribute, unchanged from
|
|
85
101
|
* before this property existed. */
|
|
86
102
|
triggerTitle?:string;
|
|
103
|
+
/** Opt-in system-camera capture for the `camera` capability: `'environment'` (rear camera) or
|
|
104
|
+
* `'user'` (front camera), the native `<input capture>` values. On an engine that supports
|
|
105
|
+
* `capture` (phones and tablets), activating `camera` opens the hidden file input with
|
|
106
|
+
* `accept="image/*"` and this `capture` value inside the same user gesture and reports the photo
|
|
107
|
+
* as `lr-files` with `capability: 'camera'` (non-image picks move to `rejected`). Elsewhere it
|
|
108
|
+
* keeps firing `lr-camera-request`. Unset (the default) or any other value: `camera` only fires
|
|
109
|
+
* `lr-camera-request`, unchanged. */
|
|
110
|
+
cameraCapture?:LyraAttachmentCameraCapture;
|
|
87
111
|
/** Forwarded to the hidden file input's own `multiple` attribute.*/
|
|
88
112
|
multiple:boolean;disabled:boolean;
|
|
89
113
|
/** How the trigger fills itself, from the library's one shared `appearance` vocabulary. The
|
|
@@ -99,4 +123,4 @@ appearance:LyraAppearance;
|
|
|
99
123
|
* tightest tiers resolve below WCAG 2.5.8's minimum, so wiring the target to it would let
|
|
100
124
|
* `size="2xs"` ship an untappable control. Override `--lr-icon-button-size` to make that
|
|
101
125
|
* trade-off explicitly, exactly as on a standalone `<lr-icon-button>`. */
|
|
102
|
-
size:LyraSize;private inputEl?;private dropdownEl?;private composedTriggerEl?;private descriptionSyncGeneration;private get triggerEl();private hasSyncedDescribedByElements;private pendingCapability;private pickerGeneration;private pendingPickerGeneration;private get effectiveCapabilities();private get hasFileCapability();protected willUpdate(changed:PropertyValues<this>):void;protected updated(changed:PropertyValues<this>):void;private syncTriggerDescription;private effectiveAccept;private activateCapability;private onTriggerClick;private onMenuSelect;private onInputChange;disconnectedCallback():void;private onControlFocus;private onControlBlur;private stopInternalEvent;private primaryControl;focus(options?:FocusOptions):void;blur():void;click():void;private renderHiddenInput;private renderSingleTrigger;private renderMenu;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-attachment-trigger':LyraAttachmentTrigger;}}
|
|
126
|
+
size:LyraSize;private inputEl?;private dropdownEl?;private composedTriggerEl?;private descriptionSyncGeneration;private get triggerEl();private hasSyncedDescribedByElements;private pendingCapability;private pickerGeneration;private pendingPickerGeneration;private get effectiveCapabilities();private get hasFileCapability();private get captureSupported();protected willUpdate(changed:PropertyValues<this>):void;protected updated(changed:PropertyValues<this>):void;private syncTriggerDescription;private effectiveAccept;private activateCapability;private onTriggerClick;private onMenuSelect;private onInputChange;disconnectedCallback():void;private onControlFocus;private onControlBlur;private stopInternalEvent;private primaryControl;focus(options?:FocusOptions):void;blur():void;click():void;private renderHiddenInput;private renderSingleTrigger;private renderMenu;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-attachment-trigger':LyraAttachmentTrigger;}}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing,svg}from"lit";import{property,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{syncAriaDescribedByElements}from"../../../internal/aria-controls.js";import{chevronIcon}from"../../../internal/icons.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./attachment-trigger.styles.js";import{falseDefaultBooleanConverter}from"../../../internal/converters.js";import{matchesAccept}from"../file-input/accept.js";import{LYRA_DEFAULT_attachmentAdd,LYRA_DEFAULT_attachmentMenuAudio,LYRA_DEFAULT_attachmentMenuCamera,LYRA_DEFAULT_attachmentMenuFiles,LYRA_DEFAULT_attachmentMenuImage,LYRA_DEFAULT_attachmentTriggerAudio,LYRA_DEFAULT_attachmentTriggerCamera,LYRA_DEFAULT_attachmentTriggerFiles,LYRA_DEFAULT_attachmentTriggerImage}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function icon(paths){return svg`
|
|
1
|
+
import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/collection-snapshot.js";import{html,nothing,svg}from"lit";import{property,query}from"lit/decorators.js";import{LyraElement}from"../../../internal/lyra-element.js";import{syncAriaDescribedByElements}from"../../../internal/aria-controls.js";import{chevronIcon}from"../../../internal/icons.js";import{relayNativeEvent}from"../../../internal/native-event-relay.js";import{sizes}from"../../../internal/sizes.styles.js";import{styles}from"./attachment-trigger.styles.js";import{falseDefaultBooleanConverter}from"../../../internal/converters.js";import{matchesAccept}from"../file-input/accept.js";import{LYRA_DEFAULT_attachmentAdd,LYRA_DEFAULT_attachmentMenuAudio,LYRA_DEFAULT_attachmentMenuCamera,LYRA_DEFAULT_attachmentMenuFiles,LYRA_DEFAULT_attachmentMenuImage,LYRA_DEFAULT_attachmentTriggerAudio,LYRA_DEFAULT_attachmentTriggerCamera,LYRA_DEFAULT_attachmentTriggerFiles,LYRA_DEFAULT_attachmentTriggerImage}from"../../../internal/default-strings/media.generated.js";import{LYRA_DEFAULT_collapse,LYRA_DEFAULT_copy,LYRA_DEFAULT_date,LYRA_DEFAULT_details,LYRA_DEFAULT_map,LYRA_DEFAULT_navigation,LYRA_DEFAULT_open,LYRA_DEFAULT_search,LYRA_DEFAULT_select}from"../../../internal/default-strings/shared.generated.js";function isCameraCapture(value){return value==="user"||value==="environment"}const ICON_VIEW_BOX="0 0 24 24",ICON_STROKE_WIDTH="1.75";function icon(paths){return svg`
|
|
2
2
|
<svg
|
|
3
3
|
width="1em"
|
|
4
4
|
height="1em"
|
|
@@ -25,7 +25,7 @@ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/co
|
|
|
25
25
|
<path d="M19 10v2a7 7 0 0 1-14 0v-2"></path>
|
|
26
26
|
<line x1="12" y1="19" x2="12" y2="23"></line>
|
|
27
27
|
<line x1="8" y1="23" x2="16" y2="23"></line>
|
|
28
|
-
`)}const CAPABILITY_META={files:{icon:paperclipIcon,triggerKey:"attachmentTriggerFiles",menuKey:"attachmentMenuFiles"},image:{icon:imageIcon,triggerKey:"attachmentTriggerImage",menuKey:"attachmentMenuImage"},camera:{icon:cameraIcon,triggerKey:"attachmentTriggerCamera",menuKey:"attachmentMenuCamera"},audio:{icon:audioIcon,triggerKey:"attachmentTriggerAudio",menuKey:"attachmentMenuAudio"}},OWNED_CAPABILITY_SNAPSHOTS=new WeakSet;function ownCapabilitySnapshot(values){const snapshot=Object.freeze(values);return OWNED_CAPABILITY_SNAPSHOTS.add(snapshot),snapshot}const DEFAULT_CAPABILITIES=ownCapabilitySnapshot(["files"]),MAX_ATTACHMENT_CAPABILITIES=4,ATTACHMENT_CAPABILITY_SCAN_LIMIT=64;function normalizeCapabilities(value){try{if(!Array.isArray(value))return DEFAULT_CAPABILITIES;if(OWNED_CAPABILITY_SNAPSHOTS.has(value))return value;const normalized=[],length=Math.min(value.length,ATTACHMENT_CAPABILITY_SCAN_LIMIT);for(let index=0;index<length&&normalized.length<MAX_ATTACHMENT_CAPABILITIES;index++){const candidate=value[index];typeof candidate=="string"&&Object.prototype.hasOwnProperty.call(CAPABILITY_META,candidate)&&!normalized.includes(candidate)&&normalized.push(candidate)}return ownCapabilitySnapshot(normalized)}catch{return DEFAULT_CAPABILITIES}}function isCanonicalCapabilitySnapshot(source){try{return typeof source=="object"&&source!==null&&OWNED_CAPABILITY_SNAPSHOTS.has(source)}catch{return!1}}class LyraAttachmentTrigger extends LyraElement{constructor(){super(...arguments),this.capabilities=DEFAULT_CAPABILITIES,this.accept="",this.hostAccessibleLabel=null,this.multiple=!1,this.disabled=!1,this.appearance="plain",this.size="m",this.descriptionSyncGeneration=0,this.hasSyncedDescribedByElements=!1,this.pendingCapability="files",this.pickerGeneration=0,this.pendingPickerGeneration=-1,this.onTriggerClick=()=>{const capability=this.effectiveCapabilities[0];capability!==void 0&&this.activateCapability(capability)},this.onMenuSelect=e=>{e.stopPropagation();const capability=e.detail.item.value;Object.prototype.hasOwnProperty.call(CAPABILITY_META,capability)&&this.effectiveCapabilities.includes(capability)&&this.activateCapability(capability)},this.onInputChange=e=>{e.stopPropagation();const input=e.target,selected=input.files,generation=this.pendingPickerGeneration;if(this.pendingPickerGeneration=-1,this.isConnected&&generation===this.pickerGeneration&&!this.disabled&&selected&&selected.length>0){const accept=this.effectiveAccept(this.pendingCapability),files=Array.from(selected),matching=files.filter(file=>matchesAccept(file,accept)),matchingFiles=new Set(matching);this.emit("lr-files",{capability:this.pendingCapability,files:matching,rejected:files.filter(file=>!matchingFiles.has(file)).map(file=>({file,reason:"type"})),remainingFiles:null,remainingTotalSize:null})}input.value=""},this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.stopInternalEvent=event=>{event.stopPropagation()}}static{this.defaultStrings={...super.defaultStrings,attachmentAdd:LYRA_DEFAULT_attachmentAdd,attachmentMenuAudio:LYRA_DEFAULT_attachmentMenuAudio,attachmentMenuCamera:LYRA_DEFAULT_attachmentMenuCamera,attachmentMenuFiles:LYRA_DEFAULT_attachmentMenuFiles,attachmentMenuImage:LYRA_DEFAULT_attachmentMenuImage,attachmentTriggerAudio:LYRA_DEFAULT_attachmentTriggerAudio,attachmentTriggerCamera:LYRA_DEFAULT_attachmentTriggerCamera,attachmentTriggerFiles:LYRA_DEFAULT_attachmentTriggerFiles,attachmentTriggerImage:LYRA_DEFAULT_attachmentTriggerImage,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["capabilities"])}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.immutableEventDetails=Object.freeze(["lr-files"])}get triggerEl(){return this.composedTriggerEl?.control??this.composedTriggerEl}get effectiveCapabilities(){return normalizeCapabilities(this.capabilities)}get hasFileCapability(){return this.effectiveCapabilities.includes("files")||this.effectiveCapabilities.includes("image")}willUpdate(changed){if(super.willUpdate(changed),changed.has("disabled")&&this.disabled&&this.dropdownEl?.hide(),changed.has("capabilities")){const normalized=normalizeCapabilities(this.capabilities);isCanonicalCapabilitySnapshot(this.capabilities)||(this.capabilities=normalized)}}updated(changed){super.updated(changed),this.syncTriggerDescription();const composed=this.composedTriggerEl;if(!composed||composed.control)return;const generation=++this.descriptionSyncGeneration;composed.updateComplete.then(()=>{generation!==this.descriptionSyncGeneration||!this.isConnected||this.syncTriggerDescription()})}syncTriggerDescription(){const hostDescribedBy=this.getAttribute("aria-describedby");!hostDescribedBy&&!this.hasSyncedDescribedByElements||(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,this.triggerEl,hostDescribedBy))}effectiveAccept(capability){return capability==="image"?this.accept||"image/*":this.accept}activateCapability(capability){if(this.disabled)return;if(capability==="camera"){this.emit("lr-camera-request",null);return}if(capability==="audio"){this.emit("lr-audio-request",null);return}this.pendingCapability=capability,this.pendingPickerGeneration=++this.pickerGeneration;const input=this.inputEl;input&&(input.accept=this.effectiveAccept(capability),input.click())}disconnectedCallback(){this.pendingPickerGeneration=-1,this.pickerGeneration++,this.dropdownEl?.hide(),super.disconnectedCallback()}primaryControl(){return this.renderRoot
|
|
28
|
+
`)}const CAPABILITY_META={files:{icon:paperclipIcon,triggerKey:"attachmentTriggerFiles",menuKey:"attachmentMenuFiles"},image:{icon:imageIcon,triggerKey:"attachmentTriggerImage",menuKey:"attachmentMenuImage"},camera:{icon:cameraIcon,triggerKey:"attachmentTriggerCamera",menuKey:"attachmentMenuCamera"},audio:{icon:audioIcon,triggerKey:"attachmentTriggerAudio",menuKey:"attachmentMenuAudio"}},OWNED_CAPABILITY_SNAPSHOTS=new WeakSet;function ownCapabilitySnapshot(values){const snapshot=Object.freeze(values);return OWNED_CAPABILITY_SNAPSHOTS.add(snapshot),snapshot}const DEFAULT_CAPABILITIES=ownCapabilitySnapshot(["files"]),MAX_ATTACHMENT_CAPABILITIES=4,ATTACHMENT_CAPABILITY_SCAN_LIMIT=64;function normalizeCapabilities(value){try{if(!Array.isArray(value))return DEFAULT_CAPABILITIES;if(OWNED_CAPABILITY_SNAPSHOTS.has(value))return value;const normalized=[],length=Math.min(value.length,ATTACHMENT_CAPABILITY_SCAN_LIMIT);for(let index=0;index<length&&normalized.length<MAX_ATTACHMENT_CAPABILITIES;index++){const candidate=value[index];typeof candidate=="string"&&Object.prototype.hasOwnProperty.call(CAPABILITY_META,candidate)&&!normalized.includes(candidate)&&normalized.push(candidate)}return ownCapabilitySnapshot(normalized)}catch{return DEFAULT_CAPABILITIES}}function isCanonicalCapabilitySnapshot(source){try{return typeof source=="object"&&source!==null&&OWNED_CAPABILITY_SNAPSHOTS.has(source)}catch{return!1}}class LyraAttachmentTrigger extends LyraElement{constructor(){super(...arguments),this.capabilities=DEFAULT_CAPABILITIES,this.accept="",this.hostAccessibleLabel=null,this.multiple=!1,this.disabled=!1,this.appearance="plain",this.size="m",this.descriptionSyncGeneration=0,this.hasSyncedDescribedByElements=!1,this.pendingCapability="files",this.pickerGeneration=0,this.pendingPickerGeneration=-1,this.onTriggerClick=()=>{const capability=this.effectiveCapabilities[0];capability!==void 0&&this.activateCapability(capability)},this.onMenuSelect=e=>{e.stopPropagation();const capability=e.detail.item.value;Object.prototype.hasOwnProperty.call(CAPABILITY_META,capability)&&this.effectiveCapabilities.includes(capability)&&this.activateCapability(capability)},this.onInputChange=e=>{e.stopPropagation();const input=e.target,selected=input.files,generation=this.pendingPickerGeneration;if(this.pendingPickerGeneration=-1,this.isConnected&&generation===this.pickerGeneration&&!this.disabled&&selected&&selected.length>0){const accept=this.effectiveAccept(this.pendingCapability),files=Array.from(selected),matching=files.filter(file=>matchesAccept(file,accept)),matchingFiles=new Set(matching);this.emit("lr-files",{capability:this.pendingCapability,files:matching,rejected:files.filter(file=>!matchingFiles.has(file)).map(file=>({file,reason:"type"})),remainingFiles:null,remainingTotalSize:null})}input.value=""},this.onControlFocus=event=>{relayNativeEvent(this,event)},this.onControlBlur=event=>{relayNativeEvent(this,event)},this.stopInternalEvent=event=>{event.stopPropagation()}}static{this.defaultStrings={...super.defaultStrings,attachmentAdd:LYRA_DEFAULT_attachmentAdd,attachmentMenuAudio:LYRA_DEFAULT_attachmentMenuAudio,attachmentMenuCamera:LYRA_DEFAULT_attachmentMenuCamera,attachmentMenuFiles:LYRA_DEFAULT_attachmentMenuFiles,attachmentMenuImage:LYRA_DEFAULT_attachmentMenuImage,attachmentTriggerAudio:LYRA_DEFAULT_attachmentTriggerAudio,attachmentTriggerCamera:LYRA_DEFAULT_attachmentTriggerCamera,attachmentTriggerFiles:LYRA_DEFAULT_attachmentTriggerFiles,attachmentTriggerImage:LYRA_DEFAULT_attachmentTriggerImage,collapse:LYRA_DEFAULT_collapse,copy:LYRA_DEFAULT_copy,date:LYRA_DEFAULT_date,details:LYRA_DEFAULT_details,map:LYRA_DEFAULT_map,navigation:LYRA_DEFAULT_navigation,open:LYRA_DEFAULT_open,search:LYRA_DEFAULT_search,select:LYRA_DEFAULT_select}}static{this.collectionSupport=collectionSupport}static{this.ownedCollectionProperties=Object.freeze(["capabilities"])}static{this.styles=[LyraElement.styles,sizes,styles]}static{this.immutableEventDetails=Object.freeze(["lr-files"])}get triggerEl(){return this.composedTriggerEl?.control??this.composedTriggerEl}get effectiveCapabilities(){return normalizeCapabilities(this.capabilities)}get hasFileCapability(){return this.effectiveCapabilities.includes("files")||this.effectiveCapabilities.includes("image")||isCameraCapture(this.cameraCapture)&&this.effectiveCapabilities.includes("camera")}get captureSupported(){const view=this.ownerDocument.defaultView;return!!(view&&"capture"in view.HTMLInputElement.prototype)}willUpdate(changed){if(super.willUpdate(changed),changed.has("disabled")&&this.disabled&&this.dropdownEl?.hide(),changed.has("capabilities")){const normalized=normalizeCapabilities(this.capabilities);isCanonicalCapabilitySnapshot(this.capabilities)||(this.capabilities=normalized)}}updated(changed){super.updated(changed),this.syncTriggerDescription();const composed=this.composedTriggerEl;if(!composed||composed.control)return;const generation=++this.descriptionSyncGeneration;composed.updateComplete.then(()=>{generation!==this.descriptionSyncGeneration||!this.isConnected||this.syncTriggerDescription()})}syncTriggerDescription(){const hostDescribedBy=this.getAttribute("aria-describedby");!hostDescribedBy&&!this.hasSyncedDescribedByElements||(this.hasSyncedDescribedByElements=syncAriaDescribedByElements(this,this.triggerEl,hostDescribedBy))}effectiveAccept(capability){return capability==="camera"?"image/*":capability==="image"?this.accept||"image/*":this.accept}activateCapability(capability){if(this.disabled)return;const capture=this.cameraCapture;if(capability==="camera"&&!(isCameraCapture(capture)&&this.captureSupported)){this.emit("lr-camera-request",null);return}if(capability==="audio"){this.emit("lr-audio-request",null);return}this.pendingCapability=capability,this.pendingPickerGeneration=++this.pickerGeneration;const input=this.inputEl;input&&(input.accept=this.effectiveAccept(capability),capability==="camera"&&isCameraCapture(capture)?input.setAttribute("capture",capture):input.removeAttribute("capture"),input.click())}disconnectedCallback(){this.pendingPickerGeneration=-1,this.pickerGeneration++,this.dropdownEl?.hide(),super.disconnectedCallback()}primaryControl(){return this.renderRoot?.querySelector('[part="trigger"], [part="menu-trigger"]')??void 0}focus(options){this.primaryControl()?.focus(options)}blur(){this.primaryControl()?.blur()}click(){this.primaryControl()?.click()}renderHiddenInput(){return html`
|
|
29
29
|
<input
|
|
30
30
|
part="hidden-input"
|
|
31
31
|
type="file"
|
|
@@ -84,4 +84,4 @@ import{__decorate}from"tslib";import{collectionSupport}from"../../../internal/co
|
|
|
84
84
|
${single?this.renderSingleTrigger(capabilities[0]):nothing}
|
|
85
85
|
${multi?this.renderMenu():nothing}
|
|
86
86
|
${this.hasFileCapability?this.renderHiddenInput():nothing}
|
|
87
|
-
`}}__decorate([property({attribute:!1})],LyraAttachmentTrigger.prototype,"capabilities",void 0),__decorate([property()],LyraAttachmentTrigger.prototype,"accept",void 0),__decorate([property({attribute:"aria-label"})],LyraAttachmentTrigger.prototype,"hostAccessibleLabel",void 0),__decorate([property({attribute:"trigger-title"})],LyraAttachmentTrigger.prototype,"triggerTitle",void 0),__decorate([property({type:Boolean,reflect:!0,converter:falseDefaultBooleanConverter})],LyraAttachmentTrigger.prototype,"multiple",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraAttachmentTrigger.prototype,"disabled",void 0),__decorate([property({reflect:!0})],LyraAttachmentTrigger.prototype,"appearance",void 0),__decorate([property({reflect:!0})],LyraAttachmentTrigger.prototype,"size",void 0),__decorate([query('input[type="file"]')],LyraAttachmentTrigger.prototype,"inputEl",void 0),__decorate([query("lr-dropdown")],LyraAttachmentTrigger.prototype,"dropdownEl",void 0),__decorate([query('[part="trigger"], [part="menu-trigger"]')],LyraAttachmentTrigger.prototype,"composedTriggerEl",void 0);export{LyraAttachmentTrigger};
|
|
87
|
+
`}}__decorate([property({attribute:!1})],LyraAttachmentTrigger.prototype,"capabilities",void 0),__decorate([property()],LyraAttachmentTrigger.prototype,"accept",void 0),__decorate([property({attribute:"aria-label"})],LyraAttachmentTrigger.prototype,"hostAccessibleLabel",void 0),__decorate([property({attribute:"trigger-title"})],LyraAttachmentTrigger.prototype,"triggerTitle",void 0),__decorate([property({attribute:"camera-capture"})],LyraAttachmentTrigger.prototype,"cameraCapture",void 0),__decorate([property({type:Boolean,reflect:!0,converter:falseDefaultBooleanConverter})],LyraAttachmentTrigger.prototype,"multiple",void 0),__decorate([property({type:Boolean,reflect:!0})],LyraAttachmentTrigger.prototype,"disabled",void 0),__decorate([property({reflect:!0})],LyraAttachmentTrigger.prototype,"appearance",void 0),__decorate([property({reflect:!0})],LyraAttachmentTrigger.prototype,"size",void 0),__decorate([query('input[type="file"]')],LyraAttachmentTrigger.prototype,"inputEl",void 0),__decorate([query("lr-dropdown")],LyraAttachmentTrigger.prototype,"dropdownEl",void 0),__decorate([query('[part="trigger"], [part="menu-trigger"]')],LyraAttachmentTrigger.prototype,"composedTriggerEl",void 0);export{LyraAttachmentTrigger};
|
|
@@ -20,13 +20,22 @@ export interface LyraDropZoneFilesEvent extends CustomEvent<LyraDropZoneFilesDet
|
|
|
20
20
|
* selected-file list, or any focusable control of its own; wrap `lr-file-input` itself (or any
|
|
21
21
|
* other focusable content) inside it when the region also needs a click-to-browse affordance.
|
|
22
22
|
*
|
|
23
|
+
* **Targeting an existing region.** Instead of wrapping, the zone can sit beside a region that is
|
|
24
|
+
* already in the page: set `for` to the region's id (resolved in the zone's own root, like a
|
|
25
|
+
* label's `for`) or `target` to the element itself. The zone then attaches its drag listeners to
|
|
26
|
+
* that element, lays its overlay over the element's box, adds no box of its own (`display:
|
|
27
|
+
* contents`) and still emits `lr-files` from itself. Static markup keeps its layout tree, and the
|
|
28
|
+
* definition can load after first paint. A `for` id that matches nothing binds nothing and is
|
|
29
|
+
* re-resolved when the root's elements or ids change.
|
|
30
|
+
*
|
|
23
31
|
* The drag-session mechanics (nested-depth tracking, accept/reject preview, legacy File System API
|
|
24
32
|
* folder traversal) are the exact ones `lr-file-input` uses, shared through
|
|
25
33
|
* `internal/drop-session-controller.ts` rather than reimplemented here.
|
|
26
34
|
*
|
|
27
35
|
* @customElement lr-drop-zone
|
|
28
36
|
* @slot - The wrapped region. Rendered as ordinary light DOM content; this element adds only the
|
|
29
|
-
* drag listeners and the overlay layered on top.
|
|
37
|
+
* drag listeners and the overlay layered on top. Not a drop target while `for`/`target` resolves to
|
|
38
|
+
* an element.
|
|
30
39
|
* @slot overlay - Custom drag-over overlay content, overriding the localized accept/reject text.
|
|
31
40
|
* @event lr-files - Frozen `detail: { files, rejected, remainingFiles, remainingTotalSize }` with
|
|
32
41
|
* detached readonly sequences and rejected-file records, fired on drop.
|
|
@@ -35,8 +44,8 @@ export interface LyraDropZoneFilesEvent extends CustomEvent<LyraDropZoneFilesDet
|
|
|
35
44
|
* identity. Typed as {@linkcode LyraDropZoneFilesEvent}, so
|
|
36
45
|
* `event.target`/`event.currentTarget` are `LyraDropZone` without a cast.
|
|
37
46
|
* @csspart base - The wrapping element wrapping the default slot and the overlay.
|
|
38
|
-
* @csspart overlay - The drag-over overlay, layered above the slotted content
|
|
39
|
-
* active drag session.
|
|
47
|
+
* @csspart overlay - The drag-over overlay, layered above the slotted content (or, while targeting,
|
|
48
|
+
* fixed over the target's box). Hidden outside an active drag session.
|
|
40
49
|
* @csspart overlay-icon - The default decorative overlay icon.
|
|
41
50
|
* @csspart overlay-text - Wrapper around the overlay slot/text content.
|
|
42
51
|
* @csspart status - The visually-hidden, `aria-hidden` mirror of the drag accept/reject state and
|
|
@@ -46,6 +55,7 @@ export interface LyraDropZoneFilesEvent extends CustomEvent<LyraDropZoneFilesDet
|
|
|
46
55
|
* @csspart rejection - The visible region listing each currently-rejected file alongside its
|
|
47
56
|
* reason, rendered in addition to the sr-only `status` summary.
|
|
48
57
|
* @cssstate dragging - Matches during an active file drag session.
|
|
58
|
+
* @cssstate targeted - Matches while `for`/`target` resolves to an element the zone is attached to.
|
|
49
59
|
* @cssprop [--lr-drop-zone-radius=var(--lr-radius)] - Corner radius of `[part="overlay"]`.
|
|
50
60
|
* @cssprop [--lr-drop-zone-overlay-border-color=var(--lr-color-brand)] - Dashed border color of
|
|
51
61
|
* `[part="overlay"]` in its neutral drag state, before an accept or reject verdict.
|
|
@@ -113,7 +123,15 @@ heldTotalSize:number;
|
|
|
113
123
|
/** Density tier for the overlay's padding, icon and instructional text -- identical contract and
|
|
114
124
|
* scale to `lr-file-input`'s own `size`, so a small-tier drop-zone can match a neighboring
|
|
115
125
|
* small-tier `lr-file-input` in the same dense layout. */
|
|
116
|
-
size:LyraSize;
|
|
126
|
+
size:LyraSize;
|
|
127
|
+
/** Id of an existing element, in this zone's own root, to attach to instead of the default slot:
|
|
128
|
+
* the zone handles drags over that element and lays its overlay over it, so a server-rendered
|
|
129
|
+
* region becomes a drop target without being wrapped. An id that matches nothing binds nothing;
|
|
130
|
+
* it is re-resolved when elements or ids in the root change. `target` takes precedence. */
|
|
131
|
+
for:string;
|
|
132
|
+
/** An element to attach to directly, taking precedence over `for` while it is connected. Same
|
|
133
|
+
* behavior as `for`; property only. */
|
|
134
|
+
target:Element|null;private overlayEl?;private boundTarget?;private stopObservingRoot?;private dragState;private rejectedFiles;private resultStatus;private readonly internals;private readonly dropSession;private politeSink?;private assertiveSink?;private announcementsArmed;constructor();
|
|
117
135
|
/** Readonly state derived from the current drag session.
|
|
118
136
|
* @default false */
|
|
119
|
-
get dragging():boolean;protected willUpdate(changed:PropertyValues<this>):void;connectedCallback():void;disconnectedCallback():void;protected updated(changed:PropertyValues):void;private classify;private rejectionMessage;private emitFiles;private onDragEnter;private onDragOver;private onDragLeave;private onDrop;private overlayText;private statusText;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-drop-zone':LyraDropZone;}}
|
|
137
|
+
get dragging():boolean;protected willUpdate(changed:PropertyValues<this>):void;private resolveTarget;private syncTarget;private observeRoot;private positionTargetOverlay;connectedCallback():void;disconnectedCallback():void;protected updated(changed:PropertyValues):void;private classify;private rejectionMessage;private emitFiles;private onDragEnter;private onDragOver;private onDragLeave;private onDrop;private onTargetDragEnter;private onTargetDragOver;private onTargetDragLeave;private onTargetDrop;private handleDropEvent;private overlayText;private statusText;render():TemplateResult;}declare global{interface HTMLElementTagNameMap{'lr-drop-zone':LyraDropZone;}}
|