react-dockable-desktop 2.1.0 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +269 -69
- package/dist/index.cjs +24 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +315 -59
- package/dist/index.d.ts +315 -59
- package/dist/index.js +24 -3
- package/dist/index.js.map +1 -1
- package/dist/styles.css +1092 -52
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,25 @@
|
|
|
1
|
-
import Ct,{useState as Pe,useRef as pe,useEffect as oe}from"react";import{createPortal as Ht}from"react-dom";import{createContext as ze,useContext as we,useState as Ut,useRef as Ae,useMemo as ut,useCallback as G,useEffect as gt}from"react";var Se=class{registry=new Map;register(o,a,m){this.registry.set(o,{Component:a,defaultOptions:m})}get(o){return this.registry.get(o)}getRegisteredIds(){return Array.from(this.registry.keys())}},nt=new Se;var Fe={floatWindow:{id:"dockable-desktop-floatWindow",defaultMessage:"Float Window"},minimizePanel:{id:"dockable-desktop-minimizePanel",defaultMessage:"Minimize Panel"},closeTab:{id:"dockable-desktop-closeTab",defaultMessage:"Close Tab"},restorePanel:{id:"dockable-desktop-restorePanel",defaultMessage:"Restore Panel"},maximizePanel:{id:"dockable-desktop-maximizePanel",defaultMessage:"Maximize Panel"},closePanel:{id:"dockable-desktop-closePanel",defaultMessage:"Close Panel"},dockWindow:{id:"dockable-desktop-dockWindow",defaultMessage:"Dock Window"},minimize:{id:"dockable-desktop-minimize",defaultMessage:"Minimize"},maximize:{id:"dockable-desktop-maximize",defaultMessage:"Maximize"},restoreSize:{id:"dockable-desktop-restoreSize",defaultMessage:"Restore Size"},close:{id:"dockable-desktop-close",defaultMessage:"Close"},closeEmptyGroup:{id:"dockable-desktop-closeEmptyGroup",defaultMessage:"Close empty split group"},anchorToRightEdge:{id:"dockable-desktop-anchorToRightEdge",defaultMessage:"Anchor to Right Edge"},anchorToBottomEdge:{id:"dockable-desktop-anchorToBottomEdge",defaultMessage:"Anchor to Bottom Edge"},windowAnchoringOptions:{id:"dockable-desktop-windowAnchoringOptions",defaultMessage:"Window Anchoring Options"},unsavedChangesTitle:{id:"dockable-desktop-unsavedChangesTitle",defaultMessage:"Unsaved Changes"},unsavedChangesMessage:{id:"dockable-desktop-unsavedChangesMessage",defaultMessage:'"{title}" has unsaved changes. Do you want to discard your changes and close?'},discardChanges:{id:"dockable-desktop-discardChanges",defaultMessage:"Discard Changes"},cancel:{id:"dockable-desktop-cancel",defaultMessage:"Cancel"},yes:{id:"dockable-desktop-yes",defaultMessage:"Yes"},no:{id:"dockable-desktop-no",defaultMessage:"No"},ok:{id:"dockable-desktop-ok",defaultMessage:"OK"},closePanelTooltip:{id:"dockable-desktop-closePanelTooltip",defaultMessage:"Close panel"},closeTooltip:{id:"dockable-desktop-closeTooltip",defaultMessage:"Close"}};import{jsx as Te}from"react/jsx-runtime";var kt=ze(null),ft=ze(null),It=ze(null),St=ze(Fe),Tt=ze({}),he=()=>we(Tt),zt=ze(nt),He=()=>we(zt),pt=class{listeners={};subscribe(o,a){return this.listeners[o]||(this.listeners[o]=[]),this.listeners[o].push(a),()=>{this.listeners[o]=this.listeners[o].filter(m=>m!==a)}}publish(o,a){this.listeners[o]&&this.listeners[o].forEach(m=>m(a))}},Jt={type:"leaf",id:"group-default",panels:[],activePanelId:null};function Vt(s){if(s)try{let o=JSON.parse(s);if(o.gridRoot&&Array.isArray(o.floating)&&Array.isArray(o.minimized)&&o.panels)return{gridRoot:o.gridRoot,floating:o.floating,minimized:o.minimized,panels:o.panels,activePanelId:Object.keys(o.panels)[0]??null}}catch{}return{gridRoot:Jt,floating:[],minimized:[],panels:{},activePanelId:null}}var Zt=({children:s,client:o,formatMessage:a,predefinedMessages:m,dir:N,modalClass:k,modalBodyClass:A,sidePanelClass:F,sidePanelBodyClass:M,windowClass:R,windowBodyClass:O})=>{let g=Ae(o?.registry??nt).current,T=o?.config.formatMessage??a,b=o?.config.predefinedMessages??m,I=o?.config.dir??N,[W,l]=Ut(()=>({...Vt(o?.initialState??null),draggedPanelId:null,dir:I||"ltr",isRtl:I==="rtl"})),w=Ae(W);w.current=W;let y=Ae({}),f=ut(()=>({...Fe,...b}),[b]),H=Ae(new pt),L=Ae(1e3),P=G((e,t)=>H.current.subscribe(e,t),[]),E=G((e,t)=>{H.current.publish(e,t)},[]),$=G((e,t)=>{let n=typeof e.x=="string"?parseFloat(e.x):e.x,i=typeof e.y=="string"?parseFloat(e.y):e.y,c=typeof e.width=="string"?parseFloat(e.width):e.width,d=typeof e.height=="string"?parseFloat(e.height):e.height;isNaN(n)&&(n=300),isNaN(i)&&(i=150),isNaN(c)&&(c=450),isNaN(d)&&(d=350);let C=B=>t.some(U=>{let _=typeof U.x=="string"?parseFloat(U.x):U.x,q=typeof U.y=="string"?parseFloat(U.y):U.y;return!U.maximized&&Math.abs(_-B.x)<20&&Math.abs(q-B.y)<20}),h=0;for(;C({x:n,y:i})&&h<10;)n+=30,i+=30,h++;let x=Math.max(100,window.innerWidth||1024),S=Math.max(100,window.innerHeight||768);return(n+c>x||i+d>S)&&(n=100+h%5*30,i=100+h%5*30),n=Math.max(0,Math.min(n,x-100)),i=Math.max(0,Math.min(i,S-40)),{x:n,y:i,width:c,height:d}},[]),z=G(e=>{L.current+=1;let t=L.current;l(n=>{let i=n.panels[e];if(!i)return n;if(i.state==="floating")return{...n,floating:n.floating.map(c=>c.id===e?{...c,z:t}:c),activePanelId:e};if(i.state==="docked"){let c=d=>d.type==="leaf"?d.panels.includes(e)?{...d,activePanelId:e}:d:{...d,children:d.children.map(c)};return{...n,gridRoot:c(n.gridRoot),activePanelId:e}}return{...n,activePanelId:e}})},[]),D=(e,t)=>{if(e.type==="leaf"){let n=e.panels.indexOf(t);if(n===-1)return e;let i=e.panels.filter(C=>C!==t),c=e.activePanelId===t?i[n]||i[n-1]||i[0]||null:e.activePanelId,d={...e,panels:i,activePanelId:c};return i.length===0&&!e.keepOnEmpty?null:d}else{let n=e.children.map(d=>D(d,t)).filter(d=>d!==null);if(n.length===0)return null;if(n.length===1)return n[0];let i=e.sizes.slice(0,n.length),c=i.reduce((d,C)=>d+C,0);return{...e,children:n,sizes:i.map(d=>d/c)}}},Y=(e,t,n)=>{if(e.type==="leaf"){if(e.id===t){let i=e.panels.includes(n)?e.panels:[...e.panels,n];return{...e,panels:i,activePanelId:n}}return e}else return{...e,children:e.children.map(i=>Y(i,t,n))}},ee=e=>{if(e.type==="leaf")return e.id;for(let t of e.children){let n=ee(t);if(n)return n}return null},se=G((e,t,n)=>{l(i=>{let c=i.panels[e],d=g.get(t),C=n?.title||n?.title||d?.defaultOptions?.title||e,h=n?.initialTarget||d?.defaultOptions?.initialTarget||"docked",x=d?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350};if(c)if(c.state==="minimized"){let _=i.minimized.filter(q=>q.id!==e);if(h==="floating"||!i.gridRoot){L.current+=1;let q=$(x,i.floating);return{...i,minimized:_,floating:[...i.floating,{...q,id:e,z:L.current}],panels:{...i.panels,[e]:{...c,state:"floating"}}}}else{let q=ee(i.gridRoot)||"group-default";return{...i,minimized:_,gridRoot:Y(i.gridRoot,q,e),panels:{...i.panels,[e]:{...c,state:"docked"}}}}}else{if(c.state==="floating")return z(e),i;{let _=q=>q.type==="leaf"?q.panels.includes(e)?{...q,activePanelId:e}:q:{...q,children:q.children.map(_)};return{...i,gridRoot:_(i.gridRoot)}}}let B={id:e,title:C,component:t,state:h==="tabbed"?"docked":h},U={...i.panels,[e]:B};if(h==="floating"){L.current+=1;let _=$(x,i.floating),q=n?.stickyRight??d?.defaultOptions?.defaultStickyRight??!1,Ce=n?.stickyBottom??d?.defaultOptions?.defaultStickyBottom??!1,We=Math.max(100,window.innerWidth||1024),Oe=Math.max(100,window.innerHeight||768),dt=typeof _.width=="string"?parseFloat(_.width):_.width,ct=typeof _.height=="string"?parseFloat(_.height):_.height,et=_.x,tt=_.y,De=10;return q&&(et=We-dt-De),Ce&&(tt=Oe-ct-De),{...i,floating:[...i.floating,{..._,id:e,z:L.current,x:et,y:tt,stickyRight:q,stickyBottom:Ce}],panels:U}}else{let _=ee(i.gridRoot)||"group-default";return{...i,gridRoot:Y(i.gridRoot,_,e),panels:U}}})},[$,z]),te=G(e=>{l(t=>{let n=t.panels[e];if(!n||g.get(n.component)?.defaultOptions?.canClose===!1)return t;delete y.current[e];let c={...t.panels};delete c[e];let d=D(t.gridRoot,e);return{...t,gridRoot:d||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:t.floating.filter(C=>C.id!==e),minimized:t.minimized.filter(C=>C.id!==e),panels:c}})},[]),K=G((e,t)=>{y.current[e]=t},[]),V=G(e=>{delete y.current[e]},[]),fe=G((e,t,n)=>{l(i=>{let c=i.panels[e];return c?{...i,panels:{...i.panels,[e]:{...c,dirty:t,dirtyOptions:n}}}:i})},[]),ce=G((e,t)=>{l(n=>{let i=n.panels[e];return i?{...n,panels:{...n.panels,[e]:{...i,title:t}}}:n})},[]),J=G(async(e,t)=>{if(t?.force){te(e);return}let n=y.current[e];if(n&&!await n())return;let i=w.current.panels[e];if(i?.dirty)if(t?.onConfirm){if(!await t.onConfirm(i.dirtyOptions))return}else return;te(e)},[te]),ae=G(e=>{l(t=>{let n=t.panels[e];if(!n||n.state==="minimized"||g.get(n.component)?.defaultOptions?.canMinimize===!1)return t;let c,d;if(n.state==="floating"){let h=t.floating.find(x=>x.id===e);h&&(c={x:Number(h.x),y:Number(h.y),width:Number(h.width),height:Number(h.height),stickyRight:h.stickyRight,stickyBottom:h.stickyBottom})}else if(n.state==="docked"){let h=x=>{if(x.type==="leaf")return x.panels.includes(e)?x.id:null;for(let S of x.children){let B=h(S);if(B)return B}return null};d=h(t.gridRoot)??void 0}let C=D(t.gridRoot,e);return{...t,gridRoot:C||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:t.floating.filter(h=>h.id!==e),minimized:[...t.minimized,{id:e,title:n.title,component:n.component}],panels:{...t.panels,[e]:{...n,state:"minimized",previousState:n.state,lastFloatingRect:c,lastLeafId:d}}}})},[]),Z=G(e=>{l(t=>{let n=t.panels[e];if(!n||n.state!=="minimized")return t;let i=t.minimized.filter(d=>d.id!==e);if((n.previousState||"docked")==="floating"){L.current+=1;let d=g.get(n.component),C=n.lastFloatingRect||d?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},h=$(C,t.floating);return{...t,minimized:i,floating:[...t.floating,{...h,id:e,z:L.current,stickyRight:!!n.lastFloatingRect?.stickyRight,stickyBottom:!!n.lastFloatingRect?.stickyBottom}],panels:{...t.panels,[e]:{...n,state:"floating"}}}}else{let d=(S,B)=>S.type==="leaf"?S.id===B:S.children.some(U=>d(U,B)),C=n.lastLeafId&&d(t.gridRoot,n.lastLeafId),h=g.get(n.component),x=h?.defaultOptions?.canDrag!==!1;if(C)return{...t,minimized:i,gridRoot:Y(t.gridRoot,n.lastLeafId,e),panels:{...t.panels,[e]:{...n,state:"docked"}}};if(x){L.current+=1;let S=n.lastFloatingRect||h?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},B=$(S,t.floating);return{...t,minimized:i,floating:[...t.floating,{...B,id:e,z:L.current,stickyRight:!!n.lastFloatingRect?.stickyRight,stickyBottom:!!n.lastFloatingRect?.stickyBottom}],panels:{...t.panels,[e]:{...n,state:"floating"}}}}else{let S=ee(t.gridRoot)||"group-default";return{...t,minimized:i,gridRoot:Y(t.gridRoot,S,e),panels:{...t.panels,[e]:{...n,state:"docked"}}}}}})},[$]),Q=G((e,t)=>{l(n=>{let i=n.panels[e];if(!i||g.get(i.component)?.defaultOptions?.canDrag===!1)return n;let d=g.get(i.component),C=t||d?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},h=D(n.gridRoot,e);L.current+=1;let x=$(C,n.floating);return{...n,gridRoot:h||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:[...n.floating,{...x,id:e,z:L.current}],panels:{...n.panels,[e]:{...i,state:"floating"}}}})},[$]),Ge=G((e,t)=>{l(n=>{let i=n.panels[e];if(!i)return n;let c=n.floating.filter(h=>h.id!==e),d=D(n.gridRoot,e),C=t||ee(d||n.gridRoot)||"group-default";return{...n,gridRoot:Y(d||n.gridRoot,C,e),floating:c,panels:{...n.panels,[e]:{...i,state:"docked"}}}})},[]),be=(e,t,n,i)=>{if(e.type==="leaf"){if(e.id===t){let c={type:"leaf",id:`group-split-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[n],activePanelId:n};return{type:"branch",orientation:i==="left"||i==="right"?"horizontal":"vertical",sizes:[.5,.5],children:i==="left"||i==="top"?[c,e]:[e,c]}}return e}else return{...e,children:e.children.map(c=>be(c,t,n,i))}},me=G(e=>{l(t=>({...t,draggedPanelId:e}))},[]),Ye=G((e,t,n)=>{l(i=>{let c=i.panels[e];if(!c)return i;let d=i.floating.filter(x=>x.id!==e),C=D(i.gridRoot,e),h;return n==="center"?h=Y(C||i.gridRoot,t,e):h=be(C||i.gridRoot,t,e,n),{...i,gridRoot:h,floating:d,panels:{...i.panels,[e]:{...c,state:"docked"}},draggedPanelId:null}})},[]),Xe=G((e,t)=>{l(n=>{let i=n.panels[e];if(!i)return n;let c=n.floating.filter(B=>B.id!==e),d=D(n.gridRoot,e),C={type:"leaf",id:`group-edge-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[e],activePanelId:e},h=t==="left"||t==="right"?"horizontal":"vertical",x=t==="left"||t==="top"?[C,d||n.gridRoot]:[d||n.gridRoot,C];return{...n,gridRoot:{type:"branch",orientation:h,sizes:t==="left"||t==="top"?[.3,.7]:[.7,.3],children:x},floating:c,panels:{...n.panels,[e]:{...i,state:"docked"}},draggedPanelId:null}})},[]),qe=G((e,t,n)=>{l(i=>{let c=i.panels[e];if(!c)return i;let d=D(i.gridRoot,e),C=S=>{if(S.type==="leaf"){if(S.id===t){let B=S.panels.filter(q=>q!==e),U=Math.max(0,Math.min(n,B.length)),_=[...B];return _.splice(U,0,e),{...S,panels:_,activePanelId:e}}return S}else return{...S,children:S.children.map(C)}},h=C(d||i.gridRoot),x=i.floating.filter(S=>S.id!==e);return{...i,gridRoot:h,floating:x,panels:{...i.panels,[e]:{...c,state:"docked"}},draggedPanelId:null}})},[]),Ke=G(e=>{l(t=>{let n=c=>{if(c.type==="leaf")return c.id===e&&c.canClose!==!1?null:c;{let d=c.children.map(x=>n(x)).filter(x=>x!==null);if(d.length===0)return null;if(d.length===1)return d[0];let C=c.sizes.slice(0,d.length),h=C.reduce((x,S)=>x+S,0);return{...c,children:d,sizes:C.map(x=>x/h)}}},i=n(t.gridRoot);return{...t,gridRoot:i||{type:"leaf",id:"group-default",panels:[],activePanelId:null}}})},[]),je=G(e=>{l(t=>({...t,floating:t.floating.map(n=>n.id===e?{...n,maximized:!n.maximized}:n)}))},[]),Ie=G((e,t)=>{let n=(i,c)=>{if(i.type==="leaf")return i;if(c===e.length)return{...i,sizes:t};let d=e[c],C=i.children.map((h,x)=>x===d?n(h,c+1):h);return{...i,children:C}};l(i=>({...i,gridRoot:n(i.gridRoot,0)}))},[]),ue=G((e,t)=>{l(n=>({...n,floating:n.floating.map(i=>i.id===e?{...i,...t}:i)}))},[]),Ue=G(()=>JSON.stringify({gridRoot:w.current.gridRoot,floating:w.current.floating,minimized:w.current.minimized,panels:w.current.panels}),[]),Je=G(e=>{try{let t=JSON.parse(e);if(t.gridRoot&&t.floating&&t.minimized&&t.panels){let n=Object.keys(t.panels)[0]||null;return l(i=>({...i,gridRoot:t.gridRoot,floating:t.floating,minimized:t.minimized,panels:t.panels,draggedPanelId:null,activePanelId:n})),!0}return!1}catch(t){return console.error("Failed to parse layout configuration:",t),!1}},[]),Ve=G(e=>{l(t=>t.activePanelId===e?t:{...t,activePanelId:e})},[]),Ne=G(e=>{l(t=>t.dir===e?t:{...t,dir:e,isRtl:e==="rtl"})},[]),Ze=G(e=>e in w.current.panels,[]),Qe=G(()=>Object.keys(w.current.panels),[]);gt(()=>{I&&l(e=>e.dir===I?e:{...e,dir:I,isRtl:I==="rtl"})},[I]);let r=ut(()=>({openPanel:se,closePanel:te,minimizePanel:ae,restorePanel:Z,floatPanel:Q,dockPanel:Ge,maximizePanel:je,updateSplitSizes:Ie,updateFloatingPosition:ue,focusPanel:z,isOpen:Ze,getOpenPanelIds:Qe,saveLayout:Ue,loadLayout:Je,publish:E,subscribe:P,setDraggedPanelId:me,dockPanelToGroup:Ye,movePanelOrder:qe,closeLeafGroup:Ke,registerCloseGuard:K,unregisterCloseGuard:V,setPanelDirty:fe,updatePanelTitle:ce,requestClosePanel:J,dockPanelToWorkspaceEdge:Xe,setActivePanel:Ve,setDirection:Ne}),[se,te,ae,Z,Q,Ge,je,Ie,ue,z,Ze,Qe,Ue,Je,E,P,me,Ye,qe,Ke,K,V,fe,ce,J,Xe,Ve,Ne]),v=e=>{let t=e.defaultMessage||e.id;return e.values&&Object.entries(e.values).forEach(([n,i])=>{t=t.replace(`{${n}}`,String(i))}),t},u=ut(()=>({modalClass:k,modalBodyClass:A,sidePanelClass:F,sidePanelBodyClass:M,windowClass:R,windowBodyClass:O}),[k,A,F,M,R,O]);return gt(()=>{if(process.env.NODE_ENV!=="development")return;let e=!1;try{for(let t of Array.from(document.styleSheets))try{if(Array.from(t.cssRules||[]).some(i=>i.cssText?.includes("react-contexify"))){e=!0;break}}catch{}}catch{}e||console.warn(`[react-dockable-desktop] replace-react-contexify CSS not detected. Context menus may not render correctly.
|
|
2
|
-
Add
|
|
3
|
-
new WorkspaceClient({ panels: { "${o}": { component: YourComponent } } })`),j("div",{className:"dw-unregistered-panel",style:{border:"2px dashed #dc3545"},children:[p("h6",{style:{fontWeight:700,marginBottom:"0.25rem"},children:"\u26A0\uFE0F Component Unregistered"}),j("span",{style:{fontSize:"0.875rem",color:"var(--text-secondary, #94a3b8)"},children:["Key: ",o]})]});let N=m.Component;return p(N,{panelId:s})},$t=new Map,Ee=new Map,it=s=>{let o=Ee.get(s);return o||(o={onClose:new Set,onMinimize:new Set,onRestore:new Set,onResize:new Set},Ee.set(s,o)),o},_t=({panelId:s})=>{let o=pe(null);return oe(()=>{let a=o.current;if(!a)return;let m=Bt(s);a.appendChild(m);let N=new ResizeObserver(k=>{for(let A of k){let{width:F,height:M}=A.contentRect;if(F>0&&M>0){$t.set(s,{width:F,height:M});let R=Ee.get(s);R&&R.onResize.forEach(O=>O(F,M))}}});return N.observe(a),()=>{N.disconnect();let k=document.getElementById(st);k||(k=document.createElement("div"),k.id=st,k.style.display="none",document.body.appendChild(k)),k.appendChild(m)}},[s]),p("div",{ref:o,style:{width:"100%",height:"100%"}})},pn=({panelId:s})=>{let o=ge(),a=He(),m=ne(),N=pe(null),k=o.panels[s],A=k?a.get(k.component):null,F=A?.defaultOptions?.disableLivePreview||!1,M=$t.get(s)||{width:800,height:500},R=M.width,O=M.height,b=Math.min(220/R,140/O);if(oe(()=>{if(F)return;let I=N.current;if(!I)return;let W=$e.get(s);if(W)return I.appendChild(W),()=>{let l=document.getElementById(st);l||(l=document.createElement("div"),l.id=st,l.style.display="none",document.body.appendChild(l)),l.appendChild(W)}},[s,F]),F){let I=R*b,W=O*b,l=k?.title||A?.defaultOptions?.title||"Panel",w=X(l,m),y=(Array.from(w)[0]||"P").toUpperCase();return p("div",{className:"taskbar-item-preview-frame",style:{width:`${I}px`,height:`${W}px`,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(108, 117, 125, 0.15)",border:"1px dashed var(--taskbar-item-border, rgba(255, 255, 255, 0.15))"},children:p("div",{style:{fontSize:"2rem",fontWeight:600,color:"var(--panel-title-color, var(--panel-text, rgba(255, 255, 255, 0.85)))",userSelect:"none"},children:y})})}return p("div",{className:"taskbar-item-preview-frame",style:{width:`${R*b}px`,height:`${O*b}px`},children:p("div",{ref:N,className:"taskbar-item-preview-host",style:{width:`${R}px`,height:`${O}px`,transform:`scale(${b})`,transformOrigin:"top left",position:"absolute",top:0,left:0,"--preview-scale":b}})})},fn=({panelId:s,children:o})=>{let a=ge(),{requestClosePanel:m,setPanelDirty:N,registerCloseGuard:k,unregisterCloseGuard:A,updatePanelTitle:F}=Be(),M=a.minimized.some(g=>g.id===s),R=pe(M);oe(()=>{let g=Ee.get(s);g&&(M&&!R.current?g.onMinimize.forEach(T=>T()):!M&&R.current&&g.onRestore.forEach(T=>T()),R.current=M)},[M,s]),oe(()=>()=>{let g=Ee.get(s);g&&(g.onClose.forEach(T=>T()),Ee.delete(s))},[s]);let O=Ct.useMemo(()=>({requestClose:g=>m(s,g),setDirty:g=>N(s,g),onCloseRequested:g=>(k(s,g),()=>A(s)),setTitle:g=>F(s,g),instanceId:s,onClose:g=>{let T=it(s);return T.onClose.add(g),()=>T.onClose.delete(g)},onMinimize:g=>{let T=it(s);return T.onMinimize.add(g),()=>T.onMinimize.delete(g)},onRestore:g=>{let T=it(s);return T.onRestore.add(g),()=>T.onRestore.delete(g)},onResize:g=>{let T=it(s);return T.onResize.add(g),()=>T.onResize.delete(g)}}),[s,m,N,k,A,F]);return p(xe,{value:O,children:o})},Gt=({node:s,path:o,onTabRightClick:a,activeDropZone:m,onHoverDropZone:N,onTabDragStart:k,hoveredTab:A,onTabHover:F,defaultPanelIcon:M,onRequestClosePanel:R})=>{let{updateSplitSizes:O}=Be();if(s.type==="leaf")return p(mn,{leaf:s,onTabRightClick:a,activeDropZone:m,onHoverDropZone:N,onTabDragStart:k,hoveredTab:A,onTabHover:F,defaultPanelIcon:M,onRequestClosePanel:R});let g=s.orientation==="horizontal",T=(b,I)=>{I.preventDefault();let W=g?I.clientX:I.clientY,l=[...s.sizes],w=I.currentTarget;w.classList.add("active"),document.body.classList.add("resizing-active",g?"resizing-row-active":"resizing-col-active");let y=I.currentTarget.parentElement,f=y?g?y.clientWidth:y.clientHeight:g?1e3:800,H=P=>{let z=((g?P.clientX:P.clientY)-W)/f,D=[...l];D[b]+=z,D[b+1]-=z,D[b]>.1&&D[b+1]>.1&&O(o,D)},L=()=>{w.classList.remove("active"),document.body.classList.remove("resizing-active","resizing-row-active","resizing-col-active"),window.removeEventListener("mousemove",H),window.removeEventListener("mouseup",L)};window.addEventListener("mousemove",H),window.addEventListener("mouseup",L)};return p("div",{style:{display:"flex",flexDirection:g?"row":"column",width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:s.children.map((b,I)=>{let W=s.sizes[I]*100;return j(Ct.Fragment,{children:[p("div",{style:{flexGrow:s.sizes[I],flexBasis:`${W}%`,overflow:"hidden",position:"relative"},children:p(Gt,{node:b,path:[...o,I],onTabRightClick:a,activeDropZone:m,onHoverDropZone:N,onTabDragStart:k,hoveredTab:A,onTabHover:F,defaultPanelIcon:M,onRequestClosePanel:R})}),I<s.children.length-1&&p("div",{onMouseDown:l=>T(I,l),style:{cursor:g?"col-resize":"row-resize",width:g?"1px":"100%",height:g?"100%":"1px",zIndex:20},className:"resizer-bar"})]},I)})})},mn=({leaf:s,onTabRightClick:o,activeDropZone:a,onHoverDropZone:m,onTabDragStart:N,hoveredTab:k,onTabHover:A,defaultPanelIcon:F,onRequestClosePanel:M})=>{let R=ge(),O=He(),{openPanel:g,closeLeafGroup:T,setActivePanel:b}=mt(),I=ne(),W=re(),{windowClass:l,windowBodyClass:w}=he(),y=f=>{g(f,R.panels[f].component),b(f)};return j("div",{"data-active-panel-id":s.activePanelId||"",className:`workspace-panel ${l??""}`,style:{overflow:"hidden",position:"relative"},children:[j("div",{className:"workspace-tab-bar",style:{minHeight:"38px"},children:[p("div",{className:"tab-headers-container",style:{scrollbarWidth:"none"},onMouseMove:f=>{R.draggedPanelId&&f.target===f.currentTarget&&A(s.id,"EMPTY",s.panels.length,"right")},onMouseLeave:f=>{R.draggedPanelId&&f.target===f.currentTarget&&A(s.id,"",-1,null)},children:s.panels.map((f,H)=>{let L=R.panels[f];if(!L)return null;let P=s.activePanelId===f,E=R.activePanelId===f,z=O.get(L.component)?.defaultOptions,D=k&&k.leafId===s.id&&k.panelId===f,Y=H===s.panels.length-1,ee=k&&k.leafId===s.id&&k.panelId==="EMPTY"&&Y,se=D?k.side==="left"?"drag-hover-left":"drag-hover-right":ee?"drag-hover-right":"";return j("div",{onClick:()=>y(f),onMouseDown:K=>{z?.canDrag!==!1&&N(f,K)},onContextMenu:K=>o(f,K),onMouseMove:K=>{if(R.draggedPanelId){let V=K.currentTarget.getBoundingClientRect(),ce=K.clientX-V.left<V.width/2?"left":"right";A(s.id,f,H,ce)}},onMouseLeave:()=>{R.draggedPanelId&&A(s.id,"",-1,null)},className:`workspace-tab ${P?E?"active workspace-tab-active-focused":"active workspace-tab-active-unfocused":"workspace-tab-inactive"} ${se}`,style:{cursor:z?.canDrag===!1?"default":"pointer"},children:[j("span",{className:"text-truncate",style:{maxWidth:"120px",display:"flex",alignItems:"center"},children:[p("span",{className:"workspace-tab-icon",children:z?.icon||F||bt}),j("span",{children:[X(L.title,I),L.dirty?" *":""]})]}),z?.renderHeaderActions&&p("span",{className:"tab-header-actions",onClick:K=>K.stopPropagation(),onMouseDown:K=>K.stopPropagation(),children:z.renderHeaderActions(f)}),z?.canClose!==!1&&p("span",{onClick:K=>{K.stopPropagation(),M(f)},title:X(W.closeTab,I),className:"close-tab-x",style:{width:"18px",height:"18px",...z?.renderHeaderActions?{}:{marginInlineStart:"auto"}},children:p("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:p("path",{d:"M18 6L6 18M6 6l12 12"})})})]},f)})}),s.panels.length===0&&s.keepOnEmpty&&s.canClose!==!1&&p("span",{onClick:()=>T(s.id),className:"close-tab-x header-close-empty-group",style:{width:"18px",height:"18px",cursor:"pointer"},title:X(W.closeEmptyGroup,I),children:p("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:p("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),j("div",{className:`dw-panel-body ${w??""}`,style:{position:"relative",overflow:"hidden"},children:[s.activePanelId&&R.panels[s.activePanelId]?p(_t,{panelId:s.activePanelId},s.activePanelId):p("div",{className:"empty-leaf-placeholder",children:p("span",{children:"Empty Workspace Section"})}),R.draggedPanelId!==null&&p("div",{className:"dock-drop-zone-overlay",children:j("div",{className:"dock-target-cross",children:[p("div",{onMouseEnter:()=>m(s.id,"top"),onMouseLeave:()=>m(s.id,null),className:"dock-target-box dock-target-top",children:"\u25B2"}),p("div",{onMouseEnter:()=>m(s.id,"bottom"),onMouseLeave:()=>m(s.id,null),className:"dock-target-box dock-target-bottom",children:"\u25BC"}),p("div",{onMouseEnter:()=>m(s.id,"left"),onMouseLeave:()=>m(s.id,null),className:"dock-target-box dock-target-left",children:"\u25C0"}),p("div",{onMouseEnter:()=>m(s.id,"right"),onMouseLeave:()=>m(s.id,null),className:"dock-target-box dock-target-right",children:"\u25B6"}),p("div",{onMouseEnter:()=>m(s.id,"center"),onMouseLeave:()=>m(s.id,null),className:"dock-target-box dock-target-center",children:"\u25A3"})]})}),R.draggedPanelId!==null&&a!==null&&a.leafId===s.id&&p("div",{className:"dock-preview-highlight",style:{left:a.position==="right"?"50%":"0",top:a.position==="bottom"?"50%":"0",width:a.position==="left"||a.position==="right"?"50%":"100%",height:a.position==="top"||a.position==="bottom"?"50%":"100%"}})]})]})},hn=({skin:s="vscode",defaultPanelIcon:o})=>{let a=ge(),m=He(),{restorePanel:N,minimizePanel:k,requestClosePanel:A,maximizePanel:F,updateFloatingPosition:M,focusPanel:R,floatPanel:O,setDraggedPanelId:g,dockPanelToGroup:T,movePanelOrder:b,dockPanelToWorkspaceEdge:I,setActivePanel:W,setDirection:l}=mt(),{openModal:w}=Me(),y=ne(),f=re(),H=Ct.useCallback(r=>{let v=a.panels[r];A(r,{onConfirm:u=>new Promise(e=>{let t=u||v?.dirtyOptions,n=v?X(v.title,y):"Panel";w(ke,{title:t?.title||f.unsavedChangesTitle,message:t?.message||{id:f.unsavedChangesMessage.id,defaultMessage:f.unsavedChangesMessage.defaultMessage,values:{title:n}},alert:t?.alert,alertType:t?.alertType||"danger",useYesNoTitles:!0,onOK:()=>e(!0),onCancel:()=>e(!1)},{size:"small"})})})},[A,a.panels,y,w,f]),{windowClass:L,windowBodyClass:P}=he(),E=pe(null),$=pe(null),[z,D]=Pe(null),Y=pe(null),[ee,se]=Pe(!1);oe(()=>()=>{Y.current&&clearTimeout(Y.current)},[]),oe(()=>{z&&(a.minimized.some(v=>v.id===z.id)||D(null))},[a.minimized,z]);let[te,K]=Pe(null),V=pe(null),[fe,ce]=Pe({x:0,y:0}),[J,ae]=Pe(null),Z=pe(null),Q=r=>{ae(r),Z.current=r},[Ge,be]=Pe(null),me=pe(null),Ye=(r,v,u,e)=>{let t=e?{leafId:r,panelId:v,index:u,side:e}:null;be(t),me.current=t},Xe=(r,v)=>{let u=v?{leafId:r,position:v}:null;K(u),V.current=u},qe=(r,v)=>{if(v.button!==0)return;let u=v.clientX,e=v.clientY,t=!1,n=d=>{let C=d.clientX-u,h=d.clientY-e;!t&&(Math.abs(C)>5||Math.abs(h)>5)&&(t=!0,g(r)),t&&ce({x:d.clientX,y:d.clientY})},i=d=>{if(window.removeEventListener("mousemove",n),window.removeEventListener("mouseup",c),t){let C=V.current,h=me.current,x=Z.current;if(x)I(r,x);else if(h){let S=h.index;h.side==="right"&&(S+=1),b(r,h.leafId,S)}else C?T(r,C.leafId,C.position):O(r,{x:d.clientX-150,y:d.clientY-15,width:450,height:350});g(null),K(null),V.current=null,be(null),me.current=null,Q(null)}},c=d=>{i(d)};window.addEventListener("mousemove",n),window.addEventListener("mouseup",c)},Ke=(r,v)=>{v.preventDefault();let u=a.panels[r];if(!u)return;let t=m.get(u.component)?.defaultOptions,n=[];t?.canDrag!==!1&&n.push({label:X(f.floatWindow,y),action:()=>O(r)}),t?.canMinimize!==!1&&n.push({label:X(f.minimizePanel,y),action:()=>k(r)}),n.length>0&&t?.canClose!==!1&&n.push({separator:!0}),t?.canClose!==!1&&n.push({label:X(f.closeTab,y),action:()=>H(r)}),n.length!==0&&$.current?.show({event:v,contextMenu:{items:n}})},je=(r,v)=>{v.preventDefault(),D(null),$.current?.show({event:v,contextMenu:{items:[{label:X(f.restorePanel,y),action:()=>N(r)},{label:X(f.maximizePanel,y),action:()=>F(r)},{separator:!0},{label:X(f.closePanel,y),action:()=>H(r)}]}})};oe(()=>{let r=Object.keys(a.panels);for(let v of Array.from($e.keys()))r.includes(v)||$e.delete(v)},[a.panels]),oe(()=>{let r=()=>{a.draggedPanelId!==null&&(g(null),K(null),be(null))};return window.addEventListener("blur",r),()=>{window.removeEventListener("blur",r)}},[a.draggedPanelId]);let Ie=pe(null),[ue,Ue]=Pe({width:1024,height:768});oe(()=>{let r=Ie.current;if(!r)return;let v=new ResizeObserver(u=>{if(!u||u.length===0)return;let e=u[0].contentRect;Ue({width:Math.max(100,e.width),height:Math.max(100,e.height)})});return v.observe(r),()=>{v.disconnect()}},[]),oe(()=>{let r=Ie.current;if(!r)return;let v=()=>{let t=Et(r);l(t?"rtl":"ltr")};v();let u=new MutationObserver(v);u.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}),u.observe(document.body,{attributes:!0,attributeFilter:["dir"]});let e=r.closest("[dir]");return e&&e!==document.documentElement&&e!==document.body&&u.observe(e,{attributes:!0,attributeFilter:["dir"]}),()=>{u.disconnect()}},[l]),oe(()=>{let r=ue.width,v=ue.height;a.floating.forEach(u=>{let e=typeof u.width=="string"?parseFloat(u.width):u.width,t=typeof u.height=="string"?parseFloat(u.height):u.height,n=typeof u.x=="string"?parseFloat(u.x):u.x,i=typeof u.y=="string"?parseFloat(u.y):u.y,c=e,d=t,C=n,h=i,x=!1;c>r&&(c=Math.max(200,r-20),x=!0),d>v&&(d=Math.max(150,v-40),x=!0);let S=10;if(u.stickyRight)C=r-c-S,x=!0;else{let B=r-100;C>B&&(C=Math.max(0,B),x=!0)}if(u.stickyBottom)h=v-d-S,x=!0;else{let B=v-40;h>B&&(h=Math.max(0,B),x=!0)}x&&M(u.id,{x:C,y:h,width:c,height:d})})},[ue,a.floating,M]),oe(()=>{let r=v=>{if(v.button!==0)return;let u=v.target;if(!u)return;let e=u.closest(".floating-window");if(e){let n=e.getAttribute("data-window-id");n&&(W(n),R(n));return}let t=u.closest(".workspace-panel");if(t){let n=t.getAttribute("data-active-panel-id");n&&W(n)}};return document.addEventListener("mousedown",r),()=>{document.removeEventListener("mousedown",r)}},[R,W]);let Je=(r,v)=>{let u=a.floating.find(S=>S.id===r);if(!u||u.maximized)return;R(r);let e=v.clientX,t=v.clientY,i=v.currentTarget.closest(".floating-window"),c=i?i.offsetLeft:0,d=i?i.offsetTop:0,C=!1,h=S=>{let B=S.clientX-e,U=S.clientY-t;if(!C&&(Math.abs(B)>5||Math.abs(U)>5)&&(C=!0,g(r)),C){let _=c+B,q=d+U;M(r,{x:_,y:q,stickyRight:!1,stickyBottom:!1})}},x=()=>{if(C){let S=V.current,B=me.current,U=Z.current;if(U)I(r,U);else if(B){let _=B.index;B.side==="right"&&(_+=1),b(r,B.leafId,_)}else S&&T(r,S.leafId,S.position);g(null),K(null),V.current=null,be(null),me.current=null,Q(null)}window.removeEventListener("mousemove",h),window.removeEventListener("mouseup",x)};window.addEventListener("mousemove",h),window.addEventListener("mouseup",x)},Ve=(r,v)=>{v.stopPropagation();let u=a.floating.find(x=>x.id===r);if(!u||u.maximized)return;R(r);let e=v.clientX,t=v.clientY,i=v.currentTarget.closest(".floating-window"),c=i?i.offsetWidth:400,d=i?i.offsetHeight:300,C=x=>{let S=x.clientX-e,B=x.clientY-t,U=Math.max(200,c+S),_=Math.max(150,d+B),q=u.x,Ce=u.y,We=ue.width,Oe=ue.height,dt=typeof u.x=="string"?parseFloat(u.x):u.x,ct=typeof u.y=="string"?parseFloat(u.y):u.y,et=typeof u.width=="string"?parseFloat(u.width):u.width,tt=typeof u.height=="string"?parseFloat(u.height):u.height,De=Math.abs(dt+et-We)<4,Rt=Math.abs(ct+tt-Oe)<4;De&&(q=We-U,q<0&&(q=0,U=We)),Rt&&(Ce=Oe-_,Ce<0&&(Ce=0,_=Oe)),M(r,{x:q,y:Ce,width:U,height:_,stickyRight:De,stickyBottom:Rt})},h=()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",h)};window.addEventListener("mousemove",C),window.addEventListener("mouseup",h)},Ne=r=>{if(E.current){let v=r==="left"?-150:150;E.current.scrollBy({left:v,behavior:"smooth"})}},[Ze,Qe]=Pe("dark");return oe(()=>{let r=()=>{let u=document.documentElement.getAttribute("data-color-scheme")==="light"?"light":"dark";Qe(u)};r();let v=new MutationObserver(r);return v.observe(document.documentElement,{attributes:!0,attributeFilter:["data-color-scheme"]}),()=>v.disconnect()},[]),j("div",{"data-workspace-skin":s,"data-color-scheme":Ze,style:{display:"flex",flexDirection:"column",width:"100%",height:"100%",overflow:"hidden",userSelect:"none"},dir:a.dir,children:[j("div",{ref:Ie,className:a.draggedPanelId?"dragging-active":void 0,style:{flexGrow:1,width:"100%",position:"relative",overflow:"hidden"},children:[a.draggedPanelId!==null&&j(Pn,{children:[p("div",{className:"workspace-edge-trigger edge-trigger-left",onMouseEnter:()=>Q("left"),onMouseLeave:()=>Q(null)}),p("div",{className:"workspace-edge-trigger edge-trigger-right",onMouseEnter:()=>Q("right"),onMouseLeave:()=>Q(null)}),p("div",{className:"workspace-edge-trigger edge-trigger-top",onMouseEnter:()=>Q("top"),onMouseLeave:()=>Q(null)}),p("div",{className:"workspace-edge-trigger edge-trigger-bottom",onMouseEnter:()=>Q("bottom"),onMouseLeave:()=>Q(null)})]}),a.draggedPanelId!==null&&J!==null&&p("div",{className:`workspace-edge-preview edge-preview-${J}`}),p("div",{style:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:a.gridRoot?p(Gt,{node:a.gridRoot,path:[],onTabRightClick:Ke,activeDropZone:te,onHoverDropZone:Xe,onTabDragStart:qe,hoveredTab:Ge,onTabHover:Ye,defaultPanelIcon:o,onRequestClosePanel:H}):p("div",{className:"empty-workspace-grid",children:"Grid Empty"})}),a.floating.map(r=>{let v=a.panels[r.id];if(!v)return null;let u=r.maximized,e=a.draggedPanelId===r.id,t=a.activePanelId===r.id,i=m.get(v.component)?.defaultOptions;return j("div",{"data-window-id":r.id,dir:a.dir,onMouseDownCapture:()=>{W(r.id),R(r.id)},className:`floating-window ${u?"maximized":""} ${t?"v2-window-focused":""} ${L??""}`,style:{position:"absolute",left:u?0:typeof r.x=="number"?`${r.x}px`:r.x,top:u?0:typeof r.y=="number"?`${r.y}px`:r.y,width:u?"100%":typeof r.width=="number"?`${r.width}px`:r.width,height:u?"100%":typeof r.height=="number"?`${r.height}px`:r.height,zIndex:r.z,pointerEvents:e?"none":"auto"},children:[j("div",{onDoubleClick:()=>F(r.id),onMouseDown:c=>{i?.canDrag!==!1&&Je(r.id,c)},className:"floating-window-titlebar cursor-move",style:{cursor:u||i?.canDrag===!1?"default":"move"},children:[j("span",{className:"floating-window-title",children:[p("span",{className:"window-title-icon",children:i?.icon||o||bt}),j("span",{children:[X(v.title,y),v.dirty?" *":""]})]}),j("div",{className:"fw-titlebar-actions",style:{gap:"var(--header-button-gap, 4px)"},onMouseDown:c=>c.stopPropagation(),children:[i?.renderHeaderActions&&p("div",{className:"window-header-actions",children:i.renderHeaderActions(r.id)}),i?.canDrag!==!1&&p("button",{type:"button",title:X(f.windowAnchoringOptions,y),onClick:c=>{let d=!!r.stickyRight,C=!!r.stickyBottom;$.current?.show({event:c,contextMenu:{items:[{label:X(f.anchorToRightEdge,y),checkbox:{active:!0,enabled:!0,value:d},action:()=>{let h=ue.width,x=typeof r.width=="string"?parseFloat(r.width):r.width;d?M(r.id,{stickyRight:!1}):M(r.id,{x:h-x-10,stickyRight:!0})}},{label:X(f.anchorToBottomEdge,y),checkbox:{active:!0,enabled:!0,value:C},action:()=>{let h=ue.height,x=typeof r.height=="string"?parseFloat(r.height):r.height;C?M(r.id,{stickyBottom:!1}):M(r.id,{y:h-x-10,stickyBottom:!0})}}]}})},className:"custom-tab-btn btn-anchor-tab",children:j("svg",{className:`anchor-icon ${r.stickyRight&&r.stickyBottom?"anchor-sticky-both":r.stickyRight?"anchor-sticky-right":r.stickyBottom?"anchor-sticky-bottom":""}`,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[p("circle",{cx:"12",cy:"5",r:"2"}),p("path",{d:"M12 7v7m0 0a4 4 0 0 1-4-4M12 14a4 4 0 0 0 4-4M5 18h14"})]})}),p("button",{type:"button",title:u?X(f.restoreSize,y):X(f.maximize,y),onClick:()=>F(r.id),className:"custom-tab-btn btn-maximize-tab",children:p("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:p("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1.5"})})}),i?.canMinimize!==!1&&p("button",{type:"button",title:X(f.minimize,y),onClick:()=>k(r.id),className:"custom-tab-btn btn-minimize-tab",children:p("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:p("path",{d:"M5 12h14"})})}),i?.canClose!==!1&&p("button",{type:"button",title:X(f.close,y),onClick:()=>H(r.id),className:"custom-tab-btn btn-close-tab",children:p("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:p("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]}),p("div",{className:P??void 0,style:{flexGrow:1,width:"100%",overflow:"hidden",position:"relative",isolation:"isolate"},children:p(_t,{panelId:r.id},r.id)}),!u&&p("div",{onMouseDown:c=>Ve(r.id,c),style:{position:"absolute",right:0,bottom:0,width:"14px",height:"14px",cursor:"se-resize",zIndex:30,background:"linear-gradient(135deg, transparent 50%, rgba(255,255,255,0.2) 50%)"}})]},r.id)})]}),a.minimized.length>0&&j("div",{className:"taskbar-footer-container",style:{height:"48px",zIndex:100},children:[p("button",{type:"button",onClick:()=>Ne("left"),className:"taskbar-nav-btn",style:{display:a.minimized.length>4?"block":"none"},children:"\u25C0"}),p("div",{ref:E,className:"taskbar-items-container",style:{scrollSnapType:"x mandatory"},children:a.minimized.map(r=>{let u=m.get(r.component)?.defaultOptions?.icon||o||bt;return p("div",{onClick:()=>{D(null),N(r.id)},onContextMenu:e=>je(r.id,e),onMouseEnter:e=>{if(ee)return;Y.current&&clearTimeout(Y.current);let t=e.currentTarget.getBoundingClientRect();e.clientX>=t.left&&e.clientX<=t.right&&e.clientY>=t.top&&e.clientY<=t.bottom&&D({id:r.id,rect:t,title:r.title,component:r.component})},onMouseLeave:()=>{Y.current=setTimeout(()=>{D(null)},150)},className:"taskbar-glassmorphic-item",style:{backdropFilter:"blur(6px)",transition:"all 0.2s",cursor:"pointer",scrollSnapAlign:"start",width:"38px",height:"38px",position:"relative",padding:0},children:p("span",{className:"taskbar-item-icon",children:u})},r.id)})}),z&&Ht(j("div",{className:"taskbar-item-tooltip",dir:a.dir,style:{position:"fixed",left:`${z.rect.left+z.rect.width/2}px`,top:`${z.rect.top-8}px`,transform:"translateX(-50%) translateY(-100%)",opacity:1,pointerEvents:"auto",zIndex:999999},onMouseEnter:()=>{Y.current&&clearTimeout(Y.current)},onMouseLeave:()=>{D(null)},onClick:()=>{N(z.id),D(null)},children:[j("div",{className:"tooltip-header-row",children:[j("span",{className:"tooltip-title-text text-truncate",style:{maxWidth:"140px"},children:[X(z.title,y),a.panels[z.id]?.dirty?" *":""]}),p("span",{onClick:r=>{r.stopPropagation(),H(z.id),D(null)},title:X(f.closePanel,y),className:"tooltip-close-x",children:p("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:p("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),p(pn,{panelId:z.id})]}),document.body),p("button",{type:"button",onClick:()=>Ne("right"),className:"taskbar-nav-btn",style:{display:a.minimized.length>4?"block":"none"},children:"\u25B6"})]}),Object.keys(a.panels).map(r=>{let v=a.panels[r];if(!v)return null;let u=Bt(r);return Ht(p(fn,{panelId:r,children:p("div",{style:{width:"100%",height:"100%"},children:gn(r,v.component,m)})}),u,r)}),p(un,{ref:$,id:"workspace-context-menu",theme:"dark",onShow:()=>se(!0),onHide:()=>se(!1)}),a.draggedPanelId!==null&&!a.floating.some(r=>r.id===a.draggedPanelId)&&j("div",{className:"drag-ghost-tab",style:{left:fe.x+12,top:fe.y+12,zIndex:1e5},children:["\u{1F4C4} ",X(a.panels[a.draggedPanelId]?.title,y)||"Tab"]})]})},yn=hn;var wt=class{registry;initialState;config;_actions=null;_pendingCalls=[];_disconnectedWarnTimer=null;constructor(o={}){if(this.registry=new Se,this.initialState=o.initialState??null,this.config={formatMessage:o.formatMessage,predefinedMessages:o.predefinedMessages,dir:o.dir},o.panels)for(let[a,m]of Object.entries(o.panels))this.registry.register(a,m.component,m.defaultOptions)}_connect(o){this._actions=o,this._disconnectedWarnTimer!==null&&(clearTimeout(this._disconnectedWarnTimer),this._disconnectedWarnTimer=null);let a=this._pendingCalls.splice(0);for(let m of a)m(o)}_disconnect(){this._actions=null}get isConnected(){return this._actions!==null}_dispatch(o){this._actions?o(this._actions):(this._pendingCalls.push(o),process.env.NODE_ENV!=="production"&&this._disconnectedWarnTimer===null&&(this._disconnectedWarnTimer=setTimeout(()=>{!this.isConnected&&this._pendingCalls.length>0&&console.warn("[react-dockable-desktop] WorkspaceClient has queued calls but was never connected to a provider. Did you forget client={workspace} on <WindowManagerProvider client={workspace}>?")},1e3)))}openPanel(...o){this._dispatch(a=>a.openPanel(...o))}closePanel(o){this._dispatch(a=>a.closePanel(o))}minimizePanel(o){this._dispatch(a=>a.minimizePanel(o))}restorePanel(o){this._dispatch(a=>a.restorePanel(o))}floatPanel(...o){this._dispatch(a=>a.floatPanel(...o))}dockPanel(...o){this._dispatch(a=>a.dockPanel(...o))}maximizePanel(o){this._dispatch(a=>a.maximizePanel(o))}focusPanel(o){this._dispatch(a=>a.focusPanel(o))}isOpen(o){return this._actions?.isOpen(o)??!1}getOpenPanelIds(){return this._actions?.getOpenPanelIds()??[]}saveLayout(){return this._actions?.saveLayout()??""}loadLayout(o){return this._actions?this._actions.loadLayout(o):(this._pendingCalls.push(a=>{a.loadLayout(o)}),!1)}setDirection(o){this._dispatch(a=>a.setDirection(o))}publish(o,a){this._dispatch(m=>m.publish(o,a))}subscribe(o,a){return this._actions?.subscribe(o,a)??(()=>{})}};import{useCallback as _e,useRef as Yt,useEffect as vn,useState as bn,useMemo as Cn}from"react";import{Fragment as Rn,jsx as de,jsxs as xt}from"react/jsx-runtime";var wn=({modal:s,index:o,isTopmost:a})=>{let{close:m,openModal:N,updateInstance:k,setDirty:A}=Me(),F=ne(),M=re(),{dir:R}=ge(),{modalClass:O,modalBodyClass:g}=he(),T=Yt(null),{id:b,Component:I,props:W,options:l,dirty:w,dirtyOptions:y}=s,f=l,[H,L]=bn(f.icon||null),P=Yt(f);P.current=f;let E=X(f.title,F),$=_e(async J=>{if(J?.force){m(b);return}if(T.current){if(!await T.current())return;m(b);return}if(w){N(ke,{title:y?.title||M.unsavedChangesTitle,message:y?.message||{id:M.unsavedChangesMessage.id,defaultMessage:M.unsavedChangesMessage.defaultMessage,values:{title:E}},alert:y?.alert,alertType:y?.alertType||"danger",useYesNoTitles:!0,onOK:()=>m(b)},{size:"small"});return}m(b)},[m,N,b,w,y,E,M]),z=_e((J,ae)=>A(b,J,ae),[A,b]),D=_e(J=>k(b,{options:{...P.current,title:J}}),[k,b]),Y=_e(J=>L(J),[]),ee=_e(J=>(T.current=J,()=>{T.current=null}),[]),se=Cn(()=>({requestClose:$,setDirty:z,setTitle:D,setIcon:Y,onCloseRequested:ee,containerType:"modal",instanceId:b}),[$,z,D,Y,ee,b]),te=w?`${E} *`:E,K=f.size?`v2-modal-size-${f.size}`:"v2-modal-size-auto",V=f.closable!==!1;vn(()=>{if(!a||!V)return;let J=ae=>{ae.key==="Escape"&&(ae.stopPropagation(),$())};return document.addEventListener("keydown",J),()=>document.removeEventListener("keydown",J)},[$,V,a]);let ce=1e4+o*10;return xt("div",{className:"v2-modal-overlay",style:{zIndex:ce},dir:R,children:[de("div",{className:"v2-modal-curtain",onClick:V?()=>$():void 0}),xt("div",{className:`v2-modal-window ${K} ${O??""}`,children:[xt("div",{className:"v2-modal-header",children:[H&&de("div",{className:"v2-modal-icon",children:H}),de("h4",{className:"v2-modal-title",children:te}),V&&de("button",{className:"v2-modal-close-button",onClick:()=>$(),title:F(M.closeTooltip),type:"button",children:de("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:de("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),de("div",{className:`v2-modal-body ${g??""}`,children:de(xe,{value:se,children:de(I,{...W,panelId:b})})})]})]})},xn=()=>{let{modals:s}=ye();return s.length===0?null:de(Rn,{children:s.map((o,a)=>de(wn,{modal:o,index:a,isTopmost:a===s.length-1},o.id))})},Mn=xn;import{useCallback as Le,useRef as Xt,useEffect as qt,useState as kn,useMemo as In}from"react";import{Fragment as Ln,jsx as ie,jsxs as Mt}from"react/jsx-runtime";var at=({panel:s,position:o,defaultWidth:a})=>{let{close:m,openModal:N,updateInstance:k,setDirty:A,registerCloseHandler:F,unregisterCloseHandler:M}=Me(),{modals:R}=ye(),O=ne(),g=re(),{dir:T}=ge(),{sidePanelClass:b,sidePanelBodyClass:I}=he(),W=Xt(null),{id:l,Component:w,props:y,options:f,dirty:H,dirtyOptions:L}=s,P=f,[E,$]=kn(P.icon||null),z=Xt(P);z.current=P;let D=X(P.title,O),Y=Le(async Z=>{if(Z?.force){m(l);return}if(W.current){if(!await W.current())return;m(l);return}if(H){N(ke,{title:L?.title||g.unsavedChangesTitle,message:L?.message||{id:g.unsavedChangesMessage.id,defaultMessage:g.unsavedChangesMessage.defaultMessage,values:{title:D}},alert:L?.alert,alertType:L?.alertType||"danger",useYesNoTitles:!0,onOK:()=>m(l)},{size:"small"});return}m(l)},[m,N,l,H,L,D,g]),ee=Le(async()=>W.current?await W.current():!H,[H]);qt(()=>(F(l,ee),()=>M(l)),[l,ee,F,M]);let se=Le((Z,Q)=>A(l,Z,Q),[A,l]),te=Le(Z=>k(l,{options:{...z.current,title:Z}}),[k,l]),K=Le(Z=>$(Z),[]),V=Le(Z=>(W.current=Z,()=>{W.current=null}),[]),fe=In(()=>({requestClose:Y,setDirty:se,setTitle:te,setIcon:K,onCloseRequested:V,containerType:o==="left"?"left-panel":"right-panel",instanceId:l}),[Y,se,te,K,V,o,l]),ce=H?`${D} *`:D;qt(()=>{let Z=Q=>{Q.key==="Escape"&&R.length===0&&Y()};return document.addEventListener("keydown",Z),()=>document.removeEventListener("keydown",Z)},[Y,R.length]);let J=P.width||a||400,ae=typeof J=="number"?`${J}px`:J;return ie("div",{className:`v2-side-panel v2-side-panel-${o} v2-side-panel-visible ${b??""}`,style:{width:ae},dir:T,children:Mt("div",{className:"v2-side-panel-window",children:[Mt("div",{className:"v2-side-panel-header",children:[E&&ie("div",{className:"v2-side-panel-icon",children:E}),ie("h4",{className:"v2-side-panel-title",children:ce}),ie("button",{className:"v2-side-panel-close-button",onClick:()=>Y(),title:O(g.closeTooltip),type:"button",children:ie("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:ie("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),ie("div",{className:`v2-side-panel-body ${I??""}`,children:ie(xe,{value:fe,children:ie(w,{...y,panelId:l})})})]})})},Sn=({defaultWidth:s})=>{let{leftPanel:o,rightPanel:a}=ye();return Mt(Ln,{children:[o&&ie(at,{panel:o,position:"left",defaultWidth:s},o.id),a&&ie(at,{panel:a,position:"right",defaultWidth:s},a.id)]})},Tn=({defaultWidth:s})=>{let{leftPanel:o}=ye();return o?ie(at,{panel:o,position:"left",defaultWidth:s},o.id):null},zn=({defaultWidth:s})=>{let{rightPanel:o}=ye();return o?ie(at,{panel:o,position:"right",defaultWidth:s},o.id):null},En=Sn;import{useState as Kt,useEffect as rt,useRef as Nn,useCallback as jt,useImperativeHandle as Wn,forwardRef as On}from"react";import{Fragment as Fn,jsx as ve,jsxs as lt}from"react/jsx-runtime";var Dn=On(function({position:o="right",tabs:a,drawerWidth:m="220px",activeTabId:N,onActiveTabChange:k,children:A},F){let M=N!==void 0,R=ne(),O=re(),[g,T]=Kt(null),b=M?N:g,[I,W]=Kt(()=>{let P=new Set;for(let E of a)E.eagerMount&&P.add(E.id);return P});rt(()=>{let P=a.filter(E=>E.eagerMount&&!I.has(E.id));P.length>0&&W(E=>{let $=new Set(E);for(let z of P)$.add(z.id);return $})},[a]);let l=Nn(b??null);rt(()=>{l.current=b??null},[b]);let w=jt(P=>{M||T(P),k?.(P)},[M,k]);Wn(F,()=>({openTab:P=>w(P),closeDrawer:()=>w(null),getActiveTab:()=>l.current}),[w]);let y=P=>{w(b===P?null:P)},f=jt(()=>w(null),[w]);rt(()=>{b&&!I.has(b)&&W(P=>{let E=new Set(P);return E.add(b),E})},[b,I]),rt(()=>{b===null&&W(P=>{let E=!1,$=new Set(P);for(let z of P){let D=a.find(Y=>Y.id===z);D&&!D.eagerMount&&!D.preserveState&&($.delete(z),E=!0)}return E?$:P})},[b,a]);let H=ve("div",{className:`sidebar-tabs-strip ${o}`,style:{width:"56px",height:"100%"},children:a.map(P=>{let E=b===P.id;return ve("button",{type:"button",onClick:()=>y(P.id),className:`sidebar-tab-btn ${E?"active":""}`,title:P.label,"aria-pressed":E,children:P.icon},P.id)})}),L=ve("div",{className:`sidebar-content-drawer h-100 ${o}`,style:{width:b?m:"0px",minWidth:b?m:"0px",overflow:"hidden",flexShrink:0},children:a.map(P=>{if(!I.has(P.id))return null;let $=b===P.id,z=()=>w(P.id);return lt("div",{style:{display:$?"flex":"none",flexDirection:"column",height:"100%",width:"100%"},children:[lt("div",{className:"sidebar-drawer-header",children:[ve("span",{className:"sidebar-header-title",children:P.label}),ve("button",{type:"button",onClick:f,className:"sidebar-close-btn",title:R(O.closePanelTooltip),"aria-label":R(O.closePanelTooltip),children:lt("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:[ve("line",{x1:"18",y1:"6",x2:"6",y2:"18"}),ve("line",{x1:"6",y1:"6",x2:"18",y2:"18"})]})})]}),ve("div",{className:"sidebar-drawer-body",children:P.renderContent(P.id,f,z)})]},P.id)})});return lt(Fn,{children:[o==="left"&&H,o==="left"&&L,A,o==="right"&&L,o==="right"&&H]})});export{ke as ConfirmationForm,ht as FormContainerContext,xe as FormContainerProvider,Tn as LeftPanelRenderer,Mn as ModalStackRenderer,ln as PanelProvider,nt as PanelRegistry,Se as PanelRegistryClass,zn as RightPanelRenderer,En as SidePanelRenderer,Dn as Sidebar,yn as WindowManager,Zt as WindowManagerProvider,wt as WorkspaceClient,Fe as defaultPredefinedMessages,X as formatLabel,yt as useFormContainer,ne as useFormatMessage,Me as usePanelActions,Qt as usePanelContext,ye as usePanelState,re as usePredefinedMessages,He as useRegistry,he as useStyleClasses,Be as useWindowManagerActions,ge as useWindowManagerState};
|
|
1
|
+
import $t,{useState as ke,useRef as pe,useEffect as le,useCallback as _t}from"react";import{createPortal as hn}from"react-dom";import{createContext as Ye,useContext as Se,useState as Gn,useRef as Ie,useMemo as Rt,useCallback as X,useEffect as dt,useSyncExternalStore as $n}from"react";import{createContext as Bn,useContext as Hn}from"react";var _n={requestClose:()=>{console.warn("FormContainerContract: requestClose called but no container is present")},setDirty:()=>{},onCloseRequested:()=>()=>{},setTitle:()=>{},setIcon:()=>{},containerType:"standalone",instanceId:"standalone",onClose:()=>()=>{},onMinimize:()=>()=>{},onRestore:()=>()=>{},onResize:()=>()=>{}},Wt=Bn(_n),Ge=Wt.Provider,at=()=>Hn(Wt);var Je=class{registry=new Map;register(n,r,i){this.registry.set(n,{Component:r,defaultOptions:i})}get(n){return this.registry.get(n)}getRegisteredIds(){return Array.from(this.registry.keys())}},wt=new Je;var lt={floatWindow:{id:"dockable-desktop-floatWindow",defaultMessage:"Float Window"},minimizePanel:{id:"dockable-desktop-minimizePanel",defaultMessage:"Minimize Panel"},closeTab:{id:"dockable-desktop-closeTab",defaultMessage:"Close Tab"},restorePanel:{id:"dockable-desktop-restorePanel",defaultMessage:"Restore Panel"},maximizePanel:{id:"dockable-desktop-maximizePanel",defaultMessage:"Maximize Panel"},closePanel:{id:"dockable-desktop-closePanel",defaultMessage:"Close Panel"},dockWindow:{id:"dockable-desktop-dockWindow",defaultMessage:"Dock Window"},minimize:{id:"dockable-desktop-minimize",defaultMessage:"Minimize"},maximize:{id:"dockable-desktop-maximize",defaultMessage:"Maximize"},restoreSize:{id:"dockable-desktop-restoreSize",defaultMessage:"Restore Size"},close:{id:"dockable-desktop-close",defaultMessage:"Close"},closeEmptyGroup:{id:"dockable-desktop-closeEmptyGroup",defaultMessage:"Close empty split group"},anchorToRightEdge:{id:"dockable-desktop-anchorToRightEdge",defaultMessage:"Anchor to Right Edge"},anchorToBottomEdge:{id:"dockable-desktop-anchorToBottomEdge",defaultMessage:"Anchor to Bottom Edge"},windowAnchoringOptions:{id:"dockable-desktop-windowAnchoringOptions",defaultMessage:"Window Anchoring Options"},unsavedChangesTitle:{id:"dockable-desktop-unsavedChangesTitle",defaultMessage:"Unsaved Changes"},unsavedChangesMessage:{id:"dockable-desktop-unsavedChangesMessage",defaultMessage:'"{title}" has unsaved changes. Do you want to discard your changes and close?'},discardChanges:{id:"dockable-desktop-discardChanges",defaultMessage:"Discard Changes"},cancel:{id:"dockable-desktop-cancel",defaultMessage:"Cancel"},yes:{id:"dockable-desktop-yes",defaultMessage:"Yes"},no:{id:"dockable-desktop-no",defaultMessage:"No"},ok:{id:"dockable-desktop-ok",defaultMessage:"OK"},closePanelTooltip:{id:"dockable-desktop-closePanelTooltip",defaultMessage:"Close panel"},closeTooltip:{id:"dockable-desktop-closeTooltip",defaultMessage:"Close"}};import{jsx as $e}from"react/jsx-runtime";var en=Ye(null),Mt=Ye(null),tn=Ye(null),nn=Ye(null),on=Ye(lt),rn=Ye({}),Fe=()=>Se(rn),sn=Ye(wt),ct=()=>Se(sn),Dt=class{listeners={};subscribe(n,r){return this.listeners[n]||(this.listeners[n]=[]),this.listeners[n].push(r),()=>{this.listeners[n]=this.listeners[n].filter(i=>i!==r)}}publish(n,r){this.listeners[n]&&this.listeners[n].forEach(i=>i(r))}},Yn={type:"leaf",id:"group-default",panels:[],activePanelId:null};function Xn(t){if(t)try{let n=JSON.parse(t);if(n.gridRoot&&Array.isArray(n.floating)&&Array.isArray(n.minimized)&&n.panels)return{gridRoot:n.gridRoot,floating:n.floating,minimized:n.minimized,panels:n.panels,activePanelId:Object.keys(n.panels)[0]??null}}catch{}return{gridRoot:Yn,floating:[],minimized:[],panels:{},activePanelId:null}}var Ot=({children:t,client:n,formatMessage:r,predefinedMessages:i,dir:b,modalClass:P,modalBodyClass:k,sidePanelClass:T,sidePanelBodyClass:R,windowClass:M,windowBodyClass:N})=>{let v=Ie(n?.registry??wt).current,S=n?.config.formatMessage??r,z=n?.config.predefinedMessages??i,D=n?.config.dir??b,[O,p]=Gn(()=>({...Xn(n?.initialState??null),draggedPanelId:null,dir:D||"ltr",isRtl:D==="rtl"})),w=Ie(O);w.current=O;let I=Ie(new Set);dt(()=>{I.current.forEach(o=>o())},[O]);let _=X(()=>w.current,[]),A=X(o=>(I.current.add(o),()=>I.current.delete(o)),[]),W=Ie({}),F=Rt(()=>({...lt,...z}),[z]),J=Ie(new Dt),x=Ie(1e3),Z=X((o,g)=>J.current.subscribe(o,g),[]),te=X((o,g)=>{J.current.publish(o,g)},[]),ne=X((o,g)=>{let a=typeof o.x=="string"?parseFloat(o.x):o.x,d=typeof o.y=="string"?parseFloat(o.y):o.y,e=typeof o.width=="string"?parseFloat(o.width):o.width,l=typeof o.height=="string"?parseFloat(o.height):o.height;isNaN(a)&&(a=300),isNaN(d)&&(d=150),isNaN(e)&&(e=450),isNaN(l)&&(l=350);let s=y=>g.some(m=>{let E=typeof m.x=="string"?parseFloat(m.x):m.x,L=typeof m.y=="string"?parseFloat(m.y):m.y;return!m.maximized&&Math.abs(E-y.x)<20&&Math.abs(L-y.y)<20}),c=0;for(;s({x:a,y:d})&&c<10;)a+=30,d+=30,c++;let u=Math.max(100,window.innerWidth||1024),h=Math.max(100,window.innerHeight||768);return(a+e>u||d+l>h)&&(a=100+c%5*30,d=100+c%5*30),a=Math.max(0,Math.min(a,u-100)),d=Math.max(0,Math.min(d,h-40)),{x:a,y:d,width:e,height:l}},[]),se=X(o=>{p(g=>{let a=g.panels[o];if(!a)return g;if(a.state==="floating"){let d=g.floating.find(l=>l.id===o);if(!d)return g;let e=!g.floating.some(l=>l.z>d.z);return e&&g.activePanelId===o?g:(e||(x.current+=1),{...g,floating:g.floating.map(l=>l.id===o?{...l,z:e?d.z:x.current}:l),activePanelId:o})}else if(a.state==="docked"){if(g.activePanelId===o)return g;let d=e=>e.type==="leaf"?e.panels.includes(o)?{...e,activePanelId:o}:e:{...e,children:e.children.map(d)};return{...g,gridRoot:d(g.gridRoot),activePanelId:o}}return g.activePanelId===o?g:{...g,activePanelId:o}})},[]),$=(o,g)=>{if(o.type==="leaf"){let a=o.panels.indexOf(g);if(a===-1)return o;let d=o.panels.filter(s=>s!==g),e=o.activePanelId===g?d[a]||d[a-1]||d[0]||null:o.activePanelId,l={...o,panels:d,activePanelId:e};return d.length===0&&!o.keepOnEmpty?null:l}else{let a=o.children.map(l=>$(l,g)).filter(l=>l!==null);if(a.length===0)return null;if(a.length===1)return a[0];let d=o.sizes.slice(0,a.length),e=d.reduce((l,s)=>l+s,0);return{...o,children:a,sizes:d.map(l=>l/e)}}},Q=(o,g,a)=>{if(o.type==="leaf"){if(o.id===g){let d=o.panels.includes(a)?o.panels:[...o.panels,a];return{...o,panels:d,activePanelId:a}}return o}else return{...o,children:o.children.map(d=>Q(d,g,a))}},Y=o=>{if(o.type==="leaf")return o.id;for(let g of o.children){let a=Y(g);if(a)return a}return null},ee=X((o,g,a)=>{let d=!(o in w.current.panels);p(e=>{let l=e.panels[o],s=v.get(g),c=a?.title||a?.title||s?.defaultOptions?.title||o,u=a?.initialTarget||s?.defaultOptions?.initialTarget||"docked",h=s?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350};if(l)if(l.state==="minimized"){let L=e.minimized.filter(C=>C.id!==o);if(u==="floating"||!e.gridRoot){x.current+=1;let C=ne(h,e.floating);return{...e,minimized:L,floating:[...e.floating,{...C,id:o,z:x.current}],panels:{...e.panels,[o]:{...l,state:"floating"}}}}else{let C=Y(e.gridRoot)||"group-default";return{...e,minimized:L,gridRoot:Q(e.gridRoot,C,o),panels:{...e.panels,[o]:{...l,state:"docked"}}}}}else{if(l.state==="floating")return se(o),e;{let L=C=>C.type==="leaf"?C.panels.includes(o)?{...C,activePanelId:o}:C:{...C,children:C.children.map(L)};return{...e,gridRoot:L(e.gridRoot)}}}let m={id:o,title:c,component:g,state:u==="tabbed"?"docked":u},E={...e.panels,[o]:m};if(u==="floating"){x.current+=1;let L=ne(h,e.floating),C=a?.stickyRight??s?.defaultOptions?.defaultStickyRight??!1,H=a?.stickyBottom??s?.defaultOptions?.defaultStickyBottom??!1,q=Math.max(100,window.innerWidth||1024),G=Math.max(100,window.innerHeight||768),ae=typeof L.width=="string"?parseFloat(L.width):L.width,fe=typeof L.height=="string"?parseFloat(L.height):L.height,De=L.x,Oe=L.y,we=10;return C&&(De=q-ae-we),H&&(Oe=G-fe-we),{...e,floating:[...e.floating,{...L,id:o,z:x.current,x:De,y:Oe,stickyRight:C,stickyBottom:H}],panels:E}}else{let L=Y(e.gridRoot)||"group-default";return{...e,gridRoot:Q(e.gridRoot,L,o),panels:E}}}),d&&J.current.publish("panel:opened",{id:o,component:g})},[ne,se]),re=X(o=>{let g=o in w.current.panels;p(a=>{let d=a.panels[o];if(!d||v.get(d.component)?.defaultOptions?.canClose===!1)return a;delete W.current[o];let l={...a.panels};delete l[o];let s=$(a.gridRoot,o);return{...a,gridRoot:s||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:a.floating.filter(c=>c.id!==o),minimized:a.minimized.filter(c=>c.id!==o),panels:l}}),g&&J.current.publish("panel:closed",{id:o})},[]),ce=X((o,g)=>{W.current[o]=g},[]),K=X(o=>{delete W.current[o]},[]),V=X((o,g,a)=>{p(d=>{let e=d.panels[o];return e?{...d,panels:{...d.panels,[o]:{...e,dirty:g,dirtyOptions:a}}}:d})},[]),oe=X((o,g)=>{p(a=>{let d=a.panels[o];return d?{...a,panels:{...a.panels,[o]:{...d,title:g}}}:a})},[]),B=X(async(o,g)=>{if(g?.force){re(o);return}let a=W.current[o];if(a&&!await a())return;let d=w.current.panels[o];if(d?.dirty)if(g?.onConfirm){if(!await g.onConfirm(d.dirtyOptions))return}else return;re(o)},[re]),ie=X(o=>{let g=w.current.panels[o]?.state!=="minimized"&&o in w.current.panels;p(a=>{let d=a.panels[o];if(!d||d.state==="minimized"||v.get(d.component)?.defaultOptions?.canMinimize===!1)return a;let l,s;if(d.state==="floating"){let u=a.floating.find(h=>h.id===o);u&&(l={x:Number(u.x),y:Number(u.y),width:Number(u.width),height:Number(u.height),stickyRight:u.stickyRight,stickyBottom:u.stickyBottom})}else if(d.state==="docked"){let u=h=>{if(h.type==="leaf")return h.panels.includes(o)?h.id:null;for(let y of h.children){let m=u(y);if(m)return m}return null};s=u(a.gridRoot)??void 0}let c=$(a.gridRoot,o);return{...a,gridRoot:c||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:a.floating.filter(u=>u.id!==o),minimized:[...a.minimized,{id:o,title:d.title,component:d.component}],panels:{...a.panels,[o]:{...d,state:"minimized",previousState:d.state,lastFloatingRect:l,lastLeafId:s}}}}),g&&J.current.publish("panel:minimized",{id:o})},[]),ge=X(o=>{let g=w.current.panels[o]?.state==="minimized";p(a=>{let d=a.panels[o];if(!d||d.state!=="minimized")return a;let e=a.minimized.filter(s=>s.id!==o);if((d.previousState||"docked")==="floating"){x.current+=1;let s=v.get(d.component),c=d.lastFloatingRect||s?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},u=ne(c,a.floating);return{...a,minimized:e,floating:[...a.floating,{...u,id:o,z:x.current,stickyRight:!!d.lastFloatingRect?.stickyRight,stickyBottom:!!d.lastFloatingRect?.stickyBottom}],panels:{...a.panels,[o]:{...d,state:"floating"}}}}else{let s=(y,m)=>y.type==="leaf"?y.id===m:y.children.some(E=>s(E,m)),c=d.lastLeafId&&s(a.gridRoot,d.lastLeafId),u=v.get(d.component),h=u?.defaultOptions?.canDrag!==!1;if(c)return{...a,minimized:e,gridRoot:Q(a.gridRoot,d.lastLeafId,o),panels:{...a.panels,[o]:{...d,state:"docked"}}};if(h){x.current+=1;let y=d.lastFloatingRect||u?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},m=ne(y,a.floating);return{...a,minimized:e,floating:[...a.floating,{...m,id:o,z:x.current,stickyRight:!!d.lastFloatingRect?.stickyRight,stickyBottom:!!d.lastFloatingRect?.stickyBottom}],panels:{...a.panels,[o]:{...d,state:"floating"}}}}else{let y=Y(a.gridRoot)||"group-default";return{...a,minimized:e,gridRoot:Q(a.gridRoot,y,o),panels:{...a.panels,[o]:{...d,state:"docked"}}}}}}),g&&J.current.publish("panel:restored",{id:o})},[ne]),ve=X((o,g)=>{p(a=>{let d=a.panels[o];if(!d||v.get(d.component)?.defaultOptions?.canDrag===!1)return a;let l=v.get(d.component),s=g||l?.defaultOptions?.favoritePosition||{x:300,y:150,width:450,height:350},c=$(a.gridRoot,o);x.current+=1;let u=ne(s,a.floating);return{...a,gridRoot:c||{type:"leaf",id:"group-default",panels:[],activePanelId:null},floating:[...a.floating,{...u,id:o,z:x.current}],panels:{...a.panels,[o]:{...d,state:"floating"}}}})},[ne]),Ee=X((o,g)=>{p(a=>{let d=a.panels[o];if(!d)return a;let e=a.floating.filter(c=>c.id!==o),l=$(a.gridRoot,o),s=g||Y(l||a.gridRoot)||"group-default";return{...a,gridRoot:Q(l||a.gridRoot,s,o),floating:e,panels:{...a.panels,[o]:{...d,state:"docked"}}}})},[]),Le=(o,g,a,d)=>{if(o.type==="leaf"){if(o.id===g){let e={type:"leaf",id:`group-split-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[a],activePanelId:a};return{type:"branch",orientation:d==="left"||d==="right"?"horizontal":"vertical",sizes:[.5,.5],children:d==="left"||d==="top"?[e,o]:[o,e]}}return o}else return{...o,children:o.children.map(e=>Le(e,g,a,d))}},ze=X(o=>{p(g=>({...g,draggedPanelId:o}))},[]),ue=X((o,g,a)=>{p(d=>{let e=d.panels[o];if(!e)return d;let l=d.floating.filter(u=>u.id!==o),s=$(d.gridRoot,o),c;return a==="center"?c=Q(s||d.gridRoot,g,o):c=Le(s||d.gridRoot,g,o,a),{...d,gridRoot:c,floating:l,panels:{...d.panels,[o]:{...e,state:"docked"}},draggedPanelId:null}})},[]),ft=X((o,g)=>{p(a=>{let d=a.panels[o];if(!d)return a;let e=a.floating.filter(y=>y.id!==o),l=$(a.gridRoot,o),s={type:"leaf",id:`group-edge-${Date.now()}-${Math.floor(Math.random()*1e3)}`,panels:[o],activePanelId:o},c=g==="left"||g==="right"?"horizontal":"vertical",u=g==="left"||g==="top"?[s,l||a.gridRoot]:[l||a.gridRoot,s];return{...a,gridRoot:{type:"branch",orientation:c,sizes:g==="left"||g==="top"?[.3,.7]:[.7,.3],children:u},floating:e,panels:{...a.panels,[o]:{...d,state:"docked"}},draggedPanelId:null}})},[]),Ne=X((o,g,a)=>{p(d=>{let e=d.panels[o];if(!e)return d;let l=$(d.gridRoot,o),s=h=>{if(h.type==="leaf"){if(h.id===g){let y=h.panels.filter(L=>L!==o),m=Math.max(0,Math.min(a,y.length)),E=[...y];return E.splice(m,0,o),{...h,panels:E,activePanelId:o}}return h}else return{...h,children:h.children.map(s)}},c=s(l||d.gridRoot),u=d.floating.filter(h=>h.id!==o);return{...d,gridRoot:c,floating:u,panels:{...d.panels,[o]:{...e,state:"docked"}},draggedPanelId:null}})},[]),Te=X(o=>{p(g=>{let a=e=>{if(e.type==="leaf")return e.id===o&&e.canClose!==!1?null:e;{let l=e.children.map(u=>a(u)).filter(u=>u!==null);if(l.length===0)return null;if(l.length===1)return l[0];let s=e.sizes.slice(0,l.length),c=s.reduce((u,h)=>u+h,0);return{...e,children:l,sizes:s.map(u=>u/c)}}},d=a(g.gridRoot);return{...g,gridRoot:d||{type:"leaf",id:"group-default",panels:[],activePanelId:null}}})},[]),mt=X(o=>{p(g=>({...g,floating:g.floating.map(a=>a.id===o?{...a,maximized:!a.maximized}:a)}))},[]),ht=X((o,g)=>{let a=(d,e)=>{if(d.type==="leaf")return d;if(e===o.length)return{...d,sizes:g};let l=o[e],s=d.children.map((c,u)=>u===l?a(c,e+1):c);return{...d,children:s}};p(d=>({...d,gridRoot:a(d.gridRoot,0)}))},[]),tt=X((o,g)=>{p(a=>({...a,floating:a.floating.map(d=>d.id===o?{...d,...g}:d)}))},[]),Be=X(()=>JSON.stringify({gridRoot:w.current.gridRoot,floating:w.current.floating,minimized:w.current.minimized,panels:w.current.panels}),[]),He=X(o=>{try{let g=JSON.parse(o);if(g.gridRoot&&g.floating&&g.minimized&&g.panels){let a=Object.keys(g.panels)[0]||null;return p(d=>({...d,gridRoot:g.gridRoot,floating:g.floating,minimized:g.minimized,panels:g.panels,draggedPanelId:null,activePanelId:a})),!0}return!1}catch(g){return console.error("Failed to parse layout configuration:",g),!1}},[]),_e=X(o=>{p(g=>g.activePanelId===o?g:{...g,activePanelId:o})},[]),nt=X(o=>{p(g=>g.dir===o?g:{...g,dir:o,isRtl:o==="rtl"})},[]),vt=X(o=>o in w.current.panels,[]),ot=X(()=>Object.keys(w.current.panels),[]);dt(()=>{D&&p(o=>o.dir===D?o:{...o,dir:D,isRtl:D==="rtl"})},[D]);let We=Ie(new Map),Ke=X((o,g)=>(We.current.set(o,g),()=>{We.current.delete(o)}),[]),xe=X(o=>We.current.get(o)?.()??[],[]),it=Rt(()=>({openPanel:ee,closePanel:re,minimizePanel:ie,restorePanel:ge,floatPanel:ve,dockPanel:Ee,maximizePanel:mt,updateSplitSizes:ht,updateFloatingPosition:tt,focusPanel:se,isOpen:vt,getOpenPanelIds:ot,saveLayout:Be,loadLayout:He,publish:te,subscribe:Z,setDraggedPanelId:ze,dockPanelToGroup:ue,movePanelOrder:Ne,closeLeafGroup:Te,registerCloseGuard:ce,unregisterCloseGuard:K,setPanelDirty:V,updatePanelTitle:oe,requestClosePanel:B,dockPanelToWorkspaceEdge:ft,setActivePanel:_e,setDirection:nt,registerPanelContextMenu:Ke,getPanelContextMenuItems:xe}),[ee,re,ie,ge,ve,Ee,mt,ht,tt,se,vt,ot,Be,He,te,Z,ze,ue,Ne,Te,ce,K,V,oe,B,ft,_e,nt,Ke,xe]),Nt=o=>{let g=o.defaultMessage||o.id;return o.values&&Object.entries(o.values).forEach(([a,d])=>{g=g.replace(`{${a}}`,String(d))}),g},Ce=Rt(()=>({modalClass:P,modalBodyClass:k,sidePanelClass:T,sidePanelBodyClass:R,windowClass:M,windowBodyClass:N}),[P,k,T,R,M,N]);dt(()=>{if(process.env.NODE_ENV!=="development")return;try{getComputedStyle(document.documentElement).getPropertyValue("--rdd-styles-loaded").trim()!=="1"&&console.error(`[react-dockable-desktop] styles.css is not imported.
|
|
2
|
+
Add this to your entry file (main.tsx / index.tsx):
|
|
3
|
+
import 'react-dockable-desktop/styles.css'
|
|
4
|
+
Without it the workspace renders as a black screen with no console errors.`)}catch{}let o=!1;try{for(let g of Array.from(document.styleSheets))try{if(Array.from(g.cssRules||[]).some(d=>d.cssText?.includes("react-contexify"))){o=!0;break}}catch{}}catch{}o||console.warn(`[react-dockable-desktop] replace-react-contexify CSS not detected. Context menus may not render correctly.
|
|
5
|
+
Add: import "replace-react-contexify/dist/ReactContexify.css"`)},[]),dt(()=>{if(n)return n._connect(it),()=>{n._disconnect()}},[n,it]);let bt=Rt(()=>({getSnapshot:_,subscribeToState:A}),[_,A]);return $e(rn.Provider,{value:Ce,children:$e(sn.Provider,{value:v,children:$e(nn.Provider,{value:bt,children:$e(en.Provider,{value:O,children:$e(Mt.Provider,{value:it,children:$e(tn.Provider,{value:S||Nt,children:$e(on.Provider,{value:F,children:t})})})})})})})},Qt=t=>()=>{};function Re(t){let n=Se(en),r=Se(nn),i=Ie(t);i.current=t;let b=$n(t?r?.subscribeToState??Qt:Qt,()=>{let P=r?.getSnapshot()??n;return i.current?i.current(P):P},()=>{let P=r?.getSnapshot()??n;return i.current?i.current(P):P});if(!n)throw new Error("useWindowManagerState must be used within WindowManagerProvider");return t?b:n}var ut=()=>{let t=Se(Mt);if(!t)throw new Error("useWindowManagerActions must be used within WindowManagerProvider");return t},Ft=()=>{let t=Se(Mt);if(!t)throw new Error("useWindowManagerActionsInternal must be used within WindowManagerProvider");return t},be=()=>Se(tn)||(n=>{let r=n.defaultMessage||n.id;return n.values&&Object.entries(n.values).forEach(([i,b])=>{r=r.replace(`{${i}}`,String(b))}),r}),j=(t,n)=>t?typeof t=="string"?t:n(t):"",Vn=()=>{let{publish:t,subscribe:n}=ut();return{publish:t,subscribe:n}},Me=()=>Se(on),an=()=>at().instanceId;function qn(t){let n=Se(Mt),r=an(),i=Ie(t);i.current=t,dt(()=>{if(!(!n?.registerPanelContextMenu||!r))return n.registerPanelContextMenu(r,()=>i.current)},[r,n?.registerPanelContextMenu])}function ln(t){if(!t)return typeof document<"u"?document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl":!1;let n=t.closest("[dir]");return n?n.getAttribute("dir")?.toLowerCase()==="rtl":document.documentElement.dir?.toLowerCase()==="rtl"||document.body.dir?.toLowerCase()==="rtl"}import{JsonContextMenu as eo}from"replace-react-contexify";import"replace-react-contexify/styles.css";import{createContext as un,useContext as pn,useState as Kn,useCallback as ye,useMemo as jn,useRef as Un}from"react";import{jsx as cn}from"react/jsx-runtime";var Jn=0,At=()=>`panel-${++Jn}-${Date.now()}`,kt=new Map,dn={leftPanel:null,rightPanel:null,modals:[]},gn=un(null),fn=un(null),Bt=({children:t})=>{let[n,r]=Kn(dn),i=Un(n);i.current=n;let b=ye((p,w)=>{kt.set(p,w)},[]),P=ye(p=>{kt.delete(p)},[]),k=ye(async(p,w,I={})=>{let _=i.current.leftPanel;if(_){let F=kt.get(_.id);if(F&&!await F())return null}let A=At(),W={id:A,Component:p,props:w,containerType:"left-panel",options:I};return r(F=>({...F,leftPanel:W})),A},[]),T=ye(async(p,w,I={})=>{let _=i.current.rightPanel;if(_){let F=kt.get(_.id);if(F&&!await F())return null}let A=At(),W={id:A,Component:p,props:w,containerType:"right-panel",options:I};return r(F=>({...F,rightPanel:W})),A},[]),R=ye((p,w,I={})=>{let _=At(),A=w.title,W={...I,title:I.title||A||"Confirmation"},F={id:_,Component:p,props:w,containerType:"modal",options:W};return r(J=>({...J,modals:[...J.modals,F]})),_},[]),M=ye(p=>{r(w=>({leftPanel:w.leftPanel?.id===p?null:w.leftPanel,rightPanel:w.rightPanel?.id===p?null:w.rightPanel,modals:w.modals.filter(I=>I.id!==p)}))},[]),N=ye(()=>{r(dn)},[]),v=ye(()=>{r(p=>({...p,modals:[]}))},[]),S=ye(p=>n.leftPanel?.id===p?n.leftPanel:n.rightPanel?.id===p?n.rightPanel:n.modals.find(w=>w.id===p),[n]),z=ye((p,w)=>{r(I=>({leftPanel:I.leftPanel?.id===p?{...I.leftPanel,...w}:I.leftPanel,rightPanel:I.rightPanel?.id===p?{...I.rightPanel,...w}:I.rightPanel,modals:I.modals.map(_=>_.id===p?{..._,...w}:_)}))},[]),D=ye((p,w,I)=>{z(p,{dirty:w,dirtyOptions:I})},[z]),O=jn(()=>({openLeftPanel:k,openRightPanel:T,openModal:R,close:M,closeAll:N,closeAllModals:v,getInstance:S,updateInstance:z,setDirty:D,registerCloseHandler:b,unregisterCloseHandler:P}),[k,T,R,M,N,v,S,z,D,b,P]);return cn(gn.Provider,{value:n,children:cn(fn.Provider,{value:O,children:t})})},Ae=()=>{let t=pn(gn);if(!t)throw new Error("usePanelState must be used within PanelProvider");return t},Xe=()=>{let t=pn(fn);if(!t)throw new Error("usePanelActions must be used within PanelProvider");return t};import{useEffect as mn,useRef as Zn}from"react";import{jsx as Ve,jsxs as Ht}from"react/jsx-runtime";var Qn=({title:t,message:n,alert:r,alertType:i="info",useYesNoTitles:b=!1,onOK:P,onCancel:k})=>{let{requestClose:T,setIcon:R,setTitle:M}=at(),N=be(),v=Me(),S=Zn(null);mn(()=>{if(t){let I=typeof t=="string"?t:N(t);M(I)}R&&R(Ve("span",{children:"\u2753"}))},[t,M,R,N]),mn(()=>{S.current?.focus()},[]);let z=typeof n=="string"?n:N(n),D=N(b?v.no:v.cancel),O=N(b?v.yes:v.ok),p=I=>{I.preventDefault(),P?.(),T()},w=()=>{k?.(),T()};return Ht("form",{onSubmit:p,className:"confirmation-form-body",children:[r&&Ht("div",{className:`confirmation-alert confirmation-alert-${i}`,children:[Ve("span",{children:"\u2139\uFE0F"}),Ve("span",{children:r})]}),Ve("div",{style:{fontSize:"0.9rem",color:"inherit",lineHeight:1.5},children:z}),Ve("hr",{style:{marginTop:"0.5rem",marginBottom:"0.5rem",opacity:.1}}),Ht("div",{className:"confirmation-actions",children:[Ve("button",{type:"button",className:"dw-btn dw-btn-sm dw-btn-outline",onClick:w,children:D}),Ve("button",{type:"submit",className:"dw-btn dw-btn-sm dw-btn-primary",ref:S,children:O})]})]})},qe=Qn;import{Fragment as vn,jsx as f,jsxs as U}from"react/jsx-runtime";var bn=(t,n)=>{if(!t)return null;if(t.type==="leaf")return t.id===n?t:null;for(let r of t.children){let i=bn(r,n);if(i)return i}return null},pt=new Map,It="preserved-dom-container",Gt=U("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:[f("rect",{x:"3",y:"3",width:"7",height:"9",rx:"1"}),f("rect",{x:"14",y:"3",width:"7",height:"5",rx:"1"}),f("rect",{x:"14",y:"12",width:"7",height:"9",rx:"1"}),f("rect",{x:"3",y:"16",width:"7",height:"5",rx:"1"})]}),Ze={float:f("span",{className:"wm-menu-icon",children:U("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:[f("rect",{x:"2",y:"8",width:"14",height:"14",rx:"1"}),f("rect",{x:"8",y:"2",width:"14",height:"14",rx:"1"})]})}),minimize:f("span",{className:"wm-menu-icon",children:f("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",style:{display:"block"},children:f("line",{x1:"4",y1:"18",x2:"20",y2:"18"})})}),restore:f("span",{className:"wm-menu-icon",children:f("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:f("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1"})})}),maximize:f("span",{className:"wm-menu-icon",children:f("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:f("rect",{x:"2",y:"2",width:"20",height:"20",rx:"1"})})}),close:f("span",{className:"wm-menu-icon",children:f("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",style:{display:"block"},children:f("path",{d:"M18 6L6 18M6 6l12 12"})})})},yn=t=>{let n=pt.get(t);return n||(n=document.createElement("div"),n.style.width="100%",n.style.height="100%",pt.set(t,n)),n},to=(t,n,r)=>{let i=r.get(n);if(!i)return console.warn(`[react-dockable-desktop] Panel "${t}" references component key "${n}" which is not registered. Add it to the WorkspaceClient panels config:
|
|
6
|
+
new WorkspaceClient({ panels: { "${n}": { component: YourComponent } } })`),U("div",{className:"dw-unregistered-panel",style:{border:"2px dashed #dc3545"},children:[f("h6",{style:{fontWeight:700,marginBottom:"0.25rem"},children:"\u26A0\uFE0F Component Unregistered"}),U("span",{style:{fontSize:"0.875rem",color:"var(--text-secondary, #94a3b8)"},children:["Key: ",n]})]});let b=i.Component;return f(b,{panelId:t})},Pn=new Map,Qe=new Map,Tt=t=>{let n=Qe.get(t);return n||(n={onClose:new Set,onMinimize:new Set,onRestore:new Set,onResize:new Set},Qe.set(t,n)),n},xn=({panelId:t})=>{let n=pe(null);return le(()=>{let r=n.current;if(!r)return;let i=yn(t);r.appendChild(i);let b=new ResizeObserver(P=>{for(let k of P){let{width:T,height:R}=k.contentRect;if(T>0&&R>0){Pn.set(t,{width:T,height:R});let M=Qe.get(t);M&&M.onResize.forEach(N=>N(T,R))}}});return b.observe(r),()=>{b.disconnect();let P=document.getElementById(It);P||(P=document.createElement("div"),P.id=It,P.style.display="none",document.body.appendChild(P)),P.appendChild(i)}},[t]),f("div",{ref:n,style:{width:"100%",height:"100%"}})},no=({panelId:t})=>{let n=Re(),r=ct(),i=be(),b=pe(null),P=n.panels[t],k=P?r.get(P.component):null,T=k?.defaultOptions?.disableLivePreview||!1,R=Pn.get(t)||{width:800,height:500},M=R.width,N=R.height,z=Math.min(220/M,140/N);if(le(()=>{if(T)return;let D=b.current;if(!D)return;let O=pt.get(t);if(O)return D.appendChild(O),()=>{let p=document.getElementById(It);p||(p=document.createElement("div"),p.id=It,p.style.display="none",document.body.appendChild(p)),p.appendChild(O)}},[t,T]),T){let D=M*z,O=N*z,p=P?.title||k?.defaultOptions?.title||"Panel",w=j(p,i),I=(Array.from(w)[0]||"P").toUpperCase();return f("div",{className:"taskbar-item-preview-frame",style:{width:`${D}px`,height:`${O}px`,display:"flex",alignItems:"center",justifyContent:"center",background:"rgba(108, 117, 125, 0.15)",border:"1px dashed var(--taskbar-item-border, rgba(255, 255, 255, 0.15))"},children:f("div",{style:{fontSize:"2rem",fontWeight:600,color:"var(--panel-title-color, var(--panel-text, rgba(255, 255, 255, 0.85)))",userSelect:"none"},children:I})})}return f("div",{className:"taskbar-item-preview-frame",style:{width:`${M*z}px`,height:`${N*z}px`},children:f("div",{ref:b,className:"taskbar-item-preview-host",style:{width:`${M}px`,height:`${N}px`,transform:`scale(${z})`,transformOrigin:"top left",position:"absolute",top:0,left:0,"--preview-scale":z}})})},oo=({panelId:t,children:n})=>{let r=Re(),{requestClosePanel:i,setPanelDirty:b,registerCloseGuard:P,unregisterCloseGuard:k,updatePanelTitle:T}=ut(),R=r.minimized.some(v=>v.id===t),M=pe(R);le(()=>{let v=Qe.get(t);v&&(R&&!M.current?v.onMinimize.forEach(S=>S()):!R&&M.current&&v.onRestore.forEach(S=>S()),M.current=R)},[R,t]),le(()=>()=>{let v=Qe.get(t);v&&(v.onClose.forEach(S=>S()),Qe.delete(t))},[t]);let N=$t.useMemo(()=>({requestClose:v=>i(t,v),setDirty:v=>b(t,v),onCloseRequested:v=>(P(t,v),()=>k(t)),setTitle:v=>T(t,v),instanceId:t,onClose:v=>{let S=Tt(t);return S.onClose.add(v),()=>S.onClose.delete(v)},onMinimize:v=>{let S=Tt(t);return S.onMinimize.add(v),()=>S.onMinimize.delete(v)},onRestore:v=>{let S=Tt(t);return S.onRestore.add(v),()=>S.onRestore.delete(v)},onResize:v=>{let S=Tt(t);return S.onResize.add(v),()=>S.onResize.delete(v)}}),[t,i,b,P,k,T]);return f(Ge,{value:N,children:n})},Cn=({node:t,path:n,onTabRightClick:r,activeDropZone:i,onHoverDropZone:b,onTabDragStart:P,hoveredTab:k,onTabHover:T,defaultPanelIcon:R,onRequestClosePanel:M})=>{let{updateSplitSizes:N}=ut();if(t.type==="leaf")return f(io,{leaf:t,onTabRightClick:r,activeDropZone:i,onHoverDropZone:b,onTabDragStart:P,hoveredTab:k,onTabHover:T,defaultPanelIcon:R,onRequestClosePanel:M});let v=t.orientation==="horizontal",S=(z,D)=>{D.preventDefault();let O=D.currentTarget;O.setPointerCapture(D.pointerId);let p=v?D.clientX:D.clientY,w=[...t.sizes];O.classList.add("active"),document.body.classList.add("resizing-active",v?"resizing-col-active":"resizing-row-active");let I=O.parentElement,_=I?v?I.clientWidth:I.clientHeight:v?1e3:800,A=F=>{let x=((v?F.clientX:F.clientY)-p)/_,Z=[...w];Z[z]+=x,Z[z+1]-=x,Z[z]>.1&&Z[z+1]>.1&&N(n,Z)},W=()=>{O.classList.remove("active"),document.body.classList.remove("resizing-active","resizing-row-active","resizing-col-active"),O.removeEventListener("pointermove",A),O.removeEventListener("pointerup",W),O.removeEventListener("pointercancel",W)};O.addEventListener("pointermove",A),O.addEventListener("pointerup",W),O.addEventListener("pointercancel",W)};return f("div",{style:{display:"flex",flexDirection:v?"row":"column",width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:t.children.map((z,D)=>{let O=t.sizes[D]*100;return U($t.Fragment,{children:[f("div",{style:{flexGrow:t.sizes[D],flexBasis:`${O}%`,overflow:"hidden",position:"relative"},children:f(Cn,{node:z,path:[...n,D],onTabRightClick:r,activeDropZone:i,onHoverDropZone:b,onTabDragStart:P,hoveredTab:k,onTabHover:T,defaultPanelIcon:R,onRequestClosePanel:M})}),D<t.children.length-1&&f("div",{onPointerDown:p=>S(D,p),style:{cursor:v?"col-resize":"row-resize",width:v?"1px":"100%",height:v?"100%":"1px",zIndex:20},className:"resizer-bar"})]},D)})})},io=({leaf:t,onTabRightClick:n,activeDropZone:r,onHoverDropZone:i,onTabDragStart:b,hoveredTab:P,onTabHover:k,defaultPanelIcon:T,onRequestClosePanel:R})=>{let M=Re(),N=ct(),{openPanel:v,closeLeafGroup:S,setActivePanel:z}=Ft(),D=be(),O=Me(),{windowClass:p,windowBodyClass:w}=Fe(),I=pe(null),[_,A]=ke({left:!1,right:!1}),W=_t(()=>{let x=I.current;x&&A({left:x.scrollLeft>0,right:x.scrollLeft<x.scrollWidth-x.clientWidth-1})},[]);le(()=>{let x=I.current;if(!x)return;x.addEventListener("scroll",W,{passive:!0});let Z=new ResizeObserver(W);return Z.observe(x),W(),()=>{x.removeEventListener("scroll",W),Z.disconnect()}},[W]);let F=x=>{I.current?.scrollBy({left:x==="left"?-120:120,behavior:"smooth"})},J=x=>{v(x,M.panels[x].component),z(x)};return U("div",{"data-active-panel-id":t.activePanelId||"",className:`workspace-panel ${p??""}`,style:{overflow:"hidden",position:"relative"},children:[U("div",{className:"workspace-tab-bar",style:{minHeight:"38px"},children:[_.left&&f("button",{className:"tab-scroll-btn tab-scroll-btn-left",onPointerDown:x=>x.stopPropagation(),onClick:()=>F("left"),tabIndex:-1,"aria-label":"Scroll tabs left",children:"\u2039"}),f("div",{ref:I,className:"tab-headers-container",style:{scrollbarWidth:"none"},onPointerMove:x=>{M.draggedPanelId&&x.target===x.currentTarget&&k(t.id,"EMPTY",t.panels.length,"right")},onPointerLeave:x=>{M.draggedPanelId&&x.target===x.currentTarget&&k(t.id,"",-1,null)},children:t.panels.map((x,Z)=>{let te=M.panels[x];if(!te)return null;let ne=t.activePanelId===x,se=M.activePanelId===x,Q=N.get(te.component)?.defaultOptions,Y=P&&P.leafId===t.id&&P.panelId===x,ee=Z===t.panels.length-1,re=P&&P.leafId===t.id&&P.panelId==="EMPTY"&&ee,ce=Y?P.side==="left"?"drag-hover-left":"drag-hover-right":re?"drag-hover-right":"",K=ne?se?"active workspace-tab-active-focused":"active workspace-tab-active-unfocused":"workspace-tab-inactive";return U("div",{"data-tab-id":x,"data-leaf-id":t.id,"data-tab-index":String(Z),onClick:()=>J(x),onPointerDown:V=>{Q?.canDrag!==!1&&b(x,V)},onContextMenu:V=>n(x,V),onPointerMove:V=>{if(M.draggedPanelId&&V.pointerType!=="touch"){let oe=V.currentTarget.getBoundingClientRect(),ie=V.clientX-oe.left<oe.width/2?"left":"right";k(t.id,x,Z,ie)}},onPointerLeave:()=>{M.draggedPanelId&&k(t.id,"",-1,null)},className:`workspace-tab ${K} ${ce}`,style:{cursor:Q?.canDrag===!1?"default":"pointer"},children:[U("span",{className:"text-truncate",style:{maxWidth:"120px",display:"flex",alignItems:"center"},children:[f("span",{className:"workspace-tab-icon",children:Q?.icon||T||Gt}),U("span",{children:[j(te.title,D),te.dirty?" *":""]})]}),Q?.renderHeaderActions&&f("span",{className:"tab-header-actions",onClick:V=>V.stopPropagation(),onPointerDown:V=>V.stopPropagation(),children:Q.renderHeaderActions(x)}),Q?.canClose!==!1&&f("span",{onClick:V=>{V.stopPropagation(),R(x)},title:j(O.closeTab,D),className:"close-tab-x",style:{width:"18px",height:"18px",...Q?.renderHeaderActions?{}:{marginInlineStart:"auto"}},children:f("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:f("path",{d:"M18 6L6 18M6 6l12 12"})})})]},x)})}),_.right&&f("button",{className:"tab-scroll-btn tab-scroll-btn-right",onPointerDown:x=>x.stopPropagation(),onClick:()=>F("right"),tabIndex:-1,"aria-label":"Scroll tabs right",children:"\u203A"}),t.panels.length===0&&t.keepOnEmpty&&t.canClose!==!1&&f("span",{onClick:()=>S(t.id),className:"close-tab-x header-close-empty-group",style:{width:"18px",height:"18px",cursor:"pointer"},title:j(O.closeEmptyGroup,D),children:f("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:f("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),U("div",{className:`dw-panel-body ${w??""}`,style:{position:"relative",overflow:"hidden"},children:[t.activePanelId&&M.panels[t.activePanelId]?f(xn,{panelId:t.activePanelId},t.activePanelId):f("div",{className:"empty-leaf-placeholder",children:f("span",{children:"Empty Workspace Section"})}),M.draggedPanelId!==null&&f("div",{className:"dock-drop-zone-overlay",children:U("div",{className:"dock-target-cross",children:[f("div",{"data-leaf-id":t.id,"data-drop-zone":"top",onPointerEnter:()=>i(t.id,"top"),onPointerLeave:()=>i(t.id,null),className:"dock-target-box dock-target-top",children:"\u25B2"}),f("div",{"data-leaf-id":t.id,"data-drop-zone":"bottom",onPointerEnter:()=>i(t.id,"bottom"),onPointerLeave:()=>i(t.id,null),className:"dock-target-box dock-target-bottom",children:"\u25BC"}),f("div",{"data-leaf-id":t.id,"data-drop-zone":"left",onPointerEnter:()=>i(t.id,"left"),onPointerLeave:()=>i(t.id,null),className:"dock-target-box dock-target-left",children:"\u25C0"}),f("div",{"data-leaf-id":t.id,"data-drop-zone":"right",onPointerEnter:()=>i(t.id,"right"),onPointerLeave:()=>i(t.id,null),className:"dock-target-box dock-target-right",children:"\u25B6"}),f("div",{"data-leaf-id":t.id,"data-drop-zone":"center",onPointerEnter:()=>i(t.id,"center"),onPointerLeave:()=>i(t.id,null),className:"dock-target-box dock-target-center",children:"\u25A3"})]})}),M.draggedPanelId!==null&&r!==null&&r.leafId===t.id&&f("div",{className:"dock-preview-highlight",style:{left:r.position==="right"?"50%":"0",top:r.position==="bottom"?"50%":"0",width:r.position==="left"||r.position==="right"?"50%":"100%",height:r.position==="top"||r.position==="bottom"?"50%":"100%"}})]})]})},ro=({skin:t="vscode",defaultPanelIcon:n,taskbarVisibility:r="always"})=>{let i=Re(),b=ct(),{restorePanel:P,minimizePanel:k,requestClosePanel:T,maximizePanel:R,updateFloatingPosition:M,focusPanel:N,floatPanel:v,setDraggedPanelId:S,dockPanelToGroup:z,movePanelOrder:D,dockPanelToWorkspaceEdge:O,setActivePanel:p,setDirection:w,getPanelContextMenuItems:I}=Ft(),{openModal:_}=Xe(),A=be(),W=Me(),F=$t.useCallback(e=>{let l=i.panels[e];T(e,{onConfirm:s=>new Promise(c=>{let u=s||l?.dirtyOptions,h=l?j(l.title,A):"Panel";_(qe,{title:u?.title||W.unsavedChangesTitle,message:u?.message||{id:W.unsavedChangesMessage.id,defaultMessage:W.unsavedChangesMessage.defaultMessage,values:{title:h}},alert:u?.alert,alertType:u?.alertType||"danger",useYesNoTitles:!0,onOK:()=>c(!0),onCancel:()=>c(!1)},{size:"small"})})})},[T,i.panels,A,_,W]),{windowClass:J,windowBodyClass:x}=Fe(),Z=pe(null),te=pe(null),[ne,se]=ke(!1),$=pe(null),Q=pe(i.minimized.length),[Y,ee]=ke(null),re=pe(null),ce=pe("mouse"),[K,V]=ke(!1);le(()=>()=>{re.current&&clearTimeout(re.current)},[]),le(()=>{Y&&(i.minimized.some(l=>l.id===Y.id)||ee(null))},[i.minimized,Y]),le(()=>{if(!Y?.fromTouch)return;let e=l=>{l.pointerType!=="touch"||document.querySelector(".taskbar-item-tooltip")?.contains(l.target)||ee(null)};return document.addEventListener("pointerdown",e,{capture:!0}),()=>document.removeEventListener("pointerdown",e,{capture:!0})},[Y?.fromTouch]);let[oe,B]=ke(null),ie=pe(null),[ge,ve]=ke({x:0,y:0}),[Ee,Le]=ke(null),ze=pe(null),ue=e=>{Le(e),ze.current=e},[ft,Ne]=ke(null),Te=pe(null),mt=(e,l,s,c)=>{let u=c?{leafId:e,panelId:l,index:s,side:c}:null;Ne(u),Te.current=u},ht=(e,l)=>{let s=l?{leafId:e,position:l}:null;B(s),ie.current=s},tt=(e,l)=>{let s=document.elementsFromPoint(e,l),c=!1,u=!1,h=!1;for(let y of s)if(y instanceof HTMLElement){if(!c&&y.dataset.dropZone){let m=y.dataset.leafId;if(m){let E=y.dataset.dropZone;B({leafId:m,position:E}),ie.current={leafId:m,position:E},c=!0}}if(!h&&y.dataset.tabId){let m=y.dataset.leafId,E=parseInt(y.dataset.tabIndex||"0",10);if(m){let L=y.getBoundingClientRect(),C=e-L.left<L.width/2?"left":"right";Ne({leafId:m,panelId:y.dataset.tabId,index:E,side:C}),Te.current={leafId:m,panelId:y.dataset.tabId,index:E,side:C},h=!0}}if(!u&&y.dataset.edgeTrigger&&(ue(y.dataset.edgeTrigger),u=!0),c&&u&&h)break}c||(B(null),ie.current=null),u||ue(null),h||(Ne(null),Te.current=null)},Be=300,He=8,_e=()=>{S(null),B(null),ie.current=null,Ne(null),Te.current=null,ue(null)},nt=(e,l)=>{let s=ie.current,c=Te.current,u=ze.current;if(u)O(e,u);else if(c){let h=c.index;c.side==="right"&&(h+=1);let y=bn(i.gridRoot,c.leafId);if(y){let m=y.panels.indexOf(e);m!==-1&&m<h&&(h-=1)}D(e,c.leafId,h)}else s?z(e,s.leafId,s.position):v(e,{x:l.clientX-150,y:l.clientY-15,width:450,height:350});_e()},vt=(e,l)=>{if(l.pointerType==="mouse"&&l.button!==0)return;let s=l.currentTarget,c=l.clientX,u=l.clientY;if(l.pointerType==="touch"){let h=l.pointerId,y=!1,m=()=>{y=!0,clearTimeout(L),s.removeEventListener("pointermove",E),s.removeEventListener("pointerup",m),s.removeEventListener("pointercancel",m)},E=C=>{Math.hypot(C.clientX-c,C.clientY-u)>He&&m()},L=setTimeout(()=>{if(y)return;s.removeEventListener("pointermove",E),s.removeEventListener("pointerup",m),s.removeEventListener("pointercancel",m);try{s.setPointerCapture(h)}catch{return}s.classList.add("long-press-active"),navigator.vibrate&&navigator.vibrate(10);let C=!1,H=ae=>{C||(C=!0,S(e)),ve({x:ae.clientX,y:ae.clientY}),tt(ae.clientX,ae.clientY)},q=ae=>{s.classList.remove("long-press-active"),s.removeEventListener("pointermove",H),s.removeEventListener("pointerup",q),s.removeEventListener("pointercancel",G),C?nt(e,ae):ot(e,ae)},G=()=>{s.classList.remove("long-press-active"),s.removeEventListener("pointermove",H),s.removeEventListener("pointerup",q),s.removeEventListener("pointercancel",G),C&&_e()};s.addEventListener("pointermove",H),s.addEventListener("pointerup",q),s.addEventListener("pointercancel",G)},Be);s.addEventListener("pointermove",E),s.addEventListener("pointerup",m),s.addEventListener("pointercancel",m)}else{let h=!1,y=E=>{let L=E.clientX-c,C=E.clientY-u;!h&&(Math.abs(L)>5||Math.abs(C)>5)&&(h=!0,S(e)),h&&ve({x:E.clientX,y:E.clientY})},m=E=>{window.removeEventListener("pointermove",y),window.removeEventListener("pointerup",m),h&&nt(e,E)};window.addEventListener("pointermove",y),window.addEventListener("pointerup",m)}},ot=(e,l)=>{l.preventDefault();let s=i.panels[e];if(!s)return;let u=b.get(s.component)?.defaultOptions,h=[];if(u?.canDrag!==!1&&h.push({label:j(W.floatWindow,A),icon:Ze.float,action:()=>v(e)}),u?.canMinimize!==!1&&h.push({label:j(W.minimizePanel,A),icon:Ze.minimize,action:()=>k(e)}),h.length>0&&u?.canClose!==!1&&h.push({separator:!0}),u?.canClose!==!1&&h.push({label:j(W.closeTab,A),icon:Ze.close,action:()=>F(e)}),h.length===0)return;let y=I(e),m=y.length>0?[...h,{separator:!0},...y]:h;te.current?.show({event:l,contextMenu:{items:m}})},We=(e,l)=>{l.preventDefault(),ee(null),te.current?.show({event:l,contextMenu:{items:[{label:j(W.restorePanel,A),icon:Ze.restore,action:()=>P(e)},{label:j(W.maximizePanel,A),icon:Ze.maximize,action:()=>R(e)},{separator:!0},{label:j(W.closePanel,A),icon:Ze.close,action:()=>F(e)}]}})};le(()=>{let e=Object.keys(i.panels);for(let l of Array.from(pt.keys()))e.includes(l)||pt.delete(l)},[i.panels]),le(()=>{let e=()=>{i.draggedPanelId!==null&&(S(null),B(null),Ne(null))};return window.addEventListener("blur",e),()=>{window.removeEventListener("blur",e)}},[i.draggedPanelId]);let Ke=pe(null),[xe,it]=ke({width:1024,height:768});le(()=>{let e=Ke.current;if(!e)return;let l=!1,s=new ResizeObserver(c=>{if(!c||c.length===0)return;let u=c[0].contentRect;if(process.env.NODE_ENV==="development"&&u.height<10&&!l){l=!0;let h=e,y=e.parentElement;for(;y&&y!==document.documentElement&&y.getBoundingClientRect().height<10;){h=y;y=y.parentElement}let m=h.tagName.toLowerCase(),E=h.id?` id="${h.id}"`:"",L=h.className?` class="${h.className}"`:"",C=h===e?"the WindowManager container itself":`a wrapper element: <${m}${E}${L}>`;console.warn(`[react-dockable-desktop] Workspace height is 0px \u2014 the workspace will be invisible.
|
|
7
|
+
|
|
8
|
+
Zero height found at: ${C}
|
|
9
|
+
|
|
10
|
+
Root cause: in CSS, "height: 100%" only works when the parent has an explicit height.
|
|
11
|
+
If any ancestor has height: auto (the default for <div>), the chain breaks and
|
|
12
|
+
everything inside collapses to 0px.
|
|
13
|
+
|
|
14
|
+
Fix options:
|
|
15
|
+
1. Use height: 100vh directly on the workspace wrapper:
|
|
16
|
+
<div style={{ height: '100vh', overflow: 'hidden' }}>
|
|
17
|
+
<WindowManager />
|
|
18
|
+
</div>
|
|
19
|
+
|
|
20
|
+
2. Use CSS Grid/Flex and let the workspace fill remaining space:
|
|
21
|
+
.layout { display: flex; flex-direction: column; height: 100vh; }
|
|
22
|
+
.workspace { flex: 1; min-height: 0; }
|
|
23
|
+
|
|
24
|
+
3. Verify styles.css is imported \u2014 it anchors html, body, #root to 100% height.`)}it({width:Math.max(100,u.width),height:Math.max(100,u.height)})});return s.observe(e),()=>{s.disconnect()}},[]),le(()=>{let e=Ke.current;if(!e)return;let l=()=>{let u=ln(e);w(u?"rtl":"ltr")};l();let s=new MutationObserver(l);s.observe(document.documentElement,{attributes:!0,attributeFilter:["dir"]}),s.observe(document.body,{attributes:!0,attributeFilter:["dir"]});let c=e.closest("[dir]");return c&&c!==document.documentElement&&c!==document.body&&s.observe(c,{attributes:!0,attributeFilter:["dir"]}),()=>{s.disconnect()}},[w]),le(()=>{let e=xe.width,l=xe.height;i.floating.forEach(s=>{let c=typeof s.width=="string"?parseFloat(s.width):s.width,u=typeof s.height=="string"?parseFloat(s.height):s.height,h=typeof s.x=="string"?parseFloat(s.x):s.x,y=typeof s.y=="string"?parseFloat(s.y):s.y,m=c,E=u,L=h,C=y,H=!1;m>e&&(m=Math.max(200,e-20),H=!0),E>l&&(E=Math.max(150,l-40),H=!0);let q=10;if(s.stickyRight)L=e-m-q,H=!0;else{let G=e-100;L>G&&(L=Math.max(0,G),H=!0)}if(s.stickyBottom)C=l-E-q,H=!0;else{let G=l-40;C>G&&(C=Math.max(0,G),H=!0)}H&&M(s.id,{x:L,y:C,width:m,height:E})})},[xe,i.floating,M]),le(()=>{let e=l=>{if(l.button!==0)return;let s=l.target;if(!s||typeof s.closest!="function")return;let c=s.closest(".floating-window");if(c){let h=c.getAttribute("data-window-id");h&&(p(h),N(h));return}let u=s.closest(".workspace-panel");if(u){let h=u.getAttribute("data-active-panel-id");h&&p(h)}};return document.addEventListener("pointerdown",e),()=>{document.removeEventListener("pointerdown",e)}},[N,p]);let Nt=(e,l)=>{let s=i.floating.find(C=>C.id===e);if(!s||s.maximized)return;N(e);let c=l.currentTarget,u=c.closest(".floating-window"),h=l.clientX,y=l.clientY,m=u?u.offsetLeft:0,E=u?u.offsetTop:0,L=()=>{let C=ie.current,H=Te.current,q=ze.current;if(q)O(e,q);else if(H){let G=H.index;H.side==="right"&&(G+=1),D(e,H.leafId,G)}else C&&z(e,C.leafId,C.position);_e()};if(l.pointerType==="touch"){let C=l.pointerId,H=!1,q=()=>{H=!0,clearTimeout(ae),c.removeEventListener("pointermove",G),c.removeEventListener("pointerup",q),c.removeEventListener("pointercancel",q)},G=fe=>{Math.hypot(fe.clientX-h,fe.clientY-y)>He&&q()},ae=setTimeout(()=>{if(H)return;c.removeEventListener("pointermove",G),c.removeEventListener("pointerup",q),c.removeEventListener("pointercancel",q);try{c.setPointerCapture(C)}catch{return}c.classList.add("long-press-active"),S(e);let fe=we=>{let yt=we.clientX-h,Pt=we.clientY-y;M(e,{x:m+yt,y:E+Pt,stickyRight:!1,stickyBottom:!1}),tt(we.clientX,we.clientY)},De=()=>{c.classList.remove("long-press-active"),c.removeEventListener("pointermove",fe),c.removeEventListener("pointerup",De),c.removeEventListener("pointercancel",Oe),L()},Oe=()=>{c.classList.remove("long-press-active"),c.removeEventListener("pointermove",fe),c.removeEventListener("pointerup",De),c.removeEventListener("pointercancel",Oe),_e()};c.addEventListener("pointermove",fe),c.addEventListener("pointerup",De),c.addEventListener("pointercancel",Oe)},Be);c.addEventListener("pointermove",G),c.addEventListener("pointerup",q),c.addEventListener("pointercancel",q)}else{let C=!1,H=G=>{let ae=G.clientX-h,fe=G.clientY-y;!C&&(Math.abs(ae)>5||Math.abs(fe)>5)&&(C=!0,S(e)),C&&M(e,{x:m+ae,y:E+fe,stickyRight:!1,stickyBottom:!1})},q=()=>{window.removeEventListener("pointermove",H),window.removeEventListener("pointerup",q),C&&L()};window.addEventListener("pointermove",H),window.addEventListener("pointerup",q)}},Ce=(e,l,s)=>{s.stopPropagation();let c=i.floating.find(Ct=>Ct.id===e);if(!c||c.maximized)return;N(e);let u=s.currentTarget;u.setPointerCapture(s.pointerId);let h=s.clientX,y=s.clientY,m=u.closest(".floating-window"),E=m?m.offsetWidth:400,L=m?m.offsetHeight:300,C=m?m.offsetLeft:0,H=m?m.offsetTop:0,q=xe.width,G=xe.height,ae=typeof c.x=="string"?parseFloat(c.x):c.x,fe=typeof c.y=="string"?parseFloat(c.y):c.y,De=typeof c.width=="string"?parseFloat(c.width):c.width,Oe=typeof c.height=="string"?parseFloat(c.height):c.height,we=l==="se"&&Math.abs(ae+De-q)<4,yt=l==="se"&&Math.abs(fe+Oe-G)<4,Pt=Ct=>{let Jt=Ct.clientX-h,Zt=Ct.clientY-y,rt=C,st=H,je=E,Ue=L;l.includes("e")&&(je=Math.max(200,E+Jt)),l.includes("w")&&(je=Math.max(200,E-Jt),rt=C+E-je),l.includes("s")&&(Ue=Math.max(150,L+Zt)),l.includes("n")&&(Ue=Math.max(150,L-Zt),st=H+L-Ue),we&&(rt=q-je,rt<0&&(rt=0,je=q)),yt&&(st=G-Ue,st<0&&(st=0,Ue=G)),M(e,{x:rt,y:st,width:je,height:Ue,stickyRight:we,stickyBottom:yt})},xt=()=>{u.removeEventListener("pointermove",Pt),u.removeEventListener("pointerup",xt),u.removeEventListener("pointercancel",xt)};u.addEventListener("pointermove",Pt),u.addEventListener("pointerup",xt),u.addEventListener("pointercancel",xt)},bt=e=>{if(Z.current){let l=e==="left"?-150:150;Z.current.scrollBy({left:l,behavior:"smooth"})}},o=_t(()=>{$.current&&clearTimeout($.current),se(!0)},[]),g=_t(()=>{$.current=setTimeout(()=>se(!1),400)},[]);le(()=>{r==="autohide"&&i.minimized.length>Q.current&&($.current&&clearTimeout($.current),se(!0),$.current=setTimeout(()=>se(!1),2e3)),Q.current=i.minimized.length},[i.minimized.length,r]);let[a,d]=ke("dark");return le(()=>{let e=()=>{let s=document.documentElement.getAttribute("data-color-scheme")==="light"?"light":"dark";d(s)};e();let l=new MutationObserver(e);return l.observe(document.documentElement,{attributes:!0,attributeFilter:["data-color-scheme"]}),()=>l.disconnect()},[]),le(()=>(t?document.documentElement.setAttribute("data-workspace-skin",t):document.documentElement.removeAttribute("data-workspace-skin"),()=>{document.documentElement.removeAttribute("data-workspace-skin")}),[t]),U("div",{"data-workspace-skin":t,"data-color-scheme":a,style:{display:"flex",flexDirection:"column",position:"relative",width:"100%",height:"100%",overflow:"hidden",userSelect:"none"},dir:i.dir,children:[U("div",{ref:Ke,className:i.draggedPanelId?"dragging-active":void 0,style:{flexGrow:1,width:"100%",position:"relative",overflow:"hidden"},children:[i.draggedPanelId!==null&&U(vn,{children:[f("div",{"data-edge-trigger":"left",className:"workspace-edge-trigger edge-trigger-left",onPointerEnter:()=>ue("left"),onPointerLeave:()=>ue(null)}),f("div",{"data-edge-trigger":"right",className:"workspace-edge-trigger edge-trigger-right",onPointerEnter:()=>ue("right"),onPointerLeave:()=>ue(null)}),f("div",{"data-edge-trigger":"top",className:"workspace-edge-trigger edge-trigger-top",onPointerEnter:()=>ue("top"),onPointerLeave:()=>ue(null)}),f("div",{"data-edge-trigger":"bottom",className:"workspace-edge-trigger edge-trigger-bottom",onPointerEnter:()=>ue("bottom"),onPointerLeave:()=>ue(null)})]}),i.draggedPanelId!==null&&Ee!==null&&f("div",{className:`workspace-edge-preview edge-preview-${Ee}`}),f("div",{style:{width:"100%",height:"100%",overflow:"hidden",position:"relative"},children:i.gridRoot?f(Cn,{node:i.gridRoot,path:[],onTabRightClick:ot,activeDropZone:oe,onHoverDropZone:ht,onTabDragStart:vt,hoveredTab:ft,onTabHover:mt,defaultPanelIcon:n,onRequestClosePanel:F}):f("div",{className:"empty-workspace-grid",children:"Grid Empty"})}),i.floating.map(e=>{let l=i.panels[e.id];if(!l)return null;let s=e.maximized,c=i.draggedPanelId===e.id,u=i.activePanelId===e.id,y=b.get(l.component)?.defaultOptions;return U("div",{"data-window-id":e.id,dir:i.dir,onPointerDownCapture:()=>{p(e.id),N(e.id)},className:`floating-window ${s?"maximized":""} ${u?"v2-window-focused":""} ${J??""}`,style:{position:"absolute",left:s?0:typeof e.x=="number"?`${e.x}px`:e.x,top:s?0:typeof e.y=="number"?`${e.y}px`:e.y,width:s?"100%":typeof e.width=="number"?`${e.width}px`:e.width,height:s?"100%":typeof e.height=="number"?`${e.height}px`:e.height,zIndex:e.z,pointerEvents:c?"none":"auto"},children:[U("div",{onDoubleClick:()=>R(e.id),onPointerDown:m=>{y?.canDrag!==!1&&Nt(e.id,m)},className:"floating-window-titlebar cursor-move",style:{cursor:s||y?.canDrag===!1?"default":"move"},children:[U("span",{className:"floating-window-title",children:[f("span",{className:"window-title-icon",children:y?.icon||n||Gt}),U("span",{children:[j(l.title,A),l.dirty?" *":""]})]}),U("div",{className:"fw-titlebar-actions",style:{gap:"var(--header-button-gap, 4px)"},onPointerDown:m=>m.stopPropagation(),children:[y?.renderHeaderActions&&f("div",{className:"window-header-actions",children:y.renderHeaderActions(e.id)}),I(e.id).length>0&&f("button",{type:"button",className:"custom-tab-btn btn-more-actions",title:"More actions",onClick:m=>{m.stopPropagation();let E=I(e.id);E.length!==0&&te.current?.show({event:m,contextMenu:{items:E}})},children:U("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"currentColor",style:{display:"block"},children:[f("circle",{cx:"12",cy:"5",r:"2"}),f("circle",{cx:"12",cy:"12",r:"2"}),f("circle",{cx:"12",cy:"19",r:"2"})]})}),y?.canDrag!==!1&&f("button",{type:"button",title:j(W.windowAnchoringOptions,A),onClick:m=>{let E=!!e.stickyRight,L=!!e.stickyBottom;te.current?.show({event:m,contextMenu:{items:[{label:j(W.anchorToRightEdge,A),checkbox:{active:!0,enabled:!0,value:E},action:()=>{let C=xe.width,H=typeof e.width=="string"?parseFloat(e.width):e.width;E?M(e.id,{stickyRight:!1}):M(e.id,{x:C-H-10,stickyRight:!0})}},{label:j(W.anchorToBottomEdge,A),checkbox:{active:!0,enabled:!0,value:L},action:()=>{let C=xe.height,H=typeof e.height=="string"?parseFloat(e.height):e.height;L?M(e.id,{stickyBottom:!1}):M(e.id,{y:C-H-10,stickyBottom:!0})}}]}})},className:"custom-tab-btn btn-anchor-tab",children:U("svg",{className:`anchor-icon ${e.stickyRight&&e.stickyBottom?"anchor-sticky-both":e.stickyRight?"anchor-sticky-right":e.stickyBottom?"anchor-sticky-bottom":""}`,width:"11",height:"11",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:[f("circle",{cx:"12",cy:"5",r:"2"}),f("path",{d:"M12 7v7m0 0a4 4 0 0 1-4-4M12 14a4 4 0 0 0 4-4M5 18h14"})]})}),f("button",{type:"button",title:s?j(W.restoreSize,A):j(W.maximize,A),onClick:()=>R(e.id),className:"custom-tab-btn btn-maximize-tab",children:f("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:f("rect",{x:"4",y:"4",width:"16",height:"16",rx:"1.5"})})}),y?.canMinimize!==!1&&f("button",{type:"button",title:j(W.minimize,A),onClick:()=>k(e.id),className:"custom-tab-btn btn-minimize-tab",children:f("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:f("path",{d:"M5 12h14"})})}),y?.canClose!==!1&&f("button",{type:"button",title:j(W.close,A),onClick:()=>F(e.id),className:"custom-tab-btn btn-close-tab",children:f("svg",{width:"10",height:"10",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"3",children:f("path",{d:"M18 6L6 18M6 6l12 12"})})})]})]}),f("div",{className:x??void 0,style:{flexGrow:1,width:"100%",overflow:"hidden",position:"relative",isolation:"isolate"},children:f(xn,{panelId:e.id},e.id)}),!s&&U(vn,{children:[f("div",{onPointerDown:m=>Ce(e.id,"n",m),className:"resize-handle resize-n"}),f("div",{onPointerDown:m=>Ce(e.id,"ne",m),className:"resize-handle resize-ne"}),f("div",{onPointerDown:m=>Ce(e.id,"e",m),className:"resize-handle resize-e"}),f("div",{onPointerDown:m=>Ce(e.id,"se",m),className:"resize-handle resize-se"}),f("div",{onPointerDown:m=>Ce(e.id,"s",m),className:"resize-handle resize-s"}),f("div",{onPointerDown:m=>Ce(e.id,"sw",m),className:"resize-handle resize-sw"}),f("div",{onPointerDown:m=>Ce(e.id,"w",m),className:"resize-handle resize-w"}),f("div",{onPointerDown:m=>Ce(e.id,"nw",m),className:"resize-handle resize-nw"})]})]},e.id)})]}),(r==="always"||i.minimized.length>0)&&U("div",{className:["taskbar-footer-container",`taskbar-mode-${r}`,r==="autohide"&&ne?"taskbar-expanded":""].filter(Boolean).join(" "),style:{height:"48px",zIndex:100},onPointerEnter:r==="autohide"?o:void 0,onPointerLeave:r==="autohide"?g:void 0,children:[r==="autohide"&&f("div",{className:"taskbar-peek-handle"}),f("button",{type:"button",onClick:()=>bt("left"),className:"taskbar-nav-btn",style:{display:i.minimized.length>4?"block":"none"},children:"\u25C0"}),f("div",{ref:Z,className:"taskbar-items-container",style:{scrollSnapType:"x mandatory"},children:i.minimized.map(e=>{let s=b.get(e.component)?.defaultOptions?.icon||n||Gt;return f("div",{onClick:()=>{ce.current!=="touch"&&(ee(null),P(e.id))},onContextMenu:c=>We(e.id,c),onPointerDown:c=>{if(ce.current=c.pointerType,c.pointerType!=="touch")return;let u=c.currentTarget,h=c.clientX,y=c.clientY,m=c.pointerId,E=!1,L=()=>{E=!0,clearTimeout(q),u.removeEventListener("pointermove",H),u.removeEventListener("pointerup",C),u.removeEventListener("pointercancel",L)},C=()=>{L();let G=u.getBoundingClientRect();Y?.id===e.id?(P(e.id),ee(null)):ee({id:e.id,rect:G,title:e.title,component:e.component,fromTouch:!0})},H=G=>{Math.hypot(G.clientX-h,G.clientY-y)>He&&L()},q=setTimeout(()=>{if(E)return;u.removeEventListener("pointermove",H),u.removeEventListener("pointerup",C),u.removeEventListener("pointercancel",L);try{u.setPointerCapture(m)}catch{return}navigator.vibrate&&navigator.vibrate(10);let G=ae=>{u.removeEventListener("pointerup",G),u.removeEventListener("pointercancel",G),We(e.id,ae)};u.addEventListener("pointerup",G),u.addEventListener("pointercancel",G)},Be);u.addEventListener("pointermove",H),u.addEventListener("pointerup",C),u.addEventListener("pointercancel",L)},onPointerEnter:c=>{if(c.pointerType==="touch"||K)return;re.current&&clearTimeout(re.current);let u=c.currentTarget.getBoundingClientRect();c.clientX>=u.left&&c.clientX<=u.right&&c.clientY>=u.top&&c.clientY<=u.bottom&&ee({id:e.id,rect:u,title:e.title,component:e.component})},onPointerLeave:c=>{c.pointerType!=="touch"&&(re.current=setTimeout(()=>{ee(null)},150))},className:"taskbar-glassmorphic-item",style:{backdropFilter:"blur(6px)",transition:"all 0.2s",cursor:"pointer",scrollSnapAlign:"start",width:"38px",height:"38px",position:"relative",padding:0},children:f("span",{className:"taskbar-item-icon",children:s})},e.id)})}),Y&&hn(U("div",{className:"taskbar-item-tooltip",dir:i.dir,style:{position:"fixed",left:`${Y.rect.left+Y.rect.width/2}px`,top:`${Y.rect.top-8}px`,transform:"translateX(-50%) translateY(-100%)",opacity:1,pointerEvents:"auto",zIndex:999999},onPointerEnter:()=>{re.current&&clearTimeout(re.current)},onPointerLeave:e=>{e.pointerType!=="touch"&&ee(null)},onClick:()=>{P(Y.id),ee(null)},onContextMenu:e=>We(Y.id,e),onPointerDown:e=>{if(e.pointerType!=="touch")return;let l=Y.id,s=e.currentTarget,c=e.clientX,u=e.clientY,h=e.pointerId,y=!1,m=()=>{y=!0,clearTimeout(L),s.removeEventListener("pointermove",E),s.removeEventListener("pointerup",m),s.removeEventListener("pointercancel",m)},E=C=>{Math.hypot(C.clientX-c,C.clientY-u)>He&&m()},L=setTimeout(()=>{if(y)return;s.removeEventListener("pointermove",E),s.removeEventListener("pointerup",m),s.removeEventListener("pointercancel",m);try{s.setPointerCapture(h)}catch{return}navigator.vibrate&&navigator.vibrate(10);let C=H=>{s.removeEventListener("pointerup",C),s.removeEventListener("pointercancel",C),We(l,H)};s.addEventListener("pointerup",C),s.addEventListener("pointercancel",C)},Be);s.addEventListener("pointermove",E),s.addEventListener("pointerup",m),s.addEventListener("pointercancel",m)},children:[U("div",{className:"tooltip-header-row",children:[U("span",{className:"tooltip-title-text text-truncate",style:{maxWidth:"140px"},children:[j(Y.title,A),i.panels[Y.id]?.dirty?" *":""]}),f("span",{onClick:e=>{e.stopPropagation(),F(Y.id),ee(null)},title:j(W.closePanel,A),className:"tooltip-close-x",children:f("svg",{width:"12",height:"12",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:f("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),f(no,{panelId:Y.id})]}),document.body),f("button",{type:"button",onClick:()=>bt("right"),className:"taskbar-nav-btn",style:{display:i.minimized.length>4?"block":"none"},children:"\u25B6"})]}),Object.keys(i.panels).map(e=>{let l=i.panels[e];if(!l)return null;let s=yn(e);return hn(f(oo,{panelId:e,children:f("div",{style:{width:"100%",height:"100%"},children:to(e,l.component,b)})}),s,e)}),f(eo,{ref:te,id:"workspace-context-menu",theme:"dark",onShow:()=>V(!0),onHide:()=>V(!1)}),i.draggedPanelId!==null&&!i.floating.some(e=>e.id===i.draggedPanelId)&&U("div",{className:"drag-ghost-tab",style:{left:ge.x+12,top:ge.y+12,zIndex:1e5},children:["\u{1F4C4} ",j(i.panels[i.draggedPanelId]?.title,A)||"Tab"]})]})},so=ro;var Yt=class{registry;initialState;config;_actions=null;_initialized=!1;_pendingCalls=[];_pendingOpenPanelIds=new Set;_pendingSubscriptions=[];_disconnectedWarnTimer=null;constructor(n={}){if(this.registry=new Je,this.initialState=n.initialState??null,this.config={formatMessage:n.formatMessage,predefinedMessages:n.predefinedMessages,dir:n.dir},n.panels)for(let[r,i]of Object.entries(n.panels))this.registry.register(r,i.component,i.defaultOptions)}_connect(n){this._actions=n,this._disconnectedWarnTimer!==null&&(clearTimeout(this._disconnectedWarnTimer),this._disconnectedWarnTimer=null),this._initialized||(this._initialized=!0);for(let i of this._pendingSubscriptions)i.unsub=n.subscribe(i.event,i.callback);let r=this._pendingCalls.splice(0);for(let i of r)i(n)}_disconnect(){this._actions=null;for(let n of this._pendingSubscriptions)n.unsub?.(),n.unsub=null}get isConnected(){return this._actions!==null}_startWarnTimer(){this._disconnectedWarnTimer===null&&(this._disconnectedWarnTimer=setTimeout(()=>{!this.isConnected&&this._pendingCalls.length>0&&console.error("[react-dockable-desktop] WorkspaceClient has "+this._pendingCalls.length+" queued call(s) but was never connected to a WindowManagerProvider. Did you forget client={workspace} on <WindowManagerProvider>?")},process.env.NODE_ENV==="production"?5e3:1e3))}_dispatch(n){this._actions?n(this._actions):(this._pendingCalls.push(n),this._startWarnTimer())}_subscribeRaw(n,r){if(this._actions)return this._actions.subscribe(n,r);let i={event:n,callback:r,unsub:null};return this._pendingSubscriptions.push(i),()=>{i.unsub?.(),i.unsub=null;let b=this._pendingSubscriptions.indexOf(i);b!==-1&&this._pendingSubscriptions.splice(b,1)}}openPanel(...n){if(this._actions){this._actions.openPanel(...n);return}let r=n[0];this._pendingOpenPanelIds.has(r)||(this._pendingOpenPanelIds.add(r),this._pendingCalls.push(i=>{this._pendingOpenPanelIds.delete(r),i.openPanel(...n)}),this._startWarnTimer())}closePanel(n){this._dispatch(r=>r.closePanel(n))}minimizePanel(n){this._dispatch(r=>r.minimizePanel(n))}restorePanel(n){this._dispatch(r=>r.restorePanel(n))}floatPanel(...n){this._dispatch(r=>r.floatPanel(...n))}dockPanel(...n){this._dispatch(r=>r.dockPanel(...n))}maximizePanel(n){this._dispatch(r=>r.maximizePanel(n))}focusPanel(n){this._dispatch(r=>r.focusPanel(n))}isOpen(n){return this._actions?.isOpen(n)??!1}getOpenPanelIds(){return this._actions?.getOpenPanelIds()??[]}saveLayout(){return this._actions?.saveLayout()??""}loadLayout(n){return this._actions?this._actions.loadLayout(n):(this._pendingCalls.push(r=>{r.loadLayout(n)}),!1)}setDirection(n){this._dispatch(r=>r.setDirection(n))}publish(n,r){this._dispatch(i=>i.publish(n,r))}subscribe(n,r){return this._subscribeRaw(n,r)}onPanelOpen(n){return this._subscribeRaw("panel:opened",r=>{let i=r;n(i.id,i.component)})}onPanelClose(n){return this._subscribeRaw("panel:closed",r=>{n(r.id)})}onPanelMinimize(n){return this._subscribeRaw("panel:minimized",r=>{n(r.id)})}onPanelRestore(n){return this._subscribeRaw("panel:restored",r=>{n(r.id)})}};import"react";import{createContext as ao,useContext as lo,useMemo as co,useState as wn}from"react";import{jsx as uo}from"react/jsx-runtime";var Rn=ao(null),St=({children:t})=>{let[n,r]=wn({}),[i,b]=wn({}),P=co(()=>({getActiveInGroup:k=>n[k]??null,setActiveInGroup:(k,T)=>r(R=>({...R,[k]:T})),isModifierActive:k=>i[k]??!1,setModifierActive:(k,T)=>b(R=>({...R,[k]:T})),toggleModifier:k=>b(T=>({...T,[k]:!T[k]}))}),[n,i]);return uo(Rn.Provider,{value:P,children:t})};function Et(){let t=lo(Rn);return t||(console.warn("useToolbar() called outside <DockableDesktopProvider>. Returning no-op."),{getActiveInGroup:()=>null,setActiveInGroup:()=>{},isModifierActive:()=>!1,setModifierActive:()=>{},toggleModifier:()=>{}})}import{jsx as Xt}from"react/jsx-runtime";var po=t=>Xt(St,{children:Xt(Ot,{...t,children:Xt(Bt,{children:t.children})})});import{useCallback as gt,useRef as Mn,useEffect as go,useState as fo,useMemo as mo}from"react";import{Fragment as yo,jsx as Pe,jsxs as Vt}from"react/jsx-runtime";var ho=({modal:t,index:n,isTopmost:r})=>{let{close:i,openModal:b,updateInstance:P,setDirty:k}=Xe(),T=be(),R=Me(),{dir:M}=Re(),{modalClass:N,modalBodyClass:v}=Fe(),S=Mn(null),{id:z,Component:D,props:O,options:p,dirty:w,dirtyOptions:I}=t,_=p,[A,W]=fo(_.icon||null),F=Mn(_);F.current=_;let J=j(_.title,T),x=gt(async K=>{if(K?.force){i(z);return}if(S.current){if(!await S.current())return;i(z);return}if(w){b(qe,{title:I?.title||R.unsavedChangesTitle,message:I?.message||{id:R.unsavedChangesMessage.id,defaultMessage:R.unsavedChangesMessage.defaultMessage,values:{title:J}},alert:I?.alert,alertType:I?.alertType||"danger",useYesNoTitles:!0,onOK:()=>i(z)},{size:"small"});return}i(z)},[i,b,z,w,I,J,R]),Z=gt((K,V)=>k(z,K,V),[k,z]),te=gt(K=>P(z,{options:{...F.current,title:K}}),[P,z]),ne=gt(K=>W(K),[]),se=gt(K=>(S.current=K,()=>{S.current=null}),[]),$=mo(()=>({requestClose:x,setDirty:Z,setTitle:te,setIcon:ne,onCloseRequested:se,containerType:"modal",instanceId:z}),[x,Z,te,ne,se,z]),Q=w?`${J} *`:J,Y=_.size?`v2-modal-size-${_.size}`:"v2-modal-size-auto",ee=_.closable!==!1;go(()=>{if(!r||!ee)return;let K=V=>{V.key==="Escape"&&(V.stopPropagation(),x())};return document.addEventListener("keydown",K),()=>document.removeEventListener("keydown",K)},[x,ee,r]);let ce=1e4+n*10;return Vt("div",{className:"v2-modal-overlay",style:{zIndex:ce},dir:M,children:[Pe("div",{className:"v2-modal-curtain",onClick:ee?()=>x():void 0}),Vt("div",{className:`v2-modal-window ${Y} ${N??""}`,children:[Vt("div",{className:"v2-modal-header",children:[A&&Pe("div",{className:"v2-modal-icon",children:A}),Pe("h4",{className:"v2-modal-title",children:Q}),ee&&Pe("button",{className:"v2-modal-close-button",onClick:()=>x(),title:T(R.closeTooltip),type:"button",children:Pe("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:Pe("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),Pe("div",{className:`v2-modal-body ${v??""}`,children:Pe(Ge,{value:$,children:Pe(D,{...O,panelId:z})})})]})]})},vo=()=>{let{modals:t}=Ae();return t.length===0?null:Pe(yo,{children:t.map((n,r)=>Pe(ho,{modal:n,index:r,isTopmost:r===t.length-1},n.id))})},bo=vo;import{useCallback as et,useRef as kn,useEffect as Tn,useState as Po,useMemo as xo}from"react";import{Fragment as ko,jsx as me,jsxs as qt}from"react/jsx-runtime";var Lt=({panel:t,position:n,defaultWidth:r})=>{let{close:i,openModal:b,updateInstance:P,setDirty:k,registerCloseHandler:T,unregisterCloseHandler:R}=Xe(),{modals:M}=Ae(),N=be(),v=Me(),{dir:S}=Re(),{sidePanelClass:z,sidePanelBodyClass:D}=Fe(),O=kn(null),{id:p,Component:w,props:I,options:_,dirty:A,dirtyOptions:W}=t,F=_,[J,x]=Po(F.icon||null),Z=kn(F);Z.current=F;let te=j(F.title,N),ne=et(async oe=>{if(oe?.force){i(p);return}if(O.current){if(!await O.current())return;i(p);return}if(A){b(qe,{title:W?.title||v.unsavedChangesTitle,message:W?.message||{id:v.unsavedChangesMessage.id,defaultMessage:v.unsavedChangesMessage.defaultMessage,values:{title:te}},alert:W?.alert,alertType:W?.alertType||"danger",useYesNoTitles:!0,onOK:()=>i(p)},{size:"small"});return}i(p)},[i,b,p,A,W,te,v]),se=et(async()=>O.current?await O.current():!A,[A]);Tn(()=>(T(p,se),()=>R(p)),[p,se,T,R]);let $=et((oe,B)=>k(p,oe,B),[k,p]),Q=et(oe=>P(p,{options:{...Z.current,title:oe}}),[P,p]),Y=et(oe=>x(oe),[]),ee=et(oe=>(O.current=oe,()=>{O.current=null}),[]),re=xo(()=>({requestClose:ne,setDirty:$,setTitle:Q,setIcon:Y,onCloseRequested:ee,containerType:n==="left"?"left-panel":"right-panel",instanceId:p}),[ne,$,Q,Y,ee,n,p]),ce=A?`${te} *`:te;Tn(()=>{let oe=B=>{B.key==="Escape"&&M.length===0&&ne()};return document.addEventListener("keydown",oe),()=>document.removeEventListener("keydown",oe)},[ne,M.length]);let K=F.width||r||400,V=typeof K=="number"?`${K}px`:K;return me("div",{className:`v2-side-panel v2-side-panel-${n} v2-side-panel-visible ${z??""}`,style:{width:V},dir:S,children:qt("div",{className:"v2-side-panel-window",children:[qt("div",{className:"v2-side-panel-header",children:[J&&me("div",{className:"v2-side-panel-icon",children:J}),me("h4",{className:"v2-side-panel-title",children:ce}),me("button",{className:"v2-side-panel-close-button",onClick:()=>ne(),title:N(v.closeTooltip),type:"button",children:me("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",children:me("path",{d:"M18 6L6 18M6 6l12 12"})})})]}),me("div",{className:`v2-side-panel-body ${D??""}`,children:me(Ge,{value:re,children:me(w,{...I,panelId:p})})})]})})},Co=({defaultWidth:t})=>{let{leftPanel:n,rightPanel:r}=Ae();return qt(ko,{children:[n&&me(Lt,{panel:n,position:"left",defaultWidth:t},n.id),r&&me(Lt,{panel:r,position:"right",defaultWidth:t},r.id)]})},wo=({defaultWidth:t})=>{let{leftPanel:n}=Ae();return n?me(Lt,{panel:n,position:"left",defaultWidth:t},n.id):null},Ro=({defaultWidth:t})=>{let{rightPanel:n}=Ae();return n?me(Lt,{panel:n,position:"right",defaultWidth:t},n.id):null},Mo=Co;import{useState as Kt,useEffect as In,useRef as jt,useCallback as zt,useImperativeHandle as To,useContext as Ln,useMemo as Ut,createContext as zn,forwardRef as Io,memo as So}from"react";import{jsx as de,jsxs as En}from"react/jsx-runtime";var Nn=zn(null),Wn=zn(null);function Eo({tabId:t,onClose:n,onOpen:r,setActiveTabId:i,children:b}){let P=Ut(()=>({tabId:t,onClose:n,onOpen:r,openTab:k=>i(k)}),[t,n,r,i]);return de(Wn.Provider,{value:P,children:b})}var Sn=So(function({tabs:n,activeTabId:r,isVisible:i,position:b,onTabClick:P}){return de("div",{style:{width:i?"56px":"0px",height:"100%",overflow:"hidden",transition:"width 0.25s cubic-bezier(0.4, 0, 0.2, 1)",flexShrink:0},children:de("div",{className:`sidebar-tabs-strip ${b}`,style:{width:"56px",height:"100%"},children:n.map(k=>{let T=r===k.id;return de("button",{type:"button",onClick:()=>P(k.id),className:`sidebar-tab-btn${T?" active":""}`,title:k.label,"aria-pressed":T,children:k.icon},k.id)})})})});function Lo({position:t,currentWidth:n,minWidth:r,maxWidth:i,onWidthChange:b,rootRef:P}){return de("div",{className:"resizer-bar",style:{cursor:"col-resize",width:"1px",height:"100%",flexShrink:0,zIndex:20},onPointerDown:T=>{T.preventDefault();let R=T.currentTarget;R.setPointerCapture(T.pointerId);let M=T.clientX,N=n;R.classList.add("active"),document.body.classList.add("resizing-active","resizing-col-active"),P.current?.classList.add("sidebar-resizing");let v=z=>{let D=z.clientX-M,O=t==="right"?N-D:N+D;b(Math.max(r,Math.min(i,O)))},S=()=>{R.classList.remove("active"),document.body.classList.remove("resizing-active","resizing-col-active"),P.current?.classList.remove("sidebar-resizing"),R.removeEventListener("pointermove",v),R.removeEventListener("pointerup",S),R.removeEventListener("pointercancel",S)};R.addEventListener("pointermove",v),R.addEventListener("pointerup",S),R.addEventListener("pointercancel",S)}})}var zo=Io(function({position:n="right",tabs:r,defaultWidth:i,minWidth:b=150,maxWidth:P=600,onWidthChange:k,drawerWidth:T,activeTabId:R,onActiveTabChange:M,visible:N,onVisibilityChange:v,stripVisible:S,onStripVisibilityChange:z,children:D},O){let p=R!==void 0,[w,I]=Kt(()=>i!==void 0?i:T!==void 0&&parseInt(T,10)||220),_=zt(B=>{I(B),k?.(B)},[k]),[A,W]=Kt(null),F=p?R:A,[J,x]=Kt(()=>new Set),Z=Ut(()=>{let B=new Set(J);F&&B.add(F);for(let ie of r)ie.eagerMount&&B.add(ie.id);return B},[J,F,r]),te=jt(F??null);In(()=>{te.current=F??null},[F]);let ne=jt(w);In(()=>{ne.current=w},[w]);let se=jt(null),$=zt(B=>{x(B!==null?ie=>{if(ie.has(B))return ie;let ge=new Set(ie);return ge.add(B),ge}:ie=>{let ge=!1,ve=new Set(ie);for(let Ee of ie){let Le=r.find(ze=>ze.id===Ee);Le&&!Le.eagerMount&&!Le.preserveState&&(ve.delete(Ee),ge=!0)}return ge?ve:ie}),p||W(B),M?.(B)},[p,M,r]);To(O,()=>({openTab:B=>$(B),closeDrawer:()=>$(null),getActiveTab:()=>te.current,show:()=>v?.(!0),hide:()=>v?.(!1),toggle:()=>v?.(N===!1),showStrip:()=>z?.(!0),hideStrip:()=>z?.(!1),setWidth:B=>_(Math.max(b,Math.min(P,B))),getWidth:()=>ne.current}),[$,N,v,z,_,b,P]);let Q=zt(B=>{$(F===B?null:B)},[F,$]),Y=zt(()=>$(null),[$]),ee=Ut(()=>({openTab:B=>$(B),closeDrawer:()=>$(null),getActiveTab:()=>te.current}),[$]),re=N!==!1,ce=re&&S!==!1,K=re&&F!=null,V=de("div",{className:`sidebar-content-drawer ${n}`,style:{flexBasis:K?`${w}px`:"0px",flexShrink:1,flexGrow:0,minWidth:K?`${b}px`:"0px",maxWidth:K?`${P}px`:"0px",overflow:"hidden",transition:"flex-basis 0.2s cubic-bezier(0.4, 0, 0.2, 1), min-width 0.2s cubic-bezier(0.4, 0, 0.2, 1), max-width 0.2s cubic-bezier(0.4, 0, 0.2, 1)"},children:r.map(B=>{if(!Z.has(B.id))return null;let ge=F===B.id,ve=()=>$(B.id);return En("div",{style:{display:ge?"flex":"none",flexDirection:"column",height:"100%",width:"100%"},children:[de("div",{className:"sidebar-drawer-header",children:de("span",{className:"sidebar-header-title",children:B.label})}),de("div",{className:"sidebar-drawer-body",children:de(Eo,{tabId:B.id,onClose:Y,onOpen:ve,setActiveTabId:$,children:B.renderContent(B.id,Y,ve)})})]},B.id)})}),oe=K?de(Lo,{position:n,currentWidth:w,minWidth:b,maxWidth:P,onWidthChange:_,rootRef:se}):null;return de(Nn.Provider,{value:ee,children:En("div",{ref:se,style:{display:"flex",flexDirection:"row",width:"100%",height:"100%",overflow:"hidden"},children:[n==="left"&&de(Sn,{tabs:r,activeTabId:F,isVisible:ce,position:n,onTabClick:Q}),n==="left"&&V,n==="left"&&oe,de("div",{style:{flex:"1 1 auto",minWidth:0,overflow:"hidden"},children:D}),n==="right"&&oe,n==="right"&&V,n==="right"&&de(Sn,{tabs:r,activeTabId:F,isVisible:ce,position:n,onTabClick:Q})]})})});function No(){let t=Ln(Nn);return t||(console.warn("useSidebar() called outside a <Sidebar> tree. Returning no-op."),{openTab:()=>{},closeDrawer:()=>{},getActiveTab:()=>null})}function Wo(){let t=Ln(Wn);return t||(console.warn("useSidebarTab() called outside a <Sidebar> tab renderContent tree. Returning no-op."),{tabId:"",onOpen:()=>{},onClose:()=>{},openTab:()=>{}})}import{forwardRef as Do,useImperativeHandle as Oo,useState as Dn,useRef as On,useEffect as Fn}from"react";import{createPortal as Fo}from"react-dom";import{Fragment as Go,jsx as he,jsxs as An}from"react/jsx-runtime";function Ao(t,n,r=8){switch(n){case"left":return{left:t.right+r,top:t.top};case"right":return{right:window.innerWidth-t.left+r,top:t.top};case"top":return{top:t.bottom+r,left:t.left};case"bottom":return{bottom:window.innerHeight-t.top+r,left:t.left}}}function Bo({item:t,position:n,toolbar:r}){let[i,b]=Dn(!1),[P,k]=Dn(null),T=On(null),R=On(null),M=t.activeItemId!==void 0,N=M?t.activeItemId:r.getActiveInGroup(t.id),v=t.items.find(p=>!("type"in p)&&p.id===N),S=N!==null,z=v?.icon??t.defaultIcon,D=v?.label??t.label,O=()=>{t.disabled||(!i&&T.current&&k(T.current.getBoundingClientRect()),b(p=>!p))};return Fn(()=>{if(!i)return;let p=w=>{let I=w.target;T.current?.contains(I)||R.current?.contains(I)||b(!1)};return document.addEventListener("mousedown",p),()=>document.removeEventListener("mousedown",p)},[i]),Fn(()=>{if(!i)return;let p=w=>{w.key==="Escape"&&b(!1)};return document.addEventListener("keydown",p),()=>document.removeEventListener("keydown",p)},[i]),An(Go,{children:[he("button",{ref:T,type:"button",className:`toolbar-btn toolbar-btn-group${S?" active":""}`,title:D,"aria-label":D,"aria-expanded":i,"aria-haspopup":"menu",disabled:t.disabled,onClick:O,children:z}),i&&P&&Fo(he("div",{ref:R,className:`toolbar-group-flyout ${n}`,style:Ao(P,n),role:"menu",children:t.items.map((p,w)=>{if("type"in p)return he("div",{className:"toolbar-group-flyout-sep",role:"separator"},`sep-${w}`);let I=N===p.id;return An("button",{type:"button",className:`toolbar-group-flyout-item${I?" active":""}`,disabled:p.disabled,role:"menuitem","aria-pressed":I,onClick:()=>{M?t.onActiveItemChange?.(p.id):r.setActiveInGroup(t.id,p.id),p.onActivate?.(p.id),b(!1)},children:[he("span",{className:"toolbar-group-flyout-icon",children:p.icon}),he("span",{className:"toolbar-group-flyout-label",children:p.label}),p.shortcut&&he("span",{className:"toolbar-group-flyout-shortcut",children:p.shortcut})]},p.id)})}),document.body)]})}function Ho(t,n,r,i){switch(t.type){case"separator":return he("div",{className:"toolbar-separator",role:"separator"},`sep-${n}`);case"action":return he("button",{type:"button",className:"toolbar-btn toolbar-btn-action",title:t.label,"aria-label":t.label,disabled:t.disabled,onClick:t.onClick,children:t.icon},t.id);case"radio":{let b=r.getActiveInGroup(t.group)===t.id;return he("button",{type:"button",className:`toolbar-btn toolbar-btn-radio${b?" active":""}`,title:t.label,"aria-label":t.label,"aria-pressed":b,disabled:t.disabled,onClick:()=>{r.setActiveInGroup(t.group,t.id),t.onActivate?.(t.id)},children:t.icon},t.id)}case"toggle":{let b=r.isModifierActive(t.id);return he("button",{type:"button",className:`toolbar-btn toolbar-btn-toggle${b?" active":""}`,title:t.label,"aria-label":t.label,"aria-pressed":b,disabled:t.disabled,onClick:()=>{r.toggleModifier(t.id),t.onToggle?.(!b)},children:t.icon},t.id)}case"group":return he(Bo,{item:t,position:i,toolbar:r},t.id)}}var _o=Do(function({position:n="left",items:r,visible:i,onVisibilityChange:b,className:P,style:k},T){let R=Et(),M=n==="left"||n==="right";Oo(T,()=>({show:()=>b?.(!0),hide:()=>b?.(!1),toggle:()=>b?.(i===!1)}),[i,b]);let N=i!==!1?{}:M?{width:"0px"}:{height:"0px"};return he("div",{className:`toolbar-strip ${n}${P?` ${P}`:""}`,role:"toolbar","aria-orientation":M?"vertical":"horizontal",style:{...N,...k},children:r.map((v,S)=>Ho(v,S,R,n))})});export{qe as ConfirmationForm,po as DockableDesktopProvider,Wt as FormContainerContext,Ge as FormContainerProvider,wo as LeftPanelRenderer,bo as ModalStackRenderer,Bt as PanelProvider,wt as PanelRegistry,Je as PanelRegistryClass,Ro as RightPanelRenderer,Mo as SidePanelRenderer,zo as Sidebar,_o as Toolbar,St as ToolbarProvider,so as WindowManager,Ot as WindowManagerProvider,Yt as WorkspaceClient,lt as defaultPredefinedMessages,j as formatLabel,at as useFormContainer,be as useFormatMessage,Xe as usePanelActions,Vn as usePanelContext,qn as usePanelContextMenu,an as usePanelId,Ae as usePanelState,Me as usePredefinedMessages,ct as useRegistry,No as useSidebar,Wo as useSidebarTab,Fe as useStyleClasses,Et as useToolbar,ut as useWindowManagerActions,Re as useWindowManagerState};
|
|
4
25
|
//# sourceMappingURL=index.js.map
|