@hero-design/rn 8.16.0 β 8.16.1
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/.turbo/turbo-build.log +9 -9
- package/es/index.js +28 -12
- package/lib/index.js +27 -11
- package/package.json +5 -5
- package/src/components/Error/StyledError.tsx +6 -0
- package/src/components/Error/__tests__/__snapshots__/index.spec.tsx.snap +183 -33
- package/src/components/Error/__tests__/index.spec.tsx +18 -0
- package/src/components/Error/index.tsx +38 -9
- package/types/components/Error/StyledError.d.ts +7 -1
- package/types/components/Error/index.d.ts +4 -3
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
[
|
|
2
|
-
[
|
|
3
|
-
[
|
|
4
|
-
[
|
|
5
|
-
[
|
|
6
|
-
[
|
|
7
|
-
[
|
|
8
|
-
[
|
|
9
|
-
[
|
|
1
|
+
[34m@hero-design/rn:build[0m: cache hit, replaying output [2mc5819fd205a488aa[0m
|
|
2
|
+
[34m@hero-design/rn:build: [0m$ yarn build:js && yarn build:types
|
|
3
|
+
[34m@hero-design/rn:build: [0m$ rollup -c
|
|
4
|
+
[34m@hero-design/rn:build: [0m[36m
|
|
5
|
+
[34m@hero-design/rn:build: [0m[1msrc/index.ts[22m β [1mlib/index.js, es/index.js[22m...[39m
|
|
6
|
+
[34m@hero-design/rn:build: [0m[1m[33m(!) Plugin replace: @rollup/plugin-replace: 'preventAssignment' currently defaults to false. It is recommended to set this option to `true`, as the next major version will default this option to `true`.[39m[22m
|
|
7
|
+
[34m@hero-design/rn:build: [0m[1m[33m(!) Plugin node-resolve: preferring built-in module 'events' over local alternative at '/root/hero-design/node_modules/events/events.js', pass 'preferBuiltins: false' to disable this behavior or 'preferBuiltins: true' to disable this warning[39m[22m
|
|
8
|
+
[34m@hero-design/rn:build: [0m[32mcreated [1mlib/index.js, es/index.js[22m in [1m26.7s[22m[39m
|
|
9
|
+
[34m@hero-design/rn:build: [0m$ tsc --noEmit false --emitDeclarationOnly --project tsconfig.prod.json
|
package/es/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as reactNative from 'react-native';
|
|
2
2
|
import { Platform, Dimensions, StyleSheet as StyleSheet$1, Animated, View, Easing, TouchableOpacity, Text as Text$1, Image as Image$1, TouchableWithoutFeedback, Pressable, SafeAreaView, KeyboardAvoidingView, TouchableHighlight, ScrollView, Modal, FlatList, useWindowDimensions, TextInput as TextInput$1, PanResponder, InteractionManager, Keyboard, SectionList, LayoutAnimation, RefreshControl as RefreshControl$1 } from 'react-native';
|
|
3
|
-
import React, { useContext, createContext, createElement, useMemo, forwardRef, useEffect, useCallback, useRef, useState, useLayoutEffect, useImperativeHandle } from 'react';
|
|
3
|
+
import React, { useContext, createContext, createElement, useMemo, forwardRef, useEffect, useCallback, useRef, useState, isValidElement, useLayoutEffect, useImperativeHandle } from 'react';
|
|
4
4
|
import { createIconSet } from 'react-native-vector-icons';
|
|
5
5
|
import { useSafeAreaInsets } from 'react-native-safe-area-context';
|
|
6
6
|
import DateTimePicker from '@react-native-community/datetimepicker';
|
|
@@ -12379,8 +12379,16 @@ var StyledErrorButtonSecondary = index$a(CompoundButton)(function (_ref5) {
|
|
|
12379
12379
|
padding: theme.__hd__.error.space.button.padding
|
|
12380
12380
|
};
|
|
12381
12381
|
});
|
|
12382
|
-
var
|
|
12382
|
+
var StyledErrorImageContainer = index$a(View)(function (_ref6) {
|
|
12383
12383
|
var theme = _ref6.theme;
|
|
12384
|
+
return {
|
|
12385
|
+
marginBottom: theme.__hd__.error.space.imageMarginBottom,
|
|
12386
|
+
width: theme.__hd__.error.sizes.image,
|
|
12387
|
+
height: theme.__hd__.error.sizes.image
|
|
12388
|
+
};
|
|
12389
|
+
});
|
|
12390
|
+
var StyledErrorImage = index$a(Image)(function (_ref7) {
|
|
12391
|
+
var theme = _ref7.theme;
|
|
12384
12392
|
return {
|
|
12385
12393
|
marginBottom: theme.__hd__.error.space.imageMarginBottom,
|
|
12386
12394
|
width: theme.__hd__.error.sizes.image,
|
|
@@ -12388,8 +12396,8 @@ var StyledErrorImage = index$a(Image)(function (_ref6) {
|
|
|
12388
12396
|
resizeMode: 'contain'
|
|
12389
12397
|
};
|
|
12390
12398
|
});
|
|
12391
|
-
var StyledErrorTitle = index$a(Typography.Text)(function (
|
|
12392
|
-
var theme =
|
|
12399
|
+
var StyledErrorTitle = index$a(Typography.Text)(function (_ref8) {
|
|
12400
|
+
var theme = _ref8.theme;
|
|
12393
12401
|
return {
|
|
12394
12402
|
fontFamily: theme.__hd__.error.fonts.title,
|
|
12395
12403
|
fontSize: theme.__hd__.error.fontSizes.title,
|
|
@@ -12398,8 +12406,8 @@ var StyledErrorTitle = index$a(Typography.Text)(function (_ref7) {
|
|
|
12398
12406
|
color: theme.__hd__.error.colors.title
|
|
12399
12407
|
};
|
|
12400
12408
|
});
|
|
12401
|
-
var StyledErrorDescription = index$a(Typography.Text)(function (
|
|
12402
|
-
var theme =
|
|
12409
|
+
var StyledErrorDescription = index$a(Typography.Text)(function (_ref9) {
|
|
12410
|
+
var theme = _ref9.theme;
|
|
12403
12411
|
return {
|
|
12404
12412
|
fontFamily: theme.__hd__.error.fonts.description,
|
|
12405
12413
|
fontSize: theme.__hd__.error.fontSizes.description,
|
|
@@ -12410,6 +12418,19 @@ var StyledErrorDescription = index$a(Typography.Text)(function (_ref8) {
|
|
|
12410
12418
|
|
|
12411
12419
|
var _excluded$a = ["variant", "title", "description", "image", "testID", "ctaText", "onCtaPress", "secondaryCtaText", "onSecondaryCtaPress"],
|
|
12412
12420
|
_excluded2 = ["visible", "variant", "title", "description", "image", "testID", "ctaText", "onCtaPress", "secondaryCtaText", "onSecondaryCtaPress"];
|
|
12421
|
+
var renderImage = function renderImage(image) {
|
|
12422
|
+
if ( /*#__PURE__*/isValidElement(image)) {
|
|
12423
|
+
return /*#__PURE__*/React.cloneElement(image, {
|
|
12424
|
+
testID: 'error-image'
|
|
12425
|
+
});
|
|
12426
|
+
}
|
|
12427
|
+
return /*#__PURE__*/React.createElement(StyledErrorImage, {
|
|
12428
|
+
source: typeof image === 'string' ? {
|
|
12429
|
+
uri: image
|
|
12430
|
+
} : image,
|
|
12431
|
+
testID: "error-image"
|
|
12432
|
+
});
|
|
12433
|
+
};
|
|
12413
12434
|
var ErrorPage = function ErrorPage(_ref) {
|
|
12414
12435
|
var _ref$variant = _ref.variant,
|
|
12415
12436
|
variant = _ref$variant === void 0 ? 'in-page' : _ref$variant,
|
|
@@ -12428,12 +12449,7 @@ var ErrorPage = function ErrorPage(_ref) {
|
|
|
12428
12449
|
return /*#__PURE__*/React.createElement(StyledErrorContainer$1, {
|
|
12429
12450
|
testID: testID,
|
|
12430
12451
|
themeVariant: variant
|
|
12431
|
-
}, /*#__PURE__*/React.createElement(StyledErrorContent, nativeProps, image && /*#__PURE__*/React.createElement(
|
|
12432
|
-
source: typeof image === 'string' ? {
|
|
12433
|
-
uri: image
|
|
12434
|
-
} : image,
|
|
12435
|
-
testID: "error-image"
|
|
12436
|
-
}), /*#__PURE__*/React.createElement(StyledErrorTitle, null, title), description && /*#__PURE__*/React.createElement(StyledErrorDescription, null, description)), showButtonContainer && /*#__PURE__*/React.createElement(StyledErrorButtonContainer, null, showCta && /*#__PURE__*/React.createElement(StyledErrorButtonPrimary, {
|
|
12452
|
+
}, /*#__PURE__*/React.createElement(StyledErrorContent, nativeProps, image && /*#__PURE__*/React.createElement(StyledErrorImageContainer, null, renderImage(image)), /*#__PURE__*/React.createElement(StyledErrorTitle, null, title), description && /*#__PURE__*/React.createElement(StyledErrorDescription, null, description)), showButtonContainer && /*#__PURE__*/React.createElement(StyledErrorButtonContainer, null, showCta && /*#__PURE__*/React.createElement(StyledErrorButtonPrimary, {
|
|
12437
12453
|
variant: "filled",
|
|
12438
12454
|
text: ctaText,
|
|
12439
12455
|
onPress: onCtaPress
|
package/lib/index.js
CHANGED
|
@@ -12408,8 +12408,16 @@ var StyledErrorButtonSecondary = index$a(CompoundButton)(function (_ref5) {
|
|
|
12408
12408
|
padding: theme.__hd__.error.space.button.padding
|
|
12409
12409
|
};
|
|
12410
12410
|
});
|
|
12411
|
-
var
|
|
12411
|
+
var StyledErrorImageContainer = index$a(reactNative.View)(function (_ref6) {
|
|
12412
12412
|
var theme = _ref6.theme;
|
|
12413
|
+
return {
|
|
12414
|
+
marginBottom: theme.__hd__.error.space.imageMarginBottom,
|
|
12415
|
+
width: theme.__hd__.error.sizes.image,
|
|
12416
|
+
height: theme.__hd__.error.sizes.image
|
|
12417
|
+
};
|
|
12418
|
+
});
|
|
12419
|
+
var StyledErrorImage = index$a(Image)(function (_ref7) {
|
|
12420
|
+
var theme = _ref7.theme;
|
|
12413
12421
|
return {
|
|
12414
12422
|
marginBottom: theme.__hd__.error.space.imageMarginBottom,
|
|
12415
12423
|
width: theme.__hd__.error.sizes.image,
|
|
@@ -12417,8 +12425,8 @@ var StyledErrorImage = index$a(Image)(function (_ref6) {
|
|
|
12417
12425
|
resizeMode: 'contain'
|
|
12418
12426
|
};
|
|
12419
12427
|
});
|
|
12420
|
-
var StyledErrorTitle = index$a(Typography.Text)(function (
|
|
12421
|
-
var theme =
|
|
12428
|
+
var StyledErrorTitle = index$a(Typography.Text)(function (_ref8) {
|
|
12429
|
+
var theme = _ref8.theme;
|
|
12422
12430
|
return {
|
|
12423
12431
|
fontFamily: theme.__hd__.error.fonts.title,
|
|
12424
12432
|
fontSize: theme.__hd__.error.fontSizes.title,
|
|
@@ -12427,8 +12435,8 @@ var StyledErrorTitle = index$a(Typography.Text)(function (_ref7) {
|
|
|
12427
12435
|
color: theme.__hd__.error.colors.title
|
|
12428
12436
|
};
|
|
12429
12437
|
});
|
|
12430
|
-
var StyledErrorDescription = index$a(Typography.Text)(function (
|
|
12431
|
-
var theme =
|
|
12438
|
+
var StyledErrorDescription = index$a(Typography.Text)(function (_ref9) {
|
|
12439
|
+
var theme = _ref9.theme;
|
|
12432
12440
|
return {
|
|
12433
12441
|
fontFamily: theme.__hd__.error.fonts.description,
|
|
12434
12442
|
fontSize: theme.__hd__.error.fontSizes.description,
|
|
@@ -12439,6 +12447,19 @@ var StyledErrorDescription = index$a(Typography.Text)(function (_ref8) {
|
|
|
12439
12447
|
|
|
12440
12448
|
var _excluded$a = ["variant", "title", "description", "image", "testID", "ctaText", "onCtaPress", "secondaryCtaText", "onSecondaryCtaPress"],
|
|
12441
12449
|
_excluded2 = ["visible", "variant", "title", "description", "image", "testID", "ctaText", "onCtaPress", "secondaryCtaText", "onSecondaryCtaPress"];
|
|
12450
|
+
var renderImage = function renderImage(image) {
|
|
12451
|
+
if ( /*#__PURE__*/React.isValidElement(image)) {
|
|
12452
|
+
return /*#__PURE__*/React__default["default"].cloneElement(image, {
|
|
12453
|
+
testID: 'error-image'
|
|
12454
|
+
});
|
|
12455
|
+
}
|
|
12456
|
+
return /*#__PURE__*/React__default["default"].createElement(StyledErrorImage, {
|
|
12457
|
+
source: typeof image === 'string' ? {
|
|
12458
|
+
uri: image
|
|
12459
|
+
} : image,
|
|
12460
|
+
testID: "error-image"
|
|
12461
|
+
});
|
|
12462
|
+
};
|
|
12442
12463
|
var ErrorPage = function ErrorPage(_ref) {
|
|
12443
12464
|
var _ref$variant = _ref.variant,
|
|
12444
12465
|
variant = _ref$variant === void 0 ? 'in-page' : _ref$variant,
|
|
@@ -12457,12 +12478,7 @@ var ErrorPage = function ErrorPage(_ref) {
|
|
|
12457
12478
|
return /*#__PURE__*/React__default["default"].createElement(StyledErrorContainer$1, {
|
|
12458
12479
|
testID: testID,
|
|
12459
12480
|
themeVariant: variant
|
|
12460
|
-
}, /*#__PURE__*/React__default["default"].createElement(StyledErrorContent, nativeProps, image && /*#__PURE__*/React__default["default"].createElement(
|
|
12461
|
-
source: typeof image === 'string' ? {
|
|
12462
|
-
uri: image
|
|
12463
|
-
} : image,
|
|
12464
|
-
testID: "error-image"
|
|
12465
|
-
}), /*#__PURE__*/React__default["default"].createElement(StyledErrorTitle, null, title), description && /*#__PURE__*/React__default["default"].createElement(StyledErrorDescription, null, description)), showButtonContainer && /*#__PURE__*/React__default["default"].createElement(StyledErrorButtonContainer, null, showCta && /*#__PURE__*/React__default["default"].createElement(StyledErrorButtonPrimary, {
|
|
12481
|
+
}, /*#__PURE__*/React__default["default"].createElement(StyledErrorContent, nativeProps, image && /*#__PURE__*/React__default["default"].createElement(StyledErrorImageContainer, null, renderImage(image)), /*#__PURE__*/React__default["default"].createElement(StyledErrorTitle, null, title), description && /*#__PURE__*/React__default["default"].createElement(StyledErrorDescription, null, description)), showButtonContainer && /*#__PURE__*/React__default["default"].createElement(StyledErrorButtonContainer, null, showCta && /*#__PURE__*/React__default["default"].createElement(StyledErrorButtonPrimary, {
|
|
12466
12482
|
variant: "filled",
|
|
12467
12483
|
text: ctaText,
|
|
12468
12484
|
onPress: onCtaPress
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hero-design/rn",
|
|
3
|
-
"version": "8.16.
|
|
3
|
+
"version": "8.16.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "es/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@emotion/native": "^11.9.3",
|
|
23
23
|
"@emotion/react": "^11.9.3",
|
|
24
|
-
"@hero-design/colors": "8.16.
|
|
24
|
+
"@hero-design/colors": "8.16.1",
|
|
25
25
|
"date-fns": "^2.16.1",
|
|
26
26
|
"events": "^3.2.0",
|
|
27
27
|
"hero-editor": "^1.9.21"
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"@babel/preset-typescript": "^7.17.12",
|
|
45
45
|
"@babel/runtime": "^7.18.9",
|
|
46
46
|
"@emotion/jest": "^11.9.3",
|
|
47
|
-
"@hero-design/eslint-plugin": "8.16.
|
|
47
|
+
"@hero-design/eslint-plugin": "8.16.1",
|
|
48
48
|
"@react-native-community/datetimepicker": "^3.5.2",
|
|
49
49
|
"@react-native-community/slider": "4.1.12",
|
|
50
50
|
"@rollup/plugin-babel": "^5.3.1",
|
|
@@ -60,9 +60,9 @@
|
|
|
60
60
|
"@types/react-native": "^0.67.7",
|
|
61
61
|
"@types/react-native-vector-icons": "^6.4.10",
|
|
62
62
|
"babel-plugin-inline-import": "^3.0.0",
|
|
63
|
-
"eslint-config-hd": "8.16.
|
|
63
|
+
"eslint-config-hd": "8.16.1",
|
|
64
64
|
"jest": "^27.3.1",
|
|
65
|
-
"prettier-config-hd": "8.16.
|
|
65
|
+
"prettier-config-hd": "8.16.1",
|
|
66
66
|
"react": "18.0.0",
|
|
67
67
|
"react-native": "0.69.7",
|
|
68
68
|
"react-native-gesture-handler": "~2.1.0",
|
|
@@ -50,6 +50,11 @@ const StyledErrorButtonSecondary = styled(Button)(({ theme }) => ({
|
|
|
50
50
|
padding: theme.__hd__.error.space.button.padding,
|
|
51
51
|
}));
|
|
52
52
|
|
|
53
|
+
const StyledErrorImageContainer = styled(View)(({ theme }) => ({
|
|
54
|
+
marginBottom: theme.__hd__.error.space.imageMarginBottom,
|
|
55
|
+
width: theme.__hd__.error.sizes.image,
|
|
56
|
+
height: theme.__hd__.error.sizes.image,
|
|
57
|
+
}));
|
|
53
58
|
const StyledErrorImage = styled(Image)(({ theme }) => ({
|
|
54
59
|
marginBottom: theme.__hd__.error.space.imageMarginBottom,
|
|
55
60
|
width: theme.__hd__.error.sizes.image,
|
|
@@ -83,4 +88,5 @@ export {
|
|
|
83
88
|
StyledErrorContent,
|
|
84
89
|
StyledErrorTitle,
|
|
85
90
|
StyledErrorDescription,
|
|
91
|
+
StyledErrorImageContainer,
|
|
86
92
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
2
|
|
|
3
|
-
exports[`Error renders error screen with image correctly 1`] = `
|
|
3
|
+
exports[`Error renders error screen with custom image element correctly 1`] = `
|
|
4
4
|
<View
|
|
5
5
|
style={
|
|
6
6
|
Array [
|
|
@@ -30,32 +30,169 @@ exports[`Error renders error screen with image correctly 1`] = `
|
|
|
30
30
|
]
|
|
31
31
|
}
|
|
32
32
|
>
|
|
33
|
-
<
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
<View
|
|
34
|
+
style={
|
|
35
|
+
Array [
|
|
36
|
+
Object {
|
|
37
|
+
"height": 176,
|
|
38
|
+
"marginBottom": 32,
|
|
39
|
+
"width": 176,
|
|
40
|
+
},
|
|
41
|
+
undefined,
|
|
42
|
+
]
|
|
43
|
+
}
|
|
44
|
+
>
|
|
45
|
+
<Image
|
|
46
|
+
source={
|
|
47
|
+
Object {
|
|
48
|
+
"uri": "path_to_image",
|
|
49
|
+
}
|
|
37
50
|
}
|
|
51
|
+
style={
|
|
52
|
+
Array [
|
|
53
|
+
Object {
|
|
54
|
+
"borderRadius": 0,
|
|
55
|
+
"height": 72,
|
|
56
|
+
"width": 72,
|
|
57
|
+
},
|
|
58
|
+
undefined,
|
|
59
|
+
]
|
|
60
|
+
}
|
|
61
|
+
testID="error-image"
|
|
62
|
+
/>
|
|
63
|
+
</View>
|
|
64
|
+
<Text
|
|
65
|
+
allowFontScaling={false}
|
|
66
|
+
style={
|
|
67
|
+
Array [
|
|
68
|
+
Object {
|
|
69
|
+
"color": "#001f23",
|
|
70
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
71
|
+
"fontSize": 14,
|
|
72
|
+
"letterSpacing": 0.42,
|
|
73
|
+
"lineHeight": 22,
|
|
74
|
+
},
|
|
75
|
+
Array [
|
|
76
|
+
Object {
|
|
77
|
+
"color": "#001f23",
|
|
78
|
+
"fontFamily": "RebondGrotesque-SemiBold",
|
|
79
|
+
"fontSize": 24,
|
|
80
|
+
"marginBottom": 8,
|
|
81
|
+
"textAlign": "center",
|
|
82
|
+
},
|
|
83
|
+
undefined,
|
|
84
|
+
],
|
|
85
|
+
]
|
|
38
86
|
}
|
|
87
|
+
themeFontSize="medium"
|
|
88
|
+
themeFontWeight="regular"
|
|
89
|
+
themeIntent="body"
|
|
90
|
+
themeTypeface="neutral"
|
|
91
|
+
>
|
|
92
|
+
Weβre sorry, something went wrong
|
|
93
|
+
</Text>
|
|
94
|
+
<Text
|
|
95
|
+
allowFontScaling={false}
|
|
39
96
|
style={
|
|
40
97
|
Array [
|
|
41
98
|
Object {
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
99
|
+
"color": "#001f23",
|
|
100
|
+
"fontFamily": "BeVietnamPro-Regular",
|
|
101
|
+
"fontSize": 14,
|
|
102
|
+
"letterSpacing": 0.42,
|
|
103
|
+
"lineHeight": 22,
|
|
45
104
|
},
|
|
46
105
|
Array [
|
|
47
106
|
Object {
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
107
|
+
"color": "#4d6265",
|
|
108
|
+
"fontFamily": "RebondGrotesque",
|
|
109
|
+
"fontSize": 18,
|
|
110
|
+
"textAlign": "center",
|
|
52
111
|
},
|
|
53
112
|
undefined,
|
|
54
113
|
],
|
|
55
114
|
]
|
|
56
115
|
}
|
|
57
|
-
|
|
58
|
-
|
|
116
|
+
themeFontSize="medium"
|
|
117
|
+
themeFontWeight="regular"
|
|
118
|
+
themeIntent="body"
|
|
119
|
+
themeTypeface="neutral"
|
|
120
|
+
>
|
|
121
|
+
Please try again later
|
|
122
|
+
</Text>
|
|
123
|
+
</View>
|
|
124
|
+
</View>
|
|
125
|
+
`;
|
|
126
|
+
|
|
127
|
+
exports[`Error renders error screen with image correctly 1`] = `
|
|
128
|
+
<View
|
|
129
|
+
style={
|
|
130
|
+
Array [
|
|
131
|
+
Object {
|
|
132
|
+
"backgroundColor": "#f6f6f7",
|
|
133
|
+
"display": "flex",
|
|
134
|
+
"flex": 1,
|
|
135
|
+
"flexDirection": "column",
|
|
136
|
+
},
|
|
137
|
+
undefined,
|
|
138
|
+
]
|
|
139
|
+
}
|
|
140
|
+
themeVariant="in-page"
|
|
141
|
+
>
|
|
142
|
+
<View
|
|
143
|
+
style={
|
|
144
|
+
Array [
|
|
145
|
+
Object {
|
|
146
|
+
"alignItems": "center",
|
|
147
|
+
"display": "flex",
|
|
148
|
+
"flex": 1,
|
|
149
|
+
"flexDirection": "column",
|
|
150
|
+
"justifyContent": "center",
|
|
151
|
+
"padding": 24,
|
|
152
|
+
},
|
|
153
|
+
undefined,
|
|
154
|
+
]
|
|
155
|
+
}
|
|
156
|
+
>
|
|
157
|
+
<View
|
|
158
|
+
style={
|
|
159
|
+
Array [
|
|
160
|
+
Object {
|
|
161
|
+
"height": 176,
|
|
162
|
+
"marginBottom": 32,
|
|
163
|
+
"width": 176,
|
|
164
|
+
},
|
|
165
|
+
undefined,
|
|
166
|
+
]
|
|
167
|
+
}
|
|
168
|
+
>
|
|
169
|
+
<Image
|
|
170
|
+
source={
|
|
171
|
+
Object {
|
|
172
|
+
"uri": "path_to_image",
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
style={
|
|
176
|
+
Array [
|
|
177
|
+
Object {
|
|
178
|
+
"borderRadius": 0,
|
|
179
|
+
"height": 72,
|
|
180
|
+
"width": 72,
|
|
181
|
+
},
|
|
182
|
+
Array [
|
|
183
|
+
Object {
|
|
184
|
+
"height": 176,
|
|
185
|
+
"marginBottom": 32,
|
|
186
|
+
"resizeMode": "contain",
|
|
187
|
+
"width": 176,
|
|
188
|
+
},
|
|
189
|
+
undefined,
|
|
190
|
+
],
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
testID="error-image"
|
|
194
|
+
/>
|
|
195
|
+
</View>
|
|
59
196
|
<Text
|
|
60
197
|
allowFontScaling={false}
|
|
61
198
|
style={
|
|
@@ -165,32 +302,45 @@ exports[`Error renders full screen error page correctly 1`] = `
|
|
|
165
302
|
]
|
|
166
303
|
}
|
|
167
304
|
>
|
|
168
|
-
<
|
|
169
|
-
source={
|
|
170
|
-
Object {
|
|
171
|
-
"uri": "path_to_image",
|
|
172
|
-
}
|
|
173
|
-
}
|
|
305
|
+
<View
|
|
174
306
|
style={
|
|
175
307
|
Array [
|
|
176
308
|
Object {
|
|
177
|
-
"
|
|
178
|
-
"
|
|
179
|
-
"width":
|
|
309
|
+
"height": 176,
|
|
310
|
+
"marginBottom": 32,
|
|
311
|
+
"width": 176,
|
|
180
312
|
},
|
|
313
|
+
undefined,
|
|
314
|
+
]
|
|
315
|
+
}
|
|
316
|
+
>
|
|
317
|
+
<Image
|
|
318
|
+
source={
|
|
319
|
+
Object {
|
|
320
|
+
"uri": "path_to_image",
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
style={
|
|
181
324
|
Array [
|
|
182
325
|
Object {
|
|
183
|
-
"
|
|
184
|
-
"
|
|
185
|
-
"
|
|
186
|
-
"width": 176,
|
|
326
|
+
"borderRadius": 0,
|
|
327
|
+
"height": 72,
|
|
328
|
+
"width": 72,
|
|
187
329
|
},
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
330
|
+
Array [
|
|
331
|
+
Object {
|
|
332
|
+
"height": 176,
|
|
333
|
+
"marginBottom": 32,
|
|
334
|
+
"resizeMode": "contain",
|
|
335
|
+
"width": 176,
|
|
336
|
+
},
|
|
337
|
+
undefined,
|
|
338
|
+
],
|
|
339
|
+
]
|
|
340
|
+
}
|
|
341
|
+
testID="error-image"
|
|
342
|
+
/>
|
|
343
|
+
</View>
|
|
194
344
|
<Text
|
|
195
345
|
allowFontScaling={false}
|
|
196
346
|
style={
|
|
@@ -2,6 +2,7 @@ import React from 'react';
|
|
|
2
2
|
import { fireEvent } from '@testing-library/react-native';
|
|
3
3
|
import renderWithTheme from '../../../testHelpers/renderWithTheme';
|
|
4
4
|
import Error from '..';
|
|
5
|
+
import Image from '../../Image';
|
|
5
6
|
|
|
6
7
|
const title = `Weβre sorry, something went wrong`;
|
|
7
8
|
const description = 'Please try again later';
|
|
@@ -26,6 +27,23 @@ describe('Error', () => {
|
|
|
26
27
|
expect(getByTestId('error-image')).toBeTruthy();
|
|
27
28
|
expect(toJSON()).toMatchSnapshot();
|
|
28
29
|
});
|
|
30
|
+
it('renders error screen with custom image element correctly', () => {
|
|
31
|
+
const image = (
|
|
32
|
+
<Image
|
|
33
|
+
source={{
|
|
34
|
+
uri: 'path_to_image',
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
);
|
|
38
|
+
const { toJSON, getByText, getByTestId } = renderWithTheme(
|
|
39
|
+
<Error title={title} description={description} image={image} />
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
expect(getByText(title)).toBeTruthy();
|
|
43
|
+
expect(getByText(description)).toBeTruthy();
|
|
44
|
+
expect(getByTestId('error-image')).toBeTruthy();
|
|
45
|
+
expect(toJSON()).toMatchSnapshot();
|
|
46
|
+
});
|
|
29
47
|
it('renders full screen error page correctly', () => {
|
|
30
48
|
const { toJSON, getByText, getByTestId } = renderWithTheme(
|
|
31
49
|
<Error
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import React, {
|
|
2
|
+
ReactElement,
|
|
3
|
+
isValidElement,
|
|
4
|
+
useCallback,
|
|
5
|
+
useEffect,
|
|
6
|
+
useState,
|
|
7
|
+
} from 'react';
|
|
8
|
+
import type {
|
|
9
|
+
ImageSourcePropType,
|
|
10
|
+
ViewProps,
|
|
11
|
+
ImageProps as RNImageProps,
|
|
12
|
+
} from 'react-native';
|
|
4
13
|
import {
|
|
5
14
|
ErrorVariant,
|
|
6
15
|
StyledErrorButtonContainer,
|
|
@@ -10,10 +19,12 @@ import {
|
|
|
10
19
|
StyledErrorContent,
|
|
11
20
|
StyledErrorDescription,
|
|
12
21
|
StyledErrorImage,
|
|
22
|
+
StyledErrorImageContainer,
|
|
13
23
|
StyledErrorModal,
|
|
14
24
|
StyledErrorTitle,
|
|
15
25
|
} from './StyledError';
|
|
16
26
|
import { useDeprecation } from '../../utils/hooks';
|
|
27
|
+
import { ImageProps } from '../Image/index';
|
|
17
28
|
|
|
18
29
|
interface ErrorProps extends ViewProps {
|
|
19
30
|
/**
|
|
@@ -37,7 +48,10 @@ interface ErrorProps extends ViewProps {
|
|
|
37
48
|
/**
|
|
38
49
|
* Image of the error
|
|
39
50
|
*/
|
|
40
|
-
image?:
|
|
51
|
+
image?:
|
|
52
|
+
| ReactElement<ImageProps | RNImageProps>
|
|
53
|
+
| ImageSourcePropType
|
|
54
|
+
| string;
|
|
41
55
|
/**
|
|
42
56
|
* Testing id of the component.
|
|
43
57
|
*/
|
|
@@ -62,6 +76,23 @@ interface ErrorProps extends ViewProps {
|
|
|
62
76
|
|
|
63
77
|
type onCloseCallbackType = 'cta' | 'secondaryCta' | null;
|
|
64
78
|
|
|
79
|
+
const renderImage = (
|
|
80
|
+
image: ReactElement<ImageProps | RNImageProps> | ImageSourcePropType | string
|
|
81
|
+
) => {
|
|
82
|
+
if (isValidElement(image)) {
|
|
83
|
+
return React.cloneElement(image, {
|
|
84
|
+
testID: 'error-image',
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<StyledErrorImage
|
|
90
|
+
source={typeof image === 'string' ? { uri: image } : image}
|
|
91
|
+
testID="error-image"
|
|
92
|
+
/>
|
|
93
|
+
);
|
|
94
|
+
};
|
|
95
|
+
|
|
65
96
|
const ErrorPage = ({
|
|
66
97
|
variant = 'in-page',
|
|
67
98
|
title,
|
|
@@ -82,12 +113,10 @@ const ErrorPage = ({
|
|
|
82
113
|
<StyledErrorContainer testID={testID} themeVariant={variant}>
|
|
83
114
|
<StyledErrorContent {...nativeProps}>
|
|
84
115
|
{image && (
|
|
85
|
-
<
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
/>
|
|
116
|
+
<StyledErrorImageContainer>
|
|
117
|
+
{renderImage(image)}
|
|
118
|
+
</StyledErrorImageContainer>
|
|
89
119
|
)}
|
|
90
|
-
|
|
91
120
|
<StyledErrorTitle>{title}</StyledErrorTitle>
|
|
92
121
|
|
|
93
122
|
{description && (
|
|
@@ -39,6 +39,12 @@ declare const StyledErrorButtonSecondary: import("@emotion/native").StyledCompon
|
|
|
39
39
|
theme?: import("@emotion/react").Theme | undefined;
|
|
40
40
|
as?: import("react").ElementType<any> | undefined;
|
|
41
41
|
}, {}, {}>;
|
|
42
|
+
declare const StyledErrorImageContainer: import("@emotion/native").StyledComponent<import("react-native").ViewProps & {
|
|
43
|
+
theme?: import("@emotion/react").Theme | undefined;
|
|
44
|
+
as?: import("react").ElementType<any> | undefined;
|
|
45
|
+
}, {}, {
|
|
46
|
+
ref?: import("react").Ref<View> | undefined;
|
|
47
|
+
}>;
|
|
42
48
|
declare const StyledErrorImage: import("@emotion/native").StyledComponent<import("../Image").ImageProps & {
|
|
43
49
|
theme?: import("@emotion/react").Theme | undefined;
|
|
44
50
|
as?: import("react").ElementType<any> | undefined;
|
|
@@ -51,4 +57,4 @@ declare const StyledErrorDescription: import("@emotion/native").StyledComponent<
|
|
|
51
57
|
theme?: import("@emotion/react").Theme | undefined;
|
|
52
58
|
as?: import("react").ElementType<any> | undefined;
|
|
53
59
|
}, {}, {}>;
|
|
54
|
-
export { ErrorVariant, StyledErrorModal, StyledErrorImage, StyledErrorContainer, StyledErrorButtonContainer, StyledErrorButtonPrimary, StyledErrorButtonSecondary, StyledErrorContent, StyledErrorTitle, StyledErrorDescription, };
|
|
60
|
+
export { ErrorVariant, StyledErrorModal, StyledErrorImage, StyledErrorContainer, StyledErrorButtonContainer, StyledErrorButtonPrimary, StyledErrorButtonSecondary, StyledErrorContent, StyledErrorTitle, StyledErrorDescription, StyledErrorImageContainer, };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import type { ImageSourcePropType, ViewProps } from 'react-native';
|
|
1
|
+
import { ReactElement } from 'react';
|
|
2
|
+
import type { ImageSourcePropType, ViewProps, ImageProps as RNImageProps } from 'react-native';
|
|
3
3
|
import { ErrorVariant } from './StyledError';
|
|
4
|
+
import { ImageProps } from '../Image/index';
|
|
4
5
|
interface ErrorProps extends ViewProps {
|
|
5
6
|
/**
|
|
6
7
|
* @deprecated use conditional rendering instead
|
|
@@ -23,7 +24,7 @@ interface ErrorProps extends ViewProps {
|
|
|
23
24
|
/**
|
|
24
25
|
* Image of the error
|
|
25
26
|
*/
|
|
26
|
-
image?: ImageSourcePropType | string;
|
|
27
|
+
image?: ReactElement<ImageProps | RNImageProps> | ImageSourcePropType | string;
|
|
27
28
|
/**
|
|
28
29
|
* Testing id of the component.
|
|
29
30
|
*/
|