react-accessible-treeview
Advanced tools
Comparing version 2.3.4 to 2.3.5
@@ -1,1 +0,1 @@ | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("classnames")),a=e(require("prop-types")),n=require("react"),r=e(n);function l(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,r,l=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);d=!0);}catch(e){i=!0,r=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw r}}return l}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){if(e){if("string"==typeof e)return c(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function o(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=s(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,d=!0,i=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return d=e.done,e},e:function(e){i=!0,l=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw l}}}}function u(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]])}return a}var f=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){var a,n=o(t);try{for(n.s();!(a=n.n()).done;){var r=a.value;if(r&&r(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},h=function(e,t){var a,n=new Set,r=o(e);try{for(r.s();!(a=r.n()).done;){var l=a.value;t.has(l)||n.add(l)}}catch(e){r.e(e)}finally{r.f()}return n},p=function(e,t){return new Set([].concat(i(h(e,t)),i(h(t,e))))},v=function(e){var t=n.useRef();return n.useEffect((function(){t.current=e}),[e]),t.current},I=function(e,t){return null!=e[t].children&&e[t].children.length>0},b=function(e,t){return e[t].parent},S=function(e,t,a){for(var n=t,r=[];;){var l=b(e,n);if(0===l||null==l||null!=l&&a.has(l))break;r.push(l),n=l}return r},y=function(e,t,a){var n=[];return function e(t,r){var l=t[r];if(null!=l.children){var d,i=o(l.children.filter((function(e){return!a.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;n.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),n},m=function(e,t,a){var n=b(e,t);if(null!=n){var r=e[n],l=r.children.indexOf(t)+a;if(r.children[l])return r.children[l]}return null},g=function(e,t,a){var n=e[t];for(e[0].id===t&&(n=e[e[t].children[e[t].children.length-1]]);a.has(n.id)&&I(e,n.id);)n=e[n.children[n.children.length-1]];return n.id},w=function(e,t,a){if(t===e[0].children[0])return null;var n=m(e,t,-1);return null==n?b(e,t):g(e,n,a)},E=function(e,t,a){var n=e[t].id;if(I(e,n)&&a.has(n))return e[n].children[0];for(;;){var r=m(e,n,1);if(null!=r)return r;if(null==(n=b(e,n)))return null}},O=function(e){var t=e.data,a=e.expandedIds,n=e.from,r=e.to,l=[],d=Object.keys(t).length,i=0,s=n;if(l.push(n),n<r)for(;i<d&&(null!=(s=E(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;else if(n>r)for(;i<d&&(null!=(s=w(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;return l},x=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},W=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,r=e.multiSelect;return a?t:n?"mixed":r?t:!!t||void 0},A=function(e,t,a){return t.concat.apply(t,i(t.filter((function(t){return I(e,t)})).map((function(t){return y(e,t,a)}))))},j=function(e,t,a){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&a()}),0):!t.contains(e.nativeEvent.relatedTarget)&&a():console.warn("ref not set on <ul>")},C=function(e,t,a){return I(e,t)&&a.has(t)&&y(e,t,new Set).some((function(e){return a.has(e)}))},D={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},k="COLLAPSE",L="COLLAPSE_MANY",N="EXPAND",U="EXPAND_MANY",R="HALF_SELECT",T="SELECT",F="DESELECT",B="TOGGLE",_="TOGGLE_SELECT",z="SELECT_MANY",K="EXCLUSIVE_CHANGE_SELECT_MANY",H="FOCUS",P="BLUR",G="DISABLE",M="ENABLE",q=function(e,t){switch(t.type){case k:var a=new Set(e.expandedIds);return a.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:a,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case L:var n,r=new Set(e.expandedIds),l=o(t.ids);try{for(l.s();!(n=l.n()).done;){var d=n.value;r.delete(d)}}catch(e){l.e(e)}finally{l.f()}return Object.assign(Object.assign({},e),{expandedIds:r,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case N:var s=new Set(e.expandedIds);return s.add(t.id),Object.assign(Object.assign({},e),{expandedIds:s,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case U:var c=new Set([].concat(i(e.expandedIds),i(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:var u=new Set(e.expandedIds);return e.expandedIds.has(t.id)?u.delete(t.id):u.add(t.id),Object.assign(Object.assign({},e),{expandedIds:u,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),p=new Set(e.selectedIds);return f.add(t.id),p.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:f,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case T:if(!t.controlled&&e.disabledIds.has(t.id))return e;var v;t.multiSelect?(v=new Set(e.selectedIds)).add(t.id):(v=new Set).add(t.id);var I=new Set(e.halfSelectedIds);return I.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:v,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case F:if(!t.controlled&&e.disabledIds.has(t.id))return e;var b,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(b=new Set(e.halfSelectedIds)).delete(t.id):b=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case _:if(e.disabledIds.has(t.id))return e;var y,m=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),m?y.delete(t.id):y.add(t.id)):(y=new Set,m||y.add(t.id));var g=new Set(e.halfSelectedIds);return g.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:g,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(i(e.selectedIds),i(E))):h(e.selectedIds,new Set(E));var O=h(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case K:var x,W=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){x=t.select?new Set(W):h(e.selectedIds,new Set(W));var A=h(e.halfSelectedIds,x);return Object.assign(Object.assign({},e),{selectedIds:x,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case H:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case P:return Object.assign(Object.assign({},e),{isFocused:!1});case G:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case M:var C=new Set(e.disabledIds);return C.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:C});default:throw new Error("Invalid action passed to the reducer")}},V=function(e){var t=e.data,a=e.controlledIds,r=e.controlledExpandedIds,l=e.defaultExpandedIds,s=e.defaultSelectedIds,c=e.defaultDisabledIds,u=e.nodeRefs,f=e.leafRefs,m=e.onSelect,g=e.onExpand,w=e.onLoadData,E=e.togglableSelect,O=e.multiSelect,x=e.propagateSelect,W=e.propagateSelectUpwards,j=d(n.useReducer(q,{selectedIds:new Set(a||s),tabbableId:t[0].children[0],isFocused:!1,expandedIds:new Set(r||l),halfSelectedIds:new Set,lastUserSelect:t[0].children[0],lastInteractedWith:null,disabledIds:new Set(c)}),2),C=j[0],D=j[1],_=C.selectedIds,K=C.expandedIds,P=C.disabledIds,G=C.tabbableId,M=C.halfSelectedIds,V=C.lastAction,X=C.lastInteractedWith,Y=v(_)||new Set,$=p(_,Y);n.useEffect((function(){if(null!=m&&m!==J){var e,a=o($);try{for(a.s();!(e=a.n()).done;){var n=e.value,r=I(t,n)||!!t[G].isBranch;m({element:t[n],isBranch:r,isExpanded:!!r&&K.has(n),isSelected:_.has(n),isDisabled:P.has(n),isHalfSelected:!!r&&M.has(n),treeState:C})}}catch(e){a.e(e)}finally{a.f()}}}),[t,_,K,P,M,$,m,C]);var Q=v(K)||new Set;n.useEffect((function(){var e=p(K,Q);if(null!=g&&g!==J){var a,n=o(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;g({element:t[r],isExpanded:K.has(r),isSelected:_.has(r),isDisabled:P.has(r),isHalfSelected:M.has(r),treeState:C})}}catch(e){n.e(e)}finally{n.f()}}}),[t,_,K,P,M,Q,g,C]);var Z,ee,te=(Z=t,ee=n.useRef(),n.useEffect((function(){ee.current=Z})),ee.current||new Set);return n.useEffect((function(){var e=p(K,Q);if(w){var a,n=o(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;w({element:t[r],isExpanded:K.has(r),isSelected:_.has(r),isDisabled:P.has(r),isHalfSelected:M.has(r),treeState:C})}}catch(e){n.e(e)}finally{n.f()}if(te!==t&&E&&x){var l,d=o(K);try{for(d.s();!(l=d.n()).done;){var i=l.value;_.has(i)&&D({type:z,ids:A(t,[i],P),select:!0,multiSelect:O,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,_,K,P,M,Q,w,C]),n.useEffect((function(){var e=new Set(a),n=h(e,Y),r=h(Y,e);if(r.size){var l,d=o(r);try{for(d.s();!(l=d.n()).done;){var i=l.value;D({type:F,id:i,multiSelect:O,controlled:!0,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}if(n.size){var s,c=o(n);try{for(c.s();!(s=c.n()).done;){var u=s.value;D({type:T,id:u,multiSelect:O,controlled:!0,lastInteractedWith:u}),x&&!P.has(u)&&D({type:z,ids:A(t,[u],P),select:!0,multiSelect:O,lastInteractedWith:u})}}catch(e){c.e(e)}finally{c.f()}}}),[a]),n.useEffect((function(){var e=new Set(r),a=h(e,Q),n=h(Q,e);if(n.size){var l,d=o(n);try{for(d.s();!(l=d.n()).done;){var s=l.value;if(I(t,s)||t[s].isBranch){var c=[s].concat(i(y(t,s,new Set)));D({type:L,ids:c,lastInteractedWith:s})}}}catch(e){d.e(e)}finally{d.f()}}if(a.size){var u,f=o(a);try{for(f.s();!(u=f.n()).done;){var p=u.value;if(I(t,p)||t[p].isBranch){var v=b(t,p);D(v?{type:U,ids:[p,v],lastInteractedWith:p}:{type:N,id:p,lastInteractedWith:p})}}}catch(e){f.e(e)}finally{f.f()}}}),[r]),n.useEffect((function(){if(W){var e=new Set($);X&&V!==H&&V!==k&&V!==N&&V!==B&&e.add(X);var a,n=function(e,t,a,n,r,l){var d,i={every:new Set,some:new Set,none:new Set},s=o(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var u=b(e,c);if(0===u||null==u||null!=u&&n.has(u))break;var f=e[u].children.filter((function(e){return!n.has(e)}));if(0===f.length)break;if(f.some((function(e){return a.has(e)||i.some.has(e)||r.has(e)})))f.every((function(e){return a.has(e)}))?i.every.add(u):i.some.add(u);else{var h=S(e,c,n).find((function(e){return a.has(e)}));if(!l&&h){y(e,h,n).forEach((function(e){r.has(e)&&i.none.add(e)}));break}i.none.add(u)}c=u}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,_,P,M,O),r=n.every,l=n.some,d=n.none,i=o(r);try{for(i.s();!(a=i.n()).done;){var s=a.value;_.has(s)||D({type:T,id:s,multiSelect:O,keepFocus:!0,NotUserAction:!0,lastInteractedWith:X})}}catch(e){i.e(e)}finally{i.f()}var c,u=o(l);try{for(u.s();!(c=u.n()).done;){var f=c.value;M.has(f)||D({type:R,id:f,lastInteractedWith:X})}}catch(e){u.e(e)}finally{u.f()}var h,p=o(d);try{for(p.s();!(h=p.n()).done;){var v=h.value;(_.has(v)||M.has(v))&&D({type:F,id:v,multiSelect:O,keepFocus:!0,NotUserAction:!0,lastInteractedWith:X})}}catch(e){p.e(e)}finally{p.f()}}}),[t,O,W,_,K,P,M,V,Y,$,X]),n.useEffect((function(){if(null!=X&&null!=G&&null!=(null==u?void 0:u.current)&&null!=(null==f?void 0:f.current)){var e=u.current[G];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(f.current[X]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[G,u,f,X]),[C,D]},X={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},Y=Object.freeze(Object.values(X)),$=Object.freeze(Object.values({check:"check",select:"select"})),J=function(){},Q=r.forwardRef((function(e,a){var l=e.data,i=e.selectedIds,s=e.nodeRenderer,c=e.onSelect,o=void 0===c?J:c,f=e.onExpand,h=void 0===f?J:f,p=e.onLoadData,v=e.className,I=void 0===v?"":v,b=e.multiSelect,S=void 0!==b&&b,y=e.propagateSelect,m=void 0!==y&&y,g=e.propagateSelectUpwards,w=void 0!==g&&g,E=e.propagateCollapse,O=void 0!==E&&E,x=e.expandOnKeyboardSelect,W=void 0!==x&&x,A=e.togglableSelect,C=void 0!==A&&A,k=e.defaultExpandedIds,L=void 0===k?[]:k,N=e.defaultSelectedIds,U=void 0===N?[]:N,R=e.defaultDisabledIds,T=void 0===R?[]:R,F=e.clickAction,B=void 0===F?X.select:F,_=e.nodeAction,z=void 0===_?"select":_,K=e.expandedIds,H=e.onBlur,G=u(e,["data","selectedIds","nodeRenderer","onSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]),M=n.useRef({}),q=n.useRef({}),Y=d(V({data:l,controlledIds:i,controlledExpandedIds:K,defaultExpandedIds:L,defaultSelectedIds:U,defaultDisabledIds:T,nodeRefs:M,leafRefs:q,onSelect:o,onExpand:h,onLoadData:p,togglableSelect:C,multiSelect:S,propagateSelect:m,propagateSelectUpwards:w}),2),$=Y[0],Q=Y[1];m=m&&S;var ee=n.useRef(null);return null!=a&&(ee=a),r.createElement("ul",Object.assign({className:t(D.root,I),role:"tree","aria-multiselectable":"select"===z?S:void 0,ref:ee,onBlur:function(e){j(e,ee.current,(function(){H&&H({treeState:$,dispatch:Q}),Q({type:P})}))},onKeyDown:ae({data:l,tabbableId:$.tabbableId,expandedIds:$.expandedIds,selectedIds:$.selectedIds,disabledIds:$.disabledIds,halfSelectedIds:$.halfSelectedIds,dispatch:Q,propagateCollapse:O,propagateSelect:m,multiSelect:S,expandOnKeyboardSelect:W,togglableSelect:C})},G),l[0].children.map((function(e,t){return r.createElement(Z,Object.assign({key:e,data:l,element:l[e],setsize:l[0].children.length,posinset:t+1,level:1},$,{state:$,dispatch:Q,nodeRefs:M,leafRefs:q,baseClassNames:D,nodeRenderer:s,propagateCollapse:O,propagateSelect:m,propagateSelectUpwards:w,multiSelect:S,togglableSelect:C,clickAction:B,nodeAction:z}))})))})),Z=function(e){var a=e.element,n=e.dispatch,d=e.data,s=e.selectedIds,c=e.tabbableId,o=e.isFocused,u=e.expandedIds,h=e.disabledIds,p=e.halfSelectedIds,v=e.lastUserSelect,b=e.nodeRefs,S=e.leafRefs,m=e.baseClassNames,g=e.nodeRenderer,w=e.nodeAction,E=e.setsize,j=e.posinset,D=e.level,k=e.propagateCollapse,N=e.propagateSelect,U=e.multiSelect,F=e.togglableSelect,P=e.clickAction,G=e.state,M=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(a.id)&&k){var t=[a.id].concat(i(y(d,a.id,new Set)));n({type:L,ids:t,lastInteractedWith:a.id})}else n({type:B,id:a.id,lastInteractedWith:a.id})},q=function(){return n({type:H,id:a.id,lastInteractedWith:a.id})},V=function(e){if(e.shiftKey){var t=O({data:d,expandedIds:u,from:v,to:a.id}).filter((function(e){return!h.has(e)}));t=N?A(d,t,h):t,n({type:K,select:!0,multiSelect:U,ids:t,lastInteractedWith:a.id})}else if(e.ctrlKey||X.select){var r=C(d,a.id,s);n({type:F?r?R:_:T,id:a.id,multiSelect:U,lastInteractedWith:a.id}),N&&!h.has(a.id)&&n({type:z,ids:A(d,[a.id],h),select:!F||!s.has(a.id),multiSelect:U,lastInteractedWith:a.id})}else P===X.exclusiveSelect?n({type:F?_:T,id:a.id,multiSelect:!1,lastInteractedWith:a.id}):P===X.focus&&n({type:H,id:a.id,lastInteractedWith:a.id})},Y=function(e){var n;return t(e,(l(n={},"".concat(e,"--expanded"),u.has(a.id)),l(n,"".concat(e,"--selected"),s.has(a.id)),l(n,"".concat(e,"--focused"),c===a.id&&o),n))},$="select"===w?{"aria-selected":x({isSelected:s.has(a.id),isDisabled:h.has(a.id),multiSelect:U})}:{"aria-checked":W({isSelected:s.has(a.id),isDisabled:h.has(a.id),isHalfSelected:p.has(a.id),multiSelect:U})};return I(d,a.id)||a.isBranch?r.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(a.id),"aria-setsize":E,"aria-posinset":j,"aria-level":D,"aria-disabled":h.has(a.id),tabIndex:c===a.id?0:-1,ref:function(e){null!=(null==b?void 0:b.current)&&null!=e&&(b.current[a.id]=e)},className:m.branchWrapper},$),r.createElement(r.Fragment,null,g({element:a,isBranch:!0,isSelected:s.has(a.id),isHalfSelected:p.has(a.id),isExpanded:u.has(a.id),isDisabled:h.has(a.id),dispatch:n,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onClick;return{onClick:null==n?f(V,M,q):f(n,q),className:t(Y(m.node),m.branch),ref:function(e){null!=(null==S?void 0:S.current)&&(S.current[a.id]=e)}}},setsize:E,posinset:j,level:D,handleSelect:V,handleExpand:M,treeState:G}),r.createElement(te,Object.assign({getClasses:Y},ee(e))))):r.createElement("li",{role:"none",className:Y(m.leafListItem)},g({element:a,isBranch:!1,isSelected:s.has(a.id),isHalfSelected:!1,isExpanded:!1,isDisabled:h.has(a.id),dispatch:n,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onClick;return Object.assign({role:"treeitem",tabIndex:c===a.id?0:-1,onClick:f(null==n?V:n,q),ref:function(e){null!=(null==b?void 0:b.current)&&null!=(null==S?void 0:S.current)&&(b.current[a.id]=e,S.current[a.id]=e)},className:t(Y(m.node),m.leaf),"aria-setsize":E,"aria-posinset":j,"aria-level":D,disabled:h.has(a.id),"aria-disabled":h.has(a.id)},$)},setsize:E,posinset:j,level:D,handleSelect:V,handleExpand:J,treeState:G}))},ee=function(e){e.setsize,e.posinset;return u(e,["setsize","posinset"])},te=function(e){var t=e.data,a=e.element,n=e.expandedIds,l=e.getClasses,d=e.baseClassNames,i=e.level,s=u(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return r.createElement("ul",{role:"group",className:l(d.nodeGroup)},n.has(a.id)&&a.children.length>0&&a.children.map((function(e,l){return r.createElement(Z,Object.assign({data:t,expandedIds:n,baseClassNames:d,key:e,element:t[e],setsize:a.children.length,posinset:l+1,level:i+1},s))})))},ae=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,r=e.disabledIds,l=e.tabbableId,d=e.dispatch,s=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect;return function(e){var h=t[l],p=h.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var v=t.filter((function(e){return 0!==e.id})),S=Object.values(v).map((function(e){return e.id})).filter((function(e){return!r.has(e)}));d({type:z,multiSelect:o,select:Array.from(n).filter((function(e){return!r.has(e)})).length!==S.length,ids:S,lastInteractedWith:h.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var m="Home"===e.key?t[0].children[0]:g(t,p,a),x=O({data:t,expandedIds:a,from:p,to:m}).filter((function(e){return!r.has(e)}));d({type:z,multiSelect:o,select:!0,ids:c?A(t,x,r):x}),d({type:H,id:m,lastInteractedWith:m})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var W=w(t,p,a);return void(null==W||r.has(W)||(d({type:z,ids:c?A(t,[W],r):[W],select:!0,multiSelect:o,lastInteractedWith:W}),d({type:H,id:W,lastInteractedWith:W})));case"ArrowDown":e.preventDefault();var j=E(t,p,a);return void(null==j||r.has(j)||(d({type:z,ids:c?A(t,[j],r):[j],multiSelect:o,select:!0,lastInteractedWith:j}),d({type:H,id:j,lastInteractedWith:j})))}switch(e.key){case"ArrowDown":e.preventDefault();var D=E(t,p,a);return void(null!=D&&d({type:H,id:D,lastInteractedWith:D}));case"ArrowUp":e.preventDefault();var F=w(t,p,a);return void(null!=F&&d({type:H,id:F,lastInteractedWith:F}));case"ArrowLeft":if(e.preventDefault(),(I(t,p)||h.isBranch)&&a.has(l))if(s){var K=[p].concat(i(y(t,p,new Set)));d({type:L,ids:K,lastInteractedWith:h.id})}else d({type:k,id:p,lastInteractedWith:p});else if(!t[0].children.includes(p)){var P=b(t,p);if(null==P)throw new Error("parentId of root element is null");d({type:H,id:P,lastInteractedWith:P})}return;case"ArrowRight":return e.preventDefault(),void((I(t,p)||h.isBranch)&&(a.has(l)?d({type:H,id:h.children[0],lastInteractedWith:h.children[0]}):d({type:N,id:p,lastInteractedWith:p})));case"Home":e.preventDefault(),d({type:H,id:t[0].children[0],lastInteractedWith:t[0].children[0]});break;case"End":e.preventDefault();var G=g(t,t[0].id,a);return void d({type:H,id:G,lastInteractedWith:G});case"*":e.preventDefault();var M=b(t,p);if(null==M)throw new Error("parentId of element is null");var q=t[M].children.filter((function(e){return I(t,e)||t[e].isBranch}));return void d({type:U,ids:q,lastInteractedWith:p});case"Enter":case" ":case"Spacebar":e.preventDefault();var V=C(t,h.id,n);return d({type:f?V?R:_:T,id:p,multiSelect:o,lastInteractedWith:p}),c&&!r.has(h.id)&&d({type:z,ids:A(t,[p],r),select:!f||!n.has(p),multiSelect:o,lastInteractedWith:p}),void(u&&d({type:B,id:p,lastInteractedWith:p}));default:if(1===e.key.length)for(var X=E(t,p,a);X!==p;)if(null!=X){if(t[X].name[0].toLowerCase()===e.key.toLowerCase())return void d({type:H,id:X,lastInteractedWith:p});X=E(t,X,a)}else X=t[0].children[0];return}}}};Q.propTypes={data:a.array.isRequired,onSelect:a.func,onExpand:a.func,className:a.string,nodeRenderer:a.func.isRequired,defaultExpandedIds:a.array,defaultSelectedIds:a.array,expandedIds:a.array,selectedIds:a.array,defaultDisabledIds:a.array,propagateCollapse:a.bool,propagateSelect:a.bool,propagateSelectUpwards:a.bool,multiSelect:a.bool,expandOnKeyboardSelect:a.bool,togglableSelect:a.bool,nodeAction:a.oneOf($),clickAction:a.oneOf(Y),onBlur:a.func,onLoadData:a.func},exports.CLICK_ACTIONS=Y,exports.default=Q,exports.flattenTree=function(e){var t=0,a=[];return function e(n,r){var l={id:t,name:n.name,children:[],parent:r};if(a[t]=l,t+=1,null!=n.children&&0!==n.children.length){var d,i=o(n.children);try{for(i.s();!(d=i.n()).done;){e(d.value,l.id)}}catch(e){i.e(e)}finally{i.f()}l.children=a.filter((function(e){return e.parent===l.id})).map((function(e){return e.id}))}}(e,null),a}; | ||
"use strict";function e(e){return e&&"object"==typeof e&&"default"in e?e.default:e}Object.defineProperty(exports,"__esModule",{value:!0});var t=e(require("classnames")),a=e(require("prop-types")),n=require("react"),r=e(n);function l(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function d(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,r,l=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);d=!0);}catch(e){i=!0,r=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw r}}return l}(e,t)||s(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function i(e){return function(e){if(Array.isArray(e))return c(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||s(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e,t){if(e){if("string"==typeof e)return c(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?c(e,t):void 0}}function c(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function o(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=s(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,d=!0,i=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return d=e.done,e},e:function(e){i=!0,l=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw l}}}}function u(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]])}return a}var f=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){var a,n=o(t);try{for(n.s();!(a=n.n()).done;){var r=a.value;if(r&&r(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},h=function(e,t){var a,n=new Set,r=o(e);try{for(r.s();!(a=r.n()).done;){var l=a.value;t.has(l)||n.add(l)}}catch(e){r.e(e)}finally{r.f()}return n},p=function(e,t){return new Set([].concat(i(h(e,t)),i(h(t,e))))},v=function(e){var t=n.useRef();return n.useEffect((function(){t.current=e}),[e]),t.current},I=function(e,t){return null!=e[t].children&&e[t].children.length>0},b=function(e,t){return e[t].parent},S=function(e,t,a){for(var n=t,r=[];;){var l=b(e,n);if(0===l||null==l||null!=l&&a.has(l))break;r.push(l),n=l}return r},y=function(e,t,a){var n=[];return function e(t,r){var l=t[r];if(null!=l.children){var d,i=o(l.children.filter((function(e){return!a.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;n.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),n},m=function(e,t,a){var n=b(e,t);if(null!=n){var r=e[n],l=r.children.indexOf(t)+a;if(r.children[l])return r.children[l]}return null},g=function(e,t,a){var n=e[t];for(e[0].id===t&&(n=e[e[t].children[e[t].children.length-1]]);a.has(n.id)&&I(e,n.id);)n=e[n.children[n.children.length-1]];return n.id},w=function(e,t,a){if(t===e[0].children[0])return null;var n=m(e,t,-1);return null==n?b(e,t):g(e,n,a)},E=function(e,t,a){var n=e[t].id;if(I(e,n)&&a.has(n))return e[n].children[0];for(;;){var r=m(e,n,1);if(null!=r)return r;if(null==(n=b(e,n)))return null}},O=function(e){var t=e.data,a=e.expandedIds,n=e.from,r=e.to,l=[],d=Object.keys(t).length,i=0,s=n;if(l.push(n),n<r)for(;i<d&&(null!=(s=E(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;else if(n>r)for(;i<d&&(null!=(s=w(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;return l},x=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},W=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,r=e.multiSelect;return a?t:n?"mixed":r?t:!!t||void 0},A=function(e,t,a){return t.concat.apply(t,i(t.filter((function(t){return I(e,t)})).map((function(t){return y(e,t,a)}))))},j=function(e,t,a){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&a()}),0):!t.contains(e.nativeEvent.relatedTarget)&&a():console.warn("ref not set on <ul>")},C=function(e,t,a){return I(e,t)&&a.has(t)&&y(e,t,new Set).some((function(e){return a.has(e)}))},D={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},k="COLLAPSE",L="COLLAPSE_MANY",N="EXPAND",U="EXPAND_MANY",R="HALF_SELECT",T="SELECT",F="DESELECT",B="TOGGLE",_="TOGGLE_SELECT",z="SELECT_MANY",K="EXCLUSIVE_CHANGE_SELECT_MANY",H="FOCUS",P="BLUR",G="DISABLE",M="ENABLE",q=function(e,t){switch(t.type){case k:var a=new Set(e.expandedIds);return a.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:a,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case L:var n,r=new Set(e.expandedIds),l=o(t.ids);try{for(l.s();!(n=l.n()).done;){var d=n.value;r.delete(d)}}catch(e){l.e(e)}finally{l.f()}return Object.assign(Object.assign({},e),{expandedIds:r,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case N:var s=new Set(e.expandedIds);return s.add(t.id),Object.assign(Object.assign({},e),{expandedIds:s,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case U:var c=new Set([].concat(i(e.expandedIds),i(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:var u=new Set(e.expandedIds);return e.expandedIds.has(t.id)?u.delete(t.id):u.add(t.id),Object.assign(Object.assign({},e),{expandedIds:u,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),p=new Set(e.selectedIds);return f.add(t.id),p.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:p,halfSelectedIds:f,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case T:if(!t.controlled&&e.disabledIds.has(t.id))return e;var v;t.multiSelect?(v=new Set(e.selectedIds)).add(t.id):(v=new Set).add(t.id);var I=new Set(e.halfSelectedIds);return I.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:v,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case F:if(!t.controlled&&e.disabledIds.has(t.id))return e;var b,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(b=new Set(e.halfSelectedIds)).delete(t.id):b=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case _:if(e.disabledIds.has(t.id))return e;var y,m=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),m?y.delete(t.id):y.add(t.id)):(y=new Set,m||y.add(t.id));var g=new Set(e.halfSelectedIds);return g.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:g,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(i(e.selectedIds),i(E))):h(e.selectedIds,new Set(E));var O=h(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case K:var x,W=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){x=t.select?new Set(W):h(e.selectedIds,new Set(W));var A=h(e.halfSelectedIds,x);return Object.assign(Object.assign({},e),{selectedIds:x,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case H:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case P:return Object.assign(Object.assign({},e),{isFocused:!1});case G:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case M:var C=new Set(e.disabledIds);return C.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:C});default:throw new Error("Invalid action passed to the reducer")}},V=function(e){var t=e.data,a=e.controlledIds,r=e.controlledExpandedIds,l=e.defaultExpandedIds,s=e.defaultSelectedIds,c=e.defaultDisabledIds,u=e.nodeRefs,f=e.leafRefs,m=e.onSelect,g=e.onExpand,w=e.onLoadData,E=e.togglableSelect,O=e.multiSelect,x=e.propagateSelect,W=e.propagateSelectUpwards,j=d(n.useReducer(q,{selectedIds:new Set(a||s),tabbableId:t[0].children[0],isFocused:!1,expandedIds:new Set(r||l),halfSelectedIds:new Set,lastUserSelect:t[0].children[0],lastInteractedWith:null,disabledIds:new Set(c)}),2),C=j[0],D=j[1],_=C.selectedIds,K=C.expandedIds,P=C.disabledIds,G=C.tabbableId,M=C.halfSelectedIds,V=C.lastAction,X=C.lastInteractedWith,Y=v(_)||new Set,$=p(_,Y);n.useEffect((function(){if(null!=m&&m!==J){var e,a=o($);try{for(a.s();!(e=a.n()).done;){var n=e.value,r=I(t,n)||!!t[G].isBranch;m({element:t[n],isBranch:r,isExpanded:!!r&&K.has(n),isSelected:_.has(n),isDisabled:P.has(n),isHalfSelected:!!r&&M.has(n),treeState:C})}}catch(e){a.e(e)}finally{a.f()}}}),[t,_,K,P,M,$,m,C]);var Q=v(K)||new Set;n.useEffect((function(){var e=p(K,Q);if(null!=g&&g!==J){var a,n=o(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;g({element:t[r],isExpanded:K.has(r),isSelected:_.has(r),isDisabled:P.has(r),isHalfSelected:M.has(r),treeState:C})}}catch(e){n.e(e)}finally{n.f()}}}),[t,_,K,P,M,Q,g,C]);var Z,ee,te=(Z=t,ee=n.useRef(),n.useEffect((function(){ee.current=Z})),ee.current||new Set);return n.useEffect((function(){var e=p(K,Q);if(w){var a,n=o(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;w({element:t[r],isExpanded:K.has(r),isSelected:_.has(r),isDisabled:P.has(r),isHalfSelected:M.has(r),treeState:C})}}catch(e){n.e(e)}finally{n.f()}if(te!==t&&E&&x){var l,d=o(K);try{for(d.s();!(l=d.n()).done;){var i=l.value;_.has(i)&&D({type:z,ids:A(t,[i],P),select:!0,multiSelect:O,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,_,K,P,M,Q,w,C]),n.useEffect((function(){var e=new Set(a),n=h(e,Y),r=h(Y,e);if(r.size){var l,d=o(r);try{for(d.s();!(l=d.n()).done;){var i=l.value;D({type:F,id:i,multiSelect:O,controlled:!0,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}if(n.size){var s,c=o(n);try{for(c.s();!(s=c.n()).done;){var u=s.value;D({type:T,id:u,multiSelect:O,controlled:!0,lastInteractedWith:u}),x&&!P.has(u)&&D({type:z,ids:A(t,[u],P),select:!0,multiSelect:O,lastInteractedWith:u})}}catch(e){c.e(e)}finally{c.f()}}}),[a]),n.useEffect((function(){var e=new Set(r),a=h(e,Q),n=h(Q,e);if(n.size){var l,d=o(n);try{for(d.s();!(l=d.n()).done;){var s=l.value;if(I(t,s)||t[s].isBranch){var c=[s].concat(i(y(t,s,new Set)));D({type:L,ids:c,lastInteractedWith:s})}}}catch(e){d.e(e)}finally{d.f()}}if(a.size){var u,f=o(a);try{for(f.s();!(u=f.n()).done;){var p=u.value;if(I(t,p)||t[p].isBranch){var v=b(t,p);D(v?{type:U,ids:[p,v],lastInteractedWith:p}:{type:N,id:p,lastInteractedWith:p})}}}catch(e){f.e(e)}finally{f.f()}}}),[r]),n.useEffect((function(){if(W){var e=new Set($);X&&V!==H&&V!==k&&V!==N&&V!==B&&e.add(X);var a,n=function(e,t,a,n,r,l){var d,i={every:new Set,some:new Set,none:new Set},s=o(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var u=b(e,c);if(0===u||null==u||null!=u&&n.has(u))break;var f=e[u].children.filter((function(e){return!n.has(e)}));if(0===f.length)break;if(f.some((function(e){return a.has(e)||i.some.has(e)||r.has(e)})))f.every((function(e){return a.has(e)}))?i.every.add(u):i.some.add(u);else{var h=S(e,c,n).find((function(e){return a.has(e)}));if(!l&&h){y(e,h,n).forEach((function(e){r.has(e)&&i.none.add(e)}));break}i.none.add(u)}c=u}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,_,P,M,O),r=n.every,l=n.some,d=n.none,i=o(r);try{for(i.s();!(a=i.n()).done;){var s=a.value;_.has(s)||D({type:T,id:s,multiSelect:O,keepFocus:!0,NotUserAction:!0,lastInteractedWith:X})}}catch(e){i.e(e)}finally{i.f()}var c,u=o(l);try{for(u.s();!(c=u.n()).done;){var f=c.value;M.has(f)||D({type:R,id:f,lastInteractedWith:X})}}catch(e){u.e(e)}finally{u.f()}var h,p=o(d);try{for(p.s();!(h=p.n()).done;){var v=h.value;(_.has(v)||M.has(v))&&D({type:F,id:v,multiSelect:O,keepFocus:!0,NotUserAction:!0,lastInteractedWith:X})}}catch(e){p.e(e)}finally{p.f()}}}),[t,O,W,_,K,P,M,V,Y,$,X]),n.useEffect((function(){if(null!=X&&null!=G&&null!=(null==u?void 0:u.current)&&null!=(null==f?void 0:f.current)){var e=u.current[G];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(f.current[X]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[G,u,f,X]),[C,D]},X={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},Y=Object.freeze(Object.values(X)),$=Object.freeze(Object.values({check:"check",select:"select"})),J=function(){},Q=r.forwardRef((function(e,a){var l=e.data,i=e.selectedIds,s=e.nodeRenderer,c=e.onSelect,o=void 0===c?J:c,f=e.onExpand,h=void 0===f?J:f,p=e.onLoadData,v=e.className,I=void 0===v?"":v,b=e.multiSelect,S=void 0!==b&&b,y=e.propagateSelect,m=void 0!==y&&y,g=e.propagateSelectUpwards,w=void 0!==g&&g,E=e.propagateCollapse,O=void 0!==E&&E,x=e.expandOnKeyboardSelect,W=void 0!==x&&x,A=e.togglableSelect,C=void 0!==A&&A,k=e.defaultExpandedIds,L=void 0===k?[]:k,N=e.defaultSelectedIds,U=void 0===N?[]:N,R=e.defaultDisabledIds,T=void 0===R?[]:R,F=e.clickAction,B=void 0===F?X.select:F,_=e.nodeAction,z=void 0===_?"select":_,K=e.expandedIds,H=e.onBlur,G=u(e,["data","selectedIds","nodeRenderer","onSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]),M=n.useRef({}),q=n.useRef({}),Y=d(V({data:l,controlledIds:i,controlledExpandedIds:K,defaultExpandedIds:L,defaultSelectedIds:U,defaultDisabledIds:T,nodeRefs:M,leafRefs:q,onSelect:o,onExpand:h,onLoadData:p,togglableSelect:C,multiSelect:S,propagateSelect:m,propagateSelectUpwards:w}),2),$=Y[0],Q=Y[1];m=m&&S;var ee=n.useRef(null);return null!=a&&(ee=a),r.createElement("ul",Object.assign({className:t(D.root,I),role:"tree","aria-multiselectable":"select"===z?S:void 0,ref:ee,onBlur:function(e){j(e,ee.current,(function(){H&&H({treeState:$,dispatch:Q}),Q({type:P})}))},onKeyDown:ae({data:l,tabbableId:$.tabbableId,expandedIds:$.expandedIds,selectedIds:$.selectedIds,disabledIds:$.disabledIds,halfSelectedIds:$.halfSelectedIds,clickAction:B,dispatch:Q,propagateCollapse:O,propagateSelect:m,multiSelect:S,expandOnKeyboardSelect:W,togglableSelect:C})},G),l[0].children.map((function(e,t){return r.createElement(Z,Object.assign({key:e,data:l,element:l[e],setsize:l[0].children.length,posinset:t+1,level:1},$,{state:$,dispatch:Q,nodeRefs:M,leafRefs:q,baseClassNames:D,nodeRenderer:s,propagateCollapse:O,propagateSelect:m,propagateSelectUpwards:w,multiSelect:S,togglableSelect:C,clickAction:B,nodeAction:z}))})))})),Z=function(e){var a=e.element,n=e.dispatch,d=e.data,s=e.selectedIds,c=e.tabbableId,o=e.isFocused,u=e.expandedIds,h=e.disabledIds,p=e.halfSelectedIds,v=e.lastUserSelect,b=e.nodeRefs,S=e.leafRefs,m=e.baseClassNames,g=e.nodeRenderer,w=e.nodeAction,E=e.setsize,j=e.posinset,D=e.level,k=e.propagateCollapse,N=e.propagateSelect,U=e.multiSelect,F=e.togglableSelect,P=e.clickAction,G=e.state,M=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(a.id)&&k){var t=[a.id].concat(i(y(d,a.id,new Set)));n({type:L,ids:t,lastInteractedWith:a.id})}else n({type:B,id:a.id,lastInteractedWith:a.id})},q=function(){return n({type:H,id:a.id,lastInteractedWith:a.id})},V=function(e){if(e.shiftKey){var t=O({data:d,expandedIds:u,from:v,to:a.id}).filter((function(e){return!h.has(e)}));t=N?A(d,t,h):t,n({type:K,select:!0,multiSelect:U,ids:t,lastInteractedWith:a.id})}else if(e.ctrlKey||P===X.select){var r=C(d,a.id,s);n({type:F?r?R:_:T,id:a.id,multiSelect:U,lastInteractedWith:a.id}),N&&!h.has(a.id)&&n({type:z,ids:A(d,[a.id],h),select:!F||!s.has(a.id),multiSelect:U,lastInteractedWith:a.id})}else P===X.exclusiveSelect?n({type:F?_:T,id:a.id,multiSelect:!1,lastInteractedWith:a.id}):P===X.focus&&n({type:H,id:a.id,lastInteractedWith:a.id})},Y=function(e){var n;return t(e,(l(n={},"".concat(e,"--expanded"),u.has(a.id)),l(n,"".concat(e,"--selected"),s.has(a.id)),l(n,"".concat(e,"--focused"),c===a.id&&o),n))},$="select"===w?{"aria-selected":x({isSelected:s.has(a.id),isDisabled:h.has(a.id),multiSelect:U})}:{"aria-checked":W({isSelected:s.has(a.id),isDisabled:h.has(a.id),isHalfSelected:p.has(a.id),multiSelect:U})};return I(d,a.id)||a.isBranch?r.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(a.id),"aria-setsize":E,"aria-posinset":j,"aria-level":D,"aria-disabled":h.has(a.id),tabIndex:c===a.id?0:-1,ref:function(e){null!=(null==b?void 0:b.current)&&null!=e&&(b.current[a.id]=e)},className:m.branchWrapper},$),r.createElement(r.Fragment,null,g({element:a,isBranch:!0,isSelected:s.has(a.id),isHalfSelected:p.has(a.id),isExpanded:u.has(a.id),isDisabled:h.has(a.id),dispatch:n,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onClick;return{onClick:null==n?f(V,M,q):f(n,q),className:t(Y(m.node),m.branch),ref:function(e){null!=(null==S?void 0:S.current)&&(S.current[a.id]=e)}}},setsize:E,posinset:j,level:D,handleSelect:V,handleExpand:M,treeState:G}),r.createElement(te,Object.assign({getClasses:Y},ee(e))))):r.createElement("li",{role:"none",className:Y(m.leafListItem)},g({element:a,isBranch:!1,isSelected:s.has(a.id),isHalfSelected:!1,isExpanded:!1,isDisabled:h.has(a.id),dispatch:n,getNodeProps:function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},n=e.onClick;return Object.assign({role:"treeitem",tabIndex:c===a.id?0:-1,onClick:f(null==n?V:n,q),ref:function(e){null!=(null==b?void 0:b.current)&&null!=(null==S?void 0:S.current)&&(b.current[a.id]=e,S.current[a.id]=e)},className:t(Y(m.node),m.leaf),"aria-setsize":E,"aria-posinset":j,"aria-level":D,disabled:h.has(a.id),"aria-disabled":h.has(a.id)},$)},setsize:E,posinset:j,level:D,handleSelect:V,handleExpand:J,treeState:G}))},ee=function(e){e.setsize,e.posinset;return u(e,["setsize","posinset"])},te=function(e){var t=e.data,a=e.element,n=e.expandedIds,l=e.getClasses,d=e.baseClassNames,i=e.level,s=u(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return r.createElement("ul",{role:"group",className:l(d.nodeGroup)},n.has(a.id)&&a.children.length>0&&a.children.map((function(e,l){return r.createElement(Z,Object.assign({data:t,expandedIds:n,baseClassNames:d,key:e,element:t[e],setsize:a.children.length,posinset:l+1,level:i+1},s))})))},ae=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,r=e.disabledIds,l=e.tabbableId,d=e.dispatch,s=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=t[l],v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var S=t.filter((function(e){return 0!==e.id})),m=Object.values(S).map((function(e){return e.id})).filter((function(e){return!r.has(e)}));d({type:z,multiSelect:o,select:Array.from(n).filter((function(e){return!r.has(e)})).length!==m.length,ids:m,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var x="Home"===e.key?t[0].children[0]:g(t,v,a),W=O({data:t,expandedIds:a,from:v,to:x}).filter((function(e){return!r.has(e)}));d({type:z,multiSelect:o,select:!0,ids:c?A(t,W,r):W}),d({type:H,id:x,lastInteractedWith:x})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var j=w(t,v,a);return void(null==j||r.has(j)||(d({type:z,ids:c?A(t,[j],r):[j],select:!0,multiSelect:o,lastInteractedWith:j}),d({type:H,id:j,lastInteractedWith:j})));case"ArrowDown":e.preventDefault();var D=E(t,v,a);return void(null==D||r.has(D)||(d({type:z,ids:c?A(t,[D],r):[D],multiSelect:o,select:!0,lastInteractedWith:D}),d({type:H,id:D,lastInteractedWith:D})))}switch(e.key){case"ArrowDown":e.preventDefault();var F=E(t,v,a);return void(null!=F&&d({type:H,id:F,lastInteractedWith:F}));case"ArrowUp":e.preventDefault();var K=w(t,v,a);return void(null!=K&&d({type:H,id:K,lastInteractedWith:K}));case"ArrowLeft":if(e.preventDefault(),(I(t,v)||p.isBranch)&&a.has(l))if(s){var P=[v].concat(i(y(t,v,new Set)));d({type:L,ids:P,lastInteractedWith:p.id})}else d({type:k,id:v,lastInteractedWith:v});else if(!t[0].children.includes(v)){var G=b(t,v);if(null==G)throw new Error("parentId of root element is null");d({type:H,id:G,lastInteractedWith:G})}return;case"ArrowRight":return e.preventDefault(),void((I(t,v)||p.isBranch)&&(a.has(l)?d({type:H,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:N,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),d({type:H,id:t[0].children[0],lastInteractedWith:t[0].children[0]});break;case"End":e.preventDefault();var M=g(t,t[0].id,a);return void d({type:H,id:M,lastInteractedWith:M});case"*":e.preventDefault();var q=b(t,v);if(null==q)throw new Error("parentId of element is null");var V=t[q].children.filter((function(e){return I(t,e)||t[e].isBranch}));return void d({type:U,ids:V,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===X.focus)return;var Y=C(t,p.id,n);return d({type:f?Y?R:_:T,id:v,multiSelect:o,lastInteractedWith:v}),c&&!r.has(p.id)&&d({type:z,ids:A(t,[v],r),select:!f||!n.has(v),multiSelect:o,lastInteractedWith:v}),void(u&&d({type:B,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var $=E(t,v,a);$!==v;)if(null!=$){if(t[$].name[0].toLowerCase()===e.key.toLowerCase())return void d({type:H,id:$,lastInteractedWith:v});$=E(t,$,a)}else $=t[0].children[0];return}}}};Q.propTypes={data:a.array.isRequired,onSelect:a.func,onExpand:a.func,className:a.string,nodeRenderer:a.func.isRequired,defaultExpandedIds:a.array,defaultSelectedIds:a.array,expandedIds:a.array,selectedIds:a.array,defaultDisabledIds:a.array,propagateCollapse:a.bool,propagateSelect:a.bool,propagateSelectUpwards:a.bool,multiSelect:a.bool,expandOnKeyboardSelect:a.bool,togglableSelect:a.bool,nodeAction:a.oneOf($),clickAction:a.oneOf(Y),onBlur:a.func,onLoadData:a.func},exports.CLICK_ACTIONS=Y,exports.default=Q,exports.flattenTree=function(e){var t=0,a=[];return function e(n,r){var l={id:t,name:n.name,children:[],parent:r};if(a[t]=l,t+=1,null!=n.children&&0!==n.children.length){var d,i=o(n.children);try{for(i.s();!(d=i.n()).done;){e(d.value,l.id)}}catch(e){i.e(e)}finally{i.f()}l.children=a.filter((function(e){return e.parent===l.id})).map((function(e){return e.id}))}}(e,null),a}; |
@@ -1,1 +0,1 @@ | ||
import e from"classnames";import t from"prop-types";import a,{useRef as n,useEffect as r,useReducer as l}from"react";function d(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,r,l=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);d=!0);}catch(e){i=!0,r=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw r}}return l}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return o(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function u(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=c(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,d=!0,i=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return d=e.done,e},e:function(e){i=!0,l=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw l}}}}function f(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]])}return a}var h=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){var a,n=u(t);try{for(n.s();!(a=n.n()).done;){var r=a.value;if(r&&r(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},p=function(e,t){var a,n=new Set,r=u(e);try{for(r.s();!(a=r.n()).done;){var l=a.value;t.has(l)||n.add(l)}}catch(e){r.e(e)}finally{r.f()}return n},v=function(e,t){return new Set([].concat(s(p(e,t)),s(p(t,e))))},I=function(e){var t=n();return r((function(){t.current=e}),[e]),t.current},b=function(e,t){return null!=e[t].children&&e[t].children.length>0},S=function(e,t){return e[t].parent},y=function(e,t,a){for(var n=t,r=[];;){var l=S(e,n);if(0===l||null==l||null!=l&&a.has(l))break;r.push(l),n=l}return r},m=function(e,t,a){var n=[];return function e(t,r){var l=t[r];if(null!=l.children){var d,i=u(l.children.filter((function(e){return!a.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;n.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),n},g=function(e,t,a){var n=S(e,t);if(null!=n){var r=e[n],l=r.children.indexOf(t)+a;if(r.children[l])return r.children[l]}return null},w=function(e,t,a){var n=e[t];for(e[0].id===t&&(n=e[e[t].children[e[t].children.length-1]]);a.has(n.id)&&b(e,n.id);)n=e[n.children[n.children.length-1]];return n.id},E=function(e,t,a){if(t===e[0].children[0])return null;var n=g(e,t,-1);return null==n?S(e,t):w(e,n,a)},O=function(e,t,a){var n=e[t].id;if(b(e,n)&&a.has(n))return e[n].children[0];for(;;){var r=g(e,n,1);if(null!=r)return r;if(null==(n=S(e,n)))return null}},W=function(e){var t=e.data,a=e.expandedIds,n=e.from,r=e.to,l=[],d=Object.keys(t).length,i=0,s=n;if(l.push(n),n<r)for(;i<d&&(null!=(s=O(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;else if(n>r)for(;i<d&&(null!=(s=E(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;return l},x=function(e){var t=0,a=[];return function e(n,r){var l={id:t,name:n.name,children:[],parent:r};if(a[t]=l,t+=1,null!=n.children&&0!==n.children.length){var d,i=u(n.children);try{for(i.s();!(d=i.n()).done;){e(d.value,l.id)}}catch(e){i.e(e)}finally{i.f()}l.children=a.filter((function(e){return e.parent===l.id})).map((function(e){return e.id}))}}(e,null),a},A=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},j=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,r=e.multiSelect;return a?t:n?"mixed":r?t:!!t||void 0},C=function(e,t,a){return t.concat.apply(t,s(t.filter((function(t){return b(e,t)})).map((function(t){return m(e,t,a)}))))},D=function(e,t,a){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&a()}),0):!t.contains(e.nativeEvent.relatedTarget)&&a():console.warn("ref not set on <ul>")},k=function(e,t,a){return b(e,t)&&a.has(t)&&m(e,t,new Set).some((function(e){return a.has(e)}))},L={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},N="COLLAPSE",U="COLLAPSE_MANY",F="EXPAND",R="EXPAND_MANY",B="HALF_SELECT",T="SELECT",z="DESELECT",K="TOGGLE",_="TOGGLE_SELECT",H="SELECT_MANY",P="EXCLUSIVE_CHANGE_SELECT_MANY",G="FOCUS",M="BLUR",V="DISABLE",X="ENABLE",Y=function(e,t){switch(t.type){case N:var a=new Set(e.expandedIds);return a.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:a,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case U:var n,r=new Set(e.expandedIds),l=u(t.ids);try{for(l.s();!(n=l.n()).done;){var d=n.value;r.delete(d)}}catch(e){l.e(e)}finally{l.f()}return Object.assign(Object.assign({},e),{expandedIds:r,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case F:var i=new Set(e.expandedIds);return i.add(t.id),Object.assign(Object.assign({},e),{expandedIds:i,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R:var c=new Set([].concat(s(e.expandedIds),s(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case K:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return f.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:f,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case T:if(!t.controlled&&e.disabledIds.has(t.id))return e;var v;t.multiSelect?(v=new Set(e.selectedIds)).add(t.id):(v=new Set).add(t.id);var I=new Set(e.halfSelectedIds);return I.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:v,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:if(!t.controlled&&e.disabledIds.has(t.id))return e;var b,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(b=new Set(e.halfSelectedIds)).delete(t.id):b=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case _:if(e.disabledIds.has(t.id))return e;var y,m=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),m?y.delete(t.id):y.add(t.id)):(y=new Set,m||y.add(t.id));var g=new Set(e.halfSelectedIds);return g.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:g,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case H:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(s(e.selectedIds),s(E))):p(e.selectedIds,new Set(E));var O=p(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case P:var W,x=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){W=t.select?new Set(x):p(e.selectedIds,new Set(x));var A=p(e.halfSelectedIds,W);return Object.assign(Object.assign({},e),{selectedIds:W,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case G:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case M:return Object.assign(Object.assign({},e),{isFocused:!1});case V:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case X:var C=new Set(e.disabledIds);return C.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:C});default:throw new Error("Invalid action passed to the reducer")}},q=function(e){var t=e.data,a=e.controlledIds,d=e.controlledExpandedIds,c=e.defaultExpandedIds,o=e.defaultSelectedIds,f=e.defaultDisabledIds,h=e.nodeRefs,g=e.leafRefs,w=e.onSelect,E=e.onExpand,O=e.onLoadData,W=e.togglableSelect,x=e.multiSelect,A=e.propagateSelect,j=e.propagateSelectUpwards,D=i(l(Y,{selectedIds:new Set(a||o),tabbableId:t[0].children[0],isFocused:!1,expandedIds:new Set(d||c),halfSelectedIds:new Set,lastUserSelect:t[0].children[0],lastInteractedWith:null,disabledIds:new Set(f)}),2),k=D[0],L=D[1],_=k.selectedIds,P=k.expandedIds,M=k.disabledIds,V=k.tabbableId,X=k.halfSelectedIds,q=k.lastAction,$=k.lastInteractedWith,J=I(_)||new Set,Q=v(_,J);r((function(){if(null!=w&&w!==Z){var e,a=u(Q);try{for(a.s();!(e=a.n()).done;){var n=e.value,r=b(t,n)||!!t[V].isBranch;w({element:t[n],isBranch:r,isExpanded:!!r&&P.has(n),isSelected:_.has(n),isDisabled:M.has(n),isHalfSelected:!!r&&X.has(n),treeState:k})}}catch(e){a.e(e)}finally{a.f()}}}),[t,_,P,M,X,Q,w,k]);var ee=I(P)||new Set;r((function(){var e=v(P,ee);if(null!=E&&E!==Z){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;E({element:t[r],isExpanded:P.has(r),isSelected:_.has(r),isDisabled:M.has(r),isHalfSelected:X.has(r),treeState:k})}}catch(e){n.e(e)}finally{n.f()}}}),[t,_,P,M,X,ee,E,k]);var te,ae,ne=(te=t,ae=n(),r((function(){ae.current=te})),ae.current||new Set);return r((function(){var e=v(P,ee);if(O){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;O({element:t[r],isExpanded:P.has(r),isSelected:_.has(r),isDisabled:M.has(r),isHalfSelected:X.has(r),treeState:k})}}catch(e){n.e(e)}finally{n.f()}if(ne!==t&&W&&A){var l,d=u(P);try{for(d.s();!(l=d.n()).done;){var i=l.value;_.has(i)&&L({type:H,ids:C(t,[i],M),select:!0,multiSelect:x,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,_,P,M,X,ee,O,k]),r((function(){var e=new Set(a),n=p(e,J),r=p(J,e);if(r.size){var l,d=u(r);try{for(d.s();!(l=d.n()).done;){var i=l.value;L({type:z,id:i,multiSelect:x,controlled:!0,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}if(n.size){var s,c=u(n);try{for(c.s();!(s=c.n()).done;){var o=s.value;L({type:T,id:o,multiSelect:x,controlled:!0,lastInteractedWith:o}),A&&!M.has(o)&&L({type:H,ids:C(t,[o],M),select:!0,multiSelect:x,lastInteractedWith:o})}}catch(e){c.e(e)}finally{c.f()}}}),[a]),r((function(){var e=new Set(d),a=p(e,ee),n=p(ee,e);if(n.size){var r,l=u(n);try{for(l.s();!(r=l.n()).done;){var i=r.value;if(b(t,i)||t[i].isBranch){var c=[i].concat(s(m(t,i,new Set)));L({type:U,ids:c,lastInteractedWith:i})}}}catch(e){l.e(e)}finally{l.f()}}if(a.size){var o,f=u(a);try{for(f.s();!(o=f.n()).done;){var h=o.value;if(b(t,h)||t[h].isBranch){var v=S(t,h);L(v?{type:R,ids:[h,v],lastInteractedWith:h}:{type:F,id:h,lastInteractedWith:h})}}}catch(e){f.e(e)}finally{f.f()}}}),[d]),r((function(){if(j){var e=new Set(Q);$&&q!==G&&q!==N&&q!==F&&q!==K&&e.add($);var a,n=function(e,t,a,n,r,l){var d,i={every:new Set,some:new Set,none:new Set},s=u(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var o=S(e,c);if(0===o||null==o||null!=o&&n.has(o))break;var f=e[o].children.filter((function(e){return!n.has(e)}));if(0===f.length)break;if(f.some((function(e){return a.has(e)||i.some.has(e)||r.has(e)})))f.every((function(e){return a.has(e)}))?i.every.add(o):i.some.add(o);else{var h=y(e,c,n).find((function(e){return a.has(e)}));if(!l&&h){m(e,h,n).forEach((function(e){r.has(e)&&i.none.add(e)}));break}i.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,_,M,X,x),r=n.every,l=n.some,d=n.none,i=u(r);try{for(i.s();!(a=i.n()).done;){var s=a.value;_.has(s)||L({type:T,id:s,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:$})}}catch(e){i.e(e)}finally{i.f()}var c,o=u(l);try{for(o.s();!(c=o.n()).done;){var f=c.value;X.has(f)||L({type:B,id:f,lastInteractedWith:$})}}catch(e){o.e(e)}finally{o.f()}var h,p=u(d);try{for(p.s();!(h=p.n()).done;){var v=h.value;(_.has(v)||X.has(v))&&L({type:z,id:v,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:$})}}catch(e){p.e(e)}finally{p.f()}}}),[t,x,j,_,P,M,X,q,J,Q,$]),r((function(){if(null!=$&&null!=V&&null!=(null==h?void 0:h.current)&&null!=(null==g?void 0:g.current)){var e=h.current[V];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(g.current[$]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[V,h,g,$]),[k,L]},$={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},J=Object.freeze(Object.values($)),Q=Object.freeze(Object.values({check:"check",select:"select"})),Z=function(){},ee=a.forwardRef((function(t,r){var l=t.data,d=t.selectedIds,s=t.nodeRenderer,c=t.onSelect,o=void 0===c?Z:c,u=t.onExpand,h=void 0===u?Z:u,p=t.onLoadData,v=t.className,I=void 0===v?"":v,b=t.multiSelect,S=void 0!==b&&b,y=t.propagateSelect,m=void 0!==y&&y,g=t.propagateSelectUpwards,w=void 0!==g&&g,E=t.propagateCollapse,O=void 0!==E&&E,W=t.expandOnKeyboardSelect,x=void 0!==W&&W,A=t.togglableSelect,j=void 0!==A&&A,C=t.defaultExpandedIds,k=void 0===C?[]:C,N=t.defaultSelectedIds,U=void 0===N?[]:N,F=t.defaultDisabledIds,R=void 0===F?[]:F,B=t.clickAction,T=void 0===B?$.select:B,z=t.nodeAction,K=void 0===z?"select":z,_=t.expandedIds,H=t.onBlur,P=f(t,["data","selectedIds","nodeRenderer","onSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]),G=n({}),V=n({}),X=i(q({data:l,controlledIds:d,controlledExpandedIds:_,defaultExpandedIds:k,defaultSelectedIds:U,defaultDisabledIds:R,nodeRefs:G,leafRefs:V,onSelect:o,onExpand:h,onLoadData:p,togglableSelect:j,multiSelect:S,propagateSelect:m,propagateSelectUpwards:w}),2),Y=X[0],J=X[1];m=m&&S;var Q=n(null);return null!=r&&(Q=r),a.createElement("ul",Object.assign({className:e(L.root,I),role:"tree","aria-multiselectable":"select"===K?S:void 0,ref:Q,onBlur:function(e){D(e,Q.current,(function(){H&&H({treeState:Y,dispatch:J}),J({type:M})}))},onKeyDown:re({data:l,tabbableId:Y.tabbableId,expandedIds:Y.expandedIds,selectedIds:Y.selectedIds,disabledIds:Y.disabledIds,halfSelectedIds:Y.halfSelectedIds,dispatch:J,propagateCollapse:O,propagateSelect:m,multiSelect:S,expandOnKeyboardSelect:x,togglableSelect:j})},P),l[0].children.map((function(e,t){return a.createElement(te,Object.assign({key:e,data:l,element:l[e],setsize:l[0].children.length,posinset:t+1,level:1},Y,{state:Y,dispatch:J,nodeRefs:G,leafRefs:V,baseClassNames:L,nodeRenderer:s,propagateCollapse:O,propagateSelect:m,propagateSelectUpwards:w,multiSelect:S,togglableSelect:j,clickAction:T,nodeAction:K}))})))})),te=function(t){var n=t.element,r=t.dispatch,l=t.data,i=t.selectedIds,c=t.tabbableId,o=t.isFocused,u=t.expandedIds,f=t.disabledIds,p=t.halfSelectedIds,v=t.lastUserSelect,I=t.nodeRefs,S=t.leafRefs,y=t.baseClassNames,g=t.nodeRenderer,w=t.nodeAction,E=t.setsize,O=t.posinset,x=t.level,D=t.propagateCollapse,L=t.propagateSelect,N=t.multiSelect,F=t.togglableSelect,R=t.clickAction,z=t.state,M=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(n.id)&&D){var t=[n.id].concat(s(m(l,n.id,new Set)));r({type:U,ids:t,lastInteractedWith:n.id})}else r({type:K,id:n.id,lastInteractedWith:n.id})},V=function(){return r({type:G,id:n.id,lastInteractedWith:n.id})},X=function(e){if(e.shiftKey){var t=W({data:l,expandedIds:u,from:v,to:n.id}).filter((function(e){return!f.has(e)}));t=L?C(l,t,f):t,r({type:P,select:!0,multiSelect:N,ids:t,lastInteractedWith:n.id})}else if(e.ctrlKey||$.select){var a=k(l,n.id,i);r({type:F?a?B:_:T,id:n.id,multiSelect:N,lastInteractedWith:n.id}),L&&!f.has(n.id)&&r({type:H,ids:C(l,[n.id],f),select:!F||!i.has(n.id),multiSelect:N,lastInteractedWith:n.id})}else R===$.exclusiveSelect?r({type:F?_:T,id:n.id,multiSelect:!1,lastInteractedWith:n.id}):R===$.focus&&r({type:G,id:n.id,lastInteractedWith:n.id})},Y=function(t){var a;return e(t,(d(a={},"".concat(t,"--expanded"),u.has(n.id)),d(a,"".concat(t,"--selected"),i.has(n.id)),d(a,"".concat(t,"--focused"),c===n.id&&o),a))},q="select"===w?{"aria-selected":A({isSelected:i.has(n.id),isDisabled:f.has(n.id),multiSelect:N})}:{"aria-checked":j({isSelected:i.has(n.id),isDisabled:f.has(n.id),isHalfSelected:p.has(n.id),multiSelect:N})};return b(l,n.id)||n.isBranch?a.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(n.id),"aria-setsize":E,"aria-posinset":O,"aria-level":x,"aria-disabled":f.has(n.id),tabIndex:c===n.id?0:-1,ref:function(e){null!=(null==I?void 0:I.current)&&null!=e&&(I.current[n.id]=e)},className:y.branchWrapper},q),a.createElement(a.Fragment,null,g({element:n,isBranch:!0,isSelected:i.has(n.id),isHalfSelected:p.has(n.id),isExpanded:u.has(n.id),isDisabled:f.has(n.id),dispatch:r,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return{onClick:null==a?h(X,M,V):h(a,V),className:e(Y(y.node),y.branch),ref:function(e){null!=(null==S?void 0:S.current)&&(S.current[n.id]=e)}}},setsize:E,posinset:O,level:x,handleSelect:X,handleExpand:M,treeState:z}),a.createElement(ne,Object.assign({getClasses:Y},ae(t))))):a.createElement("li",{role:"none",className:Y(y.leafListItem)},g({element:n,isBranch:!1,isSelected:i.has(n.id),isHalfSelected:!1,isExpanded:!1,isDisabled:f.has(n.id),dispatch:r,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return Object.assign({role:"treeitem",tabIndex:c===n.id?0:-1,onClick:h(null==a?X:a,V),ref:function(e){null!=(null==I?void 0:I.current)&&null!=(null==S?void 0:S.current)&&(I.current[n.id]=e,S.current[n.id]=e)},className:e(Y(y.node),y.leaf),"aria-setsize":E,"aria-posinset":O,"aria-level":x,disabled:f.has(n.id),"aria-disabled":f.has(n.id)},q)},setsize:E,posinset:O,level:x,handleSelect:X,handleExpand:Z,treeState:z}))},ae=function(e){e.setsize,e.posinset;return f(e,["setsize","posinset"])},ne=function(e){var t=e.data,n=e.element,r=e.expandedIds,l=e.getClasses,d=e.baseClassNames,i=e.level,s=f(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return a.createElement("ul",{role:"group",className:l(d.nodeGroup)},r.has(n.id)&&n.children.length>0&&n.children.map((function(e,l){return a.createElement(te,Object.assign({data:t,expandedIds:r,baseClassNames:d,key:e,element:t[e],setsize:n.children.length,posinset:l+1,level:i+1},s))})))},re=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,r=e.disabledIds,l=e.tabbableId,d=e.dispatch,i=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect;return function(e){var h=t[l],p=h.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var v=t.filter((function(e){return 0!==e.id})),I=Object.values(v).map((function(e){return e.id})).filter((function(e){return!r.has(e)}));d({type:H,multiSelect:o,select:Array.from(n).filter((function(e){return!r.has(e)})).length!==I.length,ids:I,lastInteractedWith:h.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var y="Home"===e.key?t[0].children[0]:w(t,p,a),g=W({data:t,expandedIds:a,from:p,to:y}).filter((function(e){return!r.has(e)}));d({type:H,multiSelect:o,select:!0,ids:c?C(t,g,r):g}),d({type:G,id:y,lastInteractedWith:y})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var x=E(t,p,a);return void(null==x||r.has(x)||(d({type:H,ids:c?C(t,[x],r):[x],select:!0,multiSelect:o,lastInteractedWith:x}),d({type:G,id:x,lastInteractedWith:x})));case"ArrowDown":e.preventDefault();var A=O(t,p,a);return void(null==A||r.has(A)||(d({type:H,ids:c?C(t,[A],r):[A],multiSelect:o,select:!0,lastInteractedWith:A}),d({type:G,id:A,lastInteractedWith:A})))}switch(e.key){case"ArrowDown":e.preventDefault();var j=O(t,p,a);return void(null!=j&&d({type:G,id:j,lastInteractedWith:j}));case"ArrowUp":e.preventDefault();var D=E(t,p,a);return void(null!=D&&d({type:G,id:D,lastInteractedWith:D}));case"ArrowLeft":if(e.preventDefault(),(b(t,p)||h.isBranch)&&a.has(l))if(i){var L=[p].concat(s(m(t,p,new Set)));d({type:U,ids:L,lastInteractedWith:h.id})}else d({type:N,id:p,lastInteractedWith:p});else if(!t[0].children.includes(p)){var z=S(t,p);if(null==z)throw new Error("parentId of root element is null");d({type:G,id:z,lastInteractedWith:z})}return;case"ArrowRight":return e.preventDefault(),void((b(t,p)||h.isBranch)&&(a.has(l)?d({type:G,id:h.children[0],lastInteractedWith:h.children[0]}):d({type:F,id:p,lastInteractedWith:p})));case"Home":e.preventDefault(),d({type:G,id:t[0].children[0],lastInteractedWith:t[0].children[0]});break;case"End":e.preventDefault();var P=w(t,t[0].id,a);return void d({type:G,id:P,lastInteractedWith:P});case"*":e.preventDefault();var M=S(t,p);if(null==M)throw new Error("parentId of element is null");var V=t[M].children.filter((function(e){return b(t,e)||t[e].isBranch}));return void d({type:R,ids:V,lastInteractedWith:p});case"Enter":case" ":case"Spacebar":e.preventDefault();var X=k(t,h.id,n);return d({type:f?X?B:_:T,id:p,multiSelect:o,lastInteractedWith:p}),c&&!r.has(h.id)&&d({type:H,ids:C(t,[p],r),select:!f||!n.has(p),multiSelect:o,lastInteractedWith:p}),void(u&&d({type:K,id:p,lastInteractedWith:p}));default:if(1===e.key.length)for(var Y=O(t,p,a);Y!==p;)if(null!=Y){if(t[Y].name[0].toLowerCase()===e.key.toLowerCase())return void d({type:G,id:Y,lastInteractedWith:p});Y=O(t,Y,a)}else Y=t[0].children[0];return}}}};ee.propTypes={data:t.array.isRequired,onSelect:t.func,onExpand:t.func,className:t.string,nodeRenderer:t.func.isRequired,defaultExpandedIds:t.array,defaultSelectedIds:t.array,expandedIds:t.array,selectedIds:t.array,defaultDisabledIds:t.array,propagateCollapse:t.bool,propagateSelect:t.bool,propagateSelectUpwards:t.bool,multiSelect:t.bool,expandOnKeyboardSelect:t.bool,togglableSelect:t.bool,nodeAction:t.oneOf(Q),clickAction:t.oneOf(J),onBlur:t.func,onLoadData:t.func};export default ee;export{J as CLICK_ACTIONS,x as flattenTree}; | ||
import e from"classnames";import t from"prop-types";import a,{useRef as n,useEffect as r,useReducer as l}from"react";function d(e,t,a){return t in e?Object.defineProperty(e,t,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[t]=a,e}function i(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var a=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==a)return;var n,r,l=[],d=!0,i=!1;try{for(a=a.call(e);!(d=(n=a.next()).done)&&(l.push(n.value),!t||l.length!==t);d=!0);}catch(e){i=!0,r=e}finally{try{d||null==a.return||a.return()}finally{if(i)throw r}}return l}(e,t)||c(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function s(e){return function(e){if(Array.isArray(e))return o(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||c(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e,t){if(e){if("string"==typeof e)return o(e,t);var a=Object.prototype.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?o(e,t):void 0}}function o(e,t){(null==t||t>e.length)&&(t=e.length);for(var a=0,n=new Array(t);a<t;a++)n[a]=e[a];return n}function u(e,t){var a="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(!a){if(Array.isArray(e)||(a=c(e))||t&&e&&"number"==typeof e.length){a&&(e=a);var n=0,r=function(){};return{s:r,n:function(){return n>=e.length?{done:!0}:{done:!1,value:e[n++]}},e:function(e){throw e},f:r}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var l,d=!0,i=!1;return{s:function(){a=a.call(e)},n:function(){var e=a.next();return d=e.done,e},e:function(e){i=!0,l=e},f:function(){try{d||null==a.return||a.return()}finally{if(i)throw l}}}}function f(e,t){var a={};for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&t.indexOf(n)<0&&(a[n]=e[n]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(n=Object.getOwnPropertySymbols(e);r<n.length;r++)t.indexOf(n[r])<0&&Object.prototype.propertyIsEnumerable.call(e,n[r])&&(a[n[r]]=e[n[r]])}return a}var h=function(){for(var e=arguments.length,t=new Array(e),a=0;a<e;a++)t[a]=arguments[a];return function(e){var a,n=u(t);try{for(n.s();!(a=n.n()).done;){var r=a.value;if(r&&r(e),e.defaultPrevented)break}}catch(e){n.e(e)}finally{n.f()}}},p=function(e,t){var a,n=new Set,r=u(e);try{for(r.s();!(a=r.n()).done;){var l=a.value;t.has(l)||n.add(l)}}catch(e){r.e(e)}finally{r.f()}return n},v=function(e,t){return new Set([].concat(s(p(e,t)),s(p(t,e))))},I=function(e){var t=n();return r((function(){t.current=e}),[e]),t.current},b=function(e,t){return null!=e[t].children&&e[t].children.length>0},S=function(e,t){return e[t].parent},y=function(e,t,a){for(var n=t,r=[];;){var l=S(e,n);if(0===l||null==l||null!=l&&a.has(l))break;r.push(l),n=l}return r},m=function(e,t,a){var n=[];return function e(t,r){var l=t[r];if(null!=l.children){var d,i=u(l.children.filter((function(e){return!a.has(e)})));try{for(i.s();!(d=i.n()).done;){var s=d.value;n.push(s),e(t,s)}}catch(e){i.e(e)}finally{i.f()}}}(e,t),n},g=function(e,t,a){var n=S(e,t);if(null!=n){var r=e[n],l=r.children.indexOf(t)+a;if(r.children[l])return r.children[l]}return null},w=function(e,t,a){var n=e[t];for(e[0].id===t&&(n=e[e[t].children[e[t].children.length-1]]);a.has(n.id)&&b(e,n.id);)n=e[n.children[n.children.length-1]];return n.id},E=function(e,t,a){if(t===e[0].children[0])return null;var n=g(e,t,-1);return null==n?S(e,t):w(e,n,a)},O=function(e,t,a){var n=e[t].id;if(b(e,n)&&a.has(n))return e[n].children[0];for(;;){var r=g(e,n,1);if(null!=r)return r;if(null==(n=S(e,n)))return null}},W=function(e){var t=e.data,a=e.expandedIds,n=e.from,r=e.to,l=[],d=Object.keys(t).length,i=0,s=n;if(l.push(n),n<r)for(;i<d&&(null!=(s=O(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;else if(n>r)for(;i<d&&(null!=(s=E(t,s,a))&&l.push(s),null!=s&&s!==r);)i+=1;return l},x=function(e){var t=0,a=[];return function e(n,r){var l={id:t,name:n.name,children:[],parent:r};if(a[t]=l,t+=1,null!=n.children&&0!==n.children.length){var d,i=u(n.children);try{for(i.s();!(d=i.n()).done;){e(d.value,l.id)}}catch(e){i.e(e)}finally{i.f()}l.children=a.filter((function(e){return e.parent===l.id})).map((function(e){return e.id}))}}(e,null),a},A=function(e){var t=e.isSelected,a=e.isDisabled,n=e.multiSelect;return a||n?t:!!t||void 0},j=function(e){var t=e.isSelected,a=e.isDisabled,n=e.isHalfSelected,r=e.multiSelect;return a?t:n?"mixed":r?t:!!t||void 0},C=function(e,t,a){return t.concat.apply(t,s(t.filter((function(t){return b(e,t)})).map((function(t){return m(e,t,a)}))))},D=function(e,t,a){null!=t?window.navigator.userAgent.match(/Trident/)?setTimeout((function(){return!t.contains(document.activeElement)&&a()}),0):!t.contains(e.nativeEvent.relatedTarget)&&a():console.warn("ref not set on <ul>")},k=function(e,t,a){return b(e,t)&&a.has(t)&&m(e,t,new Set).some((function(e){return a.has(e)}))},L={root:"tree",node:"tree-node",branch:"tree-node__branch",branchWrapper:"tree-branch-wrapper",leafListItem:"tree-leaf-list-item",leaf:"tree-node__leaf",nodeGroup:"tree-node-group"},N="COLLAPSE",U="COLLAPSE_MANY",F="EXPAND",R="EXPAND_MANY",B="HALF_SELECT",T="SELECT",z="DESELECT",K="TOGGLE",_="TOGGLE_SELECT",H="SELECT_MANY",P="EXCLUSIVE_CHANGE_SELECT_MANY",G="FOCUS",M="BLUR",V="DISABLE",X="ENABLE",Y=function(e,t){switch(t.type){case N:var a=new Set(e.expandedIds);return a.delete(t.id),Object.assign(Object.assign({},e),{expandedIds:a,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case U:var n,r=new Set(e.expandedIds),l=u(t.ids);try{for(l.s();!(n=l.n()).done;){var d=n.value;r.delete(d)}}catch(e){l.e(e)}finally{l.f()}return Object.assign(Object.assign({},e),{expandedIds:r,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case F:var i=new Set(e.expandedIds);return i.add(t.id),Object.assign(Object.assign({},e),{expandedIds:i,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case R:var c=new Set([].concat(s(e.expandedIds),s(t.ids)));return Object.assign(Object.assign({},e),{expandedIds:c,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case K:var o=new Set(e.expandedIds);return e.expandedIds.has(t.id)?o.delete(t.id):o.add(t.id),Object.assign(Object.assign({},e),{expandedIds:o,tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case B:if(e.disabledIds.has(t.id))return e;var f=new Set(e.halfSelectedIds),h=new Set(e.selectedIds);return f.add(t.id),h.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:h,halfSelectedIds:f,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case T:if(!t.controlled&&e.disabledIds.has(t.id))return e;var v;t.multiSelect?(v=new Set(e.selectedIds)).add(t.id):(v=new Set).add(t.id);var I=new Set(e.halfSelectedIds);return I.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:v,halfSelectedIds:I,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case z:if(!t.controlled&&e.disabledIds.has(t.id))return e;var b,S=new Set(e.selectedIds);return S.delete(t.id),t.multiSelect?(b=new Set(e.halfSelectedIds)).delete(t.id):b=new Set,Object.assign(Object.assign({},e),{selectedIds:S,halfSelectedIds:b,tabbableId:t.keepFocus?e.tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case _:if(e.disabledIds.has(t.id))return e;var y,m=e.selectedIds.has(t.id);t.multiSelect?(y=new Set(e.selectedIds),m?y.delete(t.id):y.add(t.id)):(y=new Set,m||y.add(t.id));var g=new Set(e.halfSelectedIds);return g.delete(t.id),Object.assign(Object.assign({},e),{selectedIds:y,halfSelectedIds:g,tabbableId:t.id,isFocused:!0,lastUserSelect:t.NotUserAction?e.lastUserSelect:t.id,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case H:var w,E=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){w=t.select?new Set([].concat(s(e.selectedIds),s(E))):p(e.selectedIds,new Set(E));var O=p(e.halfSelectedIds,w);return Object.assign(Object.assign({},e),{selectedIds:w,halfSelectedIds:O,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case P:var W,x=t.ids.filter((function(t){return!e.disabledIds.has(t)}));if(t.multiSelect){W=t.select?new Set(x):p(e.selectedIds,new Set(x));var A=p(e.halfSelectedIds,W);return Object.assign(Object.assign({},e),{selectedIds:W,halfSelectedIds:A,lastAction:t.type,lastInteractedWith:t.lastInteractedWith})}return e;case G:return Object.assign(Object.assign({},e),{tabbableId:t.id,isFocused:!0,lastAction:t.type,lastInteractedWith:t.lastInteractedWith});case M:return Object.assign(Object.assign({},e),{isFocused:!1});case V:var j=new Set(e.disabledIds);return j.add(t.id),Object.assign(Object.assign({},e),{disabledIds:j});case X:var C=new Set(e.disabledIds);return C.delete(t.id),Object.assign(Object.assign({},e),{disabledIds:C});default:throw new Error("Invalid action passed to the reducer")}},q=function(e){var t=e.data,a=e.controlledIds,d=e.controlledExpandedIds,c=e.defaultExpandedIds,o=e.defaultSelectedIds,f=e.defaultDisabledIds,h=e.nodeRefs,g=e.leafRefs,w=e.onSelect,E=e.onExpand,O=e.onLoadData,W=e.togglableSelect,x=e.multiSelect,A=e.propagateSelect,j=e.propagateSelectUpwards,D=i(l(Y,{selectedIds:new Set(a||o),tabbableId:t[0].children[0],isFocused:!1,expandedIds:new Set(d||c),halfSelectedIds:new Set,lastUserSelect:t[0].children[0],lastInteractedWith:null,disabledIds:new Set(f)}),2),k=D[0],L=D[1],_=k.selectedIds,P=k.expandedIds,M=k.disabledIds,V=k.tabbableId,X=k.halfSelectedIds,q=k.lastAction,$=k.lastInteractedWith,J=I(_)||new Set,Q=v(_,J);r((function(){if(null!=w&&w!==Z){var e,a=u(Q);try{for(a.s();!(e=a.n()).done;){var n=e.value,r=b(t,n)||!!t[V].isBranch;w({element:t[n],isBranch:r,isExpanded:!!r&&P.has(n),isSelected:_.has(n),isDisabled:M.has(n),isHalfSelected:!!r&&X.has(n),treeState:k})}}catch(e){a.e(e)}finally{a.f()}}}),[t,_,P,M,X,Q,w,k]);var ee=I(P)||new Set;r((function(){var e=v(P,ee);if(null!=E&&E!==Z){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;E({element:t[r],isExpanded:P.has(r),isSelected:_.has(r),isDisabled:M.has(r),isHalfSelected:X.has(r),treeState:k})}}catch(e){n.e(e)}finally{n.f()}}}),[t,_,P,M,X,ee,E,k]);var te,ae,ne=(te=t,ae=n(),r((function(){ae.current=te})),ae.current||new Set);return r((function(){var e=v(P,ee);if(O){var a,n=u(e);try{for(n.s();!(a=n.n()).done;){var r=a.value;O({element:t[r],isExpanded:P.has(r),isSelected:_.has(r),isDisabled:M.has(r),isHalfSelected:X.has(r),treeState:k})}}catch(e){n.e(e)}finally{n.f()}if(ne!==t&&W&&A){var l,d=u(P);try{for(d.s();!(l=d.n()).done;){var i=l.value;_.has(i)&&L({type:H,ids:C(t,[i],M),select:!0,multiSelect:x,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}}}),[t,_,P,M,X,ee,O,k]),r((function(){var e=new Set(a),n=p(e,J),r=p(J,e);if(r.size){var l,d=u(r);try{for(d.s();!(l=d.n()).done;){var i=l.value;L({type:z,id:i,multiSelect:x,controlled:!0,lastInteractedWith:i})}}catch(e){d.e(e)}finally{d.f()}}if(n.size){var s,c=u(n);try{for(c.s();!(s=c.n()).done;){var o=s.value;L({type:T,id:o,multiSelect:x,controlled:!0,lastInteractedWith:o}),A&&!M.has(o)&&L({type:H,ids:C(t,[o],M),select:!0,multiSelect:x,lastInteractedWith:o})}}catch(e){c.e(e)}finally{c.f()}}}),[a]),r((function(){var e=new Set(d),a=p(e,ee),n=p(ee,e);if(n.size){var r,l=u(n);try{for(l.s();!(r=l.n()).done;){var i=r.value;if(b(t,i)||t[i].isBranch){var c=[i].concat(s(m(t,i,new Set)));L({type:U,ids:c,lastInteractedWith:i})}}}catch(e){l.e(e)}finally{l.f()}}if(a.size){var o,f=u(a);try{for(f.s();!(o=f.n()).done;){var h=o.value;if(b(t,h)||t[h].isBranch){var v=S(t,h);L(v?{type:R,ids:[h,v],lastInteractedWith:h}:{type:F,id:h,lastInteractedWith:h})}}}catch(e){f.e(e)}finally{f.f()}}}),[d]),r((function(){if(j){var e=new Set(Q);$&&q!==G&&q!==N&&q!==F&&q!==K&&e.add($);var a,n=function(e,t,a,n,r,l){var d,i={every:new Set,some:new Set,none:new Set},s=u(t);try{for(s.s();!(d=s.n()).done;)for(var c=d.value;;){var o=S(e,c);if(0===o||null==o||null!=o&&n.has(o))break;var f=e[o].children.filter((function(e){return!n.has(e)}));if(0===f.length)break;if(f.some((function(e){return a.has(e)||i.some.has(e)||r.has(e)})))f.every((function(e){return a.has(e)}))?i.every.add(o):i.some.add(o);else{var h=y(e,c,n).find((function(e){return a.has(e)}));if(!l&&h){m(e,h,n).forEach((function(e){r.has(e)&&i.none.add(e)}));break}i.none.add(o)}c=o}}catch(e){s.e(e)}finally{s.f()}return i}(t,e,_,M,X,x),r=n.every,l=n.some,d=n.none,i=u(r);try{for(i.s();!(a=i.n()).done;){var s=a.value;_.has(s)||L({type:T,id:s,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:$})}}catch(e){i.e(e)}finally{i.f()}var c,o=u(l);try{for(o.s();!(c=o.n()).done;){var f=c.value;X.has(f)||L({type:B,id:f,lastInteractedWith:$})}}catch(e){o.e(e)}finally{o.f()}var h,p=u(d);try{for(p.s();!(h=p.n()).done;){var v=h.value;(_.has(v)||X.has(v))&&L({type:z,id:v,multiSelect:x,keepFocus:!0,NotUserAction:!0,lastInteractedWith:$})}}catch(e){p.e(e)}finally{p.f()}}}),[t,x,j,_,P,M,X,q,J,Q,$]),r((function(){if(null!=$&&null!=V&&null!=(null==h?void 0:h.current)&&null!=(null==g?void 0:g.current)){var e=h.current[V];!function(e){null!=e&&e.scrollIntoView&&e.scrollIntoView({block:"nearest"})}(g.current[$]),function(e){null!=e&&e.focus&&e.focus({preventScroll:!0})}(e)}}),[V,h,g,$]),[k,L]},$={select:"SELECT",focus:"FOCUS",exclusiveSelect:"EXCLUSIVE_SELECT"},J=Object.freeze(Object.values($)),Q=Object.freeze(Object.values({check:"check",select:"select"})),Z=function(){},ee=a.forwardRef((function(t,r){var l=t.data,d=t.selectedIds,s=t.nodeRenderer,c=t.onSelect,o=void 0===c?Z:c,u=t.onExpand,h=void 0===u?Z:u,p=t.onLoadData,v=t.className,I=void 0===v?"":v,b=t.multiSelect,S=void 0!==b&&b,y=t.propagateSelect,m=void 0!==y&&y,g=t.propagateSelectUpwards,w=void 0!==g&&g,E=t.propagateCollapse,O=void 0!==E&&E,W=t.expandOnKeyboardSelect,x=void 0!==W&&W,A=t.togglableSelect,j=void 0!==A&&A,C=t.defaultExpandedIds,k=void 0===C?[]:C,N=t.defaultSelectedIds,U=void 0===N?[]:N,F=t.defaultDisabledIds,R=void 0===F?[]:F,B=t.clickAction,T=void 0===B?$.select:B,z=t.nodeAction,K=void 0===z?"select":z,_=t.expandedIds,H=t.onBlur,P=f(t,["data","selectedIds","nodeRenderer","onSelect","onExpand","onLoadData","className","multiSelect","propagateSelect","propagateSelectUpwards","propagateCollapse","expandOnKeyboardSelect","togglableSelect","defaultExpandedIds","defaultSelectedIds","defaultDisabledIds","clickAction","nodeAction","expandedIds","onBlur"]),G=n({}),V=n({}),X=i(q({data:l,controlledIds:d,controlledExpandedIds:_,defaultExpandedIds:k,defaultSelectedIds:U,defaultDisabledIds:R,nodeRefs:G,leafRefs:V,onSelect:o,onExpand:h,onLoadData:p,togglableSelect:j,multiSelect:S,propagateSelect:m,propagateSelectUpwards:w}),2),Y=X[0],J=X[1];m=m&&S;var Q=n(null);return null!=r&&(Q=r),a.createElement("ul",Object.assign({className:e(L.root,I),role:"tree","aria-multiselectable":"select"===K?S:void 0,ref:Q,onBlur:function(e){D(e,Q.current,(function(){H&&H({treeState:Y,dispatch:J}),J({type:M})}))},onKeyDown:re({data:l,tabbableId:Y.tabbableId,expandedIds:Y.expandedIds,selectedIds:Y.selectedIds,disabledIds:Y.disabledIds,halfSelectedIds:Y.halfSelectedIds,clickAction:T,dispatch:J,propagateCollapse:O,propagateSelect:m,multiSelect:S,expandOnKeyboardSelect:x,togglableSelect:j})},P),l[0].children.map((function(e,t){return a.createElement(te,Object.assign({key:e,data:l,element:l[e],setsize:l[0].children.length,posinset:t+1,level:1},Y,{state:Y,dispatch:J,nodeRefs:G,leafRefs:V,baseClassNames:L,nodeRenderer:s,propagateCollapse:O,propagateSelect:m,propagateSelectUpwards:w,multiSelect:S,togglableSelect:j,clickAction:T,nodeAction:K}))})))})),te=function(t){var n=t.element,r=t.dispatch,l=t.data,i=t.selectedIds,c=t.tabbableId,o=t.isFocused,u=t.expandedIds,f=t.disabledIds,p=t.halfSelectedIds,v=t.lastUserSelect,I=t.nodeRefs,S=t.leafRefs,y=t.baseClassNames,g=t.nodeRenderer,w=t.nodeAction,E=t.setsize,O=t.posinset,x=t.level,D=t.propagateCollapse,L=t.propagateSelect,N=t.multiSelect,F=t.togglableSelect,R=t.clickAction,z=t.state,M=function(e){if(!(e.ctrlKey||e.altKey||e.shiftKey))if(u.has(n.id)&&D){var t=[n.id].concat(s(m(l,n.id,new Set)));r({type:U,ids:t,lastInteractedWith:n.id})}else r({type:K,id:n.id,lastInteractedWith:n.id})},V=function(){return r({type:G,id:n.id,lastInteractedWith:n.id})},X=function(e){if(e.shiftKey){var t=W({data:l,expandedIds:u,from:v,to:n.id}).filter((function(e){return!f.has(e)}));t=L?C(l,t,f):t,r({type:P,select:!0,multiSelect:N,ids:t,lastInteractedWith:n.id})}else if(e.ctrlKey||R===$.select){var a=k(l,n.id,i);r({type:F?a?B:_:T,id:n.id,multiSelect:N,lastInteractedWith:n.id}),L&&!f.has(n.id)&&r({type:H,ids:C(l,[n.id],f),select:!F||!i.has(n.id),multiSelect:N,lastInteractedWith:n.id})}else R===$.exclusiveSelect?r({type:F?_:T,id:n.id,multiSelect:!1,lastInteractedWith:n.id}):R===$.focus&&r({type:G,id:n.id,lastInteractedWith:n.id})},Y=function(t){var a;return e(t,(d(a={},"".concat(t,"--expanded"),u.has(n.id)),d(a,"".concat(t,"--selected"),i.has(n.id)),d(a,"".concat(t,"--focused"),c===n.id&&o),a))},q="select"===w?{"aria-selected":A({isSelected:i.has(n.id),isDisabled:f.has(n.id),multiSelect:N})}:{"aria-checked":j({isSelected:i.has(n.id),isDisabled:f.has(n.id),isHalfSelected:p.has(n.id),multiSelect:N})};return b(l,n.id)||n.isBranch?a.createElement("li",Object.assign({role:"treeitem","aria-expanded":u.has(n.id),"aria-setsize":E,"aria-posinset":O,"aria-level":x,"aria-disabled":f.has(n.id),tabIndex:c===n.id?0:-1,ref:function(e){null!=(null==I?void 0:I.current)&&null!=e&&(I.current[n.id]=e)},className:y.branchWrapper},q),a.createElement(a.Fragment,null,g({element:n,isBranch:!0,isSelected:i.has(n.id),isHalfSelected:p.has(n.id),isExpanded:u.has(n.id),isDisabled:f.has(n.id),dispatch:r,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return{onClick:null==a?h(X,M,V):h(a,V),className:e(Y(y.node),y.branch),ref:function(e){null!=(null==S?void 0:S.current)&&(S.current[n.id]=e)}}},setsize:E,posinset:O,level:x,handleSelect:X,handleExpand:M,treeState:z}),a.createElement(ne,Object.assign({getClasses:Y},ae(t))))):a.createElement("li",{role:"none",className:Y(y.leafListItem)},g({element:n,isBranch:!1,isSelected:i.has(n.id),isHalfSelected:!1,isExpanded:!1,isDisabled:f.has(n.id),dispatch:r,getNodeProps:function(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},a=t.onClick;return Object.assign({role:"treeitem",tabIndex:c===n.id?0:-1,onClick:h(null==a?X:a,V),ref:function(e){null!=(null==I?void 0:I.current)&&null!=(null==S?void 0:S.current)&&(I.current[n.id]=e,S.current[n.id]=e)},className:e(Y(y.node),y.leaf),"aria-setsize":E,"aria-posinset":O,"aria-level":x,disabled:f.has(n.id),"aria-disabled":f.has(n.id)},q)},setsize:E,posinset:O,level:x,handleSelect:X,handleExpand:Z,treeState:z}))},ae=function(e){e.setsize,e.posinset;return f(e,["setsize","posinset"])},ne=function(e){var t=e.data,n=e.element,r=e.expandedIds,l=e.getClasses,d=e.baseClassNames,i=e.level,s=f(e,["data","element","expandedIds","getClasses","baseClassNames","level"]);return a.createElement("ul",{role:"group",className:l(d.nodeGroup)},r.has(n.id)&&n.children.length>0&&n.children.map((function(e,l){return a.createElement(te,Object.assign({data:t,expandedIds:r,baseClassNames:d,key:e,element:t[e],setsize:n.children.length,posinset:l+1,level:i+1},s))})))},re=function(e){var t=e.data,a=e.expandedIds,n=e.selectedIds,r=e.disabledIds,l=e.tabbableId,d=e.dispatch,i=e.propagateCollapse,c=e.propagateSelect,o=e.multiSelect,u=e.expandOnKeyboardSelect,f=e.togglableSelect,h=e.clickAction;return function(e){var p=t[l],v=p.id;if(e.ctrlKey){if("a"===e.key){e.preventDefault();var I=t.filter((function(e){return 0!==e.id})),y=Object.values(I).map((function(e){return e.id})).filter((function(e){return!r.has(e)}));d({type:H,multiSelect:o,select:Array.from(n).filter((function(e){return!r.has(e)})).length!==y.length,ids:y,lastInteractedWith:p.id})}else if(e.shiftKey&&("Home"===e.key||"End"===e.key)){var g="Home"===e.key?t[0].children[0]:w(t,v,a),x=W({data:t,expandedIds:a,from:v,to:g}).filter((function(e){return!r.has(e)}));d({type:H,multiSelect:o,select:!0,ids:c?C(t,x,r):x}),d({type:G,id:g,lastInteractedWith:g})}}else{if(e.shiftKey)switch(e.key){case"ArrowUp":e.preventDefault();var A=E(t,v,a);return void(null==A||r.has(A)||(d({type:H,ids:c?C(t,[A],r):[A],select:!0,multiSelect:o,lastInteractedWith:A}),d({type:G,id:A,lastInteractedWith:A})));case"ArrowDown":e.preventDefault();var j=O(t,v,a);return void(null==j||r.has(j)||(d({type:H,ids:c?C(t,[j],r):[j],multiSelect:o,select:!0,lastInteractedWith:j}),d({type:G,id:j,lastInteractedWith:j})))}switch(e.key){case"ArrowDown":e.preventDefault();var D=O(t,v,a);return void(null!=D&&d({type:G,id:D,lastInteractedWith:D}));case"ArrowUp":e.preventDefault();var L=E(t,v,a);return void(null!=L&&d({type:G,id:L,lastInteractedWith:L}));case"ArrowLeft":if(e.preventDefault(),(b(t,v)||p.isBranch)&&a.has(l))if(i){var z=[v].concat(s(m(t,v,new Set)));d({type:U,ids:z,lastInteractedWith:p.id})}else d({type:N,id:v,lastInteractedWith:v});else if(!t[0].children.includes(v)){var P=S(t,v);if(null==P)throw new Error("parentId of root element is null");d({type:G,id:P,lastInteractedWith:P})}return;case"ArrowRight":return e.preventDefault(),void((b(t,v)||p.isBranch)&&(a.has(l)?d({type:G,id:p.children[0],lastInteractedWith:p.children[0]}):d({type:F,id:v,lastInteractedWith:v})));case"Home":e.preventDefault(),d({type:G,id:t[0].children[0],lastInteractedWith:t[0].children[0]});break;case"End":e.preventDefault();var M=w(t,t[0].id,a);return void d({type:G,id:M,lastInteractedWith:M});case"*":e.preventDefault();var V=S(t,v);if(null==V)throw new Error("parentId of element is null");var X=t[V].children.filter((function(e){return b(t,e)||t[e].isBranch}));return void d({type:R,ids:X,lastInteractedWith:v});case"Enter":case" ":case"Spacebar":if(e.preventDefault(),h===$.focus)return;var Y=k(t,p.id,n);return d({type:f?Y?B:_:T,id:v,multiSelect:o,lastInteractedWith:v}),c&&!r.has(p.id)&&d({type:H,ids:C(t,[v],r),select:!f||!n.has(v),multiSelect:o,lastInteractedWith:v}),void(u&&d({type:K,id:v,lastInteractedWith:v}));default:if(1===e.key.length)for(var q=O(t,v,a);q!==v;)if(null!=q){if(t[q].name[0].toLowerCase()===e.key.toLowerCase())return void d({type:G,id:q,lastInteractedWith:v});q=O(t,q,a)}else q=t[0].children[0];return}}}};ee.propTypes={data:t.array.isRequired,onSelect:t.func,onExpand:t.func,className:t.string,nodeRenderer:t.func.isRequired,defaultExpandedIds:t.array,defaultSelectedIds:t.array,expandedIds:t.array,selectedIds:t.array,defaultDisabledIds:t.array,propagateCollapse:t.bool,propagateSelect:t.bool,propagateSelectUpwards:t.bool,multiSelect:t.bool,expandOnKeyboardSelect:t.bool,togglableSelect:t.bool,nodeAction:t.oneOf(Q),clickAction:t.oneOf(J),onBlur:t.func,onLoadData:t.func};export default ee;export{J as CLICK_ACTIONS,x as flattenTree}; |
{ | ||
"name": "react-accessible-treeview", | ||
"description": "A react component that implements the treeview pattern as described by the WAI-ARIA Authoring Practices.", | ||
"version": "2.3.4", | ||
"version": "2.3.5", | ||
"author": "lissitz (https://github.com/lissitz)", | ||
@@ -6,0 +6,0 @@ "main": "dist/react-accessible-treeview.cjs.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
82553
0