@widergy/mobile-ui 2.17.0 → 2.18.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 (33) hide show
  1. package/CHANGELOG.md +24 -2
  2. package/lib/components/UTBottomSheet/index.js +35 -32
  3. package/lib/components/UTBottomSheet/styles.js +4 -3
  4. package/lib/components/UTDatePicker/README.md +73 -0
  5. package/lib/components/UTDatePicker/components/Calendar/constants.js +3 -0
  6. package/lib/components/UTDatePicker/components/Calendar/index.js +197 -0
  7. package/lib/components/UTDatePicker/components/Day/index.js +44 -0
  8. package/lib/components/UTDatePicker/components/Day/styles.js +8 -0
  9. package/lib/components/UTDatePicker/components/PickerColumn/index.js +57 -0
  10. package/lib/components/UTDatePicker/constants.js +48 -0
  11. package/lib/components/UTDatePicker/index.js +135 -0
  12. package/lib/components/UTDatePicker/layout.js +108 -0
  13. package/lib/components/UTDatePicker/proptypes.js +20 -0
  14. package/lib/components/UTDatePicker/styles.js +63 -0
  15. package/lib/components/UTDatePicker/theme.js +18 -0
  16. package/lib/components/UTDatePicker/utils.js +52 -0
  17. package/lib/components/UTLoading/README.md +109 -31
  18. package/lib/components/UTLoading/index.js +9 -9
  19. package/lib/components/UTLoading/{components → versions/V0/components}/AnimatedCircles/index.js +1 -1
  20. package/lib/components/UTLoading/{components → versions/V0/components}/AnimatedCircles/styles.js +16 -13
  21. package/lib/components/UTLoading/{components → versions/V0/components}/Spinner/index.js +4 -4
  22. package/lib/components/UTLoading/{components → versions/V0/components}/Spinner/styles.js +0 -3
  23. package/lib/components/UTLoading/versions/V0/index.js +18 -0
  24. package/lib/components/UTLoading/versions/V1/components/LoaderWithLogo/index.js +84 -0
  25. package/lib/components/UTLoading/versions/V1/components/LoaderWithLogo/theme.js +45 -0
  26. package/lib/components/UTLoading/versions/V1/components/Spinner/constants.js +5 -0
  27. package/lib/components/UTLoading/versions/V1/components/Spinner/index.js +143 -0
  28. package/lib/components/UTLoading/versions/V1/components/Spinner/theme.js +23 -0
  29. package/lib/components/UTLoading/versions/V1/index.js +33 -0
  30. package/lib/constants/testIds.js +19 -0
  31. package/lib/index.js +1 -0
  32. package/package.json +5 -4
  33. /package/lib/components/UTLoading/{components → versions/V0/components}/AnimatedCircles/constants.js +0 -0
