diff --git a/src/upload/constants.ts b/src/upload/constants.ts new file mode 100644 index 000000000..5c153dcf7 --- /dev/null +++ b/src/upload/constants.ts @@ -0,0 +1,26 @@ +import { PropType } from 'vue'; +import { CommonDisplayFileProps } from './interface'; + +export const commonProps = { + files: Array as PropType, + toUploadFiles: Array as PropType, + displayFiles: Array as PropType, + theme: String as PropType, + abridgeName: Array as PropType, + placeholder: String, + classPrefix: String, + tips: String, + status: String as PropType, + locale: Object as PropType, + sizeOverLimitMessage: String, + autoUpload: Boolean, + disabled: Boolean, + uploading: Boolean, + tipsClasses: [String, Array, Object] as PropType, + errorClasses: [String, Array, Object] as PropType, + default: Function as PropType, + fileListDisplay: Function as PropType, + onRemove: Function as PropType, +}; + +export default commonProps; diff --git a/src/upload/interface.ts b/src/upload/interface.ts index bc2fc7b6e..a3cc07cec 100644 --- a/src/upload/interface.ts +++ b/src/upload/interface.ts @@ -1,4 +1,3 @@ -import { PropType } from 'vue'; import { TdUploadProps, UploadRemoveContext } from './type'; import { GlobalConfigProvider } from '../config-provider/type'; import { TNode } from '../common'; @@ -27,25 +26,3 @@ export interface CommonDisplayFileProps { } export type UploadProps = TdUploadProps; - -export const commonProps = { - files: Array as PropType, - toUploadFiles: Array as PropType, - displayFiles: Array as PropType, - theme: String as PropType, - abridgeName: Array as PropType, - placeholder: String, - classPrefix: String, - tips: String, - status: String as PropType, - locale: Object as PropType, - sizeOverLimitMessage: String, - autoUpload: Boolean, - disabled: Boolean, - uploading: Boolean, - tipsClasses: [String, Array, Object] as PropType, - errorClasses: [String, Array, Object] as PropType, - default: Function as PropType, - fileListDisplay: Function as PropType, - onRemove: Function as PropType, -}; diff --git a/src/upload/themes/custom-file.tsx b/src/upload/themes/custom-file.tsx index 3fae91779..91c580d08 100644 --- a/src/upload/themes/custom-file.tsx +++ b/src/upload/themes/custom-file.tsx @@ -1,7 +1,8 @@ import { defineComponent, PropType } from '@vue/composition-api'; import isFunction from 'lodash/isFunction'; import useDrag, { UploadDragEvents } from '../hooks/useDrag'; -import { CommonDisplayFileProps, commonProps } from '../interface'; +import { CommonDisplayFileProps } from '../interface'; +import { commonProps } from '../constants'; import { renderContent } from '../../utils/render-tnode'; import { TdUploadProps } from '../type'; diff --git a/src/upload/themes/dragger-file.tsx b/src/upload/themes/dragger-file.tsx index ef087610b..fb8306393 100644 --- a/src/upload/themes/dragger-file.tsx +++ b/src/upload/themes/dragger-file.tsx @@ -9,7 +9,8 @@ import { import { abridgeName, getFileSizeText } from '../../_common/js/upload/utils'; import { TdUploadProps, UploadFile } from '../type'; import Button from '../../button'; -import { CommonDisplayFileProps, commonProps } from '../interface'; +import { CommonDisplayFileProps } from '../interface'; +import { commonProps } from '../constants'; import useCommonClassName from '../../hooks/useCommonClassName'; import TLoading from '../../loading'; import useDrag, { UploadDragEvents } from '../hooks/useDrag'; diff --git a/src/upload/themes/image-card.tsx b/src/upload/themes/image-card.tsx index e982fea43..7f6d39ec7 100644 --- a/src/upload/themes/image-card.tsx +++ b/src/upload/themes/image-card.tsx @@ -11,7 +11,8 @@ import { import Loading from '../../loading'; import { useGlobalIcon } from '../../hooks/useGlobalIcon'; import ImageViewer from '../../image-viewer'; -import { CommonDisplayFileProps, commonProps } from '../interface'; +import { CommonDisplayFileProps } from '../interface'; +import { commonProps } from '../constants'; import { TdUploadProps, UploadFile } from '../type'; export interface ImageCardUploadProps extends CommonDisplayFileProps { diff --git a/src/upload/themes/multiple-flow-list.tsx b/src/upload/themes/multiple-flow-list.tsx index 8d0ed3f88..4f991d9d0 100644 --- a/src/upload/themes/multiple-flow-list.tsx +++ b/src/upload/themes/multiple-flow-list.tsx @@ -12,7 +12,8 @@ import { } from 'tdesign-icons-vue'; import { useGlobalIcon } from '../../hooks/useGlobalIcon'; import ImageViewer from '../../image-viewer'; -import { CommonDisplayFileProps, commonProps } from '../interface'; +import { CommonDisplayFileProps } from '../interface'; +import { commonProps } from '../constants'; import TButton from '../../button'; import { UploadFile, TdUploadProps } from '../type'; import useDrag, { UploadDragEvents } from '../hooks/useDrag'; diff --git a/src/upload/themes/normal-file.tsx b/src/upload/themes/normal-file.tsx index eea21b790..99c72a26b 100644 --- a/src/upload/themes/normal-file.tsx +++ b/src/upload/themes/normal-file.tsx @@ -12,7 +12,8 @@ import { renderTNodeJSX } from '../../utils/render-tnode'; import { UploadFile } from '../type'; import { abridgeName } from '../../_common/js/upload/utils'; import { useGlobalIcon } from '../../hooks/useGlobalIcon'; -import { CommonDisplayFileProps, commonProps } from '../interface'; +import { CommonDisplayFileProps } from '../interface'; +import { commonProps } from '../constants'; export interface NormalFileProps extends CommonDisplayFileProps { multiple: boolean;