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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (60) hide show
  1. package/Application/BottomSheet.tsx +2 -2
  2. package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
  3. package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
  4. package/Application/BottomTab/TabBarIcon.tsx +1 -1
  5. package/Application/BottomTab/index.tsx +1 -15
  6. package/Application/Components/HeaderExtendHeader.tsx +1 -3
  7. package/Application/Components/HeaderRight.tsx +3 -24
  8. package/Application/Components/SearchHeader.tsx +2 -3
  9. package/Application/ModalScreen.tsx +2 -2
  10. package/Application/StackScreen.tsx +6 -2
  11. package/Application/TooltipPortal.tsx +3 -3
  12. package/Application/headerLayout.ts +3 -7
  13. package/Application/hooks.ts +1 -1
  14. package/Application/modalLayout.ts +4 -12
  15. package/Application/types.tabs.ts +0 -8
  16. package/Button/index.tsx +2 -2
  17. package/Divider/DashDivider.tsx +2 -2
  18. package/Divider/index.tsx +3 -3
  19. package/FoundationList/index.tsx +1 -1
  20. package/Icon/types.ts +1 -2
  21. package/Image/index.tsx +70 -7
  22. package/Image/styles.ts +2 -0
  23. package/Image/types.ts +9 -1
  24. package/Input/Input.tsx +2 -2
  25. package/Input/InputMoney.tsx +7 -2
  26. package/Input/InputMoneyView.tsx +2 -2
  27. package/Input/InputOTP.tsx +2 -2
  28. package/Input/InputPhoneNumber.tsx +40 -22
  29. package/Input/InputSearch.tsx +2 -2
  30. package/Input/InputTextArea.tsx +2 -2
  31. package/Input/SearchTextTyping.tsx +2 -2
  32. package/Input/SystemTextInput.tsx +2 -1
  33. package/Input/TextTyping.tsx +7 -2
  34. package/Input/index.tsx +1 -14
  35. package/Layout/Screen.tsx +5 -11
  36. package/Layout/Section.tsx +3 -14
  37. package/Layout/screenFooter.tsx +21 -181
  38. package/Layout/screenHeader.tsx +41 -56
  39. package/Layout/screenTypes.ts +1 -16
  40. package/Layout/styles.ts +0 -10
  41. package/Layout/types.ts +0 -6
  42. package/Pagination/types.ts +6 -2
  43. package/package.json +28 -26
  44. package/Application/BottomTab/Legacy/BottomTabBar.styles.ts +0 -60
  45. package/Application/BottomTab/Legacy/BottomTabBar.tsx +0 -270
  46. package/Application/BottomTab/Legacy/CustomBottomTabItem.tsx +0 -153
  47. package/Application/BottomTab/Legacy/DuoBarCompression.tsx +0 -135
  48. package/Application/BottomTab/Legacy/DuoRailTabBar.tsx +0 -149
  49. package/Application/BottomTab/Legacy/DuoTabBar.parts.tsx +0 -202
  50. package/Application/BottomTab/Legacy/DuoTabBar.styles.ts +0 -123
  51. package/Application/BottomTab/Legacy/DuoTabBar.tsx +0 -151
  52. package/Application/BottomTab/Legacy/TabBarIcon.tsx +0 -113
  53. package/Application/BottomTab/Legacy/TabScreen.tsx +0 -177
  54. package/Application/BottomTab/Legacy/badge.ts +0 -41
  55. package/Application/BottomTab/Legacy/hooks.ts +0 -358
  56. package/Application/BottomTab/Legacy/index.styles.ts +0 -30
  57. package/Application/BottomTab/Legacy/index.tsx +0 -230
  58. package/Application/Components/useHeaderRightWidth.ts +0 -46
  59. package/Input/CountryCodeView.tsx +0 -93
  60. package/Layout/__tests__/screenFooter.test.ts +0 -56
@@ -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
+ ...StyleSheet.absoluteFill,
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
+ ...StyleSheet.absoluteFill,
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
+ ...StyleSheet.absoluteFill,
154
154
  alignItems: 'center',
155
155
  justifyContent: 'center',
156
156
  },
@@ -21,7 +21,6 @@ import { getTabBadge } from './TabBarIcon';
21
21
  import { DuoTabBar, useDuoTabBarInset } from './DuoTabBar';
22
22
  import { BottomTabInsetContext } from './BottomTabInset';
23
23
  import { DuoBarCompressionProvider } from './DuoBarCompression';
24
- import LegacyBottomTab from './Legacy';
25
24
  import TabScreen from './TabScreen';
26
25
  import { ApplicationContext } from '../../Context';
27
26
  import { useScreenLayout } from '../../Layout';
@@ -59,7 +58,7 @@ const getTabSlide = (width: number): SceneInterpolator => {
59
58
  * App tab navigator: the floating bar on phones, the rail or floating bar on
60
59
  * iPhone Duo, tabs sliding in index order. Shares the bar inset with its tabs.
61
60
  */
62
- const FloatingBottomTab: React.FC<BottomTabProps> = ({
61
+ const BottomTab: React.FC<BottomTabProps> = ({
63
62
  nested,
64
63
  tabs,
65
64
  listeners,
@@ -191,17 +190,4 @@ const FloatingBottomTab: React.FC<BottomTabProps> = ({
191
190
  );
192
191
  };
193
192
 
194
- /**
195
- * App tab navigator. `useLegacy` renders the pre-redesign docked bar on phones;
196
- * iPhone Duo always uses the current rail or floating bar.
197
- */
198
- const BottomTab: React.FC<BottomTabProps> = props => {
199
- const { isIPhoneDuo } = useScreenLayout();
200
- // legacy unless told otherwise: the redesigned bar is not rolled out yet
201
- if ((props.useLegacy ?? true) && !isIPhoneDuo) {
202
- return <LegacyBottomTab {...props} />;
203
- }
204
- return <FloatingBottomTab {...props} />;
205
- };
206
-
207
193
  export default BottomTab;
@@ -23,7 +23,6 @@ import {
23
23
  type HeaderContentLayout,
24
24
  useHeaderLayout,
25
25
  } from '../headerLayout';
26
- import { useHeaderRightWidth } from './useHeaderRightWidth';
27
26
 
28
27
  const { buttonSize, pillWidth, sidePadding, titleGap } = HeaderBarMetrics;
29
28
  const SCREEN_PADDING = sidePadding;
@@ -70,8 +69,7 @@ const HeaderExtendHeader: React.FC<{
70
69
  const backLeft = buttonSize + sidePadding + titleGap;
71
70
  const defaultLeft = layout.sideBar ? SCREEN_PADDING : backLeft;
72
71
  const leftPosition = inputSearchProps?.leftPosition || defaultLeft;
73
- const measuredRightWidth = useHeaderRightWidth() ?? TOOLKIT_WIDTH;
74
- const defaultRightWidth = layout.sideBar ? 0 : measuredRightWidth;
72
+ const defaultRightWidth = layout.sideBar ? 0 : TOOLKIT_WIDTH;
75
73
  const headerRightWidth = customHeaderRightWidth ?? defaultRightWidth;
76
74
  const contentLeft = layout.insetLeft + SCREEN_PADDING + frameShift;
77
75
  const contentRight = layout.insetLeft + layout.contentWidth - frameShift;
@@ -1,6 +1,5 @@
1
- import React, { useCallback, useContext, useEffect } from 'react';
2
- import { type LayoutChangeEvent, TouchableOpacity, View } from 'react-native';
3
- import { NavigationRouteContext } from '@react-navigation/native';
1
+ import React, { useContext } from 'react';
2
+ import { TouchableOpacity, View } from 'react-native';
4
3
  import { ApplicationContext } from '../../Context';
5
4
  import { Text } from '../../Text';
6
5
  import Animated from 'react-native-reanimated';
@@ -8,12 +7,10 @@ import { useSideBarItemStyle } from '../../Layout/utils';
8
7
  import { useSideBarCounterStyle } from './DuoQuickReturnHeader';
9
8
  import { HeaderToolkitAction } from './HeaderToolkitAction';
10
9
  import { styles } from './HeaderRight.styles';
11
- import { setHeaderRightWidth } from './useHeaderRightWidth';
12
10
 
13
11
  /**
14
12
  * Header right slot: a custom `headerRight` render function, the onboarding skip
15
13
  * button, or the toolkit (stacked vertically in the floating iPhone Duo side bar).
16
- * The bar toolkit reports its width so header searches stop short of it.
17
14
  */
18
15
  const HeaderRight: React.FC<any> = props => {
19
16
  const { translate } = useContext(ApplicationContext);
@@ -21,24 +18,6 @@ const HeaderRight: React.FC<any> = props => {
21
18
  const { useOnBoarding = false, buttonOnBoarding, onPress } = headerRight;
22
19
  const sideBarStyle = useSideBarItemStyle('right', 1);
23
20
  const counterStyle = useSideBarCounterStyle();
24
- const routeKey = useContext(NavigationRouteContext)?.key;
25
-
26
- const handleToolkitLayout = useCallback(
27
- (event: LayoutChangeEvent) => {
28
- if (routeKey) {
29
- setHeaderRightWidth(routeKey, event.nativeEvent.layout.width);
30
- }
31
- },
32
- [routeKey],
33
- );
34
-
35
- useEffect(() => {
36
- return () => {
37
- if (routeKey) {
38
- setHeaderRightWidth(routeKey, undefined);
39
- }
40
- };
41
- }, [routeKey]);
42
21
 
43
22
  if (typeof props.headerRight === 'function') {
44
23
  return props.headerRight(props);
@@ -70,7 +49,7 @@ const HeaderRight: React.FC<any> = props => {
70
49
  }
71
50
 
72
51
  return (
73
- <View style={styles.headerRightButton} onLayout={handleToolkitLayout}>
52
+ <View style={styles.headerRightButton}>
74
53
  <HeaderToolkitAction {...props.headerRight} tintColor={props.tintColor} />
75
54
  </View>
76
55
  );
@@ -9,10 +9,9 @@ import { Text } from '../../Text';
9
9
  import { useNormalizedSharedValue } from '../hooks';
10
10
  import { useScreenLayout } from '../../Layout';
11
11
  import { HeaderBarMetrics } from '../headerLayout';
12
- import { useHeaderRightWidth } from './useHeaderRightWidth';
13
12
 
14
13
  const { buttonSize, pillWidth, sidePadding, titleGap } = HeaderBarMetrics;
15
- // help center | home pill and the bar padding right of it, until the toolkit lays out
14
+ // help center | home pill and the bar padding right of it
16
15
  const TOOLKIT_WIDTH = pillWidth + sidePadding;
17
16
  // the iPhone Duo side bar keeps its right header width
18
17
  const DUO_TOOLKIT_WIDTH = 73;
@@ -35,7 +34,7 @@ const SearchHeader = React.forwardRef<InputRef, SearchHeaderProps>(
35
34
  const { theme, navigator } = useContext(ApplicationContext);
36
35
  const context = useContext<any>(MiniAppContext);
37
36
  const layout = useScreenLayout();
38
- let defaultRightWidth = useHeaderRightWidth() ?? TOOLKIT_WIDTH;
37
+ let defaultRightWidth = TOOLKIT_WIDTH;
39
38
  let searchSize: InputSearchProps['size'] = 'header';
40
39
  if (layout.sideBar) {
41
40
  defaultRightWidth = DUO_TOOLKIT_WIDTH;
@@ -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
 
@@ -8,8 +8,6 @@ import { isIPhoneDuo } from './utils';
8
8
 
9
9
  // Top navigation spec, shared with the Compose / SwiftUI kits
10
10
  const HEADER_FRAME_MAX_WIDTH = 600;
11
- // stretch frame on hold until design confirms it: `stretch` lays out like `grid`
12
- const IS_STRETCH_FRAME_ENABLED = false;
13
11
 
14
12
  /**
15
13
  * Top navigation geometry on every device
@@ -37,8 +35,7 @@ const HeaderBarMetrics = {
37
35
 
38
36
  /**
39
37
  * `grid` keeps the header row at the bar edges, `stretch` centers it in a 600pt
40
- * frame on wide windows (on hold: same as `grid` for now). Background and status
41
- * bar always span the window.
38
+ * frame on wide windows. Background and status bar always span the window.
42
39
  */
43
40
  type HeaderContentLayout = 'grid' | 'stretch';
44
41
 
@@ -84,8 +81,7 @@ const getHeaderLayout = ({
84
81
  const isLargeWindow = Math.min(width, height) >= FOLDABLE_MIN_WIDTH;
85
82
  const isWide = !isDuo && isLargeWindow;
86
83
  let frameInset = sidePadding;
87
- const isStretch = IS_STRETCH_FRAME_ENABLED && contentLayout === 'stretch';
88
- if (isWide && isStretch) {
84
+ if (isWide && contentLayout === 'stretch') {
89
85
  const centered = (width - HEADER_FRAME_MAX_WIDTH) / 2;
90
86
  frameInset = Math.max(sidePadding, centered);
91
87
  }
@@ -138,7 +134,7 @@ const useHeaderFrameOptions = (
138
134
  const { width } = useWindowDimensions();
139
135
  const isDuo = isIPhoneDuo();
140
136
  return useMemo(() => {
141
- if (!IS_STRETCH_FRAME_ENABLED || contentLayout !== 'stretch' || isDuo) {
137
+ if (contentLayout !== 'stretch' || isDuo) {
142
138
  return undefined;
143
139
  }
144
140
  // the header content row already sits this far in on large iOS windows
@@ -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;
@@ -78,14 +78,6 @@ const clamp = (value: number, min: number, max: number) => {
78
78
  return Math.min(Math.max(value, min), max);
79
79
  };
80
80
 
81
- /**
82
- * True when the window's short side reaches a foldable inner display (Galaxy Z Fold,
83
- * Pixel Fold, iPhone Duo inner); short side, so a phone in landscape stays a phone.
84
- */
85
- const isFoldableWindow = (width: number, height: number) => {
86
- return Math.min(width, height) >= FOLDABLE_MIN_WIDTH;
87
- };
88
-
89
81
  /**
90
82
  * Modal geometry for a window, pure so it can be tested without a device.
91
83
  */
@@ -96,9 +88,10 @@ const getModalLayout = ({
96
88
  isDuo,
97
89
  hinge,
98
90
  }: ModalLayoutInput): ModalLayout => {
99
- const isWideWindow = isFoldableWindow(width, height);
100
- const isFoldable = isDuo || isWideWindow;
101
- const isDuoOuter = isDuo && !isWideWindow;
91
+ const shortSide = Math.min(width, height);
92
+ // short side, so a phone in landscape stays a phone
93
+ const isFoldable = isDuo || shortSide >= FOLDABLE_MIN_WIDTH;
94
+ const isDuoOuter = isDuo && shortSide < FOLDABLE_MIN_WIDTH;
102
95
  const hingeRight = hinge ? hinge.x + hinge.width : 0;
103
96
  const hasHinge = !!hinge && hinge.x > 0;
104
97
  const isHingeInWindow = hingeRight < width - insets.right;
@@ -173,7 +166,6 @@ const useModalLayout = (): ModalLayout => {
173
166
 
174
167
  export {
175
168
  getModalLayout,
176
- isFoldableWindow,
177
169
  useModalLayout,
178
170
  POPUP_MAX_WIDTH,
179
171
  POPUP_MIN_WIDTH,
@@ -33,17 +33,9 @@ export type BottomTabProps = {
33
33
  * tapping the compressed one swaps them. Defaults to 'toolbar'
34
34
  */
35
35
  compressionBehavior?: 'toolbar' | 'tabBar';
36
- /**
37
- * Renders the pre-redesign docked phone bar instead of the floating one. Ignores
38
- * `showDot`, `floatingButton.labelContent` and `compressionBehavior`; not on iPhone Duo.
39
- * Defaults to true until the redesign rolls out; pass false for the floating bar.
40
- */
41
- useLegacy?: boolean;
42
36
  };
43
37
 
44
38
  export type FloatingButtonProps = {
45
- /** Legacy bar only (`useLegacy`): custom background drawn behind the bar, e.g. a curved cutout */
46
- container?: React.ReactNode;
47
39
  icon: string | React.ReactNode;
48
40
  label: string;
49
41
  onPress: () => void;
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,69 @@ const Image: React.FC<ImageProps> = ({
81
91
  return children;
82
92
  };
83
93
 
94
+ if (!useFastImage) {
95
+ // Data-URI sources bypass FastImage (added in 05cfa7ad5 for RN 0.84;
96
+ // TODO: confirm the reason, then drop this branch if FastImage is fine).
97
+ // RN <Image> throws when given children (skeleton / fail icon), so use
98
+ // ImageBackground, which renders them on top of the image like FastImage.
99
+ return (
100
+ <ImageBackground
101
+ {...(rest as any)}
102
+ {...{
103
+ accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel,
104
+ }}
105
+ source={source as ImageSourcePropType}
106
+ style={[
107
+ styles.dataUriContainer,
108
+ styles.container,
109
+ style,
110
+ showBaseLineDebug && styles.debugBaseLine,
111
+ ]}
112
+ onLoadStart={() => {
113
+ hasErrorRef.current = false;
114
+ if (status !== 'loading' && loading) {
115
+ setStatus('loading');
116
+ }
117
+ onLoadStart?.();
118
+ }}
119
+ onLoad={event => {
120
+ hasErrorRef.current = false;
121
+ // map RN ImageLoadEvent to FastImage's OnLoadEvent shape
122
+ const { width, height } = event.nativeEvent.source;
123
+ onLoad?.({ nativeEvent: { width, height } } as any);
124
+ }}
125
+ onLoadEnd={() => {
126
+ let current: Status = 'success';
127
+ if (hasErrorRef.current) {
128
+ current = 'error';
129
+ }
130
+ setStatus(prevState =>
131
+ prevState !== current ? current : prevState,
132
+ );
133
+ onLoadEnd?.();
134
+ }}
135
+ onError={() => {
136
+ hasErrorRef.current = true;
137
+ onError?.();
138
+ }}
139
+ >
140
+ {renderContent()}
141
+ </ImageBackground>
142
+ );
143
+ }
144
+
84
145
  return (
85
146
  <FastImage
86
147
  {...rest}
87
148
  {...{ accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel }}
88
149
  source={source}
89
- style={[
90
- styles.container,
91
- style,
92
- showBaseLineDebug && styles.debugBaseLine,
93
- ]}
150
+ style={
151
+ [
152
+ styles.container,
153
+ style,
154
+ showBaseLineDebug && styles.debugBaseLine,
155
+ ] as FastImageProps['style']
156
+ }
94
157
  onProgress={event => {
95
158
  hasErrorRef.current = false;
96
159
  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