react-konva-utils
Advanced tools
+21
| MIT License | ||
| Copyright (C) 2014 - present by Anton Lavrenov | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
+9
-9
@@ -13,3 +13,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
| import React from 'react'; | ||
| import ReactDOM from 'react-dom'; | ||
| import ReactDOM from 'react-dom/client'; | ||
| import { Group } from 'react-konva'; | ||
@@ -24,8 +24,6 @@ const needForceStyle = (el) => { | ||
| const container = React.useRef(); | ||
| const [div] = React.useState(() => document.createElement('div')); | ||
| const root = React.useMemo(() => ReactDOM.createRoot(div), [div]); | ||
| const shouldTransform = transform !== null && transform !== void 0 ? transform : true; | ||
| const handleTransform = () => { | ||
| const div = container.current; | ||
| if (!div) { | ||
| return; | ||
| } | ||
| if (shouldTransform && groupRef.current) { | ||
@@ -66,4 +64,2 @@ const tr = groupRef.current.getAbsoluteTransform(); | ||
| } | ||
| let div = document.createElement('div'); | ||
| container.current = div; | ||
| parent.appendChild(div); | ||
@@ -78,3 +74,2 @@ if (shouldTransform && needForceStyle(parent)) { | ||
| group.off('absoluteTransformChange', handleTransform); | ||
| ReactDOM.unmountComponentAtNode(div); | ||
| (_a = div.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(div); | ||
@@ -87,5 +82,10 @@ }; | ||
| React.useLayoutEffect(() => { | ||
| ReactDOM.render(children, container.current); | ||
| root.render(children); | ||
| }); | ||
| React.useEffect(() => { | ||
| return () => { | ||
| root.unmount(); | ||
| }; | ||
| }, []); | ||
| return React.createElement(Group, Object.assign({ ref: groupRef }, groupProps)); | ||
| }; |
+19
-18
| { | ||
| "name": "react-konva-utils", | ||
| "version": "0.2.0", | ||
| "version": "0.3.0", | ||
| "description": "Useful components and hooks for react-konva", | ||
@@ -12,10 +12,11 @@ "author": "Anton Lavrenov", | ||
| ], | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "react-konva": "^17.0.2-4", | ||
| "use-image": "^1.0.7" | ||
| "react-konva": "^18.0.0-0", | ||
| "use-image": "^1.0.12" | ||
| }, | ||
| "peerDependencies": { | ||
| "konva": "8.x", | ||
| "react": "^17.0.2", | ||
| "react-dom": "^17.0.2" | ||
| "konva": "^8.3.5", | ||
| "react": "^18.0.0", | ||
| "react-dom": "^18.0.0" | ||
| }, | ||
@@ -29,15 +30,15 @@ "types": "./es/index.d.ts", | ||
| "devDependencies": { | ||
| "@babel/core": "^7.13.14", | ||
| "@storybook/addon-actions": "^6.2.2", | ||
| "@storybook/core-server": "^6.3.0", | ||
| "@storybook/addon-essentials": "^6.2.2", | ||
| "@storybook/addon-links": "^6.2.2", | ||
| "@storybook/core": "^6.3.0", | ||
| "@storybook/react": "^6.2.2", | ||
| "@types/react": "^17.0.3", | ||
| "babel-loader": "^8.2.2", | ||
| "@babel/core": "^7.17.9", | ||
| "@storybook/addon-actions": "^6.5.0-alpha.61", | ||
| "@storybook/addon-essentials": "^6.5.0-alpha.61", | ||
| "@storybook/addon-links": "^6.5.0-alpha.61", | ||
| "@storybook/core": "^6.5.0-alpha.61", | ||
| "@storybook/core-server": "^6.5.0-alpha.61", | ||
| "@storybook/react": "^6.5.0-alpha.61", | ||
| "@types/react": "^18.0.1", | ||
| "babel-loader": "^8.2.4", | ||
| "parcel-bundler": "^1.12.4", | ||
| "react": "^17.0.2", | ||
| "react-dom": "^17.0.2", | ||
| "typescript": "^4.2.3" | ||
| "react": "^18.0.0", | ||
| "react-dom": "^18.0.0", | ||
| "typescript": "^4.6.3" | ||
| }, | ||
@@ -44,0 +45,0 @@ "scripts": { |
12521
10.29%15
7.14%+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
+ Added
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
- Removed
Updated
Updated