@momo-kits/foundation 0.89.5 → 0.89.6-rc.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.
Files changed (73) hide show
  1. package/Application/BottomSheet.tsx +216 -0
  2. package/Application/BottomTab/BottomTabBar.tsx +278 -0
  3. package/Application/{BottomTab.tsx → BottomTab/index.tsx} +42 -18
  4. package/Application/Components.tsx +350 -86
  5. package/Application/Localize.ts +44 -0
  6. package/Application/ModalScreen.tsx +14 -185
  7. package/Application/Navigation.ts +5 -19
  8. package/Application/NavigationContainer.tsx +62 -72
  9. package/Application/Navigator.ts +53 -35
  10. package/Application/StackScreen.tsx +289 -32
  11. package/Application/index.ts +13 -15
  12. package/Application/types.ts +64 -35
  13. package/Application/utils.tsx +76 -30
  14. package/Assets/icon_bank.json +1 -1
  15. package/Badge/Badge.tsx +1 -1
  16. package/Badge/BadgeDotAnimation.tsx +95 -0
  17. package/Badge/index.tsx +2 -1
  18. package/Badge/styles.ts +50 -6
  19. package/Button/index.tsx +44 -26
  20. package/CheckBox/index.tsx +37 -26
  21. package/CheckBox/types.ts +5 -3
  22. package/Consts/colors+spacing+radius.ts +14 -0
  23. package/Icon/index.tsx +9 -8
  24. package/Icon/types.ts +2 -2
  25. package/IconButton/index.tsx +24 -14
  26. package/Image/index.tsx +23 -8
  27. package/Image/types.ts +2 -0
  28. package/Input/Input.tsx +116 -26
  29. package/Input/InputDropDown.tsx +66 -51
  30. package/Input/InputMoney.tsx +106 -15
  31. package/Input/InputOTP.tsx +49 -26
  32. package/Input/InputSearch.tsx +252 -99
  33. package/Input/InputTextArea.tsx +26 -6
  34. package/Input/TextTyping.tsx +113 -0
  35. package/Input/common.tsx +48 -22
  36. package/Input/index.tsx +112 -77
  37. package/Input/styles.ts +48 -11
  38. package/Input/utils.ts +1 -1
  39. package/Layout/Card.tsx +4 -3
  40. package/Layout/FloatingButton.tsx +168 -0
  41. package/Layout/GridSystem.tsx +1 -1
  42. package/Layout/ItemList.tsx +3 -2
  43. package/Layout/Screen.tsx +242 -121
  44. package/Layout/Section.tsx +4 -3
  45. package/Layout/styles.ts +11 -13
  46. package/Layout/types.ts +1 -1
  47. package/Layout/utils.ts +4 -4
  48. package/Loader/index.tsx +2 -0
  49. package/Pagination/PaginationScroll.tsx +2 -2
  50. package/Pagination/styles.ts +1 -1
  51. package/Popup/PopupNotify.tsx +56 -45
  52. package/Popup/PopupPromotion.tsx +5 -7
  53. package/Popup/types.ts +1 -7
  54. package/Radio/index.tsx +35 -20
  55. package/Radio/types.ts +5 -3
  56. package/Switch/index.tsx +32 -18
  57. package/Switch/types.ts +5 -3
  58. package/Tag/index.tsx +9 -2
  59. package/Tag/styles.ts +3 -2
  60. package/Tag/types.ts +12 -0
  61. package/Text/index.tsx +24 -5
  62. package/Text/styles.ts +8 -8
  63. package/Text/types.ts +19 -1
  64. package/Title/index.tsx +170 -103
  65. package/Title/styles.ts +36 -9
  66. package/Title/types.ts +16 -48
  67. package/code-scanner.js +125 -16
  68. package/index.ts +7 -0
  69. package/migrate_typo.js +56 -0
  70. package/package.json +11 -10
  71. package/publish.sh +16 -21
  72. package/tsconfig.json +1 -1
  73. package/verify.js +37 -40
@@ -7,11 +7,13 @@ import {
7
7
  HeaderBackground,
8
8
  HeaderCustom,
9
9
  HeaderLeft,
10
+ HeaderRight,
10
11
  HeaderTitle,
11
- HeaderToolkitAction,
12
12
  } from './Components';
