dockview-react 8.4.1 → 8.5.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/dist/cjs/react.d.ts +13 -0
- package/dist/dockview-react.js +144 -74
- package/dist/dockview-react.min.js +3 -3
- package/dist/package/main.cjs.js +127 -57
- package/dist/package/main.cjs.min.js +2 -2
- package/dist/package/main.esm.min.mjs +2 -2
- package/dist/package/main.esm.mjs +126 -58
- package/package.json +2 -2
package/dist/cjs/react.d.ts
CHANGED
|
@@ -32,4 +32,17 @@ type PortalLifecycleHook = () => [
|
|
|
32
32
|
*/
|
|
33
33
|
export declare const usePortalsLifecycle: PortalLifecycleHook;
|
|
34
34
|
export declare function isReactComponent(component: any): boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Creates the instance once and keeps it across effect cleanups that are not
|
|
37
|
+
* unmounts (`<Activity mode="hidden">`, StrictMode). A real unmount removes the
|
|
38
|
+
* host before cleanup, so a still-connected host means hidden; the instance is
|
|
39
|
+
* then disposed only if the host later leaves the document.
|
|
40
|
+
*/
|
|
41
|
+
export declare function useKeptInstance<T extends DockviewIDisposable>(domRef: React.RefObject<HTMLElement | null>, instanceRef: React.MutableRefObject<T | undefined>, create: (element: HTMLElement) => T): void;
|
|
42
|
+
/**
|
|
43
|
+
* Returns a check for option effects: true when the instance already holds the
|
|
44
|
+
* given values. The first values seen count as applied, since the instance was
|
|
45
|
+
* created from them, so effect replays skip redundant `updateOptions` calls.
|
|
46
|
+
*/
|
|
47
|
+
export declare function useAppliedOptions(instanceRef: React.RefObject<unknown>): (values: Record<string, unknown>) => boolean;
|
|
35
48
|
export {};
|
package/dist/dockview-react.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* dockview-react
|
|
3
|
-
* @version 8.
|
|
3
|
+
* @version 8.5.0
|
|
4
4
|
* @link https://github.com/dockview/dockview
|
|
5
5
|
* @license MIT
|
|
6
6
|
*/
|
|
@@ -51,7 +51,7 @@ react_dom = __toESM(react_dom);
|
|
|
51
51
|
//#region ../dockview-core/dist/package/main.esm.mjs
|
|
52
52
|
/**
|
|
53
53
|
* dockview-core
|
|
54
|
-
* @version 8.
|
|
54
|
+
* @version 8.5.0
|
|
55
55
|
* @link https://github.com/dockview/dockview
|
|
56
56
|
* @license MIT
|
|
57
57
|
*/
|
|
@@ -5996,24 +5996,25 @@ react_dom = __toESM(react_dom);
|
|
|
5996
5996
|
else this._element.removeAttribute("aria-labelledby");
|
|
5997
5997
|
}
|
|
5998
5998
|
renderPanel(panel, options) {
|
|
5999
|
-
var _options$asActive
|
|
6000
|
-
const doRender = ((_options$asActive = options === null || options === void 0 ? void 0 : options.asActive) !== null && _options$asActive !== void 0 ? _options$asActive : true) || this.
|
|
6001
|
-
if (
|
|
6002
|
-
var _this$panel
|
|
6003
|
-
this.panel.view.content.element.
|
|
6004
|
-
|
|
5999
|
+
var _options$asActive;
|
|
6000
|
+
const doRender = ((_options$asActive = options === null || options === void 0 ? void 0 : options.asActive) !== null && _options$asActive !== void 0 ? _options$asActive : true) || this.group.isPanelActive(panel);
|
|
6001
|
+
if (doRender || this.panel === panel) {
|
|
6002
|
+
var _this$panel;
|
|
6003
|
+
if (((_this$panel = this.panel) === null || _this$panel === void 0 ? void 0 : _this$panel.view.content.element.parentElement) === this._element) {
|
|
6004
|
+
var _this$panel$view$cont, _this$panel$view$cont2;
|
|
6005
|
+
this.panel.view.content.element.remove();
|
|
6006
|
+
(_this$panel$view$cont = (_this$panel$view$cont2 = this.panel.view.content).onHide) === null || _this$panel$view$cont === void 0 || _this$panel$view$cont.call(_this$panel$view$cont2);
|
|
6007
|
+
}
|
|
6008
|
+
this.panel = panel;
|
|
6005
6009
|
}
|
|
6006
|
-
this.panel = panel;
|
|
6007
6010
|
let container;
|
|
6008
6011
|
switch (panel.api.renderer) {
|
|
6009
6012
|
case "onlyWhenVisible":
|
|
6010
6013
|
this.group.renderContainer.detatch(panel);
|
|
6011
|
-
if (
|
|
6012
|
-
|
|
6013
|
-
|
|
6014
|
-
|
|
6015
|
-
(_this$panel$view$cont3 = (_this$panel$view$cont4 = this.panel.view.content).onShow) === null || _this$panel$view$cont3 === void 0 || _this$panel$view$cont3.call(_this$panel$view$cont4);
|
|
6016
|
-
}
|
|
6014
|
+
if (doRender) {
|
|
6015
|
+
var _panel$view$content$o, _panel$view$content;
|
|
6016
|
+
this._element.appendChild(panel.view.content.element);
|
|
6017
|
+
(_panel$view$content$o = (_panel$view$content = panel.view.content).onShow) === null || _panel$view$content$o === void 0 || _panel$view$content$o.call(_panel$view$content);
|
|
6017
6018
|
}
|
|
6018
6019
|
container = this._element;
|
|
6019
6020
|
break;
|
|
@@ -6042,9 +6043,9 @@ react_dom = __toESM(react_dom);
|
|
|
6042
6043
|
closePanel() {
|
|
6043
6044
|
if (this.panel) {
|
|
6044
6045
|
if (this.panel.api.renderer === "onlyWhenVisible") {
|
|
6045
|
-
var _this$panel$view$
|
|
6046
|
+
var _this$panel$view$cont3, _this$panel$view$cont4;
|
|
6046
6047
|
this.panel.view.content.element.remove();
|
|
6047
|
-
(_this$panel$view$
|
|
6048
|
+
(_this$panel$view$cont3 = (_this$panel$view$cont4 = this.panel.view.content).onHide) === null || _this$panel$view$cont3 === void 0 || _this$panel$view$cont3.call(_this$panel$view$cont4);
|
|
6048
6049
|
}
|
|
6049
6050
|
}
|
|
6050
6051
|
this.panel = void 0;
|
|
@@ -11019,7 +11020,6 @@ react_dom = __toESM(react_dom);
|
|
|
11019
11020
|
this.rerender(panel);
|
|
11020
11021
|
});
|
|
11021
11022
|
if (this._activePanel) {
|
|
11022
|
-
this.contentContainer.renderPanel(this._activePanel, { asActive: true });
|
|
11023
11023
|
const { width, height } = this.contentDimensions();
|
|
11024
11024
|
this._activePanel.layout(width, height);
|
|
11025
11025
|
}
|
|
@@ -19700,6 +19700,87 @@ react_dom = __toESM(react_dom);
|
|
|
19700
19700
|
*/
|
|
19701
19701
|
return typeof component === "function" || !!(component === null || component === void 0 ? void 0 : component.$$typeof);
|
|
19702
19702
|
}
|
|
19703
|
+
/**
|
|
19704
|
+
* Calls `onRemoved` once `element` leaves the document. Only its ancestors are
|
|
19705
|
+
* observed, since any removal above it is a child-list change on one of them.
|
|
19706
|
+
*/
|
|
19707
|
+
function watchForRemoval(element, onRemoved) {
|
|
19708
|
+
const parentOf = (node) => node instanceof ShadowRoot ? node.host : node.parentNode;
|
|
19709
|
+
const ancestors = /* @__PURE__ */ new Set();
|
|
19710
|
+
const observer = new MutationObserver((records) => {
|
|
19711
|
+
if (!element.isConnected) {
|
|
19712
|
+
observer.disconnect();
|
|
19713
|
+
onRemoved();
|
|
19714
|
+
return;
|
|
19715
|
+
}
|
|
19716
|
+
for (const record of records) for (const node of record.removedNodes) if (ancestors.has(node)) {
|
|
19717
|
+
observeAncestors();
|
|
19718
|
+
return;
|
|
19719
|
+
}
|
|
19720
|
+
});
|
|
19721
|
+
const observeAncestors = () => {
|
|
19722
|
+
observer.disconnect();
|
|
19723
|
+
ancestors.clear();
|
|
19724
|
+
for (let node = parentOf(element); node; node = parentOf(node)) {
|
|
19725
|
+
ancestors.add(node);
|
|
19726
|
+
observer.observe(node, { childList: true });
|
|
19727
|
+
}
|
|
19728
|
+
};
|
|
19729
|
+
observeAncestors();
|
|
19730
|
+
return Disposable.from(() => observer.disconnect());
|
|
19731
|
+
}
|
|
19732
|
+
const canHideWithoutUnmount = Number.parseInt(react.default.version, 10) >= 18;
|
|
19733
|
+
/**
|
|
19734
|
+
* Creates the instance once and keeps it across effect cleanups that are not
|
|
19735
|
+
* unmounts (`<Activity mode="hidden">`, StrictMode). A real unmount removes the
|
|
19736
|
+
* host before cleanup, so a still-connected host means hidden; the instance is
|
|
19737
|
+
* then disposed only if the host later leaves the document.
|
|
19738
|
+
*/
|
|
19739
|
+
function useKeptInstance(domRef, instanceRef, create) {
|
|
19740
|
+
const removalWatcher = react.default.useRef(void 0);
|
|
19741
|
+
react.default.useEffect(() => {
|
|
19742
|
+
var _removalWatcher$curre, _instanceRef$current;
|
|
19743
|
+
const element = domRef.current;
|
|
19744
|
+
if (!element) return;
|
|
19745
|
+
(_removalWatcher$curre = removalWatcher.current) === null || _removalWatcher$curre === void 0 || _removalWatcher$curre.dispose();
|
|
19746
|
+
removalWatcher.current = void 0;
|
|
19747
|
+
const instance = (_instanceRef$current = instanceRef.current) !== null && _instanceRef$current !== void 0 ? _instanceRef$current : create(element);
|
|
19748
|
+
instanceRef.current = instance;
|
|
19749
|
+
return () => {
|
|
19750
|
+
const dispose = () => {
|
|
19751
|
+
removalWatcher.current = void 0;
|
|
19752
|
+
instanceRef.current = void 0;
|
|
19753
|
+
instance.dispose();
|
|
19754
|
+
};
|
|
19755
|
+
if (canHideWithoutUnmount && element.isConnected && typeof MutationObserver !== "undefined") removalWatcher.current = watchForRemoval(element, dispose);
|
|
19756
|
+
else dispose();
|
|
19757
|
+
};
|
|
19758
|
+
}, []);
|
|
19759
|
+
}
|
|
19760
|
+
/**
|
|
19761
|
+
* Returns a check for option effects: true when the instance already holds the
|
|
19762
|
+
* given values. The first values seen count as applied, since the instance was
|
|
19763
|
+
* created from them, so effect replays skip redundant `updateOptions` calls.
|
|
19764
|
+
*/
|
|
19765
|
+
function useAppliedOptions(instanceRef) {
|
|
19766
|
+
const applied = react.default.useRef({
|
|
19767
|
+
instance: void 0,
|
|
19768
|
+
values: /* @__PURE__ */ new Map()
|
|
19769
|
+
});
|
|
19770
|
+
return react.default.useCallback((values) => {
|
|
19771
|
+
if (applied.current.instance !== instanceRef.current) applied.current = {
|
|
19772
|
+
instance: instanceRef.current,
|
|
19773
|
+
values: /* @__PURE__ */ new Map()
|
|
19774
|
+
};
|
|
19775
|
+
const known = applied.current.values;
|
|
19776
|
+
let unchanged = true;
|
|
19777
|
+
for (const [key, value] of Object.entries(values)) {
|
|
19778
|
+
if (known.has(key) && known.get(key) !== value) unchanged = false;
|
|
19779
|
+
known.set(key, value);
|
|
19780
|
+
}
|
|
19781
|
+
return unchanged;
|
|
19782
|
+
}, [instanceRef]);
|
|
19783
|
+
}
|
|
19703
19784
|
|
|
19704
19785
|
//#endregion
|
|
19705
19786
|
//#region src/dockview/reactContentPart.ts
|
|
@@ -19971,6 +20052,7 @@ react_dom = __toESM(react_dom);
|
|
|
19971
20052
|
const domRef = react.default.useRef(null);
|
|
19972
20053
|
const dockviewRef = react.default.useRef(void 0);
|
|
19973
20054
|
const [portals, addPortal] = usePortalsLifecycle();
|
|
20055
|
+
const isApplied = useAppliedOptions(dockviewRef);
|
|
19974
20056
|
react.default.useImperativeHandle(ref, () => domRef.current, []);
|
|
19975
20057
|
const prevProps = react.default.useRef({});
|
|
19976
20058
|
react.default.useEffect(() => {
|
|
@@ -19980,11 +20062,10 @@ react_dom = __toESM(react_dom);
|
|
|
19980
20062
|
const propValue = props[key];
|
|
19981
20063
|
if (key in props && propValue !== prevProps.current[key]) changes[key] = propValue;
|
|
19982
20064
|
});
|
|
19983
|
-
if (dockviewRef.current) dockviewRef.current.updateOptions(changes);
|
|
20065
|
+
if (dockviewRef.current && Object.keys(changes).length > 0) dockviewRef.current.updateOptions(changes);
|
|
19984
20066
|
prevProps.current = props;
|
|
19985
20067
|
}, PROPERTY_KEYS_DOCKVIEW.map((key) => props[key]));
|
|
19986
|
-
|
|
19987
|
-
if (!domRef.current) return;
|
|
20068
|
+
useKeptInstance(domRef, dockviewRef, (element) => {
|
|
19988
20069
|
const frameworkTabComponents = _objectSpread2({}, props.tabComponents);
|
|
19989
20070
|
if (props.defaultTabComponent) frameworkTabComponents[DEFAULT_REACT_TAB] = props.defaultTabComponent;
|
|
19990
20071
|
const frameworkOptions = {
|
|
@@ -20019,16 +20100,12 @@ react_dom = __toESM(react_dom);
|
|
|
20019
20100
|
return new ReactGroupDragGhostPart(ghostComponent, { addPortal });
|
|
20020
20101
|
};
|
|
20021
20102
|
}
|
|
20022
|
-
const api = createDockview(
|
|
20023
|
-
const { clientWidth, clientHeight } =
|
|
20103
|
+
const api = createDockview(element, _objectSpread2(_objectSpread2({}, coreOptions), frameworkOptions));
|
|
20104
|
+
const { clientWidth, clientHeight } = element;
|
|
20024
20105
|
api.layout(clientWidth, clientHeight);
|
|
20025
20106
|
if (props.onReady) props.onReady({ api });
|
|
20026
|
-
|
|
20027
|
-
|
|
20028
|
-
dockviewRef.current = void 0;
|
|
20029
|
-
api.dispose();
|
|
20030
|
-
};
|
|
20031
|
-
}, []);
|
|
20107
|
+
return api;
|
|
20108
|
+
});
|
|
20032
20109
|
react.default.useEffect(() => {
|
|
20033
20110
|
if (!dockviewRef.current) return () => {};
|
|
20034
20111
|
const disposable = dockviewRef.current.onDidDrop((event) => {
|
|
@@ -20048,25 +20125,28 @@ react_dom = __toESM(react_dom);
|
|
|
20048
20125
|
};
|
|
20049
20126
|
}, [props.onWillDrop]);
|
|
20050
20127
|
react.default.useEffect(() => {
|
|
20051
|
-
if (!dockviewRef.current) return;
|
|
20128
|
+
if (!dockviewRef.current || isApplied({ tabGroupChipComponent: props.tabGroupChipComponent })) return;
|
|
20052
20129
|
dockviewRef.current.updateOptions({ createTabGroupChipComponent: props.tabGroupChipComponent ? () => {
|
|
20053
20130
|
return new ReactTabGroupChipPart(props.tabGroupChipComponent, { addPortal });
|
|
20054
20131
|
} : void 0 });
|
|
20055
20132
|
}, [props.tabGroupChipComponent]);
|
|
20056
20133
|
react.default.useEffect(() => {
|
|
20057
|
-
if (!dockviewRef.current) return;
|
|
20134
|
+
if (!dockviewRef.current || isApplied({ groupDragGhostComponent: props.groupDragGhostComponent })) return;
|
|
20058
20135
|
dockviewRef.current.updateOptions({ createGroupDragGhostComponent: props.groupDragGhostComponent ? () => {
|
|
20059
20136
|
return new ReactGroupDragGhostPart(props.groupDragGhostComponent, { addPortal });
|
|
20060
20137
|
} : void 0 });
|
|
20061
20138
|
}, [props.groupDragGhostComponent]);
|
|
20062
20139
|
react.default.useEffect(() => {
|
|
20063
|
-
if (!dockviewRef.current) return;
|
|
20140
|
+
if (!dockviewRef.current || isApplied({ components: props.components })) return;
|
|
20064
20141
|
dockviewRef.current.updateOptions({ createComponent: (options) => {
|
|
20065
20142
|
return new ReactPanelContentPart(options.id, props.components[options.name], { addPortal });
|
|
20066
20143
|
} });
|
|
20067
20144
|
}, [props.components]);
|
|
20068
20145
|
react.default.useEffect(() => {
|
|
20069
|
-
if (!dockviewRef.current
|
|
20146
|
+
if (!dockviewRef.current || isApplied({
|
|
20147
|
+
tabComponents: props.tabComponents,
|
|
20148
|
+
defaultTabComponent: props.defaultTabComponent
|
|
20149
|
+
})) return;
|
|
20070
20150
|
const frameworkTabComponents = _objectSpread2({}, props.tabComponents);
|
|
20071
20151
|
if (props.defaultTabComponent) frameworkTabComponents[DEFAULT_REACT_TAB] = props.defaultTabComponent;
|
|
20072
20152
|
dockviewRef.current.updateOptions({
|
|
@@ -20077,21 +20157,21 @@ react_dom = __toESM(react_dom);
|
|
|
20077
20157
|
});
|
|
20078
20158
|
}, [props.tabComponents, props.defaultTabComponent]);
|
|
20079
20159
|
react.default.useEffect(() => {
|
|
20080
|
-
if (!dockviewRef.current) return;
|
|
20160
|
+
if (!dockviewRef.current || isApplied({ watermarkComponent: props.watermarkComponent })) return;
|
|
20081
20161
|
dockviewRef.current.updateOptions({ createWatermarkComponent: props.watermarkComponent ? () => {
|
|
20082
20162
|
return new ReactWatermarkPart("watermark", props.watermarkComponent, { addPortal });
|
|
20083
20163
|
} : void 0 });
|
|
20084
20164
|
}, [props.watermarkComponent]);
|
|
20085
20165
|
react.default.useEffect(() => {
|
|
20086
|
-
if (!dockviewRef.current) return;
|
|
20166
|
+
if (!dockviewRef.current || isApplied({ rightHeaderActionsComponent: props.rightHeaderActionsComponent })) return;
|
|
20087
20167
|
dockviewRef.current.updateOptions({ createRightHeaderActionComponent: createGroupControlElement(props.rightHeaderActionsComponent, { addPortal }) });
|
|
20088
20168
|
}, [props.rightHeaderActionsComponent]);
|
|
20089
20169
|
react.default.useEffect(() => {
|
|
20090
|
-
if (!dockviewRef.current) return;
|
|
20170
|
+
if (!dockviewRef.current || isApplied({ leftHeaderActionsComponent: props.leftHeaderActionsComponent })) return;
|
|
20091
20171
|
dockviewRef.current.updateOptions({ createLeftHeaderActionComponent: createGroupControlElement(props.leftHeaderActionsComponent, { addPortal }) });
|
|
20092
20172
|
}, [props.leftHeaderActionsComponent]);
|
|
20093
20173
|
react.default.useEffect(() => {
|
|
20094
|
-
if (!dockviewRef.current) return;
|
|
20174
|
+
if (!dockviewRef.current || isApplied({ prefixHeaderActionsComponent: props.prefixHeaderActionsComponent })) return;
|
|
20095
20175
|
dockviewRef.current.updateOptions({ createPrefixHeaderActionComponent: createGroupControlElement(props.prefixHeaderActionsComponent, { addPortal }) });
|
|
20096
20176
|
}, [props.prefixHeaderActionsComponent]);
|
|
20097
20177
|
return /* @__PURE__ */ react.default.createElement("div", {
|
|
@@ -20262,6 +20342,7 @@ react_dom = __toESM(react_dom);
|
|
|
20262
20342
|
const domRef = react.default.useRef(null);
|
|
20263
20343
|
const splitviewRef = react.default.useRef(void 0);
|
|
20264
20344
|
const [portals, addPortal] = usePortalsLifecycle();
|
|
20345
|
+
const isApplied = useAppliedOptions(splitviewRef);
|
|
20265
20346
|
react.default.useImperativeHandle(ref, () => domRef.current, []);
|
|
20266
20347
|
const prevProps = react.default.useRef({});
|
|
20267
20348
|
react.default.useEffect(() => {
|
|
@@ -20271,25 +20352,20 @@ react_dom = __toESM(react_dom);
|
|
|
20271
20352
|
const propValue = props[key];
|
|
20272
20353
|
if (key in props && propValue !== prevProps.current[key]) changes[key] = propValue;
|
|
20273
20354
|
});
|
|
20274
|
-
if (splitviewRef.current) splitviewRef.current.updateOptions(changes);
|
|
20355
|
+
if (splitviewRef.current && Object.keys(changes).length > 0) splitviewRef.current.updateOptions(changes);
|
|
20275
20356
|
prevProps.current = props;
|
|
20276
20357
|
}, PROPERTY_KEYS_SPLITVIEW.map((key) => props[key]));
|
|
20277
|
-
|
|
20278
|
-
|
|
20279
|
-
const api = createSplitview(domRef.current, _objectSpread2(_objectSpread2({}, extractCoreOptions$2(props)), { createComponent: (options) => {
|
|
20358
|
+
useKeptInstance(domRef, splitviewRef, (element) => {
|
|
20359
|
+
const api = createSplitview(element, _objectSpread2(_objectSpread2({}, extractCoreOptions$2(props)), { createComponent: (options) => {
|
|
20280
20360
|
return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
20281
20361
|
} }));
|
|
20282
|
-
const { clientWidth, clientHeight } =
|
|
20362
|
+
const { clientWidth, clientHeight } = element;
|
|
20283
20363
|
api.layout(clientWidth, clientHeight);
|
|
20284
20364
|
if (props.onReady) props.onReady({ api });
|
|
20285
|
-
|
|
20286
|
-
|
|
20287
|
-
splitviewRef.current = void 0;
|
|
20288
|
-
api.dispose();
|
|
20289
|
-
};
|
|
20290
|
-
}, []);
|
|
20365
|
+
return api;
|
|
20366
|
+
});
|
|
20291
20367
|
react.default.useEffect(() => {
|
|
20292
|
-
if (!splitviewRef.current) return;
|
|
20368
|
+
if (!splitviewRef.current || isApplied({ components: props.components })) return;
|
|
20293
20369
|
splitviewRef.current.updateOptions({ createComponent: (options) => {
|
|
20294
20370
|
return new ReactPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
20295
20371
|
} });
|
|
@@ -20334,6 +20410,7 @@ react_dom = __toESM(react_dom);
|
|
|
20334
20410
|
const domRef = react.default.useRef(null);
|
|
20335
20411
|
const gridviewRef = react.default.useRef(void 0);
|
|
20336
20412
|
const [portals, addPortal] = usePortalsLifecycle();
|
|
20413
|
+
const isApplied = useAppliedOptions(gridviewRef);
|
|
20337
20414
|
react.default.useImperativeHandle(ref, () => domRef.current, []);
|
|
20338
20415
|
const prevProps = react.default.useRef({});
|
|
20339
20416
|
react.default.useEffect(() => {
|
|
@@ -20343,25 +20420,20 @@ react_dom = __toESM(react_dom);
|
|
|
20343
20420
|
const propValue = props[key];
|
|
20344
20421
|
if (key in props && propValue !== prevProps.current[key]) changes[key] = propValue;
|
|
20345
20422
|
});
|
|
20346
|
-
if (gridviewRef.current) gridviewRef.current.updateOptions(changes);
|
|
20423
|
+
if (gridviewRef.current && Object.keys(changes).length > 0) gridviewRef.current.updateOptions(changes);
|
|
20347
20424
|
prevProps.current = props;
|
|
20348
20425
|
}, PROPERTY_KEYS_GRIDVIEW.map((key) => props[key]));
|
|
20349
|
-
|
|
20350
|
-
|
|
20351
|
-
const api = createGridview(domRef.current, _objectSpread2(_objectSpread2({}, extractCoreOptions$1(props)), { createComponent: (options) => {
|
|
20426
|
+
useKeptInstance(domRef, gridviewRef, (element) => {
|
|
20427
|
+
const api = createGridview(element, _objectSpread2(_objectSpread2({}, extractCoreOptions$1(props)), { createComponent: (options) => {
|
|
20352
20428
|
return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
20353
20429
|
} }));
|
|
20354
|
-
const { clientWidth, clientHeight } =
|
|
20430
|
+
const { clientWidth, clientHeight } = element;
|
|
20355
20431
|
api.layout(clientWidth, clientHeight);
|
|
20356
20432
|
if (props.onReady) props.onReady({ api });
|
|
20357
|
-
|
|
20358
|
-
|
|
20359
|
-
gridviewRef.current = void 0;
|
|
20360
|
-
api.dispose();
|
|
20361
|
-
};
|
|
20362
|
-
}, []);
|
|
20433
|
+
return api;
|
|
20434
|
+
});
|
|
20363
20435
|
react.default.useEffect(() => {
|
|
20364
|
-
if (!gridviewRef.current) return;
|
|
20436
|
+
if (!gridviewRef.current || isApplied({ components: props.components })) return;
|
|
20365
20437
|
gridviewRef.current.updateOptions({ createComponent: (options) => {
|
|
20366
20438
|
return new ReactGridPanelView(options.id, options.name, props.components[options.name], { addPortal });
|
|
20367
20439
|
} });
|
|
@@ -20423,6 +20495,7 @@ react_dom = __toESM(react_dom);
|
|
|
20423
20495
|
const domRef = react.default.useRef(null);
|
|
20424
20496
|
const paneviewRef = react.default.useRef(void 0);
|
|
20425
20497
|
const [portals, addPortal] = usePortalsLifecycle();
|
|
20498
|
+
const isApplied = useAppliedOptions(paneviewRef);
|
|
20426
20499
|
react.default.useImperativeHandle(ref, () => domRef.current, []);
|
|
20427
20500
|
const prevProps = react.default.useRef({});
|
|
20428
20501
|
react.default.useEffect(() => {
|
|
@@ -20432,14 +20505,13 @@ react_dom = __toESM(react_dom);
|
|
|
20432
20505
|
const propValue = props[key];
|
|
20433
20506
|
if (key in props && propValue !== prevProps.current[key]) changes[key] = propValue;
|
|
20434
20507
|
});
|
|
20435
|
-
if (paneviewRef.current) paneviewRef.current.updateOptions(changes);
|
|
20508
|
+
if (paneviewRef.current && Object.keys(changes).length > 0) paneviewRef.current.updateOptions(changes);
|
|
20436
20509
|
prevProps.current = props;
|
|
20437
20510
|
}, PROPERTY_KEYS_PANEVIEW.map((key) => props[key]));
|
|
20438
|
-
|
|
20511
|
+
useKeptInstance(domRef, paneviewRef, (element) => {
|
|
20439
20512
|
var _props$headerComponen;
|
|
20440
|
-
if (!domRef.current) return () => {};
|
|
20441
20513
|
const headerComponents = (_props$headerComponen = props.headerComponents) !== null && _props$headerComponen !== void 0 ? _props$headerComponen : {};
|
|
20442
|
-
const api = createPaneview(
|
|
20514
|
+
const api = createPaneview(element, _objectSpread2(_objectSpread2({}, extractCoreOptions(props)), {
|
|
20443
20515
|
createComponent: (options) => {
|
|
20444
20516
|
return new PanePanelSection(options.id, props.components[options.name], { addPortal });
|
|
20445
20517
|
},
|
|
@@ -20447,24 +20519,20 @@ react_dom = __toESM(react_dom);
|
|
|
20447
20519
|
return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
|
|
20448
20520
|
}
|
|
20449
20521
|
}));
|
|
20450
|
-
const { clientWidth, clientHeight } =
|
|
20522
|
+
const { clientWidth, clientHeight } = element;
|
|
20451
20523
|
api.layout(clientWidth, clientHeight);
|
|
20452
20524
|
if (props.onReady) props.onReady({ api });
|
|
20453
|
-
|
|
20454
|
-
|
|
20455
|
-
paneviewRef.current = void 0;
|
|
20456
|
-
api.dispose();
|
|
20457
|
-
};
|
|
20458
|
-
}, []);
|
|
20525
|
+
return api;
|
|
20526
|
+
});
|
|
20459
20527
|
react.default.useEffect(() => {
|
|
20460
|
-
if (!paneviewRef.current) return;
|
|
20528
|
+
if (!paneviewRef.current || isApplied({ components: props.components })) return;
|
|
20461
20529
|
paneviewRef.current.updateOptions({ createComponent: (options) => {
|
|
20462
20530
|
return new PanePanelSection(options.id, props.components[options.name], { addPortal });
|
|
20463
20531
|
} });
|
|
20464
20532
|
}, [props.components]);
|
|
20465
20533
|
react.default.useEffect(() => {
|
|
20466
20534
|
var _props$headerComponen2;
|
|
20467
|
-
if (!paneviewRef.current) return;
|
|
20535
|
+
if (!paneviewRef.current || isApplied({ headerComponents: props.headerComponents })) return;
|
|
20468
20536
|
const headerComponents = (_props$headerComponen2 = props.headerComponents) !== null && _props$headerComponen2 !== void 0 ? _props$headerComponen2 : {};
|
|
20469
20537
|
paneviewRef.current.updateOptions({ createHeaderComponent: (options) => {
|
|
20470
20538
|
return new PanePanelSection(options.id, headerComponents[options.name], { addPortal });
|
|
@@ -20628,5 +20696,7 @@ exports.themeSolarizedLight = themeSolarizedLight;
|
|
|
20628
20696
|
exports.themeSolarizedLightSpaced = themeSolarizedLightSpaced;
|
|
20629
20697
|
exports.themeVisualStudio = themeVisualStudio;
|
|
20630
20698
|
exports.toTarget = toTarget;
|
|
20699
|
+
exports.useAppliedOptions = useAppliedOptions;
|
|
20700
|
+
exports.useKeptInstance = useKeptInstance;
|
|
20631
20701
|
exports.usePortalsLifecycle = usePortalsLifecycle;
|
|
20632
20702
|
});
|