forked from HTMLElements/smart-webcomponents-angular
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsmart.grid.row.js
6 lines (4 loc) · 35.4 KB
/
smart.grid.row.js
1
2
3
4
5
6
/* Smart UI v15.2.0 (2023-04-20)
Copyright (c) 2011-2023 jQWidgets.
License: https://htmlelements.com/license/ */ //
Smart.Utilities.Assign("Grid.Row",class{constructor(e){const t=this;if(e||(e={}),Object.assign(t,e),e){if(void 0===t.data){const i={$:{}};if(e.grid&&e.grid.dataSource){const t=e.grid.dataSource;for(let e=0;e<t.dataFields.length;e++)i[(t.dataFields?t.dataFields[e]:{}).name]=""}else Object.assign(i,e);e.id&&(i.$.id=e.id),t.data=i}if((void 0===e.$||e.$&&void 0===e.$.id)&&(e.data?(e.data.$&&e.data.$.id&&(t.id=e.data.$.id),t.id||(t.id=e.index)):void 0===t.id&&(t.id=e.index),void 0===t.id&&(t.id=Smart.Utilities.Core.createGUID())),void 0===t.detailHeight&&(t.grid?t.detailHeight=t.grid.rowDetail.height:t.detailHeight=200),void 0===t.height&&t.grid&&(t.height=t.grid.layout.rowMinHeight,t.grid.__autoRowHeight&&(t.height=t.grid.__autoRowHeight),t.grid.layout.rowHeight&&(t.height=t.grid.layout.rowHeight)),void 0===t.cellHeight&&(t.cellHeight=t.height),void 0===t.showDetail&&(t.showDetail=!1),void 0===t.index&&(t.index=-1),void 0===t.visibleIndex&&(t.visibleIndex=-1),void 0===t.freeze&&(t.freeze=!1),void 0===t.height&&(t.height=null),void 0===t.minHeight&&(t.minHeight=25,t.grid&&(t.minHeight=t.grid.layout.rowMinHeight)),void 0===t.checked&&(t.checked=!1),void 0===t.selected?(t.selected=!1,(t.grid&&t.grid._selection.rows[t.id]||t.grid&&t.grid._selection.indexes[t.index])&&(t.selected=!0)):t.selected&&t.grid&&(t.grid._selection.rows[t.id]=!0,t.grid._selection.indexes[t.index]=t.index),void 0===t.enabled&&(t.enabled=!0),void 0===t.visible&&(t.visible=!0),void 0===t.allowCheck&&(t.allowCheck=!0),void 0===t.filtered&&(t.filtered=!0),void 0===t.allowResize&&(t.allowResize=!0),void 0===t.allowReorder&&(t.allowReorder=!0),void 0===t.allowToggle&&(t.allowToggle=!0),void 0===t.allowSelect&&(t.allowSelect=!0),void 0===t.starred&&(t.starred=!1),void 0===t.expanded&&(e.data&&void 0!==e.data.expanded?t.expanded=e.data.expanded:t.expanded=!1),t._addStyle(),t.headerCell=null,t._cells=[],t.name="",t.comments=[],!t.autoGenerated&&999999!==t.index){if(t.data){if(t.data.comments&&("string"==typeof t.data.comments&&t.data.comments.indexOf("[{")>=0?t.data.comments=JSON.parse(t.data.comments.replaceAll("\t"," ")):t.comments=t.data.comments),t.data.rowStyle&&(t.style=t._style=e.rowStyle),t.data.history&&(t.history=t.data.history),t.data.style&&(t.style=t._style=t.data.style,t.grid&&(t.grid._cellStyles||(t.grid._cellStyles=[]),t.grid._cellStyles["row"+t.id]=!0,t.grid._cellStyles.length++)),t.data.settings){const e=JSON.parse(t.data.settings);void 0!==e.starred&&(t.starred=e.starred),void 0!==e.height&&(t.height=t.cellHeight=e.height)}const e=t.data.$?t.data.$:t.data;e.history&&(t.history=e.history),"string"==typeof t.history&&t.history.indexOf("[{")>=0&&(t.history=JSON.parse(t.history.replaceAll("\t"," "))),t.history&&t.history.length&&(e.createdDate||(e.createdDate=t.history[0].date),e.createdBy||(e.createdBy=t.history[0].user),e.updatedDate||(e.updatedDate=t.history[t.history.length-1].date),e.updatedBy||(e.updatedBy=t.history[t.history.length-1].user)),e.style&&(t.style=t._style=e.style),e.height&&(t.height=t.cellHeight=e.height),e.comments&&(t.comments=e.comments),e.starred&&(t.starred=e.starred),e.createdDate&&(t.createdDate=e.createdDate),e.createdBy&&(t.createdBy=e.createdBy),e.updatedDate&&(t.updatedDate=e.updatedDate),e.updatedBy&&(t.updatedBy=e.updatedBy)}t.grid&&t.grid._currentUser&&t.grid._currentUser.info&&(void 0===t.createdUserId?(t.createdUserId=t.grid._currentUser.info.id,t.createdDate=new Date):t.createdDate||(t.createdDate=new Date),t.history||(t.history=[],t.addHistory({action:"created",user:t.grid._currentUser.info.id,details:{value:t.name},date:t.createdDate})))}}}_addStyle(){this.style=this._style={background:"",color:"",status:"",fontSize:"",fontFamily:"",fontWeight:"",textDecoration:"",fontStyle:""}}setStyle(e){const t=this;t._style||t._addStyle(),["background","color","fontSize","status","fontFamily","fontWeight","textDecoration","fontStyle"].forEach((i=>{e[i]&&(t._style[i]=e[i])})),t.grid&&(t._style._changed=!0,t.grid._recycle(!1))}get properties(){return["allowToggle","allowResize","allowSelect","allowReorder","allowCheck","createdDate","updatedDate","createdBy","updatedBy","canNotify","children","starred","checked","cells","detailHeight","detailTemplate","cellHeight","expandHeight","data","enabled","expanded","filtered","freeze","grid","headerCell","height","index","id","minHeight","unbound","name","selected","showDetail","visible","parent","leaf","visibleIndex","history","comments","style"]}createElement(){const e=document.createElement("smart-grid-row");return this.element=e,e.setAttribute("role","row"),e._initialize(this),e}_autoSize(e){const t=this,i=t.grid;if(!i)return;let l=i.layout.rowMinHeight;void 0!==t.minHeight&&(l=t.minHeight);const a=t.element;if(e||(e=t),e&&(t.data=e.data),!a)return t.height;i.__autoHeightRows||(i.__autoHeightRows=[]);const r=(e,t,a)=>{if(!a||!t||t.autoGenerated)return 0;i.__autoHeightRows[t.dataField]||(i.__autoHeightRows[t.dataField]=[]);let r=""+e.data[t.dataField];"date"===t.dataType&&e.data[t.dataField]&&(r=""+e.data[t.dataField].toLocaleString());let n=r.length;e._templatesHeight&&e._templatesHeight[t.dataField]&&(n=e._templatesHeight[t.dataField]);const o=i.__autoHeightRows[t.dataField][n],d=o||function(e){a.style.height="auto",t.cellsWrap?a.content.classList.add("wrap"):a.content.classList.add("nowrap");let i=0;if(e&&t)if(t.template){const l=e.canNotify;if(e.canNotify=!1,a.cell.row=e,"function"==typeof t.template)if(a.content.textContent=e.data[t.dataField],e._templatesHeight&&e._templatesHeight[t.dataField])i=e._templatesHeight[t.dataField];else{const i={row:e,column:t,cell:a.cell,oldValue:a.cell.oldValue,value:a.cell.value,template:null,isMeasuring:!0},l=a.innerHTML,r=a.cell.canNotify;a.cell.canNotify=!1,a.cell.template(i),a.cell.canNotify=r,i.template?(a.content.textContent="",a.innerHTML=l):a.content.textContent=e.data[t.dataField]}else a._setTemplate(e.data[t.dataField]||"",t.template,a.content);e.canNotify=l}else if("date"===t.dataType){const i=a.cell.getFormattedValue(e.data[t.dataField],t.cellsFormat);a.content.textContent=i}else a.content.textContent=e.data[t.dataField];let l=a.offsetHeight;return"function"==typeof t.template&&i>0&&(l=i),a.style.height="",a.content.classList.remove("wrap"),a.content.classList.remove("nowrap"),l}(e);l=Math.max(l,d),i.__autoHeightRows[t.dataField][n]=d};for(let t=0;t<i._frozenNearColumns.length;t++)r(e,i._frozenNearColumns[t],a.children[0].children[t]);for(let t=0;t<i._frozenFarColumns.length;t++)r(e,i._frozenFarColumns[t],a.children[2].children[t]);for(let t=0;t<a.children[1].children.length;t++)r(e,i._columnElements[t].column,a.children[1].children[t]);return l}addHistory(e){const t=this;e&&(t.grid.storeHistory?(void 0===t.history&&(t.history=[]),t.history.length===t.grid.storeHistoryItems&&t.history.splice(0,1),Array.isArray(t.history)||(t.history=[]),t.history.push(e)):t.history=[])}clearHistory(){this.history=[]}autoSize(){const e=this,t=e.grid._measureRowElement(e.data),i=e.data?t.row._autoSize(e):e.grid.layout.rowMinHeight;e.height=i,t.remove()}getCell(e){const t=this,i=t.grid;if(!i)return null;if("string"!=typeof e&&"number"!=typeof e||(e=i.columnByDataField[e]),!e)return null;if(t["column_"+e.dataField]){const i=t["column_"+e.dataField];return i.column=e,i}{const l=new Smart.Grid.Cell(t,e,i);return t["column_"+e.dataField]=l,l}}get cells(){const e=this;return e._cells&&e.grid&&e._cells.length===e.grid.columns.length||e.createCells(),e._cells}get viewCells(){const e=this,t=[];for(let i=0;i<e.grid.viewColumns.length;i++){const l=e.grid.viewColumns[i];if(e["column_"+l.dataField]){const i=e["column_"+l.dataField];t.push(i)}else{const i=new Smart.Grid.Cell(e,l,e.grid);e["column_"+l.dataField]=i,t.push(i)}}return e._viewCells=t,t}createCells(){const e=this,t=e.grid;e._cells=[];for(let i=0;i<t.viewColumns.length;i++){const l=t.viewColumns[i];if(!l.autoGenerated)if(e["column_"+l.dataField]){const t=e["column_"+l.dataField];e._cells.push(t)}else{const i=new Smart.Grid.Cell(e,l,t);e["column_"+l.dataField]=i,e._cells.push(i)}}}toggle(e){this.element._handleExpandCollapse(!this.expanded,e)}select(){this.setProperty("selected",!0)}unselect(){this.setProperty("selected",!1)}expand(){this.element&&this.element._handleExpandCollapse(!0)}collapse(){this.element&&this.element._handleExpandCollapse(!1)}render(){const e=this;e.element.row=e,e.element._render()}setProperty(e,t){const i=this,l=i.getProperty(e);i[e]=t,l!==t&&(i.canNotify=!1,i.propertyChanged(e,l,t),i.canNotify=!0)}getProperty(e){const t=this;if("selected"===e&&t.grid){let i=!1;t.grid._selection.cells["row"+t.id]&&(i=null),t.grid&&t.grid._selection.rows[t.id]&&(i=!0),t.grid&&t.grid._selection.indexes[t.index]&&(i=!0),t.grid&&t.grid.dataSource.virtualDataSource&&!t.grid.dataSource.id&&(i=void 0!==t.grid._selection.indexes[t.index]);const l=t.grid.rows.canNotify;return t.grid.rows.canNotify=!1,t[e]=i,t.grid.rows.canNotify=l,i}return t[e]}_updateData(){const e=this;e.data&&e.data.$&&["updatedBy","updatedDate","createdDate","createdBy","starred","comments","history","style"].forEach((t=>{void 0!==e.data.$[t]?(e[t]=e.data.$[t],"style"===t&&(e._style=e[t],e._style._changed=!0)):"starred"===t?e[t]=!1:"comments"===t||"history"===t?e[t]=[]:"updatedBy"===t?e[t]=-1:"updatedDate"===t?e[t]=null:"style"===t&&(e._addStyle(),e._style._changed=!0)}))}propertyChanged(e,t,i){const l=this;if("updatedBy"!==e&&"createdBy"!==e&&"userData"!==e&&"starred"!==e&&"style"!==e&&"history"!==e&&"updatedDate"!==e&&"createdDate"!==e&&"comments"!==e){if("showDetail"===e){l.grid.rowDetail.enabled&&!l.grid.rowDetail.dialog.enabled&&(l.height=0);const e=l.element.rowDetail;if(l.grid.appearance.allowRowDetailToggleAnimation&&!l.grid.rowDetail.dialog.enabled){l.grid._resizeHandling=!1;const t=function(e){const t=l.grid._toggledRow;!t||"transform"!==e.propertyName&&"height"!==e.propertyName||a(t)},a=function(e){e.grid.$.content.style.transition="",e.element.rowDetail.removeEventListener("transitionend",t),e.element.rowDetail.removeEventListener("transitioncancel",t),e.grid._toggledRow=null,e.element.removeAttribute("has-detail"),l.grid._refresh(),setTimeout((()=>{l.grid._resizeHandling=!0}),50)};l.grid._toggledRow=l,e.addEventListener("transitionend",t),e.addEventListener("transitioncancel",t),i?(l.element.setAttribute("has-detail",""),l.element.toggleDetailButton.removeAttribute("toggled"),l.element.toggleDetailButton.classList.remove("smart-animate"),setTimeout((()=>{l.element.toggleDetailButton.classList.add("smart-animate"),l.element.toggleDetailButton.setAttribute("toggled",""),l.element.setAttribute("show-detail","")})),l.element.style.height=l.cellHeight+l.detailHeight+"px",l.grid._autoHeight&&(l.grid.$.content.style.transition="0.25s height ease-in-out",l.grid.$.content.style.height=parseInt(l.grid.$.content.style.height)+l.detailHeight+"px",l.grid.$.scrollView.style.height="auto"),e.classList.remove("smart-hidden"),e.style.height!==l.detailHeight+"px"&&(e.style.height=l.detailHeight+"px"),e.style.lineHeight!==l.detailHeight+"px"&&(e.style.lineHeight=l.detailHeight+"px"),e.style.top!==l.cellHeight+"px"&&(e.style.top=l.cellHeight+"px")):(l.element.setAttribute("has-detail",""),l.element.toggleDetailButton.removeAttribute("toggled"),l.grid._autoHeight&&(l.grid.$.content.style.transition="0.25s height ease-in-out",l.grid.$.content.style.height=parseInt(l.grid.$.content.style.height)-l.detailHeight+"px",l.grid.$.scrollView.style.height="auto"),setTimeout((()=>{l.element.style.height=l.cellHeight+"px",l.element.removeAttribute("show-detail")})))}else l.grid.rowDetail.enabled&&!l.grid.rowDetail.dialog.enabled?l.grid._refresh():l.grid._recycle()}if("allowCheck"!==e&&"allowSelect"!==e||l.grid._recycle(),"checked"===e&&(l.grid.checkBoxes.hasThreeStates&&l.grid._hasThreeStates(l,l),l.grid._recycle()),"selected"===e){if(!1===l.allowSelect)return;if(i?(l.grid._selection.rows[l.id]=!0,l.grid._selection.indexes[l.index]=l.index):!1===i&&(void 0!==l.grid._selection.rows[l.id]&&delete l.grid._selection.rows[l.id],void 0!==l.grid._selection.indexes[l.index]&&delete l.grid._selection.indexes[l.index]),!l.element)return;i?l.element.setAttribute("aria-selected",!0):l.element.removeAttribute("aria-selected"),l.grid._recycle()}"visible"===e&&l.grid.refresh(),"expanded"===e&&(l.expandHeight||l.grid.refresh()),"height"===e&&(l.expandHeight||l.cellHeight!==i&&(l.cellHeight=i,l.grid.refresh())),"minHeight"===e&&(l.height=null,l.grid.refresh()),"freeze"===e&&(!0===i||"near"===i?l.grid._frozenNearRows.push(l):"far"===i?l.grid._frozenFarRows.push(l):(l.grid._frozenNearRows.splice(l.grid._frozenNearRows.indexOf(l),1),l.grid._frozenFarRows.splice(l.grid._frozenFarRows.indexOf(l),1)),l.grid.refresh())}else l.data&&l.data.$&&(l.data.$[e]=i,"style"===e&&(l._style=i,l._style._changed=!0))}}),Smart("smart-grid-row",class extends Smart.BaseElement{static get properties(){return{}}get isUtilityElement(){return!0}get hasStyleObserver(){return!1}addThemeClass(){}addDefaultClass(){}_initialize(e){const t=this,i=e.grid,l=i._columnElements,a=i._frozenNearColumns,r=i._frozenFarColumns,n=document.createElement("div"),o=document.createElement("div"),d=document.createElement("div"),s=document.createDocumentFragment(),c=document.createDocumentFragment(),h=document.createDocumentFragment();i.rightToLeft?(o.classList.add("far","smart-grid-cell-container"),n.classList.add("center","smart-grid-cell-container"),d.classList.add("near","smart-grid-cell-container")):(o.classList.add("near","smart-grid-cell-container"),n.classList.add("center","smart-grid-cell-container"),d.classList.add("far","smart-grid-cell-container")),t._properties=[],t.row=e,e.createCells(),t._mouseEnter=function(){if(!i.isScrolling&&!i.editing.isEditing&&(t.commandBar&&(t.commandBar.parentNode.removeChild(t.commandBar),t.commandBar=null),i.editing.enabled&&i.editing.commandColumn.visible&&i.editing.commandColumn.inline&&!t.commandBar)){const e=document.createElement("div"),l=i._getCommandColumnCommandsTemplate();e.classList.add("smart-grid-command-bar"),e.innerHTML=l,n.appendChild(e),requestAnimationFrame((()=>{e.classList.add("show")})),i._updateCommandColumnCommandsVisibility(e,t.row),e.onmousedown=function(e){const l=e.composedPath();let a=null;for(let e=0;e<l.length;e++)if(l[e].classList.contains("smart-grid-command-item")){a=l[e];break}if(a){const l=a.getAttribute("command");i._applyCommand(l,[t.row]),t.commandBar&&(t.commandBar.parentNode.removeChild(t.commandBar),t.commandBar=null),t.removeAttribute("hover"),e.stopPropagation(),e.preventDefault()}},t.commandBar=e}},t._mouseLeave=function(){i.isScrolling||i.editing.isEditing||t.commandBar&&(t.commandBar.classList.remove("show"),t.commandBar.addEventListener("transitionend",(function(){t.commandBar&&(t.commandBar.parentNode.removeChild(t.commandBar),t.commandBar=null)})),t.commandBar.addEventListener("transitioncancel",(function(){t.commandBar&&(t.commandBar.parentNode.removeChild(t.commandBar),t.commandBar=null)})))},t.addEventListener("mouseenter",t._mouseEnter),t.addEventListener("mouseleave",t._mouseLeave);for(let t=0;t<a.length;t++){const i=a[t],l=e.getCell(i).createElement();c.appendChild(l)}for(let t=0;t<r.length;t++){const i=r[t],l=e.getCell(i).createElement();h.appendChild(l)}for(let i=0;i<l.length;i++){const a=l[i],r=a.column;if(!a.parentNode||!r)break;const n=e.getCell(r).createElement();r&&r._treeColumn&&(t.toggleButton=n.toggleButton),s.appendChild(n)}o.appendChild(c),n.appendChild(s),d.appendChild(h);const g=document.createElement("div");g.classList.add("smart-grid-row-detail","smart-hidden","smart-animate");const m=document.createElement("div");m.classList.add("smart-grid-row-sub-container","smart-hidden"),t._rowFragment=document.createDocumentFragment(),t._rowFragment.appendChild(o),t._rowFragment.appendChild(n),t._rowFragment.appendChild(d),t._rowFragment.appendChild(g),t._rowFragment.appendChild(m),t.appendChild(t._rowFragment),t.cellsNearContainerElement=t.children[0],t.cellsContainerElement=t.children[1],t.cellsFarContainerElement=t.children[2],t.rowDetail=t.children[3],t.rowContainer=t.children[4],i.layout.rowHeight&&"auto"!==i.layout.rowHeight&&(e.filterRow?t.style.height=i.layout.rowMinHeight+"px":t.style.height=i.layout.rowHeight+"px"),delete t._rowFragment}get enableShadowDOM(){return!1}_handleExpandCollapse(e,t){const i=this,l=i.row,a=l.grid;if(!l.allowToggle)return null;a._toggledRow=l;let r={row:l,id:l.id};t&&(r.originalEvent=t.originalEvent),a.$.fireEvent(e?"rowExpand":"rowCollapse",r);const n=a.dataSource.virtualDataSourceOnExpand&&e&&!0!==l.data._loaded;if(e?a.dataSource._expandedRowIds[l.data.$.id]=!0:delete a.dataSource._expandedRowIds[l.data.$.id],a.stateSettings.autoSave&&a.saveState(null,["expandedRows"]),!a.appearance.allowRowToggleAnimation||n)a.rows.canNotify=!1,l.expanded=e,a.rows.canNotify=!0,l.data.expanded=e,n?(l.data._loaded=!0,l.element.querySelector("button").setAttribute("load",""),a._virtualDataRequest("expand")):(a._toggledRow=null,a._refresh()),n&&a.appearance.allowRowToggleAnimation&&(i.toggleButton.removeAttribute("toggled"),i.toggleButton.classList.remove("smart-animate"),setTimeout((()=>{i.toggleButton.classList.add("smart-animate"),i.toggleButton.setAttribute("toggled","")}),50));else{const t=function(e){e.height=e.cellHeight,a.$.content.style.transition="",e.element.rowContainer.innerHTML="",e.element.rowContainer.classList.add("smart-hidden"),e.element.rowContainer.removeEventListener("transitionend",r),e.element.rowContainer.removeEventListener("transitioncancel",r),e.element.rowContainer.style.height="",e.element.rowContainer.style.transform="",e.element.rowContainer.style.transition="",e.element.rowContainer.classList.remove("smart-animate"),e.element.toggleButton&&e.element.toggleButton.classList.remove("smart-animate"),a._refresh()},r=function(e){const l=a._toggledRow;i._toggleTimer=null,a._toggledRow=null,!l||"transform"!==e.propertyName&&"height"!==e.propertyName||setTimeout((()=>{t(l)}),50)};if(i._toggleTimer){clearTimeout(i._toggleTimer);const e=a._toggledRow;a._toggledRow=null,t(e)}i._toggleTimer=setTimeout((()=>{const t=function(){!function(){const e=a._toggledRow;a._refresh(),a._refreshRowHierarchy();let t=0;for(let e=0;e<a.rowHierarchy.length;e++){const i=a.rowHierarchy[e];let l=i.parent;for(;l;)l.id===a._toggledRow.id&&(t+=i.height),l=l.parent}const i=a._scrollView.scrollTop,l=a._contentHeight-(e.cellHeight+e.top-i);e.expandHeight=Math.min(l,t),e.height=e.cellHeight+e.expandHeight}(),a._recycle(!1),i.style.overflow="hidden",i.style.height="auto",i.style.lineHeight=l.cellHeight+"px"};e?(l.expanded=!0,t(),i.rowContainer.style.transform="scaleY(0)",i.rowContainer.style.height="0px",i.toggleButton&&i.toggleButton.removeAttribute("toggled"),a._autoHeight&&(a.$.content.style.height=parseInt(a.$.content.style.height)-l.expandHeight+"px"),setTimeout((function(){i.toggleButton&&(i.toggleButton.classList.add("smart-animate"),i.toggleButton.setAttribute("toggled","")),i.rowContainer.addEventListener("transitionend",r),i.rowContainer.addEventListener("transitioncancel",r),a._autoHeight&&(a.$.content.style.transition="0.25s height ease-in-out",a.$.content.style.height=parseInt(a.$.content.style.height)+l.expandHeight+"px"),i.rowContainer.classList.add("smart-animate"),i.rowContainer.style.height=l.expandHeight+"px",i.rowContainer.style.transform="scaleY(1)"}))):(t(),l.expanded=!1,i.rowContainer.style.transform="scaleY(0)",i.rowContainer.style.height="0px",a._autoHeight&&(a.$.content.style.height=parseInt(a.$.content.style.height)-l.expandHeight+"px",a.$.content.style.transition="",a.$.content.style.height=parseInt(a.$.content.style.height)+l.expandHeight+"px"),i.rowContainer.style.height=l.expandHeight+"px",i.rowContainer.style.transform="scaleY(1)",i.toggleButton&&(i.toggleButton.setAttribute("toggled",""),i.toggleButton.classList.add("smart-animate")),setTimeout((function(){i.toggleButton&&i.toggleButton.removeAttribute("toggled",""),a._autoHeight&&(a.$.content.style.transition="0.25s height ease-in-out",a.$.content.style.height=parseInt(a.$.content.style.height)-l.expandHeight+"px"),i.rowContainer.addEventListener("transitionend",r),i.rowContainer.addEventListener("transitioncancel",r),i.rowContainer.classList.add("smart-animate"),i.rowContainer.style.transform="scaleY(0)",i.rowContainer.style.height="0px"}),0))}),50)}}_renderAddNewRow(){const e=this,t=e.row,i=t.grid,l=t.element,a=new Smart.Grid.Cell(t,i.columns[0],i);t.visible?l.classList.remove("smart-hidden"):l.classList.add("smart-hidden");let r=i.editing.addNewRow.label;r.indexOf("{{")>=0&&(r=i.localize("addNewRow")),l.innerHTML="<smart-grid-cell><div>"+r+"</div></smart-grid-cell>",l.firstChild.firstChild.classList.add("align-center"),l.firstChild.classList.add("smart-grid-column-border-collapse"),l.firstChild.setAttribute("freeze",""),l.firstChild.setAttribute("addNewRow",""),l.firstChild.style.width="100%",i._scrollView.vScrollBar.offsetWidth>0&&(l.firstChild.style.width="calc(100% - "+(-1+i._scrollView.vScrollBar.offsetWidth)+"px)"),l.firstChild.cell=a,i._rowGap>0&&t!==i.rows[i.rows.length-1]?(e.style.marginBottom=i._rowGap+"px",parseInt(e.style.height)-i._rowGap!==t.height&&(e.style.height=t.height-i._rowGap+"px"),parseInt(e.style.lineHeight)-i._rowGap!==t.height&&(e.style.lineHeight=t.height-i._rowGap+"px")):(e.style.marginBottom="",parseInt(e.style.height)!==t.height&&(e.style.height=t.height+"px"),parseInt(e.style.lineHeight)!==t.height&&(e.style.lineHeight=t.height+"px"))}_renderFilterRow(){const e=this,t=e.row,i=t.grid,l=t.element;t.visible?l.classList.remove("smart-hidden"):l.classList.add("smart-hidden"),l.innerHTML="<smart-grid-cell><div>"+i.localize("addNewRow")+"</div></smart-grid-cell>",l.firstChild.firstChild.classList.add("align-center"),l.firstChild.classList.add("smart-grid-column-border-collapse"),l.firstChild.setAttribute("freeze",""),l.firstChild.setAttribute("addNewRow",""),l.firstChild.style.width="100%",i._scrollView.vScrollBar.offsetWidth>0&&(l.firstChild.style.width="calc(100% - "+(-1+i._scrollView.vScrollBar.offsetWidth)+"px)"),e.style.marginBottom="",parseInt(e.style.height)!==t.height&&(e.style.height=t.height+"px"),parseInt(e.style.lineHeight)!==t.height&&(e.style.lineHeight=t.height+"px")}_renderEmpty(){this.classList.add("smart-hidden")}_renderCell(e,t,i){if(!t)return void i.classList.add("smart-hidden");let l=e.getCell(t);if(l.element!==i&&(l._styleChanged=!0),e._style&&!t.autoGenerated){const t=l._updating;l._updating=!0,e._style._changed&&(l.color=e._style.color,l.background=e._style.background,l.fontFamily=e._style.fontFamily,l.fontSize=e._style.fontSize,l.fontStyle=e._style.fontStyle,l.textDecoration=e._style.textDecoration,l.fontWeight=e._style.fontWeight);const a=i.firstElementChild,r=e=>a._style&&a._style[e]?a._style[e]:"backgroundColor"===e&&null===l.background&&""===a.style[e]||null===l[e]&&""===a.style[e]?null:a.style[e];r("backgroundColor")===l.background&&r("fontFamily")===l.fontFamily&&r("fontSize")===l.fontSize&&r("fontStyle")===l.fontStyle&&r("textDecoration")===l.textDecoration&&r("fontWeight")===l.fontWeight&&r("color")===l.color||(l._styleChanged=!0),l._updating=t}i.cell!==l&&(i.cell.background===l.background&&i.cell.borderColor===l.borderColor&&i.cell.color===l.color&&i.cell.fontSize===l.fontSize&&i.cell.fontFamily===l.fontFamily&&i.cell.textDecoration===l.textDecoration&&i.cell.fontWeight===l.fontWeight&&i.cell.fontStyle===l.fontStyle||(l._styleChanged=!0)),l.element=i,i.cell=l,t._treeColumn&&l.element.isRendered&&!e.filterRow&&l.element._refresh(),l.render(),t&&t.rowHeaderColumn&&(e.header=i,i.setAttribute("data-id",e.id))}_alternate(){const e=this,t=e.row,i=t.grid,l=i.appearance.alternationStart,a=i.appearance.alternationEnd>0?i.appearance.alternationEnd:1/0;if(!(i.appearance.alternationCount<=0)&&(e.removeAttribute("alternation-index"),t.visibleIndex>=l&&t.visibleIndex<=a)){const a=(t.visibleIndex-l)%i.appearance.alternationCount;e.setAttribute("alternation-index",a)}}_openRowDetailDialog(e){const t=this,i=t.row.grid,l=t.row;if(!i.rowDetail.dialog.enabled||!l.showDetail)return!1;const a=i._dialogRowDetail||i._createDialog(i.rowDetail.dialog);if(!l.detailTemplate&&!i.rowDetail.template&&i._openRowSettingsDialog&&!i.onRowDetailInit)return void(i.editing.dialog.visible||(t._settingsDialogRowId=l.id,i._openRowSettingsDialog(l.id)));if(i.rowDetail.dialog.visible&&a.row!==l)return void(l.showDetail=!1);const r="{{message}}"===i.rowDetail.dialog.header?i.localize("dialogRowDetailHeader",{value:l.visibleIndex+1}):i.rowDetail.dialog.header;!i.rowDetail.dialog.visible||i.rowDetail.dialog.row!==l||l.showDetail?(a.header.innerHTML=r,a.content.innerHTML="",a.content.style.width="100%",a.content.style.height="100%",a.row=l,a.querySelector(".smart-footer").classList.add("smart-hidden"),i._dialogRowDetail||(a.setAttribute("tabindex",0),a.modal=!0,a.btnConfirm.innerHTML=i.localize("dialogRowDetailButtonConfirm"),a.btnCancel.innerHTML=i.localize("dialogRowDetailButtonCancel"),a.btnCancel.classList.add("smart-hidden"),a.onOpen=function(){i.rowDetail.dialog.visible=!0},a.onClose=function(){i.rowDetail.dialog.visible=!1,a.row.showDetail=!1},a.btnCancel.onclick=function(){a.close()},a.btnClose.onclick=function(){a.close()},a.btnConfirm.onclick=function(){a.close()},a.onkeydown=function(e){"Escape"===e.key&&a.close()},i._dialogRowDetail=a),a.open(),setTimeout((function(){a.focus()}),100),a.content.appendChild(e)):a.close()}_renderDetail(e){const t=this,i=t.row.grid,l=t.row;let a=l.id,r=l.detailTemplate||i.rowDetail.template;if(r.startsWith("#")&&(r=document.querySelector(r)),l._detail)return e.firstChild===l._detail||(e.firstChild&&e.removeChild(e.firstChild),e.appendChild(l._detail)),void(i.onRowDetailUpdated&&i.onRowDetailUpdated(l.index,l,e.firstChild));if(r instanceof HTMLTemplateElement){const t=r.content.cloneNode(!0).firstElementChild;a=a.toString(),a=a.replace(/'/gi,"\\'"),a=a.replace(/"/gi,'\\"');let i=t.outerHTML.replace(/{{value}}/gi,a).replace(/{{id}}/gi,l.id);i.indexOf("{{value=")>=0&&(a?(i=i.substring(0,i.indexOf("{{value="))+a+i.substring(i.indexOf("}")),i=i.replace(/}/gi,""),i=i.replace(/{/gi,"")):(i=i.replace(/{{value=/gi,""),i=i.replace(/}}/gi,""))),i="<div>"+i+"</div>";for(let e in l.data)i=i.replace("{{"+e+"}}",l.data[e]);e.innerHTML!==i&&(e.innerHTML=i)}else{let t="<div>"+r.replace(/{{value}}/gi,a).replace(/{{id}}/gi,l.id)+"</div>";for(let e in l.data)t=t.replace("{{"+e+"}}",l.data[e]);e.innerHTML!==t&&(e.innerHTML=t)}i.onRowDetailInit&&i.onRowDetailInit(l.index,l,e.firstChild),i.rowDetail.dialog.enabled?i.rowDetail.dialog.visible?t._openRowDetailDialog(e.firstChild):t._openRowDetailDialog(e.firstChild.firstElementChild):l._detail=e.firstChild}_render(){let e=this;const t=e.row,i=t.grid;if(!i)return;const l=t.getProperty("selected");if(!1===l&&e.hasAttribute("selected")?e.removeAttribute("selected"):!0===l?e.setAttribute("selected",""):null===l&&e.setAttribute("selected","indeterminate"),t.allowSelect||e.setAttribute("selected","none"),e.hasAttribute("unbound")&&e.removeAttribute("unbound"),t.unbound&&e.setAttribute("unbound",""),e.removeAttribute("focus"),i._selection.focusedCell&&i._selection.focusedCell.row&&i._selection.focusedCell.row.id===t.id&&e.setAttribute("focus",""),!i._toggledRow&&e.classList.contains("smart-animate"))return e.classList.remove("smart-animate"),e.rowContainer.innerHTML="",e.rowContainer.classList.add("smart-hidden"),i._refreshLayout(),void i._recycle();if(0===i.columns.length)return void e._renderEmpty();if(t.addNewRow&&!t.inline)return void e._renderAddNewRow();let a=!1;if(t.addNewRow&&t.inline&&(a=!0),i._toggledRow&&(t.id===i._toggledRow.id?e.setAttribute("toggle",""):e.hasAttribute("toggle")&&e.removeAttribute("toggle")),i._toggledRow&&i.appearance.allowRowToggleAnimation){let l=t.parent;if(!i._toggledRow.expanded&&i._toggledRow.id===t.id){const t=e.rowContainer;for(let e=0;e<t.children.length;e++){const l=t.children[e],a=l.getAttribute("data-id"),r=i.rowById[a];l.getAttribute("data-rendered")||(l.setAttribute("data-rendered",!0),r.element=l,r.render())}}for(;l;){if(l.id===i._toggledRow.id){const a=l.element.rowContainer;if(i._toggledRow.expanded){e.classList.add("smart-hidden");let l=t.createElement(i);for(let e=0;e<a.children.length;e++){const i=a.children[e];if(i.getAttribute("data-id")===t.id.toString())return void(l=i)}t.element=l,a.appendChild(l),a.classList.remove("smart-hidden"),l.row=t,e=l}break}l=l.parent}}e._alternate();const r=parseFloat(i.$.columnNearContainer.style.width),n=parseFloat(i.$.columnContainer.style.width),o=parseFloat(i.$.columnFarContainer.style.width),d=e.children[1],s=e.children[0],c=e.children[2];if(i.rightToLeft?(s.classList.remove("vscroll"),i.computedVerticalScrollBarVisibility&&s.classList.add("vscroll")):(c.classList.remove("vscroll"),i.computedVerticalScrollBarVisibility&&c.classList.add("vscroll")),e.hasAttribute("group")&&e.removeAttribute("group"),e.hasAttribute("tree")&&e.removeAttribute("tree"),e.hasAttribute("level")&&(e.removeAttribute("level"),e.removeAttribute("aria-level")),e.hasAttribute("leaf")&&e.removeAttribute("leaf"),e.hasAttribute("expanded")&&e.removeAttribute("expanded"),e.hasAttribute("summary")&&e.removeAttribute("summary"),e.hasAttribute("filter")&&e.removeAttribute("filter"),null===t.filtered&&e.setAttribute("filter","indeterminate"),i.dataSource.groupBy&&i.dataSource.groupBy.length>0&&"advanced"===i.grouping.renderMode&&!t.filterRow?(e.setAttribute("level",t.level),e.setAttribute("aria-level",t.level),t.expanded&&e.setAttribute("expanded",""),void 0!==t.label&&t.level===i.dataSource.groupBy.length-1&&e.setAttribute("leaf",""),void 0!==t.label?e.setAttribute("group",""):e.setAttribute("leaf",""),t.summaryRow&&e.setAttribute("summary",""),e.toggleButton&&e.toggleButton.classList.remove("smart-hidden")):i.dataSource.boundHierarchy?(e.setAttribute("level",t.level),e.setAttribute("aria-level",t.level),t.expanded&&e.setAttribute("expanded",""),t.leaf&&e.setAttribute("leaf",""),t.summaryRow&&e.setAttribute("summary",""),e.toggleButton&&e.toggleButton.classList.remove("smart-hidden")):(t.canNotify=!1,t.leaf=!0,t.expanded=!1,t.summaryRow=!1,t.data||(t.data={}),t.data.summaryRow&&(t.summaryRow=!0),t.level=0,e.toggleButton&&e.toggleButton.classList.add("smart-hidden"),t.canNotify=!0),e.setAttribute("data-id",t.id),e.visible=t.visible,e.cellsNearContainerElement.classList.remove("smart-visibility-hidden"),e.cellsContainerElement.classList.remove("smart-visibility-hidden"),e.cellsFarContainerElement.classList.remove("smart-visibility-hidden"),e.removeAttribute("rowspan"),t.addNewRow&&(t.cellHeight=t.height=i.layout.rowMinHeight),i._rowGap>0&&t!==i.rows[i.rows.length-1]?(e.style.marginBottom=i._rowGap+"px",parseInt(e.style.height)-i._rowGap!==t.height&&(e.style.height=t.height-i._rowGap+"px"),parseInt(e.style.lineHeight)-i._rowGap!==t.height&&(e.style.lineHeight=t.height-i._rowGap+"px")):(e.style.marginBottom="",parseInt(e.style.height)!==t.height&&(e.style.height=t.height+"px"),parseInt(e.style.lineHeight)!==t.height&&(e.style.lineHeight=t.height+"px")),i.rightToLeft?(d.style.right!==i._scrollView.scrollWidth-i._scrollView.scrollLeft-i._scrollView.vScrollBar.offsetWidth+"px"&&(d.style.right=i._scrollView.scrollWidth-i._scrollView.scrollLeft-i._scrollView.vScrollBar.offsetWidth+"px"),i._scrollView.scrollWidth-i._scrollView.scrollLeft-i._scrollView.vScrollBar.offsetWidth<=0&&!i._scrollView.scrollWidth&&(d.style.right=-i.offsetWidth+i._computedColumnsWidth+"px")):d.style.left!==-i._scrollView.scrollLeft+"px"&&(d.style.left=-i._scrollView.scrollLeft+"px"),i.rowDetail.enabled){const l=e.rowDetail;e.removeAttribute("show-detail"),t.showDetail?(l.classList.remove("smart-hidden"),e.setAttribute("show-detail",""),i.rowDetail.dialog.enabled?l.classList.add("smart-hidden"):(l.style.height!==t.detailHeight+"px"&&(l.style.height=t.detailHeight+"px"),l.style.lineHeight!==t.detailHeight+"px"&&(l.style.lineHeight=t.detailHeight+"px"),l.style.top!==t.cellHeight+"px"&&(l.style.top=t.cellHeight+"px")),e._renderDetail(l)):l.classList.add("smart-hidden")}else e.rowDetail&&e.rowDetail.classList.add("smart-hidden");if(s.classList.remove("smart-hidden"),c.classList.remove("smart-hidden"),s.style.width!==r+"px"&&(s.style.width=r+"px"),d.style.width!==n+"px"&&(d.style.width=n+"px"),c.style.width!==o+"px"&&(c.style.width=o+"px"),s.style.height=t.cellHeight+"px",d.style.height=t.cellHeight+"px",c.style.height=t.cellHeight+"px",0===o&&c.classList.add("smart-hidden"),0===r&&s.classList.add("smart-hidden"),r>0&&(parseInt(r),parseInt(i._autoGeneratedColumnsNearWidth)),o>0&&parseInt(o)===parseInt(i._autoGeneratedColumnsFarWidth)&&c.classList.add("border-collapse"),t._classNames="",i.onRowClass){const e=i.onRowClass(t.visibleIndex,t.data,t);if(e){const i=e.trim().split(" ");t._classNames=i}}if(i.rowCSSRules){const e=Object.keys(i.rowCSSRules);let l=[];for(let a=0;a<e.length;a++){let r=e[a];const n={index:t.visibleIndex,data:t.data,row:t,api:i};i.rowCSSRules[r](n)&&l.push(r)}t._classNames=l}for(let l=0;l<i._frozenNearColumns.length;l++){const a=i._frozenNearColumns[l];let r=e.children[0].children[l];r||(r=t.getCell(a).createElement(),e.children[0].appendChild(r)),!1!==a.visbile&&e._renderCell(t,a,r)}for(let l=0;l<i._frozenFarColumns.length;l++){const a=i._frozenFarColumns[l];let r=e.children[2].children[l];r||(r=t.getCell(a).createElement(),e.children[2].appendChild(r)),!1!==a.visbile&&e._renderCell(t,a,r)}for(let l=0;l<d.children.length;l++)if(!i._columnElements[l+i._frozenNearColumns.length]){let i=e.children[1].children[l];e._renderCell(t,null,i)}for(let l=0;l<i._columnElements.length;l++){const a=i._columnElements[l],r=a.column;if(!a.parentNode||!r){if(a&&!r){let t=e.children[1].children[l];t&&t.classList.add("smart-visibility-hidden")}else if(r&&a&&a.classList.contains("smart-visibility-hidden")){let t=e.children[1].children[l];t&&t.classList.add("smart-visibility-hidden")}continue}let n=e.children[1].children[l];n||(a.column||(a.column=r),n=t.getCell(r).createElement(),e.children[1].appendChild(n)),a.classList.contains("smart-visibility-hidden")?n.classList.add("smart-visibility-hidden"):(n.classList.remove("smart-visibility-hidden"),e._renderCell(t,r,n))}if(a){let t=e.children[1].children[0];const l=d.getBoundingClientRect(),a=s.getBoundingClientRect();for(let e=0;e<s.children.length;e++)s.children[e].classList.add("smart-add-new-row");s.children[0].innerHTML='<div style="width: 100%;" class="smart-grid-icon smart-icon-plus show"></div>',s.children[0].style.width="50px",s.children[0].style.zIndex=9;const r=i.editing.addNewColumn.visible?i._addNewColumn.width:0;let n=l.width-a.width-r+6,o=0;(i.appearance.showRowHeaderNumber||i.appearance.showRowHeader)&&(o+=30),i.rowDetail.enabled&&(o+=20),i._frozenColumnsNearWidth&&(n+=i._frozenColumnsNearWidth),t.style.width=n+"px",t.style.left=i._scrollView.scrollLeft+o+"px",i.selection.enabled?(t.content.innerHTML=n>=250?i.localize("addNewRowAlt"):i.localize("addNewRowAltSmall"),s.children[1]&&(t.content.title=s.children[1].title=i.localize("addNewRow")),i.rightToLeft&&(t.style.left="initial",t.style.right=a.width+"px"),!1===i.appearance.showRowHeader&&(i.rightToLeft?t.content.innerHTML='<span style="margin-right: 35px;"></span>'+i.localize("addNewRowAlt"):t.content.innerHTML='<span style="margin-left: 35px;"></span>'+i.localize("addNewRowAlt"))):t.content.innerHTML=i.localize("addNewRow"),t.classList.add("smart-add-new-row"),t.firstElementChild.classList.add("align-left"),t.firstElementChild.classList.remove("align-right")}t&&t._style&&(t._style._changed=!1),e.visible?e.classList.remove("smart-hidden"):e.classList.add("smart-hidden")}template(){return""}_detach(){const e=this;e.row.headerCell=null,e.row._cells=[],e.row=null,delete e.row,e.element=null,e.removeEventListener("mouseenter",e._mouseEnter),e.removeEventListener("mouseleave",e._mouseLeave),delete e.element,delete e.grid,delete e._mouseEnter,delete e._mouseLeave,delete e.cellsNearContainerElement,delete e.cellsContainerElement,delete e.cellsFarContainerElement,delete e.rowDetail,delete e.rowContainer}onDetached(){this._detach()}});