@janiscommerce/ui-native 1.22.0 → 1.24.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,5 +1,12 @@
1
1
  import React from 'react';
2
2
  import { ViewStyle } from 'react-native';
3
+ interface CollapsibleHeaderProps {
4
+ isOpen: boolean;
5
+ }
6
+ interface CollapsibleContentProps {
7
+ index: number;
8
+ isOpen?: boolean;
9
+ }
3
10
  interface CollapsibleProps<HeaderProps = {}, ContentProps = {}> {
4
11
  header: React.ComponentType<HeaderProps>;
5
12
  content: React.ComponentType<ContentProps & {
@@ -10,10 +17,8 @@ interface CollapsibleProps<HeaderProps = {}, ContentProps = {}> {
10
17
  duration?: number;
11
18
  onPressCallback?: null | (() => void);
12
19
  wrapperStyle?: ViewStyle;
20
+ isDefaultOpen?: boolean;
13
21
  }
14
- declare const Collapsible: React.FC<CollapsibleProps<{
15
- isOpen: boolean;
16
- }, {
17
- isOpen?: boolean;
18
- }>>;
22
+ declare const Collapsible: React.FC<CollapsibleProps<CollapsibleHeaderProps, CollapsibleContentProps>>;
19
23
  export default Collapsible;
24
+ export type { CollapsibleHeaderProps, CollapsibleContentProps };
@@ -2,8 +2,8 @@ import List from '../List';
2
2
  import React, { useState } from 'react';
3
3
  import { StyleSheet, View, Pressable } from 'react-native';
4
4
  import Animated, { useAnimatedStyle, useSharedValue, withTiming } from 'react-native-reanimated';
5
- const Collapsible = ({ header: Header, content: Content, data = [], onPressCallback = null, pressableComponent: PressableComponent = Pressable, duration = 500, wrapperStyle = {}, }) => {
6
- const [isOpen, setIsOpen] = useState(false);
5
+ const Collapsible = ({ header: Header, content: Content, data = [], onPressCallback = null, pressableComponent: PressableComponent = Pressable, duration = 500, wrapperStyle = {}, isDefaultOpen = false, }) => {
6
+ const [isOpen, setIsOpen] = useState(isDefaultOpen);
7
7
  const [measuredHeight, setMeasuredHeight] = useState(0);
8
8
  const contentHeight = useSharedValue(0);
9
9
  const hasHeightBeenMeasured = !!measuredHeight;
@@ -41,8 +41,7 @@ const Collapsible = ({ header: Header, content: Content, data = [], onPressCallb
41
41
  opacity: 0,
42
42
  },
43
43
  });
44
- const renderContent = (contentData) => {
45
- const { item, index } = contentData;
44
+ const renderContent = ({ item, index }) => {
46
45
  return <Content {...item} index={index} isOpen={isOpen}/>;
47
46
  };
48
47
  return (<View style={[wrapperStyle, styles.wrapperView]}>
@@ -50,10 +49,10 @@ const Collapsible = ({ header: Header, content: Content, data = [], onPressCallb
50
49
  <Header isOpen={isOpen}/>
51
50
  </PressableComponent>
52
51
  {!hasHeightBeenMeasured && (<View style={styles.contentWrapper} onLayout={handleContentLayout}>
53
- <List data={data} renderComponent={renderContent} keyExtractor={(_, index) => String(index)} showsVerticalScrollIndicator={false}/>
52
+ <List data={data} renderComponent={renderContent} keyExtractor={(_, index) => String(index)} showsVerticalScrollIndicator={false} nestedScrollEnabled={true}/>
54
53
  </View>)}
55
54
  <Animated.View style={[styles.animatedView, bodyStyle]}>
56
- <List data={data} renderComponent={renderContent} keyExtractor={(_, index) => String(index)} showsVerticalScrollIndicator={false}/>
55
+ <List data={data} renderComponent={renderContent} keyExtractor={(_, index) => String(index)} showsVerticalScrollIndicator={false} nestedScrollEnabled={true}/>
57
56
  </Animated.View>
58
57
  </View>);
59
58
  };
@@ -10,7 +10,7 @@ declare const CheckSizeValues: {
10
10
  type sizeType = typeof CheckSizeValues;
11
11
  type sizeKeys = keyof sizeType;
12
12
  interface RadioButtonProps {
13
- children: React.ReactNode | string;
13
+ children?: React.ReactNode | string;
14
14
  selected?: boolean;
15
15
  onPress?: () => {};
16
16
  checkPosition?: positions;
@@ -18,5 +18,5 @@ interface RadioButtonProps {
18
18
  checkSize?: sizeKeys;
19
19
  style?: ViewStyle;
20
20
  }
21
- declare const RadioButton: ({ children, onPress, selected, checkPosition, checkSize, disabled, style, ...props }: RadioButtonProps) => React.JSX.Element | null;
21
+ declare const RadioButton: ({ children, onPress, selected, checkPosition, checkSize, disabled, style, ...props }: RadioButtonProps) => React.JSX.Element;
22
22
  export default RadioButton;
@@ -35,9 +35,6 @@ const styles = StyleSheet.create({
35
35
  },
36
36
  });
37
37
  const RadioButton = ({ children, onPress, selected = false, checkPosition = 'left', checkSize = 'sm', disabled = false, style, ...props }) => {
38
- if (!children) {
39
- return null;
40
- }
41
38
  const { container, row, reverseRow, checkToLeft, checkToRight } = styles;
42
39
  const isStringChild = typeof children === 'string';
43
40
  const checkLeft = checkPosition === 'left';
@@ -45,7 +42,7 @@ const RadioButton = ({ children, onPress, selected = false, checkPosition = 'lef
45
42
  return (<TouchableOpacity style={[container, checkLeft ? row : reverseRow, style]} disabled={disabled} onPress={onPress} {...props}>
46
43
  <CheckBox checked={selected} disabled={disabled} customSize={customSize} borderRadius={customSize / 2} onPress={onPress}/>
47
44
  <View style={checkLeft ? checkToLeft : checkToRight}>
48
- {isStringChild ? <Typography>{children}</Typography> : children}
45
+ {children && (isStringChild ? <Typography>{children}</Typography> : children)}
49
46
  </View>
50
47
  </TouchableOpacity>);
51
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janiscommerce/ui-native",
3
- "version": "1.22.0",
3
+ "version": "1.24.0",
4
4
  "description": "components library for Janis app",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",