@jobber/components-native 0.46.0 → 0.46.2
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 +3 -3
- package/dist/src/AtlantisContext/AtlantisContext.js +2 -2
- package/dist/src/Form/context/AtlantisFormContext.js +2 -2
- package/dist/src/InputText/context/InputAccessoriesContext.js +2 -2
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/AtlantisContext/AtlantisContext.d.ts +1 -1
- package/dist/types/src/Form/context/AtlantisFormContext.d.ts +1 -1
- package/package.json +3 -3
- package/src/AtlantisContext/AtlantisContext.test.tsx +3 -2
- package/src/AtlantisContext/AtlantisContext.tsx +2 -2
- package/src/ButtonGroup/ButtonGroup.test.tsx +2 -2
- package/src/Form/Form.test.tsx +2 -2
- package/src/Form/components/FormErrorBanner/FormErrorBanner.test.tsx +2 -2
- package/src/Form/context/AtlantisFormContext.test.tsx +2 -3
- package/src/Form/context/AtlantisFormContext.tsx +4 -3
- package/src/InputCurrency/InputCurrency.test.tsx +2 -2
- package/src/InputDate/InputDate.test.tsx +4 -4
- package/src/InputText/context/InputAccessoriesContext.ts +4 -2
- package/src/InputTime/InputTime.test.tsx +3 -3
- package/src/hooks/useAtlantisI18n/useAtlantisI18n.test.ts +28 -7
|
@@ -51,6 +51,6 @@ export interface AtlantisContextProps {
|
|
|
51
51
|
*/
|
|
52
52
|
readonly setHeaderHeight: (height: number) => void;
|
|
53
53
|
}
|
|
54
|
-
export declare const
|
|
54
|
+
export declare const atlantisContextDefaultValues: AtlantisContextProps;
|
|
55
55
|
export declare const AtlantisContext: import("react").Context<AtlantisContextProps>;
|
|
56
56
|
export declare function useAtlantisContext(): AtlantisContextProps;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { AtlantisFormContextProps } from "./types";
|
|
3
|
-
export declare const
|
|
3
|
+
export declare const atlantisFormContextDefaultValues: {
|
|
4
4
|
useConfirmBeforeBack: () => import("react").MutableRefObject<() => undefined>;
|
|
5
5
|
useInternalFormLocalCache: () => {
|
|
6
6
|
setLocalCache: () => undefined;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.46.
|
|
3
|
+
"version": "0.46.2",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
},
|
|
38
38
|
"dependencies": {
|
|
39
39
|
"@jobber/design": "^0.44.4",
|
|
40
|
-
"@jobber/hooks": "^2.
|
|
40
|
+
"@jobber/hooks": "^2.2.0",
|
|
41
41
|
"@react-native-clipboard/clipboard": "^1.11.2",
|
|
42
42
|
"@react-native-picker/picker": "^2.4.10",
|
|
43
43
|
"autolinker": "^4.0.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"react-native-reanimated": "^2.17.0",
|
|
85
85
|
"react-native-safe-area-context": "^4.5.2"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "3e19cd88bd918e5e8a6c047bc5b3683d60c31451"
|
|
88
88
|
}
|
|
@@ -4,7 +4,7 @@ import { cleanup, renderHook } from "@testing-library/react-hooks";
|
|
|
4
4
|
import {
|
|
5
5
|
AtlantisContext,
|
|
6
6
|
AtlantisContextProps,
|
|
7
|
-
|
|
7
|
+
atlantisContextDefaultValues,
|
|
8
8
|
useAtlantisContext,
|
|
9
9
|
} from "./AtlantisContext";
|
|
10
10
|
|
|
@@ -14,6 +14,7 @@ const providerValues: AtlantisContextProps = {
|
|
|
14
14
|
dateFormat: "MM/DD/YYYY",
|
|
15
15
|
timeFormat: "hh:mm a",
|
|
16
16
|
timeZone: "America/Edmonton",
|
|
17
|
+
locale: "en",
|
|
17
18
|
isOnline: false,
|
|
18
19
|
onLogError: _ => {
|
|
19
20
|
return;
|
|
@@ -31,7 +32,7 @@ describe("AtlantisContext", () => {
|
|
|
31
32
|
it("should get the default values", () => {
|
|
32
33
|
const { result } = renderHook(() => useAtlantisContext());
|
|
33
34
|
|
|
34
|
-
expect(result.current).toMatchObject(
|
|
35
|
+
expect(result.current).toMatchObject(atlantisContextDefaultValues);
|
|
35
36
|
});
|
|
36
37
|
});
|
|
37
38
|
|
|
@@ -64,7 +64,7 @@ export interface AtlantisContextProps {
|
|
|
64
64
|
readonly setHeaderHeight: (height: number) => void;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
export const
|
|
67
|
+
export const atlantisContextDefaultValues: AtlantisContextProps = {
|
|
68
68
|
dateFormat: "PP",
|
|
69
69
|
// The system time is "p"
|
|
70
70
|
timeFormat: "p",
|
|
@@ -82,7 +82,7 @@ export const defaultValues: AtlantisContextProps = {
|
|
|
82
82
|
},
|
|
83
83
|
};
|
|
84
84
|
|
|
85
|
-
export const AtlantisContext = createContext(
|
|
85
|
+
export const AtlantisContext = createContext(atlantisContextDefaultValues);
|
|
86
86
|
|
|
87
87
|
export function useAtlantisContext(): AtlantisContextProps {
|
|
88
88
|
return useContext(AtlantisContext);
|
|
@@ -5,7 +5,7 @@ import { Alert } from "react-native";
|
|
|
5
5
|
import { ButtonGroup, ButtonGroupProps } from "./ButtonGroup";
|
|
6
6
|
import { Button } from "../Button";
|
|
7
7
|
import * as atlantisContext from "../AtlantisContext/AtlantisContext";
|
|
8
|
-
import {
|
|
8
|
+
import { atlantisContextDefaultValues } from "../AtlantisContext";
|
|
9
9
|
|
|
10
10
|
const mockOnOpen = jest.fn();
|
|
11
11
|
|
|
@@ -300,7 +300,7 @@ describe("ButtonGroup Offline/Online", () => {
|
|
|
300
300
|
it("should show an alert and not fire the onPress", () => {
|
|
301
301
|
const alertSpy = jest.spyOn(Alert, "alert");
|
|
302
302
|
atlantisContextSpy.mockReturnValue({
|
|
303
|
-
...
|
|
303
|
+
...atlantisContextDefaultValues,
|
|
304
304
|
isOnline: false,
|
|
305
305
|
});
|
|
306
306
|
|
package/src/Form/Form.test.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import { Alert, Keyboard } from "react-native";
|
|
|
4
4
|
import { Host } from "react-native-portalize";
|
|
5
5
|
import { Form, FormBannerMessage, FormBannerMessageType } from ".";
|
|
6
6
|
import { FormBannerErrors, FormSubmitErrorType } from "./types";
|
|
7
|
-
import {
|
|
7
|
+
import { atlantisContextDefaultValues } from "../AtlantisContext";
|
|
8
8
|
import * as atlantisContext from "../AtlantisContext/AtlantisContext";
|
|
9
9
|
import { Text } from "../Text";
|
|
10
10
|
import { Checkbox } from "../Checkbox";
|
|
@@ -476,7 +476,7 @@ describe("Form", () => {
|
|
|
476
476
|
);
|
|
477
477
|
|
|
478
478
|
atlantisContextSpy.mockReturnValue({
|
|
479
|
-
...
|
|
479
|
+
...atlantisContextDefaultValues,
|
|
480
480
|
isOnline: false,
|
|
481
481
|
});
|
|
482
482
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { cleanup, render } from "@testing-library/react-native";
|
|
3
3
|
import { FormErrorBanner } from "./FormErrorBanner";
|
|
4
|
-
import {
|
|
4
|
+
import { atlantisContextDefaultValues } from "../../../AtlantisContext";
|
|
5
5
|
import * as atlantisContext from "../../../AtlantisContext/AtlantisContext";
|
|
6
6
|
|
|
7
7
|
describe("FormErrorBanner", () => {
|
|
@@ -9,7 +9,7 @@ describe("FormErrorBanner", () => {
|
|
|
9
9
|
|
|
10
10
|
beforeEach(() => {
|
|
11
11
|
atlantisContextSpy.mockReturnValue({
|
|
12
|
-
...
|
|
12
|
+
...atlantisContextDefaultValues,
|
|
13
13
|
isOnline: true,
|
|
14
14
|
});
|
|
15
15
|
});
|
|
@@ -3,7 +3,7 @@ import { renderHook } from "@testing-library/react-hooks";
|
|
|
3
3
|
import { AtlantisFormContextProps } from "./types";
|
|
4
4
|
import {
|
|
5
5
|
AtlantisFormContext,
|
|
6
|
-
|
|
6
|
+
atlantisFormContextDefaultValues,
|
|
7
7
|
useAtlantisFormContext,
|
|
8
8
|
} from "./AtlantisFormContext";
|
|
9
9
|
|
|
@@ -13,7 +13,6 @@ const useInternalFormLocalCacheMock = jest.fn();
|
|
|
13
13
|
const providerValues: AtlantisFormContextProps = {
|
|
14
14
|
useConfirmBeforeBack: useConfirmBeforeBackMock,
|
|
15
15
|
useInternalFormLocalCache: useInternalFormLocalCacheMock,
|
|
16
|
-
headerHeight: 50,
|
|
17
16
|
};
|
|
18
17
|
|
|
19
18
|
describe("AtlantisFormContext", () => {
|
|
@@ -25,7 +24,7 @@ describe("AtlantisFormContext", () => {
|
|
|
25
24
|
it("should get the default values", () => {
|
|
26
25
|
const { result } = renderHook(() => useAtlantisFormContext());
|
|
27
26
|
|
|
28
|
-
expect(result.current).toMatchObject(
|
|
27
|
+
expect(result.current).toMatchObject(atlantisFormContextDefaultValues);
|
|
29
28
|
});
|
|
30
29
|
});
|
|
31
30
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext, useContext, useRef } from "react";
|
|
2
2
|
import { AtlantisFormContextProps } from "./types";
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const atlantisFormContextDefaultValues = {
|
|
5
5
|
useConfirmBeforeBack: () => {
|
|
6
6
|
const ref = useRef(() => undefined);
|
|
7
7
|
return ref;
|
|
@@ -12,8 +12,9 @@ export const defaultValues = {
|
|
|
12
12
|
}),
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
export const AtlantisFormContext =
|
|
16
|
-
|
|
15
|
+
export const AtlantisFormContext = createContext<AtlantisFormContextProps>(
|
|
16
|
+
atlantisFormContextDefaultValues,
|
|
17
|
+
);
|
|
17
18
|
|
|
18
19
|
export function useAtlantisFormContext(): AtlantisFormContextProps {
|
|
19
20
|
return useContext(AtlantisFormContext);
|
|
@@ -4,12 +4,12 @@ import { InputCurrency } from "./InputCurrency";
|
|
|
4
4
|
import {
|
|
5
5
|
AtlantisContext,
|
|
6
6
|
AtlantisContextProps,
|
|
7
|
-
|
|
7
|
+
atlantisContextDefaultValues,
|
|
8
8
|
} from "../AtlantisContext";
|
|
9
9
|
|
|
10
10
|
const mockCurrencySymbol = "£";
|
|
11
11
|
const atlantisContext: AtlantisContextProps = {
|
|
12
|
-
...
|
|
12
|
+
...atlantisContextDefaultValues,
|
|
13
13
|
currencySymbol: mockCurrencySymbol,
|
|
14
14
|
timeFormat: "p",
|
|
15
15
|
timeZone: Intl.DateTimeFormat().resolvedOptions().timeZone,
|
|
@@ -238,7 +238,7 @@ describe("InputDate", () => {
|
|
|
238
238
|
|
|
239
239
|
it("should display MM/DD/YYYY when dateFormat is 'P'", () => {
|
|
240
240
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue({
|
|
241
|
-
...atlantisContext.
|
|
241
|
+
...atlantisContext.atlantisContextDefaultValues,
|
|
242
242
|
dateFormat: "P",
|
|
243
243
|
});
|
|
244
244
|
const expectedDate = "05/24/2023";
|
|
@@ -252,7 +252,7 @@ describe("InputDate", () => {
|
|
|
252
252
|
|
|
253
253
|
it("should display mmmm d, yyyy when dateFormat is 'PP'", () => {
|
|
254
254
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue({
|
|
255
|
-
...atlantisContext.
|
|
255
|
+
...atlantisContext.atlantisContextDefaultValues,
|
|
256
256
|
dateFormat: "PP",
|
|
257
257
|
});
|
|
258
258
|
const expectedDate = "Feb 20, 2023";
|
|
@@ -266,7 +266,7 @@ describe("InputDate", () => {
|
|
|
266
266
|
|
|
267
267
|
it("should display mmmmm d, yyyy when dateFormat is 'PPP'", () => {
|
|
268
268
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue({
|
|
269
|
-
...atlantisContext.
|
|
269
|
+
...atlantisContext.atlantisContextDefaultValues,
|
|
270
270
|
dateFormat: "PPP",
|
|
271
271
|
});
|
|
272
272
|
const expectedDate = "July 7th, 2023";
|
|
@@ -280,7 +280,7 @@ describe("InputDate", () => {
|
|
|
280
280
|
|
|
281
281
|
it("should display dddd, mmmmm d, yyyy when dateFormat is 'PPPP'", () => {
|
|
282
282
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue({
|
|
283
|
-
...atlantisContext.
|
|
283
|
+
...atlantisContext.atlantisContextDefaultValues,
|
|
284
284
|
dateFormat: "PPPP",
|
|
285
285
|
});
|
|
286
286
|
const expectedDate = "Thursday, June 22nd, 2023";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createContext, useContext } from "react";
|
|
2
2
|
import { InputAccessoriesContextProps } from "./types";
|
|
3
3
|
|
|
4
|
-
const
|
|
4
|
+
const inputAccessoriesContextDefaultValues: InputAccessoriesContextProps = {
|
|
5
5
|
elements: {},
|
|
6
6
|
focusedInput: "",
|
|
7
7
|
canFocusNext: false,
|
|
@@ -14,7 +14,9 @@ const defaultValues: InputAccessoriesContextProps = {
|
|
|
14
14
|
setFocusedInput: () => undefined,
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const InputAccessoriesContext = createContext(
|
|
17
|
+
export const InputAccessoriesContext = createContext(
|
|
18
|
+
inputAccessoriesContextDefaultValues,
|
|
19
|
+
);
|
|
18
20
|
|
|
19
21
|
export function useInputAccessoriesContext(): InputAccessoriesContextProps {
|
|
20
22
|
return useContext(InputAccessoriesContext);
|
|
@@ -162,7 +162,7 @@ describe("Time picker", () => {
|
|
|
162
162
|
|
|
163
163
|
it("should be set to 24 hours", () => {
|
|
164
164
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue({
|
|
165
|
-
...atlantisContext.
|
|
165
|
+
...atlantisContext.atlantisContextDefaultValues,
|
|
166
166
|
timeZone: "UTC",
|
|
167
167
|
timeFormat: "HH:mm",
|
|
168
168
|
});
|
|
@@ -295,7 +295,7 @@ describe("Timezone conversion", () => {
|
|
|
295
295
|
);
|
|
296
296
|
it("should display the time in the account timezone", async () => {
|
|
297
297
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue({
|
|
298
|
-
...atlantisContext.
|
|
298
|
+
...atlantisContext.atlantisContextDefaultValues,
|
|
299
299
|
timeZone: "America/Los_Angeles",
|
|
300
300
|
});
|
|
301
301
|
|
|
@@ -309,7 +309,7 @@ describe("Timezone conversion", () => {
|
|
|
309
309
|
|
|
310
310
|
it("should have the correct offset on the time picker", async () => {
|
|
311
311
|
jest.spyOn(atlantisContext, "useAtlantisContext").mockReturnValue({
|
|
312
|
-
...atlantisContext.
|
|
312
|
+
...atlantisContext.atlantisContextDefaultValues,
|
|
313
313
|
timeZone: "America/Los_Angeles",
|
|
314
314
|
});
|
|
315
315
|
|
|
@@ -36,7 +36,10 @@ describe("useAtlantisI18n", () => {
|
|
|
36
36
|
|
|
37
37
|
describe("Español", () => {
|
|
38
38
|
it("should return español", () => {
|
|
39
|
-
spy.mockReturnValueOnce({
|
|
39
|
+
spy.mockReturnValueOnce({
|
|
40
|
+
...context.atlantisContextDefaultValues,
|
|
41
|
+
locale: "es",
|
|
42
|
+
});
|
|
40
43
|
const { result } = renderHook(useAtlantisI18n);
|
|
41
44
|
|
|
42
45
|
expect(result.current.t("cancel")).toBe("Cancelar");
|
|
@@ -45,7 +48,10 @@ describe("useAtlantisI18n", () => {
|
|
|
45
48
|
|
|
46
49
|
describe("Unsupported language", () => {
|
|
47
50
|
it("should return the english translation", () => {
|
|
48
|
-
spy.mockReturnValueOnce({
|
|
51
|
+
spy.mockReturnValueOnce({
|
|
52
|
+
...context.atlantisContextDefaultValues,
|
|
53
|
+
locale: "fr",
|
|
54
|
+
});
|
|
49
55
|
const { result } = renderHook(useAtlantisI18n);
|
|
50
56
|
|
|
51
57
|
expect(result.current.t("cancel")).toBe("Cancel");
|
|
@@ -65,7 +71,10 @@ describe("useAtlantisI18n", () => {
|
|
|
65
71
|
});
|
|
66
72
|
|
|
67
73
|
it("should return the date formatted for es", () => {
|
|
68
|
-
spy.mockReturnValueOnce({
|
|
74
|
+
spy.mockReturnValueOnce({
|
|
75
|
+
...context.atlantisContextDefaultValues,
|
|
76
|
+
locale: "es",
|
|
77
|
+
});
|
|
69
78
|
|
|
70
79
|
const { result } = renderHook(useAtlantisI18n);
|
|
71
80
|
expect(result.current.formatDate(testDate)).toBe("1 ene 2020");
|
|
@@ -79,7 +88,10 @@ describe("useAtlantisI18n", () => {
|
|
|
79
88
|
["Europe/London", "Jan 1, 2020"],
|
|
80
89
|
["Australia/Sydney", "Jan 1, 2020"],
|
|
81
90
|
])("should return the %s time", (timeZone, expected) => {
|
|
82
|
-
spy.mockReturnValueOnce({
|
|
91
|
+
spy.mockReturnValueOnce({
|
|
92
|
+
...context.atlantisContextDefaultValues,
|
|
93
|
+
timeZone,
|
|
94
|
+
});
|
|
83
95
|
|
|
84
96
|
const { result } = renderHook(useAtlantisI18n);
|
|
85
97
|
expect(result.current.formatDate(testDate)).toBe(expected);
|
|
@@ -94,7 +106,10 @@ describe("useAtlantisI18n", () => {
|
|
|
94
106
|
});
|
|
95
107
|
|
|
96
108
|
it("should return the date formatted for es", () => {
|
|
97
|
-
spy.mockReturnValueOnce({
|
|
109
|
+
spy.mockReturnValueOnce({
|
|
110
|
+
...context.atlantisContextDefaultValues,
|
|
111
|
+
locale: "es",
|
|
112
|
+
});
|
|
98
113
|
|
|
99
114
|
const { result } = renderHook(useAtlantisI18n);
|
|
100
115
|
expect(result.current.formatTime(testDate)).toBe("00:00");
|
|
@@ -108,7 +123,10 @@ describe("useAtlantisI18n", () => {
|
|
|
108
123
|
["Europe/London", "12:00 AM"],
|
|
109
124
|
["Australia/Sydney", "11:00 AM"],
|
|
110
125
|
])("should return the %s zoned time", (timeZone, expected) => {
|
|
111
|
-
spy.mockReturnValueOnce({
|
|
126
|
+
spy.mockReturnValueOnce({
|
|
127
|
+
...context.atlantisContextDefaultValues,
|
|
128
|
+
timeZone,
|
|
129
|
+
});
|
|
112
130
|
|
|
113
131
|
const { result } = renderHook(useAtlantisI18n);
|
|
114
132
|
expect(result.current.formatTime(testDate)).toBe(expected);
|
|
@@ -121,7 +139,10 @@ describe("useAtlantisI18n", () => {
|
|
|
121
139
|
["Europe/London", "1:00 AM"],
|
|
122
140
|
["Australia/Sydney", "10:00 AM"],
|
|
123
141
|
])("should return the %s spring zoned time", (timeZone, expected) => {
|
|
124
|
-
spy.mockReturnValueOnce({
|
|
142
|
+
spy.mockReturnValueOnce({
|
|
143
|
+
...context.atlantisContextDefaultValues,
|
|
144
|
+
timeZone,
|
|
145
|
+
});
|
|
125
146
|
|
|
126
147
|
const { result } = renderHook(useAtlantisI18n);
|
|
127
148
|
expect(result.current.formatTime(dateAfterSpringForward)).toBe(
|