@momo-kits/foundation 0.80.8 → 0.81.1-beta.0

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 (87) hide show
  1. package/Application/BottomSheet.tsx +212 -0
  2. package/Application/BottomTab/BottomTabBar.tsx +278 -0
  3. package/Application/BottomTab/index.tsx +143 -0
  4. package/Application/Components.tsx +384 -213
  5. package/Application/ModalScreen.tsx +14 -178
  6. package/Application/Navigation.ts +15 -19
  7. package/Application/NavigationContainer.tsx +66 -63
  8. package/Application/Navigator.ts +106 -53
  9. package/Application/StackScreen.tsx +123 -9
  10. package/Application/index.ts +19 -6
  11. package/Application/types.ts +83 -26
  12. package/Application/utils.tsx +62 -74
  13. package/Assets/icon.json +83 -5
  14. package/Assets/icon_bank.json +506 -0
  15. package/Assets/language.json +3 -1
  16. package/Badge/Badge.tsx +56 -0
  17. package/Badge/BadgeDot.tsx +11 -0
  18. package/Badge/BadgeRibbon.tsx +125 -0
  19. package/Badge/Shape.tsx +29 -0
  20. package/Badge/index.tsx +7 -0
  21. package/Badge/styles.ts +58 -0
  22. package/Badge/types.ts +63 -0
  23. package/Button/index.tsx +64 -28
  24. package/Button/styles.ts +19 -0
  25. package/CheckBox/index.tsx +37 -27
  26. package/CheckBox/types.ts +5 -3
  27. package/Consts/colors+spacing+radius.ts +18 -0
  28. package/Icon/index.tsx +14 -9
  29. package/Icon/types.ts +4 -3
  30. package/IconButton/index.tsx +24 -15
  31. package/Image/index.tsx +62 -47
  32. package/Image/styles.ts +1 -9
  33. package/Image/types.ts +5 -1
  34. package/Input/Input.tsx +104 -25
  35. package/Input/InputDropDown.tsx +115 -110
  36. package/Input/InputMoney.tsx +79 -18
  37. package/Input/InputOTP.tsx +190 -149
  38. package/Input/InputSearch.tsx +96 -44
  39. package/Input/InputTextArea.tsx +33 -17
  40. package/Input/common.tsx +26 -17
  41. package/Input/index.tsx +108 -41
  42. package/Input/styles.ts +5 -7
  43. package/Input/utils.ts +1 -1
  44. package/Layout/AnimatedInputSearch.tsx +44 -0
  45. package/Layout/Card.tsx +37 -13
  46. package/Layout/FloatingButton.tsx +168 -0
  47. package/Layout/GridSystem.tsx +2 -3
  48. package/Layout/Item.tsx +1 -2
  49. package/Layout/ItemList.tsx +55 -0
  50. package/Layout/ItemSectionList.tsx +39 -0
  51. package/Layout/Screen.tsx +404 -181
  52. package/Layout/Section.tsx +22 -22
  53. package/Layout/TextTyping.tsx +114 -0
  54. package/Layout/index.ts +12 -2
  55. package/Layout/styles.ts +46 -13
  56. package/Layout/types.ts +13 -5
  57. package/Layout/utils.ts +7 -12
  58. package/Loader/index.tsx +2 -0
  59. package/Pagination/PaginationDot.tsx +6 -1
  60. package/Pagination/PaginationNumber.tsx +7 -4
  61. package/Pagination/PaginationScroll.tsx +0 -1
  62. package/Pagination/PaginationWhiteDot.tsx +6 -1
  63. package/Pagination/styles.ts +3 -0
  64. package/Pagination/types.ts +2 -0
  65. package/Popup/PopupNotify.tsx +108 -40
  66. package/Popup/PopupPromotion.tsx +45 -10
  67. package/Popup/types.ts +13 -10
  68. package/Radio/index.tsx +35 -21
  69. package/Radio/types.ts +7 -5
  70. package/Skeleton/index.tsx +1 -1
  71. package/Switch/index.tsx +32 -19
  72. package/Switch/types.ts +5 -3
  73. package/Tag/index.tsx +2 -4
  74. package/Text/index.tsx +26 -6
  75. package/Text/styles.ts +38 -0
  76. package/Text/types.ts +25 -13
  77. package/Title/index.tsx +177 -64
  78. package/Title/styles.ts +48 -15
  79. package/Title/types.ts +16 -7
  80. package/code-scanner.js +125 -16
  81. package/index.ts +9 -0
  82. package/migrate_typo.js +56 -0
  83. package/package.json +8 -7
  84. package/publish.sh +21 -16
  85. package/tsconfig.json +1 -2
  86. package/verify.js +24 -6
  87. package/Application/BottomTab.tsx +0 -65
