react-panel-layout 0.7.0 → 0.7.1

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.
Files changed (44) hide show
  1. package/dist/{FloatingWindow-Bw2djgpz.js → FloatingWindow-CE-WzkNv.js} +2 -2
  2. package/dist/{FloatingWindow-Bw2djgpz.js.map → FloatingWindow-CE-WzkNv.js.map} +1 -1
  3. package/dist/{FloatingWindow-Cvyokf0m.cjs → FloatingWindow-DpFpmX1f.cjs} +2 -2
  4. package/dist/{FloatingWindow-Cvyokf0m.cjs.map → FloatingWindow-DpFpmX1f.cjs.map} +1 -1
  5. package/dist/{GridLayout-DNOClFzz.cjs → GridLayout-EwKszYBy.cjs} +2 -2
  6. package/dist/{GridLayout-DNOClFzz.cjs.map → GridLayout-EwKszYBy.cjs.map} +1 -1
  7. package/dist/{GridLayout-B4aCqSyd.js → GridLayout-kiWdpMLQ.js} +2 -2
  8. package/dist/{GridLayout-B4aCqSyd.js.map → GridLayout-kiWdpMLQ.js.map} +1 -1
  9. package/dist/{PanelSystem-B8Igvnb2.cjs → PanelSystem-Dmy5YI_6.cjs} +2 -2
  10. package/dist/{PanelSystem-B8Igvnb2.cjs.map → PanelSystem-Dmy5YI_6.cjs.map} +1 -1
  11. package/dist/{PanelSystem-DDUSFjXD.js → PanelSystem-DrYsYwuV.js} +3 -3
  12. package/dist/{PanelSystem-DDUSFjXD.js.map → PanelSystem-DrYsYwuV.js.map} +1 -1
  13. package/dist/config.cjs +1 -1
  14. package/dist/config.js +2 -2
  15. package/dist/dialog/index.d.ts +1 -1
  16. package/dist/grid.cjs +1 -1
  17. package/dist/grid.js +2 -2
  18. package/dist/index.cjs +1 -1
  19. package/dist/index.js +4 -4
  20. package/dist/modules/dialog/DialogContainer.d.ts +22 -2
  21. package/dist/modules/dialog/Modal.d.ts +23 -2
  22. package/dist/modules/dialog/SwipeDialogContainer.d.ts +6 -2
  23. package/dist/modules/dialog/types.d.ts +12 -0
  24. package/dist/panels.cjs +1 -1
  25. package/dist/panels.js +1 -1
  26. package/dist/stack.cjs +1 -1
  27. package/dist/stack.js +1 -1
  28. package/dist/{useAnimationFrame-Bg4e-H8O.js → useAnimationFrame-CRuFlk5t.js} +16 -16
  29. package/dist/useAnimationFrame-CRuFlk5t.js.map +1 -0
  30. package/dist/useAnimationFrame-XRpDXkwV.cjs +2 -0
  31. package/dist/useAnimationFrame-XRpDXkwV.cjs.map +1 -0
  32. package/dist/window.cjs +1 -1
  33. package/dist/window.js +1 -1
  34. package/package.json +1 -1
  35. package/src/dialog/index.ts +2 -0
  36. package/src/hooks/gesture/useSwipeInput.spec.ts +69 -0
  37. package/src/hooks/gesture/useSwipeInput.ts +2 -0
  38. package/src/modules/dialog/DialogContainer.tsx +39 -5
  39. package/src/modules/dialog/Modal.tsx +46 -4
  40. package/src/modules/dialog/SwipeDialogContainer.tsx +12 -2
  41. package/src/modules/dialog/types.ts +14 -0
  42. package/dist/useAnimationFrame-BZ6D2lMq.cjs +0 -2
  43. package/dist/useAnimationFrame-BZ6D2lMq.cjs.map +0 -1
  44. package/dist/useAnimationFrame-Bg4e-H8O.js.map +0 -1
