@momo-kits/foundation 0.154.2-beta.4 → 0.155.1-beta.2
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 +15 -10
- package/Application/BottomTab/BottomTabBar.tsx +7 -2
- package/Application/BottomTab/CustomBottomTabItem.tsx +8 -1
- package/Application/Components/HeaderAnimated.tsx +2 -12
- package/Application/Components/HeaderBackground.tsx +7 -3
- package/Application/Components/HeaderExtendHeader.tsx +6 -12
- package/Application/Components/HeaderRight.tsx +0 -9
- package/Application/Components/HeaderTitle.tsx +13 -17
- package/Application/Components/NavigationButton.tsx +0 -9
- package/Application/Components/SearchHeader.tsx +9 -4
- package/Application/Localize.ts +2 -2
- package/Application/StackScreen.tsx +2 -11
- package/Application/index.ts +0 -2
- package/Badge/Badge.tsx +9 -2
- package/Badge/BadgeDot.tsx +15 -5
- package/Badge/BadgeRibbon.tsx +10 -2
- package/Badge/styles.ts +1 -0
- package/Button/index.tsx +7 -8
- package/Button/styles.ts +2 -0
- package/CheckBox/index.tsx +13 -2
- package/CheckBox/styles.ts +5 -4
- package/Icon/index.tsx +15 -2
- package/IconButton/index.tsx +9 -2
- package/IconButton/styles.ts +3 -2
- package/Image/index.tsx +12 -2
- package/Image/styles.ts +3 -1
- package/Input/Input.tsx +15 -2
- package/Input/InputDropDown.tsx +13 -2
- package/Input/InputMoney.tsx +15 -2
- package/Input/InputOTP.tsx +20 -3
- package/Input/InputPhoneNumber.tsx +15 -2
- package/Input/InputSearch.tsx +15 -2
- package/Input/InputTextArea.tsx +12 -10
- package/Input/styles.ts +1 -0
- package/Layout/Card.tsx +5 -1
- package/Layout/Item.tsx +5 -1
- package/Layout/Section.tsx +5 -1
- package/Layout/styles.ts +3 -2
- package/Pagination/PaginationDot.tsx +8 -2
- package/Pagination/PaginationNumber.tsx +13 -6
- package/Pagination/PaginationScroll.tsx +11 -2
- package/Pagination/PaginationWhiteDot.tsx +14 -7
- package/Pagination/styles.ts +4 -3
- package/Popup/PopupNotify.tsx +4 -1
- package/Popup/PopupPromotion.tsx +8 -2
- package/Radio/index.tsx +9 -1
- package/Radio/styles.ts +5 -4
- package/Switch/index.tsx +6 -2
- package/Switch/styles.ts +3 -1
- package/Tag/index.tsx +28 -16
- package/Title/index.tsx +10 -2
- package/Title/styles.ts +4 -3
- package/package.json +1 -1
- package/Application/TooltipPortal.tsx +0 -125
- package/Tag/styles.ts +0 -25
package/Layout/Section.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { Dimensions, View, ViewProps } from 'react-native';
|
|
|
3
3
|
import { useGridSystem } from './utils';
|
|
4
4
|
import { GridContextProps } from './types';
|
|
5
5
|
import { GridContext } from './index';
|
|
6
|
-
import { ApplicationContext } from '../Context';
|
|
6
|
+
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
7
7
|
import styles from './styles';
|
|
8
8
|
import { Image } from '../Image';
|
|
9
9
|
import { Spacing } from '../Consts';
|
|
@@ -35,8 +35,11 @@ const Section: React.FC<SectionProps> = ({
|
|
|
35
35
|
...props
|
|
36
36
|
}) => {
|
|
37
37
|
const { showGrid } = useContext(ApplicationContext);
|
|
38
|
+
const context = useContext<any>(MiniAppContext);
|
|
38
39
|
const { numberOfColumns } = useGridSystem();
|
|
39
40
|
|
|
41
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
42
|
+
|
|
40
43
|
const gutterSize = 12;
|
|
41
44
|
let margin = 0;
|
|
42
45
|
if (useMargin) {
|
|
@@ -81,6 +84,7 @@ const Section: React.FC<SectionProps> = ({
|
|
|
81
84
|
flexWrap: 'wrap',
|
|
82
85
|
gap: gutterSize,
|
|
83
86
|
},
|
|
87
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
84
88
|
]}
|
|
85
89
|
>
|
|
86
90
|
{!!backgroundImage && (
|
package/Layout/styles.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {Platform, StyleSheet} from 'react-native';
|
|
2
|
-
import {Colors, Radius, Spacing} from '../Consts';
|
|
1
|
+
import { Platform, StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors, Radius, Spacing } from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
screenBanner: {
|
|
@@ -91,4 +91,5 @@ export default StyleSheet.create({
|
|
|
91
91
|
},
|
|
92
92
|
}),
|
|
93
93
|
},
|
|
94
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
94
95
|
});
|
|
@@ -4,7 +4,7 @@ import { ChildPaginationProps } from './types';
|
|
|
4
4
|
import Dot from './Dot';
|
|
5
5
|
import styles from './styles';
|
|
6
6
|
import { Spacing } from '../Consts';
|
|
7
|
-
import { ApplicationContext } from '../Context';
|
|
7
|
+
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
8
8
|
|
|
9
9
|
const PaginationDot: FC<ChildPaginationProps> = ({
|
|
10
10
|
dataLength = 2,
|
|
@@ -12,6 +12,10 @@ const PaginationDot: FC<ChildPaginationProps> = ({
|
|
|
12
12
|
style,
|
|
13
13
|
}) => {
|
|
14
14
|
const { theme } = useContext(ApplicationContext);
|
|
15
|
+
const context = useContext<any>(MiniAppContext);
|
|
16
|
+
|
|
17
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
18
|
+
|
|
15
19
|
const renderDots = () => {
|
|
16
20
|
const dots: React.ReactElement[] = [];
|
|
17
21
|
for (let i = 0; i < dataLength; i++) {
|
|
@@ -29,7 +33,9 @@ const PaginationDot: FC<ChildPaginationProps> = ({
|
|
|
29
33
|
return dots;
|
|
30
34
|
};
|
|
31
35
|
return (
|
|
32
|
-
<View
|
|
36
|
+
<View
|
|
37
|
+
style={[style, styles.row, showBaseLineDebug && styles.debugBaseLine]}
|
|
38
|
+
>
|
|
33
39
|
<View style={styles.paginationPinkContainer}>{renderDots()}</View>
|
|
34
40
|
</View>
|
|
35
41
|
);
|
|
@@ -1,17 +1,24 @@
|
|
|
1
|
-
import React, {FC} from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
3
|
-
import {ChildPaginationProps} from './types';
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { ChildPaginationProps } from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import {Text} from '../Text';
|
|
6
|
-
import {Colors} from '../Consts';
|
|
5
|
+
import { Text } from '../Text';
|
|
6
|
+
import { Colors } from '../Consts';
|
|
7
|
+
import { MiniAppContext } from '../Context';
|
|
7
8
|
|
|
8
9
|
const PaginationNumber: FC<ChildPaginationProps> = ({
|
|
9
10
|
activeIndex = 0,
|
|
10
11
|
dataLength = 2,
|
|
11
12
|
style,
|
|
12
13
|
}) => {
|
|
14
|
+
const context = useContext<any>(MiniAppContext);
|
|
15
|
+
|
|
16
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
17
|
+
|
|
13
18
|
return (
|
|
14
|
-
<View
|
|
19
|
+
<View
|
|
20
|
+
style={[style, styles.row, showBaseLineDebug && styles.debugBaseLine]}
|
|
21
|
+
>
|
|
15
22
|
<View style={styles.paginationNumberContainer}>
|
|
16
23
|
<Text color={Colors.black_01} typography={'label_default_medium'}>{`${
|
|
17
24
|
activeIndex + 1
|
|
@@ -2,7 +2,7 @@ import React, { FC, useContext, useRef, useState } from 'react';
|
|
|
2
2
|
import { Animated, View } from 'react-native';
|
|
3
3
|
import { ScrollIndicatorProps } from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
|
-
import { ApplicationContext } from '../Context';
|
|
5
|
+
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
6
6
|
|
|
7
7
|
const INDICATOR_WIDTH = 24;
|
|
8
8
|
const INDICATOR_CONTAINER_WIDTH = 72;
|
|
@@ -12,10 +12,13 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
|
|
|
12
12
|
scrollViewRef,
|
|
13
13
|
}) => {
|
|
14
14
|
const { theme } = useContext(ApplicationContext);
|
|
15
|
+
const context = useContext<any>(MiniAppContext);
|
|
15
16
|
const left = useRef(new Animated.Value(0)).current;
|
|
16
17
|
const [scrollViewWidth, setScrollViewWidth] = useState(0);
|
|
17
18
|
const [scrollContentWidth, setScrollContentWidth] = useState(0);
|
|
18
19
|
|
|
20
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
21
|
+
|
|
19
22
|
const translateX = () => {
|
|
20
23
|
if (scrollViewWidth && scrollContentWidth) {
|
|
21
24
|
const value = left.interpolate({
|
|
@@ -80,7 +83,13 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
|
|
|
80
83
|
);
|
|
81
84
|
};
|
|
82
85
|
return (
|
|
83
|
-
<View
|
|
86
|
+
<View
|
|
87
|
+
style={[
|
|
88
|
+
style,
|
|
89
|
+
styles.scrollContainer,
|
|
90
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
91
|
+
]}
|
|
92
|
+
>
|
|
84
93
|
{renderScrollView()}
|
|
85
94
|
{scrollContentWidth > scrollViewWidth && renderIndicator()}
|
|
86
95
|
</View>
|
|
@@ -1,15 +1,20 @@
|
|
|
1
|
-
import React, {FC} from 'react';
|
|
2
|
-
import {View} from 'react-native';
|
|
3
|
-
import {ChildPaginationProps} from './types';
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
|
+
import { View } from 'react-native';
|
|
3
|
+
import { ChildPaginationProps } from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import Dot from './Dot';
|
|
6
|
-
import {Colors, Spacing} from '../Consts';
|
|
6
|
+
import { Colors, Spacing } from '../Consts';
|
|
7
|
+
import { MiniAppContext } from '../Context';
|
|
7
8
|
|
|
8
9
|
const PaginationWhiteDot: FC<ChildPaginationProps> = ({
|
|
9
10
|
dataLength = 2,
|
|
10
11
|
activeIndex = 0,
|
|
11
12
|
style,
|
|
12
13
|
}) => {
|
|
14
|
+
const context = useContext<any>(MiniAppContext);
|
|
15
|
+
|
|
16
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
17
|
+
|
|
13
18
|
const renderDots = () => {
|
|
14
19
|
const dots: React.ReactElement[] = [];
|
|
15
20
|
for (let i = 0; i < dataLength; i++) {
|
|
@@ -17,8 +22,8 @@ const PaginationWhiteDot: FC<ChildPaginationProps> = ({
|
|
|
17
22
|
<Dot
|
|
18
23
|
key={`Dot${i}`}
|
|
19
24
|
style={[
|
|
20
|
-
i !== dataLength - 1 ? {marginRight: Spacing.XS} : {},
|
|
21
|
-
{backgroundColor: Colors.black_01},
|
|
25
|
+
i !== dataLength - 1 ? { marginRight: Spacing.XS } : {},
|
|
26
|
+
{ backgroundColor: Colors.black_01 },
|
|
22
27
|
]}
|
|
23
28
|
active={activeIndex === i}
|
|
24
29
|
/>,
|
|
@@ -27,7 +32,9 @@ const PaginationWhiteDot: FC<ChildPaginationProps> = ({
|
|
|
27
32
|
return dots;
|
|
28
33
|
};
|
|
29
34
|
return (
|
|
30
|
-
<View
|
|
35
|
+
<View
|
|
36
|
+
style={[style, styles.row, showBaseLineDebug && styles.debugBaseLine]}
|
|
37
|
+
>
|
|
31
38
|
<View style={styles.paginationWhiteContainer}>{renderDots()}</View>
|
|
32
39
|
</View>
|
|
33
40
|
);
|
package/Pagination/styles.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Colors, Radius, Spacing} from '../Consts';
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors, Radius, Spacing } from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
activeDot: {
|
|
@@ -46,5 +46,6 @@ export default StyleSheet.create({
|
|
|
46
46
|
height: 4,
|
|
47
47
|
borderRadius: Radius.XS,
|
|
48
48
|
},
|
|
49
|
-
row: {flexDirection: 'row'},
|
|
49
|
+
row: { flexDirection: 'row' },
|
|
50
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
50
51
|
});
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
} from 'react-native';
|
|
9
9
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
10
10
|
import { Button } from '../Button';
|
|
11
|
-
import { Radius, Spacing, Styles } from '../Consts';
|
|
11
|
+
import { Colors, Radius, Spacing, Styles } from '../Consts';
|
|
12
12
|
import { Icon } from '../Icon';
|
|
13
13
|
import { Image } from '../Image';
|
|
14
14
|
import { useScaleSize, Text } from '../Text';
|
|
@@ -33,6 +33,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
33
33
|
const { width: widthDevice } = Dimensions.get('window');
|
|
34
34
|
const scaledMaxHeight = useScaleSize(172);
|
|
35
35
|
|
|
36
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
36
37
|
const closeAction = useRef('touch_outside');
|
|
37
38
|
let descriptionStyle = {};
|
|
38
39
|
let Description: any = View;
|
|
@@ -211,6 +212,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
|
|
|
211
212
|
backgroundColor: theme.colors.background.surface,
|
|
212
213
|
width: widthDevice - Spacing.XL * 2,
|
|
213
214
|
},
|
|
215
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
214
216
|
]}
|
|
215
217
|
>
|
|
216
218
|
{!!image && <Image source={{ uri: image }} style={styles.image} />}
|
|
@@ -264,6 +266,7 @@ const styles = StyleSheet.create({
|
|
|
264
266
|
container: {
|
|
265
267
|
borderRadius: Radius.L,
|
|
266
268
|
},
|
|
269
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
267
270
|
image: {
|
|
268
271
|
borderTopLeftRadius: Radius.L,
|
|
269
272
|
borderTopRightRadius: Radius.L,
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -3,7 +3,7 @@ import { Dimensions, StyleSheet, TouchableOpacity, View } from 'react-native';
|
|
|
3
3
|
import { PopupPromotionProps } from './types';
|
|
4
4
|
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
5
5
|
import { Image } from '../Image';
|
|
6
|
-
import { Radius, Spacing } from '../Consts';
|
|
6
|
+
import { Colors, Radius, Spacing } from '../Consts';
|
|
7
7
|
import { Icon } from '../Icon';
|
|
8
8
|
|
|
9
9
|
const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
@@ -18,6 +18,8 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
18
18
|
const { width: widthDevice } = Dimensions.get('window');
|
|
19
19
|
const closeAction = useRef('touch_outside');
|
|
20
20
|
|
|
21
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
22
|
+
|
|
21
23
|
/**
|
|
22
24
|
* tracking
|
|
23
25
|
*/
|
|
@@ -95,7 +97,10 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
|
|
|
95
97
|
};
|
|
96
98
|
|
|
97
99
|
return (
|
|
98
|
-
<View
|
|
100
|
+
<View
|
|
101
|
+
accessibilityLabel={'popup_promotion'}
|
|
102
|
+
style={showBaseLineDebug && styles.debugBaseLine}
|
|
103
|
+
>
|
|
99
104
|
<TouchableOpacity onPress={() => onAction(onActionClick)}>
|
|
100
105
|
<Image
|
|
101
106
|
source={{
|
|
@@ -119,6 +124,7 @@ const styles = StyleSheet.create({
|
|
|
119
124
|
aspectRatio: 0.72,
|
|
120
125
|
width: '100%',
|
|
121
126
|
},
|
|
127
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
122
128
|
iconCloseContainer: {
|
|
123
129
|
width: '100%',
|
|
124
130
|
flexDirection: 'row',
|
package/Radio/index.tsx
CHANGED
|
@@ -5,7 +5,11 @@ import { RadioProps } from './types';
|
|
|
5
5
|
import { Text } from '../Text';
|
|
6
6
|
import styles from './styles';
|
|
7
7
|
import { useComponentId } from '../Application';
|
|
8
|
-
import {
|
|
8
|
+
import {
|
|
9
|
+
ApplicationContext,
|
|
10
|
+
ComponentContext,
|
|
11
|
+
MiniAppContext,
|
|
12
|
+
} from '../Context';
|
|
9
13
|
import { Spacing } from '../Consts';
|
|
10
14
|
|
|
11
15
|
const Radio: FC<RadioProps> = ({
|
|
@@ -21,12 +25,15 @@ const Radio: FC<RadioProps> = ({
|
|
|
21
25
|
...props
|
|
22
26
|
}) => {
|
|
23
27
|
const { theme } = useContext(ApplicationContext);
|
|
28
|
+
const context = useContext<any>(MiniAppContext);
|
|
24
29
|
const selected = value === groupValue;
|
|
25
30
|
const componentName = 'Radio';
|
|
26
31
|
const { componentId } = useComponentId(
|
|
27
32
|
`${componentName}${label ? `/${label}` : ''}`,
|
|
28
33
|
accessibilityLabel,
|
|
29
34
|
);
|
|
35
|
+
|
|
36
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
30
37
|
let disabledStyle = {};
|
|
31
38
|
let checkBoxStyle = {
|
|
32
39
|
borderWidth: 2,
|
|
@@ -67,6 +74,7 @@ const Radio: FC<RadioProps> = ({
|
|
|
67
74
|
flexDirection: 'row',
|
|
68
75
|
alignItems: 'center',
|
|
69
76
|
},
|
|
77
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
70
78
|
]}
|
|
71
79
|
accessibilityState={{
|
|
72
80
|
checked: selected,
|
package/Radio/styles.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Radius, Spacing} from '../Consts';
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Radius, Spacing, Colors } from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
radio: {
|
|
@@ -7,8 +7,9 @@ export default StyleSheet.create({
|
|
|
7
7
|
width: 20,
|
|
8
8
|
borderRadius: Radius.M,
|
|
9
9
|
},
|
|
10
|
-
container: {flex: 1},
|
|
10
|
+
container: { flex: 1 },
|
|
11
11
|
radioText: {
|
|
12
12
|
marginRight: Spacing.M,
|
|
13
|
-
}
|
|
13
|
+
},
|
|
14
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
14
15
|
});
|
package/Switch/index.tsx
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
2
|
import { TouchableOpacity, View } from 'react-native';
|
|
3
3
|
import { SwitchProps } from './types';
|
|
4
4
|
import styles from './styles';
|
|
5
5
|
import { Colors } from '../Consts';
|
|
6
6
|
import { useComponentId } from '../Application';
|
|
7
|
-
import { ComponentContext } from '../Context';
|
|
7
|
+
import { ComponentContext, MiniAppContext } from '../Context';
|
|
8
8
|
|
|
9
9
|
const Switch: FC<SwitchProps> = ({
|
|
10
10
|
value = false,
|
|
@@ -15,12 +15,15 @@ const Switch: FC<SwitchProps> = ({
|
|
|
15
15
|
accessibilityLabel,
|
|
16
16
|
...props
|
|
17
17
|
}) => {
|
|
18
|
+
const context = useContext<any>(MiniAppContext);
|
|
18
19
|
const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
|
|
19
20
|
const circleAlign = value ? 'flex-end' : 'flex-start';
|
|
20
21
|
const componentName = 'Switch';
|
|
21
22
|
|
|
22
23
|
const { componentId } = useComponentId(componentName, accessibilityLabel);
|
|
23
24
|
|
|
25
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
26
|
+
|
|
24
27
|
let backgroundColor = value ? Colors.green_03 : Colors.black_07;
|
|
25
28
|
if (disabled) {
|
|
26
29
|
backgroundColor = value ? Colors.green_09 : Colors.black_05;
|
|
@@ -49,6 +52,7 @@ const Switch: FC<SwitchProps> = ({
|
|
|
49
52
|
style,
|
|
50
53
|
styles.container,
|
|
51
54
|
{ backgroundColor, alignItems: circleAlign },
|
|
55
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
52
56
|
]}
|
|
53
57
|
>
|
|
54
58
|
<View
|
package/Switch/styles.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {StyleSheet} from 'react-native';
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors } from '../Consts';
|
|
2
3
|
|
|
3
4
|
export default StyleSheet.create({
|
|
4
5
|
container: {
|
|
@@ -20,4 +21,5 @@ export default StyleSheet.create({
|
|
|
20
21
|
height: 6,
|
|
21
22
|
borderRadius: 4,
|
|
22
23
|
},
|
|
24
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
23
25
|
});
|
package/Tag/index.tsx
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import React, {FC} from 'react';
|
|
2
|
-
import {View, StyleSheet} from 'react-native';
|
|
3
|
-
import {TagProps} from './types';
|
|
4
|
-
import {Colors, Radius, Spacing} from '../Consts';
|
|
5
|
-
import {Icon} from '../Icon';
|
|
6
|
-
import {Text, useScaleSize} from '../Text';
|
|
7
|
-
import {useComponentId} from '../Application';
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
|
+
import { View, StyleSheet } from 'react-native';
|
|
3
|
+
import { TagProps } from './types';
|
|
4
|
+
import { Colors, Radius, Spacing } from '../Consts';
|
|
5
|
+
import { Icon } from '../Icon';
|
|
6
|
+
import { Text, useScaleSize } from '../Text';
|
|
7
|
+
import { useComponentId } from '../Application';
|
|
8
|
+
import { MiniAppContext } from '../Context';
|
|
8
9
|
|
|
9
10
|
const backgroundColor = {
|
|
10
11
|
default: Colors.black_04,
|
|
@@ -33,9 +34,12 @@ const Tag: FC<TagProps> = ({
|
|
|
33
34
|
customColor,
|
|
34
35
|
accessibilityLabel,
|
|
35
36
|
}) => {
|
|
37
|
+
const context = useContext<any>(MiniAppContext);
|
|
36
38
|
const scaledHeight24 = useScaleSize(24);
|
|
37
39
|
const scaledHeight18 = useScaleSize(18);
|
|
38
|
-
|
|
40
|
+
|
|
41
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
42
|
+
|
|
39
43
|
const styles = StyleSheet.create({
|
|
40
44
|
container: {
|
|
41
45
|
paddingHorizontal: Spacing.S,
|
|
@@ -56,21 +60,22 @@ const Tag: FC<TagProps> = ({
|
|
|
56
60
|
icon: {
|
|
57
61
|
marginRight: Spacing.XS,
|
|
58
62
|
},
|
|
63
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
59
64
|
});
|
|
60
|
-
|
|
65
|
+
|
|
61
66
|
let labelColor = textColor[color];
|
|
62
67
|
let tagColor = backgroundColor[color];
|
|
63
68
|
let sizeStyle = styles.mediumContainer;
|
|
64
69
|
const componentName = 'Tag';
|
|
65
70
|
|
|
66
|
-
const {componentId} = useComponentId(
|
|
71
|
+
const { componentId } = useComponentId(
|
|
67
72
|
`${componentName}/${label}`,
|
|
68
|
-
accessibilityLabel
|
|
73
|
+
accessibilityLabel,
|
|
69
74
|
);
|
|
70
75
|
//Check if custom color is [color]_03 (only check in dev mode)
|
|
71
76
|
const validateCustomColor = (color: string) => {
|
|
72
77
|
if (__DEV__) {
|
|
73
|
-
const colorCore: {[key: string]: string} = Colors;
|
|
78
|
+
const colorCore: { [key: string]: string } = Colors;
|
|
74
79
|
const primaryColors = Object.keys(Colors)
|
|
75
80
|
.map(i => {
|
|
76
81
|
if (i.includes('_03')) {
|
|
@@ -93,8 +98,14 @@ const Tag: FC<TagProps> = ({
|
|
|
93
98
|
|
|
94
99
|
return (
|
|
95
100
|
<View
|
|
96
|
-
style={[
|
|
97
|
-
|
|
101
|
+
style={[
|
|
102
|
+
style,
|
|
103
|
+
sizeStyle,
|
|
104
|
+
{ backgroundColor: tagColor },
|
|
105
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
106
|
+
]}
|
|
107
|
+
accessibilityLabel={componentId}
|
|
108
|
+
>
|
|
98
109
|
{!!icon && (
|
|
99
110
|
<Icon
|
|
100
111
|
style={styles.icon}
|
|
@@ -106,11 +117,12 @@ const Tag: FC<TagProps> = ({
|
|
|
106
117
|
<Text
|
|
107
118
|
color={labelColor}
|
|
108
119
|
typography={'label_s_medium'}
|
|
109
|
-
accessibilityLabel={`${componentId}|text`}
|
|
120
|
+
accessibilityLabel={`${componentId}|text`}
|
|
121
|
+
>
|
|
110
122
|
{label}
|
|
111
123
|
</Text>
|
|
112
124
|
</View>
|
|
113
125
|
);
|
|
114
126
|
};
|
|
115
127
|
|
|
116
|
-
export {Tag};
|
|
128
|
+
export { Tag };
|
package/Title/index.tsx
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
import { Icon } from '../Icon';
|
|
9
9
|
import { useScaleSize, Text } from '../Text';
|
|
10
10
|
import { useComponentId } from '../Application';
|
|
11
|
-
import { ApplicationContext } from '../Context';
|
|
11
|
+
import { ApplicationContext, MiniAppContext } from '../Context';
|
|
12
12
|
import { Badge } from '../Badge';
|
|
13
13
|
import { Colors } from '../Consts';
|
|
14
14
|
import styles from './styles';
|
|
@@ -35,9 +35,12 @@ const Title: FC<TitleProps> = ({
|
|
|
35
35
|
style,
|
|
36
36
|
}) => {
|
|
37
37
|
const { theme } = useContext(ApplicationContext);
|
|
38
|
+
const context = useContext<any>(MiniAppContext);
|
|
38
39
|
const [badgeWidth, setBadgeWidth] = useState(0);
|
|
39
40
|
const [contentWidth, setContentWidth] = useState(0);
|
|
40
41
|
|
|
42
|
+
const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
|
|
43
|
+
|
|
41
44
|
const size18 = useScaleSize(18);
|
|
42
45
|
const size22 = useScaleSize(22);
|
|
43
46
|
// Dynamic styles using useScaleSize hook
|
|
@@ -263,7 +266,12 @@ const Title: FC<TitleProps> = ({
|
|
|
263
266
|
|
|
264
267
|
return (
|
|
265
268
|
<View
|
|
266
|
-
style={[
|
|
269
|
+
style={[
|
|
270
|
+
style,
|
|
271
|
+
styles.wrapper,
|
|
272
|
+
isSection && styles.margin,
|
|
273
|
+
showBaseLineDebug && styles.debugBaseLine,
|
|
274
|
+
]}
|
|
267
275
|
accessibilityLabel={componentId}
|
|
268
276
|
>
|
|
269
277
|
{renderIcon()}
|
package/Title/styles.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {StyleSheet} from 'react-native';
|
|
2
|
-
import {Colors, Radius, Spacing} from '../Consts';
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
import { Colors, Radius, Spacing } from '../Consts';
|
|
3
3
|
|
|
4
4
|
export default StyleSheet.create({
|
|
5
5
|
actionIcon: {
|
|
@@ -40,7 +40,7 @@ export default StyleSheet.create({
|
|
|
40
40
|
flexDirection: 'row',
|
|
41
41
|
alignItems: 'center',
|
|
42
42
|
},
|
|
43
|
-
contentView: {marginRight: Spacing.S, flex: 1},
|
|
43
|
+
contentView: { marginRight: Spacing.S, flex: 1 },
|
|
44
44
|
title: {
|
|
45
45
|
fontWeight: 'bold',
|
|
46
46
|
color: Colors.black_17,
|
|
@@ -51,4 +51,5 @@ export default StyleSheet.create({
|
|
|
51
51
|
description: {
|
|
52
52
|
marginTop: Spacing.XS,
|
|
53
53
|
},
|
|
54
|
+
debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
|
|
54
55
|
});
|
package/package.json
CHANGED
|
@@ -1,125 +0,0 @@
|
|
|
1
|
-
import React, {
|
|
2
|
-
createContext,
|
|
3
|
-
useContext,
|
|
4
|
-
useCallback,
|
|
5
|
-
ReactNode,
|
|
6
|
-
useMemo,
|
|
7
|
-
useReducer,
|
|
8
|
-
useRef,
|
|
9
|
-
RefObject,
|
|
10
|
-
} from 'react';
|
|
11
|
-
import { View, StyleSheet } from 'react-native';
|
|
12
|
-
|
|
13
|
-
interface TooltipPortalContextValue {
|
|
14
|
-
register: (id: string, content: ReactNode) => void;
|
|
15
|
-
unregister: (id: string, immediate?: boolean) => void;
|
|
16
|
-
portals: Map<string, ReactNode>;
|
|
17
|
-
hostRef: RefObject<View | null>;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
const TooltipPortalContext = createContext<TooltipPortalContextValue | null>(
|
|
21
|
-
null,
|
|
22
|
-
);
|
|
23
|
-
|
|
24
|
-
export const TooltipPortalProvider: React.FC<{ children: ReactNode }> = ({
|
|
25
|
-
children,
|
|
26
|
-
}) => {
|
|
27
|
-
// Use ref for synchronous updates + reducer for manual re-renders
|
|
28
|
-
const portalsRef = useRef<Map<string, ReactNode>>(new Map());
|
|
29
|
-
const hostRef = useRef<View>(null);
|
|
30
|
-
const [updateCounter, forceUpdate] = useReducer((x: number) => x + 1, 0);
|
|
31
|
-
const pendingUpdateRef = useRef<NodeJS.Timeout | null>(null);
|
|
32
|
-
|
|
33
|
-
const register = useCallback((id: string, content: ReactNode) => {
|
|
34
|
-
portalsRef.current.set(id, content);
|
|
35
|
-
forceUpdate(); // Trigger re-render to show new content
|
|
36
|
-
}, []);
|
|
37
|
-
|
|
38
|
-
const unregister = useCallback((id: string, immediate = false) => {
|
|
39
|
-
const hasItem = portalsRef.current.has(id);
|
|
40
|
-
if (!hasItem) return; // Already removed
|
|
41
|
-
|
|
42
|
-
portalsRef.current.delete(id);
|
|
43
|
-
|
|
44
|
-
// Clear any pending updates
|
|
45
|
-
if (pendingUpdateRef.current) {
|
|
46
|
-
clearTimeout(pendingUpdateRef.current);
|
|
47
|
-
pendingUpdateRef.current = null;
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (immediate) {
|
|
51
|
-
forceUpdate();
|
|
52
|
-
} else {
|
|
53
|
-
// Debounce normal updates to avoid excessive re-renders
|
|
54
|
-
pendingUpdateRef.current = setTimeout(() => {
|
|
55
|
-
forceUpdate();
|
|
56
|
-
pendingUpdateRef.current = null;
|
|
57
|
-
}, 0) as unknown as NodeJS.Timeout;
|
|
58
|
-
}
|
|
59
|
-
}, []);
|
|
60
|
-
|
|
61
|
-
const value = useMemo(
|
|
62
|
-
() => ({ register, unregister, portals: portalsRef.current, hostRef }),
|
|
63
|
-
[register, unregister, updateCounter], // Include updateCounter to refresh context
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
return (
|
|
67
|
-
<TooltipPortalContext.Provider value={value}>
|
|
68
|
-
{children}
|
|
69
|
-
</TooltipPortalContext.Provider>
|
|
70
|
-
);
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export const TooltipPortalHost: React.FC = () => {
|
|
74
|
-
const context = useContext(TooltipPortalContext);
|
|
75
|
-
|
|
76
|
-
if (!context) {
|
|
77
|
-
if (__DEV__) {
|
|
78
|
-
console.warn(
|
|
79
|
-
'TooltipPortalHost must be used within TooltipPortalProvider',
|
|
80
|
-
);
|
|
81
|
-
}
|
|
82
|
-
return null;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
const { portals, hostRef } = context;
|
|
86
|
-
|
|
87
|
-
return (
|
|
88
|
-
<View ref={hostRef} style={styles.hostContainer} pointerEvents="box-none">
|
|
89
|
-
{Array.from(portals.entries()).map(([id, content]) => (
|
|
90
|
-
<React.Fragment key={id}>{content}</React.Fragment>
|
|
91
|
-
))}
|
|
92
|
-
</View>
|
|
93
|
-
);
|
|
94
|
-
};
|
|
95
|
-
|
|
96
|
-
export const useTooltipPortal = () => {
|
|
97
|
-
const context = useContext(TooltipPortalContext);
|
|
98
|
-
|
|
99
|
-
if (!context) {
|
|
100
|
-
if (__DEV__) {
|
|
101
|
-
console.warn(
|
|
102
|
-
'useTooltipPortal must be used within TooltipPortalProvider. Tooltips may not appear correctly.',
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
|
-
// Return no-op functions if context is missing
|
|
106
|
-
return {
|
|
107
|
-
register: () => {},
|
|
108
|
-
unregister: () => {},
|
|
109
|
-
hostRef: null,
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
return context;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
const styles = StyleSheet.create({
|
|
117
|
-
hostContainer: {
|
|
118
|
-
position: 'absolute',
|
|
119
|
-
top: 0,
|
|
120
|
-
left: 0,
|
|
121
|
-
right: 0,
|
|
122
|
-
bottom: 0,
|
|
123
|
-
zIndex: 9999,
|
|
124
|
-
},
|
|
125
|
-
});
|