katoikia-app/web-ui/web-react/node_modules/primereact/treetable/treetable.esm.min.js

2 lines
77 KiB
JavaScript

import e,{Component as t}from"react";import{localeOption as n,FilterService as o}from"primereact/api";import{DomHandler as r,classNames as i,ObjectUtils as l}from"primereact/utils";import{Paginator as s}from"primereact/paginator";import{InputText as a}from"primereact/inputtext";import{OverlayService as p}from"primereact/overlayservice";import{Ripple as c}from"primereact/ripple";function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function d(e){if(Array.isArray(e))return u(e)}function h(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function f(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function y(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function g(e){return d(e)||h(e)||f(e)||y()}function m(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function v(e,t){for(var n=0;n<t.length;n++){var o=t[n];o.enumerable=o.enumerable||!1,o.configurable=!0,"value"in o&&(o.writable=!0),Object.defineProperty(e,o.key,o)}}function b(e,t,n){return t&&v(e.prototype,t),n&&v(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function C(e){if(void 0===e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function k(e,t){return k=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e},k(e,t)}function S(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),Object.defineProperty(e,"prototype",{writable:!1}),t&&k(e,t)}function w(e){return w="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},w(e)}function x(e,t){if(t&&("object"===w(t)||"function"==typeof t))return t;if(void 0!==t)throw new TypeError("Derived constructors may only return object or undefined");return C(e)}function E(e){return E=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)},E(e)}function O(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function M(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=F(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw i}}}}function F(e,t){if(e){if("string"==typeof e)return R(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?R(e,t):void 0}}function R(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function T(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var D=function(n){S(p,t);var o,l,s=(o=p,l=T(),function(){var e,t=E(o);if(l){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return x(this,e)});function p(e){var t;return m(this,p),(t=s.call(this,e)).state={badgeVisible:!1},t.onFilterInput=t.onFilterInput.bind(C(t)),t}return b(p,[{key:"onHeaderClick",value:function(e,t){if(t.props.sortable){var n=e.target;(r.hasClass(n,"p-sortable-column")||r.hasClass(n,"p-column-title")||r.hasClass(n,"p-sortable-column-icon")||r.hasClass(n.parentElement,"p-sortable-column-icon"))&&(this.props.onSort({originalEvent:e,sortField:t.props.sortField||t.props.field,sortFunction:t.props.sortFunction,sortable:t.props.sortable}),r.clearSelection())}}},{key:"onHeaderMouseDown",value:function(e,t){this.props.reorderableColumns&&t.props.reorderable&&("INPUT"!==e.target.nodeName?e.currentTarget.draggable=!0:"INPUT"===e.target.nodeName&&(e.currentTarget.draggable=!1))}},{key:"onHeaderKeyDown",value:function(e,t){"Enter"===e.key&&(this.onHeaderClick(e,t),e.preventDefault())}},{key:"getMultiSortMetaDataIndex",value:function(e){if(this.props.multiSortMeta)for(var t=0;t<this.props.multiSortMeta.length;t++)if(this.props.multiSortMeta[t].field===e.props.field)return t;return-1}},{key:"onResizerMouseDown",value:function(e,t){this.props.resizableColumns&&this.props.onResizeStart&&this.props.onResizeStart({originalEvent:e,columnEl:e.target.parentElement,column:t})}},{key:"onDragStart",value:function(e,t){this.props.onDragStart&&this.props.onDragStart({originalEvent:e,column:t})}},{key:"onDragOver",value:function(e,t){this.props.onDragOver&&this.props.onDragOver({originalEvent:e,column:t})}},{key:"onDragLeave",value:function(e,t){this.props.onDragLeave&&this.props.onDragLeave({originalEvent:e,column:t})}},{key:"onDrop",value:function(e,t){this.props.onDrop&&this.props.onDrop({originalEvent:e,column:t})}},{key:"onFilterInput",value:function(e,t){var n=this;if(t.props.filter&&this.props.onFilter){this.filterTimeout&&clearTimeout(this.filterTimeout);var o=e.target.value;this.filterTimeout=setTimeout((function(){n.props.onFilter({value:o,field:t.props.field,matchMode:t.props.filterMatchMode||"startsWith"}),n.filterTimeout=null}),this.props.filterDelay)}}},{key:"hasColumnFilter",value:function(e){if(e){var t,n=M(e);try{for(n.s();!(t=n.n()).done;){if(t.value.props.filter)return!0}}catch(e){n.e(e)}finally{n.f()}}return!1}},{key:"renderSortIcon",value:function(t,n,o){if(t.props.sortable){var r=i("p-sortable-column-icon","pi pi-fw",n?o<0?"pi-sort-amount-down":"pi-sort-amount-up-alt":"pi-sort-alt");return e.createElement("span",{className:r})}return null}},{key:"renderResizer",value:function(t){var n=this;return this.props.resizableColumns?e.createElement("span",{className:"p-column-resizer p-clickable",onMouseDown:function(e){return n.onResizerMouseDown(e,t)}}):null}},{key:"getAriaSort",value:function(e,t,n){if(e.props.sortable){var o=t?n<0?"pi-sort-down":"pi-sort-up":"pi-sort";return"pi-sort-down"===o?"descending":"pi-sort-up"===o?"ascending":"none"}return null}},{key:"renderSortBadge",value:function(t){return-1!==t&&this.state.badgeVisible?e.createElement("span",{className:"p-sortable-column-badge"},t+1):null}},{key:"renderHeaderCell",value:function(t,n){var o,r=this;if(t.props.filter&&n.renderFilter&&(o=t.props.filterElement||e.createElement(a,{onInput:function(e){return r.onFilterInput(e,t)},type:this.props.filterType,defaultValue:this.props.filters&&this.props.filters[t.props.field]?this.props.filters[t.props.field].value:null,className:"p-column-filter",placeholder:t.props.filterPlaceholder,maxLength:t.props.filterMaxLength})),n.filterOnly)return e.createElement("th",{key:t.props.columnKey||t.props.field||n.index,className:i("p-filter-column",t.props.filterHeaderClassName),style:t.props.filterHeaderStyle||t.props.style,rowSpan:t.props.rowSpan,colSpan:t.props.colSpan},o);var l=this.getMultiSortMetaDataIndex(t),s=-1!==l?this.props.multiSortMeta[l]:null,p=t.props.field===this.props.sortField,c=null!==s,u=t.props.sortable&&(p||c),d=0;p?d=this.props.sortOrder:c&&(d=s.order);var h=this.renderSortIcon(t,u,d),f=this.getAriaSort(t,u,d),y=this.renderSortBadge(l),g=i(t.props.headerClassName||t.props.className,{"p-sortable-column":t.props.sortable,"p-highlight":u,"p-resizable-column":this.props.resizableColumns}),m=this.renderResizer(t);return e.createElement("th",{key:t.columnKey||t.field||n.index,className:g,style:t.props.headerStyle||t.props.style,tabIndex:t.props.sortable?this.props.tabIndex:null,onClick:function(e){return r.onHeaderClick(e,t)},onMouseDown:function(e){return r.onHeaderMouseDown(e,t)},onKeyDown:function(e){return r.onHeaderKeyDown(e,t)},rowSpan:t.props.rowSpan,colSpan:t.props.colSpan,"aria-sort":f,onDragStart:function(e){return r.onDragStart(e,t)},onDragOver:function(e){return r.onDragOver(e,t)},onDragLeave:function(e){return r.onDragLeave(e,t)},onDrop:function(e){return r.onDrop(e,t)}},m,e.createElement("span",{className:"p-column-title"},t.props.header),h,y,o)}},{key:"renderHeaderRow",value:function(t,n){var o=this,r=e.Children.toArray(t.props.children).map((function(e,t){return o.renderHeaderCell(e,{index:t,filterOnly:!1,renderFilter:!0})}));return e.createElement("tr",{key:n},r)}},{key:"renderColumnGroup",value:function(){var t=this;return e.Children.toArray(this.props.columnGroup.props.children).map((function(e,n){return t.renderHeaderRow(e,n)}))}},{key:"renderColumns",value:function(t){var n=this;return t?this.hasColumnFilter(t)?e.createElement(e.Fragment,null,e.createElement("tr",null,t.map((function(e,t){return n.renderHeaderCell(e,{index:t,filterOnly:!1,renderFilter:!1})}))),e.createElement("tr",null,t.map((function(e,t){return n.renderHeaderCell(e,{index:t,filterOnly:!0,renderFilter:!0})})))):e.createElement("tr",null,t.map((function(e,t){return n.renderHeaderCell(e,{index:t,filterOnly:!1,renderFilter:!1})}))):null}},{key:"render",value:function(){var t=this.props.columnGroup?this.renderColumnGroup():this.renderColumns(this.props.columns);return e.createElement("thead",{className:"p-treetable-thead"},t)}}],[{key:"getDerivedStateFromProps",value:function(e,t){return{badgeVisible:e.multiSortMeta&&e.multiSortMeta.length>1}}}]),p}();function P(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=N(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw i}}}}function N(e,t){if(e){if("string"==typeof e)return z(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?z(e,t):void 0}}function z(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}var H=function(){function e(){m(this,e)}return b(e,null,[{key:"innerWidth",value:function(e){if(e){var t=e.offsetWidth,n=getComputedStyle(e);return t+=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight)}return 0}},{key:"width",value:function(e){if(e){var t=e.offsetWidth,n=getComputedStyle(e);return t-=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight),t}return 0}},{key:"getWindowScrollTop",value:function(){var e=document.documentElement;return(window.pageYOffset||e.scrollTop)-(e.clientTop||0)}},{key:"getWindowScrollLeft",value:function(){var e=document.documentElement;return(window.pageXOffset||e.scrollLeft)-(e.clientLeft||0)}},{key:"getOuterWidth",value:function(e,t){if(e){var n=e.offsetWidth||e.getBoundingClientRect().width;if(t){var o=getComputedStyle(e);n+=parseFloat(o.marginLeft)+parseFloat(o.marginRight)}return n}return 0}},{key:"getOuterHeight",value:function(e,t){if(e){var n=e.offsetHeight||e.getBoundingClientRect().height;if(t){var o=getComputedStyle(e);n+=parseFloat(o.marginTop)+parseFloat(o.marginBottom)}return n}return 0}},{key:"getClientHeight",value:function(e,t){if(e){var n=e.clientHeight;if(t){var o=getComputedStyle(e);n+=parseFloat(o.marginTop)+parseFloat(o.marginBottom)}return n}return 0}},{key:"getClientWidth",value:function(e,t){if(e){var n=e.clientWidth;if(t){var o=getComputedStyle(e);n+=parseFloat(o.marginLeft)+parseFloat(o.marginRight)}return n}return 0}},{key:"getViewport",value:function(){var e=window,t=document,n=t.documentElement,o=t.getElementsByTagName("body")[0];return{width:e.innerWidth||n.clientWidth||o.clientWidth,height:e.innerHeight||n.clientHeight||o.clientHeight}}},{key:"getOffset",value:function(e){if(e){var t=e.getBoundingClientRect();return{top:t.top+(window.pageYOffset||document.documentElement.scrollTop||document.body.scrollTop||0),left:t.left+(window.pageXOffset||document.documentElement.scrollLeft||document.body.scrollLeft||0)}}return{top:"auto",left:"auto"}}},{key:"index",value:function(e){if(e)for(var t=e.parentNode.childNodes,n=0,o=0;o<t.length;o++){if(t[o]===e)return n;1===t[o].nodeType&&n++}return-1}},{key:"addMultipleClasses",value:function(e,t){if(e&&t)if(e.classList)for(var n=t.split(" "),o=0;o<n.length;o++)e.classList.add(n[o]);else for(var r=t.split(" "),i=0;i<r.length;i++)e.className+=" "+r[i]}},{key:"removeMultipleClasses",value:function(e,t){if(e&&t)if(e.classList)for(var n=t.split(" "),o=0;o<n.length;o++)e.classList.remove(n[o]);else for(var r=t.split(" "),i=0;i<r.length;i++)e.className=e.className.replace(new RegExp("(^|\\b)"+r[i].split(" ").join("|")+"(\\b|$)","gi")," ")}},{key:"addClass",value:function(e,t){e&&t&&(e.classList?e.classList.add(t):e.className+=" "+t)}},{key:"removeClass",value:function(e,t){e&&t&&(e.classList?e.classList.remove(t):e.className=e.className.replace(new RegExp("(^|\\b)"+t.split(" ").join("|")+"(\\b|$)","gi")," "))}},{key:"hasClass",value:function(e,t){if(e)return e.classList?e.classList.contains(t):new RegExp("(^| )"+t+"( |$)","gi").test(e.className)}},{key:"find",value:function(e,t){return e?Array.from(e.querySelectorAll(t)):[]}},{key:"findSingle",value:function(e,t){return e?e.querySelector(t):null}},{key:"getHeight",value:function(e){if(e){var t=e.offsetHeight,n=getComputedStyle(e);return t-=parseFloat(n.paddingTop)+parseFloat(n.paddingBottom)+parseFloat(n.borderTopWidth)+parseFloat(n.borderBottomWidth)}return 0}},{key:"getWidth",value:function(e){if(e){var t=e.offsetWidth,n=getComputedStyle(e);return t-=parseFloat(n.paddingLeft)+parseFloat(n.paddingRight)+parseFloat(n.borderLeftWidth)+parseFloat(n.borderRightWidth)}return 0}},{key:"alignOverlay",value:function(t,n,o){var r=!(arguments.length>3&&void 0!==arguments[3])||arguments[3];t&&n&&("self"===o?this.relativePosition(t,n):(r&&(t.style.minWidth=e.getOuterWidth(n)+"px"),this.absolutePosition(t,n)))}},{key:"absolutePosition",value:function(e,t){if(e){var n,o,r=e.offsetParent?{width:e.offsetWidth,height:e.offsetHeight}:this.getHiddenElementDimensions(e),i=r.height,l=r.width,s=t.offsetHeight,a=t.offsetWidth,p=t.getBoundingClientRect(),c=this.getWindowScrollTop(),u=this.getWindowScrollLeft(),d=this.getViewport();p.top+s+i>d.height?((n=p.top+c-i)<0&&(n=c),e.style.transformOrigin="bottom"):(n=s+p.top+c,e.style.transformOrigin="top"),o=p.left+a+l>d.width?Math.max(0,p.left+u+a-l):p.left+u,e.style.top=n+"px",e.style.left=o+"px"}}},{key:"relativePosition",value:function(e,t){if(e){var n,o,r=e.offsetParent?{width:e.offsetWidth,height:e.offsetHeight}:this.getHiddenElementDimensions(e),i=t.offsetHeight,l=t.getBoundingClientRect(),s=this.getViewport();l.top+i+r.height>s.height?(l.top+(n=-1*r.height)<0&&(n=-1*l.top),e.style.transformOrigin="bottom"):(n=i,e.style.transformOrigin="top"),o=r.width>s.width?-1*l.left:l.left+r.width>s.width?-1*(l.left+r.width-s.width):0,e.style.top=n+"px",e.style.left=o+"px"}}},{key:"flipfitCollision",value:function(t,n){var o=this,r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"left top",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:"left bottom",l=arguments.length>4?arguments[4]:void 0,s=n.getBoundingClientRect(),a=this.getViewport(),p=r.split(" "),c=i.split(" "),u=function(e,t){return t?+e.substring(e.search(/(\+|-)/g))||0:e.substring(0,e.search(/(\+|-)/g))||e},d={my:{x:u(p[0]),y:u(p[1]||p[0]),offsetX:u(p[0],!0),offsetY:u(p[1]||p[0],!0)},at:{x:u(c[0]),y:u(c[1]||c[0]),offsetX:u(c[0],!0),offsetY:u(c[1]||c[0],!0)}},h={left:function(){return d.my.offsetX+d.at.offsetX+s.left+("left"===d.my.x?0:-1*("center"===d.my.x?o.getOuterWidth(t)/2:o.getOuterWidth(t)))},top:function(){return d.my.offsetY+d.at.offsetY+s.top+("top"===d.my.y?0:-1*("center"===d.my.y?o.getOuterHeight(t)/2:o.getOuterHeight(t)))}},f={count:{x:0,y:0},left:function(){var n=h.left(),o=e.getWindowScrollLeft();t.style.left=n+o+"px",2===this.count.x?(t.style.left=o+"px",this.count.x=0):n<0&&(this.count.x++,d.my.x="left",d.at.x="right",d.my.offsetX*=-1,d.at.offsetX*=-1,this.right())},right:function(){var o=h.left()+e.getOuterWidth(n),r=e.getWindowScrollLeft();t.style.left=o+r+"px",2===this.count.x?(t.style.left=a.width-e.getOuterWidth(t)+r+"px",this.count.x=0):o+e.getOuterWidth(t)>a.width&&(this.count.x++,d.my.x="right",d.at.x="left",d.my.offsetX*=-1,d.at.offsetX*=-1,this.left())},top:function(){var n=h.top(),o=e.getWindowScrollTop();t.style.top=n+o+"px",2===this.count.y?(t.style.left=o+"px",this.count.y=0):n<0&&(this.count.y++,d.my.y="top",d.at.y="bottom",d.my.offsetY*=-1,d.at.offsetY*=-1,this.bottom())},bottom:function(){var o=h.top()+e.getOuterHeight(n),r=e.getWindowScrollTop();t.style.top=o+r+"px",2===this.count.y?(t.style.left=a.height-e.getOuterHeight(t)+r+"px",this.count.y=0):o+e.getOuterHeight(n)>a.height&&(this.count.y++,d.my.y="bottom",d.at.y="top",d.my.offsetY*=-1,d.at.offsetY*=-1,this.top())},center:function(o){if("y"===o){var r=h.top()+e.getOuterHeight(n)/2;t.style.top=r+e.getWindowScrollTop()+"px",r<0?this.bottom():r+e.getOuterHeight(n)>a.height&&this.top()}else{var i=h.left()+e.getOuterWidth(n)/2;t.style.left=i+e.getWindowScrollLeft()+"px",i<0?this.left():i+e.getOuterWidth(t)>a.width&&this.right()}}};f[d.at.x]("x"),f[d.at.y]("y"),this.isFunction(l)&&l(d)}},{key:"findCollisionPosition",value:function(e){if(e){var t="left"===e?"right":"left";return"top"===e||"bottom"===e?{axis:"y",my:"center ".concat("top"===e?"bottom":"top"),at:"center ".concat(e)}:{axis:"x",my:"".concat(t," center"),at:"".concat(e," center")}}}},{key:"getParents",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:[];return null===e.parentNode?t:this.getParents(e.parentNode,t.concat([e.parentNode]))}},{key:"getScrollableParents",value:function(e){var t=[];if(e){var n,o=this.getParents(e),r=/(auto|scroll)/,i=function(e){var t=e?getComputedStyle(e):null;return t&&(r.test(t.getPropertyValue("overflow"))||r.test(t.getPropertyValue("overflowX"))||r.test(t.getPropertyValue("overflowY")))},l=P(o);try{for(l.s();!(n=l.n()).done;){var s=n.value,a=1===s.nodeType&&s.dataset.scrollselectors;if(a){var p,c=P(a.split(","));try{for(c.s();!(p=c.n()).done;){var u=this.findSingle(s,p.value);u&&i(u)&&t.push(u)}}catch(e){c.e(e)}finally{c.f()}}9!==s.nodeType&&i(s)&&t.push(s)}}catch(e){l.e(e)}finally{l.f()}}return t}},{key:"getHiddenElementOuterHeight",value:function(e){if(e){e.style.visibility="hidden",e.style.display="block";var t=e.offsetHeight;return e.style.display="none",e.style.visibility="visible",t}return 0}},{key:"getHiddenElementOuterWidth",value:function(e){if(e){e.style.visibility="hidden",e.style.display="block";var t=e.offsetWidth;return e.style.display="none",e.style.visibility="visible",t}return 0}},{key:"getHiddenElementDimensions",value:function(e){var t={};return e&&(e.style.visibility="hidden",e.style.display="block",t.width=e.offsetWidth,t.height=e.offsetHeight,e.style.display="none",e.style.visibility="visible"),t}},{key:"fadeIn",value:function(e,t){if(e){e.style.opacity=0;var n=+new Date,o=0;!function r(){o=+e.style.opacity+((new Date).getTime()-n)/t,e.style.opacity=o,n=+new Date,+o<1&&(window.requestAnimationFrame&&requestAnimationFrame(r)||setTimeout(r,16))}()}}},{key:"fadeOut",value:function(e,t){if(e)var n=1,o=50/t,r=setInterval((function(){(n-=o)<=0&&(n=0,clearInterval(r)),e.style.opacity=n}),50)}},{key:"getUserAgent",value:function(){return navigator.userAgent}},{key:"isIOS",value:function(){return/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream}},{key:"isAndroid",value:function(){return/(android)/i.test(navigator.userAgent)}},{key:"isTouchDevice",value:function(){return"ontouchstart"in window||navigator.maxTouchPoints>0||navigator.msMaxTouchPoints>0}},{key:"isFunction",value:function(e){return!!(e&&e.constructor&&e.call&&e.apply)}},{key:"appendChild",value:function(e,t){if(this.isElement(t))t.appendChild(e);else{if(!t.el||!t.el.nativeElement)throw new Error("Cannot append "+t+" to "+e);t.el.nativeElement.appendChild(e)}}},{key:"removeChild",value:function(e,t){if(this.isElement(t))t.removeChild(e);else{if(!t.el||!t.el.nativeElement)throw new Error("Cannot remove "+e+" from "+t);t.el.nativeElement.removeChild(e)}}},{key:"isElement",value:function(e){return"object"===("undefined"==typeof HTMLElement?"undefined":w(HTMLElement))?e instanceof HTMLElement:e&&"object"===w(e)&&null!==e&&1===e.nodeType&&"string"==typeof e.nodeName}},{key:"scrollInView",value:function(e,t){var n=getComputedStyle(e).getPropertyValue("borderTopWidth"),o=n?parseFloat(n):0,r=getComputedStyle(e).getPropertyValue("paddingTop"),i=r?parseFloat(r):0,l=e.getBoundingClientRect(),s=t.getBoundingClientRect().top+document.body.scrollTop-(l.top+document.body.scrollTop)-o-i,a=e.scrollTop,p=e.clientHeight,c=this.getOuterHeight(t);s<0?e.scrollTop=a+s:s+c>p&&(e.scrollTop=a+s-p+c)}},{key:"clearSelection",value:function(){if(window.getSelection)window.getSelection().empty?window.getSelection().empty():window.getSelection().removeAllRanges&&window.getSelection().rangeCount>0&&window.getSelection().getRangeAt(0).getClientRects().length>0&&window.getSelection().removeAllRanges();else if(document.selection&&document.selection.empty)try{document.selection.empty()}catch(e){}}},{key:"calculateScrollbarWidth",value:function(e){if(e){var t=getComputedStyle(e);return e.offsetWidth-e.clientWidth-parseFloat(t.borderLeftWidth)-parseFloat(t.borderRightWidth)}if(null!=this.calculatedScrollbarWidth)return this.calculatedScrollbarWidth;var n=document.createElement("div");n.className="p-scrollbar-measure",document.body.appendChild(n);var o=n.offsetWidth-n.clientWidth;return document.body.removeChild(n),this.calculatedScrollbarWidth=o,o}},{key:"getBrowser",value:function(){if(!this.browser){var e=this.resolveUserAgent();this.browser={},e.browser&&(this.browser[e.browser]=!0,this.browser.version=e.version),this.browser.chrome?this.browser.webkit=!0:this.browser.webkit&&(this.browser.safari=!0)}return this.browser}},{key:"resolveUserAgent",value:function(){var e=navigator.userAgent.toLowerCase(),t=/(chrome)[ ]([\w.]+)/.exec(e)||/(webkit)[ ]([\w.]+)/.exec(e)||/(opera)(?:.*version|)[ ]([\w.]+)/.exec(e)||/(msie) ([\w.]+)/.exec(e)||e.indexOf("compatible")<0&&/(mozilla)(?:.*? rv:([\w.]+)|)/.exec(e)||[];return{browser:t[1]||"",version:t[2]||"0"}}},{key:"isVisible",value:function(e){return e&&null!=e.offsetParent}},{key:"isExist",value:function(e){return null!=e&&e.nodeName&&e.parentNode}},{key:"hasDOM",value:function(){return!("undefined"==typeof window||!window.document||!window.document.createElement)}},{key:"getFocusableElements",value:function(t){var n,o=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"",r=e.find(t,'button:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])'.concat(o,',\n [href][clientHeight][clientWidth]:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])').concat(o,',\n input:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])').concat(o,',\n select:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])').concat(o,',\n textarea:not([tabindex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])').concat(o,',\n [tabIndex]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])').concat(o,',\n [contenteditable]:not([tabIndex = "-1"]):not([disabled]):not([style*="display:none"]):not([hidden])').concat(o)),i=[],l=P(r);try{for(l.s();!(n=l.n()).done;){var s=n.value;"none"!==getComputedStyle(s).display&&"hidden"!==getComputedStyle(s).visibility&&i.push(s)}}catch(e){l.e(e)}finally{l.f()}return i}},{key:"getFirstFocusableElement",value:function(t,n){var o=e.getFocusableElements(t,n);return o.length>0?o[0]:null}},{key:"getLastFocusableElement",value:function(t,n){var o=e.getFocusableElements(t,n);return o.length>0?o[o.length-1]:null}},{key:"getCursorOffset",value:function(e,t,n,o){if(e){var r=getComputedStyle(e),i=document.createElement("div");i.style.position="absolute",i.style.top="0px",i.style.left="0px",i.style.visibility="hidden",i.style.pointerEvents="none",i.style.overflow=r.overflow,i.style.width=r.width,i.style.height=r.height,i.style.padding=r.padding,i.style.border=r.border,i.style.overflowWrap=r.overflowWrap,i.style.whiteSpace=r.whiteSpace,i.style.lineHeight=r.lineHeight,i.innerHTML=t.replace(/\r\n|\r|\n/g,"<br />");var l=document.createElement("span");l.textContent=o,i.appendChild(l);var s=document.createTextNode(n);i.appendChild(s),document.body.appendChild(i);var a=l.offsetLeft,p=l.offsetTop,c=l.clientHeight;return document.body.removeChild(i),{left:Math.abs(a-e.scrollLeft),top:Math.abs(p-e.scrollTop)+c}}return{top:"auto",left:"auto"}}},{key:"invokeElementMethod",value:function(e,t,n){e[t].apply(e,n)}},{key:"isClickable",value:function(e){var t=e.nodeName,n=e.parentElement&&e.parentElement.nodeName;return"INPUT"===t||"TEXTAREA"===t||"BUTTON"===t||"A"===t||"INPUT"===n||"TEXTAREA"===n||"BUTTON"===n||"A"===n||this.hasClass(e,"p-button")||this.hasClass(e.parentElement,"p-button")||this.hasClass(e.parentElement,"p-checkbox")||this.hasClass(e.parentElement,"p-radiobutton")}},{key:"applyStyle",value:function(e,t){if("string"==typeof t)e.style.cssText=this.style;else for(var n in this.style)e.style[n]=t[n]}},{key:"exportCSV",value:function(t,n){var o=new Blob([t],{type:"application/csv;charset=utf-8;"});window.navigator.msSaveOrOpenBlob?navigator.msSaveOrOpenBlob(o,n+".csv"):e.saveAs({name:n+".csv",src:URL.createObjectURL(o)})||(t="data:text/csv;charset=utf-8,"+t,window.open(encodeURI(t)))}},{key:"saveAs",value:function(e){if(e){var t=document.createElement("a");if(void 0!==t.download){var n=e.name;return t.setAttribute("href",e.src),t.setAttribute("download",n),t.style.display="none",document.body.appendChild(t),t.click(),document.body.removeChild(t),!0}}return!1}},{key:"createInlineStyle",value:function(e){var t=document.createElement("style");try{e||(e=process.env.REACT_APP_CSS_NONCE)}catch(e){}return e&&t.setAttribute("nonce",e),document.head.appendChild(t),t}},{key:"removeInlineStyle",value:function(e){if(this.isExist(e)){try{document.head.removeChild(e)}catch(e){}e=null}return e}}]),e}();function L(){return L=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},L.apply(this,arguments)}function K(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var I=function(n){S(c,t);var o,s,a=(o=c,s=K(),function(){var e,t=E(o);if(s){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return x(this,e)});function c(e){var t;return m(this,c),(t=a.call(this,e)).props.editor&&(t.state={}),t.onClick=t.onClick.bind(C(t)),t.onKeyDown=t.onKeyDown.bind(C(t)),t.onEditorFocus=t.onEditorFocus.bind(C(t)),t}return b(c,[{key:"onClick",value:function(){var e=this;this.props.editor&&!this.state.editing&&(this.props.selectOnEdit||!this.props.selectOnEdit&&this.props.selected)&&(this.selfClick=!0,this.setState({editing:!0},(function(){e.bindDocumentEditListener(),e.overlayEventListener=function(t){e.isOutsideClicked(t.target)||(e.selfClick=!0)},p.on("overlay-click",e.overlayEventListener)})))}},{key:"onKeyDown",value:function(e){13!==e.which&&9!==e.which||this.switchCellToViewMode(e)}},{key:"bindDocumentEditListener",value:function(){var e=this;this.documentEditListener||(this.documentEditListener=function(t){!e.selfClick&&e.isOutsideClicked(t.target)&&e.switchCellToViewMode(t),e.selfClick=!1},document.addEventListener("click",this.documentEditListener))}},{key:"isOutsideClicked",value:function(e){return this.container&&!(this.container.isSameNode(e)||this.container.contains(e))}},{key:"unbindDocumentEditListener",value:function(){this.documentEditListener&&(document.removeEventListener("click",this.documentEditListener),this.documentEditListener=null,this.selfClick=!1)}},{key:"closeCell",value:function(){var e=this;setTimeout((function(){e.setState({editing:!1},(function(){e.unbindDocumentEditListener(),p.off("overlay-click",e.overlayEventListener),e.overlayEventListener=null}))}),1)}},{key:"onEditorFocus",value:function(e){this.onClick(e)}},{key:"switchCellToViewMode",value:function(e){this.props.cellEditValidator?this.props.cellEditValidator({originalEvent:e,columnProps:this.props})&&this.closeCell():this.closeCell()}},{key:"componentDidUpdate",value:function(){var e=this;if(this.container&&this.props.editor)if(clearTimeout(this.tabindexTimeout),this.state&&this.state.editing){var t=r.findSingle(this.container,"input");t&&document.activeElement!==t&&!t.hasAttribute("data-isCellEditing")&&(t.setAttribute("data-isCellEditing",!0),t.focus()),this.keyHelper.tabIndex=-1}else this.tabindexTimeout=setTimeout((function(){e.keyHelper&&e.keyHelper.setAttribute("tabindex",0)}),50)}},{key:"componentWillUnmount",value:function(){this.unbindDocumentEditListener(),this.overlayEventListener&&(p.off("overlay-click",this.overlayEventListener),this.overlayEventListener=null)}},{key:"render",value:function(){var t,n=this,o=i(this.props.bodyClassName||this.props.className,{"p-editable-column":this.props.editor,"p-cell-editing":!!this.props.editor&&this.state.editing}),r=this.props.bodyStyle||this.props.style;if(this.state&&this.state.editing){if(!this.props.editor)throw new Error("Editor is not found on column.");t=l.getJSXElement(this.props.editor,{node:this.props.node,rowData:this.props.node.data,value:l.resolveFieldData(this.props.node.data,this.props.field),field:this.props.field,rowIndex:this.props.rowIndex,props:this.props})}else t=this.props.body?l.getJSXElement(this.props.body,this.props.node,{field:this.props.field,rowIndex:this.props.rowIndex,props:this.props}):l.resolveFieldData(this.props.node.data,this.props.field);return e.createElement("td",{ref:function(e){return n.container=e},className:o,style:r,onClick:this.onClick,onKeyDown:this.onKeyDown},this.props.children,this.props.editor&&e.createElement("a",{tabIndex:0,ref:function(e){n.keyHelper=e},className:"p-cell-editor-key-helper p-hidden-accessible",onFocus:this.onEditorFocus},e.createElement("span",null)),t)}}]),c}();function A(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=W(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw i}}}}function W(e,t){if(e){if("string"==typeof e)return B(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?B(e,t):void 0}}function B(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function U(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function j(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?U(Object(n),!0).forEach((function(t){O(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):U(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function G(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}var V=function(n){S(a,t);var o,l,s=(o=a,l=G(),function(){var e,t=E(o);if(l){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return x(this,e)});function a(e){var t;return m(this,a),(t=s.call(this,e)).onTogglerClick=t.onTogglerClick.bind(C(t)),t.onClick=t.onClick.bind(C(t)),t.onTouchEnd=t.onTouchEnd.bind(C(t)),t.propagateUp=t.propagateUp.bind(C(t)),t.onCheckboxChange=t.onCheckboxChange.bind(C(t)),t.onCheckboxFocus=t.onCheckboxFocus.bind(C(t)),t.onCheckboxBlur=t.onCheckboxBlur.bind(C(t)),t.onRightClick=t.onRightClick.bind(C(t)),t.onKeyDown=t.onKeyDown.bind(C(t)),t}return b(a,[{key:"isLeaf",value:function(){return!1!==this.props.node.leaf&&!(this.props.node.children&&this.props.node.children.length)}},{key:"onTogglerClick",value:function(e){this.isExpanded()?this.collapse(e):this.expand(e),e.preventDefault(),e.stopPropagation()}},{key:"expand",value:function(e){var t=this.props.expandedKeys?j({},this.props.expandedKeys):{};t[this.props.node.key]=!0,this.props.onToggle({originalEvent:e,value:t}),this.invokeToggleEvents(e,!0)}},{key:"collapse",value:function(e){var t=j({},this.props.expandedKeys);delete t[this.props.node.key],this.props.onToggle({originalEvent:e,value:t}),this.invokeToggleEvents(e,!1)}},{key:"invokeToggleEvents",value:function(e,t){t?this.props.onExpand&&this.props.onExpand({originalEvent:e,node:this.props.node}):this.props.onCollapse&&this.props.onCollapse({originalEvent:e,node:this.props.node})}},{key:"onClick",value:function(e){this.props.onRowClick&&this.props.onRowClick(e,this.props.node),this.nodeTouched=!1}},{key:"onTouchEnd",value:function(){this.nodeTouched=!0}},{key:"onCheckboxChange",value:function(e){var t=this.isChecked(),n=this.props.selectionKeys?j({},this.props.selectionKeys):{};t?(this.props.propagateSelectionDown?this.propagateDown(this.props.node,!1,n):delete n[this.props.node.key],this.props.propagateSelectionUp&&this.props.onPropagateUp&&this.props.onPropagateUp({originalEvent:e,check:!1,selectionKeys:n}),this.props.onUnselect&&this.props.onUnselect({originalEvent:e,node:this.props.node})):(this.props.propagateSelectionDown?this.propagateDown(this.props.node,!0,n):n[this.props.node.key]={checked:!0},this.props.propagateSelectionUp&&this.props.onPropagateUp&&this.props.onPropagateUp({originalEvent:e,check:!0,selectionKeys:n}),this.props.onSelect&&this.props.onSelect({originalEvent:e,node:this.props.node})),this.props.onSelectionChange&&this.props.onSelectionChange({originalEvent:e,value:n}),r.clearSelection()}},{key:"onCheckboxFocus",value:function(){r.addClass(this.checkboxBox,"p-focus"),r.addClass(this.checkboxRef,"p-checkbox-focused")}},{key:"onCheckboxBlur",value:function(){r.removeClass(this.checkboxBox,"p-focus"),r.removeClass(this.checkboxRef,"p-checkbox-focused")}},{key:"propagateUp",value:function(e){var t,n=e.check,o=e.selectionKeys,r=0,i=!1,l=A(this.props.node.children);try{for(l.s();!(t=l.n()).done;){var s=t.value;o[s.key]&&o[s.key].checked?r++:o[s.key]&&o[s.key].partialChecked&&(i=!0)}}catch(e){l.e(e)}finally{l.f()}n&&r===this.props.node.children.length?o[this.props.node.key]={checked:!0,partialChecked:!1}:(n||delete o[this.props.node.key],o[this.props.node.key]=i||r>0&&r!==this.props.node.children.length?{checked:!1,partialChecked:!0}:{checked:!1,partialChecked:!1}),this.props.propagateSelectionUp&&this.props.onPropagateUp&&this.props.onPropagateUp(e)}},{key:"propagateDown",value:function(e,t,n){if(t?n[e.key]={checked:!0,partialChecked:!1}:delete n[e.key],e.children&&e.children.length)for(var o=0;o<e.children.length;o++)this.propagateDown(e.children[o],t,n)}},{key:"onRightClick",value:function(e){r.clearSelection(),this.props.onContextMenuSelectionChange&&this.props.onContextMenuSelectionChange({originalEvent:e,value:this.props.node.key}),this.props.onContextMenu&&this.props.onContextMenu({originalEvent:e,node:this.props.node})}},{key:"onKeyDown",value:function(e){if(e.target===this.container){var t=e.currentTarget;switch(e.which){case 40:var n=t.nextElementSibling;n&&n.focus(),e.preventDefault();break;case 38:var o=t.previousElementSibling;o&&o.focus(),e.preventDefault();break;case 39:this.isExpanded()||this.expand(e),e.preventDefault();break;case 37:this.isExpanded()&&this.collapse(e),e.preventDefault();break;case 13:this.onClick(e),e.preventDefault()}}}},{key:"isExpanded",value:function(){return!!this.props.expandedKeys&&void 0!==this.props.expandedKeys[this.props.node.key]}},{key:"isSelected",value:function(){return!("single"!==this.props.selectionMode&&"multiple"!==this.props.selectionMode||!this.props.selectionKeys)&&("single"===this.props.selectionMode?this.props.selectionKeys===this.props.node.key:void 0!==this.props.selectionKeys[this.props.node.key])}},{key:"isChecked",value:function(){return!!this.props.selectionKeys&&(this.props.selectionKeys[this.props.node.key]&&this.props.selectionKeys[this.props.node.key].checked)}},{key:"isPartialChecked",value:function(){return!!this.props.selectionKeys&&(this.props.selectionKeys[this.props.node.key]&&this.props.selectionKeys[this.props.node.key].partialChecked)}},{key:"renderToggler",value:function(){var t=this.isExpanded(),n=i('"p-treetable-toggler-icon pi pi-fw',{"pi-chevron-right":!t,"pi-chevron-down":t});return e.createElement("button",{type:"button",className:"p-treetable-toggler p-link p-unselectable-text",onClick:this.onTogglerClick,tabIndex:-1,style:{marginLeft:16*this.props.level+"px",visibility:!1===this.props.node.leaf||this.props.node.children&&this.props.node.children.length?"visible":"hidden"}},e.createElement("i",{className:n}),e.createElement(c,null))}},{key:"renderCheckbox",value:function(){var t=this;if("checkbox"===this.props.selectionMode&&!1!==this.props.node.selectable){var n=this.isChecked(),o=this.isPartialChecked(),r=i("p-checkbox-box",{"p-highlight":n,"p-indeterminate":o}),l=i("p-checkbox-icon p-c",{"pi pi-check":n,"pi pi-minus":o});return e.createElement("div",{className:"p-checkbox p-treetable-checkbox p-component",ref:function(e){return t.checkboxRef=e},onClick:this.onCheckboxChange,role:"checkbox","aria-checked":n},e.createElement("div",{className:"p-hidden-accessible"},e.createElement("input",{type:"checkbox",onFocus:this.onCheckboxFocus,onBlur:this.onCheckboxBlur})),e.createElement("div",{className:r,ref:function(e){return t.checkboxBox=e}},e.createElement("span",{className:l})))}return null}},{key:"renderCell",value:function(t){var n,o;return t.props.expander&&(n=this.renderToggler(),o=this.renderCheckbox()),e.createElement(I,L({key:t.props.columnKey||t.props.field},t.props,{selectOnEdit:this.props.selectOnEdit,selected:this.isSelected(),node:this.props.node,rowIndex:this.props.rowIndex}),n,o)}},{key:"renderChildren",value:function(){var t=this;return this.isExpanded()&&this.props.node.children?this.props.node.children.map((function(n,o){return e.createElement(a,{key:n.key||JSON.stringify(n.data),level:t.props.level+1,rowIndex:t.props.rowIndex+"_"+o,node:n,columns:t.props.columns,expandedKeys:t.props.expandedKeys,selectOnEdit:t.props.selectOnEdit,onToggle:t.props.onToggle,onExpand:t.props.onExpand,onCollapse:t.props.onCollapse,selectionMode:t.props.selectionMode,selectionKeys:t.props.selectionKeys,onSelectionChange:t.props.onSelectionChange,metaKeySelection:t.props.metaKeySelection,onRowClick:t.props.onRowClick,onSelect:t.props.onSelect,onUnselect:t.props.onUnselect,propagateSelectionUp:t.props.propagateSelectionUp,propagateSelectionDown:t.props.propagateSelectionDown,onPropagateUp:t.propagateUp,rowClassName:t.props.rowClassName,contextMenuSelectionKey:t.props.contextMenuSelectionKey,onContextMenuSelectionChange:t.props.onContextMenuSelectionChange,onContextMenu:t.props.onContextMenu})})):null}},{key:"render",value:function(){var t=this,n=this.props.columns.map((function(e){return t.renderCell(e)})),o=this.renderChildren(),r={"p-highlight":this.isSelected(),"p-highlight-contextmenu":this.props.contextMenuSelectionKey&&this.props.contextMenuSelectionKey===this.props.node.key};if(this.props.rowClassName){var l=this.props.rowClassName(this.props.node);r=j(j({},r),l)}return r=i(r,this.props.node.className),e.createElement(e.Fragment,null,e.createElement("tr",{ref:function(e){return t.container=e},tabIndex:0,className:r,style:this.props.node.style,onClick:this.onClick,onTouchEnd:this.onTouchEnd,onContextMenu:this.onRightClick,onKeyDown:this.onKeyDown},n),o)}}]),a}();function X(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function _(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?X(Object(n),!0).forEach((function(t){O(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):X(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function Y(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=$(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw i}}}}function $(e,t){if(e){if("string"==typeof e)return q(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?q(e,t):void 0}}function q(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function J(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}O(V,"defaultProps",{node:null,level:null,columns:null,expandedKeys:null,contextMenuSelectionKey:null,selectionMode:null,selectionKeys:null,metaKeySelection:!0,propagateSelectionUp:!0,propagateSelectionDown:!0,rowClassName:null,onExpand:null,onCollapse:null,onToggle:null,onRowClick:null,onSelect:null,onUnselect:null,onSelectionChange:null,onPropagateUp:null,onContextMenuSelectionChange:null,onContextMenu:null});var Q=function(o){S(s,t);var r,i,l=(r=s,i=J(),function(){var e,t=E(r);if(i){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return x(this,e)});function s(e){var t;return m(this,s),(t=l.call(this,e)).onRowClick=t.onRowClick.bind(C(t)),t}return b(s,[{key:"createRow",value:function(t,n){return e.createElement(V,{key:t.key||JSON.stringify(t.data),level:0,rowIndex:n,selectOnEdit:this.props.selectOnEdit,node:t,columns:this.props.columns,expandedKeys:this.props.expandedKeys,onToggle:this.props.onToggle,onExpand:this.props.onExpand,onCollapse:this.props.onCollapse,selectionMode:this.props.selectionMode,selectionKeys:this.props.selectionKeys,onSelectionChange:this.props.onSelectionChange,metaKeySelection:this.props.metaKeySelection,onRowClick:this.onRowClick,onSelect:this.props.onSelect,onUnselect:this.props.onUnselect,propagateSelectionUp:this.props.propagateSelectionUp,propagateSelectionDown:this.props.propagateSelectionDown,rowClassName:this.props.rowClassName,contextMenuSelectionKey:this.props.contextMenuSelectionKey,onContextMenuSelectionChange:this.props.onContextMenuSelectionChange,onContextMenu:this.props.onContextMenu})}},{key:"flattenizeTree",value:function(e){var t,n=[],o=Y(e=e||this.props.value);try{for(o.s();!(t=o.n()).done;){var r=t.value;n.push(r.key),this.isExpandedKey(r.key)&&(n=n.concat(this.flattenizeTree(r.children)))}}catch(e){o.e(e)}finally{o.f()}return n}},{key:"isExpandedKey",value:function(e){return this.props.expandedKeys&&!!this.props.expandedKeys[e]}},{key:"onRowClick",value:function(e,t){var n=this;this.props.onRowClick&&this.props.onRowClick({originalEvent:e,node:t});var o=e.target.nodeName;if(!("INPUT"===o||"BUTTON"===o||"A"===o||H.hasClass(e.target,"p-clickable")||H.hasClass(e.target,"p-treetable-toggler")||H.hasClass(e.target.parentElement,"p-treetable-toggler"))&&(this.isSingleSelectionMode()||this.isMultipleSelectionMode())&&!1!==t.selectable){var r,i=this.isSelected(t),l=!this.nodeTouched&&this.props.metaKeySelection,s=this.flattenizeTree(),a=s.findIndex((function(e){return e===t.key}));if(this.isMultipleSelectionMode()&&e.shiftKey){H.clearSelection();var p=s.findIndex((function(e){return n.props.selectionKeys[e]})),c=Math.min(a,p),u=Math.max(a,p);r=_({},this.props.selectionKeys);for(var d=c;d<=u;d++){r[s[d]]=!0}}else if(this.anchorRowIndex=a,l){var h=e.metaKey||e.ctrlKey;i&&h?(this.isSingleSelectionMode()?r=null:delete(r=_({},this.props.selectionKeys))[t.key],this.props.onUnselect&&this.props.onUnselect({originalEvent:e,node:t})):(this.isSingleSelectionMode()?r=t.key:this.isMultipleSelectionMode()&&((r=h&&this.props.selectionKeys?_({},this.props.selectionKeys):{})[t.key]=!0),this.props.onSelect&&this.props.onSelect({originalEvent:e,node:t}))}else this.isSingleSelectionMode()?i?(r=null,this.props.onUnselect&&this.props.onUnselect({originalEvent:e,node:t})):(r=t.key,this.props.onSelect&&this.props.onSelect({originalEvent:e,node:t})):i?(delete(r=_({},this.props.selectionKeys))[t.key],this.props.onUnselect&&this.props.onUnselect({originalEvent:e,node:t})):((r=this.props.selectionKeys?_({},this.props.selectionKeys):{})[t.key]=!0,this.props.onSelect&&this.props.onSelect({originalEvent:e,node:t}));this.props.onSelectionChange&&this.props.onSelectionChange({originalEvent:e,value:r})}}},{key:"isSingleSelectionMode",value:function(){return this.props.selectionMode&&"single"===this.props.selectionMode}},{key:"isMultipleSelectionMode",value:function(){return this.props.selectionMode&&"multiple"===this.props.selectionMode}},{key:"isSelected",value:function(e){return!("single"!==this.props.selectionMode&&"multiple"!==this.props.selectionMode||!this.props.selectionKeys)&&("single"===this.props.selectionMode?this.props.selectionKeys===e.key:void 0!==this.props.selectionKeys[e.key])}},{key:"renderRows",value:function(){var e=this;if(this.props.paginator&&!this.props.lazy){for(var t=this.props.first||0,n=t+(this.props.rows||0),o=[],r=t;r<n;r++){if(!this.props.value[r])break;o.push(this.createRow(this.props.value[r]))}return o}return this.props.value.map((function(t,n){return e.createRow(t,n)}))}},{key:"renderEmptyMessage",value:function(){if(this.props.loading)return null;var t=this.props.columns?this.props.columns.length:null,o=this.props.emptyMessage||n("emptyMessage");return e.createElement("tr",null,e.createElement("td",{className:"p-treetable-emptymessage",colSpan:t},o))}},{key:"render",value:function(){var t=this.props.value&&this.props.value.length?this.renderRows():this.renderEmptyMessage();return e.createElement("tbody",{className:"p-treetable-tbody"},t)}}]),s}();function Z(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}O(Q,"defaultProps",{value:null,columns:null,expandedKeys:null,contextMenuSelectionKey:null,paginator:!1,first:null,rows:null,selectionMode:null,selectionKeys:null,metaKeySelection:!0,propagateSelectionUp:!0,propagateSelectionDown:!0,lazy:!1,rowClassName:null,emptyMessage:null,loading:!1,onExpand:null,onCollapse:null,onToggle:null,onRowClick:null,onSelect:null,onUnselect:null,onSelectionChange:null,onContextMenuSelectionChange:null,onContextMenu:null});var ee=function(n){S(l,t);var o,r,i=(o=l,r=Z(),function(){var e,t=E(o);if(r){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return x(this,e)});function l(){return m(this,l),i.apply(this,arguments)}return b(l,[{key:"renderFooterCell",value:function(t,n){return e.createElement("td",{key:t.field||n,className:t.props.footerClassName||t.props.className,style:t.props.footerStyle||t.props.style,rowSpan:t.props.rowSpan,colSpan:t.props.colSpan},t.props.footer)}},{key:"renderFooterRow",value:function(t,n){var o=this,r=e.Children.toArray(t.props.children).map((function(e,t){return o.renderFooterCell(e,t)}));return e.createElement("tr",{key:n},r)}},{key:"renderColumnGroup",value:function(){var t=this;return e.Children.toArray(this.props.columnGroup.props.children).map((function(e,n){return t.renderFooterRow(e,n)}))}},{key:"renderColumns",value:function(t){var n=this;if(t){var o=t.map((function(e,t){return n.renderFooterCell(e,t)}));return e.createElement("tr",null,o)}return null}},{key:"hasFooter",value:function(){if(this.props.columnGroup)return!0;for(var e=0;e<this.props.columns.length;e++)if(this.props.columns[e].props.footer)return!0;return!1}},{key:"render",value:function(){var t=this.props.columnGroup?this.renderColumnGroup():this.renderColumns(this.props.columns);return this.hasFooter()?e.createElement("tfoot",{className:"p-treetable-tfoot"},t):null}}]),l}();function te(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}O(ee,"defaultProps",{columns:null,columnGroup:null});var ne=function(n){S(a,t);var o,l,s=(o=a,l=te(),function(){var e,t=E(o);if(l){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return x(this,e)});function a(e){var t;return m(this,a),(t=s.call(this,e)).onHeaderScroll=t.onHeaderScroll.bind(C(t)),t.onBodyScroll=t.onBodyScroll.bind(C(t)),t}return b(a,[{key:"componentDidMount",value:function(){if(this.setScrollHeight(),this.props.frozen)this.scrollBody.style.paddingBottom=r.calculateScrollbarWidth()+"px";else{var e=r.calculateScrollbarWidth();this.scrollHeaderBox.style.marginRight=e+"px",this.scrollFooterBox&&(this.scrollFooterBox.style.marginRight=e+"px")}}},{key:"componentDidUpdate",value:function(){this.setScrollHeight()}},{key:"setScrollHeight",value:function(){if(this.props.scrollHeight)if(-1!==this.props.scrollHeight.indexOf("%")){var e=this.findDataTableContainer(this.container);this.scrollBody.style.visibility="hidden",this.scrollBody.style.height="100px";var t=r.getOuterHeight(e),n=r.getOuterHeight(e.parentElement)*parseInt(this.props.scrollHeight,10)/100-(t-100);this.scrollBody.style.height="auto",this.scrollBody.style.maxHeight=n+"px",this.scrollBody.style.visibility="visible"}else this.scrollBody.style.maxHeight=this.props.scrollHeight}},{key:"findDataTableContainer",value:function(e){if(e){for(var t=e;t&&!r.hasClass(t,"p-treetable");)t=t.parentElement;return t}return null}},{key:"onHeaderScroll",value:function(){this.scrollHeader.scrollLeft=0}},{key:"onBodyScroll",value:function(){var e,t=this.container.previousElementSibling;t&&(e=r.findSingle(t,".p-treetable-scrollable-body")),this.scrollHeaderBox.style.marginLeft=-1*this.scrollBody.scrollLeft+"px",this.scrollFooterBox&&(this.scrollFooterBox.style.marginLeft=-1*this.scrollBody.scrollLeft+"px"),e&&(e.scrollTop=this.scrollBody.scrollTop)}},{key:"calculateRowHeight",value:function(){var e=r.findSingle(this.scrollTable,"tr:not(.p-treetable-emptymessage-row)");e&&(this.rowHeight=r.getOuterHeight(e))}},{key:"renderColGroup",value:function(){return this.props.columns&&this.props.columns.length?e.createElement("colgroup",{className:"p-treetable-scrollable-colgroup"},this.props.columns.map((function(t,n){return e.createElement("col",{key:t.field+"_"+n})}))):null}},{key:"render",value:function(){var t=this,n=i("p-treetable-scrollable-view",{"p-treetable-frozen-view":this.props.frozen,"p-treetable-unfrozen-view":!this.props.frozen&&this.props.frozenWidth}),o=this.props.frozen?this.props.frozenWidth:"calc(100% - "+this.props.frozenWidth+")",r=this.props.frozen?null:this.props.frozenWidth,l=this.renderColGroup(),s=!this.props.frozen&&this.props.scrollHeight?{overflowY:"scroll"}:null;return e.createElement("div",{className:n,style:{width:o,left:r},ref:function(e){t.container=e}},e.createElement("div",{className:"p-treetable-scrollable-header",ref:function(e){t.scrollHeader=e},onScroll:this.onHeaderScroll},e.createElement("div",{className:"p-treetable-scrollable-header-box",ref:function(e){t.scrollHeaderBox=e}},e.createElement("table",{className:"p-treetable-scrollable-header-table"},l,this.props.header))),e.createElement("div",{className:"p-treetable-scrollable-body",ref:function(e){t.scrollBody=e},style:s,onScroll:this.onBodyScroll},e.createElement("table",{ref:function(e){t.scrollTable=e},style:{top:"0"},className:"p-treetable-scrollable-body-table"},l,this.props.body)),e.createElement("div",{className:"p-treetable-scrollable-footer",ref:function(e){t.scrollFooter=e}},e.createElement("div",{className:"p-treetable-scrollable-footer-box",ref:function(e){t.scrollFooterBox=e}},e.createElement("table",{className:"p-treetable-scrollable-footer-table"},l,this.props.footer))))}}]),a}();function oe(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=re(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var o=0,r=function(){};return{s:r,n:function(){return o>=e.length?{done:!0}:{done:!1,value:e[o++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var i,l=!0,s=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return l=e.done,e},e:function(e){s=!0,i=e},f:function(){try{l||null==n.return||n.return()}finally{if(s)throw i}}}}function re(e,t){if(e){if("string"==typeof e)return ie(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?ie(e,t):void 0}}function ie(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}function le(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);t&&(o=o.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,o)}return n}function se(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?le(Object(n),!0).forEach((function(t){O(e,t,n[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):le(Object(n)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(n,t))}))}return e}function ae(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],(function(){}))),!0}catch(e){return!1}}O(ne,"defaultProps",{header:null,body:null,footer:null,columns:null,frozen:null,frozenWidth:null,frozenBody:null});var pe=function(n){S(u,t);var a,p,c=(a=u,p=ae(),function(){var e,t=E(a);if(p){var n=E(this).constructor;e=Reflect.construct(t,arguments,n)}else e=t.apply(this,arguments);return x(this,e)});function u(e){var t;m(this,u);var n={};return(t=c.call(this,e)).props.onToggle||(t.state={expandedKeys:t.props.expandedKeys}),t.props.onPage||(n.first=e.first,n.rows=e.rows),t.props.onSort||(n.sortField=e.sortField,n.sortOrder=e.sortOrder,n.multiSortMeta=e.multiSortMeta),t.props.onFilter||(n.filters=e.filters),Object.keys(n).length&&(t.state=n),t.onToggle=t.onToggle.bind(C(t)),t.onPageChange=t.onPageChange.bind(C(t)),t.onSort=t.onSort.bind(C(t)),t.onFilter=t.onFilter.bind(C(t)),t.onColumnResizeStart=t.onColumnResizeStart.bind(C(t)),t.onColumnDragStart=t.onColumnDragStart.bind(C(t)),t.onColumnDragOver=t.onColumnDragOver.bind(C(t)),t.onColumnDragLeave=t.onColumnDragLeave.bind(C(t)),t.onColumnDrop=t.onColumnDrop.bind(C(t)),t}return b(u,[{key:"onToggle",value:function(e){this.props.onToggle?this.props.onToggle(e):this.setState({expandedKeys:e.value})}},{key:"onPageChange",value:function(e){this.props.onPage?this.props.onPage(e):this.setState({first:e.first,rows:e.rows})}},{key:"onSort",value:function(e){var t,n,o=e.sortField,r=this.props.defaultSortOrder;if(this.columnSortable=e.sortable,this.columnSortFunction=e.sortFunction,this.columnField=e.sortField,"multiple"===this.props.sortMode){var i=e.originalEvent.metaKey||e.originalEvent.ctrlKey;if((t=this.getMultiSortMeta())&&t instanceof Array){var l=t.find((function(e){return e.field===o}));r=l?this.getCalculatedSortOrder(l.order):r}var s={field:o,order:r};r?(t&&i||(t=[]),this.addSortMeta(s,t)):this.props.removableSort&&t&&this.removeSortMeta(s,t),n={multiSortMeta:t}}else r=this.getSortField()===o?this.getCalculatedSortOrder(this.getSortOrder()):r,this.props.removableSort&&(o=r?o:null),n={sortField:o,sortOrder:r};this.props.onSort?this.props.onSort(n):(n.first=0,this.setState(n))}},{key:"getCalculatedSortOrder",value:function(e){return this.props.removableSort?this.props.defaultSortOrder===e?-1*e:0:-1*e}},{key:"addSortMeta",value:function(e,t){for(var n=-1,o=0;o<t.length;o++)if(t[o].field===e.field){n=o;break}n>=0?t[n]=e:t.push(e)}},{key:"removeSortMeta",value:function(e,t){for(var n=-1,o=0;o<t.length;o++)if(t[o].field===e.field){n=o;break}n>=0&&t.splice(n,1),t=t.length>0?t:null}},{key:"sortSingle",value:function(e){return this.sortNodes(e)}},{key:"sortNodes",value:function(e){var t=this,n=g(e);if(this.columnSortable&&"custom"===this.columnSortable&&this.columnSortFunction)n=this.columnSortFunction({field:this.getSortField(),order:this.getSortOrder()});else{n.sort((function(e,n){var o=t.getSortField(),r=l.resolveFieldData(e.data,o),i=l.resolveFieldData(n.data,o),s=null;return s=null==r&&null!=i?-1:null!=r&&null==i?1:null==r&&null==i?0:"string"==typeof r&&"string"==typeof i?r.localeCompare(i,void 0,{numeric:!0}):r<i?-1:r>i?1:0,t.getSortOrder()*s}));for(var o=0;o<n.length;o++)n[o].children&&n[o].children.length&&(n[o].children=this.sortNodes(n[o].children))}return n}},{key:"sortMultiple",value:function(e){var t=this.getMultiSortMeta();return t?this.sortMultipleNodes(e,t):e}},{key:"sortMultipleNodes",value:function(e,t){var n=this,o=g(e);o.sort((function(e,o){return n.multisortField(e,o,t,0)}));for(var r=0;r<o.length;r++)o[r].children&&o[r].children.length&&(o[r].children=this.sortMultipleNodes(o[r].children,t));return o}},{key:"multisortField",value:function(e,t,n,o){var r=l.resolveFieldData(e.data,n[o].field),i=l.resolveFieldData(t.data,n[o].field),s=null;if(null==r&&null!=i)s=-1;else if(null!=r&&null==i)s=1;else if(null==r&&null==i)s=0;else{if(r===i)return n.length-1>o?this.multisortField(e,t,n,o+1):0;if(("string"==typeof r||r instanceof String)&&("string"==typeof i||i instanceof String))return n[o].order*r.localeCompare(i,void 0,{numeric:!0});s=r<i?-1:1}return n[o].order*s}},{key:"filter",value:function(e,t,n){this.onFilter({value:e,field:t,matchMode:n})}},{key:"onFilter",value:function(e){var t=this.getFilters(),n=t?se({},t):{};this.isFilterBlank(e.value)?n[e.field]&&delete n[e.field]:n[e.field]={value:e.value,matchMode:e.matchMode},this.props.onFilter?this.props.onFilter({filters:n}):this.setState({first:0,filters:n})}},{key:"hasFilter",value:function(){var e=this.getFilters();return e&&Object.keys(e).length>0}},{key:"isFilterBlank",value:function(e){return null==e||("string"==typeof e&&0===e.trim().length||e instanceof Array&&0===e.length)}},{key:"onColumnResizeStart",value:function(e){var t=r.getOffset(this.container).left;this.resizeColumn=e.columnEl,this.resizeColumnProps=e.column,this.columnResizing=!0,this.lastResizerHelperX=e.originalEvent.pageX-t+this.container.scrollLeft,this.bindColumnResizeEvents()}},{key:"onColumnResize",value:function(e){var t=r.getOffset(this.container).left;r.addClass(this.container,"p-unselectable-text"),this.resizerHelper.style.height=this.container.offsetHeight+"px",this.resizerHelper.style.top="0px",this.resizerHelper.style.left=e.pageX-t+this.container.scrollLeft+"px",this.resizerHelper.style.display="block"}},{key:"onColumnResizeEnd",value:function(e){var t=this.resizerHelper.offsetLeft-this.lastResizerHelperX,n=this.resizeColumn.offsetWidth,o=n+t;if(n+t>parseInt(this.resizeColumn.style.minWidth||15,10)){if("fit"===this.props.columnResizeMode){var i=this.resizeColumn.nextElementSibling,l=i.offsetWidth-t;if(o>15&&l>15)if(this.props.scrollable){var s=this.findParentScrollableView(this.resizeColumn),a=r.findSingle(s,"table.p-treetable-scrollable-body-table"),p=r.findSingle(s,"table.p-treetable-scrollable-header-table"),c=r.findSingle(s,"table.p-treetable-scrollable-footer-table"),u=r.index(this.resizeColumn);this.resizeColGroup(p,u,o,l),this.resizeColGroup(a,u,o,l),this.resizeColGroup(c,u,o,l)}else this.resizeColumn.style.width=o+"px",i&&(i.style.width=l+"px")}else if("expand"===this.props.columnResizeMode)if(this.props.scrollable){var d=this.findParentScrollableView(this.resizeColumn),h=r.findSingle(d,"table.p-treetable-scrollable-body-table"),f=r.findSingle(d,"table.p-treetable-scrollable-header-table"),y=r.findSingle(d,"table.p-treetable-scrollable-footer-table");h.style.width=h.offsetWidth+t+"px",f.style.width=f.offsetWidth+t+"px",y&&(y.style.width=f.offsetWidth+t+"px");var g=r.index(this.resizeColumn);this.resizeColGroup(f,g,o,null),this.resizeColGroup(h,g,o,null),this.resizeColGroup(y,g,o,null)}else this.table.style.width=this.table.offsetWidth+t+"px",this.resizeColumn.style.width=o+"px";this.props.onColumnResizeEnd&&this.props.onColumnResizeEnd({element:this.resizeColumn,column:this.resizeColumnProps,delta:t})}this.resizerHelper.style.display="none",this.resizeColumn=null,this.resizeColumnProps=null,r.removeClass(this.container,"p-unselectable-text"),this.unbindColumnResizeEvents()}},{key:"findParentScrollableView",value:function(e){if(e){for(var t=e.parentElement;t&&!r.hasClass(t,"p-treetable-scrollable-view");)t=t.parentElement;return t}return null}},{key:"resizeColGroup",value:function(e,t,n,o){if(e){var r="COLGROUP"===e.children[0].nodeName?e.children[0]:null;if(!r)throw new Error("Scrollable tables require a colgroup to support resizable columns");var i=r.children[t],l=i.nextElementSibling;i.style.width=n+"px",l&&o&&(l.style.width=o+"px")}}},{key:"bindColumnResizeEvents",value:function(){var e=this;this.documentColumnResizeListener=document.addEventListener("mousemove",(function(t){e.columnResizing&&e.onColumnResize(t)})),this.documentColumnResizeEndListener=document.addEventListener("mouseup",(function(t){e.columnResizing&&(e.columnResizing=!1,e.onColumnResizeEnd(t))}))}},{key:"unbindColumnResizeEvents",value:function(){document.removeEventListener("document",this.documentColumnResizeListener),document.removeEventListener("document",this.documentColumnResizeEndListener)}},{key:"onColumnDragStart",value:function(e){var t=e.originalEvent,n=e.column;this.columnResizing?t.preventDefault():(this.iconWidth=r.getHiddenElementOuterWidth(this.reorderIndicatorUp),this.iconHeight=r.getHiddenElementOuterHeight(this.reorderIndicatorUp),this.draggedColumnEl=this.findParentHeader(t.currentTarget),this.draggedColumn=n,t.dataTransfer.setData("text","b"))}},{key:"onColumnDragOver",value:function(e){var t=e.originalEvent,n=this.findParentHeader(t.currentTarget);if(this.props.reorderableColumns&&this.draggedColumnEl&&n){t.preventDefault();var o=r.getOffset(this.container),i=r.getOffset(n);if(this.draggedColumnEl!==n){var l=i.left-o.left,s=i.left+n.offsetWidth/2;this.reorderIndicatorUp.style.top=i.top-o.top-(this.iconHeight-1)+"px",this.reorderIndicatorDown.style.top=i.top-o.top+n.offsetHeight+"px",t.pageX>s?(this.reorderIndicatorUp.style.left=l+n.offsetWidth-Math.ceil(this.iconWidth/2)+"px",this.reorderIndicatorDown.style.left=l+n.offsetWidth-Math.ceil(this.iconWidth/2)+"px",this.dropPosition=1):(this.reorderIndicatorUp.style.left=l-Math.ceil(this.iconWidth/2)+"px",this.reorderIndicatorDown.style.left=l-Math.ceil(this.iconWidth/2)+"px",this.dropPosition=-1),this.reorderIndicatorUp.style.display="block",this.reorderIndicatorDown.style.display="block"}}}},{key:"onColumnDragLeave",value:function(e){this.props.reorderableColumns&&this.draggedColumnEl&&(e.originalEvent.preventDefault(),this.reorderIndicatorUp.style.display="none",this.reorderIndicatorDown.style.display="none")}},{key:"onColumnDrop",value:function(t){var n=this,o=t.originalEvent,i=t.column;if(o.preventDefault(),this.draggedColumnEl){var s=r.index(this.draggedColumnEl),a=r.index(this.findParentHeader(o.currentTarget)),p=s!==a;if(p&&(a-s==1&&-1===this.dropPosition||s-a==1&&1===this.dropPosition)&&(p=!1),p){var c=this.state.columnOrder?this.getColumns():e.Children.toArray(this.props.children),u=function(e,t){return l.equals(e,t,e.props.columnKey||t.props.columnKey?"props.columnKey":"props.field")},d=c.findIndex((function(e){return u(e,n.draggedColumn)})),h=c.findIndex((function(e){return u(e,i)}));h<d&&1===this.dropPosition&&h++,h>d&&-1===this.dropPosition&&h--,l.reorderArray(c,d,h);var f,y=[],g=oe(c);try{for(g.s();!(f=g.n()).done;){var m=f.value;y.push(m.props.columnKey||m.props.field)}}catch(e){g.e(e)}finally{g.f()}this.setState({columnOrder:y}),this.props.onColReorder&&this.props.onColReorder({dragIndex:d,dropIndex:h,columns:c})}this.reorderIndicatorUp.style.display="none",this.reorderIndicatorDown.style.display="none",this.draggedColumnEl.draggable=!1,this.draggedColumnEl=null,this.dropPosition=null}}},{key:"findParentHeader",value:function(e){if("TH"===e.nodeName)return e;for(var t=e.parentElement;"TH"!==t.nodeName&&(t=t.parentElement););return t}},{key:"getExpandedKeys",value:function(){return this.props.onToggle?this.props.expandedKeys:this.state.expandedKeys}},{key:"getFirst",value:function(){return this.props.onPage?this.props.first:this.state.first}},{key:"getRows",value:function(){return this.props.onPage?this.props.rows:this.state.rows}},{key:"getSortField",value:function(){return this.props.onSort?this.props.sortField:this.state.sortField}},{key:"getSortOrder",value:function(){return this.props.onSort?this.props.sortOrder:this.state.sortOrder}},{key:"getMultiSortMeta",value:function(){return this.props.onSort?this.props.multiSortMeta:this.state.multiSortMeta}},{key:"getFilters",value:function(){return this.props.onFilter?this.props.filters:this.state.filters}},{key:"findColumnByKey",value:function(e,t){if(e&&e.length)for(var n=0;n<e.length;n++){var o=e[n];if(o.props.columnKey===t||o.props.field===t)return o}return null}},{key:"getColumns",value:function(){var t=e.Children.toArray(this.props.children);if(t&&t.length){if(this.props.reorderableColumns&&this.state.columnOrder){var n,o=[],r=oe(this.state.columnOrder);try{for(r.s();!(n=r.n()).done;){var i=this.findColumnByKey(t,n.value);i&&o.push(i)}}catch(e){r.e(e)}finally{r.f()}return[].concat(o,g(t.filter((function(e){return o.indexOf(e)<0}))))}return t}return null}},{key:"getTotalRecords",value:function(e){return this.props.lazy?this.props.totalRecords:e?e.length:0}},{key:"isSingleSelectionMode",value:function(){return this.props.selectionMode&&"single"===this.props.selectionMode}},{key:"isMultipleSelectionMode",value:function(){return this.props.selectionMode&&"multiple"===this.props.selectionMode}},{key:"isRowSelectionMode",value:function(){return this.isSingleSelectionMode()||this.isMultipleSelectionMode()}},{key:"getFrozenColumns",value:function(e){var t,n=null,o=oe(e);try{for(o.s();!(t=o.n()).done;){var r=t.value;r.props.frozen&&(n=n||[]).push(r)}}catch(e){o.e(e)}finally{o.f()}return n}},{key:"getScrollableColumns",value:function(e){var t,n=null,o=oe(e);try{for(o.s();!(t=o.n()).done;){var r=t.value;r.props.frozen||(n=n||[]).push(r)}}catch(e){o.e(e)}finally{o.f()}return n}},{key:"filterLocal",value:function(t){var n,r=[],i=this.getFilters(),l=e.Children.toArray(this.props.children),s="strict"===this.props.filterMode,a=oe(t);try{for(a.s();!(n=a.n()).done;){for(var p=n.value,c=se({},p),u=!0,d=!1,h=0;h<l.length;h++){var f=l[h],y=i?i[f.props.field]:null,g=f.props.field,m=void 0;if(y){var v=y.matchMode||f.props.filterMatchMode||"startsWith";if(m={filterField:g,filterValue:y.value,filterConstraint:"custom"===v?f.props.filterFunction:o.filters[v],isStrictMode:s,options:{rowData:p,filters:i,props:this.props,column:{filterMeta:y,filterField:g,props:f.props}}},(!s||this.findFilteredNodes(c,m)||this.isFilterMatched(c,m))&&(s||this.isFilterMatched(c,m)||this.findFilteredNodes(c,m))||(u=!1),!u)break}if(this.props.globalFilter&&!d){var b=se({},c);m={filterField:g,filterValue:this.props.globalFilter,filterConstraint:o.filters.contains,isStrictMode:s},(s&&(this.findFilteredNodes(b,m)||this.isFilterMatched(b,m))||!s&&(this.isFilterMatched(b,m)||this.findFilteredNodes(b,m)))&&(d=!0,c=b)}}var C=u;this.props.globalFilter&&(C=u&&d),C&&r.push(c)}}catch(e){a.e(e)}finally{a.f()}return r}},{key:"findFilteredNodes",value:function(e,t){if(e){var n=!1;if(e.children){var o=g(e.children);e.children=[];var r,i=oe(o);try{for(i.s();!(r=i.n()).done;){var l=se({},r.value);this.isFilterMatched(l,t)&&(n=!0,e.children.push(l))}}catch(e){i.e(e)}finally{i.f()}}if(n)return!0}}},{key:"isFilterMatched",value:function(e,t){var n=t.filterField,o=t.filterValue,r=t.filterConstraint,i=t.isStrictMode,s=t.options,a=!1;return r(l.resolveFieldData(e.data,n),o,this.props.filterLocale,s)&&(a=!0),(!a||i&&!this.isNodeLeaf(e))&&(a=this.findFilteredNodes(e,{filterField:n,filterValue:o,filterConstraint:r,isStrictMode:i})||a),a}},{key:"isNodeLeaf",value:function(e){return!1!==e.leaf&&!(e.children&&e.children.length)}},{key:"processValue",value:function(){var e=this.props.value;if(!this.props.lazy&&e&&e.length){(this.getSortField()||this.getMultiSortMeta())&&("single"===this.props.sortMode?e=this.sortSingle(e):"multiple"===this.props.sortMode&&(e=this.sortMultiple(e)));var t=this.getFilters();(t||this.props.globalFilter)&&(e=this.filterLocal(e,t))}return e}},{key:"createTableHeader",value:function(t,n){return e.createElement(D,{columns:t,columnGroup:n,tabIndex:this.props.tabIndex,onSort:this.onSort,sortField:this.getSortField(),sortOrder:this.getSortOrder(),multiSortMeta:this.getMultiSortMeta(),resizableColumns:this.props.resizableColumns,onResizeStart:this.onColumnResizeStart,reorderableColumns:this.props.reorderableColumns,onDragStart:this.onColumnDragStart,onDragOver:this.onColumnDragOver,onDragLeave:this.onColumnDragLeave,onDrop:this.onColumnDrop,onFilter:this.onFilter,filters:this.getFilters(),filterDelay:this.props.filterDelay})}},{key:"createTableFooter",value:function(t,n){return e.createElement(ee,{columns:t,columnGroup:n})}},{key:"createTableBody",value:function(t,n){return e.createElement(Q,{value:t,columns:n,expandedKeys:this.getExpandedKeys(),selectOnEdit:this.props.selectOnEdit,onToggle:this.onToggle,onExpand:this.props.onExpand,onCollapse:this.props.onCollapse,paginator:this.props.paginator,first:this.getFirst(),rows:this.getRows(),selectionMode:this.props.selectionMode,selectionKeys:this.props.selectionKeys,onSelectionChange:this.props.onSelectionChange,metaKeySelection:this.props.metaKeySelection,onRowClick:this.props.onRowClick,onSelect:this.props.onSelect,onUnselect:this.props.onUnselect,propagateSelectionUp:this.props.propagateSelectionUp,propagateSelectionDown:this.props.propagateSelectionDown,lazy:this.props.lazy,rowClassName:this.props.rowClassName,emptyMessage:this.props.emptyMessage,loading:this.props.loading,contextMenuSelectionKey:this.props.contextMenuSelectionKey,onContextMenuSelectionChange:this.props.onContextMenuSelectionChange,onContextMenu:this.props.onContextMenu})}},{key:"createPaginator",value:function(t,n){var o=i("p-paginator-"+t,this.props.paginatorClassName);return e.createElement(s,{first:this.getFirst(),rows:this.getRows(),pageLinkSize:this.props.pageLinkSize,className:o,onPageChange:this.onPageChange,template:this.props.paginatorTemplate,totalRecords:n,rowsPerPageOptions:this.props.rowsPerPageOptions,currentPageReportTemplate:this.props.currentPageReportTemplate,leftContent:this.props.paginatorLeft,rightContent:this.props.paginatorRight,alwaysShow:this.props.alwaysShowPaginator,dropdownAppendTo:this.props.paginatorDropdownAppendTo})}},{key:"createScrollableView",value:function(t,n,o,r,i){var l=this.createTableHeader(n,r),s=this.createTableFooter(n,i),a=this.createTableBody(t,n);return e.createElement(ne,{columns:n,header:l,body:a,footer:s,scrollHeight:this.props.scrollHeight,frozen:o,frozenWidth:this.props.frozenWidth})}},{key:"renderScrollableTable",value:function(t){var n,o,r=this.getColumns(),i=this.getFrozenColumns(r),l=i?this.getScrollableColumns(r):r;return i&&(n=this.createScrollableView(t,i,!0,this.props.frozenHeaderColumnGroup,this.props.frozenFooterColumnGroup)),o=this.createScrollableView(t,l,!1,this.props.headerColumnGroup,this.props.footerColumnGroup),e.createElement("div",{className:"p-treetable-scrollable-wrapper"},n,o)}},{key:"renderRegularTable",value:function(t){var n=this,o=this.getColumns(),r=this.createTableHeader(o,this.props.headerColumnGroup),i=this.createTableFooter(o,this.props.footerColumnGroup),l=this.createTableBody(t,o);return e.createElement("div",{className:"p-treetable-wrapper"},e.createElement("table",{style:this.props.tableStyle,className:this.props.tableClassName,ref:function(e){return n.table=e}},r,i,l))}},{key:"renderTable",value:function(e){return this.props.scrollable?this.renderScrollableTable(e):this.renderRegularTable(e)}},{key:"renderLoader",value:function(){if(this.props.loading){var t=i("p-treetable-loading-icon pi-spin",this.props.loadingIcon);return e.createElement("div",{className:"p-treetable-loading"},e.createElement("div",{className:"p-treetable-loading-overlay p-component-overlay"},e.createElement("i",{className:t})))}return null}},{key:"render",value:function(){var t=this,n=this.processValue(),o=i("p-treetable p-component",{"p-treetable-hoverable-rows":this.props.rowHover,"p-treetable-selectable":this.isRowSelectionMode(),"p-treetable-resizable":this.props.resizableColumns,"p-treetable-resizable-fit":this.props.resizableColumns&&"fit"===this.props.columnResizeMode,"p-treetable-auto-layout":this.props.autoLayout,"p-treetable-striped":this.props.stripedRows,"p-treetable-gridlines":this.props.showGridlines},this.props.className),r=this.renderTable(n),l=this.getTotalRecords(n),s=this.props.header&&e.createElement("div",{className:"p-treetable-header"},this.props.header),a=this.props.footer&&e.createElement("div",{className:"p-treetable-footer"},this.props.footer),p=this.props.paginator&&"bottom"!==this.props.paginatorPosition&&this.createPaginator("top",l),c=this.props.paginator&&"top"!==this.props.paginatorPosition&&this.createPaginator("bottom",l),u=this.renderLoader();return e.createElement("div",{id:this.props.id,className:o,style:this.props.style,ref:function(e){return t.container=e},"data-scrollselectors":".p-treetable-scrollable-body"},u,s,p,r,c,a,this.props.resizableColumns&&e.createElement("div",{ref:function(e){t.resizerHelper=e},className:"p-column-resizer-helper",style:{display:"none"}}),this.props.reorderableColumns&&e.createElement("span",{ref:function(e){return t.reorderIndicatorUp=e},className:"pi pi-arrow-down p-datatable-reorder-indicator-up",style:{position:"absolute",display:"none"}}),this.props.reorderableColumns&&e.createElement("span",{ref:function(e){return t.reorderIndicatorDown=e},className:"pi pi-arrow-up p-datatable-reorder-indicator-down",style:{position:"absolute",display:"none"}}))}}]),u}();O(pe,"defaultProps",{id:null,value:null,header:null,footer:null,style:null,className:null,tableStyle:null,tableClassName:null,expandedKeys:null,paginator:!1,paginatorPosition:"bottom",alwaysShowPaginator:!0,paginatorClassName:null,paginatorTemplate:"FirstPageLink PrevPageLink PageLinks NextPageLink LastPageLink RowsPerPageDropdown",paginatorLeft:null,paginatorRight:null,paginatorDropdownAppendTo:null,pageLinkSize:5,rowsPerPageOptions:null,currentPageReportTemplate:"({currentPage} of {totalPages})",first:null,rows:null,totalRecords:null,lazy:!1,sortField:null,sortOrder:null,multiSortMeta:null,sortMode:"single",defaultSortOrder:1,removableSort:!1,selectionMode:null,selectionKeys:null,contextMenuSelectionKey:null,metaKeySelection:!0,selectOnEdit:!0,propagateSelectionUp:!0,propagateSelectionDown:!0,autoLayout:!1,rowClassName:null,loading:!1,loadingIcon:"pi pi-spinner",tabIndex:0,scrollable:!1,scrollHeight:null,reorderableColumns:!1,headerColumnGroup:null,footerColumnGroup:null,frozenHeaderColumnGroup:null,frozenFooterColumnGroup:null,frozenWidth:null,resizableColumns:!1,columnResizeMode:"fit",emptyMessage:null,filters:null,globalFilter:null,filterMode:"lenient",filterDelay:300,filterLocale:void 0,rowHover:!1,showGridlines:!1,stripedRows:!1,onFilter:null,onExpand:null,onCollapse:null,onToggle:null,onPage:null,onSort:null,onSelect:null,onUnselect:null,onRowClick:null,onSelectionChange:null,onContextMenuSelectionChange:null,onColumnResizeEnd:null,onColReorder:null,onContextMenu:null});export{pe as TreeTable};