bootstrap-rn 0.4.10 → 0.4.12

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 (157) hide show
  1. package/lib/module/components/close/CloseButton.js +1 -1
  2. package/lib/module/components/close/CloseButton.js.map +1 -1
  3. package/lib/module/components/collapse/Collapse.js +1 -0
  4. package/lib/module/components/collapse/Collapse.js.map +1 -1
  5. package/lib/module/components/forms/FormCheckInput.js +1 -5
  6. package/lib/module/components/forms/FormCheckInput.js.map +1 -1
  7. package/lib/module/components/forms/Picker.js +24 -35
  8. package/lib/module/components/forms/Picker.js.map +1 -1
  9. package/lib/module/components/forms/PickerItem.js +1 -9
  10. package/lib/module/components/forms/PickerItem.js.map +1 -1
  11. package/lib/module/components/forms/Radio.js +1 -0
  12. package/lib/module/components/forms/Radio.js.map +1 -1
  13. package/lib/module/components/forms/internals/{FormCheckInputNative.js → FormCheckInput.js} +4 -4
  14. package/lib/module/components/forms/internals/FormCheckInput.js.map +1 -0
  15. package/lib/module/components/forms/internals/{FormCheckInputWeb.js → FormCheckInput.web.js} +4 -4
  16. package/lib/module/components/forms/internals/FormCheckInput.web.js.map +1 -0
  17. package/lib/module/components/forms/internals/{PickerNative.js → Picker.js} +4 -4
  18. package/lib/module/components/forms/internals/Picker.js.map +1 -0
  19. package/lib/module/components/forms/internals/{PickerWeb.js → Picker.web.js} +4 -4
  20. package/lib/module/components/forms/internals/Picker.web.js.map +1 -0
  21. package/lib/module/components/forms/internals/{PickerNativeItem.js → PickerItem.js} +3 -3
  22. package/lib/module/components/forms/internals/PickerItem.js.map +1 -0
  23. package/lib/module/components/forms/internals/{PickerWebItem.js → PickerItem.web.js} +3 -3
  24. package/lib/module/components/forms/internals/PickerItem.web.js.map +1 -0
  25. package/lib/module/components/helpers/Portal.js +20 -1
  26. package/lib/module/components/helpers/Portal.js.map +1 -1
  27. package/lib/module/components/helpers/Portal.web.js +10 -2
  28. package/lib/module/components/helpers/Portal.web.js.map +1 -1
  29. package/lib/module/components/helpers/PortalHost.web.js +4 -1
  30. package/lib/module/components/helpers/PortalHost.web.js.map +1 -1
  31. package/lib/module/components/list-group/ListGroup.js +1 -0
  32. package/lib/module/components/list-group/ListGroup.js.map +1 -1
  33. package/lib/module/components/navbar/NavbarToggler.js +1 -1
  34. package/lib/module/components/navbar/NavbarToggler.js.map +1 -1
  35. package/lib/module/components/popover/Popover.js +1 -0
  36. package/lib/module/components/popover/Popover.js.map +1 -1
  37. package/lib/module/components/progress/Progress.js +1 -0
  38. package/lib/module/components/progress/Progress.js.map +1 -1
  39. package/lib/module/components/tooltip/Tooltip.js +1 -0
  40. package/lib/module/components/tooltip/Tooltip.js.map +1 -1
  41. package/lib/module/components/type/Paragraph.js +2 -2
  42. package/lib/module/components/type/Paragraph.js.map +1 -1
  43. package/lib/module/hooks/useBackground.js +167 -4
  44. package/lib/module/hooks/useBackground.js.map +1 -1
  45. package/lib/module/hooks/{useBackgroundWeb.js → useBackground.web.js} +2 -2
  46. package/lib/module/hooks/useBackground.web.js.map +1 -0
  47. package/lib/module/hooks/useOverlay.web.js +6 -1
  48. package/lib/module/hooks/useOverlay.web.js.map +1 -1
  49. package/lib/module/hooks/usePortalRegistry.js +26 -0
  50. package/lib/module/hooks/usePortalRegistry.js.map +1 -0
  51. package/lib/typescript/components/collapse/Collapse.d.ts +5 -0
  52. package/lib/typescript/components/collapse/Collapse.d.ts.map +1 -1
  53. package/lib/typescript/components/forms/FormCheckInput.d.ts +0 -1
  54. package/lib/typescript/components/forms/FormCheckInput.d.ts.map +1 -1
  55. package/lib/typescript/components/forms/Picker.d.ts +0 -1
  56. package/lib/typescript/components/forms/Picker.d.ts.map +1 -1
  57. package/lib/typescript/components/forms/PickerItem.d.ts.map +1 -1
  58. package/lib/typescript/components/forms/Radio.d.ts +5 -0
  59. package/lib/typescript/components/forms/Radio.d.ts.map +1 -1
  60. package/lib/typescript/components/forms/internals/FormCheckInput.d.ts +10 -0
  61. package/lib/typescript/components/forms/internals/FormCheckInput.d.ts.map +1 -0
  62. package/lib/typescript/components/forms/internals/FormCheckInput.web.d.ts +10 -0
  63. package/lib/typescript/components/forms/internals/FormCheckInput.web.d.ts.map +1 -0
  64. package/lib/typescript/components/forms/internals/Picker.d.ts +10 -0
  65. package/lib/typescript/components/forms/internals/Picker.d.ts.map +1 -0
  66. package/lib/typescript/components/forms/internals/Picker.web.d.ts +10 -0
  67. package/lib/typescript/components/forms/internals/Picker.web.d.ts.map +1 -0
  68. package/lib/typescript/components/forms/internals/PickerItem.d.ts +10 -0
  69. package/lib/typescript/components/forms/internals/PickerItem.d.ts.map +1 -0
  70. package/lib/typescript/components/forms/internals/PickerItem.web.d.ts +10 -0
  71. package/lib/typescript/components/forms/internals/PickerItem.web.d.ts.map +1 -0
  72. package/lib/typescript/components/helpers/Portal.d.ts +2 -1
  73. package/lib/typescript/components/helpers/Portal.d.ts.map +1 -1
  74. package/lib/typescript/components/helpers/Portal.web.d.ts +2 -1
  75. package/lib/typescript/components/helpers/Portal.web.d.ts.map +1 -1
  76. package/lib/typescript/components/list-group/ListGroup.d.ts +3 -0
  77. package/lib/typescript/components/list-group/ListGroup.d.ts.map +1 -1
  78. package/lib/typescript/components/list-group/ListGroupContext.d.ts +2 -2
  79. package/lib/typescript/components/list-group/ListGroupContext.d.ts.map +1 -1
  80. package/lib/typescript/components/popover/Popover.d.ts +4 -0
  81. package/lib/typescript/components/popover/Popover.d.ts.map +1 -1
  82. package/lib/typescript/components/progress/Progress.d.ts +4 -0
  83. package/lib/typescript/components/progress/Progress.d.ts.map +1 -1
  84. package/lib/typescript/components/tooltip/Tooltip.d.ts +4 -0
  85. package/lib/typescript/components/tooltip/Tooltip.d.ts.map +1 -1
  86. package/lib/typescript/components/type/Paragraph.d.ts +2 -2
  87. package/lib/typescript/components/type/Paragraph.d.ts.map +1 -1
  88. package/lib/typescript/hooks/useBackground.d.ts +8 -4
  89. package/lib/typescript/hooks/useBackground.d.ts.map +1 -1
  90. package/lib/typescript/hooks/useBackground.web.d.ts +6 -0
  91. package/lib/typescript/hooks/useBackground.web.d.ts.map +1 -0
  92. package/lib/typescript/hooks/useOverlay.web.d.ts +5 -2
  93. package/lib/typescript/hooks/useOverlay.web.d.ts.map +1 -1
  94. package/lib/typescript/hooks/usePortalRegistry.d.ts +2 -0
  95. package/lib/typescript/hooks/usePortalRegistry.d.ts.map +1 -0
  96. package/package.json +1 -1
  97. package/src/components/buttons/Button.tsx +380 -380
  98. package/src/components/collapse/Collapse.tsx +1 -0
  99. package/src/components/forms/FormCheckInput.tsx +1 -10
  100. package/src/components/forms/Input.tsx +219 -219
  101. package/src/components/forms/Picker.tsx +24 -40
  102. package/src/components/forms/PickerItem.tsx +1 -12
  103. package/src/components/forms/Radio.tsx +1 -0
  104. package/src/components/forms/RadioContext.ts +13 -13
  105. package/src/components/forms/internals/{FormCheckInputNative.tsx → FormCheckInput.tsx} +4 -4
  106. package/src/components/forms/internals/{FormCheckInputWeb.tsx → FormCheckInput.web.tsx} +4 -4
  107. package/src/components/forms/internals/{PickerNative.tsx → Picker.tsx} +3 -5
  108. package/src/components/forms/internals/{PickerWeb.tsx → Picker.web.tsx} +3 -3
  109. package/src/components/forms/internals/{PickerNativeItem.tsx → PickerItem.tsx} +3 -5
  110. package/src/components/forms/internals/{PickerWebItem.tsx → PickerItem.web.tsx} +3 -5
  111. package/src/components/forms/internals/PickerNativeContext.ts +14 -14
  112. package/src/components/helpers/Portal.tsx +16 -2
  113. package/src/components/helpers/Portal.web.tsx +16 -4
  114. package/src/components/helpers/PortalHost.web.tsx +1 -1
  115. package/src/components/list-group/ListGroup.tsx +1 -0
  116. package/src/components/list-group/ListGroupContext.ts +11 -11
  117. package/src/components/popover/Popover.tsx +1 -0
  118. package/src/components/popover/PopoverContext.ts +13 -13
  119. package/src/components/progress/Progress.tsx +1 -0
  120. package/src/components/tooltip/Tooltip.tsx +1 -0
  121. package/src/components/tooltip/TooltipContext.ts +13 -13
  122. package/src/components/type/Paragraph.tsx +2 -2
  123. package/src/hooks/useBackground.tsx +203 -4
  124. package/src/hooks/{useBackgroundWeb.tsx → useBackground.web.tsx} +1 -1
  125. package/src/hooks/useOverlay.web.ts +20 -3
  126. package/src/hooks/usePortalRegistry.ts +36 -0
  127. package/lib/module/components/forms/PickerContext.js +0 -7
  128. package/lib/module/components/forms/PickerContext.js.map +0 -1
  129. package/lib/module/components/forms/internals/FormCheckInputNative.js.map +0 -1
  130. package/lib/module/components/forms/internals/FormCheckInputWeb.js.map +0 -1
  131. package/lib/module/components/forms/internals/PickerNative.js.map +0 -1
  132. package/lib/module/components/forms/internals/PickerNativeItem.js.map +0 -1
  133. package/lib/module/components/forms/internals/PickerWeb.js.map +0 -1
  134. package/lib/module/components/forms/internals/PickerWebItem.js.map +0 -1
  135. package/lib/module/hooks/useBackgroundNative.js +0 -170
  136. package/lib/module/hooks/useBackgroundNative.js.map +0 -1
  137. package/lib/module/hooks/useBackgroundWeb.js.map +0 -1
  138. package/lib/typescript/components/forms/PickerContext.d.ts +0 -7
  139. package/lib/typescript/components/forms/PickerContext.d.ts.map +0 -1
  140. package/lib/typescript/components/forms/internals/FormCheckInputNative.d.ts +0 -10
  141. package/lib/typescript/components/forms/internals/FormCheckInputNative.d.ts.map +0 -1
  142. package/lib/typescript/components/forms/internals/FormCheckInputWeb.d.ts +0 -10
  143. package/lib/typescript/components/forms/internals/FormCheckInputWeb.d.ts.map +0 -1
  144. package/lib/typescript/components/forms/internals/PickerNative.d.ts +0 -10
  145. package/lib/typescript/components/forms/internals/PickerNative.d.ts.map +0 -1
  146. package/lib/typescript/components/forms/internals/PickerNativeItem.d.ts +0 -10
  147. package/lib/typescript/components/forms/internals/PickerNativeItem.d.ts.map +0 -1
  148. package/lib/typescript/components/forms/internals/PickerWeb.d.ts +0 -10
  149. package/lib/typescript/components/forms/internals/PickerWeb.d.ts.map +0 -1
  150. package/lib/typescript/components/forms/internals/PickerWebItem.d.ts +0 -10
  151. package/lib/typescript/components/forms/internals/PickerWebItem.d.ts.map +0 -1
  152. package/lib/typescript/hooks/useBackgroundNative.d.ts +0 -9
  153. package/lib/typescript/hooks/useBackgroundNative.d.ts.map +0 -1
  154. package/lib/typescript/hooks/useBackgroundWeb.d.ts +0 -6
  155. package/lib/typescript/hooks/useBackgroundWeb.d.ts.map +0 -1
  156. package/src/components/forms/PickerContext.ts +0 -11
  157. package/src/hooks/useBackgroundNative.tsx +0 -204
