Compare commits

..

No commits in common. "4f393c93a8d1a3ab983709fa52088fde13195175" and "4cf5a6ba0def1162de1ff9eb871d1e945d5a090c" have entirely different histories.

98 changed files with 325 additions and 154 deletions

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ActionBarButton from './ActionBarButton'; import _ActionBarButton from './ActionBarButton';
export const ActionBarButton = withInstall(_ActionBarButton); const ActionBarButton = withInstall<typeof _ActionBarButton>(_ActionBarButton);
export default ActionBarButton; export default ActionBarButton;
export { ActionBarButton };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ActionBarIcon from './ActionBarIcon'; import _ActionBarIcon from './ActionBarIcon';
export const ActionBarIcon = withInstall(_ActionBarIcon); const ActionBarIcon = withInstall<typeof _ActionBarIcon>(_ActionBarIcon);
export default ActionBarIcon; export default ActionBarIcon;
export { ActionBarIcon };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ActionBar from './ActionBar'; import _ActionBar from './ActionBar';
export const ActionBar = withInstall(_ActionBar); const ActionBar = withInstall<typeof _ActionBar>(_ActionBar);
export default ActionBar; export default ActionBar;
export { ActionBar };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ActionSheet from './ActionSheet'; import _ActionSheet from './ActionSheet';
export const ActionSheet = withInstall(_ActionSheet); const ActionSheet = withInstall<typeof _ActionSheet>(_ActionSheet);
export default ActionSheet; export default ActionSheet;
export { ActionSheet };
export type { ActionSheetAction } from './ActionSheet'; export type { ActionSheetAction } from './ActionSheet';

View File

