@momo-kits/foundation 0.89.3-beta.1 → 0.89.3-beta.3

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.
@@ -10,10 +10,6 @@ import {Colors} from '../Consts';
10
10
  import {Icon} from '../Icon';
11
11
  import styles from './styles';
12
12
 
13
- const {
14
- ScreenContext,
15
- } = require('react-native/Libraries/Components/ScreenContext');
16
-
17
13
  export interface IconButtonProps extends TouchableOpacityProps {
18
14
  /**
19
15
  * Represents the name or key of the icon to be displayed on the IconButton.
@@ -30,10 +26,6 @@ export interface IconButtonProps extends TouchableOpacityProps {
30
26
  * Optional. Defines the size of the IconButton.
31
27
  */
32
28
  size?: 'large' | 'small';
33
-
34
- params?: any;
35
-
36
- componentId?: string;
37
29
  }
38
30
 
39
31
  const IconButton: React.FC<IconButtonProps> = ({
@@ -41,12 +33,9 @@ const IconButton: React.FC<IconButtonProps> = ({
41
33
  icon,
42
34
  size,
43
35
  onPress,
44
- params,
45
- componentId,
46
36
  ...rest
47
37
  }) => {
48
38
  const {theme} = useContext(ApplicationContext);
49
- const screenInfo = useContext<any>(ScreenContext);
50
39
 
51
40
  /**
52
41
  * get size icon button
@@ -132,23 +121,14 @@ const IconButton: React.FC<IconButtonProps> = ({
132
121
  const iconSize = size === 'small' ? 16 : 24;
133
122
 
134
123
  return (
135
- <ScreenContext.Provider
136
- value={{
137
- ...screenInfo,
138
- componentName: 'IconButton',
139
- params,
140
- state: type === 'disabled' ? 'disabled' : 'enabled',
141
- componentId,
142
- action: 'click',
143
- }}>
144
- <TouchableOpacity
145
- {...rest}
146
- activeOpacity={activeOpacity}
147
- onPress={onPressButton}
148
- style={buttonStyle}>
149
- <Icon size={iconSize} source={icon} color={getIconColor()} />
150
- </TouchableOpacity>
151
- </ScreenContext.Provider>
124
+ <TouchableOpacity
125
+ {...rest}
126
+ accessibilityLabel={`IconButton/${icon}`}
127
+ activeOpacity={activeOpacity}
128
+ onPress={onPressButton}
129
+ style={buttonStyle}>
130
+ <Icon size={iconSize} source={icon} color={getIconColor()} />
131
+ </TouchableOpacity>
152
132
  );
153
133
  };
154
134
 
package/Input/Input.tsx CHANGED
@@ -14,10 +14,6 @@ import {Icon} from '../Icon';
14
14
  import {checkTyping} from './utils';
15
15
  import {Loader} from '../Loader';
16
16
 
17
- const {
18
- ScreenContext,
19
- } = require('react-native/Libraries/Components/ScreenContext');
20
-
21
17
  const Input = forwardRef(
22
18
  (
23
19
  {
@@ -42,8 +38,6 @@ const Input = forwardRef(
42
38
  fontWeight = 'Regular',
43
39
  onPressIcon,
44
40
  style,
45
- params,
46
- componentId,
47
41
  ...props
48
42
  }: InputProps,
49
43
  ref,
@@ -53,7 +47,6 @@ const Input = forwardRef(
53
47
  const [haveValue, setHaveValue] = useState(!!value || !!props.defaultValue);
54
48
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
55
49
  const accessibilityLabel = `Input/${floatingValue ?? placeholder}`;
56
- const screenInfo = useContext<any>(ScreenContext);
57
50
 
58
51
  const onClearText = () => {
59
52
  inputRef?.current?.clear();
@@ -166,35 +159,13 @@ const Input = forwardRef(
166
159
  );
167
160
  };
168
161
 
169
- let inputState = "active"
170
-
171
- if (value && value?.length > 0 ) {
172
- inputState = 'filled'
173
- }
174
- if (errorMessage && errorMessage?.length > 0) {
175
- inputState = 'error'
176
- }
177
-
178
- if (disabled) {
179
- inputState = 'disabled'
180
- }
181
-
182
162
  return (
183
- <ScreenContext.Provider
184
- value={{
185
- ...screenInfo,
186
- componentName: 'Input',
187
- params,
188
- state: inputState,
189
- componentId,
190
- }}>
191
- <View
192
- style={[style, styles.wrapper]}
193
- accessibilityLabel={accessibilityLabel}>
194
- {renderInputView()}
195
- <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
196
- </View>
197
- </ScreenContext.Provider>
163
+ <View
164
+ style={[style, styles.wrapper]}
165
+ accessibilityLabel={accessibilityLabel}>
166
+ {renderInputView()}
167
+ <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
168
+ </View>
198
169
  );
199
170
  },
200
171
  );
@@ -19,10 +19,6 @@ import {InputMoneyProps} from './index';
19
19
  import {Icon} from '../Icon';
20
20
  import {formatMoneyToNumber, formatNumberToMoney} from './utils';
21
21
 
22
- const {
23
- ScreenContext,
24
- } = require('react-native/Libraries/Components/ScreenContext');
25
-
26
22
  const InputMoney = forwardRef(
27
23
  (
28
24
  {
@@ -40,9 +36,7 @@ const InputMoney = forwardRef(
40
36
  required = false,
41
37
  errorSpacing,
42
38
  style,
43
- params,
44
39
  defaultValue = '',
45
- componentId,
46
40
  ...props
47
41
  }: InputMoneyProps,
48
42
  ref,
@@ -51,7 +45,6 @@ const InputMoney = forwardRef(
51
45
  const [focused, setFocused] = useState(false);
52
46
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
53
47
  const accessibilityLabel = `InputMoney/${floatingValue}`;
54
- const screenInfo = useContext<any>(ScreenContext);
55
48
 
56
49
  const validateText = (text: string) => {
57
50
  const valueFormat = formatMoneyToNumber(text, 'đ');
@@ -104,7 +97,6 @@ const InputMoney = forwardRef(
104
97
  iconTintColor = disabledColor;
105
98
  }
106
99
 
107
-
108
100
  return (
109
101
  <View
110
102
  style={[
@@ -161,34 +153,13 @@ const InputMoney = forwardRef(
161
153
  );
162
154
  };
163
155
 
164
- let inputState = "active"
165
-
166
- if (value && value?.length > 0 ) {
167
- inputState = 'filled'
168
- }
169
- if (errorMessage && errorMessage?.length > 0) {
170
- inputState = 'error'
171
- }
172
-
173
- if (disabled) {
174
- inputState = 'disabled'
175
- }
176
156
  return (
177
- <ScreenContext.Provider
178
- value={{
179
- ...screenInfo,
180
- componentName: 'InputMoney',
181
- params,
182
- state: inputState,
183
- componentId,
184
- }}>
185
- <View
186
- style={[style, styles.wrapper]}
187
- accessibilityLabel={accessibilityLabel}>
188
- {renderInputView()}
189
- <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
190
- </View>
191
- </ScreenContext.Provider>
157
+ <View
158
+ style={[style, styles.wrapper]}
159
+ accessibilityLabel={accessibilityLabel}>
160
+ {renderInputView()}
161
+ <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
162
+ </View>
192
163
  );
193
164
  },
194
165
  );
@@ -22,10 +22,6 @@ import {ErrorView, getBorderColor} from './common';
22
22
  import {ApplicationContext} from '../Application';
23
23
  import {Spacing} from '../Consts';
24
24
 
25
- const {
26
- ScreenContext,
27
- } = require('react-native/Libraries/Components/ScreenContext');
28
-
29
25
  const OTPCaret: FC<CaretProps> = ({index, length}) => {
30
26
  const DURATION = 300;
31
27
  const {theme} = useContext(ApplicationContext);
@@ -82,9 +78,7 @@ const InputOTP = forwardRef(
82
78
  onFocus,
83
79
  onBlur,
84
80
  dataType = 'number',
85
- params,
86
81
  style,
87
- componentId,
88
82
  ...props
89
83
  }: InputOTPProps,
90
84
  ref,
@@ -95,7 +89,6 @@ const InputOTP = forwardRef(
95
89
  const inputRef = useRef<TextInput>(null);
96
90
  const {theme} = useContext(ApplicationContext);
97
91
  const accessibilityLabel = `InputOTP/${floatingValue ?? placeholder}`;
98
- const screenInfo = useContext<any>(ScreenContext);
99
92
 
100
93
  useImperativeHandle(ref, () => ({
101
94
  onChangeText: (text: string) => {
@@ -230,23 +223,14 @@ const InputOTP = forwardRef(
230
223
  };
231
224
 
232
225
  return (
233
- <ScreenContext.Provider
234
- value={{
235
- ...screenInfo,
236
- componentName: 'InputOTP',
237
- params,
238
- state: 'enabled',
239
- componentId,
240
- }}>
241
- <TouchableOpacity
242
- activeOpacity={1}
243
- onPress={onFocusInput}
244
- style={[style, styles.otpWrapper]}
245
- accessibilityLabel={accessibilityLabel}>
246
- {renderInputView()}
247
- <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
248
- </TouchableOpacity>
249
- </ScreenContext.Provider>
226
+ <TouchableOpacity
227
+ activeOpacity={1}
228
+ onPress={onFocusInput}
229
+ style={[style, styles.otpWrapper]}
230
+ accessibilityLabel={accessibilityLabel}>
231
+ {renderInputView()}
232
+ <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
233
+ </TouchableOpacity>
250
234
  );
251
235
  },
252
236
  );
@@ -13,10 +13,6 @@ import {Icon} from '../Icon';
13
13
  import {Text} from '../Text';
14
14
  import {checkTyping} from './utils';
15
15
 
16
- const {
17
- ScreenContext,
18
- } = require('react-native/Libraries/Components/ScreenContext');
19
-
20
16
  const InputSearch = forwardRef(
21
17
  (
22
18
  {
@@ -33,8 +29,6 @@ const InputSearch = forwardRef(
33
29
  style,
34
30
  defaultValue,
35
31
  onPressButtonText,
36
- params,
37
- componentId,
38
32
  ...props
39
33
  }: InputSearchProps,
40
34
  ref,
@@ -44,7 +38,6 @@ const InputSearch = forwardRef(
44
38
  const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
45
39
  const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
46
40
  const accessibilityLabel = `InputMoney/${placeholder}`;
47
- const screenInfo = useContext<any>(ScreenContext);
48
41
 
49
42
  const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
50
43
  setFocused(true);
@@ -125,58 +118,36 @@ const InputSearch = forwardRef(
125
118
  </View>
126
119
  );
127
120
  };
128
-
129
- let inputState = "empty"
130
-
131
- if (focused) {
132
- inputState = 'focus'
133
- }
134
-
135
- if (value && value?.length > 0 ) {
136
- inputState = 'filled'
137
- }
138
-
139
121
  return (
140
- <ScreenContext.Provider
141
- value={{
142
- ...screenInfo,
143
- componentName: 'InputSearch',
144
- params,
145
- state: inputState,
146
- componentId,
147
- }}>
122
+ <View
123
+ style={[style, styles.searchInputContainer]}
124
+ accessibilityLabel={accessibilityLabel}>
148
125
  <View
149
- style={[style, styles.searchInputContainer]}
150
- accessibilityLabel={accessibilityLabel}>
151
- <View
152
- style={[
153
- styles.searchInputWrapper,
154
- {
155
- backgroundColor: theme.colors.background.surface,
156
- borderColor: theme.colors.background.surface,
157
- },
158
- showBorder && {borderColor: theme.colors.border.default},
159
- focused && {borderColor: theme.colors.primary},
160
- ]}>
161
- <Icon
162
- source={'navigation_search'}
163
- size={24}
164
- color={theme.colors.text.hint}
165
- />
166
- {renderInputView()}
167
- {renderIconView()}
168
- </View>
169
- {showButtonText && (
170
- <TouchableOpacity onPress={onPressButtonText}>
171
- <Text
172
- typography={'action_default_bold'}
173
- style={styles.textButton}>
174
- {buttonText}
175
- </Text>
176
- </TouchableOpacity>
177
- )}
126
+ style={[
127
+ styles.searchInputWrapper,
128
+ {
129
+ backgroundColor: theme.colors.background.surface,
130
+ borderColor: theme.colors.background.surface,
131
+ },
132
+ showBorder && {borderColor: theme.colors.border.default},
133
+ focused && {borderColor: theme.colors.primary},
134
+ ]}>
135
+ <Icon
136
+ source={'navigation_search'}
137
+ size={24}
138
+ color={theme.colors.text.hint}
139
+ />
140
+ {renderInputView()}
141
+ {renderIconView()}
178
142
  </View>
179
- </ScreenContext.Provider>
143
+ {showButtonText && (
144
+ <TouchableOpacity onPress={onPressButtonText}>
145
+ <Text typography={'action_default_bold'} style={styles.textButton}>
146
+ {buttonText}
147
+ </Text>
148
+ </TouchableOpacity>
149
+ )}
150
+ </View>
180
151
  );
181
152
  },
182
153
  );
package/Input/index.tsx CHANGED
@@ -80,9 +80,6 @@ export interface InputProps extends TextInputProps {
80
80
  fontWeight?: 'Regular' | 'Bold';
81
81
 
82
82
  onPressIcon?: () => void;
83
-
84
- params?: any;
85
- componentId?: string;
86
83
  }
87
84
 
88
85
  type InputPropsWithoutSizeAndIcon = Omit<
@@ -129,10 +126,6 @@ export interface InputSearchProps extends TextInputProps {
129
126
  * Optional. Represents the name or key of the icon to be displayed in the Input component.
130
127
  */
131
128
  icon?: string;
132
-
133
- params?: any;
134
-
135
- componentId?: string;
136
129
  }
137
130
 
138
131
  export interface InputMoneyProps extends InputPropsWithoutPlaceholder {}
package/Radio/index.tsx CHANGED
@@ -6,9 +6,6 @@ import {Text} from '../Text';
6
6
  import styles from './styles';
7
7
  import {ApplicationContext} from '../Application';
8
8
  import {Spacing} from '../Consts';
9
- const {
10
- ScreenContext,
11
- } = require('react-native/Libraries/Components/ScreenContext');
12
9
 
13
10
  const Radio: FC<RadioProps> = ({
14
11
  value,
@@ -16,10 +13,9 @@ const Radio: FC<RadioProps> = ({
16
13
  disabled,
17
14
  onChange,
18
15
  label,
19
- style, params, componentId,
16
+ style,
20
17
  }) => {
21
18
  const {theme} = useContext(ApplicationContext);
22
- const screenInfo = useContext<any>(ScreenContext);
23
19
  const selected = value === groupValue;
24
20
  let disabledStyle = {};
25
21
  let checkBoxStyle = {
@@ -42,16 +38,6 @@ const Radio: FC<RadioProps> = ({
42
38
  }
43
39
 
44
40
  return (
45
- <ScreenContext.Provider
46
- value={{
47
- ...screenInfo,
48
- componentName: 'Button',
49
- params,
50
- state: disabled ? 'disabled' : 'enabled',
51
- componentId,
52
- componentValue: value,
53
- action: 'click',
54
- }}>
55
41
  <TouchableOpacity
56
42
  accessibilityLabel={`Radio/${label}/${value}`}
57
43
  onPress={onChange}
@@ -73,7 +59,6 @@ const Radio: FC<RadioProps> = ({
73
59
  />
74
60
  {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
75
61
  </TouchableOpacity>
76
- </ScreenContext.Provider>
77
62
  );
78
63
  };
79
64
 
package/Radio/types.ts CHANGED
@@ -35,9 +35,4 @@ export type RadioProps = {
35
35
  * Accepts an object of style properties.
36
36
  */
37
37
  style?: ViewStyle;
38
-
39
-
40
- params?: any
41
-
42
- componentId?: string
43
38
  };
package/Switch/index.tsx CHANGED
@@ -1,19 +1,11 @@
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
6
 
7
- const {
8
- ScreenContext,
9
- } = require('react-native/Libraries/Components/ScreenContext');
10
-
11
7
  const Switch: FC<SwitchProps> = props => {
12
- const {value, onChange, disabled, style,
13
- params, componentId,
14
- } = props;
15
- const screenInfo = useContext<any>(ScreenContext);
16
-
8
+ const {value, onChange, disabled, style} = props;
17
9
  const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
18
10
  const circleAlign = value ? 'flex-end' : 'flex-start';
19
11
 
@@ -23,16 +15,6 @@ const Switch: FC<SwitchProps> = props => {
23
15
  }
24
16
 
25
17
  return (
26
- <ScreenContext.Provider
27
- value={{
28
- ...screenInfo,
29
- componentName: 'Button',
30
- params,
31
- state: disabled ? 'disabled' : 'enabled',
32
- componentId,
33
- componentValue: value,
34
- action: 'click',
35
- }}>
36
18
  <TouchableOpacity
37
19
  accessibilityLabel={'Switch'}
38
20
  disabled={disabled}
@@ -46,7 +28,6 @@ const Switch: FC<SwitchProps> = props => {
46
28
  <View style={[styles.circleSmall, {backgroundColor}]} />
47
29
  </View>
48
30
  </TouchableOpacity>
49
- </ScreenContext.Provider>
50
31
  );
51
32
  };
52
33
 
package/Switch/types.ts CHANGED
@@ -23,8 +23,4 @@ export type SwitchProps = {
23
23
  * Accepts an object of style properties.
24
24
  */
25
25
  style?: ViewStyle;
26
-
27
- params?: any
28
-
29
- componentId?: string
30
26
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.89.3-beta.1",
3
+ "version": "0.89.3-beta.3",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {