diff --git a/src/cell/index.js b/src/cell/index.tsx similarity index 76% rename from src/cell/index.js rename to src/cell/index.tsx index 523a29a09..6cbcfc277 100644 --- a/src/cell/index.js +++ b/src/cell/index.tsx @@ -1,6 +1,7 @@ +import { PropType } from 'vue'; + // Utils import { createNamespace, isDef } from '../utils'; -import { cellProps } from './shared'; // Composition import { useRoute, routeProps } from '../composition/use-route'; @@ -10,6 +11,30 @@ import Icon from '../icon'; const [createComponent, bem] = createNamespace('cell'); +export type CellArrowDirection = 'up' | 'down' | 'left' | 'right'; + +export const cellProps = { + icon: String, + size: String as PropType<'large'>, + title: [Number, String], + value: [Number, String], + label: [Number, String], + center: Boolean, + isLink: Boolean, + required: Boolean, + clickable: Boolean, + iconPrefix: String, + titleStyle: null as any, + titleClass: null as any, + valueClass: null as any, + labelClass: null as any, + arrowDirection: String as PropType, + border: { + type: Boolean, + default: true, + }, +}; + export default createComponent({ props: { ...cellProps, @@ -91,21 +116,21 @@ export default createComponent({ const { size, center, border, isLink, required } = props; const clickable = isLink || props.clickable; - const classes = { + const classes: Record = { center, required, clickable, borderless: !border, }; if (size) { - classes[size] = size; + classes[size] = !!size; } return (
{renderLeftIcon()} diff --git a/src/cell/shared.ts b/src/cell/shared.ts deleted file mode 100644 index f3c2ec949..000000000 --- a/src/cell/shared.ts +++ /dev/null @@ -1,40 +0,0 @@ -export type SharedCellProps = { - icon?: string; - size?: string; - border: boolean; - center?: boolean; - isLink?: boolean; - required?: boolean; - clickable?: boolean; - iconPrefix?: string; - titleStyle?: any; - titleClass?: any; - valueClass?: any; - labelClass?: any; - title?: string | number; - value?: string | number; - label?: string | number; - arrowDirection?: 'up' | 'down' | 'left' | 'right'; -}; - -export const cellProps = { - icon: String, - size: String, - center: Boolean, - isLink: Boolean, - required: Boolean, - clickable: Boolean, - iconPrefix: String, - titleStyle: null as any, - titleClass: null as any, - valueClass: null as any, - labelClass: null as any, - title: [Number, String], - value: [Number, String], - label: [Number, String], - arrowDirection: String, - border: { - type: Boolean, - default: true, - }, -}; diff --git a/src/collapse-item/index.js b/src/collapse-item/index.js index 57dadf2bd..01b7362ce 100644 --- a/src/collapse-item/index.js +++ b/src/collapse-item/index.js @@ -9,9 +9,8 @@ import { useParent } from '../composition/use-relation'; import { useLazyRender } from '../composition/use-lazy-render'; // Components -import Cell from '../cell'; +import Cell, { cellProps } from '../cell'; import { COLLAPSE_KEY } from '../collapse'; -import { cellProps } from '../cell/shared'; const [createComponent, bem] = createNamespace('collapse-item'); diff --git a/src/field/index.js b/src/field/index.js index 5b69a8466..72916c84f 100644 --- a/src/field/index.js +++ b/src/field/index.js @@ -13,8 +13,7 @@ import { // Components import Icon from '../icon'; -import Cell from '../cell'; -import { cellProps } from '../cell/shared'; +import Cell, { cellProps } from '../cell'; const [createComponent, bem] = createNamespace('field');