bootstrap-rn 0.3.4 → 0.3.5
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/commonjs/components/Image.js.map +1 -1
- package/lib/commonjs/components/ImageBackground.js.map +1 -1
- package/lib/commonjs/components/Text.js.map +1 -1
- package/lib/commonjs/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/commonjs/components/modal/ModalContext.js.map +1 -1
- package/lib/commonjs/components/nav/Nav.js.map +1 -1
- package/lib/commonjs/components/nav/NavContext.js.map +1 -1
- package/lib/commonjs/components/nav/TabContext.js.map +1 -1
- package/lib/commonjs/components/navbar/NavbarContext.js.map +1 -1
- package/lib/commonjs/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/commonjs/components/popover/injectPopover.js.map +1 -1
- package/lib/commonjs/components/toasts/ToastContainer.js +3 -1
- package/lib/commonjs/components/toasts/ToastContainer.js.map +1 -1
- package/lib/commonjs/components/tooltip/injectTooltip.js +0 -3
- package/lib/commonjs/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/commonjs/index.d.ts +47 -8
- package/lib/commonjs/index.js +0 -56
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/style/StyleSheet.js +4 -2
- package/lib/commonjs/style/StyleSheet.js.map +1 -1
- package/lib/commonjs/types.d.ts +6 -3
- package/lib/module/components/Image.js.map +1 -1
- package/lib/module/components/ImageBackground.js.map +1 -1
- package/lib/module/components/Text.js.map +1 -1
- package/lib/module/components/dropdown/DropdownMenu.js.map +1 -1
- package/lib/module/components/modal/ModalContext.js.map +1 -1
- package/lib/module/components/nav/Nav.js.map +1 -1
- package/lib/module/components/nav/NavContext.js.map +1 -1
- package/lib/module/components/nav/TabContext.js.map +1 -1
- package/lib/module/components/navbar/NavbarContext.js.map +1 -1
- package/lib/module/components/offcanvas/OffcanvasContext.js.map +1 -1
- package/lib/module/components/popover/injectPopover.js.map +1 -1
- package/lib/module/components/toasts/ToastContainer.js +3 -1
- package/lib/module/components/toasts/ToastContainer.js.map +1 -1
- package/lib/module/components/tooltip/injectTooltip.js +0 -3
- package/lib/module/components/tooltip/injectTooltip.js.map +1 -1
- package/lib/module/index.d.ts +47 -8
- package/lib/module/index.js +0 -7
- package/lib/module/index.js.map +1 -1
- package/lib/module/style/StyleSheet.js +4 -2
- package/lib/module/style/StyleSheet.js.map +1 -1
- package/lib/module/types.d.ts +6 -3
- package/lib/types/components/Image.d.ts.map +1 -1
- package/lib/types/components/ImageBackground.d.ts.map +1 -1
- package/lib/types/components/Text.d.ts +1 -1
- package/lib/types/components/Text.d.ts.map +1 -1
- package/lib/types/components/dropdown/Dropdown.d.ts +2 -11
- package/lib/types/components/dropdown/Dropdown.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownContext.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownContext.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownMenu.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownMenu.d.ts.map +1 -1
- package/lib/types/components/dropdown/DropdownToggle.d.ts +2 -2
- package/lib/types/components/dropdown/DropdownToggle.d.ts.map +1 -1
- package/lib/types/components/list-group/ListGroup.d.ts +1 -1
- package/lib/types/components/list-group/ListGroupItem.d.ts +13 -1
- package/lib/types/components/list-group/ListGroupItem.d.ts.map +1 -1
- package/lib/types/components/list-group/ListGroupItemAction.d.ts +2 -2
- package/lib/types/components/list-group/ListGroupItemAction.d.ts.map +1 -1
- package/lib/types/components/modal/Modal.d.ts +1 -3
- package/lib/types/components/modal/Modal.d.ts.map +1 -1
- package/lib/types/components/modal/ModalContext.d.ts +3 -3
- package/lib/types/components/modal/ModalContext.d.ts.map +1 -1
- package/lib/types/components/nav/Nav.d.ts +1 -3
- package/lib/types/components/nav/Nav.d.ts.map +1 -1
- package/lib/types/components/nav/NavContext.d.ts +3 -3
- package/lib/types/components/nav/NavContext.d.ts.map +1 -1
- package/lib/types/components/nav/Tab.d.ts +1 -1
- package/lib/types/components/nav/TabContext.d.ts +3 -3
- package/lib/types/components/nav/TabContext.d.ts.map +1 -1
- package/lib/types/components/navbar/Navbar.d.ts +1 -1
- package/lib/types/components/navbar/NavbarBrand.d.ts +2 -2
- package/lib/types/components/navbar/NavbarBrand.d.ts.map +1 -1
- package/lib/types/components/navbar/NavbarContext.d.ts +2 -2
- package/lib/types/components/navbar/NavbarContext.d.ts.map +1 -1
- package/lib/types/components/offcanvas/Offcanvas.d.ts +1 -3
- package/lib/types/components/offcanvas/Offcanvas.d.ts.map +1 -1
- package/lib/types/components/offcanvas/OffcanvasContext.d.ts +2 -2
- package/lib/types/components/offcanvas/OffcanvasContext.d.ts.map +1 -1
- package/lib/types/components/popover/injectPopover.d.ts +9 -12
- package/lib/types/components/popover/injectPopover.d.ts.map +1 -1
- package/lib/types/components/toasts/ToastContainer.d.ts +4 -2
- package/lib/types/components/toasts/ToastContainer.d.ts.map +1 -1
- package/lib/types/components/tooltip/injectTooltip.d.ts +8 -11
- package/lib/types/components/tooltip/injectTooltip.d.ts.map +1 -1
- package/lib/types/hooks/useBackground.native.d.ts +3 -1
- package/lib/types/hooks/useBackground.native.d.ts.map +1 -1
- package/lib/types/index.d.ts +47 -8
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/style/StyleSheet.d.ts +2 -3
- package/lib/types/style/StyleSheet.d.ts.map +1 -1
- package/lib/types/style/createStyle.d.ts +3 -1
- package/lib/types/style/createStyle.d.ts.map +1 -1
- package/lib/types/style/css.d.ts +3 -1
- package/lib/types/style/css.d.ts.map +1 -1
- package/lib/types/theme/variables.d.ts +3 -1
- package/lib/types/theme/variables.d.ts.map +1 -1
- package/lib/types/types.d.ts +6 -3
- package/lib/types/types.d.ts.map +1 -1
- package/package.json +80 -80
- package/src/components/Image.tsx +31 -27
- package/src/components/ImageBackground.tsx +48 -46
- package/src/components/Text.tsx +119 -117
- package/src/components/dropdown/DropdownContext.ts +2 -2
- package/src/components/dropdown/DropdownMenu.tsx +127 -125
- package/src/components/dropdown/DropdownToggle.ts +2 -2
- package/src/components/list-group/ListGroupItemAction.tsx +2 -2
- package/src/components/modal/ModalContext.ts +3 -3
- package/src/components/nav/Nav.tsx +4 -4
- package/src/components/nav/NavContext.ts +3 -3
- package/src/components/nav/TabContext.ts +3 -3
- package/src/components/navbar/NavbarBrand.tsx +2 -2
- package/src/components/navbar/NavbarContext.ts +2 -2
- package/src/components/offcanvas/OffcanvasContext.ts +4 -2
- package/src/components/popover/injectPopover.tsx +97 -98
- package/src/components/toasts/ToastContainer.tsx +41 -39
- package/src/components/tooltip/injectTooltip.tsx +93 -96
- package/src/index.ts +242 -211
- package/src/style/StyleSheet.ts +149 -138
- package/src/types.ts +168 -162
|
@@ -4,7 +4,7 @@ export type NavbarExpand = true | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
|
|
|
4
4
|
|
|
5
5
|
export type NavbarVariant = 'light' | 'dark';
|
|
6
6
|
|
|
7
|
-
export type
|
|
7
|
+
export type NavbarContextProps = {
|
|
8
8
|
identifier: string;
|
|
9
9
|
variant?: NavbarVariant;
|
|
10
10
|
expanded?: boolean;
|
|
@@ -14,7 +14,7 @@ export type NavbarContextType = {
|
|
|
14
14
|
expand?: NavbarExpand;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
const NavbarContext = createContext<
|
|
17
|
+
const NavbarContext = createContext<NavbarContextProps | null>(null);
|
|
18
18
|
|
|
19
19
|
NavbarContext.displayName = 'NavbarContext';
|
|
20
20
|
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
|
|
3
|
-
type
|
|
3
|
+
export type OffcanvasContextProps = Record<string, never>;
|
|
4
4
|
|
|
5
|
-
const OffcanvasContext = React.createContext<
|
|
5
|
+
const OffcanvasContext = React.createContext<OffcanvasContextProps | null>(
|
|
6
|
+
null,
|
|
7
|
+
);
|
|
6
8
|
|
|
7
9
|
OffcanvasContext.displayName = 'OffcanvasContext';
|
|
8
10
|
|
|
@@ -1,98 +1,97 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { OverlayContainer } from '@react-native-aria/overlays';
|
|
3
|
-
import Overlay from '../helpers/Overlay';
|
|
4
|
-
import BackdropHandler from '../helpers/BackdropHandler';
|
|
5
|
-
import useTrigger, { TriggerProps } from '../../hooks/useTrigger';
|
|
6
|
-
import { normalizeNumber } from '../../style/math';
|
|
7
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
8
|
-
import Popover from './Popover';
|
|
9
|
-
import
|
|
10
|
-
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
} & TriggerProps;
|
|
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
|
-
|
|
81
|
-
<Popover.
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OverlayContainer } from '@react-native-aria/overlays';
|
|
3
|
+
import Overlay from '../helpers/Overlay';
|
|
4
|
+
import BackdropHandler from '../helpers/BackdropHandler';
|
|
5
|
+
import useTrigger, { TriggerProps } from '../../hooks/useTrigger';
|
|
6
|
+
import { normalizeNumber } from '../../style/math';
|
|
7
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
8
|
+
import Popover from './Popover';
|
|
9
|
+
import type { ViewRef } from '../View';
|
|
10
|
+
import type { Trigger, Axis } from '../../types';
|
|
11
|
+
|
|
12
|
+
export interface InjectPopoverProps {
|
|
13
|
+
popover: {
|
|
14
|
+
title?: React.ReactNode;
|
|
15
|
+
content: React.ReactNode;
|
|
16
|
+
autoClose?: boolean | 'inside' | 'outside';
|
|
17
|
+
trigger?: Trigger;
|
|
18
|
+
placement?: Axis;
|
|
19
|
+
} & TriggerProps;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default function injectPopover<Props>(
|
|
23
|
+
Target: React.ComponentType<Props>,
|
|
24
|
+
) {
|
|
25
|
+
const OverlayPopover = React.forwardRef<ViewRef, Props & InjectPopoverProps>(
|
|
26
|
+
(props, ref) => {
|
|
27
|
+
const {
|
|
28
|
+
popover: {
|
|
29
|
+
title,
|
|
30
|
+
content,
|
|
31
|
+
autoClose = 'outside',
|
|
32
|
+
trigger = 'press',
|
|
33
|
+
placement = 'right',
|
|
34
|
+
...popoverProps
|
|
35
|
+
},
|
|
36
|
+
...elementProps
|
|
37
|
+
} = props;
|
|
38
|
+
|
|
39
|
+
const { visible, setVisible, targetProps, targetRef, templateProps } =
|
|
40
|
+
useTrigger(trigger, popoverProps, elementProps, ref);
|
|
41
|
+
|
|
42
|
+
const offset = normalizeNumber(StyleSheet.value('popover-arrow-height'));
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<Target {...(elementProps as Props)} {...targetProps} />
|
|
47
|
+
{visible && (
|
|
48
|
+
<OverlayContainer>
|
|
49
|
+
<Overlay
|
|
50
|
+
placement={placement}
|
|
51
|
+
offset={offset}
|
|
52
|
+
arrowOffset={offset}
|
|
53
|
+
targetRef={targetRef}
|
|
54
|
+
visible={visible}
|
|
55
|
+
>
|
|
56
|
+
{(overlay, overlayRef) => (
|
|
57
|
+
<>
|
|
58
|
+
<BackdropHandler
|
|
59
|
+
toggleRef={targetRef}
|
|
60
|
+
dialogRef={overlayRef}
|
|
61
|
+
onClose={() => {
|
|
62
|
+
setVisible(false);
|
|
63
|
+
}}
|
|
64
|
+
autoClose={autoClose}
|
|
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>
|
|
88
|
+
)}
|
|
89
|
+
</>
|
|
90
|
+
);
|
|
91
|
+
},
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
OverlayPopover.displayName = 'Overlay(Popover)';
|
|
95
|
+
|
|
96
|
+
return OverlayPopover;
|
|
97
|
+
}
|
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
3
|
-
import css from '../../style/css';
|
|
4
|
-
import View, { ViewProps, ViewRef } from '../View';
|
|
5
|
-
import { getStyles } from '../../utils';
|
|
6
|
-
import ToastContainerContext from './ToastContainerContext';
|
|
7
|
-
import useList from '../../hooks/useList';
|
|
8
|
-
|
|
9
|
-
export interface ToastContainerProps extends ViewProps {}
|
|
10
|
-
|
|
11
|
-
const styles = StyleSheet.create({
|
|
12
|
-
'.toast-container': css`
|
|
13
|
-
width: 100%; // max-content;
|
|
14
|
-
max-width: 100%;
|
|
15
|
-
pointer-events: none;
|
|
16
|
-
`,
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
const ToastContainer = React.forwardRef<ViewRef, ToastContainerProps>(
|
|
20
|
-
(props, ref) => {
|
|
21
|
-
const { children, style, ...elementProps } = props;
|
|
22
|
-
|
|
23
|
-
const list = useList(children);
|
|
24
|
-
|
|
25
|
-
const classes = getStyles(styles, ['.toast-container']);
|
|
26
|
-
|
|
27
|
-
return (
|
|
28
|
-
<View {...elementProps} ref={ref} style={[classes, style]}>
|
|
29
|
-
<ToastContainerContext.Provider value>
|
|
30
|
-
{list}
|
|
31
|
-
</ToastContainerContext.Provider>
|
|
32
|
-
</View>
|
|
33
|
-
);
|
|
34
|
-
},
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
ToastContainer.displayName = 'ToastContainer';
|
|
38
|
-
|
|
39
|
-
export default ToastContainer
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
3
|
+
import css from '../../style/css';
|
|
4
|
+
import View, { ViewProps, ViewRef } from '../View';
|
|
5
|
+
import { getStyles } from '../../utils';
|
|
6
|
+
import ToastContainerContext from './ToastContainerContext';
|
|
7
|
+
import useList from '../../hooks/useList';
|
|
8
|
+
|
|
9
|
+
export interface ToastContainerProps extends ViewProps {}
|
|
10
|
+
|
|
11
|
+
const styles = StyleSheet.create({
|
|
12
|
+
'.toast-container': css`
|
|
13
|
+
width: 100%; // max-content;
|
|
14
|
+
max-width: 100%;
|
|
15
|
+
pointer-events: none;
|
|
16
|
+
`,
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const ToastContainer = React.forwardRef<ViewRef, ToastContainerProps>(
|
|
20
|
+
(props, ref) => {
|
|
21
|
+
const { children, style, ...elementProps } = props;
|
|
22
|
+
|
|
23
|
+
const list = useList(children);
|
|
24
|
+
|
|
25
|
+
const classes = getStyles(styles, ['.toast-container']);
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<View {...elementProps} ref={ref} style={[classes, style]}>
|
|
29
|
+
<ToastContainerContext.Provider value>
|
|
30
|
+
{list}
|
|
31
|
+
</ToastContainerContext.Provider>
|
|
32
|
+
</View>
|
|
33
|
+
);
|
|
34
|
+
},
|
|
35
|
+
);
|
|
36
|
+
|
|
37
|
+
ToastContainer.displayName = 'ToastContainer';
|
|
38
|
+
|
|
39
|
+
export default Object.assign(ToastContainer, {
|
|
40
|
+
Context: ToastContainerContext,
|
|
41
|
+
});
|
|
@@ -1,96 +1,93 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { OverlayContainer } from '@react-native-aria/overlays';
|
|
3
|
-
import Overlay from '../helpers/Overlay';
|
|
4
|
-
import BackdropHandler from '../helpers/BackdropHandler';
|
|
5
|
-
import useTrigger, { TriggerProps } from '../../hooks/useTrigger';
|
|
6
|
-
import { normalizeNumber } from '../../style/math';
|
|
7
|
-
import StyleSheet from '../../style/StyleSheet';
|
|
8
|
-
import Tooltip from './Tooltip';
|
|
9
|
-
import
|
|
10
|
-
import type {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
} & TriggerProps;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
} =
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
const
|
|
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
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
return OverlayTooltip;
|
|
96
|
-
}
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { OverlayContainer } from '@react-native-aria/overlays';
|
|
3
|
+
import Overlay from '../helpers/Overlay';
|
|
4
|
+
import BackdropHandler from '../helpers/BackdropHandler';
|
|
5
|
+
import useTrigger, { TriggerProps } from '../../hooks/useTrigger';
|
|
6
|
+
import { normalizeNumber } from '../../style/math';
|
|
7
|
+
import StyleSheet from '../../style/StyleSheet';
|
|
8
|
+
import Tooltip from './Tooltip';
|
|
9
|
+
import type { ViewRef } from '../View';
|
|
10
|
+
import type { Trigger, Axis } from '../../types';
|
|
11
|
+
|
|
12
|
+
export interface InjectTooltipProps {
|
|
13
|
+
tooltip: {
|
|
14
|
+
title: React.ReactNode;
|
|
15
|
+
autoClose?: boolean | 'inside' | 'outside';
|
|
16
|
+
trigger?: Trigger;
|
|
17
|
+
placement?: Axis;
|
|
18
|
+
} & TriggerProps;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default function injectTooltip<Props>(
|
|
22
|
+
Target: React.ComponentType<Props>,
|
|
23
|
+
) {
|
|
24
|
+
const OverlayTooltip = React.forwardRef<ViewRef, Props & InjectTooltipProps>(
|
|
25
|
+
(props, ref) => {
|
|
26
|
+
const {
|
|
27
|
+
tooltip: {
|
|
28
|
+
title,
|
|
29
|
+
autoClose = 'outside',
|
|
30
|
+
trigger = 'hover focus',
|
|
31
|
+
placement = 'top',
|
|
32
|
+
...tooltipProps
|
|
33
|
+
},
|
|
34
|
+
...elementProps
|
|
35
|
+
} = props;
|
|
36
|
+
|
|
37
|
+
const { visible, setVisible, targetProps, targetRef, templateProps } =
|
|
38
|
+
useTrigger(trigger, tooltipProps, elementProps, ref);
|
|
39
|
+
|
|
40
|
+
const offset = normalizeNumber(StyleSheet.value('tooltip-arrow-height'));
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<>
|
|
44
|
+
<Target {...(elementProps as Props)} {...targetProps} />
|
|
45
|
+
{visible && (
|
|
46
|
+
<OverlayContainer>
|
|
47
|
+
<Overlay
|
|
48
|
+
placement={placement}
|
|
49
|
+
targetRef={targetRef}
|
|
50
|
+
arrowOffset={offset}
|
|
51
|
+
visible={visible}
|
|
52
|
+
>
|
|
53
|
+
{(overlay, overlayRef) => (
|
|
54
|
+
<>
|
|
55
|
+
<BackdropHandler
|
|
56
|
+
toggleRef={targetRef}
|
|
57
|
+
dialogRef={overlayRef}
|
|
58
|
+
onClose={() => {
|
|
59
|
+
setVisible(false);
|
|
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>
|
|
84
|
+
)}
|
|
85
|
+
</>
|
|
86
|
+
);
|
|
87
|
+
},
|
|
88
|
+
);
|
|
89
|
+
|
|
90
|
+
OverlayTooltip.displayName = 'Overlay(Tooltip)';
|
|
91
|
+
|
|
92
|
+
return OverlayTooltip;
|
|
93
|
+
}
|