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,268 +1,268 @@
1
- import React, { useContext, useState } from 'react';
2
- import { Platform } from 'react-native';
3
- import StyleSheet from '../../style/StyleSheet';
4
- import css from '../../style/css';
5
- import { getStyles, each } from '../../utils';
6
- import type { PressableRef } from '../Pressable';
7
- import useMedia from '../../hooks/useMedia';
8
- import useStyle from '../../hooks/useStyle';
9
- import useModifier from '../../hooks/useModifier';
10
- import { FORM_VALIDATION_STATES } from '../../theme/proxies';
11
- import { escapeSvg } from '../../theme/functions';
12
- import FormCheckContext from './FormCheckContext';
13
- import FormCheckInputWeb from './internals/FormCheckInputWeb';
14
- import FormCheckInputNative from './internals/FormCheckInputNative';
15
- import type {
16
- ExtendedViewStyle,
17
- FormValidationState,
18
- StyleProp,
19
- ThemeVariables,
20
- UseFormFieldProps,
21
- } from '../../types';
22
-
23
- export interface FormCheckInputProps extends UseFormFieldProps {
24
- type: 'checkbox' | 'radio' | 'switch';
25
- value: boolean;
26
- onFocus?: () => void;
27
- onBlur?: () => void;
28
- onValueChange?: (value: boolean) => void;
29
- disabled?: boolean;
30
- valid?: boolean;
31
- invalid?: boolean;
32
- useNativeComponent?: boolean;
33
- autoFocus?: boolean;
34
- hitSlop?: number;
35
- style?: StyleProp<ExtendedViewStyle>;
36
- id?: string;
37
- }
38
-
39
- const styles = StyleSheet.create({
40
- '.form-check .form-check-input': css`
41
- $height: $line-height-base * 1rem;
42
- $margin-top-double: $height - $form-check-input-width;
43
-
44
- // float: left;
45
- // margin-left: $form-check-padding-start * -1;
46
- margin-top: $margin-top-double * 0.5; // added for bootstrap-rn
47
- margin-right: $form-check-padding-start - $form-check-input-width; // added for bootstrap-rn
48
- `,
49
- '.form-check-reverse .form-check-input': css`
50
- // float: right;
51
- // margin-right: $form-check-padding-start * -1;
52
- margin-right: 0; // added for bootstrap-rn
53
- // margin-left: 0;
54
- margin-left: $form-check-padding-start - $form-check-input-width; // added for bootstrap-rn
55
- `,
56
- '.form-check-input': css`
57
- width: $form-check-input-width;
58
- height: $form-check-input-width;
59
- // margin-top: ($line-height-base - $form-check-input-width) * 0.5; // line-height minus check height
60
- vertical-align: top;
61
- background-color: $form-check-input-bg;
62
- background-repeat: no-repeat;
63
- background-position: center;
64
- background-size: contain;
65
- border: $form-check-input-border;
66
- @include platform(web) {
67
- appearance: none;
68
- user-select: none; // added for bootstrap-rn
69
- color-adjust: exact; // Keep themed appearance for print
70
- }
71
- // @include transition($form-check-transition);
72
-
73
- &:active {
74
- // filter: $form-check-input-active-filter;
75
- }
76
-
77
- &:focus {
78
- border-color: $form-check-input-focus-border;
79
- @include platform(web) {
80
- outline-width: 0; // outline: 0;
81
- box-shadow: $form-check-input-focus-box-shadow;
82
- }
83
- }
84
- `,
85
- '.form-check-input[type="checkbox"]': css`
86
- border-radius: $form-check-input-border-radius;
87
- `,
88
- '.form-check-input[type="radio"]': css`
89
- border-radius: $form-check-radio-border-radius;
90
- `,
91
- '.form-check-input:checked': css`
92
- background-color: $form-check-input-checked-bg-color;
93
- border-color: $form-check-input-checked-border-color;
94
- `,
95
- '.form-check-input[type="checkbox"]:checked': css`
96
- // @if $enable-gradients {
97
- // background-image: escape-svg($form-check-input-checked-bg-image), var(--#{$variable-prefix}gradient);
98
- // } @else {
99
- background-image: ${(t: ThemeVariables) =>
100
- escapeSvg(t['form-check-input-checked-bg-image'])};
101
- // }
102
- `,
103
- '.form-check-input[type="radio"]:checked': css`
104
- // @if $enable-gradients {
105
- // background-image: escape-svg($form-check-radio-checked-bg-image), var(--#{$variable-prefix}gradient);
106
- // } @else {
107
- background-image: ${(t: ThemeVariables) =>
108
- escapeSvg(t['form-check-radio-checked-bg-image'])};
109
- // }
110
- `,
111
- '.form-check-input:disabled': css`
112
- @include platform(web) {
113
- pointer-events: none;
114
- filter: none;
115
- }
116
- opacity: $form-check-label-disabled-opacity;
117
- `,
118
- ...each(FORM_VALIDATION_STATES, (state, data: FormValidationState) => ({
119
- [`.form-check-input:${state}`]: css`
120
- border-color: ${(t: ThemeVariables) => data(t).color};
121
-
122
- &:focus {
123
- border-color: ${(t: ThemeVariables) =>
124
- data(t).color}; // added for bootstrap-rn
125
- @include platform(web) {
126
- box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
127
- rgba(
128
- ${(t: ThemeVariables) => data(t).color},
129
- $input-btn-focus-color-opacity
130
- );
131
- }
132
- }
133
- `,
134
- [`.form-check-input:${state}:checked`]: css`
135
- background-color: ${(t: ThemeVariables) => data(t).color};
136
- `,
137
- })),
138
- '.form-switch.form-check .form-check-input': css`
139
- // float: left;
140
- // margin-left: $form-switch-padding-start * -1;
141
- margin-right: $form-switch-padding-start - $form-switch-width; // added for bootstrap-rn
142
- `,
143
- '.form-switch.form-check-reverse .form-check-input': css`
144
- // margin-right: $form-switch-padding-start * -1;
145
- margin-right: 0; // added for bootstrap-rn
146
- // margin-left: 0;
147
- margin-left: $form-switch-padding-start - $form-switch-width; // added for bootstrap-rn
148
- `,
149
- '.form-switch .form-check-input': css`
150
- width: $form-switch-width;
151
- background-image: ${(t: ThemeVariables) =>
152
- escapeSvg(t['form-switch-bg-image'])};
153
- background-position: left center;
154
- border-radius: $form-switch-border-radius;
155
- // @include transition($form-switch-transition);
156
-
157
- &:focus {
158
- background-image: ${(t: ThemeVariables) =>
159
- escapeSvg(t['form-switch-focus-bg-image'])};
160
- }
161
- `,
162
- '.form-switch .form-check-input:checked': css`
163
- background-position: $form-switch-checked-bg-position;
164
-
165
- // @if $enable-gradients {
166
- // background-image: escape-svg($form-switch-checked-bg-image), var(--#{$prefix}gradient);
167
- // } @else {
168
- background-image: ${(t: ThemeVariables) =>
169
- escapeSvg(t['form-switch-checked-bg-image'])};
170
- // }
171
-
172
- &:focus {
173
- background-image: ${(t: ThemeVariables) =>
174
- escapeSvg(t['form-switch-checked-bg-image'])}; // added for bootstrap-rn
175
- }
176
- `,
177
- });
178
-
179
- const FormCheckInput = React.forwardRef<PressableRef, FormCheckInputProps>(
180
- (props, ref) => {
181
- const [modifierProps, modifierRef] = useModifier(
182
- 'useFormField',
183
- props,
184
- ref,
185
- );
186
-
187
- const context = useContext(FormCheckContext);
188
-
189
- const {
190
- type,
191
- value,
192
- onFocus = () => {},
193
- onBlur = () => {},
194
- disabled = context ? context.disabled : false,
195
- valid = context ? context.valid : false,
196
- invalid = context ? context.invalid : false,
197
- useNativeComponent = false,
198
- autoFocus = false,
199
- style,
200
- ...elementProps
201
- } = modifierProps;
202
-
203
- const media = useMedia();
204
- const [focused, setFocused] = useState(autoFocus);
205
-
206
- const classes = getStyles(styles, [
207
- context && '.form-check .form-check-input',
208
- context?.reverse && '.form-check-reverse .form-check-input',
209
- '.form-check-input',
210
- type === 'checkbox' && '.form-check-input[type="checkbox"]',
211
- type === 'radio' && '.form-check-input[type="radio"]',
212
- value && '.form-check-input:checked',
213
- type === 'checkbox' &&
214
- value &&
215
- '.form-check-input[type="checkbox"]:checked',
216
- type === 'radio' && value && '.form-check-input[type="radio"]:checked',
217
- disabled && '.form-check-input:disabled',
218
- // validation
219
- valid && '.form-check-input:valid',
220
- valid && value && '.form-check-input:valid:checked',
221
- invalid && '.form-check-input:invalid',
222
- invalid && value && '.form-check-input:invalid:checked',
223
- // switch
224
- context &&
225
- type === 'switch' &&
226
- '.form-switch.form-check .form-check-input',
227
- context?.reverse &&
228
- type === 'switch' &&
229
- '.form-switch.form-check-reverse .form-check-input',
230
- type === 'switch' && '.form-switch .form-check-input',
231
- type === 'switch' && value && '.form-switch .form-check-input:checked',
232
- ]);
233
-
234
- const resolveStyle = useStyle([classes, style]);
235
-
236
- const BaseFormCheckInput =
237
- Platform.OS === 'web' && !useNativeComponent
238
- ? FormCheckInputWeb
239
- : FormCheckInputNative;
240
-
241
- return (
242
- <BaseFormCheckInput
243
- {...elementProps}
244
- ref={modifierRef}
245
- type={type}
246
- value={value}
247
- onFocus={() => {
248
- setFocused(true);
249
- onFocus();
250
- }}
251
- onBlur={() => {
252
- setFocused(false);
253
- onBlur();
254
- }}
255
- disabled={disabled}
256
- autoFocus={autoFocus}
257
- style={resolveStyle({
258
- media,
259
- interaction: { focus: focused, focusVisible: focused },
260
- })}
261
- />
262
- );
263
- },
264
- );
265
-
266
- FormCheckInput.displayName = 'FormCheckInput';
267
-
268
- export default FormCheckInput;
1
+ import React, { useContext, useState } from 'react';
2
+ import { Platform } from 'react-native';
3
+ import StyleSheet from '../../style/StyleSheet';
4
+ import css from '../../style/css';
5
+ import { getStyles, each } from '../../utils';
6
+ import type { PressableRef } from '../Pressable';
7
+ import useMedia from '../../hooks/useMedia';
8
+ import useStyle from '../../hooks/useStyle';
9
+ import useModifier from '../../hooks/useModifier';
10
+ import { FORM_VALIDATION_STATES } from '../../theme/proxies';
11
+ import { escapeSvg } from '../../theme/functions';
12
+ import FormCheckContext from './FormCheckContext';
13
+ import FormCheckInputWeb from './internals/FormCheckInputWeb';
14
+ import FormCheckInputNative from './internals/FormCheckInputNative';
15
+ import type {
16
+ ExtendedViewStyle,
17
+ FormValidationState,
18
+ StyleProp,
19
+ ThemeVariables,
20
+ UseFormFieldProps,
21
+ } from '../../types';
22
+
23
+ export interface FormCheckInputProps extends UseFormFieldProps {
24
+ type: 'checkbox' | 'radio' | 'switch';
25
+ value: boolean;
26
+ onFocus?: () => void;
27
+ onBlur?: () => void;
28
+ onValueChange?: (value: boolean) => void;
29
+ disabled?: boolean;
30
+ valid?: boolean;
31
+ invalid?: boolean;
32
+ useNativeComponent?: boolean;
33
+ autoFocus?: boolean;
34
+ hitSlop?: number;
35
+ style?: StyleProp<ExtendedViewStyle>;
36
+ id?: string;
37
+ }
38
+
39
+ const styles = StyleSheet.create({
40
+ '.form-check .form-check-input': css`
41
+ $height: $line-height-base * 1rem;
42
+ $margin-top-double: $height - $form-check-input-width;
43
+
44
+ // float: left;
45
+ // margin-left: $form-check-padding-start * -1;
46
+ margin-top: $margin-top-double * 0.5; // added for bootstrap-rn
47
+ margin-right: $form-check-padding-start - $form-check-input-width; // added for bootstrap-rn
48
+ `,
49
+ '.form-check-reverse .form-check-input': css`
50
+ // float: right;
51
+ // margin-right: $form-check-padding-start * -1;
52
+ margin-right: 0; // added for bootstrap-rn
53
+ // margin-left: 0;
54
+ margin-left: $form-check-padding-start - $form-check-input-width; // added for bootstrap-rn
55
+ `,
56
+ '.form-check-input': css`
57
+ width: $form-check-input-width;
58
+ height: $form-check-input-width;
59
+ // margin-top: ($line-height-base - $form-check-input-width) * 0.5; // line-height minus check height
60
+ vertical-align: top;
61
+ background-color: $form-check-input-bg;
62
+ background-repeat: no-repeat;
63
+ background-position: center;
64
+ background-size: contain;
65
+ border: $form-check-input-border;
66
+ @include platform(web) {
67
+ appearance: none;
68
+ user-select: none; // added for bootstrap-rn
69
+ color-adjust: exact; // Keep themed appearance for print
70
+ }
71
+ // @include transition($form-check-transition);
72
+
73
+ &:active {
74
+ // filter: $form-check-input-active-filter;
75
+ }
76
+
77
+ &:focus {
78
+ border-color: $form-check-input-focus-border;
79
+ @include platform(web) {
80
+ outline-style: none; // outline: 0;
81
+ box-shadow: $form-check-input-focus-box-shadow;
82
+ }
83
+ }
84
+ `,
85
+ '.form-check-input[type="checkbox"]': css`
86
+ border-radius: $form-check-input-border-radius;
87
+ `,
88
+ '.form-check-input[type="radio"]': css`
89
+ border-radius: $form-check-radio-border-radius;
90
+ `,
91
+ '.form-check-input:checked': css`
92
+ background-color: $form-check-input-checked-bg-color;
93
+ border-color: $form-check-input-checked-border-color;
94
+ `,
95
+ '.form-check-input[type="checkbox"]:checked': css`
96
+ // @if $enable-gradients {
97
+ // background-image: escape-svg($form-check-input-checked-bg-image), var(--#{$variable-prefix}gradient);
98
+ // } @else {
99
+ background-image: ${(t: ThemeVariables) =>
100
+ escapeSvg(t['form-check-input-checked-bg-image'])};
101
+ // }
102
+ `,
103
+ '.form-check-input[type="radio"]:checked': css`
104
+ // @if $enable-gradients {
105
+ // background-image: escape-svg($form-check-radio-checked-bg-image), var(--#{$variable-prefix}gradient);
106
+ // } @else {
107
+ background-image: ${(t: ThemeVariables) =>
108
+ escapeSvg(t['form-check-radio-checked-bg-image'])};
109
+ // }
110
+ `,
111
+ '.form-check-input:disabled': css`
112
+ @include platform(web) {
113
+ pointer-events: none;
114
+ filter: none;
115
+ }
116
+ opacity: $form-check-label-disabled-opacity;
117
+ `,
118
+ ...each(FORM_VALIDATION_STATES, (state, data: FormValidationState) => ({
119
+ [`.form-check-input:${state}`]: css`
120
+ border-color: ${(t: ThemeVariables) => data(t).color};
121
+
122
+ &:focus {
123
+ border-color: ${(t: ThemeVariables) =>
124
+ data(t).color}; // added for bootstrap-rn
125
+ @include platform(web) {
126
+ box-shadow: 0 0 $input-btn-focus-blur $input-focus-width
127
+ rgba(
128
+ ${(t: ThemeVariables) => data(t).color},
129
+ $input-btn-focus-color-opacity
130
+ );
131
+ }
132
+ }
133
+ `,
134
+ [`.form-check-input:${state}:checked`]: css`
135
+ background-color: ${(t: ThemeVariables) => data(t).color};
136
+ `,
137
+ })),
138
+ '.form-switch.form-check .form-check-input': css`
139
+ // float: left;
140
+ // margin-left: $form-switch-padding-start * -1;
141
+ margin-right: $form-switch-padding-start - $form-switch-width; // added for bootstrap-rn
142
+ `,
143
+ '.form-switch.form-check-reverse .form-check-input': css`
144
+ // margin-right: $form-switch-padding-start * -1;
145
+ margin-right: 0; // added for bootstrap-rn
146
+ // margin-left: 0;
147
+ margin-left: $form-switch-padding-start - $form-switch-width; // added for bootstrap-rn
148
+ `,
149
+ '.form-switch .form-check-input': css`
150
+ width: $form-switch-width;
151
+ background-image: ${(t: ThemeVariables) =>
152
+ escapeSvg(t['form-switch-bg-image'])};
153
+ background-position: left center;
154
+ border-radius: $form-switch-border-radius;
155
+ // @include transition($form-switch-transition);
156
+
157
+ &:focus {
158
+ background-image: ${(t: ThemeVariables) =>
159
+ escapeSvg(t['form-switch-focus-bg-image'])};
160
+ }
161
+ `,
162
+ '.form-switch .form-check-input:checked': css`
163
+ background-position: $form-switch-checked-bg-position;
164
+
165
+ // @if $enable-gradients {
166
+ // background-image: escape-svg($form-switch-checked-bg-image), var(--#{$prefix}gradient);
167
+ // } @else {
168
+ background-image: ${(t: ThemeVariables) =>
169
+ escapeSvg(t['form-switch-checked-bg-image'])};
170
+ // }
171
+
172
+ &:focus {
173
+ background-image: ${(t: ThemeVariables) =>
174
+ escapeSvg(t['form-switch-checked-bg-image'])}; // added for bootstrap-rn
175
+ }
176
+ `,
177
+ });
178
+
179
+ const FormCheckInput = React.forwardRef<PressableRef, FormCheckInputProps>(
180
+ (props, ref) => {
181
+ const [modifierProps, modifierRef] = useModifier(
182
+ 'useFormField',
183
+ props,
184
+ ref,
185
+ );
186
+
187
+ const context = useContext(FormCheckContext);
188
+
189
+ const {
190
+ type,
191
+ value,
192
+ onFocus = () => {},
193
+ onBlur = () => {},
194
+ disabled = context ? context.disabled : false,
195
+ valid = context ? context.valid : false,
196
+ invalid = context ? context.invalid : false,
197
+ useNativeComponent = false,
198
+ autoFocus = false,
199
+ style,
200
+ ...elementProps
201
+ } = modifierProps;
202
+
203
+ const media = useMedia();
204
+ const [focused, setFocused] = useState(autoFocus);
205
+
206
+ const classes = getStyles(styles, [
207
+ context && '.form-check .form-check-input',
208
+ context?.reverse && '.form-check-reverse .form-check-input',
209
+ '.form-check-input',
210
+ type === 'checkbox' && '.form-check-input[type="checkbox"]',
211
+ type === 'radio' && '.form-check-input[type="radio"]',
212
+ value && '.form-check-input:checked',
213
+ type === 'checkbox' &&
214
+ value &&
215
+ '.form-check-input[type="checkbox"]:checked',
216
+ type === 'radio' && value && '.form-check-input[type="radio"]:checked',
217
+ disabled && '.form-check-input:disabled',
218
+ // validation
219
+ valid && '.form-check-input:valid',
220
+ valid && value && '.form-check-input:valid:checked',
221
+ invalid && '.form-check-input:invalid',
222
+ invalid && value && '.form-check-input:invalid:checked',
223
+ // switch
224
+ context &&
225
+ type === 'switch' &&
226
+ '.form-switch.form-check .form-check-input',
227
+ context?.reverse &&
228
+ type === 'switch' &&
229
+ '.form-switch.form-check-reverse .form-check-input',
230
+ type === 'switch' && '.form-switch .form-check-input',
231
+ type === 'switch' && value && '.form-switch .form-check-input:checked',
232
+ ]);
233
+
234
+ const resolveStyle = useStyle([classes, style]);
235
+
236
+ const BaseFormCheckInput =
237
+ Platform.OS === 'web' && !useNativeComponent
238
+ ? FormCheckInputWeb
239
+ : FormCheckInputNative;
240
+
241
+ return (
242
+ <BaseFormCheckInput
243
+ {...elementProps}
244
+ ref={modifierRef}
245
+ type={type}
246
+ value={value}
247
+ onFocus={() => {
248
+ setFocused(true);
249
+ onFocus();
250
+ }}
251
+ onBlur={() => {
252
+ setFocused(false);
253
+ onBlur();
254
+ }}
255
+ disabled={disabled}
256
+ autoFocus={autoFocus}
257
+ style={resolveStyle({
258
+ media,
259
+ interaction: { focus: focused, focusVisible: focused },
260
+ })}
261
+ />
262
+ );
263
+ },
264
+ );
265
+
266
+ FormCheckInput.displayName = 'FormCheckInput';
267
+
268
+ export default FormCheckInput;