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,22 +1,25 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import Overlay from '../helpers/Overlay';
|
|
4
|
-
import BackdropHandler from '../helpers/BackdropHandler';
|
|
5
|
-
import useTrigger, { TriggerProps } from '../../hooks/useTrigger';
|
|
2
|
+
import useOverlay from '../../hooks/useOverlay';
|
|
6
3
|
import { normalizeNumber } from '../../style/math';
|
|
7
4
|
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
+
import Portal from '../helpers/Portal';
|
|
6
|
+
import BackdropHandler from '../helpers/BackdropHandler';
|
|
8
7
|
import Popover from './Popover';
|
|
9
8
|
import type { ViewRef } from '../View';
|
|
10
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
OverlayTrigger,
|
|
11
|
+
OverlayPlacement,
|
|
12
|
+
OverlayProps,
|
|
13
|
+
} from '../../types';
|
|
14
|
+
import { concatRefs, optional } from '../../utils';
|
|
11
15
|
|
|
12
|
-
export interface InjectPopoverProps {
|
|
16
|
+
export interface InjectPopoverProps extends OverlayProps {
|
|
13
17
|
popover: {
|
|
14
18
|
title?: React.ReactNode;
|
|
15
19
|
content: React.ReactNode;
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} & TriggerProps;
|
|
20
|
+
trigger?: OverlayTrigger;
|
|
21
|
+
placement?: OverlayPlacement;
|
|
22
|
+
};
|
|
20
23
|
}
|
|
21
24
|
|
|
22
25
|
export default function injectPopover<Props>(
|
|
@@ -28,63 +31,68 @@ export default function injectPopover<Props>(
|
|
|
28
31
|
popover: {
|
|
29
32
|
title,
|
|
30
33
|
content,
|
|
31
|
-
autoClose = 'outside',
|
|
32
34
|
trigger = 'press',
|
|
33
35
|
placement = 'right',
|
|
34
36
|
...popoverProps
|
|
35
37
|
},
|
|
38
|
+
defaultVisible = false,
|
|
39
|
+
visible: controlledVisible,
|
|
40
|
+
onToggle = () => {},
|
|
36
41
|
...elementProps
|
|
37
42
|
} = props;
|
|
38
43
|
|
|
39
|
-
const { visible, setVisible, targetProps, targetRef, templateProps } =
|
|
40
|
-
useTrigger(trigger, popoverProps, elementProps, ref);
|
|
41
|
-
|
|
42
44
|
const offset = normalizeNumber(StyleSheet.value('popover-arrow-height'));
|
|
43
45
|
|
|
46
|
+
const overlay = useOverlay({
|
|
47
|
+
defaultVisible,
|
|
48
|
+
controlledVisible,
|
|
49
|
+
onToggle,
|
|
50
|
+
offset,
|
|
51
|
+
align: 'center',
|
|
52
|
+
placement,
|
|
53
|
+
trigger,
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
if ('maxWidth' in overlay.content.style) {
|
|
57
|
+
// @ts-expect-error We remove maxWidth, because maxWidth is set as style on Popover component.
|
|
58
|
+
delete overlay.content.style.maxWidth;
|
|
59
|
+
}
|
|
60
|
+
|
|
44
61
|
return (
|
|
45
62
|
<>
|
|
46
|
-
<Target
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
63
|
+
<Target
|
|
64
|
+
{...(elementProps as Props)}
|
|
65
|
+
{...overlay.trigger.getProps(elementProps)}
|
|
66
|
+
ref={concatRefs(ref, overlay.trigger.ref)}
|
|
67
|
+
{...optional(overlay.visible, {
|
|
68
|
+
'aria-describedby': overlay.identifier,
|
|
69
|
+
})}
|
|
70
|
+
/>
|
|
71
|
+
{overlay.visible && (
|
|
72
|
+
<Portal name={overlay.identifier}>
|
|
73
|
+
<BackdropHandler
|
|
74
|
+
onClose={() => {
|
|
75
|
+
overlay.setVisible(false);
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
<Popover
|
|
79
|
+
{...popoverProps}
|
|
80
|
+
{...overlay.content.getProps(popoverProps)}
|
|
81
|
+
ref={overlay.content.ref}
|
|
82
|
+
id={overlay.identifier}
|
|
83
|
+
placement={overlay.placement}
|
|
84
|
+
style={overlay.content.style}
|
|
85
|
+
floating
|
|
55
86
|
>
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
/>
|
|
66
|
-
<Popover
|
|
67
|
-
{...templateProps}
|
|
68
|
-
ref={overlayRef}
|
|
69
|
-
placement={overlay.placement}
|
|
70
|
-
popper={overlay.rendered}
|
|
71
|
-
style={[
|
|
72
|
-
overlay.overlayProps.style,
|
|
73
|
-
{
|
|
74
|
-
maxHeight: 'auto',
|
|
75
|
-
opacity: overlay.rendered ? 1 : 0,
|
|
76
|
-
},
|
|
77
|
-
]}
|
|
78
|
-
arrowStyle={overlay.arrowProps.style}
|
|
79
|
-
>
|
|
80
|
-
<Popover.Arrow />
|
|
81
|
-
{title && <Popover.Header>{title}</Popover.Header>}
|
|
82
|
-
<Popover.Body>{content}</Popover.Body>
|
|
83
|
-
</Popover>
|
|
84
|
-
</>
|
|
85
|
-
)}
|
|
86
|
-
</Overlay>
|
|
87
|
-
</OverlayContainer>
|
|
87
|
+
<Popover.Arrow
|
|
88
|
+
{...overlay.arrow.getProps({})}
|
|
89
|
+
ref={overlay.arrow.ref}
|
|
90
|
+
style={overlay.arrow.style}
|
|
91
|
+
/>
|
|
92
|
+
{title && <Popover.Header>{title}</Popover.Header>}
|
|
93
|
+
<Popover.Body>{content}</Popover.Body>
|
|
94
|
+
</Popover>
|
|
95
|
+
</Portal>
|
|
88
96
|
)}
|
|
89
97
|
</>
|
|
90
98
|
);
|
|
@@ -1,98 +1,79 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import { Platform } from 'react-native';
|
|
3
|
-
import View, { ViewProps, ViewRef } from '../View';
|
|
4
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
-
import { getStyles
|
|
6
|
-
import css from '../../style/css';
|
|
7
|
-
import TooltipArrow from './TooltipArrow';
|
|
8
|
-
import TooltipInner from './TooltipInner';
|
|
9
|
-
import TooltipContext from './TooltipContext';
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
export interface TooltipProps extends ViewProps {
|
|
13
|
-
placement?:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
//
|
|
28
|
-
//
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
//
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
{...elementProps}
|
|
81
|
-
ref={ref}
|
|
82
|
-
role={role}
|
|
83
|
-
style={[classes, style]}
|
|
84
|
-
textStyle={[textClasses, textStyle]}
|
|
85
|
-
>
|
|
86
|
-
<TooltipContext.Provider value={tooltip}>
|
|
87
|
-
{children}
|
|
88
|
-
</TooltipContext.Provider>
|
|
89
|
-
</View>
|
|
90
|
-
);
|
|
91
|
-
});
|
|
92
|
-
|
|
93
|
-
Tooltip.displayName = 'Tooltip';
|
|
94
|
-
|
|
95
|
-
export default Object.assign(Tooltip, {
|
|
96
|
-
Arrow: TooltipArrow,
|
|
97
|
-
Inner: TooltipInner,
|
|
98
|
-
});
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { Platform } from 'react-native';
|
|
3
|
+
import View, { ViewProps, ViewRef } from '../View';
|
|
4
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
+
import { getStyles } from '../../utils';
|
|
6
|
+
import css from '../../style/css';
|
|
7
|
+
import TooltipArrow from './TooltipArrow';
|
|
8
|
+
import TooltipInner from './TooltipInner';
|
|
9
|
+
import TooltipContext from './TooltipContext';
|
|
10
|
+
import type { OverlayPhysicalPlacement } from '../../types';
|
|
11
|
+
|
|
12
|
+
export interface TooltipProps extends ViewProps {
|
|
13
|
+
placement?: OverlayPhysicalPlacement;
|
|
14
|
+
floating?: boolean;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const styles = StyleSheet.create({
|
|
18
|
+
'.tooltip': css`
|
|
19
|
+
position: absolute;
|
|
20
|
+
// z-index: $zindex-tooltip;
|
|
21
|
+
// display: block;
|
|
22
|
+
margin: $tooltip-margin;
|
|
23
|
+
// opacity: 0;
|
|
24
|
+
`,
|
|
25
|
+
'.tooltip --text': css`
|
|
26
|
+
// Our parent element can be arbitrary since tooltips are by default inserted as a sibling of their target element.
|
|
27
|
+
// So reset our font and text properties to avoid inheriting weird values.
|
|
28
|
+
// @include reset-text();
|
|
29
|
+
font-size: $tooltip-font-size;
|
|
30
|
+
// Allow breaking very long words so they don't overflow the tooltip's bounds
|
|
31
|
+
// word-wrap: break-word;
|
|
32
|
+
`,
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
const Tooltip = React.forwardRef<ViewRef, TooltipProps>((props, ref) => {
|
|
36
|
+
const {
|
|
37
|
+
children,
|
|
38
|
+
placement = 'top',
|
|
39
|
+
floating,
|
|
40
|
+
style,
|
|
41
|
+
textStyle,
|
|
42
|
+
...elementProps
|
|
43
|
+
} = props;
|
|
44
|
+
|
|
45
|
+
const tooltip = useMemo(
|
|
46
|
+
() => ({
|
|
47
|
+
placement,
|
|
48
|
+
floating,
|
|
49
|
+
}),
|
|
50
|
+
[placement, floating],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
const classes = getStyles(styles, ['.tooltip']);
|
|
54
|
+
const textClasses = getStyles(styles, ['.tooltip --text']);
|
|
55
|
+
|
|
56
|
+
// Accessiblity role tooltip is only supported on web.
|
|
57
|
+
const role = Platform.OS === 'web' ? 'tooltip' : undefined;
|
|
58
|
+
|
|
59
|
+
return (
|
|
60
|
+
<View
|
|
61
|
+
{...elementProps}
|
|
62
|
+
ref={ref}
|
|
63
|
+
role={role}
|
|
64
|
+
style={[classes, style]}
|
|
65
|
+
textStyle={[textClasses, textStyle]}
|
|
66
|
+
>
|
|
67
|
+
<TooltipContext.Provider value={tooltip}>
|
|
68
|
+
{children}
|
|
69
|
+
</TooltipContext.Provider>
|
|
70
|
+
</View>
|
|
71
|
+
);
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
Tooltip.displayName = 'Tooltip';
|
|
75
|
+
|
|
76
|
+
export default Object.assign(Tooltip, {
|
|
77
|
+
Arrow: TooltipArrow,
|
|
78
|
+
Inner: TooltipInner,
|
|
79
|
+
});
|
|
@@ -5,6 +5,7 @@ import { getStyles } from '../../utils';
|
|
|
5
5
|
import css from '../../style/css';
|
|
6
6
|
import useForcedContext from '../../hooks/useForcedContext';
|
|
7
7
|
import TooltipContext from './TooltipContext';
|
|
8
|
+
import type { OverlayPlacement } from '../../types';
|
|
8
9
|
|
|
9
10
|
export interface TooltipArrowProps extends ViewProps {}
|
|
10
11
|
|
|
@@ -29,7 +30,7 @@ const styles = StyleSheet.create({
|
|
|
29
30
|
border-style: solid;
|
|
30
31
|
`,
|
|
31
32
|
'.bs-tooltip-top .tooltip-arrow': css`
|
|
32
|
-
bottom:
|
|
33
|
+
bottom: -1 * $tooltip-arrow-height;
|
|
33
34
|
`,
|
|
34
35
|
'.bs-tooltip-top .tooltip-arrow::before': css`
|
|
35
36
|
top: -1px;
|
|
@@ -43,7 +44,7 @@ const styles = StyleSheet.create({
|
|
|
43
44
|
border-bottom-color: transparent; // added for bootstrap-rn
|
|
44
45
|
`,
|
|
45
46
|
'.bs-tooltip-end .tooltip-arrow': css`
|
|
46
|
-
left:
|
|
47
|
+
left: -1 * $tooltip-arrow-height;
|
|
47
48
|
width: $tooltip-arrow-height;
|
|
48
49
|
height: $tooltip-arrow-width;
|
|
49
50
|
`,
|
|
@@ -59,7 +60,7 @@ const styles = StyleSheet.create({
|
|
|
59
60
|
border-bottom-color: transparent; // added for bootstrap-rn
|
|
60
61
|
`,
|
|
61
62
|
'.bs-tooltip-bottom .tooltip-arrow': css`
|
|
62
|
-
top:
|
|
63
|
+
top: -1 * $tooltip-arrow-height;
|
|
63
64
|
`,
|
|
64
65
|
'.bs-tooltip-bottom .tooltip-arrow::before': css`
|
|
65
66
|
bottom: -1px;
|
|
@@ -73,7 +74,7 @@ const styles = StyleSheet.create({
|
|
|
73
74
|
border-bottom-color: $tooltip-arrow-color;
|
|
74
75
|
`,
|
|
75
76
|
'.bs-tooltip-start .tooltip-arrow': css`
|
|
76
|
-
right:
|
|
77
|
+
right: -1 * $tooltip-arrow-height;
|
|
77
78
|
width: $tooltip-arrow-height;
|
|
78
79
|
height: $tooltip-arrow-width;
|
|
79
80
|
`,
|
|
@@ -90,23 +91,40 @@ const styles = StyleSheet.create({
|
|
|
90
91
|
`,
|
|
91
92
|
});
|
|
92
93
|
|
|
94
|
+
const transformPlacement = (placement: OverlayPlacement) => {
|
|
95
|
+
if (placement === 'left') {
|
|
96
|
+
return 'start';
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (placement === 'right') {
|
|
100
|
+
return 'end';
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return placement;
|
|
104
|
+
};
|
|
105
|
+
|
|
93
106
|
const TooltipArrow = React.forwardRef<ViewRef, TooltipArrowProps>(
|
|
94
107
|
(props, ref) => {
|
|
95
108
|
const { style, ...elementProps } = props;
|
|
96
109
|
|
|
97
|
-
const
|
|
110
|
+
const context = useForcedContext(TooltipContext);
|
|
111
|
+
|
|
112
|
+
// For some reason the classes are named start/end, but they always define
|
|
113
|
+
// the overlay on the left/right placement, so it has no effect on RTL.
|
|
114
|
+
// Hint: RTL is already handled by the useOverlay hook.
|
|
115
|
+
const placement = transformPlacement(context.placement);
|
|
98
116
|
|
|
99
117
|
const classes = getStyles(styles, [
|
|
100
118
|
'.tooltip-arrow',
|
|
101
|
-
|
|
119
|
+
context.floating && `.bs-tooltip-${placement} .tooltip-arrow`,
|
|
102
120
|
]);
|
|
103
121
|
const beforeClasses = getStyles(styles, [
|
|
104
122
|
'.tooltip-arrow::before',
|
|
105
|
-
|
|
123
|
+
context.floating && `.bs-tooltip-${placement} .tooltip-arrow::before`,
|
|
106
124
|
]);
|
|
107
125
|
|
|
108
126
|
return (
|
|
109
|
-
<View {...elementProps} ref={ref} style={[classes,
|
|
127
|
+
<View {...elementProps} ref={ref} style={[classes, style]}>
|
|
110
128
|
<View style={beforeClasses} />
|
|
111
129
|
</View>
|
|
112
130
|
);
|
|
@@ -1,18 +1,13 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const TooltipContext = React.createContext<TooltipContextType | null>(null);
|
|
15
|
-
|
|
16
|
-
TooltipContext.displayName = 'TooltipContext';
|
|
17
|
-
|
|
18
|
-
export default TooltipContext;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { OverlayPlacement } from '../../types';
|
|
3
|
+
|
|
4
|
+
type TooltipContextType = {
|
|
5
|
+
placement: OverlayPlacement;
|
|
6
|
+
floating?: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
const TooltipContext = React.createContext<TooltipContextType | null>(null);
|
|
10
|
+
|
|
11
|
+
TooltipContext.displayName = 'TooltipContext';
|
|
12
|
+
|
|
13
|
+
export default TooltipContext;
|
|
@@ -1,21 +1,24 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import
|
|
3
|
-
import Overlay from '../helpers/Overlay';
|
|
4
|
-
import BackdropHandler from '../helpers/BackdropHandler';
|
|
5
|
-
import useTrigger, { TriggerProps } from '../../hooks/useTrigger';
|
|
2
|
+
import useOverlay from '../../hooks/useOverlay';
|
|
6
3
|
import { normalizeNumber } from '../../style/math';
|
|
7
4
|
import StyleSheet from '../../style/StyleSheet';
|
|
5
|
+
import Portal from '../helpers/Portal';
|
|
6
|
+
import BackdropHandler from '../helpers/BackdropHandler';
|
|
8
7
|
import Tooltip from './Tooltip';
|
|
9
8
|
import type { ViewRef } from '../View';
|
|
10
|
-
import type {
|
|
9
|
+
import type {
|
|
10
|
+
OverlayTrigger,
|
|
11
|
+
OverlayPlacement,
|
|
12
|
+
OverlayProps,
|
|
13
|
+
} from '../../types';
|
|
14
|
+
import { concatRefs, optional } from '../../utils';
|
|
11
15
|
|
|
12
|
-
export interface InjectTooltipProps {
|
|
16
|
+
export interface InjectTooltipProps extends OverlayProps {
|
|
13
17
|
tooltip: {
|
|
14
18
|
title: React.ReactNode;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} & TriggerProps;
|
|
19
|
+
trigger?: OverlayTrigger;
|
|
20
|
+
placement?: OverlayPlacement;
|
|
21
|
+
};
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
export default function injectTooltip<Props>(
|
|
@@ -26,61 +29,67 @@ export default function injectTooltip<Props>(
|
|
|
26
29
|
const {
|
|
27
30
|
tooltip: {
|
|
28
31
|
title,
|
|
29
|
-
autoClose = 'outside',
|
|
30
32
|
trigger = 'hover focus',
|
|
31
33
|
placement = 'top',
|
|
32
34
|
...tooltipProps
|
|
33
35
|
},
|
|
36
|
+
defaultVisible = false,
|
|
37
|
+
visible: controlledVisible,
|
|
38
|
+
onToggle = () => {},
|
|
34
39
|
...elementProps
|
|
35
40
|
} = props;
|
|
36
41
|
|
|
37
|
-
const { visible, setVisible, targetProps, targetRef, templateProps } =
|
|
38
|
-
useTrigger(trigger, tooltipProps, elementProps, ref);
|
|
39
|
-
|
|
40
42
|
const offset = normalizeNumber(StyleSheet.value('tooltip-arrow-height'));
|
|
41
43
|
|
|
44
|
+
const overlay = useOverlay({
|
|
45
|
+
defaultVisible,
|
|
46
|
+
controlledVisible,
|
|
47
|
+
onToggle,
|
|
48
|
+
offset,
|
|
49
|
+
align: 'center',
|
|
50
|
+
placement,
|
|
51
|
+
trigger,
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
if ('maxWidth' in overlay.content.style) {
|
|
55
|
+
// @ts-expect-error We remove maxWidth, because maxWidth is set as style on Tooltip component.
|
|
56
|
+
delete overlay.content.style.maxWidth;
|
|
57
|
+
}
|
|
58
|
+
|
|
42
59
|
return (
|
|
43
60
|
<>
|
|
44
|
-
<Target
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
61
|
+
<Target
|
|
62
|
+
{...(elementProps as Props)}
|
|
63
|
+
{...overlay.trigger.getProps(elementProps)}
|
|
64
|
+
ref={concatRefs(ref, overlay.trigger.ref)}
|
|
65
|
+
{...optional(overlay.visible, {
|
|
66
|
+
'aria-describedby': overlay.identifier,
|
|
67
|
+
})}
|
|
68
|
+
/>
|
|
69
|
+
{overlay.visible && (
|
|
70
|
+
<Portal name={overlay.identifier}>
|
|
71
|
+
<BackdropHandler
|
|
72
|
+
onClose={() => {
|
|
73
|
+
overlay.setVisible(false);
|
|
74
|
+
}}
|
|
75
|
+
/>
|
|
76
|
+
<Tooltip
|
|
77
|
+
{...tooltipProps}
|
|
78
|
+
{...overlay.content.getProps(tooltipProps)}
|
|
79
|
+
ref={overlay.content.ref}
|
|
80
|
+
id={overlay.identifier}
|
|
81
|
+
placement={overlay.placement}
|
|
82
|
+
style={overlay.content.style}
|
|
83
|
+
floating
|
|
52
84
|
>
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
autoClose={autoClose}
|
|
62
|
-
/>
|
|
63
|
-
<Tooltip
|
|
64
|
-
{...templateProps}
|
|
65
|
-
ref={overlayRef}
|
|
66
|
-
placement={overlay.placement}
|
|
67
|
-
popper={overlay.rendered}
|
|
68
|
-
style={[
|
|
69
|
-
overlay.overlayProps.style,
|
|
70
|
-
{
|
|
71
|
-
maxHeight: 'auto',
|
|
72
|
-
opacity: overlay.rendered ? 1 : 0,
|
|
73
|
-
},
|
|
74
|
-
]}
|
|
75
|
-
arrowStyle={overlay.arrowProps.style}
|
|
76
|
-
>
|
|
77
|
-
<Tooltip.Arrow />
|
|
78
|
-
<Tooltip.Inner>{title}</Tooltip.Inner>
|
|
79
|
-
</Tooltip>
|
|
80
|
-
</>
|
|
81
|
-
)}
|
|
82
|
-
</Overlay>
|
|
83
|
-
</OverlayContainer>
|
|
85
|
+
<Tooltip.Arrow
|
|
86
|
+
{...overlay.arrow.getProps({})}
|
|
87
|
+
ref={overlay.arrow.ref}
|
|
88
|
+
style={overlay.arrow.style}
|
|
89
|
+
/>
|
|
90
|
+
<Tooltip.Inner>{title}</Tooltip.Inner>
|
|
91
|
+
</Tooltip>
|
|
92
|
+
</Portal>
|
|
84
93
|
)}
|
|
85
94
|
</>
|
|
86
95
|
);
|