@momo-kits/foundation 0.169.17-beta.1 → 0.169.17-beta.13

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.
Files changed (51) hide show
  1. package/Application/BottomSheet.tsx +2 -2
  2. package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
  3. package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
  4. package/Application/BottomTab/TabBarIcon.tsx +1 -1
  5. package/Application/BottomTab/index.tsx +1 -15
  6. package/Application/Components/HeaderExtendHeader.tsx +1 -3
  7. package/Application/Components/HeaderRight.tsx +3 -24
  8. package/Application/Components/SearchHeader.tsx +2 -3
  9. package/Application/ModalScreen.tsx +2 -2
  10. package/Application/StackScreen.tsx +6 -2
  11. package/Application/TooltipPortal.tsx +3 -3
  12. package/Application/headerLayout.ts +3 -7
  13. package/Application/hooks.ts +1 -1
  14. package/Application/types.tabs.ts +0 -8
  15. package/Button/index.tsx +2 -2
  16. package/Divider/DashDivider.tsx +2 -2
  17. package/Divider/index.tsx +3 -3
  18. package/FoundationList/index.tsx +1 -1
  19. package/Icon/types.ts +1 -2
  20. package/Image/index.tsx +70 -7
  21. package/Image/styles.ts +2 -0
  22. package/Image/types.ts +9 -1
  23. package/Input/Input.tsx +2 -2
  24. package/Input/InputMoney.tsx +7 -2
  25. package/Input/InputMoneyView.tsx +2 -2
  26. package/Input/InputOTP.tsx +2 -2
  27. package/Input/InputPhoneNumber.tsx +2 -2
  28. package/Input/InputSearch.tsx +2 -2
  29. package/Input/InputTextArea.tsx +2 -2
  30. package/Input/SearchTextTyping.tsx +2 -2
  31. package/Input/SystemTextInput.tsx +2 -1
  32. package/Input/TextTyping.tsx +7 -2
  33. package/Layout/screenHeader.tsx +41 -56
  34. package/Pagination/types.ts +6 -2
  35. package/Text/utils.ts +4 -30
  36. package/package.json +28 -26
  37. package/Application/BottomTab/Legacy/BottomTabBar.styles.ts +0 -60
  38. package/Application/BottomTab/Legacy/BottomTabBar.tsx +0 -270
  39. package/Application/BottomTab/Legacy/CustomBottomTabItem.tsx +0 -153
  40. package/Application/BottomTab/Legacy/DuoBarCompression.tsx +0 -135
  41. package/Application/BottomTab/Legacy/DuoRailTabBar.tsx +0 -149
  42. package/Application/BottomTab/Legacy/DuoTabBar.parts.tsx +0 -202
  43. package/Application/BottomTab/Legacy/DuoTabBar.styles.ts +0 -123
  44. package/Application/BottomTab/Legacy/DuoTabBar.tsx +0 -151
  45. package/Application/BottomTab/Legacy/TabBarIcon.tsx +0 -113
  46. package/Application/BottomTab/Legacy/TabScreen.tsx +0 -177
  47. package/Application/BottomTab/Legacy/badge.ts +0 -41
  48. package/Application/BottomTab/Legacy/hooks.ts +0 -358
  49. package/Application/BottomTab/Legacy/index.styles.ts +0 -30
  50. package/Application/BottomTab/Legacy/index.tsx +0 -230
  51. package/Application/Components/useHeaderRightWidth.ts +0 -46
@@ -7,10 +7,10 @@ import React, {
7
7
  useState,
8
8
  } from 'react';
9
9
  import {
10
- TextInput,
11
10
  TextInputFocusEvent,
12
11
  TouchableOpacity,
13
12
  View,
13
+ type TextInputInstance,
14
14
  } from 'react-native';
15
15
  import { setAutomationID, useComponentId } from '../Application';
16
16
  import { ApplicationContext, MiniAppContext } from '../Context';
