From 6770417d91df80aeea0d116fccaf3ffae8f0ee29 Mon Sep 17 00:00:00 2001
From: Boyuzhou <2470200492@qq.com>
Date: Sun, 21 Jan 2018 21:47:49 +0800
Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E7=A4=BA=E4=BE=8B?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
demo/Demo1.js | 61 -
demo/Demo4.js | 160 ---
demo/TreeDemo.scss | 16 +-
demo/demolist/Demo4.scss | 4 +
demo/demolist/Demo8.scss | 11 +
demo/index-demo-base.js | 100 +-
demo/index.js | 102 +-
dist/demo.css | 171 +--
dist/demo.css.map | 2 +-
dist/demo.js | 2741 ++++++++------------------------------
dist/demo.js.map | 2 +-
11 files changed, 720 insertions(+), 2650 deletions(-)
delete mode 100644 demo/Demo1.js
delete mode 100644 demo/Demo4.js
create mode 100644 demo/demolist/Demo4.scss
create mode 100644 demo/demolist/Demo8.scss
diff --git a/demo/Demo1.js b/demo/Demo1.js
deleted file mode 100644
index c2fcd7d..0000000
--- a/demo/Demo1.js
+++ /dev/null
@@ -1,61 +0,0 @@
-/**
- *
- * @title Tree基本使用事例
- * @description 事例涵盖 checkbox如何选择,disable状态和部分选择状态。
- *
- */
-
-
-import React, {
- Component
-} from 'react';
-import Tree from '../../src';
-
-const TreeNode = Tree.TreeNode;
-
-const defaultProps = {
- keys: ['0-0-0', '0-0-1']
-}
-console.log(Tree);
-class Demo1 extends Component {
- constructor(props) {
- super(props);
- const keys = this.props.keys;
- this.state = {
- defaultExpandedKeys: keys,
- defaultSelectedKeys: keys,
- defaultCheckedKeys: keys,
- };
- }
- onSelect(info) {
- console.log('selected', info);
- }
- onCheck(info) {
- console.log('onCheck', info);
- }
- render() {
- return (
-
-
-
-
-
-
-
- sss} key="0-0-1-0" />
-
-
-
- );
- }
-}
-
-Demo1.defaultProps = defaultProps;
-
-
-export default Demo1;
\ No newline at end of file
diff --git a/demo/Demo4.js b/demo/Demo4.js
deleted file mode 100644
index 7ff2428..0000000
--- a/demo/Demo4.js
+++ /dev/null
@@ -1,160 +0,0 @@
-/**
- *
- * @title Tree可搜索事例
- * @description
- *
- */
-
-
-import React, {
- Component
-} from 'react';
-import FormControl from 'bee-form-control';
-import Tree from '../../src';
-
-const x = 3;
-const y = 2;
-const z = 1;
-const gData = [];
-
-const generateData = (_level, _preKey, _tns) => {
- const preKey = _preKey || '0';
- const tns = _tns || gData;
-
- const children = [];
- for (let i = 0; i < x; i++) {
- const key = `${preKey}-${i}`;
- tns.push({
- title: key,
- key
- });
- if (i < y) {
- children.push(key);
- }
- }
- if (_level < 0) {
- return tns;
- }
- const level = _level - 1;
- children.forEach((key, index) => {
- tns[index].children = [];
- return generateData(level, key, tns[index].children);
- });
-};
-generateData(z);
-
-const TreeNode = Tree.TreeNode;
-
-const dataList = [];
-const generateList = (data) => {
- for (let i = 0; i < data.length; i++) {
- const node = data[i];
- const key = node.key;
- dataList.push({
- key,
- title: key
- });
- if (node.children) {
- generateList(node.children, node.key);
- }
- }
-};
-generateList(gData);
-
-const getParentKey = (key, tree) => {
- let parentKey;
- for (let i = 0; i < tree.length; i++) {
- const node = tree[i];
- if (node.children) {
- if (node.children.some(item => item.key === key)) {
- parentKey = node.key;
- } else if (getParentKey(key, node.children)) {
- parentKey = getParentKey(key, node.children);
- }
- }
- }
- return parentKey;
-};
-
-
-class Demo4 extends Component {
- constructor(props) {
- super(props);
- this.state = {
- expandedKeys: [],
- searchValue: '',
- autoExpandParent: true,
- }
- }
- onExpand = (expandedKeys) => {
- this.setState({
- expandedKeys,
- autoExpandParent: false,
- });
- }
- onChange = (value) => {
- // const value = e.target.value;
- const expandedKeys = [];
- dataList.forEach((item) => {
- if (item.key.indexOf(value) > -1) {
- expandedKeys.push(getParentKey(item.key, gData));
- }
- });
- const uniqueExpandedKeys = [];
- expandedKeys.forEach((item) => {
- if (item && uniqueExpandedKeys.indexOf(item) === -1) {
- uniqueExpandedKeys.push(item);
- }
- });
- this.setState({
- expandedKeys: uniqueExpandedKeys,
- searchValue: value,
- autoExpandParent: true,
- });
- }
- render() {
- const {
- searchValue,
- expandedKeys,
- autoExpandParent
- } = this.state;
- const loop = data => data.map((item) => {
- const index = item.key.search(searchValue);
- const beforeStr = item.key.substr(0, index);
- const afterStr = item.key.substr(index + searchValue.length);
- const title = index > -1 ? (
-
- {beforeStr}
- {searchValue}
- {afterStr}
-
- ) : {item.key};
- if (item.children) {
- return (
-
- {loop(item.children)}
-
- );
- }
- return ;
- });
- return (
-
-
-
- {loop(gData)}
-
-
- );
- }
-}
-
-export default Demo4;
\ No newline at end of file
diff --git a/demo/TreeDemo.scss b/demo/TreeDemo.scss
index dbef53b..ccab978 100644
--- a/demo/TreeDemo.scss
+++ b/demo/TreeDemo.scss
@@ -5,19 +5,5 @@
@import "../node_modules/bee-button/src/Button.scss";
@import "../node_modules/bee-transition/src/Transition.scss";
@import "../node_modules/bee-form-control/src/FormControl.scss";
-.u-tree-searchable-filter {
- color: #f50;
- transition: all .3s ease;
-}
-.title-middle {
- display: inline-block;
- vertical-align: middle;
-}
-.edit-icon {
- float:right;
- font-size: 14px;
-}
-.title-con {
- min-width: 150px;
-}
\ No newline at end of file
+
diff --git a/demo/demolist/Demo4.scss b/demo/demolist/Demo4.scss
new file mode 100644
index 0000000..d1fa8cf
--- /dev/null
+++ b/demo/demolist/Demo4.scss
@@ -0,0 +1,4 @@
+.u-tree-searchable-filter {
+ color: #f50;
+ transition: all .3s ease;
+}
\ No newline at end of file
diff --git a/demo/demolist/Demo8.scss b/demo/demolist/Demo8.scss
new file mode 100644
index 0000000..c78b6e7
--- /dev/null
+++ b/demo/demolist/Demo8.scss
@@ -0,0 +1,11 @@
+.title-middle {
+ display: inline-block;
+ vertical-align: middle;
+}
+.edit-icon {
+ float:right;
+ font-size: 14px;
+}
+.title-con {
+ min-width: 150px;
+}
\ No newline at end of file
diff --git a/demo/index-demo-base.js b/demo/index-demo-base.js
index 03b9817..c6c1f59 100644
--- a/demo/index-demo-base.js
+++ b/demo/index-demo-base.js
@@ -1,41 +1,9 @@
-
-import { Con, Row, Col } from 'bee-layout';
-import { Panel } from 'bee-panel';
+import {Col, Row} from 'bee-layout';
+import {Panel} from 'bee-panel';
import Button from 'bee-button';
-import React, { Component } from 'react';
+import React, {Component} from 'react';
import ReactDOM from 'react-dom';
-import FormControl from 'bee-form-control';
-import Tree from '../src';
-const x = 3;
-const y = 2;
-const z = 1;
-const gData = [];
-
-const generateData = (_level, _preKey, _tns) => {
- const preKey = _preKey || '0';
- const tns = _tns || gData;
-
- const children = [];
- for (let i = 0; i < x; i++) {
- const key = `${preKey}-${i}`;
- tns.push({ title: key, key });
- if (i < y) {
- children.push(key);
- }
- }
- if (_level < 0) {
- return tns;
- }
- const level = _level - 1;
- children.forEach((key, index) => {
- tns[index].children = [];
- return generateData(level, key, tns[index].children);
- });
-};
-generateData(z);
-
-const TreeNode = Tree.TreeNode;
const CARET = ;
@@ -45,46 +13,40 @@ const CARETUP = ;
{demolist}
class Demo extends Component {
- constructor(props){
+ constructor(props) {
super(props);
this.state = {
open: false
}
this.handleClick = this.handleClick.bind(this);
}
+
handleClick() {
- this.setState({ open: !this.state.open })
+ this.setState({open: !this.state.open})
}
- render () {
- const { title, example, code, desc } = this.props;
+ render() {
+ const {title, example, code, desc, scss_code} = this.props;
let caret = this.state.open ? CARETUP : CARET;
let text = this.state.open ? "隐藏代码" : "查看代码";
- const footer = (
-
- );
const header = (
-
-
- { example }
-
-
-