diff --git a/resources/dist/filament-adjacency-list.js b/resources/dist/filament-adjacency-list.js index f0e63a7..a664f8e 100644 --- a/resources/dist/filament-adjacency-list.js +++ b/resources/dist/filament-adjacency-list.js @@ -1,4 +1,4 @@ -function le(o,t){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(o);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(o,i).enumerable})),e.push.apply(e,n)}return e}function L(o){for(var t=1;t=0)&&(e[i]=o[i]);return e}function Fe(o,t){if(o==null)return{};var e=xe(o,t),n,i;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(o);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(o,n)&&(e[n]=o[n])}return e}var Re="1.15.0";function U(o){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(o)}var q=U(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Ot=U(/Edge/i),se=U(/firefox/i),Et=U(/safari/i)&&!U(/chrome/i)&&!U(/android/i),me=U(/iP(ad|od|hone)/i),ve=U(/chrome/i)&&U(/android/i),be={capture:!1,passive:!1};function w(o,t,e){o.addEventListener(t,e,!q&&be)}function b(o,t,e){o.removeEventListener(t,e,!q&&be)}function Yt(o,t){if(t){if(t[0]===">"&&(t=t.substring(1)),o)try{if(o.matches)return o.matches(t);if(o.msMatchesSelector)return o.msMatchesSelector(t);if(o.webkitMatchesSelector)return o.webkitMatchesSelector(t)}catch{return!1}return!1}}function ke(o){return o.host&&o!==document&&o.host.nodeType?o.host:o.parentNode}function W(o,t,e,n){if(o){e=e||document;do{if(t!=null&&(t[0]===">"?o.parentNode===e&&Yt(o,t):Yt(o,t))||n&&o===e)return o;if(o===e)break}while(o=ke(o))}return null}var ue=/\s+/g;function F(o,t,e){if(o&&t)if(o.classList)o.classList[e?"add":"remove"](t);else{var n=(" "+o.className+" ").replace(ue," ").replace(" "+t+" "," ");o.className=(n+(e?" "+t:"")).replace(ue," ")}}function h(o,t,e){var n=o&&o.style;if(n){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(o,""):o.currentStyle&&(e=o.currentStyle),t===void 0?e:e[t];!(t in n)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),n[t]=e+(typeof e=="string"?"":"px")}}function ft(o,t){var e="";if(typeof o=="string")e=o;else do{var n=h(o,"transform");n&&n!=="none"&&(e=n+" "+e)}while(!t&&(o=o.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(e)}function we(o,t,e){if(o){var n=o.getElementsByTagName(t),i=0,r=n.length;if(e)for(;i=r:a=i<=r,!a)return n;if(n===K())break;n=tt(n,!1)}return!1}function dt(o,t,e,n){for(var i=0,r=0,a=o.children;r2&&arguments[2]!==void 0?arguments[2]:{},i=n.evt,r=Fe(n,Le);Tt.pluginEvent.bind(p)(t,e,L({dragEl:c,parentEl:_,ghostEl:g,rootEl:S,nextEl:at,lastDownEl:Ft,cloneEl:D,cloneHidden:J,dragStarted:bt,putSortable:T,activeSortable:p.active,originalEvent:i,oldIndex:ct,oldDraggableIndex:Dt,newIndex:R,newDraggableIndex:Q,hideGhostForTarget:Oe,unhideGhostForTarget:Te,cloneNowHidden:function(){J=!0},cloneNowShown:function(){J=!1},dispatchSortableEvent:function(l){N({sortable:e,name:l,originalEvent:i})}},r))};function N(o){Ke(L({putSortable:T,cloneEl:D,targetEl:c,rootEl:S,oldIndex:ct,oldDraggableIndex:Dt,newIndex:R,newDraggableIndex:Q},o))}var c,_,g,S,at,Ft,D,J,ct,R,Dt,Q,It,T,ut=!1,Bt=!1,Ht=[],it,H,zt,Ut,de,he,bt,st,_t,Ct=!1,Nt=!1,Rt,A,$t=[],Jt=!1,Gt=[],Kt=typeof document<"u",Pt=me,pe=Ot||q?"cssFloat":"float",je=Kt&&!ve&&!me&&"draggable"in document.createElement("div"),De=function(){if(Kt){if(q)return!1;var o=document.createElement("x");return o.style.cssText="pointer-events:auto",o.style.pointerEvents==="auto"}}(),_e=function(t,e){var n=h(t),i=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),r=dt(t,0,e),a=dt(t,1,e),l=r&&h(r),s=a&&h(a),u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+O(r).width,d=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+O(a).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(r&&l.float&&l.float!=="none"){var f=l.float==="left"?"left":"right";return a&&(s.clear==="both"||s.clear===f)?"vertical":"horizontal"}return r&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||u>=i&&n[pe]==="none"||a&&n[pe]==="none"&&u+d>i)?"vertical":"horizontal"},ze=function(t,e,n){var i=n?t.left:t.top,r=n?t.right:t.bottom,a=n?t.width:t.height,l=n?e.left:e.top,s=n?e.right:e.bottom,u=n?e.width:e.height;return i===l||r===s||i+a/2===l+u/2},Ue=function(t,e){var n;return Ht.some(function(i){var r=i[k].options.emptyInsertThreshold;if(!(!r||oe(i))){var a=O(i),l=t>=a.left-r&&t<=a.right+r,s=e>=a.top-r&&e<=a.bottom+r;if(l&&s)return n=i}}),n},Ce=function(t){function e(r,a){return function(l,s,u,d){var f=l.options.group.name&&s.options.group.name&&l.options.group.name===s.options.group.name;if(r==null&&(a||f))return!0;if(r==null||r===!1)return!1;if(a&&r==="clone")return r;if(typeof r=="function")return e(r(l,s,u,d),a)(l,s,u,d);var m=(a?l:s).options.group.name;return r===!0||typeof r=="string"&&r===m||r.join&&r.indexOf(m)>-1}}var n={},i=t.group;(!i||xt(i)!="object")&&(i={name:i}),n.name=i.name,n.checkPull=e(i.pull,!0),n.checkPut=e(i.put),n.revertClone=i.revertClone,t.group=n},Oe=function(){!De&&g&&h(g,"display","none")},Te=function(){!De&&g&&h(g,"display","")};Kt&&!ve&&document.addEventListener("click",function(o){if(Bt)return o.preventDefault(),o.stopPropagation&&o.stopPropagation(),o.stopImmediatePropagation&&o.stopImmediatePropagation(),Bt=!1,!1},!0);var rt=function(t){if(c){t=t.touches?t.touches[0]:t;var e=Ue(t.clientX,t.clientY);if(e){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.target=n.rootEl=e,n.preventDefault=void 0,n.stopPropagation=void 0,e[k]._onDragOver(n)}}},$e=function(t){c&&c.parentNode[k]._isOutsideThisEl(t.target)};function p(o,t){if(!(o&&o.nodeType&&o.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(o));this.el=o,this.options=t=$({},t),o[k]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(o.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return _e(o,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(a,l){a.setData("Text",l.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:p.supportPointer!==!1&&"PointerEvent"in window&&!Et,emptyInsertThreshold:5};Tt.initializePlugins(this,o,e);for(var n in e)!(n in t)&&(t[n]=e[n]);Ce(t);for(var i in this)i.charAt(0)==="_"&&typeof this[i]=="function"&&(this[i]=this[i].bind(this));this.nativeDraggable=t.forceFallback?!1:je,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?w(o,"pointerdown",this._onTapStart):(w(o,"mousedown",this._onTapStart),w(o,"touchstart",this._onTapStart)),this.nativeDraggable&&(w(o,"dragover",this),w(o,"dragenter",this)),Ht.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),$(this,He())}p.prototype={constructor:p,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(st=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,c):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,i=this.options,r=i.preventOnFilter,a=t.type,l=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,s=(l||t).target,u=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||s,d=i.filter;if(nn(n),!c&&!(/mousedown|pointerdown/.test(a)&&t.button!==0||i.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&Et&&s&&s.tagName.toUpperCase()==="SELECT")&&(s=W(s,i.draggable,n,!1),!(s&&s.animated)&&Ft!==s)){if(ct=X(s),Dt=X(s,i.draggable),typeof d=="function"){if(d.call(this,t,s,this)){N({sortable:e,rootEl:u,name:"filter",targetEl:s,toEl:n,fromEl:n}),P("filter",e,{evt:t}),r&&t.cancelable&&t.preventDefault();return}}else if(d&&(d=d.split(",").some(function(f){if(f=W(u,f.trim(),n,!1),f)return N({sortable:e,rootEl:f,name:"filter",targetEl:s,fromEl:n,toEl:n}),P("filter",e,{evt:t}),!0}),d)){r&&t.cancelable&&t.preventDefault();return}i.handle&&!W(u,i.handle,n,!1)||this._prepareDragStart(t,l,s)}}},_prepareDragStart:function(t,e,n){var i=this,r=i.el,a=i.options,l=r.ownerDocument,s;if(n&&!c&&n.parentNode===r){var u=O(n);if(S=r,c=n,_=c.parentNode,at=c.nextSibling,Ft=n,It=a.group,p.dragged=c,it={target:c,clientX:(e||t).clientX,clientY:(e||t).clientY},de=it.clientX-u.left,he=it.clientY-u.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,c.style["will-change"]="all",s=function(){if(P("delayEnded",i,{evt:t}),p.eventCanceled){i._onDrop();return}i._disableDelayedDragEvents(),!se&&i.nativeDraggable&&(c.draggable=!0),i._triggerDragStart(t,e),N({sortable:i,name:"choose",originalEvent:t}),F(c,a.chosenClass,!0)},a.ignore.split(",").forEach(function(d){we(c,d.trim(),qt)}),w(l,"dragover",rt),w(l,"mousemove",rt),w(l,"touchmove",rt),w(l,"mouseup",i._onDrop),w(l,"touchend",i._onDrop),w(l,"touchcancel",i._onDrop),se&&this.nativeDraggable&&(this.options.touchStartThreshold=4,c.draggable=!0),P("delayStart",this,{evt:t}),a.delay&&(!a.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(Ot||q))){if(p.eventCanceled){this._onDrop();return}w(l,"mouseup",i._disableDelayedDrag),w(l,"touchend",i._disableDelayedDrag),w(l,"touchcancel",i._disableDelayedDrag),w(l,"mousemove",i._delayedDragTouchMoveHandler),w(l,"touchmove",i._delayedDragTouchMoveHandler),a.supportPointer&&w(l,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(s,a.delay)}else s()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){c&&qt(c),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;b(t,"mouseup",this._disableDelayedDrag),b(t,"touchend",this._disableDelayedDrag),b(t,"touchcancel",this._disableDelayedDrag),b(t,"mousemove",this._delayedDragTouchMoveHandler),b(t,"touchmove",this._delayedDragTouchMoveHandler),b(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?w(document,"pointermove",this._onTouchMove):e?w(document,"touchmove",this._onTouchMove):w(document,"mousemove",this._onTouchMove):(w(c,"dragend",this),w(S,"dragstart",this._onDragStart));try{document.selection?kt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(ut=!1,S&&c){P("dragStarted",this,{evt:e}),this.nativeDraggable&&w(document,"dragover",$e);var n=this.options;!t&&F(c,n.dragClass,!1),F(c,n.ghostClass,!0),p.active=this,t&&this._appendGhost(),N({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(H){this._lastX=H.clientX,this._lastY=H.clientY,Oe();for(var t=document.elementFromPoint(H.clientX,H.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(H.clientX,H.clientY),t!==e);)e=t;if(c.parentNode[k]._isOutsideThisEl(t),e)do{if(e[k]){var n=void 0;if(n=e[k]._onDragOver({clientX:H.clientX,clientY:H.clientY,target:t,rootEl:e}),n&&!this.options.dragoverBubble)break}t=e}while(e=e.parentNode);Te()}},_onTouchMove:function(t){if(it){var e=this.options,n=e.fallbackTolerance,i=e.fallbackOffset,r=t.touches?t.touches[0]:t,a=g&&ft(g,!0),l=g&&a&&a.a,s=g&&a&&a.d,u=Pt&&A&&fe(A),d=(r.clientX-it.clientX+i.x)/(l||1)+(u?u[0]-$t[0]:0)/(l||1),f=(r.clientY-it.clientY+i.y)/(s||1)+(u?u[1]-$t[1]:0)/(s||1);if(!p.active&&!ut){if(n&&Math.max(Math.abs(r.clientX-this._lastX),Math.abs(r.clientY-this._lastY))=0&&(N({rootEl:_,name:"add",toEl:_,fromEl:S,originalEvent:t}),N({sortable:this,name:"remove",toEl:_,originalEvent:t}),N({rootEl:_,name:"sort",toEl:_,fromEl:S,originalEvent:t}),N({sortable:this,name:"sort",toEl:_,originalEvent:t})),T&&T.save()):R!==ct&&R>=0&&(N({sortable:this,name:"update",toEl:_,originalEvent:t}),N({sortable:this,name:"sort",toEl:_,originalEvent:t})),p.active&&((R==null||R===-1)&&(R=ct,Q=Dt),N({sortable:this,name:"end",toEl:_,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){P("nulling",this),S=c=_=g=at=D=Ft=J=it=H=bt=R=Q=ct=Dt=st=_t=T=It=p.dragged=p.ghost=p.clone=p.active=null,Gt.forEach(function(t){t.checked=!0}),Gt.length=zt=Ut=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":c&&(this._onDragOver(t),qe(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,n=this.el.children,i=0,r=n.length,a=this.options;in.right+i||o.clientX<=n.right&&o.clientY>n.bottom&&o.clientX>=n.left:o.clientX>n.right&&o.clientY>n.top||o.clientX<=n.right&&o.clientY>n.bottom+i}function Je(o,t,e,n,i,r,a,l){var s=n?o.clientY:o.clientX,u=n?e.height:e.width,d=n?e.top:e.left,f=n?e.bottom:e.right,m=!1;if(!a){if(l&&Rtd+u*r/2:sf-Rt)return-_t}else if(s>d+u*(1-i)/2&&sf-u*r/2)?s>d+u/2?1:-1:0}function tn(o){return X(c)({statePath:t,sortable:null,init(){this.sortable=new Ie(this.$el,{disabled:e,group:o,animation:150,fallbackOnBody:!0,swapThreshold:.25,invertSwap:!0,draggable:"[data-sortable-item]",handle:"[data-sortable-handle]",onMove:i=>{if(n&&n>=0&&this.getDepth(i.related)>n)return!1},onSort:()=>{this.$wire.dispatchFormEvent("builder::sort",this.statePath,this.sortable.toArray())}})},getDepth(i,r=0){let a=i.parentElement.closest("[data-sortable-item]");return a?this.getDepth(a,++r):r}});export{sn as default}; +function le(o,t){var e=Object.keys(o);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(o);t&&(n=n.filter(function(i){return Object.getOwnPropertyDescriptor(o,i).enumerable})),e.push.apply(e,n)}return e}function K(o){for(var t=1;t=0)&&(e[i]=o[i]);return e}function Fe(o,t){if(o==null)return{};var e=xe(o,t),n,i;if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(o);for(i=0;i=0)&&Object.prototype.propertyIsEnumerable.call(o,n)&&(e[n]=o[n])}return e}var Re="1.15.0";function U(o){if(typeof window<"u"&&window.navigator)return!!navigator.userAgent.match(o)}var q=U(/(?:Trident.*rv[ :]?11\.|msie|iemobile|Windows Phone)/i),Ot=U(/Edge/i),se=U(/firefox/i),Et=U(/safari/i)&&!U(/chrome/i)&&!U(/android/i),me=U(/iP(ad|od|hone)/i),ve=U(/chrome/i)&&U(/android/i),be={capture:!1,passive:!1};function w(o,t,e){o.addEventListener(t,e,!q&&be)}function b(o,t,e){o.removeEventListener(t,e,!q&&be)}function Yt(o,t){if(t){if(t[0]===">"&&(t=t.substring(1)),o)try{if(o.matches)return o.matches(t);if(o.msMatchesSelector)return o.msMatchesSelector(t);if(o.webkitMatchesSelector)return o.webkitMatchesSelector(t)}catch{return!1}return!1}}function ke(o){return o.host&&o!==document&&o.host.nodeType?o.host:o.parentNode}function L(o,t,e,n){if(o){e=e||document;do{if(t!=null&&(t[0]===">"?o.parentNode===e&&Yt(o,t):Yt(o,t))||n&&o===e)return o;if(o===e)break}while(o=ke(o))}return null}var ue=/\s+/g;function F(o,t,e){if(o&&t)if(o.classList)o.classList[e?"add":"remove"](t);else{var n=(" "+o.className+" ").replace(ue," ").replace(" "+t+" "," ");o.className=(n+(e?" "+t:"")).replace(ue," ")}}function h(o,t,e){var n=o&&o.style;if(n){if(e===void 0)return document.defaultView&&document.defaultView.getComputedStyle?e=document.defaultView.getComputedStyle(o,""):o.currentStyle&&(e=o.currentStyle),t===void 0?e:e[t];!(t in n)&&t.indexOf("webkit")===-1&&(t="-webkit-"+t),n[t]=e+(typeof e=="string"?"":"px")}}function ft(o,t){var e="";if(typeof o=="string")e=o;else do{var n=h(o,"transform");n&&n!=="none"&&(e=n+" "+e)}while(!t&&(o=o.parentNode));var i=window.DOMMatrix||window.WebKitCSSMatrix||window.CSSMatrix||window.MSCSSMatrix;return i&&new i(e)}function we(o,t,e){if(o){var n=o.getElementsByTagName(t),i=0,r=n.length;if(e)for(;i=r:a=i<=r,!a)return n;if(n===W())break;n=tt(n,!1)}return!1}function dt(o,t,e,n){for(var i=0,r=0,a=o.children;r2&&arguments[2]!==void 0?arguments[2]:{},i=n.evt,r=Fe(n,Ke);Tt.pluginEvent.bind(p)(t,e,K({dragEl:c,parentEl:_,ghostEl:g,rootEl:S,nextEl:at,lastDownEl:Ft,cloneEl:D,cloneHidden:J,dragStarted:bt,putSortable:T,activeSortable:p.active,originalEvent:i,oldIndex:ct,oldDraggableIndex:Dt,newIndex:R,newDraggableIndex:Q,hideGhostForTarget:Oe,unhideGhostForTarget:Te,cloneNowHidden:function(){J=!0},cloneNowShown:function(){J=!1},dispatchSortableEvent:function(l){N({sortable:e,name:l,originalEvent:i})}},r))};function N(o){We(K({putSortable:T,cloneEl:D,targetEl:c,rootEl:S,oldIndex:ct,oldDraggableIndex:Dt,newIndex:R,newDraggableIndex:Q},o))}var c,_,g,S,at,Ft,D,J,ct,R,Dt,Q,It,T,ut=!1,Bt=!1,Ht=[],it,H,zt,Ut,de,he,bt,st,_t,Ct=!1,Nt=!1,Rt,A,$t=[],Jt=!1,Gt=[],Wt=typeof document<"u",Pt=me,pe=Ot||q?"cssFloat":"float",je=Wt&&!ve&&!me&&"draggable"in document.createElement("div"),De=function(){if(Wt){if(q)return!1;var o=document.createElement("x");return o.style.cssText="pointer-events:auto",o.style.pointerEvents==="auto"}}(),_e=function(t,e){var n=h(t),i=parseInt(n.width)-parseInt(n.paddingLeft)-parseInt(n.paddingRight)-parseInt(n.borderLeftWidth)-parseInt(n.borderRightWidth),r=dt(t,0,e),a=dt(t,1,e),l=r&&h(r),s=a&&h(a),u=l&&parseInt(l.marginLeft)+parseInt(l.marginRight)+O(r).width,d=s&&parseInt(s.marginLeft)+parseInt(s.marginRight)+O(a).width;if(n.display==="flex")return n.flexDirection==="column"||n.flexDirection==="column-reverse"?"vertical":"horizontal";if(n.display==="grid")return n.gridTemplateColumns.split(" ").length<=1?"vertical":"horizontal";if(r&&l.float&&l.float!=="none"){var f=l.float==="left"?"left":"right";return a&&(s.clear==="both"||s.clear===f)?"vertical":"horizontal"}return r&&(l.display==="block"||l.display==="flex"||l.display==="table"||l.display==="grid"||u>=i&&n[pe]==="none"||a&&n[pe]==="none"&&u+d>i)?"vertical":"horizontal"},ze=function(t,e,n){var i=n?t.left:t.top,r=n?t.right:t.bottom,a=n?t.width:t.height,l=n?e.left:e.top,s=n?e.right:e.bottom,u=n?e.width:e.height;return i===l||r===s||i+a/2===l+u/2},Ue=function(t,e){var n;return Ht.some(function(i){var r=i[k].options.emptyInsertThreshold;if(!(!r||oe(i))){var a=O(i),l=t>=a.left-r&&t<=a.right+r,s=e>=a.top-r&&e<=a.bottom+r;if(l&&s)return n=i}}),n},Ce=function(t){function e(r,a){return function(l,s,u,d){var f=l.options.group.name&&s.options.group.name&&l.options.group.name===s.options.group.name;if(r==null&&(a||f))return!0;if(r==null||r===!1)return!1;if(a&&r==="clone")return r;if(typeof r=="function")return e(r(l,s,u,d),a)(l,s,u,d);var m=(a?l:s).options.group.name;return r===!0||typeof r=="string"&&r===m||r.join&&r.indexOf(m)>-1}}var n={},i=t.group;(!i||xt(i)!="object")&&(i={name:i}),n.name=i.name,n.checkPull=e(i.pull,!0),n.checkPut=e(i.put),n.revertClone=i.revertClone,t.group=n},Oe=function(){!De&&g&&h(g,"display","none")},Te=function(){!De&&g&&h(g,"display","")};Wt&&!ve&&document.addEventListener("click",function(o){if(Bt)return o.preventDefault(),o.stopPropagation&&o.stopPropagation(),o.stopImmediatePropagation&&o.stopImmediatePropagation(),Bt=!1,!1},!0);var rt=function(t){if(c){t=t.touches?t.touches[0]:t;var e=Ue(t.clientX,t.clientY);if(e){var n={};for(var i in t)t.hasOwnProperty(i)&&(n[i]=t[i]);n.target=n.rootEl=e,n.preventDefault=void 0,n.stopPropagation=void 0,e[k]._onDragOver(n)}}},$e=function(t){c&&c.parentNode[k]._isOutsideThisEl(t.target)};function p(o,t){if(!(o&&o.nodeType&&o.nodeType===1))throw"Sortable: `el` must be an HTMLElement, not ".concat({}.toString.call(o));this.el=o,this.options=t=$({},t),o[k]=this;var e={group:null,sort:!0,disabled:!1,store:null,handle:null,draggable:/^[uo]l$/i.test(o.nodeName)?">li":">*",swapThreshold:1,invertSwap:!1,invertedSwapThreshold:null,removeCloneOnHide:!0,direction:function(){return _e(o,this.options)},ghostClass:"sortable-ghost",chosenClass:"sortable-chosen",dragClass:"sortable-drag",ignore:"a, img",filter:null,preventOnFilter:!0,animation:0,easing:null,setData:function(a,l){a.setData("Text",l.textContent)},dropBubble:!1,dragoverBubble:!1,dataIdAttr:"data-id",delay:0,delayOnTouchOnly:!1,touchStartThreshold:(Number.parseInt?Number:window).parseInt(window.devicePixelRatio,10)||1,forceFallback:!1,fallbackClass:"sortable-fallback",fallbackOnBody:!1,fallbackTolerance:0,fallbackOffset:{x:0,y:0},supportPointer:p.supportPointer!==!1&&"PointerEvent"in window&&!Et,emptyInsertThreshold:5};Tt.initializePlugins(this,o,e);for(var n in e)!(n in t)&&(t[n]=e[n]);Ce(t);for(var i in this)i.charAt(0)==="_"&&typeof this[i]=="function"&&(this[i]=this[i].bind(this));this.nativeDraggable=t.forceFallback?!1:je,this.nativeDraggable&&(this.options.touchStartThreshold=1),t.supportPointer?w(o,"pointerdown",this._onTapStart):(w(o,"mousedown",this._onTapStart),w(o,"touchstart",this._onTapStart)),this.nativeDraggable&&(w(o,"dragover",this),w(o,"dragenter",this)),Ht.push(this.el),t.store&&t.store.get&&this.sort(t.store.get(this)||[]),$(this,He())}p.prototype={constructor:p,_isOutsideThisEl:function(t){!this.el.contains(t)&&t!==this.el&&(st=null)},_getDirection:function(t,e){return typeof this.options.direction=="function"?this.options.direction.call(this,t,e,c):this.options.direction},_onTapStart:function(t){if(t.cancelable){var e=this,n=this.el,i=this.options,r=i.preventOnFilter,a=t.type,l=t.touches&&t.touches[0]||t.pointerType&&t.pointerType==="touch"&&t,s=(l||t).target,u=t.target.shadowRoot&&(t.path&&t.path[0]||t.composedPath&&t.composedPath()[0])||s,d=i.filter;if(nn(n),!c&&!(/mousedown|pointerdown/.test(a)&&t.button!==0||i.disabled)&&!u.isContentEditable&&!(!this.nativeDraggable&&Et&&s&&s.tagName.toUpperCase()==="SELECT")&&(s=L(s,i.draggable,n,!1),!(s&&s.animated)&&Ft!==s)){if(ct=X(s),Dt=X(s,i.draggable),typeof d=="function"){if(d.call(this,t,s,this)){N({sortable:e,rootEl:u,name:"filter",targetEl:s,toEl:n,fromEl:n}),P("filter",e,{evt:t}),r&&t.cancelable&&t.preventDefault();return}}else if(d&&(d=d.split(",").some(function(f){if(f=L(u,f.trim(),n,!1),f)return N({sortable:e,rootEl:f,name:"filter",targetEl:s,fromEl:n,toEl:n}),P("filter",e,{evt:t}),!0}),d)){r&&t.cancelable&&t.preventDefault();return}i.handle&&!L(u,i.handle,n,!1)||this._prepareDragStart(t,l,s)}}},_prepareDragStart:function(t,e,n){var i=this,r=i.el,a=i.options,l=r.ownerDocument,s;if(n&&!c&&n.parentNode===r){var u=O(n);if(S=r,c=n,_=c.parentNode,at=c.nextSibling,Ft=n,It=a.group,p.dragged=c,it={target:c,clientX:(e||t).clientX,clientY:(e||t).clientY},de=it.clientX-u.left,he=it.clientY-u.top,this._lastX=(e||t).clientX,this._lastY=(e||t).clientY,c.style["will-change"]="all",s=function(){if(P("delayEnded",i,{evt:t}),p.eventCanceled){i._onDrop();return}i._disableDelayedDragEvents(),!se&&i.nativeDraggable&&(c.draggable=!0),i._triggerDragStart(t,e),N({sortable:i,name:"choose",originalEvent:t}),F(c,a.chosenClass,!0)},a.ignore.split(",").forEach(function(d){we(c,d.trim(),qt)}),w(l,"dragover",rt),w(l,"mousemove",rt),w(l,"touchmove",rt),w(l,"mouseup",i._onDrop),w(l,"touchend",i._onDrop),w(l,"touchcancel",i._onDrop),se&&this.nativeDraggable&&(this.options.touchStartThreshold=4,c.draggable=!0),P("delayStart",this,{evt:t}),a.delay&&(!a.delayOnTouchOnly||e)&&(!this.nativeDraggable||!(Ot||q))){if(p.eventCanceled){this._onDrop();return}w(l,"mouseup",i._disableDelayedDrag),w(l,"touchend",i._disableDelayedDrag),w(l,"touchcancel",i._disableDelayedDrag),w(l,"mousemove",i._delayedDragTouchMoveHandler),w(l,"touchmove",i._delayedDragTouchMoveHandler),a.supportPointer&&w(l,"pointermove",i._delayedDragTouchMoveHandler),i._dragStartTimer=setTimeout(s,a.delay)}else s()}},_delayedDragTouchMoveHandler:function(t){var e=t.touches?t.touches[0]:t;Math.max(Math.abs(e.clientX-this._lastX),Math.abs(e.clientY-this._lastY))>=Math.floor(this.options.touchStartThreshold/(this.nativeDraggable&&window.devicePixelRatio||1))&&this._disableDelayedDrag()},_disableDelayedDrag:function(){c&&qt(c),clearTimeout(this._dragStartTimer),this._disableDelayedDragEvents()},_disableDelayedDragEvents:function(){var t=this.el.ownerDocument;b(t,"mouseup",this._disableDelayedDrag),b(t,"touchend",this._disableDelayedDrag),b(t,"touchcancel",this._disableDelayedDrag),b(t,"mousemove",this._delayedDragTouchMoveHandler),b(t,"touchmove",this._delayedDragTouchMoveHandler),b(t,"pointermove",this._delayedDragTouchMoveHandler)},_triggerDragStart:function(t,e){e=e||t.pointerType=="touch"&&t,!this.nativeDraggable||e?this.options.supportPointer?w(document,"pointermove",this._onTouchMove):e?w(document,"touchmove",this._onTouchMove):w(document,"mousemove",this._onTouchMove):(w(c,"dragend",this),w(S,"dragstart",this._onDragStart));try{document.selection?kt(function(){document.selection.empty()}):window.getSelection().removeAllRanges()}catch{}},_dragStarted:function(t,e){if(ut=!1,S&&c){P("dragStarted",this,{evt:e}),this.nativeDraggable&&w(document,"dragover",$e);var n=this.options;!t&&F(c,n.dragClass,!1),F(c,n.ghostClass,!0),p.active=this,t&&this._appendGhost(),N({sortable:this,name:"start",originalEvent:e})}else this._nulling()},_emulateDragOver:function(){if(H){this._lastX=H.clientX,this._lastY=H.clientY,Oe();for(var t=document.elementFromPoint(H.clientX,H.clientY),e=t;t&&t.shadowRoot&&(t=t.shadowRoot.elementFromPoint(H.clientX,H.clientY),t!==e);)e=t;if(c.parentNode[k]._isOutsideThisEl(t),e)do{if(e[k]){var n=void 0;if(n=e[k]._onDragOver({clientX:H.clientX,clientY:H.clientY,target:t,rootEl:e}),n&&!this.options.dragoverBubble)break}t=e}while(e=e.parentNode);Te()}},_onTouchMove:function(t){if(it){var e=this.options,n=e.fallbackTolerance,i=e.fallbackOffset,r=t.touches?t.touches[0]:t,a=g&&ft(g,!0),l=g&&a&&a.a,s=g&&a&&a.d,u=Pt&&A&&fe(A),d=(r.clientX-it.clientX+i.x)/(l||1)+(u?u[0]-$t[0]:0)/(l||1),f=(r.clientY-it.clientY+i.y)/(s||1)+(u?u[1]-$t[1]:0)/(s||1);if(!p.active&&!ut){if(n&&Math.max(Math.abs(r.clientX-this._lastX),Math.abs(r.clientY-this._lastY))=0&&(N({rootEl:_,name:"add",toEl:_,fromEl:S,originalEvent:t}),N({sortable:this,name:"remove",toEl:_,originalEvent:t}),N({rootEl:_,name:"sort",toEl:_,fromEl:S,originalEvent:t}),N({sortable:this,name:"sort",toEl:_,originalEvent:t})),T&&T.save()):R!==ct&&R>=0&&(N({sortable:this,name:"update",toEl:_,originalEvent:t}),N({sortable:this,name:"sort",toEl:_,originalEvent:t})),p.active&&((R==null||R===-1)&&(R=ct,Q=Dt),N({sortable:this,name:"end",toEl:_,originalEvent:t}),this.save()))),this._nulling()},_nulling:function(){P("nulling",this),S=c=_=g=at=D=Ft=J=it=H=bt=R=Q=ct=Dt=st=_t=T=It=p.dragged=p.ghost=p.clone=p.active=null,Gt.forEach(function(t){t.checked=!0}),Gt.length=zt=Ut=0},handleEvent:function(t){switch(t.type){case"drop":case"dragend":this._onDrop(t);break;case"dragenter":case"dragover":c&&(this._onDragOver(t),qe(t));break;case"selectstart":t.preventDefault();break}},toArray:function(){for(var t=[],e,n=this.el.children,i=0,r=n.length,a=this.options;in.right+i||o.clientX<=n.right&&o.clientY>n.bottom&&o.clientX>=n.left:o.clientX>n.right&&o.clientY>n.top||o.clientX<=n.right&&o.clientY>n.bottom+i}function Je(o,t,e,n,i,r,a,l){var s=n?o.clientY:o.clientX,u=n?e.height:e.width,d=n?e.top:e.left,f=n?e.bottom:e.right,m=!1;if(!a){if(l&&Rtd+u*r/2:sf-Rt)return-_t}else if(s>d+u*(1-i)/2&&sf-u*r/2)?s>d+u/2?1:-1:0}function tn(o){return X(c){if(n&&n>=0&&this.getDepth(i.related)>n)return!1},onSort:()=>{this.$wire.dispatchFormEvent("builder::sort",this.statePath,this.sortable.toArray())}})},getDepth(i,r=0){let a=i.parentElement.closest("[data-sortable-item]");return a?this.getDepth(a,++r):r}}}export{rn as default}; /*! Bundled license information: sortablejs/modular/sortable.esm.js: diff --git a/resources/js/index.js b/resources/js/index.js index 5c92ecb..d2f8422 100644 --- a/resources/js/index.js +++ b/resources/js/index.js @@ -1,42 +1,44 @@ import Sortable from "sortablejs" -export default ({ +export default function adjacencyList({ treeId, statePath, disabled, maxDepth -}) => ({ - statePath, - sortable: null, +}) { + return { + statePath, + sortable: null, - init() { - this.sortable = new Sortable(this.$el, { - disabled, - group: treeId, - animation: 150, - fallbackOnBody: true, - swapThreshold: 0.25, - invertSwap: true, - draggable: "[data-sortable-item]", - handle: "[data-sortable-handle]", - onMove: (evt) => { - if (maxDepth && maxDepth >= 0 && this.getDepth(evt.related) > maxDepth) { - return false; // Prevent dragging items to a depth greater than maxDepth + init() { + this.sortable = new Sortable(this.$el, { + disabled, + group: treeId, + animation: 150, + fallbackOnBody: true, + swapThreshold: 0.25, + invertSwap: true, + draggable: "[data-sortable-item]", + handle: "[data-sortable-handle]", + onMove: (evt) => { + if (maxDepth && maxDepth >= 0 && this.getDepth(evt.related) > maxDepth) { + return false; // Prevent dragging items to a depth greater than maxDepth + } + }, + onSort: () => { + this.$wire.dispatchFormEvent('builder::sort', this.statePath, this.sortable.toArray()) } - }, - onSort: () => { - this.$wire.dispatchFormEvent('builder::sort', this.statePath, this.sortable.toArray()) - } - }) - }, + }) + }, - getDepth(el, depth = 0) { - const parentElement = el.parentElement.closest('[data-sortable-item]'); + getDepth(el, depth = 0) { + const parentElement = el.parentElement.closest('[data-sortable-item]'); - if (parentElement) { - return this.getDepth(parentElement, ++depth); - } + if (parentElement) { + return this.getDepth(parentElement, ++depth); + } - return depth; - }, -}) + return depth; + }, + } +} diff --git a/resources/views/builder.blade.php b/resources/views/builder.blade.php index 2409582..786c90c 100644 --- a/resources/views/builder.blade.php +++ b/resources/views/builder.blade.php @@ -35,7 +35,7 @@ class="fi-adjacency-list-tree" ax-load ax-load-css="{{ \Filament\Support\Facades\FilamentAsset::getStyleHref('filament-adjacency-list-styles', 'saade/filament-adjacency-list') }}" ax-load-src="{{ \Filament\Support\Facades\FilamentAsset::getAlpineComponentSrc('filament-adjacency-list', 'saade/filament-adjacency-list') }}" - x-data="tree({ + x-data="adjacencyList({ treeId: @js($treeId), statePath: @js($getStatePath()), disabled: @js($isDisabled), diff --git a/resources/views/components/item.blade.php b/resources/views/components/item.blade.php index 2e80b4b..b56233f 100644 --- a/resources/views/components/item.blade.php +++ b/resources/views/components/item.blade.php @@ -86,7 +86,7 @@ class="px-2 text-gray-500 appearance-none" 'pb-1' => !$hasChildren, 'border-l border-l-gray-100 dark:border-l-white/10 ps-5 pt-2' => $hasRulers, ]) - x-data="tree({ + x-data="adjacencyList({ treeId: @js($treeId), statePath: @js($itemStatePath . ".$childrenKey"), disabled: @js($disabled),