@janiscommerce/ui-native 1.24.0 → 1.25.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.
@@ -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
  }
@@ -1,4 +1,4 @@
1
- import { FC } from 'react';
1
+ import React, { FC } from 'react';
2
2
  import { TextStyle } from 'react-native';
3
3
  import { BaseToastProps } from '../../atoms/BaseToast';
4
4
  export interface ToastProps extends BaseToastProps {
@@ -13,4 +13,11 @@ export interface ToastProps extends BaseToastProps {
13
13
  };
14
14
  }
15
15
  declare const Toast: FC<ToastProps>;
16
+ export declare const configToast: {
17
+ success: (props: ToastProps) => React.JSX.Element;
18
+ notice: (props: ToastProps) => React.JSX.Element;
19
+ warning: (props: ToastProps) => React.JSX.Element;
20
+ error: (props: ToastProps) => React.JSX.Element;
21
+ action: (props: ToastProps) => React.JSX.Element;
22
+ };
16
23
  export default Toast;
@@ -92,4 +92,11 @@ const Toast = ({ type, text1, text2, style, props }) => {
92
92
  </View>
93
93
  </BaseToast>);
94
94
  };
95
+ export const configToast = {
96
+ success: (props) => <Toast {...props}/>,
97
+ notice: (props) => <Toast {...props}/>,
98
+ warning: (props) => <Toast {...props}/>,
99
+ error: (props) => <Toast {...props}/>,
100
+ action: (props) => <Toast {...props}/>,
101
+ };
95
102
  export default Toast;
@@ -1,12 +1,3 @@
1
- import React from 'react';
2
- import { ToastProps } from '../';
3
- export declare const configToast: {
4
- success: (props: ToastProps) => React.JSX.Element;
5
- notice: (props: ToastProps) => React.JSX.Element;
6
- warning: (props: ToastProps) => React.JSX.Element;
7
- error: (props: ToastProps) => React.JSX.Element;
8
- action: (props: ToastProps) => React.JSX.Element;
9
- };
10
1
  export declare const defaultIcon: {
11
2
  success: string;
12
3
  notice: string;
@@ -1,12 +1,3 @@
1
- import React from 'react';
2
- import Toast from '../';
3
- export const configToast = {
4
- success: (props) => <Toast {...props}/>,
5
- notice: (props) => <Toast {...props}/>,
6
- warning: (props) => <Toast {...props}/>,
7
- error: (props) => <Toast {...props}/>,
8
- action: (props) => <Toast {...props}/>,
9
- };
10
1
  export const defaultIcon = {
11
2
  success: 'check_circle_bold',
12
3
  notice: 'info_circle_bold',
package/dist/index.d.ts CHANGED
@@ -21,7 +21,7 @@ import LayoutWithBottomButtons from './components/molecules/LayoutWithBottomButt
21
21
  import ProgressBar from './components/molecules/ProgressBar';
22
22
  import Select from './components/molecules/Select';
23
23
  import Toast from 'react-native-toast-message';
24
- import { configToast } from './components/molecules/Toast/utils';
24
+ import { configToast } from './components/molecules/Toast';
25
25
  import SwipeList from './components/molecules/SwipeList';
26
26
  import ItemSelectionButton from './components/molecules/ItemSelectionButton';
27
27
  import MainCardList from './components/molecules/MainCardList';
@@ -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
@@ -23,7 +23,7 @@ import LayoutWithBottomButtons from './components/molecules/LayoutWithBottomButt
23
23
  import ProgressBar from './components/molecules/ProgressBar';
24
24
  import Select from './components/molecules/Select';
25
25
  import Toast from 'react-native-toast-message';
26
- import { configToast } from './components/molecules/Toast/utils';
26
+ import { configToast } from './components/molecules/Toast';
27
27
  import SwipeList from './components/molecules/SwipeList';
28
28
  import ItemSelectionButton from './components/molecules/ItemSelectionButton';
29
29
  import MainCardList from './components/molecules/MainCardList';
@@ -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.1",
4
4
  "description": "components library for Janis app",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -44,8 +44,8 @@
44
44
  },
45
45
  "homepage": "https://github.com/janis-commerce/ui-native#readme",
46
46
  "peerDependencies": {
47
- "react": ">=17.0.2",
48
- "react-native": ">=0.67.5",
47
+ "react": ">=17.0.2 <19.0.0",
48
+ "react-native": ">=0.67.5 <0.75.0",
49
49
  "react-native-gesture-handler": ">=2.9.0",
50
50
  "react-native-fast-image": "^8.5.11",
51
51
  "react-native-reanimated": "2.17.0",
@@ -63,6 +63,7 @@
63
63
  "@storybook/addon-ondevice-controls": "^6.5.4",
64
64
  "@storybook/addon-react-native-web": "0.0.20",
65
65
  "@storybook/builder-webpack5": "^6.5.4",
66
+ "@storybook/cli": "^6.5.4",
66
67
  "@storybook/manager-webpack5": "^6.5.4",
67
68
  "@storybook/react": "^6.5.4",
68
69
  "@storybook/react-native": "^6.5.4",
@@ -99,6 +100,7 @@
99
100
  "react-native": "0.67.5",
100
101
  "react-native-fast-image": "^8.5.11",
101
102
  "react-native-svg-transformer": "^1.0.0",
103
+ "react-native-web": "^0.15.0",
102
104
  "react-test-renderer": "17.0.2",
103
105
  "setup-env": "^2.0.0",
104
106
  "storybook": "^6.5.4",
@@ -126,14 +128,12 @@
126
128
  "@react-native-async-storage/async-storage": "^1.19.0",
127
129
  "@react-native-community/datetimepicker": "^7.4.0",
128
130
  "@react-native-community/slider": "^4.4.2",
129
- "@storybook/cli": "^6.5.4",
130
131
  "babel-plugin-module-resolver": "^5.0.2",
131
132
  "react-native-gesture-handler": ">=2.9.0",
132
133
  "react-native-reanimated": "2.17.0",
133
134
  "react-native-safe-area-context": "^4.6.4",
134
135
  "react-native-svg": "12.1.1",
135
136
  "react-native-toast-message": ">=1.6.0",
136
- "react-native-vector-icons": "^9.2.0",
137
- "react-native-web": "^0.15.0"
137
+ "react-native-vector-icons": "^9.2.0"
138
138
  }
139
139
  }
@@ -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;