@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
@@ -7,6 +7,7 @@ import Item from './Item';
7
7
  import {ApplicationContext} from '../Application';
8
8
  import styles from './styles';
9
9
  import {Image} from '../Image';
10
+ import ItemList from './ItemList';
10
11
 
11
12
  export interface SectionProps extends ViewProps {
12
13
  /**
@@ -21,11 +22,6 @@ export interface SectionProps extends ViewProps {
21
22
  */
22
23
  useMargin?: boolean;
23
24
 
24
- /**
25
- * Optional. Background color for the Section component.
26
- */
27
- backgroundColor?: string;
28
-
29
25
  /**
30
26
  * Optional. Background image for the Section component.
31
27
  */
@@ -35,8 +31,9 @@ export interface SectionProps extends ViewProps {
35
31
  const Section: React.FC<SectionProps> = ({
36
32
  children,
37
33
  useMargin = true,
38
- backgroundColor,
39
34
  backgroundImage,
35
+ style,
36
+ ...props
40
37
  }) => {
41
38
  const {showGrid} = useContext(ApplicationContext);
42
39
  const {numberOfColumns} = useGridSystem();
@@ -54,7 +51,6 @@ const Section: React.FC<SectionProps> = ({
54
51
  const gridContext: GridContextProps = {
55
52
  numberOfColumns,
56
53
  gutterSize,
57
- margin,
58
54
  sizePerSpan,
59
55
  getSizeSpan: span => {
60
56
  return span * sizePerSpan + (span - 1) * gutterSize;
@@ -89,7 +85,7 @@ const Section: React.FC<SectionProps> = ({
89
85
  {rows.map((i: React.ReactElement, index: number) => {
90
86
  return (
91
87
  <View key={`Card${cursor}${index}`} style={{flexDirection: 'row'}}>
92
- {index != 0 && (
88
+ {index !== 0 && (
93
89
  <View style={{width: gridContext.gutterSize}}></View>
94
90
  )}
95
91
  {i}
@@ -111,8 +107,9 @@ const Section: React.FC<SectionProps> = ({
111
107
  if (Array.isArray(children)) {
112
108
  let cursor = 0;
113
109
  let rows: any[] = [];
114
- for (let i = 0; i < children.length; ++i) {
115
- const item = children[i];
110
+ const arrayChild = children.filter(item => !!item);
111
+ for (let i = 0; i < arrayChild.length; ++i) {
112
+ const item = arrayChild[i];
116
113
  const totalSpan = rows
117
114
  .concat([item])
118
115
  .map(i => i.props?.widthSpan)
@@ -128,14 +125,14 @@ const Section: React.FC<SectionProps> = ({
128
125
  rows = [item];
129
126
  }
130
127
 
131
- if (i == children.length - 1) {
128
+ if (i === arrayChild.length - 1) {
132
129
  cursor += 1;
133
130
  element.push(addRowView(rows, cursor, true));
134
131
  }
135
132
  }
136
133
  } else {
137
134
  element.push(children);
138
- if (children?.type == Fragment) {
135
+ if (children?.type === Fragment) {
139
136
  return renderView(children?.props.children);
140
137
  }
141
138
  }
@@ -147,28 +144,31 @@ const Section: React.FC<SectionProps> = ({
147
144
  value={{
148
145
  numberOfColumns,
149
146
  gutterSize,
150
- margin,
151
147
  sizePerSpan,
152
148
  getSizeSpan: span => {
153
149
  return span * sizePerSpan + (span - 1) * gutterSize;
154
150
  },
155
151
  }}>
156
152
  <View
157
- accessibilityLabel={`Section`}
158
- style={{
159
- width: widthSection,
160
- marginHorizontal: gridContext.margin,
161
- flexDirection: 'row',
162
- flexWrap: 'wrap',
163
- backgroundColor: backgroundColor,
164
- }}>
153
+ {...props}
154
+ onLayout={undefined}
155
+ style={[
156
+ style,
157
+ styles.protectedStyle,
158
+ {
159
+ width: widthSection,
160
+ marginHorizontal: margin,
161
+ flexDirection: 'row',
162
+ flexWrap: 'wrap',
163
+ },
164
+ ]}>
165
165
  {!!backgroundImage && (
166
166
  <Image
167
167
  source={{uri: backgroundImage}}
168
168
  style={styles.imageBackground}
169
169
  />
170
170
  )}
171
- {renderView(validateChildren(children, [Item]))}
171
+ {renderView(validateChildren(children, [Item, ItemList]))}
172
172
  {showGrid && renderOverlay()}
173
173
  </View>
174
174
  </GridContext.Provider>
@@ -0,0 +1,114 @@
1
+ import React, {FC, memo, useEffect, useRef} from 'react';
2
+ import {
3
+ InteractionManager,
4
+ StyleSheet,
5
+ TextInput,
6
+ TextStyle,
7
+ } from 'react-native';
8
+ import {Colors} from '../Consts';
9
+ import {scaleSize} from '../Text';
10
+
11
+ export interface TextTypingProps {
12
+ data: string[];
13
+ timeDelayEnd?: number;
14
+ timeDelayNextChar?: number;
15
+ inputStyle?: TextStyle;
16
+ }
17
+
18
+ const TextTyping: FC<TextTypingProps> = ({
19
+ data = [],
20
+ timeDelayEnd = 2000,
21
+ timeDelayNextChar = 20,
22
+ inputStyle = {},
23
+ }) => {
24
+ const textRef = useRef<TextInput>(null);
25
+
26
+ const currentIndex = useRef<number>(0);
27
+ const currentCharIndex = useRef<number>(0);
28
+ const currentText = useRef('');
29
+
30
+ useEffect(() => {
31
+ setTimeout(() => {
32
+ InteractionManager.runAfterInteractions();
33
+ playAnimation();
34
+ }, 1000);
35
+ }, []);
36
+
37
+ const playAnimation = () => {
38
+ const handleResetList = () => {
39
+ currentIndex.current = 0;
40
+ handleAnimation();
41
+ };
42
+
43
+ const handleAnimation = () => {
44
+ const listChar = data?.[currentIndex.current]?.split('') || [];
45
+ listChar.length !== 0 && showChar(listChar?.[currentCharIndex.current]);
46
+ };
47
+
48
+ currentIndex.current >= data?.length
49
+ ? handleResetList()
50
+ : handleAnimation();
51
+ };
52
+
53
+ const showChar = (char?: string) => {
54
+ const handleResetString = () => {
55
+ setTimeout(() => {
56
+ reset();
57
+ }, timeDelayEnd);
58
+ };
59
+
60
+ const handleShowChar = () => {
61
+ setTimeout(() => {
62
+ textRef.current?.setNativeProps?.({
63
+ text: currentText.current + char,
64
+ });
65
+ currentText.current += char;
66
+ currentCharIndex.current++;
67
+ playAnimation();
68
+ }, timeDelayNextChar);
69
+ };
70
+
71
+ currentCharIndex.current >= (data?.[currentIndex.current]?.length || 0)
72
+ ? handleResetString()
73
+ : handleShowChar();
74
+ };
75
+
76
+ const reset = () => {
77
+ const handleNextString = () => {
78
+ currentIndex.current++;
79
+ playAnimation();
80
+ };
81
+
82
+ const handleReset = () => {
83
+ setTimeout(() => {
84
+ textRef.current?.setNativeProps?.({
85
+ text: currentText.current.slice(0, -1),
86
+ });
87
+ currentText.current = currentText.current.slice(0, -1);
88
+ currentCharIndex.current--;
89
+ reset();
90
+ }, timeDelayNextChar);
91
+ };
92
+
93
+ currentCharIndex.current <= 0 ? handleNextString() : handleReset();
94
+ };
95
+
96
+ return (
97
+ <TextInput
98
+ style={[styles.inputStyle, inputStyle]}
99
+ ref={textRef}
100
+ editable={false}
101
+ autoCorrect={false}
102
+ pointerEvents={'none'}
103
+ />
104
+ );
105
+ };
106
+
107
+ export default memo(TextTyping);
108
+
109
+ const styles = StyleSheet.create({
110
+ inputStyle: {
111
+ color: Colors.black_12,
112
+ fontSize: scaleSize(12),
113
+ },
114
+ });
package/Layout/index.ts CHANGED
@@ -5,13 +5,23 @@ import {validateChildren} from './utils';
5
5
  import {createContext} from 'react';
6
6
  import {GridContextProps} from './types';
7
7
  import Item from './Item';
8
+ import ItemList from './ItemList';
9
+ import ItemSectionList from './ItemSectionList';
8
10
 
9
11
  const GridContext = createContext<GridContextProps>({
10
12
  numberOfColumns: 12,
11
13
  gutterSize: 12,
12
- margin: 12,
13
14
  sizePerSpan: 0,
14
15
  getSizeSpan: () => 0,
15
16
  });
16
17
 
17
- export {GridContext, Card, Section, GridSystem, validateChildren, Item};
18
+ export {
19
+ GridContext,
20
+ Card,
21
+ Section,
22
+ GridSystem,
23
+ validateChildren,
24
+ Item,
25
+ ItemList,
26
+ ItemSectionList,
27
+ };
package/Layout/styles.ts CHANGED
@@ -1,6 +1,16 @@
1
- import {StyleSheet} from 'react-native';
1
+ import {Platform, StyleSheet} from 'react-native';
2
+ import {Colors, Radius, Spacing} from '../Consts';
2
3
 
3
4
  export default StyleSheet.create({
5
+ extendedHeader: {
6
+ aspectRatio: 1.75,
7
+ position: 'absolute',
8
+ width: '100%',
9
+ height: 210,
10
+ },
11
+ screenBanner: {
12
+ width: '100%',
13
+ },
4
14
  boxGrid: {
5
15
  position: 'absolute',
6
16
  top: 0,
@@ -34,19 +44,8 @@ export default StyleSheet.create({
34
44
  card: {
35
45
  flexDirection: 'row',
36
46
  flexWrap: 'wrap',
37
- paddingTop: undefined,
38
- paddingBottom: undefined,
39
- paddingLeft: undefined,
40
- paddingRight: undefined,
41
- paddingVertical: undefined,
42
- paddingHorizontal: undefined,
47
+ borderRadius: Radius.M,
43
48
  padding: 12,
44
- margin: undefined,
45
- marginTop: undefined,
46
- marginBottom: undefined,
47
- marginLeft: undefined,
48
- marginRight: undefined,
49
- marginVertical: undefined,
50
49
  },
51
50
  item: {
52
51
  overflow: 'hidden',
@@ -65,4 +64,38 @@ export default StyleSheet.create({
65
64
  left: 0,
66
65
  right: 0,
67
66
  },
67
+ protectedStyle: {
68
+ marginTop: undefined,
69
+ marginBottom: undefined,
70
+ marginLeft: undefined,
71
+ marginRight: undefined,
72
+ paddingTop: undefined,
73
+ paddingBottom: undefined,
74
+ paddingLeft: undefined,
75
+ paddingRight: undefined,
76
+ padding: undefined,
77
+ margin: undefined,
78
+ marginHorizontal: undefined,
79
+ marginVertical: undefined,
80
+ paddingHorizontal: undefined,
81
+ paddingVertical: undefined,
82
+ },
83
+ shadow: {
84
+ paddingTop: Spacing.S,
85
+ ...Platform.select({
86
+ ios: {
87
+ shadowColor: Colors.black_17,
88
+ shadowOffset: {
89
+ width: 2,
90
+ height: 2,
91
+ },
92
+ shadowOpacity: 0.25,
93
+ shadowRadius: 10,
94
+ },
95
+ android: {
96
+ shadowColor: Colors.black_20,
97
+ elevation: 24,
98
+ },
99
+ }),
100
+ },
68
101
  });
package/Layout/types.ts CHANGED
@@ -1,3 +1,8 @@
1
+ import {Animated} from 'react-native';
2
+ import {InputSearchProps} from '../Input';
3
+
4
+ export type HeaderType = 'default' | 'surface' | 'extended' | 'search' | 'none';
5
+
1
6
  export type GridContextProps = {
2
7
  /**
3
8
  * Represents the number of columns in the grid.
@@ -9,11 +14,6 @@ export type GridContextProps = {
9
14
  */
10
15
  gutterSize: number;
11
16
 
12
- /**
13
- * Optional. Represents the margin around the grid.
14
- */
15
- margin?: number;
16
-
17
17
  /**
18
18
  * Represents the size (width or height) per span number.
19
19
  */
@@ -24,3 +24,11 @@ export type GridContextProps = {
24
24
  */
25
25
  getSizeSpan: (span: number) => number;
26
26
  };
27
+
28
+ export type AnimatedInputSearchProps = {
29
+ animatedValue: Animated.Value;
30
+ headerRightWidth: number;
31
+ heightHeader: number;
32
+ headerType: HeaderType;
33
+ inputSearchProps?: InputSearchProps;
34
+ };
package/Layout/utils.ts CHANGED
@@ -1,5 +1,5 @@
1
- import {Alert, Dimensions} from 'react-native';
2
1
  import React, {Fragment, ReactElement, useEffect, useState} from 'react';
2
+ import {Dimensions} from 'react-native';
3
3
 
4
4
  /**
5
5
  * validate children type
@@ -8,25 +8,20 @@ import React, {Fragment, ReactElement, useEffect, useState} from 'react';
8
8
  */
9
9
  const validateChildren = (
10
10
  children: React.ReactNode | React.ReactNode[],
11
- childrenTypes: Array<React.FC>,
11
+ childrenTypes: Array<React.ReactNode>,
12
12
  ) => {
13
- if (!__DEV__) return children;
14
-
15
13
  const validateType = (child: React.ReactElement) => {
16
14
  const valid = childrenTypes.some(
17
- childrenType => child?.type === childrenType || child?.type == Fragment,
15
+ childrenType => child?.type === childrenType || child?.type === Fragment,
18
16
  );
19
17
  if (!valid) {
20
- Alert.alert(
21
- 'Component Kits',
18
+ console.warn(
22
19
  `Wrong children type for this component, expected are ${childrenTypes
23
- .map(type => type.displayName)
20
+ .map(item => item)
24
21
  .join(', ')}.`,
25
22
  );
26
23
  }
27
- return valid;
28
24
  };
29
-
30
25
  if (Array.isArray(children)) {
31
26
  const flattenChildren: React.ReactElement[] = children.flat();
32
27
  for (const child of flattenChildren) {
@@ -47,7 +42,7 @@ const useGridSystem = () => {
47
42
  useEffect(() => {
48
43
  const subscription: any = Dimensions.addEventListener('change', () => {
49
44
  const newColumns = Dimensions.get('window').width > 600 ? 24 : 12;
50
- if (newColumns != numberOfColumns) {
45
+ if (newColumns !== numberOfColumns) {
51
46
  setNumberOfColumns(newColumns);
52
47
  }
53
48
  });
@@ -57,4 +52,4 @@ const useGridSystem = () => {
57
52
  return {numberOfColumns};
58
53
  };
59
54
 
60
- export {validateChildren, useGridSystem};
55
+ export {useGridSystem, validateChildren};
package/Loader/index.tsx CHANGED
@@ -1,4 +1,6 @@
1
1
  import Loader from './Loader';
2
2
  import ProgressBar from './ProgressBar';
3
+ import {LoaderProps, ProgressBarProps} from './types';
3
4
 
4
5
  export {Loader, ProgressBar};
6
+ export type {LoaderProps, ProgressBarProps};
@@ -9,6 +9,7 @@ import {ApplicationContext} from '../Application';
9
9
  const PaginationDot: FC<ChildPaginationProps> = ({
10
10
  dataLength = 2,
11
11
  activeIndex = 0,
12
+ style,
12
13
  }) => {
13
14
  const {theme} = useContext(ApplicationContext);
14
15
  const renderDots = () => {
@@ -27,7 +28,11 @@ const PaginationDot: FC<ChildPaginationProps> = ({
27
28
  }
28
29
  return dots;
29
30
  };
30
- return <View style={styles.paginationPinkContainer}>{renderDots()}</View>;
31
+ return (
32
+ <View style={[style, styles.row]}>
33
+ <View style={styles.paginationPinkContainer}>{renderDots()}</View>
34
+ </View>
35
+ );
31
36
  };
32
37
 
33
38
  export default PaginationDot;
@@ -8,12 +8,15 @@ import {Colors} from '../Consts';
8
8
  const PaginationNumber: FC<ChildPaginationProps> = ({
9
9
  activeIndex = 0,
10
10
  dataLength = 2,
11
+ style,
11
12
  }) => {
12
13
  return (
13
- <View style={[styles.paginationNumberContainer]}>
14
- <Text color={Colors.black_01} typography={'label_default'}>{`${
15
- activeIndex + 1
16
- }/${dataLength}`}</Text>
14
+ <View style={[style, styles.row]}>
15
+ <View style={styles.paginationNumberContainer}>
16
+ <Text color={Colors.black_01} typography={'label_default_medium'}>{`${
17
+ activeIndex + 1
18
+ }/${dataLength}`}</Text>
19
+ </View>
17
20
  </View>
18
21
  );
19
22
  };
@@ -31,7 +31,6 @@ const PaginationScroll: FC<ScrollIndicatorProps> = ({
31
31
  const renderScrollView = () => {
32
32
  return (
33
33
  <Animated.ScrollView
34
- accessibilityLabel={'PaginationScroll'}
35
34
  ref={scrollViewRef}
36
35
  onScroll={Animated.event(
37
36
  [
@@ -8,6 +8,7 @@ import {Colors, Spacing} from '../Consts';
8
8
  const PaginationWhiteDot: FC<ChildPaginationProps> = ({
9
9
  dataLength = 2,
10
10
  activeIndex = 0,
11
+ style,
11
12
  }) => {
12
13
  const renderDots = () => {
13
14
  const dots: React.ReactElement[] = [];
@@ -24,7 +25,11 @@ const PaginationWhiteDot: FC<ChildPaginationProps> = ({
24
25
  }
25
26
  return dots;
26
27
  };
27
- return <View style={[styles.paginationWhiteContainer]}>{renderDots()}</View>;
28
+ return (
29
+ <View style={[style, styles.row]}>
30
+ <View style={styles.paginationWhiteContainer}>{renderDots()}</View>
31
+ </View>
32
+ );
28
33
  };
29
34
 
30
35
  export default PaginationWhiteDot;
@@ -25,6 +25,8 @@ export default StyleSheet.create({
25
25
  paddingHorizontal: Spacing.S,
26
26
  borderRadius: Radius.L,
27
27
  backgroundColor: Colors.black_20 + '33',
28
+ alignItems: 'center',
29
+ justifyContent: 'center',
28
30
  },
29
31
  scrollContainer: {
30
32
  alignItems: 'center',
@@ -44,4 +46,5 @@ export default StyleSheet.create({
44
46
  height: 4,
45
47
  borderRadius: Radius.XS,
46
48
  },
49
+ row: {flexDirection: 'row'},
47
50
  });
@@ -20,6 +20,8 @@ export type PaginationProps = {
20
20
  * Represents the total number of items (pages) in the Pagination component.
21
21
  */
22
22
  dataLength: number;
23
+
24
+ style?: ViewStyle | ViewStyle[];
23
25
  };
24
26
 
25
27
  export type DotProps = {