@momo-kits/foundation 0.169.17-beta.1 → 0.169.17-beta.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Application/BottomSheet.tsx +2 -2
- package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
- package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
- package/Application/BottomTab/TabBarIcon.tsx +1 -1
- package/Application/BottomTab/index.tsx +1 -15
- package/Application/Components/HeaderExtendHeader.tsx +1 -3
- package/Application/Components/HeaderRight.tsx +3 -24
- package/Application/Components/SearchHeader.tsx +2 -3
- package/Application/ModalScreen.tsx +2 -2
- package/Application/StackScreen.tsx +6 -2
- package/Application/TooltipPortal.tsx +3 -3
- package/Application/headerLayout.ts +3 -7
- package/Application/hooks.ts +1 -1
- package/Application/types.tabs.ts +0 -8
- package/Button/index.tsx +2 -2
- package/Divider/DashDivider.tsx +2 -2
- package/Divider/index.tsx +3 -3
- package/FoundationList/index.tsx +1 -1
- package/Icon/types.ts +1 -2
- package/Image/index.tsx +70 -7
- package/Image/styles.ts +2 -0
- package/Image/types.ts +9 -1
- package/Input/Input.tsx +2 -2
- package/Input/InputMoney.tsx +7 -2
- package/Input/InputMoneyView.tsx +2 -2
- package/Input/InputOTP.tsx +2 -2
- package/Input/InputPhoneNumber.tsx +2 -2
- package/Input/InputSearch.tsx +2 -2
- package/Input/InputTextArea.tsx +2 -2
- package/Input/SearchTextTyping.tsx +2 -2
- package/Input/SystemTextInput.tsx +2 -1
- package/Input/TextTyping.tsx +7 -2
- package/Layout/screenHeader.tsx +41 -56
- package/Pagination/types.ts +6 -2
- package/Text/utils.ts +4 -30
- package/package.json +28 -26
- package/Application/BottomTab/Legacy/BottomTabBar.styles.ts +0 -60
- package/Application/BottomTab/Legacy/BottomTabBar.tsx +0 -270
- package/Application/BottomTab/Legacy/CustomBottomTabItem.tsx +0 -153
- package/Application/BottomTab/Legacy/DuoBarCompression.tsx +0 -135
- package/Application/BottomTab/Legacy/DuoRailTabBar.tsx +0 -149
- package/Application/BottomTab/Legacy/DuoTabBar.parts.tsx +0 -202
- package/Application/BottomTab/Legacy/DuoTabBar.styles.ts +0 -123
- package/Application/BottomTab/Legacy/DuoTabBar.tsx +0 -151
- package/Application/BottomTab/Legacy/TabBarIcon.tsx +0 -113
- package/Application/BottomTab/Legacy/TabScreen.tsx +0 -177
- package/Application/BottomTab/Legacy/badge.ts +0 -41
- package/Application/BottomTab/Legacy/hooks.ts +0 -358
- package/Application/BottomTab/Legacy/index.styles.ts +0 -30
- package/Application/BottomTab/Legacy/index.tsx +0 -230
- package/Application/Components/useHeaderRightWidth.ts +0 -46
|
@@ -215,7 +215,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
|
|
|
215
215
|
onRequestClose={() => {
|
|
216
216
|
handleDismiss();
|
|
217
217
|
}}
|
|
218
|
-
style={StyleSheet.
|
|
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.
|
|
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.
|
|
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.
|
|
60
|
+
...StyleSheet.absoluteFill,
|
|
61
61
|
alignItems: 'center',
|
|
62
62
|
justifyContent: 'center',
|
|
63
63
|
},
|
|
@@ -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
|
|
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
|
|
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, {
|
|
2
|
-
import {
|
|
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}
|
|
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
|
|
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 =
|
|
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.
|
|
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.
|
|
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
|
-
|
|
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<
|
|
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<
|
|
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
|
|
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
|
-
|
|
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 (
|
|
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
|
package/Application/hooks.ts
CHANGED
|
@@ -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;
|
|
@@ -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
|
|
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(() => {
|
package/Divider/DashDivider.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 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
|
);
|
package/FoundationList/index.tsx
CHANGED
|
@@ -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
package/Image/index.tsx
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import React, { useContext, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
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
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
-
|
|
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<
|
|
84
|
+
const inputRef = useRef<TextInputInstance | null>(null);
|
|
85
85
|
const componentName = 'Input';
|
|
86
86
|
|
|
87
87
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -7,7 +7,12 @@ import React, {
|
|
|
7
7
|
useRef,
|
|
8
8
|
useState,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import {
|
|
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<
|
|
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<{
|
package/Input/InputMoneyView.tsx
CHANGED
|
@@ -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<
|
|
46
|
+
inputRef: RefObject<TextInputInstance | null>;
|
|
47
47
|
focusAtEnd: () => void;
|
|
48
48
|
onClearText: () => void;
|
|
49
49
|
onChangeText: (text: string) => void;
|
package/Input/InputOTP.tsx
CHANGED
|
@@ -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<
|
|
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<
|
|
79
|
+
const inputRef = useRef<TextInputInstance | null>(null);
|
|
80
80
|
const componentName = 'InputPhoneNumber';
|
|
81
81
|
|
|
82
82
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
package/Input/InputSearch.tsx
CHANGED
|
@@ -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<
|
|
79
|
+
const inputRef = useRef<TextInputInstance | null>(null);
|
|
80
80
|
|
|
81
81
|
const componentName = 'InputSearch';
|
|
82
82
|
|