@grapecity/wijmo.grid.grouppanel 5.20252.44 → 5.20261.48
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/README.md +17 -0
- package/es2015-commonjs.js +2 -2
- package/es2015-esm.js +2 -2
- package/es5-esm.js +2 -2
- package/index.d.ts +7 -7
- package/index.js +2 -2
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
# Wijmo
|
|
4
4
|
|
|
5
|
+
**Note: Starting from 2027v1, Wijmo npm packages will be published only under the @mescius scope. Users using the @grapecity scope during the 2026 period will need to migrate to @mescius.**
|
|
6
|
+
|
|
7
|
+
---
|
|
8
|
+
|
|
5
9
|
Wijmo is a complete set of [JavaScript UI components](https://developer.mescius.com/wijmo?utm_source=npmwebsite&utm_medium=prospects&utm_campaign=wijmo_npm) for enterprise development. It includes a powerful data grid, charts, pivot tools, inputs, and much more and is available in your favorite framework, including [Angular](https://developer.mescius.com/wijmo/angular-ui-components?utm_source=npmwebsite&utm_medium=prospects&utm_campaign=wijmo_npm), [React](https://developer.mescius.com/wijmo/react-ui-components?utm_source=npmwebsite&utm_medium=prospects&utm_campaign=wijmo_npm), and [Vue](https://developer.mescius.com/wijmo/vue-ui-components?utm_source=npmwebsite&utm_medium=prospects&utm_campaign=wijmo_npm).
|
|
6
10
|
|
|
7
11
|
Cut your development time in half with Wijmo's lightweight, high-performance JavaScript UI components.
|
|
@@ -122,6 +126,10 @@ Submit questions to our team of [Wijmo Experts](https://developer.mescius.com/fo
|
|
|
122
126
|
|
|
123
127
|
## Wijmo JP
|
|
124
128
|
|
|
129
|
+
**注:2027v1以降、Wijmoのnpmパッケージは@mesciusスコープでのみ公開されます。2026年期間中に@grapecityスコープを使用しているユーザーは、@mesciusに移行する必要があります。**
|
|
130
|
+
|
|
131
|
+
---
|
|
132
|
+
|
|
125
133
|
[Wijmo](https://developer.mescius.jp/wijmo)は、Webアプリケーション開発に最適な数多くのUIを搭載するJavaScriptコンポーネントセットです。高速・軽量であり、開発工数の削減に大きく寄与します。データグリッド、チャート、ピボットテーブル、入力など、業務アプリケーション開発に必要となるコントロールを多数収録し、またAngularやReact、Vue.jsといったJavaScriptフレームワークにも対応しています。
|
|
126
134
|
|
|
127
135
|
なお、日本語版での動作保証は日本語版サイトで公開しているバージョンのみとなります。
|
|
@@ -161,6 +169,10 @@ Submit questions to our team of [Wijmo Experts](https://developer.mescius.com/fo
|
|
|
161
169
|
|
|
162
170
|
## Wijmo CN
|
|
163
171
|
|
|
172
|
+
**注意:从 2027v1 开始,Wijmo 的 npm 包将仅在 @mescius 作用域下发布。在 2026 年期间仍在使用 @grapecity 作用域的用户,需要迁移到 @mescius。**
|
|
173
|
+
|
|
174
|
+
---
|
|
175
|
+
|
|
164
176
|
Wijmo 是一套完整的企业级 JavaScript UI 开发组件。 它包括强大的表格、图表、数据透视、输入等组件,并且可以支持各类主流前端框架,包括 Angular、React 和 Vue。
|
|
165
177
|
|
|
166
178
|
Wijmo 的轻量级、高性能 JavaScript UI 组件可以将您的开发时间缩短一半。
|
|
@@ -255,6 +267,11 @@ Wijmo 开发包可以从 [这里](https://www.grapecity.com.cn/developer/wijmojs
|
|
|
255
267
|
|
|
256
268
|
# Wijmo KR
|
|
257
269
|
|
|
270
|
+
**참고: 2027 v1부터 Wijmo npm 패키지는 @mescius 스코프에서만 제공됩니다.
|
|
271
|
+
현재 @grapecity 스코프를 사용 중인 사용자는 2026년 내에 @mescius 스코프로 마이그레이션해 주시기 바랍니다.**
|
|
272
|
+
|
|
273
|
+
---
|
|
274
|
+
|
|
258
275
|
Wijmo(위즈모)는 고성능의 Web App 개발을 위한 완전한 JavaScript UI 컴포넌트 세트입니다. 강력한 데이터 그리드(DataGrid), 차트(Chart), 피벗 도구(OLAP/Pivop), 입력(Input) 등 개발에 필요한 100+의 다양한 컨트롤이 포함되어 있습니다.
|
|
259
276
|
|
|
260
277
|
또한, Wijmo는 Angular, React 및 Vue 등 개발자가 빠른 웹 개발과 효율적인 코드 유지 관리를 쉽게 할 수 있도록 JavaScript 프레임워크에 대한 지원을 제공합니다.
|
package/es2015-commonjs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.48
|
|
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 i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@grapecity/wijmo"),wijmo_grid_1=require("@grapecity/wijmo.grid"),selfModule=__importStar(require("@grapecity/wijmo.grid.grouppanel"));exports.GroupPanelClsNames={groupMarker:"wj-groupmarker",hostElement:"wj-grouppanel",groupPlaceholder:"wj-groupplaceholder"};function softGridFilter(){return wijmo_1._getModule("wijmo.grid.filter")}exports.softGridFilter=softGridFilter;wijmo_1._addCultureInfo("GroupPanel",{dragDrop:"Drag and Drop columns here to create Groups.",groupPanel:"Grouped columns panel",groupDescription:"Grouped by {0}{1}",groupAction:"Activate to toggle sort or remove group.",sortedAsc:", sorted ascending",sortedDesc:", sorted descending",sortedAscStatus:"{0} ascending",sortedDescStatus:"{0} descending",remove:"Remove group",added:"Added group {0}"});class GroupPanel extends wijmo_1.Control{constructor(e,t){super(e);this._hideGroupedCols=!0;this._showDragGlyphs=!0;this._maxGroups=6;this._hiddenCols=[];this._placeholder=null;this._dragEndBnd=this._dragEnd.bind(this);this._keyDownBnd=this._keyDown.bind(this);this._focusGd=null;this._ariaLabel=wijmo_1.culture.GroupPanel.groupPanel;let i=this.getTemplate();this.applyTemplate(`${exports.GroupPanelClsNames.hostElement} ${wijmo_1.ControlClsNames.hostElement}`,i,{_divMarkers:"div-markers",_divPH:"div-ph",_groupStatus:"group-status"});wijmo_1.setCss(this._divMarkers.parentElement,{width:"100%",height:"100%",minHeight:"1em",overflow:"hidden",cursor:"default"});let r=this.hostElement,s=this.addEventListener.bind(this);s(r,"dragstart",this._dragStart.bind(this));s(r,"dragover",this._dragOver.bind(this));s(r,"drop",this._drop.bind(this));s(r,"dragend",this._dragEndBnd);wijmo_1.setAttribute(r,"role","region");wijmo_1.setAttribute(r,"aria-label",this._ariaLabel);s(r,"click",this._click.bind(this));this.initialize(t)}static get controlTemplate(){GroupPanel._ctrlTemplate||(GroupPanel._ctrlTemplate=`<div><div wj-part="div-ph" class="${exports.GroupPanelClsNames.groupPlaceholder}"></div><div wj-part="div-markers"></div><div wj-part="group-status" aria-live="polite" class="${wijmo_grid_1.FlexGridClsNames.screenReaderOnly}"></div></div>`);return GroupPanel._ctrlTemplate}static set controlTemplate(e){GroupPanel._ctrlTemplate=e}get hideGroupedColumns(){return this._hideGroupedCols}set hideGroupedColumns(e){e!=this._hideGroupedCols&&(this._hideGroupedCols=wijmo_1.asBoolean(e))}get showDragGlyphs(){return this._showDragGlyphs}set showDragGlyphs(e){if(e!=this._showDragGlyphs){this._showDragGlyphs=wijmo_1.asBoolean(e);this.refresh()}}get maxGroups(){return this._maxGroups}set maxGroups(e){if(e!=this._maxGroups){this._maxGroups=wijmo_1.asNumber(e);let t=this._gds,i=this._maxGroups;t&&i>-1&&i<t.length&&t.splice(i,t.length-i)}}get placeholder(){return this._placeholder}set placeholder(e){if(e!=this._placeholder){this._placeholder=e;this.invalidate()}}get grid(){return this._g}set grid(e){if((e=wijmo_1.asType(e,wijmo_grid_1.FlexGrid,!0))!=this._g){let t=this._g;this._removeEventForGrid();t=this._g=e;this._hiddenCols=[];if(t){t.draggingColumn.addHandler(this._draggingColumn,this);t.itemsSourceChanging.addHandler(this._itemsSourceChanging,this);t.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);t.columns.collectionChanged.addHandler(this._itemsSourceChanged,this);t.addEventListener(t.hostElement,"dragend",this._dragEndBnd);t.addEventListener(t.hostElement,"keydown",this._keyDownBnd)}this._itemsSourceChanged(t,null)}}get collectionView(){return this._g?this._g.collectionView:null}get filter(){return this._filter}set filter(e){if((e=wijmo_1.asType(e,softGridFilter().FlexGridFilter,!0))!=this._filter){let t=this._filter;if(t){t.filterApplied.removeHandler(this.refresh,this);t.filterChanged.removeHandler(this._filterChanged,this)}t=this._filter=e;if(t){t.filterApplied.addHandler(this.refresh,this);t.filterChanged.addHandler(this._filterChanged,this)}this.refresh()}}get groupDescriptionCreator(){return this._gdc}set groupDescriptionCreator(e){this._gdc=e}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){if(e!=this._ariaLabel){this._ariaLabel=e;wijmo_1.setAttribute(this.hostElement,"aria-label",this._ariaLabel)}}refresh(){super.refresh();this._divMarkers.innerHTML="";this._dragMarker=this._dragCol=null;if(this._gds){let t=0===this._gds.length?"0":"-1";wijmo_1.setAttribute(this.hostElement,"tabindex",t);this._orgTabIndex=+t;let i=this._g,r=i.columnHeaders;for(let t=0;t<this._gds.length;t++){let s=this._gds[t],o=-1,l=-1;if(s instanceof wijmo_1.PropertyGroupDescription)for(let e=r.rows.length-1;e>=0&&l<0;e--)for(let t=0;t<r.columns.length&&l<0;t++){let n=i._getBindingColumn(r,e,r.columns[t]);if(n&&n.binding==s.propertyName){l=t;o=e;break}}if(l>-1&&o>-1){let t=document.createElement("button");t.dataset.groupPanel="true";i.cellFactory.updateCell(this._g.columnHeaders,o,l,t);delete t.dataset.groupPanel;wijmo_1.setAttribute(t,"class",`${wijmo_grid_1.FlexGridClsNames.cell} ${wijmo_grid_1.FlexGridClsNames.header} ${exports.GroupPanelClsNames.groupMarker}`);wijmo_1.setAttribute(t,"role","button");wijmo_1.setAttribute(t,"tabindex","0");t.removeAttribute("aria-sort");t.removeAttribute("aria-readonly");t.removeAttribute("aria-required");const n=s instanceof wijmo_1.PropertyGroupDescription?s.propertyName:"";this._markerFocusHandler=()=>{this._focusGd=s};t.addEventListener("focus",this._markerFocusHandler);this._focusGd===s&&this._focus&&(this._mkfocus=setTimeout(()=>{t.focus()},50));this._markerKeydownHandler=e=>{if((wijmo_1._isMacOS()?e.metaKey:e.ctrlKey)&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){e.preventDefault();const i=Array.from(this._divMarkers.children),r=i.indexOf(t),s=r+("ArrowLeft"===e.key?-1:1);if(s>=0&&s<i.length){this._moveGroupByIndex(r,s);this._newMkFocus=setTimeout(()=>{const e=this._divMarkers.children[s];e&&e.focus()},0)}}const i=Array.from(this._divMarkers.children);if("Delete"!==e.key||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey){const r=i.indexOf(t);switch(e.key){case"ArrowLeft":r>0&&i[r-1].focus();break;case"ArrowRight":r<i.length-1&&i[r+1].focus();break;case"Home":let t=i[0];t&&t.focus();e.preventDefault();break;case"End":let s=i[i.length-1];s&&s.focus();e.preventDefault()}}else{let t=e.target,r=wijmo_1.closest(t,"."+wijmo_grid_1.FlexGridClsNames.cell),s=this._getElementIndex(r);const{displayName:o}=this._getColumnInfoByProperty(n);this._removeGroup(s);this._announceToScreenReader(`${wijmo_1.culture.GroupPanel.remove} ${o}`);this._filterMarker=null;let l=i[0===s?1:0];l?l.focus():this.hostElement.focus()}};t.addEventListener("keydown",this._markerKeydownHandler);wijmo_1.setCss(t,{position:"static",display:"inline-block",verticalAlign:"top",left:"",right:"",top:"",width:"",height:"",paddingLeft:"",paddingRight:""});wijmo_1.removeChild(t.querySelector(".wj-elem-filter"));wijmo_1.removeChild(t.querySelector(".wj-column-selector"));if(this.showDragGlyphs){var e=wijmo_1.createElement(`<span class=${wijmo_1.GlyphClsNames.drag} aria-hidden="true"></span>`);t.insertBefore(e,t.firstChild)}let a=i._getBindingColumn(r,o,r.columns[l]);const d=a?this._getColumnDisplayName(a):n,h=this._getSortStateDescription(n,r,l);let _=d;n!==d&&(_+=", grouped by "+n);_+=h;t.setAttribute("aria-label",`${_}. ${wijmo_1.culture.GroupPanel.groupAction}`);let u=this._getColumnFilter(a);if(u){let e=wijmo_1.createElement(`<span class="wj-filter ${wijmo_1.GlyphClsNames.filter}"></span>`,t);wijmo_1.toggleClass(e,"wj-filter-on",u.isActive);wijmo_1.toggleClass(e,"wj-filter-off",!u.isActive)}wijmo_1.createElement(`<span class="${wijmo_1.UtilitesClsNames.remove}" aria-hidden="true">×</span>`,t);this._divMarkers.appendChild(t);if(a&&this.hideGroupedColumns){const e=[];if(this.grid.layoutDefinition){this.grid.layoutDefinition.forEach(t=>t.cells.forEach(t=>e.push(t.binding)))}if(!e.includes(a._binding.path)){a.visible=!1;this._hiddenCols.push(a)}}t[GroupPanel._INDEX_KEY]={row:o,col:l,panel:this}}}this._divPH.textContent=null!=this._placeholder?this._placeholder:wijmo_1.culture.GroupPanel.dragDrop;let s=this._divMarkers.children.length>0;this._divPH.style.display=s?"none":"";this._divMarkers.style.display=s?"":"none"}}hitTest(e){let t=e instanceof HTMLElement?e:e instanceof MouseEvent?e.target:null;wijmo_1.assert(null!=t,"MouseEvent or Element expected");let i=wijmo_1.closest(t,"."+wijmo_grid_1.FlexGridClsNames.cell);if(wijmo_1.hasClass(i,wijmo_grid_1.FlexGridClsNames.cell)){let e=this._getElementIndex(i);return this._gds&&e>-1?this._gds[e]:null}return null}_filterChanged(){this._filterMarker=null}_getColumnFilter(e){let t=this._filter,i=null;t&&(i=t.filterColumns&&t.filterColumns.indexOf(e.binding)<0?null:t.getColumnFilter(e));return i}_getColumnDisplayName(e){return e?e.header||e.binding:""}_getColumnInfoByProperty(e){const t=e?this._g.columns.getColumn(e):null;return{col:t,displayName:t?this._getColumnDisplayName(t):e}}_announceToScreenReader(e){this._groupStatus&&(this._groupStatus.textContent=e)}_getSortStateDescription(e,t,i){let r="";if(this._view){const s=this._view.sortDescriptions.find(t=>t.property===e);if(s){r=s.ascending?wijmo_1.culture.GroupPanel.sortedAsc:wijmo_1.culture.GroupPanel.sortedDesc;if(this._view.sortDescriptions.length>1){let e=t.columns[i]&&t.columns[i].currentSortIndex;e>-1&&(r+=" "+wijmo_1.culture.FlexGrid.ariaLabels.sortIndex+" "+(e+1))}}}return r}_moveGroupByIndex(e,t){const i=this._gds;i&&e>=0&&t>=0&&e<i.length&&t<i.length&&i.deferUpdate(()=>{const r=i[e];i.removeAt(e);i.insert(t,r);this.refresh()})}_removeGroupByColumn(e){const t=e.binding,i=this._gds;for(let e=i.length-1;e>=0;e--){const r=i[e];r instanceof wijmo_1.PropertyGroupDescription&&r.propertyName===t&&this._removeGroup(e)}}_editFilter(e){let t=this._gds,i=this._getElementIndex(e),r=t&&i>-1?t[i]:null,s=r instanceof wijmo_1.PropertyGroupDescription?r.propertyName:null,o=s?this._g.getColumn(s):null;o&&this._filter.editColumnFilter(o,null,e)}_addGroup(e,t){let i=this._gds,r=this._maxGroups,s=this._divMarkers.children.length;if(t){s=this._getIndex(t);for(let t=0;t<i.length;t++){let r=i[t];if(r instanceof wijmo_1.PropertyGroupDescription&&r.propertyName==e.binding){i.removeAt(t);t<s&&s--;break}}if(r>-1)for(let e=r-1;e<i.length;e++){this._removeGroup(e,i);e<s&&s--}}if(r<0||i.length<r){let t=this._gdc?this._gdc(e.binding):null;t||(t=new wijmo_1.PropertyGroupDescription(e.binding));i.insert(s,t);if(e&&this.hideGroupedColumns){e.visible=!1;this._hiddenCols.push(e)}const r=this._getColumnDisplayName(e);this._announceToScreenReader(format(wijmo_1.culture.GroupPanel.added,r))}}_moveGroup(e,t){let i=this._gds,r=this._getElementIndex(this._dragMarker),s=this._getIndex(t);s>r&&s--;s>=this._gds.length&&(s=this._gds.length);r!=s&&i.deferUpdate(()=>{let e=i[r];i.removeAt(r);i.insert(s,e)})}_removeGroup(e,t=this._gds){let i=t&&e>-1?t[e]:null,r=i instanceof wijmo_1.PropertyGroupDescription?i.propertyName:null,s=r?this._g.columns.getColumn(r):null;if(s){s.visible=!0;let e=this._hiddenCols,t=e.indexOf(s);t>-1&&e.splice(t,1)}i&&t.removeAt(e)}_getIndex(e){let t=e.clientX,i=this._divMarkers.children;for(let e=0;e<i.length;e++){let r=i[e].getBoundingClientRect();if((t-r.left)*(t-r.right)<0)return e}return i.length}_getElementIndex(e){if(e&&e.parentElement){let t=e.parentElement.children;for(let i=0;i<t.length;i++)if(t[i]==e)return i}return-1}_draggingColumn(e,t){let i=this._g,r=i._getBindingColumn(t.panel,t.row,i.columns[t.col]);this._dragCol=r.binding?r:null}_itemsSourceChanging(e,t){this._hiddenCols.forEach(e=>{e.visible=!0});this._hiddenCols=[]}_itemsSourceChanged(e,t){this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._view=this._g?this._g.collectionView:null;this._gds=this._view?this._view.groupDescriptions:null;this._view&&this._view.collectionChanged.addHandler(this._collectionChanged,this);this.invalidate()}_collectionChanged(e,t){t.action==wijmo_1.NotifyCollectionChangedAction.Reset&&this.invalidate()}_dragStart(e){wijmo_1._startDrag(e.dataTransfer,"move");this._dragMarker=e.target;this._dragCol=null}_dragOver(e){if(this._dragCol||this._dragMarker){e.dataTransfer.dropEffect="move";e.preventDefault();e.stopPropagation()}}_drop(e){this._dragMarker?this._moveGroup(this._dragMarker,e):this._dragCol&&this._addGroup(this._dragCol,e)}_dragEnd(e){this._dragMarker=this._dragCol=null}_keyDown(e){if(e.altKey){const t=this._g.selection,i=this._g.columns[t.col];let r=this._g.rows[t.row]instanceof wijmo_grid_1.GroupRow;if(i&&"KeyG"===e.code&&!0!==this.isDisabled&&!r){this._addGroup(i,e);e.preventDefault()}}}_click(e){let t=e.target,i=wijmo_1.closest(t,"."+wijmo_grid_1.FlexGridClsNames.cell);if(wijmo_1.hasClass(i,wijmo_grid_1.FlexGridClsNames.cell))if(wijmo_1.hasClass(t,"wj-filter")){if(i!=this._filterMarker){this._editFilter(i);this._filterMarker=i;return}}else if(wijmo_1.hasClass(t,wijmo_1.UtilitesClsNames.remove)){let e=this._getElementIndex(i),t=this._gds&&e>-1?this._gds[e]:null,r=t instanceof wijmo_1.PropertyGroupDescription?t.propertyName:null;const{displayName:s}=this._getColumnInfoByProperty(r);this._removeGroup(e);s&&this._announceToScreenReader(`${wijmo_1.culture.GroupPanel.remove} ${s}`)}else this._updateSort(e,i);this._filterMarker=null}_updateSort(e,t){let i=this._g,r=i.collectionView;if(!r||!r.canSort||i.allowSorting==wijmo_grid_1.AllowSorting.None)return;let s=this._getElementIndex(t),o=this._gds[s],l=o instanceof wijmo_1.PropertyGroupDescription?o.propertyName:null,n=l?i.getColumn(l):null;if(!n||!n.allowSorting)return;let a=n.sortMemberPath||n.binding,d=-1,h=r.sortDescriptions;for(let e=0;e<h.length;e++)if(h[e].property==a){d=e;break}let _=new wijmo_grid_1.CellRangeEventArgs(i.columnHeaders,new wijmo_grid_1.CellRange(0,n.index),e);if(i.onSortingColumn(_)){let t=e.ctrlKey||e.metaKey,r=e.shiftKey;h.deferUpdate(()=>{if(t&&r)h.clear();else if(d<0){i.allowSorting!=wijmo_grid_1.AllowSorting.MultiColumn&&h.clear();let e=null==n.sortOrder?i.sortOrder==wijmo_grid_1.SortOrder.AscDesc||i.sortOrder==wijmo_grid_1.SortOrder.AscDescNone:n.sortOrder==wijmo_grid_1.SortOrder.AscDesc||n.sortOrder==wijmo_grid_1.SortOrder.AscDescNone,t=new wijmo_1.SortDescription(a,e);h.push(t)}else{let e=h[d].ascending;const r=null!=n.sortOrder?n.sortOrder:i.sortOrder;if(t||e&&(r===wijmo_grid_1.SortOrder.DescAscNone||i.isTouching&&r===wijmo_grid_1.SortOrder.DescAsc)||!e&&(r===wijmo_grid_1.SortOrder.AscDescNone||i.isTouching&&r===wijmo_grid_1.SortOrder.AscDesc))h.splice(d,1);else{let t=new wijmo_1.SortDescription(a,!e);h.splice(d,1,t)}}});i.onSortedColumn(_)}}_removeEventForGrid(){let e=this._g;if(e){e.draggingColumn.removeHandler(this._draggingColumn);e.itemsSourceChanging.removeHandler(this._itemsSourceChanging);e.itemsSourceChanged.removeHandler(this._itemsSourceChanged);e.columns.collectionChanged.removeHandler(this._itemsSourceChanged);e.removeEventListener(e.hostElement,"dragend",this._dragEndBnd);e.removeEventListener(e.hostElement,"keydown",this._keyDownBnd)}}dispose(){this._removeEventForGrid();this._g=null;this._divMarkers.querySelectorAll("."+wijmo_grid_1.FlexGridClsNames.cell).forEach(e=>{e.removeEventListener("keydown",this._markerKeydownHandler);e.removeEventListener("focus",this._markerFocusHandler);e.removeAttribute("draggable")});this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._focusGd=null;this._dragMarker=null;this._dragCol=null;this._filterMarker=null;this._divPH=null;this._groupStatus=null;if(this._divMarkers){this._divMarkers.innerHTML="";this._divMarkers=null}if(this._mkfocus){clearTimeout(this._mkfocus);this._mkfocus=null}if(this._newMkFocus){clearTimeout(this._newMkFocus);this._newMkFocus=null}super.dispose()}}GroupPanel._ctrlTemplate="";GroupPanel._INDEX_KEY=wijmo_grid_1.FlexGridClsNames.cellIndex;exports.GroupPanel=GroupPanel;function format(e,...t){return t.reduce((e,t,i)=>e.replace(new RegExp(`\\{${i}\\}`,"g"),t),e)}wijmo_1._registerModule("wijmo.grid.grouppanel",selfModule);
|
|
14
|
+
"use strict";var __importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(null!=e)for(var i in e)Object.hasOwnProperty.call(e,i)&&(t[i]=e[i]);t.default=e;return t};Object.defineProperty(exports,"__esModule",{value:!0});const wijmo_1=require("@grapecity/wijmo"),wijmo_grid_1=require("@grapecity/wijmo.grid"),selfModule=__importStar(require("@grapecity/wijmo.grid.grouppanel"));exports.GroupPanelClsNames={groupMarker:"wj-groupmarker",hostElement:"wj-grouppanel",groupPlaceholder:"wj-groupplaceholder"};function softGridFilter(){return wijmo_1._getModule("wijmo.grid.filter")}exports.softGridFilter=softGridFilter;wijmo_1._addCultureInfo("GroupPanel",{dragDrop:"Drag and Drop columns here to create Groups.",groupPanel:"Grouped columns panel",groupDescription:"Grouped by {0}{1}",groupAction:"Activate to toggle sort or remove group.",sortedAsc:", sorted ascending",sortedDesc:", sorted descending",sortedAscStatus:"{0} ascending",sortedDescStatus:"{0} descending",remove:"Remove group",added:"Added group {0}"});class GroupPanel extends wijmo_1.Control{constructor(e,t){super(e);this._hideGroupedCols=!0;this._showDragGlyphs=!0;this._maxGroups=6;this._hiddenCols=[];this._placeholder=null;this._dragEndBnd=this._dragEnd.bind(this);this._keyDownBnd=this._keyDown.bind(this);this._focusGd=null;this._ariaLabel=wijmo_1.culture.GroupPanel.groupPanel;const i=this.getTemplate();this.applyTemplate(`${exports.GroupPanelClsNames.hostElement} ${wijmo_1.ControlClsNames.hostElement}`,i,{_divMarkers:"div-markers",_divPH:"div-ph",_groupStatus:"group-status"});wijmo_1.setCss(this._divMarkers.parentElement,{width:"100%",height:"100%",minHeight:"1em",overflow:"hidden",cursor:"default"});const r=this.hostElement,s=this.addEventListener.bind(this);s(r,"dragstart",this._dragStart.bind(this));s(r,"dragover",this._dragOver.bind(this));s(r,"drop",this._drop.bind(this));s(r,"dragend",this._dragEndBnd);wijmo_1.setAttribute(r,"role","region");wijmo_1.setAttribute(r,"aria-label",this._ariaLabel);s(r,"click",this._click.bind(this));this.initialize(t)}static get controlTemplate(){GroupPanel._ctrlTemplate||(GroupPanel._ctrlTemplate=`<div><div wj-part="div-ph" class="${exports.GroupPanelClsNames.groupPlaceholder}"></div><div wj-part="div-markers"></div><div wj-part="group-status" aria-live="polite" class="${wijmo_grid_1.FlexGridClsNames.screenReaderOnly}"></div></div>`);return GroupPanel._ctrlTemplate}static set controlTemplate(e){GroupPanel._ctrlTemplate=e}get hideGroupedColumns(){return this._hideGroupedCols}set hideGroupedColumns(e){e!=this._hideGroupedCols&&(this._hideGroupedCols=wijmo_1.asBoolean(e))}get showDragGlyphs(){return this._showDragGlyphs}set showDragGlyphs(e){if(e!=this._showDragGlyphs){this._showDragGlyphs=wijmo_1.asBoolean(e);this.refresh()}}get maxGroups(){return this._maxGroups}set maxGroups(e){if(e!=this._maxGroups){this._maxGroups=wijmo_1.asNumber(e);const t=this._gds,i=this._maxGroups;t&&i>-1&&i<t.length&&t.splice(i,t.length-i)}}get placeholder(){return this._placeholder}set placeholder(e){if(e!=this._placeholder){this._placeholder=e;this.invalidate()}}get grid(){return this._g}set grid(e){if((e=wijmo_1.asType(e,wijmo_grid_1.FlexGrid,!0))!=this._g){let t=this._g;this._removeEventForGrid();t=this._g=e;this._hiddenCols=[];if(t){t.draggingColumn.addHandler(this._draggingColumn,this);t.itemsSourceChanging.addHandler(this._itemsSourceChanging,this);t.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);t.columns.collectionChanged.addHandler(this._itemsSourceChanged,this);t.addEventListener(t.hostElement,"dragend",this._dragEndBnd);t.addEventListener(t.hostElement,"keydown",this._keyDownBnd)}this._itemsSourceChanged(t,null)}}get collectionView(){return this._g?this._g.collectionView:null}get filter(){return this._filter}set filter(e){if((e=wijmo_1.asType(e,softGridFilter().FlexGridFilter,!0))!=this._filter){let t=this._filter;if(t){t.filterApplied.removeHandler(this.refresh,this);t.filterChanged.removeHandler(this._filterChanged,this)}t=this._filter=e;if(t){t.filterApplied.addHandler(this.refresh,this);t.filterChanged.addHandler(this._filterChanged,this)}this.refresh()}}get groupDescriptionCreator(){return this._gdc}set groupDescriptionCreator(e){this._gdc=e}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){if(e!=this._ariaLabel){this._ariaLabel=e;wijmo_1.setAttribute(this.hostElement,"aria-label",this._ariaLabel)}}refresh(){super.refresh();this._divMarkers.innerHTML="";this._dragMarker=this._dragCol=null;if(this._gds){const e=0===this._gds.length?"0":"-1";wijmo_1.setAttribute(this.hostElement,"tabindex",e);this._orgTabIndex=+e;const t=this._g,i=t.columnHeaders;for(let e=0;e<this._gds.length;e++){let r=this._gds[e],s=-1,o=-1;if(r instanceof wijmo_1.PropertyGroupDescription)for(let e=i.rows.length-1;e>=0&&o<0;e--)for(let n=0;n<i.columns.length&&o<0;n++){const l=t._getBindingColumn(i,e,i.columns[n]);if(l&&l.binding==r.propertyName){o=n;s=e;break}}if(o>-1&&s>-1){const e=document.createElement("button");e.dataset.groupPanel="true";t.cellFactory.updateCell(this._g.columnHeaders,s,o,e);delete e.dataset.groupPanel;wijmo_1.setAttribute(e,"class",`${wijmo_grid_1.FlexGridClsNames.cell} ${wijmo_grid_1.FlexGridClsNames.header} ${exports.GroupPanelClsNames.groupMarker}`);wijmo_1.setAttribute(e,"role","button");wijmo_1.setAttribute(e,"tabindex","0");e.removeAttribute("aria-sort");e.removeAttribute("aria-readonly");e.removeAttribute("aria-required");const n=r instanceof wijmo_1.PropertyGroupDescription?r.propertyName:"";this._markerFocusHandler=()=>{this._focusGd=r};e.addEventListener("focus",this._markerFocusHandler);this._focusGd===r&&this._focus&&(this._mkfocus=setTimeout(()=>{e.focus()},50));this._markerKeydownHandler=t=>{if((wijmo_1._isMacOS()?t.metaKey:t.ctrlKey)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)){t.preventDefault();const i=Array.from(this._divMarkers.children),r=i.indexOf(e),s=r+("ArrowLeft"===t.key?-1:1);if(s>=0&&s<i.length){this._moveGroupByIndex(r,s);this._newMkFocus=setTimeout(()=>{const e=this._divMarkers.children[s];e&&e.focus()},0)}}const i=Array.from(this._divMarkers.children);if("Delete"!==t.key||t.altKey||t.shiftKey||t.ctrlKey||t.metaKey){const r=i.indexOf(e);switch(t.key){case"ArrowLeft":r>0&&i[r-1].focus();break;case"ArrowRight":r<i.length-1&&i[r+1].focus();break;case"Home":{const e=i[0];e&&e.focus();t.preventDefault();break}case"End":{const e=i[i.length-1];e&&e.focus();t.preventDefault();break}}}else{const e=t.target,r=wijmo_1.closest(e,"."+wijmo_grid_1.FlexGridClsNames.cell),s=this._getElementIndex(r),{displayName:o}=this._getColumnInfoByProperty(n);this._removeGroup(s);this._announceToScreenReader(`${wijmo_1.culture.GroupPanel.remove} ${o}`);this._filterMarker=null;const l=i[0===s?1:0];l?l.focus():this.hostElement.focus()}};e.addEventListener("keydown",this._markerKeydownHandler);wijmo_1.setCss(e,{position:"static",display:"inline-block",verticalAlign:"top",left:"",right:"",top:"",width:"",height:"",paddingLeft:"",paddingRight:""});wijmo_1.removeChild(e.querySelector(".wj-elem-filter"));wijmo_1.removeChild(e.querySelector(".wj-column-selector"));if(this.showDragGlyphs){const t=wijmo_1.createElement(`<span class=${wijmo_1.GlyphClsNames.drag} aria-hidden="true"></span>`);e.insertBefore(t,e.firstChild)}const l=t._getBindingColumn(i,s,i.columns[o]),a=l?this._getColumnDisplayName(l):n,d=this._getSortStateDescription(n,i,o);let h=a;n!==a&&(h+=", grouped by "+n);h+=d;e.setAttribute("aria-label",`${h}. ${wijmo_1.culture.GroupPanel.groupAction}`);const _=this._getColumnFilter(l);if(_){const t=wijmo_1.createElement(`<span class="wj-filter ${wijmo_1.GlyphClsNames.filter}"></span>`,e);wijmo_1.toggleClass(t,"wj-filter-on",_.isActive);wijmo_1.toggleClass(t,"wj-filter-off",!_.isActive)}wijmo_1.createElement(`<span class="${wijmo_1.UtilitesClsNames.remove}" aria-hidden="true">×</span>`,e);this._divMarkers.appendChild(e);if(l&&this.hideGroupedColumns){const e=[];if(this.grid.layoutDefinition){this.grid.layoutDefinition.forEach(t=>{t.cells.forEach(t=>{e.push(t.binding)})})}if(!e.includes(l._binding.path)){l.visible=!1;this._hiddenCols.push(l)}}e[GroupPanel._INDEX_KEY]={row:s,col:o,panel:this}}}this._divPH.textContent=null!=this._placeholder?this._placeholder:wijmo_1.culture.GroupPanel.dragDrop;const r=this._divMarkers.children.length>0;this._divPH.style.display=r?"none":"";this._divMarkers.style.display=r?"":"none"}}hitTest(e){const t=e instanceof HTMLElement?e:e instanceof MouseEvent?e.target:null;wijmo_1.assert(null!=t,"MouseEvent or Element expected");const i=wijmo_1.closest(t,"."+wijmo_grid_1.FlexGridClsNames.cell);if(wijmo_1.hasClass(i,wijmo_grid_1.FlexGridClsNames.cell)){const e=this._getElementIndex(i);return this._gds&&e>-1?this._gds[e]:null}return null}_filterChanged(){this._filterMarker=null}_getColumnFilter(e){let t=this._filter,i=null;t&&(i=t.filterColumns&&t.filterColumns.indexOf(e.binding)<0?null:t.getColumnFilter(e));return i}_getColumnDisplayName(e){return e?e.header||e.binding:""}_getColumnInfoByProperty(e){const t=e?this._g.columns.getColumn(e):null;return{col:t,displayName:t?this._getColumnDisplayName(t):e}}_announceToScreenReader(e){this._groupStatus&&(this._groupStatus.textContent=e)}_getSortStateDescription(e,t,i){let r="";if(this._view){const s=this._view.sortDescriptions.find(t=>t.property===e);if(s){r=s.ascending?wijmo_1.culture.GroupPanel.sortedAsc:wijmo_1.culture.GroupPanel.sortedDesc;if(this._view.sortDescriptions.length>1){const e=t.columns[i]&&t.columns[i].currentSortIndex;e>-1&&(r+=` ${wijmo_1.culture.FlexGrid.ariaLabels.sortIndex} ${e+1}`)}}}return r}_moveGroupByIndex(e,t){const i=this._gds;i&&e>=0&&t>=0&&e<i.length&&t<i.length&&i.deferUpdate(()=>{const r=i[e];i.removeAt(e);i.insert(t,r);this.refresh()})}_removeGroupByColumn(e){const t=e.binding,i=this._gds;for(let e=i.length-1;e>=0;e--){const r=i[e];r instanceof wijmo_1.PropertyGroupDescription&&r.propertyName===t&&this._removeGroup(e)}}_editFilter(e){const t=this._gds,i=this._getElementIndex(e),r=t&&i>-1?t[i]:null,s=r instanceof wijmo_1.PropertyGroupDescription?r.propertyName:null,o=s?this._g.getColumn(s):null;o&&this._filter.editColumnFilter(o,null,e)}_addGroup(e,t){const i=this._gds,r=this._maxGroups;let s=this._divMarkers.children.length;if(t){s=this._getIndex(t);for(let t=0;t<i.length;t++){const r=i[t];if(r instanceof wijmo_1.PropertyGroupDescription&&r.propertyName==e.binding){i.removeAt(t);t<s&&s--;break}}if(r>-1)for(let e=r-1;e<i.length;e++){this._removeGroup(e,i);e<s&&s--}}if(r<0||i.length<r){let t=this._gdc?this._gdc(e.binding):null;t||(t=new wijmo_1.PropertyGroupDescription(e.binding));i.insert(s,t);if(e&&this.hideGroupedColumns){e.visible=!1;this._hiddenCols.push(e)}const r=this._getColumnDisplayName(e);this._announceToScreenReader(format(wijmo_1.culture.GroupPanel.added,r))}}_moveGroup(e,t){let i=this._gds,r=this._getElementIndex(this._dragMarker),s=this._getIndex(t);s>r&&s--;s>=this._gds.length&&(s=this._gds.length);r!=s&&i.deferUpdate(()=>{const e=i[r];i.removeAt(r);i.insert(s,e)})}_removeGroup(e,t=this._gds){const i=t&&e>-1?t[e]:null,r=i instanceof wijmo_1.PropertyGroupDescription?i.propertyName:null,s=r?this._g.columns.getColumn(r):null;if(s){s.visible=!0;const e=this._hiddenCols,t=e.indexOf(s);t>-1&&e.splice(t,1)}i&&t.removeAt(e)}_getIndex(e){const t=e.clientX,i=this._divMarkers.children;for(let e=0;e<i.length;e++){const r=i[e].getBoundingClientRect();if((t-r.left)*(t-r.right)<0)return e}return i.length}_getElementIndex(e){if(e&&e.parentElement){const t=e.parentElement.children;for(let i=0;i<t.length;i++)if(t[i]==e)return i}return-1}_draggingColumn(e,t){const i=this._g,r=i._getBindingColumn(t.panel,t.row,i.columns[t.col]);this._dragCol=r.binding?r:null}_itemsSourceChanging(e,t){this._hiddenCols.forEach(e=>{e.visible=!0});this._hiddenCols=[]}_itemsSourceChanged(e,t){this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._view=this._g?this._g.collectionView:null;this._gds=this._view?this._view.groupDescriptions:null;this._view&&this._view.collectionChanged.addHandler(this._collectionChanged,this);this.invalidate()}_collectionChanged(e,t){t.action==wijmo_1.NotifyCollectionChangedAction.Reset&&this.invalidate()}_dragStart(e){wijmo_1._startDrag(e.dataTransfer,"move");this._dragMarker=e.target;this._dragCol=null}_dragOver(e){if(this._dragCol||this._dragMarker){e.dataTransfer.dropEffect="move";e.preventDefault();e.stopPropagation()}}_drop(e){this._dragMarker?this._moveGroup(this._dragMarker,e):this._dragCol&&this._addGroup(this._dragCol,e)}_dragEnd(e){this._dragMarker=this._dragCol=null}_keyDown(e){if(e.altKey){const t=this._g.selection,i=this._g.columns[t.col],r=this._g.rows[t.row]instanceof wijmo_grid_1.GroupRow;if(i&&"KeyG"===e.code&&!0!==this.isDisabled&&!r){this._addGroup(i,e);e.preventDefault()}}}_click(e){const t=e.target,i=wijmo_1.closest(t,"."+wijmo_grid_1.FlexGridClsNames.cell);if(wijmo_1.hasClass(i,wijmo_grid_1.FlexGridClsNames.cell))if(wijmo_1.hasClass(t,"wj-filter")){if(i!=this._filterMarker){this._editFilter(i);this._filterMarker=i;return}}else if(wijmo_1.hasClass(t,wijmo_1.UtilitesClsNames.remove)){const e=this._getElementIndex(i),t=this._gds&&e>-1?this._gds[e]:null,r=t instanceof wijmo_1.PropertyGroupDescription?t.propertyName:null,{displayName:s}=this._getColumnInfoByProperty(r);this._removeGroup(e);s&&this._announceToScreenReader(`${wijmo_1.culture.GroupPanel.remove} ${s}`)}else this._updateSort(e,i);this._filterMarker=null}_updateSort(e,t){const i=this._g,r=i.collectionView;if(!r||!r.canSort||i.allowSorting==wijmo_grid_1.AllowSorting.None)return;const s=this._getElementIndex(t),o=this._gds[s],n=o instanceof wijmo_1.PropertyGroupDescription?o.propertyName:null,l=n?i.getColumn(n):null;if(!l||!l.allowSorting)return;let a=l.sortMemberPath||l.binding,d=-1,h=r.sortDescriptions;for(let e=0;e<h.length;e++)if(h[e].property==a){d=e;break}const _=new wijmo_grid_1.CellRangeEventArgs(i.columnHeaders,new wijmo_grid_1.CellRange(0,l.index),e);if(i.onSortingColumn(_)){const t=e.ctrlKey||e.metaKey,r=e.shiftKey;h.deferUpdate(()=>{if(t&&r)h.clear();else if(d<0){i.allowSorting!=wijmo_grid_1.AllowSorting.MultiColumn&&h.clear();const e=null==l.sortOrder?i.sortOrder==wijmo_grid_1.SortOrder.AscDesc||i.sortOrder==wijmo_grid_1.SortOrder.AscDescNone:l.sortOrder==wijmo_grid_1.SortOrder.AscDesc||l.sortOrder==wijmo_grid_1.SortOrder.AscDescNone,t=new wijmo_1.SortDescription(a,e);h.push(t)}else{const e=h[d].ascending,r=null!=l.sortOrder?l.sortOrder:i.sortOrder;if(t||e&&(r===wijmo_grid_1.SortOrder.DescAscNone||i.isTouching&&r===wijmo_grid_1.SortOrder.DescAsc)||!e&&(r===wijmo_grid_1.SortOrder.AscDescNone||i.isTouching&&r===wijmo_grid_1.SortOrder.AscDesc))h.splice(d,1);else{const t=new wijmo_1.SortDescription(a,!e);h.splice(d,1,t)}}});i.onSortedColumn(_)}}_removeEventForGrid(){const e=this._g;if(e){e.draggingColumn.removeHandler(this._draggingColumn);e.itemsSourceChanging.removeHandler(this._itemsSourceChanging);e.itemsSourceChanged.removeHandler(this._itemsSourceChanged);e.columns.collectionChanged.removeHandler(this._itemsSourceChanged);e.removeEventListener(e.hostElement,"dragend",this._dragEndBnd);e.removeEventListener(e.hostElement,"keydown",this._keyDownBnd)}}dispose(){this._removeEventForGrid();this._g=null;this._divMarkers.querySelectorAll("."+wijmo_grid_1.FlexGridClsNames.cell).forEach(e=>{e.removeEventListener("keydown",this._markerKeydownHandler);e.removeEventListener("focus",this._markerFocusHandler);e.removeAttribute("draggable")});this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._focusGd=null;this._dragMarker=null;this._dragCol=null;this._filterMarker=null;this._divPH=null;this._groupStatus=null;if(this._divMarkers){this._divMarkers.innerHTML="";this._divMarkers=null}if(this._mkfocus){clearTimeout(this._mkfocus);this._mkfocus=null}if(this._newMkFocus){clearTimeout(this._newMkFocus);this._newMkFocus=null}super.dispose()}}GroupPanel._ctrlTemplate="";GroupPanel._INDEX_KEY=wijmo_grid_1.FlexGridClsNames.cellIndex;exports.GroupPanel=GroupPanel;function format(e,...t){return t.reduce((e,t,i)=>e.replace(new RegExp(`\\{${i}\\}`,"g"),t),e)}wijmo_1._registerModule("wijmo.grid.grouppanel",selfModule);
|
package/es2015-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.48
|
|
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{_getModule,Control,SortDescription,PropertyGroupDescription,NotifyCollectionChangedAction,assert,asBoolean,asNumber,asType,setCss,toggleClass,culture,_addCultureInfo,createElement,removeChild,_startDrag,hasClass,closest,GlyphClsNames,ControlClsNames,UtilitesClsNames,setAttribute,_isMacOS,_registerModule}from"@grapecity/wijmo";import{FlexGrid,CellRange,CellRangeEventArgs,AllowSorting,FlexGridClsNames,SortOrder,GroupRow}from"@grapecity/wijmo.grid";import*as selfModule from"@grapecity/wijmo.grid.grouppanel";export const GroupPanelClsNames={groupMarker:"wj-groupmarker",hostElement:"wj-grouppanel",groupPlaceholder:"wj-groupplaceholder"};export function softGridFilter(){return _getModule("wijmo.grid.filter")}_addCultureInfo("GroupPanel",{dragDrop:"Drag and Drop columns here to create Groups.",groupPanel:"Grouped columns panel",groupDescription:"Grouped by {0}{1}",groupAction:"Activate to toggle sort or remove group.",sortedAsc:", sorted ascending",sortedDesc:", sorted descending",sortedAscStatus:"{0} ascending",sortedDescStatus:"{0} descending",remove:"Remove group",added:"Added group {0}"});export class GroupPanel extends Control{constructor(e,t){super(e);this._hideGroupedCols=!0;this._showDragGlyphs=!0;this._maxGroups=6;this._hiddenCols=[];this._placeholder=null;this._dragEndBnd=this._dragEnd.bind(this);this._keyDownBnd=this._keyDown.bind(this);this._focusGd=null;this._ariaLabel=culture.GroupPanel.groupPanel;let r=this.getTemplate();this.applyTemplate(`${GroupPanelClsNames.hostElement} ${ControlClsNames.hostElement}`,r,{_divMarkers:"div-markers",_divPH:"div-ph",_groupStatus:"group-status"});setCss(this._divMarkers.parentElement,{width:"100%",height:"100%",minHeight:"1em",overflow:"hidden",cursor:"default"});let i=this.hostElement,s=this.addEventListener.bind(this);s(i,"dragstart",this._dragStart.bind(this));s(i,"dragover",this._dragOver.bind(this));s(i,"drop",this._drop.bind(this));s(i,"dragend",this._dragEndBnd);setAttribute(i,"role","region");setAttribute(i,"aria-label",this._ariaLabel);s(i,"click",this._click.bind(this));this.initialize(t)}static get controlTemplate(){GroupPanel._ctrlTemplate||(GroupPanel._ctrlTemplate=`<div><div wj-part="div-ph" class="${GroupPanelClsNames.groupPlaceholder}"></div><div wj-part="div-markers"></div><div wj-part="group-status" aria-live="polite" class="${FlexGridClsNames.screenReaderOnly}"></div></div>`);return GroupPanel._ctrlTemplate}static set controlTemplate(e){GroupPanel._ctrlTemplate=e}get hideGroupedColumns(){return this._hideGroupedCols}set hideGroupedColumns(e){e!=this._hideGroupedCols&&(this._hideGroupedCols=asBoolean(e))}get showDragGlyphs(){return this._showDragGlyphs}set showDragGlyphs(e){if(e!=this._showDragGlyphs){this._showDragGlyphs=asBoolean(e);this.refresh()}}get maxGroups(){return this._maxGroups}set maxGroups(e){if(e!=this._maxGroups){this._maxGroups=asNumber(e);let t=this._gds,r=this._maxGroups;t&&r>-1&&r<t.length&&t.splice(r,t.length-r)}}get placeholder(){return this._placeholder}set placeholder(e){if(e!=this._placeholder){this._placeholder=e;this.invalidate()}}get grid(){return this._g}set grid(e){if((e=asType(e,FlexGrid,!0))!=this._g){let t=this._g;this._removeEventForGrid();t=this._g=e;this._hiddenCols=[];if(t){t.draggingColumn.addHandler(this._draggingColumn,this);t.itemsSourceChanging.addHandler(this._itemsSourceChanging,this);t.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);t.columns.collectionChanged.addHandler(this._itemsSourceChanged,this);t.addEventListener(t.hostElement,"dragend",this._dragEndBnd);t.addEventListener(t.hostElement,"keydown",this._keyDownBnd)}this._itemsSourceChanged(t,null)}}get collectionView(){return this._g?this._g.collectionView:null}get filter(){return this._filter}set filter(e){if((e=asType(e,softGridFilter().FlexGridFilter,!0))!=this._filter){let t=this._filter;if(t){t.filterApplied.removeHandler(this.refresh,this);t.filterChanged.removeHandler(this._filterChanged,this)}t=this._filter=e;if(t){t.filterApplied.addHandler(this.refresh,this);t.filterChanged.addHandler(this._filterChanged,this)}this.refresh()}}get groupDescriptionCreator(){return this._gdc}set groupDescriptionCreator(e){this._gdc=e}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){if(e!=this._ariaLabel){this._ariaLabel=e;setAttribute(this.hostElement,"aria-label",this._ariaLabel)}}refresh(){super.refresh();this._divMarkers.innerHTML="";this._dragMarker=this._dragCol=null;if(this._gds){let t=0===this._gds.length?"0":"-1";setAttribute(this.hostElement,"tabindex",t);this._orgTabIndex=+t;let r=this._g,i=r.columnHeaders;for(let t=0;t<this._gds.length;t++){let s=this._gds[t],l=-1,o=-1;if(s instanceof PropertyGroupDescription)for(let e=i.rows.length-1;e>=0&&o<0;e--)for(let t=0;t<i.columns.length&&o<0;t++){let n=r._getBindingColumn(i,e,i.columns[t]);if(n&&n.binding==s.propertyName){o=t;l=e;break}}if(o>-1&&l>-1){let t=document.createElement("button");t.dataset.groupPanel="true";r.cellFactory.updateCell(this._g.columnHeaders,l,o,t);delete t.dataset.groupPanel;setAttribute(t,"class",`${FlexGridClsNames.cell} ${FlexGridClsNames.header} ${GroupPanelClsNames.groupMarker}`);setAttribute(t,"role","button");setAttribute(t,"tabindex","0");t.removeAttribute("aria-sort");t.removeAttribute("aria-readonly");t.removeAttribute("aria-required");const n=s instanceof PropertyGroupDescription?s.propertyName:"";this._markerFocusHandler=()=>{this._focusGd=s};t.addEventListener("focus",this._markerFocusHandler);this._focusGd===s&&this._focus&&(this._mkfocus=setTimeout(()=>{t.focus()},50));this._markerKeydownHandler=e=>{if((_isMacOS()?e.metaKey:e.ctrlKey)&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){e.preventDefault();const r=Array.from(this._divMarkers.children),i=r.indexOf(t),s=i+("ArrowLeft"===e.key?-1:1);if(s>=0&&s<r.length){this._moveGroupByIndex(i,s);this._newMkFocus=setTimeout(()=>{const e=this._divMarkers.children[s];e&&e.focus()},0)}}const r=Array.from(this._divMarkers.children);if("Delete"!==e.key||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey){const i=r.indexOf(t);switch(e.key){case"ArrowLeft":i>0&&r[i-1].focus();break;case"ArrowRight":i<r.length-1&&r[i+1].focus();break;case"Home":let t=r[0];t&&t.focus();e.preventDefault();break;case"End":let s=r[r.length-1];s&&s.focus();e.preventDefault()}}else{let t=e.target,i=closest(t,"."+FlexGridClsNames.cell),s=this._getElementIndex(i);const{displayName:l}=this._getColumnInfoByProperty(n);this._removeGroup(s);this._announceToScreenReader(`${culture.GroupPanel.remove} ${l}`);this._filterMarker=null;let o=r[0===s?1:0];o?o.focus():this.hostElement.focus()}};t.addEventListener("keydown",this._markerKeydownHandler);setCss(t,{position:"static",display:"inline-block",verticalAlign:"top",left:"",right:"",top:"",width:"",height:"",paddingLeft:"",paddingRight:""});removeChild(t.querySelector(".wj-elem-filter"));removeChild(t.querySelector(".wj-column-selector"));if(this.showDragGlyphs){var e=createElement(`<span class=${GlyphClsNames.drag} aria-hidden="true"></span>`);t.insertBefore(e,t.firstChild)}let a=r._getBindingColumn(i,l,i.columns[o]);const d=a?this._getColumnDisplayName(a):n,h=this._getSortStateDescription(n,i,o);let u=d;n!==d&&(u+=", grouped by "+n);u+=h;t.setAttribute("aria-label",`${u}. ${culture.GroupPanel.groupAction}`);let c=this._getColumnFilter(a);if(c){let e=createElement(`<span class="wj-filter ${GlyphClsNames.filter}"></span>`,t);toggleClass(e,"wj-filter-on",c.isActive);toggleClass(e,"wj-filter-off",!c.isActive)}createElement(`<span class="${UtilitesClsNames.remove}" aria-hidden="true">×</span>`,t);this._divMarkers.appendChild(t);if(a&&this.hideGroupedColumns){const e=[];if(this.grid.layoutDefinition){this.grid.layoutDefinition.forEach(t=>t.cells.forEach(t=>e.push(t.binding)))}if(!e.includes(a._binding.path)){a.visible=!1;this._hiddenCols.push(a)}}t[GroupPanel._INDEX_KEY]={row:l,col:o,panel:this}}}this._divPH.textContent=null!=this._placeholder?this._placeholder:culture.GroupPanel.dragDrop;let s=this._divMarkers.children.length>0;this._divPH.style.display=s?"none":"";this._divMarkers.style.display=s?"":"none"}}hitTest(e){let t=e instanceof HTMLElement?e:e instanceof MouseEvent?e.target:null;assert(null!=t,"MouseEvent or Element expected");let r=closest(t,"."+FlexGridClsNames.cell);if(hasClass(r,FlexGridClsNames.cell)){let e=this._getElementIndex(r);return this._gds&&e>-1?this._gds[e]:null}return null}_filterChanged(){this._filterMarker=null}_getColumnFilter(e){let t=this._filter,r=null;t&&(r=t.filterColumns&&t.filterColumns.indexOf(e.binding)<0?null:t.getColumnFilter(e));return r}_getColumnDisplayName(e){return e?e.header||e.binding:""}_getColumnInfoByProperty(e){const t=e?this._g.columns.getColumn(e):null;return{col:t,displayName:t?this._getColumnDisplayName(t):e}}_announceToScreenReader(e){this._groupStatus&&(this._groupStatus.textContent=e)}_getSortStateDescription(e,t,r){let i="";if(this._view){const s=this._view.sortDescriptions.find(t=>t.property===e);if(s){i=s.ascending?culture.GroupPanel.sortedAsc:culture.GroupPanel.sortedDesc;if(this._view.sortDescriptions.length>1){let e=t.columns[r]&&t.columns[r].currentSortIndex;e>-1&&(i+=" "+culture.FlexGrid.ariaLabels.sortIndex+" "+(e+1))}}}return i}_moveGroupByIndex(e,t){const r=this._gds;r&&e>=0&&t>=0&&e<r.length&&t<r.length&&r.deferUpdate(()=>{const i=r[e];r.removeAt(e);r.insert(t,i);this.refresh()})}_removeGroupByColumn(e){const t=e.binding,r=this._gds;for(let e=r.length-1;e>=0;e--){const i=r[e];i instanceof PropertyGroupDescription&&i.propertyName===t&&this._removeGroup(e)}}_editFilter(e){let t=this._gds,r=this._getElementIndex(e),i=t&&r>-1?t[r]:null,s=i instanceof PropertyGroupDescription?i.propertyName:null,l=s?this._g.getColumn(s):null;l&&this._filter.editColumnFilter(l,null,e)}_addGroup(e,t){let r=this._gds,i=this._maxGroups,s=this._divMarkers.children.length;if(t){s=this._getIndex(t);for(let t=0;t<r.length;t++){let i=r[t];if(i instanceof PropertyGroupDescription&&i.propertyName==e.binding){r.removeAt(t);t<s&&s--;break}}if(i>-1)for(let e=i-1;e<r.length;e++){this._removeGroup(e,r);e<s&&s--}}if(i<0||r.length<i){let t=this._gdc?this._gdc(e.binding):null;t||(t=new PropertyGroupDescription(e.binding));r.insert(s,t);if(e&&this.hideGroupedColumns){e.visible=!1;this._hiddenCols.push(e)}const i=this._getColumnDisplayName(e);this._announceToScreenReader(format(culture.GroupPanel.added,i))}}_moveGroup(e,t){let r=this._gds,i=this._getElementIndex(this._dragMarker),s=this._getIndex(t);s>i&&s--;s>=this._gds.length&&(s=this._gds.length);i!=s&&r.deferUpdate(()=>{let e=r[i];r.removeAt(i);r.insert(s,e)})}_removeGroup(e,t=this._gds){let r=t&&e>-1?t[e]:null,i=r instanceof PropertyGroupDescription?r.propertyName:null,s=i?this._g.columns.getColumn(i):null;if(s){s.visible=!0;let e=this._hiddenCols,t=e.indexOf(s);t>-1&&e.splice(t,1)}r&&t.removeAt(e)}_getIndex(e){let t=e.clientX,r=this._divMarkers.children;for(let e=0;e<r.length;e++){let i=r[e].getBoundingClientRect();if((t-i.left)*(t-i.right)<0)return e}return r.length}_getElementIndex(e){if(e&&e.parentElement){let t=e.parentElement.children;for(let r=0;r<t.length;r++)if(t[r]==e)return r}return-1}_draggingColumn(e,t){let r=this._g,i=r._getBindingColumn(t.panel,t.row,r.columns[t.col]);this._dragCol=i.binding?i:null}_itemsSourceChanging(e,t){this._hiddenCols.forEach(e=>{e.visible=!0});this._hiddenCols=[]}_itemsSourceChanged(e,t){this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._view=this._g?this._g.collectionView:null;this._gds=this._view?this._view.groupDescriptions:null;this._view&&this._view.collectionChanged.addHandler(this._collectionChanged,this);this.invalidate()}_collectionChanged(e,t){t.action==NotifyCollectionChangedAction.Reset&&this.invalidate()}_dragStart(e){_startDrag(e.dataTransfer,"move");this._dragMarker=e.target;this._dragCol=null}_dragOver(e){if(this._dragCol||this._dragMarker){e.dataTransfer.dropEffect="move";e.preventDefault();e.stopPropagation()}}_drop(e){this._dragMarker?this._moveGroup(this._dragMarker,e):this._dragCol&&this._addGroup(this._dragCol,e)}_dragEnd(e){this._dragMarker=this._dragCol=null}_keyDown(e){if(e.altKey){const t=this._g.selection,r=this._g.columns[t.col];let i=this._g.rows[t.row]instanceof GroupRow;if(r&&"KeyG"===e.code&&!0!==this.isDisabled&&!i){this._addGroup(r,e);e.preventDefault()}}}_click(e){let t=e.target,r=closest(t,"."+FlexGridClsNames.cell);if(hasClass(r,FlexGridClsNames.cell))if(hasClass(t,"wj-filter")){if(r!=this._filterMarker){this._editFilter(r);this._filterMarker=r;return}}else if(hasClass(t,UtilitesClsNames.remove)){let e=this._getElementIndex(r),t=this._gds&&e>-1?this._gds[e]:null,i=t instanceof PropertyGroupDescription?t.propertyName:null;const{displayName:s}=this._getColumnInfoByProperty(i);this._removeGroup(e);s&&this._announceToScreenReader(`${culture.GroupPanel.remove} ${s}`)}else this._updateSort(e,r);this._filterMarker=null}_updateSort(e,t){let r=this._g,i=r.collectionView;if(!i||!i.canSort||r.allowSorting==AllowSorting.None)return;let s=this._getElementIndex(t),l=this._gds[s],o=l instanceof PropertyGroupDescription?l.propertyName:null,n=o?r.getColumn(o):null;if(!n||!n.allowSorting)return;let a=n.sortMemberPath||n.binding,d=-1,h=i.sortDescriptions;for(let e=0;e<h.length;e++)if(h[e].property==a){d=e;break}let u=new CellRangeEventArgs(r.columnHeaders,new CellRange(0,n.index),e);if(r.onSortingColumn(u)){let t=e.ctrlKey||e.metaKey,i=e.shiftKey;h.deferUpdate(()=>{if(t&&i)h.clear();else if(d<0){r.allowSorting!=AllowSorting.MultiColumn&&h.clear();let e=null==n.sortOrder?r.sortOrder==SortOrder.AscDesc||r.sortOrder==SortOrder.AscDescNone:n.sortOrder==SortOrder.AscDesc||n.sortOrder==SortOrder.AscDescNone,t=new SortDescription(a,e);h.push(t)}else{let e=h[d].ascending;const i=null!=n.sortOrder?n.sortOrder:r.sortOrder;if(t||e&&(i===SortOrder.DescAscNone||r.isTouching&&i===SortOrder.DescAsc)||!e&&(i===SortOrder.AscDescNone||r.isTouching&&i===SortOrder.AscDesc))h.splice(d,1);else{let t=new SortDescription(a,!e);h.splice(d,1,t)}}});r.onSortedColumn(u)}}_removeEventForGrid(){let e=this._g;if(e){e.draggingColumn.removeHandler(this._draggingColumn);e.itemsSourceChanging.removeHandler(this._itemsSourceChanging);e.itemsSourceChanged.removeHandler(this._itemsSourceChanged);e.columns.collectionChanged.removeHandler(this._itemsSourceChanged);e.removeEventListener(e.hostElement,"dragend",this._dragEndBnd);e.removeEventListener(e.hostElement,"keydown",this._keyDownBnd)}}dispose(){this._removeEventForGrid();this._g=null;this._divMarkers.querySelectorAll("."+FlexGridClsNames.cell).forEach(e=>{e.removeEventListener("keydown",this._markerKeydownHandler);e.removeEventListener("focus",this._markerFocusHandler);e.removeAttribute("draggable")});this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._focusGd=null;this._dragMarker=null;this._dragCol=null;this._filterMarker=null;this._divPH=null;this._groupStatus=null;if(this._divMarkers){this._divMarkers.innerHTML="";this._divMarkers=null}if(this._mkfocus){clearTimeout(this._mkfocus);this._mkfocus=null}if(this._newMkFocus){clearTimeout(this._newMkFocus);this._newMkFocus=null}super.dispose()}}GroupPanel._ctrlTemplate="";GroupPanel._INDEX_KEY=FlexGridClsNames.cellIndex;function format(e,...t){return t.reduce((e,t,r)=>e.replace(new RegExp(`\\{${r}\\}`,"g"),t),e)}_registerModule("wijmo.grid.grouppanel",selfModule);
|
|
14
|
+
import{_getModule,Control,SortDescription,PropertyGroupDescription,NotifyCollectionChangedAction,assert,asBoolean,asNumber,asType,setCss,toggleClass,culture,_addCultureInfo,createElement,removeChild,_startDrag,hasClass,closest,GlyphClsNames,ControlClsNames,UtilitesClsNames,setAttribute,_isMacOS,_registerModule}from"@grapecity/wijmo";import{FlexGrid,CellRange,CellRangeEventArgs,AllowSorting,FlexGridClsNames,SortOrder,GroupRow}from"@grapecity/wijmo.grid";import*as selfModule from"@grapecity/wijmo.grid.grouppanel";export const GroupPanelClsNames={groupMarker:"wj-groupmarker",hostElement:"wj-grouppanel",groupPlaceholder:"wj-groupplaceholder"};export function softGridFilter(){return _getModule("wijmo.grid.filter")}_addCultureInfo("GroupPanel",{dragDrop:"Drag and Drop columns here to create Groups.",groupPanel:"Grouped columns panel",groupDescription:"Grouped by {0}{1}",groupAction:"Activate to toggle sort or remove group.",sortedAsc:", sorted ascending",sortedDesc:", sorted descending",sortedAscStatus:"{0} ascending",sortedDescStatus:"{0} descending",remove:"Remove group",added:"Added group {0}"});export class GroupPanel extends Control{constructor(e,t){super(e);this._hideGroupedCols=!0;this._showDragGlyphs=!0;this._maxGroups=6;this._hiddenCols=[];this._placeholder=null;this._dragEndBnd=this._dragEnd.bind(this);this._keyDownBnd=this._keyDown.bind(this);this._focusGd=null;this._ariaLabel=culture.GroupPanel.groupPanel;const r=this.getTemplate();this.applyTemplate(`${GroupPanelClsNames.hostElement} ${ControlClsNames.hostElement}`,r,{_divMarkers:"div-markers",_divPH:"div-ph",_groupStatus:"group-status"});setCss(this._divMarkers.parentElement,{width:"100%",height:"100%",minHeight:"1em",overflow:"hidden",cursor:"default"});const s=this.hostElement,i=this.addEventListener.bind(this);i(s,"dragstart",this._dragStart.bind(this));i(s,"dragover",this._dragOver.bind(this));i(s,"drop",this._drop.bind(this));i(s,"dragend",this._dragEndBnd);setAttribute(s,"role","region");setAttribute(s,"aria-label",this._ariaLabel);i(s,"click",this._click.bind(this));this.initialize(t)}static get controlTemplate(){GroupPanel._ctrlTemplate||(GroupPanel._ctrlTemplate=`<div><div wj-part="div-ph" class="${GroupPanelClsNames.groupPlaceholder}"></div><div wj-part="div-markers"></div><div wj-part="group-status" aria-live="polite" class="${FlexGridClsNames.screenReaderOnly}"></div></div>`);return GroupPanel._ctrlTemplate}static set controlTemplate(e){GroupPanel._ctrlTemplate=e}get hideGroupedColumns(){return this._hideGroupedCols}set hideGroupedColumns(e){e!=this._hideGroupedCols&&(this._hideGroupedCols=asBoolean(e))}get showDragGlyphs(){return this._showDragGlyphs}set showDragGlyphs(e){if(e!=this._showDragGlyphs){this._showDragGlyphs=asBoolean(e);this.refresh()}}get maxGroups(){return this._maxGroups}set maxGroups(e){if(e!=this._maxGroups){this._maxGroups=asNumber(e);const t=this._gds,r=this._maxGroups;t&&r>-1&&r<t.length&&t.splice(r,t.length-r)}}get placeholder(){return this._placeholder}set placeholder(e){if(e!=this._placeholder){this._placeholder=e;this.invalidate()}}get grid(){return this._g}set grid(e){if((e=asType(e,FlexGrid,!0))!=this._g){let t=this._g;this._removeEventForGrid();t=this._g=e;this._hiddenCols=[];if(t){t.draggingColumn.addHandler(this._draggingColumn,this);t.itemsSourceChanging.addHandler(this._itemsSourceChanging,this);t.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);t.columns.collectionChanged.addHandler(this._itemsSourceChanged,this);t.addEventListener(t.hostElement,"dragend",this._dragEndBnd);t.addEventListener(t.hostElement,"keydown",this._keyDownBnd)}this._itemsSourceChanged(t,null)}}get collectionView(){return this._g?this._g.collectionView:null}get filter(){return this._filter}set filter(e){if((e=asType(e,softGridFilter().FlexGridFilter,!0))!=this._filter){let t=this._filter;if(t){t.filterApplied.removeHandler(this.refresh,this);t.filterChanged.removeHandler(this._filterChanged,this)}t=this._filter=e;if(t){t.filterApplied.addHandler(this.refresh,this);t.filterChanged.addHandler(this._filterChanged,this)}this.refresh()}}get groupDescriptionCreator(){return this._gdc}set groupDescriptionCreator(e){this._gdc=e}get ariaLabel(){return this._ariaLabel}set ariaLabel(e){if(e!=this._ariaLabel){this._ariaLabel=e;setAttribute(this.hostElement,"aria-label",this._ariaLabel)}}refresh(){super.refresh();this._divMarkers.innerHTML="";this._dragMarker=this._dragCol=null;if(this._gds){const e=0===this._gds.length?"0":"-1";setAttribute(this.hostElement,"tabindex",e);this._orgTabIndex=+e;const t=this._g,r=t.columnHeaders;for(let e=0;e<this._gds.length;e++){let s=this._gds[e],i=-1,o=-1;if(s instanceof PropertyGroupDescription)for(let e=r.rows.length-1;e>=0&&o<0;e--)for(let n=0;n<r.columns.length&&o<0;n++){const l=t._getBindingColumn(r,e,r.columns[n]);if(l&&l.binding==s.propertyName){o=n;i=e;break}}if(o>-1&&i>-1){const e=document.createElement("button");e.dataset.groupPanel="true";t.cellFactory.updateCell(this._g.columnHeaders,i,o,e);delete e.dataset.groupPanel;setAttribute(e,"class",`${FlexGridClsNames.cell} ${FlexGridClsNames.header} ${GroupPanelClsNames.groupMarker}`);setAttribute(e,"role","button");setAttribute(e,"tabindex","0");e.removeAttribute("aria-sort");e.removeAttribute("aria-readonly");e.removeAttribute("aria-required");const n=s instanceof PropertyGroupDescription?s.propertyName:"";this._markerFocusHandler=()=>{this._focusGd=s};e.addEventListener("focus",this._markerFocusHandler);this._focusGd===s&&this._focus&&(this._mkfocus=setTimeout(()=>{e.focus()},50));this._markerKeydownHandler=t=>{if((_isMacOS()?t.metaKey:t.ctrlKey)&&("ArrowLeft"===t.key||"ArrowRight"===t.key)){t.preventDefault();const r=Array.from(this._divMarkers.children),s=r.indexOf(e),i=s+("ArrowLeft"===t.key?-1:1);if(i>=0&&i<r.length){this._moveGroupByIndex(s,i);this._newMkFocus=setTimeout(()=>{const e=this._divMarkers.children[i];e&&e.focus()},0)}}const r=Array.from(this._divMarkers.children);if("Delete"!==t.key||t.altKey||t.shiftKey||t.ctrlKey||t.metaKey){const s=r.indexOf(e);switch(t.key){case"ArrowLeft":s>0&&r[s-1].focus();break;case"ArrowRight":s<r.length-1&&r[s+1].focus();break;case"Home":{const e=r[0];e&&e.focus();t.preventDefault();break}case"End":{const e=r[r.length-1];e&&e.focus();t.preventDefault();break}}}else{const e=t.target,s=closest(e,"."+FlexGridClsNames.cell),i=this._getElementIndex(s),{displayName:o}=this._getColumnInfoByProperty(n);this._removeGroup(i);this._announceToScreenReader(`${culture.GroupPanel.remove} ${o}`);this._filterMarker=null;const l=r[0===i?1:0];l?l.focus():this.hostElement.focus()}};e.addEventListener("keydown",this._markerKeydownHandler);setCss(e,{position:"static",display:"inline-block",verticalAlign:"top",left:"",right:"",top:"",width:"",height:"",paddingLeft:"",paddingRight:""});removeChild(e.querySelector(".wj-elem-filter"));removeChild(e.querySelector(".wj-column-selector"));if(this.showDragGlyphs){const t=createElement(`<span class=${GlyphClsNames.drag} aria-hidden="true"></span>`);e.insertBefore(t,e.firstChild)}const l=t._getBindingColumn(r,i,r.columns[o]),a=l?this._getColumnDisplayName(l):n,d=this._getSortStateDescription(n,r,o);let h=a;n!==a&&(h+=", grouped by "+n);h+=d;e.setAttribute("aria-label",`${h}. ${culture.GroupPanel.groupAction}`);const u=this._getColumnFilter(l);if(u){const t=createElement(`<span class="wj-filter ${GlyphClsNames.filter}"></span>`,e);toggleClass(t,"wj-filter-on",u.isActive);toggleClass(t,"wj-filter-off",!u.isActive)}createElement(`<span class="${UtilitesClsNames.remove}" aria-hidden="true">×</span>`,e);this._divMarkers.appendChild(e);if(l&&this.hideGroupedColumns){const e=[];if(this.grid.layoutDefinition){this.grid.layoutDefinition.forEach(t=>{t.cells.forEach(t=>{e.push(t.binding)})})}if(!e.includes(l._binding.path)){l.visible=!1;this._hiddenCols.push(l)}}e[GroupPanel._INDEX_KEY]={row:i,col:o,panel:this}}}this._divPH.textContent=null!=this._placeholder?this._placeholder:culture.GroupPanel.dragDrop;const s=this._divMarkers.children.length>0;this._divPH.style.display=s?"none":"";this._divMarkers.style.display=s?"":"none"}}hitTest(e){const t=e instanceof HTMLElement?e:e instanceof MouseEvent?e.target:null;assert(null!=t,"MouseEvent or Element expected");const r=closest(t,"."+FlexGridClsNames.cell);if(hasClass(r,FlexGridClsNames.cell)){const e=this._getElementIndex(r);return this._gds&&e>-1?this._gds[e]:null}return null}_filterChanged(){this._filterMarker=null}_getColumnFilter(e){let t=this._filter,r=null;t&&(r=t.filterColumns&&t.filterColumns.indexOf(e.binding)<0?null:t.getColumnFilter(e));return r}_getColumnDisplayName(e){return e?e.header||e.binding:""}_getColumnInfoByProperty(e){const t=e?this._g.columns.getColumn(e):null;return{col:t,displayName:t?this._getColumnDisplayName(t):e}}_announceToScreenReader(e){this._groupStatus&&(this._groupStatus.textContent=e)}_getSortStateDescription(e,t,r){let s="";if(this._view){const i=this._view.sortDescriptions.find(t=>t.property===e);if(i){s=i.ascending?culture.GroupPanel.sortedAsc:culture.GroupPanel.sortedDesc;if(this._view.sortDescriptions.length>1){const e=t.columns[r]&&t.columns[r].currentSortIndex;e>-1&&(s+=` ${culture.FlexGrid.ariaLabels.sortIndex} ${e+1}`)}}}return s}_moveGroupByIndex(e,t){const r=this._gds;r&&e>=0&&t>=0&&e<r.length&&t<r.length&&r.deferUpdate(()=>{const s=r[e];r.removeAt(e);r.insert(t,s);this.refresh()})}_removeGroupByColumn(e){const t=e.binding,r=this._gds;for(let e=r.length-1;e>=0;e--){const s=r[e];s instanceof PropertyGroupDescription&&s.propertyName===t&&this._removeGroup(e)}}_editFilter(e){const t=this._gds,r=this._getElementIndex(e),s=t&&r>-1?t[r]:null,i=s instanceof PropertyGroupDescription?s.propertyName:null,o=i?this._g.getColumn(i):null;o&&this._filter.editColumnFilter(o,null,e)}_addGroup(e,t){const r=this._gds,s=this._maxGroups;let i=this._divMarkers.children.length;if(t){i=this._getIndex(t);for(let t=0;t<r.length;t++){const s=r[t];if(s instanceof PropertyGroupDescription&&s.propertyName==e.binding){r.removeAt(t);t<i&&i--;break}}if(s>-1)for(let e=s-1;e<r.length;e++){this._removeGroup(e,r);e<i&&i--}}if(s<0||r.length<s){let t=this._gdc?this._gdc(e.binding):null;t||(t=new PropertyGroupDescription(e.binding));r.insert(i,t);if(e&&this.hideGroupedColumns){e.visible=!1;this._hiddenCols.push(e)}const s=this._getColumnDisplayName(e);this._announceToScreenReader(format(culture.GroupPanel.added,s))}}_moveGroup(e,t){let r=this._gds,s=this._getElementIndex(this._dragMarker),i=this._getIndex(t);i>s&&i--;i>=this._gds.length&&(i=this._gds.length);s!=i&&r.deferUpdate(()=>{const e=r[s];r.removeAt(s);r.insert(i,e)})}_removeGroup(e,t=this._gds){const r=t&&e>-1?t[e]:null,s=r instanceof PropertyGroupDescription?r.propertyName:null,i=s?this._g.columns.getColumn(s):null;if(i){i.visible=!0;const e=this._hiddenCols,t=e.indexOf(i);t>-1&&e.splice(t,1)}r&&t.removeAt(e)}_getIndex(e){const t=e.clientX,r=this._divMarkers.children;for(let e=0;e<r.length;e++){const s=r[e].getBoundingClientRect();if((t-s.left)*(t-s.right)<0)return e}return r.length}_getElementIndex(e){if(e&&e.parentElement){const t=e.parentElement.children;for(let r=0;r<t.length;r++)if(t[r]==e)return r}return-1}_draggingColumn(e,t){const r=this._g,s=r._getBindingColumn(t.panel,t.row,r.columns[t.col]);this._dragCol=s.binding?s:null}_itemsSourceChanging(e,t){this._hiddenCols.forEach(e=>{e.visible=!0});this._hiddenCols=[]}_itemsSourceChanged(e,t){this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._view=this._g?this._g.collectionView:null;this._gds=this._view?this._view.groupDescriptions:null;this._view&&this._view.collectionChanged.addHandler(this._collectionChanged,this);this.invalidate()}_collectionChanged(e,t){t.action==NotifyCollectionChangedAction.Reset&&this.invalidate()}_dragStart(e){_startDrag(e.dataTransfer,"move");this._dragMarker=e.target;this._dragCol=null}_dragOver(e){if(this._dragCol||this._dragMarker){e.dataTransfer.dropEffect="move";e.preventDefault();e.stopPropagation()}}_drop(e){this._dragMarker?this._moveGroup(this._dragMarker,e):this._dragCol&&this._addGroup(this._dragCol,e)}_dragEnd(e){this._dragMarker=this._dragCol=null}_keyDown(e){if(e.altKey){const t=this._g.selection,r=this._g.columns[t.col],s=this._g.rows[t.row]instanceof GroupRow;if(r&&"KeyG"===e.code&&!0!==this.isDisabled&&!s){this._addGroup(r,e);e.preventDefault()}}}_click(e){const t=e.target,r=closest(t,"."+FlexGridClsNames.cell);if(hasClass(r,FlexGridClsNames.cell))if(hasClass(t,"wj-filter")){if(r!=this._filterMarker){this._editFilter(r);this._filterMarker=r;return}}else if(hasClass(t,UtilitesClsNames.remove)){const e=this._getElementIndex(r),t=this._gds&&e>-1?this._gds[e]:null,s=t instanceof PropertyGroupDescription?t.propertyName:null,{displayName:i}=this._getColumnInfoByProperty(s);this._removeGroup(e);i&&this._announceToScreenReader(`${culture.GroupPanel.remove} ${i}`)}else this._updateSort(e,r);this._filterMarker=null}_updateSort(e,t){const r=this._g,s=r.collectionView;if(!s||!s.canSort||r.allowSorting==AllowSorting.None)return;const i=this._getElementIndex(t),o=this._gds[i],n=o instanceof PropertyGroupDescription?o.propertyName:null,l=n?r.getColumn(n):null;if(!l||!l.allowSorting)return;let a=l.sortMemberPath||l.binding,d=-1,h=s.sortDescriptions;for(let e=0;e<h.length;e++)if(h[e].property==a){d=e;break}const u=new CellRangeEventArgs(r.columnHeaders,new CellRange(0,l.index),e);if(r.onSortingColumn(u)){const t=e.ctrlKey||e.metaKey,s=e.shiftKey;h.deferUpdate(()=>{if(t&&s)h.clear();else if(d<0){r.allowSorting!=AllowSorting.MultiColumn&&h.clear();const e=null==l.sortOrder?r.sortOrder==SortOrder.AscDesc||r.sortOrder==SortOrder.AscDescNone:l.sortOrder==SortOrder.AscDesc||l.sortOrder==SortOrder.AscDescNone,t=new SortDescription(a,e);h.push(t)}else{const e=h[d].ascending,s=null!=l.sortOrder?l.sortOrder:r.sortOrder;if(t||e&&(s===SortOrder.DescAscNone||r.isTouching&&s===SortOrder.DescAsc)||!e&&(s===SortOrder.AscDescNone||r.isTouching&&s===SortOrder.AscDesc))h.splice(d,1);else{const t=new SortDescription(a,!e);h.splice(d,1,t)}}});r.onSortedColumn(u)}}_removeEventForGrid(){const e=this._g;if(e){e.draggingColumn.removeHandler(this._draggingColumn);e.itemsSourceChanging.removeHandler(this._itemsSourceChanging);e.itemsSourceChanged.removeHandler(this._itemsSourceChanged);e.columns.collectionChanged.removeHandler(this._itemsSourceChanged);e.removeEventListener(e.hostElement,"dragend",this._dragEndBnd);e.removeEventListener(e.hostElement,"keydown",this._keyDownBnd)}}dispose(){this._removeEventForGrid();this._g=null;this._divMarkers.querySelectorAll("."+FlexGridClsNames.cell).forEach(e=>{e.removeEventListener("keydown",this._markerKeydownHandler);e.removeEventListener("focus",this._markerFocusHandler);e.removeAttribute("draggable")});this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._focusGd=null;this._dragMarker=null;this._dragCol=null;this._filterMarker=null;this._divPH=null;this._groupStatus=null;if(this._divMarkers){this._divMarkers.innerHTML="";this._divMarkers=null}if(this._mkfocus){clearTimeout(this._mkfocus);this._mkfocus=null}if(this._newMkFocus){clearTimeout(this._newMkFocus);this._newMkFocus=null}super.dispose()}}GroupPanel._ctrlTemplate="";GroupPanel._INDEX_KEY=FlexGridClsNames.cellIndex;function format(e,...t){return t.reduce((e,t,r)=>e.replace(new RegExp(`\\{${r}\\}`,"g"),t),e)}_registerModule("wijmo.grid.grouppanel",selfModule);
|
package/es5-esm.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.48
|
|
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,r){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};return function(e,r){extendStatics(e,r);function __(){this.constructor=e}e.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)}}();import{_getModule,Control,SortDescription,PropertyGroupDescription,NotifyCollectionChangedAction,assert,asBoolean,asNumber,asType,setCss,toggleClass,culture,_addCultureInfo,createElement,removeChild,_startDrag,hasClass,closest,GlyphClsNames,ControlClsNames,UtilitesClsNames,setAttribute,_isMacOS,_registerModule}from"@grapecity/wijmo";import{FlexGrid,CellRange,CellRangeEventArgs,AllowSorting,FlexGridClsNames,SortOrder,GroupRow}from"@grapecity/wijmo.grid";import*as selfModule from"@grapecity/wijmo.grid.grouppanel";export var GroupPanelClsNames={groupMarker:"wj-groupmarker",hostElement:"wj-grouppanel",groupPlaceholder:"wj-groupplaceholder"};export function softGridFilter(){return _getModule("wijmo.grid.filter")}_addCultureInfo("GroupPanel",{dragDrop:"Drag and Drop columns here to create Groups.",groupPanel:"Grouped columns panel",groupDescription:"Grouped by {0}{1}",groupAction:"Activate to toggle sort or remove group.",sortedAsc:", sorted ascending",sortedDesc:", sorted descending",sortedAscStatus:"{0} ascending",sortedDescStatus:"{0} descending",remove:"Remove group",added:"Added group {0}"});var GroupPanel=function(e){__extends(GroupPanel,e);function GroupPanel(r,t){var o=e.call(this,r)||this;o._hideGroupedCols=!0;o._showDragGlyphs=!0;o._maxGroups=6;o._hiddenCols=[];o._placeholder=null;o._dragEndBnd=o._dragEnd.bind(o);o._keyDownBnd=o._keyDown.bind(o);o._focusGd=null;o._ariaLabel=culture.GroupPanel.groupPanel;var n=o.getTemplate();o.applyTemplate(GroupPanelClsNames.hostElement+" "+ControlClsNames.hostElement,n,{_divMarkers:"div-markers",_divPH:"div-ph",_groupStatus:"group-status"});setCss(o._divMarkers.parentElement,{width:"100%",height:"100%",minHeight:"1em",overflow:"hidden",cursor:"default"});var i=o.hostElement,l=o.addEventListener.bind(o);l(i,"dragstart",o._dragStart.bind(o));l(i,"dragover",o._dragOver.bind(o));l(i,"drop",o._drop.bind(o));l(i,"dragend",o._dragEndBnd);setAttribute(i,"role","region");setAttribute(i,"aria-label",o._ariaLabel);l(i,"click",o._click.bind(o));o.initialize(t);return o}Object.defineProperty(GroupPanel,"controlTemplate",{get:function(){GroupPanel._ctrlTemplate||(GroupPanel._ctrlTemplate='<div><div wj-part="div-ph" class="'+GroupPanelClsNames.groupPlaceholder+'"></div><div wj-part="div-markers"></div><div wj-part="group-status" aria-live="polite" class="'+FlexGridClsNames.screenReaderOnly+'"></div></div>');return GroupPanel._ctrlTemplate},set:function(e){GroupPanel._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"hideGroupedColumns",{get:function(){return this._hideGroupedCols},set:function(e){e!=this._hideGroupedCols&&(this._hideGroupedCols=asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"showDragGlyphs",{get:function(){return this._showDragGlyphs},set:function(e){if(e!=this._showDragGlyphs){this._showDragGlyphs=asBoolean(e);this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"maxGroups",{get:function(){return this._maxGroups},set:function(e){if(e!=this._maxGroups){this._maxGroups=asNumber(e);var r=this._gds,t=this._maxGroups;r&&t>-1&&t<r.length&&r.splice(t,r.length-t)}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"placeholder",{get:function(){return this._placeholder},set:function(e){if(e!=this._placeholder){this._placeholder=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"grid",{get:function(){return this._g},set:function(e){if((e=asType(e,FlexGrid,!0))!=this._g){var r=this._g;this._removeEventForGrid();r=this._g=e;this._hiddenCols=[];if(r){r.draggingColumn.addHandler(this._draggingColumn,this);r.itemsSourceChanging.addHandler(this._itemsSourceChanging,this);r.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);r.columns.collectionChanged.addHandler(this._itemsSourceChanged,this);r.addEventListener(r.hostElement,"dragend",this._dragEndBnd);r.addEventListener(r.hostElement,"keydown",this._keyDownBnd)}this._itemsSourceChanged(r,null)}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"collectionView",{get:function(){return this._g?this._g.collectionView:null},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"filter",{get:function(){return this._filter},set:function(e){if((e=asType(e,softGridFilter().FlexGridFilter,!0))!=this._filter){var r=this._filter;if(r){r.filterApplied.removeHandler(this.refresh,this);r.filterChanged.removeHandler(this._filterChanged,this)}if(r=this._filter=e){r.filterApplied.addHandler(this.refresh,this);r.filterChanged.addHandler(this._filterChanged,this)}this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"groupDescriptionCreator",{get:function(){return this._gdc},set:function(e){this._gdc=e},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"ariaLabel",{get:function(){return this._ariaLabel},set:function(e){if(e!=this._ariaLabel){this._ariaLabel=e;setAttribute(this.hostElement,"aria-label",this._ariaLabel)}},enumerable:!0,configurable:!0});GroupPanel.prototype.refresh=function(){var r=this;e.prototype.refresh.call(this);this._divMarkers.innerHTML="";this._dragMarker=this._dragCol=null;if(this._gds){var t=0===this._gds.length?"0":"-1";setAttribute(this.hostElement,"tabindex",t);this._orgTabIndex=+t;for(var o,n=this._g,i=n.columnHeaders,_loop_1=function(e){var t=l._gds[e],s=-1,a=-1;if(t instanceof PropertyGroupDescription)for(var u=i.rows.length-1;u>=0&&a<0;u--)for(var d=0;d<i.columns.length&&a<0;d++){if((h=n._getBindingColumn(i,u,i.columns[d]))&&h.binding==t.propertyName){a=d;s=u;break}}if(a>-1&&s>-1){var p=document.createElement("button");p.dataset.groupPanel="true";n.cellFactory.updateCell(l._g.columnHeaders,s,a,p);delete p.dataset.groupPanel;setAttribute(p,"class",FlexGridClsNames.cell+" "+FlexGridClsNames.header+" "+GroupPanelClsNames.groupMarker);setAttribute(p,"role","button");setAttribute(p,"tabindex","0");p.removeAttribute("aria-sort");p.removeAttribute("aria-readonly");p.removeAttribute("aria-required");var c=t instanceof PropertyGroupDescription?t.propertyName:"";l._markerFocusHandler=function(){r._focusGd=t};p.addEventListener("focus",l._markerFocusHandler);l._focusGd===t&&l._focus&&(l._mkfocus=setTimeout((function(){p.focus()}),50));l._markerKeydownHandler=function(e){if((_isMacOS()?e.metaKey:e.ctrlKey)&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){e.preventDefault();var t=Array.from(r._divMarkers.children),o=(i=t.indexOf(p))+("ArrowLeft"===e.key?-1:1);if(o>=0&&o<t.length){r._moveGroupByIndex(i,o);r._newMkFocus=setTimeout((function(){var e=r._divMarkers.children[o];e&&e.focus()}),0)}}var n=Array.from(r._divMarkers.children);if("Delete"!==e.key||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey){var i=n.indexOf(p);switch(e.key){case"ArrowLeft":i>0&&n[i-1].focus();break;case"ArrowRight":i<n.length-1&&n[i+1].focus();break;case"Home":(s=n[0])&&s.focus();e.preventDefault();break;case"End":var l=n[n.length-1];l&&l.focus();e.preventDefault()}}else{var s,a=e.target,u=closest(a,"."+FlexGridClsNames.cell),d=r._getElementIndex(u),h=r._getColumnInfoByProperty(c).displayName;r._removeGroup(d);r._announceToScreenReader(culture.GroupPanel.remove+" "+h);r._filterMarker=null;(s=n[0===d?1:0])?s.focus():r.hostElement.focus()}};p.addEventListener("keydown",l._markerKeydownHandler);setCss(p,{position:"static",display:"inline-block",verticalAlign:"top",left:"",right:"",top:"",width:"",height:"",paddingLeft:"",paddingRight:""});removeChild(p.querySelector(".wj-elem-filter"));removeChild(p.querySelector(".wj-column-selector"));if(l.showDragGlyphs){o=createElement("<span class="+GlyphClsNames.drag+' aria-hidden="true"></span>');p.insertBefore(o,p.firstChild)}var h,g=(h=n._getBindingColumn(i,s,i.columns[a]))?l._getColumnDisplayName(h):c,_=l._getSortStateDescription(c,i,a),f=g;c!==g&&(f+=", grouped by "+c);f+=_;p.setAttribute("aria-label",f+". "+culture.GroupPanel.groupAction);var m=l._getColumnFilter(h);if(m){var v=createElement('<span class="wj-filter '+GlyphClsNames.filter+'"></span>',p);toggleClass(v,"wj-filter-on",m.isActive);toggleClass(v,"wj-filter-off",!m.isActive)}createElement('<span class="'+UtilitesClsNames.remove+'" aria-hidden="true">×</span>',p);l._divMarkers.appendChild(p);if(h&&l.hideGroupedColumns){var y=[];if(l.grid.layoutDefinition){l.grid.layoutDefinition.forEach((function(e){return e.cells.forEach((function(e){return y.push(e.binding)}))}))}if(!y.includes(h._binding.path)){h.visible=!1;l._hiddenCols.push(h)}}p[GroupPanel._INDEX_KEY]={row:s,col:a,panel:l}}},l=this,s=0;s<this._gds.length;s++)_loop_1(s);this._divPH.textContent=null!=this._placeholder?this._placeholder:culture.GroupPanel.dragDrop;var a=this._divMarkers.children.length>0;this._divPH.style.display=a?"none":"";this._divMarkers.style.display=a?"":"none"}};GroupPanel.prototype.hitTest=function(e){var r=e instanceof HTMLElement?e:e instanceof MouseEvent?e.target:null;assert(null!=r,"MouseEvent or Element expected");var t=closest(r,"."+FlexGridClsNames.cell);if(hasClass(t,FlexGridClsNames.cell)){var o=this._getElementIndex(t);return this._gds&&o>-1?this._gds[o]:null}return null};GroupPanel.prototype._filterChanged=function(){this._filterMarker=null};GroupPanel.prototype._getColumnFilter=function(e){var r=this._filter,t=null;r&&(t=r.filterColumns&&r.filterColumns.indexOf(e.binding)<0?null:r.getColumnFilter(e));return t};GroupPanel.prototype._getColumnDisplayName=function(e){return e?e.header||e.binding:""};GroupPanel.prototype._getColumnInfoByProperty=function(e){var r=e?this._g.columns.getColumn(e):null;return{col:r,displayName:r?this._getColumnDisplayName(r):e}};GroupPanel.prototype._announceToScreenReader=function(e){this._groupStatus&&(this._groupStatus.textContent=e)};GroupPanel.prototype._getSortStateDescription=function(e,r,t){var o="";if(this._view){var n=this._view.sortDescriptions.find((function(r){return r.property===e}));if(n){o=n.ascending?culture.GroupPanel.sortedAsc:culture.GroupPanel.sortedDesc;if(this._view.sortDescriptions.length>1){var i=r.columns[t]&&r.columns[t].currentSortIndex;i>-1&&(o+=" "+culture.FlexGrid.ariaLabels.sortIndex+" "+(i+1))}}}return o};GroupPanel.prototype._moveGroupByIndex=function(e,r){var t=this,o=this._gds;o&&e>=0&&r>=0&&e<o.length&&r<o.length&&o.deferUpdate((function(){var n=o[e];o.removeAt(e);o.insert(r,n);t.refresh()}))};GroupPanel.prototype._removeGroupByColumn=function(e){for(var r=e.binding,t=this._gds,o=t.length-1;o>=0;o--){var n=t[o];n instanceof PropertyGroupDescription&&n.propertyName===r&&this._removeGroup(o)}};GroupPanel.prototype._editFilter=function(e){var r=this._gds,t=this._getElementIndex(e),o=r&&t>-1?r[t]:null,n=o instanceof PropertyGroupDescription?o.propertyName:null,i=n?this._g.getColumn(n):null;i&&this._filter.editColumnFilter(i,null,e)};GroupPanel.prototype._addGroup=function(e,r){var t=this._gds,o=this._maxGroups,n=this._divMarkers.children.length;if(r){n=this._getIndex(r);for(var i=0;i<t.length;i++){var l=t[i];if(l instanceof PropertyGroupDescription&&l.propertyName==e.binding){t.removeAt(i);i<n&&n--;break}}if(o>-1)for(i=o-1;i<t.length;i++){this._removeGroup(i,t);i<n&&n--}}if(o<0||t.length<o){var s=this._gdc?this._gdc(e.binding):null;s||(s=new PropertyGroupDescription(e.binding));t.insert(n,s);if(e&&this.hideGroupedColumns){e.visible=!1;this._hiddenCols.push(e)}var a=this._getColumnDisplayName(e);this._announceToScreenReader(format(culture.GroupPanel.added,a))}};GroupPanel.prototype._moveGroup=function(e,r){var t=this._gds,o=this._getElementIndex(this._dragMarker),n=this._getIndex(r);n>o&&n--;n>=this._gds.length&&(n=this._gds.length);o!=n&&t.deferUpdate((function(){var e=t[o];t.removeAt(o);t.insert(n,e)}))};GroupPanel.prototype._removeGroup=function(e,r){void 0===r&&(r=this._gds);var t=r&&e>-1?r[e]:null,o=t instanceof PropertyGroupDescription?t.propertyName:null,n=o?this._g.columns.getColumn(o):null;if(n){n.visible=!0;var i=this._hiddenCols,l=i.indexOf(n);l>-1&&i.splice(l,1)}t&&r.removeAt(e)};GroupPanel.prototype._getIndex=function(e){for(var r=e.clientX,t=this._divMarkers.children,o=0;o<t.length;o++){var n=t[o].getBoundingClientRect();if((r-n.left)*(r-n.right)<0)return o}return t.length};GroupPanel.prototype._getElementIndex=function(e){if(e&&e.parentElement)for(var r=e.parentElement.children,t=0;t<r.length;t++)if(r[t]==e)return t;return-1};GroupPanel.prototype._draggingColumn=function(e,r){var t=this._g,o=t._getBindingColumn(r.panel,r.row,t.columns[r.col]);this._dragCol=o.binding?o:null};GroupPanel.prototype._itemsSourceChanging=function(e,r){this._hiddenCols.forEach((function(e){e.visible=!0}));this._hiddenCols=[]};GroupPanel.prototype._itemsSourceChanged=function(e,r){this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._view=this._g?this._g.collectionView:null;this._gds=this._view?this._view.groupDescriptions:null;this._view&&this._view.collectionChanged.addHandler(this._collectionChanged,this);this.invalidate()};GroupPanel.prototype._collectionChanged=function(e,r){r.action==NotifyCollectionChangedAction.Reset&&this.invalidate()};GroupPanel.prototype._dragStart=function(e){_startDrag(e.dataTransfer,"move");this._dragMarker=e.target;this._dragCol=null};GroupPanel.prototype._dragOver=function(e){if(this._dragCol||this._dragMarker){e.dataTransfer.dropEffect="move";e.preventDefault();e.stopPropagation()}};GroupPanel.prototype._drop=function(e){this._dragMarker?this._moveGroup(this._dragMarker,e):this._dragCol&&this._addGroup(this._dragCol,e)};GroupPanel.prototype._dragEnd=function(e){this._dragMarker=this._dragCol=null};GroupPanel.prototype._keyDown=function(e){if(e.altKey){var r=this._g.selection,t=this._g.columns[r.col],o=this._g.rows[r.row]instanceof GroupRow;if(t&&"KeyG"===e.code&&!0!==this.isDisabled&&!o){this._addGroup(t,e);e.preventDefault()}}};GroupPanel.prototype._click=function(e){var r=e.target,t=closest(r,"."+FlexGridClsNames.cell);if(hasClass(t,FlexGridClsNames.cell))if(hasClass(r,"wj-filter")){if(t!=this._filterMarker){this._editFilter(t);this._filterMarker=t;return}}else if(hasClass(r,UtilitesClsNames.remove)){var o=this._getElementIndex(t),n=this._gds&&o>-1?this._gds[o]:null,i=n instanceof PropertyGroupDescription?n.propertyName:null,l=this._getColumnInfoByProperty(i).displayName;this._removeGroup(o);l&&this._announceToScreenReader(culture.GroupPanel.remove+" "+l)}else this._updateSort(e,t);this._filterMarker=null};GroupPanel.prototype._updateSort=function(e,r){var t=this._g,o=t.collectionView;if(o&&o.canSort&&t.allowSorting!=AllowSorting.None){var n=this._getElementIndex(r),i=this._gds[n],l=i instanceof PropertyGroupDescription?i.propertyName:null,s=l?t.getColumn(l):null;if(s&&s.allowSorting){for(var a=s.sortMemberPath||s.binding,u=-1,d=o.sortDescriptions,p=0;p<d.length;p++)if(d[p].property==a){u=p;break}var c=new CellRangeEventArgs(t.columnHeaders,new CellRange(0,s.index),e);if(t.onSortingColumn(c)){var h=e.ctrlKey||e.metaKey,g=e.shiftKey;d.deferUpdate((function(){if(h&&g)d.clear();else if(u<0){t.allowSorting!=AllowSorting.MultiColumn&&d.clear();var e=null==s.sortOrder?t.sortOrder==SortOrder.AscDesc||t.sortOrder==SortOrder.AscDescNone:s.sortOrder==SortOrder.AscDesc||s.sortOrder==SortOrder.AscDescNone,r=new SortDescription(a,e);d.push(r)}else{e=d[u].ascending;var o=null!=s.sortOrder?s.sortOrder:t.sortOrder;if(h||e&&(o===SortOrder.DescAscNone||t.isTouching&&o===SortOrder.DescAsc)||!e&&(o===SortOrder.AscDescNone||t.isTouching&&o===SortOrder.AscDesc))d.splice(u,1);else{r=new SortDescription(a,!e);d.splice(u,1,r)}}}));t.onSortedColumn(c)}}}};GroupPanel.prototype._removeEventForGrid=function(){var e=this._g;if(e){e.draggingColumn.removeHandler(this._draggingColumn);e.itemsSourceChanging.removeHandler(this._itemsSourceChanging);e.itemsSourceChanged.removeHandler(this._itemsSourceChanged);e.columns.collectionChanged.removeHandler(this._itemsSourceChanged);e.removeEventListener(e.hostElement,"dragend",this._dragEndBnd);e.removeEventListener(e.hostElement,"keydown",this._keyDownBnd)}};GroupPanel.prototype.dispose=function(){var r=this;this._removeEventForGrid();this._g=null;this._divMarkers.querySelectorAll("."+FlexGridClsNames.cell).forEach((function(e){e.removeEventListener("keydown",r._markerKeydownHandler);e.removeEventListener("focus",r._markerFocusHandler);e.removeAttribute("draggable")}));this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._focusGd=null;this._dragMarker=null;this._dragCol=null;this._filterMarker=null;this._divPH=null;this._groupStatus=null;if(this._divMarkers){this._divMarkers.innerHTML="";this._divMarkers=null}if(this._mkfocus){clearTimeout(this._mkfocus);this._mkfocus=null}if(this._newMkFocus){clearTimeout(this._newMkFocus);this._newMkFocus=null}e.prototype.dispose.call(this)};GroupPanel._ctrlTemplate="";GroupPanel._INDEX_KEY=FlexGridClsNames.cellIndex;return GroupPanel}(Control);export{GroupPanel};function format(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];return r.reduce((function(e,r,t){return e.replace(new RegExp("\\{"+t+"\\}","g"),r)}),e)}_registerModule("wijmo.grid.grouppanel",selfModule);
|
|
14
|
+
var __extends=this&&this.__extends||function(){var extendStatics=function(e,r){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};return function(e,r){extendStatics(e,r);function __(){this.constructor=e}e.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)}}();import{_getModule,Control,SortDescription,PropertyGroupDescription,NotifyCollectionChangedAction,assert,asBoolean,asNumber,asType,setCss,toggleClass,culture,_addCultureInfo,createElement,removeChild,_startDrag,hasClass,closest,GlyphClsNames,ControlClsNames,UtilitesClsNames,setAttribute,_isMacOS,_registerModule}from"@grapecity/wijmo";import{FlexGrid,CellRange,CellRangeEventArgs,AllowSorting,FlexGridClsNames,SortOrder,GroupRow}from"@grapecity/wijmo.grid";import*as selfModule from"@grapecity/wijmo.grid.grouppanel";export var GroupPanelClsNames={groupMarker:"wj-groupmarker",hostElement:"wj-grouppanel",groupPlaceholder:"wj-groupplaceholder"};export function softGridFilter(){return _getModule("wijmo.grid.filter")}_addCultureInfo("GroupPanel",{dragDrop:"Drag and Drop columns here to create Groups.",groupPanel:"Grouped columns panel",groupDescription:"Grouped by {0}{1}",groupAction:"Activate to toggle sort or remove group.",sortedAsc:", sorted ascending",sortedDesc:", sorted descending",sortedAscStatus:"{0} ascending",sortedDescStatus:"{0} descending",remove:"Remove group",added:"Added group {0}"});var GroupPanel=function(e){__extends(GroupPanel,e);function GroupPanel(r,t){var o=e.call(this,r)||this;o._hideGroupedCols=!0;o._showDragGlyphs=!0;o._maxGroups=6;o._hiddenCols=[];o._placeholder=null;o._dragEndBnd=o._dragEnd.bind(o);o._keyDownBnd=o._keyDown.bind(o);o._focusGd=null;o._ariaLabel=culture.GroupPanel.groupPanel;var n=o.getTemplate();o.applyTemplate(GroupPanelClsNames.hostElement+" "+ControlClsNames.hostElement,n,{_divMarkers:"div-markers",_divPH:"div-ph",_groupStatus:"group-status"});setCss(o._divMarkers.parentElement,{width:"100%",height:"100%",minHeight:"1em",overflow:"hidden",cursor:"default"});var i=o.hostElement,l=o.addEventListener.bind(o);l(i,"dragstart",o._dragStart.bind(o));l(i,"dragover",o._dragOver.bind(o));l(i,"drop",o._drop.bind(o));l(i,"dragend",o._dragEndBnd);setAttribute(i,"role","region");setAttribute(i,"aria-label",o._ariaLabel);l(i,"click",o._click.bind(o));o.initialize(t);return o}Object.defineProperty(GroupPanel,"controlTemplate",{get:function(){GroupPanel._ctrlTemplate||(GroupPanel._ctrlTemplate='<div><div wj-part="div-ph" class="'+GroupPanelClsNames.groupPlaceholder+'"></div><div wj-part="div-markers"></div><div wj-part="group-status" aria-live="polite" class="'+FlexGridClsNames.screenReaderOnly+'"></div></div>');return GroupPanel._ctrlTemplate},set:function(e){GroupPanel._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"hideGroupedColumns",{get:function(){return this._hideGroupedCols},set:function(e){e!=this._hideGroupedCols&&(this._hideGroupedCols=asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"showDragGlyphs",{get:function(){return this._showDragGlyphs},set:function(e){if(e!=this._showDragGlyphs){this._showDragGlyphs=asBoolean(e);this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"maxGroups",{get:function(){return this._maxGroups},set:function(e){if(e!=this._maxGroups){this._maxGroups=asNumber(e);var r=this._gds,t=this._maxGroups;r&&t>-1&&t<r.length&&r.splice(t,r.length-t)}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"placeholder",{get:function(){return this._placeholder},set:function(e){if(e!=this._placeholder){this._placeholder=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"grid",{get:function(){return this._g},set:function(e){if((e=asType(e,FlexGrid,!0))!=this._g){var r=this._g;this._removeEventForGrid();r=this._g=e;this._hiddenCols=[];if(r){r.draggingColumn.addHandler(this._draggingColumn,this);r.itemsSourceChanging.addHandler(this._itemsSourceChanging,this);r.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);r.columns.collectionChanged.addHandler(this._itemsSourceChanged,this);r.addEventListener(r.hostElement,"dragend",this._dragEndBnd);r.addEventListener(r.hostElement,"keydown",this._keyDownBnd)}this._itemsSourceChanged(r,null)}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"collectionView",{get:function(){return this._g?this._g.collectionView:null},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"filter",{get:function(){return this._filter},set:function(e){if((e=asType(e,softGridFilter().FlexGridFilter,!0))!=this._filter){var r=this._filter;if(r){r.filterApplied.removeHandler(this.refresh,this);r.filterChanged.removeHandler(this._filterChanged,this)}if(r=this._filter=e){r.filterApplied.addHandler(this.refresh,this);r.filterChanged.addHandler(this._filterChanged,this)}this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"groupDescriptionCreator",{get:function(){return this._gdc},set:function(e){this._gdc=e},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"ariaLabel",{get:function(){return this._ariaLabel},set:function(e){if(e!=this._ariaLabel){this._ariaLabel=e;setAttribute(this.hostElement,"aria-label",this._ariaLabel)}},enumerable:!0,configurable:!0});GroupPanel.prototype.refresh=function(){var r=this;e.prototype.refresh.call(this);this._divMarkers.innerHTML="";this._dragMarker=this._dragCol=null;if(this._gds){var t=0===this._gds.length?"0":"-1";setAttribute(this.hostElement,"tabindex",t);this._orgTabIndex=+t;for(var o=this._g,n=o.columnHeaders,_loop_1=function(e){var t=i._gds[e],l=-1,s=-1;if(t instanceof PropertyGroupDescription)for(var a=n.rows.length-1;a>=0&&s<0;a--)for(var u=0;u<n.columns.length&&s<0;u++){if((h=o._getBindingColumn(n,a,n.columns[u]))&&h.binding==t.propertyName){s=u;l=a;break}}if(s>-1&&l>-1){var d=document.createElement("button");d.dataset.groupPanel="true";o.cellFactory.updateCell(i._g.columnHeaders,l,s,d);delete d.dataset.groupPanel;setAttribute(d,"class",FlexGridClsNames.cell+" "+FlexGridClsNames.header+" "+GroupPanelClsNames.groupMarker);setAttribute(d,"role","button");setAttribute(d,"tabindex","0");d.removeAttribute("aria-sort");d.removeAttribute("aria-readonly");d.removeAttribute("aria-required");var p=t instanceof PropertyGroupDescription?t.propertyName:"";i._markerFocusHandler=function(){r._focusGd=t};d.addEventListener("focus",i._markerFocusHandler);i._focusGd===t&&i._focus&&(i._mkfocus=setTimeout((function(){d.focus()}),50));i._markerKeydownHandler=function(e){if((_isMacOS()?e.metaKey:e.ctrlKey)&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){e.preventDefault();var t=Array.from(r._divMarkers.children),o=(i=t.indexOf(d))+("ArrowLeft"===e.key?-1:1);if(o>=0&&o<t.length){r._moveGroupByIndex(i,o);r._newMkFocus=setTimeout((function(){var e=r._divMarkers.children[o];e&&e.focus()}),0)}}var n=Array.from(r._divMarkers.children);if("Delete"!==e.key||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey){var i=n.indexOf(d);switch(e.key){case"ArrowLeft":i>0&&n[i-1].focus();break;case"ArrowRight":i<n.length-1&&n[i+1].focus();break;case"Home":(s=n[0])&&s.focus();e.preventDefault();break;case"End":var l=n[n.length-1];l&&l.focus();e.preventDefault()}}else{var s,a=e.target,u=closest(a,"."+FlexGridClsNames.cell),c=r._getElementIndex(u),h=r._getColumnInfoByProperty(p).displayName;r._removeGroup(c);r._announceToScreenReader(culture.GroupPanel.remove+" "+h);r._filterMarker=null;(s=n[0===c?1:0])?s.focus():r.hostElement.focus()}};d.addEventListener("keydown",i._markerKeydownHandler);setCss(d,{position:"static",display:"inline-block",verticalAlign:"top",left:"",right:"",top:"",width:"",height:"",paddingLeft:"",paddingRight:""});removeChild(d.querySelector(".wj-elem-filter"));removeChild(d.querySelector(".wj-column-selector"));if(i.showDragGlyphs){var c=createElement("<span class="+GlyphClsNames.drag+' aria-hidden="true"></span>');d.insertBefore(c,d.firstChild)}var h,g=(h=o._getBindingColumn(n,l,n.columns[s]))?i._getColumnDisplayName(h):p,_=i._getSortStateDescription(p,n,s),f=g;p!==g&&(f+=", grouped by "+p);f+=_;d.setAttribute("aria-label",f+". "+culture.GroupPanel.groupAction);var m=i._getColumnFilter(h);if(m){var v=createElement('<span class="wj-filter '+GlyphClsNames.filter+'"></span>',d);toggleClass(v,"wj-filter-on",m.isActive);toggleClass(v,"wj-filter-off",!m.isActive)}createElement('<span class="'+UtilitesClsNames.remove+'" aria-hidden="true">×</span>',d);i._divMarkers.appendChild(d);if(h&&i.hideGroupedColumns){var y=[];if(i.grid.layoutDefinition){i.grid.layoutDefinition.forEach((function(e){e.cells.forEach((function(e){y.push(e.binding)}))}))}if(!y.includes(h._binding.path)){h.visible=!1;i._hiddenCols.push(h)}}d[GroupPanel._INDEX_KEY]={row:l,col:s,panel:i}}},i=this,l=0;l<this._gds.length;l++)_loop_1(l);this._divPH.textContent=null!=this._placeholder?this._placeholder:culture.GroupPanel.dragDrop;var s=this._divMarkers.children.length>0;this._divPH.style.display=s?"none":"";this._divMarkers.style.display=s?"":"none"}};GroupPanel.prototype.hitTest=function(e){var r=e instanceof HTMLElement?e:e instanceof MouseEvent?e.target:null;assert(null!=r,"MouseEvent or Element expected");var t=closest(r,"."+FlexGridClsNames.cell);if(hasClass(t,FlexGridClsNames.cell)){var o=this._getElementIndex(t);return this._gds&&o>-1?this._gds[o]:null}return null};GroupPanel.prototype._filterChanged=function(){this._filterMarker=null};GroupPanel.prototype._getColumnFilter=function(e){var r=this._filter,t=null;r&&(t=r.filterColumns&&r.filterColumns.indexOf(e.binding)<0?null:r.getColumnFilter(e));return t};GroupPanel.prototype._getColumnDisplayName=function(e){return e?e.header||e.binding:""};GroupPanel.prototype._getColumnInfoByProperty=function(e){var r=e?this._g.columns.getColumn(e):null;return{col:r,displayName:r?this._getColumnDisplayName(r):e}};GroupPanel.prototype._announceToScreenReader=function(e){this._groupStatus&&(this._groupStatus.textContent=e)};GroupPanel.prototype._getSortStateDescription=function(e,r,t){var o="";if(this._view){var n=this._view.sortDescriptions.find((function(r){return r.property===e}));if(n){o=n.ascending?culture.GroupPanel.sortedAsc:culture.GroupPanel.sortedDesc;if(this._view.sortDescriptions.length>1){var i=r.columns[t]&&r.columns[t].currentSortIndex;i>-1&&(o+=" "+culture.FlexGrid.ariaLabels.sortIndex+" "+(i+1))}}}return o};GroupPanel.prototype._moveGroupByIndex=function(e,r){var t=this,o=this._gds;o&&e>=0&&r>=0&&e<o.length&&r<o.length&&o.deferUpdate((function(){var n=o[e];o.removeAt(e);o.insert(r,n);t.refresh()}))};GroupPanel.prototype._removeGroupByColumn=function(e){for(var r=e.binding,t=this._gds,o=t.length-1;o>=0;o--){var n=t[o];n instanceof PropertyGroupDescription&&n.propertyName===r&&this._removeGroup(o)}};GroupPanel.prototype._editFilter=function(e){var r=this._gds,t=this._getElementIndex(e),o=r&&t>-1?r[t]:null,n=o instanceof PropertyGroupDescription?o.propertyName:null,i=n?this._g.getColumn(n):null;i&&this._filter.editColumnFilter(i,null,e)};GroupPanel.prototype._addGroup=function(e,r){var t=this._gds,o=this._maxGroups,n=this._divMarkers.children.length;if(r){n=this._getIndex(r);for(var i=0;i<t.length;i++){var l=t[i];if(l instanceof PropertyGroupDescription&&l.propertyName==e.binding){t.removeAt(i);i<n&&n--;break}}if(o>-1)for(i=o-1;i<t.length;i++){this._removeGroup(i,t);i<n&&n--}}if(o<0||t.length<o){var s=this._gdc?this._gdc(e.binding):null;s||(s=new PropertyGroupDescription(e.binding));t.insert(n,s);if(e&&this.hideGroupedColumns){e.visible=!1;this._hiddenCols.push(e)}var a=this._getColumnDisplayName(e);this._announceToScreenReader(format(culture.GroupPanel.added,a))}};GroupPanel.prototype._moveGroup=function(e,r){var t=this._gds,o=this._getElementIndex(this._dragMarker),n=this._getIndex(r);n>o&&n--;n>=this._gds.length&&(n=this._gds.length);o!=n&&t.deferUpdate((function(){var e=t[o];t.removeAt(o);t.insert(n,e)}))};GroupPanel.prototype._removeGroup=function(e,r){void 0===r&&(r=this._gds);var t=r&&e>-1?r[e]:null,o=t instanceof PropertyGroupDescription?t.propertyName:null,n=o?this._g.columns.getColumn(o):null;if(n){n.visible=!0;var i=this._hiddenCols,l=i.indexOf(n);l>-1&&i.splice(l,1)}t&&r.removeAt(e)};GroupPanel.prototype._getIndex=function(e){for(var r=e.clientX,t=this._divMarkers.children,o=0;o<t.length;o++){var n=t[o].getBoundingClientRect();if((r-n.left)*(r-n.right)<0)return o}return t.length};GroupPanel.prototype._getElementIndex=function(e){if(e&&e.parentElement)for(var r=e.parentElement.children,t=0;t<r.length;t++)if(r[t]==e)return t;return-1};GroupPanel.prototype._draggingColumn=function(e,r){var t=this._g,o=t._getBindingColumn(r.panel,r.row,t.columns[r.col]);this._dragCol=o.binding?o:null};GroupPanel.prototype._itemsSourceChanging=function(e,r){this._hiddenCols.forEach((function(e){e.visible=!0}));this._hiddenCols=[]};GroupPanel.prototype._itemsSourceChanged=function(e,r){this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._view=this._g?this._g.collectionView:null;this._gds=this._view?this._view.groupDescriptions:null;this._view&&this._view.collectionChanged.addHandler(this._collectionChanged,this);this.invalidate()};GroupPanel.prototype._collectionChanged=function(e,r){r.action==NotifyCollectionChangedAction.Reset&&this.invalidate()};GroupPanel.prototype._dragStart=function(e){_startDrag(e.dataTransfer,"move");this._dragMarker=e.target;this._dragCol=null};GroupPanel.prototype._dragOver=function(e){if(this._dragCol||this._dragMarker){e.dataTransfer.dropEffect="move";e.preventDefault();e.stopPropagation()}};GroupPanel.prototype._drop=function(e){this._dragMarker?this._moveGroup(this._dragMarker,e):this._dragCol&&this._addGroup(this._dragCol,e)};GroupPanel.prototype._dragEnd=function(e){this._dragMarker=this._dragCol=null};GroupPanel.prototype._keyDown=function(e){if(e.altKey){var r=this._g.selection,t=this._g.columns[r.col],o=this._g.rows[r.row]instanceof GroupRow;if(t&&"KeyG"===e.code&&!0!==this.isDisabled&&!o){this._addGroup(t,e);e.preventDefault()}}};GroupPanel.prototype._click=function(e){var r=e.target,t=closest(r,"."+FlexGridClsNames.cell);if(hasClass(t,FlexGridClsNames.cell))if(hasClass(r,"wj-filter")){if(t!=this._filterMarker){this._editFilter(t);this._filterMarker=t;return}}else if(hasClass(r,UtilitesClsNames.remove)){var o=this._getElementIndex(t),n=this._gds&&o>-1?this._gds[o]:null,i=n instanceof PropertyGroupDescription?n.propertyName:null,l=this._getColumnInfoByProperty(i).displayName;this._removeGroup(o);l&&this._announceToScreenReader(culture.GroupPanel.remove+" "+l)}else this._updateSort(e,t);this._filterMarker=null};GroupPanel.prototype._updateSort=function(e,r){var t=this._g,o=t.collectionView;if(o&&o.canSort&&t.allowSorting!=AllowSorting.None){var n=this._getElementIndex(r),i=this._gds[n],l=i instanceof PropertyGroupDescription?i.propertyName:null,s=l?t.getColumn(l):null;if(s&&s.allowSorting){for(var a=s.sortMemberPath||s.binding,u=-1,d=o.sortDescriptions,p=0;p<d.length;p++)if(d[p].property==a){u=p;break}var c=new CellRangeEventArgs(t.columnHeaders,new CellRange(0,s.index),e);if(t.onSortingColumn(c)){var h=e.ctrlKey||e.metaKey,g=e.shiftKey;d.deferUpdate((function(){if(h&&g)d.clear();else if(u<0){t.allowSorting!=AllowSorting.MultiColumn&&d.clear();var e=null==s.sortOrder?t.sortOrder==SortOrder.AscDesc||t.sortOrder==SortOrder.AscDescNone:s.sortOrder==SortOrder.AscDesc||s.sortOrder==SortOrder.AscDescNone,r=new SortDescription(a,e);d.push(r)}else{e=d[u].ascending;var o=null!=s.sortOrder?s.sortOrder:t.sortOrder;if(h||e&&(o===SortOrder.DescAscNone||t.isTouching&&o===SortOrder.DescAsc)||!e&&(o===SortOrder.AscDescNone||t.isTouching&&o===SortOrder.AscDesc))d.splice(u,1);else{r=new SortDescription(a,!e);d.splice(u,1,r)}}}));t.onSortedColumn(c)}}}};GroupPanel.prototype._removeEventForGrid=function(){var e=this._g;if(e){e.draggingColumn.removeHandler(this._draggingColumn);e.itemsSourceChanging.removeHandler(this._itemsSourceChanging);e.itemsSourceChanged.removeHandler(this._itemsSourceChanged);e.columns.collectionChanged.removeHandler(this._itemsSourceChanged);e.removeEventListener(e.hostElement,"dragend",this._dragEndBnd);e.removeEventListener(e.hostElement,"keydown",this._keyDownBnd)}};GroupPanel.prototype.dispose=function(){var r=this;this._removeEventForGrid();this._g=null;this._divMarkers.querySelectorAll("."+FlexGridClsNames.cell).forEach((function(e){e.removeEventListener("keydown",r._markerKeydownHandler);e.removeEventListener("focus",r._markerFocusHandler);e.removeAttribute("draggable")}));this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._focusGd=null;this._dragMarker=null;this._dragCol=null;this._filterMarker=null;this._divPH=null;this._groupStatus=null;if(this._divMarkers){this._divMarkers.innerHTML="";this._divMarkers=null}if(this._mkfocus){clearTimeout(this._mkfocus);this._mkfocus=null}if(this._newMkFocus){clearTimeout(this._newMkFocus);this._newMkFocus=null}e.prototype.dispose.call(this)};GroupPanel._ctrlTemplate="";GroupPanel._INDEX_KEY=FlexGridClsNames.cellIndex;return GroupPanel}(Control);export{GroupPanel};function format(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];return r.reduce((function(e,r,t){return e.replace(new RegExp("\\{"+t+"\\}","g"),r)}),e)}_registerModule("wijmo.grid.grouppanel",selfModule);
|
package/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.48
|
|
4
4
|
* https://developer.mescius.com/wijmo
|
|
5
5
|
*
|
|
6
6
|
* Copyright(c) MESCIUS inc. All rights reserved.
|
|
@@ -231,18 +231,18 @@ export declare class GroupPanel<T = any> extends Control {
|
|
|
231
231
|
_removeGroupByColumn(col: Column): void;
|
|
232
232
|
_editFilter(marker: HTMLElement): void;
|
|
233
233
|
_addGroup(col: Column, e?: MouseEvent): void;
|
|
234
|
-
_moveGroup(
|
|
234
|
+
_moveGroup(_marker: HTMLElement, e: MouseEvent): void;
|
|
235
235
|
_removeGroup(index: number, groups?: ObservableArray<GroupDescription>): void;
|
|
236
236
|
_getIndex(e: MouseEvent): number;
|
|
237
237
|
_getElementIndex(e: HTMLElement): number;
|
|
238
|
-
_draggingColumn(
|
|
239
|
-
_itemsSourceChanging(
|
|
240
|
-
_itemsSourceChanged(
|
|
241
|
-
_collectionChanged(
|
|
238
|
+
_draggingColumn(_s: FlexGrid, e: CellRangeEventArgs): void;
|
|
239
|
+
_itemsSourceChanging(_s: FlexGrid, _e: EventArgs): void;
|
|
240
|
+
_itemsSourceChanged(_s: FlexGrid, _e: EventArgs): void;
|
|
241
|
+
_collectionChanged(_sender: any, e: NotifyCollectionChangedEventArgs): void;
|
|
242
242
|
_dragStart(e: DragEvent): void;
|
|
243
243
|
_dragOver(e: DragEvent): void;
|
|
244
244
|
_drop(e: DragEvent): void;
|
|
245
|
-
_dragEnd(
|
|
245
|
+
_dragEnd(_e: DragEvent): void;
|
|
246
246
|
_keyDown(e: KeyboardEvent): void;
|
|
247
247
|
_click(e: MouseEvent): void;
|
|
248
248
|
_updateSort(e: MouseEvent, marker: HTMLElement): void;
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/*!
|
|
2
2
|
*
|
|
3
|
-
* Wijmo Library 5.
|
|
3
|
+
* Wijmo Library 5.20261.48
|
|
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,r){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};return function(e,r){extendStatics(e,r);function __(){this.constructor=e}e.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)}}(),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(r[t]=e[t]);r.default=e;return r};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_1=require("@grapecity/wijmo"),wijmo_grid_1=require("@grapecity/wijmo.grid"),selfModule=__importStar(require("@grapecity/wijmo.grid.grouppanel"));exports.GroupPanelClsNames={groupMarker:"wj-groupmarker",hostElement:"wj-grouppanel",groupPlaceholder:"wj-groupplaceholder"};function softGridFilter(){return wijmo_1._getModule("wijmo.grid.filter")}exports.softGridFilter=softGridFilter;wijmo_1._addCultureInfo("GroupPanel",{dragDrop:"Drag and Drop columns here to create Groups.",groupPanel:"Grouped columns panel",groupDescription:"Grouped by {0}{1}",groupAction:"Activate to toggle sort or remove group.",sortedAsc:", sorted ascending",sortedDesc:", sorted descending",sortedAscStatus:"{0} ascending",sortedDescStatus:"{0} descending",remove:"Remove group",added:"Added group {0}"});var GroupPanel=function(e){__extends(GroupPanel,e);function GroupPanel(r,t){var i=e.call(this,r)||this;i._hideGroupedCols=!0;i._showDragGlyphs=!0;i._maxGroups=6;i._hiddenCols=[];i._placeholder=null;i._dragEndBnd=i._dragEnd.bind(i);i._keyDownBnd=i._keyDown.bind(i);i._focusGd=null;i._ariaLabel=wijmo_1.culture.GroupPanel.groupPanel;var o=i.getTemplate();i.applyTemplate(exports.GroupPanelClsNames.hostElement+" "+wijmo_1.ControlClsNames.hostElement,o,{_divMarkers:"div-markers",_divPH:"div-ph",_groupStatus:"group-status"});wijmo_1.setCss(i._divMarkers.parentElement,{width:"100%",height:"100%",minHeight:"1em",overflow:"hidden",cursor:"default"});var n=i.hostElement,l=i.addEventListener.bind(i);l(n,"dragstart",i._dragStart.bind(i));l(n,"dragover",i._dragOver.bind(i));l(n,"drop",i._drop.bind(i));l(n,"dragend",i._dragEndBnd);wijmo_1.setAttribute(n,"role","region");wijmo_1.setAttribute(n,"aria-label",i._ariaLabel);l(n,"click",i._click.bind(i));i.initialize(t);return i}Object.defineProperty(GroupPanel,"controlTemplate",{get:function(){GroupPanel._ctrlTemplate||(GroupPanel._ctrlTemplate='<div><div wj-part="div-ph" class="'+exports.GroupPanelClsNames.groupPlaceholder+'"></div><div wj-part="div-markers"></div><div wj-part="group-status" aria-live="polite" class="'+wijmo_grid_1.FlexGridClsNames.screenReaderOnly+'"></div></div>');return GroupPanel._ctrlTemplate},set:function(e){GroupPanel._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"hideGroupedColumns",{get:function(){return this._hideGroupedCols},set:function(e){e!=this._hideGroupedCols&&(this._hideGroupedCols=wijmo_1.asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"showDragGlyphs",{get:function(){return this._showDragGlyphs},set:function(e){if(e!=this._showDragGlyphs){this._showDragGlyphs=wijmo_1.asBoolean(e);this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"maxGroups",{get:function(){return this._maxGroups},set:function(e){if(e!=this._maxGroups){this._maxGroups=wijmo_1.asNumber(e);var r=this._gds,t=this._maxGroups;r&&t>-1&&t<r.length&&r.splice(t,r.length-t)}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"placeholder",{get:function(){return this._placeholder},set:function(e){if(e!=this._placeholder){this._placeholder=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"grid",{get:function(){return this._g},set:function(e){if((e=wijmo_1.asType(e,wijmo_grid_1.FlexGrid,!0))!=this._g){var r=this._g;this._removeEventForGrid();r=this._g=e;this._hiddenCols=[];if(r){r.draggingColumn.addHandler(this._draggingColumn,this);r.itemsSourceChanging.addHandler(this._itemsSourceChanging,this);r.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);r.columns.collectionChanged.addHandler(this._itemsSourceChanged,this);r.addEventListener(r.hostElement,"dragend",this._dragEndBnd);r.addEventListener(r.hostElement,"keydown",this._keyDownBnd)}this._itemsSourceChanged(r,null)}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"collectionView",{get:function(){return this._g?this._g.collectionView:null},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"filter",{get:function(){return this._filter},set:function(e){if((e=wijmo_1.asType(e,softGridFilter().FlexGridFilter,!0))!=this._filter){var r=this._filter;if(r){r.filterApplied.removeHandler(this.refresh,this);r.filterChanged.removeHandler(this._filterChanged,this)}if(r=this._filter=e){r.filterApplied.addHandler(this.refresh,this);r.filterChanged.addHandler(this._filterChanged,this)}this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"groupDescriptionCreator",{get:function(){return this._gdc},set:function(e){this._gdc=e},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"ariaLabel",{get:function(){return this._ariaLabel},set:function(e){if(e!=this._ariaLabel){this._ariaLabel=e;wijmo_1.setAttribute(this.hostElement,"aria-label",this._ariaLabel)}},enumerable:!0,configurable:!0});GroupPanel.prototype.refresh=function(){var r=this;e.prototype.refresh.call(this);this._divMarkers.innerHTML="";this._dragMarker=this._dragCol=null;if(this._gds){var t=0===this._gds.length?"0":"-1";wijmo_1.setAttribute(this.hostElement,"tabindex",t);this._orgTabIndex=+t;for(var i,o=this._g,n=o.columnHeaders,_loop_1=function(e){var t=l._gds[e],s=-1,a=-1;if(t instanceof wijmo_1.PropertyGroupDescription)for(var u=n.rows.length-1;u>=0&&a<0;u--)for(var d=0;d<n.columns.length&&a<0;d++){if((c=o._getBindingColumn(n,u,n.columns[d]))&&c.binding==t.propertyName){a=d;s=u;break}}if(a>-1&&s>-1){var _=document.createElement("button");_.dataset.groupPanel="true";o.cellFactory.updateCell(l._g.columnHeaders,s,a,_);delete _.dataset.groupPanel;wijmo_1.setAttribute(_,"class",wijmo_grid_1.FlexGridClsNames.cell+" "+wijmo_grid_1.FlexGridClsNames.header+" "+exports.GroupPanelClsNames.groupMarker);wijmo_1.setAttribute(_,"role","button");wijmo_1.setAttribute(_,"tabindex","0");_.removeAttribute("aria-sort");_.removeAttribute("aria-readonly");_.removeAttribute("aria-required");var p=t instanceof wijmo_1.PropertyGroupDescription?t.propertyName:"";l._markerFocusHandler=function(){r._focusGd=t};_.addEventListener("focus",l._markerFocusHandler);l._focusGd===t&&l._focus&&(l._mkfocus=setTimeout((function(){_.focus()}),50));l._markerKeydownHandler=function(e){if((wijmo_1._isMacOS()?e.metaKey:e.ctrlKey)&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){e.preventDefault();var t=Array.from(r._divMarkers.children),i=(n=t.indexOf(_))+("ArrowLeft"===e.key?-1:1);if(i>=0&&i<t.length){r._moveGroupByIndex(n,i);r._newMkFocus=setTimeout((function(){var e=r._divMarkers.children[i];e&&e.focus()}),0)}}var o=Array.from(r._divMarkers.children);if("Delete"!==e.key||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey){var n=o.indexOf(_);switch(e.key){case"ArrowLeft":n>0&&o[n-1].focus();break;case"ArrowRight":n<o.length-1&&o[n+1].focus();break;case"Home":(s=o[0])&&s.focus();e.preventDefault();break;case"End":var l=o[o.length-1];l&&l.focus();e.preventDefault()}}else{var s,a=e.target,u=wijmo_1.closest(a,"."+wijmo_grid_1.FlexGridClsNames.cell),d=r._getElementIndex(u),c=r._getColumnInfoByProperty(p).displayName;r._removeGroup(d);r._announceToScreenReader(wijmo_1.culture.GroupPanel.remove+" "+c);r._filterMarker=null;(s=o[0===d?1:0])?s.focus():r.hostElement.focus()}};_.addEventListener("keydown",l._markerKeydownHandler);wijmo_1.setCss(_,{position:"static",display:"inline-block",verticalAlign:"top",left:"",right:"",top:"",width:"",height:"",paddingLeft:"",paddingRight:""});wijmo_1.removeChild(_.querySelector(".wj-elem-filter"));wijmo_1.removeChild(_.querySelector(".wj-column-selector"));if(l.showDragGlyphs){i=wijmo_1.createElement("<span class="+wijmo_1.GlyphClsNames.drag+' aria-hidden="true"></span>');_.insertBefore(i,_.firstChild)}var c,h=(c=o._getBindingColumn(n,s,n.columns[a]))?l._getColumnDisplayName(c):p,g=l._getSortStateDescription(p,n,a),m=h;p!==h&&(m+=", grouped by "+p);m+=g;_.setAttribute("aria-label",m+". "+wijmo_1.culture.GroupPanel.groupAction);var f=l._getColumnFilter(c);if(f){var v=wijmo_1.createElement('<span class="wj-filter '+wijmo_1.GlyphClsNames.filter+'"></span>',_);wijmo_1.toggleClass(v,"wj-filter-on",f.isActive);wijmo_1.toggleClass(v,"wj-filter-off",!f.isActive)}wijmo_1.createElement('<span class="'+wijmo_1.UtilitesClsNames.remove+'" aria-hidden="true">×</span>',_);l._divMarkers.appendChild(_);if(c&&l.hideGroupedColumns){var w=[];if(l.grid.layoutDefinition){l.grid.layoutDefinition.forEach((function(e){return e.cells.forEach((function(e){return w.push(e.binding)}))}))}if(!w.includes(c._binding.path)){c.visible=!1;l._hiddenCols.push(c)}}_[GroupPanel._INDEX_KEY]={row:s,col:a,panel:l}}},l=this,s=0;s<this._gds.length;s++)_loop_1(s);this._divPH.textContent=null!=this._placeholder?this._placeholder:wijmo_1.culture.GroupPanel.dragDrop;var a=this._divMarkers.children.length>0;this._divPH.style.display=a?"none":"";this._divMarkers.style.display=a?"":"none"}};GroupPanel.prototype.hitTest=function(e){var r=e instanceof HTMLElement?e:e instanceof MouseEvent?e.target:null;wijmo_1.assert(null!=r,"MouseEvent or Element expected");var t=wijmo_1.closest(r,"."+wijmo_grid_1.FlexGridClsNames.cell);if(wijmo_1.hasClass(t,wijmo_grid_1.FlexGridClsNames.cell)){var i=this._getElementIndex(t);return this._gds&&i>-1?this._gds[i]:null}return null};GroupPanel.prototype._filterChanged=function(){this._filterMarker=null};GroupPanel.prototype._getColumnFilter=function(e){var r=this._filter,t=null;r&&(t=r.filterColumns&&r.filterColumns.indexOf(e.binding)<0?null:r.getColumnFilter(e));return t};GroupPanel.prototype._getColumnDisplayName=function(e){return e?e.header||e.binding:""};GroupPanel.prototype._getColumnInfoByProperty=function(e){var r=e?this._g.columns.getColumn(e):null;return{col:r,displayName:r?this._getColumnDisplayName(r):e}};GroupPanel.prototype._announceToScreenReader=function(e){this._groupStatus&&(this._groupStatus.textContent=e)};GroupPanel.prototype._getSortStateDescription=function(e,r,t){var i="";if(this._view){var o=this._view.sortDescriptions.find((function(r){return r.property===e}));if(o){i=o.ascending?wijmo_1.culture.GroupPanel.sortedAsc:wijmo_1.culture.GroupPanel.sortedDesc;if(this._view.sortDescriptions.length>1){var n=r.columns[t]&&r.columns[t].currentSortIndex;n>-1&&(i+=" "+wijmo_1.culture.FlexGrid.ariaLabels.sortIndex+" "+(n+1))}}}return i};GroupPanel.prototype._moveGroupByIndex=function(e,r){var t=this,i=this._gds;i&&e>=0&&r>=0&&e<i.length&&r<i.length&&i.deferUpdate((function(){var o=i[e];i.removeAt(e);i.insert(r,o);t.refresh()}))};GroupPanel.prototype._removeGroupByColumn=function(e){for(var r=e.binding,t=this._gds,i=t.length-1;i>=0;i--){var o=t[i];o instanceof wijmo_1.PropertyGroupDescription&&o.propertyName===r&&this._removeGroup(i)}};GroupPanel.prototype._editFilter=function(e){var r=this._gds,t=this._getElementIndex(e),i=r&&t>-1?r[t]:null,o=i instanceof wijmo_1.PropertyGroupDescription?i.propertyName:null,n=o?this._g.getColumn(o):null;n&&this._filter.editColumnFilter(n,null,e)};GroupPanel.prototype._addGroup=function(e,r){var t=this._gds,i=this._maxGroups,o=this._divMarkers.children.length;if(r){o=this._getIndex(r);for(var n=0;n<t.length;n++){var l=t[n];if(l instanceof wijmo_1.PropertyGroupDescription&&l.propertyName==e.binding){t.removeAt(n);n<o&&o--;break}}if(i>-1)for(n=i-1;n<t.length;n++){this._removeGroup(n,t);n<o&&o--}}if(i<0||t.length<i){var s=this._gdc?this._gdc(e.binding):null;s||(s=new wijmo_1.PropertyGroupDescription(e.binding));t.insert(o,s);if(e&&this.hideGroupedColumns){e.visible=!1;this._hiddenCols.push(e)}var a=this._getColumnDisplayName(e);this._announceToScreenReader(format(wijmo_1.culture.GroupPanel.added,a))}};GroupPanel.prototype._moveGroup=function(e,r){var t=this._gds,i=this._getElementIndex(this._dragMarker),o=this._getIndex(r);o>i&&o--;o>=this._gds.length&&(o=this._gds.length);i!=o&&t.deferUpdate((function(){var e=t[i];t.removeAt(i);t.insert(o,e)}))};GroupPanel.prototype._removeGroup=function(e,r){void 0===r&&(r=this._gds);var t=r&&e>-1?r[e]:null,i=t instanceof wijmo_1.PropertyGroupDescription?t.propertyName:null,o=i?this._g.columns.getColumn(i):null;if(o){o.visible=!0;var n=this._hiddenCols,l=n.indexOf(o);l>-1&&n.splice(l,1)}t&&r.removeAt(e)};GroupPanel.prototype._getIndex=function(e){for(var r=e.clientX,t=this._divMarkers.children,i=0;i<t.length;i++){var o=t[i].getBoundingClientRect();if((r-o.left)*(r-o.right)<0)return i}return t.length};GroupPanel.prototype._getElementIndex=function(e){if(e&&e.parentElement)for(var r=e.parentElement.children,t=0;t<r.length;t++)if(r[t]==e)return t;return-1};GroupPanel.prototype._draggingColumn=function(e,r){var t=this._g,i=t._getBindingColumn(r.panel,r.row,t.columns[r.col]);this._dragCol=i.binding?i:null};GroupPanel.prototype._itemsSourceChanging=function(e,r){this._hiddenCols.forEach((function(e){e.visible=!0}));this._hiddenCols=[]};GroupPanel.prototype._itemsSourceChanged=function(e,r){this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._view=this._g?this._g.collectionView:null;this._gds=this._view?this._view.groupDescriptions:null;this._view&&this._view.collectionChanged.addHandler(this._collectionChanged,this);this.invalidate()};GroupPanel.prototype._collectionChanged=function(e,r){r.action==wijmo_1.NotifyCollectionChangedAction.Reset&&this.invalidate()};GroupPanel.prototype._dragStart=function(e){wijmo_1._startDrag(e.dataTransfer,"move");this._dragMarker=e.target;this._dragCol=null};GroupPanel.prototype._dragOver=function(e){if(this._dragCol||this._dragMarker){e.dataTransfer.dropEffect="move";e.preventDefault();e.stopPropagation()}};GroupPanel.prototype._drop=function(e){this._dragMarker?this._moveGroup(this._dragMarker,e):this._dragCol&&this._addGroup(this._dragCol,e)};GroupPanel.prototype._dragEnd=function(e){this._dragMarker=this._dragCol=null};GroupPanel.prototype._keyDown=function(e){if(e.altKey){var r=this._g.selection,t=this._g.columns[r.col],i=this._g.rows[r.row]instanceof wijmo_grid_1.GroupRow;if(t&&"KeyG"===e.code&&!0!==this.isDisabled&&!i){this._addGroup(t,e);e.preventDefault()}}};GroupPanel.prototype._click=function(e){var r=e.target,t=wijmo_1.closest(r,"."+wijmo_grid_1.FlexGridClsNames.cell);if(wijmo_1.hasClass(t,wijmo_grid_1.FlexGridClsNames.cell))if(wijmo_1.hasClass(r,"wj-filter")){if(t!=this._filterMarker){this._editFilter(t);this._filterMarker=t;return}}else if(wijmo_1.hasClass(r,wijmo_1.UtilitesClsNames.remove)){var i=this._getElementIndex(t),o=this._gds&&i>-1?this._gds[i]:null,n=o instanceof wijmo_1.PropertyGroupDescription?o.propertyName:null,l=this._getColumnInfoByProperty(n).displayName;this._removeGroup(i);l&&this._announceToScreenReader(wijmo_1.culture.GroupPanel.remove+" "+l)}else this._updateSort(e,t);this._filterMarker=null};GroupPanel.prototype._updateSort=function(e,r){var t=this._g,i=t.collectionView;if(i&&i.canSort&&t.allowSorting!=wijmo_grid_1.AllowSorting.None){var o=this._getElementIndex(r),n=this._gds[o],l=n instanceof wijmo_1.PropertyGroupDescription?n.propertyName:null,s=l?t.getColumn(l):null;if(s&&s.allowSorting){for(var a=s.sortMemberPath||s.binding,u=-1,d=i.sortDescriptions,_=0;_<d.length;_++)if(d[_].property==a){u=_;break}var p=new wijmo_grid_1.CellRangeEventArgs(t.columnHeaders,new wijmo_grid_1.CellRange(0,s.index),e);if(t.onSortingColumn(p)){var c=e.ctrlKey||e.metaKey,h=e.shiftKey;d.deferUpdate((function(){if(c&&h)d.clear();else if(u<0){t.allowSorting!=wijmo_grid_1.AllowSorting.MultiColumn&&d.clear();var e=null==s.sortOrder?t.sortOrder==wijmo_grid_1.SortOrder.AscDesc||t.sortOrder==wijmo_grid_1.SortOrder.AscDescNone:s.sortOrder==wijmo_grid_1.SortOrder.AscDesc||s.sortOrder==wijmo_grid_1.SortOrder.AscDescNone,r=new wijmo_1.SortDescription(a,e);d.push(r)}else{e=d[u].ascending;var i=null!=s.sortOrder?s.sortOrder:t.sortOrder;if(c||e&&(i===wijmo_grid_1.SortOrder.DescAscNone||t.isTouching&&i===wijmo_grid_1.SortOrder.DescAsc)||!e&&(i===wijmo_grid_1.SortOrder.AscDescNone||t.isTouching&&i===wijmo_grid_1.SortOrder.AscDesc))d.splice(u,1);else{r=new wijmo_1.SortDescription(a,!e);d.splice(u,1,r)}}}));t.onSortedColumn(p)}}}};GroupPanel.prototype._removeEventForGrid=function(){var e=this._g;if(e){e.draggingColumn.removeHandler(this._draggingColumn);e.itemsSourceChanging.removeHandler(this._itemsSourceChanging);e.itemsSourceChanged.removeHandler(this._itemsSourceChanged);e.columns.collectionChanged.removeHandler(this._itemsSourceChanged);e.removeEventListener(e.hostElement,"dragend",this._dragEndBnd);e.removeEventListener(e.hostElement,"keydown",this._keyDownBnd)}};GroupPanel.prototype.dispose=function(){var r=this;this._removeEventForGrid();this._g=null;this._divMarkers.querySelectorAll("."+wijmo_grid_1.FlexGridClsNames.cell).forEach((function(e){e.removeEventListener("keydown",r._markerKeydownHandler);e.removeEventListener("focus",r._markerFocusHandler);e.removeAttribute("draggable")}));this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._focusGd=null;this._dragMarker=null;this._dragCol=null;this._filterMarker=null;this._divPH=null;this._groupStatus=null;if(this._divMarkers){this._divMarkers.innerHTML="";this._divMarkers=null}if(this._mkfocus){clearTimeout(this._mkfocus);this._mkfocus=null}if(this._newMkFocus){clearTimeout(this._newMkFocus);this._newMkFocus=null}e.prototype.dispose.call(this)};GroupPanel._ctrlTemplate="";GroupPanel._INDEX_KEY=wijmo_grid_1.FlexGridClsNames.cellIndex;return GroupPanel}(wijmo_1.Control);exports.GroupPanel=GroupPanel;function format(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];return r.reduce((function(e,r,t){return e.replace(new RegExp("\\{"+t+"\\}","g"),r)}),e)}wijmo_1._registerModule("wijmo.grid.grouppanel",selfModule);
|
|
14
|
+
"use strict";var __extends=this&&this.__extends||function(){var extendStatics=function(e,r){return(extendStatics=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(e,r){e.__proto__=r}||function(e,r){for(var t in r)r.hasOwnProperty(t)&&(e[t]=r[t])})(e,r)};return function(e,r){extendStatics(e,r);function __(){this.constructor=e}e.prototype=null===r?Object.create(r):(__.prototype=r.prototype,new __)}}(),__importStar=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(null!=e)for(var t in e)Object.hasOwnProperty.call(e,t)&&(r[t]=e[t]);r.default=e;return r};Object.defineProperty(exports,"__esModule",{value:!0});var wijmo_1=require("@grapecity/wijmo"),wijmo_grid_1=require("@grapecity/wijmo.grid"),selfModule=__importStar(require("@grapecity/wijmo.grid.grouppanel"));exports.GroupPanelClsNames={groupMarker:"wj-groupmarker",hostElement:"wj-grouppanel",groupPlaceholder:"wj-groupplaceholder"};function softGridFilter(){return wijmo_1._getModule("wijmo.grid.filter")}exports.softGridFilter=softGridFilter;wijmo_1._addCultureInfo("GroupPanel",{dragDrop:"Drag and Drop columns here to create Groups.",groupPanel:"Grouped columns panel",groupDescription:"Grouped by {0}{1}",groupAction:"Activate to toggle sort or remove group.",sortedAsc:", sorted ascending",sortedDesc:", sorted descending",sortedAscStatus:"{0} ascending",sortedDescStatus:"{0} descending",remove:"Remove group",added:"Added group {0}"});var GroupPanel=function(e){__extends(GroupPanel,e);function GroupPanel(r,t){var i=e.call(this,r)||this;i._hideGroupedCols=!0;i._showDragGlyphs=!0;i._maxGroups=6;i._hiddenCols=[];i._placeholder=null;i._dragEndBnd=i._dragEnd.bind(i);i._keyDownBnd=i._keyDown.bind(i);i._focusGd=null;i._ariaLabel=wijmo_1.culture.GroupPanel.groupPanel;var o=i.getTemplate();i.applyTemplate(exports.GroupPanelClsNames.hostElement+" "+wijmo_1.ControlClsNames.hostElement,o,{_divMarkers:"div-markers",_divPH:"div-ph",_groupStatus:"group-status"});wijmo_1.setCss(i._divMarkers.parentElement,{width:"100%",height:"100%",minHeight:"1em",overflow:"hidden",cursor:"default"});var n=i.hostElement,l=i.addEventListener.bind(i);l(n,"dragstart",i._dragStart.bind(i));l(n,"dragover",i._dragOver.bind(i));l(n,"drop",i._drop.bind(i));l(n,"dragend",i._dragEndBnd);wijmo_1.setAttribute(n,"role","region");wijmo_1.setAttribute(n,"aria-label",i._ariaLabel);l(n,"click",i._click.bind(i));i.initialize(t);return i}Object.defineProperty(GroupPanel,"controlTemplate",{get:function(){GroupPanel._ctrlTemplate||(GroupPanel._ctrlTemplate='<div><div wj-part="div-ph" class="'+exports.GroupPanelClsNames.groupPlaceholder+'"></div><div wj-part="div-markers"></div><div wj-part="group-status" aria-live="polite" class="'+wijmo_grid_1.FlexGridClsNames.screenReaderOnly+'"></div></div>');return GroupPanel._ctrlTemplate},set:function(e){GroupPanel._ctrlTemplate=e},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"hideGroupedColumns",{get:function(){return this._hideGroupedCols},set:function(e){e!=this._hideGroupedCols&&(this._hideGroupedCols=wijmo_1.asBoolean(e))},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"showDragGlyphs",{get:function(){return this._showDragGlyphs},set:function(e){if(e!=this._showDragGlyphs){this._showDragGlyphs=wijmo_1.asBoolean(e);this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"maxGroups",{get:function(){return this._maxGroups},set:function(e){if(e!=this._maxGroups){this._maxGroups=wijmo_1.asNumber(e);var r=this._gds,t=this._maxGroups;r&&t>-1&&t<r.length&&r.splice(t,r.length-t)}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"placeholder",{get:function(){return this._placeholder},set:function(e){if(e!=this._placeholder){this._placeholder=e;this.invalidate()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"grid",{get:function(){return this._g},set:function(e){if((e=wijmo_1.asType(e,wijmo_grid_1.FlexGrid,!0))!=this._g){var r=this._g;this._removeEventForGrid();r=this._g=e;this._hiddenCols=[];if(r){r.draggingColumn.addHandler(this._draggingColumn,this);r.itemsSourceChanging.addHandler(this._itemsSourceChanging,this);r.itemsSourceChanged.addHandler(this._itemsSourceChanged,this);r.columns.collectionChanged.addHandler(this._itemsSourceChanged,this);r.addEventListener(r.hostElement,"dragend",this._dragEndBnd);r.addEventListener(r.hostElement,"keydown",this._keyDownBnd)}this._itemsSourceChanged(r,null)}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"collectionView",{get:function(){return this._g?this._g.collectionView:null},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"filter",{get:function(){return this._filter},set:function(e){if((e=wijmo_1.asType(e,softGridFilter().FlexGridFilter,!0))!=this._filter){var r=this._filter;if(r){r.filterApplied.removeHandler(this.refresh,this);r.filterChanged.removeHandler(this._filterChanged,this)}if(r=this._filter=e){r.filterApplied.addHandler(this.refresh,this);r.filterChanged.addHandler(this._filterChanged,this)}this.refresh()}},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"groupDescriptionCreator",{get:function(){return this._gdc},set:function(e){this._gdc=e},enumerable:!0,configurable:!0});Object.defineProperty(GroupPanel.prototype,"ariaLabel",{get:function(){return this._ariaLabel},set:function(e){if(e!=this._ariaLabel){this._ariaLabel=e;wijmo_1.setAttribute(this.hostElement,"aria-label",this._ariaLabel)}},enumerable:!0,configurable:!0});GroupPanel.prototype.refresh=function(){var r=this;e.prototype.refresh.call(this);this._divMarkers.innerHTML="";this._dragMarker=this._dragCol=null;if(this._gds){var t=0===this._gds.length?"0":"-1";wijmo_1.setAttribute(this.hostElement,"tabindex",t);this._orgTabIndex=+t;for(var i=this._g,o=i.columnHeaders,_loop_1=function(e){var t=n._gds[e],l=-1,s=-1;if(t instanceof wijmo_1.PropertyGroupDescription)for(var a=o.rows.length-1;a>=0&&s<0;a--)for(var u=0;u<o.columns.length&&s<0;u++){if((c=i._getBindingColumn(o,a,o.columns[u]))&&c.binding==t.propertyName){s=u;l=a;break}}if(s>-1&&l>-1){var d=document.createElement("button");d.dataset.groupPanel="true";i.cellFactory.updateCell(n._g.columnHeaders,l,s,d);delete d.dataset.groupPanel;wijmo_1.setAttribute(d,"class",wijmo_grid_1.FlexGridClsNames.cell+" "+wijmo_grid_1.FlexGridClsNames.header+" "+exports.GroupPanelClsNames.groupMarker);wijmo_1.setAttribute(d,"role","button");wijmo_1.setAttribute(d,"tabindex","0");d.removeAttribute("aria-sort");d.removeAttribute("aria-readonly");d.removeAttribute("aria-required");var _=t instanceof wijmo_1.PropertyGroupDescription?t.propertyName:"";n._markerFocusHandler=function(){r._focusGd=t};d.addEventListener("focus",n._markerFocusHandler);n._focusGd===t&&n._focus&&(n._mkfocus=setTimeout((function(){d.focus()}),50));n._markerKeydownHandler=function(e){if((wijmo_1._isMacOS()?e.metaKey:e.ctrlKey)&&("ArrowLeft"===e.key||"ArrowRight"===e.key)){e.preventDefault();var t=Array.from(r._divMarkers.children),i=(n=t.indexOf(d))+("ArrowLeft"===e.key?-1:1);if(i>=0&&i<t.length){r._moveGroupByIndex(n,i);r._newMkFocus=setTimeout((function(){var e=r._divMarkers.children[i];e&&e.focus()}),0)}}var o=Array.from(r._divMarkers.children);if("Delete"!==e.key||e.altKey||e.shiftKey||e.ctrlKey||e.metaKey){var n=o.indexOf(d);switch(e.key){case"ArrowLeft":n>0&&o[n-1].focus();break;case"ArrowRight":n<o.length-1&&o[n+1].focus();break;case"Home":(s=o[0])&&s.focus();e.preventDefault();break;case"End":var l=o[o.length-1];l&&l.focus();e.preventDefault()}}else{var s,a=e.target,u=wijmo_1.closest(a,"."+wijmo_grid_1.FlexGridClsNames.cell),p=r._getElementIndex(u),c=r._getColumnInfoByProperty(_).displayName;r._removeGroup(p);r._announceToScreenReader(wijmo_1.culture.GroupPanel.remove+" "+c);r._filterMarker=null;(s=o[0===p?1:0])?s.focus():r.hostElement.focus()}};d.addEventListener("keydown",n._markerKeydownHandler);wijmo_1.setCss(d,{position:"static",display:"inline-block",verticalAlign:"top",left:"",right:"",top:"",width:"",height:"",paddingLeft:"",paddingRight:""});wijmo_1.removeChild(d.querySelector(".wj-elem-filter"));wijmo_1.removeChild(d.querySelector(".wj-column-selector"));if(n.showDragGlyphs){var p=wijmo_1.createElement("<span class="+wijmo_1.GlyphClsNames.drag+' aria-hidden="true"></span>');d.insertBefore(p,d.firstChild)}var c,h=(c=i._getBindingColumn(o,l,o.columns[s]))?n._getColumnDisplayName(c):_,g=n._getSortStateDescription(_,o,s),m=h;_!==h&&(m+=", grouped by "+_);m+=g;d.setAttribute("aria-label",m+". "+wijmo_1.culture.GroupPanel.groupAction);var f=n._getColumnFilter(c);if(f){var v=wijmo_1.createElement('<span class="wj-filter '+wijmo_1.GlyphClsNames.filter+'"></span>',d);wijmo_1.toggleClass(v,"wj-filter-on",f.isActive);wijmo_1.toggleClass(v,"wj-filter-off",!f.isActive)}wijmo_1.createElement('<span class="'+wijmo_1.UtilitesClsNames.remove+'" aria-hidden="true">×</span>',d);n._divMarkers.appendChild(d);if(c&&n.hideGroupedColumns){var w=[];if(n.grid.layoutDefinition){n.grid.layoutDefinition.forEach((function(e){e.cells.forEach((function(e){w.push(e.binding)}))}))}if(!w.includes(c._binding.path)){c.visible=!1;n._hiddenCols.push(c)}}d[GroupPanel._INDEX_KEY]={row:l,col:s,panel:n}}},n=this,l=0;l<this._gds.length;l++)_loop_1(l);this._divPH.textContent=null!=this._placeholder?this._placeholder:wijmo_1.culture.GroupPanel.dragDrop;var s=this._divMarkers.children.length>0;this._divPH.style.display=s?"none":"";this._divMarkers.style.display=s?"":"none"}};GroupPanel.prototype.hitTest=function(e){var r=e instanceof HTMLElement?e:e instanceof MouseEvent?e.target:null;wijmo_1.assert(null!=r,"MouseEvent or Element expected");var t=wijmo_1.closest(r,"."+wijmo_grid_1.FlexGridClsNames.cell);if(wijmo_1.hasClass(t,wijmo_grid_1.FlexGridClsNames.cell)){var i=this._getElementIndex(t);return this._gds&&i>-1?this._gds[i]:null}return null};GroupPanel.prototype._filterChanged=function(){this._filterMarker=null};GroupPanel.prototype._getColumnFilter=function(e){var r=this._filter,t=null;r&&(t=r.filterColumns&&r.filterColumns.indexOf(e.binding)<0?null:r.getColumnFilter(e));return t};GroupPanel.prototype._getColumnDisplayName=function(e){return e?e.header||e.binding:""};GroupPanel.prototype._getColumnInfoByProperty=function(e){var r=e?this._g.columns.getColumn(e):null;return{col:r,displayName:r?this._getColumnDisplayName(r):e}};GroupPanel.prototype._announceToScreenReader=function(e){this._groupStatus&&(this._groupStatus.textContent=e)};GroupPanel.prototype._getSortStateDescription=function(e,r,t){var i="";if(this._view){var o=this._view.sortDescriptions.find((function(r){return r.property===e}));if(o){i=o.ascending?wijmo_1.culture.GroupPanel.sortedAsc:wijmo_1.culture.GroupPanel.sortedDesc;if(this._view.sortDescriptions.length>1){var n=r.columns[t]&&r.columns[t].currentSortIndex;n>-1&&(i+=" "+wijmo_1.culture.FlexGrid.ariaLabels.sortIndex+" "+(n+1))}}}return i};GroupPanel.prototype._moveGroupByIndex=function(e,r){var t=this,i=this._gds;i&&e>=0&&r>=0&&e<i.length&&r<i.length&&i.deferUpdate((function(){var o=i[e];i.removeAt(e);i.insert(r,o);t.refresh()}))};GroupPanel.prototype._removeGroupByColumn=function(e){for(var r=e.binding,t=this._gds,i=t.length-1;i>=0;i--){var o=t[i];o instanceof wijmo_1.PropertyGroupDescription&&o.propertyName===r&&this._removeGroup(i)}};GroupPanel.prototype._editFilter=function(e){var r=this._gds,t=this._getElementIndex(e),i=r&&t>-1?r[t]:null,o=i instanceof wijmo_1.PropertyGroupDescription?i.propertyName:null,n=o?this._g.getColumn(o):null;n&&this._filter.editColumnFilter(n,null,e)};GroupPanel.prototype._addGroup=function(e,r){var t=this._gds,i=this._maxGroups,o=this._divMarkers.children.length;if(r){o=this._getIndex(r);for(var n=0;n<t.length;n++){var l=t[n];if(l instanceof wijmo_1.PropertyGroupDescription&&l.propertyName==e.binding){t.removeAt(n);n<o&&o--;break}}if(i>-1)for(n=i-1;n<t.length;n++){this._removeGroup(n,t);n<o&&o--}}if(i<0||t.length<i){var s=this._gdc?this._gdc(e.binding):null;s||(s=new wijmo_1.PropertyGroupDescription(e.binding));t.insert(o,s);if(e&&this.hideGroupedColumns){e.visible=!1;this._hiddenCols.push(e)}var a=this._getColumnDisplayName(e);this._announceToScreenReader(format(wijmo_1.culture.GroupPanel.added,a))}};GroupPanel.prototype._moveGroup=function(e,r){var t=this._gds,i=this._getElementIndex(this._dragMarker),o=this._getIndex(r);o>i&&o--;o>=this._gds.length&&(o=this._gds.length);i!=o&&t.deferUpdate((function(){var e=t[i];t.removeAt(i);t.insert(o,e)}))};GroupPanel.prototype._removeGroup=function(e,r){void 0===r&&(r=this._gds);var t=r&&e>-1?r[e]:null,i=t instanceof wijmo_1.PropertyGroupDescription?t.propertyName:null,o=i?this._g.columns.getColumn(i):null;if(o){o.visible=!0;var n=this._hiddenCols,l=n.indexOf(o);l>-1&&n.splice(l,1)}t&&r.removeAt(e)};GroupPanel.prototype._getIndex=function(e){for(var r=e.clientX,t=this._divMarkers.children,i=0;i<t.length;i++){var o=t[i].getBoundingClientRect();if((r-o.left)*(r-o.right)<0)return i}return t.length};GroupPanel.prototype._getElementIndex=function(e){if(e&&e.parentElement)for(var r=e.parentElement.children,t=0;t<r.length;t++)if(r[t]==e)return t;return-1};GroupPanel.prototype._draggingColumn=function(e,r){var t=this._g,i=t._getBindingColumn(r.panel,r.row,t.columns[r.col]);this._dragCol=i.binding?i:null};GroupPanel.prototype._itemsSourceChanging=function(e,r){this._hiddenCols.forEach((function(e){e.visible=!0}));this._hiddenCols=[]};GroupPanel.prototype._itemsSourceChanged=function(e,r){this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._view=this._g?this._g.collectionView:null;this._gds=this._view?this._view.groupDescriptions:null;this._view&&this._view.collectionChanged.addHandler(this._collectionChanged,this);this.invalidate()};GroupPanel.prototype._collectionChanged=function(e,r){r.action==wijmo_1.NotifyCollectionChangedAction.Reset&&this.invalidate()};GroupPanel.prototype._dragStart=function(e){wijmo_1._startDrag(e.dataTransfer,"move");this._dragMarker=e.target;this._dragCol=null};GroupPanel.prototype._dragOver=function(e){if(this._dragCol||this._dragMarker){e.dataTransfer.dropEffect="move";e.preventDefault();e.stopPropagation()}};GroupPanel.prototype._drop=function(e){this._dragMarker?this._moveGroup(this._dragMarker,e):this._dragCol&&this._addGroup(this._dragCol,e)};GroupPanel.prototype._dragEnd=function(e){this._dragMarker=this._dragCol=null};GroupPanel.prototype._keyDown=function(e){if(e.altKey){var r=this._g.selection,t=this._g.columns[r.col],i=this._g.rows[r.row]instanceof wijmo_grid_1.GroupRow;if(t&&"KeyG"===e.code&&!0!==this.isDisabled&&!i){this._addGroup(t,e);e.preventDefault()}}};GroupPanel.prototype._click=function(e){var r=e.target,t=wijmo_1.closest(r,"."+wijmo_grid_1.FlexGridClsNames.cell);if(wijmo_1.hasClass(t,wijmo_grid_1.FlexGridClsNames.cell))if(wijmo_1.hasClass(r,"wj-filter")){if(t!=this._filterMarker){this._editFilter(t);this._filterMarker=t;return}}else if(wijmo_1.hasClass(r,wijmo_1.UtilitesClsNames.remove)){var i=this._getElementIndex(t),o=this._gds&&i>-1?this._gds[i]:null,n=o instanceof wijmo_1.PropertyGroupDescription?o.propertyName:null,l=this._getColumnInfoByProperty(n).displayName;this._removeGroup(i);l&&this._announceToScreenReader(wijmo_1.culture.GroupPanel.remove+" "+l)}else this._updateSort(e,t);this._filterMarker=null};GroupPanel.prototype._updateSort=function(e,r){var t=this._g,i=t.collectionView;if(i&&i.canSort&&t.allowSorting!=wijmo_grid_1.AllowSorting.None){var o=this._getElementIndex(r),n=this._gds[o],l=n instanceof wijmo_1.PropertyGroupDescription?n.propertyName:null,s=l?t.getColumn(l):null;if(s&&s.allowSorting){for(var a=s.sortMemberPath||s.binding,u=-1,d=i.sortDescriptions,_=0;_<d.length;_++)if(d[_].property==a){u=_;break}var p=new wijmo_grid_1.CellRangeEventArgs(t.columnHeaders,new wijmo_grid_1.CellRange(0,s.index),e);if(t.onSortingColumn(p)){var c=e.ctrlKey||e.metaKey,h=e.shiftKey;d.deferUpdate((function(){if(c&&h)d.clear();else if(u<0){t.allowSorting!=wijmo_grid_1.AllowSorting.MultiColumn&&d.clear();var e=null==s.sortOrder?t.sortOrder==wijmo_grid_1.SortOrder.AscDesc||t.sortOrder==wijmo_grid_1.SortOrder.AscDescNone:s.sortOrder==wijmo_grid_1.SortOrder.AscDesc||s.sortOrder==wijmo_grid_1.SortOrder.AscDescNone,r=new wijmo_1.SortDescription(a,e);d.push(r)}else{e=d[u].ascending;var i=null!=s.sortOrder?s.sortOrder:t.sortOrder;if(c||e&&(i===wijmo_grid_1.SortOrder.DescAscNone||t.isTouching&&i===wijmo_grid_1.SortOrder.DescAsc)||!e&&(i===wijmo_grid_1.SortOrder.AscDescNone||t.isTouching&&i===wijmo_grid_1.SortOrder.AscDesc))d.splice(u,1);else{r=new wijmo_1.SortDescription(a,!e);d.splice(u,1,r)}}}));t.onSortedColumn(p)}}}};GroupPanel.prototype._removeEventForGrid=function(){var e=this._g;if(e){e.draggingColumn.removeHandler(this._draggingColumn);e.itemsSourceChanging.removeHandler(this._itemsSourceChanging);e.itemsSourceChanged.removeHandler(this._itemsSourceChanged);e.columns.collectionChanged.removeHandler(this._itemsSourceChanged);e.removeEventListener(e.hostElement,"dragend",this._dragEndBnd);e.removeEventListener(e.hostElement,"keydown",this._keyDownBnd)}};GroupPanel.prototype.dispose=function(){var r=this;this._removeEventForGrid();this._g=null;this._divMarkers.querySelectorAll("."+wijmo_grid_1.FlexGridClsNames.cell).forEach((function(e){e.removeEventListener("keydown",r._markerKeydownHandler);e.removeEventListener("focus",r._markerFocusHandler);e.removeAttribute("draggable")}));this._view&&this._view.collectionChanged.removeHandler(this._collectionChanged);this._focusGd=null;this._dragMarker=null;this._dragCol=null;this._filterMarker=null;this._divPH=null;this._groupStatus=null;if(this._divMarkers){this._divMarkers.innerHTML="";this._divMarkers=null}if(this._mkfocus){clearTimeout(this._mkfocus);this._mkfocus=null}if(this._newMkFocus){clearTimeout(this._newMkFocus);this._newMkFocus=null}e.prototype.dispose.call(this)};GroupPanel._ctrlTemplate="";GroupPanel._INDEX_KEY=wijmo_grid_1.FlexGridClsNames.cellIndex;return GroupPanel}(wijmo_1.Control);exports.GroupPanel=GroupPanel;function format(e){for(var r=[],t=1;t<arguments.length;t++)r[t-1]=arguments[t];return r.reduce((function(e,r,t){return e.replace(new RegExp("\\{"+t+"\\}","g"),r)}),e)}wijmo_1._registerModule("wijmo.grid.grouppanel",selfModule);
|
package/package.json
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@grapecity/wijmo.grid.grouppanel",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.20261.48",
|
|
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
|
-
"@grapecity/wijmo": "5.
|
|
11
|
-
"@grapecity/wijmo.input": "5.
|
|
12
|
-
"@grapecity/wijmo.grid": "5.
|
|
13
|
-
"@grapecity/wijmo.grid.filter": "5.
|
|
10
|
+
"@grapecity/wijmo": "5.20261.48",
|
|
11
|
+
"@grapecity/wijmo.input": "5.20261.48",
|
|
12
|
+
"@grapecity/wijmo.grid": "5.20261.48",
|
|
13
|
+
"@grapecity/wijmo.grid.filter": "5.20261.48"
|
|
14
14
|
},
|
|
15
15
|
"homepage": "https://developer.mescius.com/wijmo",
|
|
16
16
|
"bugs": {
|