Comparing version 3.0.4 to 3.0.5
@@ -134,3 +134,8 @@ import React, { CSSProperties } from "react"; | ||
componentWillUnmount(): void; | ||
/** @ignore | ||
* layout state doesn't change instantly after setState, use this to make sure the correct layout is | ||
*/ | ||
tempLayout: LayoutData; | ||
setLayout(layout: LayoutData): void; | ||
getLayout(): LayoutData; | ||
/** @ignore | ||
@@ -137,0 +142,0 @@ * change layout |
@@ -94,3 +94,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
this._onWindowResize = debounce(() => { | ||
let layout = this.tempLayout || this.state.layout; | ||
let layout = this.getLayout(); | ||
if (this._ref) { | ||
@@ -162,3 +162,3 @@ let newLayout = Algorithm.fixFloatPanelPos(layout, this._ref.offsetWidth, this._ref.offsetHeight); | ||
dockMove(source, target, direction) { | ||
let layout = this.tempLayout || this.state.layout; | ||
let layout = this.getLayout(); | ||
if (direction === 'maximize') { | ||
@@ -217,3 +217,3 @@ layout = Algorithm.maximize(layout, source); | ||
} | ||
if (layout !== this.state.layout) { | ||
if (layout !== this.getLayout()) { | ||
layout = Algorithm.fixLayoutData(layout); | ||
@@ -236,3 +236,3 @@ let currentTabId = null; | ||
find(id, filter) { | ||
return Algorithm.find(this.tempLayout || this.state.layout, id, filter); | ||
return Algorithm.find(this.getLayout(), id, filter); | ||
} | ||
@@ -257,3 +257,3 @@ /** @ignore */ | ||
} | ||
let { layout } = this.state; | ||
let layout = this.getLayout(); | ||
layout = Algorithm.removeFromLayout(layout, tab); // remove old tab | ||
@@ -263,3 +263,3 @@ panelData = Algorithm.getUpdatedObject(panelData); // panelData might change during removeTab | ||
layout = Algorithm.fixLayoutData(layout); | ||
this.setState({ layout }); | ||
this.changeLayout(layout, newTab.id); | ||
return true; | ||
@@ -383,2 +383,9 @@ } | ||
} | ||
setLayout(layout) { | ||
this.tempLayout = layout; | ||
this.setState({ layout }); | ||
} | ||
getLayout() { | ||
return this.tempLayout || this.state.layout; | ||
} | ||
/** @ignore | ||
@@ -397,4 +404,3 @@ * change layout | ||
// uncontrolled layout when Props.layout is not defined | ||
this.tempLayout = layoutData; | ||
this.setState({ layout: layoutData }); | ||
this.setLayout(layoutData); | ||
} | ||
@@ -409,3 +415,3 @@ } | ||
if (onLayoutChange) { | ||
let layout = this.tempLayout || this.state.layout; | ||
let layout = this.getLayout(); | ||
let savedLayout = Serializer.saveLayoutData(layout, this.props.saveTab, this.props.afterPanelSaved); | ||
@@ -418,3 +424,3 @@ layout.loadedFrom = savedLayout; | ||
saveLayout() { | ||
return Serializer.saveLayoutData(this.tempLayout || this.state.layout, this.props.saveTab, this.props.afterPanelSaved); | ||
return Serializer.saveLayoutData(this.getLayout(), this.props.saveTab, this.props.afterPanelSaved); | ||
} | ||
@@ -427,3 +433,3 @@ /** | ||
let { defaultLayout, loadTab, afterPanelLoaded } = this.props; | ||
this.setState({ layout: DockLayout.loadLayoutData(savedLayout, this.props, this._ref.offsetWidth, this._ref.offsetHeight) }); | ||
this.setLayout(DockLayout.loadLayoutData(savedLayout, this.props, this._ref.offsetWidth, this._ref.offsetHeight)); | ||
} | ||
@@ -430,0 +436,0 @@ /** @ignore */ |
@@ -134,7 +134,8 @@ import React from "react"; | ||
} | ||
let tab = (React.createElement("div", { ref: this.getRef }, | ||
let tab = (React.createElement(DragDropDiv, { getRef: this.getRef, onDragStartT: onDragStart, onDragOverT: onDragOver, onDropT: onDrop, onDragLeaveT: onDragLeave }, | ||
React.createElement("div", { className: 'dock-tab-hit-area', ref: this.getHitAreaRef }), | ||
title, | ||
React.createElement(DragDropDiv, { className: 'dock-tab-hit-area', getRef: this.getHitAreaRef, onDragStartT: onDragStart, onDragOverT: onDragOver, onDropT: onDrop, onDragLeaveT: onDragLeave }, closable ? | ||
closable ? | ||
React.createElement("div", { className: 'dock-tab-close-btn', onClick: this.onCloseClick, onKeyDown: this.onKeyDownCloseBtn, tabIndex: 0 }) | ||
: null))); | ||
: null)); | ||
return (React.createElement(DockTabPane, { key: id, cacheId: id, cached: cached, tab: tab }, content)); | ||
@@ -141,0 +142,0 @@ } |
# History | ||
---- | ||
## 3.0.5 / 2021-03-08 | ||
- allow mouse event handler on tab title | ||
- fix the issue that calling updateTab() doesn't trigger onLayoutChange #71 | ||
## 3.0.2 / 2021-02-06 | ||
@@ -5,0 +9,0 @@ - fix serialization of popup window |
@@ -134,3 +134,8 @@ import React, { CSSProperties } from "react"; | ||
componentWillUnmount(): void; | ||
/** @ignore | ||
* layout state doesn't change instantly after setState, use this to make sure the correct layout is | ||
*/ | ||
tempLayout: LayoutData; | ||
setLayout(layout: LayoutData): void; | ||
getLayout(): LayoutData; | ||
/** @ignore | ||
@@ -137,0 +142,0 @@ * change layout |
@@ -119,3 +119,3 @@ "use strict"; | ||
this._onWindowResize = debounce_1.default(() => { | ||
let layout = this.tempLayout || this.state.layout; | ||
let layout = this.getLayout(); | ||
if (this._ref) { | ||
@@ -187,3 +187,3 @@ let newLayout = Algorithm.fixFloatPanelPos(layout, this._ref.offsetWidth, this._ref.offsetHeight); | ||
dockMove(source, target, direction) { | ||
let layout = this.tempLayout || this.state.layout; | ||
let layout = this.getLayout(); | ||
if (direction === 'maximize') { | ||
@@ -242,3 +242,3 @@ layout = Algorithm.maximize(layout, source); | ||
} | ||
if (layout !== this.state.layout) { | ||
if (layout !== this.getLayout()) { | ||
layout = Algorithm.fixLayoutData(layout); | ||
@@ -261,3 +261,3 @@ let currentTabId = null; | ||
find(id, filter) { | ||
return Algorithm.find(this.tempLayout || this.state.layout, id, filter); | ||
return Algorithm.find(this.getLayout(), id, filter); | ||
} | ||
@@ -282,3 +282,3 @@ /** @ignore */ | ||
} | ||
let { layout } = this.state; | ||
let layout = this.getLayout(); | ||
layout = Algorithm.removeFromLayout(layout, tab); // remove old tab | ||
@@ -288,3 +288,3 @@ panelData = Algorithm.getUpdatedObject(panelData); // panelData might change during removeTab | ||
layout = Algorithm.fixLayoutData(layout); | ||
this.setState({ layout }); | ||
this.changeLayout(layout, newTab.id); | ||
return true; | ||
@@ -408,2 +408,9 @@ } | ||
} | ||
setLayout(layout) { | ||
this.tempLayout = layout; | ||
this.setState({ layout }); | ||
} | ||
getLayout() { | ||
return this.tempLayout || this.state.layout; | ||
} | ||
/** @ignore | ||
@@ -422,4 +429,3 @@ * change layout | ||
// uncontrolled layout when Props.layout is not defined | ||
this.tempLayout = layoutData; | ||
this.setState({ layout: layoutData }); | ||
this.setLayout(layoutData); | ||
} | ||
@@ -434,3 +440,3 @@ } | ||
if (onLayoutChange) { | ||
let layout = this.tempLayout || this.state.layout; | ||
let layout = this.getLayout(); | ||
let savedLayout = Serializer.saveLayoutData(layout, this.props.saveTab, this.props.afterPanelSaved); | ||
@@ -443,3 +449,3 @@ layout.loadedFrom = savedLayout; | ||
saveLayout() { | ||
return Serializer.saveLayoutData(this.tempLayout || this.state.layout, this.props.saveTab, this.props.afterPanelSaved); | ||
return Serializer.saveLayoutData(this.getLayout(), this.props.saveTab, this.props.afterPanelSaved); | ||
} | ||
@@ -452,3 +458,3 @@ /** | ||
let { defaultLayout, loadTab, afterPanelLoaded } = this.props; | ||
this.setState({ layout: DockLayout.loadLayoutData(savedLayout, this.props, this._ref.offsetWidth, this._ref.offsetHeight) }); | ||
this.setLayout(DockLayout.loadLayoutData(savedLayout, this.props, this._ref.offsetWidth, this._ref.offsetHeight)); | ||
} | ||
@@ -455,0 +461,0 @@ /** @ignore */ |
@@ -159,7 +159,8 @@ "use strict"; | ||
} | ||
let tab = (react_1.default.createElement("div", { ref: this.getRef }, | ||
let tab = (react_1.default.createElement(DragDropDiv_1.DragDropDiv, { getRef: this.getRef, onDragStartT: onDragStart, onDragOverT: onDragOver, onDropT: onDrop, onDragLeaveT: onDragLeave }, | ||
react_1.default.createElement("div", { className: 'dock-tab-hit-area', ref: this.getHitAreaRef }), | ||
title, | ||
react_1.default.createElement(DragDropDiv_1.DragDropDiv, { className: 'dock-tab-hit-area', getRef: this.getHitAreaRef, onDragStartT: onDragStart, onDragOverT: onDragOver, onDropT: onDrop, onDragLeaveT: onDragLeave }, closable ? | ||
closable ? | ||
react_1.default.createElement("div", { className: 'dock-tab-close-btn', onClick: this.onCloseClick, onKeyDown: this.onKeyDownCloseBtn, tabIndex: 0 }) | ||
: null))); | ||
: null)); | ||
return (react_1.default.createElement(DockTabPane_1.default, { key: id, cacheId: id, cached: cached, tab: tab }, content)); | ||
@@ -166,0 +167,0 @@ } |
{ | ||
"name": "rc-dock", | ||
"version": "3.0.4", | ||
"version": "3.0.5", | ||
"description": "dock layout for react component", | ||
@@ -75,4 +75,4 @@ "repository": { | ||
"build-www": "ts-node tool/build-www", | ||
"build-es": "tsc --build tsconfig_es.json" | ||
"build-es": "tsc --module es2020 --outDir ./es" | ||
} | ||
} |
@@ -21,3 +21,3 @@ { | ||
"newLine": "lf", | ||
"outDir": "./es" | ||
"outDir": "./lib" | ||
}, | ||
@@ -24,0 +24,0 @@ "include": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
497595
13397
125