@jobber/components-native 0.89.5-JOB-140604-2d32fc8.44 → 0.89.5-JOB-140604-8777ec5.52

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 (229) hide show
  1. package/dist/package.json +7 -7
  2. package/dist/src/ActionItem/ActionItemGroup.js +1 -1
  3. package/dist/src/AutoLink/components/Link/Link.js +1 -1
  4. package/dist/src/BottomSheet/BottomSheet.js +4 -2
  5. package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +26 -0
  6. package/dist/src/Chip/Chip.js +12 -1
  7. package/dist/src/Chip/Chip.style.js +1 -1
  8. package/dist/src/ContentOverlay/ContentOverlay.js +3 -5
  9. package/dist/src/ErrorMessageWrapper/context/ErrorMessageProvider.js +1 -1
  10. package/dist/src/Form/Form.js +2 -1
  11. package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +1 -1
  12. package/dist/src/Form/hooks/useInternalForm.js +6 -3
  13. package/dist/src/FormatFile/components/MediaView/MediaView.js +22 -5
  14. package/dist/src/InputDate/InputDate.js +2 -2
  15. package/dist/src/InputFieldWrapper/InputFieldWrapper.js +14 -12
  16. package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +5 -2
  17. package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +5 -2
  18. package/dist/src/InputPressable/InputPressable.js +20 -8
  19. package/dist/src/InputPressable/InputPressable.style.js +3 -0
  20. package/dist/src/InputText/InputText.js +22 -11
  21. package/dist/src/InputText/InputText.style.js +4 -0
  22. package/dist/src/InputTime/InputTime.js +2 -2
  23. package/dist/src/Menu/Menu.js +2 -2
  24. package/dist/src/Select/components/SelectPressable/SelectPressable.js +1 -1
  25. package/dist/src/utils/meta/meta.json +0 -1
  26. package/dist/tsconfig.build.tsbuildinfo +1 -1
  27. package/dist/types/src/ActionItem/ActionItem.d.ts +2 -1
  28. package/dist/types/src/ActionItem/ActionItemGroup.d.ts +2 -1
  29. package/dist/types/src/ActionItem/components/ActionItemContainer.d.ts +2 -1
  30. package/dist/types/src/ActionLabel/ActionLabel.d.ts +1 -1
  31. package/dist/types/src/ActivityIndicator/ActivityIndicator.d.ts +2 -1
  32. package/dist/types/src/AutoLink/AutoLink.d.ts +2 -1
  33. package/dist/types/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.d.ts +2 -1
  34. package/dist/types/src/AutoLink/components/Link/Link.d.ts +2 -1
  35. package/dist/types/src/Banner/Banner.d.ts +2 -1
  36. package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +2 -1
  37. package/dist/types/src/BottomSheet/BottomSheet.d.ts +4 -9
  38. package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +2 -1
  39. package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +8 -0
  40. package/dist/types/src/Button/Button.d.ts +2 -1
  41. package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.d.ts +1 -1
  42. package/dist/types/src/ButtonGroup/ButtonGroup.d.ts +2 -1
  43. package/dist/types/src/ButtonGroup/ButtonGroupAction.d.ts +4 -3
  44. package/dist/types/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts +3 -2
  45. package/dist/types/src/Card/Card.d.ts +2 -1
  46. package/dist/types/src/Card/components/InternalCardHeader.d.ts +2 -1
  47. package/dist/types/src/Checkbox/Checkbox.d.ts +2 -1
  48. package/dist/types/src/Checkbox/CheckboxGroup.d.ts +2 -1
  49. package/dist/types/src/Chip/Chip.d.ts +2 -1
  50. package/dist/types/src/Content/Content.d.ts +2 -1
  51. package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +1 -1
  52. package/dist/types/src/Disclosure/Disclosure.d.ts +1 -1
  53. package/dist/types/src/Divider/Divider.d.ts +2 -1
  54. package/dist/types/src/EmptyState/EmptyState.d.ts +2 -1
  55. package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.d.ts +2 -1
  56. package/dist/types/src/ErrorMessageWrapper/context/ErrorMessageProvider.d.ts +2 -1
  57. package/dist/types/src/ErrorMessageWrapper/context/types.d.ts +1 -1
  58. package/dist/types/src/Flex/Flex.d.ts +2 -1
  59. package/dist/types/src/Form/Form.d.ts +2 -1
  60. package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +3 -2
  61. package/dist/types/src/Form/components/FormBody/FormBody.d.ts +3 -2
  62. package/dist/types/src/Form/components/FormCache/FormCache.d.ts +2 -1
  63. package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +2 -1
  64. package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -1
  65. package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +2 -1
  66. package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +2 -1
  67. package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +2 -1
  68. package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +2 -1
  69. package/dist/types/src/Form/context/AtlantisFormContext.d.ts +1 -1
  70. package/dist/types/src/Form/context/types.d.ts +2 -2
  71. package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +2 -2
  72. package/dist/types/src/Form/hooks/useInternalForm.d.ts +5 -5
  73. package/dist/types/src/Form/types.d.ts +10 -4
  74. package/dist/types/src/FormField/FormField.d.ts +1 -1
  75. package/dist/types/src/FormatFile/FormatFile.d.ts +2 -1
  76. package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -1
  77. package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +2 -1
  78. package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +3 -2
  79. package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +2 -1
  80. package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +2 -1
  81. package/dist/types/src/Heading/Heading.d.ts +1 -1
  82. package/dist/types/src/Icon/Icon.d.ts +2 -1
  83. package/dist/types/src/IconButton/IconButton.d.ts +1 -1
  84. package/dist/types/src/InputCurrency/InputCurrency.d.ts +2 -1
  85. package/dist/types/src/InputDate/InputDate.d.ts +4 -2
  86. package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +9 -2
  87. package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +2 -1
  88. package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +4 -4
  89. package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +4 -4
  90. package/dist/types/src/InputPressable/InputPressable.d.ts +9 -1
  91. package/dist/types/src/InputPressable/InputPressable.style.d.ts +3 -0
  92. package/dist/types/src/InputSearch/InputSearch.d.ts +1 -1
  93. package/dist/types/src/InputSearch/components/FilterButton.d.ts +2 -1
  94. package/dist/types/src/InputText/InputText.d.ts +8 -0
  95. package/dist/types/src/InputText/InputText.style.d.ts +4 -0
  96. package/dist/types/src/InputText/context/InputAccessoriesProvider.d.ts +2 -1
  97. package/dist/types/src/InputTime/InputTime.d.ts +4 -2
  98. package/dist/types/src/Menu/Menu.d.ts +2 -1
  99. package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +2 -1
  100. package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +2 -1
  101. package/dist/types/src/Menu/types.d.ts +6 -1
  102. package/dist/types/src/ProgressBar/ProgressBar.d.ts +2 -1
  103. package/dist/types/src/ProgressBar/ProgressBarInner.d.ts +2 -1
  104. package/dist/types/src/Select/Select.d.ts +3 -2
  105. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.d.ts +2 -1
  106. package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.d.ts +2 -1
  107. package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.d.ts +2 -1
  108. package/dist/types/src/Select/components/SelectPressable/SelectPressable.d.ts +2 -1
  109. package/dist/types/src/StatusLabel/StatusLabel.d.ts +2 -1
  110. package/dist/types/src/Switch/Switch.d.ts +2 -1
  111. package/dist/types/src/Switch/components/BaseSwitch/BaseSwitch.d.ts +2 -1
  112. package/dist/types/src/Text/Text.d.ts +1 -1
  113. package/dist/types/src/TextList/TextList.d.ts +2 -1
  114. package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +2 -1
  115. package/dist/types/src/Toast/Toast.d.ts +2 -1
  116. package/dist/types/src/Typography/Typography.d.ts +1 -1
  117. package/dist/types/src/Typography/TypographyGestureDetector.d.ts +2 -1
  118. package/dist/types/src/utils/test/MockSafeAreaProvider.d.ts +1 -1
  119. package/package.json +7 -7
  120. package/src/ActionItem/ActionItem.tsx +1 -1
  121. package/src/ActionItem/ActionItemGroup.tsx +1 -3
  122. package/src/ActionItem/components/ActionItemContainer.tsx +1 -1
  123. package/src/ActionLabel/ActionLabel.tsx +1 -1
  124. package/src/ActivityIndicator/ActivityIndicator.tsx +1 -3
  125. package/src/AutoLink/AutoLink.tsx +1 -1
  126. package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +1 -1
  127. package/src/AutoLink/components/Link/Link.tsx +1 -5
  128. package/src/Banner/Banner.tsx +2 -2
  129. package/src/Banner/components/BannerIcon/BannerIcon.tsx +1 -1
  130. package/src/BottomSheet/BottomSheet.stories.tsx +0 -1
  131. package/src/BottomSheet/BottomSheet.tsx +9 -10
  132. package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +1 -1
  133. package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +90 -0
  134. package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +41 -0
  135. package/src/Button/Button.tsx +1 -1
  136. package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +1 -1
  137. package/src/ButtonGroup/ButtonGroup.tsx +1 -1
  138. package/src/ButtonGroup/ButtonGroupAction.tsx +4 -4
  139. package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +2 -2
  140. package/src/Card/Card.tsx +1 -1
  141. package/src/Card/components/InternalCardHeader.tsx +1 -1
  142. package/src/Checkbox/Checkbox.tsx +2 -2
  143. package/src/Checkbox/CheckboxGroup.test.tsx +1 -1
  144. package/src/Checkbox/CheckboxGroup.tsx +2 -2
  145. package/src/Chip/Chip.style.ts +1 -1
  146. package/src/Chip/Chip.tsx +20 -2
  147. package/src/Content/Content.tsx +1 -1
  148. package/src/ContentOverlay/ContentOverlay.tsx +3 -4
  149. package/src/Disclosure/Disclosure.tsx +1 -1
  150. package/src/Divider/Divider.tsx +1 -1
  151. package/src/EmptyState/EmptyState.tsx +1 -1
  152. package/src/ErrorMessageWrapper/ErrorMessageWrapper.tsx +1 -1
  153. package/src/ErrorMessageWrapper/context/ErrorMessageProvider.tsx +3 -5
  154. package/src/ErrorMessageWrapper/context/types.ts +1 -1
  155. package/src/Flex/Flex.tsx +2 -2
  156. package/src/Form/Form.test.tsx +145 -2
  157. package/src/Form/Form.tsx +3 -1
  158. package/src/Form/components/FormActionBar/FormActionBar.tsx +3 -3
  159. package/src/Form/components/FormBody/FormBody.tsx +3 -3
  160. package/src/Form/components/FormCache/FormCache.tsx +1 -1
  161. package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +1 -1
  162. package/src/Form/components/FormMask/FormMask.tsx +1 -1
  163. package/src/Form/components/FormMessage/FormMessage.tsx +1 -1
  164. package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +1 -1
  165. package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +1 -3
  166. package/src/Form/components/FormSaveButton/FormSaveButton.tsx +1 -1
  167. package/src/Form/context/types.ts +2 -2
  168. package/src/Form/hooks/useFormViewRefs.ts +4 -5
  169. package/src/Form/hooks/useInternalForm.ts +12 -5
  170. package/src/Form/types.ts +11 -4
  171. package/src/FormField/FormField.tsx +1 -1
  172. package/src/FormatFile/FormatFile.tsx +3 -3
  173. package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +1 -1
  174. package/src/FormatFile/components/FileView/FileView.tsx +1 -1
  175. package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +2 -2
  176. package/src/FormatFile/components/MediaView/MediaView.test.tsx +283 -0
  177. package/src/FormatFile/components/MediaView/MediaView.tsx +28 -7
  178. package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +1 -1
  179. package/src/Heading/Heading.tsx +1 -1
  180. package/src/Icon/Icon.tsx +1 -1
  181. package/src/IconButton/IconButton.tsx +1 -1
  182. package/src/InputCurrency/InputCurrency.tsx +1 -1
  183. package/src/InputDate/InputDate.tsx +7 -3
  184. package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +48 -1
  185. package/src/InputFieldWrapper/InputFieldWrapper.tsx +39 -29
  186. package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +1 -1
  187. package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +3 -5
  188. package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +8 -6
  189. package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +2 -4
  190. package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +8 -6
  191. package/src/InputPassword/InputPassword.tsx +1 -1
  192. package/src/InputPressable/InputPressable.style.ts +4 -0
  193. package/src/InputPressable/InputPressable.test.tsx +75 -1
  194. package/src/InputPressable/InputPressable.tsx +34 -8
  195. package/src/InputSearch/InputSearch.tsx +1 -0
  196. package/src/InputSearch/components/FilterButton.tsx +1 -1
  197. package/src/InputText/InputText.style.ts +5 -0
  198. package/src/InputText/InputText.test.tsx +75 -0
  199. package/src/InputText/InputText.tsx +32 -12
  200. package/src/InputText/context/InputAccessoriesProvider.tsx +1 -1
  201. package/src/InputTime/InputTime.tsx +7 -3
  202. package/src/Menu/Menu.tsx +3 -3
  203. package/src/Menu/components/MenuOption/MenuOption.tsx +1 -1
  204. package/src/Menu/components/Overlay/Overlay.tsx +1 -1
  205. package/src/Menu/types.ts +7 -1
  206. package/src/ProgressBar/ProgressBar.tsx +1 -1
  207. package/src/ProgressBar/ProgressBarInner.tsx +1 -1
  208. package/src/Select/Select.tsx +2 -2
  209. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +1 -1
  210. package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.tsx +1 -1
  211. package/src/Select/components/SelectInternalPicker/SelectInternalPicker.tsx +1 -1
  212. package/src/Select/components/SelectPressable/SelectPressable.tsx +1 -4
  213. package/src/StatusLabel/StatusLabel.tsx +1 -1
  214. package/src/Switch/Switch.tsx +1 -1
  215. package/src/Switch/components/BaseSwitch/BaseSwitch.tsx +1 -1
  216. package/src/Text/Text.tsx +1 -1
  217. package/src/TextList/TextList.tsx +1 -1
  218. package/src/ThumbnailList/ThumbnailList.tsx +1 -1
  219. package/src/Toast/Toast.tsx +2 -2
  220. package/src/Typography/Typography.tsx +1 -1
  221. package/src/Typography/TypographyGestureDetector.tsx +1 -3
  222. package/src/utils/meta/meta.json +0 -1
  223. package/src/utils/test/MockSafeAreaProvider.tsx +1 -1
  224. package/dist/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.js +0 -45
  225. package/dist/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.js +0 -8
  226. package/dist/types/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.d.ts +0 -9
  227. package/dist/types/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.d.ts +0 -5
  228. package/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.ts +0 -9
  229. package/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.tsx +0 -89
