Skip to content

Commit

Permalink
Merge pull request #2 from RickoNoNo3/dev
Browse files Browse the repository at this point in the history
Dev updated to 1.3.7
  • Loading branch information
RickoNoNo3 committed Apr 22, 2022
2 parents 26c889d + 8b3b77d commit c2a6f01
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 42 deletions.
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,8 @@
<a target="_blank" href="https://www.npmjs.com/package/react-winbox"><img src="https://img.shields.io/npm/v/react-winbox?style=flat-square"></a>
![GitHub Workflow Status](https://img.shields.io/github/workflow/status/rickonono3/react-winbox/Node.js%20CI/main?style=flat-square)


A React controlled component for [WinBox.js](https://github.com/nextapps-de/winbox), with full Reactful props and state. Includes all configuration of WinBox.js by using React component props.

## Use it just like other native components of you! Whatever the float window does.

**Full type declaration for both JavaScript and TypeScript.**

![demo screenshot](https://github.com/RickoNoNo3/react-winbox/blob/main/demo.jpg)
Expand All @@ -22,7 +19,7 @@ yarn add react-winbox

## Usage

To use WinBox, ensure the body has a non-zero height, e.g. `100vh`.
To use WinBox, ensure the document body has a initial non-zero height, e.g. `100vh`.

```jsx
import WinBox from 'react-winbox';
Expand Down
2 changes: 1 addition & 1 deletion dist/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import 'winbox/dist/css/winbox.min.css';
declare type WinBoxPropType = {
title: string;
id?: string;
children?: ReactElement | null;
children?: ReactElement | ReactElement[] | null;
/**
* When you use this, the children elements will be ignored.
*/
Expand Down
15 changes: 12 additions & 3 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,20 @@ var WinBox = /** @class */ (function (_super) {
return; // because of twice calling in the strictMode, there can't be a `!this.state.closed`
if (Object.keys(_this.props).indexOf('url') !== -1 && _this.props.url)
return; // do nothing if url is set.
if (!_this.reactRoot || _this.reactRootTarget !== _this.winBoxObj.body) {
// this.reactRoot = hydrateRoot(this.winBoxObj.body, this.props.children);
if ( /*!this.reactRoot ||*/_this.reactRootTarget !== _this.winBoxObj.body) {
// this.reactRoot = hydrateRoot(this.winBoxObj.body, this.props.children); // downgraded
_this.reactRootTarget = _this.winBoxObj.body;
}
react_dom_1.default.render((_a = _this.props.children) !== null && _a !== void 0 ? _a : (0, jsx_runtime_1.jsx)(jsx_runtime_1.Fragment, {}), (_b = _this.reactRootTarget) !== null && _b !== void 0 ? _b : null);
if (_this.props.children) {
if (Array.isArray(_this.props.children)) {
var children = _this.props.children;
react_dom_1.default.render(children !== null && children !== void 0 ? children : [], (_a = _this.reactRootTarget) !== null && _a !== void 0 ? _a : null);
}
else {
var children = _this.props.children;
react_dom_1.default.render(children, (_b = _this.reactRootTarget) !== null && _b !== void 0 ? _b : null);
}
}
};
_this.maintainStyle = function () {
if (!_this.winBoxObj)
Expand Down
38 changes: 18 additions & 20 deletions package-lock.json

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

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-winbox",
"version": "1.3.6",
"version": "1.3.7",
"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 All @@ -19,8 +19,8 @@
"react-dom": "^16.14.0"
},
"devDependencies": {
"@types/react": "^17.0.39",
"@types/react-dom": "^17.0.11",
"@types/react": "^16.0.41",
"@types/react-dom": "^16.0.11",
"@types/winbox": "^0.2.1",
"@typescript-eslint/eslint-plugin": "^5.19.0",
"@typescript-eslint/parser": "^5.19.0",
Expand Down
12 changes: 10 additions & 2 deletions src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import ReactDOM, {Container, render, Renderer} from 'react-dom';
type WinBoxPropType = {
title: string
id?: string
children?: ReactElement | null
children?: ReactElement | ReactElement[] | null
/**
* When you use this, the children elements will be ignored.
*/
Expand Down Expand Up @@ -153,7 +153,15 @@ class WinBox extends Component<WinBoxPropType, WinBoxState> {
// this.reactRoot = hydrateRoot(this.winBoxObj.body, this.props.children); // downgraded
this.reactRootTarget = this.winBoxObj.body;
}
ReactDOM.render(this.props.children ?? <></>, this.reactRootTarget ?? null);
if (this.props.children) {
if (Array.isArray(this.props.children)) {
const children = this.props.children as ReactElement[];
ReactDOM.render(children ?? [], this.reactRootTarget ?? null);
} else {
const children = this.props.children as ReactElement;
ReactDOM.render(children, this.reactRootTarget ?? null);
}
}
};

maintainStyle = () => {
Expand Down
18 changes: 9 additions & 9 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,17 @@
"resolved" "https://registry.npmmirror.com/@types/prop-types/-/prop-types-15.7.5.tgz"
"version" "15.7.5"

"@types/react-dom@^17.0.11":
"integrity" "sha512-Tr9VU9DvNoHDWlmecmcsE5ZZiUkYx+nKBzum4Oxe1K0yJVyBlfbq7H3eXjxXqJczBKqPGq3EgfTru4MgKb9+Yw=="
"resolved" "https://registry.npmjs.org/@types/react-dom/-/react-dom-17.0.15.tgz"
"version" "17.0.15"
"@types/react-dom@^16.0.11":
"integrity" "sha512-FIX2AVmPTGP30OUJ+0vadeIFJJ07Mh1m+U0rxfgyW34p3rTlXI+nlenvAxNn4BP36YyI9IJ/+UJ7Wu22N1pI7A=="
"resolved" "https://registry.npmjs.org/@types/react-dom/-/react-dom-16.9.14.tgz"
"version" "16.9.14"
dependencies:
"@types/react" "^17"
"@types/react" "^16"

"@types/react@^17", "@types/react@^17.0.39":
"integrity" "sha512-Ye0nlw09GeMp2Suh8qoOv0odfgCoowfM/9MG6WeRD60Gq9wS90bdkdRtYbRkNhXOpG4H+YXGvj4wOWhAC0LJ1g=="
"resolved" "https://registry.npmjs.org/@types/react/-/react-17.0.44.tgz"
"version" "17.0.44"
"@types/react@^16", "@types/react@^16.0.41":
"integrity" "sha512-cXRVHd7vBT5v1is72mmvmsg9stZrbJO04DJqFeh3Yj2tVKO6vmxg5BI+ybI6Ls7ROXRG3aFbZj9x0WA3ZAoDQw=="
"resolved" "https://registry.npmjs.org/@types/react/-/react-16.14.25.tgz"
"version" "16.14.25"
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
Expand Down

0 comments on commit c2a6f01

Please sign in to comment.