@hero-design/rn 8.42.0-alpha.0 → 8.42.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.
Files changed (36) hide show
  1. package/.turbo/turbo-build.log +1 -1
  2. package/es/index.js +614 -696
  3. package/lib/index.js +616 -700
  4. package/package.json +7 -8
  5. package/rollup.config.js +0 -1
  6. package/src/components/Carousel/__tests__/__snapshots__/CardCarousel.spec.tsx.snap +20 -0
  7. package/src/components/Carousel/__tests__/__snapshots__/StyledCardCarousel.spec.tsx.snap +15 -0
  8. package/src/components/Carousel/__tests__/__snapshots__/index.spec.tsx.snap +96 -3
  9. package/src/components/Carousel/__tests__/index.spec.tsx +47 -1
  10. package/src/components/Carousel/index.tsx +16 -22
  11. package/src/components/Error/StyledError.tsx +2 -1
  12. package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +115 -97
  13. package/src/components/Error/__tests__/index.spec.tsx +9 -6
  14. package/src/components/Modal/__tests__/__snapshots__/index.spec.tsx.snap +117 -0
  15. package/src/components/Modal/__tests__/index.spec.tsx +99 -0
  16. package/src/components/Modal/index.tsx +178 -82
  17. package/src/components/PageControl/__tests__/__snapshots__/index.spec.tsx.snap +15 -0
  18. package/src/components/PageControl/index.tsx +1 -0
  19. package/src/components/Success/StyledSuccess.tsx +2 -1
  20. package/src/components/Success/__tests__/__snapshots__/index.spec.tsx.snap +115 -95
  21. package/src/components/Success/__tests__/index.spec.tsx +9 -6
  22. package/src/index.ts +0 -2
  23. package/testUtils/setup.tsx +0 -18
  24. package/types/components/Carousel/index.d.ts +1 -1
  25. package/types/components/Error/StyledError.d.ts +3 -5
  26. package/types/components/Modal/index.d.ts +12 -8
  27. package/types/components/Success/StyledSuccess.d.ts +3 -5
  28. package/types/index.d.ts +1 -2
  29. package/src/components/Modal/ModalContentWrapper.tsx +0 -112
  30. package/src/components/Modal/ModalPresenter/ModalPresenter.tsx +0 -135
  31. package/src/components/Modal/ModalPresenter/index.tsx +0 -9
  32. package/src/components/Modal/ModalProvider.tsx +0 -8
  33. package/types/components/Modal/ModalContentWrapper.d.ts +0 -16
  34. package/types/components/Modal/ModalPresenter/ModalPresenter.d.ts +0 -34
  35. package/types/components/Modal/ModalPresenter/index.d.ts +0 -3
  36. package/types/components/Modal/ModalProvider.d.ts +0 -5
@@ -245,146 +245,164 @@ exports[`Error renders error screen with image correctly 1`] = `
245
245
  `;
246
246
 
