@momo-kits/foundation 0.77.8-beta.4 → 0.77.8-beta.6

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,4 +1,4 @@
1
- import React, {FC, useContext, useRef, useState} from 'react';
1
+ import React, {FC, forwardRef, useContext, useRef, useState} from 'react';
2
2
  import {
3
3
  NativeSyntheticEvent,
4
4
  TextInput,
@@ -19,135 +19,142 @@ import {InputTextAreaProps} from './index';
19
19
  import {Icon} from '../Icon';
20
20
  import {ApplicationContext} from '../Application';
21
21
 
22
- const InputTextArea: FC<InputTextAreaProps> = ({
23
- errorMessage,
24
- onChangeText,
25
- floatingIconColor,
26
- floatingIcon,
27
- floatingValue,
28
- onFocus,
29
- onBlur,
30
- disabled,
31
- value,
32
- defaultValue,
33
- height,
34
- placeholder,
35
- maxLength,
36
- required,
37
- errorSpacing,
38
- ...props
39
- }) => {
40
- const {theme} = useContext(ApplicationContext);
41
- const [focused, setFocused] = useState(false);
42
- const [inputValue, setInputValue] = useState(defaultValue ?? '');
43
- const inputRef = useRef<any>(null);
22
+ const InputTextArea: FC<InputTextAreaProps> = forwardRef(
23
+ (
24
+ {
25
+ errorMessage,
26
+ onChangeText,
27
+ floatingIconColor,
28
+ floatingIcon,
29
+ floatingValue,
30
+ onFocus,
31
+ onBlur,
32
+ disabled,
33
+ value,
34
+ defaultValue,
35
+ height,
36
+ placeholder,
37
+ maxLength,
38
+ required,
39
+ errorSpacing,
40
+ ...props
41
+ },
42
+ ref,
43
+ ) => {
44
+ const {theme} = useContext(ApplicationContext);
45
+ const [focused, setFocused] = useState(false);
46
+ const [inputValue, setInputValue] = useState(defaultValue ?? '');
47
+ const inputRef = (ref as React.RefObject<TextInput>) ?? useRef<TextInput>();
44
48
 
45
- const onClearText = () => {
46
- inputRef?.current?.clear();
47
- _onChangeText('');
48
- };
49
+ const onClearText = () => {
50
+ inputRef?.current?.clear();
51
+ _onChangeText('');
52
+ };
49
53
 
50
- const _onChangeText = (text: string) => {
51
- onChangeText?.(text);
52
- setInputValue(text);
53
- };
54
+ const _onChangeText = (text: string) => {
55
+ onChangeText?.(text);
56
+ setInputValue(text);
57
+ };
54
58
 
55
- const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
56
- setFocused(true);
57
- onFocus?.(e);
58
- };
59
+ const _onFocus = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
60
+ setFocused(true);
61
+ onFocus?.(e);
62
+ };
59
63
 
60
- const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
61
- setFocused(false);
62
- onBlur?.(e);
63
- };
64
+ const _onBlur = (e: NativeSyntheticEvent<TextInputFocusEventData>) => {
65
+ setFocused(false);
66
+ onBlur?.(e);
67
+ };
64
68
 
65
- const renderCountingView = () => {
66
- return (
67
- <View style={styles.countingView}>
68
- <Text color={theme.colors.text.hint} typography={'description_xs'}>
69
- {`${inputValue.length}/${maxLength}`}
70
- </Text>
71
- </View>
72
- );
73
- };
74
- const renderInputView = () => {
75
- const disabledColor = theme.colors.text.disable;
76
- let textColor = theme.colors.text.default;
77
- let placeholderColor = theme.colors.text.hint;
69
+ const renderCountingView = () => {
70
+ return (
71
+ <View style={styles.countingView}>
72
+ <Text color={theme.colors.text.hint} typography={'description_xs'}>
73
+ {`${inputValue.length}/${maxLength}`}
74
+ </Text>
75
+ </View>
76
+ );
77
+ };
78
+ const renderInputView = () => {
79
+ const disabledColor = theme.colors.text.disable;
80
+ let textColor = theme.colors.text.default;
81
+ let placeholderColor = theme.colors.text.hint;
78
82
 
79
- if (disabled) {
80
- textColor = disabledColor;
81
- placeholderColor = disabledColor;
82
- }
83
+ if (disabled) {
84
+ textColor = disabledColor;
85
+ placeholderColor = disabledColor;
86
+ }
83
87
 
84
- return (
85
- <View
86
- style={[
87
- styles.textAreaWrapper,
88
- {
89
- height: height || DEFAULT_HEIGHT,
90
- backgroundColor: theme.colors.background.surface,
91
- },
92
- getBorderColor(theme, focused, errorMessage, disabled),
93
- ]}>
94
- <FloatingView
95
- floatingValue={floatingValue}
96
- floatingIconColor={floatingIconColor}
97
- disabled={disabled}
98
- floatingIcon={floatingIcon}
99
- required={required}
100
- />
101
- <View style={styles.rowArea}>
102
- <View style={styles.textAreaView}>
103
- <TextInput
104
- {...props}
105
- accessibilityLabel={`TextInput`}
106
- ref={inputRef}
107
- editable={!disabled}
108
- textAlignVertical="top"
109
- style={[
110
- styles.textArea,
111
- {
112
- color: textColor,
113
- },
114
- ]}
115
- maxLength={maxLength}
116
- textBreakStrategy="highQuality"
117
- multiline={true}
118
- value={value}
119
- onChangeText={_onChangeText}
120
- onFocus={_onFocus}
121
- onBlur={_onBlur}
122
- placeholder={placeholder}
123
- selectionColor={theme.colors.primary}
124
- placeholderTextColor={placeholderColor}
125
- />
126
- </View>
127
- {focused && inputValue.length > 0 && (
128
- <TouchableOpacity style={styles.iconWrapper} onPress={onClearText}>
129
- <Icon
130
- source="24_navigation_close_circle_full"
131
- size={16}
132
- color={theme.colors.text.hint}
88
+ return (
89
+ <View
90
+ style={[
91
+ styles.textAreaWrapper,
92
+ {
93
+ height: height || DEFAULT_HEIGHT,
94
+ backgroundColor: theme.colors.background.surface,
95
+ },
96
+ getBorderColor(theme, focused, errorMessage, disabled),
97
+ ]}>
98
+ <FloatingView
99
+ floatingValue={floatingValue}
100
+ floatingIconColor={floatingIconColor}
101
+ disabled={disabled}
102
+ floatingIcon={floatingIcon}
103
+ required={required}
104
+ />
105
+ <View style={styles.rowArea}>
106
+ <View style={styles.textAreaView}>
107
+ <TextInput
108
+ {...props}
109
+ accessibilityLabel={`TextInput`}
110
+ ref={inputRef}
111
+ editable={!disabled}
112
+ textAlignVertical="top"
113
+ style={[
114
+ styles.textArea,
115
+ {
116
+ color: textColor,
117
+ },
118
+ ]}
119
+ maxLength={maxLength}
120
+ textBreakStrategy="highQuality"
121
+ multiline={true}
122
+ value={value}
123
+ onChangeText={_onChangeText}
124
+ onFocus={_onFocus}
125
+ onBlur={_onBlur}
126
+ placeholder={placeholder}
127
+ selectionColor={theme.colors.primary}
128
+ placeholderTextColor={placeholderColor}
133
129
  />
134
- </TouchableOpacity>
135
- )}
130
+ </View>
131
+ {focused && inputValue.length > 0 && (
132
+ <TouchableOpacity
133
+ style={styles.iconWrapper}
134
+ onPress={onClearText}>
135
+ <Icon
136
+ source="24_navigation_close_circle_full"
137
+ size={16}
138
+ color={theme.colors.text.hint}
139
+ />
140
+ </TouchableOpacity>
141
+ )}
142
+ </View>
143
+ {renderCountingView()}
136
144
  </View>
137
- {renderCountingView()}
145
+ );
146
+ };
147
+
148
+ return (
149
+ <View
150
+ style={styles.wrapper}
151
+ accessibilityLabel={`InputTextArea/${floatingValue}`}>
152
+ {renderInputView()}
153
+ <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
138
154
  </View>
139
155
  );
140
- };
141
-
142
- return (
143
- <View
144
- style={styles.wrapper}
145
- accessibilityLabel={`InputTextArea/${floatingValue}`}>
146
- {renderInputView()}
147
- <ErrorView errorMessage={errorMessage} errorSpacing={errorSpacing} />
148
- </View>
149
- );
150
- };
156
+ },
157
+ );
151
158
 
