UNPKG

6.6 kBTypeScriptView Raw
1import { RenderFunction, SetupContext, Ref, ComponentPublicInstance } from 'vue'
2import { VXEComponent, VxeComponentBase, VxeEvent, SizeType, ValueOf } from './component'
3import { VxeGlobalRendererHandles } from './v-x-e-table'
4import { VxeTableDefines, VxeTableConstructor, VxeTablePrivateMethods } from './table'
5import { VxeButtonProps } from './button'
6
7/* eslint-disable no-use-before-define */
8
9/**
10 * 组件 - 工具栏
11 * @example import { VxeToolbar } from 'vxe-table'
12 */
13export const VxeToolbar: VXEComponent<VxeToolbarProps, VxeToolbarEventProps, VxeToolbarSlots>
14/**
15 * 组件 - 工具栏
16 */
17export const Toolbar: typeof VxeToolbar
18
19export type VxeToolbarInstance = ComponentPublicInstance<VxeToolbarProps, VxeToolbarConstructor>
20
21export interface VxeToolbarConstructor extends VxeComponentBase, VxeToolbarMethods {
22 props: VxeToolbarProps
23 context: SetupContext<VxeToolbarEmits>
24 reactData: ToolbarReactData
25 getRefMaps(): ToolbarPrivateRef
26 renderVN: RenderFunction
27}
28
29export interface ToolbarPrivateRef {
30 refElem: Ref<HTMLDivElement>
31}
32export interface VxeToolbarPrivateRef extends ToolbarPrivateRef { }
33
34export namespace VxeToolbarPropTypes {
35 export type Size = SizeType
36 export type Id = string
37 export type Loading = boolean
38
39 interface ResizableConfig {
40 storage?: boolean
41 }
42 export type Resizable = boolean | ResizableConfig
43 export interface ResizableOpts extends ResizableConfig { }
44
45 interface RefreshConfig {
46 queryMethod?(params: { [key: string]: any }): any
47 code?: 'query' | 'reload' | '' | null
48 icon?: string
49 iconLoading?: string
50 /**
51 * @deprecated 请使用 queryMethod
52 */
53 query?(params: { [key: string]: any }): Promise<any>
54 }
55 export type Refresh = boolean | RefreshConfig
56 export interface RefreshOpts extends RefreshConfig { }
57
58 interface ImportConfig {
59 icon?: string
60 }
61 export type Import = boolean | ImportConfig
62 export interface ImportOpts extends ImportConfig { }
63
64 interface ExportConfig {
65 icon?: string
66 }
67 export type Export = boolean | ExportConfig
68 export interface ExportOpts extends ExportConfig { }
69
70 export interface PrintConfig {
71 icon?: string
72 }
73 export type Print = boolean | PrintConfig
74 export interface PrintOpts extends PrintConfig { }
75
76 interface ZoomConfig {
77 iconIn?: string
78 iconOut?: string
79 }
80 export type Zoom = boolean | ZoomConfig
81 export interface ZoomOpts extends ZoomConfig { }
82
83 interface CustomConfig {
84 icon?: string
85
86 /**
87 * 已废弃,请使用 custom-config.trigger
88 * @deprecated
89 */
90 trigger?: string,
91 /**
92 * 已废弃,请使用 custom-config.immediate
93 * @deprecated
94 */
95 immediate?: boolean
96 /**
97 * 已废弃,请使用 custom-config.storage
98 * @deprecated
99 */
100 storage?: boolean
101 /**
102 * 已废弃,请使用 custom-config.checkMethod
103 * @deprecated
104 */
105 checkMethod?(params: { column: VxeTableDefines.ColumnInfo }): boolean
106 /**
107 * 已废弃,请使用 custom-config.showFooter
108 * @deprecated
109 */
110 showFooter?: boolean
111 /**
112 * 已废弃,请使用 custom-config.allowFixed
113 * @deprecated
114 */
115 allowFixed?: boolean
116 /**
117 * 已废弃,请使用 custom-config.resetButtonText
118 * @deprecated
119 */
120 resetButtonText?: string
121 /**
122 * 已废弃,请使用 custom-config.confirmButtonText
123 * @deprecated
124 */
125 confirmButtonText?: string
126 /**
127 * 已废弃,请使用 custom-config.showFooter
128 * @deprecated
129 */
130 isFooter?: boolean
131 }
132 export type Custom = boolean | CustomConfig
133 export interface CustomOpts extends CustomConfig { }
134
135 interface ButtonAndToolConfig extends VxeButtonProps {
136 code?: string
137 visible?: boolean
138 params?: any
139 }
140
141 export interface ButtonConfig extends ButtonAndToolConfig {
142 dropdowns?: ButtonConfig[]
143 buttonRender?: VxeGlobalRendererHandles.RenderButtonOptions
144 }
145 export type Buttons = ButtonConfig[]
146
147 export interface ToolConfig extends ButtonAndToolConfig {
148 dropdowns?: ToolConfig[]
149 toolRender?: VxeGlobalRendererHandles.RenderToolOptions
150 }
151 export type Tools = ToolConfig[]
152
153 export type Perfect = boolean
154
155 export type ClassName = string | ((params: {
156 $toolbar: VxeToolbarConstructor
157 }) => string)
158}
159
160export type VxeToolbarProps = {
161 size?: VxeToolbarPropTypes.Size
162 /**
163 * 唯一 ID 标识
164 */
165 id?: VxeToolbarPropTypes.Id
166 /**
167 * 是否加载中
168 */
169 loading?: VxeToolbarPropTypes.Loading
170 /**
171 * 列宽拖动配置
172 */
173 resizable?: VxeToolbarPropTypes.Resizable
174 /**
175 * 刷新按钮配置
176 */
177 refresh?: VxeToolbarPropTypes.Refresh
178 /**
179 * 导入按钮配置
180 */
181 import?: VxeToolbarPropTypes.Import
182 /**
183 * 导出按钮配置
184 */
185 export?: VxeToolbarPropTypes.Export
186 print?: VxeToolbarPropTypes.Print
187 zoom?: VxeToolbarPropTypes.Zoom
188 /**
189 * 自定义列配置
190 */
191 custom?: VxeToolbarPropTypes.Custom
192 /**
193 * 按钮列表
194 */
195 buttons?: VxeToolbarPropTypes.Buttons
196 tools?: VxeToolbarPropTypes.Tools
197 /**
198 * 配套的样式
199 */
200 perfect?: VxeToolbarPropTypes.Perfect
201 className?: VxeToolbarPropTypes.ClassName
202}
203
204export interface ToolbarReactData {
205 isRefresh: boolean
206 columns: VxeTableDefines.ColumnInfo[]
207}
208
209export interface ToolbarMethods {
210 dispatchEvent(type: ValueOf<VxeToolbarEmits>, params: any, evnt: Event): void
211 syncUpdate(params: {
212 collectColumn: VxeTableDefines.ColumnInfo<any>[]
213 $table: VxeTableConstructor<any> & VxeTablePrivateMethods<any>
214 }): void
215}
216export interface VxeToolbarMethods extends ToolbarMethods { }
217
218export interface ToolbarPrivateMethods { }
219export interface VxeToolbarPrivateMethods extends ToolbarPrivateMethods { }
220
221export type VxeToolbarEmits = [
222 'button-click',
223 'tool-click'
224]
225
226export namespace VxeToolbarDefines {
227 export interface ToolbarEventParams extends VxeEvent {
228 $toolbar: VxeToolbarConstructor
229 }
230}
231
232export type VxeToolbarEventProps = {
233 [key: string]: any
234}
235
236export interface VxeToolbarListeners { }
237
238export namespace VxeToolbarEvents { }
239
240export interface VxeToolbarSlots {
241 /**
242 * 自定义左侧按钮列表
243 */
244 buttons: (params: {
245 [key: string]: any
246 }) => any
247 /**
248 * 自定义右侧工具列表
249 */
250 tools: ((params: {
251 [key: string]: any
252 }) => any) | undefined
253}