247
247
  exports[`Error renders full screen error page correctly 1`] = `
248
- <Modal
249
- animationType="slide"
250
- hardwareAccelerated={false}
251
- onDismiss={[Function]}
252
- onRequestClose={[Function]}
253
- style={
254
- [
248
+ [
249
+ <View
250
+ collapsable={false}
251
+ style={
255
252
  {
256
- "height": "100%",
257
- "width": "100%",
258
- },
259
- undefined,
260
- ]
261
- }
262
- visible={true}
263
- >
253
+ "backgroundColor": "#000000",
254
+ "bottom": 0,
255
+ "left": 0,
256
+ "opacity": 0,
257
+ "position": "absolute",
258
+ "right": 0,
259
+ "top": 0,
260
+ }
261
+ }
262
+ />,
264
263
  <View
264
+ collapsable={false}
265
265
  style={
266
- [
267
- {
268
- "backgroundColor": "#ccd2d3",
269
- "display": "flex",
270
- "flex": 1,
271
- "flexDirection": "column",
272
- },
273
- undefined,
274
- ]
266
+ {
267
+ "bottom": 0,
268
+ "left": 0,
269
+ "opacity": 1,
270
+ "position": "absolute",
271
+ "right": 0,
272
+ "top": 0,
273
+ "transform": [
274
+ {
275
+ "translateY": 1334,
276
+ },
277
+ ],
278
+ }
275
279
  }
276
- themeVariant="full-screen"
277
280
  >
278
281
  <View
279
282
  style={
280
283
  [
281
284
  {
282
- "alignItems": "center",
285
+ "backgroundColor": "#ccd2d3",
283
286
  "display": "flex",
284
287
  "flex": 1,
285
288
  "flexDirection": "column",
286
- "justifyContent": "center",
287
- "padding": 24,
288
289
  },
289
290
  undefined,
290
291
  ]
291
292
  }
293
+ themeVariant="full-screen"
292
294
  >
293
295
  <View
294
296
  style={
295
297
  [
296
298
  {
297
- "height": 176,
298
- "marginBottom": 24,
299
- "width": 176,
299
+ "alignItems": "center",
300
+ "display": "flex",
301
+ "flex": 1,
302
+ "flexDirection": "column",
303
+ "justifyContent": "center",
304
+ "padding": 24,
300
305
  },
301
306
  undefined,
302
307
  ]
303
308
  }
304
309
  >
305
- <Image
306
- source={
307
- {
308
- "uri": "path_to_image",
309
- }
310
+ <View
311
+ style={
312
+ [
313
+ {
314
+ "height": 176,
315
+ "marginBottom": 24,
316
+ "width": 176,
317
+ },
318
+ undefined,
319
+ ]
310
320
  }
321
+ >
322
+ <Image
323
+ source={
324
+ {
325
+ "uri": "path_to_image",
326
+ }
327
+ }
328
+ style={
329
+ [
330
+ {
331
+ "borderRadius": 0,
332
+ "height": 72,
333
+ "width": 72,
334
+ },
335
+ [
336
+ {
337
+ "height": 176,
338
+ "marginBottom": 24,
339
+ "resizeMode": "contain",
340
+ "width": 176,
341
+ },
342
+ undefined,
343
+ ],
344
+ ]
345
+ }
346
+ testID="error-image"
347
+ />
348
+ </View>
349
+ <Text
350
+ allowFontScaling={false}
311
351
  style={
312
352
  [
313
353
  {
314
- "borderRadius": 0,
315
- "height": 72,
316
- "width": 72,
354
+ "color": "#001f23",
355
+ "fontFamily": "RebondGrotesque-SemiBold",
356
+ "fontSize": 24,
357
+ "letterSpacing": 0.24,
358
+ "lineHeight": 32,
317
359
  },
318
360
  [
319
361
  {
320
- "height": 176,
321
- "marginBottom": 24,
322
- "resizeMode": "contain",
323
- "width": 176,
362
+ "color": "#001f23",
363
+ "marginBottom": 8,
364
+ "textAlign": "center",
324
365
  },
325
366
  undefined,
326
367
  ],
327
368
  ]
328
369
  }
329
- testID="error-image"
330
- />
331
- </View>
332
- <Text
333
- allowFontScaling={false}
334
- style={
335
- [
336
- {
337
- "color": "#001f23",
338
- "fontFamily": "RebondGrotesque-SemiBold",
339
- "fontSize": 24,
340
- "letterSpacing": 0.24,
341
- "lineHeight": 32,
342
- },
370
+ themeIntent="body"
371
+ themeLevel="h4"
372
+ themeTypeface="playful"
373
+ >
374
+ We’re sorry, something went wrong
375
+ </Text>
376
+ <Text
377
+ allowFontScaling={false}
378
+ style={
343
379
  [
344
380
  {
345
381
  "color": "#001f23",
346
- "marginBottom": 8,
347
- "textAlign": "center",
382
+ "fontFamily": "BeVietnamPro-Regular",
383
+ "fontSize": 18,
384
+ "letterSpacing": 0.54,
385
+ "lineHeight": 26,
348
386
  },
349
- undefined,
350
- ],
351
- ]
352
- }
353
- themeIntent="body"
354
- themeLevel="h4"
355
- themeTypeface="playful"
356
- >
357
- We’re sorry, something went wrong
358
- </Text>
359
- <Text
360
- allowFontScaling={false}
361
- style={
362
- [
363
- {
364
- "color": "#001f23",
365
- "fontFamily": "BeVietnamPro-Regular",
366
- "fontSize": 18,
367
- "letterSpacing": 0.54,
368
- "lineHeight": 26,
369
- },
370
- [
371
- {
372
- "color": "#4d6265",
373
- "textAlign": "center",
374
- },
375
- undefined,
376
- ],
377
- ]
378
- }
379
- themeIntent="body"
380
- themeTypeface="playful"
381
- themeVariant="regular"
382
- >
383
- Please try again later
384
- </Text>
387
+ [
388
+ {
389
+ "color": "#4d6265",
390
+ "textAlign": "center",
391
+ },
392
+ undefined,
393
+ ],
394
+ ]
395
+ }
396
+ themeIntent="body"
397
+ themeTypeface="playful"
398
+ themeVariant="regular"
399
+ >
400
+ Please try again later
401
+ </Text>
402
+ </View>
385
403
  </View>
386
- </View>
387
- </Modal>
404
+ </View>,
405
+ ]
388
406
  `;