@@ -0,0 +1,168 @@
1
+ import {default as React, useContext, useEffect, useRef, useState} from 'react';
2
+ import {
3
+ Animated,
4
+ LayoutChangeEvent,
5
+ StyleSheet,
6
+ TouchableOpacity,
7
+ View,
8
+ } from 'react-native';
9
+ import {ApplicationContext} from '../Application';
10
+ import {Icon} from '../Icon';
11
+
12
+ export interface FloatingButtonProps {
13
+ label?: string;
14
+ onPress?: () => void;
15
+ position?: 'center' | 'right';
16
+ icon?: string;
17
+ iconColor?: string;
18
+ size?: 'small' | 'large';
19
+ animatedValue?: Animated.Value;
20
+ bottom?: number;
21
+ renderComponent?: () => React.ReactNode;
22
+ }
23
+
24
+ export const FloatingButton: React.FC<FloatingButtonProps> = ({
25
+ renderComponent,
26
+ label = '',
27
+ onPress = () => {},
28
+ position = 'right',
29
+ icon = '',
30
+ iconColor = '',
31
+ size = 'small',
32
+ animatedValue,
33
+ bottom = 12,
34
+ }: FloatingButtonProps) => {
35
+ const {theme} = useContext(ApplicationContext);
36
+ const maxWidth = useRef(0);
37
+ const minWidth = size === 'small' ? 36 : 48;
38
+ const [opacityAnimated] = useState(new Animated.Value(0)); // Initial opacity set to 0
39
+ const [widthAnimated, setWidthAnimated] = useState<Animated.Value>();
40
+ const lastOffset = useRef(0);
41
+ const lastDirection = useRef<string>();
42
+ const [showText, setShowText] = React.useState(true);
43
+
44
+ useEffect(() => {
45
+ if (!label) return;
46
+
47
+ Animated.timing(opacityAnimated, {
48
+ toValue: 1,
49
+ duration: 100,
50
+ useNativeDriver: true,
51
+ }).start();
52
+
53
+ const listener = animatedValue?.addListener(({value}) => {
54
+ if (value !== lastOffset.current && value > 0) {
55
+ const direction = value > lastOffset.current ? 'down' : 'up';
56
+ lastOffset.current = value;
57
+ if (lastDirection.current !== direction) {
58
+ lastDirection.current = direction;
59
+ if (direction === 'down') {
60
+ Animated.timing(opacityAnimated, {
61
+ toValue: 0,
62
+ duration: 100,
63
+ useNativeDriver: true,
64
+ }).start();
65
+ Animated.timing(widthAnimated!, {
66
+ toValue: minWidth,
67
+ duration: 100,
68
+ useNativeDriver: false,
69
+ }).start(() => setShowText(false));
70
+ } else {
71
+ Animated.timing(opacityAnimated, {
72
+ toValue: 1,
73
+ duration: 100,
74
+ useNativeDriver: true,
75
+ }).start();
76
+ Animated.timing(widthAnimated!, {
77
+ toValue: maxWidth.current,
78
+ duration: 100,
79
+ useNativeDriver: false,
80
+ }).start(() => setShowText(true));
81
+ }
82
+ }
83
+ }
84
+ });
85
+
86
+ return () => {
87
+ if (listener !== null) {
88
+ animatedValue?.removeListener(listener);
89
+ }
90
+ };
91
+ }, [label, widthAnimated]);
92
+
93
+ const handleLayout = (event: LayoutChangeEvent) => {
94
+ const layout = event.nativeEvent.layout;
95
+ if (widthAnimated) return;
96
+ maxWidth.current = layout.width;
97
+ setWidthAnimated(new Animated.Value(layout.width));
98
+ };
99
+
100
+ if (renderComponent) {
101
+ return (
102
+ <View
103
+ onLayout={handleLayout}
104
+ style={[
105
+ styles.container,
106
+ {
107
+ right: position === 'right' ? 12 : undefined,
108
+ alignSelf: position === 'center' ? 'center' : 'flex-end',
109
+ bottom,
110
+ },
111
+ ]}>
112
+ {renderComponent()}
113
+ </View>
114
+ );
115
+ }
116
+
117
+ return (
118
+ <Animated.View
119
+ onLayout={handleLayout}
120
+ style={[
121
+ styles.container,
122
+ {
123
+ right: position === 'right' ? 12 : undefined,
124
+ alignSelf: position === 'center' ? 'center' : 'flex-end',
125
+ width: widthAnimated,
126
+ height: size === 'small' ? 36 : 48,
127
+ backgroundColor: theme.colors.primary,
128
+ bottom,
129
+ },
130
+ ]}>
131
+ <TouchableOpacity
132
+ style={{flexDirection: 'row', alignItems: 'center'}}
133
+ onPress={onPress}>
134
+ <Icon
135
+ source={icon}
136
+ size={size === 'small' ? 12 : 24}
137
+ color={iconColor}
138
+ />
139
+ {showText && !!label && (
140
+ <Animated.Text
141
+ style={[styles.label, {opacity: opacityAnimated, color: 'white'}]}
142
+ numberOfLines={1}>
143
+ {label}
144
+ </Animated.Text>
145
+ )}
146
+ </TouchableOpacity>
147
+ </Animated.View>
148
+ );
149
+ };
150
+
151
+ const styles = StyleSheet.create({
152
+ container: {
153
+ flexDirection: 'row',
154
+ alignContent: 'center',
155
+ alignItems: 'center',
156
+ position: 'absolute',
157
+ borderRadius: 100,
158
+ paddingHorizontal: 12,
159
+ flexWrap: 'wrap',
160
+ alignSelf: 'flex-end',
161
+ },
162
+ label: {
163
+ marginLeft: 8,
164
+ fontSize: 16,
165
+ lineHeight: 22,
166
+ fontWeight: '700',
167
+ },
168
+ });
@@ -24,7 +24,6 @@ const GridSystem: React.FC<any> = ({
24
24
  const grid: GridContextProps = {
25
25
  numberOfColumns,
26
26
  gutterSize,
27
- margin,
28
27
  sizePerSpan,
29
28
  getSizeSpan: span => {
30
29
  return span * sizePerSpan + (span - 1) * gutterSize;
@@ -46,7 +45,7 @@ const GridSystem: React.FC<any> = ({
46
45
  screenGrid && insets,
47
46
  {
48
47
  borderColor: theme.colors.error.primary,
49
- marginHorizontal: grid.margin,
48
+ marginHorizontal: margin,
50
49
  top: Spacing.M,
51
50
  bottom: Spacing.M,
52
51
  },
@@ -54,7 +53,7 @@ const GridSystem: React.FC<any> = ({
54
53
  {list.map((_, index) => {
55
54
  return (
56
55
  <View style={{flexDirection: 'row'}} key={index.toString()}>
57
- {index != -0 && <View style={{width: grid.gutterSize}} />}
56
+ {index !== -0 && <View style={{width: grid.gutterSize}} />}
58
57
  <View
59
58
  key={`Grid${index.toString()}`}
60
59
  pointerEvents="none"
package/Layout/Item.tsx CHANGED
@@ -5,7 +5,7 @@ import {GridContext} from './index';
5
5
  import {ApplicationContext} from '../Application';
6
6
  import styles from './styles';
7
7
 
8
- type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
8
+ export type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
9
9
 
10
10
  export interface ItemProps extends ViewProps {
11
11
  /**
@@ -37,7 +37,6 @@ const Item: React.FC<ItemProps> = ({
37
37
 
38
38
  return (
39
39
  <View
40
- accessibilityLabel={`Item`}
41
40
  style={[
42
41
  style,
43
42
  styles.item,
@@ -0,0 +1,55 @@
1
+ import React, {forwardRef, useContext} from 'react';
2
+ import {FlatList, FlatListProps, View} from 'react-native';
3
+ import Item, {SpanNumber} from './Item';
4
+ import {GridContext} from './index';
5
+ import styles from './styles';
6
+
7
+ export interface ItemListProps extends FlatListProps<any> {
8
+ /**
9
+ * Represents the width of the Card component in terms of span numbers (1-12).
10
+ */
11
+ widthSpan?: SpanNumber;
12
+ }
13
+
14
+ const ItemList = forwardRef(
15
+ (
16
+ {
17
+ renderItem,
18
+ widthSpan,
19
+ style,
20
+ contentContainerStyle,
21
+ ...props
22
+ }: ItemListProps,
23
+ ref,
24
+ ) => {
25
+ const {gutterSize, numberOfColumns} = useContext(GridContext);
26
+ const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
27
+ const numColumns = Math.floor(numberOfColumns / widthItem);
28
+ const indexBegin = props?.data?.map((_i, index) => index * numColumns);
29
+ const _renderItem = (item: any) => {
30
+ if (indexBegin?.includes(item?.index)) {
31
+ return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
32
+ }
33
+ return (
34
+ <View style={{paddingLeft: gutterSize}}>
35
+ <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>
36
+ </View>
37
+ );
38
+ };
39
+
40
+ return (
41
+ <FlatList
42
+ ref={ref as React.RefObject<FlatList>}
43
+ {...props}
44
+ numColumns={numColumns}
45
+ renderItem={_renderItem}
46
+ horizontal={false}
47
+ ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
48
+ style={[style, styles.protectedStyle]}
49
+ contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
50
+ />
51
+ );
52
+ },
53
+ );
54
+
55
+ export default ItemList;
@@ -0,0 +1,39 @@
1
+ import React, {FC, useContext} from 'react';
2
+ import {SectionList, SectionListProps, View} from 'react-native';
3
+ import Item, {SpanNumber} from './Item';
4
+ import {GridContext} from './index';
5
+ import styles from './styles';
6
+
7
+ export interface ItemSectionListProps extends SectionListProps<any> {
8
+ /**
9
+ * Represents the width of the Card component in terms of span numbers (1-12).
10
+ */
11
+ widthSpan?: SpanNumber;
12
+ }
13
+
14
+ const ItemSectionList: FC<ItemSectionListProps> = ({
15
+ renderItem,
16
+ widthSpan,
17
+ style,
18
+ contentContainerStyle,
19
+ ...props
20
+ }) => {
21
+ const {gutterSize, numberOfColumns} = useContext(GridContext);
22
+ const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
23
+ const _renderItem = (item: any) => {
24
+ return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
25
+ };
26
+
27
+ return (
28
+ <SectionList
29
+ {...props}
30
+ renderItem={_renderItem}
31
+ horizontal={false}
32
+ ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
33
+ style={[style, styles.protectedStyle]}
34
+ contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
35
+ />
36
+ );
37
+ };
38
+
39
+ export default ItemSectionList;