UNPKG

4.09 kBTypeScriptView Raw
1import { RenderFunction, SetupContext, ComponentPublicInstance, Ref } from 'vue'
2import { VXEComponent, VxeComponentBase, SizeType, VNodeStyle, VxeEvent, ValueOf } from './component'
3
4/* eslint-disable no-use-before-define */
5
6/**
7 * 组件 - 下拉容器
8 * @example import { Pulldown as VxePulldown } from 'vxe-table'
9 */
10export const VxePulldown: VXEComponent<VxePulldownProps, VxePulldownEventProps, VxePulldownSlots>
11/**
12 * 组件 - 下拉容器
13 */
14export const Pulldown: typeof VxePulldown
15
16export type VxePulldownEmits = [
17 'update:modelValue',
18 'hide-panel'
19]
20
21export namespace VxePulldownPropTypes {
22 export type ModelValue = boolean
23 export type Size = SizeType
24 export type Disabled = boolean
25 export type Placement = string
26 export type ClassName = string | ((params: { $pulldown: VxePulldownConstructor }) => string)
27 export type PopupClassName = string | ((params: { $pulldown: VxePulldownConstructor }) => string)
28 export type DestroyOnClose = boolean
29 export type Transfer = boolean
30}
31
32export interface PulldownPrivateRef {
33 refElem: Ref<HTMLDivElement>
34}
35export type VxePulldownPrivateRef = PulldownPrivateRef
36
37export interface PulldownReactData {
38 inited: boolean
39 panelIndex: number
40 panelStyle: VNodeStyle | null
41 panelPlacement: string | null
42 visiblePanel: boolean
43 animatVisible: boolean
44 isActivated: boolean
45}
46
47export interface PulldownPrivateMethods {}
48export type VxePulldownPrivateMethods = PulldownPrivateMethods
49
50export type VxePulldownProps = {
51 size?: VxePulldownPropTypes.Size
52 modelValue?: VxePulldownPropTypes.ModelValue
53 /**
54 * 是否禁用
55 */
56 disabled?: VxePulldownPropTypes.Disabled
57 className?: VxePulldownPropTypes.ClassName
58 popupClassName?: VxePulldownPropTypes.PopupClassName
59 /**
60 * 固定显示下拉面板的方向
61 */
62 placement?: VxePulldownPropTypes.Placement
63 /**
64 * 在下拉容器关闭时销毁内容
65 */
66 destroyOnClose?: VxePulldownPropTypes.DestroyOnClose
67 /**
68 * 是否将弹框容器插入于 body 内(对于嵌入到表格或者弹窗中被遮挡时需要设置为 true
69 */
70 transfer?: VxePulldownPropTypes.Transfer
71}
72
73export interface PulldownMethods {
74 dispatchEvent(type: ValueOf<VxePulldownEmits>, params: any, evnt: Event): void
75 /**
76 * 判断下拉面板是否可视
77 */
78 isPanelVisible(): boolean
79
80 /**
81 * 切换下拉面板
82 */
83 togglePanel(): Promise<void>
84
85 /**
86 * 显示下拉面板
87 */
88 showPanel(): Promise<void>
89
90 /**
91 * 隐藏下拉面板
92 */
93 hidePanel(): Promise<void>
94}
95export type VxePulldownMethods = PulldownMethods
96
97export interface VxePulldownConstructor extends VxeComponentBase, VxePulldownMethods {
98 props: VxePulldownProps
99 context: SetupContext<VxePulldownEmits>
100 reactData: PulldownReactData
101 getRefMaps(): PulldownPrivateRef
102 renderVN: RenderFunction
103}
104
105export type VxePulldownInstance = ComponentPublicInstance<VxePulldownProps, VxePulldownConstructor>
106
107export namespace VxePulldownDefines {
108 export interface PulldownEventParams extends VxeEvent {
109 $pulldown: VxePulldownConstructor
110 }
111
112 export interface HidePanelParams { }
113 export type HidePanelEventParams = HidePanelParams
114}
115
116export namespace VxePulldownEvents {
117 export type HidePanel = (params: VxePulldownDefines.HidePanelEventParams) => void
118}
119
120export type VxePulldownEventProps = {
121 onHidePanel?: VxePulldownEvents.HidePanel
122}
123
124export interface VxePulldownListeners {
125 hidePanel?: VxePulldownEvents.HidePanel
126}
127
128export interface VxePulldownSlots {
129 /**
130 * 自定义弹窗容器头部模板
131 */
132 header: (params: {
133 [key: string]: any
134 }) => any
135 /**
136 * 自定义显示的内容
137 */
138 default: (params: {
139 [key: string]: any
140 }) => any
141 /**
142 * 自定义弹窗容器底部模板
143 */
144 footer: ((params: {
145 [key: string]: any
146 }) => any) | undefined
147 /**
148 * 自定义下拉面板显示的内容
149 */
150 dropdown: (params: {
151 [key: string]: any
152 }) => any
153}