@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
@@ -1,123 +0,0 @@
1
- import { StyleSheet } from 'react-native';
2
- import { Colors, Spacing } from '../../../Consts';
3
- import { DuoMetrics } from '../../../Layout/utils';
4
-
5
- export const ITEM_SIZE = DuoMetrics.controlSize;
6
- export const ICON_SIZE = 28;
7
- export const QR_ICON_SIZE = 24;
8
- export const RAIL_PADDING = 6;
9
- export const RAIL_GAP = Spacing.XXS;
10
- export const RAIL_PITCH = ITEM_SIZE + RAIL_GAP;
11
- // selection bubble overflows the 48 rail cell by 5 above and below (Figma MT2)
12
- export const RAIL_BUBBLE_WIDTH = 44;
13
- export const RAIL_BUBBLE_HEIGHT = 58;
14
- export const FLOATING_HEIGHT = DuoMetrics.floatingTabBarHeight;
15
- export const FLOATING_PADDING = Spacing.XS;
16
- // the system bar sizes its pill to the tabs instead of stretching it across the display
17
- export const FLOATING_ITEM_WIDTH = 80;
18
- export const FLOATING_BUBBLE_RADIUS =
19
- (FLOATING_HEIGHT - 2 * FLOATING_PADDING) / 2;
20
-
21
- /**
22
- * distance from the screen bottom to the floating tab bar, overlapping the home
23
- * indicator inset like the system tab bar
24
- */
25
- export const getFloatingTabBarBottom = (bottomInset: number) =>
26
- Math.max(bottomInset - DuoMetrics.floatingTabBarInsetOverlap, Spacing.S);
27
-
28
- export const styles = StyleSheet.create({
29
- barMaterial: {
30
- borderWidth: 1,
31
- },
32
- icon: {
33
- width: ICON_SIZE,
34
- height: ICON_SIZE,
35
- },
36
- railColumn: {
37
- position: 'absolute',
38
- gap: Spacing.M,
39
- },
40
- railColumnRight: {
41
- alignItems: 'flex-start',
42
- paddingLeft: Spacing.M,
43
- },
44
- railColumnLeft: {
45
- alignItems: 'flex-end',
46
- paddingRight: Spacing.M,
47
- },
48
- railCompact: {
49
- width: ITEM_SIZE,
50
- height: ITEM_SIZE,
51
- borderRadius: ITEM_SIZE / 2,
52
- alignItems: 'center',
53
- justifyContent: 'center',
54
- },
55
- rail: {
56
- width: ITEM_SIZE,
57
- paddingVertical: RAIL_PADDING,
58
- gap: RAIL_GAP,
59
- },
60
- railBubble: {
61
- position: 'absolute',
62
- top: RAIL_PADDING - (RAIL_BUBBLE_HEIGHT - ITEM_SIZE) / 2,
63
- left: (ITEM_SIZE - RAIL_BUBBLE_WIDTH) / 2,
64
- width: RAIL_BUBBLE_WIDTH,
65
- height: RAIL_BUBBLE_HEIGHT,
66
- },
67
- railItem: {
68
- width: ITEM_SIZE,
69
- height: ITEM_SIZE,
70
- alignItems: 'center',
71
- justifyContent: 'center',
72
- },
73
- railQr: {
74
- width: ITEM_SIZE,
75
- height: ITEM_SIZE,
76
- borderRadius: ITEM_SIZE / 2,
77
- alignItems: 'center',
78
- justifyContent: 'center',
79
- },
80
- floating: {
81
- position: 'absolute',
82
- flexDirection: 'row',
83
- justifyContent: 'center',
84
- gap: Spacing.S,
85
- },
86
- floatingBar: {
87
- flexShrink: 1,
88
- height: FLOATING_HEIGHT,
89
- padding: FLOATING_PADDING,
90
- },
91
- floatingRow: {
92
- flex: 1,
93
- flexDirection: 'row',
94
- },
95
- floatingBubble: {
96
- position: 'absolute',
97
- top: 0,
98
- bottom: 0,
99
- left: 0,
100
- },
101
- floatingItem: {
102
- flex: 1,
103
- alignItems: 'center',
104
- justifyContent: 'center',
105
- },
106
- itemLayer: {
107
- alignItems: 'center',
108
- justifyContent: 'center',
109
- gap: Spacing.XXS,
110
- },
111
- // pink fills the whole pinned platter
112
- floatingQr: {
113
- width: FLOATING_HEIGHT,
114
- height: FLOATING_HEIGHT,
115
- borderRadius: FLOATING_HEIGHT / 2,
116
- alignItems: 'center',
117
- justifyContent: 'center',
118
- shadowColor: Colors.black_20,
119
- shadowOffset: { width: 0, height: 6 },
120
- shadowOpacity: 0.16,
121
- shadowRadius: 16,
122
- },
123
- });
@@ -1,151 +0,0 @@
1
- import React, { useContext, useMemo, useState } from 'react';
2
- import { LayoutChangeEvent, TouchableOpacity, View } from 'react-native';
3
- import { GestureDetector } from 'react-native-gesture-handler';
4
- import Animated from 'react-native-reanimated';
5
- import { ApplicationContext } from '../../../Context';
6
- import { DuoMetrics, useScreenLayout } from '../../../Layout/utils';
7
- import { useLiquidSelection } from './hooks';
8
- import { DuoRailTabBar } from './DuoRailTabBar';
9
- import {
10
- BarMaterial,
11
- getTabItems,
12
- LiquidTabItem,
13
- Props,
14
- QrIcon,
15
- SelectionMaterial,
16
- TabLabel,
17
- } from './DuoTabBar.parts';
18
- import {
19
- FLOATING_BUBBLE_RADIUS,
20
- FLOATING_HEIGHT,
21
- FLOATING_ITEM_WIDTH,
22
- FLOATING_PADDING,
23
- getFloatingTabBarBottom,
24
- QR_ICON_SIZE,
25
- styles,
26
- } from './DuoTabBar.styles';
27
-
28
- /**
29
- * space tab content leaves under the Duo floating tab bar, 0 elsewhere
30
- */
31
- const useDuoTabBarInset = () => {
32
- const { isIPhoneDuo, sideBar, insets } = useScreenLayout();
33
- if (!isIPhoneDuo || sideBar) {
34
- return 0;
35
- }
36
- return FLOATING_HEIGHT + getFloatingTabBarBottom(insets.bottom);
37
- };
38
-
39
- /**
40
- * floating labelled bar for the unfolded portrait display, QR pinned in its own
41
- * platter on the trailing side
42
- */
43
- const DuoFloatingTabBar: React.FC<Props> = props => {
44
- const { theme } = useContext(ApplicationContext);
45
- const { insets } = useScreenLayout();
46
- const { state, floatingButton, activeTintColor, inactiveTintColor } = props;
47
- const items = getTabItems(props);
48
- const [rowWidth, setRowWidth] = useState(0);
49
- const cellWidth = rowWidth / state.routes.length;
50
-
51
- const selection = useLiquidSelection({
52
- count: items.length,
53
- pitch: cellWidth,
54
- firstCenter: cellWidth / 2,
55
- axis: 'x',
56
- index: state.index,
57
- onSelect: itemIndex => items[itemIndex]?.onPress(),
58
- });
59
- const { barStyle, bubbleStyle } = selection;
60
- const tabCount = state.routes.length;
61
- // stable style arrays, see Rail
62
- const floatingBarStyle = useMemo(
63
- () => [
64
- styles.floatingBar,
65
- { width: tabCount * FLOATING_ITEM_WIDTH + 2 * FLOATING_PADDING },
66
- barStyle,
67
- ],
68
- [tabCount, barStyle],
69
- );
70
- const floatingBubbleStyle = useMemo(
71
- () => [styles.floatingBubble, { width: cellWidth }, bubbleStyle],
72
- [cellWidth, bubbleStyle],
73
- );
74
-
75
- const onRowLayout = (e: LayoutChangeEvent) =>
76
- setRowWidth(e.nativeEvent.layout.width);
77
-
78
- return (
79
- <View
80
- pointerEvents={'box-none'}
81
- style={[
82
- styles.floating,
83
- {
84
- left: insets.left + DuoMetrics.floatingTabBarMargin,
85
- right: insets.right + DuoMetrics.floatingTabBarMargin,
86
- bottom: getFloatingTabBarBottom(insets.bottom),
87
- },
88
- ]}
89
- >
90
- <Animated.View
91
- style={floatingBarStyle}
92
- accessibilityLabel={'bottom_tab_bar'}
93
- >
94
- <BarMaterial radius={FLOATING_HEIGHT / 2} />
95
- <GestureDetector gesture={selection.gesture}>
96
- <View style={styles.floatingRow} onLayout={onRowLayout}>
97
- {rowWidth > 0 && (
98
- <Animated.View pointerEvents={'none'} style={floatingBubbleStyle}>
99
- <SelectionMaterial radius={FLOATING_BUBBLE_RADIUS} />
100
- </Animated.View>
101
- )}
102
- {items.map((item, index) => (
103
- <LiquidTabItem
104
- key={item.route.key}
105
- item={item}
106
- itemIndex={index}
107
- selection={selection}
108
- onSelect={item.onPress}
109
- renderContent={active => (
110
- <>
111
- {item.renderIcon(active)}
112
- <TabLabel
113
- label={item.label}
114
- typography={'label_xs_medium'}
115
- color={active ? activeTintColor : inactiveTintColor}
116
- />
117
- </>
118
- )}
119
- style={styles.floatingItem}
120
- />
121
- ))}
122
- </View>
123
- </GestureDetector>
124
- </Animated.View>
125
- {floatingButton && (
126
- <TouchableOpacity
127
- accessibilityRole={'button'}
128
- accessibilityLabel={floatingButton.label}
129
- onPress={floatingButton.onPress}
130
- style={[styles.floatingQr, { backgroundColor: theme.colors.primary }]}
131
- >
132
- <QrIcon icon={floatingButton.icon} size={QR_ICON_SIZE} />
133
- </TouchableOpacity>
134
- )}
135
- </View>
136
- );
137
- };
138
-
139
- /**
140
- * iPhone Duo tab bar: rail in the side bar, or a floating bar when unfolded portrait
141
- */
142
- const DuoTabBar: React.FC<Props> = props => {
143
- const { sideBar } = useScreenLayout();
144
- return sideBar ? (
145
- <DuoRailTabBar {...props} />
146
- ) : (
147
- <DuoFloatingTabBar {...props} />
148
- );
149
- };
150
-
151
- export { DuoTabBar, useDuoTabBarInset };
@@ -1,113 +0,0 @@
1
- import type { Route } from '@react-navigation/native';
2
- import React from 'react';
3
- import {
4
- type StyleProp,
5
- StyleSheet,
6
- type TextStyle,
7
- View,
8
- type ViewStyle,
9
- } from 'react-native';
10
-
11
- import { Colors } from '../../../Consts';
12
- import { Badge, BadgeDot } from '../../../Badge';
13
-
14
- type Props = {
15
- route: Route<string>;
16
- badge?: string | number;
17
- badgeStyle?: StyleProp<TextStyle> | any;
18
- activeOpacity: number;
19
- inactiveOpacity: number;
20
- activeTintColor?: string;
21
- inactiveTintColor?: string;
22
- renderIcon: (props: {
23
- focused: boolean;
24
- color: string;
25
- size: number;
26
- }) => React.ReactNode;
27
- allowFontScaling?: boolean;
28
- style: StyleProp<ViewStyle>;
29
- };
30
-
31
- /**
32
- * Icon sizes taken from Apple HIG
33
- * https://developer.apple.com/design/human-interface-guidelines/tab-bars
34
- */
35
- const ICON_SIZE_WIDE = 35;
36
-
37
- export function TabBarIcon({
38
- route: _,
39
- badge,
40
- badgeStyle,
41
- activeOpacity,
42
- inactiveOpacity,
43
- activeTintColor,
44
- inactiveTintColor,
45
- renderIcon,
46
- style,
47
- }: Props) {
48
- const iconSize = 25;
49
-
50
- const renderBadge = () => {
51
- if (badge == null) {
52
- return;
53
- }
54
- if (badge === '') {
55
- return <BadgeDot size={'small'} style={[styles.badge, badgeStyle]} />;
56
- }
57
- return <Badge style={[styles.badge, badgeStyle]} label={badge} />;
58
- };
59
-
60
- // We render the icon twice at the same position on top of each other:
61
- // active and inactive one, so we can fade between them.
62
- return (
63
- <View style={[styles.wrapperUikit, style]}>
64
- <View
65
- style={[
66
- styles.icon,
67
- {
68
- opacity: activeOpacity,
69
- // Workaround for react-native >= 0.54 layout bug
70
- minWidth: iconSize,
71
- },
72
- ]}
73
- >
74
- {renderIcon({
75
- focused: true,
76
- size: iconSize,
77
- color: activeTintColor ?? Colors.black_20,
78
- })}
79
- </View>
80
- <View style={[styles.icon, { opacity: inactiveOpacity }]}>
81
- {renderIcon({
82
- focused: false,
83
- size: iconSize,
84
- color: inactiveTintColor ?? Colors.black_04,
85
- })}
86
- </View>
87
- {renderBadge()}
88
- </View>
89
- );
90
- }
91
-
92
- const styles = StyleSheet.create({
93
- icon: {
94
- // We render the icon twice at the same position on top of each other:
95
- // active and inactive one, so we can fade between them:
96
- // Cover the whole iconContainer:
97
- position: 'absolute',
98
- alignSelf: 'center',
99
- alignItems: 'center',
100
- justifyContent: 'center',
101
- height: '100%',
102
- width: '100%',
103
- },
104
- wrapperUikit: {
105
- width: ICON_SIZE_WIDE,
106
- height: ICON_SIZE_WIDE,
107
- },
108
- badge: {
109
- position: 'absolute',
110
- end: -3,
111
- top: -3,
112
- },
113
- });
@@ -1,177 +0,0 @@
1
- import {
2
- NavigationContainer,
3
- NavigationIndependentTree,
4
- useFocusEffect,
5
- } from '@react-navigation/native';
6
- import { createStackNavigator } from '@react-navigation/stack';
7
- import React, { useContext, useEffect } from 'react';
8
- import Animated, {
9
- useAnimatedStyle,
10
- useSharedValue,
11
- withTiming,
12
- } from 'react-native-reanimated';
13
- import StackScreen from '../../StackScreen';
14
- import { getOptions, getStackOptions } from '../../navigationOptions';
15
- import { useAppState } from '../../hooks';
16
- import { ApplicationContext, MiniAppContext } from '../../../Context';
17
- import { useScreenLayout } from '../../../Layout';
18
- import { getHeaderRowOptions } from '../../../Layout/utils';
19
- import { styles } from './index.styles';
20
-
21
- const Stack = createStackNavigator();
22
-
23
- const TabScreen: React.FC<any> = ({ route, navigation }) => {
24
- const { navigator } = useContext(ApplicationContext);
25
- const context = useContext<any>(MiniAppContext);
26
- const { nested, options, screen, initialParams } = route?.params;
27
- const headerStyleOptions = getHeaderRowOptions(useScreenLayout());
28
-
29
- const opacityValue = 0.3;
30
- const scaleValue = 0.97;
31
- const opacity = useSharedValue(opacityValue);
32
- const scale = useSharedValue(scaleValue);
33
- const screenName = screen?.name || screen?.type?.name || 'Invalid';
34
- const { isBackgroundToForeground } = useAppState();
35
-
36
- const tabAnimatedStyle = useAnimatedStyle(() => ({
37
- opacity: opacity.value,
38
- transform: [{ scale: scale.value }],
39
- }));
40
-
41
- const onScreenNavigated = (pre: string, current: string) => {
42
- if (!isBackgroundToForeground) {
43
- const data: any = {
44
- preScreenName: pre,
45
- screenName: current,
46
- componentName: 'Screen',
47
- state: 'navigated',
48
- action: 'push',
49
- };
50
-
51
- context?.autoTracking?.({
52
- ...context,
53
- ...data,
54
- });
55
-
56
- /**
57
- * debug toast
58
- */
59
- navigator?.maxApi?.showToastDebug?.({
60
- appId: context.appId,
61
- message: `${screenName} screen_navigated`,
62
- type: 'ERROR',
63
- });
64
- }
65
- };
66
-
67
- useFocusEffect(
68
- React.useCallback(
69
- () => {
70
- opacity.value = withTiming(1, { duration: 200 });
71
- scale.value = withTiming(1, { duration: 200 });
72
-
73
- setTimeout(() => {
74
- navigator?.maxApi?.getDataObserver?.(
75
- 'current_screen',
76
- (data: any) => {
77
- onScreenNavigated(data?.screenName, screenName);
78
- navigator?.maxApi?.setObserver?.('current_screen', {
79
- screenName,
80
- });
81
- },
82
- );
83
- }, 100);
84
-
85
- return () => {
86
- if (navigation.getState().index !== route?.params.index) {
87
- opacity.value = withTiming(opacityValue, { duration: 200 });
88
- scale.value = withTiming(scaleValue, { duration: 200 });
89
- }
90
- };
91
- },
92
- // eslint-disable-next-line react-hooks/exhaustive-deps
93
- [],
94
- ),
95
- );
96
-
97
- useEffect(
98
- () => {
99
- const onFocusApp = navigator?.maxApi?.listen?.('onFocusApp', () => {
100
- if (navigation.isFocused()) {
101
- navigator?.maxApi?.getDataObserver?.(
102
- 'current_screen',
103
- (data: any) => {
104
- onScreenNavigated(data?.screenName, screenName);
105
- navigator?.maxApi?.setObserver?.('current_screen', {
106
- screenName,
107
- });
108
- },
109
- );
110
- }
111
- });
112
-
113
- return () => {
114
- onFocusApp?.remove?.();
115
- };
116
- },
117
- // eslint-disable-next-line react-hooks/exhaustive-deps
118
- [],
119
- );
120
-
121
- let stackOptions = {};
122
- if (options) {
123
- stackOptions = getOptions(options);
124
- }
125
-
126
- if (nested) {
127
- return (
128
- <Animated.View style={[styles.container, tabAnimatedStyle]}>
129
- <Stack.Navigator screenOptions={headerStyleOptions}>
130
- <Stack.Screen
131
- name="Stack"
132
- component={StackScreen}
133
- initialParams={{
134
- screen,
135
- options: stackOptions,
136
- initialParams,
137
- bottomTab: 'nested',
138
- }}
139
- options={{ ...getStackOptions() }}
140
- />
141
- </Stack.Navigator>
142
- </Animated.View>
143
- );
144
- }
145
-
146
- return (
147
- <Animated.View
148
- style={[
149
- styles.container,
150
- {
151
- opacity,
152
- transform: [{ scale }],
153
- },
154
- ]}
155
- >
156
- <NavigationIndependentTree>
157
- <NavigationContainer>
158
- <Stack.Navigator screenOptions={headerStyleOptions}>
159
- <Stack.Screen
160
- name="Stack"
161
- component={StackScreen}
162
- initialParams={{
163
- screen,
164
- options: stackOptions,
165
- initialParams,
166
- bottomTab: 'default',
167
- }}
168
- options={{ ...getStackOptions(), ...options }}
169
- />
170
- </Stack.Navigator>
171
- </NavigationContainer>
172
- </NavigationIndependentTree>
173
- </Animated.View>
174
- );
175
- };
176
-
177
- export default TabScreen;
@@ -1,41 +0,0 @@
1
- import { Colors } from '../../../Consts';
2
-
3
- export const getBadgeProps = (itemBadgeLabel: string | number | undefined) => {
4
- const isNum = !isNaN(parseInt(`${itemBadgeLabel}`, 10));
5
- const isDot = typeof itemBadgeLabel === 'string' && !itemBadgeLabel;
6
- const isNumZero = isNum && Number(itemBadgeLabel) === 0;
7
-
8
- let badgeLabel = itemBadgeLabel;
9
- if (isNumZero) {
10
- badgeLabel = undefined;
11
- }
12
-
13
- let badgeStyle: {
14
- marginRight: number;
15
- top: number;
16
- backgroundColor: string;
17
- width?: number;
18
- } = {
19
- marginRight: -8,
20
- top: -4,
21
- backgroundColor: Colors.orange_03,
22
- };
23
-
24
- if (isNum) {
25
- badgeStyle = {
26
- marginRight: -4,
27
- top: -4,
28
- backgroundColor: Colors.red_03,
29
- };
30
- }
31
- if (isDot) {
32
- badgeStyle = {
33
- marginRight: -2,
34
- top: -2,
35
- backgroundColor: Colors.orange_03,
36
- width: 12,
37
- };
38
- }
39
-
40
- return { badgeLabel, badgeStyle };
41
- };