389
407
 
390
408
  exports[`Error renders title only correctly 1`] = `
@@ -3,6 +3,7 @@ import { fireEvent } from '@testing-library/react-native';
3
3
  import renderWithTheme from '../../../testHelpers/renderWithTheme';
4
4
  import Error from '..';
5
5
  import Image from '../../Image';
6
+ import Portal from '../../Portal';
6
7
 
7
8
  const title = `We’re sorry, something went wrong`;
8
9
  const description = 'Please try again later';
@@ -46,12 +47,14 @@ describe('Error', () => {
46
47
  });
47
48
  it('renders full screen error page correctly', () => {
48
49
  const { toJSON, getByText, getByTestId } = renderWithTheme(
49
- <Error
50
- variant="full-screen"
51
- title={title}
52
- description={description}
53
- image="path_to_image"
54
- />
50
+ <Portal.Provider>
51
+ <Error
52
+ variant="full-screen"
53
+ title={title}
54
+ description={description}
55
+ image="path_to_image"
56
+ />
57
+ </Portal.Provider>
55
58
  );
56
59
 
57
60
  expect(getByText(title)).toBeTruthy();
@@ -0,0 +1,117 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Modal renders correctly 1`] = `
4
+ [
5
+ <View
6
+ collapsable={false}
7
+ style={
8
+ {
9
+ "backgroundColor": "#000000",
10
+ "bottom": 0,
11
+ "left": 0,
12
+ "opacity": 0.4,
13
+ "position": "absolute",
14
+ "right": 0,
15
+ "top": 0,
16
+ }
17
+ }
18
+ />,
19
+ <View
20
+ collapsable={false}
21
+ style={
22
+ {
23
+ "bottom": 0,
24
+ "left": 0,
25
+ "opacity": 1,
26
+ "position": "absolute",
27
+ "right": 0,
28
+ "top": 0,
29
+ "transform": [
30
+ {
31
+ "translateY": 0,
32
+ },
33
+ ],
34
+ }
35
+ }
36
+ >
37
+ <Text
38
+ allowFontScaling={false}
39
+ style={
40
+ [
41
+ {
42
+ "color": "#001f23",
43
+ "fontFamily": "BeVietnamPro-Regular",
44
+ "fontSize": 16,
45
+ "letterSpacing": 0.48,
46
+ "lineHeight": 24,
47
+ },
48
+ undefined,
49
+ ]
50
+ }
51
+ themeIntent="body"
52
+ themeTypeface="neutral"
53
+ themeVariant="regular"
54
+ >
55
+ Modal content
56
+ </Text>
57
+ </View>,
58
+ ]
59
+ `;
60
+
61
+ exports[`Modal renders correctly with transparent 1`] = `
62
+ [
63
+ <View
64
+ collapsable={false}
65
+ style={
66
+ {
67
+ "backgroundColor": "transparent",
68
+ "bottom": 0,
69
+ "left": 0,
70
+ "opacity": 0.4,
71
+ "position": "absolute",
72
+ "right": 0,
73
+ "top": 0,
74
+ }
75
+ }
76
+ />,
77
+ <View
78
+ collapsable={false}
79
+ style={
80
+ {
81
+ "bottom": 0,
82
+ "left": 0,
83
+ "opacity": 1,
84
+ "position": "absolute",
85
+ "right": 0,
86
+ "top": 0,
87
+ "transform": [
88
+ {
89
+ "translateY": 0,
90
+ },
91
+ ],
92
+ }
93
+ }
94
+ >
95
+ <Text
96
+ allowFontScaling={false}
97
+ style={
98
+ [
99
+ {
100
+ "color": "#001f23",
101
+ "fontFamily": "BeVietnamPro-Regular",
102
+ "fontSize": 16,
103
+ "letterSpacing": 0.48,
104
+ "lineHeight": 24,
105
+ },
106
+ undefined,
107
+ ]
108
+ }
109
+ themeIntent="body"
110
+ themeTypeface="neutral"
111
+ themeVariant="regular"
112
+ >
113
+ Modal content
114
+ </Text>
115
+ </View>,
116
+ ]
117
+ `;
@@ -0,0 +1,99 @@
1
+ import { fireEvent } from '@testing-library/react-native';
2
+ import React from 'react';
3
+ import { BackHandler } from 'react-native';
4
+ import Modal from '..';
5
+ import { Button } from '../../..';
6
+ import renderWithTheme from '../../../testHelpers/renderWithTheme';
7
+ import Portal from '../../Portal';
8
+ import Typography from '../../Typography';
9
+
10
+ describe('Modal', () => {
11
+ it('renders correctly', () => {
12
+ const wrapper = renderWithTheme(
13
+ <Portal.Provider>
14
+ <Modal visible>
15
+ <Typography.Body>Modal content</Typography.Body>
16
+ </Modal>
17
+ </Portal.Provider>
18
+ );
19
+
20
+ expect(wrapper.toJSON()).toMatchSnapshot();
21
+ });
22
+
23
+ it('renders correctly with transparent', () => {
24
+ const wrapper = renderWithTheme(
25
+ <Portal.Provider>
26
+ <Modal visible transparent>
27
+ <Typography.Body>Modal content</Typography.Body>
28
+ </Modal>
29
+ </Portal.Provider>
30
+ );
31
+
32
+ expect(wrapper.toJSON()).toMatchSnapshot();
33
+ });
34
+
35
+ it('trigger onShow callback correctly', () => {
36
+ const onShow = jest.fn();
37
+ renderWithTheme(
38
+ <Portal.Provider>
39
+ <Modal visible onShow={onShow}>
40
+ <Typography.Body>Modal content</Typography.Body>
41
+ </Modal>
42
+ </Portal.Provider>
43
+ );
44
+
45
+ expect(onShow).toBeCalledTimes(1);
46
+ });
47
+
48
+ it('trigger onRequestClose callback correctly', () => {
49
+ jest.mock('react-native/Libraries/Utilities/Platform', () => ({
50
+ OS: 'android',
51
+ select: () => null,
52
+ }));
53
+
54
+ const onRequestClose = jest.fn();
55
+ renderWithTheme(
56
+ <Portal.Provider>
57
+ <Modal visible onRequestClose={onRequestClose}>
58
+ <Typography.Body>Modal content</Typography.Body>
59
+ </Modal>
60
+ </Portal.Provider>
61
+ );
62
+
63
+ // @ts-expect-error: BackHandler mock
64
+ BackHandler.mockPressBack();
65
+ expect(onRequestClose).toBeCalled();
66
+ });
67
+
68
+ it('trigger onDismiss callback correctly', async () => {
69
+ jest.mock('react-native/Libraries/Utilities/Platform', () => ({
70
+ OS: 'ios',
71
+ select: () => null,
72
+ }));
73
+
74
+ const onDismiss = jest.fn();
75
+
76
+ const ModalExample = () => {
77
+ const [modalVisible, setModalVisible] = React.useState(true);
78
+
79
+ return (
80
+ <Portal.Provider>
81
+ <Modal
82
+ animationType="none"
83
+ visible={modalVisible}
84
+ onDismiss={onDismiss}
85
+ transparent
86
+ >
87
+ <Typography.Body>Modal content</Typography.Body>
88
+ <Button text="Close modal" onPress={() => setModalVisible(false)} />
89
+ </Modal>
90
+ </Portal.Provider>
91
+ );
92
+ };
93
+
94
+ const { getByText } = renderWithTheme(<ModalExample />);
95
+
96
+ fireEvent.press(getByText('Close modal'));
97
+ expect(onDismiss).toBeCalled();
98
+ });
99
+ });