@momo-kits/foundation 0.169.9 → 0.169.10-beta.1
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.hooks.ts +17 -27
- package/Application/BottomSheet.tsx +27 -35
- package/Application/BottomTab/BottomTabBar.tsx +6 -6
- package/Application/BottomTab/DuoRailTabBar.tsx +5 -5
- package/Application/BottomTab/TabScreen.tsx +10 -11
- package/Application/BottomTab/index.tsx +5 -5
- package/Application/BottomTab/usePressLift.ts +3 -3
- package/Application/Components/HeaderAnimated.tsx +38 -13
- package/Application/Components/HeaderBackground.tsx +16 -3
- package/Application/Components/HeaderExtendHeader.tsx +41 -28
- package/Application/Components/HeaderLeft.tsx +4 -18
- package/Application/Components/HeaderRight.styles.ts +15 -13
- package/Application/Components/HeaderTitle.shared.ts +10 -11
- package/Application/Components/HeaderToolkitAction.tsx +21 -54
- package/Application/Components/NavigationButton.tsx +9 -6
- package/Application/Components/SearchHeader.tsx +20 -7
- package/Application/Components/useToolkitActions.tsx +21 -22
- package/Application/ModalScreen.tsx +15 -19
- package/Application/StackScreen.tsx +18 -13
- package/Application/headerLayout.ts +165 -0
- package/Application/index.ts +11 -1
- package/Application/modalLayout.ts +0 -1
- package/Application/navigationOptions.tsx +6 -15
- package/Application/types.header.ts +7 -2
- package/Application/types.ts +7 -0
- package/Context/index.ts +1 -3
- package/Image/index.tsx +6 -6
- package/Input/Input.tsx +37 -40
- package/Input/InputDropDown.tsx +10 -13
- package/Input/InputMoney.tsx +17 -17
- package/Input/InputMoneyView.tsx +12 -12
- package/Input/InputOTP.tsx +34 -46
- package/Input/InputPhoneNumber.tsx +43 -48
- package/Input/InputSearch.tsx +39 -26
- package/Input/InputTextArea.tsx +23 -29
- package/Input/common.tsx +257 -0
- package/Input/index.tsx +7 -1
- package/Input/moneyUtils.ts +23 -0
- package/Input/utils.ts +7 -126
- package/Layout/FloatingButton.tsx +24 -38
- package/Layout/Screen.tsx +3 -0
- package/Layout/layoutMetrics.ts +34 -43
- package/Layout/screenHeader.tsx +55 -52
- package/Layout/screenTypes.ts +13 -4
- package/Pagination/PaginationScroll.tsx +3 -5
- package/Pagination/types.ts +5 -3
- package/Popup/PopupNotify.tsx +14 -17
- package/Popup/PopupPromotion.tsx +4 -5
- package/Popup/types.ts +4 -2
- package/Popup/utils.ts +4 -7
- package/Skeleton/index.tsx +12 -15
- package/package.json +1 -1
- package/Input/ErrorView.tsx +0 -59
- package/Input/FloatingView.tsx +0 -101
- package/Input/RenderTrailing.tsx +0 -79
- package/Input/constants.ts +0 -8
package/Input/ErrorView.tsx
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import React, { type FC, useContext } from 'react';
|
|
2
|
-
import { View } from 'react-native';
|
|
3
|
-
import { Styles } from '../Consts';
|
|
4
|
-
import { ApplicationContext } from '../Context';
|
|
5
|
-
import { Icon } from '../Icon';
|
|
6
|
-
import { Text, useScaleSize } from '../Text';
|
|
7
|
-
import styles from './styles';
|
|
8
|
-
|
|
9
|
-
const ICON_SIZE = 16;
|
|
10
|
-
|
|
11
|
-
type ErrorViewProps = {
|
|
12
|
-
errorMessage?: string;
|
|
13
|
-
errorSpacing?: boolean;
|
|
14
|
-
hintText?: string;
|
|
15
|
-
componentId?: string;
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Error or hint row under an input (error wins); with neither, `errorSpacing`
|
|
20
|
-
* keeps an empty row so the layout doesn't jump when an error appears.
|
|
21
|
-
*/
|
|
22
|
-
const ErrorView: FC<ErrorViewProps> = ({
|
|
23
|
-
errorMessage,
|
|
24
|
-
errorSpacing,
|
|
25
|
-
hintText,
|
|
26
|
-
componentId,
|
|
27
|
-
}) => {
|
|
28
|
-
const { theme } = useContext(ApplicationContext);
|
|
29
|
-
const errorColor = theme.colors.error.primary;
|
|
30
|
-
const hintColor = theme.colors.text.hint;
|
|
31
|
-
const hintTextDefault = hintText ?? 'Không thể chỉnh sửa';
|
|
32
|
-
const scaledIconSize = useScaleSize(ICON_SIZE);
|
|
33
|
-
|
|
34
|
-
if (errorMessage || hintText) {
|
|
35
|
-
const messageColor = errorMessage ? errorColor : hintColor;
|
|
36
|
-
const messageType = errorMessage ? 'error' : 'hint';
|
|
37
|
-
return (
|
|
38
|
-
<View style={styles.errorView}>
|
|
39
|
-
<View style={styles.errorIcon}>
|
|
40
|
-
<Icon color={messageColor} source="ic_error" size={scaledIconSize} />
|
|
41
|
-
</View>
|
|
42
|
-
<Text
|
|
43
|
-
accessibilityLabel={`${componentId}|${messageType}-text`}
|
|
44
|
-
style={Styles.flex}
|
|
45
|
-
color={messageColor}
|
|
46
|
-
typography={'description_default_regular'}
|
|
47
|
-
>
|
|
48
|
-
{errorMessage ?? hintTextDefault}
|
|
49
|
-
</Text>
|
|
50
|
-
</View>
|
|
51
|
-
);
|
|
52
|
-
}
|
|
53
|
-
if (errorSpacing) {
|
|
54
|
-
return <View style={[styles.errorView, styles.errorSpacing]} />;
|
|
55
|
-
}
|
|
56
|
-
return <View />;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export { ErrorView };
|
package/Input/FloatingView.tsx
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import React, { type FC, useContext } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
type GestureResponderEvent,
|
|
4
|
-
TouchableOpacity,
|
|
5
|
-
View,
|
|
6
|
-
type ViewStyle,
|
|
7
|
-
} from 'react-native';
|
|
8
|
-
import { ApplicationContext } from '../Context';
|
|
9
|
-
import { Icon } from '../Icon';
|
|
10
|
-
import { Text, useScaleSize } from '../Text';
|
|
11
|
-
import { PRESSED_OPACITY } from './constants';
|
|
12
|
-
import styles from './styles';
|
|
13
|
-
|
|
14
|
-
const LABEL_OFFSET = 10;
|
|
15
|
-
const ICON_SIZE = 16;
|
|
16
|
-
|
|
17
|
-
type FloatingViewProps = {
|
|
18
|
-
floatingValue?: string;
|
|
19
|
-
floatingIconColor?: string;
|
|
20
|
-
componentId?: string;
|
|
21
|
-
disabled?: boolean;
|
|
22
|
-
floatingIcon?: string;
|
|
23
|
-
required?: boolean;
|
|
24
|
-
style?: ViewStyle;
|
|
25
|
-
onPress?: (e: GestureResponderEvent) => void;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/**
|
|
29
|
-
* Floating label on the input's top border with a required `*` and an
|
|
30
|
-
* optional pressable icon; renders nothing without `floatingValue`.
|
|
31
|
-
*/
|
|
32
|
-
const FloatingView: FC<FloatingViewProps> = ({
|
|
33
|
-
floatingValue,
|
|
34
|
-
floatingIconColor,
|
|
35
|
-
disabled,
|
|
36
|
-
floatingIcon,
|
|
37
|
-
required,
|
|
38
|
-
style,
|
|
39
|
-
onPress,
|
|
40
|
-
componentId,
|
|
41
|
-
}) => {
|
|
42
|
-
const { theme } = useContext(ApplicationContext);
|
|
43
|
-
const scaledTop = useScaleSize(LABEL_OFFSET);
|
|
44
|
-
if (!floatingValue) {
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
let floatingTextColor = theme.colors.text.hint;
|
|
49
|
-
let floatingIconTintColor = floatingIconColor;
|
|
50
|
-
if (disabled) {
|
|
51
|
-
floatingTextColor = theme.colors.text.disable;
|
|
52
|
-
floatingIconTintColor = theme.colors.text.disable;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return (
|
|
56
|
-
<View
|
|
57
|
-
style={[
|
|
58
|
-
styles.floatingView,
|
|
59
|
-
styles.floatingViewLayer,
|
|
60
|
-
{
|
|
61
|
-
backgroundColor: theme.colors.background.surface,
|
|
62
|
-
top: -scaledTop,
|
|
63
|
-
},
|
|
64
|
-
style,
|
|
65
|
-
]}
|
|
66
|
-
>
|
|
67
|
-
<Text
|
|
68
|
-
color={floatingTextColor}
|
|
69
|
-
typography={'label_s_medium'}
|
|
70
|
-
accessibilityLabel={`${componentId}|floating-text`}
|
|
71
|
-
>
|
|
72
|
-
{floatingValue}
|
|
73
|
-
{required && (
|
|
74
|
-
<Text
|
|
75
|
-
typography={'label_s_medium'}
|
|
76
|
-
color={theme.colors.error.primary}
|
|
77
|
-
>
|
|
78
|
-
*
|
|
79
|
-
</Text>
|
|
80
|
-
)}
|
|
81
|
-
</Text>
|
|
82
|
-
{!!floatingIcon && (
|
|
83
|
-
<TouchableOpacity
|
|
84
|
-
activeOpacity={onPress ? PRESSED_OPACITY : 1}
|
|
85
|
-
onPress={onPress}
|
|
86
|
-
accessibilityLabel={`${componentId}|floating-icon-touch`}
|
|
87
|
-
>
|
|
88
|
-
<Icon
|
|
89
|
-
color={floatingIconTintColor}
|
|
90
|
-
source={floatingIcon}
|
|
91
|
-
size={ICON_SIZE}
|
|
92
|
-
style={styles.floatingIcon}
|
|
93
|
-
accessibilityLabel={`${componentId}|floating-icon`}
|
|
94
|
-
/>
|
|
95
|
-
</TouchableOpacity>
|
|
96
|
-
)}
|
|
97
|
-
</View>
|
|
98
|
-
);
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
export { FloatingView };
|
package/Input/RenderTrailing.tsx
DELETED
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
import React, { type FC, type ReactNode, useContext } from 'react';
|
|
2
|
-
import { TouchableOpacity } from 'react-native';
|
|
3
|
-
import IconSources from '../Assets/icon.json';
|
|
4
|
-
import { ApplicationContext } from '../Context';
|
|
5
|
-
import { Icon } from '../Icon';
|
|
6
|
-
import { Loader } from '../Loader';
|
|
7
|
-
import { Text } from '../Text';
|
|
8
|
-
import styles from './styles';
|
|
9
|
-
|
|
10
|
-
const ICON_SIZE = 24;
|
|
11
|
-
const TEXT_MAX_LENGTH = 15;
|
|
12
|
-
|
|
13
|
-
type IconSourceMap = Record<string, { uri?: string } | undefined>;
|
|
14
|
-
|
|
15
|
-
type TrailingProps = {
|
|
16
|
-
loading?: boolean;
|
|
17
|
-
color?: string;
|
|
18
|
-
icon?: string;
|
|
19
|
-
componentId?: string;
|
|
20
|
-
onPressIcon?: () => void;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Trailing slot: spinner while `loading`, an icon when `icon` is a known icon
|
|
25
|
-
* name or URL, otherwise `icon` as a text action (first 15 chars).
|
|
26
|
-
*/
|
|
27
|
-
const RenderTrailing: FC<TrailingProps> = ({
|
|
28
|
-
loading,
|
|
29
|
-
color,
|
|
30
|
-
icon,
|
|
31
|
-
onPressIcon,
|
|
32
|
-
componentId,
|
|
33
|
-
}) => {
|
|
34
|
-
const { theme } = useContext(ApplicationContext);
|
|
35
|
-
if (loading) {
|
|
36
|
-
return <Loader type={'spinner'} color={color} style={styles.icon} />;
|
|
37
|
-
}
|
|
38
|
-
if (!icon) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const iconSources: IconSourceMap = IconSources;
|
|
43
|
-
const isIconName = !!iconSources[icon]?.uri;
|
|
44
|
-
const isIcon = isIconName || icon.includes('http');
|
|
45
|
-
const renderIconTouchable = (content: ReactNode) => {
|
|
46
|
-
return (
|
|
47
|
-
<TouchableOpacity
|
|
48
|
-
accessibilityLabel={`${componentId}|trailing-touch`}
|
|
49
|
-
onPress={onPressIcon}
|
|
50
|
-
style={styles.icon}
|
|
51
|
-
>
|
|
52
|
-
{content}
|
|
53
|
-
</TouchableOpacity>
|
|
54
|
-
);
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
if (isIcon) {
|
|
58
|
-
return renderIconTouchable(
|
|
59
|
-
<Icon
|
|
60
|
-
color={color}
|
|
61
|
-
source={icon}
|
|
62
|
-
size={ICON_SIZE}
|
|
63
|
-
accessibilityLabel={`${componentId}|trailing-icon`}
|
|
64
|
-
/>,
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
return renderIconTouchable(
|
|
68
|
-
<Text
|
|
69
|
-
typography="action_xs_bold"
|
|
70
|
-
color={color ?? theme.colors.primary}
|
|
71
|
-
numberOfLines={1}
|
|
72
|
-
accessibilityLabel={`${componentId}|trailing-text`}
|
|
73
|
-
>
|
|
74
|
-
{icon.substring(0, TEXT_MAX_LENGTH)}
|
|
75
|
-
</Text>,
|
|
76
|
-
);
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
export { RenderTrailing };
|
package/Input/constants.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
/** Input text size before font scaling. */
|
|
2
|
-
const INPUT_FONT_SIZE = 14;
|
|
3
|
-
/** Size of the clear (x) icon shown while a focused field has a value. */
|
|
4
|
-
const CLEAR_ICON_SIZE = 16;
|
|
5
|
-
/** Pressed opacity of the floating icon, dropdown and typing placeholder. */
|
|
6
|
-
const PRESSED_OPACITY = 0.6;
|
|
7
|
-
|
|
8
|
-
export { INPUT_FONT_SIZE, CLEAR_ICON_SIZE, PRESSED_OPACITY };
|