mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
types(Search): missing some props in jsx (#8485)
This commit is contained in:
parent
1217088d95
commit
e1df4bd9c3
@ -54,65 +54,70 @@ import type {
|
|||||||
|
|
||||||
const [name, bem] = createNamespace('field');
|
const [name, bem] = createNamespace('field');
|
||||||
|
|
||||||
|
// provide to Search component to inherit
|
||||||
|
export const fieldProps = {
|
||||||
|
formatter: Function as PropType<(value: string) => string>,
|
||||||
|
leftIcon: String,
|
||||||
|
rightIcon: String,
|
||||||
|
clearable: Boolean,
|
||||||
|
maxlength: [Number, String],
|
||||||
|
inputAlign: String as PropType<FieldTextAlign>,
|
||||||
|
placeholder: String,
|
||||||
|
errorMessage: String,
|
||||||
|
error: {
|
||||||
|
type: Boolean,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
disabled: {
|
||||||
|
type: Boolean,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
readonly: {
|
||||||
|
type: Boolean,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
|
clearIcon: {
|
||||||
|
type: String,
|
||||||
|
default: 'clear',
|
||||||
|
},
|
||||||
|
modelValue: {
|
||||||
|
type: [String, Number],
|
||||||
|
default: '',
|
||||||
|
},
|
||||||
|
clearTrigger: {
|
||||||
|
type: String as PropType<FieldClearTrigger>,
|
||||||
|
default: 'focus',
|
||||||
|
},
|
||||||
|
formatTrigger: {
|
||||||
|
type: String as PropType<FieldFormatTrigger>,
|
||||||
|
default: 'onChange',
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name,
|
name,
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
...cellProps,
|
...cellProps,
|
||||||
|
...fieldProps,
|
||||||
rows: [Number, String],
|
rows: [Number, String],
|
||||||
name: String,
|
name: String,
|
||||||
rules: Array as PropType<FieldRule[]>,
|
rules: Array as PropType<FieldRule[]>,
|
||||||
autosize: [Boolean, Object] as PropType<boolean | FieldAutosizeConfig>,
|
autosize: [Boolean, Object] as PropType<boolean | FieldAutosizeConfig>,
|
||||||
leftIcon: String,
|
|
||||||
rightIcon: String,
|
|
||||||
clearable: Boolean,
|
|
||||||
formatter: Function as PropType<(value: string) => string>,
|
|
||||||
maxlength: [Number, String],
|
|
||||||
labelWidth: [Number, String],
|
labelWidth: [Number, String],
|
||||||
labelClass: UnknownProp,
|
labelClass: UnknownProp,
|
||||||
labelAlign: String as PropType<FieldTextAlign>,
|
labelAlign: String as PropType<FieldTextAlign>,
|
||||||
inputAlign: String as PropType<FieldTextAlign>,
|
|
||||||
placeholder: String,
|
|
||||||
autocomplete: String,
|
autocomplete: String,
|
||||||
errorMessage: String,
|
|
||||||
errorMessageAlign: String as PropType<FieldTextAlign>,
|
|
||||||
showWordLimit: Boolean,
|
showWordLimit: Boolean,
|
||||||
|
errorMessageAlign: String as PropType<FieldTextAlign>,
|
||||||
type: {
|
type: {
|
||||||
type: String as PropType<FieldType>,
|
type: String as PropType<FieldType>,
|
||||||
default: 'text',
|
default: 'text',
|
||||||
},
|
},
|
||||||
error: {
|
|
||||||
type: Boolean,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
colon: {
|
colon: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: null,
|
default: null,
|
||||||
},
|
},
|
||||||
disabled: {
|
|
||||||
type: Boolean,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
readonly: {
|
|
||||||
type: Boolean,
|
|
||||||
default: null,
|
|
||||||
},
|
|
||||||
clearIcon: {
|
|
||||||
type: String,
|
|
||||||
default: 'clear',
|
|
||||||
},
|
|
||||||
modelValue: {
|
|
||||||
type: [String, Number],
|
|
||||||
default: '',
|
|
||||||
},
|
|
||||||
clearTrigger: {
|
|
||||||
type: String as PropType<FieldClearTrigger>,
|
|
||||||
default: 'focus',
|
|
||||||
},
|
|
||||||
formatTrigger: {
|
|
||||||
type: String as PropType<FieldFormatTrigger>,
|
|
||||||
default: 'onChange',
|
|
||||||
},
|
|
||||||
},
|
},
|
||||||
|
|
||||||
emits: [
|
emits: [
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { ref, PropType, CSSProperties, defineComponent } from 'vue';
|
import { ref, PropType, defineComponent } from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import {
|
import {
|
||||||
@ -7,6 +7,7 @@ import {
|
|||||||
preventDefault,
|
preventDefault,
|
||||||
ComponentInstance,
|
ComponentInstance,
|
||||||
} from '../utils';
|
} from '../utils';
|
||||||
|
import { fieldProps } from '../field/Field';
|
||||||
|
|
||||||
// Composables
|
// Composables
|
||||||
import { useExpose } from '../composables/use-expose';
|
import { useExpose } from '../composables/use-expose';
|
||||||
@ -14,9 +15,6 @@ import { useExpose } from '../composables/use-expose';
|
|||||||
// Components
|
// Components
|
||||||
import { Field } from '../field';
|
import { Field } from '../field';
|
||||||
|
|
||||||
// Types
|
|
||||||
import type { FieldClearTrigger, FieldFormatTrigger } from '../field/types';
|
|
||||||
|
|
||||||
const [name, bem, t] = createNamespace('search');
|
const [name, bem, t] = createNamespace('search');
|
||||||
|
|
||||||
export type SearchShape = 'square' | 'round';
|
export type SearchShape = 'square' | 'round';
|
||||||
@ -24,20 +22,12 @@ export type SearchShape = 'square' | 'round';
|
|||||||
export default defineComponent({
|
export default defineComponent({
|
||||||
name,
|
name,
|
||||||
|
|
||||||
inheritAttrs: false,
|
|
||||||
|
|
||||||
props: {
|
props: {
|
||||||
|
...fieldProps,
|
||||||
label: String,
|
label: String,
|
||||||
clearIcon: String,
|
|
||||||
rightIcon: String,
|
|
||||||
formatter: Function as PropType<(value: string) => string>,
|
|
||||||
modelValue: String,
|
|
||||||
actionText: String,
|
actionText: String,
|
||||||
background: String,
|
background: String,
|
||||||
showAction: Boolean,
|
showAction: Boolean,
|
||||||
errorMessage: String,
|
|
||||||
clearTrigger: String as PropType<FieldClearTrigger>,
|
|
||||||
formatTrigger: String as PropType<FieldFormatTrigger>,
|
|
||||||
shape: {
|
shape: {
|
||||||
type: String as PropType<SearchShape>,
|
type: String as PropType<SearchShape>,
|
||||||
default: 'square',
|
default: 'square',
|
||||||
@ -101,24 +91,14 @@ export default defineComponent({
|
|||||||
const blur = () => filedRef.value?.blur();
|
const blur = () => filedRef.value?.blur();
|
||||||
const focus = () => filedRef.value?.focus();
|
const focus = () => filedRef.value?.focus();
|
||||||
|
|
||||||
const fieldPropNames = [
|
const fieldPropNames = Object.keys(fieldProps) as Array<
|
||||||
'leftIcon',
|
keyof typeof fieldProps
|
||||||
'clearIcon',
|
>;
|
||||||
'rightIcon',
|
|
||||||
'formatter',
|
|
||||||
'clearable',
|
|
||||||
'modelValue',
|
|
||||||
'clearTrigger',
|
|
||||||
'errorMessage',
|
|
||||||
'formatTrigger',
|
|
||||||
] as const;
|
|
||||||
|
|
||||||
const renderField = () => {
|
const renderField = () => {
|
||||||
const fieldAttrs = {
|
const fieldAttrs = {
|
||||||
...attrs,
|
...attrs,
|
||||||
...pick(props, fieldPropNames),
|
...pick(props, fieldPropNames),
|
||||||
style: null,
|
|
||||||
class: null,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const onInput = (value: string) => emit('update:modelValue', value);
|
const onInput = (value: string) => emit('update:modelValue', value);
|
||||||
@ -140,11 +120,8 @@ export default defineComponent({
|
|||||||
|
|
||||||
return () => (
|
return () => (
|
||||||
<div
|
<div
|
||||||
class={[bem({ 'show-action': props.showAction }), attrs.class]}
|
class={bem({ 'show-action': props.showAction })}
|
||||||
style={{
|
style={{ background: props.background }}
|
||||||
background: props.background,
|
|
||||||
...(attrs.style as CSSProperties),
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{slots.left?.()}
|
{slots.left?.()}
|
||||||
<div class={bem('content', props.shape)}>
|
<div class={bem('content', props.shape)}>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user