Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-accessible-treeview

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-accessible-treeview - npm Package Compare versions

Comparing version 2.3.5 to 2.4.0

dist/__tests__/ControlledDisabledNode.test.d.ts

8

dist/index.d.ts

@@ -1,4 +0,6 @@

import TreeView, { ClickActions, CLICK_ACTIONS, IBranchProps, LeafProps, INode, INodeRendererProps, ITreeViewOnExpandProps, ITreeViewOnSelectProps, ITreeViewProps, ITreeViewState, TreeViewAction, ITreeViewOnLoadDataProps } from "./TreeView";
import { EventCallback, flattenTree } from "./TreeView/utils";
export { flattenTree, ITreeViewProps, INode, ITreeViewOnSelectProps, CLICK_ACTIONS, ITreeViewOnExpandProps, ITreeViewOnLoadDataProps, EventCallback, TreeViewAction, INodeRendererProps, ClickActions, IBranchProps, LeafProps, ITreeViewState, };
import TreeView, { ClickActions, CLICK_ACTIONS, IBranchProps, LeafProps, INodeRendererProps, ITreeViewOnExpandProps, ITreeViewOnSelectProps, ITreeViewProps, ITreeViewOnLoadDataProps } from "./TreeView";
import { ITreeViewState, TreeViewAction } from "./TreeView/reducer";
import { INode, TreeViewData, EventCallback } from "./TreeView/types";
import { flattenTree } from "./TreeView/utils";
export { flattenTree, ITreeViewProps, INode, TreeViewData, ITreeViewOnSelectProps, CLICK_ACTIONS, ITreeViewOnExpandProps, ITreeViewOnLoadDataProps, EventCallback, TreeViewAction, INodeRendererProps, ClickActions, IBranchProps, LeafProps, ITreeViewState, };
export default TreeView;

@@ -1,1 +0,1 @@

