@momo-kits/foundation 0.160.1-rn.84 → 0.161.1-beta.1

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 (47) hide show
  1. package/Application/BottomSheet.tsx +1 -1
  2. package/Application/BottomTab/BottomTabBar.tsx +2 -2
  3. package/Application/BottomTab/CustomBottomTabItem.tsx +1 -1
  4. package/Application/BottomTab/index.tsx +0 -1
  5. package/Application/Components/HeaderBackground.tsx +1 -1
  6. package/Application/Components/HeaderExtendHeader.tsx +1 -1
  7. package/Application/Components/HeaderTitle.tsx +1 -1
  8. package/Application/Components/SearchHeader.tsx +1 -1
  9. package/Application/NavigationContainer.tsx +20 -17
  10. package/Application/WidgetContainer.tsx +21 -8
  11. package/Application/index.ts +0 -2
  12. package/Application/types.ts +0 -6
  13. package/Badge/Badge.tsx +9 -3
  14. package/Badge/BadgeDot.tsx +1 -1
  15. package/Badge/BadgeRibbon.tsx +1 -1
  16. package/Badge/styles.ts +4 -5
  17. package/Button/index.tsx +2 -2
  18. package/CheckBox/index.tsx +1 -1
  19. package/Context/index.ts +0 -4
  20. package/Divider/index.tsx +3 -3
  21. package/Icon/index.tsx +1 -1
  22. package/IconButton/index.tsx +1 -1
  23. package/Image/index.tsx +2 -47
  24. package/Input/Input.tsx +2 -2
  25. package/Input/InputDropDown.tsx +2 -2
  26. package/Input/InputMoney.tsx +2 -2
  27. package/Input/InputOTP.tsx +1 -1
  28. package/Input/InputPhoneNumber.tsx +2 -2
  29. package/Input/InputSearch.tsx +3 -2
  30. package/Input/InputTextArea.tsx +1 -1
  31. package/Input/styles.ts +1 -6
  32. package/Layout/FloatingButton.tsx +12 -3
  33. package/Layout/Item.tsx +1 -1
  34. package/Pagination/PaginationDot.tsx +1 -1
  35. package/Pagination/PaginationNumber.tsx +1 -1
  36. package/Pagination/PaginationScroll.tsx +1 -1
  37. package/Pagination/PaginationWhiteDot.tsx +1 -1
  38. package/Popup/PopupNotify.tsx +1 -1
  39. package/Popup/PopupPromotion.tsx +2 -2
  40. package/Radio/index.tsx +1 -1
  41. package/Switch/index.tsx +1 -1
  42. package/Tag/index.tsx +1 -1
  43. package/Text/index.tsx +5 -16
  44. package/Text/utils.ts +19 -43
  45. package/Title/index.tsx +1 -1
  46. package/package.json +34 -34
  47. package/Application/ScaleSizeProvider.tsx +0 -16
@@ -39,7 +39,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
39
39
  const heightHeader = useHeaderHeight();
40
40
  const keyboardOffset = heightHeader - Math.min(insets.bottom, 21);
41
41
 
42
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
42
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
43
43
 
