From d1fae4cdfb141761f585c68412141163e77ecbb3 Mon Sep 17 00:00:00 2001 From: Uldis Jansons <51125239+chronosye@users.noreply.github.com> Date: Sat, 22 Oct 2022 18:49:05 +0300 Subject: [PATCH 1/8] Added onToggle --- index.d.ts | 5 +++++ src/index.js | 5 ++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/index.d.ts b/index.d.ts index ee69255..dbbe7b5 100644 --- a/index.d.ts +++ b/index.d.ts @@ -35,6 +35,11 @@ export interface TreeProps { */ onClick?: React.MouseEventHandler; + /** + * Event handler for clicks on the toggler icon + */ + onToggle?: React.MouseEventHandler; + /** * Custom react-spring animation config */ diff --git a/src/index.js b/src/index.js index a289ea0..30ffa5a 100644 --- a/src/index.js +++ b/src/index.js @@ -47,6 +47,7 @@ export default class Tree extends React.PureComponent { canHide: PropTypes.bool, content: PropTypes.node, springConfig: PropTypes.func, + onToggle: PropTypes.func, } constructor(props) { @@ -54,9 +55,11 @@ export default class Tree extends React.PureComponent { this.state = { open: props.open, visible: props.visible, immediate: false } } - toggle = () => + toggle = () => { + if (this.props.onToggle) this.props.onToggle(!this.state.open) this.props.children && this.setState(state => ({ open: !state.open, immediate: false })) + } toggleVisibility = () => { this.setState( From 5827c276c1da84640a57641ff696938aa619f377 Mon Sep 17 00:00:00 2001 From: Uldis Jansons <51125239+chronosye@users.noreply.github.com> Date: Sun, 23 Oct 2022 15:13:20 +0300 Subject: [PATCH 2/8] updated package file --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index cb851dd..db7cb26 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "react-animated-tree", - "version": "1.0.8", + "name": "@chronosye/react-animated-tree", + "version": "1.0.0", "description": "Animate React with ease", "main": "dist/react-animated-tree.cjs.js", "module": "dist/react-animated-tree.es.js", @@ -35,7 +35,7 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/drcmda/react-animated-tree.git" + "url": "git+https://github.com/chronosye/react-animated-tree.git" }, "keywords": [ "react", @@ -47,9 +47,9 @@ "author": "Paul Henschel", "license": "ISC", "bugs": { - "url": "https://github.com/drcmda/react-animated-tree/issues" + "url": "https://github.com/chronosye/react-animated-tree/issues" }, - "homepage": "https://github.com/drcmda/react-animated-tree#readme", + "homepage": "https://github.com/chronosye/react-animated-tree#readme", "devDependencies": { "@babel/core": "7.0.0-beta.49", "@babel/plugin-transform-runtime": "^7.0.0-beta.49", From dc9f21f29bd4c63cb97a623c0247e7c7e155b439 Mon Sep 17 00:00:00 2001 From: Uldis Jansons <51125239+chronosye@users.noreply.github.com> Date: Sun, 23 Oct 2022 15:15:31 +0300 Subject: [PATCH 3/8] Updated readme --- readme.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/readme.md b/readme.md index 7f255e9..592fbc1 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,5 @@ -[![Build Status](https://travis-ci.org/drcmda/react-animated-tree.svg?branch=master)](https://travis-ci.org/drcmda/react-animated-tree) [![npm version](https://badge.fury.io/js/react-animated-tree.svg)](https://badge.fury.io/js/react-animated-tree) - npm install react-animated-tree + npm install @chronosye/react-animated-tree A simple, configurable tree view control for React. @@ -16,6 +15,7 @@ Demo: https://codesandbox.io/embed/rrw7mrknyp * `canHide`, optional: when set true displays an eye icon * `visible`, optional: default visible state * `onClick`, optional: click events on the eye +* `onToggle`, optional: click events on the icon * `springConfig`, optional: react-spring animation config ```jsx From 25d2e891d1c748f2b28e598b791bf0d71779a18b Mon Sep 17 00:00:00 2001 From: Uldis Jansons <51125239+chronosye@users.noreply.github.com> Date: Sun, 23 Oct 2022 15:34:42 +0300 Subject: [PATCH 4/8] Updated versions --- package.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index db7cb26..1226ad9 100644 --- a/package.json +++ b/package.json @@ -51,11 +51,11 @@ }, "homepage": "https://github.com/chronosye/react-animated-tree#readme", "devDependencies": { - "@babel/core": "7.0.0-beta.49", - "@babel/plugin-transform-runtime": "^7.0.0-beta.49", - "@babel/preset-env": "7.0.0-beta.49", - "@babel/preset-react": "7.0.0-beta.49", - "@babel/preset-stage-2": "7.0.0-beta.49", + "@babel/core": "^7.0.0", + "@babel/plugin-transform-runtime": "^7.0.0", + "@babel/preset-env": "^7.0.0", + "@babel/preset-react": "^7.0.0", + "@babel/preset-stage-2": "^7.0.0", "babel-core": "7.0.0-bridge.0", "babel-jest": "23.0.1", "husky": "^1.0.0-rc.8", From 375679cbfa9af9b6d43dbeaa2b0e107188464418 Mon Sep 17 00:00:00 2001 From: Uldis Jansons <51125239+chronosye@users.noreply.github.com> Date: Tue, 25 Oct 2022 16:38:51 +0300 Subject: [PATCH 5/8] Changed versions --- package.json | 35 +++++++++++++++++------------------ rollup.config.js | 37 ++++++++++++++----------------------- 2 files changed, 31 insertions(+), 41 deletions(-) diff --git a/package.json b/package.json index 1226ad9..f3f2451 100644 --- a/package.json +++ b/package.json @@ -51,23 +51,22 @@ }, "homepage": "https://github.com/chronosye/react-animated-tree#readme", "devDependencies": { - "@babel/core": "^7.0.0", - "@babel/plugin-transform-runtime": "^7.0.0", - "@babel/preset-env": "^7.0.0", - "@babel/preset-react": "^7.0.0", - "@babel/preset-stage-2": "^7.0.0", - "babel-core": "7.0.0-bridge.0", - "babel-jest": "23.0.1", - "husky": "^1.0.0-rc.8", - "lint-staged": "^7.1.2", - "prettier": "^1.13.2", - "rimraf": "2.6.2", - "rollup": "0.59.4", - "rollup-plugin-babel": "^4.0.0-beta.4", - "rollup-plugin-commonjs": "^9.1.3", - "rollup-plugin-node-resolve": "^3.3.0", - "rollup-plugin-size-snapshot": "^0.5.1", - "rollup-plugin-uglify": "^4.0.0" + "@babel/core": "7.14.0", + "@babel/plugin-transform-runtime": "7.13.5", + "@babel/preset-env": "7.14.1", + "@babel/preset-react": "7.13.13", + "@babel/preset-stage-2": "7.8.3", + "@rollup/plugin-babel": "5.3.0", + "@rollup/plugin-commonjs": "19.0.0", + "@rollup/plugin-node-resolve": "13.0.0", + "babel-core": "6.26.3", + "babel-jest": "26.6.3", + "husky": "6.0.0", + "lint-staged": "11.0.0", + "rimraf": "3.0.2", + "rollup": "2.47.0", + "rollup-plugin-size-snapshot": "^0.12.0", + "rollup-plugin-uglify": "^6.0.4" }, "peerDependencies": { "prop-types": "15.x.x", @@ -75,7 +74,7 @@ "react-dom": ">= 16.3.2" }, "dependencies": { - "@babel/runtime": "7.0.0-beta.49", + "@babel/runtime": "7.14.0", "react-spring": "^5.3.7" } } diff --git a/rollup.config.js b/rollup.config.js index bd353d1..b76d5af 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,25 +1,16 @@ -import babel from 'rollup-plugin-babel' -import resolve from 'rollup-plugin-node-resolve' -import commonjs from 'rollup-plugin-commonjs' -import { uglify } from 'rollup-plugin-uglify' -import { sizeSnapshot } from 'rollup-plugin-size-snapshot' +import babel from "@rollup/plugin-babel" +import { nodeResolve } from "@rollup/plugin-node-resolve" +import commonjs from "@rollup/plugin-commonjs" +import { uglify } from "rollup-plugin-uglify" +import { sizeSnapshot } from "rollup-plugin-size-snapshot" const isExternal = id => !id.startsWith('.') && !id.startsWith('/') const getBabelOptions = ({ useESModules }) => ({ - babelrc: false, - exclude: '**/node_modules/**', - runtimeHelpers: true, - presets: [ - ['@babel/preset-env', { loose: true, modules: false }], - ['@babel/preset-stage-2', { loose: true, decoratorsLegacy: true }], - '@babel/preset-react', - ], - plugins: [ - [ - '@babel/transform-runtime', - { polyfill: false, useBuiltIns: true, useESModules }, - ], - ], + babelrc: false, + exclude: "**/node_modules/**", + babelHelpers: "runtime", + presets: ["@babel/react", "@babel/env"], + plugins: [["@babel/transform-runtime", { useESModules }]], }) function createConfig(entry, out, name) { @@ -52,10 +43,10 @@ function createConfig(entry, out, name) { external: ['react', 'react-dom', 'prop-types', 'react-spring'], plugins: [ babel(getBabelOptions({ useESModules: false })), - resolve(), - commonjs(), - sizeSnapshot(), - uglify({ compress: true, mangle: { toplevel: true } }), + nodeResolve(), + commonjs(), + sizeSnapshot(), + uglify({ compress: true, mangle: { toplevel: true } }), ], }, ] From 4f6ab98042c2b919703098456947680b0c07ef21 Mon Sep 17 00:00:00 2001 From: Uldis Jansons <51125239+chronosye@users.noreply.github.com> Date: Wed, 26 Oct 2022 17:04:31 +0300 Subject: [PATCH 6/8] changed config --- package.json | 37 +++++++++--------- rollup.config.js | 99 ++++++++++++++++++++++++++---------------------- 2 files changed, 74 insertions(+), 62 deletions(-) diff --git a/package.json b/package.json index f3f2451..e572c44 100644 --- a/package.json +++ b/package.json @@ -51,22 +51,25 @@ }, "homepage": "https://github.com/chronosye/react-animated-tree#readme", "devDependencies": { - "@babel/core": "7.14.0", - "@babel/plugin-transform-runtime": "7.13.5", - "@babel/preset-env": "7.14.1", - "@babel/preset-react": "7.13.13", - "@babel/preset-stage-2": "7.8.3", - "@rollup/plugin-babel": "5.3.0", - "@rollup/plugin-commonjs": "19.0.0", - "@rollup/plugin-node-resolve": "13.0.0", - "babel-core": "6.26.3", - "babel-jest": "26.6.3", - "husky": "6.0.0", - "lint-staged": "11.0.0", - "rimraf": "3.0.2", - "rollup": "2.47.0", - "rollup-plugin-size-snapshot": "^0.12.0", - "rollup-plugin-uglify": "^6.0.4" + "babel-eslint": "^10.0.3", + "cross-env": "^7.0.2", + "eslint": "^6.8.0", + "eslint-config-prettier": "^6.7.0", + "eslint-config-standard": "^14.1.0", + "eslint-config-standard-react": "^9.2.0", + "eslint-plugin-import": "^2.18.2", + "eslint-plugin-node": "^11.0.0", + "eslint-plugin-prettier": "^3.1.1", + "eslint-plugin-promise": "^4.2.1", + "eslint-plugin-react": "^7.17.0", + "eslint-plugin-standard": "^4.0.1", + "gh-pages": "^2.2.0", + "microbundle-crl": "^0.13.8", + "npm-run-all": "^4.1.5", + "prettier": "^2.0.4", + "react": "^16.13.1", + "react-dom": "^16.13.1", + "react-scripts": "^3.4.1" }, "peerDependencies": { "prop-types": "15.x.x", @@ -74,7 +77,7 @@ "react-dom": ">= 16.3.2" }, "dependencies": { - "@babel/runtime": "7.14.0", + "@babel/runtime": "7.0.0-beta.49", "react-spring": "^5.3.7" } } diff --git a/rollup.config.js b/rollup.config.js index b76d5af..95709b7 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,55 +1,64 @@ -import babel from "@rollup/plugin-babel" -import { nodeResolve } from "@rollup/plugin-node-resolve" -import commonjs from "@rollup/plugin-commonjs" -import { uglify } from "rollup-plugin-uglify" -import { sizeSnapshot } from "rollup-plugin-size-snapshot" +import babel from 'rollup-plugin-babel' +import resolve from 'rollup-plugin-node-resolve' +import commonjs from 'rollup-plugin-commonjs' +import { uglify } from 'rollup-plugin-uglify' +import { sizeSnapshot } from 'rollup-plugin-size-snapshot' const isExternal = id => !id.startsWith('.') && !id.startsWith('/') const getBabelOptions = ({ useESModules }) => ({ - babelrc: false, - exclude: "**/node_modules/**", - babelHelpers: "runtime", - presets: ["@babel/react", "@babel/env"], - plugins: [["@babel/transform-runtime", { useESModules }]], + babelrc: false, + exclude: '**/node_modules/**', + runtimeHelpers: true, + presets: [ + ['@babel/preset-env', { loose: true, modules: false }], + ['@babel/preset-stage-2', { loose: true, decoratorsLegacy: true }], + '@babel/preset-react', + ], + plugins: [ + [ + '@babel/transform-runtime', + { polyfill: false, useBuiltIns: true, useESModules }, + ], + ], }) function createConfig(entry, out, name) { - return [ - { - input: `./src/${entry}.js`, - output: { file: `dist/${out}.es.js`, format: 'es' }, - external: isExternal, - plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()], - }, - { - input: `./src/${entry}.js`, - output: { file: `dist/${out}.cjs.js`, format: 'cjs' }, - external: isExternal, - plugins: [babel(getBabelOptions({ useESModules: false }))], - }, - { - input: `./src/${entry}.js`, - output: { - file: `dist/${out}.umd.js`, - format: 'umd', - name, - globals: { - react: 'React', - 'react-dom': 'ReactDOM', - 'prop-types': 'PropTypes', - 'react-spring': 'ReactSpring', + return [ + { + input: `./src/${entry}.js`, + output: { file: `dist/${out}.es.js`, format: 'es' }, + external: isExternal, + plugins: [babel(getBabelOptions({ useESModules: true })), sizeSnapshot()], }, - }, - external: ['react', 'react-dom', 'prop-types', 'react-spring'], - plugins: [ - babel(getBabelOptions({ useESModules: false })), - nodeResolve(), - commonjs(), - sizeSnapshot(), - uglify({ compress: true, mangle: { toplevel: true } }), - ], - }, - ] + { + input: `./src/${entry}.js`, + output: { file: `dist/${out}.cjs.js`, format: 'cjs' }, + external: isExternal, + plugins: [babel(getBabelOptions({ useESModules: false }))], + }, + { + input: `./src/${entry}.js`, + output: { + file: `dist/${out}.umd.js`, + format: 'umd', + name, + globals: { + react: 'React', + 'react-dom': 'ReactDOM', + 'prop-types': 'PropTypes', + 'react-spring': 'ReactSpring', + }, + }, + external: ['react', 'react-dom', 'prop-types', 'react-spring'], + plugins: [ + babel(getBabelOptions({ useESModules: false })), + resolve(), + commonjs(), + sizeSnapshot(), + uglify({ compress: true, mangle: { toplevel: true } }), + ], + }, + ] } export default [ From 24c83b11e9878aee9e98692fc6ca6808d7ad4608 Mon Sep 17 00:00:00 2001 From: Uldis Jansons <51125239+chronosye@users.noreply.github.com> Date: Wed, 26 Oct 2022 17:19:18 +0300 Subject: [PATCH 7/8] changed package.json file --- package.json | 34 ++++++++++++++++------------------ 1 file changed, 16 insertions(+), 18 deletions(-) diff --git a/package.json b/package.json index e572c44..5751a31 100644 --- a/package.json +++ b/package.json @@ -2,9 +2,12 @@ "name": "@chronosye/react-animated-tree", "version": "1.0.0", "description": "Animate React with ease", - "main": "dist/react-animated-tree.cjs.js", - "module": "dist/react-animated-tree.es.js", - "typings": "index.d.ts", + "main": "dist/index.js", + "module": "dist/index.modern.js", + "source": "src/index.js", + "engines": { + "node": ">=10" + }, "files": [ "dist", "src", @@ -13,11 +16,16 @@ ], "sideEffects": false, "scripts": { - "prebuild": "rimraf dist", - "build": "rollup -c", - "prepare": "npm run build", - "test": "echo will do", - "precommit": "lint-staged" + "build": "microbundle-crl --no-compress --format modern,cjs", + "start": "microbundle-crl watch --no-compress --format modern,cjs", + "prepublish": "run-s build", + "test": "run-s test:unit test:build", + "test:build": "run-s build", + "test:lint": "eslint .", + "test:unit": "cross-env CI=1 react-scripts test --env=jsdom", + "test:watch": "react-scripts test --env=jsdom", + "predeploy": "cd example && yarn install && yarn run build", + "deploy": "gh-pages -d example/build" }, "prettier": { "semi": false, @@ -33,10 +41,6 @@ "git add" ] }, - "repository": { - "type": "git", - "url": "git+https://github.com/chronosye/react-animated-tree.git" - }, "keywords": [ "react", "motion", @@ -44,12 +48,6 @@ "animation", "spring" ], - "author": "Paul Henschel", - "license": "ISC", - "bugs": { - "url": "https://github.com/chronosye/react-animated-tree/issues" - }, - "homepage": "https://github.com/chronosye/react-animated-tree#readme", "devDependencies": { "babel-eslint": "^10.0.3", "cross-env": "^7.0.2", From 25248fba5ed06e5a3d3e9ac8869783a8101fccfe Mon Sep 17 00:00:00 2001 From: Uldis Jansons <51125239+chronosye@users.noreply.github.com> Date: Thu, 27 Oct 2022 09:26:29 +0300 Subject: [PATCH 8/8] Changed toogle function --- src/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 30ffa5a..8ae3cd5 100644 --- a/src/index.js +++ b/src/index.js @@ -56,7 +56,7 @@ export default class Tree extends React.PureComponent { } toggle = () => { - if (this.props.onToggle) this.props.onToggle(!this.state.open) + if (this.props.onToggle) this.props.onToggle() this.props.children && this.setState(state => ({ open: !state.open, immediate: false })) }