From dbe7fe78cecf5801130e3e14a26c0839a3b67968 Mon Sep 17 00:00:00 2001
From: tangjinzhou <415800467@qq.com>
Date: Sat, 14 May 2022 14:57:40 +0800
Subject: [PATCH] feat: autocomplete add status
---
components/auto-complete/demo/index.vue | 3 +
components/auto-complete/demo/status.vue | 85 ++++++++++++++++++++++++
components/auto-complete/index.en-US.md | 2 +
components/auto-complete/index.tsx | 2 +
components/auto-complete/index.zh-CN.md | 4 +-
5 files changed, 95 insertions(+), 1 deletion(-)
create mode 100644 components/auto-complete/demo/status.vue
diff --git a/components/auto-complete/demo/index.vue b/components/auto-complete/demo/index.vue
index 7fd1c9434..a788b90fb 100644
--- a/components/auto-complete/demo/index.vue
+++ b/components/auto-complete/demo/index.vue
@@ -6,6 +6,7 @@
+
@@ -16,6 +17,7 @@ import Custom from './custom.vue';
import NonCaseSensitive from './non-case-sensitive.vue';
import CertainCategory from './certain-category.vue';
import UncertainCategory from './uncertain-category.vue';
+import statusVue from './status.vue';
import CN from '../index.zh-CN.md';
import US from '../index.en-US.md';
@@ -25,6 +27,7 @@ export default defineComponent({
CN,
US,
components: {
+ statusVue,
Basic,
Options,
Custom,
diff --git a/components/auto-complete/demo/status.vue b/components/auto-complete/demo/status.vue
new file mode 100644
index 000000000..4e34064c7
--- /dev/null
+++ b/components/auto-complete/demo/status.vue
@@ -0,0 +1,85 @@
+
+---
+order: 19
+version: 3.3.0
+title:
+ zh-CN: 自定义状态
+ en-US: Status
+---
+
+## zh-CN
+
+使用 `status` 为 AutoComplete 添加状态,可选 `error` 或者 `warning`。
+
+## en-US
+
+Add status to AutoComplete with `status`, which could be `error` or `warning`.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/components/auto-complete/index.en-US.md b/components/auto-complete/index.en-US.md
index dd29793c0..03e7a9614 100644
--- a/components/auto-complete/index.en-US.md
+++ b/components/auto-complete/index.en-US.md
@@ -40,6 +40,7 @@ The differences with Select are:
| option | custom render option by slot | v-slot:option="{value, label, [disabled, key, title]}" | - | 3.0 |
| options | Data source for autocomplete | [DataSourceItemType](https://github.com/vueComponent/ant-design-vue/blob/724d53b907e577cf5880c1e6742d4c3f924f8f49/components/auto-complete/index.vue#L9)\[] | | |
| placeholder | placeholder of input | string | - | |
+| status | Set validation status | 'error' \| 'warning' | - | 3.3.0 |
| v-model:value | selected option | string\|string\[]\|{ key: string, label: string\|vNodes }\|Array<{ key: string, label: string\|vNodes }> | - | |
### events
@@ -52,6 +53,7 @@ The differences with Select are:
| focus | Called when entering the component | function() | | |
| search | Called when searching items. | function(value) | - | |
| select | Called when a option is selected. param is option's value and option instance. | function(value, option) | | |
+| clear | Called when clear | function | - | 3.3.0 |
## Methods
diff --git a/components/auto-complete/index.tsx b/components/auto-complete/index.tsx
index 1cca93153..721128c1b 100644
--- a/components/auto-complete/index.tsx
+++ b/components/auto-complete/index.tsx
@@ -7,6 +7,7 @@ import Option from './Option';
import OptGroup from './OptGroup';
import omit from '../_util/omit';
import useConfigInject from '../_util/hooks/useConfigInject';
+import type { InputStatus } from '../_util/statusUtils';
function isSelectOptionOrSelectOptGroup(child: any): boolean {
return child?.type?.isSelectOption || child?.type?.isSelectOptGroup;
@@ -30,6 +31,7 @@ export const autoCompleteProps = () => ({
// optionLabelProp: PropTypes.string.def('children'),
filterOption: { type: [Boolean, Function], default: false },
defaultActiveFirstOption: { type: Boolean, default: true },
+ status: String as PropType,
});
export type AutoCompleteProps = Partial>>;
diff --git a/components/auto-complete/index.zh-CN.md b/components/auto-complete/index.zh-CN.md
index a9a6eea38..79caa5384 100644
--- a/components/auto-complete/index.zh-CN.md
+++ b/components/auto-complete/index.zh-CN.md
@@ -41,18 +41,20 @@ cover: https://gw.alipayobjects.com/zos/alicdn/qtJm4yt45/AutoComplete.svg
| option | 通过 option 插槽,自定义节点 | v-slot:option="{value, label, [disabled, key, title]}" | - | 3.0 |
| options | 自动完成的数据源 | [DataSourceItemType](https://github.com/vueComponent/ant-design-vue/blob/724d53b907e577cf5880c1e6742d4c3f924f8f49/components/auto-complete/index.vue#L9)\[] | | |
| placeholder | 输入框提示 | string \| slot | - | |
+| status | 设置校验状态 | 'error' \| 'warning' | - | 3.3.0 |
| v-model:value | 指定当前选中的条目 | string\|string\[]\|{ key: string, label: string\|vNodes }\|Array<{ key: string, label: string\|vNodes }> | 无 | |
### 事件
| 事件名称 | 说明 | 回调参数 | 版本 |
-| --- | --- | --- | --- |
+| --- | --- | --- | --- | --- |
| blur | 失去焦点时的回调 | function() | |
| change | 选中 option,或 input 的 value 变化时,调用此函数 | function(value) | |
| dropdownVisibleChange | 展开下拉菜单的回调 | function(open) | |
| focus | 获得焦点时的回调 | function() | |
| search | 搜索补全项的时候调用 | function(value) | |
| select | 被选中时调用,参数为选中项的 value 值 | function(value, option) | |
+| clear | 清除内容时回调 | function | - | 3.3.0 |
## 方法