mirror of
https://gitee.com/vant-contrib/vant.git
synced 2026-06-04 09:38:09 +08:00
Compare commits
No commits in common. "4cf5a6ba0def1162de1ff9eb871d1e945d5a090c" and "9c62bd3ebd48f982af2c47191327b577236bdf16" have entirely different histories.
4cf5a6ba0d
...
9c62bd3ebd
@ -60,7 +60,6 @@ const [name, bem] = createNamespace('field');
|
|||||||
|
|
||||||
// provide to Search component to inherit
|
// provide to Search component to inherit
|
||||||
export const fieldSharedProps = {
|
export const fieldSharedProps = {
|
||||||
id: String,
|
|
||||||
formatter: Function as PropType<(value: string) => string>,
|
formatter: Function as PropType<(value: string) => string>,
|
||||||
leftIcon: String,
|
leftIcon: String,
|
||||||
rightIcon: String,
|
rightIcon: String,
|
||||||
@ -402,7 +401,6 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
|
|
||||||
const inputAttrs = {
|
const inputAttrs = {
|
||||||
id: props.id,
|
|
||||||
ref: inputRef,
|
ref: inputRef,
|
||||||
name: props.name,
|
name: props.name,
|
||||||
rows: props.rows !== undefined ? +props.rows : undefined,
|
rows: props.rows !== undefined ? +props.rows : undefined,
|
||||||
@ -495,7 +493,7 @@ export default defineComponent({
|
|||||||
return [slots.label(), colon];
|
return [slots.label(), colon];
|
||||||
}
|
}
|
||||||
if (props.label) {
|
if (props.label) {
|
||||||
return <label for={props.id}>{props.label + colon}</label>;
|
return <label>{props.label + colon}</label>;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@ -249,8 +249,7 @@ Use `input-align` prop to align the input value.
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| v-model | Field value | _number \| string_ | - |
|
| v-model | Field value | _number \| string_ | - |
|
||||||
| label | Field label | _string_ | - |
|
| label | Field label | _string_ | - |
|
||||||
| name | Field name | _string_ | - |
|
| name | Name | _string_ | - |
|
||||||
| id `v3.2.2` | Input id, the for attribute of the label also will be set | _string_ | - |
|
|
||||||
| type | Input type, can be set to `tel` `digit`<br>`number` `textarea` `password` | _string_ | `text` |
|
| type | Input type, can be set to `tel` `digit`<br>`number` `textarea` `password` | _string_ | `text` |
|
||||||
| size | Size,can be set to `large` | _string_ | - |
|
| size | Size,can be set to `large` | _string_ | - |
|
||||||
| maxlength | Max length of value | _number \| string_ | - |
|
| maxlength | Max length of value | _number \| string_ | - |
|
||||||
|
|||||||
@ -268,8 +268,7 @@ export default {
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| v-model | 当前输入的值 | _number \| string_ | - |
|
| v-model | 当前输入的值 | _number \| string_ | - |
|
||||||
| label | 输入框左侧文本 | _string_ | - |
|
| label | 输入框左侧文本 | _string_ | - |
|
||||||
| name | 名称,作为提交表单时的标识符 | _string_ | - |
|
| name | 名称,提交表单的标识符 | _string_ | - |
|
||||||
| id `v3.2.2` | 输入框 id,同时会设置 label 的 for 属性 | _string_ | - |
|
|
||||||
| type | 输入框类型, 可选值为 `tel` `digit`<br>`number` `textarea` `password` 等 | _string_ | `text` |
|
| type | 输入框类型, 可选值为 `tel` `digit`<br>`number` `textarea` `password` 等 | _string_ | `text` |
|
||||||
| size | 大小,可选值为 `large` | _string_ | - |
|
| size | 大小,可选值为 `large` | _string_ | - |
|
||||||
| maxlength | 输入的最大字符数 | _number \| string_ | - |
|
| maxlength | 输入的最大字符数 | _number \| string_ | - |
|
||||||
|
|||||||
@ -455,15 +455,3 @@ test('should render autofocus attribute to input when using autofocus prop', asy
|
|||||||
const input = wrapper.find('input');
|
const input = wrapper.find('input');
|
||||||
expect(input.element.hasAttributes('autofocus')).toBeTruthy();
|
expect(input.element.hasAttributes('autofocus')).toBeTruthy();
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should render id prop correctly', async () => {
|
|
||||||
const wrapper = mount(Field, {
|
|
||||||
props: {
|
|
||||||
label: 'Label',
|
|
||||||
id: 'my-id',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.find('input').attributes('id')).toEqual('my-id');
|
|
||||||
expect(wrapper.find('label').attributes('for')).toEqual('my-id');
|
|
||||||
});
|
|
||||||
|
|||||||
@ -120,7 +120,6 @@ Use `action` slot to custom right button, `cancel` event will no longer be Emitt
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| label | Left side label | _string_ | - |
|
| label | Left side label | _string_ | - |
|
||||||
| shape | Shape of field, can be set to `round` | _string_ | `square` |
|
| shape | Shape of field, can be set to `round` | _string_ | `square` |
|
||||||
| id `v3.2.2` | Input id, the for attribute of the label also will be set | _string_ | - |
|
|
||||||
| background | Background color of field | _string_ | `#f2f2f2` |
|
| background | Background color of field | _string_ | `#f2f2f2` |
|
||||||
| maxlength | Max length of value | _number \| string_ | - |
|
| maxlength | Max length of value | _number \| string_ | - |
|
||||||
| placeholder | Placeholder | _string_ | - |
|
| placeholder | Placeholder | _string_ | - |
|
||||||
|
|||||||
@ -132,7 +132,6 @@ export default {
|
|||||||
| --- | --- | --- | --- |
|
| --- | --- | --- | --- |
|
||||||
| label | 搜索框左侧文本 | _string_ | - |
|
| label | 搜索框左侧文本 | _string_ | - |
|
||||||
| shape | 搜索框形状,可选值为 `round` | _string_ | `square` |
|
| shape | 搜索框形状,可选值为 `round` | _string_ | `square` |
|
||||||
| id `v3.2.2` | 搜索框 id,同时会设置 label 的 for 属性 | _string_ | - |
|
|
||||||
| background | 搜索框外部背景色 | _string_ | `#f2f2f2` |
|
| background | 搜索框外部背景色 | _string_ | `#f2f2f2` |
|
||||||
| maxlength | 输入的最大字符数 | _number \| string_ | - |
|
| maxlength | 输入的最大字符数 | _number \| string_ | - |
|
||||||
| placeholder | 占位提示文字 | _string_ | - |
|
| placeholder | 占位提示文字 | _string_ | - |
|
||||||
|
|||||||
@ -67,9 +67,9 @@ export default defineComponent({
|
|||||||
const renderLabel = () => {
|
const renderLabel = () => {
|
||||||
if (slots.label || props.label) {
|
if (slots.label || props.label) {
|
||||||
return (
|
return (
|
||||||
<label class={bem('label')} for={props.id}>
|
<div class={bem('label')}>
|
||||||
{slots.label ? slots.label() : props.label}
|
{slots.label ? slots.label() : props.label}
|
||||||
</label>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -115,9 +115,9 @@ exports[`should render demo and match snapshot 1`] = `
|
|||||||
<div>
|
<div>
|
||||||
<div class="van-search van-search--show-action">
|
<div class="van-search van-search--show-action">
|
||||||
<div class="van-search__content van-search__content--square">
|
<div class="van-search__content van-search__content--square">
|
||||||
<label class="van-search__label">
|
<div class="van-search__label">
|
||||||
Address
|
Address
|
||||||
</label>
|
</div>
|
||||||
<div class="van-cell van-cell--borderless van-field van-search__field">
|
<div class="van-cell van-cell--borderless van-field van-search__field">
|
||||||
<div class="van-field__left-icon">
|
<div class="van-field__left-icon">
|
||||||
<i class="van-badge__wrapper van-icon van-icon-search">
|
<i class="van-badge__wrapper van-icon van-icon-search">
|
||||||
|
|||||||
@ -10,9 +10,9 @@ exports[`should render action text when using action-text prop 1`] = `
|
|||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should render label slot correctly 1`] = `
|
exports[`should render label slot correctly 1`] = `
|
||||||
<label class="van-search__label">
|
<div class="van-search__label">
|
||||||
Custom Label
|
Custom Label
|
||||||
</label>
|
</div>
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`should render left icon when using left-icon prop 1`] = `
|
exports[`should render left icon when using left-icon prop 1`] = `
|
||||||
|
|||||||
@ -138,15 +138,3 @@ test('should call input.blur when vm.blur is called', () => {
|
|||||||
(wrapper.vm as SearchInstance).blur();
|
(wrapper.vm as SearchInstance).blur();
|
||||||
expect(onBlur).toHaveBeenCalledTimes(1);
|
expect(onBlur).toHaveBeenCalledTimes(1);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('should render id prop correctly', async () => {
|
|
||||||
const wrapper = mount(Search, {
|
|
||||||
props: {
|
|
||||||
label: 'Label',
|
|
||||||
id: 'my-id',
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
expect(wrapper.find('input').attributes('id')).toEqual('my-id');
|
|
||||||
expect(wrapper.find('label').attributes('for')).toEqual('my-id');
|
|
||||||
});
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user