@aceshooting/lyra-ui 30.8.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 +239 -329
- 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-loader.js +1 -1
- package/dist/components/charts/chart/box-plot.class.js +2 -2
- package/dist/components/charts/chart/chart-core-loader.js +1 -1
- package/dist/components/charts/chart/chart-feature-loader.js +1 -1
- 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/charts/chart-3d/chart-3d-engine.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/code-block/code-loader.js +1 -1
- package/dist/components/conversation/code-block/shiki-oniguruma.js +1 -1
- package/dist/components/conversation/code-block/shiki-types.js +1 -1
- package/dist/components/conversation/markdown/katex-loader.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-loader.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/emoji-picker/emoji-data-loader.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-peer-bulk-standard.js +1 -1
- package/dist/components/media/flag/flag-peer-bulk.js +1 -1
- package/dist/components/media/flag/flag-peer.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-feature-loader.js +1 -1
- package/dist/components/media/map/map-loader.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/qr-code/qr-code-loader.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-engine-adapter.js +1 -1
- package/dist/components/retrieval/graph/graph-loader.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/icon/dompurify-loader.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-loader.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-loader.js +1 -1
- package/dist/components/viewers/docx-viewer/docx-viewer.class.js +1 -1
- package/dist/components/viewers/ebook-viewer/ebook-loader.js +1 -1
- package/dist/components/viewers/ebook-viewer/ebook-viewer.class.js +1 -1
- package/dist/components/viewers/ebook-viewer/epub-unload-guard.js +1 -0
- package/dist/components/viewers/email-viewer/email-loader.js +1 -1
- package/dist/components/viewers/html-viewer/dompurify-loader.js +1 -1
- package/dist/components/viewers/include/include.class.js +1 -1
- package/dist/components/viewers/model-viewer/model-viewer-loader.js +1 -1
- package/dist/components/viewers/model-viewer/model-viewer.class.js +1 -1
- package/dist/components/viewers/notebook-viewer/dompurify-loader.js +1 -1
- package/dist/components/viewers/notebook-viewer/notebook-viewer.class.js +1 -1
- package/dist/components/viewers/pdf-viewer/pdf-loader.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/pptx-viewer/pptx-loader.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-loader.js +1 -1
- package/dist/components/viewers/spreadsheet-viewer/spreadsheet-viewer.class.js +1 -1
- package/dist/components/viewers/svg-viewer/dompurify-loader.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/dompurify-loader.js +1 -1
- 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/locale-loaders.generated.js +1 -1
- package/dist/internal/map-custom-layer-controller.js +1 -1
- package/dist/internal/map-scene-layer-runtime.js +1 -1
- package/dist/internal/media-panorama.js +1 -1
- package/dist/internal/package-metadata.js +1 -1
- package/dist/internal/papaparse-loader.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/dist/theme-core.css +1 -0
- package/dist/utilities/scoped-registry.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/ai-and-peers.md +34 -0
- package/llms/shared/forms-and-accessibility.md +21 -4
- package/llms/shared/imports-and-registration.md +2 -0
- package/llms/shared/styles-and-tokens.md +47 -1
- package/llms/shared.md +104 -5
- package/package.json +25 -21
- package/registrations.json +1 -1
|
@@ -13,10 +13,10 @@ import{SourceRequestController,sourceCount,sourceRevision}from"../../internal/so
|
|
|
13
13
|
>
|
|
14
14
|
${text}
|
|
15
15
|
</button>
|
|
16
|
-
</div>`}columnWindow(key,count,limit=count){if(this.geometryWidth===void 0){const view=this.host.ownerDocument.defaultView,token=view?.getComputedStyle(this.host).getPropertyValue("--lr-size-8rem").trim()||"8rem";if(this.geometryWidth=Math.max(1,resolveCssTokenLength(token,{host:this.host})??1),this.hooks.pageScroll?.()&&view){const rect=this.host.getBoundingClientRect(),leading=view.getComputedStyle(this.host).direction==="rtl"?view.innerWidth-rect.right:rect.left;this.geometryAllocation=Math.max(0,view.innerWidth-Math.max(0,leading)),this.pageOffset=Math.max(0,-leading)}else this.geometryAllocation=this.host.clientWidth}const width=this.geometryWidth,allocation=this.geometryAllocation??0;let window=this.windows.get(key);const offset=this.hooks.pageScroll?.()?this.forcedPageOffset??this.pageOffset:window?.offset??0,start=Math.min(Math.max(0,count-1),Math.max(0,Math.floor(offset/width)-2)),end=Math.min(count,start+Math.max(1,limit),Math.max(start+1,Math.ceil((offset+allocation)/width)+4));return(!window||window.count!==count||window.width!==width||window.start!==start||window.end!==end)&&(window={start,end,count,width,offset,columns:Array.from({length:end-start},(_,index)=>start+index),style:`grid-template-columns:repeat(${count},minmax(var(--lr-size-8rem),1fr));min-inline-size:calc(${count} * var(--lr-size-8rem))`},this.windows.set(key,window)),window}scrollColumns(key,target){this.setColumnOffset(key,Math.abs(target.scrollLeft))}setColumnOffset(key,offset){const window=this.windows.get(key);if(!window||window.offset===offset)return;window.offset=offset;const previous=window.columns;this.columnWindow(key,window.count).columns!==previous&&this.hooks.repaint()}async showColumn(key,col,scroller){const window=this.windows.get(key);if(!(!window||!scroller)&&(col<window.start||col>=window.end)){const rtl=this.host.ownerDocument.defaultView?.getComputedStyle(this.host).direction==="rtl";scroller.scrollLeft=(rtl?-1:1)*col*window.width,this.hooks.pageScroll?.()?(this.forcedPageOffset=col*window.width,this.setColumnOffset(key,this.forcedPageOffset)):this.scrollColumns(key,scroller),await this.host.updateComplete}}rowRenderer(key,inputs,render){const dependencies=[...inputs,this.highlights,this.hooks.locale(),this.hooks.localize("highlightWithLabel"),this.hooks.localize("cellHighlightWithLabel")],existing=this.renderers.get(key);if(existing&&dependencies.length===existing.inputs.length&&dependencies.every((value,index)=>value===existing.inputs[index]))return existing.render;const rows=new Map,memo=(row,index)=>{const existing2=rows.get(index);if(existing2&&existing2.row===row)return existing2.result;const result=render(row,index);return rows.set(index,{row,result}),rows.size>256&&rows.delete(rows.keys().next().value),result};return this.renderers.set(key,{inputs:dependencies,render:memo}),memo}revealCell(target){return this.scroll.reveal(target),!!target}scrollColumnIntoView(root,selector,col){return this.scroll.scrollColumnIntoView(root.querySelector(selector),col)}async runSearch(query,loaded,scan,source=scan){this.search.query=query;const locale=this.hooks.locale();this.lastLocale=locale;const bounded=boundedViewerSearchQuery(query,locale),matches=[];let exact=bounded.accepted;if(loaded&&bounded.accepted&&bounded.needle){let corpus=this.searchCorpus;if(!corpus||corpus.source!==source||corpus.locale!==locale){const budget=new ViewerSearchWorkBudget,fields=[];scan((text,match)=>(fields.push({text:budget.prepare(text,locale),match}),budget.complete)),corpus={source,locale,fields,exact:budget.complete},this.searchCorpus=corpus}exact=corpus.exact;for(const field of corpus.fields)if(field.text?.includes(bounded.needle)){if(matches.length===MAX_TABLE_SEARCH_MATCHES){exact=!1;break}matches.push(field.match)}}return this.search.publish(matches,exact),matches.length>0&&await this.hooks.jump(matches[0]),matches.length}async step(direction){return this.search.step(direction)?await this.hooks.jump(this.search.matches[this.search.activeIndex])!==!1:!1}clearSearch(){this.activeRowKey="",this.search.clear()}}const TABLE_VIEWER_SOURCE_MESSAGE_KEYS={documentPreviewResourceTooLarge:"documentPreviewResourceTooLarge",documentPreviewFailedToLoad:"documentPreviewFailedToLoad",noData:"noData",loadingDocument:"loadingDocument",sourceSearchUnavailable:"sourceSearchUnavailable"};class TableViewerSourceController{constructor(host,chrome,hooks){this.host=host,this.chrome=chrome,this.hooks=hooks,this.locale="",this.limit=0,this.dirty=!0,this.bindingIntent=0,this.sheets=[],this.sheetIndex=0,this.rows=0,this.columns=0,this.slots=[],this.physicalReads=0,this.epoch=0,this.paint=0,this.firstRow=0,this.visibleRows=0,this.windowIntent=0,this.activeRow="",this.windowColumns=[],this.labels=[],this.columnStart=0,this.labelUnits=0,this.loaded=!1,this.pendingPaint=!1,this.sourceRows=this.makeRows(),this.searchRunning=!1,this.onRange=event=>{if(event.stopPropagation(),!this.loaded||event.currentTarget.source!==this.sourceRows)return;const start=Math.min(this.rows,event.detail.start),row=Math.max(0,start-6),visible=Math.max(0,Math.min(this.rows,event.detail.end)-start);row===this.firstRow&&visible===this.visibleRows||(this.visibleRows=visible,this.firstRow=row,this.requestWindow(),this.notify())},this.searchState=new ViewerSearchState(()=>[],detail=>hooks.emitSearch(detail),()=>hooks.repaint()),this.authority=new SourceRequestController(host,{channels:["cells0","cells1","search","reveal"],onReset:()=>this.reset()}),host.addController(this)}get enabled(){return this.hooks.source()!==void 0}get busy(){return this.enabled&&!this.failure&&this.slots.some(slot=>slot.state!=="ready")}makeRows(){return{count:this.rows,itemAt:index=>index,keyAt:index=>index,indexOfKey:key=>typeof key=="number"&&Number.isSafeInteger(key)&&key>=0&&key<this.rows?key:-1}}notify(){if(this.pendingPaint)return;this.pendingPaint=!0;const document=this.host.ownerDocument;queueMicrotask(()=>{this.pendingPaint=!1,this.host.isConnected&&this.host.ownerDocument===document&&this.hooks.repaint()})}reset(){this.epoch++,this.dirty=!0;for(const slot of this.slots)slot.settle(!1);this.slots=[],this.windowColumns=[],this.labels=[],this.labelUnits=0,this.failure=void 0,this.loaded=!1,this.firstRow=0,this.visibleRows=0,this.paint++,this.queuedSearch=void 0,this.notify()}refresh(){this.bindingIntent++,this.hooks.cancelAnchor(),this.authority.refresh()}hostConnected(){this.dirty=!0,this.notify()}hostDisconnected(){this.dirty=!0}adopted(){this.hooks.cancelAnchor(),this.authority.adopted()}update(){const source=this.hooks.source(),intent=this.bindingIntent,locale=this.hooks.locale(),limit=this.hooks.columnLimit();if(!(source===this.bound&&this.failure&&!this.dirty&&locale===this.locale&&limit===this.limit))try{const revision=source===void 0?void 0:sourceRevision(source.revision);if(source===this.bound&&revision===this.revision&&locale===this.locale&&limit===this.limit&&!this.dirty||source!==this.hooks.source()||intent!==this.bindingIntent||(source===this.bound&&(revision!==this.revision||locale!==this.locale||limit!==this.limit)&&this.hooks.cancelAnchor(),this.authority.setSource(source,revision),source!==this.hooks.source()||intent!==this.bindingIntent))return;source===this.bound&&revision===this.revision&&(locale!==this.locale||limit!==this.limit)&&this.authority.refresh();const epoch=this.epoch;if(this.bound=source,this.revision=revision,this.locale=locale,this.limit=limit,this.dirty=!1,this.failure=void 0,this.sheetIndex=0,this.firstRow=0,this.activeRow="",this.searchState.dirty&&this.searchState.clear(),source===void 0){this.theme&&(this.theme.hostDisconnected(),this.host.removeController(this.theme),this.theme=void 0),this.sheets=[],this.sheet=void 0;return}this.theme??=new ThemeWatcher(this.host,()=>this.notify());let sheets;if(this.hooks.workbook){const raw=source.sheets;if(!Array.isArray(raw)||raw.length>256)throw new LyraResourceLimitError;const keys=new Set,names=new Set;sheets=raw.map(entry=>{if(!entry||typeof entry.key!="string"||!entry.key||typeof entry.name!="string"||!entry.name||keys.has(entry.key)||names.has(entry.name))throw new TypeError("Invalid source sheet");if(entry.key.length>65536||entry.name.length>65536)throw new LyraResourceLimitError;return keys.add(entry.key),names.add(entry.name),Object.freeze({key:entry.key,name:entry.name,data:entry.data})})}else sheets=[{key:"",name:"",data:source}];if(!this.current(epoch))return;this.sheets=Object.freeze(sheets),this.selectSheet(0)}catch(error){if(this.hooks.source()!==source)return;this.bound=source,this.locale=locale,this.limit=limit,this.dirty=!1,this.fail(error)}}current(epoch){return epoch===this.epoch&&this.hooks.source()===this.bound&&this.host.isConnected}fail(error){this.failure!==error&&(this.failure=error,this.hooks.error(error),this.notify())}selectSheet(index){this.authority.invalidate("cells0"),this.authority.invalidate("cells1"),this.authority.invalidate("reveal");for(const slot of this.slots)slot.settle(!1);if(this.slots=[],this.windowColumns=[],this.labels=[],this.labelUnits=0,this.firstRow=0,this.visibleRows=0,this.activeRow="",this.sheetIndex=index,this.sheet=this.sheets[index],this.paint++,!this.sheet){this.rows=this.columns=0,this.sourceRows=this.makeRows();return}const data=this.sheet.data,epoch=this.epoch,revision=sourceRevision(data.revision),rows=sourceCount(data.rowCount),columns=sourceCount(data.columnCount);if(rows>=Number.MAX_SAFE_INTEGER||columns>this.limit)throw new LyraResourceLimitError;if(typeof data.columnAt!="function"||typeof data.cellAt=="function"==(typeof data.readCells=="function"))throw new TypeError("Invalid cell source");this.current(epoch)&&(this.sheetRevision=revision,this.rows=rows,this.columns=columns,this.sourceRows=this.makeRows(),this.loaded=!0,this.host.shadowRoot?.querySelector(tag("virtual-list"))?.scrollToIndex(0,{align:"start",behavior:"auto"}))}scalar(value){if(value!=null&&typeof value!="string"&&typeof value!="boolean"&&(typeof value!="number"||!Number.isFinite(value)))throw new TypeError("Invalid source cell");const text=this.hooks.format(value);if(text.length>65536)throw new LyraResourceLimitError;return text}prepareColumns(columns){if(this.windowColumns===columns||!this.sheet)return;const epoch=this.epoch,sheet=this.sheet,labels=[];let units=0;for(const index of columns){const column=sheet.data.columnAt(index);if(!this.current(epoch)||this.sheet!==sheet)return;if(!column||typeof column.key!="string"||!column.key||typeof column.label!="string")throw new TypeError("Invalid source column");if(column.key.length>65536||column.label.length>65536)throw new LyraResourceLimitError;if(units+=column.key.length+column.label.length,units>2e6)throw new LyraResourceLimitError;labels.push(Object.freeze({key:column.key,label:column.label}))}this.labels=labels,this.labelUnits=units,this.windowColumns=columns,this.columnStart=columns[0]??0,this.paint++,this.requestWindow()}requestWindow(){if(!this.sheet||!this.loaded||!this.windowColumns.length||!this.rows||this.failure)return;const epoch=this.epoch,intent=++this.windowIntent,maximum=Math.min(500,Math.floor(1e4/this.windowColumns.length)),first=Math.min(this.firstRow,this.rows-1),demand=Math.min(this.rows-first,this.visibleRows+12),block=Math.min(maximum,Math.max(64,demand));if(demand>maximum*2){this.fail(new LyraResourceLimitError);return}const aligned=Math.floor(first/block)*block,row=first-aligned+demand<=block*2?aligned:first,starts=row+block<this.rows?[row,row+block]:[row],keys=starts.map(start=>`${this.sheetIndex}:${start}:${block}:${this.columnStart}:${this.windowColumns.length}`),previous=this.slots;this.slots=previous.filter(slot=>keys.includes(slot.key));for(const slot of previous)if(!this.slots.includes(slot)&&(slot.settle(!1),this.authority.invalidate(slot.channel),!this.current(epoch)||intent!==this.windowIntent))return;for(let index=0;index<starts.length;index++){if(this.slots.some(slot2=>slot2.key===keys[index]))continue;const channel=this.slots.some(slot2=>slot2.channel==="cells0")?"cells1":"cells0",lease=this.authority.begin(channel,this.locale);if(!lease||!this.current(epoch)||intent!==this.windowIntent)return;let settle;const promise=new Promise(resolve=>{settle=resolve}),slot={key:keys[index],channel,row:starts[index],rows:Math.min(block,this.rows-starts[index]),column:this.columnStart,columns:this.windowColumns.length,lease,source:this.sheet.data,promise,settle,state:"queued",units:0};lease.context.signal.addEventListener("abort",()=>slot.settle(!1),{once:!0}),this.slots.push(slot)}this.paint++,queueMicrotask(()=>this.pump())}pump(){for(;this.physicalReads<2;){const slot=this.slots.find(value=>value.state==="queued"&&value.lease.isCurrent());if(!slot)return;slot.state="loading",this.physicalReads++,this.read(slot)}}async read(slot){try{const source=slot.source,result=source.readCells?await source.readCells(Object.freeze({...slot.lease.context,revision:this.sheetRevision,row:slot.row,rowCount:slot.rows,column:slot.column,columnCount:slot.columns})):void 0;if(!slot.lease.isCurrent()||!this.slots.includes(slot))return;if(result!==void 0&&(!Array.isArray(result)||result.length!==slot.rows))throw new TypeError("Invalid source rectangle");const values=[];let units=this.labelUnits+this.slots.reduce((sum,other)=>sum+(other===slot?0:other.units),0);const initialUnits=units;for(let row=0;row<slot.rows;row++){const input=result?.[row];if(result!==void 0&&(!Array.isArray(input)||input.length!==slot.columns))throw new TypeError("Invalid source rectangle row");const cells=[];for(let col=0;col<slot.columns;col++){const value=result!==void 0?input[col]:source.cellAt(slot.row+row,slot.column+col);if(!slot.lease.isCurrent()||!this.slots.includes(slot))return;const text=this.scalar(value);if(units+=text.length,units>2e6)throw new LyraResourceLimitError;cells.push(text)}values.push(cells)}slot.values=values,slot.units=units-initialUnits,slot.state="ready",slot.settle(!0),this.paint++,this.notify()}catch(error){slot.lease.isCurrent()&&this.slots.includes(slot)&&this.fail(error),slot.settle(!1)}finally{this.physicalReads--,this.pump()}}scrollColumns(target){this.chrome.scrollColumns(this,target)}row(index,style,height){const slot=this.slots.find(value=>index>=value.row&&index<value.row+value.rows&&value.state==="ready"),rawRow=index+1+Number(this.hooks.header()),highlights=this.chrome.highlightsForRow(rawRow,this.hooks.workbook?this.sheet?.name:void 0);return html`<div part="data-row" role="presentation" aria-busy=${slot?"false":"true"} style=${`${style};height:${height}px;overflow:hidden`}>
|
|
16
|
+
</div>`}columnWindow(key,count,limit=count){if(this.geometryWidth===void 0){const view=this.host.ownerDocument.defaultView,token=view?.getComputedStyle(this.host).getPropertyValue("--lr-size-8rem").trim()||"8rem";if(this.geometryWidth=Math.max(1,resolveCssTokenLength(token,{host:this.host})??1),this.hooks.pageScroll?.()&&view){const rect=this.host.getBoundingClientRect(),leading=view.getComputedStyle(this.host).direction==="rtl"?view.innerWidth-rect.right:rect.left;this.geometryAllocation=Math.max(0,view.innerWidth-Math.max(0,leading)),this.pageOffset=Math.max(0,-leading)}else this.geometryAllocation=this.host.clientWidth}const width=this.geometryWidth,allocation=this.geometryAllocation??0;let window=this.windows.get(key);const offset=this.hooks.pageScroll?.()?this.forcedPageOffset??this.pageOffset:window?.offset??0,start=Math.min(Math.max(0,count-1),Math.max(0,Math.floor(offset/width)-2)),end=Math.min(count,start+Math.max(1,limit),Math.max(start+1,Math.ceil((offset+allocation)/width)+4));return(!window||window.count!==count||window.width!==width||window.start!==start||window.end!==end)&&(window={start,end,count,width,offset,columns:Array.from({length:end-start},(_,index)=>start+index),style:`grid-template-columns:repeat(${count},minmax(var(--lr-size-8rem),1fr));min-inline-size:calc(${count} * var(--lr-size-8rem))`},this.windows.set(key,window)),window}scrollColumns(key,target){this.setColumnOffset(key,Math.abs(target.scrollLeft))}setColumnOffset(key,offset){const window=this.windows.get(key);if(!window||window.offset===offset)return;window.offset=offset;const previous=window.columns;this.columnWindow(key,window.count).columns!==previous&&this.hooks.repaint()}async showColumn(key,col,scroller){const window=this.windows.get(key);if(!(!window||!scroller)&&(col<window.start||col>=window.end)){const rtl=this.host.ownerDocument.defaultView?.getComputedStyle(this.host).direction==="rtl";scroller.scrollLeft=(rtl?-1:1)*col*window.width,this.hooks.pageScroll?.()?(this.forcedPageOffset=col*window.width,this.setColumnOffset(key,this.forcedPageOffset)):this.scrollColumns(key,scroller),await this.host.updateComplete}}rowRenderer(key,inputs,render){const dependencies=[...inputs,this.highlights,this.hooks.locale(),this.hooks.localize("highlightWithLabel"),this.hooks.localize("cellHighlightWithLabel")],existing=this.renderers.get(key);if(existing&&dependencies.length===existing.inputs.length&&dependencies.every((value,index)=>value===existing.inputs[index]))return existing.render;const rows=new Map,memo=(row,index)=>{const existing2=rows.get(index);if(existing2&&existing2.row===row)return existing2.result;const result=render(row,index);return rows.set(index,{row,result}),rows.size>256&&rows.delete(rows.keys().next().value),result};return this.renderers.set(key,{inputs:dependencies,render:memo}),memo}revealCell(target){return this.scroll.reveal(target),!!target}scrollColumnIntoView(root,selector,col){return this.scroll.scrollColumnIntoView(root.querySelector(selector),col)}async runSearch(query,loaded,scan,source=scan){this.search.query=query;const locale=this.hooks.locale();this.lastLocale=locale;const bounded=boundedViewerSearchQuery(query,locale),matches=[];let exact=bounded.accepted;if(loaded&&bounded.accepted&&bounded.needle){let corpus=this.searchCorpus;if(!corpus||corpus.source!==source||corpus.locale!==locale){const budget=new ViewerSearchWorkBudget,fields=[];scan((text,match)=>(fields.push({text:budget.prepare(text,locale),match}),budget.complete)),corpus={source,locale,fields,exact:budget.complete},this.searchCorpus=corpus}exact=corpus.exact;for(const field of corpus.fields)if(field.text?.includes(bounded.needle)){if(matches.length===MAX_TABLE_SEARCH_MATCHES){exact=!1;break}matches.push(field.match)}}return this.search.publish(matches,exact)?(matches.length>0&&await this.hooks.jump(matches[0]),matches.length):0}async step(direction){return this.search.step(direction)?await this.hooks.jump(this.search.matches[this.search.activeIndex])!==!1:!1}clearSearch(){this.activeRowKey="",this.search.clear()}}const TABLE_VIEWER_SOURCE_MESSAGE_KEYS={documentPreviewResourceTooLarge:"documentPreviewResourceTooLarge",documentPreviewFailedToLoad:"documentPreviewFailedToLoad",noData:"noData",loadingDocument:"loadingDocument",sourceSearchUnavailable:"sourceSearchUnavailable"};class TableViewerSourceController{constructor(host,chrome,hooks){this.host=host,this.chrome=chrome,this.hooks=hooks,this.locale="",this.limit=0,this.dirty=!0,this.bindingIntent=0,this.sheetIntent=0,this.sheets=[],this.sheetIndex=0,this.rows=0,this.columns=0,this.slots=[],this.physicalReads=0,this.epoch=0,this.paint=0,this.firstRow=0,this.visibleRows=0,this.windowIntent=0,this.activeRow="",this.windowColumns=[],this.labels=[],this.columnStart=0,this.labelUnits=0,this.loaded=!1,this.pendingPaint=!1,this.sourceRows=this.makeRows(),this.searchRunning=!1,this.searchIntent=0,this.onRange=event=>{if(event.stopPropagation(),!this.loaded||event.currentTarget.source!==this.sourceRows)return;const start=Math.min(this.rows,event.detail.start),row=Math.max(0,start-6),visible=Math.max(0,Math.min(this.rows,event.detail.end)-start);row===this.firstRow&&visible===this.visibleRows||(this.visibleRows=visible,this.firstRow=row,this.requestWindow(),this.notify())},this.searchState=new ViewerSearchState(()=>[],detail=>hooks.emitSearch(detail),()=>hooks.repaint()),this.authority=new SourceRequestController(host,{channels:["cells0","cells1","search","reveal"],onReset:()=>this.reset()}),host.addController(this)}get enabled(){return this.hooks.source()!==void 0}get busy(){return this.enabled&&!this.failure&&this.slots.some(slot=>slot.state!=="ready")}makeRows(){return{count:this.rows,itemAt:index=>index,keyAt:index=>index,indexOfKey:key=>typeof key=="number"&&Number.isSafeInteger(key)&&key>=0&&key<this.rows?key:-1}}notify(){if(this.pendingPaint)return;this.pendingPaint=!0;const document=this.host.ownerDocument;queueMicrotask(()=>{this.pendingPaint=!1,this.host.isConnected&&this.host.ownerDocument===document&&this.hooks.repaint()})}reset(){this.epoch++,this.searchIntent++,this.dirty=!0;for(const slot of this.slots)slot.settle(!1);this.slots=[],this.windowColumns=[],this.labels=[],this.labelUnits=0,this.failure=void 0,this.loaded=!1,this.firstRow=0,this.visibleRows=0,this.paint++,this.queuedSearch=void 0,this.notify()}refresh(){this.bindingIntent++,this.hooks.cancelAnchor(),this.authority.refresh()}hostConnected(){this.dirty=!0,this.notify()}hostDisconnected(){this.dirty=!0}adopted(){this.hooks.cancelAnchor(),this.authority.adopted()}update(){const source=this.hooks.source(),intent=this.bindingIntent,locale=this.hooks.locale(),limit=this.hooks.columnLimit();if(!(source===this.bound&&this.failure&&!this.dirty&&locale===this.locale&&limit===this.limit))try{const revision=source===void 0?void 0:sourceRevision(source.revision);if(source===this.bound&&revision===this.revision&&locale===this.locale&&limit===this.limit&&!this.dirty||source!==this.hooks.source()||intent!==this.bindingIntent||(source===this.bound&&(revision!==this.revision||locale!==this.locale||limit!==this.limit)&&this.hooks.cancelAnchor(),this.authority.setSource(source,revision),source!==this.hooks.source()||intent!==this.bindingIntent))return;source===this.bound&&revision===this.revision&&(locale!==this.locale||limit!==this.limit)&&this.authority.refresh();const epoch=this.epoch;if(this.bound=source,this.revision=revision,this.locale=locale,this.limit=limit,this.dirty=!1,this.failure=void 0,this.sheetIndex=0,this.firstRow=0,this.activeRow="",this.searchState.dirty&&this.searchState.clear(),source===void 0){this.theme&&(this.theme.hostDisconnected(),this.host.removeController(this.theme),this.theme=void 0),this.sheets=[],this.sheet=void 0;return}this.theme??=new ThemeWatcher(this.host,()=>this.notify());let sheets;if(this.hooks.workbook){const raw=source.sheets;if(!Array.isArray(raw)||raw.length>256)throw new LyraResourceLimitError;const keys=new Set,names=new Set;sheets=raw.map(entry=>{if(!entry||typeof entry.key!="string"||!entry.key||typeof entry.name!="string"||!entry.name||keys.has(entry.key)||names.has(entry.name))throw new TypeError("Invalid source sheet");if(entry.key.length>65536||entry.name.length>65536)throw new LyraResourceLimitError;return keys.add(entry.key),names.add(entry.name),Object.freeze({key:entry.key,name:entry.name,data:entry.data})})}else sheets=[{key:"",name:"",data:source}];if(!this.current(epoch))return;this.sheets=Object.freeze(sheets),this.selectSheet(0)}catch(error){if(this.hooks.source()!==source)return;this.bound=source,this.locale=locale,this.limit=limit,this.dirty=!1,this.fail(error)}}current(epoch){return epoch===this.epoch&&this.hooks.source()===this.bound&&this.host.isConnected}fail(error){this.failure!==error&&(this.failure=error,this.hooks.error(error),this.notify())}selectSheet(index){const intent=++this.sheetIntent,epoch=this.epoch,current=()=>intent===this.sheetIntent&&this.current(epoch);for(const channel of["cells0","cells1","reveal"])if(this.authority.invalidate(channel),!current())return!1;for(const slot of this.slots)slot.settle(!1);if(this.slots=[],this.windowColumns=[],this.labels=[],this.labelUnits=0,this.firstRow=0,this.visibleRows=0,this.activeRow="",this.sheetIndex=index,this.sheet=this.sheets[index],this.paint++,!this.sheet)return this.rows=this.columns=0,this.sourceRows=this.makeRows(),!0;const data=this.sheet.data;try{const revision=sourceRevision(data.revision);if(!current())return!1;const rows=sourceCount(data.rowCount);if(!current())return!1;const columns=sourceCount(data.columnCount);if(!current())return!1;if(rows>=Number.MAX_SAFE_INTEGER||columns>this.limit)throw new LyraResourceLimitError;const columnAt=data.columnAt;if(!current())return!1;const cellAt=data.cellAt;if(!current())return!1;const readCells=data.readCells;if(!current())return!1;if(typeof columnAt!="function"||typeof cellAt=="function"==(typeof readCells=="function"))throw new TypeError("Invalid cell source");return this.sheetRevision=revision,this.rows=rows,this.columns=columns,this.sourceRows=this.makeRows(),this.loaded=!0,this.host.shadowRoot?.querySelector(tag("virtual-list"))?.scrollToIndex(0,{align:"start",behavior:"auto"}),current()}catch(error){if(current())throw error;return!1}}scalar(value){if(value!=null&&typeof value!="string"&&typeof value!="boolean"&&(typeof value!="number"||!Number.isFinite(value)))throw new TypeError("Invalid source cell");const text=this.hooks.format(value);if(text.length>65536)throw new LyraResourceLimitError;return text}prepareColumns(columns){if(this.windowColumns===columns||!this.sheet)return;const epoch=this.epoch,sheet=this.sheet,intent=this.sheetIntent,current=()=>this.current(epoch)&&this.sheet===sheet&&this.sheetIntent===intent,labels=[];let units=0;for(const index of columns){const column=sheet.data.columnAt(index);if(!current())return;if(!column)throw new TypeError("Invalid source column");const key=column.key;if(!current())return;const label=column.label;if(!current())return;if(typeof key!="string"||!key||typeof label!="string")throw new TypeError("Invalid source column");if(key.length>65536||label.length>65536)throw new LyraResourceLimitError;if(units+=key.length+label.length,units>2e6)throw new LyraResourceLimitError;labels.push(Object.freeze({key,label}))}this.labels=labels,this.labelUnits=units,this.windowColumns=columns,this.columnStart=columns[0]??0,this.paint++,this.requestWindow()}requestWindow(){if(!this.sheet||!this.loaded||!this.windowColumns.length||!this.rows||this.failure)return;const epoch=this.epoch,intent=++this.windowIntent,maximum=Math.min(500,Math.floor(1e4/this.windowColumns.length)),first=Math.min(this.firstRow,this.rows-1),demand=Math.min(this.rows-first,this.visibleRows+12),block=Math.min(maximum,Math.max(64,demand));if(demand>maximum*2){this.fail(new LyraResourceLimitError);return}const aligned=Math.floor(first/block)*block,row=first-aligned+demand<=block*2?aligned:first,starts=row+block<this.rows?[row,row+block]:[row],keys=starts.map(start=>`${this.sheetIndex}:${start}:${block}:${this.columnStart}:${this.windowColumns.length}`),previous=this.slots;this.slots=previous.filter(slot=>keys.includes(slot.key));for(const slot of previous)if(!this.slots.includes(slot)&&(slot.settle(!1),this.authority.invalidate(slot.channel),!this.current(epoch)||intent!==this.windowIntent))return;for(let index=0;index<starts.length;index++){if(this.slots.some(slot2=>slot2.key===keys[index]))continue;const channel=this.slots.some(slot2=>slot2.channel==="cells0")?"cells1":"cells0",lease=this.authority.begin(channel,this.locale);if(!lease||!this.current(epoch)||intent!==this.windowIntent)return;let settle;const promise=new Promise(resolve=>{settle=resolve}),slot={key:keys[index],channel,row:starts[index],rows:Math.min(block,this.rows-starts[index]),column:this.columnStart,columns:this.windowColumns.length,lease,source:this.sheet.data,promise,settle,state:"queued",units:0};lease.context.signal.addEventListener("abort",()=>slot.settle(!1),{once:!0}),this.slots.push(slot)}this.paint++,queueMicrotask(()=>this.pump())}pump(){for(;this.physicalReads<2;){const slot=this.slots.find(value=>value.state==="queued"&&value.lease.isCurrent());if(!slot)return;slot.state="loading",this.physicalReads++,this.read(slot)}}async read(slot){try{const source=slot.source,result=source.readCells?await source.readCells(Object.freeze({...slot.lease.context,revision:this.sheetRevision,row:slot.row,rowCount:slot.rows,column:slot.column,columnCount:slot.columns})):void 0;if(!slot.lease.isCurrent()||!this.slots.includes(slot))return;if(result!==void 0&&(!Array.isArray(result)||result.length!==slot.rows))throw new TypeError("Invalid source rectangle");const values=[];let units=this.labelUnits+this.slots.reduce((sum,other)=>sum+(other===slot?0:other.units),0);const initialUnits=units;for(let row=0;row<slot.rows;row++){const input=result?.[row];if(result!==void 0&&(!Array.isArray(input)||input.length!==slot.columns))throw new TypeError("Invalid source rectangle row");const cells=[];for(let col=0;col<slot.columns;col++){const value=result!==void 0?input[col]:source.cellAt(slot.row+row,slot.column+col);if(!slot.lease.isCurrent()||!this.slots.includes(slot))return;const text=this.scalar(value);if(units+=text.length,units>2e6)throw new LyraResourceLimitError;cells.push(text)}values.push(cells)}slot.values=values,slot.units=units-initialUnits,slot.state="ready",slot.settle(!0),this.paint++,this.notify()}catch(error){slot.lease.isCurrent()&&this.slots.includes(slot)&&this.fail(error),slot.settle(!1)}finally{this.physicalReads--,this.pump()}}scrollColumns(target){this.chrome.scrollColumns(this,target)}row(index,style,height){const slot=this.slots.find(value=>index>=value.row&&index<value.row+value.rows&&value.state==="ready"),rawRow=index+1+Number(this.hooks.header()),highlights=this.chrome.highlightsForRow(rawRow,this.hooks.workbook?this.sheet?.name:void 0);return html`<div part="data-row" role="presentation" aria-busy=${slot?"false":"true"} style=${`${style};height:${height}px;overflow:hidden`}>
|
|
17
17
|
${this.windowColumns.map((column,position)=>this.chrome.renderCell(slot?.values?.[index-slot.row]?.[position]??"",column,highlights,"cell","cell",this.hooks.colorVar,this.hooks.activeHighlight()))}
|
|
18
|
-
</div>`}render(){if(this.failure)return html`<div part="error">${this.hooks.localize(isResourceLimitError(this.failure)?"documentPreviewResourceTooLarge":"documentPreviewFailedToLoad")}</div>`;if(!this.loaded||!this.sheet||!this.columns)return html`<p class="empty-note">${this.hooks.localize("noData")}</p>`;
|
|
19
|
-
${this.hooks.workbook&&this.sheets.length>1?this.hooks.renderSheetTabs?.(this.sheets.map(sheet=>sheet.name),this.sheetIndex,index=>{if(Number.isInteger(index)&&index>=0&&index<this.sheets.length&&index!==this.sheetIndex)try{this.selectSheet(index)
|
|
18
|
+
</div>`}render(){if(this.failure)return html`<div part="error">${this.hooks.localize(isResourceLimitError(this.failure)?"documentPreviewResourceTooLarge":"documentPreviewFailedToLoad")}</div>`;if(!this.loaded||!this.sheet||!this.columns)return html`<p class="empty-note">${this.hooks.localize("noData")}</p>`;const epoch=this.epoch,intent=this.sheetIntent,current=()=>this.current(epoch)&&this.sheetIntent===intent;try{const window=this.chrome.columnWindow(this,this.columns,100);if(this.prepareColumns(window.columns),!current())return html``;if(this.failure)return html`<div part="error">${this.hooks.localize("documentPreviewFailedToLoad")}</div>`;const view=this.host.ownerDocument.defaultView,height=Math.max(1,resolveCssTokenLength(view?.getComputedStyle(this.host).getPropertyValue("--lr-size-3rem").trim()||"3rem",{host:this.host})??48),header=this.hooks.header(),search=this.hooks.workbook?this.bound.search:this.sheet.data.search;return html`
|
|
19
|
+
${this.hooks.workbook&&this.sheets.length>1?this.hooks.renderSheetTabs?.(this.sheets.map(sheet=>sheet.name),this.sheetIndex,index=>{if(Number.isInteger(index)&&index>=0&&index<this.sheets.length&&index!==this.sheetIndex){this.hooks.cancelAnchor();try{this.selectSheet(index)&&this.notify()}catch(error){this.fail(error)}}})??nothing:nothing}
|
|
20
20
|
${this.busy?html`<p part="spinner" class="empty-note">${this.hooks.localize("loadingDocument")}</p>`:nothing}
|
|
21
21
|
${typeof search!="function"?html`<p part="search-status" class="empty-note">${this.hooks.localize("sourceSearchUnavailable")}</p>`:nothing}
|
|
22
22
|
<div part=${this.hooks.headerPart==="header-cell"?"table":"sheet"} role="table" aria-label=${this.hooks.workbook?this.sheet.name:this.hooks.label(this.rows)} aria-rowcount=${this.rows+Number(header)} aria-colcount=${this.columns}
|
|
@@ -28,4 +28,4 @@ import{SourceRequestController,sourceCount,sourceRevision}from"../../internal/so
|
|
|
28
28
|
.scrollElement=${this.hooks.pageScroll?.()?view??void 0:void 0}
|
|
29
29
|
@lr-visible-range-change=${this.onRange} @lr-virtual-scroll=${event=>event.stopPropagation()} @lr-load-more=${event=>event.stopPropagation()}
|
|
30
30
|
></lr-virtual-list>
|
|
31
|
-
</div>`}catch(error){return this.fail(error),html`<div part="error">${this.hooks.localize(isResourceLimitError(error)?"documentPreviewResourceTooLarge":"documentPreviewFailedToLoad")}</div>`}}async revealAnchor(anchor){if(anchor.kind!=="cell-range")return!1;const range=parseCellRange(anchor.range);if(!range)return!1;const name=anchor.sheet??range.sheet;if(!this.hooks.workbook&&name)return!1;const index=name?this.sheets.findIndex(sheet=>sheet.name===name):this.sheetIndex;return this.reveal(index,range.startRow-Number(this.hooks.header()),range.startCol)}async reveal(sheetIndex,row,column){if(this.failure||sheetIndex<0||sheetIndex>=this.sheets.length)return!1;if(sheetIndex!==this.sheetIndex)try{this.selectSheet(sheetIndex)
|
|
31
|
+
</div>`}catch(error){return current()?(this.fail(error),html`<div part="error">${this.hooks.localize(isResourceLimitError(error)?"documentPreviewResourceTooLarge":"documentPreviewFailedToLoad")}</div>`):html``}}async revealAnchor(anchor){if(anchor.kind!=="cell-range")return!1;const range=parseCellRange(anchor.range);if(!range)return!1;const name=anchor.sheet??range.sheet;if(!this.hooks.workbook&&name)return!1;const index=name?this.sheets.findIndex(sheet=>sheet.name===name):this.sheetIndex;return this.reveal(index,range.startRow-Number(this.hooks.header()),range.startCol)}async reveal(sheetIndex,row,column){if(this.failure||sheetIndex<0||sheetIndex>=this.sheets.length)return!1;if(sheetIndex!==this.sheetIndex)try{if(!this.selectSheet(sheetIndex))return!1;this.notify()}catch(error){return this.fail(error),!1}if(!Number.isSafeInteger(row)||row<(this.hooks.header()?-1:0)||row>=this.rows||!Number.isSafeInteger(column)||column<0||column>=this.columns)return!1;const lease=this.authority.begin("reveal",this.locale);if(!lease||(await this.host.updateComplete,!lease.isCurrent())||(await this.chrome.showColumn(this,column,this.hooks.scrollContainer?.()??this.host.shadowRoot?.querySelector('[part="sheet"]')??null),!lease.isCurrent()))return!1;if(row<0)return this.chrome.revealCell(this.host.shadowRoot?.querySelector(`[part="header-row"] [aria-colindex="${column+1}"]`));const previousRow=this.firstRow,sheet=this.sheet,epoch=this.epoch;this.firstRow=row,this.activeRow=row,this.requestWindow(),this.notify();const abandon=()=>(this.firstRow===row&&this.sheet===sheet&&this.current(epoch)&&(this.firstRow=previousRow,this.requestWindow(),this.notify()),!1);if(await this.host.updateComplete,!lease.isCurrent())return abandon();const list=this.host.shadowRoot?.querySelector(tag("virtual-list"));if(!list)return abandon();if(list.scrollToIndex(row,{align:"start",behavior:"auto"}),await list.updateComplete,!lease.isCurrent())return!1;const slot=this.slots.find(value=>row>=value.row&&row<value.row+value.rows&&column>=value.column&&column<value.column+value.columns);if(!slot||!await slot.promise||!lease.isCurrent()||(await this.host.updateComplete,await list.updateComplete,!lease.isCurrent()))return!1;const target=list.shadowRoot?.querySelector(`[data-row-index="${row}"] [aria-colindex="${column+1}"]`);return this.chrome.revealCell(target)&&lease.isCurrent()}beginSearchChange(){const intent=++this.searchIntent;this.hooks.cancelAnchor();for(const channel of["search","reveal"]){if(intent!==this.searchIntent)return;this.authority.invalidate(channel)}return intent===this.searchIntent?intent:void 0}async search(query){const intent=this.beginSearchChange();if(intent===void 0)return 0;this.searchState.query=query;const bounded=boundedViewerSearchQuery(query,this.locale);if(!bounded.needle||!bounded.accepted)return this.searchState.publish([],bounded.accepted),0;const source=this.bound,search=this.hooks.workbook?source?.search:this.sheet?.data.search;if(intent!==this.searchIntent)return 0;if(!source||!search||this.failure)return this.searchState.publish([],!1),0;const lease=this.authority.begin("search",this.locale);return lease?new Promise(resolve=>{lease.context.signal.addEventListener("abort",()=>resolve(0),{once:!0});const run=async()=>{if(!lease.isCurrent()){resolve(0);return}this.searchRunning=!0;try{const result=await search.call(source,Object.freeze({...lease.context,query,limit:MAX_TABLE_SEARCH_MATCHES}));if(!lease.isCurrent())return;if(!result||!Array.isArray(result.hits)||result.hits.length>MAX_TABLE_SEARCH_MATCHES||typeof result.exhaustive!="boolean"||result.total!==null&&sourceCount(result.total)<result.hits.length)throw new TypeError("Invalid source search result");if(result.exhaustive&&result.total!==null&&result.total!==result.hits.length)throw new TypeError("Inconsistent source search total");let exact=result.exhaustive;const hits=[];for(const hit of result.hits){const index=this.hooks.workbook?this.sheets.findIndex(sheet=>sheet.key===hit.sheetKey):0;if(index<0||!Number.isSafeInteger(hit.row)||hit.row<-1||!Number.isSafeInteger(hit.column)||hit.column<0)throw new TypeError("Invalid source search hit");const data=this.sheets[index].data;if(hit.row>=sourceCount(data.rowCount)||hit.column>=sourceCount(data.columnCount)||hit.column>=this.limit)throw new TypeError("Source search hit is out of bounds");if(!lease.isCurrent())return;if(hit.row===-1&&!this.hooks.header()){exact=!1;continue}hits.push({sheetIndex:index,row:hit.row,col:hit.column})}if(!lease.isCurrent())return;if(!this.searchState.publish(hits,exact)||!lease.isCurrent()){resolve(0);return}hits.length&&await this.reveal(hits[0].sheetIndex,hits[0].row,hits[0].col),lease.isCurrent()&&resolve(hits.length)}catch(error){lease.isCurrent()&&(this.fail(error),this.searchState.publish([],!1),resolve(0))}finally{this.searchRunning=!1;const next=this.queuedSearch;this.queuedSearch=void 0,next&&next()}};this.searchRunning?this.queuedSearch=run:run()}):0}async step(direction){const intent=this.searchIntent;if(!this.searchState.step(direction)||intent!==this.searchIntent)return!1;const hit=this.searchState.matches[this.searchState.activeIndex];return this.reveal(hit.sheetIndex,hit.row,hit.col)}clearSearch(){this.beginSearchChange()!==void 0&&(this.activeRow="",this.searchState.clear(),this.notify())}}export{TABLE_VIEWER_SOURCE_MESSAGE_KEYS,TableViewerController,TableViewerScrollController,TableViewerSourceController,collectTableSearchMatches,tableHighlightsForColumn,tableHighlightsForRow};
|