Skip to content

Commit 7e9f9d4

Browse files
authored
feat: Improve component matching (#102)
1 parent 391a6b1 commit 7e9f9d4

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

src/config.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,13 @@ export const libraryName = 'element-plus'
99

1010
export const iconLibraryName = '@element-plus/icons-vue'
1111

12-
const allComponents = Object.values(AllComponents).reduce<string[]>((all, item) => {
13-
if (isVueComponent(item) && /^El[A-Z]\w+/.test((item as Component).name ?? '')) {
14-
all.push((item as Component).name!)
12+
const allComponents = Object.entries(AllComponents).reduce<string[]>((all, [key, item]) => {
13+
const regExp = /^El[A-Z]\w+/
14+
if (isVueComponent(item) && regExp.test(key) && regExp.test((item as Component).name ?? '')) {
15+
all.push(key)
1516
}
1617
return all
17-
}, [] as string[])
18+
}, [])
1819

1920
export const allIcons = Object.keys(AllIcons)
2021

@@ -29,6 +30,8 @@ const allImports: PresetImport[] = allImportsWithStyle
2930

3031
const allNoStylesComponents: string[] = [
3132
'ElAutoResizer',
33+
'ElCollection',
34+
'ElCollectionItem',
3235
'ElTooltipV2'
3336
]
3437

@@ -45,11 +48,13 @@ const allSubComponents: Record<string, string[]> = {
4548
ElCarousel: ['ElCarouselItem'],
4649
ElCheckbox: ['ElCheckboxButton', 'ElCheckboxGroup'],
4750
ElCollapse: ['ElCollapseItem'],
51+
ElCollection: ['ElCollectionItem'],
4852
ElContainer: ['ElAside', 'ElFooter', 'ElHeader', 'ElMain'],
4953
ElDescriptions: ['ElDescriptionsItem'],
5054
ElDropdown: ['ElDropdownItem', 'ElDropdownMenu'],
5155
ElForm: ['ElFormItem'],
5256
ElMenu: ['ElMenuItem', 'ElMenuItemGroup', 'ElSubMenu'],
57+
ElPopper: ['ElPopperArrow', 'ElPopperContent', 'ElPopperTrigger'],
5358
ElRadio: ['ElRadioGroup', 'ElRadioButton'],
5459
ElSkeleton: ['ElSkeletonItem'],
5560
ElSelect: ['ElOption', 'ElOptionGroup'],

src/utils.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export function isArray (value: any): value is any[] {
77
}
88

99
export function isVueComponent (value: any): value is Component {
10-
return typeof value === 'object' && (value.name || value.props || value.emits || value.setup || value.render)
10+
return typeof value === 'object' && value.name && (value.props || value.emits || value.setup || value.render)
1111
}
1212

1313
export function toArray<T extends any | any[]> (

0 commit comments

Comments
 (0)