@momo-kits/foundation 0.92.2 → 0.92.3-beta.10

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.
@@ -19,18 +19,8 @@ import {CaretProps, InputOTPProps} from './index';
19
19
  import {scaleSize, Text} from '../Text';
20
20
  import styles from './styles';
21
21
  import {ErrorView, getBorderColor} from './common';
22
- import {ApplicationContext} from '../Application';
22
+ import {ApplicationContext, ComponentContext} from '../Application';
23
23
  import {Spacing} from '../Consts';
24
- import {
25
- cleanNameForTracking,
26
- formatComponentName,
27
- getAccessibilityID,
28
- } from '../Application/utils';
29
-
30
- const {
31
- ScreenContext,
32
- MiniAppContext,
33
- } = require('react-native/Libraries/Components/ScreenContext');
34
24
 
35
25
  const OTPCaret: FC<CaretProps> = ({index, length}) => {
36
26
  const DURATION = 300;
@@ -80,7 +70,7 @@ const InputOTP = forwardRef(
80
70
  length,
81
71
  errorMessage,
82
72
  errorSpacing,
83
- floatingValue,
73
+ floatingValue = 'Label',
84
74
  floatingIconColor,
85
75
  floatingIcon,
86
76
  placeholder,
@@ -90,19 +80,16 @@ const InputOTP = forwardRef(
90
80
  dataType = 'number',
91
81
  params,
92
82
  style,
93
- componentId,
83
+ accessibilityLabel,
94
84
  ...props
95
85
  }: InputOTPProps,
96
86
  ref,
97
87
  ) => {
98
88
  const MAX_LENGTH = 10;
99
- const {appId, code} = useContext<any>(MiniAppContext);
100
-
101
89
  const [value, setValue] = useState('');
102
90
  const [focused, setFocused] = useState(false);
103
91
  const inputRef = useRef<TextInput>(null);
104
92
  const {theme} = useContext(ApplicationContext);
105
- const screenInfo = useContext<any>(ScreenContext);
106
93
 
107
94
  useImperativeHandle(ref, () => ({
108
95
  onChangeText: (text: string) => {
@@ -195,12 +182,6 @@ const InputOTP = forwardRef(
195
182
  );
196
183
  };
197
184
 
198
- const accessibilityID = getAccessibilityID(
199
- `${appId}/${code}/${screenInfo.screenName}/input_${cleanNameForTracking(
200
- floatingValue,
201
- )}`,
202
- );
203
-
204
185
  const renderInputView = () => {
205
186
  return (
206
187
  <View
@@ -215,7 +196,9 @@ const InputOTP = forwardRef(
215
196
  styles.otpFloatingView,
216
197
  {backgroundColor: theme.colors.background.surface},
217
198
  ]}>
218
- <Text typography={'description_default_regular'}>
199
+ <Text
200
+ typography={'description_default_regular'}
201
+ color={theme.colors.text.hint}>
219
202
  {floatingValue}
220
203
  </Text>
221
204
  </View>
@@ -226,7 +209,7 @@ const InputOTP = forwardRef(
226
209
  <View style={styles.inputView}>
227
210
  <TextInput
228
211
  {...props}
229
- {...accessibilityID}
212
+ accessibilityLabel={accessibilityLabel}
230
213
  ref={inputRef}
231
214
  value={value}
232
215
  onChangeText={_onChangeText}
@@ -243,14 +226,13 @@ const InputOTP = forwardRef(
243
226
  };
244
227
 
245
228
  return (
246
- <ScreenContext.Provider
229
+ <ComponentContext.Provider
247
230
  value={{
248
- ...screenInfo,
249
231
  componentName: 'InputOTP',
250
232
  params,
251
- componentLabel: formatComponentName(floatingValue || ''),
233
+ componentLabel: floatingValue,
252
234
  state: 'enabled',
253
- componentId,
235
+ componentId: accessibilityLabel,
254
236
  }}>
255
237
  <TouchableOpacity
256
238
  activeOpacity={1}
@@ -259,7 +241,7 @@ const InputOTP = forwardRef(
259
241
  {renderInputView()}
260
242
  <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
261
243
  </TouchableOpacity>
262
- </ScreenContext.Provider>
244
+ </ComponentContext.Provider>
263
245
  );
264
246
  },
265
247
  );
@@ -7,17 +7,11 @@ import {
7
7
  View,
8
8
  } from 'react-native';
9
9
  import {InputSearchProps} from './index';
10
- import {ApplicationContext} from '../Application';
10
+ import {ApplicationContext, ComponentContext} from '../Application';
11
11
  import styles from './styles';
12
12
  import {Icon} from '../Icon';
13
13
  import {Text} from '../Text';
14
14
  import {checkTyping} from './utils';
15
- import {getAccessibilityID} from '../Application/utils';
16
-
17
- const {
18
- ScreenContext,
19
- MiniAppContext,
20
- } = require('react-native/Libraries/Components/ScreenContext');
21
15
 
22
16
  const InputSearch = forwardRef(
23
17
  (
@@ -35,18 +29,16 @@ const InputSearch = forwardRef(
35
29
  defaultValue,
36
30
  onPressButtonText,
37
31
  params,
38
- componentId,
39
32
  hasColorBG = false,
33
+ accessibilityLabel,
40
34
  ...props
41
35
  }: InputSearchProps,
42
36
  ref,
43
37
  ) => {
44
38
  const {theme} = useContext(ApplicationContext);
45
- const {appId, code} = useContext<any>(MiniAppContext);
46
39
  const [focused, setFocused] = useState(false);
47
40
  const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
48
41
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
49
- const screenInfo = useContext<any>(ScreenContext);
50
42
 
51
43
  const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
52
44
  setFocused(true);
@@ -72,9 +64,7 @@ const InputSearch = forwardRef(
72
64
  return (
73
65
  <TextInput
74
66
  {...props}
75
- {...getAccessibilityID(
76
- `${appId}/${code}/${screenInfo.screenName}/input_search`,
77
- )}
67
+ accessibilityLabel={accessibilityLabel}
78
68
  textAlignVertical="center"
79
69
  ref={inputRef}
80
70
  style={[
@@ -145,13 +135,12 @@ const InputSearch = forwardRef(
145
135
  : theme.colors.background.surface;
146
136
 
147
137
  return (
148
- <ScreenContext.Provider
138
+ <ComponentContext.Provider
149
139
  value={{
150
- ...screenInfo,
151
140
  componentName: 'InputSearch',
152
141
  params,
153
142
  state: inputState,
154
- componentId,
143
+ componentId: accessibilityLabel,
155
144
  }}>
156
145
  <View style={[style, styles.searchInputContainer]}>
157
146
  <View
@@ -179,7 +168,7 @@ const InputSearch = forwardRef(
179
168
  </TouchableOpacity>
180
169
  )}
181
170
  </View>
182
- </ScreenContext.Provider>
171
+ </ComponentContext.Provider>
183
172
  );
184
173
  },
185
174
  );
@@ -18,12 +18,6 @@ import {
18
18
  import {InputTextAreaProps} from './index';
19
19
  import {Icon} from '../Icon';
20
20
  import {ApplicationContext} from '../Application';
21
- import {cleanNameForTracking, getAccessibilityID} from '../Application/utils';
22
-
23
- const {
24
- ScreenContext,
25
- MiniAppContext,
26
- } = require('react-native/Libraries/Components/ScreenContext');
27
21
 
28
22
  const InputTextArea = forwardRef(
29
23
  (
@@ -44,13 +38,12 @@ const InputTextArea = forwardRef(
44
38
  required,
45
39
  errorSpacing,
46
40
  style,
41
+ accessibilityLabel,
47
42
  ...props
48
43
  }: InputTextAreaProps,
49
44
  ref,
50
45
  ) => {
51
46
  const {theme} = useContext(ApplicationContext);
52
- const screenInfo = useContext<any>(ScreenContext);
53
- const {appId, code} = useContext<any>(MiniAppContext);
54
47
  const [focused, setFocused] = useState(false);
55
48
  const [inputValue, setInputValue] = useState(defaultValue ?? '');
56
49
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
@@ -96,20 +89,6 @@ const InputTextArea = forwardRef(
96
89
  placeholderColor = disabledColor;
97
90
  }
98
91
 
99
- const accessibilityID = disabled
100
- ? getAccessibilityID(
101
- `${appId}/${code}/${
102
- screenInfo.screenName
103
- }/input_${cleanNameForTracking(
104
- floatingValue ?? placeholder,
105
- )}_disabled`,
106
- )
107
- : getAccessibilityID(
108
- `${appId}/${code}/${
109
- screenInfo.screenName
110
- }/input_${cleanNameForTracking(floatingValue ?? placeholder)}`,
111
- );
112
-
113
92
  return (
114
93
  <View
115
94
  style={[
@@ -131,7 +110,6 @@ const InputTextArea = forwardRef(
131
110
  <View style={styles.textAreaView}>
132
111
  <TextInput
133
112
  {...props}
134
- {...accessibilityID}
135
113
  ref={inputRef}
136
114
  editable={!disabled}
137
115
  textAlignVertical="top"
package/Input/index.tsx CHANGED
@@ -82,7 +82,6 @@ export interface InputProps extends TextInputProps {
82
82
  onPressIcon?: () => void;
83
83
 
84
84
  params?: any;
85
- componentId?: string;
86
85
  }
87
86
 
88
87
  type InputPropsWithoutSizeAndIcon = Omit<
@@ -130,8 +129,6 @@ export interface InputSearchProps extends TextInputProps {
130
129
  hasColorBG?: boolean;
131
130
 
132
131
  params?: any;
133
-
134
- componentId?: string;
135
132
  }
136
133
 
137
134
  export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
@@ -169,7 +166,7 @@ export type CaretProps = {
169
166
  length?: number;
170
167
  };
171
168
 
172
- export interface InputDropDownProps {
169
+ export interface InputDropDownProps extends InputProps {
173
170
  /**
174
171
  * Optional. Defines the size of the InputDropDown component.
175
172
  * 'small' - A smaller, less prominent input.
@@ -264,11 +261,6 @@ export interface InputDropDownProps {
264
261
  [key: string]: any;
265
262
  };
266
263
 
267
- /**
268
- * component id for element tracking.
269
- */
270
- componentId?: string;
271
-
272
264
  /**
273
265
  * Optional. Represents the style of the InputDropDown component.
274
266
  */
package/Input/styles.ts CHANGED
@@ -53,7 +53,7 @@ export default StyleSheet.create({
53
53
  marginRight: Spacing.M,
54
54
  },
55
55
  icon: {
56
- marginLeft: Spacing.S
56
+ marginLeft: Spacing.S,
57
57
  },
58
58
  iconWrapper: {
59
59
  width: 24,
@@ -145,7 +145,7 @@ export default StyleSheet.create({
145
145
  },
146
146
  otpFloatingView: {
147
147
  position: 'absolute',
148
- top: -Spacing.S,
148
+ top: scaleSize(-Spacing.M + 2),
149
149
  alignSelf: 'center',
150
150
  paddingHorizontal: Spacing.S,
151
151
  },
package/Layout/Screen.tsx CHANGED
@@ -18,7 +18,7 @@ import React, {
18
18
  useEffect,
19
19
  useRef,
20
20
  } from 'react';
21
- import {Colors, Spacing, Styles} from '../Consts';
21
+ import {Colors, Shadow, Spacing, Styles} from '../Consts';
22
22
  import {Card, Section, validateChildren} from './index';
23
23
  import {
24
24
  ApplicationContext,
@@ -337,8 +337,9 @@ const Screen = forwardRef(
337
337
  {Footer && (
338
338
  <View
339
339
  style={[
340
- styles.footerContainer,
340
+ Shadow.Dark,
341
341
  {
342
+ paddingTop: Spacing.S,
342
343
  paddingBottom: Math.min(insets.bottom, 21) + Spacing.S,
343
344
  backgroundColor: theme.colors.background.surface,
344
345
  },
package/Layout/styles.ts CHANGED
@@ -80,18 +80,4 @@ export default StyleSheet.create({
80
80
  paddingHorizontal: undefined,
81
81
  paddingVertical: undefined,
82
82
  },
83
- footerContainer: {
84
- paddingTop: Spacing.S,
85
- ...Platform.select({
86
- android: {
87
- elevation: 4,
88
- },
89
- ios: {
90
- shadowColor: Colors.black_20,
91
- shadowOffset: {width: 0, height: -2},
92
- shadowOpacity: 0.1,
93
- shadowRadius: 3,
94
- },
95
- }),
96
- },
97
83
  });
@@ -4,14 +4,9 @@ import {PopupNotifyProps} from './types';
4
4
  import {Radius, Spacing, Styles} from '../Consts';
5
5
  import {Image} from '../Image';
6
6
  import {Text} from '../Text';
7
- import {ApplicationContext} from '../Application';
7
+ import {ApplicationContext, MiniAppContext} from '../Application';
8
8
  import {Button} from '../Button';
9
9
  import {Icon} from '../Icon';
10
- import {getAccessibilityID} from '../Application/utils';
11
-
12
- const {
13
- MiniAppContext,
14
- } = require('react-native/Libraries/Components/ScreenContext');
15
10
 
16
11
  const PopupNotify: React.FC<PopupNotifyProps> = ({
17
12
  id,
@@ -47,7 +42,8 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
47
42
  screen_name = routes[routesLength - 2]?.params?.screen?.name;
48
43
  }
49
44
  const tracking = {
50
- ...context,
45
+ appId: context.appId,
46
+ code: context.code,
51
47
  screen_name,
52
48
  component_type: 'popup',
53
49
  component_name: id,
@@ -166,7 +162,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
166
162
  const buildCloseIcon = () => {
167
163
  return (
168
164
  <TouchableOpacity
169
- {...getAccessibilityID?.('ic_popup_close')}
165
+ accessibilityLabel={'ic_popup_close'}
170
166
  style={styles.iconCloseContainer}
171
167
  onPress={() => {
172
168
  closeAction.current = 'icon_close';
@@ -192,7 +188,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
192
188
 
193
189
  return (
194
190
  <View
195
- {...getAccessibilityID?.(`pu_${context.code}_notify`)}
191
+ accessibilityLabel={'PopupNotify'}
196
192
  style={[
197
193
  styles.container,
198
194
  {backgroundColor: theme.colors.background.surface},
@@ -1,15 +1,10 @@
1
1
  import React, {useContext, useEffect, useRef} from 'react';
2
2
  import {StyleSheet, TouchableOpacity, View} from 'react-native';
3
3
  import {PopupPromotionProps} from './types';
4
- import {ApplicationContext} from '../Application';
4
+ import {ApplicationContext, MiniAppContext} from '../Application';
5
5
  import {Image} from '../Image';
6
6
  import {Radius, Spacing} from '../Consts';
7
7
  import {Icon} from '../Icon';
8
- import {getAccessibilityID} from '../Application/utils';
9
-
10
- const {
11
- MiniAppContext,
12
- } = require('react-native/Libraries/Components/ScreenContext');
13
8
 
14
9
  const PopupPromotion: React.FC<PopupPromotionProps> = ({
15
10
  id,
@@ -31,7 +26,8 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
31
26
  screen_name = routes[routesLength - 2]?.params?.screen?.name;
32
27
  }
33
28
  const tracking = {
34
- ...context,
29
+ appId: context.appId,
30
+ code: context.code,
35
31
  screen_name,
36
32
  component_type: 'popup',
37
33
  component_name: id,
@@ -54,10 +50,9 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
54
50
  */
55
51
  const buildCloseIcon = () => {
56
52
  return (
57
- <View
58
- {...getAccessibilityID?.('ic_popup_close')}
59
- style={styles.iconCloseContainer}>
53
+ <View style={styles.iconCloseContainer}>
60
54
  <TouchableOpacity
55
+ accessibilityLabel={'ic_popup_close'}
61
56
  onPress={() => {
62
57
  closeAction.current = 'icon_close';
63
58
  navigator?.pop();
@@ -84,7 +79,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
84
79
  };
85
80
 
86
81
  return (
87
- <View {...getAccessibilityID?.(`pu_${context.code}_promotion`)}>
82
+ <View accessibilityLabel={'PopupPromotion'}>
88
83
  <Image
89
84
  source={{
90
85
  uri: image,
@@ -120,8 +115,4 @@ const styles = StyleSheet.create({
120
115
  },
121
116
  });
122
117
 
123
- PopupPromotion.defaultProps = {
124
- image: 'https://google.com',
125
- };
126
-
127
118
  export default PopupPromotion;
package/Radio/index.tsx CHANGED
@@ -4,18 +4,9 @@ import {TouchableOpacity, View} from 'react-native';
4
4
  import {RadioProps} from './types';
5
5
  import {Text} from '../Text';
6
6
  import styles from './styles';
7
- import {ApplicationContext} from '../Application';
7
+ import {ApplicationContext, ComponentContext} from '../Application';
8
8
  import {Spacing} from '../Consts';
9
- import {
10
- cleanNameForTracking,
11
- formatNameLength,
12
- getAccessibilityID,
13
- } from '../Application/utils';
14
-
15
- const {
16
- ScreenContext,
17
- MiniAppContext,
18
- } = require('react-native/Libraries/Components/ScreenContext');
9
+ import {formatNameLength} from '../Application/utils';
19
10
 
20
11
  const Radio: FC<RadioProps> = ({
21
12
  value,
@@ -25,11 +16,9 @@ const Radio: FC<RadioProps> = ({
25
16
  label,
26
17
  style,
27
18
  params,
28
- componentId,
19
+ accessibilityLabel,
29
20
  }) => {
30
- const {appId, code} = useContext<any>(MiniAppContext);
31
21
  const {theme} = useContext(ApplicationContext);
32
- const screenInfo = useContext<any>(ScreenContext);
33
22
  const selected = value === groupValue;
34
23
  let disabledStyle = {};
35
24
  let checkBoxStyle = {
@@ -51,26 +40,19 @@ const Radio: FC<RadioProps> = ({
51
40
  };
52
41
  }
53
42
 
54
- const accessibilityID = getAccessibilityID?.(
55
- `${appId}/${code}/${screenInfo.screenName}/rdo_${cleanNameForTracking(
56
- label,
57
- )}_${selected}`,
58
- );
59
-
60
43
  return (
61
- <ScreenContext.Provider
44
+ <ComponentContext.Provider
62
45
  value={{
63
- ...screenInfo,
64
- componentName: 'Button',
46
+ componentName: 'Radio',
65
47
  params,
66
48
  state: disabled ? 'disabled' : 'enabled',
67
- componentId,
49
+ componentId: accessibilityLabel,
68
50
  componentLabel: formatNameLength(label || ''),
69
- componentValue: value,
51
+ componentValue: selected,
70
52
  action: 'click',
71
53
  }}>
72
54
  <TouchableOpacity
73
- {...accessibilityID}
55
+ accessibilityLabel={accessibilityLabel}
74
56
  onPress={onChange}
75
57
  disabled={disabled}
76
58
  style={[
@@ -90,7 +72,7 @@ const Radio: FC<RadioProps> = ({
90
72
  />
91
73
  {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
92
74
  </TouchableOpacity>
93
- </ScreenContext.Provider>
75
+ </ComponentContext.Provider>
94
76
  );
95
77
  };
96
78
 
package/Radio/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 RadioProps = {
3
+ export interface RadioProps extends TouchableOpacityProps {
4
4
  /**
5
5
  * `value`: Represents the value associated with the Radio component.
6
6
  * It is used to determine whether the Radio component is selected or not in comparison with the `groupValue`.
@@ -36,8 +36,5 @@ export type RadioProps = {
36
36
  */
37
37
  style?: ViewStyle;
38
38
 
39
-
40
- params?: any
41
-
42
- componentId?: string
43
- };
39
+ params?: any;
40
+ }
package/Switch/index.tsx CHANGED
@@ -1,20 +1,18 @@
1
- import React, {FC, useContext} from 'react';
1
+ import React, {FC} from 'react';
2
2
  import {TouchableOpacity, View} from 'react-native';
3
3
  import {SwitchProps} from './types';
4
4
  import styles from './styles';
5
5
  import {Colors} from '../Consts';
6
- import {getAccessibilityID} from '../Application/utils';
7
-
8
- const {
9
- ScreenContext,
10
- MiniAppContext,
11
- } = require('react-native/Libraries/Components/ScreenContext');
12
-
13
- const Switch: FC<SwitchProps> = props => {
14
- const {appId, code} = useContext<any>(MiniAppContext);
15
- const {value, onChange, disabled, style, params, componentId} = props;
16
- const screenInfo = useContext<any>(ScreenContext);
6
+ import {ComponentContext} from '../Application';
17
7
 
8
+ const Switch: FC<SwitchProps> = ({
9
+ value = false,
10
+ onChange,
11
+ disabled = false,
12
+ style,
13
+ params,
14
+ accessibilityLabel,
15
+ }) => {
18
16
  const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
19
17
  const circleAlign = value ? 'flex-end' : 'flex-start';
20
18
 
@@ -23,24 +21,19 @@ const Switch: FC<SwitchProps> = props => {
23
21
  backgroundColor = value ? Colors.green_09 : Colors.black_05;
24
22
  }
25
23
 
26
- const accessibilityID = getAccessibilityID?.(
27
- `${appId}/${code}/${screenInfo.screenName}/swt_${value}`,
28
- );
29
-
30
24
  return (
31
- <ScreenContext.Provider
25
+ <ComponentContext.Provider
32
26
  value={{
33
- ...screenInfo,
34
- componentName: 'Button',
27
+ componentName: 'Switch',
35
28
  params,
36
29
  state: disabled ? 'disabled' : 'enabled',
37
- componentId,
30
+ componentId: accessibilityLabel,
38
31
  componentValue: value,
39
32
  action: 'click',
40
33
  }}>
41
34
  <TouchableOpacity
42
- {...accessibilityID}
43
35
  disabled={disabled}
36
+ accessibilityLabel={accessibilityLabel}
44
37
  onPress={() => onChange?.(!value)}
45
38
  style={[
46
39
  style,
@@ -51,12 +44,8 @@ const Switch: FC<SwitchProps> = props => {
51
44
  <View style={[styles.circleSmall, {backgroundColor}]} />
52
45
  </View>
53
46
  </TouchableOpacity>
54
- </ScreenContext.Provider>
47
+ </ComponentContext.Provider>
55
48
  );
56
49
  };
57
50
 
58
- Switch.defaultProps = {
59
- value: false,
60
- disabled: false,
61
- };
62
51
  export {Switch};
package/Switch/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 SwitchProps = {
3
+ export interface SwitchProps extends TouchableOpacityProps {
4
4
  /**
5
5
  * `value`: Represents whether the Switch component is currently in the 'on' (`true`) or 'off' (`false`) state.
6
6
  */
@@ -24,7 +24,5 @@ export type SwitchProps = {
24
24
  */
25
25
  style?: ViewStyle;
26
26
 
27
- params?: any
28
-
29
- componentId?: string
30
- };
27
+ params?: any;
28
+ }