refactor(components): [input] fix ts error (#8200)

This commit is contained in:
btea 2022-06-13 14:49:18 +08:00 committed by GitHub
parent 0c597a63ef
commit bf2d671142
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 5 deletions

View File

@ -80,7 +80,7 @@
<el-icon
v-if="showClear"
:class="[nsInput.e('icon'), nsInput.e('clear')]"
@mousedown.prevent
@mousedown.prevent="NOOP"
@click="clear"
>
<circle-close />
@ -174,6 +174,7 @@ import {
View as IconView,
} from '@element-plus/icons-vue'
import {
NOOP,
ValidateComponentsMap,
debugWarn,
isKorean,
@ -210,8 +211,8 @@ const instance = getCurrentInstance()!
const rawAttrs = useRawAttrs()
const slots = useSlots()
const containerAttrs = computed<Record<string, unknown>>(() => {
const comboBoxAttrs = {}
const containerAttrs = computed(() => {
const comboBoxAttrs: Record<string, unknown> = {}
if (props.containerRole === 'combobox') {
comboBoxAttrs['aria-haspopup'] = rawAttrs['aria-haspopup']
comboBoxAttrs['aria-owns'] = rawAttrs['aria-owns']
@ -248,7 +249,9 @@ const _ref = computed(() => input.value || textarea.value)
const needStatusIcon = computed(() => form?.statusIcon ?? false)
const validateState = computed(() => formItem?.validateState || '')
const validateIcon = computed(() => ValidateComponentsMap[validateState.value])
const validateIcon = computed(
() => validateState.value && ValidateComponentsMap[validateState.value]
)
const passwordIcon = computed(() =>
passwordVisible.value ? IconView : IconHide
)

View File

@ -9,6 +9,7 @@ import type {
FormEmits,
FormItemProp,
FormItemProps,
FormItemValidateState,
FormLabelWidthContext,
FormProps,
} from '@element-plus/components/form'
@ -47,7 +48,7 @@ export type FormContext = FormProps &
export interface FormItemContext extends FormItemProps {
$el: HTMLDivElement | undefined
size: ComponentSize
validateState: string
validateState: FormItemValidateState
isGroup: boolean
labelId: string
inputIds: string[]