@evotecit/canopyx 0.1.3 → 0.2.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/CanopyX.Html/Assets/canopyx-calendar-edit.js +113 -0
- package/CanopyX.Html/Assets/canopyx-calendar-ics.js +87 -0
- package/CanopyX.Html/Assets/canopyx-calendar-recurrence.js +36 -0
- package/CanopyX.Html/Assets/canopyx-calendar.css +279 -0
- package/CanopyX.Html/Assets/canopyx-calendar.js +307 -0
- package/CanopyX.Html/Assets/canopyx-cell-range.css +38 -0
- package/CanopyX.Html/Assets/canopyx-cell-range.js +141 -0
- package/CanopyX.Html/Assets/canopyx-column-groups.css +18 -0
- package/CanopyX.Html/Assets/canopyx-column-groups.js +51 -0
- package/CanopyX.Html/Assets/canopyx-data.js +14 -0
- package/CanopyX.Html/Assets/canopyx-detail-rows.css +18 -0
- package/CanopyX.Html/Assets/canopyx-detail-rows.js +51 -0
- package/CanopyX.Html/Assets/canopyx-editing.css +44 -0
- package/CanopyX.Html/Assets/canopyx-editing.js +134 -0
- package/CanopyX.Html/Assets/canopyx-enhance.js +126 -0
- package/CanopyX.Html/Assets/canopyx-export.js +18 -0
- package/CanopyX.Html/Assets/canopyx-facets.css +86 -0
- package/CanopyX.Html/Assets/canopyx-facets.js +65 -0
- package/CanopyX.Html/Assets/canopyx-filter-editor.css +15 -18
- package/CanopyX.Html/Assets/canopyx-filter-editor.js +23 -17
- package/CanopyX.Html/Assets/canopyx-format-editor.css +77 -0
- package/CanopyX.Html/Assets/canopyx-format-editor.js +30 -0
- package/CanopyX.Html/Assets/canopyx-formatting.css +40 -0
- package/CanopyX.Html/Assets/canopyx-formatting.js +101 -0
- package/CanopyX.Html/Assets/canopyx-grid-module.mjs +352 -246
- package/CanopyX.Html/Assets/canopyx-grid.css +139 -117
- package/CanopyX.Html/Assets/canopyx-grid.js +352 -246
- package/CanopyX.Html/Assets/canopyx-grouping.css +39 -0
- package/CanopyX.Html/Assets/canopyx-grouping.js +85 -0
- package/CanopyX.Html/Assets/canopyx-highlight.css +34 -0
- package/CanopyX.Html/Assets/canopyx-highlight.js +80 -0
- package/CanopyX.Html/Assets/canopyx-history.js +13 -0
- package/CanopyX.Html/Assets/canopyx-interactive.css +18 -6
- package/CanopyX.Html/Assets/canopyx-interactive.js +179 -100
- package/CanopyX.Html/Assets/canopyx-labels-de.js +304 -0
- package/CanopyX.Html/Assets/canopyx-labels-es.js +304 -0
- package/CanopyX.Html/Assets/canopyx-labels-fr.js +529 -0
- package/CanopyX.Html/Assets/canopyx-labels-it.js +529 -0
- package/CanopyX.Html/Assets/canopyx-labels-pl.js +304 -0
- package/CanopyX.Html/Assets/canopyx-layouts.css +48 -0
- package/CanopyX.Html/Assets/canopyx-layouts.js +39 -0
- package/CanopyX.Html/Assets/canopyx-link.css +19 -0
- package/CanopyX.Html/Assets/canopyx-link.js +38 -0
- package/CanopyX.Html/Assets/canopyx-links.js +14 -0
- package/CanopyX.Html/Assets/canopyx-live.css +24 -0
- package/CanopyX.Html/Assets/canopyx-live.js +88 -0
- package/CanopyX.Html/Assets/canopyx-module.mjs +180 -100
- package/CanopyX.Html/Assets/canopyx-pager.css +10 -0
- package/CanopyX.Html/Assets/canopyx-pager.js +14 -0
- package/CanopyX.Html/Assets/canopyx-record-panel.css +111 -0
- package/CanopyX.Html/Assets/canopyx-record-panel.js +178 -0
- package/CanopyX.Html/Assets/canopyx-reporting-module.mjs +406 -342
- package/CanopyX.Html/Assets/canopyx-reporting.css +140 -135
- package/CanopyX.Html/Assets/canopyx-reporting.js +406 -342
- package/CanopyX.Html/Assets/canopyx-search.js +32 -0
- package/CanopyX.Html/Assets/canopyx-timeline.css +80 -0
- package/CanopyX.Html/Assets/canopyx-timeline.js +88 -0
- package/CanopyX.Html/Assets/canopyx-tree-tools.css +103 -0
- package/CanopyX.Html/Assets/canopyx-tree-tools.js +92 -0
- package/CanopyX.Html/Assets/canopyx.css +17 -5
- package/CanopyX.Html/Assets/canopyx.js +175 -96
- package/JavaScript/calendar.d.ts +362 -0
- package/JavaScript/cell-ranges.d.ts +76 -0
- package/JavaScript/column-groups.d.ts +32 -0
- package/JavaScript/editing.d.ts +257 -0
- package/JavaScript/enhance.d.ts +202 -0
- package/JavaScript/facets.d.ts +58 -0
- package/JavaScript/formatting.d.ts +88 -0
- package/JavaScript/grid.d.ts +409 -56
- package/JavaScript/hosts.d.ts +177 -2
- package/JavaScript/index.d.ts +53 -4
- package/JavaScript/live.d.ts +115 -0
- package/JavaScript/locales/de.mjs +304 -0
- package/JavaScript/locales/es.mjs +304 -0
- package/JavaScript/locales/fr.d.ts +6 -0
- package/JavaScript/locales/fr.mjs +527 -0
- package/JavaScript/locales/it.d.ts +6 -0
- package/JavaScript/locales/it.mjs +527 -0
- package/JavaScript/locales/pl.mjs +304 -0
- package/JavaScript/plugins.d.ts +113 -0
- package/JavaScript/protocol.d.ts +139 -6
- package/JavaScript/records.d.ts +136 -0
- package/README.md +61 -9
- package/README.nuget.md +1 -1
- package/package.json +99 -3
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
(function(global){"use strict";const installed=new WeakSet();const part={version:"2fa02b9178c6c5df",install(context){if(installed.has(context.DataGrid.prototype))return;const{DataGrid,h,setText,fill,gridButton,gridIcon,gridQuery,gridResultShape,gridQueryRows,gridCompare,gridOrder,validateGridRows,validateGridPage,validateGridCursorPage,gridFreeze,requireIdentifier,checkDocument,cellValue,PROTOCOL,GRID_REPORTING,VIEW_MODES,inlineGridSource}=context;const LIVE_KEYS=new Set(["stableOrder","flash","batchMs","pollMs","load","announce","pauseWhenHidden"]);const LIVE_MAX_ROWS=100000;function liveOptions(view,options){const read=value=>{if(value===undefined||value===true||value===false)return{};if(!value||typeof value!=="object"||Array.isArray(value)||Object.keys(value).some(key=>!LIVE_KEYS.has(key)))
|
|
2
|
+
throw new Error("CanopyX: live takes stableOrder, flash, batchMs, pollMs, load, announce and pauseWhenHidden.");return value};const merged=options.live===false?{}:{...read(view.live),...read(options.live)},flash=merged.flash;const integer=(value,min,max)=>value===undefined||Number.isInteger(value)&&value>=min&&value<=max;if(["stableOrder","announce","pauseWhenHidden"].some(key=>merged[key]!==undefined&&typeof merged[key]!=="boolean")||
|
|
3
|
+
!(flash===undefined||typeof flash==="boolean"||flash&&typeof flash==="object"&&Object.keys(flash).every(key=>key==="durationMs")&&integer(flash.durationMs,100,10000))||
|
|
4
|
+
!integer(merged.batchMs,0,60000)||!(merged.pollMs===undefined||merged.pollMs===0||integer(merged.pollMs,250,86400000))||
|
|
5
|
+
merged.load!==undefined&&typeof merged.load!=="function")
|
|
6
|
+
throw new Error("CanopyX: invalid live options.");return{stableOrder:merged.stableOrder!==false,flashMs:flash?flash.durationMs||1200:0,batchMs:merged.batchMs||0,pollMs:merged.pollMs||0,load:merged.load||null,announce:merged.announce!==false,pauseWhenHidden:merged.pauseWhenHidden!==false}}
|
|
7
|
+
function liveTransaction(grid,input){if(input&&typeof input==="object"&&input.protocol!==undefined){checkDocument(input,"gridTransaction");if(input.view!==grid.view.id)throw new Error("CanopyX: the transaction is for another grid.")}
|
|
8
|
+
if(!input||typeof input!=="object"||Array.isArray(input)||Object.keys(input).some(key=>!["add","update","remove","protocol","type","view"].includes(key)))
|
|
9
|
+
throw new Error("CanopyX: a transaction is { add, update, remove }.");const list=name=>{const value=input[name];if(value!==undefined&&!Array.isArray(value))throw new Error("CanopyX: transaction "+name+" takes an array.");return value||[]};if(list("add").length+list("update").length+list("remove").length>LIVE_MAX_ROWS)throw new Error("CanopyX: a transaction changes at most "+LIVE_MAX_ROWS+" rows.");const add=list("add"),update=list("update");const remove=list("remove").map(item=>typeof item==="string"?item:item&&item.id);validateGridRows(add,grid.view.columns);const seen=new Set();for(const row of update){requireIdentifier(row&&row.id,"updated row ID");if(seen.has(row.id))throw new Error("CanopyX: duplicate updated row ID "+row.id);seen.add(row.id);if(row.cells!==undefined&&(!row.cells||typeof row.cells!=="object"||Array.isArray(row.cells))||row.fields!==undefined&&(!row.fields||typeof row.fields!=="object"||Array.isArray(row.fields)))
|
|
10
|
+
throw new Error("CanopyX: invalid updated row.");const cells={};for(const[id,cell]of Object.entries(row.cells||{}))if(cell!==null)cells[id]=cell;for(const id of Object.keys(row.cells||{}))if(!grid.view.columns.some(column=>column.id===id))throw new Error("CanopyX: undeclared grid column "+id);validateGridRows([{id:row.id,cells,tone:row.tone??undefined,className:row.className??undefined}],grid.view.columns)}
|
|
11
|
+
remove.forEach(id=>requireIdentifier(id,"removed row ID"));return{add:liveCopy(add),update:liveCopy(update),remove}}
|
|
12
|
+
function liveEnqueue(queue,change){for(const id of change.remove)queue.set(id,{kind:"remove",id});for(const row of change.add)queue.set(row.id,{kind:"add",id:row.id,row});for(const row of change.update){const queued=queue.get(row.id);if(queued?.kind==="remove")continue;if(!queued){queue.set(row.id,{kind:"update",id:row.id,row});continue}
|
|
13
|
+
const target=queued.row;Object.assign(target.cells||(target.cells={}),row.cells||{});for(const name of["tone","className","fields","detail"])if(row[name]!==undefined)target[name]=row[name]}
|
|
14
|
+
return queue}
|
|
15
|
+
const liveSame=(a,b)=>JSON.stringify(a??null)===JSON.stringify(b??null);function liveChangedColumns(before,after){if(!before)return "*";const columns=new Set();for(const id of new Set([...Object.keys(before.cells),...Object.keys(after.cells)]))
|
|
16
|
+
if(Object.hasOwn(before.cells,id)!==Object.hasOwn(after.cells,id)||!liveSame(before.cells[id],after.cells[id]))columns.add(id);return columns}
|
|
17
|
+
function liveSameRow(a,b){return["tone","className","fields","detail"].every(name=>liveSame(a[name],b[name]))&&!liveChangedColumns(a,b).size}
|
|
18
|
+
function liveDiff(rows,current){const add=[],keep=new Set();for(const row of rows){keep.add(row.id);const existing=current.get(row.id);if(!existing||!liveSameRow(existing,row))add.push(row)}
|
|
19
|
+
return{add,update:[],remove:[...current.keys()].filter(id=>!keep.has(id))}}
|
|
20
|
+
const liveCopy=value=>JSON.parse(JSON.stringify(value));function liveColumns(view){return new Map(view.columns.map(column=>[column.id,column]))}
|
|
21
|
+
function liveComparer(grid,query){const columns=liveColumns(grid.view),compare=GRID_REPORTING.compare?.(grid.view)||gridCompare;const sorts=query.sort.map(sort=>[columns.get(sort.column),sort.direction]);return(a,b)=>{for(const[column,direction]of sorts){const result=compare(a,b,column,direction);if(result)return result}
|
|
22
|
+
return gridOrder(a.id,b.id)}}
|
|
23
|
+
function liveMatcher(grid,query){const columns=liveColumns(grid.view),unsorted={...query,sort:[]};const view={columns:grid.view.columns,searchColumns:grid.view.searchColumns,rows:null};return row=>{view.rows=[row];return gridQueryRows(view,unsorted,columns,false).length===1}}
|
|
24
|
+
function liveIndexOrder(order){order.at=new Map();order.ids.forEach((id,index)=>order.at.set(id,index));return order}
|
|
25
|
+
Object.assign(DataGrid.prototype,{liveRows(){if(this.liveRowsOf!==this.view.rows){this.liveRowMap=new Map();for(const row of this.view.rows)this.liveRowMap.set(row.id,row);this.liveRowsOf=this.view.rows}
|
|
26
|
+
return this.liveRowMap},liveOrderOf(){const query=this.acceptedQuery,shape=gridResultShape(query);if(this.liveOrder?.shape!==shape||this.liveOrderSource!==this.source){const rows=gridQueryRows(this.view,query,liveColumns(this.view),GRID_REPORTING.compare?.(this.view)||gridCompare);this.liveOrder=liveIndexOrder({shape,ids:rows.map(row=>row.id),dirty:false});this.liveOrderSource=this.source}
|
|
27
|
+
return this.liveOrder},liveApplyRows(queue,ordered){const rows=this.liveRows(),query=this.acceptedQuery,stable=this.liveOpts.stableOrder;if(!ordered)this.liveOrder=null;const order=ordered?this.liveOrderOf():{at:new Map(),ids:[]};const matches=liveMatcher(this,query),compare=liveComparer(this,query);const result={added:[],updated:[],removed:[],missing:[]},changed=new Map(),leave=new Set(),enter=[],kept=[];for(const change of queue.values()){const before=rows.get(change.id);if(change.kind==="remove"){if(!before){result.missing.push(change.id);continue}
|
|
28
|
+
rows.delete(change.id);result.removed.push(change.id);if(order.at.has(change.id))leave.add(change.id);continue}
|
|
29
|
+
if(change.kind==="update"&&!before){result.missing.push(change.id);continue}
|
|
30
|
+
const after=change.kind==="add"?change.row:liveMerged(before,change.row);if(before&&liveSameRow(before,after))continue;rows.set(change.id,after);(before?result.updated:result.added).push(change.id);changed.set(change.id,liveChangedColumns(before,after));if(!ordered)continue;const was=order.at.has(change.id),now=matches(after);if(was&&!now)leave.add(change.id);else if(!was&&now)enter.push(after);else if(was&&now){if(stable)kept.push(change.id);else{leave.add(change.id);enter.push(after)}}}
|
|
31
|
+
if(!changed.size&&!result.removed.length)return{result,changed};if(!ordered){this.view.rows=this.liveRowsOf=[...rows.values()];return{result,changed}}
|
|
32
|
+
let dirty=order.dirty;const neighbour=(index,step)=>{for(let at=index+step;at>=0&&at<order.ids.length;at +=step)if(!leave.has(order.ids[at]))return rows.get(order.ids[at]);return null};for(const id of kept){if(dirty)break;const index=order.at.get(id),row=rows.get(id),previous=neighbour(index,-1),next=neighbour(index,1);dirty=!!(previous&&compare(previous,row)>0||next&&compare(row,next)>0)}
|
|
33
|
+
let ids=leave.size?order.ids.filter(id=>!leave.has(id)):order.ids;if(enter.length){enter.sort(compare);const merged=[];let i=0,j=0;while(i<ids.length&&j<enter.length)merged.push(compare(rows.get(ids[i]),enter[j])<=0?ids[i++]:enter[j++].id);while(i<ids.length)merged.push(ids[i++]);while(j<enter.length)merged.push(enter[j++].id);ids=merged}
|
|
34
|
+
this.liveOrder=liveIndexOrder({shape:order.shape,ids,dirty:stable&&dirty});this.view.rows=this.liveRowsOf=[...rows.values()];return{result,changed}}});function liveMerged(before,change){const after={...before,cells:{...before.cells}};Object.assign(after.cells,change.cells||{});for(const name of["tone","className","fields","detail"])if(change[name]!==undefined){if(change[name]===null)delete after[name];else after[name]=change[name]}
|
|
35
|
+
return after}
|
|
36
|
+
const LIVE_REQUEST=DataGrid.prototype.requestPage;DataGrid.prototype.requestPage=function(query,signal){const order=this.liveOrder;if(order&&this.liveOrderSource!==this.source)this.liveOrder=null;if(!this.liveOrder||!this.liveInline()||gridResultShape(query)!==order.shape)return LIVE_REQUEST.call(this,query,signal);const rows=this.liveRows(),items=order.ids.slice(query.offset,query.offset+query.limit).map(id=>rows.get(id));return Promise.resolve({protocol:PROTOCOL,type:"gridPage",view:this.view.id,revision:query.revision||"inline",offset:query.offset,total:rows.size,matched:order.ids.length,items})};Object.assign(DataGrid.prototype,{liveInline(){return this.view.source.kind==="inline"&&!this.opts.source},liveProjected(){const reporting=this.view.reporting;return!!(reporting&&(reporting.grouping||this.acceptedQuery?.groupBy?.length||reporting.aggregates?.length||reporting.detail)||this.opts.detail)},liveAnchor(){const top=this.logicalTop(),index=this.rowAt(top),row=this.rowCache.get(index);return{top,index,id:row&&!row.status?row.key:null,delta:top-this.rowTop(index)}},liveSwap(snapshot,pagesFor,positionOf,changed,removed,shifted=true){const hadFocus=this.canvas.contains(document.activeElement),anchor=this.liveAnchor(),old=new Map();const focused=this.focused,focusIndex=focused?focused._ri:-1,focusId=focused&&!focused.status?focused.key:null;for(const row of this.rowCache.values())old.set(row.key,row);const length=this.pageLength;if(this.paged&&!this.cursor&&this.pageOffset>0&&this.pageOffset>=snapshot.matched)
|
|
37
|
+
this.pageOffset=Math.max(0,Math.floor((snapshot.matched-1)/ length) * length);
|
|
38
|
+
const anchorIndex=anchor.id===null?-1:positionOf(anchor.id),newFocus=focusId===null?-1:positionOf(focusId);const pages=pagesFor(anchorIndex>=0?anchorIndex:anchor.index,newFocus);if(this.pendingPages.size||this.pendingNavigation){this.queryEpoch++;this.pendingPages.clear();this.pendingNavigation=null}
|
|
39
|
+
this.pages.clear();this.rowCache.clear();this.placeholders.clear();this.snapshot={revision:snapshot.revision,total:snapshot.total,matched:snapshot.matched};const heights=this.autoRows?new Map():null;for(const[offset,items]of[...pages].sort((a,b)=>a[0]- b[0])){items.forEach((item,index)=>{const row=old.get(item.id);if(!row)return;if(heights&&this.rowHeights.has(row._ri))heights.set(offset+index,this.rowHeights.get(row._ri));row.h=item;row._ri=offset+index;row.hpx=this.rowH;this.rowCache.set(row._ri,row)});this.storePage({protocol:PROTOCOL,type:"gridPage",view:this.view.id,revision:snapshot.revision,offset,items})}
|
|
40
|
+
const accepted=this.acceptedQuery,offset=this.paged&&!this.cursor?this.pageOffset:accepted.offset;if(accepted.revision!==snapshot.revision||accepted.offset!==offset)this.acceptedQuery=gridQuery(this.view,{...accepted,offset,revision:snapshot.revision});this.version++;if(heights){this.rowHeights=heights;this.rowOffsets=null;this.syncRowOffsets()}
|
|
41
|
+
else this.total=(this.paged?Math.max(0,Math.min(length,snapshot.matched-this.pageOffset)):snapshot.matched)*this.rowH;this.grid.setAttribute("aria-rowcount",String(snapshot.matched+1 +(this.headDepth||0)));this.grid.tabIndex=snapshot.matched?-1:0;let top=anchor.top;if(anchorIndex>=0&&(anchor.top>0||hadFocus))top=this.rowTop(anchorIndex)+ anchor.delta;this.syncScrollRange(Math.max(0,Math.min(top,this.total)));if(focused)this.focused=newFocus>=0?this.rowCache.get(newFocus)||this.rowItem(newFocus):
|
|
42
|
+
snapshot.matched?this.rowItem(Math.max(this.rowBounds().first,Math.min(focusIndex,this.rowBounds().last))):null;this.setNotice(snapshot.matched?"":this.labels.searchNoResults,false);this.render();if(hadFocus&&!this.canvas.contains(document.activeElement)){const element=this.focused&&this.rendered.get(this.focused);(element||this.grid).focus({preventScroll:true})}
|
|
43
|
+
this.syncQuerySummary();this.syncPager();this.syncGridChrome();this.liveAfterChange(changed,removed,positionOf,shifted)},liveAfterChange(changed,removed,positionOf,shifted){const gone=new Set(removed);if(this.querySelection){let touched=false;for(const id of gone)touched=this.selectionExcluded.delete(id)||touched;if(this.querySelection.matched!==this.snapshot.matched||this.querySelection.revision!==this.snapshot.revision){this.querySelection=gridFreeze({...this.querySelection,matched:this.snapshot.matched,revision:this.snapshot.revision});touched=true}
|
|
44
|
+
if(touched)this.publishQuerySelection?.()}else if(gone.size&&[...this.selected].some(id=>gone.has(id)))this.setSelection([...this.selected].filter(id=>!gone.has(id)));if(this.formatStatsKey!==undefined)this.formatStatsKey=null;VIEW_MODES.refresh?.(this);const dialog=this.recordDrawer,id=dialog?.isConnected?dialog.getAttribute("data-cx-record"):null;if(id&&typeof dialog._cxPaint==="function"&&(changed.has(id)||gone.has(id)||shifted)){const index=gone.has(id)?-1:positionOf(id),row=index>=0?this.rowCache.get(index):null;const record=row?row.h:index<0||!this.liveInline()?null:this.liveRows().get(id);if(record)dialog._cxPaint(row?record:liveCopy(record),index);else if(gone.has(id)){dialog._cxPaint(dialog._cxRecord,null);this.liveNote(this.labels.gridLiveRecordRemoved)}
|
|
45
|
+
else if(shifted&&!changed.has(id))dialog._cxPaint(dialog._cxRecord,index>=0?index:null)}
|
|
46
|
+
this.liveFlash(changed)},async liveRequery(changed,removed){const anchor=this.liveAnchor(),active=document.activeElement,hadFocus=this.canvas.contains(active);const focusedId=this.focused&&!this.focused.status?this.focused.key:null,keep=this.dataLifetime;this.dataLifetime=new AbortController();this.summaryCandidate=null;try{await this.setQuery({...this.acceptedQuery,offset:this.paged?this.pageOffset:0,revision:undefined})}
|
|
47
|
+
finally{const current=this.dataLifetime;if(current.signal.aborted||this.destroyed)keep.abort();else current.signal.addEventListener("abort",()=>keep.abort(),{once:true})}
|
|
48
|
+
this.setLogicalTop(Math.min(anchor.top,this.total));this.render();for(let wait=0;wait<8&&this.pendingPages.size&&!this.destroyed;wait++)await Promise.race([...this.pendingPages.values()].map(token=>token.promise));const focus=focusedId&&[...this.rowCache.values()].find(row=>row.key===focusedId);if(focus)this.focused=focus;if(hadFocus&&!this.canvas.contains(document.activeElement))(focus&&this.rendered.get(focus)||this.grid).focus({preventScroll:true});const dialog=this.recordDrawer,id=dialog?.isConnected?dialog.getAttribute("data-cx-record"):null,row=id&&[...this.rowCache.values()].find(item=>item.key===id);if(row&&changed.has(id))dialog._cxPaint(row.h,row._ri);else if(id&&new Set(removed).has(id)){dialog._cxPaint(dialog._cxRecord,null);this.liveNote(this.labels.gridLiveRecordRemoved)}
|
|
49
|
+
if(dialog?.contains(active)&&!dialog.contains(document.activeElement))active.focus?.({preventScroll:true});this.liveAfterChange(changed,removed,()=>-1,false)}});Object.assign(DataGrid.prototype,{liveHeldOffsets(){const offsets=new Set([0]),bounds=this.rowBounds(),size=this.pageSize;if(this.focused&&this.focused._ri>=0)offsets.add(Math.floor(this.focused._ri / size) * size);
|
|
50
|
+
if(this.paged)offsets.add(Math.floor(this.pageOffset / size) * size);
|
|
51
|
+
for(const range of this.window?this.window.ranges||[this.window]:[])
|
|
52
|
+
for(let page=Math.floor(Math.max(bounds.first,range.first)/ size) * size; page <= Math.min(bounds.last, range.last); page += size) offsets.add(page);
|
|
53
|
+
return[...offsets].slice(0,4).sort((a,b)=>a-b)},async liveRefreshHost(force){if(this.cursor)return this.liveRefreshCursor();const offsets=this.liveHeldOffsets(),lifetime=this.dataLifetime,epoch=this.queryEpoch,accepted=this.acceptedQuery;const ask=async(offset,snapshot)=>{const query=gridQuery(this.view,{...accepted,offset,limit:this.pageSize,revision:snapshot?snapshot.revision:undefined});const page=validateGridPage(await this.requestPage(query,lifetime.signal),this.view,query,snapshot);if(this.destroyed||epoch!==this.queryEpoch||this.acceptedQuery!==accepted)throw new DOMException("The refresh was superseded.","AbortError");return page};const first=await ask(0,null);if(!force&&(first.revision===this.snapshot.revision||first.revision===this.livePending?.snapshot?.revision))return null;const snapshot={revision:first.revision,total:first.total,matched:first.matched};if(this.liveProjected()){this.livePending=null;this.liveMoved=false;await this.liveRequery(new Map(),[]);return{changed:new Map(),removed:[],orderChanged:false,revision:this.snapshot.revision}}
|
|
54
|
+
const pages=new Map([[0,first.items]]);for(const offset of offsets)if(offset&&offset<snapshot.matched)pages.set(offset,(await ask(offset,snapshot)).items);const position=new Map(),fresh=new Map();for(const[offset,items]of pages)items.forEach((item,index)=>{position.set(item.id,offset+index);fresh.set(item.id,item)});const changed=new Map(),held=new Map();for(const row of this.rowCache.values())if(!row.status)held.set(row.key,row);for(const[id,item]of fresh){const row=held.get(id),columns=row?liveChangedColumns(row.h,item):"*";if(columns==="*"||columns.size)changed.set(id,columns)}
|
|
55
|
+
const seen=[...this.rendered.keys()].filter(row=>!row.status&&row.key).sort((a,b)=>a._ri-b._ri).map(row=>row.key);const before=seen.filter(id=>position.has(id)),after=[...before].sort((a,b)=>position.get(a)- position.get(b));const moved=before.some((id,index)=>id!==after[index]);if(moved&&this.liveOpts.stableOrder&&!force){this.liveSetHeld(fresh,false);this.livePending={snapshot,pages};this.liveSyncPrompt();return{changed,removed:[],orderChanged:true,revision:snapshot.revision}}
|
|
56
|
+
this.livePending=null;this.liveMoved=false;this.liveSwap(snapshot,()=>pages,id=>position.get(id)??-1,changed,[]);this.liveSyncPrompt();return{changed,removed:[],orderChanged:false,revision:snapshot.revision}},async liveRefreshCursor(){const query=gridQuery(this.view,{...this.acceptedQuery,cursor:undefined,revision:undefined,limit:this.pageLength});const page=validateGridCursorPage(await this.requestPage(query,this.dataLifetime.signal),this.view,query,null);if(this.destroyed||page.revision===this.snapshot.revision||page.revision===this.livePending?.revision)return null;this.livePending={cursor:true,revision:page.revision};this.liveSyncPrompt();return{changed:new Map(),removed:[],orderChanged:false,newData:true,revision:page.revision}},liveSetHeld(changes,merge){const changed=new Map(),loaded=new Set(),pages=new Set(),query=this.acceptedQuery,used=new Set(query.sort.map(sort=>sort.column));const walk=group=>{if(!group)return;for(const filter of group.filters)used.add(filter.column);group.groups.forEach(walk)};for(const filter of query.filters)used.add(filter.column);walk(query.filterGroup);const searched=!!query.search;let moved=false;for(const row of this.rowCache.values()){const change=!row.status&&changes.get(row.key);if(!change)continue;loaded.add(row.key);const after=merge?liveMerged(row.h,change):liveCopy(change),columns=liveChangedColumns(row.h,after);if(!columns.size&&liveSameRow(row.h,after))continue;row.h=after;changed.set(row.key,columns);pages.add(Math.floor(row._ri / this.pageSize) * this.pageSize);
|
|
57
|
+
if(searched||[...columns].some(id=>used.has(id)))moved=true}
|
|
58
|
+
if(merge&&this.livePending?.pages){for(const items of this.livePending.pages.values())for(let index=0;index<items.length;index++){const item=items[index],change=loaded.has(item.id)&&changes.get(item.id);if(!change)continue;const after=liveMerged(item,change),columns=liveChangedColumns(item,after);items[index]=after;if(!liveSameRow(item,after)&&(searched||[...columns].some(id=>used.has(id))))moved=true}
|
|
59
|
+
if(moved)this.livePending={refresh:true}}
|
|
60
|
+
for(const offset of pages){const page=this.pages.get(offset);if(page?.rows)this.storePage({offset,items:page.rows.map(row=>row.h)})}
|
|
61
|
+
if(changed.size){this.version++;this.scheduleRender();const positions=new Map([...this.rowCache.values()].map(row=>[row.key,row._ri]));this.liveAfterChange(changed,[],id=>positions.get(id)??-1,false)}
|
|
62
|
+
return{changed,moved,loaded}}});const LIVE_PAGE=DataGrid.prototype.loadPage,LIVE_RETRY=DataGrid.prototype.retry;DataGrid.prototype.loadPage=function(offset){const pending=this.livePending;if(!(pending?.pages||pending?.refresh)||!this.snapshot||this.pendingQuery||this.destroyed)return LIVE_PAGE.call(this,offset);if(this.pendingPages.has(offset))return this.pendingPages.get(offset).promise;const epoch=this.queryEpoch,lifetime=this.dataLifetime,token={};this.pendingPages.set(offset,token);if(!pending.applying)pending.applying=this.resort().catch(error=>{pending.error=error;throw error});token.promise=pending.applying.then(()=>{if(this.destroyed||epoch!==this.queryEpoch||lifetime!==this.dataLifetime||lifetime.signal.aborted)return;if(this.pendingPages.get(offset)===token)this.pendingPages.delete(offset);if(!this.pages.get(offset)?.rows)return LIVE_PAGE.call(this,offset)}).catch(error=>{if(this.destroyed||epoch!==this.queryEpoch||lifetime!==this.dataLifetime||lifetime.signal.aborted)return;this.pages.set(offset,{error,offset});this.version++;this.setNotice(fill(this.labels.loadError,{error:error.message}),true);this.emit("error",{error});this.scheduleRender()}).finally(()=>{if(this.pendingPages.get(offset)===token){this.pendingPages.delete(offset);this.loadWindow()}});return token.promise};DataGrid.prototype.retry=function(){const pending=this.livePending;if(pending?.error){pending.applying=null;delete pending.error}
|
|
63
|
+
return LIVE_RETRY.call(this)};const LIVE_ANNOUNCE_MS=2000;Object.assign(DataGrid.prototype,{liveSay(text){if(this.live&&text){setText(this.live,"");setText(this.live,text)}},liveNote(text){(this.liveNotes||=[]).push(text)},liveSpeak(){const notes=this.liveNotes;this.liveNotes=null;if(notes?.length)this.liveSay(notes.join(" "))},liveSyncPrompt(){const cursor=!!this.livePending?.cursor,show=!!(this.liveOrder?.dirty&&this.liveOrder.shape===gridResultShape(this.acceptedQuery)||this.livePending||this.liveMoved);if(!show){if(this.liveBar&&!this.liveBar.hidden){if(this.liveBar.contains(document.activeElement))(this.rendered.get(this.focused)||this.grid).focus({preventScroll:true});this.liveBar.hidden=true}
|
|
64
|
+
return}
|
|
65
|
+
if(!this.liveBar){const bar=this.liveBar=h("div","cx-live-bar"),text=this.liveBarText=h("span","cx-live-bar-text"),button=this.liveBarButton=gridButton("",()=>{const focus=bar.contains(document.activeElement);this.resort().then(()=>{if(focus&&!this.canvas.contains(document.activeElement))(this.rendered.get(this.focused)||this.grid).focus({preventScroll:true})})
|
|
66
|
+
.catch(error=>this.emit("error",{error}))});text.id=this.id+"-live-text";button.setAttribute("aria-describedby",text.id);bar.append(gridIcon(null,'<path d="M8 5v14M5 16l3 3 3-3M16 19V5M13 8l3-3 3 3"/>'),text,button);if(!this.toolbar.hidden&&this.spacer?.parentNode===this.toolbar)this.spacer.after(bar);else{bar.classList.add("cx-live-float");this.host.classList.add("cx-live-grid");this.grid.before(bar)}
|
|
67
|
+
this.lifetime.signal.addEventListener("abort",()=>{bar.remove();this.host.classList.remove("cx-live-grid")},{once:true})}
|
|
68
|
+
const wasHidden=this.liveBar.hidden||this.liveBarCursor!==cursor;setText(this.liveBarText,cursor?this.labels.gridLiveNewData:this.labels.gridLiveOrderChanged);setText(this.liveBarButton,cursor?this.labels.gridLiveRefresh:this.labels.gridLiveResort);this.liveBarButton.title=cursor?"":this.labels.gridLiveOrderHint;this.liveBarCursor=cursor;if(this.liveBar.classList.contains("cx-live-float"))this.liveBar.style.top=this.grid.offsetTop+this.head.offsetHeight+6+"px";this.liveBar.hidden=false;if(wasHidden)this.liveNote(cursor?this.labels.gridLiveNewData:this.labels.gridLiveOrderChanged+". "+this.labels.gridLiveOrderHint)},liveFlash(changed){const duration=this.liveOpts?.flashMs;if(!duration||!changed.size)return;const now=performance.now(),flashes=this.liveFlashes||=new Map();for(const[id,columns]of changed){const existing=flashes.get(id),merged=columns==="*"||existing?.columns==="*"?"*":new Set([...(existing?.columns||[]),...columns]);if(merged!=="*"&&!merged.size)continue;flashes.set(id,{columns:merged,start:now,until:now+duration})}
|
|
69
|
+
clearTimeout(this.liveFlashTimer);this.liveFlashTimer=setTimeout(()=>this.liveFlashExpire(),duration+20);this.version++;this.scheduleRender()},liveFlashExpire(){if(this.destroyed||!this.liveFlashes)return;const now=performance.now();for(const[id,flash]of this.liveFlashes)if(flash.until<=now)this.liveFlashes.delete(id);if(this.liveFlashes.size)this.liveFlashTimer=setTimeout(()=>this.liveFlashExpire(),Math.max(20,Math.min(...[...this.liveFlashes.values()].map(flash=>flash.until))- now+20));this.version++;this.scheduleRender()},liveAnnounce(result){if(!this.liveOpts?.announce||!result.added.length&&!result.removed.length)return;const counts=this.liveCounts||={added:0,updated:0,removed:0};counts.added +=result.added.length;counts.updated +=result.updated.length;counts.removed +=result.removed.length;if(this.liveAnnounceTimer)return;if(!this.liveSpoke||performance.now()- this.liveSpoke>=LIVE_ANNOUNCE_MS){this.liveNote(this.liveCountText());this.liveCoolDown()}
|
|
70
|
+
else this.liveAnnounceTimer=setTimeout(()=>{this.liveAnnounceTimer=0;this.liveSay(this.liveCountText());this.liveCoolDown()},LIVE_ANNOUNCE_MS -(performance.now()- this.liveSpoke))},liveCountText(){const numbers=new Intl.NumberFormat(this.lang),counts=this.liveCounts;this.liveCounts=null;return counts?fill(this.labels.gridLiveChanged,{added:numbers.format(counts.added),updated:numbers.format(counts.updated),removed:numbers.format(counts.removed)}):""},liveCoolDown(){this.liveSpoke=performance.now();this.liveAnnounceTimer=setTimeout(()=>{this.liveAnnounceTimer=0;if(this.liveCounts&&!this.destroyed){this.liveSay(this.liveCountText());this.liveCoolDown()}},LIVE_ANNOUNCE_MS)}});const LIVE_FILL=DataGrid.prototype.fillRow;DataGrid.prototype.fillRow=function(element,row){LIVE_FILL.call(this,element,row);const flash=this.liveFlashes?.size&&!row.status&&row.key?this.liveFlashes.get(row.key):null,mark=flash?row.key+"@"+flash.start:null;if(element._cxFlash&&element._cxFlashMark===mark&&element._cxFlashLayout===element._layout)return;if(element._cxFlash){for(const cell of element._cxFlash){cell.classList.remove("cx-live-flash");cell.style.removeProperty("animation-delay")}element._cxFlash=null;element._cxFlashMark=null}
|
|
71
|
+
if(!flash||!element._cells)return;const now=performance.now();if(flash.until<=now)return;const marked=[];element._cells.forEach((slot,index)=>{const column=this.cols[index];if(!slot||!column||flash.columns!=="*"&&!flash.columns.has(column.id))return;slot.cell.classList.add("cx-live-flash");slot.cell.style.animationDelay=Math.round(flash.start-now)+ "ms";marked.push(slot.cell)});if(marked.length){element._cxFlash=marked;element._cxFlashMark=mark;element._cxFlashLayout=element._layout}};Object.assign(DataGrid.prototype,{startLive(){if(this.destroyed)throw new DOMException("Grid was destroyed.","AbortError");if(this.liveOpts)return;this.liveOpts=liveOptions(this.view,this.opts);this.liveQueue=new Map();this.liveWaiters=[];this.liveScheduled=new Set();if(this.liveOpts.flashMs)this.host.style.setProperty("--cx-live-flash-ms",this.liveOpts.flashMs+"ms");this.host.addEventListener("canopyx:query",()=>{if(this.liveOrder&&this.liveOrder.shape!==gridResultShape(this.acceptedQuery))this.liveOrder=null;this.livePending=null;this.liveMoved=false;this.liveSyncPrompt()},{signal:this.lifetime.signal});this.lifetime.signal.addEventListener("abort",()=>{clearTimeout(this.liveTimer);clearTimeout(this.liveFlashTimer);clearTimeout(this.liveAnnounceTimer);this.host.style.removeProperty("--cx-live-flash-ms");for(const waiter of this.liveWaiters.splice(0))waiter.reject(new DOMException("Grid was destroyed.","AbortError"))},{once:true});if(this.liveOpts.pollMs)this.livePoll({intervalMs:this.liveOpts.pollMs})},liveStatus(){const queued=new Set(this.liveQueue?.keys());for(const{change}of this.liveScheduled||[])if(change){for(const row of[...change.add,...change.update])queued.add(row.id);change.remove.forEach(id=>queued.add(id))}
|
|
72
|
+
return gridFreeze({orderChanged:!!(this.liveOrder?.dirty||this.livePending?.pages||this.livePending?.refresh||this.liveMoved),newData:!!this.livePending?.cursor,pending:queued.size,polling:!!this.livePoller?.active,revision:this.snapshot?.revision??null})},liveRun(task){return this.liveChain=(this.liveChain||Promise.resolve()).catch(()=>{}).then(async()=>{this.startLive();await this.liveSettle();return task()})},applyTransaction(input){return this.liveQueueChange(liveTransaction(this,input),"api")},addRows(rows){return this.applyTransaction({add:rows})},updateRows(rows){return this.applyTransaction({update:rows})},removeRows(ids){return this.applyTransaction({remove:ids})},async setRows(rows){if(!this.liveInline())throw new Error("CanopyX: setRows replaces inline rows; a hosted grid's rows change at its source, then refreshRows().");validateGridRows(rows,this.view.columns);const owned=liveCopy(rows);return this.liveQueueChange(null,"api",owned)},liveQueueChange(change,source,replacement){if(this.destroyed)return Promise.reject(new DOMException("Grid was destroyed.","AbortError"));this.startLive();if(this.view.source.kind==="inline"&&this.opts.source)
|
|
73
|
+
return Promise.reject(new Error("CanopyX: this grid's rows belong to its own source; change them through it (an enhanced grid's setData, addRows and removeRows)."));if(!this.liveInline()&&(change.add.length||change.remove.length))
|
|
74
|
+
return Promise.reject(new Error("CanopyX: rows of a hosted grid are added and removed at its source; call refreshRows() after."));const scheduled={change};this.liveScheduled.add(scheduled);let waiter;const promise=new Promise((resolve,reject)=>{waiter={resolve,reject}});this.liveRun(async()=>{if(replacement){await this.liveFlush().catch(()=>{});change=liveTransaction(this,liveDiff(replacement,this.liveRows()))}
|
|
75
|
+
this.liveScheduled.delete(scheduled);this.liveEnqueueChange(change,source,waiter)}).catch(error=>{this.liveScheduled.delete(scheduled);waiter.reject(error)});return promise},liveEnqueueChange(change,source,waiter){liveEnqueue(this.liveQueue,change);this.liveWaiters.push(waiter);this.liveSource=this.liveSource&&this.liveSource!==source?"api":source;if(!this.liveOpts.batchMs)this.flushTransactions().catch(()=>{});else if(!this.liveTimer)this.liveTimer=setTimeout(()=>this.flushTransactions().catch(()=>{}),this.liveOpts.batchMs)},flushTransactions(){clearTimeout(this.liveTimer);this.liveTimer=0;return this.liveRun(()=>this.liveFlush())},async liveFlush(){clearTimeout(this.liveTimer);this.liveTimer=0;const queue=this.liveQueue,waiters=this.liveWaiters.splice(0),source=this.liveSource||"api";this.liveQueue=new Map();this.liveSource=null;try{const result=queue.size?await this.liveApply(queue,source):liveResult();waiters.forEach(waiter=>waiter.resolve(result));return result}catch(error){waiters.forEach(waiter=>waiter.reject(error));throw error}},async liveSettle(){if(!this.acceptedQuery&&!this.pendingQuery)await this.ready.catch(()=>{});while(!this.destroyed&&this.pendingQuery)await new Promise(resolve=>setTimeout(resolve,16));if(this.destroyed)throw new DOMException("Grid was destroyed.","AbortError");if(!this.acceptedQuery)throw new Error("CanopyX: live changes need an accepted query.");if(this.view.rowData&&this.liveInline()){await this.source.decoded;delete this.view.rowData;this.source=inlineGridSource(this.view)}},liveInlinePages(order){const rows=this.liveRows(),size=this.pageSize;return(anchor,focus)=>{const span=Math.ceil((this.grid.clientHeight||600)/ this.rowH) + 30, offsets = new Set();
|
|
76
|
+
const[first,last]=this.paged?[this.pageOffset,this.pageOffset+this.pageLength-1]:[Math.max(0,anchor-span),anchor+2*span];for(let page=Math.floor(first / size) * size; page <= Math.min(last, order.ids.length - 1); page += size) offsets.add(page);
|
|
77
|
+
if(focus>=0)offsets.add(Math.floor(focus / size) * size);
|
|
78
|
+
return new Map([...offsets].map(offset=>[offset,order.ids.slice(offset,offset+size).map(id=>liveCopy(rows.get(id)))]))}},liveSwapInline(changed,removed,shifted){const order=this.liveOrder;this.liveSwap({revision:this.snapshot.revision,total:this.liveRows().size,matched:order.ids.length},this.liveInlinePages(order),id=>order.at.get(id)??-1,changed,removed,shifted)},async liveApply(queue,source){let outcome;if(this.liveInline()){const projected=this.liveProjected(),{result,changed}=this.liveApplyRows(queue,!projected);if(changed.size||result.removed.length){if(!this.opts.source)this.source=inlineGridSource(this.view);this.liveOrderSource=this.source;if(projected)await this.liveRequery(changed,result.removed);else this.liveSwapInline(changed,result.removed,result.added.length>0||result.removed.length>0||!this.liveOpts.stableOrder)}
|
|
79
|
+
outcome={...result,orderChanged:!!this.liveOrder?.dirty}}else{const updates=new Map([...queue.values()].map(change=>[change.id,change.row]));const{changed,moved,loaded}=this.liveSetHeld(updates,true);if(moved)this.liveMoved=true;outcome={added:[],updated:[...changed.keys()],removed:[],missing:[...updates.keys()].filter(id=>!loaded.has(id)),orderChanged:this.liveMoved}}
|
|
80
|
+
const recordNote=!!this.liveNotes?.length;this.liveSyncPrompt();if(!recordNote)this.liveAnnounce(outcome);this.liveSpeak();return this.liveReport(outcome,source)},liveReport(outcome,source){const detail=gridFreeze({added:outcome.added||[],updated:outcome.updated||[],removed:outcome.removed||[],missing:outcome.missing||[],orderChanged:!!outcome.orderChanged,newData:!!outcome.newData,revision:outcome.revision??this.snapshot?.revision??null,source});if(detail.added.length||detail.updated.length||detail.removed.length||detail.newData||detail.orderChanged||outcome.refreshed)this.emit("rowsChanged",detail);return detail},refreshRows(){return this.liveRefresh("refresh")},liveRefresh(source){return this.liveRun(async()=>{if(this.liveInline()){if(!this.liveOpts.load)return liveResult();await this.liveFlush().catch(()=>{});let answer=await this.runGridHook(signal=>this.liveOpts.load({signal,query:this.acceptedQuery,rows:this.view.rows.length}),this.dataLifetime.signal);if(answer==null)return liveResult();if(Array.isArray(answer)){validateGridRows(answer,this.view.columns);answer=liveCopy(answer)}
|
|
81
|
+
const change=liveTransaction(this,Array.isArray(answer)?liveDiff(answer,this.liveRows()):answer),queue=new Map();liveEnqueue(queue,change);return this.liveApply(queue,source)}
|
|
82
|
+
if(this.view.source.kind==="inline")return liveResult();const outcome=await this.liveRefreshHost(false);if(!outcome)return liveResult();const changed=[...outcome.changed].filter(([,columns])=>columns!=="*").map(([id])=>id);this.liveSpeak();return this.liveReport({updated:changed,orderChanged:outcome.orderChanged,newData:outcome.newData,revision:outcome.revision,refreshed:true},source)})},resort(){return this.liveRun(async()=>{const pending=this.livePending,revision=this.snapshot?.revision;if(pending?.cursor){this.livePending=null;this.liveSyncPrompt();await this.setQuery({...this.acceptedQuery,cursor:undefined,revision:undefined},{pageLength:this.pageLength});return}
|
|
83
|
+
if(this.liveInline()){this.liveOrder=null;this.liveMoved=false;if(this.liveProjected())await this.liveRequery(new Map(),[]);else{this.liveOrderOf();this.liveSwapInline(new Map(),[],true)}}else if(pending?.pages){this.livePending=null;this.liveMoved=false;const position=new Map();for(const[offset,items]of pending.pages)items.forEach((item,index)=>position.set(item.id,offset+index));this.liveSwap(pending.snapshot,()=>pending.pages,id=>position.get(id)??-1,new Map(),[])}else{this.liveMoved=false;await this.liveRefreshHost(true)}
|
|
84
|
+
this.liveSyncPrompt();if(!this.liveInline()&&this.snapshot?.revision!==revision)this.liveReport({refreshed:true,revision:this.snapshot.revision},"refresh");this.liveNote(this.labels.gridLiveSorted);this.liveSpeak()})},async poll(options={}){return this.livePoll(options)},livePoll(options){this.startLive();if(!options||typeof options!=="object"||Array.isArray(options))throw new Error("CanopyX: poll takes options.");const interval=options.intervalMs??this.liveOpts.pollMs,hidden=options.pauseWhenHidden??this.liveOpts.pauseWhenHidden;if(!Number.isInteger(interval)||interval<250||interval>86400000||typeof hidden!=="boolean"||options.load!==undefined&&typeof options.load!=="function")
|
|
85
|
+
throw new Error("CanopyX: poll needs intervalMs from 250 to 86400000.");if(options.load)this.liveOpts.load=options.load;if(this.liveInline()&&!this.liveOpts.load)throw new Error("CanopyX: an inline grid polls a load function (live.load or poll({ load })).");this.livePoller?.stop();const lifetime=new AbortController();let timer=0,running=null,paused=false,due=false;const schedule=()=>{clearTimeout(timer);timer=paused||lifetime.signal.aborted?0:setTimeout(tick,interval)};const tick=now=>{clearTimeout(timer);timer=0;if(lifetime.signal.aborted||paused&&!now)return Promise.resolve();if(hidden&&document.hidden&&!now){due=true;return Promise.resolve()}
|
|
86
|
+
if(running)return running;return running=this.liveRefresh("poll").then(()=>undefined,error=>{if(error?.name!=="AbortError")this.emit("error",{error})})
|
|
87
|
+
.finally(()=>{running=null;schedule()})};const stop=()=>{lifetime.abort();clearTimeout(timer);if(this.livePoller===poller)this.livePoller=null};document.addEventListener("visibilitychange",()=>{if(!document.hidden&&due&&!paused){due=false;tick()}},{signal:lifetime.signal});this.lifetime.signal.addEventListener("abort",stop,{once:true,signal:lifetime.signal});const poller=Object.freeze({pause(){paused=true;clearTimeout(timer);timer=0},resume(){if(!paused||lifetime.signal.aborted)return;paused=false;due=false;tick()},stop,refresh:()=>tick(true),get paused(){return paused},get active(){return!lifetime.signal.aborted&&!paused}});this.livePoller=poller;if(options.immediate)tick();else schedule();return poller}});function liveResult(){return gridFreeze({added:[],updated:[],removed:[],missing:[],orderChanged:false,newData:false,revision:null,source:"api"})}
|
|
88
|
+
installed.add(context.DataGrid.prototype)}};(global.CanopyXParts||=[]).push(["live",part])})(typeof window!=="undefined"?window:globalThis);
|