bootstrap-rn 0.3.4 → 0.3.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (172) hide show
  1. package/lib/commonjs/components/Image.js.map +1 -1
  2. package/lib/commonjs/components/ImageBackground.js.map +1 -1
  3. package/lib/commonjs/components/Text.js.map +1 -1
  4. package/lib/commonjs/components/dropdown/DropdownMenu.js.map +1 -1
  5. package/lib/commonjs/components/forms/RadioGroup.js.map +1 -1
  6. package/lib/commonjs/components/forms/internals/PickerNative.js.map +1 -1
  7. package/lib/commonjs/components/modal/Modal.js +1 -1
  8. package/lib/commonjs/components/modal/Modal.js.map +1 -1
  9. package/lib/commonjs/components/modal/ModalBody.js +1 -1
  10. package/lib/commonjs/components/modal/ModalBody.js.map +1 -1
  11. package/lib/commonjs/components/modal/ModalContext.js.map +1 -1
  12. package/lib/commonjs/components/nav/Nav.js.map +1 -1
  13. package/lib/commonjs/components/nav/NavContext.js.map +1 -1
  14. package/lib/commonjs/components/nav/TabContext.js.map +1 -1
  15. package/lib/commonjs/components/navbar/NavbarContext.js.map +1 -1
  16. package/lib/commonjs/components/offcanvas/OffcanvasBody.js.map +1 -1
  17. package/lib/commonjs/components/offcanvas/OffcanvasContext.js.map +1 -1
  18. package/lib/commonjs/components/popover/injectPopover.js.map +1 -1
  19. package/lib/commonjs/components/toasts/ToastContainer.js +3 -1
  20. package/lib/commonjs/components/toasts/ToastContainer.js.map +1 -1
  21. package/lib/commonjs/components/tooltip/injectTooltip.js +0 -3
  22. package/lib/commonjs/components/tooltip/injectTooltip.js.map +1 -1
  23. package/lib/commonjs/index.d.ts +47 -8
  24. package/lib/commonjs/index.js +0 -56
  25. package/lib/commonjs/index.js.map +1 -1
  26. package/lib/commonjs/style/StyleSheet.js +4 -2
  27. package/lib/commonjs/style/StyleSheet.js.map +1 -1
  28. package/lib/commonjs/style/makeUtilities.js.map +1 -1
  29. package/lib/commonjs/types.d.ts +6 -3
  30. package/lib/module/components/Image.js.map +1 -1
  31. package/lib/module/components/ImageBackground.js.map +1 -1
  32. package/lib/module/components/Text.js.map +1 -1
  33. package/lib/module/components/dropdown/DropdownMenu.js.map +1 -1
  34. package/lib/module/components/forms/RadioGroup.js.map +1 -1
  35. package/lib/module/components/forms/internals/PickerNative.js.map +1 -1
  36. package/lib/module/components/modal/Modal.js +1 -1
  37. package/lib/module/components/modal/Modal.js.map +1 -1
  38. package/lib/module/components/modal/ModalBody.js +1 -1
  39. package/lib/module/components/modal/ModalBody.js.map +1 -1
  40. package/lib/module/components/modal/ModalContext.js.map +1 -1
  41. package/lib/module/components/nav/Nav.js.map +1 -1
  42. package/lib/module/components/nav/NavContext.js.map +1 -1
  43. package/lib/module/components/nav/TabContext.js.map +1 -1
  44. package/lib/module/components/navbar/NavbarContext.js.map +1 -1
  45. package/lib/module/components/offcanvas/OffcanvasBody.js.map +1 -1
  46. package/lib/module/components/offcanvas/OffcanvasContext.js.map +1 -1
  47. package/lib/module/components/popover/injectPopover.js.map +1 -1
  48. package/lib/module/components/toasts/ToastContainer.js +3 -1
  49. package/lib/module/components/toasts/ToastContainer.js.map +1 -1
  50. package/lib/module/components/tooltip/injectTooltip.js +0 -3
  51. package/lib/module/components/tooltip/injectTooltip.js.map +1 -1
  52. package/lib/module/index.d.ts +47 -8
  53. package/lib/module/index.js +0 -7
  54. package/lib/module/index.js.map +1 -1
  55. package/lib/module/style/StyleSheet.js +4 -2
  56. package/lib/module/style/StyleSheet.js.map +1 -1
  57. package/lib/module/style/makeUtilities.js.map +1 -1
  58. package/lib/module/types.d.ts +6 -3
  59. package/lib/types/components/Image.d.ts.map +1 -1
  60. package/lib/types/components/ImageBackground.d.ts.map +1 -1
  61. package/lib/types/components/Text.d.ts +1 -1
  62. package/lib/types/components/Text.d.ts.map +1 -1
  63. package/lib/types/components/dropdown/Dropdown.d.ts +2 -11
  64. package/lib/types/components/dropdown/Dropdown.d.ts.map +1 -1
  65. package/lib/types/components/dropdown/DropdownContext.d.ts +2 -2
  66. package/lib/types/components/dropdown/DropdownContext.d.ts.map +1 -1
  67. package/lib/types/components/dropdown/DropdownMenu.d.ts +2 -2
  68. package/lib/types/components/dropdown/DropdownMenu.d.ts.map +1 -1
  69. package/lib/types/components/dropdown/DropdownToggle.d.ts +2 -2
  70. package/lib/types/components/dropdown/DropdownToggle.d.ts.map +1 -1
  71. package/lib/types/components/forms/Picker.d.ts +4 -4
  72. package/lib/types/components/forms/Picker.d.ts.map +1 -1
  73. package/lib/types/components/forms/PickerItem.d.ts +1 -1
  74. package/lib/types/components/forms/PickerItem.d.ts.map +1 -1
  75. package/lib/types/components/forms/Radio.d.ts +1 -1
  76. package/lib/types/components/forms/Radio.d.ts.map +1 -1
  77. package/lib/types/components/forms/RadioContext.d.ts +2 -2
  78. package/lib/types/components/forms/RadioContext.d.ts.map +1 -1
  79. package/lib/types/components/forms/RadioGroup.d.ts +2 -2
  80. package/lib/types/components/forms/RadioGroup.d.ts.map +1 -1
  81. package/lib/types/components/forms/internals/PickerNative.d.ts.map +1 -1
  82. package/lib/types/components/forms/internals/PickerNativeContext.d.ts +2 -2
  83. package/lib/types/components/forms/internals/PickerNativeContext.d.ts.map +1 -1
  84. package/lib/types/components/forms/internals/PickerNativeItem.d.ts +1 -1
  85. package/lib/types/components/forms/internals/PickerNativeItem.d.ts.map +1 -1
  86. package/lib/types/components/forms/internals/PickerWebItem.d.ts +1 -1
  87. package/lib/types/components/forms/internals/PickerWebItem.d.ts.map +1 -1
  88. package/lib/types/components/list-group/ListGroup.d.ts +1 -1
  89. package/lib/types/components/list-group/ListGroupItem.d.ts +13 -1
  90. package/lib/types/components/list-group/ListGroupItem.d.ts.map +1 -1
  91. package/lib/types/components/list-group/ListGroupItemAction.d.ts +2 -2
  92. package/lib/types/components/list-group/ListGroupItemAction.d.ts.map +1 -1
  93. package/lib/types/components/modal/Modal.d.ts +4 -7
  94. package/lib/types/components/modal/Modal.d.ts.map +1 -1
  95. package/lib/types/components/modal/ModalBody.d.ts +3 -6
  96. package/lib/types/components/modal/ModalBody.d.ts.map +1 -1
  97. package/lib/types/components/modal/ModalContext.d.ts +3 -3
  98. package/lib/types/components/modal/ModalContext.d.ts.map +1 -1
  99. package/lib/types/components/nav/Nav.d.ts +1 -3
  100. package/lib/types/components/nav/Nav.d.ts.map +1 -1
  101. package/lib/types/components/nav/NavContext.d.ts +3 -3
  102. package/lib/types/components/nav/NavContext.d.ts.map +1 -1
  103. package/lib/types/components/nav/Tab.d.ts +1 -1
  104. package/lib/types/components/nav/TabContext.d.ts +3 -3
  105. package/lib/types/components/nav/TabContext.d.ts.map +1 -1
  106. package/lib/types/components/navbar/Navbar.d.ts +1 -1
  107. package/lib/types/components/navbar/NavbarBrand.d.ts +2 -2
  108. package/lib/types/components/navbar/NavbarBrand.d.ts.map +1 -1
  109. package/lib/types/components/navbar/NavbarContext.d.ts +2 -2
  110. package/lib/types/components/navbar/NavbarContext.d.ts.map +1 -1
  111. package/lib/types/components/offcanvas/Offcanvas.d.ts +1 -3
  112. package/lib/types/components/offcanvas/Offcanvas.d.ts.map +1 -1
  113. package/lib/types/components/offcanvas/OffcanvasBody.d.ts +3 -4
  114. package/lib/types/components/offcanvas/OffcanvasBody.d.ts.map +1 -1
  115. package/lib/types/components/offcanvas/OffcanvasContext.d.ts +2 -2
  116. package/lib/types/components/offcanvas/OffcanvasContext.d.ts.map +1 -1
  117. package/lib/types/components/popover/injectPopover.d.ts +9 -12
  118. package/lib/types/components/popover/injectPopover.d.ts.map +1 -1
  119. package/lib/types/components/toasts/ToastContainer.d.ts +4 -2
  120. package/lib/types/components/toasts/ToastContainer.d.ts.map +1 -1
  121. package/lib/types/components/tooltip/injectTooltip.d.ts +8 -11
  122. package/lib/types/components/tooltip/injectTooltip.d.ts.map +1 -1
  123. package/lib/types/hooks/useBackground.native.d.ts +3 -1
  124. package/lib/types/hooks/useBackground.native.d.ts.map +1 -1
  125. package/lib/types/index.d.ts +47 -8
  126. package/lib/types/index.d.ts.map +1 -1
  127. package/lib/types/style/StyleSheet.d.ts +2 -3
  128. package/lib/types/style/StyleSheet.d.ts.map +1 -1
  129. package/lib/types/style/createStyle.d.ts +3 -1
  130. package/lib/types/style/createStyle.d.ts.map +1 -1
  131. package/lib/types/style/css.d.ts +3 -1
  132. package/lib/types/style/css.d.ts.map +1 -1
  133. package/lib/types/style/makeUtilities.d.ts +6 -2
  134. package/lib/types/style/makeUtilities.d.ts.map +1 -1
  135. package/lib/types/theme/variables.d.ts +3 -1
  136. package/lib/types/theme/variables.d.ts.map +1 -1
  137. package/lib/types/types.d.ts +6 -3
  138. package/lib/types/types.d.ts.map +1 -1
  139. package/package.json +80 -80
  140. package/src/components/Image.tsx +31 -27
  141. package/src/components/ImageBackground.tsx +48 -46
  142. package/src/components/Text.tsx +119 -117
  143. package/src/components/dropdown/DropdownContext.ts +2 -2
  144. package/src/components/dropdown/DropdownMenu.tsx +127 -125
  145. package/src/components/dropdown/DropdownToggle.ts +2 -2
  146. package/src/components/forms/Picker.tsx +191 -191
  147. package/src/components/forms/PickerItem.tsx +32 -32
  148. package/src/components/forms/Radio.tsx +37 -37
  149. package/src/components/forms/RadioContext.ts +13 -13
  150. package/src/components/forms/RadioGroup.tsx +42 -40
  151. package/src/components/forms/internals/PickerNative.tsx +193 -195
  152. package/src/components/forms/internals/PickerNativeContext.ts +14 -14
  153. package/src/components/forms/internals/PickerNativeItem.tsx +59 -59
  154. package/src/components/forms/internals/PickerWebItem.tsx +36 -36
  155. package/src/components/list-group/ListGroupItemAction.tsx +2 -2
  156. package/src/components/modal/Modal.tsx +234 -233
  157. package/src/components/modal/ModalBody.tsx +52 -56
  158. package/src/components/modal/ModalContext.ts +3 -3
  159. package/src/components/nav/Nav.tsx +4 -4
  160. package/src/components/nav/NavContext.ts +3 -3
  161. package/src/components/nav/TabContext.ts +3 -3
  162. package/src/components/navbar/NavbarBrand.tsx +2 -2
  163. package/src/components/navbar/NavbarContext.ts +2 -2
  164. package/src/components/offcanvas/OffcanvasBody.tsx +64 -66
  165. package/src/components/offcanvas/OffcanvasContext.ts +4 -2
  166. package/src/components/popover/injectPopover.tsx +97 -98
  167. package/src/components/toasts/ToastContainer.tsx +41 -39
  168. package/src/components/tooltip/injectTooltip.tsx +93 -96
  169. package/src/index.ts +242 -211
  170. package/src/style/StyleSheet.ts +149 -138
  171. package/src/style/makeUtilities.ts +79 -76
  172. package/src/types.ts +168 -162
