bootstrap-rn 0.3.4 → 0.3.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 (172) hide show
  1. package/lib/commonjs/components/Image.js.map +1 -1
  2. package/lib/commonjs/components/ImageBackground.js.map +1 -1
  3. package/lib/commonjs/components/Text.js.map +1 -1
  4. package/lib/commonjs/components/dropdown/DropdownMenu.js.map +1 -1
  5. package/lib/commonjs/components/forms/RadioGroup.js.map +1 -1
  6. package/lib/commonjs/components/forms/internals/PickerNative.js.map +1 -1
  7. package/lib/commonjs/components/modal/Modal.js +1 -1
  8. package/lib/commonjs/components/modal/Modal.js.map +1 -1
  9. package/lib/commonjs/components/modal/ModalBody.js +1 -1
  10. package/lib/commonjs/components/modal/ModalBody.js.map +1 -1
  11. package/lib/commonjs/components/modal/ModalContext.js.map +1 -1
  12. package/lib/commonjs/components/nav/Nav.js.map +1 -1
  13. package/lib/commonjs/components/nav/NavContext.js.map +1 -1
  14. package/lib/commonjs/components/nav/TabContext.js.map +1 -1
  15. package/lib/commonjs/components/navbar/NavbarContext.js.map +1 -1
  16. package/lib/commonjs/components/offcanvas/OffcanvasBody.js.map +1 -1
  17. package/lib/commonjs/components/offcanvas/OffcanvasContext.js.map +1 -1
  18. package/lib/commonjs/components/popover/injectPopover.js.map +1 -1
  19. package/lib/commonjs/components/toasts/ToastContainer.js +3 -1
  20. package/lib/commonjs/components/toasts/ToastContainer.js.map +1 -1
  21. package/lib/commonjs/components/tooltip/injectTooltip.js +0 -3
  22. package/lib/commonjs/components/tooltip/injectTooltip.js.map +1 -1
  23. package/lib/commonjs/index.d.ts +47 -8
  24. package/lib/commonjs/index.js +0 -56
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/style/StyleSheet.js +4 -2
  27. package/lib/commonjs/style/StyleSheet.js.map +1 -1
  28. package/lib/commonjs/style/makeUtilities.js.map +1 -1
  29. package/lib/commonjs/types.d.ts +6 -3
  30. package/lib/module/components/Image.js.map +1 -1
  31. package/lib/module/components/ImageBackground.js.map +1 -1
  32. package/lib/module/components/Text.js.map +1 -1
  33. package/lib/module/components/dropdown/DropdownMenu.js.map +1 -1
  34. package/lib/module/components/forms/RadioGroup.js.map +1 -1
  35. package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
  36. package/lib/module/components/modal/Modal.js +1 -1
  37. package/lib/module/components/modal/Modal.js.map +1 -1
  38. package/lib/module/components/modal/ModalBody.js +1 -1
  39. package/lib/module/components/modal/ModalBody.js.map +1 -1
  40. package/lib/module/components/modal/ModalContext.js.map +1 -1
  41. package/lib/module/components/nav/Nav.js.map +1 -1
  42. package/lib/module/components/nav/NavContext.js.map +1 -1
  43. package/lib/module/components/nav/TabContext.js.map +1 -1
  44. package/lib/module/components/navbar/NavbarContext.js.map +1 -1
  45. package/lib/module/components/offcanvas/OffcanvasBody.js.map +1 -1
  46. package/lib/module/components/offcanvas/OffcanvasContext.js.map +1 -1
  47. package/lib/module/components/popover/injectPopover.js.map +1 -1
  48. package/lib/module/components/toasts/ToastContainer.js +3 -1
  49. package/lib/module/components/toasts/ToastContainer.js.map +1 -1
  50. package/lib/module/components/tooltip/injectTooltip.js +0 -3
  51. package/lib/module/components/tooltip/injectTooltip.js.map +1 -1
  52. package/lib/module/index.d.ts +47 -8
  53. package/lib/module/index.js +0 -7
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/style/StyleSheet.js +4 -2
  56. package/lib/module/style/StyleSheet.js.map +1 -1
  57. package/lib/module/style/makeUtilities.js.map +1 -1
  58. package/lib/module/types.d.ts +6 -3
  59. package/lib/types/components/Image.d.ts.map +1 -1
  60. package/lib/types/components/ImageBackground.d.ts.map +1 -1
  61. package/lib/types/components/Text.d.ts +1 -1
  62. package/lib/types/components/Text.d.ts.map +1 -1
  63. package/lib/types/components/dropdown/Dropdown.d.ts +2 -11
  64. package/lib/types/components/dropdown/Dropdown.d.ts.map +1 -1
  65. package/lib/types/components/dropdown/DropdownContext.d.ts +2 -2
  66. package/lib/types/components/dropdown/DropdownContext.d.ts.map +1 -1
  67. package/lib/types/components/dropdown/DropdownMenu.d.ts +2 -2
  68. package/lib/types/components/dropdown/DropdownMenu.d.ts.map +1 -1
  69. package/lib/types/components/dropdown/DropdownToggle.d.ts +2 -2
  70. package/lib/types/components/dropdown/DropdownToggle.d.ts.map +1 -1
  71. package/lib/types/components/forms/Picker.d.ts +4 -4
  72. package/lib/types/components/forms/Picker.d.ts.map +1 -1
  73. package/lib/types/components/forms/PickerItem.d.ts +1 -1
  74. package/lib/types/components/forms/PickerItem.d.ts.map +1 -1
  75. package/lib/types/components/forms/Radio.d.ts +1 -1
  76. package/lib/types/components/forms/Radio.d.ts.map +1 -1
  77. package/lib/types/components/forms/RadioContext.d.ts +2 -2
  78. package/lib/types/components/forms/RadioContext.d.ts.map +1 -1
  79. package/lib/types/components/forms/RadioGroup.d.ts +2 -2
  80. package/lib/types/components/forms/RadioGroup.d.ts.map +1 -1
  81. package/lib/types/components/forms/internals/PickerNative.d.ts.map +1 -1
  82. package/lib/types/components/forms/internals/PickerNativeContext.d.ts +2 -2
  83. package/lib/types/components/forms/internals/PickerNativeContext.d.ts.map +1 -1
  84. package/lib/types/components/forms/internals/PickerNativeItem.d.ts +1 -1
  85. package/lib/types/components/forms/internals/PickerNativeItem.d.ts.map +1 -1
  86. package/lib/types/components/forms/internals/PickerWebItem.d.ts +1 -1
  87. package/lib/types/components/forms/internals/PickerWebItem.d.ts.map +1 -1
  88. package/lib/types/components/list-group/ListGroup.d.ts +1 -1
  89. package/lib/types/components/list-group/ListGroupItem.d.ts +13 -1
  90. package/lib/types/components/list-group/ListGroupItem.d.ts.map +1 -1
  91. package/lib/types/components/list-group/ListGroupItemAction.d.ts +2 -2
  92. package/lib/types/components/list-group/ListGroupItemAction.d.ts.map +1 -1
  93. package/lib/types/components/modal/Modal.d.ts +4 -7
  94. package/lib/types/components/modal/Modal.d.ts.map +1 -1
  95. package/lib/types/components/modal/ModalBody.d.ts +3 -6
  96. package/lib/types/components/modal/ModalBody.d.ts.map +1 -1
  97. package/lib/types/components/modal/ModalContext.d.ts +3 -3
  98. package/lib/types/components/modal/ModalContext.d.ts.map +1 -1
  99. package/lib/types/components/nav/Nav.d.ts +1 -3
  100. package/lib/types/components/nav/Nav.d.ts.map +1 -1
  101. package/lib/types/components/nav/NavContext.d.ts +3 -3
  102. package/lib/types/components/nav/NavContext.d.ts.map +1 -1
  103. package/lib/types/components/nav/Tab.d.ts +1 -1
  104. package/lib/types/components/nav/TabContext.d.ts +3 -3
  105. package/lib/types/components/nav/TabContext.d.ts.map +1 -1
  106. package/lib/types/components/navbar/Navbar.d.ts +1 -1
  107. package/lib/types/components/navbar/NavbarBrand.d.ts +2 -2
  108. package/lib/types/components/navbar/NavbarBrand.d.ts.map +1 -1
  109. package/lib/types/components/navbar/NavbarContext.d.ts +2 -2
  110. package/lib/types/components/navbar/NavbarContext.d.ts.map +1 -1
  111. package/lib/types/components/offcanvas/Offcanvas.d.ts +1 -3
  112. package/lib/types/components/offcanvas/Offcanvas.d.ts.map +1 -1
  113. package/lib/types/components/offcanvas/OffcanvasBody.d.ts +3 -4
  114. package/lib/types/components/offcanvas/OffcanvasBody.d.ts.map +1 -1
  115. package/lib/types/components/offcanvas/OffcanvasContext.d.ts +2 -2
  116. package/lib/types/components/offcanvas/OffcanvasContext.d.ts.map +1 -1
  117. package/lib/types/components/popover/injectPopover.d.ts +9 -12
  118. package/lib/types/components/popover/injectPopover.d.ts.map +1 -1
  119. package/lib/types/components/toasts/ToastContainer.d.ts +4 -2
  120. package/lib/types/components/toasts/ToastContainer.d.ts.map +1 -1
  121. package/lib/types/components/tooltip/injectTooltip.d.ts +8 -11
  122. package/lib/types/components/tooltip/injectTooltip.d.ts.map +1 -1
  123. package/lib/types/hooks/useBackground.native.d.ts +3 -1
  124. package/lib/types/hooks/useBackground.native.d.ts.map +1 -1
  125. package/lib/types/index.d.ts +47 -8
  126. package/lib/types/index.d.ts.map +1 -1
  127. package/lib/types/style/StyleSheet.d.ts +2 -3
  128. package/lib/types/style/StyleSheet.d.ts.map +1 -1
  129. package/lib/types/style/createStyle.d.ts +3 -1
  130. package/lib/types/style/createStyle.d.ts.map +1 -1
  131. package/lib/types/style/css.d.ts +3 -1
  132. package/lib/types/style/css.d.ts.map +1 -1
  133. package/lib/types/style/makeUtilities.d.ts +6 -2
  134. package/lib/types/style/makeUtilities.d.ts.map +1 -1
  135. package/lib/types/theme/variables.d.ts +3 -1
  136. package/lib/types/theme/variables.d.ts.map +1 -1
  137. package/lib/types/types.d.ts +6 -3
  138. package/lib/types/types.d.ts.map +1 -1
  139. package/package.json +80 -80
  140. package/src/components/Image.tsx +31 -27
  141. package/src/components/ImageBackground.tsx +48 -46
  142. package/src/components/Text.tsx +119 -117
  143. package/src/components/dropdown/DropdownContext.ts +2 -2
  144. package/src/components/dropdown/DropdownMenu.tsx +127 -125
  145. package/src/components/dropdown/DropdownToggle.ts +2 -2
  146. package/src/components/forms/Picker.tsx +191 -191
  147. package/src/components/forms/PickerItem.tsx +32 -32
  148. package/src/components/forms/Radio.tsx +37 -37
  149. package/src/components/forms/RadioContext.ts +13 -13
  150. package/src/components/forms/RadioGroup.tsx +42 -40
  151. package/src/components/forms/internals/PickerNative.tsx +193 -195
  152. package/src/components/forms/internals/PickerNativeContext.ts +14 -14
  153. package/src/components/forms/internals/PickerNativeItem.tsx +59 -59
  154. package/src/components/forms/internals/PickerWebItem.tsx +36 -36
  155. package/src/components/list-group/ListGroupItemAction.tsx +2 -2
  156. package/src/components/modal/Modal.tsx +234 -233
  157. package/src/components/modal/ModalBody.tsx +52 -56
  158. package/src/components/modal/ModalContext.ts +3 -3
  159. package/src/components/nav/Nav.tsx +4 -4
  160. package/src/components/nav/NavContext.ts +3 -3
  161. package/src/components/nav/TabContext.ts +3 -3
  162. package/src/components/navbar/NavbarBrand.tsx +2 -2
  163. package/src/components/navbar/NavbarContext.ts +2 -2
  164. package/src/components/offcanvas/OffcanvasBody.tsx +64 -66
  165. package/src/components/offcanvas/OffcanvasContext.ts +4 -2
  166. package/src/components/popover/injectPopover.tsx +97 -98
  167. package/src/components/toasts/ToastContainer.tsx +41 -39
  168. package/src/components/tooltip/injectTooltip.tsx +93 -96
  169. package/src/index.ts +242 -211
  170. package/src/style/StyleSheet.ts +149 -138
  171. package/src/style/makeUtilities.ts +79 -76
  172. package/src/types.ts +168 -162
