@momo-kits/foundation 0.75.1-beta.9 → 0.75.3-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 (113) hide show
  1. package/Application/BottomSheet.tsx +225 -0
  2. package/Application/BottomTab/BottomTabBar.tsx +291 -0
  3. package/Application/BottomTab/index.tsx +138 -0
  4. package/Application/Components.tsx +555 -0
  5. package/Application/ModalScreen.tsx +97 -0
  6. package/Application/Navigation.ts +50 -0
  7. package/Application/NavigationContainer.tsx +121 -0
  8. package/Application/Navigator.ts +151 -0
  9. package/Application/StackScreen.tsx +148 -0
  10. package/Application/index.ts +37 -0
  11. package/{Navigation → Application}/types.ts +101 -33
  12. package/Application/utils.tsx +153 -0
  13. package/Assets/DotAnimation.json +256 -0
  14. package/Assets/SpinnerAnimation.json +1027 -0
  15. package/Assets/icon.json +89 -5
  16. package/Assets/icon_bank.json +506 -0
  17. package/Assets/language.json +202 -0
  18. package/Badge/Badge.tsx +56 -0
  19. package/Badge/BadgeDot.tsx +11 -0
  20. package/Badge/BadgeRibbon.tsx +125 -0
  21. package/Badge/Shape.tsx +29 -0
  22. package/Badge/index.tsx +7 -0
  23. package/Badge/styles.ts +58 -0
  24. package/Badge/types.ts +63 -0
  25. package/Button/index.tsx +91 -40
  26. package/Button/styles.ts +19 -0
  27. package/CheckBox/index.tsx +58 -43
  28. package/CheckBox/styles.ts +1 -1
  29. package/CheckBox/types.ts +6 -4
  30. package/Consts/colors+spacing+radius.ts +18 -0
  31. package/Consts/styles.ts +0 -26
  32. package/Consts/theme.ts +5 -1
  33. package/Divider/index.tsx +3 -1
  34. package/Icon/index.tsx +15 -10
  35. package/Icon/types.ts +4 -3
  36. package/IconButton/index.tsx +24 -15
  37. package/Image/index.tsx +63 -45
  38. package/Image/styles.ts +1 -9
  39. package/Image/types.ts +5 -1
  40. package/Input/Input.tsx +227 -115
  41. package/Input/InputDropDown.tsx +132 -0
  42. package/Input/InputMoney.tsx +173 -110
  43. package/Input/InputOTP.tsx +257 -0
  44. package/Input/InputSearch.tsx +160 -130
  45. package/Input/InputTextArea.tsx +149 -121
  46. package/Input/common.tsx +36 -18
  47. package/Input/index.tsx +212 -17
  48. package/Input/styles.ts +44 -7
  49. package/Input/utils.ts +2 -2
  50. package/Layout/Card.tsx +76 -37
  51. package/Layout/FloatingButton.tsx +168 -0
  52. package/Layout/GridSystem.tsx +35 -23
  53. package/Layout/Item.tsx +29 -33
  54. package/Layout/ItemList.tsx +55 -0
  55. package/Layout/ItemSectionList.tsx +39 -0
  56. package/Layout/Screen.tsx +390 -0
  57. package/Layout/Section.tsx +73 -35
  58. package/Layout/index.ts +13 -3
  59. package/Layout/styles.ts +101 -0
  60. package/Layout/types.ts +1 -37
  61. package/Layout/utils.ts +38 -43
  62. package/Loader/DotLoader.tsx +37 -0
  63. package/Loader/Loader.tsx +13 -0
  64. package/Loader/ProgressBar.tsx +44 -0
  65. package/Loader/Spinner.tsx +29 -0
  66. package/Loader/index.tsx +4 -0
  67. package/Loader/styles.ts +10 -0
  68. package/Loader/types.ts +35 -0
  69. package/Loader/utils.ts +25 -0
  70. package/Pagination/Dot.tsx +1 -1
  71. package/Pagination/PaginationDot.tsx +8 -3
  72. package/Pagination/PaginationNumber.tsx +8 -7
  73. package/Pagination/PaginationScroll.tsx +1 -1
  74. package/Pagination/PaginationWhiteDot.tsx +8 -5
  75. package/Pagination/styles.ts +3 -0
  76. package/Pagination/types.ts +2 -0
  77. package/Popup/PopupNotify.tsx +108 -46
  78. package/Popup/PopupPromotion.tsx +63 -22
  79. package/Popup/types.ts +15 -4
  80. package/Radio/index.tsx +35 -21
  81. package/Radio/types.ts +7 -5
  82. package/Skeleton/index.tsx +1 -1
  83. package/Skeleton/types.ts +3 -0
  84. package/Switch/index.tsx +35 -24
  85. package/Switch/types.ts +5 -3
  86. package/Tag/index.tsx +1 -1
  87. package/Text/index.tsx +32 -26
  88. package/Text/styles.ts +38 -0
  89. package/Text/types.ts +25 -13
  90. package/Text/utils.ts +14 -0
  91. package/Title/index.tsx +197 -0
  92. package/Title/styles.ts +79 -0
  93. package/Title/types.ts +20 -0
  94. package/code-scanner.js +143 -0
  95. package/index.ts +22 -2
  96. package/migrate_typo.js +56 -0
  97. package/package.json +44 -39
  98. package/publish.sh +2 -5
  99. package/tsconfig.json +24 -0
  100. package/verify.js +47 -0
  101. package/Assets/header-background.png +0 -0
  102. package/Layout/ScreenContainer.tsx +0 -121
  103. package/Navigation/BottomTab.tsx +0 -39
  104. package/Navigation/Components.tsx +0 -365
  105. package/Navigation/ModalScreen.tsx +0 -226
  106. package/Navigation/Navigation.ts +0 -44
  107. package/Navigation/NavigationButton.tsx +0 -54
  108. package/Navigation/NavigationContainer.tsx +0 -77
  109. package/Navigation/Navigator.ts +0 -82
  110. package/Navigation/Observer.ts +0 -79
  111. package/Navigation/StackScreen.tsx +0 -27
  112. package/Navigation/index.ts +0 -14
  113. package/Navigation/utils.tsx +0 -137
