@jobber/components-native 0.84.3 → 0.84.4-CLEANUPre-6d043f4.28
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 +24 -15
- package/dist/src/Banner/Banner.js +2 -0
- package/dist/src/Banner/components/BannerIcon/BannerIcon.style.js +3 -0
- package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +0 -1
- package/dist/src/Form/components/FormCache/FormCache.js +1 -0
- package/dist/src/FormatFile/utils/createUseCreateThumbnail.js +1 -1
- package/dist/src/InputCurrency/InputCurrency.js +42 -30
- package/dist/src/InputEmail/InputEmail.js +12 -4
- package/dist/src/InputFieldWrapper/InputFieldWrapper.style.js +1 -1
- package/dist/src/InputNumber/InputNumber.js +10 -4
- package/dist/src/InputSearch/InputSearch.js +1 -1
- package/dist/src/InputText/InputText.js +1 -0
- 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/Banner/components/BannerIcon/BannerIcon.style.d.ts +3 -0
- package/dist/types/src/Banner/types.d.ts +1 -1
- package/dist/types/src/Form/components/FormCache/FormCache.d.ts +2 -2
- package/dist/types/src/Form/context/types.d.ts +2 -2
- package/dist/types/src/Form/hooks/useInternalForm.d.ts +2 -2
- package/dist/types/src/Form/types.d.ts +3 -3
- package/dist/types/src/InputFieldWrapper/InputFieldWrapper.style.d.ts +1 -1
- package/package.json +24 -15
- package/src/AtlantisContext/AtlantisContext.test.tsx +1 -1
- package/src/AutoLink/AutoLink.test.tsx +2 -4
- package/src/Banner/Banner.test.tsx +12 -0
- package/src/Banner/Banner.tsx +2 -0
- package/src/Banner/components/BannerIcon/BannerIcon.style.ts +3 -0
- package/src/Banner/types.ts +1 -1
- package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +0 -1
- package/src/Checkbox/CheckboxGroup.test.tsx +2 -6
- package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +1 -1
- package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +1 -1
- package/src/EmptyState/EmptyState.test.tsx +29 -42
- package/src/Form/components/FormCache/FormCache.tsx +4 -3
- package/src/Form/components/FormMessage/FormMessage.test.tsx +40 -27
- package/src/Form/context/AtlantisFormContext.test.tsx +1 -1
- package/src/Form/context/types.ts +2 -2
- package/src/Form/hooks/useInternalForm.ts +2 -1
- package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +2 -1
- package/src/Form/types.ts +3 -4
- package/src/FormatFile/FormatFile.test.tsx +6 -6
- package/src/FormatFile/utils/createUseCreateThumbnail.ts +1 -1
- package/src/Icon/__snapshots__/Icon.test.tsx.snap +7 -0
- package/src/InputCurrency/InputCurrency.tsx +71 -57
- package/src/InputEmail/InputEmail.tsx +15 -8
- package/src/InputFieldWrapper/InputFieldWrapper.style.ts +1 -1
- package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +5 -11
- package/src/InputNumber/InputNumber.tsx +11 -7
- package/src/InputSearch/InputSearch.tsx +1 -1
- package/src/InputText/InputText.tsx +1 -0
- package/src/ThumbnailList/ThumbnailList.test.tsx +5 -5
- 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/dist/tsconfig.tsbuildinfo +0 -1
package/dist/tsconfig.json
CHANGED
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
"declarationDir": "./dist/types",
|
|
9
9
|
"resolveJsonModule": true,
|
|
10
10
|
"paths": {
|
|
11
|
+
"@jobber/hooks": [
|
|
12
|
+
"../hooks/src/index.ts"
|
|
13
|
+
],
|
|
11
14
|
"@jobber/hooks/*": [
|
|
12
|
-
"
|
|
15
|
+
"../hooks/src/*"
|
|
13
16
|
]
|
|
14
17
|
},
|
|
15
18
|
"types": [
|
|
@@ -32,10 +35,5 @@
|
|
|
32
35
|
"**/*.stories.tsx",
|
|
33
36
|
"**/*.test.ts",
|
|
34
37
|
"**/*.test.tsx",
|
|
35
|
-
],
|
|
36
|
-
"references": [
|
|
37
|
-
{
|
|
38
|
-
"path": "../hooks"
|
|
39
|
-
}
|
|
40
38
|
]
|
|
41
39
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { IconNames } from "@jobber/design";
|
|
2
2
|
import type { ReactElement } from "react";
|
|
3
3
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
4
|
-
export type BannerTypes = "error" | "warning" | "notice";
|
|
4
|
+
export type BannerTypes = "error" | "warning" | "notice" | "success";
|
|
5
5
|
export interface BannerStyleProps {
|
|
6
6
|
/**
|
|
7
7
|
* Styles applied to the main view of the banner. Styles are grabbed from Banner.style.ts file
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import type { FieldValues } from "react-hook-form";
|
|
1
|
+
import type { DeepPartial, FieldValues } from "react-hook-form";
|
|
2
2
|
interface FormCacheProps<T extends FieldValues> {
|
|
3
3
|
readonly localCacheId?: string | string[];
|
|
4
4
|
readonly localCacheKey?: string;
|
|
5
5
|
readonly localCacheExclude?: string[];
|
|
6
|
-
readonly setLocalCache: (data: T) => void;
|
|
6
|
+
readonly setLocalCache: (data: DeepPartial<T>) => void;
|
|
7
7
|
}
|
|
8
8
|
export declare function FormCache<T extends FieldValues>({ localCacheExclude, localCacheKey, setLocalCache, }: FormCacheProps<T>): JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -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
|
export interface UseConfirmBeforeBackProps {
|
|
4
4
|
alwaysPreventBack: boolean;
|
|
5
5
|
onAcceptEvent?: () => void;
|
|
@@ -18,7 +18,7 @@ interface LocalCacheOptions {
|
|
|
18
18
|
export interface AtlantisFormContextProps {
|
|
19
19
|
useConfirmBeforeBack: (props: UseConfirmBeforeBackProps) => MutableRefObject<() => void>;
|
|
20
20
|
useInternalFormLocalCache: <TData extends FieldValues>(formMethods: UseFormReturn<TData>, cacheKey?: string, options?: LocalCacheOptions) => {
|
|
21
|
-
setLocalCache: (data: TData) => void;
|
|
21
|
+
setLocalCache: (data: DeepPartial<TData>) => void;
|
|
22
22
|
removeLocalCache: () => void;
|
|
23
23
|
};
|
|
24
24
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FieldValues, UseFormHandleSubmit, UseFormReturn } from "react-hook-form";
|
|
1
|
+
import type { DeepPartial, FieldValues, UseFormHandleSubmit, UseFormReturn } from "react-hook-form";
|
|
2
2
|
import type { MutableRefObject, RefObject } from "react";
|
|
3
3
|
import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
4
4
|
import type { InternalFormProps } from "../types";
|
|
@@ -13,7 +13,7 @@ interface UseInternalForm<T extends FieldValues> {
|
|
|
13
13
|
readonly isSubmitting: boolean;
|
|
14
14
|
readonly isDirty: boolean;
|
|
15
15
|
readonly removeListenerRef: MutableRefObject<() => void>;
|
|
16
|
-
readonly setLocalCache: (data: T) => void;
|
|
16
|
+
readonly setLocalCache: (data: DeepPartial<T>) => void;
|
|
17
17
|
}
|
|
18
18
|
export declare function useInternalForm<T extends FieldValues, SubmitResponseType>({ mode, reValidateMode, initialValues, formRef, localCacheKey, localCacheId, scrollViewRef, saveButtonHeight, messageBannerHeight, }: UseInternalFormProps<T, SubmitResponseType>): UseInternalForm<T>;
|
|
19
19
|
export {};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { MutableRefObject, RefObject } from "react";
|
|
2
|
-
import type { ControllerProps,
|
|
2
|
+
import type { ControllerProps, DefaultValues, FieldPath, FieldValues, Mode, UseFormReturn } from "react-hook-form";
|
|
3
3
|
import type { IconNames } from "@jobber/design";
|
|
4
4
|
import type { KeyboardAwareScrollView } from "react-native-keyboard-aware-scroll-view";
|
|
5
|
-
export type FormValues<T> =
|
|
5
|
+
export type FormValues<T> = T;
|
|
6
6
|
export type FormErrors = FormNetworkErrors | FormUserErrors;
|
|
7
7
|
export type FormBannerMessage = FormWarningMessage | FormNoticeMessage;
|
|
8
8
|
export declare enum FormSubmitErrorType {
|
|
@@ -81,7 +81,7 @@ export interface FormProps<T extends FieldValues, SubmitResponseType> {
|
|
|
81
81
|
* The initial values of the form inputs
|
|
82
82
|
* This should be available as soon as initialLoading is set to false
|
|
83
83
|
*/
|
|
84
|
-
initialValues?:
|
|
84
|
+
initialValues?: DefaultValues<T>;
|
|
85
85
|
/**
|
|
86
86
|
* When the validation should happen.
|
|
87
87
|
* Possible values are "onBlur", "onChange", "onSubmit", "onTouched", and "all".
|
|
@@ -23,6 +23,7 @@ export declare const useStyles: () => {
|
|
|
23
23
|
right: number;
|
|
24
24
|
bottom: number;
|
|
25
25
|
left: number;
|
|
26
|
+
zIndex: number;
|
|
26
27
|
};
|
|
27
28
|
miniLabel: {
|
|
28
29
|
top: number;
|
|
@@ -30,7 +31,6 @@ export declare const useStyles: () => {
|
|
|
30
31
|
backgroundColor: string;
|
|
31
32
|
marginRight: number;
|
|
32
33
|
maxHeight: number;
|
|
33
|
-
zIndex: number;
|
|
34
34
|
};
|
|
35
35
|
miniLabelShowClearAction: {
|
|
36
36
|
backgroundColor: string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.84.
|
|
3
|
+
"version": "0.84.4-CLEANUPre-6d043f4.28+6d043f490",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -32,10 +32,10 @@
|
|
|
32
32
|
"build": "npm run build:clean && npm run compile",
|
|
33
33
|
"bootstrap": "npm run build",
|
|
34
34
|
"prepack": "npm run build",
|
|
35
|
-
"compile": "tsc -
|
|
35
|
+
"compile": "tsc -p tsconfig.build.json",
|
|
36
36
|
"build:clean": "rm -rf ./dist",
|
|
37
37
|
"storybook": "storybook dev -p 6008 --disable-telemetry",
|
|
38
|
-
"build
|
|
38
|
+
"storybook:build": "storybook build --disable-telemetry"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@react-native-clipboard/clipboard": "^1.11.2",
|
|
@@ -43,8 +43,8 @@
|
|
|
43
43
|
"autolinker": "^4.0.0",
|
|
44
44
|
"deepmerge": "^4.2.2",
|
|
45
45
|
"lodash": "^4.17.21",
|
|
46
|
-
"react-hook-form": "^7.
|
|
47
|
-
"react-intl": "^
|
|
46
|
+
"react-hook-form": "^7.52.0",
|
|
47
|
+
"react-intl": "^7.1.11",
|
|
48
48
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
49
49
|
"react-native-modalize": "^2.0.13",
|
|
50
50
|
"react-native-portalize": "^1.0.7",
|
|
@@ -53,18 +53,27 @@
|
|
|
53
53
|
"ts-xor": "^1.1.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
+
"@react-native-community/datetimepicker": "^8.4.5",
|
|
57
|
+
"@react-native/babel-preset": "^0.81.1",
|
|
56
58
|
"@storybook/addon-a11y": "^9.1.2",
|
|
57
59
|
"@storybook/react": "^9.1.2",
|
|
58
60
|
"@storybook/react-native-web-vite": "^9.1.2",
|
|
59
|
-
"@testing-library/
|
|
60
|
-
"@testing-library/react-native": "^12.0.1",
|
|
61
|
+
"@testing-library/react-native": "^13.3.3",
|
|
61
62
|
"@types/lodash.chunk": "^4.2.7",
|
|
62
63
|
"@types/lodash.debounce": "^4.0.7",
|
|
63
64
|
"@types/lodash.identity": "^3.0.7",
|
|
64
|
-
"@types/react": "^18.0.28",
|
|
65
65
|
"@types/react-native-uuid": "^1.4.0",
|
|
66
|
-
"
|
|
67
|
-
"
|
|
66
|
+
"@types/react-test-renderer": "19.1.0",
|
|
67
|
+
"date-fns": "^2.30.0",
|
|
68
|
+
"date-fns-tz": "^2.0.0",
|
|
69
|
+
"react-native": "^0.81.4",
|
|
70
|
+
"react-native-gesture-handler": "^2.28.0",
|
|
71
|
+
"react-native-modal-datetime-picker": "^18.0.0",
|
|
72
|
+
"react-native-reanimated": "^3.7.1",
|
|
73
|
+
"react-native-safe-area-context": "^5.4.0",
|
|
74
|
+
"react-native-svg": "^15.1.0",
|
|
75
|
+
"react-native-web": "^0.20.0",
|
|
76
|
+
"react-test-renderer": "19.1.0",
|
|
68
77
|
"storybook": "^9.1.2"
|
|
69
78
|
},
|
|
70
79
|
"peerDependencies": {
|
|
@@ -73,10 +82,10 @@
|
|
|
73
82
|
"@react-native-community/datetimepicker": ">=6.7.0",
|
|
74
83
|
"date-fns": "^2.30.0",
|
|
75
84
|
"date-fns-tz": "^2.0.0",
|
|
76
|
-
"react": "^18.
|
|
77
|
-
"react-intl": "^6
|
|
78
|
-
"react-native": ">=0.
|
|
79
|
-
"react-native-gesture-handler": ">=2.
|
|
85
|
+
"react": "^18 || ^19.1.0",
|
|
86
|
+
"react-intl": "^6 || ^7",
|
|
87
|
+
"react-native": ">=0.79.5",
|
|
88
|
+
"react-native-gesture-handler": ">=2.22.0",
|
|
80
89
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
81
90
|
"react-native-modal-datetime-picker": " >=13.0.0",
|
|
82
91
|
"react-native-modalize": "^2.0.13",
|
|
@@ -85,5 +94,5 @@
|
|
|
85
94
|
"react-native-safe-area-context": "^5.4.0",
|
|
86
95
|
"react-native-svg": ">=12.0.0"
|
|
87
96
|
},
|
|
88
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "6d043f4908d39d779d91ffa9fe2e84418734665c"
|
|
89
98
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
2
2
|
import type { PropsWithChildren } from "react";
|
|
3
3
|
import React from "react";
|
|
4
|
-
import { renderHook } from "@testing-library/react-
|
|
4
|
+
import { renderHook } from "@testing-library/react-native";
|
|
5
5
|
import type { AtlantisContextProps } from "./AtlantisContext";
|
|
6
6
|
import {
|
|
7
7
|
AtlantisContext,
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { fireEvent, render } from "@testing-library/react-native";
|
|
3
|
+
import { Linking } from "react-native";
|
|
3
4
|
import { copyTextToClipboard } from "./clipboard";
|
|
4
5
|
import { AutoLink } from "./AutoLink";
|
|
5
6
|
|
|
6
|
-
const mockOpenUrl = jest.
|
|
7
|
-
jest.mock("react-native/Libraries/Linking/Linking", () => ({
|
|
8
|
-
openURL: mockOpenUrl,
|
|
9
|
-
}));
|
|
7
|
+
const mockOpenUrl = jest.spyOn(Linking, "openURL").mockImplementation();
|
|
10
8
|
|
|
11
9
|
jest.mock("./clipboard", () => {
|
|
12
10
|
return {
|
|
@@ -35,6 +35,18 @@ describe("Banner", () => {
|
|
|
35
35
|
expect(getByText("Notice me")).toBeDefined();
|
|
36
36
|
expect(icon.props.children.props.name).toBe("starburst");
|
|
37
37
|
});
|
|
38
|
+
|
|
39
|
+
it("renders a success Banner", () => {
|
|
40
|
+
const { getByText, getByTestId } = render(
|
|
41
|
+
<Banner type="success">
|
|
42
|
+
<Text>Your import is complete</Text>
|
|
43
|
+
</Banner>,
|
|
44
|
+
);
|
|
45
|
+
|
|
46
|
+
const icon = getByTestId("ATL-Banner-Icon");
|
|
47
|
+
expect(getByText("Your import is complete")).toBeDefined();
|
|
48
|
+
expect(icon.props.children.props.name).toBe("checkmark");
|
|
49
|
+
});
|
|
38
50
|
});
|
|
39
51
|
|
|
40
52
|
describe("Children", () => {
|
package/src/Banner/Banner.tsx
CHANGED
package/src/Banner/types.ts
CHANGED
|
@@ -2,7 +2,7 @@ import type { IconNames } from "@jobber/design";
|
|
|
2
2
|
import type { ReactElement } from "react";
|
|
3
3
|
import type { StyleProp, ViewStyle } from "react-native";
|
|
4
4
|
|
|
5
|
-
export type BannerTypes = "error" | "warning" | "notice";
|
|
5
|
+
export type BannerTypes = "error" | "warning" | "notice" | "success";
|
|
6
6
|
|
|
7
7
|
export interface BannerStyleProps {
|
|
8
8
|
/**
|
|
@@ -23,7 +23,6 @@ const leftOffset = -1 * offset;
|
|
|
23
23
|
|
|
24
24
|
// looks like deprecation for FlatList in reanimated is cascading down to other exports
|
|
25
25
|
// This is not createAnimatedComponent(FlatList), we are fine
|
|
26
|
-
// eslint-disable-next-line import/no-deprecated
|
|
27
26
|
const AnimatedImage = Animated.createAnimatedComponent(ImageBackground);
|
|
28
27
|
|
|
29
28
|
function InternalButtonLoadingInternal({
|
|
@@ -172,12 +172,8 @@ describe("when the parent checkbox does not have a label", () => {
|
|
|
172
172
|
it("does not render the parent checkbox", async () => {
|
|
173
173
|
const { checkboxGroup } = setup(undefined);
|
|
174
174
|
|
|
175
|
-
const
|
|
176
|
-
|
|
177
|
-
};
|
|
178
|
-
expect(findParentCheckbox).toThrow(
|
|
179
|
-
"Unable to find an element with accessibilityLabel: all condiments",
|
|
180
|
-
);
|
|
175
|
+
const parentCheckbox = checkboxGroup.queryByLabelText(parentCheckboxLabel);
|
|
176
|
+
expect(parentCheckbox).toBeNull();
|
|
181
177
|
});
|
|
182
178
|
});
|
|
183
179
|
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { act, renderHook } from "@testing-library/react-
|
|
1
|
+
import { act, renderHook } from "@testing-library/react-native";
|
|
2
2
|
import type { KeyboardEvent } from "react-native";
|
|
3
3
|
import { DeviceEventEmitter } from "react-native";
|
|
4
4
|
import { useKeyboardVisibility } from "./useKeyboardVisibility";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { fireEvent, render } from "@testing-library/react-native";
|
|
2
|
+
import { fireEvent, render, screen } from "@testing-library/react-native";
|
|
3
|
+
import { Path } from "react-native-svg";
|
|
3
4
|
import type { EmptyStateProps } from "./EmptyState";
|
|
4
5
|
import { EmptyState } from "./EmptyState";
|
|
5
|
-
import * as IconComponent from "../Icon/Icon";
|
|
6
6
|
|
|
7
7
|
const primaryOnPress = jest.fn();
|
|
8
8
|
const secondaryOnPress = jest.fn();
|
|
@@ -27,83 +27,70 @@ const component = (overrideProps?: Partial<EmptyStateProps>) => {
|
|
|
27
27
|
...overrideProps,
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
render(<EmptyState {...props} />);
|
|
31
31
|
};
|
|
32
32
|
|
|
33
|
-
const iconSpy = jest.spyOn(IconComponent, "Icon");
|
|
34
|
-
|
|
35
|
-
afterEach(() => jest.clearAllMocks());
|
|
36
|
-
|
|
37
33
|
describe("EmptyState", () => {
|
|
38
34
|
it("renders the title", () => {
|
|
39
|
-
|
|
35
|
+
component();
|
|
40
36
|
|
|
41
|
-
expect(getByText(defaultProps.title)).toBeDefined();
|
|
37
|
+
expect(screen.getByText(defaultProps.title)).toBeDefined();
|
|
42
38
|
});
|
|
43
39
|
|
|
44
40
|
it("renders the description", () => {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
expect(getByText(defaultProps.description)).toBeDefined();
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
it("renders the icon", () => {
|
|
51
|
-
const { getByTestId } = component();
|
|
41
|
+
component();
|
|
52
42
|
|
|
53
|
-
expect(
|
|
43
|
+
expect(screen.getByText(defaultProps.description)).toBeDefined();
|
|
54
44
|
});
|
|
55
45
|
|
|
56
|
-
it("
|
|
46
|
+
it("renders the icon with default color and large size", () => {
|
|
57
47
|
component();
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
48
|
+
const icon = screen.getByTestId(defaultProps.icon);
|
|
49
|
+
const path = icon.findByType(Path);
|
|
50
|
+
expect(path.props.fill).toBe("hsl(197, 90%, 12%)");
|
|
51
|
+
expect(icon.props.style).toEqual(
|
|
52
|
+
expect.arrayContaining([
|
|
53
|
+
expect.objectContaining({
|
|
54
|
+
width: 32,
|
|
55
|
+
height: 32,
|
|
56
|
+
}),
|
|
57
|
+
]),
|
|
66
58
|
);
|
|
67
59
|
});
|
|
68
60
|
|
|
69
|
-
it("
|
|
70
|
-
component({ iconColor: "
|
|
61
|
+
it("renders the correct icon color when specified", async () => {
|
|
62
|
+
component({ iconColor: "warning" });
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
name: "link",
|
|
76
|
-
size: "large",
|
|
77
|
-
},
|
|
78
|
-
{},
|
|
79
|
-
);
|
|
64
|
+
const icon = screen.getByTestId(defaultProps.icon);
|
|
65
|
+
const pathElement = icon.findByType(Path);
|
|
66
|
+
expect(pathElement.props.fill).toBe("hsl(51, 64%, 49%)");
|
|
80
67
|
});
|
|
81
68
|
|
|
82
69
|
it("renders the primary action and allows users to interact with it by clicking", () => {
|
|
83
|
-
|
|
70
|
+
component();
|
|
84
71
|
|
|
85
|
-
const button = getByLabelText(defaultProps.primaryAction.label);
|
|
72
|
+
const button = screen.getByLabelText(defaultProps.primaryAction.label);
|
|
86
73
|
expect(button).toBeDefined();
|
|
87
74
|
fireEvent.press(button);
|
|
88
75
|
expect(primaryOnPress).toHaveBeenCalledTimes(1);
|
|
89
76
|
});
|
|
90
77
|
|
|
91
78
|
it("renders the secondary action and allows users to interact with it by clicking", () => {
|
|
92
|
-
|
|
79
|
+
component();
|
|
93
80
|
|
|
94
|
-
const button = getByLabelText(defaultProps.secondaryAction.label);
|
|
81
|
+
const button = screen.getByLabelText(defaultProps.secondaryAction.label);
|
|
95
82
|
expect(button).toBeDefined();
|
|
96
83
|
fireEvent.press(button);
|
|
97
84
|
expect(secondaryOnPress).toHaveBeenCalledTimes(1);
|
|
98
85
|
});
|
|
99
86
|
|
|
100
87
|
it("does render buttons if neither primary nor secondary action is passed in", () => {
|
|
101
|
-
|
|
88
|
+
component({
|
|
102
89
|
description: "No buttons",
|
|
103
90
|
primaryAction: undefined,
|
|
104
91
|
secondaryAction: undefined,
|
|
105
92
|
});
|
|
106
93
|
|
|
107
|
-
expect(queryAllByRole("button")).toHaveLength(0);
|
|
94
|
+
expect(screen.queryAllByRole("button")).toHaveLength(0);
|
|
108
95
|
});
|
|
109
96
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React, { useEffect, useMemo } from "react";
|
|
2
|
-
import type { FieldValues } from "react-hook-form";
|
|
2
|
+
import type { DeepPartial, FieldValues } from "react-hook-form";
|
|
3
3
|
import { useFormContext, useWatch } from "react-hook-form";
|
|
4
4
|
import omit from "lodash/omit";
|
|
5
5
|
|
|
@@ -7,7 +7,7 @@ interface FormCacheProps<T extends FieldValues> {
|
|
|
7
7
|
readonly localCacheId?: string | string[];
|
|
8
8
|
readonly localCacheKey?: string;
|
|
9
9
|
readonly localCacheExclude?: string[];
|
|
10
|
-
readonly setLocalCache: (data: T) => void;
|
|
10
|
+
readonly setLocalCache: (data: DeepPartial<T>) => void;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
export function FormCache<T extends FieldValues>({
|
|
@@ -18,7 +18,7 @@ export function FormCache<T extends FieldValues>({
|
|
|
18
18
|
const { control, formState } = useFormContext<T>();
|
|
19
19
|
const { isDirty } = formState;
|
|
20
20
|
|
|
21
|
-
const formData = useWatch
|
|
21
|
+
const formData = useWatch({ control });
|
|
22
22
|
const shouldExclude = useMemo(() => {
|
|
23
23
|
return Array.isArray(localCacheExclude) && localCacheExclude.length > 0;
|
|
24
24
|
}, [localCacheExclude]);
|
|
@@ -46,5 +46,6 @@ export function FormCache<T extends FieldValues>({
|
|
|
46
46
|
}
|
|
47
47
|
}, [formData, isDirty, localCacheExclude, setLocalCache, shouldExclude]);
|
|
48
48
|
|
|
49
|
+
// eslint-disable-next-line react/jsx-no-useless-fragment
|
|
49
50
|
return <></>;
|
|
50
51
|
}
|
|
@@ -1,30 +1,41 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
fireEvent,
|
|
4
|
+
render,
|
|
5
|
+
screen,
|
|
6
|
+
waitFor,
|
|
7
|
+
} from "@testing-library/react-native";
|
|
3
8
|
import { FormMessage } from ".";
|
|
4
9
|
|
|
5
10
|
describe("FormMessage", () => {
|
|
6
11
|
it("should render null when there are no message to show", () => {
|
|
7
|
-
|
|
8
|
-
expect(
|
|
12
|
+
render(<FormMessage />);
|
|
13
|
+
expect(screen.toJSON()).toMatchInlineSnapshot(`null`);
|
|
9
14
|
});
|
|
10
15
|
|
|
11
|
-
it("should show the message", () => {
|
|
12
|
-
|
|
16
|
+
it("should show the message", async () => {
|
|
17
|
+
render(<FormMessage />);
|
|
13
18
|
|
|
14
19
|
const description = "🔥";
|
|
15
20
|
FormMessage.show({ description });
|
|
16
|
-
|
|
21
|
+
await waitFor(() => {
|
|
22
|
+
expect(screen.getByText(description)).toBeDefined();
|
|
23
|
+
});
|
|
17
24
|
});
|
|
18
25
|
|
|
19
|
-
it("should close the message", () => {
|
|
20
|
-
|
|
26
|
+
it("should close the message", async () => {
|
|
27
|
+
render(<FormMessage />);
|
|
21
28
|
|
|
22
29
|
const description = "🌚";
|
|
23
30
|
FormMessage.show({ description });
|
|
24
|
-
|
|
31
|
+
await waitFor(() => {
|
|
32
|
+
expect(screen.getByText(description)).toBeDefined();
|
|
33
|
+
});
|
|
25
34
|
|
|
26
35
|
FormMessage.close();
|
|
27
|
-
|
|
36
|
+
await waitFor(() => {
|
|
37
|
+
expect(screen.queryByText(description)).toBeNull();
|
|
38
|
+
});
|
|
28
39
|
});
|
|
29
40
|
|
|
30
41
|
describe("Opening another message through a message", () => {
|
|
@@ -40,33 +51,35 @@ describe("FormMessage", () => {
|
|
|
40
51
|
},
|
|
41
52
|
});
|
|
42
53
|
|
|
43
|
-
it("should show the most recent message", () => {
|
|
44
|
-
|
|
45
|
-
<FormMessage />,
|
|
46
|
-
);
|
|
54
|
+
it("should show the most recent message", async () => {
|
|
55
|
+
render(<FormMessage />);
|
|
47
56
|
|
|
48
57
|
showMessage();
|
|
49
58
|
|
|
50
|
-
|
|
51
|
-
|
|
59
|
+
await waitFor(() => {
|
|
60
|
+
expect(screen.getByText(firstMessage)).toBeDefined();
|
|
61
|
+
});
|
|
62
|
+
expect(screen.queryByText(secondMessage)).toBeNull();
|
|
52
63
|
|
|
53
|
-
fireEvent.press(getByLabelText("Click me"));
|
|
64
|
+
fireEvent.press(screen.getByLabelText("Click me"));
|
|
54
65
|
|
|
55
|
-
expect(getByText(secondMessage)).toBeDefined();
|
|
56
|
-
expect(queryByText(firstMessage)).toBeNull();
|
|
66
|
+
expect(screen.getByText(secondMessage)).toBeDefined();
|
|
67
|
+
expect(screen.queryByText(firstMessage)).toBeNull();
|
|
57
68
|
});
|
|
58
69
|
|
|
59
|
-
it("should close the most recent message", () => {
|
|
60
|
-
|
|
61
|
-
<FormMessage />,
|
|
62
|
-
);
|
|
70
|
+
it("should close the most recent message", async () => {
|
|
71
|
+
render(<FormMessage />);
|
|
63
72
|
|
|
64
73
|
showMessage();
|
|
65
|
-
|
|
74
|
+
await waitFor(() => {
|
|
75
|
+
expect(screen.getByText("Click me")).toBeDefined();
|
|
76
|
+
});
|
|
77
|
+
fireEvent.press(screen.getByLabelText("Click me"));
|
|
66
78
|
FormMessage.close();
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
79
|
+
await waitFor(() => {
|
|
80
|
+
expect(screen.getByText(firstMessage)).toBeDefined();
|
|
81
|
+
});
|
|
82
|
+
expect(screen.queryByText(secondMessage)).toBeNull();
|
|
70
83
|
});
|
|
71
84
|
});
|
|
72
85
|
});
|
|
@@ -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,7 @@ 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
33
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
DeepPartial,
|
|
2
3
|
FieldValues,
|
|
3
4
|
UseFormHandleSubmit,
|
|
4
5
|
UseFormReturn,
|
|
@@ -31,7 +32,7 @@ interface UseInternalForm<T extends FieldValues> {
|
|
|
31
32
|
readonly isSubmitting: boolean;
|
|
32
33
|
readonly isDirty: boolean;
|
|
33
34
|
readonly removeListenerRef: MutableRefObject<() => void>;
|
|
34
|
-
readonly setLocalCache: (data: T) => void;
|
|
35
|
+
readonly setLocalCache: (data: DeepPartial<T>) => void;
|
|
35
36
|
}
|
|
36
37
|
|
|
37
38
|
export function useInternalForm<T extends FieldValues, SubmitResponseType>({
|
|
@@ -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(),
|