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,245 +1,245 @@
|
|
|
1
|
-
import React, { useContext, useRef } from 'react';
|
|
2
|
-
import { Modal as BaseModal,
|
|
3
|
-
import { OverlayProvider } from '@react-native-aria/overlays';
|
|
4
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
-
import css from '../../style/css';
|
|
6
|
-
import BackdropHandler from '../helpers/BackdropHandler';
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import
|
|
12
|
-
import
|
|
13
|
-
import
|
|
14
|
-
import
|
|
15
|
-
import
|
|
16
|
-
import
|
|
17
|
-
import
|
|
18
|
-
import
|
|
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
|
-
bottom: 0; // added for bootstrap-rn
|
|
77
|
-
right: 0;
|
|
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
|
-
border-
|
|
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
|
-
const
|
|
162
|
-
|
|
163
|
-
const
|
|
164
|
-
|
|
165
|
-
const
|
|
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
|
-
<View style={
|
|
211
|
-
<BackdropHandler
|
|
212
|
-
dialogRef={offcanvasRef}
|
|
213
|
-
onClose={handleToggle}
|
|
214
|
-
backdrop={backdrop}
|
|
215
|
-
/>
|
|
216
|
-
</View>
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
</
|
|
231
|
-
</
|
|
232
|
-
</View>
|
|
233
|
-
</SafeAreaView>
|
|
234
|
-
</BaseModal>
|
|
235
|
-
);
|
|
236
|
-
});
|
|
237
|
-
|
|
238
|
-
Offcanvas.displayName = 'Offcanvas';
|
|
239
|
-
|
|
240
|
-
export default Object.assign(Offcanvas, {
|
|
241
|
-
Context: OffcanvasContext,
|
|
242
|
-
Header: OffcanvasHeader,
|
|
243
|
-
Title: OffcanvasTitle,
|
|
244
|
-
Body: OffcanvasBody,
|
|
245
|
-
});
|
|
1
|
+
import React, { useContext, 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 css from '../../style/css';
|
|
6
|
+
import BackdropHandler from '../helpers/BackdropHandler';
|
|
7
|
+
import SafeAreaView from '../SafeAreaView';
|
|
8
|
+
import View, { ViewProps, ViewRef } from '../View';
|
|
9
|
+
import { GRID_BREAKPOINTS } from '../../theme/proxies';
|
|
10
|
+
import { infix, next } from '../../theme/breakpoints';
|
|
11
|
+
import { getStyles, each, concatRefs } from '../../utils';
|
|
12
|
+
import useMedia from '../../hooks/useMedia';
|
|
13
|
+
import NavbarContext from '../navbar/NavbarContext';
|
|
14
|
+
import useOffcanvas from './useOffcanvas';
|
|
15
|
+
import OffcanvasContext from './OffcanvasContext';
|
|
16
|
+
import OffcanvasHeader from './OffcanvasHeader';
|
|
17
|
+
import OffcanvasTitle from './OffcanvasTitle';
|
|
18
|
+
import OffcanvasBody from './OffcanvasBody';
|
|
19
|
+
import type {
|
|
20
|
+
ExtendedTextStyle,
|
|
21
|
+
ExtendedViewStyle,
|
|
22
|
+
StyleProp,
|
|
23
|
+
} from '../../types';
|
|
24
|
+
|
|
25
|
+
export interface OffcanvasProps extends ViewProps {
|
|
26
|
+
visible?: boolean;
|
|
27
|
+
placement?: 'top' | 'bottom' | 'start' | 'end';
|
|
28
|
+
backdrop?: boolean | 'static';
|
|
29
|
+
scroll?: boolean;
|
|
30
|
+
onToggle?: () => void;
|
|
31
|
+
dialogStyle?: StyleProp<ExtendedViewStyle>;
|
|
32
|
+
dialogTextStyle?: StyleProp<ExtendedTextStyle>;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const styles = StyleSheet.create({
|
|
36
|
+
'.offcanvas': css`
|
|
37
|
+
position: absolute; // fixed;
|
|
38
|
+
// bottom: 0;
|
|
39
|
+
z-index: $zindex-offcanvas;
|
|
40
|
+
display: flex;
|
|
41
|
+
flex-direction: column;
|
|
42
|
+
max-width: 100%;
|
|
43
|
+
// visibility: hidden;
|
|
44
|
+
`,
|
|
45
|
+
'.offcanvas --text': css`
|
|
46
|
+
color: $offcanvas-color;
|
|
47
|
+
`,
|
|
48
|
+
'.offcanvas-backdrop': css`
|
|
49
|
+
position: absolute;
|
|
50
|
+
top: 0;
|
|
51
|
+
left: 0;
|
|
52
|
+
z-index: $zindex-offcanvas-backdrop;
|
|
53
|
+
width: 100%;
|
|
54
|
+
height: 100%;
|
|
55
|
+
`,
|
|
56
|
+
'.offcanvas-backdrop-inset': css`
|
|
57
|
+
background-color: $offcanvas-backdrop-bg;
|
|
58
|
+
opacity: $offcanvas-backdrop-opacity;
|
|
59
|
+
`,
|
|
60
|
+
'.offcanvas-start': css`
|
|
61
|
+
top: 0;
|
|
62
|
+
bottom: 0; // added for bootstrap-rn
|
|
63
|
+
left: 0;
|
|
64
|
+
`,
|
|
65
|
+
'.offcanvas-end': css`
|
|
66
|
+
top: 0;
|
|
67
|
+
bottom: 0; // added for bootstrap-rn
|
|
68
|
+
right: 0;
|
|
69
|
+
`,
|
|
70
|
+
'.offcanvas-top': css`
|
|
71
|
+
top: 0;
|
|
72
|
+
right: 0;
|
|
73
|
+
left: 0;
|
|
74
|
+
`,
|
|
75
|
+
'.offcanvas-bottom': css`
|
|
76
|
+
bottom: 0; // added for bootstrap-rn
|
|
77
|
+
right: 0;
|
|
78
|
+
left: 0;
|
|
79
|
+
`,
|
|
80
|
+
'.offcanvas-inset': css`
|
|
81
|
+
max-width: 100%; // added for bootstrap-rn
|
|
82
|
+
max-height: 100%; // added for bootstrap-rn
|
|
83
|
+
background-color: $offcanvas-bg-color;
|
|
84
|
+
// background-clip: padding-box;
|
|
85
|
+
@include platform(web) {
|
|
86
|
+
outline-width: 0; // outline: 0;
|
|
87
|
+
}
|
|
88
|
+
// @include box-shadow($offcanvas-box-shadow);
|
|
89
|
+
// @include transition(transform $offcanvas-transition-duration ease-in-out);
|
|
90
|
+
`,
|
|
91
|
+
'.offcanvas-inset-start': css`
|
|
92
|
+
width: $offcanvas-horizontal-width;
|
|
93
|
+
border-right-width: $offcanvas-border-width;
|
|
94
|
+
border-style: solid;
|
|
95
|
+
border-color: $offcanvas-border-color;
|
|
96
|
+
// transform: translateX(-100%);
|
|
97
|
+
`,
|
|
98
|
+
'.offcanvas-inset-end': css`
|
|
99
|
+
width: $offcanvas-horizontal-width;
|
|
100
|
+
border-left-width: $offcanvas-border-width;
|
|
101
|
+
border-style: solid;
|
|
102
|
+
border-color: $offcanvas-border-color;
|
|
103
|
+
// transform: translateX(100%);
|
|
104
|
+
`,
|
|
105
|
+
'.offcanvas-inset-top': css`
|
|
106
|
+
height: $offcanvas-vertical-height;
|
|
107
|
+
max-height: 100%;
|
|
108
|
+
border-bottom-width: $offcanvas-border-width;
|
|
109
|
+
border-style: solid;
|
|
110
|
+
border-color: $offcanvas-border-color;
|
|
111
|
+
// transform: translateY(-100%);
|
|
112
|
+
`,
|
|
113
|
+
'.offcanvas-inset-bottom': css`
|
|
114
|
+
height: $offcanvas-vertical-height;
|
|
115
|
+
max-height: 100%;
|
|
116
|
+
width: 100%;
|
|
117
|
+
border-top-width: $offcanvas-border-width;
|
|
118
|
+
border-style: solid;
|
|
119
|
+
border-color: $offcanvas-border-color;
|
|
120
|
+
// transform: translateY(100%);
|
|
121
|
+
`,
|
|
122
|
+
// Navbar styles
|
|
123
|
+
...each(GRID_BREAKPOINTS, (breakpoint) => ({
|
|
124
|
+
[`.navbar-expand${infix(next(breakpoint))} .offcanvas`]: css`
|
|
125
|
+
@include media-breakpoint-up(${next(breakpoint)}) {
|
|
126
|
+
position: relative; // inherit;
|
|
127
|
+
bottom: 0;
|
|
128
|
+
// z-index: auto;
|
|
129
|
+
flex-grow: 1;
|
|
130
|
+
// visibility: visible !important; // stylelint-disable-line declaration-no-important
|
|
131
|
+
background-color: transparent;
|
|
132
|
+
border-right-width: 0;
|
|
133
|
+
border-left-width: 0;
|
|
134
|
+
// @include box-shadow(none);
|
|
135
|
+
// @include transition(none);
|
|
136
|
+
// transform: none;
|
|
137
|
+
}
|
|
138
|
+
`,
|
|
139
|
+
})),
|
|
140
|
+
});
|
|
141
|
+
|
|
142
|
+
const Offcanvas = React.forwardRef<ViewRef, OffcanvasProps>((props, ref) => {
|
|
143
|
+
const {
|
|
144
|
+
children,
|
|
145
|
+
visible = false,
|
|
146
|
+
placement = 'top',
|
|
147
|
+
backdrop = true,
|
|
148
|
+
scroll = false,
|
|
149
|
+
onToggle: handleToggle,
|
|
150
|
+
style,
|
|
151
|
+
dialogStyle,
|
|
152
|
+
textStyle,
|
|
153
|
+
dialogTextStyle,
|
|
154
|
+
...elementProps
|
|
155
|
+
} = props;
|
|
156
|
+
|
|
157
|
+
const media = useMedia();
|
|
158
|
+
const navbar = useContext(NavbarContext);
|
|
159
|
+
const offcanvasRef = useRef(null);
|
|
160
|
+
|
|
161
|
+
const offcanvas = useOffcanvas(visible, scroll);
|
|
162
|
+
|
|
163
|
+
const backdropClasses = getStyles(styles, ['.offcanvas-backdrop']);
|
|
164
|
+
const backdropInsetClasses = getStyles(styles, ['.offcanvas-backdrop-inset']);
|
|
165
|
+
const classes = getStyles(styles, [
|
|
166
|
+
'.offcanvas',
|
|
167
|
+
`.offcanvas-${placement}`,
|
|
168
|
+
navbar &&
|
|
169
|
+
navbar.expand &&
|
|
170
|
+
`.navbar-expand${
|
|
171
|
+
navbar.expand === true ? '' : `-${navbar.expand}`
|
|
172
|
+
} .offcanvas`,
|
|
173
|
+
]);
|
|
174
|
+
const dialogClasses = getStyles(styles, [
|
|
175
|
+
'.offcanvas-inset',
|
|
176
|
+
`.offcanvas-inset-${placement}`,
|
|
177
|
+
]);
|
|
178
|
+
const textClasses = getStyles(styles, ['.offcanvas-content --text']);
|
|
179
|
+
|
|
180
|
+
// Render children without modal for navbar.
|
|
181
|
+
if (
|
|
182
|
+
navbar &&
|
|
183
|
+
navbar.expand &&
|
|
184
|
+
(navbar.expand === true || media.up(navbar.expand))
|
|
185
|
+
) {
|
|
186
|
+
return (
|
|
187
|
+
<View
|
|
188
|
+
{...elementProps}
|
|
189
|
+
ref={ref}
|
|
190
|
+
style={[classes, style]}
|
|
191
|
+
textStyle={[textClasses, textStyle]}
|
|
192
|
+
>
|
|
193
|
+
{children}
|
|
194
|
+
</View>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return (
|
|
199
|
+
<BaseModal
|
|
200
|
+
transparent
|
|
201
|
+
// Modal is only shown correctly on older Android versions if we set this.
|
|
202
|
+
navigationBarTranslucent={
|
|
203
|
+
Platform.OS === 'android' && Platform.constants.Version < 35
|
|
204
|
+
}
|
|
205
|
+
visible={navbar ? navbar.expanded : visible}
|
|
206
|
+
onRequestClose={handleToggle}
|
|
207
|
+
>
|
|
208
|
+
{backdrop && (
|
|
209
|
+
<SafeAreaView style={backdropClasses}>
|
|
210
|
+
<View style={[{ flexGrow: 1 }, backdropInsetClasses]}>
|
|
211
|
+
<BackdropHandler
|
|
212
|
+
dialogRef={offcanvasRef}
|
|
213
|
+
onClose={handleToggle}
|
|
214
|
+
backdrop={backdrop}
|
|
215
|
+
/>
|
|
216
|
+
</View>
|
|
217
|
+
</SafeAreaView>
|
|
218
|
+
)}
|
|
219
|
+
<SafeAreaView
|
|
220
|
+
{...elementProps}
|
|
221
|
+
ref={concatRefs(offcanvasRef, ref)}
|
|
222
|
+
style={[classes, style]}
|
|
223
|
+
textStyle={[textClasses, textStyle]}
|
|
224
|
+
>
|
|
225
|
+
<View
|
|
226
|
+
style={[{ flexGrow: 1 }, dialogClasses, dialogStyle]}
|
|
227
|
+
textStyle={dialogTextStyle}
|
|
228
|
+
>
|
|
229
|
+
<OffcanvasContext.Provider value={offcanvas}>
|
|
230
|
+
<OverlayProvider>{children}</OverlayProvider>
|
|
231
|
+
</OffcanvasContext.Provider>
|
|
232
|
+
</View>
|
|
233
|
+
</SafeAreaView>
|
|
234
|
+
</BaseModal>
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
|
|
238
|
+
Offcanvas.displayName = 'Offcanvas';
|
|
239
|
+
|
|
240
|
+
export default Object.assign(Offcanvas, {
|
|
241
|
+
Context: OffcanvasContext,
|
|
242
|
+
Header: OffcanvasHeader,
|
|
243
|
+
Title: OffcanvasTitle,
|
|
244
|
+
Body: OffcanvasBody,
|
|
245
|
+
});
|