@widergy/mobile-ui 0.40.1 → 1.1.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.
Files changed (84) hide show
  1. package/CHANGELOG.md +921 -0
  2. package/lib/components/Button/index.js +10 -6
  3. package/lib/components/Button/styles.js +5 -5
  4. package/lib/components/Capture/index.js +3 -3
  5. package/lib/components/Carousel/components/CarouselComponent/index.js +2 -0
  6. package/lib/components/Carousel/components/CarouselContainer/index.js +2 -10
  7. package/lib/components/CheckList/components/CheckBoxRenderer/index.js +1 -0
  8. package/lib/components/CheckList/index.js +5 -3
  9. package/lib/components/CheckList/proptypes.js +2 -2
  10. package/lib/components/Checkbox/styles.js +3 -3
  11. package/lib/components/Dropdown/index.js +12 -10
  12. package/lib/components/FilePicker/utils.js +2 -2
  13. package/lib/components/Icon/constants.js +1 -0
  14. package/lib/components/Icon/index.js +11 -1
  15. package/lib/components/ImageIcon/index.js +8 -1
  16. package/lib/components/ImageRadio/index.js +21 -12
  17. package/lib/components/Loading/index.js +1 -0
  18. package/lib/components/Overlay/index.js +2 -10
  19. package/lib/components/PhotoAlbum/index.js +8 -9
  20. package/lib/components/Picker/index.js +2 -2
  21. package/lib/components/Portal/components/Manager/index.js +7 -4
  22. package/lib/components/RadioGroup/components/RadioButton/index.js +5 -5
  23. package/lib/components/RateChart/components/RateStagesGraph/components/Indicator/index.js +3 -3
  24. package/lib/components/RateChart/components/RateStagesGraph/components/Indicator/utils.js +1 -1
  25. package/lib/components/TransformView/constants.js +1 -1
  26. package/lib/components/TransformView/utils.js +674 -0
  27. package/lib/components/UTAutocomplete/index.js +4 -4
  28. package/lib/components/UTBanner/index.js +42 -0
  29. package/lib/components/UTBanner/styles.js +14 -0
  30. package/lib/components/UTCBUInput/index.js +2 -2
  31. package/lib/components/UTHeader/index.js +56 -0
  32. package/lib/components/UTHeader/styles.js +16 -0
  33. package/lib/components/UTMenu/components/ListView/index.js +4 -2
  34. package/lib/components/UTMenu/components/MenuOption/index.js +1 -0
  35. package/lib/components/UTMenu/index.js +3 -3
  36. package/lib/components/UTMenu/proptypes.js +2 -2
  37. package/lib/components/UTOnBoarding/components/CardContent/index.js +3 -3
  38. package/lib/components/UTOnBoarding/index.js +4 -4
  39. package/lib/components/UTPasswordField/components/PasswordValidations/index.js +2 -6
  40. package/lib/components/UTSelect/componentes/MultipleItem/index.js +1 -0
  41. package/lib/components/UTSelect/proptypes.js +1 -0
  42. package/lib/components/UTStepFeedback/components/CircleNumber/index.js +12 -10
  43. package/lib/components/UTStepFeedback/index.js +36 -37
  44. package/lib/components/UTStepper/components/Connectors/index.js +33 -0
  45. package/lib/components/UTStepper/components/Connectors/styles.js +26 -0
  46. package/lib/components/UTStepper/components/Step/index.js +50 -0
  47. package/lib/components/UTStepper/components/Step/styles.js +47 -0
  48. package/lib/components/UTStepper/index.js +34 -0
  49. package/lib/components/UTStepper/styles.js +12 -0
  50. package/lib/components/UTStepper/types.js +3 -0
  51. package/lib/components/UTSwitch/proptypes.js +1 -0
  52. package/lib/components/UTTextInput/components/BaseInput/index.js +10 -12
  53. package/lib/components/UTTextInput/proptypes.js +1 -0
  54. package/lib/components/UTTopbar/index.js +64 -0
  55. package/lib/components/UTTopbar/styles.js +16 -0
  56. package/lib/components/UTTopbar/types.js +8 -0
  57. package/lib/components/UTWorkflowContainer/index.js +10 -102
  58. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/BottomStepHandler/index.js +4 -4
  59. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/BottomStepHandler/styles.js +3 -3
  60. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/index.js +9 -9
  61. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/styles.js +3 -3
  62. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/index.js +2 -2
  63. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/styles.js +12 -12
  64. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/components/ActionButton/types.js +9 -9
  65. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/index.js +6 -6
  66. package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/styles.js +3 -3
  67. package/lib/components/UTWorkflowContainer/versions/V0/index.js +108 -0
  68. package/lib/components/UTWorkflowContainer/{styles.js → versions/V0/styles.js} +4 -4
  69. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/index.js +35 -0
  70. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/styles.js +13 -0
  71. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/components/ActionButton/types.js +9 -0
  72. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/constants.js +2 -0
  73. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/index.js +110 -0
  74. package/lib/components/UTWorkflowContainer/versions/V1/components/BottomActions/styles.js +75 -0
  75. package/lib/components/UTWorkflowContainer/versions/V1/index.js +94 -0
  76. package/lib/components/UTWorkflowContainer/versions/V1/styles.js +14 -0
  77. package/lib/components/UTWorkflowContainer/versions/V1/types.js +24 -0
  78. package/lib/theming/DefaultTheme.js +1 -0
  79. package/lib/utils/fileUtils.js/index.js +20 -5
  80. package/package.json +47 -71
  81. /package/lib/components/UTWorkflowContainer/{README.md → versions/V0/README.md} +0 -0
  82. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/Header/utils.js +0 -0
  83. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/constants.js +0 -0
  84. /package/lib/components/UTWorkflowContainer/{components → versions/V0/components}/StepsHandler/utils.js +0 -0
