theme.keycloak.v2.admin.resources.assets.Droppable-DrenVtJB.js Maven / Gradle / Ivy
import{_ as w,l as C}from"./index-C1LIsRX7.js";import*as s from"react";import{s as S}from"./DataListItemRow-COCiEHyF.js";import{G as se}from"./grip-vertical-icon-Bnn0MebT.js";const re=e=>{var{children:t,className:a=""}=e,n=w(e,["children","className"]);return s.createElement("div",Object.assign({className:C(S.dataListItemControl,a)},n),t)};re.displayName="DataListControl";const oe=e=>{var{className:t="",isDisabled:a=!1}=e,n=w(e,["className","isDisabled"]);return s.createElement("button",Object.assign({className:C(S.dataListItemDraggableButton,a&&S.modifiers.disabled,t),type:"button",disabled:a},n),s.createElement("span",{className:C(S.dataListItemDraggableIcon)},s.createElement(se,null)))};oe.displayName="DataListDragButton";const G=s.createContext({onDrag:e=>!0,onDragMove:(e,t)=>{},onDrop:(e,t)=>!1}),ne=({children:e,onDrag:t=()=>!0,onDragMove:a=()=>{},onDrop:n=()=>!1})=>s.createElement(G.Provider,{value:{onDrag:t,onDragMove:a,onDrop:n}},e);ne.displayName="DragDrop";const u={draggable:"pf-v5-c-draggable",droppable:"pf-v5-c-droppable",modifiers:{dragging:"pf-m-dragging",dragOutside:"pf-m-drag-outside"},themeDark:"pf-v5-theme-dark"},H=s.createContext({zone:"defaultDroppableZone",droppableId:"defaultDroppableId"}),ie={name:"--pf-v5-c-draggable--m-dragging--BackgroundColor",value:"#fff",var:"var(--pf-v5-c-draggable--m-dragging--BackgroundColor)"};function le(){const e=document.createElement("div");document.head.appendChild(e);const t=window.getComputedStyle(e).backgroundColor;return document.head.removeChild(e),t}function T(e){const t=le(),a=window.getComputedStyle(e).backgroundColor;return a!==t?a:e.parentElement?T(e.parentElement):t}function de(e){if(e.getAttribute("blankDiv")==="true")for(let t=0;t{t.style.transform="",t.style.transition="",e.draggableNodesRects[a]=t.getBoundingClientRect()})}function ge(e,t){return e.clientX>t.x&&e.clientXt.y&&e.clientY{var{className:t,children:a,style:n={},hasNoWrapper:L=!1}=e,x=w(e,["className","children","style","hasNoWrapper"]);let[h,D]=s.useState(n);const[O,A]=s.useState(!1),[U,Z]=s.useState(!0),{zone:z,droppableId:Y}=s.useContext(H),{onDrag:F,onDragMove:J,onDrop:K}=s.useContext(G);let P=0,E=0,_=null,y,I=null,$,j,k=0;const Q=o=>{O&&(A(!1),D(n))};function W(){const o=y?y.getAttribute("data-pf-droppableid"):null;return{source:{droppableId:Y,index:_},dest:o!==null&&I!==null?{droppableId:o,index:I}:void 0,hoveringDroppableId:o}}const ee=o=>{o.forEach(M),document.removeEventListener("mousemove",$),document.removeEventListener("mouseup",j),document.removeEventListener("contextmenu",j);const{source:d,dest:r,hoveringDroppableId:B}=W(),v=K(d,r);v&&Y===B?(A(!1),D(n)):v||D(Object.assign(Object.assign({},h),{transition:"transform 0.5s cubic-bezier(0.2, 1, 0.1, 1) 0s",transform:"",background:n.background,boxShadow:n.boxShadow}))},te=(o,d,r)=>{if(y=null,d.forEach(g=>{const{node:i,rect:m,isDraggingHost:b,draggableNodes:f,draggableNodesRects:c}=g;if(ge(o,m)){if(i.classList.remove(u.modifiers.dragOutside),y=i,i.getAttribute("blankDiv")!=="true"&&!b){const p=document.createElement("div");p.setAttribute("blankDiv","true");let l=-1;for(let N=0;N=E-k;(q||V)&&l===-1&&(V&&!q?f[N].after(p):f[N].before(p),p.style.height=`${r.height}px`,p.style.width=`${r.width}px`,i.setAttribute("blankDiv","true"),l=N),l!==-1&&(R.y+=r.height)}f.splice(l,0,p),c.splice(l,0,r),m.height+=r.height}}else M(g),i.classList.add(u.modifiers.dragging),i.classList.add(u.modifiers.dragOutside)}),D(Object.assign(Object.assign({},h),{transform:`translate(${o.pageX-P}px, ${o.pageY-E}px)`})),Z(!!y),I=null,y){const{draggableNodes:g,draggableNodesRects:i}=d.find(b=>b.node===y);let m=0;g.forEach((b,f)=>{b.style.transition="transform 0.5s cubic-bezier(0.2, 1, 0.1, 1) 0s";const c=i[f],p=c.y+c.height/2;let l=0;Ep?l-=r.height:E>=p&&o.pageY-k<=p&&(l+=r.height),(l<=m&&l<0||l>m&&l>0)&&(I=f),b.style.transform=`translate(0, ${l}px`,m=l})}const{source:B,dest:v}=W();J(B,v)},ae=o=>{if(o.preventDefault(),O)return;const d=o.target,r=d.getBoundingClientRect(),v=Array.from(document.querySelectorAll(`[data-pf-droppable="${z}"]`)).reduce((g,i)=>{i.classList.add(u.modifiers.dragging);const m=Array.from(i.querySelectorAll(`[data-pf-draggable-zone="${z}"]`)),b=i.contains(d);b&&(_=m.indexOf(d));const f={node:i,rect:i.getBoundingClientRect(),isDraggingHost:b,draggableNodes:m.map(c=>c===d?c.cloneNode(!1):c),draggableNodesRects:m.map(c=>c.getBoundingClientRect())};return g.push(f),g},[]);if(!F({droppableId:Y,index:_})){v.forEach(g=>M(g));return}h=Object.assign(Object.assign({},h),{top:r.y,left:r.x,width:r.width,height:r.height,[ie.name]:T(d),position:"fixed",zIndex:5e3}),D(h),P=o.pageX,E=o.pageY,k=E-r.y,A(!0),$=g=>te(g,v,r),j=()=>ee(v),document.addEventListener("mousemove",$),document.addEventListener("mouseup",j)},X=Object.assign({"data-pf-draggable-zone":O?null:z,draggable:!0,className:C(u.draggable,O&&u.modifiers.dragging,!U&&u.modifiers.dragOutside,t),onDragStart:ae,onTransitionEnd:Q,style:h},x);return s.createElement(s.Fragment,null,O&&s.createElement("div",Object.assign({draggable:!0},x,{style:Object.assign(Object.assign({},n),{visibility:"hidden"})}),a),L?s.cloneElement(a,X):s.createElement("div",Object.assign({},X),a))};ce.displayName="Draggable";const pe=e=>{var{className:t,children:a,zone:n="defaultZone",droppableId:L="defaultId",hasNoWrapper:x=!1}=e,h=w(e,["className","children","zone","droppableId","hasNoWrapper"]);const D=Object.assign({"data-pf-droppable":n,"data-pf-droppableid":L,className:x&&s.Children.count(a)===1?C(u.droppable,t,a.props.className):C(u.droppable,t)},h);return s.createElement(H.Provider,{value:{zone:n,droppableId:L}},x?s.cloneElement(a,D):s.createElement("div",Object.assign({},D),a))};pe.displayName="Droppable";export{oe as D,ce as a,re as b,ne as c,pe as d};
//# sourceMappingURL=Droppable-DrenVtJB.js.map