// All material copyright Esri, All Rights Reserved, unless otherwise specified. // See https://js.arcgis.com/4.30/esri/copyright.txt for details. //>>built define("../../../chunks/tslib.es6 ../../../core/Evented ../../../core/reactiveUtils ../../../core/accessorSupport/decorators/property ../../../core/has ../../../core/Logger ../../../core/RandomLCG ../../../core/accessorSupport/decorators/subclass ../../support/uriUtils ../../support/widgetUtils".split(" "),function(e,d,r,f,w,x,y,u,v,t){d=class extends d.EventedAccessor{constructor(b){super(b);this.autoWidth=this._menuIsOpen=!1;this.cellValueFormatFunction=a=>{const {rowData:c,value:g}=a;({formatFunction:a}= this);const h=t.renderingSanitizer.sanitize(g);if(a&&c){const {index:k,item:{feature:l}}=c;return a({column:this,feature:l,index:k,value:h})}return h};this.fieldName=this.direction=null;this.flexGrow=1;this.formatFunction=this.footerRenderFunction=null;this.frozenToEnd=this.frozen=!1;this.grid=null;this.headerRenderFunction=a=>{({root:a}=a);const c=this.createHeaderContent();this.removeCellContent(a);a.appendChild(c)};this.hidden=!1;this.messagesURIUtils=this.messagesCommon=this.messages=this.menuConfig= this.label=this.initialSortPriority=this.icon=null;this.renderFunction=({root:a,column:c,rowData:g})=>{const h=this.getCellValue(c,g);c=this.cellValueFormatFunction({column:c,rowData:g,value:h});g=null;g=c instanceof HTMLElement?c:v.autoLink(this.messagesURIUtils,c);this.removeCellContent(a);g instanceof HTMLElement?a.appendChild(g):null!=g&&(a.innerHTML=g.toString())};this.resizable=!0;this.sortable=!1;this.store=null;this.textAlign="start";this.textWrap=!1;this.visibleElements=this.timeZoneName= this.timeZone=null;this.width=200}initialize(){const {fieldName:b}=this;this._set("sortElement",this.createSortElement());this.sortElement.setAttribute("path",b);this.addHandles([r.watch(()=>this.direction,a=>{const {sortElement:c}=this;this.sortable&&c&&(a?this.sortElement.direction!==a&&c.setAttribute("direction",a):c.removeAttribute("direction"))}),r.watch(()=>this.hidden,()=>this.closeMenu()),r.watch(()=>this.fieldName,a=>{const {sortElement:c}=this;c&&c.path!==a&&c.setAttribute("path",a)}),r.watch(()=> this.effectiveLabel,a=>{const {sortElement:c}=this;c&&c.textContent!==a&&(c.setAttribute("title",a),c.textContent=a)})])}get customMenuItems(){return this.menuConfig?.items?.map(({disabled:b,hidden:a,icon:c,iconClass:g,label:h,selected:k,clickFunction:l})=>this.createCalciteDropdownItem({disabled:b,hidden:a,iconClass:g,iconStart:c,selected:k,textContent:h,onclick:n=>l(n)}))??[]}get defaultMenuItems(){if(!this.sortable)return[];var b=this.messages;const a=[],c=this.visibleElements?.columnMenuItems; if(!1!==c?.sortAscending){const g=this.createCalciteDropdownItem({iconStart:"sort-ascending-arrow",textContent:b?.sortAsc,onclick:()=>this.direction="asc"});a.push(g)}!1!==c?.sortDescending&&(b=this.createCalciteDropdownItem({iconStart:"sort-descending-arrow",textContent:b?.sortDesc,onclick:()=>this.direction="desc"}),a.push(b));return a}get effectiveLabel(){return t.renderingSanitizer.sanitize(this.label||this.fieldName)}get iconNode(){const {icon:b}=this;return b?this.createCalciteIcon({icon:b}): null}set invalid(b){this._set("invalid",b);this.grid?.generateCellPartNames()}get menu(){const {customMenuItems:b,defaultMenuItems:a,menuConfig:c}=this;var g=!!c?.open;const h=this.createCalciteAction({icon:c?.icon??"ellipsis",text:this.messages?.menu??"",slot:"trigger"}),k=document.createElement("calcite-dropdown");k.maxItems=c?.maxItems??4;k.placement="top-end";k.overlayPositioning="fixed";k.scale=c?.scale??"m";g&&(k.open=g,this._menuIsOpen=!0);k.appendChild(h);k.addEventListener("calciteDropdownOpen", ()=>this._menuIsOpen=!0);k.addEventListener("calciteDropdownClose",()=>this._menuIsOpen=!1);k.onkeydown=this._stopPropagationOnSelect;k.addEventListener("mousewheel",l=>{l.stopPropagation()});a.length&&(g=k.appendChild(document.createElement("calcite-dropdown-group")),g.selectionMode="none",g.append(...a));b.length&&(g=k.appendChild(document.createElement("calcite-dropdown-group")),g.selectionMode=c?.selectionMode??"none",g.append(...b));return k}get menuItems(){return[...this.defaultMenuItems,...this.customMenuItems]}get menuIsOpen(){return this._menuIsOpen}get menuIsVisible(){return!(!1=== this.visibleElements?.columnMenus||!this.menuItems.length)}closeMenu(){this.menu.open=!1}getCellValue(b,a){return b.path&&a?.item?a.item[b.path]:""}createSortElement(){const {effectiveLabel:b,direction:a,fieldName:c,initialSortPriority:g}=this,h=document.createElement("vaadin-grid-sorter");h.classList.add("esri-column__sorter");h.setAttribute("path",c);h.setAttribute("title",b);h.textContent=b;a&&h.setAttribute("direction",a);null!=g&&(h._initialOrder=g);h.addEventListener("direction-changed",()=> {this.direction!==h.direction&&this._set("direction",h.direction)});return h}createCalciteAction(b){const a=document.createElement("calcite-action"),{className:c,disabled:g,icon:h,label:k,scale:l,slot:n,text:q,textEnabled:m,onclick:p}=b;a.className=c??"";a.disabled=!!g;a.icon=h??"";a.label=k??"";a.scale=l??"s";a.slot=n??"";a.text=a.title=q??"";a.textEnabled=!!m;a.onclick=p??null;return a}createCalciteButton(b){const a=document.createElement("calcite-button"),{appearance:c,className:g,disabled:h,iconEnd:k, iconFlipRtl:l,loading:n,onclick:q,scale:m,textContent:p}=b;a.className=g??"";a.scale=m??"s";a.appearance=c??"transparent";a.disabled=!!h;a.iconEnd=k??"";l&&(a.iconFlipRtl=l);a.loading=!!n;a.textContent=a.title=p??"";a.onclick=q??null;return a}createCalciteDropdownItem(b){const a=document.createElement("calcite-dropdown-item"),{disabled:c,hidden:g,iconClass:h,iconStart:k,textContent:l,onclick:n,selected:q}=b;b=l??"";if(h&&!k){const m=document.createElement("span"),p=document.createElement("span"); p.classList.add("esri-column__header-menu-icon",h);m.textContent=m.title=b;m.insertBefore(p,m.firstChild);a.appendChild(m)}else a.iconStart=k??"",a.textContent=a.title=b;a.disabled=!!c;a.hidden="function"===typeof g?g():!!g;a.selected=!!q;n&&(a.addEventListener("calciteDropdownItemSelect",n),a.onkeydown=this._stopPropagationOnSelect);return a}createCalciteIcon(b){var {effectiveLabel:a}=this;const {icon:c,scale:g,textLabel:h}=b;b=document.createElement("calcite-icon");a=h??a;b.icon=c;b.scale=g??"s"; b.textLabel=a;b.title=a;return b}createHeaderContent(){const {effectiveLabel:b,iconNode:a}=this,c=document.createElement("div");c.classList.add("esri-column__header-content");a&&c.appendChild(a);if(this.sortable)c.appendChild(this.sortElement);else if(""!==b){const g=document.createElement("div");g.classList.add("esri-column__header-label");const h=g.appendChild(document.createElement("span"));h.textContent=b;h.setAttribute("title",b);c.appendChild(g)}this.menuIsVisible&&c.appendChild(this.menu); return c}removeCellContent(b){if(b&&b.firstChild)try{for(;b?.firstChild;)b?.removeChild(b.firstChild)}catch(a){}}openMenu(){this.menuIsVisible&&(this.menu.open=!0,this.menuItems[0]?.setFocus())}sort(){this.sortable&&this.sortElement?.click()}_stopPropagationOnSelect(b){"Enter"!==b.key&&" "!==b.key||b.stopPropagation()}};e.__decorate([f.property()],d.prototype,"_menuIsOpen",void 0);e.__decorate([f.property()],d.prototype,"autoWidth",void 0);e.__decorate([f.property()],d.prototype,"cellValueFormatFunction", void 0);e.__decorate([f.property()],d.prototype,"customMenuItems",null);e.__decorate([f.property()],d.prototype,"defaultMenuItems",null);e.__decorate([f.property()],d.prototype,"direction",void 0);e.__decorate([f.property()],d.prototype,"effectiveLabel",null);e.__decorate([f.property({constructOnly:!0})],d.prototype,"fieldName",void 0);e.__decorate([f.property()],d.prototype,"flexGrow",void 0);e.__decorate([f.property()],d.prototype,"footerRenderFunction",void 0);e.__decorate([f.property()],d.prototype, "formatFunction",void 0);e.__decorate([f.property()],d.prototype,"frozen",void 0);e.__decorate([f.property()],d.prototype,"frozenToEnd",void 0);e.__decorate([f.property()],d.prototype,"grid",void 0);e.__decorate([f.property()],d.prototype,"iconNode",null);e.__decorate([f.property()],d.prototype,"invalid",null);e.__decorate([f.property()],d.prototype,"headerRenderFunction",void 0);e.__decorate([f.property()],d.prototype,"hidden",void 0);e.__decorate([f.property()],d.prototype,"icon",void 0);e.__decorate([f.property({constructOnly:!0})], d.prototype,"initialSortPriority",void 0);e.__decorate([f.property()],d.prototype,"label",void 0);e.__decorate([f.property()],d.prototype,"menu",null);e.__decorate([f.property()],d.prototype,"menuItems",null);e.__decorate([f.property()],d.prototype,"menuConfig",void 0);e.__decorate([f.property()],d.prototype,"menuIsOpen",null);e.__decorate([f.property()],d.prototype,"menuIsVisible",null);e.__decorate([f.property()],d.prototype,"messages",void 0);e.__decorate([f.property()],d.prototype,"messagesCommon", void 0);e.__decorate([f.property()],d.prototype,"messagesURIUtils",void 0);e.__decorate([f.property()],d.prototype,"renderFunction",void 0);e.__decorate([f.property()],d.prototype,"resizable",void 0);e.__decorate([f.property()],d.prototype,"sortable",void 0);e.__decorate([f.property({readOnly:!0})],d.prototype,"sortElement",void 0);e.__decorate([f.property()],d.prototype,"store",void 0);e.__decorate([f.property()],d.prototype,"textAlign",void 0);e.__decorate([f.property()],d.prototype,"textWrap", void 0);e.__decorate([f.property()],d.prototype,"timeZone",void 0);e.__decorate([f.property()],d.prototype,"timeZoneName",void 0);e.__decorate([f.property()],d.prototype,"visibleElements",void 0);e.__decorate([f.property()],d.prototype,"width",void 0);return d=e.__decorate([u.subclass("esri.widgets.FeatureTable.Grid.Column")],d)});