@momo-kits/foundation 0.161.2-beta.1 → 0.161.2-beta.5

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 (42) 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/Components/HeaderBackground.tsx +1 -1
  5. package/Application/Components/HeaderExtendHeader.tsx +1 -1
  6. package/Application/Components/HeaderTitle.tsx +1 -1
  7. package/Application/Components/SearchHeader.tsx +1 -1
  8. package/Application/NavigationContainer.tsx +25 -21
  9. package/Application/WidgetContainer.tsx +18 -7
  10. package/Application/index.ts +0 -2
  11. package/Application/types.ts +0 -6
  12. package/Badge/Badge.tsx +9 -3
  13. package/Badge/BadgeDot.tsx +1 -1
  14. package/Badge/BadgeRibbon.tsx +1 -1
  15. package/Button/index.tsx +2 -2
  16. package/CheckBox/index.tsx +1 -1
  17. package/Context/index.ts +0 -4
  18. package/Icon/index.tsx +1 -1
  19. package/IconButton/index.tsx +1 -1
  20. package/Image/index.tsx +1 -1
  21. package/Input/Input.tsx +1 -1
  22. package/Input/InputDropDown.tsx +1 -1
  23. package/Input/InputMoney.tsx +1 -1
  24. package/Input/InputOTP.tsx +1 -1
  25. package/Input/InputPhoneNumber.tsx +1 -1
  26. package/Input/InputSearch.tsx +1 -1
  27. package/Input/InputTextArea.tsx +1 -1
  28. package/Layout/Item.tsx +1 -1
  29. package/Pagination/PaginationDot.tsx +1 -1
  30. package/Pagination/PaginationNumber.tsx +1 -1
  31. package/Pagination/PaginationScroll.tsx +1 -1
  32. package/Pagination/PaginationWhiteDot.tsx +1 -1
  33. package/Popup/PopupNotify.tsx +1 -1
  34. package/Popup/PopupPromotion.tsx +1 -1
  35. package/Radio/index.tsx +1 -1
  36. package/Switch/index.tsx +1 -1
  37. package/Tag/index.tsx +1 -1
  38. package/Text/index.tsx +1 -1
  39. package/Text/utils.ts +18 -41
  40. package/Title/index.tsx +1 -1
  41. package/package.json +1 -1
  42. 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,
