UNPKG

51.5 kBJavaScriptView Raw
1!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t=t||self).gridjs={})}(this,(function(t){"use strict";
2/*! *****************************************************************************
3 Copyright (c) Microsoft Corporation.
4
5 Permission to use, copy, modify, and/or distribute this software for any
6 purpose with or without fee is hereby granted.
7
8 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
9 REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
10 AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
11 INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
12 LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
13 OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
14 PERFORMANCE OF THIS SOFTWARE.
15 ***************************************************************************** */var e=function(t,n){return(e=Object.setPrototypeOf||{__proto__:[]}instanceof Array&&function(t,e){t.__proto__=e}||function(t,e){for(var n in e)e.hasOwnProperty(n)&&(t[n]=e[n])})(t,n)};function n(t,n){function r(){this.constructor=t}e(t,n),t.prototype=null===n?Object.create(n):(r.prototype=n.prototype,new r)}var r=function(){return(r=Object.assign||function(t){for(var e,n=1,r=arguments.length;n<r;n++)for(var o in e=arguments[n])Object.prototype.hasOwnProperty.call(e,o)&&(t[o]=e[o]);return t}).apply(this,arguments)};function o(t,e,n,r){return new(n||(n=Promise))((function(o,i){function s(t){try{u(r.next(t))}catch(t){i(t)}}function a(t){try{u(r.throw(t))}catch(t){i(t)}}function u(t){var e;t.done?o(t.value):(e=t.value,e instanceof n?e:new n((function(t){t(e)}))).then(s,a)}u((r=r.apply(t,e||[])).next())}))}function i(t,e){var n,r,o,i,s={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]};return i={next:a(0),throw:a(1),return:a(2)},"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function a(i){return function(a){return function(i){if(n)throw new TypeError("Generator is already executing.");for(;s;)try{if(n=1,r&&(o=2&i[0]?r.return:i[0]?r.throw||((o=r.return)&&o.call(r),0):r.next)&&!(o=o.call(r,i[1])).done)return o;switch(r=0,o&&(i=[2&i[0],o.value]),i[0]){case 0:case 1:o=i;break;case 4:return s.label++,{value:i[1],done:!1};case 5:s.label++,r=i[1],i=[0];continue;case 7:i=s.ops.pop(),s.trys.pop();continue;default:if(!(o=s.trys,(o=o.length>0&&o[o.length-1])||6!==i[0]&&2!==i[0])){s=0;continue}if(3===i[0]&&(!o||i[1]>o[0]&&i[1]<o[3])){s.label=i[1];break}if(6===i[0]&&s.label<o[1]){s.label=o[1],o=i;break}if(o&&s.label<o[2]){s.label=o[2],s.ops.push(i);break}o[2]&&s.ops.pop(),s.trys.pop();continue}i=e.call(t,s)}catch(t){i=[6,t],r=0}finally{n=o=0}if(5&i[0])throw i[1];return{value:i[0]?i[1]:void 0,done:!0}}([i,a])}}}function s(){for(var t=0,e=0,n=arguments.length;e<n;e++)t+=arguments[e].length;var r=Array(t),o=0;for(e=0;e<n;e++)for(var i=arguments[e],s=0,a=i.length;s<a;s++,o++)r[o]=i[s];return r}function a(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(t){var e=16*Math.random()|0;return("x"==t?e:3&e|8).toString(16)}))}var u,p,c,l,h,f,d,_=function(){function t(t){this._id=t||a()}return Object.defineProperty(t.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),t}(),y={},g=[],m=/acit|ex(?:s|g|n|p|$)|rph|grid|ows|mnc|ntw|ine[ch]|zoo|^ord|itera/i;function v(t,e){for(var n in e)t[n]=e[n];return t}function b(t){var e=t.parentNode;e&&e.removeChild(t)}function w(t,e,n){var r,o=arguments,i={};for(r in e)"key"!==r&&"ref"!==r&&(i[r]=e[r]);if(arguments.length>3)for(n=[n],r=3;r<arguments.length;r++)n.push(o[r]);if(null!=n&&(i.children=n),"function"==typeof t&&null!=t.defaultProps)for(r in t.defaultProps)void 0===i[r]&&(i[r]=t.defaultProps[r]);return P(t,i,e&&e.key,e&&e.ref,null)}function P(t,e,n,r,o){var i={type:t,props:e,key:n,ref:r,__k:null,__:null,__b:0,__e:null,__d:void 0,__c:null,constructor:void 0,__v:o};return null==o&&(i.__v=i),u.vnode&&u.vnode(i),i}function k(){return{current:null}}function S(t){return t.children}function x(t,e){this.props=t,this.context=e}function C(t,e){if(null==e)return t.__?C(t.__,t.__.__k.indexOf(t)+1):null;for(var n;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e)return n.__e;return"function"==typeof t.type?C(t):null}function N(t){var e,n;if(null!=(t=t.__)&&null!=t.__c){for(t.__e=t.__c.base=null,e=0;e<t.__k.length;e++)if(null!=(n=t.__k[e])&&null!=n.__e){t.__e=t.__c.base=n.__e;break}return N(t)}}function T(t){(!t.__d&&(t.__d=!0)&&c.push(t)&&!O.__r++||h!==u.debounceRendering)&&((h=u.debounceRendering)||l)(O)}function O(){for(var t;O.__r=c.length;)t=c.sort((function(t,e){return t.__v.__b-e.__v.__b})),c=[],t.some((function(t){var e,n,r,o,i,s,a;t.__d&&(s=(i=(e=t).__v).__e,(a=e.__P)&&(n=[],(r=v({},i)).__v=r,o=I(a,i,r,e.__n,void 0!==a.ownerSVGElement,null,n,null==s?C(i):s),A(n,i),o!=s&&N(i)))}))}function E(t,e,n,r,o,i,s,a,u,p){var c,l,h,f,d,_,m,v=r&&r.__k||g,w=v.length;for(u==y&&(u=null!=s?s[0]:w?C(r,0):null),n.__k=[],c=0;c<e.length;c++)if(null!=(f=n.__k[c]=null==(f=e[c])||"boolean"==typeof f?null:"string"==typeof f||"number"==typeof f?P(null,f,null,null,f):Array.isArray(f)?P(S,{children:f},null,null,null):null!=f.__e||null!=f.__c?P(f.type,f.props,f.key,null,f.__v):f)){if(f.__=n,f.__b=n.__b+1,null===(h=v[c])||h&&f.key==h.key&&f.type===h.type)v[c]=void 0;else for(l=0;l<w;l++){if((h=v[l])&&f.key==h.key&&f.type===h.type){v[l]=void 0;break}h=null}d=I(t,f,h=h||y,o,i,s,a,u,p),(l=f.ref)&&h.ref!=l&&(m||(m=[]),h.ref&&m.push(h.ref,null,f),m.push(l,f.__c||d,f)),null!=d?(null==_&&(_=d),u=D(t,f,h,v,s,d,u),"option"==n.type?t.value="":"function"==typeof n.type&&(n.__d=u)):u&&h.__e==u&&u.parentNode!=t&&(u=C(h))}if(n.__e=_,null!=s&&"function"!=typeof n.type)for(c=s.length;c--;)null!=s[c]&&b(s[c]);for(c=w;c--;)null!=v[c]&&H(v[c],v[c]);if(m)for(c=0;c<m.length;c++)M(m[c],m[++c],m[++c])}function D(t,e,n,r,o,i,s){var a,u,p;if(void 0!==e.__d)a=e.__d,e.__d=void 0;else if(o==n||i!=s||null==i.parentNode)t:if(null==s||s.parentNode!==t)t.appendChild(i),a=null;else{for(u=s,p=0;(u=u.nextSibling)&&p<r.length;p+=2)if(u==i)break t;t.insertBefore(i,s),a=s}return void 0!==a?a:i.nextSibling}function F(t,e,n){"-"===e[0]?t.setProperty(e,n):t[e]="number"==typeof n&&!1===m.test(e)?n+"px":null==n?"":n}function U(t,e,n,r,o){var i,s,a,u,p;if(o?"className"===e&&(e="class"):"class"===e&&(e="className"),"style"===e)if(i=t.style,"string"==typeof n)i.cssText=n;else{if("string"==typeof r&&(i.cssText="",r=null),r)for(u in r)n&&u in n||F(i,u,"");if(n)for(p in n)r&&n[p]===r[p]||F(i,p,n[p])}else"o"===e[0]&&"n"===e[1]?(s=e!==(e=e.replace(/Capture$/,"")),a=e.toLowerCase(),e=(a in t?a:e).slice(2),n?(r||t.addEventListener(e,L,s),(t.l||(t.l={}))[e]=n):t.removeEventListener(e,L,s)):"list"!==e&&"tagName"!==e&&"form"!==e&&"type"!==e&&"size"!==e&&!o&&e in t?t[e]=null==n?"":n:"function"!=typeof n&&"dangerouslySetInnerHTML"!==e&&(e!==(e=e.replace(/^xlink:?/,""))?null==n||!1===n?t.removeAttributeNS("http://www.w3.org/1999/xlink",e.toLowerCase()):t.setAttributeNS("http://www.w3.org/1999/xlink",e.toLowerCase(),n):null==n||!1===n&&!/^ar/.test(e)?t.removeAttribute(e):t.setAttribute(e,n))}function L(t){this.l[t.type](u.event?u.event(t):t)}function j(t,e,n){var r,o;for(r=0;r<t.__k.length;r++)(o=t.__k[r])&&(o.__=t,o.__e&&("function"==typeof o.type&&o.__k.length>1&&j(o,e,n),e=D(n,o,o,t.__k,null,o.__e,e),"function"==typeof t.type&&(t.__d=e)))}function I(t,e,n,r,o,i,s,a,p){var c,l,h,f,d,_,y,g,m,b,w,P=e.type;if(void 0!==e.constructor)return null;(c=u.__b)&&c(e);try{t:if("function"==typeof P){if(g=e.props,m=(c=P.contextType)&&r[c.__c],b=c?m?m.props.value:c.__:r,n.__c?y=(l=e.__c=n.__c).__=l.__E:("prototype"in P&&P.prototype.render?e.__c=l=new P(g,b):(e.__c=l=new x(g,b),l.constructor=P,l.render=W),m&&m.sub(l),l.props=g,l.state||(l.state={}),l.context=b,l.__n=r,h=l.__d=!0,l.__h=[]),null==l.__s&&(l.__s=l.state),null!=P.getDerivedStateFromProps&&(l.__s==l.state&&(l.__s=v({},l.__s)),v(l.__s,P.getDerivedStateFromProps(g,l.__s))),f=l.props,d=l.state,h)null==P.getDerivedStateFromProps&&null!=l.componentWillMount&&l.componentWillMount(),null!=l.componentDidMount&&l.__h.push(l.componentDidMount);else{if(null==P.getDerivedStateFromProps&&g!==f&&null!=l.componentWillReceiveProps&&l.componentWillReceiveProps(g,b),!l.__e&&null!=l.shouldComponentUpdate&&!1===l.shouldComponentUpdate(g,l.__s,b)||e.__v===n.__v){l.props=g,l.state=l.__s,e.__v!==n.__v&&(l.__d=!1),l.__v=e,e.__e=n.__e,e.__k=n.__k,l.__h.length&&s.push(l),j(e,a,t);break t}null!=l.componentWillUpdate&&l.componentWillUpdate(g,l.__s,b),null!=l.componentDidUpdate&&l.__h.push((function(){l.componentDidUpdate(f,d,_)}))}l.context=b,l.props=g,l.state=l.__s,(c=u.__r)&&c(e),l.__d=!1,l.__v=e,l.__P=t,c=l.render(l.props,l.state,l.context),l.state=l.__s,null!=l.getChildContext&&(r=v(v({},r),l.getChildContext())),h||null==l.getSnapshotBeforeUpdate||(_=l.getSnapshotBeforeUpdate(f,d)),w=null!=c&&c.type==S&&null==c.key?c.props.children:c,E(t,Array.isArray(w)?w:[w],e,n,r,o,i,s,a,p),l.base=e.__e,l.__h.length&&s.push(l),y&&(l.__E=l.__=null),l.__e=!1}else null==i&&e.__v===n.__v?(e.__k=n.__k,e.__e=n.__e):e.__e=R(n.__e,e,n,r,o,i,s,p);(c=u.diffed)&&c(e)}catch(t){e.__v=null,u.__e(t,e,n)}return e.__e}function A(t,e){u.__c&&u.__c(e,t),t.some((function(e){try{t=e.__h,e.__h=[],t.some((function(t){t.call(e)}))}catch(t){u.__e(t,e.__v)}}))}function R(t,e,n,r,o,i,s,a){var u,p,c,l,h,f=n.props,d=e.props;if(o="svg"===e.type||o,null!=i)for(u=0;u<i.length;u++)if(null!=(p=i[u])&&((null===e.type?3===p.nodeType:p.localName===e.type)||t==p)){t=p,i[u]=null;break}if(null==t){if(null===e.type)return document.createTextNode(d);t=o?document.createElementNS("http://www.w3.org/2000/svg",e.type):document.createElement(e.type,d.is&&{is:d.is}),i=null,a=!1}if(null===e.type)f!==d&&t.data!=d&&(t.data=d);else{if(null!=i&&(i=g.slice.call(t.childNodes)),c=(f=n.props||y).dangerouslySetInnerHTML,l=d.dangerouslySetInnerHTML,!a){if(null!=i)for(f={},h=0;h<t.attributes.length;h++)f[t.attributes[h].name]=t.attributes[h].value;(l||c)&&(l&&c&&l.__html==c.__html||(t.innerHTML=l&&l.__html||""))}(function(t,e,n,r,o){var i;for(i in n)"children"===i||"key"===i||i in e||U(t,i,null,n[i],r);for(i in e)o&&"function"!=typeof e[i]||"children"===i||"key"===i||"value"===i||"checked"===i||n[i]===e[i]||U(t,i,e[i],n[i],r)})(t,d,f,o,a),l?e.__k=[]:(u=e.props.children,E(t,Array.isArray(u)?u:[u],e,n,r,"foreignObject"!==e.type&&o,i,s,y,a)),a||("value"in d&&void 0!==(u=d.value)&&u!==t.value&&U(t,"value",u,f.value,!1),"checked"in d&&void 0!==(u=d.checked)&&u!==t.checked&&U(t,"checked",u,f.checked,!1))}return t}function M(t,e,n){try{"function"==typeof t?t(e):t.current=e}catch(t){u.__e(t,n)}}function H(t,e,n){var r,o,i;if(u.unmount&&u.unmount(t),(r=t.ref)&&(r.current&&r.current!==t.__e||M(r,null,e)),n||"function"==typeof t.type||(n=null!=(o=t.__e)),t.__e=t.__d=void 0,null!=(r=t.__c)){if(r.componentWillUnmount)try{r.componentWillUnmount()}catch(t){u.__e(t,e)}r.base=r.__P=null}if(r=t.__k)for(i=0;i<r.length;i++)r[i]&&H(r[i],e,n);null!=o&&b(o)}function W(t,e,n){return this.constructor(t,n)}function B(t,e,n){var r,o,i;u.__&&u.__(t,e),o=(r=n===f)?null:n&&n.__k||e.__k,t=w(S,null,[t]),i=[],I(e,(r?e:n||e).__k=t,o||y,y,void 0!==e.ownerSVGElement,n&&!r?[n]:o?null:e.childNodes.length?g.slice.call(e.childNodes):null,i,n||y,r),A(i,t)}u={__e:function(t,e){for(var n,r;e=e.__;)if((n=e.__c)&&!n.__)try{if(n.constructor&&null!=n.constructor.getDerivedStateFromError&&(r=!0,n.setState(n.constructor.getDerivedStateFromError(t))),null!=n.componentDidCatch&&(r=!0,n.componentDidCatch(t)),r)return T(n.__E=n)}catch(e){t=e}throw t}},p=function(t){return null!=t&&void 0===t.constructor},x.prototype.setState=function(t,e){var n;n=this.__s!==this.state?this.__s:this.__s=v({},this.state),"function"==typeof t&&(t=t(n,this.props)),t&&v(n,t),null!=t&&this.__v&&(e&&this.__h.push(e),T(this))},x.prototype.forceUpdate=function(t){this.__v&&(this.__e=!0,t&&this.__h.push(t),T(this))},x.prototype.render=S,c=[],l="function"==typeof Promise?Promise.prototype.then.bind(Promise.resolve()):setTimeout,O.__r=0,f=y,d=0;var q={search:{placeholder:"Type a keyword..."},sort:{sortAsc:"Sort column ascending",sortDesc:"Sort column descending"},pagination:{previous:"Previous",next:"Next",navigate:function(t,e){return"Page "+t+" of "+e},page:function(t){return"Page "+t},showing:"Showing",of:"of",to:"to",results:"results"},loading:"Loading...",noRecordsFound:"No matching records found",error:"An error happened while fetching the data"},G=function(){function t(t){this._language=t,this._defaultLanguage=q}return t.prototype.getString=function(t,e){if(!e||!t)return null;var n=t.split("."),r=n[0];if(e[r]){var o=e[r];return"string"==typeof o?function(){return o}:"function"==typeof o?o:this.getString(n.slice(1).join("."),o)}return null},t.prototype.translate=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r,o=this.getString(t,this._language);return(r=o||this.getString(t,this._defaultLanguage))?r.apply(void 0,e):t},t}();var K=function(t){function e(e,n){var r,o=t.call(this,e,n)||this;return o.config=function(t){if(!t)return null;var e=Object.keys(t);return e.length?t[e[0]].props.value:null}(n),o.config&&(o._=(r=o.config.translator,function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];return r.translate.apply(r,s([t],e))})),o}return n(e,t),e}(x),$=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.render=function(){return w(this.props.parentElement,{dangerouslySetInnerHTML:{__html:this.props.content}})},e.defaultProps={parentElement:"span"},e}(K);function z(t,e){return w($,{content:t,parentElement:e})}var V=function(t){function e(e){var n=t.call(this)||this;return n.setData(e),n}return n(e,t),e.prototype.cast=function(t){return t instanceof HTMLElement?z(t.outerHTML):t},e.prototype.setData=function(t){return this.data=this.cast(t),this},e}(_),Y=function(t){function e(e){var n=t.call(this)||this;return n.cells=e||[],n}return n(e,t),Object.defineProperty(e.prototype,"cells",{get:function(){return this._cells},set:function(t){this._cells=t},enumerable:!1,configurable:!0}),e.fromCells=function(t){return new e(t.map((function(t){return new V(t.data)})))},Object.defineProperty(e.prototype,"length",{get:function(){return this.cells.length},enumerable:!1,configurable:!0}),e}(_);var X=function(t){function e(e){var n=t.call(this)||this;return n.rows=e instanceof Array?e:e instanceof Y?[e]:[],n}return n(e,t),Object.defineProperty(e.prototype,"rows",{get:function(){return this._rows},set:function(t){this._rows=t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"length",{get:function(){return this._length||this.rows.length},set:function(t){this._length=t},enumerable:!1,configurable:!0}),e.fromRows=function(t){return new e(t.map((function(t){return Y.fromCells(t.cells)})))},e.fromArray=function(t){return new e((t=function(t){return!t[0]||t[0]instanceof Array?t:[t]}(t)).map((function(t){return new Y(t.map((function(t){return new V(t)})))})))},e}(_);function Z(t,e){return"string"==typeof t?t.indexOf("%")>-1?e/100*parseInt(t,10):parseInt(t,10):t}function J(t){return t?Math.floor(t)+"px":""}function Q(t,e){if(!t)return null;var n=t.querySelectorAll("tr:first-child > td");return n&&n[e]?n[e].clientWidth:null}var tt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.resetStyle=function(){return{padding:0,margin:0,border:"none",outline:"none"}},e.prototype.head=function(){var t=this;return w("thead",{style:this.resetStyle()},w("tr",null,this.props.header.columns.map((function(e){return w("th",{style:r(r({},t.resetStyle()),{whiteSpace:"nowrap",paddingRight:e.sort?"18px":"0"})},e.name)}))))},e.prototype.td=function(t){return w("td",{style:this.resetStyle()},t.data)},e.prototype.tr=function(t){var e=this;return w("tr",{style:this.resetStyle()},t.cells.map((function(t){return e.td(t)})))},e.prototype.body=function(){var t=this;return w("tbody",{style:this.resetStyle()},this.props.data&&this.props.data.rows.map((function(e){return t.tr(e)})))},e.prototype.render=function(){return w("table",{style:r({position:"absolute",zIndex:"-2147483640",visibility:"hidden",tableLayout:"auto",width:"auto"},this.resetStyle())},this.head(),this.body())},e}(K);var et,nt=function(t){function e(){var e=t.call(this)||this;return e._columns=[],e}return n(e,t),Object.defineProperty(e.prototype,"columns",{get:function(){return this._columns},set:function(t){this._columns=t},enumerable:!1,configurable:!0}),e.prototype.adjustWidth=function(t,e,n,r){if(void 0===r&&(r=!0),!t)return this;var o=t.clientWidth,i={current:null};if(n&&n.length&&r){var s=w(tt,{data:X.fromRows(n.rows.slice(0,10)),header:this});s.ref=i,B(s,e.current)}for(var a=0,u=this.columns;a<u.length;a++){var p=u[a];!p.width&&r?p.width=J(Q(i.current.base,this.columns.indexOf(p))):p.width=J(Z(p.width,o))}return n&&n.length&&r&&B(null,e.current),this},e.prototype.setSort=function(t){for(var e=0,n=this.columns;e<n.length;e++){var o=n[e];void 0===o.sort&&t.sort&&(o.sort={enabled:!0}),o.sort?"object"==typeof o.sort&&(o.sort=r({enabled:!0},o.sort)):o.sort={enabled:!1}}},e.prototype.setID=function(){for(var t=0,e=this.columns;t<e.length;t++){var n=e[t];n.id||"string"!=typeof n.name||(n.id=n.name.replace(/(?:^\w|[A-Z]|\b\w|\s+)/g,(function(t,e){return 0==+t?"":0===e?t.toLowerCase():t.toUpperCase()})))}},e.fromUserConfig=function(t){var n=new e;if(t.from)n.columns=e.fromHTMLTable(t.from).columns;else if(t.columns)for(var r=0,o=t.columns;r<o.length;r++){var i=o[r];"string"==typeof i||p(i)?n.columns.push({name:i}):"object"==typeof i&&n.columns.push(i)}else!t.data||"object"!=typeof t.data[0]||t.data[0]instanceof Array||(n.columns=Object.keys(t.data[0]).map((function(t){return{name:t}})));return n.columns.length?(n.setID(),n.setSort(t),n):null},e.fromHTMLTable=function(t){for(var n=new e,r=0,o=t.querySelector("thead").querySelectorAll("th");r<o.length;r++){var i=o[r];n.columns.push({name:i.innerText,width:i.width})}return n},e}(_),rt=function(){function t(){this._callbacks={},this._isDispatching=!1,this._isHandled={},this._isPending={},this._lastID=1}return t.prototype.register=function(t){var e="ID_"+this._lastID++;return this._callbacks[e]=t,e},t.prototype.unregister=function(t){if(!this._callbacks[t])throw Error("Dispatcher.unregister(...): "+t+" does not map to a registered callback.");delete this._callbacks[t]},t.prototype.waitFor=function(t){if(!this._isDispatching)throw Error("Dispatcher.waitFor(...): Must be invoked while dispatching.");for(var e=0;e<t.length;e++){var n=t[e];if(this._isPending[n]){if(!this._isHandled[n])throw Error("Dispatcher.waitFor(...): Circular dependency detected while ' +\n 'waiting for "+n+".")}else{if(!this._callbacks[n])throw Error("Dispatcher.waitFor(...): "+n+" does not map to a registered callback.");this._invokeCallback(n)}}},t.prototype.dispatch=function(t){if(this._isDispatching)throw Error("Dispatch.dispatch(...): Cannot dispatch in the middle of a dispatch.");this._startDispatching(t);try{for(var e in this._callbacks)this._isPending[e]||this._invokeCallback(e)}finally{this._stopDispatching()}},t.prototype.isDispatching=function(){return this._isDispatching},t.prototype._invokeCallback=function(t){this._isPending[t]=!0,this._callbacks[t](this._pendingPayload),this._isHandled[t]=!0},t.prototype._startDispatching=function(t){for(var e in this._callbacks)this._isPending[e]=!1,this._isHandled[e]=!1;this._pendingPayload=t,this._isDispatching=!0},t.prototype._stopDispatching=function(){delete this._pendingPayload,this._isDispatching=!1},t}(),ot=function(){},it=function(t){function e(e){var n=t.call(this)||this;return n.set(e),n}return n(e,t),e.prototype.get=function(){return o(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return[4,this.data()];case 1:return[2,{data:t=e.sent(),total:t.length}]}}))}))},e.prototype.set=function(t){return t instanceof Array?this.data=function(){return t}:t instanceof Function&&(this.data=t),this},e}(ot),st=new(function(){function t(){}return t.prototype.format=function(t,e){return"[Grid.js] ["+e.toUpperCase()+"]: "+t},t.prototype.error=function(t,e){void 0===e&&(e=!1);var n=this.format(t,"error");if(e)throw Error(n);console.error(n)},t.prototype.warn=function(t){console.warn(this.format(t,"warn"))},t.prototype.info=function(t){console.info(this.format(t,"info"))},t}()),at=function(t){function e(e){var n=t.call(this)||this;return n.options=e,n}return n(e,t),e.prototype.handler=function(t){return"function"==typeof this.options.handle?this.options.handle(t):t.ok?t.json():(st.error("Could not fetch data: "+t.status+" - "+t.statusText,!0),null)},e.prototype.get=function(t){var e=r(r({},this.options),t);return fetch(e.url,e).then(this.handler.bind(this)).then((function(t){return{data:e.then(t),total:"function"==typeof e.total?e.total(t):void 0}}))},e}(ot),ut=function(){function t(){}return t.createFromUserConfig=function(t){var e=null;return t.data&&(e=new it(t.data)),t.from&&(e=new it(this.tableElementToArray(t.from)),t.from.style.display="none"),t.server&&(e=new at(t.server)),e||st.error("Could not determine the storage type",!0),e},t.tableElementToArray=function(t){for(var e=[],n=0,r=t.querySelector("tbody").querySelectorAll("tr");n<r.length;n++){for(var o=[],i=0,s=r[n].querySelectorAll("td");i<s.length;i++){var a=s[i];1===a.childNodes.length&&a.childNodes[0].nodeType===Node.TEXT_NODE?o.push(a.innerText):o.push(z(a.innerHTML))}e.push(o)}return e},t}(),pt=function(){function t(){}return t.prototype.init=function(t){this.callbacks||(this.callbacks={}),t&&!this.callbacks[t]&&(this.callbacks[t]=[])},t.prototype.on=function(t,e){return this.init(t),this.callbacks[t].push(e),this},t.prototype.off=function(t,e){var n=t;return this.init(),this.callbacks[n]&&0!==this.callbacks[n].length?(this.callbacks[n]=this.callbacks[n].filter((function(t){return t!=e})),this):this},t.prototype.emit=function(t){for(var e=[],n=1;n<arguments.length;n++)e[n-1]=arguments[n];var r=t;return this.init(r),this.callbacks[r].length>0&&(this.callbacks[r].forEach((function(t){return t.apply(void 0,e)})),!0)},t}();!function(t){t[t.Initiator=0]="Initiator",t[t.ServerFilter=1]="ServerFilter",t[t.ServerSort=2]="ServerSort",t[t.ServerLimit=3]="ServerLimit",t[t.Extractor=4]="Extractor",t[t.Transformer=5]="Transformer",t[t.Filter=6]="Filter",t[t.Sort=7]="Sort",t[t.Limit=8]="Limit"}(et||(et={}));var ct,lt=function(t){function e(e){var n=t.call(this)||this;return n._props={},n.id=a(),e&&n.setProps(e),n}return n(e,t),e.prototype.process=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.validateProps instanceof Function&&this.validateProps.apply(this,t),this.emit.apply(this,s(["beforeProcess"],t));var n=this._process.apply(this,t);return this.emit.apply(this,s(["afterProcess"],t)),n},e.prototype.setProps=function(t){return Object.assign(this._props,t),this.emit("propsUpdated",this),this},Object.defineProperty(e.prototype,"props",{get:function(){return this._props},enumerable:!1,configurable:!0}),e}(pt),ht=function(t){function e(e){var n=t.call(this)||this;return n._steps=new Map,n.cache=new Map,n.lastProcessorIndexUpdated=-1,e&&e.forEach((function(t){return n.register(t)})),n}return n(e,t),e.prototype.clearCache=function(){this.cache=new Map,this.lastProcessorIndexUpdated=-1},e.prototype.register=function(t,e){if(void 0===e&&(e=null),null===t.type)throw Error("Processor type is not defined");t.on("propsUpdated",this.processorPropsUpdated.bind(this)),this.addProcessorByPriority(t,e),this.afterRegistered(t)},e.prototype.unregister=function(t){if(t){var e=this._steps.get(t.type);e&&e.length&&(this._steps.set(t.type,e.filter((function(e){return e!=t}))),this.emit("updated",t))}},e.prototype.addProcessorByPriority=function(t,e){var n=this._steps.get(t.type);if(!n){var r=[];this._steps.set(t.type,r),n=r}if(null===e||e<0)n.push(t);else if(n[e]){var o=n.slice(0,e-1),i=n.slice(e+1);this._steps.set(t.type,o.concat(t).concat(i))}else n[e]=t},Object.defineProperty(e.prototype,"steps",{get:function(){for(var t=[],e=0,n=this.getSortedProcessorTypes();e<n.length;e++){var r=n[e],o=this._steps.get(r);o&&o.length&&(t=t.concat(o))}return t.filter((function(t){return t}))},enumerable:!1,configurable:!0}),e.prototype.getStepsByType=function(t){return this.steps.filter((function(e){return e.type===t}))},e.prototype.getSortedProcessorTypes=function(){return Object.keys(et).filter((function(t){return!isNaN(Number(t))})).map((function(t){return Number(t)}))},e.prototype.process=function(t){return o(this,void 0,void 0,(function(){var e,n,r,o,s,a,u;return i(this,(function(i){switch(i.label){case 0:e=this.lastProcessorIndexUpdated,n=this.steps,r=t,i.label=1;case 1:i.trys.push([1,7,,8]),o=0,s=n,i.label=2;case 2:return o<s.length?(a=s[o],this.findProcessorIndexByID(a.id)>=e?[4,a.process(r)]:[3,4]):[3,6];case 3:return r=i.sent(),this.cache.set(a.id,r),[3,5];case 4:r=this.cache.get(a.id),i.label=5;case 5:return o++,[3,2];case 6:return[3,8];case 7:throw u=i.sent(),st.error(u),this.emit("error",r),u;case 8:return this.lastProcessorIndexUpdated=n.length,this.emit("afterProcess",r),[2,r]}}))}))},e.prototype.findProcessorIndexByID=function(t){return this.steps.findIndex((function(e){return e.id==t}))},e.prototype.setLastProcessorIndex=function(t){var e=this.findProcessorIndexByID(t.id);this.lastProcessorIndexUpdated>e&&(this.lastProcessorIndexUpdated=e)},e.prototype.processorPropsUpdated=function(t){this.setLastProcessorIndex(t),this.emit("propsUpdated"),this.emit("updated",t)},e.prototype.afterRegistered=function(t){this.setLastProcessorIndex(t),this.emit("afterRegister"),this.emit("updated",t)},e}(pt),ft=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return et.Extractor},enumerable:!1,configurable:!0}),e.prototype._process=function(t){return o(this,void 0,void 0,(function(){return i(this,(function(e){switch(e.label){case 0:return[4,this.props.storage.get(t)];case 1:return[2,e.sent()]}}))}))},e}(lt),dt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return et.Transformer},enumerable:!1,configurable:!0}),e.prototype._process=function(t){var e=X.fromArray(t.data);return e.length=t.total,e},e}(lt),_t=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return et.Initiator},enumerable:!1,configurable:!0}),e.prototype._process=function(){return{url:this.props.serverStorageOptions.url,method:this.props.serverStorageOptions.method}},e}(lt),yt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return et.Transformer},enumerable:!1,configurable:!0}),e.prototype.castData=function(t){var e=this;return t&&t.length?t[0]instanceof Array?t:"object"!=typeof t[0]||t[0]instanceof Array?[]:t.map((function(t){return e.props.header.columns.map((function(e){return t[e.id]}))})):[]},e.prototype._process=function(t){return{data:this.castData(t.data),total:t.total}},e}(lt),gt=function(){function t(){}return t.createFromConfig=function(t){var e=new ht;return t.storage instanceof at&&e.register(new _t({serverStorageOptions:t.server})),e.register(new ft({storage:t.storage})),e.register(new yt({header:t.header})),e.register(new dt),e},t}(),mt=function(){function t(e){Object.assign(this,r(r({},t.defaultConfig()),e)),this._userConfig={}}return t.prototype.assign=function(t){for(var e=0,n=Object.keys(t);e<n.length;e++){var r=n[e];"_userConfig"!==r&&(this[r]=t[r])}return this},t.prototype.update=function(e){return e?(this._userConfig=r(r({},this._userConfig),e),this.assign(t.fromUserConfig(this._userConfig)),this):this},t.defaultConfig=function(){return{dispatcher:new rt,tempRef:{current:null},width:"100%",autoWidth:!0,style:{},className:{}}},t.fromUserConfig=function(e){var n=new t(e);return n._userConfig=e,"boolean"==typeof e.sort&&e.sort&&n.assign({sort:{multiColumn:!0}}),n.assign({header:nt.fromUserConfig(n)}),n.assign({storage:ut.createFromUserConfig(e)}),n.assign({pipeline:gt.createFromConfig(n)}),n.assign({pagination:r({enabled:!0===e.pagination||e.pagination instanceof Object},e.pagination)}),n.assign({search:r({enabled:!0===e.search||e.search instanceof Object},e.search)}),n.assign({translator:new G(e.language)}),n},t}();function vt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];var n="gridjs";return""+n+t.reduce((function(t,e){return t+"-"+e}),"")}function bt(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];return t.filter((function(t){return t})).reduce((function(t,e){return(t||"")+" "+e}),"").trim()}!function(t){t[t.Init=0]="Init",t[t.Loading=1]="Loading",t[t.Loaded=2]="Loaded",t[t.Rendered=3]="Rendered",t[t.Error=4]="Error"}(ct||(ct={}));var wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.content=function(){return this.props.column&&"function"==typeof this.props.column.formatter?this.props.column.formatter(this.props.cell.data,this.props.row,this.props.column):this.props.cell.data},e.prototype.handleClick=function(t){this.config.eventEmitter.emit("cellClick",t,this.props.cell,this.props.column,this.props.row)},e.prototype.render=function(){return w("td",{role:this.props.role,colSpan:this.props.colSpan,className:bt(vt("td"),this.props.className,this.config.className.td),style:r({},this.config.style.td),onClick:this.handleClick.bind(this)},this.content())},e}(K),Pt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.getColumn=function(t){return this.props.header?this.props.header.columns[t]:null},e.prototype.handleClick=function(t){this.config.eventEmitter.emit("rowClick",t,this.props.row)},e.prototype.render=function(){var t=this;return this.props.children?w("tr",{className:vt("tr")},this.props.children):w("tr",{className:vt("tr"),onClick:this.handleClick.bind(this)},this.props.row.cells.map((function(e,n){return w(wt,{key:e.id,cell:e,row:t.props.row,column:t.getColumn(n)})})))},e}(K),kt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.render=function(){return w(Pt,null,w(wt,{role:"alert",colSpan:this.props.colSpan,cell:new V(this.props.message),className:bt(vt("message"),this.props.className?this.props.className:null)}))},e}(K),St=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.headerLength=function(){return this.props.header?this.props.header.columns.length:0},e.prototype.render=function(){var t=this;return w("tbody",{className:vt("tbody")},this.props.data&&this.props.data.rows.map((function(e){return w(Pt,{key:e.id,row:e,header:t.props.header})})),this.props.status===ct.Loading&&(!this.props.data||0===this.props.data.length)&&w(kt,{message:this._("loading"),colSpan:this.headerLength(),className:vt("loading")}),this.props.status===ct.Loaded&&this.props.data&&0===this.props.data.length&&w(kt,{message:this._("noRecordsFound"),colSpan:this.headerLength(),className:vt("notfound")}),this.props.status===ct.Error&&w(kt,{message:this._("error"),colSpan:this.headerLength(),className:vt("error")}))},e}(K),xt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.validateProps=function(){for(var t=0,e=this.props.columns;t<e.length;t++){var n=e[t];void 0===n.direction&&(n.direction=1),1!==n.direction&&-1!==n.direction&&st.error("Invalid sort direction "+n.direction)}},Object.defineProperty(e.prototype,"type",{get:function(){return et.Sort},enumerable:!1,configurable:!0}),e.prototype.compare=function(t,e){return t>e?1:t<e?-1:0},e.prototype.compareWrapper=function(t,e){for(var n=0,r=0,o=this.props.columns;r<o.length;r++){var i=o[r];if(0!==n)break;var s=t.cells[i.index].data,a=e.cells[i.index].data;"function"==typeof i.compare?n|=i.compare(s,a)*i.direction:n|=this.compare(s,a)*i.direction}return n},e.prototype._process=function(t){var e=s(t.rows);e.sort(this.compareWrapper.bind(this));var n=new X(e);return n.length=t.length,n},e}(lt),Ct=function(t){function e(e){var n=t.call(this)||this;return n.dispatcher=e,n._state=n.getInitialState(),e.register(n._handle.bind(n)),n}return n(e,t),e.prototype._handle=function(t){this.handle(t.type,t.payload)},e.prototype.setState=function(t){var e=this._state;this._state=t,this.emit("updated",t,e)},Object.defineProperty(e.prototype,"state",{get:function(){return this._state},enumerable:!1,configurable:!0}),e}(pt),Nt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.getInitialState=function(){return[]},e.prototype.handle=function(t,e){if("SORT_COLUMN"===t){var n=e.index,r=e.direction,o=e.multi,i=e.compare;this.sortColumn(n,r,o,i)}else if("SORT_COLUMN_TOGGLE"===t){n=e.index,o=e.multi,i=e.compare;this.sortToggle(n,o,i)}},e.prototype.sortToggle=function(t,e,n){var r=s(this.state).find((function(e){return e.index===t}));r?this.sortColumn(t,1===r.direction?-1:1,e,n):this.sortColumn(t,1,e,n)},e.prototype.sortColumn=function(t,e,n,r){var o=s(this.state),i=o.length,a=o.find((function(e){return e.index===t})),u=!1,p=!1,c=!1,l=!1;if(void 0!==a?n?-1===a.direction?c=!0:l=!0:1===i?l=!0:i>1&&(p=!0,u=!0):0===i?u=!0:i>0&&!n?(u=!0,p=!0):i>0&&n&&(u=!0),p&&(o=[]),u)o.push({index:t,direction:e,compare:r});else if(l){var h=o.indexOf(a);o[h].direction=e}else if(c){var f=o.indexOf(a);o.splice(f,1)}this.setState(o)},e}(Ct),Tt=function(){function t(t){this.dispatcher=t}return t.prototype.dispatch=function(t,e){this.dispatcher.dispatch({type:t,payload:e})},t}(),Ot=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.sortColumn=function(t,e,n,r){this.dispatch("SORT_COLUMN",{index:t,direction:e,multi:n,compare:r})},e.prototype.sortToggle=function(t,e,n){this.dispatch("SORT_COLUMN_TOGGLE",{index:t,multi:e,compare:n})},e}(Tt),Et=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return et.ServerSort},enumerable:!1,configurable:!0}),e.prototype._process=function(t){var e={};return this.props.url&&(e.url=this.props.url(t.url,this.props.columns)),this.props.body&&(e.body=this.props.body(t.body,this.props.columns)),r(r({},t),e)},e}(lt),Dt=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.actions=new Ot(r.config.dispatcher),r.store=new Nt(r.config.dispatcher),e.enabled&&(r.sortProcessor=r.getOrCreateSortProcessor(),r.updateStateFn=r.updateState.bind(r),r.store.on("updated",r.updateStateFn),r.state={direction:0}),r}return n(e,t),e.prototype.componentWillUnmount=function(){this.config.pipeline.unregister(this.sortProcessor),this.store.off("updated",this.updateStateFn),this.updateSortProcessorFn&&this.store.off("updated",this.updateSortProcessorFn)},e.prototype.updateState=function(){var t=this,e=this.store.state.find((function(e){return e.index===t.props.index}));e?this.setState({direction:e.direction}):this.setState({direction:0})},e.prototype.updateSortProcessor=function(t){this.sortProcessor.setProps({columns:t})},e.prototype.getOrCreateSortProcessor=function(){var t=et.Sort;this.config.sort&&"object"==typeof this.config.sort.server&&(t=et.ServerSort);var e,n=this.config.pipeline.getStepsByType(t);return n.length>0?e=n[0]:(this.updateSortProcessorFn=this.updateSortProcessor.bind(this),this.store.on("updated",this.updateSortProcessorFn),e=t===et.ServerSort?new Et(r({columns:this.store.state},this.config.sort.server)):new xt({columns:this.store.state}),this.config.pipeline.register(e)),e},e.prototype.changeDirection=function(t){t.preventDefault(),t.stopPropagation(),this.actions.sortToggle(this.props.index,!0===t.shiftKey&&this.config.sort.multiColumn,this.props.compare)},e.prototype.render=function(){if(!this.props.enabled)return null;var t=this.state.direction,e="neutral";return 1===t?e="asc":-1===t&&(e="desc"),w("button",{tabIndex:-1,"aria-label":this._("sort.sort"+(1===t?"Desc":"Asc")),title:this._("sort.sort"+(1===t?"Desc":"Asc")),className:bt(vt("sort"),vt("sort",e)),onClick:this.changeDirection.bind(this)})},e}(K),Ft=function(t){function e(){var e=null!==t&&t.apply(this,arguments)||this;return e.sortRef={current:null},e}return n(e,t),e.prototype.isSortable=function(){return this.props.column.sort.enabled},e.prototype.onClick=function(t){t.stopPropagation(),this.isSortable()&&this.sortRef.current.changeDirection(t)},e.prototype.keyDown=function(t){this.isSortable()&&13===t.which&&this.onClick(t)},e.prototype.render=function(){var t={};return this.isSortable()&&(t.tabIndex=0),w("th",r({className:bt(vt("th"),this.isSortable()?vt("th","sort"):null,this.config.className.th),onClick:this.onClick.bind(this),style:r(r({},this.config.style.th),{width:this.props.column.width}),onKeyDown:this.keyDown.bind(this)},t),this.props.column.name,this.isSortable()&&w(Dt,r({ref:this.sortRef,index:this.props.index},this.props.column.sort)))},e}(K),Ut=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.render=function(){return this.props.header?w("thead",{key:this.props.header.id,className:vt("thead")},w(Pt,null,this.props.header.columns.map((function(t,e){return w(Ft,{column:t,index:e})})))):null},e}(K),Lt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.render=function(){return w("table",{role:"grid",className:bt(vt("table"),this.config.className.table),style:r(r({},this.config.style.table),{width:this.props.width})},w(Ut,{header:this.props.header}),w(St,{data:this.props.data,status:this.props.status,header:this.props.header}))},e}(K);var jt,It,At,Rt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return et.Filter},enumerable:!1,configurable:!0}),e.prototype._process=function(t){return this.props.keyword?(e=String(this.props.keyword).trim(),n=t,e=e.replace(/[-[\]{}()*+?.,\\^$|#\s]/g,"\\$&"),new X(n.rows.filter((function(t){return t.cells.some((function(t){if(!t||!t.data)return!1;var n="";if("object"==typeof t.data){var r=t.data;r.props&&r.props.content&&(n=r.props.content)}else n=String(t.data);return new RegExp(e,"gi").test(n)}))})))):t;var e,n},e}(lt),Mt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.getInitialState=function(){return{keyword:null}},e.prototype.handle=function(t,e){if("SEARCH_KEYWORD"===t){var n=e.keyword;this.search(n)}},e.prototype.search=function(t){this.setState({keyword:t})},e}(Ct),Ht=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.search=function(t){this.dispatch("SEARCH_KEYWORD",{keyword:t})},e}(Tt),Wt=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return et.ServerFilter},enumerable:!1,configurable:!0}),e.prototype._process=function(t){if(!this.props.keyword)return t;var e={};return this.props.url&&(e.url=this.props.url(t.url,this.props.keyword)),this.props.body&&(e.body=this.props.body(t.body,this.props.keyword)),r(r({},t),e)},e}(lt),Bt=function(t){function e(e,n){var r=t.call(this,e,n)||this;r.actions=new Ht(r.config.dispatcher),r.store=new Mt(r.config.dispatcher);var o=e.enabled,i=e.keyword;if(o){r.actions.search(i),r.storeUpdatedFn=r.storeUpdated.bind(r),r.store.on("updated",r.storeUpdatedFn);var s=void 0;s=e.server?new Wt({keyword:e.keyword,url:e.server.url,body:e.server.body}):new Rt({keyword:e.keyword}),r.searchProcessor=s,r.config.pipeline.register(s)}return r}return n(e,t),e.prototype.componentWillUnmount=function(){this.config.pipeline.unregister(this.searchProcessor),this.store.off("updated",this.storeUpdatedFn)},e.prototype.storeUpdated=function(t){this.searchProcessor.setProps({keyword:t.keyword})},e.prototype.onChange=function(t){var e=t.target.value;this.actions.search(e)},e.prototype.render=function(){if(!this.props.enabled)return null;var t,e,n,r=this.onChange.bind(this);return this.searchProcessor instanceof Wt&&(t=r,e=this.props.debounceTimeout,r=function(){for(var r=[],o=0;o<arguments.length;o++)r[o]=arguments[o];return new Promise((function(o){n&&clearTimeout(n),n=setTimeout((function(){return o(t.apply(void 0,r))}),e)}))}),w("div",{className:vt("search")},w("input",{type:"search",placeholder:this._("search.placeholder"),"aria-label":this._("search.placeholder"),onInput:r,className:bt(vt("input"),vt("search","input")),value:this.store.state.keyword}))},e.defaultProps={debounceTimeout:250},e}(K),qt=0,Gt=[],Kt=u.__r,$t=u.diffed,zt=u.__c,Vt=u.unmount;function Yt(t,e){u.__h&&u.__h(It,t,qt||e),qt=0;var n=It.__H||(It.__H={__:[],__h:[]});return t>=n.__.length&&n.__.push({}),n.__[t]}function Xt(t){return qt=5,function(t,e){var n=Yt(jt++,7);return ee(n.__H,e)?(n.__H=e,n.__h=t,n.__=t()):n.__}((function(){return{current:t}}),[])}function Zt(){Gt.some((function(t){if(t.__P)try{t.__H.__h.forEach(Qt),t.__H.__h.forEach(te),t.__H.__h=[]}catch(e){return t.__H.__h=[],u.__e(e,t.__v),!0}})),Gt=[]}u.__r=function(t){Kt&&Kt(t),jt=0;var e=(It=t.__c).__H;e&&(e.__h.forEach(Qt),e.__h.forEach(te),e.__h=[])},u.diffed=function(t){$t&&$t(t);var e=t.__c;e&&e.__H&&e.__H.__h.length&&(1!==Gt.push(e)&&At===u.requestAnimationFrame||((At=u.requestAnimationFrame)||function(t){var e,n=function(){clearTimeout(r),Jt&&cancelAnimationFrame(e),setTimeout(t)},r=setTimeout(n,100);Jt&&(e=requestAnimationFrame(n))})(Zt))},u.__c=function(t,e){e.some((function(t){try{t.__h.forEach(Qt),t.__h=t.__h.filter((function(t){return!t.__||te(t)}))}catch(n){e.some((function(t){t.__h&&(t.__h=[])})),e=[],u.__e(n,t.__v)}})),zt&&zt(t,e)},u.unmount=function(t){Vt&&Vt(t);var e=t.__c;if(e&&e.__H)try{e.__H.__.forEach(Qt)}catch(t){u.__e(t,e.__v)}};var Jt="function"==typeof requestAnimationFrame;function Qt(t){"function"==typeof t.u&&t.u()}function te(t){t.u=t.__()}function ee(t,e){return!t||e.some((function(e,n){return e!==t[n]}))}var ne=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.headerRef=Xt(null),r.state={isActive:!0},r}return n(e,t),e.prototype.componentDidMount=function(){0===this.headerRef.current.children.length&&this.setState({isActive:!1})},e.prototype.render=function(){return this.state.isActive?w("div",{ref:this.headerRef,className:bt(vt("head"),this.config.className.header),style:r({},this.config.style.header)},w(Bt,r({},this.config.search))):null},e}(K),re=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),e.prototype.validateProps=function(){if(isNaN(Number(this.props.limit))||isNaN(Number(this.props.page)))throw Error("Invalid parameters passed")},Object.defineProperty(e.prototype,"type",{get:function(){return et.Limit},enumerable:!1,configurable:!0}),e.prototype._process=function(t){var e=this.props.page,n=e*this.props.limit,r=(e+1)*this.props.limit;return new X(t.rows.slice(n,r))},e}(lt),oe=function(t){function e(){return null!==t&&t.apply(this,arguments)||this}return n(e,t),Object.defineProperty(e.prototype,"type",{get:function(){return et.ServerLimit},enumerable:!1,configurable:!0}),e.prototype._process=function(t){var e={};return this.props.url&&(e.url=this.props.url(t.url,this.props.page,this.props.limit)),this.props.body&&(e.body=this.props.body(t.body,this.props.page,this.props.limit)),r(r({},t),e)},e}(lt),ie=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.state={limit:e.limit,page:e.page||0,total:0},r}return n(e,t),e.prototype.componentWillMount=function(){var t=this;if(this.props.enabled){var e=void 0;this.setTotalFromTabularFn=this.setTotalFromTabular.bind(this),this.props.server?(e=new oe({limit:this.state.limit,page:this.state.page,url:this.props.server.url,body:this.props.server.body}),this.config.pipeline.on("afterProcess",this.setTotalFromTabularFn)):(e=new re({limit:this.state.limit,page:this.state.page})).on("beforeProcess",this.setTotalFromTabularFn),this.processor=e,this.config.pipeline.register(e),this.config.pipeline.on("error",(function(){t.setState({total:0,page:0})}))}},e.prototype.setTotalFromTabular=function(t){this.setTotal(t.length)},e.prototype.onUpdate=function(t){this.props.resetPageOnUpdate&&t!==this.processor&&this.setPage(0)},e.prototype.componentDidMount=function(){this.onUpdateFn=this.onUpdate.bind(this),this.config.pipeline.on("updated",this.onUpdateFn)},e.prototype.componentWillUnmount=function(){this.config.pipeline.unregister(this.processor),this.config.pipeline.off("updated",this.onUpdateFn)},Object.defineProperty(e.prototype,"pages",{get:function(){return Math.ceil(this.state.total/this.state.limit)},enumerable:!1,configurable:!0}),e.prototype.setPage=function(t){if(t>=this.pages||t<0||t===this.state.page)return null;this.setState({page:t}),this.processor.setProps({page:t})},e.prototype.setTotal=function(t){this.setState({total:t})},e.prototype.renderPages=function(){var t=this;if(this.props.buttonsCount<=0)return null;var e=Math.min(this.pages,this.props.buttonsCount),n=Math.min(this.state.page,Math.floor(e/2));return this.state.page+Math.floor(e/2)>=this.pages&&(n=e-(this.pages-this.state.page)),w(S,null,this.pages>e&&this.state.page-n>0&&w(S,null,w("button",{tabIndex:0,onClick:this.setPage.bind(this,0),title:this._("pagination.firstPage")},this._("1")),w("button",{tabIndex:-1,className:vt("spread")},"...")),Array.from(Array(e).keys()).map((function(e){return t.state.page+(e-n)})).map((function(e){return w("button",{tabIndex:0,onClick:t.setPage.bind(t,e),className:t.state.page===e?vt("currentPage"):null,title:t._("pagination.page",e+1)},t._(""+(e+1)))})),this.pages>e&&this.pages>this.state.page+n+1&&w(S,null,w("button",{tabIndex:-1,className:vt("spread")},"..."),w("button",{tabIndex:0,onClick:this.setPage.bind(this,this.pages-1),title:this._("pagination.page",this.pages)},this._(""+this.pages))))},e.prototype.renderSummary=function(){return w(S,null,this.props.summary&&this.state.total>0&&w("div",{role:"status",className:vt("summary"),title:this._("pagination.navigate",this.state.page+1,this.pages)},this._("pagination.showing")," ",w("b",null,this._(""+(this.state.page*this.state.limit+1)))," ",this._("pagination.to")," ",w("b",null,this._(""+Math.min((this.state.page+1)*this.state.limit,this.state.total)))," ",this._("pagination.of")," ",w("b",null,this._(""+this.state.total))," ",this._("pagination.results")))},e.prototype.render=function(){return this.props.enabled?w("div",{className:vt("pagination")},this.renderSummary(),w("div",{className:vt("pages")},this.props.prevButton&&w("button",{tabIndex:0,disabled:0===this.state.page,onClick:this.setPage.bind(this,this.state.page-1)},this._("pagination.previous")),this.renderPages(),this.props.nextButton&&w("button",{tabIndex:0,disabled:this.pages===this.state.page+1||0===this.pages,onClick:this.setPage.bind(this,this.state.page+1)},this._("pagination.next")))):null},e.defaultProps={summary:!0,nextButton:!0,prevButton:!0,buttonsCount:3,limit:10,resetPageOnUpdate:!0},e}(K),se=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.footerRef=Xt(null),r.state={isActive:!0},r}return n(e,t),e.prototype.componentDidMount=function(){0===this.footerRef.current.children.length&&this.setState({isActive:!1})},e.prototype.render=function(){return this.state.isActive?w("div",{ref:this.footerRef,className:bt(vt("footer"),this.config.className.footer),style:r({},this.config.style.footer)},w(ie,r({},this.config.pagination))):null},e}(K),ae=function(t){function e(e,n){var r=t.call(this,e,n)||this;return r.configContext=function(t){var e={},n={__c:"__cC"+d++,__:t,Consumer:function(t,e){return t.children(e)},Provider:function(t){var r,o=this;return this.getChildContext||(r=[],this.getChildContext=function(){return e[n.__c]=o,e},this.shouldComponentUpdate=function(t){o.props.value!==t.value&&r.some((function(e){e.context=t.value,T(e)}))},this.sub=function(t){r.push(t);var e=t.componentWillUnmount;t.componentWillUnmount=function(){r.splice(r.indexOf(t),1),e&&e.call(t)}}),t.children}};return n.Consumer.contextType=n,n.Provider.__=n,n}(null),r.state={status:ct.Loading,header:e.header,data:null},r}return n(e,t),e.prototype.processPipeline=function(){return o(this,void 0,void 0,(function(){var t,e;return i(this,(function(n){switch(n.label){case 0:this.props.config.eventEmitter.emit("beforeLoad"),this.setState({status:ct.Loading}),n.label=1;case 1:return n.trys.push([1,3,,4]),[4,this.props.pipeline.process()];case 2:return t=n.sent(),this.setState({data:t,status:ct.Loaded}),this.props.config.eventEmitter.emit("load",t),[3,4];case 3:return e=n.sent(),st.error(e),this.setState({status:ct.Error,data:null}),[3,4];case 4:return[2]}}))}))},e.prototype.componentDidMount=function(){return o(this,void 0,void 0,(function(){var t;return i(this,(function(e){switch(e.label){case 0:return t=this.props.config,[4,this.processPipeline()];case 1:return e.sent(),t.header&&this.state.data&&this.state.data.length&&this.setState({header:t.header.adjustWidth(t.container,t.tempRef,this.state.data,t.autoWidth)}),this.processPipelineFn=this.processPipeline.bind(this),this.props.pipeline.on("updated",this.processPipelineFn),[2]}}))}))},e.prototype.componentWillUnmount=function(){this.props.pipeline.off("updated",this.processPipelineFn)},e.prototype.render=function(){return w(this.configContext.Provider,{value:this.props.config},w("div",{role:"complementary",className:bt("gridjs",vt("container"),this.state.status===ct.Loading?vt("loading"):null,this.props.config.className.container),style:r(r({},this.props.config.style.container),{width:this.props.width})},this.state.status===ct.Loading&&w("div",{className:vt("loading-bar")}),w(ne,null),w("div",{className:vt("wrapper"),style:{width:this.props.width}},w(Lt,{data:this.state.data,header:this.state.header,width:this.props.width,status:this.state.status})),w(se,null)),w("div",{ref:this.props.config.tempRef,id:"gridjs-temp",className:vt("temp")}))},e}(K),ue=function(t){function e(e){var n=t.call(this)||this;return n.config=new mt({eventEmitter:n}).update(e),n}return n(e,t),e.prototype.updateConfig=function(t){return this.config.update(t),this},e.prototype.createElement=function(){return w(ae,{config:this.config,pipeline:this.config.pipeline,header:this.config.header,width:this.config.width})},e.prototype.forceRender=function(){return this.config&&this.config.container||st.error("Container is empty. Make sure you call render() before forceRender()",!0),this.config.pipeline.clearCache(),B(null,this.config.container),B(this.createElement(),this.config.container),this},e.prototype.render=function(t){return t||st.error("Container element cannot be null",!0),t.childNodes.length>0?(st.error("The container element "+t+" is not empty. Make sure the container is empty and call render() again"),this):(this.config.container=t,B(this.createElement(),t),this)},e}(pt);t.Component=x,t.Config=mt,t.Grid=ue,t.createElement=w,t.createRef=k,t.h=w,t.html=z,t.useEffect=function(t,e){var n=Yt(jt++,3);!u.__s&&ee(n.__H,e)&&(n.__=t,n.__H=e,It.__H.__h.push(n))},t.useRef=Xt,Object.defineProperty(t,"__esModule",{value:!0})}));
16//# sourceMappingURL=gridjs.production.min.js.map