mirror of
https://gitee.com/vant-contrib/vant.git
synced 2025-04-06 03:57:59 +08:00
chore: export some types (#8309)
This commit is contained in:
parent
ae40d40c24
commit
8bae9ca0ed
@ -5,3 +5,5 @@ const AddressEdit = withInstall<typeof _AddressEdit>(_AddressEdit);
|
|||||||
|
|
||||||
export default AddressEdit;
|
export default AddressEdit;
|
||||||
export { AddressEdit };
|
export { AddressEdit };
|
||||||
|
export type { AddressEditInfo } from './AddressEdit';
|
||||||
|
export type { AddressEditSearchItem } from './AddressEditDetail';
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
import {
|
import {
|
||||||
PropType,
|
PropType,
|
||||||
CSSProperties,
|
CSSProperties,
|
||||||
ButtonHTMLAttributes,
|
|
||||||
defineComponent,
|
defineComponent,
|
||||||
|
ButtonHTMLAttributes,
|
||||||
} from 'vue';
|
} from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
|
@ -5,3 +5,5 @@ const Calendar = withInstall<typeof _Calendar>(_Calendar);
|
|||||||
|
|
||||||
export default Calendar;
|
export default Calendar;
|
||||||
export { Calendar };
|
export { Calendar };
|
||||||
|
export type { CalendarType } from './CalendarMonth';
|
||||||
|
export type { CalendarDayItem, CalendarDayType } from './CalendarDay';
|
||||||
|
@ -5,3 +5,4 @@ const Cell = withInstall<typeof _Cell>(_Cell);
|
|||||||
|
|
||||||
export default Cell;
|
export default Cell;
|
||||||
export { Cell };
|
export { Cell };
|
||||||
|
export type { CellArrowDirection } from './Cell';
|
||||||
|
@ -5,3 +5,4 @@ const ContactCard = withInstall<typeof _ContactCard>(_ContactCard);
|
|||||||
|
|
||||||
export default ContactCard;
|
export default ContactCard;
|
||||||
export { ContactCard };
|
export { ContactCard };
|
||||||
|
export type { ContactCardType } from './ContactCard';
|
||||||
|
@ -5,3 +5,4 @@ const ContactList = withInstall<typeof _ContactList>(_ContactList);
|
|||||||
|
|
||||||
export default ContactList;
|
export default ContactList;
|
||||||
export { ContactList };
|
export { ContactList };
|
||||||
|
export type { ContactListItem } from './ContactList';
|
||||||
|
@ -5,3 +5,4 @@ const DatetimePicker = withInstall<typeof _DatetimePicker>(_DatetimePicker);
|
|||||||
|
|
||||||
export default DatetimePicker;
|
export default DatetimePicker;
|
||||||
export { DatetimePicker };
|
export { DatetimePicker };
|
||||||
|
export type { DatetimePickerType } from './utils';
|
||||||
|
@ -5,3 +5,4 @@ const Grid = withInstall<typeof _Grid>(_Grid);
|
|||||||
|
|
||||||
export default Grid;
|
export default Grid;
|
||||||
export { Grid };
|
export { Grid };
|
||||||
|
export type { GridDirection } from './Grid';
|
||||||
|
@ -5,3 +5,4 @@ const NoticeBar = withInstall<typeof _NoticeBar>(_NoticeBar);
|
|||||||
|
|
||||||
export default NoticeBar;
|
export default NoticeBar;
|
||||||
export { NoticeBar };
|
export { NoticeBar };
|
||||||
|
export type { NoticeBarMode } from './NoticeBar';
|
||||||
|
@ -5,3 +5,10 @@ const Picker = withInstall<typeof _Picker>(_Picker);
|
|||||||
|
|
||||||
export default Picker;
|
export default Picker;
|
||||||
export { Picker };
|
export { Picker };
|
||||||
|
export type {
|
||||||
|
PickerColumn,
|
||||||
|
PickerOption,
|
||||||
|
PickerObjectColumn,
|
||||||
|
PickerObjectOption,
|
||||||
|
PickerToolbarPosition,
|
||||||
|
} from './Picker';
|
||||||
|
@ -5,3 +5,9 @@ const Popover = withInstall<typeof _Popover>(_Popover);
|
|||||||
|
|
||||||
export default Popover;
|
export default Popover;
|
||||||
export { Popover };
|
export { Popover };
|
||||||
|
export type {
|
||||||
|
PopoverTheme,
|
||||||
|
PopoverAction,
|
||||||
|
PopoverTrigger,
|
||||||
|
PopoverPlacement,
|
||||||
|
} from './Popover';
|
||||||
|
@ -5,3 +5,4 @@ const Row = withInstall<typeof _Row>(_Row);
|
|||||||
|
|
||||||
export default Row;
|
export default Row;
|
||||||
export { Row };
|
export { Row };
|
||||||
|
export type { RowAlign, RowJustify } from './Row';
|
||||||
|
@ -5,3 +5,4 @@ const Search = withInstall<typeof _Search>(_Search);
|
|||||||
|
|
||||||
export default Search;
|
export default Search;
|
||||||
export { Search };
|
export { Search };
|
||||||
|
export type { SearchShape } from './Search';
|
||||||
|
@ -5,3 +5,4 @@ const Sticky = withInstall<typeof _Sticky>(_Sticky);
|
|||||||
|
|
||||||
export default Sticky;
|
export default Sticky;
|
||||||
export { Sticky };
|
export { Sticky };
|
||||||
|
export type { StickyPosition } from './Sticky';
|
||||||
|
@ -50,7 +50,7 @@ const [name, bem] = createNamespace('tabs');
|
|||||||
|
|
||||||
export const TABS_KEY = Symbol(name);
|
export const TABS_KEY = Symbol(name);
|
||||||
|
|
||||||
export type TabType = 'line' | 'card';
|
export type TabsType = 'line' | 'card';
|
||||||
|
|
||||||
export type TabsProvide = {
|
export type TabsProvide = {
|
||||||
props: {
|
props: {
|
||||||
@ -82,7 +82,7 @@ export default defineComponent({
|
|||||||
titleActiveColor: String,
|
titleActiveColor: String,
|
||||||
titleInactiveColor: String,
|
titleInactiveColor: String,
|
||||||
type: {
|
type: {
|
||||||
type: String as PropType<TabType>,
|
type: String as PropType<TabsType>,
|
||||||
default: 'line',
|
default: 'line',
|
||||||
},
|
},
|
||||||
active: {
|
active: {
|
||||||
|
@ -5,3 +5,4 @@ const Tabs = withInstall<typeof _Tabs>(_Tabs);
|
|||||||
|
|
||||||
export default Tabs;
|
export default Tabs;
|
||||||
export { Tabs };
|
export { Tabs };
|
||||||
|
export type { TabsType } from './Tabs';
|
||||||
|
@ -5,3 +5,4 @@ const TreeSelect = withInstall<typeof _TreeSelect>(_TreeSelect);
|
|||||||
|
|
||||||
export default TreeSelect;
|
export default TreeSelect;
|
||||||
export { TreeSelect };
|
export { TreeSelect };
|
||||||
|
export type { TreeSelectItem, TreeSelectChild } from './TreeSelect';
|
||||||
|
@ -9,9 +9,9 @@ import {
|
|||||||
isOversize,
|
isOversize,
|
||||||
filterFiles,
|
filterFiles,
|
||||||
isImageFile,
|
isImageFile,
|
||||||
FileListItem,
|
|
||||||
readFileContent,
|
readFileContent,
|
||||||
UploaderResultType,
|
UploaderResultType,
|
||||||
|
UploaderFileListItem,
|
||||||
} from './utils';
|
} from './utils';
|
||||||
|
|
||||||
// Composables
|
// Composables
|
||||||
@ -38,7 +38,7 @@ export type UploaderBeforeRead = (
|
|||||||
) => PromiseOrNot<File | File[] | undefined>;
|
) => PromiseOrNot<File | File[] | undefined>;
|
||||||
|
|
||||||
export type UploaderAfterRead = (
|
export type UploaderAfterRead = (
|
||||||
items: FileListItem | FileListItem[],
|
items: UploaderFileListItem | UploaderFileListItem[],
|
||||||
detail: {
|
detail: {
|
||||||
name: string | number;
|
name: string | number;
|
||||||
index: number;
|
index: number;
|
||||||
@ -68,7 +68,7 @@ export default defineComponent({
|
|||||||
default: 'image/*',
|
default: 'image/*',
|
||||||
},
|
},
|
||||||
modelValue: {
|
modelValue: {
|
||||||
type: Array as PropType<FileListItem[]>,
|
type: Array as PropType<UploaderFileListItem[]>,
|
||||||
default: () => [],
|
default: () => [],
|
||||||
},
|
},
|
||||||
maxSize: {
|
maxSize: {
|
||||||
@ -131,7 +131,9 @@ export default defineComponent({
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
const onAfterRead = (items: FileListItem | FileListItem[]) => {
|
const onAfterRead = (
|
||||||
|
items: UploaderFileListItem | UploaderFileListItem[]
|
||||||
|
) => {
|
||||||
resetInput();
|
resetInput();
|
||||||
|
|
||||||
if (isOversize(items, props.maxSize)) {
|
if (isOversize(items, props.maxSize)) {
|
||||||
@ -170,7 +172,11 @@ export default defineComponent({
|
|||||||
files.map((file) => readFileContent(file, resultType))
|
files.map((file) => readFileContent(file, resultType))
|
||||||
).then((contents) => {
|
).then((contents) => {
|
||||||
const fileList = (files as File[]).map((file, index) => {
|
const fileList = (files as File[]).map((file, index) => {
|
||||||
const result: FileListItem = { file, status: '', message: '' };
|
const result: UploaderFileListItem = {
|
||||||
|
file,
|
||||||
|
status: '',
|
||||||
|
message: '',
|
||||||
|
};
|
||||||
|
|
||||||
if (contents[index]) {
|
if (contents[index]) {
|
||||||
result.content = contents[index] as string;
|
result.content = contents[index] as string;
|
||||||
@ -183,7 +189,7 @@ export default defineComponent({
|
|||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
readFileContent(files, resultType).then((content) => {
|
readFileContent(files, resultType).then((content) => {
|
||||||
const result: FileListItem = {
|
const result: UploaderFileListItem = {
|
||||||
file: files as File,
|
file: files as File,
|
||||||
status: '',
|
status: '',
|
||||||
message: '',
|
message: '',
|
||||||
@ -237,7 +243,7 @@ export default defineComponent({
|
|||||||
|
|
||||||
const onClosePreview = () => emit('close-preview');
|
const onClosePreview = () => emit('close-preview');
|
||||||
|
|
||||||
const previewImage = (item: FileListItem) => {
|
const previewImage = (item: UploaderFileListItem) => {
|
||||||
if (props.previewFullImage) {
|
if (props.previewFullImage) {
|
||||||
const imageFiles = props.modelValue.filter(isImageFile);
|
const imageFiles = props.modelValue.filter(isImageFile);
|
||||||
const images = imageFiles
|
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);
|
const fileList = props.modelValue.slice(0);
|
||||||
fileList.splice(index, 1);
|
fileList.splice(index, 1);
|
||||||
|
|
||||||
@ -267,7 +273,7 @@ export default defineComponent({
|
|||||||
emit('delete', item, getDetail(index));
|
emit('delete', item, getDetail(index));
|
||||||
};
|
};
|
||||||
|
|
||||||
const renderPreviewItem = (item: FileListItem, index: number) => {
|
const renderPreviewItem = (item: UploaderFileListItem, index: number) => {
|
||||||
const needPickData = [
|
const needPickData = [
|
||||||
'imageFit',
|
'imageFit',
|
||||||
'deletable',
|
'deletable',
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { PropType, defineComponent } from 'vue';
|
import { PropType, defineComponent } from 'vue';
|
||||||
|
|
||||||
// Utils
|
// Utils
|
||||||
import { bem, isImageFile, FileListItem } from './utils';
|
import { bem, isImageFile, UploaderFileListItem } from './utils';
|
||||||
import { isDef, getSizeStyle } from '../utils';
|
import { isDef, getSizeStyle } from '../utils';
|
||||||
import { callInterceptor, Interceptor } from '../utils/interceptor';
|
import { callInterceptor, Interceptor } from '../utils/interceptor';
|
||||||
|
|
||||||
@ -20,7 +20,7 @@ export default defineComponent({
|
|||||||
previewSize: [Number, String],
|
previewSize: [Number, String],
|
||||||
beforeDelete: Function as PropType<Interceptor>,
|
beforeDelete: Function as PropType<Interceptor>,
|
||||||
item: {
|
item: {
|
||||||
type: Object as PropType<FileListItem>,
|
type: Object as PropType<UploaderFileListItem>,
|
||||||
required: true,
|
required: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -56,7 +56,7 @@
|
|||||||
<script lang="ts">
|
<script lang="ts">
|
||||||
import { reactive, toRefs } from 'vue';
|
import { reactive, toRefs } from 'vue';
|
||||||
import { useTranslate } from '@demo/use-translate';
|
import { useTranslate } from '@demo/use-translate';
|
||||||
import { FileListItem } from '../utils';
|
import { UploaderFileListItem } from '../utils';
|
||||||
import Toast from '../../toast';
|
import Toast from '../../toast';
|
||||||
|
|
||||||
const i18n = {
|
const i18n = {
|
||||||
@ -155,11 +155,11 @@ export default {
|
|||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
||||||
const afterRead = (file: FileListItem, detail: unknown) => {
|
const afterRead = (file: UploaderFileListItem, detail: unknown) => {
|
||||||
console.log(file, detail);
|
console.log(file, detail);
|
||||||
};
|
};
|
||||||
|
|
||||||
const afterReadFailed = (item: FileListItem) => {
|
const afterReadFailed = (item: UploaderFileListItem) => {
|
||||||
item.status = 'uploading';
|
item.status = 'uploading';
|
||||||
item.message = t('uploading');
|
item.message = t('uploading');
|
||||||
|
|
||||||
@ -169,7 +169,7 @@ export default {
|
|||||||
}, 1000);
|
}, 1000);
|
||||||
};
|
};
|
||||||
|
|
||||||
const onOversize = (file: FileListItem, detail: unknown) => {
|
const onOversize = (file: UploaderFileListItem, detail: unknown) => {
|
||||||
console.log(file, detail);
|
console.log(file, detail);
|
||||||
Toast(t('overSizeTip'));
|
Toast(t('overSizeTip'));
|
||||||
};
|
};
|
||||||
|
@ -5,3 +5,4 @@ const Uploader = withInstall<typeof _Uploader>(_Uploader);
|
|||||||
|
|
||||||
export default Uploader;
|
export default Uploader;
|
||||||
export { Uploader };
|
export { Uploader };
|
||||||
|
export type { UploaderResultType, UploaderFileListItem } from './utils';
|
||||||
|
@ -8,7 +8,7 @@ export { name, bem };
|
|||||||
|
|
||||||
export type UploaderResultType = 'dataUrl' | 'text' | 'file';
|
export type UploaderResultType = 'dataUrl' | 'text' | 'file';
|
||||||
|
|
||||||
export type FileListItem = {
|
export type UploaderFileListItem = {
|
||||||
url?: string;
|
url?: string;
|
||||||
file?: File;
|
file?: File;
|
||||||
content?: string;
|
content?: string;
|
||||||
@ -51,15 +51,18 @@ export function readFileContent(file: File, resultType: UploaderResultType) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function isOversize(
|
export function isOversize(
|
||||||
items: FileListItem | FileListItem[],
|
items: UploaderFileListItem | UploaderFileListItem[],
|
||||||
maxSize: number | string
|
maxSize: number | string
|
||||||
): boolean {
|
): boolean {
|
||||||
return toArray(items).some((item) => item.file && item.file.size > maxSize);
|
return toArray(items).some((item) => item.file && item.file.size > maxSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function filterFiles(items: FileListItem[], maxSize: number | string) {
|
export function filterFiles(
|
||||||
const valid: FileListItem[] = [];
|
items: UploaderFileListItem[],
|
||||||
const invalid: FileListItem[] = [];
|
maxSize: number | string
|
||||||
|
) {
|
||||||
|
const valid: UploaderFileListItem[] = [];
|
||||||
|
const invalid: UploaderFileListItem[] = [];
|
||||||
|
|
||||||
items.forEach((item) => {
|
items.forEach((item) => {
|
||||||
if (item.file && item.file.size > maxSize) {
|
if (item.file && item.file.size > maxSize) {
|
||||||
@ -78,7 +81,7 @@ export function isImageUrl(url: string): boolean {
|
|||||||
return IMAGE_REGEXP.test(url);
|
return IMAGE_REGEXP.test(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function isImageFile(item: FileListItem): boolean {
|
export function isImageFile(item: UploaderFileListItem): boolean {
|
||||||
// some special urls cannot be recognized
|
// some special urls cannot be recognized
|
||||||
// user can add `isImage` flag to mark it as an image url
|
// user can add `isImage` flag to mark it as an image url
|
||||||
if (item.isImage) {
|
if (item.isImage) {
|
||||||
|
@ -2,6 +2,10 @@ import { createBEM } from './bem';
|
|||||||
import { createTranslate } from './translate';
|
import { createTranslate } from './translate';
|
||||||
|
|
||||||
export function createNamespace(name: string) {
|
export function createNamespace(name: string) {
|
||||||
name = 'van-' + name;
|
const prefixedName = `van-${name}`;
|
||||||
return [name, createBEM(name), createTranslate(name)] as const;
|
return [
|
||||||
|
prefixedName,
|
||||||
|
createBEM(prefixedName),
|
||||||
|
createTranslate(prefixedName),
|
||||||
|
] as const;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user