@jobber/components-native 0.84.4-JOB-134681-8086ad4.25 → 0.84.4-JOB-138679-b1552ab.68
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 +23 -14
- package/dist/src/ActionItem/ActionItemGroup.js +1 -1
- package/dist/src/AutoLink/components/Link/Link.js +1 -1
- package/dist/src/Banner/Banner.js +2 -0
- package/dist/src/Banner/components/BannerIcon/BannerIcon.style.js +3 -0
- package/dist/src/BottomSheet/BottomSheet.js +2 -2
- package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +0 -1
- package/dist/src/ButtonGroup/ButtonGroup.js +1 -1
- package/dist/src/ContentOverlay/ContentOverlay.js +5 -7
- package/dist/src/ContentOverlay/UNSAFE_WrappedModalize.js +23 -0
- package/dist/src/ErrorMessageWrapper/context/ErrorMessageProvider.js +1 -1
- package/dist/src/Form/Form.js +5 -2
- package/dist/src/Form/components/FormCache/FormCache.js +1 -0
- package/dist/src/Form/components/FormMessageBanner/FormMessageBanner.js +1 -1
- package/dist/src/Form/context/AtlantisFormContext.js +1 -0
- package/dist/src/Form/hooks/useInternalForm.js +6 -3
- package/dist/src/FormatFile/components/MediaView/MediaView.js +22 -5
- package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +1 -1
- package/dist/src/InputCurrency/InputCurrency.js +42 -30
- package/dist/src/InputDate/InputDate.js +2 -2
- package/dist/src/InputEmail/InputEmail.js +12 -4
- package/dist/src/InputFieldWrapper/InputFieldWrapper.js +14 -12
- package/dist/src/InputFieldWrapper/InputFieldWrapper.style.js +1 -1
- package/dist/src/InputFieldWrapper/components/Prefix/Prefix.js +5 -2
- package/dist/src/InputFieldWrapper/components/Suffix/Suffix.js +5 -2
- package/dist/src/InputNumber/InputNumber.js +10 -4
- package/dist/src/InputPressable/InputPressable.js +20 -8
- package/dist/src/InputPressable/InputPressable.style.js +3 -0
- package/dist/src/InputSearch/InputSearch.js +1 -1
- 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/Select.style.js +1 -0
- package/dist/src/Select/components/SelectPressable/SelectPressable.js +1 -1
- package/dist/src/Switch/components/BaseSwitch/BaseSwitch.js +7 -1
- package/dist/src/Typography/Typography.js +16 -5
- package/dist/src/hooks/useAtlantisI18n/locales/en.json +1 -0
- package/dist/src/hooks/useAtlantisI18n/locales/es.json +1 -0
- package/dist/src/hooks/useFormController.js +5 -14
- package/dist/tsconfig.build.json +7 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/dist/tsconfig.json +4 -6
- 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 +4 -3
- 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/Banner/components/BannerIcon/BannerIcon.style.d.ts +3 -0
- package/dist/types/src/Banner/types.d.ts +1 -1
- package/dist/types/src/BottomSheet/BottomSheet.d.ts +1 -1
- package/dist/types/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.d.ts +2 -1
- 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/ContentOverlay.d.ts +1 -1
- package/dist/types/src/ContentOverlay/UNSAFE_WrappedModalize.d.ts +3 -0
- 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 +4 -3
- 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 +2 -1
- package/dist/types/src/Form/context/types.d.ts +3 -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 +13 -7
- 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 +4 -3
- 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/InputFieldWrapper.style.d.ts +1 -1
- 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 +10 -2
- 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 +4 -3
- 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 +3 -3
- package/dist/types/src/Typography/TypographyGestureDetector.d.ts +2 -1
- package/dist/types/src/utils/test/MockSafeAreaProvider.d.ts +1 -1
- package/package.json +23 -14
- 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.test.tsx +12 -0
- package/src/ActionLabel/ActionLabel.tsx +3 -3
- package/src/ActionLabel/__snapshots__/ActionLabel.test.tsx.snap +66 -0
- package/src/ActivityIndicator/ActivityIndicator.tsx +1 -3
- package/src/AtlantisContext/AtlantisContext.test.tsx +1 -1
- package/src/AtlantisThemeContext/AtlantisThemeContext.test.tsx +5 -5
- package/src/AutoLink/AutoLink.test.tsx +2 -4
- 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.test.tsx +12 -0
- package/src/Banner/Banner.tsx +4 -2
- package/src/Banner/components/BannerIcon/BannerIcon.style.ts +3 -0
- package/src/Banner/components/BannerIcon/BannerIcon.tsx +1 -1
- package/src/Banner/types.ts +1 -1
- package/src/BottomSheet/BottomSheet.test.tsx +17 -17
- package/src/BottomSheet/BottomSheet.tsx +4 -3
- package/src/BottomSheet/components/BottomSheetOption/BottomSheetOption.tsx +1 -1
- package/src/Button/Button.tsx +1 -1
- package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +1 -2
- package/src/ButtonGroup/ButtonGroup.test.tsx +13 -11
- package/src/ButtonGroup/ButtonGroup.tsx +2 -2
- 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 +3 -7
- package/src/Checkbox/CheckboxGroup.tsx +2 -2
- package/src/Chip/Chip.tsx +1 -1
- package/src/Content/Content.tsx +1 -1
- package/src/ContentOverlay/ContentOverlay.test.tsx +34 -27
- package/src/ContentOverlay/ContentOverlay.tsx +7 -7
- package/src/ContentOverlay/UNSAFE_WrappedModalize.tsx +41 -0
- package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +7 -7
- package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +1 -1
- package/src/Disclosure/Disclosure.tsx +1 -1
- package/src/Divider/Divider.tsx +1 -1
- package/src/EmptyState/EmptyState.test.tsx +29 -42
- 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 +8 -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 +5 -4
- package/src/Form/components/FormErrorBanner/FormErrorBanner.tsx +1 -1
- package/src/Form/components/FormMask/FormMask.tsx +1 -1
- package/src/Form/components/FormMessage/FormMessage.test.tsx +40 -27
- 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.test.tsx +2 -2
- package/src/Form/components/FormSaveButton/FormSaveButton.tsx +1 -1
- package/src/Form/context/AtlantisFormContext.test.tsx +1 -1
- package/src/Form/context/AtlantisFormContext.tsx +1 -0
- package/src/Form/context/types.ts +3 -2
- package/src/Form/hooks/useFormViewRefs.ts +4 -5
- package/src/Form/hooks/useInternalForm.ts +12 -4
- package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +2 -1
- package/src/Form/types.ts +14 -8
- package/src/FormField/FormField.tsx +1 -1
- package/src/FormatFile/FormatFile.test.tsx +21 -21
- 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.test.tsx +14 -14
- 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/FormatFile/utils/createUseCreateThumbnail.ts +1 -1
- package/src/Glimmer/Glimmer.test.tsx +2 -2
- package/src/Heading/Heading.test.tsx +13 -0
- package/src/Heading/Heading.tsx +3 -3
- package/src/Heading/__snapshots__/Heading.test.tsx.snap +65 -0
- package/src/Icon/Icon.tsx +1 -1
- package/src/Icon/__snapshots__/Icon.test.tsx.snap +7 -0
- package/src/IconButton/IconButton.tsx +1 -1
- package/src/InputCurrency/InputCurrency.tsx +72 -58
- package/src/InputDate/InputDate.tsx +7 -3
- package/src/InputEmail/InputEmail.tsx +15 -8
- package/src/InputFieldWrapper/InputFieldWrapper.style.ts +1 -1
- 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 +8 -16
- 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/InputNumber/InputNumber.tsx +11 -7
- 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 +2 -1
- 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 +34 -17
- 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.style.ts +1 -0
- 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 +8 -2
- package/src/Text/Text.test.tsx +10 -0
- package/src/Text/Text.tsx +3 -3
- package/src/Text/__snapshots__/Text.test.tsx.snap +66 -0
- package/src/TextList/TextList.tsx +1 -1
- package/src/ThumbnailList/ThumbnailList.test.tsx +5 -5
- package/src/ThumbnailList/ThumbnailList.tsx +1 -1
- package/src/Toast/Toast.tsx +2 -2
- package/src/Typography/Typography.test.tsx +61 -0
- package/src/Typography/Typography.tsx +25 -9
- package/src/Typography/TypographyGestureDetector.tsx +1 -3
- package/src/Typography/__snapshots__/Typography.test.tsx.snap +222 -0
- package/src/hooks/useAtlantisI18n/locales/en.json +1 -0
- package/src/hooks/useAtlantisI18n/locales/es.json +1 -0
- package/src/hooks/useFormController.ts +6 -13
- package/src/utils/test/MockSafeAreaProvider.tsx +1 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
|
@@ -127,7 +127,7 @@ describe("when a secondaryActions is passed in", () => {
|
|
|
127
127
|
const beforeSubmitMock = jest.fn().mockImplementation(() => {
|
|
128
128
|
return Promise.resolve(true);
|
|
129
129
|
});
|
|
130
|
-
const { getByLabelText } = render(
|
|
130
|
+
const { findByLabelText, getByLabelText } = render(
|
|
131
131
|
<ButtonGroupForTest
|
|
132
132
|
primaryAction={pressHandler}
|
|
133
133
|
loading={false}
|
|
@@ -145,7 +145,7 @@ describe("when a secondaryActions is passed in", () => {
|
|
|
145
145
|
/>,
|
|
146
146
|
);
|
|
147
147
|
fireEvent.press(getByLabelText("More"));
|
|
148
|
-
expect(
|
|
148
|
+
expect(await findByLabelText("hi")).toBeDefined();
|
|
149
149
|
fireEvent.press(getByLabelText("hi"));
|
|
150
150
|
expect(beforeSubmitMock).toHaveBeenCalled();
|
|
151
151
|
await waitFor(() => {
|
|
@@ -13,7 +13,7 @@ export function FormSaveButton({
|
|
|
13
13
|
setSecondaryActionLoading,
|
|
14
14
|
onOpenBottomSheet,
|
|
15
15
|
onCloseBottomSheet,
|
|
16
|
-
}: FormSaveButtonProps)
|
|
16
|
+
}: FormSaveButtonProps) {
|
|
17
17
|
const { t } = useAtlantisI18n();
|
|
18
18
|
const formContext = useFormContext();
|
|
19
19
|
const buttonActions = useButtonGroupAction(secondaryActions);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PropsWithChildren } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import { renderHook } from "@testing-library/react-
|
|
3
|
+
import { renderHook } from "@testing-library/react-native";
|
|
4
4
|
import type { AtlantisFormContextProps } from "./types";
|
|
5
5
|
import {
|
|
6
6
|
AtlantisFormContext,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { MutableRefObject } from "react";
|
|
2
|
-
import type { FieldValues, UseFormReturn } from "react-hook-form";
|
|
2
|
+
import type { DeepPartial, FieldValues, UseFormReturn } from "react-hook-form";
|
|
3
3
|
|
|
4
4
|
export interface UseConfirmBeforeBackProps {
|
|
5
5
|
alwaysPreventBack: boolean;
|
|
@@ -27,7 +27,8 @@ export interface AtlantisFormContextProps {
|
|
|
27
27
|
cacheKey?: string,
|
|
28
28
|
options?: LocalCacheOptions,
|
|
29
29
|
) => {
|
|
30
|
-
setLocalCache: (data: TData) => void;
|
|
30
|
+
setLocalCache: (data: DeepPartial<TData>) => void;
|
|
31
31
|
removeLocalCache: () => void;
|
|
32
32
|
};
|
|
33
|
+
edgeToEdgeEnabled?: boolean;
|
|
33
34
|
}
|
|
@@ -4,15 +4,14 @@ import type { View } from "react-native";
|
|
|
4
4
|
import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
5
5
|
|
|
6
6
|
interface UseFormViewRefsReturn {
|
|
7
|
-
readonly scrollViewRef: RefObject<KeyboardAwareScrollView>;
|
|
8
|
-
readonly bottomViewRef: RefObject<View>;
|
|
7
|
+
readonly scrollViewRef: RefObject<KeyboardAwareScrollView | null>;
|
|
8
|
+
readonly bottomViewRef: RefObject<View | null>;
|
|
9
9
|
readonly scrollToTop: () => void;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export function useFormViewRefs(): UseFormViewRefsReturn {
|
|
13
|
-
const scrollViewRef
|
|
14
|
-
|
|
15
|
-
const bottomViewRef: RefObject<View> = useRef<View>(null);
|
|
13
|
+
const scrollViewRef = useRef<KeyboardAwareScrollView>(null);
|
|
14
|
+
const bottomViewRef = useRef<View>(null);
|
|
16
15
|
const scrollToTop = useCallback(() => {
|
|
17
16
|
scrollViewRef.current?.scrollToPosition(0, 0);
|
|
18
17
|
}, [scrollViewRef]);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
DeepPartial,
|
|
2
3
|
FieldValues,
|
|
3
4
|
UseFormHandleSubmit,
|
|
4
5
|
UseFormReturn,
|
|
@@ -19,8 +20,9 @@ type UseInternalFormProps<T extends FieldValues, SubmitResponseType> = Pick<
|
|
|
19
20
|
| "localCacheKey"
|
|
20
21
|
| "localCacheExclude"
|
|
21
22
|
| "localCacheId"
|
|
23
|
+
| "UNSAFE_allowDiscardLocalCacheWhenOffline"
|
|
22
24
|
> & {
|
|
23
|
-
scrollViewRef?: RefObject<KeyboardAwareScrollView>;
|
|
25
|
+
scrollViewRef?: RefObject<KeyboardAwareScrollView | null>;
|
|
24
26
|
readonly saveButtonHeight: number;
|
|
25
27
|
readonly messageBannerHeight: number;
|
|
26
28
|
};
|
|
@@ -31,7 +33,7 @@ interface UseInternalForm<T extends FieldValues> {
|
|
|
31
33
|
readonly isSubmitting: boolean;
|
|
32
34
|
readonly isDirty: boolean;
|
|
33
35
|
readonly removeListenerRef: MutableRefObject<() => void>;
|
|
34
|
-
readonly setLocalCache: (data: T) => void;
|
|
36
|
+
readonly setLocalCache: (data: DeepPartial<T>) => void;
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
export function useInternalForm<T extends FieldValues, SubmitResponseType>({
|
|
@@ -44,6 +46,7 @@ export function useInternalForm<T extends FieldValues, SubmitResponseType>({
|
|
|
44
46
|
scrollViewRef,
|
|
45
47
|
saveButtonHeight,
|
|
46
48
|
messageBannerHeight,
|
|
49
|
+
UNSAFE_allowDiscardLocalCacheWhenOffline = false,
|
|
47
50
|
}: UseInternalFormProps<T, SubmitResponseType>): UseInternalForm<T> {
|
|
48
51
|
const { useConfirmBeforeBack, useInternalFormLocalCache } =
|
|
49
52
|
useAtlantisFormContext();
|
|
@@ -81,11 +84,16 @@ export function useInternalForm<T extends FieldValues, SubmitResponseType>({
|
|
|
81
84
|
};
|
|
82
85
|
}
|
|
83
86
|
|
|
87
|
+
const shouldRemoveCacheOnBack = UNSAFE_allowDiscardLocalCacheWhenOffline
|
|
88
|
+
? true
|
|
89
|
+
: isOnline;
|
|
90
|
+
|
|
84
91
|
const removeListenerRef = useConfirmBeforeBack({
|
|
85
92
|
alwaysPreventBack: isSubmitting,
|
|
86
93
|
shouldShowAlert: isDirty,
|
|
87
|
-
onAcceptEvent:
|
|
88
|
-
showLostProgressMessage:
|
|
94
|
+
onAcceptEvent: shouldRemoveCacheOnBack ? removeLocalCache : undefined,
|
|
95
|
+
showLostProgressMessage:
|
|
96
|
+
shouldRemoveCacheOnBack || !clientSideSaveOn ? true : false,
|
|
89
97
|
});
|
|
90
98
|
|
|
91
99
|
return {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { renderHook } from "@testing-library/react-
|
|
1
|
+
import { renderHook } from "@testing-library/react-native";
|
|
2
2
|
import { useScrollToError } from "./useScrollToError";
|
|
3
3
|
|
|
4
4
|
const mockFormState = {
|
|
@@ -25,6 +25,7 @@ jest.mock("../../../ErrorMessageWrapper", () => ({
|
|
|
25
25
|
el: {
|
|
26
26
|
measure: jest.fn((_, callback) => callback()),
|
|
27
27
|
hasErrorMessage: true,
|
|
28
|
+
accessibilityFocus: jest.fn(),
|
|
28
29
|
},
|
|
29
30
|
},
|
|
30
31
|
register: jest.fn(),
|
package/src/Form/types.ts
CHANGED
|
@@ -1,17 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ReactElement, RefObject } from "react";
|
|
2
2
|
import type {
|
|
3
3
|
ControllerProps,
|
|
4
|
-
|
|
4
|
+
DefaultValues,
|
|
5
5
|
FieldPath,
|
|
6
6
|
FieldValues,
|
|
7
7
|
Mode,
|
|
8
|
-
UnpackNestedValue,
|
|
9
8
|
UseFormReturn,
|
|
10
9
|
} from "react-hook-form";
|
|
11
10
|
import type { IconNames } from "@jobber/design";
|
|
12
11
|
import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
13
12
|
|
|
14
|
-
export type FormValues<T> =
|
|
13
|
+
export type FormValues<T> = T;
|
|
15
14
|
export type FormErrors = FormNetworkErrors | FormUserErrors;
|
|
16
15
|
export type FormBannerMessage = FormWarningMessage | FormNoticeMessage;
|
|
17
16
|
|
|
@@ -55,7 +54,7 @@ interface FormNoticeMessage {
|
|
|
55
54
|
|
|
56
55
|
export type FormRef<T extends FieldValues = FieldValues> =
|
|
57
56
|
| (UseFormReturn<T> & {
|
|
58
|
-
scrollViewRef?: RefObject<KeyboardAwareScrollView>;
|
|
57
|
+
scrollViewRef?: RefObject<KeyboardAwareScrollView | null>;
|
|
59
58
|
saveButtonHeight?: number;
|
|
60
59
|
messageBannerHeight?: number;
|
|
61
60
|
})
|
|
@@ -109,7 +108,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
|
|
|
109
108
|
* The initial values of the form inputs
|
|
110
109
|
* This should be available as soon as initialLoading is set to false
|
|
111
110
|
*/
|
|
112
|
-
initialValues?:
|
|
111
|
+
initialValues?: DefaultValues<T>;
|
|
113
112
|
|
|
114
113
|
/**
|
|
115
114
|
* When the validation should happen.
|
|
@@ -128,7 +127,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
|
|
|
128
127
|
/**
|
|
129
128
|
* ref object to access react hook form methods and state
|
|
130
129
|
*/
|
|
131
|
-
formRef?:
|
|
130
|
+
formRef?: RefObject<FormRef<T> | undefined>;
|
|
132
131
|
|
|
133
132
|
/**
|
|
134
133
|
* Label to be displayed for the save button
|
|
@@ -143,7 +142,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
|
|
|
143
142
|
onSubmit: () => void,
|
|
144
143
|
label: string | undefined,
|
|
145
144
|
isSubmitting: boolean,
|
|
146
|
-
) =>
|
|
145
|
+
) => ReactElement;
|
|
147
146
|
|
|
148
147
|
/**
|
|
149
148
|
* Adding a key will save a local copy of the form data that will be used to
|
|
@@ -172,6 +171,13 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
|
|
|
172
171
|
*/
|
|
173
172
|
localCacheId?: string | string[];
|
|
174
173
|
|
|
174
|
+
/**
|
|
175
|
+
* If true, the local cache will be removed when the user navigates away from
|
|
176
|
+
* the dirty form even when offline. By default, cache is only removed on back when online.
|
|
177
|
+
* Defaults to false.
|
|
178
|
+
*/
|
|
179
|
+
UNSAFE_allowDiscardLocalCacheWhenOffline?: boolean;
|
|
180
|
+
|
|
175
181
|
/**
|
|
176
182
|
* Secondary Action for ButtonGroup
|
|
177
183
|
*/
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import type { RenderAPI } from "@testing-library/react-native";
|
|
3
|
-
import { fireEvent, render } from "@testing-library/react-native";
|
|
4
|
-
import { Host } from "react-native-portalize";
|
|
3
|
+
import { fireEvent, render, waitFor } from "@testing-library/react-native";
|
|
5
4
|
import { Alert } from "react-native";
|
|
5
|
+
import { Host } from "react-native-portalize";
|
|
6
6
|
import type { File } from ".";
|
|
7
7
|
import { FormatFile } from ".";
|
|
8
8
|
import {
|
|
@@ -117,12 +117,12 @@ function basicRenderTestWithValue() {
|
|
|
117
117
|
);
|
|
118
118
|
});
|
|
119
119
|
|
|
120
|
-
it("renders ProgressBar state advancing with the upload percentage", () => {
|
|
120
|
+
it("renders ProgressBar state advancing with the upload percentage", async () => {
|
|
121
121
|
jest.useFakeTimers();
|
|
122
122
|
const { getByTestId } = renderFormatFile(file);
|
|
123
123
|
jest.advanceTimersByTime(progressBarAnimationTime);
|
|
124
|
-
const formatFileInnerProgressBar =
|
|
125
|
-
"format-file-inner-progress-bar",
|
|
124
|
+
const formatFileInnerProgressBar = await waitFor(() =>
|
|
125
|
+
getByTestId("format-file-inner-progress-bar"),
|
|
126
126
|
);
|
|
127
127
|
const innerProgressBarWidth = parseInt(
|
|
128
128
|
formatFileInnerProgressBar.props.style.width,
|
|
@@ -210,59 +210,59 @@ function basicRenderTestWithValue() {
|
|
|
210
210
|
jest.advanceTimersByTime(progressBarAnimationTime);
|
|
211
211
|
});
|
|
212
212
|
|
|
213
|
-
it("shows a BottomSheet with a remove option when tapped", () => {
|
|
214
|
-
const { getByTestId,
|
|
213
|
+
it("shows a BottomSheet with a remove option when tapped", async () => {
|
|
214
|
+
const { getByTestId, findByLabelText } = tree;
|
|
215
215
|
fireEvent.press(getByTestId(testId));
|
|
216
|
-
expect(
|
|
216
|
+
expect(await findByLabelText(removeLabel)).toBeDefined();
|
|
217
217
|
});
|
|
218
218
|
|
|
219
219
|
describe("when the BottomSheet remove option is tapped", () => {
|
|
220
|
-
it("calls the onRemove action", () => {
|
|
221
|
-
const { getByTestId,
|
|
220
|
+
it("calls the onRemove action", async () => {
|
|
221
|
+
const { getByTestId, findByLabelText } = tree;
|
|
222
222
|
fireEvent.press(getByTestId(testId));
|
|
223
|
-
fireEvent.press(
|
|
223
|
+
fireEvent.press(await findByLabelText(removeLabel));
|
|
224
224
|
expect(onRemove).toHaveBeenCalledTimes(1);
|
|
225
225
|
});
|
|
226
226
|
});
|
|
227
227
|
|
|
228
228
|
it("creates a thumbnail when a media file is used", () => {
|
|
229
|
-
const expectedCalls = testId.includes("image") ?
|
|
229
|
+
const expectedCalls = testId.includes("image") ? 1 : 0;
|
|
230
230
|
expect(mockCreateThumbnail).toHaveBeenCalledTimes(expectedCalls);
|
|
231
231
|
});
|
|
232
232
|
},
|
|
233
233
|
);
|
|
234
234
|
|
|
235
235
|
describe("when the preview option is tapped", () => {
|
|
236
|
-
it("calls onPreview with a valid image", () => {
|
|
236
|
+
it("calls onPreview with a valid image", async () => {
|
|
237
237
|
const previewLabel = "Preview image";
|
|
238
|
-
const { getByTestId,
|
|
238
|
+
const { getByTestId, findByLabelText } = renderFormatFile(
|
|
239
239
|
FILE_UPLOAD_MOCK_IMAGE({ progress: 1, status: StatusCode.Completed }),
|
|
240
240
|
"image",
|
|
241
241
|
);
|
|
242
242
|
fireEvent.press(getByTestId("test-image"));
|
|
243
|
-
fireEvent.press(
|
|
243
|
+
fireEvent.press(await findByLabelText(previewLabel));
|
|
244
244
|
expect(mockOnPreview).toHaveBeenCalledTimes(1);
|
|
245
245
|
});
|
|
246
246
|
|
|
247
|
-
it("calls onPreview with a valid pdf file", () => {
|
|
247
|
+
it("calls onPreview with a valid pdf file", async () => {
|
|
248
248
|
const previewLabel = "Preview file";
|
|
249
|
-
const { getByTestId,
|
|
249
|
+
const { getByTestId, findByLabelText } = renderFormatFile(
|
|
250
250
|
FILE_UPLOAD_MOCK_PDF({ progress: 1, status: StatusCode.Completed }),
|
|
251
251
|
"file",
|
|
252
252
|
);
|
|
253
253
|
fireEvent.press(getByTestId("test-file"));
|
|
254
|
-
fireEvent.press(
|
|
254
|
+
fireEvent.press(await findByLabelText(previewLabel));
|
|
255
255
|
expect(mockOnPreview).toHaveBeenCalledTimes(1);
|
|
256
256
|
});
|
|
257
257
|
|
|
258
|
-
it("calls onPreview with a valid external PDF file", () => {
|
|
258
|
+
it("calls onPreview with a valid external PDF file", async () => {
|
|
259
259
|
const previewLabel = "Preview file";
|
|
260
|
-
const { getByTestId,
|
|
260
|
+
const { getByTestId, findByLabelText } = renderFormatFile(
|
|
261
261
|
FILE_MOCK_PDF,
|
|
262
262
|
"file",
|
|
263
263
|
);
|
|
264
264
|
fireEvent.press(getByTestId("test-file"));
|
|
265
|
-
fireEvent.press(
|
|
265
|
+
fireEvent.press(await findByLabelText(previewLabel));
|
|
266
266
|
expect(mockOnPreview).toHaveBeenCalledTimes(1);
|
|
267
267
|
});
|
|
268
268
|
|
|
@@ -88,7 +88,7 @@ function FormatFileContent({
|
|
|
88
88
|
styleInGrid,
|
|
89
89
|
onUploadComplete,
|
|
90
90
|
isMedia,
|
|
91
|
-
}: FormatFileContentProps)
|
|
91
|
+
}: FormatFileContentProps) {
|
|
92
92
|
const styles = useStyles();
|
|
93
93
|
|
|
94
94
|
return (
|
|
@@ -204,7 +204,7 @@ export function FormatFile<T extends File | FileUpload>({
|
|
|
204
204
|
showFileTypeIndicator = true,
|
|
205
205
|
createThumbnail,
|
|
206
206
|
onPreviewPress,
|
|
207
|
-
}: FormatFileProps<T>)
|
|
207
|
+
}: FormatFileProps<T>) {
|
|
208
208
|
const onTapModified = onTap ? () => onTap(file) : () => undefined;
|
|
209
209
|
|
|
210
210
|
const formattedFile = parseFile(file, showFileTypeIndicator);
|
|
@@ -236,7 +236,7 @@ function FormatFileInternal({
|
|
|
236
236
|
onPreviewPress,
|
|
237
237
|
testID,
|
|
238
238
|
createThumbnail: createThumbnailProp,
|
|
239
|
-
}: FormatFileInternalProps)
|
|
239
|
+
}: FormatFileInternalProps) {
|
|
240
240
|
const [showOverlay, setShowOverlay] = useState<boolean>(
|
|
241
241
|
file.status !== StatusCode.Completed,
|
|
242
242
|
);
|
|
@@ -39,11 +39,11 @@ const basicRenderTestWithValue = () => {
|
|
|
39
39
|
const removeLabel = `Remove ${bottomSheetOptionsSuffix}`;
|
|
40
40
|
let tree: RenderAPI;
|
|
41
41
|
|
|
42
|
-
beforeEach(() => {
|
|
42
|
+
beforeEach(async () => {
|
|
43
43
|
tree = renderBottomSheet(
|
|
44
44
|
bottomSheetOptionsSuffix as BottomSheetOptionsSuffix,
|
|
45
45
|
);
|
|
46
|
-
act(() => {
|
|
46
|
+
await act(async () => {
|
|
47
47
|
bottomSheetRef.current?.open();
|
|
48
48
|
});
|
|
49
49
|
});
|
|
@@ -52,29 +52,29 @@ const basicRenderTestWithValue = () => {
|
|
|
52
52
|
});
|
|
53
53
|
|
|
54
54
|
describe("onPreviewPress", () => {
|
|
55
|
-
it("renders the preview option", () => {
|
|
56
|
-
const {
|
|
55
|
+
it("renders the preview option", async () => {
|
|
56
|
+
const { findByLabelText } = tree;
|
|
57
57
|
|
|
58
|
-
expect(
|
|
58
|
+
expect(await findByLabelText(previewLabel)).toBeDefined();
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
it("is called when pressed", () => {
|
|
62
|
-
const {
|
|
63
|
-
fireEvent.press(
|
|
61
|
+
it("is called when pressed", async () => {
|
|
62
|
+
const { findByLabelText } = tree;
|
|
63
|
+
fireEvent.press(await findByLabelText(previewLabel));
|
|
64
64
|
expect(onPreview).toHaveBeenCalledTimes(1);
|
|
65
65
|
});
|
|
66
66
|
});
|
|
67
67
|
|
|
68
68
|
describe("onRemovePress", () => {
|
|
69
|
-
it("renders the remove option", () => {
|
|
70
|
-
const {
|
|
69
|
+
it("renders the remove option", async () => {
|
|
70
|
+
const { findByLabelText } = tree;
|
|
71
71
|
|
|
72
|
-
expect(
|
|
72
|
+
expect(await findByLabelText(removeLabel)).toBeDefined();
|
|
73
73
|
});
|
|
74
74
|
|
|
75
|
-
it("is called when pressed", () => {
|
|
76
|
-
const {
|
|
77
|
-
fireEvent.press(
|
|
75
|
+
it("is called when pressed", async () => {
|
|
76
|
+
const { findByLabelText } = tree;
|
|
77
|
+
fireEvent.press(await findByLabelText(removeLabel));
|
|
78
78
|
|
|
79
79
|
expect(onRemove).toHaveBeenCalledTimes(1);
|
|
80
80
|
});
|
|
@@ -9,7 +9,7 @@ import { useAtlantisI18n } from "../../../hooks/useAtlantisI18n";
|
|
|
9
9
|
export type BottomSheetOptionsSuffix = "receipt" | "image" | "file" | "video";
|
|
10
10
|
|
|
11
11
|
interface FormatFileBottomSheetProps {
|
|
12
|
-
readonly bottomSheetRef: RefObject<BottomSheetRef>;
|
|
12
|
+
readonly bottomSheetRef: RefObject<BottomSheetRef | null>;
|
|
13
13
|
readonly onPreviewPress?: () => void;
|
|
14
14
|
readonly onRemovePress?: () => void;
|
|
15
15
|
readonly bottomSheetOptionsSuffix?: BottomSheetOptionsSuffix;
|
|
@@ -20,7 +20,7 @@ export const FormatFileBottomSheet = ({
|
|
|
20
20
|
onPreviewPress,
|
|
21
21
|
onRemovePress,
|
|
22
22
|
bottomSheetOptionsSuffix,
|
|
23
|
-
}: FormatFileBottomSheetProps)
|
|
23
|
+
}: FormatFileBottomSheetProps) => {
|
|
24
24
|
const { t } = useAtlantisI18n();
|
|
25
25
|
|
|
26
26
|
const handlePress = (onPressAction: () => void) => {
|