From 6f4ff57fc18bbfc0930bc8b9cf6b0cb5d7be9eea Mon Sep 17 00:00:00 2001 From: rick Date: Thu, 19 May 2022 14:18:29 +0800 Subject: [PATCH 1/3] onclose fixed --- dist/index.d.ts | 2 -- dist/index.js | 9 +++------ src/index.tsx | 15 ++++----------- 3 files changed, 7 insertions(+), 19 deletions(-) diff --git a/dist/index.d.ts b/dist/index.d.ts index b0fc16b..409df33 100644 --- a/dist/index.d.ts +++ b/dist/index.d.ts @@ -62,8 +62,6 @@ declare type WinBoxState = { */ declare class WinBox extends Component { winBoxObj: OriginalWinBox; - private reactRoot; - private reactRootTarget; constructor(props: any); componentDidMount(): void; componentDidUpdate(prevProps: Readonly, prevState: Readonly): void; diff --git a/dist/index.js b/dist/index.js index 2251e90..3a3eed2 100644 --- a/dist/index.js +++ b/dist/index.js @@ -122,15 +122,12 @@ var WinBox = /** @class */ (function (_super) { _this.maintainStyle(); }; _this.handleClose = function () { - _this.reactRoot = undefined; - _this.reactRootTarget = undefined; + _this.winBoxObj = undefined; _this.setState({ closed: true }); }; _this.state = { closed: false, }; - _this.reactRoot = undefined; - _this.reactRootTarget = undefined; _this.winBoxObj = undefined; return _this; } @@ -140,9 +137,9 @@ var WinBox = /** @class */ (function (_super) { try { if (this.props.id !== undefined && this.props.id !== null && document.getElementById(this.props.id)) throw 'duplicated window id'; - this.winBoxObj = new winbox_1.default(__assign(__assign({ width: 300, height: 200, top: 0, bottom: 0, left: 0, right: 0 }, this.props), { class: "".concat((_a = this.props.className) !== null && _a !== void 0 ? _a : ''), onClose: function () { + this.winBoxObj = new winbox_1.default(__assign(__assign({ width: 300, height: 200, top: 0, bottom: 0, left: 0, right: 0 }, this.props), { class: "".concat((_a = this.props.className) !== null && _a !== void 0 ? _a : ''), onclose: function (force) { var _a, _b; - if ((_b = (_a = _this.props).onclose) === null || _b === void 0 ? void 0 : _b.call(_a)) { + if ((_b = (_a = _this.props).onclose) === null || _b === void 0 ? void 0 : _b.call(_a, force)) { return true; } _this.handleClose(); // only when false, do close process. diff --git a/src/index.tsx b/src/index.tsx index fc113ef..2c07405 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -1,7 +1,7 @@ import React, {Component, ReactElement} from 'react'; import OriginalWinBox from 'winbox/src/js/winbox'; import 'winbox/dist/css/winbox.min.css'; -import ReactDOM, {Container, Renderer} from 'react-dom'; +import ReactDOM from 'react-dom'; export type WinBoxPropType = { title: string @@ -73,17 +73,11 @@ type WinBoxState = { class WinBox extends Component { public winBoxObj: OriginalWinBox; - private reactRoot: Renderer | undefined; - - private reactRootTarget: Container | undefined; - constructor(props) { super(props); this.state = { closed: false, }; - this.reactRoot = undefined; - this.reactRootTarget = undefined; this.winBoxObj = undefined; } @@ -100,8 +94,8 @@ class WinBox extends Component { right: 0, ...this.props, class: `${this.props.className ?? ''}`, - onClose: () => { - if (this.props.onclose?.()) { + onclose: (force?: boolean) => { + if (this.props.onclose?.(force)) { return true; } this.handleClose(); // only when false, do close process. @@ -222,8 +216,7 @@ class WinBox extends Component { }; handleClose = () => { - this.reactRoot = undefined; - this.reactRootTarget = undefined; + this.winBoxObj = undefined; this.setState({closed: true}); }; From e96a7eacb7df80bdeb7484637f0a91e19c451143 Mon Sep 17 00:00:00 2001 From: rick Date: Thu, 19 May 2022 14:25:50 +0800 Subject: [PATCH 2/3] onclose fixed --- src/index.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/index.tsx b/src/index.tsx index 2c07405..61b1d4d 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -47,10 +47,10 @@ export type WinBoxPropType = { * * see the following document for more detail about the argument and the return value. * @see https://github.com/nextapps-de/winbox - * @param force whether you should not abort the winbox to close. + * @param force Whether you should not abort the winbox to close. If this is true, you MUST return false, or some problems will happen. * @return noDefaultClose - true if the winbox does not need the default close process, for example, when it needs a confirmation to close instead of being closed suddenly. */ - onclose?: (force?: boolean) => boolean | undefined | void, + onclose?: (force: boolean) => boolean | undefined | void, onmove?: (x: number, y: number) => any, onresize?: (width: number, height: number) => any, onblur?: () => any, @@ -95,7 +95,7 @@ class WinBox extends Component { ...this.props, class: `${this.props.className ?? ''}`, onclose: (force?: boolean) => { - if (this.props.onclose?.(force)) { + if (this.props.onclose?.(force ?? false)) { return true; } this.handleClose(); // only when false, do close process. From 74a5f49ce8ec796bedff4f924c9cdc8d93b1e9d2 Mon Sep 17 00:00:00 2001 From: rick Date: Thu, 19 May 2022 14:25:56 +0800 Subject: [PATCH 3/3] 1.4.1 --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index daa1103..993f60e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "react-winbox", - "version": "1.4.0", + "version": "1.4.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "react-winbox", - "version": "1.4.0", + "version": "1.4.1", "license": "MIT", "dependencies": { "winbox": "^0.2.1" diff --git a/package.json b/package.json index 1e67600..1d45333 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "react-winbox", - "version": "1.4.0", + "version": "1.4.1", "description": "The React component for WinBox.js. Full Reactful props and state. A window manager for React", "private": false, "homepage": "https://github.com/rickonono3/react-winbox",