From 56b210156eda9df0e9fe853043adcb2be39345aa Mon Sep 17 00:00:00 2001 From: neverland Date: Sat, 18 Dec 2021 11:08:27 +0800 Subject: [PATCH] types(Popup): add PopupInstance prop (#10062) * types(Popup): add PopupInstance prop * docs: update --- packages/vant/src/popup/Popup.tsx | 9 ++------- packages/vant/src/popup/README.md | 7 ++++++- packages/vant/src/popup/README.zh-CN.md | 7 ++++++- packages/vant/src/popup/index.ts | 5 +++-- packages/vant/src/popup/types.ts | 12 ++++++++++++ 5 files changed, 29 insertions(+), 11 deletions(-) create mode 100644 packages/vant/src/popup/types.ts diff --git a/packages/vant/src/popup/Popup.tsx b/packages/vant/src/popup/Popup.tsx index 5a0881e56..3c47671fd 100644 --- a/packages/vant/src/popup/Popup.tsx +++ b/packages/vant/src/popup/Popup.tsx @@ -35,13 +35,8 @@ import { POPUP_TOGGLE_KEY } from '../composables/on-popup-reopen'; import { Icon } from '../icon'; import { Overlay } from '../overlay'; -export type PopupPosition = 'top' | 'left' | 'bottom' | 'right' | 'center' | ''; - -export type PopupCloseIconPosition = - | 'top-left' - | 'top-right' - | 'bottom-left' - | 'bottom-right'; +// Types +import type { PopupPosition, PopupCloseIconPosition } from './types'; const popupProps = extend({}, popupSharedProps, { round: Boolean, diff --git a/packages/vant/src/popup/README.md b/packages/vant/src/popup/README.md index 361a4e6c8..d8bf110a0 100644 --- a/packages/vant/src/popup/README.md +++ b/packages/vant/src/popup/README.md @@ -151,7 +151,12 @@ Use `teleport` prop to specify mount location. The component exports the following type definitions: ```ts -import type { PopupProps, PopupPosition, PopupCloseIconPosition } from 'vant'; +import type { + PopupProps, + PopupPosition, + PopupInstance, + PopupCloseIconPosition, +} from 'vant'; ``` ## Theming diff --git a/packages/vant/src/popup/README.zh-CN.md b/packages/vant/src/popup/README.zh-CN.md index 37a3cbba3..3967ea023 100644 --- a/packages/vant/src/popup/README.zh-CN.md +++ b/packages/vant/src/popup/README.zh-CN.md @@ -157,7 +157,12 @@ export default { 组件导出以下类型定义: ```ts -import type { PopupProps, PopupPosition, PopupCloseIconPosition } from 'vant'; +import type { + PopupProps, + PopupPosition, + PopupInstance, + PopupCloseIconPosition, +} from 'vant'; ``` ## 主题定制 diff --git a/packages/vant/src/popup/index.ts b/packages/vant/src/popup/index.ts index 2c8fe56f9..b09f75098 100644 --- a/packages/vant/src/popup/index.ts +++ b/packages/vant/src/popup/index.ts @@ -3,8 +3,9 @@ import _Popup from './Popup'; export const Popup = withInstall(_Popup); export default Popup; +export type { PopupProps } from './Popup'; export type { - PopupProps, PopupPosition, + PopupInstance, PopupCloseIconPosition, -} from './Popup'; +} from './types'; diff --git a/packages/vant/src/popup/types.ts b/packages/vant/src/popup/types.ts new file mode 100644 index 000000000..d11cb1470 --- /dev/null +++ b/packages/vant/src/popup/types.ts @@ -0,0 +1,12 @@ +import type { ComponentPublicInstance } from 'vue'; +import type { PopupProps } from './Popup'; + +export type PopupPosition = 'top' | 'left' | 'bottom' | 'right' | 'center' | ''; + +export type PopupCloseIconPosition = + | 'top-left' + | 'top-right' + | 'bottom-left' + | 'bottom-right'; + +export type PopupInstance = ComponentPublicInstance;