-
Notifications
You must be signed in to change notification settings - Fork 536
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(verification-code): add verification-code component (#2823)
- Loading branch information
Showing
24 changed files
with
795 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
packages/web-vue/components/verification-code/README.en-US.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
```yaml | ||
meta: | ||
type: Component | ||
category: Data Entry | ||
title: VerificationCode | ||
description: Verification code input component. | ||
``` | ||
*Auto translate by google.* | ||
@import ./__demo__/basic.md | ||
@import ./__demo__/status.md | ||
@import ./__demo__/masked.md | ||
@import ./__demo__/separator.md | ||
@import ./__demo__/form.md | ||
@import ./__demo__/formatter.md | ||
## API | ||
### `<verification-code>` Props | ||
|
||
|Attribute|Description|Type|Default| | ||
|---|---|---|:---:| | ||
|model-value **(v-model)**|Value|`string`|`-`| | ||
|default-value|Default value (uncontrolled state)|`string`|`''`| | ||
|length|The length of the verification code, rendering the corresponding number of input boxes according to the length.|`number`|`6`| | ||
|size|Input size|`'mini' \| 'small' \| 'medium' \| 'large'`|`'medium'`| | ||
|disabled|Whether to disable|`boolean`|`false`| | ||
|masked|Password mode|`boolean`|`false`| | ||
|readonly|Readonly|`boolean`|`false`| | ||
|error|Whether it is an error state|`boolean`|`false`| | ||
|separator|Separator. Customizable rendering separators after input boxes with different indexes|`(index: number, character: string) => VNode`|`-`| | ||
|formatter|Formatter function, triggered when the user input value changes|`(inputValue: string, index: number, value: string) => string \| boolean`|`-`| | ||
### `<verification-code>` Events | ||
|
||
|Event Name|Description|Parameters| | ||
|---|---|---| | ||
|change|Triggered when the value changes|value: ` string `| | ||
|finish|Triggered when the filling is complete|value: ` string `| | ||
|input|Triggered on input|inputValue: ` string `<br>index: ` number `<br>ev: `Event`| | ||
|
||
|
41 changes: 41 additions & 0 deletions
41
packages/web-vue/components/verification-code/README.zh-CN.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
```yaml | ||
meta: | ||
type: 组件 | ||
category: 数据输入 | ||
title: 验证码输入 VerificationCode | ||
description: 验证码输入组件 | ||
``` | ||
@import ./__demo__/basic.md | ||
@import ./__demo__/status.md | ||
@import ./__demo__/masked.md | ||
@import ./__demo__/separator.md | ||
@import ./__demo__/form.md | ||
@import ./__demo__/formatter.md | ||
## API | ||
### `<verification-code>` Props | ||
|
||
|参数名|描述|类型|默认值| | ||
|---|---|---|:---:| | ||
|model-value **(v-model)**|绑定值|`string`|`-`| | ||
|default-value|默认值(非受控状态)|`string`|`''`| | ||
|length|验证码的长度,根据长度渲染对应个数的输入框|`number`|`6`| | ||
|size|输入框大小|`'mini' \| 'small' \| 'medium' \| 'large'`|`'medium'`| | ||
|disabled|是否禁用|`boolean`|`false`| | ||
|masked|是否密码模式|`boolean`|`false`| | ||
|readonly|只读|`boolean`|`false`| | ||
|error|是否为错误状态|`boolean`|`false`| | ||
|separator|分隔符。可在不同索引的输入框后自定义渲染分隔符|`(index: number, character: string) => VNode`|`-`| | ||
|formatter|格式化函数,当用户输入值改变时触发|`(inputValue: string, index: number, value: string) => string \| boolean`|`-`| | ||
### `<verification-code>` Events | ||
|
||
|事件名|描述|参数| | ||
|---|---|---| | ||
|change|值发生改变时触发|value: ` string `| | ||
|finish|填充完成时触发|value: ` string `| | ||
|input|输入时触发|inputValue: ` string `<br>index: ` number `<br>ev: `Event`| | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
## zh-CN | ||
```yaml | ||
meta: | ||
type: 组件 | ||
category: 数据输入 | ||
title: 验证码输入 VerificationCode | ||
description: 验证码输入组件 | ||
``` | ||
--- | ||
## en-US | ||
```yaml | ||
meta: | ||
type: Component | ||
category: Data Entry | ||
title: VerificationCode | ||
description: Verification code input component. | ||
``` | ||
--- | ||
@import ./__demo__/basic.md | ||
@import ./__demo__/status.md | ||
@import ./__demo__/masked.md | ||
@import ./__demo__/separator.md | ||
@import ./__demo__/form.md | ||
@import ./__demo__/formatter.md | ||
## API | ||
%%API(verification-code.tsx)%% |
31 changes: 31 additions & 0 deletions
31
packages/web-vue/components/verification-code/__demo__/basic.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
```yaml | ||
title: | ||
zh-CN: 基本使用 | ||
en-US: Basic Usage | ||
``` | ||
## zh-CN | ||
验证码输入框的基本用法。 | ||
--- | ||
## en-US | ||
Basic usage | ||
--- | ||
```vue | ||
<template> | ||
<a-verification-code v-model="value" style="width: 300px" @finish="onFinish" /> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue'; | ||
import { Message} from '@arco-design/web-vue'; | ||
|
||
const value = ref('654321'); | ||
const onFinish = (value) => Message.info(`Verification code: ${value}`); | ||
</script> | ||
``` |
50 changes: 50 additions & 0 deletions
50
packages/web-vue/components/verification-code/__demo__/form.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
```yaml | ||
title: | ||
zh-CN: 配合表单使用 | ||
en-US: With Form | ||
``` | ||
## zh-CN | ||
配合表单使用实现校验。 | ||
--- | ||
## en-US | ||
Use with forms to implement verification. | ||
--- | ||
```vue | ||
<template> | ||
<a-form ref="formRef" :model="form" style="width: 300px"> | ||
<a-form-item | ||
field="code" | ||
label="code" | ||
:rules="[ | ||
{required:true,message:'Verification code is required'}, | ||
{minLength:6, message:'Verification code is incomplete'}, | ||
{ match: /^\d+$/, message: 'Must be numeric' }, | ||
]" | ||
> | ||
<a-verification-code v-model="form.code" style="width: 300px" @finish="onFinish" /> | ||
</a-form-item> | ||
<a-form-item> | ||
<a-button style="width: 60px" type='primary' size='large' htmlType='submit'>Submit</a-button> | ||
</a-form-item> | ||
</a-form> | ||
</template> | ||
|
||
<script setup> | ||
import { ref } from 'vue'; | ||
import { Message} from '@arco-design/web-vue'; | ||
|
||
const value = ref('654321'); | ||
const formRef = ref(null); | ||
const form = ref({ | ||
code: '', | ||
}) | ||
const onFinish = (value) => Message.info(`Verification code: ${value}`); | ||
</script> | ||
``` |
34 changes: 34 additions & 0 deletions
34
packages/web-vue/components/verification-code/__demo__/formatter.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
```yaml | ||
title: | ||
zh-CN: 格式化输入 | ||
en-US: Formatter input | ||
``` | ||
## zh-CN | ||
通过 `formatter` 校验输入。此外,可以返回非布尔类型来将用户输入的字符串为特定的格式。 | ||
|
||
--- | ||
|
||
## en-US | ||
|
||
Validate input using `formatter`. Additionally, it can return non-boolean types to format the user-entered string into a specific format. | ||
|
||
--- | ||
|
||
```vue | ||
<template> | ||
<a-space direction="vertical"> | ||
<a-verification-code | ||
defaultValue='123456' | ||
style="width: 300px" | ||
:formatter="(inputValue) => /^\d*$/.test(inputValue) ? inputValue : false" | ||
/> | ||
<a-verification-code | ||
defaultValue='abcdef' | ||
style="width: 300px" | ||
:formatter="(inputValue) => /^[a-zA-Z]*$/.test(inputValue) ? inputValue.toUpperCase() : ''" | ||
/> | ||
</a-space> | ||
</template> | ||
``` |
29 changes: 29 additions & 0 deletions
29
packages/web-vue/components/verification-code/__demo__/masked.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
```yaml | ||
title: | ||
zh-CN: 密码模式 | ||
en-US: Masked | ||
``` | ||
## zh-CN | ||
指定 `masked = true`可开启密码模式 | ||
|
||
--- | ||
|
||
## en-US | ||
|
||
Use `masked = true` to turn on password mode | ||
|
||
--- | ||
|
||
```vue | ||
<template> | ||
<a-verification-code defaultValue="123" style="width: 300px" masked @finish="onFinish" /> | ||
</template> | ||
<script setup> | ||
import { Message} from '@arco-design/web-vue'; | ||
const onFinish = (value) => Message.info(`Verification code: ${value}`); | ||
</script> | ||
``` |
Oops, something went wrong.