UNPKG

@arcgis/core

Version:

ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API

3 lines (2 loc) 6.41 kB
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */ import{__decorate as e}from"tslib";import t from"../../../core/Collection.js";import{referenceSetter as i}from"../../../core/collectionUtils.js";import{EventedAccessor as n}from"../../../core/Evented.js";import{property as o,subclass as l}from"../../../core/accessorSupport/decorators.js";import{isGroupColumn as r}from"../support/columnUtils.js";import{uniqueColumnNames as s,isPageIndexValid as d}from"../support/tableUtils.js";let u=class extends n{constructor(e){super(e),this.actionColumnConfig=null,this.cellPartNameGenerator=(e,t)=>{const i=t.item.objectId;let n="";t?.item&&this.rowHighlightIds.includes(i)&&(n+=" highlight");const o=this.findColumn(e?.path);if(!o)return n;if(o.invalid&&(n+=" invalid"),o.textWrap&&(n+=" text-wrap"),"editInfo"in o&&o.editInfo&&o.editInfo.rowData?.index===t.index&&(n+=" editing"),o.tableHasPendingEdits&&(o.itemHasPendingEdits(i,o.fieldName)&&(n+=" pending-edit"),o.tableHasInvalidPendingEdits)){const e=o.itemHasInvalidPendingEdits(i);o.itemHasInvalidPendingEdits(i,o.fieldName)?n+=" pending-edit-invalid":e||(n+=" pending-edit-other")}return n},this.columnPerformanceModeEnabled=!0,this.columnReorderingEnabled=!0,this.columns=new t,this.dataProvider=async(e,t)=>{const{store:i}=this;if(!t)return;t(await i.fetchItems(e))},this.maxSize=null,this.multipleSelectionEnabled=!0,this.multipleSelectionEnabledOverride=null,this.multiSortEnabled=!1,this.multipleSortPriority="prepend",this.noDataMessage=null,this.paginationEnabled=!1,this.rowDetailsRenderer=null,this.store=null}get actionColumn(){return this.allColumns.find(e=>e.fieldName===s.action)}get allColumns(){return this.columns.toArray().flatMap(e=>[e,...r(e)&&e.columns?.length?e.columns:[]])}get allVisibleColumns(){return this.allColumns.filter(e=>!e.hidden)}get columnMenuIsOpen(){return this.allColumns.some(e=>e.menuIsOpen)}get editingEnabled(){return this.store.editingEnabled}set editingEnabled(e){this.store.editingEnabled=e}get editableColumns(){return this.allColumns.filter(e=>"editable"in e)}get effectiveSize(){const{filterBySelectionEnabled:e,highlightIds:t,objectIds:i,pageSize:n,size:o}=this;if(0===o)return 0;if(this.paginationEnabled){const l=this.pageCount===this.pageIndex+1&&o%n||n;return e?Math.min(t.length,l):i.length?Math.min(i.length,l):l}return e?t.length:i.length?i.length:o}get filterBySelectionEnabled(){return!!this._get("filterBySelectionEnabled")}set filterBySelectionEnabled(e){this._set("filterBySelectionEnabled",e)}get groupColumns(){return this.columns.toArray().filter(e=>r(e))}get hasInvalidColumnConfiguration(){return this.visibleColumns.every(e=>e.frozen||e.frozenToEnd)}get highlightIds(){return this._get("highlightIds")||new t}set highlightIds(e){let n=Array.isArray(e)?new t(e):e;this.effectiveMultipleSelectionEnabled||(n=n.slice(0,1)),this._set("highlightIds",i(n,this._get("highlightIds"),t))}get isEditing(){return this.editableColumns.some(e=>e.editInfo)}get isQuerying(){return this.store.isQuerying}get isQueryingOrSyncing(){return this.isQuerying||this.isSyncing}get isSyncing(){return this.store.isSyncing}get effectiveMultipleSelectionEnabled(){return!1!==this.multipleSelectionEnabledOverride&&this.multipleSelectionEnabled}get objectIds(){return this._get("objectIds")??new t}set objectIds(e){this._set("objectIds",i(e,this._get("objectIds"),t))}get pageCount(){const{pageSize:e,size:t}=this;return 0===t||0===e?1:Math.ceil(t/e)}get pageIndex(){return this._get("pageIndex")||0}set pageIndex(e){const{pageCount:t}=this;d(e,t)&&this._set("pageIndex",e)}get pageSize(){return this.store.pageSize}set pageSize(e){this.store.pageSize=e}get rowHighlightIds(){return this._get("rowHighlightIds")||new t}set rowHighlightIds(e){this._set("rowHighlightIds",i(e,this._get("rowHighlightIds"),t))}get size(){const e=this.store?.count??0,{maxSize:t}=this;return null!=e&&null!=t?Math.min(t,e):e}get state(){return this.store.state}get visibleColumns(){return this.columns.toArray().filter(e=>!e.hidden)}closeColumnMenus(){this.allColumns.forEach(e=>e.closeMenu())}sortColumn(e,t){if(!e)return;const i=this.findColumn(e);i&&(i.direction=t)}hideColumn(e){const t=this.findColumn(e);!1===t?.hidden&&(t.hidden=!0)}showColumn(e){const t=this.findColumn(e);t?.hidden&&(t.hidden=!1)}showAllColumns(){this.allColumns.forEach(e=>{e.hidden&&(e.hidden=!1)})}findColumn(e){return this.allColumns.find(t=>t.fieldName===e)}refresh(){this.store.reset(),this.store.load()}toggleColumnVisibility(e){const t=this.findColumn(e);t&&(t.hidden=!t.hidden)}};e([o()],u.prototype,"actionColumn",null),e([o()],u.prototype,"actionColumnConfig",void 0),e([o()],u.prototype,"allColumns",null),e([o()],u.prototype,"allVisibleColumns",null),e([o()],u.prototype,"cellPartNameGenerator",void 0),e([o()],u.prototype,"columnMenuIsOpen",null),e([o()],u.prototype,"columnPerformanceModeEnabled",void 0),e([o()],u.prototype,"columnReorderingEnabled",void 0),e([o()],u.prototype,"columns",void 0),e([o()],u.prototype,"dataProvider",void 0),e([o()],u.prototype,"editingEnabled",null),e([o()],u.prototype,"editableColumns",null),e([o()],u.prototype,"effectiveSize",null),e([o()],u.prototype,"filterBySelectionEnabled",null),e([o()],u.prototype,"groupColumns",null),e([o()],u.prototype,"hasInvalidColumnConfiguration",null),e([o()],u.prototype,"highlightIds",null),e([o()],u.prototype,"isEditing",null),e([o()],u.prototype,"isQuerying",null),e([o()],u.prototype,"isQueryingOrSyncing",null),e([o()],u.prototype,"isSyncing",null),e([o()],u.prototype,"maxSize",void 0),e([o()],u.prototype,"multipleSelectionEnabled",void 0),e([o()],u.prototype,"multipleSelectionEnabledOverride",void 0),e([o()],u.prototype,"effectiveMultipleSelectionEnabled",null),e([o()],u.prototype,"multiSortEnabled",void 0),e([o()],u.prototype,"multipleSortPriority",void 0),e([o()],u.prototype,"noDataMessage",void 0),e([o()],u.prototype,"objectIds",null),e([o()],u.prototype,"pageCount",null),e([o()],u.prototype,"pageIndex",null),e([o()],u.prototype,"pageSize",null),e([o()],u.prototype,"paginationEnabled",void 0),e([o()],u.prototype,"rowHighlightIds",null),e([o()],u.prototype,"rowDetailsRenderer",void 0),e([o({readOnly:!0})],u.prototype,"size",null),e([o()],u.prototype,"store",void 0),e([o({readOnly:!0})],u.prototype,"state",null),e([o()],u.prototype,"visibleColumns",null),u=e([l("esri.widgets.FeatureTable.Grid.GridViewModel")],u);const a=u;export{a as default};