@@ -72,7 +72,7 @@ export default function BottomTabBar({
72
72
  const focusedTab = state?.routes[state.index]?.name || routes[0]?.params;
73
73
 
74
74
  const context = useContext<any>(MiniAppContext);
75
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
75
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
76
76
 
77
77
  /**
78
78
  * 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) {
@@ -22,7 +22,7 @@ const HeaderBackground: React.FC<HeaderBackgroundProps> = ({
22
22
  const fallback = useSharedValue(0);
23
23
  const sv = animatedValue ?? fallback;
24
24
 
25
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
25
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
26
26
 
27
27
  return (
28
28
  <View style={[Styles.flex, showBaseLineDebug && styles.debugBaseLine]}>
@@ -57,7 +57,7 @@ const HeaderExtendHeader: React.FC<{
57
57
  useShadowHeader = false;
58
58
  }
59
59
 
60
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
60
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
61
61
 
62
62
  const heightStyle = useAnimatedStyle(() => ({
63
63
  height: interpolate(
@@ -41,7 +41,7 @@ type HeaderTitleExtraProps = {
41
41
  const HeaderTitle: React.FC<HeaderTitleExtraProps & { [key: string]: any }> = props => {
42
42
  const context = useContext<any>(MiniAppContext);
43
43
 
44
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
44
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
45
45
 
46
46
  const interpolateConfig = props.interpolate ?? {
47
47
  inputRange: [0, 200],
@@ -70,7 +70,7 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
70
70
  return true;
71
71
  };
72
72
 
73
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
73
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
74
74
 
75
75
  return (
76
76
  <View
@@ -16,7 +16,6 @@ import { DeviceEventEmitter } from 'react-native';
16
16
  import StackScreen from './StackScreen';
17
17
  import ModalScreen from './ModalScreen';
18
18
  import Navigator from './Navigator';
19
- import ScaleSizeProvider from './ScaleSizeProvider';
20
19
  import { getModalOptions, getStackOptions } from './utils';
21
20
  import { NavigationContainerProps } from './types';
22
21
  import { ApplicationContext, MiniAppContext } from '../Context';
@@ -36,39 +35,44 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
36
35
  maxApi,
37
36
  initialParams,
38
37
  localize = new Localize({ vi: {}, en: {} }),
39
- features = {
40
- enableBottomTabAnimation: true,
41
- enableHapticDialog: true,
42
- enableForceFoundationList: false,
43
- enableHapticBottomTab: true,
44
- },
45
38
  }) => {
46
39
  const context = useContext<any>(MiniAppContext);
47
40
  const [currentContext, setCurrentContext] = useState<any>({});
41
+ const [allowFontScale, setAllowFontScale] = useState<boolean>(
42
+ context?.designSystemConfig?.allowFontScale ?? true,
43
+ );
44
+
45
+ useEffect(() => {
46
+ const sub = maxApi?.observer?.('use_font_scale', (value: boolean) => {
47
+ setAllowFontScale(value ?? true);
48
+ });
49
+
50
+ return () => {
51
+ sub?.remove?.();
52
+ };
53
+ }, []);
48
54
 
49
55
  const mergedContext = {
50
56
  ...context,
51
57
  ...currentContext,
52
- features: {
53
- ...context?.features,
54
- ...features,
58
+ designSystemConfig: {
59
+ ...context?.designSystemConfig,
60
+ allowFontScale,
55
61
  },
56
62
  };
57
63
 
58
64
  return (
59
65
  <SafeAreaProvider>
60
66
  <MiniAppContext.Provider value={mergedContext}>
61
- <ScaleSizeProvider scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}>
62
- <Navigation
63
- screen={screen}
64
- theme={theme}
65
- options={options}
66
- maxApi={maxApi}
67
- setCurrentContext={setCurrentContext}
68
- initialParams={initialParams}
69
- localize={localize}
70
- />
71
- </ScaleSizeProvider>
67
+ <Navigation
68
+ screen={screen}
69
+ theme={theme}
70
+ options={options}
71
+ maxApi={maxApi}
72
+ setCurrentContext={setCurrentContext}
73
+ initialParams={initialParams}
74
+ localize={localize}
75
+ />
72
76
  </MiniAppContext.Provider>
73
77
  </SafeAreaProvider>
74
78
  );
@@ -1,7 +1,6 @@
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
- import ScaleSizeProvider from './ScaleSizeProvider';
5
4
  import { WidgetContainerProps } from './types';
6
5
  import { ApplicationContext, MiniAppContext } from '../Context';
7
6
  import Localize from './Localize';
@@ -43,7 +42,19 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
43
42
  const isReady = useRef(false);
44
43
  const navigator = useRef(new Navigator(navigationRef, isReady, true));
45
44
  const [currentContext, setCurrentContext] = useState({});
45
+ const [allowFontScale, setAllowFontScale] = useState<boolean>(
46
+ context?.designSystemConfig?.allowFontScale ?? true,
47
+ );
48
+
49
+ useEffect(() => {
50
+ const sub = maxApi?.observer?.('use_font_scale', (value: boolean) => {
51
+ setAllowFontScale(value ?? true);
52
+ });
46
53
 
54
+ return () => {
55
+ sub?.remove?.();
56
+ };
57
+ }, []);
47
58
  let headerBackground = context?.designConfig?.headerBar;
48
59
  let headerGradient = theme.colors?.gradient;
49
60
 
@@ -71,15 +82,16 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
71
82
  const mergedContext = {
72
83
  ...context,
73
84
  ...currentContext,
85
+ designSystemConfig: {
86
+ ...context?.designSystemConfig,
87
+ allowFontScale,
88
+ },
74
89
  };
75
90
 
76
91
  return (
77
- <View style={{ height: height ?? '100%', minHeight:1 }}>
92
+ <View style={{ height: height ?? '100%', minHeight: 1 }}>
78
93
  <SafeAreaProvider>
79
94
  <MiniAppContext.Provider value={mergedContext}>
80
- <ScaleSizeProvider
81
- scaleSizeMaxRate={mergedContext?.scaleSizeMaxRate}
82
- >
83
95
  <ApplicationContext.Provider
84
96
  value={{
85
97
  navigator: navigator.current,
@@ -157,7 +169,6 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
157
169
  </ReactNavigationContainer>
158
170
  </NavigationIndependentTree>
159
171
  </ApplicationContext.Provider>
160
- </ScaleSizeProvider>
161
172
  </MiniAppContext.Provider>
162
173
  </SafeAreaProvider>
163
174
  </View>
@@ -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/Button/index.tsx CHANGED
@@ -74,7 +74,7 @@ const Button: FC<ButtonProps> = ({
74
74
  const animationRef = useRef<LottieView>(null);
75
75
  const pressAnim = useSharedValue(0);
76
76
 
77
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
77
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
78
78
 
79
79
  const componentName = 'Button';
80
80
  const { componentId } = useComponentId(
@@ -352,7 +352,7 @@ const Button: FC<ButtonProps> = ({
352
352
  onPressOut={animateOut}
353
353
  >
354
354
  <Reanimated.View style={[buttonStyle, animatedStyle]}>
355
- {renderIcon('left')}
355
+ {renderIcon('left')}
356
356
  {renderTitle()}
357
357
  {renderIcon('right')}
358
358
  {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/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
@@ -42,7 +42,7 @@ const Image: React.FC<ImageProps> = ({
42
42
  const error = useRef(false);
43
43
  const [status, setStatus] = useState<Status>('success');
44
44
 
45
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
45
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
46
46
 
47
47
  let accessibilityLabel: any = `img|${getImageName(source)}`;
48
48
  if (component?.componentId) {
package/Input/Input.tsx CHANGED
@@ -81,7 +81,7 @@ const Input = forwardRef(
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}`,
@@ -43,7 +43,7 @@ const InputDropDown = ({
43
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}`,
@@ -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}`,
@@ -114,7 +114,7 @@ const InputOTP = forwardRef(
114
114
 
115
115
  const componentName = 'InputOTP';
116
116
 
117
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
117
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
118
118
 
119
119
  const { componentId } = useComponentId(
120
120
  `${componentName}/${placeholder}`,
@@ -73,7 +73,7 @@ const InputPhoneNumber = forwardRef(
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}`,
@@ -146,7 +146,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
146
146
  const context = useContext<any>(MiniAppContext);
147
147
  const scaledFontSize = useScaleSize(14);
148
148
 
149
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
149
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
150
150
 
151
151
  const [focused, setFocused] = useState(false);
152
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/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
@@ -24,7 +24,7 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
24
24
  const [scrollViewWidth, setScrollViewWidth] = useState(0);
25
25
  const [scrollContentWidth, setScrollContentWidth] = useState(0);
26
26
 
27
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
27
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
28
28
 
29
29
  const onScroll = useAnimatedScrollHandler({
30
30
  onScroll: (event) => {
@@ -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
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
@@ -158,7 +158,7 @@ const Text: React.FC<TextProps> = ({
158
158
  );
159
159
  }
160
160
 
161
- const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
161
+ const showBaseLineDebug = context?.designSystemConfig?.isBaselineEnabled;
162
162
 
163
163
  if (skeleton.loading) {
164
164
  return (
package/Text/utils.ts CHANGED
@@ -1,62 +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.3;
9
8
 
10
- const useScaleSize = (size: number, scaleRate?: number) => {
11
- const { scaleSizeMaxRate = MAX_FONT_SCALE } = useContext(ScaleSizeContext);
12
- const fontScale = PixelRatio.getFontScale();
9
+ const useScaleSize = (size: number) => {
13
10
  const { width } = useWindowDimensions();
14
- const deviceScale = width / DEFAULT_SCREEN_SIZE;
15
-
16
- const maxScaleRate = scaleRate ?? scaleSizeMaxRate;
11
+ const context = useContext<any>(MiniAppContext);
12
+ const allowFontScale = context?.designSystemConfig?.allowFontScale ?? true;
17
13
 
18
- let fontSizeDeviceScale = size;
19
- let fontSizeOSScale = size;
14
+ if (allowFontScale) {
15
+ const deviceScale = width / DEFAULT_SCREEN_SIZE;
16
+ const fontScale = PixelRatio.getFontScale();
20
17
 
21
- if (deviceScale > 1) {
22
- fontSizeDeviceScale = Math.min(
23
- fontSizeDeviceScale * deviceScale,
24
- fontSizeDeviceScale + MAX_DEVICE_SCALE,
25
- );
26
- }
18
+ const maxSize = size * MAX_FONT_SCALE;
19
+ const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
20
+ const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
27
21
 
28
- if (fontScale > 1) {
29
- fontSizeOSScale = Math.min(
30
- fontSizeOSScale * fontScale,
31
- fontSizeOSScale * maxScaleRate,
32
- );
22
+ return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
33
23
  }
34
24
 
35
- return Math.max(fontSizeDeviceScale, fontSizeOSScale);
25
+ return size;
36
26
  };
37
27
 
38
28
  const scaleSize = (size: number) => {
39
- const fontScale = PixelRatio.getFontScale();
40
29
  const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
30
+ const fontScale = PixelRatio.getFontScale();
41
31
 
42
- let fontSizeDeviceScale = size;
43
- let fontSizeOSScale = size;
44
-
45
- if (deviceScale > 1) {
46
- fontSizeDeviceScale = Math.min(
47
- fontSizeDeviceScale * deviceScale,
48
- fontSizeDeviceScale + MAX_DEVICE_SCALE,
49
- );
50
- }
51
-
52
- if (fontScale > 1) {
53
- fontSizeOSScale = Math.min(
54
- fontSizeOSScale * fontScale,
55
- fontSizeOSScale * MAX_FONT_SCALE,
56
- );
57
- }
32
+ const maxSize = size * MAX_FONT_SCALE;
33
+ const fontSizeScaleDevice = deviceScale > 1 ? deviceScale * size : size;
34
+ const fontSizeScaleOS = fontScale > 1 ? fontScale * size : size;
58
35
 
59
- return Math.max(fontSizeDeviceScale, fontSizeOSScale);
36
+ return Math.min(Math.max(fontSizeScaleDevice, fontSizeScaleOS), maxSize);
60
37
  };
61
38
 
62
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.161.2-beta.1",
3
+ "version": "0.161.2-beta.5",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
@@ -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;