@janiscommerce/ui-native 1.21.0 → 1.22.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.
@@ -1,6 +1,6 @@
1
1
  import React, { FC } from 'react';
2
2
  import { FlatListProps, ScrollViewProps } from 'react-native';
3
- type TypeData = string | number | object | [] | React.ReactElement;
3
+ type TypeData = any;
4
4
  type RCProps = {
5
5
  item: TypeData;
6
6
  index: number;
@@ -10,11 +10,17 @@ export declare enum TypeList {
10
10
  FlatList = "flatList",
11
11
  ScrollView = "scrollView"
12
12
  }
13
- interface ListProps {
13
+ interface BaseProps {
14
14
  data: TypeData[] | undefined;
15
15
  renderComponent: TypeRenderComponent;
16
16
  type?: TypeList;
17
17
  }
18
- type MergedProps = ListProps & (FlatListProps<TypeData> | ScrollViewProps);
19
- declare const List: FC<MergedProps>;
18
+ type FlatListOnlyProps = Omit<FlatListProps<TypeData>, 'data' | 'renderItem'> & {
19
+ type?: TypeList.FlatList;
20
+ };
21
+ type ScrollViewOnlyProps = ScrollViewProps & {
22
+ type: TypeList.ScrollView;
23
+ };
24
+ type ListProps = BaseProps & (FlatListOnlyProps | ScrollViewOnlyProps);
25
+ declare const List: FC<ListProps>;
20
26
  export default List;
@@ -9,8 +9,13 @@ const List = ({ data, renderComponent, type = TypeList.FlatList, ...props }) =>
9
9
  if (!data?.length) {
10
10
  return null;
11
11
  }
12
- const FlatListComponent = () => <FlatList data={data} renderItem={renderComponent} {...props}/>;
13
- const ScrollViewComponent = () => (<ScrollView {...props}>{data.map((item, index) => renderComponent({ item, index }))}</ScrollView>);
14
- return type === TypeList.FlatList ? <FlatListComponent /> : <ScrollViewComponent />;
12
+ if (type === TypeList.ScrollView) {
13
+ const scrollProps = props;
14
+ return (<ScrollView {...scrollProps}>
15
+ {data.map((item, index) => renderComponent({ item, index }))}
16
+ </ScrollView>);
17
+ }
18
+ const cleanedFlatProps = props;
19
+ return (<FlatList data={data} renderItem={({ item, index }) => renderComponent({ item, index })} keyExtractor={(item, index) => String(item.id ?? index)} {...cleanedFlatProps}/>);
15
20
  };
16
21
  export default List;
@@ -74,7 +74,7 @@ const ErrorFallback = ({ error, errorDetails, isDebug, errorMessage, }) => {
74
74
  <Typography type="heading" size="large" style={styles.heading}>
75
75
  Oops! Something went wrong.
76
76
  </Typography>
77
- {error && <Typography color={palette.error.main}>{error}</Typography>}
77
+ {error && isDebug && <Typography color={palette.error.main}>{error}</Typography>}
78
78
  {isDebug && (<Collapsible wrapperStyle={styles.collapsibleWrapper} header={ShowErrorDetailsButton} content={ErrorDetails} data={data} pressableComponent={TouchableOpacity}/>)}
79
79
  </View>);
80
80
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janiscommerce/ui-native",
3
- "version": "1.21.0",
3
+ "version": "1.22.0",
4
4
  "description": "components library for Janis app",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",