var Common;!function(t){!function(e){"use strict";class i{constructor(t,e,i,n,o,s){this._dataIndex=t;this._columnIndex=e;this._ignoreCommitCallback=!1;this._gridControl=n;this._options=o;this._editElement=i;this._textValue=i.hasAttribute("grid-edit-value")?i.getAttribute("grid-edit-value"):i.innerText;this._cachedInnerHTML=i.innerHTML;this._inputElement=s||document.createElement("input");this._inputElement.value=this._textValue;this._inputElement.classList.add("grid-edit-box");this._keyboardHandler=this.keyboardHandler.bind(this);this._inputElement.addEventListener("keydown",this._keyboardHandler);this._focusHandler=this.focusHandler.bind(this);this._inputElement.addEventListener("focusout",this._focusHandler)}get inputElement(){return this._inputElement}dismiss(){this._editElement.innerHTML=this._cachedInnerHTML;this._editElement.focus();this.notifyPostEdit()}notifyPostEdit(){this._inputElement.removeEventListener("keydown",this._keyboardHandler);this._inputElement.removeEventListener("focusout",this._focusHandler);void 0!==this._options.postEditCellCallback&&this._options.postEditCellCallback(this._dataIndex,this._columnIndex)}keyboardHandler(e){var i=this._gridControl.getRowInfo(this._dataIndex),n=this._gridControl.getColumns();if(e.keyCode===t.KeyCodes.Enter){this.commitValue(e);e.stopPropagation();return!1}if(e.keyCode===t.KeyCodes.Escape){this.dismiss();e.stopPropagation();e.preventDefault();return!1}if(e.keyCode!==t.KeyCodes.Tab){if(e.keyCode===t.KeyCodes.ArrowUp||e.keyCode===t.KeyCodes.ArrowDown||e.keyCode===t.KeyCodes.PageUp||e.keyCode===t.KeyCodes.PageDown)return!0;e.stopPropagation();return t.preventIEKeys(e)}if(this._options.commitOnTab)this.commitValue(e);else if(i){var o=i.row.children;this._ignoreCommitCallback=!0;this._editElement.innerHTML=this._cachedInnerHTML;this.notifyPostEdit();var s=this._columnIndex;if(e.shiftKey)for(;s>0;){if((r=o[--s]).classList.contains("grid-cell-editable")){this._gridControl.createEditBox(this._dataIndex,s,r);break}}else{for(;s<n.length-1;){var r;if((r=o[++s]).classList.contains("grid-cell-editable")){this._gridControl.createEditBox(this._dataIndex,s,r);break}}n.length>0&&s===n.length-1&&o[0].parentElement.focus()}e.stopPropagation();return!1}}focusHandler(t){this.commitValue(t)}commitValue(t){var e=this._inputElement.value;this._editElement.innerText=this._ignoreCommitCallback?this._textValue:e;this._options.commitEditCellCallback&&!this._ignoreCommitCallback&&this._options.commitEditCellCallback(e,this._dataIndex,this._columnIndex);this.notifyPostEdit();t.stopPropagation();t.preventDefault();return!1}}e.GridCellEditControl=i}(t.Grid||(t.Grid={}))}(Common||(Common={}));
