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