mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-24 10:20:19 +08:00
feat(NumberKeyboard): add close-button-loading prop (#6158)
This commit is contained in:
parent
acfefe6518
commit
3e9863d63a
@ -1,5 +1,6 @@
|
|||||||
import { createNamespace } from '../utils';
|
import { createNamespace } from '../utils';
|
||||||
import { TouchMixin } from '../mixins/touch';
|
import { TouchMixin } from '../mixins/touch';
|
||||||
|
import Loading from '../loading';
|
||||||
import DeleteIcon from './DeleteIcon';
|
import DeleteIcon from './DeleteIcon';
|
||||||
import CollapseIcon from './CollapseIcon';
|
import CollapseIcon from './CollapseIcon';
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ export default createComponent({
|
|||||||
color: String,
|
color: String,
|
||||||
wider: Boolean,
|
wider: Boolean,
|
||||||
large: Boolean,
|
large: Boolean,
|
||||||
|
loading: Boolean,
|
||||||
},
|
},
|
||||||
|
|
||||||
data() {
|
data() {
|
||||||
@ -55,6 +57,10 @@ export default createComponent({
|
|||||||
const isDelete = this.type === 'delete';
|
const isDelete = this.type === 'delete';
|
||||||
const text = this.slots('default') || this.text;
|
const text = this.slots('default') || this.text;
|
||||||
|
|
||||||
|
if (this.loading) {
|
||||||
|
return <Loading class={bem('loading-icon')} />;
|
||||||
|
}
|
||||||
|
|
||||||
if (isDelete) {
|
if (isDelete) {
|
||||||
return text || <DeleteIcon class={bem('delete-icon')} />;
|
return text || <DeleteIcon class={bem('delete-icon')} />;
|
||||||
}
|
}
|
||||||
|
@ -133,14 +133,15 @@ export default {
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| v-model (value) `v2.0.2` | Current value | _string_ | - |
|
| v-model (value) `v2.0.2` | Current value | _string_ | - |
|
||||||
| show | Whether to show keyboard | _boolean_ | - |
|
| show | Whether to show keyboard | _boolean_ | - |
|
||||||
| theme | Keyboard theme,can be set to `custom` | _string_ | `default` |
|
|
||||||
| title | Keyboard title | _string_ | - |
|
| title | Keyboard title | _string_ | - |
|
||||||
|
| theme | Keyboard theme,can be set to `custom` | _string_ | `default` |
|
||||||
| maxlength `v2.0.2` | Value maxlength | _number \| string_ | - |
|
| maxlength `v2.0.2` | Value maxlength | _number \| string_ | - |
|
||||||
| transition | Whether to show transition animation | _boolean_ | `true` |
|
| transition | Whether to show transition animation | _boolean_ | `true` |
|
||||||
| z-index | Keyboard z-index | _number \| string_ | `100` |
|
| z-index | Keyboard z-index | _number \| string_ | `100` |
|
||||||
| extra-key | Content of bottom left key | _string_ | `''` |
|
| extra-key | Content of bottom left key | _string_ | `''` |
|
||||||
| close-button-text | Close button text | _string_ | - |
|
| close-button-text | Close button text | _string_ | - |
|
||||||
| delete-button-text | Delete button text | _string_ | Delete Icon |
|
| delete-button-text | Delete button text | _string_ | Delete Icon |
|
||||||
|
| close-button-loading `v2.6.4` | Whether to show loading close button in custom theme | _boolean_ | `false` |
|
||||||
| show-delete-key `v2.5.9` | Whether to show delete button | _boolean_ | `true` |
|
| show-delete-key `v2.5.9` | Whether to show delete button | _boolean_ | `true` |
|
||||||
| hide-on-click-outside | Whether to hide keyboard when click outside | _boolean_ | `true` |
|
| hide-on-click-outside | Whether to hide keyboard when click outside | _boolean_ | `true` |
|
||||||
| safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` |
|
| safe-area-inset-bottom | Whether to enable bottom safe area adaptation | _boolean_ | `true` |
|
||||||
|
@ -144,14 +144,15 @@ export default {
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| v-model (value) `v2.0.2` | 当前输入值 | _string_ | - |
|
| v-model (value) `v2.0.2` | 当前输入值 | _string_ | - |
|
||||||
| show | 是否显示键盘 | _boolean_ | - |
|
| show | 是否显示键盘 | _boolean_ | - |
|
||||||
| theme | 样式风格,可选值为 `custom` | _string_ | `default` |
|
|
||||||
| title | 键盘标题 | _string_ | - |
|
| title | 键盘标题 | _string_ | - |
|
||||||
|
| theme | 样式风格,可选值为 `custom` | _string_ | `default` |
|
||||||
| maxlength `v2.0.2` | 输入值最大长度 | _number \| string_ | - |
|
| maxlength `v2.0.2` | 输入值最大长度 | _number \| string_ | - |
|
||||||
| transition | 是否开启过场动画 | _boolean_ | `true` |
|
| transition | 是否开启过场动画 | _boolean_ | `true` |
|
||||||
| z-index | 键盘 z-index | _number \| string_ | `100` |
|
| z-index | 键盘 z-index 层级 | _number \| string_ | `100` |
|
||||||
| extra-key | 左下角按键内容 | _string_ | `''` |
|
| extra-key | 左下角按键内容 | _string_ | `''` |
|
||||||
| close-button-text | 关闭按钮文字,空则不展示 | _string_ | - |
|
| close-button-text | 关闭按钮文字,空则不展示 | _string_ | - |
|
||||||
| delete-button-text | 删除按钮文字,空则展示删除图标 | _string_ | - |
|
| delete-button-text | 删除按钮文字,空则展示删除图标 | _string_ | - |
|
||||||
|
| close-button-loading `v2.6.4` | 是否将关闭按钮设置为加载中状态,仅在 `theme="custom"` 时有效 | _boolean_ | `false` |
|
||||||
| show-delete-key `v2.5.9` | 是否展示删除图标 | _boolean_ | `true` |
|
| show-delete-key `v2.5.9` | 是否展示删除图标 | _boolean_ | `true` |
|
||||||
| hide-on-click-outside | 点击外部时是否收起键盘 | _boolean_ | `true` |
|
| hide-on-click-outside | 点击外部时是否收起键盘 | _boolean_ | `true` |
|
||||||
| safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` |
|
| safe-area-inset-bottom | 是否开启[底部安全区适配](#/zh-CN/quickstart#di-bu-an-quan-qu-gua-pei) | _boolean_ | `true` |
|
||||||
|
@ -24,6 +24,7 @@ export default createComponent({
|
|||||||
zIndex: [Number, String],
|
zIndex: [Number, String],
|
||||||
closeButtonText: String,
|
closeButtonText: String,
|
||||||
deleteButtonText: String,
|
deleteButtonText: String,
|
||||||
|
closeButtonLoading: Boolean,
|
||||||
theme: {
|
theme: {
|
||||||
type: String,
|
type: String,
|
||||||
default: 'default',
|
default: 'default',
|
||||||
@ -189,6 +190,7 @@ export default createComponent({
|
|||||||
text={this.closeButtonText}
|
text={this.closeButtonText}
|
||||||
type="close"
|
type="close"
|
||||||
color="blue"
|
color="blue"
|
||||||
|
loading={this.closeButtonLoading}
|
||||||
onPress={this.onPress}
|
onPress={this.onPress}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -129,4 +129,8 @@
|
|||||||
width: 30px;
|
width: 30px;
|
||||||
height: 24px;
|
height: 24px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
&__loading-icon {
|
||||||
|
color: @number-keyboard-button-text-color;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import NumberKeyboard from '..';
|
import NumberKeyboard from '..';
|
||||||
import { mount, trigger } from '../../../test';
|
import { mount, trigger, later } from '../../../test';
|
||||||
|
|
||||||
function clickKey(key) {
|
function clickKey(key) {
|
||||||
trigger(key, 'touchstart');
|
trigger(key, 'touchstart');
|
||||||
@ -216,3 +216,15 @@ test('show-delete-key prop', () => {
|
|||||||
wrapper.setData({ showDeleteKey: false });
|
wrapper.setData({ showDeleteKey: false });
|
||||||
expect(wrapper.contains('.van-key--delete')).toBeFalsy();
|
expect(wrapper.contains('.van-key--delete')).toBeFalsy();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('close-button-loading prop', () => {
|
||||||
|
const wrapper = mount(NumberKeyboard, {
|
||||||
|
propsData: {
|
||||||
|
show: true,
|
||||||
|
theme: 'custom',
|
||||||
|
closeButtonLoading: true,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
expect(wrapper.contains('.van-key__loading-icon')).toBeTruthy();
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user