-
Notifications
You must be signed in to change notification settings - Fork 13.5k
/
Copy pathconfig.ts
282 lines (235 loc) · 8.11 KB
/
config.ts
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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
import type { SpinnerTypes } from '../components/spinner/spinner-configs';
import type { TabButtonLayout } from '../components/tab-bar/tab-bar-interface';
import type { AnimationBuilder, Mode } from '../interface';
import type { LogLevel } from './logging';
import type { PlatformConfig } from './platform';
export interface IonicConfig {
/**
* When it's set to `false`, disables all animation and transition across the app.
* Can be useful to make ionic smoother in slow devices, when animations can't run smoothly.
*/
animated?: boolean;
/**
* When it's set to `false`, it disables all material-design ripple-effects across the app.
* Defaults to `true`.
*/
rippleEffect?: boolean;
/**
* The mode determines which platform styles to use for the whole application.
*/
mode?: Mode;
/**
* Wherever ionic will respond to hardware go back buttons in an Android device.
* Defaults to `true` when ionic runs in a mobile device.
*/
hardwareBackButton?: boolean;
/**
* Whenever clicking the top status bar should cause the scroll to top in an application.
* Defaults to `true` when ionic runs in a mobile device.
*/
statusTap?: boolean;
/**
* Overrides the default icon in all `<ion-back-button>` components.
*/
backButtonIcon?: string;
/**
* Overrides the default text in all `<ion-back-button>` components.
*/
backButtonText?: string;
/**
* Overrides the default defaultHref in all `<ion-back-button>` components.
*/
backButtonDefaultHref?: string;
/**
* Overrides the default icon in all `<ion-menu-button>` components.
*/
menuIcon?: string;
/**
* Overrides the default menu type for all `<ion-menu>` components.
* By default the menu type is chosen based in the app's mode.
*/
menuType?: string;
/**
* Overrides the default spinner in all `<ion-spinner>` components.
* By default the spinner type is chosen based in the mode (ios or md).
*/
spinner?: SpinnerTypes;
/**
* Overrides the default enableOnOffLabels in all `<ion-toggle>` components.
*/
toggleOnOffLabels?: boolean;
/**
* Overrides the default spinner for all `ion-loading` overlays, ie. the ones
* created with `ion-loading-controller`.
*/
loadingSpinner?: SpinnerTypes | null;
/**
* Overrides the default icon in all `<ion-refresh-content>` components.
*/
refreshingIcon?: string;
/**
* Overrides the default spinner type in all `<ion-refresh-content>` components.
*/
refreshingSpinner?: SpinnerTypes | null;
/**
* Overrides the default spinner type in all `<ion-infinite-scroll-content>` components.
*/
infiniteLoadingSpinner?: SpinnerTypes | null;
/**
* Global switch that disables or enables "swipe-to-go-back" gesture across all
* `ion-nav` in your application.
*/
swipeBackEnabled?: boolean;
/**
* Overrides the default "layout" of all `ion-bar-button` across the whole application.
*/
tabButtonLayout?: TabButtonLayout;
/**
* Overrides the default `duration` for all `ion-toast` components.
*/
toastDuration?: number;
/**
* Overrides the default "animation" of all `ion-nav` and `ion-router-outlet` across the whole application.
* This prop allows to replace the default transition and provide a custom one that applies to all navigation outlets.
*/
navAnimation?: AnimationBuilder;
/**
* Provides a custom enter animation for all `ion-action-sheet`, overriding the default "animation".
*/
actionSheetEnter?: AnimationBuilder;
/**
* Provides a custom enter animation for all `ion-alert`, overriding the default "animation".
*/
alertEnter?: AnimationBuilder;
/**
* Provides a custom enter animation for all `ion-loading`, overriding the default "animation".
*/
loadingEnter?: AnimationBuilder;
/**
* Provides a custom enter animation for all `ion-modal`, overriding the default "animation".
*/
modalEnter?: AnimationBuilder;
/**
* Provides a custom enter animation for all `ion-popover`, overriding the default "animation".
*/
popoverEnter?: AnimationBuilder;
/**
* Provides a custom enter animation for all `ion-toast`, overriding the default "animation".
*/
toastEnter?: AnimationBuilder;
/**
* Provides a custom enter animation for all `ion-picker-legacy`, overriding the default "animation".
*/
pickerEnter?: AnimationBuilder;
/**
* Provides a custom leave animation for all `ion-action-sheet`, overriding the default "animation".
*/
actionSheetLeave?: AnimationBuilder;
/**
* Provides a custom leave animation for all `ion-alert`, overriding the default "animation".
*/
alertLeave?: AnimationBuilder;
/**
* Provides a custom leave animation for all `ion-loading`, overriding the default "animation".
*/
loadingLeave?: AnimationBuilder;
/**
* Provides a custom leave animation for all `ion-modal`, overriding the default "animation".
*/
modalLeave?: AnimationBuilder;
/**
* Provides a custom leave animation for all `ion-popover`, overriding the default "animation".
*/
popoverLeave?: AnimationBuilder;
/**
* Provides a custom leave animation for all `ion-toast`, overriding the default "animation".
*/
toastLeave?: AnimationBuilder;
/**
* Provides a custom leave animation for all `ion-picker-legacy`, overriding the default "animation".
*/
pickerLeave?: AnimationBuilder;
/**
* If `true`, Ionic will enable a basic DOM sanitizer on component properties that accept custom HTML.
*/
sanitizerEnabled?: boolean;
/**
* Relevant Components: ion-alert, ion-infinite-scroll-content, ion-loading, ion-refresher-content, ion-toast
* If `false`, all `innerHTML` usage will be disabled in Ionic, and
* custom HTML will not be usable in the relevant components.
* If `true`, all `innerHTML` usage will be enabled in Ionic, and
* custom HTML will be usable in the relevant components.
* `innerHTML` usage is disabled by default.
*/
innerHTMLTemplatesEnabled?: boolean;
/**
* Overrides the default platform detection methods.
*/
platform?: PlatformConfig;
/**
* @experimental
* When defined, Ionic will move focus to the appropriate element after each
* page transition. This ensures that users relying on assistive technology
* are informed when a page transition happens.
*/
focusManagerPriority?: FocusManagerPriority[];
/**
* @experimental
* If `true`, the [CloseWatcher API](https://github.com/WICG/close-watcher) will be used to handle
* all Escape key and hardware back button presses to dismiss menus and overlays and to navigate.
* Note that the `hardwareBackButton` config option must also be `true`.
*/
experimentalCloseWatcher?: boolean;
/**
* Configures the logging level for Ionic Framework:
*
* - `'OFF'`: No errors or warnings are logged.
* - `'ERROR'`: Logs only errors.
* - `'WARN'`: Logs errors and warnings.
*/
logLevel?: LogLevel;
// PRIVATE configs
keyboardHeight?: number;
inputShims?: boolean;
scrollPadding?: boolean;
inputBlurring?: boolean;
scrollAssist?: boolean;
hideCaretOnScroll?: boolean;
// INTERNAL configs
// TODO(FW-2832): types
persistConfig?: boolean;
_forceStatusbarPadding?: boolean;
_testing?: boolean;
_zoneGate?: (h: () => any) => any;
_ael?: (el: any, name: string, cb: any, opts: any) => any;
_rel?: (el: any, name: string, cb: any, opts: any) => any;
_ce?: (eventName: string, opts: any) => any;
}
type FocusManagerPriority = 'content' | 'heading' | 'banner';
export const setupConfig = (config: IonicConfig) => {
const win = window as any;
const Ionic = win.Ionic;
// eslint-disable-next-line @typescript-eslint/prefer-optional-chain
if (Ionic && Ionic.config && Ionic.config.constructor.name !== 'Object') {
return;
}
win.Ionic = win.Ionic || {};
win.Ionic.config = {
...win.Ionic.config,
...config,
};
return win.Ionic.config;
};
export const getMode = (): Mode => {
const win = window as any;
const config = win?.Ionic?.config;
if (config) {
if (config.mode) {
return config.mode;
} else {
return config.get('mode');
}
}
return 'md';
};
export const ENABLE_HTML_CONTENT_DEFAULT = false;