@janiscommerce/ui-native 1.24.0 → 1.25.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.
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const ErrorFallback: React.FC;
3
+ export default ErrorFallback;
@@ -0,0 +1,24 @@
1
+ import React from 'react';
2
+ import Typography from '../../../../atoms/Typography';
3
+ import { StyleSheet, View } from 'react-native';
4
+ import { palette } from '../../../../../theme/palette';
5
+ import Icon from '../../../../atoms/Icon';
6
+ const styles = StyleSheet.create({
7
+ container: {
8
+ flexDirection: 'row',
9
+ alignItems: 'center',
10
+ },
11
+ errorMessageText: {
12
+ marginLeft: 4,
13
+ color: palette.error.main,
14
+ },
15
+ });
16
+ const ErrorFallback = () => {
17
+ return (<View style={styles.container}>
18
+ <Icon name="exclamation_circle" color={palette.error.main} size={20}/>
19
+ <Typography type="body" size="medium" style={styles.errorMessageText}>
20
+ Something went wrong.
21
+ </Typography>
22
+ </View>);
23
+ };
24
+ export default ErrorFallback;
@@ -1,8 +1,6 @@
1
1
  import React, { ReactNode } from 'react';
2
2
  interface ErrorBoundaryProps {
3
3
  children: ReactNode;
4
- isDebug?: boolean;
5
- errorMessage?: string;
6
4
  renderErrorComponent?: (errorMessage: string) => ReactNode;
7
5
  onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
8
6
  onMount?: () => void;
@@ -29,7 +29,7 @@ class ErrorBoundary extends React.Component {
29
29
  if (typeof renderErrorComponent === 'function') {
30
30
  return renderErrorComponent(this.state.error?.message || '');
31
31
  }
32
- return (<ErrorFallback isDebug={this.props.isDebug} errorMessage={this.props.errorMessage} error={this.state.error?.message} errorDetails={this.state.errorInfo?.componentStack}/>);
32
+ return <ErrorFallback />;
33
33
  }
34
34
  return this.props.children;
35
35
  }
package/dist/index.d.ts CHANGED
@@ -30,7 +30,7 @@ import BaseDetail from './components/molecules/BaseDetail';
30
30
  import LoadingFullScreen from './components/organisms/LoadingFullScreen';
31
31
  import FullScreenMessage from './components/organisms/FullScreenMessage';
32
32
  import SwipeItemSelectionList from './components/organisms/SwipeItemSelectionList';
33
- import ErrorBoundary from './components/organisms/ErrorBoundary';
33
+ import ErrorBoundary from './components/molecules/ErrorBoundary';
34
34
  import ProductDetail from './components/organisms/ProductDetail';
35
35
  import { palette } from './theme/palette';
36
36
  import * as getScale from './scale';
package/dist/index.js CHANGED
@@ -33,7 +33,7 @@ import BaseDetail from './components/molecules/BaseDetail';
33
33
  import LoadingFullScreen from './components/organisms/LoadingFullScreen';
34
34
  import FullScreenMessage from './components/organisms/FullScreenMessage';
35
35
  import SwipeItemSelectionList from './components/organisms/SwipeItemSelectionList';
36
- import ErrorBoundary from './components/organisms/ErrorBoundary';
36
+ import ErrorBoundary from './components/molecules/ErrorBoundary';
37
37
  import ProductDetail from './components/organisms/ProductDetail';
38
38
  // Misc
39
39
  import { palette } from './theme/palette';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janiscommerce/ui-native",
3
- "version": "1.24.0",
3
+ "version": "1.25.0",
4
4
  "description": "components library for Janis app",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -1,9 +0,0 @@
1
- import React from 'react';
2
- interface ErrorFallbackProps {
3
- error?: string;
4
- errorDetails?: string;
5
- isDebug?: boolean;
6
- errorMessage?: string;
7
- }
8
- declare const ErrorFallback: React.FC<ErrorFallbackProps>;
9
- export default ErrorFallback;
@@ -1,81 +0,0 @@
1
- import React from 'react';
2
- import Collapsible from '../../../../atoms/Collapsible';
3
- import Typography from '../../../../atoms/Typography';
4
- import { StyleSheet, TouchableOpacity, View } from 'react-native';
5
- import { palette } from '../../../../../theme/palette';
6
- const styles = StyleSheet.create({
7
- container: {
8
- flex: 1,
9
- justifyContent: 'center',
10
- alignItems: 'center',
11
- backgroundColor: palette.white.light,
12
- padding: 30,
13
- borderRadius: 12,
14
- margin: 16,
15
- shadowColor: palette.base.black,
16
- shadowOffset: { width: 0, height: 2 },
17
- shadowOpacity: 0.2,
18
- shadowRadius: 4,
19
- elevation: 5,
20
- },
21
- errorMessageText: {
22
- textAlign: 'center',
23
- color: palette.error.main,
24
- },
25
- showErrorButton: {
26
- paddingVertical: 10,
27
- paddingHorizontal: 20,
28
- justifyContent: 'center',
29
- alignItems: 'center',
30
- backgroundColor: palette.error.main,
31
- borderRadius: 6,
32
- marginVertical: 12,
33
- },
34
- collapsibleWrapper: {
35
- marginBottom: 35,
36
- },
37
- errorDetails: {
38
- padding: 10,
39
- backgroundColor: palette.black.main,
40
- borderRadius: 8,
41
- marginVertical: 10,
42
- },
43
- heading: {
44
- marginBottom: 12,
45
- },
46
- goBackButtonWrapper: {
47
- marginTop: 20,
48
- },
49
- });
50
- const ShowErrorDetailsButton = () => {
51
- return (<View style={styles.showErrorButton}>
52
- <Typography color={palette.base.white}>Show error details</Typography>
53
- </View>);
54
- };
55
- const ErrorDetails = ({ errorDetails }) => {
56
- return (<View style={styles.errorDetails}>
57
- <Typography color={palette.error.main}>{errorDetails}</Typography>
58
- </View>);
59
- };
60
- const ErrorFallback = ({ error, errorDetails, isDebug, errorMessage, }) => {
61
- const data = [
62
- {
63
- errorDetails,
64
- },
65
- ];
66
- if (errorMessage) {
67
- return (<View style={styles.container}>
68
- <Typography type="heading" size="large" style={styles.errorMessageText}>
69
- {errorMessage}
70
- </Typography>
71
- </View>);
72
- }
73
- return (<View style={styles.container}>
74
- <Typography type="heading" size="large" style={styles.heading}>
75
- Oops! Something went wrong.
76
- </Typography>
77
- {error && isDebug && <Typography color={palette.error.main}>{error}</Typography>}
78
- {isDebug && (<Collapsible wrapperStyle={styles.collapsibleWrapper} header={ShowErrorDetailsButton} content={ErrorDetails} data={data} pressableComponent={TouchableOpacity}/>)}
79
- </View>);
80
- };
81
- export default ErrorFallback;