-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathtypes.ts
More file actions
193 lines (188 loc) · 5.62 KB
/
types.ts
File metadata and controls
193 lines (188 loc) · 5.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
import type { ElIdInjectionContext, ElZIndexInjectionContext, ConfigProviderContext } from 'element-plus'
/** name: export name from the library, as: the name you want to use in your project, from: the name of library */
export type PresetComponent = string | [name: string, as?: string, from?: string]
/** name: export name from the library, path: the file path in the component directory */
export type PresetImport = [name: string | string[], path: string]
/** directive: export name from the library, name: export name with style */
export type PresetDirectives = Record<string, string | [directive: string, name?: string]>
/** Used to filter files that need to automatically import styles and other functions */
export interface TransformOptions {
include: RegExp[]
exclude: RegExp[]
}
export interface ModuleOptions extends TransformOptions {
/**
* A list of components that need to be automatically imported externally.
*
* @default 'from element-plus/es/component'
*
* If there are components that are not imported automatically from Element Plus, you need to add the component name here.
*
* @example
* ```ts
* ['ElSubMenu']
* ```
*/
components: PresetComponent[]
/**
* A map of components that the definition file of subComponent is in its parent component.
*/
subComponents: Record<string, string[]>
/**
* A list of directives that need to be automatically imported externally.
*
* @default
* ```ts
* {
* Loading: ['ElLoadingDirective', 'ElLoading'],
* Popover: ['ElPopoverDirective', 'ElPopover'],
* InfiniteScroll: 'ElInfiniteScroll'
* }
* ```
*/
directives: PresetDirectives
/**
* A list of imports that need to be automatically imported externally.
*
* When you need to add automatically import content from Element Plus, you can add it here.
*
* @example
* ```ts
* [
* ['useLocale', 'es/hooks/use-locale/index.mjs'],
* [['castArray', 'unique'], 'es/utils/arrays.mjs']
* ]
* ```
*
* @before
* ```ts
* import { useLocale } from 'element-plus'
* const { t } = useLocale()
* ```
*
* @after
* ```ts
* const { t } = useLocale()
* ```
*/
imports: PresetImport[]
/**
*
* List of imports that will be imported whether if autoImports is disabled.
*
* @default
* ```ts
* [
* ["ID_INJECTION_KEY", "es/hooks/use-id/index.mjs"],
* ["ZINDEX_INJECTION_KEY", "es/hooks/use-z-index/index.mjs"],
* ["provideGlobalConfig", "es/components/config-provider/src/hooks/use-global-config.mjs"],
* ]
* ```
*/
baseImports: PresetImport[]
/**
* import style css or sass(scss) with components
*
* @default 'css'
*
* Disable automatically import styles with `false`
*/
importStyle: 'css' | 'scss' | boolean
/**
* A list of themes that require importing styles automatically.
*
* Currently, only [dark](https://element-plus.org/en-US/guide/dark-mode.html) is supported.
*
* @example
* ```ts
* ['dark']
* ```
*/
themes: Array<'dark'>
/**
* A list of component names that have no styles, so resolving their styles file should be prevented
*
* @default
* ```ts
* ['ElAutoResizer', 'ElTooltipV2']
* ```
*/
noStylesComponents: string[]
/**
* We need to inject the same ID value into the server side and client side to ensure that the code generated on the server is the same as that on the client, so as to avoid hydrate errors.
*
* @default
* ```ts
* { prefix: 1024, current: 0 }
* ```
*/
injectionID: ElIdInjectionContext
/**
* We need to inject an initial z-index value to ensure that the server side and client side generate the same z-index value, so as to avoid hydration errors.
*
* @default
* ```ts
* { current: 0 }
* ```
*/
injectionZIndex: ElZIndexInjectionContext
/**
* Global component className prefix.
*
* When you change the global namespace, you must change it here as well.
*
* @default 'el'
*/
namespace: string
/**
* Which element the tooltip CONTENT appends to.
*
* When you modify the `append-to` props in all based on ElTooltip components, you need to add the value here, to avoid hydrate errors.
*
* If you used `Teleport` to teleport a part of a component's template into a DOM node near the `<body>` tag, you can also add this ID here. The internal plug-in will automatically handle hydrate errors.
*/
appendTo: string[]
/**
* Icon prefix name.
*
* To avoid the duplication of icon names with native DOM or other components, we recommend adding a prefix to the icon.
*
* @default 'ElIcon'
*
* Disable automatically import icon with `false`
*/
icon: false | string
/**
* Replace default locale, you can find locale list [here](https://github.com/element-plus/element-plus/tree/dev/packages/locale/lang).
*
* @default 'en'
* @example 'zh-cn'
*/
defaultLocale?: string
/**
* Set global configuration, such as modifying the default size and z-index of the component.
*
* @example
* ```ts
* { size: 'small', zIndex: 3000 }
* ```
*/
globalConfig?: ConfigProviderContext
/**
* List of methods that need to be installed.
*
* @example
* ```ts
* ['ElLoading', 'ElMessage', 'ElMessageBox', 'ElNotification']
* ```
*/
installMethods: Array<'ElLoading' | 'ElMessage' | 'ElMessageBox' | 'ElNotification'>
/**
* Whether to cache the element-plus components and directives. **Only effective in development mode**.
*
* If you enable this feature, you will get faster loading speed in development mode.
*
* @default 'false'
*/
cache?: boolean
}