From 8bae9ca0ed29f3029923907f5d1b2bc68794d4c6 Mon Sep 17 00:00:00 2001 From: neverland Date: Mon, 8 Mar 2021 17:14:55 +0800 Subject: [PATCH] chore: export some types (#8309) --- src/address-edit/index.ts | 2 ++ src/button/Button.tsx | 2 +- src/calendar/index.ts | 2 ++ src/cell/index.ts | 1 + src/contact-card/index.ts | 1 + src/contact-list/index.ts | 1 + src/datetime-picker/index.ts | 1 + src/grid/index.ts | 1 + src/notice-bar/index.ts | 1 + src/picker/index.ts | 7 +++++++ src/popover/index.ts | 6 ++++++ src/row/index.ts | 1 + src/search/index.ts | 1 + src/sticky/index.ts | 1 + src/tabs/Tabs.tsx | 4 ++-- src/tabs/index.ts | 1 + src/tree-select/index.ts | 1 + src/uploader/Uploader.tsx | 24 +++++++++++++++--------- src/uploader/UploaderPreviewItem.tsx | 4 ++-- src/uploader/demo/index.vue | 8 ++++---- src/uploader/index.ts | 1 + src/uploader/utils.ts | 15 +++++++++------ src/utils/create/index.ts | 8 ++++++-- 23 files changed, 68 insertions(+), 26 deletions(-) diff --git a/src/address-edit/index.ts b/src/address-edit/index.ts index 0ecb2428c..55f962db2 100644 --- a/src/address-edit/index.ts +++ b/src/address-edit/index.ts @@ -5,3 +5,5 @@ const AddressEdit = withInstall(_AddressEdit); export default AddressEdit; export { AddressEdit }; +export type { AddressEditInfo } from './AddressEdit'; +export type { AddressEditSearchItem } from './AddressEditDetail'; diff --git a/src/button/Button.tsx b/src/button/Button.tsx index b3251db19..2ad21ac69 100644 --- a/src/button/Button.tsx +++ b/src/button/Button.tsx @@ -1,8 +1,8 @@ import { PropType, CSSProperties, - ButtonHTMLAttributes, defineComponent, + ButtonHTMLAttributes, } from 'vue'; // Utils diff --git a/src/calendar/index.ts b/src/calendar/index.ts index 74ea6df82..91cb18bfc 100644 --- a/src/calendar/index.ts +++ b/src/calendar/index.ts @@ -5,3 +5,5 @@ const Calendar = withInstall(_Calendar); export default Calendar; export { Calendar }; +export type { CalendarType } from './CalendarMonth'; +export type { CalendarDayItem, CalendarDayType } from './CalendarDay'; diff --git a/src/cell/index.ts b/src/cell/index.ts index 08ee00947..973a1faf6 100644 --- a/src/cell/index.ts +++ b/src/cell/index.ts @@ -5,3 +5,4 @@ const Cell = withInstall(_Cell); export default Cell; export { Cell }; +export type { CellArrowDirection } from './Cell'; diff --git a/src/contact-card/index.ts b/src/contact-card/index.ts index e3d16eaeb..87817f5e0 100644 --- a/src/contact-card/index.ts +++ b/src/contact-card/index.ts @@ -5,3 +5,4 @@ const ContactCard = withInstall(_ContactCard); export default ContactCard; export { ContactCard }; +export type { ContactCardType } from './ContactCard'; diff --git a/src/contact-list/index.ts b/src/contact-list/index.ts index 8475cafe1..15cf4233f 100644 --- a/src/contact-list/index.ts +++ b/src/contact-list/index.ts @@ -5,3 +5,4 @@ const ContactList = withInstall(_ContactList); export default ContactList; export { ContactList }; +export type { ContactListItem } from './ContactList'; diff --git a/src/datetime-picker/index.ts b/src/datetime-picker/index.ts index fdd3b561f..62339411c 100644 --- a/src/datetime-picker/index.ts +++ b/src/datetime-picker/index.ts @@ -5,3 +5,4 @@ const DatetimePicker = withInstall(_DatetimePicker); export default DatetimePicker; export { DatetimePicker }; +export type { DatetimePickerType } from './utils'; diff --git a/src/grid/index.ts b/src/grid/index.ts index 84cf90c9f..18c14c556 100644 --- a/src/grid/index.ts +++ b/src/grid/index.ts @@ -5,3 +5,4 @@ const Grid = withInstall(_Grid); export default Grid; export { Grid }; +export type { GridDirection } from './Grid'; diff --git a/src/notice-bar/index.ts b/src/notice-bar/index.ts index 540235eb1..27536f692 100644 --- a/src/notice-bar/index.ts +++ b/src/notice-bar/index.ts @@ -5,3 +5,4 @@ const NoticeBar = withInstall(_NoticeBar); export default NoticeBar; export { NoticeBar }; +export type { NoticeBarMode } from './NoticeBar'; diff --git a/src/picker/index.ts b/src/picker/index.ts index cb06b6cab..cfc1ee1d2 100644 --- a/src/picker/index.ts +++ b/src/picker/index.ts @@ -5,3 +5,10 @@ const Picker = withInstall(_Picker); export default Picker; export { Picker }; +export type { + PickerColumn, + PickerOption, + PickerObjectColumn, + PickerObjectOption, + PickerToolbarPosition, +} from './Picker'; diff --git a/src/popover/index.ts b/src/popover/index.ts index 9ad259494..cb6b27e36 100644 --- a/src/popover/index.ts +++ b/src/popover/index.ts @@ -5,3 +5,9 @@ const Popover = withInstall(_Popover); export default Popover; export { Popover }; +export type { + PopoverTheme, + PopoverAction, + PopoverTrigger, + PopoverPlacement, +} from './Popover'; diff --git a/src/row/index.ts b/src/row/index.ts index b15dd68ed..613a73fa4 100644 --- a/src/row/index.ts +++ b/src/row/index.ts @@ -5,3 +5,4 @@ const Row = withInstall(_Row); export default Row; export { Row }; +export type { RowAlign, RowJustify } from './Row'; diff --git a/src/search/index.ts b/src/search/index.ts index 8d867887f..dd29c1b8c 100644 --- a/src/search/index.ts +++ b/src/search/index.ts @@ -5,3 +5,4 @@ const Search = withInstall(_Search); export default Search; export { Search }; +export type { SearchShape } from './Search'; diff --git a/src/sticky/index.ts b/src/sticky/index.ts index e78497937..905496794 100644 --- a/src/sticky/index.ts +++ b/src/sticky/index.ts @@ -5,3 +5,4 @@ const Sticky = withInstall(_Sticky); export default Sticky; export { Sticky }; +export type { StickyPosition } from './Sticky'; diff --git a/src/tabs/Tabs.tsx b/src/tabs/Tabs.tsx index cae93cee3..7da49752f 100644 --- a/src/tabs/Tabs.tsx +++ b/src/tabs/Tabs.tsx @@ -50,7 +50,7 @@ const [name, bem] = createNamespace('tabs'); export const TABS_KEY = Symbol(name); -export type TabType = 'line' | 'card'; +export type TabsType = 'line' | 'card'; export type TabsProvide = { props: { @@ -82,7 +82,7 @@ export default defineComponent({ titleActiveColor: String, titleInactiveColor: String, type: { - type: String as PropType, + type: String as PropType, default: 'line', }, active: { diff --git a/src/tabs/index.ts b/src/tabs/index.ts index d67f4d5f2..dfe9c9100 100644 --- a/src/tabs/index.ts +++ b/src/tabs/index.ts @@ -5,3 +5,4 @@ const Tabs = withInstall(_Tabs); export default Tabs; export { Tabs }; +export type { TabsType } from './Tabs'; diff --git a/src/tree-select/index.ts b/src/tree-select/index.ts index 51e15029f..1c18942d3 100644 --- a/src/tree-select/index.ts +++ b/src/tree-select/index.ts @@ -5,3 +5,4 @@ const TreeSelect = withInstall(_TreeSelect); export default TreeSelect; export { TreeSelect }; +export type { TreeSelectItem, TreeSelectChild } from './TreeSelect'; diff --git a/src/uploader/Uploader.tsx b/src/uploader/Uploader.tsx index 44483588c..f5dafce6d 100644 --- a/src/uploader/Uploader.tsx +++ b/src/uploader/Uploader.tsx @@ -9,9 +9,9 @@ import { isOversize, filterFiles, isImageFile, - FileListItem, readFileContent, UploaderResultType, + UploaderFileListItem, } from './utils'; // Composables @@ -38,7 +38,7 @@ export type UploaderBeforeRead = ( ) => PromiseOrNot; export type UploaderAfterRead = ( - items: FileListItem | FileListItem[], + items: UploaderFileListItem | UploaderFileListItem[], detail: { name: string | number; index: number; @@ -68,7 +68,7 @@ export default defineComponent({ default: 'image/*', }, modelValue: { - type: Array as PropType, + type: Array as PropType, default: () => [], }, maxSize: { @@ -131,7 +131,9 @@ export default defineComponent({ } }; - const onAfterRead = (items: FileListItem | FileListItem[]) => { + const onAfterRead = ( + items: UploaderFileListItem | UploaderFileListItem[] + ) => { resetInput(); if (isOversize(items, props.maxSize)) { @@ -170,7 +172,11 @@ export default defineComponent({ files.map((file) => readFileContent(file, resultType)) ).then((contents) => { const fileList = (files as File[]).map((file, index) => { - const result: FileListItem = { file, status: '', message: '' }; + const result: UploaderFileListItem = { + file, + status: '', + message: '', + }; if (contents[index]) { result.content = contents[index] as string; @@ -183,7 +189,7 @@ export default defineComponent({ }); } else { readFileContent(files, resultType).then((content) => { - const result: FileListItem = { + const result: UploaderFileListItem = { file: files as File, status: '', message: '', @@ -237,7 +243,7 @@ export default defineComponent({ const onClosePreview = () => emit('close-preview'); - const previewImage = (item: FileListItem) => { + const previewImage = (item: UploaderFileListItem) => { if (props.previewFullImage) { const imageFiles = props.modelValue.filter(isImageFile); const images = imageFiles @@ -259,7 +265,7 @@ export default defineComponent({ } }; - const deleteFile = (item: FileListItem, index: number) => { + const deleteFile = (item: UploaderFileListItem, index: number) => { const fileList = props.modelValue.slice(0); fileList.splice(index, 1); @@ -267,7 +273,7 @@ export default defineComponent({ emit('delete', item, getDetail(index)); }; - const renderPreviewItem = (item: FileListItem, index: number) => { + const renderPreviewItem = (item: UploaderFileListItem, index: number) => { const needPickData = [ 'imageFit', 'deletable', diff --git a/src/uploader/UploaderPreviewItem.tsx b/src/uploader/UploaderPreviewItem.tsx index 475dce89a..d793a9929 100644 --- a/src/uploader/UploaderPreviewItem.tsx +++ b/src/uploader/UploaderPreviewItem.tsx @@ -1,7 +1,7 @@ import { PropType, defineComponent } from 'vue'; // Utils -import { bem, isImageFile, FileListItem } from './utils'; +import { bem, isImageFile, UploaderFileListItem } from './utils'; import { isDef, getSizeStyle } from '../utils'; import { callInterceptor, Interceptor } from '../utils/interceptor'; @@ -20,7 +20,7 @@ export default defineComponent({ previewSize: [Number, String], beforeDelete: Function as PropType, item: { - type: Object as PropType, + type: Object as PropType, required: true, }, }, diff --git a/src/uploader/demo/index.vue b/src/uploader/demo/index.vue index d3b1f65c5..1c44ee963 100644 --- a/src/uploader/demo/index.vue +++ b/src/uploader/demo/index.vue @@ -56,7 +56,7 @@