Skip to content

Commit

Permalink
fix: input融合form,icon使用修改 (jd-opensource#1970)
Browse files Browse the repository at this point in the history
* fix: backtop  add ts interface

* fix: ts类型修改

* feat: 添加*.d.ts文件

* fix: ts类型修改

* fix: toast类型修改

* fix: input组件修改,结合form

* fix: input组件showlimit 调整,样式修改,icon修改

* fix: input 修改

* fix: input icon 修改

Co-authored-by: lkjh3214 <[email protected]>
Co-authored-by: love_forever <[email protected]>
Co-authored-by: richard1015 <[email protected]>
  • Loading branch information
4 people authored Dec 23, 2022
1 parent d2384b6 commit cd01a7e
Show file tree
Hide file tree
Showing 13 changed files with 261 additions and 1,083 deletions.
4 changes: 2 additions & 2 deletions src/packages/__VUE/form/demo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
required
:rules="[{ required: true, message: translate('nameTip') }]"
>
<input
<nut-input
class="nut-input-text"
v-model="dynamicForm.state.name"
:placeholder="translate('nameTip')"
Expand Down Expand Up @@ -75,7 +75,7 @@
required
:rules="[{ required: true, message: translate('nameTip') }]"
>
<input
<nut-input
class="nut-input-text"
@blur="customBlurValidate('name')"
v-model="formData.name"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,29 +1,16 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`should colon 1`] = `
"<view class=\\"nut-input__label\\" style=\\"width: 80px; text-align: left;\\">
<view class=\\"nut-input__label-string\\">test :</view>
</view>"
`;
exports[`should render word limit correctly 1`] = `"<view class=\\"nut-input-word-limit\\"><span class=\\"nut-input-word-num\\">3</span>/9999</view>"`;
exports[`should render word limit correctly when modelValue is null 1`] = `
"<view class=\\"nut-input nut-input--border\\" maxlength=\\"3\\">
<!--v-if-->
<!--v-if-->
<view class=\\"nut-input-value\\">
<view class=\\"nut-input-inner\\">
<view class=\\"nut-input-box\\"><input style=\\"text-align: left;\\" type=\\"text\\" class=\\"input-text\\" maxlength=\\"9999\\" placeholder=\\"\\" formattrigger=\\"onChange\\" enterkeyhint=\\"done\\"></view>
<view class=\\"nut-input-clear-box\\">
<!--v-if-->
<view class=\\"nut-input-box\\"><input style=\\"text-align: left;\\" type=\\"text\\" class=\\"input-text\\" maxlength=\\"9999\\" placeholder=\\"\\" formattrigger=\\"onChange\\" enterkeyhint=\\"done\\">
<view class=\\"nut-input-word-limit\\"><span class=\\"nut-input-word-num\\">0</span>/9999</view>
</view>
<!--v-if-->
<!--v-if-->
<!--v-if-->
</view>
<view class=\\"nut-input-word-limit\\"><span class=\\"nut-input-word-num\\">0</span>/9999</view>
<!--v-if-->
</view>
</view>"
`;
54 changes: 2 additions & 52 deletions src/packages/__VUE/input/__tests__/input.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ afterAll(() => {
});

test('base', () => {
const wrapper = mount(Input, { props: { modelValue: 3 } });
const wrapper = mount(Input, { props: { modelValue: '3' } });
const input = wrapper.find('input');
expect(input.exists()).toBe(true);
expect(input.element.value).toBe('3');
Expand Down Expand Up @@ -102,53 +102,14 @@ test('should format input value when type is digit', () => {
// expect((wrapper.emitted('change') as any)[1][0]).toEqual('11');
});

test('should no label', () => {
const wrapper = mount(Input, {
props: {}
});
const label = wrapper.find('.label-string');
expect(label.exists()).toBe(false);
});

test('should label', () => {
const wrapper = mount(Input, {
props: {
label: '文本'
}
});
const label = wrapper.find('.label-string');
expect(label.text()).toBe('文本');
});

test('should label-class', () => {
const wrapper = mount(Input, {
props: {
label: '文本',
labelClass: 'test-class'
}
});
const label = wrapper.find('.nut-input__label');
expect(label.classes()).toContain('test-class');
});

test('should colon', () => {
const wrapper = mount(Input, {
props: {
label: 'test',
colon: true
}
});
expect(wrapper.find('.nut-input__label').html()).toMatchSnapshot();
});

test('should require', () => {
const wrapper = mount(Input, {
props: {
required: true
}
});
const input = wrapper.find('.nut-input');
expect(input.classes()).toContain('nut-input-required');
expect(input.classes()).toContain('nut-input--required');
});

test('should disabled', () => {
Expand Down Expand Up @@ -193,17 +154,6 @@ test('should render word limit correctly when modelValue is null', () => {
expect(wrapper.html()).toMatchSnapshot();
});

test('should labelAlign', () => {
const wrapper = mount(Input, {
props: {
label: '文本',
labelAlign: 'right'
}
});
const input: any = wrapper.find('.nut-input__label');
expect(input.element.style.textAlign).toEqual('right');
});

test('should inputAlign', () => {
const wrapper = mount(Input, {
props: {
Expand Down
Loading

0 comments on commit cd01a7e

Please sign in to comment.