diff --git a/packages/components/avatar/__tests__/avatar.spec.ts b/packages/components/avatar/__tests__/avatar.spec.ts index 3332df1dbc..adec67f0fb 100644 --- a/packages/components/avatar/__tests__/avatar.spec.ts +++ b/packages/components/avatar/__tests__/avatar.spec.ts @@ -6,7 +6,7 @@ import { mockImageEvent, } from '@element-plus/test-utils' -import Avatar from '../src/index.vue' +import Avatar from '../src/avatar.vue' describe('Avatar.vue', () => { mockImageEvent() diff --git a/packages/components/avatar/index.ts b/packages/components/avatar/index.ts index dd78f0819d..9ca8e85c0e 100644 --- a/packages/components/avatar/index.ts +++ b/packages/components/avatar/index.ts @@ -1,12 +1,7 @@ -import { App } from 'vue' -import type { SFCWithInstall } from '@element-plus/utils/types' -import Avatar from './src/index.vue' +import Avatar from './src/avatar.vue' +import { withInstall } from '@element-plus/utils/with-install' -Avatar.install = (app: App): void => { - app.component(Avatar.name, Avatar) -} +export const ElAvatar = withInstall(Avatar) +export default ElAvatar -const _Avatar = Avatar as SFCWithInstall - -export default _Avatar -export const ElAvatar = _Avatar +export * from './src/avatar' diff --git a/packages/components/avatar/src/avatar.ts b/packages/components/avatar/src/avatar.ts new file mode 100644 index 0000000000..64725a1f27 --- /dev/null +++ b/packages/components/avatar/src/avatar.ts @@ -0,0 +1,35 @@ +import { buildProp } from '@element-plus/utils/props' +import type { CSSProperties, ExtractPropTypes } from 'vue' + +export const avatarProps = { + size: buildProp({ + type: [Number, String], + values: ['large', 'medium', 'small'], + default: 'large', + validator: (val): val is number => typeof val === 'number', + } as const), + + shape: buildProp({ + type: String, + values: ['circle', 'square'], + default: 'circle', + } as const), + + icon: String, + src: { + type: String, + default: '', + }, + alt: String, + srcSet: String, + fit: buildProp({ + type: String, + default: 'cover', + } as const), +} as const +export type AvatarProps = ExtractPropTypes + +export const avatarEmits = { + error: (evt: Event) => evt instanceof Event, +} +export type AvatarEmits = typeof avatarEmits diff --git a/packages/components/avatar/src/avatar.vue b/packages/components/avatar/src/avatar.vue new file mode 100644 index 0000000000..e8e5bd2ed5 --- /dev/null +++ b/packages/components/avatar/src/avatar.vue @@ -0,0 +1,75 @@ + + + diff --git a/packages/components/avatar/src/index.vue b/packages/components/avatar/src/index.vue deleted file mode 100644 index 74a323e675..0000000000 --- a/packages/components/avatar/src/index.vue +++ /dev/null @@ -1,109 +0,0 @@ - - -