Skip to content

Commit bb549d5

Browse files
committed
2 parents e3b593b + e23265c commit bb549d5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

47 files changed

+2931
-1964
lines changed

components/_util/BaseMixin.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getOptionProps } from './props-util'
21

32
export default {
43
directives: {
@@ -17,9 +16,9 @@ export default {
1716
methods: {
1817
setState (state, callback) {
1918
const newState = typeof state === 'function' ? state(this.$data) : state
20-
if (this.getDerivedStateFromProps) {
21-
Object.assign(newState, this.getDerivedStateFromProps(getOptionProps(this), this.$data, true) || {})
22-
}
19+
// if (this.getDerivedStateFromProps) {
20+
// Object.assign(newState, this.getDerivedStateFromProps(getOptionProps(this), { ...this.$data, ...newState }, true) || {})
21+
// }
2322
Object.assign(this.$data, newState)
2423
this.$nextTick(() => {
2524
callback && callback()
Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,19 @@
11
// Jest Snapshot v1, https://goo.gl/fbAQLP
22

3-
exports[`renders ./components/tree-select/demo/basic.md correctly 1`] = `
4-
<span class="ant-select ant-select-enabled ant-select-allow-clear" style="width: 300px;"><span role="combobox" aria-autocomplete="list" aria-haspopup="true" tabindex="0" class="ant-select-selection
5-
ant-select-selection--single"><span class="ant-select-selection__rendered"><span class="ant-select-selection__placeholder">Please select</span></span><span class="ant-select-arrow" style="outline: none;"><i class="ant-select-arrow-icon anticon anticon-down"><svg viewBox="64 64 896 896" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></i></span></span></span>
6-
`;
3+
exports[`renders ./components/tree-select/demo/basic.md correctly 1`] = `<span role="combobox" aria-haspopup="listbox" tabindex="0" class="ant-select ant-select-enabled ant-select-allow-clear" style="width: 300px;"><span class="ant-select-selection ant-select-selection--single"><span class="ant-select-selection__rendered"><span class="ant-select-selection__placeholder">Please select</span></span><span class="ant-select-arrow" style="outline: none;"><i class="ant-select-arrow-icon anticon anticon-down"><svg viewBox="64 64 896 896" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></i></span></span></span>`;
74

85
exports[`renders ./components/tree-select/demo/checkable.md correctly 1`] = `
9-
<span class="ant-select ant-select-enabled" style="width: 300px;"><span role="combobox" aria-autocomplete="list" aria-haspopup="true" class="ant-select-selection
10-
ant-select-selection--multiple"><div class="ant-select-selection__rendered"><li title="Node1" unselectable="unselectable" class="ant-select-selection__choice"><span class="ant-select-selection__choice__remove"><i class="ant-select-remove-icon anticon anticon-close"><svg viewBox="64 64 896 896" data-icon="close" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg></i></span><span class="ant-select-selection__choice__content">Node1</span></li>
11-
<li class="ant-select-search ant-select-search--inline"><span class="ant-select-search__field__wrap"><input role="textbox" class="ant-select-search__field"><span class="ant-select-search__field__mirror">&nbsp;</span></span></li>
12-
</div><span class="ant-select-search__field__placeholder" style="display: none;">Please select</span></span>
13-
</span>
6+
<span role="combobox" aria-haspopup="listbox" tabindex="-1" class="ant-select ant-select-enabled" style="width: 300px;"><span class="ant-select-selection ant-select-selection--multiple"><div class="ant-select-selection__rendered"><li unselectable="unselectable" role="menuitem" title="Node1" class="ant-select-selection__choice"><span class="ant-select-selection__choice__remove"><i class="ant-select-remove-icon anticon anticon-close"><svg viewBox="64 64 896 896" data-icon="close" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M563.8 512l262.5-312.9c4.4-5.2.7-13.1-6.1-13.1h-79.8c-4.7 0-9.2 2.1-12.3 5.7L511.6 449.8 295.1 191.7c-3-3.6-7.5-5.7-12.3-5.7H203c-6.8 0-10.5 7.9-6.1 13.1L459.4 512 196.9 824.9A7.95 7.95 0 0 0 203 838h79.8c4.7 0 9.2-2.1 12.3-5.7l216.5-258.1 216.5 258.1c3 3.6 7.5 5.7 12.3 5.7h79.8c6.8 0 10.5-7.9 6.1-13.1L563.8 512z"></path></svg></i></span><span class="ant-select-selection__choice__content">Node1</span></li>
7+
<li class="ant-select-search ant-select-search--inline"><span class="ant-select-search__field__wrap"><input type="text" aria-label="filter select" aria-autocomplete="list" aria-multiline="false" class="ant-select-search__field" style="width: 0px;"><span class="ant-select-search__field__mirror">&nbsp;</span></span></li>
8+
</div>
9+
</span></span>
1410
`;
1511
1612
exports[`renders ./components/tree-select/demo/multiple.md correctly 1`] = `
17-
<span class="ant-select ant-select-enabled ant-select-allow-clear" style="width: 300px;"><span role="combobox" aria-autocomplete="list" aria-haspopup="true" class="ant-select-selection
18-
ant-select-selection--multiple"><div class="ant-select-selection__rendered"><li class="ant-select-search ant-select-search--inline"><span class="ant-select-search__field__wrap"><input role="textbox" class="ant-select-search__field"><span class="ant-select-search__field__mirror">&nbsp;</span></span></li>
13+
<span role="combobox" aria-haspopup="listbox" tabindex="-1" class="ant-select ant-select-enabled ant-select-allow-clear" style="width: 300px;"><span class="ant-select-selection ant-select-selection--multiple"><div class="ant-select-selection__rendered"><li class="ant-select-search ant-select-search--inline"><span class="ant-select-search__field__wrap"><input type="text" aria-label="filter select" aria-autocomplete="list" aria-multiline="false" class="ant-select-search__field" style="width: 0px;"><span class="ant-select-search__field__mirror">&nbsp;</span></span></li>
1914
</div><span class="ant-select-search__field__placeholder" style="display: block;">Please select</span></span></span>
2015
`;
2116
22-
exports[`renders ./components/tree-select/demo/treeData.md correctly 1`] = `
23-
<span class="ant-select ant-select-enabled" style="width: 300px;"><span role="combobox" aria-autocomplete="list" aria-haspopup="true" tabindex="0" class="ant-select-selection
24-
ant-select-selection--single"><span class="ant-select-selection__rendered"><span class="ant-select-selection__placeholder">Please select</span></span><span class="ant-select-arrow" style="outline: none;"><i class="ant-select-arrow-icon anticon anticon-down"><svg viewBox="64 64 896 896" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></i></span></span></span>
25-
`;
17+
exports[`renders ./components/tree-select/demo/suffix.md correctly 1`] = `<span role="combobox" aria-haspopup="listbox" tabindex="0" class="ant-select ant-select-enabled ant-select-allow-clear" style="width: 300px;"><span class="ant-select-selection ant-select-selection--single"><span class="ant-select-selection__rendered"><span class="ant-select-selection__placeholder">Please select</span></span><span class="ant-select-arrow" style="outline: none;"><i class="anticon anticon-smile"><svg viewBox="64 64 896 896" data-icon="smile" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M288 421a48 48 0 1 0 96 0 48 48 0 1 0-96 0zm352 0a48 48 0 1 0 96 0 48 48 0 1 0-96 0zM512 64C264.6 64 64 264.6 64 512s200.6 448 448 448 448-200.6 448-448S759.4 64 512 64zm263 711c-34.2 34.2-74 61-118.3 79.8C611 874.2 562.3 884 512 884c-50.3 0-99-9.8-144.8-29.2A370.4 370.4 0 0 1 248.9 775c-34.2-34.2-61-74-79.8-118.3C149.8 611 140 562.3 140 512s9.8-99 29.2-144.8A370.4 370.4 0 0 1 249 248.9c34.2-34.2 74-61 118.3-79.8C413 149.8 461.7 140 512 140c50.3 0 99 9.8 144.8 29.2A370.4 370.4 0 0 1 775.1 249c34.2 34.2 61 74 79.8 118.3C874.2 413 884 461.7 884 512s-9.8 99-29.2 144.8A368.89 368.89 0 0 1 775 775zM664 533h-48.1c-4.2 0-7.8 3.2-8.1 7.4C604 589.9 562.5 629 512 629s-92.1-39.1-95.8-88.6c-.3-4.2-3.9-7.4-8.1-7.4H360a8 8 0 0 0-8 8.4c4.4 84.3 74.5 151.6 160 151.6s155.6-67.3 160-151.6a8 8 0 0 0-8-8.4z"></path></svg></i></span></span></span>`;
18+
19+
exports[`renders ./components/tree-select/demo/treeData.md correctly 1`] = `<span role="combobox" aria-haspopup="listbox" tabindex="0" class="ant-select ant-select-enabled" style="width: 300px;"><span class="ant-select-selection ant-select-selection--single"><span class="ant-select-selection__rendered"><span class="ant-select-selection__placeholder">Please select</span></span><span class="ant-select-arrow" style="outline: none;"><i class="ant-select-arrow-icon anticon anticon-down"><svg viewBox="64 64 896 896" data-icon="down" width="1em" height="1em" fill="currentColor" aria-hidden="true" class=""><path d="M884 256h-75c-5.1 0-9.9 2.5-12.9 6.6L512 654.2 227.9 262.6c-3-4.1-7.8-6.6-12.9-6.6h-75c-6.5 0-10.3 7.4-6.5 12.7l352.6 486.1c12.8 17.6 39 17.6 51.7 0l352.6-486.1c3.9-5.3.1-12.7-6.4-12.7z"></path></svg></i></span></span></span>`;

components/tree-select/demo/basic.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ The most basic usage.
2222
>
2323
<a-tree-select-node value='parent 1' title='parent 1' key='0-1'>
2424
<a-tree-select-node value='parent 1-0' title='parent 1-0' key='0-1-1'>
25-
<a-tree-select-node value='leaf1' title='my leaf' key='random' />
25+
<a-tree-select-node :selectable="false" value='leaf1' title='my leaf' key='random' />
2626
<a-tree-select-node value='leaf2' title='your leaf' key='random1' />
2727
</a-tree-select-node>
2828
<a-tree-select-node value='parent 1-1' title='parent 1-1' key='random2'>
@@ -39,12 +39,13 @@ The most basic usage.
3939
export default {
4040
data () {
4141
return {
42+
treeExpandedKeys: [],
4243
value: undefined,
4344
}
4445
},
4546
methods: {
4647
onChange (value) {
47-
console.log(arguments)
48+
console.log(value)
4849
this.value = value
4950
},
5051
},

components/tree-select/demo/checkable.md

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ Multiple and checkable.
1818
treeCheckable
1919
:showCheckedStrategy="SHOW_PARENT"
2020
searchPlaceholder='Please select'
21-
treeNodeFilterProp='label'
2221
/>
2322
</template>
2423

@@ -27,29 +26,29 @@ import { TreeSelect } from 'ant-design-vue'
2726
const SHOW_PARENT = TreeSelect.SHOW_PARENT
2827
2928
const treeData = [{
30-
label: 'Node1',
29+
title: 'Node1',
3130
value: '0-0',
3231
key: '0-0',
3332
children: [{
34-
label: 'Child Node1',
33+
title: 'Child Node1',
3534
value: '0-0-0',
3635
key: '0-0-0',
3736
}],
3837
}, {
39-
label: 'Node2',
38+
title: 'Node2',
4039
value: '0-1',
4140
key: '0-1',
4241
children: [{
43-
label: 'Child Node3',
42+
title: 'Child Node3',
4443
value: '0-1-0',
4544
key: '0-1-0',
4645
disabled: true,
4746
}, {
48-
label: 'Child Node4',
47+
title: 'Child Node4',
4948
value: '0-1-1',
5049
key: '0-1-1',
5150
}, {
52-
label: 'Child Node5',
51+
title: 'Child Node5',
5352
value: '0-1-2',
5453
key: '0-1-2',
5554
}],
@@ -64,7 +63,7 @@ export default {
6463
},
6564
methods: {
6665
onChange (value) {
67-
console.log('onChange ', value, arguments)
66+
console.log('onChange ', value)
6867
this.value = value
6968
},
7069
},

components/tree-select/demo/index.vue

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import Basic from './basic'
33
import Checkable from './checkable'
44
import Multiple from './multiple'
55
import TreeData from './treeData'
6+
import Suffix from './suffix'
67
78
import CN from '../index.zh-CN.md'
89
import US from '../index.en-US.md'
@@ -35,6 +36,7 @@ export default {
3536
<Checkable/>
3637
<Multiple/>
3738
<TreeData/>
39+
<Suffix />
3840
<api>
3941
<template slot='cn'>
4042
<CN/>

components/tree-select/demo/multiple.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ export default {
4747
},
4848
methods: {
4949
onChange (value) {
50-
console.log(arguments)
50+
console.log(value)
5151
this.value = value
5252
},
5353
onSearch () {
54-
console.log(arguments)
54+
console.log(...arguments)
5555
},
5656
onSelect () {
57-
console.log(arguments)
57+
console.log(...arguments)
5858
},
5959
},
6060
}

components/tree-select/demo/suffix.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
<cn>
2+
#### 后缀图标
3+
最简单的用法。
4+
</cn>
5+
6+
<us>
7+
#### Suffix
8+
The most basic usage.
9+
</us>
10+
11+
```html
12+
<template>
13+
<a-tree-select
14+
showSearch
15+
style="width: 300px"
16+
:value="value"
17+
:dropdownStyle="{ maxHeight: '400px', overflow: 'auto' }"
18+
placeholder='Please select'
19+
allowClear
20+
treeDefaultExpandAll
21+
@change="onChange"
22+
>
23+
<a-icon slot="suffixIcon" type="smile" />
24+
<a-tree-select-node value='parent 1' title='parent 1' key='0-1'>
25+
<a-tree-select-node value='parent 1-0' title='parent 1-0' key='0-1-1'>
26+
<a-tree-select-node value='leaf1' title='my leaf' key='random' />
27+
<a-tree-select-node value='leaf2' title='your leaf' key='random1' />
28+
</a-tree-select-node>
29+
<a-tree-select-node value='parent 1-1' title='parent 1-1' key='random2'>
30+
<a-tree-select-node value='sss' key='random3'>
31+
<b style="color: #08c" slot="title">sss</b>
32+
</a-tree-select-node>
33+
</a-tree-select-node>
34+
</a-tree-select-node>
35+
</a-tree-select>
36+
</template>
37+
38+
<script>
39+
40+
export default {
41+
data () {
42+
return {
43+
value: undefined,
44+
}
45+
},
46+
methods: {
47+
onChange (value) {
48+
console.log(value)
49+
this.value = value
50+
},
51+
},
52+
}
53+
</script>
54+
```

components/tree-select/demo/treeData.md

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,32 @@ The tree structure can be populated using `treeData` property. This is a quick a
1616
:treeData="treeData"
1717
placeholder='Please select'
1818
treeDefaultExpandAll
19-
labelInValue
2019
v-model="value"
2120
>
22-
<span style="color: #08c" slot="label" slot-scope="{key, value}" v-if="key='0-0-1'">
21+
<span style="color: #08c" slot="title" slot-scope="{key, value}" v-if="key='0-0-1'">
2322
<a-icon type="home"/>Child Node1 {{value}}
2423
</span>
2524
</a-tree-select>
2625
</template>
2726

2827
<script>
2928
const treeData = [{
30-
label: 'Node1',
29+
title: 'Node1',
3130
value: '0-0',
3231
key: '0-0',
3332
children: [{
3433
value: '0-0-1',
3534
key: '0-0-1',
36-
scopedSlots: { // custom label
37-
label: 'label',
35+
scopedSlots: { // custom title
36+
title: 'title',
3837
},
3938
}, {
40-
label: 'Child Node2',
39+
title: 'Child Node2',
4140
value: '0-0-2',
4241
key: '0-0-2',
4342
}],
4443
}, {
45-
label: 'Node2',
44+
title: 'Node2',
4645
value: '0-1',
4746
key: '0-1',
4847
}]

components/tree-select/index.en-US.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,23 +21,25 @@
2121
| showCheckedStrategy | The way show selected item in box. **Default:** just show child nodes. **`TreeSelect.SHOW_ALL`:** show all checked treeNodes (include parent treeNode). **`TreeSelect.SHOW_PARENT`:** show checked treeNodes (just show parent treeNode). | enum { TreeSelect.SHOW_ALL, TreeSelect.SHOW_PARENT, TreeSelect.SHOW_CHILD } | TreeSelect.SHOW_CHILD |
2222
| showSearch | Whether to display a search input in the dropdown menu(valid only in the single mode) | boolean | false |
2323
| size | To set the size of the select input, options: `large` `small` | string | 'default' |
24+
| suffixIcon | The custom suffix icon | VNode \| slot | - |
2425
| treeCheckable | Whether to show checkbox on the treeNodes | boolean | false |
2526
| treeCheckStrictly | Whether to check nodes precisely (in the `checkable` mode), means parent and child nodes are not associated, and it will make `labelInValue` be true | boolean | false |
2627
| treeData | Data of the treeNodes, manual construction work is no longer needed if this property has been set(ensure the Uniqueness of each value) | array&lt;{ value, label, children, [disabled, disableCheckbox, selectable] }> | \[] |
2728
| treeDataSimpleMode | Enable simple mode of treeData.(treeData should like this: [{id:1, pId:0, value:'1', label:"test1",...},...], pId is parent node's id) | false\|Array&lt;{ id: string, pId: string, rootPId: null }> | false |
2829
| treeDefaultExpandAll | Whether to expand all treeNodes by default | boolean | false |
2930
| treeDefaultExpandedKeys | Default expanded treeNodes | string\[] | - |
31+
| treeExpandedKeys | Set expanded keys | string\[] | - |
3032
| treeNodeFilterProp | Will be used for filtering if `filterTreeNode` returns true | string | 'value' |
3133
| treeNodeLabelProp | Will render as content of select | string | 'title' |
3234
| value(v-model) | To set the current selected treeNode(s). | string\|string\[] | - |
33-
| suffixIcon | The custom suffix icon | VNode \| slot | - |
3435

3536
### Events
3637
| Events Name | Description | Arguments |
3738
| --- | --- | --- |
3839
| change | A callback function, can be executed when selected treeNodes or input value change | function(value, label, extra) |
3940
| search | A callback function, can be executed when the search input changes. | function(value: string) |
4041
| select | A callback function, can be executed when you select a treeNode. | function(value, node, extra) |
42+
| treeExpand | A callback function, can be executed when treeNode expanded | function(expandedKeys) |
4143

4244
### Tree Methods
4345

@@ -52,6 +54,7 @@
5254
5355
| Property | Description | Type | Default |
5456
| -------- | ----------- | ---- | ------- |
57+
| selectable | can be selected | boolean | true |
5558
| disableCheckbox | Disables the checkbox of the treeNode | boolean | false |
5659
| disabled | Disabled or not | boolean | false |
5760
| isLeaf | Leaf node or not | boolean | false |

components/tree-select/index.jsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,10 +136,12 @@ const TreeSelect = {
136136
dropdownStyle: { maxHeight: '100vh', overflow: 'auto', ...dropdownStyle },
137137
treeCheckable: checkable,
138138
notFoundContent: notFoundContent || locale.notFoundContent,
139+
__propsSymbol__: Symbol(),
139140
},
140141
class: cls,
141142
on: { ...this.$listeners, change: this.onChange },
142143
ref: 'vcTreeSelect',
144+
scopedSlots: this.$scopedSlots,
143145
}
144146
return (
145147
<VcTreeSelect {...VcTreeSelectProps}>{filterEmpty(this.$slots.default)}</VcTreeSelect>

0 commit comments

Comments
 (0)