@jobber/components-native 0.89.5-JOB-140604-cab60b8.43 → 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.
- package/dist/package.json +7 -7
- package/dist/src/ActionItem/ActionItemGroup.js +1 -1
- package/dist/src/AutoLink/components/Link/Link.js +1 -1
- package/dist/src/BottomSheet/BottomSheet.js +4 -2
- package/dist/src/BottomSheet/hooks/useBottomSheetBackHandler.js +26 -0
- package/dist/src/Chip/Chip.js +12 -1
- package/dist/src/Chip/Chip.style.js +1 -1
- package/dist/src/ContentOverlay/ContentOverlay.js +3 -5
- package/dist/src/ErrorMessageWrapper/context/ErrorMessageProvider.js +1 -1
- package/dist/src/Form/Form.js +2 -1
- package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +1 -1
- package/dist/src/Form/hooks/useInternalForm.js +6 -3
- package/dist/src/FormatFile/components/MediaView/MediaView.js +22 -5
- package/dist/src/InputDate/InputDate.js +2 -2
- package/dist/src/InputFieldWrapper/InputFieldWrapper.js +14 -12
- package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +5 -2
- package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +5 -2
- package/dist/src/InputPressable/InputPressable.js +20 -8
- package/dist/src/InputPressable/InputPressable.style.js +3 -0
- package/dist/src/InputText/InputText.js +22 -11
- package/dist/src/InputText/InputText.style.js +4 -0
- package/dist/src/InputTime/InputTime.js +2 -2
- package/dist/src/Menu/Menu.js +2 -2
- package/dist/src/Select/components/SelectPressable/SelectPressable.js +1 -1
- package/dist/src/utils/meta/meta.json +0 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/src/ActionItem/ActionItem.d.ts +2 -1
- package/dist/types/src/ActionItem/ActionItemGroup.d.ts +2 -1
- package/dist/types/src/ActionItem/components/ActionItemContainer.d.ts +2 -1
- package/dist/types/src/ActionLabel/ActionLabel.d.ts +1 -1
- package/dist/types/src/ActivityIndicator/ActivityIndicator.d.ts +2 -1
- package/dist/types/src/AutoLink/AutoLink.d.ts +2 -1
- package/dist/types/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.d.ts +2 -1
- package/dist/types/src/AutoLink/components/Link/Link.d.ts +2 -1
- package/dist/types/src/Banner/Banner.d.ts +2 -1
- package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +2 -1
- package/dist/types/src/BottomSheet/BottomSheet.d.ts +4 -9
- package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +2 -1
- package/dist/types/src/BottomSheet/hooks/useBottomSheetBackHandler.d.ts +8 -0
- package/dist/types/src/Button/Button.d.ts +2 -1
- package/dist/types/src/Button/components/InternalButtonLoading/InternalButtonLoading.d.ts +1 -1
- package/dist/types/src/ButtonGroup/ButtonGroup.d.ts +2 -1
- package/dist/types/src/ButtonGroup/ButtonGroupAction.d.ts +4 -3
- package/dist/types/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.d.ts +3 -2
- package/dist/types/src/Card/Card.d.ts +2 -1
- package/dist/types/src/Card/components/InternalCardHeader.d.ts +2 -1
- package/dist/types/src/Checkbox/Checkbox.d.ts +2 -1
- package/dist/types/src/Checkbox/CheckboxGroup.d.ts +2 -1
- package/dist/types/src/Chip/Chip.d.ts +2 -1
- package/dist/types/src/Content/Content.d.ts +2 -1
- package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +1 -1
- package/dist/types/src/Disclosure/Disclosure.d.ts +1 -1
- package/dist/types/src/Divider/Divider.d.ts +2 -1
- package/dist/types/src/EmptyState/EmptyState.d.ts +2 -1
- package/dist/types/src/ErrorMessageWrapper/ErrorMessageWrapper.d.ts +2 -1
- package/dist/types/src/ErrorMessageWrapper/context/ErrorMessageProvider.d.ts +2 -1
- package/dist/types/src/ErrorMessageWrapper/context/types.d.ts +1 -1
- package/dist/types/src/Flex/Flex.d.ts +2 -1
- package/dist/types/src/Form/Form.d.ts +2 -1
- package/dist/types/src/Form/components/FormActionBar/FormActionBar.d.ts +3 -2
- package/dist/types/src/Form/components/FormBody/FormBody.d.ts +3 -2
- package/dist/types/src/Form/components/FormCache/FormCache.d.ts +2 -1
- package/dist/types/src/Form/components/FormErrorBanner/FormErrorBanner.d.ts +2 -1
- package/dist/types/src/Form/components/FormMask/FormMask.d.ts +2 -1
- package/dist/types/src/Form/components/FormMessage/FormMessage.d.ts +2 -1
- package/dist/types/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.d.ts +2 -1
- package/dist/types/src/Form/components/FormMessageBanner/FormMessageBanner.d.ts +2 -1
- package/dist/types/src/Form/components/FormSaveButton/FormSaveButton.d.ts +2 -1
- package/dist/types/src/Form/context/AtlantisFormContext.d.ts +1 -1
- package/dist/types/src/Form/context/types.d.ts +2 -2
- package/dist/types/src/Form/hooks/useFormViewRefs.d.ts +2 -2
- package/dist/types/src/Form/hooks/useInternalForm.d.ts +5 -5
- package/dist/types/src/Form/types.d.ts +10 -4
- package/dist/types/src/FormField/FormField.d.ts +1 -1
- package/dist/types/src/FormatFile/FormatFile.d.ts +2 -1
- package/dist/types/src/FormatFile/components/ErrorIcon/ErrorIcon.d.ts +2 -1
- package/dist/types/src/FormatFile/components/FileView/FileView.d.ts +2 -1
- package/dist/types/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.d.ts +3 -2
- package/dist/types/src/FormatFile/components/MediaView/MediaView.d.ts +2 -1
- package/dist/types/src/FormatFile/components/ProgressBar/ProgressBar.d.ts +2 -1
- package/dist/types/src/Heading/Heading.d.ts +1 -1
- package/dist/types/src/Icon/Icon.d.ts +2 -1
- package/dist/types/src/IconButton/IconButton.d.ts +1 -1
- package/dist/types/src/InputCurrency/InputCurrency.d.ts +2 -1
- package/dist/types/src/InputDate/InputDate.d.ts +4 -2
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.d.ts +9 -2
- package/dist/types/src/InputFieldWrapper/components/ClearAction/ClearAction.d.ts +2 -1
- package/dist/types/src/InputFieldWrapper/components/Prefix/Prefix.d.ts +4 -4
- package/dist/types/src/InputFieldWrapper/components/Suffix/Suffix.d.ts +4 -4
- package/dist/types/src/InputPressable/InputPressable.d.ts +9 -1
- package/dist/types/src/InputPressable/InputPressable.style.d.ts +3 -0
- package/dist/types/src/InputSearch/InputSearch.d.ts +1 -1
- package/dist/types/src/InputSearch/components/FilterButton.d.ts +2 -1
- package/dist/types/src/InputText/InputText.d.ts +8 -0
- package/dist/types/src/InputText/InputText.style.d.ts +4 -0
- package/dist/types/src/InputText/context/InputAccessoriesProvider.d.ts +2 -1
- package/dist/types/src/InputTime/InputTime.d.ts +4 -2
- package/dist/types/src/Menu/Menu.d.ts +2 -1
- package/dist/types/src/Menu/components/MenuOption/MenuOption.d.ts +2 -1
- package/dist/types/src/Menu/components/Overlay/Overlay.d.ts +2 -1
- package/dist/types/src/Menu/types.d.ts +6 -1
- package/dist/types/src/ProgressBar/ProgressBar.d.ts +2 -1
- package/dist/types/src/ProgressBar/ProgressBarInner.d.ts +2 -1
- package/dist/types/src/Select/Select.d.ts +3 -2
- package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.d.ts +2 -1
- package/dist/types/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.d.ts +2 -1
- package/dist/types/src/Select/components/SelectInternalPicker/SelectInternalPicker.d.ts +2 -1
- package/dist/types/src/Select/components/SelectPressable/SelectPressable.d.ts +2 -1
- package/dist/types/src/StatusLabel/StatusLabel.d.ts +2 -1
- package/dist/types/src/Switch/Switch.d.ts +2 -1
- package/dist/types/src/Switch/components/BaseSwitch/BaseSwitch.d.ts +2 -1
- package/dist/types/src/Text/Text.d.ts +1 -1
- package/dist/types/src/TextList/TextList.d.ts +2 -1
- package/dist/types/src/ThumbnailList/ThumbnailList.d.ts +2 -1
- package/dist/types/src/Toast/Toast.d.ts +2 -1
- package/dist/types/src/Typography/Typography.d.ts +1 -1
- package/dist/types/src/Typography/TypographyGestureDetector.d.ts +2 -1
- package/dist/types/src/utils/test/MockSafeAreaProvider.d.ts +1 -1
- package/package.json +7 -7
- package/src/ActionItem/ActionItem.tsx +1 -1
- package/src/ActionItem/ActionItemGroup.tsx +1 -3
- package/src/ActionItem/components/ActionItemContainer.tsx +1 -1
- package/src/ActionLabel/ActionLabel.tsx +1 -1
- package/src/ActivityIndicator/ActivityIndicator.tsx +1 -3
- package/src/AutoLink/AutoLink.tsx +1 -1
- package/src/AutoLink/components/ComposeTextWithLinks/ComposeTextWithLinks.tsx +1 -1
- package/src/AutoLink/components/Link/Link.tsx +1 -5
- package/src/Banner/Banner.tsx +2 -2
- package/src/Banner/components/BannerIcon/BannerIcon.tsx +1 -1
- package/src/BottomSheet/BottomSheet.stories.tsx +0 -1
- package/src/BottomSheet/BottomSheet.tsx +9 -10
- package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +1 -1
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.test.ts +90 -0
- package/src/BottomSheet/hooks/useBottomSheetBackHandler.ts +41 -0
- package/src/Button/Button.tsx +1 -1
- package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +1 -1
- package/src/ButtonGroup/ButtonGroup.tsx +1 -1
- package/src/ButtonGroup/ButtonGroupAction.tsx +4 -4
- package/src/ButtonGroup/components/SecondaryActionSheet/SecondaryActionSheet.tsx +2 -2
- package/src/Card/Card.tsx +1 -1
- package/src/Card/components/InternalCardHeader.tsx +1 -1
- package/src/Checkbox/Checkbox.tsx +2 -2
- package/src/Checkbox/CheckboxGroup.test.tsx +1 -1
- package/src/Checkbox/CheckboxGroup.tsx +2 -2
- package/src/Chip/Chip.style.ts +1 -1
- package/src/Chip/Chip.tsx +20 -2
- package/src/Content/Content.tsx +1 -1
- package/src/ContentOverlay/ContentOverlay.tsx +3 -4
- package/src/Disclosure/Disclosure.tsx +1 -1
- package/src/Divider/Divider.tsx +1 -1
- package/src/EmptyState/EmptyState.tsx +1 -1
- package/src/ErrorMessageWrapper/ErrorMessageWrapper.tsx +1 -1
- package/src/ErrorMessageWrapper/context/ErrorMessageProvider.tsx +3 -5
- package/src/ErrorMessageWrapper/context/types.ts +1 -1
- package/src/Flex/Flex.tsx +2 -2
- package/src/Form/Form.test.tsx +145 -2
- package/src/Form/Form.tsx +3 -1
- package/src/Form/components/FormActionBar/FormActionBar.tsx +3 -3
- package/src/Form/components/FormBody/FormBody.tsx +3 -3
- package/src/Form/components/FormCache/FormCache.tsx +1 -1
- package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +1 -1
- package/src/Form/components/FormMask/FormMask.tsx +1 -1
- package/src/Form/components/FormMessage/FormMessage.tsx +1 -1
- package/src/Form/components/FormMessage/components/InternalFormMessage/InternalFormMessage.tsx +1 -1
- package/src/Form/components/FormMessageBanner/FormMessageBanner.tsx +1 -3
- package/src/Form/components/FormSaveButton/FormSaveButton.tsx +1 -1
- package/src/Form/context/types.ts +2 -2
- package/src/Form/hooks/useFormViewRefs.ts +4 -5
- package/src/Form/hooks/useInternalForm.ts +12 -5
- package/src/Form/types.ts +11 -4
- package/src/FormField/FormField.tsx +1 -1
- package/src/FormatFile/FormatFile.tsx +3 -3
- package/src/FormatFile/components/ErrorIcon/ErrorIcon.tsx +1 -1
- package/src/FormatFile/components/FileView/FileView.tsx +1 -1
- package/src/FormatFile/components/FormatFileBottomSheet/FormatFileBottomSheet.tsx +2 -2
- package/src/FormatFile/components/MediaView/MediaView.test.tsx +283 -0
- package/src/FormatFile/components/MediaView/MediaView.tsx +28 -7
- package/src/FormatFile/components/ProgressBar/ProgressBar.tsx +1 -1
- package/src/Heading/Heading.tsx +1 -1
- package/src/Icon/Icon.tsx +1 -1
- package/src/IconButton/IconButton.tsx +1 -1
- package/src/InputCurrency/InputCurrency.tsx +1 -1
- package/src/InputDate/InputDate.tsx +7 -3
- package/src/InputFieldWrapper/InputFieldWrapper.test.tsx +48 -1
- package/src/InputFieldWrapper/InputFieldWrapper.tsx +39 -29
- package/src/InputFieldWrapper/components/ClearAction/ClearAction.tsx +1 -1
- package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +3 -5
- package/src/InputFieldWrapper/components/Prefix/Prefix.tsx +8 -6
- package/src/InputFieldWrapper/components/Suffix/Suffix.test.tsx +2 -4
- package/src/InputFieldWrapper/components/Suffix/Suffix.tsx +8 -6
- package/src/InputPassword/InputPassword.tsx +1 -1
- package/src/InputPressable/InputPressable.style.ts +4 -0
- package/src/InputPressable/InputPressable.test.tsx +75 -1
- package/src/InputPressable/InputPressable.tsx +34 -8
- package/src/InputSearch/InputSearch.tsx +1 -0
- package/src/InputSearch/components/FilterButton.tsx +1 -1
- package/src/InputText/InputText.style.ts +5 -0
- package/src/InputText/InputText.test.tsx +75 -0
- package/src/InputText/InputText.tsx +32 -12
- package/src/InputText/context/InputAccessoriesProvider.tsx +1 -1
- package/src/InputTime/InputTime.tsx +7 -3
- package/src/Menu/Menu.tsx +3 -3
- package/src/Menu/components/MenuOption/MenuOption.tsx +1 -1
- package/src/Menu/components/Overlay/Overlay.tsx +1 -1
- package/src/Menu/types.ts +7 -1
- package/src/ProgressBar/ProgressBar.tsx +1 -1
- package/src/ProgressBar/ProgressBarInner.tsx +1 -1
- package/src/Select/Select.tsx +2 -2
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.ios.tsx +1 -1
- package/src/Select/components/SelectDefaultPicker/SelectDefaultPicker.tsx +1 -1
- package/src/Select/components/SelectInternalPicker/SelectInternalPicker.tsx +1 -1
- package/src/Select/components/SelectPressable/SelectPressable.tsx +1 -4
- package/src/StatusLabel/StatusLabel.tsx +1 -1
- package/src/Switch/Switch.tsx +1 -1
- package/src/Switch/components/BaseSwitch/BaseSwitch.tsx +1 -1
- package/src/Text/Text.tsx +1 -1
- package/src/TextList/TextList.tsx +1 -1
- package/src/ThumbnailList/ThumbnailList.tsx +1 -1
- package/src/Toast/Toast.tsx +2 -2
- package/src/Typography/Typography.tsx +1 -1
- package/src/Typography/TypographyGestureDetector.tsx +1 -3
- package/src/utils/meta/meta.json +0 -1
- package/src/utils/test/MockSafeAreaProvider.tsx +1 -1
- package/dist/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.js +0 -45
- package/dist/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.js +0 -8
- package/dist/types/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.d.ts +0 -9
- package/dist/types/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.d.ts +0 -5
- package/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.styles.ts +0 -9
- package/src/BottomSheet/components/BottomSheetInputText/BottomSheetInputText.tsx +0 -89
|
@@ -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)
|
|
14
|
+
}: AutoLinkProps) {
|
|
15
15
|
const { splitText, matches } = useCreateLinkedText({ text, ...rest });
|
|
16
16
|
const { tokens } = useAtlantisTheme();
|
|
17
17
|
|
|
@@ -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>
|
package/src/Banner/Banner.tsx
CHANGED
|
@@ -18,7 +18,7 @@ export function Banner({
|
|
|
18
18
|
type,
|
|
19
19
|
children,
|
|
20
20
|
icon,
|
|
21
|
-
}: BannerProps)
|
|
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)
|
|
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)
|
|
13
|
+
export function BannerIcon({ icon, type }: BannerIconProps) {
|
|
14
14
|
const styles = useStyles();
|
|
15
15
|
|
|
16
16
|
return (
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ReactNode
|
|
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 {
|
|
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)
|
|
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
|
+
}
|
package/src/Button/Button.tsx
CHANGED
|
@@ -28,7 +28,7 @@ const AnimatedImage = Animated.createAnimatedComponent(ImageBackground);
|
|
|
28
28
|
function InternalButtonLoadingInternal({
|
|
29
29
|
variation,
|
|
30
30
|
type,
|
|
31
|
-
}: InternalButtonLoadingProps)
|
|
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)
|
|
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?:
|
|
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)
|
|
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
|
-
)
|
|
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)
|
|
26
|
+
}: SecondaryActionSheetProps) {
|
|
27
27
|
return (
|
|
28
28
|
<Portal>
|
|
29
29
|
<BottomSheet
|
package/src/Card/Card.tsx
CHANGED
|
@@ -15,7 +15,7 @@ export function InternalCardHeader({
|
|
|
15
15
|
children,
|
|
16
16
|
testID,
|
|
17
17
|
collapsable,
|
|
18
|
-
}: InternalCardHeaderProps)
|
|
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)
|
|
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)
|
|
116
|
+
}: CheckboxProps) {
|
|
117
117
|
const internalValue = checked ?? !!defaultChecked;
|
|
118
118
|
|
|
119
119
|
const iconName = indeterminate ? "minus2" : "checkmark";
|
|
@@ -46,7 +46,7 @@ export function CheckboxGroup({
|
|
|
46
46
|
onChange,
|
|
47
47
|
name,
|
|
48
48
|
...rest
|
|
49
|
-
}: CheckboxGroupProps)
|
|
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)
|
|
95
|
+
}: ControlledCheckboxGroupProps) {
|
|
96
96
|
const childrenNames = React.Children.map(children, child => {
|
|
97
97
|
const name = throwErrorIfItHasNoName(child.props.name);
|
|
98
98
|
|
package/src/Chip/Chip.style.ts
CHANGED
|
@@ -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-
|
|
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)
|
|
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
|
+
}
|
package/src/Content/Content.tsx
CHANGED
|
@@ -51,7 +51,7 @@ export function Content({
|
|
|
51
51
|
childSpacing = "base",
|
|
52
52
|
direction = "vertical",
|
|
53
53
|
UNSAFE_style,
|
|
54
|
-
}: ContentProps)
|
|
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
|
-
)
|
|
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}
|
package/src/Divider/Divider.tsx
CHANGED
|
@@ -34,7 +34,7 @@ export function ErrorMessageWrapper({
|
|
|
34
34
|
message,
|
|
35
35
|
wrapFor = "default",
|
|
36
36
|
children,
|
|
37
|
-
}: ErrorMessageWrapperProps)
|
|
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>)
|
|
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>)
|
|
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) => (
|