Browse Source

feat: update tree

pull/2682/head
tanjinzhou 4 years ago
parent
commit
f35ae0efae
  1. 2
      antdv-demo
  2. 5
      components/tree/DirectoryTree.jsx
  3. 6
      components/tree/util.js
  4. 4
      components/vc-tree/src/Tree.jsx
  5. 4
      components/vc-tree/src/TreeNode.jsx
  6. 2
      examples/App.vue

2
antdv-demo

@ -1 +1 @@
Subproject commit 7713f7b97f8ce3493094935d5fc1eaaf4ea501aa
Subproject commit fe4a4e29aebe7cc1a5bbacf43c2b34671b00c880

5
components/tree/DirectoryTree.jsx

@ -57,7 +57,8 @@ export default {
data() {
const props = getOptionProps(this);
const { defaultExpandAll, defaultExpandParent, expandedKeys, defaultExpandedKeys } = props;
const { keyEntities } = convertTreeToEntities(this.$slots.default);
const children = getSlot(this);
const { keyEntities } = convertTreeToEntities(children);
const state = {};
// Selected keys
state._selectedKeys = props.selectedKeys || props.defaultSelectedKeys || [];
@ -67,7 +68,7 @@ export default {
if (props.treeData) {
state._expandedKeys = getFullKeyListByTreeData(props.treeData);
} else {
state._expandedKeys = getFullKeyList(this.$slots.default);
state._expandedKeys = getFullKeyList(children);
}
} else if (defaultExpandParent) {
state._expandedKeys = conductExpandParent(expandedKeys || defaultExpandedKeys, keyEntities);

6
components/tree/util.js

@ -1,5 +1,5 @@
import { getNodeChildren, convertTreeToEntities } from '../vc-tree/src/util';
import { getSlots } from '../_util/props-util';
import { getSlot } from '../_util/props-util';
const Record = {
None: 'node',
@ -13,9 +13,9 @@ function traverseNodesKey(rootChildren, callback) {
function processNode(node) {
const { key } = node;
const children = getSlots(node);
const children = getSlot(node);
if (callback(key, node) !== false) {
traverseNodesKey(typeof children === 'function' ? children() : children, callback);
traverseNodesKey(children, callback);
}
}

4
components/vc-tree/src/Tree.jsx

@ -1,7 +1,7 @@
import PropTypes from '../../_util/vue-types';
import classNames from 'classnames';
import warning from 'warning';
import { hasProp, initDefaultProps, getOptionProps, getSlots } from '../../_util/props-util';
import { hasProp, initDefaultProps, getOptionProps, getSlot } from '../../_util/props-util';
import { cloneElement } from '../../_util/vnode';
import BaseMixin from '../../_util/BaseMixin';
import {
@ -237,7 +237,7 @@ const Tree = {
onNodeDragStart(event, node) {
const { _expandedKeys } = this.$data;
const { eventKey } = node;
const children = getSlots(node);
const children = getSlot(node);
this.dragNode = node;
this.setState({

4
components/vc-tree/src/TreeNode.jsx

@ -54,6 +54,7 @@ const TreeNode = {
),
data() {
this.children = null;
return {
dragNodeHighlight: false,
};
@ -241,7 +242,7 @@ const TreeNode = {
},
getNodeChildren() {
const originList = getSlot(this);
const originList = this.children;
const targetList = getNodeChildren(originList);
if (originList.length !== targetList.length) {
@ -521,6 +522,7 @@ const TreeNode = {
},
render() {
this.children = getSlot(this);
const {
dragOver,
dragOverGapTop,

2
examples/App.vue

@ -4,7 +4,7 @@
</div>
</template>
<script>
import demo from '../antdv-demo/docs/tree/demo/customized-icon';
import demo from '../antdv-demo/docs/tree/demo/directory';
export default {
components: {

Loading…
Cancel
Save