@jobber/components-native 0.87.1 → 0.88.1-JOB-139048-04134dd.0
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 +15 -16
- package/dist/src/Button/components/InternalButtonLoading/InternalButtonLoading.js +0 -1
- package/dist/src/ContentOverlay/ContentOverlay.js +2 -2
- package/dist/src/ContentOverlay/UNSAFE_WrappedModalize.js +27 -0
- package/dist/src/ContentOverlay/index.js +1 -0
- package/dist/src/utils/meta/meta.json +2 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -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/ContentOverlay/index.d.ts +1 -0
- package/dist/types/src/InputText/InputText.d.ts +2 -2
- package/package.json +15 -16
- package/src/AtlantisContext/AtlantisContext.test.tsx +1 -1
- package/src/AutoLink/AutoLink.test.tsx +2 -4
- package/src/Button/components/InternalButtonLoading/InternalButtonLoading.tsx +0 -1
- package/src/Checkbox/CheckboxGroup.test.tsx +2 -6
- package/src/ContentOverlay/ContentOverlay.test.tsx +30 -23
- package/src/ContentOverlay/ContentOverlay.tsx +4 -3
- package/src/ContentOverlay/UNSAFE_WrappedModalize.tsx +45 -0
- package/src/ContentOverlay/hooks/useKeyboardVisibility.test.ts +1 -1
- package/src/ContentOverlay/hooks/useViewLayoutHeight.test.ts +1 -1
- package/src/ContentOverlay/index.ts +1 -0
- package/src/EmptyState/EmptyState.test.tsx +29 -42
- package/src/Form/components/FormMessage/FormMessage.test.tsx +40 -27
- package/src/Form/context/AtlantisFormContext.test.tsx +1 -1
- package/src/Form/hooks/useScrollToError/useScrollToError.test.tsx +2 -1
- package/src/FormatFile/FormatFile.test.tsx +6 -6
- package/src/Icon/__snapshots__/Icon.test.tsx.snap +7 -0
- package/src/InputFieldWrapper/components/Prefix/Prefix.test.tsx +5 -11
- package/src/InputText/InputText.tsx +2 -5
- package/src/ThumbnailList/ThumbnailList.test.tsx +5 -5
- package/src/utils/meta/meta.json +2 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Modalize } from "react-native-modalize";
|
|
2
|
+
import type { Modalize } from "react-native-modalize";
|
|
3
3
|
import type { ContentOverlayProps } from "./types";
|
|
4
4
|
export declare const ContentOverlay: React.ForwardRefExoticComponent<ContentOverlayProps & React.RefAttributes<{
|
|
5
5
|
open?: Modalize["open"];
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { IHandles } from "react-native-modalize/lib/options";
|
|
3
|
+
export declare const UNSAFE_WrappedModalize: React.ForwardRefExoticComponent<Omit<import("react-native-modalize/lib/options").IProps<any> & React.RefAttributes<string | number | boolean | {} | React.ReactPortal | React.ReactElement<any, string | ((props: any) => React.ReactElement<any, any> | null) | (new (props: any) => React.Component<any, any, any>)> | React.ReactNodeArray | undefined>, "ref"> & React.RefAttributes<IHandles>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SyntheticEvent } from "react";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import type {
|
|
3
|
+
import type { FocusEvent, StyleProp, TextInputProps, TextStyle } from "react-native";
|
|
4
4
|
import { TextInput } from "react-native";
|
|
5
5
|
import type { RegisterOptions } from "react-hook-form";
|
|
6
6
|
import type { IconNames } from "@jobber/design";
|
|
@@ -65,7 +65,7 @@ export interface InputTextProps extends Pick<InputFieldWrapperProps, "toolbar" |
|
|
|
65
65
|
* Callback that is called when the text input is focused
|
|
66
66
|
* @param event
|
|
67
67
|
*/
|
|
68
|
-
readonly onFocus?: (event?:
|
|
68
|
+
readonly onFocus?: (event?: FocusEvent) => void;
|
|
69
69
|
/**
|
|
70
70
|
* Callback that is called when the text input is blurred
|
|
71
71
|
*/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.88.1-JOB-139048-04134dd.0+04134dd81",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"deepmerge": "^4.2.2",
|
|
45
45
|
"lodash": "^4.17.21",
|
|
46
46
|
"react-hook-form": "^7.52.0",
|
|
47
|
-
"react-intl": "^
|
|
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,28 +53,27 @@
|
|
|
53
53
|
"ts-xor": "^1.1.0"
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
|
-
"@react-native-community/datetimepicker": "^
|
|
56
|
+
"@react-native-community/datetimepicker": "^8.4.5",
|
|
57
|
+
"@react-native/babel-preset": "^0.81.1",
|
|
57
58
|
"@storybook/addon-a11y": "^9.1.2",
|
|
58
59
|
"@storybook/react": "^9.1.2",
|
|
59
60
|
"@storybook/react-native-web-vite": "^9.1.2",
|
|
60
|
-
"@testing-library/
|
|
61
|
-
"@testing-library/react-native": "^12.0.1",
|
|
61
|
+
"@testing-library/react-native": "^13.3.3",
|
|
62
62
|
"@types/lodash.chunk": "^4.2.7",
|
|
63
63
|
"@types/lodash.debounce": "^4.0.7",
|
|
64
64
|
"@types/lodash.identity": "^3.0.7",
|
|
65
|
-
"@types/react": "^18.0.28",
|
|
66
65
|
"@types/react-native-uuid": "^1.4.0",
|
|
66
|
+
"@types/react-test-renderer": "19.1.0",
|
|
67
67
|
"date-fns": "^2.30.0",
|
|
68
68
|
"date-fns-tz": "^2.0.0",
|
|
69
|
-
"
|
|
70
|
-
"react-native": "^
|
|
71
|
-
"react-native-
|
|
72
|
-
"react-native-modal-datetime-picker": "^15.0.1",
|
|
69
|
+
"react-native": "^0.81.4",
|
|
70
|
+
"react-native-gesture-handler": "^2.28.0",
|
|
71
|
+
"react-native-modal-datetime-picker": "^18.0.0",
|
|
73
72
|
"react-native-reanimated": "^3.7.1",
|
|
74
73
|
"react-native-safe-area-context": "^5.4.0",
|
|
75
74
|
"react-native-svg": "^15.1.0",
|
|
76
75
|
"react-native-web": "^0.20.0",
|
|
77
|
-
"react-test-renderer": "
|
|
76
|
+
"react-test-renderer": "19.1.0",
|
|
78
77
|
"storybook": "^9.1.2"
|
|
79
78
|
},
|
|
80
79
|
"peerDependencies": {
|
|
@@ -83,10 +82,10 @@
|
|
|
83
82
|
"@react-native-community/datetimepicker": ">=6.7.0",
|
|
84
83
|
"date-fns": "^2.30.0",
|
|
85
84
|
"date-fns-tz": "^2.0.0",
|
|
86
|
-
"react": "^18.
|
|
87
|
-
"react-intl": "^6
|
|
88
|
-
"react-native": ">=0.
|
|
89
|
-
"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",
|
|
90
89
|
"react-native-keyboard-aware-scroll-view": "^0.9.5",
|
|
91
90
|
"react-native-modal-datetime-picker": " >=13.0.0",
|
|
92
91
|
"react-native-modalize": "^2.0.13",
|
|
@@ -95,5 +94,5 @@
|
|
|
95
94
|
"react-native-safe-area-context": "^5.4.0",
|
|
96
95
|
"react-native-svg": ">=12.0.0"
|
|
97
96
|
},
|
|
98
|
-
"gitHead": "
|
|
97
|
+
"gitHead": "04134dd81a80801cb9749c94d92f80b0e1d7c7dc"
|
|
99
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 {
|
|
@@ -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
|
|
|
@@ -4,7 +4,7 @@ import { AccessibilityInfo, View } from "react-native";
|
|
|
4
4
|
import { Host } from "react-native-portalize";
|
|
5
5
|
import type { ReactTestInstance } from "react-test-renderer";
|
|
6
6
|
import { act } from "react-test-renderer";
|
|
7
|
-
import type { ContentOverlayRef, ModalBackgroundColor } from "./
|
|
7
|
+
import type { ContentOverlayRef, ModalBackgroundColor } from "./types";
|
|
8
8
|
import { ContentOverlay } from "./ContentOverlay";
|
|
9
9
|
import { tokens } from "../utils/design";
|
|
10
10
|
import { Button } from "../Button";
|
|
@@ -106,23 +106,30 @@ function renderContentOverlay(
|
|
|
106
106
|
return renderResult;
|
|
107
107
|
}
|
|
108
108
|
|
|
109
|
-
function renderAndOpenContentOverlay(
|
|
109
|
+
async function renderAndOpenContentOverlay(
|
|
110
|
+
defaultOptions = getDefaultOptions(),
|
|
111
|
+
) {
|
|
110
112
|
const rendered = renderContentOverlay(defaultOptions);
|
|
111
113
|
|
|
112
114
|
act(() => {
|
|
113
115
|
fireEvent.press(rendered.getByLabelText(defaultOptions.buttonLabel));
|
|
114
116
|
});
|
|
115
117
|
|
|
118
|
+
// Wait for the modal to open asynchronously (due to requestAnimationFrame)
|
|
119
|
+
await waitFor(() => {
|
|
120
|
+
expect(rendered.getByTestId("ATL-Overlay-Header")).toBeDefined();
|
|
121
|
+
});
|
|
122
|
+
|
|
116
123
|
return rendered;
|
|
117
124
|
}
|
|
118
125
|
|
|
119
126
|
describe("when open is called on the content overlay ref", () => {
|
|
120
|
-
it("should open the content overlay, exposing the content to the user", () => {
|
|
127
|
+
it("should open the content overlay, exposing the content to the user", async () => {
|
|
121
128
|
const options: testRendererOptions = {
|
|
122
129
|
...getDefaultOptions(),
|
|
123
130
|
text: "I am text within the content overlay",
|
|
124
131
|
};
|
|
125
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
132
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
126
133
|
|
|
127
134
|
expect(contentOverlayScreen.getByText(options.text)).toBeDefined();
|
|
128
135
|
});
|
|
@@ -135,7 +142,7 @@ describe("when the close button is clicked on an open content overlay", () => {
|
|
|
135
142
|
text: "I am text within the content overlay",
|
|
136
143
|
showDismiss: true,
|
|
137
144
|
};
|
|
138
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
145
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
139
146
|
|
|
140
147
|
act(() => {
|
|
141
148
|
fireEvent.press(
|
|
@@ -156,7 +163,7 @@ describe("when the close button is clicked on an open content overlay with a def
|
|
|
156
163
|
onCloseCallback: jest.fn(),
|
|
157
164
|
showDismiss: true,
|
|
158
165
|
};
|
|
159
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
166
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
160
167
|
|
|
161
168
|
act(() => {
|
|
162
169
|
fireEvent.press(
|
|
@@ -191,7 +198,7 @@ describe("when the content overlay is created with a defined onOpen prop", () =>
|
|
|
191
198
|
...getDefaultOptions(),
|
|
192
199
|
onOpenCallback: jest.fn(),
|
|
193
200
|
};
|
|
194
|
-
renderAndOpenContentOverlay(options);
|
|
201
|
+
await renderAndOpenContentOverlay(options);
|
|
195
202
|
|
|
196
203
|
await waitFor(() => {
|
|
197
204
|
expect(options.onOpenCallback).toHaveBeenCalled();
|
|
@@ -201,25 +208,25 @@ describe("when the content overlay is created with a defined onOpen prop", () =>
|
|
|
201
208
|
});
|
|
202
209
|
|
|
203
210
|
describe("when title prop passed to content overlay", () => {
|
|
204
|
-
it("should set the header title", () => {
|
|
211
|
+
it("should set the header title", async () => {
|
|
205
212
|
const options: testRendererOptions = {
|
|
206
213
|
...getDefaultOptions(),
|
|
207
214
|
title: "Awesome Title",
|
|
208
215
|
};
|
|
209
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
216
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
210
217
|
|
|
211
218
|
expect(contentOverlayScreen.getByText(options.title)).toBeDefined();
|
|
212
219
|
});
|
|
213
220
|
});
|
|
214
221
|
|
|
215
222
|
describe("when accessibilityLabel prop passed to content overlay", () => {
|
|
216
|
-
it("should set the header accessibilityLabel", () => {
|
|
223
|
+
it("should set the header accessibilityLabel", async () => {
|
|
217
224
|
const options: testRendererOptions = {
|
|
218
225
|
...getDefaultOptions(),
|
|
219
226
|
a11yLabel: "Awesome a11y Label",
|
|
220
227
|
showDismiss: true,
|
|
221
228
|
};
|
|
222
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
229
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
223
230
|
|
|
224
231
|
expect(
|
|
225
232
|
contentOverlayScreen.getByLabelText(options.a11yLabel || "ohno"),
|
|
@@ -228,13 +235,13 @@ describe("when accessibilityLabel prop passed to content overlay", () => {
|
|
|
228
235
|
});
|
|
229
236
|
|
|
230
237
|
describe("when accessibilityLabel prop NOT passed to content overlay", () => {
|
|
231
|
-
it("should use default accessibilityLabel", () => {
|
|
238
|
+
it("should use default accessibilityLabel", async () => {
|
|
232
239
|
const options: testRendererOptions = {
|
|
233
240
|
...getDefaultOptions(),
|
|
234
241
|
title: "Awesome Title",
|
|
235
242
|
showDismiss: true,
|
|
236
243
|
};
|
|
237
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
244
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
238
245
|
|
|
239
246
|
expect(
|
|
240
247
|
contentOverlayScreen.getAllByLabelText(`Close ${options.title} modal`),
|
|
@@ -251,7 +258,7 @@ describe("when there is a screen reader enabled", () => {
|
|
|
251
258
|
const options: testRendererOptions = {
|
|
252
259
|
...getDefaultOptions(),
|
|
253
260
|
};
|
|
254
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
261
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
255
262
|
|
|
256
263
|
expect(
|
|
257
264
|
await contentOverlayScreen.findByTestId("ATL-Overlay-CloseButton"),
|
|
@@ -260,12 +267,12 @@ describe("when there is a screen reader enabled", () => {
|
|
|
260
267
|
});
|
|
261
268
|
|
|
262
269
|
describe("when fullScreen is set to true", () => {
|
|
263
|
-
it("should show the dismiss button", () => {
|
|
270
|
+
it("should show the dismiss button", async () => {
|
|
264
271
|
const options: testRendererOptions = {
|
|
265
272
|
...getDefaultOptions(),
|
|
266
273
|
fullScreen: true,
|
|
267
274
|
};
|
|
268
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
275
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
269
276
|
expect(
|
|
270
277
|
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
271
278
|
).toBeDefined();
|
|
@@ -273,12 +280,12 @@ describe("when fullScreen is set to true", () => {
|
|
|
273
280
|
});
|
|
274
281
|
|
|
275
282
|
describe("when showDismiss is set to true", () => {
|
|
276
|
-
it("should show the dismiss button", () => {
|
|
283
|
+
it("should show the dismiss button", async () => {
|
|
277
284
|
const options: testRendererOptions = {
|
|
278
285
|
...getDefaultOptions(),
|
|
279
286
|
showDismiss: true,
|
|
280
287
|
};
|
|
281
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
288
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
282
289
|
expect(
|
|
283
290
|
contentOverlayScreen.getByTestId("ATL-Overlay-CloseButton"),
|
|
284
291
|
).toBeDefined();
|
|
@@ -292,7 +299,7 @@ describe("when the close button is clicked on an open content overlay with a def
|
|
|
292
299
|
onBeforeExitCallback: jest.fn(),
|
|
293
300
|
showDismiss: true,
|
|
294
301
|
};
|
|
295
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
302
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
296
303
|
|
|
297
304
|
act(() => {
|
|
298
305
|
fireEvent.press(
|
|
@@ -308,11 +315,11 @@ describe("when the close button is clicked on an open content overlay with a def
|
|
|
308
315
|
|
|
309
316
|
describe("modalBackgroundColor prop", () => {
|
|
310
317
|
describe("when using the default surface value", () => {
|
|
311
|
-
it("renders the component with the color-surface color", () => {
|
|
318
|
+
it("renders the component with the color-surface color", async () => {
|
|
312
319
|
const options: testRendererOptions = {
|
|
313
320
|
...getDefaultOptions(),
|
|
314
321
|
};
|
|
315
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
322
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
316
323
|
const OverlayHeader = contentOverlayScreen.getByTestId(
|
|
317
324
|
"ATL-Overlay-Header",
|
|
318
325
|
).children[0] as ReactTestInstance;
|
|
@@ -337,12 +344,12 @@ describe("modalBackgroundColor prop", () => {
|
|
|
337
344
|
});
|
|
338
345
|
|
|
339
346
|
describe("when set to background", () => {
|
|
340
|
-
it("changes the backround color of the modal to color-surface--background", () => {
|
|
347
|
+
it("changes the backround color of the modal to color-surface--background", async () => {
|
|
341
348
|
const options: testRendererOptions = {
|
|
342
349
|
...getDefaultOptions(),
|
|
343
350
|
modalBackgroundColor: "background",
|
|
344
351
|
};
|
|
345
|
-
const contentOverlayScreen = renderAndOpenContentOverlay(options);
|
|
352
|
+
const contentOverlayScreen = await renderAndOpenContentOverlay(options);
|
|
346
353
|
const OverlayHeader = contentOverlayScreen.getByTestId(
|
|
347
354
|
"ATL-Overlay-Header",
|
|
348
355
|
).children[0] as ReactTestInstance;
|
|
@@ -7,7 +7,7 @@ import React, {
|
|
|
7
7
|
useRef,
|
|
8
8
|
useState,
|
|
9
9
|
} from "react";
|
|
10
|
-
import { Modalize } from "react-native-modalize";
|
|
10
|
+
import type { Modalize } from "react-native-modalize";
|
|
11
11
|
import { useSafeAreaInsets } from "react-native-safe-area-context";
|
|
12
12
|
import type { NativeScrollEvent, NativeSyntheticEvent } from "react-native";
|
|
13
13
|
import {
|
|
@@ -26,6 +26,7 @@ import type {
|
|
|
26
26
|
ContentOverlayRef,
|
|
27
27
|
ModalBackgroundColor,
|
|
28
28
|
} from "./types";
|
|
29
|
+
import { UNSAFE_WrappedModalize } from "./UNSAFE_WrappedModalize";
|
|
29
30
|
import { useIsScreenReaderEnabled } from "../hooks";
|
|
30
31
|
import { IconButton } from "../IconButton";
|
|
31
32
|
import { Heading } from "../Heading";
|
|
@@ -153,7 +154,7 @@ function ContentOverlayInternal(
|
|
|
153
154
|
return (
|
|
154
155
|
<>
|
|
155
156
|
{headerHeightKnown && childrenHeightKnown && (
|
|
156
|
-
<
|
|
157
|
+
<UNSAFE_WrappedModalize
|
|
157
158
|
ref={callbackInternalRef}
|
|
158
159
|
overlayStyle={styles.overlay}
|
|
159
160
|
handleStyle={styles.handle}
|
|
@@ -196,7 +197,7 @@ function ContentOverlayInternal(
|
|
|
196
197
|
>
|
|
197
198
|
{Platform.OS === "android" ? renderedHeader : undefined}
|
|
198
199
|
{renderedChildren}
|
|
199
|
-
</
|
|
200
|
+
</UNSAFE_WrappedModalize>
|
|
200
201
|
)}
|
|
201
202
|
{!childrenHeightKnown && (
|
|
202
203
|
<View style={[styles.hiddenContent, modalStyle]}>
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import React, {
|
|
2
|
+
forwardRef,
|
|
3
|
+
useImperativeHandle,
|
|
4
|
+
useRef,
|
|
5
|
+
useState,
|
|
6
|
+
} from "react";
|
|
7
|
+
import { Modalize } from "react-native-modalize";
|
|
8
|
+
import type { IHandles } from "react-native-modalize/lib/options";
|
|
9
|
+
|
|
10
|
+
type Props = React.ComponentProps<typeof Modalize>;
|
|
11
|
+
|
|
12
|
+
// DON'T USE THIS COMPONENT DIRECTLY.
|
|
13
|
+
// It is exposed only so that the deprecated ContentOverlay component can use this along with the
|
|
14
|
+
// newer one contained in this lib.
|
|
15
|
+
// This is a temporary solution for new architecture. JOB-137549 plans to replace modalize entirely.
|
|
16
|
+
export const UNSAFE_WrappedModalize = forwardRef<IHandles, Props>(
|
|
17
|
+
(props, ref) => {
|
|
18
|
+
const innerRef = useRef<IHandles | null>(null);
|
|
19
|
+
const [openRenderId, setOpenRenderId] = useState(0);
|
|
20
|
+
|
|
21
|
+
useImperativeHandle(
|
|
22
|
+
ref,
|
|
23
|
+
() => ({
|
|
24
|
+
open(dest) {
|
|
25
|
+
setOpenRenderId(id => id + 1);
|
|
26
|
+
// Open on a fresh tick for additional safety
|
|
27
|
+
requestAnimationFrame(() => {
|
|
28
|
+
innerRef.current?.open(dest);
|
|
29
|
+
});
|
|
30
|
+
},
|
|
31
|
+
close(dest) {
|
|
32
|
+
innerRef.current?.close(dest);
|
|
33
|
+
},
|
|
34
|
+
}),
|
|
35
|
+
[],
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
// Use a unique key to force a remount, ensuring we get fresh gesture handler nodes within modalize
|
|
39
|
+
return (
|
|
40
|
+
<Modalize key={`modalize-${openRenderId}`} ref={innerRef} {...props} />
|
|
41
|
+
);
|
|
42
|
+
},
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
UNSAFE_WrappedModalize.displayName = "UNSAFE_WrappedModalize";
|
|
@@ -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
|
});
|