From 877c1f74a90b68a971044d4de9bd81a01c4e8e9f Mon Sep 17 00:00:00 2001
From: "1029278668@qq.com" <1029278668@qq.com>
Date: Sat, 22 May 2021 13:38:29 +0800
Subject: [PATCH] =?UTF-8?q?doc:=20dumi=E6=9E=84=E5=BB=BA=E5=9C=A8=E7=BA=BF?=
=?UTF-8?q?=E6=96=87=E6=A1=A3?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.gitignore | 1 +
README.md | 30 ++++++------
docs/README.md | 92 ++++++++++++++++++++++++++++++++++++
docs/demo/basic.md | 3 ++
docs/demo/expand.md | 3 ++
docs/demo/expandAll.md | 3 ++
docs/demo/horizontal.md | 3 ++
docs/demo/vertical.md | 3 ++
docs/examples/basic.jsx | 70 +++++++++++++++++++++++++++
docs/examples/expand.jsx | 70 +++++++++++++++++++++++++++
docs/examples/expandAll.jsx | 70 +++++++++++++++++++++++++++
docs/examples/horizontal.jsx | 70 +++++++++++++++++++++++++++
docs/examples/vertical.jsx | 70 +++++++++++++++++++++++++++
docs/index.md | 5 ++
jsconfig.json | 16 +++++++
package.json | 12 +++--
webpack.config.js | 6 +++
17 files changed, 509 insertions(+), 18 deletions(-)
create mode 100644 docs/README.md
create mode 100644 docs/demo/basic.md
create mode 100644 docs/demo/expand.md
create mode 100644 docs/demo/expandAll.md
create mode 100644 docs/demo/horizontal.md
create mode 100644 docs/demo/vertical.md
create mode 100644 docs/examples/basic.jsx
create mode 100644 docs/examples/expand.jsx
create mode 100644 docs/examples/expandAll.jsx
create mode 100644 docs/examples/horizontal.jsx
create mode 100644 docs/examples/vertical.jsx
create mode 100644 docs/index.md
create mode 100644 jsconfig.json
diff --git a/.gitignore b/.gitignore
index b2ab8c3..0434cfa 100644
--- a/.gitignore
+++ b/.gitignore
@@ -22,3 +22,4 @@ yarn-error.log*
package.lock.json
examples/demo/.idea/workspace.xml
+/**/**/.umi
diff --git a/README.md b/README.md
index d4e6254..ce20137 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,13 @@
# react-org-tree
-[![npm version][npm-image]][npm-url]
-[](../../commits/master)
-[](https://github.com/artdong/react-org-tree/stargazers)
-[](https://github.com/artdong/react-org-tree/network)
-[](https://github.com/artdong/react-org-tree/blob/master/LICENSE)
+[![npm version][npm-image]][npm-url] [](../../commits/master) [](https://github.com/artdong/react-org-tree/stargazers) [](https://github.com/artdong/react-org-tree/network) [![npm download][download-image]][download-url] [](https://github.com/umijs/dumi) [](https://github.com/artdong/react-org-tree/blob/master/LICENSE)
+
+[npm-image]: http://img.shields.io/npm/v/react-org-tree.svg?style=flat-square
+[npm-url]: http://npmjs.org/package/react-org-tree
+[download-image]: https://img.shields.io/npm/dm/react-org-tree.svg?style=flat-square
+[download-url]: https://npmjs.org/package/react-org-tree
+[bundlephobia-url]: https://bundlephobia.com/result?p=react-org-tree
+[bundlephobia-image]: https://badgen.net/bundlephobia/minzip/react-org-tree
> A simple organization tree component based on react
@@ -91,6 +94,13 @@ const data = {
labelClassName | 树节点样式 | `String` | `white`
onClick | 点击事件 | Function(e:Event, data)
+## Example
+
+http://localhost:8000/demo/
+
+## License
+
+react-org-tree is released under the MIT license.
#### 欢迎关注微信公众号`全栈弄潮儿` ,获取更多学习资源及技术文章等
* 微信公众号二维码,扫一扫或者搜索"全栈弄潮儿"即可关注
@@ -99,17 +109,9 @@ const data = {
+
+
+
\ No newline at end of file
diff --git a/docs/demo/expand.md b/docs/demo/expand.md
new file mode 100644
index 0000000..e9c2e19
--- /dev/null
+++ b/docs/demo/expand.md
@@ -0,0 +1,3 @@
+## expand
+
+
\ No newline at end of file
diff --git a/docs/demo/expandAll.md b/docs/demo/expandAll.md
new file mode 100644
index 0000000..3d8f052
--- /dev/null
+++ b/docs/demo/expandAll.md
@@ -0,0 +1,3 @@
+## expandAll
+
+
\ No newline at end of file
diff --git a/docs/demo/horizontal.md b/docs/demo/horizontal.md
new file mode 100644
index 0000000..cd5a103
--- /dev/null
+++ b/docs/demo/horizontal.md
@@ -0,0 +1,3 @@
+## horizontal
+
+
\ No newline at end of file
diff --git a/docs/demo/vertical.md b/docs/demo/vertical.md
new file mode 100644
index 0000000..4ee4880
--- /dev/null
+++ b/docs/demo/vertical.md
@@ -0,0 +1,3 @@
+## vertical
+
+
\ No newline at end of file
diff --git a/docs/examples/basic.jsx b/docs/examples/basic.jsx
new file mode 100644
index 0000000..d781d44
--- /dev/null
+++ b/docs/examples/basic.jsx
@@ -0,0 +1,70 @@
+import React, { Component } from 'react';
+
+import OrgTree from 'react-org-tree';
+
+class OrgTreeDemo extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ data: {
+ id: 0,
+ label: 'XXX股份有限公司',
+ children: [{
+ id: 1,
+ label: '技术部',
+ children: [{
+ id: 4,
+ label: '后端工程师'
+ }, {
+ id: 5,
+ label: '前端工程师'
+ }, {
+ id: 6,
+ label: '运维工程师'
+ }]
+ }, {
+ id: 2,
+ label: '人事部'
+ }, {
+ id: 3,
+ label: '销售部'
+ }]
+ },
+ horizontal: false,
+ collapsable: false,
+ expandAll: true,
+ labelClassName: 'bg-white'
+ };
+ }
+
+ componentDidMount() {
+ }
+
+ componentWillUnmount() {
+ }
+
+ render() {
+ const { data, horizontal, collapsable, expandAll, labelClassName } = this.state;
+
+ return (
+
+ {
+ return data.label;
+ }}
+ onClick={(e, data) => {
+ //todo
+ }}
+ >
+
+
+ );
+ }
+}
+
+export default OrgTreeDemo;
\ No newline at end of file
diff --git a/docs/examples/expand.jsx b/docs/examples/expand.jsx
new file mode 100644
index 0000000..13e0e12
--- /dev/null
+++ b/docs/examples/expand.jsx
@@ -0,0 +1,70 @@
+import React, { Component } from 'react';
+
+import OrgTree from 'react-org-tree';
+
+class OrgTreeDemo extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ data: {
+ id: 0,
+ label: 'XXX股份有限公司',
+ children: [{
+ id: 1,
+ label: '技术部',
+ children: [{
+ id: 4,
+ label: '后端工程师'
+ }, {
+ id: 5,
+ label: '前端工程师'
+ }, {
+ id: 6,
+ label: '运维工程师'
+ }]
+ }, {
+ id: 2,
+ label: '人事部'
+ }, {
+ id: 3,
+ label: '销售部'
+ }]
+ },
+ horizontal: false,
+ collapsable: true,
+ expandAll: false,
+ labelClassName: 'bg-white'
+ };
+ }
+
+ componentDidMount() {
+ }
+
+ componentWillUnmount() {
+ }
+
+ render() {
+ const { data, horizontal, collapsable, expandAll, labelClassName } = this.state;
+
+ return (
+
+ {
+ return data.label;
+ }}
+ onClick={(e, data) => {
+ //todo
+ }}
+ >
+
+
+ );
+ }
+}
+
+export default OrgTreeDemo;
\ No newline at end of file
diff --git a/docs/examples/expandAll.jsx b/docs/examples/expandAll.jsx
new file mode 100644
index 0000000..4738927
--- /dev/null
+++ b/docs/examples/expandAll.jsx
@@ -0,0 +1,70 @@
+import React, { Component } from 'react';
+
+import OrgTree from 'react-org-tree';
+
+class OrgTreeDemo extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ data: {
+ id: 0,
+ label: 'XXX股份有限公司',
+ children: [{
+ id: 1,
+ label: '技术部',
+ children: [{
+ id: 4,
+ label: '后端工程师'
+ }, {
+ id: 5,
+ label: '前端工程师'
+ }, {
+ id: 6,
+ label: '运维工程师'
+ }]
+ }, {
+ id: 2,
+ label: '人事部'
+ }, {
+ id: 3,
+ label: '销售部'
+ }]
+ },
+ horizontal: false,
+ collapsable: true,
+ expandAll: true,
+ labelClassName: 'bg-white'
+ };
+ }
+
+ componentDidMount() {
+ }
+
+ componentWillUnmount() {
+ }
+
+ render() {
+ const { data, horizontal, collapsable, expandAll, labelClassName } = this.state;
+
+ return (
+
+ {
+ return data.label;
+ }}
+ onClick={(e, data) => {
+ //todo
+ }}
+ >
+
+
+ );
+ }
+}
+
+export default OrgTreeDemo;
\ No newline at end of file
diff --git a/docs/examples/horizontal.jsx b/docs/examples/horizontal.jsx
new file mode 100644
index 0000000..a14b5e3
--- /dev/null
+++ b/docs/examples/horizontal.jsx
@@ -0,0 +1,70 @@
+import React, { Component } from 'react';
+
+import OrgTree from 'react-org-tree';
+
+class OrgTreeDemo extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ data: {
+ id: 0,
+ label: 'XXX股份有限公司',
+ children: [{
+ id: 1,
+ label: '技术部',
+ children: [{
+ id: 4,
+ label: '后端工程师'
+ }, {
+ id: 5,
+ label: '前端工程师'
+ }, {
+ id: 6,
+ label: '运维工程师'
+ }]
+ }, {
+ id: 2,
+ label: '人事部'
+ }, {
+ id: 3,
+ label: '销售部'
+ }]
+ },
+ horizontal: true,
+ collapsable: true,
+ expandAll: true,
+ labelClassName: 'bg-white'
+ };
+ }
+
+ componentDidMount() {
+ }
+
+ componentWillUnmount() {
+ }
+
+ render() {
+ const { data, horizontal, collapsable, expandAll, labelClassName } = this.state;
+
+ return (
+
+ {
+ return data.label;
+ }}
+ onClick={(e, data) => {
+ //todo
+ }}
+ >
+
+
+ );
+ }
+}
+
+export default OrgTreeDemo;
\ No newline at end of file
diff --git a/docs/examples/vertical.jsx b/docs/examples/vertical.jsx
new file mode 100644
index 0000000..4738927
--- /dev/null
+++ b/docs/examples/vertical.jsx
@@ -0,0 +1,70 @@
+import React, { Component } from 'react';
+
+import OrgTree from 'react-org-tree';
+
+class OrgTreeDemo extends Component {
+ constructor(props) {
+ super(props);
+ this.state = {
+ data: {
+ id: 0,
+ label: 'XXX股份有限公司',
+ children: [{
+ id: 1,
+ label: '技术部',
+ children: [{
+ id: 4,
+ label: '后端工程师'
+ }, {
+ id: 5,
+ label: '前端工程师'
+ }, {
+ id: 6,
+ label: '运维工程师'
+ }]
+ }, {
+ id: 2,
+ label: '人事部'
+ }, {
+ id: 3,
+ label: '销售部'
+ }]
+ },
+ horizontal: false,
+ collapsable: true,
+ expandAll: true,
+ labelClassName: 'bg-white'
+ };
+ }
+
+ componentDidMount() {
+ }
+
+ componentWillUnmount() {
+ }
+
+ render() {
+ const { data, horizontal, collapsable, expandAll, labelClassName } = this.state;
+
+ return (
+
+ {
+ return data.label;
+ }}
+ onClick={(e, data) => {
+ //todo
+ }}
+ >
+
+
+ );
+ }
+}
+
+export default OrgTreeDemo;
\ No newline at end of file
diff --git a/docs/index.md b/docs/index.md
new file mode 100644
index 0000000..8699ee5
--- /dev/null
+++ b/docs/index.md
@@ -0,0 +1,5 @@
+---
+title: react-org-tree
+---
+
+
\ No newline at end of file
diff --git a/jsconfig.json b/jsconfig.json
new file mode 100644
index 0000000..78ee6db
--- /dev/null
+++ b/jsconfig.json
@@ -0,0 +1,16 @@
+{
+ "compilerOptions": {
+ "baseUrl": "./",
+ "paths": {
+ "react-org-tree": ["src/index.js"]
+ },
+ "target": "ES6",
+ "module": "commonjs",
+ "jsx": "react",
+ "allowSyntheticDefaultImports": true
+ },
+ "include": [
+ "src/**/*"
+ ],
+ "exclude": ["node_modules"]
+ }
\ No newline at end of file
diff --git a/package.json b/package.json
index faacb14..7419430 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "react-org-tree",
- "version": "0.2.5",
+ "version": "0.2.7",
"description": "a simple organization tree component based on react",
"main": "dist/bundle.js",
"files": [
@@ -8,6 +8,8 @@
"lib"
],
"scripts": {
+ "docs:start": "dumi dev",
+ "docs:build": "dumi build",
"test": "echo \"Error: no test specified\" && exit 1",
"build": "webpack"
},
@@ -34,7 +36,6 @@
"babel-loader": "^7.1.2",
"babel-preset-env": "^1.6.1",
"babel-preset-react": "^6.24.1",
- "classnames": "^2.2.6",
"css-loader": "^2.0.1",
"node-sass": "^4.11.0",
"less": "^3.9.0",
@@ -44,7 +45,10 @@
"sass-loader": "^7.1.0",
"style-loader": "^0.23.1",
"webpack": "^3.10.0",
- "webpack-node-externals": "^1.6.0"
+ "webpack-node-externals": "^1.6.0",
+ "dumi": "^1.1.4"
},
- "dependencies": {}
+ "dependencies": {
+ "classnames": "^2.2.6"
+ }
}
diff --git a/webpack.config.js b/webpack.config.js
index ad182c5..a218d77 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -21,5 +21,11 @@ module.exports = {
}
]
},
+ resolve: {
+ extensions: ['.js', '.jsx', '.json', '.less'],
+ alias: {
+ 'react-org-tree': path.resolve('src/index.js')
+ }
+ },
externals: [nodeExternals()]
};