@@ -9,7 +9,7 @@ import useBackground from '../../../hooks/useBackground';
9
9
  import type { PressableRef } from '../../Pressable';
10
10
  import type { FormCheckInputProps } from '../FormCheckInput';
11
11
 
12
- export interface FormCheckInputWebProps extends FormCheckInputProps {
12
+ export interface BaseFormCheckInputProps extends FormCheckInputProps {
13
13
  style: ViewStyle[];
14
14
  }
15
15
 
@@ -38,8 +38,8 @@ const Input = ({
38
38
  }: InputProps & React.RefAttributes<HTMLInputElement>) =>
39
39
  createElement('input', { ...props, ref, style: [styles.reboot, style] });
40
40
 
41
- function FormCheckInputWeb(
42
- props: FormCheckInputWebProps & React.RefAttributes<PressableRef>,
41
+ function FormCheckInput(
42
+ props: BaseFormCheckInputProps & React.RefAttributes<PressableRef>,
43
43
  ) {
44
44
  const {
45
45
  ref,
@@ -76,4 +76,4 @@ function FormCheckInputWeb(
76
76
  );
77
77
  }
78
78
 
79
- export default FormCheckInputWeb;
79
+ export default FormCheckInput;
@@ -15,7 +15,7 @@ import PickerNativeContext from './PickerNativeContext';
15
15
  import type { PickerProps, MenuComponentProps } from '../Picker';
16
16
  import type { PickerItemProps } from '../PickerItem';
17
17
 
18
- export interface PickerNativeProps extends PickerProps {
18
+ export interface BasePickerProps extends PickerProps {
19
19
  style: TextStyle[];
20
20
  }
21
21
 
@@ -107,9 +107,7 @@ function DefaultMenuComponent({
107
107
  }
108
108
  /* eslint-enable */
109
109
 
110
- function PickerNative(
111
- props: PickerNativeProps & React.RefAttributes<PressableRef>,
112
- ) {
110
+ function Picker(props: BasePickerProps & React.RefAttributes<PressableRef>) {
113
111
  const {
114
112
  ref,
115
113
  children,
@@ -193,4 +191,4 @@ function PickerNative(
193
191
  );
194
192
  }
195
193
 
196
- export default PickerNative;
194
+ export default Picker;
@@ -10,7 +10,7 @@ import PickerWebContext from './PickerWebContext';
10
10
  import type { PickerProps } from '../Picker';
11
11
  import type { PressableRef } from '../../Pressable';
12
12
 
13
- interface PickerWebProps extends PickerProps {
13
+ interface BasePickerProps extends PickerProps {
14
14
  style: TextStyle[];
15
15
  }
16
16
 
@@ -33,7 +33,7 @@ const getOptionStyle = (
33
33
  return null;
34
34
  };
35
35
 
36
- function PickerWeb(props: PickerWebProps & React.RefAttributes<PressableRef>) {
36
+ function Picker(props: BasePickerProps & React.RefAttributes<PressableRef>) {
37
37
  const {
38
38
  ref,
39
39
  children,
@@ -83,4 +83,4 @@ function PickerWeb(props: PickerWebProps & React.RefAttributes<PressableRef>) {
83
83
  );
84
84
  }
85
85
 
86
- export default PickerWeb;
86
+ export default Picker;
@@ -10,7 +10,7 @@ import useForcedContext from '../../../hooks/useForcedContext';
10
10
  import PickerNativeContext from './PickerNativeContext';
11
11
  import { ViewProps, ViewRef } from '../../View';
12
12
 
13
- export interface PickerNativeItemProps extends ViewProps {
13
+ export interface PickerItemProps extends ViewProps {
14
14
  label: string;
15
15
  value: string;
16
16
  disabled?: boolean;
@@ -24,9 +24,7 @@ const styles = StyleSheet.create({
24
24
  itemDisabled: css``,
25
25
  });
26
26
 
27
- function PickerNativeItem(
28
- props: PickerNativeItemProps & React.RefAttributes<ViewRef>,
29
- ) {
27
+ function PickerItem(props: PickerItemProps & React.RefAttributes<ViewRef>) {
30
28
  const { ref, label, value, disabled = false } = props;
31
29
 
32
30
  const { selectedValue, handleValueChange } =
@@ -54,4 +52,4 @@ function PickerNativeItem(
54
52
  );
55
53
  }
56
54
 
57
- export default PickerNativeItem;
55
+ export default PickerItem;
@@ -7,15 +7,13 @@ import useForcedContext from '../../../hooks/useForcedContext';
7
7
  import PickerWebContext from './PickerWebContext';
8
8
  import type { ViewProps, ViewRef } from '../../View';
9
9
 
10
- export interface PickerWebItemProps extends ViewProps {
10
+ export interface PickerItemProps extends ViewProps {
11
11
  label: string;
12
12
  value: string;
13
13
  disabled?: boolean;
14
14
  }
15
15
 
16
- function PickerWebItem(
17
- props: PickerWebItemProps & React.RefAttributes<ViewRef>,
18
- ) {
16
+ function PickerItem(props: PickerItemProps & React.RefAttributes<ViewRef>) {
19
17
  const { ref, label, value, disabled = false } = props;
20
18
 
21
19
  const { optionColor } = useForcedContext(PickerWebContext);
@@ -31,4 +29,4 @@ function PickerWebItem(
31
29
  );
32
30
  }
33
31
 
34
- export default PickerWebItem;
32
+ export default PickerItem;
@@ -1,14 +1,14 @@
1
- import React from 'react';
2
-
3
- type PickerNativeContextType = {
4
- selectedValue?: string | null | undefined;
5
- handleValueChange: (value: string) => void;
6
- };
7
-
8
- const PickerNativeContext = React.createContext<PickerNativeContextType | null>(
9
- null,
10
- );
11
-
12
- PickerNativeContext.displayName = 'PickerNativeContext';
13
-
14
- export default PickerNativeContext;
1
+ import React from 'react';
2
+
3
+ type PickerNativeContextType = {
4
+ selectedValue?: string | null | undefined;
5
+ handleValueChange: (value: string) => void;
6
+ };
7
+
8
+ const PickerNativeContext = React.createContext<PickerNativeContextType | null>(
9
+ null,
10
+ );
11
+
12
+ PickerNativeContext.displayName = 'PickerNativeContext';
13
+
14
+ export default PickerNativeContext;
@@ -1,10 +1,24 @@
1
- import { Portal } from '@rn-primitives/portal';
1
+ import React from 'react';
2
+ import { Portal as BasePortal } from '@rn-primitives/portal';
3
+ import usePortalRegistry from '../../hooks/usePortalRegistry';
4
+ import TextStyleContext from '../../style/TextStyleContext';
2
5
 
3
6
  export interface PortalProps {
4
- // eslint-disable-next-line react/no-unused-prop-types
5
7
  name: string;
6
8
  hostName?: string;
7
9
  children: React.ReactNode;
8
10
  }
9
11
 
12
+ function Portal({ name, hostName, children }: PortalProps) {
13
+ usePortalRegistry(name, hostName);
14
+
15
+ return (
16
+ <BasePortal name={name} hostName={hostName}>
17
+ <TextStyleContext.Provider value={null}>
18
+ {children}
19
+ </TextStyleContext.Provider>
20
+ </BasePortal>
21
+ );
22
+ }
23
+
10
24
  export default Portal;
@@ -1,8 +1,9 @@
1
- import { useLayoutEffect, useState } from 'react';
1
+ import React, { useLayoutEffect, useState } from 'react';
2
2
  import { createPortal } from 'react-dom';
3
+ import usePortalRegistry from '../../hooks/usePortalRegistry';
4
+ import TextStyleContext from '../../style/TextStyleContext';
3
5
 
4
6
  export interface PortalProps {
5
- // eslint-disable-next-line react/no-unused-prop-types
6
7
  name: string;
7
8
  hostName?: string;
8
9
  children: React.ReactNode;
@@ -10,11 +11,17 @@ export interface PortalProps {
10
11
 
11
12
  const DEFAULT_PORTAL_HOST = 'INTERNAL_PRIMITIVE_DEFAULT_HOST_NAME';
12
13
 
13
- function Portal({ hostName = DEFAULT_PORTAL_HOST, children }: PortalProps) {
14
+ function Portal({
15
+ name,
16
+ hostName = DEFAULT_PORTAL_HOST,
17
+ children,
18
+ }: PortalProps) {
14
19
  const [element, setElement] = useState(() =>
15
20
  document.getElementById(hostName),
16
21
  );
17
22
 
23
+ usePortalRegistry(name, hostName);
24
+
18
25
  // Retry lookup after mount, before paint, in case the host element
19
26
  // was not yet committed to the DOM during the initial render.
20
27
  useLayoutEffect(() => {
@@ -36,7 +43,12 @@ function Portal({ hostName = DEFAULT_PORTAL_HOST, children }: PortalProps) {
36
43
  return null;
37
44
  }
38
45
 
39
- return createPortal(children, element);
46
+ return createPortal(
47
+ <TextStyleContext.Provider value={null}>
48
+ {children}
49
+ </TextStyleContext.Provider>,
50
+ element,
51
+ );
40
52
  }
41
53
 
42
54
  export default Portal;
@@ -8,7 +8,7 @@ export interface PortalHostProps {
8
8
  const DEFAULT_PORTAL_HOST = 'INTERNAL_PRIMITIVE_DEFAULT_HOST_NAME';
9
9
 
10
10
  function PortalHost({ name = DEFAULT_PORTAL_HOST }: PortalHostProps) {
11
- return <View id={name} />;
11
+ return <View id={name} style={{ position: 'absolute' }} />;
12
12
  }
13
13
 
14
14
  export default PortalHost;
@@ -70,6 +70,7 @@ function ListGroup(props: ListGroupProps & React.RefAttributes<ViewRef>) {
70
70
  }
71
71
 
72
72
  export default Object.assign(ListGroup, {
73
+ Context: ListGroupContext,
73
74
  Item: ListGroupItem,
74
75
  ItemAction: ListGroupItemAction,
75
76
  });
@@ -1,11 +1,11 @@
1
- import React from 'react';
2
-
3
- interface ListGroupContextType {
4
- flush?: boolean;
5
- }
6
-
7
- const ListGroupContext = React.createContext<ListGroupContextType | null>(null);
8
-
9
- ListGroupContext.displayName = 'ListGroupContext';
10
-
11
- export default ListGroupContext;
1
+ import React from 'react';
2
+
3
+ type ListGroupContextType = {
4
+ flush?: boolean;
5
+ };
6
+
7
+ const ListGroupContext = React.createContext<ListGroupContextType | null>(null);
8
+
9
+ ListGroupContext.displayName = 'ListGroupContext';
10
+
11
+ export default ListGroupContext;
@@ -80,6 +80,7 @@ function Popover(props: PopoverProps & React.RefAttributes<ViewRef>) {
80
80
  }
81
81
 
82
82
  export default Object.assign(Popover, {
83
+ Context: PopoverContext,
83
84
  Arrow: PopoverArrow,
84
85
  Header: PopoverHeader,
85
86
  Body: PopoverBody,
@@ -1,13 +1,13 @@
1
- import React from 'react';
2
- import type { OverlayPlacement } from '../../types';
3
-
4
- type PopoverContextType = {
5
- placement: OverlayPlacement;
6
- floating?: boolean;
7
- };
8
-
9
- const PopoverContext = React.createContext<PopoverContextType | null>(null);
10
-
11
- PopoverContext.displayName = 'PopoverContext';
12
-
13
- export default PopoverContext;
1
+ import React from 'react';
2
+ import type { OverlayPlacement } from '../../types';
3
+
4
+ type PopoverContextType = {
5
+ placement: OverlayPlacement;
6
+ floating?: boolean;
7
+ };
8
+
9
+ const PopoverContext = React.createContext<PopoverContextType | null>(null);
10
+
11
+ PopoverContext.displayName = 'PopoverContext';
12
+
13
+ export default PopoverContext;
@@ -60,5 +60,6 @@ function Progress(props: ProgressProps & React.RefAttributes<ViewRef>) {
60
60
  }
61
61
 
62
62
  export default Object.assign(Progress, {
63
+ Context: ProgressContext,
63
64
  Bar: ProgressBar,
64
65
  });
@@ -73,6 +73,7 @@ function Tooltip(props: TooltipProps & React.RefAttributes<ViewRef>) {
73
73
  }
74
74
 
75
75
  export default Object.assign(Tooltip, {
76
+ Context: TooltipContext,
76
77
  Arrow: TooltipArrow,
77
78
  Inner: TooltipInner,
78
79
  });
@@ -1,13 +1,13 @@
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
+ 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;
@@ -21,7 +21,7 @@ const styles = StyleSheet.create({
21
21
  `,
22
22
  });
23
23
 
24
- function Heading(props: ParagraphProps & React.RefAttributes<TextRef>) {
24
+ function Paragraph(props: ParagraphProps & React.RefAttributes<TextRef>) {
25
25
  const { ref, children, lead, style, ...elementProps } = props;
26
26
 
27
27
  const classes = getStyles(styles, ['paragraph', lead && '.lead']);
@@ -37,4 +37,4 @@ function Heading(props: ParagraphProps & React.RefAttributes<TextRef>) {
37
37
  );
38
38
  }
39
39
 
40
- export default Heading;
40
+ export default Paragraph;
@@ -1,5 +1,204 @@
1
- import { Platform } from 'react-native';
2
- import useBackgroundWeb from './useBackgroundWeb';
3
- import useBackgroundNative from './useBackgroundNative';
1
+ import React from 'react';
2
+ import { I18nManager, StyleSheet, View } from 'react-native';
3
+ import { SvgXml } from 'react-native-svg';
4
+ import type { BaseStyle } from '../types';
4
5
 
5
- export default Platform.OS === 'web' ? useBackgroundWeb : useBackgroundNative;
6
+ type Position = 'center' | 'left' | 'right' | 'top' | 'bottom';
7
+
8
+ type BackgroundSize = 'cover' | 'contain' | { width: number; height: number };
9
+
10
+ type BackgroundResult = {
11
+ containerStyle: BaseStyle;
12
+ objectStyle: BaseStyle;
13
+ xml: string | null;
14
+ };
15
+
16
+ const styles = StyleSheet.create({
17
+ container: { overflow: 'hidden' },
18
+ object: { aspectRatio: 1 },
19
+ });
20
+
21
+ const horizontalPositions = {
22
+ left: (offset: number = 0) => ({
23
+ alignItems: I18nManager.isRTL ? 'flex-end' : 'flex-start',
24
+ paddingLeft: offset,
25
+ }),
26
+ right: (offset: number = 0) => ({
27
+ alignItems: I18nManager.isRTL ? 'flex-start' : 'flex-end',
28
+ paddingRight: offset,
29
+ }),
30
+ center: (offset?: number) => {
31
+ if (offset !== undefined) {
32
+ return null;
33
+ }
34
+
35
+ return {
36
+ alignItems: 'center',
37
+ };
38
+ },
39
+ top: undefined,
40
+ bottom: undefined,
41
+ };
42
+
43
+ const verticalPositions = {
44
+ top: (offset: number = 0) => ({
45
+ justifyContent: 'flex-start',
46
+ paddingTop: offset,
47
+ }),
48
+ bottom: (offset: number = 0) => ({
49
+ justifyContent: 'flex-end',
50
+ paddingBottom: offset,
51
+ }),
52
+ center: (offset?: number) => {
53
+ if (offset !== undefined) {
54
+ return null;
55
+ }
56
+
57
+ return {
58
+ justifyContent: 'center',
59
+ };
60
+ },
61
+ left: undefined,
62
+ right: undefined,
63
+ };
64
+
65
+ const getXml = (value: string) => {
66
+ const match = value.match(/^url\("data:image\/svg\+xml,(.*?)"\)$/);
67
+
68
+ if (!match) {
69
+ return null;
70
+ }
71
+
72
+ return decodeURIComponent(match[1]);
73
+ };
74
+
75
+ const transforms = {
76
+ backgroundSize(value: BackgroundSize) {
77
+ if (value === 'cover') {
78
+ return {
79
+ width: '100%',
80
+ // TODO: Support cover for views with height > width.
81
+ // height: '100%',
82
+ };
83
+ }
84
+
85
+ if (value === 'contain') {
86
+ return {
87
+ width: '100%',
88
+ height: '100%',
89
+ };
90
+ }
91
+
92
+ const { width, height = width } = value;
93
+
94
+ return {
95
+ width,
96
+ height,
97
+ };
98
+ },
99
+ backgroundPosition(value: Position) {
100
+ if (value === 'center') {
101
+ return {
102
+ alignItems: 'center',
103
+ justifyContent: 'center',
104
+ };
105
+ }
106
+
107
+ const horizontalPosition = horizontalPositions[value];
108
+
109
+ if (horizontalPosition !== undefined) {
110
+ return {
111
+ ...horizontalPosition(),
112
+ justifyContent: 'center',
113
+ };
114
+ }
115
+
116
+ const verticalPosition = verticalPositions[value];
117
+
118
+ if (verticalPosition) {
119
+ return {
120
+ alignItems: 'center',
121
+ ...verticalPosition(),
122
+ };
123
+ }
124
+
125
+ return null;
126
+ },
127
+ backgroundPositionX(
128
+ value: Position | { position: Position; offset: number },
129
+ ) {
130
+ const { position = 'left', offset } =
131
+ typeof value === 'object'
132
+ ? value
133
+ : { position: value, offset: undefined };
134
+
135
+ const horizontalPosition = horizontalPositions[position];
136
+
137
+ if (!horizontalPosition) {
138
+ return null;
139
+ }
140
+
141
+ return horizontalPosition(offset);
142
+ },
143
+ backgroundPositionY(
144
+ value: Position | { position: Position; offset: number },
145
+ ) {
146
+ const { position = 'top', offset } =
147
+ typeof value === 'object'
148
+ ? value
149
+ : { position: value, offset: undefined };
150
+
151
+ const verticalPosition = verticalPositions[position];
152
+
153
+ if (!verticalPosition) {
154
+ return null;
155
+ }
156
+
157
+ return verticalPosition(offset);
158
+ },
159
+ };
160
+
161
+ export default function useBackground(style: BaseStyle[]) {
162
+ const flattenedStyle = StyleSheet.flatten(style);
163
+
164
+ const background: BackgroundResult = {
165
+ containerStyle: {},
166
+ objectStyle: {},
167
+ xml: null,
168
+ };
169
+
170
+ Object.entries(flattenedStyle).forEach(([key, value]) => {
171
+ if (!value) {
172
+ return;
173
+ }
174
+
175
+ if (key === 'backgroundImage') {
176
+ background.xml = getXml(value);
177
+ } else if (key === 'backgroundSize') {
178
+ Object.assign(background.objectStyle, transforms[key](value));
179
+ } else if (
180
+ key === 'backgroundPosition' ||
181
+ key === 'backgroundPositionX' ||
182
+ key === 'backgroundPositionY'
183
+ ) {
184
+ Object.assign(background.containerStyle, transforms[key](value));
185
+ }
186
+ });
187
+
188
+ return {
189
+ style: flattenedStyle,
190
+ element: (
191
+ <View
192
+ style={[
193
+ StyleSheet.absoluteFill,
194
+ styles.container,
195
+ background.containerStyle,
196
+ ]}
197
+ >
198
+ <View style={[styles.object, background.objectStyle]}>
199
+ {background.xml && <SvgXml xml={background.xml} />}
200
+ </View>
201
+ </View>
202
+ ),
203
+ };
204
+ }
@@ -102,7 +102,7 @@ const resolveBackgroundPosition = (style: BackgroundWebStyle) => {
102
102
  return `${valueX} ${valueY}`;
103
103
  };
104
104
 
105
- export default function useBackgroundWeb(style: BaseStyle[]) {
105
+ export default function useBackground(style: BaseStyle[]) {
106
106
  const flattenedStyle = StyleSheet.flatten(style);
107
107
 
108
108
  const backgroundStyle: BaseStyle = {
@@ -1,5 +1,5 @@
1
1
  import { type HTMLProps, useId, useMemo, useRef } from 'react';
2
- import { I18nManager } from 'react-native';
2
+ import { GestureResponderEvent, I18nManager } from 'react-native';
3
3
  import {
4
4
  useFloating,
5
5
  arrow,
@@ -61,10 +61,27 @@ const getAlignedPlacement = (
61
61
 
62
62
  const transformReferenceProps =
63
63
  (handle: UseInteractionsReturn['getReferenceProps']) =>
64
- (props: HTMLProps<Element> | undefined) => {
64
+ (
65
+ props:
66
+ | (HTMLProps<Element> & { onPress?: (event: unknown) => void })
67
+ | undefined,
68
+ ) => {
69
+ const handlePress = props?.onPress;
65
70
  const { onClick, ...referenceProps } = handle(props);
66
71
 
67
- return { ...referenceProps, onPress: onClick };
72
+ const handleClick = onClick as
73
+ | ((event: GestureResponderEvent) => void)
74
+ | undefined;
75
+
76
+ return {
77
+ ...referenceProps,
78
+ onPress: handlePress
79
+ ? (event: GestureResponderEvent) => {
80
+ handleClick?.(event);
81
+ handlePress(event);
82
+ }
83
+ : handleClick,
84
+ };
68
85
  };
69
86
 
70
87
  export default function useOverlay({
@@ -0,0 +1,36 @@
1
+ import { useLayoutEffect } from 'react';
2
+
3
+ const DEFAULT_PORTAL_HOST = 'INTERNAL_PRIMITIVE_DEFAULT_HOST_NAME';
4
+
5
+ const registry = new Map<string, Set<string>>();
6
+
7
+ export default function usePortalRegistry(
8
+ name: string,
9
+ hostName: string = DEFAULT_PORTAL_HOST,
10
+ ) {
11
+ useLayoutEffect(() => {
12
+ let names = registry.get(hostName);
13
+
14
+ if (!names) {
15
+ names = new Set();
16
+ registry.set(hostName, names);
17
+ }
18
+
19
+ if (names.has(name)) {
20
+ // eslint-disable-next-line no-console
21
+ console.warn(
22
+ `Portal: A portal with name "${name}" is already registered on host "${hostName}".`,
23
+ );
24
+ }
25
+
26
+ names.add(name);
27
+
28
+ return () => {
29
+ names.delete(name);
30
+
31
+ if (names.size === 0) {
32
+ registry.delete(hostName);
33
+ }
34
+ };
35
+ }, [name, hostName]);
36
+ }
@@ -1,7 +0,0 @@
1
- "use strict";
2
-
3
- import React from 'react';
4
- const PickerContext = /*#__PURE__*/React.createContext(null);
5
- PickerContext.displayName = 'PickerContext';
6
- export default PickerContext;
7
- //# sourceMappingURL=PickerContext.js.map
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","PickerContext","createContext","displayName"],"sourceRoot":"..\\..\\..\\..\\src","sources":["components/forms/PickerContext.ts"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAMzB,MAAMC,aAAa,gBAAGD,KAAK,CAACE,aAAa,CAA2B,IAAI,CAAC;AAEzED,aAAa,CAACE,WAAW,GAAG,eAAe;AAE3C,eAAeF,aAAa","ignoreList":[]}
@@ -1 +0,0 @@
1
- {"version":3,"names":["React","Pressable","useBackground","jsx","_jsx","FormCheckInputNative","props","ref","type","value","onValueChange","handleValueChange","onFocus","onBlur","hitSlop","disabled","style","id","inputBackground","role","onPress","children","element"],"sourceRoot":"..\\..\\..\\..\\..\\src","sources":["components/forms/internals/FormCheckInputNative.tsx"],"mappings":";;AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,OAAOC,SAAS,MAAwB,oBAAiB;AACzD,OAAOC,aAAa,MAAM,iCAA8B;AAAC,SAAAC,GAAA,IAAAC,IAAA;AAOzD,SAASC,oBAAoBA,CAC3BC,KAAoE,EACpE;EACA,MAAM;IACJC,GAAG;IACHC,IAAI;IACJC,KAAK;IACLC,aAAa,EAAEC,iBAAiB;IAChCC,OAAO,GAAGA,CAAA,KAAM,CAAC,CAAC;IAClBC,MAAM,GAAGA,CAAA,KAAM,CAAC,CAAC;IACjBC,OAAO,GAAG,CAAC;IACXC,QAAQ,GAAG,KAAK;IAChBC,KAAK;IACLC;EACF,CAAC,GAAGX,KAAK;EAET,MAAMY,eAAe,GAAGhB,aAAa,CAACc,KAAK,CAAC;EAE5C,oBACEZ,IAAA,CAACH,SAAS;IACRM,GAAG,EAAEA,GAAI;IACTY,IAAI,EAAEX,IAAK;IACX,gBAAcC,KAAM;IACpBW,OAAO,EAAEA,CAAA,KAAM;MACb,IAAIT,iBAAiB,EAAEA,iBAAiB,CAAC,CAACF,KAAK,CAAC;IAClD,CAAE;IACFG,OAAO,EAAEA,OAAQ;IACjBC,MAAM,EAAEA,MAAO;IACfC,OAAO,EAAEA,OAAQ;IACjBC,QAAQ,EAAEA,QAAS;IACnBC,KAAK,EAAEE,eAAe,CAACF,KAAM;IAC7BC,EAAE,EAAEA,EAAG;IAAAI,QAAA,EAENH,eAAe,CAACI;EAAO,CACf,CAAC;AAEhB;AAEA,eAAejB,oBAAoB","ignoreList":[]}