@@ -70,7 +70,7 @@ const InputTextArea = forwardRef(
70
70
  const inputFontFamily = exportFontFamily('regular');
71
71
  const [isFocused, setIsFocused] = useState(false);
72
72
  const [inputValue, setInputValue] = useState(defaultValue ?? '');
73
- const inputRef = useRef<TextInput | null>(null);
73
+ const inputRef = useRef<TextInputInstance | null>(null);
74
74
 
75
75
  useEffect(() => {
76
76
  setInputValue(value ?? '');
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import React, { FC, useEffect, useRef } from 'react';
3
- import { TextInput } from 'react-native';
3
+ import { TextInput, type TextInputInstance } from 'react-native';
4
4
  import { useScaleSize, exportFontFamily } from '../Text';
5
5
  import styles from './styles';
6
6
 
@@ -13,7 +13,7 @@ export const TextTyping: FC<any> = ({
13
13
  timeDelayEnd = 2000,
14
14
  timeDelayNextChar = 20,
15
15
  }) => {
16
- const textRef = useRef<TextInput>(null);
16
+ const textRef = useRef<TextInputInstance>(null);
17
17
  const scaledFontSize = useScaleSize(12);
18
18
  const typingFontFamily = exportFontFamily('regular');
19
19
 
@@ -4,11 +4,12 @@ import {
4
4
  TextInput,
5
5
  TextInputProps,
6
6
  TouchableOpacity,
7
+ type TextInputInstance,
7
8
  } from 'react-native';
8
9
  import { Styles } from '../Consts';
9
10
 
10
11
  interface SystemTextInputProps extends TextInputProps {
11
- ref?: React.RefObject<TextInput | null>;
12
+ ref?: React.RefObject<TextInputInstance | null>;
12
13
  }
13
14
 
14
15
  /**
@@ -1,6 +1,11 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import React, { FC, memo, useEffect, useRef } from 'react';
3
- import { Platform, TextInput, TextStyle } from 'react-native';
3
+ import {
4
+ Platform,
5
+ TextInput,
6
+ TextStyle,
7
+ type TextInputInstance,
8
+ } from 'react-native';
4
9
  import { Colors } from '../Consts';
5
10
  import { useScaleSize, exportFontFamily } from '../Text';
6
11
 
@@ -21,7 +26,7 @@ const TextTyping: FC<TextTypingProps> = ({
21
26
  timeDelayNextChar = 20,
22
27
  inputStyle = {},
23
28
  }) => {
24
- const textRef = useRef<TextInput>(null);
29
+ const textRef = useRef<TextInputInstance>(null);
25
30
  const scaledFontSize = useScaleSize(12);
26
31
  const inputFontFamily = exportFontFamily('regular');
27
32
 
@@ -4,9 +4,9 @@ import { StackNavigationOptions } from '@react-navigation/stack';
4
4
  import type { SharedValue } from 'react-native-reanimated';
5
5
  import Navigation from '../Application/Navigation';
6
6
  import { AnimatedHeader, SearchHeaderProps } from '../Application/types';
7
+ import { exportHeaderTitle } from '../Application/navigationOptions';
7
8
  import { Colors, Spacing } from '../Consts';
8
9
  import {
9
- exportHeaderTitle,
10
10
  HeaderBackground,
11
11
  HeaderLeft,
12
12
  HeaderTitle,
@@ -63,9 +63,8 @@ const getSearchTitleOptions = (
63
63
  };
64
64
 
65
65
  /**
66
- * Applies the Screen's navigation header (plain, extended, animated banner or search), with
67
- * a ref search header on top, and re-applies it on prop or layout change. Returns the
68
- * search header setter and the tint.
66
+ * Applies the Screen's navigation header (plain, extended, animated banner or search) and
67
+ * re-applies it when those props change. Returns the search header setter and the tint.
69
68
  */
70
69
  export const useScreenHeader = ({
71
70
  navigation,
@@ -84,7 +83,6 @@ export const useScreenHeader = ({
84
83
  }: ScreenHeaderParams) => {
85
84
  const currentTint = useRef<string | undefined>(undefined);
86
85
  const appliedHeaderMode = useRef<string | undefined>(undefined);
87
- const searchHeaderParams = useRef<SearchHeaderProps | undefined>(undefined);
88
86
  const headerLayout = useHeaderLayout(contentLayout);
89
87
  const frameOptions = useHeaderFrameOptions(contentLayout);
90
88
 
@@ -245,54 +243,45 @@ export const useScreenHeader = ({
245
243
  }, [navigation?.instance, sharedValue, frameOptions]);
246
244
 
247
245
  // the search field spans the content (or the stretch frame), clear of the side bar
248
- // and status bar clusters; kept as numbers so the setter below stays stable
249
- let searchWidth = headerLayout.frameWidth;
250
- let searchLeft = Spacing.M;
251
- if (layout.sideBar) {
252
- searchWidth = layout.contentWidth - Spacing.M * 2;
253
- searchLeft = Spacing.M - getHeaderMargin(layout.width);
254
- }
255
- const clearance = layout.statusBarClearance;
256
- if (clearance) {
257
- searchWidth -= clearance.left + clearance.right;
258
- }
259
-
260
- /**
261
- * Shows the search header and keeps its params: the header effect puts it back over the
262
- * base header, so a call made before that effect, or a resize, does not lose it.
263
- */
264
- const setSearchHeader = useCallback(
265
- (params: SearchHeaderProps) => {
266
- searchHeaderParams.current = params;
267
- const options: StackNavigationOptions = {
268
- ...frameOptions,
269
- headerRight: undefined,
270
- headerTitleContainerStyle: {
271
- width: searchWidth,
272
- maxWidth: searchWidth,
273
- marginLeft: 0,
274
- marginEnd: 0,
275
- marginStart: 0,
276
- marginHorizontal: 0,
277
- marginVertical: 0,
278
- margin: 0,
279
- left: searchLeft,
280
- },
281
- headerLeft: (props: any) => {
282
- if (params?.hiddenBack) {
283
- return null;
284
- }
285
- return <HeaderLeft {...props} floating />;
286
- },
287
- headerTitle: () => (
288
- <SearchHeader {...params} animatedValue={sharedValue} />
289
- ),
290
- };
246
+ // and status bar clusters
247
+ const setSearchHeader = (params: SearchHeaderProps) => {
248
+ let searchWidth = headerLayout.frameWidth;
249
+ let searchLeft = Spacing.M;
250
+ if (layout.sideBar) {
251
+ searchWidth = layout.contentWidth - Spacing.M * 2;
252
+ searchLeft = Spacing.M - getHeaderMargin(layout.width);
253
+ }
254
+ const clearance = layout.statusBarClearance;
255
+ if (clearance) {
256
+ searchWidth -= clearance.left + clearance.right;
257
+ }
258
+ const options: StackNavigationOptions = {
259
+ ...frameOptions,
260
+ headerRight: undefined,
261
+ headerTitleContainerStyle: {
262
+ width: searchWidth,
263
+ maxWidth: searchWidth,
264
+ marginLeft: 0,
265
+ marginEnd: 0,
266
+ marginStart: 0,
267
+ marginHorizontal: 0,
268
+ marginVertical: 0,
269
+ margin: 0,
270
+ left: searchLeft,
271
+ },
272
+ headerLeft: (props: any) => {
273
+ if (params?.hiddenBack) {
274
+ return null;
275
+ }
276
+ return <HeaderLeft {...props} floating />;
277
+ },
278
+ headerTitle: () => (
279
+ <SearchHeader {...params} animatedValue={sharedValue} />
280
+ ),
281
+ };
291
282
 
292
- navigation?.instance?.setOptions(options);
293
- },
294
- [navigation?.instance, sharedValue, frameOptions, searchWidth, searchLeft],
295
- );
283
+ navigation?.instance?.setOptions(options);
284
+ };
296
285
 
297
286
  useEffect(() => {
298
287
  const focus = navigation?.instance?.addListener?.('focus', () => {
@@ -313,9 +302,6 @@ export const useScreenHeader = ({
313
302
  setHeaderType(headerType, appliedHeaderMode.current === headerType);
314
303
  appliedHeaderMode.current = headerType;
315
304
  }
316
- if (searchHeaderParams.current) {
317
- setSearchHeader(searchHeaderParams.current);
318
- }
319
305
 
320
306
  return () => {
321
307
  focus?.();
@@ -329,7 +315,6 @@ export const useScreenHeader = ({
329
315
  setAnimatedHeader,
330
316
  setAnimatedSearch,
331
317
  setHeaderType,
332
- setSearchHeader,
333
318
  ]);
334
319
 
335
320
  return { setSearchHeader, currentTint };
@@ -1,4 +1,8 @@
1
- import {ScrollView, ScrollViewProps, ViewStyle} from 'react-native';
1
+ import {
2
+ ScrollViewProps,
3
+ ViewStyle,
4
+ type ScrollViewInstance,
5
+ } from 'react-native';
2
6
  import {Ref} from 'react';
3
7
 
4
8
  export type PaginationProps = {
@@ -32,7 +36,7 @@ export interface ScrollIndicatorProps extends ScrollViewProps {
32
36
  * Optional. Represents a reference to the ScrollView component.
33
37
  * It can be used to access the instance methods of the ScrollView.
34
38
  */
35
- scrollViewRef?: Ref<ScrollView>;
39
+ scrollViewRef?: Ref<ScrollViewInstance>;
36
40
  }
37
41
 
38
42
  export type ChildPaginationProps = Omit<PaginationProps, 'type'>;
package/Text/utils.ts CHANGED
@@ -5,50 +5,24 @@ import { MiniAppContext } from '../Context';
5
5
  const DEFAULT_SCREEN_SIZE = 375;
6
6
  const MAX_FONT_SCALE = 1.5;
7
7
  const MAX_DEVICE_SCALE = 5;
8
- const APP_SCALE_LEVELS = [1, 1.2, 1.3, 1.4];
9
8
 
10
9
  type MiniAppScale = {
11
10
  scaleSizeMaxRate?: number;
12
- fontScale?: {
13
- useOSScaleRate?: boolean;
14
- appScaleRate?: number;
15
- /** @deprecated Use `appScaleRate`. Still sent by the host. */
16
- userScaleRate?: number;
17
- };
18
- };
19
-
20
- /**
21
- * Snaps a host scale rate to the nearest app scale level (1, 1.2, 1.3, 1.4),
22
- * ties going lower, so legacy rates (1.1, 1.6) resolve like the host does.
23
- */
24
- const toAppScaleRate = (rate?: number) => {
25
- if (!rate) {
26
- return APP_SCALE_LEVELS[0];
27
- }
28
- const percent = Math.round(rate * 100);
29
- const distance = (level: number) =>
30
- Math.abs(Math.round(level * 100) - percent);
31
- return APP_SCALE_LEVELS.reduce((best, level) =>
32
- distance(level) < distance(best) ? level : best,
33
- );
11
+ fontScale?: { useOSScaleRate?: boolean; userScaleRate?: number };
34
12
  };
35
13
 
36
14
  /**
37
15
  * Scales `size` by screen width (+5 max) and OS font scale (max `scaleRate`,
38
16
  * else the ScaleSizeProvider rate, else 1.5), taking the larger, or by the mini
39
- * app `fontScale.appScaleRate`; a provider rate caps both at `size × rate`.
17
+ * app `fontScale.userScaleRate`; a provider rate caps both at `size × rate`.
40
18
  */
41
19
  const useScaleSize = (size: number, scaleRate?: number) => {
42
20
  const { width } = useWindowDimensions();
43
21
  const context = useContext<MiniAppScale | undefined>(MiniAppContext);
44
22
  const scaleSizeMaxRate = context?.scaleSizeMaxRate;
45
23
  const maxSize = scaleSizeMaxRate ? size * scaleSizeMaxRate : Infinity;
46
- const appScale = context?.fontScale;
47
- if (appScale?.useOSScaleRate === false) {
48
- const rate = toAppScaleRate(
49
- appScale.appScaleRate ?? appScale.userScaleRate,
50
- );
51
- return Math.min(size * rate, maxSize);
24
+ if (context?.fontScale?.useOSScaleRate === false) {
25
+ return Math.min(size * (context.fontScale.userScaleRate ?? 1), maxSize);
52
26
  }
53
27
  const fontScale = PixelRatio.getFontScale();
54
28
  const deviceScale = width / DEFAULT_SCREEN_SIZE;
package/package.json CHANGED
@@ -1,39 +1,41 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.169.17-beta.1",
3
+ "version": "0.169.17-beta.13",
4
4
  "description": "React Native Component Kits",
5
- "main": "index.ts",
6
- "scripts": {},
7
5
  "keywords": [
8
6
  "@momo-kits/foundation"
9
7
  ],
8
+ "license": "MoMo",
9
+ "main": "index.ts",
10
+ "publishConfig": {
11
+ "registry": "https://registry.npmjs.org/"
12
+ },
13
+ "scripts": {},
10
14
  "dependencies": {
11
- "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
12
- "@react-navigation/bottom-tabs": "7.4.2",
13
- "@react-navigation/core": "7.12.1",
14
- "@react-navigation/elements": "2.5.2",
15
- "@react-navigation/native": "7.1.14",
16
- "@react-navigation/routers": "7.4.1",
17
- "@react-navigation/stack": "7.4.2",
18
- "react-native-gesture-handler": "2.27.1",
19
- "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
20
- "react-native-reanimated": "4.1.3",
21
- "react-native-worklets": "0.6.1",
22
- "react-native-safe-area-context": "5.5.2",
23
- "react-native-reserved-regions": "0.2.0",
15
+ "@react-navigation/bottom-tabs": "7.21.0",
16
+ "@react-navigation/core": "7.24.0",
17
+ "@react-navigation/elements": "2.9.45",
18
+ "@react-navigation/native": "7.5.1",
19
+ "@react-navigation/routers": "7.6.5",
20
+ "@react-navigation/stack": "7.12.1",
24
21
  "@shopify/flash-list": "2.1.0",
25
- "lottie-react-native": "7.2.4"
22
+ "lottie-react-native": "7.3.6",
23
+ "react-native-fast-image": "git+https://oauth2:k_r5y_gV6sX9-TqQxgcd@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
24
+ "react-native-gesture-handler": "3.4.0",
25
+ "react-native-linear-gradient": "git+https://oauth2:k_r5y_gV6sX9-TqQxgcd@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
26
+ "react-native-reanimated": "4.7.1",
27
+ "react-native-safe-area-context": "5.7.0",
28
+ "react-native-reserved-regions": "0.2.0"
29
+ },
30
+ "devDependencies": {
31
+ "@types/color": "3.0.6",
32
+ "react-native-reanimated": "4.7.1",
33
+ "react-native-worklets": "0.13.0"
26
34
  },
27
35
  "peerDependencies": {
28
36
  "react-native": "*",
29
37
  "react-native-svg": "*",
30
- "react-native-worklets": "0.6.1"
31
- },
32
- "devDependencies": {
33
- "@types/color": "3.0.6"
34
- },
35
- "publishConfig": {
36
- "registry": "https://registry.npmjs.org/"
37
- },
38
- "license": "MoMo"
38
+ "react-native-reanimated": ">=4.7.0",
39
+ "react-native-worklets": ">=0.13.0"
40
+ }
39
41
  }
@@ -1,60 +0,0 @@
1
- import { Platform, StyleSheet } from 'react-native';
2
- import { Colors, Radius } from '../../../Consts';
3
-
4
- export const styles = StyleSheet.create({
5
- content: {
6
- flex: 1,
7
- flexDirection: 'row',
8
- },
9
- tabBar: {
10
- left: 0,
11
- right: 0,
12
- bottom: 0,
13
- borderTopWidth: StyleSheet.hairlineWidth,
14
- elevation: 8,
15
- },
16
- tabBarFloatingButton: {
17
- left: 0,
18
- right: 0,
19
- bottom: 0,
20
- zIndex: 1,
21
- shadowColor: Colors.black_20,
22
- shadowOffset: { width: 0, height: -2 },
23
- shadowOpacity: 0.05,
24
- shadowRadius: 3,
25
- elevation: 8,
26
- },
27
- floatingContainer: {
28
- position: 'absolute',
29
- alignItems: 'center',
30
- left: 0,
31
- right: 0,
32
- top: -2,
33
- bottom: Platform.OS === 'ios' ? -6 : 4,
34
- },
35
- floatingContent: {
36
- alignItems: 'center',
37
- justifyContent: 'center',
38
- height: 48,
39
- width: 48,
40
- borderRadius: 24,
41
- top: -10,
42
- },
43
- indicator: {
44
- height: 2,
45
- width: 44,
46
- alignSelf: 'center',
47
- borderBottomLeftRadius: 1,
48
- borderBottomRightRadius: 1,
49
- },
50
- debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
51
- floatingLabel: {
52
- top: -4,
53
- borderRadius: Radius.XL,
54
- paddingHorizontal: 6,
55
- },
56
- indicatorContainer: {
57
- position: 'absolute',
58
- top: 0,
59
- },
60
- });