@@ -43,7 +43,7 @@ export function ActionLabel({
43
43
  type = "default",
44
44
  disabled = false,
45
45
  align = "center",
46
- }: ActionLabelProps): JSX.Element {
46
+ }: ActionLabelProps) {
47
47
  return (
48
48
  <Typography
49
49
  color={getColor(variation, disabled)}
@@ -3,9 +3,7 @@ import type { ActivityIndicatorProps } from "react-native";
3
3
  import { ActivityIndicator } from "react-native";
4
4
  import { useAtlantisTheme } from "../AtlantisThemeContext";
5
5
 
6
- export function JobberActivityIndicator(
7
- props: ActivityIndicatorProps,
8
- ): JSX.Element {
6
+ export function JobberActivityIndicator(props: ActivityIndicatorProps) {
9
7
  const { tokens } = useAtlantisTheme();
10
8
 
11
9
  return (
@@ -11,7 +11,7 @@ export function AutoLink({
11
11
  bottomTabsVisible = true,
12
12
  selectable = true,
13
13
  ...rest
14
- }: AutoLinkProps): JSX.Element {
14
+ }: AutoLinkProps) {
15
15
  const { splitText, matches } = useCreateLinkedText({ text, ...rest });
16
16
  const { tokens } = useAtlantisTheme();
17
17
 
@@ -12,7 +12,7 @@ export function ComposeTextWithLinks({
12
12
  match,
13
13
  bottomTabsVisible,
14
14
  selectable = true,
15
- }: ComposeTextWithLinksProps): JSX.Element {
15
+ }: ComposeTextWithLinksProps) {
16
16
  const { t } = useAtlantisI18n();
17
17
 
18
18
  const isLink = match?.getType();
@@ -8,11 +8,7 @@ interface LinkProps {
8
8
  readonly onLongPress?: () => void;
9
9
  }
10
10
 
11
- export function Link({
12
- children,
13
- onPress,
14
- onLongPress,
15
- }: LinkProps): JSX.Element {
11
+ export function Link({ children, onPress, onLongPress }: LinkProps) {
16
12
  return (
17
13
  <RNText onPress={onPress} onLongPress={onLongPress}>
18
14
  <Text variation="interactive">{children}</Text>
@@ -18,7 +18,7 @@ export function Banner({
18
18
  type,
19
19
  children,
20
20
  icon,
21
- }: BannerProps): JSX.Element {
21
+ }: BannerProps) {
22
22
  const bannerIcon = icon || getBannerIcon(type);
23
23
 
24
24
  const shouldFlow =
@@ -60,7 +60,7 @@ export function Banner({
60
60
  );
61
61
  }
62
62
 
63
- function BannerChildren({ children }: PropsWithChildren): JSX.Element {
63
+ function BannerChildren({ children }: PropsWithChildren) {
64
64
  if (!children) return <></>;
65
65
 
66
66
  if (children && typeof children === "string") {
@@ -10,7 +10,7 @@ export interface BannerIconProps {
10
10
  readonly type: BannerTypes;
11
11
  }
12
12
 
13
- export function BannerIcon({ icon, type }: BannerIconProps): JSX.Element {
13
+ export function BannerIcon({ icon, type }: BannerIconProps) {
14
14
  const styles = useStyles();
15
15
 
16
16
  return (
@@ -100,7 +100,6 @@ const HeaderFooterInputTextTemplate = () => {
100
100
  text="Send message"
101
101
  onPress={() => alert("send message")}
102
102
  />
103
- <BottomSheet.InputText placeholder="Enter your name" />
104
103
  <BottomSheetOption
105
104
  icon="phone"
106
105
  iconColor="greyBlue"
@@ -1,4 +1,4 @@
1
- import type { ReactNode, Ref } from "react";
1
+ import type { ReactNode } from "react";
2
2
  import React, { useCallback, useImperativeHandle, useRef } from "react";
3
3
  import { Keyboard, View } from "react-native";
4
4
  import { useSafeAreaInsets } from "react-native-safe-area-context";
@@ -13,7 +13,7 @@ import type {
13
13
  } from "@gorhom/bottom-sheet";
14
14
  import { useStyles } from "./BottomSheet.style";
15
15
  import { BottomSheetOption } from "./components/BottomSheetOption";
16
- import { BottomSheetInputText } from "./components/BottomSheetInputText/BottomSheetInputText";
16
+ import { useBottomSheetBackHandler } from "./hooks/useBottomSheetBackHandler";
17
17
  import { Divider } from "../Divider";
18
18
  import { Heading } from "../Heading";
19
19
  import { useIsScreenReaderEnabled } from "../hooks";
@@ -46,11 +46,6 @@ export interface BottomSheetProps {
46
46
  * Callback that is called when the overlay is closed.
47
47
  */
48
48
  readonly onClose?: () => void;
49
-
50
- /**
51
- * Ref to the bottom sheet component.
52
- */
53
- readonly ref?: Ref<BottomSheetRef>;
54
49
  }
55
50
 
56
51
  export interface BottomSheetRef {
@@ -66,15 +61,18 @@ export function BottomSheet({
66
61
  onOpen,
67
62
  onClose,
68
63
  ref,
69
- }: BottomSheetProps) {
64
+ }: BottomSheetProps & { readonly ref?: React.Ref<BottomSheetRef> }) {
70
65
  const styles = useStyles();
71
66
  const isScreenReaderEnabled = useIsScreenReaderEnabled();
67
+
72
68
  const cancellable = (showCancel && !loading) || isScreenReaderEnabled;
73
69
 
74
70
  const { t } = useAtlantisI18n();
75
71
  const insets = useSafeAreaInsets();
76
72
  const previousIndexRef = useRef(-1);
77
73
  const bottomSheetRef = useRef<RNBottomSheet>(null);
74
+ const { handleSheetPositionChange } =
75
+ useBottomSheetBackHandler(bottomSheetRef);
78
76
 
79
77
  useImperativeHandle(ref, () => ({
80
78
  open: () => {
@@ -86,6 +84,9 @@ export function BottomSheet({
86
84
  }));
87
85
 
88
86
  const handleChange = (index: number) => {
87
+ // Handle Android back button
88
+ handleSheetPositionChange(index);
89
+
89
90
  const previousIndex = previousIndexRef.current;
90
91
 
91
92
  if (previousIndex === -1 && index >= 0) {
@@ -185,5 +186,3 @@ function Backdrop(bottomSheetBackdropProps: BottomSheetBackdropProps) {
185
186
  />
186
187
  );
187
188
  }
188
-
189
- BottomSheet.InputText = BottomSheetInputText;
@@ -25,7 +25,7 @@ export function BottomSheetOption({
25
25
  destructive,
26
26
  textTransform = "capitalize",
27
27
  onPress,
28
- }: BottomSheetOptionProps): JSX.Element {
28
+ }: BottomSheetOptionProps) {
29
29
  const destructiveColor = "destructive";
30
30
  const textVariation = destructive ? destructiveColor : "subdued";
31
31
  const styles = useStyles();
@@ -0,0 +1,90 @@
1
+ import { createRef } from "react";
2
+ import type { RefObject } from "react";
3
+ import { act, renderHook } from "@testing-library/react-native";
4
+ import { BackHandler } from "react-native";
5
+ import type BottomSheet from "@gorhom/bottom-sheet";
6
+ import { useBottomSheetBackHandler } from "./useBottomSheetBackHandler";
7
+
8
+ describe("useBottomSheetBackHandler", () => {
9
+ let mockRemove: jest.Mock;
10
+ let mockAddEventListener: jest.SpyInstance;
11
+
12
+ beforeEach(() => {
13
+ mockRemove = jest.fn();
14
+ mockAddEventListener = jest.spyOn(BackHandler, "addEventListener");
15
+ mockAddEventListener.mockReturnValue({ remove: mockRemove });
16
+ });
17
+
18
+ afterEach(() => {
19
+ mockAddEventListener.mockRestore();
20
+ });
21
+
22
+ it("should register BackHandler listener when sheet becomes visible", async () => {
23
+ const bottomSheetRef = createRef<BottomSheet | null>();
24
+ const { result } = renderHook(() =>
25
+ useBottomSheetBackHandler(bottomSheetRef),
26
+ );
27
+
28
+ await act(async () => {
29
+ result.current.handleSheetPositionChange(0);
30
+ });
31
+
32
+ expect(mockAddEventListener).toHaveBeenCalledWith(
33
+ "hardwareBackPress",
34
+ expect.any(Function),
35
+ );
36
+ });
37
+
38
+ it("should call close() when back button is pressed", async () => {
39
+ const mockClose = jest.fn();
40
+ const bottomSheetRef = {
41
+ current: {
42
+ close: mockClose,
43
+ } as unknown as BottomSheet,
44
+ } as RefObject<BottomSheet | null>;
45
+
46
+ const { result } = renderHook(() =>
47
+ useBottomSheetBackHandler(bottomSheetRef),
48
+ );
49
+
50
+ await act(async () => {
51
+ result.current.handleSheetPositionChange(0);
52
+ });
53
+
54
+ const registeredCallback = mockAddEventListener.mock.calls[0][1];
55
+ const returnValue = registeredCallback();
56
+
57
+ expect(mockClose).toHaveBeenCalled();
58
+ expect(returnValue).toBe(true);
59
+ });
60
+
61
+ it("should remove listener when sheet is dismissed", async () => {
62
+ const bottomSheetRef = createRef<BottomSheet | null>();
63
+ const { result } = renderHook(() =>
64
+ useBottomSheetBackHandler(bottomSheetRef),
65
+ );
66
+
67
+ await act(async () => {
68
+ result.current.handleSheetPositionChange(0);
69
+ });
70
+
71
+ await act(async () => {
72
+ result.current.handleSheetPositionChange(-1);
73
+ });
74
+
75
+ expect(mockRemove).toHaveBeenCalled();
76
+ });
77
+
78
+ it("should not register listener when index is negative", async () => {
79
+ const bottomSheetRef = createRef<BottomSheet | null>();
80
+ const { result } = renderHook(() =>
81
+ useBottomSheetBackHandler(bottomSheetRef),
82
+ );
83
+
84
+ await act(async () => {
85
+ result.current.handleSheetPositionChange(-1);
86
+ });
87
+
88
+ expect(mockAddEventListener).not.toHaveBeenCalled();
89
+ });
90
+ });
@@ -0,0 +1,41 @@
1
+ import { useCallback, useRef } from "react";
2
+ import { BackHandler, type NativeEventSubscription } from "react-native";
3
+ import type BottomSheet from "@gorhom/bottom-sheet";
4
+
5
+ /**
6
+ * Hook that closes the bottom sheet on the hardware back button press if it is visible
7
+ * @param bottomSheetRef ref to the bottom sheet component
8
+ */
9
+ export function useBottomSheetBackHandler(
10
+ bottomSheetRef: React.RefObject<BottomSheet | null>,
11
+ ): {
12
+ handleSheetPositionChange: (index: number) => void;
13
+ } {
14
+ const backHandlerSubscriptionRef = useRef<NativeEventSubscription | null>(
15
+ null,
16
+ );
17
+
18
+ const handleSheetPositionChange = useCallback(
19
+ (index: number) => {
20
+ const isBottomSheetVisible = index >= 0;
21
+
22
+ if (isBottomSheetVisible && !backHandlerSubscriptionRef.current) {
23
+ // Setup the back handler if the bottom sheet is right in front of the user
24
+ backHandlerSubscriptionRef.current = BackHandler.addEventListener(
25
+ "hardwareBackPress",
26
+ () => {
27
+ bottomSheetRef.current?.close();
28
+
29
+ return true;
30
+ },
31
+ );
32
+ } else if (!isBottomSheetVisible) {
33
+ backHandlerSubscriptionRef.current?.remove();
34
+ backHandlerSubscriptionRef.current = null;
35
+ }
36
+ },
37
+ [bottomSheetRef],
38
+ );
39
+
40
+ return { handleSheetPositionChange };
41
+ }
@@ -124,7 +124,7 @@ export function Button({
124
124
  icon,
125
125
  testID,
126
126
  UNSAFE_style,
127
- }: ButtonProps): JSX.Element {
127
+ }: ButtonProps) {
128
128
  const { tokens } = useAtlantisTheme();
129
129
  const styles = useStyles();
130
130
 
@@ -28,7 +28,7 @@ const AnimatedImage = Animated.createAnimatedComponent(ImageBackground);
28
28
  function InternalButtonLoadingInternal({
29
29
  variation,
30
30
  type,
31
- }: InternalButtonLoadingProps): JSX.Element {
31
+ }: InternalButtonLoadingProps) {
32
32
  const translateX = useSharedValue(0);
33
33
  translateX.value = withRepeat(
34
34
  withTiming(offset, {
@@ -45,7 +45,7 @@ export function ButtonGroup({
45
45
  onOpenBottomSheet,
46
46
  onCloseBottomSheet,
47
47
  allowTapWhenOffline = false,
48
- }: ButtonGroupProps): JSX.Element {
48
+ }: ButtonGroupProps) {
49
49
  const { t } = useAtlantisI18n();
50
50
  const { handlePress } = usePreventTapWhenOffline();
51
51
  const secondaryActionsRef = useRef<BottomSheetRef>(null);
@@ -1,5 +1,5 @@
1
1
  import type { IconColorNames, IconNames } from "@jobber/design";
2
- import React from "react";
2
+ import React, { type ReactElement } from "react";
3
3
  import type { ButtonType, ButtonVariation } from "../Button";
4
4
 
5
5
  export interface ButtonGroupActionProps {
@@ -49,18 +49,18 @@ export interface ButtonGroupPrimaryActionProps extends ButtonGroupActionProps {
49
49
  /**
50
50
  * Optional custom button that can be rendered in place of the primary action button
51
51
  */
52
- customButton?: JSX.Element;
52
+ customButton?: ReactElement;
53
53
  loading?: boolean;
54
54
  }
55
55
 
56
56
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
57
- export function PrimaryAction(_: ButtonGroupPrimaryActionProps): JSX.Element {
57
+ export function PrimaryAction(_: ButtonGroupPrimaryActionProps) {
58
58
  return <></>;
59
59
  }
60
60
 
61
61
  export function SecondaryAction(
62
62
  // eslint-disable-next-line @typescript-eslint/no-unused-vars
63
63
  _: ButtonGroupSecondaryActionProps,
64
- ): JSX.Element {
64
+ ) {
65
65
  return <></>;
66
66
  }
@@ -9,7 +9,7 @@ import { BottomSheet } from "../../../BottomSheet/BottomSheet";
9
9
 
10
10
  interface SecondaryActionSheetProps {
11
11
  readonly actions: ButtonGroupSecondaryActionProps[];
12
- readonly secondaryActionsRef: RefObject<BottomSheetRef>;
12
+ readonly secondaryActionsRef: RefObject<BottomSheetRef | null>;
13
13
  readonly showCancel?: boolean;
14
14
  readonly heading?: string;
15
15
  readonly onOpenBottomSheet?: () => void;
@@ -23,7 +23,7 @@ export function SecondaryActionSheet({
23
23
  showCancel,
24
24
  onOpenBottomSheet,
25
25
  onCloseBottomSheet,
26
- }: SecondaryActionSheetProps): JSX.Element {
26
+ }: SecondaryActionSheetProps) {
27
27
  return (
28
28
  <Portal>
29
29
  <BottomSheet
package/src/Card/Card.tsx CHANGED
@@ -80,7 +80,7 @@ export function Card({
80
80
  testID = "card",
81
81
  error,
82
82
  elevation = "none",
83
- }: CardProps): JSX.Element {
83
+ }: CardProps) {
84
84
  const styles = useStyles();
85
85
 
86
86
  return (
@@ -15,7 +15,7 @@ export function InternalCardHeader({
15
15
  children,
16
16
  testID,
17
17
  collapsable,
18
- }: InternalCardHeaderProps): JSX.Element {
18
+ }: InternalCardHeaderProps) {
19
19
  const styles = useStyles();
20
20
 
21
21
  const conditionalChildStyling = collapsable ? undefined : styles.noChildren;
@@ -79,7 +79,7 @@ export type CheckboxProps = XOR<
79
79
  UncontrolledCheckboxProps
80
80
  >;
81
81
 
82
- export function Checkbox(props: CheckboxProps): JSX.Element {
82
+ export function Checkbox(props: CheckboxProps) {
83
83
  if (props.checked !== undefined && props.onChange !== undefined) {
84
84
  return <CheckboxInternal {...props} />;
85
85
  } else if (props.name) {
@@ -113,7 +113,7 @@ function CheckboxInternal({
113
113
  assistiveText,
114
114
  onChange,
115
115
  accessibilityLabel,
116
- }: CheckboxProps): JSX.Element {
116
+ }: CheckboxProps) {
117
117
  const internalValue = checked ?? !!defaultChecked;
118
118
 
119
119
  const iconName = indeterminate ? "minus2" : "checkmark";
@@ -66,7 +66,7 @@ function SetupWithForm({
66
66
  }: {
67
67
  readonly initialValues: CheckboxGroupFormData;
68
68
  readonly onChangeHandlers?: CheckboxGroupFormOnChangeHandlers;
69
- }): JSX.Element {
69
+ }) {
70
70
  const formMethods = useForm({ defaultValues: initialValues });
71
71
 
72
72
  return (
@@ -46,7 +46,7 @@ export function CheckboxGroup({
46
46
  onChange,
47
47
  name,
48
48
  ...rest
49
- }: CheckboxGroupProps): JSX.Element {
49
+ }: CheckboxGroupProps) {
50
50
  if (state !== undefined && onChange !== undefined) {
51
51
  return (
52
52
  <CheckboxGroupInternal
@@ -92,7 +92,7 @@ function CheckboxGroupInternal({
92
92
  accessibilityLabel,
93
93
  onChange,
94
94
  name: parentName,
95
- }: ControlledCheckboxGroupProps): JSX.Element {
95
+ }: ControlledCheckboxGroupProps) {
96
96
  const childrenNames = React.Children.map(children, child => {
97
97
  const name = throwErrorIfItHasNoName(child.props.name);
98
98
 
@@ -12,7 +12,7 @@ export const useStyles = buildThemedStyles(tokens => {
12
12
  justifyContent: "center",
13
13
  marginHorizontal: tokens["space-smaller"],
14
14
  marginTop: tokens["space-small"],
15
- paddingHorizontal: tokens["space-small"],
15
+ paddingHorizontal: tokens["space-base"],
16
16
  },
17
17
  iconLeft: {
18
18
  marginHorizontal: tokens["space-smallest"],
package/src/Chip/Chip.tsx CHANGED
@@ -5,6 +5,7 @@ import type { IconNames } from "@jobber/design";
5
5
  import { useStyles } from "./Chip.style";
6
6
  import { Icon } from "../Icon";
7
7
  import { Typography } from "../Typography";
8
+ import type { AtlantisThemeContextValue } from "../AtlantisThemeContext";
8
9
  import { useAtlantisTheme } from "../AtlantisThemeContext";
9
10
 
10
11
  export type AccentType = "client" | "invoice" | "job" | "request" | "quote";
@@ -68,7 +69,7 @@ export function Chip({
68
69
  accessibilityLabel,
69
70
  accessibilityRole = "radio",
70
71
  accent,
71
- }: ChipProps): JSX.Element {
72
+ }: ChipProps) {
72
73
  const styles = useStyles();
73
74
  const { tokens } = useAtlantisTheme();
74
75
  const defaultAccentColor = tokens["color-surface--reverse"];
@@ -86,6 +87,7 @@ export function Chip({
86
87
  : tokens["color-interactive--background"],
87
88
  },
88
89
  isActive && { backgroundColor: accentColor },
90
+ getBorderStyle(inactiveBackgroundColor, tokens),
89
91
  ];
90
92
  const dismiss =
91
93
  (isActive || inactiveBackgroundColor === "surface") &&
@@ -96,7 +98,7 @@ export function Chip({
96
98
  iconCustomColor: iconColor,
97
99
  dismissColor: dismiss,
98
100
  };
99
- }, [accent, isActive, inactiveBackgroundColor]);
101
+ }, [accent, isActive, inactiveBackgroundColor, getBorderStyle, styles]);
100
102
 
101
103
  const accessibilityState = useMemo(() => {
102
104
  const checkableRoles = ["radio", "switch", "togglebutton", "checkbox"];
@@ -145,3 +147,19 @@ export function Chip({
145
147
  </Pressable>
146
148
  );
147
149
  }
150
+
151
+ function getBorderStyle(
152
+ inactiveBackgroundColor: "surface" | "background",
153
+ tokens: AtlantisThemeContextValue["tokens"],
154
+ ) {
155
+ let borderColor = "transparent";
156
+
157
+ if (inactiveBackgroundColor === "surface") {
158
+ borderColor = tokens["color-border"];
159
+ }
160
+
161
+ return {
162
+ borderColor,
163
+ borderWidth: tokens["border-base"],
164
+ };
165
+ }
@@ -51,7 +51,7 @@ export function Content({
51
51
  childSpacing = "base",
52
52
  direction = "vertical",
53
53
  UNSAFE_style,
54
- }: ContentProps): JSX.Element {
54
+ }: ContentProps) {
55
55
  const horizontalStyles = useHorizontalStyles();
56
56
  const verticalStyles = useVerticalStyles();
57
57
  const spaceAroundStyles = useSpaceAroundStyles();
@@ -57,7 +57,7 @@ function ContentOverlayInternal(
57
57
  avoidKeyboardLikeIOS,
58
58
  }: ContentOverlayProps,
59
59
  ref: Ref<ContentOverlayRef>,
60
- ): JSX.Element {
60
+ ) {
61
61
  isDraggable = onBeforeExit ? false : isDraggable;
62
62
  const isCloseableOnOverlayTap = onBeforeExit ? false : true;
63
63
  const { t } = useAtlantisI18n();
@@ -71,9 +71,9 @@ function ContentOverlayInternal(
71
71
  const shouldShowDismiss =
72
72
  showDismiss || isScreenReaderEnabled || isFullScreenOrTopPosition;
73
73
  const [showHeaderShadow, setShowHeaderShadow] = useState<boolean>(false);
74
- const overlayHeader = useRef<View>();
74
+ const overlayHeader = useRef<View>(null);
75
75
 
76
- const internalRef = useRef<Modalize>();
76
+ const internalRef = useRef<Modalize>(null);
77
77
  const [modalizeMethods, setModalizeMethods] = useState<ContentOverlayRef>();
78
78
  const callbackInternalRef = useCallback((instance: Modalize) => {
79
79
  if (instance && !internalRef.current) {
@@ -244,7 +244,6 @@ function ContentOverlayInternal(
244
244
  {shouldShowDismiss && (
245
245
  <View
246
246
  style={styles.dismissButton}
247
- // @ts-expect-error tsc-ci
248
247
  ref={overlayHeader}
249
248
  accessibilityLabel={accessibilityLabel || closeOverlayA11YLabel}
250
249
  accessible={true}
@@ -61,7 +61,7 @@ export function Disclosure({
61
61
  onToggle,
62
62
  isEmpty,
63
63
  animationDuration = staticTokens["timing-slowest"],
64
- }: DisclosureProps): JSX.Element {
64
+ }: DisclosureProps) {
65
65
  const styles = useStyles();
66
66
 
67
67
  return (
@@ -26,7 +26,7 @@ export function Divider({
26
26
  size = "base",
27
27
  direction = "horizontal",
28
28
  testID = "Divider",
29
- }: DividerProps): JSX.Element {
29
+ }: DividerProps) {
30
30
  const horizontalStyles = useHorizontalStyles();
31
31
  const verticalStyles = useVerticalStyles();
32
32
 
@@ -65,7 +65,7 @@ export function EmptyState({
65
65
  primaryAction,
66
66
  secondaryAction,
67
67
  iconColor = "blue",
68
- }: EmptyStateProps): JSX.Element {
68
+ }: EmptyStateProps) {
69
69
  const styles = useStyles();
70
70
 
71
71
  return (
@@ -34,7 +34,7 @@ export function ErrorMessageWrapper({
34
34
  message,
35
35
  wrapFor = "default",
36
36
  children,
37
- }: ErrorMessageWrapperProps): JSX.Element {
37
+ }: ErrorMessageWrapperProps) {
38
38
  const errorMessageContext = useErrorMessageContext();
39
39
  const register = errorMessageContext?.register;
40
40
  const unregister = errorMessageContext?.unregister;
@@ -13,9 +13,7 @@ interface ErrorMessageProviderProps {
13
13
  readonly children: ReactNode;
14
14
  }
15
15
 
16
- export function ErrorMessageProvider({
17
- children,
18
- }: ErrorMessageProviderProps): JSX.Element {
16
+ export function ErrorMessageProvider({ children }: ErrorMessageProviderProps) {
19
17
  const [elements, setElements] = useState<
20
18
  ErrorMessageContextProps["elements"]
21
19
  >({});
@@ -51,13 +49,13 @@ export function ErrorMessageProvider({
51
49
  }
52
50
  }
53
51
 
54
- function getMeasure(ref: RefObject<View>) {
52
+ function getMeasure(ref: RefObject<View | null>) {
55
53
  return function measure(...args: Parameters<NativeMethods["measureLayout"]>) {
56
54
  ref.current?.measureLayout(...args);
57
55
  };
58
56
  }
59
57
 
60
- function getAccessibilityFocus(ref: RefObject<View>) {
58
+ function getAccessibilityFocus(ref: RefObject<View | null>) {
61
59
  return function accessibilityFocus() {
62
60
  const reactTag = findNodeHandle(ref.current);
63
61
  reactTag &&
@@ -50,7 +50,7 @@ type ElementID = Element["id"];
50
50
  export interface ErrorMessageContextRegisterParams {
51
51
  readonly id: ElementID;
52
52
  readonly hasErrorMessage: Methods["hasErrorMessage"];
53
- readonly ref: RefObject<View>;
53
+ readonly ref: RefObject<View | null>;
54
54
  }
55
55
 
56
56
  export interface ErrorMessageContextProps {
package/src/Flex/Flex.tsx CHANGED
@@ -11,7 +11,7 @@ export function Flex({
11
11
  align = "center",
12
12
  gap = "base",
13
13
  children,
14
- }: PropsWithChildren<FlexProps>): JSX.Element {
14
+ }: PropsWithChildren<FlexProps>) {
15
15
  if (template.length === 1) {
16
16
  console.warn("Please use <Content /> component for a stacked layout");
17
17
  }
@@ -54,7 +54,7 @@ function Row({
54
54
  align = "center",
55
55
  gap = "base",
56
56
  children,
57
- }: PropsWithChildren<FlexProps>): JSX.Element {
57
+ }: PropsWithChildren<FlexProps>) {
58
58
  return (
59
59
  <View testID="ATL-Flex-Row" style={[styles.row, { alignItems: align }]}>
60
60
  {Children.map(children, (child, index) => (