bootstrap-rn 0.4.3 → 0.4.5
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 +4 -2
- package/lib/module/components/Body.js.map +1 -1
- package/lib/module/components/SafeAreaView.js +44 -0
- package/lib/module/components/SafeAreaView.js.map +1 -0
- package/lib/module/components/close/CloseButton.js +1 -1
- package/lib/module/components/close/CloseButton.js.map +1 -1
- package/lib/module/components/forms/internals/FormCheckInputNative.js +1 -1
- package/lib/module/components/forms/internals/FormCheckInputNative.js.map +1 -1
- package/lib/module/components/forms/internals/FormCheckInputWeb.js +4 -2
- package/lib/module/components/forms/internals/FormCheckInputWeb.js.map +1 -1
- package/lib/module/components/forms/internals/PickerNative.js +1 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/module/components/forms/internals/PickerWeb.js +5 -2
- package/lib/module/components/forms/internals/PickerWeb.js.map +1 -1
- 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 +5 -2
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/module/components/navbar/NavbarToggler.js +1 -1
- package/lib/module/components/navbar/NavbarToggler.js.map +1 -1
- package/lib/module/components/offcanvas/Offcanvas.js +65 -66
- 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/hooks/useBackground.js +4 -78
- package/lib/module/hooks/useBackground.js.map +1 -1
- package/lib/module/hooks/{useBackground.native.js → useBackgroundNative.js} +2 -2
- package/lib/module/hooks/useBackgroundNative.js.map +1 -0
- package/lib/module/hooks/useBackgroundWeb.js +81 -0
- package/lib/module/hooks/useBackgroundWeb.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/components/Body.d.ts +2 -2
- package/lib/typescript/components/Body.d.ts.map +1 -1
- package/lib/typescript/components/SafeAreaView.d.ts +13 -0
- package/lib/typescript/components/SafeAreaView.d.ts.map +1 -0
- package/lib/typescript/components/forms/internals/FormCheckInputWeb.d.ts.map +1 -1
- package/lib/typescript/components/forms/internals/PickerNative.d.ts.map +1 -1
- package/lib/typescript/components/forms/internals/PickerWeb.d.ts.map +1 -1
- 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/hooks/useBackground.d.ts +4 -5
- package/lib/typescript/hooks/useBackground.d.ts.map +1 -1
- package/lib/typescript/hooks/{useBackground.native.d.ts → useBackgroundNative.d.ts} +2 -2
- package/lib/typescript/hooks/useBackgroundNative.d.ts.map +1 -0
- package/lib/typescript/hooks/useBackgroundWeb.d.ts +6 -0
- package/lib/typescript/hooks/useBackgroundWeb.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +2 -0
- package/lib/typescript/index.d.ts.map +1 -1
- package/package.json +87 -85
- package/src/components/Body.tsx +68 -58
- package/src/components/SafeAreaView.tsx +71 -0
- package/src/components/forms/internals/FormCheckInputWeb.tsx +79 -78
- package/src/components/forms/internals/PickerNative.tsx +3 -2
- package/src/components/forms/internals/PickerWeb.tsx +85 -78
- package/src/components/helpers/Overlay.tsx +2 -13
- package/src/components/modal/Modal.tsx +241 -234
- package/src/components/offcanvas/Offcanvas.tsx +247 -245
- package/src/components/popover/PopoverArrow.tsx +192 -164
- package/src/components/tooltip/TooltipArrow.tsx +118 -102
- package/src/hooks/useBackground.tsx +4 -122
- package/src/hooks/{useBackground.native.tsx → useBackgroundNative.tsx} +1 -1
- package/src/hooks/useBackgroundWeb.tsx +123 -0
- package/src/index.ts +3 -0
- package/src/style/transform/index.ts +245 -245
- package/src/theme/variables.ts +1420 -1420
- package/lib/module/hooks/useBackground.native.js.map +0 -1
- package/lib/typescript/hooks/useBackground.native.d.ts.map +0 -1
|
@@ -1,234 +1,241 @@
|
|
|
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 } 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
|
+
statusBarTranslucent
|
|
189
|
+
navigationBarTranslucent
|
|
190
|
+
visible={visible}
|
|
191
|
+
onRequestClose={handleToggle}
|
|
192
|
+
>
|
|
193
|
+
{backdrop && <View style={backdropClasses} />}
|
|
194
|
+
<FlexView
|
|
195
|
+
{...elementProps}
|
|
196
|
+
// @ts-expect-error Type of ref depends on component.
|
|
197
|
+
ref={ref}
|
|
198
|
+
style={[classes, scrollable && centeredStyle, style]}
|
|
199
|
+
textStyle={textStyle}
|
|
200
|
+
contentContainerStyle={
|
|
201
|
+
scrollable
|
|
202
|
+
? undefined
|
|
203
|
+
: [{ flexGrow: 1 }, centeredStyle, contentContainerStyle]
|
|
204
|
+
}
|
|
205
|
+
>
|
|
206
|
+
<BackdropHandler
|
|
207
|
+
dialogRef={dialogRef}
|
|
208
|
+
onClose={handleToggle}
|
|
209
|
+
backdrop={backdrop}
|
|
210
|
+
/>
|
|
211
|
+
<SafeAreaView style={scrollable && { flexShrink: 1 }}>
|
|
212
|
+
<View
|
|
213
|
+
ref={dialogRef}
|
|
214
|
+
style={[dialogClasses, dialogStyle]}
|
|
215
|
+
textStyle={dialogTextStyle}
|
|
216
|
+
>
|
|
217
|
+
<View
|
|
218
|
+
style={[contentClasses, contentStyle]}
|
|
219
|
+
textStyle={[contentTextClasses, contentTextStyle]}
|
|
220
|
+
>
|
|
221
|
+
<ModalContext.Provider value={modal}>
|
|
222
|
+
<OverlayProvider>{children}</OverlayProvider>
|
|
223
|
+
</ModalContext.Provider>
|
|
224
|
+
</View>
|
|
225
|
+
</View>
|
|
226
|
+
</SafeAreaView>
|
|
227
|
+
</FlexView>
|
|
228
|
+
</BaseModal>
|
|
229
|
+
);
|
|
230
|
+
},
|
|
231
|
+
);
|
|
232
|
+
|
|
233
|
+
Modal.displayName = 'Modal';
|
|
234
|
+
|
|
235
|
+
export default Object.assign(Modal, {
|
|
236
|
+
Context: ModalContext,
|
|
237
|
+
Header: ModalHeader,
|
|
238
|
+
Title: ModalTitle,
|
|
239
|
+
Body: ModalBody,
|
|
240
|
+
Footer: ModalFooter,
|
|
241
|
+
});
|