@janiscommerce/ui-native 1.15.2 → 1.16.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.
@@ -3,16 +3,16 @@ 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
5
  const Collapsible = ({ header: Header, content: Content, data = [], onPressCallback = null, pressableComponent: PressableComponent = Pressable, duration = 500, wrapperStyle = {}, }) => {
6
- const isOpen = useSharedValue(false);
6
+ const [isOpen, setIsOpen] = useState(false);
7
7
  const [measuredHeight, setMeasuredHeight] = useState(0);
8
8
  const contentHeight = useSharedValue(0);
9
9
  const hasHeightBeenMeasured = !!measuredHeight;
10
10
  const handleOpen = () => {
11
11
  // istanbul ignore next
12
- if (!isOpen.value && measuredHeight > 0) {
12
+ if (!isOpen && measuredHeight > 0) {
13
13
  contentHeight.value = measuredHeight;
14
14
  }
15
- isOpen.value = !isOpen.value;
15
+ setIsOpen(!isOpen);
16
16
  if (onPressCallback) {
17
17
  onPressCallback();
18
18
  }
@@ -27,14 +27,11 @@ const Collapsible = ({ header: Header, content: Content, data = [], onPressCallb
27
27
  };
28
28
  // istanbul ignore next
29
29
  const bodyStyle = useAnimatedStyle(() => ({
30
- maxHeight: withTiming(isOpen.value ? contentHeight.value : 0, { duration }),
30
+ maxHeight: withTiming(isOpen ? contentHeight.value : 0, { duration }),
31
31
  overflow: 'hidden',
32
32
  }));
33
33
  const styles = StyleSheet.create({
34
- wrapperView: {
35
- flex: 1,
36
- width: '100%',
37
- },
34
+ wrapperView: { flex: 1, width: '100%' },
38
35
  animatedView: {
39
36
  overflow: 'hidden',
40
37
  width: '100%',
@@ -50,7 +47,7 @@ const Collapsible = ({ header: Header, content: Content, data = [], onPressCallb
50
47
  };
51
48
  return (<View style={[wrapperStyle, styles.wrapperView]}>
52
49
  <PressableComponent onPress={handleOpen}>
53
- <Header isOpen={isOpen.value}/>
50
+ <Header isOpen={isOpen}/>
54
51
  </PressableComponent>
55
52
  {!hasHeightBeenMeasured && (<View style={styles.contentWrapper} onLayout={handleContentLayout}>
56
53
  <List data={data} renderComponent={renderContent} keyExtractor={(_, index) => String(index)} showsVerticalScrollIndicator={false}/>
@@ -18,7 +18,7 @@ var InputType;
18
18
  InputType["amountTotal"] = "numeric";
19
19
  InputType["numeric"] = "numeric";
20
20
  })(InputType || (InputType = {}));
21
- const Input = forwardRef(({ type, variant = 'default', totalValue, placeholder, onChangeText, ...props }, ref) => {
21
+ const Input = forwardRef(({ style, type, variant = 'default', totalValue, placeholder, onChangeText, ...props }, ref) => {
22
22
  const [value, setValue] = useState('');
23
23
  const isPlaceholderBeingShown = !value;
24
24
  const isAmountTotalVariant = variant === 'amountTotal';
@@ -39,6 +39,7 @@ const Input = forwardRef(({ type, variant = 'default', totalValue, placeholder,
39
39
  alignItems: 'center',
40
40
  flexDirection: 'row',
41
41
  position: 'relative',
42
+ width: '100%',
42
43
  },
43
44
  input: {
44
45
  color: palette.black.main,
@@ -91,8 +92,8 @@ const Input = forwardRef(({ type, variant = 'default', totalValue, placeholder,
91
92
  </Typography>);
92
93
  };
93
94
  return (<TouchableWithoutFeedback onPress={handlePress}>
94
- <View style={styles.container} {...props}>
95
- <BaseInput testID="input" style={styles.input} ref={inputRef} value={value} keyboardType={resolvedKeyboardType} onChangeText={changeTextCb}/>
95
+ <View style={[styles.container, style]}>
96
+ <BaseInput testID="input" style={styles.input} ref={inputRef} value={value} keyboardType={resolvedKeyboardType} onChangeText={changeTextCb} {...props}/>
96
97
  {renderPlaceholder()}
97
98
  {isAmountTotalVariant && (<Typography style={styles.totalValue} type="display">
98
99
  {`/${totalValue?.toString()}`}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janiscommerce/ui-native",
3
- "version": "1.15.2",
3
+ "version": "1.16.0",
4
4
  "description": "components library for Janis app",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",