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.
- package/lib/module/Context.js.map +1 -1
- package/lib/module/Provider.js +3 -7
- package/lib/module/Provider.js.map +1 -1
- package/lib/module/components/Body.js +8 -1
- package/lib/module/components/Body.js.map +1 -1
- package/lib/module/components/buttons/Button.js +10 -8
- package/lib/module/components/buttons/Button.js.map +1 -1
- package/lib/module/components/close/CloseButton.js +7 -3
- package/lib/module/components/close/CloseButton.js.map +1 -1
- package/lib/module/components/collapse/useCollapse.js +2 -3
- package/lib/module/components/collapse/useCollapse.js.map +1 -1
- package/lib/module/components/dropdown/Dropdown.js +1 -2
- package/lib/module/components/dropdown/Dropdown.js.map +1 -1
- package/lib/module/components/dropdown/DropdownContext.js.map +1 -1
- package/lib/module/components/dropdown/DropdownMenu.js +33 -59
- package/lib/module/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/module/components/dropdown/useDismissDropdown.js +5 -4
- package/lib/module/components/dropdown/useDismissDropdown.js.map +1 -1
- package/lib/module/components/dropdown/useDropdown.js +35 -11
- package/lib/module/components/dropdown/useDropdown.js.map +1 -1
- package/lib/module/components/dropdown/useToggleDropdown.js +4 -6
- package/lib/module/components/dropdown/useToggleDropdown.js.map +1 -1
- package/lib/module/components/forms/FormCheckInput.js +1 -1
- package/lib/module/components/forms/Input.js +1 -1
- package/lib/module/components/forms/internals/PickerNative.js +1 -1
- package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
- package/lib/module/components/helpers/BackdropHandler.js +6 -92
- package/lib/module/components/helpers/BackdropHandler.js.map +1 -1
- package/lib/module/components/helpers/BackdropHandler.web.js +8 -0
- package/lib/module/components/helpers/BackdropHandler.web.js.map +1 -0
- package/lib/module/components/helpers/Dialog.js +29 -0
- package/lib/module/components/helpers/Dialog.js.map +1 -0
- package/lib/module/components/helpers/Dialog.web.js +117 -0
- package/lib/module/components/helpers/Dialog.web.js.map +1 -0
- package/lib/module/components/helpers/Portal.js +5 -0
- package/lib/module/components/helpers/Portal.js.map +1 -0
- package/lib/module/components/helpers/Portal.web.js +16 -0
- package/lib/module/components/helpers/Portal.web.js.map +1 -0
- package/lib/module/components/helpers/PortalHost.js +5 -0
- package/lib/module/components/helpers/PortalHost.js.map +1 -0
- package/lib/module/components/helpers/PortalHost.web.js +15 -0
- package/lib/module/components/helpers/PortalHost.web.js.map +1 -0
- package/lib/module/components/modal/Modal.js +58 -48
- package/lib/module/components/modal/Modal.js.map +1 -1
- package/lib/module/components/modal/ModalContext.js.map +1 -1
- package/lib/module/components/modal/ModalTitle.js +6 -0
- package/lib/module/components/modal/ModalTitle.js.map +1 -1
- package/lib/module/components/modal/useModal.js +4 -13
- package/lib/module/components/modal/useModal.js.map +1 -1
- package/lib/module/components/nav/useTabbable.js +2 -3
- package/lib/module/components/nav/useTabbable.js.map +1 -1
- package/lib/module/components/navbar/NavbarToggler.js +1 -1
- package/lib/module/components/navbar/useNavbar.js +2 -3
- package/lib/module/components/navbar/useNavbar.js.map +1 -1
- package/lib/module/components/offcanvas/Offcanvas.js +84 -82
- package/lib/module/components/offcanvas/Offcanvas.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasTitle.js +6 -0
- package/lib/module/components/offcanvas/OffcanvasTitle.js.map +1 -1
- package/lib/module/components/offcanvas/useOffcanvas.js +6 -14
- package/lib/module/components/offcanvas/useOffcanvas.js.map +1 -1
- package/lib/module/components/pagination/PaginationItem.js +39 -39
- package/lib/module/components/popover/Popover.js +6 -8
- package/lib/module/components/popover/Popover.js.map +1 -1
- package/lib/module/components/popover/PopoverArrow.js +18 -9
- package/lib/module/components/popover/PopoverArrow.js.map +1 -1
- package/lib/module/components/popover/PopoverContext.js.map +1 -1
- package/lib/module/components/popover/injectPopover.js +48 -45
- package/lib/module/components/popover/injectPopover.js.map +1 -1
- package/lib/module/components/tooltip/Tooltip.js +7 -23
- package/lib/module/components/tooltip/Tooltip.js.map +1 -1
- package/lib/module/components/tooltip/TooltipArrow.js +22 -12
- package/lib/module/components/tooltip/TooltipArrow.js.map +1 -1
- package/lib/module/components/tooltip/TooltipContext.js.map +1 -1
- package/lib/module/components/tooltip/injectTooltip.js +46 -42
- package/lib/module/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/module/hooks/useBackgroundNative.js.map +1 -1
- package/lib/module/hooks/useFocusRing.js +13 -0
- package/lib/module/hooks/useFocusRing.js.map +1 -0
- package/lib/module/hooks/useFocusRing.web.js +5 -0
- package/lib/module/hooks/useFocusRing.web.js.map +1 -0
- package/lib/module/hooks/useInteractionState.js +11 -11
- package/lib/module/hooks/useInteractionState.js.map +1 -1
- package/lib/module/hooks/useOverlay.js +121 -0
- package/lib/module/hooks/useOverlay.js.map +1 -0
- package/lib/module/hooks/useOverlay.web.js +113 -0
- package/lib/module/hooks/useOverlay.web.js.map +1 -0
- package/lib/module/hooks/useScrollbarEffects.js +7 -60
- package/lib/module/hooks/useScrollbarEffects.js.map +1 -1
- package/lib/module/hooks/useScrollbarEffects.web.js +59 -0
- package/lib/module/hooks/useScrollbarEffects.web.js.map +1 -0
- package/lib/module/index.js +3 -3
- package/lib/module/index.js.map +1 -1
- package/lib/module/style/StyleSheet.js +1 -3
- package/lib/module/style/StyleSheet.js.map +1 -1
- package/lib/module/theme/variables.js +9 -9
- package/lib/module/utils.js +0 -11
- package/lib/module/utils.js.map +1 -1
- package/lib/typescript/Context.d.ts +0 -1
- package/lib/typescript/Context.d.ts.map +1 -1
- package/lib/typescript/Provider.d.ts.map +1 -1
- package/lib/typescript/components/Body.d.ts.map +1 -1
- package/lib/typescript/components/Link.d.ts +1 -1
- package/lib/typescript/components/Link.d.ts.map +1 -1
- package/lib/typescript/components/Pressable.d.ts +1 -1
- package/lib/typescript/components/Pressable.d.ts.map +1 -1
- package/lib/typescript/components/TextInput.d.ts +3 -3
- package/lib/typescript/components/TextInput.d.ts.map +1 -1
- package/lib/typescript/components/buttons/Button.d.ts +1 -1
- package/lib/typescript/components/buttons/Button.d.ts.map +1 -1
- package/lib/typescript/components/close/CloseButton.d.ts +1 -1
- package/lib/typescript/components/close/CloseButton.d.ts.map +1 -1
- package/lib/typescript/components/collapse/useCollapse.d.ts.map +1 -1
- package/lib/typescript/components/dropdown/Dropdown.d.ts +0 -1
- package/lib/typescript/components/dropdown/Dropdown.d.ts.map +1 -1
- package/lib/typescript/components/dropdown/DropdownContext.d.ts +14 -3
- package/lib/typescript/components/dropdown/DropdownContext.d.ts.map +1 -1
- package/lib/typescript/components/dropdown/DropdownMenu.d.ts +0 -1
- package/lib/typescript/components/dropdown/DropdownMenu.d.ts.map +1 -1
- package/lib/typescript/components/dropdown/useDismissDropdown.d.ts +1 -1
- package/lib/typescript/components/dropdown/useDismissDropdown.d.ts.map +1 -1
- package/lib/typescript/components/dropdown/useDropdown.d.ts +38 -4
- package/lib/typescript/components/dropdown/useDropdown.d.ts.map +1 -1
- package/lib/typescript/components/dropdown/useToggleDropdown.d.ts +4 -3
- package/lib/typescript/components/dropdown/useToggleDropdown.d.ts.map +1 -1
- package/lib/typescript/components/forms/Picker.d.ts +1 -1
- package/lib/typescript/components/forms/internals/PickerNative.d.ts +1 -1
- package/lib/typescript/components/forms/internals/PickerNative.d.ts.map +1 -1
- package/lib/typescript/components/forms/internals/PickerWeb.d.ts +1 -1
- package/lib/typescript/components/forms/internals/PickerWeb.d.ts.map +1 -1
- package/lib/typescript/components/helpers/BackdropHandler.d.ts +2 -11
- package/lib/typescript/components/helpers/BackdropHandler.d.ts.map +1 -1
- package/lib/typescript/components/helpers/BackdropHandler.web.d.ts +3 -0
- package/lib/typescript/components/helpers/BackdropHandler.web.d.ts.map +1 -0
- package/lib/typescript/components/helpers/Dialog.d.ts +15 -0
- package/lib/typescript/components/helpers/Dialog.d.ts.map +1 -0
- package/lib/typescript/components/helpers/Dialog.web.d.ts +15 -0
- package/lib/typescript/components/helpers/Dialog.web.d.ts.map +1 -0
- package/lib/typescript/components/helpers/Portal.d.ts +8 -0
- package/lib/typescript/components/helpers/Portal.d.ts.map +1 -0
- package/lib/typescript/components/helpers/Portal.web.d.ts +8 -0
- package/lib/typescript/components/helpers/Portal.web.d.ts.map +1 -0
- package/lib/typescript/components/helpers/PortalHost.d.ts +6 -0
- package/lib/typescript/components/helpers/PortalHost.d.ts.map +1 -0
- package/lib/typescript/components/helpers/PortalHost.web.d.ts +7 -0
- package/lib/typescript/components/helpers/PortalHost.web.d.ts.map +1 -0
- package/lib/typescript/components/list-group/ListGroup.d.ts +1 -1
- package/lib/typescript/components/list-group/ListGroupItemAction.d.ts +1 -1
- package/lib/typescript/components/list-group/ListGroupItemAction.d.ts.map +1 -1
- package/lib/typescript/components/modal/Modal.d.ts +1 -1
- package/lib/typescript/components/modal/Modal.d.ts.map +1 -1
- package/lib/typescript/components/modal/ModalContext.d.ts +1 -0
- package/lib/typescript/components/modal/ModalContext.d.ts.map +1 -1
- package/lib/typescript/components/modal/ModalTitle.d.ts.map +1 -1
- package/lib/typescript/components/modal/useModal.d.ts +2 -1
- package/lib/typescript/components/modal/useModal.d.ts.map +1 -1
- package/lib/typescript/components/nav/Nav.d.ts +1 -1
- package/lib/typescript/components/nav/NavLink.d.ts +1 -1
- package/lib/typescript/components/nav/NavLink.d.ts.map +1 -1
- package/lib/typescript/components/nav/useTabbable.d.ts.map +1 -1
- package/lib/typescript/components/navbar/Navbar.d.ts +2 -2
- package/lib/typescript/components/navbar/NavbarBrand.d.ts +1 -1
- package/lib/typescript/components/navbar/NavbarBrand.d.ts.map +1 -1
- package/lib/typescript/components/navbar/NavbarToggler.d.ts +1 -1
- package/lib/typescript/components/navbar/NavbarToggler.d.ts.map +1 -1
- package/lib/typescript/components/navbar/useNavbar.d.ts.map +1 -1
- package/lib/typescript/components/offcanvas/Offcanvas.d.ts +1 -4
- package/lib/typescript/components/offcanvas/Offcanvas.d.ts.map +1 -1
- package/lib/typescript/components/offcanvas/OffcanvasContext.d.ts +3 -1
- package/lib/typescript/components/offcanvas/OffcanvasContext.d.ts.map +1 -1
- package/lib/typescript/components/offcanvas/OffcanvasTitle.d.ts.map +1 -1
- package/lib/typescript/components/offcanvas/useOffcanvas.d.ts +3 -1
- package/lib/typescript/components/offcanvas/useOffcanvas.d.ts.map +1 -1
- package/lib/typescript/components/popover/Popover.d.ts +3 -4
- package/lib/typescript/components/popover/Popover.d.ts.map +1 -1
- package/lib/typescript/components/popover/PopoverArrow.d.ts.map +1 -1
- package/lib/typescript/components/popover/PopoverContext.d.ts +3 -4
- package/lib/typescript/components/popover/PopoverContext.d.ts.map +1 -1
- package/lib/typescript/components/popover/injectPopover.d.ts +5 -7
- package/lib/typescript/components/popover/injectPopover.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/Tooltip.d.ts +3 -4
- package/lib/typescript/components/tooltip/Tooltip.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/TooltipArrow.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/TooltipContext.d.ts +3 -4
- package/lib/typescript/components/tooltip/TooltipContext.d.ts.map +1 -1
- package/lib/typescript/components/tooltip/injectTooltip.d.ts +5 -7
- package/lib/typescript/components/tooltip/injectTooltip.d.ts.map +1 -1
- package/lib/typescript/hooks/useBackgroundNative.d.ts.map +1 -1
- package/lib/typescript/hooks/useFocusRing.d.ts +3 -0
- package/lib/typescript/hooks/useFocusRing.d.ts.map +1 -0
- package/lib/typescript/hooks/useFocusRing.web.d.ts +3 -0
- package/lib/typescript/hooks/useFocusRing.web.d.ts.map +1 -0
- package/lib/typescript/hooks/useInteractionState.d.ts +7 -7
- package/lib/typescript/hooks/useInteractionState.d.ts.map +1 -1
- package/lib/typescript/hooks/useOverlay.d.ts +64 -0
- package/lib/typescript/hooks/useOverlay.d.ts.map +1 -0
- package/lib/typescript/hooks/useOverlay.web.d.ts +37 -0
- package/lib/typescript/hooks/useOverlay.web.d.ts.map +1 -0
- package/lib/typescript/hooks/useScrollbarEffects.d.ts.map +1 -1
- package/lib/typescript/hooks/useScrollbarEffects.web.d.ts +7 -0
- package/lib/typescript/hooks/useScrollbarEffects.web.d.ts.map +1 -0
- package/lib/typescript/index.d.ts +5 -4
- package/lib/typescript/index.d.ts.map +1 -1
- package/lib/typescript/style/StyleSheet.d.ts.map +1 -1
- package/lib/typescript/types.d.ts +12 -6
- package/lib/typescript/types.d.ts.map +1 -1
- package/lib/typescript/utils.d.ts +2 -3
- package/lib/typescript/utils.d.ts.map +1 -1
- package/package.json +92 -85
- package/src/Context.ts +37 -38
- package/src/Provider.tsx +61 -66
- package/src/components/Body.tsx +16 -1
- package/src/components/TextInput.tsx +66 -66
- package/src/components/buttons/Button.tsx +381 -379
- package/src/components/close/CloseButton.tsx +142 -138
- package/src/components/collapse/useCollapse.ts +25 -26
- package/src/components/dropdown/Dropdown.tsx +77 -80
- package/src/components/dropdown/DropdownContext.ts +14 -3
- package/src/components/dropdown/DropdownMenu.tsx +243 -284
- package/src/components/dropdown/useDismissDropdown.ts +30 -29
- package/src/components/dropdown/useDropdown.ts +55 -38
- package/src/components/dropdown/useToggleDropdown.ts +31 -32
- package/src/components/forms/FormCheckInput.tsx +268 -268
- package/src/components/forms/Input.tsx +220 -220
- package/src/components/forms/internals/PickerNative.tsx +9 -10
- package/src/components/helpers/BackdropHandler.tsx +5 -119
- package/src/components/helpers/BackdropHandler.web.tsx +6 -0
- package/src/components/helpers/Dialog.tsx +49 -0
- package/src/components/helpers/Dialog.web.tsx +145 -0
- package/src/components/helpers/Portal.tsx +10 -0
- package/src/components/helpers/Portal.web.tsx +22 -0
- package/src/components/helpers/PortalHost.tsx +7 -0
- package/src/components/helpers/PortalHost.web.tsx +14 -0
- package/src/components/modal/Modal.tsx +60 -48
- package/src/components/modal/ModalContext.ts +12 -11
- package/src/components/modal/ModalTitle.tsx +41 -31
- package/src/components/modal/useModal.ts +13 -25
- package/src/components/nav/useTabbable.ts +31 -32
- package/src/components/navbar/NavbarToggler.tsx +130 -130
- package/src/components/navbar/useNavbar.ts +30 -31
- package/src/components/offcanvas/Offcanvas.tsx +91 -92
- package/src/components/offcanvas/OffcanvasContext.ts +13 -11
- package/src/components/offcanvas/OffcanvasTitle.tsx +43 -33
- package/src/components/offcanvas/useOffcanvas.ts +12 -20
- package/src/components/pagination/PaginationItem.tsx +139 -139
- package/src/components/popover/Popover.tsx +87 -90
- package/src/components/popover/PopoverArrow.tsx +22 -6
- package/src/components/popover/PopoverContext.ts +13 -18
- package/src/components/popover/injectPopover.tsx +63 -55
- package/src/components/tooltip/Tooltip.tsx +79 -98
- package/src/components/tooltip/TooltipArrow.tsx +26 -8
- package/src/components/tooltip/TooltipContext.ts +13 -18
- package/src/components/tooltip/injectTooltip.tsx +62 -53
- package/src/hooks/useAction.ts +78 -78
- package/src/hooks/useBackgroundNative.tsx +6 -4
- package/src/hooks/useFocusRing.ts +13 -0
- package/src/hooks/useFocusRing.web.ts +3 -0
- package/src/hooks/useInteractionState.ts +75 -81
- package/src/hooks/useOverlay.ts +197 -0
- package/src/hooks/useOverlay.web.ts +190 -0
- package/src/hooks/useScrollbarEffects.ts +5 -83
- package/src/hooks/useScrollbarEffects.web.ts +83 -0
- package/src/index.ts +5 -5
- package/src/style/StyleSheet.ts +2 -5
- package/src/theme/variables.ts +1420 -1420
- package/src/types.ts +14 -14
- package/src/utils.ts +4 -22
- package/lib/module/components/SafeAreaView.js +0 -42
- package/lib/module/components/SafeAreaView.js.map +0 -1
- package/lib/module/components/helpers/Overlay.js +0 -50
- package/lib/module/components/helpers/Overlay.js.map +0 -1
- package/lib/module/hooks/useIdentifier.js +0 -14
- package/lib/module/hooks/useIdentifier.js.map +0 -1
- package/lib/module/hooks/useTrigger.js +0 -97
- package/lib/module/hooks/useTrigger.js.map +0 -1
- package/lib/typescript/components/SafeAreaView.d.ts +0 -12
- package/lib/typescript/components/SafeAreaView.d.ts.map +0 -1
- package/lib/typescript/components/helpers/Overlay.d.ts +0 -28
- package/lib/typescript/components/helpers/Overlay.d.ts.map +0 -1
- package/lib/typescript/hooks/useIdentifier.d.ts +0 -2
- package/lib/typescript/hooks/useIdentifier.d.ts.map +0 -1
- package/lib/typescript/hooks/useTrigger.d.ts +0 -33
- package/lib/typescript/hooks/useTrigger.d.ts.map +0 -1
- package/src/components/SafeAreaView.tsx +0 -64
- package/src/components/helpers/Overlay.tsx +0 -81
- package/src/hooks/useIdentifier.ts +0 -15
- 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-
|
|
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
|
-
|
|
5
|
-
|
|
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
|
|
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:
|
|
145
|
-
onFocus(event
|
|
143
|
+
const handleFocus = (event: FocusEvent) => {
|
|
144
|
+
onFocus(event);
|
|
146
145
|
};
|
|
147
146
|
|
|
148
|
-
const handleBlur = (event:
|
|
149
|
-
onBlur(event
|
|
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:
|
|
160
|
+
onFocus={(event: FocusEvent) => {
|
|
162
161
|
handleFocus(event);
|
|
163
162
|
}}
|
|
164
|
-
onBlur={(event:
|
|
163
|
+
onBlur={(event: BlurEvent) => {
|
|
165
164
|
handleBlur(event);
|
|
166
165
|
}}
|
|
167
166
|
disabled={disabled}
|
|
@@ -1,126 +1,14 @@
|
|
|
1
|
-
import React
|
|
2
|
-
import {
|
|
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
|
-
|
|
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={
|
|
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;
|