"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("classnames")),a=e(require("prop-types")),n=require("react"),r=e(n);function l(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,r,l=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);d=!0);}catch(e){i=!0,r=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw r}}return l}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){if(e){if("string"==typeof e)return c(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function o(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=s(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,d=!0,i=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return d=e.done,e},e:function(e){i=!0,l=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw l}}}}function u(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]])}return a}var f=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){var a,n=o(t);try{for(n.s();!(a=n.n()).done;){var r=a.value;if(r&&r(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},h=function(e,t){var a,n=new Set,r=o(e);try{for(r.s();!(a=r.n()).done;){var l=a.value;t.has(l)||n.add(l)}}catch(e){r.e(e)}finally{r.f()}return n},p=function(e,t){return new Set([].concat(i(h(e,t)),i(h(t,e))))},v=function(e){var t=n.useRef();return n.useEffect((function(){t.current=e}),[e]),t.current},I=function(e,t){return null!=e[t].children&&e[t].children.length>0},b=function(e,t){return e[t].parent},S=function(e,t,a){for(var n=t,r=[];;){var l=b(e,n);if(0===l||null==l||null!=l&&a.has(l))break;r.push(l),n=l}return r},y=function(e,t,a){var n=[];return function e(t,r){var l=t[r];if(null!=l.children){var d,i=o(l.children.filter((function(e){return!a.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;n.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),n},m=function(e,t,a){var n=b(e,t);if(null!=n){var r=e[n],l=r.children.indexOf(t)+a;if(r.children[l])return r.children[l]}return null},g=function(e,t,a){var n=e[t];for(e[0].id===t&&(n=e[e[t].children[e[t].children.length-1]]);a.has(n.id)&&I(e,n.id);)n=e[n.children[n.children.length-1]];return n.id},w=function(e,t,a){if(t===e[0].children[0])return null;var n=m(e,t,-1);return null==n?b(e,t):g(e,n,a)},E=function(e,t,a){var n=e[t].id;if(I(e,n)&&a.has(n))return e[n].children[0];for(;;){var r=m(e,n,1);if(null!=r)return r;if(null==(n=b(e,n)))return null}},O=function(e){var t=e.data,a=e.expandedIds,n=e.from,r=e.to,l=[],d=Object.keys(t).length,i=0,s=n;if(l.push(n),n<r)for(;i<d&&(null!=(s=E(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;else if(n>r)for(;i<d&&(null!=(s=w(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;return l},x=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},W=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,r=e.multiSelect;return a?t:n?"mixed":r?t:!!t||void 0},A=function(e,t,a){return t.concat.apply(t,i(t.filter((function(t){return I(e,t)})).map((function(t){return y(e,t,a)}))))},j=function(e,t,a){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&a()}),0):!t.contains(e.nativeEvent.relatedTarget)&&a():console.warn("ref not set on <ul>")},C=function(e,t,a){return I(e,t)&&a.has(t)&&y(e,t,new Set).some((function(e){return a.has(e)}))},D={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},k="COLLAPSE",L="COLLAPSE_MANY",N="EXPAND",U="EXPAND_MANY",R="HALF_SELECT",T="SELECT",F="DESELECT",B="TOGGLE",_="TOGGLE_SELECT",z="SELECT_MANY",K="EXCLUSIVE_CHANGE_SELECT_MANY",H="FOCUS",P="BLUR",G="DISABLE",M="ENABLE",q=function(e,t){switch(t.type){case k:var a=new Set(e.expandedIds);return a.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:a,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case L:var n,r=new Set(e.expandedIds),l=o(t.ids);try{for(l.s();!(n=l.n()).done;){var d=n.value;r.delete(d)}}catch(e){l.e(e)}finally{l.f()}return Object.assign(Object.assign({},e),{expandedIds:r,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case N:var s=new Set(e.expandedIds);return s.add(t.id),Object.assign(Object.assign({},e),{expandedIds:s,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case U:var c=new Set([].concat(i(e.expandedIds),i(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:var u=new Set(e.expandedIds);return e.expandedIds.has(t.id)?u.delete(t.id):u.add(t.id),Object.assign(Object.assign({},e),{expandedIds:u,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),p=new Set(e.selectedIds);return f.add(t.id),p.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:f,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case T:if(!t.controlled&&e.disabledIds.has(t.id))return e;var v;t.multiSelect?(v=new Set(e.selectedIds)).add(t.id):(v=new Set).add(t.id);var I=new Set(e.halfSelectedIds);return I.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:v,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case F:if(!t.controlled&&e.disabledIds.has(t.id))return e;var b,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(b=new Set(e.halfSelectedIds)).delete(t.id):b=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case _:if(e.disabledIds.has(t.id))return e;var y,m=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),m?y.delete(t.id):y.add(t.id)):(y=new Set,m||y.add(t.id));var g=new Set(e.halfSelectedIds);return g.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:g,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(i(e.selectedIds),i(E))):h(e.selectedIds,new Set(E));var O=h(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case K:var x,W=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){x=t.select?new Set(W):h(e.selectedIds,new Set(W));var A=h(e.halfSelectedIds,x);return Object.assign(Object.assign({},e),{selectedIds:x,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case H:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case P:return Object.assign(Object.assign({},e),{isFocused:!1});case G:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case M:var C=new Set(e.disabledIds);return C.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:C});default:throw new Error("Invalid action passed to the reducer")}},V=function(e){var t=e.data,a=e.controlledIds,r=e.controlledExpandedIds,l=e.defaultExpandedIds,s=e.defaultSelectedIds,c=e.defaultDisabledIds,u=e.nodeRefs,f=e.leafRefs,m=e.onSelect,g=e.onExpand,w=e.onLoadData,E=e.togglableSelect,O=e.multiSelect,x=e.propagateSelect,W=e.propagateSelectUpwards,j=d(n.useReducer(q,{selectedIds:new Set(a||s),tabbableId:t[0].children[0],isFocused:!1,expandedIds:new Set(r||l),halfSelectedIds:new Set,lastUserSelect:t[0].children[0],lastInteractedWith:null,disabledIds:new Set(c)}),2),C=j[0],D=j[1],_=C.selectedIds,K=C.expandedIds,P=C.disabledIds,G=C.tabbableId,M=C.halfSelectedIds,V=C.lastAction,X=C.lastInteractedWith,Y=v(_)||new Set,$=p(_,Y);n.useEffect((function(){if(null!=m&&m!==J){var e,a=o($);try{for(a.s();!(e=a.n()).done;){var n=e.value,r=I(t,n)||!!t[G].isBranch;m({element:t[n],isBranch:r,isExpanded:!!r&&K.has(n),isSelected:_.has(n),isDisabled:P.has(n),isHalfSelected:!!r&&M.has(n),treeState:C})}}catch(e){a.e(e)}finally{a.f()}}}),[t,_,K,P,M,$,m,C]);var Q=v(K)||new Set;n.useEffect((function(){var e=p(K,Q);if(null!=g&&g!==J){var a,n=o(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;g({element:t[r],isExpanded:K.has(r),isSelected:_.has(r),isDisabled:P.has(r),isHalfSelected:M.has(r),treeState:C})}}catch(e){n.e(e)}finally{n.f()}}}),[t,_,K,P,M,Q,g,C]);var Z,ee,te=(Z=t,ee=n.useRef(),n.useEffect((function(){ee.current=Z})),ee.current||new Set);return n.useEffect((function(){var e=p(K,Q);if(w){var a,n=o(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;w({element:t[r],isExpanded:K.has(r),isSelected:_.has(r),isDisabled:P.has(r),isHalfSelected:M.has(r),treeState:C})}}catch(e){n.e(e)}finally{n.f()}if(te!==t&&E&&x){var l,d=o(K);try{for(d.s();!(l=d.n()).done;){var i=l.value;_.has(i)&&D({type:z,ids:A(t,[i],P),select:!0,multiSelect:O,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,_,K,P,M,Q,w,C]),n.useEffect((function(){var e=new Set(a),n=h(e,Y),r=h(Y,e);if(r.size){var l,d=o(r);try{for(d.s();!(l=d.n()).done;){var i=l.value;D({type:F,id:i,multiSelect:O,controlled:!0,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}if(n.size){var s,c=o(n);try{for(c.s();!(s=c.n()).done;){var u=s.value;D({type:T,id:u,multiSelect:O,controlled:!0,lastInteractedWith:u}),x&&!P.has(u)&&D({type:z,ids:A(t,[u],P),select:!0,multiSelect:O,lastInteractedWith:u})}}catch(e){c.e(e)}finally{c.f()}}}),[a]),n.useEffect((function(){var e=new Set(r),a=h(e,Q),n=h(Q,e);if(n.size){var l,d=o(n);try{for(d.s();!(l=d.n()).done;){var s=l.value;if(I(t,s)||t[s].isBranch){var c=[s].concat(i(y(t,s,new Set)));D({type:L,ids:c,lastInteractedWith:s})}}}catch(e){d.e(e)}finally{d.f()}}if(a.size){var u,f=o(a);try{for(f.s();!(u=f.n()).done;){var p=u.value;if(I(t,p)||t[p].isBranch){var v=b(t,p);D(v?{type:U,ids:[p,v],lastInteractedWith:p}:{type:N,id:p,lastInteractedWith:p})}}}catch(e){f.e(e)}finally{f.f()}}}),[r]),n.useEffect((function(){if(W){var e=new Set($);X&&V!==H&&V!==k&&V!==N&&V!==B&&e.add(X);var a,n=function(e,t,a,n,r,l){var d,i={every:new Set,some:new Set,none:new Set},s=o(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var u=b(e,c);if(0===u||null==u||null!=u&&n.has(u))break;var f=e[u].children.filter((function(e){return!n.has(e)}));if(0===f.length)break;if(f.some((function(e){return a.has(e)||i.some.has(e)||r.has(e)})))f.every((function(e){return a.has(e)}))?i.every.add(u):i.some.add(u);else{var h=S(e,c,n).find((function(e){return a.has(e)}));if(!l&&h){y(e,h,n).forEach((function(e){r.has(e)&&i.none.add(e)}));break}i.none.add(u)}c=u}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,_,P,M,O),r=n.every,l=n.some,d=n.none,i=o(r);try{for(i.s();!(a=i.n()).done;){var s=a.value;_.has(s)||D({type:T,id:s,multiSelect:O,keepFocus:!0,NotUserAction:!0,lastInteractedWith:X})}}catch(e){i.e(e)}finally{i.f()}var c,u=o(l);try{for(u.s();!(c=u.n()).done;){var f=c.value;M.has(f)||D({type:R,id:f,lastInteractedWith:X})}}catch(e){u.e(e)}finally{u.f()}var h,p=o(d);try{for(p.s();!(h=p.n()).done;){var v=h.value;(_.has(v)||M.has(v))&&D({type:F,id:v,multiSelect:O,keepFocus:!0,NotUserAction:!0,lastInteractedWith:X})}}catch(e){p.e(e)}finally{p.f()}}}),[t,O,W,_,K,P,M,V,Y,$,X]),n.useEffect((function(){if(null!=X&&null!=G&&null!=(null==u?void 0:u.current)&&null!=(null==f?void 0:f.current)){var e=u.current[G];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(f.current[X]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[G,u,f,X]),[C,D]},X={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},Y=Object.freeze(Object.values(X)),$=Object.freeze(Object.values({check:"check",select:"select"})),J=function(){},Q=r.forwardRef((function(e,a){var l=e.data,i=e.selectedIds,s=e.nodeRenderer,c=e.onSelect,o=void 0===c?J:c,f=e.onExpand,h=void 0===f?J:f,p=e.onLoadData,v=e.className,I=void 0===v?"":v,b=e.multiSelect,S=void 0!==b&&b,y=e.propagateSelect,m=void 0!==y&&y,g=e.propagateSelectUpwards,w=void 0!==g&&g,E=e.propagateCollapse,O=void 0!==E&&E,x=e.expandOnKeyboardSelect,W=void 0!==x&&x,A=e.togglableSelect,C=void 0!==A&&A,k=e.defaultExpandedIds,L=void 0===k?[]:k,N=e.defaultSelectedIds,U=void 0===N?[]:N,R=e.defaultDisabledIds,T=void 0===R?[]:R,F=e.clickAction,B=void 0===F?X.select:F,_=e.nodeAction,z=void 0===_?"select":_,K=e.expandedIds,H=e.onBlur,G=u(e,["data","selectedIds","nodeRenderer","onSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]),M=n.useRef({}),q=n.useRef({}),Y=d(V({data:l,controlledIds:i,controlledExpandedIds:K,defaultExpandedIds:L,defaultSelectedIds:U,defaultDisabledIds:T,nodeRefs:M,leafRefs:q,onSelect:o,onExpand:h,onLoadData:p,togglableSelect:C,multiSelect:S,propagateSelect:m,propagateSelectUpwards:w}),2),$=Y[0],Q=Y[1];m=m&&S;var ee=n.useRef(null);return null!=a&&(ee=a),r.createElement("ul",Object.assign({className:t(D.root,I),role:"tree","aria-multiselectable":"select"===z?S:void 0,ref:ee,onBlur:function(e){j(e,ee.current,(function(){H&&H({treeState:$,dispatch:Q}),Q({type:P})}))},onKeyDown:ae({data:l,tabbableId:$.tabbableId,expandedIds:$.expandedIds,selectedIds:$.selectedIds,disabledIds:$.disabledIds,halfSelectedIds:$.halfSelectedIds,clickAction:B,dispatch:Q,propagateCollapse:O,propagateSelect:m,multiSelect:S,expandOnKeyboardSelect:W,togglableSelect:C})},G),l[0].children.map((function(e,t){return r.createElement(Z,Object.assign({key:e,data:l,element:l[e],setsize:l[0].children.length,posinset:t+1,level:1},$,{state:$,dispatch:Q,nodeRefs:M,leafRefs:q,baseClassNames:D,nodeRenderer:s,propagateCollapse:O,propagateSelect:m,propagateSelectUpwards:w,multiSelect:S,togglableSelect:C,clickAction:B,nodeAction:z}))})))})),Z=function(e){var a=e.element,n=e.dispatch,d=e.data,s=e.selectedIds,c=e.tabbableId,o=e.isFocused,u=e.expandedIds,h=e.disabledIds,p=e.halfSelectedIds,v=e.lastUserSelect,b=e.nodeRefs,S=e.leafRefs,m=e.baseClassNames,g=e.nodeRenderer,w=e.nodeAction,E=e.setsize,j=e.posinset,D=e.level,k=e.propagateCollapse,N=e.propagateSelect,U=e.multiSelect,F=e.togglableSelect,P=e.clickAction,G=e.state,M=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(a.id)&&k){var t=[a.id].concat(i(y(d,a.id,new Set)));n({type:L,ids:t,lastInteractedWith:a.id})}else n({type:B,id:a.id,lastInteractedWith:a.id})},q=function(){return n({type:H,id:a.id,lastInteractedWith:a.id})},V=function(e){if(e.shiftKey){var t=O({data:d,expandedIds:u,from:v,to:a.id}).filter((function(e){return!h.has(e)}));t=N?A(d,t,h):t,n({type:K,select:!0,multiSelect:U,ids:t,lastInteractedWith:a.id})}else if(e.ctrlKey||P===X.select){var r=C(d,a.id,s);n({type:F?r?R:_:T,id:a.id,multiSelect:U,lastInteractedWith:a.id}),N&&!h.has(a.id)&&n({type:z,ids:A(d,[a.id],h),select:!F||!s.has(a.id),multiSelect:U,lastInteractedWith:a.id})}else P===X.exclusiveSelect?n({type:F?_:T,id:a.id,multiSelect:!1,lastInteractedWith:a.id}):P===X.focus&&n({type:H,id:a.id,lastInteractedWith:a.id})},Y=function(e){var n;return t(e,(l(n={},"".concat(e,"--expanded"),u.has(a.id)),l(n,"".concat(e,"--selected"),s.has(a.id)),l(n,"".concat(e,"--focused"),c===a.id&&o),n))},$="select"===w?{"aria-selected":x({isSelected:s.has(a.id),isDisabled:h.has(a.id),multiSelect:U})}:{"aria-checked":W({isSelected:s.has(a.id),isDisabled:h.has(a.id),isHalfSelected:p.has(a.id),multiSelect:U})};return I(d,a.id)||a.isBranch?r.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(a.id),"aria-setsize":E,"aria-posinset":j,"aria-level":D,"aria-disabled":h.has(a.id),tabIndex:c===a.id?0:-1,ref:function(e){null!=(null==b?void 0:b.current)&&null!=e&&(b.current[a.id]=e)},className:m.branchWrapper},$),r.createElement(r.Fragment,null,g({element:a,isBranch:!0,isSelected:s.has(a.id),isHalfSelected:p.has(a.id),isExpanded:u.has(a.id),isDisabled:h.has(a.id),dispatch:n,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onClick;return{onClick:null==n?f(V,M,q):f(n,q),className:t(Y(m.node),m.branch),ref:function(e){null!=(null==S?void 0:S.current)&&(S.current[a.id]=e)}}},setsize:E,posinset:j,level:D,handleSelect:V,handleExpand:M,treeState:G}),r.createElement(te,Object.assign({getClasses:Y},ee(e))))):r.createElement("li",{role:"none",className:Y(m.leafListItem)},g({element:a,isBranch:!1,isSelected:s.has(a.id),isHalfSelected:!1,isExpanded:!1,isDisabled:h.has(a.id),dispatch:n,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onClick;return Object.assign({role:"treeitem",tabIndex:c===a.id?0:-1,onClick:f(null==n?V:n,q),ref:function(e){null!=(null==b?void 0:b.current)&&null!=(null==S?void 0:S.current)&&(b.current[a.id]=e,S.current[a.id]=e)},className:t(Y(m.node),m.leaf),"aria-setsize":E,"aria-posinset":j,"aria-level":D,disabled:h.has(a.id),"aria-disabled":h.has(a.id)},$)},setsize:E,posinset:j,level:D,handleSelect:V,handleExpand:J,treeState:G}))},ee=function(e){e.setsize,e.posinset;return u(e,["setsize","posinset"])},te=function(e){var t=e.data,a=e.element,n=e.expandedIds,l=e.getClasses,d=e.baseClassNames,i=e.level,s=u(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return r.createElement("ul",{role:"group",className:l(d.nodeGroup)},n.has(a.id)&&a.children.length>0&&a.children.map((function(e,l){return r.createElement(Z,Object.assign({data:t,expandedIds:n,baseClassNames:d,key:e,element:t[e],setsize:a.children.length,posinset:l+1,level:i+1},s))})))},ae=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,r=e.disabledIds,l=e.tabbableId,d=e.dispatch,s=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=t[l],v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var S=t.filter((function(e){return 0!==e.id})),m=Object.values(S).map((function(e){return e.id})).filter((function(e){return!r.has(e)}));d({type:z,multiSelect:o,select:Array.from(n).filter((function(e){return!r.has(e)})).length!==m.length,ids:m,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var x="Home"===e.key?t[0].children[0]:g(t,v,a),W=O({data:t,expandedIds:a,from:v,to:x}).filter((function(e){return!r.has(e)}));d({type:z,multiSelect:o,select:!0,ids:c?A(t,W,r):W}),d({type:H,id:x,lastInteractedWith:x})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var j=w(t,v,a);return void(null==j||r.has(j)||(d({type:z,ids:c?A(t,[j],r):[j],select:!0,multiSelect:o,lastInteractedWith:j}),d({type:H,id:j,lastInteractedWith:j})));case"ArrowDown":e.preventDefault();var D=E(t,v,a);return void(null==D||r.has(D)||(d({type:z,ids:c?A(t,[D],r):[D],multiSelect:o,select:!0,lastInteractedWith:D}),d({type:H,id:D,lastInteractedWith:D})))}switch(e.key){case"ArrowDown":e.preventDefault();var F=E(t,v,a);return void(null!=F&&d({type:H,id:F,lastInteractedWith:F}));case"ArrowUp":e.preventDefault();var K=w(t,v,a);return void(null!=K&&d({type:H,id:K,lastInteractedWith:K}));case"ArrowLeft":if(e.preventDefault(),(I(t,v)||p.isBranch)&&a.has(l))if(s){var P=[v].concat(i(y(t,v,new Set)));d({type:L,ids:P,lastInteractedWith:p.id})}else d({type:k,id:v,lastInteractedWith:v});else if(!t[0].children.includes(v)){var G=b(t,v);if(null==G)throw new Error("parentId of root element is null");d({type:H,id:G,lastInteractedWith:G})}return;case"ArrowRight":return e.preventDefault(),void((I(t,v)||p.isBranch)&&(a.has(l)?d({type:H,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:N,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),d({type:H,id:t[0].children[0],lastInteractedWith:t[0].children[0]});break;case"End":e.preventDefault();var M=g(t,t[0].id,a);return void d({type:H,id:M,lastInteractedWith:M});case"*":e.preventDefault();var q=b(t,v);if(null==q)throw new Error("parentId of element is null");var V=t[q].children.filter((function(e){return I(t,e)||t[e].isBranch}));return void d({type:U,ids:V,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===X.focus)return;var Y=C(t,p.id,n);return d({type:f?Y?R:_:T,id:v,multiSelect:o,lastInteractedWith:v}),c&&!r.has(p.id)&&d({type:z,ids:A(t,[v],r),select:!f||!n.has(v),multiSelect:o,lastInteractedWith:v}),void(u&&d({type:B,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var $=E(t,v,a);$!==v;)if(null!=$){if(t[$].name[0].toLowerCase()===e.key.toLowerCase())return void d({type:H,id:$,lastInteractedWith:v});$=E(t,$,a)}else $=t[0].children[0];return}}}};Q.propTypes={data:a.array.isRequired,onSelect:a.func,onExpand:a.func,className:a.string,nodeRenderer:a.func.isRequired,defaultExpandedIds:a.array,defaultSelectedIds:a.array,expandedIds:a.array,selectedIds:a.array,defaultDisabledIds:a.array,propagateCollapse:a.bool,propagateSelect:a.bool,propagateSelectUpwards:a.bool,multiSelect:a.bool,expandOnKeyboardSelect:a.bool,togglableSelect:a.bool,nodeAction:a.oneOf($),clickAction:a.oneOf(Y),onBlur:a.func,onLoadData:a.func},exports.CLICK_ACTIONS=Y,exports.default=Q,exports.flattenTree=function(e){var t=0,a=[];return function e(n,r){var l={id:t,name:n.name,children:[],parent:r};if(a[t]=l,t+=1,null!=n.children&&0!==n.children.length){var d,i=o(n.children);try{for(i.s();!(d=i.n()).done;){e(d.value,l.id)}}catch(e){i.e(e)}finally{i.f()}l.children=a.filter((function(e){return e.parent===l.id})).map((function(e){return e.id}))}}(e,null),a};
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("classnames")),n=e(require("prop-types")),a=require("react"),r=e(a);function l(e){return(l="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function i(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var a,r,l=[],i=!0,d=!1;try{for(n=n.call(e);!(i=(a=n.next()).done)&&(l.push(a.value),!t||l.length!==t);i=!0);}catch(e){d=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(d)throw r}}return l}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return o(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function u(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=c(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0,r=function(){};return{s:r,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,i=!0,d=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){d=!0,l=e},f:function(){try{i||null==n.return||n.return()}finally{if(d)throw l}}}}function f(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n}var h=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){var n,a=u(t);try{for(a.s();!(n=a.n()).done;){var r=n.value;if(r&&r(e),e.defaultPrevented)break}}catch(e){a.e(e)}finally{a.f()}}},p=function(e,t){var n,a=new Set,r=u(e);try{for(r.s();!(n=r.n()).done;){var l=n.value;t.has(l)||a.add(l)}}catch(e){r.e(e)}finally{r.f()}return a},v=function(e,t){return new Set([].concat(s(p(e,t)),s(p(t,e))))},b=function(e){var t=a.useRef();return a.useEffect((function(){t.current=e}),[e]),t.current},I=function(e,t){var n;return!!(null===(n=N(e,t).children)||void 0===n?void 0:n.length)},S=function(e,t){return N(e,t).parent},y=function(e,t,n){for(var a=t,r=[];;){var l=S(e,a);if(0===l||null==l||null!=l&&n.has(l))break;r.push(l),a=l}return r},m=function(e,t,n){var a=[];return function e(t,r){var l=N(t,r);if(null!=l.children){var i,d=u(l.children.filter((function(e){return!n.has(e)})));try{for(d.s();!(i=d.n()).done;){var s=i.value;a.push(s),e(t,s)}}catch(e){d.e(e)}finally{d.f()}}}(e,t),a},g=function(e,t,n){var a=S(e,t);if(null!=a){var r=N(e,a),l=r.children.indexOf(t)+n;if(r.children[l])return r.children[l]}return null},w=function(e,t,n){var a=N(e,t);for(k(e).id===t&&(a=N(e,N(e,t).children[N(e,t).children.length-1]));n.has(a.id)&&I(e,a.id);)a=N(e,a.children[a.children.length-1]);return a.id},E=function(e,t,n){if(t===k(e).children[0])return null;var a=g(e,t,-1);return null==a?S(e,t):w(e,a,n)},O=function(e,t,n){var a=N(e,t).id;if(I(e,a)&&n.has(a))return N(e,a).children[0];for(;;){var r=g(e,a,1);if(null!=r)return r;if(null==(a=S(e,a)))return null}},x=function(e){var t=e.data,n=e.expandedIds,a=e.from,r=e.to,l=[],i=t.length,d=0,s=a;if(l.push(a),a<r)for(;d<i&&(null!=(s=O(t,s,n))&&l.push(s),null!=s&&s!==r);)d+=1;else if(a>r)for(;d<i&&(null!=(s=E(t,s,n))&&l.push(s),null!=s&&s!==r);)d+=1;return l},W=function(e){var t=e.isSelected,n=e.isDisabled,a=e.multiSelect;return n||a?t:!!t||void 0},A=function(e){var t=e.isSelected,n=e.isDisabled,a=e.isHalfSelected,r=e.multiSelect;return n?t:a?"mixed":r?t:!!t||void 0},j=function(e,t,n){return t.concat.apply(t,s(t.filter((function(t){return I(e,t)})).map((function(t){return m(e,t,n)}))))},D=function(e,t,n){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&n()}),0):!t.contains(e.nativeEvent.relatedTarget)&&n():console.warn("ref not set on <ul>")},C=function(e,t,n){return I(e,t)&&n.has(t)&&m(e,t,new Set).some((function(e){return n.has(e)}))},k=function(e){var t=e.find((function(e){return null===e.parent}));if(!t)throw Error("TreeView data must contain parent node.");return t},N=function(e,t){var n=e.find((function(e){return e.id===t}));if(null==n)throw Error("Node with id=".concat(t," doesn't exist in the tree."));return n},L=function(e){var t=Array.from(new Set(e));return e.length!==t.length},U="COLLAPSE",R="COLLAPSE_MANY",T="EXPAND",F="EXPAND_MANY",B="HALF_SELECT",_="SELECT",z="DESELECT",K="TOGGLE",H="TOGGLE_SELECT",P="SELECT_MANY",M="EXCLUSIVE_CHANGE_SELECT_MANY",V="FOCUS",q="BLUR",G="DISABLE",X="ENABLE",Y=function(e,t){switch(t.type){case U:var n=new Set(e.expandedIds);return n.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:n,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R:var a,r=new Set(e.expandedIds),l=u(t.ids);try{for(l.s();!(a=l.n()).done;){var i=a.value;r.delete(i)}}catch(e){l.e(e)}finally{l.f()}return Object.assign(Object.assign({},e),{expandedIds:r,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case T:var d=new Set(e.expandedIds);return d.add(t.id),Object.assign(Object.assign({},e),{expandedIds:d,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case F:var c=new Set([].concat(s(e.expandedIds),s(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case K:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return f.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:f,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case _:if(!t.controlled&&e.disabledIds.has(t.id))return e;var v;t.multiSelect?(v=new Set(e.selectedIds)).add(t.id):(v=new Set).add(t.id);var b=new Set(e.halfSelectedIds);return b.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:v,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:if(!t.controlled&&e.disabledIds.has(t.id))return e;var I,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(I=new Set(e.halfSelectedIds)).delete(t.id):I=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case H:if(e.disabledIds.has(t.id))return e;var y,m=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),m?y.delete(t.id):y.add(t.id)):(y=new Set,m||y.add(t.id));var g=new Set(e.halfSelectedIds);return g.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:g,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case P:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(s(e.selectedIds),s(E))):p(e.selectedIds,new Set(E));var O=p(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case M:var x,W=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){x=t.select?new Set(W):p(e.selectedIds,new Set(W));var A=p(e.halfSelectedIds,x);return Object.assign(Object.assign({},e),{selectedIds:x,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case V:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case q:return Object.assign(Object.assign({},e),{isFocused:!1});case G:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case X:var D=new Set(e.disabledIds);return D.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:D});default:throw new Error("Invalid action passed to the reducer")}},$={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},J=function(e){var t=e.data,n=e.controlledIds,r=e.controlledExpandedIds,l=e.defaultExpandedIds,i=e.defaultSelectedIds,c=e.defaultDisabledIds,o=e.nodeRefs,f=e.leafRefs,h=e.onSelect,g=e.onExpand,w=e.onLoadData,E=e.togglableSelect,O=e.multiSelect,x=e.propagateSelect,W=e.propagateSelectUpwards,A=k(t),D=d(a.useReducer(Y,{selectedIds:new Set(n||i),tabbableId:A.children[0],isFocused:!1,expandedIds:new Set(r||l),halfSelectedIds:new Set,lastUserSelect:A.children[0],lastInteractedWith:null,disabledIds:new Set(c)}),2),C=D[0],L=D[1],H=C.selectedIds,M=C.expandedIds,q=C.disabledIds,G=C.tabbableId,X=C.halfSelectedIds,$=C.lastAction,J=C.lastInteractedWith,Q=b(H)||new Set,Z=v(H,Q);a.useEffect((function(){var e;if(null!=h&&h!==te){var n,a=u(Z);try{for(a.s();!(n=a.n()).done;){var r=n.value,l=I(t,r)||!!(null===(e=N(t,G))||void 0===e?void 0:e.isBranch);h({element:N(t,r),isBranch:l,isExpanded:!!l&&M.has(r),isSelected:H.has(r),isDisabled:q.has(r),isHalfSelected:!!l&&X.has(r),treeState:C})}}catch(e){a.e(e)}finally{a.f()}}}),[t,H,M,q,X,Z,h,C]);var ee=b(M)||new Set;a.useEffect((function(){var e=v(M,ee);if(null!=g&&g!==te){var n,a=u(e);try{for(a.s();!(n=a.n()).done;){var r=n.value;g({element:N(t,r),isExpanded:M.has(r),isSelected:H.has(r),isDisabled:q.has(r),isHalfSelected:X.has(r),treeState:C})}}catch(e){a.e(e)}finally{a.f()}}}),[t,H,M,q,X,ee,g,C]);var ne,ae,re=(ne=t,ae=a.useRef(),a.useEffect((function(){ae.current=ne})),ae.current||new Map);return a.useEffect((function(){var e=v(M,ee);if(w){var n,a=u(e);try{for(a.s();!(n=a.n()).done;){var r=n.value;w({element:N(t,r),isExpanded:M.has(r),isSelected:H.has(r),isDisabled:q.has(r),isHalfSelected:X.has(r),treeState:C})}}catch(e){a.e(e)}finally{a.f()}if(re!==t&&E&&x){var l,i=u(M);try{for(i.s();!(l=i.n()).done;){var d=l.value;H.has(d)&&L({type:P,ids:j(t,[d],q),select:!0,multiSelect:O,lastInteractedWith:d})}}catch(e){i.e(e)}finally{i.f()}}}}),[t,H,M,q,X,ee,w,C]),a.useEffect((function(){var e=new Set(n),a=p(e,Q),r=p(Q,e);if(r.size){var l,i=u(r);try{for(i.s();!(l=i.n()).done;){var d=l.value;L({type:z,id:d,multiSelect:O,controlled:!0,lastInteractedWith:d})}}catch(e){i.e(e)}finally{i.f()}}if(a.size){var s,c=u(a);try{for(c.s();!(s=c.n()).done;){var o=s.value;L({type:_,id:o,multiSelect:O,controlled:!0,lastInteractedWith:o}),x&&!q.has(o)&&L({type:P,ids:j(t,[o],q),select:!0,multiSelect:O,lastInteractedWith:o})}}catch(e){c.e(e)}finally{c.f()}}}),[n]),a.useEffect((function(){var e=new Set(r),n=p(e,ee),a=p(ee,e);if(a.size){var l,i=u(a);try{for(i.s();!(l=i.n()).done;){var d=l.value;if(I(t,d)||N(t,d).isBranch){var c=[d].concat(s(m(t,d,new Set)));L({type:R,ids:c,lastInteractedWith:d})}}}catch(e){i.e(e)}finally{i.f()}}if(n.size){var o,f=u(n);try{for(f.s();!(o=f.n()).done;){var h=o.value;if(I(t,h)||N(t,h).isBranch){var v=S(t,h);L(v?{type:F,ids:[h,v],lastInteractedWith:h}:{type:T,id:h,lastInteractedWith:h})}}}catch(e){f.e(e)}finally{f.f()}}}),[r]),a.useEffect((function(){if(W){var e=new Set(Z);J&&$!==V&&$!==U&&$!==T&&$!==K&&e.add(J);var n,a=function(e,t,n,a,r,l){var i,d={every:new Set,some:new Set,none:new Set},s=u(t);try{for(s.s();!(i=s.n()).done;)for(var c=i.value;;){var o=S(e,c);if(0===o||null==o||null!=o&&a.has(o))break;var f=N(e,o).children.filter((function(e){return!a.has(e)}));if(0===f.length)break;if(f.some((function(e){return n.has(e)||d.some.has(e)||r.has(e)})))f.every((function(e){return n.has(e)}))?d.every.add(o):d.some.add(o);else{var h=y(e,c,a).find((function(e){return n.has(e)}));if(!l&&h){m(e,h,a).forEach((function(e){r.has(e)&&d.none.add(e)}));break}d.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return d}(t,e,H,q,X,O),r=a.every,l=a.some,i=a.none,d=u(r);try{for(d.s();!(n=d.n()).done;){var s=n.value;H.has(s)||L({type:_,id:s,multiSelect:O,keepFocus:!0,NotUserAction:!0,lastInteractedWith:J})}}catch(e){d.e(e)}finally{d.f()}var c,o=u(l);try{for(o.s();!(c=o.n()).done;){var f=c.value;X.has(f)||L({type:B,id:f,lastInteractedWith:J})}}catch(e){o.e(e)}finally{o.f()}var h,p=u(i);try{for(p.s();!(h=p.n()).done;){var v=h.value;(H.has(v)||X.has(v))&&L({type:z,id:v,multiSelect:O,keepFocus:!0,NotUserAction:!0,lastInteractedWith:J})}}catch(e){p.e(e)}finally{p.f()}}}),[t,O,W,H,M,q,X,$,Q,Z,J]),a.useEffect((function(){if(null!=J&&null!=G&&null!=(null==o?void 0:o.current)&&null!=(null==f?void 0:f.current)){var e=o.current[G];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(f.current[J]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[G,o,f,J]),[C,L]},Q={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},Z=Object.freeze(Object.values(Q)),ee=Object.freeze(Object.values({check:"check",select:"select"})),te=function(){},ne=r.forwardRef((function(e,n){var i=e.data,s=e.selectedIds,c=e.nodeRenderer,o=e.onSelect,u=void 0===o?te:o,h=e.onExpand,p=void 0===h?te:h,v=e.onLoadData,b=e.className,I=void 0===b?"":b,S=e.multiSelect,y=void 0!==S&&S,m=e.propagateSelect,g=void 0!==m&&m,w=e.propagateSelectUpwards,E=void 0!==w&&w,O=e.propagateCollapse,x=void 0!==O&&O,W=e.expandOnKeyboardSelect,A=void 0!==W&&W,j=e.togglableSelect,C=void 0!==j&&j,U=e.defaultExpandedIds,R=void 0===U?[]:U,T=e.defaultSelectedIds,F=void 0===T?[]:T,B=e.defaultDisabledIds,_=void 0===B?[]:B,z=e.clickAction,K=void 0===z?Q.select:z,H=e.nodeAction,P=void 0===H?"select":H,M=e.expandedIds,V=e.onBlur,G=f(e,["data","selectedIds","nodeRenderer","onSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]);!function(e){if(L(e.map((function(e){return e.id}))))throw Error("Multiple TreeView nodes have the same ID. IDs must be unique.");if(e.forEach((function(e){if(e.id===e.parent)throw Error("Node with id=".concat(e.id," has parent reference to itself."));if(L(e.children))throw Error("Node with id=".concat(e.id," contains duplicate ids in its children."))})),1!==e.filter((function(e){return null===e.parent})).length)throw Error("TreeView can have only one root node.")}(i);var X=a.useRef({}),Y=a.useRef({}),Z=d(J({data:i,controlledIds:s,controlledExpandedIds:M,defaultExpandedIds:R,defaultSelectedIds:F,defaultDisabledIds:_,nodeRefs:X,leafRefs:Y,onSelect:u,onExpand:p,onLoadData:v,togglableSelect:C,multiSelect:y,propagateSelect:g,propagateSelectUpwards:E}),2),ee=Z[0],ne=Z[1];g=g&&y;var re=a.useRef(null);return null!=n&&(re=n),r.createElement("ul",Object.assign({className:t($.root,I),role:"tree","aria-multiselectable":"select"===P?y:void 0,ref:re,onBlur:function(e){D(e,re.current,(function(){V&&V({treeState:ee,dispatch:ne}),ne({type:q})}))},onKeyDown:ie({data:i,tabbableId:ee.tabbableId,expandedIds:ee.expandedIds,selectedIds:ee.selectedIds,disabledIds:ee.disabledIds,halfSelectedIds:ee.halfSelectedIds,clickAction:K,dispatch:ne,propagateCollapse:x,propagateSelect:g,multiSelect:y,expandOnKeyboardSelect:A,togglableSelect:C})},G),k(i).children.map((function(e,t){return r.createElement(ae,Object.assign({key:"".concat(e,"-").concat(l(e)),data:i,element:N(i,e),setsize:k(i).children.length,posinset:t+1,level:1},ee,{state:ee,dispatch:ne,nodeRefs:X,leafRefs:Y,baseClassNames:$,nodeRenderer:c,propagateCollapse:x,propagateSelect:g,propagateSelectUpwards:E,multiSelect:y,togglableSelect:C,clickAction:K,nodeAction:P}))})))})),ae=function(e){var n=e.element,a=e.dispatch,l=e.data,d=e.selectedIds,c=e.tabbableId,o=e.isFocused,u=e.expandedIds,f=e.disabledIds,p=e.halfSelectedIds,v=e.lastUserSelect,b=e.nodeRefs,S=e.leafRefs,y=e.baseClassNames,g=e.nodeRenderer,w=e.nodeAction,E=e.setsize,O=e.posinset,D=e.level,k=e.propagateCollapse,N=e.propagateSelect,L=e.multiSelect,U=e.togglableSelect,T=e.clickAction,F=e.state,z=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(n.id)&&k){var t=[n.id].concat(s(m(l,n.id,new Set)));a({type:R,ids:t,lastInteractedWith:n.id})}else a({type:K,id:n.id,lastInteractedWith:n.id})},q=function(){return a({type:V,id:n.id,lastInteractedWith:n.id})},G=function(e){if(e.shiftKey){var t=x({data:l,expandedIds:u,from:v,to:n.id}).filter((function(e){return!f.has(e)}));t=N?j(l,t,f):t,a({type:M,select:!0,multiSelect:L,ids:t,lastInteractedWith:n.id})}else if(e.ctrlKey||T===Q.select){var r=C(l,n.id,d);a({type:U?r?B:H:_,id:n.id,multiSelect:L,lastInteractedWith:n.id}),N&&!f.has(n.id)&&a({type:P,ids:j(l,[n.id],f),select:!U||!d.has(n.id),multiSelect:L,lastInteractedWith:n.id})}else T===Q.exclusiveSelect?a({type:U?H:_,id:n.id,multiSelect:!1,lastInteractedWith:n.id}):T===Q.focus&&a({type:V,id:n.id,lastInteractedWith:n.id})},X=function(e){var a;return t(e,(i(a={},"".concat(e,"--expanded"),u.has(n.id)),i(a,"".concat(e,"--selected"),d.has(n.id)),i(a,"".concat(e,"--focused"),c===n.id&&o),a))},Y="select"===w?{"aria-selected":W({isSelected:d.has(n.id),isDisabled:f.has(n.id),multiSelect:L})}:{"aria-checked":A({isSelected:d.has(n.id),isDisabled:f.has(n.id),isHalfSelected:p.has(n.id),multiSelect:L})};return I(l,n.id)||n.isBranch?r.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(n.id),"aria-setsize":E,"aria-posinset":O,"aria-level":D,"aria-disabled":f.has(n.id),tabIndex:c===n.id?0:-1,ref:function(e){null!=(null==b?void 0:b.current)&&null!=e&&(b.current[n.id]=e)},className:y.branchWrapper},Y),r.createElement(r.Fragment,null,g({element:n,isBranch:!0,isSelected:d.has(n.id),isHalfSelected:p.has(n.id),isExpanded:u.has(n.id),isDisabled:f.has(n.id),dispatch:a,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=e.onClick;return{onClick:null==a?h(G,z,q):h(a,q),className:t(X(y.node),y.branch),ref:function(e){null!=(null==S?void 0:S.current)&&(S.current[n.id]=e)}}},setsize:E,posinset:O,level:D,handleSelect:G,handleExpand:z,treeState:F}),r.createElement(le,Object.assign({getClasses:X},re(e))))):r.createElement("li",{role:"none",className:X(y.leafListItem)},g({element:n,isBranch:!1,isSelected:d.has(n.id),isHalfSelected:!1,isExpanded:!1,isDisabled:f.has(n.id),dispatch:a,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=e.onClick;return Object.assign({role:"treeitem",tabIndex:c===n.id?0:-1,onClick:h(null==a?G:a,q),ref:function(e){null!=(null==b?void 0:b.current)&&null!=(null==S?void 0:S.current)&&(b.current[n.id]=e,S.current[n.id]=e)},className:t(X(y.node),y.leaf),"aria-setsize":E,"aria-posinset":O,"aria-level":D,disabled:f.has(n.id),"aria-disabled":f.has(n.id)},Y)},setsize:E,posinset:O,level:D,handleSelect:G,handleExpand:te,treeState:F}))},re=function(e){e.setsize,e.posinset;return f(e,["setsize","posinset"])},le=function(e){var t=e.data,n=e.element,a=e.expandedIds,i=e.getClasses,d=e.baseClassNames,s=e.level,c=f(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return r.createElement("ul",{role:"group",className:i(d.nodeGroup)},a.has(n.id)&&n.children.length>0&&n.children.map((function(e,i){return r.createElement(ae,Object.assign({data:t,expandedIds:a,baseClassNames:d,key:"".concat(e,"-").concat(l(e)),element:N(t,e),setsize:n.children.length,posinset:i+1,level:s+1},c))})))},ie=function(e){var t=e.data,n=e.expandedIds,a=e.selectedIds,r=e.disabledIds,l=e.tabbableId,i=e.dispatch,d=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=N(t,l),v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var b=t.filter((function(e){return null!==e.parent})).map((function(e){return e.id})).filter((function(e){return!r.has(e)}));i({type:P,multiSelect:o,select:Array.from(a).filter((function(e){return!r.has(e)})).length!==b.length,ids:b,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var y="Home"===e.key?k(t).children[0]:w(t,v,n),g=x({data:t,expandedIds:n,from:v,to:y}).filter((function(e){return!r.has(e)}));i({type:P,multiSelect:o,select:!0,ids:c?j(t,g,r):g}),i({type:V,id:y,lastInteractedWith:y})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var W=E(t,v,n);return void(null==W||r.has(W)||(i({type:P,ids:c?j(t,[W],r):[W],select:!0,multiSelect:o,lastInteractedWith:W}),i({type:V,id:W,lastInteractedWith:W})));case"ArrowDown":e.preventDefault();var A=O(t,v,n);return void(null==A||r.has(A)||(i({type:P,ids:c?j(t,[A],r):[A],multiSelect:o,select:!0,lastInteractedWith:A}),i({type:V,id:A,lastInteractedWith:A})))}switch(e.key){case"ArrowDown":e.preventDefault();var D=O(t,v,n);return void(null!=D&&i({type:V,id:D,lastInteractedWith:D}));case"ArrowUp":e.preventDefault();var L=E(t,v,n);return void(null!=L&&i({type:V,id:L,lastInteractedWith:L}));case"ArrowLeft":if(e.preventDefault(),(I(t,v)||p.isBranch)&&n.has(l))if(d){var z=[v].concat(s(m(t,v,new Set)));i({type:R,ids:z,lastInteractedWith:p.id})}else i({type:U,id:v,lastInteractedWith:v});else if(!k(t).children.includes(v)){var M=S(t,v);if(null==M)throw new Error("parentId of root element is null");i({type:V,id:M,lastInteractedWith:M})}return;case"ArrowRight":return e.preventDefault(),void((I(t,v)||p.isBranch)&&(n.has(l)?i({type:V,id:p.children[0],lastInteractedWith:p.children[0]}):i({type:T,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),i({type:V,id:k(t).children[0],lastInteractedWith:k(t).children[0]});break;case"End":e.preventDefault();var q=w(t,k(t).id,n);return void i({type:V,id:q,lastInteractedWith:q});case"*":e.preventDefault();var G=S(t,v);if(null==G)throw new Error("parentId of element is null");var X=N(t,G).children.filter((function(e){return I(t,e)||N(t,e).isBranch}));return void i({type:F,ids:X,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===Q.focus)return;var Y=C(t,p.id,a);return i({type:f?Y?B:H:_,id:v,multiSelect:o,lastInteractedWith:v}),c&&!r.has(p.id)&&i({type:P,ids:j(t,[v],r),select:!f||!a.has(v),multiSelect:o,lastInteractedWith:v}),void(u&&i({type:K,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var $=O(t,v,n);$!==v;)if(null!=$){if(N(t,$).name[0].toLowerCase()===e.key.toLowerCase())return void i({type:V,id:$,lastInteractedWith:v});$=O(t,$,n)}else $=k(t).children[0];return}}}};ne.propTypes={data:n.array.isRequired,onSelect:n.func,onExpand:n.func,className:n.string,nodeRenderer:n.func.isRequired,defaultExpandedIds:n.array,defaultSelectedIds:n.array,expandedIds:n.array,selectedIds:n.array,defaultDisabledIds:n.array,propagateCollapse:n.bool,propagateSelect:n.bool,propagateSelectUpwards:n.bool,multiSelect:n.bool,expandOnKeyboardSelect:n.bool,togglableSelect:n.bool,nodeAction:n.oneOf(ee),clickAction:n.oneOf(Z),onBlur:n.func,onLoadData:n.func},exports.CLICK_ACTIONS=Z,exports.default=ne,exports.flattenTree=function(e){var t=0,n=[];return function e(a,r){var l,i={id:a.id||t,name:a.name,children:[],parent:r};if(n.find((function(e){return e.id===i.id})))throw Error("Multiple TreeView nodes have the same ID (".concat(i.id,"). IDs must be unique."));if(n.push(i),t+=1,null===(l=a.children)||void 0===l?void 0:l.length){var d,s=u(a.children);try{for(s.s();!(d=s.n()).done;){e(d.value,i.id)}}catch(e){s.e(e)}finally{s.f()}var c,o=u(n.values());try{for(o.s();!(c=o.n()).done;){var f=c.value;f.parent===i.id&&i.children.push(f.id)}}catch(e){o.e(e)}finally{o.f()}}}(e,null),n};

@@ -1,1 +0,1 @@

import e from"classnames";import t from"prop-types";import a,{useRef as n,useEffect as r,useReducer as l}from"react";function d(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,r,l=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);d=!0);}catch(e){i=!0,r=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw r}}return l}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return o(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function u(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=c(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,d=!0,i=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return d=e.done,e},e:function(e){i=!0,l=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw l}}}}function f(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]])}return a}var h=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){var a,n=u(t);try{for(n.s();!(a=n.n()).done;){var r=a.value;if(r&&r(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},p=function(e,t){var a,n=new Set,r=u(e);try{for(r.s();!(a=r.n()).done;){var l=a.value;t.has(l)||n.add(l)}}catch(e){r.e(e)}finally{r.f()}return n},v=function(e,t){return new Set([].concat(s(p(e,t)),s(p(t,e))))},I=function(e){var t=n();return r((function(){t.current=e}),[e]),t.current},b=function(e,t){return null!=e[t].children&&e[t].children.length>0},S=function(e,t){return e[t].parent},y=function(e,t,a){for(var n=t,r=[];;){var l=S(e,n);if(0===l||null==l||null!=l&&a.has(l))break;r.push(l),n=l}return r},m=function(e,t,a){var n=[];return function e(t,r){var l=t[r];if(null!=l.children){var d,i=u(l.children.filter((function(e){return!a.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;n.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),n},g=function(e,t,a){var n=S(e,t);if(null!=n){var r=e[n],l=r.children.indexOf(t)+a;if(r.children[l])return r.children[l]}return null},w=function(e,t,a){var n=e[t];for(e[0].id===t&&(n=e[e[t].children[e[t].children.length-1]]);a.has(n.id)&&b(e,n.id);)n=e[n.children[n.children.length-1]];return n.id},E=function(e,t,a){if(t===e[0].children[0])return null;var n=g(e,t,-1);return null==n?S(e,t):w(e,n,a)},O=function(e,t,a){var n=e[t].id;if(b(e,n)&&a.has(n))return e[n].children[0];for(;;){var r=g(e,n,1);if(null!=r)return r;if(null==(n=S(e,n)))return null}},W=function(e){var t=e.data,a=e.expandedIds,n=e.from,r=e.to,l=[],d=Object.keys(t).length,i=0,s=n;if(l.push(n),n<r)for(;i<d&&(null!=(s=O(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;else if(n>r)for(;i<d&&(null!=(s=E(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;return l},x=function(e){var t=0,a=[];return function e(n,r){var l={id:t,name:n.name,children:[],parent:r};if(a[t]=l,t+=1,null!=n.children&&0!==n.children.length){var d,i=u(n.children);try{for(i.s();!(d=i.n()).done;){e(d.value,l.id)}}catch(e){i.e(e)}finally{i.f()}l.children=a.filter((function(e){return e.parent===l.id})).map((function(e){return e.id}))}}(e,null),a},A=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},j=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,r=e.multiSelect;return a?t:n?"mixed":r?t:!!t||void 0},C=function(e,t,a){return t.concat.apply(t,s(t.filter((function(t){return b(e,t)})).map((function(t){return m(e,t,a)}))))},D=function(e,t,a){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&a()}),0):!t.contains(e.nativeEvent.relatedTarget)&&a():console.warn("ref not set on <ul>")},k=function(e,t,a){return b(e,t)&&a.has(t)&&m(e,t,new Set).some((function(e){return a.has(e)}))},L={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},N="COLLAPSE",U="COLLAPSE_MANY",F="EXPAND",R="EXPAND_MANY",B="HALF_SELECT",T="SELECT",z="DESELECT",K="TOGGLE",_="TOGGLE_SELECT",H="SELECT_MANY",P="EXCLUSIVE_CHANGE_SELECT_MANY",G="FOCUS",M="BLUR",V="DISABLE",X="ENABLE",Y=function(e,t){switch(t.type){case N:var a=new Set(e.expandedIds);return a.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:a,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case U:var n,r=new Set(e.expandedIds),l=u(t.ids);try{for(l.s();!(n=l.n()).done;){var d=n.value;r.delete(d)}}catch(e){l.e(e)}finally{l.f()}return Object.assign(Object.assign({},e),{expandedIds:r,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case F:var i=new Set(e.expandedIds);return i.add(t.id),Object.assign(Object.assign({},e),{expandedIds:i,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R:var c=new Set([].concat(s(e.expandedIds),s(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case K:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return f.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:f,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case T:if(!t.controlled&&e.disabledIds.has(t.id))return e;var v;t.multiSelect?(v=new Set(e.selectedIds)).add(t.id):(v=new Set).add(t.id);var I=new Set(e.halfSelectedIds);return I.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:v,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:if(!t.controlled&&e.disabledIds.has(t.id))return e;var b,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(b=new Set(e.halfSelectedIds)).delete(t.id):b=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case _:if(e.disabledIds.has(t.id))return e;var y,m=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),m?y.delete(t.id):y.add(t.id)):(y=new Set,m||y.add(t.id));var g=new Set(e.halfSelectedIds);return g.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:g,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case H:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(s(e.selectedIds),s(E))):p(e.selectedIds,new Set(E));var O=p(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case P:var W,x=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){W=t.select?new Set(x):p(e.selectedIds,new Set(x));var A=p(e.halfSelectedIds,W);return Object.assign(Object.assign({},e),{selectedIds:W,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case G:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case M:return Object.assign(Object.assign({},e),{isFocused:!1});case V:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case X:var C=new Set(e.disabledIds);return C.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:C});default:throw new Error("Invalid action passed to the reducer")}},q=function(e){var t=e.data,a=e.controlledIds,d=e.controlledExpandedIds,c=e.defaultExpandedIds,o=e.defaultSelectedIds,f=e.defaultDisabledIds,h=e.nodeRefs,g=e.leafRefs,w=e.onSelect,E=e.onExpand,O=e.onLoadData,W=e.togglableSelect,x=e.multiSelect,A=e.propagateSelect,j=e.propagateSelectUpwards,D=i(l(Y,{selectedIds:new Set(a||o),tabbableId:t[0].children[0],isFocused:!1,expandedIds:new Set(d||c),halfSelectedIds:new Set,lastUserSelect:t[0].children[0],lastInteractedWith:null,disabledIds:new Set(f)}),2),k=D[0],L=D[1],_=k.selectedIds,P=k.expandedIds,M=k.disabledIds,V=k.tabbableId,X=k.halfSelectedIds,q=k.lastAction,$=k.lastInteractedWith,J=I(_)||new Set,Q=v(_,J);r((function(){if(null!=w&&w!==Z){var e,a=u(Q);try{for(a.s();!(e=a.n()).done;){var n=e.value,r=b(t,n)||!!t[V].isBranch;w({element:t[n],isBranch:r,isExpanded:!!r&&P.has(n),isSelected:_.has(n),isDisabled:M.has(n),isHalfSelected:!!r&&X.has(n),treeState:k})}}catch(e){a.e(e)}finally{a.f()}}}),[t,_,P,M,X,Q,w,k]);var ee=I(P)||new Set;r((function(){var e=v(P,ee);if(null!=E&&E!==Z){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;E({element:t[r],isExpanded:P.has(r),isSelected:_.has(r),isDisabled:M.has(r),isHalfSelected:X.has(r),treeState:k})}}catch(e){n.e(e)}finally{n.f()}}}),[t,_,P,M,X,ee,E,k]);var te,ae,ne=(te=t,ae=n(),r((function(){ae.current=te})),ae.current||new Set);return r((function(){var e=v(P,ee);if(O){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;O({element:t[r],isExpanded:P.has(r),isSelected:_.has(r),isDisabled:M.has(r),isHalfSelected:X.has(r),treeState:k})}}catch(e){n.e(e)}finally{n.f()}if(ne!==t&&W&&A){var l,d=u(P);try{for(d.s();!(l=d.n()).done;){var i=l.value;_.has(i)&&L({type:H,ids:C(t,[i],M),select:!0,multiSelect:x,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,_,P,M,X,ee,O,k]),r((function(){var e=new Set(a),n=p(e,J),r=p(J,e);if(r.size){var l,d=u(r);try{for(d.s();!(l=d.n()).done;){var i=l.value;L({type:z,id:i,multiSelect:x,controlled:!0,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}if(n.size){var s,c=u(n);try{for(c.s();!(s=c.n()).done;){var o=s.value;L({type:T,id:o,multiSelect:x,controlled:!0,lastInteractedWith:o}),A&&!M.has(o)&&L({type:H,ids:C(t,[o],M),select:!0,multiSelect:x,lastInteractedWith:o})}}catch(e){c.e(e)}finally{c.f()}}}),[a]),r((function(){var e=new Set(d),a=p(e,ee),n=p(ee,e);if(n.size){var r,l=u(n);try{for(l.s();!(r=l.n()).done;){var i=r.value;if(b(t,i)||t[i].isBranch){var c=[i].concat(s(m(t,i,new Set)));L({type:U,ids:c,lastInteractedWith:i})}}}catch(e){l.e(e)}finally{l.f()}}if(a.size){var o,f=u(a);try{for(f.s();!(o=f.n()).done;){var h=o.value;if(b(t,h)||t[h].isBranch){var v=S(t,h);L(v?{type:R,ids:[h,v],lastInteractedWith:h}:{type:F,id:h,lastInteractedWith:h})}}}catch(e){f.e(e)}finally{f.f()}}}),[d]),r((function(){if(j){var e=new Set(Q);$&&q!==G&&q!==N&&q!==F&&q!==K&&e.add($);var a,n=function(e,t,a,n,r,l){var d,i={every:new Set,some:new Set,none:new Set},s=u(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var o=S(e,c);if(0===o||null==o||null!=o&&n.has(o))break;var f=e[o].children.filter((function(e){return!n.has(e)}));if(0===f.length)break;if(f.some((function(e){return a.has(e)||i.some.has(e)||r.has(e)})))f.every((function(e){return a.has(e)}))?i.every.add(o):i.some.add(o);else{var h=y(e,c,n).find((function(e){return a.has(e)}));if(!l&&h){m(e,h,n).forEach((function(e){r.has(e)&&i.none.add(e)}));break}i.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,_,M,X,x),r=n.every,l=n.some,d=n.none,i=u(r);try{for(i.s();!(a=i.n()).done;){var s=a.value;_.has(s)||L({type:T,id:s,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:$})}}catch(e){i.e(e)}finally{i.f()}var c,o=u(l);try{for(o.s();!(c=o.n()).done;){var f=c.value;X.has(f)||L({type:B,id:f,lastInteractedWith:$})}}catch(e){o.e(e)}finally{o.f()}var h,p=u(d);try{for(p.s();!(h=p.n()).done;){var v=h.value;(_.has(v)||X.has(v))&&L({type:z,id:v,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:$})}}catch(e){p.e(e)}finally{p.f()}}}),[t,x,j,_,P,M,X,q,J,Q,$]),r((function(){if(null!=$&&null!=V&&null!=(null==h?void 0:h.current)&&null!=(null==g?void 0:g.current)){var e=h.current[V];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(g.current[$]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[V,h,g,$]),[k,L]},$={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},J=Object.freeze(Object.values($)),Q=Object.freeze(Object.values({check:"check",select:"select"})),Z=function(){},ee=a.forwardRef((function(t,r){var l=t.data,d=t.selectedIds,s=t.nodeRenderer,c=t.onSelect,o=void 0===c?Z:c,u=t.onExpand,h=void 0===u?Z:u,p=t.onLoadData,v=t.className,I=void 0===v?"":v,b=t.multiSelect,S=void 0!==b&&b,y=t.propagateSelect,m=void 0!==y&&y,g=t.propagateSelectUpwards,w=void 0!==g&&g,E=t.propagateCollapse,O=void 0!==E&&E,W=t.expandOnKeyboardSelect,x=void 0!==W&&W,A=t.togglableSelect,j=void 0!==A&&A,C=t.defaultExpandedIds,k=void 0===C?[]:C,N=t.defaultSelectedIds,U=void 0===N?[]:N,F=t.defaultDisabledIds,R=void 0===F?[]:F,B=t.clickAction,T=void 0===B?$.select:B,z=t.nodeAction,K=void 0===z?"select":z,_=t.expandedIds,H=t.onBlur,P=f(t,["data","selectedIds","nodeRenderer","onSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]),G=n({}),V=n({}),X=i(q({data:l,controlledIds:d,controlledExpandedIds:_,defaultExpandedIds:k,defaultSelectedIds:U,defaultDisabledIds:R,nodeRefs:G,leafRefs:V,onSelect:o,onExpand:h,onLoadData:p,togglableSelect:j,multiSelect:S,propagateSelect:m,propagateSelectUpwards:w}),2),Y=X[0],J=X[1];m=m&&S;var Q=n(null);return null!=r&&(Q=r),a.createElement("ul",Object.assign({className:e(L.root,I),role:"tree","aria-multiselectable":"select"===K?S:void 0,ref:Q,onBlur:function(e){D(e,Q.current,(function(){H&&H({treeState:Y,dispatch:J}),J({type:M})}))},onKeyDown:re({data:l,tabbableId:Y.tabbableId,expandedIds:Y.expandedIds,selectedIds:Y.selectedIds,disabledIds:Y.disabledIds,halfSelectedIds:Y.halfSelectedIds,clickAction:T,dispatch:J,propagateCollapse:O,propagateSelect:m,multiSelect:S,expandOnKeyboardSelect:x,togglableSelect:j})},P),l[0].children.map((function(e,t){return a.createElement(te,Object.assign({key:e,data:l,element:l[e],setsize:l[0].children.length,posinset:t+1,level:1},Y,{state:Y,dispatch:J,nodeRefs:G,leafRefs:V,baseClassNames:L,nodeRenderer:s,propagateCollapse:O,propagateSelect:m,propagateSelectUpwards:w,multiSelect:S,togglableSelect:j,clickAction:T,nodeAction:K}))})))})),te=function(t){var n=t.element,r=t.dispatch,l=t.data,i=t.selectedIds,c=t.tabbableId,o=t.isFocused,u=t.expandedIds,f=t.disabledIds,p=t.halfSelectedIds,v=t.lastUserSelect,I=t.nodeRefs,S=t.leafRefs,y=t.baseClassNames,g=t.nodeRenderer,w=t.nodeAction,E=t.setsize,O=t.posinset,x=t.level,D=t.propagateCollapse,L=t.propagateSelect,N=t.multiSelect,F=t.togglableSelect,R=t.clickAction,z=t.state,M=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(n.id)&&D){var t=[n.id].concat(s(m(l,n.id,new Set)));r({type:U,ids:t,lastInteractedWith:n.id})}else r({type:K,id:n.id,lastInteractedWith:n.id})},V=function(){return r({type:G,id:n.id,lastInteractedWith:n.id})},X=function(e){if(e.shiftKey){var t=W({data:l,expandedIds:u,from:v,to:n.id}).filter((function(e){return!f.has(e)}));t=L?C(l,t,f):t,r({type:P,select:!0,multiSelect:N,ids:t,lastInteractedWith:n.id})}else if(e.ctrlKey||R===$.select){var a=k(l,n.id,i);r({type:F?a?B:_:T,id:n.id,multiSelect:N,lastInteractedWith:n.id}),L&&!f.has(n.id)&&r({type:H,ids:C(l,[n.id],f),select:!F||!i.has(n.id),multiSelect:N,lastInteractedWith:n.id})}else R===$.exclusiveSelect?r({type:F?_:T,id:n.id,multiSelect:!1,lastInteractedWith:n.id}):R===$.focus&&r({type:G,id:n.id,lastInteractedWith:n.id})},Y=function(t){var a;return e(t,(d(a={},"".concat(t,"--expanded"),u.has(n.id)),d(a,"".concat(t,"--selected"),i.has(n.id)),d(a,"".concat(t,"--focused"),c===n.id&&o),a))},q="select"===w?{"aria-selected":A({isSelected:i.has(n.id),isDisabled:f.has(n.id),multiSelect:N})}:{"aria-checked":j({isSelected:i.has(n.id),isDisabled:f.has(n.id),isHalfSelected:p.has(n.id),multiSelect:N})};return b(l,n.id)||n.isBranch?a.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(n.id),"aria-setsize":E,"aria-posinset":O,"aria-level":x,"aria-disabled":f.has(n.id),tabIndex:c===n.id?0:-1,ref:function(e){null!=(null==I?void 0:I.current)&&null!=e&&(I.current[n.id]=e)},className:y.branchWrapper},q),a.createElement(a.Fragment,null,g({element:n,isBranch:!0,isSelected:i.has(n.id),isHalfSelected:p.has(n.id),isExpanded:u.has(n.id),isDisabled:f.has(n.id),dispatch:r,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return{onClick:null==a?h(X,M,V):h(a,V),className:e(Y(y.node),y.branch),ref:function(e){null!=(null==S?void 0:S.current)&&(S.current[n.id]=e)}}},setsize:E,posinset:O,level:x,handleSelect:X,handleExpand:M,treeState:z}),a.createElement(ne,Object.assign({getClasses:Y},ae(t))))):a.createElement("li",{role:"none",className:Y(y.leafListItem)},g({element:n,isBranch:!1,isSelected:i.has(n.id),isHalfSelected:!1,isExpanded:!1,isDisabled:f.has(n.id),dispatch:r,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return Object.assign({role:"treeitem",tabIndex:c===n.id?0:-1,onClick:h(null==a?X:a,V),ref:function(e){null!=(null==I?void 0:I.current)&&null!=(null==S?void 0:S.current)&&(I.current[n.id]=e,S.current[n.id]=e)},className:e(Y(y.node),y.leaf),"aria-setsize":E,"aria-posinset":O,"aria-level":x,disabled:f.has(n.id),"aria-disabled":f.has(n.id)},q)},setsize:E,posinset:O,level:x,handleSelect:X,handleExpand:Z,treeState:z}))},ae=function(e){e.setsize,e.posinset;return f(e,["setsize","posinset"])},ne=function(e){var t=e.data,n=e.element,r=e.expandedIds,l=e.getClasses,d=e.baseClassNames,i=e.level,s=f(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return a.createElement("ul",{role:"group",className:l(d.nodeGroup)},r.has(n.id)&&n.children.length>0&&n.children.map((function(e,l){return a.createElement(te,Object.assign({data:t,expandedIds:r,baseClassNames:d,key:e,element:t[e],setsize:n.children.length,posinset:l+1,level:i+1},s))})))},re=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,r=e.disabledIds,l=e.tabbableId,d=e.dispatch,i=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=t[l],v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var I=t.filter((function(e){return 0!==e.id})),y=Object.values(I).map((function(e){return e.id})).filter((function(e){return!r.has(e)}));d({type:H,multiSelect:o,select:Array.from(n).filter((function(e){return!r.has(e)})).length!==y.length,ids:y,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var g="Home"===e.key?t[0].children[0]:w(t,v,a),x=W({data:t,expandedIds:a,from:v,to:g}).filter((function(e){return!r.has(e)}));d({type:H,multiSelect:o,select:!0,ids:c?C(t,x,r):x}),d({type:G,id:g,lastInteractedWith:g})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var A=E(t,v,a);return void(null==A||r.has(A)||(d({type:H,ids:c?C(t,[A],r):[A],select:!0,multiSelect:o,lastInteractedWith:A}),d({type:G,id:A,lastInteractedWith:A})));case"ArrowDown":e.preventDefault();var j=O(t,v,a);return void(null==j||r.has(j)||(d({type:H,ids:c?C(t,[j],r):[j],multiSelect:o,select:!0,lastInteractedWith:j}),d({type:G,id:j,lastInteractedWith:j})))}switch(e.key){case"ArrowDown":e.preventDefault();var D=O(t,v,a);return void(null!=D&&d({type:G,id:D,lastInteractedWith:D}));case"ArrowUp":e.preventDefault();var L=E(t,v,a);return void(null!=L&&d({type:G,id:L,lastInteractedWith:L}));case"ArrowLeft":if(e.preventDefault(),(b(t,v)||p.isBranch)&&a.has(l))if(i){var z=[v].concat(s(m(t,v,new Set)));d({type:U,ids:z,lastInteractedWith:p.id})}else d({type:N,id:v,lastInteractedWith:v});else if(!t[0].children.includes(v)){var P=S(t,v);if(null==P)throw new Error("parentId of root element is null");d({type:G,id:P,lastInteractedWith:P})}return;case"ArrowRight":return e.preventDefault(),void((b(t,v)||p.isBranch)&&(a.has(l)?d({type:G,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:F,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),d({type:G,id:t[0].children[0],lastInteractedWith:t[0].children[0]});break;case"End":e.preventDefault();var M=w(t,t[0].id,a);return void d({type:G,id:M,lastInteractedWith:M});case"*":e.preventDefault();var V=S(t,v);if(null==V)throw new Error("parentId of element is null");var X=t[V].children.filter((function(e){return b(t,e)||t[e].isBranch}));return void d({type:R,ids:X,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===$.focus)return;var Y=k(t,p.id,n);return d({type:f?Y?B:_:T,id:v,multiSelect:o,lastInteractedWith:v}),c&&!r.has(p.id)&&d({type:H,ids:C(t,[v],r),select:!f||!n.has(v),multiSelect:o,lastInteractedWith:v}),void(u&&d({type:K,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var q=O(t,v,a);q!==v;)if(null!=q){if(t[q].name[0].toLowerCase()===e.key.toLowerCase())return void d({type:G,id:q,lastInteractedWith:v});q=O(t,q,a)}else q=t[0].children[0];return}}}};ee.propTypes={data:t.array.isRequired,onSelect:t.func,onExpand:t.func,className:t.string,nodeRenderer:t.func.isRequired,defaultExpandedIds:t.array,defaultSelectedIds:t.array,expandedIds:t.array,selectedIds:t.array,defaultDisabledIds:t.array,propagateCollapse:t.bool,propagateSelect:t.bool,propagateSelectUpwards:t.bool,multiSelect:t.bool,expandOnKeyboardSelect:t.bool,togglableSelect:t.bool,nodeAction:t.oneOf(Q),clickAction:t.oneOf(J),onBlur:t.func,onLoadData:t.func};export default ee;export{J as CLICK_ACTIONS,x as flattenTree};
import e from"classnames";import t from"prop-types";import n,{useRef as a,useEffect as r,useReducer as l}from"react";function i(e){return(i="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function d(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var a,r,l=[],i=!0,d=!1;try{for(n=n.call(e);!(i=(a=n.next()).done)&&(l.push(a.value),!t||l.length!==t);i=!0);}catch(e){d=!0,r=e}finally{try{i||null==n.return||n.return()}finally{if(d)throw r}}return l}(e,t)||o(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){return function(e){if(Array.isArray(e))return u(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||o(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function o(e,t){if(e){if("string"==typeof e)return u(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?u(e,t):void 0}}function u(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,a=new Array(t);n<t;n++)a[n]=e[n];return a}function f(e,t){var n="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!n){if(Array.isArray(e)||(n=o(e))||t&&e&&"number"==typeof e.length){n&&(e=n);var a=0,r=function(){};return{s:r,n:function(){return a>=e.length?{done:!0}:{done:!1,value:e[a++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,i=!0,d=!1;return{s:function(){n=n.call(e)},n:function(){var e=n.next();return i=e.done,e},e:function(e){d=!0,l=e},f:function(){try{i||null==n.return||n.return()}finally{if(d)throw l}}}}function h(e,t){var n={};for(var a in e)Object.prototype.hasOwnProperty.call(e,a)&&t.indexOf(a)<0&&(n[a]=e[a]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(a=Object.getOwnPropertySymbols(e);r<a.length;r++)t.indexOf(a[r])<0&&Object.prototype.propertyIsEnumerable.call(e,a[r])&&(n[a[r]]=e[a[r]])}return n}var p=function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(e){var n,a=f(t);try{for(a.s();!(n=a.n()).done;){var r=n.value;if(r&&r(e),e.defaultPrevented)break}}catch(e){a.e(e)}finally{a.f()}}},v=function(e,t){var n,a=new Set,r=f(e);try{for(r.s();!(n=r.n()).done;){var l=n.value;t.has(l)||a.add(l)}}catch(e){r.e(e)}finally{r.f()}return a},b=function(e,t){return new Set([].concat(c(v(e,t)),c(v(t,e))))},I=function(e){var t=a();return r((function(){t.current=e}),[e]),t.current},S=function(e,t){var n;return!!(null===(n=U(e,t).children)||void 0===n?void 0:n.length)},y=function(e,t){return U(e,t).parent},m=function(e,t,n){for(var a=t,r=[];;){var l=y(e,a);if(0===l||null==l||null!=l&&n.has(l))break;r.push(l),a=l}return r},g=function(e,t,n){var a=[];return function e(t,r){var l=U(t,r);if(null!=l.children){var i,d=f(l.children.filter((function(e){return!n.has(e)})));try{for(d.s();!(i=d.n()).done;){var s=i.value;a.push(s),e(t,s)}}catch(e){d.e(e)}finally{d.f()}}}(e,t),a},w=function(e,t,n){var a=y(e,t);if(null!=a){var r=U(e,a),l=r.children.indexOf(t)+n;if(r.children[l])return r.children[l]}return null},E=function(e,t,n){var a=U(e,t);for(L(e).id===t&&(a=U(e,U(e,t).children[U(e,t).children.length-1]));n.has(a.id)&&S(e,a.id);)a=U(e,a.children[a.children.length-1]);return a.id},O=function(e,t,n){if(t===L(e).children[0])return null;var a=w(e,t,-1);return null==a?y(e,t):E(e,a,n)},W=function(e,t,n){var a=U(e,t).id;if(S(e,a)&&n.has(a))return U(e,a).children[0];for(;;){var r=w(e,a,1);if(null!=r)return r;if(null==(a=y(e,a)))return null}},x=function(e){var t=e.data,n=e.expandedIds,a=e.from,r=e.to,l=[],i=t.length,d=0,s=a;if(l.push(a),a<r)for(;d<i&&(null!=(s=W(t,s,n))&&l.push(s),null!=s&&s!==r);)d+=1;else if(a>r)for(;d<i&&(null!=(s=O(t,s,n))&&l.push(s),null!=s&&s!==r);)d+=1;return l},A=function(e){var t=0,n=[];return function e(a,r){var l,i={id:a.id||t,name:a.name,children:[],parent:r};if(n.find((function(e){return e.id===i.id})))throw Error("Multiple TreeView nodes have the same ID (".concat(i.id,"). IDs must be unique."));if(n.push(i),t+=1,null===(l=a.children)||void 0===l?void 0:l.length){var d,s=f(a.children);try{for(s.s();!(d=s.n()).done;){e(d.value,i.id)}}catch(e){s.e(e)}finally{s.f()}var c,o=f(n.values());try{for(o.s();!(c=o.n()).done;){var u=c.value;u.parent===i.id&&i.children.push(u.id)}}catch(e){o.e(e)}finally{o.f()}}}(e,null),n},j=function(e){var t=e.isSelected,n=e.isDisabled,a=e.multiSelect;return n||a?t:!!t||void 0},D=function(e){var t=e.isSelected,n=e.isDisabled,a=e.isHalfSelected,r=e.multiSelect;return n?t:a?"mixed":r?t:!!t||void 0},C=function(e,t,n){return t.concat.apply(t,c(t.filter((function(t){return S(e,t)})).map((function(t){return g(e,t,n)}))))},k=function(e,t,n){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&n()}),0):!t.contains(e.nativeEvent.relatedTarget)&&n():console.warn("ref not set on <ul>")},N=function(e,t,n){return S(e,t)&&n.has(t)&&g(e,t,new Set).some((function(e){return n.has(e)}))},L=function(e){var t=e.find((function(e){return null===e.parent}));if(!t)throw Error("TreeView data must contain parent node.");return t},U=function(e,t){var n=e.find((function(e){return e.id===t}));if(null==n)throw Error("Node with id=".concat(t," doesn't exist in the tree."));return n},T=function(e){var t=Array.from(new Set(e));return e.length!==t.length},F="COLLAPSE",R="COLLAPSE_MANY",B="EXPAND",z="EXPAND_MANY",K="HALF_SELECT",_="SELECT",H="DESELECT",P="TOGGLE",M="TOGGLE_SELECT",V="SELECT_MANY",G="EXCLUSIVE_CHANGE_SELECT_MANY",q="FOCUS",X="BLUR",Y="DISABLE",$="ENABLE",J=function(e,t){switch(t.type){case F:var n=new Set(e.expandedIds);return n.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:n,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R:var a,r=new Set(e.expandedIds),l=f(t.ids);try{for(l.s();!(a=l.n()).done;){var i=a.value;r.delete(i)}}catch(e){l.e(e)}finally{l.f()}return Object.assign(Object.assign({},e),{expandedIds:r,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:var d=new Set(e.expandedIds);return d.add(t.id),Object.assign(Object.assign({},e),{expandedIds:d,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:var s=new Set([].concat(c(e.expandedIds),c(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:s,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case P:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case K:if(e.disabledIds.has(t.id))return e;var u=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return u.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:u,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case _:if(!t.controlled&&e.disabledIds.has(t.id))return e;var p;t.multiSelect?(p=new Set(e.selectedIds)).add(t.id):(p=new Set).add(t.id);var b=new Set(e.halfSelectedIds);return b.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case H:if(!t.controlled&&e.disabledIds.has(t.id))return e;var I,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(I=new Set(e.halfSelectedIds)).delete(t.id):I=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case M:if(e.disabledIds.has(t.id))return e;var y,m=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),m?y.delete(t.id):y.add(t.id)):(y=new Set,m||y.add(t.id));var g=new Set(e.halfSelectedIds);return g.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:g,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case V:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(c(e.selectedIds),c(E))):v(e.selectedIds,new Set(E));var O=v(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case G:var W,x=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){W=t.select?new Set(x):v(e.selectedIds,new Set(x));var A=v(e.halfSelectedIds,W);return Object.assign(Object.assign({},e),{selectedIds:W,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case q:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case X:return Object.assign(Object.assign({},e),{isFocused:!1});case Y:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case $:var D=new Set(e.disabledIds);return D.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:D});default:throw new Error("Invalid action passed to the reducer")}},Q={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},Z=function(e){var t=e.data,n=e.controlledIds,i=e.controlledExpandedIds,d=e.defaultExpandedIds,o=e.defaultSelectedIds,u=e.defaultDisabledIds,h=e.nodeRefs,p=e.leafRefs,w=e.onSelect,E=e.onExpand,O=e.onLoadData,W=e.togglableSelect,x=e.multiSelect,A=e.propagateSelect,j=e.propagateSelectUpwards,D=L(t),k=s(l(J,{selectedIds:new Set(n||o),tabbableId:D.children[0],isFocused:!1,expandedIds:new Set(i||d),halfSelectedIds:new Set,lastUserSelect:D.children[0],lastInteractedWith:null,disabledIds:new Set(u)}),2),N=k[0],T=k[1],M=N.selectedIds,G=N.expandedIds,X=N.disabledIds,Y=N.tabbableId,$=N.halfSelectedIds,Q=N.lastAction,Z=N.lastInteractedWith,ee=I(M)||new Set,te=b(M,ee);r((function(){var e;if(null!=w&&w!==ae){var n,a=f(te);try{for(a.s();!(n=a.n()).done;){var r=n.value,l=S(t,r)||!!(null===(e=U(t,Y))||void 0===e?void 0:e.isBranch);w({element:U(t,r),isBranch:l,isExpanded:!!l&&G.has(r),isSelected:M.has(r),isDisabled:X.has(r),isHalfSelected:!!l&&$.has(r),treeState:N})}}catch(e){a.e(e)}finally{a.f()}}}),[t,M,G,X,$,te,w,N]);var ne=I(G)||new Set;r((function(){var e=b(G,ne);if(null!=E&&E!==ae){var n,a=f(e);try{for(a.s();!(n=a.n()).done;){var r=n.value;E({element:U(t,r),isExpanded:G.has(r),isSelected:M.has(r),isDisabled:X.has(r),isHalfSelected:$.has(r),treeState:N})}}catch(e){a.e(e)}finally{a.f()}}}),[t,M,G,X,$,ne,E,N]);var re,le,ie=(re=t,le=a(),r((function(){le.current=re})),le.current||new Map);return r((function(){var e=b(G,ne);if(O){var n,a=f(e);try{for(a.s();!(n=a.n()).done;){var r=n.value;O({element:U(t,r),isExpanded:G.has(r),isSelected:M.has(r),isDisabled:X.has(r),isHalfSelected:$.has(r),treeState:N})}}catch(e){a.e(e)}finally{a.f()}if(ie!==t&&W&&A){var l,i=f(G);try{for(i.s();!(l=i.n()).done;){var d=l.value;M.has(d)&&T({type:V,ids:C(t,[d],X),select:!0,multiSelect:x,lastInteractedWith:d})}}catch(e){i.e(e)}finally{i.f()}}}}),[t,M,G,X,$,ne,O,N]),r((function(){var e=new Set(n),a=v(e,ee),r=v(ee,e);if(r.size){var l,i=f(r);try{for(i.s();!(l=i.n()).done;){var d=l.value;T({type:H,id:d,multiSelect:x,controlled:!0,lastInteractedWith:d})}}catch(e){i.e(e)}finally{i.f()}}if(a.size){var s,c=f(a);try{for(c.s();!(s=c.n()).done;){var o=s.value;T({type:_,id:o,multiSelect:x,controlled:!0,lastInteractedWith:o}),A&&!X.has(o)&&T({type:V,ids:C(t,[o],X),select:!0,multiSelect:x,lastInteractedWith:o})}}catch(e){c.e(e)}finally{c.f()}}}),[n]),r((function(){var e=new Set(i),n=v(e,ne),a=v(ne,e);if(a.size){var r,l=f(a);try{for(l.s();!(r=l.n()).done;){var d=r.value;if(S(t,d)||U(t,d).isBranch){var s=[d].concat(c(g(t,d,new Set)));T({type:R,ids:s,lastInteractedWith:d})}}}catch(e){l.e(e)}finally{l.f()}}if(n.size){var o,u=f(n);try{for(u.s();!(o=u.n()).done;){var h=o.value;if(S(t,h)||U(t,h).isBranch){var p=y(t,h);T(p?{type:z,ids:[h,p],lastInteractedWith:h}:{type:B,id:h,lastInteractedWith:h})}}}catch(e){u.e(e)}finally{u.f()}}}),[i]),r((function(){if(j){var e=new Set(te);Z&&Q!==q&&Q!==F&&Q!==B&&Q!==P&&e.add(Z);var n,a=function(e,t,n,a,r,l){var i,d={every:new Set,some:new Set,none:new Set},s=f(t);try{for(s.s();!(i=s.n()).done;)for(var c=i.value;;){var o=y(e,c);if(0===o||null==o||null!=o&&a.has(o))break;var u=U(e,o).children.filter((function(e){return!a.has(e)}));if(0===u.length)break;if(u.some((function(e){return n.has(e)||d.some.has(e)||r.has(e)})))u.every((function(e){return n.has(e)}))?d.every.add(o):d.some.add(o);else{var h=m(e,c,a).find((function(e){return n.has(e)}));if(!l&&h){g(e,h,a).forEach((function(e){r.has(e)&&d.none.add(e)}));break}d.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return d}(t,e,M,X,$,x),r=a.every,l=a.some,i=a.none,d=f(r);try{for(d.s();!(n=d.n()).done;){var s=n.value;M.has(s)||T({type:_,id:s,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:Z})}}catch(e){d.e(e)}finally{d.f()}var c,o=f(l);try{for(o.s();!(c=o.n()).done;){var u=c.value;$.has(u)||T({type:K,id:u,lastInteractedWith:Z})}}catch(e){o.e(e)}finally{o.f()}var h,p=f(i);try{for(p.s();!(h=p.n()).done;){var v=h.value;(M.has(v)||$.has(v))&&T({type:H,id:v,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:Z})}}catch(e){p.e(e)}finally{p.f()}}}),[t,x,j,M,G,X,$,Q,ee,te,Z]),r((function(){if(null!=Z&&null!=Y&&null!=(null==h?void 0:h.current)&&null!=(null==p?void 0:p.current)){var e=h.current[Y];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(p.current[Z]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[Y,h,p,Z]),[N,T]},ee={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},te=Object.freeze(Object.values(ee)),ne=Object.freeze(Object.values({check:"check",select:"select"})),ae=function(){},re=n.forwardRef((function(t,r){var l=t.data,d=t.selectedIds,c=t.nodeRenderer,o=t.onSelect,u=void 0===o?ae:o,f=t.onExpand,p=void 0===f?ae:f,v=t.onLoadData,b=t.className,I=void 0===b?"":b,S=t.multiSelect,y=void 0!==S&&S,m=t.propagateSelect,g=void 0!==m&&m,w=t.propagateSelectUpwards,E=void 0!==w&&w,O=t.propagateCollapse,W=void 0!==O&&O,x=t.expandOnKeyboardSelect,A=void 0!==x&&x,j=t.togglableSelect,D=void 0!==j&&j,C=t.defaultExpandedIds,N=void 0===C?[]:C,F=t.defaultSelectedIds,R=void 0===F?[]:F,B=t.defaultDisabledIds,z=void 0===B?[]:B,K=t.clickAction,_=void 0===K?ee.select:K,H=t.nodeAction,P=void 0===H?"select":H,M=t.expandedIds,V=t.onBlur,G=h(t,["data","selectedIds","nodeRenderer","onSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]);!function(e){if(T(e.map((function(e){return e.id}))))throw Error("Multiple TreeView nodes have the same ID. IDs must be unique.");if(e.forEach((function(e){if(e.id===e.parent)throw Error("Node with id=".concat(e.id," has parent reference to itself."));if(T(e.children))throw Error("Node with id=".concat(e.id," contains duplicate ids in its children."))})),1!==e.filter((function(e){return null===e.parent})).length)throw Error("TreeView can have only one root node.")}(l);var q=a({}),Y=a({}),$=s(Z({data:l,controlledIds:d,controlledExpandedIds:M,defaultExpandedIds:N,defaultSelectedIds:R,defaultDisabledIds:z,nodeRefs:q,leafRefs:Y,onSelect:u,onExpand:p,onLoadData:v,togglableSelect:D,multiSelect:y,propagateSelect:g,propagateSelectUpwards:E}),2),J=$[0],te=$[1];g=g&&y;var ne=a(null);return null!=r&&(ne=r),n.createElement("ul",Object.assign({className:e(Q.root,I),role:"tree","aria-multiselectable":"select"===P?y:void 0,ref:ne,onBlur:function(e){k(e,ne.current,(function(){V&&V({treeState:J,dispatch:te}),te({type:X})}))},onKeyDown:se({data:l,tabbableId:J.tabbableId,expandedIds:J.expandedIds,selectedIds:J.selectedIds,disabledIds:J.disabledIds,halfSelectedIds:J.halfSelectedIds,clickAction:_,dispatch:te,propagateCollapse:W,propagateSelect:g,multiSelect:y,expandOnKeyboardSelect:A,togglableSelect:D})},G),L(l).children.map((function(e,t){return n.createElement(le,Object.assign({key:"".concat(e,"-").concat(i(e)),data:l,element:U(l,e),setsize:L(l).children.length,posinset:t+1,level:1},J,{state:J,dispatch:te,nodeRefs:q,leafRefs:Y,baseClassNames:Q,nodeRenderer:c,propagateCollapse:W,propagateSelect:g,propagateSelectUpwards:E,multiSelect:y,togglableSelect:D,clickAction:_,nodeAction:P}))})))})),le=function(t){var a=t.element,r=t.dispatch,l=t.data,i=t.selectedIds,s=t.tabbableId,o=t.isFocused,u=t.expandedIds,f=t.disabledIds,h=t.halfSelectedIds,v=t.lastUserSelect,b=t.nodeRefs,I=t.leafRefs,y=t.baseClassNames,m=t.nodeRenderer,w=t.nodeAction,E=t.setsize,O=t.posinset,W=t.level,A=t.propagateCollapse,k=t.propagateSelect,L=t.multiSelect,U=t.togglableSelect,T=t.clickAction,F=t.state,B=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(a.id)&&A){var t=[a.id].concat(c(g(l,a.id,new Set)));r({type:R,ids:t,lastInteractedWith:a.id})}else r({type:P,id:a.id,lastInteractedWith:a.id})},z=function(){return r({type:q,id:a.id,lastInteractedWith:a.id})},H=function(e){if(e.shiftKey){var t=x({data:l,expandedIds:u,from:v,to:a.id}).filter((function(e){return!f.has(e)}));t=k?C(l,t,f):t,r({type:G,select:!0,multiSelect:L,ids:t,lastInteractedWith:a.id})}else if(e.ctrlKey||T===ee.select){var n=N(l,a.id,i);r({type:U?n?K:M:_,id:a.id,multiSelect:L,lastInteractedWith:a.id}),k&&!f.has(a.id)&&r({type:V,ids:C(l,[a.id],f),select:!U||!i.has(a.id),multiSelect:L,lastInteractedWith:a.id})}else T===ee.exclusiveSelect?r({type:U?M:_,id:a.id,multiSelect:!1,lastInteractedWith:a.id}):T===ee.focus&&r({type:q,id:a.id,lastInteractedWith:a.id})},X=function(t){var n;return e(t,(d(n={},"".concat(t,"--expanded"),u.has(a.id)),d(n,"".concat(t,"--selected"),i.has(a.id)),d(n,"".concat(t,"--focused"),s===a.id&&o),n))},Y="select"===w?{"aria-selected":j({isSelected:i.has(a.id),isDisabled:f.has(a.id),multiSelect:L})}:{"aria-checked":D({isSelected:i.has(a.id),isDisabled:f.has(a.id),isHalfSelected:h.has(a.id),multiSelect:L})};return S(l,a.id)||a.isBranch?n.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(a.id),"aria-setsize":E,"aria-posinset":O,"aria-level":W,"aria-disabled":f.has(a.id),tabIndex:s===a.id?0:-1,ref:function(e){null!=(null==b?void 0:b.current)&&null!=e&&(b.current[a.id]=e)},className:y.branchWrapper},Y),n.createElement(n.Fragment,null,m({element:a,isBranch:!0,isSelected:i.has(a.id),isHalfSelected:h.has(a.id),isExpanded:u.has(a.id),isDisabled:f.has(a.id),dispatch:r,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick;return{onClick:null==n?p(H,B,z):p(n,z),className:e(X(y.node),y.branch),ref:function(e){null!=(null==I?void 0:I.current)&&(I.current[a.id]=e)}}},setsize:E,posinset:O,level:W,handleSelect:H,handleExpand:B,treeState:F}),n.createElement(de,Object.assign({getClasses:X},ie(t))))):n.createElement("li",{role:"none",className:X(y.leafListItem)},m({element:a,isBranch:!1,isSelected:i.has(a.id),isHalfSelected:!1,isExpanded:!1,isDisabled:f.has(a.id),dispatch:r,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=t.onClick;return Object.assign({role:"treeitem",tabIndex:s===a.id?0:-1,onClick:p(null==n?H:n,z),ref:function(e){null!=(null==b?void 0:b.current)&&null!=(null==I?void 0:I.current)&&(b.current[a.id]=e,I.current[a.id]=e)},className:e(X(y.node),y.leaf),"aria-setsize":E,"aria-posinset":O,"aria-level":W,disabled:f.has(a.id),"aria-disabled":f.has(a.id)},Y)},setsize:E,posinset:O,level:W,handleSelect:H,handleExpand:ae,treeState:F}))},ie=function(e){e.setsize,e.posinset;return h(e,["setsize","posinset"])},de=function(e){var t=e.data,a=e.element,r=e.expandedIds,l=e.getClasses,d=e.baseClassNames,s=e.level,c=h(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return n.createElement("ul",{role:"group",className:l(d.nodeGroup)},r.has(a.id)&&a.children.length>0&&a.children.map((function(e,l){return n.createElement(le,Object.assign({data:t,expandedIds:r,baseClassNames:d,key:"".concat(e,"-").concat(i(e)),element:U(t,e),setsize:a.children.length,posinset:l+1,level:s+1},c))})))},se=function(e){var t=e.data,n=e.expandedIds,a=e.selectedIds,r=e.disabledIds,l=e.tabbableId,i=e.dispatch,d=e.propagateCollapse,s=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=U(t,l),v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var b=t.filter((function(e){return null!==e.parent})).map((function(e){return e.id})).filter((function(e){return!r.has(e)}));i({type:V,multiSelect:o,select:Array.from(a).filter((function(e){return!r.has(e)})).length!==b.length,ids:b,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var I="Home"===e.key?L(t).children[0]:E(t,v,n),m=x({data:t,expandedIds:n,from:v,to:I}).filter((function(e){return!r.has(e)}));i({type:V,multiSelect:o,select:!0,ids:s?C(t,m,r):m}),i({type:q,id:I,lastInteractedWith:I})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var w=O(t,v,n);return void(null==w||r.has(w)||(i({type:V,ids:s?C(t,[w],r):[w],select:!0,multiSelect:o,lastInteractedWith:w}),i({type:q,id:w,lastInteractedWith:w})));case"ArrowDown":e.preventDefault();var A=W(t,v,n);return void(null==A||r.has(A)||(i({type:V,ids:s?C(t,[A],r):[A],multiSelect:o,select:!0,lastInteractedWith:A}),i({type:q,id:A,lastInteractedWith:A})))}switch(e.key){case"ArrowDown":e.preventDefault();var j=W(t,v,n);return void(null!=j&&i({type:q,id:j,lastInteractedWith:j}));case"ArrowUp":e.preventDefault();var D=O(t,v,n);return void(null!=D&&i({type:q,id:D,lastInteractedWith:D}));case"ArrowLeft":if(e.preventDefault(),(S(t,v)||p.isBranch)&&n.has(l))if(d){var k=[v].concat(c(g(t,v,new Set)));i({type:R,ids:k,lastInteractedWith:p.id})}else i({type:F,id:v,lastInteractedWith:v});else if(!L(t).children.includes(v)){var T=y(t,v);if(null==T)throw new Error("parentId of root element is null");i({type:q,id:T,lastInteractedWith:T})}return;case"ArrowRight":return e.preventDefault(),void((S(t,v)||p.isBranch)&&(n.has(l)?i({type:q,id:p.children[0],lastInteractedWith:p.children[0]}):i({type:B,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),i({type:q,id:L(t).children[0],lastInteractedWith:L(t).children[0]});break;case"End":e.preventDefault();var H=E(t,L(t).id,n);return void i({type:q,id:H,lastInteractedWith:H});case"*":e.preventDefault();var G=y(t,v);if(null==G)throw new Error("parentId of element is null");var X=U(t,G).children.filter((function(e){return S(t,e)||U(t,e).isBranch}));return void i({type:z,ids:X,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===ee.focus)return;var Y=N(t,p.id,a);return i({type:f?Y?K:M:_,id:v,multiSelect:o,lastInteractedWith:v}),s&&!r.has(p.id)&&i({type:V,ids:C(t,[v],r),select:!f||!a.has(v),multiSelect:o,lastInteractedWith:v}),void(u&&i({type:P,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var $=W(t,v,n);$!==v;)if(null!=$){if(U(t,$).name[0].toLowerCase()===e.key.toLowerCase())return void i({type:q,id:$,lastInteractedWith:v});$=W(t,$,n)}else $=L(t).children[0];return}}}};re.propTypes={data:t.array.isRequired,onSelect:t.func,onExpand:t.func,className:t.string,nodeRenderer:t.func.isRequired,defaultExpandedIds:t.array,defaultSelectedIds:t.array,expandedIds:t.array,selectedIds:t.array,defaultDisabledIds:t.array,propagateCollapse:t.bool,propagateSelect:t.bool,propagateSelectUpwards:t.bool,multiSelect:t.bool,expandOnKeyboardSelect:t.bool,togglableSelect:t.bool,nodeAction:t.oneOf(ne),clickAction:t.oneOf(te),onBlur:t.func,onLoadData:t.func};export default re;export{te as CLICK_ACTIONS,A as flattenTree};
import React from "react";
import { EventCallback } from "./utils";
export interface INode {
/** A non-negative integer that uniquely identifies the node */
id: number;
/** Used to match on key press */
name: string;
/** An array with the ids of the children nodes */
children: number[];
/** The parent of the node; null for the root node */
parent: number | null;
/** Used to indicated whether a node is branch to be able load async data onExpand*/
isBranch?: boolean;
}
export type INodeRef = HTMLLIElement | HTMLDivElement;
export type INodeRefs = null | React.RefObject<{
[key: number]: INodeRef;
}>;
export type TreeViewAction = {
type: "COLLAPSE";
id: number;
lastInteractedWith?: number | null;
} | {
type: "COLLAPSE_MANY";
ids: number[];
lastInteractedWith?: number | null;
} | {
type: "EXPAND";
id: number;
lastInteractedWith?: number | null;
} | {
type: "EXPAND_MANY";
ids: number[];
lastInteractedWith?: number | null;
} | {
type: "HALF_SELECT";
id: number;
lastInteractedWith?: number | null;
} | {
type: "SELECT";
id: number;
multiSelect?: boolean;
controlled?: boolean;
keepFocus?: boolean;
NotUserAction?: boolean;
lastInteractedWith?: number | null;
} | {
type: "DESELECT";
id: number;
multiSelect?: boolean;
controlled?: boolean;
keepFocus?: boolean;
NotUserAction?: boolean;
lastInteractedWith?: number | null;
} | {
type: "TOGGLE";
id: number;
lastInteractedWith?: number | null;
} | {
type: "TOGGLE_SELECT";
id: number;
multiSelect?: boolean;
NotUserAction?: boolean;
lastInteractedWith?: number | null;
} | {
type: "SELECT_MANY";
ids: number[];
select?: boolean;
multiSelect?: boolean;
lastInteractedWith?: number | null;
} | {
type: "EXCLUSIVE_SELECT_MANY";
} | {
type: "EXCLUSIVE_CHANGE_SELECT_MANY";
ids: number[];
select?: boolean;
multiSelect?: boolean;
lastInteractedWith?: number | null;
} | {
type: "FOCUS";
id: number;
lastInteractedWith?: number | null;
} | {
type: "BLUR";
} | {
type: "DISABLE";
id: number;
} | {
type: "ENABLE";
id: number;
};
export interface ITreeViewState {
/** Set of the ids of the expanded nodes */
expandedIds: Set<number>;
/** Set of the ids of the selected nodes */
disabledIds: Set<number>;
/** Set of the ids of the selected nodes */
halfSelectedIds: Set<number>;
/** Set of the ids of the selected nodes */
selectedIds: Set<number>;
/** Id of the node with tabindex = 0 */
tabbableId: number;
/** Whether the tree has focus */
isFocused: boolean;
/** Last selection made directly by the user */
lastUserSelect: number;
/** Last node interacted with */
lastInteractedWith?: number | null;
lastAction?: TreeViewAction["type"];
}
import { ITreeViewState, TreeViewAction } from "./reducer";
import { EventCallback, INode, INodeRef, NodeId, TreeViewData } from "./types";
declare const clickActions: {

@@ -206,3 +99,3 @@ readonly select: "SELECT";

/** Tree data*/
data: INode[];
data: TreeViewData;
/** Function called when a node changes its selected state */

@@ -221,11 +114,11 @@ onSelect?: (props: ITreeViewOnSelectProps) => void;

/** Array with the ids of the default expanded nodes */
defaultExpandedIds?: number[];
defaultExpandedIds?: NodeId[];
/** Array with the ids of the default selected nodes */
defaultSelectedIds?: number[];
defaultSelectedIds?: NodeId[];
/** Array with the ids of controlled expanded nodes */
expandedIds?: number[];
expandedIds?: NodeId[];
/** Array with the ids of controlled selected nodes */
selectedIds?: number[];
selectedIds?: NodeId[];
/** Array with the ids of the default disabled nodes */
defaultDisabledIds?: number[];
defaultDisabledIds?: NodeId[];
/** If true, collapsing a node will also collapse its descendants */

@@ -232,0 +125,0 @@ propagateCollapse?: boolean;

@@ -1,35 +0,34 @@

/// <reference types="react" />
import { INode, INodeRef } from ".";
export type EventCallback = <T, E>(event: React.MouseEvent<T, E> | React.KeyboardEvent<T>) => void;
import { EventCallback, INode, INodeRef, NodeId, TreeViewData } from "./types";
export declare const composeHandlers: (...handlers: EventCallback[]) => EventCallback;
export declare const difference: (a: Set<number>, b: Set<number>) => Set<number>;
export declare const symmetricDifference: (a: Set<number>, b: Set<number>) => Set<number>;
export declare const usePrevious: (x: Set<number>) => Set<number> | undefined;
export declare const usePreviousData: (value: INode[] | undefined) => INode[] | undefined;
export declare const isBranchNode: (data: INode[], i: number) => boolean;
export declare const difference: (a: Set<NodeId>, b: Set<NodeId>) => Set<NodeId>;
export declare const symmetricDifference: (a: Set<NodeId>, b: Set<NodeId>) => Set<NodeId>;
export declare const usePrevious: (x: Set<NodeId>) => Set<NodeId> | undefined;
export declare const usePreviousData: (value: TreeViewData) => TreeViewData | undefined;
export declare const isBranchNode: (data: TreeViewData, i: NodeId) => boolean;
export declare const scrollToRef: (ref: INodeRef) => void;
export declare const focusRef: (ref: INodeRef) => void;
export declare const getParent: (data: INode[], id: number) => number | null;
export declare const getAncestors: (data: INode[], childId: number, disabledIds: Set<number>) => number[];
export declare const getDescendants: (data: INode[], id: number, disabledIds: Set<number>) => number[];
export declare const getSibling: (data: INode[], id: number, diff: number) => number | null;
export declare const getLastAccessible: (data: INode[], id: number, expandedIds: Set<number>) => number;
export declare const getPreviousAccessible: (data: INode[], id: number, expandedIds: Set<number>) => number | null;
export declare const getNextAccessible: (data: INode[], id: number, expandedIds: Set<number>) => number | null;
export declare const propagateSelectChange: (data: INode[], ids: Set<number>, selectedIds: Set<number>, disabledIds: Set<number>, halfSelectedIds: Set<number>, multiSelect?: boolean) => {
every: Set<number>;
some: Set<number>;
none: Set<number>;
export declare const getParent: (data: TreeViewData, id: NodeId) => NodeId | null;
export declare const getAncestors: (data: TreeViewData, childId: NodeId, disabledIds: Set<NodeId>) => NodeId[];
export declare const getDescendants: (data: TreeViewData, id: NodeId, disabledIds: Set<NodeId>) => NodeId[];
export declare const getSibling: (data: TreeViewData, id: NodeId, diff: number) => NodeId | null;
export declare const getLastAccessible: (data: TreeViewData, id: NodeId, expandedIds: Set<NodeId>) => NodeId;
export declare const getPreviousAccessible: (data: TreeViewData, id: NodeId, expandedIds: Set<NodeId>) => NodeId | null;
export declare const getNextAccessible: (data: TreeViewData, id: NodeId, expandedIds: Set<NodeId>) => NodeId | null;
export declare const propagateSelectChange: (data: TreeViewData, ids: Set<NodeId>, selectedIds: Set<NodeId>, disabledIds: Set<NodeId>, halfSelectedIds: Set<NodeId>, multiSelect?: boolean) => {
every: Set<NodeId>;
some: Set<NodeId>;
none: Set<NodeId>;
};
export declare const getAccessibleRange: ({ data, expandedIds, from, to, }: {
data: INode[];
expandedIds: Set<number>;
from: number;
to: number;
}) => number[];
data: TreeViewData;
expandedIds: Set<NodeId>;
from: NodeId;
to: NodeId;
}) => NodeId[];
interface ITreeNode {
id?: NodeId;
name: string;
children?: ITreeNode[];
}
export declare const flattenTree: (tree: ITreeNode) => INode[];
export declare const flattenTree: (tree: ITreeNode) => TreeViewData;
export declare const getAriaSelected: ({ isSelected, isDisabled, multiSelect, }: {

@@ -46,5 +45,8 @@ isSelected: boolean;

}) => boolean | undefined | "mixed";
export declare const propagatedIds: (data: INode[], ids: number[], disabledIds: Set<number>) => number[];
export declare const propagatedIds: (data: TreeViewData, ids: NodeId[], disabledIds: Set<NodeId>) => NodeId[];
export declare const onComponentBlur: (event: React.FocusEvent, treeNode: HTMLUListElement | null, callback: () => void) => void;
export declare const isBranchSelectedAndHasSelectedDescendants: (data: INode[], elementId: number, selectedIds: Set<number>) => boolean;
export declare const isBranchSelectedAndHasSelectedDescendants: (data: TreeViewData, elementId: NodeId, selectedIds: Set<NodeId>) => boolean;
export declare const getTreeParent: (data: TreeViewData) => INode;
export declare const getTreeNode: (data: TreeViewData, id: NodeId) => INode;
export declare const validateTreeViewData: (data: TreeViewData) => void;
export {};
{
"name": "react-accessible-treeview",
"description": "A react component that implements the treeview pattern as described by the WAI-ARIA Authoring Practices.",
"version": "2.3.5",
"version": "2.4.0",
"author": "lissitz (https://github.com/lissitz)",

@@ -6,0 +6,0 @@ "main": "dist/react-accessible-treeview.cjs.js",

@@ -46,11 +46,11 @@ # react-accessible-treeview [![Build Status](https://travis-ci.org/lissitz/react-accessible-treeview.svg?branch=master)](https://travis-ci.org/lissitz/react-accessible-treeview) [![Greenkeeper badge](https://badges.greenkeeper.io/lissitz/react-accessible-treeview.svg)](https://greenkeeper.io/) [![npm version](https://badge.fury.io/js/react-accessible-treeview.svg)](https://badge.fury.io/js/react-accessible-treeview) [![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

| Property | Type | Default | Description |
| ---------- | ----------- | -------- | ------------------------------------------------------------------------------------------------ |
| `id` | `number` | required | A nonnegative integer that uniquely identifies the node |
| `name` | `string` | required | Used to match on key press |
| `children` | `array[id]` | required | An array with the ids of the children nodes. |
| `parent` | `id` | required | The parent of the node. `null` for the root node |
| `isBranch` | `boolean` | optional | Used to indicated whether a node is branch to be able load async data onExpand, default is false |
| Property | Type | Default | Description |
| ---------- | -------------------- | -------- | ------------------------------------------------------------------------------------------------ |
| `id` | `number` or `string` | required | A nonnegative integer or string that uniquely identifies the node |
| `name` | `string` | required | Used to match on key press |
| `children` | `array[id]` | required | An array with the ids of the children nodes. |
| `parent` | `id` | required | The parent of the node. `null` for the root node |
| `isBranch` | `boolean` | optional | Used to indicated whether a node is branch to be able load async data onExpand, default is false |
The first item of the array represents the root node and won't be displayed.
The item with `parent:null` of the array represents the root node and won't be displayed.

@@ -76,4 +76,6 @@ Example:

The array can also be generated from a nested object using the `flattenTree` helper (see the examples below).
The array can also be generated from a nested object using the `flattenTree` helper (see the examples below).
Data supports non-sequential ids provided by user.
<br/> <br/>

@@ -80,0 +82,0 @@

@@ -6,3 +6,2 @@ import TreeView, {

LeafProps,
INode,
INodeRendererProps,

@@ -12,7 +11,7 @@ ITreeViewOnExpandProps,

ITreeViewProps,
ITreeViewState,
TreeViewAction,
ITreeViewOnLoadDataProps,
} from "./TreeView";
import { EventCallback, flattenTree } from "./TreeView/utils";
import { ITreeViewState, TreeViewAction } from "./TreeView/reducer";
import { INode, TreeViewData, EventCallback } from "./TreeView/types";
import { flattenTree } from "./TreeView/utils";

@@ -23,2 +22,3 @@ export {

INode,
TreeViewData,
ITreeViewOnSelectProps,

@@ -25,0 +25,0 @@ CLICK_ACTIONS,

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc