@momo-kits/foundation 0.92.1-tracking.9 → 0.92.2-tracking.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.
@@ -4,10 +4,14 @@ 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, MiniAppContext} from '../Application';
7
+ import {ApplicationContext} from '../Application';
8
8
  import {Button} from '../Button';
9
9
  import {Icon} from '../Icon';
10
- import {getAccessibilityID} from "../Application/utils";
10
+ import {getAccessibilityID} from '../Application/utils';
11
+
12
+ const {
13
+ MiniAppContext,
14
+ } = require('react-native/Libraries/Components/ScreenContext');
11
15
 
12
16
  const PopupNotify: React.FC<PopupNotifyProps> = ({
13
17
  id,
@@ -20,7 +24,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
20
24
  buttonDirection = 'row',
21
25
  onIconClose,
22
26
  }) => {
23
- const context = useContext(MiniAppContext);
27
+ const context = useContext<any>(MiniAppContext);
24
28
  const {theme, navigator, translate} = useContext(ApplicationContext);
25
29
  const [scrollContent, setScrollContent] = useState(false);
26
30
  const closeAction = useRef('touch_outside');
@@ -43,7 +47,8 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
43
47
  screen_name = routes[routesLength - 2]?.params?.screen?.name;
44
48
  }
45
49
  const tracking = {
46
- ...context,
50
+ appId: context.appId,
51
+ code: context.code,
47
52
  screen_name,
48
53
  component_type: 'popup',
49
54
  component_name: id,
@@ -90,6 +95,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
90
95
  closeAction.current = 'button_action';
91
96
  onAction(secondary?.onPress);
92
97
  }}
98
+ accessibilityLabel={'btn_popup_cancel'}
93
99
  />
94
100
  </View>
95
101
  <View style={styles.buttonSpace} />
@@ -103,19 +109,17 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
103
109
  closeAction.current = 'button_action';
104
110
  onAction(primary.onPress);
105
111
  }}
112
+ accessibilityLabel={'btn_popup_allow'}
106
113
  />
107
114
  </View>
108
115
  </View>
109
116
  );
110
117
  };
111
118
  const renderColumn = () => {
112
- const accessibilityPrimaryID = getAccessibilityID?.('btn_popup_allow')
113
- const accessibilitySecondID = getAccessibilityID?.('btn_popup_cancel')
114
-
115
119
  return (
116
120
  <View style={Styles.columnCenter}>
117
121
  <Button
118
- accessibilityID={accessibilityPrimaryID}
122
+ accessibilityLabel={'btn_popup_allow'}
119
123
  title={primary.title}
120
124
  size="medium"
121
125
  onPress={() => {
@@ -127,7 +131,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
127
131
  <>
128
132
  <View style={styles.buttonSpace} />
129
133
  <Button
130
- accessibilityID={accessibilitySecondID}
134
+ accessibilityLabel={'btn_popup_cancel'}
131
135
  title={secondary?.title}
132
136
  type="text"
133
137
  size="medium"
@@ -161,11 +165,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
161
165
  * build close action
162
166
  */
163
167
  const buildCloseIcon = () => {
164
- const accessibilityCloseID = getAccessibilityID?.('ic_popup_close')
165
-
166
168
  return (
167
169
  <TouchableOpacity
168
- {...accessibilityCloseID}
170
+ {...getAccessibilityID?.('ic_popup_close')}
169
171
  style={styles.iconCloseContainer}
170
172
  onPress={() => {
171
173
  closeAction.current = 'icon_close';
@@ -189,11 +191,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
189
191
  );
190
192
  };
191
193
 
192
- const accessibilityID = getAccessibilityID?.(`pu_${context.code}_notify`)
193
-
194
194
  return (
195
195
  <View
196
- {...accessibilityID}
196
+ {...getAccessibilityID?.(`pu_${context.code}_notify`)}
197
197
  style={[
198
198
  styles.container,
199
199
  {backgroundColor: theme.colors.background.surface},
@@ -1,18 +1,22 @@
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, MiniAppContext} from '../Application';
4
+ import {ApplicationContext} 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";
8
+ import {getAccessibilityID} from '../Application/utils';
9
+
10
+ const {
11
+ MiniAppContext,
12
+ } = require('react-native/Libraries/Components/ScreenContext');
9
13
 
10
14
  const PopupPromotion: React.FC<PopupPromotionProps> = ({
11
15
  id,
12
16
  image,
13
17
  onIconClose,
14
18
  }) => {
15
- const context = useContext(MiniAppContext);
19
+ const context = useContext<any>(MiniAppContext);
16
20
  const {theme, navigator} = useContext(ApplicationContext);
17
21
  const closeAction = useRef('touch_outside');
18
22
 
@@ -27,7 +31,8 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
27
31
  screen_name = routes[routesLength - 2]?.params?.screen?.name;
28
32
  }
29
33
  const tracking = {
30
- ...context,
34
+ appId: context.appId,
35
+ code: context.code,
31
36
  screen_name,
32
37
  component_type: 'popup',
33
38
  component_name: id,
@@ -49,10 +54,10 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
49
54
  * build close action
50
55
  */
51
56
  const buildCloseIcon = () => {
52
- const accessibilityCloseID = getAccessibilityID?.('ic_popup_close')
53
-
54
57
  return (
55
- <View {...accessibilityCloseID} style={styles.iconCloseContainer}>
58
+ <View
59
+ {...getAccessibilityID?.('ic_popup_close')}
60
+ style={styles.iconCloseContainer}>
56
61
  <TouchableOpacity
57
62
  onPress={() => {
58
63
  closeAction.current = 'icon_close';
@@ -78,12 +83,9 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
78
83
  </View>
79
84
  );
80
85
  };
81
- const accessibilityID = getAccessibilityID?.(`pu_${context.code}_promotion`)
82
86
 
83
87
  return (
84
- <View
85
- {...accessibilityID}
86
- >
88
+ <View {...getAccessibilityID?.(`pu_${context.code}_promotion`)}>
87
89
  <Image
88
90
  source={{
89
91
  uri: image,
@@ -119,8 +121,4 @@ const styles = StyleSheet.create({
119
121
  },
120
122
  });
121
123
 
122
- PopupPromotion.defaultProps = {
123
- image: 'https://google.com',
124
- };
125
-
126
124
  export default PopupPromotion;
package/Radio/index.tsx CHANGED
@@ -4,12 +4,12 @@ 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, MiniAppContext} from '../Application';
7
+ import {ApplicationContext} from '../Application';
8
8
  import {Spacing} from '../Consts';
9
- import {formatNameLength, getAccessibilityID} from '../Application/utils';
9
+ import {formatNameLength} from '../Application/utils';
10
10
 
11
11
  const {
12
- ScreenContext,
12
+ ComponentContext,
13
13
  } = require('react-native/Libraries/Components/ScreenContext');
14
14
 
15
15
  const Radio: FC<RadioProps> = ({
@@ -20,11 +20,9 @@ const Radio: FC<RadioProps> = ({
20
20
  label,
21
21
  style,
22
22
  params,
23
- componentId,
23
+ accessibilityLabel,
24
24
  }) => {
25
- const {appId} = useContext(MiniAppContext)
26
25
  const {theme} = useContext(ApplicationContext);
27
- const screenInfo = useContext<any>(ScreenContext);
28
26
  const selected = value === groupValue;
29
27
  let disabledStyle = {};
30
28
  let checkBoxStyle = {
@@ -45,22 +43,20 @@ const Radio: FC<RadioProps> = ({
45
43
  : theme.colors.text.disable,
46
44
  };
47
45
  }
48
- const accessibilityID = getAccessibilityID?.(`${appId}/${screenInfo.screenName}/rdo_${label}_${value}`)
49
46
 
50
47
  return (
51
- <ScreenContext.Provider
48
+ <ComponentContext.Provider
52
49
  value={{
53
- ...screenInfo,
54
50
  componentName: 'Button',
55
51
  params,
56
52
  state: disabled ? 'disabled' : 'enabled',
57
- componentId,
53
+ componentId: accessibilityLabel,
58
54
  componentLabel: formatNameLength(label || ''),
59
55
  componentValue: value,
60
56
  action: 'click',
61
57
  }}>
62
58
  <TouchableOpacity
63
- {...accessibilityID}
59
+ accessibilityLabel={accessibilityLabel}
64
60
  onPress={onChange}
65
61
  disabled={disabled}
66
62
  style={[
@@ -80,7 +76,7 @@ const Radio: FC<RadioProps> = ({
80
76
  />
81
77
  {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
82
78
  </TouchableOpacity>
83
- </ScreenContext.Provider>
79
+ </ComponentContext.Provider>
84
80
  );
85
81
  };
86
82
 
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,21 @@
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
- import {MiniAppContext} from "../Application";
8
6
 
9
7
  const {
10
- ScreenContext,
8
+ ComponentContext,
11
9
  } = require('react-native/Libraries/Components/ScreenContext');
12
10
 
13
- const Switch: FC<SwitchProps> = props => {
14
- const {appId} = useContext(MiniAppContext)
15
- const {value, onChange, disabled, style, params, componentId} = props;
16
- const screenInfo = useContext<any>(ScreenContext);
17
-
11
+ const Switch: FC<SwitchProps> = ({
12
+ value = false,
13
+ onChange,
14
+ disabled = false,
15
+ style,
16
+ params,
17
+ accessibilityLabel,
18
+ }) => {
18
19
  const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
19
20
  const circleAlign = value ? 'flex-end' : 'flex-start';
20
21
 
@@ -22,22 +23,20 @@ const Switch: FC<SwitchProps> = props => {
22
23
  if (disabled) {
23
24
  backgroundColor = value ? Colors.green_09 : Colors.black_05;
24
25
  }
25
- const accessibilityID = getAccessibilityID?.(`${appId}/${screenInfo.screenName}/swt_${value}`)
26
26
 
27
27
  return (
28
- <ScreenContext.Provider
28
+ <ComponentContext.Provider
29
29
  value={{
30
- ...screenInfo,
31
30
  componentName: 'Button',
32
31
  params,
33
32
  state: disabled ? 'disabled' : 'enabled',
34
- componentId,
33
+ componentId: accessibilityLabel,
35
34
  componentValue: value,
36
35
  action: 'click',
37
36
  }}>
38
37
  <TouchableOpacity
39
- {...accessibilityID}
40
38
  disabled={disabled}
39
+ accessibilityLabel={accessibilityLabel}
41
40
  onPress={() => onChange?.(!value)}
42
41
  style={[
43
42
  style,
@@ -48,12 +47,8 @@ const Switch: FC<SwitchProps> = props => {
48
47
  <View style={[styles.circleSmall, {backgroundColor}]} />
49
48
  </View>
50
49
  </TouchableOpacity>
51
- </ScreenContext.Provider>
50
+ </ComponentContext.Provider>
52
51
  );
53
52
  };
54
53
 
55
- Switch.defaultProps = {
56
- value: false,
57
- disabled: false,
58
- };
59
54
  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
+ }
package/Text/index.tsx CHANGED
@@ -50,11 +50,25 @@ export interface TextProps extends RNTextProps {
50
50
  * It can be any valid color string (e.g., hex, rgb, rgba, etc.).
51
51
  */
52
52
  color?: string;
53
-
54
- children?: any
55
53
  }
54
+
55
+ const deprecatedValues: Typography[] = [
56
+ 'headline_default',
57
+ 'headline_l',
58
+ 'headline_xl',
59
+ 'title_default',
60
+ 'title_xs',
61
+ 'title_s',
62
+ 'header_default',
63
+ 'paragraph_default',
64
+ 'paragraph_bold',
65
+ 'paragraph_italic',
66
+ 'label_xxs',
67
+ 'action_s',
68
+ ];
69
+
56
70
  const Text: React.FC<TextProps> = ({
57
- typography='body_default_regular',
71
+ typography = 'body_default_regular',
58
72
  color,
59
73
  children,
60
74
  style,
@@ -96,6 +110,13 @@ const Text: React.FC<TextProps> = ({
96
110
  };
97
111
 
98
112
  const textStyle = getTypoStyle(typography);
113
+
114
+ if (deprecatedValues.includes(typography)) {
115
+ console.warn(
116
+ `Warning: The typography value "${typography}" is deprecated.`,
117
+ );
118
+ }
119
+
99
120
  return (
100
121
  <RNText
101
122
  {...rest}
package/Text/styles.ts CHANGED
@@ -5,7 +5,7 @@ export default {
5
5
  header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
6
6
  header_xs_semibold: {fontSize: 12, lineHeight: 18, fontWeight: '600'},
7
7
  body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
8
- body_regularstrikethrought: {
8
+ body_default_regularstrikethrought: {
9
9
  fontSize: 14,
10
10
  lineHeight: 20,
11
11
  fontWeight: '400',
@@ -22,8 +22,8 @@ export default {
22
22
  fontWeight: '400',
23
23
  textDecorationLine: 'line-through',
24
24
  },
25
- description_s_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
26
- description_s_regularstrikethrought: {
25
+ description_xs_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
26
+ description_xs_regularstrikethrought: {
27
27
  fontSize: 10,
28
28
  lineHeight: 14,
29
29
  fontWeight: '400',
package/Text/types.ts CHANGED
@@ -14,13 +14,31 @@ export type TypographyWeight = {
14
14
  };
15
15
 
16
16
  export type Typography =
17
+ /**
18
+ * @deprecated
19
+ **/
20
+ | 'headline_default'
21
+ | 'headline_l'
22
+ | 'headline_xl'
23
+ | 'title_default'
24
+ | 'title_xs'
25
+ | 'title_s'
26
+ | 'header_default'
27
+ | 'paragraph_default'
28
+ | 'paragraph_bold'
29
+ | 'paragraph_italic'
30
+ | 'label_xxs'
31
+ | 'action_s'
32
+ /**
33
+ * end
34
+ **/
17
35
  | 'headline_default_bold'
18
36
  | 'header_m_bold'
19
37
  | 'header_default_bold'
20
38
  | 'header_s_semibold'
21
39
  | 'header_xs_semibold'
22
40
  | 'body_default_regular'
23
- | 'body_regularstrikethrought'
41
+ | 'body_default_regularstrikethrought'
24
42
  | 'description_default_regular'
25
43
  | 'description_default_regularstrikethrought'
26
44
  | 'description_xs_regular'