@mescius/wijmo.grid
Version:
UI library for pure JS, Angular, React, Vue and more...
14 lines (13 loc) • 342 kB
JavaScript
/*!
*
* Wijmo Library 5.20252.44
* https://developer.mescius.com/wijmo
*
* Copyright(c) MESCIUS inc. All rights reserved.
*
* Licensed under the End-User License Agreement For MESCIUS Wijmo Software.
* us.sales@mescius.com
* https://developer.mescius.com/wijmo/licensing
*
*/
var _a,__extends=this&&this.__extends||function(){var extendStatics=function(e,t){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var i in t)t.hasOwnProperty(i)&&(e[i]=t[i])})(e,t)};return function(e,t){extendStatics(e,t);function __(){this.constructor=e}e.prototype=null===t?Object.create(t):(__.prototype=t.prototype,new __)}}(),__assign=this&&this.__assign||function(){return(__assign=Object.assign||function(e){for(var t,i=1,o=arguments.length;i<o;i++){t=arguments[i];for(var n in t)Object.prototype.hasOwnProperty.call(t,n)&&(e[n]=t[n])}return e}).apply(this,arguments)};import{isInt,asInt,_addCultureInfo,tryCast,format,Size,CancelEventArgs,asType,asBoolean,isFunction,Key,_getModule,asArray,assert,copy,isArray,isNumber,isString,toHeaderCase,NotifyCollectionChangedEventArgs,ObservableArray,Point,mouseToPage,closest,culture,SortDescription,Control,isSafari,isIE,isIE9,closestClass,addClass,removeClass,setCss,getActiveElement,removeChild,createElement,setAttribute,_startDrag,clamp,isEdge,hasClass,ControlStateClsNames,isMobile,Event,EventArgs,_MaskProvider,asString,asCollectionView,toPlainText,_Map,asFunction,Globalize,escapeHtml,isBoolean,toggleClass,contains,setChecked,setAriaLabel,disableAutoComplete,evalTemplate,DataType,isChromiumBased,InputFormElementsClsNames,GlyphClsNames,UtilitesClsNames,isiOS,setSelectionRange,isNullOrUndefined,isUndefined,asNumber,asEnum,getType,_deprecated,Aggregate,Binding,CollectionViewGroup,uidGenerator,changeType,isFirefox,DateTime,Rect,CollectionView,NotifyCollectionChangedAction,getAggregate,isDate,showPopup,hidePopup,ControlClsNames,Clipboard,_isMacOS,ForeignClsNames,Tooltip,isPrimitive,enable,setText,getTypes,hasItems,getElementRect,supportsFocusOptions,isIE10,isSupportTouch,getScrollableParent,getOffsetFromAncestor,_NullValue,_getFocusableElements,_registerModule}from"@mescius/wijmo";import{MultiSelect}from"@mescius/wijmo.input";import*as mInput from"@mescius/wijmo.input";import*as selfModule from"@mescius/wijmo.grid";var _safariVer=null;export function _getSafariVer(){return _safariVer}if(isSafari()){var match=navigator.userAgent.match(/version\/([\d\.]+)/i);if(null!=match){var version=match[1],parts=(match=version.match(/(\d+)/g)).map((function(e){return parseInt(e)}));_safariVer={full:version,major:parts[0],minor:parts[1]}}}export var FlexGridClsNames={alt:"wj-alt",bigHeader:"wj-big-header",bottomLeft:"wj-bottomleft",cell:"wj-cell",cellCheck:"wj-cell-check",cellIndex:"wj-cell-index",cells:"wj-cells",colFooters:"wj-colfooters",colGroup:"wj-colgroup",colHeaders:"wj-colheaders",elemCollapse:"wj-elem-collapse",elemCollapseSpace:"wj-elem-collapse-space",elemDropDown:"wj-elem-dropdown",elemPin:"wj-elem-pin",errorTip:"wj-error-tip",focusHeaderCell:"wj-focus-header-cell",frozen:"wj-frozen",frozenClone:"wj-frozen-clone",frozenCol:"wj-frozen-col",frozenColLeft:"wj-frozen-col-left",frozenColRight:"wj-frozen-col-right",frozenColRightEdge:"wj-frozen-col-right-edge",frozenRow:"wj-frozen-row",frozenRowBottom:"wj-frozen-row-bottom",gridEditor:"wj-grid-editor",gridIme:"wj-grid-ime",gridListBox:"wj-grid-listbox",group:"wj-group",groupSummary:"wj-group-summary",hasDropDown:"wj-hasdropdown",header:"wj-header",headerAlt:"wj-header-alt",hostElement:"wj-flexgrid",lastFrozenRow:"wj-last-frozen-row",lastFrozenRowBottom:"wj-last-frozen-row-bottom",lastVisibleCol:"wj-last-visible-col",lastVisibleRow:"wj-last-visible-row",marker:"wj-marker",marquee:"wj-marquee",multiline:"wj-multiline",new:"wj-new",radioMap:"wj-radio-map",row:"wj-row",rowHeaders:"wj-rowheaders",sortAsc:"wj-sort-asc",sortDesc:"wj-sort-desc",sortIndex:"wj-sort-index",topLeft:"wj-topleft",whiteSpacePre:"wj-whitespace-pre",wrap:"wj-wrap",noDataOverlay:"wj-no-data-overlay",screenReaderOnly:"wj-sr-only"};export var _CustomEditorClsNames={editorsContainer:"wj-grid-editors-container"};export var DataMapEditor;!function(e){e[e.AutoComplete=0]="AutoComplete";e[e.DropDownList=1]="DropDownList";e[e.RadioButtons=2]="RadioButtons";e[e.Menu=3]="Menu"}(DataMapEditor||(DataMapEditor={}));var DataMap=function(){function DataMap(e,t,i){this._keyPath="";this._displayPath="";this._sortByVal=!0;this._editable=!1;this._useFilter=!1;this._serK=!0;this.mapChanged=new Event;if(isArray(e)&&!t&&!i){e=e.map((function(e){return{value:e}}));t=i="value"}this._cv=asCollectionView(e);this._keyPath=asString(t,!1);this._displayPath=asString(i,!1);this._cv.collectionChanged.addHandler(this.onMapChanged,this)}Object.defineProperty(DataMap.prototype,"sortByDisplayValues",{get:function(){return this._sortByVal},set:function(e){this._sortByVal=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(DataMap.prototype,"serializeKeys",{get:function(){return this._serK},set:function(e){if((e=asBoolean(e))!==this._serK){var t=this._map,i=t&&t.size;this._map=null;this._serK=e;i&&this.onMapChanged(EventArgs.empty)}},enumerable:!0,configurable:!0});Object.defineProperty(DataMap.prototype,"collectionView",{get:function(){return this._cv},enumerable:!0,configurable:!0});Object.defineProperty(DataMap.prototype,"selectedValuePath",{get:function(){return this._keyPath},enumerable:!0,configurable:!0});Object.defineProperty(DataMap.prototype,"displayMemberPath",{get:function(){return this._displayPath},enumerable:!0,configurable:!0});DataMap.prototype.getDataItem=function(e){var t=this;if(!this._map){var i=this._cv.sourceCollection,o=new _Map(this.serializeKeys);isArray(i)&&this._keyPath&&i.forEach((function(e){var i=e[t._keyPath];o.has(i)||o.set(i,e)}));this._map=o}return this._map.get(e)};DataMap.prototype.getDisplayValue=function(e){var t=this._displayPath,i=this.getDataItem(e);return t&&i?i[t]:e};DataMap.prototype.getKeyValue=function(e,t){var i=this._displayPath,o=this._indexOf(e,i,t,!0);o<0&&(o=this._indexOf(e,i,t,!1));return o>-1?this._cv.sourceCollection[o][this._keyPath]:null};DataMap.prototype.getDisplayValues=function(e){var t=this;return this._cv&&this._displayPath?this._cv.items.map((function(e){return e[t._displayPath]})):[]};DataMap.prototype.getFilteredItems=function(e){return this._cv?this._cv.items:[]};Object.defineProperty(DataMap.prototype,"useFilter",{get:function(){return this._useFilter},set:function(e){this._useFilter=asBoolean(e)},enumerable:!0,configurable:!0});DataMap.prototype.getKeyValues=function(){var e=this;return this._cv&&this._keyPath?this._cv.items.map((function(t){return t[e._keyPath]})):[]};Object.defineProperty(DataMap.prototype,"isEditable",{get:function(){return this._editable},set:function(e){this._editable=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(DataMap.prototype,"search",{get:function(){return this._search},set:function(e){e&&(this._search=asFunction(e))},enumerable:!0,configurable:!0});DataMap.prototype.onMapChanged=function(e){this._map=null;this.mapChanged.raise(this,e)};DataMap.prototype._indexOf=function(e,t,i,o){var n=-1,l=-1;if(this._cv&&t){var r=null!=e?e.toString():"";r&&i&&(e=toPlainText(r));for(var s=o?r:r.toLowerCase(),a=this._cv.sourceCollection,d=0;d<a.length;d++){var c=a[d],u=c?c[t]:void 0;null!=u&&null!=u||(u="");i&&isString(u)&&(u=toPlainText(u));u==e?n=d:o||u.length!=s.length||u.toLowerCase()!=s?null!=u&&u.toString()==r&&(n=d):n=d;if(n==d){if(!this._cv.filter||this._cv.filter(c))return n;l<0&&(l=n)}}}return l};return DataMap}();export{DataMap};var CellRange=function(){function CellRange(e,t,i,o){void 0===e&&(e=-1);void 0===t&&(t=-1);void 0===i&&(i=e);void 0===o&&(o=t);this.setRange(e,t,i,o)}CellRange.prototype.setRange=function(e,t,i,o){void 0===e&&(e=-1);void 0===t&&(t=-1);void 0===i&&(i=e);void 0===o&&(o=t);this._row=asInt(e);this._col=asInt(t);this._row2=asInt(i);this._col2=asInt(o)};Object.defineProperty(CellRange.prototype,"row",{get:function(){return this._row},set:function(e){this._row=asInt(e)},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"col",{get:function(){return this._col},set:function(e){this._col=asInt(e)},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"row2",{get:function(){return this._row2},set:function(e){this._row2=asInt(e)},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"col2",{get:function(){return this._col2},set:function(e){this._col2=asInt(e)},enumerable:!0,configurable:!0});CellRange.prototype.clone=function(){return new CellRange(this._row,this._col,this._row2,this._col2)};CellRange.prototype.copy=function(e){this.setRange(e._row,e._col,e._row2,e._col2)};Object.defineProperty(CellRange.prototype,"rowSpan",{get:function(){return Math.abs(this._row2-this._row)+1},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"columnSpan",{get:function(){return Math.abs(this._col2-this._col)+1},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"topRow",{get:function(){return Math.min(this._row,this._row2)},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"bottomRow",{get:function(){return Math.max(this._row,this._row2)},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"leftCol",{get:function(){return Math.min(this._col,this._col2)},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"rightCol",{get:function(){return Math.max(this._col,this._col2)},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"isValid",{get:function(){return this._row>-1&&this._col>-1&&this._row2>-1&&this._col2>-1},enumerable:!0,configurable:!0});Object.defineProperty(CellRange.prototype,"isSingleCell",{get:function(){return this._row==this._row2&&this._col==this._col2},enumerable:!0,configurable:!0});CellRange.prototype.contains=function(e,t){var i=tryCast(e,CellRange);if(i)return i.topRow>=this.topRow&&i.bottomRow<=this.bottomRow&&i.leftCol>=this.leftCol&&i.rightCol<=this.rightCol;if(isInt(e)&&isInt(t))return e>=this.topRow&&e<=this.bottomRow&&t>=this.leftCol&&t<=this.rightCol;throw"contains expects a CellRange or row/column indices."};CellRange.prototype.containsRow=function(e){return asInt(e)>=this.topRow&&e<=this.bottomRow};CellRange.prototype.containsColumn=function(e){return asInt(e)>=this.leftCol&&e<=this.rightCol};CellRange.prototype.intersects=function(e){return this.intersectsRow(e)&&this.intersectsColumn(e)};CellRange.prototype.intersectsRow=function(e){return e&&!(this.bottomRow<e.topRow||this.topRow>e.bottomRow)};CellRange.prototype.intersectsColumn=function(e){return e&&!(this.rightCol<e.leftCol||this.leftCol>e.rightCol)};CellRange.prototype.getRenderSize=function(e){var t=new Size(0,0);if(this.isValid){for(var i=this.topRow;i<=this.bottomRow;i++)e.rows[i]&&(t.height+=e.rows[i].renderSize);for(var o=this.leftCol;o<=this.rightCol;o++)e.columns[o]&&(t.width+=e.columns[o].renderSize)}return t};CellRange.prototype.equals=function(e){return e instanceof CellRange&&this._row==e._row&&this._col==e._col&&this._row2==e._row2&&this._col2==e._col2};CellRange.prototype.combine=function(e){return e?new CellRange(Math.min(this.topRow,e.topRow),Math.min(this.leftCol,e.leftCol),Math.max(this.bottomRow,e.bottomRow),Math.max(this.rightCol,e.rightCol)):this};CellRange.prototype.toString=function(){return format("({row}, {col})-({row2}, {col2})",this)};return CellRange}();export{CellRange};export 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||(CellType={}));var GridPanel=function(){function GridPanel(e,t,i,o,n){this._offsetY=0;this._rng=new CellRange;this._g=asType(e,FlexGrid);this._ct=asInt(t);this._rows=asType(i,RowCollection);this._cols=asType(o,ColumnCollection);this._e=asType(n,HTMLElement);this._vrb=new CellRange;this._uid=uidGenerator()}Object.defineProperty(GridPanel.prototype,"activeCell",{get:function(){return this._activeCell},enumerable:!0,configurable:!0});Object.defineProperty(GridPanel.prototype,"grid",{get:function(){return this._g},enumerable:!0,configurable:!0});Object.defineProperty(GridPanel.prototype,"cellType",{get:function(){return this._ct},enumerable:!0,configurable:!0});Object.defineProperty(GridPanel.prototype,"viewRange",{get:function(){return this._getViewRange()},enumerable:!0,configurable:!0});Object.defineProperty(GridPanel.prototype,"width",{get:function(){return this._cols.getTotalSize()},enumerable:!0,configurable:!0});Object.defineProperty(GridPanel.prototype,"height",{get:function(){return this._rows.getTotalSize()},enumerable:!0,configurable:!0});Object.defineProperty(GridPanel.prototype,"rows",{get:function(){return this._rows},enumerable:!0,configurable:!0});Object.defineProperty(GridPanel.prototype,"columns",{get:function(){return this._cols},enumerable:!0,configurable:!0});GridPanel.prototype.getCellData=function(e,t,i){t=this._toIndex(t);return this._getCellData(e,t,i)};GridPanel.prototype._getCellData=function(e,t,i){var o,n,l=this._g,r=this._rows[asNumber(e,!1,!0)];if(!r)return null;o=this._cols[asNumber(t,!1,!0)];var s=l?l._getBindingColumn(this,e,o):o,a=null,d=r instanceof GroupRow;d&&r.dataItem instanceof CollectionViewGroup&&!l.childItemsPath&&(a=r.dataItem);s&&r&&s.binding&&r.dataItem&&!a?n=s._binding.getValue(r.dataItem):r._ubv&&(n=r._ubv[o._hash]);null==n&&(n=this._getSpecialData(e,r,t,o,s,d,a,n));if(i){var c=s.dataMap||r.dataMap;if(this.cellType==CellType.Cell&&s._edt&&s._edt._ctl instanceof MultiSelect&&n){var u=new Binding(s._edt._ctl.displayMemberPath),h=u&&isArray(n)?n.map((function(e){return u.getValue(e)})):n;if(isArray(h)&&h.length>0){var p=h.join(", ");n=format(p||culture.MultiSelect.itemsSelected,{count:h.length})}}else this.cellType==CellType.Cell&&c&&(n=c.getDisplayValue(n));n=null!=n?Globalize.format(n,s.format||r.format):""}return n};GridPanel.prototype.setCellData=function(e,t,i,o,n,l){void 0===o&&(o=!0);void 0===n&&(n=!0);void 0===l&&(l=!1);var r=this._g,s=this._rows[asNumber(e,!1,!0)],a=asNumber(this._toIndex(t),!1,!0),d=this._cols[a],c=DataType;if(!s)return!1;var u=r?r._getBindingColumn(this,e,d):d;if(!u)return!1;var h=u.dataMap||s.dataMap;if(this._ct==CellType.Cell){var p=u.getIsRequired(s),g=u.isContentHtml||s.isContentHtml;if(!l&&h&&null!=i){var f=h.getKeyValue(i,g);if(null==f&&null==h.getDisplayValue(null)){if(h.getDisplayValue(i)!=i);else if(!h.isEditable||h.displayMemberPath!=h.selectedValuePath){if(""!=i||p||!r.commitEmptyEdits)return!1;i=null}}else{var _=r.getRowDataItem(e,a);if(h.useFilter&&_){var m=h.getFilteredItems(_);if(!(m.length>0))return!1;if(m.filter((function(e){return e[h._keyPath]==f})).length>0)i=f;else{var C=m.filter((function(e){return e[h.displayMemberPath]==i}));C.length>0&&(i=C[0][h._keyPath])}}else i=f}}var w=c.Object,v=u.dataType||s.dataType,y=this.getCellData(e,t,!1);u._edt&&u._edt._ctl instanceof MultiSelect&&v===c.String&&isArray(i)&&(i=i.join(", "));w=v||getType(y);if(null==i||""===i&&o&&!h){if(p||!r.commitEmptyEdits&&(null==y||""===y))return!1;w!=c.String&&(i=null);o=!1}if("NaN"==i&&Number.isNaN(y)&&!r.commitEmptyEdits)return!1;if(o){var b=u.format||s.format;b||w!=c.Date||(b="d");u.mask&&isString(i)&&w!=c.String&&(i=i.replace(/_/g,""));i=changeType(i,w,b,y);if(w!=c.Object&&getType(i)!=w)return!1}}if(s.dataItem&&u.binding){var R=u._binding,x=s.dataItem,S=R.getValue(x);if(i!==S&&(h&&!h.serializeKeys||!DateTime.equals(i,S))){var E=r.collectionView,H=E instanceof CollectionView&&x!=E.currentEditItem&&E.trackChanges,F=null;H&&(F=E._extend({},x));R.setValue(x,i);if(H){var z=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,x,E.items.indexOf(x));E.onCollectionChanged(z,F)}}}else{s._ubv||(s._ubv={});s._ubv[d._hash]=i}n&&r&&r.invalidate();return!0};GridPanel.prototype._getRowData=function(e){var t,i=this._g,o=this._rows[asNumber(e,!1,!0)],n=null,l=[];if(null!=o){var r=null,s=o instanceof GroupRow;s&&o.dataItem instanceof CollectionViewGroup&&!i.childItemsPath&&(r=o.dataItem);for(var a=!r&&o.dataItem,d=0;d<i.columns.length;d++){var c=t=this._cols[d];a&&i&&(c=i._getBindingColumn(this,e,t));c.binding?n=c._binding.getValue(o.dataItem):o._ubv&&(n=o._ubv[t._hash]);null==n&&(n=this._getSpecialData(e,o,d,t,c,s,r,n));l[d]=n}}return l};GridPanel.prototype._getSpecialData=function(e,t,i,o,n,l,r,s){var a=s,d=CellType;switch(this._ct){case d.TopLeft:case d.ColumnHeader:e!=this._rows.length-1&&n==o||(a=n.header);break;case d.ColumnFooter:if(l&&n.aggregate!=Aggregate.None){var c=this._g.collectionView;if(c){var u=tryCast(c,CollectionView);a=u?u.getAggregate(n.aggregate,n.binding):getAggregate(n.aggregate,c.items,n.binding)}}break;case d.Cell:var h=void 0,p=this._g._isServerCollectionView(this._g.collectionView);p&&(h=this._g.collectionView);if(t instanceof GroupRow)if(i==this._cols.firstVisibleIndex)a=t.getGroupHeader();else if(p&&h.groupOnServer&&(h.groupLazyLoading||h._virtualization)){var g=t.dataItem;a=h.getGroupAggregate(n.binding,g,n.aggregate)}else r&&n.aggregate!=Aggregate.None&&(a=r.getAggregate(n.aggregate,n.binding,this._g.collectionView,this._g))}return a};GridPanel.prototype.getCellBoundingRect=function(e,t,i){var o=this._g,n=this.rows[e],l=this.columns[this._toIndex(t)],r=this.rows._frozenInternal<0&&this.rows.isFrozen(e)&&o._hasScroll(this.rows)?this._g._szClient.height+n._antipos:n.pos,s=this.columns._frozenInternal<0&&this.columns.isFrozen(Number(t))&&o._hasScroll(this.columns)?this._g._szClient.width+l._antipos:l.pos,a=new Rect(s,r,l.renderSize,n.renderSize);if(o.rightToLeft){a.left=this.hostElement.clientWidth-a.right;isIE()||(a.left-=o._root.offsetWidth-o._root.clientWidth)}if(!i){var d=this.hostElement.getBoundingClientRect();a.left+=d.left;a.top+=d.top-this._offsetY}this.rows.isFrozen(e)&&(this.rows._frozenInternal>0||!this.rows.isFrozen(this.rows._firstVisible))&&(a.top-=o.scrollPosition.y);this.columns.isFrozen(Number(t))&&(a.left-=o.scrollPosition.x*(o.rightToLeft?-1:1));return a};GridPanel.prototype.getCellElement=function(e,t){var i=this.hostElement.children,o=this._g.rows._frozenInternal<0?i.length:Math.min(e+2,i.length);t=this._toIndex(t);for(var n=0;n<o;n++)for(var l=i[n].children,r=this._g.columns._frozenInternal<0?l.length:Math.min(t+2,l.length),s=0;s<r;s++){var a=l[s],d=a[GridPanel._INDEX_KEY];if(d&&(d.row==e&&d.col==t||d.rng&&d.rng.contains(e,t)))return a}return null};GridPanel.prototype.getSelectedState=function(e,t,i){var o=this._g,n=o.selectionMode,l=o._selHdl.selection,r=SelectionMode,s=SelectedState;if(n==r.None)return s.None;t=this._toIndex(t);switch(this._ct){case CellType.Cell:if(o.activePanelType!=this.cellType){i||(i=o.getMergedRange(this,e,t)||new CellRange(e,t));for(var a=i.leftCol;a<=i.rightCol;a++)if(o.columns[a]&&o.columns[a].isSelected)return s.Selected;for(var d=i.topRow;d<=i.bottomRow;d++)if(o.rows[d].isSelected)return s.Selected;return s.None}i||(i=o.getMergedRange(this,e,t));var c=o._getAnchorCell();if(i){if(i.contains(l.row,l.col)){if(!o.anchorCursor||null==c)return o.showMarquee?s.Active:s.Cursor;if(e==c.y&&t==c.x||i.row==c.y&&i.col==c.x)return o.showMarquee?s.Active:s.Cursor}if(i.intersects(l)&&o.anchorCursor&&null!=c&&(e==c.y&&t==c.x||i.row==c.y&&i.col==c.x))return o.showMarquee?s.Active:s.Cursor;if(i.intersects(l)&&n!=r.ListBox)return s.Selected;for(a=i.leftCol;a<=i.rightCol;a++)if(o.columns[a]&&o.columns[a].isSelected)return s.Selected;for(d=i.topRow;d<=i.bottomRow;d++)if(o.rows[d].isSelected)return s.Selected}if(o.anchorCursor&&null!=c){if(e==c.y&&t==c.x)return o.showMarquee?s.Active:s.Cursor}else if(l.row==e&&l.col==t)return o.showMarquee?s.Active:s.Cursor;if(o.rows[e].isSelected||o.columns[t].isSelected)return s.Selected;if(n==r.MultiRange)for(var u=o._selHdl.extendedSelection,h=0;h<u.length;h++)if(u[h].contains(e,t)||i&&i.intersects(u[h]))return s.Selected;if(i)switch(n){case r.Row:case r.RowRange:if(i.containsRow(l.row))return s.Selected}return n==r.ListBox?s.None:(l=this._getAdjustedSelection(l)).containsRow(e)&&l.containsColumn(t)?s.Selected:s.None;case CellType.ColumnHeader:if(o.activePanelType==CellType.ColumnHeader){if((i=o.getMergedRange(this,e,t,!1))&&i.contains(l))return s.Cursor;if(l.row==e&&l.col==t)return s.Cursor}if(o.activePanelType==CellType.Cell&&o.showSelectedHeaders&HeadersVisibility.Column&&(o.columns[t].isSelected||l.containsColumn(t)||l.intersectsColumn(i))){i&&(e=i.bottomRow);if(e==this.rows.length-1)return s.Selected}break;case CellType.RowHeader:if(o.activePanelType==CellType.RowHeader){if((i=o.getMergedRange(this,e,t,!1))&&i.contains(l))return s.Cursor;if(l.row==e&&l.col==t)return s.Cursor}if(o.activePanelType==CellType.Cell&&o.showSelectedHeaders&HeadersVisibility.Row&&(o.rows[e].isSelected||l.containsRow(e)||l.intersectsRow(i))){i&&(t=i.rightCol);if(t==this.columns.length-1)return s.Selected}break;case CellType.TopLeft:if(o.activePanelType==CellType.TopLeft){i||(i=o.getMergedRange(this,e,t,!1));if(i&&i.contains(l))return s.Cursor;if(l.row==e&&l.col==t)return s.Cursor}break;case CellType.BottomLeft:if(o.activePanelType===CellType.BottomLeft){i||(i=o.getMergedRange(this,e,t,!1));if(i&&i.contains(l))return s.Cursor;if(l.row==e&&l.col==t)return s.Cursor}break;case CellType.ColumnFooter:if(o.activePanelType===CellType.ColumnFooter){i||(i=o.getMergedRange(this,e,t,!1));if(i&&i.contains(l))return s.Cursor;if(l.row==e&&l.col==t)return s.Cursor}}return s.None};Object.defineProperty(GridPanel.prototype,"hostElement",{get:function(){return this._e},enumerable:!0,configurable:!0});GridPanel.prototype.isRangeValid=function(e){return e&&e.isValid&&e.bottomRow<this.rows.length&&e.rightCol<this.columns.length};GridPanel.prototype.getNextVisibleRow=function(e){void 0===e&&(e=0);for(var t=Math.max(e,0);t<this.rows.length;t++)if(this.rows[t].isVisible)return t;return-1};GridPanel.prototype.getLastVisibleRow=function(e){void 0===e&&(e=1/0);for(var t=Math.min(e,this.rows.length-1);t>=0;t--)if(this.rows[t].isVisible)return t;return-1};GridPanel.prototype.getNextVisibleColumn=function(e){void 0===e&&(e=0);for(var t=Math.max(e,0);t<this.columns.length;t++)if(this.columns[t].isVisible)return t;return-1};GridPanel.prototype.getLastVisibleColumn=function(e){void 0===e&&(e=1/0);for(var t=Math.min(e,this.columns.length-1);t>=0;t--)if(this.columns[t].isVisible)return t;return-1};GridPanel.prototype._toIndex=function(e){if(isString(e)&&(e=this._cols.indexOf(e))<0)throw"Invalid column name or binding.";return e};GridPanel.prototype._getAdjustedSelection=function(e){var t=this._g,i=this._rng,o=SelectionMode;switch(t.selectionMode){case o.Cell:i.setRange(e.row,e.col,e.row,e.col);break;case o.Row:i.setRange(e.row,0,e.row,t.columns.length-1);break;case o.RowRange:case o.ListBox:i.setRange(e.row,0,e.row2,t.columns.length-1);break;default:i.copy(e)}return i};GridPanel.prototype._getOffsetY=function(){return this._offsetY};GridPanel.prototype._updateContent=function(e,t,i,o){var n=this._g,l=this._e,r=this._rows,s=this._cols,a=this._ct;if(a==CellType.ColumnHeader||a==CellType.ColumnFooter||a==CellType.RowHeader){var d=n._ptScrl,c=l.style;a==CellType.RowHeader?c.top=d.y+"px":n.rightToLeft?c.right=d.x+"px":c.left=d.x+"px"}if(this._offsetY!=i){e=!1;this._offsetY=i}var u=this._getViewRange(),h=u;if(h.isValid){var p=r.length<=n._vtRows?r.length:0,g=s.length<=n._vtCols?s.length:0,f=r._frozenInternal>=0?Math.max(u.row-p,r._frozenInternal):Math.max(u.row-p,0),_=r._frozenInternal>=0?Math.min(u.row2+p,r.length-1):Math.min(u.row2+p,r.length-1+r._frozenInternal),m=s._frozenInternal>=0?Math.max(u.col-g,s._frozenInternal):Math.max(u.col-g,0),C=s._frozenInternal>=0?Math.min(u.col2+g,s.length-1):Math.min(u.col2+g,s.length-1+s._frozenInternal);h=new CellRange(f,m,_,C)}if(e&&!t&&this._vrb.contains(u)&&!r._frozenInternal&&!s._frozenInternal)return this._activeCell;e&&h.equals(this._vrb)||(t=!1);e&&!t&&this._ct!=CellType.TopLeft&&this._reorderCells(h,this._vrb);this._activeCell=null;this._vru=u;this._vrb=h;this._recycle=e;var w=this.grid.topLeftCells.hostElement.parentElement;[HeadersVisibility.Row,HeadersVisibility.Column].includes(n.headersVisibility)?setAttribute(w,"aria-hidden",!0):w.removeAttribute("aria-hidden");this._updateCells(t,0,o);return this._activeCell};GridPanel.prototype._updateCells=function(e,t,i){var o=this,n=this._rows,renderVisibleRange=function(){for(var n=o._vrb.topRow;n<=o._vrb.bottomRow&&n>-1;n++)t=o._renderRow(n,o._vrb,e,t,i)};if(n._frozenInternal>0){!function(){for(var l=0;l<n._frozenInternal&&l<n.length;l++)t=o._renderRow(l,o._vrb,e,t,i)}();renderVisibleRange()}else if(n._frozenInternal<0){renderVisibleRange();!function(){for(var l=n._lastFrozen;l<n.length;l++)t=o._renderRow(l,o._vrb,e,t,i)}()}else renderVisibleRange();this._scanAndRemoveExtraCells(t)};GridPanel.prototype._scanAndRemoveExtraCells=function(e){for(var t=this._e;t.childElementCount>e;){var i=t.lastElementChild;removeChild(i);this._removeExtraCells(i,0)}};GridPanel.prototype._clearCells=function(){for(var e=this.hostElement,t=this._g.cellFactory,i=e.childElementCount-1;i>=0;i--){for(var o=e.children[i],n=o.childElementCount-1;n>=0;n--)t.disposeCell(o.children[n]);removeChild(o)}e.innerHTML=""};GridPanel.prototype._reorderCells=function(e,t){var i=this;if(this._g._reorderCells&&t.isValid&&e.isValid&&e.intersects(t)){var relocateForScrollToBeginning=function(e,t,o,n,l,r){assert(o<0,"Scroll delta must be a negative number");var s,a,d=-o,c=t+(n-l+1),u=e.childElementCount-c;if(u<d&&u>0){s=u;a=d-u}else{s=d;a=0}if(s>0){var h=i._createRange(e,c,c+s);h&&e.insertBefore(h.extractContents(),e.children[t])}if(a>0)for(var p=e.children[t],g=0;g<a;g++){var f=document.createElement("div");f.className=r;e.insertBefore(f,p)}};if(e.row!=t.row){var o=this._e;if(0!=(a=e.row-t.row)){var n=this._ct==CellType.Cell?1:0,l=o.childElementCount;this.rows._frozenInternal>0&&(n+=this.rows._frozenInternal);if(a>0){var r=n,s=Math.min(n+a,l);(h=this._createRange(o,r,s))&&o.appendChild(h.extractContents())}else relocateForScrollToBeginning(o,n,a,e.row2,t.row,FlexGridClsNames.row)}}if(e.col!=t.col){var a;o=this._e;if(0!=(a=e.col-t.col)){n=this._ct==CellType.Cell&&this._g.rowHeaderPath?1:0;this.columns._frozenInternal>=0&&(n+=this.columns._frozenInternal);for(var d=0;d<o.children.length;d++){var c=o.children[d],u=l=c.children.length;this.columns._frozenInternal<0&&(u+=this.columns._frozenInternal);if(hasClass(c,FlexGridClsNames.row))if(a>0){var h;r=n,s=Math.min(n+a,u);(h=this._createRange(c,r,s))&&c.appendChild(h.extractContents())}else relocateForScrollToBeginning(c,n,a,e.col2,t.col,FlexGridClsNames.cell)}}}}};GridPanel.prototype._createRange=function(e,t,i){if(i>t&&i<=e.children.length&&t>-1){this._docRange||(this._docRange=document.createRange());var o=this._docRange;o.setStart(e,t);o.setEnd(e,i);return o}return null};GridPanel.prototype._renderRowHdrCell=function(e,t,i){var o=e.children[0];o||(o=createElement(GridPanel._HTML_CELL,e));o.setAttribute("role",t<0?"columnheader":"rowheader");o.textContent=i?i.toString():"";setCss(o,{position:"fixed",left:-32e3,top:-32e3,width:.1,height:.1,overflow:"hidden",opacity:"0"});o[GridPanel._INDEX_KEY]={row:t,col:-1,panel:this};return 1};GridPanel.prototype._renderRow=function(e,t,i,o,n){var l=this._g,r=this.rows[e];if(r.renderSize<=0)return o;var s=this._e.children[o];s||(s=createElement('<div class="'+FlexGridClsNames.row+'"></div>',this._e));var a=this._g.columnHeaders&&this._g.columnHeaders.rows&&this._g.columnHeaders.rows.length||0,d=this._g.headersVisibility&HeadersVisibility.Column?a:0,makeId=function(e,t,i){return"g-"+l._ariaId+"-"+e+"-"+t+"-"+i},setAriaOwns=function(t,i){for(var o=[],n=0;n<i;n++)o.push(makeId(t,e,n));return o.join(" ")};switch(this._ct){case CellType.ColumnHeader:if(l.headersVisibility&HeadersVisibility.Row&&l.headersVisibility&HeadersVisibility.Column){var c=[],u=setAriaOwns("tl",l.topLeftCells.columns.length);u&&c.push(u);var h=setAriaOwns("ch",this.columns.length);h&&c.push(h);(f=c.join(" "))&&setAttribute(s,"aria-owns",f)}setAttribute(s,"aria-rowindex",e+1);break;case CellType.TopLeft:setAttribute(s,"aria-rowindex",e+1);break;case CellType.Cell:if(l.headersVisibility&HeadersVisibility.Row){c=[];var p=setAriaOwns("rh",l.rowHeaders.columns.length);p&&c.push(p);var g=setAriaOwns("cell",l.cells.columns.length);g&&c.push(g);var f=c.join(" ");this._allowSetAriaOwns(f,s)?setAttribute(s,"aria-owns",f):setAttribute(s,"aria-owns")}setAttribute(s,"aria-rowindex",e+1+d);break;case CellType.RowHeader:setAttribute(s,"aria-rowindex",e+1+d);break;case CellType.BottomLeft:case CellType.ColumnFooter:if(l.headersVisibility&HeadersVisibility.Row){c=[];var _=setAriaOwns("bl",l.bottomLeftCells.columns.length);_&&c.push(_);var m=setAriaOwns("cf",l.columnFooters.columns.length);m&&c.push(m);(f=c.join(" "))&&setAttribute(s,"aria-owns",f)}var C=a+l.rows.length+e+1;setAttribute(s,"aria-rowindex",C)}if(this._ct==CellType.Cell){s.setAttribute("role","row");var w=SelectionMode,v=r.isSelected;switch(l.selectionMode){case w.Row:case w.RowRange:v=v||this._g._selHdl.selection.containsRow(e)}setAttribute(s,"aria-selected",!!v||null);setAttribute(s,"aria-level",r instanceof GroupRow?r.level+1:null);setAttribute(s,"aria-expanded",r instanceof GroupRow?!r.isCollapsed:null);this.rows.ariaLabel&&setAttribute(s,"aria-label",this.rows.ariaLabel)}this._ct!==CellType.TopLeft&&this._ct!==CellType.ColumnFooter&&this._ct!==CellType.BottomLeft||s.setAttribute("role","row");var y=0;if(this._ct==CellType.Cell||this._ct==CellType.ColumnHeader){var b=this._g._getRowHeaderPath();if(b){var R=this._ct==CellType.Cell?[b.getValue(r.dataItem),e]:[b.path,-1],x=R[0],S=R[1];y=this._renderRowHdrCell(s,S,x)}}var E=t.clone();E.col=this.columns._frozenInternal>=0?0:this.columns.length+this.columns._frozenInternal;E.col2=this.columns._frozenInternal>=0?this.columns._frozenInternal-1:this.columns.length-1;if(this.columns._frozenInternal>=0)for(var H=0;H<this.columns._frozenInternal&&H<this.columns.length;H++)y=this._renderCell(s,e,H,E,i,y,n);else for(H=Math.max(0,this.columns.length+this.columns._frozenInternal);H<this.columns.length;H++)y=this._renderCell(s,e,H,E,i,y,n);if(t.leftCol>-1){var F=l.getMergedRange(this,e,t.leftCol,!1),z=-1;if(F){z=F.leftCol;for(;!this.columns[z].isVisible&&z<F.rightCol;)z++}F&&z<t.leftCol&&(y=this._renderCell(s,e,z,t,i,y,n))}for(H=t.leftCol;H<=t.rightCol&&H>-1;H++)y=this._renderCell(s,e,H,t,i,y,n);this._removeExtraCells(s,y);return o+1};GridPanel.prototype._allowSetAriaOwns=function(e,t){return!!e&&!hasClass(t,"wj-detail-row")};GridPanel.prototype._renderCell=function(e,t,i,o,n,l,r){var s=this._g,a=this._ct==CellType.Cell?s.getMergedRange(this,t,i,!1):s.getMergedRange(this,t,i);if(a){for(var d=Math.max(o.row,a.row);d<t;d++)if(this.rows[d].renderSize)return l;for(d=Math.max(o.col,a.col);d<i;d++)if(this.columns[d].renderSize)return l;if(t>=a.row&&t<=a.row2&&i>a.col&&i<=a.col2&&this._ct===CellType.Cell&&a.isSingleCell)return l;var c=this.columns._frozenInternal;if(c&&a.col<c&&a.col2>=c&&i>a.col)return l;if(!this.columns[i].isVisible&&"DetailRow"!==this._rows[t].constructor.name)return l;if(a.leftCol!=i)for(var u=a.leftCol;u<i;u++)if(this.columns[u].isVisible)return l}var h=this.columns[i];if((!h||h.renderSize<=0)&&(!a||a.getRenderSize(this).width<=0))return l;var p=e.children[l];if(p&&!n&&this._recycle&&s._lazyRender&&!s.activeEditor){var g=p[GridPanel._INDEX_KEY];g&&g.row==t&&g.col==i&&g.rng==a&&(this.rows.isFrozen(t)||this.columns.isFrozen(i)||(n=!0))}var f=SelectedState,_=this.getSelectedState(t,i,a),m=_==f.Cursor||_==f.Active,C=!1;switch(this.cellType){case CellType.RowHeader:case CellType.ColumnHeader:case CellType.TopLeft:case CellType.BottomLeft:case CellType.ColumnFooter:C=!0}if(p&&n){toggleClass(p,ControlStateClsNames.active,m);toggleClass(p,C?FlexGridClsNames.focusHeaderCell:ControlStateClsNames.selected,_==f.Cursor);toggleClass(p,ControlStateClsNames.multiSelected,_==f.Selected);p.querySelector(".wj-column-selector, .wj-cell-check")||setAttribute(p,"aria-selected",!(!m&&_==f.None)||null);m&&(this._activeCell=p);return l+1}p||(p=createElement(GridPanel._HTML_CELL,e));setAttribute(p,"aria-colindex",r?i+1+r:i+1);m&&(this._activeCell=p);if(this._ct==CellType.Cell){setAttribute(p,"role","gridcell");setAttribute(p,"aria-selected",!(_==f.None&&!m)||null);var w=!s.canEditCell(t,i)||null;setAttribute(p,"aria-readonly",w);setAttribute(p,"aria-required",w?null:h.getIsRequired())}this._ct!==CellType.ColumnFooter&&this._ct!==CellType.BottomLeft||setAttribute(p,"role","gridcell");s.cellFactory.updateCell(this,t,i,p,a);p[GridPanel._INDEX_KEY]={row:t,col:i,rng:a,panel:this};return l+1};GridPanel.prototype._removeExtraCells=function(e,t){var i=this._g.cellFactory;0!==t||this.cellType!==CellType.RowHeader&&this.cellType!==CellType.TopLeft&&this.cellType!==CellType.BottomLeft||setAttribute(e,"aria-hidden","true");for(;e.childElementCount>t;){var o=e.lastElementChild;i.disposeCell(o);removeChild(o)}};GridPanel.prototype._getViewRange=function(){var e=this._g,t=e._ptScrl,i=e._szClientSB,o=this._rows,n=this._cols,l=new CellRange(0,0,o.length-1,n.length-1);if(this._ct==CellType.Cell||this._ct==CellType.RowHeader){var r=-t.y+this._offsetY,s=i.height;if((u=Math.min(Math.abs(o._frozenInternal),o.length-1))>0)if(o._frozenInternal>=0){r+=g=o[u-1].pos;s-=g}else{s+=g=o[o.length-u]._antipos}if(o._frozenInternal>=0)if(u>0&&o[u].pos>i.height)l.row=l.row2=-1;else{l.row=Math.min(o.length-1,Math.max(u,o.getItemAt(r)));l.row2=Math.max(l.row,o.getItemAt(r+s))}else if(u>0&&o[o.length-u]._antipos+i.height<0)l.row=l.row2=-1;else{l.row=Math.min(o.length+o._frozenInternal-1,o.getItemAt(r));l.row2=Math.max(l.row,o.getItemAt(r+s));e.columnFooters.rows.length>0&&(l.row2-=e.columnFooters.rows.length)}var a=e.hostElement;if(e._clipToScreen&&a){var d=a.getBoundingClientRect(),c=-d.top-e.cells._e.offsetTop;d.top<0&&(l.row=Math.max(l.row,o.getItemAt(c)-1));d.bottom>innerHeight&&(l.row2=Math.min(l.row2,o.getItemAt(c+innerHeight)+1))}}if(this._ct==CellType.Cell||this._ct==CellType.ColumnHeader){var u,h=-t.x,p=i.width;if((u=Math.min(Math.abs(n._frozenInternal),n.length-1))>0&&n._frozenInternal>0){h+=g=n[u-1].pos;p-=g}else if(u>0&&n._frozenInternal<0){var g;h+=g=n[0].pos}if(n._frozenInternal>=0?u>0&&n[u].pos>i.width:u>0&&Math.abs(n[n.length-u]._antipos)>i.width)l.col=l.col2=-1;else if(n._frozenInternal>=0){l.col=Math.min(n.length-1,Math.max(u,n.getItemAt(h)));l.col2=Math.max(l.col,n.getItemAt(h+p))}else{l.col=Math.min(n.length-1,Math.max(0,n.getItemAt(h)));l.col2=Math.max(l.col,n.getItemAt(h+p-n._frozenColAreaWidth))}}o.length<=Math.abs(o._frozenInternal)&&(l.row=l.row2=-1);n.length<=Math.abs(n._frozenInternal)&&(l.col=l.col2=-1);return l};GridPanel.prototype._getFrozenPos=function(){var e=this._rows._frozenInternal,t=this._cols._frozenInternal,i=null,o=null,n=0,l=0;e>0?n=(i=e>0?this._rows[e-1]:null)?i.pos+i.renderSize:0:e<0&&this._rows.lastFrozen&&(n=Math.min(this._rows.lastFrozen.pos,this._g._szClient.height+this._rows.lastFrozen._antipos));t>0?l=(o=t>0?this._cols[t-1]:null)?o.pos+o.renderSize:0:t<0&&this._cols.lastFrozen&&(l=Math.min(this._cols.lastFrozen.pos,this._g._szClient.width+this._cols.lastFrozen._antipos));return new Point(l,n)};GridPanel.prototype.dispose=function(){this._clearCells();if(this._docRange){this._docRange.detach();this._docRange=null}this._g=null;this._e=null;this._rows=null;this._cols=null;this._activeCell=null};GridPanel._INDEX_KEY=FlexGridClsNames.cellIndex;GridPanel._HTML_CELL='<div class="'+FlexGridClsNames.cell+'" tabindex="-1"></div>';return GridPanel}();export{GridPanel};var CellRangeEventArgs=function(e){__extends(CellRangeEventArgs,e);function CellRangeEventArgs(t,i,o){var n=e.call(this)||this;n._p=asType(t,GridPanel,!0);n._rng=asType(i,CellRange,!0);n._data=o;return n}Object.defineProperty(CellRangeEventArgs.prototype,"panel",{get:function(){return this._p},enumerable:!0,configurable:!0});Object.defineProperty(CellRangeEventArgs.prototype,"range",{get:function(){return this._rng.clone()},enumerable:!0,configurable:!0});Object.defineProperty(CellRangeEventArgs.prototype,"row",{get:function(){return this._rng.row},enumerable:!0,configurable:!0});Object.defineProperty(CellRangeEventArgs.prototype,"col",{get:function(){return this._rng.col},enumerable:!0,configurable:!0});Object.defineProperty(CellRangeEventArgs.prototype,"data",{get:function(){return this._data},set:function(e){this._data=e},enumerable:!0,configurable:!0});CellRangeEventArgs.prototype.getRow=function(){return this._p&&this.row>-1?this._p.rows[this.row]:null};CellRangeEventArgs.prototype.getColumn=function(e){var t=this._p,i=t&&this.col>-1?t.columns[this.col]:null;if(i&&e){var o=t.grid;i=t.cellType===CellType.ColumnHeader&&o._hasColumnGroups()?o._getColumnGroup(this.row,this.col):t.grid._getBindingColumn(t,this.row,i)}return i};return CellRangeEventArgs}(CancelEventArgs);export{CellRangeEventArgs};var FormatItemEventArgs=function(e){__extends(FormatItemEventArgs,e);function FormatItemEventArgs(t,i,o,n){void 0===n&&(n=!0);var l=e.call(this,t,i)||this;l._updateContent=!0;l._cell=asType(o,HTMLElement);return l}Object.defineProperty(FormatItemEventArgs.prototype,"cell",{get:function(){return this._cell},enumerable:!0,configurable:!0});Object.defineProperty(FormatItemEventArgs.prototype,"updateContent",{get:function(){return this._updateContent},enumerable:!0,configurable:!0});return FormatItemEventArgs}(CellRangeEventArgs);export{FormatItemEventArgs};var CellEditEndingEventArgs=function(e){__extends(CellEditEndingEventArgs,e);function CellEditEndingEventArgs(){var t=null!==e&&e.apply(this,arguments)||this;t._stayInEditMode=!1;t._refresh=!0;return t}Object.defineProperty(CellEditEndingEventArgs.prototype,"stayInEditMode",{get:function(){return this._stayInEditMode},set:function(e){this._stayInEditMode=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(CellEditEndingEventArgs.prototype,"refresh",{get:function(){return this._refresh},set:function(e){this._refresh=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(CellEditEndingEventArgs.prototype,"previousData",{get:function(){return null!=this._previousData?this._previousData:this._data},set:function(e){this._previousData=e},enumerable:!0,configurable:!0});return CellEditEndingEventArgs}(CellRangeEventArgs);export{CellEditEndingEventArgs};export function softInput(){return _getModule("wijmo.input")}export function softDetailRow(){return _getModule("wijmo.grid.detail")}export function softMultirow(){return _getModule("wijmo.grid.multirow")}export function softTransposed(){return _getModule("wijmo.grid.transposed")}export function softTransposedMultirow(){return _getModule("wijmo.grid.transposedmultirow")}export function softRestCV(){return _getModule("wijmo.rest")}export function softODataCV(){return _getModule("wijmo.odata")}export function softGridInteropBase(){return _getModule("wijmo.interop.grid")}export var SelectionMode;!function(e){e[e.None=0]="None";e[e.Cell=1]="Cell";e[e.CellRange=2]="CellRange";e[e.Row=3]="Row";e[e.RowRange=4]="RowRange";e[e.ListBox=5]="ListBox";e[e.MultiRange=6]="MultiRange"}(SelectionMode||(SelectionMode={}));export var SelectedState;!function(e){e[e.None=0]="None";e[e.Selected=1]="Selected";e[e.Cursor=2]="Cursor";e[e.Active=3]="Active"}(SelectedState||(SelectedState={}));export var SelMove;!function(e){e[e.None=0]="None";e[e.Next=1]="Next";e[e.Prev=2]="Prev";e[e.NextPage=3]="NextPage";e[e.PrevPage=4]="PrevPage";e[e.Home=5]="Home";e[e.End=6]="End";e[e.NextCell=7]="NextCell";e[e.PrevCell=8]="PrevCell";e[e.NextEditableCell=9]="NextEditableCell";e[e.PrevEditableCell=10]="PrevEditableCell"}(SelMove||(SelMove={}));var _SelectionHandler=function(){function _SelectionHandler(e){this._sel=new CellRange(0,0);this._xSel=new ObservableArray;this._mode=SelectionMode.CellRange;this._g=e;this._e=new CellRangeEventArgs(e.cells,new CellRange(0,0));this._collectionChangedHandler=function(){e.invalidate()};this._xSel.collectionChanged.addHandler(this._collectionChangedHandler)}Object.defineProperty(_SelectionHandler.prototype,"selectionMode",{get:function(){return this._mode},set:function(e){e!=this._mode&&this._setSelectionMode(e)},enumerable:!0,configurable:!0});Object.defineProperty(_SelectionHandler.prototype,"selection",{get:function(){return this._sel},set:function(e){this.select(e)},enumerable:!0,configurable:!0});Object.defineProperty(_SelectionHandler.prototype,"extendedSelection",{get:function(){return this._xSel},enumerable:!0,configurable:!0});Object.defineProperty(_SelectionHandler.prototype,"cellRangeEventArgs",{get:function(){return this._e},enumerable:!0,configurable:!0});_SelectionHandler.prototype.select=function(e,t,i,o){void 0===t&&(t=!0);void 0===i&&(i=!1);o||(o=this._g._gpCells);var n=this._g,l=this._e.range,r=this._sel,s=l,a=!1,d=SelectionMode,c=n.activePanelType,u=o.cellType==CellType.RowHeader||o.cellType==CellType.ColumnHeader,h=o.cellType==CellType.BottomLeft||o.cellType==CellType.ColumnFooter,p=!u&&!h;n._mouseHdl._eMouse&&(n._mouseHdl._eMouse.ctrlKey||n._mouseHdl._eMouse.metaKey);if(isNumber(e)&&isString(t)){var g=o.columns.indexOf(t);if(g<0)throw"Invalid column name or binding.";l.setRange(e,g);t=!0}else if(isNumber(e)&&isNumber(t)){l.setRange(e,t);t=!0}else e instanceof CellRange?l.copy(e):assert(!1,"CellRange expected");n.activePanel=o;switch(n.selectionMode){case d.Cell:s.row2=s.row;s.col2=s.col;break;case d.Row:s.row2=s.row;break;case d.ListBox:a=!0}if(u||h){s.row2=s.row;s.col2=s.col}var f=s.equals(r)&&c==o.cellType;if(f&&a&&p)for(var _=0;_<n.rows.length;_++)if(n.rows[_].isSelected!==s.containsRow(_)){f=!1;break}if(f){t&&o.isRangeValid(s)&&this._showSelection();return!0}var m=Control.getControl(closest(getActiveElement(),"."+FlexGridClsNames.hostElement));if(m&&m==n&&m.activeEditor&&!m.finishEditing())return!1;var C=this._e;C._rng=s;C.cancel=!1;if(!n.onSelectionChanging(C)&&!i)return!1;p&&a&&n.rows.forEach((function(e,t){e._setFlag(RowColFlags.Selected,s.containsRow(t),!0)}));s.row=Math.min(s.row,o.rows.length-1);s.row2=Math.min(s.row2,o.rows.length-1);this._sel.copy(s);n.refreshCells(!1,!0,!0);t&&this._showSelection();var w=n.collectionView;if(w&&p){var v=n._getCvIndex(s.row);w.moveCurrentToPosition(v)}var y=getActiveElement();this._g.errorTip&&(y.classList.contains(ControlStateClsNames.invalid)?this._g.errorTip._showAutoTip(void 0,y):this._g.errorTip.hide());n.onSelectionChanged(C);return!0};_SelectionHandler.prototype.moveSelectionWithinSelectedPanel=function(e,t){var i=this._g,o=this._sel.clone(),n=i.activePanel,l=i.getMergedRange(n,o.row,o.col,!1);l||(l=new CellRange(o.row,o.col));if(e>0){var r=n.getNextVisibleRow(l.bottomRow+e);r>=0&&(o.row=o.row2=r);if(!n.columns[o.col].isVisible){var s=n.getNextVisibleColumn(l.leftCol);s>=0&&(o.col=o.col2=s)}}else if(e<0){var a=n.getLastVisibleRow(l.topRow+e);a>=0&&(o.row=o.row2=a)}if(t>0){var d=n.getNextVisibleColumn(l.rightCol+t);d>=0&&(o.col=o.col2=d)}else if(t<0){var c=n.getLastVisibleColumn(l.leftCol+t);c>=0&&(o.col=o.col2=c)}o.equals(this._sel)||i.select(o,!0,n)};_SelectionHandler.prototype.moveSelection=function(e,t,i){var o=this._g,n=this._sel,l=i&&o.anchorCursor?new CellRange(n.row2,n.col2):new CellRange(n.row,n.col),r=l.row,s=l.col,a=o.columns,d=Math.max(0,o._szClient.height-o.columnHeaders.height),c=SelMove,u=-1,h=o.getMergedRange(o.cells,r,s),p=0;if(h){t==c.Next||t==c.NextCell||t==c.NextEditableCell?s=h.rightCol:t!=c.Prev&&t!=c.PrevCell&&t!=c.PrevEditableCell||(s=h.leftCol);if(e==c.Next||e==c.NextCell||e==c.NextEditableCell){r=h.bottomRow;if(softMultirow()&&o instanceof softMultirow().MultiRow){p=l.row-h.topRow;if(h.bottomRow===o.rows.length-1)return}}else if(e==c.Prev||e==c.PrevCell||e==c.PrevEditableCell){r=h.topRow;if(softMultirow()&&o instanceof softMultirow().MultiRow){p=l.row-h.bottomRow;if(0===h.topRow)return}}}switch(t){case c.NextCell:case c.NextEditableCell:u=s;(s=this._getNextColumnCell(r,u,t))!=u&&(h=o.getMergedRange(o.cells,r,s))&&s<h.col2&&(s=h.col2);if(s==u)for(;;){if(r==o.rows.length-1){s=l.col;r=l.row;break}var g=!1;if((r=this._getNextRowCell(r,s,t))>l.row){u=-1;for(;u<a.length;){if((s=this._getNextColumnCell(r,u,t))==u){g=!0;break}(h=o.getMergedRange(o.cells,r,s))&&s<h.col2&&(s=h.col2);break}if(g)continue}break}o.select(r,s);break;case c.PrevCell:case c.PrevEditableCell:u=s;(s=this._getNextColumnCell(r,u,t))!=u&&(h=o.getMergedRange(o.cells,r,s))&&s>h.col&&(s=h.col);if(s==u)for(;;){if(0==r){s=l.col;r=l.row;break}g=!1;if((r=this._getNextRowCell(r,s,t))<l.row){u=a.length;for(;u>-1;){(s=this._getNextColumnCell(r,u,t))!=u?(h=o.getMergedRange(o.cells,r,s))&&s>h.col&&(s=h.col):g=!0;break}if(g)continue}break}o.select(r,s);break;default:r=this._getNextRowCell(r,s,e,d);r+=p;s=this._getNextColumnCell(r,s,t,d);i?o.selection=o.anchorCursor?new CellRange(n.row,n.col,r,s):new CellRange(r,s,n.row2,n.col2):o.select(r,s)}};_SelectionHandler.prototype._getNextColumnCell=function(e,t,i,o){void 0===o&&(o=0);return this._g.columns.getNextCell(t,i,o)};_SelectionHandler.prototype._getNextRowCell=function(e,t,i,o){void 0===o&&(o=0);return this._g.rows.getNextCell(e,i,o)};_SelectionHandler.prototype._setSelectionMode=function(e){var t=this._g,i=t.rows;this._mode=e;this._xSel.clear();if(i.length){this._adjustSelection(this._sel,e,!0);t.invalidate()}};_SelectionHandler.prototype._adjustSelection=function(e,t,i){void 0===i&&(i=!1);var o=this._g.rows,n=SelectionMode,l=void 0;if(this._g.hostElement){l=this._g.hostElement.querySelector("input.wj-column-selector")instanceof HTMLInputElement}if(!l)for(var r=0;r<o.length;r++)o[r]._setFlag(RowColFlags.Selected,!1,!0);var s=e.clone();switch(t){case n.None:s=new CellRange;break;case n.Cell:s=new CellRange(e.row,e.col);break;case n.ListBox:if(l)return;for(r=0;r<o.length;r++)o[r]._setFlag(RowColFlags.Selected,s.containsRow(r),!0)}this.select(s,!1,i)};_SelectionHandler.prototype._expandSelection=function(){var e=this._g,t=e.selectionMode;if(e.expandSelectionOnCopyPaste&&t){var i=this.selection,o=SelectionMode;switch(t){case o.Cell:case o.Row:break;case o.ListBox:this._expandSelectedRows();break;case o.RowRange:i=new CellRange(i.topRow,0,i.bottomRow,e.columns.length-1);default:var n=this._expandSelectionRange(i);n&&this.select(n,!1)}}};_SelectionHandler.prototype._deselectRange=function(e){var t=this.selection,i=this.extendedSelection;if(t.contains(e)){var o=i.length;this._sel=o?i[o-1]:new CellRange;o&&i.removeAt(o-1);return!0}for(var n=0;n<i.length;n++)if(i[n].contains(e)){i.removeAt(n);return!0}return!1};_SelectionHandler.prototype._expandSelectedRows=function(){assert(this.selectionMode==SelectionMode.ListBox,"ListBox mode expected");for(var e=this._g,t=e.selectedRows.map((function(e){return e.index})),i=[],o=0;o<t.length;o++)for(var n=new CellRange(t[o],0,t[o],e.columns.length-1),l=this._expandSelectionRange(n)||n,r=l.topRow;r<=l.bottomRow;r++)-1===i.indexOf(r)&&i.push(r);i.sort();this._selectRows(i)};_SelectionHandler.prototype._expandSelectionRange=function(e){var t=this._g,i=t.cells,o=t.getMergedRange(i,e.topRow,e.leftCol,!1),n=t.getMergedRange(i,e.bottomRow,e.leftCol,!1),l=t.getMergedRange(i,e.topRow,e.rightCol,!1),r=t.getMergedRange(i,e.bottomRow,e.rightCol,!1);if(o||n||l||r){o=o||new CellRange(e.topRow,e.leftCol);n=n||new CellRange(e.bottomRow,e.leftCol);l=l||new CellRange(e.topRow,e.rightCol);r=r||new CellRange(e.bottomRow,e.rightCol);return new CellRange(Math.min(o.topRow,n.topRow,l.topRow,r.topRow),Math.min(o.leftCol,n.leftCol,l.leftCol,r.leftCol),Math.max(o.bottomRow,n.bottomRow,l.bottomRow,r.bottomRow),Math.max(o.rightCol,n.rightCol,l.rightCol,r.rightCol))}return null};_SelectionHandler.prototype._selectRows=function(e){assert(this.selectionMode==SelectionMode.ListBox,"ListBox mode expected");for(var t=this._g,i=0,o=!0;i<t.rows.length;i++){var n=t.rows[i],l=e&&e.indexOf(n.index)>-1;if(l&&o){o=!1;this.select(i,this.selection.col)}n.isSelected=l}};_SelectionHandler.prototype._showSelection=function(){var e=this._g,t=this._sel.clone();e.activePanelType===CellType.ColumnHeader?t.row=-1:e.activePanelType===CellType.RowHeader?t.col=-1:(e.activePanelType===CellType.BottomLeft||e.activePanelType===CellType.ColumnFooter)&&(t.row=-1);e.activePanelType!==CellType.TopLeft&&(e.anchorCursor?e.scrollIntoView(t.row2,t.col2):e.scrollIntoView(t.row,t.col));e.activePanelType!==CellType.Cell&&this._showHeaderSelection()};_SelectionHandler.prototype._showHeaderSelection=function(){var e=this._g.activePanel.activeCell;if(e){var t=e.getBoundingClientRect(),i=0,o=0,n=document.documentElement.clientWidth,l=document.documentElement.clientHeight;t.y<0?i=t.y:t.y>l-2&&(i=t.y-l+t.height);t.x<0?o=t.x:t.x>n-2&&(o=t.x-n+t.width);0==i&&0==o||window.scrollBy(o,i)}};_SelectionHandler.prototype._adjustReferenceCell=function(e,t,i){var o=this._g,n=o.getMergedRange(o.cells,e.row,e.col);if(n&&!n.isSingleCell){var l=SelMove;switch(t){case l.Next:case l.NextCell:case l.NextEditableCell:e.row=n.bottomRow;break;case l.Prev:case l.PrevCell:case l.PrevEditableCell:e.row=n.topRow}switch(i){case l.Next:case l.NextCell:case l.NextEditableCell:e.col=n.rightCol;break;case l.Prev:case l.PrevCell:case l.PrevEditableCell:e.col=n.leftCol}}};_SelectionHandler.prototype.dispose=function(){if(this._xSel&&this._collectionChangedHandler){this._xSel.collectionChanged.removeHandler(this._collectionChangedHandler);this._collectionChangedHandler=null}this._g=null;this._e=null;this._xSel=null};return _SelectionHandler}();export{_SelectionHandler};export 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