@janiscommerce/ui-native 1.15.3 → 1.16.2

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}/>
@@ -7,7 +7,6 @@ interface BaseInputPropsExtended extends BaseInputProps {
7
7
  variant?: InputVariant;
8
8
  onChangeText?: (text: string) => void;
9
9
  totalValue?: number;
10
- placeholder?: string;
11
10
  }
12
11
  type AmountTotalProps = BaseInputPropsExtended & {
13
12
  variant: 'amountTotal';
@@ -1,11 +1,11 @@
1
1
  import React, { forwardRef, useState, useRef } from 'react';
2
- import { StyleSheet, View, TouchableWithoutFeedback, Keyboard, Platform, } from 'react-native';
2
+ import { StyleSheet, View, TouchableWithoutFeedback, Keyboard } from 'react-native';
3
3
  import BaseInput from '../../atoms/BaseInput';
4
4
  import { palette } from '../../../theme/palette';
5
5
  import { moderateScale, scaledForDevice } from '../../../scale';
6
6
  import handleChangeText from './utils/handleChangeText';
7
7
  import Typography from '../../atoms/Typography';
8
- const isWeb = Platform.OS === 'web';
8
+ import typography from '../../../theme/typography';
9
9
  var InputType;
10
10
  (function (InputType) {
11
11
  InputType["currency"] = "numeric";
@@ -18,9 +18,8 @@ var InputType;
18
18
  InputType["amountTotal"] = "numeric";
19
19
  InputType["numeric"] = "numeric";
20
20
  })(InputType || (InputType = {}));
21
- const Input = forwardRef(({ style, type, variant = 'default', totalValue, placeholder, onChangeText, ...props }, ref) => {
21
+ const Input = forwardRef(({ style, type, variant = 'default', totalValue, onChangeText, ...props }, ref) => {
22
22
  const [value, setValue] = useState('');
23
- const isPlaceholderBeingShown = !value;
24
23
  const isAmountTotalVariant = variant === 'amountTotal';
25
24
  const internalRef = useRef(null);
26
25
  const inputRef = ref ?? internalRef;
@@ -42,24 +41,24 @@ const Input = forwardRef(({ style, type, variant = 'default', totalValue, placeh
42
41
  width: '100%',
43
42
  },
44
43
  input: {
44
+ ...typography.display.medium,
45
45
  color: palette.black.main,
46
- fontSize: scaledForDevice(42, moderateScale),
47
46
  height: '100%',
48
47
  textAlign: 'center',
49
48
  textAlignVertical: 'center',
50
49
  includeFontPadding: false,
51
50
  paddingVertical: 0,
52
- ...(isPlaceholderBeingShown && { marginLeft: scaledForDevice(-12, moderateScale) }),
53
- ...(isWeb && { flex: 1, maxWidth: isPlaceholderBeingShown ? '1%' : undefined }),
54
51
  },
55
52
  totalValue: {
56
53
  color: palette.primary.main,
57
54
  },
58
- placeholder: {
59
- color: '#A8AAAC',
60
- marginLeft: scaledForDevice(-12, moderateScale),
61
- },
62
55
  });
56
+ const getTextAlignment = () => {
57
+ if (value) {
58
+ return isAmountTotalVariant ? 'right' : 'center';
59
+ }
60
+ return 'left';
61
+ };
63
62
  const changeTextCb = (text) => {
64
63
  const transformedText = handleChangeText(text, variant);
65
64
  setValue(transformedText);
@@ -83,18 +82,9 @@ const Input = forwardRef(({ style, type, variant = 'default', totalValue, placeh
83
82
  }
84
83
  return InputType.default;
85
84
  })();
86
- const renderPlaceholder = () => {
87
- if (value.length > 0) {
88
- return null;
89
- }
90
- return (<Typography type="display" style={styles.placeholder}>
91
- {placeholder}
92
- </Typography>);
93
- };
94
85
  return (<TouchableWithoutFeedback onPress={handlePress}>
95
86
  <View style={[styles.container, style]}>
96
- <BaseInput testID="input" style={styles.input} ref={inputRef} value={value} keyboardType={resolvedKeyboardType} onChangeText={changeTextCb} {...props}/>
97
- {renderPlaceholder()}
87
+ <BaseInput testID="input" style={styles.input} textAlign={getTextAlignment()} ref={inputRef} value={value} keyboardType={resolvedKeyboardType} onChangeText={changeTextCb} {...props}/>
98
88
  {isAmountTotalVariant && (<Typography style={styles.totalValue} type="display">
99
89
  {`/${totalValue?.toString()}`}
100
90
  </Typography>)}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@janiscommerce/ui-native",
3
- "version": "1.15.3",
3
+ "version": "1.16.2",
4
4
  "description": "components library for Janis app",
5
5
  "main": "dist/index.js",
6
6
  "typings": "dist/index.d.ts",
@@ -25,7 +25,8 @@
25
25
  "update-stories": "sb-rn-get-stories --config-path .ondevice",
26
26
  "storybook-web": "node scripts/set-app-mode.js web && npm run storybook-web-build && start-storybook -p 6006 --config-dir ./.storybook",
27
27
  "storybook-web-build": "node scripts/set-app-mode.js web && build-storybook --config-dir ./.storybook --output-dir ./.storybook_static",
28
- "storybook-web-docs": "build-storybook --config-dir ./.storybook --output-dir ./docs"
28
+ "storybook-web-docs": "build-storybook --config-dir ./.storybook --output-dir ./docs",
29
+ "preversion": "npm run test:coverage"
29
30
  },
30
31
  "repository": {
31
32
  "type": "git",