@widergy/mobile-ui 1.18.5 → 1.18.6

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [1.18.6](https://github.com/widergy/mobile-ui/compare/v1.18.5...v1.18.6) (2024-08-23)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * utselectablecard border radius ([#331](https://github.com/widergy/mobile-ui/issues/331)) ([00f17a6](https://github.com/widergy/mobile-ui/commit/00f17a6ac99f764df6f82b61fd733a7fddae8e27))
7
+
1
8
  ## [1.18.5](https://github.com/widergy/mobile-ui/compare/v1.18.4...v1.18.5) (2024-08-23)
2
9
 
3
10
 
@@ -1,8 +1,7 @@
1
1
  import React from 'react';
2
2
  import { bool, func, number, shape, string } from 'prop-types';
3
3
  import { Image, View } from 'react-native';
4
- import merge from 'lodash/merge';
5
- import { isEmpty } from 'lodash';
4
+ import isEmpty from 'lodash/isEmpty';
6
5
 
7
6
  import Touchable from '../Touchable';
8
7
  import Surface from '../Surface';
@@ -10,8 +9,9 @@ import UTTooltip from '../UTTooltip';
10
9
  import { useTheme } from '../../theming';
11
10
  import UTIcon from '../UTIcon';
12
11
  import UTLabel from '../UTLabel';
12
+ import { mergeMultipleStyles } from '../../utils/styleUtils';
13
13
 
14
- import { getColorTheme, getUTSelectableCardStyles, ICON_SIZE } from './styles';
14
+ import { getColorTheme, ownStyles, ICON_SIZE, getAppearanceStyles, ownSizeStyles } from './styles';
15
15
 
16
16
  const UTSelectableCard = ({
17
17
  additionalInfo = {},
@@ -28,9 +28,10 @@ const UTSelectableCard = ({
28
28
  tooltip
29
29
  }) => {
30
30
  const theme = useTheme();
31
- const themedStyles = merge(
32
- {},
33
- getUTSelectableCardStyles(theme?.UTSelectableCard),
31
+ const themedStyles = mergeMultipleStyles(
32
+ ownStyles,
33
+ getAppearanceStyles(theme)[appearance],
34
+ ownSizeStyles[size],
34
35
  theme?.UTSelectableCard,
35
36
  style
36
37
  );
@@ -43,10 +44,10 @@ const UTSelectableCard = ({
43
44
  disabled={disabled}
44
45
  onPress={() => onPress?.()}
45
46
  style={[
46
- themedStyles[`${appearance}Appearance`],
47
- selected && themedStyles[`${appearance}SelectedContainer`],
48
- disabled && themedStyles[`${appearance}DisabledContainer`],
49
- themedStyles[`${size}Size`]
47
+ themedStyles.appearance,
48
+ selected && themedStyles.selectedContainer,
49
+ disabled && themedStyles.disabledContainer,
50
+ themedStyles.size
50
51
  ]}
51
52
  >
52
53
  <View style={themedStyles.container}>
@@ -2,88 +2,102 @@ import { StyleSheet } from 'react-native';
2
2
 
3
3
  export const ICON_SIZE = 40;
4
4
 
5
- export const getUTSelectableCardStyles = (theme = {}) =>
6
- StyleSheet.create({
7
- additionalInfo: {
8
- textAlign: 'right'
9
- },
10
- checkIcon: {
11
- marginLeft: 16
12
- },
13
- column: {
14
- alignSelf: 'center'
15
- },
16
- container: {
17
- alignItems: 'center',
18
- display: 'flex',
19
- flexDirection: 'row'
20
- },
21
- description: {
22
- marginTop: 4
23
- },
24
- icon: {
25
- marginRight: 16
26
- },
27
- outerContainer: {
28
- borderRadius: 4
29
- },
30
- selectedTitleAndTooltip: {
31
- maxWidth: 300
32
- },
33
- textContainer: {
34
- display: 'flex',
35
- flexDirection: 'row',
36
- flexGrow: 1,
37
- justifyContent: 'space-between'
38
- },
39
- titleAndTooltip: {
40
- alignItems: 'center',
41
- display: 'flex',
42
- flexDirection: 'row'
43
- },
44
- titleMargin: {
45
- marginRight: 8
46
- },
47
-
48
- // Sizes
49
- mediumSize: {
50
- padding: 24
51
- },
52
- smallSize: {
53
- padding: 16
54
- },
5
+ const WHITE = 'white';
6
+ const GRAY = 'gray';
55
7
 
56
- // White
57
- whiteAppearance: {
58
- backgroundColor: theme.whiteBackground || 'white',
8
+ export const getAppearanceStyles = (theme = {}) => ({
9
+ [WHITE]: {
10
+ appearance: {
11
+ backgroundColor: theme.Palette.light['01'],
59
12
  borderColor: 'transparent',
13
+ borderRadius: 4,
60
14
  borderWidth: 2
61
15
  },
62
- whiteDisabledContainer: {
63
- backgroundColor: theme.whiteDisabledBackground || 'lightgray',
16
+ disabledContainer: {
17
+ backgroundColor: theme.Palette.light['03'],
64
18
  borderColor: 'transparent',
65
19
  borderWidth: 2
66
20
  },
67
- whiteSelectedContainer: {
68
- borderColor: theme.whiteSelectedBorder || 'royalblue',
21
+ selectedContainer: {
22
+ borderColor: theme.Palette.accent['05'],
69
23
  borderWidth: 2
70
- },
71
-
72
- // Gray
73
- grayAppearance: {
74
- backgroundColor: theme.grayBackground || 'gainsboro',
75
- borderColor: theme.grayBorder || 'gray',
24
+ }
25
+ },
26
+ [GRAY]: {
27
+ appearance: {
28
+ backgroundColor: theme.Palette.light['03'],
29
+ borderColor: theme.Palette.light['05'],
30
+ borderRadius: 4,
76
31
  borderWidth: 1
77
32
  },
78
- grayDisabledContainer: {
79
- borderColor: theme.grayDisabledBorder || 'gray',
80
- borderWidth: 2
33
+ disabledContainer: {
34
+ borderWidth: 1
81
35
  },
82
- graySelectedContainer: {
83
- backgroundColor: theme.graySelectedBackground || 'aliceblue',
84
- borderColor: theme.graySelectedBorder || 'royalblue',
85
- borderWidth: 2
36
+ selectedContainer: {
37
+ backgroundColor: theme.Palette.accent['01'],
38
+ borderColor: theme.Palette.accent['03'],
39
+ borderWidth: 1
86
40
  }
87
- });
41
+ }
42
+ });
43
+
44
+ const MEDIUM = 'medium';
45
+ const SMALL = 'small';
46
+
47
+ export const ownSizeStyles = {
48
+ [MEDIUM]: {
49
+ size: {
50
+ padding: 24
51
+ }
52
+ },
53
+ [SMALL]: {
54
+ size: {
55
+ padding: 16
56
+ }
57
+ }
58
+ };
59
+
60
+ export const ownStyles = StyleSheet.create({
61
+ additionalInfo: {
62
+ textAlign: 'right'
63
+ },
64
+ checkIcon: {
65
+ marginLeft: 16
66
+ },
67
+ column: {
68
+ alignSelf: 'center'
69
+ },
70
+ container: {
71
+ alignItems: 'center',
72
+ display: 'flex',
73
+ flexDirection: 'row'
74
+ },
75
+ description: {
76
+ marginTop: 4
77
+ },
78
+ icon: {
79
+ marginRight: 16
80
+ },
81
+ outerContainer: {
82
+ borderRadius: 4
83
+ },
84
+ selectedTitleAndTooltip: {
85
+ maxWidth: 300
86
+ },
87
+ textContainer: {
88
+ display: 'flex',
89
+ flexDirection: 'row',
90
+ flexGrow: 1,
91
+ justifyContent: 'space-between'
92
+ },
93
+ titleAndTooltip: {
94
+ alignItems: 'center',
95
+ display: 'flex',
96
+ flexDirection: 'row'
97
+ },
98
+ titleMargin: {
99
+ marginRight: 8
100
+ }
101
+ });
88
102
 
89
103
  export const getColorTheme = (selected, disabled) => (selected ? 'accent' : disabled ? 'gray' : 'dark');
@@ -1,3 +1,6 @@
1
+ import isArray from 'lodash/isArray';
2
+ import mergeWith from 'lodash/mergeWith';
3
+
1
4
  export const SHADOW_OPACITY = 0.1;
2
5
 
3
6
  const shadowLevels = {
@@ -65,6 +68,18 @@ export const getCustomStyles = (variants, props, styles, stylePrefix = '') =>
65
68
  .map(variant => (props[variant] ? styles[`${variant}${stylePrefix}`] : null))
66
69
  .filter(style => style !== null);
67
70
 
71
+ const asArray = value => (isArray(value) ? value : [value]);
72
+
73
+ export const mergeMultipleStyles = (...params) => {
74
+ return mergeWith({}, ...params, (valueA, valueB) => {
75
+ if (valueA && valueB && (isArray(valueA) || isArray(valueB))) {
76
+ return [...asArray(valueA), ...asArray(valueB)];
77
+ }
78
+ // By returning `undefined`, lodash will use its default merging behavior for objects
79
+ return undefined;
80
+ });
81
+ };
82
+
68
83
  export default {
69
84
  generateLayoutMeasuresObject,
70
85
  getCustomStyles
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": "1.18.5",
5
+ "version": "1.18.6",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [