react-tree-selector
Version:
Lightweight, customizable and fast Dropdown Tree Select component for React
12 lines • 57.2 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("react")):"function"==typeof define&&define.amd?define("ReactDropdownTreeSelect",["react"],t):"object"==typeof exports?exports.ReactDropdownTreeSelect=t(require("react")):e.ReactDropdownTreeSelect=t(e.React)}(this,function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=11)}([function(e,t,n){e.exports=n(9)()},function(t,n){t.exports=e},function(e,t,n){var r;
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/*!
Copyright (c) 2017 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
!function(){"use strict";var n={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var a=typeof r;if("string"===a||"number"===a)e.push(this&&this[r]||r);else if(Array.isArray(r))e.push(o.apply(this,r));else if("object"===a)for(var i in r)n.call(r,i)&&r[i]&&e.push(this&&this[i]||i)}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){},function(e,t,n){var r;r=function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={exports:{},id:r,loaded:!1};return e[r].call(o.exports,o,o.exports,n),o.loaded=!0,o.exports}return n.m=e,n.c=t,n.p="",n(0)}([function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var r=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},o=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),a=function(e,t,n){for(var r=!0;r;){var o=e,a=t,i=n;r=!1,null===o&&(o=Function.prototype);var l=Object.getOwnPropertyDescriptor(o,a);if(void 0!==l){if("value"in l)return l.value;var s=l.get;if(void 0===s)return;return s.call(i)}var c=Object.getPrototypeOf(o);if(null===c)return;e=c,t=a,n=i,r=!0,l=c=void 0}};function i(e){return e&&e.__esModule?e:{default:e}}var l=n(8),s=i(l),c=i(n(6)),u=i(n(2)),h=n(1),d=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),a(Object.getPrototypeOf(t.prototype),"constructor",this).call(this),this.state={showLoader:!1,lastScrollTop:0,actionTriggered:!1,pullToRefreshThresholdBreached:!1},this.startY=0,this.currentY=0,this.dragging=!1,this.maxPullDownDistance=0,this.onScrollListener=this.onScrollListener.bind(this),this.throttledOnScrollListener=(0,u.default)(this.onScrollListener,150).bind(this),this.onStart=this.onStart.bind(this),this.onMove=this.onMove.bind(this),this.onEnd=this.onEnd.bind(this),this.getScrollableTarget=this.getScrollableTarget.bind(this)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,l.Component),o(t,[{key:"componentDidMount",value:function(){if(this._scrollableNode=this.getScrollableTarget(),this.el=this.props.height?this._infScroll:this._scrollableNode||window,this.el.addEventListener("scroll",this.throttledOnScrollListener),"number"==typeof this.props.initialScrollY&&this.el.scrollHeight>this.props.initialScrollY&&this.el.scrollTo(0,this.props.initialScrollY),this.props.pullDownToRefresh&&(this.el.addEventListener("touchstart",this.onStart),this.el.addEventListener("touchmove",this.onMove),this.el.addEventListener("touchend",this.onEnd),this.el.addEventListener("mousedown",this.onStart),this.el.addEventListener("mousemove",this.onMove),this.el.addEventListener("mouseup",this.onEnd),this.maxPullDownDistance=this._pullDown.firstChild.getBoundingClientRect().height,this.forceUpdate(),"function"!=typeof this.props.refreshFunction))throw new Error('Mandatory prop "refreshFunction" missing.\n Pull Down To Refresh functionality will not work\n as expected. Check README.md for usage\'')}},{key:"componentWillUnmount",value:function(){this.el.removeEventListener("scroll",this.throttledOnScrollListener),this.props.pullDownToRefresh&&(this.el.removeEventListener("touchstart",this.onStart),this.el.removeEventListener("touchmove",this.onMove),this.el.removeEventListener("touchend",this.onEnd),this.el.removeEventListener("mousedown",this.onStart),this.el.removeEventListener("mousemove",this.onMove),this.el.removeEventListener("mouseup",this.onEnd))}},{key:"componentWillReceiveProps",value:function(e){this.props.key===e.key&&this.props.dataLength===e.dataLength||this.setState({showLoader:!1,actionTriggered:!1,pullToRefreshThresholdBreached:!1})}},{key:"getScrollableTarget",value:function(){return this.props.scrollableTarget instanceof HTMLElement?this.props.scrollableTarget:"string"==typeof this.props.scrollableTarget?document.getElementById(this.props.scrollableTarget):(null===this.props.scrollableTarget&&console.warn("You are trying to pass scrollableTarget but it is null. This might\n happen because the element may not have been added to DOM yet.\n See https://github.com/ankeetmaini/react-infinite-scroll-component/issues/59 for more info.\n "),null)}},{key:"onStart",value:function(e){this.state.lastScrollTop||(this.dragging=!0,this.startY=e.pageY||e.touches[0].pageY,this.currentY=this.startY,this._infScroll.style.willChange="transform",this._infScroll.style.transition="transform 0.2s cubic-bezier(0,0,0.31,1)")}},{key:"onMove",value:function(e){this.dragging&&(this.currentY=e.pageY||e.touches[0].pageY,this.currentY<this.startY||(this.currentY-this.startY>=this.props.pullDownToRefreshThreshold&&this.setState({pullToRefreshThresholdBreached:!0}),this.currentY-this.startY>1.5*this.maxPullDownDistance||(this._infScroll.style.overflow="visible",this._infScroll.style.transform="translate3d(0px, "+(this.currentY-this.startY)+"px, 0px)")))}},{key:"onEnd",value:function(e){var t=this;this.startY=0,this.currentY=0,this.dragging=!1,this.state.pullToRefreshThresholdBreached&&this.props.refreshFunction&&this.props.refreshFunction(),requestAnimationFrame(function(){t._infScroll&&(t._infScroll.style.overflow="auto",t._infScroll.style.transform="none",t._infScroll.style.willChange="none")})}},{key:"isElementAtBottom",value:function(e){var t=arguments.length<=1||void 0===arguments[1]?.8:arguments[1],n=e===document.body||e===document.documentElement?window.screen.availHeight:e.clientHeight,r=(0,h.parseThreshold)(t);return r.unit===h.ThresholdUnits.Pixel?e.scrollTop+n>=e.scrollHeight-r.value:e.scrollTop+n>=r.value/100*e.scrollHeight}},{key:"onScrollListener",value:function(e){var t=this;"function"==typeof this.props.onScroll&&setTimeout(function(){return t.props.onScroll(e)},0);var n=this.props.height||this._scrollableNode?e.target:document.documentElement.scrollTop?document.documentElement:document.body;this.state.actionTriggered||(this.isElementAtBottom(n,this.props.scrollThreshold)&&this.props.hasMore&&(this.setState({actionTriggered:!0,showLoader:!0}),this.props.next()),this.setState({lastScrollTop:n.scrollTop}))}},{key:"render",value:function(){var e=this,t=r({height:this.props.height||"auto",overflow:"auto",WebkitOverflowScrolling:"touch"},this.props.style),n=this.props.hasChildren||!(!this.props.children||!this.props.children.length),o=this.props.pullDownToRefresh&&this.props.height?{overflow:"auto"}:{};return s.default.createElement("div",{style:o},s.default.createElement("div",{className:"infinite-scroll-component "+(this.props.className||""),ref:function(t){return e._infScroll=t},style:t},this.props.pullDownToRefresh&&s.default.createElement("div",{style:{position:"relative"},ref:function(t){return e._pullDown=t}},s.default.createElement("div",{style:{position:"absolute",left:0,right:0,top:-1*this.maxPullDownDistance}},!this.state.pullToRefreshThresholdBreached&&this.props.pullDownToRefreshContent,this.state.pullToRefreshThresholdBreached&&this.props.releaseToRefreshContent)),this.props.children,!this.state.showLoader&&!n&&this.props.hasMore&&this.props.loader,this.state.showLoader&&this.props.hasMore&&this.props.loader,!this.props.hasMore&&this.props.endMessage))}}]),t}();t.default=d,d.defaultProps={pullDownToRefreshContent:s.default.createElement("h3",null,"Pull down to refresh"),releaseToRefreshContent:s.default.createElement("h3",null,"Release to refresh"),pullDownToRefreshThreshold:100,disableBrowserPullToRefresh:!0},d.propTypes={next:c.default.func,hasMore:c.default.bool,children:c.default.node,loader:c.default.node.isRequired,scrollThreshold:c.default.oneOfType([c.default.number,c.default.string]),endMessage:c.default.node,style:c.default.object,height:c.default.number,scrollableTarget:c.default.node,hasChildren:c.default.bool,pullDownToRefresh:c.default.bool,pullDownToRefreshContent:c.default.node,releaseToRefreshContent:c.default.node,pullDownToRefreshThreshold:c.default.number,refreshFunction:c.default.func,onScroll:c.default.func,dataLength:c.default.number.isRequired,key:c.default.string},e.exports=t.default},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.parseThreshold=function(e){if("number"==typeof e)return{unit:n.Percent,value:100*e};if("string"==typeof e)return e.match(/^(\d*(\.\d+)?)px$/)?{unit:n.Pixel,value:parseFloat(e)}:e.match(/^(\d*(\.\d+)?)%$/)?{unit:n.Percent,value:parseFloat(e)}:(console.warn('scrollThreshold format is invalid. Valid formats: "120px", "50%"...'),r);return console.warn("scrollThreshold should be string or number"),r};var n={Pixel:"Pixel",Percent:"Percent"};t.ThresholdUnits=n;var r={unit:n.Percent,value:.8}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e,t,n){var r,o;return t||(t=250),function(){var a=n||this,i=+new Date,l=arguments;r&&i<r+t?(clearTimeout(o),o=setTimeout(function(){r=i,e.apply(a,l)},t)):(r=i,e.apply(a,l))}},e.exports=t.default},function(e,t){"use strict";function n(e){return function(){return e}}var r=function(){};r.thatReturns=n,r.thatReturnsFalse=n(!1),r.thatReturnsTrue=n(!0),r.thatReturnsNull=n(null),r.thatReturnsThis=function(){return this},r.thatReturnsArgument=function(e){return e},e.exports=r},function(e,t,n){"use strict";var r=function(e){};e.exports=function(e,t,n,o,a,i,l,s){if(r(t),!e){var c;if(void 0===t)c=new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");else{var u=[n,o,a,i,l,s],h=0;(c=new Error(t.replace(/%s/g,function(){return u[h++]}))).name="Invariant Violation"}throw c.framesToPop=1,c}}},function(e,t,n){"use strict";var r=n(3),o=n(4),a=n(7);e.exports=function(){function e(e,t,n,r,i,l){l!==a&&o(!1,"Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types")}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t};return n.checkPropTypes=r,n.PropTypes=n,n}},function(e,t,n){e.exports=n(5)()},function(e,t){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(t,n){t.exports=e}])},e.exports=r(n(1))},function(e,t,n){"use strict";e.exports=function(e,t){var n=e.filter(t);return 0!==n.length&&n.length!==e.length}},function(e,t,n){"use strict";var r=n(10);function o(){}function a(){}a.resetWarningCache=o,e.exports=function(){function e(e,t,n,o,a,i){if(i!==r){var l=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw l.name="Invariant Violation",l}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:o};return n.PropTypes=n,n}},function(e,t,n){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},function(e,t,n){"use strict";n.r(t);var r,o,a,i=n(2),l=n.n(i),s=n(0),c=n.n(s),u=n(1),h=n.n(u),d=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{};return Object.keys(e).reduce(function(t,n){var r;return t["data-"+(r=n,r.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase())]=e[n],t},{})},p=(function(){}(),function(e){return!e||Array.isArray(e)&&!e.length}),f=function(e,t){return e instanceof Event&&!function(e){if(e.path)return e.path;for(var t=e.target,n=[t];t.parentElement;)t=t.parentElement,n.unshift(t);return n}(e).some(function(e){return e===t})},g=function(e,t){var n=void 0;return function(){for(var r=arguments.length,o=Array(r),a=0;a<r;a++)o[a]=arguments[a];var i=!n;clearTimeout(n),n=setTimeout(function(){n=null,e.apply(void 0,o)},t),i&&e.apply(void 0,o)}},y=(r="rdts",o=1,a=new WeakMap,{get:function(e){return a.has(e)||a.set(e,o++),""+r+a.get(e)},reset:function(){a=new WeakMap,o=1}}),b=n(5),v=n.n(b),m=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function w(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var O=l.a.bind(v.a),k=function(e){return e+"_tag"},T=function(e){function t(){var e,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return n=r=w(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),r.handleClick=function(e){var t=r.props,n=t.id,o=t.onDelete;e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),o(n,void 0!==(e.key||e.keyCode))},r.onKeyDown=function(e){"Backspace"===e.key&&(r.handleClick(e),e.preventDefault())},r.onKeyUp=function(e){(32===e.keyCode||["Delete","Enter"].indexOf(e.key)>-1)&&(r.handleClick(e),e.preventDefault())},w(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),m(t,[{key:"render",value:function(){var e=this.props,t=e.id,n=e.label,r=e.labelRemove,o=void 0===r?"Remove":r,a=e.readOnly,i=e.disabled,l=k(t),s=t+"_button",c=O("tag-remove",{readOnly:a},{disabled:i}),u=a||i;return h.a.createElement("span",{className:O("tag"),id:l,"aria-label":n},n,h.a.createElement("button",{id:s,onClick:u?void 0:this.handleClick,onKeyDown:u?void 0:this.onKeyDown,onKeyUp:u?void 0:this.onKeyUp,className:c,type:"button","aria-label":o,"aria-labelledby":s+" "+l,"aria-disabled":u},"x"))}}]),t}();T.propTypes={id:c.a.string.isRequired,label:c.a.string.isRequired,onDelete:c.a.func,readOnly:c.a.bool,disabled:c.a.bool,labelRemove:c.a.string};var _=T,P=n(6),S=n.n(P);function C(e,t){var n=function(e){if(!e)return{};if("#"===e[0])return{"aria-labelledby":e.substring(1).replace(/ #/g," ")};return{"aria-label":e}}(e);return t&&(n["aria-labelledby"]=((n["aria-labelledby"]||"")+" "+t).trim()),n}var E=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}(),x=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e};var N=l.a.bind(S.a),j=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return n.handleInputChange=function(e){e.persist(),n.delayedCallback(e)},n.delayedCallback=g(function(e){return n.props.onInputChange(e.target.value)},300),n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),E(t,[{key:"render",value:function(){var e=this.props,t=e.tags,n=e.onTagRemove,r=e.inputRef,o=e.texts,a=void 0===o?{}:o,i=e.onFocus,l=e.onBlur,s=e.disabled,c=e.readOnly,u=e.onKeyDown,p=e.activeDescendant;return h.a.createElement("ul",{className:N("tag-list")},function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[],t=arguments[1],n=arguments[2],r=arguments[3],o=arguments[4];return e.map(function(e){var a=e._id,i=e.label,l=e.tagClassName,s=e.dataset;return h.a.createElement("li",x({className:N("tag-item",l),key:"tag-item-"+a},d(s)),h.a.createElement(_,{label:i,id:a,onDelete:t,readOnly:n,disabled:r,labelRemove:o}))})}(t,n,c,s,a.labelRemove),h.a.createElement("li",{className:N("tag-item")},h.a.createElement("input",x({type:"text",disabled:s,ref:r,className:N("search"),placeholder:a.placeholder||"Choose...",onKeyDown:u,onChange:this.handleInputChange,onFocus:i,onBlur:l,readOnly:c,"aria-activedescendant":p,"aria-autocomplete":u?"list":void 0},C(a.label)))))}}]),t}();j.propTypes={tags:c.a.array,texts:c.a.object,onInputChange:c.a.func,onFocus:c.a.func,onBlur:c.a.func,onTagRemove:c.a.func,onKeyDown:c.a.func,inputRef:c.a.func,disabled:c.a.bool,readOnly:c.a.bool,activeDescendant:c.a.string};var D=j,M=n(4),I=n.n(M),R=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},A=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function F(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var L=l.a.bind(I.a),B=function(e){function t(){var e,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return n=r=F(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),r.getAriaAttributes=function(){var e=r.props,t=e.mode,n=e.texts,o=void 0===n?{}:n,a=e.showDropdown,i=e.clientId,l=e.tags,s=i+"_trigger",c=[],u=C(o.label);return l&&l.length&&(u["aria-label"]&&c.push(s),l.forEach(function(e){c.push(k(e._id))}),u=C(o.label,c.join(" "))),R({id:s,role:"button",tabIndex:0,"aria-haspopup":"simpleSelect"===t?"listbox":"tree","aria-expanded":a?"true":"false"},u)},r.handleTrigger=function(e){e.key&&13!==e.keyCode&&32!==e.keyCode&&40!==e.keyCode||e.key&&r.triggerNode&&r.triggerNode!==document.activeElement||(r.props.showDropdown||32!==e.keyCode||e.preventDefault(),r.props.onTrigger(e))},F(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),A(t,[{key:"render",value:function(){var e=this,t=this.props,n=t.disabled,r=t.readOnly,o=t.showDropdown,a=L({"dropdown-trigger":!0,arrow:!0,disabled:n,readOnly:r,top:o,bottom:!o});return h.a.createElement("a",R({ref:function(t){e.triggerNode=t},className:a,onClick:n?void 0:this.handleTrigger,onKeyDown:n?void 0:this.handleTrigger},this.getAriaAttributes()),this.props.children)}}]),t}();B.propTypes={onTrigger:c.a.func,disabled:c.a.bool,readOnly:c.a.bool,showDropdown:c.a.bool,mode:c.a.oneOf(["multiSelect","simpleSelect","radioSelect","hierarchical"]),texts:c.a.object,clientId:c.a.string,tags:c.a.array};var V=B,Y=n(7),K=n.n(Y),q=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function H(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var U=function(e){function t(){var e,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return n=r=H(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),r.handleClick=function(){var e=r.props,t=e.onAction,n=e.actionData;t&&t(n.nodeId,n.action)},H(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),q(t,[{key:"render",value:function(){var e=this.props,t=e.title,n=e.className,r=e.text,o=e.readOnly;return h.a.createElement("i",{title:t,className:n,onClick:o?void 0:this.handleClick},r)}}]),t}();U.propTypes={title:c.a.string,text:c.a.string,className:c.a.string,actionData:c.a.object,onAction:c.a.func,readOnly:c.a.bool},U.defaultProps={onAction:function(){}};var W=U,z=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},$=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var J=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),$(t,[{key:"render",value:function(){var e=this.props,t=e.actions,n=e.id,r=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["actions","id"]);return p(t)?null:t.map(function(e,t){var o=e.id||"action-"+t;return h.a.createElement(W,z({key:o},r,e,{actionData:{action:z({},e,{id:o}),nodeId:n}}))})}}]),t}();J.propTypes={id:c.a.string.isRequired,actions:c.a.array};var Z=J,G=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Q=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var X=function(e){var t=e.checked,n=e.indeterminate;return function(e){e&&(e.checked=t,e.indeterminate=n)}},ee=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),Q(t,[{key:"render",value:function(){var e=this.props,t=e.checked,n=e.indeterminate,r=void 0!==n&&n,o=e.onChange,a=e.disabled,i=e.readOnly,l=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["checked","indeterminate","onChange","disabled","readOnly"]),s=a||i;return h.a.createElement("input",G({type:"checkbox",ref:X({checked:t,indeterminate:r}),onChange:o,disabled:s},l))}}]),t}();ee.propTypes={checked:c.a.bool,indeterminate:c.a.bool,onChange:c.a.func,disabled:c.a.bool,readOnly:c.a.bool};var te=ee,ne=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},re=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var oe=function(e){var t=e.checked;return function(e){e&&(e.checked=t)}},ae=function(e){function t(){return function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t),function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).apply(this,arguments))}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),re(t,[{key:"render",value:function(){var e=this.props,t=e.name,n=e.checked,r=e.onChange,o=e.disabled,a=e.readOnly,i=function(e,t){var n={};for(var r in e)t.indexOf(r)>=0||Object.prototype.hasOwnProperty.call(e,r)&&(n[r]=e[r]);return n}(e,["name","checked","onChange","disabled","readOnly"]),l=o||a;return h.a.createElement("input",ne({type:"radio",name:t,ref:oe({checked:n}),onChange:r,disabled:l},i))}}]),t}();ae.propTypes={name:c.a.string.isRequired,checked:c.a.bool,onChange:c.a.func,disabled:c.a.bool,readOnly:c.a.bool};var ie=ae,le=n(3),se=n.n(le),ce=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},ue=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function he(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var de=l.a.bind(se.a),pe=function(e){function t(){var e,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return n=r=he(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),r.handleCheckboxChange=function(e){var t=r.props,n=t.mode,o=t.id,a=t.onCheckboxChange;"simpleSelect"===n||"radioSelect"===n?a(o,!0):a(o,e.target.checked);e.stopPropagation(),e.nativeEvent.stopImmediatePropagation()},he(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),ue(t,[{key:"render",value:function(){var e=this.props,t=e.mode,n=e.title,r=e.label,o=e.id,a=e.partial,i=e.checked,l=this.props,s=l.value,c=l.disabled,u=l.showPartiallySelected,d=l.readOnly,p=l.clientId,f={className:"node-label"};"simpleSelect"===t&&!d&&!c&&(f.onClick=this.handleCheckboxChange);var g={id:o,value:s,checked:i,disabled:c,readOnly:d,tabIndex:-1};return h.a.createElement("label",{title:n||r,htmlFor:o},"radioSelect"===t?h.a.createElement(ie,ce({name:p,className:"radio-item",onChange:this.handleCheckboxChange},g)):h.a.createElement(te,ce({name:o,className:de("checkbox-item",{"simple-select":"simpleSelect"===t}),indeterminate:u&&a,onChange:this.handleCheckboxChange},g)),h.a.createElement("span",f,r))}}]),t}();pe.propTypes={id:c.a.string.isRequired,actions:c.a.array,title:c.a.string,label:c.a.string.isRequired,value:c.a.string.isRequired,checked:c.a.bool,partial:c.a.bool,disabled:c.a.bool,dataset:c.a.object,mode:c.a.oneOf(["multiSelect","simpleSelect","radioSelect","hierarchical"]),showPartiallySelected:c.a.bool,onCheckboxChange:c.a.func,readOnly:c.a.bool,clientId:c.a.string};var fe=pe,ge=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function ye(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var be=l.a.bind(se.a),ve=function(e){function t(){var e,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return n=r=ye(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),r.onToggle=function(e){e.stopPropagation(),e.nativeEvent.stopImmediatePropagation(),r.props.onNodeToggle(r.props.id)},r.onKeyDown=function(e){"Enter"!==e.key&&32!==e.keyCode||(r.props.onNodeToggle(r.props.id),e.preventDefault())},ye(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),ge(t,[{key:"render",value:function(){var e=this.props,t=e.expanded;if(e.isLeaf)return null;var n=be("toggle",{expanded:t,collapsed:!t});return h.a.createElement("i",{role:"button",tabIndex:-1,className:n,onClick:this.onToggle,onKeyDown:this.onKeyDown,"aria-hidden":!0})}}]),t}();ve.propTypes={expanded:c.a.bool,isLeaf:c.a.bool,onNodeToggle:c.a.func,id:c.a.string};var me=ve,we=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Oe=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();function ke(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}var Te=l.a.bind(se.a),_e=function(e){return p(e)},Pe=function(e){function t(){var e,n,r;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);for(var o=arguments.length,a=Array(o),i=0;i<o;i++)a[i]=arguments[i];return n=r=ke(this,(e=t.__proto__||Object.getPrototypeOf(t)).call.apply(e,[this].concat(a))),r.getAriaAttributes=function(){var e=r.props,t=e._children,n=e._depth,o=e.checked,a=e.disabled,i=e.expanded,l=e.readOnly,s=e.mode,c=e.partial,u={};return u.role="simpleSelect"===s?"option":"treeitem",u["aria-disabled"]=a||l,u["aria-selected"]=o,"simpleSelect"!==s&&(u["aria-checked"]=c?"mixed":o,u["aria-level"]=(n||0)+1,u["aria-expanded"]=t&&(i?"true":"false")),u},ke(r,n)}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["PureComponent"]),Oe(t,[{key:"render",value:function(){var e=this.props,t=e.mode,n=e.keepTreeOnSearch,r=e._id,o=e._children,a=e.dataset,i=e._depth,l=e.expanded,s=e.title,c=e.label,u=e.partial,p=e.checked,f=e.value,g=e.disabled,y=e.actions,b=e.onAction,v=e.searchModeOn,m=e.onNodeToggle,w=e.onCheckboxChange,O=e.showPartiallySelected,k=e.readOnly,T=e.clientId,_=function(e){var t=e.keepTreeOnSearch,n=e.keepChildrenOnSearch,r=e._children,o=e.matchInChildren,a=e.matchInParent,i=e.disabled,l=e.partial,s=e.hide,c=e.className,u=e.showPartiallySelected,h=e.readOnly,d=e.checked,p=e._focused;return Te("node",{leaf:_e(r),tree:!_e(r),disabled:i,hide:s,"match-in-children":t&&o,"match-in-parent":t&&n&&a,partial:u&&l,readOnly:h,checked:d,focused:p},c)}(this.props),P=n||!v?{paddingLeft:20*(i||0)+"px"}:{},S=r+"_li";return h.a.createElement("li",we({className:_,style:P,id:S},d(a),this.getAriaAttributes()),h.a.createElement(me,{isLeaf:_e(o),expanded:l,id:r,onNodeToggle:m}),h.a.createElement(fe,{title:s,label:c,id:r,partial:u,checked:p,value:f,disabled:g,mode:t,onCheckboxChange:w,showPartiallySelected:O,readOnly:k,clientId:T}),h.a.createElement(Z,{actions:y,onAction:b,id:r,readOnly:k}))}}]),t}();Pe.propTypes={_id:c.a.string.isRequired,_depth:c.a.number,_children:c.a.array,actions:c.a.array,className:c.a.string,title:c.a.string,label:c.a.string.isRequired,value:c.a.string.isRequired,checked:c.a.bool,expanded:c.a.bool,disabled:c.a.bool,partial:c.a.bool,dataset:c.a.object,keepTreeOnSearch:c.a.bool,keepChildrenOnSearch:c.a.bool,searchModeOn:c.a.bool,onNodeToggle:c.a.func,onAction:c.a.func,onCheckboxChange:c.a.func,mode:c.a.oneOf(["multiSelect","simpleSelect","radioSelect","hierarchical"]),showPartiallySelected:c.a.bool,readOnly:c.a.bool,clientId:c.a.string};var Se=Pe,Ce=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},Ee=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var xe=function(e){function t(e){!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,t);var n=function(e,t){if(!e)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return!t||"object"!=typeof t&&"function"!=typeof t?e:t}(this,(t.__proto__||Object.getPrototypeOf(t)).call(this,e));return Ne.call(n),n.currentPage=1,n.computeInstanceProps(e,!0),n.state={items:n.allVisibleNodes.slice(0,n.props.pageSize)},n}return function(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function, not "+typeof t);e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,enumerable:!1,writable:!0,configurable:!0}}),t&&(Object.setPrototypeOf?Object.setPrototypeOf(e,t):e.__proto__=t)}(t,u["Component"]),Ee(t,[{key:"render",value:function(){var e=this.props.searchModeOn;return h.a.createElement("ul",Ce({className:"root "+(e?"searchModeOn":""),ref:this.setNodeRef},this.getAriaAttributes()),this.state.scrollableTarget&&h.a.createElement(K.a,{dataLength:this.state.items.length,next:this.loadMore,hasMore:this.hasMore(),loader:h.a.createElement("span",{className:"searchLoader"},"Loading..."),scrollableTarget:this.state.scrollableTarget},this.state.items))}}]),t}();xe.propTypes={data:c.a.object,keepTreeOnSearch:c.a.bool,keepChildrenOnSearch:c.a.bool,searchModeOn:c.a.bool,onChange:c.a.func,onNodeToggle:c.a.func,onAction:c.a.func,onCheckboxChange:c.a.func,mode:c.a.oneOf(["multiSelect","simpleSelect","radioSelect","hierarchical"]),showPartiallySelected:c.a.bool,pageSize:c.a.number,readOnly:c.a.bool,clientId:c.a.string,activeDescendant:c.a.string},xe.defaultProps={pageSize:100};var Ne=function(){var e=this;this.componentWillReceiveProps=function(t){var n=t.activeDescendant,r=n===e.props.activeDescendant;e.computeInstanceProps(t,!r),e.setState({items:e.allVisibleNodes.slice(0,e.currentPage*e.props.pageSize)},function(){if(!r){var t=e.state.scrollableTarget,o=n&&document&&document.getElementById(n);o&&t&&(t.scrollTop=o.offsetTop-(t.clientHeight-o.clientHeight)/2)}})},this.componentDidMount=function(){e.setState({scrollableTarget:e.node.parentNode})},this.computeInstanceProps=function(t,n){if(e.allVisibleNodes=e.getNodes(t),e.totalPages=Math.ceil(e.allVisibleNodes.length/e.props.pageSize),n&&t.activeDescendant){var r=t.activeDescendant.replace(/_li$/,""),o=e.allVisibleNodes.findIndex(function(e){return e.key===r})+1;e.currentPage=o>0?Math.ceil(o/e.props.pageSize):1}},this.getNodes=function(e){var t=e.data,n=e.keepTreeOnSearch,r=e.keepChildrenOnSearch,o=e.searchModeOn,a=e.mode,i=e.showPartiallySelected,l=e.readOnly,s=e.onAction,c=e.onChange,u=e.onCheckboxChange,d=e.onNodeToggle,p=e.activeDescendant,f=e.clientId,g=[];return t.forEach(function(e){(function(e,t,n){if(t||e.expanded)return!0;var r=e._parent&&n.get(e._parent);return!r||r.expanded})(e,o,t)&&g.push(e)}),!n&&o&&(g=g.sort(function(e,t){return e.label>t.label?1:-1})),g.map(function(e){return h.a.createElement(Se,Ce({keepTreeOnSearch:n,keepChildrenOnSearch:r,key:e._id},e,{searchModeOn:o,onChange:c,onCheckboxChange:u,onNodeToggle:d,onAction:s,mode:a,showPartiallySelected:i,readOnly:l,clientId:f,activeDescendant:p}))})},this.hasMore=function(){return e.currentPage<e.totalPages},this.loadMore=function(){e.currentPage=e.currentPage+1;var t=e.allVisibleNodes.slice(0,e.currentPage*e.props.pageSize);e.setState({items:t})},this.setNodeRef=function(t){e.node=t},this.getAriaAttributes=function(){var t=e.props.mode;return{role:"simpleSelect"===t?"listbox":"tree","aria-multiselectable":/multiSelect|hierarchical/.test(t)}}},je=xe,De=n(8),Me=n.n(De),Ie=function(e){return e},Re=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"children",n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:Ie;return Me()(e[t],function(e){return n(e).checked})||e[t].some(function(e){return n(e).partial})};var Ae=function(e){var t=e.tree,n=e.simple,r=e.radio,o=e.showPartialState,a=e.hierarchical,i=e.rootPrefixId;return function e(t){var n=t.nodes,r=t.parent,o=t.depth,a=void 0===o?0:o,i=t.simple,l=t.radio,s=t.showPartialState,c=t.hierarchical,u=t.rootPrefixId,h=t._rv,d=void 0===h?{list:new Map,defaultValues:[],singleSelectedNode:null}:h,f=i||l;return n.forEach(function(t,n){t._depth=a,r?(t._id=t.id||r._id+"-"+n,t._parent=r._id,r._children.push(t._id)):t._id=t.id||""+(u?u+"-"+n:n),f&&t.checked&&(d.singleSelectedNode?t.checked=!1:d.singleSelectedNode=t),f&&t.isDefaultValue&&d.singleSelectedNode&&!d.singleSelectedNode.isDefaultValue&&(d.singleSelectedNode.checked=!1,d.singleSelectedNode=null),!t.isDefaultValue||f&&0!==d.defaultValues.length||(d.defaultValues.push(t._id),t.checked=!0,f&&(d.singleSelectedNode=t)),c&&!l||function(e){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},n=arguments.length>2&&void 0!==arguments[2]&&!arguments[2]?["disabled"]:["checked","disabled"],r=0;r<n.length;r++){var o=n[r];void 0===e[o]&&void 0!==t[o]&&(e[o]=t[o])}}(t,r,!l),d.list.set(t._id,t),!i&&t.children&&(t._children=[],e({nodes:t.children,parent:t,depth:a+1,radio:l,showPartialState:s,hierarchical:c,_rv:d}),s&&!t.checked&&(t.partial=Re(t),f||p(t.children)||!t.children.every(function(e){return e.checked})||(t.checked=!0)),t.children=void 0)}),d}({nodes:Array.isArray(t)?t:[t],simple:n,radio:r,showPartialState:o,hierarchical:a,rootPrefixId:i})},Fe=function e(t,n,r){n[t._id]=!0,p(t._children)||t._children.forEach(function(t){return e(r(t),n,r)})},Le=function(e,t){var n=[],r={};return e.forEach(function(e,o){r[o]||(t(e,o,r)&&n.push(e),r[o]=!0)}),n},Be={getNodesMatching:Le,getVisibleNodes:function(e,t,n){return Le(e,function(e,r,o){return n&&e._children&&e._children.length&&!0!==e.expanded&&Fe(e,o,t),!e.hide})},markSubTreeVisited:Fe},Ve=function(){return function(e,t){if(Array.isArray(e))return e;if(Symbol.iterator in Object(e))return function(e,t){var n=[],r=!0,o=!1,a=void 0;try{for(var i,l=e[Symbol.iterator]();!(r=(i=l.next()).done)&&(n.push(i.value),!t||n.length!==t);r=!0);}catch(e){o=!0,a=e}finally{try{!r&&l.return&&l.return()}finally{if(o)throw a}}return n}(e,t);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),Ye="ArrowUp",Ke="ArrowDown",qe="ArrowLeft",He="ArrowRight",Ue="Enter",We="Home",ze="PageUp",$e="End",Je="PageDown",Ze={None:"None",FocusPrevious:"FocusPrevious",FocusNext:"FocusNext",FocusParent:"FocusParent",FocusFirst:"FocusFirst",FocusLast:"FocusLast",ToggleExpanded:"ToggleExpanded",ToggleChecked:"ToggleChecked"},Ge=new Set([Ze.FocusPrevious,Ze.FocusNext,Ze.FocusParent,Ze.FocusFirst,Ze.FocusLast]),Qe=[Ye,Ke,We,ze,$e,Je],Xe=Qe.concat([qe,He,Ue]),et=function(e,t,n,r){return t.indexOf(e)>-1||!n&&e===r},tt=function(e,t,n){if(!e||0===e.length)return t;var r=t;(function(e){return et(e,[Ze.FocusFirst,Ze.FocusLast],!0)})(n)?r=Ve(e,1)[0]:[Ze.FocusPrevious,Ze.FocusNext].indexOf(n)>-1&&(r=function(e,t){var n=e.indexOf(t)+1;return n%e.length==0?e[0]:e[n]}(e,t));return r},nt={isValidKey:function(e,t){return(t?Xe:Qe).indexOf(e)>-1},getAction:function(e,t){return t===qe?function(e,t){return e&&t===qe?!0===e.expanded?Ze.ToggleExpanded:e._parent?Ze.FocusParent:Ze.None:Ze.None}(e,t):t===He?function(e,t){return e&&e._children&&t===He?!0!==e.expanded?Ze.ToggleExpanded:Ze.FocusNext:Ze.None}(e,t):function(e,t){return et(e,[We,ze],t,Ke)}(t,e)?Ze.FocusFirst:function(e,t){return et(e,[$e,Je],t,Ye)}(t,e)?Ze.FocusLast:function(e,t){if(!e)return Ze.None;switch(t){case Ye:return Ze.FocusPrevious;case Ke:return Ze.FocusNext;case Ue:return Ze.ToggleChecked;default:return Ze.None}}(e,t)},getNextFocus:function(e,t,n,r,o){if(n===Ze.FocusParent)return function(e,t){return e&&e._parent?t(e._parent):e}(t,r);if(!Ge.has(n))return t;var a=Be.getVisibleNodes(e,r,o);return function(e){return et(e,[Ze.FocusPrevious,Ze.FocusLast],!0)}(n)&&(a=a.reverse()),tt(a,t,n)},getNextFocusAfterTagDelete:function(e,t,n,r){var o=t&&t.findIndex(function(t){return t._id===e});if(o<0||!n.length)return r;var a=n[o=n.length>o?o:n.length-1]._id,i=document.getElementById(k(a));return i&&i.firstElementChild||r},handleFocusNavigationkey:function(e,t,n,r,o){var a=nt.getNextFocus(e,n,t,r,o);return n&&a&&n._id!==a._id&&(n._focused=!1),a?(a._focused=!0,a._id):n&&n._id},handleToggleNavigationkey:function(e,t,n,r,o){return e!==Ze.ToggleChecked||n||t.readOnly||t.disabled?e===Ze.ToggleExpanded&&o(t._id):r(t._id,!0!==t.checked),t&&t._id}},rt=nt,ot=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(t,n,r){return n&&e(t.prototype,n),r&&e(t,r),t}}();var at=function(){function e(t){var n=t.data,r=t.mode,o=t.showPartiallySelected,a=t.rootPrefixId,i=t.searchPredicate;!function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}(this,e),this._src=n,this.simpleSelect="simpleSelect"===r,this.radioSelect="radioSelect"===r,this.hierarchical="hierarchical"===r,this.searchPredicate=i;var l=Ae({tree:JSON.parse(JSON.stringify(n)),simple:this.simpleSelect,radio:this.radioSelect,showPartialState:o,hierarchical:this.hierarchical,rootPrefixId:a}),s=l.list,c=l.defaultValues,u=l.singleSelectedNode;this.tree=s,this.defaultValues=c,this.showPartialState=!this.hierarchical&&o,this.searchMaps=new Map,(this.simpleSelect||this.radioSelect)&&u&&(this.currentChecked=u._id)}return ot(e,[{key:"getNodeById",value:function(e){return this.tree.get(e)}},{key:"getMatches",value:function(e){var t=this;if(this.searchMaps.has(e))return this.searchMaps.get(e);var n=-1,r=e;this.searchMaps.forEach(function(t,o){e.startsWith(o)&&o.length>n&&(n=o.length,r=o)});var o=[],a=this._getAddOnMatch(o,e);r!==e?this.searchMaps.get(r).forEach(function(e){return a(t.getNodeById(e))}):this.tree.forEach(a);return this.searchMaps.set(e,o),o}},{key:"addParentsToTree",value:function(e,t){if(void 0!==e){var n=this.getNodeById(e);this.addParentsToTree(n._parent,t),n.hide=!n._isMatch||n.hide,n.matchInChildren=!0,t.set(e,n)}}},{key:"addChildrenToTree",value:function(e,t,n){var r=this;void 0!==e&&e.forEach(function(e){if(!n||!n.includes(e)){var o=r.getNodeById(e);o.matchInParent=!0,t.set(e,o),r.addChildrenToTree(o._children,t)}})}},{key:"filterTree",value:function(e,t,n){var r=this,o=this.getMatches(e.toLowerCase()),a=new Map;o.forEach(function(e){var i=r.getNodeById(e);i.hide=!1,i._isMatch=!0,t&&r.addParentsToTree(i._parent,a),a.set(e,i),t&&n&&r.addChildrenToTree(i._children,a,o)});var i=0===o.length;return this.matchTree=a,{allNodesHidden:i,tree:a}}},{key:"restoreNodes",value:function(){return this.tree.forEach(function(e){e.hide=!1}),this.tree}},{key:"restoreDefaultValues",value:function(){var e=this;return this.defaultValues.forEach(function(t){e.setNodeCheckedState(t,!0)}),this.tree}},{key:"togglePreviousChecked",value:function(e,t){var n=this.currentChecked;n&&n!==e&&(this.getNodeById(n).checked=!1),this.currentChecked=t?e:null}},{key:"setNodeCheckedState",value:function(e,t){var n=this.getNodeById(e);n.checked=t,this.showPartialState&&(n.partial=!1),this.simpleSelect?this.togglePreviousChecked(e,t):this.radioSelect?(this.togglePreviousChecked(e,t),this.showPartialState&&this.partialCheckParents(n),t||this.unCheckParents(n)):(this.hierarchical||this.toggleChildren(e,t),this.showPartialState&&this.partialCheckParents(n),this.hierarchical||t||this.unCheckParents(n))}},{key:"unCheckParents",value:function(e){for(var t=e._parent;t;){var n=this.getNodeById(t);n.checked=!1,n.partial=Re(n,"_children",this.getNodeById.bind(this)),t=n._parent}}},{key:"partialCheckParents",value:function(e){for(var t=this,n=e._parent;n;){var r=this.getNodeById(n);r.checked=r._children.every(function(e){return t.getNodeById(e).checked}),r.partial=Re(r,"_children",this.getNodeById.bind(this)),n=r._parent}}},{key:"toggleChildren",value:function(e,t){var n=this,r=this.getNodeById(e);r.checked=t,this.showPartialState&&(r.partial=!1),p(r._children)||r._children.forEach(function(e){return n.toggleChildren(e,t)})}},{key:"toggleNodeExpandState",value:function(e){var t=this.getNodeById(e);return t.expanded=!t.expanded,t.expanded||this.collapseChildren(t),this.tree}},{key:"collapseChildren",value:function(e){var t=this;e.expanded=!1,p(e._children)||e._children.forEach(function(e){return t.collapseChildren(t.getNodeById(e))})}},{key:"getTreeAndTags",value:function(){return{tree:this.matchTree||this.tree,tags:this.tags}}},{key:"handleNavigationKey",value:function(e,t,n,r,o,a,i){var l=this,s=e&&this.getNodeById(e),c=rt.getAction(s,n);return Ge.has(c)?rt.handleFocusNavigationkey(t,c,s,function(e){return l.getNodeById(e)},o):s&&t.has(s._id)?rt.handleToggleNavigationkey(c,s,r,a,i):e}},{key:"_getAddOnMatch",value:function(e,t){var n=function(e,t){return e.label.toLowerCase().indexOf(t)>=0};return"function"==typeof this.searchPredicate&&(n=this.searchPredicate),function(r){n(r,t)&&e.push(r._id)}}},{key:"tags",get:function(){var e=this;return this.radioSelect||this.simpleSelect?this.currentChecked?[this.getNodeById(this.currentChecked)]:[]:Be.getNodesMatching(this.tree,function(t,n,r){return t.checked&&!e.hierarchical&&Be.markSubTreeVisited(t,r,function(t){return e.getNodeById(t)}),t.checked})}}]),e}(),it=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var r in n)Object.prototype.hasOwnProperty.call(n,r)&&(e[r]=n[r])}return e},lt=function(){function e(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}return function(