@@ -1,13 +1,5 @@
1
1
  import { bool, elementType, func, oneOf, shape, string } from 'prop-types';
2
- import React, {
3
- Fragment,
4
- useState,
5
- forwardRef,
6
- useImperativeHandle,
7
- useRef,
8
- useEffect,
9
- useMemo
10
- } from 'react';
2
+ import React, { useState, forwardRef, useImperativeHandle, useRef, useEffect, useMemo } from 'react';
11
3
  import { ViewPropTypes } from 'deprecated-react-native-prop-types';
12
4
  import { TextInput } from 'react-native';
13
5
  import _ from 'lodash';
@@ -76,7 +68,7 @@ const BaseInput = forwardRef(
76
68
  : {};
77
69
 
78
70
  return (
79
- <Fragment>
71
+ <>
80
72
  <TextInput
81
73
  autoCorrect={false}
82
74
  ref={textInputRef}
@@ -88,7 +80,11 @@ const BaseInput = forwardRef(
88
80
  editable={!select && !disabled}
89
81
  {...props}
90
82
  secureTextEntry={!showInput}
91
- style={[...variantStyle.text, select && { color: theme.fonts?.fontColor }, select && disabled && { color: theme.fonts?.fontDisabledColor}]}
83
+ style={[
84
+ ...variantStyle.text,
85
+ select && { color: theme.fonts?.fontColor },
86
+ select && disabled && { color: theme.fonts?.fontDisabledColor }
87
+ ]}
92
88
  />
93
89
  {(RightIcon || hiddenInput) && (
94
90
  <Touchable
@@ -109,11 +105,13 @@ const BaseInput = forwardRef(
109
105
  )}
110
106
  </Touchable>
111
107
  )}
112
- </Fragment>
108
+ </>
113
109
  );
114
110
  }
115
111
  );
116
112
 