@ -41,7 +41,9 @@ export default defineComponent({
emit('input', `${express.address || ''} ${express.name || ''}`.trim()); emit('input', `${express.address || ''} ${express.name || ''}`.trim());
}; };
const onFinish = () => field.value?.blur(); const onFinish = () => {
field.value!.blur();
};
const renderFinish = () => { const renderFinish = () => {
if (props.value && props.focused && android) { if (props.value && props.focused && android) {

View File

@ -1,8 +1,10 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _AddressEdit from './AddressEdit'; import _AddressEdit from './AddressEdit';
export const AddressEdit = withInstall(_AddressEdit); const AddressEdit = withInstall<typeof _AddressEdit>(_AddressEdit);
export default AddressEdit; export default AddressEdit;
export { AddressEdit };
export type { export type {
AddressEditInfo, AddressEditInfo,
AddressEditInstance, AddressEditInstance,

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _AddressList from './AddressList'; import _AddressList from './AddressList';
export const AddressList = withInstall(_AddressList); const AddressList = withInstall<typeof _AddressList>(_AddressList);
export default AddressList; export default AddressList;
export { AddressList };
export type { AddressListAddress } from './AddressListItem'; export type { AddressListAddress } from './AddressListItem';

View File

@ -285,10 +285,8 @@ export default defineComponent({
state.code = values[index].code; state.code = values[index].code;
setValues(); setValues();
if (pickerRef.value) { const parsedValues = parseValues(pickerRef.value!.getValues());
const parsedValues = parseValues(pickerRef.value.getValues()); emit('change', parsedValues, index);
emit('change', parsedValues, index);
}
}; };
const onConfirm = (values: AreaColumnOption[], index: number) => { const onConfirm = (values: AreaColumnOption[], index: number) => {

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Area from './Area'; import _Area from './Area';
export const Area = withInstall(_Area); const Area = withInstall<typeof _Area>(_Area);
export default Area; export default Area;
export { Area };
export type { AreaList, AreaInstance, AreaColumnOption } from './types'; export type { AreaList, AreaInstance, AreaColumnOption } from './types';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Badge from './Badge'; import _Badge from './Badge';
export const Badge = withInstall(_Badge); const Badge = withInstall<typeof _Badge>(_Badge);
export default Badge; export default Badge;
export { Badge };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Button from './Button'; import _Button from './Button';
export const Button = withInstall(_Button); const Button = withInstall<typeof _Button>(_Button);
export default Button; export default Button;
export { Button };
export type { ButtonType, ButtonSize } from './Button'; export type { ButtonType, ButtonSize } from './Button';

View File

@ -94,14 +94,12 @@ export default defineComponent({
const scrollIntoView = (body: Element) => { const scrollIntoView = (body: Element) => {
const el = props.showSubtitle ? daysRef.value : monthRef.value; const el = props.showSubtitle ? daysRef.value : monthRef.value;
if (el) { const scrollTop =
const scrollTop = el!.getBoundingClientRect().top -
el.getBoundingClientRect().top - body.getBoundingClientRect().top +
body.getBoundingClientRect().top + body.scrollTop;
body.scrollTop;
setScrollTop(body, scrollTop); setScrollTop(body, scrollTop);
}
}; };
const getMultipleDayType = (day: Date) => { const getMultipleDayType = (day: Date) => {

View File

@ -1,8 +1,10 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Calendar from './Calendar'; import _Calendar from './Calendar';
export const Calendar = withInstall(_Calendar); const Calendar = withInstall<typeof _Calendar>(_Calendar);
export default Calendar; export default Calendar;
export { Calendar };
export type { export type {
CalendarType, CalendarType,
CalendarDayItem, CalendarDayItem,

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Card from './Card'; import _Card from './Card';
export const Card = withInstall(_Card); const Card = withInstall<typeof _Card>(_Card);
export default Card; export default Card;
export { Card };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Cascader from './Cascader'; import _Cascader from './Cascader';
export const Cascader = withInstall(_Cascader); const Cascader = withInstall<typeof _Cascader>(_Cascader);
export default Cascader; export default Cascader;
export { Cascader };
export type { CascaderOption, CascaderFieldNames } from './Cascader'; export type { CascaderOption, CascaderFieldNames } from './Cascader';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _CellGroup from './CellGroup'; import _CellGroup from './CellGroup';
export const CellGroup = withInstall(_CellGroup); const CellGroup = withInstall<typeof _CellGroup>(_CellGroup);
export default CellGroup; export default CellGroup;
export { CellGroup };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Cell from './Cell'; import _Cell from './Cell';
export const Cell = withInstall(_Cell); const Cell = withInstall<typeof _Cell>(_Cell);
export default Cell; export default Cell;
export { Cell };
export type { CellArrowDirection } from './Cell'; export type { CellArrowDirection } from './Cell';

View File

@ -1,8 +1,10 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _CheckboxGroup from './CheckboxGroup'; import _CheckboxGroup from './CheckboxGroup';
export const CheckboxGroup = withInstall(_CheckboxGroup); const CheckboxGroup = withInstall<typeof _CheckboxGroup>(_CheckboxGroup);
export default CheckboxGroup; export default CheckboxGroup;
export { CheckboxGroup };
export type { export type {
CheckboxGroupInstance, CheckboxGroupInstance,
CheckboxGroupToggleAllOptions, CheckboxGroupToggleAllOptions,

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Checkbox from './Checkbox'; import _Checkbox from './Checkbox';
export const Checkbox = withInstall(_Checkbox); const Checkbox = withInstall<typeof _Checkbox>(_Checkbox);
export default Checkbox; export default Checkbox;
export { Checkbox };
export type { CheckboxInstance } from './types'; export type { CheckboxInstance } from './types';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Circle from './Circle'; import _Circle from './Circle';
export const Circle = withInstall(_Circle); const Circle = withInstall<typeof _Circle>(_Circle);
export default Circle; export default Circle;
export { Circle };
export type { CircleStartPosition } from './Circle'; export type { CircleStartPosition } from './Circle';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Col from './Col'; import _Col from './Col';
export const Col = withInstall(_Col); const Col = withInstall<typeof _Col>(_Col);
export default Col; export default Col;
export { Col };

View File

@ -61,8 +61,8 @@ export default defineComponent({
const onTransitionEnd = () => { const onTransitionEnd = () => {
if (!expanded.value) { if (!expanded.value) {
show.value = false; show.value = false;
} else if (wrapperRef.value) { } else {
wrapperRef.value.style.height = ''; wrapperRef.value!.style.height = '';
} }
}; };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _CollapseItem from './CollapseItem'; import _CollapseItem from './CollapseItem';
export const CollapseItem = withInstall(_CollapseItem); const CollapseItem = withInstall<typeof _CollapseItem>(_CollapseItem);
export default CollapseItem; export default CollapseItem;
export { CollapseItem };
export type { CollapseItemInstance } from './types'; export type { CollapseItemInstance } from './types';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Collapse from './Collapse'; import _Collapse from './Collapse';
export const Collapse = withInstall(_Collapse); const Collapse = withInstall<typeof _Collapse>(_Collapse);
export default Collapse; export default Collapse;
export { Collapse };

View File

@ -4,11 +4,11 @@ import { Ref, ref, onMounted, nextTick } from 'vue';
export const useHeight = (element: Element | Ref<Element | undefined>) => { export const useHeight = (element: Element | Ref<Element | undefined>) => {
const height = ref<number>(); const height = ref<number>();
onMounted(() => onMounted(() => {
nextTick(() => { nextTick(() => {
height.value = useRect(element).height; height.value = useRect(element).height;
}) });
); });
return height; return height;
}; };

View File

@ -71,9 +71,17 @@ export function useLockScroll(
} }
}; };
const init = () => shouldLock() && lock(); const init = () => {
if (shouldLock()) {
lock();
}
};
const destroy = () => shouldLock() && unlock(); const destroy = () => {
if (shouldLock()) {
unlock();
}
};
onMountedOrActivated(init); onMountedOrActivated(init);
onDeactivated(destroy); onDeactivated(destroy);

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ConfigProvider from './ConfigProvider'; import _ConfigProvider from './ConfigProvider';
export const ConfigProvider = withInstall(_ConfigProvider); const ConfigProvider = withInstall<typeof _ConfigProvider>(_ConfigProvider);
export default ConfigProvider; export default ConfigProvider;
export { ConfigProvider };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ContactCard from './ContactCard'; import _ContactCard from './ContactCard';
export const ContactCard = withInstall(_ContactCard); const ContactCard = withInstall<typeof _ContactCard>(_ContactCard);
export default ContactCard; export default ContactCard;
export { ContactCard };
export type { ContactCardType } from './ContactCard'; export type { ContactCardType } from './ContactCard';

View File

@ -54,10 +54,11 @@ export default defineComponent({
} }
}; };
const onDelete = () => const onDelete = () => {
Dialog.confirm({ Dialog.confirm({
title: t('confirmDelete'), title: t('confirmDelete'),
}).then(() => emit('delete', contact)); }).then(() => emit('delete', contact));
};
const renderButtons = () => ( const renderButtons = () => (
<div class={bem('buttons')}> <div class={bem('buttons')}>

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ContactEdit from './ContactEdit'; import _ContactEdit from './ContactEdit';
export const ContactEdit = withInstall(_ContactEdit); const ContactEdit = withInstall<typeof _ContactEdit>(_ContactEdit);
export default ContactEdit; export default ContactEdit;
export { ContactEdit };
export type { ContactEditInfo } from './ContactEdit'; export type { ContactEditInfo } from './ContactEdit';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ContactList from './ContactList'; import _ContactList from './ContactList';
export const ContactList = withInstall(_ContactList); const ContactList = withInstall<typeof _ContactList>(_ContactList);
export default ContactList; export default ContactList;
export { ContactList };
export type { ContactListItem } from './ContactList'; export type { ContactListItem } from './ContactList';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _CountDown from './CountDown'; import _CountDown from './CountDown';
export const CountDown = withInstall(_CountDown); const CountDown = withInstall<typeof _CountDown>(_CountDown);
export default CountDown; export default CountDown;
export { CountDown };
export type { CountDownInstance, CountDownCurrentTime } from './CountDown'; export type { CountDownInstance, CountDownCurrentTime } from './CountDown';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _CouponCell from './CouponCell'; import _CouponCell from './CouponCell';
export const CouponCell = withInstall(_CouponCell); const CouponCell = withInstall<typeof _CouponCell>(_CouponCell);
export default CouponCell; export default CouponCell;
export { CouponCell };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _CouponList from './CouponList'; import _CouponList from './CouponList';
export const CouponList = withInstall(_CouponList); const CouponList = withInstall<typeof _CouponList>(_CouponList);
export default CouponList; export default CouponList;
export { CouponList };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Coupon from './Coupon'; import _Coupon from './Coupon';
export const Coupon = withInstall(_Coupon); const Coupon = withInstall<typeof _Coupon>(_Coupon);
export default Coupon; export default Coupon;
export { Coupon };
export type { CouponInfo } from './Coupon'; export type { CouponInfo } from './Coupon';

View File

@ -222,7 +222,7 @@ export default defineComponent({
}); });
nextTick(() => { nextTick(() => {
picker.value?.setValues(values); picker.value!.setValues(values);
}); });
}; };

View File

@ -106,7 +106,7 @@ export default defineComponent({
]; ];
nextTick(() => { nextTick(() => {
picker.value?.setValues(values); picker.value!.setValues(values);
}); });
}; };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _DatetimePicker from './DatetimePicker'; import _DatetimePicker from './DatetimePicker';
export const DatetimePicker = withInstall(_DatetimePicker); const DatetimePicker = withInstall<typeof _DatetimePicker>(_DatetimePicker);
export default DatetimePicker; export default DatetimePicker;
export { DatetimePicker };
export type { DatetimePickerType, DatetimePickerInstance } from './types'; export type { DatetimePickerType, DatetimePickerInstance } from './types';

View File

@ -120,11 +120,11 @@ Dialog.resetDefaultOptions = () => {
Dialog.currentOptions = extend({}, Dialog.defaultOptions); Dialog.currentOptions = extend({}, Dialog.defaultOptions);
}; };
Dialog.Component = withInstall(VanDialog);
Dialog.install = (app: App) => { Dialog.install = (app: App) => {
app.use(Dialog.Component); app.use(withInstall<typeof VanDialog>(VanDialog));
app.config.globalProperties.$dialog = Dialog; app.config.globalProperties.$dialog = Dialog;
}; };
Dialog.Component = withInstall<typeof VanDialog>(VanDialog);
export { Dialog }; export { Dialog };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Divider from './Divider'; import _Divider from './Divider';
export const Divider = withInstall(_Divider); const Divider = withInstall<typeof _Divider>(_Divider);
export default Divider; export default Divider;
export { Divider };
export type { DividerContentPosition } from './Divider'; export type { DividerContentPosition } from './Divider';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _DropdownItem from './DropdownItem'; import _DropdownItem from './DropdownItem';
export const DropdownItem = withInstall(_DropdownItem); const DropdownItem = withInstall<typeof _DropdownItem>(_DropdownItem);
export default DropdownItem; export default DropdownItem;
export { DropdownItem };
export type { DropdownItemInstance, DropdownItemOption } from './types'; export type { DropdownItemInstance, DropdownItemOption } from './types';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _DropdownMenu from './DropdownMenu'; import _DropdownMenu from './DropdownMenu';
export const DropdownMenu = withInstall(_DropdownMenu); const DropdownMenu = withInstall<typeof _DropdownMenu>(_DropdownMenu);
export default DropdownMenu; export default DropdownMenu;
export { DropdownMenu };
export type { DropdownMenuDirection } from './types'; export type { DropdownMenuDirection } from './types';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Empty from './Empty'; import _Empty from './Empty';
export const Empty = withInstall(_Empty); const Empty = withInstall<typeof _Empty>(_Empty);
export default Empty; export default Empty;
export { Empty };

View File

@ -1,8 +1,10 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Field from './Field'; import _Field from './Field';
export const Field = withInstall(_Field); const Field = withInstall<typeof _Field>(_Field);
export default Field; export default Field;
export { Field };
export type { export type {
FieldType, FieldType,
FieldRule, FieldRule,

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Form from './Form'; import _Form from './Form';
export const Form = withInstall(_Form); const Form = withInstall<typeof _Form>(_Form);
export default Form; export default Form;
export { Form };
export type { FormInstance } from './types'; export type { FormInstance } from './types';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _GridItem from './GridItem'; import _GridItem from './GridItem';
export const GridItem = withInstall(_GridItem); const GridItem = withInstall<typeof _GridItem>(_GridItem);
export default GridItem; export default GridItem;
export { GridItem };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Grid from './Grid'; import _Grid from './Grid';
export const Grid = withInstall(_Grid); const Grid = withInstall<typeof _Grid>(_Grid);
export default Grid; export default Grid;
export { Grid };
export type { GridDirection } from './Grid'; export type { GridDirection } from './Grid';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Icon from './Icon'; import _Icon from './Icon';
export const Icon = withInstall(_Icon); const Icon = withInstall<typeof _Icon>(_Icon);
export default Icon; export default Icon;
export { Icon };

View File

@ -70,10 +70,10 @@ const ImagePreview = (
return instance; return instance;
}; };
ImagePreview.Component = withInstall(VanImagePreview); ImagePreview.Component = withInstall<typeof VanImagePreview>(VanImagePreview);
ImagePreview.install = (app: App) => { ImagePreview.install = (app: App) => {
app.use(ImagePreview.Component); app.use(withInstall<typeof VanImagePreview>(VanImagePreview));
}; };
export { ImagePreview }; export { ImagePreview };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Image from './Image'; import _Image from './Image';
export const Image = withInstall(_Image); const Image = withInstall<typeof _Image>(_Image);
export default Image; export default Image;
export { Image };
export type { ImageFit } from './Image'; export type { ImageFit } from './Image';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _IndexAnchor from './IndexAnchor'; import _IndexAnchor from './IndexAnchor';
export const IndexAnchor = withInstall(_IndexAnchor); const IndexAnchor = withInstall<typeof _IndexAnchor>(_IndexAnchor);
export default IndexAnchor; export default IndexAnchor;
export { IndexAnchor };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _IndexBar from './IndexBar'; import _IndexBar from './IndexBar';
export const IndexBar = withInstall(_IndexBar); const IndexBar = withInstall<typeof _IndexBar>(_IndexBar);
export default IndexBar; export default IndexBar;
export { IndexBar };
export type { IndexBarInstance } from './types'; export type { IndexBarInstance } from './types';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _List from './List'; import _List from './List';
export const List = withInstall(_List); const List = withInstall<typeof _List>(_List);
export default List; export default List;
export { List };
export type { ListInstance, ListDirection } from './types'; export type { ListInstance, ListDirection } from './types';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Loading from './Loading'; import _Loading from './Loading';
export const Loading = withInstall(_Loading); const Loading = withInstall<typeof _Loading>(_Loading);
export default Loading; export default Loading;
export { Loading };
export type { LoadingType } from './Loading'; export type { LoadingType } from './Loading';

View File

@ -10,7 +10,7 @@ const messages = reactive<Messages>({
'zh-CN': defaultMessages, 'zh-CN': defaultMessages,
}); });
export const Locale = { const Locale = {
messages(): Message { messages(): Message {
return messages[lang.value]; return messages[lang.value];
}, },
@ -26,3 +26,4 @@ export const Locale = {
}; };
export default Locale; export default Locale;
export { Locale };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _NavBar from './NavBar'; import _NavBar from './NavBar';
export const NavBar = withInstall(_NavBar); const NavBar = withInstall<typeof _NavBar>(_NavBar);
export default NavBar; export default NavBar;
export { NavBar };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _NoticeBar from './NoticeBar'; import _NoticeBar from './NoticeBar';
export const NoticeBar = withInstall(_NoticeBar); const NoticeBar = withInstall<typeof _NoticeBar>(_NoticeBar);
export default NoticeBar; export default NoticeBar;
export { NoticeBar };
export type { NoticeBarMode, NoticeBarInstance } from './types'; export type { NoticeBarMode, NoticeBarInstance } from './types';

View File

@ -23,21 +23,25 @@ export default defineComponent({
}), }),
setup(props, { slots }) { setup(props, { slots }) {
return () => ( return () => {
<Popup const style = {
show={props.show} color: props.color,
class={[bem([props.type]), props.className]} background: props.background,
style={{ };
color: props.color,
background: props.background, return (
}} <Popup
overlay={false} show={props.show}
position="top" class={[bem([props.type]), props.className]}
duration={0.2} style={style}
lockScroll={props.lockScroll} overlay={false}
> position="top"
{slots.default ? slots.default() : props.message} duration={0.2}
</Popup> lockScroll={props.lockScroll}
); >
{slots.default ? slots.default() : props.message}
</Popup>
);
};
}, },
}); });

View File

@ -92,11 +92,11 @@ Notify.resetDefaultOptions = () => {
Notify.currentOptions = defaultOptions(); Notify.currentOptions = defaultOptions();
}; };
Notify.Component = withInstall(VanNotify);
Notify.install = (app: App) => { Notify.install = (app: App) => {
app.use(Notify.Component); app.use(withInstall<typeof VanNotify>(VanNotify));
app.config.globalProperties.$notify = Notify; app.config.globalProperties.$notify = Notify;
}; };
Notify.Component = withInstall<typeof VanNotify>(VanNotify);
export { Notify }; export { Notify };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _NumberKeyboard from './NumberKeyboard'; import _NumberKeyboard from './NumberKeyboard';
export const NumberKeyboard = withInstall(_NumberKeyboard); const NumberKeyboard = withInstall<typeof _NumberKeyboard>(_NumberKeyboard);
export default NumberKeyboard; export default NumberKeyboard;
export { NumberKeyboard };
export type { NumberKeyboardTheme } from './NumberKeyboard'; export type { NumberKeyboardTheme } from './NumberKeyboard';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Overlay from './Overlay'; import _Overlay from './Overlay';
export const Overlay = withInstall(_Overlay); const Overlay = withInstall<typeof _Overlay>(_Overlay);
export default Overlay; export default Overlay;
export { Overlay };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Pagination from './Pagination'; import _Pagination from './Pagination';
export const Pagination = withInstall(_Pagination); const Pagination = withInstall<typeof _Pagination>(_Pagination);
export default Pagination; export default Pagination;
export { Pagination };
export type { PaginationMode } from './Pagination'; export type { PaginationMode } from './Pagination';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _PasswordInput from './PasswordInput'; import _PasswordInput from './PasswordInput';
export const PasswordInput = withInstall(_PasswordInput); const PasswordInput = withInstall<typeof _PasswordInput>(_PasswordInput);
export default PasswordInput; export default PasswordInput;
export { PasswordInput };

View File

@ -1,8 +1,10 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Picker from './Picker'; import _Picker from './Picker';
export const Picker = withInstall(_Picker); const Picker = withInstall<typeof _Picker>(_Picker);
export default Picker; export default Picker;
export { Picker };
export type { export type {
PickerColumn, PickerColumn,
PickerOption, PickerOption,

View File

@ -79,7 +79,7 @@ export default defineComponent({
closeOnClickOverlay: truthProp, closeOnClickOverlay: truthProp,
closeOnClickOutside: truthProp, closeOnClickOutside: truthProp,
offset: { offset: {
type: Array as unknown as PropType<[number, number]>, type: (Array as unknown) as PropType<[number, number]>,
default: () => [0, 8], default: () => [0, 8],
}, },
theme: { theme: {
@ -112,28 +112,24 @@ export default defineComponent({
const wrapperRef = ref<HTMLElement>(); const wrapperRef = ref<HTMLElement>();
const popoverRef = ref<ComponentInstance>(); const popoverRef = ref<ComponentInstance>();
const createPopperInstance = () => { const createPopperInstance = () =>
if (wrapperRef.value && popoverRef.value) { createPopper(wrapperRef.value!, popoverRef.value!.popupRef.value, {
return createPopper(wrapperRef.value, popoverRef.value.popupRef.value, { placement: props.placement,
placement: props.placement, modifiers: [
modifiers: [ {
{ name: 'computeStyles',
name: 'computeStyles', options: {
options: { adaptive: false,
adaptive: false, gpuAcceleration: false,
gpuAcceleration: false,
},
}, },
extend({}, offsetModifier, { },
options: { extend({}, offsetModifier, {
offset: props.offset, options: {
}, offset: props.offset,
}), },
], }),
}); ],
} });
return null;
};
const updateLocation = () => { const updateLocation = () => {
nextTick(() => { nextTick(() => {

View File

@ -1,8 +1,10 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Popover from './Popover'; import _Popover from './Popover';
export const Popover = withInstall(_Popover); const Popover = withInstall<typeof _Popover>(_Popover);
export default Popover; export default Popover;
export { Popover };
export type { export type {
PopoverTheme, PopoverTheme,
PopoverAction, PopoverAction,

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Popup from './Popup'; import _Popup from './Popup';
export const Popup = withInstall(_Popup); const Popup = withInstall<typeof _Popup>(_Popup);
export default Popup; export default Popup;
export { Popup };
export type { PopupPosition, PopupCloseIconPosition } from './Popup'; export type { PopupPosition, PopupCloseIconPosition } from './Popup';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Progress from './Progress'; import _Progress from './Progress';
export const Progress = withInstall(_Progress); const Progress = withInstall<typeof _Progress>(_Progress);
export default Progress; export default Progress;
export { Progress };
export type { ProgressInstance } from './types'; export type { ProgressInstance } from './types';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _PullRefresh from './PullRefresh'; import _PullRefresh from './PullRefresh';
export const PullRefresh = withInstall(_PullRefresh); const PullRefresh = withInstall<typeof _PullRefresh>(_PullRefresh);
export default PullRefresh; export default PullRefresh;
export { PullRefresh };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _RadioGroup from './RadioGroup'; import _RadioGroup from './RadioGroup';
export const RadioGroup = withInstall(_RadioGroup); const RadioGroup = withInstall<typeof _RadioGroup>(_RadioGroup);
export default RadioGroup; export default RadioGroup;
export { RadioGroup };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Radio from './Radio'; import _Radio from './Radio';
export const Radio = withInstall(_Radio); const Radio = withInstall<typeof _Radio>(_Radio);
export default Radio; export default Radio;
export { Radio };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Rate from './Rate'; import _Rate from './Rate';
export const Rate = withInstall(_Rate); const Rate = withInstall<typeof _Rate>(_Rate);
export default Rate; export default Rate;
export { Rate };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Row from './Row'; import _Row from './Row';
export const Row = withInstall(_Row); const Row = withInstall<typeof _Row>(_Row);
export default Row; export default Row;
export { Row };
export type { RowAlign, RowJustify } from './Row'; export type { RowAlign, RowJustify } from './Row';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Search from './Search'; import _Search from './Search';
export const Search = withInstall(_Search); const Search = withInstall<typeof _Search>(_Search);
export default Search; export default Search;
export { Search };
export type { SearchShape, SearchInstance } from './types'; export type { SearchShape, SearchInstance } from './types';

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _ShareSheet from './ShareSheet'; import _ShareSheet from './ShareSheet';
export const ShareSheet = withInstall(_ShareSheet); const ShareSheet = withInstall<typeof _ShareSheet>(_ShareSheet);
export default ShareSheet; export default ShareSheet;
export { ShareSheet };
export type { ShareSheetOption, ShareSheetOptions } from './ShareSheet'; export type { ShareSheetOption, ShareSheetOptions } from './ShareSheet';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _SidebarItem from './SidebarItem'; import _SidebarItem from './SidebarItem';
export const SidebarItem = withInstall(_SidebarItem); const SidebarItem = withInstall<typeof _SidebarItem>(_SidebarItem);
export default SidebarItem; export default SidebarItem;
export { SidebarItem };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Sidebar from './Sidebar'; import _Sidebar from './Sidebar';
export const Sidebar = withInstall(_Sidebar); const Sidebar = withInstall<typeof _Sidebar>(_Sidebar);
export default Sidebar; export default Sidebar;
export { Sidebar };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Skeleton from './Skeleton'; import _Skeleton from './Skeleton';
export const Skeleton = withInstall(_Skeleton); const Skeleton = withInstall<typeof _Skeleton>(_Skeleton);
export default Skeleton; export default Skeleton;
export { Skeleton };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Slider from './Slider'; import _Slider from './Slider';
export const Slider = withInstall(_Slider); const Slider = withInstall<typeof _Slider>(_Slider);
export default Slider; export default Slider;
export { Slider };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Step from './Step'; import _Step from './Step';
export const Step = withInstall(_Step); const Step = withInstall<typeof _Step>(_Step);
export default Step; export default Step;
export { Step };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Stepper, { StepperTheme } from './Stepper'; import _Stepper, { StepperTheme } from './Stepper';
export const Stepper = withInstall(_Stepper); const Stepper = withInstall<typeof _Stepper>(_Stepper);
export default Stepper; export default Stepper;
export { Stepper };
export type { StepperTheme }; export type { StepperTheme };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Steps from './Steps'; import _Steps from './Steps';
export const Steps = withInstall(_Steps); const Steps = withInstall<typeof _Steps>(_Steps);
export default Steps; export default Steps;
export { Steps };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Sticky from './Sticky'; import _Sticky from './Sticky';
export const Sticky = withInstall(_Sticky); const Sticky = withInstall<typeof _Sticky>(_Sticky);
export default Sticky; export default Sticky;
export { Sticky };
export type { StickyPosition } from './Sticky'; export type { StickyPosition } from './Sticky';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _SubmitBar from './SubmitBar'; import _SubmitBar from './SubmitBar';
export const SubmitBar = withInstall(_SubmitBar); const SubmitBar = withInstall<typeof _SubmitBar>(_SubmitBar);
export default SubmitBar; export default SubmitBar;
export { SubmitBar };

View File

@ -1,8 +1,10 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _SwipeCell from './SwipeCell'; import _SwipeCell from './SwipeCell';
export const SwipeCell = withInstall(_SwipeCell); const SwipeCell = withInstall<typeof _SwipeCell>(_SwipeCell);
export default SwipeCell; export default SwipeCell;
export { SwipeCell };
export type { export type {
SwipeCellSide, SwipeCellSide,
SwipeCellPosition, SwipeCellPosition,

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _SwipeItem from './SwipeItem'; import _SwipeItem from './SwipeItem';
export const SwipeItem = withInstall(_SwipeItem); const SwipeItem = withInstall<typeof _SwipeItem>(_SwipeItem);
export default SwipeItem; export default SwipeItem;
export { SwipeItem };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Swipe from './Swipe'; import _Swipe from './Swipe';
export const Swipe = withInstall(_Swipe); const Swipe = withInstall<typeof _Swipe>(_Swipe);
export default Swipe; export default Swipe;
export { Swipe };
export type { SwipeInstance, SwipeToOptions } from './types'; export type { SwipeInstance, SwipeToOptions } from './types';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Switch from './Switch'; import _Switch from './Switch';
export const Switch = withInstall(_Switch); const Switch = withInstall<typeof _Switch>(_Switch);
export default Switch; export default Switch;
export { Switch };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Tab from './Tab'; import _Tab from './Tab';
export const Tab = withInstall(_Tab); const Tab = withInstall<typeof _Tab>(_Tab);
export default Tab; export default Tab;
export { Tab };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _TabbarItem from './TabbarItem'; import _TabbarItem from './TabbarItem';
export const TabbarItem = withInstall(_TabbarItem); const TabbarItem = withInstall<typeof _TabbarItem>(_TabbarItem);
export default TabbarItem; export default TabbarItem;
export { TabbarItem };

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Tabbar from './Tabbar'; import _Tabbar from './Tabbar';
export const Tabbar = withInstall(_Tabbar); const Tabbar = withInstall<typeof _Tabbar>(_Tabbar);
export default Tabbar; export default Tabbar;
export { Tabbar };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Tabs from './Tabs'; import _Tabs from './Tabs';
export const Tabs = withInstall(_Tabs); const Tabs = withInstall<typeof _Tabs>(_Tabs);
export default Tabs; export default Tabs;
export { Tabs };
export type { TabsType, TabsInstance } from './types'; export type { TabsType, TabsInstance } from './types';

View File

@ -1,5 +1,7 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Tag from './Tag'; import _Tag from './Tag';
export const Tag = withInstall(_Tag); const Tag = withInstall<typeof _Tag>(_Tag);
export default Tag; export default Tag;
export { Tag };

View File

@ -78,7 +78,9 @@ export default defineComponent({
} }
}; };
const clearTimer = () => clearTimeout(timer); const clearTimer = () => {
clearTimeout(timer);
};
const renderIcon = () => { const renderIcon = () => {
const { icon, type, iconSize, iconPrefix, loadingType } = props; const { icon, type, iconSize, iconPrefix, loadingType } = props;

View File

@ -155,7 +155,7 @@ Toast.clear = (all?: boolean) => {
} else if (!allowMultiple) { } else if (!allowMultiple) {
queue[0].clear(); queue[0].clear();
} else { } else {
queue.shift()?.clear(); queue.shift()!.clear();
} }
} }
}; };
@ -186,7 +186,7 @@ Toast.allowMultiple = (value = true) => {
}; };
Toast.install = (app: App) => { Toast.install = (app: App) => {
app.use(withInstall(VanToast)); app.use(withInstall<typeof VanToast>(VanToast));
app.config.globalProperties.$toast = Toast; app.config.globalProperties.$toast = Toast;
}; };

View File

@ -1,6 +1,8 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _TreeSelect from './TreeSelect'; import _TreeSelect from './TreeSelect';
export const TreeSelect = withInstall(_TreeSelect); const TreeSelect = withInstall<typeof _TreeSelect>(_TreeSelect);
export default TreeSelect; export default TreeSelect;
export { TreeSelect };
export type { TreeSelectItem, TreeSelectChild } from './TreeSelect'; export type { TreeSelectItem, TreeSelectChild } from './TreeSelect';

View File

@ -1,8 +1,10 @@
import { withInstall } from '../utils'; import { withInstall } from '../utils';
import _Uploader from './Uploader'; import _Uploader from './Uploader';
export const Uploader = withInstall(_Uploader); const Uploader = withInstall<typeof _Uploader>(_Uploader);
export default Uploader; export default Uploader;
export { Uploader };
export type { export type {
UploaderInstance, UploaderInstance,
UploaderResultType, UploaderResultType,

View File

@ -14,12 +14,13 @@ export type WithInstall<T> = T & {
install(app: App): void; install(app: App): void;
} & EventShim; } & EventShim;
export function withInstall<T>(options: T) { // using any here because tsc will generate some weird results when using generics
export function withInstall<T>(options: any): WithInstall<T> {
(options as Record<string, unknown>).install = (app: App) => { (options as Record<string, unknown>).install = (app: App) => {
const { name } = options as any; const { name } = options as any;
app.component(name, options); app.component(name, options);
app.component(camelize(`-${name}`), options); app.component(camelize(`-${name}`), options);
}; };
return options as WithInstall<T>; return options;
} }