From ae5b02df0dcb3ccb5a44691712c02ee664a9b69d Mon Sep 17 00:00:00 2001 From: undefined-design <1207145565@qq.com> Date: Fri, 5 Nov 2021 23:34:46 +0800 Subject: [PATCH] refactor(components): refactor row --- packages/components/row/index.ts | 14 +++------- packages/components/row/src/row.ts | 41 +++++++++++++++++------------- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/packages/components/row/index.ts b/packages/components/row/index.ts index f496430d1b..4b65524906 100644 --- a/packages/components/row/index.ts +++ b/packages/components/row/index.ts @@ -1,13 +1,7 @@ +import { withInstall } from '@element-plus/utils/with-install' import Row from './src/row' -import type { App } from 'vue' -import type { SFCWithInstall } from '@element-plus/utils/types' +export const ElRow = withInstall(Row) +export default ElRow -const _Row = Row as SFCWithInstall - -_Row.install = (app: App) => { - app.component(_Row.name, _Row) -} - -export default _Row -export const ElRow = _Row +export * from './src/row' diff --git a/packages/components/row/src/row.ts b/packages/components/row/src/row.ts index 766fd4fdf8..2a5462a7e3 100644 --- a/packages/components/row/src/row.ts +++ b/packages/components/row/src/row.ts @@ -1,25 +1,30 @@ import { defineComponent, computed, h, provide } from 'vue' +import { buildProps } from '@element-plus/utils/props' +import type { ExtractPropTypes } from 'vue' + +export const rowProps = buildProps({ + tag: { + type: String, + default: 'div', + }, + gutter: { + type: Number, + default: 0, + }, + justify: { + type: String, + default: 'start', + }, + align: { + type: String, + default: 'top', + }, +} as const) +export type RowProps = ExtractPropTypes export default defineComponent({ name: 'ElRow', - props: { - tag: { - type: String, - default: 'div', - }, - gutter: { - type: Number, - default: 0, - }, - justify: { - type: String, - default: 'start', - }, - align: { - type: String, - default: 'top', - }, - }, + props: rowProps, setup(props, { slots }) { const gutter = computed(() => props.gutter) provide('ElRow', {