113
+ BaseInput.displayName = 'BaseInput';
114
+
117
115
  BaseInput.propTypes = {
118
116
  onBlur: func.isRequired,
119
117
  onFocus: func.isRequired,
@@ -1,5 +1,6 @@
1
1
  import { string, func, bool, any, shape, elementType, oneOfType } from 'prop-types';
2
2
 
3
+ // eslint-disable-next-line react/forbid-prop-types
3
4
  const refPropType = oneOfType([func, shape({ current: any })]);
4
5
 
5
6
  export default {
@@ -0,0 +1,64 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { number } from 'prop-types';
4
+
5
+ import IconButton from '../IconButton';
6
+ import Label from '../Label';
7
+ import UTStepper from '../UTStepper';
8
+ import UTProgressBar from '../UTProgressBar';
9
+ import { StagesPropTypes } from '../UTStepper/types';
10
+
11
+ import ownStyles, { BAR_HEIGHT } from './styles';
12
+ import { TopbarPropTypes } from './types';
13
+
14
+ const UTTopbar = ({
15
+ currentStage,
16
+ currentStep,
17
+ stages,
18
+ stepsCount,
19
+ theme,
20
+ topbar: { colorTheme = 'light', goBack, title, variant = 'secondary', icon } = {}
21
+ }) => {
22
+ const size = { big: variant === 'primary' };
23
+
24
+ const ownTheme = theme.UTWorkflowContainer?.topbar?.[colorTheme];
25
+
26
+ return (
27
+ <View>
28
+ <View style={[ownStyles.container, ownTheme?.container]}>
29
+ <IconButton
30
+ color={ownTheme?.icon || 'black'}
31
+ name={icon?.name || 'arrow-left'}
32
+ size={24}
33
+ style={ownStyles.child}
34
+ type={icon?.type || 'material-community'}
35
+ onPress={goBack}
36
+ />
37
+ <Label color={ownTheme?.text || 'black'} {...size} bold style={ownStyles.child}>
38
+ {title}
39
+ </Label>
40
+ {stages && <UTStepper {...{ currentStage, stages }} />}
41
+ </View>
42
+ {currentStep && stepsCount && (
43
+ <UTProgressBar
44
+ value={currentStep / stepsCount}
45
+ styles={{
46
+ barContainer: {
47
+ height: BAR_HEIGHT
48
+ }
49
+ }}
50
+ />
51
+ )}
52
+ </View>
53
+ );
54
+ };
55
+
56
+ UTTopbar.propTypes = {
57
+ currentStage: number,
58
+ currentStep: number,
59
+ stages: StagesPropTypes,
60
+ stepsCount: number,
61
+ topbar: TopbarPropTypes
62
+ };
63
+
64
+ export default UTTopbar;
@@ -0,0 +1,16 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ export const BAR_HEIGHT = 8;
4
+
5
+ export default StyleSheet.create({
6
+ child: {
7
+ marginRight: 16
8
+ },
9
+ container: {
10
+ alignItems: 'center',
11
+ display: 'flex',
12
+ flexDirection: 'row',
13
+ justifyContent: 'flex-start',
14
+ padding: 16
15
+ }
16
+ });
@@ -0,0 +1,8 @@
1
+ import { func, oneOf, shape, string } from 'prop-types';
2
+
3
+ export const TopbarPropTypes = shape({
4
+ colorTheme: oneOf(['light', 'dark']),
5
+ goBack: func,
6
+ title: string,
7
+ variant: oneOf(['primary', 'secondary'])
8
+ });
@@ -1,108 +1,16 @@
1
- import React, { useEffect } from 'react';
2
- import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
- import { View } from 'react-native';
4
- import { number, func, shape, bool, string, oneOf } from 'prop-types';
5
- import _ from 'lodash';
1
+ import React from 'react';
2
+ import { string } from 'prop-types';
6
3
 
7
- import Label from '../Label';
8
- import { useTheme } from '../../theming';
4
+ import V0 from './versions/V0';
5
+ import V1 from './versions/V1';
9
6
 
10
- import ownStyles from './styles';
11
- import Header from './components/Header';
12
- import ActionButtonPropTypes from './components/StepsHandler/components/ActionButton/types';
13
- import BottomStepHandler from './components/BottomStepHandler';
14
-
15
- const UTWorkflowContainer = ({
16
- stepsCount,
17
- currentStep,
18
- nextButton,
19
- returnButton,
20
- onExit,
21
- hideStepCounter,
22
- children,
23
- styles = {},
24
- title,
25
- subtitle,
26
- stepCounter,
27
- bottomHandler,
28
- hideHeader = false,
29
- useMarkdown
30
- }) => {
31
- useEffect(() => () => onExit?.(), []);
32
- const theme = useTheme();
33
-
34
- const themedStyles = _.merge({}, ownStyles, theme?.UTWorkflowContainer, styles);
35
-
36
- const { titleProps, subtitleProps } = themedStyles?.labelProps || {};
37
-
38
- const Title = React.isValidElement(title) ? (
39
- title
40
- ) : (
41
- <Label big bold {...titleProps} style={themedStyles.title}>
42
- {title}
43
- </Label>
44
- );
45
-
46
- const Subtitle = React.isValidElement(subtitle) ? (
47
- subtitle
48
- ) : (
49
- <Label
50
- medium
51
- {...subtitleProps}
52
- style={themedStyles.subtitle}
53
- markdownStyles={themedStyles.markdown}
54
- useMarkdown={useMarkdown}
55
- >
56
- {subtitle}
57
- </Label>
58
- );
59
-
60
- return (
61
- <View style={themedStyles.container}>
62
- {!hideHeader && (
63
- <Header
64
- stepsCount={stepsCount}
65
- currentStep={currentStep}
66
- nextButton={nextButton}
67
- returnButton={returnButton}
68
- hideStepCounter={hideStepCounter}
69
- themedStyles={themedStyles}
70
- styles={styles}
71
- stepCounter={stepCounter}
72
- bottomHandler={bottomHandler}
73
- />
74
- )}
75
- {!!title && Title}
76
- {!!subtitle && Subtitle}
77
- {children}
78
- {bottomHandler && (
79
- <BottomStepHandler
80
- stepsCount={stepsCount}
81
- currentStep={currentStep}
82
- styles={styles}
83
- nextButton={nextButton}
84
- themedStyles={themedStyles}
85
- returnButton={returnButton}
86
- hideStepCounter={hideStepCounter}
87
- stepCounter={stepCounter}
88
- />
89
- )}
90
- </View>
91
- );
7
+ const UTWorkflowContainer = ({ version = 'V0', ...props }) => {
8
+ const Component = { V0, V1 }[version];
9
+ return <Component {...props} />;
92
10
  };
11
+
93
12
  UTWorkflowContainer.propTypes = {
94
- stepsCount: number.isRequired,
95
- currentStep: number.isRequired,
96
- nextButton: ActionButtonPropTypes.isRequired,
97
- returnButton: ActionButtonPropTypes.isRequired,
98
- onExit: func,
99
- hideStepCounter: bool,
100
- styles: shape(ViewPropTypes?.style),
101
- title: string,
102
- subtitle: string,
103
- stepCounter: oneOf([func, string]),
104
- bottomHandler: bool,
105
- hideHeader: bool,
106
- useMarkdown: bool
13
+ version: string
107
14
  };
15
+
108
16
  export default UTWorkflowContainer;
@@ -28,7 +28,7 @@ const BottomStepHandler = ({
28
28
  nextButton={nextButton}
29
29
  returnButton={returnButton}
30
30
  hideStepCounter={hideStepCounter}
31
- styles={{ stepsHandler: styles?.bottomStepHandler, stepCounter: styles?.bottomStepCounter }}
31
+ styles={{ stepCounter: styles?.bottomStepCounter, stepsHandler: styles?.bottomStepHandler }}
32
32
  themedStyles={mergedStyles}
33
33
  stepCounter={stepCounter}
34
34
  />
@@ -37,13 +37,13 @@ const BottomStepHandler = ({
37
37
  };
38
38
 
39
39
  BottomStepHandler.propTypes = {
40
- stepsCount: number.isRequired,
41
40
  currentStep: number.isRequired,
41
+ hideStepCounter: bool,
42
42
  nextButton: ActionButtonPropTypes.isRequired,
43
43
  returnButton: ActionButtonPropTypes.isRequired,
44
- hideStepCounter: bool,
45
- styles: shape(ViewPropTypes?.style),
46
44
  stepCounter: oneOf([func, string]),
45
+ stepsCount: number.isRequired,
46
+ styles: shape(ViewPropTypes?.style),
47
47
  // eslint-disable-next-line react/forbid-prop-types
48
48
  themedStyles: any
49
49
  };
@@ -1,14 +1,14 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- import { verticalScale } from '../../../../utils/scaleUtils';
3
+ import { verticalScale } from '../../../../../../utils/scaleUtils';
4
4
 
5
5
  export const BAR_HEIGHT = verticalScale(10);
6
6
 
7
7
  export default StyleSheet.create({
8
8
  bottomStepContainer: {
9
9
  alignItems: 'center',
10
+ marginTop: 'auto',
10
11
  overflow: 'hidden',
11
- width: '100%',
12
- marginTop: 'auto'
12
+ width: '100%'
13
13
  }
14
14
  });
@@ -3,7 +3,7 @@ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
3
  import { View } from 'react-native';
4
4
  import { number, bool, shape, oneOf, func, string } from 'prop-types';
5
5
 
6
- import UTProgressBar from '../../../UTProgressBar';
6
+ import UTProgressBar from '../../../../../UTProgressBar';
7
7
  import StepsHandler from '../StepsHandler';
8
8
  import ActionButtonPropTypes from '../StepsHandler/components/ActionButton/types';
9
9
 
@@ -26,13 +26,13 @@ const Header = ({
26
26
  value={getProgressValue(currentStep, stepsCount)}
27
27
  styles={{
28
28
  barContainer: {
29
- marginTop: -BAR_HEIGHT / 2,
30
- marginBottom: -BAR_HEIGHT / 2 + 25,
31
29
  height: BAR_HEIGHT,
30
+ marginBottom: -BAR_HEIGHT / 2 + 25,
31
+ marginTop: -BAR_HEIGHT / 2,
32
32
  ...styles?.barContainer
33
33
  },
34
- progressBar: styles?.progressBar,
35
- borderStyle: styles?.borderStyle || UTProgressBar.BorderStyles.SLOPE
34
+ borderStyle: styles?.borderStyle || UTProgressBar.BorderStyles.SLOPE,
35
+ progressBar: styles?.progressBar
36
36
  }}
37
37
  />
38
38
  {!bottomHandler && (
@@ -51,14 +51,14 @@ const Header = ({
51
51
  );
52
52
 
53
53
  Header.propTypes = {
54
- stepsCount: number.isRequired,
54
+ bottomHandler: bool,
55
55
  currentStep: number.isRequired,
56
+ hideStepCounter: bool,
56
57
  nextButton: ActionButtonPropTypes.isRequired,
57
58
  returnButton: ActionButtonPropTypes.isRequired,
58
- hideStepCounter: bool,
59
- styles: shape(ViewPropTypes?.style),
60
59
  stepCounter: oneOf([func, string]),
61
- bottomHandler: bool,
60
+ stepsCount: number.isRequired,
61
+ styles: shape(ViewPropTypes?.style),
62
62
  themedStyles: shape(ViewPropTypes?.style)
63
63
  };
64
64
 
@@ -1,14 +1,14 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- import { verticalScale } from '../../../../utils/scaleUtils';
3
+ import { verticalScale } from '../../../../../../utils/scaleUtils';
4
4
 
5
5
  export const BAR_HEIGHT = verticalScale(10);
6
6
 
7
7
  export default StyleSheet.create({
8
8
  container: {
9
9
  alignItems: 'center',
10
+ marginBottom: verticalScale(30),
10
11
  overflow: 'hidden',
11
- width: '100%',
12
- marginBottom: verticalScale(30)
12
+ width: '100%'
13
13
  }
14
14
  });
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
2
  import Icon from 'react-native-vector-icons/AntDesign';
3
3
 
4
- import Touchable from '../../../../../Touchable';
5
- import { withTheme } from '../../../../../../theming';
4
+ import Touchable from '../../../../../../../Touchable';
5
+ import { withTheme } from '../../../../../../../../theming';
6
6
 
7
7
  import createStyles, { DEFAULT_ICON_SIZE } from './styles';
8
8
  import ActionButtonProptypes from './types';
@@ -1,6 +1,6 @@
1
1
  import { StyleSheet } from 'react-native';
2
2
 
3
- import { horizontalScale } from '../../../../../../utils/scaleUtils';
3
+ import { horizontalScale } from '../../../../../../../../utils/scaleUtils';
4
4
 
5
5
  const BUTTON_SIZE = horizontalScale(45);
6
6
  const BORDER_WIDTH = 1.5;
@@ -8,29 +8,29 @@ export const DEFAULT_ICON_SIZE = horizontalScale(20);
8
8
 
9
9
  export default theme =>
10
10
  StyleSheet.create({
11
- disabled: {
12
- opacity: 0.5
13
- },
14
- shown: {
15
- opacity: 1
16
- },
17
11
  borderless: {
18
12
  borderWidth: 0
19
13
  },
20
14
  container: {
21
15
  alignItems: 'center',
22
- justifyContent: 'center',
23
- padding: 10,
24
- borderRadius: 100,
25
16
  borderColor: theme.colors.primary,
17
+ borderRadius: 100,
26
18
  borderWidth: BORDER_WIDTH,
27
19
  height: BUTTON_SIZE,
20
+ justifyContent: 'center',
21
+ padding: 10,
28
22
  width: BUTTON_SIZE
29
23
  },
30
- icon: {
31
- marginTop: BORDER_WIDTH
24
+ disabled: {
25
+ opacity: 0.5
32
26
  },
33
27
  hidden: {
34
28
  opacity: 0
29
+ },
30
+ icon: {
31
+ marginTop: BORDER_WIDTH
32
+ },
33
+ shown: {
34
+ opacity: 1
35
35
  }
36
36
  });
@@ -2,19 +2,19 @@ import { string, bool, func, number, shape } from 'prop-types';
2
2
  import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
3
  import { Text } from 'react-native';
4
4
 
5
- import TouchablePropTypes from '../../../../../Touchable/propTypes';
6
- import { themeType } from '../../../../../../theming';
5
+ import TouchablePropTypes from '../../../../../../../Touchable/propTypes';
6
+ import { themeType } from '../../../../../../../../theming';
7
7
 
8
8
  export default shape({
9
- name: string,
10
- disabled: bool,
11
- onPress: func,
12
9
  borderless: bool,
13
- size: number,
14
10
  color: string,
11
+ disabled: bool,
12
+ IconProps: shape(Text?.propTypes),
15
13
  IconStyle: ViewPropTypes?.style,
16
- TouchableStyle: ViewPropTypes?.style,
14
+ name: string,
15
+ onPress: func,
16
+ size: number,
17
+ theme: themeType,
17
18
  TouchableProps: shape(TouchablePropTypes),
18
- IconProps: shape(Text?.propTypes),
19
- theme: themeType
19
+ TouchableStyle: ViewPropTypes?.style
20
20
  });
@@ -4,7 +4,7 @@ import { View } from 'react-native';
4
4
  import { number, bool, shape, oneOf, func, string, any, elementType } from 'prop-types';
5
5
  import _ from 'lodash';
6
6
 
7
- import Label from '../../../Label';
7
+ import Label from '../../../../../Label';
8
8
 
9
9
  import ownStyles from './styles';
10
10
  import { defaultStepCounter } from './utils';
@@ -65,16 +65,16 @@ const StepsHandler = ({
65
65
  };
66
66
 
67
67
  StepsHandler.propTypes = {
68
+ currentStep: number.isRequired,
69
+ hideStepCounter: bool,
68
70
  nextButton: ActionButtonPropTypes.isRequired,
69
71
  returnButton: ActionButtonPropTypes.isRequired,
72
+ stepCounter: oneOf([string, func]),
73
+ StepCounterComponent: elementType,
70
74
  stepsCount: number.isRequired,
71
- currentStep: number.isRequired,
72
- hideStepCounter: bool,
73
75
  styles: shape(ViewPropTypes?.style),
74
- stepCounter: oneOf([string, func]),
75
76
  // eslint-disable-next-line react/forbid-prop-types
76
- themedStyles: any,
77
- StepCounterComponent: elementType
77
+ themedStyles: any
78
78
  };
79
79
 
80
80
  export default StepsHandler;
@@ -2,9 +2,9 @@ import { StyleSheet } from 'react-native';
2
2
 
3
3
  export default StyleSheet.create({
4
4
  stepsHandler: {
5
- width: '100%',
6
- flexDirection: 'row',
7
5
  alignItems: 'center',
8
- justifyContent: 'space-between'
6
+ flexDirection: 'row',
7
+ justifyContent: 'space-between',
8
+ width: '100%'
9
9
  }
10
10
  });
@@ -0,0 +1,108 @@
1
+ import React, { useEffect } from 'react';
2
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
3
+ import { View } from 'react-native';
4
+ import { number, func, shape, bool, string, oneOf } from 'prop-types';
5
+ import _ from 'lodash';
6
+
7
+ import Label from '../../../Label';
8
+ import { useTheme } from '../../../../theming';
9
+
10
+ import ownStyles from './styles';
11
+ import Header from './components/Header';
12
+ import ActionButtonPropTypes from './components/StepsHandler/components/ActionButton/types';
13
+ import BottomStepHandler from './components/BottomStepHandler';
14
+
15
+ const UTWorkflowContainer = ({
16
+ stepsCount,
17
+ currentStep,
18
+ nextButton,
19
+ returnButton,
20
+ onExit,
21
+ hideStepCounter,
22
+ children,
23
+ styles = {},
24
+ title,
25
+ subtitle,
26
+ stepCounter,
27
+ bottomHandler,
28
+ hideHeader = false,
29
+ useMarkdown
30
+ }) => {
31
+ useEffect(() => () => onExit?.(), []);
32
+ const theme = useTheme();
33
+
34
+ const themedStyles = _.merge({}, ownStyles, theme?.UTWorkflowContainer, styles);
35
+
36
+ const { titleProps, subtitleProps } = themedStyles?.labelProps || {};
37
+
38
+ const Title = React.isValidElement(title) ? (
39
+ title
40
+ ) : (
41
+ <Label big bold {...titleProps} style={themedStyles.title}>
42
+ {title}
43
+ </Label>
44
+ );
45
+
46
+ const Subtitle = React.isValidElement(subtitle) ? (
47
+ subtitle
48
+ ) : (
49
+ <Label
50
+ medium
51
+ {...subtitleProps}
52
+ style={themedStyles.subtitle}
53
+ markdownStyles={themedStyles.markdown}
54
+ useMarkdown={useMarkdown}
55
+ >
56
+ {subtitle}
57
+ </Label>
58
+ );
59
+
60
+ return (
61
+ <View style={themedStyles.container}>
62
+ {!hideHeader && (
63
+ <Header
64
+ stepsCount={stepsCount}
65
+ currentStep={currentStep}
66
+ nextButton={nextButton}
67
+ returnButton={returnButton}
68
+ hideStepCounter={hideStepCounter}
69
+ themedStyles={themedStyles}
70
+ styles={styles}
71
+ stepCounter={stepCounter}
72
+ bottomHandler={bottomHandler}
73
+ />
74
+ )}
75
+ {!!title && Title}
76
+ {!!subtitle && Subtitle}
77
+ {children}
78
+ {bottomHandler && (
79
+ <BottomStepHandler
80
+ stepsCount={stepsCount}
81
+ currentStep={currentStep}
82
+ styles={styles}
83
+ nextButton={nextButton}
84
+ themedStyles={themedStyles}
85
+ returnButton={returnButton}
86
+ hideStepCounter={hideStepCounter}
87
+ stepCounter={stepCounter}
88
+ />
89
+ )}
90
+ </View>
91
+ );
92
+ };
93
+ UTWorkflowContainer.propTypes = {
94
+ bottomHandler: bool,
95
+ currentStep: number.isRequired,
96
+ hideHeader: bool,
97
+ hideStepCounter: bool,
98
+ nextButton: ActionButtonPropTypes.isRequired,
99
+ onExit: func,
100
+ returnButton: ActionButtonPropTypes.isRequired,
101
+ stepCounter: oneOf([func, string]),
102
+ stepsCount: number.isRequired,
103
+ styles: shape(ViewPropTypes?.style),
104
+ subtitle: string,
105
+ title: string,
106
+ useMarkdown: bool
107
+ };
108
+ export default UTWorkflowContainer;
@@ -4,12 +4,12 @@ const BORDER_RADIUS_SIZE = 20;
4
4
 
5
5
  export default StyleSheet.create({
6
6
  container: {
7
- flex: 1,
8
7
  alignItems: 'center',
9
8
  backgroundColor: 'white',
10
- borderRadius: BORDER_RADIUS_SIZE,
11
- paddingHorizontal: BORDER_RADIUS_SIZE / 1.25,
12
9
  borderColor: '#e2e2e2',
13
- borderWidth: 1
10
+ borderRadius: BORDER_RADIUS_SIZE,
11
+ borderWidth: 1,
12
+ flex: 1,
13
+ paddingHorizontal: BORDER_RADIUS_SIZE / 1.25
14
14
  }
15
15
  });
@@ -0,0 +1,35 @@
1
+ import React from 'react';
2
+ import { string, func, bool } from 'prop-types';
3
+ import { View } from 'react-native';
4
+ import _ from 'lodash';
5
+
6
+ import Button from '../../../../../../../Button';
7
+
8
+ import ownStyles from './styles';
9
+
10
+ const ActionButton = ({ hidden, disabled, onPress, label, mode, style }) => {
11
+ const themedStyles = _.merge({}, ownStyles, style);
12
+
13
+ return (
14
+ <View style={themedStyles.actionButton}>
15
+ <Button
16
+ disabled={disabled || hidden}
17
+ mode={mode}
18
+ lowerCase
19
+ title={label}
20
+ onPress={onPress}
21
+ containerStyle={themedStyles.buttonContainer}
22
+ />
23
+ </View>
24
+ );
25
+ };
26
+
27
+ ActionButton.propTypes = {
28
+ disabled: bool,
29
+ hidden: bool,
30
+ label: string,
31
+ mode: string,
32
+ onPress: func
33
+ };
34
+
35
+ export default ActionButton;