@momo-kits/foundation 0.92.2 → 0.92.3-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.
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
46
  componentName: 'Button',
65
47
  params,
66
48
  state: disabled ? 'disabled' : 'enabled',
67
- componentId,
49
+ componentId: accessibilityLabel,
68
50
  componentLabel: formatNameLength(label || ''),
69
51
  componentValue: value,
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
27
  componentName: 'Button',
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
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.92.2",
3
+ "version": "0.92.3-tracking.2",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {