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.4.0 to 2.5.0

dist/__tests__/TreeViewOnNodeSelect.test.d.ts

7

dist/index.d.ts

@@ -1,6 +0,7 @@

import TreeView, { ClickActions, CLICK_ACTIONS, IBranchProps, LeafProps, INodeRendererProps, ITreeViewOnExpandProps, ITreeViewOnSelectProps, ITreeViewProps, ITreeViewOnLoadDataProps } from "./TreeView";
import TreeView, { ITreeViewOnExpandProps, ITreeViewOnSelectProps, ITreeViewOnNodeSelectProps, ITreeViewProps, ITreeViewOnLoadDataProps } from "./TreeView";
import { CLICK_ACTIONS } from "./TreeView/constants";
import { ITreeViewState, TreeViewAction } from "./TreeView/reducer";
import { INode, TreeViewData, EventCallback } from "./TreeView/types";
import { INode, TreeViewData, EventCallback, ClickActions, INodeRendererProps, IBranchProps, LeafProps } 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 { flattenTree, ITreeViewProps, INode, TreeViewData, ITreeViewOnSelectProps, ITreeViewOnNodeSelectProps, 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")),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};
"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"),l=e(n);function r(e){return(r="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,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,l,r=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(r.push(n.value),!t||r.length!==t);d=!0);}catch(e){i=!0,l=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw l}}return r}(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,l=function(){};return{s:l,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:l}}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 r,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,r=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw r}}}}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 l=0;for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)t.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(e,n[l])&&(a[n[l]]=e[n[l]])}return a}var h=function(){},p=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 l=a.value;if(l&&l(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},v=function(e,t){var a,n=new Set,l=u(e);try{for(l.s();!(a=l.n()).done;){var r=a.value;t.has(r)||n.add(r)}}catch(e){l.e(e)}finally{l.f()}return n},y=function(e,t){return new Set([].concat(s(v(e,t)),s(v(t,e))))},b=function(e){var t=n.useRef();return n.useEffect((function(){t.current=e}),[e]),t.current},S=function(e,t){var a;return!!(null===(a=k(e,t).children)||void 0===a?void 0:a.length)},I=function(e,t){return k(e,t).parent},g=function(e,t,a){for(var n=t,l=[];;){var r=I(e,n);if(0===r||null==r||null!=r&&a.has(r))break;l.push(r),n=r}return l},m=function(e,t,a){var n=[];return function e(t,l){var r=k(t,l);if(null!=r.children){var d,i=u(r.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},w=function(e,t,a){var n=I(e,t);if(null!=n){var l=k(e,n),r=l.children.indexOf(t)+a;if(l.children[r])return l.children[r]}return null},E=function(e,t,a){var n=k(e,t);for(N(e).id===t&&(n=k(e,k(e,t).children[k(e,t).children.length-1]));a.has(n.id)&&S(e,n.id);)n=k(e,n.children[n.children.length-1]);return n.id},O=function(e,t,a){if(t===N(e).children[0])return null;var n=w(e,t,-1);return null==n?I(e,t):E(e,n,a)},x=function(e,t,a){var n=k(e,t).id;if(S(e,n)&&a.has(n))return k(e,n).children[0];for(;;){var l=w(e,n,1);if(null!=l)return l;if(null==(n=I(e,n)))return null}},A=function(e){var t=e.data,a=e.expandedIds,n=e.from,l=e.to,r=[],d=t.length,i=0,s=n;if(r.push(n),n<l)for(;i<d&&(null!=(s=x(t,s,a))&&r.push(s),null!=s&&s!==l);)i+=1;else if(n>l)for(;i<d&&(null!=(s=O(t,s,a))&&r.push(s),null!=s&&s!==l);)i+=1;return r},W=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,l=e.multiSelect;return a?t:n?"mixed":l?t:!!t||void 0},T=function(e,t,a){return t.concat.apply(t,s(t.filter((function(t){return S(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>")},C=function(e,t,a){return S(e,t)&&a.has(t)&&m(e,t,new Set).some((function(e){return a.has(e)}))},N=function(e){var t=e.find((function(e){return null===e.parent}));if(!t)throw Error("TreeView data must contain parent node.");return t},k=function(e,t){var a=e.find((function(e){return e.id===t}));if(null==a)throw Error("Node with id=".concat(t," doesn't exist in the tree."));return a},L=function(e){var t=Array.from(new Set(e));return e.length!==t.length},M="COLLAPSE",U="COLLAPSE_MANY",R="EXPAND",B="EXPAND_MANY",F="HALF_SELECT",_="SELECT",z="DESELECT",K="TOGGLE",H="TOGGLE_SELECT",P="SELECT_MANY",G="EXCLUSIVE_CHANGE_SELECT_MANY",V="FOCUS",q="BLUR",Y="DISABLE",X="ENABLE",$="CLEAR_MANUALLY_TOGGLED",J=function(e,t){switch(t.type){case M: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,l=new Set(e.expandedIds),r=u(t.ids);try{for(r.s();!(n=r.n()).done;){var d=n.value;l.delete(d)}}catch(e){r.e(e)}finally{r.f()}return Object.assign(Object.assign({},e),{expandedIds:l,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R: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 B: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 F: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 p;t.multiSelect?(p=new Set(e.selectedIds)).add(t.id):(p=new Set).add(t.id);var y=new Set(e.halfSelectedIds);return y.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:y,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});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,lastManuallyToggled:t.lastManuallyToggled});case H:if(e.disabledIds.has(t.id))return e;var I,g=e.selectedIds.has(t.id);t.multiSelect?(I=new Set(e.selectedIds),g?I.delete(t.id):I.add(t.id)):(I=new Set,g||I.add(t.id));var m=new Set(e.halfSelectedIds);return m.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:I,halfSelectedIds:m,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});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))):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,lastManuallyToggled:t.lastManuallyToggled})}return e;case G:var x,A=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){x=t.select?new Set(A):v(e.selectedIds,new Set(A));var W=v(e.halfSelectedIds,x);return Object.assign(Object.assign({},e),{selectedIds:x,halfSelectedIds:W,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}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 Y:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case X:var T=new Set(e.disabledIds);return T.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:T});case $:return Object.assign(Object.assign({},e),{lastManuallyToggled:null});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={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},ee=Object.freeze(Object.values(Z)),te=Object.freeze(Object.values({check:"check",select:"select"})),ae=function(e){var a=e.element,n=e.dispatch,r=e.data,i=e.selectedIds,c=e.tabbableId,o=e.isFocused,u=e.expandedIds,v=e.disabledIds,y=e.halfSelectedIds,b=e.lastUserSelect,I=e.nodeRefs,g=e.leafRefs,w=e.baseClassNames,E=e.nodeRenderer,O=e.nodeAction,x=e.setsize,D=e.posinset,N=e.level,k=e.propagateCollapse,L=e.propagateSelect,M=e.multiSelect,R=e.togglableSelect,B=e.clickAction,z=e.state,q=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(a.id)&&k){var t=[a.id].concat(s(m(r,a.id,new Set)));n({type:U,ids:t,lastInteractedWith:a.id})}else n({type:K,id:a.id,lastInteractedWith:a.id})},Y=function(){return n({type:V,id:a.id,lastInteractedWith:a.id})},X=function(e){if(e.shiftKey){var t=A({data:r,expandedIds:u,from:b,to:a.id}).filter((function(e){return!v.has(e)}));t=L?T(r,t,v):t,n({type:G,select:!0,multiSelect:M,ids:t,lastInteractedWith:a.id,lastManuallyToggled:a.id})}else if(e.ctrlKey||B===Z.select){var l=C(r,a.id,i);n({type:R?l?F:H:_,id:a.id,multiSelect:M,lastInteractedWith:a.id,lastManuallyToggled:a.id}),L&&!v.has(a.id)&&n({type:P,ids:T(r,[a.id],v),select:!R||!i.has(a.id),multiSelect:M,lastInteractedWith:a.id,lastManuallyToggled:a.id})}else B===Z.exclusiveSelect?n({type:R?H:_,id:a.id,multiSelect:!1,lastInteractedWith:a.id,lastManuallyToggled:a.id}):B===Z.focus&&n({type:V,id:a.id,lastInteractedWith:a.id})},$=function(e){var n;return t(e,(d(n={},"".concat(e,"--expanded"),u.has(a.id)),d(n,"".concat(e,"--selected"),i.has(a.id)),d(n,"".concat(e,"--focused"),c===a.id&&o),n))},J="select"===O?{"aria-selected":W({isSelected:i.has(a.id),isDisabled:v.has(a.id),multiSelect:M})}:{"aria-checked":j({isSelected:i.has(a.id),isDisabled:v.has(a.id),isHalfSelected:y.has(a.id),multiSelect:M})};return S(r,a.id)||a.isBranch?l.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(a.id),"aria-setsize":x,"aria-posinset":D,"aria-level":N,"aria-disabled":v.has(a.id),tabIndex:c===a.id?0:-1,ref:function(e){null!=(null==I?void 0:I.current)&&null!=e&&(I.current[a.id]=e)},className:w.branchWrapper},J),l.createElement(l.Fragment,null,E({element:a,isBranch:!0,isSelected:i.has(a.id),isHalfSelected:y.has(a.id),isExpanded:u.has(a.id),isDisabled:v.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?p(X,q,Y):p(n,Y),className:t($(w.node),w.branch),ref:function(e){null!=(null==g?void 0:g.current)&&(g.current[a.id]=e)}}},setsize:x,posinset:D,level:N,handleSelect:X,handleExpand:q,treeState:z}),l.createElement(ne,Object.assign({getClasses:$},function(e){e.setsize,e.posinset;return f(e,["setsize","posinset"])}(e))))):l.createElement("li",{role:"none",className:$(w.leafListItem)},E({element:a,isBranch:!1,isSelected:i.has(a.id),isHalfSelected:!1,isExpanded:!1,isDisabled:v.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:p(null==n?X:n,Y),ref:function(e){null!=(null==I?void 0:I.current)&&null!=(null==g?void 0:g.current)&&(I.current[a.id]=e,g.current[a.id]=e)},className:t($(w.node),w.leaf),"aria-setsize":x,"aria-posinset":D,"aria-level":N,disabled:v.has(a.id),"aria-disabled":v.has(a.id)},J)},setsize:x,posinset:D,level:N,handleSelect:X,handleExpand:h,treeState:z}))},ne=function(e){var t=e.data,a=e.element,n=e.expandedIds,d=e.getClasses,i=e.baseClassNames,s=e.level,c=f(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return l.createElement("ul",{role:"group",className:d(i.nodeGroup)},n.has(a.id)&&a.children.length>0&&a.children.map((function(e,d){return l.createElement(ae,Object.assign({data:t,expandedIds:n,baseClassNames:i,key:"".concat(e,"-").concat(r(e)),element:k(t,e),setsize:a.children.length,posinset:d+1,level:s+1},c))})))},le=function(e){var t=e.data,a=e.controlledIds,l=e.controlledExpandedIds,r=e.defaultExpandedIds,d=e.defaultSelectedIds,c=e.defaultDisabledIds,o=e.nodeRefs,f=e.leafRefs,p=e.onSelect,w=e.onNodeSelect,E=e.onExpand,O=e.onLoadData,x=e.togglableSelect,A=e.multiSelect,W=e.propagateSelect,j=e.propagateSelectUpwards,D=N(t),C=i(n.useReducer(J,{selectedIds:new Set(a||d),tabbableId:D.children[0],isFocused:!1,expandedIds:new Set(l||r),halfSelectedIds:new Set,lastUserSelect:D.children[0],lastInteractedWith:null,lastManuallyToggled:null,disabledIds:new Set(c)}),2),L=C[0],H=C[1],G=L.selectedIds,q=L.expandedIds,Y=L.disabledIds,X=L.tabbableId,Q=L.halfSelectedIds,Z=L.lastAction,ee=L.lastInteractedWith,te=L.lastManuallyToggled,ae=b(G)||new Set,ne=y(G,ae);n.useEffect((function(){var e;if(null!=p&&p!==h){var a,n=u(ne);try{for(n.s();!(a=n.n()).done;){var l=a.value,r=S(t,l)||!!(null===(e=k(t,X))||void 0===e?void 0:e.isBranch);p({element:k(t,l),isBranch:r,isExpanded:!!r&&q.has(l),isSelected:G.has(l),isDisabled:Y.has(l),isHalfSelected:!!r&&Q.has(l),treeState:L})}}catch(e){n.e(e)}finally{n.f()}}}),[t,G,q,Y,Q,ne,p,L]),n.useEffect((function(){null!=w&&w!==h&&null!=te&&ne.size&&(w({element:k(t,te),isSelected:G.has(te),isBranch:S(t,te),treeState:L}),H({type:$}))}),[te,G,ne]);var le=b(q)||new Set;n.useEffect((function(){var e=y(q,le);if(null!=E&&E!==h){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var l=a.value;E({element:k(t,l),isExpanded:q.has(l),isSelected:G.has(l),isDisabled:Y.has(l),isHalfSelected:Q.has(l),treeState:L})}}catch(e){n.e(e)}finally{n.f()}}}),[t,G,q,Y,Q,le,E,L]);var re,de,ie=(re=t,de=n.useRef(),n.useEffect((function(){de.current=re})),de.current||new Map);return n.useEffect((function(){var e=y(q,le);if(O){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var l=a.value;O({element:k(t,l),isExpanded:q.has(l),isSelected:G.has(l),isDisabled:Y.has(l),isHalfSelected:Q.has(l),treeState:L})}}catch(e){n.e(e)}finally{n.f()}if(ie!==t&&x&&W){var r,d=u(q);try{for(d.s();!(r=d.n()).done;){var i=r.value;G.has(i)&&H({type:P,ids:T(t,[i],Y),select:!0,multiSelect:A,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,G,q,Y,Q,le,O,L]),n.useEffect((function(){var e=new Set(a),n=v(e,ae),l=v(ae,e);if(l.size){var r,d=u(l);try{for(d.s();!(r=d.n()).done;){var i=r.value;H({type:z,id:i,multiSelect:A,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;H({type:_,id:o,multiSelect:A,controlled:!0,lastInteractedWith:o}),W&&!Y.has(o)&&H({type:P,ids:T(t,[o],Y),select:!0,multiSelect:A,lastInteractedWith:o})}}catch(e){c.e(e)}finally{c.f()}}}),[a]),n.useEffect((function(){var e=new Set(l),a=v(e,le),n=v(le,e);if(n.size){var r,d=u(n);try{for(d.s();!(r=d.n()).done;){var i=r.value;if(S(t,i)||k(t,i).isBranch){var c=[i].concat(s(m(t,i,new Set)));H({type:U,ids:c,lastInteractedWith:i})}}}catch(e){d.e(e)}finally{d.f()}}if(a.size){var o,f=u(a);try{for(f.s();!(o=f.n()).done;){var h=o.value;if(S(t,h)||k(t,h).isBranch){var p=I(t,h);H(p?{type:B,ids:[h,p],lastInteractedWith:h}:{type:R,id:h,lastInteractedWith:h})}}}catch(e){f.e(e)}finally{f.f()}}}),[l]),n.useEffect((function(){if(j){var e=new Set(ne);ee&&Z!==V&&Z!==M&&Z!==R&&Z!==K&&e.add(ee);var a,n=function(e,t,a,n,l,r){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=I(e,c);if(0===o||null==o||null!=o&&n.has(o))break;var f=k(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)||l.has(e)})))f.every((function(e){return a.has(e)}))?i.every.add(o):i.some.add(o);else{var h=g(e,c,n).find((function(e){return a.has(e)}));if(!r&&h){m(e,h,n).forEach((function(e){l.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,G,Y,Q,A),l=n.every,r=n.some,d=n.none,i=u(l);try{for(i.s();!(a=i.n()).done;){var s=a.value;G.has(s)||H({type:_,id:s,multiSelect:A,keepFocus:!0,NotUserAction:!0,lastInteractedWith:ee})}}catch(e){i.e(e)}finally{i.f()}var c,o=u(r);try{for(o.s();!(c=o.n()).done;){var f=c.value;Q.has(f)||H({type:F,id:f,lastInteractedWith:ee})}}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;(G.has(v)||Q.has(v))&&H({type:z,id:v,multiSelect:A,keepFocus:!0,NotUserAction:!0,lastInteractedWith:ee,lastManuallyToggled:te})}}catch(e){p.e(e)}finally{p.f()}}}),[t,A,j,G,q,Y,Q,Z,ae,ne,ee]),n.useEffect((function(){if(null!=ee&&null!=X&&null!=(null==o?void 0:o.current)&&null!=(null==f?void 0:f.current)){var e=o.current[X];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(f.current[ee]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[X,o,f,ee]),[L,H]},re=l.forwardRef((function(e,a){var d=e.data,s=e.selectedIds,c=e.nodeRenderer,o=e.onSelect,u=void 0===o?h:o,p=e.onNodeSelect,v=void 0===p?h:p,y=e.onExpand,b=void 0===y?h:y,S=e.onLoadData,I=e.className,g=void 0===I?"":I,m=e.multiSelect,w=void 0!==m&&m,E=e.propagateSelect,O=void 0!==E&&E,x=e.propagateSelectUpwards,A=void 0!==x&&x,W=e.propagateCollapse,j=void 0!==W&&W,T=e.expandOnKeyboardSelect,C=void 0!==T&&T,M=e.togglableSelect,U=void 0!==M&&M,R=e.defaultExpandedIds,B=void 0===R?[]:R,F=e.defaultSelectedIds,_=void 0===F?[]:F,z=e.defaultDisabledIds,K=void 0===z?[]:z,H=e.clickAction,P=void 0===H?Z.select:H,G=e.nodeAction,V=void 0===G?"select":G,Y=e.expandedIds,X=e.onBlur,$=f(e,["data","selectedIds","nodeRenderer","onSelect","onNodeSelect","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.")}(d);var J=n.useRef({}),ee=n.useRef({}),te=i(le({data:d,controlledIds:s,controlledExpandedIds:Y,defaultExpandedIds:B,defaultSelectedIds:_,defaultDisabledIds:K,nodeRefs:J,leafRefs:ee,onSelect:u,onNodeSelect:v,onExpand:b,onLoadData:S,togglableSelect:U,multiSelect:w,propagateSelect:O,propagateSelectUpwards:A}),2),ne=te[0],re=te[1];O=O&&w;var ie=n.useRef(null);return null!=a&&(ie=a),l.createElement("ul",Object.assign({className:t(Q.root,g),role:"tree","aria-multiselectable":"select"===V?w:void 0,ref:ie,onBlur:function(e){D(e,ie.current,(function(){X&&X({treeState:ne,dispatch:re}),re({type:q})}))},onKeyDown:de({data:d,tabbableId:ne.tabbableId,expandedIds:ne.expandedIds,selectedIds:ne.selectedIds,disabledIds:ne.disabledIds,halfSelectedIds:ne.halfSelectedIds,clickAction:P,dispatch:re,propagateCollapse:j,propagateSelect:O,multiSelect:w,expandOnKeyboardSelect:C,togglableSelect:U})},$),N(d).children.map((function(e,t){return l.createElement(ae,Object.assign({key:"".concat(e,"-").concat(r(e)),data:d,element:k(d,e),setsize:N(d).children.length,posinset:t+1,level:1},ne,{state:ne,dispatch:re,nodeRefs:J,leafRefs:ee,baseClassNames:Q,nodeRenderer:c,propagateCollapse:j,propagateSelect:O,propagateSelectUpwards:A,multiSelect:w,togglableSelect:U,clickAction:P,nodeAction:V}))})))})),de=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,l=e.disabledIds,r=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=k(t,r),v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var y=t.filter((function(e){return null!==e.parent})).map((function(e){return e.id})).filter((function(e){return!l.has(e)}));d({type:P,multiSelect:o,select:Array.from(n).filter((function(e){return!l.has(e)})).length!==y.length,ids:y,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var b="Home"===e.key?N(t).children[0]:E(t,v,a),g=A({data:t,expandedIds:a,from:v,to:b}).filter((function(e){return!l.has(e)}));d({type:P,multiSelect:o,select:!0,ids:c?T(t,g,l):g}),d({type:V,id:b,lastInteractedWith:b})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var w=O(t,v,a);return void(null==w||l.has(w)||(d({type:P,ids:c?T(t,[w],l):[w],select:!0,multiSelect:o,lastInteractedWith:w,lastManuallyToggled:w}),d({type:V,id:w,lastInteractedWith:w})));case"ArrowDown":e.preventDefault();var W=x(t,v,a);return void(null==W||l.has(W)||(d({type:P,ids:c?T(t,[W],l):[W],multiSelect:o,select:!0,lastInteractedWith:W,lastManuallyToggled:W}),d({type:V,id:W,lastInteractedWith:W})))}switch(e.key){case"ArrowDown":e.preventDefault();var j=x(t,v,a);return void(null!=j&&d({type:V,id:j,lastInteractedWith:j}));case"ArrowUp":e.preventDefault();var D=O(t,v,a);return void(null!=D&&d({type:V,id:D,lastInteractedWith:D}));case"ArrowLeft":if(e.preventDefault(),(S(t,v)||p.isBranch)&&a.has(r))if(i){var L=[v].concat(s(m(t,v,new Set)));d({type:U,ids:L,lastInteractedWith:p.id})}else d({type:M,id:v,lastInteractedWith:v});else if(!N(t).children.includes(v)){var z=I(t,v);if(null==z)throw new Error("parentId of root element is null");d({type:V,id:z,lastInteractedWith:z})}return;case"ArrowRight":return e.preventDefault(),void((S(t,v)||p.isBranch)&&(a.has(r)?d({type:V,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:R,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),d({type:V,id:N(t).children[0],lastInteractedWith:N(t).children[0]});break;case"End":e.preventDefault();var G=E(t,N(t).id,a);return void d({type:V,id:G,lastInteractedWith:G});case"*":e.preventDefault();var q=I(t,v);if(null==q)throw new Error("parentId of element is null");var Y=k(t,q).children.filter((function(e){return S(t,e)||k(t,e).isBranch}));return void d({type:B,ids:Y,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===Z.focus)return;var X=C(t,p.id,n);return d({type:f?X?F:H:_,id:v,multiSelect:o,lastInteractedWith:v,lastManuallyToggled:v}),c&&!l.has(p.id)&&d({type:P,ids:T(t,[v],l),select:!f||!n.has(v),multiSelect:o,lastInteractedWith:v,lastManuallyToggled:v}),void(u&&d({type:K,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var $=x(t,v,a);$!==v;)if(null!=$){if(k(t,$).name[0].toLowerCase()===e.key.toLowerCase())return void d({type:V,id:$,lastInteractedWith:v});$=x(t,$,a)}else $=N(t).children[0];return}}}};re.propTypes={data:a.array.isRequired,onSelect:a.func,onNodeSelect: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(te),clickAction:a.oneOf(ee),onBlur:a.func,onLoadData:a.func},exports.CLICK_ACTIONS=ee,exports.default=re,exports.flattenTree=function(e){var t=0,a=[];return function e(n,l){var r,d={id:n.id||t,name:n.name,children:[],parent:l};if(a.find((function(e){return e.id===d.id})))throw Error("Multiple TreeView nodes have the same ID (".concat(d.id,"). IDs must be unique."));if(a.push(d),t+=1,null===(r=n.children)||void 0===r?void 0:r.length){var i,s=u(n.children);try{for(s.s();!(i=s.n()).done;){e(i.value,d.id)}}catch(e){s.e(e)}finally{s.f()}var c,o=u(a.values());try{for(o.s();!(c=o.n()).done;){var f=c.value;f.parent===d.id&&d.children.push(f.id)}}catch(e){o.e(e)}finally{o.f()}}}(e,null),a};

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

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 e from"classnames";import t from"prop-types";import a,{useRef as n,useEffect as l,useReducer as r}from"react";function d(e){return(d="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,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function s(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,l,r=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(r.push(n.value),!t||r.length!==t);d=!0);}catch(e){i=!0,l=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw l}}return r}(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 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)?u(e,t):void 0}}function u(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 f(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=o(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,l=function(){};return{s:l,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:l}}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 r,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,r=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw r}}}}function h(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 l=0;for(n=Object.getOwnPropertySymbols(e);l<n.length;l++)t.indexOf(n[l])<0&&Object.prototype.propertyIsEnumerable.call(e,n[l])&&(a[n[l]]=e[n[l]])}return a}var p=function(){},v=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=f(t);try{for(n.s();!(a=n.n()).done;){var l=a.value;if(l&&l(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},y=function(e,t){var a,n=new Set,l=f(e);try{for(l.s();!(a=l.n()).done;){var r=a.value;t.has(r)||n.add(r)}}catch(e){l.e(e)}finally{l.f()}return n},S=function(e,t){return new Set([].concat(c(y(e,t)),c(y(t,e))))},b=function(e){var t=n();return l((function(){t.current=e}),[e]),t.current},I=function(e,t){var a;return!!(null===(a=M(e,t).children)||void 0===a?void 0:a.length)},g=function(e,t){return M(e,t).parent},m=function(e,t,a){for(var n=t,l=[];;){var r=g(e,n);if(0===r||null==r||null!=r&&a.has(r))break;l.push(r),n=r}return l},w=function(e,t,a){var n=[];return function e(t,l){var r=M(t,l);if(null!=r.children){var d,i=f(r.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},E=function(e,t,a){var n=g(e,t);if(null!=n){var l=M(e,n),r=l.children.indexOf(t)+a;if(l.children[r])return l.children[r]}return null},O=function(e,t,a){var n=M(e,t);for(L(e).id===t&&(n=M(e,M(e,t).children[M(e,t).children.length-1]));a.has(n.id)&&I(e,n.id);)n=M(e,n.children[n.children.length-1]);return n.id},A=function(e,t,a){if(t===L(e).children[0])return null;var n=E(e,t,-1);return null==n?g(e,t):O(e,n,a)},W=function(e,t,a){var n=M(e,t).id;if(I(e,n)&&a.has(n))return M(e,n).children[0];for(;;){var l=E(e,n,1);if(null!=l)return l;if(null==(n=g(e,n)))return null}},x=function(e){var t=e.data,a=e.expandedIds,n=e.from,l=e.to,r=[],d=t.length,i=0,s=n;if(r.push(n),n<l)for(;i<d&&(null!=(s=W(t,s,a))&&r.push(s),null!=s&&s!==l);)i+=1;else if(n>l)for(;i<d&&(null!=(s=A(t,s,a))&&r.push(s),null!=s&&s!==l);)i+=1;return r},j=function(e){var t=0,a=[];return function e(n,l){var r,d={id:n.id||t,name:n.name,children:[],parent:l};if(a.find((function(e){return e.id===d.id})))throw Error("Multiple TreeView nodes have the same ID (".concat(d.id,"). IDs must be unique."));if(a.push(d),t+=1,null===(r=n.children)||void 0===r?void 0:r.length){var i,s=f(n.children);try{for(s.s();!(i=s.n()).done;){e(i.value,d.id)}}catch(e){s.e(e)}finally{s.f()}var c,o=f(a.values());try{for(o.s();!(c=o.n()).done;){var u=c.value;u.parent===d.id&&d.children.push(u.id)}}catch(e){o.e(e)}finally{o.f()}}}(e,null),a},T=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},D=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,l=e.multiSelect;return a?t:n?"mixed":l?t:!!t||void 0},C=function(e,t,a){return t.concat.apply(t,c(t.filter((function(t){return I(e,t)})).map((function(t){return w(e,t,a)}))))},N=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 I(e,t)&&a.has(t)&&w(e,t,new Set).some((function(e){return a.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},M=function(e,t){var a=e.find((function(e){return e.id===t}));if(null==a)throw Error("Node with id=".concat(t," doesn't exist in the tree."));return a},U=function(e){var t=Array.from(new Set(e));return e.length!==t.length},R="COLLAPSE",B="COLLAPSE_MANY",F="EXPAND",z="EXPAND_MANY",_="HALF_SELECT",K="SELECT",H="DESELECT",P="TOGGLE",G="TOGGLE_SELECT",V="SELECT_MANY",Y="EXCLUSIVE_CHANGE_SELECT_MANY",q="FOCUS",X="BLUR",$="DISABLE",J="ENABLE",Q="CLEAR_MANUALLY_TOGGLED",Z=function(e,t){switch(t.type){case R: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 B:var n,l=new Set(e.expandedIds),r=f(t.ids);try{for(r.s();!(n=r.n()).done;){var d=n.value;l.delete(d)}}catch(e){r.e(e)}finally{r.f()}return Object.assign(Object.assign({},e),{expandedIds:l,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 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 _: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 K: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 v=new Set(e.halfSelectedIds);return v.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:v,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case H:if(!t.controlled&&e.disabledIds.has(t.id))return e;var S,b=new Set(e.selectedIds);return b.delete(t.id),t.multiSelect?(S=new Set(e.halfSelectedIds)).delete(t.id):S=new Set,Object.assign(Object.assign({},e),{selectedIds:b,halfSelectedIds:S,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});case G:if(e.disabledIds.has(t.id))return e;var I,g=e.selectedIds.has(t.id);t.multiSelect?(I=new Set(e.selectedIds),g?I.delete(t.id):I.add(t.id)):(I=new Set,g||I.add(t.id));var m=new Set(e.halfSelectedIds);return m.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:I,halfSelectedIds:m,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled});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))):y(e.selectedIds,new Set(E));var O=y(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}return e;case Y:var A,W=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){A=t.select?new Set(W):y(e.selectedIds,new Set(W));var x=y(e.halfSelectedIds,A);return Object.assign(Object.assign({},e),{selectedIds:A,halfSelectedIds:x,lastAction:t.type,lastInteractedWith:t.lastInteractedWith,lastManuallyToggled:t.lastManuallyToggled})}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 $:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case J:var T=new Set(e.disabledIds);return T.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:T});case Q:return Object.assign(Object.assign({},e),{lastManuallyToggled:null});default:throw new Error("Invalid action passed to the reducer")}},ee={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"},te={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},ae=Object.freeze(Object.values(te)),ne=Object.freeze(Object.values({check:"check",select:"select"})),le=function(t){var n=t.element,l=t.dispatch,r=t.data,d=t.selectedIds,s=t.tabbableId,o=t.isFocused,u=t.expandedIds,f=t.disabledIds,y=t.halfSelectedIds,S=t.lastUserSelect,b=t.nodeRefs,g=t.leafRefs,m=t.baseClassNames,E=t.nodeRenderer,O=t.nodeAction,A=t.setsize,W=t.posinset,j=t.level,N=t.propagateCollapse,L=t.propagateSelect,M=t.multiSelect,U=t.togglableSelect,R=t.clickAction,F=t.state,z=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(n.id)&&N){var t=[n.id].concat(c(w(r,n.id,new Set)));l({type:B,ids:t,lastInteractedWith:n.id})}else l({type:P,id:n.id,lastInteractedWith:n.id})},H=function(){return l({type:q,id:n.id,lastInteractedWith:n.id})},X=function(e){if(e.shiftKey){var t=x({data:r,expandedIds:u,from:S,to:n.id}).filter((function(e){return!f.has(e)}));t=L?C(r,t,f):t,l({type:Y,select:!0,multiSelect:M,ids:t,lastInteractedWith:n.id,lastManuallyToggled:n.id})}else if(e.ctrlKey||R===te.select){var a=k(r,n.id,d);l({type:U?a?_:G:K,id:n.id,multiSelect:M,lastInteractedWith:n.id,lastManuallyToggled:n.id}),L&&!f.has(n.id)&&l({type:V,ids:C(r,[n.id],f),select:!U||!d.has(n.id),multiSelect:M,lastInteractedWith:n.id,lastManuallyToggled:n.id})}else R===te.exclusiveSelect?l({type:U?G:K,id:n.id,multiSelect:!1,lastInteractedWith:n.id,lastManuallyToggled:n.id}):R===te.focus&&l({type:q,id:n.id,lastInteractedWith:n.id})},$=function(t){var a;return e(t,(i(a={},"".concat(t,"--expanded"),u.has(n.id)),i(a,"".concat(t,"--selected"),d.has(n.id)),i(a,"".concat(t,"--focused"),s===n.id&&o),a))},J="select"===O?{"aria-selected":T({isSelected:d.has(n.id),isDisabled:f.has(n.id),multiSelect:M})}:{"aria-checked":D({isSelected:d.has(n.id),isDisabled:f.has(n.id),isHalfSelected:y.has(n.id),multiSelect:M})};return I(r,n.id)||n.isBranch?a.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(n.id),"aria-setsize":A,"aria-posinset":W,"aria-level":j,"aria-disabled":f.has(n.id),tabIndex:s===n.id?0:-1,ref:function(e){null!=(null==b?void 0:b.current)&&null!=e&&(b.current[n.id]=e)},className:m.branchWrapper},J),a.createElement(a.Fragment,null,E({element:n,isBranch:!0,isSelected:d.has(n.id),isHalfSelected:y.has(n.id),isExpanded:u.has(n.id),isDisabled:f.has(n.id),dispatch:l,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return{onClick:null==a?v(X,z,H):v(a,H),className:e($(m.node),m.branch),ref:function(e){null!=(null==g?void 0:g.current)&&(g.current[n.id]=e)}}},setsize:A,posinset:W,level:j,handleSelect:X,handleExpand:z,treeState:F}),a.createElement(re,Object.assign({getClasses:$},function(e){e.setsize,e.posinset;return h(e,["setsize","posinset"])}(t))))):a.createElement("li",{role:"none",className:$(m.leafListItem)},E({element:n,isBranch:!1,isSelected:d.has(n.id),isHalfSelected:!1,isExpanded:!1,isDisabled:f.has(n.id),dispatch:l,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return Object.assign({role:"treeitem",tabIndex:s===n.id?0:-1,onClick:v(null==a?X:a,H),ref:function(e){null!=(null==b?void 0:b.current)&&null!=(null==g?void 0:g.current)&&(b.current[n.id]=e,g.current[n.id]=e)},className:e($(m.node),m.leaf),"aria-setsize":A,"aria-posinset":W,"aria-level":j,disabled:f.has(n.id),"aria-disabled":f.has(n.id)},J)},setsize:A,posinset:W,level:j,handleSelect:X,handleExpand:p,treeState:F}))},re=function(e){var t=e.data,n=e.element,l=e.expandedIds,r=e.getClasses,i=e.baseClassNames,s=e.level,c=h(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return a.createElement("ul",{role:"group",className:r(i.nodeGroup)},l.has(n.id)&&n.children.length>0&&n.children.map((function(e,r){return a.createElement(le,Object.assign({data:t,expandedIds:l,baseClassNames:i,key:"".concat(e,"-").concat(d(e)),element:M(t,e),setsize:n.children.length,posinset:r+1,level:s+1},c))})))},de=function(e){var t=e.data,a=e.controlledIds,d=e.controlledExpandedIds,i=e.defaultExpandedIds,o=e.defaultSelectedIds,u=e.defaultDisabledIds,h=e.nodeRefs,v=e.leafRefs,E=e.onSelect,O=e.onNodeSelect,A=e.onExpand,W=e.onLoadData,x=e.togglableSelect,j=e.multiSelect,T=e.propagateSelect,D=e.propagateSelectUpwards,N=L(t),k=s(r(Z,{selectedIds:new Set(a||o),tabbableId:N.children[0],isFocused:!1,expandedIds:new Set(d||i),halfSelectedIds:new Set,lastUserSelect:N.children[0],lastInteractedWith:null,lastManuallyToggled:null,disabledIds:new Set(u)}),2),U=k[0],G=k[1],Y=U.selectedIds,X=U.expandedIds,$=U.disabledIds,J=U.tabbableId,ee=U.halfSelectedIds,te=U.lastAction,ae=U.lastInteractedWith,ne=U.lastManuallyToggled,le=b(Y)||new Set,re=S(Y,le);l((function(){var e;if(null!=E&&E!==p){var a,n=f(re);try{for(n.s();!(a=n.n()).done;){var l=a.value,r=I(t,l)||!!(null===(e=M(t,J))||void 0===e?void 0:e.isBranch);E({element:M(t,l),isBranch:r,isExpanded:!!r&&X.has(l),isSelected:Y.has(l),isDisabled:$.has(l),isHalfSelected:!!r&&ee.has(l),treeState:U})}}catch(e){n.e(e)}finally{n.f()}}}),[t,Y,X,$,ee,re,E,U]),l((function(){null!=O&&O!==p&&null!=ne&&re.size&&(O({element:M(t,ne),isSelected:Y.has(ne),isBranch:I(t,ne),treeState:U}),G({type:Q}))}),[ne,Y,re]);var de=b(X)||new Set;l((function(){var e=S(X,de);if(null!=A&&A!==p){var a,n=f(e);try{for(n.s();!(a=n.n()).done;){var l=a.value;A({element:M(t,l),isExpanded:X.has(l),isSelected:Y.has(l),isDisabled:$.has(l),isHalfSelected:ee.has(l),treeState:U})}}catch(e){n.e(e)}finally{n.f()}}}),[t,Y,X,$,ee,de,A,U]);var ie,se,ce=(ie=t,se=n(),l((function(){se.current=ie})),se.current||new Map);return l((function(){var e=S(X,de);if(W){var a,n=f(e);try{for(n.s();!(a=n.n()).done;){var l=a.value;W({element:M(t,l),isExpanded:X.has(l),isSelected:Y.has(l),isDisabled:$.has(l),isHalfSelected:ee.has(l),treeState:U})}}catch(e){n.e(e)}finally{n.f()}if(ce!==t&&x&&T){var r,d=f(X);try{for(d.s();!(r=d.n()).done;){var i=r.value;Y.has(i)&&G({type:V,ids:C(t,[i],$),select:!0,multiSelect:j,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,Y,X,$,ee,de,W,U]),l((function(){var e=new Set(a),n=y(e,le),l=y(le,e);if(l.size){var r,d=f(l);try{for(d.s();!(r=d.n()).done;){var i=r.value;G({type:H,id:i,multiSelect:j,controlled:!0,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}if(n.size){var s,c=f(n);try{for(c.s();!(s=c.n()).done;){var o=s.value;G({type:K,id:o,multiSelect:j,controlled:!0,lastInteractedWith:o}),T&&!$.has(o)&&G({type:V,ids:C(t,[o],$),select:!0,multiSelect:j,lastInteractedWith:o})}}catch(e){c.e(e)}finally{c.f()}}}),[a]),l((function(){var e=new Set(d),a=y(e,de),n=y(de,e);if(n.size){var l,r=f(n);try{for(r.s();!(l=r.n()).done;){var i=l.value;if(I(t,i)||M(t,i).isBranch){var s=[i].concat(c(w(t,i,new Set)));G({type:B,ids:s,lastInteractedWith:i})}}}catch(e){r.e(e)}finally{r.f()}}if(a.size){var o,u=f(a);try{for(u.s();!(o=u.n()).done;){var h=o.value;if(I(t,h)||M(t,h).isBranch){var p=g(t,h);G(p?{type:z,ids:[h,p],lastInteractedWith:h}:{type:F,id:h,lastInteractedWith:h})}}}catch(e){u.e(e)}finally{u.f()}}}),[d]),l((function(){if(D){var e=new Set(re);ae&&te!==q&&te!==R&&te!==F&&te!==P&&e.add(ae);var a,n=function(e,t,a,n,l,r){var d,i={every:new Set,some:new Set,none:new Set},s=f(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var o=g(e,c);if(0===o||null==o||null!=o&&n.has(o))break;var u=M(e,o).children.filter((function(e){return!n.has(e)}));if(0===u.length)break;if(u.some((function(e){return a.has(e)||i.some.has(e)||l.has(e)})))u.every((function(e){return a.has(e)}))?i.every.add(o):i.some.add(o);else{var h=m(e,c,n).find((function(e){return a.has(e)}));if(!r&&h){w(e,h,n).forEach((function(e){l.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,Y,$,ee,j),l=n.every,r=n.some,d=n.none,i=f(l);try{for(i.s();!(a=i.n()).done;){var s=a.value;Y.has(s)||G({type:K,id:s,multiSelect:j,keepFocus:!0,NotUserAction:!0,lastInteractedWith:ae})}}catch(e){i.e(e)}finally{i.f()}var c,o=f(r);try{for(o.s();!(c=o.n()).done;){var u=c.value;ee.has(u)||G({type:_,id:u,lastInteractedWith:ae})}}catch(e){o.e(e)}finally{o.f()}var h,p=f(d);try{for(p.s();!(h=p.n()).done;){var v=h.value;(Y.has(v)||ee.has(v))&&G({type:H,id:v,multiSelect:j,keepFocus:!0,NotUserAction:!0,lastInteractedWith:ae,lastManuallyToggled:ne})}}catch(e){p.e(e)}finally{p.f()}}}),[t,j,D,Y,X,$,ee,te,le,re,ae]),l((function(){if(null!=ae&&null!=J&&null!=(null==h?void 0:h.current)&&null!=(null==v?void 0:v.current)){var e=h.current[J];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(v.current[ae]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[J,h,v,ae]),[U,G]},ie=a.forwardRef((function(t,l){var r=t.data,i=t.selectedIds,c=t.nodeRenderer,o=t.onSelect,u=void 0===o?p:o,f=t.onNodeSelect,v=void 0===f?p:f,y=t.onExpand,S=void 0===y?p:y,b=t.onLoadData,I=t.className,g=void 0===I?"":I,m=t.multiSelect,w=void 0!==m&&m,E=t.propagateSelect,O=void 0!==E&&E,A=t.propagateSelectUpwards,W=void 0!==A&&A,x=t.propagateCollapse,j=void 0!==x&&x,T=t.expandOnKeyboardSelect,D=void 0!==T&&T,C=t.togglableSelect,k=void 0!==C&&C,R=t.defaultExpandedIds,B=void 0===R?[]:R,F=t.defaultSelectedIds,z=void 0===F?[]:F,_=t.defaultDisabledIds,K=void 0===_?[]:_,H=t.clickAction,P=void 0===H?te.select:H,G=t.nodeAction,V=void 0===G?"select":G,Y=t.expandedIds,q=t.onBlur,$=h(t,["data","selectedIds","nodeRenderer","onSelect","onNodeSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]);!function(e){if(U(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(U(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.")}(r);var J=n({}),Q=n({}),Z=s(de({data:r,controlledIds:i,controlledExpandedIds:Y,defaultExpandedIds:B,defaultSelectedIds:z,defaultDisabledIds:K,nodeRefs:J,leafRefs:Q,onSelect:u,onNodeSelect:v,onExpand:S,onLoadData:b,togglableSelect:k,multiSelect:w,propagateSelect:O,propagateSelectUpwards:W}),2),ae=Z[0],ne=Z[1];O=O&&w;var re=n(null);return null!=l&&(re=l),a.createElement("ul",Object.assign({className:e(ee.root,g),role:"tree","aria-multiselectable":"select"===V?w:void 0,ref:re,onBlur:function(e){N(e,re.current,(function(){q&&q({treeState:ae,dispatch:ne}),ne({type:X})}))},onKeyDown:se({data:r,tabbableId:ae.tabbableId,expandedIds:ae.expandedIds,selectedIds:ae.selectedIds,disabledIds:ae.disabledIds,halfSelectedIds:ae.halfSelectedIds,clickAction:P,dispatch:ne,propagateCollapse:j,propagateSelect:O,multiSelect:w,expandOnKeyboardSelect:D,togglableSelect:k})},$),L(r).children.map((function(e,t){return a.createElement(le,Object.assign({key:"".concat(e,"-").concat(d(e)),data:r,element:M(r,e),setsize:L(r).children.length,posinset:t+1,level:1},ae,{state:ae,dispatch:ne,nodeRefs:J,leafRefs:Q,baseClassNames:ee,nodeRenderer:c,propagateCollapse:j,propagateSelect:O,propagateSelectUpwards:W,multiSelect:w,togglableSelect:k,clickAction:P,nodeAction:V}))})))})),se=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,l=e.disabledIds,r=e.tabbableId,d=e.dispatch,i=e.propagateCollapse,s=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=M(t,r),v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var y=t.filter((function(e){return null!==e.parent})).map((function(e){return e.id})).filter((function(e){return!l.has(e)}));d({type:V,multiSelect:o,select:Array.from(n).filter((function(e){return!l.has(e)})).length!==y.length,ids:y,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var S="Home"===e.key?L(t).children[0]:O(t,v,a),b=x({data:t,expandedIds:a,from:v,to:S}).filter((function(e){return!l.has(e)}));d({type:V,multiSelect:o,select:!0,ids:s?C(t,b,l):b}),d({type:q,id:S,lastInteractedWith:S})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var m=A(t,v,a);return void(null==m||l.has(m)||(d({type:V,ids:s?C(t,[m],l):[m],select:!0,multiSelect:o,lastInteractedWith:m,lastManuallyToggled:m}),d({type:q,id:m,lastInteractedWith:m})));case"ArrowDown":e.preventDefault();var E=W(t,v,a);return void(null==E||l.has(E)||(d({type:V,ids:s?C(t,[E],l):[E],multiSelect:o,select:!0,lastInteractedWith:E,lastManuallyToggled:E}),d({type:q,id:E,lastInteractedWith:E})))}switch(e.key){case"ArrowDown":e.preventDefault();var j=W(t,v,a);return void(null!=j&&d({type:q,id:j,lastInteractedWith:j}));case"ArrowUp":e.preventDefault();var T=A(t,v,a);return void(null!=T&&d({type:q,id:T,lastInteractedWith:T}));case"ArrowLeft":if(e.preventDefault(),(I(t,v)||p.isBranch)&&a.has(r))if(i){var D=[v].concat(c(w(t,v,new Set)));d({type:B,ids:D,lastInteractedWith:p.id})}else d({type:R,id:v,lastInteractedWith:v});else if(!L(t).children.includes(v)){var N=g(t,v);if(null==N)throw new Error("parentId of root element is null");d({type:q,id:N,lastInteractedWith:N})}return;case"ArrowRight":return e.preventDefault(),void((I(t,v)||p.isBranch)&&(a.has(r)?d({type:q,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:F,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),d({type:q,id:L(t).children[0],lastInteractedWith:L(t).children[0]});break;case"End":e.preventDefault();var U=O(t,L(t).id,a);return void d({type:q,id:U,lastInteractedWith:U});case"*":e.preventDefault();var H=g(t,v);if(null==H)throw new Error("parentId of element is null");var Y=M(t,H).children.filter((function(e){return I(t,e)||M(t,e).isBranch}));return void d({type:z,ids:Y,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===te.focus)return;var X=k(t,p.id,n);return d({type:f?X?_:G:K,id:v,multiSelect:o,lastInteractedWith:v,lastManuallyToggled:v}),s&&!l.has(p.id)&&d({type:V,ids:C(t,[v],l),select:!f||!n.has(v),multiSelect:o,lastInteractedWith:v,lastManuallyToggled:v}),void(u&&d({type:P,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var $=W(t,v,a);$!==v;)if(null!=$){if(M(t,$).name[0].toLowerCase()===e.key.toLowerCase())return void d({type:q,id:$,lastInteractedWith:v});$=W(t,$,a)}else $=L(t).children[0];return}}}};ie.propTypes={data:t.array.isRequired,onSelect:t.func,onNodeSelect: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(ae),onBlur:t.func,onLoadData:t.func};export default ie;export{ae as CLICK_ACTIONS,j as flattenTree};
import React from "react";
import { ITreeViewState, TreeViewAction } from "./reducer";
import { EventCallback, INode, INodeRef, NodeId, TreeViewData } from "./types";
declare const clickActions: {
readonly select: "SELECT";
readonly focus: "FOCUS";
readonly exclusiveSelect: "EXCLUSIVE_SELECT";
};
export declare const CLICK_ACTIONS: readonly ("SELECT" | "FOCUS" | "EXCLUSIVE_SELECT")[];
type ValueOf<T> = T[keyof T];
export type ClickActions = ValueOf<typeof clickActions>;
type ActionableNode = {
"aria-selected": boolean | undefined;
} | {
"aria-checked": boolean | undefined | "mixed";
};
export type LeafProps = ActionableNode & {
role: string;
tabIndex: number;
onClick: EventCallback;
ref: <T extends INodeRef>(x: T | null) => void;
className: string;
"aria-setsize": number;
"aria-posinset": number;
"aria-level": number;
"aria-selected": boolean;
disabled: boolean;
"aria-disabled": boolean;
};
export interface IBranchProps {
onClick: EventCallback;
className: string;
}
export interface INodeRendererProps {
/** The object that represents the rendered node */
import { ClickActions, INode, INodeRendererProps, NodeAction, NodeId, TreeViewData } from "./types";
export interface ITreeViewOnSelectProps {
element: INode;
/** A function which gives back the props to pass to the node */
getNodeProps: (args?: {
onClick?: EventCallback;
}) => IBranchProps | LeafProps;
/** Whether the rendered node is a branch node */
isBranch: boolean;
/** Whether the rendered node is selected */
isExpanded: boolean;
isSelected: boolean;
/** If the node is a branch node, whether it is half-selected, else undefined */
isHalfSelected: boolean;
/** If the node is a branch node, whether it is expanded, else undefined */
isExpanded: boolean;
/** Whether the rendered node is disabled */
isDisabled: boolean;
/** A positive integer that corresponds to the aria-level attribute */
level: number;
/** A positive integer that corresponds to the aria-setsize attribute */
setsize: number;
/** A positive integer that corresponds to the aria-posinset attribute */
posinset: number;
/** Function to assign to the onClick event handler of the element(s) that will toggle the selected state */
handleSelect: EventCallback;
/** Function to assign to the onClick event handler of the element(s) that will toggle the expanded state */
handleExpand: EventCallback;
/** Function to dispatch actions */
dispatch: React.Dispatch<TreeViewAction>;
/** state of the treeview */
treeState: ITreeViewState;
}
export interface ITreeViewOnSelectProps {
export interface ITreeViewOnNodeSelectProps {
element: INode;
isSelected: boolean;
isBranch: boolean;
isExpanded: boolean;
isSelected: boolean;
isHalfSelected: boolean;
isDisabled: boolean;
treeState: ITreeViewState;
treeState?: ITreeViewState;
}

@@ -91,8 +35,2 @@ export interface ITreeViewOnExpandProps {

}
declare const nodeActions: {
readonly check: "check";
readonly select: "select";
};
export declare const NODE_ACTIONS: readonly ("select" | "check")[];
export type NodeAction = ValueOf<typeof nodeActions>;
export interface ITreeViewProps {

@@ -103,2 +41,4 @@ /** Tree data*/

onSelect?: (props: ITreeViewOnSelectProps) => void;
/** Function called when a single node is manually selected/unselected. */
onNodeSelect?: (props: ITreeViewOnNodeSelectProps) => void;
/** Function called when a node changes its expanded state */

@@ -105,0 +45,0 @@ onExpand?: (props: ITreeViewOnExpandProps) => void;

@@ -18,2 +18,3 @@ import { NodeId } from "./types";

readonly enable: "ENABLE";
readonly clearLastManuallyToggled: "CLEAR_MANUALLY_TOGGLED";
};

@@ -48,2 +49,3 @@ export type TreeViewAction = {

lastInteractedWith?: NodeId | null;
lastManuallyToggled?: NodeId | null;
} | {

@@ -57,2 +59,3 @@ type: "DESELECT";

lastInteractedWith?: NodeId | null;
lastManuallyToggled?: NodeId | null;
} | {

@@ -68,2 +71,3 @@ type: "TOGGLE";

lastInteractedWith?: NodeId | null;
lastManuallyToggled?: NodeId | null;
} | {

@@ -75,2 +79,3 @@ type: "SELECT_MANY";

lastInteractedWith?: NodeId | null;
lastManuallyToggled?: NodeId | null;
} | {

@@ -84,2 +89,3 @@ type: "EXCLUSIVE_SELECT_MANY";

lastInteractedWith?: NodeId | null;
lastManuallyToggled?: NodeId | null;
} | {

@@ -97,2 +103,4 @@ type: "FOCUS";

id: NodeId;
} | {
type: "CLEAR_MANUALLY_TOGGLED";
};

@@ -116,4 +124,6 @@ export interface ITreeViewState {

lastInteractedWith?: NodeId | null;
/** Last node manually selected/deselected */
lastManuallyToggled?: NodeId | null;
lastAction?: TreeViewAction["type"];
}
export declare const treeReducer: (state: ITreeViewState, action: TreeViewAction) => ITreeViewState;
/// <reference types="react" />
import { clickActions, nodeActions } from "./constants";
import { ITreeViewState, TreeViewAction } from "./reducer";
export type ValueOf<T> = T[keyof T];
export type ClickActions = ValueOf<typeof clickActions>;
export type NodeAction = ValueOf<typeof nodeActions>;
export type NodeId = number | string;
export type INodeRef = HTMLLIElement | HTMLDivElement;
export type INodeRefs = null | React.RefObject<{
[key: NodeId]: INodeRef;
}>;
export type TreeViewData = INode[];
export type EventCallback = <T, E>(event: React.MouseEvent<T, E> | React.KeyboardEvent<T>) => void;
export interface INode {

@@ -15,7 +26,56 @@ /** A non-negative integer that uniquely identifies the node */

}
export type INodeRef = HTMLLIElement | HTMLDivElement;
export type INodeRefs = null | React.RefObject<{
[key: NodeId]: INodeRef;
}>;
export type TreeViewData = INode[];
export type EventCallback = <T, E>(event: React.MouseEvent<T, E> | React.KeyboardEvent<T>) => void;
export interface INodeRendererProps {
/** The object that represents the rendered node */
element: INode;
/** A function which gives back the props to pass to the node */
getNodeProps: (args?: {
onClick?: EventCallback;
}) => IBranchProps | LeafProps;
/** Whether the rendered node is a branch node */
isBranch: boolean;
/** Whether the rendered node is selected */
isSelected: boolean;
/** If the node is a branch node, whether it is half-selected, else undefined */
isHalfSelected: boolean;
/** If the node is a branch node, whether it is expanded, else undefined */
isExpanded: boolean;
/** Whether the rendered node is disabled */
isDisabled: boolean;
/** A positive integer that corresponds to the aria-level attribute */
level: number;
/** A positive integer that corresponds to the aria-setsize attribute */
setsize: number;
/** A positive integer that corresponds to the aria-posinset attribute */
posinset: number;
/** Function to assign to the onClick event handler of the element(s) that will toggle the selected state */
handleSelect: EventCallback;
/** Function to assign to the onClick event handler of the element(s) that will toggle the expanded state */
handleExpand: EventCallback;
/** Function to dispatch actions */
dispatch: React.Dispatch<TreeViewAction>;
/** state of the treeview */
treeState: ITreeViewState;
}
type ActionableNode = {
"aria-selected": boolean | undefined;
} | {
"aria-checked": boolean | undefined | "mixed";
};
export type LeafProps = ActionableNode & {
role: string;
tabIndex: number;
onClick: EventCallback;
ref: <T extends INodeRef>(x: T | null) => void;
className: string;
"aria-setsize": number;
"aria-posinset": number;
"aria-level": number;
"aria-selected": boolean;
disabled: boolean;
"aria-disabled": boolean;
};
export interface IBranchProps {
onClick: EventCallback;
className: string;
}
export {};
import { EventCallback, INode, INodeRef, NodeId, TreeViewData } from "./types";
export declare const noop: () => void;
export declare const composeHandlers: (...handlers: EventCallback[]) => EventCallback;

@@ -3,0 +4,0 @@ export declare const difference: (a: Set<NodeId>, b: Set<NodeId>) => Set<NodeId>;

{
"name": "react-accessible-treeview",
"description": "A react component that implements the treeview pattern as described by the WAI-ARIA Authoring Practices.",
"version": "2.4.0",
"version": "2.5.0",
"author": "lissitz (https://github.com/lissitz)",

@@ -23,3 +23,3 @@ "main": "dist/react-accessible-treeview.cjs.js",

"@storybook/addons": "^6.5.16",
"@storybook/react": "^6.5.16",
"@storybook/react": "^7.0.7",
"@testing-library/dom": "^8.16.0",

@@ -26,0 +26,0 @@ "@testing-library/jest-dom": "^5.16.4",

@@ -24,2 +24,3 @@ # 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)

| `onSelect` | `func` | `noop` | Function called when a node changes its selected state |
| `onNodeSelect` | `func` | `noop` | Function called when a node was manually selected/deselected |
| `onExpand` | `func` | `noop` | Function called when a node changes its expanded state |

@@ -76,3 +77,3 @@ | `className` | `string` | `""` | className to add to the outermost dom element, al `ul` with `role = "tree"` |

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).

@@ -111,2 +112,6 @@ Data supports non-sequential ids provided by user.

## onNodeSelect
- _Arguments_: `onNodeSelect({element, isBranch, isSelected, treeState })`
Note: the function uses the state right _after_ the selection before propagation.
## onExpand

@@ -120,3 +125,3 @@

- _Arguments_: `onLoadData({element, isExpanded, isSelected, isHalfSelected, isDisabled, treeState})`
Note: the function uses the state _after_ inital data is loaded and on expansion .
Note: the function uses the state _after_ inital data is loaded and on expansion.
<br/> <br/>

@@ -169,11 +174,12 @@

| Property | Type | Default | Description |
| ------------------ | ---------------- | ----------------------------- | ---------------------------------------- |
| selectedIds | `Set` | `new Set(defaultSelectedIds)` | Set of the ids of the selected nodes |
| tabbableId | `number` | `data[0].children[0]` | Id of the node with tabindex = 0 |
| isFocused | `bool` | `false` | Whether the tree has focus |
| expandedIds | `Set` | `new Set(defaultExpandedIds)` | Set of the ids of the expanded nodes |
| halfSelectedIds | `Set` | `new Set()` | Set of the ids of the selected nodes |
| lastUserSelect | `number` | `data[0].children[0]` | Last selection made directly by the user |
| lastInteractedWith | `number or null` | `null` | Last node interacted with |
| disabledIds | `Set` | `new Set(defaultDisabledIds)` | Set of the ids of the selected nodes |
| Property | Type | Default | Description |
| ------------------- | ---------------- | ----------------------------- | ----------------------------------------------- |
| selectedIds | `Set` | `new Set(defaultSelectedIds)` | Set of the ids of the selected nodes |
| tabbableId | `number` | `data[0].children[0]` | Id of the node with tabindex = 0 |
| isFocused | `bool` | `false` | Whether the tree has focus |
| expandedIds | `Set` | `new Set(defaultExpandedIds)` | Set of the ids of the expanded nodes |
| halfSelectedIds | `Set` | `new Set()` | Set of the ids of the selected nodes |
| lastUserSelect | `number` | `data[0].children[0]` | Last selection made directly by the user |
| lastInteractedWith | `number or null` | `null` | Last node interacted with |
| lastManuallyToggled | `number or null` | `null` | Last node that was manually selected/deselected |
| disabledIds | `Set` | `new Set(defaultDisabledIds)` | Set of the ids of the selected nodes |
import TreeView, {
ClickActions,
CLICK_ACTIONS,
IBranchProps,
LeafProps,
INodeRendererProps,
ITreeViewOnExpandProps,
ITreeViewOnSelectProps,
ITreeViewOnNodeSelectProps,
ITreeViewProps,
ITreeViewOnLoadDataProps,
} from "./TreeView";
import { CLICK_ACTIONS } from "./TreeView/constants";
import { ITreeViewState, TreeViewAction } from "./TreeView/reducer";
import { INode, TreeViewData, EventCallback } from "./TreeView/types";
import {
INode,
TreeViewData,
EventCallback,
ClickActions,
INodeRendererProps,
IBranchProps,
LeafProps,
} from "./TreeView/types";
import { flattenTree } from "./TreeView/utils";

@@ -22,2 +27,3 @@

ITreeViewOnSelectProps,
ITreeViewOnNodeSelectProps,
CLICK_ACTIONS,

@@ -24,0 +30,0 @@ ITreeViewOnExpandProps,

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