Skip to content

Commit c7ab23c

Browse files
committed
feat: update tree
1 parent 90960e0 commit c7ab23c

File tree

14 files changed

+200
-704
lines changed

14 files changed

+200
-704
lines changed

components/index.js

Lines changed: 1 addition & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -125,101 +125,60 @@ import { default as Drawer } from './drawer'
125125
const components = [
126126
Affix,
127127
Anchor,
128-
Anchor.Link,
129128
AutoComplete,
130-
AutoComplete.Option,
131-
AutoComplete.OptGroup,
132129
Alert,
133130
Avatar,
134131
BackTop,
135132
Badge,
136133
Breadcrumb,
137-
Breadcrumb.Item,
138134
Button,
139-
Button.Group,
140135
Calendar,
141136
Card,
142-
Card.Meta,
143-
Card.Grid,
144137
Collapse,
145-
Collapse.Panel,
146138
Carousel,
147139
Cascader,
148140
Checkbox,
149-
Checkbox.Group,
150141
Col,
151142
DatePicker,
152-
DatePicker.MonthPicker,
153-
DatePicker.RangePicker,
154-
DatePicker.WeekPicker,
155143
Divider,
156144
Dropdown,
157-
Dropdown.Button,
158145
Form,
159-
Form.Item,
160146
Icon,
161147
Input,
162-
Input.Group,
163-
Input.Search,
164-
Input.TextArea,
165148
InputNumber,
166149
Layout,
167-
Layout.Header,
168-
Layout.Footer,
169-
Layout.Sider,
170-
Layout.Content,
171150
List,
172-
List.Item,
173-
List.Item.Meta,
174151
LocaleProvider,
175152
Menu,
176-
Menu.Item,
177-
Menu.SubMenu,
178-
Menu.Divider,
179-
Menu.ItemGroup,
180153
Modal,
181154
Pagination,
182155
Popconfirm,
183156
Popover,
184157
Progress,
185158
Radio,
186-
Radio.Group,
187-
Radio.Button,
188159
Rate,
189160
Row,
190161
Select,
191-
Select.Option,
192-
Select.OptGroup,
193162
Slider,
194163
Spin,
195164
Steps,
196-
Steps.Step,
197165
Switch,
198166
Table,
199-
Table.Column,
200-
Table.ColumnGroup,
201167
Transfer,
202168
Tree,
203-
Tree.TreeNode,
204169
TreeSelect,
205-
TreeSelect.TreeNode,
206170
Tabs,
207-
Tabs.TabPane,
208-
Tabs.TabContent,
209171
Tag,
210-
Tag.CheckableTag,
211172
TimePicker,
212173
Timeline,
213-
Timeline.Item,
214174
Tooltip,
215175
Upload,
216-
Upload.Dragger,
217176
Drawer,
218177
]
219178

220179
const install = function (Vue) {
221180
components.map(component => {
222-
Vue.component(component.name, component)
181+
Vue.use(component)
223182
})
224183

225184
Vue.prototype.$message = message

components/tree/DirectoryTree.jsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { conductExpandParent, convertTreeToEntities } from '../vc-tree/src/util'
55
import Tree, { TreeProps } from './Tree'
66
import { calcRangeKeys, getFullKeyList } from './util'
77
import Icon from '../icon'
8+
import BaseMixin from '../_util/BaseMixin'
89
import { initDefaultProps, getOptionProps } from '../_util/props-util'
910

1011
// export type ExpandAction = false | 'click' | 'doubleClick';
@@ -27,12 +28,13 @@ function getIcon (h, props) {
2728
}
2829

2930
export default {
31+
mixins: [BaseMixin],
3032
name: 'ADirectoryTree',
3133
model: {
3234
prop: 'checkedKeys',
3335
event: 'check',
3436
},
35-
props: initDefaultProps({ ...TreeProps(), expandAction: PropTypes.oneOf([false, 'click', 'doubleClick']) }, {
37+
props: initDefaultProps({ ...TreeProps(), expandAction: PropTypes.oneOf([false, 'click', 'doubleclick']) }, {
3638
prefixCls: 'ant-tree',
3739
showIcon: true,
3840
expandAction: 'click',
@@ -55,7 +57,7 @@ export default {
5557

5658
// Expanded keys
5759
if (defaultExpandAll) {
58-
state._expandedKeys = getFullKeyList(props.children)
60+
state._expandedKeys = getFullKeyList(this.$slots.default)
5961
} else if (defaultExpandParent) {
6062
state._expandedKeys = conductExpandParent(expandedKeys || defaultExpandedKeys, keyEntities)
6163
} else {
@@ -102,7 +104,7 @@ export default {
102104
const { expandAction } = this.$props
103105

104106
// Expand the tree
105-
if (expandAction === 'doubleClick') {
107+
if (expandAction === 'doubleclick') {
106108
this.onDebounceExpand(event, node)
107109
}
108110

@@ -117,7 +119,6 @@ export default {
117119
const { eventKey = '' } = node
118120

119121
const newState = {}
120-
121122
// Windows / Mac single pick
122123
const ctrlPick = nativeEvent.ctrlKey || nativeEvent.metaKey
123124
const shiftPick = nativeEvent.shiftKey
@@ -171,7 +172,7 @@ export default {
171172
this.$emit('expand', newExpandedKeys, {
172173
expanded: !expanded,
173174
node,
174-
nativeEvent: event.nativeEvent,
175+
nativeEvent: event,
175176
})
176177
},
177178

@@ -195,10 +196,13 @@ export default {
195196
selectedKeys,
196197
},
197198
class: `${prefixCls}-directory`,
198-
select: this.onSelect,
199-
click: this.onClick,
200-
doubleclick: this.onDoubleClick,
201-
expand: this.onExpand,
199+
on: {
200+
...this.$listeners,
201+
select: this.onSelect,
202+
click: this.onClick,
203+
doubleclick: this.onDoubleClick,
204+
expand: this.onExpand,
205+
},
202206
}
203207
return (
204208
<Tree {...treeProps}>{this.$slots.default}</Tree>

components/tree/Tree.jsx

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -113,12 +113,8 @@ export default {
113113
const { children, on = {}, slots = {}, scopedSlots = {}, key, class: cls, style, ...restProps } = item
114114
const treeNodeProps = {
115115
...restProps,
116-
icon: restProps.icon ||
117-
$slots[slots.icon] ||
118-
($scopedSlots[scopedSlots.icon] && $scopedSlots[scopedSlots.icon]),
119-
title: restProps.title ||
120-
$slots[slots.title] ||
121-
($scopedSlots[scopedSlots.title] && $scopedSlots[scopedSlots.title])(item),
116+
icon: $slots[slots.icon] || ($scopedSlots[scopedSlots.icon] && $scopedSlots[scopedSlots.icon]) || restProps.icon,
117+
title: $slots[slots.title] || ($scopedSlots[scopedSlots.title] && $scopedSlots[scopedSlots.title](item)) || restProps.title,
122118
dataRef: item,
123119
on,
124120
key,

0 commit comments

Comments
 (0)