/*
*
* Wijmo Library 5.20183.567
* http://wijmo.com/
*
* Copyright(c) GrapeCity, Inc. All rights reserved.
*
* Licensed under the GrapeCity Commercial License.
* sales@wijmo.com
* wijmo.com/products/wijmo-5/license/
*
*/
"use strict";function tryGetModuleWijmoInput(){let e;return(e=__glob.wijmo)&&e.input}Object.defineProperty(exports,"__esModule",{value:!0});const wjcCore=require("wijmo/wijmo");var __glob="undefined"!=typeof window?window:self;const wjcSelfRef=require("wijmo/wijmo.grid");var wjcSelf=wjcSelfRef||exports;__glob.wijmo=__glob.wijmo||{},__glob.wijmo.grid=wjcSelf,wjcCore._addCultureInfo("FlexGrid",{groupHeaderFormat:"{name}: {value} ({count:n0} items)",ariaLabels:{toggleDropDown:"Toggle Dropdown",toggleGroup:"Toggle Group"}});var HeadersVisibility;!function(e){e[e.None=0]="None",e[e.Column=1]="Column",e[e.Row=2]="Row",e[e.All=3]="All"}(HeadersVisibility=exports.HeadersVisibility||(exports.HeadersVisibility={}));class FlexGrid extends wjcCore.Control{constructor(e,t){super(e,null,!0),this._szClient=new wjcCore.Size(0,0),this._ptScrl=new wjcCore.Point(0,0),this._cellPadLeft=3,this._cellPadVert=0,this._clipToScreen=!1,this._autoGenCols=!0,this._autoClipboard=!0,this._autoScroll=!0,this._autoSearch=!1,this._readOnly=!1,this._indent=14,this._autoSizeMode=AutoSizeMode.Both,this._hdrVis=HeadersVisibility.All,this._alSorting=!0,this._alAddNew=!1,this._alDelete=!1,this._alResizing=AllowResizing.Columns,this._alDragging=AllowDragging.Columns,this._alMerging=AllowMerging.None,this._ssHdr=HeadersVisibility.None,this._shSort=!0,this._shGroups=!0,this._altStep=1,this._shErr=!0,this._shDropDown=!0,this._valEdt=!0,this._deferResizing=!1,this._pSel=!0,this._pOutline=!0,this._stickyHdr=!1,this._anchorCursor=!1,this._vt=0,this._vtRows=0,this._vtCols=0,this._reorderCells=!0,this._refreshOnEdit=!0,this._lazyRender=!1,this.itemsSourceChanging=new wjcCore.Event,this.itemsSourceChanged=new wjcCore.Event,this.scrollPositionChanged=new wjcCore.Event,this.selectionChanging=new wjcCore.Event,this.selectionChanged=new wjcCore.Event,this.loadingRows=new wjcCore.Event,this.loadedRows=new wjcCore.Event,this.updatingLayout=new wjcCore.Event,this.updatedLayout=new wjcCore.Event,this.resizingColumn=new wjcCore.Event,this.resizedColumn=new wjcCore.Event,this.autoSizingColumn=new wjcCore.Event,this.autoSizedColumn=new wjcCore.Event,this.draggingColumn=new wjcCore.Event,this.draggingColumnOver=new wjcCore.Event,this.draggedColumn=new wjcCore.Event,this.resizingRow=new wjcCore.Event,this.resizedRow=new wjcCore.Event,this.autoSizingRow=new wjcCore.Event,this.autoSizedRow=new wjcCore.Event,this.draggingRow=new wjcCore.Event,this.draggingRowOver=new wjcCore.Event,this.draggedRow=new wjcCore.Event,this.groupCollapsedChanging=new wjcCore.Event,this.groupCollapsedChanged=new wjcCore.Event,this.sortingColumn=new wjcCore.Event,this.sortedColumn=new wjcCore.Event,this.beginningEdit=new wjcCore.Event,this.prepareCellForEdit=new wjcCore.Event,this.cellEditEnding=new wjcCore.Event,this.cellEditEnded=new wjcCore.Event,this.rowEditStarting=new wjcCore.Event,this.rowEditStarted=new wjcCore.Event,this.rowEditEnding=new wjcCore.Event,this.rowEditEnded=new wjcCore.Event,this.rowAdded=new wjcCore.Event,this.deletingRow=new wjcCore.Event,this.deletedRow=new wjcCore.Event,this.copying=new wjcCore.Event,this.copied=new wjcCore.Event,this.pasting=new wjcCore.Event,this.pasted=new wjcCore.Event,this.pastingCell=new wjcCore.Event,this.pastedCell=new wjcCore.Event,this.formatItem=new wjcCore.Event(()=>{this.invalidate()}),this.updatingView=new wjcCore.Event,this.updatedView=new wjcCore.Event,this._mappedColumns=null;let i=this.hostElement;wjcCore.isIE()&&(i.style.borderRadius="0");let s=this.getTemplate();this.applyTemplate("wj-control wj-content wj-flexgrid",s,{_root:"root",_eSz:"sz",_eCt:"cells",_fCt:"fcells",_eTL:"tl",_eBL:"bl",_eCHdr:"ch",_eRHdr:"rh",_eCFtr:"cf",_eTLCt:"tlcells",_eBLCt:"blcells",_eCHdrCt:"chcells",_eCFtrCt:"cfcells",_eRHdrCt:"rhcells",_eMarquee:"marquee",_eFocus:"focus"});[this._eRHdr,this._eCFtr,this._eCHdr,this._eBL,this._eTL].forEach(e=>{wjcCore.setAttribute(e,"aria-hidden",!0),wjcCore.setCss(e,{position:"absolute",overflow:"hidden",outline:"none"}),wjcCore.setCss(e.firstElementChild,{position:"relative"})}),[this._eFocus,this._eMarquee,this._fCt,this._eSz].forEach(e=>{wjcCore.setAttribute(e,"aria-hidden",!0)}),i.tabIndex=-1,this.deferUpdate(()=>{let e=this._getDefaultRowHeight();this._rows=new RowCollection(this,e),this._cols=new ColumnCollection(this,4*e),this._hdrRows=new RowCollection(this,e),this._hdrCols=new ColumnCollection(this,Math.round(1.25*e)),this._ftrRows=new RowCollection(this,e);let i=CellType;this._gpTL=new GridPanel(this,i.TopLeft,this._hdrRows,this._hdrCols,this._eTLCt),this._gpCHdr=new GridPanel(this,i.ColumnHeader,this._hdrRows,this._cols,this._eCHdrCt),this._gpRHdr=new GridPanel(this,i.RowHeader,this._rows,this._hdrCols,this._eRHdrCt),this._gpCells=new GridPanel(this,i.Cell,this._rows,this._cols,this._eCt),this._gpBL=new GridPanel(this,i.BottomLeft,this._ftrRows,this._hdrCols,this._eBLCt),this._gpCFtr=new GridPanel(this,i.ColumnFooter,this._ftrRows,this._cols,this._eCFtrCt),this._hdrRows.push(new Row),this._hdrCols.push(new Column({align:"center"})),this._cf=new CellFactory,this._keyHdl=new _KeyboardHandler(this),this._mouseHdl=new _MouseHandler(this),this._edtHdl=new _EditHandler(this),this._selHdl=new _SelectionHandler(this),this._addHdl=new _AddNewHandler(this),this._mrgMgr=new MergeManager(this),this._bndSortConverter=this._sortConverter.bind(this),this._errorTip=new wjcCore.Tooltip({isContentHtml:!1,showDelay:0,cssClass:"wj-error-tip"}),wjcCore.setAttribute(this.cells.hostElement,"role","grid"),this.selectionMode=SelectionMode.CellRange,this.initialize(t)}),this.addEventListener(this._root,"scroll",e=>{this._updateScrollPosition()&&(this.finishEditing(),this._updateContent(!0))}),this.addEventListener(i,"focus",e=>{if(i.tabIndex>-1){let t=e.target;if(t instanceof HTMLElement&&t.tabIndex<0)return void this._setFocus(!0)}},!0)}_handleResize(){this._rcBounds=null,super._handleResize()}get headersVisibility(){return this._hdrVis}set headersVisibility(e){(e=wjcCore.asEnum(e,HeadersVisibility))!=this._hdrVis&&(this._hdrVis=e,this.invalidate())}get stickyHeaders(){return this._stickyHdr}set stickyHeaders(e){e!=this._stickyHdr&&(this._stickyHdr=wjcCore.asBoolean(e),this._updateStickyHeaders(),this.invalidate())}get preserveSelectedState(){return this._pSel}set preserveSelectedState(e){this._pSel=wjcCore.asBoolean(e)}get preserveOutlineState(){return this._pOutline}set preserveOutlineState(e){this._pOutline=wjcCore.asBoolean(e)}get anchorCursor(){return this._anchorCursor}set anchorCursor(e){this._anchorCursor=wjcCore.asBoolean(e)}get virtualizationThreshold(){return this._vt}set virtualizationThreshold(e){this._vt=e,wjcCore.isNumber(e)?this._vtRows=this._vtCols=wjcCore.asNumber(e):e?wjcCore.isArray(e)&&2==e.length?(this._vtRows=wjcCore.asNumber(e[0]),this._vtCols=wjcCore.asNumber(e[1])):wjcCore.assert(!1,"virtualizationThreshold should be a number or an array with two numbers."):this._vtRows=this._vtCols=0}get autoGenerateColumns(){return this._autoGenCols}set autoGenerateColumns(e){this._autoGenCols=wjcCore.asBoolean(e)}get autoClipboard(){return this._autoClipboard}set autoClipboard(e){this._autoClipboard=wjcCore.asBoolean(e)}get autoScroll(){return this._autoScroll}set autoScroll(e){this._autoScroll=wjcCore.asBoolean(e)}get autoSearch(){return this._autoSearch}set autoSearch(e){this._autoSearch=wjcCore.asBoolean(e)}get columnLayout(){let e=FlexGrid._getSerializableProperties(Column),t=new Column,i=[];return this.columns.forEach(s=>{let l={};e.forEach(e=>{let i=s[e];i!=t[e]&&wjcCore.isPrimitive(i)&&"size"!=e&&(l[e]=i)}),i.push(l)}),JSON.stringify({columns:i})}set columnLayout(e){let t=JSON.parse(wjcCore.asString(e));if(!t||null==t.columns)throw"Invalid columnLayout data.";this.columns.clear(),this.initialize(t)}get isReadOnly(){return this._readOnly}set isReadOnly(e){e!=this._readOnly&&(this._readOnly=wjcCore.asBoolean(e),this.finishEditing(),this.invalidate(!0),this._addHdl.updateNewRowTemplate(),wjcCore.toggleClass(this.hostElement,"wj-state-readonly",this.isReadOnly),this._setAria("readonly",this.isReadOnly?"true":null))}get imeEnabled(){return null!=this._imeHdl}set imeEnabled(e){if(wjcCore.asBoolean(e)!=this.imeEnabled&&this.finishEditing()){let t=this.containsFocus();this._imeHdl&&(this._imeHdl.dispose(),this._imeHdl=null),e&&(this._imeHdl=new _ImeHandler(this)),t&&this.focus()}}get allowResizing(){return this._alResizing}set allowResizing(e){this._alResizing=wjcCore.asEnum(e,AllowResizing)}get deferResizing(){return this._deferResizing}set deferResizing(e){this._deferResizing=wjcCore.asBoolean(e)}get autoSizeMode(){return this._autoSizeMode}set autoSizeMode(e){this._autoSizeMode=wjcCore.asEnum(e,AutoSizeMode)}get quickAutoSize(){return this._quickSize}set quickAutoSize(e){this._quickSize=wjcCore.asBoolean(e,!0)}_getQuickAutoSize(){return wjcCore.isBoolean(this._quickSize)?this._quickSize:!this.formatItem.hasHandlers&&null==this.itemFormatter}get allowSorting(){return this._alSorting}set allowSorting(e){this._alSorting=wjcCore.asBoolean(e)}get allowAddNew(){return this._alAddNew}set allowAddNew(e){e!=this._alAddNew&&(this._alAddNew=wjcCore.asBoolean(e),this._addHdl.updateNewRowTemplate())}get newRowAtTop(){return this._addHdl.newRowAtTop}set newRowAtTop(e){this._addHdl.newRowAtTop=wjcCore.asBoolean(e)}get allowDelete(){return this._alDelete}set allowDelete(e){e!=this._alDelete&&(this._alDelete=wjcCore.asBoolean(e))}get allowMerging(){return this._alMerging}set allowMerging(e){(e=wjcCore.asEnum(e,AllowMerging))!=this._alMerging&&(this._alMerging=e,this.invalidate())}get showSelectedHeaders(){return this._ssHdr}set showSelectedHeaders(e){(e=wjcCore.asEnum(e,HeadersVisibility))!=this._ssHdr&&(this._ssHdr=e,this.invalidate())}get showMarquee(){return!this._eMarquee.style.display}set showMarquee(e){if(e!=this.showMarquee){let t=this._eMarquee.style;t.visibility="collapse",t.display=wjcCore.asBoolean(e)?"":"none",this.invalidate()}}get showSort(){return this._shSort}set showSort(e){e!=this._shSort&&(this._shSort=wjcCore.asBoolean(e),this.invalidate())}get showGroups(){return this._shGroups}set showGroups(e){e!=this._shGroups&&(this._shGroups=wjcCore.asBoolean(e),this._bindGrid(!1))}get alternatingRowStep(){return this._altStep}set alternatingRowStep(e){e!=this._altStep&&(this._altStep=wjcCore.asInt(e,!1,!0),this.invalidate())}get showAlternatingRows(){return this._altStep>0}set showAlternatingRows(e){wjcCore._deprecated("showAlternatingRows","alternatingRowStep"),this.alternatingRowStep=e?1:0}get showErrors(){return this._shErr}set showErrors(e){e!=this._shErr&&(this._clearCells(),this._shErr=wjcCore.asBoolean(e))}get errorTip(){return this._errorTip}set errorTip(e){e!=this._errorTip&&(this._clearCells(),this._errorTip=wjcCore.asType(e,wjcCore.Tooltip,!0))}get itemValidator(){return this._itemValidator}set itemValidator(e){e!=this.itemValidator&&(this._itemValidator=wjcCore.asFunction(e),this.invalidate())}get validateEdits(){return this._valEdt}set validateEdits(e){this._valEdt=wjcCore.asBoolean(e)}get groupHeaderFormat(){return this._gHdrFmt}set groupHeaderFormat(e){e!=this._gHdrFmt&&(this._gHdrFmt=wjcCore.asString(e),this._bindGrid(!1))}get allowDragging(){return this._alDragging}set allowDragging(e){(e=wjcCore.asEnum(e,AllowDragging))!=this._alDragging&&(this._alDragging=e,this.invalidate())}get itemsSource(){return this._items}set itemsSource(e){if(e!=this._items){let t=new wjcCore.CancelEventArgs;if(this.onItemsSourceChanging(t)){if(this._cv){let e=wjcCore.tryCast(this._cv,wjcCore.CollectionView);e&&e.sortConverter==this._bndSortConverter&&(e.sortConverter=null),this._cv.currentChanged.removeHandler(this._cvCurrentChanged,this),this._cv.collectionChanged.removeHandler(this._cvCollectionChanged,this),this._cv=null}if(this._items=e,this._cv=this._getCollectionView(e),this._lastCount=0,this._cv){this._cv.currentChanged.addHandler(this._cvCurrentChanged,this),this._cv.collectionChanged.addHandler(this._cvCollectionChanged,this);let e=wjcCore.tryCast(this._cv,wjcCore.CollectionView);e&&!e.sortConverter&&(e.sortConverter=this._bndSortConverter)}this._bindGrid(!0);let i=SelectionMode;this.selectionMode==i.ListBox&&(this.selectionMode=i.CellRange,this.selectionMode=i.ListBox),this.onItemsSourceChanged(t)}}}get collectionView(){return this._cv}get editableCollectionView(){return wjcCore.tryCast(this._cv,"IEditableCollectionView")}get childItemsPath(){return this._childItemsPath}set childItemsPath(e){e!=this._childItemsPath&&(wjcCore.assert(null==e||wjcCore.isArray(e)||wjcCore.isString(e),"childItemsPath should be an array or a string."),this._childItemsPath=e,this._bindGrid(!0))}get rowHeaderPath(){return this._rowHdrPath?this._rowHdrPath.path:null}set rowHeaderPath(e){e!=this.rowHeaderPath&&(e=wjcCore.asString(e),this._rowHdrPath=e?new wjcCore.Binding(e):null,this.invalidate())}get cells(){return this._gpCells}get columnHeaders(){return this._gpCHdr}get columnFooters(){return this._gpCFtr}get rowHeaders(){return this._gpRHdr}get topLeftCells(){return this._gpTL}get bottomLeftCells(){return this._gpBL}get rows(){return this._rows}get columns(){return this._cols}getColumn(e){return this.columns.getColumn(e)}get frozenRows(){return this.rows.frozen}set frozenRows(e){this.rows.frozen=e}get frozenColumns(){return this.columns.frozen}set frozenColumns(e){this.columns.frozen=e}get cloneFrozenCells(){return this._fzClone}set cloneFrozenCells(e){e!=this.cloneFrozenCells&&(wjcCore.setText(this._fCt,null),this._fzClone=wjcCore.asBoolean(e,!0),this.invalidate())}get sortRowIndex(){return this._sortRowIndex}set sortRowIndex(e){e!=this._sortRowIndex&&(this._sortRowIndex=wjcCore.asNumber(e,!0),this.invalidate())}get editColumnIndex(){return this._editColIndex}set editColumnIndex(e){e!=this._editColIndex&&(this._editColIndex=wjcCore.asNumber(e,!0),this.invalidate())}get scrollPosition(){return this._ptScrl.clone()}set scrollPosition(e){let t=this._root,i=-e.x;if(this.rightToLeft)switch(FlexGrid._getRtlMode()){case"rev":i=t.scrollWidth-t.clientWidth+e.x;break;case"neg":i=e.x;break;default:i=-e.x}t.scrollLeft=i,t.scrollTop=-e.y}get clientSize(){return this._szClient}get controlRect(){return this._rcBounds||(this._rcBounds=wjcCore.getElementRect(this._root)),this._rcBounds}get scrollSize(){return new wjcCore.Size(this._gpCells.width,this._heightBrowser)}get viewRange(){return this._gpCells.viewRange}get cellFactory(){return this._cf}set cellFactory(e){e!=this._cf&&(this._clearCells(),this._cf=wjcCore.asType(e,CellFactory,!1))}get itemFormatter(){return this._itemFormatter}set itemFormatter(e){e!=this._itemFormatter&&(this._clearCells(),this._itemFormatter=wjcCore.asFunction(e))}canEditCell(e,t){return this._edtHdl._allowEditing(e,t)}getCellData(e,t,i){return this.cells.getCellData(e,t,i)}getCellBoundingRect(e,t,i){return this.cells.getCellBoundingRect(e,t,i)}setCellData(e,t,i,s=!0,l=!0){return this.cells.setCellData(e,t,i,s,l)}hitTest(e,t){return wjcCore.isNumber(e)&&wjcCore.isNumber(t)&&(e=new wjcCore.Point(e,t)),wjcCore.isBoolean(t)&&t&&(this._rcBounds=null),new HitTestInfo(this,e)}getClipString(e,t,i,s){return this._edtHdl.getClipString(e,t,i,s)}setClipString(e,t){this._edtHdl.setClipString(e,t)}focus(){this._setFocus(!1)}dispose(){this.finishEditing(!0),this.itemsSource=null,super.dispose()}refresh(e=!0){if(super.refresh(e),this.finishEditing(),e){this._updateColumnTypes(),this.scrollPosition=this._ptScrl;let e=this._getDefaultRowHeight();this._rows._setDefaultSize(e),this._cols._setDefaultSize(4*e),this._hdrRows._setDefaultSize(e),this._hdrCols._setDefaultSize(Math.round(1.25*e)),this._ftrRows._setDefaultSize(e),this._toInv&&(clearTimeout(this._toInv),this._toInv=null)}this.refreshCells(e),this._szCtl=new wjcCore.Size(this._e.offsetWidth,this._e.offsetHeight)}refreshCells(e,t,i){this.isUpdating||(e?this._updateLayout():this._updateContent(t,i))}autoSizeColumn(e,t=!1,i=4){this.autoSizeColumns(e,e,t,i)}autoSizeColumns(e,t,i=!1,s=4){let l=0,o=i?this.topLeftCells:this.columnHeaders,r=i?this.bottomLeftCells:this.columnFooters,n=i?this.rowHeaders:this.cells,a=this.viewRange;e=null==e?0:wjcCore.asInt(e),t=null==t?n.columns.length-1:wjcCore.asInt(t),a.row=Math.max(0,a.row-1e3),a.row2=Math.min(a.row2+1e3,this.rows.length-1),this.finishEditing()&&this.columns.deferUpdate(()=>{wjcCore.setCss(this._eCt,{width:this._gpCells.width});let i=wjcCore.createElement('
',n.hostElement),h=this._getCanvasContext();for(let c=e;c<=t&&c>-1&&c0&&(e.width=l+s+2)}}this.cellFactory.disposeCell(i),wjcCore.removeChild(i)})}autoSizeRow(e,t=!1,i=0){this.autoSizeRows(e,e,t,i)}autoSizeRows(e,t,i=!1,s=0){let l=0,o=i?this.topLeftCells:this.rowHeaders,r=i?this.columnHeaders:this.cells;if(i=wjcCore.asBoolean(i),s=wjcCore.asNumber(s),e=null==e?0:wjcCore.asInt(e),t=null==t?r.rows.length-1:wjcCore.asInt(t),this.finishEditing()){wjcCore.setCss(this._eCt,{width:this._gpCells.width});let i=wjcCore.createElement('',r.hostElement);this.rows.deferUpdate(()=>{let n={};for(let a=e;a<=t&&a>-1&&a0&&(r.rows[a].height=l+s))}),this.cellFactory.disposeCell(i),wjcCore.removeChild(i)}}get treeIndent(){return this._indent}set treeIndent(e){e!=this._indent&&(this._indent=wjcCore.asNumber(e,!1,!0),this.columns.onCollectionChanged())}collapseGroupsToLevel(e){this.finishEditing()&&this.deferUpdate(()=>{let t=this.rows;t.deferUpdate(()=>{for(let i=0;i=e)}})})}get selectionMode(){return this._selHdl.selectionMode}set selectionMode(e){(e=wjcCore.asEnum(e,SelectionMode))!=this.selectionMode&&(this._clearCells(),this._selHdl.selectionMode=e)}get selection(){return this._selHdl.selection.clone()}set selection(e){this._selHdl.selection=e}select(e,t=!0){this._selHdl.select(e,t)}getSelectedState(e,t){return this.cells.getSelectedState(e,t,null)}get selectedRows(){let e=[];if(this.selectionMode==SelectionMode.ListBox)for(let t=0;t-1&&i<=t.bottomRow;i++)e.push(this.rows[i])}return e}set selectedRows(e){wjcCore.assert(this.selectionMode==SelectionMode.ListBox,"This property can be set only in ListBox mode."),e=wjcCore.asArray(e),this.deferUpdate(()=>{for(let t=0,i=!0;t-1;l&&i&&(i=!1,this.select(t,this.selection.col)),s.isSelected=l}})}get selectedItems(){let e=this.selectedRows;for(let t=0;t{for(let t=0,i=!0;t-1;l&&i&&(i=!1,this.select(t,this.selection.col)),s.isSelected=l}})}scrollIntoView(e,t,i){(null==this._maxOffsetY||this._rows._dirty||this._cols._dirty)&&this._updateLayout();let s=this.scrollPosition,l=this._szClient.width,o=this._szClient.height-this._gpCFtr.rows.getTotalSize(),r=this.cells._getFrozenPos();if((e=wjcCore.asInt(e))>-1&&e=this._rows.frozen){let t=this._rows[e],i=this.cells.height>o?Math.round(t.pos/(this.cells.height-o)*100)/100:0,l=Math.round(this._maxOffsetY*i),n=t.pos-l,a=n+t.renderSize;a>o-s.y&&(s.y=Math.max(-n,o-a)),n-r.y<-s.y&&(s.y=-(n-r.y))}if((t=wjcCore.asInt(t))>-1&&t=this._cols.frozen){let e=this._cols[t],i=e.pos+e.renderSize;i>-s.x+l&&(s.x=Math.max(-e.pos,l-i)),e.pos-r.x<-s.x&&(s.x=-(e.pos-r.x))}return!s.equals(this._ptScrl)&&(this.scrollPosition=s,i&&(this._updateScrollPosition(),this.refresh()),!0)}isRangeValid(e){return e.isValid&&e.bottomRow0
',document.body),e&&i.setAttribute("class",e.getAttribute("class")),t=i.children[0]);let s=t.offsetHeight;return(isNaN(s)||s<=6)&&(s=28),wjcCore.removeChild(i),s}_getCollectionView(e){return wjcCore.asCollectionView(e)}_getCanvasContext(){let e=document.createElement("canvas").getContext("2d"),t=getComputedStyle(this.hostElement);return e.font=t.fontSize+" "+t.fontFamily.split(",")[0],e}_getWidestRow(e,t,i,s){let l=0,o=0,r=e.columns[i].dataType==wjcCore.DataType.Boolean;for(let n=t.row;n<=t.row2;n++)if(e.rows[n].isVisible){let t=e.getCellData(n,i,!0),a=s.measureText(t).width,h=this.getMergedRange(e,n,i,!1);if(h&&h.columnSpan>1&&(a/=h.columnSpan),a>o&&(o=a,l=n),r)break}return l}_getDesiredWidth(e,t,i,s){let l=this.getMergedRange(e,t,i,!1),o=s.style;return this.cellFactory.updateCell(e,t,i,s,l),o.width=o.top=o.left="",s.offsetWidth/(l&&l.columnSpan>1?l.columnSpan:1)}_getDesiredHeight(e,t,i,s){let l=s.style,o=this.getMergedRange(e,t,i,!1),r=o?o.rowSpan:1;return this.cellFactory.updateCell(e,t,i,s,o),s.innerHTML.trim()||(s.innerHTML=" "),l.height=l.top=l.left="",s.offsetHeight/r}_getDesiredRowHeight(e,t,i,s){let l=0;for(let o=0;o1?a.rowSpan:1,content:r.dataType==wjcCore.DataType.Number?"1":e.getCellData(t,o,!0)},h=JSON.stringify(l);null==(n=s[h])&&(n=this._getDesiredHeight(e,t,o,i),s[h]=n)}else n=this._getDesiredHeight(e,t,o,i);l=Math.max(n,l)}}return l}_getSortRowIndex(){return null!=this._sortRowIndex?this._sortRowIndex:this.columnHeaders.rows.length-1}_getEditColumnIndex(){return null!=this._editColIndex?this._editColIndex:this.rowHeaders.columns.length-1}_sortConverter(e,t,i,s){let l;if(s){if(this._mappedColumns=null,this._cv){let e=this._cv.sortDescriptions;for(let t=0;t-1&&(l=this.columns[this._mouseHdl._htDown.col],this._mappedColumns&&l.dataMap&&(this._mappedColumns[l.binding]=l.dataMap))}if(this._mappedColumns){let t=this._mappedColumns[e.property];t&&t.sortByDisplayValues&&(i=t.getDisplayValue(i))}return i}_bindGrid(e){if(this.finishEditing(),this.deferUpdate(()=>{this.autoGenerateColumns&&0==this._lastCount&&wjcCore.hasItems(this._cv)&&(e=!0);let t,i=this.selectionMode==SelectionMode.ListBox;this.preserveSelectedState&&i&&(t=this.selectedItems);let s;if(this.preserveOutlineState&&wjcCore.isFunction(window.Map)&&this.rows.maxGroupLevel>-1){s=new Map;for(let e=0;e{this._bindColumns()});let l=new wjcCore.CancelEventArgs;this.onLoadingRows(l)&&(this.rows.deferUpdate(()=>{this._bindRows()}),this.onLoadedRows(l));let o=0;if(t&&t.length)for(let e=0;e-1&&(this.rows[e].isSelected=!0,o++);if(i&&0==o&&this._lastCount>0){let e=this.selection;for(let t=e.topRow;t<=e.bottomRow&&t>-1&&t{for(let e=0;e-1)return this.rows.removeAt(e),void this._syncSelection(!1);wjcCore.assert(!1,"removed item not found on grid.")}this._bindGrid(!1)}}_cvCurrentChanged(e,t){this._syncSelection(!1)}_syncSelection(e){if(this._cv&&this.selectionMode!=SelectionMode.None){let t=this._selHdl.selection,i=t.row>-1&&t.row-1){let t=this._cv.items[e];for(;e-1?this.rows[e]:null;return t&&(t instanceof GroupRow||null==t.dataItem)?e:-1}}return this.selection.row}_getCvIndex(e){if(this._cv&&e>-1&&e-1;e--)if(t[e]===i)return e}return-1}_findRow(e){for(let t=0;t0,this._rcBounds=null}this._eTL.style.top=this._eCHdr.style.top=e?-t+"px":"",wjcCore.toggleClass(this._eTL,FlexGrid._WJS_STICKY,e),wjcCore.toggleClass(this._eCHdr,FlexGrid._WJS_STICKY,e)}_updateScrollHandler(){this._clipToScreen=this._getClipToScreen();let e=this._stickyHdr||this._clipToScreen;e!=this._scrollHandlerAttached&&(this._scrollHandlerAttached=e,e?this.addEventListener(window,"scroll",this._scroll.bind(this),!0):this.removeEventListener(window,"scroll"))}_getClipToScreen(){if(this.rows.length<=FlexGrid._MIN_VIRT_ROWS)return!1;if(this._root.clientHeight!=this._root.scrollHeight)return!1;for(let e=this.hostElement;e&&e!=document.documentElement;e=e.parentElement)if("auto"==getComputedStyle(e).overflow)return!1;return!0}_scroll(e){wjcCore.contains(e.target,this.hostElement)&&(this._clipToScreen&&(this._afClip&&cancelAnimationFrame(this._afClip),this._afClip=requestAnimationFrame(()=>{this._afClip=null,this.finishEditing(),this._updateContent(!0)})),this._stickyHdr&&(this._afSticky&&cancelAnimationFrame(this._afSticky),this._afSticky=requestAnimationFrame(()=>{this._afSticky=null;let e=new wjcCore.CancelEventArgs;this.onUpdatingLayout(e)&&(this._updateStickyHeaders(),this.onUpdatedLayout(e))})))}_updateScrollPosition(){let e=this._root,t=e.scrollTop,i=e.scrollLeft;this.rightToLeft&&"rev"==FlexGrid._getRtlMode()&&(i=e.scrollWidth-e.clientWidth-i);let s=new wjcCore.Point(-Math.abs(i),-t);return!this._ptScrl.equals(s)&&(this._ptScrl=s,this.onScrollPositionChanged(),!0)}_updateContent(e,t){let i=this._root,s=this.hostElement,l=this.cells.hostElement,o=wjcCore.getActiveElement(),r=wjcCore.contains(s,o)?o:null,n=this._activeCell,a=new wjcCore.CancelEventArgs;if(!this.onUpdatingView(a))return;wjcCore.setAttribute(l,"role",this.rows.maxGroupLevel<0?"grid":"treegrid"),this._hasValidation=wjcCore.isFunction(this._itemValidator)||this._cv&&wjcCore.isFunction(this._cv.getError);let h=!t&&this._errorTip&&this._errorTip._tips.length;if(this._offsetY=0,this._heightBrowser>this._szClient.height){let e=Math.round(-this._ptScrl.y/(this._heightBrowser-this._szClient.height)*100)/100;this._offsetY=Math.round(this._maxOffsetY*e)}this._updateScrollPosition();let c=this._gpCells._updateContent(e,t,this._offsetY);if(this._hdrVis&HeadersVisibility.Column&&(!t||this._ssHdr&HeadersVisibility.Column)&&this._gpCHdr._updateContent(e,t,0),this._hdrVis&HeadersVisibility.Row&&(!t||this._ssHdr&HeadersVisibility.Row)&&this._gpRHdr._updateContent(e,t,this._offsetY),this._hdrVis&&!t&&this._gpTL._updateContent(e,t,0),this._gpCFtr.rows.length&&(this._gpBL._updateContent(e,t,0),this._gpCFtr._updateContent(e,t,0)),this.showMarquee){let e=this._selHdl.selection,t=this._eMarquee;if(this.isRangeValid(e)){let i=this._getMarqueeRect(e),s=t.firstChild,o=t.offsetWidth-s.offsetWidth,r=t.offsetHeight-s.offsetHeight;wjcCore.setCss(t,{left:i.left+l.offsetLeft-o/2,top:i.top+l.offsetTop-r/2,width:i.width+o,height:i.height+r,visibility:i.width>0&&i.height>0?"":"collapse"})}else wjcCore.setCss(t,{left:0,top:0,width:0,height:0,visibility:"collapse"})}if(h&&this._errorTip&&this._errorTip._tips.length&&(this._toErrorTips&&clearTimeout(this._toErrorTips),this._toErrorTips=setTimeout(()=>{this._errorTip.hide();let e=this._errorTip._tips;for(let i=0;i=0;for(let l=0;l=t&&s.top=t&&l.bottom=t&&s.right>i.left&&(s.left=i.left-s.width),e.rightCol>=t&&l.left>i.left&&(l.left=i.left)):(e.leftCol>=t&&s.left=t&&l.right{let t=new Column(e);t._setFlag(RowColFlags.AutoGenerated,!0),t.name=e.binding,t.header=wjcCore.toHeaderCase(e.binding),t.dataType==wjcCore.DataType.Number&&(t.width=80),this.columns.push(t)}),this._updateColumnTypes()}_updateColumnTypes(){let e=this._cv;if(wjcCore.hasItems(e)){let t=e.items[0],i=this.columns;for(let e=0;e0&&this.showGroups)for(let e=0;e0}return!1}_wantsInput(e){return this._isInputElement(e)&&!this.activeEditor&&!this._edtHdl._isNativeCheckbox(e)&&!wjcCore.hasClass(e,"wj-grid-ime")&&wjcCore.contains(document.body,e)}static _getMaxSupportedCssHeight(){if(!FlexGrid._maxCssHeight){let e=335e5;wjcCore.isIE()?e=15e5:wjcCore.isFirefox()&&(e=175e5),FlexGrid._maxCssHeight=e}return FlexGrid._maxCssHeight}static _getRtlMode(){if(!FlexGrid._rtlMode){let e=wjcCore.createElement('');document.body.appendChild(e);let t=e.scrollLeft;e.scrollLeft=-1e3;let i=e.scrollLeft;wjcCore.removeChild(e),FlexGrid._rtlMode=i<0?"neg":t>0?"rev":"std"}return FlexGrid._rtlMode}}FlexGrid._WJS_STICKY="wj-state-sticky",FlexGrid._WJS_MEASURE="wj-state-measuring",FlexGrid._WJS_UPDATING="wj-state-updating",FlexGrid._MIN_VIRT_ROWS=200,FlexGrid.controlTemplate='',exports.FlexGrid=FlexGrid;class CellRangeEventArgs extends wjcCore.CancelEventArgs{constructor(e,t,i){super(),this._p=wjcCore.asType(e,GridPanel,!0),this._rng=wjcCore.asType(t,CellRange,!0),this._data=i}get panel(){return this._p}get range(){return this._rng.clone()}get row(){return this._rng.row}get col(){return this._rng.col}get data(){return this._data}set data(e){this._data=e}}exports.CellRangeEventArgs=CellRangeEventArgs;class FormatItemEventArgs extends CellRangeEventArgs{constructor(e,t,i){super(e,t),this._cell=wjcCore.asType(i,HTMLElement)}get cell(){return this._cell}}exports.FormatItemEventArgs=FormatItemEventArgs;class CellEditEndingEventArgs extends CellRangeEventArgs{constructor(){super(...arguments),this._stayInEditMode=!1,this._refresh=!0}get stayInEditMode(){return this._stayInEditMode}set stayInEditMode(e){this._stayInEditMode=wjcCore.asBoolean(e)}get refresh(){return this._refresh}set refresh(e){this._refresh=wjcCore.asBoolean(e)}}exports.CellEditEndingEventArgs=CellEditEndingEventArgs;var CellType;!function(e){e[e.None=0]="None",e[e.Cell=1]="Cell",e[e.ColumnHeader=2]="ColumnHeader",e[e.RowHeader=3]="RowHeader",e[e.TopLeft=4]="TopLeft",e[e.ColumnFooter=5]="ColumnFooter",e[e.BottomLeft=6]="BottomLeft"}(CellType=exports.CellType||(exports.CellType={}));class GridPanel{constructor(e,t,i,s,l){this._offsetY=0,this._rng=new CellRange,this._g=wjcCore.asType(e,FlexGrid),this._ct=wjcCore.asInt(t),this._rows=wjcCore.asType(i,RowCollection),this._cols=wjcCore.asType(s,ColumnCollection),this._e=wjcCore.asType(l,HTMLElement),this._vrb=new CellRange}get grid(){return this._g}get cellType(){return this._ct}get viewRange(){return this._getViewRange()}get width(){return this._cols.getTotalSize()}get height(){return this._rows.getTotalSize()}get rows(){return this._rows}get columns(){return this._cols}getCellData(e,t,i){let s,l=this._g,o=this._rows[wjcCore.asNumber(e,!1,!0)],r=null;if(wjcCore.isString(t)&&(t=this._cols.indexOf(t))<0)throw"Invalid column name or binding.";s=this._cols[wjcCore.asNumber(t,!1,!0)];let n=l?l._getBindingColumn(this,e,s):s,a=null;if(o instanceof GroupRow&&o.dataItem instanceof wjcCore.CollectionViewGroup&&!l.childItemsPath&&(a=o.dataItem),n.binding&&o.dataItem&&!a?r=n._binding.getValue(o.dataItem):o._ubv&&(r=o._ubv[s._hash]),null==r)switch(this._ct){case CellType.ColumnHeader:e!=this._rows.length-1&&n==s||(r=n.header);break;case CellType.ColumnFooter:if(n.aggregate!=wjcCore.Aggregate.None&&o instanceof GroupRow){let e=this._g.collectionView;if(e){let t=wjcCore.tryCast(e,wjcCore.CollectionView);r=t?t.getAggregate(n.aggregate,n.binding):wjcCore.getAggregate(n.aggregate,e.items,n.binding)}}break;case CellType.Cell:n.aggregate!=wjcCore.Aggregate.None&&o instanceof GroupRow&&a&&(r=a.getAggregate(n.aggregate,n.binding,this._g.collectionView))}return i&&(this.cellType==CellType.Cell&&n.dataMap&&(r=n.dataMap.getDisplayValue(r)),r=null!=r?wjcCore.Globalize.format(r,n.format||o.format):""),r}setCellData(e,t,i,s=!0,l=!0){let o,r=this._rows[wjcCore.asNumber(e,!1,!0)];if(wjcCore.isString(t)&&(t=this._cols.indexOf(t))<0)throw"Invalid column name or binding.";o=this._cols[wjcCore.asNumber(t,!1,!0)];let n=this._g?this._g._getBindingColumn(this,e,o):o;if(this._ct==CellType.Cell){if(n.dataMap&&null!=i&&(n.isRequired||""!=i)){let e=n.dataMap,t=e.getKeyValue(i);if(null==t&&null==e.getDisplayValue(null)){if(e.getDisplayValue(i)!=i);else if(!e.isEditable||e.displayMemberPath!=e.selectedValuePath)return!1}else i=t}let l=wjcCore.DataType.Object,o=n.dataType||r.dataType;if(o)l=o;else{let i=this.getCellData(e,t,!1);l=wjcCore.getType(i)}let a=n.getIsRequired(r),h=""===i||null==i;if(!a&&h)l!=wjcCore.DataType.String&&(i=null),s=!1;else if(a&&h&&s)return!1;if(s&&(i=wjcCore.changeType(i,l,n.format||r.format),l!=wjcCore.DataType.Object&&wjcCore.getType(i)!=l))return!1}if(r.dataItem&&n.binding){let e=n._binding,t=r.dataItem,s=e.getValue(t);if(i!==s&&!wjcCore.DateTime.equals(i,s)){e.setValue(t,i);let s=this._g.collectionView;if(s instanceof wjcCore.CollectionView&&t!=s.currentEditItem){let e=new wjcCore.NotifyCollectionChangedEventArgs(wjcCore.NotifyCollectionChangedAction.Change,t,s.items.indexOf(t));s.onCollectionChanged(e)}}}else r._ubv||(r._ubv={}),r._ubv[o._hash]=i;return l&&this._g&&this._g.invalidate(),!0}getCellBoundingRect(e,t,i){let s=this._g,l=this.rows[e],o=this.columns[t],r=new wjcCore.Rect(o.pos,l.pos,o.renderSize,l.renderSize);if(s.rightToLeft&&(r.left=this.hostElement.clientWidth-r.right,wjcCore.isIE()||wjcCore.isFirefox()||(r.left-=s._root.offsetWidth-s._root.clientWidth)),!i){let e=this.hostElement.getBoundingClientRect();r.left+=e.left,r.top+=e.top-this._offsetY}return e-1;e++)c=this._renderRow(e,h,t,c);for(;l.childElementCount>c;){let e=l.lastElementChild;l.removeChild(e),this._removeExtraCells(e,0)}return this._activeCell}_clearCells(){let e=this.hostElement;for(let t=e.childElementCount-1;t>=0;t--){let i=e.children[t];e.removeChild(i);for(let e=i.childElementCount-1;e>=0;e--)this._cf.disposeCell(i.children[e])}}_reorderCells(e,t){if(this._g._reorderCells&&t.isValid&&e.isValid&&e.intersects(t)){if(e.row!=t.row){let i=this._e,s=e.row-t.row,l=Math.max(1,e.rowSpan-1);if(0!=s&&Math.abs(s)0){let l=e,o=Math.min(e+s,t-1),r=this._createRange(i,l,o);r&&oe){let t=i.children[e];i.insertBefore(r.extractContents(),t)}}}}if(e.col!=t.col){let i=this._e,s=e.col-t.col,l=Math.max(1,e.columnSpan-1);if(0!=s&&Math.abs(s)0){let t=e,i=Math.min(e+s,o-1),r=this._createRange(l,t,i);r&&ie){let t=l.children[e];l.insertBefore(r.extractContents(),t)}}}}}}}}_createRange(e,t,i){if(i>t&&i<=e.children.length&&t>-1){this._docRange||(this._docRange=document.createRange());let s=this._docRange;return s.setStart(e,t),s.setEnd(e,i),s}return null}_renderColHdrRow(e,t){if(t)return 1;let i=this._e.children[0];i||(i=wjcCore.createElement('',this._e));let s=this._g,l=s?s.columnHeaders.rows.ariaLabel:null;wjcCore.setAttribute(i,"aria-label",l),wjcCore.setAttribute(i,"aria-selected",null);let o=0,r=this._g._getRowHeaderPath();r&&(o=this._renderRowHdrCell(i,-1,r.path));for(let s=0;s-1;s++)o=this._renderColHdrCell(i,s,e,t,o);return this._removeExtraCells(i,o),1}_renderColHdrCell(e,t,i,s,l){let o=this.grid,r=this.columns[t];if(r.renderSize<=0)return l;if(s)return l+1;let n=e.children[l];if(n||(n=wjcCore.createElement('',e)),wjcCore.setAttribute(n,"role","columnheader"),n&&this._recycle&&o._lazyRender){let e=n[GridPanel._INDEX_KEY];if(e&&-1==e.row&&e.col==t&&t>=this.columns.frozen)return l+1}if(n.textContent=this.columns[t].header,wjcCore.setCss(n,{position:"fixed",left:r.pos,top:-32e3,width:r.renderWidth,height:.1,overflow:"hidden",opacity:"0",pointerEvents:"none"}),r.describedById||this.columns.describedById){let e=[r.describedById,this.columns.describedById].join(" ").trim();wjcCore.setAttribute(n,"aria-describedby",e||null)}if(o.allowSorting){let e="none";switch(o._getBindingColumn(this,0,r).currentSort){case"+":e="ascending";break;case"-":e="descending"}wjcCore.setAttribute(n,"aria-sort",e)}return o.isReadOnly||(wjcCore.setAttribute(n,"aria-readonly",r.isReadOnly),wjcCore.setAttribute(n,"aria-required",r.getIsRequired())),n[GridPanel._INDEX_KEY]={row:-1,col:t,panel:this},l+1}_renderRowHdrCell(e,t,i){let s=e.children[0];return s||(s=wjcCore.createElement('',e)),s.setAttribute("role",t<0?"columnheader":"rowheader"),s.textContent=i?i.toString():"",wjcCore.setCss(s,{position:"fixed",left:-32e3,top:-32e3,width:.1,height:.1,overflow:"hidden",opacity:"0"}),s[GridPanel._INDEX_KEY]={row:t,col:-1,panel:this},1}_renderRow(e,t,i,s){let l=this._g,o=this.rows[e];if(o.renderSize<=0)return s;let r=this._e.children[s];if(r||(r=wjcCore.createElement('',this._e)),this._ct==CellType.Cell){r.setAttribute("role","row");let t=SelectionMode;switch(l.selectionMode){case t.Row:case t.RowRange:case t.ListBox:let i=o.isSelected||this._g._selHdl.selection.containsRow(e);wjcCore.setAttribute(r,"aria-selected",!!i)}wjcCore.setAttribute(r,"aria-level",o instanceof GroupRow?o.level+1:null),wjcCore.setAttribute(r,"aria-expanded",o instanceof GroupRow?!o.isCollapsed:null),this.rows.ariaLabel&&wjcCore.setAttribute(r,"aria-label",this.rows.ariaLabel)}let n=0;if(this._ct==CellType.Cell){let t=this._g._getRowHeaderPath();t&&(n=this._renderRowHdrCell(r,e,t.getValue(o.dataItem)))}for(let s=0;s-1;s++)n=this._renderCell(r,e,s,t,i,n);return this._removeExtraCells(r,n),s+1}_renderCell(e,t,i,s,l,o){let r=this._g,n=r.getMergedRange(this,t,i);if(n){for(let e=Math.max(s.row,n.row);e=this.rows.frozen&&i>=this.columns.frozen&&(l=!0)}let c=SelectedState,d=this.getSelectedState(t,i,n),g=d==c.Cursor||d==c.Active;return h&&l?(wjcCore.toggleClass(h,"wj-state-active",g),wjcCore.toggleClass(h,"wj-state-selected",d==c.Cursor),wjcCore.toggleClass(h,"wj-state-multi-selected",d==c.Selected),wjcCore.setAttribute(h,"aria-selected",g||d!=c.None),g&&(this._activeCell=h),o+1):(h||((h=document.createElement("div")).tabIndex=-1,e.appendChild(h)),g&&(this._activeCell=h),this._ct==CellType.Cell&&(wjcCore.setAttribute(h,"role","gridcell"),wjcCore.setAttribute(h,"aria-selected",d!=c.None||g),wjcCore.setAttribute(h,"aria-readonly",!r.canEditCell(t,i)||null),wjcCore.setAttribute(h,"aria-required",a.getIsRequired())),r.cellFactory.updateCell(this,t,i,h,n),h[GridPanel._INDEX_KEY]={row:t,col:i,rng:n,panel:this},o+1)}_removeExtraCells(e,t){for(;e.childElementCount>t;){let t=e.lastElementChild;e.removeChild(t),this._cf.disposeCell(t)}}_getViewRange(){let e=this._g,t=e._ptScrl,i=this._rows,s=this._cols,l=new CellRange(0,0,i.length-1,s.length-1);if(this._ct==CellType.Cell||this._ct==CellType.RowHeader){let s=-t.y+this._offsetY,o=e._szClient.height,r=Math.min(i.frozen,i.length-1);if(r>0){let e=i[r-1].pos;s+=e,o-=e}if(l.row=Math.min(i.length-1,Math.max(i.frozen,i.getItemAt(s+1))),l.row2=i.getItemAt(s+o),e._clipToScreen){let t=e.hostElement.getBoundingClientRect();t.top<0&&(l.row=Math.max(l.row,i.getItemAt(-t.top-e._ptScrl.y)-1)),t.bottom>innerHeight&&(l.row2=Math.min(l.row2,i.getItemAt(-t.top-e._ptScrl.y+innerHeight)+1))}}if(this._ct==CellType.Cell||this._ct==CellType.ColumnHeader){let i=-t.x,o=e._szClient.width,r=Math.min(s.frozen,s.length-1);if(r>0){let e=s[r-1].pos;i+=e,o-=e}l.col=Math.min(s.length-1,Math.max(s.frozen,s.getItemAt(i+1))),l.col2=s.getItemAt(i+o)}return i.length<=i.frozen&&(l.row=l.row2=-1),s.length<=s.frozen&&(l.col=l.col2=-1),l}_getFrozenPos(){let e=this._rows.frozen,t=this._cols.frozen,i=e>0?this._rows[e-1]:null,s=t>0?this._cols[t-1]:null,l=i?i.pos+i.renderSize:0,o=s?s.pos+s.renderSize:0;return new wjcCore.Point(o,l)}}GridPanel._INDEX_KEY="wj-cell-index",exports.GridPanel=GridPanel;class CellFactory{updateCell(e,t,i,s,l,o){let r=e.grid,n=r.rightToLeft,a=CellType,h=e.rows,c=e.columns,d=h[t],g=c[i],w=t,u=i,_=d instanceof GroupRow?d:null,C=d instanceof _NewRowTemplate?d:null,p=g.renderWidth,f=d.renderHeight,m=e.cellType,R="wj-cell",y="",v={display:""};if(0!=o&&s.firstElementChild&&(1==s.childNodes.length&&"checkbox"==s.firstElementChild.type||(s.textContent="")),l&&!l.isSingleCell){t=l.row,i=l.col,w=l.row2,u=l.col2,d=h[t],g=c[i],_=d instanceof GroupRow?d:null;let s=l.getRenderSize(e);f=s.height,p=s.width}let j=r._getBindingColumn(e,t,g),S=j.dataType||d.dataType,E=j.dataMap&&0!=j.showDropDown||d.dataMap&&0!=d.showDropDown,b=S==wjcCore.DataType.Boolean&&!E,x=g.pos,z=d.pos;r._useFrozenDiv()&&m==a.Cell&&!r.editRange?(t=c.frozen&&(x+=r._ptScrl.x),i=h.frozen&&(z+=r._ptScrl.y)):(t-1&&i==r.columns.firstVisibleIndex&&r.treeIndent){let e=_?Math.max(0,_.level):r.rows.maxGroupLevel+1,t=r.treeIndent*e+r._cellPadLeft;n?v.paddingRight=t+"px":v.paddingLeft=t+"px"}if(0!=o){let l=e.getCellData(t,i,!1),o=e.getCellData(t,i,!0);if(m==a.Cell&&i==r.columns.firstVisibleIndex&&_&&_.hasChildren&&!this._isEditingCell(r,t,i)){let e=this._getTreeBtn(_);o=wjcCore.escapeHtml(o)||_.getGroupHeader(),s.innerHTML=e.outerHTML+" "+o,y=""}else if(m==a.ColumnHeader&&j.currentSort&&r.showSort&&(w==r._getSortRowIndex()||j!=g))R+=" wj-sort-"+("+"==j.currentSort?"asc":"desc"),s.innerHTML=wjcCore.escapeHtml(o)+" "+this._getSortIcon(j);else if(m!=a.RowHeader||i!=r._getEditColumnIndex()||o)if(m!=a.Cell||S!=wjcCore.DataType.Boolean||E||_&&!wjcCore.isBoolean(l))if(m==a.Cell&&this._isEditingCell(r,t,i)){let l=j.inputType||d.inputType;if(l||(l=S!=wjcCore.DataType.Number||E?"text":"tel"),!E&&!j.mask&&!d.mask){let s=e.getCellData(t,i,!1);if(wjcCore.isNumber(s)){let e=s.toString(),t=j.format||d.format;if(t&&s!=Math.round(s)){let i=e.match(/\.(\d+)/)[1].length;t=t.replace(/([a-z])(\d*)(.*)/gi,"$01"+i+"$3")}o=wjcCore.Globalize.formatNumber(s,t,!0)}}s.innerHTML=(j.multiLine||d.multiLine)&&"checkbox"!=l?'':'';let n=s.children[0];wjcCore.addClass(n,"wj-grid-editor wj-form-control"),wjcCore.disableAutoComplete(n),n.value=o,n.required=j.getIsRequired(d),wjcCore.setAttribute(n,"aria-required",n.required);let a=j.maxLength||d.maxLength;a&&(n.maxLength=a),n.style.textAlign=j.getAlignment(d);let h=j.mask||d.mask;h&&new wjcCore._MaskProvider(n,h),r._edtHdl._edt=n}else m==a.Cell&&(d.isContentHtml||j.isContentHtml)?s.innerHTML=o:s.textContent=o||"";else{let e=s.firstChild;e instanceof HTMLInputElement&&"checkbox"==e.type||(s.innerHTML='',e=s.firstChild),e.checked=1==l,e.indeterminate=null==l,e.disabled=!r.canEditCell(t,i),e.disabled&&(e.style.cursor="default"),r.editRange&&r.editRange.contains(t,i)&&(r._edtHdl._edt=e)}else{let e=r.editableCollectionView,t=e?e.currentEditItem:null;t&&d.dataItem==t?s.innerHTML='':d instanceof _NewRowTemplate&&(s.innerHTML='')}if(m==a.Cell&&E&&tryGetModuleWijmoInput()&&r.showDropDown&&r.canEditCell(t,i)){if(!CellFactory._ddBtn){let e=CellFactory._WJC_DROPDOWN,t=wjcCore.createElement('');wjcCore.setAriaLabel(t,wjcCore.culture.FlexGrid.ariaLabels.toggleDropDown),wjcCore.setAttribute(t,"aria-expanded",!1),CellFactory._ddBtn=t}let e=CellFactory._ddBtn.cloneNode(!0);s.appendChild(e)}}if(m==a.RowHeader||m==a.ColumnHeader){let e=m==a.RowHeader?!_&&!C&&d.allowDragging&&0!=(r.allowDragging&AllowDragging.Rows):g.allowDragging&&0!=(r.allowDragging&AllowDragging.Columns);wjcCore.setAttribute(s,"draggable",e?"true":null)}R+=y,s.className!=R&&(s.className=R);let D=s.style;for(var L in v)D[L]!==v[L]&&(D[L]=v[L]);if(r._edtHdl._edt&&r._edtHdl._edt.parentElement==s){let e=r._root,t=e.getBoundingClientRect(),i=s.getBoundingClientRect(),l=t.top+e.clientHeight-i.top,o=t.left+e.clientWidth-i.left;i.height>l&&(s.style.height=l+"px"),i.width>o&&(s.style.width=o+"px")}if((m==a.Cell||m==a.RowHeader)&&r._getShowErrors()){let l=r._getError(e,t,i);r._edtHdl._setCellError(s,l)}if(r.itemFormatter&&r.itemFormatter(e,t,i,s),r.formatItem.hasHandlers){let l=CellFactory._fmtRng;l?l.setRange(t,i,w,u):l=CellFactory._fmtRng=new CellRange(t,i,w,u);let o=new FormatItemEventArgs(e,l,s);r.onFormatItem(o)}}disposeCell(e){}getEditorValue(e){let t=e._edtHdl._edt;if(t instanceof HTMLInputElement&&"checkbox"==t.type)return t.checked;if(t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement){let e=t.maxLength;return wjcCore.isNumber(e)&&e>-1&&t.value.length>e?t.value.substr(0,e):t.value}return null}_isEditingCell(e,t,i){return e.editRange&&e.editRange.contains(t,i)}_getTreeBtn(e){let t=CellFactory._WJC_COLLAPSE,i=(e.isCollapsed?"":"down-")+(e.grid.rightToLeft?"left":"right"),s=wjcCore.createElement('');return wjcCore.setAriaLabel(s,wjcCore.culture.FlexGrid.ariaLabels.toggleGroup),wjcCore.setAttribute(s,"aria-expanded",!e.isCollapsed),s}_getSortIcon(e){return''}}CellFactory._WJC_COLLAPSE="wj-elem-collapse",CellFactory._WJC_DROPDOWN="wj-elem-dropdown",exports.CellFactory=CellFactory;class CellRange{constructor(e=-1,t=-1,i=e,s=t){this.setRange(e,t,i,s)}setRange(e=-1,t=-1,i=e,s=t){this._row=wjcCore.asInt(e),this._col=wjcCore.asInt(t),this._row2=wjcCore.asInt(i),this._col2=wjcCore.asInt(s)}get row(){return this._row}set row(e){this._row=wjcCore.asInt(e)}get col(){return this._col}set col(e){this._col=wjcCore.asInt(e)}get row2(){return this._row2}set row2(e){this._row2=wjcCore.asInt(e)}get col2(){return this._col2}set col2(e){this._col2=wjcCore.asInt(e)}clone(){return new CellRange(this._row,this._col,this._row2,this._col2)}copy(e){this.setRange(e._row,e._col,e._row2,e._col2)}get rowSpan(){return Math.abs(this._row2-this._row)+1}get columnSpan(){return Math.abs(this._col2-this._col)+1}get topRow(){return Math.min(this._row,this._row2)}get bottomRow(){return Math.max(this._row,this._row2)}get leftCol(){return Math.min(this._col,this._col2)}get rightCol(){return Math.max(this._col,this._col2)}get isValid(){return this._row>-1&&this._col>-1&&this._row2>-1&&this._col2>-1}get isSingleCell(){return this._row==this._row2&&this._col==this._col2}contains(e,t){let i=wjcCore.tryCast(e,CellRange);if(i)return i.topRow>=this.topRow&&i.bottomRow<=this.bottomRow&&i.leftCol>=this.leftCol&&i.rightCol<=this.rightCol;if(wjcCore.isInt(e)&&wjcCore.isInt(t))return e>=this.topRow&&e<=this.bottomRow&&t>=this.leftCol&&t<=this.rightCol;throw"contains expects a CellRange or row/column indices."}containsRow(e){return wjcCore.asInt(e)>=this.topRow&&e<=this.bottomRow}containsColumn(e){return wjcCore.asInt(e)>=this.leftCol&&e<=this.rightCol}intersects(e){return this.intersectsRow(e)&&this.intersectsColumn(e)}intersectsRow(e){return e&&!(this.bottomRowe.bottomRow)}intersectsColumn(e){return e&&!(this.rightCole.rightCol)}getRenderSize(e){let t=new wjcCore.Size(0,0);if(this.isValid){for(let i=this.topRow;i<=this.bottomRow;i++)t.height+=e.rows[i].renderSize;for(let i=this.leftCol;i<=this.rightCol;i++)t.width+=e.columns[i].renderSize}return t}equals(e){return e instanceof CellRange&&this._row==e._row&&this._col==e._col&&this._row2==e._row2&&this._col2==e._col2}}exports.CellRange=CellRange;var RowColFlags;!function(e){e[e.Visible=1]="Visible",e[e.AllowResizing=2]="AllowResizing",e[e.AllowDragging=4]="AllowDragging",e[e.AllowMerging=8]="AllowMerging",e[e.AllowSorting=16]="AllowSorting",e[e.AutoGenerated=32]="AutoGenerated",e[e.Collapsed=64]="Collapsed",e[e.ParentCollapsed=128]="ParentCollapsed",e[e.Selected=256]="Selected",e[e.ReadOnly=512]="ReadOnly",e[e.HtmlContent=1024]="HtmlContent",e[e.WordWrap=2048]="WordWrap",e[e.MultiLine=4096]="MultiLine",e[e.HasTemplate=8192]="HasTemplate",e[e.RowDefault=3]="RowDefault",e[e.ColumnDefault=23]="ColumnDefault"}(RowColFlags=exports.RowColFlags||(exports.RowColFlags={}));class RowCol{constructor(){this._list=null,this._pos=0,this._idx=-1,this._vidx=-1,this.gridChanged=new wjcCore.Event}get dataType(){return this._type}set dataType(e){e=wjcCore.asEnum(e,wjcCore.DataType,!0),this._type!=e&&(this._type=e,this.grid&&this.grid.invalidate())}get inputType(){return this._inpType}set inputType(e){this._inpType=wjcCore.asString(e,!0)}get mask(){return this._mask}set mask(e){this._mask=wjcCore.asString(e,!0)}get maxLength(){return this._maxLen}set maxLength(e){this._maxLen=wjcCore.asNumber(e,!0,!0)}get align(){return this._align}set align(e){this._align!=e&&(this._align=e,this.onPropertyChanged())}get format(){return this._fmt}set format(e){this._fmt!=e&&(this._fmt=e,this.onPropertyChanged())}get dataMap(){return this._map}set dataMap(e){this._map!=e&&(this._map&&this._map.mapChanged.removeHandler(this.onPropertyChanged,this),wjcCore.isArray(e)&&(e=new DataMap(e,null,null)),this._map=wjcCore.asType(e,DataMap,!0),this._map&&this._map.mapChanged.addHandler(this.onPropertyChanged,this),this.onPropertyChanged())}get showDropDown(){return this._showDropDown}set showDropDown(e){e!=this._showDropDown&&(this._showDropDown=wjcCore.asBoolean(e,!0),this.grid&&this.grid.invalidate())}get dropDownCssClass(){return this._ddCssClass}set dropDownCssClass(e){this._ddCssClass=wjcCore.asString(e)}get visible(){return this._getFlag(RowColFlags.Visible)}set visible(e){this._setFlag(RowColFlags.Visible,e)}get isVisible(){return!!this._getFlag(RowColFlags.Visible)&&(!this._getFlag(RowColFlags.ParentCollapsed)||this instanceof _NewRowTemplate)}get pos(){return this._list&&this._list._dirty&&this._list._update(),this._pos}get index(){return this._list&&this._list._dirty&&this._list._update(),this._idx}get visibleIndex(){return this._list&&this._list._dirty&&this._list._update(),this.isVisible?this._vidx:-1}get size(){return this._sz}set size(e){e!=this._sz&&(this._sz=wjcCore.asNumber(e,!0),this.onPropertyChanged())}get renderSize(){if(!this.isVisible)return 0;let e=this._sz,t=this._list;return t&&((null==e||e<0)&&(e=t.defaultSize),null!=t.minSize&&et.maxSize&&(e=t.maxSize)),null!=this._szMin&ðis._szMax&&(e=this._szMax),e}get allowResizing(){return this._getFlag(RowColFlags.AllowResizing)}set allowResizing(e){this._setFlag(RowColFlags.AllowResizing,e)}get allowDragging(){return this._getFlag(RowColFlags.AllowDragging)}set allowDragging(e){this._setFlag(RowColFlags.AllowDragging,e)}get allowMerging(){return this._getFlag(RowColFlags.AllowMerging)}set allowMerging(e){this._setFlag(RowColFlags.AllowMerging,e)}get isSelected(){return this._getFlag(RowColFlags.Selected)}set isSelected(e){if(this._setFlag(RowColFlags.Selected,e,!0)){let e=this.grid;e&&e.refreshCells(!1,!0,!0)}}get isReadOnly(){return this._getFlag(RowColFlags.ReadOnly)}set isReadOnly(e){this._setFlag(RowColFlags.ReadOnly,e)}get isRequired(){return this._required}set isRequired(e){this._required=wjcCore.asBoolean(e,!0)}get isContentHtml(){return this._getFlag(RowColFlags.HtmlContent)}set isContentHtml(e){this.isContentHtml!=e&&(this._setFlag(RowColFlags.HtmlContent,e),this.grid&&this.grid.invalidate())}get wordWrap(){return this._getFlag(RowColFlags.WordWrap)}set wordWrap(e){this._setFlag(RowColFlags.WordWrap,e)}get multiLine(){return this._getFlag(RowColFlags.MultiLine)}set multiLine(e){this._setFlag(RowColFlags.MultiLine,e)}get cssClass(){return this._cssClass}set cssClass(e){e!=this._cssClass&&(this._cssClass=wjcCore.asString(e),this.grid&&this.grid.invalidate())}get cssClassAll(){return this._cssClassAll}set cssClassAll(e){e!=this._cssClassAll&&(this._cssClassAll=wjcCore.asString(e),this.grid&&this.grid.invalidate())}get grid(){return this._list?this._list._g:null}get collectionView(){return this.grid?this.grid.collectionView:null}onPropertyChanged(){this._list&&(this._list._dirty=!0,this.grid.invalidate())}onGridChanged(e){this.gridChanged.raise(this,e)}_setList(e){e!=this._list&&(this._list=e,this.onGridChanged())}_getFlag(e){return 0!=(this._f&e)}_setFlag(e,t,i){return t!=this._getFlag(e)&&(this._f=t?this._f|e:this._f&~e,i||this.onPropertyChanged(),!0)}}exports.RowCol=RowCol;class Column extends RowCol{constructor(e){super(),this._f=RowColFlags.ColumnDefault,this._hash=Column._ctr.toString(36),Column._ctr++,e&&wjcCore.copy(this,e)}get name(){return this._name}set name(e){this._name=e}get binding(){return this._binding?this._binding.path:null}set binding(e){if(e!=this.binding){let t=wjcCore.asString(e);if(this._binding=t?new wjcCore.Binding(t):null,!this._type&&this.grid&&this._binding){let e=this.grid.collectionView;if(e&&e.sourceCollection&&e.sourceCollection.length){let t=e.sourceCollection[0];this._type=wjcCore.getType(this._binding.getValue(t))}}this.onPropertyChanged()}}get sortMemberPath(){return this._bindingSort?this._bindingSort.path:null}set sortMemberPath(e){if(e!=this.sortMemberPath){let t=wjcCore.asString(e);this._bindingSort=t?new wjcCore.Binding(t):null,this.onPropertyChanged()}}get width(){return null!=this._szStar?this._szStar:this.size}set width(e){null!=Column._parseStarSize(e)?(this._szStar=e,this.onPropertyChanged()):(this._szStar=null,this.size=wjcCore.asNumber(e,!0))}get minWidth(){return this._szMin}set minWidth(e){e!=this._szMin&&(this._szMin=wjcCore.asNumber(e,!0,!0),this.onPropertyChanged())}get maxWidth(){return this._szMax}set maxWidth(e){e!=this._szMax&&(this._szMax=wjcCore.asNumber(e,!0,!0),this.onPropertyChanged())}get quickAutoSize(){return this._quickSize}set quickAutoSize(e){this._quickSize=wjcCore.asBoolean(e,!0)}_getQuickAutoSize(){return!!this.grid._getQuickAutoSize()&&(wjcCore.isBoolean(this._quickSize)?this._quickSize:!(this.isContentHtml||this.wordWrap||this.multiLine||this._getFlag(RowColFlags.HasTemplate)))}get renderWidth(){return this.renderSize}get header(){return this._hdr?this._hdr:this.binding}set header(e){this._hdr!=e&&(this._hdr=e,this.onPropertyChanged())}get allowSorting(){return this._getFlag(RowColFlags.AllowSorting)}set allowSorting(e){this._setFlag(RowColFlags.AllowSorting,e)}get currentSort(){let e=this.grid?this.grid.collectionView:null,t=e?e.sortDescriptions:null,i=t&&t.length?this._getBindingSort():null;if(i)for(let e=0;e0:!e||e.dataType!=wjcCore.DataType.String||(null!=e.dataMap||null!=e.mask&&e.mask.length>0)}getAlignment(e){if(null!=this._align)return this._align;if(e&&null!=e.align)return e.align;if(!this._map)switch(this.dataType){case wjcCore.DataType.Boolean:return"center";case wjcCore.DataType.Number:return"right"}if(e&&!e.dataMap)switch(e.dataType){case wjcCore.DataType.Boolean:return"center";case wjcCore.DataType.Number:return"right"}return""}_getBindingSort(){return this.sortMemberPath?this.sortMemberPath:this.binding?this.binding:null}static _parseStarSize(e){if(wjcCore.isString(e)&&e.length>0&&"*"==e[e.length-1]){let t=1==e.length?1:1*e.substr(0,e.length-1);if(t>0&&!isNaN(t))return t}return null}}Column._ctr=0,exports.Column=Column;class Row extends RowCol{constructor(e){super(),this._f=RowColFlags.ColumnDefault,this._data=e}get dataItem(){return this._data}set dataItem(e){this._data=e}get height(){return this.size}set height(e){this.size=e}get renderHeight(){return this.renderSize}}exports.Row=Row;class GroupRow extends Row{constructor(){super(),this._level=-1,this.isReadOnly=!0}get level(){return this._level}set level(e){wjcCore.asInt(e),e!=this._level&&(this._level=e,this.onPropertyChanged())}get hasChildren(){if(null!=this.grid&&null!=this._list){this._list._update();let e=this.indexthis.level)}return!0}get isCollapsed(){return this._getFlag(RowColFlags.Collapsed)}set isCollapsed(e){wjcCore.asBoolean(e),e!=this.isCollapsed&&null!=this._list&&this._setCollapsed(e)}getGroupHeader(){let e=this.grid,t=e.groupHeaderFormat||wjcCore.culture.FlexGrid.groupHeaderFormat,i=wjcCore.tryCast(this.dataItem,wjcCore.CollectionViewGroup);if(i&&t&&e.showGroups&&!e.childItemsPath){let s=i.groupDescription.propertyName,l=i.name,o=e.getColumn(s),r=this.isContentHtml;o?(r=r||o.isContentHtml,o.header&&(s=o.header),o.dataMap?l=o.dataMap.getDisplayValue(l):o.format&&(l=wjcCore.Globalize.format(l,o.format))):s=wjcCore.toHeaderCase(s);let n=i.getAggregate(wjcCore.Aggregate.CntAll,null,e.collectionView);return wjcCore.format(t,{name:wjcCore.escapeHtml(s),value:r?l:wjcCore.escapeHtml(l),level:i.level,count:n})}return""}_setCollapsed(e){let t=this.grid,i=t.rows,s=this.getCellRange(),l=new CellRangeEventArgs(t.cells,new CellRange(this.index,-1));t.onGroupCollapsedChanging(l)&&(t.deferUpdate(()=>{i.deferUpdate(()=>{this._setFlag(RowColFlags.Collapsed,e,!0);for(let t=s.topRow+1;t<=s.bottomRow&&t>-1&&t0&&this[0].renderSize)return 0;e=Math.round(e);let t,i,s=this.length,l=0,o=s-1;for(;l<=o;)if(t=l+o>>>1,(i=this[t])._pos>e&&t>0)o=t-1;else{if(!(i._pos+i.renderSize<=e&&t0&&!this[t].renderSize;)t--;for(;t0)return s;break;case l.Prev:for(s=e-1;s>=0;s--)if(this[s].renderSize>0)return s;break;case l.End:for(s=this.length-1;s>=0;s--)if(this[s].renderSize>0)return s;break;case l.Home:for(s=0;s0)return s;break;case l.NextPage:return(s=this.getItemAt(this[e].pos+this[e].renderSize+i))<0?this.getNextCell(e,SelMove.End,i):s==e&&s0&&this[s-1].renderSize?s-1:s}return e}canMoveElement(e,t){if(t==e)return!1;if(e<0||e>=this.length||t>=this.length)return!1;t<0&&(t=this.length-1);let i=Math.min(e,t),s=Math.max(e,t);for(let e=i;e<=s;e++)if(!this[e].allowDragging)return!1;return!(this[t]instanceof _NewRowTemplate)}moveElement(e,t){if(this.canMoveElement(e,t)){let i=this[e];this.removeAt(e),t<0&&(t=this.length),this.insert(t,i)}}onCollectionChanged(e=wjcCore.NotifyCollectionChangedEventArgs.reset){this._dirty=!0,this._g.invalidate(),super.onCollectionChanged(e)}push(e){return e._setList(this),super.push(e)}splice(e,t,i){for(let i=0;i0&&(s+=e,i++,l-1?this[t]:null}indexOf(e){if(e instanceof Column)return super.indexOf(e);for(let t=0;t0?o._sz=s:(o._sz=Math.max(0,Math.round(Column._parseStarSize(o._szStar)/i*e)),s-=o.renderWidth))}return this._dirty=!0,this._update(),!0}return!1}}exports.ColumnCollection=ColumnCollection;class RowCollection extends RowColCollection{constructor(){super(...arguments),this._maxLevel=-1}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){e!=this.ariaLabel&&(this._ariaLabel=wjcCore.asString(e),this._g&&this._g.refresh())}get maxGroupLevel(){return this._dirty&&this._update(),this._maxLevel}_update(){if(super._update()){this._maxLevel=-1;for(let e=0;ethis._maxLevel&&(this._maxLevel=t.level)}return!0}return!1}}exports.RowCollection=RowCollection;class HitTestInfo{constructor(e,t){this._row=-1,this._col=-1,this._edge=0;let i;if(t instanceof Element){if(wjcCore.closest(t,".wj-flexgrid")!=e.hostElement)return;e=t}if(e instanceof Element&&!(e instanceof FlexGrid)){let t=wjcCore.closest(e,".wj-cell"),i=t?t[GridPanel._INDEX_KEY]:null;return void(i&&(this._row=i.row,this._col=i.col,this._rng=i.rng,this._p=i.panel,this._g=i.panel.grid))}if(e instanceof FlexGrid)i=this._g=e;else{if(!(e instanceof GridPanel))throw"First parameter should be a FlexGrid or GridPanel.";this._p=e,i=this._g=this._p.grid}t instanceof MouseEvent&&"mousedown"==t.type&&(i._rcBounds=null),t=wjcCore.mouseToPage(t),this._pt=t.clone();let s=i.controlRect,l=i._szClient,o=i.topLeftCells,r=i._eTL,n=i.headersVisibility,a=HeadersVisibility,h=n&a.Row?o.columns.getTotalSize():0,c=n&a.Column?o.rows.getTotalSize():0,d=n&a.Column?c+r.offsetTop:0,g=i._eBL,w=g.offsetHeight;if(t.x-=s.left,t.y-=s.top,this._g.rightToLeft&&(t.x=s.width-t.x),!this._p&&t.x>=0&&t.y>=r.offsetTop&&l&&t.x<=l.width+h&&t.y<=l.height+d&&(t.yr.y||r.y<=0)&&(t.y-=i._ptScrl.y,t.y+=this._p._getOffsetY())):l!=o.BottomLeft&&l!=o.ColumnFooter||(t.y-=g.offsetTop),l!=o.ColumnHeader&&l!=o.Cell&&l!=o.ColumnFooter||(t.x-=h,(t.x>r.x||r.x<=0)&&(t.x-=i._ptScrl.x)),l!=o.ColumnHeader&&l!=o.TopLeft||(t.y-=d-c),this._edge=0;let u=HitTestInfo._SZEDGE[this._g.isTouching?1:0];if(this._g.isTouching&&(u=HitTestInfo._SZEDGE[1],t.x-=u/2),this._row=t.y>n?-1:e.getItemAt(t.y),this._col=t.x>a?-1:s.getItemAt(t.x),this._row<0||this._col<0)return void(this._p=null);if(this._col>-1){let e=s[this._col];t.x-e.pos<=u&&(this._edge|=1),e.pos+e.renderSize-t.x<=u&&(this._edge|=4)}if(this._row>-1){let i=e[this._row];t.y-i.pos<=u&&(this._edge|=2),i.pos+i.renderSize-t.y<=u&&(this._edge|=8)}}}get point(){return this._pt}get cellType(){return this._p?this._p.cellType:CellType.None}get panel(){return this._p}get grid(){return this._p?this._p.grid:null}get row(){return this._row}get col(){return this._col}get range(){return this._rng||(this._rng=new CellRange(this._row,this._col)),this._rng}get edgeLeft(){return 0!=(1&this._edge)}get edgeTop(){return 0!=(2&this._edge)}get edgeRight(){return 0!=(4&this._edge)}get edgeBottom(){return 0!=(8&this._edge)}}HitTestInfo._SZEDGE=[5,30],exports.HitTestInfo=HitTestInfo;var AllowMerging;!function(e){e[e.None=0]="None",e[e.Cells=1]="Cells",e[e.ColumnHeaders=2]="ColumnHeaders",e[e.RowHeaders=4]="RowHeaders",e[e.AllHeaders=6]="AllHeaders",e[e.All=7]="All"}(AllowMerging=exports.AllowMerging||(exports.AllowMerging={}));class MergeManager{constructor(e){this._g=e}getMergedRange(e,t,i,s=!0){let l=this._g,o=e.cellType,r=e.columns,n=e.rows,a=n[t],h=r[i];if(a instanceof _NewRowTemplate)return null;if(l.showGroups&&!l.childItemsPath&&a instanceof GroupRow&&a.dataItem instanceof wjcCore.CollectionViewGroup&&o==CellType.Cell){let e=new CellRange(t,i);if(h.aggregate==wjcCore.Aggregate.None){for(;e.col>0&&r[e.col-1].aggregate==wjcCore.Aggregate.None&&e.col!=r.frozen;)e.col--;for(;e.col2=n.frozen?!s||o!=CellType.Cell&&o!=CellType.RowHeader||l._vtRows=h&&this._mergeCell(e,s,i,t,i);s--)r.row=s;for(let s=t+1;s<=c&&this._mergeCell(e,t,i,s,i);s++)r.row2=s;for(;r.row=r.frozen?!s||o!=CellType.Cell&&o!=CellType.ColumnHeader||l._vtCols=h&&this._mergeCell(e,t,s,t,i);s--)n.col=s;for(let s=i+1;s<=c&&this._mergeCell(e,t,i,t,s);s++)n.col2=s;for(;n.col0&&(o.allowMerging&&this._mergeCell(e,t,i-1,t,i)||r.allowMerging&&this._mergeCell(e,s,i-1,s,i)))return!1;if(l-1?this._cv.sourceCollection[i][this._keyPath]:null}getDisplayValue(e){if(!this._hash){this._hash={};let e=this._cv.sourceCollection;if(e&&this._keyPath&&this._displayPath)for(let t=e.length-1;t>=0;t--){let i=e[t],s=i[this._keyPath],l=i[this._displayPath];this._hash[s]=l}}let t=this._hash[e];return null!=t?t:e}getDisplayValues(e){let t=[];if(this._cv&&this._displayPath){let e=this._cv.items;for(let i=0;i{let s=e==SelectionMode.ListBox&&this._sel.containsRow(i);t._setFlag(RowColFlags.Selected,s,!0)}),e){case t.None:this._sel.setRange(-1,-1);break;case t.Cell:this._sel.row2=this._sel.row,this._sel.col2=this._sel.col;break;case t.Row:this._sel.row2=this._sel.row}this._mode=e,this._g.invalidate()}}get selection(){return this._sel}set selection(e){this.select(e)}select(e,t=!0){wjcCore.isNumber(e)&&wjcCore.isNumber(t)?(this._rng.setRange(e,t),t=!0):e instanceof CellRange?this._rng.copy(e):wjcCore.assert(!1,"CellRange expected");let i=this._g,s=this._sel,l=this._rng,o=!1,r=SelectionMode;switch(i.selectionMode){case r.Cell:l.row2=l.row,l.col2=l.col;break;case r.Row:l.row2=l.row;break;case r.ListBox:o=!0}let n=l.equals(s);if(o&&l.row>-1&&!i.rows[l.row].isSelected&&(n=!1),n)return void(t&&this._showSelection());let a=this._e;if(a._rng=l,a.cancel=!1,i.onSelectionChanging(a)){if(o&&(l.row!=s.row||l.rowSpan>1||s.rowSpan>1)&&i.rows.forEach((e,t)=>{e._setFlag(RowColFlags.Selected,l.containsRow(t),!0)}),l.row=Math.min(l.row,i.rows.length-1),l.row2=Math.min(l.row2,i.rows.length-1),this._sel.copy(l),i.refreshCells(!1,!0,!0),t&&this._showSelection(),i.collectionView){let e=i._getCvIndex(l.row);i.collectionView.moveCurrentToPosition(e)}i.onSelectionChanged(a)}}moveSelection(e,t,i){let s=this._g,l=this._sel,o=i&&s.anchorCursor?new CellRange(l.row2,l.col2):new CellRange(l.row,l.col);this._adjustReferenceCell(o,e,t);let r=o.row,n=o.col,a=s.rows,h=s.columns,c=Math.max(0,s._szClient.height-s.columnHeaders.height),d=SelMove;switch(t){case d.NextCell:(n=h.getNextCell(n,d.Next,c))==o.col&&(r=a.getNextCell(r,d.Next,c))>o.row&&(n=h.getNextCell(0,d.Next,c),n=h.getNextCell(n,d.Prev,c)),s.select(r,n);break;case d.PrevCell:(n=h.getNextCell(o.col,d.Prev,c))==o.col&&(r=a.getNextCell(r,d.Prev,c)){t.setClipString(e)}),void e.stopPropagation()}(o||l)&&"Space"==e.code&&(d=wjcCore.Key.Space);let g=SelMove,w=SelectionMode;switch(d){case wjcCore.Key.Space:if(o&&s.isValid)switch(t.selectionMode){case w.CellRange:case w.Row:case w.RowRange:case w.ListBox:t.select(new CellRange(s.row,0,s.row,t.columns.length-1))}else if(l&&s.isValid)switch(t.selectionMode){case w.CellRange:t.select(new CellRange(0,s.col,t.rows.length-1,s.col))}else(n=this._startEditing(!0,e))&&setTimeout(()=>{let e=t.activeEditor;e&&(e.disabled||e.readOnly?t.finishEditing():"checkbox"==e.type&&(e.checked=!e.checked,t.finishEditing()))});break;case 65:if(l)switch(t.selectionMode){case w.CellRange:case w.Row:case w.RowRange:case w.ListBox:t.select(new CellRange(0,0,t.rows.length-1,t.columns.length-1))}else n=!1;break;case wjcCore.Key.Left:l||e.altKey?n=!1:s.isValid&&0==s.leftCol&&null!=h&&!h.isCollapsed&&h.hasChildren?h.isCollapsed=!0:this._moveSel(g.None,l?g.Home:g.Prev,o);break;case wjcCore.Key.Right:l||e.altKey?n=!1:s.isValid&&0==s.leftCol&&null!=h&&h.isCollapsed?h.isCollapsed=!1:this._moveSel(g.None,l?g.End:g.Next,o);break;case wjcCore.Key.Up:l?n=!1:(this._altDown=e.altKey,e.altKey?n=i._toggleListBox(e):this._moveSel(g.Prev,g.None,o));break;case wjcCore.Key.Down:l?n=!1:(this._altDown=e.altKey,e.altKey?n=i._toggleListBox(e):this._moveSel(g.Next,g.None,o));break;case wjcCore.Key.PageUp:if(this._altDown=e.altKey,this._moveSel(e.altKey?g.Home:g.PrevPage,g.None,o),t.rows.frozen&&t.selection.rowwjcCore.Key.Space)if(this._startEditing(!1,e)&&t.activeEditor){let s=wjcCore.getActiveElement();if(s instanceof HTMLInputElement&&"checkbox"!=s.type||s instanceof HTMLTextAreaElement){let l=t._selHdl.selection,o=t.getCellData(l.row,l.col,!0),r=t.getCellData(l.row,l.col,!1),n=wjcCore.culture.Globalize.numberFormat["%"]||"%",a=String.fromCharCode(e.charCode),h=wjcCore.isNumber(r)&&o.indexOf(n)>-1||""==o&&s.value==n;s.value=a+(h?n:""),wjcCore.setSelectionRange(s,1),s.dispatchEvent(i._evtInput),i._keypress(e),i._edtValue=s.value!=o?s.value:null,e.preventDefault()}}else if(t.autoSearch){let i=!1,s=t._selHdl.selection;if(e.charCode>32||32==e.charCode&&this._search){e.preventDefault(),this._search+=String.fromCharCode(e.charCode).toLowerCase(),this._toSearch&&clearTimeout(this._toSearch),this._toSearch=setTimeout(()=>{this._toSearch=null,this._search=""},wjcCore.Control._SEARCH_DELAY);let l=this._findNext(s.row,s.col);l<0&&this._search.length>1&&(this._search=this._search[this._search.length-1],l=this._findNext(s.row,s.col)),l>-1&&(i=!0,t.select(l,s.col))}i||(this._search="")}}_findNext(e,t){let i=this._g,s=i.rows.length;(e<0||1==this._search.length)&&e++;for(let l=0;l-1&&e<=s.bottomRow;e++)o.push(l[e]);break;case a.ListBox:for(let e=0;e-1&&o.push(l[s.topRow]);break;case a.RowRange:for(let e=s.topRow;e>-1&&e<=s.bottomRow;e++)o.push(l[e])}if(o.length>0){if(t.deferUpdate(()=>{i&&i.beginUpdate();for(let e=o.length-1;e>=0;e--){let s=o[e];r.setRange(s.index,-1),t.onDeletingRow(n)&&(i&&s.dataItem?i.remove(s.dataItem):t.rows.removeAt(s.index),t.onDeletedRow(n))}i&&i.endUpdate()}),t.selectionMode==a.ListBox){let e=t.selection.row;e>-1&&e{for(let l=s.topRow;l<=s.bottomRow;l++){let o=t.rows[l];if(!o.isReadOnly)for(let a=s.leftCol;a<=s.rightCol;a++){let s=t._getBindingColumn(t.cells,l,t.columns[a]);if(!s.getIsRequired(o)&&!s.isReadOnly&&!o.isReadOnly&&t.getCellData(l,a,!0)&&(r.setRange(l,a),n.cancel=!1,t.onBeginningEdit(n))){if(i){let s=i.currentEditItem;!e&&s&&s!=o.dataItem&&(e=!0,i.beginUpdate()),s=o.dataItem,i.editItem(s),t._edtHdl._edItem=s}t.setCellData(l,a,"",!0,!1),t.onCellEditEnding(n),t.onCellEditEnded(n)}}}t.selection=s,t.scrollPosition=l,e&&i.endUpdate()}),!0}return!1}_startEditing(e,t,i,s){return this._g._edtHdl.startEditing(e,i,s,!0,t)}}exports._KeyboardHandler=_KeyboardHandler;const _AR_ALLCELLS=4,_WJC_DRAGSRC="wj-state-dragsrc";var AllowResizing;!function(e){e[e.None=0]="None",e[e.Columns=1]="Columns",e[e.Rows=2]="Rows",e[e.Both=3]="Both",e[e.ColumnsAllCells=4|e.Columns]="ColumnsAllCells",e[e.RowsAllCells=4|e.Rows]="RowsAllCells",e[e.BothAllCells=4|e.Both]="BothAllCells"}(AllowResizing=exports.AllowResizing||(exports.AllowResizing={}));var AutoSizeMode;!function(e){e[e.None=0]="None",e[e.Headers=1]="Headers",e[e.Cells=2]="Cells",e[e.Both=3]="Both"}(AutoSizeMode=exports.AutoSizeMode||(exports.AutoSizeMode={}));var AllowDragging;!function(e){e[e.None=0]="None",e[e.Columns=1]="Columns",e[e.Rows=2]="Rows",e[e.Both=3]="Both"}(AllowDragging=exports.AllowDragging||(exports.AllowDragging={}));class _MouseHandler{constructor(e){this._tsLast=0;let t=e.hostElement,i=e.addEventListener.bind(e),s=e.removeEventListener.bind(e);this._g=e,this._dvMarker=wjcCore.createElement('
'),i(t,"mousedown",t=>{if(e._rcBounds=null,!t.defaultPrevented&&0==t.button){let r=t.target;if(!e.containsFocus()){let t=r instanceof HTMLElement&&r.tabIndex>-1?r:e._eFocus;e._setFocusNoScroll(t)}setTimeout(()=>{t.defaultPrevented||e.focus()});let n=wjcCore.closest(r,".wj-flexgrid");if(n&&n!=e.hostElement||!e.activeEditor&&e._isInputElement(r)){let i=e.hitTest(t);switch(i.cellType){case CellType.Cell:e.select(i.range,!1),r instanceof HTMLElement&&"root"!=r.getAttribute("wj-part")&&r.focus();break;case CellType.ColumnHeader:case CellType.ColumnFooter:e.scrollIntoView(-1,i.col);break;case CellType.RowHeader:e.scrollIntoView(i.row,-1)}return}let a=document;s(a,"mousemove"),s(a,"mouseup"),i(a,"mousemove",l),i(a,"mouseup",o),this._isDown=!0,this._mousedown(t)}});let l=e=>{this._mousemove(e)},o=e=>{this._isDown=!1,s(document,"mousemove"),s(document,"mouseup"),this._mouseup(e)};i(t,"mouseup",e=>{this._tsLast=Date.now()}),i(t,"mouseenter",t=>{e._rcBounds=null}),i(t,"mousemove",this._hover.bind(this)),i(t,"dblclick",this._dblclick.bind(this)),i(t,"click",this._click.bind(this)),i(t,"selectstart",t=>{e._isInputElement(t.target)||t.preventDefault()}),i(t,"wheel",t=>{if(!t.defaultPrevented&&t.deltaY&&!t.ctrlKey&&!t.metaKey){let i=e._root,s=t.deltaY,l=0;if(i.scrollHeight>i.offsetHeight&&wjcCore.closest(t.target,".wj-flexgrid")==e.hostElement){switch(t.deltaMode){case 1:l=e.rows.defaultSize*(s<0?-1:1);break;case 2:l=i.clientHeight*(s<0?-1:1);break;case 0:default:wjcCore.isSafari()&&(s=wjcCore.clamp(s,-150,150)),l=s}e.hostElement.focus(),i.scrollTop+=l,t.preventDefault()}}}),i(t,"dragstart",this._dragstart.bind(this)),i(t,"dragover",this._dragover.bind(this)),i(t,"dragleave",this._dragover.bind(this)),i(t,"drop",this._drop.bind(this)),i(t,"dragend",this._dragend.bind(this)),this._enableTouchResizing()}resetMouseState(){this._updating&&(this._updating=!1,this._g.endUpdate()),this._dragSrc&&wjcCore.removeClass(this._dragSrc,_WJC_DRAGSRC),this._showDragMarker(null);let e=this._g.hostElement;e&&(e.style.cursor="");let t=this._g;t.removeEventListener(document,"mousemove"),t.removeEventListener(document,"mouseup"),this._tsLast=Date.now(),this._eMouse=null,this._isDown=null,this._htDown=null,this._lbSelRows=null,this._szRowCol=null,this._szArgs=null,t._rcBounds=null}_enableTouchResizing(){let e=this._g,t=e.hostElement,i="ontouchstart"in window?["touchstart","touchmove","touchend"]:"onpointerdown"in window?["pointerdown","pointermove","pointerup"]:null;i&&(e.addEventListener(t,i[0],i=>{if((null==i.pointerType||"touch"==i.pointerType)&&!wjcCore.closest(i.target,".wj-elem-filter")){var s=wjcCore.closest(i.target,".wj-cell");s instanceof HTMLElement&&(e._rcBounds=null,this._htDown=null,this._hover(i),this._szRowCol&&(s.removeAttribute("draggable"),t.style.touchAction="none",this._mousedown(i),i.preventDefault()))}}),e.addEventListener(t,i[1],e=>{null!=e.pointerType&&"touch"!=e.pointerType||this._szRowCol&&(this._mousemove(e),e.preventDefault())}),e.addEventListener(t,i[2],e=>{if((null==e.pointerType||"touch"==e.pointerType)&&this._szRowCol){if(this._szArgs)this._finishResizing(this._eMouse);else{let t=wjcCore.closest(e.target,".wj-cell");t instanceof HTMLElement&&t.click()}this.resetMouseState(),t.style.touchAction=""}}))}_mousedown(e){let t=this._g,i=t.hitTest(e),s=i.cellType,l=e.ctrlKey||e.metaKey,o=e.target,r=CellType;if(this._selDown=t.selection,i.panel==t.cells){if(wjcCore.closestClass(o,CellFactory._WJC_DROPDOWN))return t._edtHdl._toggleListBox(e,i.range),void e.preventDefault();if(t.editRange&&t.editRange.contains(i.range))return}let n=wjcCore.getActiveElement();if(o!=n||!t._isInputElement(o)){if(s==r.None)return t.finishEditing(),void(o!=t._root&&o!=t._fCt&&t._edtHdl._commitRowEdits());if(this._htDown=i,this._eMouse=e,null!=this._szRowCol)return n!=t._eFocus&&(t._eFocus.tabIndex=0,t._eFocus.focus()),void this._handleResizing(e);if(!(s==r.RowHeader&&i.edgeBottom&&t.allowResizing&AllowResizing.Rows&&this._getResizeRow(i))){switch(s){case r.Cell:case r.RowHeader:l&&t.selectionMode==SelectionMode.ListBox&&this._startListBoxSelection(i.row),this._mouseSelect(e,e.shiftKey),s==r.RowHeader&&0==(t.allowDragging&AllowDragging.Rows)&&(e.preventDefault(),t.focus())}if(s==r.Cell&&t.rows.maxGroupLevel>-1&&wjcCore.closestClass(o,CellFactory._WJC_COLLAPSE)){let e=wjcCore.tryCast(t.rows[i.row],GroupRow);if(e)return l?t.collapseGroupsToLevel(e.isCollapsed?e.level+1:e.level):e.isCollapsed=!e.isCollapsed,void this.resetMouseState()}}}}_mousemove(e){if(null!=this._htDown){if(0==e.buttons&&this._eMouse&&e.timeStamp-this._eMouse.timeStamp>600)return void this.resetMouseState();if(this._eMouse=e,this._szRowCol)this._handleResizing(e);else switch(this._htDown.cellType){case CellType.Cell:this._mouseSelect(e,!0);break;case CellType.RowHeader:0==(this._g.allowDragging&AllowDragging.Rows)&&this._mouseSelect(e,!0)}}}_mouseup(e){if(this._g.isTouching&&(this._dragSrc||e.target instanceof HTMLHtmlElement))return;let t=this._g,i=t.hitTest(e),s=this._htDown,l=SelectionMode;if(s&&!e.defaultPrevented)if(this._szArgs)this._finishResizing(e);else if(s.panel!=t.topLeftCells||this._szArgs)s.panel!=t.columnHeaders||e.dataTransfer?s.panel==t.cells&&(this._szRowCol||e.ctrlKey||e.metaKey||e.shiftKey||i.panel==s.panel&&i.range.equals(s.range)&&t.selection.equals(this._selDown)&&t._edtHdl.startEditing(!0,i.row,i.col,!0,e)):i.panel==s.panel&&i.col==s.col&&!i.edgeRight&&i.col>-1&&this._clickSort(e,i);else if(i.panel==s.panel&&i.row==s.row&&i.col==s.col&&t.rows.length&&t.columns.length)switch(t.selectionMode){case l.CellRange:case l.RowRange:case l.ListBox:t.select(new CellRange(0,0,t.rows.length-1,t.columns.length-1))}this.resetMouseState()}_click(e){Date.now()-this._tsLast>50&&!e.pointerType&&this._handleClick(e)}_handleClick(e){let t=this._g,i=e.target,s=new HitTestInfo(i,null),l=s.panel;if(!e.defaultPrevented&&s.grid==t&&!t._isInputElement(i))if(l==t.topLeftCells)t.select(new CellRange(0,0,t.rows.length-1,t.columns.length-1));else if(l==t.columnHeaders)this._clickSort(e,s);else if(l==t.rowHeaders)t.select(new CellRange(s.row,0,s.row,t.columns.length-1));else if(l==t.cells)if(s.row<0)this._clickSort(e,s);else if(wjcCore.closestClass(i,CellFactory._WJC_COLLAPSE)){let i=t.rows[s.row];i instanceof GroupRow&&(e.ctrlKey?t.collapseGroupsToLevel(i.isCollapsed?i.level+1:i.level):i.isCollapsed=!i.isCollapsed)}else wjcCore.closestClass(i,CellFactory._WJC_DROPDOWN)?t._edtHdl._toggleListBox(e,s.range):t.select(s.range)}_clickSort(e,t){let i=this._g,s=i.collectionView,l=e.ctrlKey||e.metaKey;if(!s||!s.canSort||!i.allowSorting)return;t.row;let o=t.panel.columns[t.col],r=i._getBindingColumn(t.panel,t.row,o),n=r?r._getBindingSort():null;if(!r.allowSorting||!n)return;if(o==r){let e=i.getMergedRange(t.panel,t.row,t.col,!1);if(e&&e.columnSpan>1)return}let a=t.grid.collectionView.sortDescriptions,h=null;for(let e=0;e=0&&e.target!=i._root&&(s=new HitTestInfo(i,e)).cellType!=CellType.Cell&&s.cellType!=CellType.RowHeader&&setTimeout(()=>{this._isDown&&this._eMouse&&this._mouseSelect(this._eMouse,t)},100)}}_handleResizing(e){if(e.preventDefault(),this._szRowCol instanceof Column){let t=this._g,i=wjcCore.mouseToPage(e).x,s=Math.round(Math.max(_MouseHandler._SZ_MIN,this._szStart+(i-this._htDown.point.x)*(t.rightToLeft?-1:1)));if(this._szRowCol.renderSize!=s){if(null==this._szArgs){let e=t.rowHeaders.columns.indexOf(this._szRowCol)>-1?t.rowHeaders:t.cells;this._szArgs=new CellRangeEventArgs(e,new CellRange(-1,this._szRowCol.index))}this._szArgs.cancel=!1,t.onResizingColumn(this._szArgs)&&(t.deferResizing?this._showResizeMarker(s):this._szRowCol.width=s)}}if(this._szRowCol instanceof Row){let t=this._g,i=wjcCore.mouseToPage(e).y,s=Math.round(Math.max(_MouseHandler._SZ_MIN,this._szStart+(i-this._htDown.point.y)));if(this._szRowCol.renderSize!=s){if(null==this._szArgs){let e=t.columnHeaders.rows.indexOf(this._szRowCol)>-1?t.columnHeaders:t.cells;this._szArgs=new CellRangeEventArgs(e,new CellRange(this._szRowCol.index,-1))}this._szArgs.cancel=!1,t.onResizingRow(this._szArgs)&&(t.deferResizing?this._showResizeMarker(s):this._szRowCol.height=s)}}}_dragstart(e){let t=this._g,i=this._htDown,s=AllowDragging;if(i){if(this._dragSrc=null,this._htDrag=null,!this._szRowCol){let l=new CellRangeEventArgs(i.panel,i.range);if(i.cellType==CellType.ColumnHeader&&t.allowDragging&s.Columns&&i.col>-1&&t.columns[i.col].allowDragging)t.onDraggingColumn(l)?this._dragSrc=e.target:e.preventDefault();else if(i.cellType==CellType.RowHeader&&t.allowDragging&s.Rows&&i.row>-1&&t.rows[i.row].allowDragging){let s=t.rows[i.row];s instanceof GroupRow||s instanceof _NewRowTemplate||(t.onDraggingRow(l)?this._dragSrc=e.target:e.preventDefault())}else i.cellType==CellType.TopLeft&&t.allowDragging&s.Columns&&i.col>-1&&t.topLeftCells.columns[i.col].allowDragging&&(t.onDraggingColumn(l)?this._dragSrc=e.target:e.preventDefault())}this._dragSrc&&e.dataTransfer&&!e.defaultPrevented&&(this._htDrag=i,wjcCore._startDrag(e.dataTransfer,"move"),e.stopPropagation(),wjcCore.addClass(this._dragSrc,_WJC_DRAGSRC),t.beginUpdate(),this._updating=!0)}}_dragend(e){this._dragSrc=null,this._htDrag=null,this.resetMouseState()}_dragover(e){let t=this._g,i=this._hitTest(e),s=this._dragSrc?this._htDrag:null,l=CellType,o=!1;if(s&&i.cellType==s.cellType){let e=new CellRangeEventArgs(i.panel,i.range,s);i.cellType==l.ColumnHeader?(e.cancel=!t.columns.canMoveElement(s.col,i.col),o=t.onDraggingColumnOver(e)):i.cellType==l.RowHeader?(e.cancel=!t.rows.canMoveElement(s.row,i.row),o=t.onDraggingRowOver(e)):i.cellType==l.TopLeft&&(e.cancel=!t.topLeftCells.columns.canMoveElement(s.col,i.col),o=t.onDraggingColumnOver(e))}if(o?(e.dataTransfer.dropEffect="move",this._showDragMarker(i),e.preventDefault(),e.stopPropagation()):this._showDragMarker(null),s&&t.autoScroll){let i=t.controlRect,l=t.scrollPosition,o=wjcCore.Control._DRAG_SCROLL_EDGE,r=wjcCore.Control._DRAG_SCROLL_STEP;s.panel==t.columnHeaders?(e.pageX-i.leftthis._htDown.col&&(o.left+=s.renderWidth),e.cellType==l.ColumnHeader&&e.colthis._htDown.row&&(o.top+=r.renderHeight),e.row-1){let r=s.col,n=wjcCore.mouseToPage(e).x,a=Math.round(Math.max(_MouseHandler._SZ_MIN,this._szStart+(n-this._htDown.point.x)*(this._g.rightToLeft?-1:1)));if(s.panel.columns[r].width=Math.round(a),t.onResizedColumn(s),l&&this._htDown.cellType==o.ColumnHeader&&i.containsColumn(r))for(let e=i.leftCol;e<=i.rightCol;e++)t.columns[e].allowResizing&&e!=r&&(s=new CellRangeEventArgs(t.cells,new CellRange(-1,e)),t.onResizingColumn(s)&&(t.columns[e].size=t.columns[r].size,t.onResizedColumn(s)))}if(s.row>-1){let r=s.row,n=wjcCore.mouseToPage(e).y,a=Math.round(Math.max(_MouseHandler._SZ_MIN,this._szStart+(n-this._htDown.point.y)));if(s.panel.rows[r].height=Math.round(a),t.onResizedRow(s),l&&this._htDown.cellType==o.RowHeader&&i.containsRow(r))for(let e=i.topRow;e<=i.bottomRow;e++)t.rows[e].allowResizing&&e!=r&&(s=new CellRangeEventArgs(t.cells,new CellRange(e,-1)),t.onResizingRow(s)&&(t.rows[e].size=t.rows[r].size,t.onResizedRow(s)))}}}_startListBoxSelection(e){let t=this._g.rows,i=this._lbSelRows={};this._lbSelState=!t[e].isSelected,t.forEach((e,t)=>{e.isSelected&&(i[t]=!0)})}_handleSelection(e,t){let i=this._g,s=i.rows,l=i._selHdl.selection,o=new CellRange(e.row,e.col);if(e.row>-1&&e.col>-1)if(null!=this._lbSelRows){let t=!1;o=new CellRange(e.row,e.col,this._htDown.row,this._htDown.col),s.forEach((e,s)=>{let r=o.containsRow(s)?this._lbSelState:null!=this._lbSelRows[s];if(r!=e.isSelected){let o=new CellRangeEventArgs(i.cells,new CellRange(s,l.col,s,l.col2));i.onSelectionChanging(o)&&(e._setFlag(RowColFlags.Selected,r,!0),i.onSelectionChanged(o),t=!0)}}),t&&i.refreshCells(!1,!0,!0),i.scrollIntoView(e.row,e.col)}else t&&(i.anchorCursor?(o.row=l.row,o.col=l.col):(o.row2=l.row2,o.col2=l.col2)),e.cellType==CellType.RowHeader?(o.col=0,o.col2=i.columns.length-1,i.select(o,!1),i.scrollIntoView(e.row,-1)):i.select(o)}}_MouseHandler._SZ_MIN=0,exports._MouseHandler=_MouseHandler;const _WJC_CHECKBOX="wj-cell-check",_PAGE_SIZE=4;class _EditHandler{constructor(e){this._fullEdit=!1,this._list=null,this._g=e,this._evtInput=document.createEvent("HTMLEvents"),this._evtInput.initEvent("input",!0,!1),this._evtChange=document.createEvent("HTMLEvents"),this._evtChange.initEvent("change",!0,!1),e.selectionChanging.addHandler((t,i)=>{if(this.finishEditing()){let t=e._selHdl.selection.row;if(t!=i.row){let s=e.rows.length;(t>-1&&t-1&&i.row{let e=wjcCore.getActiveElement();e&&"fixed"==getComputedStyle(e).position?this.finishEditing():this._commitRowEdits()});let t=e.hostElement;e.addEventListener(t,"mousedown",t=>{if(t.defaultPrevented||0!=t.button)return;if(e._mouseHdl._szRowCol)return;e.selection;let i=e.hitTest(t);if(i.cellType!=CellType.Cell&&i.cellType!=CellType.None)this.finishEditing();else if(i.cellType!=CellType.None){let s=wjcCore.tryCast(t.target,HTMLInputElement);this._isNativeCheckbox(s)&&(s!=this.activeEditor&&(t.preventDefault(),this.startEditing(!1,i.row,i.col,!0,t)&&(s=this.activeEditor)),!s||"checkbox"!=s.type||s.disabled||s.readOnly||(s.checked=!s.checked,e._setFocusNoScroll(s),this.finishEditing()))}},!0),e.addEventListener(t,"click",e=>{this._isNativeCheckbox(e.target)&&(e.preventDefault(),e.stopImmediatePropagation())},!0),e.addEventListener(t,"compositionend",this._keypress.bind(this))}startEditing(e=!0,t,i,s,l){let o=this._g;if(t=wjcCore.asNumber(t,!0,!0),i=wjcCore.asNumber(i,!0,!0),null==t&&(t=o.selection.row),null==i&&(i=o.selection.col),null==s&&(s=!0),!this._allowEditing(t,i))return!1;let r=o.getMergedRange(o.cells,t,i,!1);r||(r=new CellRange(t,i));let n=o.rows[t].dataItem;if(o.scrollIntoView(r.row,r.col,!0),o.select(r,!0),!o.rows[t]||n!=o.rows[t].dataItem)return!1;if(r.equals(this._rng))return!0;if(this.activeEditor&&!this.finishEditing())return!1;let a=new CellRangeEventArgs(o.cells,r,l);if(!o.onBeginningEdit(a))return!1;let h=o.editableCollectionView,c=!1;h&&((c=(n=o.rows[t].dataItem)!=h.currentEditItem)&&o.onRowEditStarting(a),h.editItem(n),c&&(o.onRowEditStarted(a),this._edItem=n)),this._fullEdit=wjcCore.asBoolean(e),this._rng=r,this._list=null;let d=o.rows[t],g=o._getBindingColumn(o.cells,t,o.columns[i]),w=g.dataMap||d.dataMap;w&&(this._list=w.getDisplayValues(n)),r.isSingleCell?this._updateEditorCell(t,i,c):o.refresh(!1);let u=this._edt;if(u){if("checkbox"==u.type)this._fullEdit=!1;else if(s){let e=0,s=u.value.length,r=!1,n=wjcCore.culture.Globalize.numberFormat["%"]||"%",a=o.getCellData(t,i,!1);if(wjcCore.isNumber(a)?r=u.value.indexOf(n)>-1:null==a&&(r=/^p/i.test(g.format))&&u.value.indexOf(n)<0&&(u.value+=n),r){let t=u.value;for(e=0,s=t.length;s>0&&(t[s-1]==n||" "==t[s-1]);)s--;for(;e{t.select()}):t.select(),!1;if(!l.cancel){l.data=i.cells.getCellData(s.topRow,s.leftCol,!1);let e=i.cellFactory.getEditorValue(i);for(let t=s.topRow;t<=s.bottomRow&&t{if(l.isVisible){let l=this._getRowClipString(i,r,e.leftCol,e.rightCol,t,s);o.push(l)}})}let n=l.cells;if(l.selectionMode==r.ListBox)n.rows.forEach((i,l)=>{if(i.isSelected&&i.isVisible){let i=this._getRowClipString(n,l,e.leftCol,e.rightCol,t,s);o.push(i)}});else for(let i=e.topRow;i<=e.bottomRow;i++)if(n.rows[i].isVisible){let l=this._getRowClipString(n,i,e.leftCol,e.rightCol,t,s);o.push(l)}return o.join(t?"\r\n":"\n")}_getRowClipString(e,t,i,s,l,o){let r="",n=l?",":"\t",a=e.rows[t];if(a.isVisible){if(o){let i=e.cellType==CellType.ColumnHeader?e.grid.topLeftCells:e.grid.rowHeaders;for(let e=0;e-1;return!i&&t&&(i=e.indexOf('"')>-1||e.indexOf(",")>-1),i&&(!t&&e.match(/^".?"$/)||(e='"'+e+'"')),e}setClipString(e,t){let i=this._g,s=null==t,l=SelectionMode;if(!t)switch(t=i.selection,i.selectionMode){case l.Row:case l.RowRange:case l.ListBox:t.col=0,t.col2=i.columns.length-1}t=wjcCore.asType(t,CellRange);let o=this._parseClipString(wjcCore.asString(e));s&&!t.isSingleCell&&o.length&&this._expandClipRows(o,t);let r=new CellRange(t.topRow,t.leftCol,t.topRow+o.length-1,t.leftCol+o[0].length-1),n=new CellRangeEventArgs(i.cells,r);if(!i.onPasting(n))return!1;r=new CellRange(t.topRow,t.leftCol);let a=i.editableCollectionView,h=!1,c=t.topRow;i.deferUpdate(()=>{a&&o.length>1&&a.beginUpdate();for(let e=0;e1&&a.endUpdate(),i.select(r),i.onPasted(n),h&&wjcCore.closest(i.hostElement,"form")){let e=wjcCore.createElement("",i.hostElement),t=document.createEvent("HTMLEvents");t.initEvent("change",!0,!1),e.dispatchEvent(t),wjcCore.removeChild(e)}})}_isNativeCheckbox(e){return e instanceof HTMLInputElement&&"checkbox"==e.type&&!e.disabled&&!e.readOnly&&wjcCore.hasClass(e,_WJC_CHECKBOX)&&wjcCore.closest(e,".wj-flexgrid")==this._g.hostElement}_parseClipString(e){let t=[];e=(e=e.replace(/\r\n/g,"\n").replace(/\r/g,"\n")).replace(/\n$/,"");let i=0,s=0;for(i=0;i=" ",o=!1,r=!1;for(s=i;s1&&'"'==o[0]&&'"'==o[r-1]?o=(o=o.substr(1,r-2)).replace(/""/g,'"'):"\t"==o&&(o=""),e[e.length-1].push(o),l&&e.push([])}_expandClipRows(e,t){let i=e.length,s=0;for(let t=0;t1||r>1)&&(1==o&&(o=i),1==r&&(r=s),r%s==0&&o%i==0)){for(let t=s;t=i.rows.length||t<0||t>=i.columns.length)return!1;let s=i.rows[e];if(!s||s.isReadOnly||!s.isVisible)return!1;let l=i._getBindingColumn(i.cells,e,i.columns[t]);return!(!l||l.isReadOnly||!l.isVisible)}_commitRowEdits(){let e=this._g;if(this.finishEditing()&&this._edItem){let t=e.editableCollectionView;if(t&&(t.currentEditItem||t.currentAddItem)){let i=new CellRangeEventArgs(e.cells,e.selection);e.onRowEditEnding(i),t.commitEdit(),e.onRowEditEnded(i)}this._edItem=null}}_keydown(e){let t=this._edt;switch(e.keyCode){case wjcCore.Key.F2:return this._fullEdit=!this._fullEdit,e.preventDefault(),!0;case wjcCore.Key.F4:return this._toggleListBox(e),e.preventDefault(),!0;case wjcCore.Key.Space:return!t||"checkbox"!=t.type||t.disabled||t.readOnly||(t.checked=!t.checked,this.finishEditing(),e.preventDefault()),!0;case wjcCore.Key.Enter:if(e.preventDefault(),t&&e.altKey){let t=e.target;if(t instanceof HTMLTextAreaElement&&"soft"==t.wrap){let e=t.value,i=t.selectionStart,s=t.selectionEnd;t.value=e.substr(0,i)+"\n"+e.substr(s),wjcCore.setSelectionRange(t,i+1)}return!0}return!this.finishEditing();case wjcCore.Key.Tab:return e.preventDefault(),!this.finishEditing();case wjcCore.Key.Escape:return e.preventDefault(),this.finishEditing(!0),!0;case wjcCore.Key.Up:case wjcCore.Key.Down:case wjcCore.Key.Left:case wjcCore.Key.Right:case wjcCore.Key.PageUp:case wjcCore.Key.PageDown:case wjcCore.Key.Home:case wjcCore.Key.End:if(this._lbx)return this._keydownListBox(e);if(e.altKey)switch(e.keyCode){case wjcCore.Key.Up:case wjcCore.Key.Down:return this._toggleListBox(e),e.preventDefault(),!0}if(!this._fullEdit&&this.finishEditing())return!1}return!0}_keydownListBox(e){let t=!0;if(this._lbx)switch(e.keyCode){case wjcCore.Key.Up:e.altKey?this._toggleListBox(e):this._lbx.selectedIndex>0&&this._lbx.selectedIndex--;break;case wjcCore.Key.Down:e.altKey?this._toggleListBox(e):this._lbx.selectedIndex++;break;case wjcCore.Key.Home:case wjcCore.Key.PageUp:this._lbx.selectedIndex=0;break;case wjcCore.Key.End:case wjcCore.Key.PageDown:this._lbx.selectedIndex=this._lbx.collectionView.items.length-1;break;default:t=!1}return!!t&&(e.preventDefault(),!0)}_keypress(e){let t=this._edt,i=e.charCode||32;if(t&&"checkbox"!=t.type&&wjcCore.getActiveElement()==t&&this._list&&this._list.length>0&&i>=32){let i=t.selectionStart,s=t.value.substr(0,i);e.target==t&&e.charCode&&(s+=String.fromCharCode(e.charCode),i++);let l=this._findString(this._list,s,!0);l<0&&(l=this._findString(this._list,s,!1)),l>-1&&(t.value=this._list[l],wjcCore.setSelectionRange(t,i,t.value.length),t.dispatchEvent(this._evtInput),e.preventDefault&&e.preventDefault())}}_findString(e,t,i){i||(t=t.toLowerCase());for(let s=0;s{this._removeListBox(),e.focus(),this.finishEditing()}),a.lostFocus.addHandler(()=>{this._removeListBox()}),a.selectedIndexChanged.addHandler(()=>{let t=e.activeEditor;t&&(t.value=a.selectedValue,t.dispatchEvent(this._evtInput),wjcCore.setSelectionRange(t,0,t.value.length))});let h=e.cells.getCellElement(i.row,i.col);if(h){wjcCore.showPopup(n,h,!1,!1,!1);let e=h.querySelector("."+CellFactory._WJC_DROPDOWN);wjcCore.setAttribute(e,"aria-expanded",!0)}else wjcCore.showPopup(n,e.getCellBoundingRect(i.row,i.col)),n[wjcCore.Control._OWNR_KEY]=e.hostElement;return a}_removeListBox(){let e=this._lbx;e&&(this._lbx=null,wjcCore.hidePopup(e.hostElement,()=>{e.dispose()}))}}exports._EditHandler=_EditHandler;class _AddNewHandler{constructor(e){this._nrt=new _NewRowTemplate,this._g=e,this._keydownBnd=this._keydown.bind(this),this._attach()}get newRowAtTop(){return this._top}set newRowAtTop(e){e!=this.newRowAtTop&&(this._top=wjcCore.asBoolean(e),this.updateNewRowTemplate())}updateNewRowTemplate(){let e=this._g,t=e.editableCollectionView,i=e.rows,s=this._nrt,l=t&&t.canAddNew&&e.allowAddNew&&!e.isReadOnly,o=i.indexOf(s),r=this._top?0:i.length-1,n=!1;if(!l&&o>-1){let t=e.selection;t.row==o&&e.select(t.row-1,t.col),i.removeAt(o)}else l&&(o<0?n=!0:o!=r&&(i.removeAt(o),n=!0),n&&(this._top?i.insert(0,s):i.push(s)),s&&(s._setFlag(RowColFlags.ParentCollapsed,!1),this._top&&e.selectionMode==SelectionMode.ListBox||s._setFlag(RowColFlags.Selected,!1)))}_attach(){let e=this._g;e&&(e.beginningEdit.addHandler(this._beginningEdit,this),e.pastingCell.addHandler(this._beginningEdit,this),e.rowEditEnded.addHandler(this._rowEditEnded,this),e.loadedRows.addHandler(this.updateNewRowTemplate,this),e.hostElement.addEventListener("keydown",this._keydownBnd,!0))}_detach(){let e=this._g;e&&(e.beginningEdit.removeHandler(this._beginningEdit),e.pastingCell.removeHandler(this._beginningEdit),e.rowEditEnded.removeHandler(this._rowEditEnded),e.loadedRows.removeHandler(this.updateNewRowTemplate),e.hostElement.removeEventListener("keydown",this._keydownBnd,!0))}_keydown(e){e.defaultPrevented||e.keyCode!=wjcCore.Key.Escape||null==this._g.activeEditor&&this._top&&this._nrt.dataItem&&(this._nrt.dataItem=null,this._g.invalidate())}_beginningEdit(e,t){if(!t.cancel){let i=e.rows[t.row];if(wjcCore.tryCast(i,_NewRowTemplate)){let s=e.editableCollectionView;if(s&&s.canAddNew)if(this._top){if(null==this._nrt.dataItem){let e=null,t=s.sourceCollection,i=s.newItemCreator;e=wjcCore.isFunction(i)?i():t&&t.length?new t[0].constructor:{},this._nrt.dataItem=e}}else{let l=s.currentAddItem&&s.currentAddItem==i.dataItem?s.currentAddItem:s.addNew();s.moveCurrentTo(l);let o=this._nrt.isSelected;this.updateNewRowTemplate(),o&&t.row>-1&&(e.rows[t.row].isSelected=!0),e.refresh(!0),e.onRowAdded(t),t.cancel&&s.cancelNew()}}}}_rowEditEnded(e,t){let i=e.editableCollectionView,s=this._nrt.dataItem;if(i&&!this._committing)if(i.isAddingNew)i.commitNew();else if(s&&!t.cancel){this._committing=!0,this._nrt.dataItem=null;let l=i.addNew();for(let e in s)l[e]=s[e];e.onRowAdded(t),t.cancel?i.cancelNew():i.commitNew(),setTimeout(()=>{e.select(0,e.columns.firstVisibleIndex),this.updateNewRowTemplate()},20),this._committing=!1}}}exports._AddNewHandler=_AddNewHandler;class _NewRowTemplate extends Row{}exports._NewRowTemplate=_NewRowTemplate;class _ImeHandler{constructor(e){this._updateImeFocusBnd=this._updateImeFocus.bind(this),this._cmpstartBnd=this._compositionstart.bind(this),this._mousedownBnd=this._mousedown.bind(this),this._mouseupBnd=this._mouseup.bind(this),this._keydownBnd=this._keydown.bind(this),this._ignoreKey=!1,this._g=e;let t=wjcCore.createElement('');wjcCore.disableAutoComplete(t),wjcCore.setCss(t,_ImeHandler._cssHidden),this._tbx=t,e._root.appendChild(t),this._updateImeFocus();let i=e.hostElement,s=e.addEventListener.bind(e);s(t,"compositionstart",this._cmpstartBnd),s(i,"blur",this._updateImeFocusBnd,!0),s(i,"focus",this._updateImeFocusBnd),s(i,"mousedown",this._mousedownBnd,!0),s(i,"mouseup",this._mouseupBnd,!0),s(i,"keydown",this._keydownBnd,!0),e.cellEditEnded.addHandler(this._cellEditEnded,this),e.selectionChanged.addHandler(this._updateImeFocus,this)}dispose(){let e=this._g,t=e.hostElement,i=this._tbx,s=e.removeEventListener.bind(e);s(i,"compositionstart",this._cmpstartBnd),s(t,"blur",this._updateImeFocusBnd),s(t,"focus",this._updateImeFocusBnd),s(t,"mousedown",this._mousedownBnd),s(t,"mouseup",this._mouseupBnd),s(t,"keydown",this._keydownBnd),e.cellEditEnded.removeHandler(this._cellEditEnded),e.selectionChanged.removeHandler(this._updateImeFocus),wjcCore.removeChild(i)}_keydown(e){let t=this._g;this._ignoreKey=!1,t.activeEditor||"Space"!=e.code||(this._tbx.value="",e.shiftKey||e.ctrlKey?this._ignoreKey=!0:this._compositionstart())}_compositionstart(){let e=this._g;if(!e.activeEditor&&!this._ignoreKey){let t=e._selHdl.selection;if(e.startEditing(!1,t.row,t.col,!1)&&e.activeEditor){t=e.editRange;let i=e.activeEditor,s=this._tbx,l=e.cells.hostElement,o=e.columns[t.col].pos+l.offsetLeft,r=e.rows[t.row].pos+l.offsetTop,n=e.getCellBoundingRect(t.row,t.col),a=wjcCore.closest(i,".wj-cell");n.width=a.offsetWidth,n.height=a.offsetHeight,t.row{wjcCore.setAttribute(s,e,i.getAttribute(e))});let c=i instanceof HTMLTextAreaElement;wjcCore.setAttribute(s,"wrap",c?"soft":"off");let d=getComputedStyle(a),g=d.paddingTop;if(t.rowSpan>1&&!c){let e=parseFloat(d.lineHeight);isNaN(e)&&(e=1.2*parseFloat(d.fontSize)),g=Math.max(0,(n.height-e)/2)+"px"}wjcCore.setCss(s,{position:"absolute",left:o,top:r,width:n.width-1,height:n.height-1,paddingTop:g,paddingLeft:d.paddingLeft,paddingRight:d.paddingRight,textAlign:d.textAlign,zIndex:a.style.zIndex}),e._edtHdl._edt=s;let w=i.value;setTimeout(()=>{" "!=s.value&&" "!=s.value||(s.value=w,wjcCore.setSelectionRange(s,w.length))},20),i.value=""}}}_cellEditEnded(){wjcCore.setCss(this._tbx,_ImeHandler._cssHidden),setTimeout(()=>{this._tbx.value=""})}_mousedown(e){this._isMouseDown=!0,this._updateImeFocus()}_mouseup(e){this._isMouseDown=!1,this._updateImeFocus()}_updateImeFocus(){let e=this._g,t=this._tbx,i=wjcCore.getActiveElement();e.activeEditor||wjcCore.closest(i,".wj-flexgrid")!=e.hostElement||(this._enableIme()?i!=t&&(t.disabled=!1,t.select(),t.focus()):(t.disabled=!0,t.value=""))}_enableIme(){let e=this._g,t=e._selHdl.selection;if(!e.canEditCell(t.row,t.col))return!1;let i=t.isValid?e._getBindingColumn(e.cells,t.row,e.columns[t.col]):null;return!(!i||i.dataType==wjcCore.DataType.Boolean)}}_ImeHandler._cssHidden={position:"fixed",left:-10,top:-10,width:"1px",overflow:"hidden"},exports._ImeHandler=_ImeHandler;