@momo-kits/foundation 0.80.9 → 0.81.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/Components.tsx +47 -6
- package/Application/ModalScreen.tsx +24 -7
- package/Application/Navigation.ts +3 -5
- package/Application/NavigationContainer.tsx +2 -2
- package/Application/index.ts +12 -5
- package/Application/types.ts +14 -6
- package/Application/utils.tsx +15 -47
- package/Consts/colors+spacing+radius.ts +4 -0
- package/Image/index.tsx +21 -11
- package/Input/Input.tsx +5 -3
- package/Input/InputDropDown.tsx +6 -3
- package/Input/InputMoney.tsx +6 -3
- package/Input/InputOTP.tsx +7 -9
- package/Input/InputSearch.tsx +6 -9
- package/Input/InputTextArea.tsx +5 -3
- package/Input/common.tsx +2 -2
- package/Input/index.tsx +3 -1
- package/Layout/Card.tsx +18 -4
- package/Layout/ItemList.tsx +63 -0
- package/Layout/Screen.tsx +223 -176
- package/Layout/Section.tsx +2 -1
- package/Layout/index.ts +10 -1
- package/Layout/styles.ts +12 -0
- package/Layout/types.ts +2 -0
- package/Layout/utils.ts +2 -7
- package/Pagination/PaginationDot.tsx +6 -1
- package/Pagination/PaginationNumber.tsx +7 -4
- package/Pagination/PaginationWhiteDot.tsx +6 -1
- package/Pagination/styles.ts +3 -0
- package/Pagination/types.ts +2 -0
- package/Radio/types.ts +2 -2
- package/package.json +1 -1
package/Input/InputSearch.tsx
CHANGED
|
@@ -37,7 +37,7 @@ const InputSearch = forwardRef(
|
|
|
37
37
|
const [focused, setFocused] = useState(false);
|
|
38
38
|
const [haveValue, setHaveValue] = useState(!!value || !!defaultValue);
|
|
39
39
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
40
|
-
|
|
40
|
+
const accessibilityLabel = `InputMoney/${placeholder}`;
|
|
41
41
|
|
|
42
42
|
const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
|
|
43
43
|
setFocused(true);
|
|
@@ -60,19 +60,16 @@ const InputSearch = forwardRef(
|
|
|
60
60
|
};
|
|
61
61
|
|
|
62
62
|
const renderInputView = () => {
|
|
63
|
-
let textColor = theme.colors.text.default;
|
|
64
|
-
let placeholderColor = theme.colors.text.hint;
|
|
65
|
-
|
|
66
63
|
return (
|
|
67
64
|
<TextInput
|
|
68
65
|
{...props}
|
|
69
|
-
accessibilityLabel={
|
|
66
|
+
accessibilityLabel={accessibilityLabel}
|
|
70
67
|
textAlignVertical="top"
|
|
71
68
|
ref={inputRef}
|
|
72
69
|
style={[
|
|
73
70
|
styles.searchInput,
|
|
74
71
|
{
|
|
75
|
-
color:
|
|
72
|
+
color: theme.colors.text.default,
|
|
76
73
|
},
|
|
77
74
|
]}
|
|
78
75
|
value={value}
|
|
@@ -81,7 +78,7 @@ const InputSearch = forwardRef(
|
|
|
81
78
|
onBlur={_onBlur}
|
|
82
79
|
placeholder={placeholder}
|
|
83
80
|
selectionColor={theme.colors.primary}
|
|
84
|
-
placeholderTextColor={
|
|
81
|
+
placeholderTextColor={theme.colors.text.hint}
|
|
85
82
|
/>
|
|
86
83
|
);
|
|
87
84
|
};
|
|
@@ -112,7 +109,7 @@ const InputSearch = forwardRef(
|
|
|
112
109
|
]}
|
|
113
110
|
/>
|
|
114
111
|
<Icon
|
|
115
|
-
color={
|
|
112
|
+
color={iconColor}
|
|
116
113
|
source={icon}
|
|
117
114
|
style={styles.iconSearchInput}
|
|
118
115
|
/>
|
|
@@ -124,7 +121,7 @@ const InputSearch = forwardRef(
|
|
|
124
121
|
return (
|
|
125
122
|
<View
|
|
126
123
|
style={[style, styles.searchInputContainer]}
|
|
127
|
-
accessibilityLabel={
|
|
124
|
+
accessibilityLabel={accessibilityLabel}>
|
|
128
125
|
<View
|
|
129
126
|
style={[
|
|
130
127
|
styles.searchInputWrapper,
|
package/Input/InputTextArea.tsx
CHANGED
|
@@ -37,6 +37,7 @@ const InputTextArea = forwardRef(
|
|
|
37
37
|
maxLength,
|
|
38
38
|
required,
|
|
39
39
|
errorSpacing,
|
|
40
|
+
style,
|
|
40
41
|
...props
|
|
41
42
|
}: InputTextAreaProps,
|
|
42
43
|
ref,
|
|
@@ -45,6 +46,7 @@ const InputTextArea = forwardRef(
|
|
|
45
46
|
const [focused, setFocused] = useState(false);
|
|
46
47
|
const [inputValue, setInputValue] = useState(defaultValue ?? '');
|
|
47
48
|
const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
|
|
49
|
+
const accessibilityLabel = `InputTextArea/${floatingValue ?? placeholder}`;
|
|
48
50
|
|
|
49
51
|
const onClearText = () => {
|
|
50
52
|
inputRef?.current?.clear();
|
|
@@ -106,7 +108,7 @@ const InputTextArea = forwardRef(
|
|
|
106
108
|
<View style={styles.textAreaView}>
|
|
107
109
|
<TextInput
|
|
108
110
|
{...props}
|
|
109
|
-
accessibilityLabel={
|
|
111
|
+
accessibilityLabel={accessibilityLabel}
|
|
110
112
|
ref={inputRef}
|
|
111
113
|
editable={!disabled}
|
|
112
114
|
textAlignVertical="top"
|
|
@@ -147,8 +149,8 @@ const InputTextArea = forwardRef(
|
|
|
147
149
|
|
|
148
150
|
return (
|
|
149
151
|
<View
|
|
150
|
-
style={styles.wrapper}
|
|
151
|
-
accessibilityLabel={
|
|
152
|
+
style={[style, styles.wrapper]}
|
|
153
|
+
accessibilityLabel={accessibilityLabel}>
|
|
152
154
|
{renderInputView()}
|
|
153
155
|
<ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
|
|
154
156
|
</View>
|
package/Input/common.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {View, ViewStyle} from 'react-native';
|
|
2
2
|
import styles from './styles';
|
|
3
|
-
import {Text} from '../Text';
|
|
3
|
+
import {scaleSize, Text} from '../Text';
|
|
4
4
|
import React, {FC, useContext} from 'react';
|
|
5
5
|
import {ApplicationContext} from '../Application';
|
|
6
6
|
import {Icon} from '../Icon';
|
|
@@ -16,7 +16,7 @@ type FloatingViewProps = {
|
|
|
16
16
|
style?: ViewStyle;
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
export const DEFAULT_HEIGHT =
|
|
19
|
+
export const DEFAULT_HEIGHT = scaleSize(104);
|
|
20
20
|
export const MAX_LENGTH = 300;
|
|
21
21
|
|
|
22
22
|
export const getBorderColor = (
|
package/Input/index.tsx
CHANGED
|
@@ -4,7 +4,7 @@ import InputSearch from './InputSearch';
|
|
|
4
4
|
import InputMoney from './InputMoney';
|
|
5
5
|
import InputOTP from './InputOTP';
|
|
6
6
|
import InputDropDown from './InputDropDown';
|
|
7
|
-
import {TextInputProps} from 'react-native';
|
|
7
|
+
import {TextInputProps, ViewStyle} from 'react-native';
|
|
8
8
|
|
|
9
9
|
export interface InputProps extends TextInputProps {
|
|
10
10
|
/**
|
|
@@ -238,6 +238,8 @@ export interface InputDropDownProps {
|
|
|
238
238
|
* Optional. Represents the color of the leading icon in the InputDropDown component.
|
|
239
239
|
*/
|
|
240
240
|
leadingIconColor?: string;
|
|
241
|
+
|
|
242
|
+
style: ViewStyle | ViewStyle[];
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
export {Input, InputTextArea, InputSearch, InputMoney, InputOTP, InputDropDown};
|
package/Layout/Card.tsx
CHANGED
|
@@ -7,16 +7,27 @@ import Item from './Item';
|
|
|
7
7
|
import {Image} from '../Image';
|
|
8
8
|
import {ApplicationContext} from '../Application';
|
|
9
9
|
import styles from './styles';
|
|
10
|
-
import {Colors, Spacing} from '../Consts';
|
|
10
|
+
import {Colors, Shadow, Spacing} from '../Consts';
|
|
11
|
+
import ItemList from './ItemList';
|
|
11
12
|
|
|
12
13
|
export interface CardProps extends ViewProps {
|
|
13
14
|
/**
|
|
14
15
|
* Optional. Background image for the card.
|
|
15
16
|
*/
|
|
16
17
|
backgroundImage?: string;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Optional. Use shadow for the card.
|
|
21
|
+
*/
|
|
22
|
+
useShadow?: boolean;
|
|
17
23
|
}
|
|
18
24
|
|
|
19
|
-
const Card: React.FC<CardProps> = ({
|
|
25
|
+
const Card: React.FC<CardProps> = ({
|
|
26
|
+
children,
|
|
27
|
+
style,
|
|
28
|
+
backgroundImage,
|
|
29
|
+
useShadow = false,
|
|
30
|
+
}) => {
|
|
20
31
|
const {showGrid} = useContext(ApplicationContext);
|
|
21
32
|
const {numberOfColumns} = useGridSystem();
|
|
22
33
|
|
|
@@ -127,6 +138,7 @@ const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
|
|
|
127
138
|
return element;
|
|
128
139
|
};
|
|
129
140
|
|
|
141
|
+
const {theme} = useContext(ApplicationContext);
|
|
130
142
|
return (
|
|
131
143
|
<GridContext.Provider value={gridContext}>
|
|
132
144
|
<View
|
|
@@ -137,15 +149,17 @@ const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
|
|
|
137
149
|
{
|
|
138
150
|
width: widthSection,
|
|
139
151
|
marginHorizontal: gridContext.margin,
|
|
152
|
+
backgroundColor: theme.colors.background.surface,
|
|
140
153
|
},
|
|
154
|
+
useShadow && Shadow.Light,
|
|
141
155
|
]}>
|
|
142
156
|
{!!backgroundImage && (
|
|
143
157
|
<Image
|
|
144
158
|
source={{uri: backgroundImage}}
|
|
145
|
-
style={
|
|
159
|
+
style={styles.imageBackground}
|
|
146
160
|
/>
|
|
147
161
|
)}
|
|
148
|
-
{renderView(validateChildren(children, [Item]))}
|
|
162
|
+
{renderView(validateChildren(children, [Item, ItemList]))}
|
|
149
163
|
{showGrid && renderOverlay()}
|
|
150
164
|
</View>
|
|
151
165
|
</GridContext.Provider>
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import React, {FC, ReactElement, useContext} from 'react';
|
|
2
|
+
import {FlatList, FlatListProps, View} from 'react-native';
|
|
3
|
+
import Item from './Item';
|
|
4
|
+
import {GridContext} from './index';
|
|
5
|
+
|
|
6
|
+
const ItemList: FC<FlatListProps<any>> = ({
|
|
7
|
+
renderItem,
|
|
8
|
+
numColumns = 1,
|
|
9
|
+
style,
|
|
10
|
+
...props
|
|
11
|
+
}) => {
|
|
12
|
+
const {gutterSize} = useContext(GridContext);
|
|
13
|
+
|
|
14
|
+
const _renderItem = (info: any) => {
|
|
15
|
+
const {item, index, separators} = info;
|
|
16
|
+
|
|
17
|
+
const children = renderItem?.({
|
|
18
|
+
item,
|
|
19
|
+
index,
|
|
20
|
+
separators,
|
|
21
|
+
}) as ReactElement;
|
|
22
|
+
|
|
23
|
+
if (children?.type !== Item) {
|
|
24
|
+
console.warn('Wrong children type for this component, expected are Item');
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const spacingStyle =
|
|
28
|
+
numColumns > 1
|
|
29
|
+
? {
|
|
30
|
+
marginRight: gutterSize,
|
|
31
|
+
}
|
|
32
|
+
: {};
|
|
33
|
+
|
|
34
|
+
return <View style={spacingStyle}>{children}</View>;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<FlatList
|
|
39
|
+
{...props}
|
|
40
|
+
numColumns={numColumns}
|
|
41
|
+
renderItem={_renderItem}
|
|
42
|
+
horizontal={false}
|
|
43
|
+
ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
|
|
44
|
+
style={[
|
|
45
|
+
style,
|
|
46
|
+
{
|
|
47
|
+
marginTop: undefined,
|
|
48
|
+
marginBottom: undefined,
|
|
49
|
+
marginLeft: undefined,
|
|
50
|
+
marginRight: undefined,
|
|
51
|
+
paddingTop: undefined,
|
|
52
|
+
paddingBottom: undefined,
|
|
53
|
+
paddingLeft: undefined,
|
|
54
|
+
paddingRight: undefined,
|
|
55
|
+
padding: undefined,
|
|
56
|
+
margin: undefined,
|
|
57
|
+
},
|
|
58
|
+
]}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default ItemList;
|