bootstrap-rn 0.4.6 → 0.4.8
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/Picker.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 +31 -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 +28 -21
- package/src/Context.ts +37 -38
- package/src/Provider.tsx +61 -66
- package/src/components/Body.tsx +68 -53
- 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/Picker.tsx +1 -1
- 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 +42 -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
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
import { type HTMLProps, useId, useMemo, useRef } from 'react';
|
|
2
|
+
import { I18nManager } from 'react-native';
|
|
3
|
+
import {
|
|
4
|
+
useFloating,
|
|
5
|
+
arrow,
|
|
6
|
+
flip,
|
|
7
|
+
shift,
|
|
8
|
+
offset as applyOffset,
|
|
9
|
+
autoUpdate,
|
|
10
|
+
useDismiss,
|
|
11
|
+
useClick,
|
|
12
|
+
useFocus,
|
|
13
|
+
useHover,
|
|
14
|
+
useInteractions,
|
|
15
|
+
type Placement,
|
|
16
|
+
type UseInteractionsReturn,
|
|
17
|
+
} from '@floating-ui/react';
|
|
18
|
+
import useControlledState from './useControlledState';
|
|
19
|
+
import type {
|
|
20
|
+
OverlayPhysicalPlacement,
|
|
21
|
+
OverlayTrigger,
|
|
22
|
+
OverlayAlignment,
|
|
23
|
+
OverlayPlacement,
|
|
24
|
+
} from '../types';
|
|
25
|
+
import { optional } from '../utils';
|
|
26
|
+
|
|
27
|
+
type UseOverlayOptions = {
|
|
28
|
+
defaultVisible: boolean;
|
|
29
|
+
controlledVisible: boolean | undefined;
|
|
30
|
+
onToggle: (value: boolean) => void;
|
|
31
|
+
offset: number;
|
|
32
|
+
align: OverlayAlignment;
|
|
33
|
+
placement: OverlayPlacement;
|
|
34
|
+
trigger?: OverlayTrigger;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const transformPlacement = (placement: OverlayPlacement) => {
|
|
38
|
+
if (placement === 'start') {
|
|
39
|
+
return I18nManager.isRTL ? 'right' : 'left';
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (placement === 'end') {
|
|
43
|
+
return I18nManager.isRTL ? 'left' : 'right';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return placement;
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const getAlignedPlacement = (
|
|
50
|
+
placement: OverlayPlacement,
|
|
51
|
+
align: OverlayAlignment,
|
|
52
|
+
) => {
|
|
53
|
+
const transformedPlacement = transformPlacement(placement);
|
|
54
|
+
|
|
55
|
+
if (align === 'center') {
|
|
56
|
+
return transformedPlacement;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return `${transformedPlacement}-${align}` as Placement;
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
const transformReferenceProps =
|
|
63
|
+
(handle: UseInteractionsReturn['getReferenceProps']) =>
|
|
64
|
+
(props: HTMLProps<Element> | undefined) => {
|
|
65
|
+
const { onClick, ...referenceProps } = handle(props);
|
|
66
|
+
|
|
67
|
+
return { ...referenceProps, onPress: onClick };
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export default function useOverlay({
|
|
71
|
+
defaultVisible,
|
|
72
|
+
controlledVisible,
|
|
73
|
+
onToggle: handleToggle,
|
|
74
|
+
offset,
|
|
75
|
+
align,
|
|
76
|
+
placement,
|
|
77
|
+
trigger = 'press',
|
|
78
|
+
}: UseOverlayOptions) {
|
|
79
|
+
const identifier = useId();
|
|
80
|
+
|
|
81
|
+
const [visible, setVisible] = useControlledState(
|
|
82
|
+
defaultVisible,
|
|
83
|
+
controlledVisible,
|
|
84
|
+
handleToggle,
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const arrowRef = useRef(null);
|
|
88
|
+
const alignedPlacement = getAlignedPlacement(placement, align);
|
|
89
|
+
|
|
90
|
+
const floating = useFloating({
|
|
91
|
+
open: visible,
|
|
92
|
+
onOpenChange: setVisible,
|
|
93
|
+
placement: alignedPlacement,
|
|
94
|
+
middleware: [
|
|
95
|
+
arrow({
|
|
96
|
+
element: arrowRef,
|
|
97
|
+
}),
|
|
98
|
+
applyOffset({ mainAxis: offset }),
|
|
99
|
+
flip({
|
|
100
|
+
fallbackPlacements:
|
|
101
|
+
placement === 'top' || placement === 'bottom'
|
|
102
|
+
? [
|
|
103
|
+
getAlignedPlacement('top', align),
|
|
104
|
+
getAlignedPlacement('bottom', align),
|
|
105
|
+
'right',
|
|
106
|
+
'left',
|
|
107
|
+
]
|
|
108
|
+
: [
|
|
109
|
+
getAlignedPlacement('right', align),
|
|
110
|
+
getAlignedPlacement('left', align),
|
|
111
|
+
'top',
|
|
112
|
+
'bottom',
|
|
113
|
+
],
|
|
114
|
+
}),
|
|
115
|
+
shift(),
|
|
116
|
+
],
|
|
117
|
+
whileElementsMounted: autoUpdate,
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
const interactions = trigger.split(' ');
|
|
121
|
+
|
|
122
|
+
const click = useClick(floating.context, {
|
|
123
|
+
enabled: interactions.includes('press'),
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
const focus = useFocus(floating.context, {
|
|
127
|
+
enabled: interactions.includes('focus'),
|
|
128
|
+
});
|
|
129
|
+
const hover = useHover(floating.context, {
|
|
130
|
+
enabled: interactions.includes('hover'),
|
|
131
|
+
});
|
|
132
|
+
const dismiss = useDismiss(floating.context);
|
|
133
|
+
|
|
134
|
+
const { getReferenceProps, getFloatingProps } = useInteractions([
|
|
135
|
+
click,
|
|
136
|
+
focus,
|
|
137
|
+
hover,
|
|
138
|
+
dismiss,
|
|
139
|
+
]);
|
|
140
|
+
|
|
141
|
+
const arrowTransformStyle = useMemo(() => {
|
|
142
|
+
const arrowData = floating.context.middlewareData.arrow;
|
|
143
|
+
const shiftData = floating.context.middlewareData.shift;
|
|
144
|
+
|
|
145
|
+
if (!arrowData || (!arrowData.x && !arrowData.y)) {
|
|
146
|
+
return null;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
const side = floating.placement.split('-')[0] as OverlayPhysicalPlacement;
|
|
150
|
+
const isVerticalSide = side === 'top' || side === 'bottom';
|
|
151
|
+
|
|
152
|
+
const x = isVerticalSide ? (arrowData.x || 0) - (shiftData?.x || 0) : 0;
|
|
153
|
+
const y = !isVerticalSide ? (arrowData.y || 0) - (shiftData?.y || 0) : 0;
|
|
154
|
+
|
|
155
|
+
return `translate(${x < 0 ? 0 : x}px, ${y < 0 ? 0 : y}px)`;
|
|
156
|
+
}, [
|
|
157
|
+
floating.context.middlewareData.arrow,
|
|
158
|
+
floating.context.middlewareData.shift,
|
|
159
|
+
floating.placement,
|
|
160
|
+
]);
|
|
161
|
+
|
|
162
|
+
return useMemo(
|
|
163
|
+
() => ({
|
|
164
|
+
identifier,
|
|
165
|
+
visible,
|
|
166
|
+
setVisible,
|
|
167
|
+
placement: floating.placement.split('-')[0] as OverlayPhysicalPlacement,
|
|
168
|
+
trigger: {
|
|
169
|
+
ref: floating.refs.setReference,
|
|
170
|
+
getProps: transformReferenceProps(getReferenceProps),
|
|
171
|
+
},
|
|
172
|
+
content: {
|
|
173
|
+
ref: floating.refs.setFloating,
|
|
174
|
+
getProps: getFloatingProps,
|
|
175
|
+
style: floating.floatingStyles,
|
|
176
|
+
},
|
|
177
|
+
arrow: {
|
|
178
|
+
ref: arrowRef,
|
|
179
|
+
getProps: () => {},
|
|
180
|
+
style: {
|
|
181
|
+
position: 'absolute',
|
|
182
|
+
...optional(arrowTransformStyle !== null, {
|
|
183
|
+
transform: arrowTransformStyle,
|
|
184
|
+
}),
|
|
185
|
+
},
|
|
186
|
+
},
|
|
187
|
+
}),
|
|
188
|
+
[visible, floating.placement, floating.floatingStyles, arrowTransformStyle],
|
|
189
|
+
);
|
|
190
|
+
}
|
|
@@ -1,93 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Platform } from 'react-native';
|
|
1
|
+
import { useMemo, RefObject } from 'react';
|
|
3
2
|
import type { ViewRef } from '../components/View';
|
|
4
3
|
|
|
5
|
-
type ScrollbarEffectsState = {
|
|
6
|
-
counter: number;
|
|
7
|
-
elements: HTMLElement[];
|
|
8
|
-
originalWidths: string[];
|
|
9
|
-
originalBodyOverflow: string;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
const computeScrollbarWidth = () => {
|
|
13
|
-
const documentWidth = document.documentElement.clientWidth;
|
|
14
|
-
return Math.abs(window.innerWidth - documentWidth);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
4
|
export default function useScrollbarEffects(
|
|
5
|
+
// @ts-expect-error Argument elements is used on the web only.
|
|
6
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
18
7
|
elements: RefObject<ViewRef | null>[],
|
|
19
8
|
) {
|
|
20
|
-
if (Platform.OS !== 'web') {
|
|
21
|
-
return useMemo(
|
|
22
|
-
() => ({
|
|
23
|
-
hide() {},
|
|
24
|
-
show() {},
|
|
25
|
-
}),
|
|
26
|
-
[],
|
|
27
|
-
);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const state = useRef<ScrollbarEffectsState>({
|
|
31
|
-
counter: 0,
|
|
32
|
-
elements: [],
|
|
33
|
-
originalWidths: [],
|
|
34
|
-
originalBodyOverflow: '',
|
|
35
|
-
});
|
|
36
|
-
|
|
37
9
|
return useMemo(
|
|
38
10
|
() => ({
|
|
39
|
-
hide() {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (state.current.counter !== 1) {
|
|
43
|
-
return;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const rect = document.body.getBoundingClientRect();
|
|
47
|
-
const isBodyOverflowing = rect.left + rect.right < window.innerWidth;
|
|
48
|
-
|
|
49
|
-
// Set body and fixed elements padding adjustments.
|
|
50
|
-
const fixedElements = elements
|
|
51
|
-
.filter((ref) => ref.current)
|
|
52
|
-
.map((ref) => ref.current);
|
|
53
|
-
|
|
54
|
-
// @ts-expect-error fixedElements should be of type HTMLElement[]
|
|
55
|
-
state.current.elements = [document.body, ...fixedElements];
|
|
56
|
-
|
|
57
|
-
state.current.originalWidths = state.current.elements.map(
|
|
58
|
-
(el) => el.style.width || '',
|
|
59
|
-
);
|
|
60
|
-
|
|
61
|
-
state.current.originalBodyOverflow = document.body.style.overflow || '';
|
|
62
|
-
|
|
63
|
-
if (isBodyOverflowing) {
|
|
64
|
-
const scrollbarWidth = computeScrollbarWidth();
|
|
65
|
-
|
|
66
|
-
state.current.elements.forEach((el) => {
|
|
67
|
-
// eslint-disable-next-line no-param-reassign
|
|
68
|
-
el.style.width = `calc(100% - ${scrollbarWidth}px)`;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
// Add "overflow: hidden" to body element.
|
|
73
|
-
document.body.style.overflow = 'hidden';
|
|
74
|
-
},
|
|
75
|
-
show() {
|
|
76
|
-
state.current.counter -= 1;
|
|
77
|
-
|
|
78
|
-
if (state.current.counter !== 0) {
|
|
79
|
-
return;
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
// Remove "overflow: hidden" from body element.
|
|
83
|
-
document.body.style.overflow = state.current.originalBodyOverflow;
|
|
84
|
-
|
|
85
|
-
// Reset body padding adjustments.
|
|
86
|
-
state.current.elements.forEach((el, key) => {
|
|
87
|
-
// eslint-disable-next-line no-param-reassign
|
|
88
|
-
el.style.width = state.current.originalWidths[key] || '';
|
|
89
|
-
});
|
|
90
|
-
},
|
|
11
|
+
hide() {},
|
|
12
|
+
show() {},
|
|
91
13
|
}),
|
|
92
14
|
[],
|
|
93
15
|
);
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { useRef, useMemo, RefObject } from 'react';
|
|
2
|
+
import type { ViewRef } from '../components/View';
|
|
3
|
+
|
|
4
|
+
type ScrollbarEffectsState = {
|
|
5
|
+
counter: number;
|
|
6
|
+
elements: HTMLElement[];
|
|
7
|
+
originalWidths: string[];
|
|
8
|
+
originalBodyOverflow: string;
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
const computeScrollbarWidth = () => {
|
|
12
|
+
const documentWidth = document.documentElement.clientWidth;
|
|
13
|
+
return Math.abs(window.innerWidth - documentWidth);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
export default function useScrollbarEffects(
|
|
17
|
+
elements: RefObject<ViewRef | null>[],
|
|
18
|
+
) {
|
|
19
|
+
const state = useRef<ScrollbarEffectsState>({
|
|
20
|
+
counter: 0,
|
|
21
|
+
elements: [],
|
|
22
|
+
originalWidths: [],
|
|
23
|
+
originalBodyOverflow: '',
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
return useMemo(
|
|
27
|
+
() => ({
|
|
28
|
+
hide() {
|
|
29
|
+
state.current.counter += 1;
|
|
30
|
+
|
|
31
|
+
if (state.current.counter !== 1) {
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const rect = document.body.getBoundingClientRect();
|
|
36
|
+
const isBodyOverflowing = rect.left + rect.right < window.innerWidth;
|
|
37
|
+
|
|
38
|
+
// Set body and fixed elements padding adjustments.
|
|
39
|
+
const fixedElements = elements
|
|
40
|
+
.filter((ref) => ref.current)
|
|
41
|
+
.map((ref) => ref.current);
|
|
42
|
+
|
|
43
|
+
// @ts-expect-error fixedElements should be of type HTMLElement[]
|
|
44
|
+
state.current.elements = [document.body, ...fixedElements];
|
|
45
|
+
|
|
46
|
+
state.current.originalWidths = state.current.elements.map(
|
|
47
|
+
(el) => el.style.width || '',
|
|
48
|
+
);
|
|
49
|
+
|
|
50
|
+
state.current.originalBodyOverflow = document.body.style.overflow || '';
|
|
51
|
+
|
|
52
|
+
if (isBodyOverflowing) {
|
|
53
|
+
const scrollbarWidth = computeScrollbarWidth();
|
|
54
|
+
|
|
55
|
+
state.current.elements.forEach((el) => {
|
|
56
|
+
// eslint-disable-next-line no-param-reassign
|
|
57
|
+
el.style.width = `calc(100% - ${scrollbarWidth}px)`;
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Add "overflow: hidden" to body element.
|
|
62
|
+
document.body.style.overflow = 'hidden';
|
|
63
|
+
},
|
|
64
|
+
show() {
|
|
65
|
+
state.current.counter -= 1;
|
|
66
|
+
|
|
67
|
+
if (state.current.counter !== 0) {
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Remove "overflow: hidden" from body element.
|
|
72
|
+
document.body.style.overflow = state.current.originalBodyOverflow;
|
|
73
|
+
|
|
74
|
+
// Reset body padding adjustments.
|
|
75
|
+
state.current.elements.forEach((el, key) => {
|
|
76
|
+
// eslint-disable-next-line no-param-reassign
|
|
77
|
+
el.style.width = state.current.originalWidths[key] || '';
|
|
78
|
+
});
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
[],
|
|
82
|
+
);
|
|
83
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { PortalProvider } from '@react-native-aria/overlays';
|
|
2
1
|
import css from './style/css';
|
|
3
2
|
import makeUtilities from './style/makeUtilities';
|
|
4
3
|
import makeTheme from './style/makeTheme';
|
|
@@ -14,7 +13,6 @@ export {
|
|
|
14
13
|
Context,
|
|
15
14
|
makeUtilities,
|
|
16
15
|
makeTheme,
|
|
17
|
-
PortalProvider,
|
|
18
16
|
Provider,
|
|
19
17
|
StyleSheet,
|
|
20
18
|
useFixedElement,
|
|
@@ -190,6 +188,11 @@ export type { ProgressBarProps } from './components/progress/ProgressBar';
|
|
|
190
188
|
export { default as Paragraph } from './components/type/Paragraph';
|
|
191
189
|
export type { ParagraphProps } from './components/type/Paragraph';
|
|
192
190
|
|
|
191
|
+
export { default as Portal } from './components/helpers/Portal';
|
|
192
|
+
export { default as PortalHost } from './components/helpers/PortalHost';
|
|
193
|
+
export type { PortalProps } from './components/helpers/Portal';
|
|
194
|
+
export type { PortalHostProps } from './components/helpers/PortalHost';
|
|
195
|
+
|
|
193
196
|
export { default as Pressable } from './components/Pressable';
|
|
194
197
|
export type { PressableProps } from './components/Pressable';
|
|
195
198
|
|
|
@@ -210,9 +213,6 @@ export type { SwitchProps } from './components/forms/Switch';
|
|
|
210
213
|
export { default as Spinner } from './components/spinners/Spinner';
|
|
211
214
|
export type { SpinnerProps } from './components/spinners/Spinner';
|
|
212
215
|
|
|
213
|
-
export { default as SafeAreaView } from './components/SafeAreaView';
|
|
214
|
-
export type { SafeAreaViewProps } from './components/SafeAreaView';
|
|
215
|
-
|
|
216
216
|
export { default as ScrollView } from './components/ScrollView';
|
|
217
217
|
export type { ScrollViewProps } from './components/ScrollView';
|
|
218
218
|
|
package/src/style/StyleSheet.ts
CHANGED
|
@@ -63,13 +63,10 @@ const createSheet = <T extends string>(
|
|
|
63
63
|
return target.stateless[prop] || target.stateful[prop] || undefined;
|
|
64
64
|
},
|
|
65
65
|
ownKeys: (target) => target.keys,
|
|
66
|
-
getOwnPropertyDescriptor(target, name:
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
68
|
-
const proxy = this;
|
|
69
|
-
|
|
66
|
+
getOwnPropertyDescriptor(target, name: T) {
|
|
70
67
|
return {
|
|
71
68
|
get value() {
|
|
72
|
-
return
|
|
69
|
+
return target.stateless[name] || target.stateful[name] || undefined;
|
|
73
70
|
},
|
|
74
71
|
configurable: true,
|
|
75
72
|
enumerable: true,
|