bootstrap-rn 0.3.4 → 0.3.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/components/Image.js.map +1 -1
- package/lib/commonjs/components/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/Text.js.map +1 -1
- package/lib/commonjs/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/commonjs/components/forms/RadioGroup.js.map +1 -1
- package/lib/commonjs/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/commonjs/components/modal/Modal.js +1 -1
- package/lib/commonjs/components/modal/Modal.js.map +1 -1
- package/lib/commonjs/components/modal/ModalBody.js +1 -1
- package/lib/commonjs/components/modal/ModalBody.js.map +1 -1
- package/lib/commonjs/components/modal/ModalContext.js.map +1 -1
- package/lib/commonjs/components/nav/Nav.js.map +1 -1
- package/lib/commonjs/components/nav/NavContext.js.map +1 -1
- package/lib/commonjs/components/nav/TabContext.js.map +1 -1
- package/lib/commonjs/components/navbar/NavbarContext.js.map +1 -1
- package/lib/commonjs/components/offcanvas/OffcanvasBody.js.map +1 -1
- package/lib/commonjs/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/commonjs/components/popover/injectPopover.js.map +1 -1
- package/lib/commonjs/components/toasts/ToastContainer.js +3 -1
- package/lib/commonjs/components/toasts/ToastContainer.js.map +1 -1
- package/lib/commonjs/components/tooltip/injectTooltip.js +0 -3
- package/lib/commonjs/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/commonjs/index.d.ts +47 -8
- package/lib/commonjs/index.js +0 -56
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/style/StyleSheet.js +4 -2
- package/lib/commonjs/style/StyleSheet.js.map +1 -1
- package/lib/commonjs/style/makeUtilities.js.map +1 -1
- package/lib/commonjs/types.d.ts +6 -3
- package/lib/module/components/Image.js.map +1 -1
- package/lib/module/components/ImageBackground.js.map +1 -1
- package/lib/module/components/Text.js.map +1 -1
- package/lib/module/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/module/components/forms/RadioGroup.js.map +1 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/module/components/modal/Modal.js +1 -1
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/module/components/modal/ModalBody.js +1 -1
- package/lib/module/components/modal/ModalBody.js.map +1 -1
- package/lib/module/components/modal/ModalContext.js.map +1 -1
- package/lib/module/components/nav/Nav.js.map +1 -1
- package/lib/module/components/nav/NavContext.js.map +1 -1
- package/lib/module/components/nav/TabContext.js.map +1 -1
- package/lib/module/components/navbar/NavbarContext.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasBody.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/module/components/popover/injectPopover.js.map +1 -1
- package/lib/module/components/toasts/ToastContainer.js +3 -1
- package/lib/module/components/toasts/ToastContainer.js.map +1 -1
- package/lib/module/components/tooltip/injectTooltip.js +0 -3
- package/lib/module/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/module/index.d.ts +47 -8
- package/lib/module/index.js +0 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/style/StyleSheet.js +4 -2
- package/lib/module/style/StyleSheet.js.map +1 -1
- package/lib/module/style/makeUtilities.js.map +1 -1
- package/lib/module/types.d.ts +6 -3
- package/lib/types/components/Image.d.ts.map +1 -1
- package/lib/types/components/ImageBackground.d.ts.map +1 -1
- package/lib/types/components/Text.d.ts +1 -1
- package/lib/types/components/Text.d.ts.map +1 -1
- package/lib/types/components/dropdown/Dropdown.d.ts +2 -11
- package/lib/types/components/dropdown/Dropdown.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownContext.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownContext.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownMenu.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownMenu.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownToggle.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownToggle.d.ts.map +1 -1
- package/lib/types/components/forms/Picker.d.ts +4 -4
- package/lib/types/components/forms/Picker.d.ts.map +1 -1
- package/lib/types/components/forms/PickerItem.d.ts +1 -1
- package/lib/types/components/forms/PickerItem.d.ts.map +1 -1
- package/lib/types/components/forms/Radio.d.ts +1 -1
- package/lib/types/components/forms/Radio.d.ts.map +1 -1
- package/lib/types/components/forms/RadioContext.d.ts +2 -2
- package/lib/types/components/forms/RadioContext.d.ts.map +1 -1
- package/lib/types/components/forms/RadioGroup.d.ts +2 -2
- package/lib/types/components/forms/RadioGroup.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNative.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNativeContext.d.ts +2 -2
- package/lib/types/components/forms/internals/PickerNativeContext.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerNativeItem.d.ts +1 -1
- package/lib/types/components/forms/internals/PickerNativeItem.d.ts.map +1 -1
- package/lib/types/components/forms/internals/PickerWebItem.d.ts +1 -1
- package/lib/types/components/forms/internals/PickerWebItem.d.ts.map +1 -1
- package/lib/types/components/list-group/ListGroup.d.ts +1 -1
- package/lib/types/components/list-group/ListGroupItem.d.ts +13 -1
- package/lib/types/components/list-group/ListGroupItem.d.ts.map +1 -1
- package/lib/types/components/list-group/ListGroupItemAction.d.ts +2 -2
- package/lib/types/components/list-group/ListGroupItemAction.d.ts.map +1 -1
- package/lib/types/components/modal/Modal.d.ts +4 -7
- package/lib/types/components/modal/Modal.d.ts.map +1 -1
- package/lib/types/components/modal/ModalBody.d.ts +3 -6
- package/lib/types/components/modal/ModalBody.d.ts.map +1 -1
- package/lib/types/components/modal/ModalContext.d.ts +3 -3
- package/lib/types/components/modal/ModalContext.d.ts.map +1 -1
- package/lib/types/components/nav/Nav.d.ts +1 -3
- package/lib/types/components/nav/Nav.d.ts.map +1 -1
- package/lib/types/components/nav/NavContext.d.ts +3 -3
- package/lib/types/components/nav/NavContext.d.ts.map +1 -1
- package/lib/types/components/nav/Tab.d.ts +1 -1
- package/lib/types/components/nav/TabContext.d.ts +3 -3
- package/lib/types/components/nav/TabContext.d.ts.map +1 -1
- package/lib/types/components/navbar/Navbar.d.ts +1 -1
- package/lib/types/components/navbar/NavbarBrand.d.ts +2 -2
- package/lib/types/components/navbar/NavbarBrand.d.ts.map +1 -1
- package/lib/types/components/navbar/NavbarContext.d.ts +2 -2
- package/lib/types/components/navbar/NavbarContext.d.ts.map +1 -1
- package/lib/types/components/offcanvas/Offcanvas.d.ts +1 -3
- package/lib/types/components/offcanvas/Offcanvas.d.ts.map +1 -1
- package/lib/types/components/offcanvas/OffcanvasBody.d.ts +3 -4
- package/lib/types/components/offcanvas/OffcanvasBody.d.ts.map +1 -1
- package/lib/types/components/offcanvas/OffcanvasContext.d.ts +2 -2
- package/lib/types/components/offcanvas/OffcanvasContext.d.ts.map +1 -1
- package/lib/types/components/popover/injectPopover.d.ts +9 -12
- package/lib/types/components/popover/injectPopover.d.ts.map +1 -1
- package/lib/types/components/toasts/ToastContainer.d.ts +4 -2
- package/lib/types/components/toasts/ToastContainer.d.ts.map +1 -1
- package/lib/types/components/tooltip/injectTooltip.d.ts +8 -11
- package/lib/types/components/tooltip/injectTooltip.d.ts.map +1 -1
- package/lib/types/hooks/useBackground.native.d.ts +3 -1
- package/lib/types/hooks/useBackground.native.d.ts.map +1 -1
- package/lib/types/index.d.ts +47 -8
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/style/StyleSheet.d.ts +2 -3
- package/lib/types/style/StyleSheet.d.ts.map +1 -1
- package/lib/types/style/createStyle.d.ts +3 -1
- package/lib/types/style/createStyle.d.ts.map +1 -1
- package/lib/types/style/css.d.ts +3 -1
- package/lib/types/style/css.d.ts.map +1 -1
- package/lib/types/style/makeUtilities.d.ts +6 -2
- package/lib/types/style/makeUtilities.d.ts.map +1 -1
- package/lib/types/theme/variables.d.ts +3 -1
- package/lib/types/theme/variables.d.ts.map +1 -1
- package/lib/types/types.d.ts +6 -3
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +80 -80
- package/src/components/Image.tsx +31 -27
- package/src/components/ImageBackground.tsx +48 -46
- package/src/components/Text.tsx +119 -117
- package/src/components/dropdown/DropdownContext.ts +2 -2
- package/src/components/dropdown/DropdownMenu.tsx +127 -125
- package/src/components/dropdown/DropdownToggle.ts +2 -2
- package/src/components/forms/Picker.tsx +191 -191
- package/src/components/forms/PickerItem.tsx +32 -32
- package/src/components/forms/Radio.tsx +37 -37
- package/src/components/forms/RadioContext.ts +13 -13
- package/src/components/forms/RadioGroup.tsx +42 -40
- package/src/components/forms/internals/PickerNative.tsx +193 -195
- package/src/components/forms/internals/PickerNativeContext.ts +14 -14
- package/src/components/forms/internals/PickerNativeItem.tsx +59 -59
- package/src/components/forms/internals/PickerWebItem.tsx +36 -36
- package/src/components/list-group/ListGroupItemAction.tsx +2 -2
- package/src/components/modal/Modal.tsx +234 -233
- package/src/components/modal/ModalBody.tsx +52 -56
- package/src/components/modal/ModalContext.ts +3 -3
- package/src/components/nav/Nav.tsx +4 -4
- package/src/components/nav/NavContext.ts +3 -3
- package/src/components/nav/TabContext.ts +3 -3
- package/src/components/navbar/NavbarBrand.tsx +2 -2
- package/src/components/navbar/NavbarContext.ts +2 -2
- package/src/components/offcanvas/OffcanvasBody.tsx +64 -66
- package/src/components/offcanvas/OffcanvasContext.ts +4 -2
- package/src/components/popover/injectPopover.tsx +97 -98
- package/src/components/toasts/ToastContainer.tsx +41 -39
- package/src/components/tooltip/injectTooltip.tsx +93 -96
- package/src/index.ts +242 -211
- package/src/style/StyleSheet.ts +149 -138
- package/src/style/makeUtilities.ts +79 -76
- package/src/types.ts +168 -162
|
@@ -1,233 +1,234 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { Modal as BaseModal, SafeAreaView } from 'react-native';
|
|
3
|
-
import { OverlayProvider } from '@react-native-aria/overlays';
|
|
4
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
-
import { getStyles } from '../../utils';
|
|
6
|
-
import css from '../../style/css';
|
|
7
|
-
import ScrollView from '../ScrollView';
|
|
8
|
-
import View, {
|
|
9
|
-
import BackdropHandler from '../helpers/BackdropHandler';
|
|
10
|
-
import useModal from './useModal';
|
|
11
|
-
import ModalContext from './ModalContext';
|
|
12
|
-
import ModalHeader from './ModalHeader';
|
|
13
|
-
import ModalTitle from './ModalTitle';
|
|
14
|
-
import ModalBody from './ModalBody';
|
|
15
|
-
import ModalFooter from './ModalFooter';
|
|
16
|
-
import { ExtendedTextStyle, ExtendedViewStyle, StyleProp } from '../../types';
|
|
17
|
-
|
|
18
|
-
export interface ModalProps extends
|
|
19
|
-
visible: boolean;
|
|
20
|
-
size?: 'sm' | 'lg' | 'xl';
|
|
21
|
-
backdrop?: boolean | 'static';
|
|
22
|
-
scrollable?: boolean;
|
|
23
|
-
centered?: boolean;
|
|
24
|
-
onToggle: () => void;
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
| 'flex-
|
|
34
|
-
| '
|
|
35
|
-
| '
|
|
36
|
-
| 'space-
|
|
37
|
-
| 'space-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
// overflow-
|
|
50
|
-
//
|
|
51
|
-
//
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
//
|
|
57
|
-
//
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
width:
|
|
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
|
-
background-
|
|
94
|
-
|
|
95
|
-
border: $modal-content-border-
|
|
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
|
-
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { Modal as BaseModal, SafeAreaView } from 'react-native';
|
|
3
|
+
import { OverlayProvider } from '@react-native-aria/overlays';
|
|
4
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
+
import { getStyles } from '../../utils';
|
|
6
|
+
import css from '../../style/css';
|
|
7
|
+
import ScrollView, { ScrollViewRef, ScrollViewProps } from '../ScrollView';
|
|
8
|
+
import View, { ViewRef } from '../View';
|
|
9
|
+
import BackdropHandler from '../helpers/BackdropHandler';
|
|
10
|
+
import useModal from './useModal';
|
|
11
|
+
import ModalContext from './ModalContext';
|
|
12
|
+
import ModalHeader from './ModalHeader';
|
|
13
|
+
import ModalTitle from './ModalTitle';
|
|
14
|
+
import ModalBody from './ModalBody';
|
|
15
|
+
import ModalFooter from './ModalFooter';
|
|
16
|
+
import { ExtendedTextStyle, ExtendedViewStyle, StyleProp } from '../../types';
|
|
17
|
+
|
|
18
|
+
export interface ModalProps extends ScrollViewProps {
|
|
19
|
+
visible: boolean;
|
|
20
|
+
size?: 'sm' | 'lg' | 'xl';
|
|
21
|
+
backdrop?: boolean | 'static';
|
|
22
|
+
scrollable?: boolean;
|
|
23
|
+
centered?: boolean;
|
|
24
|
+
onToggle: () => void;
|
|
25
|
+
dialogStyle?: StyleProp<ExtendedViewStyle>;
|
|
26
|
+
contentStyle?: StyleProp<ExtendedViewStyle>;
|
|
27
|
+
dialogTextStyle?: StyleProp<ExtendedTextStyle>;
|
|
28
|
+
contentTextStyle?: StyleProp<ExtendedTextStyle>;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
type JustifyContentValue =
|
|
32
|
+
| 'flex-start'
|
|
33
|
+
| 'flex-end'
|
|
34
|
+
| 'center'
|
|
35
|
+
| 'space-between'
|
|
36
|
+
| 'space-around'
|
|
37
|
+
| 'space-evenly';
|
|
38
|
+
|
|
39
|
+
const styles = StyleSheet.create({
|
|
40
|
+
'.modal': css`
|
|
41
|
+
position: absolute; // fixed;
|
|
42
|
+
top: 0;
|
|
43
|
+
left: 0;
|
|
44
|
+
z-index: $zindex-modal;
|
|
45
|
+
// display: none;
|
|
46
|
+
width: 100%;
|
|
47
|
+
height: 100%;
|
|
48
|
+
// overflow-x: hidden;
|
|
49
|
+
// overflow-y: auto;
|
|
50
|
+
// Prevent Chrome on Windows from adding a focus outline. For details, see
|
|
51
|
+
// https://github.com/twbs/bootstrap/pull/10951.
|
|
52
|
+
@include platform(web) {
|
|
53
|
+
outline-width: 0; // outline: 0;
|
|
54
|
+
}
|
|
55
|
+
// We deliberately don't use "-webkit-overflow-scrolling: touch;" due to a
|
|
56
|
+
// gnarly iOS Safari bug: https://bugs.webkit.org/show_bug.cgi?id=158342
|
|
57
|
+
// See also https://github.com/twbs/bootstrap/issues/17695
|
|
58
|
+
`,
|
|
59
|
+
'.modal-dialog': css`
|
|
60
|
+
position: relative;
|
|
61
|
+
width: auto;
|
|
62
|
+
margin: $modal-dialog-margin;
|
|
63
|
+
// allow clicks to pass through for custom click handling to close modal
|
|
64
|
+
pointer-events: auto; // pointer-events: none;
|
|
65
|
+
|
|
66
|
+
@include media-breakpoint-up(sm) {
|
|
67
|
+
width: 100%; // added for bootstrap-rn
|
|
68
|
+
max-width: $modal-md;
|
|
69
|
+
margin: $modal-dialog-margin-y-sm-up auto;
|
|
70
|
+
}
|
|
71
|
+
`,
|
|
72
|
+
'.modal-dialog-scrollable': css`
|
|
73
|
+
flex-shrink: 1; // added for bootstrap-rn
|
|
74
|
+
// height: calc(100% - var(--#{$prefix}modal-margin) * 2);
|
|
75
|
+
`,
|
|
76
|
+
'.modal-dialog-scrollable .modal-content': css`
|
|
77
|
+
max-height: 100%;
|
|
78
|
+
overflow: hidden;
|
|
79
|
+
`,
|
|
80
|
+
'.modal-dialog-centered': css`
|
|
81
|
+
display: flex;
|
|
82
|
+
// align-items: center;
|
|
83
|
+
// min-height: calc(100% - var(--#{$prefix}modal-margin) * 2);
|
|
84
|
+
`,
|
|
85
|
+
'.modal-content': css`
|
|
86
|
+
position: relative;
|
|
87
|
+
display: flex;
|
|
88
|
+
flex-direction: column;
|
|
89
|
+
width: 100%; // Ensure ".modal-content" extends the full width of the parent ".modal-dialog"
|
|
90
|
+
// counteract the pointer-events: none; in the .modal-dialog
|
|
91
|
+
pointer-events: auto;
|
|
92
|
+
background-color: $modal-content-bg;
|
|
93
|
+
// background-clip: padding-box;
|
|
94
|
+
border: $modal-content-border-width solid $modal-content-border-color;
|
|
95
|
+
border-radius: $modal-content-border-radius;
|
|
96
|
+
// @include box-shadow($modal-content-box-shadow-xs);
|
|
97
|
+
// Remove focus outline from opened modal
|
|
98
|
+
// outline: 0;
|
|
99
|
+
|
|
100
|
+
@include media-breakpoint-up(sm) {
|
|
101
|
+
// @include box-shadow($modal-content-box-shadow-sm-up);
|
|
102
|
+
}
|
|
103
|
+
`,
|
|
104
|
+
'.modal-content --text': css`
|
|
105
|
+
color: $modal-content-color;
|
|
106
|
+
`,
|
|
107
|
+
'.modal-backdrop': css`
|
|
108
|
+
position: absolute;
|
|
109
|
+
top: 0;
|
|
110
|
+
left: 0;
|
|
111
|
+
z-index: $zindex-modal-backdrop;
|
|
112
|
+
width: 100%;
|
|
113
|
+
height: 100%;
|
|
114
|
+
background-color: $modal-backdrop-bg;
|
|
115
|
+
opacity: $modal-backdrop-opacity;
|
|
116
|
+
`,
|
|
117
|
+
'.modal-sm': css`
|
|
118
|
+
@include media-breakpoint-up(sm) {
|
|
119
|
+
max-width: $modal-sm;
|
|
120
|
+
}
|
|
121
|
+
`,
|
|
122
|
+
'.modal-lg': css`
|
|
123
|
+
@include media-breakpoint-up(lg) {
|
|
124
|
+
max-width: $modal-lg;
|
|
125
|
+
}
|
|
126
|
+
`,
|
|
127
|
+
'.modal-xl': css`
|
|
128
|
+
@include media-breakpoint-up(lg) {
|
|
129
|
+
max-width: $modal-lg;
|
|
130
|
+
}
|
|
131
|
+
@include media-breakpoint-up(xl) {
|
|
132
|
+
max-width: $modal-xl;
|
|
133
|
+
}
|
|
134
|
+
`,
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
const Modal = React.forwardRef<ViewRef | ScrollViewRef, ModalProps>(
|
|
138
|
+
(props, ref) => {
|
|
139
|
+
const {
|
|
140
|
+
children,
|
|
141
|
+
visible,
|
|
142
|
+
size,
|
|
143
|
+
backdrop = true,
|
|
144
|
+
scrollable = false,
|
|
145
|
+
centered = false,
|
|
146
|
+
onToggle: handleToggle,
|
|
147
|
+
style,
|
|
148
|
+
contentContainerStyle,
|
|
149
|
+
dialogStyle,
|
|
150
|
+
contentStyle,
|
|
151
|
+
textStyle,
|
|
152
|
+
dialogTextStyle,
|
|
153
|
+
contentTextStyle,
|
|
154
|
+
...elementProps
|
|
155
|
+
} = props;
|
|
156
|
+
|
|
157
|
+
const dialogRef = useRef(null);
|
|
158
|
+
|
|
159
|
+
const modal = useModal(visible, scrollable);
|
|
160
|
+
|
|
161
|
+
const backdropClasses = getStyles(styles, ['.modal-backdrop']);
|
|
162
|
+
const classes = getStyles(styles, ['.modal']);
|
|
163
|
+
const dialogClasses = getStyles(styles, [
|
|
164
|
+
'.modal-dialog',
|
|
165
|
+
size === 'sm' && '.modal-sm',
|
|
166
|
+
size === 'lg' && '.modal-lg',
|
|
167
|
+
size === 'xl' && '.modal-xl',
|
|
168
|
+
scrollable && '.modal-dialog-scrollable',
|
|
169
|
+
centered && '.modal-dialog-centered',
|
|
170
|
+
]);
|
|
171
|
+
const contentClasses = getStyles(styles, [
|
|
172
|
+
'.modal-content',
|
|
173
|
+
scrollable && '.modal-dialog-scrollable .modal-content',
|
|
174
|
+
]);
|
|
175
|
+
const contentTextClasses = getStyles(styles, ['.modal-content --text']);
|
|
176
|
+
|
|
177
|
+
// If scrollable we use a ScrollView in ModalBody, so we can use a View here.
|
|
178
|
+
const FlexView = scrollable ? View : ScrollView;
|
|
179
|
+
|
|
180
|
+
const centeredStyle = centered && {
|
|
181
|
+
justifyContent: 'center' as JustifyContentValue,
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
return (
|
|
185
|
+
<BaseModal transparent visible={visible} onRequestClose={handleToggle}>
|
|
186
|
+
{backdrop && <View style={backdropClasses} />}
|
|
187
|
+
<FlexView
|
|
188
|
+
{...elementProps}
|
|
189
|
+
// @ts-expect-error Type of ref depends on component.
|
|
190
|
+
ref={ref}
|
|
191
|
+
style={[classes, scrollable && centeredStyle, style]}
|
|
192
|
+
textStyle={textStyle}
|
|
193
|
+
contentContainerStyle={
|
|
194
|
+
scrollable
|
|
195
|
+
? undefined
|
|
196
|
+
: [{ flexGrow: 1 }, centeredStyle, contentContainerStyle]
|
|
197
|
+
}
|
|
198
|
+
>
|
|
199
|
+
<BackdropHandler
|
|
200
|
+
dialogRef={dialogRef}
|
|
201
|
+
onClose={handleToggle}
|
|
202
|
+
backdrop={backdrop}
|
|
203
|
+
/>
|
|
204
|
+
<SafeAreaView style={{ flexShrink: 1 }}>
|
|
205
|
+
<View
|
|
206
|
+
ref={dialogRef}
|
|
207
|
+
style={[dialogClasses, dialogStyle]}
|
|
208
|
+
textStyle={dialogTextStyle}
|
|
209
|
+
>
|
|
210
|
+
<View
|
|
211
|
+
style={[contentClasses, contentStyle]}
|
|
212
|
+
textStyle={[contentTextClasses, contentTextStyle]}
|
|
213
|
+
>
|
|
214
|
+
<ModalContext.Provider value={modal}>
|
|
215
|
+
<OverlayProvider>{children}</OverlayProvider>
|
|
216
|
+
</ModalContext.Provider>
|
|
217
|
+
</View>
|
|
218
|
+
</View>
|
|
219
|
+
</SafeAreaView>
|
|
220
|
+
</FlexView>
|
|
221
|
+
</BaseModal>
|
|
222
|
+
);
|
|
223
|
+
},
|
|
224
|
+
);
|
|
225
|
+
|
|
226
|
+
Modal.displayName = 'Modal';
|
|
227
|
+
|
|
228
|
+
export default Object.assign(Modal, {
|
|
229
|
+
Context: ModalContext,
|
|
230
|
+
Header: ModalHeader,
|
|
231
|
+
Title: ModalTitle,
|
|
232
|
+
Body: ModalBody,
|
|
233
|
+
Footer: ModalFooter,
|
|
234
|
+
});
|
|
@@ -1,56 +1,52 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
{
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
ModalBody.displayName = 'ModalBody';
|
|
55
|
-
|
|
56
|
-
export default ModalBody;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import css from '../../style/css';
|
|
3
|
+
import { getStyles } from '../../utils';
|
|
4
|
+
import useForcedContext from '../../hooks/useForcedContext';
|
|
5
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
6
|
+
import View, { ViewRef } from '../View';
|
|
7
|
+
import ScrollView, { ScrollViewRef, ScrollViewProps } from '../ScrollView';
|
|
8
|
+
import ModalContext from './ModalContext';
|
|
9
|
+
|
|
10
|
+
export interface ModalBodyProps extends ScrollViewProps {}
|
|
11
|
+
|
|
12
|
+
const styles = StyleSheet.create({
|
|
13
|
+
'.modal-body': css`
|
|
14
|
+
position: relative;
|
|
15
|
+
// Enable "flex-grow: 1" so that the body take up as much space as possible
|
|
16
|
+
// when there should be a fixed height on ".modal-dialog".
|
|
17
|
+
// Note from bootstrap-rn: Centered modals do not work with this style, but
|
|
18
|
+
// everything just works fine without this style.
|
|
19
|
+
// flex: 1 1 auto;
|
|
20
|
+
padding: $modal-inner-padding;
|
|
21
|
+
`,
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
const ModalBody = React.forwardRef<ViewRef | ScrollViewRef, ModalBodyProps>(
|
|
25
|
+
(props, ref) => {
|
|
26
|
+
const { children, style, contentContainerStyle, ...elementProps } = props;
|
|
27
|
+
|
|
28
|
+
const { scrollable } = useForcedContext(ModalContext);
|
|
29
|
+
|
|
30
|
+
const classes = getStyles(styles, ['.modal-body']);
|
|
31
|
+
|
|
32
|
+
const FlexView = scrollable ? ScrollView : View;
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<FlexView
|
|
36
|
+
{...elementProps}
|
|
37
|
+
// @ts-expect-error Type of ref depends on component.
|
|
38
|
+
ref={ref}
|
|
39
|
+
style={scrollable ? style : [classes, style]}
|
|
40
|
+
contentContainerStyle={
|
|
41
|
+
scrollable ? [classes, contentContainerStyle] : undefined
|
|
42
|
+
}
|
|
43
|
+
>
|
|
44
|
+
{children}
|
|
45
|
+
</FlexView>
|
|
46
|
+
);
|
|
47
|
+
},
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
ModalBody.displayName = 'ModalBody';
|
|
51
|
+
|
|
52
|
+
export default ModalBody;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export interface ModalContextProps {
|
|
4
4
|
scrollable: boolean;
|
|
5
|
-
}
|
|
5
|
+
}
|
|
6
6
|
|
|
7
|
-
const ModalContext = React.createContext<
|
|
7
|
+
const ModalContext = React.createContext<ModalContextProps | null>(null);
|
|
8
8
|
|
|
9
9
|
ModalContext.displayName = 'ModalContext';
|
|
10
10
|
|
|
@@ -6,10 +6,10 @@ import View, { ViewProps, ViewRef } from '../View';
|
|
|
6
6
|
import { GRID_BREAKPOINTS } from '../../theme/proxies';
|
|
7
7
|
import { infix, next } from '../../theme/breakpoints';
|
|
8
8
|
import { getStyles, each } from '../../utils';
|
|
9
|
-
import NavbarContext, {
|
|
9
|
+
import NavbarContext, { NavbarContextProps } from '../navbar/NavbarContext';
|
|
10
10
|
import NavContext, { NavVariant } from './NavContext';
|
|
11
11
|
import NavLink from './NavLink';
|
|
12
|
-
import TabContext, {
|
|
12
|
+
import TabContext, { TabContextProps } from './TabContext';
|
|
13
13
|
|
|
14
14
|
export interface NavProps extends ViewProps {
|
|
15
15
|
variant?: NavVariant;
|
|
@@ -47,8 +47,8 @@ const styles = StyleSheet.create({
|
|
|
47
47
|
});
|
|
48
48
|
|
|
49
49
|
const getRole = (
|
|
50
|
-
tabbable:
|
|
51
|
-
navbar:
|
|
50
|
+
tabbable: TabContextProps | null,
|
|
51
|
+
navbar: NavbarContextProps | null,
|
|
52
52
|
) => {
|
|
53
53
|
if (tabbable) {
|
|
54
54
|
return 'tablist';
|
|
@@ -2,11 +2,11 @@ import { createContext } from 'react';
|
|
|
2
2
|
|
|
3
3
|
export type NavVariant = 'tabs' | 'pills';
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
export interface NavContextProps {
|
|
6
6
|
variant?: NavVariant;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
|
|
9
|
-
const NavContext = createContext<
|
|
9
|
+
const NavContext = createContext<NavContextProps | null>(null);
|
|
10
10
|
|
|
11
11
|
NavContext.displayName = 'NavContext';
|
|
12
12
|
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface TabContextProps {
|
|
4
4
|
identifier: string;
|
|
5
5
|
activeTarget: string;
|
|
6
6
|
setActiveTarget: (target: string) => void;
|
|
7
|
-
}
|
|
7
|
+
}
|
|
8
8
|
|
|
9
|
-
const TabContext = createContext<
|
|
9
|
+
const TabContext = createContext<TabContextProps | null>(null);
|
|
10
10
|
|
|
11
11
|
TabContext.displayName = 'TabContext';
|
|
12
12
|
|