gp-grid-core 0.2.3 → 0.3.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/dist/index.d.ts +16 -1
- package/dist/index.js +13 -11
- package/package.json +9 -9
package/dist/index.d.ts
CHANGED
|
@@ -229,6 +229,7 @@ interface SetContentSizeInstruction {
|
|
|
229
229
|
type: "SET_CONTENT_SIZE";
|
|
230
230
|
width: number;
|
|
231
231
|
height: number;
|
|
232
|
+
viewportWidth: number;
|
|
232
233
|
}
|
|
233
234
|
/** Update header instruction */
|
|
234
235
|
interface UpdateHeaderInstruction {
|
|
@@ -1493,6 +1494,18 @@ declare function calculateColumnPositions(columns: ColumnDefinition[]): number[]
|
|
|
1493
1494
|
* Get total width from column positions
|
|
1494
1495
|
*/
|
|
1495
1496
|
declare function getTotalWidth(columnPositions: number[]): number;
|
|
1497
|
+
/**
|
|
1498
|
+
* Calculate scaled column positions when container is wider than total column widths.
|
|
1499
|
+
* Columns expand proportionally based on their original width ratios.
|
|
1500
|
+
*
|
|
1501
|
+
* @param columns - Column definitions with original widths
|
|
1502
|
+
* @param containerWidth - Available container width
|
|
1503
|
+
* @returns Object with positions array and widths array
|
|
1504
|
+
*/
|
|
1505
|
+
declare function calculateScaledColumnPositions(columns: ColumnDefinition[], containerWidth: number): {
|
|
1506
|
+
positions: number[];
|
|
1507
|
+
widths: number[];
|
|
1508
|
+
};
|
|
1496
1509
|
/**
|
|
1497
1510
|
* Find column index at a given X coordinate
|
|
1498
1511
|
*/
|
|
@@ -1577,6 +1590,8 @@ interface GridState {
|
|
|
1577
1590
|
} | null;
|
|
1578
1591
|
contentWidth: number;
|
|
1579
1592
|
contentHeight: number;
|
|
1593
|
+
/** Viewport width (container's visible width) for column scaling */
|
|
1594
|
+
viewportWidth: number;
|
|
1580
1595
|
headers: Map<number, HeaderData>;
|
|
1581
1596
|
filterPopup: FilterPopupState | null;
|
|
1582
1597
|
isLoading: boolean;
|
|
@@ -1589,4 +1604,4 @@ interface GridState {
|
|
|
1589
1604
|
} | null;
|
|
1590
1605
|
}
|
|
1591
1606
|
//#endregion
|
|
1592
|
-
export { type AssignSlotInstruction, type BatchInstructionListener, type CancelFillInstruction, type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CloseFilterPopupInstruction, type ColumnDefinition, type ColumnFilterModel, type CommitEditInstruction, type CommitFillInstruction, type ContainerBounds, type CreateSlotInstruction, type DataChangeListener, type DataErrorInstruction, type DataLoadedInstruction, type DataLoadingInstruction, type DataSource, type DataSourceRequest, type DataSourceResponse, type DateFilterCondition, type DateFilterOperator, type DestroySlotInstruction, type Direction, type DragMoveResult, type DragState, EditManager, type EditManagerOptions, type EditRendererParams, type EditState, type FillHandleState, FillManager, type FilterCombination, type FilterCondition, type FilterModel, type FilterPopupState, GridCore, type GridCoreOptions, type GridInstruction, type GridState, type HeaderData, type HeaderRendererParams, IndexedDataStore, type IndexedDataStoreOptions, InputHandler, type InputHandlerDeps, type InputResult, type InstructionListener, type KeyEventData, type KeyboardResult, type MoveSlotInstruction, type MutableClientDataSourceOptions, type MutableDataSource, type NumberFilterCondition, type NumberFilterOperator, type OpenFilterPopupInstruction, type PointerEventData, type Row, type RowId, type RowSortCache, type RowsAddedInstruction, type RowsRemovedInstruction, type RowsUpdatedInstruction, SelectionManager, type SelectionState, type SetActiveCellInstruction, type SetContentSizeInstruction, type SetSelectionRangeInstruction, type SlotData, type BatchInstructionListener$1 as SlotPoolBatchListener, SlotPoolManager, type SlotPoolManagerOptions, type SlotState, type SortDirection, type SortModel, SortWorkerManager, type StartEditInstruction, type StartFillInstruction, type StopEditInstruction, type TextFilterCondition, type TextFilterOperator, type Transaction, TransactionManager, type TransactionManagerOptions, type TransactionProcessedInstruction, type TransactionResult, type UpdateFillInstruction, type UpdateHeaderInstruction, buildCellClasses, calculateColumnPositions, cellStyles, compareValues, computeValueHash, containerStyles, createClientDataSource, createDataSourceFromArray, createMutableClientDataSource, createServerDataSource, evaluateColumnFilter, evaluateDateCondition, evaluateNumberCondition, evaluateTextCondition, filtersStyles, findColumnAtX, getFieldValue, getSharedSortWorker, getTotalWidth, gridStyles, headerStyles, injectStyles, isCellActive, isCellEditing, isCellInFillPreview, isCellSelected, isRowVisible, isSameDay, rowPassesFilter, scrollbarStyles, setFieldValue, statesStyles, stringToSortableNumber, terminateSharedSortWorker, variablesStyles };
|
|
1607
|
+
export { type AssignSlotInstruction, type BatchInstructionListener, type CancelFillInstruction, type CellDataType, type CellPosition, type CellRange, type CellRendererParams, type CellValue, type CloseFilterPopupInstruction, type ColumnDefinition, type ColumnFilterModel, type CommitEditInstruction, type CommitFillInstruction, type ContainerBounds, type CreateSlotInstruction, type DataChangeListener, type DataErrorInstruction, type DataLoadedInstruction, type DataLoadingInstruction, type DataSource, type DataSourceRequest, type DataSourceResponse, type DateFilterCondition, type DateFilterOperator, type DestroySlotInstruction, type Direction, type DragMoveResult, type DragState, EditManager, type EditManagerOptions, type EditRendererParams, type EditState, type FillHandleState, FillManager, type FilterCombination, type FilterCondition, type FilterModel, type FilterPopupState, GridCore, type GridCoreOptions, type GridInstruction, type GridState, type HeaderData, type HeaderRendererParams, IndexedDataStore, type IndexedDataStoreOptions, InputHandler, type InputHandlerDeps, type InputResult, type InstructionListener, type KeyEventData, type KeyboardResult, type MoveSlotInstruction, type MutableClientDataSourceOptions, type MutableDataSource, type NumberFilterCondition, type NumberFilterOperator, type OpenFilterPopupInstruction, type PointerEventData, type Row, type RowId, type RowSortCache, type RowsAddedInstruction, type RowsRemovedInstruction, type RowsUpdatedInstruction, SelectionManager, type SelectionState, type SetActiveCellInstruction, type SetContentSizeInstruction, type SetSelectionRangeInstruction, type SlotData, type BatchInstructionListener$1 as SlotPoolBatchListener, SlotPoolManager, type SlotPoolManagerOptions, type SlotState, type SortDirection, type SortModel, SortWorkerManager, type StartEditInstruction, type StartFillInstruction, type StopEditInstruction, type TextFilterCondition, type TextFilterOperator, type Transaction, TransactionManager, type TransactionManagerOptions, type TransactionProcessedInstruction, type TransactionResult, type UpdateFillInstruction, type UpdateHeaderInstruction, buildCellClasses, calculateColumnPositions, calculateScaledColumnPositions, cellStyles, compareValues, computeValueHash, containerStyles, createClientDataSource, createDataSourceFromArray, createMutableClientDataSource, createServerDataSource, evaluateColumnFilter, evaluateDateCondition, evaluateNumberCondition, evaluateTextCondition, filtersStyles, findColumnAtX, getFieldValue, getSharedSortWorker, getTotalWidth, gridStyles, headerStyles, injectStyles, isCellActive, isCellEditing, isCellInFillPreview, isCellSelected, isRowVisible, isSameDay, rowPassesFilter, scrollbarStyles, setFieldValue, statesStyles, stringToSortableNumber, terminateSharedSortWorker, variablesStyles };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
var e=class{state={activeCell:null,range:null,anchor:null,selectionMode:!1};options;listeners=[];constructor(e){this.options=e}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e)}getState(){return{...this.state}}getActiveCell(){return this.state.activeCell}getSelectionRange(){return this.state.range}isSelected(e,t){let{range:n}=this.state;if(!n)return!1;let r=Math.min(n.startRow,n.endRow),i=Math.max(n.startRow,n.endRow),a=Math.min(n.startCol,n.endCol),o=Math.max(n.startCol,n.endCol);return e>=r&&e<=i&&t>=a&&t<=o}isActiveCell(e,t){let{activeCell:n}=this.state;return n?.row===e&&n?.col===t}startSelection(e,t={}){let{shift:n=!1,ctrl:r=!1}=t,{row:i,col:a}=this.clampPosition(e);n&&this.state.anchor?(this.state.range={startRow:this.state.anchor.row,startCol:this.state.anchor.col,endRow:i,endCol:a},this.state.activeCell={row:i,col:a}):(this.state.activeCell={row:i,col:a},this.state.anchor={row:i,col:a},this.state.range=null),this.state.selectionMode=r,this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell}),this.emit({type:`SET_SELECTION_RANGE`,range:this.state.range})}moveFocus(e,t=!1){if(!this.state.activeCell){this.startSelection({row:0,col:0});return}let{row:n,col:r}=this.state.activeCell,i=n,a=r;switch(e){case`up`:i=Math.max(0,n-1);break;case`down`:i=Math.min(this.options.getRowCount()-1,n+1);break;case`left`:a=Math.max(0,r-1);break;case`right`:a=Math.min(this.options.getColumnCount()-1,r+1);break}t?(this.state.anchor||(this.state.anchor={row:n,col:r}),this.state.range={startRow:this.state.anchor.row,startCol:this.state.anchor.col,endRow:i,endCol:a},this.state.activeCell={row:i,col:a},this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell}),this.emit({type:`SET_SELECTION_RANGE`,range:this.state.range})):(this.state.activeCell={row:i,col:a},this.state.anchor={row:i,col:a},this.state.range=null,this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell}),this.emit({type:`SET_SELECTION_RANGE`,range:null}))}selectAll(){let e=this.options.getRowCount(),t=this.options.getColumnCount();e===0||t===0||(this.state.range={startRow:0,startCol:0,endRow:e-1,endCol:t-1},this.state.activeCell||(this.state.activeCell={row:0,col:0},this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell})),this.emit({type:`SET_SELECTION_RANGE`,range:this.state.range}))}clearSelection(){this.state.activeCell=null,this.state.range=null,this.state.anchor=null,this.state.selectionMode=!1,this.emit({type:`SET_ACTIVE_CELL`,position:null}),this.emit({type:`SET_SELECTION_RANGE`,range:null})}setActiveCell(e,t){let n=this.clampPosition({row:e,col:t});this.state.activeCell=n,this.state.anchor=n,this.state.range=null,this.emit({type:`SET_ACTIVE_CELL`,position:this.state.activeCell}),this.emit({type:`SET_SELECTION_RANGE`,range:null})}setSelectionRange(e){this.state.range=e,this.emit({type:`SET_SELECTION_RANGE`,range:this.state.range})}getSelectedData(){let{range:e,activeCell:t}=this.state;if(!e&&!t)return[];let n=e||{startRow:t.row,startCol:t.col,endRow:t.row,endCol:t.col},r=Math.min(n.startRow,n.endRow),i=Math.max(n.startRow,n.endRow),a=Math.min(n.startCol,n.endCol),o=Math.max(n.startCol,n.endCol),s=[];for(let e=r;e<=i;e++){let t=[];for(let n=a;n<=o;n++)t.push(this.options.getCellValue(e,n));s.push(t)}return s}async copySelectionToClipboard(){let e=this.getSelectedData();if(e.length===0)return;let t=e.map(e=>e.map(e=>e==null?``:String(e)).join(` `)).join(`
|
|
2
|
-
`);try{await navigator.clipboard.writeText(t)}catch{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.left=`-9999px`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}}clampPosition(e){let t=this.options.getRowCount(),n=this.options.getColumnCount();return{row:Math.max(0,Math.min(e.row,t-1)),col:Math.max(0,Math.min(e.col,n-1))}}},t=class{state=null;options;listeners=[];constructor(e){this.options=e}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e)}getState(){return this.state?{...this.state}:null}isActive(){return this.state!==null}startFillDrag(e){this.state={sourceRange:e,targetRow:e.endRow,targetCol:e.endCol},this.emit({type:`START_FILL`,sourceRange:e})}updateFillDrag(e,t){if(!this.state)return;let n=this.options.getRowCount(),r=this.options.getColumnCount();e=Math.max(0,Math.min(e,n-1)),t=Math.max(0,Math.min(t,r-1)),this.state.targetRow=e,this.state.targetCol=t,this.emit({type:`UPDATE_FILL`,targetRow:e,targetCol:t})}commitFillDrag(){if(!this.state)return;let{sourceRange:e,targetRow:t,targetCol:n}=this.state,r=this.calculateFilledCells(e,t,n);for(let{row:e,col:t,value:n}of r)this.options.setCellValue(e,t,n);this.emit({type:`COMMIT_FILL`,filledCells:r}),this.state=null}cancelFillDrag(){this.state&&(this.state=null,this.emit({type:`CANCEL_FILL`}))}calculateFilledCells(e,t,n){let r=[],i=Math.min(e.startRow,e.endRow),a=Math.max(e.startRow,e.endRow),o=Math.min(e.startCol,e.endCol),s=Math.max(e.startCol,e.endCol),c=t>a,l=t<i;if(c||l)for(let e=o;e<=s;e++){let n=this.getSourceColumnValues(i,a,e),o=this.detectPattern(n);if(c)for(let i=a+1;i<=t;i++){let t=i-a-1,s=this.applyPattern(o,n,t);r.push({row:i,col:e,value:s})}else if(l)for(let a=i-1;a>=t;a--){let t=i-a-1,s=this.applyPattern(o,n,t,!0);r.push({row:a,col:e,value:s})}}return r}getSourceColumnValues(e,t,n){let r=[];for(let i=e;i<=t;i++)r.push(this.options.getCellValue(i,n));return r}detectPattern(e){if(e.length===0)return{type:`constant`,value:null};if(e.length===1)return{type:`constant`,value:e[0]??null};let t=e.map(e=>typeof e==`number`?e:Number(e));if(t.every(e=>!isNaN(e))){let e=[];for(let n=1;n<t.length;n++)e.push(t[n]-t[n-1]);if(e.every(t=>t===e[0])&&e[0]!==void 0)return{type:`arithmetic`,start:t[0],step:e[0]}}return{type:`repeat`,values:e}}applyPattern(e,t,n,r=!1){switch(e.type){case`constant`:return e.value;case`arithmetic`:{let i=r?-(n+1):n+1;return(r?e.start:e.start+e.step*(t.length-1))+e.step*i}case`repeat`:{let t=e.values.length;if(t===0)return null;if(r){let r=(t-1-n%t+t)%t;return e.values[r]??null}return e.values[n%t]??null}}}},n=class{state={slots:new Map,rowToSlot:new Map,nextSlotId:0};options;listeners=[];batchListeners=[];constructor(e){this.options=e}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onBatchInstruction(e){return this.batchListeners.push(e),()=>{this.batchListeners=this.batchListeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e);for(let t of this.batchListeners)t([e])}emitBatch(e){if(e.length!==0){for(let t of this.batchListeners)t(e);for(let t of e)for(let e of this.listeners)e(t)}}getSlotForRow(e){return this.state.rowToSlot.get(e)}getSlots(){return this.state.slots}syncSlots(){let e=this.options.getScrollTop(),t=this.options.getRowHeight(),n=this.options.getViewportHeight(),r=this.options.getTotalRows(),i=this.options.getOverscan(),a=Math.max(0,Math.floor(e/t)-i),o=Math.min(r-1,Math.ceil((e+n)/t)+i);if(r===0||o<a){this.destroyAllSlots();return}let s=new Set;for(let e=a;e<=o;e++)s.add(e);let c=[],l=[];for(let[e,t]of this.state.slots)s.has(t.rowIndex)?s.delete(t.rowIndex):(l.push(e),this.state.rowToSlot.delete(t.rowIndex));let u=Array.from(s);for(let e=0;e<u.length;e++){let t=u[e],n=this.options.getRowData(t);if(e<l.length){let r=l[e],i=this.state.slots.get(r),a=this.getRowTranslateY(t);i.rowIndex=t,i.rowData=n??{},i.translateY=a,this.state.rowToSlot.set(t,r),c.push({type:`ASSIGN_SLOT`,slotId:r,rowIndex:t,rowData:n??{}}),c.push({type:`MOVE_SLOT`,slotId:r,translateY:a})}else{let e=`slot-${this.state.nextSlotId++}`,r=this.getRowTranslateY(t),i={slotId:e,rowIndex:t,rowData:n??{},translateY:r};this.state.slots.set(e,i),this.state.rowToSlot.set(t,e),c.push({type:`CREATE_SLOT`,slotId:e}),c.push({type:`ASSIGN_SLOT`,slotId:e,rowIndex:t,rowData:n??{}}),c.push({type:`MOVE_SLOT`,slotId:e,translateY:r})}}for(let e=u.length;e<l.length;e++){let t=l[e];this.state.slots.delete(t),c.push({type:`DESTROY_SLOT`,slotId:t})}for(let[e,t]of this.state.slots){let n=this.getRowTranslateY(t.rowIndex);t.translateY!==n&&(t.translateY=n,c.push({type:`MOVE_SLOT`,slotId:e,translateY:n}))}this.emitBatch(c)}destroyAllSlots(){let e=[];for(let t of this.state.slots.keys())e.push({type:`DESTROY_SLOT`,slotId:t});this.state.slots.clear(),this.state.rowToSlot.clear(),this.emitBatch(e)}refreshAllSlots(){let e=[],t=this.options.getTotalRows();for(let[n,r]of this.state.slots)if(r.rowIndex>=0&&r.rowIndex<t){let t=this.options.getRowData(r.rowIndex),i=this.getRowTranslateY(r.rowIndex);r.rowData=t??{},r.translateY=i,e.push({type:`ASSIGN_SLOT`,slotId:n,rowIndex:r.rowIndex,rowData:t??{}}),e.push({type:`MOVE_SLOT`,slotId:n,translateY:i})}this.emitBatch(e),this.syncSlots()}updateSlot(e){let t=this.state.rowToSlot.get(e);if(t){let n=this.options.getRowData(e);n&&this.emit({type:`ASSIGN_SLOT`,slotId:t,rowIndex:e,rowData:n})}}getRowTranslateY(e){let t=this.options.getRowHeight(),n=this.options.getHeaderHeight(),r=this.options.getScrollRatio(),i=this.options.getVirtualContentHeight(),a=this.options.getScrollTop(),o=e*t+n;if(r>=1)return o;let s=a,c=o-(s-s*r);return Math.max(0,Math.min(c,i))}},r=class{editState=null;options;listeners=[];constructor(e){this.options=e}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e)}getState(){return this.editState?{...this.editState}:null}isEditing(){return this.editState!==null}isEditingCell(e,t){return this.editState!==null&&this.editState.row===e&&this.editState.col===t}startEdit(e,t){let n=this.options.getColumn(t);if(!n||n.editable!==!0)return!1;let r=this.options.getCellValue(e,t);return this.editState={row:e,col:t,initialValue:r,currentValue:r},this.emit({type:`START_EDIT`,row:e,col:t,initialValue:r}),!0}updateValue(e){this.editState&&(this.editState.currentValue=e)}commit(){if(!this.editState)return;let{row:e,col:t,currentValue:n}=this.editState;this.options.setCellValue(e,t,n),this.emit({type:`COMMIT_EDIT`,row:e,col:t,value:n}),this.editState=null,this.emit({type:`STOP_EDIT`}),this.options.onCommit?.(e,t,n)}cancel(){this.editState=null,this.emit({type:`STOP_EDIT`})}},i=class{core;deps;isDraggingSelection=!1;isDraggingFill=!1;fillSourceRange=null;fillTarget=null;constructor(e,t){this.core=e,this.deps=t}updateDeps(e){this.deps={...this.deps,...e}}getDragState(){return{isDragging:this.isDraggingSelection||this.isDraggingFill,dragType:this.isDraggingFill?`fill`:this.isDraggingSelection?`selection`:null,fillSourceRange:this.fillSourceRange,fillTarget:this.fillTarget}}handleCellMouseDown(e,t,n){return n.button!==0||this.core.getEditState()!==null?{preventDefault:!1,stopPropagation:!1}:(this.core.selection.startSelection({row:e,col:t},{shift:n.shiftKey,ctrl:n.ctrlKey||n.metaKey}),{preventDefault:!1,stopPropagation:!1,focusContainer:!0,startDrag:n.shiftKey?void 0:`selection`})}handleCellDoubleClick(e,t){this.core.startEdit(e,t)}handleFillHandleMouseDown(e,t,n){if(!e&&!t)return{preventDefault:!1,stopPropagation:!1};let r=t??{startRow:e.row,startCol:e.col,endRow:e.row,endCol:e.col};return this.core.fill.startFillDrag(r),this.fillSourceRange=r,this.fillTarget={row:Math.max(r.startRow,r.endRow),col:Math.max(r.startCol,r.endCol)},this.isDraggingFill=!0,{preventDefault:!0,stopPropagation:!0,startDrag:`fill`}}handleHeaderClick(e,t){let n=this.core.getSortModel().find(t=>t.colId===e)?.direction,r=n==null?`asc`:n===`asc`?`desc`:null;this.core.setSort(e,r,t)}startSelectionDrag(){this.isDraggingSelection=!0}handleDragMove(e,t){if(!this.isDraggingSelection&&!this.isDraggingFill)return null;let{top:n,left:r,width:i,height:a,scrollTop:o,scrollLeft:s}=t,c=this.deps.getHeaderHeight(),l=this.deps.getColumnPositions(),u=this.deps.getColumnCount(),d=e.clientX-r+s,f=e.clientY-n-c,p=Math.max(0,Math.min(this.core.getRowIndexAtDisplayY(f,o),this.core.getRowCount()-1)),m=Math.max(0,Math.min(this.findColumnAtX(d,l),u-1));this.isDraggingSelection&&this.core.selection.startSelection({row:p,col:m},{shift:!0}),this.isDraggingFill&&(this.core.fill.updateFillDrag(p,m),this.fillTarget={row:p,col:m});let h=e.clientY-n,g=e.clientX-r;return{targetRow:p,targetCol:m,autoScroll:this.calculateAutoScroll(h,g,a,i,c)}}handleDragEnd(){this.isDraggingFill&&(this.core.fill.commitFillDrag(),this.core.refreshSlotData()),this.isDraggingSelection=!1,this.isDraggingFill=!1,this.fillSourceRange=null,this.fillTarget=null}handleWheel(e,t,n){return this.core.isScalingActive()?{dy:e*n,dx:t*n}:null}handleKeyDown(e,t,n,r){if(r||n&&e.key!==`Enter`&&e.key!==`Escape`&&e.key!==`Tab`)return{preventDefault:!1};let{selection:i}=this.core,a=e.shiftKey,o=e.ctrlKey||e.metaKey,s=(e=>{switch(e){case`ArrowUp`:return`up`;case`ArrowDown`:return`down`;case`ArrowLeft`:return`left`;case`ArrowRight`:return`right`;default:return null}})(e.key);if(s)return i.moveFocus(s,a),{preventDefault:!0,scrollToCell:i.getActiveCell()??void 0};switch(e.key){case`Enter`:return n?this.core.commitEdit():t&&this.core.startEdit(t.row,t.col),{preventDefault:!0};case`Escape`:return n?this.core.cancelEdit():i.clearSelection(),{preventDefault:!0};case`Tab`:return n&&this.core.commitEdit(),i.moveFocus(a?`left`:`right`,!1),{preventDefault:!0};case`a`:if(o)return i.selectAll(),{preventDefault:!0};break;case`c`:if(o)return i.copySelectionToClipboard(),{preventDefault:!0};break;case`F2`:return t&&!n&&this.core.startEdit(t.row,t.col),{preventDefault:!0};case`Delete`:case`Backspace`:if(t&&!n)return this.core.startEdit(t.row,t.col),{preventDefault:!0};break;default:t&&!n&&!o&&e.key.length===1&&this.core.startEdit(t.row,t.col);break}return{preventDefault:!1}}findColumnAtX(e,t){for(let n=0;n<t.length-1;n++)if(e>=t[n]&&e<t[n+1])return n;return e>=t[t.length-1]?t.length-2:0}calculateAutoScroll(e,t,n,r,i){let a=0,o=0;return e<40+i?o=-10:e>n-40&&(o=10),t<40?a=-10:t>r-40&&(a=10),a!==0||o!==0?{dx:a,dy:o}:null}};const a=1e7;var o=class{columns;dataSource;rowHeight;headerHeight;overscan;sortingEnabled;scrollTop=0;scrollLeft=0;viewportWidth=800;viewportHeight=600;cachedRows=new Map;totalRows=0;currentPageIndex=0;pageSize=1e6;sortModel=[];filterModel={};openFilterColIndex=null;selection;fill;input;slotPool;editManager;columnPositions=[];listeners=[];batchListeners=[];naturalContentHeight=0;virtualContentHeight=0;scrollRatio=1;constructor(a){this.columns=a.columns,this.dataSource=a.dataSource,this.rowHeight=a.rowHeight,this.headerHeight=a.headerHeight??a.rowHeight,this.overscan=a.overscan??3,this.sortingEnabled=a.sortingEnabled??!0,this.computeColumnPositions(),this.selection=new e({getRowCount:()=>this.totalRows,getColumnCount:()=>this.columns.length,getCellValue:(e,t)=>this.getCellValue(e,t),getRowData:e=>this.cachedRows.get(e),getColumn:e=>this.columns[e]}),this.selection.onInstruction(e=>this.emit(e)),this.fill=new t({getRowCount:()=>this.totalRows,getColumnCount:()=>this.columns.length,getCellValue:(e,t)=>this.getCellValue(e,t),getColumn:e=>this.columns[e],setCellValue:(e,t,n)=>this.setCellValue(e,t,n)}),this.fill.onInstruction(e=>this.emit(e)),this.slotPool=new n({getRowHeight:()=>this.rowHeight,getHeaderHeight:()=>this.headerHeight,getOverscan:()=>this.overscan,getScrollTop:()=>this.scrollTop,getViewportHeight:()=>this.viewportHeight,getTotalRows:()=>this.totalRows,getScrollRatio:()=>this.scrollRatio,getVirtualContentHeight:()=>this.virtualContentHeight,getRowData:e=>this.cachedRows.get(e)}),this.slotPool.onBatchInstruction(e=>this.emitBatch(e)),this.editManager=new r({getColumn:e=>this.columns[e],getCellValue:(e,t)=>this.getCellValue(e,t),setCellValue:(e,t,n)=>this.setCellValue(e,t,n),onCommit:e=>{this.slotPool.updateSlot(e)}}),this.editManager.onInstruction(e=>this.emit(e)),this.input=new i(this,{getHeaderHeight:()=>this.headerHeight,getRowHeight:()=>this.rowHeight,getColumnPositions:()=>this.columnPositions,getColumnCount:()=>this.columns.length})}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onBatchInstruction(e){return this.batchListeners.push(e),()=>{this.batchListeners=this.batchListeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e);for(let t of this.batchListeners)t([e])}emitBatch(e){if(e.length!==0){for(let t of this.batchListeners)t(e);for(let t of e)for(let e of this.listeners)e(t)}}async initialize(){await this.fetchData(),this.slotPool.syncSlots(),this.emitContentSize(),this.emitHeaders()}setViewport(e,t,n,r){let i=this.scrollRatio<1?e/this.scrollRatio:e;if(!(this.scrollTop!==i||this.scrollLeft!==t||this.viewportWidth!==n||this.viewportHeight!==r))return;this.scrollTop=i,this.scrollLeft=t,this.viewportWidth=n,this.viewportHeight=r,this.slotPool.syncSlots();let a=this.getVisibleRowRange();this.emit({type:`UPDATE_VISIBLE_RANGE`,start:a.start,end:a.end})}async fetchData(){this.emit({type:`DATA_LOADING`});try{let e={pagination:{pageIndex:this.currentPageIndex,pageSize:this.pageSize},sort:this.sortModel.length>0?this.sortModel:void 0,filter:Object.keys(this.filterModel).length>0?this.filterModel:void 0},t=await this.dataSource.fetch(e);this.cachedRows.clear(),t.rows.forEach((e,t)=>{this.cachedRows.set(this.currentPageIndex*this.pageSize+t,e)}),this.totalRows=t.totalRows,t.totalRows>t.rows.length&&this.currentPageIndex===0&&await this.fetchAllData(),this.emit({type:`DATA_LOADED`,totalRows:this.totalRows})}catch(e){this.emit({type:`DATA_ERROR`,error:e instanceof Error?e.message:String(e)})}}async fetchAllData(){let e=Math.ceil(this.totalRows/this.pageSize);for(let t=1;t<e;t++){let e={pagination:{pageIndex:t,pageSize:this.pageSize},sort:this.sortModel.length>0?this.sortModel:void 0,filter:Object.keys(this.filterModel).length>0?this.filterModel:void 0};(await this.dataSource.fetch(e)).rows.forEach((e,n)=>{this.cachedRows.set(t*this.pageSize+n,e)})}}async setSort(e,t,n=!1){if(!this.sortingEnabled||this.columns.find(t=>(t.colId??t.field)===e)?.sortable===!1)return;let r=this.sortModel.findIndex(t=>t.colId===e);n?t===null?r>=0&&this.sortModel.splice(r,1):r>=0?this.sortModel[r].direction=t:this.sortModel.push({colId:e,direction:t}):this.sortModel=t===null?[]:[{colId:e,direction:t}],await this.fetchData(),this.slotPool.refreshAllSlots(),this.emitHeaders()}async setFilter(e,t){this.columns.find(t=>(t.colId??t.field)===e)?.filterable!==!1&&(t===null||typeof t==`string`&&t.trim()===``||typeof t==`object`&&t.conditions&&t.conditions.length===0?delete this.filterModel[e]:typeof t==`string`?this.filterModel[e]={conditions:[{type:`text`,operator:`contains`,value:t}],combination:`and`}:this.filterModel[e]=t,await this.fetchData(),this.slotPool.refreshAllSlots(),this.emitContentSize(),this.emitHeaders())}hasActiveFilter(e){let t=this.filterModel[e];return t?t.conditions.length>0:!1}isColumnSortable(e){return this.sortingEnabled?this.columns[e]?.sortable!==!1:!1}isColumnFilterable(e){return this.columns[e]?.filterable!==!1}getDistinctValuesForColumn(e,t=500){let n=this.columns.find(t=>(t.colId??t.field)===e);if(!n)return[];let r=new Map;for(let e of this.cachedRows.values()){let i=this.getFieldValue(e,n.field);if(Array.isArray(i)){let e=[...i].sort((e,t)=>String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})),n=JSON.stringify(e);if(!r.has(n)&&(r.set(n,e),r.size>=t))break}else{let e=JSON.stringify(i);if(!r.has(e)&&(r.set(e,i),r.size>=t))break}}let i=Array.from(r.values());return i.sort((e,t)=>{let n=Array.isArray(e)?e.join(`, `):String(e??``),r=Array.isArray(t)?t.join(`, `):String(t??``);return n.localeCompare(r,void 0,{numeric:!0,sensitivity:`base`})}),i}openFilterPopup(e,t){if(this.openFilterColIndex===e){this.closeFilterPopup();return}let n=this.columns[e];if(!n||!this.isColumnFilterable(e))return;let r=n.colId??n.field,i=this.getDistinctValuesForColumn(r);this.openFilterColIndex=e,this.emit({type:`OPEN_FILTER_POPUP`,colIndex:e,column:n,anchorRect:t,distinctValues:i,currentFilter:this.filterModel[r]})}closeFilterPopup(){this.openFilterColIndex=null,this.emit({type:`CLOSE_FILTER_POPUP`})}getSortModel(){return[...this.sortModel]}getFilterModel(){return{...this.filterModel}}startEdit(e,t){this.editManager.startEdit(e,t)}updateEditValue(e){this.editManager.updateValue(e)}commitEdit(){this.editManager.commit()}cancelEdit(){this.editManager.cancel()}getEditState(){return this.editManager.getState()}getCellValue(e,t){let n=this.cachedRows.get(e);if(!n)return null;let r=this.columns[t];return r?this.getFieldValue(n,r.field):null}setCellValue(e,t,n){let r=this.cachedRows.get(e);if(!r||typeof r!=`object`)return;let i=this.columns[t];i&&this.setFieldValue(r,i.field,n)}getFieldValue(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r??null}setFieldValue(e,t,n){let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];t in i||(i[t]={}),i=i[t]}let a=r[r.length-1];i[a]=n}computeColumnPositions(){this.columnPositions=[0];let e=0;for(let t of this.columns)e+=t.width,this.columnPositions.push(e)}emitContentSize(){let e=this.columnPositions[this.columnPositions.length-1]??0;this.naturalContentHeight=this.totalRows*this.rowHeight+this.headerHeight,this.naturalContentHeight>a?(this.virtualContentHeight=a,this.scrollRatio=a/this.naturalContentHeight):(this.virtualContentHeight=this.naturalContentHeight,this.scrollRatio=1),this.emit({type:`SET_CONTENT_SIZE`,width:e,height:this.virtualContentHeight})}emitHeaders(){let e=new Map;this.sortModel.forEach((t,n)=>{e.set(t.colId,{direction:t.direction,index:n+1})});for(let t=0;t<this.columns.length;t++){let n=this.columns[t],r=n.colId??n.field,i=e.get(r);this.emit({type:`UPDATE_HEADER`,colIndex:t,column:n,sortDirection:i?.direction,sortIndex:i?.index,sortable:this.isColumnSortable(t),filterable:this.isColumnFilterable(t),hasFilter:this.hasActiveFilter(r)})}}getColumns(){return this.columns}getColumnPositions(){return[...this.columnPositions]}getRowCount(){return this.totalRows}getRowHeight(){return this.rowHeight}getHeaderHeight(){return this.headerHeight}getTotalWidth(){return this.columnPositions[this.columnPositions.length-1]??0}getTotalHeight(){return this.virtualContentHeight||this.totalRows*this.rowHeight+this.headerHeight}isScalingActive(){return this.scrollRatio<1}getNaturalHeight(){return this.naturalContentHeight||this.totalRows*this.rowHeight+this.headerHeight}getScrollRatio(){return this.scrollRatio}getVisibleRowRange(){let e=this.viewportHeight-this.headerHeight,t=Math.max(0,Math.floor(this.scrollTop/this.rowHeight)),n=Math.min(this.totalRows-1,Math.ceil((this.scrollTop+e)/this.rowHeight)-1);return{start:t,end:Math.max(t,n)}}getScrollTopForRow(e){return e*this.rowHeight*this.scrollRatio}getRowIndexAtDisplayY(e,t){let n=e+(this.scrollRatio<1?t/this.scrollRatio:t);return Math.floor(n/this.rowHeight)}getRowData(e){return this.cachedRows.get(e)}async refresh(){await this.fetchData(),this.slotPool.refreshAllSlots(),this.emitContentSize();let e=this.getVisibleRowRange();this.emit({type:`UPDATE_VISIBLE_RANGE`,start:e.start,end:e.end})}refreshSlotData(){this.slotPool.refreshAllSlots()}async setDataSource(e){this.dataSource=e,await this.refresh()}setColumns(e){this.columns=e,this.computeColumnPositions(),this.emitContentSize(),this.emitHeaders(),this.slotPool.syncSlots()}};function s(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r??null}function c(e,t){if(e==null&&t==null)return 0;if(e==null)return 1;if(t==null)return-1;let n=Number(e),r=Number(t);return!isNaN(n)&&!isNaN(r)?n-r:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t))}function l(e,t){return[...e].sort((e,n)=>{for(let{colId:r,direction:i}of t){let t=c(s(e,r),s(n,r));if(t!==0)return i===`asc`?t:-t}return 0})}typeof self<`u`&&self.onmessage!==void 0&&(self.onmessage=e=>{let{type:t,id:n,data:r,sortModel:i}=e.data;if(t===`sort`)try{let e=l(r,i);self.postMessage({type:`sorted`,id:n,data:e})}catch(e){self.postMessage({type:`error`,id:n,error:String(e)})}});var u=class{worker=null;workerUrl=null;pendingRequests=new Map;nextRequestId=0;isTerminated=!1;async sortInWorker(e,t){if(this.isTerminated)throw Error(`SortWorkerManager has been terminated`);this.worker||this.initializeWorker();let n=this.nextRequestId++;return new Promise((r,i)=>{this.pendingRequests.set(n,{resolve:r,reject:i});let a={type:`sort`,id:n,data:e,sortModel:t};this.worker.postMessage(a)})}async sortIndices(e,t){if(this.isTerminated)throw Error(`SortWorkerManager has been terminated`);this.worker||this.initializeWorker();let n=this.nextRequestId++,r=new Float64Array(e);return new Promise((e,i)=>{this.pendingRequests.set(n,{resolve:e,reject:i});let a={type:`sortIndices`,id:n,values:r,direction:t};this.worker.postMessage(a,[r.buffer])})}async sortMultiColumn(e,t){if(this.isTerminated)throw Error(`SortWorkerManager has been terminated`);this.worker||this.initializeWorker();let n=this.nextRequestId++,r=e.map(e=>new Float64Array(e)),i=new Int8Array(t.map(e=>e===`asc`?1:-1));return new Promise((e,t)=>{this.pendingRequests.set(n,{resolve:e,reject:t});let a={type:`sortMultiColumn`,id:n,columns:r,directions:i},o=r.map(e=>e.buffer);o.push(i.buffer),this.worker.postMessage(a,o)})}async sortStringHashes(e,t,n){if(this.isTerminated)throw Error(`SortWorkerManager has been terminated`);this.worker||this.initializeWorker();let r=this.nextRequestId++;return new Promise((i,a)=>{this.pendingRequests.set(r,{resolve:e=>{let{indices:r,collisionRuns:a}=e;a.length>0&&this.resolveCollisions(r,a,n,t),i(r)},reject:a});let o={type:`sortStringHashes`,id:r,hashChunks:e,direction:t},s=e.map(e=>e.buffer);this.worker.postMessage(o,s)})}resolveCollisions(e,t,n,r){let i=r===`asc`?1:-1;for(let r=0;r<t.length;r+=2){let a=t[r],o=t[r+1],s=Array.from(e.slice(a,o)),c=n[s[0]],l=!0;for(let e=1;e<s.length;e++)if(n[s[e]]!==c){l=!1;break}if(!l){s.sort((e,t)=>i*n[e].localeCompare(n[t]));for(let t=0;t<s.length;t++)e[a+t]=s[t]}}}initializeWorker(){if(typeof Worker>`u`)throw Error(`Web Workers are not available in this environment`);let e=new Blob([`
|
|
2
|
+
`);try{await navigator.clipboard.writeText(t)}catch{let e=document.createElement(`textarea`);e.value=t,e.style.position=`fixed`,e.style.left=`-9999px`,document.body.appendChild(e),e.select(),document.execCommand(`copy`),document.body.removeChild(e)}}clampPosition(e){let t=this.options.getRowCount(),n=this.options.getColumnCount();return{row:Math.max(0,Math.min(e.row,t-1)),col:Math.max(0,Math.min(e.col,n-1))}}},t=class{state=null;options;listeners=[];constructor(e){this.options=e}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e)}getState(){return this.state?{...this.state}:null}isActive(){return this.state!==null}startFillDrag(e){this.state={sourceRange:e,targetRow:e.endRow,targetCol:e.endCol},this.emit({type:`START_FILL`,sourceRange:e})}updateFillDrag(e,t){if(!this.state)return;let n=this.options.getRowCount(),r=this.options.getColumnCount();e=Math.max(0,Math.min(e,n-1)),t=Math.max(0,Math.min(t,r-1)),this.state.targetRow=e,this.state.targetCol=t,this.emit({type:`UPDATE_FILL`,targetRow:e,targetCol:t})}commitFillDrag(){if(!this.state)return;let{sourceRange:e,targetRow:t,targetCol:n}=this.state,r=this.calculateFilledCells(e,t,n);for(let{row:e,col:t,value:n}of r)this.options.setCellValue(e,t,n);this.emit({type:`COMMIT_FILL`,filledCells:r}),this.state=null}cancelFillDrag(){this.state&&(this.state=null,this.emit({type:`CANCEL_FILL`}))}calculateFilledCells(e,t,n){let r=[],i=Math.min(e.startRow,e.endRow),a=Math.max(e.startRow,e.endRow),o=Math.min(e.startCol,e.endCol),s=Math.max(e.startCol,e.endCol),c=t>a,l=t<i;if(c||l)for(let e=o;e<=s;e++){let n=this.getSourceColumnValues(i,a,e),o=this.detectPattern(n);if(c)for(let i=a+1;i<=t;i++){let t=i-a-1,s=this.applyPattern(o,n,t);r.push({row:i,col:e,value:s})}else if(l)for(let a=i-1;a>=t;a--){let t=i-a-1,s=this.applyPattern(o,n,t,!0);r.push({row:a,col:e,value:s})}}return r}getSourceColumnValues(e,t,n){let r=[];for(let i=e;i<=t;i++)r.push(this.options.getCellValue(i,n));return r}detectPattern(e){if(e.length===0)return{type:`constant`,value:null};if(e.length===1)return{type:`constant`,value:e[0]??null};let t=e.map(e=>typeof e==`number`?e:Number(e));if(t.every(e=>!isNaN(e))){let e=[];for(let n=1;n<t.length;n++)e.push(t[n]-t[n-1]);if(e.every(t=>t===e[0])&&e[0]!==void 0)return{type:`arithmetic`,start:t[0],step:e[0]}}return{type:`repeat`,values:e}}applyPattern(e,t,n,r=!1){switch(e.type){case`constant`:return e.value;case`arithmetic`:{let i=r?-(n+1):n+1;return(r?e.start:e.start+e.step*(t.length-1))+e.step*i}case`repeat`:{let t=e.values.length;if(t===0)return null;if(r){let r=(t-1-n%t+t)%t;return e.values[r]??null}return e.values[n%t]??null}}}},n=class{state={slots:new Map,rowToSlot:new Map,nextSlotId:0};options;listeners=[];batchListeners=[];constructor(e){this.options=e}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onBatchInstruction(e){return this.batchListeners.push(e),()=>{this.batchListeners=this.batchListeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e);for(let t of this.batchListeners)t([e])}emitBatch(e){if(e.length!==0){for(let t of this.batchListeners)t(e);for(let t of e)for(let e of this.listeners)e(t)}}getSlotForRow(e){return this.state.rowToSlot.get(e)}getSlots(){return this.state.slots}syncSlots(){let e=this.options.getScrollTop(),t=this.options.getRowHeight(),n=this.options.getViewportHeight(),r=this.options.getTotalRows(),i=this.options.getOverscan(),a=Math.max(0,Math.floor(e/t)-i),o=Math.min(r-1,Math.ceil((e+n)/t)+i);if(r===0||o<a){this.destroyAllSlots();return}let s=new Set;for(let e=a;e<=o;e++)s.add(e);let c=[],l=[];for(let[e,t]of this.state.slots)s.has(t.rowIndex)?s.delete(t.rowIndex):(l.push(e),this.state.rowToSlot.delete(t.rowIndex));let u=Array.from(s);for(let e=0;e<u.length;e++){let t=u[e],n=this.options.getRowData(t);if(e<l.length){let r=l[e],i=this.state.slots.get(r),a=this.getRowTranslateY(t);i.rowIndex=t,i.rowData=n??{},i.translateY=a,this.state.rowToSlot.set(t,r),c.push({type:`ASSIGN_SLOT`,slotId:r,rowIndex:t,rowData:n??{}}),c.push({type:`MOVE_SLOT`,slotId:r,translateY:a})}else{let e=`slot-${this.state.nextSlotId++}`,r=this.getRowTranslateY(t),i={slotId:e,rowIndex:t,rowData:n??{},translateY:r};this.state.slots.set(e,i),this.state.rowToSlot.set(t,e),c.push({type:`CREATE_SLOT`,slotId:e}),c.push({type:`ASSIGN_SLOT`,slotId:e,rowIndex:t,rowData:n??{}}),c.push({type:`MOVE_SLOT`,slotId:e,translateY:r})}}for(let e=u.length;e<l.length;e++){let t=l[e];this.state.slots.delete(t),c.push({type:`DESTROY_SLOT`,slotId:t})}for(let[e,t]of this.state.slots){let n=this.getRowTranslateY(t.rowIndex);t.translateY!==n&&(t.translateY=n,c.push({type:`MOVE_SLOT`,slotId:e,translateY:n}))}this.emitBatch(c)}destroyAllSlots(){let e=[];for(let t of this.state.slots.keys())e.push({type:`DESTROY_SLOT`,slotId:t});this.state.slots.clear(),this.state.rowToSlot.clear(),this.emitBatch(e)}refreshAllSlots(){let e=[],t=this.options.getTotalRows();for(let[n,r]of this.state.slots)if(r.rowIndex>=0&&r.rowIndex<t){let t=this.options.getRowData(r.rowIndex),i=this.getRowTranslateY(r.rowIndex);r.rowData=t??{},r.translateY=i,e.push({type:`ASSIGN_SLOT`,slotId:n,rowIndex:r.rowIndex,rowData:t??{}}),e.push({type:`MOVE_SLOT`,slotId:n,translateY:i})}this.emitBatch(e),this.syncSlots()}updateSlot(e){let t=this.state.rowToSlot.get(e);if(t){let n=this.options.getRowData(e);n&&this.emit({type:`ASSIGN_SLOT`,slotId:t,rowIndex:e,rowData:n})}}getRowTranslateY(e){let t=this.options.getRowHeight(),n=this.options.getHeaderHeight(),r=this.options.getScrollRatio(),i=this.options.getVirtualContentHeight(),a=this.options.getScrollTop(),o=e*t+n;if(r>=1)return o;let s=a,c=o-(s-s*r);return Math.max(0,Math.min(c,i))}},r=class{editState=null;options;listeners=[];constructor(e){this.options=e}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e)}getState(){return this.editState?{...this.editState}:null}isEditing(){return this.editState!==null}isEditingCell(e,t){return this.editState!==null&&this.editState.row===e&&this.editState.col===t}startEdit(e,t){let n=this.options.getColumn(t);if(!n||n.editable!==!0)return!1;let r=this.options.getCellValue(e,t);return this.editState={row:e,col:t,initialValue:r,currentValue:r},this.emit({type:`START_EDIT`,row:e,col:t,initialValue:r}),!0}updateValue(e){this.editState&&(this.editState.currentValue=e)}commit(){if(!this.editState)return;let{row:e,col:t,currentValue:n}=this.editState;this.options.setCellValue(e,t,n),this.emit({type:`COMMIT_EDIT`,row:e,col:t,value:n}),this.editState=null,this.emit({type:`STOP_EDIT`}),this.options.onCommit?.(e,t,n)}cancel(){this.editState=null,this.emit({type:`STOP_EDIT`})}},i=class{core;deps;isDraggingSelection=!1;isDraggingFill=!1;fillSourceRange=null;fillTarget=null;constructor(e,t){this.core=e,this.deps=t}updateDeps(e){this.deps={...this.deps,...e}}getDragState(){return{isDragging:this.isDraggingSelection||this.isDraggingFill,dragType:this.isDraggingFill?`fill`:this.isDraggingSelection?`selection`:null,fillSourceRange:this.fillSourceRange,fillTarget:this.fillTarget}}handleCellMouseDown(e,t,n){return n.button!==0||this.core.getEditState()!==null?{preventDefault:!1,stopPropagation:!1}:(this.core.selection.startSelection({row:e,col:t},{shift:n.shiftKey,ctrl:n.ctrlKey||n.metaKey}),{preventDefault:!1,stopPropagation:!1,focusContainer:!0,startDrag:n.shiftKey?void 0:`selection`})}handleCellDoubleClick(e,t){this.core.startEdit(e,t)}handleFillHandleMouseDown(e,t,n){if(!e&&!t)return{preventDefault:!1,stopPropagation:!1};let r=t??{startRow:e.row,startCol:e.col,endRow:e.row,endCol:e.col};return this.core.fill.startFillDrag(r),this.fillSourceRange=r,this.fillTarget={row:Math.max(r.startRow,r.endRow),col:Math.max(r.startCol,r.endCol)},this.isDraggingFill=!0,{preventDefault:!0,stopPropagation:!0,startDrag:`fill`}}handleHeaderClick(e,t){let n=this.core.getSortModel().find(t=>t.colId===e)?.direction,r=n==null?`asc`:n===`asc`?`desc`:null;this.core.setSort(e,r,t)}startSelectionDrag(){this.isDraggingSelection=!0}handleDragMove(e,t){if(!this.isDraggingSelection&&!this.isDraggingFill)return null;let{top:n,left:r,width:i,height:a,scrollTop:o,scrollLeft:s}=t,c=this.deps.getHeaderHeight(),l=this.deps.getColumnPositions(),u=this.deps.getColumnCount(),d=e.clientX-r+s,f=e.clientY-n-c,p=Math.max(0,Math.min(this.core.getRowIndexAtDisplayY(f,o),this.core.getRowCount()-1)),m=Math.max(0,Math.min(this.findColumnAtX(d,l),u-1));this.isDraggingSelection&&this.core.selection.startSelection({row:p,col:m},{shift:!0}),this.isDraggingFill&&(this.core.fill.updateFillDrag(p,m),this.fillTarget={row:p,col:m});let h=e.clientY-n,g=e.clientX-r;return{targetRow:p,targetCol:m,autoScroll:this.calculateAutoScroll(h,g,a,i,c)}}handleDragEnd(){this.isDraggingFill&&(this.core.fill.commitFillDrag(),this.core.refreshSlotData()),this.isDraggingSelection=!1,this.isDraggingFill=!1,this.fillSourceRange=null,this.fillTarget=null}handleWheel(e,t,n){return this.core.isScalingActive()?{dy:e*n,dx:t*n}:null}handleKeyDown(e,t,n,r){if(r||n&&e.key!==`Enter`&&e.key!==`Escape`&&e.key!==`Tab`)return{preventDefault:!1};let{selection:i}=this.core,a=e.shiftKey,o=e.ctrlKey||e.metaKey,s=(e=>{switch(e){case`ArrowUp`:return`up`;case`ArrowDown`:return`down`;case`ArrowLeft`:return`left`;case`ArrowRight`:return`right`;default:return null}})(e.key);if(s)return i.moveFocus(s,a),{preventDefault:!0,scrollToCell:i.getActiveCell()??void 0};switch(e.key){case`Enter`:return n?this.core.commitEdit():t&&this.core.startEdit(t.row,t.col),{preventDefault:!0};case`Escape`:return n?this.core.cancelEdit():i.clearSelection(),{preventDefault:!0};case`Tab`:return n&&this.core.commitEdit(),i.moveFocus(a?`left`:`right`,!1),{preventDefault:!0};case`a`:if(o)return i.selectAll(),{preventDefault:!0};break;case`c`:if(o)return i.copySelectionToClipboard(),{preventDefault:!0};break;case`F2`:return t&&!n&&this.core.startEdit(t.row,t.col),{preventDefault:!0};case`Delete`:case`Backspace`:if(t&&!n)return this.core.startEdit(t.row,t.col),{preventDefault:!0};break;default:t&&!n&&!o&&e.key.length===1&&this.core.startEdit(t.row,t.col);break}return{preventDefault:!1}}findColumnAtX(e,t){for(let n=0;n<t.length-1;n++)if(e>=t[n]&&e<t[n+1])return n;return e>=t[t.length-1]?t.length-2:0}calculateAutoScroll(e,t,n,r,i){let a=0,o=0;return e<40+i?o=-10:e>n-40&&(o=10),t<40?a=-10:t>r-40&&(a=10),a!==0||o!==0?{dx:a,dy:o}:null}};const a=1e7;var o=class{columns;dataSource;rowHeight;headerHeight;overscan;sortingEnabled;scrollTop=0;scrollLeft=0;viewportWidth=800;viewportHeight=600;cachedRows=new Map;totalRows=0;currentPageIndex=0;pageSize=1e6;sortModel=[];filterModel={};openFilterColIndex=null;selection;fill;input;slotPool;editManager;columnPositions=[];listeners=[];batchListeners=[];naturalContentHeight=0;virtualContentHeight=0;scrollRatio=1;constructor(a){this.columns=a.columns,this.dataSource=a.dataSource,this.rowHeight=a.rowHeight,this.headerHeight=a.headerHeight??a.rowHeight,this.overscan=a.overscan??3,this.sortingEnabled=a.sortingEnabled??!0,this.computeColumnPositions(),this.selection=new e({getRowCount:()=>this.totalRows,getColumnCount:()=>this.columns.length,getCellValue:(e,t)=>this.getCellValue(e,t),getRowData:e=>this.cachedRows.get(e),getColumn:e=>this.columns[e]}),this.selection.onInstruction(e=>this.emit(e)),this.fill=new t({getRowCount:()=>this.totalRows,getColumnCount:()=>this.columns.length,getCellValue:(e,t)=>this.getCellValue(e,t),getColumn:e=>this.columns[e],setCellValue:(e,t,n)=>this.setCellValue(e,t,n)}),this.fill.onInstruction(e=>this.emit(e)),this.slotPool=new n({getRowHeight:()=>this.rowHeight,getHeaderHeight:()=>this.headerHeight,getOverscan:()=>this.overscan,getScrollTop:()=>this.scrollTop,getViewportHeight:()=>this.viewportHeight,getTotalRows:()=>this.totalRows,getScrollRatio:()=>this.scrollRatio,getVirtualContentHeight:()=>this.virtualContentHeight,getRowData:e=>this.cachedRows.get(e)}),this.slotPool.onBatchInstruction(e=>this.emitBatch(e)),this.editManager=new r({getColumn:e=>this.columns[e],getCellValue:(e,t)=>this.getCellValue(e,t),setCellValue:(e,t,n)=>this.setCellValue(e,t,n),onCommit:e=>{this.slotPool.updateSlot(e)}}),this.editManager.onInstruction(e=>this.emit(e)),this.input=new i(this,{getHeaderHeight:()=>this.headerHeight,getRowHeight:()=>this.rowHeight,getColumnPositions:()=>this.columnPositions,getColumnCount:()=>this.columns.length})}onInstruction(e){return this.listeners.push(e),()=>{this.listeners=this.listeners.filter(t=>t!==e)}}onBatchInstruction(e){return this.batchListeners.push(e),()=>{this.batchListeners=this.batchListeners.filter(t=>t!==e)}}emit(e){for(let t of this.listeners)t(e);for(let t of this.batchListeners)t([e])}emitBatch(e){if(e.length!==0){for(let t of this.batchListeners)t(e);for(let t of e)for(let e of this.listeners)e(t)}}async initialize(){await this.fetchData(),this.slotPool.syncSlots(),this.emitContentSize(),this.emitHeaders()}setViewport(e,t,n,r){let i=this.scrollRatio<1?e/this.scrollRatio:e,a=this.viewportWidth!==n||this.viewportHeight!==r;if(!(this.scrollTop!==i||this.scrollLeft!==t||a))return;this.scrollTop=i,this.scrollLeft=t,this.viewportWidth=n,this.viewportHeight=r,this.slotPool.syncSlots();let o=this.getVisibleRowRange();this.emit({type:`UPDATE_VISIBLE_RANGE`,start:o.start,end:o.end}),a&&this.emitContentSize()}async fetchData(){this.emit({type:`DATA_LOADING`});try{let e={pagination:{pageIndex:this.currentPageIndex,pageSize:this.pageSize},sort:this.sortModel.length>0?this.sortModel:void 0,filter:Object.keys(this.filterModel).length>0?this.filterModel:void 0},t=await this.dataSource.fetch(e);this.cachedRows.clear(),t.rows.forEach((e,t)=>{this.cachedRows.set(this.currentPageIndex*this.pageSize+t,e)}),this.totalRows=t.totalRows,t.totalRows>t.rows.length&&this.currentPageIndex===0&&await this.fetchAllData(),this.emit({type:`DATA_LOADED`,totalRows:this.totalRows})}catch(e){this.emit({type:`DATA_ERROR`,error:e instanceof Error?e.message:String(e)})}}async fetchAllData(){let e=Math.ceil(this.totalRows/this.pageSize);for(let t=1;t<e;t++){let e={pagination:{pageIndex:t,pageSize:this.pageSize},sort:this.sortModel.length>0?this.sortModel:void 0,filter:Object.keys(this.filterModel).length>0?this.filterModel:void 0};(await this.dataSource.fetch(e)).rows.forEach((e,n)=>{this.cachedRows.set(t*this.pageSize+n,e)})}}async setSort(e,t,n=!1){if(!this.sortingEnabled||this.columns.find(t=>(t.colId??t.field)===e)?.sortable===!1)return;let r=this.sortModel.findIndex(t=>t.colId===e);n?t===null?r>=0&&this.sortModel.splice(r,1):r>=0?this.sortModel[r].direction=t:this.sortModel.push({colId:e,direction:t}):this.sortModel=t===null?[]:[{colId:e,direction:t}],await this.fetchData(),this.slotPool.refreshAllSlots(),this.emitHeaders()}async setFilter(e,t){this.columns.find(t=>(t.colId??t.field)===e)?.filterable!==!1&&(t===null||typeof t==`string`&&t.trim()===``||typeof t==`object`&&t.conditions&&t.conditions.length===0?delete this.filterModel[e]:typeof t==`string`?this.filterModel[e]={conditions:[{type:`text`,operator:`contains`,value:t}],combination:`and`}:this.filterModel[e]=t,await this.fetchData(),this.slotPool.refreshAllSlots(),this.emitContentSize(),this.emitHeaders())}hasActiveFilter(e){let t=this.filterModel[e];return t?t.conditions.length>0:!1}isColumnSortable(e){return this.sortingEnabled?this.columns[e]?.sortable!==!1:!1}isColumnFilterable(e){return this.columns[e]?.filterable!==!1}getDistinctValuesForColumn(e,t=500){let n=this.columns.find(t=>(t.colId??t.field)===e);if(!n)return[];let r=new Map;for(let e of this.cachedRows.values()){let i=this.getFieldValue(e,n.field);if(Array.isArray(i)){let e=[...i].sort((e,t)=>String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})),n=JSON.stringify(e);if(!r.has(n)&&(r.set(n,e),r.size>=t))break}else{let e=JSON.stringify(i);if(!r.has(e)&&(r.set(e,i),r.size>=t))break}}let i=Array.from(r.values());return i.sort((e,t)=>{let n=Array.isArray(e)?e.join(`, `):String(e??``),r=Array.isArray(t)?t.join(`, `):String(t??``);return n.localeCompare(r,void 0,{numeric:!0,sensitivity:`base`})}),i}openFilterPopup(e,t){if(this.openFilterColIndex===e){this.closeFilterPopup();return}let n=this.columns[e];if(!n||!this.isColumnFilterable(e))return;let r=n.colId??n.field,i=this.getDistinctValuesForColumn(r);this.openFilterColIndex=e,this.emit({type:`OPEN_FILTER_POPUP`,colIndex:e,column:n,anchorRect:t,distinctValues:i,currentFilter:this.filterModel[r]})}closeFilterPopup(){this.openFilterColIndex=null,this.emit({type:`CLOSE_FILTER_POPUP`})}getSortModel(){return[...this.sortModel]}getFilterModel(){return{...this.filterModel}}startEdit(e,t){this.editManager.startEdit(e,t)}updateEditValue(e){this.editManager.updateValue(e)}commitEdit(){this.editManager.commit()}cancelEdit(){this.editManager.cancel()}getEditState(){return this.editManager.getState()}getCellValue(e,t){let n=this.cachedRows.get(e);if(!n)return null;let r=this.columns[t];return r?this.getFieldValue(n,r.field):null}setCellValue(e,t,n){let r=this.cachedRows.get(e);if(!r||typeof r!=`object`)return;let i=this.columns[t];i&&this.setFieldValue(r,i.field,n)}getFieldValue(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r??null}setFieldValue(e,t,n){let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];t in i||(i[t]={}),i=i[t]}let a=r[r.length-1];i[a]=n}computeColumnPositions(){this.columnPositions=[0];let e=0;for(let t of this.columns)e+=t.width,this.columnPositions.push(e)}emitContentSize(){let e=this.columnPositions[this.columnPositions.length-1]??0;this.naturalContentHeight=this.totalRows*this.rowHeight+this.headerHeight,this.naturalContentHeight>a?(this.virtualContentHeight=a,this.scrollRatio=a/this.naturalContentHeight):(this.virtualContentHeight=this.naturalContentHeight,this.scrollRatio=1),this.emit({type:`SET_CONTENT_SIZE`,width:e,height:this.virtualContentHeight,viewportWidth:this.viewportWidth})}emitHeaders(){let e=new Map;this.sortModel.forEach((t,n)=>{e.set(t.colId,{direction:t.direction,index:n+1})});for(let t=0;t<this.columns.length;t++){let n=this.columns[t],r=n.colId??n.field,i=e.get(r);this.emit({type:`UPDATE_HEADER`,colIndex:t,column:n,sortDirection:i?.direction,sortIndex:i?.index,sortable:this.isColumnSortable(t),filterable:this.isColumnFilterable(t),hasFilter:this.hasActiveFilter(r)})}}getColumns(){return this.columns}getColumnPositions(){return[...this.columnPositions]}getRowCount(){return this.totalRows}getRowHeight(){return this.rowHeight}getHeaderHeight(){return this.headerHeight}getTotalWidth(){return this.columnPositions[this.columnPositions.length-1]??0}getTotalHeight(){return this.virtualContentHeight||this.totalRows*this.rowHeight+this.headerHeight}isScalingActive(){return this.scrollRatio<1}getNaturalHeight(){return this.naturalContentHeight||this.totalRows*this.rowHeight+this.headerHeight}getScrollRatio(){return this.scrollRatio}getVisibleRowRange(){let e=this.viewportHeight-this.headerHeight,t=Math.max(0,Math.floor(this.scrollTop/this.rowHeight)),n=Math.min(this.totalRows-1,Math.ceil((this.scrollTop+e)/this.rowHeight)-1);return{start:t,end:Math.max(t,n)}}getScrollTopForRow(e){return e*this.rowHeight*this.scrollRatio}getRowIndexAtDisplayY(e,t){let n=e+(this.scrollRatio<1?t/this.scrollRatio:t);return Math.floor(n/this.rowHeight)}getRowData(e){return this.cachedRows.get(e)}async refresh(){await this.fetchData(),this.slotPool.refreshAllSlots(),this.emitContentSize();let e=this.getVisibleRowRange();this.emit({type:`UPDATE_VISIBLE_RANGE`,start:e.start,end:e.end})}refreshSlotData(){this.slotPool.refreshAllSlots()}async setDataSource(e){this.dataSource=e,await this.refresh()}setColumns(e){this.columns=e,this.computeColumnPositions(),this.emitContentSize(),this.emitHeaders(),this.slotPool.syncSlots()}};function s(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r??null}function c(e,t){if(e==null&&t==null)return 0;if(e==null)return 1;if(t==null)return-1;let n=Number(e),r=Number(t);return!isNaN(n)&&!isNaN(r)?n-r:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t))}function l(e,t){return[...e].sort((e,n)=>{for(let{colId:r,direction:i}of t){let t=c(s(e,r),s(n,r));if(t!==0)return i===`asc`?t:-t}return 0})}typeof self<`u`&&self.onmessage!==void 0&&(self.onmessage=e=>{let{type:t,id:n,data:r,sortModel:i}=e.data;if(t===`sort`)try{let e=l(r,i);self.postMessage({type:`sorted`,id:n,data:e})}catch(e){self.postMessage({type:`error`,id:n,error:String(e)})}});var u=class{worker=null;workerUrl=null;pendingRequests=new Map;nextRequestId=0;isTerminated=!1;async sortInWorker(e,t){if(this.isTerminated)throw Error(`SortWorkerManager has been terminated`);this.worker||this.initializeWorker();let n=this.nextRequestId++;return new Promise((r,i)=>{this.pendingRequests.set(n,{resolve:r,reject:i});let a={type:`sort`,id:n,data:e,sortModel:t};this.worker.postMessage(a)})}async sortIndices(e,t){if(this.isTerminated)throw Error(`SortWorkerManager has been terminated`);this.worker||this.initializeWorker();let n=this.nextRequestId++,r=new Float64Array(e);return new Promise((e,i)=>{this.pendingRequests.set(n,{resolve:e,reject:i});let a={type:`sortIndices`,id:n,values:r,direction:t};this.worker.postMessage(a,[r.buffer])})}async sortMultiColumn(e,t){if(this.isTerminated)throw Error(`SortWorkerManager has been terminated`);this.worker||this.initializeWorker();let n=this.nextRequestId++,r=e.map(e=>new Float64Array(e)),i=new Int8Array(t.map(e=>e===`asc`?1:-1));return new Promise((e,t)=>{this.pendingRequests.set(n,{resolve:e,reject:t});let a={type:`sortMultiColumn`,id:n,columns:r,directions:i},o=r.map(e=>e.buffer);o.push(i.buffer),this.worker.postMessage(a,o)})}async sortStringHashes(e,t,n){if(this.isTerminated)throw Error(`SortWorkerManager has been terminated`);this.worker||this.initializeWorker();let r=this.nextRequestId++;return new Promise((i,a)=>{this.pendingRequests.set(r,{resolve:e=>{let{indices:r,collisionRuns:a}=e;a.length>0&&this.resolveCollisions(r,a,n,t),i(r)},reject:a});let o={type:`sortStringHashes`,id:r,hashChunks:e,direction:t},s=e.map(e=>e.buffer);this.worker.postMessage(o,s)})}resolveCollisions(e,t,n,r){let i=r===`asc`?1:-1;for(let r=0;r<t.length;r+=2){let a=t[r],o=t[r+1],s=Array.from(e.slice(a,o)),c=n[s[0]],l=!0;for(let e=1;e<s.length;e++)if(n[s[e]]!==c){l=!1;break}if(!l){s.sort((e,t)=>i*n[e].localeCompare(n[t]));for(let t=0;t<s.length;t++)e[a+t]=s[t]}}}initializeWorker(){if(typeof Worker>`u`)throw Error(`Web Workers are not available in this environment`);let e=new Blob([`
|
|
3
3
|
// Inline sort worker code
|
|
4
4
|
function getFieldValue(row, field) {
|
|
5
5
|
const parts = field.split(".");
|
|
@@ -181,7 +181,7 @@ self.onmessage = function(e) {
|
|
|
181
181
|
}
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
|
-
`],{type:`application/javascript`});this.workerUrl=URL.createObjectURL(e),this.worker=new Worker(this.workerUrl),this.worker.onmessage=e=>{let{id:t}=e.data,n=this.pendingRequests.get(t);n&&(this.pendingRequests.delete(t),e.data.type===`sorted`?n.resolve(e.data.data):e.data.type===`sortedIndices`||e.data.type===`sortedMultiColumn`?n.resolve(e.data.indices):e.data.type===`sortedStringHashes`?n.resolve({indices:e.data.indices,collisionRuns:e.data.collisionRuns}):e.data.type===`error`&&n.reject(Error(e.data.error)))},this.worker.onerror=e=>{for(let[t,n]of this.pendingRequests)n.reject(Error(`Worker error: ${e.message}`)),this.pendingRequests.delete(t)}}terminate(){this.worker&&=(this.worker.terminate(),null),this.workerUrl&&=(URL.revokeObjectURL(this.workerUrl),null);for(let[,e]of this.pendingRequests)e.reject(Error(`Worker terminated`));this.pendingRequests.clear(),this.isTerminated=!0}isAvailable(){return!this.isTerminated&&typeof Worker<`u`}};let d=null;function f(){return d||=new u,d}function p(){d&&=(d.terminate(),null)}function m(e){let t=e.toLowerCase(),n=Math.min(t.length,10),r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e),i;i=n>=97&&n<=122?n-97:n>=48&&n<=57?n-48+26:0,r=r*36+i}for(let e=n;e<10;e++)r*=36;return r}function h(e){let t=e.toLowerCase(),n=[];for(let e=0;e<3;e++){let r=e*10,i=0;for(let e=0;e<10;e++){let n=r+e,a=n<t.length?t.charCodeAt(n):0,o;o=a>=97&&a<=122?a-97:a>=48&&a<=57?a-48+26:0,i=i*36+o}n.push(i)}return n}function g(e){if(e==null)return Number.MAX_VALUE;if(Array.isArray(e))return e.length===0?Number.MAX_VALUE:m(e.join(`, `));if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();if(typeof e==`string`)return m(e);let t=Number(e);return isNaN(t)?0:t}function ee(e,t){let n=e==null||Array.isArray(e)&&e.length===0,r=t==null||Array.isArray(t)&&t.length===0;if(n&&r)return 0;if(n)return 1;if(r)return-1;if(Array.isArray(e)||Array.isArray(t)){let n=Array.isArray(e)?e.join(`, `):String(e??``),r=Array.isArray(t)?t.join(`, `):String(t??``);return n.localeCompare(r)}let i=Number(e),a=Number(t);return!isNaN(i)&&!isNaN(a)?i-a:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t))}function te(e,t,n){return[...e].sort((e,r)=>{for(let{colId:i,direction:a}of t){let t=ee(n(e,i),n(r,i));if(t!==0)return a===`asc`?t:-t}return 0})}function _(e,t,n){let r=Object.entries(t).filter(([,e])=>typeof e==`string`?e.trim()!==``:e.conditions&&e.conditions.length>0);return r.length===0?e:e.filter(e=>{for(let[t,i]of r){let r=n(e,t);if(typeof i==`string`){if(!String(r??``).toLowerCase().includes(i.toLowerCase()))return!1;continue}if(!v(r,i))return!1}return!0})}function v(e,t){if(t.conditions.length===0)return!0;let n=t.conditions[0];if(!n)return!0;let r=y(e,n);for(let n=1;n<t.conditions.length;n++){let i=t.conditions[n-1],a=t.conditions[n],o=i.nextOperator??t.combination,s=y(e,a);o===`and`?r&&=s:r||=s}return r}function y(e,t){switch(t.type){case`text`:return ne(e,t);case`number`:return b(e,t);case`date`:return S(e,t);default:return!0}}function ne(e,t){let n=e==null||e===``||Array.isArray(e)&&e.length===0;if(t.selectedValues&&t.selectedValues.size>0){let r=t.includeBlank===!0&&n;if(Array.isArray(e)){let n=[...e].sort((e,t)=>String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})).join(`, `);return t.selectedValues.has(n)||r}let i=String(e??``);return t.selectedValues.has(i)||r}let r=String(e??``).toLowerCase(),i=String(t.value??``).toLowerCase();switch(t.operator){case`contains`:return r.includes(i);case`notContains`:return!r.includes(i);case`equals`:return r===i;case`notEquals`:return r!==i;case`startsWith`:return r.startsWith(i);case`endsWith`:return r.endsWith(i);case`blank`:return n;case`notBlank`:return!n;default:return!0}}function b(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=Number(e);if(isNaN(r))return!1;let i=t.value??0,a=t.valueTo??0;switch(t.operator){case`=`:return r===i;case`!=`:return r!==i;case`>`:return r>i;case`<`:return r<i;case`>=`:return r>=i;case`<=`:return r<=i;case`between`:return r>=i&&r<=a;default:return!0}}function x(e,t){return e.toDateString()===t.toDateString()}function S(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=e instanceof Date?e:new Date(String(e));if(isNaN(r.getTime()))return!1;let i=t.value instanceof Date?t.value:new Date(String(t.value??``)),a=t.valueTo instanceof Date?t.valueTo:new Date(String(t.valueTo??``)),o=r.getTime(),s=i.getTime(),c=a.getTime();switch(t.operator){case`=`:return x(r,i);case`!=`:return!x(r,i);case`>`:return o>s;case`<`:return o<s;case`between`:return o>=s&&o<=c;default:return!0}}function re(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r??null}function C(e,t={}){let{getFieldValue:n=re,useWorker:r=!0}=t,i=r?new u:null;return{async fetch(t){let r=[...e];if(t.filter&&Object.keys(t.filter).length>0&&(r=_(r,t.filter,n)),t.sort&&t.sort.length>0)if(i&&i.isAvailable()&&r.length>=2e5){let e;if(t.sort.length===1){let{colId:a,direction:o}=t.sort[0],s=!1;for(let e of r){let t=n(e,a);if(t!=null){s=typeof t==`string`||Array.isArray(t);break}}if(s){let t=[],s=Array.from({length:3},()=>[]);for(let e of r){let r=n(e,a),i=r==null?``:Array.isArray(r)?r.join(`, `):String(r);t.push(i);let o=h(i);for(let e=0;e<3;e++)s[e].push(o[e])}let c=s.map(e=>new Float64Array(e));e=await i.sortStringHashes(c,o,t)}else{let t=r.map(e=>g(n(e,a)));e=await i.sortIndices(t,o)}}else{let a=[],o=[];for(let{colId:e,direction:i}of t.sort){let t=r.map(t=>g(n(t,e)));a.push(t),o.push(i)}e=await i.sortMultiColumn(a,o)}let a=Array(r.length);for(let t=0;t<e.length;t++)a[t]=r[e[t]];r=a}else r=te(r,t.sort,n);let a=r.length,{pageIndex:o,pageSize:s}=t.pagination,c=o*s;return{rows:r.slice(c,c+s),totalRows:a}}}}function w(e){return C(e)}function T(e){return{async fetch(t){return e(t)}}}function E(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r??null}function D(e,t,n){let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];if(typeof i!=`object`||!i)return;i=i[t]}typeof i==`object`&&i&&(i[r[r.length-1]]=n)}function O(e){let t=e.toLowerCase(),n=Math.min(t.length,10),r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e),i;i=n>=97&&n<=122?n-97:n>=48&&n<=57?n-48+26:0,r=r*36+i}for(let e=n;e<10;e++)r*=36;return r}function k(e,t){let n=e==null||Array.isArray(e)&&e.length===0,r=t==null||Array.isArray(t)&&t.length===0;if(n&&r)return 0;if(n)return 1;if(r)return-1;if(Array.isArray(e)||Array.isArray(t)){let n=Array.isArray(e)?e.join(`, `):String(e??``),r=Array.isArray(t)?t.join(`, `):String(t??``);return n.localeCompare(r)}let i=Number(e),a=Number(t);return!isNaN(i)&&!isNaN(a)?i-a:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t))}function A(e){if(e==null)return Number.MAX_VALUE;if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();if(typeof e==`string`)return O(e);let t=Number(e);return isNaN(t)?0:t}function ie(e,t){let n=[];for(let r of t.sortModel){let i=A(t.getFieldValue(e,r.colId));n.push(i)}return n}function j(e,t,n){if(!e||!t)return null;for(let r=0;r<n.length;r++){let i=e[r]-t[r];if(i!==0)return n[r].direction===`asc`?i:-i}return 0}function M(e,t,n,r){for(let{colId:i,direction:a}of n){let n=k(r(e,i),r(t,i));if(n!==0)return a===`asc`?n:-n}return 0}function N(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function P(e,t){let n=e==null||e===``||Array.isArray(e)&&e.length===0;if(t.selectedValues&&t.selectedValues.size>0){let r=t.includeBlank===!0&&n;if(Array.isArray(e)){let n=[...e].sort((e,t)=>String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})).join(`, `);return t.selectedValues.has(n)||r}let i=String(e??``);return t.selectedValues.has(i)||r}let r=String(e??``).toLowerCase(),i=String(t.value??``).toLowerCase();switch(t.operator){case`contains`:return r.includes(i);case`notContains`:return!r.includes(i);case`equals`:return r===i;case`notEquals`:return r!==i;case`startsWith`:return r.startsWith(i);case`endsWith`:return r.endsWith(i);case`blank`:return n;case`notBlank`:return!n;default:return!0}}function F(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=typeof e==`number`?e:parseFloat(String(e));if(isNaN(r))return!1;let i=t.value??0,a=t.valueTo??0;switch(t.operator){case`=`:return r===i;case`!=`:return r!==i;case`>`:return r>i;case`<`:return r<i;case`>=`:return r>=i;case`<=`:return r<=i;case`between`:return r>=i&&r<=a;default:return!0}}function I(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=e instanceof Date?e:new Date(String(e));if(isNaN(r.getTime()))return!1;let i=t.value?t.value instanceof Date?t.value:new Date(t.value):new Date,a=t.valueTo?t.valueTo instanceof Date?t.valueTo:new Date(t.valueTo):new Date;switch(t.operator){case`=`:return N(r,i);case`!=`:return!N(r,i);case`>`:return r>i;case`<`:return r<i;case`between`:return r>=i&&r<=a;default:return!0}}function L(e,t){switch(t.type){case`text`:return P(e,t);case`number`:return F(e,t);case`date`:return I(e,t);default:return!0}}function R(e,t){if(!t.conditions||!t.conditions.length)return!0;let n=t.conditions[0];if(!n)return!0;let r=L(e,n);for(let n=1;n<t.conditions.length;n++){let i=t.conditions[n-1],a=t.conditions[n],o=i.nextOperator??t.combination,s=L(e,a);o===`and`?r&&=s:r||=s}return r}function z(e,t,n){let r=Object.entries(t).filter(([,e])=>e!=null);if(r.length===0)return!0;for(let[t,i]of r)if(!R(n(e,t),i))return!1;return!0}var B=class{rows=[];rowById=new Map;sortedIndices=[];sortModel=[];sortModelHash=``;filterModel={};filteredIndices=new Set;distinctValues=new Map;rowSortCache=new Map;options;constructor(e=[],t){this.options={getRowId:t.getRowId,getFieldValue:t.getFieldValue??E},this.setData(e)}setData(e){this.rows=[...e],this.rowById.clear(),this.rowSortCache.clear(),this.distinctValues.clear();for(let e=0;e<this.rows.length;e++){let t=this.rows[e],n=this.options.getRowId(t);this.rowById.set(n,e)}this.rebuildSortedIndices(),this.rebuildFilteredIndices(),this.rebuildDistinctValues()}query(e){e.sort&&this.setSortModel(e.sort),e.filter&&this.setFilterModel(e.filter);let t=this.getVisibleIndices(),n=t.length,{pageIndex:r,pageSize:i}=e.pagination,a=r*i,o=Math.min(a+i,n),s=[];for(let e=a;e<o;e++){let n=t[e];n!==void 0&&s.push(this.rows[n])}return{rows:s,totalRows:n}}getRowById(e){let t=this.rowById.get(e);return t===void 0?void 0:this.rows[t]}getRowByIndex(e){return this.rows[e]}getTotalRowCount(){return this.rows.length}getVisibleRowCount(){return Object.keys(this.filterModel).length===0?this.rows.length:this.filteredIndices.size}getDistinctValues(e){let t=this.distinctValues.get(e);return t?Array.from(t):[]}addRows(e){for(let t of e)this.addRow(t)}addRow(e){let t=this.options.getRowId(e);if(this.rowById.has(t)){console.warn(`Row with ID ${t} already exists. Skipping.`);return}let n=this.rows.length;if(this.rows.push(e),this.rowById.set(t,n),this.updateDistinctValuesForRow(e,`add`),this.sortModel.length>0&&this.computeRowHashes(n,e),this.sortModel.length>0){let e=this.binarySearchInsertPosition(n);this.sortedIndices.splice(e,0,n)}else this.sortedIndices.push(n);this.rowPassesFilter(e)&&this.filteredIndices.add(n)}removeRows(e){let t=[];for(let n of e){let e=this.rowById.get(n);e!==void 0&&t.push(e)}if(t.length!==0){t.sort((e,t)=>t-e);for(let e of t)this.removeRowByIndex(e)}}removeRowByIndex(e){let t=this.rows[e];if(!t)return;let n=this.options.getRowId(t);this.updateDistinctValuesForRow(t,`remove`);let r=this.sortedIndices.indexOf(e);r!==-1&&this.sortedIndices.splice(r,1),this.filteredIndices.delete(e),this.rowSortCache.delete(e),this.rowById.delete(n),this.rows.splice(e,1),this.reindexAfterRemoval(e)}reindexAfterRemoval(e){for(let[t,n]of this.rowById.entries())n>e&&this.rowById.set(t,n-1);for(let t=0;t<this.sortedIndices.length;t++)this.sortedIndices[t]>e&&this.sortedIndices[t]--;let t=new Set;for(let n of this.filteredIndices)n>e?t.add(n-1):t.add(n);this.filteredIndices=t;let n=new Map;for(let[t,r]of this.rowSortCache)t>e?n.set(t-1,r):n.set(t,r);this.rowSortCache=n}updateCell(e,t,n){let r=this.rowById.get(e);if(r===void 0){console.warn(`Row with ID ${e} not found.`);return}let i=this.rows[r],a=this.options.getFieldValue(i,t);if(D(i,t,n),this.updateDistinctValueForField(t,a,n),this.sortModel.some(e=>e.colId===t)&&this.sortModel.length>0){this.computeRowHashes(r,i);let e=this.sortedIndices.indexOf(r);e!==-1&&this.sortedIndices.splice(e,1);let t=this.binarySearchInsertPosition(r);this.sortedIndices.splice(t,0,r)}t in this.filterModel&&(this.rowPassesFilter(i)?this.filteredIndices.add(r):this.filteredIndices.delete(r))}updateRow(e,t){for(let[n,r]of Object.entries(t))this.updateCell(e,n,r)}setSortModel(e){let t=JSON.stringify(e);t!==this.sortModelHash&&(this.sortModelHash=t,this.sortModel=[...e],this.rebuildHashCache(),this.rebuildSortedIndices())}getSortModel(){return[...this.sortModel]}setFilterModel(e){JSON.stringify(e)!==JSON.stringify(this.filterModel)&&(this.filterModel={...e},this.rebuildFilteredIndices())}getFilterModel(){return{...this.filterModel}}rebuildSortedIndices(){this.sortedIndices=Array.from({length:this.rows.length},(e,t)=>t),this.sortModel.length!==0&&this.sortedIndices.sort((e,t)=>this.compareRows(e,t))}rebuildHashCache(){if(this.rowSortCache.clear(),this.sortModel.length!==0)for(let e=0;e<this.rows.length;e++)this.computeRowHashes(e,this.rows[e])}computeRowHashes(e,t){if(this.sortModel.length===0)return;let n=ie(t,{sortModel:this.sortModel,sortModelHash:this.sortModelHash,getFieldValue:this.options.getFieldValue}),r=this.rowSortCache.get(e);r||(r={hashes:new Map},this.rowSortCache.set(e,r)),r.hashes.set(this.sortModelHash,n)}compareRows(e,t){let n=this.rowSortCache.get(e),r=this.rowSortCache.get(t),i=n?.hashes.get(this.sortModelHash),a=r?.hashes.get(this.sortModelHash),o=j(i,a,this.sortModel);return o===null?M(this.rows[e],this.rows[t],this.sortModel,this.options.getFieldValue):o}binarySearchInsertPosition(e){let t=0,n=this.sortedIndices.length;for(;t<n;){let r=t+n>>>1,i=this.sortedIndices[r];this.compareRows(e,i)>0?t=r+1:n=r}return t}rebuildFilteredIndices(){if(this.filteredIndices.clear(),Object.entries(this.filterModel).filter(([,e])=>e!=null).length!==0)for(let e=0;e<this.rows.length;e++)this.rowPassesFilter(this.rows[e])&&this.filteredIndices.add(e)}rowPassesFilter(e){return z(e,this.filterModel,this.options.getFieldValue)}getVisibleIndices(){return Object.entries(this.filterModel).filter(([,e])=>e!=null).length>0?this.sortedIndices.filter(e=>this.filteredIndices.has(e)):this.sortedIndices}rebuildDistinctValues(){this.distinctValues.clear();for(let e of this.rows)this.updateDistinctValuesForRow(e,`add`)}updateDistinctValuesForRow(e,t){if(!(typeof e!=`object`||!e)){for(let[n,r]of Object.entries(e))if(r!=null&&t===`add`){let e=this.distinctValues.get(n);if(e||(e=new Set,this.distinctValues.set(n,e)),Array.isArray(r))for(let t of r)t!=null&&e.add(t);else e.add(r)}}}updateDistinctValueForField(e,t,n){if(n!=null){let t=this.distinctValues.get(e);if(t||(t=new Set,this.distinctValues.set(e,t)),Array.isArray(n))for(let e of n)e!=null&&t.add(e);else t.add(n)}}},V=class{queue=[];debounceTimer=null;pendingPromise=null;options;constructor(e){this.options=e}add(e){e.length!==0&&(this.queue.push({type:`ADD`,rows:e}),this.scheduleProcessing())}remove(e){e.length!==0&&(this.queue.push({type:`REMOVE`,rowIds:e}),this.scheduleProcessing())}updateCell(e,t,n){this.queue.push({type:`UPDATE_CELL`,rowId:e,field:t,value:n}),this.scheduleProcessing()}updateRow(e,t){Object.keys(t).length!==0&&(this.queue.push({type:`UPDATE_ROW`,rowId:e,data:t}),this.scheduleProcessing())}flush(){return this.queue.length===0?Promise.resolve():(this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPromise?new Promise((e,t)=>{let n=this.pendingPromise,r=n.resolve,i=n.reject;n.resolve=()=>{r(),e()},n.reject=e=>{i(e),t(e)}}):new Promise((e,t)=>{this.pendingPromise={resolve:e,reject:t},this.processQueue()}))}hasPending(){return this.queue.length>0}getPendingCount(){return this.queue.length}clear(){this.queue=[],this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPromise&&=(this.pendingPromise.resolve(),null)}scheduleProcessing(){if(this.options.debounceMs===0){this.processQueue();return}this.debounceTimer===null&&(this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.processQueue()},this.options.debounceMs))}processQueue(){if(this.queue.length===0){this.pendingPromise&&=(this.pendingPromise.resolve(),null);return}let e=this.queue;this.queue=[];let t={added:0,removed:0,updated:0};try{for(let n of e)switch(n.type){case`ADD`:this.options.store.addRows(n.rows),t.added+=n.rows.length;break;case`REMOVE`:this.options.store.removeRows(n.rowIds),t.removed+=n.rowIds.length;break;case`UPDATE_CELL`:this.options.store.updateCell(n.rowId,n.field,n.value),t.updated++;break;case`UPDATE_ROW`:this.options.store.updateRow(n.rowId,n.data),t.updated++;break}this.options.onProcessed&&this.options.onProcessed(t),this.pendingPromise&&=(this.pendingPromise.resolve(),null)}catch(e){this.pendingPromise&&=(this.pendingPromise.reject(e instanceof Error?e:Error(String(e))),null)}}};function H(e,t){let{getRowId:n,getFieldValue:r,debounceMs:i=50,onTransactionProcessed:a}=t,o=new B(e,{getRowId:n,getFieldValue:r}),s=new Set,c=new V({debounceMs:i,store:o,onProcessed:e=>{a?.(e);for(let t of s)t(e)}});return{async fetch(e){return c.hasPending()&&await c.flush(),o.query(e)},addRows(e){c.add(e)},removeRows(e){c.remove(e)},updateCell(e,t,n){c.updateCell(e,t,n)},updateRow(e,t){c.updateRow(e,t)},async flushTransactions(){await c.flush()},hasPendingTransactions(){return c.hasPending()},getDistinctValues(e){return o.getDistinctValues(e)},getRowById(e){return o.getRowById(e)},getTotalRowCount(){return o.getTotalRowCount()},subscribe(e){return s.add(e),()=>{s.delete(e)}}}}const U=`
|
|
184
|
+
`],{type:`application/javascript`});this.workerUrl=URL.createObjectURL(e),this.worker=new Worker(this.workerUrl),this.worker.onmessage=e=>{let{id:t}=e.data,n=this.pendingRequests.get(t);n&&(this.pendingRequests.delete(t),e.data.type===`sorted`?n.resolve(e.data.data):e.data.type===`sortedIndices`||e.data.type===`sortedMultiColumn`?n.resolve(e.data.indices):e.data.type===`sortedStringHashes`?n.resolve({indices:e.data.indices,collisionRuns:e.data.collisionRuns}):e.data.type===`error`&&n.reject(Error(e.data.error)))},this.worker.onerror=e=>{for(let[t,n]of this.pendingRequests)n.reject(Error(`Worker error: ${e.message}`)),this.pendingRequests.delete(t)}}terminate(){this.worker&&=(this.worker.terminate(),null),this.workerUrl&&=(URL.revokeObjectURL(this.workerUrl),null);for(let[,e]of this.pendingRequests)e.reject(Error(`Worker terminated`));this.pendingRequests.clear(),this.isTerminated=!0}isAvailable(){return!this.isTerminated&&typeof Worker<`u`}};let d=null;function f(){return d||=new u,d}function p(){d&&=(d.terminate(),null)}function m(e){let t=e.toLowerCase(),n=Math.min(t.length,10),r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e),i;i=n>=97&&n<=122?n-97:n>=48&&n<=57?n-48+26:0,r=r*36+i}for(let e=n;e<10;e++)r*=36;return r}function h(e){let t=e.toLowerCase(),n=[];for(let e=0;e<3;e++){let r=e*10,i=0;for(let e=0;e<10;e++){let n=r+e,a=n<t.length?t.charCodeAt(n):0,o;o=a>=97&&a<=122?a-97:a>=48&&a<=57?a-48+26:0,i=i*36+o}n.push(i)}return n}function g(e){if(e==null)return Number.MAX_VALUE;if(Array.isArray(e))return e.length===0?Number.MAX_VALUE:m(e.join(`, `));if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();if(typeof e==`string`)return m(e);let t=Number(e);return isNaN(t)?0:t}function ee(e,t){let n=e==null||Array.isArray(e)&&e.length===0,r=t==null||Array.isArray(t)&&t.length===0;if(n&&r)return 0;if(n)return 1;if(r)return-1;if(Array.isArray(e)||Array.isArray(t)){let n=Array.isArray(e)?e.join(`, `):String(e??``),r=Array.isArray(t)?t.join(`, `):String(t??``);return n.localeCompare(r)}let i=Number(e),a=Number(t);return!isNaN(i)&&!isNaN(a)?i-a:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t))}function te(e,t,n){return[...e].sort((e,r)=>{for(let{colId:i,direction:a}of t){let t=ee(n(e,i),n(r,i));if(t!==0)return a===`asc`?t:-t}return 0})}function _(e,t,n){let r=Object.entries(t).filter(([,e])=>typeof e==`string`?e.trim()!==``:e.conditions&&e.conditions.length>0);return r.length===0?e:e.filter(e=>{for(let[t,i]of r){let r=n(e,t);if(typeof i==`string`){if(!String(r??``).toLowerCase().includes(i.toLowerCase()))return!1;continue}if(!v(r,i))return!1}return!0})}function v(e,t){if(t.conditions.length===0)return!0;let n=t.conditions[0];if(!n)return!0;let r=y(e,n);for(let n=1;n<t.conditions.length;n++){let i=t.conditions[n-1],a=t.conditions[n],o=i.nextOperator??t.combination,s=y(e,a);o===`and`?r&&=s:r||=s}return r}function y(e,t){switch(t.type){case`text`:return ne(e,t);case`number`:return b(e,t);case`date`:return re(e,t);default:return!0}}function ne(e,t){let n=e==null||e===``||Array.isArray(e)&&e.length===0;if(t.selectedValues&&t.selectedValues.size>0){let r=t.includeBlank===!0&&n;if(Array.isArray(e)){let n=[...e].sort((e,t)=>String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})).join(`, `);return t.selectedValues.has(n)||r}let i=String(e??``);return t.selectedValues.has(i)||r}let r=String(e??``).toLowerCase(),i=String(t.value??``).toLowerCase();switch(t.operator){case`contains`:return r.includes(i);case`notContains`:return!r.includes(i);case`equals`:return r===i;case`notEquals`:return r!==i;case`startsWith`:return r.startsWith(i);case`endsWith`:return r.endsWith(i);case`blank`:return n;case`notBlank`:return!n;default:return!0}}function b(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=Number(e);if(isNaN(r))return!1;let i=t.value??0,a=t.valueTo??0;switch(t.operator){case`=`:return r===i;case`!=`:return r!==i;case`>`:return r>i;case`<`:return r<i;case`>=`:return r>=i;case`<=`:return r<=i;case`between`:return r>=i&&r<=a;default:return!0}}function x(e,t){return e.toDateString()===t.toDateString()}function re(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=e instanceof Date?e:new Date(String(e));if(isNaN(r.getTime()))return!1;let i=t.value instanceof Date?t.value:new Date(String(t.value??``)),a=t.valueTo instanceof Date?t.valueTo:new Date(String(t.valueTo??``)),o=r.getTime(),s=i.getTime(),c=a.getTime();switch(t.operator){case`=`:return x(r,i);case`!=`:return!x(r,i);case`>`:return o>s;case`<`:return o<s;case`between`:return o>=s&&o<=c;default:return!0}}function ie(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r??null}function S(e,t={}){let{getFieldValue:n=ie,useWorker:r=!0}=t,i=r?new u:null;return{async fetch(t){let r=[...e];if(t.filter&&Object.keys(t.filter).length>0&&(r=_(r,t.filter,n)),t.sort&&t.sort.length>0)if(i&&i.isAvailable()&&r.length>=2e5){let e;if(t.sort.length===1){let{colId:a,direction:o}=t.sort[0],s=!1;for(let e of r){let t=n(e,a);if(t!=null){s=typeof t==`string`||Array.isArray(t);break}}if(s){let t=[],s=Array.from({length:3},()=>[]);for(let e of r){let r=n(e,a),i=r==null?``:Array.isArray(r)?r.join(`, `):String(r);t.push(i);let o=h(i);for(let e=0;e<3;e++)s[e].push(o[e])}let c=s.map(e=>new Float64Array(e));e=await i.sortStringHashes(c,o,t)}else{let t=r.map(e=>g(n(e,a)));e=await i.sortIndices(t,o)}}else{let a=[],o=[];for(let{colId:e,direction:i}of t.sort){let t=r.map(t=>g(n(t,e)));a.push(t),o.push(i)}e=await i.sortMultiColumn(a,o)}let a=Array(r.length);for(let t=0;t<e.length;t++)a[t]=r[e[t]];r=a}else r=te(r,t.sort,n);let a=r.length,{pageIndex:o,pageSize:s}=t.pagination,c=o*s;return{rows:r.slice(c,c+s),totalRows:a}}}}function C(e){return S(e)}function w(e){return{async fetch(t){return e(t)}}}function T(e,t){let n=t.split(`.`),r=e;for(let e of n){if(typeof r!=`object`||!r)return null;r=r[e]}return r??null}function E(e,t,n){let r=t.split(`.`),i=e;for(let e=0;e<r.length-1;e++){let t=r[e];if(typeof i!=`object`||!i)return;i=i[t]}typeof i==`object`&&i&&(i[r[r.length-1]]=n)}function D(e){let t=e.toLowerCase(),n=Math.min(t.length,10),r=0;for(let e=0;e<n;e++){let n=t.charCodeAt(e),i;i=n>=97&&n<=122?n-97:n>=48&&n<=57?n-48+26:0,r=r*36+i}for(let e=n;e<10;e++)r*=36;return r}function O(e,t){let n=e==null||Array.isArray(e)&&e.length===0,r=t==null||Array.isArray(t)&&t.length===0;if(n&&r)return 0;if(n)return 1;if(r)return-1;if(Array.isArray(e)||Array.isArray(t)){let n=Array.isArray(e)?e.join(`, `):String(e??``),r=Array.isArray(t)?t.join(`, `):String(t??``);return n.localeCompare(r)}let i=Number(e),a=Number(t);return!isNaN(i)&&!isNaN(a)?i-a:e instanceof Date&&t instanceof Date?e.getTime()-t.getTime():String(e).localeCompare(String(t))}function k(e){if(e==null)return Number.MAX_VALUE;if(typeof e==`number`)return e;if(e instanceof Date)return e.getTime();if(typeof e==`string`)return D(e);let t=Number(e);return isNaN(t)?0:t}function ae(e,t){let n=[];for(let r of t.sortModel){let i=k(t.getFieldValue(e,r.colId));n.push(i)}return n}function A(e,t,n){if(!e||!t)return null;for(let r=0;r<n.length;r++){let i=e[r]-t[r];if(i!==0)return n[r].direction===`asc`?i:-i}return 0}function j(e,t,n,r){for(let{colId:i,direction:a}of n){let n=O(r(e,i),r(t,i));if(n!==0)return a===`asc`?n:-n}return 0}function M(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function N(e,t){let n=e==null||e===``||Array.isArray(e)&&e.length===0;if(t.selectedValues&&t.selectedValues.size>0){let r=t.includeBlank===!0&&n;if(Array.isArray(e)){let n=[...e].sort((e,t)=>String(e).localeCompare(String(t),void 0,{numeric:!0,sensitivity:`base`})).join(`, `);return t.selectedValues.has(n)||r}let i=String(e??``);return t.selectedValues.has(i)||r}let r=String(e??``).toLowerCase(),i=String(t.value??``).toLowerCase();switch(t.operator){case`contains`:return r.includes(i);case`notContains`:return!r.includes(i);case`equals`:return r===i;case`notEquals`:return r!==i;case`startsWith`:return r.startsWith(i);case`endsWith`:return r.endsWith(i);case`blank`:return n;case`notBlank`:return!n;default:return!0}}function P(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=typeof e==`number`?e:parseFloat(String(e));if(isNaN(r))return!1;let i=t.value??0,a=t.valueTo??0;switch(t.operator){case`=`:return r===i;case`!=`:return r!==i;case`>`:return r>i;case`<`:return r<i;case`>=`:return r>=i;case`<=`:return r<=i;case`between`:return r>=i&&r<=a;default:return!0}}function F(e,t){let n=e==null||e===``;if(t.operator===`blank`)return n;if(t.operator===`notBlank`)return!n;if(n)return!1;let r=e instanceof Date?e:new Date(String(e));if(isNaN(r.getTime()))return!1;let i=t.value?t.value instanceof Date?t.value:new Date(t.value):new Date,a=t.valueTo?t.valueTo instanceof Date?t.valueTo:new Date(t.valueTo):new Date;switch(t.operator){case`=`:return M(r,i);case`!=`:return!M(r,i);case`>`:return r>i;case`<`:return r<i;case`between`:return r>=i&&r<=a;default:return!0}}function I(e,t){switch(t.type){case`text`:return N(e,t);case`number`:return P(e,t);case`date`:return F(e,t);default:return!0}}function L(e,t){if(!t.conditions||!t.conditions.length)return!0;let n=t.conditions[0];if(!n)return!0;let r=I(e,n);for(let n=1;n<t.conditions.length;n++){let i=t.conditions[n-1],a=t.conditions[n],o=i.nextOperator??t.combination,s=I(e,a);o===`and`?r&&=s:r||=s}return r}function R(e,t,n){let r=Object.entries(t).filter(([,e])=>e!=null);if(r.length===0)return!0;for(let[t,i]of r)if(!L(n(e,t),i))return!1;return!0}var z=class{rows=[];rowById=new Map;sortedIndices=[];sortModel=[];sortModelHash=``;filterModel={};filteredIndices=new Set;distinctValues=new Map;rowSortCache=new Map;options;constructor(e=[],t){this.options={getRowId:t.getRowId,getFieldValue:t.getFieldValue??T},this.setData(e)}setData(e){this.rows=[...e],this.rowById.clear(),this.rowSortCache.clear(),this.distinctValues.clear();for(let e=0;e<this.rows.length;e++){let t=this.rows[e],n=this.options.getRowId(t);this.rowById.set(n,e)}this.rebuildSortedIndices(),this.rebuildFilteredIndices(),this.rebuildDistinctValues()}query(e){e.sort&&this.setSortModel(e.sort),e.filter&&this.setFilterModel(e.filter);let t=this.getVisibleIndices(),n=t.length,{pageIndex:r,pageSize:i}=e.pagination,a=r*i,o=Math.min(a+i,n),s=[];for(let e=a;e<o;e++){let n=t[e];n!==void 0&&s.push(this.rows[n])}return{rows:s,totalRows:n}}getRowById(e){let t=this.rowById.get(e);return t===void 0?void 0:this.rows[t]}getRowByIndex(e){return this.rows[e]}getTotalRowCount(){return this.rows.length}getVisibleRowCount(){return Object.keys(this.filterModel).length===0?this.rows.length:this.filteredIndices.size}getDistinctValues(e){let t=this.distinctValues.get(e);return t?Array.from(t):[]}addRows(e){for(let t of e)this.addRow(t)}addRow(e){let t=this.options.getRowId(e);if(this.rowById.has(t)){console.warn(`Row with ID ${t} already exists. Skipping.`);return}let n=this.rows.length;if(this.rows.push(e),this.rowById.set(t,n),this.updateDistinctValuesForRow(e,`add`),this.sortModel.length>0&&this.computeRowHashes(n,e),this.sortModel.length>0){let e=this.binarySearchInsertPosition(n);this.sortedIndices.splice(e,0,n)}else this.sortedIndices.push(n);this.rowPassesFilter(e)&&this.filteredIndices.add(n)}removeRows(e){let t=[];for(let n of e){let e=this.rowById.get(n);e!==void 0&&t.push(e)}if(t.length!==0){t.sort((e,t)=>t-e);for(let e of t)this.removeRowByIndex(e)}}removeRowByIndex(e){let t=this.rows[e];if(!t)return;let n=this.options.getRowId(t);this.updateDistinctValuesForRow(t,`remove`);let r=this.sortedIndices.indexOf(e);r!==-1&&this.sortedIndices.splice(r,1),this.filteredIndices.delete(e),this.rowSortCache.delete(e),this.rowById.delete(n),this.rows.splice(e,1),this.reindexAfterRemoval(e)}reindexAfterRemoval(e){for(let[t,n]of this.rowById.entries())n>e&&this.rowById.set(t,n-1);for(let t=0;t<this.sortedIndices.length;t++)this.sortedIndices[t]>e&&this.sortedIndices[t]--;let t=new Set;for(let n of this.filteredIndices)n>e?t.add(n-1):t.add(n);this.filteredIndices=t;let n=new Map;for(let[t,r]of this.rowSortCache)t>e?n.set(t-1,r):n.set(t,r);this.rowSortCache=n}updateCell(e,t,n){let r=this.rowById.get(e);if(r===void 0){console.warn(`Row with ID ${e} not found.`);return}let i=this.rows[r],a=this.options.getFieldValue(i,t);if(E(i,t,n),this.updateDistinctValueForField(t,a,n),this.sortModel.some(e=>e.colId===t)&&this.sortModel.length>0){this.computeRowHashes(r,i);let e=this.sortedIndices.indexOf(r);e!==-1&&this.sortedIndices.splice(e,1);let t=this.binarySearchInsertPosition(r);this.sortedIndices.splice(t,0,r)}t in this.filterModel&&(this.rowPassesFilter(i)?this.filteredIndices.add(r):this.filteredIndices.delete(r))}updateRow(e,t){for(let[n,r]of Object.entries(t))this.updateCell(e,n,r)}setSortModel(e){let t=JSON.stringify(e);t!==this.sortModelHash&&(this.sortModelHash=t,this.sortModel=[...e],this.rebuildHashCache(),this.rebuildSortedIndices())}getSortModel(){return[...this.sortModel]}setFilterModel(e){JSON.stringify(e)!==JSON.stringify(this.filterModel)&&(this.filterModel={...e},this.rebuildFilteredIndices())}getFilterModel(){return{...this.filterModel}}rebuildSortedIndices(){this.sortedIndices=Array.from({length:this.rows.length},(e,t)=>t),this.sortModel.length!==0&&this.sortedIndices.sort((e,t)=>this.compareRows(e,t))}rebuildHashCache(){if(this.rowSortCache.clear(),this.sortModel.length!==0)for(let e=0;e<this.rows.length;e++)this.computeRowHashes(e,this.rows[e])}computeRowHashes(e,t){if(this.sortModel.length===0)return;let n=ae(t,{sortModel:this.sortModel,sortModelHash:this.sortModelHash,getFieldValue:this.options.getFieldValue}),r=this.rowSortCache.get(e);r||(r={hashes:new Map},this.rowSortCache.set(e,r)),r.hashes.set(this.sortModelHash,n)}compareRows(e,t){let n=this.rowSortCache.get(e),r=this.rowSortCache.get(t),i=n?.hashes.get(this.sortModelHash),a=r?.hashes.get(this.sortModelHash),o=A(i,a,this.sortModel);return o===null?j(this.rows[e],this.rows[t],this.sortModel,this.options.getFieldValue):o}binarySearchInsertPosition(e){let t=0,n=this.sortedIndices.length;for(;t<n;){let r=t+n>>>1,i=this.sortedIndices[r];this.compareRows(e,i)>0?t=r+1:n=r}return t}rebuildFilteredIndices(){if(this.filteredIndices.clear(),Object.entries(this.filterModel).filter(([,e])=>e!=null).length!==0)for(let e=0;e<this.rows.length;e++)this.rowPassesFilter(this.rows[e])&&this.filteredIndices.add(e)}rowPassesFilter(e){return R(e,this.filterModel,this.options.getFieldValue)}getVisibleIndices(){return Object.entries(this.filterModel).filter(([,e])=>e!=null).length>0?this.sortedIndices.filter(e=>this.filteredIndices.has(e)):this.sortedIndices}rebuildDistinctValues(){this.distinctValues.clear();for(let e of this.rows)this.updateDistinctValuesForRow(e,`add`)}updateDistinctValuesForRow(e,t){if(!(typeof e!=`object`||!e)){for(let[n,r]of Object.entries(e))if(r!=null&&t===`add`){let e=this.distinctValues.get(n);if(e||(e=new Set,this.distinctValues.set(n,e)),Array.isArray(r))for(let t of r)t!=null&&e.add(t);else e.add(r)}}}updateDistinctValueForField(e,t,n){if(n!=null){let t=this.distinctValues.get(e);if(t||(t=new Set,this.distinctValues.set(e,t)),Array.isArray(n))for(let e of n)e!=null&&t.add(e);else t.add(n)}}},B=class{queue=[];debounceTimer=null;pendingPromise=null;options;constructor(e){this.options=e}add(e){e.length!==0&&(this.queue.push({type:`ADD`,rows:e}),this.scheduleProcessing())}remove(e){e.length!==0&&(this.queue.push({type:`REMOVE`,rowIds:e}),this.scheduleProcessing())}updateCell(e,t,n){this.queue.push({type:`UPDATE_CELL`,rowId:e,field:t,value:n}),this.scheduleProcessing()}updateRow(e,t){Object.keys(t).length!==0&&(this.queue.push({type:`UPDATE_ROW`,rowId:e,data:t}),this.scheduleProcessing())}flush(){return this.queue.length===0?Promise.resolve():(this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPromise?new Promise((e,t)=>{let n=this.pendingPromise,r=n.resolve,i=n.reject;n.resolve=()=>{r(),e()},n.reject=e=>{i(e),t(e)}}):new Promise((e,t)=>{this.pendingPromise={resolve:e,reject:t},this.processQueue()}))}hasPending(){return this.queue.length>0}getPendingCount(){return this.queue.length}clear(){this.queue=[],this.debounceTimer!==null&&(clearTimeout(this.debounceTimer),this.debounceTimer=null),this.pendingPromise&&=(this.pendingPromise.resolve(),null)}scheduleProcessing(){if(this.options.debounceMs===0){this.processQueue();return}this.debounceTimer===null&&(this.debounceTimer=setTimeout(()=>{this.debounceTimer=null,this.processQueue()},this.options.debounceMs))}processQueue(){if(this.queue.length===0){this.pendingPromise&&=(this.pendingPromise.resolve(),null);return}let e=this.queue;this.queue=[];let t={added:0,removed:0,updated:0};try{for(let n of e)switch(n.type){case`ADD`:this.options.store.addRows(n.rows),t.added+=n.rows.length;break;case`REMOVE`:this.options.store.removeRows(n.rowIds),t.removed+=n.rowIds.length;break;case`UPDATE_CELL`:this.options.store.updateCell(n.rowId,n.field,n.value),t.updated++;break;case`UPDATE_ROW`:this.options.store.updateRow(n.rowId,n.data),t.updated++;break}this.options.onProcessed&&this.options.onProcessed(t),this.pendingPromise&&=(this.pendingPromise.resolve(),null)}catch(e){this.pendingPromise&&=(this.pendingPromise.reject(e instanceof Error?e:Error(String(e))),null)}}};function V(e,t){let{getRowId:n,getFieldValue:r,debounceMs:i=50,onTransactionProcessed:a}=t,o=new z(e,{getRowId:n,getFieldValue:r}),s=new Set,c=new B({debounceMs:i,store:o,onProcessed:e=>{a?.(e);for(let t of s)t(e)}});return{async fetch(e){return c.hasPending()&&await c.flush(),o.query(e)},addRows(e){c.add(e)},removeRows(e){c.remove(e)},updateCell(e,t,n){c.updateCell(e,t,n)},updateRow(e,t){c.updateRow(e,t)},async flushTransactions(){await c.flush()},hasPendingTransactions(){return c.hasPending()},getDistinctValues(e){return o.getDistinctValues(e)},getRowById(e){return o.getRowById(e)},getTotalRowCount(){return o.getTotalRowCount()},subscribe(e){return s.add(e),()=>{s.delete(e)}}}}const H=`
|
|
185
185
|
/* =============================================================================
|
|
186
186
|
GP Grid - CSS Variables for Theming
|
|
187
187
|
============================================================================= */
|
|
@@ -199,6 +199,7 @@ self.onmessage = function(e) {
|
|
|
199
199
|
/* Header */
|
|
200
200
|
--gp-grid-header-bg: #f1f3f5;
|
|
201
201
|
--gp-grid-header-text: #212529;
|
|
202
|
+
--gp-grid-header-z-index: 10;
|
|
202
203
|
|
|
203
204
|
/* Selection */
|
|
204
205
|
--gp-grid-primary: #228be6;
|
|
@@ -238,6 +239,7 @@ self.onmessage = function(e) {
|
|
|
238
239
|
/* Header */
|
|
239
240
|
--gp-grid-header-bg: #25262b;
|
|
240
241
|
--gp-grid-header-text: #c1c2c5;
|
|
242
|
+
--gp-grid-header-z-index: 10;
|
|
241
243
|
|
|
242
244
|
/* Selection */
|
|
243
245
|
--gp-grid-primary: #339af0;
|
|
@@ -263,7 +265,7 @@ self.onmessage = function(e) {
|
|
|
263
265
|
--gp-grid-scrollbar-thumb: #373a40;
|
|
264
266
|
--gp-grid-scrollbar-thumb-hover: #4a4d52;
|
|
265
267
|
}
|
|
266
|
-
`,
|
|
268
|
+
`,U=`
|
|
267
269
|
/* =============================================================================
|
|
268
270
|
GP Grid - Clean Flat Design
|
|
269
271
|
============================================================================= */
|
|
@@ -286,7 +288,7 @@ self.onmessage = function(e) {
|
|
|
286
288
|
outline: none;
|
|
287
289
|
border-color: var(--gp-grid-primary);
|
|
288
290
|
}
|
|
289
|
-
`,
|
|
291
|
+
`,W=`
|
|
290
292
|
/* =============================================================================
|
|
291
293
|
Header
|
|
292
294
|
============================================================================= */
|
|
@@ -295,7 +297,7 @@ self.onmessage = function(e) {
|
|
|
295
297
|
position: sticky;
|
|
296
298
|
top: 0;
|
|
297
299
|
left: 0;
|
|
298
|
-
z-index:
|
|
300
|
+
z-index: var(--gp-grid-header-z-index);
|
|
299
301
|
background-color: var(--gp-grid-header-bg);
|
|
300
302
|
border-bottom: 1px solid var(--gp-grid-border);
|
|
301
303
|
}
|
|
@@ -400,7 +402,7 @@ self.onmessage = function(e) {
|
|
|
400
402
|
color: var(--gp-grid-primary);
|
|
401
403
|
background-color: var(--gp-grid-primary-light);
|
|
402
404
|
}
|
|
403
|
-
`,
|
|
405
|
+
`,G=`
|
|
404
406
|
/* =============================================================================
|
|
405
407
|
Data Cells
|
|
406
408
|
============================================================================= */
|
|
@@ -506,7 +508,7 @@ self.onmessage = function(e) {
|
|
|
506
508
|
.gp-grid-edit-input:focus {
|
|
507
509
|
outline: none;
|
|
508
510
|
}
|
|
509
|
-
`,
|
|
511
|
+
`,K=`
|
|
510
512
|
/* =============================================================================
|
|
511
513
|
Loading & Error States
|
|
512
514
|
============================================================================= */
|
|
@@ -574,7 +576,7 @@ self.onmessage = function(e) {
|
|
|
574
576
|
font-size: 14px;
|
|
575
577
|
text-align: center;
|
|
576
578
|
}
|
|
577
|
-
`,
|
|
579
|
+
`,q=`
|
|
578
580
|
/* =============================================================================
|
|
579
581
|
Scrollbar Styling
|
|
580
582
|
============================================================================= */
|
|
@@ -600,7 +602,7 @@ self.onmessage = function(e) {
|
|
|
600
602
|
.gp-grid-container::-webkit-scrollbar-corner {
|
|
601
603
|
background-color: var(--gp-grid-scrollbar-track);
|
|
602
604
|
}
|
|
603
|
-
`,
|
|
605
|
+
`,J=`
|
|
604
606
|
/* =============================================================================
|
|
605
607
|
Filter Popup
|
|
606
608
|
============================================================================= */
|
|
@@ -911,5 +913,5 @@ self.onmessage = function(e) {
|
|
|
911
913
|
.gp-grid-filter-btn-apply:hover {
|
|
912
914
|
opacity: 0.9;
|
|
913
915
|
}
|
|
914
|
-
`,
|
|
915
|
-
`);let
|
|
916
|
+
`,Y=`gp-grid-styles`,X=[H,U,W,G,K,q,J].join(`
|
|
917
|
+
`);let Z=!1;function oe(){if(Z||typeof document>`u`)return;if(document.getElementById(Y)){Z=!0;return}let e=document.createElement(`style`);e.id=Y,e.textContent=X,document.head.appendChild(e),Z=!0}function Q(e){let t=[0],n=0;for(let r of e)n+=r.width,t.push(n);return t}function $(e){return e[e.length-1]??0}function se(e,t){let n=Q(e),r=$(n);if(t<=r||r===0)return{positions:n,widths:e.map(e=>e.width)};let i=t/r,a=e.map(e=>e.width*i),o=[0],s=0;for(let e of a)s+=e,o.push(s);return{positions:o,widths:a}}function ce(e,t){for(let n=0;n<t.length-1;n++)if(e>=t[n]&&e<t[n+1])return n;return e>=t[t.length-1]?t.length-2:0}function le(e,t,n){if(!n)return!1;let r=Math.min(n.startRow,n.endRow),i=Math.max(n.startRow,n.endRow),a=Math.min(n.startCol,n.endCol),o=Math.max(n.startCol,n.endCol);return e>=r&&e<=i&&t>=a&&t<=o}function ue(e,t,n){return n?.row===e&&n?.col===t}function de(e,t){return!t||t.end<0||t.start>t.end?!0:e>=t.start&&e<=t.end}function fe(e,t,n){return n?.row===e&&n?.col===t}function pe(e,t,n,r,i){if(!n||!r||!i)return!1;let a=Math.min(r.startRow,r.endRow),o=Math.max(r.startRow,r.endRow),s=Math.min(r.startCol,r.endCol),c=Math.max(r.startCol,r.endCol),l=i.row>o,u=i.row<a;return l?e>o&&e<=i.row&&t>=s&&t<=c:u?e<a&&e>=i.row&&t>=s&&t<=c:!1}function me(e,t,n,r){let i=[`gp-grid-cell`];return e&&i.push(`gp-grid-cell--active`),t&&!e&&i.push(`gp-grid-cell--selected`),n&&i.push(`gp-grid-cell--editing`),r&&i.push(`gp-grid-cell--fill-preview`),i.join(` `)}export{r as EditManager,t as FillManager,o as GridCore,z as IndexedDataStore,i as InputHandler,e as SelectionManager,n as SlotPoolManager,u as SortWorkerManager,B as TransactionManager,me as buildCellClasses,Q as calculateColumnPositions,se as calculateScaledColumnPositions,G as cellStyles,O as compareValues,k as computeValueHash,U as containerStyles,S as createClientDataSource,C as createDataSourceFromArray,V as createMutableClientDataSource,w as createServerDataSource,L as evaluateColumnFilter,F as evaluateDateCondition,P as evaluateNumberCondition,N as evaluateTextCondition,J as filtersStyles,ce as findColumnAtX,T as getFieldValue,f as getSharedSortWorker,$ as getTotalWidth,X as gridStyles,W as headerStyles,oe as injectStyles,ue as isCellActive,fe as isCellEditing,pe as isCellInFillPreview,le as isCellSelected,de as isRowVisible,M as isSameDay,R as rowPassesFilter,q as scrollbarStyles,E as setFieldValue,K as statesStyles,D as stringToSortableNumber,p as terminateSharedSortWorker,H as variablesStyles};
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "gp-grid-core",
|
|
3
3
|
"description": "A high-performance, framework-agnostic TypeScript data grid core with virtual scrolling",
|
|
4
4
|
"private": false,
|
|
5
|
-
"version": "0.
|
|
5
|
+
"version": "0.3.0",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"main": "dist/index.js",
|
|
8
8
|
"types": "dist/index.d.ts",
|
|
@@ -37,6 +37,13 @@
|
|
|
37
37
|
"files": [
|
|
38
38
|
"dist"
|
|
39
39
|
],
|
|
40
|
+
"devDependencies": {
|
|
41
|
+
"@types/node": "^24.9.1",
|
|
42
|
+
"@vitest/coverage-v8": "^4.0.15",
|
|
43
|
+
"tsdown": "^0.15.9",
|
|
44
|
+
"typescript": "~5.8.3",
|
|
45
|
+
"vitest": "^4.0.15"
|
|
46
|
+
},
|
|
40
47
|
"scripts": {
|
|
41
48
|
"dev": "tsdown --watch",
|
|
42
49
|
"build": "tsdown --clean --sourcemap",
|
|
@@ -44,12 +51,5 @@
|
|
|
44
51
|
"test": "vitest",
|
|
45
52
|
"test:ui": "vitest --ui",
|
|
46
53
|
"bench": "vitest bench"
|
|
47
|
-
},
|
|
48
|
-
"devDependencies": {
|
|
49
|
-
"@types/node": "^24.9.1",
|
|
50
|
-
"@vitest/coverage-v8": "^4.0.15",
|
|
51
|
-
"tsdown": "^0.15.9",
|
|
52
|
-
"typescript": "~5.8.3",
|
|
53
|
-
"vitest": "^4.0.15"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|