13
- import {NavigationOptions, Theme} from './types';
13
+ import {NavigationOptions} from './types';
14
14
  import {Colors} from '../Consts';
15
+ import Navigation from './Navigation';
16
+ import {LayoutChangeEvent} from 'react-native';
15
17
 
16
18
  /**
17
19
  * default options for stack screen
@@ -22,7 +24,7 @@ const getStackOptions = (): StackNavigationOptions => {
22
24
  headerTitle: HeaderTitle,
23
25
  headerBackground: (props: any) => <HeaderBackground {...props} />,
24
26
  headerLeft: (props: any) => <HeaderLeft {...props} />,
25
- headerRight: (props: any) => <HeaderToolkitAction {...props} />,
27
+ headerRight: (props: any) => <HeaderRight {...props} />,
26
28
  headerTintColor: Colors.black_01,
27
29
  };
28
30
  };
@@ -72,39 +74,44 @@ const getModalOptions = (): StackNavigationOptions => {
72
74
  /**
73
75
  * build react-navigation options
74
76
  */
75
- const getOptions = (params: NavigationOptions, theme: Theme) => {
77
+ const getOptions = (params: NavigationOptions, navigation?: Navigation) => {
76
78
  let options = {};
77
79
 
80
+ /**
81
+ * left header factory
82
+ */
78
83
  if (
79
84
  typeof params.onPressLeftHeader === 'function' ||
80
85
  params.preventBack !== undefined ||
81
86
  typeof params.hiddenBack === 'boolean'
82
87
  ) {
88
+ let headerLeft: any = (props: any) => (
89
+ <HeaderLeft
90
+ {...props}
91
+ preventBack={params.preventBack}
92
+ onPressLeftHeader={params.onPressLeftHeader}
93
+ />
94
+ );
95
+ if (params.hiddenBack) {
96
+ headerLeft = null;
97
+ }
83
98
  options = {
84
99
  ...options,
85
- headerLeft: params.hiddenBack
86
- ? null
87
- : (props: any) => (
88
- <HeaderLeft
89
- {...props}
90
- preventBack={params.preventBack}
91
- onPressLeftHeader={params.onPressLeftHeader}
92
- />
93
- ),
100
+ headerLeft,
94
101
  };
95
102
  }
96
103
 
97
- if (typeof params.surface == 'boolean') {
104
+ /**
105
+ * surface header style
106
+ */
107
+ if (typeof params.surface === 'boolean') {
108
+ console.warn('surface options is deprecated, headerType instead in screen');
98
109
  if (params.surface) {
99
110
  options = {
100
111
  ...options,
101
- headerTintColor: theme.colors.text.default,
112
+ headerTintColor: Colors.black_17,
102
113
  headerBackground: () => (
103
- <HeaderBackground
104
- image={null}
105
- backgroundColor={theme.colors.background.surface}
106
- useBorder={true}
107
- />
114
+ <HeaderBackground image={null} useSurface={true} />
108
115
  ),
109
116
  };
110
117
  } else {
@@ -116,7 +123,13 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
116
123
  }
117
124
  }
118
125
 
126
+ /**
127
+ * custom title
128
+ */
119
129
  if (params.customTitle) {
130
+ console.warn(
131
+ 'customTitle options is deprecated, please used headerTitle instead'
132
+ );
120
133
  options = {
121
134
  ...options,
122
135
  headerTitleAlign: 'left',
@@ -126,19 +139,39 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
126
139
  };
127
140
  }
128
141
 
129
- options = {
130
- ...options,
131
- headerRight: (props: any) => {
142
+ /**
143
+ * header right
144
+ */
145
+ if (params.headerRight) {
146
+ let headerRight: any = (props: any) => {
147
+ return (
148
+ <HeaderRight
149
+ {...props}
150
+ {...params.headerRight}
151
+ onLayout={(e: LayoutChangeEvent) => {
152
+ navigation?.onHeaderRightChange?.(e.nativeEvent.layout.width);
153
+ }}
154
+ />
155
+ );
156
+ };
157
+ if (typeof params.headerRight === 'function') {
158
+ headerRight = (props: any) => {
132
159
  return (
133
- <HeaderToolkitAction
134
- preventBack={params.preventBack}
135
- pinnedTool={params.toolkitParams?.pinnedTool}
136
- runtimeTools={params.toolkitParams?.runtimeTools}
160
+ <HeaderRight
137
161
  {...props}
138
- />
162
+ onLayout={(e: LayoutChangeEvent) => {
163
+ navigation?.onHeaderRightChange?.(e.nativeEvent.layout.width);
164
+ }}>
165
+ {params.headerRight(props)}
166
+ </HeaderRight>
139
167
  );
140
- },
168
+ };
169
+ }
170
+ options = {
171
+ ...options,
172
+ headerRight,
141
173
  };
174
+ }
142
175
 
143
176
  return {
144
177
  ...params,
@@ -146,4 +179,17 @@ const getOptions = (params: NavigationOptions, theme: Theme) => {
146
179
  };
147
180
  };
148
181
 
149
- export {getStackOptions, getDialogOptions, getModalOptions, getOptions};
182
+ const formatNameLength = (name = '') => {
183
+ let formattedName = name;
184
+ if (formattedName.length > 100) {
185
+ formattedName = formattedName.substring(0, 100);
186
+ }
187
+ return formattedName;
188
+ };
189
+ export {
190
+ getStackOptions,
191
+ getDialogOptions,
192
+ getModalOptions,
193
+ getOptions,
194
+ formatNameLength,
195
+ };
@@ -503,4 +503,4 @@
503
503
  "zalopay_icon": {
504
504
  "uri": "https://static.momocdn.net/app/img/kits/icon_bank/zalopay_icon.png"
505
505
  }
506
- }
506
+ }
package/Badge/Badge.tsx CHANGED
@@ -46,7 +46,7 @@ const Badge: FC<BadgeProps> = ({label = 'Label', style, backgroundColor}) => {
46
46
 
47
47
  return (
48
48
  <View style={[style, styles.badge, {backgroundColor: badgeColor}]}>
49
- <Text color={Colors.black_01} typography={'action_xs_bold'}>
49
+ <Text color={Colors.black_01} typography={'action_xxs_bold'}>
50
50
  {formatTitle()}
51
51
  </Text>
52
52
  </View>
@@ -0,0 +1,95 @@
1
+ import React, {useEffect, useRef} from 'react';
2
+ import {Animated, View} from 'react-native';
3
+ import {BadgeDotProps} from './types';
4
+ import styles from './styles';
5
+
6
+ const DURATION = 500;
7
+
8
+ const BadgeDotAnimation = ({size, style}: BadgeDotProps) => {
9
+ // Refs for animated values
10
+ const scaleAnim = useRef(new Animated.Value(1)).current;
11
+ const waveScaleAnim = useRef(new Animated.Value(1)).current;
12
+ const waveOpacityAnim = useRef(new Animated.Value(0)).current;
13
+
14
+ const dotStyle =
15
+ size === 'small' ? styles.dotAnimationSmall : styles.dotAnimation;
16
+ const waveStyle = size === 'small' ? styles.waveSmall : styles.wave;
17
+
18
+ useEffect(() => {
19
+ // Infinite loop animation for the scale and wave effect
20
+ const animation = Animated.loop(
21
+ Animated.parallel([
22
+ // Dot pulse animation
23
+ Animated.sequence([
24
+ Animated.spring(scaleAnim, {
25
+ toValue: 1, // Scale up slightly
26
+ friction: 5, // Controls the "bounciness" of the spring
27
+ tension: 30, // Controls the "stiffness" of the spring
28
+ useNativeDriver: true,
29
+ }),
30
+ Animated.spring(scaleAnim, {
31
+ toValue: 1.1,
32
+ friction: 5,
33
+ tension: 30,
34
+ useNativeDriver: true,
35
+ }),
36
+ ]), // Wave animation
37
+ Animated.sequence([
38
+ Animated.timing(waveScaleAnim, {
39
+ toValue: 2.5,
40
+ duration: DURATION * 3,
41
+ useNativeDriver: true,
42
+ }),
43
+ Animated.timing(waveScaleAnim, {
44
+ toValue: 1, // Reset wave size
45
+ duration: 0,
46
+ useNativeDriver: true,
47
+ }),
48
+ ]), // Wave opacity animation
49
+ Animated.sequence([
50
+ Animated.timing(waveOpacityAnim, {
51
+ toValue: 0.3, // Wave becomes visible
52
+ duration: DURATION * 2,
53
+ useNativeDriver: true,
54
+ }),
55
+ Animated.timing(waveOpacityAnim, {
56
+ toValue: 0, // Wave fades out
57
+ duration: DURATION,
58
+ useNativeDriver: true,
59
+ }),
60
+ ]),
61
+ ])
62
+ );
63
+ animation.start();
64
+
65
+ return () => {
66
+ animation.stop();
67
+ };
68
+ }, []);
69
+
70
+ return (
71
+ <View style={[styles.dotAnimationContainer, style]}>
72
+ {/* Wave Animation */}
73
+ <Animated.View
74
+ style={[
75
+ waveStyle,
76
+ {
77
+ transform: [{scale: waveScaleAnim}],
78
+ opacity: waveOpacityAnim,
79
+ },
80
+ ]}
81
+ />
82
+ {/* Dot Animation */}
83
+ <Animated.View
84
+ style={[
85
+ dotStyle,
86
+ {
87
+ transform: [{scale: scaleAnim}],
88
+ },
89
+ ]}
90
+ />
91
+ </View>
92
+ );
93
+ };
94
+
95
+ export default BadgeDotAnimation;
package/Badge/index.tsx CHANGED
@@ -1,7 +1,8 @@
1
1
  import Badge from './Badge';
2
2
  import BadgeDot from './BadgeDot';
3
3
  import BadgeRibbon from './BadgeRibbon';
4
+ import BadgeDotAnimation from './BadgeDotAnimation';
4
5
  import {BadgeProps, BadgeDotProps, BadgeRibbonProps} from './types';
5
6
 
6
- export {Badge, BadgeRibbon, BadgeDot};
7
+ export {Badge, BadgeRibbon, BadgeDot, BadgeDotAnimation};
7
8
  export type {BadgeProps, BadgeDotProps, BadgeRibbonProps};
package/Badge/styles.ts CHANGED
@@ -2,6 +2,10 @@ import {StyleSheet} from 'react-native';
2
2
  import {Colors, Radius, Spacing} from '../Consts';
3
3
  import {scaleSize} from '../Text';
4
4
 
5
+ const DOT_SIZE = 16;
6
+
7
+ const DOT_SMALL_SIZE = 10;
8
+
5
9
  export default StyleSheet.create({
6
10
  badge: {
7
11
  paddingHorizontal: Spacing.XS,
@@ -15,21 +19,61 @@ export default StyleSheet.create({
15
19
  borderColor: Colors.black_01,
16
20
  alignSelf: 'baseline',
17
21
  },
22
+ dotAnimationContainer: {
23
+ position: 'relative',
24
+ alignItems: 'center',
25
+ justifyContent: 'center',
26
+ },
18
27
  dot: {
19
- width: 16,
20
- height: 16,
28
+ width: DOT_SIZE,
29
+ height: DOT_SIZE,
21
30
  borderWidth: 2,
22
31
  borderColor: Colors.black_01,
23
32
  backgroundColor: Colors.red_03,
24
- borderRadius: 8,
33
+ borderRadius: DOT_SIZE / 2,
25
34
  },
26
35
  dotSmall: {
27
- width: 10,
28
- height: 10,
36
+ width: DOT_SMALL_SIZE,
37
+ height: DOT_SMALL_SIZE,
29
38
  borderWidth: 1,
30
39
  borderColor: Colors.black_01,
31
40
  backgroundColor: Colors.red_03,
32
- borderRadius: 5,
41
+ borderRadius: DOT_SMALL_SIZE / 2,
42
+ },
43
+ dotAnimation: {
44
+ width: DOT_SIZE,
45
+ height: DOT_SIZE,
46
+ borderColor: Colors.black_01,
47
+ backgroundColor: Colors.red_03,
48
+ borderRadius: DOT_SIZE / 2,
49
+ borderWidth: 0,
50
+ },
51
+ dotAnimationSmall: {
52
+ width: DOT_SMALL_SIZE,
53
+ height: DOT_SMALL_SIZE,
54
+ borderColor: Colors.black_01,
55
+ backgroundColor: Colors.red_03,
56
+ borderRadius: DOT_SMALL_SIZE / 2,
57
+ borderWidth: 0,
58
+ },
59
+ wave: {
60
+ width: DOT_SIZE,
61
+ height: DOT_SIZE,
62
+ borderColor: Colors.black_01,
63
+ backgroundColor: Colors.red_03,
64
+ borderRadius: DOT_SIZE / 2,
65
+ opacity: 0,
66
+ position: 'absolute',
67
+ borderWidth: 0,
68
+ },
69
+ waveSmall: {
70
+ width: DOT_SMALL_SIZE,
71
+ height: DOT_SMALL_SIZE,
72
+ borderColor: Colors.black_01,
73
+ backgroundColor: Colors.red_03,
74
+ borderRadius: DOT_SMALL_SIZE / 2,
75
+ borderWidth: 0,
76
+ position: 'absolute',
33
77
  },
34
78
  ribbon: {
35
79
  alignSelf: 'baseline',
package/Button/index.tsx CHANGED
@@ -6,9 +6,8 @@ import {
6
6
  TouchableOpacityProps,
7
7
  View,
8
8
  } from 'react-native';
9
-
10
9
  import LinearGradient from 'react-native-linear-gradient';
11
- import {ApplicationContext} from '../Application';
10
+ import {ApplicationContext, ComponentContext} from '../Application';
12
11
  import {Text} from '../Text';
13
12
  import {Typography} from '../Text/types';
14
13
  import {Colors, Spacing} from '../Consts';
@@ -59,7 +58,7 @@ export interface ButtonProps extends TouchableOpacityProps {
59
58
  /**
60
59
  * If true, the icon of button will use the tint color provided by its container.
61
60
  */
62
- useTintColor?: boolean;
61
+ tintColor?: string;
63
62
 
64
63
  /**
65
64
  * If true, the icon of button will use be show indicator loading.
@@ -70,30 +69,39 @@ export interface ButtonProps extends TouchableOpacityProps {
70
69
  * A callback function that is called when the button is pressed.
71
70
  */
72
71
  onPress: () => void;
72
+
73
+ params?: any;
73
74
  }
74
75
 
75
76
  const Button: FC<ButtonProps> = ({
76
77
  type = 'primary',
77
78
  size = 'large',
78
- useTintColor = true,
79
+ tintColor = null,
79
80
  full = true,
80
81
  iconRight,
81
82
  iconLeft,
82
83
  loading = false,
83
84
  title = 'Button',
84
85
  onPress,
86
+ params,
87
+ accessibilityLabel,
85
88
  ...rest
86
89
  }) => {
87
90
  const {theme, config} = useContext(ApplicationContext);
88
91
  const {gradient, color} = config?.navigationBar?.buttonColors ?? {};
89
92
  let gradientPros;
90
- if (gradient?.length > 0 && type == 'primary') {
93
+ let state = 'enabled';
94
+ if (loading) {
95
+ state = 'loading';
96
+ }
97
+ if (gradient?.length > 0 && type === 'primary') {
91
98
  gradientPros = {
92
99
  colors: gradient,
93
100
  start: {x: 1, y: 0.5},
94
101
  end: {x: 0, y: 0.5},
95
102
  };
96
103
  }
104
+
97
105
  const getSizeStyle = () => {
98
106
  const styleSheet: {[key: string]: any} = styles;
99
107
  return styleSheet[size ?? 'small'];
@@ -209,9 +217,9 @@ const Button: FC<ButtonProps> = ({
209
217
  */
210
218
  const renderTitle = () => {
211
219
  const typography = getTypography();
212
- const color = getTextColor();
220
+ const textColor = getTextColor();
213
221
  return (
214
- <Text typography={typography} color={color} numberOfLines={1}>
222
+ <Text typography={typography} color={textColor} numberOfLines={1}>
215
223
  {title}
216
224
  </Text>
217
225
  );
@@ -223,7 +231,7 @@ const Button: FC<ButtonProps> = ({
223
231
  const renderLeading = () => {
224
232
  const iconSize = getIconSize();
225
233
  const marginRight = getIconSpace();
226
- const color = useTintColor ? getTextColor() : undefined;
234
+ const textColor = tintColor ?? getTextColor();
227
235
 
228
236
  if (loading) {
229
237
  return (
@@ -237,7 +245,7 @@ const Button: FC<ButtonProps> = ({
237
245
  borderRadius: Spacing.M,
238
246
  },
239
247
  ]}>
240
- <Loader type="spinner" color={color} />
248
+ <Loader type="spinner" color={getTextColor()} />
241
249
  </View>
242
250
  );
243
251
  }
@@ -248,7 +256,7 @@ const Button: FC<ButtonProps> = ({
248
256
  styles.leading,
249
257
  {width: iconSize, height: iconSize, marginRight},
250
258
  ]}>
251
- <Icon color={color} source={iconLeft} size={iconSize} />
259
+ <Icon color={textColor} source={iconLeft} size={iconSize} />
252
260
  </View>
253
261
  );
254
262
  }
@@ -258,7 +266,7 @@ const Button: FC<ButtonProps> = ({
258
266
  * render trailing
259
267
  */
260
268
  const renderTrailing = () => {
261
- const color = useTintColor ? getTextColor() : undefined;
269
+ const textColor = tintColor ?? getTextColor();
262
270
  const marginLeft = getIconSpace();
263
271
 
264
272
  if (iconRight) {
@@ -269,7 +277,7 @@ const Button: FC<ButtonProps> = ({
269
277
  styles.trailing,
270
278
  {width: iconSize, height: iconSize, marginLeft},
271
279
  ]}>
272
- <Icon color={color} source={iconRight} size={iconSize} />
280
+ <Icon color={textColor} source={iconRight} size={iconSize} />
273
281
  </View>
274
282
  );
275
283
  }
@@ -289,21 +297,31 @@ const Button: FC<ButtonProps> = ({
289
297
  };
290
298
 
291
299
  const activeOpacity = type === 'disabled' ? 0.75 : 0.5;
292
-
293
300
  return (
294
- <TouchableOpacity
295
- {...rest}
296
- activeOpacity={activeOpacity}
297
- onPress={onPressButton}
298
- style={buttonStyle}>
299
- {renderLeading()}
300
- {renderTitle()}
301
- {renderTrailing()}
302
- {gradientPros && (
303
- <AnimationLinear {...gradientPros} style={styles.gradientView} />
304
- )}
305
- {gradientPros && <View style={styles.strokeView} />}
306
- </TouchableOpacity>
301
+ <ComponentContext.Provider
302
+ value={{
303
+ componentName: 'Button',
304
+ params,
305
+ state: state,
306
+ componentId: accessibilityLabel,
307
+ componentValue: title,
308
+ action: 'click',
309
+ }}>
310
+ <TouchableOpacity
311
+ {...rest}
312
+ accessibilityLabel={accessibilityLabel}
313
+ activeOpacity={activeOpacity}
314
+ onPress={onPressButton}
315
+ style={buttonStyle}>
316
+ {renderLeading()}
317
+ {renderTitle()}
318
+ {renderTrailing()}
319
+ {gradientPros && (
320
+ <AnimationLinear {...gradientPros} style={styles.gradientView} />
321
+ )}
322
+ {gradientPros && <View style={styles.strokeView} />}
323
+ </TouchableOpacity>
324
+ </ComponentContext.Provider>
307
325
  );
308
326
  };
309
327
 
@@ -2,17 +2,20 @@ import React, {FC, useContext} from 'react';
2
2
  import {TouchableOpacity, View} from 'react-native';
3
3
  import {CheckBoxProps} from './types';
4
4
  import styles from './styles';
5
- import {ApplicationContext} from '../Application';
5
+ import {ApplicationContext, ComponentContext} from '../Application';
6
6
  import {Text} from '../Text';
7
7
  import {Icon} from '../Icon';
8
+ import {formatNameLength} from '../Application/utils';
8
9
 
9
10
  const CheckBox: FC<CheckBoxProps> = ({
10
11
  value,
11
- disabled,
12
+ disabled = false,
12
13
  onChange,
13
14
  style,
14
15
  label,
15
16
  indeterminate,
17
+ params,
18
+ accessibilityLabel,
16
19
  }) => {
17
20
  const {theme} = useContext(ApplicationContext);
18
21
  const haveValue = value || indeterminate;
@@ -35,31 +38,39 @@ const CheckBox: FC<CheckBoxProps> = ({
35
38
  }
36
39
 
37
40
  return (
38
- <TouchableOpacity
39
- activeOpacity={0.8}
40
- onPress={() => onChange?.(!value)}
41
- disabled={disabled}
42
- style={[style, styles.container]}>
43
- <View
44
- style={[
45
- {borderColor, backgroundColor, borderWidth: 1},
46
- styles.checkbox,
47
- ]}>
48
- {haveValue && (
49
- <Icon
50
- color={theme.colors.background.surface}
51
- size={20}
52
- source={iconSource}
53
- />
54
- )}
55
- </View>
56
- {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
57
- </TouchableOpacity>
41
+ <ComponentContext.Provider
42
+ value={{
43
+ componentName: 'CheckBox',
44
+ params,
45
+ state: disabled ? 'disabled' : 'filled',
46
+ componentId: accessibilityLabel,
47
+ action: 'click',
48
+ componentLabel: formatNameLength(label || ''),
49
+ componentValue: indeterminate ? 'undetermined' : value,
50
+ }}>
51
+ <TouchableOpacity
52
+ accessibilityLabel={accessibilityLabel}
53
+ activeOpacity={0.8}
54
+ onPress={() => onChange?.(!value)}
55
+ disabled={disabled}
56
+ style={[style, styles.container]}>
57
+ <View
58
+ style={[
59
+ {borderColor, backgroundColor, borderWidth: 1},
60
+ styles.checkbox,
61
+ ]}>
62
+ {haveValue && (
63
+ <Icon
64
+ color={theme.colors.background.surface}
65
+ size={20}
66
+ source={iconSource}
67
+ />
68
+ )}
69
+ </View>
70
+ {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
71
+ </TouchableOpacity>
72
+ </ComponentContext.Provider>
58
73
  );
59
74
  };
60
75
 
61
- CheckBox.defaultProps = {
62
- disabled: false,
63
- };
64
-
65
76
  export {CheckBox};
package/CheckBox/types.ts CHANGED
@@ -1,6 +1,6 @@
1
- import {ViewStyle} from 'react-native';
1
+ import {TouchableOpacityProps, ViewStyle} from 'react-native';
2
2
 
3
- export type CheckBoxProps = {
3
+ export interface CheckBoxProps extends TouchableOpacityProps {
4
4
  /**
5
5
  * Represents whether the CheckBox is currently checked (`true`) or unchecked (`false`).
6
6
  */
@@ -35,4 +35,6 @@ export type CheckBoxProps = {
35
35
  * Accepts an object of style properties.
36
36
  */
37
37
  style?: ViewStyle;
38
- };
38
+
39
+ params?: any;
40
+ }
@@ -213,6 +213,20 @@ const Shadow = {
213
213
  elevation: 6,
214
214
  },
215
215
  }),
216
+
217
+ Pink: Platform.select({
218
+ ios: {
219
+ shadowColor: '#e27eb5',
220
+ shadowOffset: {width: 0, height: 6},
221
+ shadowOpacity: 0.25,
222
+ shadowRadius: 8,
223
+ },
224
+ android: {
225
+ elevation: 16,
226
+ shadowColor: '#e27eb5',
227
+ shadowOpacity: 0.25,
228
+ },
229
+ }),
216
230
  };
217
231
 
218
232
  export {Colors, Spacing, Radius, Shadow};