@@ -1,2 +1,2 @@
1
- "use strict";const h=require("react/jsx-runtime"),Lt=require("react"),C=require("./FloatingWindow-Cvyokf0m.cjs"),I=require("./styles-qf6ptVLD.cjs"),Tt=require("./SwipePivotTabBar-fjjXkpj7.cjs"),xt=require("./ResizeHandle-CBcAS918.cjs"),pt=require("./useIsomorphicLayoutEffect-DGRNF4Lf.cjs"),B=require("./useDocumentPointerEvents-DxDSOtip.cjs");function Mt(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const d=Mt(Lt),_t=()=>{const t=new Map;return e=>{if(!e)return;const n=t.get(e);if(n!==void 0)return n;const r=t.size;return t.set(e,r),r}},Dt=_t(),J=new Map,Pt=t=>{const e=`ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${Dt(t.root)}`;if(J.has(e))return J.get(e);const n=new class{#t=new Map;#e=new IntersectionObserver(r=>{r.forEach(o=>{const s=this.#t.get(o.target);s&&s(o)})},t);observe(r,o){return this.#t.set(r,o),this.#e.observe(r),()=>{this.#t.delete(r),this.#e.unobserve(r)}}};return J.set(e,n),n},it=Object.freeze({x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0});function Ht(t,{threshold:e=0,rootMargin:n="0px",root:r=null}){const[o,s]=d.useState(null);return d.useEffect(()=>{const l=t.current;return l?Pt({threshold:e,rootMargin:n,root:r}).observe(l,u=>{s({isIntersecting:u.isIntersecting,boundingClientRect:u.boundingClientRect,intersectionRatio:u.intersectionRatio,intersectionRect:u.intersectionRect,rootBounds:u.rootBounds,target:u.target,time:u.time})}):void 0},[t,e,n,r]),d.useMemo(()=>({isIntersecting:o?.isIntersecting??!1,boundingClientRect:o?.boundingClientRect??it,intersectionRatio:o?.intersectionRatio??0,intersectionRect:o?.intersectionRect??it,rootBounds:o?.rootBounds??null,target:o?.target??t.current,time:o?.time??0}),[o,t])}const bt={position:"absolute",pointerEvents:"auto",boxSizing:"border-box",background:"transparent",border:"none"},Gt={...bt,width:I.GRID_LAYER_CORNER_HIT_SIZE,height:I.GRID_LAYER_CORNER_HIT_SIZE,zIndex:2},Nt={...bt,zIndex:1},kt={"top-left":{top:0,left:0,transform:"translate(-50%, -50%)",cursor:"nwse-resize"},"top-right":{top:0,right:0,transform:"translate(50%, -50%)",cursor:"nesw-resize"},"bottom-left":{bottom:0,left:0,transform:"translate(-50%, 50%)",cursor:"nesw-resize"},"bottom-right":{bottom:0,right:0,transform:"translate(50%, 50%)",cursor:"nwse-resize"}},At={left:{top:I.GRID_LAYER_CORNER_HIT_SIZE,bottom:I.GRID_LAYER_CORNER_HIT_SIZE,left:0,width:I.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateX(-50%)",cursor:"ew-resize"},right:{top:I.GRID_LAYER_CORNER_HIT_SIZE,bottom:I.GRID_LAYER_CORNER_HIT_SIZE,right:0,width:I.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateX(50%)",cursor:"ew-resize"},top:{left:I.GRID_LAYER_CORNER_HIT_SIZE,right:I.GRID_LAYER_CORNER_HIT_SIZE,top:0,height:I.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateY(-50%)",cursor:"ns-resize"},bottom:{left:I.GRID_LAYER_CORNER_HIT_SIZE,right:I.GRID_LAYER_CORNER_HIT_SIZE,bottom:0,height:I.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateY(50%)",cursor:"ns-resize"}},jt=[{key:"top-left",variant:"corner",horizontal:"left",vertical:"top"},{key:"top-right",variant:"corner",horizontal:"right",vertical:"top"},{key:"bottom-left",variant:"corner",horizontal:"left",vertical:"bottom"},{key:"bottom-right",variant:"corner",horizontal:"right",vertical:"bottom"},{key:"left",variant:"edge",horizontal:"left"},{key:"right",variant:"edge",horizontal:"right"},{key:"top",variant:"edge",vertical:"top"},{key:"bottom",variant:"edge",vertical:"bottom"}],St=({layerId:t,onPointerDown:e})=>h.jsx(h.Fragment,{children:jt.map(n=>{const r=n.variant==="corner"?Gt:Nt,o=n.variant==="corner"?kt[n.key]:At[n.key],s={...r,...o},l=n.variant==="corner"?{"data-resize-corner":n.key}:{"data-resize-edge":n.key};return h.jsx("div",{role:"presentation","aria-hidden":"true",style:s,...l,"data-layer-id":t,onPointerDown:a=>e(n,a)},n.key)})}),Ot=({pivot:t})=>{const{Outlet:e}=Tt.usePivot({items:t.items,activeId:t.activeId,defaultActiveId:t.defaultActiveId,onActiveChange:t.onActiveChange,transitionMode:t.transitionMode});return h.jsx(e,{})},Yt=(t,e)=>t.pivot?h.jsx(Ot,{pivot:t.pivot}):t.cache?e(t.id):t.component,zt=d.memo(({layer:t,onClose:e})=>{const{getCachedContent:n}=C.usePanelSystem(),r=Yt(t,n);return t.floating?.chrome?h.jsx(C.FloatingWindow,{id:t.id,config:t.floating,onClose:e,children:r}):r});zt.displayName="LayerContentRenderer";const wt=d.memo(({layerId:t,isResizable:e,onPointerDown:n})=>e?h.jsx(St,{layerId:t,onPointerDown:n}):null);wt.displayName="LayerResizeHandles";const Ft=(t,e)=>t?"auto":e?"visible":"hidden",Rt=d.memo(({layer:t,handleLayerPointerDown:e})=>{const{getLayerRenderState:n}=C.useGridLayoutContext(),{style:r,isResizable:o,isResizing:s,onResizeHandlePointerDown:l}=n(t),a=d.useMemo(()=>{const m={};return t.gridArea&&(m.gridArea=t.gridArea),t.gridRow&&(m.gridRow=t.gridRow),t.gridColumn&&(m.gridColumn=t.gridColumn),m},[t.gridArea,t.gridRow,t.gridColumn]),u=d.useMemo(()=>{const m=!!t.floating,g=Ft(t.scrollable,m),S={...r,...a,minWidth:0,minHeight:0,overflow:g};return o?{...S,position:"relative"}:S},[r,a,o,t.scrollable,t.floating]),b=d.useCallback(()=>{t.floating?.onClose?.()},[t.floating]);return h.jsxs("div",{"data-layer-id":t.id,"data-draggable":!!t.floating?.draggable,"data-resizable":o,"data-resizing":s,style:u,onPointerDown:e,children:[h.jsx(C.LayerInstanceProvider,{layerId:t.id,children:h.jsx(zt,{layer:t,onClose:b})}),h.jsx(wt,{layerId:t.id,isResizable:o,onPointerDown:l})]})});Rt.displayName="EmbeddedLayer";const Et=({layers:t})=>{const{handleLayerPointerDown:e}=C.useGridLayoutContext();return h.jsx(h.Fragment,{children:t.map(n=>{const r=n.floating?.mode??"embedded";return n.floating&&r==="popup"?h.jsx(C.PopupLayerPortal,{layer:n},n.id):h.jsx(Rt,{layer:n,handleLayerPointerDown:e},n.id)})})},at={position:"absolute",pointerEvents:"auto"},Q=({direction:t,trackIndex:e,align:n,gap:r,span:o,onResize:s})=>{const l=t==="col"?"vertical":"horizontal",a=d.useCallback(m=>{const g=n==="start"?-m:m;s(t,e,g)},[n,t,e,s]),u=d.useMemo(()=>t==="col"?{gridColumn:`${e+1} / ${e+2}`,gridRow:`${o.start} / ${o.end}`}:{gridRow:`${e+1} / ${e+2}`,gridColumn:`${o.start} / ${o.end}`},[t,e,o]),b=d.useMemo(()=>{const g=Math.max(0,r)/2+I.GRID_HANDLE_THICKNESS/2;return t==="col"?{...at,width:I.GRID_HANDLE_THICKNESS,height:"100%",top:0,bottom:0,...n==="start"?{left:-g}:{right:-g}}:{...at,width:"100%",height:I.GRID_HANDLE_THICKNESS,left:0,right:0,...n==="start"?{top:-g}:{bottom:-g}}},[n,t,r]);return h.jsx("div",{"data-resizable":"true",style:{...u,position:"relative",pointerEvents:"none"},children:h.jsx("div",{"data-direction":l,"data-align":n,"data-handle":"true",style:b,children:h.jsx(xt.ResizeHandle,{direction:l,onResize:a})})})},$t=t=>{const e=new Map;t.forEach((r,o)=>{r.forEach((s,l)=>{if(!s||s===".")return;const a=e.get(s);if(a){const b={rowStart:Math.min(a.rowStart,o),rowEnd:Math.max(a.rowEnd,o),colStart:Math.min(a.colStart,l),colEnd:Math.max(a.colEnd,l)};e.set(s,b);return}const u={rowStart:o,rowEnd:o,colStart:l,colEnd:l};e.set(s,u)})});const n=new Map;return e.forEach((r,o)=>{const s=r.rowStart+1,l=r.rowEnd+2,a=r.colStart+1,u=r.colEnd+2,b={gridArea:o,gridRow:`${s} / ${l}`,gridColumn:`${a} / ${u}`};n.set(o,b)}),n},Bt=(t,e)=>{if((t.positionMode??"grid")!=="grid")return t;const r=t.gridArea??t.id,o=e.get(r);if(!o)return t;const s=!t.gridArea,l=!t.gridRow,a=!t.gridColumn;return!s&&!l&&!a?t:{...t,gridArea:s?o.gridArea:t.gridArea,gridRow:l?o.gridRow:t.gridRow,gridColumn:a?o.gridColumn:t.gridColumn}},vt=(t,e)=>{const n=d.useMemo(()=>$t(t.areas),[t.areas]),r=d.useMemo(()=>e.map(a=>Bt(a,n)),[e,n]),o=d.useMemo(()=>r.filter(a=>a.visible!==!1),[r]),s=d.useMemo(()=>o.filter(a=>!a.drawer),[o]),l=d.useMemo(()=>{const a=new Map;return r.forEach(u=>{a.set(u.id,u)}),a},[r]);return{normalizedLayers:r,visibleLayers:o,regularLayers:s,layerById:l}},Wt=t=>{if(!t)return{rowGap:0,columnGap:0};const e=t.split(/\s+/).map(r=>r.trim()).filter(Boolean),n=r=>{const o=r.match(/^(-?\d+(?:\.\d+)?)px$/);return o?Number.parseFloat(o[1]):0};if(e.length===1){const r=n(e[0]);return{rowGap:r,columnGap:r}}return{rowGap:n(e[0]),columnGap:n(e[1])}},Xt=(t,e)=>{if(!t)return[];const n=getComputedStyle(t);return(e==="col"?n.gridTemplateColumns:n.gridTemplateRows).split(/\s+/).map(o=>parseFloat(o)).filter(o=>!Number.isNaN(o))},et=(t,e=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY)=>Math.min(Math.max(t,e),n),Kt=(t,e)=>typeof t!="number"||!Number.isFinite(t)?e:t,Z=(t,e)=>`${t}-${e}`,Zt=(t,e,n,r)=>{const o=Z(n,r),s=e[o];return s!==void 0?`minmax(${t.minSize??0}px, ${s}px)`:t.size},ct=(t,e,n)=>t.map((r,o)=>Zt(r,e,n,o)).join(" "),W=(t,e)=>t.reduce((n,r,o)=>(r.resizable&&r.size.endsWith("px")&&(n[Z(e,o)]=parseInt(r.size,10)),n),{}),Vt=({trackSizes:t,track:e,direction:n,trackIndex:r,containerRef:o})=>{const s=Z(n,r),l=t[s];if(l!==void 0)return l;const u=Xt(o?.current??null,n)[r];return u!==void 0&&u>0?u:e.size.endsWith("px")?Number.parseInt(e.size,10):300},qt=(t,e)=>t.reduce((n,r,o)=>o===e?n:r.size.includes("fr")?n+100:n+(r.minSize??50),0),Ut=({track:t,tracks:e,trackIndex:n,direction:r,containerRef:o,gapSizes:s})=>{if(!o?.current)return t.maxSize;const l=r==="col"?o.current.offsetWidth:o.current.offsetHeight,a=qt(e,n),u=e.length-1,b=r==="col"?s.columnGap:s.rowGap,m=u*b,g=l-a-m;return t.maxSize!==void 0?Math.min(t.maxSize,g):g},Jt=(t,e,n)=>et(t,e??Number.NEGATIVE_INFINITY,n??Number.POSITIVE_INFINITY),lt=(t,e)=>{const n=t.length,r=[];for(let l=0;l<n;l++){const a=t[l],u=a[e],b=a[e+1];u!==b&&r.push(l)}if(r.length===0)return{start:1,end:n+1};const o=Math.min(...r),s=Math.max(...r);return{start:o+1,end:s+2}},ut=(t,e)=>{const n=t[e],r=t[e+1],o=n?.length??0,s=[];for(let u=0;u<o;u++){const b=n?.[u],m=r?.[u];b!==m&&s.push(u)}if(s.length===0)return{start:1,end:o+1};const l=Math.min(...s),a=Math.max(...s);return{start:l+1,end:a+2}},Qt=(t,e)=>{if(t.length===0)return[];const n=e.length;if(t.length===1)return t[0]?.resizable?[{trackIndex:0,align:"end",span:{start:1,end:n+1}}]:[];const r=[];return Array.from({length:t.length-1},(s,l)=>l).forEach(s=>{const l=t[s];if(t[s+1]?.resizable){const u=lt(e,s);r.push({trackIndex:s+1,align:"start",span:u});return}if(l?.resizable){const u=lt(e,s);r.push({trackIndex:s,align:"end",span:u})}}),r},te=(t,e)=>{if(t.length===0)return[];const n=e[0]?.length??0;if(t.length===1)return t[0]?.resizable?[{trackIndex:0,align:"end",span:{start:1,end:n+1}}]:[];const r=[];return Array.from({length:t.length-1},(s,l)=>l).forEach(s=>{const l=t[s];if(t[s+1]?.resizable){const u=ut(e,s);r.push({trackIndex:s+1,align:"start",span:u});return}if(l?.resizable){const u=ut(e,s);r.push({trackIndex:s,align:"end",span:u})}}),r},ee=t=>t!==void 0?{gap:t}:{},ne=(t,e)=>{const n=Object.keys(e),r={};for(const m of n)r[m]=t[m]??e[m];const o=Object.keys(t),s=o.length!==n.length,l=o.some(m=>!Object.prototype.hasOwnProperty.call(r,m)),a=s?!0:l,u=n.some(m=>t[m]!==r[m]);return(a?!0:u)?r:null},It=(t,e,n)=>{const[r,o]=d.useState(()=>({...W(t.columns,"col"),...W(t.rows,"row")}));pt.useIsomorphicLayoutEffect(()=>{const g={...W(t.columns,"col"),...W(t.rows,"row")};o(S=>ne(S,g)??S)},[t.columns,t.rows]);const s=d.useMemo(()=>t.areas.map(g=>`"${g.join(" ")}"`).join(" "),[t.areas]),l=d.useMemo(()=>Wt(t.gap),[t.gap]),a=d.useMemo(()=>Qt(t.columns,t.areas),[t.columns,t.areas]),u=d.useMemo(()=>te(t.rows,t.areas),[t.rows,t.areas]),b=d.useMemo(()=>({...t.style,...e,gridTemplateAreas:s,gridTemplateRows:ct(t.rows,r,"row"),gridTemplateColumns:ct(t.columns,r,"col"),...ee(t.gap)}),[s,t.columns,t.gap,t.rows,t.style,e,r]),m=d.useCallback((g,S,E)=>{const L=g==="row"?t.rows:t.columns,y=L[S];if(!y||!y.resizable)return;const M=Vt({trackSizes:r,track:y,direction:g,trackIndex:S,containerRef:n}),_=Ut({track:y,tracks:L,trackIndex:S,direction:g,containerRef:n,gapSizes:l}),x=Z(g,S);o(H=>{const k=M+E,G=Jt(k,y.minSize,_);return{...H,[x]:G}})},[t.columns,t.rows,r,n,l]);return{columnHandles:a,rowHandles:u,gapSizes:l,gridStyle:b,handleResize:m}},re=t=>t.positionMode?t.positionMode:t.floating?(t.floating.mode??"embedded")==="embedded"?"absolute":"relative":"grid",oe=t=>({position:t==="grid"?"relative":t}),se=(t,e)=>e!=="grid"?{}:{gridArea:t.gridArea,gridRow:t.gridRow,gridColumn:t.gridColumn},ie=t=>t?{top:t.top,right:t.right,bottom:t.bottom,left:t.left}:{},ae=t=>t!==void 0?{zIndex:t}:{},ce=(t,e)=>({width:t,height:e}),le=(t,e)=>t.pointerEvents!==void 0?typeof t.pointerEvents=="boolean"?{pointerEvents:t.pointerEvents?"auto":"none"}:{pointerEvents:t.pointerEvents}:e==="absolute"||e==="fixed"?{pointerEvents:"auto"}:{},ue=t=>t.floating?t.floating.position??t.floating.defaultPosition??t.position:t.position,de=t=>{if(t.floating){const e=t.floating.size??t.floating.defaultSize;if(e)return{width:e.width,height:e.height}}return{width:t.width,height:t.height}},ge=t=>t.floating?.zIndex!==void 0?t.floating.zIndex:t.zIndex,he=t=>{const e=re(t),n=ue(t),r=de(t),o=ge(t);return{...t.style,...oe(e),...se(t,e),...ie(n),...ae(o),...ce(r.width,r.height),...le(t,e)}},fe=t=>{const e=t.floating;return e?e.mode??"embedded":null},P=t=>fe(t)!=="embedded"?null:t.floating??null,dt=t=>t instanceof HTMLElement?["INPUT","TEXTAREA","SELECT","BUTTON"].includes(t.tagName):!1,gt=(t,e,n)=>{const r=e??Number.NEGATIVE_INFINITY,o=n??Number.POSITIVE_INFINITY;return et(t,r,o)},ht=(t,e,n)=>{if(typeof t=="number"&&Number.isFinite(t))return t;throw new Error(`Floating layer "${n}" must provide a numeric "${e}" value when draggable mode is enabled.`)},ft=t=>{const e=P(t);if(!e)throw new Error(`Floating layer "${t.id}" is missing floating configuration required for dragging.`);const n=e.position??e.defaultPosition??t.position;if(!n)throw new Error(`Floating layer "${t.id}" must define position with left and top values.`);return{left:ht(n.left,"left",t.id),top:ht(n.top,"top",t.id)}},me=t=>{const e=P(t);return e?e.constraints??{}:{}},pe=(t,e,n)=>t?t==="left"?e-n:e+n:e,be=(t,e,n)=>t?t==="top"?e-n:e+n:e,Se=(t,e,n)=>!t||t==="right"?e:e+n,ze=(t,e,n)=>!t||t==="bottom"?e:e+n,tt=(t,e)=>t?t.dataset.layerId===e?t:tt(t.parentElement,e):null,nt=(t,e,n)=>!t||n?.(t)?null:e(t)?t:nt(t.parentElement,e,n),we=t=>t instanceof HTMLElement?nt(t,e=>e.dataset.dragHandle==="true",e=>e.dataset.dragIgnore==="true"):null,mt=t=>t instanceof HTMLElement?nt(t,e=>e.dataset.resizeCorner!==void 0||e.dataset.resizeEdge!==void 0)!==null:!1,X=t=>{const e=P(t);return e?e.resizable===!0:!1},K=t=>{if(!P(t))return null;const n=ve(t);if(!n)throw new Error(`Floating layer "${t.id}" must define width and height when resizable or draggable.`);return{width:n.width,height:n.height}},Re=(t,e,n)=>{const r=t.filter(X).reduce((g,S)=>{if(n===S.id){const L=e[S.id];if(L)return g[S.id]=L,g}const E=K(S);return E&&(g[S.id]=E),g},{}),o=Object.keys(e),s=Object.keys(r),l=o.length!==s.length,a=o.some(g=>!Object.prototype.hasOwnProperty.call(r,g)),u=l?!0:a,b=s.some(g=>{const S=e[g],E=r[g];return!S||!E?!0:S.width!==E.width||S.height!==E.height});return{sizes:r,changed:u?!0:b}},Ee=({layers:t,layerById:e,isRootLevel:n})=>{const[r,o]=d.useState(null),[s,l]=d.useState(null),[a,u]=d.useState({}),[b,m]=d.useState({}),g=d.useRef(null),S=d.useRef(null),E=B.useEffectEvent((c,i)=>{e.get(c)?.floating?.onMove?.(i)}),L=B.useEffectEvent((c,i)=>{e.get(c)?.floating?.onResize?.(i)});pt.useIsomorphicLayoutEffect(()=>{const{sizes:c,changed:i}=Re(t,b,s);i&&m(c)},[t,s]);const y=d.useCallback((c,i,f,p)=>{const z=ft(i),v=a[c]??{x:0,y:0},w={pointerStartX:p.clientX,pointerStartY:p.clientY,initialTranslationX:v.x,initialTranslationY:v.y,baseLeft:z.left,baseTop:z.top,layerId:c,pointerId:p.pointerId,target:f};if(w.target.setPointerCapture)try{w.target.setPointerCapture(w.pointerId)}catch{}g.current=w,o(c)},[a]),M=d.useCallback(c=>{const i=c.target,f=we(i);if(!f)return;const p=f.closest("[data-layer-id]")?.getAttribute("data-layer-id");if(!p)return;const z=e.get(p);if(!z)return;const v=P(z);if(!(!v||v.draggable!==!0)&&!dt(c.target)&&!mt(c.target)&&f){const w=tt(f,p);if(!w)return;y(p,z,w,c);return}},[y,e]),_=d.useCallback((c,i)=>{const f=e.get(c),p=f?P(f):null;if(!f||!p||p.draggable!==!0||dt(i.target)||mt(i.target))return;const z=tt(i.currentTarget,c);z&&y(c,f,z,i)},[y,e]),x=d.useCallback((c,i,f)=>{const p=e.get(c);if(!p||!X(p))return;const z=b[c]??K(p);if(!z)return;const v=ft(p),w=me(p),T=a[c]??{x:0,y:0};if(f.stopPropagation(),f.preventDefault(),f.currentTarget.setPointerCapture)try{f.currentTarget.setPointerCapture(f.pointerId)}catch{}S.current={layerId:c,pointerId:f.pointerId,horizontalEdge:i.horizontal,verticalEdge:i.vertical,startX:f.clientX,startY:f.clientY,startWidth:z.width,startHeight:z.height,startPosition:T,baseLeft:v.left,baseTop:v.top,minWidth:w.minWidth,maxWidth:w.maxWidth,minHeight:w.minHeight,maxHeight:w.maxHeight,target:f.currentTarget},l(c)},[e,a,b]),H=d.useCallback(c=>{const i=g.current;if(!i)return;const f=c.clientX-i.pointerStartX,p=c.clientY-i.pointerStartY,z={x:i.initialTranslationX+f,y:i.initialTranslationY+p};u(v=>({...v,[i.layerId]:z})),E(i.layerId,{left:i.baseLeft+z.x,top:i.baseTop+z.y})},[E]),k=d.useCallback(c=>{const i=S.current;if(!i||i.pointerId!==c.pointerId||!e.get(i.layerId))return;const p=c.clientX-i.startX,z=c.clientY-i.startY,v=pe(i.horizontalEdge,i.startWidth,p),w=be(i.verticalEdge,i.startHeight,z),T=gt(v,i.minWidth,i.maxWidth),D=gt(w,i.minHeight,i.maxHeight),Y=i.startWidth-T,V=i.startHeight-D,rt=Se(i.horizontalEdge,i.startPosition.x,Y),yt=ze(i.verticalEdge,i.startPosition.y,V),q=b[i.layerId],ot={width:T,height:D};(!q||q.width!==T||q.height!==D)&&(m(U=>({...U,[i.layerId]:ot})),L(i.layerId,ot));const st=a[i.layerId]??{x:0,y:0},F={x:rt,y:yt};(st.x!==F.x||st.y!==F.y)&&(u(U=>({...U,[i.layerId]:F})),E(i.layerId,{left:i.baseLeft+F.x,top:i.baseTop+F.y}))},[e,a,b,E,L]),G=d.useCallback(c=>{const i=g.current;if(i){if(i.pointerId===c.pointerId&&i.target.releasePointerCapture)try{i.target.releasePointerCapture(i.pointerId)}catch{}g.current=null}o(null)},[]),A=d.useCallback(c=>{const i=S.current;if(i){if(i.pointerId===c.pointerId&&i.target.releasePointerCapture)try{i.target.releasePointerCapture(i.pointerId)}catch{}S.current=null}l(null)},[]);B.useDocumentPointerEvents(r!==null,{onMove:H,onUp:G,onCancel:G}),B.useDocumentPointerEvents(s!==null,{onMove:k,onUp:A,onCancel:A});const j=d.useCallback(c=>{const i=he(c),f=P(c);if(!f||f.draggable!==!0)return i;const p=a[c.id],z=r===c.id,v=s===c.id,w=p?{transform:`translate(${p.x}px, ${p.y}px)`}:{},T=b[c.id],D=X(c)?K(c):null,Y=T??D,V=Y?{width:`${Y.width}px`,height:`${Y.height}px`}:{};return{...i,...V,...w,...z||v?{cursor:"grabbing"}:{}}},[r,a,b,s]),$=d.useCallback(c=>{if(!X(c))return{isResizable:!1};const f=b[c.id],p=K(c);return(f??p)!==null?{isResizable:!0,onPointerDown:(T,D)=>{x(c.id,T,D)}}:{isResizable:!1}},[x,b]),O=d.useCallback(c=>{const{isResizable:i,onPointerDown:f}=$(c),p=j(c),z=s===c.id;return{style:p,isResizable:i,isResizing:z,onResizeHandlePointerDown:(v,w)=>{f&&f(v,w)}}},[j,$,s]),R=d.useCallback(c=>({"data-drag-handle":"true",role:"button","aria-roledescription":"Drag handle","aria-label":"Drag layer",onPointerDown:i=>{_(c,i)}}),[_]);return{providerValue:d.useMemo(()=>({handleLayerPointerDown:M,getLayerRenderState:O,getLayerHandleProps:R,isRootLevel:n}),[R,O,M,n]),draggingLayerId:r,resizingLayerId:s}},ve=t=>{if(t.floating){const e=t.floating.size??t.floating.defaultSize;if(e)return{width:e.width,height:e.height}}if(typeof t.width=="number"&&typeof t.height=="number")return{width:t.width,height:t.height}},Ct={display:"grid",width:"100%",height:"100%",overflow:"hidden",position:"relative"},Ie={touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"},Ce={...Ct,overflow:"visible",height:"auto",minHeight:"100%"},ye=t=>t?Ce:Ct,Le=({config:t,layers:e,style:n,root:r=!1})=>{const o=d.useRef(null),{isIntersecting:s}=Ht(o,{threshold:0});return h.jsx(C.PanelSystemProvider,{config:t,layers:e,style:n,children:h.jsx(C.DrawerRevealProvider,{children:h.jsx(Te,{gridRef:o,isIntersecting:s,isRoot:r})})})},Te=({gridRef:t,isIntersecting:e,isRoot:n})=>{const{config:r,style:o,layers:s}=C.usePanelSystem(),{normalizedLayers:l,visibleLayers:a,regularLayers:u,layerById:b}=vt(r,s.defs),{columnHandles:m,rowHandles:g,gapSizes:S,gridStyle:E,handleResize:L}=It(r,o,t),{providerValue:y,draggingLayerId:M,resizingLayerId:_}=Ee({layers:l,layerById:b,isRootLevel:n}),{setGridRef:x}=C.useDrawerReveal();d.useLayoutEffect(()=>(x(t),()=>{x(null)}),[t,x]);const H=M?!0:!!_,k=d.useMemo(()=>({...ye(n),...E,...H?Ie:{}}),[E,H,n]),G=d.useMemo(()=>a.filter(R=>R.drawer?.inline?!C.isRevealMode(R.drawer.animationMode):!1),[a]),A=d.useMemo(()=>a.filter(R=>R.drawer?.inline?C.isRevealMode(R.drawer.animationMode):!1),[a]),j=d.useMemo(()=>a.filter(R=>R.drawer?!R.drawer.inline:!1),[a]),$=A.length>0,O=h.jsxs("div",{ref:t,style:k,"data-dragging":!!M,"data-resizing":!!_,"data-visible":e,children:[h.jsx(C.GridLayoutProvider,{value:y,children:h.jsx(Et,{layers:u})}),m.map(({trackIndex:R,align:N,span:c})=>h.jsx(Q,{direction:"col",trackIndex:R,align:N,gap:S.columnGap,span:c,onResize:L},`col-${R}:${N}`)),g.map(({trackIndex:R,align:N,span:c})=>h.jsx(Q,{direction:"row",trackIndex:R,align:N,gap:S.rowGap,span:c,onResize:L},`row-${R}:${N}`)),h.jsx(C.DrawerLayers,{layers:G})]});return $?h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[O,h.jsx(C.DrawerLayers,{layers:A})]}),h.jsx(C.DrawerLayers,{layers:j})]}):h.jsxs(h.Fragment,{children:[O,h.jsx(C.DrawerLayers,{layers:j})]})};exports.GridLayerList=Et;exports.GridLayerResizeHandles=St;exports.GridLayout=Le;exports.GridTrackResizeHandle=Q;exports.clampNumber=et;exports.toFiniteNumberOr=Kt;exports.useGridPlacements=vt;exports.useGridTracks=It;
2
- //# sourceMappingURL=GridLayout-DNOClFzz.cjs.map
1
+ "use strict";const h=require("react/jsx-runtime"),Lt=require("react"),C=require("./FloatingWindow-DpFpmX1f.cjs"),I=require("./styles-qf6ptVLD.cjs"),Tt=require("./SwipePivotTabBar-fjjXkpj7.cjs"),xt=require("./ResizeHandle-CBcAS918.cjs"),pt=require("./useIsomorphicLayoutEffect-DGRNF4Lf.cjs"),B=require("./useDocumentPointerEvents-DxDSOtip.cjs");function Mt(t){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const n in t)if(n!=="default"){const r=Object.getOwnPropertyDescriptor(t,n);Object.defineProperty(e,n,r.get?r:{enumerable:!0,get:()=>t[n]})}}return e.default=t,Object.freeze(e)}const d=Mt(Lt),_t=()=>{const t=new Map;return e=>{if(!e)return;const n=t.get(e);if(n!==void 0)return n;const r=t.size;return t.set(e,r),r}},Dt=_t(),J=new Map,Pt=t=>{const e=`ovs-threshold:${t.threshold}-rootMargin:${t.rootMargin}-root:${Dt(t.root)}`;if(J.has(e))return J.get(e);const n=new class{#t=new Map;#e=new IntersectionObserver(r=>{r.forEach(o=>{const s=this.#t.get(o.target);s&&s(o)})},t);observe(r,o){return this.#t.set(r,o),this.#e.observe(r),()=>{this.#t.delete(r),this.#e.unobserve(r)}}};return J.set(e,n),n},it=Object.freeze({x:0,y:0,width:0,height:0,top:0,right:0,bottom:0,left:0});function Ht(t,{threshold:e=0,rootMargin:n="0px",root:r=null}){const[o,s]=d.useState(null);return d.useEffect(()=>{const l=t.current;return l?Pt({threshold:e,rootMargin:n,root:r}).observe(l,u=>{s({isIntersecting:u.isIntersecting,boundingClientRect:u.boundingClientRect,intersectionRatio:u.intersectionRatio,intersectionRect:u.intersectionRect,rootBounds:u.rootBounds,target:u.target,time:u.time})}):void 0},[t,e,n,r]),d.useMemo(()=>({isIntersecting:o?.isIntersecting??!1,boundingClientRect:o?.boundingClientRect??it,intersectionRatio:o?.intersectionRatio??0,intersectionRect:o?.intersectionRect??it,rootBounds:o?.rootBounds??null,target:o?.target??t.current,time:o?.time??0}),[o,t])}const bt={position:"absolute",pointerEvents:"auto",boxSizing:"border-box",background:"transparent",border:"none"},Gt={...bt,width:I.GRID_LAYER_CORNER_HIT_SIZE,height:I.GRID_LAYER_CORNER_HIT_SIZE,zIndex:2},Nt={...bt,zIndex:1},kt={"top-left":{top:0,left:0,transform:"translate(-50%, -50%)",cursor:"nwse-resize"},"top-right":{top:0,right:0,transform:"translate(50%, -50%)",cursor:"nesw-resize"},"bottom-left":{bottom:0,left:0,transform:"translate(-50%, 50%)",cursor:"nesw-resize"},"bottom-right":{bottom:0,right:0,transform:"translate(50%, 50%)",cursor:"nwse-resize"}},At={left:{top:I.GRID_LAYER_CORNER_HIT_SIZE,bottom:I.GRID_LAYER_CORNER_HIT_SIZE,left:0,width:I.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateX(-50%)",cursor:"ew-resize"},right:{top:I.GRID_LAYER_CORNER_HIT_SIZE,bottom:I.GRID_LAYER_CORNER_HIT_SIZE,right:0,width:I.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateX(50%)",cursor:"ew-resize"},top:{left:I.GRID_LAYER_CORNER_HIT_SIZE,right:I.GRID_LAYER_CORNER_HIT_SIZE,top:0,height:I.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateY(-50%)",cursor:"ns-resize"},bottom:{left:I.GRID_LAYER_CORNER_HIT_SIZE,right:I.GRID_LAYER_CORNER_HIT_SIZE,bottom:0,height:I.GRID_LAYER_EDGE_HIT_THICKNESS,transform:"translateY(50%)",cursor:"ns-resize"}},jt=[{key:"top-left",variant:"corner",horizontal:"left",vertical:"top"},{key:"top-right",variant:"corner",horizontal:"right",vertical:"top"},{key:"bottom-left",variant:"corner",horizontal:"left",vertical:"bottom"},{key:"bottom-right",variant:"corner",horizontal:"right",vertical:"bottom"},{key:"left",variant:"edge",horizontal:"left"},{key:"right",variant:"edge",horizontal:"right"},{key:"top",variant:"edge",vertical:"top"},{key:"bottom",variant:"edge",vertical:"bottom"}],St=({layerId:t,onPointerDown:e})=>h.jsx(h.Fragment,{children:jt.map(n=>{const r=n.variant==="corner"?Gt:Nt,o=n.variant==="corner"?kt[n.key]:At[n.key],s={...r,...o},l=n.variant==="corner"?{"data-resize-corner":n.key}:{"data-resize-edge":n.key};return h.jsx("div",{role:"presentation","aria-hidden":"true",style:s,...l,"data-layer-id":t,onPointerDown:a=>e(n,a)},n.key)})}),Ot=({pivot:t})=>{const{Outlet:e}=Tt.usePivot({items:t.items,activeId:t.activeId,defaultActiveId:t.defaultActiveId,onActiveChange:t.onActiveChange,transitionMode:t.transitionMode});return h.jsx(e,{})},Yt=(t,e)=>t.pivot?h.jsx(Ot,{pivot:t.pivot}):t.cache?e(t.id):t.component,zt=d.memo(({layer:t,onClose:e})=>{const{getCachedContent:n}=C.usePanelSystem(),r=Yt(t,n);return t.floating?.chrome?h.jsx(C.FloatingWindow,{id:t.id,config:t.floating,onClose:e,children:r}):r});zt.displayName="LayerContentRenderer";const wt=d.memo(({layerId:t,isResizable:e,onPointerDown:n})=>e?h.jsx(St,{layerId:t,onPointerDown:n}):null);wt.displayName="LayerResizeHandles";const Ft=(t,e)=>t?"auto":e?"visible":"hidden",Rt=d.memo(({layer:t,handleLayerPointerDown:e})=>{const{getLayerRenderState:n}=C.useGridLayoutContext(),{style:r,isResizable:o,isResizing:s,onResizeHandlePointerDown:l}=n(t),a=d.useMemo(()=>{const m={};return t.gridArea&&(m.gridArea=t.gridArea),t.gridRow&&(m.gridRow=t.gridRow),t.gridColumn&&(m.gridColumn=t.gridColumn),m},[t.gridArea,t.gridRow,t.gridColumn]),u=d.useMemo(()=>{const m=!!t.floating,g=Ft(t.scrollable,m),S={...r,...a,minWidth:0,minHeight:0,overflow:g};return o?{...S,position:"relative"}:S},[r,a,o,t.scrollable,t.floating]),b=d.useCallback(()=>{t.floating?.onClose?.()},[t.floating]);return h.jsxs("div",{"data-layer-id":t.id,"data-draggable":!!t.floating?.draggable,"data-resizable":o,"data-resizing":s,style:u,onPointerDown:e,children:[h.jsx(C.LayerInstanceProvider,{layerId:t.id,children:h.jsx(zt,{layer:t,onClose:b})}),h.jsx(wt,{layerId:t.id,isResizable:o,onPointerDown:l})]})});Rt.displayName="EmbeddedLayer";const Et=({layers:t})=>{const{handleLayerPointerDown:e}=C.useGridLayoutContext();return h.jsx(h.Fragment,{children:t.map(n=>{const r=n.floating?.mode??"embedded";return n.floating&&r==="popup"?h.jsx(C.PopupLayerPortal,{layer:n},n.id):h.jsx(Rt,{layer:n,handleLayerPointerDown:e},n.id)})})},at={position:"absolute",pointerEvents:"auto"},Q=({direction:t,trackIndex:e,align:n,gap:r,span:o,onResize:s})=>{const l=t==="col"?"vertical":"horizontal",a=d.useCallback(m=>{const g=n==="start"?-m:m;s(t,e,g)},[n,t,e,s]),u=d.useMemo(()=>t==="col"?{gridColumn:`${e+1} / ${e+2}`,gridRow:`${o.start} / ${o.end}`}:{gridRow:`${e+1} / ${e+2}`,gridColumn:`${o.start} / ${o.end}`},[t,e,o]),b=d.useMemo(()=>{const g=Math.max(0,r)/2+I.GRID_HANDLE_THICKNESS/2;return t==="col"?{...at,width:I.GRID_HANDLE_THICKNESS,height:"100%",top:0,bottom:0,...n==="start"?{left:-g}:{right:-g}}:{...at,width:"100%",height:I.GRID_HANDLE_THICKNESS,left:0,right:0,...n==="start"?{top:-g}:{bottom:-g}}},[n,t,r]);return h.jsx("div",{"data-resizable":"true",style:{...u,position:"relative",pointerEvents:"none"},children:h.jsx("div",{"data-direction":l,"data-align":n,"data-handle":"true",style:b,children:h.jsx(xt.ResizeHandle,{direction:l,onResize:a})})})},$t=t=>{const e=new Map;t.forEach((r,o)=>{r.forEach((s,l)=>{if(!s||s===".")return;const a=e.get(s);if(a){const b={rowStart:Math.min(a.rowStart,o),rowEnd:Math.max(a.rowEnd,o),colStart:Math.min(a.colStart,l),colEnd:Math.max(a.colEnd,l)};e.set(s,b);return}const u={rowStart:o,rowEnd:o,colStart:l,colEnd:l};e.set(s,u)})});const n=new Map;return e.forEach((r,o)=>{const s=r.rowStart+1,l=r.rowEnd+2,a=r.colStart+1,u=r.colEnd+2,b={gridArea:o,gridRow:`${s} / ${l}`,gridColumn:`${a} / ${u}`};n.set(o,b)}),n},Bt=(t,e)=>{if((t.positionMode??"grid")!=="grid")return t;const r=t.gridArea??t.id,o=e.get(r);if(!o)return t;const s=!t.gridArea,l=!t.gridRow,a=!t.gridColumn;return!s&&!l&&!a?t:{...t,gridArea:s?o.gridArea:t.gridArea,gridRow:l?o.gridRow:t.gridRow,gridColumn:a?o.gridColumn:t.gridColumn}},vt=(t,e)=>{const n=d.useMemo(()=>$t(t.areas),[t.areas]),r=d.useMemo(()=>e.map(a=>Bt(a,n)),[e,n]),o=d.useMemo(()=>r.filter(a=>a.visible!==!1),[r]),s=d.useMemo(()=>o.filter(a=>!a.drawer),[o]),l=d.useMemo(()=>{const a=new Map;return r.forEach(u=>{a.set(u.id,u)}),a},[r]);return{normalizedLayers:r,visibleLayers:o,regularLayers:s,layerById:l}},Wt=t=>{if(!t)return{rowGap:0,columnGap:0};const e=t.split(/\s+/).map(r=>r.trim()).filter(Boolean),n=r=>{const o=r.match(/^(-?\d+(?:\.\d+)?)px$/);return o?Number.parseFloat(o[1]):0};if(e.length===1){const r=n(e[0]);return{rowGap:r,columnGap:r}}return{rowGap:n(e[0]),columnGap:n(e[1])}},Xt=(t,e)=>{if(!t)return[];const n=getComputedStyle(t);return(e==="col"?n.gridTemplateColumns:n.gridTemplateRows).split(/\s+/).map(o=>parseFloat(o)).filter(o=>!Number.isNaN(o))},et=(t,e=Number.NEGATIVE_INFINITY,n=Number.POSITIVE_INFINITY)=>Math.min(Math.max(t,e),n),Kt=(t,e)=>typeof t!="number"||!Number.isFinite(t)?e:t,Z=(t,e)=>`${t}-${e}`,Zt=(t,e,n,r)=>{const o=Z(n,r),s=e[o];return s!==void 0?`minmax(${t.minSize??0}px, ${s}px)`:t.size},ct=(t,e,n)=>t.map((r,o)=>Zt(r,e,n,o)).join(" "),W=(t,e)=>t.reduce((n,r,o)=>(r.resizable&&r.size.endsWith("px")&&(n[Z(e,o)]=parseInt(r.size,10)),n),{}),Vt=({trackSizes:t,track:e,direction:n,trackIndex:r,containerRef:o})=>{const s=Z(n,r),l=t[s];if(l!==void 0)return l;const u=Xt(o?.current??null,n)[r];return u!==void 0&&u>0?u:e.size.endsWith("px")?Number.parseInt(e.size,10):300},qt=(t,e)=>t.reduce((n,r,o)=>o===e?n:r.size.includes("fr")?n+100:n+(r.minSize??50),0),Ut=({track:t,tracks:e,trackIndex:n,direction:r,containerRef:o,gapSizes:s})=>{if(!o?.current)return t.maxSize;const l=r==="col"?o.current.offsetWidth:o.current.offsetHeight,a=qt(e,n),u=e.length-1,b=r==="col"?s.columnGap:s.rowGap,m=u*b,g=l-a-m;return t.maxSize!==void 0?Math.min(t.maxSize,g):g},Jt=(t,e,n)=>et(t,e??Number.NEGATIVE_INFINITY,n??Number.POSITIVE_INFINITY),lt=(t,e)=>{const n=t.length,r=[];for(let l=0;l<n;l++){const a=t[l],u=a[e],b=a[e+1];u!==b&&r.push(l)}if(r.length===0)return{start:1,end:n+1};const o=Math.min(...r),s=Math.max(...r);return{start:o+1,end:s+2}},ut=(t,e)=>{const n=t[e],r=t[e+1],o=n?.length??0,s=[];for(let u=0;u<o;u++){const b=n?.[u],m=r?.[u];b!==m&&s.push(u)}if(s.length===0)return{start:1,end:o+1};const l=Math.min(...s),a=Math.max(...s);return{start:l+1,end:a+2}},Qt=(t,e)=>{if(t.length===0)return[];const n=e.length;if(t.length===1)return t[0]?.resizable?[{trackIndex:0,align:"end",span:{start:1,end:n+1}}]:[];const r=[];return Array.from({length:t.length-1},(s,l)=>l).forEach(s=>{const l=t[s];if(t[s+1]?.resizable){const u=lt(e,s);r.push({trackIndex:s+1,align:"start",span:u});return}if(l?.resizable){const u=lt(e,s);r.push({trackIndex:s,align:"end",span:u})}}),r},te=(t,e)=>{if(t.length===0)return[];const n=e[0]?.length??0;if(t.length===1)return t[0]?.resizable?[{trackIndex:0,align:"end",span:{start:1,end:n+1}}]:[];const r=[];return Array.from({length:t.length-1},(s,l)=>l).forEach(s=>{const l=t[s];if(t[s+1]?.resizable){const u=ut(e,s);r.push({trackIndex:s+1,align:"start",span:u});return}if(l?.resizable){const u=ut(e,s);r.push({trackIndex:s,align:"end",span:u})}}),r},ee=t=>t!==void 0?{gap:t}:{},ne=(t,e)=>{const n=Object.keys(e),r={};for(const m of n)r[m]=t[m]??e[m];const o=Object.keys(t),s=o.length!==n.length,l=o.some(m=>!Object.prototype.hasOwnProperty.call(r,m)),a=s?!0:l,u=n.some(m=>t[m]!==r[m]);return(a?!0:u)?r:null},It=(t,e,n)=>{const[r,o]=d.useState(()=>({...W(t.columns,"col"),...W(t.rows,"row")}));pt.useIsomorphicLayoutEffect(()=>{const g={...W(t.columns,"col"),...W(t.rows,"row")};o(S=>ne(S,g)??S)},[t.columns,t.rows]);const s=d.useMemo(()=>t.areas.map(g=>`"${g.join(" ")}"`).join(" "),[t.areas]),l=d.useMemo(()=>Wt(t.gap),[t.gap]),a=d.useMemo(()=>Qt(t.columns,t.areas),[t.columns,t.areas]),u=d.useMemo(()=>te(t.rows,t.areas),[t.rows,t.areas]),b=d.useMemo(()=>({...t.style,...e,gridTemplateAreas:s,gridTemplateRows:ct(t.rows,r,"row"),gridTemplateColumns:ct(t.columns,r,"col"),...ee(t.gap)}),[s,t.columns,t.gap,t.rows,t.style,e,r]),m=d.useCallback((g,S,E)=>{const L=g==="row"?t.rows:t.columns,y=L[S];if(!y||!y.resizable)return;const M=Vt({trackSizes:r,track:y,direction:g,trackIndex:S,containerRef:n}),_=Ut({track:y,tracks:L,trackIndex:S,direction:g,containerRef:n,gapSizes:l}),x=Z(g,S);o(H=>{const k=M+E,G=Jt(k,y.minSize,_);return{...H,[x]:G}})},[t.columns,t.rows,r,n,l]);return{columnHandles:a,rowHandles:u,gapSizes:l,gridStyle:b,handleResize:m}},re=t=>t.positionMode?t.positionMode:t.floating?(t.floating.mode??"embedded")==="embedded"?"absolute":"relative":"grid",oe=t=>({position:t==="grid"?"relative":t}),se=(t,e)=>e!=="grid"?{}:{gridArea:t.gridArea,gridRow:t.gridRow,gridColumn:t.gridColumn},ie=t=>t?{top:t.top,right:t.right,bottom:t.bottom,left:t.left}:{},ae=t=>t!==void 0?{zIndex:t}:{},ce=(t,e)=>({width:t,height:e}),le=(t,e)=>t.pointerEvents!==void 0?typeof t.pointerEvents=="boolean"?{pointerEvents:t.pointerEvents?"auto":"none"}:{pointerEvents:t.pointerEvents}:e==="absolute"||e==="fixed"?{pointerEvents:"auto"}:{},ue=t=>t.floating?t.floating.position??t.floating.defaultPosition??t.position:t.position,de=t=>{if(t.floating){const e=t.floating.size??t.floating.defaultSize;if(e)return{width:e.width,height:e.height}}return{width:t.width,height:t.height}},ge=t=>t.floating?.zIndex!==void 0?t.floating.zIndex:t.zIndex,he=t=>{const e=re(t),n=ue(t),r=de(t),o=ge(t);return{...t.style,...oe(e),...se(t,e),...ie(n),...ae(o),...ce(r.width,r.height),...le(t,e)}},fe=t=>{const e=t.floating;return e?e.mode??"embedded":null},P=t=>fe(t)!=="embedded"?null:t.floating??null,dt=t=>t instanceof HTMLElement?["INPUT","TEXTAREA","SELECT","BUTTON"].includes(t.tagName):!1,gt=(t,e,n)=>{const r=e??Number.NEGATIVE_INFINITY,o=n??Number.POSITIVE_INFINITY;return et(t,r,o)},ht=(t,e,n)=>{if(typeof t=="number"&&Number.isFinite(t))return t;throw new Error(`Floating layer "${n}" must provide a numeric "${e}" value when draggable mode is enabled.`)},ft=t=>{const e=P(t);if(!e)throw new Error(`Floating layer "${t.id}" is missing floating configuration required for dragging.`);const n=e.position??e.defaultPosition??t.position;if(!n)throw new Error(`Floating layer "${t.id}" must define position with left and top values.`);return{left:ht(n.left,"left",t.id),top:ht(n.top,"top",t.id)}},me=t=>{const e=P(t);return e?e.constraints??{}:{}},pe=(t,e,n)=>t?t==="left"?e-n:e+n:e,be=(t,e,n)=>t?t==="top"?e-n:e+n:e,Se=(t,e,n)=>!t||t==="right"?e:e+n,ze=(t,e,n)=>!t||t==="bottom"?e:e+n,tt=(t,e)=>t?t.dataset.layerId===e?t:tt(t.parentElement,e):null,nt=(t,e,n)=>!t||n?.(t)?null:e(t)?t:nt(t.parentElement,e,n),we=t=>t instanceof HTMLElement?nt(t,e=>e.dataset.dragHandle==="true",e=>e.dataset.dragIgnore==="true"):null,mt=t=>t instanceof HTMLElement?nt(t,e=>e.dataset.resizeCorner!==void 0||e.dataset.resizeEdge!==void 0)!==null:!1,X=t=>{const e=P(t);return e?e.resizable===!0:!1},K=t=>{if(!P(t))return null;const n=ve(t);if(!n)throw new Error(`Floating layer "${t.id}" must define width and height when resizable or draggable.`);return{width:n.width,height:n.height}},Re=(t,e,n)=>{const r=t.filter(X).reduce((g,S)=>{if(n===S.id){const L=e[S.id];if(L)return g[S.id]=L,g}const E=K(S);return E&&(g[S.id]=E),g},{}),o=Object.keys(e),s=Object.keys(r),l=o.length!==s.length,a=o.some(g=>!Object.prototype.hasOwnProperty.call(r,g)),u=l?!0:a,b=s.some(g=>{const S=e[g],E=r[g];return!S||!E?!0:S.width!==E.width||S.height!==E.height});return{sizes:r,changed:u?!0:b}},Ee=({layers:t,layerById:e,isRootLevel:n})=>{const[r,o]=d.useState(null),[s,l]=d.useState(null),[a,u]=d.useState({}),[b,m]=d.useState({}),g=d.useRef(null),S=d.useRef(null),E=B.useEffectEvent((c,i)=>{e.get(c)?.floating?.onMove?.(i)}),L=B.useEffectEvent((c,i)=>{e.get(c)?.floating?.onResize?.(i)});pt.useIsomorphicLayoutEffect(()=>{const{sizes:c,changed:i}=Re(t,b,s);i&&m(c)},[t,s]);const y=d.useCallback((c,i,f,p)=>{const z=ft(i),v=a[c]??{x:0,y:0},w={pointerStartX:p.clientX,pointerStartY:p.clientY,initialTranslationX:v.x,initialTranslationY:v.y,baseLeft:z.left,baseTop:z.top,layerId:c,pointerId:p.pointerId,target:f};if(w.target.setPointerCapture)try{w.target.setPointerCapture(w.pointerId)}catch{}g.current=w,o(c)},[a]),M=d.useCallback(c=>{const i=c.target,f=we(i);if(!f)return;const p=f.closest("[data-layer-id]")?.getAttribute("data-layer-id");if(!p)return;const z=e.get(p);if(!z)return;const v=P(z);if(!(!v||v.draggable!==!0)&&!dt(c.target)&&!mt(c.target)&&f){const w=tt(f,p);if(!w)return;y(p,z,w,c);return}},[y,e]),_=d.useCallback((c,i)=>{const f=e.get(c),p=f?P(f):null;if(!f||!p||p.draggable!==!0||dt(i.target)||mt(i.target))return;const z=tt(i.currentTarget,c);z&&y(c,f,z,i)},[y,e]),x=d.useCallback((c,i,f)=>{const p=e.get(c);if(!p||!X(p))return;const z=b[c]??K(p);if(!z)return;const v=ft(p),w=me(p),T=a[c]??{x:0,y:0};if(f.stopPropagation(),f.preventDefault(),f.currentTarget.setPointerCapture)try{f.currentTarget.setPointerCapture(f.pointerId)}catch{}S.current={layerId:c,pointerId:f.pointerId,horizontalEdge:i.horizontal,verticalEdge:i.vertical,startX:f.clientX,startY:f.clientY,startWidth:z.width,startHeight:z.height,startPosition:T,baseLeft:v.left,baseTop:v.top,minWidth:w.minWidth,maxWidth:w.maxWidth,minHeight:w.minHeight,maxHeight:w.maxHeight,target:f.currentTarget},l(c)},[e,a,b]),H=d.useCallback(c=>{const i=g.current;if(!i)return;const f=c.clientX-i.pointerStartX,p=c.clientY-i.pointerStartY,z={x:i.initialTranslationX+f,y:i.initialTranslationY+p};u(v=>({...v,[i.layerId]:z})),E(i.layerId,{left:i.baseLeft+z.x,top:i.baseTop+z.y})},[E]),k=d.useCallback(c=>{const i=S.current;if(!i||i.pointerId!==c.pointerId||!e.get(i.layerId))return;const p=c.clientX-i.startX,z=c.clientY-i.startY,v=pe(i.horizontalEdge,i.startWidth,p),w=be(i.verticalEdge,i.startHeight,z),T=gt(v,i.minWidth,i.maxWidth),D=gt(w,i.minHeight,i.maxHeight),Y=i.startWidth-T,V=i.startHeight-D,rt=Se(i.horizontalEdge,i.startPosition.x,Y),yt=ze(i.verticalEdge,i.startPosition.y,V),q=b[i.layerId],ot={width:T,height:D};(!q||q.width!==T||q.height!==D)&&(m(U=>({...U,[i.layerId]:ot})),L(i.layerId,ot));const st=a[i.layerId]??{x:0,y:0},F={x:rt,y:yt};(st.x!==F.x||st.y!==F.y)&&(u(U=>({...U,[i.layerId]:F})),E(i.layerId,{left:i.baseLeft+F.x,top:i.baseTop+F.y}))},[e,a,b,E,L]),G=d.useCallback(c=>{const i=g.current;if(i){if(i.pointerId===c.pointerId&&i.target.releasePointerCapture)try{i.target.releasePointerCapture(i.pointerId)}catch{}g.current=null}o(null)},[]),A=d.useCallback(c=>{const i=S.current;if(i){if(i.pointerId===c.pointerId&&i.target.releasePointerCapture)try{i.target.releasePointerCapture(i.pointerId)}catch{}S.current=null}l(null)},[]);B.useDocumentPointerEvents(r!==null,{onMove:H,onUp:G,onCancel:G}),B.useDocumentPointerEvents(s!==null,{onMove:k,onUp:A,onCancel:A});const j=d.useCallback(c=>{const i=he(c),f=P(c);if(!f||f.draggable!==!0)return i;const p=a[c.id],z=r===c.id,v=s===c.id,w=p?{transform:`translate(${p.x}px, ${p.y}px)`}:{},T=b[c.id],D=X(c)?K(c):null,Y=T??D,V=Y?{width:`${Y.width}px`,height:`${Y.height}px`}:{};return{...i,...V,...w,...z||v?{cursor:"grabbing"}:{}}},[r,a,b,s]),$=d.useCallback(c=>{if(!X(c))return{isResizable:!1};const f=b[c.id],p=K(c);return(f??p)!==null?{isResizable:!0,onPointerDown:(T,D)=>{x(c.id,T,D)}}:{isResizable:!1}},[x,b]),O=d.useCallback(c=>{const{isResizable:i,onPointerDown:f}=$(c),p=j(c),z=s===c.id;return{style:p,isResizable:i,isResizing:z,onResizeHandlePointerDown:(v,w)=>{f&&f(v,w)}}},[j,$,s]),R=d.useCallback(c=>({"data-drag-handle":"true",role:"button","aria-roledescription":"Drag handle","aria-label":"Drag layer",onPointerDown:i=>{_(c,i)}}),[_]);return{providerValue:d.useMemo(()=>({handleLayerPointerDown:M,getLayerRenderState:O,getLayerHandleProps:R,isRootLevel:n}),[R,O,M,n]),draggingLayerId:r,resizingLayerId:s}},ve=t=>{if(t.floating){const e=t.floating.size??t.floating.defaultSize;if(e)return{width:e.width,height:e.height}}if(typeof t.width=="number"&&typeof t.height=="number")return{width:t.width,height:t.height}},Ct={display:"grid",width:"100%",height:"100%",overflow:"hidden",position:"relative"},Ie={touchAction:"none",WebkitTouchCallout:"none",WebkitUserSelect:"none",userSelect:"none"},Ce={...Ct,overflow:"visible",height:"auto",minHeight:"100%"},ye=t=>t?Ce:Ct,Le=({config:t,layers:e,style:n,root:r=!1})=>{const o=d.useRef(null),{isIntersecting:s}=Ht(o,{threshold:0});return h.jsx(C.PanelSystemProvider,{config:t,layers:e,style:n,children:h.jsx(C.DrawerRevealProvider,{children:h.jsx(Te,{gridRef:o,isIntersecting:s,isRoot:r})})})},Te=({gridRef:t,isIntersecting:e,isRoot:n})=>{const{config:r,style:o,layers:s}=C.usePanelSystem(),{normalizedLayers:l,visibleLayers:a,regularLayers:u,layerById:b}=vt(r,s.defs),{columnHandles:m,rowHandles:g,gapSizes:S,gridStyle:E,handleResize:L}=It(r,o,t),{providerValue:y,draggingLayerId:M,resizingLayerId:_}=Ee({layers:l,layerById:b,isRootLevel:n}),{setGridRef:x}=C.useDrawerReveal();d.useLayoutEffect(()=>(x(t),()=>{x(null)}),[t,x]);const H=M?!0:!!_,k=d.useMemo(()=>({...ye(n),...E,...H?Ie:{}}),[E,H,n]),G=d.useMemo(()=>a.filter(R=>R.drawer?.inline?!C.isRevealMode(R.drawer.animationMode):!1),[a]),A=d.useMemo(()=>a.filter(R=>R.drawer?.inline?C.isRevealMode(R.drawer.animationMode):!1),[a]),j=d.useMemo(()=>a.filter(R=>R.drawer?!R.drawer.inline:!1),[a]),$=A.length>0,O=h.jsxs("div",{ref:t,style:k,"data-dragging":!!M,"data-resizing":!!_,"data-visible":e,children:[h.jsx(C.GridLayoutProvider,{value:y,children:h.jsx(Et,{layers:u})}),m.map(({trackIndex:R,align:N,span:c})=>h.jsx(Q,{direction:"col",trackIndex:R,align:N,gap:S.columnGap,span:c,onResize:L},`col-${R}:${N}`)),g.map(({trackIndex:R,align:N,span:c})=>h.jsx(Q,{direction:"row",trackIndex:R,align:N,gap:S.rowGap,span:c,onResize:L},`row-${R}:${N}`)),h.jsx(C.DrawerLayers,{layers:G})]});return $?h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{position:"relative",width:"100%",height:"100%"},children:[O,h.jsx(C.DrawerLayers,{layers:A})]}),h.jsx(C.DrawerLayers,{layers:j})]}):h.jsxs(h.Fragment,{children:[O,h.jsx(C.DrawerLayers,{layers:j})]})};exports.GridLayerList=Et;exports.GridLayerResizeHandles=St;exports.GridLayout=Le;exports.GridTrackResizeHandle=Q;exports.clampNumber=et;exports.toFiniteNumberOr=Kt;exports.useGridPlacements=vt;exports.useGridTracks=It;
2
+ //# sourceMappingURL=GridLayout-EwKszYBy.cjs.map