@mescius/wijmo.grid.transposed 5.20252.44 → 5.20261.45-nightly.d20260105.t014601
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es2015-commonjs.js +2 -2
- package/es2015-esm.js +2 -2
- package/es5-esm.js +2 -2
- package/index.d.ts +2 -2
- package/index.js +2 -2
- package/package.json +3 -3
package/es2015-commonjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t014601
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
"use strict";var __importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var o in e)Object.hasOwnProperty.call(e,o)&&(t[o]=e[o]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_grid_1=require("@mescius/wijmo.grid"),wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.grid.transposed"));exports.TransposedGridClsNames={hostElement:"wj-transposed-grid"};class _MergeManager extends wijmo_grid_1.MergeManager{getMergedRange(e,t,o,r=!0){let i=e.grid,s=i._hasColumnGroups();if(e==i.columnHeaders&&s)return null;if(e==i.rowHeaders&&s){if(t<0||t>=e.rows.length||o<0||o>=e.columns.length)return null;let r=i._getColumnGroup(t,o);if(r){let o=r._rng,i=e.rows;if(i.isFrozen(o.row)!=i.isFrozen(o.row2)){o=o.clone();i.isFrozen(t)?o.row2=i._frozenInternal-1:o.row=i._frozenInternal}return o}return null}return super.getMergedRange(e,t,o,r)}}exports._MergeManager=_MergeManager;class TransposedGrid extends wijmo_grid_1.FlexGrid{constructor(e,t){super(e,null);this._keyPrefix="item";this._autoGenRows=!0;wijmo_1.addClass(this.hostElement,exports.TransposedGridClsNames.hostElement);this.allowSorting=wijmo_grid_1.AllowSorting.None;this.headersVisibility=wijmo_grid_1.HeadersVisibility.Row;this._rowInfo=new wijmo_grid_1.ColumnCollection(this,this.columns.defaultSize);this._grpHdl=new _RowGroupHandler(this);this.mergeManager=new _MergeManager;this.initialize(t);this._rowInfo.collectionChanged.addHandler(this._rowInfoChanged,this);this.deferUpdate(()=>{let e=this.rowHeaders.columns;if(e.length){e[e.length-1].width=this.columns.defaultSize}})}static get controlTemplate(){TransposedGrid._ctrlTemplate||(TransposedGrid._ctrlTemplate=wijmo_grid_1.FlexGrid.controlTemplate);return TransposedGrid._ctrlTemplate}static set controlTemplate(e){TransposedGrid._ctrlTemplate=e}get autoGenerateRows(){return this._autoGenRows}set autoGenerateRows(e){this._autoGenRows=wijmo_1.asBoolean(e)}get rowGroups(){return this._grpHdl.getGroupDefinitions()}set rowGroups(e){this._rowInfo.deferUpdate(()=>{this.autoGenerateRows=!1;this._rowInfo.clear();this._grpHdl.createColumnGroups(wijmo_1.asArray(e))})}refresh(e){let t=this._rowInfo;if(t._dirty){t._dirty=!1;this._rowInfoChanged()}else super.refresh(e)}get allowAddNew(){return!1}set allowAddNew(e){}get allowDelete(){return!1}set allowDelete(e){}get allowSorting(){return wijmo_grid_1.AllowSorting.None}set allowSorting(e){wijmo_1.assert(e===wijmo_grid_1.AllowSorting.None,"TransposedGrid does not support sorting.");this._alSorting=e}get columnGroups(){return null}set columnGroups(e){throw"TransposedGrid does not support columnGroups, use rowGroups instead."}onRowEditEnded(e){let t=wijmo_1.tryCast(this._sourceItems,"ICollectionView");if(t){let e=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change);t.collectionChanged.raise(t,e)}super.onRowEditEnded(e)}_getCollectionView(e){let t=wijmo_1.tryCast(this._sourceItems,"ICollectionView");t&&t.collectionChanged.removeHandler(this._sourceViewChanged);t=wijmo_1.tryCast(e,"ICollectionView");let o=e;if(wijmo_1.isArray(e))o=this._transposeItemsSource(e);else if(t){t.collectionChanged.addHandler(this._sourceViewChanged,this);o=this._transposeItemsSource(t.items)}this.autoGenerateColumns=!0;let r=super._getCollectionView(o),i=null;t instanceof wijmo_1.CollectionView&&(i=t.getError);i&&r instanceof wijmo_1.CollectionView&&(this._supportsProxies()?r.getError=(e,t)=>{if(null==t)return null;let o=e._keys.indexOf(t);return i(e._arr[o],e._bnd.path)}:r.getError=(e,t)=>{if(null==t)return null;let o=parseInt(t.substr(this._keyPrefix.length));return i(e._arr[o],e._rowInfo.binding)});this._sourceItems=e;return r}_getColumnTypes(e){let t,o;if(this._sourceItems)if(wijmo_1.isArray(this._sourceItems))o=this._sourceItems;else{let e=wijmo_1.tryCast(this._sourceItems,"ICollectionView");e&&(o=e.items)}t=o?o.map((e,t)=>({binding:this._keyPrefix+t,dataType:wijmo_1.DataType.Object})):wijmo_1.getTypes(e);return t}_copy(e,t){if(/rows|columns/.test(e)){wijmo_1.assert(wijmo_1.isArray(t),"Array Expected.");let e=wijmo_1.asArray(t);e.some(e=>null!=e.columns)?this.rowGroups=e:this._rowInfo.deferUpdate(()=>{this.autoGenerateRows=!1;this._rowInfo.clear();t.forEach(e=>{let t=new TransposedGridRow(e);this._rowInfo.push(t)})});return!0}return super._copy(e,t)}onLoadedRows(e){let t=this.columns;for(let e=0;e<t.length;e++){let o=t[e];o.align=null;o.dataType=0}let o=this.rowHeaders.columns;for(let e=0;e<o.length;e++){o[e].align="left";o[e].width=0}let r=wijmo_grid_1.FlexGrid._getSerializableProperties(wijmo_grid_1.Row);this.rows.forEach(e=>{let t=e.dataItem._rowInfo;if(t){this._copyProps(t,e,r,["showDropDown","width","size"]);if(this._hasColumnGroups())for(let t=0;t<o.length;t++){let o=this._grpHdl.getColumnGroup(e.index,t);o&&this._updateRowHeaders(e.index,t,o)}else o.length&&this._updateRowHeaders(e.index,o.length-1,t)}});for(let e=0;e<o.length;e++)0===o[e].width&&(o[e].width=this.columns.defaultSize);super.onLoadedRows(e)}_getBindingColumn(e,t,o){let r=o;if(e!=this.cells)return r;let i=e.rows[t],s=i&&i.dataItem&&i.dataItem._rowInfo;if(wijmo_1.isUndefined(s))return r;r=new wijmo_grid_1.Column;let n=wijmo_grid_1.FlexGrid._getSerializableProperties(wijmo_grid_1.Column);this._copyProps(s,r,n);r.binding=o.binding;r.header=s.header||wijmo_1.toHeaderCase(s.binding);return r}_isTransposed(){return!0}_autoSizeRows(){this.autoSizeMode&wijmo_grid_1.AutoSizeMode.Both&&this.autoSizeRows();super._autoSizeRows()}_copyProps(e,t,o,r=[]){for(let i in e)if(o.indexOf(i)>-1&&-1===r.indexOf(i)){let o=e[i];if(!wijmo_1.isUndefined(o))try{t[i]=o}catch(e){}}}_updateRowHeaders(e,t,o){let r=o.header||wijmo_1.toHeaderCase(o.binding);this.rowHeaders.setCellData(e,t,r);let i=this.rowHeaders.columns,s=o.width;if(wijmo_1.isNumber(s)&&s>0){let e=o._rng;if(e&&e instanceof wijmo_grid_1.CellRange&&e.isValid){let t=e.columnSpan;wijmo_1.assert(t>0,"Column span is negative or equal to 0");s/=t}i[t].width=Math.max(i[t].width,s)}}_rowInfoChanged(){this._toRowInfo&&clearTimeout(this._toRowInfo);this._toRowInfo=setTimeout(()=>{let e=this.selection,t=this.itemsSource;this.itemsSource=null;this.itemsSource=t;this.selection=e;this.invalidate(!0)},wijmo_1.Control._REFRESH_INTERVAL)}_sourceViewChanged(e,t){this.activeEditor||this.invalidate()}_transposeItemsSource(e){let t=new wijmo_1.ObservableArray,o=wijmo_1.getTypes(e),r=e.map((e,t)=>this._keyPrefix+t);(this.autoGenerateRows?this._getRowInfo(e):this._rowInfo).forEach((i,s)=>{let n=new wijmo_1.Binding(i.binding);if(null==i.dataType&&e.length){let t=n.getValue(e[0]);i.dataType=null!=t?wijmo_1.getType(t):o[s].dataType}if(this._supportsProxies()){let o=this._createProxy(e,i,r);t.push(o)}else{let o=this._createTransposedObject(e,i,this._keyPrefix);t.push(o)}});e instanceof wijmo_1.ObservableArray&&e.collectionChanged.addHandler((e,o)=>{if(o.action===wijmo_1.NotifyCollectionChangedAction.Change)this.activeEditor||this.invalidate();else{let e=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Reset);t.onCollectionChanged(e);this._rowInfoChanged()}});return t}_supportsProxies(){return null!=window.Proxy}_createProxy(e,t,o){let r={_arr:e,_rowInfo:t,_bnd:new wijmo_1.Binding(t.binding),_keys:o};return new Proxy(r,{ownKeys:e=>e._keys,getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0,writable:!0}),get:(e,t)=>{let o=e._keys.indexOf(t);return o>-1?e._bnd.getValue(e._arr[o]):e[t]},set:(e,t,o)=>{let r=e._keys.indexOf(t);if(r>-1){let t=e._arr,i=t[r];e._bnd.setValue(i,o);if(t instanceof wijmo_1.ObservableArray){let e=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change,i,r);t.onCollectionChanged(e)}return!0}return!1}})}_createTransposedObject(e,t,o){let r={_arr:e,_rowInfo:t},i=new wijmo_1.Binding(t.binding);for(let t=0;t<e.length;t++){let s=e[t];Object.defineProperty(r,o+t,{enumerable:!0,get:()=>i.getValue(s),set:o=>{i.setValue(s,o);if(e instanceof wijmo_1.ObservableArray){let o=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change,s,t);e.onCollectionChanged(o)}return!0}})}return r}_getRowInfo(e){let t=[];wijmo_1.getTypes(e).forEach(e=>{let o=e.binding,r=e.dataType;if(r!=wijmo_1.DataType.Object&&r!=wijmo_1.DataType.Array){let e={binding:o,header:wijmo_1.toHeaderCase(o),dataType:r},i=wijmo_grid_1.FlexGrid._defTypeWidth[r];if(null!=i){if(wijmo_1.isString(i)){let e=Math.round(parseFloat(i));i=i.indexOf("*")<0?e:e*this.columns.defaultSize}wijmo_1.isNumber(i)&&i>0&&(e.width=i)}t.push(e)}});return t}getRowDataItem(e,t){let o=this.cells;if(o.rows[e].dataItem._rowInfo instanceof TransposedGridRow){let e={};for(let r=0;r<o.rows.length;r++){e[o.rows[r].dataItem._rowInfo._binding.path]=o.getCellData(r,t,!1)}return e}return super.getRowDataItem(e,t)}}TransposedGrid._ctrlTemplate="";exports.TransposedGrid=TransposedGrid;class TransposedGridRow extends wijmo_grid_1.Column{get height(){return this._height}set height(e){this._height=e}}exports.TransposedGridRow=TransposedGridRow;class _RowGroupHandler{constructor(e){this._grid=e}get columnGroups(){return null}createColumnGroups(e){this._createRowGroups(e)}hasColumnGroups(){return null!=this._colGroups&&this._colGroups.length>0}getGroupDefinitions(){return this._groupDefs}getColumnGroup(e,t){let o=this._grid;if(t<o.rowHeaders.columns.length&&e<o._rowInfo.length)for(let o=this._colGroups;o;){let r=o;for(let r=0;r<o.length;r++){let i=o[r],s=i._rng;if(s.containsRow(e)){if(s.containsColumn(t)||0==i.columns.length)return i;o=i.columns;break}}if(o==r)break}return null}canMoveColumnGroup(e,t,o,r){return this._grid.columns.canMoveElement(t,r)}moveColumnGroup(e,t,o,r,i){return this._grid.columns.moveElement(t,r)}_createRowGroups(e){let t=this._grid;this._groupDefs=wijmo_1.asArray(e);t.autoGenerateRows=!1;t._rowInfo.clear();this._colGroups=[];e.forEach(e=>{this._colGroups.push(new _RowGroup(e,null))});let o=1;this._colGroups.forEach(e=>{this._addRowGroup(e);o=Math.max(o,e._getMaxLevel())});this._colGroups.forEach(e=>{e._expandRange(o)});let r=t.rowHeaders.columns;r.clear();for(let e=0;e<=o;e++){let t=new wijmo_grid_1.Column;r.splice(e,0,t);e<o&&(t.cssClassAll=wijmo_grid_1.FlexGridClsNames.colGroup)}}_addRowGroup(e){let t=this._grid;e._grid=t;e._rng.row=t._rowInfo.length;0==e.columns.length?t._rowInfo.push(e):e.columns.forEach(e=>{this._addRowGroup(e)});e._rng.row2=t._rowInfo.length-1}}exports._RowGroupHandler=_RowGroupHandler;class _RowGroup extends wijmo_grid_1.Column{constructor(e,t){super();this._rng=new wijmo_grid_1.CellRange(-1,0);this._cols=[];this._lvl=0;this._collapsed=!1;this._pGrp=t;this._lvl=0;for(let e=t;e;e=e._pGrp)this._lvl++;t&&t.columns.indexOf(this)<0&&t.columns.push(this);this._rng.col=this._rng.col2=this._lvl;this.allowDragging=!1;wijmo_1.copy(this,e)}get columns(){return this._cols}set columns(e){let t=this._cols=[];e.forEach(e=>{let o=new _RowGroup(e,this);t.indexOf(o)<0&&t.push(o)})}get rows(){return this._cols}get isEmpty(){return 0===this._cols.length}get height(){return this._height}set height(e){this._height=e}get level(){let e=this,t=0;for(;e._pGrp;){e=e._pGrp;t++}return t}get collapseTo(){return this._collTo}set collapseTo(e){wijmo_1.assert(wijmo_1.isArray(e)||wijmo_1.isString(e),"collapseTo should be an array or a string.");this._collTo=e}get isCollapsed(){return this._collapsed}set isCollapsed(e){if(e!=this._collapsed){let t=this._grid;if(t){let o=new wijmo_grid_1.CellRangeEventArgs(t.rowHeaders,this._rng,this);if(t.onColumnGroupCollapsedChanging(o)){this._collapsed=wijmo_1.asBoolean(e);t.onColumnGroupCollapsedChanged(o)}}else this._collapsed=wijmo_1.asBoolean(e)}setTimeout(()=>{this._updateCollapsedState()})}_copy(e,t){if(/rows|columns/.test(e)){let e=wijmo_1.asArray(t);this.columns=e;return!0}return!1}_updateCollapsedState(){let e=this._grid._rowInfo,t=this._rng,o=this._collapsed;this._cols.forEach(e=>{if(e instanceof _RowGroup){e._collapsed=o;e._updateCollapsedState()}});let r=this._getCollapseToIndices();for(let i=t.topRow;i<=t.bottomRow;i++)e[i].visible=!o||r.indexOf(i)>-1}_getMaxLevel(){let e=this._lvl;this.columns.forEach(t=>{e=Math.max(e,t._getMaxLevel())});return e}_expandRange(e){let t=e-this._getMaxLevel();if(t>0){this._rng.col2+=t;this._cols.forEach(e=>{e._shiftRange(t)})}let o=this._grid._rowInfo,r=this._rng;for(let t=r.row;t<=r.row2;t++){o[t]._rng.col2=e}}_shiftRange(e){this._rng.col+=e;this._rng.col2+=e;this._cols.forEach(t=>{t._shiftRange(e)})}_getCollapseToBindings(){let e=this.collapseTo;return wijmo_1.isString(e)?[e]:e}_getCollapseToIndices(){let e=this._grid,t=this._rng,o=this._getCollapseToBindings();if(o&&o.length){let r=[],i=e._rowInfo;for(let e=0;e<o.length;e++)switch(o[e]){case"$first":r.push(t.topRow);break;case"$last":r.push(t.bottomRow);break;default:let s=i.indexOf(o[e]);s>-1&&r.push(s)}if(r.length)return r}return[t.bottomRow]}}exports._RowGroup=_RowGroup;wijmo_1._registerModule("wijmo.grid.transposed",selfModule);
|
|
14
|
+
"use strict";var __importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(o[t]=e[t]);o.default=e;return o};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_grid_1=require("@mescius/wijmo.grid"),wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.grid.transposed"));exports.TransposedGridClsNames={hostElement:"wj-transposed-grid"};class _MergeManager extends wijmo_grid_1.MergeManager{getMergedRange(e,o,t,s=!0){const r=e.grid,i=r._hasColumnGroups();if(e==r.columnHeaders&&i)return null;if(e==r.rowHeaders&&i){if(o<0||o>=e.rows.length||t<0||t>=e.columns.length)return null;const s=r._getColumnGroup(o,t);if(s){let t=s._rng,r=e.rows;if(r.isFrozen(t.row)!=r.isFrozen(t.row2)){t=t.clone();r.isFrozen(o)?t.row2=r._frozenInternal-1:t.row=r._frozenInternal}return t}return null}return super.getMergedRange(e,o,t,s)}}exports._MergeManager=_MergeManager;class TransposedGrid extends wijmo_grid_1.FlexGrid{constructor(e,o){super(e,null);this._keyPrefix="item";this._autoGenRows=!0;wijmo_1.addClass(this.hostElement,exports.TransposedGridClsNames.hostElement);this.allowSorting=wijmo_grid_1.AllowSorting.None;this.headersVisibility=wijmo_grid_1.HeadersVisibility.Row;this._rowInfo=new wijmo_grid_1.ColumnCollection(this,this.columns.defaultSize);this._grpHdl=new _RowGroupHandler(this);this.mergeManager=new _MergeManager;this.initialize(o);this._rowInfo.collectionChanged.addHandler(this._rowInfoChanged,this);this.deferUpdate(()=>{const e=this.rowHeaders.columns;if(e.length){e[e.length-1].width=this.columns.defaultSize}})}static get controlTemplate(){TransposedGrid._ctrlTemplate||(TransposedGrid._ctrlTemplate=wijmo_grid_1.FlexGrid.controlTemplate);return TransposedGrid._ctrlTemplate}static set controlTemplate(e){TransposedGrid._ctrlTemplate=e}get autoGenerateRows(){return this._autoGenRows}set autoGenerateRows(e){this._autoGenRows=wijmo_1.asBoolean(e)}get rowGroups(){return this._grpHdl.getGroupDefinitions()}set rowGroups(e){this._rowInfo.deferUpdate(()=>{this.autoGenerateRows=!1;this._rowInfo.clear();this._grpHdl.createColumnGroups(wijmo_1.asArray(e))})}refresh(e){const o=this._rowInfo;if(o._dirty){o._dirty=!1;this._rowInfoChanged()}else super.refresh(e)}get allowAddNew(){return!1}set allowAddNew(e){}get allowDelete(){return!1}set allowDelete(e){}get allowSorting(){return wijmo_grid_1.AllowSorting.None}set allowSorting(e){wijmo_1.assert(e===wijmo_grid_1.AllowSorting.None,"TransposedGrid does not support sorting.");this._alSorting=e}get columnGroups(){return null}set columnGroups(e){throw"TransposedGrid does not support columnGroups, use rowGroups instead."}onRowEditEnded(e){const o=wijmo_1.tryCast(this._sourceItems,"ICollectionView");if(o){const e=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change);o.collectionChanged.raise(o,e)}super.onRowEditEnded(e)}_getCollectionView(e){let o=wijmo_1.tryCast(this._sourceItems,"ICollectionView");o&&o.collectionChanged.removeHandler(this._sourceViewChanged);o=wijmo_1.tryCast(e,"ICollectionView");let t=e;if(wijmo_1.isArray(e))t=this._transposeItemsSource(e);else if(o){o.collectionChanged.addHandler(this._sourceViewChanged,this);t=this._transposeItemsSource(o.items)}this.autoGenerateColumns=!0;const s=super._getCollectionView(t);let r=null;o instanceof wijmo_1.CollectionView&&(r=o.getError);r&&s instanceof wijmo_1.CollectionView&&(this._supportsProxies()?s.getError=(e,o)=>{if(null==o)return null;const t=e._keys.indexOf(o);return r(e._arr[t],e._bnd.path)}:s.getError=(e,o)=>{if(null==o)return null;const t=parseInt(o.substr(this._keyPrefix.length));return r(e._arr[t],e._rowInfo.binding)});this._sourceItems=e;return s}_getColumnTypes(e){let o,t;if(this._sourceItems)if(wijmo_1.isArray(this._sourceItems))t=this._sourceItems;else{const e=wijmo_1.tryCast(this._sourceItems,"ICollectionView");e&&(t=e.items)}o=t?t.map((e,o)=>({binding:this._keyPrefix+o,dataType:wijmo_1.DataType.Object})):wijmo_1.getTypes(e);return o}_copy(e,o){if(/rows|columns/.test(e)){wijmo_1.assert(wijmo_1.isArray(o),"Array Expected.");const e=wijmo_1.asArray(o);e.some(e=>null!=e.columns)?this.rowGroups=e:this._rowInfo.deferUpdate(()=>{this.autoGenerateRows=!1;this._rowInfo.clear();o.forEach(e=>{const o=new TransposedGridRow(e);this._rowInfo.push(o)})});return!0}return super._copy(e,o)}onLoadedRows(e){const o=this.columns;for(let e=0;e<o.length;e++){const t=o[e];t.align=null;t.dataType=0}const t=this.rowHeaders.columns;for(let e=0;e<t.length;e++){t[e].align="left";t[e].width=0}const s=wijmo_grid_1.FlexGrid._getSerializableProperties(wijmo_grid_1.Row);this.rows.forEach(e=>{const o=e.dataItem._rowInfo;if(o){this._copyProps(o,e,s,["showDropDown","width","size"]);if(this._hasColumnGroups())for(let o=0;o<t.length;o++){const t=this._grpHdl.getColumnGroup(e.index,o);t&&this._updateRowHeaders(e.index,o,t)}else t.length&&this._updateRowHeaders(e.index,t.length-1,o)}});for(let e=0;e<t.length;e++)0===t[e].width&&(t[e].width=this.columns.defaultSize);super.onLoadedRows(e)}_getBindingColumn(e,o,t){let s=t;if(e!=this.cells)return s;const r=e.rows[o],i=r&&r.dataItem&&r.dataItem._rowInfo;if(wijmo_1.isUndefined(i))return s;s=new wijmo_grid_1.Column;const n=wijmo_grid_1.FlexGrid._getSerializableProperties(wijmo_grid_1.Column);this._copyProps(i,s,n);s.binding=t.binding;s.header=i.header||wijmo_1.toHeaderCase(i.binding);return s}_isTransposed(){return!0}_autoSizeRows(){this.autoSizeMode&wijmo_grid_1.AutoSizeMode.Both&&this.autoSizeRows();super._autoSizeRows()}_copyProps(e,o,t,s=[]){for(const r in e)if(t.indexOf(r)>-1&&-1===s.indexOf(r)){const t=e[r];if(!wijmo_1.isUndefined(t))try{o[r]=t}catch(e){}}}_updateRowHeaders(e,o,t){const s=t.header||wijmo_1.toHeaderCase(t.binding);this.rowHeaders.setCellData(e,o,s);const r=this.rowHeaders.columns;let i=t.width;if(wijmo_1.isNumber(i)&&i>0){const e=t._rng;if(e&&e instanceof wijmo_grid_1.CellRange&&e.isValid){const o=e.columnSpan;wijmo_1.assert(o>0,"Column span is negative or equal to 0");i/=o}r[o].width=Math.max(r[o].width,i)}}_rowInfoChanged(){this._toRowInfo&&clearTimeout(this._toRowInfo);this._toRowInfo=setTimeout(()=>{const e=this.selection,o=this.itemsSource;this.itemsSource=null;this.itemsSource=o;this.selection=e;this.invalidate(!0)},wijmo_1.Control._REFRESH_INTERVAL)}_sourceViewChanged(e,o){this.activeEditor||this.invalidate()}_transposeItemsSource(e){const o=new wijmo_1.ObservableArray,t=wijmo_1.getTypes(e),s=e.map((e,o)=>this._keyPrefix+o);(this.autoGenerateRows?this._getRowInfo(e):this._rowInfo).forEach((r,i)=>{const n=new wijmo_1.Binding(r.binding);if(null==r.dataType&&e.length){const o=n.getValue(e[0]);r.dataType=null!=o?wijmo_1.getType(o):t[i].dataType}if(this._supportsProxies()){const t=this._createProxy(e,r,s);o.push(t)}else{const t=this._createTransposedObject(e,r,this._keyPrefix);o.push(t)}});e instanceof wijmo_1.ObservableArray&&e.collectionChanged.addHandler((e,t)=>{if(t.action===wijmo_1.NotifyCollectionChangedAction.Change)this.activeEditor||this.invalidate();else{const e=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Reset);o.onCollectionChanged(e);this._rowInfoChanged()}});return o}_supportsProxies(){return null!=window.Proxy}_createProxy(e,o,t){const s={_arr:e,_rowInfo:o,_bnd:new wijmo_1.Binding(o.binding),_keys:t};return new Proxy(s,{ownKeys:e=>e._keys,getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0,writable:!0}),get:(e,o)=>{const t=e._keys.indexOf(o);return t>-1?e._bnd.getValue(e._arr[t]):e[o]},set:(e,o,t)=>{const s=e._keys.indexOf(o);if(s>-1){const o=e._arr,r=o[s];e._bnd.setValue(r,t);if(o instanceof wijmo_1.ObservableArray){const e=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change,r,s);o.onCollectionChanged(e)}return!0}return!1}})}_createTransposedObject(e,o,t){const s={_arr:e,_rowInfo:o},r=new wijmo_1.Binding(o.binding);for(let o=0;o<e.length;o++){const i=e[o];Object.defineProperty(s,t+o,{enumerable:!0,get:()=>r.getValue(i),set:t=>{r.setValue(i,t);if(e instanceof wijmo_1.ObservableArray){const t=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change,i,o);e.onCollectionChanged(t)}return!0}})}return s}_getRowInfo(e){const o=[];wijmo_1.getTypes(e).forEach(e=>{const t=e.binding,s=e.dataType;if(s!=wijmo_1.DataType.Object&&s!=wijmo_1.DataType.Array){const e={binding:t,header:wijmo_1.toHeaderCase(t),dataType:s};let r=wijmo_grid_1.FlexGrid._defTypeWidth[s];if(null!=r){if(wijmo_1.isString(r)){const e=Math.round(parseFloat(r));r=r.indexOf("*")<0?e:e*this.columns.defaultSize}wijmo_1.isNumber(r)&&r>0&&(e.width=r)}o.push(e)}});return o}getRowDataItem(e,o){const t=this.cells;if(t.rows[e].dataItem._rowInfo instanceof TransposedGridRow){const e={};for(let s=0;s<t.rows.length;s++){e[t.rows[s].dataItem._rowInfo._binding.path]=t.getCellData(s,o,!1)}return e}return super.getRowDataItem(e,o)}}TransposedGrid._ctrlTemplate="";exports.TransposedGrid=TransposedGrid;class TransposedGridRow extends wijmo_grid_1.Column{get height(){return this._height}set height(e){this._height=e}}exports.TransposedGridRow=TransposedGridRow;class _RowGroupHandler{constructor(e){this._grid=e}get columnGroups(){return null}createColumnGroups(e){this._createRowGroups(e)}hasColumnGroups(){return null!=this._colGroups&&this._colGroups.length>0}getGroupDefinitions(){return this._groupDefs}getColumnGroup(e,o){const t=this._grid;if(o<t.rowHeaders.columns.length&&e<t._rowInfo.length)for(let t=this._colGroups;t;){const s=t;for(let s=0;s<t.length;s++){const r=t[s],i=r._rng;if(i.containsRow(e)){if(i.containsColumn(o)||0==r.columns.length)return r;t=r.columns;break}}if(t==s)break}return null}canMoveColumnGroup(e,o,t,s){return this._grid.columns.canMoveElement(o,s)}moveColumnGroup(e,o,t,s,r){return this._grid.columns.moveElement(o,s)}_createRowGroups(e){const o=this._grid;this._groupDefs=wijmo_1.asArray(e);o.autoGenerateRows=!1;o._rowInfo.clear();this._colGroups=[];e.forEach(e=>{this._colGroups.push(new _RowGroup(e,null))});let t=1;this._colGroups.forEach(e=>{this._addRowGroup(e);t=Math.max(t,e._getMaxLevel())});this._colGroups.forEach(e=>{e._expandRange(t)});const s=o.rowHeaders.columns;s.clear();for(let e=0;e<=t;e++){const o=new wijmo_grid_1.Column;s.splice(e,0,o);e<t&&(o.cssClassAll=wijmo_grid_1.FlexGridClsNames.colGroup)}}_addRowGroup(e){const o=this._grid;e._grid=o;e._rng.row=o._rowInfo.length;0==e.columns.length?o._rowInfo.push(e):e.columns.forEach(e=>{this._addRowGroup(e)});e._rng.row2=o._rowInfo.length-1}}exports._RowGroupHandler=_RowGroupHandler;class _RowGroup extends wijmo_grid_1.Column{constructor(e,o){super();this._rng=new wijmo_grid_1.CellRange(-1,0);this._cols=[];this._lvl=0;this._collapsed=!1;this._pGrp=o;this._lvl=0;for(let e=o;e;e=e._pGrp)this._lvl++;o&&o.columns.indexOf(this)<0&&o.columns.push(this);this._rng.col=this._rng.col2=this._lvl;this.allowDragging=!1;wijmo_1.copy(this,e)}get columns(){return this._cols}set columns(e){this._cols=[];const o=this._cols;e.forEach(e=>{const t=new _RowGroup(e,this);o.indexOf(t)<0&&o.push(t)})}get rows(){return this._cols}get isEmpty(){return 0===this._cols.length}get height(){return this._height}set height(e){this._height=e}get level(){let e=this,o=0;for(;e._pGrp;){e=e._pGrp;o++}return o}get collapseTo(){return this._collTo}set collapseTo(e){wijmo_1.assert(wijmo_1.isArray(e)||wijmo_1.isString(e),"collapseTo should be an array or a string.");this._collTo=e}get isCollapsed(){return this._collapsed}set isCollapsed(e){if(e!=this._collapsed){const o=this._grid;if(o){const t=new wijmo_grid_1.CellRangeEventArgs(o.rowHeaders,this._rng,this);if(o.onColumnGroupCollapsedChanging(t)){this._collapsed=wijmo_1.asBoolean(e);o.onColumnGroupCollapsedChanged(t)}}else this._collapsed=wijmo_1.asBoolean(e)}setTimeout(()=>{this._updateCollapsedState()})}_copy(e,o){if(/rows|columns/.test(e)){const e=wijmo_1.asArray(o);this.columns=e;return!0}return!1}_updateCollapsedState(){const e=this._grid._rowInfo,o=this._rng,t=this._collapsed;this._cols.forEach(e=>{if(e instanceof _RowGroup){e._collapsed=t;e._updateCollapsedState()}});const s=this._getCollapseToIndices();for(let r=o.topRow;r<=o.bottomRow;r++)e[r].visible=!t||s.indexOf(r)>-1}_getMaxLevel(){let e=this._lvl;this.columns.forEach(o=>{e=Math.max(e,o._getMaxLevel())});return e}_expandRange(e){const o=e-this._getMaxLevel();if(o>0){this._rng.col2+=o;this._cols.forEach(e=>{e._shiftRange(o)})}const t=this._grid._rowInfo,s=this._rng;for(let o=s.row;o<=s.row2;o++){t[o]._rng.col2=e}}_shiftRange(e){this._rng.col+=e;this._rng.col2+=e;this._cols.forEach(o=>{o._shiftRange(e)})}_getCollapseToBindings(){const e=this.collapseTo;return wijmo_1.isString(e)?[e]:e}_getCollapseToIndices(){const e=this._grid,o=this._rng,t=this._getCollapseToBindings();if(t&&t.length){const s=[],r=e._rowInfo;for(let e=0;e<t.length;e++)switch(t[e]){case"$first":s.push(o.topRow);break;case"$last":s.push(o.bottomRow);break;default:{const o=r.indexOf(t[e]);o>-1&&s.push(o);break}}if(s.length)return s}return[o.bottomRow]}}exports._RowGroup=_RowGroup;wijmo_1._registerModule("wijmo.grid.transposed",selfModule);
|
package/es2015-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t014601
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
import{MergeManager,CellRange,FlexGrid,Row,Column,ColumnCollection,CellRangeEventArgs,AllowSorting,HeadersVisibility,AutoSizeMode,FlexGridClsNames}from"@mescius/wijmo.grid";import{asArray,assert,isArray,isString,isNumber,isUndefined,asBoolean,getTypes,getType,tryCast,toHeaderCase,addClass,DataType,Binding,Control,CollectionView,ObservableArray,NotifyCollectionChangedEventArgs,NotifyCollectionChangedAction,copy,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.grid.transposed";export const TransposedGridClsNames={hostElement:"wj-transposed-grid"};export class _MergeManager extends MergeManager{getMergedRange(e,t,o,r=!0){let s=e.grid,n=s._hasColumnGroups();if(e==s.columnHeaders&&n)return null;if(e==s.rowHeaders&&n){if(t<0||t>=e.rows.length||o<0||o>=e.columns.length)return null;let r=s._getColumnGroup(t,o);if(r){let o=r._rng,s=e.rows;if(s.isFrozen(o.row)!=s.isFrozen(o.row2)){o=o.clone();s.isFrozen(t)?o.row2=s._frozenInternal-1:o.row=s._frozenInternal}return o}return null}return super.getMergedRange(e,t,o,r)}}export class TransposedGrid extends FlexGrid{constructor(e,t){super(e,null);this._keyPrefix="item";this._autoGenRows=!0;addClass(this.hostElement,TransposedGridClsNames.hostElement);this.allowSorting=AllowSorting.None;this.headersVisibility=HeadersVisibility.Row;this._rowInfo=new ColumnCollection(this,this.columns.defaultSize);this._grpHdl=new _RowGroupHandler(this);this.mergeManager=new _MergeManager;this.initialize(t);this._rowInfo.collectionChanged.addHandler(this._rowInfoChanged,this);this.deferUpdate(()=>{let e=this.rowHeaders.columns;if(e.length){e[e.length-1].width=this.columns.defaultSize}})}static get controlTemplate(){TransposedGrid._ctrlTemplate||(TransposedGrid._ctrlTemplate=FlexGrid.controlTemplate);return TransposedGrid._ctrlTemplate}static set controlTemplate(e){TransposedGrid._ctrlTemplate=e}get autoGenerateRows(){return this._autoGenRows}set autoGenerateRows(e){this._autoGenRows=asBoolean(e)}get rowGroups(){return this._grpHdl.getGroupDefinitions()}set rowGroups(e){this._rowInfo.deferUpdate(()=>{this.autoGenerateRows=!1;this._rowInfo.clear();this._grpHdl.createColumnGroups(asArray(e))})}refresh(e){let t=this._rowInfo;if(t._dirty){t._dirty=!1;this._rowInfoChanged()}else super.refresh(e)}get allowAddNew(){return!1}set allowAddNew(e){}get allowDelete(){return!1}set allowDelete(e){}get allowSorting(){return AllowSorting.None}set allowSorting(e){assert(e===AllowSorting.None,"TransposedGrid does not support sorting.");this._alSorting=e}get columnGroups(){return null}set columnGroups(e){throw"TransposedGrid does not support columnGroups, use rowGroups instead."}onRowEditEnded(e){let t=tryCast(this._sourceItems,"ICollectionView");if(t){let e=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change);t.collectionChanged.raise(t,e)}super.onRowEditEnded(e)}_getCollectionView(e){let t=tryCast(this._sourceItems,"ICollectionView");t&&t.collectionChanged.removeHandler(this._sourceViewChanged);t=tryCast(e,"ICollectionView");let o=e;if(isArray(e))o=this._transposeItemsSource(e);else if(t){t.collectionChanged.addHandler(this._sourceViewChanged,this);o=this._transposeItemsSource(t.items)}this.autoGenerateColumns=!0;let r=super._getCollectionView(o),s=null;t instanceof CollectionView&&(s=t.getError);s&&r instanceof CollectionView&&(this._supportsProxies()?r.getError=(e,t)=>{if(null==t)return null;let o=e._keys.indexOf(t);return s(e._arr[o],e._bnd.path)}:r.getError=(e,t)=>{if(null==t)return null;let o=parseInt(t.substr(this._keyPrefix.length));return s(e._arr[o],e._rowInfo.binding)});this._sourceItems=e;return r}_getColumnTypes(e){let t,o;if(this._sourceItems)if(isArray(this._sourceItems))o=this._sourceItems;else{let e=tryCast(this._sourceItems,"ICollectionView");e&&(o=e.items)}t=o?o.map((e,t)=>({binding:this._keyPrefix+t,dataType:DataType.Object})):getTypes(e);return t}_copy(e,t){if(/rows|columns/.test(e)){assert(isArray(t),"Array Expected.");let e=asArray(t);e.some(e=>null!=e.columns)?this.rowGroups=e:this._rowInfo.deferUpdate(()=>{this.autoGenerateRows=!1;this._rowInfo.clear();t.forEach(e=>{let t=new TransposedGridRow(e);this._rowInfo.push(t)})});return!0}return super._copy(e,t)}onLoadedRows(e){let t=this.columns;for(let e=0;e<t.length;e++){let o=t[e];o.align=null;o.dataType=0}let o=this.rowHeaders.columns;for(let e=0;e<o.length;e++){o[e].align="left";o[e].width=0}let r=FlexGrid._getSerializableProperties(Row);this.rows.forEach(e=>{let t=e.dataItem._rowInfo;if(t){this._copyProps(t,e,r,["showDropDown","width","size"]);if(this._hasColumnGroups())for(let t=0;t<o.length;t++){let o=this._grpHdl.getColumnGroup(e.index,t);o&&this._updateRowHeaders(e.index,t,o)}else o.length&&this._updateRowHeaders(e.index,o.length-1,t)}});for(let e=0;e<o.length;e++)0===o[e].width&&(o[e].width=this.columns.defaultSize);super.onLoadedRows(e)}_getBindingColumn(e,t,o){let r=o;if(e!=this.cells)return r;let s=e.rows[t],n=s&&s.dataItem&&s.dataItem._rowInfo;if(isUndefined(n))return r;r=new Column;let i=FlexGrid._getSerializableProperties(Column);this._copyProps(n,r,i);r.binding=o.binding;r.header=n.header||toHeaderCase(n.binding);return r}_isTransposed(){return!0}_autoSizeRows(){this.autoSizeMode&AutoSizeMode.Both&&this.autoSizeRows();super._autoSizeRows()}_copyProps(e,t,o,r=[]){for(let s in e)if(o.indexOf(s)>-1&&-1===r.indexOf(s)){let o=e[s];if(!isUndefined(o))try{t[s]=o}catch(e){}}}_updateRowHeaders(e,t,o){let r=o.header||toHeaderCase(o.binding);this.rowHeaders.setCellData(e,t,r);let s=this.rowHeaders.columns,n=o.width;if(isNumber(n)&&n>0){let e=o._rng;if(e&&e instanceof CellRange&&e.isValid){let t=e.columnSpan;assert(t>0,"Column span is negative or equal to 0");n/=t}s[t].width=Math.max(s[t].width,n)}}_rowInfoChanged(){this._toRowInfo&&clearTimeout(this._toRowInfo);this._toRowInfo=setTimeout(()=>{let e=this.selection,t=this.itemsSource;this.itemsSource=null;this.itemsSource=t;this.selection=e;this.invalidate(!0)},Control._REFRESH_INTERVAL)}_sourceViewChanged(e,t){this.activeEditor||this.invalidate()}_transposeItemsSource(e){let t=new ObservableArray,o=getTypes(e),r=e.map((e,t)=>this._keyPrefix+t);(this.autoGenerateRows?this._getRowInfo(e):this._rowInfo).forEach((s,n)=>{let i=new Binding(s.binding);if(null==s.dataType&&e.length){let t=i.getValue(e[0]);s.dataType=null!=t?getType(t):o[n].dataType}if(this._supportsProxies()){let o=this._createProxy(e,s,r);t.push(o)}else{let o=this._createTransposedObject(e,s,this._keyPrefix);t.push(o)}});e instanceof ObservableArray&&e.collectionChanged.addHandler((e,o)=>{if(o.action===NotifyCollectionChangedAction.Change)this.activeEditor||this.invalidate();else{let e=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);t.onCollectionChanged(e);this._rowInfoChanged()}});return t}_supportsProxies(){return null!=window.Proxy}_createProxy(e,t,o){let r={_arr:e,_rowInfo:t,_bnd:new Binding(t.binding),_keys:o};return new Proxy(r,{ownKeys:e=>e._keys,getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0,writable:!0}),get:(e,t)=>{let o=e._keys.indexOf(t);return o>-1?e._bnd.getValue(e._arr[o]):e[t]},set:(e,t,o)=>{let r=e._keys.indexOf(t);if(r>-1){let t=e._arr,s=t[r];e._bnd.setValue(s,o);if(t instanceof ObservableArray){let e=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,s,r);t.onCollectionChanged(e)}return!0}return!1}})}_createTransposedObject(e,t,o){let r={_arr:e,_rowInfo:t},s=new Binding(t.binding);for(let t=0;t<e.length;t++){let n=e[t];Object.defineProperty(r,o+t,{enumerable:!0,get:()=>s.getValue(n),set:o=>{s.setValue(n,o);if(e instanceof ObservableArray){let o=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,n,t);e.onCollectionChanged(o)}return!0}})}return r}_getRowInfo(e){let t=[];getTypes(e).forEach(e=>{let o=e.binding,r=e.dataType;if(r!=DataType.Object&&r!=DataType.Array){let e={binding:o,header:toHeaderCase(o),dataType:r},s=FlexGrid._defTypeWidth[r];if(null!=s){if(isString(s)){let e=Math.round(parseFloat(s));s=s.indexOf("*")<0?e:e*this.columns.defaultSize}isNumber(s)&&s>0&&(e.width=s)}t.push(e)}});return t}getRowDataItem(e,t){let o=this.cells;if(o.rows[e].dataItem._rowInfo instanceof TransposedGridRow){let e={};for(let r=0;r<o.rows.length;r++){e[o.rows[r].dataItem._rowInfo._binding.path]=o.getCellData(r,t,!1)}return e}return super.getRowDataItem(e,t)}}TransposedGrid._ctrlTemplate="";export class TransposedGridRow extends Column{get height(){return this._height}set height(e){this._height=e}}export class _RowGroupHandler{constructor(e){this._grid=e}get columnGroups(){return null}createColumnGroups(e){this._createRowGroups(e)}hasColumnGroups(){return null!=this._colGroups&&this._colGroups.length>0}getGroupDefinitions(){return this._groupDefs}getColumnGroup(e,t){let o=this._grid;if(t<o.rowHeaders.columns.length&&e<o._rowInfo.length)for(let o=this._colGroups;o;){let r=o;for(let r=0;r<o.length;r++){let s=o[r],n=s._rng;if(n.containsRow(e)){if(n.containsColumn(t)||0==s.columns.length)return s;o=s.columns;break}}if(o==r)break}return null}canMoveColumnGroup(e,t,o,r){return this._grid.columns.canMoveElement(t,r)}moveColumnGroup(e,t,o,r,s){return this._grid.columns.moveElement(t,r)}_createRowGroups(e){let t=this._grid;this._groupDefs=asArray(e);t.autoGenerateRows=!1;t._rowInfo.clear();this._colGroups=[];e.forEach(e=>{this._colGroups.push(new _RowGroup(e,null))});let o=1;this._colGroups.forEach(e=>{this._addRowGroup(e);o=Math.max(o,e._getMaxLevel())});this._colGroups.forEach(e=>{e._expandRange(o)});let r=t.rowHeaders.columns;r.clear();for(let e=0;e<=o;e++){let t=new Column;r.splice(e,0,t);e<o&&(t.cssClassAll=FlexGridClsNames.colGroup)}}_addRowGroup(e){let t=this._grid;e._grid=t;e._rng.row=t._rowInfo.length;0==e.columns.length?t._rowInfo.push(e):e.columns.forEach(e=>{this._addRowGroup(e)});e._rng.row2=t._rowInfo.length-1}}export class _RowGroup extends Column{constructor(e,t){super();this._rng=new CellRange(-1,0);this._cols=[];this._lvl=0;this._collapsed=!1;this._pGrp=t;this._lvl=0;for(let e=t;e;e=e._pGrp)this._lvl++;t&&t.columns.indexOf(this)<0&&t.columns.push(this);this._rng.col=this._rng.col2=this._lvl;this.allowDragging=!1;copy(this,e)}get columns(){return this._cols}set columns(e){let t=this._cols=[];e.forEach(e=>{let o=new _RowGroup(e,this);t.indexOf(o)<0&&t.push(o)})}get rows(){return this._cols}get isEmpty(){return 0===this._cols.length}get height(){return this._height}set height(e){this._height=e}get level(){let e=this,t=0;for(;e._pGrp;){e=e._pGrp;t++}return t}get collapseTo(){return this._collTo}set collapseTo(e){assert(isArray(e)||isString(e),"collapseTo should be an array or a string.");this._collTo=e}get isCollapsed(){return this._collapsed}set isCollapsed(e){if(e!=this._collapsed){let t=this._grid;if(t){let o=new CellRangeEventArgs(t.rowHeaders,this._rng,this);if(t.onColumnGroupCollapsedChanging(o)){this._collapsed=asBoolean(e);t.onColumnGroupCollapsedChanged(o)}}else this._collapsed=asBoolean(e)}setTimeout(()=>{this._updateCollapsedState()})}_copy(e,t){if(/rows|columns/.test(e)){let e=asArray(t);this.columns=e;return!0}return!1}_updateCollapsedState(){let e=this._grid._rowInfo,t=this._rng,o=this._collapsed;this._cols.forEach(e=>{if(e instanceof _RowGroup){e._collapsed=o;e._updateCollapsedState()}});let r=this._getCollapseToIndices();for(let s=t.topRow;s<=t.bottomRow;s++)e[s].visible=!o||r.indexOf(s)>-1}_getMaxLevel(){let e=this._lvl;this.columns.forEach(t=>{e=Math.max(e,t._getMaxLevel())});return e}_expandRange(e){let t=e-this._getMaxLevel();if(t>0){this._rng.col2+=t;this._cols.forEach(e=>{e._shiftRange(t)})}let o=this._grid._rowInfo,r=this._rng;for(let t=r.row;t<=r.row2;t++){o[t]._rng.col2=e}}_shiftRange(e){this._rng.col+=e;this._rng.col2+=e;this._cols.forEach(t=>{t._shiftRange(e)})}_getCollapseToBindings(){let e=this.collapseTo;return isString(e)?[e]:e}_getCollapseToIndices(){let e=this._grid,t=this._rng,o=this._getCollapseToBindings();if(o&&o.length){let r=[],s=e._rowInfo;for(let e=0;e<o.length;e++)switch(o[e]){case"$first":r.push(t.topRow);break;case"$last":r.push(t.bottomRow);break;default:let n=s.indexOf(o[e]);n>-1&&r.push(n)}if(r.length)return r}return[t.bottomRow]}}_registerModule("wijmo.grid.transposed",selfModule);
|
|
14
|
+
import{MergeManager,CellRange,FlexGrid,Row,Column,ColumnCollection,CellRangeEventArgs,AllowSorting,HeadersVisibility,AutoSizeMode,FlexGridClsNames}from"@mescius/wijmo.grid";import{asArray,assert,isArray,isString,isNumber,isUndefined,asBoolean,getTypes,getType,tryCast,toHeaderCase,addClass,DataType,Binding,Control,CollectionView,ObservableArray,NotifyCollectionChangedEventArgs,NotifyCollectionChangedAction,copy,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.grid.transposed";export const TransposedGridClsNames={hostElement:"wj-transposed-grid"};export class _MergeManager extends MergeManager{getMergedRange(e,t,o,s=!0){const r=e.grid,n=r._hasColumnGroups();if(e==r.columnHeaders&&n)return null;if(e==r.rowHeaders&&n){if(t<0||t>=e.rows.length||o<0||o>=e.columns.length)return null;const s=r._getColumnGroup(t,o);if(s){let o=s._rng,r=e.rows;if(r.isFrozen(o.row)!=r.isFrozen(o.row2)){o=o.clone();r.isFrozen(t)?o.row2=r._frozenInternal-1:o.row=r._frozenInternal}return o}return null}return super.getMergedRange(e,t,o,s)}}export class TransposedGrid extends FlexGrid{constructor(e,t){super(e,null);this._keyPrefix="item";this._autoGenRows=!0;addClass(this.hostElement,TransposedGridClsNames.hostElement);this.allowSorting=AllowSorting.None;this.headersVisibility=HeadersVisibility.Row;this._rowInfo=new ColumnCollection(this,this.columns.defaultSize);this._grpHdl=new _RowGroupHandler(this);this.mergeManager=new _MergeManager;this.initialize(t);this._rowInfo.collectionChanged.addHandler(this._rowInfoChanged,this);this.deferUpdate(()=>{const e=this.rowHeaders.columns;if(e.length){e[e.length-1].width=this.columns.defaultSize}})}static get controlTemplate(){TransposedGrid._ctrlTemplate||(TransposedGrid._ctrlTemplate=FlexGrid.controlTemplate);return TransposedGrid._ctrlTemplate}static set controlTemplate(e){TransposedGrid._ctrlTemplate=e}get autoGenerateRows(){return this._autoGenRows}set autoGenerateRows(e){this._autoGenRows=asBoolean(e)}get rowGroups(){return this._grpHdl.getGroupDefinitions()}set rowGroups(e){this._rowInfo.deferUpdate(()=>{this.autoGenerateRows=!1;this._rowInfo.clear();this._grpHdl.createColumnGroups(asArray(e))})}refresh(e){const t=this._rowInfo;if(t._dirty){t._dirty=!1;this._rowInfoChanged()}else super.refresh(e)}get allowAddNew(){return!1}set allowAddNew(e){}get allowDelete(){return!1}set allowDelete(e){}get allowSorting(){return AllowSorting.None}set allowSorting(e){assert(e===AllowSorting.None,"TransposedGrid does not support sorting.");this._alSorting=e}get columnGroups(){return null}set columnGroups(e){throw"TransposedGrid does not support columnGroups, use rowGroups instead."}onRowEditEnded(e){const t=tryCast(this._sourceItems,"ICollectionView");if(t){const e=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change);t.collectionChanged.raise(t,e)}super.onRowEditEnded(e)}_getCollectionView(e){let t=tryCast(this._sourceItems,"ICollectionView");t&&t.collectionChanged.removeHandler(this._sourceViewChanged);t=tryCast(e,"ICollectionView");let o=e;if(isArray(e))o=this._transposeItemsSource(e);else if(t){t.collectionChanged.addHandler(this._sourceViewChanged,this);o=this._transposeItemsSource(t.items)}this.autoGenerateColumns=!0;const s=super._getCollectionView(o);let r=null;t instanceof CollectionView&&(r=t.getError);r&&s instanceof CollectionView&&(this._supportsProxies()?s.getError=(e,t)=>{if(null==t)return null;const o=e._keys.indexOf(t);return r(e._arr[o],e._bnd.path)}:s.getError=(e,t)=>{if(null==t)return null;const o=parseInt(t.substr(this._keyPrefix.length));return r(e._arr[o],e._rowInfo.binding)});this._sourceItems=e;return s}_getColumnTypes(e){let t,o;if(this._sourceItems)if(isArray(this._sourceItems))o=this._sourceItems;else{const e=tryCast(this._sourceItems,"ICollectionView");e&&(o=e.items)}t=o?o.map((e,t)=>({binding:this._keyPrefix+t,dataType:DataType.Object})):getTypes(e);return t}_copy(e,t){if(/rows|columns/.test(e)){assert(isArray(t),"Array Expected.");const e=asArray(t);e.some(e=>null!=e.columns)?this.rowGroups=e:this._rowInfo.deferUpdate(()=>{this.autoGenerateRows=!1;this._rowInfo.clear();t.forEach(e=>{const t=new TransposedGridRow(e);this._rowInfo.push(t)})});return!0}return super._copy(e,t)}onLoadedRows(e){const t=this.columns;for(let e=0;e<t.length;e++){const o=t[e];o.align=null;o.dataType=0}const o=this.rowHeaders.columns;for(let e=0;e<o.length;e++){o[e].align="left";o[e].width=0}const s=FlexGrid._getSerializableProperties(Row);this.rows.forEach(e=>{const t=e.dataItem._rowInfo;if(t){this._copyProps(t,e,s,["showDropDown","width","size"]);if(this._hasColumnGroups())for(let t=0;t<o.length;t++){const o=this._grpHdl.getColumnGroup(e.index,t);o&&this._updateRowHeaders(e.index,t,o)}else o.length&&this._updateRowHeaders(e.index,o.length-1,t)}});for(let e=0;e<o.length;e++)0===o[e].width&&(o[e].width=this.columns.defaultSize);super.onLoadedRows(e)}_getBindingColumn(e,t,o){let s=o;if(e!=this.cells)return s;const r=e.rows[t],n=r&&r.dataItem&&r.dataItem._rowInfo;if(isUndefined(n))return s;s=new Column;const i=FlexGrid._getSerializableProperties(Column);this._copyProps(n,s,i);s.binding=o.binding;s.header=n.header||toHeaderCase(n.binding);return s}_isTransposed(){return!0}_autoSizeRows(){this.autoSizeMode&AutoSizeMode.Both&&this.autoSizeRows();super._autoSizeRows()}_copyProps(e,t,o,s=[]){for(const r in e)if(o.indexOf(r)>-1&&-1===s.indexOf(r)){const o=e[r];if(!isUndefined(o))try{t[r]=o}catch(e){}}}_updateRowHeaders(e,t,o){const s=o.header||toHeaderCase(o.binding);this.rowHeaders.setCellData(e,t,s);const r=this.rowHeaders.columns;let n=o.width;if(isNumber(n)&&n>0){const e=o._rng;if(e&&e instanceof CellRange&&e.isValid){const t=e.columnSpan;assert(t>0,"Column span is negative or equal to 0");n/=t}r[t].width=Math.max(r[t].width,n)}}_rowInfoChanged(){this._toRowInfo&&clearTimeout(this._toRowInfo);this._toRowInfo=setTimeout(()=>{const e=this.selection,t=this.itemsSource;this.itemsSource=null;this.itemsSource=t;this.selection=e;this.invalidate(!0)},Control._REFRESH_INTERVAL)}_sourceViewChanged(e,t){this.activeEditor||this.invalidate()}_transposeItemsSource(e){const t=new ObservableArray,o=getTypes(e),s=e.map((e,t)=>this._keyPrefix+t);(this.autoGenerateRows?this._getRowInfo(e):this._rowInfo).forEach((r,n)=>{const i=new Binding(r.binding);if(null==r.dataType&&e.length){const t=i.getValue(e[0]);r.dataType=null!=t?getType(t):o[n].dataType}if(this._supportsProxies()){const o=this._createProxy(e,r,s);t.push(o)}else{const o=this._createTransposedObject(e,r,this._keyPrefix);t.push(o)}});e instanceof ObservableArray&&e.collectionChanged.addHandler((e,o)=>{if(o.action===NotifyCollectionChangedAction.Change)this.activeEditor||this.invalidate();else{const e=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);t.onCollectionChanged(e);this._rowInfoChanged()}});return t}_supportsProxies(){return null!=window.Proxy}_createProxy(e,t,o){const s={_arr:e,_rowInfo:t,_bnd:new Binding(t.binding),_keys:o};return new Proxy(s,{ownKeys:e=>e._keys,getOwnPropertyDescriptor:()=>({enumerable:!0,configurable:!0,writable:!0}),get:(e,t)=>{const o=e._keys.indexOf(t);return o>-1?e._bnd.getValue(e._arr[o]):e[t]},set:(e,t,o)=>{const s=e._keys.indexOf(t);if(s>-1){const t=e._arr,r=t[s];e._bnd.setValue(r,o);if(t instanceof ObservableArray){const e=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,r,s);t.onCollectionChanged(e)}return!0}return!1}})}_createTransposedObject(e,t,o){const s={_arr:e,_rowInfo:t},r=new Binding(t.binding);for(let t=0;t<e.length;t++){const n=e[t];Object.defineProperty(s,o+t,{enumerable:!0,get:()=>r.getValue(n),set:o=>{r.setValue(n,o);if(e instanceof ObservableArray){const o=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,n,t);e.onCollectionChanged(o)}return!0}})}return s}_getRowInfo(e){const t=[];getTypes(e).forEach(e=>{const o=e.binding,s=e.dataType;if(s!=DataType.Object&&s!=DataType.Array){const e={binding:o,header:toHeaderCase(o),dataType:s};let r=FlexGrid._defTypeWidth[s];if(null!=r){if(isString(r)){const e=Math.round(parseFloat(r));r=r.indexOf("*")<0?e:e*this.columns.defaultSize}isNumber(r)&&r>0&&(e.width=r)}t.push(e)}});return t}getRowDataItem(e,t){const o=this.cells;if(o.rows[e].dataItem._rowInfo instanceof TransposedGridRow){const e={};for(let s=0;s<o.rows.length;s++){e[o.rows[s].dataItem._rowInfo._binding.path]=o.getCellData(s,t,!1)}return e}return super.getRowDataItem(e,t)}}TransposedGrid._ctrlTemplate="";export class TransposedGridRow extends Column{get height(){return this._height}set height(e){this._height=e}}export class _RowGroupHandler{constructor(e){this._grid=e}get columnGroups(){return null}createColumnGroups(e){this._createRowGroups(e)}hasColumnGroups(){return null!=this._colGroups&&this._colGroups.length>0}getGroupDefinitions(){return this._groupDefs}getColumnGroup(e,t){const o=this._grid;if(t<o.rowHeaders.columns.length&&e<o._rowInfo.length)for(let o=this._colGroups;o;){const s=o;for(let s=0;s<o.length;s++){const r=o[s],n=r._rng;if(n.containsRow(e)){if(n.containsColumn(t)||0==r.columns.length)return r;o=r.columns;break}}if(o==s)break}return null}canMoveColumnGroup(e,t,o,s){return this._grid.columns.canMoveElement(t,s)}moveColumnGroup(e,t,o,s,r){return this._grid.columns.moveElement(t,s)}_createRowGroups(e){const t=this._grid;this._groupDefs=asArray(e);t.autoGenerateRows=!1;t._rowInfo.clear();this._colGroups=[];e.forEach(e=>{this._colGroups.push(new _RowGroup(e,null))});let o=1;this._colGroups.forEach(e=>{this._addRowGroup(e);o=Math.max(o,e._getMaxLevel())});this._colGroups.forEach(e=>{e._expandRange(o)});const s=t.rowHeaders.columns;s.clear();for(let e=0;e<=o;e++){const t=new Column;s.splice(e,0,t);e<o&&(t.cssClassAll=FlexGridClsNames.colGroup)}}_addRowGroup(e){const t=this._grid;e._grid=t;e._rng.row=t._rowInfo.length;0==e.columns.length?t._rowInfo.push(e):e.columns.forEach(e=>{this._addRowGroup(e)});e._rng.row2=t._rowInfo.length-1}}export class _RowGroup extends Column{constructor(e,t){super();this._rng=new CellRange(-1,0);this._cols=[];this._lvl=0;this._collapsed=!1;this._pGrp=t;this._lvl=0;for(let e=t;e;e=e._pGrp)this._lvl++;t&&t.columns.indexOf(this)<0&&t.columns.push(this);this._rng.col=this._rng.col2=this._lvl;this.allowDragging=!1;copy(this,e)}get columns(){return this._cols}set columns(e){this._cols=[];const t=this._cols;e.forEach(e=>{const o=new _RowGroup(e,this);t.indexOf(o)<0&&t.push(o)})}get rows(){return this._cols}get isEmpty(){return 0===this._cols.length}get height(){return this._height}set height(e){this._height=e}get level(){let e=this,t=0;for(;e._pGrp;){e=e._pGrp;t++}return t}get collapseTo(){return this._collTo}set collapseTo(e){assert(isArray(e)||isString(e),"collapseTo should be an array or a string.");this._collTo=e}get isCollapsed(){return this._collapsed}set isCollapsed(e){if(e!=this._collapsed){const t=this._grid;if(t){const o=new CellRangeEventArgs(t.rowHeaders,this._rng,this);if(t.onColumnGroupCollapsedChanging(o)){this._collapsed=asBoolean(e);t.onColumnGroupCollapsedChanged(o)}}else this._collapsed=asBoolean(e)}setTimeout(()=>{this._updateCollapsedState()})}_copy(e,t){if(/rows|columns/.test(e)){const e=asArray(t);this.columns=e;return!0}return!1}_updateCollapsedState(){const e=this._grid._rowInfo,t=this._rng,o=this._collapsed;this._cols.forEach(e=>{if(e instanceof _RowGroup){e._collapsed=o;e._updateCollapsedState()}});const s=this._getCollapseToIndices();for(let r=t.topRow;r<=t.bottomRow;r++)e[r].visible=!o||s.indexOf(r)>-1}_getMaxLevel(){let e=this._lvl;this.columns.forEach(t=>{e=Math.max(e,t._getMaxLevel())});return e}_expandRange(e){const t=e-this._getMaxLevel();if(t>0){this._rng.col2+=t;this._cols.forEach(e=>{e._shiftRange(t)})}const o=this._grid._rowInfo,s=this._rng;for(let t=s.row;t<=s.row2;t++){o[t]._rng.col2=e}}_shiftRange(e){this._rng.col+=e;this._rng.col2+=e;this._cols.forEach(t=>{t._shiftRange(e)})}_getCollapseToBindings(){const e=this.collapseTo;return isString(e)?[e]:e}_getCollapseToIndices(){const e=this._grid,t=this._rng,o=this._getCollapseToBindings();if(o&&o.length){const s=[],r=e._rowInfo;for(let e=0;e<o.length;e++)switch(o[e]){case"$first":s.push(t.topRow);break;case"$last":s.push(t.bottomRow);break;default:{const t=r.indexOf(o[e]);t>-1&&s.push(t);break}}if(s.length)return s}return[t.bottomRow]}}_registerModule("wijmo.grid.transposed",selfModule);
|
package/es5-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t014601
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
var __extends=this&&this.__extends||function(){var extendStatics=function(e,o){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r])})(e,o)};return function(e,o){extendStatics(e,o);function __(){this.constructor=e}e.prototype=null===o?Object.create(o):(__.prototype=o.prototype,new __)}}();import{MergeManager,CellRange,FlexGrid,Row,Column,ColumnCollection,CellRangeEventArgs,AllowSorting,HeadersVisibility,AutoSizeMode,FlexGridClsNames}from"@mescius/wijmo.grid";import{asArray,assert,isArray,isString,isNumber,isUndefined,asBoolean,getTypes,getType,tryCast,toHeaderCase,addClass,DataType,Binding,Control,CollectionView,ObservableArray,NotifyCollectionChangedEventArgs,NotifyCollectionChangedAction,copy,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.grid.transposed";export var TransposedGridClsNames={hostElement:"wj-transposed-grid"};var _MergeManager=function(e){__extends(_MergeManager,e);function _MergeManager(){return null!==e&&e.apply(this,arguments)||this}_MergeManager.prototype.getMergedRange=function(o,r,t,n){void 0===n&&(n=!0);var i=o.grid,s=i._hasColumnGroups();if(o==i.columnHeaders&&s)return null;if(o==i.rowHeaders&&s){if(r<0||r>=o.rows.length||t<0||t>=o.columns.length)return null;var a=i._getColumnGroup(r,t);if(a){var l=a._rng,u=o.rows;if(u.isFrozen(l.row)!=u.isFrozen(l.row2)){l=l.clone();u.isFrozen(r)?l.row2=u._frozenInternal-1:l.row=u._frozenInternal}return l}return null}return e.prototype.getMergedRange.call(this,o,r,t,n)};return _MergeManager}(MergeManager);export{_MergeManager};var TransposedGrid=function(e){__extends(TransposedGrid,e);function TransposedGrid(o,r){var t=e.call(this,o,null)||this;t._keyPrefix="item";t._autoGenRows=!0;addClass(t.hostElement,TransposedGridClsNames.hostElement);t.allowSorting=AllowSorting.None;t.headersVisibility=HeadersVisibility.Row;t._rowInfo=new ColumnCollection(t,t.columns.defaultSize);t._grpHdl=new _RowGroupHandler(t);t.mergeManager=new _MergeManager;t.initialize(r);t._rowInfo.collectionChanged.addHandler(t._rowInfoChanged,t);t.deferUpdate((function(){var e=t.rowHeaders.columns;if(e.length){e[e.length-1].width=t.columns.defaultSize}}));return t}Object.defineProperty(TransposedGrid,"controlTemplate",{get:function(){TransposedGrid._ctrlTemplate||(TransposedGrid._ctrlTemplate=FlexGrid.controlTemplate);return TransposedGrid._ctrlTemplate},set:function(e){TransposedGrid._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"autoGenerateRows",{get:function(){return this._autoGenRows},set:function(e){this._autoGenRows=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"rowGroups",{get:function(){return this._grpHdl.getGroupDefinitions()},set:function(e){var o=this;this._rowInfo.deferUpdate((function(){o.autoGenerateRows=!1;o._rowInfo.clear();o._grpHdl.createColumnGroups(asArray(e))}))},enumerable:!0,configurable:!0});TransposedGrid.prototype.refresh=function(o){var r=this._rowInfo;if(r._dirty){r._dirty=!1;this._rowInfoChanged()}else e.prototype.refresh.call(this,o)};Object.defineProperty(TransposedGrid.prototype,"allowAddNew",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"allowDelete",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"allowSorting",{get:function(){return AllowSorting.None},set:function(e){assert(e===AllowSorting.None,"TransposedGrid does not support sorting.");this._alSorting=e},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"columnGroups",{get:function(){return null},set:function(e){throw"TransposedGrid does not support columnGroups, use rowGroups instead."},enumerable:!0,configurable:!0});TransposedGrid.prototype.onRowEditEnded=function(o){var r=tryCast(this._sourceItems,"ICollectionView");if(r){var t=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change);r.collectionChanged.raise(r,t)}e.prototype.onRowEditEnded.call(this,o)};TransposedGrid.prototype._getCollectionView=function(o){var r=this,t=tryCast(this._sourceItems,"ICollectionView");t&&t.collectionChanged.removeHandler(this._sourceViewChanged);t=tryCast(o,"ICollectionView");var n=o;if(isArray(o))n=this._transposeItemsSource(o);else if(t){t.collectionChanged.addHandler(this._sourceViewChanged,this);n=this._transposeItemsSource(t.items)}this.autoGenerateColumns=!0;var i=e.prototype._getCollectionView.call(this,n),s=null;t instanceof CollectionView&&(s=t.getError);s&&i instanceof CollectionView&&(this._supportsProxies()?i.getError=function(e,o){if(null==o)return null;var r=e._keys.indexOf(o);return s(e._arr[r],e._bnd.path)}:i.getError=function(e,o){if(null==o)return null;var t=parseInt(o.substr(r._keyPrefix.length));return s(e._arr[t],e._rowInfo.binding)});this._sourceItems=o;return i};TransposedGrid.prototype._getColumnTypes=function(e){var o,r=this;if(this._sourceItems)if(isArray(this._sourceItems))o=this._sourceItems;else{var t=tryCast(this._sourceItems,"ICollectionView");t&&(o=t.items)}return o?o.map((function(e,o){return{binding:r._keyPrefix+o,dataType:DataType.Object}})):getTypes(e)};TransposedGrid.prototype._copy=function(o,r){var t=this;if(/rows|columns/.test(o)){assert(isArray(r),"Array Expected.");var n=asArray(r);n.some((function(e){return null!=e.columns}))?this.rowGroups=n:this._rowInfo.deferUpdate((function(){t.autoGenerateRows=!1;t._rowInfo.clear();r.forEach((function(e){var o=new TransposedGridRow(e);t._rowInfo.push(o)}))}));return!0}return e.prototype._copy.call(this,o,r)};TransposedGrid.prototype.onLoadedRows=function(o){for(var r=this,t=this.columns,n=0;n<t.length;n++){var i=t[n];i.align=null;i.dataType=0}var s=this.rowHeaders.columns;for(n=0;n<s.length;n++){s[n].align="left";s[n].width=0}var a=FlexGrid._getSerializableProperties(Row);this.rows.forEach((function(e){var o=e.dataItem._rowInfo;if(o){r._copyProps(o,e,a,["showDropDown","width","size"]);if(r._hasColumnGroups())for(var t=0;t<s.length;t++){var n=r._grpHdl.getColumnGroup(e.index,t);n&&r._updateRowHeaders(e.index,t,n)}else s.length&&r._updateRowHeaders(e.index,s.length-1,o)}}));for(n=0;n<s.length;n++)0===s[n].width&&(s[n].width=this.columns.defaultSize);e.prototype.onLoadedRows.call(this,o)};TransposedGrid.prototype._getBindingColumn=function(e,o,r){var t=r;if(e!=this.cells)return t;var n=e.rows[o],i=n&&n.dataItem&&n.dataItem._rowInfo;if(isUndefined(i))return t;t=new Column;var s=FlexGrid._getSerializableProperties(Column);this._copyProps(i,t,s);t.binding=r.binding;t.header=i.header||toHeaderCase(i.binding);return t};TransposedGrid.prototype._isTransposed=function(){return!0};TransposedGrid.prototype._autoSizeRows=function(){this.autoSizeMode&AutoSizeMode.Both&&this.autoSizeRows();e.prototype._autoSizeRows.call(this)};TransposedGrid.prototype._copyProps=function(e,o,r,t){void 0===t&&(t=[]);for(var n in e)if(r.indexOf(n)>-1&&-1===t.indexOf(n)){var i=e[n];if(!isUndefined(i))try{o[n]=i}catch(e){}}};TransposedGrid.prototype._updateRowHeaders=function(e,o,r){var t=r.header||toHeaderCase(r.binding);this.rowHeaders.setCellData(e,o,t);var n=this.rowHeaders.columns,i=r.width;if(isNumber(i)&&i>0){var s=r._rng;if(s&&s instanceof CellRange&&s.isValid){var a=s.columnSpan;assert(a>0,"Column span is negative or equal to 0");i/=a}n[o].width=Math.max(n[o].width,i)}};TransposedGrid.prototype._rowInfoChanged=function(){var e=this;this._toRowInfo&&clearTimeout(this._toRowInfo);this._toRowInfo=setTimeout((function(){var o=e.selection,r=e.itemsSource;e.itemsSource=null;e.itemsSource=r;e.selection=o;e.invalidate(!0)}),Control._REFRESH_INTERVAL)};TransposedGrid.prototype._sourceViewChanged=function(e,o){this.activeEditor||this.invalidate()};TransposedGrid.prototype._transposeItemsSource=function(e){var o=this,r=new ObservableArray,t=getTypes(e),n=e.map((function(e,r){return o._keyPrefix+r}));(this.autoGenerateRows?this._getRowInfo(e):this._rowInfo).forEach((function(i,s){var a=new Binding(i.binding);if(null==i.dataType&&e.length){var l=a.getValue(e[0]);i.dataType=null!=l?getType(l):t[s].dataType}if(o._supportsProxies()){var u=o._createProxy(e,i,n);r.push(u)}else{var p=o._createTransposedObject(e,i,o._keyPrefix);r.push(p)}}));e instanceof ObservableArray&&e.collectionChanged.addHandler((function(e,t){if(t.action===NotifyCollectionChangedAction.Change)o.activeEditor||o.invalidate();else{var n=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);r.onCollectionChanged(n);o._rowInfoChanged()}}));return r};TransposedGrid.prototype._supportsProxies=function(){return null!=window.Proxy};TransposedGrid.prototype._createProxy=function(e,o,r){var t={_arr:e,_rowInfo:o,_bnd:new Binding(o.binding),_keys:r};return new Proxy(t,{ownKeys:function(e){return e._keys},getOwnPropertyDescriptor:function(){return{enumerable:!0,configurable:!0,writable:!0}},get:function(e,o){var r=e._keys.indexOf(o);return r>-1?e._bnd.getValue(e._arr[r]):e[o]},set:function(e,o,r){var t=e._keys.indexOf(o);if(t>-1){var n=e._arr,i=n[t];e._bnd.setValue(i,r);if(n instanceof ObservableArray){var s=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,i,t);n.onCollectionChanged(s)}return!0}return!1}})};TransposedGrid.prototype._createTransposedObject=function(e,o,r){for(var t={_arr:e,_rowInfo:o},n=new Binding(o.binding),_loop_1=function(o){var i=e[o];Object.defineProperty(t,r+o,{enumerable:!0,get:function(){return n.getValue(i)},set:function(r){n.setValue(i,r);if(e instanceof ObservableArray){var t=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,i,o);e.onCollectionChanged(t)}return!0}})},i=0;i<e.length;i++)_loop_1(i);return t};TransposedGrid.prototype._getRowInfo=function(e){var o=this,r=[];getTypes(e).forEach((function(e){var t=e.binding,n=e.dataType;if(n!=DataType.Object&&n!=DataType.Array){var i={binding:t,header:toHeaderCase(t),dataType:n},s=FlexGrid._defTypeWidth[n];if(null!=s){if(isString(s)){var a=Math.round(parseFloat(s));s=s.indexOf("*")<0?a:a*o.columns.defaultSize}isNumber(s)&&s>0&&(i.width=s)}r.push(i)}}));return r};TransposedGrid.prototype.getRowDataItem=function(o,r){var t=this.cells;if(t.rows[o].dataItem._rowInfo instanceof TransposedGridRow){for(var n={},i=0;i<t.rows.length;i++){n[t.rows[i].dataItem._rowInfo._binding.path]=t.getCellData(i,r,!1)}return n}return e.prototype.getRowDataItem.call(this,o,r)};TransposedGrid._ctrlTemplate="";return TransposedGrid}(FlexGrid);export{TransposedGrid};var TransposedGridRow=function(e){__extends(TransposedGridRow,e);function TransposedGridRow(){return null!==e&&e.apply(this,arguments)||this}Object.defineProperty(TransposedGridRow.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0});return TransposedGridRow}(Column);export{TransposedGridRow};var _RowGroupHandler=function(){function _RowGroupHandler(e){this._grid=e}Object.defineProperty(_RowGroupHandler.prototype,"columnGroups",{get:function(){return null},enumerable:!0,configurable:!0});_RowGroupHandler.prototype.createColumnGroups=function(e){this._createRowGroups(e)};_RowGroupHandler.prototype.hasColumnGroups=function(){return null!=this._colGroups&&this._colGroups.length>0};_RowGroupHandler.prototype.getGroupDefinitions=function(){return this._groupDefs};_RowGroupHandler.prototype.getColumnGroup=function(e,o){var r=this._grid;if(o<r.rowHeaders.columns.length&&e<r._rowInfo.length)for(var t=this._colGroups;t;){for(var n=t,i=0;i<t.length;i++){var s=t[i],a=s._rng;if(a.containsRow(e)){if(a.containsColumn(o)||0==s.columns.length)return s;t=s.columns;break}}if(t==n)break}return null};_RowGroupHandler.prototype.canMoveColumnGroup=function(e,o,r,t){return this._grid.columns.canMoveElement(o,t)};_RowGroupHandler.prototype.moveColumnGroup=function(e,o,r,t,n){return this._grid.columns.moveElement(o,t)};_RowGroupHandler.prototype._createRowGroups=function(e){var o=this,r=this._grid;this._groupDefs=asArray(e);r.autoGenerateRows=!1;r._rowInfo.clear();this._colGroups=[];e.forEach((function(e){o._colGroups.push(new _RowGroup(e,null))}));var t=1;this._colGroups.forEach((function(e){o._addRowGroup(e);t=Math.max(t,e._getMaxLevel())}));this._colGroups.forEach((function(e){e._expandRange(t)}));var n=r.rowHeaders.columns;n.clear();for(var i=0;i<=t;i++){var s=new Column;n.splice(i,0,s);i<t&&(s.cssClassAll=FlexGridClsNames.colGroup)}};_RowGroupHandler.prototype._addRowGroup=function(e){var o=this,r=this._grid;e._grid=r;e._rng.row=r._rowInfo.length;0==e.columns.length?r._rowInfo.push(e):e.columns.forEach((function(e){o._addRowGroup(e)}));e._rng.row2=r._rowInfo.length-1};return _RowGroupHandler}();export{_RowGroupHandler};var _RowGroup=function(e){__extends(_RowGroup,e);function _RowGroup(o,r){var t=e.call(this)||this;t._rng=new CellRange(-1,0);t._cols=[];t._lvl=0;t._collapsed=!1;t._pGrp=r;t._lvl=0;for(var n=r;n;n=n._pGrp)t._lvl++;r&&r.columns.indexOf(t)<0&&r.columns.push(t);t._rng.col=t._rng.col2=t._lvl;t.allowDragging=!1;copy(t,o);return t}Object.defineProperty(_RowGroup.prototype,"columns",{get:function(){return this._cols},set:function(e){var o=this,r=this._cols=[];e.forEach((function(e){var t=new _RowGroup(e,o);r.indexOf(t)<0&&r.push(t)}))},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"rows",{get:function(){return this._cols},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"isEmpty",{get:function(){return 0===this._cols.length},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"level",{get:function(){for(var e=this,o=0;e._pGrp;){e=e._pGrp;o++}return o},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"collapseTo",{get:function(){return this._collTo},set:function(e){assert(isArray(e)||isString(e),"collapseTo should be an array or a string.");this._collTo=e},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"isCollapsed",{get:function(){return this._collapsed},set:function(e){var o=this;if(e!=this._collapsed){var r=this._grid;if(r){var t=new CellRangeEventArgs(r.rowHeaders,this._rng,this);if(r.onColumnGroupCollapsedChanging(t)){this._collapsed=asBoolean(e);r.onColumnGroupCollapsedChanged(t)}}else this._collapsed=asBoolean(e)}setTimeout((function(){o._updateCollapsedState()}))},enumerable:!0,configurable:!0});_RowGroup.prototype._copy=function(e,o){if(/rows|columns/.test(e)){var r=asArray(o);this.columns=r;return!0}return!1};_RowGroup.prototype._updateCollapsedState=function(){var e=this._grid._rowInfo,o=this._rng,r=this._collapsed;this._cols.forEach((function(e){if(e instanceof _RowGroup){e._collapsed=r;e._updateCollapsedState()}}));for(var t=this._getCollapseToIndices(),n=o.topRow;n<=o.bottomRow;n++)e[n].visible=!r||t.indexOf(n)>-1};_RowGroup.prototype._getMaxLevel=function(){var e=this._lvl;this.columns.forEach((function(o){e=Math.max(e,o._getMaxLevel())}));return e};_RowGroup.prototype._expandRange=function(e){var o=e-this._getMaxLevel();if(o>0){this._rng.col2+=o;this._cols.forEach((function(e){e._shiftRange(o)}))}for(var r=this._grid._rowInfo,t=this._rng,n=t.row;n<=t.row2;n++){r[n]._rng.col2=e}};_RowGroup.prototype._shiftRange=function(e){this._rng.col+=e;this._rng.col2+=e;this._cols.forEach((function(o){o._shiftRange(e)}))};_RowGroup.prototype._getCollapseToBindings=function(){var e=this.collapseTo;return isString(e)?[e]:e};_RowGroup.prototype._getCollapseToIndices=function(){var e=this._grid,o=this._rng,r=this._getCollapseToBindings();if(r&&r.length){for(var t=[],n=e._rowInfo,i=0;i<r.length;i++)switch(r[i]){case"$first":t.push(o.topRow);break;case"$last":t.push(o.bottomRow);break;default:var s=n.indexOf(r[i]);s>-1&&t.push(s)}if(t.length)return t}return[o.bottomRow]};return _RowGroup}(Column);export{_RowGroup};_registerModule("wijmo.grid.transposed",selfModule);
|
|
14
|
+
var __extends=this&&this.__extends||function(){var extendStatics=function(e,o){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r])})(e,o)};return function(e,o){extendStatics(e,o);function __(){this.constructor=e}e.prototype=null===o?Object.create(o):(__.prototype=o.prototype,new __)}}();import{MergeManager,CellRange,FlexGrid,Row,Column,ColumnCollection,CellRangeEventArgs,AllowSorting,HeadersVisibility,AutoSizeMode,FlexGridClsNames}from"@mescius/wijmo.grid";import{asArray,assert,isArray,isString,isNumber,isUndefined,asBoolean,getTypes,getType,tryCast,toHeaderCase,addClass,DataType,Binding,Control,CollectionView,ObservableArray,NotifyCollectionChangedEventArgs,NotifyCollectionChangedAction,copy,_registerModule}from"@mescius/wijmo";import*as selfModule from"@mescius/wijmo.grid.transposed";export var TransposedGridClsNames={hostElement:"wj-transposed-grid"};var _MergeManager=function(e){__extends(_MergeManager,e);function _MergeManager(){return null!==e&&e.apply(this,arguments)||this}_MergeManager.prototype.getMergedRange=function(o,r,t,n){void 0===n&&(n=!0);var i=o.grid,s=i._hasColumnGroups();if(o==i.columnHeaders&&s)return null;if(o==i.rowHeaders&&s){if(r<0||r>=o.rows.length||t<0||t>=o.columns.length)return null;var a=i._getColumnGroup(r,t);if(a){var l=a._rng,u=o.rows;if(u.isFrozen(l.row)!=u.isFrozen(l.row2)){l=l.clone();u.isFrozen(r)?l.row2=u._frozenInternal-1:l.row=u._frozenInternal}return l}return null}return e.prototype.getMergedRange.call(this,o,r,t,n)};return _MergeManager}(MergeManager);export{_MergeManager};var TransposedGrid=function(e){__extends(TransposedGrid,e);function TransposedGrid(o,r){var t=e.call(this,o,null)||this;t._keyPrefix="item";t._autoGenRows=!0;addClass(t.hostElement,TransposedGridClsNames.hostElement);t.allowSorting=AllowSorting.None;t.headersVisibility=HeadersVisibility.Row;t._rowInfo=new ColumnCollection(t,t.columns.defaultSize);t._grpHdl=new _RowGroupHandler(t);t.mergeManager=new _MergeManager;t.initialize(r);t._rowInfo.collectionChanged.addHandler(t._rowInfoChanged,t);t.deferUpdate((function(){var e=t.rowHeaders.columns;if(e.length){e[e.length-1].width=t.columns.defaultSize}}));return t}Object.defineProperty(TransposedGrid,"controlTemplate",{get:function(){TransposedGrid._ctrlTemplate||(TransposedGrid._ctrlTemplate=FlexGrid.controlTemplate);return TransposedGrid._ctrlTemplate},set:function(e){TransposedGrid._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"autoGenerateRows",{get:function(){return this._autoGenRows},set:function(e){this._autoGenRows=asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"rowGroups",{get:function(){return this._grpHdl.getGroupDefinitions()},set:function(e){var o=this;this._rowInfo.deferUpdate((function(){o.autoGenerateRows=!1;o._rowInfo.clear();o._grpHdl.createColumnGroups(asArray(e))}))},enumerable:!0,configurable:!0});TransposedGrid.prototype.refresh=function(o){var r=this._rowInfo;if(r._dirty){r._dirty=!1;this._rowInfoChanged()}else e.prototype.refresh.call(this,o)};Object.defineProperty(TransposedGrid.prototype,"allowAddNew",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"allowDelete",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"allowSorting",{get:function(){return AllowSorting.None},set:function(e){assert(e===AllowSorting.None,"TransposedGrid does not support sorting.");this._alSorting=e},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"columnGroups",{get:function(){return null},set:function(e){throw"TransposedGrid does not support columnGroups, use rowGroups instead."},enumerable:!0,configurable:!0});TransposedGrid.prototype.onRowEditEnded=function(o){var r=tryCast(this._sourceItems,"ICollectionView");if(r){var t=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change);r.collectionChanged.raise(r,t)}e.prototype.onRowEditEnded.call(this,o)};TransposedGrid.prototype._getCollectionView=function(o){var r=this,t=tryCast(this._sourceItems,"ICollectionView");t&&t.collectionChanged.removeHandler(this._sourceViewChanged);t=tryCast(o,"ICollectionView");var n=o;if(isArray(o))n=this._transposeItemsSource(o);else if(t){t.collectionChanged.addHandler(this._sourceViewChanged,this);n=this._transposeItemsSource(t.items)}this.autoGenerateColumns=!0;var i=e.prototype._getCollectionView.call(this,n),s=null;t instanceof CollectionView&&(s=t.getError);s&&i instanceof CollectionView&&(this._supportsProxies()?i.getError=function(e,o){if(null==o)return null;var r=e._keys.indexOf(o);return s(e._arr[r],e._bnd.path)}:i.getError=function(e,o){if(null==o)return null;var t=parseInt(o.substr(r._keyPrefix.length));return s(e._arr[t],e._rowInfo.binding)});this._sourceItems=o;return i};TransposedGrid.prototype._getColumnTypes=function(e){var o,r=this;if(this._sourceItems)if(isArray(this._sourceItems))o=this._sourceItems;else{var t=tryCast(this._sourceItems,"ICollectionView");t&&(o=t.items)}return o?o.map((function(e,o){return{binding:r._keyPrefix+o,dataType:DataType.Object}})):getTypes(e)};TransposedGrid.prototype._copy=function(o,r){var t=this;if(/rows|columns/.test(o)){assert(isArray(r),"Array Expected.");var n=asArray(r);n.some((function(e){return null!=e.columns}))?this.rowGroups=n:this._rowInfo.deferUpdate((function(){t.autoGenerateRows=!1;t._rowInfo.clear();r.forEach((function(e){var o=new TransposedGridRow(e);t._rowInfo.push(o)}))}));return!0}return e.prototype._copy.call(this,o,r)};TransposedGrid.prototype.onLoadedRows=function(o){for(var r=this,t=this.columns,n=0;n<t.length;n++){var i=t[n];i.align=null;i.dataType=0}var s=this.rowHeaders.columns;for(n=0;n<s.length;n++){s[n].align="left";s[n].width=0}var a=FlexGrid._getSerializableProperties(Row);this.rows.forEach((function(e){var o=e.dataItem._rowInfo;if(o){r._copyProps(o,e,a,["showDropDown","width","size"]);if(r._hasColumnGroups())for(var t=0;t<s.length;t++){var n=r._grpHdl.getColumnGroup(e.index,t);n&&r._updateRowHeaders(e.index,t,n)}else s.length&&r._updateRowHeaders(e.index,s.length-1,o)}}));for(n=0;n<s.length;n++)0===s[n].width&&(s[n].width=this.columns.defaultSize);e.prototype.onLoadedRows.call(this,o)};TransposedGrid.prototype._getBindingColumn=function(e,o,r){var t=r;if(e!=this.cells)return t;var n=e.rows[o],i=n&&n.dataItem&&n.dataItem._rowInfo;if(isUndefined(i))return t;t=new Column;var s=FlexGrid._getSerializableProperties(Column);this._copyProps(i,t,s);t.binding=r.binding;t.header=i.header||toHeaderCase(i.binding);return t};TransposedGrid.prototype._isTransposed=function(){return!0};TransposedGrid.prototype._autoSizeRows=function(){this.autoSizeMode&AutoSizeMode.Both&&this.autoSizeRows();e.prototype._autoSizeRows.call(this)};TransposedGrid.prototype._copyProps=function(e,o,r,t){void 0===t&&(t=[]);for(var n in e)if(r.indexOf(n)>-1&&-1===t.indexOf(n)){var i=e[n];if(!isUndefined(i))try{o[n]=i}catch(e){}}};TransposedGrid.prototype._updateRowHeaders=function(e,o,r){var t=r.header||toHeaderCase(r.binding);this.rowHeaders.setCellData(e,o,t);var n=this.rowHeaders.columns,i=r.width;if(isNumber(i)&&i>0){var s=r._rng;if(s&&s instanceof CellRange&&s.isValid){var a=s.columnSpan;assert(a>0,"Column span is negative or equal to 0");i/=a}n[o].width=Math.max(n[o].width,i)}};TransposedGrid.prototype._rowInfoChanged=function(){var e=this;this._toRowInfo&&clearTimeout(this._toRowInfo);this._toRowInfo=setTimeout((function(){var o=e.selection,r=e.itemsSource;e.itemsSource=null;e.itemsSource=r;e.selection=o;e.invalidate(!0)}),Control._REFRESH_INTERVAL)};TransposedGrid.prototype._sourceViewChanged=function(e,o){this.activeEditor||this.invalidate()};TransposedGrid.prototype._transposeItemsSource=function(e){var o=this,r=new ObservableArray,t=getTypes(e),n=e.map((function(e,r){return o._keyPrefix+r}));(this.autoGenerateRows?this._getRowInfo(e):this._rowInfo).forEach((function(i,s){var a=new Binding(i.binding);if(null==i.dataType&&e.length){var l=a.getValue(e[0]);i.dataType=null!=l?getType(l):t[s].dataType}if(o._supportsProxies()){var u=o._createProxy(e,i,n);r.push(u)}else{var p=o._createTransposedObject(e,i,o._keyPrefix);r.push(p)}}));e instanceof ObservableArray&&e.collectionChanged.addHandler((function(e,t){if(t.action===NotifyCollectionChangedAction.Change)o.activeEditor||o.invalidate();else{var n=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Reset);r.onCollectionChanged(n);o._rowInfoChanged()}}));return r};TransposedGrid.prototype._supportsProxies=function(){return null!=window.Proxy};TransposedGrid.prototype._createProxy=function(e,o,r){var t={_arr:e,_rowInfo:o,_bnd:new Binding(o.binding),_keys:r};return new Proxy(t,{ownKeys:function(e){return e._keys},getOwnPropertyDescriptor:function(){return{enumerable:!0,configurable:!0,writable:!0}},get:function(e,o){var r=e._keys.indexOf(o);return r>-1?e._bnd.getValue(e._arr[r]):e[o]},set:function(e,o,r){var t=e._keys.indexOf(o);if(t>-1){var n=e._arr,i=n[t];e._bnd.setValue(i,r);if(n instanceof ObservableArray){var s=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,i,t);n.onCollectionChanged(s)}return!0}return!1}})};TransposedGrid.prototype._createTransposedObject=function(e,o,r){for(var t={_arr:e,_rowInfo:o},n=new Binding(o.binding),_loop_1=function(o){var i=e[o];Object.defineProperty(t,r+o,{enumerable:!0,get:function(){return n.getValue(i)},set:function(r){n.setValue(i,r);if(e instanceof ObservableArray){var t=new NotifyCollectionChangedEventArgs(NotifyCollectionChangedAction.Change,i,o);e.onCollectionChanged(t)}return!0}})},i=0;i<e.length;i++)_loop_1(i);return t};TransposedGrid.prototype._getRowInfo=function(e){var o=this,r=[];getTypes(e).forEach((function(e){var t=e.binding,n=e.dataType;if(n!=DataType.Object&&n!=DataType.Array){var i={binding:t,header:toHeaderCase(t),dataType:n},s=FlexGrid._defTypeWidth[n];if(null!=s){if(isString(s)){var a=Math.round(parseFloat(s));s=s.indexOf("*")<0?a:a*o.columns.defaultSize}isNumber(s)&&s>0&&(i.width=s)}r.push(i)}}));return r};TransposedGrid.prototype.getRowDataItem=function(o,r){var t=this.cells;if(t.rows[o].dataItem._rowInfo instanceof TransposedGridRow){for(var n={},i=0;i<t.rows.length;i++){n[t.rows[i].dataItem._rowInfo._binding.path]=t.getCellData(i,r,!1)}return n}return e.prototype.getRowDataItem.call(this,o,r)};TransposedGrid._ctrlTemplate="";return TransposedGrid}(FlexGrid);export{TransposedGrid};var TransposedGridRow=function(e){__extends(TransposedGridRow,e);function TransposedGridRow(){return null!==e&&e.apply(this,arguments)||this}Object.defineProperty(TransposedGridRow.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0});return TransposedGridRow}(Column);export{TransposedGridRow};var _RowGroupHandler=function(){function _RowGroupHandler(e){this._grid=e}Object.defineProperty(_RowGroupHandler.prototype,"columnGroups",{get:function(){return null},enumerable:!0,configurable:!0});_RowGroupHandler.prototype.createColumnGroups=function(e){this._createRowGroups(e)};_RowGroupHandler.prototype.hasColumnGroups=function(){return null!=this._colGroups&&this._colGroups.length>0};_RowGroupHandler.prototype.getGroupDefinitions=function(){return this._groupDefs};_RowGroupHandler.prototype.getColumnGroup=function(e,o){var r=this._grid;if(o<r.rowHeaders.columns.length&&e<r._rowInfo.length)for(var t=this._colGroups;t;){for(var n=t,i=0;i<t.length;i++){var s=t[i],a=s._rng;if(a.containsRow(e)){if(a.containsColumn(o)||0==s.columns.length)return s;t=s.columns;break}}if(t==n)break}return null};_RowGroupHandler.prototype.canMoveColumnGroup=function(e,o,r,t){return this._grid.columns.canMoveElement(o,t)};_RowGroupHandler.prototype.moveColumnGroup=function(e,o,r,t,n){return this._grid.columns.moveElement(o,t)};_RowGroupHandler.prototype._createRowGroups=function(e){var o=this,r=this._grid;this._groupDefs=asArray(e);r.autoGenerateRows=!1;r._rowInfo.clear();this._colGroups=[];e.forEach((function(e){o._colGroups.push(new _RowGroup(e,null))}));var t=1;this._colGroups.forEach((function(e){o._addRowGroup(e);t=Math.max(t,e._getMaxLevel())}));this._colGroups.forEach((function(e){e._expandRange(t)}));var n=r.rowHeaders.columns;n.clear();for(var i=0;i<=t;i++){var s=new Column;n.splice(i,0,s);i<t&&(s.cssClassAll=FlexGridClsNames.colGroup)}};_RowGroupHandler.prototype._addRowGroup=function(e){var o=this,r=this._grid;e._grid=r;e._rng.row=r._rowInfo.length;0==e.columns.length?r._rowInfo.push(e):e.columns.forEach((function(e){o._addRowGroup(e)}));e._rng.row2=r._rowInfo.length-1};return _RowGroupHandler}();export{_RowGroupHandler};var _RowGroup=function(e){__extends(_RowGroup,e);function _RowGroup(o,r){var t=e.call(this)||this;t._rng=new CellRange(-1,0);t._cols=[];t._lvl=0;t._collapsed=!1;t._pGrp=r;t._lvl=0;for(var n=r;n;n=n._pGrp)t._lvl++;r&&r.columns.indexOf(t)<0&&r.columns.push(t);t._rng.col=t._rng.col2=t._lvl;t.allowDragging=!1;copy(t,o);return t}Object.defineProperty(_RowGroup.prototype,"columns",{get:function(){return this._cols},set:function(e){var o=this;this._cols=[];var r=this._cols;e.forEach((function(e){var t=new _RowGroup(e,o);r.indexOf(t)<0&&r.push(t)}))},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"rows",{get:function(){return this._cols},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"isEmpty",{get:function(){return 0===this._cols.length},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"level",{get:function(){for(var e=this,o=0;e._pGrp;){e=e._pGrp;o++}return o},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"collapseTo",{get:function(){return this._collTo},set:function(e){assert(isArray(e)||isString(e),"collapseTo should be an array or a string.");this._collTo=e},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"isCollapsed",{get:function(){return this._collapsed},set:function(e){var o=this;if(e!=this._collapsed){var r=this._grid;if(r){var t=new CellRangeEventArgs(r.rowHeaders,this._rng,this);if(r.onColumnGroupCollapsedChanging(t)){this._collapsed=asBoolean(e);r.onColumnGroupCollapsedChanged(t)}}else this._collapsed=asBoolean(e)}setTimeout((function(){o._updateCollapsedState()}))},enumerable:!0,configurable:!0});_RowGroup.prototype._copy=function(e,o){if(/rows|columns/.test(e)){var r=asArray(o);this.columns=r;return!0}return!1};_RowGroup.prototype._updateCollapsedState=function(){var e=this._grid._rowInfo,o=this._rng,r=this._collapsed;this._cols.forEach((function(e){if(e instanceof _RowGroup){e._collapsed=r;e._updateCollapsedState()}}));for(var t=this._getCollapseToIndices(),n=o.topRow;n<=o.bottomRow;n++)e[n].visible=!r||t.indexOf(n)>-1};_RowGroup.prototype._getMaxLevel=function(){var e=this._lvl;this.columns.forEach((function(o){e=Math.max(e,o._getMaxLevel())}));return e};_RowGroup.prototype._expandRange=function(e){var o=e-this._getMaxLevel();if(o>0){this._rng.col2+=o;this._cols.forEach((function(e){e._shiftRange(o)}))}for(var r=this._grid._rowInfo,t=this._rng,n=t.row;n<=t.row2;n++){r[n]._rng.col2=e}};_RowGroup.prototype._shiftRange=function(e){this._rng.col+=e;this._rng.col2+=e;this._cols.forEach((function(o){o._shiftRange(e)}))};_RowGroup.prototype._getCollapseToBindings=function(){var e=this.collapseTo;return isString(e)?[e]:e};_RowGroup.prototype._getCollapseToIndices=function(){var e=this._grid,o=this._rng,r=this._getCollapseToBindings();if(r&&r.length){for(var t=[],n=e._rowInfo,i=0;i<r.length;i++)switch(r[i]){case"$first":t.push(o.topRow);break;case"$last":t.push(o.bottomRow);break;default:var s=n.indexOf(r[i]);s>-1&&t.push(s)}if(t.length)return t}return[o.bottomRow]};return _RowGroup}(Column);export{_RowGroup};_registerModule("wijmo.grid.transposed",selfModule);
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t014601
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -162,7 +162,7 @@ export declare class TransposedGrid<T = any> extends FlexGrid {
|
|
|
162
162
|
private _copyProps;
|
|
163
163
|
private _updateRowHeaders;
|
|
164
164
|
_rowInfoChanged(): void;
|
|
165
|
-
_sourceViewChanged(
|
|
165
|
+
_sourceViewChanged(_sender: ICollectionView, _e: NotifyCollectionChangedEventArgs): void;
|
|
166
166
|
_transposeItemsSource(arr: any[]): ObservableArray;
|
|
167
167
|
_supportsProxies(): boolean;
|
|
168
168
|
_createProxy(arr: any[], rowInfo: any, proxyKeys: string[]): any;
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.45-nightly.d20260105.t014601
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -11,4 +11,4 @@
|
|
|
11
11
|
*
|
|
12
12
|
*/
|
|
13
13
|
|
|
14
|
-
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(e,o){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r])})(e,o)};return function(e,o){extendStatics(e,o);function __(){this.constructor=e}e.prototype=null===o?Object.create(o):(__.prototype=o.prototype,new __)}}(),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(o[r]=e[r]);o.default=e;return o};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_grid_1=require("@mescius/wijmo.grid"),wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.grid.transposed"));exports.TransposedGridClsNames={hostElement:"wj-transposed-grid"};var _MergeManager=function(e){__extends(_MergeManager,e);function _MergeManager(){return null!==e&&e.apply(this,arguments)||this}_MergeManager.prototype.getMergedRange=function(o,r,t,n){void 0===n&&(n=!0);var i=o.grid,s=i._hasColumnGroups();if(o==i.columnHeaders&&s)return null;if(o==i.rowHeaders&&s){if(r<0||r>=o.rows.length||t<0||t>=o.columns.length)return null;var a=i._getColumnGroup(r,t);if(a){var l=a._rng,u=o.rows;if(u.isFrozen(l.row)!=u.isFrozen(l.row2)){l=l.clone();u.isFrozen(r)?l.row2=u._frozenInternal-1:l.row=u._frozenInternal}return l}return null}return e.prototype.getMergedRange.call(this,o,r,t,n)};return _MergeManager}(wijmo_grid_1.MergeManager);exports._MergeManager=_MergeManager;var TransposedGrid=function(e){__extends(TransposedGrid,e);function TransposedGrid(o,r){var t=e.call(this,o,null)||this;t._keyPrefix="item";t._autoGenRows=!0;wijmo_1.addClass(t.hostElement,exports.TransposedGridClsNames.hostElement);t.allowSorting=wijmo_grid_1.AllowSorting.None;t.headersVisibility=wijmo_grid_1.HeadersVisibility.Row;t._rowInfo=new wijmo_grid_1.ColumnCollection(t,t.columns.defaultSize);t._grpHdl=new _RowGroupHandler(t);t.mergeManager=new _MergeManager;t.initialize(r);t._rowInfo.collectionChanged.addHandler(t._rowInfoChanged,t);t.deferUpdate((function(){var e=t.rowHeaders.columns;if(e.length){e[e.length-1].width=t.columns.defaultSize}}));return t}Object.defineProperty(TransposedGrid,"controlTemplate",{get:function(){TransposedGrid._ctrlTemplate||(TransposedGrid._ctrlTemplate=wijmo_grid_1.FlexGrid.controlTemplate);return TransposedGrid._ctrlTemplate},set:function(e){TransposedGrid._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"autoGenerateRows",{get:function(){return this._autoGenRows},set:function(e){this._autoGenRows=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"rowGroups",{get:function(){return this._grpHdl.getGroupDefinitions()},set:function(e){var o=this;this._rowInfo.deferUpdate((function(){o.autoGenerateRows=!1;o._rowInfo.clear();o._grpHdl.createColumnGroups(wijmo_1.asArray(e))}))},enumerable:!0,configurable:!0});TransposedGrid.prototype.refresh=function(o){var r=this._rowInfo;if(r._dirty){r._dirty=!1;this._rowInfoChanged()}else e.prototype.refresh.call(this,o)};Object.defineProperty(TransposedGrid.prototype,"allowAddNew",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"allowDelete",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"allowSorting",{get:function(){return wijmo_grid_1.AllowSorting.None},set:function(e){wijmo_1.assert(e===wijmo_grid_1.AllowSorting.None,"TransposedGrid does not support sorting.");this._alSorting=e},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"columnGroups",{get:function(){return null},set:function(e){throw"TransposedGrid does not support columnGroups, use rowGroups instead."},enumerable:!0,configurable:!0});TransposedGrid.prototype.onRowEditEnded=function(o){var r=wijmo_1.tryCast(this._sourceItems,"ICollectionView");if(r){var t=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change);r.collectionChanged.raise(r,t)}e.prototype.onRowEditEnded.call(this,o)};TransposedGrid.prototype._getCollectionView=function(o){var r=this,t=wijmo_1.tryCast(this._sourceItems,"ICollectionView");t&&t.collectionChanged.removeHandler(this._sourceViewChanged);t=wijmo_1.tryCast(o,"ICollectionView");var n=o;if(wijmo_1.isArray(o))n=this._transposeItemsSource(o);else if(t){t.collectionChanged.addHandler(this._sourceViewChanged,this);n=this._transposeItemsSource(t.items)}this.autoGenerateColumns=!0;var i=e.prototype._getCollectionView.call(this,n),s=null;t instanceof wijmo_1.CollectionView&&(s=t.getError);s&&i instanceof wijmo_1.CollectionView&&(this._supportsProxies()?i.getError=function(e,o){if(null==o)return null;var r=e._keys.indexOf(o);return s(e._arr[r],e._bnd.path)}:i.getError=function(e,o){if(null==o)return null;var t=parseInt(o.substr(r._keyPrefix.length));return s(e._arr[t],e._rowInfo.binding)});this._sourceItems=o;return i};TransposedGrid.prototype._getColumnTypes=function(e){var o,r=this;if(this._sourceItems)if(wijmo_1.isArray(this._sourceItems))o=this._sourceItems;else{var t=wijmo_1.tryCast(this._sourceItems,"ICollectionView");t&&(o=t.items)}return o?o.map((function(e,o){return{binding:r._keyPrefix+o,dataType:wijmo_1.DataType.Object}})):wijmo_1.getTypes(e)};TransposedGrid.prototype._copy=function(o,r){var t=this;if(/rows|columns/.test(o)){wijmo_1.assert(wijmo_1.isArray(r),"Array Expected.");var n=wijmo_1.asArray(r);n.some((function(e){return null!=e.columns}))?this.rowGroups=n:this._rowInfo.deferUpdate((function(){t.autoGenerateRows=!1;t._rowInfo.clear();r.forEach((function(e){var o=new TransposedGridRow(e);t._rowInfo.push(o)}))}));return!0}return e.prototype._copy.call(this,o,r)};TransposedGrid.prototype.onLoadedRows=function(o){for(var r=this,t=this.columns,n=0;n<t.length;n++){var i=t[n];i.align=null;i.dataType=0}var s=this.rowHeaders.columns;for(n=0;n<s.length;n++){s[n].align="left";s[n].width=0}var a=wijmo_grid_1.FlexGrid._getSerializableProperties(wijmo_grid_1.Row);this.rows.forEach((function(e){var o=e.dataItem._rowInfo;if(o){r._copyProps(o,e,a,["showDropDown","width","size"]);if(r._hasColumnGroups())for(var t=0;t<s.length;t++){var n=r._grpHdl.getColumnGroup(e.index,t);n&&r._updateRowHeaders(e.index,t,n)}else s.length&&r._updateRowHeaders(e.index,s.length-1,o)}}));for(n=0;n<s.length;n++)0===s[n].width&&(s[n].width=this.columns.defaultSize);e.prototype.onLoadedRows.call(this,o)};TransposedGrid.prototype._getBindingColumn=function(e,o,r){var t=r;if(e!=this.cells)return t;var n=e.rows[o],i=n&&n.dataItem&&n.dataItem._rowInfo;if(wijmo_1.isUndefined(i))return t;t=new wijmo_grid_1.Column;var s=wijmo_grid_1.FlexGrid._getSerializableProperties(wijmo_grid_1.Column);this._copyProps(i,t,s);t.binding=r.binding;t.header=i.header||wijmo_1.toHeaderCase(i.binding);return t};TransposedGrid.prototype._isTransposed=function(){return!0};TransposedGrid.prototype._autoSizeRows=function(){this.autoSizeMode&wijmo_grid_1.AutoSizeMode.Both&&this.autoSizeRows();e.prototype._autoSizeRows.call(this)};TransposedGrid.prototype._copyProps=function(e,o,r,t){void 0===t&&(t=[]);for(var n in e)if(r.indexOf(n)>-1&&-1===t.indexOf(n)){var i=e[n];if(!wijmo_1.isUndefined(i))try{o[n]=i}catch(e){}}};TransposedGrid.prototype._updateRowHeaders=function(e,o,r){var t=r.header||wijmo_1.toHeaderCase(r.binding);this.rowHeaders.setCellData(e,o,t);var n=this.rowHeaders.columns,i=r.width;if(wijmo_1.isNumber(i)&&i>0){var s=r._rng;if(s&&s instanceof wijmo_grid_1.CellRange&&s.isValid){var a=s.columnSpan;wijmo_1.assert(a>0,"Column span is negative or equal to 0");i/=a}n[o].width=Math.max(n[o].width,i)}};TransposedGrid.prototype._rowInfoChanged=function(){var e=this;this._toRowInfo&&clearTimeout(this._toRowInfo);this._toRowInfo=setTimeout((function(){var o=e.selection,r=e.itemsSource;e.itemsSource=null;e.itemsSource=r;e.selection=o;e.invalidate(!0)}),wijmo_1.Control._REFRESH_INTERVAL)};TransposedGrid.prototype._sourceViewChanged=function(e,o){this.activeEditor||this.invalidate()};TransposedGrid.prototype._transposeItemsSource=function(e){var o=this,r=new wijmo_1.ObservableArray,t=wijmo_1.getTypes(e),n=e.map((function(e,r){return o._keyPrefix+r}));(this.autoGenerateRows?this._getRowInfo(e):this._rowInfo).forEach((function(i,s){var a=new wijmo_1.Binding(i.binding);if(null==i.dataType&&e.length){var l=a.getValue(e[0]);i.dataType=null!=l?wijmo_1.getType(l):t[s].dataType}if(o._supportsProxies()){var u=o._createProxy(e,i,n);r.push(u)}else{var p=o._createTransposedObject(e,i,o._keyPrefix);r.push(p)}}));e instanceof wijmo_1.ObservableArray&&e.collectionChanged.addHandler((function(e,t){if(t.action===wijmo_1.NotifyCollectionChangedAction.Change)o.activeEditor||o.invalidate();else{var n=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Reset);r.onCollectionChanged(n);o._rowInfoChanged()}}));return r};TransposedGrid.prototype._supportsProxies=function(){return null!=window.Proxy};TransposedGrid.prototype._createProxy=function(e,o,r){var t={_arr:e,_rowInfo:o,_bnd:new wijmo_1.Binding(o.binding),_keys:r};return new Proxy(t,{ownKeys:function(e){return e._keys},getOwnPropertyDescriptor:function(){return{enumerable:!0,configurable:!0,writable:!0}},get:function(e,o){var r=e._keys.indexOf(o);return r>-1?e._bnd.getValue(e._arr[r]):e[o]},set:function(e,o,r){var t=e._keys.indexOf(o);if(t>-1){var n=e._arr,i=n[t];e._bnd.setValue(i,r);if(n instanceof wijmo_1.ObservableArray){var s=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change,i,t);n.onCollectionChanged(s)}return!0}return!1}})};TransposedGrid.prototype._createTransposedObject=function(e,o,r){for(var t={_arr:e,_rowInfo:o},n=new wijmo_1.Binding(o.binding),_loop_1=function(o){var i=e[o];Object.defineProperty(t,r+o,{enumerable:!0,get:function(){return n.getValue(i)},set:function(r){n.setValue(i,r);if(e instanceof wijmo_1.ObservableArray){var t=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change,i,o);e.onCollectionChanged(t)}return!0}})},i=0;i<e.length;i++)_loop_1(i);return t};TransposedGrid.prototype._getRowInfo=function(e){var o=this,r=[];wijmo_1.getTypes(e).forEach((function(e){var t=e.binding,n=e.dataType;if(n!=wijmo_1.DataType.Object&&n!=wijmo_1.DataType.Array){var i={binding:t,header:wijmo_1.toHeaderCase(t),dataType:n},s=wijmo_grid_1.FlexGrid._defTypeWidth[n];if(null!=s){if(wijmo_1.isString(s)){var a=Math.round(parseFloat(s));s=s.indexOf("*")<0?a:a*o.columns.defaultSize}wijmo_1.isNumber(s)&&s>0&&(i.width=s)}r.push(i)}}));return r};TransposedGrid.prototype.getRowDataItem=function(o,r){var t=this.cells;if(t.rows[o].dataItem._rowInfo instanceof TransposedGridRow){for(var n={},i=0;i<t.rows.length;i++){n[t.rows[i].dataItem._rowInfo._binding.path]=t.getCellData(i,r,!1)}return n}return e.prototype.getRowDataItem.call(this,o,r)};TransposedGrid._ctrlTemplate="";return TransposedGrid}(wijmo_grid_1.FlexGrid);exports.TransposedGrid=TransposedGrid;var TransposedGridRow=function(e){__extends(TransposedGridRow,e);function TransposedGridRow(){return null!==e&&e.apply(this,arguments)||this}Object.defineProperty(TransposedGridRow.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0});return TransposedGridRow}(wijmo_grid_1.Column);exports.TransposedGridRow=TransposedGridRow;var _RowGroupHandler=function(){function _RowGroupHandler(e){this._grid=e}Object.defineProperty(_RowGroupHandler.prototype,"columnGroups",{get:function(){return null},enumerable:!0,configurable:!0});_RowGroupHandler.prototype.createColumnGroups=function(e){this._createRowGroups(e)};_RowGroupHandler.prototype.hasColumnGroups=function(){return null!=this._colGroups&&this._colGroups.length>0};_RowGroupHandler.prototype.getGroupDefinitions=function(){return this._groupDefs};_RowGroupHandler.prototype.getColumnGroup=function(e,o){var r=this._grid;if(o<r.rowHeaders.columns.length&&e<r._rowInfo.length)for(var t=this._colGroups;t;){for(var n=t,i=0;i<t.length;i++){var s=t[i],a=s._rng;if(a.containsRow(e)){if(a.containsColumn(o)||0==s.columns.length)return s;t=s.columns;break}}if(t==n)break}return null};_RowGroupHandler.prototype.canMoveColumnGroup=function(e,o,r,t){return this._grid.columns.canMoveElement(o,t)};_RowGroupHandler.prototype.moveColumnGroup=function(e,o,r,t,n){return this._grid.columns.moveElement(o,t)};_RowGroupHandler.prototype._createRowGroups=function(e){var o=this,r=this._grid;this._groupDefs=wijmo_1.asArray(e);r.autoGenerateRows=!1;r._rowInfo.clear();this._colGroups=[];e.forEach((function(e){o._colGroups.push(new _RowGroup(e,null))}));var t=1;this._colGroups.forEach((function(e){o._addRowGroup(e);t=Math.max(t,e._getMaxLevel())}));this._colGroups.forEach((function(e){e._expandRange(t)}));var n=r.rowHeaders.columns;n.clear();for(var i=0;i<=t;i++){var s=new wijmo_grid_1.Column;n.splice(i,0,s);i<t&&(s.cssClassAll=wijmo_grid_1.FlexGridClsNames.colGroup)}};_RowGroupHandler.prototype._addRowGroup=function(e){var o=this,r=this._grid;e._grid=r;e._rng.row=r._rowInfo.length;0==e.columns.length?r._rowInfo.push(e):e.columns.forEach((function(e){o._addRowGroup(e)}));e._rng.row2=r._rowInfo.length-1};return _RowGroupHandler}();exports._RowGroupHandler=_RowGroupHandler;var _RowGroup=function(e){__extends(_RowGroup,e);function _RowGroup(o,r){var t=e.call(this)||this;t._rng=new wijmo_grid_1.CellRange(-1,0);t._cols=[];t._lvl=0;t._collapsed=!1;t._pGrp=r;t._lvl=0;for(var n=r;n;n=n._pGrp)t._lvl++;r&&r.columns.indexOf(t)<0&&r.columns.push(t);t._rng.col=t._rng.col2=t._lvl;t.allowDragging=!1;wijmo_1.copy(t,o);return t}Object.defineProperty(_RowGroup.prototype,"columns",{get:function(){return this._cols},set:function(e){var o=this,r=this._cols=[];e.forEach((function(e){var t=new _RowGroup(e,o);r.indexOf(t)<0&&r.push(t)}))},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"rows",{get:function(){return this._cols},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"isEmpty",{get:function(){return 0===this._cols.length},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"level",{get:function(){for(var e=this,o=0;e._pGrp;){e=e._pGrp;o++}return o},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"collapseTo",{get:function(){return this._collTo},set:function(e){wijmo_1.assert(wijmo_1.isArray(e)||wijmo_1.isString(e),"collapseTo should be an array or a string.");this._collTo=e},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"isCollapsed",{get:function(){return this._collapsed},set:function(e){var o=this;if(e!=this._collapsed){var r=this._grid;if(r){var t=new wijmo_grid_1.CellRangeEventArgs(r.rowHeaders,this._rng,this);if(r.onColumnGroupCollapsedChanging(t)){this._collapsed=wijmo_1.asBoolean(e);r.onColumnGroupCollapsedChanged(t)}}else this._collapsed=wijmo_1.asBoolean(e)}setTimeout((function(){o._updateCollapsedState()}))},enumerable:!0,configurable:!0});_RowGroup.prototype._copy=function(e,o){if(/rows|columns/.test(e)){var r=wijmo_1.asArray(o);this.columns=r;return!0}return!1};_RowGroup.prototype._updateCollapsedState=function(){var e=this._grid._rowInfo,o=this._rng,r=this._collapsed;this._cols.forEach((function(e){if(e instanceof _RowGroup){e._collapsed=r;e._updateCollapsedState()}}));for(var t=this._getCollapseToIndices(),n=o.topRow;n<=o.bottomRow;n++)e[n].visible=!r||t.indexOf(n)>-1};_RowGroup.prototype._getMaxLevel=function(){var e=this._lvl;this.columns.forEach((function(o){e=Math.max(e,o._getMaxLevel())}));return e};_RowGroup.prototype._expandRange=function(e){var o=e-this._getMaxLevel();if(o>0){this._rng.col2+=o;this._cols.forEach((function(e){e._shiftRange(o)}))}for(var r=this._grid._rowInfo,t=this._rng,n=t.row;n<=t.row2;n++){r[n]._rng.col2=e}};_RowGroup.prototype._shiftRange=function(e){this._rng.col+=e;this._rng.col2+=e;this._cols.forEach((function(o){o._shiftRange(e)}))};_RowGroup.prototype._getCollapseToBindings=function(){var e=this.collapseTo;return wijmo_1.isString(e)?[e]:e};_RowGroup.prototype._getCollapseToIndices=function(){var e=this._grid,o=this._rng,r=this._getCollapseToBindings();if(r&&r.length){for(var t=[],n=e._rowInfo,i=0;i<r.length;i++)switch(r[i]){case"$first":t.push(o.topRow);break;case"$last":t.push(o.bottomRow);break;default:var s=n.indexOf(r[i]);s>-1&&t.push(s)}if(t.length)return t}return[o.bottomRow]};return _RowGroup}(wijmo_grid_1.Column);exports._RowGroup=_RowGroup;wijmo_1._registerModule("wijmo.grid.transposed",selfModule);
|
|
14
|
+
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(e,o){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,o){e.__proto__=o}||function(e,o){for(var r in o)o.hasOwnProperty(r)&&(e[r]=o[r])})(e,o)};return function(e,o){extendStatics(e,o);function __(){this.constructor=e}e.prototype=null===o?Object.create(o):(__.prototype=o.prototype,new __)}}(),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var o={};if(null!=e)for(var r in e)Object.hasOwnProperty.call(e,r)&&(o[r]=e[r]);o.default=e;return o};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_grid_1=require("@mescius/wijmo.grid"),wijmo_1=require("@mescius/wijmo"),selfModule=__importStar(require("@mescius/wijmo.grid.transposed"));exports.TransposedGridClsNames={hostElement:"wj-transposed-grid"};var _MergeManager=function(e){__extends(_MergeManager,e);function _MergeManager(){return null!==e&&e.apply(this,arguments)||this}_MergeManager.prototype.getMergedRange=function(o,r,t,n){void 0===n&&(n=!0);var i=o.grid,s=i._hasColumnGroups();if(o==i.columnHeaders&&s)return null;if(o==i.rowHeaders&&s){if(r<0||r>=o.rows.length||t<0||t>=o.columns.length)return null;var a=i._getColumnGroup(r,t);if(a){var l=a._rng,u=o.rows;if(u.isFrozen(l.row)!=u.isFrozen(l.row2)){l=l.clone();u.isFrozen(r)?l.row2=u._frozenInternal-1:l.row=u._frozenInternal}return l}return null}return e.prototype.getMergedRange.call(this,o,r,t,n)};return _MergeManager}(wijmo_grid_1.MergeManager);exports._MergeManager=_MergeManager;var TransposedGrid=function(e){__extends(TransposedGrid,e);function TransposedGrid(o,r){var t=e.call(this,o,null)||this;t._keyPrefix="item";t._autoGenRows=!0;wijmo_1.addClass(t.hostElement,exports.TransposedGridClsNames.hostElement);t.allowSorting=wijmo_grid_1.AllowSorting.None;t.headersVisibility=wijmo_grid_1.HeadersVisibility.Row;t._rowInfo=new wijmo_grid_1.ColumnCollection(t,t.columns.defaultSize);t._grpHdl=new _RowGroupHandler(t);t.mergeManager=new _MergeManager;t.initialize(r);t._rowInfo.collectionChanged.addHandler(t._rowInfoChanged,t);t.deferUpdate((function(){var e=t.rowHeaders.columns;if(e.length){e[e.length-1].width=t.columns.defaultSize}}));return t}Object.defineProperty(TransposedGrid,"controlTemplate",{get:function(){TransposedGrid._ctrlTemplate||(TransposedGrid._ctrlTemplate=wijmo_grid_1.FlexGrid.controlTemplate);return TransposedGrid._ctrlTemplate},set:function(e){TransposedGrid._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"autoGenerateRows",{get:function(){return this._autoGenRows},set:function(e){this._autoGenRows=wijmo_1.asBoolean(e)},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"rowGroups",{get:function(){return this._grpHdl.getGroupDefinitions()},set:function(e){var o=this;this._rowInfo.deferUpdate((function(){o.autoGenerateRows=!1;o._rowInfo.clear();o._grpHdl.createColumnGroups(wijmo_1.asArray(e))}))},enumerable:!0,configurable:!0});TransposedGrid.prototype.refresh=function(o){var r=this._rowInfo;if(r._dirty){r._dirty=!1;this._rowInfoChanged()}else e.prototype.refresh.call(this,o)};Object.defineProperty(TransposedGrid.prototype,"allowAddNew",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"allowDelete",{get:function(){return!1},set:function(e){},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"allowSorting",{get:function(){return wijmo_grid_1.AllowSorting.None},set:function(e){wijmo_1.assert(e===wijmo_grid_1.AllowSorting.None,"TransposedGrid does not support sorting.");this._alSorting=e},enumerable:!0,configurable:!0});Object.defineProperty(TransposedGrid.prototype,"columnGroups",{get:function(){return null},set:function(e){throw"TransposedGrid does not support columnGroups, use rowGroups instead."},enumerable:!0,configurable:!0});TransposedGrid.prototype.onRowEditEnded=function(o){var r=wijmo_1.tryCast(this._sourceItems,"ICollectionView");if(r){var t=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change);r.collectionChanged.raise(r,t)}e.prototype.onRowEditEnded.call(this,o)};TransposedGrid.prototype._getCollectionView=function(o){var r=this,t=wijmo_1.tryCast(this._sourceItems,"ICollectionView");t&&t.collectionChanged.removeHandler(this._sourceViewChanged);t=wijmo_1.tryCast(o,"ICollectionView");var n=o;if(wijmo_1.isArray(o))n=this._transposeItemsSource(o);else if(t){t.collectionChanged.addHandler(this._sourceViewChanged,this);n=this._transposeItemsSource(t.items)}this.autoGenerateColumns=!0;var i=e.prototype._getCollectionView.call(this,n),s=null;t instanceof wijmo_1.CollectionView&&(s=t.getError);s&&i instanceof wijmo_1.CollectionView&&(this._supportsProxies()?i.getError=function(e,o){if(null==o)return null;var r=e._keys.indexOf(o);return s(e._arr[r],e._bnd.path)}:i.getError=function(e,o){if(null==o)return null;var t=parseInt(o.substr(r._keyPrefix.length));return s(e._arr[t],e._rowInfo.binding)});this._sourceItems=o;return i};TransposedGrid.prototype._getColumnTypes=function(e){var o,r=this;if(this._sourceItems)if(wijmo_1.isArray(this._sourceItems))o=this._sourceItems;else{var t=wijmo_1.tryCast(this._sourceItems,"ICollectionView");t&&(o=t.items)}return o?o.map((function(e,o){return{binding:r._keyPrefix+o,dataType:wijmo_1.DataType.Object}})):wijmo_1.getTypes(e)};TransposedGrid.prototype._copy=function(o,r){var t=this;if(/rows|columns/.test(o)){wijmo_1.assert(wijmo_1.isArray(r),"Array Expected.");var n=wijmo_1.asArray(r);n.some((function(e){return null!=e.columns}))?this.rowGroups=n:this._rowInfo.deferUpdate((function(){t.autoGenerateRows=!1;t._rowInfo.clear();r.forEach((function(e){var o=new TransposedGridRow(e);t._rowInfo.push(o)}))}));return!0}return e.prototype._copy.call(this,o,r)};TransposedGrid.prototype.onLoadedRows=function(o){for(var r=this,t=this.columns,n=0;n<t.length;n++){var i=t[n];i.align=null;i.dataType=0}var s=this.rowHeaders.columns;for(n=0;n<s.length;n++){s[n].align="left";s[n].width=0}var a=wijmo_grid_1.FlexGrid._getSerializableProperties(wijmo_grid_1.Row);this.rows.forEach((function(e){var o=e.dataItem._rowInfo;if(o){r._copyProps(o,e,a,["showDropDown","width","size"]);if(r._hasColumnGroups())for(var t=0;t<s.length;t++){var n=r._grpHdl.getColumnGroup(e.index,t);n&&r._updateRowHeaders(e.index,t,n)}else s.length&&r._updateRowHeaders(e.index,s.length-1,o)}}));for(n=0;n<s.length;n++)0===s[n].width&&(s[n].width=this.columns.defaultSize);e.prototype.onLoadedRows.call(this,o)};TransposedGrid.prototype._getBindingColumn=function(e,o,r){var t=r;if(e!=this.cells)return t;var n=e.rows[o],i=n&&n.dataItem&&n.dataItem._rowInfo;if(wijmo_1.isUndefined(i))return t;t=new wijmo_grid_1.Column;var s=wijmo_grid_1.FlexGrid._getSerializableProperties(wijmo_grid_1.Column);this._copyProps(i,t,s);t.binding=r.binding;t.header=i.header||wijmo_1.toHeaderCase(i.binding);return t};TransposedGrid.prototype._isTransposed=function(){return!0};TransposedGrid.prototype._autoSizeRows=function(){this.autoSizeMode&wijmo_grid_1.AutoSizeMode.Both&&this.autoSizeRows();e.prototype._autoSizeRows.call(this)};TransposedGrid.prototype._copyProps=function(e,o,r,t){void 0===t&&(t=[]);for(var n in e)if(r.indexOf(n)>-1&&-1===t.indexOf(n)){var i=e[n];if(!wijmo_1.isUndefined(i))try{o[n]=i}catch(e){}}};TransposedGrid.prototype._updateRowHeaders=function(e,o,r){var t=r.header||wijmo_1.toHeaderCase(r.binding);this.rowHeaders.setCellData(e,o,t);var n=this.rowHeaders.columns,i=r.width;if(wijmo_1.isNumber(i)&&i>0){var s=r._rng;if(s&&s instanceof wijmo_grid_1.CellRange&&s.isValid){var a=s.columnSpan;wijmo_1.assert(a>0,"Column span is negative or equal to 0");i/=a}n[o].width=Math.max(n[o].width,i)}};TransposedGrid.prototype._rowInfoChanged=function(){var e=this;this._toRowInfo&&clearTimeout(this._toRowInfo);this._toRowInfo=setTimeout((function(){var o=e.selection,r=e.itemsSource;e.itemsSource=null;e.itemsSource=r;e.selection=o;e.invalidate(!0)}),wijmo_1.Control._REFRESH_INTERVAL)};TransposedGrid.prototype._sourceViewChanged=function(e,o){this.activeEditor||this.invalidate()};TransposedGrid.prototype._transposeItemsSource=function(e){var o=this,r=new wijmo_1.ObservableArray,t=wijmo_1.getTypes(e),n=e.map((function(e,r){return o._keyPrefix+r}));(this.autoGenerateRows?this._getRowInfo(e):this._rowInfo).forEach((function(i,s){var a=new wijmo_1.Binding(i.binding);if(null==i.dataType&&e.length){var l=a.getValue(e[0]);i.dataType=null!=l?wijmo_1.getType(l):t[s].dataType}if(o._supportsProxies()){var u=o._createProxy(e,i,n);r.push(u)}else{var p=o._createTransposedObject(e,i,o._keyPrefix);r.push(p)}}));e instanceof wijmo_1.ObservableArray&&e.collectionChanged.addHandler((function(e,t){if(t.action===wijmo_1.NotifyCollectionChangedAction.Change)o.activeEditor||o.invalidate();else{var n=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Reset);r.onCollectionChanged(n);o._rowInfoChanged()}}));return r};TransposedGrid.prototype._supportsProxies=function(){return null!=window.Proxy};TransposedGrid.prototype._createProxy=function(e,o,r){var t={_arr:e,_rowInfo:o,_bnd:new wijmo_1.Binding(o.binding),_keys:r};return new Proxy(t,{ownKeys:function(e){return e._keys},getOwnPropertyDescriptor:function(){return{enumerable:!0,configurable:!0,writable:!0}},get:function(e,o){var r=e._keys.indexOf(o);return r>-1?e._bnd.getValue(e._arr[r]):e[o]},set:function(e,o,r){var t=e._keys.indexOf(o);if(t>-1){var n=e._arr,i=n[t];e._bnd.setValue(i,r);if(n instanceof wijmo_1.ObservableArray){var s=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change,i,t);n.onCollectionChanged(s)}return!0}return!1}})};TransposedGrid.prototype._createTransposedObject=function(e,o,r){for(var t={_arr:e,_rowInfo:o},n=new wijmo_1.Binding(o.binding),_loop_1=function(o){var i=e[o];Object.defineProperty(t,r+o,{enumerable:!0,get:function(){return n.getValue(i)},set:function(r){n.setValue(i,r);if(e instanceof wijmo_1.ObservableArray){var t=new wijmo_1.NotifyCollectionChangedEventArgs(wijmo_1.NotifyCollectionChangedAction.Change,i,o);e.onCollectionChanged(t)}return!0}})},i=0;i<e.length;i++)_loop_1(i);return t};TransposedGrid.prototype._getRowInfo=function(e){var o=this,r=[];wijmo_1.getTypes(e).forEach((function(e){var t=e.binding,n=e.dataType;if(n!=wijmo_1.DataType.Object&&n!=wijmo_1.DataType.Array){var i={binding:t,header:wijmo_1.toHeaderCase(t),dataType:n},s=wijmo_grid_1.FlexGrid._defTypeWidth[n];if(null!=s){if(wijmo_1.isString(s)){var a=Math.round(parseFloat(s));s=s.indexOf("*")<0?a:a*o.columns.defaultSize}wijmo_1.isNumber(s)&&s>0&&(i.width=s)}r.push(i)}}));return r};TransposedGrid.prototype.getRowDataItem=function(o,r){var t=this.cells;if(t.rows[o].dataItem._rowInfo instanceof TransposedGridRow){for(var n={},i=0;i<t.rows.length;i++){n[t.rows[i].dataItem._rowInfo._binding.path]=t.getCellData(i,r,!1)}return n}return e.prototype.getRowDataItem.call(this,o,r)};TransposedGrid._ctrlTemplate="";return TransposedGrid}(wijmo_grid_1.FlexGrid);exports.TransposedGrid=TransposedGrid;var TransposedGridRow=function(e){__extends(TransposedGridRow,e);function TransposedGridRow(){return null!==e&&e.apply(this,arguments)||this}Object.defineProperty(TransposedGridRow.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0});return TransposedGridRow}(wijmo_grid_1.Column);exports.TransposedGridRow=TransposedGridRow;var _RowGroupHandler=function(){function _RowGroupHandler(e){this._grid=e}Object.defineProperty(_RowGroupHandler.prototype,"columnGroups",{get:function(){return null},enumerable:!0,configurable:!0});_RowGroupHandler.prototype.createColumnGroups=function(e){this._createRowGroups(e)};_RowGroupHandler.prototype.hasColumnGroups=function(){return null!=this._colGroups&&this._colGroups.length>0};_RowGroupHandler.prototype.getGroupDefinitions=function(){return this._groupDefs};_RowGroupHandler.prototype.getColumnGroup=function(e,o){var r=this._grid;if(o<r.rowHeaders.columns.length&&e<r._rowInfo.length)for(var t=this._colGroups;t;){for(var n=t,i=0;i<t.length;i++){var s=t[i],a=s._rng;if(a.containsRow(e)){if(a.containsColumn(o)||0==s.columns.length)return s;t=s.columns;break}}if(t==n)break}return null};_RowGroupHandler.prototype.canMoveColumnGroup=function(e,o,r,t){return this._grid.columns.canMoveElement(o,t)};_RowGroupHandler.prototype.moveColumnGroup=function(e,o,r,t,n){return this._grid.columns.moveElement(o,t)};_RowGroupHandler.prototype._createRowGroups=function(e){var o=this,r=this._grid;this._groupDefs=wijmo_1.asArray(e);r.autoGenerateRows=!1;r._rowInfo.clear();this._colGroups=[];e.forEach((function(e){o._colGroups.push(new _RowGroup(e,null))}));var t=1;this._colGroups.forEach((function(e){o._addRowGroup(e);t=Math.max(t,e._getMaxLevel())}));this._colGroups.forEach((function(e){e._expandRange(t)}));var n=r.rowHeaders.columns;n.clear();for(var i=0;i<=t;i++){var s=new wijmo_grid_1.Column;n.splice(i,0,s);i<t&&(s.cssClassAll=wijmo_grid_1.FlexGridClsNames.colGroup)}};_RowGroupHandler.prototype._addRowGroup=function(e){var o=this,r=this._grid;e._grid=r;e._rng.row=r._rowInfo.length;0==e.columns.length?r._rowInfo.push(e):e.columns.forEach((function(e){o._addRowGroup(e)}));e._rng.row2=r._rowInfo.length-1};return _RowGroupHandler}();exports._RowGroupHandler=_RowGroupHandler;var _RowGroup=function(e){__extends(_RowGroup,e);function _RowGroup(o,r){var t=e.call(this)||this;t._rng=new wijmo_grid_1.CellRange(-1,0);t._cols=[];t._lvl=0;t._collapsed=!1;t._pGrp=r;t._lvl=0;for(var n=r;n;n=n._pGrp)t._lvl++;r&&r.columns.indexOf(t)<0&&r.columns.push(t);t._rng.col=t._rng.col2=t._lvl;t.allowDragging=!1;wijmo_1.copy(t,o);return t}Object.defineProperty(_RowGroup.prototype,"columns",{get:function(){return this._cols},set:function(e){var o=this;this._cols=[];var r=this._cols;e.forEach((function(e){var t=new _RowGroup(e,o);r.indexOf(t)<0&&r.push(t)}))},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"rows",{get:function(){return this._cols},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"isEmpty",{get:function(){return 0===this._cols.length},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"height",{get:function(){return this._height},set:function(e){this._height=e},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"level",{get:function(){for(var e=this,o=0;e._pGrp;){e=e._pGrp;o++}return o},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"collapseTo",{get:function(){return this._collTo},set:function(e){wijmo_1.assert(wijmo_1.isArray(e)||wijmo_1.isString(e),"collapseTo should be an array or a string.");this._collTo=e},enumerable:!0,configurable:!0});Object.defineProperty(_RowGroup.prototype,"isCollapsed",{get:function(){return this._collapsed},set:function(e){var o=this;if(e!=this._collapsed){var r=this._grid;if(r){var t=new wijmo_grid_1.CellRangeEventArgs(r.rowHeaders,this._rng,this);if(r.onColumnGroupCollapsedChanging(t)){this._collapsed=wijmo_1.asBoolean(e);r.onColumnGroupCollapsedChanged(t)}}else this._collapsed=wijmo_1.asBoolean(e)}setTimeout((function(){o._updateCollapsedState()}))},enumerable:!0,configurable:!0});_RowGroup.prototype._copy=function(e,o){if(/rows|columns/.test(e)){var r=wijmo_1.asArray(o);this.columns=r;return!0}return!1};_RowGroup.prototype._updateCollapsedState=function(){var e=this._grid._rowInfo,o=this._rng,r=this._collapsed;this._cols.forEach((function(e){if(e instanceof _RowGroup){e._collapsed=r;e._updateCollapsedState()}}));for(var t=this._getCollapseToIndices(),n=o.topRow;n<=o.bottomRow;n++)e[n].visible=!r||t.indexOf(n)>-1};_RowGroup.prototype._getMaxLevel=function(){var e=this._lvl;this.columns.forEach((function(o){e=Math.max(e,o._getMaxLevel())}));return e};_RowGroup.prototype._expandRange=function(e){var o=e-this._getMaxLevel();if(o>0){this._rng.col2+=o;this._cols.forEach((function(e){e._shiftRange(o)}))}for(var r=this._grid._rowInfo,t=this._rng,n=t.row;n<=t.row2;n++){r[n]._rng.col2=e}};_RowGroup.prototype._shiftRange=function(e){this._rng.col+=e;this._rng.col2+=e;this._cols.forEach((function(o){o._shiftRange(e)}))};_RowGroup.prototype._getCollapseToBindings=function(){var e=this.collapseTo;return wijmo_1.isString(e)?[e]:e};_RowGroup.prototype._getCollapseToIndices=function(){var e=this._grid,o=this._rng,r=this._getCollapseToBindings();if(r&&r.length){for(var t=[],n=e._rowInfo,i=0;i<r.length;i++)switch(r[i]){case"$first":t.push(o.topRow);break;case"$last":t.push(o.bottomRow);break;default:var s=n.indexOf(r[i]);s>-1&&t.push(s)}if(t.length)return t}return[o.bottomRow]};return _RowGroup}(wijmo_grid_1.Column);exports._RowGroup=_RowGroup;wijmo_1._registerModule("wijmo.grid.transposed",selfModule);
|
package/package.json
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mescius/wijmo.grid.transposed",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20261.45-nightly.d20260105.t014601",
|
|
4
4
|
"description": "UI library for pure JS, Angular, React, Vue and more...",
|
|
5
5
|
"author": "MESCIUS inc",
|
|
6
6
|
"license": "Commercial",
|
|
7
7
|
"main": "./index.js",
|
|
8
8
|
"types": "./index.d.ts",
|
|
9
9
|
"dependencies": {
|
|
10
|
-
"@mescius/wijmo": "5.
|
|
11
|
-
"@mescius/wijmo.grid": "5.
|
|
10
|
+
"@mescius/wijmo": "5.20261.45-nightly.d20260105.t014601",
|
|
11
|
+
"@mescius/wijmo.grid": "5.20261.45-nightly.d20260105.t014601"
|
|
12
12
|
},
|
|
13
13
|
"homepage": "https://developer.mescius.com/wijmo",
|
|
14
14
|
"bugs": {
|