@@ -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
+ });
@@ -1,23 +1,29 @@
1
1
  import React, {useContext} from 'react';
2
2
  import {useSafeAreaInsets} from 'react-native-safe-area-context';
3
3
  import {Dimensions, StyleSheet, View} from 'react-native';
4
- import {ApplicationContext} from '../Navigation';
4
+ import {ApplicationContext} from '../Application';
5
5
  import {Colors, Spacing} from '../Consts';
6
6
  import {GridContextProps} from './types';
7
+ import {useGridSystem} from './utils';
7
8
 
8
- const GridSystem: React.FC = () => {
9
+ const GridSystem: React.FC<any> = ({
10
+ width = Dimensions.get('window').width,
11
+ useMargin = true,
12
+ gutterSize = Spacing.M,
13
+ screenGrid = true,
14
+ gridColor = Colors.blue_07,
15
+ }) => {
9
16
  const {theme} = useContext(ApplicationContext);
10
- const numberOfColumns = 12;
11
- const gutterSize = 12;
12
- const margin = 12;
13
- const widthSection = Dimensions.get('window').width - margin * 2;
17
+ const {numberOfColumns} = useGridSystem();
18
+
19
+ const margin = useMargin ? Spacing.M : 0;
20
+ const widthSection = width - margin * 2;
14
21
  const totalGutterSize = gutterSize * (numberOfColumns - 1);
15
22
  const sizePerSpan = (widthSection - totalGutterSize) / numberOfColumns;
16
23
 
17
24
  const grid: GridContextProps = {
18
25
  numberOfColumns,
19
26
  gutterSize,
20
- margin,
21
27
  sizePerSpan,
22
28
  getSizeSpan: span => {
23
29
  return span * sizePerSpan + (span - 1) * gutterSize;
@@ -25,7 +31,7 @@ const GridSystem: React.FC = () => {
25
31
  };
26
32
  const insets = useSafeAreaInsets();
27
33
 
28
- const list = [];
34
+ const list: number[] = [];
29
35
  for (let i = 1; i <= grid.numberOfColumns; i++) {
30
36
  list.push(i);
31
37
  }
@@ -36,23 +42,26 @@ const GridSystem: React.FC = () => {
36
42
  pointerEvents="none"
37
43
  style={[
38
44
  styles.gridContainer,
39
- insets,
45
+ screenGrid && insets,
40
46
  {
41
47
  borderColor: theme.colors.error.primary,
42
- marginHorizontal: grid.margin,
48
+ marginHorizontal: margin,
49
+ top: Spacing.M,
50
+ bottom: Spacing.M,
43
51
  },
44
52
  ]}>
45
- {list.map((i, index) => {
53
+ {list.map((_, index) => {
46
54
  return (
47
55
  <View style={{flexDirection: 'row'}} key={index.toString()}>
48
56
  {index != -0 && <View style={{width: grid.gutterSize}} />}
49
57
  <View
50
- key={index.toString()}
58
+ key={`Grid${index.toString()}`}
51
59
  pointerEvents="none"
52
60
  style={[
53
61
  styles.gridColumn,
54
62
  {
55
63
  width: grid.sizePerSpan,
64
+ backgroundColor: gridColor,
56
65
  },
57
66
  ]}
58
67
  />
@@ -60,16 +69,20 @@ const GridSystem: React.FC = () => {
60
69
  );
61
70
  })}
62
71
  </View>
63
- <View pointerEvents="none" style={styles.dangerLeftContainer} />
64
- <View pointerEvents="none" style={styles.dangerRightContainer} />
65
- <View
66
- pointerEvents="none"
67
- style={[styles.dangerTopContainer, {height: insets.top}]}
68
- />
69
- <View
70
- pointerEvents="none"
71
- style={[styles.dangerBottomContainer, {height: insets.bottom}]}
72
- />
72
+ {screenGrid && (
73
+ <>
74
+ <View pointerEvents="none" style={styles.dangerLeftContainer} />
75
+ <View pointerEvents="none" style={styles.dangerRightContainer} />
76
+ <View
77
+ pointerEvents="none"
78
+ style={[styles.dangerTopContainer, {height: Spacing.M}]}
79
+ />
80
+ <View
81
+ pointerEvents="none"
82
+ style={[styles.dangerBottomContainer, {height: insets.bottom}]}
83
+ />
84
+ </>
85
+ )}
73
86
  </>
74
87
  );
75
88
  };
@@ -87,7 +100,6 @@ const styles = StyleSheet.create({
87
100
  gridColumn: {
88
101
  height: '100%',
89
102
  opacity: 0.2,
90
- backgroundColor: Colors.blue_07,
91
103
  },
92
104
  dangerTopContainer: {
93
105
  opacity: 0.2,
package/Layout/Item.tsx CHANGED
@@ -1,56 +1,52 @@
1
1
  import React, {useContext} from 'react';
2
- import {View} from 'react-native';
2
+ import {View, ViewProps} from 'react-native';
3
3
 
4
- import {ItemProps} from './types';
5
4
  import {GridContext} from './index';
6
- import {GRIDVIEW} from '../Consts';
5
+ import {ApplicationContext} from '../Application';
6
+ import styles from './styles';
7
+
8
+ export type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
9
+
10
+ export interface ItemProps extends ViewProps {
11
+ /**
12
+ * Represents the width of the Card component in terms of span numbers (1-12).
13
+ */
14
+ widthSpan?: SpanNumber;
15
+
16
+ /**
17
+ * Optional. Represents the height of the Card component in terms of span numbers (1-12).
18
+ */
19
+ heightSpan?: SpanNumber;
20
+ }
7
21
 
8
22
  const Item: React.FC<ItemProps> = ({
9
- widthSpan = 12,
23
+ widthSpan,
10
24
  heightSpan,
11
25
  children,
12
26
  style,
13
27
  }) => {
28
+ const {showGrid} = useContext(ApplicationContext);
14
29
  const grid = useContext(GridContext);
15
30
 
16
31
  /**
17
32
  * render overlay view only dev mode
18
33
  */
19
34
  const renderOverlay = () => {
20
- return (
21
- <View
22
- pointerEvents={'none'}
23
- style={{
24
- position: 'absolute',
25
- top: 0,
26
- bottom: 0,
27
- left: 0,
28
- right: 0,
29
- borderColor: 'red',
30
- borderWidth: 1,
31
- }}
32
- />
33
- );
35
+ return <View pointerEvents={'none'} style={styles.boxGrid} />;
34
36
  };
35
37
 
36
- const styles: any = style ?? {};
37
-
38
38
  return (
39
39
  <View
40
- accessibilityLabel={`Item`}
41
- style={{
42
- ...styles,
43
- width: grid.getSizeSpan(widthSpan),
44
- height: heightSpan ? grid.getSizeSpan(heightSpan) : undefined,
45
- overflow: 'hidden',
46
- margin: undefined,
47
- marginTop: undefined,
48
- marginBottom: undefined,
49
- marginLeft: undefined,
50
- marginRight: undefined,
51
- }}>
40
+ style={[
41
+ style,
42
+ styles.item,
43
+ {
44
+ width: grid.getSizeSpan(widthSpan ?? grid.numberOfColumns),
45
+ height: heightSpan ? grid.getSizeSpan(heightSpan) : undefined,
46
+ },
47
+ ]}>
52
48
  {children}
53
- {GRIDVIEW && renderOverlay()}
49
+ {showGrid && renderOverlay()}
54
50
  </View>
55
51
  );
56
52
  };
@@ -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;