Skip to content

Commit 3a2a672

Browse files
committed
doc: update auto-complete demo
1 parent 275996e commit 3a2a672

File tree

5 files changed

+37
-97
lines changed

5 files changed

+37
-97
lines changed

components/auto-complete/__tests__/__snapshots__/demo.test.js.snap

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,10 @@ exports[`renders ./components/auto-complete/demo/basic.vue correctly 1`] = `
1414
1515
exports[`renders ./components/auto-complete/demo/certain-category.vue correctly 1`] = `
1616
<div class="certain-category-search-wrapper" style="width: 250px;">
17-
<div class="ant-select ant-select-lg certain-category-search ant-select-lg ant-select-show-search ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search" style="width: 100%;">
17+
<div class="ant-select certain-category-search ant-select-show-search ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search" style="width: 250px;">
1818
<!---->
1919
<!---->
20-
<div class="ant-select-selector"><span class="ant-select-selection-search"><span class="ant-input-affix-wrapper ant-select-selection-search-input"><!----><input placeholder="input here" id="rc_select_TEST_OR_SSR" autocomplete="off" type="search" class="ant-input" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_TEST_OR_SSR_list" aria-autocomplete="list" aria-controls="rc_select_TEST_OR_SSR_list" aria-activedescendant="rc_select_TEST_OR_SSR_list_0"><span class="ant-input-suffix"><!----><!----><span role="img" aria-label="search" class="anticon anticon-search certain-category-icon"><svg focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span></span></span></span>
20+
<div class="ant-select-selector"><span class="ant-select-selection-search"><span class="ant-input-group-wrapper ant-input-group-wrapper-lg ant-input-search ant-input-search-large ant-select-selection-search-input"><span class="ant-input-wrapper ant-input-group"><!----><input placeholder="input here" id="rc_select_TEST_OR_SSR" autocomplete="off" type="search" class="ant-input ant-input-lg" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_TEST_OR_SSR_list" aria-autocomplete="list" aria-controls="rc_select_TEST_OR_SSR_list" aria-activedescendant="rc_select_TEST_OR_SSR_list_0"><span class="ant-input-group-addon"><button class="ant-btn ant-btn-lg ant-input-search-button ant-btn-icon-only" type="button"><span role="img" aria-label="search" class="anticon anticon-search"><svg focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span></button></span></span></span></span>
2121
<!----><span class="ant-select-selection-placeholder"><!----></span>
2222
</div>
2323
<!---->
@@ -64,7 +64,7 @@ exports[`renders ./components/auto-complete/demo/options.vue correctly 1`] = `
6464
6565
exports[`renders ./components/auto-complete/demo/uncertain-category.vue correctly 1`] = `
6666
<div class="global-search-wrapper" style="width: 300px;">
67-
<div class="ant-select ant-select-lg global-search ant-select-lg ant-select-show-search ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search" style="width: 100%;">
67+
<div style="width: 300px;" class="ant-select ant-select-show-search ant-select-auto-complete ant-select-single ant-select-customize-input ant-select-show-search">
6868
<!---->
6969
<!---->
7070
<div class="ant-select-selector"><span class="ant-select-selection-search"><span class="ant-input-group-wrapper ant-input-group-wrapper-lg ant-input-search ant-input-search-large ant-input-search-with-button ant-select-selection-search-input"><span class="ant-input-wrapper ant-input-group"><!----><input placeholder="input here" id="rc_select_TEST_OR_SSR" autocomplete="off" type="search" class="ant-input ant-input-lg" role="combobox" aria-haspopup="listbox" aria-owns="rc_select_TEST_OR_SSR_list" aria-autocomplete="list" aria-controls="rc_select_TEST_OR_SSR_list" aria-activedescendant="rc_select_TEST_OR_SSR_list_0"><span class="ant-input-group-addon"><button class="ant-btn ant-btn-primary ant-btn-lg ant-input-search-button" type="button"><!----><span role="img" aria-label="search" class="anticon anticon-search"><svg focusable="false" class="" data-icon="search" width="1em" height="1em" fill="currentColor" aria-hidden="true" viewBox="64 64 896 896"><path d="M909.6 854.5L649.9 594.8C690.2 542.7 712 479 712 412c0-80.2-31.3-155.4-87.9-212.1-56.6-56.7-132-87.9-212.1-87.9s-155.5 31.3-212.1 87.9C143.2 256.5 112 331.8 112 412c0 80.1 31.3 155.5 87.9 212.1C256.5 680.8 331.8 712 412 712c67 0 130.6-21.8 182.7-62l259.7 259.6a8.2 8.2 0 0011.6 0l43.6-43.5a8.2 8.2 0 000-11.6zM570.4 570.4C528 612.7 471.8 636 412 636s-116-23.3-158.4-65.6C211.3 528 188 471.8 188 412s23.3-116.1 65.6-158.4C296 211.3 352.2 188 412 188s116.1 23.2 158.4 65.6S636 352.2 636 412s-23.3 116.1-65.6 158.4z"></path></svg></span></button></span></span></span></span>

