@momo-kits/foundation 0.169.16-beta.1 → 0.169.16-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.
@@ -215,7 +215,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
215
215
  onRequestClose={() => {
216
216
  handleDismiss();
217
217
  }}
218
- style={StyleSheet.absoluteFillObject}
218
+ style={StyleSheet.absoluteFill}
219
219
  isModalKit={true}
220
220
  supportedOrientations={isDuo ? DUO_ORIENTATIONS : undefined}
221
221
  >
@@ -230,7 +230,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
230
230
  style={styles.container}
231
231
  >
232
232
  <Pressable
233
- style={StyleSheet.absoluteFillObject}
233
+ style={StyleSheet.absoluteFill}
234
234
  onPress={() => {
235
235
  action.current = 'touch';
236
236
  handleDismiss();
@@ -68,7 +68,7 @@ export const styles = StyleSheet.create({
68
68
  },
69
69
  // custom label content over the label text, centered and unclipped
70
70
  ctaLabelOverlay: {
71
- ...StyleSheet.absoluteFillObject,
71
+ ...{position: 'absolute', top: 0, bottom: 0, left: 0, right: 0},
72
72
  alignItems: 'center',
73
73
  justifyContent: 'center',
74
74
  },
@@ -57,7 +57,7 @@ export const styles = StyleSheet.create({
57
57
  },
58
58
  // custom label content over the label text, centered and unclipped
59
59
  railCtaLabelOverlay: {
60
- ...StyleSheet.absoluteFillObject,
60
+ ...{position: 'absolute', top: 0, bottom: 0, left: 0, right: 0},
61
61
  alignItems: 'center',
62
62
  justifyContent: 'center',
63
63
  },
@@ -150,7 +150,7 @@ const styles = StyleSheet.create({
150
150
  height: TabBarMetrics.iconSize,
151
151
  },
152
152
  layer: {
153
- ...StyleSheet.absoluteFillObject,
153
+ ...{position: 'absolute', top: 0, bottom: 0, left: 0, right: 0},
154
154
  alignItems: 'center',
155
155
  justifyContent: 'center',
156
156
  },
@@ -161,7 +161,7 @@ const Modal: React.FC<ModalParams> = props => {
161
161
  transparent
162
162
  visible={true}
163
163
  onRequestClose={handleDismiss}
164
- style={StyleSheet.absoluteFillObject}
164
+ style={StyleSheet.absoluteFill}
165
165
  isModalKit={true}
166
166
  supportedOrientations={isDuo ? DUO_ORIENTATIONS : undefined}
167
167
  >
@@ -170,7 +170,7 @@ const Modal: React.FC<ModalParams> = props => {
170
170
  behavior={Platform.OS === 'ios' ? 'padding' : undefined}
171
171
  >
172
172
  <Pressable
173
- style={StyleSheet.absoluteFillObject}
173
+ style={StyleSheet.absoluteFill}
174
174
  onPress={() => handleDismiss(undefined, barrierDismissible)}
175
175
  >
176
176
  <Animated.View style={[styles.overlayContent, scrimStyle]} />
@@ -1,5 +1,4 @@
1
1
  import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
2
- import { InteractionManager } from 'react-native';
3
2
  import { useHeaderHeight } from '@react-navigation/elements';
4
3
  import { ScreenTrackingParams } from './types';
5
4
  import Navigation from './Navigation';
@@ -14,7 +13,12 @@ const TRACKING_TIMEOUT = 5000;
14
13
  const ELEMENT_IDLE_TIMEOUT = 2000;
15
14
  const LOADING_IDLE_TIMEOUT = 2000;
16
15
 
17
- const runAfterInteractions = InteractionManager.runAfterInteractions;
16
+ // RN 0.87+: InteractionManager đã bị xoá khỏi react-native → thay bằng requestIdleCallback.
17
+ // Giữ nguyên shape trả về { cancel } để code bên dưới (timeoutInteraction?.cancel?.()) không đổi.
18
+ const runAfterInteractions = (task: () => void) => {
19
+ const handle = requestIdleCallback(() => task());
20
+ return { cancel: () => cancelIdleCallback(handle) };
21
+ };
18
22
 
19
23
  /**
20
24
  * Hosts a feature screen in the stack: applies its header options, provides
@@ -8,13 +8,13 @@ import React, {
8
8
  useReducer,
9
9
  useRef,
10
10
  } from 'react';
11
- import { StyleSheet, View } from 'react-native';
11
+ import { StyleSheet, View, type ViewInstance } from 'react-native';
12
12
 
13
13
  interface TooltipPortalContextValue {
14
14
  register: (id: string, content: ReactNode) => void;
15
15
  unregister: (id: string, immediate?: boolean) => void;
16
16
  portals: Map<string, ReactNode>;
17
- hostRef: RefObject<View | null>;
17
+ hostRef: RefObject<ViewInstance | null>;
18
18
  }
19
19
 
20
20
  const TooltipPortalContext = createContext<TooltipPortalContextValue | null>(
@@ -30,7 +30,7 @@ export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
30
30
  }) => {
31
31
  // The ref map updates synchronously; the reducer only triggers re-renders.
32
32
  const portalsRef = useRef<Map<string, ReactNode>>(new Map());
33
- const hostRef = useRef<View>(null);
33
+ const hostRef = useRef<ViewInstance>(null);
34
34
  const [updateCounter, forceUpdate] = useReducer((x: number) => x + 1, 0);
35
35
  const pendingUpdateRef = useRef<any>(null);
36
36
 
@@ -54,7 +54,7 @@ const useAppState = () => {
54
54
 
55
55
  useEffect(() => {
56
56
  const subscription = AppState.addEventListener('change', nextAppState => {
57
- const wasInBackground = /inactive|background/.test(appState.current);
57
+ const wasInBackground = /inactive|background/.test(appState.current ?? '');
58
58
  const isReturning = wasInBackground && nextAppState === 'active';
59
59
  isBackgroundToForeground.current = isReturning;
60
60
  appState.current = nextAppState;
package/Button/index.tsx CHANGED
@@ -192,10 +192,10 @@ const Button: FC<ButtonProps> = ({
192
192
 
193
193
  const sizeStyle = getSizeStyle();
194
194
  const typeStyle = getTypeStyle(type, theme, color);
195
- const containerStyle: ViewStyle = StyleSheet.flatten([
195
+ const containerStyle = StyleSheet.flatten([
196
196
  full && { width: '100%' },
197
197
  loading && { opacity: 0.75 },
198
- ]);
198
+ ]) as ViewStyle;
199
199
  const buttonStyle = StyleSheet.flatten([sizeStyle, typeStyle]);
200
200
 
201
201
  const animatedStyle = useAnimatedStyle(() => {
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { StyleSheet, View, ViewStyle } from 'react-native';
2
+ import { StyleProp, StyleSheet, View, ViewStyle } from 'react-native';
3
3
  import { ApplicationContext } from '../Context';
4
4
  import { Spacing } from '../Consts';
5
5
  import Svg, { Line } from 'react-native-svg';
@@ -8,7 +8,7 @@ export interface DashDividerProps {
8
8
  /**
9
9
  * Custom styles for dash divider
10
10
  */
11
- style?: ViewStyle;
11
+ style?: StyleProp<ViewStyle>;
12
12
  }
13
13
 
14
14
  /** 1px dashed horizontal line in the default border color. */
package/Divider/index.tsx CHANGED
@@ -1,5 +1,5 @@
1
1
  import React, { useContext } from 'react';
2
- import { StyleSheet, View, ViewStyle } from 'react-native';
2
+ import { StyleProp, StyleSheet, 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?: ViewStyle;
11
+ style?: StyleProp<ViewStyle>;
12
12
 
13
13
  /**
14
14
  * Enable margin vertical 4px
@@ -34,10 +34,10 @@ const Divider: React.FC<DividerProps> = ({
34
34
  return (
35
35
  <View
36
36
  style={[
37
- style,
38
37
  styles.divider,
39
38
  useMargin ? styles.margin : styles.noMargin,
40
39
  { backgroundColor: theme.colors.border.default },
40
+ style,
41
41
  ]}
42
42
  />
43
43
  );
@@ -10,7 +10,7 @@ type CombinedListProps<ItemT> = FlatListProps<ItemT> &
10
10
  * switch to it without type changes.
11
11
  */
12
12
  const FoundationList = <ItemT,>(props: CombinedListProps<ItemT>) => {
13
- return <FlashList {...props} />;
13
+ return <FlashList {...(props as FlashListProps<ItemT>)} />;
14
14
  };
15
15
 
16
16
  export { FoundationList };
package/Icon/types.ts CHANGED
@@ -1,5 +1,4 @@
1
- import { ImageStyle } from 'react-native-fast-image';
2
- import { StyleProp } from 'react-native';
1
+ import { ImageStyle, StyleProp } from 'react-native';
3
2
 
4
3
  export type IconProps = {
5
4
  /**
package/Image/index.tsx CHANGED
@@ -1,6 +1,11 @@
1
1
  import React, { useContext, useRef, useState } from 'react';
2
- import { StyleSheet, View } from 'react-native';
3
- import FastImage from 'react-native-fast-image';
2
+ import {
3
+ ImageBackground,
4
+ ImageSourcePropType,
5
+ StyleSheet,
6
+ View,
7
+ } from 'react-native';
8
+ import FastImage, { FastImageProps } from 'react-native-fast-image';
4
9
  import styles from './styles';
5
10
  import {
6
11
  ApplicationContext,
@@ -24,6 +29,10 @@ export const getImageName = (source: any): string => {
24
29
  return '';
25
30
  };
26
31
 
32
+ const isDataUriSource = (source: any): boolean => {
33
+ return typeof source?.uri === 'string' && source.uri.startsWith('data:');
34
+ };
35
+
27
36
  /**
28
37
  * FastImage that shows a skeleton while loading (if `loading`) or inside a
29
38
  * loading `SkeletonProvider`, and a fail icon on error.
@@ -48,6 +57,7 @@ const Image: React.FC<ImageProps> = ({
48
57
  const [status, setStatus] = useState<Status>('success');
49
58
 
50
59
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
60
+ const useFastImage = !isDataUriSource(source);
51
61
 
52
62
  const imageName = getImageName(source);
53
63
  let accessibilityLabel: any = `img|${imageName}`;
@@ -81,16 +91,61 @@ const Image: React.FC<ImageProps> = ({
81
91
  return children;
82
92
  };
83
93
 
94
+ if (!useFastImage) {
95
+ // RN <Image> throws when given children (skeleton / fail icon), so use
96
+ // ImageBackground, which renders them on top of the image like FastImage.
97
+ return (
98
+ <ImageBackground
99
+ {...(rest as any)}
100
+ {...{
101
+ accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel,
102
+ }}
103
+ source={source as ImageSourcePropType}
104
+ style={[
105
+ styles.dataUriContainer,
106
+ styles.container,
107
+ style,
108
+ showBaseLineDebug && styles.debugBaseLine,
109
+ ]}
110
+ onLoadStart={() => {
111
+ hasErrorRef.current = false;
112
+ if (status !== 'loading' && loading) {
113
+ setStatus('loading');
114
+ }
115
+ }}
116
+ onLoad={() => {
117
+ hasErrorRef.current = false;
118
+ }}
119
+ onLoadEnd={() => {
120
+ let current: Status = 'success';
121
+ if (hasErrorRef.current) {
122
+ current = 'error';
123
+ }
124
+ setStatus(prevState =>
125
+ prevState !== current ? current : prevState,
126
+ );
127
+ }}
128
+ onError={() => {
129
+ hasErrorRef.current = true;
130
+ }}
131
+ >
132
+ {renderContent()}
133
+ </ImageBackground>
134
+ );
135
+ }
136
+
84
137
  return (
85
138
  <FastImage
86
139
  {...rest}
87
140
  {...{ accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel }}
88
141
  source={source}
89
- style={[
90
- styles.container,
91
- style,
92
- showBaseLineDebug && styles.debugBaseLine,
93
- ]}
142
+ style={
143
+ [
144
+ styles.container,
145
+ style,
146
+ showBaseLineDebug && styles.debugBaseLine,
147
+ ] as FastImageProps['style']
148
+ }
94
149
  onProgress={event => {
95
150
  hasErrorRef.current = false;
96
151
  if (status !== 'loading' && loading) {
package/Image/styles.ts CHANGED
@@ -3,5 +3,7 @@ import { Colors } from '../Consts';
3
3
 
4
4
  export default StyleSheet.create({
5
5
  container: {},
6
+ // same clipping as FastImage's container, so borderRadius rounds the image
7
+ dataUriContainer: { overflow: 'hidden' },
6
8
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
7
9
  });
package/Image/types.ts CHANGED
@@ -1,6 +1,14 @@
1
+ import { ImageStyle, StyleProp } from 'react-native';
1
2
  import { FastImageProps } from 'react-native-fast-image';
2
3
 
3
- export interface ImageProps extends FastImageProps {
4
+ /**
5
+ * `style` uses React Native's own `ImageStyle`: from RN 0.87 (Strict TS API)
6
+ * react-native no longer exports `FlexStyle`/`ShadowStyleIOS`, which
7
+ * react-native-fast-image's `ImageStyle` extends, so that type lost layout
8
+ * props such as `width`, `margin*` or `position`.
9
+ */
10
+ export interface ImageProps extends Omit<FastImageProps, 'style'> {
11
+ style?: StyleProp<ImageStyle>;
4
12
  loading?: boolean;
5
13
  accessibilityLabel?: any;
6
14
  params?: any;
package/Input/Input.tsx CHANGED
@@ -6,10 +6,10 @@ import React, {
6
6
  useState,
7
7
  } from 'react';
8
8
  import {
9
- TextInput,
10
9
  TextInputFocusEvent,
11
10
  TouchableOpacity,
12
11
  View,
12
+ type TextInputInstance,
13
13
  } from 'react-native';
14
14
  import { useComponentId } from '../Application';
15
15
  import { Icon } from '../Icon';
@@ -81,7 +81,7 @@ const Input = forwardRef(
81
81
  const [isFocused, setIsFocused] = useState(false);
82
82
  const [internalText, setInternalText] = useState(defaultValue || '');
83
83
  const hasValue = value !== undefined ? !!value : !!internalText;
84
- const inputRef = useRef<TextInput | null>(null);
84
+ const inputRef = useRef<TextInputInstance | null>(null);
85
85
  const componentName = 'Input';
86
86
 
87
87
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
@@ -7,7 +7,12 @@ import React, {
7
7
  useRef,
8
8
  useState,
9
9
  } from 'react';
10
- import { Platform, TextInput, TextInputFocusEvent, View } from 'react-native';
10
+ import {
11
+ Platform,
12
+ TextInputFocusEvent,
13
+ View,
14
+ type TextInputInstance,
15
+ } from 'react-native';
11
16
  import { useComponentId } from '../Application';
12
17
  import { ComponentContext, MiniAppContext } from '../Context';
13
18
  import { ErrorView } from './ErrorView';
@@ -56,7 +61,7 @@ const InputMoney = forwardRef(
56
61
  const [displayValue, setDisplayValue] = useState('');
57
62
  const [numericValue, setNumericValue] = useState('');
58
63
  const [lastDisplayValue, setLastDisplayValue] = useState('');
59
- const inputRef = useRef<TextInput>(null);
64
+ const inputRef = useRef<TextInputInstance>(null);
60
65
  const caretDigitsAfter = useRef<number | undefined>(undefined);
61
66
  const lastRawText = useRef('');
62
67
  const [caretSelection, setCaretSelection] = useState<{
@@ -2,11 +2,11 @@ import React, { RefObject, useContext } from 'react';
2
2
  import {
3
3
  Pressable,
4
4
  Text,
5
- TextInput,
6
5
  TextInputFocusEvent,
7
6
  TextInputProps,
8
7
  TouchableOpacity,
9
8
  View,
9
+ type TextInputInstance,
10
10
  } from 'react-native';
11
11
  import { ApplicationContext } from '../Context';
12
12
  import { Icon } from '../Icon';
@@ -43,7 +43,7 @@ type InputMoneyViewProps = Pick<
43
43
  componentId: string;
44
44
  displayValue: string;
45
45
  caretSelection?: { start: number; end: number };
46
- inputRef: RefObject<TextInput | null>;
46
+ inputRef: RefObject<TextInputInstance | null>;
47
47
  focusAtEnd: () => void;
48
48
  onClearText: () => void;
49
49
  onChangeText: (text: string) => void;
@@ -9,10 +9,10 @@ import React, {
9
9
  } from 'react';
10
10
  import {
11
11
  PixelRatio,
12
- TextInput,
13
12
  TextInputFocusEvent,
14
13
  TouchableOpacity,
15
14
  View,
15
+ type TextInputInstance,
16
16
  } from 'react-native';
17
17
  import Animated, {
18
18
  cancelAnimation,
@@ -116,7 +116,7 @@ const InputOTP = forwardRef(
116
116
  ) => {
117
117
  const [value, setValue] = useState('');
118
118
  const [isFocused, setIsFocused] = useState(false);
119
- const inputRef = useRef<TextInput | null>(null);
119
+ const inputRef = useRef<TextInputInstance | null>(null);
120
120
  const { theme } = useContext(ApplicationContext);
121
121
  const context = useContext<any>(MiniAppContext);
122
122
 
@@ -7,10 +7,10 @@ import React, {
7
7
  } from 'react';
8
8
  import {
9
9
  StyleSheet,
10
- TextInput,
11
10
  TextInputFocusEvent,
12
11
  TouchableOpacity,
13
12
  View,
13
+ type TextInputInstance,
14
14
  } from 'react-native';
15
15
  import { useComponentId } from '../Application';
16
16
  import {
@@ -76,7 +76,7 @@ const InputPhoneNumber = forwardRef(
76
76
  const [isFocused, setIsFocused] = useState(false);
77
77
  const [internalText, setInternalText] = useState(defaultValue || '');
78
78
  const hasValue = value !== undefined ? !!value : !!internalText;
79
- const inputRef = useRef<TextInput | null>(null);
79
+ const inputRef = useRef<TextInputInstance | null>(null);
80
80
  const componentName = 'InputPhoneNumber';
81
81
 
82
82
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
@@ -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 { useComponentId } from '../Application';
16
16
  import { HeaderBarMetrics } from '../Application/headerLayout';
@@ -76,7 +76,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
76
76
  const [internalText, setInternalText] = useState(defaultValue || '');
77
77
  const currentValue = value !== undefined ? value : internalText;
78
78
  const hasValue = !!currentValue;
79
- const inputRef = useRef<TextInput | null>(null);
79
+ const inputRef = useRef<TextInputInstance | null>(null);
80
80
 
81
81
  const componentName = 'InputSearch';
82
82
 
@@ -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
 
package/Layout/Card.tsx CHANGED
@@ -1,13 +1,12 @@
1
1
  import React, { useContext } from 'react';
2
2
  import { View, ViewProps } from 'react-native';
3
- import { GRID_GUTTER, GRID_MARGIN } from './constants';
4
- import { useGridSystem } from './useGridSystem';
3
+ import { useGridSystem, useScreenLayout } from './utils';
5
4
  import { GridContextProps } from './types';
6
5
  import { GridContext } from './index';
7
6
  import { Image } from '../Image';
8
7
  import { ApplicationContext } from '../Context';
9
8
  import styles from './styles';
10
- import { Radius, Shadow } from '../Consts';
9
+ import { Radius, Shadow, Spacing } from '../Consts';
11
10
 
12
11
  export interface CardProps extends ViewProps {
13
12
  /**
@@ -22,7 +21,7 @@ export interface CardProps extends ViewProps {
22
21
  }
23
22
 
24
23
  /**
25
- * Surface card across the grid width minus 12pt margins, with its own grid for child
24
+ * Surface card across the content width minus 12pt margins, with its own grid for child
26
25
  * Items; optional background image and light shadow.
27
26
  */
28
27
  const Card: React.FC<CardProps> = ({
@@ -33,18 +32,19 @@ const Card: React.FC<CardProps> = ({
33
32
  ...props
34
33
  }) => {
35
34
  const { theme } = useContext(ApplicationContext);
36
- const { numberOfColumns, gridWidth, gridOffset } = useGridSystem();
35
+ const { numberOfColumns } = useGridSystem();
36
+ const { contentWidth } = useScreenLayout();
37
37
 
38
- const gutterSize = GRID_GUTTER;
39
- const margin = GRID_MARGIN;
40
- const widthSection = gridWidth - margin * 2;
38
+ const gutterSize = 8;
39
+ const margin = 12;
40
+ const widthSection = contentWidth - margin * 2;
41
41
  const innerWidth = widthSection - margin * 2;
42
42
  const columnsWidth = innerWidth - gutterSize * (numberOfColumns - 1);
43
43
  const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
44
44
 
45
45
  const gridContext: GridContextProps = {
46
46
  numberOfColumns,
47
- gutterSize: GRID_GUTTER,
47
+ gutterSize: Spacing.S,
48
48
  sizePerSpan,
49
49
  getSizeSpan: span => {
50
50
  return sizePerSpan * span + gutterSize * (span - 1);
@@ -63,7 +63,7 @@ const Card: React.FC<CardProps> = ({
63
63
  styles.card,
64
64
  {
65
65
  width: widthSection,
66
- marginHorizontal: gridOffset + margin,
66
+ marginHorizontal: margin,
67
67
  gap: gutterSize,
68
68
  },
69
69
  !!backgroundImage && { backgroundColor: undefined },
package/Layout/Item.tsx CHANGED
@@ -7,12 +7,12 @@ import { SpanNumber } from './types';
7
7
 
8
8
  export interface ItemProps extends ViewProps {
9
9
  /**
10
- * Width in grid columns (1-36, out of the grid's 12, 24 or 36). Defaults to the full row.
10
+ * Width in grid columns (1-12). Defaults to the full row.
11
11
  */
12
12
  widthSpan?: SpanNumber;
13
13
 
14
14
  /**
15
- * Optional. Height in grid spans (1-36, out of the grid's 12, 24 or 36). Unset keeps the content height.
15
+ * Optional. Height in grid spans (1-12). Unset keeps the content height.
16
16
  */
17
17
  heightSpan?: SpanNumber;
18
18
  }
@@ -1,11 +1,11 @@
1
1
  import React from 'react';
2
2
  import { View, ViewProps } from 'react-native';
3
- import { GRID_GUTTER, GRID_MARGIN } from './constants';
4
- import { useGridSystem } from './useGridSystem';
3
+ import { useGridSystem, useScreenLayout } from './utils';
5
4
  import { GridContextProps } from './types';
6
5
  import { GridContext } from './index';
7
6
  import styles from './styles';
8
7
  import { Image } from '../Image';
8
+ import { Spacing } from '../Consts';
9
9
 
10
10
  export interface SectionProps extends ViewProps {
11
11
  /**
@@ -37,21 +37,22 @@ const Section: React.FC<SectionProps> = ({
37
37
  style,
38
38
  ...props
39
39
  }) => {
40
- const { numberOfColumns, gridWidth, gridOffset } = useGridSystem();
40
+ const { numberOfColumns } = useGridSystem();
41
+ const { contentWidth } = useScreenLayout();
41
42
 
42
- const gutterSize = GRID_GUTTER;
43
+ const gutterSize = 12;
43
44
  let margin = 0;
44
45
  if (useMargin) {
45
- margin = GRID_MARGIN;
46
+ margin = 12;
46
47
  }
47
- const widthSection = gridWidth - margin * 2;
48
+ const widthSection = contentWidth - margin * 2;
48
49
 
49
50
  const columnsWidth = widthSection - gutterSize * (numberOfColumns - 1);
50
51
  const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
51
52
 
52
53
  const gridContext: GridContextProps = {
53
54
  numberOfColumns,
54
- gutterSize: GRID_GUTTER,
55
+ gutterSize: Spacing.M,
55
56
  sizePerSpan,
56
57
  getSizeSpan: span => {
57
58
  return span * sizePerSpan + gutterSize * (span - 1);
@@ -69,7 +70,7 @@ const Section: React.FC<SectionProps> = ({
69
70
  styles.rowWrap,
70
71
  {
71
72
  width: widthSection,
72
- marginHorizontal: gridOffset + margin,
73
+ marginHorizontal: margin,
73
74
  gap: gutterSize,
74
75
  },
75
76
  ]}
package/Layout/types.ts CHANGED
@@ -13,43 +13,7 @@ export type ScreenRef = {
13
13
  */
14
14
  setSearchHeader: (params: SearchHeaderProps) => void;
15
15
  };
16
- export type SpanNumber =
17
- | 1
18
- | 2
19
- | 3
20
- | 4
21
- | 5
22
- | 6
23
- | 7
24
- | 8
25
- | 9
26
- | 10
27
- | 11
28
- | 12
29
- | 13
30
- | 14
31
- | 15
32
- | 16
33
- | 17
34
- | 18
35
- | 19
36
- | 20
37
- | 21
38
- | 22
39
- | 23
40
- | 24
41
- | 25
42
- | 26
43
- | 27
44
- | 28
45
- | 29
46
- | 30
47
- | 31
48
- | 32
49
- | 33
50
- | 34
51
- | 35
52
- | 36;
16
+ export type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
53
17
 
54
18
  export type GridContextProps = {
55
19
  /**
package/Layout/utils.ts CHANGED
@@ -357,6 +357,13 @@ const useSideBarItemStyle = (
357
357
  };
358
358
  };
359
359
 
360
+ /** Column count of the content grid: 24 on content wider than 600pt, otherwise 12. */
361
+ const useGridSystem = () => {
362
+ const { contentWidth } = useScreenLayout();
363
+ const numberOfColumns = contentWidth > 600 ? 24 : 12;
364
+ return { numberOfColumns };
365
+ };
366
+
360
367
  export type { ScreenLayout, SideBarEdge, SideBarLayout, StatusBarClearance };
361
368
 
362
369
  export {
@@ -365,6 +372,7 @@ export {
365
372
  InnerEdgeStyles,
366
373
  getHeaderMargin,
367
374
  getHeaderRowOptions,
375
+ useGridSystem,
368
376
  useScreenLayout,
369
377
  useSideBarItemStyle,
370
378
  validateChildren,
@@ -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/package.json CHANGED
@@ -1,39 +1,41 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.169.16-beta.1",
3
+ "version": "0.169.16-beta.3",
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": {
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",
21
+ "@shopify/flash-list": "2.1.0",
22
+ "lottie-react-native": "7.3.6",
11
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",
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",
24
+ "react-native-gesture-handler": "3.4.0",
19
25
  "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",
24
- "@shopify/flash-list": "2.1.0",
25
- "lottie-react-native": "7.2.4"
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,19 +0,0 @@
1
- const GRID_MARGIN = 12;
2
- const GRID_GUTTER = 12;
3
- const GRID_PHONE_MAX_WIDTH = 600;
4
- const GRID_TABLET_MIN_WIDTH = 800;
5
- const GRID_DESKTOP_MIN_WIDTH = 1100;
6
- const GRID_PHONE_COLUMNS = 12;
7
- const GRID_TABLET_COLUMNS = 24;
8
- const GRID_DESKTOP_COLUMNS = 36;
9
-
10
- export {
11
- GRID_DESKTOP_COLUMNS,
12
- GRID_DESKTOP_MIN_WIDTH,
13
- GRID_GUTTER,
14
- GRID_MARGIN,
15
- GRID_PHONE_COLUMNS,
16
- GRID_PHONE_MAX_WIDTH,
17
- GRID_TABLET_COLUMNS,
18
- GRID_TABLET_MIN_WIDTH,
19
- };
@@ -1,49 +0,0 @@
1
- import {
2
- GRID_DESKTOP_COLUMNS,
3
- GRID_DESKTOP_MIN_WIDTH,
4
- GRID_PHONE_COLUMNS,
5
- GRID_PHONE_MAX_WIDTH,
6
- GRID_TABLET_COLUMNS,
7
- GRID_TABLET_MIN_WIDTH,
8
- } from './constants';
9
- import { useScreenLayout } from './utils';
10
-
11
- /**
12
- * Column count for a content width: 12 below 800pt, 24 below 1100pt, 36 from there
13
- */
14
- const getGridColumns = (width: number) => {
15
- if (width >= GRID_DESKTOP_MIN_WIDTH) {
16
- return GRID_DESKTOP_COLUMNS;
17
- }
18
- if (width >= GRID_TABLET_MIN_WIDTH) {
19
- return GRID_TABLET_COLUMNS;
20
- }
21
- return GRID_PHONE_COLUMNS;
22
- };
23
-
24
- /**
25
- * Grid width for a content width: the 12-column grid stops at 600pt and is centered,
26
- * the wider grids fill the content
27
- */
28
- const getGridWidth = (width: number) => {
29
- if (width < GRID_TABLET_MIN_WIDTH) {
30
- return Math.min(width, GRID_PHONE_MAX_WIDTH);
31
- }
32
- return width;
33
- };
34
-
35
- /**
36
- * Grid for the current content width: column count, grid width and the horizontal
37
- * offset that centers a grid narrower than the content
38
- */
39
- const useGridSystem = () => {
40
- const { contentWidth } = useScreenLayout();
41
- const gridWidth = getGridWidth(contentWidth);
42
- return {
43
- numberOfColumns: getGridColumns(contentWidth),
44
- gridWidth,
45
- gridOffset: (contentWidth - gridWidth) / 2,
46
- };
47
- };
48
-
49
- export { useGridSystem };