@@ -1,233 +1,234 @@
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 from '../ScrollView';
8
- import View, { ViewProps, 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 ViewProps {
19
- visible: boolean;
20
- size?: 'sm' | 'lg' | 'xl';
21
- backdrop?: boolean | 'static';
22
- scrollable?: boolean;
23
- centered?: boolean;
24
- onToggle: () => void;
25
- contentContainerStyle?: StyleProp<ExtendedViewStyle>;
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, ModalProps>((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 We need to fix it in the future.
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
- Modal.displayName = 'Modal';
226
-
227
- export default Object.assign(Modal, {
228
- Context: ModalContext,
229
- Header: ModalHeader,
230
- Title: ModalTitle,
231
- Body: ModalBody,
232
- Footer: ModalFooter,
233
- });
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,56 +1,52 @@
1
- import React from 'react';
2
- import { View as BaseView, ScrollView as BaseScrollView } from 'react-native';
3
- import css from '../../style/css';
4
- import { getStyles } from '../../utils';
5
- import useForcedContext from '../../hooks/useForcedContext';
6
- import StyleSheet from '../../style/StyleSheet';
7
- import View, { ViewProps } from '../View';
8
- import ScrollView from '../ScrollView';
9
- import ModalContext from './ModalContext';
10
- import { ExtendedTextStyle, StyleProp } from '../../types';
11
-
12
- export interface ModalBodyProps extends ViewProps {
13
- contentContainerStyle?: StyleProp<ExtendedTextStyle>;
14
- }
15
-
16
- const styles = StyleSheet.create({
17
- '.modal-body': css`
18
- position: relative;
19
- // Enable "flex-grow: 1" so that the body take up as much space as possible
20
- // when there should be a fixed height on ".modal-dialog".
21
- // Note from bootstrap-rn: Centered modals do not work with this style, but
22
- // everything just works fine without this style.
23
- // flex: 1 1 auto;
24
- padding: $modal-inner-padding;
25
- `,
26
- });
27
-
28
- const ModalBody = React.forwardRef<BaseScrollView | BaseView, ModalBodyProps>(
29
- (props, ref) => {
30
- const { children, style, contentContainerStyle, ...elementProps } = props;
31
-
32
- const { scrollable } = useForcedContext(ModalContext);
33
-
34
- const classes = getStyles(styles, ['.modal-body']);
35
-
36
- const FlexView = scrollable ? ScrollView : View;
37
-
38
- return (
39
- <FlexView
40
- {...elementProps}
41
- // @ts-expect-error We need to fix it in the future.
42
- ref={ref}
43
- style={scrollable ? style : [classes, style]}
44
- contentContainerStyle={
45
- scrollable ? [classes, contentContainerStyle] : undefined
46
- }
47
- >
48
- {children}
49
- </FlexView>
50
- );
51
- },
52
- );
53
-
54
- ModalBody.displayName = 'ModalBody';
55
-
56
- export default ModalBody;
1
+ import React from 'react';
2
+ import css from '../../style/css';
3
+ import { getStyles } from '../../utils';
4
+ import useForcedContext from '../../hooks/useForcedContext';
5
+ import StyleSheet from '../../style/StyleSheet';
6
+ import View, { ViewRef } from '../View';
7
+ import ScrollView, { ScrollViewRef, ScrollViewProps } from '../ScrollView';
8
+ import ModalContext from './ModalContext';
9
+
10
+ export interface ModalBodyProps extends ScrollViewProps {}
11
+
12
+ const styles = StyleSheet.create({
13
+ '.modal-body': css`
14
+ position: relative;
15
+ // Enable "flex-grow: 1" so that the body take up as much space as possible
16
+ // when there should be a fixed height on ".modal-dialog".
17
+ // Note from bootstrap-rn: Centered modals do not work with this style, but
18
+ // everything just works fine without this style.
19
+ // flex: 1 1 auto;
20
+ padding: $modal-inner-padding;
21
+ `,
22
+ });
23
+
24
+ const ModalBody = React.forwardRef<ViewRef | ScrollViewRef, ModalBodyProps>(
25
+ (props, ref) => {
26
+ const { children, style, contentContainerStyle, ...elementProps } = props;
27
+
28
+ const { scrollable } = useForcedContext(ModalContext);
29
+
30
+ const classes = getStyles(styles, ['.modal-body']);
31
+
32
+ const FlexView = scrollable ? ScrollView : View;
33
+
34
+ return (
35
+ <FlexView
36
+ {...elementProps}
37
+ // @ts-expect-error Type of ref depends on component.
38
+ ref={ref}
39
+ style={scrollable ? style : [classes, style]}
40
+ contentContainerStyle={
41
+ scrollable ? [classes, contentContainerStyle] : undefined
42
+ }
43
+ >
44
+ {children}
45
+ </FlexView>
46
+ );
47
+ },
48
+ );
49
+
50
+ ModalBody.displayName = 'ModalBody';
51
+
52
+ export default ModalBody;
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
- type ModalContextType = {
3
+ export interface ModalContextProps {
4
4
  scrollable: boolean;
5
- };
5
+ }
6
6
 
7
- const ModalContext = React.createContext<ModalContextType | null>(null);
7
+ const ModalContext = React.createContext<ModalContextProps | null>(null);
8
8
 
9
9
  ModalContext.displayName = 'ModalContext';
10
10
 
@@ -6,10 +6,10 @@ import View, { ViewProps, ViewRef } from '../View';
6
6
  import { GRID_BREAKPOINTS } from '../../theme/proxies';
7
7
  import { infix, next } from '../../theme/breakpoints';
8
8
  import { getStyles, each } from '../../utils';
9
- import NavbarContext, { NavbarContextType } from '../navbar/NavbarContext';
9
+ import NavbarContext, { NavbarContextProps } from '../navbar/NavbarContext';
10
10
  import NavContext, { NavVariant } from './NavContext';
11
11
  import NavLink from './NavLink';
12
- import TabContext, { TabContextType } from './TabContext';
12
+ import TabContext, { TabContextProps } from './TabContext';
13
13
 
14
14
  export interface NavProps extends ViewProps {
15
15
  variant?: NavVariant;
@@ -47,8 +47,8 @@ const styles = StyleSheet.create({
47
47
  });
48
48
 
49
49
  const getRole = (
50
- tabbable: TabContextType | null,
51
- navbar: NavbarContextType | null,
50
+ tabbable: TabContextProps | null,
51
+ navbar: NavbarContextProps | null,
52
52
  ) => {
53
53
  if (tabbable) {
54
54
  return 'tablist';
@@ -2,11 +2,11 @@ import { createContext } from 'react';
2
2
 
3
3
  export type NavVariant = 'tabs' | 'pills';
4
4
 
5
- type NavContextType = {
5
+ export interface NavContextProps {
6
6
  variant?: NavVariant;
7
- };
7
+ }
8
8
 
9
- const NavContext = createContext<NavContextType | null>(null);
9
+ const NavContext = createContext<NavContextProps | null>(null);
10
10
 
11
11
  NavContext.displayName = 'NavContext';
12
12
 
@@ -1,12 +1,12 @@
1
1
  import { createContext } from 'react';
2
2
 
3
- export type TabContextType = {
3
+ export interface TabContextProps {
4
4
  identifier: string;
5
5
  activeTarget: string;
6
6
  setActiveTarget: (target: string) => void;
7
- };
7
+ }
8
8
 
9
- const TabContext = createContext<TabContextType | null>(null);
9
+ const TabContext = createContext<TabContextProps | null>(null);
10
10
 
11
11
  TabContext.displayName = 'TabContext';
12
12