tabulator-tables
Version:
Interactive table generation JavaScript library
2 lines • 28.4 kB
JavaScript
/* Tabulator v4.9.3 (c) Oliver Folkerd */
var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},Edit=function(e){this.table=e,this.currentCell=!1,this.mouseClick=!1,this.recursionBlock=!1,this.invalidEdit=!1,this.editedCells=[]};Edit.prototype.initializeColumn=function(e){var t=this,i={editor:!1,blocked:!1,check:e.definition.editable,params:e.definition.editorParams||{}};switch(_typeof(e.definition.editor)){case"string":"tick"===e.definition.editor&&(e.definition.editor="tickCross",console.warn("DEPRECATION WARNING - the tick editor has been deprecated, please use the tickCross editor")),t.editors[e.definition.editor]?i.editor=t.editors[e.definition.editor]:console.warn("Editor Error - No such editor found: ",e.definition.editor);break;case"function":i.editor=e.definition.editor;break;case"boolean":!0===e.definition.editor&&("function"!=typeof e.definition.formatter?("tick"===e.definition.formatter&&(e.definition.formatter="tickCross",console.warn("DEPRECATION WARNING - the tick editor has been deprecated, please use the tickCross editor")),t.editors[e.definition.formatter]?i.editor=t.editors[e.definition.formatter]:i.editor=t.editors.input):console.warn("Editor Error - Cannot auto lookup editor for a custom formatter: ",e.definition.formatter))}i.editor&&(e.modules.edit=i)},Edit.prototype.getCurrentCell=function(){return!!this.currentCell&&this.currentCell.getComponent()},Edit.prototype.clearEditor=function(e){var t,i=this.currentCell;if(this.invalidEdit=!1,i){for(this.currentCell=!1,t=i.getElement(),e?i.validate():t.classList.remove("tabulator-validation-fail"),t.classList.remove("tabulator-editing");t.firstChild;)t.removeChild(t.firstChild);i.row.getElement().classList.remove("tabulator-row-editing")}},Edit.prototype.cancelEdit=function(){if(this.currentCell){var e=this.currentCell,t=this.currentCell.getComponent();this.clearEditor(!0),e.setValueActual(e.getValue()),e.cellRendered(),("textarea"==e.column.definition.editor||e.column.definition.variableHeight)&&e.row.normalizeHeight(!0),e.column.cellEvents.cellEditCancelled&&e.column.cellEvents.cellEditCancelled.call(this.table,t),this.table.options.cellEditCancelled.call(this.table,t)}},Edit.prototype.bindEditor=function(e){var t=this,i=e.getElement(!0);i.setAttribute("tabindex",0),i.addEventListener("click",function(e){i.classList.contains("tabulator-editing")||i.focus({preventScroll:!0})}),i.addEventListener("mousedown",function(e){2===e.button?e.preventDefault():t.mouseClick=!0}),i.addEventListener("focus",function(i){t.recursionBlock||t.edit(e,i,!1)})},Edit.prototype.focusCellNoEvent=function(e,t){this.recursionBlock=!0,t&&"ie"===this.table.browser||e.getElement().focus({preventScroll:!0}),this.recursionBlock=!1},Edit.prototype.editCell=function(e,t){this.focusCellNoEvent(e),this.edit(e,!1,t)},Edit.prototype.focusScrollAdjust=function(e){if("virtual"==this.table.rowManager.getRenderMode()){var t=this.table.rowManager.element.scrollTop,i=this.table.rowManager.element.clientHeight+this.table.rowManager.element.scrollTop,n=e.row.getElement();n.offsetTop;n.offsetTop<t?this.table.rowManager.element.scrollTop-=t-n.offsetTop:n.offsetTop+n.offsetHeight>i&&(this.table.rowManager.element.scrollTop+=n.offsetTop+n.offsetHeight-i);var o=this.table.rowManager.element.scrollLeft,a=this.table.rowManager.element.clientWidth+this.table.rowManager.element.scrollLeft,r=e.getElement();r.offsetLeft;this.table.modExists("frozenColumns")&&(o+=parseInt(this.table.modules.frozenColumns.leftMargin),a-=parseInt(this.table.modules.frozenColumns.rightMargin)),this.table.options.virtualDomHoz&&(o-=parseInt(this.table.vdomHoz.vDomPadLeft),a-=parseInt(this.table.vdomHoz.vDomPadLeft)),r.offsetLeft<o?this.table.rowManager.element.scrollLeft-=o-r.offsetLeft:r.offsetLeft+r.offsetWidth>a&&(this.table.rowManager.element.scrollLeft+=r.offsetLeft+r.offsetWidth-a)}},Edit.prototype.edit=function(e,t,i){function n(t){if(u.currentCell===e){var i=!0;return e.column.modules.validate&&u.table.modExists("validate")&&"manual"!=u.table.options.validationMode&&(i=u.table.modules.validate.validate(e.column.modules.validate,e,t)),!0===i||"highlight"===u.table.options.validationMode?(u.clearEditor(),e.modules.edit||(e.modules.edit={}),e.modules.edit.edited=!0,-1==u.editedCells.indexOf(e)&&u.editedCells.push(e),e.setValue(t,!0),u.table.options.dataTree&&u.table.modExists("dataTree")&&u.table.modules.dataTree.checkForRestyle(e),!0===i||(m.classList.add("tabulator-validation-fail"),u.table.options.validationFailed.call(u.table,e.getComponent(),t,i),!1)):(u.invalidEdit=!0,m.classList.add("tabulator-validation-fail"),u.focusCellNoEvent(e,!0),c(),u.table.options.validationFailed.call(u.table,e.getComponent(),t,i),!1)}}function o(){u.currentCell===e&&(u.cancelEdit(),u.table.options.dataTree&&u.table.modExists("dataTree")&&u.table.modules.dataTree.checkForRestyle(e))}function a(e){c=e}var r,l,s,u=this,d=!0,c=function(){},m=e.getElement();if(this.currentCell)return void(this.invalidEdit||this.cancelEdit());if(e.column.modules.edit.blocked)return this.mouseClick=!1,m.blur(),!1;switch(t&&t.stopPropagation(),_typeof(e.column.modules.edit.check)){case"function":d=e.column.modules.edit.check(e.getComponent());break;case"boolean":d=e.column.modules.edit.check}if(d||i){if(u.cancelEdit(),u.currentCell=e,this.focusScrollAdjust(e),l=e.getComponent(),this.mouseClick&&(this.mouseClick=!1,e.column.cellEvents.cellClick&&e.column.cellEvents.cellClick.call(this.table,t,l)),e.column.cellEvents.cellEditing&&e.column.cellEvents.cellEditing.call(this.table,l),u.table.options.cellEditing.call(this.table,l),s="function"==typeof e.column.modules.edit.params?e.column.modules.edit.params(l):e.column.modules.edit.params,!1===(r=e.column.modules.edit.editor.call(u,l,a,n,o,s)))return m.blur(),!1;if(!(r instanceof Node))return console.warn("Edit Error - Editor should return an instance of Node, the editor returned:",r),m.blur(),!1;for(m.classList.add("tabulator-editing"),e.row.getElement().classList.add("tabulator-row-editing");m.firstChild;)m.removeChild(m.firstChild);m.appendChild(r),c();for(var f=m.children,p=0;p<f.length;p++)f[p].addEventListener("click",function(e){e.stopPropagation()});return!0}return this.mouseClick=!1,m.blur(),!1},Edit.prototype.maskInput=function(e,t){function i(t){var l=n[t];void 0!==l&&l!==r&&l!==o&&l!==a&&(e.value=e.value+""+l,i(t+1))}var n=t.mask,o=void 0!==t.maskLetterChar?t.maskLetterChar:"A",a=void 0!==t.maskNumberChar?t.maskNumberChar:"9",r=void 0!==t.maskWildcardChar?t.maskWildcardChar:"*",l=!1;e.addEventListener("keydown",function(t){var i=e.value.length,s=t.key;if(t.keyCode>46){if(i>=n.length)return t.preventDefault(),t.stopPropagation(),l=!1,!1;switch(n[i]){case o:if(s.toUpperCase()==s.toLowerCase())return t.preventDefault(),t.stopPropagation(),l=!1,!1;break;case a:if(isNaN(s))return t.preventDefault(),t.stopPropagation(),l=!1,!1;break;case r:break;default:if(s!==n[i])return t.preventDefault(),t.stopPropagation(),l=!1,!1}l=!0}}),e.addEventListener("keyup",function(n){n.keyCode>46&&t.maskAutoFill&&i(e.value.length)}),e.placeholder||(e.placeholder=n),t.maskAutoFill&&i(e.value.length)},Edit.prototype.getEditedCells=function(){var e=[];return this.editedCells.forEach(function(t){e.push(t.getComponent())}),e},Edit.prototype.clearEdited=function(e){var t;e.modules.edit&&e.modules.edit.edited&&(e.modules.edit.edited=!1,e.modules.validate&&(e.modules.validate.invalid=!1)),(t=this.editedCells.indexOf(e))>-1&&this.editedCells.splice(t,1)},Edit.prototype.editors={input:function(e,t,i,n,o){function a(e){(null===r||void 0===r)&&""!==l.value||l.value!==r?i(l.value)&&(r=l.value):n()}var r=e.getValue(),l=document.createElement("input");if(l.setAttribute("type",o.search?"search":"text"),l.style.padding="4px",l.style.width="100%",l.style.boxSizing="border-box",o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var s in o.elementAttributes)"+"==s.charAt(0)?(s=s.slice(1),l.setAttribute(s,l.getAttribute(s)+o.elementAttributes["+"+s])):l.setAttribute(s,o.elementAttributes[s]);return l.value=void 0!==r?r:"",t(function(){l.focus({preventScroll:!0}),l.style.height="100%"}),l.addEventListener("change",a),l.addEventListener("blur",a),l.addEventListener("keydown",function(e){switch(e.keyCode){case 13:a(e);break;case 27:n();break;case 35:case 36:e.stopPropagation()}}),o.mask&&this.table.modules.edit.maskInput(l,o),l},textarea:function(e,t,i,n,o){function a(t){(null===r||void 0===r)&&""!==u.value||u.value!==r?(i(u.value)&&(r=u.value),setTimeout(function(){e.getRow().normalizeHeight()},300)):n()}var r=e.getValue(),l=o.verticalNavigation||"hybrid",s=String(null!==r&&void 0!==r?r:""),u=(s.match(/(?:\r\n|\r|\n)/g),document.createElement("textarea")),d=0;if(u.style.display="block",u.style.padding="2px",u.style.height="100%",u.style.width="100%",u.style.boxSizing="border-box",u.style.whiteSpace="pre-wrap",u.style.resize="none",o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var c in o.elementAttributes)"+"==c.charAt(0)?(c=c.slice(1),u.setAttribute(c,u.getAttribute(c)+o.elementAttributes["+"+c])):u.setAttribute(c,o.elementAttributes[c]);return u.value=s,t(function(){u.focus({preventScroll:!0}),u.style.height="100%",u.scrollHeight,u.style.height=u.scrollHeight+"px",e.getRow().normalizeHeight()}),u.addEventListener("change",a),u.addEventListener("blur",a),u.addEventListener("keyup",function(){u.style.height="";var t=u.scrollHeight;u.style.height=t+"px",t!=d&&(d=t,e.getRow().normalizeHeight())}),u.addEventListener("keydown",function(e){switch(e.keyCode){case 27:n();break;case 38:("editor"==l||"hybrid"==l&&u.selectionStart)&&(e.stopImmediatePropagation(),e.stopPropagation());break;case 40:("editor"==l||"hybrid"==l&&u.selectionStart!==u.value.length)&&(e.stopImmediatePropagation(),e.stopPropagation());break;case 35:case 36:e.stopPropagation()}}),o.mask&&this.table.modules.edit.maskInput(u,o),u},number:function(e,t,i,n,o){function a(){var e=s.value;isNaN(e)||""===e||(e=Number(e)),e!==r?i(e)&&(r=e):n()}var r=e.getValue(),l=o.verticalNavigation||"editor",s=document.createElement("input");if(s.setAttribute("type","number"),void 0!==o.max&&s.setAttribute("max",o.max),void 0!==o.min&&s.setAttribute("min",o.min),void 0!==o.step&&s.setAttribute("step",o.step),s.style.padding="4px",s.style.width="100%",s.style.boxSizing="border-box",o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var u in o.elementAttributes)"+"==u.charAt(0)?(u=u.slice(1),s.setAttribute(u,s.getAttribute(u)+o.elementAttributes["+"+u])):s.setAttribute(u,o.elementAttributes[u]);s.value=r;var d=function(e){a()};return t(function(){s.removeEventListener("blur",d),s.focus({preventScroll:!0}),s.style.height="100%",s.addEventListener("blur",d)}),s.addEventListener("keydown",function(e){switch(e.keyCode){case 13:a();break;case 27:n();break;case 38:case 40:"editor"==l&&(e.stopImmediatePropagation(),e.stopPropagation());break;case 35:case 36:e.stopPropagation()}}),o.mask&&this.table.modules.edit.maskInput(s,o),s},range:function(e,t,i,n,o){function a(){var e=l.value;isNaN(e)||""===e||(e=Number(e)),e!=r?i(e)&&(r=e):n()}var r=e.getValue(),l=document.createElement("input");if(l.setAttribute("type","range"),void 0!==o.max&&l.setAttribute("max",o.max),void 0!==o.min&&l.setAttribute("min",o.min),void 0!==o.step&&l.setAttribute("step",o.step),l.style.padding="4px",l.style.width="100%",l.style.boxSizing="border-box",o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var s in o.elementAttributes)"+"==s.charAt(0)?(s=s.slice(1),l.setAttribute(s,l.getAttribute(s)+o.elementAttributes["+"+s])):l.setAttribute(s,o.elementAttributes[s]);return l.value=r,t(function(){l.focus({preventScroll:!0}),l.style.height="100%"}),l.addEventListener("blur",function(e){a()}),l.addEventListener("keydown",function(e){switch(e.keyCode){case 13:a();break;case 27:n()}}),l},select:function(e,t,i,n,o){function a(t){var i,n={},o=A.table.getData();return i=t?A.table.columnManager.getColumnByField(t):e.getColumn()._getSelf(),i?o.forEach(function(e){var t=i.getFieldValue(e);null!==t&&void 0!==t&&""!==t&&(n[t]=!0)}):console.warn("unable to find matching column to create select lookup list:",t),Object.keys(n)}function r(t,i){function n(e){var e={label:e.label,value:e.value,itemParams:e.itemParams,elementAttributes:e.elementAttributes,element:!1};return i.indexOf(e.value)>-1&&u(e),a.push(e),r.push(e),e}var a=[],r=[];if("function"==typeof t&&(t=t(e)),Array.isArray(t))t.forEach(function(e){var t;"object"===(void 0===e?"undefined":_typeof(e))?e.options?(t={label:e.label,group:!0,itemParams:e.itemParams,elementAttributes:e.elementAttributes,element:!1},r.push(t),e.options.forEach(function(e){n(e)})):n(e):(t={label:e,value:e,element:!1},i.indexOf(t.value)>-1&&u(t),a.push(t),r.push(t))});else for(var s in t){var d={label:t[s],value:s,element:!1};i.indexOf(d.value)>-1&&u(d),a.push(d),r.push(d)}o.sortValuesList&&(a.sort(function(e,t){return e.label<t.label?-1:e.label>t.label?1:0}),r.sort(function(e,t){return e.label<t.label?-1:e.label>t.label?1:0}),"asc"!==o.sortValuesList&&(a.reverse(),r.reverse())),N=a,M=r,l()}function l(){for(;I.firstChild;)I.removeChild(I.firstChild);M.forEach(function(t){var i=t.element;if(!i){if(i=document.createElement("div"),t.label=o.listItemFormatter?o.listItemFormatter(t.value,t.label,e,i,t.itemParams):t.label,t.group?(i.classList.add("tabulator-edit-select-list-group"),i.tabIndex=0,i.innerHTML=""===t.label?" ":t.label):(i.classList.add("tabulator-edit-select-list-item"),i.tabIndex=0,i.innerHTML=""===t.label?" ":t.label,i.addEventListener("click",function(){j=!0,setTimeout(function(){j=!1},10),T?(c(t),P.focus()):m(t)}),V.indexOf(t)>-1&&i.classList.add("active")),t.elementAttributes&&"object"==_typeof(t.elementAttributes))for(var n in t.elementAttributes)"+"==n.charAt(0)?(n=n.slice(1),i.setAttribute(n,P.getAttribute(n)+t.elementAttributes["+"+n])):i.setAttribute(n,t.elementAttributes[n]);i.addEventListener("mousedown",function(){O=!1,setTimeout(function(){O=!0},10)}),t.element=i}I.appendChild(i)})}function s(e,t){!T&&S&&S.element&&S.element.classList.remove("active"),S&&S.element&&S.element.classList.remove("focused"),S=e,e.element&&(e.element.classList.add("focused"),t&&e.element.classList.add("active")),e&&e.element&&e.element.scrollIntoView&&e.element.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}function u(e){-1==V.indexOf(e)&&(V.push(e),s(e,!0)),p()}function d(e){var t=V[e];e>-1&&(V.splice(e,1),t.element&&t.element.classList.remove("active"))}function c(e){e||(e=S);var t=V.indexOf(e);t>-1?d(t):(!0!==T&&V.length>=T&&d(0),u(e)),p()}function m(e){g(),e||(e=S),e&&(P.value=e.label,i(e.value)),x=[e.value]}function f(e){e||g();var t=[];V.forEach(function(e){t.push(e.value)}),x=t,i(t)}function p(){var e=[];V.forEach(function(t){e.push(t.label)}),P.value=e.join(", "),!1===A.currentCell&&f(!0)}function b(){for(var e=V.length,t=0;t<e;t++)d(0)}function v(){g(),n()}function h(){if(V=[],!I.parentNode){!0===o.values?r(a(),x):"string"==typeof o.values?r(a(o.values),x):r(o.values||[],x);var e=Tabulator.prototype.helpers.elOffset(C);I.style.minWidth=C.offsetWidth+"px",I.style.top=e.top+C.offsetHeight+"px",I.style.left=e.left+"px",I.addEventListener("mousedown",function(e){O=!1,setTimeout(function(){O=!0},10)}),document.body.appendChild(I)}}function g(){I.parentNode&&I.parentNode.removeChild(I),y()}function y(){A.table.rowManager.element.removeEventListener("scroll",v)}function E(e){clearTimeout(H);var t=String.fromCharCode(event.keyCode).toLowerCase();F+=t.toLowerCase();var i=N.find(function(e){return void 0!==e.label&&e.label.toLowerCase().startsWith(F)});i&&s(i,!T),H=setTimeout(function(){F=""},800)}var k=this,A=this,C=e.getElement(),L=e.getValue(),w=o.verticalNavigation||"editor",x=void 0!==L||null===L?Array.isArray(L)?L:[L]:void 0!==o.defaultValue?o.defaultValue:[],P=document.createElement("input"),I=document.createElement("div"),T=o.multiselect,N=[],S={},M=[],V=[],O=!0,j=!1,F="",H=null;if((Array.isArray(o)||!Array.isArray(o)&&"object"===(void 0===o?"undefined":_typeof(o))&&!o.values)&&(console.warn("DEPRECATION WARNING - values for the select editor must now be passed into the values property of the editorParams object, not as the editorParams object"),o={values:o}),P.setAttribute("type","text"),P.style.padding="4px",P.style.width="100%",P.style.boxSizing="border-box",P.style.cursor="default",P.readOnly=0!=this.currentCell,o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var W in o.elementAttributes)"+"==W.charAt(0)?(W=W.slice(1),P.setAttribute(W,P.getAttribute(W)+o.elementAttributes["+"+W])):P.setAttribute(W,o.elementAttributes[W]);return P.value=void 0!==L||null===L?L:"",P.addEventListener("search",function(e){P.value||(b(),f())}),P.addEventListener("keydown",function(e){var t;switch(e.keyCode){case 38:t=N.indexOf(S),("editor"==w||"hybrid"==w&&t)&&(e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),t>0&&s(N[t-1],!T));break;case 40:t=N.indexOf(S),("editor"==w||"hybrid"==w&&t<N.length-1)&&(e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),t<N.length-1&&(-1==t?s(N[0],!T):s(N[t+1],!T)));break;case 37:case 39:e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault();break;case 13:T?c():m();break;case 27:v();break;case 9:break;default:!1===A.currentCell&&e.preventDefault(),e.keyCode>=38&&e.keyCode<=90&&E(e.keyCode)}}),P.addEventListener("blur",function(e){O&&(T?f():v())}),P.addEventListener("focus",function(e){j||h()}),I=document.createElement("div"),I.classList.add("tabulator-edit-select-list"),t(function(){P.style.height="100%",P.focus({preventScroll:!0})}),setTimeout(function(){k.table.rowManager.element.addEventListener("scroll",v)},10),P},autocomplete:function(e,t,i,n,o){function a(){!0===o.values?N=r():"string"==typeof o.values&&(N=r(o.values))}function r(t){var i,n={},a=E.table.getData();return i=t?E.table.columnManager.getColumnByField(t):e.getColumn()._getSelf(),i?(a.forEach(function(e){var t=i.getFieldValue(e);null!==t&&void 0!==t&&""!==t&&(n[t]=!0)}),n=o.sortValuesList?"asc"==o.sortValuesList?Object.keys(n).sort():Object.keys(n).sort().reverse():Object.keys(n)):console.warn("unable to find matching column to create autocomplete lookup list:",t),n}function l(e,t){var i,n,a=[];i=N||(o.values||[]),o.searchFunc?(a=o.searchFunc(e,i),a instanceof Promise?(s(void 0!==o.searchingPlaceholder?o.searchingPlaceholder:"Searching..."),a.then(function(e){c(u(e),t)}).catch(function(e){console.err("error in autocomplete search promise:",e)})):c(u(a),t)):(n=u(i),""===e?o.showListOnEmpty&&(a=n):n.forEach(function(t){null===t.value&&void 0===t.value||(String(t.value).toLowerCase().indexOf(String(e).toLowerCase())>-1||String(t.title).toLowerCase().indexOf(String(e).toLowerCase())>-1)&&a.push(t)}),c(a,t))}function s(e){var t=document.createElement("div");d(),!1!==e&&(t.classList.add("tabulator-edit-select-list-notice"),t.tabIndex=0,e instanceof Node?t.appendChild(e):t.innerHTML=e,x.appendChild(t))}function u(e){var t=[];if(Array.isArray(e))e.forEach(function(e){var i={};"object"===(void 0===e?"undefined":_typeof(e))?(i.title=o.listItemFormatter?o.listItemFormatter(e.value,e.label):e.label,i.value=e.value):(i.title=o.listItemFormatter?o.listItemFormatter(e,e):e,i.value=e),t.push(i)});else for(var i in e){var n={title:o.listItemFormatter?o.listItemFormatter(i,e[i]):e[i],value:i};t.push(n)}return t}function d(){for(;x.firstChild;)x.removeChild(x.firstChild)}function c(e,t){e.length?m(e,t):o.emptyPlaceholder&&s(o.emptyPlaceholder)}function m(e,t){var i=!1;d(),P=e,P.forEach(function(e){var n=e.element;n||(n=document.createElement("div"),n.classList.add("tabulator-edit-select-list-item"),n.tabIndex=0,n.innerHTML=e.title,n.addEventListener("click",function(t){b(e),f()}),n.addEventListener("mousedown",function(e){T=!1,setTimeout(function(){T=!0},10)}),e.element=n,t&&e.value==A&&(w.value=e.title,e.element.classList.add("active"),i=!0),e===I&&(e.element.classList.add("active"),i=!0)),x.appendChild(n)}),i||b(!1)}function f(){v(),I?A!==I.value?(A=I.value,w.value=I.title,i(I.value)):n():o.freetext?(A=w.value,i(w.value)):o.allowEmpty&&""===w.value?(A=w.value,i(w.value)):n()}function p(){if(!x.parentNode){for(console.log("show",L);x.firstChild;)x.removeChild(x.firstChild);var e=Tabulator.prototype.helpers.elOffset(k);x.style.minWidth=k.offsetWidth+"px",x.style.top=e.top+k.offsetHeight+"px",x.style.left=e.left+"px",document.body.appendChild(x)}}function b(e,t){I&&I.element&&I.element.classList.remove("active"),I=e,e&&e.element&&e.element.classList.add("active"),e&&e.element&&e.element.scrollIntoView&&e.element.scrollIntoView({behavior:"smooth",block:"nearest",inline:"start"})}function v(){x.parentNode&&x.parentNode.removeChild(x),g()}function h(){v(),n()}function g(){E.table.rowManager.element.removeEventListener("scroll",h)}var y=this,E=this,k=e.getElement(),A=e.getValue(),C=o.verticalNavigation||"editor",L=void 0!==A||null===A?A:void 0!==o.defaultValue?o.defaultValue:"",w=document.createElement("input"),x=document.createElement("div"),P=[],I=!1,T=!0,N=!1;if(w.setAttribute("type","search"),w.style.padding="4px",w.style.width="100%",w.style.boxSizing="border-box",o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var S in o.elementAttributes)"+"==S.charAt(0)?(S=S.slice(1),w.setAttribute(S,w.getAttribute(S)+o.elementAttributes["+"+S])):w.setAttribute(S,o.elementAttributes[S]);return x.classList.add("tabulator-edit-select-list"),x.addEventListener("mousedown",function(e){T=!1,setTimeout(function(){T=!0},10)}),w.addEventListener("keydown",function(e){var t;switch(e.keyCode){case 38:t=P.indexOf(I),("editor"==C||"hybrid"==C&&t)&&(e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),b(t>0?P[t-1]:!1));break;case 40:t=P.indexOf(I),("editor"==C||"hybrid"==C&&t<P.length-1)&&(e.stopImmediatePropagation(),e.stopPropagation(),e.preventDefault(),t<P.length-1&&b(-1==t?P[0]:P[t+1]));break;case 37:case 39:e.stopImmediatePropagation(),e.stopPropagation();break;case 13:f();break;case 27:h();break;case 36:case 35:e.stopImmediatePropagation()}}),w.addEventListener("keyup",function(e){switch(e.keyCode){case 38:case 37:case 39:case 40:case 13:case 27:break;default:l(w.value)}}),w.addEventListener("search",function(e){l(w.value)}),w.addEventListener("blur",function(e){T&&f()}),w.addEventListener("focus",function(e){var t=L;a(),p(),w.value=t,l(t,!0)}),t(function(){w.style.height="100%",w.focus({preventScroll:!0})}),o.mask&&this.table.modules.edit.maskInput(w,o),setTimeout(function(){y.table.rowManager.element.addEventListener("scroll",h)},10),a(),w.value=L,l(L,!0),w},star:function(e,t,i,n,o){function a(e){m.forEach(function(t,i){i<e?("ie"==l.table.browser?t.setAttribute("class","tabulator-star-active"):t.classList.replace("tabulator-star-inactive","tabulator-star-active"),t.innerHTML='<polygon fill="#488CE9" stroke="#014AAE" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>'):("ie"==l.table.browser?t.setAttribute("class","tabulator-star-inactive"):t.classList.replace("tabulator-star-active","tabulator-star-inactive"),t.innerHTML='<polygon fill="#010155" stroke="#686868" stroke-width="37.6152" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="10" points="259.216,29.942 330.27,173.919 489.16,197.007 374.185,309.08 401.33,467.31 259.216,392.612 117.104,467.31 144.25,309.08 29.274,197.007 188.165,173.919 "/>')})}function r(e){u=e,a(e)}var l=this,s=e.getElement(),u=e.getValue(),d=s.getElementsByTagName("svg").length||5,c=s.getElementsByTagName("svg")[0]?s.getElementsByTagName("svg")[0].getAttribute("width"):14,m=[],f=document.createElement("div"),p=document.createElementNS("http://www.w3.org/2000/svg","svg");if(s.style.whiteSpace="nowrap",s.style.overflow="hidden",s.style.textOverflow="ellipsis",f.style.verticalAlign="middle",f.style.display="inline-block",f.style.padding="4px",p.setAttribute("width",c),p.setAttribute("height",c),p.setAttribute("viewBox","0 0 512 512"),p.setAttribute("xml:space","preserve"),p.style.padding="0 1px",o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var b in o.elementAttributes)"+"==b.charAt(0)?(b=b.slice(1),f.setAttribute(b,f.getAttribute(b)+o.elementAttributes["+"+b])):f.setAttribute(b,o.elementAttributes[b]);for(var v=1;v<=d;v++)!function(e){var t=document.createElement("span"),n=p.cloneNode(!0);m.push(n),t.addEventListener("mouseenter",function(t){t.stopPropagation(),t.stopImmediatePropagation(),a(e)}),t.addEventListener("mousemove",function(e){e.stopPropagation(),e.stopImmediatePropagation()}),t.addEventListener("click",function(t){t.stopPropagation(),t.stopImmediatePropagation(),i(e),s.blur()}),t.appendChild(n),f.appendChild(t)}(v);return u=Math.min(parseInt(u),d),a(u),f.addEventListener("mousemove",function(e){a(0)}),f.addEventListener("click",function(e){i(0)}),s.addEventListener("blur",function(e){n()}),s.addEventListener("keydown",function(e){switch(e.keyCode){case 39:r(u+1);break;case 37:r(u-1);break;case 13:i(u);break;case 27:n()}}),f},progress:function(e,t,i,n,o){function a(){var e=window.getComputedStyle(s,null),t=c*Math.round(p.offsetWidth/((s.clientWidth-parseInt(e.getPropertyValue("padding-left"))-parseInt(e.getPropertyValue("padding-right")))/100))+d;i(t),s.setAttribute("aria-valuenow",t),s.setAttribute("aria-label",m)}var r,l,s=e.getElement(),u=void 0===o.max?s.getElementsByTagName("div")[0].getAttribute("max")||100:o.max,d=void 0===o.min?s.getElementsByTagName("div")[0].getAttribute("min")||0:o.min,c=(u-d)/100,m=e.getValue()||0,f=document.createElement("div"),p=document.createElement("div");if(f.style.position="absolute",f.style.right="0",f.style.top="0",f.style.bottom="0",f.style.width="5px",f.classList.add("tabulator-progress-handle"),p.style.display="inline-block",p.style.position="relative",p.style.height="100%",p.style.backgroundColor="#488CE9",p.style.maxWidth="100%",p.style.minWidth="0%",o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var b in o.elementAttributes)"+"==b.charAt(0)?(b=b.slice(1),p.setAttribute(b,p.getAttribute(b)+o.elementAttributes["+"+b])):p.setAttribute(b,o.elementAttributes[b]);return s.style.padding="4px 4px",m=Math.min(parseFloat(m),u),m=Math.max(parseFloat(m),d),m=Math.round((m-d)/c),p.style.width=m+"%",s.setAttribute("aria-valuemin",d),s.setAttribute("aria-valuemax",u),p.appendChild(f),f.addEventListener("mousedown",function(e){r=e.screenX,l=p.offsetWidth}),f.addEventListener("mouseover",function(){f.style.cursor="ew-resize"}),s.addEventListener("mousemove",function(e){r&&(p.style.width=l+e.screenX-r+"px")}),s.addEventListener("mouseup",function(e){r&&(e.stopPropagation(),e.stopImmediatePropagation(),r=!1,l=!1,a())}),s.addEventListener("keydown",function(e){switch(e.keyCode){case 39:e.preventDefault(),p.style.width=p.clientWidth+s.clientWidth/100+"px";break;case 37:e.preventDefault(),p.style.width=p.clientWidth-s.clientWidth/100+"px";break;case 9:case 13:a();break;case 27:n()}}),s.addEventListener("blur",function(){n()}),p},tickCross:function(e,t,i,n,o){function a(e){return s?e?d?u:l.checked:l.checked&&!d?(l.checked=!1,l.indeterminate=!0,d=!0,u):(d=!1,l.checked):l.checked}var r=e.getValue(),l=document.createElement("input"),s=o.tristate,u=void 0===o.indeterminateValue?null:o.indeterminateValue,d=!1;if(l.setAttribute("type","checkbox"),l.style.marginTop="5px",l.style.boxSizing="border-box",o.elementAttributes&&"object"==_typeof(o.elementAttributes))for(var c in o.elementAttributes)"+"==c.charAt(0)?(c=c.slice(1),l.setAttribute(c,l.getAttribute(c)+o.elementAttributes["+"+c])):l.setAttribute(c,o.elementAttributes[c]);return l.value=r,!s||void 0!==r&&r!==u&&""!==r||(d=!0,l.indeterminate=!0),"firefox"!=this.table.browser&&t(function(){l.focus({preventScroll:!0})}),l.checked=!0===r||"true"===r||"True"===r||1===r,t(function(){l.focus()}),l.addEventListener("change",function(e){i(a())}),l.addEventListener("blur",function(e){i(a(!0))}),l.addEventListener("keydown",function(e){13==e.keyCode&&i(a()),27==e.keyCode&&n()}),l}},Tabulator.prototype.registerModule("edit",Edit);