-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(cdk:forms): add
interactions
trigger (#1766)
- Loading branch information
Showing
10 changed files
with
157 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
--- | ||
title: | ||
zh: 配置 `trigger` 为 interactions | ||
en: Set `trigger` as interactions | ||
order: 0 | ||
--- | ||
|
||
## zh | ||
|
||
内置的 `interactions` trigger具有更好的交互体验,结合了 `blur` 和 `change` 两种触发方式。 | ||
|
||
## en | ||
|
||
Inset `interactions` trigger type provides better user experence, which combines triggers of `blur` and `change`. |
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,66 @@ | ||
<template> | ||
<IxForm class="demo-form" :control="formGroup"> | ||
<IxFormItem message="Please input your username!"> | ||
<IxInput control="username" prefix="user"></IxInput> | ||
</IxFormItem> | ||
<IxFormItem message="Please input your password, its length is 6-18!"> | ||
<IxInput control="password" prefix="lock" :type="passwordVisible ? 'text' : 'password'"> | ||
<template #suffix> | ||
<IxIcon :name="passwordVisible ? 'eye-invisible' : 'eye'" @click="passwordVisible = !passwordVisible"> | ||
</IxIcon> | ||
</template> | ||
</IxInput> | ||
</IxFormItem> | ||
<IxFormItem messageTooltip> | ||
<IxCheckbox control="remember">Remember me</IxCheckbox> | ||
</IxFormItem> | ||
<IxFormItem style="margin: 8px 0" messageTooltip> | ||
<IxButton mode="primary" block type="submit" @click="login">Login</IxButton> | ||
</IxFormItem> | ||
<IxRow> | ||
<IxCol span="12"> | ||
<a>Forgot password</a> | ||
</IxCol> | ||
<IxCol span="12" class="text-right"> | ||
<a>Register now!</a> | ||
</IxCol> | ||
</IxRow> | ||
</IxForm> | ||
</template> | ||
|
||
<script setup lang="ts"> | ||
import { ref } from 'vue' | ||
import { Validators, useFormGroup } from '@idux/cdk/forms' | ||
const { required, minLength, maxLength } = Validators | ||
const formGroup = useFormGroup( | ||
{ | ||
username: ['', required], | ||
password: ['', [required, minLength(6), maxLength(18)]], | ||
remember: [true], | ||
}, | ||
{ trigger: 'interactions' }, | ||
) | ||
const login = () => { | ||
if (formGroup.valid.value) { | ||
console.log('login', formGroup.getValue()) | ||
} else { | ||
formGroup.markAsDirty() | ||
} | ||
} | ||
const passwordVisible = ref(false) | ||
</script> | ||
|
||
<style lang="less" scoped> | ||
.demo-form { | ||
max-width: 300px; | ||
} | ||
.text-right { | ||
text-align: right; | ||
} | ||
</style> |
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