refactor(components): [description, input] use the component name constant (#20107)

* refactor(components): [description] extracts the component name constant

* refactor: extracts the component name constant

* refactor: change the location of COMPONENT_NAME

* Update packages/components/descriptions/src/description-item.ts

Co-authored-by: btea <2356281422@qq.com>

* refactor: change the name

* refactor: Extract COMPONENT_NAME to a separate file

* refactor: Adjust rows

---------

Co-authored-by: btea <2356281422@qq.com>
This commit is contained in:
风屿 2025-03-15 23:14:51 +08:00 committed by GitHub
parent 4807705579
commit e87a8670d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 9 additions and 4 deletions

View File

@ -0,0 +1 @@
export const COMPONENT_NAME = 'ElDescriptionsItem'

View File

@ -1,5 +1,6 @@
import { defineComponent } from 'vue'
import { buildProps } from '@element-plus/utils'
import { COMPONENT_NAME } from './constants'
import type { ExtractPropTypes, Slot, VNode } from 'vue'
@ -75,8 +76,9 @@ export const descriptionItemProps = buildProps({
default: '',
},
})
const DescriptionItem = defineComponent({
name: 'ElDescriptionsItem',
name: COMPONENT_NAME,
props: descriptionItemProps,
})

View File

@ -32,6 +32,7 @@ import { useFormSize } from '@element-plus/components/form'
import ElDescriptionsRow from './descriptions-row.vue'
import { descriptionsKey } from './token'
import { descriptionProps } from './description'
import { COMPONENT_NAME } from './constants'
import type { IDescriptionsInject } from './descriptions.type'
import type { DescriptionItemVNode } from './description-item'
@ -76,7 +77,7 @@ const getRows = () => {
const children = flattedChildren(slots.default()).filter(
(node): node is DescriptionItemVNode =>
(node as any)?.type?.name === 'ElDescriptionsItem'
(node as any)?.type?.name === COMPONENT_NAME
)
const rows: DescriptionItemVNode[][] = []
let temp: DescriptionItemVNode[] = []

View File

@ -197,8 +197,9 @@ import type { StyleValue } from 'vue'
type TargetElement = HTMLInputElement | HTMLTextAreaElement
const COMPONENT_NAME = 'ElInput'
defineOptions({
name: 'ElInput',
name: COMPONENT_NAME,
inheritAttrs: false,
})
const props = defineProps(inputProps)
@ -502,7 +503,7 @@ watch(
onMounted(() => {
if (!props.formatter && props.parser) {
debugWarn(
'ElInput',
COMPONENT_NAME,
'If you set the parser, you also need to set the formatter.'
)
}