react-composable-treeview 1.0.3 → 1.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -0
- package/dist/contexts/groupContext.d.ts +1 -0
- package/dist/index.cjs +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +210 -207
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -70,6 +70,7 @@ Contains all the parts of a collapsible group.
|
|
|
70
70
|
| Data attribute | Values |
|
|
71
71
|
| -------------- | ------------------ |
|
|
72
72
|
| data-state | "open" \| "closed" |
|
|
73
|
+
| depth | number |
|
|
73
74
|
|
|
74
75
|
### Item
|
|
75
76
|
|
|
@@ -79,6 +80,10 @@ Contains an item.
|
|
|
79
80
|
| ----- | -------- | ------- |
|
|
80
81
|
| value | `string` | '' |
|
|
81
82
|
|
|
83
|
+
| Data attribute | Values |
|
|
84
|
+
| -------------- | ------ |
|
|
85
|
+
| depth | number |
|
|
86
|
+
|
|
82
87
|
### Trigger
|
|
83
88
|
|
|
84
89
|
Toggles the collapsed state of its associated group.
|
package/dist/index.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";const p=require("react");var
|
|
1
|
+
"use strict";const p=require("react");var ue={exports:{}},G={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.min.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var Fe;function dr(){if(Fe)return G;Fe=1;var t=p,o=Symbol.for("react.element"),i=Symbol.for("react.fragment"),a=Object.prototype.hasOwnProperty,d=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,f={key:!0,ref:!0,__self:!0,__source:!0};function c(h,_,w){var R,x={},C=null,O=null;w!==void 0&&(C=""+w),_.key!==void 0&&(C=""+_.key),_.ref!==void 0&&(O=_.ref);for(R in _)a.call(_,R)&&!f.hasOwnProperty(R)&&(x[R]=_[R]);if(h&&h.defaultProps)for(R in _=h.defaultProps,_)x[R]===void 0&&(x[R]=_[R]);return{$$typeof:o,type:h,key:C,ref:O,props:x,_owner:d.current}}return G.Fragment=i,G.jsx=c,G.jsxs=c,G}var q={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,15 +14,15 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
18
|
-
`+
|
|
19
|
-
`),
|
|
20
|
-
`),
|
|
21
|
-
`+s[
|
|
17
|
+
*/var De;function vr(){return De||(De=1,process.env.NODE_ENV!=="production"&&function(){var t=p,o=Symbol.for("react.element"),i=Symbol.for("react.portal"),a=Symbol.for("react.fragment"),d=Symbol.for("react.strict_mode"),f=Symbol.for("react.profiler"),c=Symbol.for("react.provider"),h=Symbol.for("react.context"),_=Symbol.for("react.forward_ref"),w=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),x=Symbol.for("react.memo"),C=Symbol.for("react.lazy"),O=Symbol.for("react.offscreen"),F=Symbol.iterator,E="@@iterator";function V(e){if(e===null||typeof e!="object")return null;var r=F&&e[F]||e[E];return typeof r=="function"?r:null}var P=t.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(e){{for(var r=arguments.length,n=new Array(r>1?r-1:0),u=1;u<r;u++)n[u-1]=arguments[u];T("error",e,n)}}function T(e,r,n){{var u=P.ReactDebugCurrentFrame,v=u.getStackAddendum();v!==""&&(r+="%s",n=n.concat([v]));var g=n.map(function(l){return String(l)});g.unshift("Warning: "+r),Function.prototype.apply.call(console[e],console,g)}}var D=!1,K=!1,Ve=!1,Le=!1,Ne=!1,ce;ce=Symbol.for("react.module.reference");function $e(e){return!!(typeof e=="string"||typeof e=="function"||e===a||e===f||Ne||e===d||e===w||e===R||Le||e===O||D||K||Ve||typeof e=="object"&&e!==null&&(e.$$typeof===C||e.$$typeof===x||e.$$typeof===c||e.$$typeof===h||e.$$typeof===_||e.$$typeof===ce||e.getModuleId!==void 0))}function We(e,r,n){var u=e.displayName;if(u)return u;var v=r.displayName||r.name||"";return v!==""?n+"("+v+")":n}function fe(e){return e.displayName||"Context"}function j(e){if(e==null)return null;if(typeof e.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof e=="function")return e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case a:return"Fragment";case i:return"Portal";case f:return"Profiler";case d:return"StrictMode";case w:return"Suspense";case R:return"SuspenseList"}if(typeof e=="object")switch(e.$$typeof){case h:var r=e;return fe(r)+".Consumer";case c:var n=e;return fe(n._context)+".Provider";case _:return We(e,e.render,"ForwardRef");case x:var u=e.displayName||null;return u!==null?u:j(e.type)||"Memo";case C:{var v=e,g=v._payload,l=v._init;try{return j(l(g))}catch{return null}}}return null}var L=Object.assign,Y=0,le,de,ve,pe,he,_e,ge;function Re(){}Re.__reactDisabledLog=!0;function Ye(){{if(Y===0){le=console.log,de=console.info,ve=console.warn,pe=console.error,he=console.group,_e=console.groupCollapsed,ge=console.groupEnd;var e={configurable:!0,enumerable:!0,value:Re,writable:!0};Object.defineProperties(console,{info:e,log:e,warn:e,error:e,group:e,groupCollapsed:e,groupEnd:e})}Y++}}function Ue(){{if(Y--,Y===0){var e={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},e,{value:le}),info:L({},e,{value:de}),warn:L({},e,{value:ve}),error:L({},e,{value:pe}),group:L({},e,{value:he}),groupCollapsed:L({},e,{value:_e}),groupEnd:L({},e,{value:ge})})}Y<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var Q=P.ReactCurrentDispatcher,ee;function J(e,r,n){{if(ee===void 0)try{throw Error()}catch(v){var u=v.stack.trim().match(/\n( *(at )?)/);ee=u&&u[1]||""}return`
|
|
18
|
+
`+ee+e}}var re=!1,M;{var Ge=typeof WeakMap=="function"?WeakMap:Map;M=new Ge}function be(e,r){if(!e||re)return"";{var n=M.get(e);if(n!==void 0)return n}var u;re=!0;var v=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var g;g=Q.current,Q.current=null,Ye();try{if(r){var l=function(){throw Error()};if(Object.defineProperty(l.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(l,[])}catch(A){u=A}Reflect.construct(e,[],l)}else{try{l.call()}catch(A){u=A}e.call(l.prototype)}}else{try{throw Error()}catch(A){u=A}e()}}catch(A){if(A&&u&&typeof A.stack=="string"){for(var s=A.stack.split(`
|
|
19
|
+
`),S=u.stack.split(`
|
|
20
|
+
`),m=s.length-1,y=S.length-1;m>=1&&y>=0&&s[m]!==S[y];)y--;for(;m>=1&&y>=0;m--,y--)if(s[m]!==S[y]){if(m!==1||y!==1)do if(m--,y--,y<0||s[m]!==S[y]){var k=`
|
|
21
|
+
`+s[m].replace(" at new "," at ");return e.displayName&&k.includes("<anonymous>")&&(k=k.replace("<anonymous>",e.displayName)),typeof e=="function"&&M.set(e,k),k}while(m>=1&&y>=0);break}}}finally{re=!1,Q.current=g,Ue(),Error.prepareStackTrace=v}var $=e?e.displayName||e.name:"",Ae=$?J($):"";return typeof e=="function"&&M.set(e,Ae),Ae}function qe(e,r,n){return be(e,!1)}function Be(e){var r=e.prototype;return!!(r&&r.isReactComponent)}function z(e,r,n){if(e==null)return"";if(typeof e=="function")return be(e,Be(e));if(typeof e=="string")return J(e);switch(e){case w:return J("Suspense");case R:return J("SuspenseList")}if(typeof e=="object")switch(e.$$typeof){case _:return qe(e.render);case x:return z(e.type,r,n);case C:{var u=e,v=u._payload,g=u._init;try{return z(g(v),r,n)}catch{}}}return""}var X=Object.prototype.hasOwnProperty,Ee={},me=P.ReactDebugCurrentFrame;function H(e){if(e){var r=e._owner,n=z(e.type,e._source,r?r.type:null);me.setExtraStackFrame(n)}else me.setExtraStackFrame(null)}function Ke(e,r,n,u,v){{var g=Function.call.bind(X);for(var l in e)if(g(e,l)){var s=void 0;try{if(typeof e[l]!="function"){var S=Error((u||"React class")+": "+n+" type `"+l+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof e[l]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw S.name="Invariant Violation",S}s=e[l](r,l,u,n,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(m){s=m}s&&!(s instanceof Error)&&(H(v),b("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",u||"React class",n,l,typeof s),H(null)),s instanceof Error&&!(s.message in Ee)&&(Ee[s.message]=!0,H(v),b("Failed %s type: %s",n,s.message),H(null))}}}var Je=Array.isArray;function te(e){return Je(e)}function Me(e){{var r=typeof Symbol=="function"&&Symbol.toStringTag,n=r&&e[Symbol.toStringTag]||e.constructor.name||"Object";return n}}function ze(e){try{return ye(e),!1}catch{return!0}}function ye(e){return""+e}function we(e){if(ze(e))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",Me(e)),ye(e)}var U=P.ReactCurrentOwner,Xe={key:!0,ref:!0,__self:!0,__source:!0},xe,Ce,ne;ne={};function He(e){if(X.call(e,"ref")){var r=Object.getOwnPropertyDescriptor(e,"ref").get;if(r&&r.isReactWarning)return!1}return e.ref!==void 0}function Ze(e){if(X.call(e,"key")){var r=Object.getOwnPropertyDescriptor(e,"key").get;if(r&&r.isReactWarning)return!1}return e.key!==void 0}function Qe(e,r){if(typeof e.ref=="string"&&U.current&&r&&U.current.stateNode!==r){var n=j(U.current.type);ne[n]||(b('Component "%s" contains the string ref "%s". Support for string refs will be removed in a future major release. This case cannot be automatically converted to an arrow function. We ask you to manually fix this case by using useRef() or createRef() instead. Learn more about using refs safely here: https://reactjs.org/link/strict-mode-string-ref',j(U.current.type),e.ref),ne[n]=!0)}}function er(e,r){{var n=function(){xe||(xe=!0,b("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"key",{get:n,configurable:!0})}}function rr(e,r){{var n=function(){Ce||(Ce=!0,b("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",r))};n.isReactWarning=!0,Object.defineProperty(e,"ref",{get:n,configurable:!0})}}var tr=function(e,r,n,u,v,g,l){var s={$$typeof:o,type:e,key:r,ref:n,props:l,_owner:g};return s._store={},Object.defineProperty(s._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(s,"_self",{configurable:!1,enumerable:!1,writable:!1,value:u}),Object.defineProperty(s,"_source",{configurable:!1,enumerable:!1,writable:!1,value:v}),Object.freeze&&(Object.freeze(s.props),Object.freeze(s)),s};function nr(e,r,n,u,v){{var g,l={},s=null,S=null;n!==void 0&&(we(n),s=""+n),Ze(r)&&(we(r.key),s=""+r.key),He(r)&&(S=r.ref,Qe(r,v));for(g in r)X.call(r,g)&&!Xe.hasOwnProperty(g)&&(l[g]=r[g]);if(e&&e.defaultProps){var m=e.defaultProps;for(g in m)l[g]===void 0&&(l[g]=m[g])}if(s||S){var y=typeof e=="function"?e.displayName||e.name||"Unknown":e;s&&er(l,y),S&&rr(l,y)}return tr(e,s,S,v,u,U.current,l)}}var oe=P.ReactCurrentOwner,Te=P.ReactDebugCurrentFrame;function N(e){if(e){var r=e._owner,n=z(e.type,e._source,r?r.type:null);Te.setExtraStackFrame(n)}else Te.setExtraStackFrame(null)}var ae;ae=!1;function ie(e){return typeof e=="object"&&e!==null&&e.$$typeof===o}function Se(){{if(oe.current){var e=j(oe.current.type);if(e)return`
|
|
22
22
|
|
|
23
23
|
Check the render method of \``+e+"`."}return""}}function or(e){{if(e!==void 0){var r=e.fileName.replace(/^.*[\\\/]/,""),n=e.lineNumber;return`
|
|
24
24
|
|
|
25
|
-
Check your code at `+r+":"+n+"."}return""}}var
|
|
25
|
+
Check your code at `+r+":"+n+"."}return""}}var Pe={};function ar(e){{var r=Se();if(!r){var n=typeof e=="string"?e:e.displayName||e.name;n&&(r=`
|
|
26
26
|
|
|
27
|
-
Check the top-level render call using <`+n+">.")}return r}}function
|
|
27
|
+
Check the top-level render call using <`+n+">.")}return r}}function Oe(e,r){{if(!e._store||e._store.validated||e.key!=null)return;e._store.validated=!0;var n=ar(r);if(Pe[n])return;Pe[n]=!0;var u="";e&&e._owner&&e._owner!==oe.current&&(u=" It was passed a child from "+j(e._owner.type)+"."),N(e),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',n,u),N(null)}}function ke(e,r){{if(typeof e!="object")return;if(te(e))for(var n=0;n<e.length;n++){var u=e[n];ie(u)&&Oe(u,r)}else if(ie(e))e._store&&(e._store.validated=!0);else if(e){var v=V(e);if(typeof v=="function"&&v!==e.entries)for(var g=v.call(e),l;!(l=g.next()).done;)ie(l.value)&&Oe(l.value,r)}}}function ir(e){{var r=e.type;if(r==null||typeof r=="string")return;var n;if(typeof r=="function")n=r.propTypes;else if(typeof r=="object"&&(r.$$typeof===_||r.$$typeof===x))n=r.propTypes;else return;if(n){var u=j(r);Ke(n,e.props,"prop",u,e)}else if(r.PropTypes!==void 0&&!ae){ae=!0;var v=j(r);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",v||"Unknown")}typeof r.getDefaultProps=="function"&&!r.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ur(e){{for(var r=Object.keys(e.props),n=0;n<r.length;n++){var u=r[n];if(u!=="children"&&u!=="key"){N(e),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",u),N(null);break}}e.ref!==null&&(N(e),b("Invalid attribute `ref` supplied to `React.Fragment`."),N(null))}}function je(e,r,n,u,v,g){{var l=$e(e);if(!l){var s="";(e===void 0||typeof e=="object"&&e!==null&&Object.keys(e).length===0)&&(s+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var S=or(v);S?s+=S:s+=Se();var m;e===null?m="null":te(e)?m="array":e!==void 0&&e.$$typeof===o?(m="<"+(j(e.type)||"Unknown")+" />",s=" Did you accidentally export a JSX literal instead of a component?"):m=typeof e,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",m,s)}var y=nr(e,r,n,v,g);if(y==null)return y;if(l){var k=r.children;if(k!==void 0)if(u)if(te(k)){for(var $=0;$<k.length;$++)ke(k[$],e);Object.freeze&&Object.freeze(k)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else ke(k,e)}return e===a?ur(y):ir(y),y}}function sr(e,r,n){return je(e,r,n,!0)}function cr(e,r,n){return je(e,r,n,!1)}var fr=cr,lr=sr;q.Fragment=a,q.jsx=fr,q.jsxs=lr}()),q}process.env.NODE_ENV==="production"?ue.exports=dr():ue.exports=vr();var I=ue.exports;const B=p.createContext({rootValue:new Set,setRootValue:()=>{},selection:null,setSelection:()=>{},focus:{current:""},nodeMap:{current:{}},pushToNodeMap:()=>{}});function pr(){const t=p.useRef({__root__:{value:"__root__",parent:"",children:{},index:0,childrenLength:0,isGroup:!0,ref:{current:null}}}),o=p.useRef({}),i=p.useCallback((a,d,f,c,h)=>{if(!t.current[d]){o.current[d]?o.current[d].push([a,d,f,c,h]):o.current[d]=[[a,d,f,c,h]];return}if(t.current[a]={value:a,parent:d,children:{},childrenLength:0,index:f,isGroup:c,ref:h},t.current[d].children[f]=a,(f+1>t.current[d].childrenLength||t.current[t.current[d].childrenLength-1]==null)&&(t.current[d].childrenLength=f+1),o.current[a]){for(const _ of o.current[a])i(..._);delete o.current[a]}},[]);return[t,i]}const W=p.createContext({parent:"",getIndex:()=>-1,depth:-1});function hr(t,o,i){const[a,d]=p.useState(i);return[t!==void 0?t:a,h=>{d(h),o&&o(a)}]}function Z(t,o){return function(a){if(t==null||t(a),!a.defaultPrevented)return o==null?void 0:o(a)}}function se(...t){return p.useCallback(o=>{for(const i of t)typeof i=="function"?i(o):i!=null&&(i.current=o)},[t])}function Ie(){const t=p.useRef(-1),o=p.useRef({});return p.useCallback(a=>(o.current[a]==null&&(o.current[a]=++t.current),o.current[a]),[])}const _r=["ArrowRight","ArrowUp","ArrowLeft","ArrowDown","Home","End","Enter"];function gr(t,o){var a;const i=t[o].children[0];i!=null&&((a=t[i].ref.current)==null||a.focus())}function Rr(t,o){var a;const i=t[o].parent;i!="__root__"&&((a=t[i].ref.current)==null||a.focus())}function br(t,o){var d,f;const i=t[o].parent,a=t[o].index;if(a!=0){let c=t[i].children[a-1],h;for(;t[c].isGroup&&(h=t[c].children[t[c].childrenLength-1],!(h==null||t[h].ref.current==null));)c=h;(d=t[c].ref.current)==null||d.focus();return}i!="__root__"&&((f=t[i].ref.current)==null||f.focus())}function Er(t,o){var d,f;if(t[o].isGroup){const c=(d=t[t[o].children[0]])==null?void 0:d.ref.current;if(c){c.focus();return}}let i,a;for(;i=t[o].parent,a=t[i].children[t[o].index+1],a==null;){if(i=="__root__")return;o=i}(f=t[a].ref.current)==null||f.focus()}function mr(t){var i;const o=t.__root__.children[0];(i=t[o].ref.current)==null||i.focus()}function yr(t){var a;let o="__root__",i;for(;t[o].isGroup&&(i=t[o].children[t[o].childrenLength-1],!(i==null||t[i].ref.current==null));)o=i;(a=t[o].ref.current)==null||a.focus()}const wr=p.forwardRef(({value:t,onValueChange:o,defaultValue:i,onKeyDown:a,...d},f)=>{const[c,h]=pr(),_=Ie(),[w,R]=hr(t,o,i??new Set),[x,C]=p.useState(null),O=p.useRef(null),F=se(O,f),E=p.useRef(""),V=p.useCallback(b=>{if(!(!_r.includes(b.key)||!c.current))switch(b.key){case"ArrowRight":if(!c.current[E.current].isGroup)break;w.has(E.current)?gr(c.current,E.current):R(T=>new Set([...T,E.current]));break;case"ArrowLeft":w.has(E.current)?R(T=>new Set([...T].filter(D=>D!==E.current))):Rr(c.current,E.current);break;case"ArrowUp":br(c.current,E.current);break;case"ArrowDown":Er(c.current,E.current);break;case"Home":mr(c.current);break;case"End":yr(c.current);break;case"Enter":C(E.current),w.has(E.current)?R(T=>new Set([...T].filter(D=>D!==E.current))):R(T=>new Set([...T,E.current]));break}},[w]),P=Z(a,V);return I.jsx(B.Provider,{value:{rootValue:w,setRootValue:R,selection:x,setSelection:C,focus:E,nodeMap:c,pushToNodeMap:h},children:I.jsx(W.Provider,{value:{parent:"__root__",getIndex:_,depth:0},children:I.jsx("ul",{ref:F,role:"tree","aria-multiselectable":"false",onKeyDown:P,...d})})})}),xr=p.forwardRef(({value:t,onFocus:o,...i},a)=>{const{selection:d,focus:f,nodeMap:c,pushToNodeMap:h}=p.useContext(B),{parent:_,getIndex:w,depth:R}=p.useContext(W),x=p.useRef(null),C=se(x,a),O=Z(o,F);function F(V){var P,b,T;(b=(P=c.current)==null?void 0:P[f.current].ref.current)==null||b.setAttribute("tabindex","-1"),(T=x.current)==null||T.setAttribute("tabindex","0"),f.current=t,V.preventDefault()}const E=w(t);return h(t,_,E,!1,x),f.current==""&&_=="__root__"&&E==0&&(f.current=t),I.jsx("li",{ref:C,role:"treenode","aria-selected":d==t,tabIndex:f.current==t?0:-1,onFocus:O,"data-depth":R,...i})}),Cr=p.forwardRef(({value:t,onFocus:o,...i},a)=>{const d=Ie(),{rootValue:f,selection:c,focus:h,nodeMap:_,pushToNodeMap:w}=p.useContext(B),{parent:R,getIndex:x,depth:C}=p.useContext(W),O=p.useRef(null),F=se(O,a),E=Z(o,V);function V(b){var T,D,K;(D=(T=_.current)==null?void 0:T[h.current].ref.current)==null||D.setAttribute("tabindex","-1"),(K=O.current)==null||K.setAttribute("tabindex","0"),h.current=t,b.preventDefault()}const P=x(t);return w(t,R,P,!0,O),h.current==""&&R=="__root__"&&P==0&&(h.current=t),I.jsx(W.Provider,{value:{parent:t,getIndex:d,depth:C+1},children:I.jsx("li",{ref:F,role:"treenode","aria-expanded":f.has(t),"data-state":f.has(t)?"open":"closed","data-depth":C,"aria-selected":c==t,tabIndex:h.current==t?0:-1,onFocus:E,...i})})}),Tr=p.forwardRef(({onClick:t,...o},i)=>{const{setRootValue:a,setSelection:d}=p.useContext(B),{parent:f}=p.useContext(W),c=Z(t,h);function h(){d(f),a(_=>_.has(f)?new Set([..._].filter(w=>w!==f)):new Set([..._,f]))}return I.jsx("div",{ref:i,onClick:c,...o})}),Sr=p.forwardRef(({...t},o)=>{const{rootValue:i}=p.useContext(B),{parent:a}=p.useContext(W);if(i.has(a))return I.jsx("ul",{ref:o,role:"group",...t})}),Pr={Root:wr,Group:Cr,Trigger:Tr,Content:Sr,Item:xr};module.exports=Pr;
|
|
28
28
|
//# sourceMappingURL=index.cjs.map
|