components/auto-complete/demo/certain-category.vue

+17-41
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,8 @@ Lookup-Patterns - Certain Category.
2121
v-model:value="value"
2222
class="certain-category-search"
2323
dropdown-class-name="certain-category-search-dropdown"
24-
:dropdown-match-select-width="false"
25-
:dropdown-style="{ width: '300px' }"
26-
size="large"
27-
style="width: 100%"
28-
option-label-prop="value"
24+
:dropdown-match-select-width="500"
25+
style="width: 250px"
2926
:options="dataSource"
3027
>
3128
<template #option="item">
@@ -52,30 +49,33 @@ Lookup-Patterns - Certain Category.
5249
</a>
5350
</template>
5451
<template v-else>
55-
{{ item.title }}
56-
<span class="certain-search-item-count">{{ item.count }} people</span>
52+
<div style="display: flex; justify-content: space-between">
53+
{{ item.value }}
54+
<span>
55+
<UserOutlined />
56+
{{ item.count }}
57+
</span>
58+
</div>
5759
</template>
5860
</template>
59-
<a-input placeholder="input here">
60-
<template #suffix><search-outlined class="certain-category-icon" /></template>
61-
</a-input>
61+
<a-input-search placeholder="input here" size="large"></a-input-search>
6262
</a-auto-complete>
6363
</div>
6464
</template>
6565