152
159
  InputTextArea.defaultProps = {
153
160
  maxLength: MAX_LENGTH,
package/Input/index.tsx CHANGED
@@ -59,6 +59,11 @@ export interface InputProps extends TextInputProps {
59
59
  * Defaults to `false` if not provided.
60
60
  */
61
61
  errorSpacing?: boolean;
62
+
63
+ /**
64
+ * If true, the icon of input will use be show indicator loading.
65
+ */
66
+ loading?: boolean;
62
67
  }
63
68
 
64
69
  type InputPropsWithoutSizeAndIcon = Omit<
package/Layout/Card.tsx CHANGED
@@ -1,7 +1,7 @@
1
1
  import React, {useContext} from 'react';
2
- import {Dimensions, View} from 'react-native';
2
+ import {Dimensions, View, ViewProps} from 'react-native';
3
3
  import {useGridSystem, validateChildren} from './utils';
4
- import {CardProps, GridContextProps} from './types';
4
+ import {GridContextProps} from './types';
5
5
  import {GridContext, GridSystem} from './index';
6
6
  import Item from './Item';
7
7
  import {Image} from '../Image';
@@ -9,6 +9,13 @@ import {ApplicationContext} from '../Application';
9
9
  import styles from './styles';
10
10
  import {Colors, Spacing} from '../Consts';
11
11
 
12
+ export interface CardProps extends ViewProps {
13
+ /**
14
+ * Optional. Background image for the card.
15
+ */
16
+ backgroundImage?: string;
17
+ }
18
+
12
19
  const Card: React.FC<CardProps> = ({children, style, backgroundImage}) => {
13
20
  const {showGrid} = useContext(ApplicationContext);
14
21
  const {numberOfColumns} = useGridSystem();
package/Layout/Item.tsx CHANGED
@@ -1,11 +1,24 @@
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
5
  import {ApplicationContext} from '../Application';
7
6
  import styles from './styles';
8
7
 
8
+ 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
+ }
21
+
9
22
  const Item: React.FC<ItemProps> = ({
10
23
  widthSpan,
11
24
  heightSpan,
package/Layout/Screen.tsx CHANGED
@@ -1,13 +1,71 @@
1
- import {Animated, KeyboardAvoidingView, Platform, View} from 'react-native';
1
+ import {
2
+ Animated,
3
+ KeyboardAvoidingView,
4
+ Platform,
5
+ ScrollViewProps,
6
+ View,
7
+ ViewProps,
8
+ } from 'react-native';
2
9
  import {useHeaderHeight} from '@react-navigation/stack';
3
10
  import {useSafeAreaInsets} from 'react-native-safe-area-context';
4
- import React, {useContext, useEffect, useRef} from 'react';
5
- import {ScreenProps} from '../Application/types';
11
+ import React, {ReactNode, useContext, useEffect, useRef} from 'react';
6
12
  import {Spacing, Styles} from '../Consts';
7
13
  import {Card, Section, validateChildren} from './index';
8
14
  import {ApplicationContext, HeaderTitle} from '../Application';
9
15
  import Navigation from '../Application/Navigation';
10
16
 
17
+ export interface ScreenProps extends ViewProps {
18
+ /**
19
+ * Optional. Navigation object for handling navigation actions.
20
+ */
21
+ navigation?: Navigation;
22
+
23
+ /**
24
+ * Optional. If `true`, enable keyboard avoiding view for the screen.
25
+ */
26
+ enableKeyboardAvoidingView?: boolean;
27
+
28
+ /**
29
+ * Optional. Background color of the header.
30
+ */
31
+ headerBackground?: string;
32
+
33
+ /**
34
+ * Optional. If `true`, the screen content is scrollable.
35
+ */
36
+ scrollable?: boolean;
37
+
38
+ /**
39
+ * Optional. If `true`, use an animated header for the screen.
40
+ */
41
+ useAnimatedHeader?: boolean;
42
+
43
+ /**
44
+ * Optional. If `true`, use an extended header for the screen.
45
+ */
46
+ useExtendedHeader?: boolean;
47
+
48
+ /**
49
+ * Optional. Props for the underlying ScrollView component when `scrollable` is `true`.
50
+ */
51
+ scrollViewProps?: ScrollViewProps;
52
+
53
+ /**
54
+ * Optional. ReactNode representing the footer component of the screen.
55
+ */
56
+ footerComponent?: ReactNode;
57
+
58
+ /**
59
+ * Optional. Margin for the header component.
60
+ */
61
+ marginHeader?: number;
62
+
63
+ /**
64
+ * Optional. Background color of the screen.
65
+ */
66
+ backgroundColor?: string;
67
+ }
68
+
11
69
  const Screen: React.FC<ScreenProps> = ({
12
70
  children,
13
71
  enableKeyboardAvoidingView = false,
@@ -1,13 +1,37 @@
1
1
  import React, {useContext} from 'react';
2
- import {Dimensions, View} from 'react-native';
2
+ import {Dimensions, View, ViewProps} from 'react-native';
3
3
  import {useGridSystem, validateChildren} from './utils';
4
- import {GridContextProps, SectionProps} from './types';
4
+ import {GridContextProps} from './types';
5
5
  import {GridContext} from './index';
6
6
  import Item from './Item';
7
7
  import {ApplicationContext} from '../Application';
8
8
  import styles from './styles';
9
9
  import {Image} from '../Image';
10
10
 
11
+ export interface SectionProps extends ViewProps {
12
+ /**
13
+ * Optional. If `true`, the Section component will be displayed in an expanded state.
14
+ * Defaults to `false` if not provided.
15
+ */
16
+ expanded?: boolean;
17
+
18
+ /**
19
+ * Optional. If `true`, margin will be applied to the Section component.
20
+ * Defaults to `false` if not provided.
21
+ */
22
+ useMargin?: boolean;
23
+
24
+ /**
25
+ * Optional. Background color for the Section component.
26
+ */
27
+ backgroundColor?: string;
28
+
29
+ /**
30
+ * Optional. Background image for the Section component.
31
+ */
32
+ backgroundImage?: string;
33
+ }
34
+
11
35
  const Section: React.FC<SectionProps> = ({
12
36
  children,
13
37
  useMargin = true,
@@ -116,7 +140,16 @@ const Section: React.FC<SectionProps> = ({
116
140
  };
117
141
 
118
142
  return (
119
- <GridContext.Provider value={gridContext}>
143
+ <GridContext.Provider
144
+ value={{
145
+ numberOfColumns,
146
+ gutterSize,
147
+ margin,
148
+ sizePerSpan,
149
+ getSizeSpan: span => {
150
+ return span * sizePerSpan + (span - 1) * gutterSize;
151
+ },
152
+ }}>
120
153
  <View
121
154
  accessibilityLabel={`Section`}
122
155
  style={{
package/Layout/types.ts CHANGED
@@ -1,7 +1,3 @@
1
- import {ViewProps} from 'react-native';
2
-
3
- type SpanNumber = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12;
4
-
5
1
  export type GridContextProps = {
6
2
  /**
7
3
  * Represents the number of columns in the grid.
@@ -28,36 +24,3 @@ export type GridContextProps = {
28
24
  */
29
25
  getSizeSpan: (span: number) => number;
30
26
  };
31
- export interface SectionProps extends ViewProps {
32
- /**
33
- * Optional. If `true`, the Section component will be displayed in an expanded state.
34
- * Defaults to `false` if not provided.
35
- */
36
- expanded?: boolean;
37
-
38
- /**
39
- * Optional. If `true`, margin will be applied to the Section component.
40
- * Defaults to `false` if not provided.
41
- */
42
- useMargin?: boolean;
43
-
44
- backgroundColor?: string;
45
-
46
- backgroundImage?: string;
47
- }
48
-
49
- export interface ItemProps extends ViewProps {
50
- /**
51
- * Represents the width of the Card component in terms of span numbers (1-12).
52
- */
53
- widthSpan?: SpanNumber;
54
-
55
- /**
56
- * Optional. Represents the height of the Card component in terms of span numbers (1-12).
57
- */
58
- heightSpan?: SpanNumber;
59
- }
60
-
61
- export interface CardProps extends ViewProps {
62
- backgroundImage?: string;
63
- }
@@ -1,17 +1,17 @@
1
1
  import React, {FC, useContext} from 'react';
2
- import {View, ViewProps} from 'react-native';
3
2
  import AnimatedLottieView from 'lottie-react-native';
4
3
  import animation from '../Assets/DotAnimation.json';
5
4
  import {ApplicationContext} from '../Application';
6
5
  import {hexToRGBA} from './utils';
6
+ import {LoaderProps} from './types';
7
7
 
8
- const DotLoader: FC<ViewProps> = ({style}) => {
8
+ const DotLoader: FC<LoaderProps> = ({color}) => {
9
9
  const {theme} = useContext(ApplicationContext);
10
10
 
11
11
  const arrayColor = [
12
- theme.colors.primary,
13
- theme.colors.secondary,
14
- theme.colors.primary,
12
+ color ?? theme.colors.primary,
13
+ theme.colors.background.surface,
14
+ color ?? theme.colors.primary,
15
15
  ];
16
16
 
17
17
  let source: any = animation;
@@ -26,13 +26,11 @@ const DotLoader: FC<ViewProps> = ({style}) => {
26
26
  });
27
27
 
28
28
  return (
29
- <View style={style}>
30
- <AnimatedLottieView
31
- source={source}
32
- style={{width: 52, height: 18}}
33
- autoPlay
34
- />
35
- </View>
29
+ <AnimatedLottieView
30
+ source={source}
31
+ style={{width: 52, height: 18}}
32
+ autoPlay
33
+ />
36
34
  );
37
35
  };
38
36
 
package/Loader/Loader.tsx CHANGED
@@ -3,12 +3,11 @@ import {LoaderProps} from './types';
3
3
  import DotLoader from './DotLoader';
4
4
  import Spinner from './Spinner';
5
5
 
6
- const Loader: FC<LoaderProps> = ({type = 'dot', style}) => {
6
+ const Loader: FC<LoaderProps> = ({type = 'dot', ...props}) => {
7
7
  if (type === 'spinner') {
8
- return <Spinner style={style} />;
8
+ return <Spinner {...props} key={props.color} />;
9
9
  }
10
-
11
- return <DotLoader style={style} />;
10
+ return <DotLoader {...props} key={props.color} />;
12
11
  };
13
12
 
14
13
  export default Loader;
@@ -1,30 +1,28 @@
1
1
  import React, {FC, useContext} from 'react';
2
- import {View, ViewProps} from 'react-native';
3
2
  import AnimatedLottieView from 'lottie-react-native';
4
3
  import animation from '../Assets/SpinnerAnimation.json';
5
4
  import {hexToRGBA} from './utils';
6
5
  import {ApplicationContext} from '../Application';
6
+ import {LoaderProps} from './types';
7
7
 
8
- const Spinner: FC<ViewProps> = ({style}) => {
8
+ const Spinner: FC<LoaderProps> = ({color}) => {
9
9
  const {theme} = useContext(ApplicationContext);
10
10
 
11
11
  let source: any = animation;
12
12
  source.assets[0].layers.forEach((layer: any) => {
13
13
  layer.shapes[0].it.forEach((item: any) => {
14
14
  if (item.ty === 'fl' && item.c) {
15
- item.c.k = hexToRGBA(theme.colors.primary);
15
+ item.c.k = hexToRGBA(color ?? theme.colors.primary);
16
16
  }
17
17
  });
18
18
  });
19
19
 
20
20
  return (
21
- <View style={style}>
22
- <AnimatedLottieView
23
- source={source}
24
- style={{width: 24, height: 24}}
25
- autoPlay
26
- />
27
- </View>
21
+ <AnimatedLottieView
22
+ source={source}
23
+ style={{width: 24, height: 24}}
24
+ autoPlay
25
+ />
28
26
  );
29
27
  };
30
28
 
package/Loader/types.ts CHANGED
@@ -1,11 +1,35 @@
1
1
  import {ViewStyle} from 'react-native';
2
2
 
3
3
  export type LoaderProps = {
4
+ /**
5
+ * Optional. Type of loader, can be 'dot' or 'spinner'.
6
+ */
4
7
  type?: 'dot' | 'spinner';
8
+
9
+ /**
10
+ * Optional. Color for the loader.
11
+ */
12
+ color?: string;
13
+
14
+ /**
15
+ * Optional. Style or styles for the loader component.
16
+ */
5
17
  style?: ViewStyle | ViewStyle[];
6
18
  };
7
19
 
8
20
  export type ProgressBarProps = {
21
+ /**
22
+ * Required. Percentage value to display on the progress bar.
23
+ */
9
24
  percent: number;
25
+
26
+ /**
27
+ * Optional. Color for the progress bar.
28
+ */
29
+ color?: string;
30
+
31
+ /**
32
+ * Optional. Style or styles for the progress bar component.
33
+ */
10
34
  style?: ViewStyle | ViewStyle[];
11
35
  };
@@ -10,8 +10,8 @@ import {Icon} from '../Icon';
10
10
 
11
11
  const PopupNotify: React.FC<PopupNotifyProps> = ({
12
12
  image,
13
- title,
14
- description,
13
+ title = 'Title',
14
+ description = 'Description',
15
15
  information,
16
16
  secondary,
17
17
  primary,
@@ -206,12 +206,4 @@ const styles = StyleSheet.create({
206
206
  },
207
207
  });
208
208
 
209
- PopupNotify.defaultProps = {
210
- title: 'Title',
211
- primary: {
212
- title: 'Primary',
213
- onPress: () => {},
214
- },
215
- };
216
-
217
209
  export default PopupNotify;
package/Skeleton/types.ts CHANGED
@@ -1,3 +1,6 @@
1
1
  export type SkeletonTypes = {
2
+ /**
3
+ * Optional. Custom styles for the Skeleton component.
4
+ */
2
5
  style?: object;
3
6
  };