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,234 +1,243 @@
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
+ 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
+ });