@gouvfr-lasuite/ui-kit 0.1.1 → 0.1.2
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/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -98,5 +98,5 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
|
98
98
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function RE(t,e){if(t){if(typeof t=="string")return Vl(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Vl(t,e)}}function Vl(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function ME(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],i=!0,o=!1,a,s;try{for(n=n.call(t);!(i=(a=n.next()).done)&&(r.push(a.value),!(e&&r.length===e));i=!0);}catch(l){o=!0,s=l}finally{try{!i&&n.return!=null&&n.return()}finally{if(o)throw s}}return r}}function AE(t){if(Array.isArray(t))return t}function KE(t,e,n){var r=Ht(),i=_E(t,e),o=TE(t);Lt(function(){var s=H0(o,i,r),l=kE(s,2),u=l[0],c=l[1];return e.receiveHandlerId(u),n.receiveHandlerId(u),c},[r,e,i,n,o.map(function(a){return a.toString()}).join("|")])}function LE(){var t=Ht();return d.useMemo(function(){return new I0(t)},[t])}function FE(t){var e=Ht(),n=d.useMemo(function(){return new z0(e.getBackend())},[e]);return Lt(function(){return n.dropTargetOptions=t||null,n.reconnect(),function(){return n.disconnectDropTarget()}},[t]),n}function jE(t){return d.useMemo(function(){return t.hooks.dropTarget()},[t])}function Ff(t,e){var n=Af(t,e),r=LE(),i=FE(n.options);return KE(n,r,i),[Lf(n.collect,r,i),jE(i)]}function zE(t,e){return UE(t)||WE(t,e)||BE(t,e)||HE()}function HE(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
|
99
99
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function BE(t,e){if(t){if(typeof t=="string")return Gl(t,e);var n=Object.prototype.toString.call(t).slice(8,-1);if(n==="Object"&&t.constructor&&(n=t.constructor.name),n==="Map"||n==="Set")return Array.from(t);if(n==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n))return Gl(t,e)}}function Gl(t,e){(e==null||e>t.length)&&(e=t.length);for(var n=0,r=new Array(e);n<e;n++)r[n]=t[n];return r}function WE(t,e){var n=t==null?null:typeof Symbol<"u"&&t[Symbol.iterator]||t["@@iterator"];if(n!=null){var r=[],i=!0,o=!1,a,s;try{for(n=n.call(t);!(i=(a=n.next()).done)&&(r.push(a.value),!(e&&r.length===e));i=!0);}catch(l){o=!0,s=l}finally{try{!i&&n.return!=null&&n.return()}finally{if(o)throw s}}return r}}function UE(t){if(Array.isArray(t))return t}function VE(t){var e=Ht(),n=e.getMonitor(),r=Kf(n,t),i=zE(r,2),o=i[0],a=i[1];return d.useEffect(function(){return n.subscribeToOffsetChange(a)}),d.useEffect(function(){return n.subscribeToStateChange(a)}),o}function jf(t){var e=null,n=function(){return e==null&&(e=t()),e};return n}function GE(t,e){return t.filter(function(n){return n!==e})}function qE(t,e){var n=new Set,r=function(a){return n.add(a)};t.forEach(r),e.forEach(r);var i=[];return n.forEach(function(o){return i.push(o)}),i}function YE(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function XE(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function JE(t,e,n){return XE(t.prototype,e),t}function ql(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var QE=function(){function t(e){YE(this,t),ql(this,"entered",[]),ql(this,"isNodeInDocument",void 0),this.isNodeInDocument=e}return JE(t,[{key:"enter",value:function(n){var r=this,i=this.entered.length,o=function(s){return r.isNodeInDocument(s)&&(!s.contains||s.contains(n))};return this.entered=qE(this.entered.filter(o),[n]),i===0&&this.entered.length>0}},{key:"leave",value:function(n){var r=this.entered.length;return this.entered=GE(this.entered.filter(this.isNodeInDocument),n),r>0&&this.entered.length===0}},{key:"reset",value:function(){this.entered=[]}}]),t}(),ZE=jf(function(){return/firefox/i.test(navigator.userAgent)}),zf=jf(function(){return!!window.safari});function e$(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function t$(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function n$(t,e,n){return t$(t.prototype,e),t}function Mn(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var Yl=function(){function t(e,n){e$(this,t),Mn(this,"xs",void 0),Mn(this,"ys",void 0),Mn(this,"c1s",void 0),Mn(this,"c2s",void 0),Mn(this,"c3s",void 0);for(var r=e.length,i=[],o=0;o<r;o++)i.push(o);i.sort(function(b,k){return e[b]<e[k]?-1:1});for(var a=[],s=[],l,u,c=0;c<r-1;c++)l=e[c+1]-e[c],u=n[c+1]-n[c],a.push(l),s.push(u/l);for(var p=[s[0]],g=0;g<a.length-1;g++){var h=s[g],y=s[g+1];if(h*y<=0)p.push(0);else{l=a[g];var f=a[g+1],v=l+f;p.push(3*v/((v+f)/h+(v+l)/y))}}p.push(s[s.length-1]);for(var m=[],S=[],w,O=0;O<p.length-1;O++){w=s[O];var x=p[O],D=1/a[O],P=x+p[O+1]-w-w;m.push((w-x-P)*D),S.push(P*D*D)}this.xs=e,this.ys=n,this.c1s=p,this.c2s=m,this.c3s=S}return n$(t,[{key:"interpolate",value:function(n){var r=this.xs,i=this.ys,o=this.c1s,a=this.c2s,s=this.c3s,l=r.length-1;if(n===r[l])return i[l];for(var u=0,c=s.length-1,p;u<=c;){p=Math.floor(.5*(u+c));var g=r[p];if(g<n)u=p+1;else if(g>n)c=p-1;else return i[p]}l=Math.max(0,c);var h=n-r[l],y=h*h;return i[l]+o[l]*h+a[l]*y+s[l]*h*y}}]),t}(),r$=1;function Hf(t){var e=t.nodeType===r$?t:t.parentElement;if(!e)return null;var n=e.getBoundingClientRect(),r=n.top,i=n.left;return{x:i,y:r}}function Dr(t){return{x:t.clientX,y:t.clientY}}function i$(t){var e;return t.nodeName==="IMG"&&(ZE()||!((e=document.documentElement)!==null&&e!==void 0&&e.contains(t)))}function o$(t,e,n,r){var i=t?e.width:n,o=t?e.height:r;return zf()&&t&&(o/=window.devicePixelRatio,i/=window.devicePixelRatio),{dragPreviewWidth:i,dragPreviewHeight:o}}function a$(t,e,n,r,i){var o=i$(e),a=o?t:e,s=Hf(a),l={x:n.x-s.x,y:n.y-s.y},u=t.offsetWidth,c=t.offsetHeight,p=r.anchorX,g=r.anchorY,h=o$(o,e,u,c),y=h.dragPreviewWidth,f=h.dragPreviewHeight,v=function(){var P=new Yl([0,.5,1],[l.y,l.y/c*f,l.y+f-c]),b=P.interpolate(g);return zf()&&o&&(b+=(window.devicePixelRatio-1)*f),b},m=function(){var P=new Yl([0,.5,1],[l.x,l.x/u*y,l.x+y-u]);return P.interpolate(p)},S=i.offsetX,w=i.offsetY,O=S===0||S,x=w===0||w;return{x:O?S:m(),y:x?w:v()}}var Bf="__NATIVE_FILE__",Wf="__NATIVE_URL__",Uf="__NATIVE_TEXT__",Vf="__NATIVE_HTML__";const Xl=Object.freeze(Object.defineProperty({__proto__:null,FILE:Bf,HTML:Vf,TEXT:Uf,URL:Wf},Symbol.toStringTag,{value:"Module"}));function po(t,e,n){var r=e.reduce(function(i,o){return i||t.getData(o)},"");return r??n}var en;function Pr(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var ra=(en={},Pr(en,Bf,{exposeProperties:{files:function(e){return Array.prototype.slice.call(e.files)},items:function(e){return e.items},dataTransfer:function(e){return e}},matchesTypes:["Files"]}),Pr(en,Vf,{exposeProperties:{html:function(e,n){return po(e,n,"")},dataTransfer:function(e){return e}},matchesTypes:["Html","text/html"]}),Pr(en,Wf,{exposeProperties:{urls:function(e,n){return po(e,n,"").split(`
|
|
100
100
|
`)},dataTransfer:function(e){return e}},matchesTypes:["Url","text/uri-list"]}),Pr(en,Uf,{exposeProperties:{text:function(e,n){return po(e,n,"")},dataTransfer:function(e){return e}},matchesTypes:["Text","text/plain"]}),en);function s$(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function l$(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function u$(t,e,n){return l$(t.prototype,e),t}function Jl(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var c$=function(){function t(e){s$(this,t),Jl(this,"item",void 0),Jl(this,"config",void 0),this.config=e,this.item={},this.initializeExposedProperties()}return u$(t,[{key:"initializeExposedProperties",value:function(){var n=this;Object.keys(this.config.exposeProperties).forEach(function(r){Object.defineProperty(n.item,r,{configurable:!0,enumerable:!0,get:function(){return console.warn(`Browser doesn't allow reading "`.concat(r,'" until the drop event.')),null}})})}},{key:"loadDataTransfer",value:function(n){var r=this;if(n){var i={};Object.keys(this.config.exposeProperties).forEach(function(o){i[o]={value:r.config.exposeProperties[o](n,r.config.matchesTypes),configurable:!0,enumerable:!0}}),Object.defineProperties(this.item,i)}}},{key:"canDrag",value:function(){return!0}},{key:"beginDrag",value:function(){return this.item}},{key:"isDragging",value:function(n,r){return r===n.getSourceId()}},{key:"endDrag",value:function(){}}]),t}();function d$(t,e){var n=new c$(ra[t]);return n.loadDataTransfer(e),n}function go(t){if(!t)return null;var e=Array.prototype.slice.call(t.types||[]);return Object.keys(ra).filter(function(n){var r=ra[n].matchesTypes;return r.some(function(i){return e.indexOf(i)>-1})})[0]||null}function f$(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function h$(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function p$(t,e,n){return h$(t.prototype,e),t}function vo(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var g$=function(){function t(e,n){f$(this,t),vo(this,"ownerDocument",null),vo(this,"globalContext",void 0),vo(this,"optionsArgs",void 0),this.globalContext=e,this.optionsArgs=n}return p$(t,[{key:"window",get:function(){if(this.globalContext)return this.globalContext;if(typeof window<"u")return window}},{key:"document",get:function(){var n;return(n=this.globalContext)!==null&&n!==void 0&&n.document?this.globalContext.document:this.window?this.window.document:void 0}},{key:"rootElement",get:function(){var n;return((n=this.optionsArgs)===null||n===void 0?void 0:n.rootElement)||this.window}}]),t}();function Ql(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter(function(i){return Object.getOwnPropertyDescriptor(t,i).enumerable})),n.push.apply(n,r)}return n}function Zl(t){for(var e=1;e<arguments.length;e++){var n=arguments[e]!=null?arguments[e]:{};e%2?Ql(Object(n),!0).forEach(function(r){te(t,r,n[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(n)):Ql(Object(n)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(n,r))})}return t}function v$(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function m$(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}function y$(t,e,n){return m$(t.prototype,e),t}function te(t,e,n){return e in t?Object.defineProperty(t,e,{value:n,enumerable:!0,configurable:!0,writable:!0}):t[e]=n,t}var b$=function(){function t(e,n,r){var i=this;v$(this,t),te(this,"options",void 0),te(this,"actions",void 0),te(this,"monitor",void 0),te(this,"registry",void 0),te(this,"enterLeaveCounter",void 0),te(this,"sourcePreviewNodes",new Map),te(this,"sourcePreviewNodeOptions",new Map),te(this,"sourceNodes",new Map),te(this,"sourceNodeOptions",new Map),te(this,"dragStartSourceIds",null),te(this,"dropTargetIds",[]),te(this,"dragEnterTargetIds",[]),te(this,"currentNativeSource",null),te(this,"currentNativeHandle",null),te(this,"currentDragSourceNode",null),te(this,"altKeyPressed",!1),te(this,"mouseMoveTimeoutTimer",null),te(this,"asyncEndDragFrameId",null),te(this,"dragOverTargetIds",null),te(this,"lastClientOffset",null),te(this,"hoverRafId",null),te(this,"getSourceClientOffset",function(o){var a=i.sourceNodes.get(o);return a&&Hf(a)||null}),te(this,"endDragNativeItem",function(){i.isDraggingNativeItem()&&(i.actions.endDrag(),i.currentNativeHandle&&i.registry.removeSource(i.currentNativeHandle),i.currentNativeHandle=null,i.currentNativeSource=null)}),te(this,"isNodeInDocument",function(o){return!!(o&&i.document&&i.document.body&&i.document.body.contains(o))}),te(this,"endDragIfSourceWasRemovedFromDOM",function(){var o=i.currentDragSourceNode;o==null||i.isNodeInDocument(o)||i.clearCurrentDragSourceNode()&&i.monitor.isDragging()&&i.actions.endDrag()}),te(this,"handleTopDragStartCapture",function(){i.clearCurrentDragSourceNode(),i.dragStartSourceIds=[]}),te(this,"handleTopDragStart",function(o){if(!o.defaultPrevented){var a=i.dragStartSourceIds;i.dragStartSourceIds=null;var s=Dr(o);i.monitor.isDragging()&&i.actions.endDrag(),i.actions.beginDrag(a||[],{publishSource:!1,getSourceClientOffset:i.getSourceClientOffset,clientOffset:s});var l=o.dataTransfer,u=go(l);if(i.monitor.isDragging()){if(l&&typeof l.setDragImage=="function"){var c=i.monitor.getSourceId(),p=i.sourceNodes.get(c),g=i.sourcePreviewNodes.get(c)||p;if(g){var h=i.getCurrentSourcePreviewNodeOptions(),y=h.anchorX,f=h.anchorY,v=h.offsetX,m=h.offsetY,S={anchorX:y,anchorY:f},w={offsetX:v,offsetY:m},O=a$(p,g,s,S,w);l.setDragImage(g,O.x,O.y)}}try{l==null||l.setData("application/json",{})}catch{}i.setCurrentDragSourceNode(o.target);var x=i.getCurrentSourcePreviewNodeOptions(),D=x.captureDraggingState;D?i.actions.publishDragSource():setTimeout(function(){return i.actions.publishDragSource()},0)}else if(u)i.beginDragNativeItem(u);else{if(l&&!l.types&&(o.target&&!o.target.hasAttribute||!o.target.hasAttribute("draggable")))return;o.preventDefault()}}}),te(this,"handleTopDragEndCapture",function(){i.clearCurrentDragSourceNode()&&i.monitor.isDragging()&&i.actions.endDrag()}),te(this,"handleTopDragEnterCapture",function(o){i.dragEnterTargetIds=[];var a=i.enterLeaveCounter.enter(o.target);if(!(!a||i.monitor.isDragging())){var s=o.dataTransfer,l=go(s);l&&i.beginDragNativeItem(l,s)}}),te(this,"handleTopDragEnter",function(o){var a=i.dragEnterTargetIds;if(i.dragEnterTargetIds=[],!!i.monitor.isDragging()){i.altKeyPressed=o.altKey,a.length>0&&i.actions.hover(a,{clientOffset:Dr(o)});var s=a.some(function(l){return i.monitor.canDropOnTarget(l)});s&&(o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect=i.getCurrentDropEffect()))}}),te(this,"handleTopDragOverCapture",function(){i.dragOverTargetIds=[]}),te(this,"handleTopDragOver",function(o){var a=i.dragOverTargetIds;if(i.dragOverTargetIds=[],!i.monitor.isDragging()){o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect="none");return}i.altKeyPressed=o.altKey,i.lastClientOffset=Dr(o),i.hoverRafId===null&&typeof requestAnimationFrame<"u"&&(i.hoverRafId=requestAnimationFrame(function(){i.monitor.isDragging()&&i.actions.hover(a||[],{clientOffset:i.lastClientOffset}),i.hoverRafId=null}));var s=(a||[]).some(function(l){return i.monitor.canDropOnTarget(l)});s?(o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect=i.getCurrentDropEffect())):i.isDraggingNativeItem()?o.preventDefault():(o.preventDefault(),o.dataTransfer&&(o.dataTransfer.dropEffect="none"))}),te(this,"handleTopDragLeaveCapture",function(o){i.isDraggingNativeItem()&&o.preventDefault();var a=i.enterLeaveCounter.leave(o.target);a&&i.isDraggingNativeItem()&&setTimeout(function(){return i.endDragNativeItem()},0)}),te(this,"handleTopDropCapture",function(o){if(i.dropTargetIds=[],i.isDraggingNativeItem()){var a;o.preventDefault(),(a=i.currentNativeSource)===null||a===void 0||a.loadDataTransfer(o.dataTransfer)}else go(o.dataTransfer)&&o.preventDefault();i.enterLeaveCounter.reset()}),te(this,"handleTopDrop",function(o){var a=i.dropTargetIds;i.dropTargetIds=[],i.actions.hover(a,{clientOffset:Dr(o)}),i.actions.drop({dropEffect:i.getCurrentDropEffect()}),i.isDraggingNativeItem()?i.endDragNativeItem():i.monitor.isDragging()&&i.actions.endDrag()}),te(this,"handleSelectStart",function(o){var a=o.target;typeof a.dragDrop=="function"&&(a.tagName==="INPUT"||a.tagName==="SELECT"||a.tagName==="TEXTAREA"||a.isContentEditable||(o.preventDefault(),a.dragDrop()))}),this.options=new g$(n,r),this.actions=e.getActions(),this.monitor=e.getMonitor(),this.registry=e.getRegistry(),this.enterLeaveCounter=new QE(this.isNodeInDocument)}return y$(t,[{key:"profile",value:function(){var n,r;return{sourcePreviewNodes:this.sourcePreviewNodes.size,sourcePreviewNodeOptions:this.sourcePreviewNodeOptions.size,sourceNodeOptions:this.sourceNodeOptions.size,sourceNodes:this.sourceNodes.size,dragStartSourceIds:((n=this.dragStartSourceIds)===null||n===void 0?void 0:n.length)||0,dropTargetIds:this.dropTargetIds.length,dragEnterTargetIds:this.dragEnterTargetIds.length,dragOverTargetIds:((r=this.dragOverTargetIds)===null||r===void 0?void 0:r.length)||0}}},{key:"window",get:function(){return this.options.window}},{key:"document",get:function(){return this.options.document}},{key:"rootElement",get:function(){return this.options.rootElement}},{key:"setup",value:function(){var n=this.rootElement;if(n!==void 0){if(n.__isReactDndBackendSetUp)throw new Error("Cannot have two HTML5 backends at the same time.");n.__isReactDndBackendSetUp=!0,this.addEventListeners(n)}}},{key:"teardown",value:function(){var n=this.rootElement;if(n!==void 0&&(n.__isReactDndBackendSetUp=!1,this.removeEventListeners(this.rootElement),this.clearCurrentDragSourceNode(),this.asyncEndDragFrameId)){var r;(r=this.window)===null||r===void 0||r.cancelAnimationFrame(this.asyncEndDragFrameId)}}},{key:"connectDragPreview",value:function(n,r,i){var o=this;return this.sourcePreviewNodeOptions.set(n,i),this.sourcePreviewNodes.set(n,r),function(){o.sourcePreviewNodes.delete(n),o.sourcePreviewNodeOptions.delete(n)}}},{key:"connectDragSource",value:function(n,r,i){var o=this;this.sourceNodes.set(n,r),this.sourceNodeOptions.set(n,i);var a=function(u){return o.handleDragStart(u,n)},s=function(u){return o.handleSelectStart(u)};return r.setAttribute("draggable","true"),r.addEventListener("dragstart",a),r.addEventListener("selectstart",s),function(){o.sourceNodes.delete(n),o.sourceNodeOptions.delete(n),r.removeEventListener("dragstart",a),r.removeEventListener("selectstart",s),r.setAttribute("draggable","false")}}},{key:"connectDropTarget",value:function(n,r){var i=this,o=function(u){return i.handleDragEnter(u,n)},a=function(u){return i.handleDragOver(u,n)},s=function(u){return i.handleDrop(u,n)};return r.addEventListener("dragenter",o),r.addEventListener("dragover",a),r.addEventListener("drop",s),function(){r.removeEventListener("dragenter",o),r.removeEventListener("dragover",a),r.removeEventListener("drop",s)}}},{key:"addEventListeners",value:function(n){n.addEventListener&&(n.addEventListener("dragstart",this.handleTopDragStart),n.addEventListener("dragstart",this.handleTopDragStartCapture,!0),n.addEventListener("dragend",this.handleTopDragEndCapture,!0),n.addEventListener("dragenter",this.handleTopDragEnter),n.addEventListener("dragenter",this.handleTopDragEnterCapture,!0),n.addEventListener("dragleave",this.handleTopDragLeaveCapture,!0),n.addEventListener("dragover",this.handleTopDragOver),n.addEventListener("dragover",this.handleTopDragOverCapture,!0),n.addEventListener("drop",this.handleTopDrop),n.addEventListener("drop",this.handleTopDropCapture,!0))}},{key:"removeEventListeners",value:function(n){n.removeEventListener&&(n.removeEventListener("dragstart",this.handleTopDragStart),n.removeEventListener("dragstart",this.handleTopDragStartCapture,!0),n.removeEventListener("dragend",this.handleTopDragEndCapture,!0),n.removeEventListener("dragenter",this.handleTopDragEnter),n.removeEventListener("dragenter",this.handleTopDragEnterCapture,!0),n.removeEventListener("dragleave",this.handleTopDragLeaveCapture,!0),n.removeEventListener("dragover",this.handleTopDragOver),n.removeEventListener("dragover",this.handleTopDragOverCapture,!0),n.removeEventListener("drop",this.handleTopDrop),n.removeEventListener("drop",this.handleTopDropCapture,!0))}},{key:"getCurrentSourceNodeOptions",value:function(){var n=this.monitor.getSourceId(),r=this.sourceNodeOptions.get(n);return Zl({dropEffect:this.altKeyPressed?"copy":"move"},r||{})}},{key:"getCurrentDropEffect",value:function(){return this.isDraggingNativeItem()?"copy":this.getCurrentSourceNodeOptions().dropEffect}},{key:"getCurrentSourcePreviewNodeOptions",value:function(){var n=this.monitor.getSourceId(),r=this.sourcePreviewNodeOptions.get(n);return Zl({anchorX:.5,anchorY:.5,captureDraggingState:!1},r||{})}},{key:"isDraggingNativeItem",value:function(){var n=this.monitor.getItemType();return Object.keys(Xl).some(function(r){return Xl[r]===n})}},{key:"beginDragNativeItem",value:function(n,r){this.clearCurrentDragSourceNode(),this.currentNativeSource=d$(n,r),this.currentNativeHandle=this.registry.addSource(n,this.currentNativeSource),this.actions.beginDrag([this.currentNativeHandle])}},{key:"setCurrentDragSourceNode",value:function(n){var r=this;this.clearCurrentDragSourceNode(),this.currentDragSourceNode=n;var i=1e3;this.mouseMoveTimeoutTimer=setTimeout(function(){var o;return(o=r.rootElement)===null||o===void 0?void 0:o.addEventListener("mousemove",r.endDragIfSourceWasRemovedFromDOM,!0)},i)}},{key:"clearCurrentDragSourceNode",value:function(){if(this.currentDragSourceNode){if(this.currentDragSourceNode=null,this.rootElement){var n;(n=this.window)===null||n===void 0||n.clearTimeout(this.mouseMoveTimeoutTimer||void 0),this.rootElement.removeEventListener("mousemove",this.endDragIfSourceWasRemovedFromDOM,!0)}return this.mouseMoveTimeoutTimer=null,!0}return!1}},{key:"handleDragStart",value:function(n,r){n.defaultPrevented||(this.dragStartSourceIds||(this.dragStartSourceIds=[]),this.dragStartSourceIds.unshift(r))}},{key:"handleDragEnter",value:function(n,r){this.dragEnterTargetIds.unshift(r)}},{key:"handleDragOver",value:function(n,r){this.dragOverTargetIds===null&&(this.dragOverTargetIds=[]),this.dragOverTargetIds.unshift(r)}},{key:"handleDrop",value:function(n,r){this.dropTargetIds.unshift(r)}}]),t}(),Or;function S$(){return Or||(Or=new Image,Or.src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw=="),Or}var w$=function(e,n,r){return new b$(e,n,r)};function E$(t){const e=Oe(),n=e.selectedIds,[r,i,o]=CE(()=>({canDrag:()=>t.isDraggable,type:"NODE",item:()=>{const a=e.isSelected(t.id)?Array.from(n):[t.id];return e.dispatch(wn.dragStart(t.id,a)),{id:t.id,dragIds:a}},end:()=>{e.hideCursor(),e.dispatch(wn.dragEnd())}}),[n,t]);return d.useEffect(()=>{o(S$())},[o]),i}function $$(t,e){const n=t.getBoundingClientRect(),r=e.x-Math.round(n.x),i=e.y-Math.round(n.y),o=n.height,a=i<o/2,s=!a,l=o/4,u=i>l&&i<o-l;return{x:r,inTopHalf:a,inBottomHalf:s,inMiddle:u,atTop:!u&&a,atBottom:!u&&s}}function x$(t,e,n,r){return t?t.isInternal?r.atTop?[e,t]:r.inMiddle?[t,t]:[t,n]:r.inTopHalf?[e,t]:[t,n]:[e,null]}function Ir(t,e){return{parentId:t||null,index:e}}function tn(t,e){return{type:"line",index:t,level:e}}function C$(t){return{type:"highlight",id:t}}function mo(t,e){var n;let r=t;for(;r.parent&&r.level>e;)r=r.parent;const i=((n=r.parent)===null||n===void 0?void 0:n.id)||null,o=mf(r)+1;return{parentId:i,index:o}}function Gf(t){var e;const n=$$(t.element,t.offset),r=t.indent,i=Math.round(Math.max(0,n.x-r)/r),{node:o,nextNode:a,prevNode:s}=t,[l,u]=x$(o,s,a,n);if(o&&o.isInternal&&n.inMiddle)return{drop:Ir(o.id,null),cursor:C$(o.id)};if(!l)return{drop:Ir((e=u==null?void 0:u.parent)===null||e===void 0?void 0:e.id,0),cursor:tn(0,0)};if(hf(l)){const c=Mr(i,(u==null?void 0:u.level)||0,l.level);return{drop:mo(l,c),cursor:tn(l.rowIndex+1,c)}}if(pf(l)){const c=Mr(i,(u==null?void 0:u.level)||0,l.level);return{drop:mo(l,c),cursor:tn(l.rowIndex+1,c)}}if(gf(l)){const c=Mr(i,0,l.level+1);return c>l.level?{drop:Ir(l.id,0),cursor:tn(l.rowIndex+1,c)}:{drop:mo(l,c),cursor:tn(l.rowIndex+1,c)}}return{drop:Ir(l==null?void 0:l.id,0),cursor:tn(l.rowIndex+1,l.level+1)}}function T$(t,e){const n=Oe(),[r,i]=Ff(()=>({accept:"NODE",canDrop:()=>n.canDrop(),hover:(o,a)=>{const s=a.getClientOffset();if(!t.current||!s)return;const{cursor:l,drop:u}=Gf({element:t.current,offset:s,indent:n.indent,node:e,prevNode:e.prev,nextNode:e.next});u&&n.dispatch(wn.hovering(u.parentId,u.index)),a.canDrop()?l&&n.showCursor(l):n.hideCursor()},drop:(o,a)=>{if(!a.canDrop())return null;let{parentId:s,index:l,dragIds:u}=n.state.dnd;Ef(n.props.onMove,{dragIds:u,parentId:s===er?null:s,index:l===null?0:l,dragNodes:n.dragNodes,parentNode:n.get(s)}),n.open(s)}}),[e,t.current,n.props]);return i}function D$(t){const e=Oe(),n=e.at(t);if(!n)throw new Error(`Could not find node for index: ${t}`);return d.useMemo(()=>{const r=n.clone();return e.visibleNodes[t]=r,r},[...Object.values(n.state),n])}const P$=d.memo(function({index:e,style:n}){ff(),qb();const r=Oe(),i=D$(e),o=d.useRef(null),a=E$(i),s=T$(o,i),l=d.useCallback(f=>{o.current=f,s(f)},[s]),u=r.indent*i.level,c=d.useMemo(()=>({paddingLeft:u}),[u]),p=d.useMemo(()=>{var f,v;return Object.assign(Object.assign({},n),{top:parseFloat(n.top)+((v=(f=r.props.padding)!==null&&f!==void 0?f:r.props.paddingTop)!==null&&v!==void 0?v:0)})},[n,r.props.padding,r.props.paddingTop]),g={role:"treeitem","aria-level":i.level+1,"aria-selected":i.isSelected,"aria-expanded":i.isOpen,style:p,tabIndex:-1,className:r.props.rowClassName};d.useEffect(()=>{var f;!i.isEditing&&i.isFocused&&((f=o.current)===null||f===void 0||f.focus({preventScroll:!0}))},[i.isEditing,i.isFocused,o.current]);const h=r.renderNode,y=r.renderRow;return T.jsx(y,{node:i,innerRef:l,attrs:g,children:T.jsx(h,{node:i,tree:r,style:c,dragHandle:a})})});let yo="",eu=null;function qf(){ff();const t=Oe();return T.jsx("div",{role:"tree",style:{height:t.height,width:t.width,minHeight:0,minWidth:0},onContextMenu:t.props.onContextMenu,onClick:t.props.onClick,tabIndex:0,onFocus:e=>{e.currentTarget.contains(e.relatedTarget)||t.onFocus()},onBlur:e=>{e.currentTarget.contains(e.relatedTarget)||t.onBlur()},onKeyDown:e=>{var n;if(t.isEditing)return;if(e.key==="Backspace"){if(!t.props.onDelete)return;const i=Array.from(t.selectedIds);if(i.length>1){let o=t.mostRecentNode;for(;o&&o.isSelected;)o=o.nextSibling;o||(o=t.lastNode),t.focus(o,{scroll:!1}),t.delete(Array.from(i))}else{const o=t.focusedNode;if(o){const a=o.nextSibling,s=o.parent;t.focus(a||s,{scroll:!1}),t.delete(o)}}return}if(e.key==="Tab"&&!e.shiftKey){e.preventDefault(),yf(e.currentTarget);return}if(e.key==="Tab"&&e.shiftKey){e.preventDefault(),bf(e.currentTarget);return}if(e.key==="ArrowDown"){e.preventDefault();const i=t.nextNode;if(e.metaKey){t.select(t.focusedNode),t.activate(t.focusedNode);return}else if(!e.shiftKey||t.props.disableMultiSelection){t.focus(i);return}else{if(!i)return;const o=t.focusedNode;o?o.isSelected?t.selectContiguous(i):t.selectMulti(i):t.focus(t.firstNode);return}}if(e.key==="ArrowUp"){e.preventDefault();const i=t.prevNode;if(!e.shiftKey||t.props.disableMultiSelection){t.focus(i);return}else{if(!i)return;const o=t.focusedNode;o?o.isSelected?t.selectContiguous(i):t.selectMulti(i):t.focus(t.lastNode);return}}if(e.key==="ArrowRight"){const i=t.focusedNode;if(!i)return;i.isInternal&&i.isOpen?t.focus(t.nextNode):i.isInternal&&t.open(i.id);return}if(e.key==="ArrowLeft"){const i=t.focusedNode;if(!i||i.isRoot)return;i.isInternal&&i.isOpen?t.close(i.id):!((n=i.parent)===null||n===void 0)&&n.isRoot||t.focus(i.parent);return}if(e.key==="a"&&e.metaKey&&!t.props.disableMultiSelection){e.preventDefault(),t.selectAll();return}if(e.key==="a"&&!e.metaKey&&t.props.onCreate){t.createLeaf();return}if(e.key==="A"&&!e.metaKey){if(!t.props.onCreate)return;t.createInternal();return}if(e.key==="Home"){e.preventDefault(),t.focus(t.firstNode);return}if(e.key==="End"){e.preventDefault(),t.focus(t.lastNode);return}if(e.key==="Enter"){const i=t.focusedNode;if(!i||!i.isEditable||!t.props.onRename)return;setTimeout(()=>{i&&t.edit(i)});return}if(e.key===" "){e.preventDefault();const i=t.focusedNode;if(!i)return;i.isLeaf?(i.select(),i.activate()):i.toggle();return}if(e.key==="*"){const i=t.focusedNode;if(!i)return;t.openSiblings(i);return}if(e.key==="PageUp"){e.preventDefault(),t.pageUp();return}e.key==="PageDown"&&(e.preventDefault(),t.pageDown()),clearTimeout(eu),yo+=e.key,eu=setTimeout(()=>{yo=""},600);const r=t.visibleNodes.find(i=>{const o=i.data.name;return typeof o=="string"?o.toLowerCase().startsWith(yo):!1});r&&t.focus(r.id)},children:T.jsx(_S,{className:t.props.className,outerRef:t.listEl,itemCount:t.visibleNodes.length,height:t.height,width:t.width,itemSize:t.rowHeight,overscanCount:t.overscanCount,itemKey:e=>{var n;return((n=t.visibleNodes[e])===null||n===void 0?void 0:n.id)||e},outerElementType:RS,innerElementType:KS,onScroll:t.props.onScroll,onItemsRendered:t.onItemsRendered.bind(t),ref:t.list,children:P$})})}function tu(t){return t.isFiltered?I$(t.root,t.isMatch.bind(t)):O$(t.root)}function O$(t){const e=[];function n(r){var i;r.level>=0&&e.push(r),r.isOpen&&((i=r.children)===null||i===void 0||i.forEach(n))}return n(t),e.forEach(Yf),e}function I$(t,e){const n={},r=[];function i(a){if(!a.isRoot&&e(a)){n[a.id]=!0;let l=a.parent;for(;l;)n[l.id]=!0,l=l.parent}if(a.children)for(let l of a.children)i(l)}function o(a){var s;a.level>=0&&n[a.id]&&r.push(a),a.isOpen&&((s=a.children)===null||s===void 0||s.forEach(o))}return i(t),o(t),r.forEach(Yf),r}function Yf(t,e){t.rowIndex=e}const nu=t=>t.reduce((e,n,r)=>(e[n.id]=r,e),{});var bo=function(t,e,n,r){function i(o){return o instanceof n?o:new n(function(a){a(o)})}return new(n||(n=Promise))(function(o,a){function s(c){try{u(r.next(c))}catch(p){a(p)}}function l(c){try{u(r.throw(c))}catch(p){a(p)}}function u(c){c.done?o(c.value):i(c.value).then(s,l)}u((r=r.apply(t,e||[])).next())})};const{safeRun:he,identify:et,identifyNull:je}=eS;class Wn{constructor(e,n,r,i){this.store=e,this.props=n,this.list=r,this.listEl=i,this.visibleStartIndex=0,this.visibleStopIndex=0,this.root=fl(this),this.visibleNodes=tu(this),this.idToIndex=nu(this.visibleNodes)}update(e){this.props=e,this.root=fl(this),this.visibleNodes=tu(this),this.idToIndex=nu(this.visibleNodes)}dispatch(e){return this.store.dispatch(e)}get state(){return this.store.getState()}get openState(){return this.state.nodes.open.unfiltered}get width(){var e;return(e=this.props.width)!==null&&e!==void 0?e:300}get height(){var e;return(e=this.props.height)!==null&&e!==void 0?e:500}get indent(){var e;return(e=this.props.indent)!==null&&e!==void 0?e:24}get rowHeight(){var e;return(e=this.props.rowHeight)!==null&&e!==void 0?e:24}get overscanCount(){var e;return(e=this.props.overscanCount)!==null&&e!==void 0?e:1}get searchTerm(){return(this.props.searchTerm||"").trim()}get matchFn(){var e;const n=(e=this.props.searchMatch)!==null&&e!==void 0?e:(r,i)=>JSON.stringify(Object.values(r.data)).toLocaleLowerCase().includes(i.toLocaleLowerCase());return r=>n(r,this.searchTerm)}accessChildren(e){var n;const r=this.props.childrenAccessor||"children";return(n=jn(e,r))!==null&&n!==void 0?n:null}accessId(e){const n=this.props.idAccessor||"id",r=jn(e,n);if(!r)throw new Error("Data must contain an 'id' property or props.idAccessor must return a string");return r}get firstNode(){var e;return(e=this.visibleNodes[0])!==null&&e!==void 0?e:null}get lastNode(){var e;return(e=this.visibleNodes[this.visibleNodes.length-1])!==null&&e!==void 0?e:null}get focusedNode(){var e;return(e=this.get(this.state.nodes.focus.id))!==null&&e!==void 0?e:null}get mostRecentNode(){var e;return(e=this.get(this.state.nodes.selection.mostRecent))!==null&&e!==void 0?e:null}get nextNode(){const e=this.indexOf(this.focusedNode);return e===null?null:this.at(e+1)}get prevNode(){const e=this.indexOf(this.focusedNode);return e===null?null:this.at(e-1)}get(e){return e&&e in this.idToIndex&&this.visibleNodes[this.idToIndex[e]]||null}at(e){return this.visibleNodes[e]||null}nodesBetween(e,n){var r;if(e===null||n===null)return[];const i=(r=this.indexOf(e))!==null&&r!==void 0?r:0,o=this.indexOf(n);if(o===null)return[];const a=Math.min(i,o),s=Math.max(i,o);return this.visibleNodes.slice(a,s+1)}indexOf(e){const n=wf(e);return n?this.idToIndex[n]:null}get editingId(){return this.state.nodes.edit.id}createInternal(){return this.create({type:"internal"})}createLeaf(){return this.create({type:"leaf"})}create(){return bo(this,arguments,void 0,function*(e={}){var n,r;const i=e.parentId===void 0?Cf(this):e.parentId,o=(n=e.index)!==null&&n!==void 0?n:xf(this),a=(r=e.type)!==null&&r!==void 0?r:"leaf",s=yield he(this.props.onCreate,{type:a,parentId:i,index:o,parentNode:this.get(i)});s&&(this.focus(s),setTimeout(()=>{this.edit(s).then(()=>{this.select(s),this.activate(s)})}))})}delete(e){return bo(this,void 0,void 0,function*(){if(!e)return;const r=(Array.isArray(e)?e:[e]).map(et),i=r.map(o=>this.get(o)).filter(o=>!!o);yield he(this.props.onDelete,{nodes:i,ids:r})})}edit(e){const n=et(e);return this.resolveEdit({cancelled:!0}),this.scrollTo(n),this.dispatch(io(n)),new Promise(r=>{Wn.editPromise=r})}submit(e,n){return bo(this,void 0,void 0,function*(){if(!e)return;const r=et(e);yield he(this.props.onRename,{id:r,name:n,node:this.get(r)}),this.dispatch(io(null)),this.resolveEdit({cancelled:!1,value:n}),setTimeout(()=>this.onFocus())})}reset(){this.dispatch(io(null)),this.resolveEdit({cancelled:!0}),setTimeout(()=>this.onFocus())}activate(e){const n=this.get(je(e));n&&he(this.props.onActivate,n)}resolveEdit(e){const n=Wn.editPromise;n&&n(e),Wn.editPromise=null}get selectedIds(){return this.state.nodes.selection.ids}get selectedNodes(){let e=[];for(let n of Array.from(this.selectedIds)){const r=this.get(n);r&&e.push(r)}return e}focus(e,n={}){e&&(this.props.selectionFollowsFocus?this.select(e):(this.dispatch(Xt(et(e))),n.scroll!==!1&&this.scrollTo(e),this.focusedNode&&he(this.props.onFocus,this.focusedNode)))}pageUp(){var e,n;const r=this.visibleStartIndex,o=this.visibleStopIndex-r;let a=(n=(e=this.focusedNode)===null||e===void 0?void 0:e.rowIndex)!==null&&n!==void 0?n:0;a>r?a=r:a=Math.max(r-o,0),this.focus(this.at(a))}pageDown(){var e,n;const r=this.visibleStartIndex,i=this.visibleStopIndex,o=i-r;let a=(n=(e=this.focusedNode)===null||e===void 0?void 0:e.rowIndex)!==null&&n!==void 0?n:0;a<i?a=i:a=Math.min(a+o,this.visibleNodes.length-1),this.focus(this.at(a))}select(e,n={}){if(!e)return;const r=n.focus!==!1,i=et(e);r&&this.dispatch(Xt(i)),this.dispatch(Fe.only(i)),this.dispatch(Fe.anchor(i)),this.dispatch(Fe.mostRecent(i)),this.scrollTo(i,n.align),this.focusedNode&&r&&he(this.props.onFocus,this.focusedNode),he(this.props.onSelect,this.selectedNodes)}deselect(e){if(!e)return;const n=et(e);this.dispatch(Fe.remove(n)),he(this.props.onSelect,this.selectedNodes)}selectMulti(e){const n=this.get(je(e));n&&(this.dispatch(Xt(n.id)),this.dispatch(Fe.add(n.id)),this.dispatch(Fe.anchor(n.id)),this.dispatch(Fe.mostRecent(n.id)),this.scrollTo(n),this.focusedNode&&he(this.props.onFocus,this.focusedNode),he(this.props.onSelect,this.selectedNodes))}selectContiguous(e){if(!e)return;const n=et(e),{anchor:r,mostRecent:i}=this.state.nodes.selection;this.dispatch(Xt(n)),this.dispatch(Fe.remove(this.nodesBetween(r,i))),this.dispatch(Fe.add(this.nodesBetween(r,je(n)))),this.dispatch(Fe.mostRecent(n)),this.scrollTo(n),this.focusedNode&&he(this.props.onFocus,this.focusedNode),he(this.props.onSelect,this.selectedNodes)}deselectAll(){this.setSelection({ids:[],anchor:null,mostRecent:null}),he(this.props.onSelect,this.selectedNodes)}selectAll(){var e;this.setSelection({ids:Object.keys(this.idToIndex),anchor:this.firstNode,mostRecent:this.lastNode}),this.dispatch(Xt((e=this.lastNode)===null||e===void 0?void 0:e.id)),this.focusedNode&&he(this.props.onFocus,this.focusedNode),he(this.props.onSelect,this.selectedNodes)}setSelection(e){var n;const r=new Set((n=e.ids)===null||n===void 0?void 0:n.map(et)),i=je(e.anchor),o=je(e.mostRecent);this.dispatch(Fe.set({ids:r,anchor:i,mostRecent:o})),he(this.props.onSelect,this.selectedNodes)}get cursorParentId(){const{cursor:e}=this.state.dnd;switch(e.type){case"highlight":return e.id;default:return null}}get cursorOverFolder(){return this.state.dnd.cursor.type==="highlight"}get dragNodes(){return this.state.dnd.dragIds.map(e=>this.get(e)).filter(e=>!!e)}get dragNode(){return this.get(this.state.nodes.drag.id)}get dragDestinationParent(){return this.get(this.state.nodes.drag.destinationParentId)}get dragDestinationIndex(){return this.state.nodes.drag.destinationIndex}canDrop(){var e;if(this.isFiltered)return!1;const n=(e=this.get(this.state.dnd.parentId))!==null&&e!==void 0?e:this.root,r=this.dragNodes,i=this.props.disableDrop;for(const o of r)if(!o||!n||o.isInternal&&vf(n,o))return!1;return typeof i=="function"?!i({parentNode:n,dragNodes:this.dragNodes,index:this.state.dnd.index||0}):typeof i=="string"?!n.data[i]:typeof i=="boolean"?!i:!0}hideCursor(){this.dispatch(wn.cursor({type:"none"}))}showCursor(e){this.dispatch(wn.cursor(e))}open(e){const n=je(e);n&&(this.isOpen(n)||(this.dispatch(Yo.open(n,this.isFiltered)),he(this.props.onToggle,n)))}close(e){const n=je(e);n&&this.isOpen(n)&&(this.dispatch(Yo.close(n,this.isFiltered)),he(this.props.onToggle,n))}toggle(e){const n=je(e);if(n)return this.isOpen(n)?this.close(n):this.open(n)}openParents(e){const n=je(e);if(!n)return;const r=Ma(this.root,n);let i=r==null?void 0:r.parent;for(;i;)this.open(i.id),i=i.parent}openSiblings(e){const n=e.parent;if(!n)this.toggle(e.id);else if(n.children){const r=e.isOpen;for(let i of n.children)i.isInternal&&(r?this.close(i.id):this.open(i.id));this.scrollTo(this.focusedNode)}}openAll(){ii(this.root,e=>{e.isInternal&&e.open()})}closeAll(){ii(this.root,e=>{e.isInternal&&e.close()})}scrollTo(e,n="smart"){if(!e)return;const r=et(e);return this.openParents(r),$f(()=>r in this.idToIndex).then(()=>{var i;const o=this.idToIndex[r];o!==void 0&&((i=this.list.current)===null||i===void 0||i.scrollToItem(o,n))}).catch(()=>{})}get isEditing(){return this.state.nodes.edit.id!==null}get isFiltered(){var e;return!!(!((e=this.props.searchTerm)===null||e===void 0)&&e.trim())}get hasFocus(){return this.state.nodes.focus.treeFocused}get hasNoSelection(){return this.state.nodes.selection.ids.size===0}get hasOneSelection(){return this.state.nodes.selection.ids.size===1}get hasMultipleSelections(){return this.state.nodes.selection.ids.size>1}isSelected(e){return e?this.state.nodes.selection.ids.has(e):!1}isOpen(e){var n,r,i;if(!e)return!1;if(e===er)return!0;const o=(n=this.props.openByDefault)!==null&&n!==void 0?n:!0;return this.isFiltered?(r=this.state.nodes.open.filtered[e])!==null&&r!==void 0?r:!0:(i=this.state.nodes.open.unfiltered[e])!==null&&i!==void 0?i:o}isEditable(e){const n=this.props.disableEdit||(()=>!1);return!jn(e,n)}isDraggable(e){const n=this.props.disableDrag||(()=>!1);return!jn(e,n)}isDragging(e){const n=je(e);return n?this.state.nodes.drag.id===n:!1}isFocused(e){return this.hasFocus&&this.state.nodes.focus.id===e}isMatch(e){return this.matchFn(e)}willReceiveDrop(e){const n=je(e);if(!n)return!1;const{destinationParentId:r,destinationIndex:i}=this.state.nodes.drag;return n===r&&i===null}onFocus(){const e=this.focusedNode||this.firstNode;e&&this.dispatch(Xt(e.id))}onBlur(){this.dispatch(cS())}onItemsRendered(e){this.visibleStartIndex=e.visibleStartIndex,this.visibleStopIndex=e.visibleStopIndex}get renderContainer(){return this.props.renderContainer||qf}get renderRow(){return this.props.renderRow||oS}get renderNode(){return this.props.children||aS}get renderDragPreview(){return this.props.renderDragPreview||Tf}get renderCursor(){return this.props.renderCursor||iS}}function Ee(t){return`Minified Redux error #${t}; visit https://redux.js.org/Errors?code=${t} for the full message or use the non-minified dev environment for full errors. `}var _$=typeof Symbol=="function"&&Symbol.observable||"@@observable",ru=_$,So=()=>Math.random().toString(36).substring(7).split("").join("."),k$={INIT:`@@redux/INIT${So()}`,REPLACE:`@@redux/REPLACE${So()}`,PROBE_UNKNOWN_ACTION:()=>`@@redux/PROBE_UNKNOWN_ACTION${So()}`},Pt=k$;function Xf(t){if(typeof t!="object"||t===null)return!1;let e=t;for(;Object.getPrototypeOf(e)!==null;)e=Object.getPrototypeOf(e);return Object.getPrototypeOf(t)===e||Object.getPrototypeOf(t)===null}function N$(t){if(t===void 0)return"undefined";if(t===null)return"null";const e=typeof t;switch(e){case"boolean":case"string":case"number":case"symbol":case"function":return e}if(Array.isArray(t))return"array";if(A$(t))return"date";if(M$(t))return"error";const n=R$(t);switch(n){case"Symbol":case"Promise":case"WeakMap":case"WeakSet":case"Map":case"Set":return n}return Object.prototype.toString.call(t).slice(8,-1).toLowerCase().replace(/\s/g,"")}function R$(t){return typeof t.constructor=="function"?t.constructor.name:null}function M$(t){return t instanceof Error||typeof t.message=="string"&&t.constructor&&typeof t.constructor.stackTraceLimit=="number"}function A$(t){return t instanceof Date?!0:typeof t.toDateString=="function"&&typeof t.getDate=="function"&&typeof t.setDate=="function"}function ct(t){let e=typeof t;return process.env.NODE_ENV!=="production"&&(e=N$(t)),e}function Jf(t,e,n){if(typeof t!="function")throw new Error(process.env.NODE_ENV==="production"?Ee(2):`Expected the root reducer to be a function. Instead, received: '${ct(t)}'`);if(typeof e=="function"&&typeof n=="function"||typeof n=="function"&&typeof arguments[3]=="function")throw new Error(process.env.NODE_ENV==="production"?Ee(0):"It looks like you are passing several store enhancers to createStore(). This is not supported. Instead, compose them together to a single function. See https://redux.js.org/tutorials/fundamentals/part-4-store#creating-a-store-with-enhancers for an example.");if(typeof e=="function"&&typeof n>"u"&&(n=e,e=void 0),typeof n<"u"){if(typeof n!="function")throw new Error(process.env.NODE_ENV==="production"?Ee(1):`Expected the enhancer to be a function. Instead, received: '${ct(n)}'`);return n(Jf)(t,e)}let r=t,i=e,o=new Map,a=o,s=0,l=!1;function u(){a===o&&(a=new Map,o.forEach((v,m)=>{a.set(m,v)}))}function c(){if(l)throw new Error(process.env.NODE_ENV==="production"?Ee(3):"You may not call store.getState() while the reducer is executing. The reducer has already received the state as an argument. Pass it down from the top reducer instead of reading it from the store.");return i}function p(v){if(typeof v!="function")throw new Error(process.env.NODE_ENV==="production"?Ee(4):`Expected the listener to be a function. Instead, received: '${ct(v)}'`);if(l)throw new Error(process.env.NODE_ENV==="production"?Ee(5):"You may not call store.subscribe() while the reducer is executing. If you would like to be notified after the store has been updated, subscribe from a component and invoke store.getState() in the callback to access the latest state. See https://redux.js.org/api/store#subscribelistener for more details.");let m=!0;u();const S=s++;return a.set(S,v),function(){if(m){if(l)throw new Error(process.env.NODE_ENV==="production"?Ee(6):"You may not unsubscribe from a store listener while the reducer is executing. See https://redux.js.org/api/store#subscribelistener for more details.");m=!1,u(),a.delete(S),o=null}}}function g(v){if(!Xf(v))throw new Error(process.env.NODE_ENV==="production"?Ee(7):`Actions must be plain objects. Instead, the actual type was: '${ct(v)}'. You may need to add middleware to your store setup to handle dispatching other values, such as 'redux-thunk' to handle dispatching functions. See https://redux.js.org/tutorials/fundamentals/part-4-store#middleware and https://redux.js.org/tutorials/fundamentals/part-6-async-logic#using-the-redux-thunk-middleware for examples.`);if(typeof v.type>"u")throw new Error(process.env.NODE_ENV==="production"?Ee(8):'Actions may not have an undefined "type" property. You may have misspelled an action type string constant.');if(typeof v.type!="string")throw new Error(process.env.NODE_ENV==="production"?Ee(17):`Action "type" property must be a string. Instead, the actual type was: '${ct(v.type)}'. Value was: '${v.type}' (stringified)`);if(l)throw new Error(process.env.NODE_ENV==="production"?Ee(9):"Reducers may not dispatch actions.");try{l=!0,i=r(i,v)}finally{l=!1}return(o=a).forEach(S=>{S()}),v}function h(v){if(typeof v!="function")throw new Error(process.env.NODE_ENV==="production"?Ee(10):`Expected the nextReducer to be a function. Instead, received: '${ct(v)}`);r=v,g({type:Pt.REPLACE})}function y(){const v=p;return{subscribe(m){if(typeof m!="object"||m===null)throw new Error(process.env.NODE_ENV==="production"?Ee(11):`Expected the observer to be an object. Instead, received: '${ct(m)}'`);function S(){const O=m;O.next&&O.next(c())}return S(),{unsubscribe:v(S)}},[ru](){return this}}}return g({type:Pt.INIT}),{dispatch:g,subscribe:p,getState:c,replaceReducer:h,[ru]:y}}function iu(t){typeof console<"u"&&typeof console.error=="function"&&console.error(t);try{throw new Error(t)}catch{}}function K$(t,e,n,r){const i=Object.keys(e),o=n&&n.type===Pt.INIT?"preloadedState argument passed to createStore":"previous state received by the reducer";if(i.length===0)return"Store does not have a valid reducer. Make sure the argument passed to combineReducers is an object whose values are reducers.";if(!Xf(t))return`The ${o} has unexpected type of "${ct(t)}". Expected argument to be an object with the following keys: "${i.join('", "')}"`;const a=Object.keys(t).filter(s=>!e.hasOwnProperty(s)&&!r[s]);if(a.forEach(s=>{r[s]=!0}),!(n&&n.type===Pt.REPLACE)&&a.length>0)return`Unexpected ${a.length>1?"keys":"key"} "${a.join('", "')}" found in ${o}. Expected to find one of the known reducer keys instead: "${i.join('", "')}". Unexpected keys will be ignored.`}function L$(t){Object.keys(t).forEach(e=>{const n=t[e];if(typeof n(void 0,{type:Pt.INIT})>"u")throw new Error(process.env.NODE_ENV==="production"?Ee(12):`The slice reducer for key "${e}" returned undefined during initialization. If the state passed to the reducer is undefined, you must explicitly return the initial state. The initial state may not be undefined. If you don't want to set a value for this reducer, you can use null instead of undefined.`);if(typeof n(void 0,{type:Pt.PROBE_UNKNOWN_ACTION()})>"u")throw new Error(process.env.NODE_ENV==="production"?Ee(13):`The slice reducer for key "${e}" returned undefined when probed with a random type. Don't try to handle '${Pt.INIT}' or other actions in "redux/*" namespace. They are considered private. Instead, you must return the current state for any unknown actions, unless it is undefined, in which case you must return the initial state, regardless of the action type. The initial state may not be undefined, but can be null.`)})}function ou(t){const e=Object.keys(t),n={};for(let a=0;a<e.length;a++){const s=e[a];process.env.NODE_ENV!=="production"&&typeof t[s]>"u"&&iu(`No reducer provided for key "${s}"`),typeof t[s]=="function"&&(n[s]=t[s])}const r=Object.keys(n);let i;process.env.NODE_ENV!=="production"&&(i={});let o;try{L$(n)}catch(a){o=a}return function(s={},l){if(o)throw o;if(process.env.NODE_ENV!=="production"){const p=K$(s,n,l,i);p&&iu(p)}let u=!1;const c={};for(let p=0;p<r.length;p++){const g=r[p],h=n[g],y=s[g],f=h(y,l);if(typeof f>"u"){const v=l&&l.type;throw new Error(process.env.NODE_ENV==="production"?Ee(14):`When called with an action of type ${v?`"${String(v)}"`:"(unknown type)"}, the slice reducer for key "${g}" returned undefined. To ignore an action, you must explicitly return the previous state. If you want this reducer to hold no value, you can return null instead of undefined.`)}c[g]=f,u=u||f!==y}return u=u||r.length!==Object.keys(s).length,u?c:s}}function F$(t=Sn().nodes.drag,e){switch(e.type){case"DND_DRAG_START":return Object.assign(Object.assign({},t),{id:e.id,selectedIds:e.dragIds});case"DND_DRAG_END":return Object.assign(Object.assign({},t),{id:null,destinationParentId:null,destinationIndex:null,selectedIds:[]});case"DND_HOVERING":return e.parentId!==t.destinationParentId||e.index!=t.destinationIndex?Object.assign(Object.assign({},t),{destinationParentId:e.parentId,destinationIndex:e.index}):t;default:return t}}const j$=ou({nodes:ou({focus:dS,edit:uS,open:fS,selection:hS,drag:F$}),dnd:pS}),z$=Sn();function H$({treeProps:t,imperativeHandle:e,children:n}){const r=d.useRef(null),i=d.useRef(null),o=d.useRef(Jf(j$,Sn(t))),a=da.useSyncExternalStore(o.current.subscribe,o.current.getState,()=>z$),s=d.useMemo(()=>new Wn(o.current,t,r,i),[]),l=d.useRef(0);return d.useMemo(()=>{l.current+=1,s.update(t)},[...Object.values(t),a.nodes.open]),d.useImperativeHandle(e,()=>s),d.useEffect(()=>{s.props.selection?s.select(s.props.selection,{focus:!1}):s.deselectAll()},[s.props.selection]),d.useEffect(()=>{s.props.searchTerm||o.current.dispatch(Yo.clear(!0))},[s.props.searchTerm]),T.jsx(lf.Provider,{value:s,children:T.jsx(df.Provider,{value:l.current,children:T.jsx(uf.Provider,{value:a.nodes,children:T.jsx(cf.Provider,{value:a.dnd,children:T.jsx(S0,Object.assign({backend:w$,options:{rootElement:s.props.dndRootElement||void 0}},t.dndManager&&{manager:t.dndManager},{children:n}))})})})})}function B$(){const t=Oe(),[,e]=Ff(()=>({accept:"NODE",canDrop:(n,r)=>r.isOver({shallow:!0})?t.canDrop():!1,hover:(n,r)=>{if(!r.isOver({shallow:!0}))return;const i=r.getClientOffset();if(!t.listEl.current||!i)return;const{cursor:o,drop:a}=Gf({element:t.listEl.current,offset:i,indent:t.indent,node:null,prevNode:t.visibleNodes[t.visibleNodes.length-1],nextNode:null});a&&t.dispatch(wn.hovering(a.parentId,a.index)),r.canDrop()?o&&t.showCursor(o):t.hideCursor()}}),[t]);e(t.listEl)}function W$(t){return B$(),t.children}function U$(){const e=Oe().props.renderContainer||qf;return T.jsx(T.Fragment,{children:T.jsx(e,{})})}function V$(){const t=Oe(),{offset:e,mouse:n,item:r,isDragging:i}=VE(a=>({offset:a.getSourceClientOffset(),mouse:a.getClientOffset(),item:a.getItem(),isDragging:a.isDragging()})),o=t.props.renderDragPreview||Tf;return T.jsx(o,{offset:e,mouse:n,id:(r==null?void 0:r.id)||null,dragIds:(r==null?void 0:r.dragIds)||[],isDragging:i})}class G${constructor(e){this.root=q$(e)}get data(){var e,n;return(n=(e=this.root.children)===null||e===void 0?void 0:e.map(r=>r.data))!==null&&n!==void 0?n:[]}create(e){const n=e.parentId?this.find(e.parentId):this.root;if(!n)return null;n.addChild(e.data,e.index)}move(e){const n=this.find(e.id),r=e.parentId?this.find(e.parentId):this.root;!n||!r||(r.addChild(n.data,e.index),n.drop())}update(e){const n=this.find(e.id);n&&n.update(e.changes)}drop(e){const n=this.find(e.id);n&&n.drop()}find(e,n=this.root){if(!n)return null;if(n.id===e)return n;if(n.children){for(let r of n.children){const i=this.find(e,r);if(i)return i}return null}return null}}function q$(t){const e=new Qf({id:"ROOT"},null);return e.children=t.map(n=>Ha(n,e)),e}function Ha(t,e){const n=new Qf(t,e);return t.children&&(n.children=t.children.map(r=>Ha(r,n))),n}class Qf{constructor(e,n){this.data=e,this.parent=n,this.id=e.id}hasParent(){return!!this.parent}get childIndex(){return this.hasParent()?this.parent.children.indexOf(this):-1}addChild(e,n){var r,i;const o=Ha(e,this);this.children=(r=this.children)!==null&&r!==void 0?r:[],this.children.splice(n,0,o),this.data.children=(i=this.data.children)!==null&&i!==void 0?i:[],this.data.children.splice(n,0,e)}removeChild(e){var n,r;(n=this.children)===null||n===void 0||n.splice(e,1),(r=this.data.children)===null||r===void 0||r.splice(e,1)}update(e){if(this.hasParent()){const n=this.childIndex;this.parent.addChild(Object.assign(Object.assign({},this.data),e),n),this.drop()}}drop(){this.hasParent()&&this.parent.removeChild(this.childIndex)}}let Y$=0;function X$(t){const[e,n]=d.useState(t),r=d.useMemo(()=>new G$(e),[e]);return[e,{onMove:u=>{for(const c of u.dragIds)r.move({id:c,parentId:u.parentId,index:u.index});n(r.data)},onRename:({name:u,id:c})=>{r.update({id:c,changes:{name:u}}),n(r.data)},onCreate:({parentId:u,index:c,type:p})=>{const g={id:`simple-tree-id-${Y$++}`,name:""};return p==="internal"&&(g.children=[]),r.create({parentId:u,index:c,data:g}),n(r.data),g},onDelete:u=>{u.ids.forEach(c=>r.drop({id:c})),n(r.data)}}]}function J$(t){if(t.initialData&&t.data)throw new Error("React Arborist Tree => Provide either a data or initialData prop, but not both.");if(t.initialData&&(t.onCreate||t.onDelete||t.onMove||t.onRename))throw new Error(`React Arborist Tree => You passed the initialData prop along with a data handler.
|
|
101
|
-
Use the data prop if you want to provide your own handlers.`);if(t.initialData){const[e,n]=X$(t.initialData);return Object.assign(Object.assign(Object.assign({},t),n),{data:e})}else return t}function Q$(t,e){const n=J$(t);return T.jsxs(H$,{treeProps:n,imperativeHandle:e,children:[T.jsx(W$,{children:T.jsx(U$,{})}),T.jsx(V$,{})]})}const Z$=d.forwardRef(Q$),Zf=({top:t,left:e})=>T.jsx("div",{className:"c__tree-view__cursor",style:{top:t,left:e+10}});function ex(t,e){var n=d.useRef(null),r=d.useRef(null);r.current=e;var i=d.useRef(null);d.useEffect(function(){o()});var o=d.useCallback(function(){var a=i.current,s=r.current,l=a||(s?s instanceof Element?s:s.current:null);n.current&&n.current.element===l&&n.current.subscriber===t||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:l,subscriber:t,cleanup:l?t(l):void 0})},[t]);return d.useEffect(function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}},[]),d.useCallback(function(a){i.current=a,o()},[o])}function au(t,e,n){return t[e]?t[e][0]?t[e][0][n]:t[e][n]:e==="contentBoxSize"?t.contentRect[n==="inlineSize"?"width":"height"]:void 0}function tx(t){t===void 0&&(t={});var e=t.onResize,n=d.useRef(void 0);n.current=e;var r=t.round||Math.round,i=d.useRef(),o=d.useState({width:void 0,height:void 0}),a=o[0],s=o[1],l=d.useRef(!1);d.useEffect(function(){return l.current=!1,function(){l.current=!0}},[]);var u=d.useRef({width:void 0,height:void 0}),c=ex(d.useCallback(function(p){return(!i.current||i.current.box!==t.box||i.current.round!==r)&&(i.current={box:t.box,round:r,instance:new ResizeObserver(function(g){var h=g[0],y=t.box==="border-box"?"borderBoxSize":t.box==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",f=au(h,y,"inlineSize"),v=au(h,y,"blockSize"),m=f?r(f):void 0,S=v?r(v):void 0;if(u.current.width!==m||u.current.height!==S){var w={width:m,height:S};u.current.width=m,u.current.height=S,n.current?n.current(w):l.current||s(w)}})}),i.current.instance.observe(p,{box:t.box}),function(){i.current&&i.current.instance.unobserve(p)}},[t.box,r]),t.ref);return d.useMemo(function(){return{ref:c,width:a.width,height:a.height}},[c,a.width,a.height])}var Ae=(t=>(t.NODE="node",t.SEPARATOR="separator",t.TITLE="title",t))(Ae||{}),Et=(t=>(t.FIRST_CHILD="first-child",t.LAST_CHILD="last-child",t.LEFT="left",t.RIGHT="right",t))(Et||{});const si=t=>t?t.type===Ae.SEPARATOR:!1,li=t=>t?t.type===Ae.TITLE:!1,zn=t=>!si(t)&&!li(t),nx=({treeData:t,initialOpenState:e,selectedNodeId:n,rootNodeId:r,renderNode:i,handleMove:o,canDrop:a,canDrag:s})=>{const{ref:l,width:u,height:c}=tx(),p=h=>{var I,z,M,j;const y=JSON.parse(JSON.stringify(t)),f=h.dragNodes[0],v=h.parentId?((I=h.parentNode)==null?void 0:I.data.children)??[]:y,m=h.dragNodes[0].data.value.id,S=h.dragNodes[0].data,w=(z=h.parentNode)==null?void 0:z.data;if((w==null?void 0:w.value.type)===Ae.TITLE||(w==null?void 0:w.value.type)===Ae.SEPARATOR)return null;const O=S.parentKey??r,x=h.parentId??r;let D=h.index+0,P=null,b=x;const k=((j=(M=f.parent)==null?void 0:M.children)==null?void 0:j.findIndex(_=>_.data.value.id===m))??0;if(O===x){if(k===D)return null;D=D<k?D:D-1}const B=h.index-1,N=v[B],H=h.index,E=v[H];return h.index===0?(b=r,P=Et.FIRST_CHILD):!w&&h.index===1&&!zn(N.value)?(b=r,D=1,P=Et.FIRST_CHILD):h.index===v.length?(b=b??r,P=Et.LAST_CHILD):N&&zn(N.value)?(b=N.value.id,P=Et.RIGHT):E&&zn(E.value)&&(P=Et.LEFT,b=E.value.id),P&&b?{targetModeId:b,mode:P,oldParentId:O,index:D,newParentId:h.parentId,sourceId:m}:null},g=h=>{const y=p(h);y&&(o==null||o(y))};return T.jsx("div",{ref:l,className:"c__tree-view--container",children:T.jsx(Z$,{data:t,openByDefault:!1,disableEdit:!0,className:"c__tree-view",idAccessor:"key",onMove:g,rowHeight:35,disableDrag:h=>s?!s(h):!1,disableDrop:({parentNode:h,dragNodes:y,index:f})=>{var w,O;if(a&&!a({parentNode:h,dragNodes:y,index:f}))return h.data.value.canDrop=!1,!0;if(((w=h.data.value)==null?void 0:w.type)===Ae.TITLE||((O=h.data.value)==null?void 0:O.type)===Ae.SEPARATOR)return!0;if(h.id==="__REACT_ARBORIST_INTERNAL_ROOT__"){const x=t[f-1],D=t[f],P=t[f+1],b=si(x==null?void 0:x.value),k=si(D==null?void 0:D.value),B=li(x==null?void 0:x.value),N=li(D==null?void 0:D.value),H=zn(P==null?void 0:P.value);return!!(f===0&&(k||N)||b&&N&&H||B&&k&&H)}const v=h==null?void 0:h.isOpen,m=(h==null?void 0:h.data.value.childrenCount)&&h.data.value.childrenCount>0||(h==null?void 0:h.data.children)&&h.data.children.length>0;if(!m)return h.data.value.canDrop=!0,!1;let S=h.data.value.childrenCount&&h.data.value.childrenCount>0&&(h==null?void 0:h.data.children)&&h.data.children.length>0;return S=S??!0,!v&&!S&&m?(h.data.value.canDrop=!0,!0):(h.data.value.canDrop=!0,!1)},paddingBottom:30,width:u,initialOpenState:e,height:c,overscanCount:20,selection:n,renderCursor:Zf,renderRow:h=>{const y=h.node.data.value.type===Ae.TITLE,f=h.node.data.value.type===Ae.SEPARATOR,{style:v}=h.attrs,m={...v};return y||f?T.jsx("div",{...h.attrs,style:m,ref:h.innerRef,onFocus:S=>S.stopPropagation(),onClick:h.node.handleClick,children:h.children}):T.jsx("div",{...h.attrs,style:m,ref:h.innerRef,onFocus:S=>S.stopPropagation(),onClick:h.node.handleClick,children:T.jsx("div",{style:{padding:"0 12px"},children:h.children})})},rowClassName:"c__tree-view--row",children:h=>i(h)})})},rx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ix(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function ox(t){return"nodeType"in t}function ax(t){var e,n;return t?ix(t)?t:ox(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}const eh=rx?d.useLayoutEffect:d.useEffect;function th(t){const e=d.useRef(t);return eh(()=>{e.current=t}),d.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function su(t,e){e===void 0&&(e=[t]);const n=d.useRef(t);return eh(()=>{n.current!==t&&(n.current=t)},e),n}function sx(t){const e=th(t),n=d.useRef(null),r=d.useCallback(i=>{i!==n.current&&(e==null||e(i,n.current)),n.current=i},[]);return[n,r]}let wo={};function lx(t,e){return d.useMemo(()=>{const n=wo[t]==null?0:wo[t]+1;return wo[t]=n,t+"-"+n},[t,e])}var Un;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Un||(Un={}));function lu(){}const ux=Object.freeze({x:0,y:0});function cx(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function dx(t,e,n){const r=cx(e);if(!r)return t;const{scaleX:i,scaleY:o,x:a,y:s}=r,l=t.left-a-(1-i)*parseFloat(n),u=t.top-s-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),c=i?t.width/i:t.width,p=o?t.height/o:t.height;return{width:c,height:p,top:u,right:l+c,bottom:u+p,left:l}}const fx={ignoreTransform:!1};function nh(t,e){e===void 0&&(e=fx);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:c}=ax(t).getComputedStyle(t);u&&(n=dx(n,u,c))}const{top:r,left:i,width:o,height:a,bottom:s,right:l}=n;return{top:r,left:i,width:o,height:a,bottom:s,right:l}}function uu(t){return nh(t,{ignoreTransform:!0})}var dn;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(dn||(dn={}));var cu;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(cu||(cu={}));var ft;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ft||(ft={}));ft.Space,ft.Enter,ft.Esc,ft.Space,ft.Enter,ft.Tab;var du;(function(t){t[t.RightClick=2]="RightClick"})(du||(du={}));var fu;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(fu||(fu={}));var hu;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(hu||(hu={}));dn.Backward+"",dn.Forward+"",dn.Backward+"",dn.Forward+"";var ia;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(ia||(ia={}));var oa;(function(t){t.Optimized="optimized"})(oa||(oa={}));function hx(t){let{callback:e,disabled:n}=t;const r=th(e),i=d.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return d.useEffect(()=>()=>i==null?void 0:i.disconnect(),[i]),i}ia.WhileDragging,oa.Optimized;const px={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:lu,draggableNodes:new Map,over:null,measureDroppableContainers:lu},gx=d.createContext(px);({...ux});var pu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(pu||(pu={}));const vx="Droppable",mx={timeout:25};function yx(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const o=lx(vx),{active:a,dispatch:s,over:l,measureDroppableContainers:u}=d.useContext(gx),c=d.useRef({disabled:n}),p=d.useRef(!1),g=d.useRef(null),h=d.useRef(null),{disabled:y,updateMeasurementsFor:f,timeout:v}={...mx,...i},m=su(f??r),S=d.useCallback(()=>{if(!p.current){p.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{u(Array.isArray(m.current)?m.current:[m.current]),h.current=null},v)},[v]),w=hx({callback:S,disabled:y||!a}),O=d.useCallback((b,k)=>{w&&(k&&(w.unobserve(k),p.current=!1),b&&w.observe(b))},[w]),[x,D]=sx(O),P=su(e);return d.useEffect(()=>{!w||!x.current||(w.disconnect(),p.current=!1,w.observe(x.current))},[x,w]),d.useEffect(()=>(s({type:Un.RegisterDroppable,element:{id:r,key:o,disabled:n,node:x,rect:g,data:P}}),()=>s({type:Un.UnregisterDroppable,key:o,id:r})),[r]),d.useEffect(()=>{n!==c.current.disabled&&(s({type:Un.SetDroppableDisabled,id:r,key:o,disabled:n}),c.current.disabled=n)},[r,o,n,s]),{active:a,rect:g,isOver:(l==null?void 0:l.id)===r,node:x,over:l,setNodeRef:D}}const bx=t=>{const{isOver:e,setNodeRef:n}=yx({id:t.id,data:t.data});return d.useEffect(()=>{var r;(r=t.onOver)==null||r.call(t,e,t.data)},[e,t.data,t.onOver]),T.jsx("div",{ref:n,children:t.children})},Sx=({children:t,onClick:e,node:n,dragHandle:r,style:i,loadChildren:o,forceLoading:a})=>{var w,O;const s=d.useRef(null),[l,u]=d.useState(!1),[c,p]=d.useState(!1),g=a??l,h=n.willReceiveDrop||c,y=n.data.value.childrenCount!==void 0&&n.data.value.childrenCount>0||(((w=n.data.children)==null?void 0:w.length)??0)>0,f=((O=n.children)==null?void 0:O.length)??!1,v=n.isLeaf||!y,m=d.useCallback(async()=>{if(!v){if(f||n.data.value.hasLoadedChildren){n.toggle();return}u(!0),await(o==null?void 0:o(n.data.value)),u(!1),n.open()}},[f,o,n,v]),S=d.useCallback(x=>{x&&!n.isOpen&&!n.isDragging&&(s.current=setTimeout(()=>{m()},500)),s.current&&!x&&clearTimeout(s.current)},[m,n.isOpen,n.isDragging]);return d.useEffect(()=>{S(h)},[h,S]),n.data.value.type===Ae.SEPARATOR?T.jsx("div",{className:"c__tree-view--node__separator"}):n.data.value.type===Ae.TITLE?T.jsx("div",{className:"c__tree-view--node__title",children:n.data.value.title}):T.jsx(bx,{id:n.id,data:{data:n.data,nodeApi:n},onOver:p,children:T.jsxs("div",{onClick:e,ref:r,style:i,className:jt("c__tree-view--node",{...n.state,canDrop:n.data.value.canDrop??!0,externalDrop:c}),children:[v&&T.jsx("div",{className:"c__tree-view--node__leaf"}),!v&&T.jsxs(T.Fragment,{children:[g&&T.jsx("div",{className:"c__tree-view--node__loading",children:T.jsx(Da,{})}),!g&&T.jsx("span",{onClick:x=>{x.stopPropagation(),m()},className:"c__tree-view--node__arrow material-icons",children:n.isOpen?"keyboard_arrow_down":"keyboard_arrow_right"})]}),t]})})},wx=(t,e,n)=>{const{remove:r,update:i,insert:o,insertBefore:a,insertAfter:s,append:l,prepend:u,getItem:c,move:p,items:g}=Cv({initialItems:JSON.parse(JSON.stringify(t)),getKey:M=>M.id,getChildren:M=>M.children||[]}),[h,y]=d.useState(),f=(M=[])=>{const j=g.map(V=>V.key);r(...j);const _=JSON.parse(JSON.stringify(M));_.length>0&&o(null,0,..._),y(void 0)},v=(M,j)=>{var _;if(M){const V=c(M);V&&(o(M,((_=V.children)==null?void 0:_.length)??0,j),N(M,j))}else o(null,g.length,j)},m=(M,j)=>{const _=c(M);if(!_){console.error("No item found");return}let V=_.value.children??null;j.children&&(V=[...V??[],...j.children]);const J={..._.value,...j,children:V,childrenCount:(V==null?void 0:V.length)??_.value.childrenCount};i(M,J)},S=M=>{const j=c(M),_=j==null?void 0:j.parentKey;_&&j&&B(_,j.value.id),r(M)},w=async M=>{if(!e){console.error("No refresh callback provided");return}try{const j=await e(M);m(M,j)}catch(j){console.error("error while refreshing node:",j)}},O=M=>{o(null,g.length,M)},x=(M,j)=>{const _=c(M);if(!_){console.error("No item found");return}const V={..._.value,children:j,childrenCount:j.length};i(M,V)},D=(M,j)=>{a(M,j)},P=(M,j)=>{s(M,j)},b=(M,j)=>{l(M,j)},k=(M,j)=>{u(M,j)},B=(M,j)=>{const _=c(M);if(!_)return;const J=(_.value.children??[]).filter(re=>re.id!==j);_.value.children=J,_.value.childrenCount=J.length},N=(M,j)=>{const _=c(M);if(!_)return;const J=[..._.value.children??[],j];_.value.children=J,_.value.childrenCount=J.length},H=M=>{const j=c(M);j&&y(j.value)},E=(M,j,_,V)=>{var re;const J=(re=c(M))==null?void 0:re.value;p(M,j,_),j&&J&&N(j,J),V&&B(V,M)};return{nodes:g,addChild:v,updateNode:m,deleteNode:S,addRootNode:O,selectedNode:h,setSelectedNode:y,refreshNode:w,setChildren:x,insertBeforeNode:D,insertAfterNode:P,handleMove:M=>{E(M.sourceId,M.newParentId,M.index,M.oldParentId)},prependToNode:k,moveNode:E,appendToNode:b,move:p,resetTree:f,handleLoadChildren:async M=>{if(!n)return[];const j=await n(M);return m(M,{children:j,hasLoadedChildren:!0,childrenCount:j.length}),j},selectNodeById:H}};exports.CunninghamProvider=ph;exports.CustomTabs=Gb;exports.DropdownMenu=Qc;exports.Header=td;exports.HorizontalSeparator=qo;exports.Label=Cd;exports.LanguagePicker=ed;exports.LeftPanel=nd;exports.MainLayout=Am;exports.ProConnectButton=gh;exports.QuickSearch=Wb;exports.QuickSearchGroup=Ub;exports.QuickSearchInput=sf;exports.QuickSearchItem=Rr;exports.QuickSearchItemTemplate=Vb;exports.Spinner=Da;exports.TreeView=nx;exports.TreeViewItem=Sx;exports.TreeViewMoveModeEnum=Et;exports.TreeViewNodeTypeEnum=Ae;exports.TreeViewSeparator=Zf;exports.WithLabel=Lm;exports.cunninghamConfig=jo;exports.getLocales=vu;exports.headerHeight=Km;exports.isNode=zn;exports.isSeparator=si;exports.isTitle=li;exports.useDropdownMenu=Zc;exports.useResponsive=vi;exports.useTree=wx;
|
|
101
|
+
Use the data prop if you want to provide your own handlers.`);if(t.initialData){const[e,n]=X$(t.initialData);return Object.assign(Object.assign(Object.assign({},t),n),{data:e})}else return t}function Q$(t,e){const n=J$(t);return T.jsxs(H$,{treeProps:n,imperativeHandle:e,children:[T.jsx(W$,{children:T.jsx(U$,{})}),T.jsx(V$,{})]})}const Z$=d.forwardRef(Q$),Zf=({top:t,left:e})=>T.jsx("div",{className:"c__tree-view__cursor",style:{top:t,left:e+10}});function ex(t,e){var n=d.useRef(null),r=d.useRef(null);r.current=e;var i=d.useRef(null);d.useEffect(function(){o()});var o=d.useCallback(function(){var a=i.current,s=r.current,l=a||(s?s instanceof Element?s:s.current:null);n.current&&n.current.element===l&&n.current.subscriber===t||(n.current&&n.current.cleanup&&n.current.cleanup(),n.current={element:l,subscriber:t,cleanup:l?t(l):void 0})},[t]);return d.useEffect(function(){return function(){n.current&&n.current.cleanup&&(n.current.cleanup(),n.current=null)}},[]),d.useCallback(function(a){i.current=a,o()},[o])}function au(t,e,n){return t[e]?t[e][0]?t[e][0][n]:t[e][n]:e==="contentBoxSize"?t.contentRect[n==="inlineSize"?"width":"height"]:void 0}function tx(t){t===void 0&&(t={});var e=t.onResize,n=d.useRef(void 0);n.current=e;var r=t.round||Math.round,i=d.useRef(),o=d.useState({width:void 0,height:void 0}),a=o[0],s=o[1],l=d.useRef(!1);d.useEffect(function(){return l.current=!1,function(){l.current=!0}},[]);var u=d.useRef({width:void 0,height:void 0}),c=ex(d.useCallback(function(p){return(!i.current||i.current.box!==t.box||i.current.round!==r)&&(i.current={box:t.box,round:r,instance:new ResizeObserver(function(g){var h=g[0],y=t.box==="border-box"?"borderBoxSize":t.box==="device-pixel-content-box"?"devicePixelContentBoxSize":"contentBoxSize",f=au(h,y,"inlineSize"),v=au(h,y,"blockSize"),m=f?r(f):void 0,S=v?r(v):void 0;if(u.current.width!==m||u.current.height!==S){var w={width:m,height:S};u.current.width=m,u.current.height=S,n.current?n.current(w):l.current||s(w)}})}),i.current.instance.observe(p,{box:t.box}),function(){i.current&&i.current.instance.unobserve(p)}},[t.box,r]),t.ref);return d.useMemo(function(){return{ref:c,width:a.width,height:a.height}},[c,a.width,a.height])}var Ae=(t=>(t.NODE="node",t.SEPARATOR="separator",t.TITLE="title",t))(Ae||{}),Et=(t=>(t.FIRST_CHILD="first-child",t.LAST_CHILD="last-child",t.LEFT="left",t.RIGHT="right",t))(Et||{});const si=t=>t?t.type===Ae.SEPARATOR:!1,li=t=>t?t.type===Ae.TITLE:!1,zn=t=>!si(t)&&!li(t),nx=({treeData:t,initialOpenState:e,selectedNodeId:n,rootNodeId:r,renderNode:i,handleMove:o,canDrop:a,canDrag:s})=>{const{ref:l,width:u,height:c}=tx(),p=h=>{var I,z,M,j;const y=JSON.parse(JSON.stringify(t)),f=h.dragNodes[0],v=h.parentId?((I=h.parentNode)==null?void 0:I.data.children)??[]:y,m=h.dragNodes[0].data.value.id,S=h.dragNodes[0].data,w=(z=h.parentNode)==null?void 0:z.data;if((w==null?void 0:w.value.type)===Ae.TITLE||(w==null?void 0:w.value.type)===Ae.SEPARATOR)return null;const O=S.parentKey??r,x=h.parentId??r;let D=h.index+0,P=null,b=x;const k=((j=(M=f.parent)==null?void 0:M.children)==null?void 0:j.findIndex(_=>_.data.value.id===m))??0;if(O===x){if(k===D)return null;D=D<k?D:D-1}const B=h.index-1,N=v[B],H=h.index,E=v[H];return h.index===0?(b=h.parentId??r,P=Et.FIRST_CHILD):!w&&h.index===1&&!zn(N.value)?(b=r,D=1,P=Et.FIRST_CHILD):h.index===v.length?(b=b??r,P=Et.LAST_CHILD):N&&zn(N.value)?(b=N.value.id,P=Et.RIGHT):E&&zn(E.value)&&(P=Et.LEFT,b=E.value.id),P&&b?{targetModeId:b,mode:P,oldParentId:O,index:D,newParentId:h.parentId,sourceId:m}:null},g=h=>{const y=p(h);y&&(o==null||o(y))};return T.jsx("div",{ref:l,className:"c__tree-view--container",children:T.jsx(Z$,{data:t,openByDefault:!1,disableEdit:!0,className:"c__tree-view",idAccessor:"key",onMove:g,rowHeight:35,disableDrag:h=>s?!s(h):!1,disableDrop:({parentNode:h,dragNodes:y,index:f})=>{var w,O;if(a&&!a({parentNode:h,dragNodes:y,index:f}))return h.data.value.canDrop=!1,!0;if(((w=h.data.value)==null?void 0:w.type)===Ae.TITLE||((O=h.data.value)==null?void 0:O.type)===Ae.SEPARATOR)return!0;if(h.id==="__REACT_ARBORIST_INTERNAL_ROOT__"){const x=t[f-1],D=t[f],P=t[f+1],b=si(x==null?void 0:x.value),k=si(D==null?void 0:D.value),B=li(x==null?void 0:x.value),N=li(D==null?void 0:D.value),H=zn(P==null?void 0:P.value);return!!(f===0&&(k||N)||b&&N&&H||B&&k&&H)}const v=h==null?void 0:h.isOpen,m=(h==null?void 0:h.data.value.childrenCount)&&h.data.value.childrenCount>0||(h==null?void 0:h.data.children)&&h.data.children.length>0;if(!m)return h.data.value.canDrop=!0,!1;let S=h.data.value.childrenCount&&h.data.value.childrenCount>0&&(h==null?void 0:h.data.children)&&h.data.children.length>0;return S=S??!0,!v&&!S&&m?(h.data.value.canDrop=!0,!0):(h.data.value.canDrop=!0,!1)},paddingBottom:30,width:u,initialOpenState:e,height:c,overscanCount:20,selection:n,renderCursor:Zf,renderRow:h=>{const y=h.node.data.value.type===Ae.TITLE,f=h.node.data.value.type===Ae.SEPARATOR,{style:v}=h.attrs,m={...v};return y||f?T.jsx("div",{...h.attrs,style:m,ref:h.innerRef,onFocus:S=>S.stopPropagation(),onClick:h.node.handleClick,children:h.children}):T.jsx("div",{...h.attrs,style:m,ref:h.innerRef,onFocus:S=>S.stopPropagation(),onClick:h.node.handleClick,children:T.jsx("div",{style:{padding:"0 12px"},children:h.children})})},rowClassName:"c__tree-view--row",children:h=>i(h)})})},rx=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function ix(t){const e=Object.prototype.toString.call(t);return e==="[object Window]"||e==="[object global]"}function ox(t){return"nodeType"in t}function ax(t){var e,n;return t?ix(t)?t:ox(t)&&(e=(n=t.ownerDocument)==null?void 0:n.defaultView)!=null?e:window:window}const eh=rx?d.useLayoutEffect:d.useEffect;function th(t){const e=d.useRef(t);return eh(()=>{e.current=t}),d.useCallback(function(){for(var n=arguments.length,r=new Array(n),i=0;i<n;i++)r[i]=arguments[i];return e.current==null?void 0:e.current(...r)},[])}function su(t,e){e===void 0&&(e=[t]);const n=d.useRef(t);return eh(()=>{n.current!==t&&(n.current=t)},e),n}function sx(t){const e=th(t),n=d.useRef(null),r=d.useCallback(i=>{i!==n.current&&(e==null||e(i,n.current)),n.current=i},[]);return[n,r]}let wo={};function lx(t,e){return d.useMemo(()=>{const n=wo[t]==null?0:wo[t]+1;return wo[t]=n,t+"-"+n},[t,e])}var Un;(function(t){t.DragStart="dragStart",t.DragMove="dragMove",t.DragEnd="dragEnd",t.DragCancel="dragCancel",t.DragOver="dragOver",t.RegisterDroppable="registerDroppable",t.SetDroppableDisabled="setDroppableDisabled",t.UnregisterDroppable="unregisterDroppable"})(Un||(Un={}));function lu(){}const ux=Object.freeze({x:0,y:0});function cx(t){if(t.startsWith("matrix3d(")){const e=t.slice(9,-1).split(/, /);return{x:+e[12],y:+e[13],scaleX:+e[0],scaleY:+e[5]}}else if(t.startsWith("matrix(")){const e=t.slice(7,-1).split(/, /);return{x:+e[4],y:+e[5],scaleX:+e[0],scaleY:+e[3]}}return null}function dx(t,e,n){const r=cx(e);if(!r)return t;const{scaleX:i,scaleY:o,x:a,y:s}=r,l=t.left-a-(1-i)*parseFloat(n),u=t.top-s-(1-o)*parseFloat(n.slice(n.indexOf(" ")+1)),c=i?t.width/i:t.width,p=o?t.height/o:t.height;return{width:c,height:p,top:u,right:l+c,bottom:u+p,left:l}}const fx={ignoreTransform:!1};function nh(t,e){e===void 0&&(e=fx);let n=t.getBoundingClientRect();if(e.ignoreTransform){const{transform:u,transformOrigin:c}=ax(t).getComputedStyle(t);u&&(n=dx(n,u,c))}const{top:r,left:i,width:o,height:a,bottom:s,right:l}=n;return{top:r,left:i,width:o,height:a,bottom:s,right:l}}function uu(t){return nh(t,{ignoreTransform:!0})}var dn;(function(t){t[t.Forward=1]="Forward",t[t.Backward=-1]="Backward"})(dn||(dn={}));var cu;(function(t){t.Click="click",t.DragStart="dragstart",t.Keydown="keydown",t.ContextMenu="contextmenu",t.Resize="resize",t.SelectionChange="selectionchange",t.VisibilityChange="visibilitychange"})(cu||(cu={}));var ft;(function(t){t.Space="Space",t.Down="ArrowDown",t.Right="ArrowRight",t.Left="ArrowLeft",t.Up="ArrowUp",t.Esc="Escape",t.Enter="Enter",t.Tab="Tab"})(ft||(ft={}));ft.Space,ft.Enter,ft.Esc,ft.Space,ft.Enter,ft.Tab;var du;(function(t){t[t.RightClick=2]="RightClick"})(du||(du={}));var fu;(function(t){t[t.Pointer=0]="Pointer",t[t.DraggableRect=1]="DraggableRect"})(fu||(fu={}));var hu;(function(t){t[t.TreeOrder=0]="TreeOrder",t[t.ReversedTreeOrder=1]="ReversedTreeOrder"})(hu||(hu={}));dn.Backward+"",dn.Forward+"",dn.Backward+"",dn.Forward+"";var ia;(function(t){t[t.Always=0]="Always",t[t.BeforeDragging=1]="BeforeDragging",t[t.WhileDragging=2]="WhileDragging"})(ia||(ia={}));var oa;(function(t){t.Optimized="optimized"})(oa||(oa={}));function hx(t){let{callback:e,disabled:n}=t;const r=th(e),i=d.useMemo(()=>{if(n||typeof window>"u"||typeof window.ResizeObserver>"u")return;const{ResizeObserver:o}=window;return new o(r)},[n]);return d.useEffect(()=>()=>i==null?void 0:i.disconnect(),[i]),i}ia.WhileDragging,oa.Optimized;const px={activatorEvent:null,activators:[],active:null,activeNodeRect:null,ariaDescribedById:{draggable:""},dispatch:lu,draggableNodes:new Map,over:null,measureDroppableContainers:lu},gx=d.createContext(px);({...ux});var pu;(function(t){t[t.Uninitialized=0]="Uninitialized",t[t.Initializing=1]="Initializing",t[t.Initialized=2]="Initialized"})(pu||(pu={}));const vx="Droppable",mx={timeout:25};function yx(t){let{data:e,disabled:n=!1,id:r,resizeObserverConfig:i}=t;const o=lx(vx),{active:a,dispatch:s,over:l,measureDroppableContainers:u}=d.useContext(gx),c=d.useRef({disabled:n}),p=d.useRef(!1),g=d.useRef(null),h=d.useRef(null),{disabled:y,updateMeasurementsFor:f,timeout:v}={...mx,...i},m=su(f??r),S=d.useCallback(()=>{if(!p.current){p.current=!0;return}h.current!=null&&clearTimeout(h.current),h.current=setTimeout(()=>{u(Array.isArray(m.current)?m.current:[m.current]),h.current=null},v)},[v]),w=hx({callback:S,disabled:y||!a}),O=d.useCallback((b,k)=>{w&&(k&&(w.unobserve(k),p.current=!1),b&&w.observe(b))},[w]),[x,D]=sx(O),P=su(e);return d.useEffect(()=>{!w||!x.current||(w.disconnect(),p.current=!1,w.observe(x.current))},[x,w]),d.useEffect(()=>(s({type:Un.RegisterDroppable,element:{id:r,key:o,disabled:n,node:x,rect:g,data:P}}),()=>s({type:Un.UnregisterDroppable,key:o,id:r})),[r]),d.useEffect(()=>{n!==c.current.disabled&&(s({type:Un.SetDroppableDisabled,id:r,key:o,disabled:n}),c.current.disabled=n)},[r,o,n,s]),{active:a,rect:g,isOver:(l==null?void 0:l.id)===r,node:x,over:l,setNodeRef:D}}const bx=t=>{const{isOver:e,setNodeRef:n}=yx({id:t.id,data:t.data});return d.useEffect(()=>{var r;(r=t.onOver)==null||r.call(t,e,t.data)},[e,t.data,t.onOver]),T.jsx("div",{ref:n,children:t.children})},Sx=({children:t,onClick:e,node:n,dragHandle:r,style:i,loadChildren:o,forceLoading:a})=>{var w,O;const s=d.useRef(null),[l,u]=d.useState(!1),[c,p]=d.useState(!1),g=a??l,h=n.willReceiveDrop||c,y=n.data.value.childrenCount!==void 0&&n.data.value.childrenCount>0||(((w=n.data.children)==null?void 0:w.length)??0)>0,f=((O=n.children)==null?void 0:O.length)??!1,v=n.isLeaf||!y,m=d.useCallback(async()=>{if(!v){if(f||n.data.value.hasLoadedChildren){n.toggle();return}u(!0),await(o==null?void 0:o(n.data.value)),u(!1),n.open()}},[f,o,n,v]),S=d.useCallback(x=>{x&&!n.isOpen&&!n.isDragging&&(s.current=setTimeout(()=>{m()},500)),s.current&&!x&&clearTimeout(s.current)},[m,n.isOpen,n.isDragging]);return d.useEffect(()=>{S(h)},[h,S]),n.data.value.type===Ae.SEPARATOR?T.jsx("div",{className:"c__tree-view--node__separator"}):n.data.value.type===Ae.TITLE?T.jsx("div",{className:"c__tree-view--node__title",children:n.data.value.title}):T.jsx(bx,{id:n.id,data:{data:n.data,nodeApi:n},onOver:p,children:T.jsxs("div",{onClick:e,ref:r,style:i,className:jt("c__tree-view--node",{...n.state,canDrop:n.data.value.canDrop??!0,externalDrop:c}),children:[v&&T.jsx("div",{className:"c__tree-view--node__leaf"}),!v&&T.jsxs(T.Fragment,{children:[g&&T.jsx("div",{className:"c__tree-view--node__loading",children:T.jsx(Da,{})}),!g&&T.jsx("span",{onClick:x=>{x.stopPropagation(),m()},className:"c__tree-view--node__arrow material-icons",children:n.isOpen?"keyboard_arrow_down":"keyboard_arrow_right"})]}),t]})})},wx=(t,e,n)=>{const{remove:r,update:i,insert:o,insertBefore:a,insertAfter:s,append:l,prepend:u,getItem:c,move:p,items:g}=Cv({initialItems:JSON.parse(JSON.stringify(t)),getKey:M=>M.id,getChildren:M=>M.children||[]}),[h,y]=d.useState(),f=(M=[])=>{const j=g.map(V=>V.key);r(...j);const _=JSON.parse(JSON.stringify(M));_.length>0&&o(null,0,..._),y(void 0)},v=(M,j)=>{var _;if(M){const V=c(M);V&&(o(M,((_=V.children)==null?void 0:_.length)??0,j),N(M,j))}else o(null,g.length,j)},m=(M,j)=>{const _=c(M);if(!_){console.error("No item found");return}let V=_.value.children??null;j.children&&(V=[...V??[],...j.children]);const J={..._.value,...j,children:V,childrenCount:(V==null?void 0:V.length)??_.value.childrenCount};i(M,J)},S=M=>{const j=c(M),_=j==null?void 0:j.parentKey;_&&j&&B(_,j.value.id),r(M)},w=async M=>{if(!e){console.error("No refresh callback provided");return}try{const j=await e(M);m(M,j)}catch(j){console.error("error while refreshing node:",j)}},O=M=>{o(null,g.length,M)},x=(M,j)=>{const _=c(M);if(!_){console.error("No item found");return}const V={..._.value,children:j,childrenCount:j.length};i(M,V)},D=(M,j)=>{a(M,j)},P=(M,j)=>{s(M,j)},b=(M,j)=>{l(M,j)},k=(M,j)=>{u(M,j)},B=(M,j)=>{const _=c(M);if(!_)return;const J=(_.value.children??[]).filter(re=>re.id!==j);_.value.children=J,_.value.childrenCount=J.length},N=(M,j)=>{const _=c(M);if(!_)return;const J=[..._.value.children??[],j];_.value.children=J,_.value.childrenCount=J.length},H=M=>{const j=c(M);j&&y(j.value)},E=(M,j,_,V)=>{var re;const J=(re=c(M))==null?void 0:re.value;p(M,j,_),j&&J&&N(j,J),V&&B(V,M)};return{nodes:g,addChild:v,updateNode:m,deleteNode:S,addRootNode:O,selectedNode:h,setSelectedNode:y,refreshNode:w,setChildren:x,insertBeforeNode:D,insertAfterNode:P,handleMove:M=>{E(M.sourceId,M.newParentId,M.index,M.oldParentId)},prependToNode:k,moveNode:E,appendToNode:b,move:p,resetTree:f,handleLoadChildren:async M=>{if(!n)return[];const j=await n(M);return m(M,{children:j,hasLoadedChildren:!0,childrenCount:j.length}),j},selectNodeById:H}};exports.CunninghamProvider=ph;exports.CustomTabs=Gb;exports.DropdownMenu=Qc;exports.Header=td;exports.HorizontalSeparator=qo;exports.Label=Cd;exports.LanguagePicker=ed;exports.LeftPanel=nd;exports.MainLayout=Am;exports.ProConnectButton=gh;exports.QuickSearch=Wb;exports.QuickSearchGroup=Ub;exports.QuickSearchInput=sf;exports.QuickSearchItem=Rr;exports.QuickSearchItemTemplate=Vb;exports.Spinner=Da;exports.TreeView=nx;exports.TreeViewItem=Sx;exports.TreeViewMoveModeEnum=Et;exports.TreeViewNodeTypeEnum=Ae;exports.TreeViewSeparator=Zf;exports.WithLabel=Lm;exports.cunninghamConfig=jo;exports.getLocales=vu;exports.headerHeight=Km;exports.isNode=zn;exports.isSeparator=si;exports.isTitle=li;exports.useDropdownMenu=Zc;exports.useResponsive=vi;exports.useTree=wx;
|
|
102
102
|
//# sourceMappingURL=index.cjs.map
|