dockview 6.2.1 → 6.3.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.
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * dockview
3
- * @version 6.2.1
3
+ * @version 6.3.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
7
- "use strict";var e=require("dockview-core"),t=require("react"),n=require("react-dom");const r=(e,n)=>{const[,r]=t.useState(0),o=t.useRef(e.componentProps);return t.useImperativeHandle(n,()=>({update:e=>{o.current=Object.assign(Object.assign({},o.current),e),r(e=>e+1)}}),[]),t.createElement(e.component,o.current)};r.displayName="DockviewReactJsBridge";const o=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),a=t.createContext({});class i{constructor(e,t,n,r,o){this.parent=e,this.portalStore=t,this.component=n,this.parameters=r,this.context=o,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!c(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=t.createElement(t.forwardRef(r),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),i=this.context?t.createElement(a.Provider,{value:this.context},e):e,s=n.createPortal(i,this.parent,o.next());this.ref={portal:s,disposable:this.portalStore.addPortal(s)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const s=()=>{const[n,r]=t.useState([]);t.useDebugValue(`Portal count: ${n.length}`);return[n,t.useCallback(t=>{r(e=>[...e,t]);let n=!1;return e.DockviewDisposable.from(()=>{if(n)throw new Error("invalid operation: resource already disposed");n=!0,r(e=>e.filter(e=>e!==t))})},[])]};function c(e){return"function"==typeof e||!!(null==e?void 0:e.$$typeof)}class p{get element(){return this._element}constructor(t,n,r){this.id=t,this.component=n,this.reactPortalStore=r,this._onDidFocus=new e.DockviewEmitter,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new e.DockviewEmitter,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new i(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class l{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new i(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;null===(t=this.part)||void 0===t||t.update({params:e.params})}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class u{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new i(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,n,r;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:null!==(r=null===(n=this.parameters)||void 0===n?void 0:n.params)&&void 0!==r?r:{}})}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class d{get element(){return this._element}get part(){return this._part}constructor(t,n,r){this.component=t,this.reactPortalStore=n,this._group=r,this.mutableDisposable=new e.DockviewMutableDisposable,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(t){this.mutableDisposable.value=new e.DockviewCompositeDisposable(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),t.api.onDidActiveChange(()=>{this.updateGroupActive()}),t.api.onDidLocationChange(e=>{this.updateLocation(e.location)})),this._part=new i(this.element,this.reactPortalStore,this.component,{api:t.api,containerApi:t.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:t.api.location})}dispose(){var e;this.mutableDisposable.dispose(),null===(e=this._part)||void 0===e||e.dispose()}update(e){var t;null===(t=this._part)||void 0===t||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}}class m{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new i(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class h{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new i(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;null===(t=this.part)||void 0===t||t.update({tabGroup:e.tabGroup})}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}function f(e,t){return e?n=>new d(e,t,n):void 0}const v="props.defaultTabComponent";const P=t.forwardRef((n,r)=>{const o=t.useRef(null),a=t.useRef(void 0),[i,c]=s();t.useImperativeHandle(r,()=>o.current,[]);const d=t.useRef({});return t.useEffect(()=>{const t={};e.PROPERTY_KEYS_DOCKVIEW.forEach(e=>{const r=e,o=n[r];r in n&&o!==d.current[r]&&(t[r]=o)}),a.current&&a.current.updateOptions(t),d.current=n},e.PROPERTY_KEYS_DOCKVIEW.map(e=>n[e])),t.useEffect(()=>{var t;if(!o.current)return;const r=null!==(t=n.tabComponents)&&void 0!==t?t:{};n.defaultTabComponent&&(r[v]=n.defaultTabComponent);const i={createLeftHeaderActionComponent:f(n.leftHeaderActionsComponent,{addPortal:c}),createRightHeaderActionComponent:f(n.rightHeaderActionsComponent,{addPortal:c}),createPrefixHeaderActionComponent:f(n.prefixHeaderActionsComponent,{addPortal:c}),createComponent:e=>new p(e.id,n.components[e.name],{addPortal:c}),createTabComponent:e=>new l(e.id,r[e.name],{addPortal:c}),createWatermarkComponent:n.watermarkComponent?()=>new u("watermark",n.watermarkComponent,{addPortal:c}):void 0,defaultTabComponent:n.defaultTabComponent?v:void 0,createContextMenuItemComponent:e=>{if(e.component)return new m(e.id,e.component,{addPortal:c})}},s=function(t){return e.PROPERTY_KEYS_DOCKVIEW.reduce((e,n)=>(n in t&&(e[n]=t[n]),e),{})}(n);if(n.tabGroupChipComponent){const e=n.tabGroupChipComponent;s.createTabGroupChipComponent=()=>new h(e,{addPortal:c})}const d=e.createDockview(o.current,Object.assign(Object.assign({},s),i)),{clientWidth:P,clientHeight:w}=o.current;return d.layout(P,w),n.onReady&&n.onReady({api:d}),a.current=d,()=>{a.current=void 0,d.dispose()}},[]),t.useEffect(()=>{if(!a.current)return()=>{};const e=a.current.onDidDrop(e=>{n.onDidDrop&&n.onDidDrop(e)});return()=>{e.dispose()}},[n.onDidDrop]),t.useEffect(()=>{if(!a.current)return()=>{};const e=a.current.onWillDrop(e=>{n.onWillDrop&&n.onWillDrop(e)});return()=>{e.dispose()}},[n.onWillDrop]),t.useEffect(()=>{a.current&&a.current.updateOptions({createTabGroupChipComponent:n.tabGroupChipComponent?()=>new h(n.tabGroupChipComponent,{addPortal:c}):void 0})},[n.tabGroupChipComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createComponent:e=>new p(e.id,n.components[e.name],{addPortal:c})})},[n.components]),t.useEffect(()=>{var e;if(!a.current)return;const t=null!==(e=n.tabComponents)&&void 0!==e?e:{};n.defaultTabComponent&&(t[v]=n.defaultTabComponent),a.current.updateOptions({defaultTabComponent:n.defaultTabComponent?v:void 0,createTabComponent:e=>new l(e.id,t[e.name],{addPortal:c})})},[n.tabComponents,n.defaultTabComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createWatermarkComponent:n.watermarkComponent?()=>new u("watermark",n.watermarkComponent,{addPortal:c}):void 0})},[n.watermarkComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createRightHeaderActionComponent:f(n.rightHeaderActionsComponent,{addPortal:c})})},[n.rightHeaderActionsComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createLeftHeaderActionComponent:f(n.leftHeaderActionsComponent,{addPortal:c})})},[n.leftHeaderActionsComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createPrefixHeaderActionComponent:f(n.prefixHeaderActionsComponent,{addPortal:c})})},[n.prefixHeaderActionsComponent]),t.createElement("div",{style:{height:"100%",width:"100%"},ref:o},i)});P.displayName="DockviewComponent","function"==typeof SuppressedError&&SuppressedError;const w=()=>t.createElement("svg",{height:"11",width:"11",viewBox:"0 0 28 28","aria-hidden":"false",focusable:!1,className:"dv-svg"},t.createElement("path",{d:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}));class C extends e.SplitviewPanel{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){var t,n;return new i(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(n=null===(t=this._params)||void 0===t?void 0:t.params)&&void 0!==n?n:{},api:this.api,containerApi:new e.SplitviewApi(this._params.accessor)})}}const E=t.forwardRef((n,r)=>{const o=t.useRef(null),a=t.useRef(void 0),[i,c]=s();t.useImperativeHandle(r,()=>o.current,[]);const p=t.useRef({});return t.useEffect(()=>{const t={};e.PROPERTY_KEYS_SPLITVIEW.forEach(e=>{const r=e,o=n[r];r in n&&o!==p.current[r]&&(t[r]=o)}),a.current&&a.current.updateOptions(t),p.current=n},e.PROPERTY_KEYS_SPLITVIEW.map(e=>n[e])),t.useEffect(()=>{if(!o.current)return()=>{};const t={createComponent:e=>new C(e.id,e.name,n.components[e.name],{addPortal:c})},r=e.createSplitview(o.current,Object.assign(Object.assign({},function(t){return e.PROPERTY_KEYS_SPLITVIEW.reduce((e,n)=>(n in t&&(e[n]=t[n]),e),{})}(n)),t)),{clientWidth:i,clientHeight:s}=o.current;return r.layout(i,s),n.onReady&&n.onReady({api:r}),a.current=r,()=>{a.current=void 0,r.dispose()}},[]),t.useEffect(()=>{a.current&&a.current.updateOptions({createComponent:e=>new C(e.id,e.name,n.components[e.name],{addPortal:c})})},[n.components]),t.createElement("div",{style:{height:"100%",width:"100%"},ref:o},i)});E.displayName="SplitviewComponent";class _ extends e.GridviewPanel{constructor(e,t,n,r){super(e,t),this.reactComponent=n,this.reactPortalStore=r}getComponent(){var t,n;return new i(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(n=null===(t=this._params)||void 0===t?void 0:t.params)&&void 0!==n?n:{},api:this.api,containerApi:new e.GridviewApi(this._params.accessor)})}}const b=t.forwardRef((n,r)=>{const o=t.useRef(null),a=t.useRef(void 0),[i,c]=s();t.useImperativeHandle(r,()=>o.current,[]);const p=t.useRef({});return t.useEffect(()=>{const t={};e.PROPERTY_KEYS_GRIDVIEW.forEach(e=>{const r=e,o=n[r];r in n&&o!==p.current[r]&&(t[r]=o)}),a.current&&a.current.updateOptions(t),p.current=n},e.PROPERTY_KEYS_GRIDVIEW.map(e=>n[e])),t.useEffect(()=>{if(!o.current)return()=>{};const t={createComponent:e=>new _(e.id,e.name,n.components[e.name],{addPortal:c})},r=e.createGridview(o.current,Object.assign(Object.assign({},function(t){return e.PROPERTY_KEYS_GRIDVIEW.reduce((e,n)=>(n in t&&(e[n]=t[n]),e),{})}(n)),t)),{clientWidth:i,clientHeight:s}=o.current;return r.layout(i,s),n.onReady&&n.onReady({api:r}),a.current=r,()=>{a.current=void 0,r.dispose()}},[]),t.useEffect(()=>{a.current&&a.current.updateOptions({createComponent:e=>new _(e.id,e.name,n.components[e.name],{addPortal:c})})},[n.components]),t.createElement("div",{style:{height:"100%",width:"100%"},ref:o},i)});b.displayName="GridviewComponent";class g{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new i(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const R=t.forwardRef((n,r)=>{const o=t.useRef(null),a=t.useRef(void 0),[i,c]=s();t.useImperativeHandle(r,()=>o.current,[]);const p=t.useRef({});return t.useEffect(()=>{const t={};e.PROPERTY_KEYS_PANEVIEW.forEach(e=>{const r=e,o=n[r];r in n&&o!==p.current[r]&&(t[r]=o)}),a.current&&a.current.updateOptions(t),p.current=n},e.PROPERTY_KEYS_PANEVIEW.map(e=>n[e])),t.useEffect(()=>{var t;if(!o.current)return()=>{};const r=null!==(t=n.headerComponents)&&void 0!==t?t:{},i={createComponent:e=>new g(e.id,n.components[e.name],{addPortal:c}),createHeaderComponent:e=>new g(e.id,r[e.name],{addPortal:c})},s=e.createPaneview(o.current,Object.assign(Object.assign({},function(t){return e.PROPERTY_KEYS_PANEVIEW.reduce((e,n)=>(n in t&&(e[n]=t[n]),e),{})}(n)),i)),{clientWidth:p,clientHeight:l}=o.current;return s.layout(p,l),n.onReady&&n.onReady({api:s}),a.current=s,()=>{a.current=void 0,s.dispose()}},[]),t.useEffect(()=>{a.current&&a.current.updateOptions({createComponent:e=>new g(e.id,n.components[e.name],{addPortal:c})})},[n.components]),t.useEffect(()=>{var e;if(!a.current)return;const t=null!==(e=n.headerComponents)&&void 0!==e?e:{};a.current.updateOptions({createHeaderComponent:e=>new g(e.id,t[e.name],{addPortal:c})})},[n.headerComponents]),t.useEffect(()=>{if(!a.current)return()=>{};const e=a.current.onDidDrop(e=>{n.onDidDrop&&n.onDidDrop(e)});return()=>{e.dispose()}},[n.onDidDrop]),t.createElement("div",{style:{height:"100%",width:"100%"},ref:o},i)});R.displayName="PaneviewComponent",exports.DockviewDefaultTab=e=>{var{api:n,containerApi:r,params:o,hideClose:a,closeActionOverride:i,onPointerDown:s,onPointerUp:c,onPointerLeave:p,tabLocation:l}=e,u=function(e,t){var n={};for(var r in e)Object.prototype.hasOwnProperty.call(e,r)&&t.indexOf(r)<0&&(n[r]=e[r]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var o=0;for(r=Object.getOwnPropertySymbols(e);o<r.length;o++)t.indexOf(r[o])<0&&Object.prototype.propertyIsEnumerable.call(e,r[o])&&(n[r[o]]=e[r[o]])}return n}(e,["api","containerApi","params","hideClose","closeActionOverride","onPointerDown","onPointerUp","onPointerLeave","tabLocation"]);const d=function(e){const[n,r]=t.useState(e.title);return t.useEffect(()=>{const t=e.onDidTitleChange(e=>{r(e.title)});return n!==e.title&&r(e.title),()=>{t.dispose()}},[e]),n}(n),m=t.useRef(!1),h=t.useCallback(e=>{e.preventDefault(),i?i():n.close()},[n,i]),f=t.useCallback(e=>{e.preventDefault()},[]),v=t.useCallback(e=>{m.current=1===e.button,null==s||s(e)},[s]),P=t.useCallback(e=>{m&&1===e.button&&!a&&(m.current=!1,h(e)),null==c||c(e)},[c,h,a]),C=t.useCallback(e=>{m.current=!1,null==p||p(e)},[p]);return t.createElement("div",Object.assign({"data-testid":"dockview-dv-default-tab"},u,{onPointerDown:v,onPointerUp:P,onPointerLeave:C,className:"dv-default-tab"}),t.createElement("span",{className:"dv-default-tab-content"},d),!a&&t.createElement("div",{className:"dv-default-tab-action",onPointerDown:f,onClick:h},t.createElement(w,null)))},exports.DockviewReact=P,exports.GridviewReact=b,exports.PaneviewReact=R,exports.ReactPart=i,exports.ReactPartContext=a,exports.SplitviewReact=E,exports.isReactComponent=c,exports.usePortalsLifecycle=s,Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
7
+ "use strict";var e=require("dockview-core"),t=require("react"),n=require("react-dom");const o=(e,n)=>{const[,o]=t.useState(0),r=t.useRef(e.componentProps);return t.useImperativeHandle(n,()=>({update:e=>{r.current=Object.assign(Object.assign({},r.current),e),o(e=>e+1)}}),[]),t.createElement(e.component,r.current)};o.displayName="DockviewReactJsBridge";const r=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),a=t.createContext({});class i{constructor(e,t,n,o,r){this.parent=e,this.portalStore=t,this.component=n,this.parameters=o,this.context=r,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!c(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=t.createElement(t.forwardRef(o),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),i=this.context?t.createElement(a.Provider,{value:this.context},e):e,s=n.createPortal(i,this.parent,r.next());this.ref={portal:s,disposable:this.portalStore.addPortal(s)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const s=()=>{const[n,o]=t.useState([]);t.useDebugValue(`Portal count: ${n.length}`);return[n,t.useCallback(t=>{o(e=>[...e,t]);let n=!1;return e.DockviewDisposable.from(()=>{if(n)throw new Error("invalid operation: resource already disposed");n=!0,o(e=>e.filter(e=>e!==t))})},[])]};function c(e){return"function"==typeof e||!!(null==e?void 0:e.$$typeof)}class p{get element(){return this._element}constructor(t,n,o){this.id=t,this.component=n,this.reactPortalStore=o,this._onDidFocus=new e.DockviewEmitter,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new e.DockviewEmitter,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new i(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class l{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new i(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;null===(t=this.part)||void 0===t||t.update({params:e.params})}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class u{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new i(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,n,o;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:null!==(o=null===(n=this.parameters)||void 0===n?void 0:n.params)&&void 0!==o?o:{}})}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class d{get element(){return this._element}get part(){return this._part}constructor(t,n,o){this.component=t,this.reactPortalStore=n,this._group=o,this.mutableDisposable=new e.DockviewMutableDisposable,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(t){this.mutableDisposable.value=new e.DockviewCompositeDisposable(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),t.api.onDidActiveChange(()=>{this.updateGroupActive()}),t.api.onDidLocationChange(e=>{this.updateLocation(e.location)})),this._part=new i(this.element,this.reactPortalStore,this.component,{api:t.api,containerApi:t.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:t.api.location})}dispose(){var e;this.mutableDisposable.dispose(),null===(e=this._part)||void 0===e||e.dispose()}update(e){var t;null===(t=this._part)||void 0===t||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}}class m{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new i(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class h{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new i(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;null===(t=this.part)||void 0===t||t.update({tabGroup:e.tabGroup})}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class f{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new i(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}function v(e,t){return e?n=>new d(e,t,n):void 0}const P="props.defaultTabComponent";const w=t.forwardRef((n,o)=>{const r=t.useRef(null),a=t.useRef(void 0),[i,c]=s();t.useImperativeHandle(o,()=>r.current,[]);const d=t.useRef({});return t.useEffect(()=>{const t={};e.PROPERTY_KEYS_DOCKVIEW.forEach(e=>{const o=e,r=n[o];o in n&&r!==d.current[o]&&(t[o]=r)}),a.current&&a.current.updateOptions(t),d.current=n},e.PROPERTY_KEYS_DOCKVIEW.map(e=>n[e])),t.useEffect(()=>{var t;if(!r.current)return;const o=null!==(t=n.tabComponents)&&void 0!==t?t:{};n.defaultTabComponent&&(o[P]=n.defaultTabComponent);const i={createLeftHeaderActionComponent:v(n.leftHeaderActionsComponent,{addPortal:c}),createRightHeaderActionComponent:v(n.rightHeaderActionsComponent,{addPortal:c}),createPrefixHeaderActionComponent:v(n.prefixHeaderActionsComponent,{addPortal:c}),createComponent:e=>new p(e.id,n.components[e.name],{addPortal:c}),createTabComponent:e=>new l(e.id,o[e.name],{addPortal:c}),createWatermarkComponent:n.watermarkComponent?()=>new u("watermark",n.watermarkComponent,{addPortal:c}):void 0,defaultTabComponent:n.defaultTabComponent?P:void 0,createContextMenuItemComponent:e=>{if(e.component)return new m(e.id,e.component,{addPortal:c})}},s=function(t){return e.PROPERTY_KEYS_DOCKVIEW.reduce((e,n)=>(n in t&&(e[n]=t[n]),e),{})}(n);if(n.tabGroupChipComponent){const e=n.tabGroupChipComponent;s.createTabGroupChipComponent=()=>new h(e,{addPortal:c})}if(n.groupDragGhostComponent){const e=n.groupDragGhostComponent;s.createGroupDragGhostComponent=()=>new f(e,{addPortal:c})}const d=e.createDockview(r.current,Object.assign(Object.assign({},s),i)),{clientWidth:w,clientHeight:C}=r.current;return d.layout(w,C),n.onReady&&n.onReady({api:d}),a.current=d,()=>{a.current=void 0,d.dispose()}},[]),t.useEffect(()=>{if(!a.current)return()=>{};const e=a.current.onDidDrop(e=>{n.onDidDrop&&n.onDidDrop(e)});return()=>{e.dispose()}},[n.onDidDrop]),t.useEffect(()=>{if(!a.current)return()=>{};const e=a.current.onWillDrop(e=>{n.onWillDrop&&n.onWillDrop(e)});return()=>{e.dispose()}},[n.onWillDrop]),t.useEffect(()=>{a.current&&a.current.updateOptions({createTabGroupChipComponent:n.tabGroupChipComponent?()=>new h(n.tabGroupChipComponent,{addPortal:c}):void 0})},[n.tabGroupChipComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createGroupDragGhostComponent:n.groupDragGhostComponent?()=>new f(n.groupDragGhostComponent,{addPortal:c}):void 0})},[n.groupDragGhostComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createComponent:e=>new p(e.id,n.components[e.name],{addPortal:c})})},[n.components]),t.useEffect(()=>{var e;if(!a.current)return;const t=null!==(e=n.tabComponents)&&void 0!==e?e:{};n.defaultTabComponent&&(t[P]=n.defaultTabComponent),a.current.updateOptions({defaultTabComponent:n.defaultTabComponent?P:void 0,createTabComponent:e=>new l(e.id,t[e.name],{addPortal:c})})},[n.tabComponents,n.defaultTabComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createWatermarkComponent:n.watermarkComponent?()=>new u("watermark",n.watermarkComponent,{addPortal:c}):void 0})},[n.watermarkComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createRightHeaderActionComponent:v(n.rightHeaderActionsComponent,{addPortal:c})})},[n.rightHeaderActionsComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createLeftHeaderActionComponent:v(n.leftHeaderActionsComponent,{addPortal:c})})},[n.leftHeaderActionsComponent]),t.useEffect(()=>{a.current&&a.current.updateOptions({createPrefixHeaderActionComponent:v(n.prefixHeaderActionsComponent,{addPortal:c})})},[n.prefixHeaderActionsComponent]),t.createElement("div",{style:{height:"100%",width:"100%"},ref:r},i)});w.displayName="DockviewComponent","function"==typeof SuppressedError&&SuppressedError;const C=()=>t.createElement("svg",{height:"11",width:"11",viewBox:"0 0 28 28","aria-hidden":"false",focusable:!1,className:"dv-svg"},t.createElement("path",{d:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}));class _ extends e.SplitviewPanel{constructor(e,t,n,o){super(e,t),this.reactComponent=n,this.reactPortalStore=o}getComponent(){var t,n;return new i(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(n=null===(t=this._params)||void 0===t?void 0:t.params)&&void 0!==n?n:{},api:this.api,containerApi:new e.SplitviewApi(this._params.accessor)})}}const E=t.forwardRef((n,o)=>{const r=t.useRef(null),a=t.useRef(void 0),[i,c]=s();t.useImperativeHandle(o,()=>r.current,[]);const p=t.useRef({});return t.useEffect(()=>{const t={};e.PROPERTY_KEYS_SPLITVIEW.forEach(e=>{const o=e,r=n[o];o in n&&r!==p.current[o]&&(t[o]=r)}),a.current&&a.current.updateOptions(t),p.current=n},e.PROPERTY_KEYS_SPLITVIEW.map(e=>n[e])),t.useEffect(()=>{if(!r.current)return()=>{};const t={createComponent:e=>new _(e.id,e.name,n.components[e.name],{addPortal:c})},o=e.createSplitview(r.current,Object.assign(Object.assign({},function(t){return e.PROPERTY_KEYS_SPLITVIEW.reduce((e,n)=>(n in t&&(e[n]=t[n]),e),{})}(n)),t)),{clientWidth:i,clientHeight:s}=r.current;return o.layout(i,s),n.onReady&&n.onReady({api:o}),a.current=o,()=>{a.current=void 0,o.dispose()}},[]),t.useEffect(()=>{a.current&&a.current.updateOptions({createComponent:e=>new _(e.id,e.name,n.components[e.name],{addPortal:c})})},[n.components]),t.createElement("div",{style:{height:"100%",width:"100%"},ref:r},i)});E.displayName="SplitviewComponent";class g extends e.GridviewPanel{constructor(e,t,n,o){super(e,t),this.reactComponent=n,this.reactPortalStore=o}getComponent(){var t,n;return new i(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(n=null===(t=this._params)||void 0===t?void 0:t.params)&&void 0!==n?n:{},api:this.api,containerApi:new e.GridviewApi(this._params.accessor)})}}const b=t.forwardRef((n,o)=>{const r=t.useRef(null),a=t.useRef(void 0),[i,c]=s();t.useImperativeHandle(o,()=>r.current,[]);const p=t.useRef({});return t.useEffect(()=>{const t={};e.PROPERTY_KEYS_GRIDVIEW.forEach(e=>{const o=e,r=n[o];o in n&&r!==p.current[o]&&(t[o]=r)}),a.current&&a.current.updateOptions(t),p.current=n},e.PROPERTY_KEYS_GRIDVIEW.map(e=>n[e])),t.useEffect(()=>{if(!r.current)return()=>{};const t={createComponent:e=>new g(e.id,e.name,n.components[e.name],{addPortal:c})},o=e.createGridview(r.current,Object.assign(Object.assign({},function(t){return e.PROPERTY_KEYS_GRIDVIEW.reduce((e,n)=>(n in t&&(e[n]=t[n]),e),{})}(n)),t)),{clientWidth:i,clientHeight:s}=r.current;return o.layout(i,s),n.onReady&&n.onReady({api:o}),a.current=o,()=>{a.current=void 0,o.dispose()}},[]),t.useEffect(()=>{a.current&&a.current.updateOptions({createComponent:e=>new g(e.id,e.name,n.components[e.name],{addPortal:c})})},[n.components]),t.createElement("div",{style:{height:"100%",width:"100%"},ref:r},i)});b.displayName="GridviewComponent";class D{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new i(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const R=t.forwardRef((n,o)=>{const r=t.useRef(null),a=t.useRef(void 0),[i,c]=s();t.useImperativeHandle(o,()=>r.current,[]);const p=t.useRef({});return t.useEffect(()=>{const t={};e.PROPERTY_KEYS_PANEVIEW.forEach(e=>{const o=e,r=n[o];o in n&&r!==p.current[o]&&(t[o]=r)}),a.current&&a.current.updateOptions(t),p.current=n},e.PROPERTY_KEYS_PANEVIEW.map(e=>n[e])),t.useEffect(()=>{var t;if(!r.current)return()=>{};const o=null!==(t=n.headerComponents)&&void 0!==t?t:{},i={createComponent:e=>new D(e.id,n.components[e.name],{addPortal:c}),createHeaderComponent:e=>new D(e.id,o[e.name],{addPortal:c})},s=e.createPaneview(r.current,Object.assign(Object.assign({},function(t){return e.PROPERTY_KEYS_PANEVIEW.reduce((e,n)=>(n in t&&(e[n]=t[n]),e),{})}(n)),i)),{clientWidth:p,clientHeight:l}=r.current;return s.layout(p,l),n.onReady&&n.onReady({api:s}),a.current=s,()=>{a.current=void 0,s.dispose()}},[]),t.useEffect(()=>{a.current&&a.current.updateOptions({createComponent:e=>new D(e.id,n.components[e.name],{addPortal:c})})},[n.components]),t.useEffect(()=>{var e;if(!a.current)return;const t=null!==(e=n.headerComponents)&&void 0!==e?e:{};a.current.updateOptions({createHeaderComponent:e=>new D(e.id,t[e.name],{addPortal:c})})},[n.headerComponents]),t.useEffect(()=>{if(!a.current)return()=>{};const e=a.current.onDidDrop(e=>{n.onDidDrop&&n.onDidDrop(e)});return()=>{e.dispose()}},[n.onDidDrop]),t.createElement("div",{style:{height:"100%",width:"100%"},ref:r},i)});R.displayName="PaneviewComponent",exports.DockviewDefaultTab=e=>{var{api:n,containerApi:o,params:r,hideClose:a,closeActionOverride:i,onPointerDown:s,onPointerUp:c,onPointerLeave:p,tabLocation:l}=e,u=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["api","containerApi","params","hideClose","closeActionOverride","onPointerDown","onPointerUp","onPointerLeave","tabLocation"]);const d=function(e){const[n,o]=t.useState(e.title);return t.useEffect(()=>{const t=e.onDidTitleChange(e=>{o(e.title)});return n!==e.title&&o(e.title),()=>{t.dispose()}},[e]),n}(n),m=t.useRef(!1),h=t.useCallback(e=>{e.preventDefault(),i?i():n.close()},[n,i]),f=t.useCallback(e=>{e.preventDefault()},[]),v=t.useCallback(e=>{m.current=1===e.button,null==s||s(e)},[s]),P=t.useCallback(e=>{m&&1===e.button&&!a&&(m.current=!1,h(e)),null==c||c(e)},[c,h,a]),w=t.useCallback(e=>{m.current=!1,null==p||p(e)},[p]);return t.createElement("div",Object.assign({"data-testid":"dockview-dv-default-tab"},u,{onPointerDown:v,onPointerUp:P,onPointerLeave:w,className:"dv-default-tab"}),t.createElement("span",{className:"dv-default-tab-content"},d),!a&&t.createElement("div",{className:"dv-default-tab-action",onPointerDown:f,onClick:h},t.createElement(C,null)))},exports.DockviewReact=w,exports.GridviewReact=b,exports.PaneviewReact=R,exports.ReactPart=i,exports.ReactPartContext=a,exports.SplitviewReact=E,exports.isReactComponent=c,exports.usePortalsLifecycle=s,Object.keys(e).forEach(function(t){"default"===t||Object.prototype.hasOwnProperty.call(exports,t)||Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * dockview
3
- * @version 6.2.1
3
+ * @version 6.3.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
7
- import{DockviewDisposable as e,DockviewEmitter as t,DockviewMutableDisposable as n,DockviewCompositeDisposable as o,PROPERTY_KEYS_DOCKVIEW as r,createDockview as a,SplitviewPanel as i,SplitviewApi as s,PROPERTY_KEYS_SPLITVIEW as c,createSplitview as p,GridviewPanel as l,GridviewApi as d,PROPERTY_KEYS_GRIDVIEW as u,createGridview as m,PROPERTY_KEYS_PANEVIEW as h,createPaneview as f}from"dockview-core";export*from"dockview-core";import v from"react";import C from"react-dom";const P=(e,t)=>{const[,n]=v.useState(0),o=v.useRef(e.componentProps);return v.useImperativeHandle(t,()=>({update:e=>{o.current=Object.assign(Object.assign({},o.current),e),n(e=>e+1)}}),[]),v.createElement(e.component,o.current)};P.displayName="DockviewReactJsBridge";const w=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),b=v.createContext({});class g{constructor(e,t,n,o,r){this.parent=e,this.portalStore=t,this.component=n,this.parameters=o,this.context=r,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!y(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=v.createElement(v.forwardRef(P),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?v.createElement(b.Provider,{value:this.context},e):e,n=C.createPortal(t,this.parent,w.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const _=()=>{const[t,n]=v.useState([]);v.useDebugValue(`Portal count: ${t.length}`);return[t,v.useCallback(t=>{n(e=>[...e,t]);let o=!1;return e.from(()=>{if(o)throw new Error("invalid operation: resource already disposed");o=!0,n(e=>e.filter(e=>e!==t))})},[])]};function y(e){return"function"==typeof e||!!(null==e?void 0:e.$$typeof)}class E{get element(){return this._element}constructor(e,n,o){this.id=e,this.component=n,this.reactPortalStore=o,this._onDidFocus=new t,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new t,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new g(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class D{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new g(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;null===(t=this.part)||void 0===t||t.update({params:e.params})}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class A{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new g(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,n,o;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:null!==(o=null===(n=this.parameters)||void 0===n?void 0:n.params)&&void 0!==o?o:{}})}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class O{get element(){return this._element}get part(){return this._part}constructor(e,t,o){this.component=e,this.reactPortalStore=t,this._group=o,this.mutableDisposable=new n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.mutableDisposable.value=new o(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(e=>{this.updateLocation(e.location)})),this._part=new g(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),null===(e=this._part)||void 0===e||e.dispose()}update(e){var t;null===(t=this._part)||void 0===t||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}}class R{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new g(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class S{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new g(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;null===(t=this.part)||void 0===t||t.update({tabGroup:e.tabGroup})}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}function H(e,t){return e?n=>new O(e,t,n):void 0}const k="props.defaultTabComponent";const L=v.forwardRef((e,t)=>{const n=v.useRef(null),o=v.useRef(void 0),[i,s]=_();v.useImperativeHandle(t,()=>n.current,[]);const c=v.useRef({});return v.useEffect(()=>{const t={};r.forEach(n=>{const o=n,r=e[o];o in e&&r!==c.current[o]&&(t[o]=r)}),o.current&&o.current.updateOptions(t),c.current=e},r.map(t=>e[t])),v.useEffect(()=>{var t;if(!n.current)return;const i=null!==(t=e.tabComponents)&&void 0!==t?t:{};e.defaultTabComponent&&(i[k]=e.defaultTabComponent);const c={createLeftHeaderActionComponent:H(e.leftHeaderActionsComponent,{addPortal:s}),createRightHeaderActionComponent:H(e.rightHeaderActionsComponent,{addPortal:s}),createPrefixHeaderActionComponent:H(e.prefixHeaderActionsComponent,{addPortal:s}),createComponent:t=>new E(t.id,e.components[t.name],{addPortal:s}),createTabComponent:e=>new D(e.id,i[e.name],{addPortal:s}),createWatermarkComponent:e.watermarkComponent?()=>new A("watermark",e.watermarkComponent,{addPortal:s}):void 0,defaultTabComponent:e.defaultTabComponent?k:void 0,createContextMenuItemComponent:e=>{if(e.component)return new R(e.id,e.component,{addPortal:s})}},p=function(e){return r.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}(e);if(e.tabGroupChipComponent){const t=e.tabGroupChipComponent;p.createTabGroupChipComponent=()=>new S(t,{addPortal:s})}const l=a(n.current,Object.assign(Object.assign({},p),c)),{clientWidth:d,clientHeight:u}=n.current;return l.layout(d,u),e.onReady&&e.onReady({api:l}),o.current=l,()=>{o.current=void 0,l.dispose()}},[]),v.useEffect(()=>{if(!o.current)return()=>{};const t=o.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),v.useEffect(()=>{if(!o.current)return()=>{};const t=o.current.onWillDrop(t=>{e.onWillDrop&&e.onWillDrop(t)});return()=>{t.dispose()}},[e.onWillDrop]),v.useEffect(()=>{o.current&&o.current.updateOptions({createTabGroupChipComponent:e.tabGroupChipComponent?()=>new S(e.tabGroupChipComponent,{addPortal:s}):void 0})},[e.tabGroupChipComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createComponent:t=>new E(t.id,e.components[t.name],{addPortal:s})})},[e.components]),v.useEffect(()=>{var t;if(!o.current)return;const n=null!==(t=e.tabComponents)&&void 0!==t?t:{};e.defaultTabComponent&&(n[k]=e.defaultTabComponent),o.current.updateOptions({defaultTabComponent:e.defaultTabComponent?k:void 0,createTabComponent:e=>new D(e.id,n[e.name],{addPortal:s})})},[e.tabComponents,e.defaultTabComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new A("watermark",e.watermarkComponent,{addPortal:s}):void 0})},[e.watermarkComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createRightHeaderActionComponent:H(e.rightHeaderActionsComponent,{addPortal:s})})},[e.rightHeaderActionsComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createLeftHeaderActionComponent:H(e.leftHeaderActionsComponent,{addPortal:s})})},[e.leftHeaderActionsComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createPrefixHeaderActionComponent:H(e.prefixHeaderActionsComponent,{addPortal:s})})},[e.prefixHeaderActionsComponent]),v.createElement("div",{style:{height:"100%",width:"100%"},ref:n},i)});L.displayName="DockviewComponent","function"==typeof SuppressedError&&SuppressedError;const x=()=>v.createElement("svg",{height:"11",width:"11",viewBox:"0 0 28 28","aria-hidden":"false",focusable:!1,className:"dv-svg"},v.createElement("path",{d:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}));const j=e=>{var{api:t,containerApi:n,params:o,hideClose:r,closeActionOverride:a,onPointerDown:i,onPointerUp:s,onPointerLeave:c,tabLocation:p}=e,l=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["api","containerApi","params","hideClose","closeActionOverride","onPointerDown","onPointerUp","onPointerLeave","tabLocation"]);const d=function(e){const[t,n]=v.useState(e.title);return v.useEffect(()=>{const o=e.onDidTitleChange(e=>{n(e.title)});return t!==e.title&&n(e.title),()=>{o.dispose()}},[e]),t}(t),u=v.useRef(!1),m=v.useCallback(e=>{e.preventDefault(),a?a():t.close()},[t,a]),h=v.useCallback(e=>{e.preventDefault()},[]),f=v.useCallback(e=>{u.current=1===e.button,null==i||i(e)},[i]),C=v.useCallback(e=>{u&&1===e.button&&!r&&(u.current=!1,m(e)),null==s||s(e)},[s,m,r]),P=v.useCallback(e=>{u.current=!1,null==c||c(e)},[c]);return v.createElement("div",Object.assign({"data-testid":"dockview-dv-default-tab"},l,{onPointerDown:f,onPointerUp:C,onPointerLeave:P,className:"dv-default-tab"}),v.createElement("span",{className:"dv-default-tab-content"},d),!r&&v.createElement("div",{className:"dv-default-tab-action",onPointerDown:h,onClick:m},v.createElement(x,null)))};class G extends i{constructor(e,t,n,o){super(e,t),this.reactComponent=n,this.reactPortalStore=o}getComponent(){var e,t;return new g(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{},api:this.api,containerApi:new s(this._params.accessor)})}}const N=v.forwardRef((e,t)=>{const n=v.useRef(null),o=v.useRef(void 0),[r,a]=_();v.useImperativeHandle(t,()=>n.current,[]);const i=v.useRef({});return v.useEffect(()=>{const t={};c.forEach(n=>{const o=n,r=e[o];o in e&&r!==i.current[o]&&(t[o]=r)}),o.current&&o.current.updateOptions(t),i.current=e},c.map(t=>e[t])),v.useEffect(()=>{if(!n.current)return()=>{};const t={createComponent:t=>new G(t.id,t.name,e.components[t.name],{addPortal:a})},r=p(n.current,Object.assign(Object.assign({},function(e){return c.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}(e)),t)),{clientWidth:i,clientHeight:s}=n.current;return r.layout(i,s),e.onReady&&e.onReady({api:r}),o.current=r,()=>{o.current=void 0,r.dispose()}},[]),v.useEffect(()=>{o.current&&o.current.updateOptions({createComponent:t=>new G(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),v.createElement("div",{style:{height:"100%",width:"100%"},ref:n},r)});N.displayName="SplitviewComponent";class T extends l{constructor(e,t,n,o){super(e,t),this.reactComponent=n,this.reactPortalStore=o}getComponent(){var e,t;return new g(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{},api:this.api,containerApi:new d(this._params.accessor)})}}const I=v.forwardRef((e,t)=>{const n=v.useRef(null),o=v.useRef(void 0),[r,a]=_();v.useImperativeHandle(t,()=>n.current,[]);const i=v.useRef({});return v.useEffect(()=>{const t={};u.forEach(n=>{const o=n,r=e[o];o in e&&r!==i.current[o]&&(t[o]=r)}),o.current&&o.current.updateOptions(t),i.current=e},u.map(t=>e[t])),v.useEffect(()=>{if(!n.current)return()=>{};const t={createComponent:t=>new T(t.id,t.name,e.components[t.name],{addPortal:a})},r=m(n.current,Object.assign(Object.assign({},function(e){return u.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}(e)),t)),{clientWidth:i,clientHeight:s}=n.current;return r.layout(i,s),e.onReady&&e.onReady({api:r}),o.current=r,()=>{o.current=void 0,r.dispose()}},[]),v.useEffect(()=>{o.current&&o.current.updateOptions({createComponent:t=>new T(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),v.createElement("div",{style:{height:"100%",width:"100%"},ref:n},r)});I.displayName="GridviewComponent";class W{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new g(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const B=v.forwardRef((e,t)=>{const n=v.useRef(null),o=v.useRef(void 0),[r,a]=_();v.useImperativeHandle(t,()=>n.current,[]);const i=v.useRef({});return v.useEffect(()=>{const t={};h.forEach(n=>{const o=n,r=e[o];o in e&&r!==i.current[o]&&(t[o]=r)}),o.current&&o.current.updateOptions(t),i.current=e},h.map(t=>e[t])),v.useEffect(()=>{var t;if(!n.current)return()=>{};const r=null!==(t=e.headerComponents)&&void 0!==t?t:{},i={createComponent:t=>new W(t.id,e.components[t.name],{addPortal:a}),createHeaderComponent:e=>new W(e.id,r[e.name],{addPortal:a})},s=f(n.current,Object.assign(Object.assign({},function(e){return h.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}(e)),i)),{clientWidth:c,clientHeight:p}=n.current;return s.layout(c,p),e.onReady&&e.onReady({api:s}),o.current=s,()=>{o.current=void 0,s.dispose()}},[]),v.useEffect(()=>{o.current&&o.current.updateOptions({createComponent:t=>new W(t.id,e.components[t.name],{addPortal:a})})},[e.components]),v.useEffect(()=>{var t;if(!o.current)return;const n=null!==(t=e.headerComponents)&&void 0!==t?t:{};o.current.updateOptions({createHeaderComponent:e=>new W(e.id,n[e.name],{addPortal:a})})},[e.headerComponents]),v.useEffect(()=>{if(!o.current)return()=>{};const t=o.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),v.createElement("div",{style:{height:"100%",width:"100%"},ref:n},r)});B.displayName="PaneviewComponent";export{j as DockviewDefaultTab,L as DockviewReact,I as GridviewReact,B as PaneviewReact,g as ReactPart,b as ReactPartContext,N as SplitviewReact,y as isReactComponent,_ as usePortalsLifecycle};
7
+ import{DockviewDisposable as e,DockviewEmitter as t,DockviewMutableDisposable as n,DockviewCompositeDisposable as o,PROPERTY_KEYS_DOCKVIEW as r,createDockview as a,SplitviewPanel as i,SplitviewApi as s,PROPERTY_KEYS_SPLITVIEW as c,createSplitview as p,GridviewPanel as l,GridviewApi as d,PROPERTY_KEYS_GRIDVIEW as u,createGridview as m,PROPERTY_KEYS_PANEVIEW as h,createPaneview as f}from"dockview-core";export*from"dockview-core";import v from"react";import C from"react-dom";const P=(e,t)=>{const[,n]=v.useState(0),o=v.useRef(e.componentProps);return v.useImperativeHandle(t,()=>({update:e=>{o.current=Object.assign(Object.assign({},o.current),e),n(e=>e+1)}}),[]),v.createElement(e.component,o.current)};P.displayName="DockviewReactJsBridge";const g=(()=>{let e=1;return{next:()=>`dockview_react_portal_key_${(e++).toString()}`}})(),w=v.createContext({});class _{constructor(e,t,n,o,r){this.parent=e,this.portalStore=t,this.component=n,this.parameters=o,this.context=r,this._initialProps={},this.disposed=!1,this.createPortal()}update(e){if(this.disposed)throw new Error("invalid operation: resource is already disposed");this.componentInstance?this.componentInstance.update(e):this._initialProps=Object.assign(Object.assign({},this._initialProps),e)}createPortal(){if(this.disposed)throw new Error("invalid operation: resource is already disposed");if(!y(this.component))throw new Error("Dockview: Only React.memo(...), React.ForwardRef(...) and functional components are accepted as components");const e=v.createElement(v.forwardRef(P),{component:this.component,componentProps:this.parameters,ref:e=>{this.componentInstance=e,Object.keys(this._initialProps).length>0&&(this.componentInstance.update(this._initialProps),this._initialProps={})}}),t=this.context?v.createElement(w.Provider,{value:this.context},e):e,n=C.createPortal(t,this.parent,g.next());this.ref={portal:n,disposable:this.portalStore.addPortal(n)}}dispose(){var e;null===(e=this.ref)||void 0===e||e.disposable.dispose(),this.disposed=!0}}const b=()=>{const[t,n]=v.useState([]);v.useDebugValue(`Portal count: ${t.length}`);return[t,v.useCallback(t=>{n(e=>[...e,t]);let o=!1;return e.from(()=>{if(o)throw new Error("invalid operation: resource already disposed");o=!0,n(e=>e.filter(e=>e!==t))})},[])]};function y(e){return"function"==typeof e||!!(null==e?void 0:e.$$typeof)}class E{get element(){return this._element}constructor(e,n,o){this.id=e,this.component=n,this.reactPortalStore=o,this._onDidFocus=new t,this.onDidFocus=this._onDidFocus.event,this._onDidBlur=new t,this.onDidBlur=this._onDidBlur.event,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new _(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi})}update(e){var t;null===(t=this.part)||void 0===t||t.update({params:e.params})}layout(e,t){}dispose(){var e;this._onDidFocus.dispose(),this._onDidBlur.dispose(),null===(e=this.part)||void 0===e||e.dispose()}}class D{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}focus(){}init(e){this.part=new _(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,containerApi:e.containerApi,tabLocation:e.tabLocation})}update(e){var t;null===(t=this.part)||void 0===t||t.update({params:e.params})}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class O{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new _(this.element,this.reactPortalStore,this.component,{group:e.group,containerApi:e.containerApi})}focus(){}update(e){var t,n,o;this.parameters&&(this.parameters.params=e.params),null===(t=this.part)||void 0===t||t.update({params:null!==(o=null===(n=this.parameters)||void 0===n?void 0:n.params)&&void 0!==o?o:{}})}layout(e,t){}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class A{get element(){return this._element}get part(){return this._part}constructor(e,t,o){this.component=e,this.reactPortalStore=t,this._group=o,this.mutableDisposable=new n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.mutableDisposable.value=new o(this._group.model.onDidAddPanel(()=>{this.updatePanels()}),this._group.model.onDidRemovePanel(()=>{this.updatePanels()}),this._group.model.onDidActivePanelChange(()=>{this.updateActivePanel()}),e.api.onDidActiveChange(()=>{this.updateGroupActive()}),e.api.onDidLocationChange(e=>{this.updateLocation(e.location)})),this._part=new _(this.element,this.reactPortalStore,this.component,{api:e.api,containerApi:e.containerApi,panels:this._group.model.panels,activePanel:this._group.model.activePanel,isGroupActive:this._group.api.isActive,group:this._group,headerPosition:this._group.model.headerPosition,location:e.api.location})}dispose(){var e;this.mutableDisposable.dispose(),null===(e=this._part)||void 0===e||e.dispose()}update(e){var t;null===(t=this._part)||void 0===t||t.update(e.params)}updatePanels(){this.update({params:{panels:this._group.model.panels}})}updateActivePanel(){this.update({params:{activePanel:this._group.model.activePanel}})}updateGroupActive(){this.update({params:{isGroupActive:this._group.api.isActive}})}updateLocation(e){this.update({params:{location:e}})}}class R{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new _(this._element,this.reactPortalStore,this.component,e)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class S{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new _(this._element,this.reactPortalStore,this.component,{tabGroup:e.tabGroup,api:e.api})}update(e){var t;null===(t=this.part)||void 0===t||t.update({tabGroup:e.tabGroup})}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}class H{get element(){return this._element}constructor(e,t){this.component=e,this.reactPortalStore=t,this._element=document.createElement("div"),this._element.className="dv-react-part",this._element.style.display="inline-flex"}init(e){this.part=new _(this._element,this.reactPortalStore,this.component,{group:e.group,api:e.api})}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}function k(e,t){return e?n=>new A(e,t,n):void 0}const G="props.defaultTabComponent";const L=v.forwardRef((e,t)=>{const n=v.useRef(null),o=v.useRef(void 0),[i,s]=b();v.useImperativeHandle(t,()=>n.current,[]);const c=v.useRef({});return v.useEffect(()=>{const t={};r.forEach(n=>{const o=n,r=e[o];o in e&&r!==c.current[o]&&(t[o]=r)}),o.current&&o.current.updateOptions(t),c.current=e},r.map(t=>e[t])),v.useEffect(()=>{var t;if(!n.current)return;const i=null!==(t=e.tabComponents)&&void 0!==t?t:{};e.defaultTabComponent&&(i[G]=e.defaultTabComponent);const c={createLeftHeaderActionComponent:k(e.leftHeaderActionsComponent,{addPortal:s}),createRightHeaderActionComponent:k(e.rightHeaderActionsComponent,{addPortal:s}),createPrefixHeaderActionComponent:k(e.prefixHeaderActionsComponent,{addPortal:s}),createComponent:t=>new E(t.id,e.components[t.name],{addPortal:s}),createTabComponent:e=>new D(e.id,i[e.name],{addPortal:s}),createWatermarkComponent:e.watermarkComponent?()=>new O("watermark",e.watermarkComponent,{addPortal:s}):void 0,defaultTabComponent:e.defaultTabComponent?G:void 0,createContextMenuItemComponent:e=>{if(e.component)return new R(e.id,e.component,{addPortal:s})}},p=function(e){return r.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}(e);if(e.tabGroupChipComponent){const t=e.tabGroupChipComponent;p.createTabGroupChipComponent=()=>new S(t,{addPortal:s})}if(e.groupDragGhostComponent){const t=e.groupDragGhostComponent;p.createGroupDragGhostComponent=()=>new H(t,{addPortal:s})}const l=a(n.current,Object.assign(Object.assign({},p),c)),{clientWidth:d,clientHeight:u}=n.current;return l.layout(d,u),e.onReady&&e.onReady({api:l}),o.current=l,()=>{o.current=void 0,l.dispose()}},[]),v.useEffect(()=>{if(!o.current)return()=>{};const t=o.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),v.useEffect(()=>{if(!o.current)return()=>{};const t=o.current.onWillDrop(t=>{e.onWillDrop&&e.onWillDrop(t)});return()=>{t.dispose()}},[e.onWillDrop]),v.useEffect(()=>{o.current&&o.current.updateOptions({createTabGroupChipComponent:e.tabGroupChipComponent?()=>new S(e.tabGroupChipComponent,{addPortal:s}):void 0})},[e.tabGroupChipComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createGroupDragGhostComponent:e.groupDragGhostComponent?()=>new H(e.groupDragGhostComponent,{addPortal:s}):void 0})},[e.groupDragGhostComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createComponent:t=>new E(t.id,e.components[t.name],{addPortal:s})})},[e.components]),v.useEffect(()=>{var t;if(!o.current)return;const n=null!==(t=e.tabComponents)&&void 0!==t?t:{};e.defaultTabComponent&&(n[G]=e.defaultTabComponent),o.current.updateOptions({defaultTabComponent:e.defaultTabComponent?G:void 0,createTabComponent:e=>new D(e.id,n[e.name],{addPortal:s})})},[e.tabComponents,e.defaultTabComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createWatermarkComponent:e.watermarkComponent?()=>new O("watermark",e.watermarkComponent,{addPortal:s}):void 0})},[e.watermarkComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createRightHeaderActionComponent:k(e.rightHeaderActionsComponent,{addPortal:s})})},[e.rightHeaderActionsComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createLeftHeaderActionComponent:k(e.leftHeaderActionsComponent,{addPortal:s})})},[e.leftHeaderActionsComponent]),v.useEffect(()=>{o.current&&o.current.updateOptions({createPrefixHeaderActionComponent:k(e.prefixHeaderActionsComponent,{addPortal:s})})},[e.prefixHeaderActionsComponent]),v.createElement("div",{style:{height:"100%",width:"100%"},ref:n},i)});L.displayName="DockviewComponent","function"==typeof SuppressedError&&SuppressedError;const x=()=>v.createElement("svg",{height:"11",width:"11",viewBox:"0 0 28 28","aria-hidden":"false",focusable:!1,className:"dv-svg"},v.createElement("path",{d:"M2.1 27.3L0 25.2L11.55 13.65L0 2.1L2.1 0L13.65 11.55L25.2 0L27.3 2.1L15.75 13.65L27.3 25.2L25.2 27.3L13.65 15.75L2.1 27.3Z"}));const j=e=>{var{api:t,containerApi:n,params:o,hideClose:r,closeActionOverride:a,onPointerDown:i,onPointerUp:s,onPointerLeave:c,tabLocation:p}=e,l=function(e,t){var n={};for(var o in e)Object.prototype.hasOwnProperty.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(null!=e&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(o=Object.getOwnPropertySymbols(e);r<o.length;r++)t.indexOf(o[r])<0&&Object.prototype.propertyIsEnumerable.call(e,o[r])&&(n[o[r]]=e[o[r]])}return n}(e,["api","containerApi","params","hideClose","closeActionOverride","onPointerDown","onPointerUp","onPointerLeave","tabLocation"]);const d=function(e){const[t,n]=v.useState(e.title);return v.useEffect(()=>{const o=e.onDidTitleChange(e=>{n(e.title)});return t!==e.title&&n(e.title),()=>{o.dispose()}},[e]),t}(t),u=v.useRef(!1),m=v.useCallback(e=>{e.preventDefault(),a?a():t.close()},[t,a]),h=v.useCallback(e=>{e.preventDefault()},[]),f=v.useCallback(e=>{u.current=1===e.button,null==i||i(e)},[i]),C=v.useCallback(e=>{u&&1===e.button&&!r&&(u.current=!1,m(e)),null==s||s(e)},[s,m,r]),P=v.useCallback(e=>{u.current=!1,null==c||c(e)},[c]);return v.createElement("div",Object.assign({"data-testid":"dockview-dv-default-tab"},l,{onPointerDown:f,onPointerUp:C,onPointerLeave:P,className:"dv-default-tab"}),v.createElement("span",{className:"dv-default-tab-content"},d),!r&&v.createElement("div",{className:"dv-default-tab-action",onPointerDown:h,onClick:m},v.createElement(x,null)))};class N extends i{constructor(e,t,n,o){super(e,t),this.reactComponent=n,this.reactPortalStore=o}getComponent(){var e,t;return new _(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{},api:this.api,containerApi:new s(this._params.accessor)})}}const T=v.forwardRef((e,t)=>{const n=v.useRef(null),o=v.useRef(void 0),[r,a]=b();v.useImperativeHandle(t,()=>n.current,[]);const i=v.useRef({});return v.useEffect(()=>{const t={};c.forEach(n=>{const o=n,r=e[o];o in e&&r!==i.current[o]&&(t[o]=r)}),o.current&&o.current.updateOptions(t),i.current=e},c.map(t=>e[t])),v.useEffect(()=>{if(!n.current)return()=>{};const t={createComponent:t=>new N(t.id,t.name,e.components[t.name],{addPortal:a})},r=p(n.current,Object.assign(Object.assign({},function(e){return c.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}(e)),t)),{clientWidth:i,clientHeight:s}=n.current;return r.layout(i,s),e.onReady&&e.onReady({api:r}),o.current=r,()=>{o.current=void 0,r.dispose()}},[]),v.useEffect(()=>{o.current&&o.current.updateOptions({createComponent:t=>new N(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),v.createElement("div",{style:{height:"100%",width:"100%"},ref:n},r)});T.displayName="SplitviewComponent";class I extends l{constructor(e,t,n,o){super(e,t),this.reactComponent=n,this.reactPortalStore=o}getComponent(){var e,t;return new _(this.element,this.reactPortalStore,this.reactComponent,{params:null!==(t=null===(e=this._params)||void 0===e?void 0:e.params)&&void 0!==t?t:{},api:this.api,containerApi:new d(this._params.accessor)})}}const W=v.forwardRef((e,t)=>{const n=v.useRef(null),o=v.useRef(void 0),[r,a]=b();v.useImperativeHandle(t,()=>n.current,[]);const i=v.useRef({});return v.useEffect(()=>{const t={};u.forEach(n=>{const o=n,r=e[o];o in e&&r!==i.current[o]&&(t[o]=r)}),o.current&&o.current.updateOptions(t),i.current=e},u.map(t=>e[t])),v.useEffect(()=>{if(!n.current)return()=>{};const t={createComponent:t=>new I(t.id,t.name,e.components[t.name],{addPortal:a})},r=m(n.current,Object.assign(Object.assign({},function(e){return u.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}(e)),t)),{clientWidth:i,clientHeight:s}=n.current;return r.layout(i,s),e.onReady&&e.onReady({api:r}),o.current=r,()=>{o.current=void 0,r.dispose()}},[]),v.useEffect(()=>{o.current&&o.current.updateOptions({createComponent:t=>new I(t.id,t.name,e.components[t.name],{addPortal:a})})},[e.components]),v.createElement("div",{style:{height:"100%",width:"100%"},ref:n},r)});W.displayName="GridviewComponent";class B{get element(){return this._element}constructor(e,t,n){this.id=e,this.component=t,this.reactPortalStore=n,this._element=document.createElement("div"),this._element.style.height="100%",this._element.style.width="100%"}init(e){this.part=new _(this.element,this.reactPortalStore,this.component,{params:e.params,api:e.api,title:e.title,containerApi:e.containerApi})}toJSON(){return{id:this.id}}update(e){var t;null===(t=this.part)||void 0===t||t.update(e.params)}dispose(){var e;null===(e=this.part)||void 0===e||e.dispose()}}const F=v.forwardRef((e,t)=>{const n=v.useRef(null),o=v.useRef(void 0),[r,a]=b();v.useImperativeHandle(t,()=>n.current,[]);const i=v.useRef({});return v.useEffect(()=>{const t={};h.forEach(n=>{const o=n,r=e[o];o in e&&r!==i.current[o]&&(t[o]=r)}),o.current&&o.current.updateOptions(t),i.current=e},h.map(t=>e[t])),v.useEffect(()=>{var t;if(!n.current)return()=>{};const r=null!==(t=e.headerComponents)&&void 0!==t?t:{},i={createComponent:t=>new B(t.id,e.components[t.name],{addPortal:a}),createHeaderComponent:e=>new B(e.id,r[e.name],{addPortal:a})},s=f(n.current,Object.assign(Object.assign({},function(e){return h.reduce((t,n)=>(n in e&&(t[n]=e[n]),t),{})}(e)),i)),{clientWidth:c,clientHeight:p}=n.current;return s.layout(c,p),e.onReady&&e.onReady({api:s}),o.current=s,()=>{o.current=void 0,s.dispose()}},[]),v.useEffect(()=>{o.current&&o.current.updateOptions({createComponent:t=>new B(t.id,e.components[t.name],{addPortal:a})})},[e.components]),v.useEffect(()=>{var t;if(!o.current)return;const n=null!==(t=e.headerComponents)&&void 0!==t?t:{};o.current.updateOptions({createHeaderComponent:e=>new B(e.id,n[e.name],{addPortal:a})})},[e.headerComponents]),v.useEffect(()=>{if(!o.current)return()=>{};const t=o.current.onDidDrop(t=>{e.onDidDrop&&e.onDidDrop(t)});return()=>{t.dispose()}},[e.onDidDrop]),v.createElement("div",{style:{height:"100%",width:"100%"},ref:n},r)});F.displayName="PaneviewComponent";export{j as DockviewDefaultTab,L as DockviewReact,W as GridviewReact,F as PaneviewReact,_ as ReactPart,w as ReactPartContext,T as SplitviewReact,y as isReactComponent,b as usePortalsLifecycle};
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * dockview
3
- * @version 6.2.1
3
+ * @version 6.3.0
4
4
  * @link https://github.com/mathuo/dockview
5
5
  * @license MIT
6
6
  */
@@ -378,6 +378,29 @@ class ReactTabGroupChipPart {
378
378
  }
379
379
  }
380
380
 
381
+ class ReactGroupDragGhostPart {
382
+ get element() {
383
+ return this._element;
384
+ }
385
+ constructor(component, reactPortalStore) {
386
+ this.component = component;
387
+ this.reactPortalStore = reactPortalStore;
388
+ this._element = document.createElement('div');
389
+ this._element.className = 'dv-react-part';
390
+ this._element.style.display = 'inline-flex';
391
+ }
392
+ init(params) {
393
+ this.part = new ReactPart(this._element, this.reactPortalStore, this.component, {
394
+ group: params.group,
395
+ api: params.api,
396
+ });
397
+ }
398
+ dispose() {
399
+ var _a;
400
+ (_a = this.part) === null || _a === void 0 ? void 0 : _a.dispose();
401
+ }
402
+ }
403
+
381
404
  function createGroupControlElement(component, store) {
382
405
  return component
383
406
  ? (groupPanel) => {
@@ -465,6 +488,14 @@ const DockviewReact = React.forwardRef((props, ref) => {
465
488
  });
466
489
  };
467
490
  }
491
+ if (props.groupDragGhostComponent) {
492
+ const ghostComponent = props.groupDragGhostComponent;
493
+ coreOptions.createGroupDragGhostComponent = () => {
494
+ return new ReactGroupDragGhostPart(ghostComponent, {
495
+ addPortal,
496
+ });
497
+ };
498
+ }
468
499
  const api = createDockview(domRef.current, Object.assign(Object.assign({}, coreOptions), frameworkOptions));
469
500
  const { clientWidth, clientHeight } = domRef.current;
470
501
  api.layout(clientWidth, clientHeight);
@@ -521,6 +552,20 @@ const DockviewReact = React.forwardRef((props, ref) => {
521
552
  : undefined,
522
553
  });
523
554
  }, [props.tabGroupChipComponent]);
555
+ React.useEffect(() => {
556
+ if (!dockviewRef.current) {
557
+ return;
558
+ }
559
+ dockviewRef.current.updateOptions({
560
+ createGroupDragGhostComponent: props.groupDragGhostComponent
561
+ ? () => {
562
+ return new ReactGroupDragGhostPart(props.groupDragGhostComponent, {
563
+ addPortal,
564
+ });
565
+ }
566
+ : undefined,
567
+ });
568
+ }, [props.groupDragGhostComponent]);
524
569
  React.useEffect(() => {
525
570
  if (!dockviewRef.current) {
526
571
  return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dockview",
3
- "version": "6.2.1",
3
+ "version": "6.3.0",
4
4
  "description": "React docking layout manager — tabs, groups, grids, splitviews, drag and drop, floating panels",
5
5
  "keywords": [
6
6
  "splitview",
@@ -68,7 +68,7 @@
68
68
  "format:check": "prettier --check 'src/**/*.{ts,tsx,js,jsx}'"
69
69
  },
70
70
  "dependencies": {
71
- "dockview-core": "^6.2.1"
71
+ "dockview-core": "^6.3.0"
72
72
  },
73
73
  "peerDependencies": {
74
74
  "react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"