-
Notifications
You must be signed in to change notification settings - Fork 13.4k
Expand file tree
/
Copy pathconfig.ts
More file actions
408 lines (338 loc) · 11.2 KB
/
config.ts
File metadata and controls
408 lines (338 loc) · 11.2 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
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
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
import type { SpinnerTypes } from '../components/spinner/spinner-configs';
import type { TabButtonLayout } from '../components/tab-bar/tab-bar-interface';
import type { AnimationBuilder, Mode, Theme } 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 the platform behaviors to use for the entire application,
* such as rubber-band scrolling on iOS or Android page transitions.
*
* Possible values are: `"ios"` or `"md"`.
*
* Without a specified theme, the mode will be used to determine which platform
* styles to use throughout the application. This is legacy behavior to prevent
* breaking changes, but we recommend the use of a specific theme to opt in to
* the new styles.
*/
mode?: Mode;
/**
* The theme determines the visual appearance of components.
* - `"ios"` - iOS components aligning to the Cupertino guidelines
* - `"md"` - Material Design components aligning to Material Design 2 guidelines
* - `"ionic"` - **EXPERIMENTAL** Ionic's upcoming new design system
*/
theme?: Theme;
/**
* 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;
/**
* The selector that will be used to query the root of the Ionic application.
* This element is used for things like injecting overlay elements into the DOM and managing focus.
*
* @default 'ion-app'
*/
appRootSelector?: string;
/**
* Overrides the toggle icon for all `ion-accordion` components.
*/
accordionToggleIcon?: string;
/**
* Overrides the separator icon for all `ion-breadcrumb` components,
* only when mode is set to `ios`.
*/
breadcrumbSeparatorIcon?: string;
/**
* Overrides the collapsed icon for all `ion-breadcrumb` components.
*/
breadcrumbCollapsedIcon?: string;
/**
* Overrides the next icon for all `ion-datetime` components.
*/
datetimeNextIcon?: string;
/**
* Overrides the previous icon for all `ion-datetime` components.
*/
datetimePreviousIcon?: string;
/**
* Overrides the expanded icon for all `ion-datetime` components.
*/
datetimeExpandedIcon?: string;
/**
* Overrides the collapsed icon for all `ion-datetime` components.
*/
datetimeCollapsedIcon?: string;
/**
* Overrides the close icon for all `ion-fab-button` components.
*/
fabButtonCloseIcon?: string;
/**
* Overrides the clear icon for all `ion-input` components.
*/
inputClearIcon?: string;
/**
* Overrides the show icon for all `ion-input-password` components.
*/
inputPasswordShowIcon?: string;
/**
* Overrides the hide icon for all `ion-input-password` components.
*/
inputPasswordHideIcon?: string;
/**
* Overrides the detail icon for all `ion-item` components.
*/
itemDetailIcon?: string;
/**
* Overrides the handle icon for all `ion-reorder` components.
*/
reorderHandleIcon?: string;
/**
* Overrides the cancel icon for all `ion-searchbar` components,
* only when mode is set to `md`.
*/
searchbarCancelIcon?: string;
/**
* Overrides the clear icon for all `ion-searchbar` components.
*/
searchbarClearIcon?: string;
/**
* Overrides the search icon for all `ion-searchbar` components.
*/
searchbarSearchIcon?: string;
/**
* Overrides the expand icon for all `ion-select` components.
*/
selectExpandedIcon?: string;
/**
* Overrides the collapsed icon for all `ion-select` components.
*/
selectCollapsedIcon?: string;
/**
* Overrides the checked icon for all `ion-toggle` components.
*/
toggleCheckedIcon?: string;
/**
* Overrides the unchecked icon for all `ion-toggle` components.
*/
toggleUncheckedIcon?: string;
/**
* 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;
// Theme configs
customTheme?: any;
// INTERNAL configs
// TODO(FW-2832): types
persistConfig?: boolean;
_forceStatusbarPadding?: boolean;
_testing?: boolean;
_zoneGate?: (h: () => 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;