Skip to content

Commit

Permalink
Merge pull request #7 from RickoNoNo3/dev
Browse files Browse the repository at this point in the history
Dev v1.4.1
  • Loading branch information
RickoNoNo3 authored May 19, 2022
2 parents 2beb9e4 + 74a5f49 commit e166887
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 24 deletions.
2 changes: 0 additions & 2 deletions dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ declare type WinBoxState = {
*/
declare class WinBox extends Component<WinBoxPropType, WinBoxState> {
winBoxObj: OriginalWinBox;
private reactRoot;
private reactRootTarget;
constructor(props: any);
componentDidMount(): void;
componentDidUpdate(prevProps: Readonly<WinBoxPropType>, prevState: Readonly<WinBoxState>): void;
Expand Down
9 changes: 3 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
19 changes: 6 additions & 13 deletions src/index.tsx
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -73,17 +73,11 @@ type WinBoxState = {
class WinBox extends Component<WinBoxPropType, WinBoxState> {
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;
}

Expand All @@ -100,8 +94,8 @@ class WinBox extends Component<WinBoxPropType, WinBoxState> {
right: 0,
...this.props,
class: `${this.props.className ?? ''}`,
onClose: () => {
if (this.props.onclose?.()) {
onclose: (force?: boolean) => {
if (this.props.onclose?.(force ?? false)) {
return true;
}
this.handleClose(); // only when false, do close process.
Expand Down Expand Up @@ -222,8 +216,7 @@ class WinBox extends Component<WinBoxPropType, WinBoxState> {
};

handleClose = () => {
this.reactRoot = undefined;
this.reactRootTarget = undefined;
this.winBoxObj = undefined;
this.setState({closed: true});
};

Expand Down

0 comments on commit e166887

Please sign in to comment.