@grapecity/wijmo.grid.multirow
Advanced tools
Comparing version 5.20183.595-nightly.d20190405.t210807 to 5.20183.595-nightly.d20190406.t001954
@@ -1,14 +0,1 @@ | ||
/*! | ||
* | ||
* Wijmo Library 5.20183.595-nightly.d20190405.t210807 | ||
* 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";Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),selfModule=require("@grapecity/wijmo.grid.multirow");class _Cell extends wijmo_grid_1.Column{constructor(e){super(),this._row=this._col=0,this._rowspan=this._colspan=1,e&&wijmo_1.copy(this,e)}get colspan(){return this._colspan}set colspan(e){this._colspan=wijmo_1.asInt(e,!1,!0),wijmo_1.assert(this._colspan>0,"colspan must be >= 1")}get rowspan(){return this._rowspan}set rowspan(e){this._rowspan=wijmo_1.asInt(e,!1,!0),wijmo_1.assert(this._rowspan>0,"colspan must be >= 1")}}exports._Cell=_Cell;class _MultiRow extends wijmo_grid_1.Row{constructor(e,t,l){super(e),this._idxData=t,this._idxRecord=l}get recordIndex(){return this._idxRecord}get dataIndex(){return this._idxData}}exports._MultiRow=_MultiRow;class _CellGroup extends _Cell{constructor(e,t){if(super(),this._colstart=0,this._g=e,t&&wijmo_1.copy(this,t),!this._cells)throw"Cell group with no cells?";let l=0,s=0,o=0,i=1,r=0;this._cells.forEach((e,t)=>{if(s>0&&s+e.colspan>this._colspan){for(let e=o;e<t;e++)this._cells[e].rowspan=i;l+=i,s=0,o=t,i=e.rowspan}e._row=l,e._col=s,s+=e.colspan,i=Math.max(i,e.rowspan),r+=e.colspan}),this._rowspan=l+1,this._colspan>r&&(this._colspan=r);for(let e=0;e<this._cells.length;e++){let t=this._cells[e];(e==this._cells.length-1||this._cells[e+1]._row>t._row)&&(s=t._col,t._colspan=this._colspan-s)}}_copy(e,t){return"cells"==e&&(this._cells=[],wijmo_1.isArray(t)&&t.forEach(e=>{let t=new _Cell(e);!e.header&&t.binding&&(t.header=wijmo_1.toHeaderCase(t.binding)),this._cells.push(t),this._colspan=Math.max(this._colspan,t.colspan)}),!0)}get cells(){return this._cells}closeGroup(e){if(e>this._rowspan){for(let t=0;t<this._cells.length;t++){let l=this._cells[t];l._row==this._rowspan-1&&(l._rowspan=e-l._row)}this._rowspan=e}this._cols=new wijmo_grid_1.ColumnCollection(this._g,this._g.columns.defaultSize),this._rng=new Array(e*this._colspan);for(let e=0;e<this._cells.length;e++){let t=this._cells[e];for(let e=0;e<t._rowspan;e++)for(let l=0;l<t._colspan;l++){let s=(t._row+e)*this._colspan+t._col+l;this._cols.setAt(s,t);let o=new wijmo_grid_1.CellRange(0-e,0-l,0-e+t._rowspan-1,0-l+t._colspan-1);o.isSingleCell||(this._rng[s]=o)}}this._rng[-1]=new wijmo_grid_1.CellRange(0,this._colstart,0,this._colstart+this._colspan-1)}getColumnWidth(e){for(let t=0;t<this._cells.length;t++){let l=this._cells[t];if(l._col==e&&1==l.colspan)return l.width}return null}getMergedRange(e,t,l){if(t<0)return this._rng[-1];let s=e.rows[t],o=null!=s.recordIndex?s.recordIndex:t%this._rowspan,i=l-this._colstart,r=this._rng[o*this._colspan+i];return e.cellType==wijmo_grid_1.CellType.ColumnHeader&&t++,r?new wijmo_grid_1.CellRange(t+r.row,l+r.col,t+r.row2,l+r.col2):null}getBindingColumn(e,t,l){if(t<0)return this;let s=e.rows[t],o=s&&null!=s.recordIndex?s.recordIndex:t%this._rowspan,i=l-this._colstart;return this._cols[o*this._colspan+i]}getColumn(e){return this._cols.getColumn(e)}}exports._CellGroup=_CellGroup;class _MergeManager extends wijmo_grid_1.MergeManager{getMergedRange(e,t,l,s=!0){let o=e.grid;switch(e.cellType){case wijmo_grid_1.CellType.Cell:case wijmo_grid_1.CellType.RowHeader:if(e.rows[t]instanceof wijmo_grid_1.GroupRow)return super.getMergedRange(e,t,l,s)}switch(e.cellType){case wijmo_grid_1.CellType.Cell:case wijmo_grid_1.CellType.ColumnHeader:let s=o._cellGroupsByColumn[l];wijmo_1.assert(s instanceof _CellGroup,"Failed to get the group!");let i=e.cellType==wijmo_grid_1.CellType.ColumnHeader?s.getMergedRange(e,t-1,l):s.getMergedRange(e,t,l),r=e.columns.frozen;r&&i&&i.columnSpan>1&&i.col<r&&i.col2>=r&&(i=i.clone(),l<r?i.col2=r-1:i.col=r);let n=e.rows.frozen;return n&&i&&i.rowSpan>1&&e.cellType==wijmo_grid_1.CellType.Cell&&i.row<n&&i.row2>=n&&(i=i.clone(),t<n?i.row2=n-1:i.row=n),i;case wijmo_grid_1.CellType.RowHeader:let a=o._rowsPerItem,_=t-e.rows[t].recordIndex,d=Math.min(_+a-1,e.rows.length-1);return new wijmo_grid_1.CellRange(_,0,d,e.columns.length-1);case wijmo_grid_1.CellType.TopLeft:return new wijmo_grid_1.CellRange(0,0,e.rows.length-1,e.columns.length-1)}return null}}exports._MergeManager=_MergeManager;class MultiRow extends wijmo_grid_1.FlexGrid{constructor(e,t){super(e),this._rowsPerItem=1,this._cellBindingGroups=[],this._centerVert=!0,this._collapsedHeaders=!1,this.collapsedHeadersChanging=new wijmo_1.Event,this.collapsedHeadersChanged=new wijmo_1.Event,wijmo_1.addClass(this.hostElement,"wj-multirow");let l=this.columnHeaders.hostElement.parentElement,s=wijmo_1.createElement('<div class="wj-hdr-collapse"><span></span></div>');s.style.display="none",l.appendChild(s),this._btnCollapse=s,this._updateButtonGlyph(),this.addEventListener(s,"mousedown",e=>{switch(this.collapsedHeaders){case null:case!1:this._collapsedHeadersWasNull=null==this.collapsedHeaders,this.collapsedHeaders=!0;break;case!0:this.collapsedHeaders=!!this._collapsedHeadersWasNull&&null}e.preventDefault(),this.focus()},!0),this.autoGenerateColumns=!1,this.mergeManager=new _MergeManager(this);let o=this.hostElement;this.removeEventListener(o,"dragover"),this.removeEventListener(o,"dragleave"),this.removeEventListener(o,"dragdrop"),this._addHdl=new _MultiRowAddNewHandler(this),this.formatItem.addHandler(this._formatItem,this),this.addEventListener(this.rowHeaders.hostElement,"click",e=>{if(!e.defaultPrevented&&this.selectionMode!=wijmo_grid_1.SelectionMode.None){let t=this.hitTest(e);if(t.panel==this.rowHeaders&&t.row>-1){let t=this.selection,l=this.rows[t.topRow],s=this.selectionMode!=wijmo_grid_1.SelectionMode.Row?this.rows[t.bottomRow]:l;if(l&&null!=l.recordIndex){let o=l.index-l.recordIndex,i=s.index-s.recordIndex+this.rowsPerItem-1,r=this.columns.length-1,n=t.row!=t.topRow?new wijmo_grid_1.CellRange(i,0,o,r):new wijmo_grid_1.CellRange(o,0,i,r);this.select(n),e.preventDefault()}}}},!0),this.initialize(t)}_getProductInfo(){return"H87K,MultiRow"}get layoutDefinition(){return this._layoutDef}set layoutDefinition(e){this._layoutDef=wijmo_1.asArray(e),this._rowsPerItem=1,this._cellBindingGroups=this._parseCellGroups(this._layoutDef),this._cellBindingGroups.forEach(e=>{this._rowsPerItem=Math.max(this._rowsPerItem,e._rowspan)}),this._bindGrid(!0)}get rowsPerItem(){return this._rowsPerItem}getBindingColumn(e,t,l){return this._getBindingColumn(e,t,e.columns[l])}getColumn(e){if(wijmo_1.isString(e)){let t=this._cellBindingGroups,l=null;for(let s=0;s<t.length&&!l;s++)l=t[s].getColumn(e);return l}return super.getColumn(e)}get centerHeadersVertically(){return this._centerVert}set centerHeadersVertically(e){e!=this._centerVert&&(this._centerVert=wijmo_1.asBoolean(e),this.invalidate())}get collapsedHeaders(){return this._collapsedHeaders}set collapsedHeaders(e){if(e!=this._collapsedHeaders){let t=new wijmo_1.CancelEventArgs;this.onCollapsedHeadersChanging(t)&&(this._collapsedHeaders=wijmo_1.asBoolean(e,!0),this._updateCollapsedHeaders(),this._updateButtonGlyph(),this.onCollapsedHeadersChanged(t))}}get showHeaderCollapseButton(){return""==this._btnCollapse.style.display}set showHeaderCollapseButton(e){e!=this.showHeaderCollapseButton&&(this._btnCollapse.style.display=wijmo_1.asBoolean(e)?"":"none")}onCollapsedHeadersChanging(e){return this.collapsedHeadersChanging.raise(this,e),!e.cancel}onCollapsedHeadersChanged(e){this.collapsedHeadersChanged.raise(this,e)}_getQuickAutoSize(){return wijmo_1.isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter}_addBoundRow(e,t){let l=e[t];for(let e=0;e<this._rowsPerItem;e++)this.rows.push(new _MultiRow(l,t,e))}_addNode(e,t,l){this._addBoundRow(e,t)}_bindColumns(){let e=this.columnHeaders.rows,t=this._rowsPerItem+1;for(;e.length>t;)e.removeAt(e.length-1);for(;e.length<t;)e.push(new wijmo_grid_1.Row);this._updateCollapsedHeaders(),this.columns.clear(),this._cellGroupsByColumn={};let l=null,s=this.collectionView;if(s&&s.sourceCollection&&s.sourceCollection.length&&(l=s.sourceCollection[0]),this._cellBindingGroups)for(let e=0;e<this._cellBindingGroups.length;e++){let t=this._cellBindingGroups[e];for(let e=0;e<t._colspan;e++){this._cellGroupsByColumn[this.columns.length]=t;let l=new wijmo_grid_1.Column;for(let s=0;s<t.cells.length;s++){let o=t.cells[s],i="width,binding,header,format,dataMap,name,aggregate".split(",");if(o._col==e){i.forEach(e=>{null!=o[e]&&(l[e]=o[e])});break}}this.columns.push(l)}}}_updateCollapsedHeaders(){let e=this.columnHeaders.rows,t=this.collapsedHeaders;e[0].visible=0!=t;for(let l=1;l<e.length;l++)e[l].visible=1!=t}_updateColumnTypes(){super._updateColumnTypes();let e=this.collectionView;if(wijmo_1.hasItems(e)){let t=e.items[0];for(let e=0;e<this._cellBindingGroups.length;e++){let l=this._cellBindingGroups[e];for(let e=0;e<l._cols.length;e++){let s=l._cols[e];null==s.dataType&&s._binding&&(s.dataType=wijmo_1.getType(s._binding.getValue(t)))}}}}_getBindingColumn(e,t,l){if(e==this.cells||e==this.columnHeaders){let s=this._cellGroupsByColumn[l.index];e==this.columnHeaders&&t--,l=s.getBindingColumn(e,t,l.index)}return l}_cvCollectionChanged(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{let e=wijmo_1.NotifyCollectionChangedAction;switch(t.action){case e.Change:this.invalidate();break;case e.Add:if(t.index==this.collectionView.items.length-1){let e=this.rows.length;for(;e>0&&this.rows[e-1]instanceof wijmo_grid_1._NewRowTemplate;)e--;for(let l=0;l<this._rowsPerItem;l++)this.rows.insert(e+l,new _MultiRow(t.item,t.index,l));return}wijmo_1.assert(!1,"added item should be the last one.");break;default:this._bindGrid(!1)}}}_parseCellGroups(e){let t=[],l=1;if(e){for(let s=0,o=0;s<e.length;s++){let i=new _CellGroup(this,e[s]);i._colstart=o,o+=i._colspan,l=Math.max(l,i._rowspan),t.push(i)}for(let e=0;e<t.length;e++)t[e].closeGroup(l)}return t}_formatItem(e,t){let l=this._rowsPerItem,s=t.panel.cellType,o=t.panel.rows[t.range.row],i=t.panel.rows[t.range.row2],r=t.cell;if(s==wijmo_grid_1.CellType.ColumnHeader&&wijmo_1.toggleClass(r,"wj-group-header",0==t.range.row),s==wijmo_grid_1.CellType.Cell||s==wijmo_grid_1.CellType.ColumnHeader){let e=this._cellGroupsByColumn[t.col];wijmo_1.assert(e instanceof _CellGroup,"Failed to get the group!"),wijmo_1.toggleClass(r,"wj-group-start",e._colstart==t.range.col),wijmo_1.toggleClass(r,"wj-group-end",e._colstart+e._colspan-1==t.range.col2)}l>1&&(s!=wijmo_grid_1.CellType.Cell&&s!=wijmo_grid_1.CellType.RowHeader||(wijmo_1.toggleClass(r,"wj-record-start",o instanceof _MultiRow&&0==o.recordIndex),wijmo_1.toggleClass(r,"wj-record-end",i instanceof _MultiRow&&i.recordIndex==l-1)));let n=this.alternatingRowStep;if(n){let e=!1;o instanceof _MultiRow&&(e=o.dataIndex%(n+1)==0,1==n&&(e=!e)),wijmo_1.toggleClass(r,"wj-alt",e)}if(this._centerVert&&!r.getAttribute("wj-state-measuring")){let e=!1;if(r.innerHTML&&t.range.rowSpan>1)if(e=!0,0==r.childElementCount)r.innerHTML="<div>"+r.innerHTML+"</div>";else{let e=document.createElement("div"),t=document.createRange();t.selectNodeContents(r),t.surroundContents(e)}wijmo_1.toggleClass(r,"wj-center-vert",e)}}_updateButtonGlyph(){let e=this._btnCollapse.querySelector("span");e instanceof HTMLElement&&(e.className=this.collapsedHeaders?"wj-glyph-left":"wj-glyph-down-left")}_getError(e,t,l){if(wijmo_1.isFunction(this.itemValidator)&&e==this.rowHeaders)for(let e=0;e<this._rowsPerItem;e++)for(l=0;l<this.columns.length;l++){let s=this.itemValidator(t+e,l);if(s)return s}return super._getError(e,t,l)}}exports.MultiRow=MultiRow;class _MultiRowAddNewHandler extends wijmo_grid_1._AddNewHandler{constructor(e){e._addHdl._detach(),super(e)}updateNewRowTemplate(){let e=this._g.editableCollectionView,t=this._g,l=t.rows,s=e&&e.canAddNew&&t.allowAddNew&&!t.isReadOnly,o=-1;for(let e=0;e<l.length;e+=t.rowsPerItem)if(l[e]instanceof _MultiRowNewRowTemplate){o=e;break}if(s&&o>-1&&(this._top&&o>0||!this._top&&0==o)&&(o=-1,this._removeNewRowTemplate()),s&&o<0)for(let e=0;e<t.rowsPerItem;e++){let t=new _MultiRowNewRowTemplate(e);this._top?l.insert(e,t):l.push(t)}!s&&o>-1&&this._removeNewRowTemplate()}_keydown(e){super._keydown(e),e.defaultPrevented||e.keyCode!=wijmo_1.Key.Escape||this._copyNewDataItem()}_rowEditEnded(e,t){super._rowEditEnded(e,t),this._copyNewDataItem()}_beginningEdit(e,t){super._beginningEdit(e,t),this._top&&!e.rows[0].dataItem&&this._copyNewDataItem()}_copyNewDataItem(){if(this._top){let e=this._g,t=e.rows;for(let l=0;l<e.rowsPerItem;l++)t[l]instanceof wijmo_grid_1._NewRowTemplate&&(t[l].dataItem=this._nrt.dataItem)}}_removeNewRowTemplate(){for(let e=0,t=this._g.rows;e<t.length;e++)t[e]instanceof wijmo_grid_1._NewRowTemplate&&(t.removeAt(e),e--)}}exports._MultiRowAddNewHandler=_MultiRowAddNewHandler;class _MultiRowNewRowTemplate extends wijmo_grid_1._NewRowTemplate{constructor(e){super(),this._idxRecord=e}get recordIndex(){return this._idxRecord}}wijmo_1._registerModule("wijmo.grid.multirow",selfModule); | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),selfModule=require("@grapecity/wijmo.grid.multirow");class _Cell extends wijmo_grid_1.Column{constructor(e){super(),this._row=this._col=0,this._rowspan=this._colspan=1,e&&wijmo_1.copy(this,e)}get colspan(){return this._colspan}set colspan(e){this._colspan=wijmo_1.asInt(e,!1,!0),wijmo_1.assert(this._colspan>0,"colspan must be >= 1")}get rowspan(){return this._rowspan}set rowspan(e){this._rowspan=wijmo_1.asInt(e,!1,!0),wijmo_1.assert(this._rowspan>0,"colspan must be >= 1")}}exports._Cell=_Cell;class _MultiRow extends wijmo_grid_1.Row{constructor(e,t,l){super(e),this._idxData=t,this._idxRecord=l}get recordIndex(){return this._idxRecord}get dataIndex(){return this._idxData}}exports._MultiRow=_MultiRow;class _CellGroup extends _Cell{constructor(e,t){if(super(),this._colstart=0,this._g=e,t&&wijmo_1.copy(this,t),!this._cells)throw"Cell group with no cells?";let l=0,s=0,o=0,i=1,r=0;this._cells.forEach((e,t)=>{if(s>0&&s+e.colspan>this._colspan){for(let e=o;e<t;e++)this._cells[e].rowspan=i;l+=i,s=0,o=t,i=e.rowspan}e._row=l,e._col=s,s+=e.colspan,i=Math.max(i,e.rowspan),r+=e.colspan}),this._rowspan=l+1,this._colspan>r&&(this._colspan=r);for(let e=0;e<this._cells.length;e++){let t=this._cells[e];(e==this._cells.length-1||this._cells[e+1]._row>t._row)&&(s=t._col,t._colspan=this._colspan-s)}}_copy(e,t){return"cells"==e&&(this._cells=[],wijmo_1.isArray(t)&&t.forEach(e=>{let t=new _Cell(e);!e.header&&t.binding&&(t.header=wijmo_1.toHeaderCase(t.binding)),this._cells.push(t),this._colspan=Math.max(this._colspan,t.colspan)}),!0)}get cells(){return this._cells}closeGroup(e){if(e>this._rowspan){for(let t=0;t<this._cells.length;t++){let l=this._cells[t];l._row==this._rowspan-1&&(l._rowspan=e-l._row)}this._rowspan=e}this._cols=new wijmo_grid_1.ColumnCollection(this._g,this._g.columns.defaultSize),this._rng=new Array(e*this._colspan);for(let e=0;e<this._cells.length;e++){let t=this._cells[e];for(let e=0;e<t._rowspan;e++)for(let l=0;l<t._colspan;l++){let s=(t._row+e)*this._colspan+t._col+l;this._cols.setAt(s,t);let o=new wijmo_grid_1.CellRange(0-e,0-l,0-e+t._rowspan-1,0-l+t._colspan-1);o.isSingleCell||(this._rng[s]=o)}}this._rng[-1]=new wijmo_grid_1.CellRange(0,this._colstart,0,this._colstart+this._colspan-1)}getColumnWidth(e){for(let t=0;t<this._cells.length;t++){let l=this._cells[t];if(l._col==e&&1==l.colspan)return l.width}return null}getMergedRange(e,t,l){if(t<0)return this._rng[-1];let s=e.rows[t],o=null!=s.recordIndex?s.recordIndex:t%this._rowspan,i=l-this._colstart,r=this._rng[o*this._colspan+i];return e.cellType==wijmo_grid_1.CellType.ColumnHeader&&t++,r?new wijmo_grid_1.CellRange(t+r.row,l+r.col,t+r.row2,l+r.col2):null}getBindingColumn(e,t,l){if(t<0)return this;let s=e.rows[t],o=s&&null!=s.recordIndex?s.recordIndex:t%this._rowspan,i=l-this._colstart;return this._cols[o*this._colspan+i]}getColumn(e){return this._cols.getColumn(e)}}exports._CellGroup=_CellGroup;class _MergeManager extends wijmo_grid_1.MergeManager{getMergedRange(e,t,l,s=!0){let o=e.grid;switch(e.cellType){case wijmo_grid_1.CellType.Cell:case wijmo_grid_1.CellType.RowHeader:if(e.rows[t]instanceof wijmo_grid_1.GroupRow)return super.getMergedRange(e,t,l,s)}switch(e.cellType){case wijmo_grid_1.CellType.Cell:case wijmo_grid_1.CellType.ColumnHeader:let s=o._cellGroupsByColumn[l];wijmo_1.assert(s instanceof _CellGroup,"Failed to get the group!");let i=e.cellType==wijmo_grid_1.CellType.ColumnHeader?s.getMergedRange(e,t-1,l):s.getMergedRange(e,t,l),r=e.columns.frozen;r&&i&&i.columnSpan>1&&i.col<r&&i.col2>=r&&(i=i.clone(),l<r?i.col2=r-1:i.col=r);let n=e.rows.frozen;return n&&i&&i.rowSpan>1&&e.cellType==wijmo_grid_1.CellType.Cell&&i.row<n&&i.row2>=n&&(i=i.clone(),t<n?i.row2=n-1:i.row=n),i;case wijmo_grid_1.CellType.RowHeader:let a=o._rowsPerItem,_=t-e.rows[t].recordIndex,d=Math.min(_+a-1,e.rows.length-1);return new wijmo_grid_1.CellRange(_,0,d,e.columns.length-1);case wijmo_grid_1.CellType.TopLeft:return new wijmo_grid_1.CellRange(0,0,e.rows.length-1,e.columns.length-1)}return null}}exports._MergeManager=_MergeManager;class MultiRow extends wijmo_grid_1.FlexGrid{constructor(e,t){super(e),this._rowsPerItem=1,this._cellBindingGroups=[],this._centerVert=!0,this._collapsedHeaders=!1,this.collapsedHeadersChanging=new wijmo_1.Event,this.collapsedHeadersChanged=new wijmo_1.Event,wijmo_1.addClass(this.hostElement,"wj-multirow");let l=this.columnHeaders.hostElement.parentElement,s=wijmo_1.createElement('<div class="wj-hdr-collapse"><span></span></div>');s.style.display="none",l.appendChild(s),this._btnCollapse=s,this._updateButtonGlyph(),this.addEventListener(s,"mousedown",e=>{switch(this.collapsedHeaders){case null:case!1:this._collapsedHeadersWasNull=null==this.collapsedHeaders,this.collapsedHeaders=!0;break;case!0:this.collapsedHeaders=!!this._collapsedHeadersWasNull&&null}e.preventDefault(),this.focus()},!0),this.autoGenerateColumns=!1,this.mergeManager=new _MergeManager(this);let o=this.hostElement;this.removeEventListener(o,"dragover"),this.removeEventListener(o,"dragleave"),this.removeEventListener(o,"dragdrop"),this._addHdl=new _MultiRowAddNewHandler(this),this.formatItem.addHandler(this._formatItem,this),this.addEventListener(this.rowHeaders.hostElement,"click",e=>{if(!e.defaultPrevented&&this.selectionMode!=wijmo_grid_1.SelectionMode.None){let t=this.hitTest(e);if(t.panel==this.rowHeaders&&t.row>-1){let t=this.selection,l=this.rows[t.topRow],s=this.selectionMode!=wijmo_grid_1.SelectionMode.Row?this.rows[t.bottomRow]:l;if(l&&null!=l.recordIndex){let o=l.index-l.recordIndex,i=s.index-s.recordIndex+this.rowsPerItem-1,r=this.columns.length-1,n=t.row!=t.topRow?new wijmo_grid_1.CellRange(i,0,o,r):new wijmo_grid_1.CellRange(o,0,i,r);this.select(n),e.preventDefault()}}}},!0),this.initialize(t)}_getProductInfo(){return"H87K,MultiRow"}get layoutDefinition(){return this._layoutDef}set layoutDefinition(e){this._layoutDef=wijmo_1.asArray(e),this._rowsPerItem=1,this._cellBindingGroups=this._parseCellGroups(this._layoutDef),this._cellBindingGroups.forEach(e=>{this._rowsPerItem=Math.max(this._rowsPerItem,e._rowspan)}),this._bindGrid(!0)}get rowsPerItem(){return this._rowsPerItem}getBindingColumn(e,t,l){return this._getBindingColumn(e,t,e.columns[l])}getColumn(e){if(wijmo_1.isString(e)){let t=this._cellBindingGroups,l=null;for(let s=0;s<t.length&&!l;s++)l=t[s].getColumn(e);return l}return super.getColumn(e)}get centerHeadersVertically(){return this._centerVert}set centerHeadersVertically(e){e!=this._centerVert&&(this._centerVert=wijmo_1.asBoolean(e),this.invalidate())}get collapsedHeaders(){return this._collapsedHeaders}set collapsedHeaders(e){if(e!=this._collapsedHeaders){let t=new wijmo_1.CancelEventArgs;this.onCollapsedHeadersChanging(t)&&(this._collapsedHeaders=wijmo_1.asBoolean(e,!0),this._updateCollapsedHeaders(),this._updateButtonGlyph(),this.onCollapsedHeadersChanged(t))}}get showHeaderCollapseButton(){return""==this._btnCollapse.style.display}set showHeaderCollapseButton(e){e!=this.showHeaderCollapseButton&&(this._btnCollapse.style.display=wijmo_1.asBoolean(e)?"":"none")}onCollapsedHeadersChanging(e){return this.collapsedHeadersChanging.raise(this,e),!e.cancel}onCollapsedHeadersChanged(e){this.collapsedHeadersChanged.raise(this,e)}_getQuickAutoSize(){return wijmo_1.isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter}_addBoundRow(e,t){let l=e[t];for(let e=0;e<this._rowsPerItem;e++)this.rows.push(new _MultiRow(l,t,e))}_addNode(e,t,l){this._addBoundRow(e,t)}_bindColumns(){let e=this.columnHeaders.rows,t=this._rowsPerItem+1;for(;e.length>t;)e.removeAt(e.length-1);for(;e.length<t;)e.push(new wijmo_grid_1.Row);this._updateCollapsedHeaders(),this.columns.clear(),this._cellGroupsByColumn={};let l=null,s=this.collectionView;if(s&&s.sourceCollection&&s.sourceCollection.length&&(l=s.sourceCollection[0]),this._cellBindingGroups)for(let e=0;e<this._cellBindingGroups.length;e++){let t=this._cellBindingGroups[e];for(let e=0;e<t._colspan;e++){this._cellGroupsByColumn[this.columns.length]=t;let l=new wijmo_grid_1.Column;for(let s=0;s<t.cells.length;s++){let o=t.cells[s],i="width,binding,header,format,dataMap,name,aggregate".split(",");if(o._col==e){i.forEach(e=>{null!=o[e]&&(l[e]=o[e])});break}}this.columns.push(l)}}}_updateCollapsedHeaders(){let e=this.columnHeaders.rows,t=this.collapsedHeaders;e[0].visible=0!=t;for(let l=1;l<e.length;l++)e[l].visible=1!=t}_updateColumnTypes(){super._updateColumnTypes();let e=this.collectionView;if(wijmo_1.hasItems(e)){let t=e.items[0];for(let e=0;e<this._cellBindingGroups.length;e++){let l=this._cellBindingGroups[e];for(let e=0;e<l._cols.length;e++){let s=l._cols[e];null==s.dataType&&s._binding&&(s.dataType=wijmo_1.getType(s._binding.getValue(t)))}}}}_getBindingColumn(e,t,l){if(e==this.cells||e==this.columnHeaders){let s=this._cellGroupsByColumn[l.index];e==this.columnHeaders&&t--,l=s.getBindingColumn(e,t,l.index)}return l}_cvCollectionChanged(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{let e=wijmo_1.NotifyCollectionChangedAction;switch(t.action){case e.Change:this.invalidate();break;case e.Add:if(t.index==this.collectionView.items.length-1){let e=this.rows.length;for(;e>0&&this.rows[e-1]instanceof wijmo_grid_1._NewRowTemplate;)e--;for(let l=0;l<this._rowsPerItem;l++)this.rows.insert(e+l,new _MultiRow(t.item,t.index,l));return}wijmo_1.assert(!1,"added item should be the last one.");break;default:this._bindGrid(!1)}}}_parseCellGroups(e){let t=[],l=1;if(e){for(let s=0,o=0;s<e.length;s++){let i=new _CellGroup(this,e[s]);i._colstart=o,o+=i._colspan,l=Math.max(l,i._rowspan),t.push(i)}for(let e=0;e<t.length;e++)t[e].closeGroup(l)}return t}_formatItem(e,t){let l=this._rowsPerItem,s=t.panel.cellType,o=t.panel.rows[t.range.row],i=t.panel.rows[t.range.row2],r=t.cell;if(s==wijmo_grid_1.CellType.ColumnHeader&&wijmo_1.toggleClass(r,"wj-group-header",0==t.range.row),s==wijmo_grid_1.CellType.Cell||s==wijmo_grid_1.CellType.ColumnHeader){let e=this._cellGroupsByColumn[t.col];wijmo_1.assert(e instanceof _CellGroup,"Failed to get the group!"),wijmo_1.toggleClass(r,"wj-group-start",e._colstart==t.range.col),wijmo_1.toggleClass(r,"wj-group-end",e._colstart+e._colspan-1==t.range.col2)}l>1&&(s!=wijmo_grid_1.CellType.Cell&&s!=wijmo_grid_1.CellType.RowHeader||(wijmo_1.toggleClass(r,"wj-record-start",o instanceof _MultiRow&&0==o.recordIndex),wijmo_1.toggleClass(r,"wj-record-end",i instanceof _MultiRow&&i.recordIndex==l-1)));let n=this.alternatingRowStep;if(n){let e=!1;o instanceof _MultiRow&&(e=o.dataIndex%(n+1)==0,1==n&&(e=!e)),wijmo_1.toggleClass(r,"wj-alt",e)}if(this._centerVert&&!r.getAttribute("wj-state-measuring")){let e=!1;if(r.innerHTML&&t.range.rowSpan>1)if(e=!0,0==r.childElementCount)r.innerHTML="<div>"+r.innerHTML+"</div>";else{let e=document.createElement("div"),t=document.createRange();t.selectNodeContents(r),t.surroundContents(e)}wijmo_1.toggleClass(r,"wj-center-vert",e)}}_updateButtonGlyph(){let e=this._btnCollapse.querySelector("span");e instanceof HTMLElement&&(e.className=this.collapsedHeaders?"wj-glyph-left":"wj-glyph-down-left")}_getError(e,t,l){if(wijmo_1.isFunction(this.itemValidator)&&e==this.rowHeaders)for(let e=0;e<this._rowsPerItem;e++)for(l=0;l<this.columns.length;l++){let s=this.itemValidator(t+e,l);if(s)return s}return super._getError(e,t,l)}}exports.MultiRow=MultiRow;class _MultiRowAddNewHandler extends wijmo_grid_1._AddNewHandler{constructor(e){e._addHdl._detach(),super(e)}updateNewRowTemplate(){let e=this._g.editableCollectionView,t=this._g,l=t.rows,s=e&&e.canAddNew&&t.allowAddNew&&!t.isReadOnly,o=-1;for(let e=0;e<l.length;e+=t.rowsPerItem)if(l[e]instanceof _MultiRowNewRowTemplate){o=e;break}if(s&&o>-1&&(this._top&&o>0||!this._top&&0==o)&&(o=-1,this._removeNewRowTemplate()),s&&o<0)for(let e=0;e<t.rowsPerItem;e++){let t=new _MultiRowNewRowTemplate(e);this._top?l.insert(e,t):l.push(t)}!s&&o>-1&&this._removeNewRowTemplate()}_keydown(e){super._keydown(e),e.defaultPrevented||e.keyCode!=wijmo_1.Key.Escape||this._copyNewDataItem()}_rowEditEnded(e,t){super._rowEditEnded(e,t),this._copyNewDataItem()}_beginningEdit(e,t){super._beginningEdit(e,t),this._top&&!e.rows[0].dataItem&&this._copyNewDataItem()}_copyNewDataItem(){if(this._top){let e=this._g,t=e.rows;for(let l=0;l<e.rowsPerItem;l++)t[l]instanceof wijmo_grid_1._NewRowTemplate&&(t[l].dataItem=this._nrt.dataItem)}}_removeNewRowTemplate(){for(let e=0,t=this._g.rows;e<t.length;e++)t[e]instanceof wijmo_grid_1._NewRowTemplate&&(t.removeAt(e),e--)}}exports._MultiRowAddNewHandler=_MultiRowAddNewHandler;class _MultiRowNewRowTemplate extends wijmo_grid_1._NewRowTemplate{constructor(e){super(),this._idxRecord=e}get recordIndex(){return this._idxRecord}}wijmo_1._registerModule("wijmo.grid.multirow",selfModule); |
@@ -1,14 +0,1 @@ | ||
/*! | ||
* | ||
* Wijmo Library 5.20183.595-nightly.d20190405.t210807 | ||
* 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/ | ||
* | ||
*/ | ||
import{Row,MergeManager,GroupRow,CellRange,CellType,FlexGrid,_AddNewHandler,_NewRowTemplate,Column,SelectionMode,ColumnCollection}from"@grapecity/wijmo.grid";import{assert,Key,copy,asInt,Event,CancelEventArgs,addClass,createElement,asArray,asBoolean,getType,toggleClass,isFunction,NotifyCollectionChangedAction,hasItems,isString,isBoolean,isArray,toHeaderCase,_registerModule}from"@grapecity/wijmo";import*as selfModule from"@grapecity/wijmo.grid.multirow";export class _Cell extends Column{constructor(e){super(),this._row=this._col=0,this._rowspan=this._colspan=1,e&©(this,e)}get colspan(){return this._colspan}set colspan(e){this._colspan=asInt(e,!1,!0),assert(this._colspan>0,"colspan must be >= 1")}get rowspan(){return this._rowspan}set rowspan(e){this._rowspan=asInt(e,!1,!0),assert(this._rowspan>0,"colspan must be >= 1")}};export class _MultiRow extends Row{constructor(e,t,l){super(e),this._idxData=t,this._idxRecord=l}get recordIndex(){return this._idxRecord}get dataIndex(){return this._idxData}};export class _CellGroup extends _Cell{constructor(e,t){if(super(),this._colstart=0,this._g=e,t&©(this,t),!this._cells)throw"Cell group with no cells?";let l=0,s=0,o=0,r=1,n=0;this._cells.forEach((e,t)=>{if(s>0&&s+e.colspan>this._colspan){for(let e=o;e<t;e++)this._cells[e].rowspan=r;l+=r,s=0,o=t,r=e.rowspan}e._row=l,e._col=s,s+=e.colspan,r=Math.max(r,e.rowspan),n+=e.colspan}),this._rowspan=l+1,this._colspan>n&&(this._colspan=n);for(let e=0;e<this._cells.length;e++){let t=this._cells[e];(e==this._cells.length-1||this._cells[e+1]._row>t._row)&&(s=t._col,t._colspan=this._colspan-s)}}_copy(e,t){return"cells"==e&&(this._cells=[],isArray(t)&&t.forEach(e=>{let t=new _Cell(e);!e.header&&t.binding&&(t.header=toHeaderCase(t.binding)),this._cells.push(t),this._colspan=Math.max(this._colspan,t.colspan)}),!0)}get cells(){return this._cells}closeGroup(e){if(e>this._rowspan){for(let t=0;t<this._cells.length;t++){let l=this._cells[t];l._row==this._rowspan-1&&(l._rowspan=e-l._row)}this._rowspan=e}this._cols=new ColumnCollection(this._g,this._g.columns.defaultSize),this._rng=new Array(e*this._colspan);for(let e=0;e<this._cells.length;e++){let t=this._cells[e];for(let e=0;e<t._rowspan;e++)for(let l=0;l<t._colspan;l++){let s=(t._row+e)*this._colspan+t._col+l;this._cols.setAt(s,t);let o=new CellRange(0-e,0-l,0-e+t._rowspan-1,0-l+t._colspan-1);o.isSingleCell||(this._rng[s]=o)}}this._rng[-1]=new CellRange(0,this._colstart,0,this._colstart+this._colspan-1)}getColumnWidth(e){for(let t=0;t<this._cells.length;t++){let l=this._cells[t];if(l._col==e&&1==l.colspan)return l.width}return null}getMergedRange(e,t,l){if(t<0)return this._rng[-1];let s=e.rows[t],o=null!=s.recordIndex?s.recordIndex:t%this._rowspan,r=l-this._colstart,n=this._rng[o*this._colspan+r];return e.cellType==CellType.ColumnHeader&&t++,n?new CellRange(t+n.row,l+n.col,t+n.row2,l+n.col2):null}getBindingColumn(e,t,l){if(t<0)return this;let s=e.rows[t],o=s&&null!=s.recordIndex?s.recordIndex:t%this._rowspan,r=l-this._colstart;return this._cols[o*this._colspan+r]}getColumn(e){return this._cols.getColumn(e)}};export class _MergeManager extends MergeManager{getMergedRange(e,t,l,s=!0){let o=e.grid;switch(e.cellType){case CellType.Cell:case CellType.RowHeader:if(e.rows[t]instanceof GroupRow)return super.getMergedRange(e,t,l,s)}switch(e.cellType){case CellType.Cell:case CellType.ColumnHeader:let s=o._cellGroupsByColumn[l];assert(s instanceof _CellGroup,"Failed to get the group!");let r=e.cellType==CellType.ColumnHeader?s.getMergedRange(e,t-1,l):s.getMergedRange(e,t,l),n=e.columns.frozen;n&&r&&r.columnSpan>1&&r.col<n&&r.col2>=n&&(r=r.clone(),l<n?r.col2=n-1:r.col=n);let i=e.rows.frozen;return i&&r&&r.rowSpan>1&&e.cellType==CellType.Cell&&r.row<i&&r.row2>=i&&(r=r.clone(),t<i?r.row2=i-1:r.row=i),r;case CellType.RowHeader:let a=o._rowsPerItem,d=t-e.rows[t].recordIndex,h=Math.min(d+a-1,e.rows.length-1);return new CellRange(d,0,h,e.columns.length-1);case CellType.TopLeft:return new CellRange(0,0,e.rows.length-1,e.columns.length-1)}return null}};export class MultiRow extends FlexGrid{constructor(e,t){super(e),this._rowsPerItem=1,this._cellBindingGroups=[],this._centerVert=!0,this._collapsedHeaders=!1,this.collapsedHeadersChanging=new Event,this.collapsedHeadersChanged=new Event,addClass(this.hostElement,"wj-multirow");let l=this.columnHeaders.hostElement.parentElement,s=createElement('<div class="wj-hdr-collapse"><span></span></div>');s.style.display="none",l.appendChild(s),this._btnCollapse=s,this._updateButtonGlyph(),this.addEventListener(s,"mousedown",e=>{switch(this.collapsedHeaders){case null:case!1:this._collapsedHeadersWasNull=null==this.collapsedHeaders,this.collapsedHeaders=!0;break;case!0:this.collapsedHeaders=!!this._collapsedHeadersWasNull&&null}e.preventDefault(),this.focus()},!0),this.autoGenerateColumns=!1,this.mergeManager=new _MergeManager(this);let o=this.hostElement;this.removeEventListener(o,"dragover"),this.removeEventListener(o,"dragleave"),this.removeEventListener(o,"dragdrop"),this._addHdl=new _MultiRowAddNewHandler(this),this.formatItem.addHandler(this._formatItem,this),this.addEventListener(this.rowHeaders.hostElement,"click",e=>{if(!e.defaultPrevented&&this.selectionMode!=SelectionMode.None){let t=this.hitTest(e);if(t.panel==this.rowHeaders&&t.row>-1){let t=this.selection,l=this.rows[t.topRow],s=this.selectionMode!=SelectionMode.Row?this.rows[t.bottomRow]:l;if(l&&null!=l.recordIndex){let o=l.index-l.recordIndex,r=s.index-s.recordIndex+this.rowsPerItem-1,n=this.columns.length-1,i=t.row!=t.topRow?new CellRange(r,0,o,n):new CellRange(o,0,r,n);this.select(i),e.preventDefault()}}}},!0),this.initialize(t)}_getProductInfo(){return"H87K,MultiRow"}get layoutDefinition(){return this._layoutDef}set layoutDefinition(e){this._layoutDef=asArray(e),this._rowsPerItem=1,this._cellBindingGroups=this._parseCellGroups(this._layoutDef),this._cellBindingGroups.forEach(e=>{this._rowsPerItem=Math.max(this._rowsPerItem,e._rowspan)}),this._bindGrid(!0)}get rowsPerItem(){return this._rowsPerItem}getBindingColumn(e,t,l){return this._getBindingColumn(e,t,e.columns[l])}getColumn(e){if(isString(e)){let t=this._cellBindingGroups,l=null;for(let s=0;s<t.length&&!l;s++)l=t[s].getColumn(e);return l}return super.getColumn(e)}get centerHeadersVertically(){return this._centerVert}set centerHeadersVertically(e){e!=this._centerVert&&(this._centerVert=asBoolean(e),this.invalidate())}get collapsedHeaders(){return this._collapsedHeaders}set collapsedHeaders(e){if(e!=this._collapsedHeaders){let t=new CancelEventArgs;this.onCollapsedHeadersChanging(t)&&(this._collapsedHeaders=asBoolean(e,!0),this._updateCollapsedHeaders(),this._updateButtonGlyph(),this.onCollapsedHeadersChanged(t))}}get showHeaderCollapseButton(){return""==this._btnCollapse.style.display}set showHeaderCollapseButton(e){e!=this.showHeaderCollapseButton&&(this._btnCollapse.style.display=asBoolean(e)?"":"none")}onCollapsedHeadersChanging(e){return this.collapsedHeadersChanging.raise(this,e),!e.cancel}onCollapsedHeadersChanged(e){this.collapsedHeadersChanged.raise(this,e)}_getQuickAutoSize(){return isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter}_addBoundRow(e,t){let l=e[t];for(let e=0;e<this._rowsPerItem;e++)this.rows.push(new _MultiRow(l,t,e))}_addNode(e,t,l){this._addBoundRow(e,t)}_bindColumns(){let e=this.columnHeaders.rows,t=this._rowsPerItem+1;for(;e.length>t;)e.removeAt(e.length-1);for(;e.length<t;)e.push(new Row);this._updateCollapsedHeaders(),this.columns.clear(),this._cellGroupsByColumn={};let l=null,s=this.collectionView;if(s&&s.sourceCollection&&s.sourceCollection.length&&(l=s.sourceCollection[0]),this._cellBindingGroups)for(let e=0;e<this._cellBindingGroups.length;e++){let t=this._cellBindingGroups[e];for(let e=0;e<t._colspan;e++){this._cellGroupsByColumn[this.columns.length]=t;let l=new Column;for(let s=0;s<t.cells.length;s++){let o=t.cells[s],r="width,binding,header,format,dataMap,name,aggregate".split(",");if(o._col==e){r.forEach(e=>{null!=o[e]&&(l[e]=o[e])});break}}this.columns.push(l)}}}_updateCollapsedHeaders(){let e=this.columnHeaders.rows,t=this.collapsedHeaders;e[0].visible=0!=t;for(let l=1;l<e.length;l++)e[l].visible=1!=t}_updateColumnTypes(){super._updateColumnTypes();let e=this.collectionView;if(hasItems(e)){let t=e.items[0];for(let e=0;e<this._cellBindingGroups.length;e++){let l=this._cellBindingGroups[e];for(let e=0;e<l._cols.length;e++){let s=l._cols[e];null==s.dataType&&s._binding&&(s.dataType=getType(s._binding.getValue(t)))}}}}_getBindingColumn(e,t,l){if(e==this.cells||e==this.columnHeaders){let s=this._cellGroupsByColumn[l.index];e==this.columnHeaders&&t--,l=s.getBindingColumn(e,t,l.index)}return l}_cvCollectionChanged(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{let e=NotifyCollectionChangedAction;switch(t.action){case e.Change:this.invalidate();break;case e.Add:if(t.index==this.collectionView.items.length-1){let e=this.rows.length;for(;e>0&&this.rows[e-1]instanceof _NewRowTemplate;)e--;for(let l=0;l<this._rowsPerItem;l++)this.rows.insert(e+l,new _MultiRow(t.item,t.index,l));return}assert(!1,"added item should be the last one.");break;default:this._bindGrid(!1)}}}_parseCellGroups(e){let t=[],l=1;if(e){for(let s=0,o=0;s<e.length;s++){let r=new _CellGroup(this,e[s]);r._colstart=o,o+=r._colspan,l=Math.max(l,r._rowspan),t.push(r)}for(let e=0;e<t.length;e++)t[e].closeGroup(l)}return t}_formatItem(e,t){let l=this._rowsPerItem,s=t.panel.cellType,o=t.panel.rows[t.range.row],r=t.panel.rows[t.range.row2],n=t.cell;if(s==CellType.ColumnHeader&&toggleClass(n,"wj-group-header",0==t.range.row),s==CellType.Cell||s==CellType.ColumnHeader){let e=this._cellGroupsByColumn[t.col];assert(e instanceof _CellGroup,"Failed to get the group!"),toggleClass(n,"wj-group-start",e._colstart==t.range.col),toggleClass(n,"wj-group-end",e._colstart+e._colspan-1==t.range.col2)}l>1&&(s!=CellType.Cell&&s!=CellType.RowHeader||(toggleClass(n,"wj-record-start",o instanceof _MultiRow&&0==o.recordIndex),toggleClass(n,"wj-record-end",r instanceof _MultiRow&&r.recordIndex==l-1)));let i=this.alternatingRowStep;if(i){let e=!1;o instanceof _MultiRow&&(e=o.dataIndex%(i+1)==0,1==i&&(e=!e)),toggleClass(n,"wj-alt",e)}if(this._centerVert&&!n.getAttribute("wj-state-measuring")){let e=!1;if(n.innerHTML&&t.range.rowSpan>1)if(e=!0,0==n.childElementCount)n.innerHTML="<div>"+n.innerHTML+"</div>";else{let e=document.createElement("div"),t=document.createRange();t.selectNodeContents(n),t.surroundContents(e)}toggleClass(n,"wj-center-vert",e)}}_updateButtonGlyph(){let e=this._btnCollapse.querySelector("span");e instanceof HTMLElement&&(e.className=this.collapsedHeaders?"wj-glyph-left":"wj-glyph-down-left")}_getError(e,t,l){if(isFunction(this.itemValidator)&&e==this.rowHeaders)for(let e=0;e<this._rowsPerItem;e++)for(l=0;l<this.columns.length;l++){let s=this.itemValidator(t+e,l);if(s)return s}return super._getError(e,t,l)}};export class _MultiRowAddNewHandler extends _AddNewHandler{constructor(e){e._addHdl._detach(),super(e)}updateNewRowTemplate(){let e=this._g.editableCollectionView,t=this._g,l=t.rows,s=e&&e.canAddNew&&t.allowAddNew&&!t.isReadOnly,o=-1;for(let e=0;e<l.length;e+=t.rowsPerItem)if(l[e]instanceof _MultiRowNewRowTemplate){o=e;break}if(s&&o>-1&&(this._top&&o>0||!this._top&&0==o)&&(o=-1,this._removeNewRowTemplate()),s&&o<0)for(let e=0;e<t.rowsPerItem;e++){let t=new _MultiRowNewRowTemplate(e);this._top?l.insert(e,t):l.push(t)}!s&&o>-1&&this._removeNewRowTemplate()}_keydown(e){super._keydown(e),e.defaultPrevented||e.keyCode!=Key.Escape||this._copyNewDataItem()}_rowEditEnded(e,t){super._rowEditEnded(e,t),this._copyNewDataItem()}_beginningEdit(e,t){super._beginningEdit(e,t),this._top&&!e.rows[0].dataItem&&this._copyNewDataItem()}_copyNewDataItem(){if(this._top){let e=this._g,t=e.rows;for(let l=0;l<e.rowsPerItem;l++)t[l]instanceof _NewRowTemplate&&(t[l].dataItem=this._nrt.dataItem)}}_removeNewRowTemplate(){for(let e=0,t=this._g.rows;e<t.length;e++)t[e]instanceof _NewRowTemplate&&(t.removeAt(e),e--)}};class _MultiRowNewRowTemplate extends _NewRowTemplate{constructor(e){super(),this._idxRecord=e}get recordIndex(){return this._idxRecord}}_registerModule("wijmo.grid.multirow",selfModule); | ||
import{Row,MergeManager,GroupRow,CellRange,CellType,FlexGrid,_AddNewHandler,_NewRowTemplate,Column,SelectionMode,ColumnCollection}from"@grapecity/wijmo.grid";import{assert,Key,copy,asInt,Event,CancelEventArgs,addClass,createElement,asArray,asBoolean,getType,toggleClass,isFunction,NotifyCollectionChangedAction,hasItems,isString,isBoolean,isArray,toHeaderCase,_registerModule}from"@grapecity/wijmo";import*as selfModule from"@grapecity/wijmo.grid.multirow";export class _Cell extends Column{constructor(e){super(),this._row=this._col=0,this._rowspan=this._colspan=1,e&©(this,e)}get colspan(){return this._colspan}set colspan(e){this._colspan=asInt(e,!1,!0),assert(this._colspan>0,"colspan must be >= 1")}get rowspan(){return this._rowspan}set rowspan(e){this._rowspan=asInt(e,!1,!0),assert(this._rowspan>0,"colspan must be >= 1")}};export class _MultiRow extends Row{constructor(e,t,l){super(e),this._idxData=t,this._idxRecord=l}get recordIndex(){return this._idxRecord}get dataIndex(){return this._idxData}};export class _CellGroup extends _Cell{constructor(e,t){if(super(),this._colstart=0,this._g=e,t&©(this,t),!this._cells)throw"Cell group with no cells?";let l=0,s=0,o=0,r=1,n=0;this._cells.forEach((e,t)=>{if(s>0&&s+e.colspan>this._colspan){for(let e=o;e<t;e++)this._cells[e].rowspan=r;l+=r,s=0,o=t,r=e.rowspan}e._row=l,e._col=s,s+=e.colspan,r=Math.max(r,e.rowspan),n+=e.colspan}),this._rowspan=l+1,this._colspan>n&&(this._colspan=n);for(let e=0;e<this._cells.length;e++){let t=this._cells[e];(e==this._cells.length-1||this._cells[e+1]._row>t._row)&&(s=t._col,t._colspan=this._colspan-s)}}_copy(e,t){return"cells"==e&&(this._cells=[],isArray(t)&&t.forEach(e=>{let t=new _Cell(e);!e.header&&t.binding&&(t.header=toHeaderCase(t.binding)),this._cells.push(t),this._colspan=Math.max(this._colspan,t.colspan)}),!0)}get cells(){return this._cells}closeGroup(e){if(e>this._rowspan){for(let t=0;t<this._cells.length;t++){let l=this._cells[t];l._row==this._rowspan-1&&(l._rowspan=e-l._row)}this._rowspan=e}this._cols=new ColumnCollection(this._g,this._g.columns.defaultSize),this._rng=new Array(e*this._colspan);for(let e=0;e<this._cells.length;e++){let t=this._cells[e];for(let e=0;e<t._rowspan;e++)for(let l=0;l<t._colspan;l++){let s=(t._row+e)*this._colspan+t._col+l;this._cols.setAt(s,t);let o=new CellRange(0-e,0-l,0-e+t._rowspan-1,0-l+t._colspan-1);o.isSingleCell||(this._rng[s]=o)}}this._rng[-1]=new CellRange(0,this._colstart,0,this._colstart+this._colspan-1)}getColumnWidth(e){for(let t=0;t<this._cells.length;t++){let l=this._cells[t];if(l._col==e&&1==l.colspan)return l.width}return null}getMergedRange(e,t,l){if(t<0)return this._rng[-1];let s=e.rows[t],o=null!=s.recordIndex?s.recordIndex:t%this._rowspan,r=l-this._colstart,n=this._rng[o*this._colspan+r];return e.cellType==CellType.ColumnHeader&&t++,n?new CellRange(t+n.row,l+n.col,t+n.row2,l+n.col2):null}getBindingColumn(e,t,l){if(t<0)return this;let s=e.rows[t],o=s&&null!=s.recordIndex?s.recordIndex:t%this._rowspan,r=l-this._colstart;return this._cols[o*this._colspan+r]}getColumn(e){return this._cols.getColumn(e)}};export class _MergeManager extends MergeManager{getMergedRange(e,t,l,s=!0){let o=e.grid;switch(e.cellType){case CellType.Cell:case CellType.RowHeader:if(e.rows[t]instanceof GroupRow)return super.getMergedRange(e,t,l,s)}switch(e.cellType){case CellType.Cell:case CellType.ColumnHeader:let s=o._cellGroupsByColumn[l];assert(s instanceof _CellGroup,"Failed to get the group!");let r=e.cellType==CellType.ColumnHeader?s.getMergedRange(e,t-1,l):s.getMergedRange(e,t,l),n=e.columns.frozen;n&&r&&r.columnSpan>1&&r.col<n&&r.col2>=n&&(r=r.clone(),l<n?r.col2=n-1:r.col=n);let i=e.rows.frozen;return i&&r&&r.rowSpan>1&&e.cellType==CellType.Cell&&r.row<i&&r.row2>=i&&(r=r.clone(),t<i?r.row2=i-1:r.row=i),r;case CellType.RowHeader:let a=o._rowsPerItem,d=t-e.rows[t].recordIndex,h=Math.min(d+a-1,e.rows.length-1);return new CellRange(d,0,h,e.columns.length-1);case CellType.TopLeft:return new CellRange(0,0,e.rows.length-1,e.columns.length-1)}return null}};export class MultiRow extends FlexGrid{constructor(e,t){super(e),this._rowsPerItem=1,this._cellBindingGroups=[],this._centerVert=!0,this._collapsedHeaders=!1,this.collapsedHeadersChanging=new Event,this.collapsedHeadersChanged=new Event,addClass(this.hostElement,"wj-multirow");let l=this.columnHeaders.hostElement.parentElement,s=createElement('<div class="wj-hdr-collapse"><span></span></div>');s.style.display="none",l.appendChild(s),this._btnCollapse=s,this._updateButtonGlyph(),this.addEventListener(s,"mousedown",e=>{switch(this.collapsedHeaders){case null:case!1:this._collapsedHeadersWasNull=null==this.collapsedHeaders,this.collapsedHeaders=!0;break;case!0:this.collapsedHeaders=!!this._collapsedHeadersWasNull&&null}e.preventDefault(),this.focus()},!0),this.autoGenerateColumns=!1,this.mergeManager=new _MergeManager(this);let o=this.hostElement;this.removeEventListener(o,"dragover"),this.removeEventListener(o,"dragleave"),this.removeEventListener(o,"dragdrop"),this._addHdl=new _MultiRowAddNewHandler(this),this.formatItem.addHandler(this._formatItem,this),this.addEventListener(this.rowHeaders.hostElement,"click",e=>{if(!e.defaultPrevented&&this.selectionMode!=SelectionMode.None){let t=this.hitTest(e);if(t.panel==this.rowHeaders&&t.row>-1){let t=this.selection,l=this.rows[t.topRow],s=this.selectionMode!=SelectionMode.Row?this.rows[t.bottomRow]:l;if(l&&null!=l.recordIndex){let o=l.index-l.recordIndex,r=s.index-s.recordIndex+this.rowsPerItem-1,n=this.columns.length-1,i=t.row!=t.topRow?new CellRange(r,0,o,n):new CellRange(o,0,r,n);this.select(i),e.preventDefault()}}}},!0),this.initialize(t)}_getProductInfo(){return"H87K,MultiRow"}get layoutDefinition(){return this._layoutDef}set layoutDefinition(e){this._layoutDef=asArray(e),this._rowsPerItem=1,this._cellBindingGroups=this._parseCellGroups(this._layoutDef),this._cellBindingGroups.forEach(e=>{this._rowsPerItem=Math.max(this._rowsPerItem,e._rowspan)}),this._bindGrid(!0)}get rowsPerItem(){return this._rowsPerItem}getBindingColumn(e,t,l){return this._getBindingColumn(e,t,e.columns[l])}getColumn(e){if(isString(e)){let t=this._cellBindingGroups,l=null;for(let s=0;s<t.length&&!l;s++)l=t[s].getColumn(e);return l}return super.getColumn(e)}get centerHeadersVertically(){return this._centerVert}set centerHeadersVertically(e){e!=this._centerVert&&(this._centerVert=asBoolean(e),this.invalidate())}get collapsedHeaders(){return this._collapsedHeaders}set collapsedHeaders(e){if(e!=this._collapsedHeaders){let t=new CancelEventArgs;this.onCollapsedHeadersChanging(t)&&(this._collapsedHeaders=asBoolean(e,!0),this._updateCollapsedHeaders(),this._updateButtonGlyph(),this.onCollapsedHeadersChanged(t))}}get showHeaderCollapseButton(){return""==this._btnCollapse.style.display}set showHeaderCollapseButton(e){e!=this.showHeaderCollapseButton&&(this._btnCollapse.style.display=asBoolean(e)?"":"none")}onCollapsedHeadersChanging(e){return this.collapsedHeadersChanging.raise(this,e),!e.cancel}onCollapsedHeadersChanged(e){this.collapsedHeadersChanged.raise(this,e)}_getQuickAutoSize(){return isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter}_addBoundRow(e,t){let l=e[t];for(let e=0;e<this._rowsPerItem;e++)this.rows.push(new _MultiRow(l,t,e))}_addNode(e,t,l){this._addBoundRow(e,t)}_bindColumns(){let e=this.columnHeaders.rows,t=this._rowsPerItem+1;for(;e.length>t;)e.removeAt(e.length-1);for(;e.length<t;)e.push(new Row);this._updateCollapsedHeaders(),this.columns.clear(),this._cellGroupsByColumn={};let l=null,s=this.collectionView;if(s&&s.sourceCollection&&s.sourceCollection.length&&(l=s.sourceCollection[0]),this._cellBindingGroups)for(let e=0;e<this._cellBindingGroups.length;e++){let t=this._cellBindingGroups[e];for(let e=0;e<t._colspan;e++){this._cellGroupsByColumn[this.columns.length]=t;let l=new Column;for(let s=0;s<t.cells.length;s++){let o=t.cells[s],r="width,binding,header,format,dataMap,name,aggregate".split(",");if(o._col==e){r.forEach(e=>{null!=o[e]&&(l[e]=o[e])});break}}this.columns.push(l)}}}_updateCollapsedHeaders(){let e=this.columnHeaders.rows,t=this.collapsedHeaders;e[0].visible=0!=t;for(let l=1;l<e.length;l++)e[l].visible=1!=t}_updateColumnTypes(){super._updateColumnTypes();let e=this.collectionView;if(hasItems(e)){let t=e.items[0];for(let e=0;e<this._cellBindingGroups.length;e++){let l=this._cellBindingGroups[e];for(let e=0;e<l._cols.length;e++){let s=l._cols[e];null==s.dataType&&s._binding&&(s.dataType=getType(s._binding.getValue(t)))}}}}_getBindingColumn(e,t,l){if(e==this.cells||e==this.columnHeaders){let s=this._cellGroupsByColumn[l.index];e==this.columnHeaders&&t--,l=s.getBindingColumn(e,t,l.index)}return l}_cvCollectionChanged(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{let e=NotifyCollectionChangedAction;switch(t.action){case e.Change:this.invalidate();break;case e.Add:if(t.index==this.collectionView.items.length-1){let e=this.rows.length;for(;e>0&&this.rows[e-1]instanceof _NewRowTemplate;)e--;for(let l=0;l<this._rowsPerItem;l++)this.rows.insert(e+l,new _MultiRow(t.item,t.index,l));return}assert(!1,"added item should be the last one.");break;default:this._bindGrid(!1)}}}_parseCellGroups(e){let t=[],l=1;if(e){for(let s=0,o=0;s<e.length;s++){let r=new _CellGroup(this,e[s]);r._colstart=o,o+=r._colspan,l=Math.max(l,r._rowspan),t.push(r)}for(let e=0;e<t.length;e++)t[e].closeGroup(l)}return t}_formatItem(e,t){let l=this._rowsPerItem,s=t.panel.cellType,o=t.panel.rows[t.range.row],r=t.panel.rows[t.range.row2],n=t.cell;if(s==CellType.ColumnHeader&&toggleClass(n,"wj-group-header",0==t.range.row),s==CellType.Cell||s==CellType.ColumnHeader){let e=this._cellGroupsByColumn[t.col];assert(e instanceof _CellGroup,"Failed to get the group!"),toggleClass(n,"wj-group-start",e._colstart==t.range.col),toggleClass(n,"wj-group-end",e._colstart+e._colspan-1==t.range.col2)}l>1&&(s!=CellType.Cell&&s!=CellType.RowHeader||(toggleClass(n,"wj-record-start",o instanceof _MultiRow&&0==o.recordIndex),toggleClass(n,"wj-record-end",r instanceof _MultiRow&&r.recordIndex==l-1)));let i=this.alternatingRowStep;if(i){let e=!1;o instanceof _MultiRow&&(e=o.dataIndex%(i+1)==0,1==i&&(e=!e)),toggleClass(n,"wj-alt",e)}if(this._centerVert&&!n.getAttribute("wj-state-measuring")){let e=!1;if(n.innerHTML&&t.range.rowSpan>1)if(e=!0,0==n.childElementCount)n.innerHTML="<div>"+n.innerHTML+"</div>";else{let e=document.createElement("div"),t=document.createRange();t.selectNodeContents(n),t.surroundContents(e)}toggleClass(n,"wj-center-vert",e)}}_updateButtonGlyph(){let e=this._btnCollapse.querySelector("span");e instanceof HTMLElement&&(e.className=this.collapsedHeaders?"wj-glyph-left":"wj-glyph-down-left")}_getError(e,t,l){if(isFunction(this.itemValidator)&&e==this.rowHeaders)for(let e=0;e<this._rowsPerItem;e++)for(l=0;l<this.columns.length;l++){let s=this.itemValidator(t+e,l);if(s)return s}return super._getError(e,t,l)}};export class _MultiRowAddNewHandler extends _AddNewHandler{constructor(e){e._addHdl._detach(),super(e)}updateNewRowTemplate(){let e=this._g.editableCollectionView,t=this._g,l=t.rows,s=e&&e.canAddNew&&t.allowAddNew&&!t.isReadOnly,o=-1;for(let e=0;e<l.length;e+=t.rowsPerItem)if(l[e]instanceof _MultiRowNewRowTemplate){o=e;break}if(s&&o>-1&&(this._top&&o>0||!this._top&&0==o)&&(o=-1,this._removeNewRowTemplate()),s&&o<0)for(let e=0;e<t.rowsPerItem;e++){let t=new _MultiRowNewRowTemplate(e);this._top?l.insert(e,t):l.push(t)}!s&&o>-1&&this._removeNewRowTemplate()}_keydown(e){super._keydown(e),e.defaultPrevented||e.keyCode!=Key.Escape||this._copyNewDataItem()}_rowEditEnded(e,t){super._rowEditEnded(e,t),this._copyNewDataItem()}_beginningEdit(e,t){super._beginningEdit(e,t),this._top&&!e.rows[0].dataItem&&this._copyNewDataItem()}_copyNewDataItem(){if(this._top){let e=this._g,t=e.rows;for(let l=0;l<e.rowsPerItem;l++)t[l]instanceof _NewRowTemplate&&(t[l].dataItem=this._nrt.dataItem)}}_removeNewRowTemplate(){for(let e=0,t=this._g.rows;e<t.length;e++)t[e]instanceof _NewRowTemplate&&(t.removeAt(e),e--)}};class _MultiRowNewRowTemplate extends _NewRowTemplate{constructor(e){super(),this._idxRecord=e}get recordIndex(){return this._idxRecord}}_registerModule("wijmo.grid.multirow",selfModule); |
@@ -1,14 +0,1 @@ | ||
/*! | ||
* | ||
* Wijmo Library 5.20183.595-nightly.d20190405.t210807 | ||
* 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/ | ||
* | ||
*/ | ||
var __extends=this&&this.__extends||function(){var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])})(t,o)};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}();import{Row,MergeManager,GroupRow,CellRange,CellType,FlexGrid,_AddNewHandler,_NewRowTemplate,Column,SelectionMode,ColumnCollection}from"@grapecity/wijmo.grid";import{assert,Key,copy,asInt,Event,CancelEventArgs,addClass,createElement,asArray,asBoolean,getType,toggleClass,isFunction,NotifyCollectionChangedAction,hasItems,isString,isBoolean,isArray,toHeaderCase,_registerModule}from"@grapecity/wijmo";import*as selfModule from"@grapecity/wijmo.grid.multirow";var _Cell=function(e){function t(t){var o=e.call(this)||this;return o._row=o._col=0,o._rowspan=o._colspan=1,t&©(o,t),o}return __extends(t,e),Object.defineProperty(t.prototype,"colspan",{get:function(){return this._colspan},set:function(e){this._colspan=asInt(e,!1,!0),assert(this._colspan>0,"colspan must be >= 1")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowspan",{get:function(){return this._rowspan},set:function(e){this._rowspan=asInt(e,!1,!0),assert(this._rowspan>0,"colspan must be >= 1")},enumerable:!0,configurable:!0}),t}(Column);export{_Cell};var _MultiRow=function(e){function t(t,o,r){var n=e.call(this,t)||this;return n._idxData=o,n._idxRecord=r,n}return __extends(t,e),Object.defineProperty(t.prototype,"recordIndex",{get:function(){return this._idxRecord},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataIndex",{get:function(){return this._idxData},enumerable:!0,configurable:!0}),t}(Row);export{_MultiRow};var _CellGroup=function(e){function t(t,o){var r=e.call(this)||this;if(r._colstart=0,r._g=t,o&©(r,o),!r._cells)throw"Cell group with no cells?";var n=0,l=0,s=0,a=1,i=0;r._cells.forEach(function(e,t){if(l>0&&l+e.colspan>r._colspan){for(var o=s;o<t;o++)r._cells[o].rowspan=a;n+=a,l=0,s=t,a=e.rowspan}e._row=n,e._col=l,l+=e.colspan,a=Math.max(a,e.rowspan),i+=e.colspan}),r._rowspan=n+1,r._colspan>i&&(r._colspan=i);for(var c=0;c<r._cells.length;c++){var p=r._cells[c];(c==r._cells.length-1||r._cells[c+1]._row>p._row)&&(l=p._col,p._colspan=r._colspan-l)}return r}return __extends(t,e),t.prototype._copy=function(e,t){var o=this;return"cells"==e&&(this._cells=[],isArray(t)&&t.forEach(function(e){var t=new _Cell(e);!e.header&&t.binding&&(t.header=toHeaderCase(t.binding)),o._cells.push(t),o._colspan=Math.max(o._colspan,t.colspan)}),!0)},Object.defineProperty(t.prototype,"cells",{get:function(){return this._cells},enumerable:!0,configurable:!0}),t.prototype.closeGroup=function(e){if(e>this._rowspan){for(var t=0;t<this._cells.length;t++){(o=this._cells[t])._row==this._rowspan-1&&(o._rowspan=e-o._row)}this._rowspan=e}this._cols=new ColumnCollection(this._g,this._g.columns.defaultSize),this._rng=new Array(e*this._colspan);for(t=0;t<this._cells.length;t++)for(var o=this._cells[t],r=0;r<o._rowspan;r++)for(var n=0;n<o._colspan;n++){var l=(o._row+r)*this._colspan+o._col+n;this._cols.setAt(l,o);var s=new CellRange(0-r,0-n,0-r+o._rowspan-1,0-n+o._colspan-1);s.isSingleCell||(this._rng[l]=s)}this._rng[-1]=new CellRange(0,this._colstart,0,this._colstart+this._colspan-1)},t.prototype.getColumnWidth=function(e){for(var t=0;t<this._cells.length;t++){var o=this._cells[t];if(o._col==e&&1==o.colspan)return o.width}return null},t.prototype.getMergedRange=function(e,t,o){if(t<0)return this._rng[-1];var r=e.rows[t],n=null!=r.recordIndex?r.recordIndex:t%this._rowspan,l=o-this._colstart,s=this._rng[n*this._colspan+l];return e.cellType==CellType.ColumnHeader&&t++,s?new CellRange(t+s.row,o+s.col,t+s.row2,o+s.col2):null},t.prototype.getBindingColumn=function(e,t,o){if(t<0)return this;var r=e.rows[t],n=r&&null!=r.recordIndex?r.recordIndex:t%this._rowspan,l=o-this._colstart;return this._cols[n*this._colspan+l]},t.prototype.getColumn=function(e){return this._cols.getColumn(e)},t}(_Cell);export{_CellGroup};var _MergeManager=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.getMergedRange=function(t,o,r,n){void 0===n&&(n=!0);var l=t.grid;switch(t.cellType){case CellType.Cell:case CellType.RowHeader:if(t.rows[o]instanceof GroupRow)return e.prototype.getMergedRange.call(this,t,o,r,n)}switch(t.cellType){case CellType.Cell:case CellType.ColumnHeader:var s=l._cellGroupsByColumn[r];assert(s instanceof _CellGroup,"Failed to get the group!");var a=t.cellType==CellType.ColumnHeader?s.getMergedRange(t,o-1,r):s.getMergedRange(t,o,r),i=t.columns.frozen;i&&a&&a.columnSpan>1&&a.col<i&&a.col2>=i&&(a=a.clone(),r<i?a.col2=i-1:a.col=i);var c=t.rows.frozen;return c&&a&&a.rowSpan>1&&t.cellType==CellType.Cell&&a.row<c&&a.row2>=c&&(a=a.clone(),o<c?a.row2=c-1:a.row=c),a;case CellType.RowHeader:var p=l._rowsPerItem,u=o-t.rows[o].recordIndex,d=Math.min(u+p-1,t.rows.length-1);return new CellRange(u,0,d,t.columns.length-1);case CellType.TopLeft:return new CellRange(0,0,t.rows.length-1,t.columns.length-1)}return null},t}(MergeManager);export{_MergeManager};var MultiRow=function(e){function t(t,o){var r=e.call(this,t)||this;r._rowsPerItem=1,r._cellBindingGroups=[],r._centerVert=!0,r._collapsedHeaders=!1,r.collapsedHeadersChanging=new Event,r.collapsedHeadersChanged=new Event,addClass(r.hostElement,"wj-multirow");var n=r.columnHeaders.hostElement.parentElement,l=createElement('<div class="wj-hdr-collapse"><span></span></div>');l.style.display="none",n.appendChild(l),r._btnCollapse=l,r._updateButtonGlyph(),r.addEventListener(l,"mousedown",function(e){switch(r.collapsedHeaders){case null:case!1:r._collapsedHeadersWasNull=null==r.collapsedHeaders,r.collapsedHeaders=!0;break;case!0:r.collapsedHeaders=!!r._collapsedHeadersWasNull&&null}e.preventDefault(),r.focus()},!0),r.autoGenerateColumns=!1,r.mergeManager=new _MergeManager(r);var s=r.hostElement;return r.removeEventListener(s,"dragover"),r.removeEventListener(s,"dragleave"),r.removeEventListener(s,"dragdrop"),r._addHdl=new _MultiRowAddNewHandler(r),r.formatItem.addHandler(r._formatItem,r),r.addEventListener(r.rowHeaders.hostElement,"click",function(e){if(!e.defaultPrevented&&r.selectionMode!=SelectionMode.None){var t=r.hitTest(e);if(t.panel==r.rowHeaders&&t.row>-1){var o=r.selection,n=r.rows[o.topRow],l=r.selectionMode!=SelectionMode.Row?r.rows[o.bottomRow]:n;if(n&&null!=n.recordIndex){var s=n.index-n.recordIndex,a=l.index-l.recordIndex+r.rowsPerItem-1,i=r.columns.length-1,c=o.row!=o.topRow?new CellRange(a,0,s,i):new CellRange(s,0,a,i);r.select(c),e.preventDefault()}}}},!0),r.initialize(o),r}return __extends(t,e),t.prototype._getProductInfo=function(){return"H87K,MultiRow"},Object.defineProperty(t.prototype,"layoutDefinition",{get:function(){return this._layoutDef},set:function(e){var t=this;this._layoutDef=asArray(e),this._rowsPerItem=1,this._cellBindingGroups=this._parseCellGroups(this._layoutDef),this._cellBindingGroups.forEach(function(e){t._rowsPerItem=Math.max(t._rowsPerItem,e._rowspan)}),this._bindGrid(!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowsPerItem",{get:function(){return this._rowsPerItem},enumerable:!0,configurable:!0}),t.prototype.getBindingColumn=function(e,t,o){return this._getBindingColumn(e,t,e.columns[o])},t.prototype.getColumn=function(t){if(isString(t)){for(var o=this._cellBindingGroups,r=null,n=0;n<o.length&&!r;n++)r=o[n].getColumn(t);return r}return e.prototype.getColumn.call(this,t)},Object.defineProperty(t.prototype,"centerHeadersVertically",{get:function(){return this._centerVert},set:function(e){e!=this._centerVert&&(this._centerVert=asBoolean(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collapsedHeaders",{get:function(){return this._collapsedHeaders},set:function(e){if(e!=this._collapsedHeaders){var t=new CancelEventArgs;this.onCollapsedHeadersChanging(t)&&(this._collapsedHeaders=asBoolean(e,!0),this._updateCollapsedHeaders(),this._updateButtonGlyph(),this.onCollapsedHeadersChanged(t))}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showHeaderCollapseButton",{get:function(){return""==this._btnCollapse.style.display},set:function(e){e!=this.showHeaderCollapseButton&&(this._btnCollapse.style.display=asBoolean(e)?"":"none")},enumerable:!0,configurable:!0}),t.prototype.onCollapsedHeadersChanging=function(e){return this.collapsedHeadersChanging.raise(this,e),!e.cancel},t.prototype.onCollapsedHeadersChanged=function(e){this.collapsedHeadersChanged.raise(this,e)},t.prototype._getQuickAutoSize=function(){return isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter},t.prototype._addBoundRow=function(e,t){for(var o=e[t],r=0;r<this._rowsPerItem;r++)this.rows.push(new _MultiRow(o,t,r))},t.prototype._addNode=function(e,t,o){this._addBoundRow(e,t)},t.prototype._bindColumns=function(){for(var e=this.columnHeaders.rows,t=this._rowsPerItem+1;e.length>t;)e.removeAt(e.length-1);for(;e.length<t;)e.push(new Row);this._updateCollapsedHeaders(),this.columns.clear(),this._cellGroupsByColumn={};var o=this.collectionView;if(o&&o.sourceCollection&&o.sourceCollection.length&&o.sourceCollection[0],this._cellBindingGroups)for(var r=0;r<this._cellBindingGroups.length;r++)for(var n=this._cellBindingGroups[r],l=function(e){s._cellGroupsByColumn[s.columns.length]=n;for(var t=new Column,o=function(o){var r=n.cells[o],l="width,binding,header,format,dataMap,name,aggregate".split(",");if(r._col==e)return l.forEach(function(e){null!=r[e]&&(t[e]=r[e])}),"break"},r=0;r<n.cells.length;r++){if("break"===o(r))break}s.columns.push(t)},s=this,a=0;a<n._colspan;a++)l(a)},t.prototype._updateCollapsedHeaders=function(){var e=this.columnHeaders.rows,t=this.collapsedHeaders;e[0].visible=0!=t;for(var o=1;o<e.length;o++)e[o].visible=1!=t},t.prototype._updateColumnTypes=function(){e.prototype._updateColumnTypes.call(this);var t=this.collectionView;if(hasItems(t))for(var o=t.items[0],r=0;r<this._cellBindingGroups.length;r++)for(var n=this._cellBindingGroups[r],l=0;l<n._cols.length;l++){var s=n._cols[l];null==s.dataType&&s._binding&&(s.dataType=getType(s._binding.getValue(o)))}},t.prototype._getBindingColumn=function(e,t,o){if(e==this.cells||e==this.columnHeaders){var r=this._cellGroupsByColumn[o.index];e==this.columnHeaders&&t--,o=r.getBindingColumn(e,t,o.index)}return o},t.prototype._cvCollectionChanged=function(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{var o=NotifyCollectionChangedAction;switch(t.action){case o.Change:this.invalidate();break;case o.Add:if(t.index==this.collectionView.items.length-1){for(var r=this.rows.length;r>0&&this.rows[r-1]instanceof _NewRowTemplate;)r--;for(var n=0;n<this._rowsPerItem;n++)this.rows.insert(r+n,new _MultiRow(t.item,t.index,n));return}assert(!1,"added item should be the last one.");break;default:this._bindGrid(!1)}}},t.prototype._parseCellGroups=function(e){var t=[],o=1;if(e){for(var r=0,n=0;r<e.length;r++){var l=new _CellGroup(this,e[r]);l._colstart=n,n+=l._colspan,o=Math.max(o,l._rowspan),t.push(l)}for(r=0;r<t.length;r++)t[r].closeGroup(o)}return t},t.prototype._formatItem=function(e,t){var o=this._rowsPerItem,r=t.panel.cellType,n=t.panel.rows[t.range.row],l=t.panel.rows[t.range.row2],s=t.cell;if(r==CellType.ColumnHeader&&toggleClass(s,"wj-group-header",0==t.range.row),r==CellType.Cell||r==CellType.ColumnHeader){var a=this._cellGroupsByColumn[t.col];assert(a instanceof _CellGroup,"Failed to get the group!"),toggleClass(s,"wj-group-start",a._colstart==t.range.col),toggleClass(s,"wj-group-end",a._colstart+a._colspan-1==t.range.col2)}o>1&&(r!=CellType.Cell&&r!=CellType.RowHeader||(toggleClass(s,"wj-record-start",n instanceof _MultiRow&&0==n.recordIndex),toggleClass(s,"wj-record-end",l instanceof _MultiRow&&l.recordIndex==o-1)));var i=this.alternatingRowStep;if(i){var c=!1;n instanceof _MultiRow&&(c=n.dataIndex%(i+1)==0,1==i&&(c=!c)),toggleClass(s,"wj-alt",c)}if(this._centerVert&&!s.getAttribute("wj-state-measuring")){var p=!1;if(s.innerHTML&&t.range.rowSpan>1)if(p=!0,0==s.childElementCount)s.innerHTML="<div>"+s.innerHTML+"</div>";else{var u=document.createElement("div"),d=document.createRange();d.selectNodeContents(s),d.surroundContents(u)}toggleClass(s,"wj-center-vert",p)}},t.prototype._updateButtonGlyph=function(){var e=this._btnCollapse.querySelector("span");e instanceof HTMLElement&&(e.className=this.collapsedHeaders?"wj-glyph-left":"wj-glyph-down-left")},t.prototype._getError=function(t,o,r){if(isFunction(this.itemValidator)&&t==this.rowHeaders)for(var n=0;n<this._rowsPerItem;n++)for(r=0;r<this.columns.length;r++){var l=this.itemValidator(o+n,r);if(l)return l}return e.prototype._getError.call(this,t,o,r)},t}(FlexGrid);export{MultiRow};var _MultiRowAddNewHandler=function(e){function t(t){return t._addHdl._detach(),e.call(this,t)||this}return __extends(t,e),t.prototype.updateNewRowTemplate=function(){for(var e=this._g.editableCollectionView,t=this._g,o=t.rows,r=e&&e.canAddNew&&t.allowAddNew&&!t.isReadOnly,n=-1,l=0;l<o.length;l+=t.rowsPerItem)if(o[l]instanceof _MultiRowNewRowTemplate){n=l;break}if(r&&n>-1&&(this._top&&n>0||!this._top&&0==n)&&(n=-1,this._removeNewRowTemplate()),r&&n<0)for(l=0;l<t.rowsPerItem;l++){var s=new _MultiRowNewRowTemplate(l);this._top?o.insert(l,s):o.push(s)}!r&&n>-1&&this._removeNewRowTemplate()},t.prototype._keydown=function(t){e.prototype._keydown.call(this,t),t.defaultPrevented||t.keyCode!=Key.Escape||this._copyNewDataItem()},t.prototype._rowEditEnded=function(t,o){e.prototype._rowEditEnded.call(this,t,o),this._copyNewDataItem()},t.prototype._beginningEdit=function(t,o){e.prototype._beginningEdit.call(this,t,o),this._top&&!t.rows[0].dataItem&&this._copyNewDataItem()},t.prototype._copyNewDataItem=function(){if(this._top)for(var e=this._g,t=e.rows,o=0;o<e.rowsPerItem;o++)t[o]instanceof _NewRowTemplate&&(t[o].dataItem=this._nrt.dataItem)},t.prototype._removeNewRowTemplate=function(){for(var e=0,t=this._g.rows;e<t.length;e++)t[e]instanceof _NewRowTemplate&&(t.removeAt(e),e--)},t}(_AddNewHandler);export{_MultiRowAddNewHandler};var _MultiRowNewRowTemplate=function(e){function t(t){var o=e.call(this)||this;return o._idxRecord=t,o}return __extends(t,e),Object.defineProperty(t.prototype,"recordIndex",{get:function(){return this._idxRecord},enumerable:!0,configurable:!0}),t}(_NewRowTemplate);_registerModule("wijmo.grid.multirow",selfModule); | ||
var __extends=this&&this.__extends||function(){var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])})(t,o)};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}();import{Row,MergeManager,GroupRow,CellRange,CellType,FlexGrid,_AddNewHandler,_NewRowTemplate,Column,SelectionMode,ColumnCollection}from"@grapecity/wijmo.grid";import{assert,Key,copy,asInt,Event,CancelEventArgs,addClass,createElement,asArray,asBoolean,getType,toggleClass,isFunction,NotifyCollectionChangedAction,hasItems,isString,isBoolean,isArray,toHeaderCase,_registerModule}from"@grapecity/wijmo";import*as selfModule from"@grapecity/wijmo.grid.multirow";var _Cell=function(e){function t(t){var o=e.call(this)||this;return o._row=o._col=0,o._rowspan=o._colspan=1,t&©(o,t),o}return __extends(t,e),Object.defineProperty(t.prototype,"colspan",{get:function(){return this._colspan},set:function(e){this._colspan=asInt(e,!1,!0),assert(this._colspan>0,"colspan must be >= 1")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowspan",{get:function(){return this._rowspan},set:function(e){this._rowspan=asInt(e,!1,!0),assert(this._rowspan>0,"colspan must be >= 1")},enumerable:!0,configurable:!0}),t}(Column);export{_Cell};var _MultiRow=function(e){function t(t,o,r){var n=e.call(this,t)||this;return n._idxData=o,n._idxRecord=r,n}return __extends(t,e),Object.defineProperty(t.prototype,"recordIndex",{get:function(){return this._idxRecord},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataIndex",{get:function(){return this._idxData},enumerable:!0,configurable:!0}),t}(Row);export{_MultiRow};var _CellGroup=function(e){function t(t,o){var r=e.call(this)||this;if(r._colstart=0,r._g=t,o&©(r,o),!r._cells)throw"Cell group with no cells?";var n=0,l=0,s=0,a=1,i=0;r._cells.forEach(function(e,t){if(l>0&&l+e.colspan>r._colspan){for(var o=s;o<t;o++)r._cells[o].rowspan=a;n+=a,l=0,s=t,a=e.rowspan}e._row=n,e._col=l,l+=e.colspan,a=Math.max(a,e.rowspan),i+=e.colspan}),r._rowspan=n+1,r._colspan>i&&(r._colspan=i);for(var c=0;c<r._cells.length;c++){var p=r._cells[c];(c==r._cells.length-1||r._cells[c+1]._row>p._row)&&(l=p._col,p._colspan=r._colspan-l)}return r}return __extends(t,e),t.prototype._copy=function(e,t){var o=this;return"cells"==e&&(this._cells=[],isArray(t)&&t.forEach(function(e){var t=new _Cell(e);!e.header&&t.binding&&(t.header=toHeaderCase(t.binding)),o._cells.push(t),o._colspan=Math.max(o._colspan,t.colspan)}),!0)},Object.defineProperty(t.prototype,"cells",{get:function(){return this._cells},enumerable:!0,configurable:!0}),t.prototype.closeGroup=function(e){if(e>this._rowspan){for(var t=0;t<this._cells.length;t++){(o=this._cells[t])._row==this._rowspan-1&&(o._rowspan=e-o._row)}this._rowspan=e}this._cols=new ColumnCollection(this._g,this._g.columns.defaultSize),this._rng=new Array(e*this._colspan);for(t=0;t<this._cells.length;t++)for(var o=this._cells[t],r=0;r<o._rowspan;r++)for(var n=0;n<o._colspan;n++){var l=(o._row+r)*this._colspan+o._col+n;this._cols.setAt(l,o);var s=new CellRange(0-r,0-n,0-r+o._rowspan-1,0-n+o._colspan-1);s.isSingleCell||(this._rng[l]=s)}this._rng[-1]=new CellRange(0,this._colstart,0,this._colstart+this._colspan-1)},t.prototype.getColumnWidth=function(e){for(var t=0;t<this._cells.length;t++){var o=this._cells[t];if(o._col==e&&1==o.colspan)return o.width}return null},t.prototype.getMergedRange=function(e,t,o){if(t<0)return this._rng[-1];var r=e.rows[t],n=null!=r.recordIndex?r.recordIndex:t%this._rowspan,l=o-this._colstart,s=this._rng[n*this._colspan+l];return e.cellType==CellType.ColumnHeader&&t++,s?new CellRange(t+s.row,o+s.col,t+s.row2,o+s.col2):null},t.prototype.getBindingColumn=function(e,t,o){if(t<0)return this;var r=e.rows[t],n=r&&null!=r.recordIndex?r.recordIndex:t%this._rowspan,l=o-this._colstart;return this._cols[n*this._colspan+l]},t.prototype.getColumn=function(e){return this._cols.getColumn(e)},t}(_Cell);export{_CellGroup};var _MergeManager=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.getMergedRange=function(t,o,r,n){void 0===n&&(n=!0);var l=t.grid;switch(t.cellType){case CellType.Cell:case CellType.RowHeader:if(t.rows[o]instanceof GroupRow)return e.prototype.getMergedRange.call(this,t,o,r,n)}switch(t.cellType){case CellType.Cell:case CellType.ColumnHeader:var s=l._cellGroupsByColumn[r];assert(s instanceof _CellGroup,"Failed to get the group!");var a=t.cellType==CellType.ColumnHeader?s.getMergedRange(t,o-1,r):s.getMergedRange(t,o,r),i=t.columns.frozen;i&&a&&a.columnSpan>1&&a.col<i&&a.col2>=i&&(a=a.clone(),r<i?a.col2=i-1:a.col=i);var c=t.rows.frozen;return c&&a&&a.rowSpan>1&&t.cellType==CellType.Cell&&a.row<c&&a.row2>=c&&(a=a.clone(),o<c?a.row2=c-1:a.row=c),a;case CellType.RowHeader:var p=l._rowsPerItem,u=o-t.rows[o].recordIndex,d=Math.min(u+p-1,t.rows.length-1);return new CellRange(u,0,d,t.columns.length-1);case CellType.TopLeft:return new CellRange(0,0,t.rows.length-1,t.columns.length-1)}return null},t}(MergeManager);export{_MergeManager};var MultiRow=function(e){function t(t,o){var r=e.call(this,t)||this;r._rowsPerItem=1,r._cellBindingGroups=[],r._centerVert=!0,r._collapsedHeaders=!1,r.collapsedHeadersChanging=new Event,r.collapsedHeadersChanged=new Event,addClass(r.hostElement,"wj-multirow");var n=r.columnHeaders.hostElement.parentElement,l=createElement('<div class="wj-hdr-collapse"><span></span></div>');l.style.display="none",n.appendChild(l),r._btnCollapse=l,r._updateButtonGlyph(),r.addEventListener(l,"mousedown",function(e){switch(r.collapsedHeaders){case null:case!1:r._collapsedHeadersWasNull=null==r.collapsedHeaders,r.collapsedHeaders=!0;break;case!0:r.collapsedHeaders=!!r._collapsedHeadersWasNull&&null}e.preventDefault(),r.focus()},!0),r.autoGenerateColumns=!1,r.mergeManager=new _MergeManager(r);var s=r.hostElement;return r.removeEventListener(s,"dragover"),r.removeEventListener(s,"dragleave"),r.removeEventListener(s,"dragdrop"),r._addHdl=new _MultiRowAddNewHandler(r),r.formatItem.addHandler(r._formatItem,r),r.addEventListener(r.rowHeaders.hostElement,"click",function(e){if(!e.defaultPrevented&&r.selectionMode!=SelectionMode.None){var t=r.hitTest(e);if(t.panel==r.rowHeaders&&t.row>-1){var o=r.selection,n=r.rows[o.topRow],l=r.selectionMode!=SelectionMode.Row?r.rows[o.bottomRow]:n;if(n&&null!=n.recordIndex){var s=n.index-n.recordIndex,a=l.index-l.recordIndex+r.rowsPerItem-1,i=r.columns.length-1,c=o.row!=o.topRow?new CellRange(a,0,s,i):new CellRange(s,0,a,i);r.select(c),e.preventDefault()}}}},!0),r.initialize(o),r}return __extends(t,e),t.prototype._getProductInfo=function(){return"H87K,MultiRow"},Object.defineProperty(t.prototype,"layoutDefinition",{get:function(){return this._layoutDef},set:function(e){var t=this;this._layoutDef=asArray(e),this._rowsPerItem=1,this._cellBindingGroups=this._parseCellGroups(this._layoutDef),this._cellBindingGroups.forEach(function(e){t._rowsPerItem=Math.max(t._rowsPerItem,e._rowspan)}),this._bindGrid(!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowsPerItem",{get:function(){return this._rowsPerItem},enumerable:!0,configurable:!0}),t.prototype.getBindingColumn=function(e,t,o){return this._getBindingColumn(e,t,e.columns[o])},t.prototype.getColumn=function(t){if(isString(t)){for(var o=this._cellBindingGroups,r=null,n=0;n<o.length&&!r;n++)r=o[n].getColumn(t);return r}return e.prototype.getColumn.call(this,t)},Object.defineProperty(t.prototype,"centerHeadersVertically",{get:function(){return this._centerVert},set:function(e){e!=this._centerVert&&(this._centerVert=asBoolean(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collapsedHeaders",{get:function(){return this._collapsedHeaders},set:function(e){if(e!=this._collapsedHeaders){var t=new CancelEventArgs;this.onCollapsedHeadersChanging(t)&&(this._collapsedHeaders=asBoolean(e,!0),this._updateCollapsedHeaders(),this._updateButtonGlyph(),this.onCollapsedHeadersChanged(t))}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showHeaderCollapseButton",{get:function(){return""==this._btnCollapse.style.display},set:function(e){e!=this.showHeaderCollapseButton&&(this._btnCollapse.style.display=asBoolean(e)?"":"none")},enumerable:!0,configurable:!0}),t.prototype.onCollapsedHeadersChanging=function(e){return this.collapsedHeadersChanging.raise(this,e),!e.cancel},t.prototype.onCollapsedHeadersChanged=function(e){this.collapsedHeadersChanged.raise(this,e)},t.prototype._getQuickAutoSize=function(){return isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter},t.prototype._addBoundRow=function(e,t){for(var o=e[t],r=0;r<this._rowsPerItem;r++)this.rows.push(new _MultiRow(o,t,r))},t.prototype._addNode=function(e,t,o){this._addBoundRow(e,t)},t.prototype._bindColumns=function(){for(var e=this.columnHeaders.rows,t=this._rowsPerItem+1;e.length>t;)e.removeAt(e.length-1);for(;e.length<t;)e.push(new Row);this._updateCollapsedHeaders(),this.columns.clear(),this._cellGroupsByColumn={};var o=this.collectionView;if(o&&o.sourceCollection&&o.sourceCollection.length&&o.sourceCollection[0],this._cellBindingGroups)for(var r=0;r<this._cellBindingGroups.length;r++)for(var n=this._cellBindingGroups[r],l=function(e){s._cellGroupsByColumn[s.columns.length]=n;for(var t=new Column,o=function(o){var r=n.cells[o],l="width,binding,header,format,dataMap,name,aggregate".split(",");if(r._col==e)return l.forEach(function(e){null!=r[e]&&(t[e]=r[e])}),"break"},r=0;r<n.cells.length;r++){if("break"===o(r))break}s.columns.push(t)},s=this,a=0;a<n._colspan;a++)l(a)},t.prototype._updateCollapsedHeaders=function(){var e=this.columnHeaders.rows,t=this.collapsedHeaders;e[0].visible=0!=t;for(var o=1;o<e.length;o++)e[o].visible=1!=t},t.prototype._updateColumnTypes=function(){e.prototype._updateColumnTypes.call(this);var t=this.collectionView;if(hasItems(t))for(var o=t.items[0],r=0;r<this._cellBindingGroups.length;r++)for(var n=this._cellBindingGroups[r],l=0;l<n._cols.length;l++){var s=n._cols[l];null==s.dataType&&s._binding&&(s.dataType=getType(s._binding.getValue(o)))}},t.prototype._getBindingColumn=function(e,t,o){if(e==this.cells||e==this.columnHeaders){var r=this._cellGroupsByColumn[o.index];e==this.columnHeaders&&t--,o=r.getBindingColumn(e,t,o.index)}return o},t.prototype._cvCollectionChanged=function(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{var o=NotifyCollectionChangedAction;switch(t.action){case o.Change:this.invalidate();break;case o.Add:if(t.index==this.collectionView.items.length-1){for(var r=this.rows.length;r>0&&this.rows[r-1]instanceof _NewRowTemplate;)r--;for(var n=0;n<this._rowsPerItem;n++)this.rows.insert(r+n,new _MultiRow(t.item,t.index,n));return}assert(!1,"added item should be the last one.");break;default:this._bindGrid(!1)}}},t.prototype._parseCellGroups=function(e){var t=[],o=1;if(e){for(var r=0,n=0;r<e.length;r++){var l=new _CellGroup(this,e[r]);l._colstart=n,n+=l._colspan,o=Math.max(o,l._rowspan),t.push(l)}for(r=0;r<t.length;r++)t[r].closeGroup(o)}return t},t.prototype._formatItem=function(e,t){var o=this._rowsPerItem,r=t.panel.cellType,n=t.panel.rows[t.range.row],l=t.panel.rows[t.range.row2],s=t.cell;if(r==CellType.ColumnHeader&&toggleClass(s,"wj-group-header",0==t.range.row),r==CellType.Cell||r==CellType.ColumnHeader){var a=this._cellGroupsByColumn[t.col];assert(a instanceof _CellGroup,"Failed to get the group!"),toggleClass(s,"wj-group-start",a._colstart==t.range.col),toggleClass(s,"wj-group-end",a._colstart+a._colspan-1==t.range.col2)}o>1&&(r!=CellType.Cell&&r!=CellType.RowHeader||(toggleClass(s,"wj-record-start",n instanceof _MultiRow&&0==n.recordIndex),toggleClass(s,"wj-record-end",l instanceof _MultiRow&&l.recordIndex==o-1)));var i=this.alternatingRowStep;if(i){var c=!1;n instanceof _MultiRow&&(c=n.dataIndex%(i+1)==0,1==i&&(c=!c)),toggleClass(s,"wj-alt",c)}if(this._centerVert&&!s.getAttribute("wj-state-measuring")){var p=!1;if(s.innerHTML&&t.range.rowSpan>1)if(p=!0,0==s.childElementCount)s.innerHTML="<div>"+s.innerHTML+"</div>";else{var u=document.createElement("div"),d=document.createRange();d.selectNodeContents(s),d.surroundContents(u)}toggleClass(s,"wj-center-vert",p)}},t.prototype._updateButtonGlyph=function(){var e=this._btnCollapse.querySelector("span");e instanceof HTMLElement&&(e.className=this.collapsedHeaders?"wj-glyph-left":"wj-glyph-down-left")},t.prototype._getError=function(t,o,r){if(isFunction(this.itemValidator)&&t==this.rowHeaders)for(var n=0;n<this._rowsPerItem;n++)for(r=0;r<this.columns.length;r++){var l=this.itemValidator(o+n,r);if(l)return l}return e.prototype._getError.call(this,t,o,r)},t}(FlexGrid);export{MultiRow};var _MultiRowAddNewHandler=function(e){function t(t){return t._addHdl._detach(),e.call(this,t)||this}return __extends(t,e),t.prototype.updateNewRowTemplate=function(){for(var e=this._g.editableCollectionView,t=this._g,o=t.rows,r=e&&e.canAddNew&&t.allowAddNew&&!t.isReadOnly,n=-1,l=0;l<o.length;l+=t.rowsPerItem)if(o[l]instanceof _MultiRowNewRowTemplate){n=l;break}if(r&&n>-1&&(this._top&&n>0||!this._top&&0==n)&&(n=-1,this._removeNewRowTemplate()),r&&n<0)for(l=0;l<t.rowsPerItem;l++){var s=new _MultiRowNewRowTemplate(l);this._top?o.insert(l,s):o.push(s)}!r&&n>-1&&this._removeNewRowTemplate()},t.prototype._keydown=function(t){e.prototype._keydown.call(this,t),t.defaultPrevented||t.keyCode!=Key.Escape||this._copyNewDataItem()},t.prototype._rowEditEnded=function(t,o){e.prototype._rowEditEnded.call(this,t,o),this._copyNewDataItem()},t.prototype._beginningEdit=function(t,o){e.prototype._beginningEdit.call(this,t,o),this._top&&!t.rows[0].dataItem&&this._copyNewDataItem()},t.prototype._copyNewDataItem=function(){if(this._top)for(var e=this._g,t=e.rows,o=0;o<e.rowsPerItem;o++)t[o]instanceof _NewRowTemplate&&(t[o].dataItem=this._nrt.dataItem)},t.prototype._removeNewRowTemplate=function(){for(var e=0,t=this._g.rows;e<t.length;e++)t[e]instanceof _NewRowTemplate&&(t.removeAt(e),e--)},t}(_AddNewHandler);export{_MultiRowAddNewHandler};var _MultiRowNewRowTemplate=function(e){function t(t){var o=e.call(this)||this;return o._idxRecord=t,o}return __extends(t,e),Object.defineProperty(t.prototype,"recordIndex",{get:function(){return this._idxRecord},enumerable:!0,configurable:!0}),t}(_NewRowTemplate);_registerModule("wijmo.grid.multirow",selfModule); |
@@ -1,13 +0,1 @@ | ||
/*! | ||
* | ||
* Wijmo Library 5.20183.595-nightly.d20190405.t210807 | ||
* 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/ | ||
* | ||
*/ | ||
/** | ||
@@ -14,0 +2,0 @@ * {@module wijmo.grid.multirow} |
15
index.js
@@ -1,14 +0,1 @@ | ||
/*! | ||
* | ||
* Wijmo Library 5.20183.595-nightly.d20190405.t210807 | ||
* 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";var __extends=this&&this.__extends||function(){var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])})(t,o)};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),selfModule=require("@grapecity/wijmo.grid.multirow"),_Cell=function(e){function t(t){var o=e.call(this)||this;return o._row=o._col=0,o._rowspan=o._colspan=1,t&&wijmo_1.copy(o,t),o}return __extends(t,e),Object.defineProperty(t.prototype,"colspan",{get:function(){return this._colspan},set:function(e){this._colspan=wijmo_1.asInt(e,!1,!0),wijmo_1.assert(this._colspan>0,"colspan must be >= 1")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowspan",{get:function(){return this._rowspan},set:function(e){this._rowspan=wijmo_1.asInt(e,!1,!0),wijmo_1.assert(this._rowspan>0,"colspan must be >= 1")},enumerable:!0,configurable:!0}),t}(wijmo_grid_1.Column);exports._Cell=_Cell;var _MultiRow=function(e){function t(t,o,r){var n=e.call(this,t)||this;return n._idxData=o,n._idxRecord=r,n}return __extends(t,e),Object.defineProperty(t.prototype,"recordIndex",{get:function(){return this._idxRecord},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataIndex",{get:function(){return this._idxData},enumerable:!0,configurable:!0}),t}(wijmo_grid_1.Row);exports._MultiRow=_MultiRow;var _CellGroup=function(e){function t(t,o){var r=e.call(this)||this;if(r._colstart=0,r._g=t,o&&wijmo_1.copy(r,o),!r._cells)throw"Cell group with no cells?";var n=0,i=0,l=0,s=1,a=0;r._cells.forEach(function(e,t){if(i>0&&i+e.colspan>r._colspan){for(var o=l;o<t;o++)r._cells[o].rowspan=s;n+=s,i=0,l=t,s=e.rowspan}e._row=n,e._col=i,i+=e.colspan,s=Math.max(s,e.rowspan),a+=e.colspan}),r._rowspan=n+1,r._colspan>a&&(r._colspan=a);for(var c=0;c<r._cells.length;c++){var _=r._cells[c];(c==r._cells.length-1||r._cells[c+1]._row>_._row)&&(i=_._col,_._colspan=r._colspan-i)}return r}return __extends(t,e),t.prototype._copy=function(e,t){var o=this;return"cells"==e&&(this._cells=[],wijmo_1.isArray(t)&&t.forEach(function(e){var t=new _Cell(e);!e.header&&t.binding&&(t.header=wijmo_1.toHeaderCase(t.binding)),o._cells.push(t),o._colspan=Math.max(o._colspan,t.colspan)}),!0)},Object.defineProperty(t.prototype,"cells",{get:function(){return this._cells},enumerable:!0,configurable:!0}),t.prototype.closeGroup=function(e){if(e>this._rowspan){for(var t=0;t<this._cells.length;t++){(o=this._cells[t])._row==this._rowspan-1&&(o._rowspan=e-o._row)}this._rowspan=e}this._cols=new wijmo_grid_1.ColumnCollection(this._g,this._g.columns.defaultSize),this._rng=new Array(e*this._colspan);for(t=0;t<this._cells.length;t++)for(var o=this._cells[t],r=0;r<o._rowspan;r++)for(var n=0;n<o._colspan;n++){var i=(o._row+r)*this._colspan+o._col+n;this._cols.setAt(i,o);var l=new wijmo_grid_1.CellRange(0-r,0-n,0-r+o._rowspan-1,0-n+o._colspan-1);l.isSingleCell||(this._rng[i]=l)}this._rng[-1]=new wijmo_grid_1.CellRange(0,this._colstart,0,this._colstart+this._colspan-1)},t.prototype.getColumnWidth=function(e){for(var t=0;t<this._cells.length;t++){var o=this._cells[t];if(o._col==e&&1==o.colspan)return o.width}return null},t.prototype.getMergedRange=function(e,t,o){if(t<0)return this._rng[-1];var r=e.rows[t],n=null!=r.recordIndex?r.recordIndex:t%this._rowspan,i=o-this._colstart,l=this._rng[n*this._colspan+i];return e.cellType==wijmo_grid_1.CellType.ColumnHeader&&t++,l?new wijmo_grid_1.CellRange(t+l.row,o+l.col,t+l.row2,o+l.col2):null},t.prototype.getBindingColumn=function(e,t,o){if(t<0)return this;var r=e.rows[t],n=r&&null!=r.recordIndex?r.recordIndex:t%this._rowspan,i=o-this._colstart;return this._cols[n*this._colspan+i]},t.prototype.getColumn=function(e){return this._cols.getColumn(e)},t}(_Cell);exports._CellGroup=_CellGroup;var _MergeManager=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.getMergedRange=function(t,o,r,n){void 0===n&&(n=!0);var i=t.grid;switch(t.cellType){case wijmo_grid_1.CellType.Cell:case wijmo_grid_1.CellType.RowHeader:if(t.rows[o]instanceof wijmo_grid_1.GroupRow)return e.prototype.getMergedRange.call(this,t,o,r,n)}switch(t.cellType){case wijmo_grid_1.CellType.Cell:case wijmo_grid_1.CellType.ColumnHeader:var l=i._cellGroupsByColumn[r];wijmo_1.assert(l instanceof _CellGroup,"Failed to get the group!");var s=t.cellType==wijmo_grid_1.CellType.ColumnHeader?l.getMergedRange(t,o-1,r):l.getMergedRange(t,o,r),a=t.columns.frozen;a&&s&&s.columnSpan>1&&s.col<a&&s.col2>=a&&(s=s.clone(),r<a?s.col2=a-1:s.col=a);var c=t.rows.frozen;return c&&s&&s.rowSpan>1&&t.cellType==wijmo_grid_1.CellType.Cell&&s.row<c&&s.row2>=c&&(s=s.clone(),o<c?s.row2=c-1:s.row=c),s;case wijmo_grid_1.CellType.RowHeader:var _=i._rowsPerItem,d=o-t.rows[o].recordIndex,p=Math.min(d+_-1,t.rows.length-1);return new wijmo_grid_1.CellRange(d,0,p,t.columns.length-1);case wijmo_grid_1.CellType.TopLeft:return new wijmo_grid_1.CellRange(0,0,t.rows.length-1,t.columns.length-1)}return null},t}(wijmo_grid_1.MergeManager);exports._MergeManager=_MergeManager;var MultiRow=function(e){function t(t,o){var r=e.call(this,t)||this;r._rowsPerItem=1,r._cellBindingGroups=[],r._centerVert=!0,r._collapsedHeaders=!1,r.collapsedHeadersChanging=new wijmo_1.Event,r.collapsedHeadersChanged=new wijmo_1.Event,wijmo_1.addClass(r.hostElement,"wj-multirow");var n=r.columnHeaders.hostElement.parentElement,i=wijmo_1.createElement('<div class="wj-hdr-collapse"><span></span></div>');i.style.display="none",n.appendChild(i),r._btnCollapse=i,r._updateButtonGlyph(),r.addEventListener(i,"mousedown",function(e){switch(r.collapsedHeaders){case null:case!1:r._collapsedHeadersWasNull=null==r.collapsedHeaders,r.collapsedHeaders=!0;break;case!0:r.collapsedHeaders=!!r._collapsedHeadersWasNull&&null}e.preventDefault(),r.focus()},!0),r.autoGenerateColumns=!1,r.mergeManager=new _MergeManager(r);var l=r.hostElement;return r.removeEventListener(l,"dragover"),r.removeEventListener(l,"dragleave"),r.removeEventListener(l,"dragdrop"),r._addHdl=new _MultiRowAddNewHandler(r),r.formatItem.addHandler(r._formatItem,r),r.addEventListener(r.rowHeaders.hostElement,"click",function(e){if(!e.defaultPrevented&&r.selectionMode!=wijmo_grid_1.SelectionMode.None){var t=r.hitTest(e);if(t.panel==r.rowHeaders&&t.row>-1){var o=r.selection,n=r.rows[o.topRow],i=r.selectionMode!=wijmo_grid_1.SelectionMode.Row?r.rows[o.bottomRow]:n;if(n&&null!=n.recordIndex){var l=n.index-n.recordIndex,s=i.index-i.recordIndex+r.rowsPerItem-1,a=r.columns.length-1,c=o.row!=o.topRow?new wijmo_grid_1.CellRange(s,0,l,a):new wijmo_grid_1.CellRange(l,0,s,a);r.select(c),e.preventDefault()}}}},!0),r.initialize(o),r}return __extends(t,e),t.prototype._getProductInfo=function(){return"H87K,MultiRow"},Object.defineProperty(t.prototype,"layoutDefinition",{get:function(){return this._layoutDef},set:function(e){var t=this;this._layoutDef=wijmo_1.asArray(e),this._rowsPerItem=1,this._cellBindingGroups=this._parseCellGroups(this._layoutDef),this._cellBindingGroups.forEach(function(e){t._rowsPerItem=Math.max(t._rowsPerItem,e._rowspan)}),this._bindGrid(!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowsPerItem",{get:function(){return this._rowsPerItem},enumerable:!0,configurable:!0}),t.prototype.getBindingColumn=function(e,t,o){return this._getBindingColumn(e,t,e.columns[o])},t.prototype.getColumn=function(t){if(wijmo_1.isString(t)){for(var o=this._cellBindingGroups,r=null,n=0;n<o.length&&!r;n++)r=o[n].getColumn(t);return r}return e.prototype.getColumn.call(this,t)},Object.defineProperty(t.prototype,"centerHeadersVertically",{get:function(){return this._centerVert},set:function(e){e!=this._centerVert&&(this._centerVert=wijmo_1.asBoolean(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collapsedHeaders",{get:function(){return this._collapsedHeaders},set:function(e){if(e!=this._collapsedHeaders){var t=new wijmo_1.CancelEventArgs;this.onCollapsedHeadersChanging(t)&&(this._collapsedHeaders=wijmo_1.asBoolean(e,!0),this._updateCollapsedHeaders(),this._updateButtonGlyph(),this.onCollapsedHeadersChanged(t))}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showHeaderCollapseButton",{get:function(){return""==this._btnCollapse.style.display},set:function(e){e!=this.showHeaderCollapseButton&&(this._btnCollapse.style.display=wijmo_1.asBoolean(e)?"":"none")},enumerable:!0,configurable:!0}),t.prototype.onCollapsedHeadersChanging=function(e){return this.collapsedHeadersChanging.raise(this,e),!e.cancel},t.prototype.onCollapsedHeadersChanged=function(e){this.collapsedHeadersChanged.raise(this,e)},t.prototype._getQuickAutoSize=function(){return wijmo_1.isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter},t.prototype._addBoundRow=function(e,t){for(var o=e[t],r=0;r<this._rowsPerItem;r++)this.rows.push(new _MultiRow(o,t,r))},t.prototype._addNode=function(e,t,o){this._addBoundRow(e,t)},t.prototype._bindColumns=function(){for(var e=this.columnHeaders.rows,t=this._rowsPerItem+1;e.length>t;)e.removeAt(e.length-1);for(;e.length<t;)e.push(new wijmo_grid_1.Row);this._updateCollapsedHeaders(),this.columns.clear(),this._cellGroupsByColumn={};var o=this.collectionView;if(o&&o.sourceCollection&&o.sourceCollection.length&&o.sourceCollection[0],this._cellBindingGroups)for(var r=0;r<this._cellBindingGroups.length;r++)for(var n=this._cellBindingGroups[r],i=function(e){l._cellGroupsByColumn[l.columns.length]=n;for(var t=new wijmo_grid_1.Column,o=function(o){var r=n.cells[o],i="width,binding,header,format,dataMap,name,aggregate".split(",");if(r._col==e)return i.forEach(function(e){null!=r[e]&&(t[e]=r[e])}),"break"},r=0;r<n.cells.length;r++){if("break"===o(r))break}l.columns.push(t)},l=this,s=0;s<n._colspan;s++)i(s)},t.prototype._updateCollapsedHeaders=function(){var e=this.columnHeaders.rows,t=this.collapsedHeaders;e[0].visible=0!=t;for(var o=1;o<e.length;o++)e[o].visible=1!=t},t.prototype._updateColumnTypes=function(){e.prototype._updateColumnTypes.call(this);var t=this.collectionView;if(wijmo_1.hasItems(t))for(var o=t.items[0],r=0;r<this._cellBindingGroups.length;r++)for(var n=this._cellBindingGroups[r],i=0;i<n._cols.length;i++){var l=n._cols[i];null==l.dataType&&l._binding&&(l.dataType=wijmo_1.getType(l._binding.getValue(o)))}},t.prototype._getBindingColumn=function(e,t,o){if(e==this.cells||e==this.columnHeaders){var r=this._cellGroupsByColumn[o.index];e==this.columnHeaders&&t--,o=r.getBindingColumn(e,t,o.index)}return o},t.prototype._cvCollectionChanged=function(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{var o=wijmo_1.NotifyCollectionChangedAction;switch(t.action){case o.Change:this.invalidate();break;case o.Add:if(t.index==this.collectionView.items.length-1){for(var r=this.rows.length;r>0&&this.rows[r-1]instanceof wijmo_grid_1._NewRowTemplate;)r--;for(var n=0;n<this._rowsPerItem;n++)this.rows.insert(r+n,new _MultiRow(t.item,t.index,n));return}wijmo_1.assert(!1,"added item should be the last one.");break;default:this._bindGrid(!1)}}},t.prototype._parseCellGroups=function(e){var t=[],o=1;if(e){for(var r=0,n=0;r<e.length;r++){var i=new _CellGroup(this,e[r]);i._colstart=n,n+=i._colspan,o=Math.max(o,i._rowspan),t.push(i)}for(r=0;r<t.length;r++)t[r].closeGroup(o)}return t},t.prototype._formatItem=function(e,t){var o=this._rowsPerItem,r=t.panel.cellType,n=t.panel.rows[t.range.row],i=t.panel.rows[t.range.row2],l=t.cell;if(r==wijmo_grid_1.CellType.ColumnHeader&&wijmo_1.toggleClass(l,"wj-group-header",0==t.range.row),r==wijmo_grid_1.CellType.Cell||r==wijmo_grid_1.CellType.ColumnHeader){var s=this._cellGroupsByColumn[t.col];wijmo_1.assert(s instanceof _CellGroup,"Failed to get the group!"),wijmo_1.toggleClass(l,"wj-group-start",s._colstart==t.range.col),wijmo_1.toggleClass(l,"wj-group-end",s._colstart+s._colspan-1==t.range.col2)}o>1&&(r!=wijmo_grid_1.CellType.Cell&&r!=wijmo_grid_1.CellType.RowHeader||(wijmo_1.toggleClass(l,"wj-record-start",n instanceof _MultiRow&&0==n.recordIndex),wijmo_1.toggleClass(l,"wj-record-end",i instanceof _MultiRow&&i.recordIndex==o-1)));var a=this.alternatingRowStep;if(a){var c=!1;n instanceof _MultiRow&&(c=n.dataIndex%(a+1)==0,1==a&&(c=!c)),wijmo_1.toggleClass(l,"wj-alt",c)}if(this._centerVert&&!l.getAttribute("wj-state-measuring")){var _=!1;if(l.innerHTML&&t.range.rowSpan>1)if(_=!0,0==l.childElementCount)l.innerHTML="<div>"+l.innerHTML+"</div>";else{var d=document.createElement("div"),p=document.createRange();p.selectNodeContents(l),p.surroundContents(d)}wijmo_1.toggleClass(l,"wj-center-vert",_)}},t.prototype._updateButtonGlyph=function(){var e=this._btnCollapse.querySelector("span");e instanceof HTMLElement&&(e.className=this.collapsedHeaders?"wj-glyph-left":"wj-glyph-down-left")},t.prototype._getError=function(t,o,r){if(wijmo_1.isFunction(this.itemValidator)&&t==this.rowHeaders)for(var n=0;n<this._rowsPerItem;n++)for(r=0;r<this.columns.length;r++){var i=this.itemValidator(o+n,r);if(i)return i}return e.prototype._getError.call(this,t,o,r)},t}(wijmo_grid_1.FlexGrid);exports.MultiRow=MultiRow;var _MultiRowAddNewHandler=function(e){function t(t){return t._addHdl._detach(),e.call(this,t)||this}return __extends(t,e),t.prototype.updateNewRowTemplate=function(){for(var e=this._g.editableCollectionView,t=this._g,o=t.rows,r=e&&e.canAddNew&&t.allowAddNew&&!t.isReadOnly,n=-1,i=0;i<o.length;i+=t.rowsPerItem)if(o[i]instanceof _MultiRowNewRowTemplate){n=i;break}if(r&&n>-1&&(this._top&&n>0||!this._top&&0==n)&&(n=-1,this._removeNewRowTemplate()),r&&n<0)for(i=0;i<t.rowsPerItem;i++){var l=new _MultiRowNewRowTemplate(i);this._top?o.insert(i,l):o.push(l)}!r&&n>-1&&this._removeNewRowTemplate()},t.prototype._keydown=function(t){e.prototype._keydown.call(this,t),t.defaultPrevented||t.keyCode!=wijmo_1.Key.Escape||this._copyNewDataItem()},t.prototype._rowEditEnded=function(t,o){e.prototype._rowEditEnded.call(this,t,o),this._copyNewDataItem()},t.prototype._beginningEdit=function(t,o){e.prototype._beginningEdit.call(this,t,o),this._top&&!t.rows[0].dataItem&&this._copyNewDataItem()},t.prototype._copyNewDataItem=function(){if(this._top)for(var e=this._g,t=e.rows,o=0;o<e.rowsPerItem;o++)t[o]instanceof wijmo_grid_1._NewRowTemplate&&(t[o].dataItem=this._nrt.dataItem)},t.prototype._removeNewRowTemplate=function(){for(var e=0,t=this._g.rows;e<t.length;e++)t[e]instanceof wijmo_grid_1._NewRowTemplate&&(t.removeAt(e),e--)},t}(wijmo_grid_1._AddNewHandler);exports._MultiRowAddNewHandler=_MultiRowAddNewHandler;var _MultiRowNewRowTemplate=function(e){function t(t){var o=e.call(this)||this;return o._idxRecord=t,o}return __extends(t,e),Object.defineProperty(t.prototype,"recordIndex",{get:function(){return this._idxRecord},enumerable:!0,configurable:!0}),t}(wijmo_grid_1._NewRowTemplate);wijmo_1._registerModule("wijmo.grid.multirow",selfModule); | ||
"use strict";var __extends=this&&this.__extends||function(){var e=function(t,o){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,t){e.__proto__=t}||function(e,t){for(var o in t)t.hasOwnProperty(o)&&(e[o]=t[o])})(t,o)};return function(t,o){function r(){this.constructor=t}e(t,o),t.prototype=null===o?Object.create(o):(r.prototype=o.prototype,new r)}}();Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_grid_1=require("@grapecity/wijmo.grid"),wijmo_1=require("@grapecity/wijmo"),selfModule=require("@grapecity/wijmo.grid.multirow"),_Cell=function(e){function t(t){var o=e.call(this)||this;return o._row=o._col=0,o._rowspan=o._colspan=1,t&&wijmo_1.copy(o,t),o}return __extends(t,e),Object.defineProperty(t.prototype,"colspan",{get:function(){return this._colspan},set:function(e){this._colspan=wijmo_1.asInt(e,!1,!0),wijmo_1.assert(this._colspan>0,"colspan must be >= 1")},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowspan",{get:function(){return this._rowspan},set:function(e){this._rowspan=wijmo_1.asInt(e,!1,!0),wijmo_1.assert(this._rowspan>0,"colspan must be >= 1")},enumerable:!0,configurable:!0}),t}(wijmo_grid_1.Column);exports._Cell=_Cell;var _MultiRow=function(e){function t(t,o,r){var n=e.call(this,t)||this;return n._idxData=o,n._idxRecord=r,n}return __extends(t,e),Object.defineProperty(t.prototype,"recordIndex",{get:function(){return this._idxRecord},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"dataIndex",{get:function(){return this._idxData},enumerable:!0,configurable:!0}),t}(wijmo_grid_1.Row);exports._MultiRow=_MultiRow;var _CellGroup=function(e){function t(t,o){var r=e.call(this)||this;if(r._colstart=0,r._g=t,o&&wijmo_1.copy(r,o),!r._cells)throw"Cell group with no cells?";var n=0,i=0,l=0,s=1,a=0;r._cells.forEach(function(e,t){if(i>0&&i+e.colspan>r._colspan){for(var o=l;o<t;o++)r._cells[o].rowspan=s;n+=s,i=0,l=t,s=e.rowspan}e._row=n,e._col=i,i+=e.colspan,s=Math.max(s,e.rowspan),a+=e.colspan}),r._rowspan=n+1,r._colspan>a&&(r._colspan=a);for(var c=0;c<r._cells.length;c++){var _=r._cells[c];(c==r._cells.length-1||r._cells[c+1]._row>_._row)&&(i=_._col,_._colspan=r._colspan-i)}return r}return __extends(t,e),t.prototype._copy=function(e,t){var o=this;return"cells"==e&&(this._cells=[],wijmo_1.isArray(t)&&t.forEach(function(e){var t=new _Cell(e);!e.header&&t.binding&&(t.header=wijmo_1.toHeaderCase(t.binding)),o._cells.push(t),o._colspan=Math.max(o._colspan,t.colspan)}),!0)},Object.defineProperty(t.prototype,"cells",{get:function(){return this._cells},enumerable:!0,configurable:!0}),t.prototype.closeGroup=function(e){if(e>this._rowspan){for(var t=0;t<this._cells.length;t++){(o=this._cells[t])._row==this._rowspan-1&&(o._rowspan=e-o._row)}this._rowspan=e}this._cols=new wijmo_grid_1.ColumnCollection(this._g,this._g.columns.defaultSize),this._rng=new Array(e*this._colspan);for(t=0;t<this._cells.length;t++)for(var o=this._cells[t],r=0;r<o._rowspan;r++)for(var n=0;n<o._colspan;n++){var i=(o._row+r)*this._colspan+o._col+n;this._cols.setAt(i,o);var l=new wijmo_grid_1.CellRange(0-r,0-n,0-r+o._rowspan-1,0-n+o._colspan-1);l.isSingleCell||(this._rng[i]=l)}this._rng[-1]=new wijmo_grid_1.CellRange(0,this._colstart,0,this._colstart+this._colspan-1)},t.prototype.getColumnWidth=function(e){for(var t=0;t<this._cells.length;t++){var o=this._cells[t];if(o._col==e&&1==o.colspan)return o.width}return null},t.prototype.getMergedRange=function(e,t,o){if(t<0)return this._rng[-1];var r=e.rows[t],n=null!=r.recordIndex?r.recordIndex:t%this._rowspan,i=o-this._colstart,l=this._rng[n*this._colspan+i];return e.cellType==wijmo_grid_1.CellType.ColumnHeader&&t++,l?new wijmo_grid_1.CellRange(t+l.row,o+l.col,t+l.row2,o+l.col2):null},t.prototype.getBindingColumn=function(e,t,o){if(t<0)return this;var r=e.rows[t],n=r&&null!=r.recordIndex?r.recordIndex:t%this._rowspan,i=o-this._colstart;return this._cols[n*this._colspan+i]},t.prototype.getColumn=function(e){return this._cols.getColumn(e)},t}(_Cell);exports._CellGroup=_CellGroup;var _MergeManager=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return __extends(t,e),t.prototype.getMergedRange=function(t,o,r,n){void 0===n&&(n=!0);var i=t.grid;switch(t.cellType){case wijmo_grid_1.CellType.Cell:case wijmo_grid_1.CellType.RowHeader:if(t.rows[o]instanceof wijmo_grid_1.GroupRow)return e.prototype.getMergedRange.call(this,t,o,r,n)}switch(t.cellType){case wijmo_grid_1.CellType.Cell:case wijmo_grid_1.CellType.ColumnHeader:var l=i._cellGroupsByColumn[r];wijmo_1.assert(l instanceof _CellGroup,"Failed to get the group!");var s=t.cellType==wijmo_grid_1.CellType.ColumnHeader?l.getMergedRange(t,o-1,r):l.getMergedRange(t,o,r),a=t.columns.frozen;a&&s&&s.columnSpan>1&&s.col<a&&s.col2>=a&&(s=s.clone(),r<a?s.col2=a-1:s.col=a);var c=t.rows.frozen;return c&&s&&s.rowSpan>1&&t.cellType==wijmo_grid_1.CellType.Cell&&s.row<c&&s.row2>=c&&(s=s.clone(),o<c?s.row2=c-1:s.row=c),s;case wijmo_grid_1.CellType.RowHeader:var _=i._rowsPerItem,d=o-t.rows[o].recordIndex,p=Math.min(d+_-1,t.rows.length-1);return new wijmo_grid_1.CellRange(d,0,p,t.columns.length-1);case wijmo_grid_1.CellType.TopLeft:return new wijmo_grid_1.CellRange(0,0,t.rows.length-1,t.columns.length-1)}return null},t}(wijmo_grid_1.MergeManager);exports._MergeManager=_MergeManager;var MultiRow=function(e){function t(t,o){var r=e.call(this,t)||this;r._rowsPerItem=1,r._cellBindingGroups=[],r._centerVert=!0,r._collapsedHeaders=!1,r.collapsedHeadersChanging=new wijmo_1.Event,r.collapsedHeadersChanged=new wijmo_1.Event,wijmo_1.addClass(r.hostElement,"wj-multirow");var n=r.columnHeaders.hostElement.parentElement,i=wijmo_1.createElement('<div class="wj-hdr-collapse"><span></span></div>');i.style.display="none",n.appendChild(i),r._btnCollapse=i,r._updateButtonGlyph(),r.addEventListener(i,"mousedown",function(e){switch(r.collapsedHeaders){case null:case!1:r._collapsedHeadersWasNull=null==r.collapsedHeaders,r.collapsedHeaders=!0;break;case!0:r.collapsedHeaders=!!r._collapsedHeadersWasNull&&null}e.preventDefault(),r.focus()},!0),r.autoGenerateColumns=!1,r.mergeManager=new _MergeManager(r);var l=r.hostElement;return r.removeEventListener(l,"dragover"),r.removeEventListener(l,"dragleave"),r.removeEventListener(l,"dragdrop"),r._addHdl=new _MultiRowAddNewHandler(r),r.formatItem.addHandler(r._formatItem,r),r.addEventListener(r.rowHeaders.hostElement,"click",function(e){if(!e.defaultPrevented&&r.selectionMode!=wijmo_grid_1.SelectionMode.None){var t=r.hitTest(e);if(t.panel==r.rowHeaders&&t.row>-1){var o=r.selection,n=r.rows[o.topRow],i=r.selectionMode!=wijmo_grid_1.SelectionMode.Row?r.rows[o.bottomRow]:n;if(n&&null!=n.recordIndex){var l=n.index-n.recordIndex,s=i.index-i.recordIndex+r.rowsPerItem-1,a=r.columns.length-1,c=o.row!=o.topRow?new wijmo_grid_1.CellRange(s,0,l,a):new wijmo_grid_1.CellRange(l,0,s,a);r.select(c),e.preventDefault()}}}},!0),r.initialize(o),r}return __extends(t,e),t.prototype._getProductInfo=function(){return"H87K,MultiRow"},Object.defineProperty(t.prototype,"layoutDefinition",{get:function(){return this._layoutDef},set:function(e){var t=this;this._layoutDef=wijmo_1.asArray(e),this._rowsPerItem=1,this._cellBindingGroups=this._parseCellGroups(this._layoutDef),this._cellBindingGroups.forEach(function(e){t._rowsPerItem=Math.max(t._rowsPerItem,e._rowspan)}),this._bindGrid(!0)},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"rowsPerItem",{get:function(){return this._rowsPerItem},enumerable:!0,configurable:!0}),t.prototype.getBindingColumn=function(e,t,o){return this._getBindingColumn(e,t,e.columns[o])},t.prototype.getColumn=function(t){if(wijmo_1.isString(t)){for(var o=this._cellBindingGroups,r=null,n=0;n<o.length&&!r;n++)r=o[n].getColumn(t);return r}return e.prototype.getColumn.call(this,t)},Object.defineProperty(t.prototype,"centerHeadersVertically",{get:function(){return this._centerVert},set:function(e){e!=this._centerVert&&(this._centerVert=wijmo_1.asBoolean(e),this.invalidate())},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"collapsedHeaders",{get:function(){return this._collapsedHeaders},set:function(e){if(e!=this._collapsedHeaders){var t=new wijmo_1.CancelEventArgs;this.onCollapsedHeadersChanging(t)&&(this._collapsedHeaders=wijmo_1.asBoolean(e,!0),this._updateCollapsedHeaders(),this._updateButtonGlyph(),this.onCollapsedHeadersChanged(t))}},enumerable:!0,configurable:!0}),Object.defineProperty(t.prototype,"showHeaderCollapseButton",{get:function(){return""==this._btnCollapse.style.display},set:function(e){e!=this.showHeaderCollapseButton&&(this._btnCollapse.style.display=wijmo_1.asBoolean(e)?"":"none")},enumerable:!0,configurable:!0}),t.prototype.onCollapsedHeadersChanging=function(e){return this.collapsedHeadersChanging.raise(this,e),!e.cancel},t.prototype.onCollapsedHeadersChanged=function(e){this.collapsedHeadersChanged.raise(this,e)},t.prototype._getQuickAutoSize=function(){return wijmo_1.isBoolean(this.quickAutoSize)?this.quickAutoSize:this.formatItem.handlerCount<=1&&null==this.itemFormatter},t.prototype._addBoundRow=function(e,t){for(var o=e[t],r=0;r<this._rowsPerItem;r++)this.rows.push(new _MultiRow(o,t,r))},t.prototype._addNode=function(e,t,o){this._addBoundRow(e,t)},t.prototype._bindColumns=function(){for(var e=this.columnHeaders.rows,t=this._rowsPerItem+1;e.length>t;)e.removeAt(e.length-1);for(;e.length<t;)e.push(new wijmo_grid_1.Row);this._updateCollapsedHeaders(),this.columns.clear(),this._cellGroupsByColumn={};var o=this.collectionView;if(o&&o.sourceCollection&&o.sourceCollection.length&&o.sourceCollection[0],this._cellBindingGroups)for(var r=0;r<this._cellBindingGroups.length;r++)for(var n=this._cellBindingGroups[r],i=function(e){l._cellGroupsByColumn[l.columns.length]=n;for(var t=new wijmo_grid_1.Column,o=function(o){var r=n.cells[o],i="width,binding,header,format,dataMap,name,aggregate".split(",");if(r._col==e)return i.forEach(function(e){null!=r[e]&&(t[e]=r[e])}),"break"},r=0;r<n.cells.length;r++){if("break"===o(r))break}l.columns.push(t)},l=this,s=0;s<n._colspan;s++)i(s)},t.prototype._updateCollapsedHeaders=function(){var e=this.columnHeaders.rows,t=this.collapsedHeaders;e[0].visible=0!=t;for(var o=1;o<e.length;o++)e[o].visible=1!=t},t.prototype._updateColumnTypes=function(){e.prototype._updateColumnTypes.call(this);var t=this.collectionView;if(wijmo_1.hasItems(t))for(var o=t.items[0],r=0;r<this._cellBindingGroups.length;r++)for(var n=this._cellBindingGroups[r],i=0;i<n._cols.length;i++){var l=n._cols[i];null==l.dataType&&l._binding&&(l.dataType=wijmo_1.getType(l._binding.getValue(o)))}},t.prototype._getBindingColumn=function(e,t,o){if(e==this.cells||e==this.columnHeaders){var r=this._cellGroupsByColumn[o.index];e==this.columnHeaders&&t--,o=r.getBindingColumn(e,t,o.index)}return o},t.prototype._cvCollectionChanged=function(e,t){if(this.autoGenerateColumns&&0==this.columns.length)this._bindGrid(!0);else{var o=wijmo_1.NotifyCollectionChangedAction;switch(t.action){case o.Change:this.invalidate();break;case o.Add:if(t.index==this.collectionView.items.length-1){for(var r=this.rows.length;r>0&&this.rows[r-1]instanceof wijmo_grid_1._NewRowTemplate;)r--;for(var n=0;n<this._rowsPerItem;n++)this.rows.insert(r+n,new _MultiRow(t.item,t.index,n));return}wijmo_1.assert(!1,"added item should be the last one.");break;default:this._bindGrid(!1)}}},t.prototype._parseCellGroups=function(e){var t=[],o=1;if(e){for(var r=0,n=0;r<e.length;r++){var i=new _CellGroup(this,e[r]);i._colstart=n,n+=i._colspan,o=Math.max(o,i._rowspan),t.push(i)}for(r=0;r<t.length;r++)t[r].closeGroup(o)}return t},t.prototype._formatItem=function(e,t){var o=this._rowsPerItem,r=t.panel.cellType,n=t.panel.rows[t.range.row],i=t.panel.rows[t.range.row2],l=t.cell;if(r==wijmo_grid_1.CellType.ColumnHeader&&wijmo_1.toggleClass(l,"wj-group-header",0==t.range.row),r==wijmo_grid_1.CellType.Cell||r==wijmo_grid_1.CellType.ColumnHeader){var s=this._cellGroupsByColumn[t.col];wijmo_1.assert(s instanceof _CellGroup,"Failed to get the group!"),wijmo_1.toggleClass(l,"wj-group-start",s._colstart==t.range.col),wijmo_1.toggleClass(l,"wj-group-end",s._colstart+s._colspan-1==t.range.col2)}o>1&&(r!=wijmo_grid_1.CellType.Cell&&r!=wijmo_grid_1.CellType.RowHeader||(wijmo_1.toggleClass(l,"wj-record-start",n instanceof _MultiRow&&0==n.recordIndex),wijmo_1.toggleClass(l,"wj-record-end",i instanceof _MultiRow&&i.recordIndex==o-1)));var a=this.alternatingRowStep;if(a){var c=!1;n instanceof _MultiRow&&(c=n.dataIndex%(a+1)==0,1==a&&(c=!c)),wijmo_1.toggleClass(l,"wj-alt",c)}if(this._centerVert&&!l.getAttribute("wj-state-measuring")){var _=!1;if(l.innerHTML&&t.range.rowSpan>1)if(_=!0,0==l.childElementCount)l.innerHTML="<div>"+l.innerHTML+"</div>";else{var d=document.createElement("div"),p=document.createRange();p.selectNodeContents(l),p.surroundContents(d)}wijmo_1.toggleClass(l,"wj-center-vert",_)}},t.prototype._updateButtonGlyph=function(){var e=this._btnCollapse.querySelector("span");e instanceof HTMLElement&&(e.className=this.collapsedHeaders?"wj-glyph-left":"wj-glyph-down-left")},t.prototype._getError=function(t,o,r){if(wijmo_1.isFunction(this.itemValidator)&&t==this.rowHeaders)for(var n=0;n<this._rowsPerItem;n++)for(r=0;r<this.columns.length;r++){var i=this.itemValidator(o+n,r);if(i)return i}return e.prototype._getError.call(this,t,o,r)},t}(wijmo_grid_1.FlexGrid);exports.MultiRow=MultiRow;var _MultiRowAddNewHandler=function(e){function t(t){return t._addHdl._detach(),e.call(this,t)||this}return __extends(t,e),t.prototype.updateNewRowTemplate=function(){for(var e=this._g.editableCollectionView,t=this._g,o=t.rows,r=e&&e.canAddNew&&t.allowAddNew&&!t.isReadOnly,n=-1,i=0;i<o.length;i+=t.rowsPerItem)if(o[i]instanceof _MultiRowNewRowTemplate){n=i;break}if(r&&n>-1&&(this._top&&n>0||!this._top&&0==n)&&(n=-1,this._removeNewRowTemplate()),r&&n<0)for(i=0;i<t.rowsPerItem;i++){var l=new _MultiRowNewRowTemplate(i);this._top?o.insert(i,l):o.push(l)}!r&&n>-1&&this._removeNewRowTemplate()},t.prototype._keydown=function(t){e.prototype._keydown.call(this,t),t.defaultPrevented||t.keyCode!=wijmo_1.Key.Escape||this._copyNewDataItem()},t.prototype._rowEditEnded=function(t,o){e.prototype._rowEditEnded.call(this,t,o),this._copyNewDataItem()},t.prototype._beginningEdit=function(t,o){e.prototype._beginningEdit.call(this,t,o),this._top&&!t.rows[0].dataItem&&this._copyNewDataItem()},t.prototype._copyNewDataItem=function(){if(this._top)for(var e=this._g,t=e.rows,o=0;o<e.rowsPerItem;o++)t[o]instanceof wijmo_grid_1._NewRowTemplate&&(t[o].dataItem=this._nrt.dataItem)},t.prototype._removeNewRowTemplate=function(){for(var e=0,t=this._g.rows;e<t.length;e++)t[e]instanceof wijmo_grid_1._NewRowTemplate&&(t.removeAt(e),e--)},t}(wijmo_grid_1._AddNewHandler);exports._MultiRowAddNewHandler=_MultiRowAddNewHandler;var _MultiRowNewRowTemplate=function(e){function t(t){var o=e.call(this)||this;return o._idxRecord=t,o}return __extends(t,e),Object.defineProperty(t.prototype,"recordIndex",{get:function(){return this._idxRecord},enumerable:!0,configurable:!0}),t}(wijmo_grid_1._NewRowTemplate);wijmo_1._registerModule("wijmo.grid.multirow",selfModule); |
{ | ||
"name": "@grapecity/wijmo.grid.multirow", | ||
"version": "5.20183.595-nightly.d20190405.t210807", | ||
"version": "5.20183.595-nightly.d20190406.t001954", | ||
"description": "UI library for pure JS, Angular, React, Vue and more...", | ||
@@ -10,5 +10,5 @@ "author": "GrapeCity, Inc", | ||
"dependencies": { | ||
"@grapecity/wijmo": "5.20183.595-nightly.d20190405.t210807", | ||
"@grapecity/wijmo.input": "5.20183.595-nightly.d20190405.t210807", | ||
"@grapecity/wijmo.grid": "5.20183.595-nightly.d20190405.t210807" | ||
"@grapecity/wijmo": "5.20183.595-nightly.d20190406.t001954", | ||
"@grapecity/wijmo.input": "5.20183.595-nightly.d20190406.t001954", | ||
"@grapecity/wijmo.grid": "5.20183.595-nightly.d20190406.t001954" | ||
}, | ||
@@ -15,0 +15,0 @@ "module": "./es5-esm.js", |
@@ -1,13 +0,1 @@ | ||
/*! | ||
* | ||
* Wijmo Library 5.20183.595-nightly.d20190405.t210807 | ||
* 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/ | ||
* | ||
*/ | ||
/** | ||
@@ -14,0 +2,0 @@ * {@module wijmo.grid.multirow} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79581
616
+ Added@grapecity/wijmo@5.20183.595-nightly.d20190406.t001954(transitive)
+ Added@grapecity/wijmo.grid@5.20183.595-nightly.d20190406.t001954(transitive)
+ Added@grapecity/wijmo.input@5.20183.595-nightly.d20190406.t001954(transitive)
+ Added@grapecity/wijmo.styles@5.20183.595-nightly.d20190406.t001954(transitive)
- Removed@grapecity/wijmo@5.20183.595-nightly.d20190405.t210807(transitive)
- Removed@grapecity/wijmo.grid@5.20183.595-nightly.d20190405.t210807(transitive)
- Removed@grapecity/wijmo.input@5.20183.595-nightly.d20190405.t210807(transitive)
- Removed@grapecity/wijmo.styles@5.20183.595-nightly.d20190405.t210807(transitive)
Updated@grapecity/wijmo@5.20183.595-nightly.d20190406.t001954
Updated@grapecity/wijmo.grid@5.20183.595-nightly.d20190406.t001954
Updated@grapecity/wijmo.input@5.20183.595-nightly.d20190406.t001954