@momo-kits/foundation 0.162.2-beta.1 → 0.162.2-beta.15

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.
@@ -37,7 +37,8 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
37
37
  const action = useRef<undefined | string>(undefined);
38
38
  const insets = useSafeAreaInsets();
39
39
  const heightHeader = useHeaderHeight();
40
- const keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
40
+ const bottomInset = Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom;
41
+ const keyboardOffset = heightHeader - bottomInset;
41
42
 
42
43
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
43
44
 
@@ -311,7 +312,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
311
312
  {useBottomInset && (
312
313
  <View
313
314
  style={{
314
- height: Math.min(insets.bottom, 21),
315
+ height: bottomInset,
315
316
  backgroundColor: backgroundColor,
316
317
  }}
317
318
  />
@@ -296,7 +296,7 @@ const BottomTab: React.FC<BottomTabProps> = ({
296
296
  activeTintColor={theme.colors.primary}
297
297
  style={[
298
298
  {
299
- height: 64 + Math.min(insets.bottom, 21),
299
+ height: 64 + (Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom),
300
300
  },
301
301
  ]}
302
302
  />
@@ -86,7 +86,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
86
86
 
87
87
  const styles = StyleSheet.create({
88
88
  headerLeft: {
89
- marginLeft: 8,
89
+ marginLeft: 12,
90
90
  },
91
91
  });
92
92
 
package/Input/Input.tsx CHANGED
@@ -77,7 +77,8 @@ const Input = forwardRef(
77
77
  const scaledFontSize = useScaleSize(14);
78
78
  const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
79
79
  const [focused, setFocused] = useState(false);
80
- const haveValue = !!value || !!defaultValue;
80
+ const [internalText, setInternalText] = useState(defaultValue || '');
81
+ const haveValue = value !== undefined ? !!value : !!internalText;
81
82
  const inputRef = useRef<TextInput | null>(null);
82
83
  const componentName = 'Input';
83
84
 
@@ -95,6 +96,9 @@ const Input = forwardRef(
95
96
  };
96
97
 
97
98
  const _onChangeText = (text: string) => {
99
+ if (value === undefined) {
100
+ setInternalText(text);
101
+ }
98
102
  onChangeText?.(text);
99
103
  };
100
104
 
@@ -109,6 +113,13 @@ const Input = forwardRef(
109
113
  };
110
114
 
111
115
  const _setText = (text: string) => {
116
+ if (__DEV__ && value !== undefined) {
117
+ console.error(
118
+ `${componentName}: calling ref.setText() on a controlled input (\`value\` is provided) is an anti-pattern. ` +
119
+ 'It creates two sources of truth: setText will be overridden by React on the next render. ' +
120
+ 'Update the state behind `value` instead.',
121
+ );
122
+ }
112
123
  inputRef?.current?.setNativeProps({ text });
113
124
  _onChangeText(text);
114
125
  };
@@ -69,7 +69,8 @@ const InputPhoneNumber = forwardRef(
69
69
  const context = useContext<any>(MiniAppContext);
70
70
  const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
71
71
  const [focused, setFocused] = useState(false);
72
- const haveValue = !!value || !!defaultValue;
72
+ const [internalText, setInternalText] = useState(defaultValue || '');
73
+ const haveValue = value !== undefined ? !!value : !!internalText;
73
74
  const inputRef = useRef<TextInput | null>(null);
74
75
  const componentName = 'InputPhoneNumber';
75
76
 
@@ -86,6 +87,9 @@ const InputPhoneNumber = forwardRef(
86
87
  };
87
88
 
88
89
  const _onChangeText = (text: string) => {
90
+ if (value === undefined) {
91
+ setInternalText(text);
92
+ }
89
93
  onChangeText?.(text);
90
94
  };
91
95
 
@@ -100,6 +104,13 @@ const InputPhoneNumber = forwardRef(
100
104
  };
101
105
 
102
106
  const _setText = (text: string) => {
107
+ if (__DEV__ && value !== undefined) {
108
+ console.error(
109
+ `${componentName}: calling ref.setText() on a controlled input (\`value\` is provided) is an anti-pattern. ` +
110
+ 'It creates two sources of truth: setText will be overridden by React on the next render. ' +
111
+ 'Update the state behind `value` instead.',
112
+ );
113
+ }
103
114
  inputRef?.current?.setNativeProps({ text });
104
115
  _onChangeText(text);
105
116
  };
package/Layout/Screen.tsx CHANGED
@@ -240,9 +240,10 @@ const Screen = forwardRef(
240
240
  let handleScroll;
241
241
  let Component: any = View;
242
242
 
243
- let keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
243
+ const bottomInset = Platform.OS === 'ios' ? Math.min(insets.bottom, 21) : insets.bottom;
244
+ let keyboardOffset = heightHeader - bottomInset;
244
245
  if (headerType === 'extended' || animatedHeader || inputSearchProps) {
245
- keyboardOffset = -Math.min(insets.bottom, 21);
246
+ keyboardOffset = -bottomInset;
246
247
  }
247
248
 
248
249
  /**
@@ -662,7 +663,7 @@ const Screen = forwardRef(
662
663
  {...floatingButtonProps}
663
664
  animatedValue={sharedValue}
664
665
  bottom={
665
- Footer || isTab ? 12 : Math.min(insets.bottom, 21) + Spacing.S
666
+ Footer || isTab ? 12 : bottomInset + Spacing.S
666
667
  }
667
668
  />
668
669
  </View>
@@ -673,7 +674,7 @@ const Screen = forwardRef(
673
674
  style={[
674
675
  styles.shadow,
675
676
  {
676
- paddingBottom: Math.min(insets.bottom, 21) + Spacing.S,
677
+ paddingBottom: bottomInset + Spacing.S,
677
678
  backgroundColor: theme.colors.background.surface,
678
679
  },
679
680
  ]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.162.2-beta.1",
3
+ "version": "0.162.2-beta.15",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},