bootstrap-rn 0.4.6 → 0.4.7

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 (287) hide show
  1. package/lib/module/Context.js.map +1 -1
  2. package/lib/module/Provider.js +3 -7
  3. package/lib/module/Provider.js.map +1 -1
  4. package/lib/module/components/Body.js +8 -1
  5. package/lib/module/components/Body.js.map +1 -1
  6. package/lib/module/components/buttons/Button.js +10 -8
  7. package/lib/module/components/buttons/Button.js.map +1 -1
  8. package/lib/module/components/close/CloseButton.js +7 -3
  9. package/lib/module/components/close/CloseButton.js.map +1 -1
  10. package/lib/module/components/collapse/useCollapse.js +2 -3
  11. package/lib/module/components/collapse/useCollapse.js.map +1 -1
  12. package/lib/module/components/dropdown/Dropdown.js +1 -2
  13. package/lib/module/components/dropdown/Dropdown.js.map +1 -1
  14. package/lib/module/components/dropdown/DropdownContext.js.map +1 -1
  15. package/lib/module/components/dropdown/DropdownMenu.js +33 -59
  16. package/lib/module/components/dropdown/DropdownMenu.js.map +1 -1
  17. package/lib/module/components/dropdown/useDismissDropdown.js +5 -4
  18. package/lib/module/components/dropdown/useDismissDropdown.js.map +1 -1
  19. package/lib/module/components/dropdown/useDropdown.js +35 -11
  20. package/lib/module/components/dropdown/useDropdown.js.map +1 -1
  21. package/lib/module/components/dropdown/useToggleDropdown.js +4 -6
  22. package/lib/module/components/dropdown/useToggleDropdown.js.map +1 -1
  23. package/lib/module/components/forms/FormCheckInput.js +1 -1
  24. package/lib/module/components/forms/Input.js +1 -1
  25. package/lib/module/components/forms/internals/PickerNative.js +1 -1
  26. package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
  27. package/lib/module/components/helpers/BackdropHandler.js +6 -92
  28. package/lib/module/components/helpers/BackdropHandler.js.map +1 -1
  29. package/lib/module/components/helpers/BackdropHandler.web.js +8 -0
  30. package/lib/module/components/helpers/BackdropHandler.web.js.map +1 -0
  31. package/lib/module/components/helpers/Dialog.js +29 -0
  32. package/lib/module/components/helpers/Dialog.js.map +1 -0
  33. package/lib/module/components/helpers/Dialog.web.js +117 -0
  34. package/lib/module/components/helpers/Dialog.web.js.map +1 -0
  35. package/lib/module/components/helpers/Portal.js +5 -0
  36. package/lib/module/components/helpers/Portal.js.map +1 -0
  37. package/lib/module/components/helpers/Portal.web.js +16 -0
  38. package/lib/module/components/helpers/Portal.web.js.map +1 -0
  39. package/lib/module/components/helpers/PortalHost.js +5 -0
  40. package/lib/module/components/helpers/PortalHost.js.map +1 -0
  41. package/lib/module/components/helpers/PortalHost.web.js +15 -0
  42. package/lib/module/components/helpers/PortalHost.web.js.map +1 -0
  43. package/lib/module/components/modal/Modal.js +58 -48
  44. package/lib/module/components/modal/Modal.js.map +1 -1
  45. package/lib/module/components/modal/ModalContext.js.map +1 -1
  46. package/lib/module/components/modal/ModalTitle.js +6 -0
  47. package/lib/module/components/modal/ModalTitle.js.map +1 -1
  48. package/lib/module/components/modal/useModal.js +4 -13
  49. package/lib/module/components/modal/useModal.js.map +1 -1
  50. package/lib/module/components/nav/useTabbable.js +2 -3
  51. package/lib/module/components/nav/useTabbable.js.map +1 -1
  52. package/lib/module/components/navbar/NavbarToggler.js +1 -1
  53. package/lib/module/components/navbar/useNavbar.js +2 -3
  54. package/lib/module/components/navbar/useNavbar.js.map +1 -1
  55. package/lib/module/components/offcanvas/Offcanvas.js +84 -82
  56. package/lib/module/components/offcanvas/Offcanvas.js.map +1 -1
  57. package/lib/module/components/offcanvas/OffcanvasContext.js.map +1 -1
  58. package/lib/module/components/offcanvas/OffcanvasTitle.js +6 -0
  59. package/lib/module/components/offcanvas/OffcanvasTitle.js.map +1 -1
  60. package/lib/module/components/offcanvas/useOffcanvas.js +6 -14
  61. package/lib/module/components/offcanvas/useOffcanvas.js.map +1 -1
  62. package/lib/module/components/pagination/PaginationItem.js +39 -39
  63. package/lib/module/components/popover/Popover.js +6 -8
  64. package/lib/module/components/popover/Popover.js.map +1 -1
  65. package/lib/module/components/popover/PopoverArrow.js +18 -9
  66. package/lib/module/components/popover/PopoverArrow.js.map +1 -1
  67. package/lib/module/components/popover/PopoverContext.js.map +1 -1
  68. package/lib/module/components/popover/injectPopover.js +48 -45
  69. package/lib/module/components/popover/injectPopover.js.map +1 -1
  70. package/lib/module/components/tooltip/Tooltip.js +7 -23
  71. package/lib/module/components/tooltip/Tooltip.js.map +1 -1
  72. package/lib/module/components/tooltip/TooltipArrow.js +22 -12
  73. package/lib/module/components/tooltip/TooltipArrow.js.map +1 -1
  74. package/lib/module/components/tooltip/TooltipContext.js.map +1 -1
  75. package/lib/module/components/tooltip/injectTooltip.js +46 -42
  76. package/lib/module/components/tooltip/injectTooltip.js.map +1 -1
  77. package/lib/module/hooks/useBackgroundNative.js.map +1 -1
  78. package/lib/module/hooks/useFocusRing.js +13 -0
  79. package/lib/module/hooks/useFocusRing.js.map +1 -0
  80. package/lib/module/hooks/useFocusRing.web.js +5 -0
  81. package/lib/module/hooks/useFocusRing.web.js.map +1 -0
  82. package/lib/module/hooks/useInteractionState.js +11 -11
  83. package/lib/module/hooks/useInteractionState.js.map +1 -1
  84. package/lib/module/hooks/useOverlay.js +121 -0
  85. package/lib/module/hooks/useOverlay.js.map +1 -0
  86. package/lib/module/hooks/useOverlay.web.js +113 -0
  87. package/lib/module/hooks/useOverlay.web.js.map +1 -0
  88. package/lib/module/hooks/useScrollbarEffects.js +7 -60
  89. package/lib/module/hooks/useScrollbarEffects.js.map +1 -1
  90. package/lib/module/hooks/useScrollbarEffects.web.js +59 -0
  91. package/lib/module/hooks/useScrollbarEffects.web.js.map +1 -0
  92. package/lib/module/index.js +3 -3
  93. package/lib/module/index.js.map +1 -1
  94. package/lib/module/style/StyleSheet.js +1 -3
  95. package/lib/module/style/StyleSheet.js.map +1 -1
  96. package/lib/module/theme/variables.js +9 -9
  97. package/lib/module/utils.js +0 -11
  98. package/lib/module/utils.js.map +1 -1
  99. package/lib/typescript/Context.d.ts +0 -1
  100. package/lib/typescript/Context.d.ts.map +1 -1
  101. package/lib/typescript/Provider.d.ts.map +1 -1
  102. package/lib/typescript/components/Body.d.ts.map +1 -1
  103. package/lib/typescript/components/Link.d.ts +1 -1
  104. package/lib/typescript/components/Link.d.ts.map +1 -1
  105. package/lib/typescript/components/Pressable.d.ts +1 -1
  106. package/lib/typescript/components/Pressable.d.ts.map +1 -1
  107. package/lib/typescript/components/TextInput.d.ts +3 -3
  108. package/lib/typescript/components/TextInput.d.ts.map +1 -1
  109. package/lib/typescript/components/buttons/Button.d.ts +1 -1
  110. package/lib/typescript/components/buttons/Button.d.ts.map +1 -1
  111. package/lib/typescript/components/close/CloseButton.d.ts +1 -1
  112. package/lib/typescript/components/close/CloseButton.d.ts.map +1 -1
  113. package/lib/typescript/components/collapse/useCollapse.d.ts.map +1 -1
  114. package/lib/typescript/components/dropdown/Dropdown.d.ts +0 -1
  115. package/lib/typescript/components/dropdown/Dropdown.d.ts.map +1 -1
  116. package/lib/typescript/components/dropdown/DropdownContext.d.ts +14 -3
  117. package/lib/typescript/components/dropdown/DropdownContext.d.ts.map +1 -1
  118. package/lib/typescript/components/dropdown/DropdownMenu.d.ts +0 -1
  119. package/lib/typescript/components/dropdown/DropdownMenu.d.ts.map +1 -1
  120. package/lib/typescript/components/dropdown/useDismissDropdown.d.ts +1 -1
  121. package/lib/typescript/components/dropdown/useDismissDropdown.d.ts.map +1 -1
  122. package/lib/typescript/components/dropdown/useDropdown.d.ts +38 -4
  123. package/lib/typescript/components/dropdown/useDropdown.d.ts.map +1 -1
  124. package/lib/typescript/components/dropdown/useToggleDropdown.d.ts +4 -3
  125. package/lib/typescript/components/dropdown/useToggleDropdown.d.ts.map +1 -1
  126. package/lib/typescript/components/forms/Picker.d.ts +1 -1
  127. package/lib/typescript/components/forms/internals/PickerNative.d.ts +1 -1
  128. package/lib/typescript/components/forms/internals/PickerNative.d.ts.map +1 -1
  129. package/lib/typescript/components/forms/internals/PickerWeb.d.ts +1 -1
  130. package/lib/typescript/components/forms/internals/PickerWeb.d.ts.map +1 -1
  131. package/lib/typescript/components/helpers/BackdropHandler.d.ts +2 -11
  132. package/lib/typescript/components/helpers/BackdropHandler.d.ts.map +1 -1
  133. package/lib/typescript/components/helpers/BackdropHandler.web.d.ts +3 -0
  134. package/lib/typescript/components/helpers/BackdropHandler.web.d.ts.map +1 -0
  135. package/lib/typescript/components/helpers/Dialog.d.ts +15 -0
  136. package/lib/typescript/components/helpers/Dialog.d.ts.map +1 -0
  137. package/lib/typescript/components/helpers/Dialog.web.d.ts +15 -0
  138. package/lib/typescript/components/helpers/Dialog.web.d.ts.map +1 -0
  139. package/lib/typescript/components/helpers/Portal.d.ts +8 -0
  140. package/lib/typescript/components/helpers/Portal.d.ts.map +1 -0
  141. package/lib/typescript/components/helpers/Portal.web.d.ts +8 -0
  142. package/lib/typescript/components/helpers/Portal.web.d.ts.map +1 -0
  143. package/lib/typescript/components/helpers/PortalHost.d.ts +6 -0
  144. package/lib/typescript/components/helpers/PortalHost.d.ts.map +1 -0
  145. package/lib/typescript/components/helpers/PortalHost.web.d.ts +7 -0
  146. package/lib/typescript/components/helpers/PortalHost.web.d.ts.map +1 -0
  147. package/lib/typescript/components/list-group/ListGroup.d.ts +1 -1
  148. package/lib/typescript/components/list-group/ListGroupItemAction.d.ts +1 -1
  149. package/lib/typescript/components/list-group/ListGroupItemAction.d.ts.map +1 -1
  150. package/lib/typescript/components/modal/Modal.d.ts +1 -1
  151. package/lib/typescript/components/modal/Modal.d.ts.map +1 -1
  152. package/lib/typescript/components/modal/ModalContext.d.ts +1 -0
  153. package/lib/typescript/components/modal/ModalContext.d.ts.map +1 -1
  154. package/lib/typescript/components/modal/ModalTitle.d.ts.map +1 -1
  155. package/lib/typescript/components/modal/useModal.d.ts +2 -1
  156. package/lib/typescript/components/modal/useModal.d.ts.map +1 -1
  157. package/lib/typescript/components/nav/Nav.d.ts +1 -1
  158. package/lib/typescript/components/nav/NavLink.d.ts +1 -1
  159. package/lib/typescript/components/nav/NavLink.d.ts.map +1 -1
  160. package/lib/typescript/components/nav/useTabbable.d.ts.map +1 -1
  161. package/lib/typescript/components/navbar/Navbar.d.ts +2 -2
  162. package/lib/typescript/components/navbar/NavbarBrand.d.ts +1 -1
  163. package/lib/typescript/components/navbar/NavbarBrand.d.ts.map +1 -1
  164. package/lib/typescript/components/navbar/NavbarToggler.d.ts +1 -1
  165. package/lib/typescript/components/navbar/NavbarToggler.d.ts.map +1 -1
  166. package/lib/typescript/components/navbar/useNavbar.d.ts.map +1 -1
  167. package/lib/typescript/components/offcanvas/Offcanvas.d.ts +1 -4
  168. package/lib/typescript/components/offcanvas/Offcanvas.d.ts.map +1 -1
  169. package/lib/typescript/components/offcanvas/OffcanvasContext.d.ts +3 -1
  170. package/lib/typescript/components/offcanvas/OffcanvasContext.d.ts.map +1 -1
  171. package/lib/typescript/components/offcanvas/OffcanvasTitle.d.ts.map +1 -1
  172. package/lib/typescript/components/offcanvas/useOffcanvas.d.ts +3 -1
  173. package/lib/typescript/components/offcanvas/useOffcanvas.d.ts.map +1 -1
  174. package/lib/typescript/components/popover/Popover.d.ts +3 -4
  175. package/lib/typescript/components/popover/Popover.d.ts.map +1 -1
  176. package/lib/typescript/components/popover/PopoverArrow.d.ts.map +1 -1
  177. package/lib/typescript/components/popover/PopoverContext.d.ts +3 -4
  178. package/lib/typescript/components/popover/PopoverContext.d.ts.map +1 -1
  179. package/lib/typescript/components/popover/injectPopover.d.ts +5 -7
  180. package/lib/typescript/components/popover/injectPopover.d.ts.map +1 -1
  181. package/lib/typescript/components/tooltip/Tooltip.d.ts +3 -4
  182. package/lib/typescript/components/tooltip/Tooltip.d.ts.map +1 -1
  183. package/lib/typescript/components/tooltip/TooltipArrow.d.ts.map +1 -1
  184. package/lib/typescript/components/tooltip/TooltipContext.d.ts +3 -4
  185. package/lib/typescript/components/tooltip/TooltipContext.d.ts.map +1 -1
  186. package/lib/typescript/components/tooltip/injectTooltip.d.ts +5 -7
  187. package/lib/typescript/components/tooltip/injectTooltip.d.ts.map +1 -1
  188. package/lib/typescript/hooks/useBackgroundNative.d.ts.map +1 -1
  189. package/lib/typescript/hooks/useFocusRing.d.ts +3 -0
  190. package/lib/typescript/hooks/useFocusRing.d.ts.map +1 -0
  191. package/lib/typescript/hooks/useFocusRing.web.d.ts +3 -0
  192. package/lib/typescript/hooks/useFocusRing.web.d.ts.map +1 -0
  193. package/lib/typescript/hooks/useInteractionState.d.ts +7 -7
  194. package/lib/typescript/hooks/useInteractionState.d.ts.map +1 -1
  195. package/lib/typescript/hooks/useOverlay.d.ts +64 -0
  196. package/lib/typescript/hooks/useOverlay.d.ts.map +1 -0
  197. package/lib/typescript/hooks/useOverlay.web.d.ts +37 -0
  198. package/lib/typescript/hooks/useOverlay.web.d.ts.map +1 -0
  199. package/lib/typescript/hooks/useScrollbarEffects.d.ts.map +1 -1
  200. package/lib/typescript/hooks/useScrollbarEffects.web.d.ts +7 -0
  201. package/lib/typescript/hooks/useScrollbarEffects.web.d.ts.map +1 -0
  202. package/lib/typescript/index.d.ts +5 -4
  203. package/lib/typescript/index.d.ts.map +1 -1
  204. package/lib/typescript/style/StyleSheet.d.ts.map +1 -1
  205. package/lib/typescript/types.d.ts +12 -6
  206. package/lib/typescript/types.d.ts.map +1 -1
  207. package/lib/typescript/utils.d.ts +2 -3
  208. package/lib/typescript/utils.d.ts.map +1 -1
  209. package/package.json +92 -85
  210. package/src/Context.ts +37 -38
  211. package/src/Provider.tsx +61 -66
  212. package/src/components/Body.tsx +16 -1
  213. package/src/components/TextInput.tsx +66 -66
  214. package/src/components/buttons/Button.tsx +381 -379
  215. package/src/components/close/CloseButton.tsx +142 -138
  216. package/src/components/collapse/useCollapse.ts +25 -26
  217. package/src/components/dropdown/Dropdown.tsx +77 -80
  218. package/src/components/dropdown/DropdownContext.ts +14 -3
  219. package/src/components/dropdown/DropdownMenu.tsx +243 -284
  220. package/src/components/dropdown/useDismissDropdown.ts +30 -29
  221. package/src/components/dropdown/useDropdown.ts +55 -38
  222. package/src/components/dropdown/useToggleDropdown.ts +31 -32
  223. package/src/components/forms/FormCheckInput.tsx +268 -268
  224. package/src/components/forms/Input.tsx +220 -220
  225. package/src/components/forms/internals/PickerNative.tsx +9 -10
  226. package/src/components/helpers/BackdropHandler.tsx +5 -119
  227. package/src/components/helpers/BackdropHandler.web.tsx +6 -0
  228. package/src/components/helpers/Dialog.tsx +49 -0
  229. package/src/components/helpers/Dialog.web.tsx +145 -0
  230. package/src/components/helpers/Portal.tsx +10 -0
  231. package/src/components/helpers/Portal.web.tsx +22 -0
  232. package/src/components/helpers/PortalHost.tsx +7 -0
  233. package/src/components/helpers/PortalHost.web.tsx +14 -0
  234. package/src/components/modal/Modal.tsx +60 -48
  235. package/src/components/modal/ModalContext.ts +12 -11
  236. package/src/components/modal/ModalTitle.tsx +41 -31
  237. package/src/components/modal/useModal.ts +13 -25
  238. package/src/components/nav/useTabbable.ts +31 -32
  239. package/src/components/navbar/NavbarToggler.tsx +130 -130
  240. package/src/components/navbar/useNavbar.ts +30 -31
  241. package/src/components/offcanvas/Offcanvas.tsx +91 -92
  242. package/src/components/offcanvas/OffcanvasContext.ts +13 -11
  243. package/src/components/offcanvas/OffcanvasTitle.tsx +43 -33
  244. package/src/components/offcanvas/useOffcanvas.ts +12 -20
  245. package/src/components/pagination/PaginationItem.tsx +139 -139
  246. package/src/components/popover/Popover.tsx +87 -90
  247. package/src/components/popover/PopoverArrow.tsx +22 -6
  248. package/src/components/popover/PopoverContext.ts +13 -18
  249. package/src/components/popover/injectPopover.tsx +63 -55
  250. package/src/components/tooltip/Tooltip.tsx +79 -98
  251. package/src/components/tooltip/TooltipArrow.tsx +26 -8
  252. package/src/components/tooltip/TooltipContext.ts +13 -18
  253. package/src/components/tooltip/injectTooltip.tsx +62 -53
  254. package/src/hooks/useAction.ts +78 -78
  255. package/src/hooks/useBackgroundNative.tsx +6 -4
  256. package/src/hooks/useFocusRing.ts +13 -0
  257. package/src/hooks/useFocusRing.web.ts +3 -0
  258. package/src/hooks/useInteractionState.ts +75 -81
  259. package/src/hooks/useOverlay.ts +197 -0
  260. package/src/hooks/useOverlay.web.ts +190 -0
  261. package/src/hooks/useScrollbarEffects.ts +5 -83
  262. package/src/hooks/useScrollbarEffects.web.ts +83 -0
  263. package/src/index.ts +5 -5
  264. package/src/style/StyleSheet.ts +2 -5
  265. package/src/theme/variables.ts +1420 -1420
  266. package/src/types.ts +14 -14
  267. package/src/utils.ts +4 -22
  268. package/lib/module/components/SafeAreaView.js +0 -42
  269. package/lib/module/components/SafeAreaView.js.map +0 -1
  270. package/lib/module/components/helpers/Overlay.js +0 -50
  271. package/lib/module/components/helpers/Overlay.js.map +0 -1
  272. package/lib/module/hooks/useIdentifier.js +0 -14
  273. package/lib/module/hooks/useIdentifier.js.map +0 -1
  274. package/lib/module/hooks/useTrigger.js +0 -97
  275. package/lib/module/hooks/useTrigger.js.map +0 -1
  276. package/lib/typescript/components/SafeAreaView.d.ts +0 -12
  277. package/lib/typescript/components/SafeAreaView.d.ts.map +0 -1
  278. package/lib/typescript/components/helpers/Overlay.d.ts +0 -28
  279. package/lib/typescript/components/helpers/Overlay.d.ts.map +0 -1
  280. package/lib/typescript/hooks/useIdentifier.d.ts +0 -2
  281. package/lib/typescript/hooks/useIdentifier.d.ts.map +0 -1
  282. package/lib/typescript/hooks/useTrigger.d.ts +0 -33
  283. package/lib/typescript/hooks/useTrigger.d.ts.map +0 -1
  284. package/src/components/SafeAreaView.tsx +0 -64
  285. package/src/components/helpers/Overlay.tsx +0 -81
  286. package/src/hooks/useIdentifier.ts +0 -15
  287. package/src/hooks/useTrigger.ts +0 -141
@@ -1,220 +1,220 @@
1
- import React from 'react';
2
- import StyleSheet from '../../style/StyleSheet';
3
- import css from '../../style/css';
4
- import TextInput, { TextInputProps, TextInputRef } from '../TextInput';
5
- import { getStyles, each } from '../../utils';
6
- import useModifier from '../../hooks/useModifier';
7
- import { FORM_VALIDATION_STATES } from '../../theme/proxies';
8
- import type {
9
- FormValidationState,
10
- ThemeVariables,
11
- UseFormFieldProps,
12
- } from '../../types';
13
-
14
- export interface InputProps extends UseFormFieldProps, TextInputProps {
15
- size?: 'sm' | 'lg';
16
- placeholderTextColor?: string;
17
- multiline?: boolean;
18
- disabled?: boolean;
19
- valid?: boolean;
20
- invalid?: boolean;
21
- readOnly?: boolean;
22
- selectTextOnFocus?: boolean;
23
- }
24
-
25
- // Known issues:
26
- //
27
- // line-height (iOS)
28
- // If a line height is defined on iOS the text will be displayed on the bottom
29
- // of the line. As a workaround the line height is only defined for multi line
30
- // inputs.
31
- //
32
- // multi line height (iOS)
33
- // A multi line input on iOS has only the height of a single line input. As a
34
- // workaround we added a height of $input-height-sm + 8rem for multi line
35
- // inputs on iOS.
36
- //
37
- // single line height (Android)
38
- // If no height is defined, Android sets a text line height of 28px auto-
39
- // matically, which leads to a larger height than min height for the default
40
- // and sm size. As a workaround we set a height for single line inputs.
41
- const styles = StyleSheet.create({
42
- '.form-control': css`
43
- // display: block;
44
- width: 100%;
45
- min-height: $input-height; // added for bootstrap-rn
46
- padding: $input-padding-y $input-padding-x;
47
- font-family: $input-font-family;
48
- font-size: $input-font-size;
49
- font-weight: $input-font-weight;
50
- @include platform(web) {
51
- line-height: $input-font-size * $input-line-height;
52
- }
53
- color: $input-color;
54
- background-color: $input-bg;
55
- // background-clip: padding-box;
56
- border: $input-border-width solid $input-border-color;
57
- @include platform(web) {
58
- appearance: none; // Fix appearance for date inputs in Safari
59
- }
60
-
61
- // Note: This has no effect on <select>s in some browsers, due to the limited stylability of "<select>"s in CSS.
62
- border-radius: $input-border-radius;
63
-
64
- // @include box-shadow($input-box-shadow);
65
- // @include transition($input-transition);
66
-
67
- // Customize the ":focus" state to imitate native WebKit styles.
68
- &:focus {
69
- color: $input-focus-color;
70
- background-color: $input-focus-bg;
71
- border-color: $input-focus-border-color;
72
- @include platform(web) {
73
- outline-width: 0; // outline: 0;
74
- // @if $enable-shadows {
75
- // @include box-shadow($input-box-shadow, $input-focus-box-shadow);
76
- // } @else {
77
- // // Avoid using mixin so we can pass custom focus shadow properly
78
- box-shadow: $input-focus-box-shadow;
79
- // }
80
- }
81
- }
82
- `,
83
- '.form-control.disabled': css`
84
- background-color: $input-disabled-bg;
85
- border-color: $input-disabled-border-color;
86
- // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
87
- opacity: 1;
88
- `,
89
- '.form-control-sm': css`
90
- min-height: $input-height-sm;
91
- padding: $input-padding-y-sm $input-padding-x-sm;
92
- font-size: $input-font-size-sm;
93
- @include platform(web) {
94
- line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
95
- }
96
- border-radius: $input-border-radius-sm;
97
- `,
98
- '.form-control-lg': css`
99
- min-height: $input-height-lg;
100
- padding: $input-padding-y-lg $input-padding-x-lg;
101
- font-size: $input-font-size-lg;
102
- @include platform(web) {
103
- line-height: $input-font-size-lg * $line-height-base; // added for bootstrap-rn
104
- }
105
- border-radius: $input-border-radius-lg;
106
- `,
107
- '.form-control:not(textarea)': css`
108
- @include platform(android) {
109
- height: $input-height; // added for bootstrap-rn
110
- }
111
- `,
112
- '.form-control-sm:not(textarea)': css`
113
- @include platform(android) {
114
- height: $input-height-sm; // added for bootstrap-rn
115
- }
116
- `,
117
- '.form-control-lg:not(textarea)': css`
118
- @include platform(android) {
119
- height: $input-height-lg; // added for bootstrap-rn
120
- }
121
- `,
122
- 'textarea.form-control': css`
123
- vertical-align: top; // added for bootstrap-rn
124
- min-height: $input-height;
125
-
126
- @include platform(ios) {
127
- min-height: $input-height-sm + 8rem; // added for bootstrap-rn
128
- }
129
- @include platform(native) {
130
- line-height: $input-font-size * $input-line-height; // added for bootstrap-rn
131
- }
132
- `,
133
- 'textarea.form-control-sm': css`
134
- min-height: $input-height-sm;
135
-
136
- @include platform(ios) {
137
- // TODO: Adjust ios height to sm size
138
- min-height: $input-height-sm + 8rem; // added for bootstrap-rn
139
- }
140
- @include platform(native) {
141
- line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
142
- }
143
- `,
144
- 'textarea.form-control-lg': css`
145
- min-height: $input-height-lg;
146
-
147
- @include platform(ios) {
148
- // TODO: Adjust ios height to lg size
149
- min-height: $input-height-sm + 8rem; // added for bootstrap-rn
150
- }
151
- @include platform(native) {
152
- line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
153
- }
154
- `,
155
- ...each(FORM_VALIDATION_STATES, (state, data: FormValidationState) => ({
156
- [`.form-control:${state}`]: css`
157
- border-color: ${(t: ThemeVariables) => data(t).color};
158
-
159
- &:focus {
160
- border-color: ${(t: ThemeVariables) => data(t).color};
161
- @include platform(web) {
162
- box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
163
- rgba(
164
- ${(t: ThemeVariables) => data(t).color},
165
- $input-btn-focus-color-opacity
166
- );
167
- }
168
- }
169
- `,
170
- })),
171
- });
172
-
173
- const Input = React.forwardRef<TextInputRef, InputProps>((props, ref) => {
174
- const [modifierProps, modifierRef] = useModifier('useFormField', props, ref);
175
-
176
- const {
177
- size,
178
- placeholderTextColor = StyleSheet.value('input-placeholder-color'),
179
- multiline = false,
180
- disabled = false,
181
- valid = false,
182
- invalid = false,
183
- readOnly = false,
184
- selectTextOnFocus = false,
185
- style,
186
- ...elementProps
187
- } = modifierProps;
188
-
189
- const classes = getStyles(styles, [
190
- '.form-control',
191
- disabled && '.form-control.disabled',
192
- size === 'sm' && '.form-control-sm',
193
- size === 'lg' && '.form-control-lg',
194
- !multiline && '.form-control:not(textarea)',
195
- !multiline && size === 'sm' && '.form-control-sm:not(textarea)',
196
- !multiline && size === 'lg' && '.form-control-lg:not(textarea)',
197
- multiline && 'textarea.form-control',
198
- multiline && size === 'sm' && 'textarea.form-control-sm',
199
- multiline && size === 'lg' && 'textarea.form-control-lg',
200
- valid && '.form-control:valid',
201
- invalid && '.form-control:invalid',
202
- ]);
203
-
204
- return (
205
- <TextInput
206
- {...elementProps}
207
- ref={modifierRef}
208
- placeholderTextColor={placeholderTextColor}
209
- multiline={multiline}
210
- disabled={disabled}
211
- readOnly={disabled ? true : readOnly}
212
- selectTextOnFocus={disabled ? false : selectTextOnFocus}
213
- style={[classes, style]}
214
- />
215
- );
216
- });
217
-
218
- Input.displayName = 'Input';
219
-
220
- export default Input;
1
+ import React from 'react';
2
+ import StyleSheet from '../../style/StyleSheet';
3
+ import css from '../../style/css';
4
+ import TextInput, { TextInputProps, TextInputRef } from '../TextInput';
5
+ import { getStyles, each } from '../../utils';
6
+ import useModifier from '../../hooks/useModifier';
7
+ import { FORM_VALIDATION_STATES } from '../../theme/proxies';
8
+ import type {
9
+ FormValidationState,
10
+ ThemeVariables,
11
+ UseFormFieldProps,
12
+ } from '../../types';
13
+
14
+ export interface InputProps extends UseFormFieldProps, TextInputProps {
15
+ size?: 'sm' | 'lg';
16
+ placeholderTextColor?: string;
17
+ multiline?: boolean;
18
+ disabled?: boolean;
19
+ valid?: boolean;
20
+ invalid?: boolean;
21
+ readOnly?: boolean;
22
+ selectTextOnFocus?: boolean;
23
+ }
24
+
25
+ // Known issues:
26
+ //
27
+ // line-height (iOS)
28
+ // If a line height is defined on iOS the text will be displayed on the bottom
29
+ // of the line. As a workaround the line height is only defined for multi line
30
+ // inputs.
31
+ //
32
+ // multi line height (iOS)
33
+ // A multi line input on iOS has only the height of a single line input. As a
34
+ // workaround we added a height of $input-height-sm + 8rem for multi line
35
+ // inputs on iOS.
36
+ //
37
+ // single line height (Android)
38
+ // If no height is defined, Android sets a text line height of 28px auto-
39
+ // matically, which leads to a larger height than min height for the default
40
+ // and sm size. As a workaround we set a height for single line inputs.
41
+ const styles = StyleSheet.create({
42
+ '.form-control': css`
43
+ // display: block;
44
+ width: 100%;
45
+ min-height: $input-height; // added for bootstrap-rn
46
+ padding: $input-padding-y $input-padding-x;
47
+ font-family: $input-font-family;
48
+ font-size: $input-font-size;
49
+ font-weight: $input-font-weight;
50
+ @include platform(web) {
51
+ line-height: $input-font-size * $input-line-height;
52
+ }
53
+ color: $input-color;
54
+ background-color: $input-bg;
55
+ // background-clip: padding-box;
56
+ border: $input-border-width solid $input-border-color;
57
+ @include platform(web) {
58
+ appearance: none; // Fix appearance for date inputs in Safari
59
+ }
60
+
61
+ // Note: This has no effect on <select>s in some browsers, due to the limited stylability of "<select>"s in CSS.
62
+ border-radius: $input-border-radius;
63
+
64
+ // @include box-shadow($input-box-shadow);
65
+ // @include transition($input-transition);
66
+
67
+ // Customize the ":focus" state to imitate native WebKit styles.
68
+ &:focus {
69
+ color: $input-focus-color;
70
+ background-color: $input-focus-bg;
71
+ border-color: $input-focus-border-color;
72
+ @include platform(web) {
73
+ outline-style: none; // outline: 0;
74
+ // @if $enable-shadows {
75
+ // @include box-shadow($input-box-shadow, $input-focus-box-shadow);
76
+ // } @else {
77
+ // // Avoid using mixin so we can pass custom focus shadow properly
78
+ box-shadow: $input-focus-box-shadow;
79
+ // }
80
+ }
81
+ }
82
+ `,
83
+ '.form-control.disabled': css`
84
+ background-color: $input-disabled-bg;
85
+ border-color: $input-disabled-border-color;
86
+ // iOS fix for unreadable disabled content; see https://github.com/twbs/bootstrap/issues/11655.
87
+ opacity: 1;
88
+ `,
89
+ '.form-control-sm': css`
90
+ min-height: $input-height-sm;
91
+ padding: $input-padding-y-sm $input-padding-x-sm;
92
+ font-size: $input-font-size-sm;
93
+ @include platform(web) {
94
+ line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
95
+ }
96
+ border-radius: $input-border-radius-sm;
97
+ `,
98
+ '.form-control-lg': css`
99
+ min-height: $input-height-lg;
100
+ padding: $input-padding-y-lg $input-padding-x-lg;
101
+ font-size: $input-font-size-lg;
102
+ @include platform(web) {
103
+ line-height: $input-font-size-lg * $line-height-base; // added for bootstrap-rn
104
+ }
105
+ border-radius: $input-border-radius-lg;
106
+ `,
107
+ '.form-control:not(textarea)': css`
108
+ @include platform(android) {
109
+ height: $input-height; // added for bootstrap-rn
110
+ }
111
+ `,
112
+ '.form-control-sm:not(textarea)': css`
113
+ @include platform(android) {
114
+ height: $input-height-sm; // added for bootstrap-rn
115
+ }
116
+ `,
117
+ '.form-control-lg:not(textarea)': css`
118
+ @include platform(android) {
119
+ height: $input-height-lg; // added for bootstrap-rn
120
+ }
121
+ `,
122
+ 'textarea.form-control': css`
123
+ vertical-align: top; // added for bootstrap-rn
124
+ min-height: $input-height;
125
+
126
+ @include platform(ios) {
127
+ min-height: $input-height-sm + 8rem; // added for bootstrap-rn
128
+ }
129
+ @include platform(native) {
130
+ line-height: $input-font-size * $input-line-height; // added for bootstrap-rn
131
+ }
132
+ `,
133
+ 'textarea.form-control-sm': css`
134
+ min-height: $input-height-sm;
135
+
136
+ @include platform(ios) {
137
+ // TODO: Adjust ios height to sm size
138
+ min-height: $input-height-sm + 8rem; // added for bootstrap-rn
139
+ }
140
+ @include platform(native) {
141
+ line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
142
+ }
143
+ `,
144
+ 'textarea.form-control-lg': css`
145
+ min-height: $input-height-lg;
146
+
147
+ @include platform(ios) {
148
+ // TODO: Adjust ios height to lg size
149
+ min-height: $input-height-sm + 8rem; // added for bootstrap-rn
150
+ }
151
+ @include platform(native) {
152
+ line-height: $input-font-size-sm * $line-height-base; // added for bootstrap-rn
153
+ }
154
+ `,
155
+ ...each(FORM_VALIDATION_STATES, (state, data: FormValidationState) => ({
156
+ [`.form-control:${state}`]: css`
157
+ border-color: ${(t: ThemeVariables) => data(t).color};
158
+
159
+ &:focus {
160
+ border-color: ${(t: ThemeVariables) => data(t).color};
161
+ @include platform(web) {
162
+ box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
163
+ rgba(
164
+ ${(t: ThemeVariables) => data(t).color},
165
+ $input-btn-focus-color-opacity
166
+ );
167
+ }
168
+ }
169
+ `,
170
+ })),
171
+ });
172
+
173
+ const Input = React.forwardRef<TextInputRef, InputProps>((props, ref) => {
174
+ const [modifierProps, modifierRef] = useModifier('useFormField', props, ref);
175
+
176
+ const {
177
+ size,
178
+ placeholderTextColor = StyleSheet.value('input-placeholder-color'),
179
+ multiline = false,
180
+ disabled = false,
181
+ valid = false,
182
+ invalid = false,
183
+ readOnly = false,
184
+ selectTextOnFocus = false,
185
+ style,
186
+ ...elementProps
187
+ } = modifierProps;
188
+
189
+ const classes = getStyles(styles, [
190
+ '.form-control',
191
+ disabled && '.form-control.disabled',
192
+ size === 'sm' && '.form-control-sm',
193
+ size === 'lg' && '.form-control-lg',
194
+ !multiline && '.form-control:not(textarea)',
195
+ !multiline && size === 'sm' && '.form-control-sm:not(textarea)',
196
+ !multiline && size === 'lg' && '.form-control-lg:not(textarea)',
197
+ multiline && 'textarea.form-control',
198
+ multiline && size === 'sm' && 'textarea.form-control-sm',
199
+ multiline && size === 'lg' && 'textarea.form-control-lg',
200
+ valid && '.form-control:valid',
201
+ invalid && '.form-control:invalid',
202
+ ]);
203
+
204
+ return (
205
+ <TextInput
206
+ {...elementProps}
207
+ ref={modifierRef}
208
+ placeholderTextColor={placeholderTextColor}
209
+ multiline={multiline}
210
+ disabled={disabled}
211
+ readOnly={disabled ? true : readOnly}
212
+ selectTextOnFocus={disabled ? false : selectTextOnFocus}
213
+ style={[classes, style]}
214
+ />
215
+ );
216
+ });
217
+
218
+ Input.displayName = 'Input';
219
+
220
+ export default Input;
@@ -1,9 +1,8 @@
1
1
  import React, { useState, useMemo } from 'react';