@@ -6,7 +6,7 @@ import useForcedContext from '../../hooks/useForcedContext';
6
6
  import { getStyles } from '../../utils';
7
7
  import NavbarContext from './NavbarContext';
8
8
 
9
- export interface NavbarBrand extends PressableProps {}
9
+ export interface NavbarBrandProps extends PressableProps {}
10
10
 
11
11
  const styles = StyleSheet.create({
12
12
  '.navbar-brand': css`
@@ -49,7 +49,7 @@ const styles = StyleSheet.create({
49
49
  `,
50
50
  });
51
51
 
52
- const NavbarBrand = React.forwardRef<PressableRef, NavbarBrand>(
52
+ const NavbarBrand = React.forwardRef<PressableRef, NavbarBrandProps>(
53
53
  (props, ref) => {
54
54
  const { children, style, textStyle, ...elementProps } = props;
55
55
 
@@ -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 NavbarContextType = {
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<NavbarContextType | null>(null);
17
+ const NavbarContext = createContext<NavbarContextProps | null>(null);
18
18
 
19
19
  NavbarContext.displayName = 'NavbarContext';
20
20
 
@@ -1,66 +1,64 @@
1
- import React, { useContext } from 'react';
2
- import { ScrollView as BaseScrollView } from 'react-native';
3
- import css from '../../style/css';
4
- import StyleSheet from '../../style/StyleSheet';
5
- import ScrollView from '../ScrollView';
6
- import { GRID_BREAKPOINTS } from '../../theme/proxies';
7
- import { infix, next } from '../../theme/breakpoints';
8
- import { getStyles, each } from '../../utils';
9
- import NavbarContext from '../navbar/NavbarContext';
10
- import type { ExtendedViewStyle, StyleProp } from '../../types';
11
- import { ViewProps } from '../View';
12
-
13
- export interface OffcanvasBodyProps extends ViewProps {
14
- contentContainerStyle?: StyleProp<ExtendedViewStyle>;
15
- }
16
-
17
- const styles = StyleSheet.create({
18
- '.offcanvas-body': css`
19
- // flex-grow: 1;
20
- padding: $offcanvas-padding-y $offcanvas-padding-x;
21
- // overflow-y: auto;
22
- `,
23
- // Navbar styles
24
- ...each(GRID_BREAKPOINTS, (breakpoint) => ({
25
- [`.navbar-expand${infix(next(breakpoint))} .offcanvas-body`]: css`
26
- @include media-breakpoint-up(${next(breakpoint)}) {
27
- display: flex;
28
- flex-grow: 0;
29
- padding: 0;
30
- // overflow-y: visible;
31
- }
32
- `,
33
- })),
34
- });
35
-
36
- const OffcanvasBody = React.forwardRef<BaseScrollView, OffcanvasBodyProps>(
37
- (props, ref) => {
38
- const { children, style, contentContainerStyle, ...elementProps } = props;
39
-
40
- const navbar = useContext(NavbarContext);
41
-
42
- const contentContainerClasses = getStyles(styles, [
43
- '.offcanvas-body',
44
- navbar &&
45
- navbar.expand &&
46
- `.navbar-expand${
47
- navbar.expand === true ? '' : `-${navbar.expand}`
48
- } .offcanvas-body`,
49
- ]);
50
-
51
- return (
52
- <ScrollView
53
- {...elementProps}
54
- ref={ref}
55
- style={style}
56
- contentContainerStyle={[contentContainerClasses, contentContainerStyle]}
57
- >
58
- {children}
59
- </ScrollView>
60
- );
61
- },
62
- );
63
-
64
- OffcanvasBody.displayName = 'OffcanvasBody';
65
-
66
- export default OffcanvasBody;
1
+ import React, { useContext } from 'react';
2
+ import css from '../../style/css';
3
+ import StyleSheet from '../../style/StyleSheet';
4
+ import ScrollView, { ScrollViewProps, ScrollViewRef } from '../ScrollView';
5
+ import { GRID_BREAKPOINTS } from '../../theme/proxies';
6
+ import { infix, next } from '../../theme/breakpoints';
7
+ import { getStyles, each } from '../../utils';
8
+ import NavbarContext from '../navbar/NavbarContext';
9
+ import type { ExtendedViewStyle, StyleProp } from '../../types';
10
+
11
+ export interface OffcanvasBodyProps extends ScrollViewProps {
12
+ contentContainerStyle?: StyleProp<ExtendedViewStyle>;
13
+ }
14
+
15
+ const styles = StyleSheet.create({
16
+ '.offcanvas-body': css`
17
+ // flex-grow: 1;
18
+ padding: $offcanvas-padding-y $offcanvas-padding-x;
19
+ // overflow-y: auto;
20
+ `,
21
+ // Navbar styles
22
+ ...each(GRID_BREAKPOINTS, (breakpoint) => ({
23
+ [`.navbar-expand${infix(next(breakpoint))} .offcanvas-body`]: css`
24
+ @include media-breakpoint-up(${next(breakpoint)}) {
25
+ display: flex;
26
+ flex-grow: 0;
27
+ padding: 0;
28
+ // overflow-y: visible;
29
+ }
30
+ `,
31
+ })),
32
+ });
33
+
34
+ const OffcanvasBody = React.forwardRef<ScrollViewRef, OffcanvasBodyProps>(
35
+ (props, ref) => {
36
+ const { children, style, contentContainerStyle, ...elementProps } = props;
37
+
38
+ const navbar = useContext(NavbarContext);
39
+
40
+ const contentContainerClasses = getStyles(styles, [
41
+ '.offcanvas-body',
42
+ navbar &&
43
+ navbar.expand &&
44
+ `.navbar-expand${
45
+ navbar.expand === true ? '' : `-${navbar.expand}`
46
+ } .offcanvas-body`,
47
+ ]);
48
+
49
+ return (
50
+ <ScrollView
51
+ {...elementProps}
52
+ ref={ref}
53
+ style={style}
54
+ contentContainerStyle={[contentContainerClasses, contentContainerStyle]}
55
+ >
56
+ {children}
57
+ </ScrollView>
58
+ );
59
+ },
60
+ );
61
+
62
+ OffcanvasBody.displayName = 'OffcanvasBody';
63
+
64
+ export default OffcanvasBody;
@@ -1,8 +1,10 @@
1
1
  import React from 'react';
2
2
 
3
- type OffcanvasContextType = Record<string, never>;
3
+ export type OffcanvasContextProps = Record<string, never>;
4
4
 
5
- const OffcanvasContext = React.createContext<OffcanvasContextType | null>(null);
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 Pressable, { PressableProps } from '../Pressable';
10
- import type { ViewRef } from '../View';
11
- import type { Trigger, Axis } from '../../types';
12
-
13
- type PopoverProps = {
14
- title?: React.ReactNode;
15
- content: React.ReactNode;
16
- autoClose?: boolean | 'inside' | 'outside';
17
- trigger?: Trigger;
18
- placement?: Axis;
19
- } & TriggerProps;
20
-
21
- export interface InjectPopoverProps extends PressableProps {
22
- popover: PopoverProps;
23
- }
24
-
25
- export default function injectPopover(Target: typeof Pressable) {
26
- const OverlayPopover = React.forwardRef<ViewRef, InjectPopoverProps>(
27
- (props, ref) => {
28
- const {
29
- popover: {
30
- title,
31
- content,
32
- autoClose = 'outside',
33
- trigger = 'press',
34
- placement = 'right',
35
- ...popoverProps
36
- },
37
- ...elementProps
38
- } = props;
39
-
40
- const { visible, setVisible, targetProps, targetRef, templateProps } =
41
- useTrigger(trigger, popoverProps, elementProps, ref);
42
-
43
- const offset = normalizeNumber(StyleSheet.value('popover-arrow-height'));
44
-
45
- return (
46
- <>
47
- <Target {...elementProps} {...targetProps} />
48
- {visible && (
49
- <OverlayContainer>
50
- <Overlay
51
- placement={placement}
52
- offset={offset}
53
- arrowOffset={offset}
54
- targetRef={targetRef}
55
- visible={visible}
56
- >
57
- {(overlay, overlayRef) => (
58
- <>
59
- <BackdropHandler
60
- toggleRef={targetRef}
61
- dialogRef={overlayRef}
62
- onClose={() => {
63
- setVisible(false);
64
- }}
65
- autoClose={autoClose}
66
- />
67
- <Popover
68
- {...templateProps}
69
- ref={overlayRef}
70
- placement={overlay.placement}
71
- popper={overlay.rendered}
72
- style={[
73
- overlay.overlayProps.style,
74
- {
75
- maxHeight: 'auto',
76
- opacity: overlay.rendered ? 1 : 0,
77
- },
78
- ]}
79
- arrowStyle={overlay.arrowProps.style}
80
- >
81
- <Popover.Arrow />
82
- {title && <Popover.Header>{title}</Popover.Header>}
83
- <Popover.Body>{content}</Popover.Body>
84
- </Popover>
85
- </>
86
- )}
87
- </Overlay>
88
- </OverlayContainer>
89
- )}
90
- </>
91
- );
92
- },
93
- );
94
-
95
- OverlayPopover.displayName = 'Overlay(Popover)';
96
-
97
- return OverlayPopover;
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 Pressable, { PressableProps } from '../Pressable';
10
- import type { ViewRef } from '../View';
11
- import type { Trigger, Axis } from '../../types';
12
-
13
- type TooltipProps = {
14
- title: React.ReactNode;
15
- autoClose?: boolean | 'inside' | 'outside';
16
- trigger?: Trigger;
17
- placement?: Axis;
18
- } & TriggerProps;
19
-
20
- export interface InjectTooltipProps extends PressableProps {
21
- tooltip: TooltipProps;
22
- }
23
-
24
- export default function injectTooltip(Target: typeof Pressable) {
25
- const OverlayTooltip = React.forwardRef<ViewRef, InjectTooltipProps>(
26
- (props, ref) => {
27
- /* eslint-disable react/prop-types */
28
- const {
29
- tooltip: {
30
- title,
31
- autoClose = 'outside',
32
- trigger = 'hover focus',
33
- placement = 'top',
34
- ...tooltipProps
35
- },
36
- ...elementProps
37
- } = props;
38
- /* eslint-enable */
39
-
40
- const { visible, setVisible, targetProps, targetRef, templateProps } =
41
- useTrigger(trigger, tooltipProps, elementProps, ref);
42
-
43
- const offset = normalizeNumber(StyleSheet.value('tooltip-arrow-height'));
44
-
45
- return (
46
- <>
47
- <Target {...elementProps} {...targetProps} />
48
- {visible && (
49
- <OverlayContainer>
50
- <Overlay
51
- placement={placement}
52
- targetRef={targetRef}
53
- arrowOffset={offset}
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
- <Tooltip
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
- <Tooltip.Arrow />
81
- <Tooltip.Inner>{title}</Tooltip.Inner>
82
- </Tooltip>
83
- </>
84
- )}
85
- </Overlay>
86
- </OverlayContainer>
87
- )}
88
- </>
89
- );
90
- },
91
- );
92
-
93
- OverlayTooltip.displayName = 'Overlay(Tooltip)';
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
+ }