6666
<script lang="ts">
67-
import { SearchOutlined } from '@ant-design/icons-vue';
6867
import { defineComponent, ref } from 'vue';
68+
import { UserOutlined } from '@ant-design/icons-vue';
6969
const dataSource = [
7070
{
7171
value: 'Libraries',
7272
options: [
7373
{
74-
value: 'AntDesign',
74+
value: 'AntDesignVue',
7575
count: 10000,
7676
},
7777
{
78-
value: 'AntDesign UI',
78+
value: 'AntDesignVue UI',
7979
count: 10600,
8080
},
8181
],
@@ -84,11 +84,11 @@ const dataSource = [
8484
value: 'Solutions',
8585
options: [
8686
{
87-
value: 'AntDesign UI FAQ',
87+
value: 'AntDesignVue UI FAQ',
8888
count: 60100,
8989
},
9090
{
91-
value: 'AntDesign FAQ',
91+
value: 'AntDesignVue FAQ',
9292
count: 30010,
9393
},
9494
],
@@ -97,7 +97,7 @@ const dataSource = [
9797
value: 'Articles',
9898
options: [
9999
{
100-
value: 'AntDesign design language',
100+
value: 'AntDesignVue design language',
101101
count: 100000,
102102
},
103103
],
@@ -108,7 +108,7 @@ const dataSource = [
108108
];
109109
export default defineComponent({
110110
components: {
111-
SearchOutlined,
111+
UserOutlined,
112112
},
113113
setup() {
114114
return {
@@ -142,27 +142,3 @@ export default defineComponent({
142142
max-height: 300px;
143143
}
144144
</style>
145-
146-
<style scoped>
147-
.certain-category-search-wrapper
148-
:deep(.certain-category-search.ant-select-auto-complete)
149-
.ant-input-affix-wrapper
150-
.ant-input-suffix {
151-
right: 12px;
152-
}
153-
.certain-category-search-wrapper :deep(.certain-search-item-count) {
154-
position: absolute;
155-
color: #999;
156-
right: 16px;
157-
}
158-
.certain-category-search-wrapper
159-
:deep(.certain-category-search.ant-select-focused)
160-
.certain-category-icon {
161-
color: #108ee9;
162-
}
163-
.certain-category-search-wrapper :deep(.certain-category-icon) {
164-
color: #6e6e6e;
165-
transition: all 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
166-
font-size: 16px;
167-
}
168-
</style>

components/auto-complete/demo/uncertain-category.vue

+15-51
Original file line numberDiff line numberDiff line change
@@ -14,29 +14,30 @@ title:
1414

1515
Lookup-Patterns - Uncertain Category.
1616
</docs>
17-
1817
<template>
1918
<div class="global-search-wrapper" style="width: 300px">
2019
<a-auto-complete
2120
v-model:value="value"
22-
class="global-search"
23-
size="large"
24-
style="width: 100%"
25-
option-label-prop="title"
21+
:dropdown-match-select-width="252"
22+
style="width: 300px"
2623
:options="dataSource"
2724
@select="onSelect"
2825
@search="handleSearch"
2926
>
3027
<template #option="item">
31-
Found {{ item.query }} on
32-
<a
33-
:href="`https://s.taobao.com/search?q=${item.query}`"
34-
target="_blank"
35-
rel="noopener noreferrer"
36-
>
37-
{{ item.category }}
38-
</a>
39-
<span class="global-search-item-count">{{ item.count }} results</span>
28+
<div style="display: flex; justify-content: space-between">
29+
<span>
30+
Found {{ item.query }} on
31+
<a
32+
:href="`https://s.taobao.com/search?q=${item.query}`"
33+
target="_blank"
34+
rel="noopener noreferrer"
35+
>
36+
{{ item.category }}
37+
</a>
38+
</span>
39+
<span>{{ item.count }} results</span>
40+
</div>
4041
</template>
4142
<a-input-search size="large" placeholder="input here" enter-button></a-input-search>
4243
</a-auto-complete>
@@ -86,40 +87,3 @@ export default defineComponent({
8687
},
8788
});
8889
</script>
89-
90-
<style>
91-
.global-search-wrapper {
92-
padding-right: 50px;
93-
}
94-
95-
.global-search {
96-
width: 100%;
97-
}
98-
99-
.global-search.ant-select-auto-complete .ant-select-selection--single {
100-
margin-right: -46px;
101-
}
102-
103-
.global-search.ant-select-auto-complete .ant-input-affix-wrapper .ant-input:not(:last-child) {
104-
padding-right: 62px;
105-
}
106-
107-
.global-search.ant-select-auto-complete .ant-input-affix-wrapper .ant-input-suffix button {
108-
border-top-left-radius: 0;
109-
border-bottom-left-radius: 0;
110-
}
111-
112-
.global-search-item {
113-
display: flex;
114-
}
115-
116-
.global-search-item-desc {
117-
flex: auto;
118-
text-overflow: ellipsis;
119-
overflow: hidden;
120-
}
121-
122-
.global-search-item-count {
123-
flex: none;
124-
}
125-
</style>

components/auto-complete/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ The differences with Select are:
2626

2727
| Property | Description | Type | Default | Version |
2828
| --- | --- | --- | --- | --- |
29-
| #default (for customize input element) | customize input element | HTMLInputElement / HTMLTextAreaElement | `<Input />` | |
3029
| allowClear | Show clear button, effective in multiple mode only. | boolean | false | |
3130
| autofocus | get focus when component mounted | boolean | false | |
3231
| backfill | backfill selected item the input when using keyboard | boolean | false | |
32+
| default (for customize input element) | customize input element | slot | `<Input />` | |
3333
| defaultActiveFirstOption | Whether active first option by default | boolean | true | |
3434
| defaultOpen | Initial open state of dropdown | boolean | - | |
3535
| disabled | Whether disabled select | boolean | false | |

components/auto-complete/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ cover: https://gw.alipayobjects.com/zos/alicdn/qtJm4yt45/AutoComplete.svg
2727

2828
| 参数 | 说明 | 类型 | 默认值 | 版本 |
2929
| --- | --- | --- | --- | --- |
30-
| #default (自定义输入框) | 自定义输入框 | HTMLInputElement / HTMLTextAreaElement | `<Input />` | |
3130
| allowClear | 支持清除, 单选模式有效 | boolean | false | |
3231
| autofocus | 自动获取焦点 | boolean | false | |
3332
| backfill | 使用键盘选择选项的时候把选中项回填到输入框中 | boolean | false | |
33+
| default (自定义输入框) | 自定义输入框 | slot | `<Input />` | |
3434
| defaultActiveFirstOption | 是否默认高亮第一个选项。 | boolean | true | |
3535
| defaultOpen | 是否默认展开下拉菜单 | boolean | - | |
3636
| disabled | 是否禁用 | boolean | false | |

0 commit comments

Comments
 (0)