@@ -0,0 +1,18 @@
1
+ import React from 'react';
2
+ import { bool } from 'prop-types';
3
+
4
+ import AnimatedCircles from './components/AnimatedCircles';
5
+ import Spinner from './components/Spinner';
6
+
7
+ const UTLoading = props => {
8
+ const { useUtilityLoading } = props || {};
9
+ return useUtilityLoading ? <AnimatedCircles {...props} /> : <Spinner {...props} />;
10
+ };
11
+
12
+ UTLoading.displayName = 'UTLoading';
13
+
14
+ UTLoading.propTypes = {
15
+ useUtilityLoading: bool
16
+ };
17
+
18
+ export default UTLoading;
@@ -0,0 +1,84 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { Animated, Easing, View } from 'react-native';
3
+ import { bool, elementType, node, number, string } from 'prop-types';
4
+
5
+ import UTLabel from '../../../../../UTLabel';
6
+ import { TEST_IDS } from '../../../../../../constants/testIds';
7
+
8
+ import { ownStyles } from './theme';
9
+
10
+ const { UTLoading: loadingIds } = TEST_IDS;
11
+
12
+ const LoaderWithLogo = ({
13
+ children,
14
+ dataTestId = loadingIds.loader,
15
+ fullScreen = false,
16
+ loading,
17
+ LoaderRing,
18
+ Logo,
19
+ logoSize,
20
+ message,
21
+ rotationDuration,
22
+ size
23
+ }) => {
24
+ const rotation = useRef(new Animated.Value(0)).current;
25
+
26
+ useEffect(() => {
27
+ Animated.loop(
28
+ Animated.timing(rotation, {
29
+ duration: rotationDuration,
30
+ easing: Easing.linear,
31
+ toValue: 1,
32
+ useNativeDriver: false
33
+ })
34
+ ).start();
35
+ }, [rotation, rotationDuration]);
36
+
37
+ if (!loading) return children ?? null;
38
+
39
+ const spin = rotation.interpolate({
40
+ inputRange: [0, 1],
41
+ outputRange: ['0deg', '360deg']
42
+ });
43
+
44
+ const containerStyle = fullScreen ? ownStyles.fullScreen : ownStyles.container;
45
+
46
+ return (
47
+ <View style={containerStyle} testID={dataTestId}>
48
+ <View style={[ownStyles.ringWrapper, { height: size, width: size }]}>
49
+ {!!LoaderRing && (
50
+ <Animated.View style={[ownStyles.ringAbsolute, { transform: [{ rotate: spin }] }]}>
51
+ <LoaderRing height={size} width={size} />
52
+ </Animated.View>
53
+ )}
54
+ {!!Logo && (
55
+ <View style={ownStyles.logoWrapper}>
56
+ <Logo height={logoSize} width={logoSize} />
57
+ </View>
58
+ )}
59
+ </View>
60
+ {!!message && (
61
+ <UTLabel style={ownStyles.message} variant="small">
62
+ {message}
63
+ </UTLabel>
64
+ )}
65
+ </View>
66
+ );
67
+ };
68
+
69
+ LoaderWithLogo.displayName = 'UTLoading';
70
+
71
+ LoaderWithLogo.propTypes = {
72
+ children: node,
73
+ dataTestId: string,
74
+ fullScreen: bool,
75
+ loading: bool,
76
+ LoaderRing: elementType,
77
+ Logo: elementType,
78
+ logoSize: number,
79
+ message: string,
80
+ rotationDuration: number,
81
+ size: number
82
+ };
83
+
84
+ export default LoaderWithLogo;
@@ -0,0 +1,45 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ const WHITE = '#ffffff';
4
+
5
+ export const ownStyles = StyleSheet.create({
6
+ container: {
7
+ alignItems: 'center',
8
+ backgroundColor: WHITE,
9
+ flex: 1,
10
+ justifyContent: 'center',
11
+ width: '100%'
12
+ },
13
+ fullScreen: {
14
+ alignItems: 'center',
15
+ backgroundColor: WHITE,
16
+ bottom: 0,
17
+ elevation: 9999,
18
+ justifyContent: 'center',
19
+ left: 0,
20
+ position: 'absolute',
21
+ right: 0,
22
+ top: 0,
23
+ zIndex: 9999
24
+ },
25
+ logoWrapper: {
26
+ alignItems: 'center',
27
+ bottom: 0,
28
+ justifyContent: 'center',
29
+ left: 0,
30
+ position: 'absolute',
31
+ right: 0,
32
+ top: 0
33
+ },
34
+ message: {
35
+ marginTop: 12,
36
+ textAlign: 'center'
37
+ },
38
+ ringAbsolute: {
39
+ position: 'absolute'
40
+ },
41
+ ringWrapper: {
42
+ alignItems: 'center',
43
+ justifyContent: 'center'
44
+ }
45
+ });
@@ -0,0 +1,5 @@
1
+ export const SPINNER_SIZE = 72;
2
+ export const SPINNER_THICKNESS = 5;
3
+ export const SPINNER_ROTATION_DURATION = 1000;
4
+ export const ARC_SWEEP_DEGREES = 270;
5
+ export const GRADIENT_ID = 'spinnerGrad';
@@ -0,0 +1,143 @@
1
+ import React, { useEffect, useRef } from 'react';
2
+ import { Animated, Easing, View } from 'react-native';
3
+ import { arrayOf, bool, node, number, string } from 'prop-types';
4
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
5
+ import { Circle, Defs, LinearGradient, Stop, Svg } from 'react-native-svg';
6
+
7
+ import { useTheme } from '../../../../../../theming';
8
+ import UTLabel from '../../../../../UTLabel';
9
+ import { TEST_IDS } from '../../../../../../constants/testIds';
10
+
11
+ import {
12
+ ARC_SWEEP_DEGREES,
13
+ GRADIENT_ID,
14
+ SPINNER_ROTATION_DURATION,
15
+ SPINNER_SIZE,
16
+ SPINNER_THICKNESS
17
+ } from './constants';
18
+ import {
19
+ getArcColor,
20
+ getRadius,
21
+ getSpinnerSize,
22
+ getSpinnerThickness,
23
+ getTrackColor,
24
+ ownStyles
25
+ } from './theme';
26
+
27
+ const AnimatedSvg = Animated.createAnimatedComponent(Svg);
28
+
29
+ const { UTLoading: loadingIds } = TEST_IDS;
30
+
31
+ const renderArc = (spinnerSize, radius, arcColor, spinnerThickness, arcLength, circumference, colors) => {
32
+ const isGradient = colors?.length === 2;
33
+ return (
34
+ <>
35
+ {isGradient && (
36
+ <Defs>
37
+ <LinearGradient id={GRADIENT_ID} x1="0" y1="0" x2="1" y2="0">
38
+ <Stop offset="0" stopColor={colors[0]} />
39
+ <Stop offset="1" stopColor={colors[1]} />
40
+ </LinearGradient>
41
+ </Defs>
42
+ )}
43
+ <Circle
44
+ cx={spinnerSize / 2}
45
+ cy={spinnerSize / 2}
46
+ r={radius}
47
+ stroke={isGradient ? `url(#${GRADIENT_ID})` : arcColor}
48
+ strokeWidth={spinnerThickness}
49
+ strokeLinecap="round"
50
+ strokeDasharray={`${arcLength} ${circumference - arcLength}`}
51
+ strokeDashoffset={0}
52
+ fill="none"
53
+ />
54
+ </>
55
+ );
56
+ };
57
+
58
+ const Spinner = ({
59
+ children,
60
+ colors,
61
+ dataTestId = loadingIds.spinner,
62
+ loading,
63
+ message,
64
+ preventUnmount,
65
+ size = SPINNER_SIZE,
66
+ style,
67
+ thickness = SPINNER_THICKNESS
68
+ }) => {
69
+ const theme = useTheme();
70
+ const rotation = useRef(new Animated.Value(0)).current;
71
+
72
+ useEffect(() => {
73
+ Animated.loop(
74
+ Animated.timing(rotation, {
75
+ duration: SPINNER_ROTATION_DURATION,
76
+ easing: Easing.linear,
77
+ toValue: 1,
78
+ useNativeDriver: true
79
+ })
80
+ ).start();
81
+ }, [rotation]);
82
+
83
+ if (!loading && !preventUnmount) return children ?? null;
84
+
85
+ const spinnerSize = getSpinnerSize(size);
86
+ const spinnerThickness = getSpinnerThickness(thickness);
87
+ const radius = getRadius(size, thickness);
88
+ const circumference = 2 * Math.PI * radius;
89
+ const arcLength = (ARC_SWEEP_DEGREES / 360) * circumference;
90
+ const trackColor = getTrackColor(theme);
91
+ const arcColor = colors?.length >= 1 ? colors[0] : getArcColor(theme);
92
+
93
+ const spin = rotation.interpolate({ inputRange: [0, 1], outputRange: ['0deg', '360deg'] });
94
+
95
+ const spinnerContent = (
96
+ <View style={[ownStyles.container, style]} testID={dataTestId}>
97
+ <AnimatedSvg width={spinnerSize} height={spinnerSize} style={{ transform: [{ rotate: spin }] }}>
98
+ <Circle
99
+ cx={spinnerSize / 2}
100
+ cy={spinnerSize / 2}
101
+ r={radius}
102
+ stroke={trackColor}
103
+ strokeWidth={spinnerThickness}
104
+ fill="none"
105
+ />
106
+ {renderArc(spinnerSize, radius, arcColor, spinnerThickness, arcLength, circumference, colors)}
107
+ </AnimatedSvg>
108
+ {!!message && (
109
+ <UTLabel style={ownStyles.message} variant="small">
110
+ {message}
111
+ </UTLabel>
112
+ )}
113
+ </View>
114
+ );
115
+
116
+ if (preventUnmount) {
117
+ return (
118
+ <>
119
+ {!!loading && spinnerContent}
120
+ {/* eslint-disable-next-line react-native/no-inline-styles */}
121
+ <View style={{ display: loading ? 'none' : 'flex' }}>{children}</View>
122
+ </>
123
+ );
124
+ }
125
+
126
+ return spinnerContent;
127
+ };
128
+
129
+ Spinner.displayName = 'UTLoading';
130
+
131
+ Spinner.propTypes = {
132
+ children: node,
133
+ colors: arrayOf(string),
134
+ dataTestId: string,
135
+ loading: bool,
136
+ message: string,
137
+ preventUnmount: bool,
138
+ style: ViewPropTypes.style,
139
+ size: number,
140
+ thickness: number
141
+ };
142
+
143
+ export default Spinner;
@@ -0,0 +1,23 @@
1
+ import { SPINNER_SIZE, SPINNER_THICKNESS } from './constants';
2
+
3
+ export const ownStyles = {
4
+ container: {
5
+ alignItems: 'center',
6
+ flex: 1,
7
+ justifyContent: 'center'
8
+ },
9
+ message: {
10
+ marginTop: 12,
11
+ textAlign: 'center'
12
+ }
13
+ };
14
+
15
+ export const getSpinnerSize = size => size || SPINNER_SIZE;
16
+
17
+ export const getSpinnerThickness = thickness => thickness || SPINNER_THICKNESS;
18
+
19
+ export const getRadius = (size, thickness) => (getSpinnerSize(size) - getSpinnerThickness(thickness)) / 2;
20
+
21
+ export const getArcColor = theme => theme?.UTLoading?.arcColor || theme?.colors?.primary;
22
+
23
+ export const getTrackColor = theme => theme?.UTLoading?.trackColor || theme?.Palette?.light?.['04'];
@@ -0,0 +1,33 @@
1
+ import React from 'react';
2
+ import { arrayOf, bool, elementType, node, number, string } from 'prop-types';
3
+ import { ViewPropTypes } from 'deprecated-react-native-prop-types';
4
+
5
+ import LoaderWithLogo from './components/LoaderWithLogo';
6
+ import Spinner from './components/Spinner';
7
+
8
+ const UTLoading = props => {
9
+ const { useUtilityLoading } = props || {};
10
+ return useUtilityLoading ? <LoaderWithLogo {...props} /> : <Spinner {...props} />;
11
+ };
12
+
13
+ UTLoading.displayName = 'UTLoading';
14
+
15
+ UTLoading.propTypes = {
16
+ children: node,
17
+ colors: arrayOf(string),
18
+ dataTestId: string,
19
+ fullScreen: bool,
20
+ loading: bool,
21
+ LoaderRing: elementType,
22
+ Logo: elementType,
23
+ logoSize: number,
24
+ message: string,
25
+ preventUnmount: bool,
26
+ rotationDuration: number,
27
+ size: number,
28
+ style: ViewPropTypes.style,
29
+ thickness: number,
30
+ useUtilityLoading: bool
31
+ };
32
+
33
+ export default UTLoading;
@@ -19,6 +19,7 @@ export const TEST_ID_CONSTANTS = {
19
19
  label: 'label',
20
20
  left: 'left',
21
21
  list: 'list',
22
+ loader: 'loader',
22
23
  logo: 'logo',
23
24
  modal: 'modal',
24
25
  option: 'option',
@@ -30,6 +31,7 @@ export const TEST_ID_CONSTANTS = {
30
31
  searchInput: 'searchInput',
31
32
  secondaryAction: 'secondaryAction',
32
33
  selectAll: 'selectAll',
34
+ spinner: 'spinner',
33
35
  subLabel: 'subLabel',
34
36
  subtitle: 'subtitle',
35
37
  tagline: 'tagline',
@@ -44,8 +46,25 @@ export const TEST_ID_CONSTANTS = {
44
46
 
45
47
  export const TEST_IDS = {
46
48
  modal: 'modal',
49
+ UTDatePicker: {
50
+ calendar: 'UTDatePicker.calendar',
51
+ calendarMonthYear: 'UTDatePicker.calendar.monthYear',
52
+ calendarNextBtn: 'UTDatePicker.calendar.nextBtn',
53
+ calendarPrevBtn: 'UTDatePicker.calendar.prevBtn',
54
+ errorMessage: 'UTDatePicker.errorMessage',
55
+ input: 'UTDatePicker.input',
56
+ monthItem: 'UTDatePicker.monthItem',
57
+ monthView: 'UTDatePicker.monthView',
58
+ root: 'UTDatePicker.root',
59
+ yearItem: 'UTDatePicker.yearItem',
60
+ yearView: 'UTDatePicker.yearView'
61
+ },
47
62
  roundView: 'roundView',
48
63
  skeletonLoader: 'skeletonLoader',
64
+ UTLoading: {
65
+ loader: `UTLoading.${TEST_ID_CONSTANTS.loader}`,
66
+ spinner: `UTLoading.${TEST_ID_CONSTANTS.spinner}`
67
+ },
49
68
  topbar: {
50
69
  goBack: 'topbar.goBack',
51
70
  title: 'topbar.title'
package/lib/index.js CHANGED
@@ -49,6 +49,7 @@ export { default as UTCuit } from './components/UTCuit';
49
49
  export { default as UTCheckList } from './components/UTCheckList';
50
50
  export { default as UTDataCategory } from './components/UTDataCategory';
51
51
  export { default as UTDataElement } from './components/UTDataElement';
52
+ export { default as UTDatePicker } from './components/UTDatePicker';
52
53
  export { default as UTDetailDrawer } from './components/UTDetailDrawer';
53
54
  export { default as UTIcon } from './components/UTIcon';
54
55
  export { default as UTImage } from './components/UTImage';
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@widergy/mobile-ui",
3
3
  "description": "Widergy Mobile Components",
4
4
  "author": "widergy",
5
- "version": "2.17.0",
5
+ "version": "2.18.0",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [
@@ -43,6 +43,7 @@
43
43
  "@tabler/icons-react-native": "^3.34.1",
44
44
  "@widergy/web-utils": "^2.0.0",
45
45
  "core-js": "3",
46
+ "dayjs": "^1.11.10",
46
47
  "deprecated-react-native-prop-types": "^5.0.0",
47
48
  "expo-document-picker": "^13.1.6",
48
49
  "expo-image-manipulator": "^13.1.7",
@@ -73,12 +74,12 @@
73
74
  "@commitlint/config-conventional": "^17.7.0",
74
75
  "@eslint/compat": "^1.4.0",
75
76
  "@eslint/eslintrc": "^3.3.0",
76
- "@widergy/semantic-release-package-config": "^1.0.0",
77
- "@widergy/eslint-config": "^1.0.0",
78
77
  "@react-native/babel-preset": "0.73.0",
78
+ "@widergy/eslint-config": "^1.0.0",
79
+ "@widergy/semantic-release-package-config": "^1.0.0",
80
+ "babel-jest": "^29.6.2",
79
81
  "babel-plugin-import-glob": "^2.0.0",
80
82
  "babel-plugin-module-resolver": "^5.0.0",
81
- "babel-jest": "^29.6.2",
82
83
  "babel-preset-minify": "^0.5.2",
83
84
  "eslint": "^9.38.0",
84
85
  "eslint-config-airbnb": "^19.0.4",