@momo-kits/foundation 0.169.16-beta.7 → 0.169.16-beta.8
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/Legacy/TabScreen.tsx +22 -16
- package/Application/BottomTab/Legacy/hooks.ts +1 -1
- package/Application/BottomTab/Legacy/index.tsx +1 -5
- package/Application/BottomTab/TabBarIcon.tsx +1 -1
- package/Application/BottomTab/TabScreen.tsx +22 -12
- package/Application/BottomTab/index.tsx +1 -1
- package/Application/Components/HeaderLeft.tsx +2 -2
- package/Application/Components/SearchHeader.tsx +2 -2
- package/Application/Components/SwipeBackHaptic.tsx +1 -1
- package/Application/Components/useToolkitActions.tsx +64 -34
- package/Application/ModalScreen.tsx +4 -4
- package/Application/NavigationContainer.tsx +10 -11
- package/Application/Navigator.ts +2 -7
- package/Application/StackScreen.tracking.ts +12 -22
- package/Application/StackScreen.tsx +34 -26
- package/Application/TooltipPortal.tsx +3 -3
- package/Application/WidgetContainer.tsx +6 -9
- package/Application/hooks.ts +1 -15
- package/Application/index.ts +0 -4
- package/Application/types.ts +3 -16
- 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 +2 -1
- package/Image/index.tsx +7 -62
- package/Image/styles.ts +0 -2
- package/Image/types.ts +1 -9
- package/Input/Input.tsx +2 -2
- package/Input/InputMoney.tsx +2 -7
- 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 +1 -2
- package/Input/TextTyping.tsx +2 -7
- package/Pagination/types.ts +2 -6
- package/package.json +26 -28
- package/Application/KitsBindingProvider.tsx +0 -22
- package/Application/KitsHost.ts +0 -183
- package/Application/__tests__/KitsHost.test.ts +0 -155
- package/Application/types.binding.ts +0 -134
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useContext, useEffect, useLayoutEffect, useRef } from 'react';
|
|
2
|
+
import { InteractionManager } from 'react-native';
|
|
2
3
|
import { useHeaderHeight } from '@react-navigation/elements';
|
|
3
|
-
import {
|
|
4
|
+
import { ScreenTrackingParams } from './types';
|
|
4
5
|
import Navigation from './Navigation';
|
|
5
6
|
import { ApplicationContext, MiniAppContext, ScreenContext } from '../Context';
|
|
6
7
|
import { SwipeBackHaptic } from './Components/SwipeBackHaptic';
|
|
@@ -13,12 +14,7 @@ const TRACKING_TIMEOUT = 5000;
|
|
|
13
14
|
const ELEMENT_IDLE_TIMEOUT = 2000;
|
|
14
15
|
const LOADING_IDLE_TIMEOUT = 2000;
|
|
15
16
|
|
|
16
|
-
|
|
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
|
-
};
|
|
17
|
+
const runAfterInteractions = InteractionManager.runAfterInteractions;
|
|
22
18
|
|
|
23
19
|
/**
|
|
24
20
|
* Hosts a feature screen in the stack: applies its header options, provides
|
|
@@ -88,9 +84,9 @@ const StackScreen: React.FC<any> = props => {
|
|
|
88
84
|
|
|
89
85
|
useEffect(() => {
|
|
90
86
|
let focusScreen: any;
|
|
91
|
-
let focusAppListener:
|
|
87
|
+
let focusAppListener: { remove?: () => void } | undefined;
|
|
92
88
|
if (['Invalid', 'screen'].includes(screenName)) {
|
|
93
|
-
navigator?.
|
|
89
|
+
navigator?.maxApi?.showPopup?.('notice', {
|
|
94
90
|
title: 'Invalid screen name',
|
|
95
91
|
message:
|
|
96
92
|
'Your screen has not been rendered because Platform has not detected the screen name. Please migrate to support this feature.',
|
|
@@ -101,30 +97,42 @@ const StackScreen: React.FC<any> = props => {
|
|
|
101
97
|
|
|
102
98
|
if (!bottomTab) {
|
|
103
99
|
focusScreen = props.navigation.addListener('focus', () => {
|
|
104
|
-
navigator?.
|
|
100
|
+
navigator?.maxApi?.getDataObserver?.('current_screen', (item: any) => {
|
|
105
101
|
handleScreenNavigated(item?.screenName, screenName);
|
|
106
|
-
navigator?.
|
|
102
|
+
navigator?.maxApi?.setDataObserver?.('current_screen', {
|
|
103
|
+
screenName,
|
|
104
|
+
startTime,
|
|
105
|
+
});
|
|
107
106
|
});
|
|
108
107
|
});
|
|
109
|
-
focusAppListener = navigator?.
|
|
108
|
+
focusAppListener = navigator?.maxApi?.listen?.('onFocusApp', () => {
|
|
110
109
|
if (props.navigation.isFocused()) {
|
|
111
|
-
navigator?.
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
navigator?.maxApi?.getDataObserver?.(
|
|
111
|
+
'current_screen',
|
|
112
|
+
(item: any) => {
|
|
113
|
+
handleScreenNavigated(item?.screenName, screenName);
|
|
114
|
+
navigator?.maxApi?.setDataObserver?.('current_screen', {
|
|
115
|
+
screenName,
|
|
116
|
+
startTime,
|
|
117
|
+
});
|
|
118
|
+
},
|
|
119
|
+
);
|
|
115
120
|
}
|
|
116
121
|
});
|
|
117
122
|
}
|
|
118
123
|
|
|
119
|
-
navigator?.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
+
navigator?.maxApi?.startTraceScreenLoad?.(
|
|
125
|
+
screenName,
|
|
126
|
+
context,
|
|
127
|
+
(item: any) => {
|
|
128
|
+
tracking.current.traceIdLoad = item?.traceId;
|
|
129
|
+
},
|
|
130
|
+
);
|
|
131
|
+
navigator?.maxApi?.startTraceScreenInteraction?.(
|
|
124
132
|
screenName,
|
|
125
133
|
context,
|
|
126
|
-
|
|
127
|
-
tracking.current.traceIdInteraction =
|
|
134
|
+
(item: any) => {
|
|
135
|
+
tracking.current.traceIdInteraction = item?.traceId;
|
|
128
136
|
},
|
|
129
137
|
);
|
|
130
138
|
|
|
@@ -142,13 +150,13 @@ const StackScreen: React.FC<any> = props => {
|
|
|
142
150
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
143
151
|
clearTimeout(tracking.current.timeoutLoading);
|
|
144
152
|
focusScreen?.();
|
|
145
|
-
focusAppListener?.remove();
|
|
153
|
+
focusAppListener?.remove?.();
|
|
146
154
|
};
|
|
147
155
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
148
156
|
}, []);
|
|
149
157
|
|
|
150
158
|
/** Reports a navigation to this screen: `back` if it was shown before. */
|
|
151
|
-
const handleScreenNavigated = (pre: string
|
|
159
|
+
const handleScreenNavigated = (pre: string, current: string) => {
|
|
152
160
|
if (!isBackgroundToForeground) {
|
|
153
161
|
const item: any = {
|
|
154
162
|
preScreenName: pre,
|
|
@@ -165,7 +173,7 @@ const StackScreen: React.FC<any> = props => {
|
|
|
165
173
|
|
|
166
174
|
tracking.current.mounted = true;
|
|
167
175
|
|
|
168
|
-
navigator?.
|
|
176
|
+
navigator?.maxApi?.showToastDebug?.({
|
|
169
177
|
appId: context.appId,
|
|
170
178
|
message: `${screenName} screen_navigated`,
|
|
171
179
|
type: 'ERROR',
|
|
@@ -8,13 +8,13 @@ import React, {
|
|
|
8
8
|
useReducer,
|
|
9
9
|
useRef,
|
|
10
10
|
} from 'react';
|
|
11
|
-
import { StyleSheet, View
|
|
11
|
+
import { StyleSheet, View } 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<View | 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<View>(null);
|
|
34
34
|
const [updateCounter, forceUpdate] = useReducer((x: number) => x + 1, 0);
|
|
35
35
|
const pendingUpdateRef = useRef<any>(null);
|
|
36
36
|
|
|
@@ -15,7 +15,6 @@ import { isWhiteListDesignSystem } from './utils';
|
|
|
15
15
|
import { createStackNavigator } from '@react-navigation/stack';
|
|
16
16
|
import ModalScreen from './ModalScreen';
|
|
17
17
|
import { StyleSheet, View } from 'react-native';
|
|
18
|
-
import { useKitsBinding } from './hooks';
|
|
19
18
|
|
|
20
19
|
const Stack = createStackNavigator();
|
|
21
20
|
|
|
@@ -35,13 +34,12 @@ const WidgetContent: React.FC = ({ route }: any) => {
|
|
|
35
34
|
|
|
36
35
|
/**
|
|
37
36
|
* Root of an embedded widget: its own navigator with the widget screen and the
|
|
38
|
-
* `Modal` route, sized to the widget's content height.
|
|
39
|
-
* inherited from an enclosing container (see `useKitsBinding`).
|
|
37
|
+
* `Modal` route, sized to the widget's content height.
|
|
40
38
|
*/
|
|
41
39
|
const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
42
40
|
widget,
|
|
43
41
|
theme = defaultTheme,
|
|
44
|
-
|
|
42
|
+
maxApi,
|
|
45
43
|
localize = new Localize({ vi: {}, en: {} }),
|
|
46
44
|
}) => {
|
|
47
45
|
const [height, setHeight] = useState<any>(undefined);
|
|
@@ -50,14 +48,13 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
50
48
|
const isReady = useRef(false);
|
|
51
49
|
const navigator = useRef(new Navigator(navigationRef, isReady, true));
|
|
52
50
|
const [currentContext, setCurrentContext] = useState({});
|
|
53
|
-
const resolved = useKitsBinding(binding);
|
|
54
51
|
|
|
55
52
|
useEffect(() => {
|
|
56
|
-
const sub =
|
|
53
|
+
const sub = maxApi?.observer?.('font_scale_config', (data: any) => {
|
|
57
54
|
setCurrentContext((prev: any) => ({ ...prev, fontScale: data }));
|
|
58
55
|
});
|
|
59
|
-
return () => sub
|
|
60
|
-
}, [
|
|
56
|
+
return () => sub?.remove?.();
|
|
57
|
+
}, [maxApi]);
|
|
61
58
|
|
|
62
59
|
let headerBackground = context?.designConfig?.headerBar;
|
|
63
60
|
let headerGradient = theme.colors?.gradient;
|
|
@@ -69,7 +66,7 @@ const WidgetContainer: React.FC<WidgetContainerProps> = ({
|
|
|
69
66
|
headerGradient = context?.designConfig?.headerGradient;
|
|
70
67
|
}
|
|
71
68
|
|
|
72
|
-
navigator.current.
|
|
69
|
+
navigator.current.maxApi = maxApi;
|
|
73
70
|
|
|
74
71
|
/** Text for a localization key, or the current-language side of `{ vi, en }`. */
|
|
75
72
|
const translate = (data?: string | { vi: string; en: string }) => {
|
package/Application/hooks.ts
CHANGED
|
@@ -13,9 +13,6 @@ import {
|
|
|
13
13
|
isRNAnimatedValue,
|
|
14
14
|
isSharedValue,
|
|
15
15
|
} from './utils';
|
|
16
|
-
import { KitsBindingContext } from './KitsBindingProvider';
|
|
17
|
-
import { resolveKitsBinding } from './KitsHost';
|
|
18
|
-
import type { KitsBinding, ResolvedKitsBinding } from './types.binding';
|
|
19
16
|
|
|
20
17
|
const FOREGROUND_FLAG_DURATION = 100;
|
|
21
18
|
|
|
@@ -57,7 +54,7 @@ const useAppState = () => {
|
|
|
57
54
|
|
|
58
55
|
useEffect(() => {
|
|
59
56
|
const subscription = AppState.addEventListener('change', nextAppState => {
|
|
60
|
-
const wasInBackground = /inactive|background/.test(appState.current
|
|
57
|
+
const wasInBackground = /inactive|background/.test(appState.current);
|
|
61
58
|
const isReturning = wasInBackground && nextAppState === 'active';
|
|
62
59
|
isBackgroundToForeground.current = isReturning;
|
|
63
60
|
appState.current = nextAppState;
|
|
@@ -132,19 +129,8 @@ const useNormalizedSharedValue = (
|
|
|
132
129
|
return fallback;
|
|
133
130
|
};
|
|
134
131
|
|
|
135
|
-
/**
|
|
136
|
-
* Binding of a container: its `binding` prop, else the host's hand-off through
|
|
137
|
-
* `KitsBindingProvider`, else `KitsHost`. Never an enclosing container's.
|
|
138
|
-
*/
|
|
139
|
-
const useKitsBinding = (binding?: KitsBinding): ResolvedKitsBinding => {
|
|
140
|
-
const handedOff = useContext(KitsBindingContext);
|
|
141
|
-
const source = binding ?? handedOff;
|
|
142
|
-
return useMemo(() => resolveKitsBinding(source), [source]);
|
|
143
|
-
};
|
|
144
|
-
|
|
145
132
|
export {
|
|
146
133
|
useComponentId,
|
|
147
|
-
useKitsBinding,
|
|
148
134
|
useAppState,
|
|
149
135
|
useNativeCanGoBack,
|
|
150
136
|
useNormalizedSharedValue,
|
package/Application/index.ts
CHANGED
|
@@ -20,8 +20,6 @@ import Navigation from './Navigation';
|
|
|
20
20
|
import Navigator from './Navigator';
|
|
21
21
|
import ScaleSizeProvider from './ScaleSizeProvider';
|
|
22
22
|
import { useTooltipPortal } from './TooltipPortal';
|
|
23
|
-
import { KitsHost } from './KitsHost';
|
|
24
|
-
import { KitsBindingProvider } from './KitsBindingProvider';
|
|
25
23
|
import {
|
|
26
24
|
getModalLayout,
|
|
27
25
|
useModalLayout,
|
|
@@ -53,8 +51,6 @@ export {
|
|
|
53
51
|
HeaderBarMetrics,
|
|
54
52
|
getHeaderLayout,
|
|
55
53
|
useHeaderLayout,
|
|
56
|
-
KitsHost,
|
|
57
|
-
KitsBindingProvider,
|
|
58
54
|
};
|
|
59
55
|
|
|
60
56
|
export type { ModalLayout, ModalRect, HeaderContentLayout, HeaderLayout };
|
package/Application/types.ts
CHANGED
|
@@ -10,12 +10,10 @@ import type {
|
|
|
10
10
|
} from './types.header';
|
|
11
11
|
import type { LocalizeProps, Theme } from './types.theme';
|
|
12
12
|
import type { HeaderContentLayout } from './headerLayout';
|
|
13
|
-
import type { KitsBinding, ResolvedKitsBinding } from './types.binding';
|
|
14
13
|
|
|
15
14
|
export * from './types.theme';
|
|
16
15
|
export * from './types.header';
|
|
17
16
|
export * from './types.tabs';
|
|
18
|
-
export * from './types.binding';
|
|
19
17
|
|
|
20
18
|
export type NavigationProps = {
|
|
21
19
|
context: any;
|
|
@@ -26,8 +24,7 @@ export type NavigatorProps = {
|
|
|
26
24
|
ref?: any;
|
|
27
25
|
isReady?: any;
|
|
28
26
|
isWidget?: any;
|
|
29
|
-
|
|
30
|
-
binding: ResolvedKitsBinding;
|
|
27
|
+
maxApi?: any;
|
|
31
28
|
dismissData?: any;
|
|
32
29
|
push: (params: ScreenParams) => void;
|
|
33
30
|
replace: (params: ScreenParams) => void;
|
|
@@ -62,12 +59,7 @@ export type NavigationContainerProps = {
|
|
|
62
59
|
screen: React.ComponentType<NavigationScreenProps>;
|
|
63
60
|
options?: NavigationOptions;
|
|
64
61
|
theme?: Theme;
|
|
65
|
-
|
|
66
|
-
* Optional. Host services for this mini app; defaults to a host's
|
|
67
|
-
* `KitsBindingProvider`, then `KitsHost`, never an enclosing container's.
|
|
68
|
-
* Keep it stable.
|
|
69
|
-
*/
|
|
70
|
-
binding?: KitsBinding;
|
|
62
|
+
maxApi: any;
|
|
71
63
|
initialParams?: any;
|
|
72
64
|
localize: LocalizeProps;
|
|
73
65
|
features?: FeatureFlags;
|
|
@@ -76,12 +68,7 @@ export type NavigationContainerProps = {
|
|
|
76
68
|
export type WidgetContainerProps = {
|
|
77
69
|
widget: React.ComponentType<any>;
|
|
78
70
|
theme?: Theme;
|
|
79
|
-
|
|
80
|
-
* Optional. Host services for this widget's app; defaults to a host's
|
|
81
|
-
* `KitsBindingProvider`, then `KitsHost`, never an enclosing container's.
|
|
82
|
-
* Keep it stable.
|
|
83
|
-
*/
|
|
84
|
-
binding?: KitsBinding;
|
|
71
|
+
maxApi: any;
|
|
85
72
|
localize: LocalizeProps;
|
|
86
73
|
};
|
|
87
74
|
|
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 = StyleSheet.flatten([
|
|
195
|
+
const containerStyle: ViewStyle = StyleSheet.flatten([
|
|
196
196
|
full && { width: '100%' },
|
|
197
197
|
loading && { opacity: 0.75 },
|
|
198
|
-
])
|
|
198
|
+
]);
|
|
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 {
|
|
2
|
+
import { 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?:
|
|
11
|
+
style?: 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 {
|
|
2
|
+
import { 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?:
|
|
11
|
+
style?: 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,
|
|
37
38
|
styles.divider,
|
|
38
39
|
useMargin ? styles.margin : styles.noMargin,
|
|
39
40
|
{ 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 {...
|
|
13
|
+
return <FlashList {...props} />;
|
|
14
14
|
};
|
|
15
15
|
|
|
16
16
|
export { FoundationList };
|
package/Icon/types.ts
CHANGED
package/Image/index.tsx
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
import React, { useContext, useRef, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
ImageSourcePropType,
|
|
5
|
-
StyleSheet,
|
|
6
|
-
View,
|
|
7
|
-
} from 'react-native';
|
|
8
|
-
import FastImage, { FastImageProps } from 'react-native-fast-image';
|
|
2
|
+
import { StyleSheet, View } from 'react-native';
|
|
3
|
+
import FastImage from 'react-native-fast-image';
|
|
9
4
|
import styles from './styles';
|
|
10
5
|
import {
|
|
11
6
|
ApplicationContext,
|
|
@@ -29,10 +24,6 @@ export const getImageName = (source: any): string => {
|
|
|
29
24
|
return '';
|
|
30
25
|
};
|
|
31
26
|
|
|
32
|
-
const isDataUriSource = (source: any): boolean => {
|
|
33
|
-
return typeof source?.uri === 'string' && source.uri.startsWith('data:');
|
|
34
|
-
};
|
|
35
|
-
|
|
36
27
|
/**
|
|
37
28
|
* FastImage that shows a skeleton while loading (if `loading`) or inside a
|
|
38
29
|
* loading `SkeletonProvider`, and a fail icon on error.
|
|
@@ -57,7 +48,6 @@ const Image: React.FC<ImageProps> = ({
|
|
|
57
48
|
const [status, setStatus] = useState<Status>('success');
|
|
58
49
|
|
|
59
50
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
60
|
-
const useFastImage = !isDataUriSource(source);
|
|
61
51
|
|
|
62
52
|
const imageName = getImageName(source);
|
|
63
53
|
let accessibilityLabel: any = `img|${imageName}`;
|
|
@@ -91,61 +81,16 @@ const Image: React.FC<ImageProps> = ({
|
|
|
91
81
|
return children;
|
|
92
82
|
};
|
|
93
83
|
|
|
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
|
-
|
|
137
84
|
return (
|
|
138
85
|
<FastImage
|
|
139
86
|
{...rest}
|
|
140
87
|
{...{ accessibilityLabel: rest.accessibilityLabel ?? accessibilityLabel }}
|
|
141
88
|
source={source}
|
|
142
|
-
style={
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
] as FastImageProps['style']
|
|
148
|
-
}
|
|
89
|
+
style={[
|
|
90
|
+
styles.container,
|
|
91
|
+
style,
|
|
92
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
93
|
+
]}
|
|
149
94
|
onProgress={event => {
|
|
150
95
|
hasErrorRef.current = false;
|
|
151
96
|
if (status !== 'loading' && loading) {
|
package/Image/styles.ts
CHANGED
|
@@ -3,7 +3,5 @@ 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' },
|
|
8
6
|
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
9
7
|
});
|
package/Image/types.ts
CHANGED
|
@@ -1,14 +1,6 @@
|
|
|
1
|
-
import { ImageStyle, StyleProp } from 'react-native';
|
|
2
1
|
import { FastImageProps } from 'react-native-fast-image';
|
|
3
2
|
|
|
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>;
|
|
3
|
+
export interface ImageProps extends FastImageProps {
|
|
12
4
|
loading?: boolean;
|
|
13
5
|
accessibilityLabel?: any;
|
|
14
6
|
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,
|
|
9
10
|
TextInputFocusEvent,
|
|
10
11
|
TouchableOpacity,
|
|
11
12
|
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<TextInput | null>(null);
|
|
85
85
|
const componentName = 'Input';
|
|
86
86
|
|
|
87
87
|
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
package/Input/InputMoney.tsx
CHANGED
|
@@ -7,12 +7,7 @@ import React, {
|
|
|
7
7
|
useRef,
|
|
8
8
|
useState,
|
|
9
9
|
} from 'react';
|
|
10
|
-
import {
|
|
11
|
-
Platform,
|
|
12
|
-
TextInputFocusEvent,
|
|
13
|
-
View,
|
|
14
|
-
type TextInputInstance,
|
|
15
|
-
} from 'react-native';
|
|
10
|
+
import { Platform, TextInput, TextInputFocusEvent, View } from 'react-native';
|
|
16
11
|
import { useComponentId } from '../Application';
|
|
17
12
|
import { ComponentContext, MiniAppContext } from '../Context';
|
|
18
13
|
import { ErrorView } from './ErrorView';
|
|
@@ -61,7 +56,7 @@ const InputMoney = forwardRef(
|
|
|
61
56
|
const [displayValue, setDisplayValue] = useState('');
|
|
62
57
|
const [numericValue, setNumericValue] = useState('');
|
|
63
58
|
const [lastDisplayValue, setLastDisplayValue] = useState('');
|
|
64
|
-
const inputRef = useRef<
|
|
59
|
+
const inputRef = useRef<TextInput>(null);
|
|
65
60
|
const caretDigitsAfter = useRef<number | undefined>(undefined);
|
|
66
61
|
const lastRawText = useRef('');
|
|
67
62
|
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,
|
|
5
6
|
TextInputFocusEvent,
|
|
6
7
|
TextInputProps,
|
|
7
8
|
TouchableOpacity,
|
|
8
9
|
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<TextInput | 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,
|
|
12
13
|
TextInputFocusEvent,
|
|
13
14
|
TouchableOpacity,
|
|
14
15
|
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<TextInput | 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,
|
|
10
11
|
TextInputFocusEvent,
|
|
11
12
|
TouchableOpacity,
|
|
12
13
|
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<TextInput | 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,
|
|
10
11
|
TextInputFocusEvent,
|
|
11
12
|
TouchableOpacity,
|
|
12
13
|
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<TextInput | null>(null);
|
|
80
80
|
|
|
81
81
|
const componentName = 'InputSearch';
|
|
82
82
|
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -7,10 +7,10 @@ import React, {
|
|
|
7
7
|
useState,
|
|
8
8
|
} from 'react';
|
|
9
9
|
import {
|
|
10
|
+
TextInput,
|
|
10
11
|
TextInputFocusEvent,
|
|
11
12
|
TouchableOpacity,
|
|
12
13
|
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<
|
|
73
|
+
const inputRef = useRef<TextInput | null>(null);
|
|
74
74
|
|
|
75
75
|
useEffect(() => {
|
|
76
76
|
setInputValue(value ?? '');
|