bootstrap-rn 0.4.4 → 0.4.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/module/components/Body.js +2 -2
- package/lib/module/components/Body.js.map +1 -1
- package/lib/module/components/SafeAreaView.js +42 -0
- package/lib/module/components/SafeAreaView.js.map +1 -0
- package/lib/module/components/helpers/Overlay.js +2 -13
- package/lib/module/components/helpers/Overlay.js.map +1 -1
- package/lib/module/components/modal/Modal.js +7 -3
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/module/components/offcanvas/Offcanvas.js +65 -67
- package/lib/module/components/offcanvas/Offcanvas.js.map +1 -1
- package/lib/module/components/popover/PopoverArrow.js +28 -0
- package/lib/module/components/popover/PopoverArrow.js.map +1 -1
- package/lib/module/components/tooltip/TooltipArrow.js +16 -0
- package/lib/module/components/tooltip/TooltipArrow.js.map +1 -1
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/Body.d.ts.map +1 -1
- package/lib/typescript/components/SafeAreaView.d.ts +12 -0
- package/lib/typescript/components/SafeAreaView.d.ts.map +1 -0
- package/lib/typescript/components/helpers/Overlay.d.ts.map +1 -1
- package/lib/typescript/components/modal/Modal.d.ts.map +1 -1
- package/lib/typescript/components/offcanvas/Offcanvas.d.ts.map +1 -1
- package/lib/typescript/components/popover/PopoverArrow.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/TooltipArrow.d.ts.map +1 -1
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +85 -85
- package/src/components/Body.tsx +53 -58
- package/src/components/SafeAreaView.tsx +64 -0
- package/src/components/helpers/Overlay.tsx +2 -13
- package/src/components/modal/Modal.tsx +243 -234
- package/src/components/offcanvas/Offcanvas.tsx +245 -245
- package/src/components/popover/PopoverArrow.tsx +192 -164
- package/src/components/tooltip/TooltipArrow.tsx +118 -102
- package/src/index.ts +3 -0
- package/src/theme/variables.ts +1420 -1420
|
@@ -1,234 +1,243 @@
|
|
|
1
|
-
import React, { useRef } from 'react';
|
|
2
|
-
import { Modal as BaseModal,
|
|
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
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
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
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
//
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
//
|
|
91
|
-
pointer-events:
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
border
|
|
96
|
-
|
|
97
|
-
//
|
|
98
|
-
// outline
|
|
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
|
-
const
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
size === '
|
|
167
|
-
size === '
|
|
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
|
-
|
|
1
|
+
import React, { useRef } from 'react';
|
|
2
|
+
import { Modal as BaseModal, Platform } 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 SafeAreaView from '../SafeAreaView';
|
|
11
|
+
import useModal from './useModal';
|
|
12
|
+
import ModalContext from './ModalContext';
|
|
13
|
+
import ModalHeader from './ModalHeader';
|
|
14
|
+
import ModalTitle from './ModalTitle';
|
|
15
|
+
import ModalBody from './ModalBody';
|
|
16
|
+
import ModalFooter from './ModalFooter';
|
|
17
|
+
import { ExtendedTextStyle, ExtendedViewStyle, StyleProp } from '../../types';
|
|
18
|
+
|
|
19
|
+
export interface ModalProps extends ScrollViewProps {
|
|
20
|
+
visible: boolean;
|
|
21
|
+
size?: 'sm' | 'lg' | 'xl';
|
|
22
|
+
backdrop?: boolean | 'static';
|
|
23
|
+
scrollable?: boolean;
|
|
24
|
+
centered?: boolean;
|
|
25
|
+
onToggle: () => void;
|
|
26
|
+
dialogStyle?: StyleProp<ExtendedViewStyle>;
|
|
27
|
+
contentStyle?: StyleProp<ExtendedViewStyle>;
|
|
28
|
+
dialogTextStyle?: StyleProp<ExtendedTextStyle>;
|
|
29
|
+
contentTextStyle?: StyleProp<ExtendedTextStyle>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
type JustifyContentValue =
|
|
33
|
+
| 'flex-start'
|
|
34
|
+
| 'flex-end'
|
|
35
|
+
| 'center'
|
|
36
|
+
| 'space-between'
|
|
37
|
+
| 'space-around'
|
|
38
|
+
| 'space-evenly';
|
|
39
|
+
|
|
40
|
+
const styles = StyleSheet.create({
|
|
41
|
+
'.modal': css`
|
|
42
|
+
position: absolute; // fixed;
|
|
43
|
+
top: 0;
|
|
44
|
+
left: 0;
|
|
45
|
+
z-index: $zindex-modal;
|
|
46
|
+
// display: none;
|
|
47
|
+
width: 100%;
|
|
48
|
+
height: 100%;
|
|
49
|
+
// overflow-x: hidden;
|
|
50
|
+
// overflow-y: auto;
|
|
51
|
+
// Prevent Chrome on Windows from adding a focus outline. For details, see
|
|
52
|
+
// https://github.com/twbs/bootstrap/pull/10951.
|
|
53
|
+
@include platform(web) {
|
|
54
|
+
outline-width: 0; // outline: 0;
|
|
55
|
+
}
|
|
56
|
+
// We deliberately don't use "-webkit-overflow-scrolling: touch;" due to a
|
|
57
|
+
// gnarly iOS Safari bug: https://bugs.webkit.org/show_bug.cgi?id=158342
|
|
58
|
+
// See also https://github.com/twbs/bootstrap/issues/17695
|
|
59
|
+
`,
|
|
60
|
+
'.modal-dialog': css`
|
|
61
|
+
position: relative;
|
|
62
|
+
width: auto;
|
|
63
|
+
margin: $modal-dialog-margin;
|
|
64
|
+
// allow clicks to pass through for custom click handling to close modal
|
|
65
|
+
pointer-events: auto; // pointer-events: none;
|
|
66
|
+
|
|
67
|
+
@include media-breakpoint-up(sm) {
|
|
68
|
+
width: 100%; // added for bootstrap-rn
|
|
69
|
+
max-width: $modal-md;
|
|
70
|
+
margin: $modal-dialog-margin-y-sm-up auto;
|
|
71
|
+
}
|
|
72
|
+
`,
|
|
73
|
+
'.modal-dialog-scrollable': css`
|
|
74
|
+
flex-shrink: 1; // added for bootstrap-rn
|
|
75
|
+
// height: calc(100% - var(--#{$prefix}modal-margin) * 2);
|
|
76
|
+
`,
|
|
77
|
+
'.modal-dialog-scrollable .modal-content': css`
|
|
78
|
+
max-height: 100%;
|
|
79
|
+
overflow: hidden;
|
|
80
|
+
`,
|
|
81
|
+
'.modal-dialog-centered': css`
|
|
82
|
+
display: flex;
|
|
83
|
+
// align-items: center;
|
|
84
|
+
// min-height: calc(100% - var(--#{$prefix}modal-margin) * 2);
|
|
85
|
+
`,
|
|
86
|
+
'.modal-content': css`
|
|
87
|
+
position: relative;
|
|
88
|
+
display: flex;
|
|
89
|
+
flex-direction: column;
|
|
90
|
+
width: 100%; // Ensure ".modal-content" extends the full width of the parent ".modal-dialog"
|
|
91
|
+
// counteract the pointer-events: none; in the .modal-dialog
|
|
92
|
+
pointer-events: auto;
|
|
93
|
+
background-color: $modal-content-bg;
|
|
94
|
+
// background-clip: padding-box;
|
|
95
|
+
border: $modal-content-border-width solid $modal-content-border-color;
|
|
96
|
+
border-radius: $modal-content-border-radius;
|
|
97
|
+
// @include box-shadow($modal-content-box-shadow-xs);
|
|
98
|
+
// Remove focus outline from opened modal
|
|
99
|
+
// outline: 0;
|
|
100
|
+
|
|
101
|
+
@include media-breakpoint-up(sm) {
|
|
102
|
+
// @include box-shadow($modal-content-box-shadow-sm-up);
|
|
103
|
+
}
|
|
104
|
+
`,
|
|
105
|
+
'.modal-content --text': css`
|
|
106
|
+
color: $modal-content-color;
|
|
107
|
+
`,
|
|
108
|
+
'.modal-backdrop': css`
|
|
109
|
+
position: absolute;
|
|
110
|
+
top: 0;
|
|
111
|
+
left: 0;
|
|
112
|
+
z-index: $zindex-modal-backdrop;
|
|
113
|
+
width: 100%;
|
|
114
|
+
height: 100%;
|
|
115
|
+
background-color: $modal-backdrop-bg;
|
|
116
|
+
opacity: $modal-backdrop-opacity;
|
|
117
|
+
`,
|
|
118
|
+
'.modal-sm': css`
|
|
119
|
+
@include media-breakpoint-up(sm) {
|
|
120
|
+
max-width: $modal-sm;
|
|
121
|
+
}
|
|
122
|
+
`,
|
|
123
|
+
'.modal-lg': css`
|
|
124
|
+
@include media-breakpoint-up(lg) {
|
|
125
|
+
max-width: $modal-lg;
|
|
126
|
+
}
|
|
127
|
+
`,
|
|
128
|
+
'.modal-xl': css`
|
|
129
|
+
@include media-breakpoint-up(lg) {
|
|
130
|
+
max-width: $modal-lg;
|
|
131
|
+
}
|
|
132
|
+
@include media-breakpoint-up(xl) {
|
|
133
|
+
max-width: $modal-xl;
|
|
134
|
+
}
|
|
135
|
+
`,
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
const Modal = React.forwardRef<ViewRef | ScrollViewRef, ModalProps>(
|
|
139
|
+
(props, ref) => {
|
|
140
|
+
const {
|
|
141
|
+
children,
|
|
142
|
+
visible,
|
|
143
|
+
size,
|
|
144
|
+
backdrop = true,
|
|
145
|
+
scrollable = false,
|
|
146
|
+
centered = false,
|
|
147
|
+
onToggle: handleToggle,
|
|
148
|
+
style,
|
|
149
|
+
contentContainerStyle,
|
|
150
|
+
dialogStyle,
|
|
151
|
+
contentStyle,
|
|
152
|
+
textStyle,
|
|
153
|
+
dialogTextStyle,
|
|
154
|
+
contentTextStyle,
|
|
155
|
+
...elementProps
|
|
156
|
+
} = props;
|
|
157
|
+
|
|
158
|
+
const dialogRef = useRef(null);
|
|
159
|
+
|
|
160
|
+
const modal = useModal(visible, scrollable);
|
|
161
|
+
|
|
162
|
+
const backdropClasses = getStyles(styles, ['.modal-backdrop']);
|
|
163
|
+
const classes = getStyles(styles, ['.modal']);
|
|
164
|
+
const dialogClasses = getStyles(styles, [
|
|
165
|
+
'.modal-dialog',
|
|
166
|
+
size === 'sm' && '.modal-sm',
|
|
167
|
+
size === 'lg' && '.modal-lg',
|
|
168
|
+
size === 'xl' && '.modal-xl',
|
|
169
|
+
scrollable && '.modal-dialog-scrollable',
|
|
170
|
+
centered && '.modal-dialog-centered',
|
|
171
|
+
]);
|
|
172
|
+
const contentClasses = getStyles(styles, [
|
|
173
|
+
'.modal-content',
|
|
174
|
+
scrollable && '.modal-dialog-scrollable .modal-content',
|
|
175
|
+
]);
|
|
176
|
+
const contentTextClasses = getStyles(styles, ['.modal-content --text']);
|
|
177
|
+
|
|
178
|
+
// If scrollable we use a ScrollView in ModalBody, so we can use a View here.
|
|
179
|
+
const FlexView = scrollable ? View : ScrollView;
|
|
180
|
+
|
|
181
|
+
const centeredStyle = centered && {
|
|
182
|
+
justifyContent: 'center' as JustifyContentValue,
|
|
183
|
+
};
|
|
184
|
+
|
|
185
|
+
return (
|
|
186
|
+
<BaseModal
|
|
187
|
+
transparent
|
|
188
|
+
// Modal is only shown correctly on older Android versions if we set this.
|
|
189
|
+
navigationBarTranslucent={
|
|
190
|
+
Platform.OS === 'android' && Platform.constants.Version < 35
|
|
191
|
+
}
|
|
192
|
+
visible={visible}
|
|
193
|
+
onRequestClose={handleToggle}
|
|
194
|
+
>
|
|
195
|
+
{backdrop && <View style={backdropClasses} />}
|
|
196
|
+
<FlexView
|
|
197
|
+
{...elementProps}
|
|
198
|
+
// @ts-expect-error Type of ref depends on component.
|
|
199
|
+
ref={ref}
|
|
200
|
+
style={[classes, scrollable && centeredStyle, style]}
|
|
201
|
+
textStyle={textStyle}
|
|
202
|
+
contentContainerStyle={
|
|
203
|
+
scrollable
|
|
204
|
+
? undefined
|
|
205
|
+
: [{ flexGrow: 1 }, centeredStyle, contentContainerStyle]
|
|
206
|
+
}
|
|
207
|
+
>
|
|
208
|
+
<BackdropHandler
|
|
209
|
+
dialogRef={dialogRef}
|
|
210
|
+
onClose={handleToggle}
|
|
211
|
+
backdrop={backdrop}
|
|
212
|
+
/>
|
|
213
|
+
<SafeAreaView style={scrollable && { flexShrink: 1 }}>
|
|
214
|
+
<View
|
|
215
|
+
ref={dialogRef}
|
|
216
|
+
style={[dialogClasses, dialogStyle]}
|
|
217
|
+
textStyle={dialogTextStyle}
|
|
218
|
+
>
|
|
219
|
+
<View
|
|
220
|
+
style={[contentClasses, contentStyle]}
|
|
221
|
+
textStyle={[contentTextClasses, contentTextStyle]}
|
|
222
|
+
>
|
|
223
|
+
<ModalContext.Provider value={modal}>
|
|
224
|
+
<OverlayProvider>{children}</OverlayProvider>
|
|
225
|
+
</ModalContext.Provider>
|
|
226
|
+
</View>
|
|
227
|
+
</View>
|
|
228
|
+
</SafeAreaView>
|
|
229
|
+
</FlexView>
|
|
230
|
+
</BaseModal>
|
|
231
|
+
);
|
|
232
|
+
},
|
|
233
|
+
);
|
|
234
|
+
|
|
235
|
+
Modal.displayName = 'Modal';
|
|
236
|
+
|
|
237
|
+
export default Object.assign(Modal, {
|
|
238
|
+
Context: ModalContext,
|
|
239
|
+
Header: ModalHeader,
|
|
240
|
+
Title: ModalTitle,
|
|
241
|
+
Body: ModalBody,
|
|
242
|
+
Footer: ModalFooter,
|
|
243
|
+
});
|