2
2
  import {
3
3
  TextStyle,
4
- TextInputFocusEventData,
5
- NativeSyntheticEvent,
6
- TargetedEvent,
4
+ FocusEvent,
5
+ BlurEvent,
7
6
  StyleSheet as StyleUtils,
8
7
  } from 'react-native';
9
8
  import StyleSheet from '../../../style/StyleSheet';
@@ -97,7 +96,7 @@ function DefaultMenuComponent({
97
96
  );
98
97
 
99
98
  return (
100
- <Offcanvas placement="bottom" visible onToggle={handleClose}>
99
+ <Offcanvas placement="bottom" visible onClose={handleClose}>
101
100
  <Offcanvas.Body contentContainerStyle={styles.menu}>
102
101
  <PickerNativeContext.Provider value={contextValue}>
103
102
  {children}
@@ -141,12 +140,12 @@ const PickerNative = React.forwardRef<PressableRef, PickerNativeProps>(
141
140
  setVisible(false);
142
141
  };
143
142
 
144
- const handleFocus = (event: NativeSyntheticEvent<TargetedEvent>) => {
145
- onFocus(event as NativeSyntheticEvent<TextInputFocusEventData>);
143
+ const handleFocus = (event: FocusEvent) => {
144
+ onFocus(event);
146
145
  };
147
146
 
148
- const handleBlur = (event: NativeSyntheticEvent<TargetedEvent>) => {
149
- onBlur(event as NativeSyntheticEvent<TextInputFocusEventData>);
147
+ const handleBlur = (event: BlurEvent) => {
148
+ onBlur(event);
150
149
  };
151
150
 
152
151
  return (
@@ -158,10 +157,10 @@ const PickerNative = React.forwardRef<PressableRef, PickerNativeProps>(
158
157
  onPress={() => {
159
158
  setVisible(true);
160
159
  }}
161
- onFocus={(event: NativeSyntheticEvent<TargetedEvent>) => {
160
+ onFocus={(event: FocusEvent) => {
162
161
  handleFocus(event);
163
162
  }}
164
- onBlur={(event: NativeSyntheticEvent<TargetedEvent>) => {
163
+ onBlur={(event: BlurEvent) => {
165
164
  handleBlur(event);
166
165
  }}
167
166
  disabled={disabled}
@@ -1,126 +1,14 @@
1
- import React, { useEffect, useMemo, RefObject } from 'react';
2
- import { Platform } from 'react-native';
3
- import StyleSheet from '../../style/StyleSheet';
4
- import css from '../../style/css';
1
+ import React from 'react';
2
+ import { StyleSheet } from 'react-native';
5
3
  import Pressable from '../Pressable';
6
- import { ViewRef } from '../View';
7
-
8
- type BackdropType = boolean | 'static';
9
- type AutoCloseType = boolean | string;
10
-
11
- const styles = StyleSheet.create({
12
- handler: css`
13
- top: 0;
14
- bottom: 0;
15
- left: 0;
16
- right: 0;
17
- position: absolute;
18
- flex-grow: 1;
19
- `,
20
- });
21
-
22
- const initialState = {
23
- waitingForMouseUp: false,
24
- ignoreBackdropClick: false,
25
- };
26
4
 
27
5
  interface BackdropHandlerProps {
28
- toggleRef?: RefObject<ViewRef | null>;
29
- dialogRef: RefObject<ViewRef | null>;
30
6
  onClose?: () => void;
31
- autoClose?: AutoCloseType;
32
- backdrop?: BackdropType;
7
+ backdrop?: boolean | 'static';
33
8
  }
34
9
 
35
10
  function BackdropHandler(props: BackdropHandlerProps) {
36
- const {
37
- toggleRef,
38
- dialogRef,
39
- onClose: handleClose,
40
- backdrop = true,
41
- autoClose = 'outside',
42
- } = props;
43
-
44
- if (Platform.OS === 'web') {
45
- const state = useMemo(() => initialState, []);
46
-
47
- useEffect(() => {
48
- const toggle = toggleRef
49
- ? // @ts-expect-error web only method for converting to HTMLElement
50
- (toggleRef.current as HTMLElement)
51
- : undefined;
52
- // @ts-expect-error web only method for converting to HTMLElement
53
- const dialog = dialogRef.current as HTMLElement;
54
-
55
- const handleDialogMouseDown = () => {
56
- state.waitingForMouseUp = true;
57
- };
58
-
59
- // Workaround for chrome, because chrome does not fire onMouseDown event
60
- // for dialog when clicking on the <select> menu.
61
- const handleDialogMouseUp = () => {
62
- state.ignoreBackdropClick = true;
63
- };
64
-
65
- const handleDocumentClick = ({ target }: MouseEvent) => {
66
- const isDialogClick =
67
- state.ignoreBackdropClick ||
68
- (dialog && dialog.contains(target as Node));
69
-
70
- if (backdrop === 'static' || autoClose === false) {
71
- return;
72
- }
73
-
74
- // Click outside -> return if autoClose is inside.
75
- if (!isDialogClick && autoClose === 'inside') {
76
- return;
77
- }
78
-
79
- // Click inside / on dialog -> return if autoClose is outside.
80
- if (isDialogClick) {
81
- state.ignoreBackdropClick = false;
82
-
83
- if (autoClose === 'outside') {
84
- return;
85
- }
86
- }
87
-
88
- // Click on toggle -> return always.
89
- if (toggle && (target === toggle || toggle.contains(target as Node))) {
90
- return;
91
- }
92
-
93
- handleClose?.();
94
- };
95
-
96
- const handleDocumentMouseUp = () => {
97
- if (state.waitingForMouseUp) {
98
- state.ignoreBackdropClick = true;
99
- }
100
-
101
- state.waitingForMouseUp = false;
102
- };
103
-
104
- if (dialog) {
105
- dialog.addEventListener('mousedown', handleDialogMouseDown);
106
- dialog.addEventListener('mouseup', handleDialogMouseUp);
107
- }
108
- // See https://github.com/necolas/react-native-web/issues/2115
109
- document.addEventListener('click', handleDocumentClick, true);
110
- document.addEventListener('mouseup', handleDocumentMouseUp, true);
111
-
112
- return () => {
113
- if (dialog) {
114
- dialog.removeEventListener('mousedown', handleDialogMouseDown);
115
- dialog.removeEventListener('mouseup', handleDialogMouseUp);
116
- }
117
- document.removeEventListener('click', handleDocumentClick, true);
118
- document.removeEventListener('mouseup', handleDocumentMouseUp, true);
119
- };
120
- }, [backdrop, autoClose]);
121
-
122
- return null;
123
- }
11
+ const { onClose: handleClose, backdrop = true } = props;
124
12
 
125
13
  if (backdrop !== true) {
126
14
  return null;
@@ -128,7 +16,7 @@ function BackdropHandler(props: BackdropHandlerProps) {
128
16
 
129
17
  return (
130
18
  <Pressable
131
- style={styles.handler}
19
+ style={[StyleSheet.absoluteFill, { flexGrow: 1 }]}
132
20
  onPress={() => {
133
21
  handleClose?.();
134
22
  }}
@@ -138,6 +26,4 @@ function BackdropHandler(props: BackdropHandlerProps) {
138
26
  );
139
27
  }
140
28
 
141
- BackdropHandler.displayName = 'BackdropHandler';
142
-
143
29
  export default BackdropHandler;
@@ -0,0 +1,6 @@
1
+ // We handle everything in useOverlay for web, so this is a noop.
2
+ function BackdropHandler() {
3
+ return null;
4
+ }
5
+
6
+ export default BackdropHandler;