@momo-kits/foundation 0.77.2 → 0.77.4

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.
@@ -1,14 +1,14 @@
1
- import React, {FC, useContext} from 'react';
1
+ import React, {useContext} from 'react';
2
+ import {View} from 'react-native';
2
3
  import {BottomTabProps} from './types';
3
4
  import {createBottomTabNavigator} from '@react-navigation/bottom-tabs';
4
5
  import {Icon} from '../Icon';
5
6
  import {Text} from '../Text';
6
7
  import {ApplicationContext} from './index';
7
- import {View} from 'react-native';
8
8
 
9
9
  const Tab = createBottomTabNavigator();
10
10
 
11
- const BottomTab: FC<BottomTabProps> = ({tabs, listeners}) => {
11
+ const BottomTab: React.FC<BottomTabProps> = ({tabs, listeners}) => {
12
12
  const {theme} = useContext(ApplicationContext);
13
13
  return (
14
14
  <Tab.Navigator>
@@ -77,7 +77,7 @@ const styles = StyleSheet.create({
77
77
  },
78
78
  });
79
79
 
80
- const HeaderTitle: React.FC<any> = props => {
80
+ const HeaderTitle: React.FC<any> = ({accessibilityLabel = '', ...props}) => {
81
81
  const {theme} = useContext(ApplicationContext);
82
82
  const opacity = props.animatedValue?.interpolate({
83
83
  inputRange: [0, 200],
@@ -88,7 +88,7 @@ const HeaderTitle: React.FC<any> = props => {
88
88
  return (
89
89
  <Animated.Text
90
90
  {...props}
91
- accessibilityLabel={`HeaderTitle/${props.children}`}
91
+ accessibilityLabel={`HeaderTitle/${accessibilityLabel}${props.children}`}
92
92
  style={[
93
93
  styles.title,
94
94
  {fontFamily: `${theme.font}-Bold`, opacity, color: props.tintColor},
@@ -102,6 +102,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
102
102
  preventBack,
103
103
  useBorder,
104
104
  backgroundColor,
105
+ accessibilityLabel = '',
105
106
  }) => {
106
107
  const {navigator} = useContext(ApplicationContext);
107
108
  const goBack = () => {
@@ -138,7 +139,7 @@ const HeaderLeft: React.FC<HeaderBackProps> = ({
138
139
  icon="ic_back"
139
140
  tintColor={tintColor}
140
141
  onPress={goBack}
141
- accessibilityLabel={'Back'}
142
+ accessibilityLabel={`${accessibilityLabel}Back`}
142
143
  useBorder={useBorder}
143
144
  backgroundColor={backgroundColor}
144
145
  />
@@ -18,7 +18,7 @@ import {
18
18
  NavigationButton,
19
19
  NavigationContainer,
20
20
  } from './index';
21
- import {HeaderBackground, HeaderLeft} from './Components';
21
+ import {HeaderBackground, HeaderLeft, HeaderTitle} from './Components';
22
22
 
23
23
  const ModalScreen: React.FC<any> = props => {
24
24
  useEffect(() => {
@@ -160,10 +160,19 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
160
160
  {...props}
161
161
  useBorder={false}
162
162
  backgroundColor="transparent"
163
+ accessibilityLabel={'BottomSheet/'}
163
164
  />
164
165
  );
165
166
  }
166
167
  },
168
+ headerTitle: (props: any) => {
169
+ return (
170
+ <HeaderTitle
171
+ {...props}
172
+ accessibilityLabel={'BottomSheet/'}
173
+ />
174
+ );
175
+ },
167
176
  headerBackground: () => (
168
177
  <HeaderBackground backgroundColor={backgroundColor} />
169
178
  ),
@@ -178,6 +187,7 @@ const BottomSheet: React.FC<BottomSheetParams> = props => {
178
187
  backgroundColor="transparent"
179
188
  useBorder={false}
180
189
  onPress={bottomSheetRef.current?.dismiss}
190
+ accessibilityLabel={'BottomSheet/Close'}
181
191
  />
182
192
  </HeaderRightAction>
183
193
  ),
@@ -1,4 +1,4 @@
1
- import React, {useRef} from 'react';
1
+ import React, {useEffect, useRef, useState} from 'react';
2
2
  import {BottomSheetModalProvider} from '@gorhom/bottom-sheet';
3
3
  import {SafeAreaProvider} from 'react-native-safe-area-context';
4
4
  import {
@@ -10,10 +10,9 @@ import StackScreen from './StackScreen';
10
10
  import ModalScreen from './ModalScreen';
11
11
  import Navigator from './Navigator';
12
12
  import {getDialogOptions, getModalOptions, getStackOptions} from './utils';
13
- import {GridSystem} from '../Layout';
14
- import {GRIDVIEW} from '../Consts';
15
13
  import {NavigationContainerProps} from './types';
16
14
  import {ApplicationContext} from './index';
15
+ import {DeviceEventEmitter} from 'react-native';
17
16
 
18
17
  const Stack = createStackNavigator();
19
18
 
@@ -25,13 +24,27 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
25
24
  }) => {
26
25
  const navigationRef = React.useRef<NavigationContainerRef>(null);
27
26
  const navigator = useRef(new Navigator(navigationRef));
27
+ const [showGrid, setShowGrid] = useState(false);
28
+
29
+ useEffect(() => {
30
+ const subscription = DeviceEventEmitter.addListener(
31
+ 'onChangeGrid',
32
+ enable => {
33
+ setShowGrid(!!enable);
34
+ },
35
+ );
36
+ return () => {
37
+ subscription.remove();
38
+ };
39
+ }, []);
40
+
28
41
  navigator.current.maxApi = maxApi;
29
42
 
30
43
  return (
31
44
  <SafeAreaProvider>
32
45
  <BottomSheetModalProvider>
33
46
  <ApplicationContext.Provider
34
- value={{theme, navigator: navigator.current}}>
47
+ value={{theme, navigator: navigator.current, showGrid}}>
35
48
  <ReactNavigationContainer
36
49
  theme={{
37
50
  ...theme,
@@ -69,7 +82,6 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
69
82
  </ReactNavigationContainer>
70
83
  </ApplicationContext.Provider>
71
84
  </BottomSheetModalProvider>
72
- {GRIDVIEW && <GridSystem />}
73
85
  </SafeAreaProvider>
74
86
  );
75
87
  };
@@ -2,10 +2,11 @@ import React, {useContext, useEffect} from 'react';
2
2
  import {ScreenParams} from './types';
3
3
  import Navigation from './Navigation';
4
4
  import {ApplicationContext} from './index';
5
+ import {GridSystem} from '../Layout';
5
6
 
6
7
  const StackScreen: React.FC<ScreenParams> = props => {
7
8
  const {screen: Component, options}: ScreenParams = props.route.params;
8
- const {theme, navigator} = useContext(ApplicationContext);
9
+ const {theme, showGrid, navigator} = useContext(ApplicationContext);
9
10
  const navigation = new Navigation(props.navigation, theme);
10
11
 
11
12
  const params = {
@@ -21,7 +22,12 @@ const StackScreen: React.FC<ScreenParams> = props => {
21
22
  }
22
23
  }, [options]);
23
24
 
24
- return <Component {...params} />;
25
+ return (
26
+ <>
27
+ <Component {...params} />
28
+ {showGrid && <GridSystem />}
29
+ </>
30
+ );
25
31
  };
26
32
 
27
33
  export default StackScreen;
@@ -4,6 +4,8 @@ import Navigator from './Navigator';
4
4
  import {PopupNotifyProps} from '../Popup/types';
5
5
  import Navigation from './Navigation';
6
6
 
7
+ type Screen = React.ComponentType<NavigationScreenProps>;
8
+
7
9
  export type Theme = {
8
10
  dark: boolean;
9
11
  colors: {
@@ -62,10 +64,11 @@ export type Theme = {
62
64
  export type Context = {
63
65
  theme: Theme;
64
66
  navigator?: Navigator;
67
+ showGrid?: boolean;
65
68
  };
66
69
 
67
70
  export type NavigationContainerProps = {
68
- screen: React.ElementType;
71
+ screen: Screen;
69
72
  options?: NavigationOptions;
70
73
  theme: Theme;
71
74
  maxApi?: any;
@@ -91,13 +94,12 @@ export interface ScreenProps extends ViewProps {
91
94
 
92
95
  export type ScreenParams = {
93
96
  [key: string]: any;
94
- screen: React.ElementType;
97
+ screen: Screen;
95
98
  options?: NavigationOptions;
96
99
  };
97
100
 
98
101
  export interface ModalParams extends ScreenParams {
99
102
  [key: string]: any;
100
- screen: React.ElementType;
101
103
  onDismiss?: () => void;
102
104
  barrierDismissible?: boolean;
103
105
  }
@@ -130,6 +132,7 @@ export type NavigationOptions = {
130
132
 
131
133
  export interface HeaderBackProps extends NavigationButtonProps {
132
134
  preventBack?: PopupNotifyProps;
135
+ accessibilityLabel?: string;
133
136
  }
134
137
 
135
138
  export type HeaderBackgroundProps = {
@@ -163,7 +166,7 @@ export type BottomTabItemProps = {
163
166
  icon: string;
164
167
  showDot?: boolean;
165
168
  badgeLabel?: string;
166
- screen: React.ComponentType<any>;
169
+ screen: Screen;
167
170
  };
168
171
 
169
172
  export type BottomTabProps = {
package/Consts/theme.ts CHANGED
@@ -116,6 +116,7 @@ const defaultDarkTheme: Theme = {
116
116
  const defaultContext: Context = {
117
117
  theme: defaultTheme,
118
118
  navigator: undefined,
119
+ showGrid: false,
119
120
  };
120
121
 
121
122
  export {defaultContext, defaultTheme, defaultDarkTheme};
package/Input/Input.tsx CHANGED
@@ -124,7 +124,7 @@ const Input: FC<InputProps> = ({
124
124
  };
125
125
 
126
126
  return (
127
- <View style={styles.wrapper} accessibilityLabel={`Input`}>
127
+ <View style={styles.wrapper} accessibilityLabel={`Input/${floatingValue}`}>
128
128
  {renderInputView()}
129
129
  <ErrorView errorMessage={errorMessage} />
130
130
  </View>
@@ -123,7 +123,9 @@ const InputMoney: FC<InputMoneyProps> = ({
123
123
  };
124
124
 
125
125
  return (
126
- <View style={styles.wrapper} accessibilityLabel={`InputMoney`}>
126
+ <View
127
+ style={styles.wrapper}
128
+ accessibilityLabel={`InputMoney/${floatingValue}`}>
127
129
  {renderInputView()}
128
130
  <ErrorView errorMessage={errorMessage} />
129
131
  </View>
@@ -132,7 +132,7 @@ const InputSearch: FC<InputSearchProps> = ({
132
132
  return (
133
133
  <View
134
134
  style={[style, styles.searchInputContainer]}
135
- accessibilityLabel={`InputSearch`}>
135
+ accessibilityLabel={`InputSearch/${placeholder}`}>
136
136
  <View
137
137
  style={[
138
138
  getBorderColor(),
@@ -139,7 +139,9 @@ const InputTextArea: FC<InputTextAreaProps> = ({
139
139
  };
140
140
 
141
141
  return (
142
- <View style={styles.wrapper} accessibilityLabel={`InputTextArea`}>
142
+ <View
143
+ style={styles.wrapper}
144
+ accessibilityLabel={`InputTextArea/${floatingValue}`}>
143
145
  {renderInputView()}
144
146
  <ErrorView errorMessage={errorMessage} />
145
147
  </View>
package/Layout/Card.tsx CHANGED
@@ -1,12 +1,15 @@
1
- import React from 'react';
1
+ import React, {useContext} from 'react';
2
2
  import {Dimensions, View} from 'react-native';
3
3
  import {useGridSystem, validateChildren} from './utils';
4
4
  import {CardProps, GridContextProps} from './types';
5
5
  import {GridContext} from './index';
6
- import {GRIDVIEW} from '../Consts';
7
6
  import Item from './Item';
7
+ import {Image} from '../Image';
8
+ import {ApplicationContext} from '../Application';
9
+ import styles from './styles';
8
10
 
9
- const Card: React.FC<CardProps> = ({children, style}) => {
11
+ const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
12
+ const {showGrid} = useContext(ApplicationContext);
10
13
  const {numberOfColumns} = useGridSystem();
11
14
 
12
15
  const gutterSize = 8;
@@ -29,20 +32,7 @@ const Card: React.FC<CardProps> = ({children, style}) => {
29
32
  * render overlay only dev mode
30
33
  */
31
34
  const renderOverlay = () => {
32
- return (
33
- <View
34
- pointerEvents={'none'}
35
- style={{
36
- position: 'absolute',
37
- top: 0,
38
- bottom: 0,
39
- left: 0,
40
- right: 0,
41
- borderColor: 'red',
42
- borderWidth: 1,
43
- }}
44
- />
45
- );
35
+ return <View pointerEvents={'none'} style={styles.boxGrid} />;
46
36
  };
47
37
 
48
38
  /**
@@ -122,16 +112,20 @@ const Card: React.FC<CardProps> = ({children, style}) => {
122
112
  accessibilityLabel={`Card`}
123
113
  style={[
124
114
  style,
115
+ styles.card,
125
116
  {
126
117
  width: widthSection,
127
118
  marginHorizontal: gridContext.margin,
128
- padding: 12,
129
- flexDirection: 'row',
130
- flexWrap: 'wrap',
131
119
  },
132
120
  ]}>
121
+ {!!backgroundImage && (
122
+ <Image
123
+ source={{uri: backgroundImage}}
124
+ style={[style, styles.cardImage]}
125
+ />
126
+ )}
133
127
  {renderView(validateChildren(children, [Item]))}
134
- {GRIDVIEW && renderOverlay()}
128
+ {showGrid && renderOverlay()}
135
129
  </View>
136
130
  </GridContext.Provider>
137
131
  );
@@ -42,6 +42,7 @@ const GridSystem: React.FC = () => {
42
42
  {
43
43
  borderColor: theme.colors.error.primary,
44
44
  marginHorizontal: grid.margin,
45
+ top: Spacing.M,
45
46
  },
46
47
  ]}>
47
48
  {list.map((i, index) => {
@@ -66,7 +67,7 @@ const GridSystem: React.FC = () => {
66
67
  <View pointerEvents="none" style={styles.dangerRightContainer} />
67
68
  <View
68
69
  pointerEvents="none"
69
- style={[styles.dangerTopContainer, {height: insets.top}]}
70
+ style={[styles.dangerTopContainer, {height: Spacing.M}]}
70
71
  />
71
72
  <View
72
73
  pointerEvents="none"
package/Layout/Item.tsx CHANGED
@@ -3,7 +3,8 @@ import {View} from 'react-native';
3
3
 
4
4
  import {ItemProps} from './types';
5
5
  import {GridContext} from './index';
6
- import {GRIDVIEW} from '../Consts';
6
+ import {ApplicationContext} from '../Application';
7
+ import styles from './styles';
7
8
 
8
9
  const Item: React.FC<ItemProps> = ({
9
10
  widthSpan,
@@ -11,26 +12,14 @@ const Item: React.FC<ItemProps> = ({
11
12
  children,
12
13
  style,
13
14
  }) => {
15
+ const {showGrid} = useContext(ApplicationContext);
14
16
  const grid = useContext(GridContext);
15
17
 
16
18
  /**
17
19
  * render overlay view only dev mode
18
20
  */
19
21
  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
- );
22
+ return <View pointerEvents={'none'} style={styles.boxGrid} />;
34
23
  };
35
24
 
36
25
  return (
@@ -38,19 +27,14 @@ const Item: React.FC<ItemProps> = ({
38
27
  accessibilityLabel={`Item`}
39
28
  style={[
40
29
  style,
30
+ styles.item,
41
31
  {
42
32
  width: grid.getSizeSpan(widthSpan ?? grid.numberOfColumns),
43
33
  height: heightSpan ? grid.getSizeSpan(heightSpan) : undefined,
44
- overflow: 'hidden',
45
- margin: undefined,
46
- marginTop: undefined,
47
- marginBottom: undefined,
48
- marginLeft: undefined,
49
- marginRight: undefined,
50
34
  },
51
35
  ]}>
52
36
  {children}
53
- {GRIDVIEW && renderOverlay()}
37
+ {showGrid && renderOverlay()}
54
38
  </View>
55
39
  );
56
40
  };
@@ -1,16 +1,18 @@
1
- import React from 'react';
1
+ import React, {useContext} from 'react';
2
2
  import {Dimensions, View} from 'react-native';
3
3
  import {useGridSystem, validateChildren} from './utils';
4
4
  import {GridContextProps, SectionProps} from './types';
5
5
  import {GridContext} from './index';
6
- import {GRIDVIEW} from '../Consts';
7
6
  import Item from './Item';
7
+ import {ApplicationContext} from '../Application';
8
+ import styles from './styles';
8
9
 
9
10
  const Section: React.FC<SectionProps> = ({
10
11
  children,
11
12
  useMargin = true,
12
13
  backgroundColor,
13
14
  }) => {
15
+ const {showGrid} = useContext(ApplicationContext);
14
16
  const {numberOfColumns} = useGridSystem();
15
17
 
16
18
  const gutterSize = 12;
@@ -37,20 +39,7 @@ const Section: React.FC<SectionProps> = ({
37
39
  * render overlay only dev mode
38
40
  */
39
41
  const renderOverlay = () => {
40
- return (
41
- <View
42
- pointerEvents={'none'}
43
- style={{
44
- position: 'absolute',
45
- top: 0,
46
- bottom: 0,
47
- left: 0,
48
- right: 0,
49
- borderColor: 'red',
50
- borderWidth: 1,
51
- }}
52
- />
53
- );
42
+ return <View pointerEvents={'none'} style={styles.boxGrid} />;
54
43
  };
55
44
 
56
45
  /**
@@ -136,7 +125,7 @@ const Section: React.FC<SectionProps> = ({
136
125
  backgroundColor: backgroundColor,
137
126
  }}>
138
127
  {renderView(validateChildren(children, [Item]))}
139
- {GRIDVIEW && renderOverlay()}
128
+ {showGrid && renderOverlay()}
140
129
  </View>
141
130
  </GridContext.Provider>
142
131
  );
@@ -0,0 +1,47 @@
1
+ import {StyleSheet} from 'react-native';
2
+
3
+ export default StyleSheet.create({
4
+ boxGrid: {
5
+ position: 'absolute',
6
+ top: 0,
7
+ bottom: 0,
8
+ left: 0,
9
+ right: 0,
10
+ borderColor: 'red',
11
+ borderWidth: 1,
12
+ },
13
+ card: {
14
+ flexDirection: 'row',
15
+ flexWrap: 'wrap',
16
+ paddingTop: undefined,
17
+ paddingBottom: undefined,
18
+ paddingLeft: undefined,
19
+ paddingRight: undefined,
20
+ paddingVertical: undefined,
21
+ paddingHorizontal: undefined,
22
+ padding: 12,
23
+ margin: undefined,
24
+ marginTop: undefined,
25
+ marginBottom: undefined,
26
+ marginLeft: undefined,
27
+ marginRight: undefined,
28
+ marginVertical: undefined,
29
+ },
30
+ item: {
31
+ overflow: 'hidden',
32
+ margin: undefined,
33
+ marginTop: undefined,
34
+ marginBottom: undefined,
35
+ marginLeft: undefined,
36
+ marginRight: undefined,
37
+ marginVertical: undefined,
38
+ marginHorizontal: undefined,
39
+ },
40
+ cardImage: {
41
+ position: 'absolute',
42
+ top: 0,
43
+ bottom: 0,
44
+ left: 0,
45
+ right: 0,
46
+ },
47
+ });
package/Layout/types.ts CHANGED
@@ -57,5 +57,5 @@ export interface ItemProps extends ViewProps {
57
57
  }
58
58
 
59
59
  export interface CardProps extends ViewProps {
60
- background?: string;
60
+ backgroundImage?: string;
61
61
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.77.2",
3
+ "version": "0.77.4",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {