forked from ng-bootstrap/ng-bootstrap
-
Notifications
You must be signed in to change notification settings - Fork 0
/
modal-config.ts
142 lines (124 loc) · 3.34 KB
/
modal-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
import {Injectable, Injector} from '@angular/core';
import {NgbConfig} from '../ngb-config';
import {NgbModalRef} from './modal-ref';
/**
* Options available when opening new modal windows with `NgbModal.open()` method.
*/
export interface NgbModalOptions<T = any> {
/**
* If `true`, modal opening and closing will be animated.
*
* @since 8.0.0
*/
animation?: boolean;
/**
* `aria-labelledby` attribute value to set on the modal window.
*
* @since 2.2.0
*/
ariaLabelledBy?: string;
/**
* `aria-describedby` attribute value to set on the modal window.
*
* @since 6.1.0
*/
ariaDescribedBy?: string;
/**
* If `true`, the backdrop element will be created for a given modal.
*
* Alternatively, specify `'static'` for a backdrop which doesn't close the modal on click.
*
* Default value is `true`.
*/
backdrop?: boolean | 'static';
/**
* Callback right before the modal will be dismissed.
*
* If this function returns:
* * `false`
* * a promise resolved with `false`
* * a promise that is rejected
*
* then the modal won't be dismissed.
*/
beforeDismiss?: (modalRef: NgbModalRef<T>) => boolean | Promise<boolean>;
/**
* If `true`, the modal will be centered vertically.
*
* Default value is `false`.
*
* @since 1.1.0
*/
centered?: boolean;
/**
* A selector specifying the element all new modal windows should be appended to.
* Since v5.3.0 it is also possible to pass the reference to an `HTMLElement`.
*
* If not specified, will be `body`.
*/
container?: string | HTMLElement;
/**
* The `Injector` to use for modal content.
*/
injector?: Injector;
/**
* If `true`, the modal will be closed when `Escape` key is pressed
*
* Default value is `true`.
*/
keyboard?: boolean;
/**
* Scrollable modal content (false by default).
*
* @since 5.0.0
*/
scrollable?: boolean;
/**
* Size of a new modal window.
*/
size?: 'sm' | 'lg' | 'xl' | string;
/**
* A custom class to append to the modal window.
*/
windowClass?: string;
/**
* A custom class to append to the modal dialog.
*
* @since 9.1.0
*/
modalDialogClass?: string;
/**
* A custom class to append to the modal backdrop.
*
* @since 1.1.0
*/
backdropClass?: string;
}
/**
* A configuration service for the [`NgbModal`](#/components/modal/api#NgbModal) service.
*
* You can inject this service, typically in your root component, and customize the values of its properties in
* order to provide default values for all modals used in the application.
*
* @since 3.1.0
*/
@Injectable({providedIn: 'root'})
export class NgbModalConfig implements Required<NgbModalOptions> {
ariaLabelledBy: string;
ariaDescribedBy: string;
backdrop: boolean | 'static' = true;
beforeDismiss: (modalRef: NgbModalRef<any>) => boolean | Promise<boolean>;
centered: boolean;
container: string;
injector: Injector;
keyboard = true;
scrollable: boolean;
size: 'sm' | 'lg' | 'xl' | string;
windowClass: string;
modalDialogClass: string;
backdropClass: string;
private _animation: boolean;
constructor(private _ngbConfig: NgbConfig) {}
get animation(): boolean { return (this._animation === undefined) ? this._ngbConfig.animation : this._animation; }
set animation(animation: boolean) { this._animation = animation; }
}