UNPKG

7.93 kBTypeScriptView Raw
1import { SaveFileFunction, ReadFileFunction, PrintFunction } from '../module/export'
2import { SizeType } from '../component'
3import { VxeTableProps } from '../table'
4import { VxeGridProps } from '../grid'
5import { VxeToolbarProps } from '../toolbar'
6import { VxeTooltipProps } from '../tooltip'
7import { VxePagerProps } from '../pager'
8import { VxeModalProps, ModalController } from '../modal'
9import { VxeDrawerProps, DrawerController } from '../drawer'
10import { VxeFormProps } from '../form'
11import { VxeListProps } from '../list'
12import { VxeSwitchProps } from '../switch'
13import { VxeSelectProps } from '../select'
14import { VxeInputProps } from '../input'
15import { VxeTextareaProps } from '../textarea'
16import { VxeButtonProps } from '../button'
17import { VxeButtonGroupProps } from '../button-group'
18import { VxeCheckboxProps } from '../checkbox'
19import { VxeCheckboxGroupProps } from '../checkbox-group'
20import { VxeRadioProps } from '../radio'
21import { VxeRadioButtonProps } from '../radio-button'
22import { VxeRadioGroupProps } from '../radio-group'
23
24import { VxeGlobalRenderer } from './renderer'
25import { VxeGlobalInterceptor } from './interceptor'
26import { VxeGlobalCommands } from './commands'
27import { VxeGlobalFormats } from './formats'
28import { VxeGlobalMenus } from './menus'
29import { VxeGlobalValidators } from './validators'
30import { VxeGlobalHooks } from './hooks'
31
32/* eslint-disable no-use-before-define */
33
34export interface VXETableConfigOptions {
35 /**
36 * 扩展插件授权码
37 */
38 authId?: string
39 onAuth?(event: {
40 status: boolean
41 code: number
42 msg: string
43
44 [key: string]: any
45 }): void
46
47 theme?: null | '' | 'default' | 'dark'
48
49 size?: SizeType
50 zIndex?: number
51 version?: number
52 emptyCell?: string
53 icon?: VxeGlobalIcon
54 table?: VxeTableProps
55 grid?: VxeGridProps
56 export?: {
57 types?: {
58 [key: string]: 0 | 1 | 2
59 }
60 [key: string]: any
61 }
62 tooltip?: VxeTooltipProps
63 pager?: VxePagerProps
64 form?: VxeFormProps
65 input?: VxeInputProps
66 textarea?: VxeTextareaProps
67 select?: VxeSelectProps
68 toolbar?: VxeToolbarProps
69 button?: VxeButtonProps
70 buttonGroup?: VxeButtonGroupProps
71 radio?: VxeRadioProps
72 radioButton?: VxeRadioButtonProps
73 radioGroup?: VxeRadioGroupProps
74 checkbox?: VxeCheckboxProps
75 checkboxGroup?: VxeCheckboxGroupProps
76 switch?: VxeSwitchProps
77 modal?: VxeModalProps
78 drawer?: VxeDrawerProps
79 list?: VxeListProps
80 translate?(key: string, args?: any): string
81 i18n?(key: string, args?: any): string
82
83 /**
84 * 还原旧的单元格校验模式,已废弃
85 * @deprecated
86 */
87 cellVaildMode?: 'obsolete' | '' | null
88
89 [key: string]: any
90}
91
92export type VxeGlobalConfig = VXETableConfigOptions
93
94export interface VxeGlobalIcon {
95 [ket: string]: string
96}
97
98export type VxeGlobalConfigMethod = (options?: VXETableConfigOptions) => VXETableCore
99export type VxeGlobalThemeMethod = (name?: '' | 'light' | 'dark') => VXETableCore
100export type VxeGlobalGetThemeMethod = () => 'light' | 'dark'
101
102/**
103 * 请使用 setConfig
104 * @deprecated
105 */
106export type VxeGlobalSetup = (options?: VXETableConfigOptions) => Required<VXETableConfigOptions>
107/**
108 * @deprecated
109 */
110export type VXETableGlobalConfig = (options?: VXETableConfigOptions) => Required<VXETableConfigOptions>
111/**
112 * 请使用 setConfig
113 * @deprecated
114 */
115export type VXETableSetupOptions = (options?: VXETableConfigOptions) => Required<VXETableConfigOptions>
116
117export class VXETableConfig {
118 clipboard: {
119 text: string
120 html: string
121 }
122
123 get zIndex(): number
124 get nextZIndex(): number
125 /**
126 * 获取导出的所有文件类型
127 */
128 get exportTypes(): string[]
129 /**
130 * 获取导入的所有文件类型
131 */
132 get importTypes(): string[]
133}
134
135export type VxeGlobalI18n = (key: string, args?: any) => string
136export type VxeGlobalTranslate = (key: string, args?: any) => string
137export type VxeGlobalUse = (plugin: VXETablePluginObject, ...options: any[]) => VXETableCore
138
139export const setConfig: VxeGlobalConfigMethod
140export const setTheme: VxeGlobalThemeMethod
141export const getTheme: VxeGlobalGetThemeMethod
142
143export const interceptor: VxeGlobalInterceptor
144export const renderer: VxeGlobalRenderer
145export const commands: VxeGlobalCommands
146export const formats: VxeGlobalFormats
147export const menus: VxeGlobalMenus
148export const validators: VxeGlobalValidators
149export const hooks: VxeGlobalHooks
150export const modal: ModalController
151export const drawer: DrawerController
152export const saveFile: SaveFileFunction
153export const readFile: ReadFileFunction
154export const print: PrintFunction
155export const t: VxeGlobalI18n
156export const _t: VxeGlobalTranslate
157export const use: VxeGlobalUse
158/**
159 * 请使用 setConfig
160 * @deprecated
161 */
162export const config: VXETableGlobalConfig
163/**
164 * 请使用 setConfig
165 * @deprecated
166 */
167export const setup: VXETableSetupOptions
168/**
169 * 已废弃
170 * @deprecated
171 */
172export const globalConfs: VXETableConfig
173
174export function getComponent (name: string): any
175export function component (comp: any): any
176
177export function setIcon(options?: VxeGlobalIcon): VXETableCore
178
179export interface VXETablePluginObject {
180 install(vxetable: VXETableCore, ...options: any[]): void
181 [key: string]: any
182}
183
184export interface VxeGlobalStore {
185 [key: string]: any
186 clipboard?: {
187 text: string
188 html: string
189 }
190}
191export const globalStore: VxeGlobalStore
192
193export type VXETableVersion = 'v1' | 'v2' | 'v3' | 'v4'
194
195export const v: VXETableVersion
196
197export interface VXETableCore {
198 tooltip?: boolean
199 /**
200 * 版本号
201 */
202 version: string
203 tableVersion?: string;
204 /**
205 * 设置全局参数/获取所有参数
206 */
207 setConfig: VxeGlobalConfigMethod
208 setTheme: VxeGlobalThemeMethod
209 getTheme: VxeGlobalGetThemeMethod
210 setIcon: typeof setIcon
211 /**
212 * 读取内部数据
213 */
214 globalStore: VxeGlobalStore
215 /**
216 * Table interceptor
217 */
218 interceptor: VxeGlobalInterceptor
219 /**
220 * Table renderer
221 */
222 renderer: VxeGlobalRenderer
223 /**
224 * Table commands
225 */
226 commands: VxeGlobalCommands
227 /**
228 * Table column formatter
229 */
230 formats: VxeGlobalFormats
231 /**
232 * Table context menu
233 */
234 menus: VxeGlobalMenus
235 /**
236 * Validators table/form
237 */
238 validators: VxeGlobalValidators
239 /**
240 * Table VxeGlobalHooks API
241 */
242 hooks: VxeGlobalHooks
243 /**
244 * 弹窗
245 */
246 modal: ModalController
247 drawer: DrawerController
248 /**
249 * 读取本地文件
250 */
251 saveFile: SaveFileFunction
252 /**
253 * 读取本地文件
254 */
255 readFile: ReadFileFunction
256 /**
257 * 打印
258 */
259 print: PrintFunction
260 /**
261 * 安装插件
262 * @param plugin
263 * @param options
264 */
265 use: VxeGlobalUse
266 /**
267 * 读取内置国际化
268 */
269 t: VxeGlobalI18n
270 _t: VxeGlobalTranslate
271
272 getComponent: typeof getComponent,
273 component: typeof component,
274
275 /**
276 * 请使用 setConfig
277 * @deprecated
278 */
279 config: VXETableGlobalConfig
280 /**
281 * @deprecated 已废弃
282 */
283 globalConfs: VXETableConfig
284 /**
285 * 已被 version 替换
286 * @deprecated
287 */
288 v: VXETableVersion
289 /**
290 * 请使用 setConfig
291 * @deprecated
292 */
293 setup: VXETableSetupOptions
294}
295
296/**
297 * 一个基于 vue 的 PC 端表单/表格组件,支持增删改查、虚拟列表、虚拟树、懒加载、快捷菜单、数据校验、树形结构、打印导出、表单渲染、数据分页、弹窗、自定义模板、渲染器、JSON 配置式...
298 */
299export const VXETable: VXETableCore
300export const VxeUI: VXETableCore
301
302export * from './renderer'
303export * from './interceptor'
304export * from './commands'
305export * from './formats'
306export * from './menus'
307export * from './validators'
308export * from './hooks'
309
310export default VXETable