44
44
  const {
45
45
  screen: Screen,
@@ -63,7 +63,7 @@ export default function BottomTabBar({
63
63
  const focusedTab = state?.routes[state.index]?.name || routes[0]?.params;
64
64
 
65
65
  const context = useContext<any>(MiniAppContext);
66
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
66
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
67
67
 
68
68
  /**
69
69
  * render tab item
@@ -299,7 +299,7 @@ const styles = StyleSheet.create({
299
299
  left: 0,
300
300
  right: 0,
301
301
  top: -2,
302
- bottom: Platform.OS === 'ios' ? -6 : 4
302
+ bottom: Platform.OS === 'ios' ? -6 : 4,
303
303
  },
304
304
  floatingContent: {
305
305
  alignItems: 'center',
@@ -61,7 +61,7 @@ const CustomBottomTabItem: React.FC<CustomBottomTabItemProps> = ({
61
61
  allowFontScaling,
62
62
  }) => {
63
63
  const context = useContext<any>(MiniAppContext);
64
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
64
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
65
65
 
66
66
  const renderIcon = () => {
67
67
  if (icon === undefined) {
@@ -376,7 +376,6 @@ const BottomTab: React.FC<BottomTabProps> = ({
376
376
  return (
377
377
  <Text
378
378
  numberOfLines={1}
379
- maxScaleRate={1.4}
380
379
  typography={
381
380
  focused ? 'label_xs_medium' : 'description_xs_regular'
382
381
  }
@@ -24,7 +24,7 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
24
24
  const gradientColor = customGradientColor ?? theme.colors.gradient;
25
25
  const headerImage = headerBackground ?? theme.assets?.headerBackground;
26
26
 
27
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
27
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
28
28
 
29
29
  const opacityBackground = animatedValue?.interpolate({
30
30
  inputRange: [0, 52],
@@ -49,7 +49,7 @@ const HeaderExtendHeader: React.FC<{
49
49
  const headerBackground = customBackground ?? theme.assets?.headerBackground;
50
50
  const leftPosition = inputSearchProps?.leftPosition || BACK_WIDTH + 20;
51
51
 
52
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
52
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
53
53
 
54
54
  const opacityBackground = animatedValue?.interpolate({
55
55
  inputRange: [0, 52],
@@ -24,7 +24,7 @@ import { Skeleton } from '../../Skeleton';
24
24
  const HeaderTitle: React.FC<any> = props => {
25
25
  const context = useContext<any>(MiniAppContext);
26
26
 
27
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
27
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
28
28
 
29
29
  const opacity = props.animatedValue?.interpolate(
30
30
  props.interpolate ?? {
@@ -77,7 +77,7 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
77
77
  return true;
78
78
  };
79
79
 
80
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
80
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
81
81
 
82
82
  return (
83
83
  <View
@@ -35,28 +35,31 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
35
35
  maxApi,
36
36
  initialParams,
37
37
  localize = new Localize({ vi: {}, en: {} }),
38
- features = {
39
- enableBottomTabAnimation: true,
40
- enableHapticDialog: true,
41
- enableForceFoundationList: false,
42
- enableHapticBottomTab: true,
43
- },
44
38
  }) => {
45
39
  const context = useContext<any>(MiniAppContext);
46
- const [currentContext, setCurrentContext] = useState({});
40
+ const [currentContext, setCurrentContext] = useState<any>({});
41
+ const [allowFontScale, setAllowFontScale] = useState<boolean>(
42
+ context?.designSystemConfig?.allowFontScale ?? true,
43
+ );
44
+
45
+ useEffect(() => {
46
+ maxApi?.getDataObserver?.('allow_font_scale', (value: boolean) => {
47
+ setAllowFontScale(value ?? true);
48
+ });
49
+ }, [maxApi]);
50
+
51
+ const mergedContext = {
52
+ ...context,
53
+ ...currentContext,
54
+ designSystemConfig: {
55
+ ...context?.designSystemConfig,
56
+ allowFontScale,
57
+ },
58
+ };
47
59
 
48
60
  return (
49
61
  <SafeAreaProvider>
50
- <MiniAppContext.Provider
51
- value={{
52
- ...context,
53
- ...currentContext,
54
- features: {
55
- ...context?.features,
56
- ...features,
57
- },
58
- }}
59
- >
62
+ <MiniAppContext.Provider value={mergedContext}>
60
63
  <Navigation
61
64
  screen={screen}
62
65
  theme={theme}
@@ -1,4 +1,4 @@
1
- import React, { useContext, useRef, useState } from 'react';
1
+ import React, { useContext, useEffect, useRef, useState } from 'react';
2
2
  import { SafeAreaProvider } from 'react-native-safe-area-context';
3
3
  import Navigator from './Navigator';
4
4
  import { WidgetContainerProps } from './types';
@@ -42,6 +42,15 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
42
42
  const isReady = useRef(false);
43
43
  const navigator = useRef(new Navigator(navigationRef, isReady, true));
44
44
  const [currentContext, setCurrentContext] = useState({});
45
+ const [allowFontScale, setAllowFontScale] = useState<boolean>(
46
+ context?.designSystemConfig?.allowFontScale ?? true,
47
+ );
48
+
49
+ useEffect(() => {
50
+ maxApi?.getDataObserver?.('allow_font_scale', (value: boolean) => {
51
+ setAllowFontScale(value ?? true);
52
+ });
53
+ }, [maxApi]);
45
54
 
46
55
  let headerBackground = context?.designConfig?.headerBar;
47
56
  let headerGradient = theme.colors?.gradient;
@@ -67,15 +76,19 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
67
76
 
68
77
  navigator.current.setCurrentContext = setCurrentContext;
69
78
 
79
+ const mergedContext = {
80
+ ...context,
81
+ ...currentContext,
82
+ designSystemConfig: {
83
+ ...context?.designSystemConfig,
84
+ allowFontScale,
85
+ },
86
+ };
87
+
70
88
  return (
71
- <View style={{ height: height ?? '100%', minHeight:1 }}>
89
+ <View style={{ height: height ?? '100%', minHeight: 1 }}>
72
90
  <SafeAreaProvider>
73
- <MiniAppContext.Provider
74
- value={{
75
- ...context,
76
- ...currentContext,
77
- }}
78
- >
91
+ <MiniAppContext.Provider value={mergedContext}>
79
92
  <ApplicationContext.Provider
80
93
  value={{
81
94
  navigator: navigator.current,
@@ -16,7 +16,6 @@ export * from './Components/SearchHeader';
16
16
  import { exportHeaderTitle, setAutomationID, useComponentId } from './utils';
17
17
  import Navigation from './Navigation';
18
18
  import Navigator from './Navigator';
19
- import ScaleSizeProvider from './ScaleSizeProvider';
20
19
  import { useTooltipPortal } from './TooltipPortal';
21
20
 
22
21
  export {
@@ -29,6 +28,5 @@ export {
29
28
  Navigation,
30
29
  Navigator,
31
30
  exportHeaderTitle,
32
- ScaleSizeProvider,
33
31
  useTooltipPortal,
34
32
  };
@@ -107,11 +107,6 @@ export type Theme = {
107
107
  };
108
108
  };
109
109
 
110
- export type ScaleSizeProviderProps = {
111
- scaleSizeMaxRate?: number;
112
- children: ViewProps['children'];
113
- };
114
-
115
110
  export type Context = {
116
111
  [key: string]: any;
117
112
  theme: Theme;
@@ -158,7 +153,6 @@ export type NavigationContainerProps = {
158
153
  maxApi: any;
159
154
  initialParams?: any;
160
155
  localize: LocalizeProps;
161
- features?: FeatureFlags;
162
156
  };
163
157
 
164
158
  export type WidgetContainerProps = {
package/Badge/Badge.tsx CHANGED
@@ -18,8 +18,8 @@ const Badge: FC<BadgeProps> = ({
18
18
  const { componentId } = useComponentId('Badge', accessibilityLabel);
19
19
  const scaledSize = useScaleSize(16);
20
20
 
21
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
22
-
21
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
22
+
23
23
  const styles = StyleSheet.create({
24
24
  badge: {
25
25
  paddingHorizontal: Spacing.XS,
@@ -84,7 +84,13 @@ const Badge: FC<BadgeProps> = ({
84
84
  }
85
85
 
86
86
  return (
87
- <View style={[style, styles.badgeContainer, showBaseLineDebug && styles.debugBaseLine]}>
87
+ <View
88
+ style={[
89
+ style,
90
+ styles.badgeContainer,
91
+ showBaseLineDebug && styles.debugBaseLine,
92
+ ]}
93
+ >
88
94
  <View
89
95
  style={[styles.badge, { backgroundColor: badgeColor }]}
90
96
  accessibilityLabel={componentId}
@@ -9,7 +9,7 @@ const BadgeDot: FC<BadgeDotProps> = ({ size = 'large', style }) => {
9
9
  let dotStyle;
10
10
  let dotContainerStyle;
11
11
 
12
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
12
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
13
13
 
14
14
  if (size === 'large') {
15
15
  dotStyle = styles.dot;
@@ -19,7 +19,7 @@ const BadgeRibbon: FC<BadgeRibbonProps> = ({
19
19
  const isRight = position === 'top_right' || position === 'bottom_right';
20
20
  const isUpTail = position === 'bottom_left' || position === 'top_right';
21
21
 
22
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
22
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
23
23
 
24
24
  const ribbonRotate = useMemo(() => (isRight ? '180deg' : '0deg'), [isRight]);
25
25
  const textRotate = ribbonRotate;
package/Badge/styles.ts CHANGED
@@ -1,6 +1,5 @@
1
1
  import {StyleSheet} from 'react-native';
2
2
  import {Colors, Radius, Spacing} from '../Consts';
3
- import {scaleSize} from '../Text';
4
3
 
5
4
  const DOT_SIZE = 16;
6
5
 
@@ -12,8 +11,8 @@ export default StyleSheet.create({
12
11
  borderRadius: Radius.M,
13
12
  justifyContent: 'center',
14
13
  alignItems: 'center',
15
- height: scaleSize(16) - 2,
16
- minWidth: scaleSize(16) - 2,
14
+ height: DOT_SIZE - 2,
15
+ minWidth: DOT_SIZE - 2,
17
16
  flexDirection: 'row',
18
17
  alignSelf: 'baseline',
19
18
  },
@@ -21,8 +20,8 @@ export default StyleSheet.create({
21
20
  borderRadius: Radius.M,
22
21
  justifyContent: 'center',
23
22
  alignItems: 'center',
24
- height: scaleSize(16),
25
- minWidth: scaleSize(16),
23
+ height: DOT_SIZE,
24
+ minWidth: DOT_SIZE,
26
25
  flexDirection: 'row',
27
26
  borderWidth: 1,
28
27
  borderColor: Colors.black_01,
package/Button/index.tsx CHANGED
@@ -77,7 +77,7 @@ const Button: FC<ButtonProps> = ({
77
77
  const animationRef = useRef<LottieView>(null);
78
78
  const pressAnim = useSharedValue(0);
79
79
 
80
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
80
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
81
81
 
82
82
  const componentName = 'Button';
83
83
  const { componentId } = useComponentId(
@@ -355,7 +355,7 @@ const Button: FC<ButtonProps> = ({
355
355
  onPressOut={animateOut}
356
356
  >
357
357
  <Reanimated.View style={[buttonStyle, animatedStyle]}>
358
- {renderIcon('left')}
358
+ {renderIcon('left')}
359
359
  {renderTitle()}
360
360
  {renderIcon('right')}
361
361
  {gradientPros && (
@@ -34,7 +34,7 @@ const CheckBox: FC<CheckBoxProps> = ({
34
34
  props.accessibilityLabel,
35
35
  );
36
36
 
37
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
37
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
38
38
 
39
39
  if (haveValue) {
40
40
  borderColor = theme.colors.primary;
package/Context/index.ts CHANGED
@@ -9,9 +9,6 @@ const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
9
9
  const ScreenContext = (Platform as any).ScreenContext ?? Context;
10
10
  const ComponentContext = (Platform as any).ComponentContext ?? Context;
11
11
  const SkeletonContext = createContext({ loading: false });
12
- const ScaleSizeContext = createContext<{ scaleSizeMaxRate?: number }>({
13
- scaleSizeMaxRate: undefined,
14
- });
15
12
  const TrackingScopeContext = createContext<{ scopeName?: string }>({
16
13
  scopeName: undefined,
17
14
  });
@@ -23,5 +20,4 @@ export {
23
20
  ComponentContext,
24
21
  SkeletonContext,
25
22
  TrackingScopeContext,
26
- ScaleSizeContext,
27
23
  };
package/Divider/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { StyleProp, View, ViewStyle } from 'react-native';
2
+ import { View, ViewStyle } from 'react-native';
3
3
  import { ApplicationContext } from '../Context';
4
4
  import { Spacing } from '../Consts';
5
5
  import { DashDivider } from './DashDivider';
@@ -8,7 +8,7 @@ export interface DividerProps {
8
8
  /**
9
9
  * Custom styles for divider
10
10
  */
11
- style?: StyleProp<ViewStyle>;
11
+ style?: ViewStyle;
12
12
 
13
13
  /**
14
14
  * Enable margin vertical 4px
@@ -30,13 +30,13 @@ const Divider: React.FC<DividerProps> = ({
30
30
  return (
31
31
  <View
32
32
  style={[
33
+ style,
33
34
  {
34
35
  height: 1,
35
36
  width: '100%',
36
37
  backgroundColor: theme.colors.border.default,
37
38
  marginVertical: useMargin ? Spacing.XS : 0,
38
39
  },
39
- style,
40
40
  ]}
41
41
  />
42
42
  );
package/Icon/index.tsx CHANGED
@@ -17,7 +17,7 @@ const Icon: React.FC<IconProps> = ({
17
17
  const { theme } = useContext(ApplicationContext);
18
18
  const context = useContext<any>(MiniAppContext);
19
19
 
20
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
20
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
21
21
 
22
22
  /**
23
23
  * get icon source maps or remote http
@@ -46,7 +46,7 @@ const IconButton: React.FC<IconButtonProps> = ({
46
46
  const { theme } = useContext(ApplicationContext);
47
47
  const context = useContext<any>(MiniAppContext);
48
48
 
49
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
49
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
50
50
 
51
51
  /**
52
52
  * get size icon button
package/Image/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { useContext, useRef, useState } from 'react';
2
- import { Image as RNImage, StyleSheet, View } from 'react-native';
2
+ import { StyleSheet, View } from 'react-native';
3
3
  import FastImage from 'react-native-fast-image';
4
4
  import styles from './styles';
5
5
  import {
@@ -23,10 +23,6 @@ export const getImageName = (source: any): string => {
23
23
  return '';
24
24
  };
25
25
 
26
- const isDataUriSource = (source: any): boolean => {
27
- return typeof source?.uri === 'string' && source.uri.startsWith('data:');
28
- };
29
-
30
26
  const Image: React.FC<ImageProps> = ({
31
27
  style,
32
28
  source,
@@ -41,8 +37,7 @@ const Image: React.FC<ImageProps> = ({
41
37
  const error = useRef(false);
42
38
  const [status, setStatus] = useState<Status>('success');
43
39
 
44
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
45
- const useFastImage = !isDataUriSource(source);
40
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
46
41
 
47
42
  let accessibilityLabel: any = `img|${getImageName(source)}`;
48
43
  if (component?.componentId) {
@@ -79,46 +74,6 @@ const Image: React.FC<ImageProps> = ({
79
74
  return children;
80
75
  };
81
76
 
82
- if (!useFastImage) {
83
- return (
84
- <RNImage
85
- {...rest}
86
- {...{
87
- accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel,
88
- }}
89
- source={source}
90
- style={[
91
- styles.container,
92
- style,
93
- showBaseLineDebug && styles.debugBaseLine,
94
- ]}
95
- onLoadStart={() => {
96
- error.current = false;
97
- if (status !== 'loading' && loading) {
98
- setStatus('loading');
99
- }
100
- }}
101
- onLoad={() => {
102
- error.current = false;
103
- }}
104
- onLoadEnd={() => {
105
- let current: Status = 'success';
106
- if (error.current) {
107
- current = 'error';
108
- }
109
- setStatus(prevState =>
110
- prevState !== current ? current : prevState,
111
- );
112
- }}
113
- onError={() => {
114
- error.current = true;
115
- }}
116
- >
117
- {renderContent()}
118
- </RNImage>
119
- );
120
- }
121
-
122
77
  return (
123
78
  <FastImage
124
79
  {...rest}
package/Input/Input.tsx CHANGED
@@ -75,13 +75,13 @@ const Input = forwardRef(
75
75
  const { theme } = useContext(ApplicationContext);
76
76
  const context = useContext<any>(MiniAppContext);
77
77
  const scaledFontSize = useScaleSize(14);
78
- const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1);
78
+ const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
79
79
  const [focused, setFocused] = useState(false);
80
80
  const haveValue = !!value || !!defaultValue;
81
81
  const inputRef = useRef<TextInput | null>(null);
82
82
  const componentName = 'Input';
83
83
 
84
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
84
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
85
85
 
86
86
  const { componentId } = useComponentId(
87
87
  `${componentName}/${placeholder}`,
@@ -40,10 +40,10 @@ const InputDropDown = ({
40
40
  }: InputDropDownProps) => {
41
41
  const { theme } = useContext(ApplicationContext);
42
42
  const context = useContext<any>(MiniAppContext);
43
- const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1);
43
+ const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
44
44
  const componentName = 'InputDropDown';
45
45
 
46
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
46
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
47
47
 
48
48
  const { componentId } = useComponentId(
49
49
  `${componentName}/${placeholder}`,
@@ -67,7 +67,7 @@ const InputMoney = forwardRef(
67
67
  ) => {
68
68
  const { theme } = useContext(ApplicationContext);
69
69
  const context = useContext<any>(MiniAppContext);
70
- const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1);
70
+ const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
71
71
  const scaledFontSize = useScaleSize(20);
72
72
  const [focused, setFocused] = useState(false);
73
73
  const [displayValue, setDisplayValue] = useState('');
@@ -76,7 +76,7 @@ const InputMoney = forwardRef(
76
76
  const inputRef = useRef<TextInput>(null);
77
77
  const componentName = 'InputMoney';
78
78
 
79
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
79
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
80
80
 
81
81
  const { componentId } = useComponentId(
82
82
  `${componentName}/${placeholder}`,
@@ -99,7 +99,7 @@ const InputOTP = forwardRef(
99
99
 
100
100
  const componentName = 'InputOTP';
101
101
 
102
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
102
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
103
103
 
104
104
  const { componentId } = useComponentId(
105
105
  `${componentName}/${placeholder}`,
@@ -67,13 +67,13 @@ const InputPhoneNumber = forwardRef(
67
67
  ) => {
68
68
  const { theme } = useContext(ApplicationContext);
69
69
  const context = useContext<any>(MiniAppContext);
70
- const scaleHeight = useScaleSize(size === 'small' ? 48 : 56, 1.1);
70
+ const scaleHeight = useScaleSize(size === 'small' ? 48 : 56);
71
71
  const [focused, setFocused] = useState(false);
72
72
  const haveValue = !!value || !!defaultValue;
73
73
  const inputRef = useRef<TextInput | null>(null);
74
74
  const componentName = 'InputPhoneNumber';
75
75
 
76
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
76
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
77
77
 
78
78
  const { componentId } = useComponentId(
79
79
  `${componentName}/${placeholder}`,
@@ -35,6 +35,7 @@ const TextTyping: FC<any> = ({
35
35
  timeDelayNextChar = 20,
36
36
  }) => {
37
37
  const textRef = useRef<TextInput>(null);
38
+ const scaledFontSize = useScaleSize(12);
38
39
 
39
40
  const currentIndex = useRef<number>(0);
40
41
  const currentCharIndex = useRef<number>(0);
@@ -107,7 +108,7 @@ const TextTyping: FC<any> = ({
107
108
 
108
109
  return (
109
110
  <TextInput
110
- style={styles.inputStyle}
111
+ style={[styles.inputStyle, { fontSize: scaledFontSize }]}
111
112
  ref={textRef}
112
113
  editable={false}
113
114
  autoCorrect={false}
@@ -145,7 +146,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
145
146
  const context = useContext<any>(MiniAppContext);
146
147
  const scaledFontSize = useScaleSize(14);
147
148
 
148
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
149
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
149
150
 
150
151
  const [focused, setFocused] = useState(false);
151
152
  const [internalText, setInternalText] = useState(defaultValue || '');
@@ -57,7 +57,7 @@ const InputTextArea = forwardRef(
57
57
  const context = useContext<any>(MiniAppContext);
58
58
  const DEFAULT_HEIGHT = useScaleSize(104);
59
59
 
60
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
60
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
61
61
  const scaledFontSize = useScaleSize(14);
62
62
  const [focused, setFocused] = useState(false);
63
63
  const [inputValue, setInputValue] = useState(defaultValue ?? '');
package/Input/styles.ts CHANGED
@@ -1,13 +1,11 @@
1
1
  import { Platform, StyleSheet } from 'react-native';
2
2
  import { Colors, Radius, Spacing } from '../Consts';
3
- import { scaleSize } from '../Text';
4
3
 
5
4
  export default StyleSheet.create({
6
5
  //input style
7
6
  input: {
8
7
  flex: 1,
9
8
  paddingLeft: Spacing.M,
10
- fontSize: scaleSize(14),
11
9
  height: '100%',
12
10
  },
13
11
  wrapper: {
@@ -76,7 +74,6 @@ export default StyleSheet.create({
76
74
  flex: 1,
77
75
  paddingRight: Spacing.XS,
78
76
  paddingVertical: Spacing.XS,
79
- fontSize: scaleSize(14),
80
77
  },
81
78
  textAreaWrapper: {
82
79
  borderWidth: 1,
@@ -129,13 +126,11 @@ export default StyleSheet.create({
129
126
  width: '100%',
130
127
  paddingLeft: Spacing.M,
131
128
  height: '100%',
132
- fontSize: scaleSize(20),
133
129
  paddingVertical: Spacing.S,
134
130
  fontWeight: 'bold',
135
131
  },
136
132
  inputStyle: {
137
133
  color: Colors.black_12,
138
- fontSize: scaleSize(12),
139
134
  height: Platform.select({
140
135
  android: 60,
141
136
  ios: 36,
@@ -217,7 +212,7 @@ export default StyleSheet.create({
217
212
  borderRadius: Radius.XS,
218
213
  overflow: 'hidden',
219
214
  },
220
- currency: { fontSize: scaleSize(20), fontWeight: 'bold' },
215
+ currency: { fontWeight: 'bold' },
221
216
  phoneNumberDivider: {
222
217
  width: 1,
223
218
  marginLeft: Spacing.M,
@@ -14,6 +14,7 @@ import {
14
14
  } from 'react-native';
15
15
  import { ApplicationContext } from '../Context';
16
16
  import { Icon } from '../Icon';
17
+ import { useScaleSize } from '../Text';
17
18
 
18
19
  export interface FloatingButtonProps {
19
20
  label?: string;
@@ -39,6 +40,8 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
39
40
  bottom = 12,
40
41
  }: FloatingButtonProps) => {
41
42
  const { theme } = useContext(ApplicationContext);
43
+ const scaledFontSize = useScaleSize(16);
44
+ const scaledLineHeight = useScaleSize(22);
42
45
  const maxWidth = useRef(0);
43
46
  const minWidth = size === 'small' ? 36 : 48;
44
47
  const [opacityAnimated] = useState(new Animated.Value(0)); // Initial opacity set to 0
@@ -148,7 +151,15 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
148
151
  {showText && !!label && (
149
152
  <Animated.Text
150
153
  allowFontScaling={false}
151
- style={[styles.label, { opacity: opacityAnimated, color: 'white' }]}
154
+ style={[
155
+ styles.label,
156
+ {
157
+ fontSize: scaledFontSize,
158
+ lineHeight: scaledLineHeight,
159
+ opacity: opacityAnimated,
160
+ color: 'white',
161
+ },
162
+ ]}
152
163
  numberOfLines={1}
153
164
  >
154
165
  {label}
@@ -172,8 +183,6 @@ const styles = StyleSheet.create({
172
183
  },
173
184
  label: {
174
185
  marginLeft: 8,
175
- fontSize: 16,
176
- lineHeight: 22,
177
186
  fontWeight: '700',
178
187
  },
179
188
  });
package/Layout/Item.tsx CHANGED
@@ -27,7 +27,7 @@ const Item: React.FC<ItemProps> = ({
27
27
  const context = useContext<any>(MiniAppContext);
28
28
  const grid = useContext(GridContext);
29
29
 
30
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
30
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
31
31
 
32
32
  /**
33
33
  * render overlay view only dev mode
@@ -14,7 +14,7 @@ const PaginationDot: FC<ChildPaginationProps> = ({
14
14
  const { theme } = useContext(ApplicationContext);
15
15
  const context = useContext<any>(MiniAppContext);
16
16
 
17
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
17
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
18
18
 
19
19
  const renderDots = () => {
20
20
  const dots: React.ReactElement[] = [];
@@ -13,7 +13,7 @@ const PaginationNumber: FC<ChildPaginationProps> = ({
13
13
  }) => {
14
14
  const context = useContext<any>(MiniAppContext);
15
15
 
16
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
16
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
17
17
 
18
18
  return (
19
19
  <View
@@ -17,7 +17,7 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
17
17
  const [scrollViewWidth, setScrollViewWidth] = useState(0);
18
18
  const [scrollContentWidth, setScrollContentWidth] = useState(0);
19
19
 
20
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
20
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
21
21
 
22
22
  const translateX = () => {
23
23
  if (scrollViewWidth && scrollContentWidth) {
@@ -13,7 +13,7 @@ const PaginationWhiteDot: FC<ChildPaginationProps> = ({
13
13
  }) => {
14
14
  const context = useContext<any>(MiniAppContext);
15
15
 
16
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
16
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
17
17
 
18
18
  const renderDots = () => {
19
19
  const dots: React.ReactElement[] = [];
@@ -32,7 +32,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
32
32
  const { width: widthDevice } = Dimensions.get('window');
33
33
  const scaledMaxHeight = useScaleSize(172);
34
34
 
35
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
35
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
36
36
  const closeAction = useRef('touch_outside');
37
37
  let descriptionStyle = {};
38
38
  let Description: any = View;
@@ -17,7 +17,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
17
17
  const { width: widthDevice } = Dimensions.get('window');
18
18
  const closeAction = useRef('touch_outside');
19
19
 
20
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
20
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
21
21
 
22
22
  /**
23
23
  * on action popup
@@ -92,7 +92,7 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
92
92
 
93
93
  const styles = StyleSheet.create({
94
94
  container: {
95
- aspectRatio: 0.5625, // 9:16
95
+ aspectRatio: 0.72,
96
96
  width: '100%',
97
97
  },
98
98
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
package/Radio/index.tsx CHANGED
@@ -33,7 +33,7 @@ const Radio: FC<RadioProps> = ({
33
33
  accessibilityLabel,
34
34
  );
35
35
 
36
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
36
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
37
37
  let disabledStyle = {};
38
38
  let checkBoxStyle = {
39
39
  borderWidth: 2,
package/Switch/index.tsx CHANGED
@@ -22,7 +22,7 @@ const Switch: FC<SwitchProps> = ({
22
22
 
23
23
  const { componentId } = useComponentId(componentName, accessibilityLabel);
24
24
 
25
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
25
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
26
26
 
27
27
  let backgroundColor = value ? Colors.green_03 : Colors.black_07;
28
28
  if (disabled) {
package/Tag/index.tsx CHANGED
@@ -38,7 +38,7 @@ const Tag: FC<TagProps> = ({
38
38
  const scaledHeight24 = useScaleSize(24);
39
39
  const scaledHeight18 = useScaleSize(18);
40
40
 
41
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
41
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
42
42
 
43
43
  const styles = StyleSheet.create({
44
44
  container: {
package/Text/index.tsx CHANGED
@@ -75,12 +75,6 @@ export interface TextProps extends RNTextProps {
75
75
  * Ex: MomoSignature, MomoTrustDisplay
76
76
  */
77
77
  fontFamily?: string;
78
-
79
- /**
80
- * Optional. Modified max scale rate of scaleSize function in Text component, default is 1.5.
81
- * Ex: 1.5, 2
82
- */
83
- maxScaleRate?: number;
84
78
  }
85
79
 
86
80
  const deprecatedValues: Typography[] = [
@@ -98,11 +92,7 @@ const deprecatedValues: Typography[] = [
98
92
  'action_s',
99
93
  ];
100
94
 
101
- const TypoStyles = (
102
- typo: Typography,
103
- newFontFamily?: string,
104
- maxScaleRate?: number,
105
- ) => {
95
+ const TypoStyles = (typo: Typography, newFontFamily?: string) => {
106
96
  const { theme } = useContext(ApplicationContext);
107
97
  const styleSheet: {
108
98
  [key: string]: any;
@@ -142,8 +132,8 @@ const TypoStyles = (
142
132
  return {
143
133
  ...typoStyle,
144
134
  fontFamily,
145
- fontSize: useScaleSize(fontSize, maxScaleRate),
146
- lineHeight: useScaleSize(lineHeight, maxScaleRate),
135
+ fontSize: useScaleSize(fontSize),
136
+ lineHeight: useScaleSize(lineHeight),
147
137
  fontStyle,
148
138
  fontWeight,
149
139
  };
@@ -155,13 +145,12 @@ const Text: React.FC<TextProps> = ({
155
145
  children,
156
146
  style,
157
147
  fontFamily,
158
- maxScaleRate,
159
148
  ...rest
160
149
  }) => {
161
150
  const { theme } = useContext(ApplicationContext);
162
151
  const context = useContext<any>(MiniAppContext);
163
152
  const skeleton = useContext(SkeletonContext);
164
- const textStyle = TypoStyles(typography, fontFamily, maxScaleRate);
153
+ const textStyle = TypoStyles(typography, fontFamily);
165
154
 
166
155
  if (deprecatedValues.includes(typography)) {
167
156
  console.warn(
@@ -169,7 +158,7 @@ const Text: React.FC<TextProps> = ({
169
158
  );
170
159
  }
171
160
 
172
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
161
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
173
162
 
174
163
  if (skeleton.loading) {
175
164
  return (
package/Text/utils.ts CHANGED
@@ -1,63 +1,39 @@
1
1
  import { Dimensions, PixelRatio, useWindowDimensions } from 'react-native';
2
2
  import { useContext } from 'react';
3
- import { ScaleSizeContext } from '../Context';
3
+ import { MiniAppContext } from '../Context';
4
4
 
5
5
  const deviceWidth = Dimensions.get('window').width;
6
6
  const DEFAULT_SCREEN_SIZE = 375;
7
- const MAX_FONT_SCALE = 1.5;
8
- const MAX_DEVICE_SCALE = 5;
7
+ const MAX_FONT_SCALE = 1.2;
9
8
 
10
- const useScaleSize = (size: number, scaleRate?: number) => {
11
- const scaleSizeContext = useContext<any>(ScaleSizeContext);
12
- const fontScale = PixelRatio.getFontScale();
13
- const windowSize = useWindowDimensions();
14
- const deviceScale = windowSize.width / DEFAULT_SCREEN_SIZE;
15
-
16
- const maxScaleRate =
17
- scaleRate || scaleSizeContext?.scaleSizeMaxRate || MAX_FONT_SCALE;
9
+ const useScaleSize = (size: number) => {
10
+ const { width } = useWindowDimensions();
11
+ const context = useContext<any>(MiniAppContext);
12
+ const allowFontScale = context?.designSystemConfig?.allowFontScale ?? true;
18
13
 
19
- let fontSizeDeviceScale = size;
20
- let fontSizeOSScale = size;
14
+ if (allowFontScale) {
15
+ const deviceScale = width / DEFAULT_SCREEN_SIZE;
16
+ const fontScale = PixelRatio.getFontScale();
21
17
 
22
- if (deviceScale > 1) {
23
- fontSizeDeviceScale = Math.min(
24
- fontSizeDeviceScale * deviceScale,
25
- fontSizeDeviceScale + MAX_DEVICE_SCALE,
26
- );
27
- }
18
+ const maxSize = size * MAX_FONT_SCALE;
19
+ const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
20
+ const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
28
21
 
29
- if (fontScale > 1) {
30
- fontSizeOSScale = Math.min(
31
- fontSizeOSScale * fontScale,
32
- fontSizeOSScale * maxScaleRate,
33
- );
22
+ return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
34
23
  }
35
24
 
36
- return Math.max(fontSizeDeviceScale, fontSizeOSScale);
25
+ return size;
37
26
  };
38
27
 
39
28
  const scaleSize = (size: number) => {
40
- const fontScale = PixelRatio.getFontScale();
41
29
  const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
30
+ const fontScale = PixelRatio.getFontScale();
42
31
 
43
- let fontSizeDeviceScale = size;
44
- let fontSizeOSScale = size;
45
-
46
- if (deviceScale > 1) {
47
- fontSizeDeviceScale = Math.min(
48
- fontSizeDeviceScale * deviceScale,
49
- fontSizeDeviceScale + MAX_DEVICE_SCALE,
50
- );
51
- }
52
-
53
- if (fontScale > 1) {
54
- fontSizeOSScale = Math.min(
55
- fontSizeOSScale * fontScale,
56
- fontSizeOSScale * MAX_FONT_SCALE,
57
- );
58
- }
32
+ const maxSize = size * MAX_FONT_SCALE;
33
+ const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
34
+ const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
59
35
 
60
- return Math.max(fontSizeDeviceScale, fontSizeOSScale);
36
+ return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
61
37
  };
62
38
 
63
39
  export { scaleSize, useScaleSize };
package/Title/index.tsx CHANGED
@@ -39,7 +39,7 @@ const Title: FC<TitleProps> = ({
39
39
  const [badgeWidth, setBadgeWidth] = useState(0);
40
40
  const [contentWidth, setContentWidth] = useState(0);
41
41
 
42
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
42
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
43
43
 
44
44
  const size18 = useScaleSize(18);
45
45
  const size22 = useScaleSize(22);
package/package.json CHANGED
@@ -1,35 +1,35 @@
1
1
  {
2
- "name": "@momo-kits/foundation",
3
- "version": "0.160.1-rn.84",
4
- "description": "React Native Component Kits",
5
- "keywords": [
6
- "@momo-kits/foundation"
7
- ],
8
- "license": "MoMo",
9
- "main": "index.ts",
10
- "publishConfig": {
11
- "registry": "https://registry.npmjs.org/"
12
- },
13
- "scripts": {},
14
- "dependencies": {
15
- "@react-navigation/bottom-tabs": "7.4.2",
16
- "@react-navigation/core": "7.12.1",
17
- "@react-navigation/elements": "2.5.2",
18
- "@react-navigation/native": "7.1.14",
19
- "@react-navigation/routers": "7.4.1",
20
- "@react-navigation/stack": "7.4.2",
21
- "@shopify/flash-list": "2.1.0",
22
- "lottie-react-native": "7.3.4",
23
- "react-native-fast-image": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-fast-image.git#v8.11.0",
24
- "react-native-gesture-handler": "2.31.0",
25
- "react-native-linear-gradient": "git+https://oauth2:TGi6oBj-LdzsKpLXQSoH@gitlab.mservice.com.vn/momo-platform/public/react-native-linear-gradient#v3.0.0",
26
- "react-native-reanimated": "4.2.2",
27
- "react-native-safe-area-context": "5.7.0"
28
- },
29
- "devDependencies": {
30
- "@types/color": "3.0.6"
31
- },
32
- "peerDependencies": {
33
- "react-native": "*"
34
- }
35
- }
2
+ "name": "@momo-kits/foundation",
3
+ "version": "0.161.1-beta.1",
4
+ "description": "React Native Component Kits",
5
+ "main": "index.ts",
6
+ "scripts": {},
7
+ "keywords": [
8
+ "@momo-kits/foundation"
9
+ ],
10
+ "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.0",
21
+ "react-native-safe-area-context": "5.5.2",
22
+ "@shopify/flash-list": "2.1.0",
23
+ "lottie-react-native": "7.2.4"
24
+ },
25
+ "peerDependencies": {
26
+ "react-native": "*"
27
+ },
28
+ "devDependencies": {
29
+ "@types/color": "3.0.6"
30
+ },
31
+ "publishConfig": {
32
+ "registry": "https://registry.npmjs.org/"
33
+ },
34
+ "license": "MoMo"
35
+ }
@@ -1,16 +0,0 @@
1
- import React, { FC } from 'react';
2
- import { ScaleSizeContext } from '../Context';
3
- import { ScaleSizeProviderProps } from './types';
4
-
5
- const ScaleSizeProvider: FC<ScaleSizeProviderProps> = ({
6
- scaleSizeMaxRate,
7
- children,
8
- }) => {
9
- return (
10
- <ScaleSizeContext.Provider value={{ scaleSizeMaxRate }}>
11
- {children}
12
- </ScaleSizeContext.Provider>
13
- );
14
- };
15
-
16
- export default ScaleSizeProvider;