@momo-kits/foundation 0.76.1-beta.2 → 0.77.1-optimize.3

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 (100) hide show
  1. package/Application/BottomTab/BottomTabBar.tsx +478 -0
  2. package/Application/BottomTab/index.tsx +134 -0
  3. package/Application/Components.tsx +339 -161
  4. package/Application/ModalScreen.tsx +113 -99
  5. package/Application/Navigation.ts +22 -16
  6. package/Application/NavigationContainer.tsx +99 -48
  7. package/Application/Navigator.ts +110 -41
  8. package/Application/StackScreen.tsx +129 -8
  9. package/Application/index.ts +23 -4
  10. package/Application/types.ts +84 -33
  11. package/Application/utils.tsx +71 -49
  12. package/Assets/DotAnimation.json +256 -0
  13. package/Assets/SpinnerAnimation.json +1027 -0
  14. package/Assets/icon.json +83 -5
  15. package/Assets/icon_bank.json +506 -0
  16. package/Assets/language.json +202 -0
  17. package/Badge/Badge.tsx +56 -0
  18. package/Badge/BadgeDot.tsx +11 -0
  19. package/Badge/BadgeRibbon.tsx +125 -0
  20. package/Badge/Shape.tsx +29 -0
  21. package/Badge/index.tsx +7 -0
  22. package/Badge/styles.ts +58 -0
  23. package/Badge/types.ts +63 -0
  24. package/Button/index.tsx +90 -39
  25. package/Button/styles.ts +19 -0
  26. package/CheckBox/index.tsx +58 -43
  27. package/CheckBox/styles.ts +1 -1
  28. package/CheckBox/types.ts +6 -4
  29. package/Consts/colors+spacing+radius.ts +18 -0
  30. package/Consts/styles.ts +0 -26
  31. package/Consts/theme.ts +4 -0
  32. package/Divider/index.tsx +2 -0
  33. package/Icon/index.tsx +14 -9
  34. package/Icon/types.ts +4 -3
  35. package/IconButton/index.tsx +24 -15
  36. package/Image/index.tsx +63 -47
  37. package/Image/styles.ts +1 -9
  38. package/Image/types.ts +5 -1
  39. package/Input/Input.tsx +227 -116
  40. package/Input/InputDropDown.tsx +132 -0
  41. package/Input/InputMoney.tsx +174 -111
  42. package/Input/InputOTP.tsx +257 -0
  43. package/Input/InputSearch.tsx +160 -132
  44. package/Input/InputTextArea.tsx +150 -123
  45. package/Input/common.tsx +42 -17
  46. package/Input/index.tsx +204 -18
  47. package/Input/styles.ts +44 -7
  48. package/Input/utils.ts +2 -2
  49. package/Layout/Card.tsx +67 -29
  50. package/Layout/FloatingButton.tsx +149 -0
  51. package/Layout/GridSystem.tsx +31 -21
  52. package/Layout/Item.tsx +21 -25
  53. package/Layout/ItemList.tsx +55 -0
  54. package/Layout/ItemSectionList.tsx +39 -0
  55. package/Layout/Screen.tsx +343 -153
  56. package/Layout/Section.tsx +66 -34
  57. package/Layout/index.ts +13 -3
  58. package/Layout/styles.ts +101 -0
  59. package/Layout/types.ts +1 -39
  60. package/Layout/utils.ts +27 -52
  61. package/Loader/DotLoader.tsx +37 -0
  62. package/Loader/Loader.tsx +13 -0
  63. package/Loader/ProgressBar.tsx +44 -0
  64. package/Loader/Spinner.tsx +29 -0
  65. package/Loader/index.tsx +4 -0
  66. package/Loader/styles.ts +10 -0
  67. package/Loader/types.ts +35 -0
  68. package/Loader/utils.ts +25 -0
  69. package/Pagination/PaginationDot.tsx +7 -2
  70. package/Pagination/PaginationNumber.tsx +8 -6
  71. package/Pagination/PaginationScroll.tsx +0 -1
  72. package/Pagination/PaginationWhiteDot.tsx +8 -5
  73. package/Pagination/styles.ts +3 -0
  74. package/Pagination/types.ts +2 -0
  75. package/Popup/PopupNotify.tsx +108 -46
  76. package/Popup/PopupPromotion.tsx +63 -22
  77. package/Popup/types.ts +15 -4
  78. package/Radio/index.tsx +35 -21
  79. package/Radio/types.ts +7 -5
  80. package/Skeleton/index.tsx +1 -1
  81. package/Skeleton/types.ts +3 -0
  82. package/Switch/index.tsx +35 -24
  83. package/Switch/types.ts +5 -3
  84. package/Tag/index.tsx +2 -4
  85. package/Text/index.tsx +27 -22
  86. package/Text/styles.ts +38 -0
  87. package/Text/types.ts +25 -13
  88. package/Text/utils.ts +1 -1
  89. package/Title/index.tsx +186 -0
  90. package/Title/styles.ts +79 -0
  91. package/Title/types.ts +20 -0
  92. package/code-scanner.js +143 -0
  93. package/index.ts +6 -0
  94. package/migrate_typo.js +56 -0
  95. package/package.json +14 -9
  96. package/tsconfig.json +24 -0
  97. package/verify.js +47 -0
  98. package/Application/BottomTab.tsx +0 -52
  99. package/Application/NavigationButton.tsx +0 -54
  100. package/Assets/header-background.png +0 -0
package/Layout/Screen.tsx CHANGED
@@ -1,188 +1,378 @@
1
+ import {useHeaderHeight} from '@react-navigation/stack';
2
+ import React, {
3
+ forwardRef,
4
+ Fragment,
5
+ ReactNode,
6
+ useContext,
7
+ useEffect,
8
+ useRef,
9
+ } from 'react';
1
10
  import {
2
11
  Animated,
3
12
  KeyboardAvoidingView,
13
+ NativeScrollEvent,
14
+ NativeSyntheticEvent,
4
15
  Platform,
5
- Text,
16
+ ScrollViewProps,
6
17
  View,
18
+ ViewProps,
7
19
  } from 'react-native';
8
- import {useHeaderHeight} from '@react-navigation/stack';
9
20
  import {useSafeAreaInsets} from 'react-native-safe-area-context';
10
- import React, {useContext, useEffect, useRef} from 'react';
11
- import {ScreenProps} from '../Application/types';
12
- import {Spacing, Styles} from '../Consts';
13
- import {Card, Section, validateChildren} from './index';
14
- import {ApplicationContext} from '../Application';
21
+ import {
22
+ ApplicationContext,
23
+ HeaderBackground,
24
+ HeaderTitle,
25
+ } from '../Application';
15
26
  import Navigation from '../Application/Navigation';
16
- import {HeaderTitle} from '../Application/Components';
17
-
18
- const Screen: React.FC<ScreenProps> = ({
19
- children,
20
- enableKeyboardAvoidingView = false,
21
- scrollable = false,
22
- navigation,
23
- marginHeader,
24
- useAnimatedHeader = false,
25
- useExtendedHeader = false,
26
- headerBackground,
27
- scrollViewProps,
28
- footerComponent: Footer,
29
- }) => {
30
- const animatedValue = useRef<Animated.Value | undefined>(undefined);
31
- const {theme} = useContext(ApplicationContext);
32
- const insets = useSafeAreaInsets();
33
- const headerTransparent = useAnimatedHeader || useExtendedHeader;
34
-
35
- let handleScroll;
36
- let imageAnimatedStyle = {};
37
- let opacity;
38
- let Component: any = View;
39
- animatedValue.current = undefined;
27
+ import {AnimatedHeader, NavigationOptions} from '../Application/types';
28
+ import {Colors, Spacing, Styles} from '../Consts';
29
+ import {FloatingButton, FloatingButtonProps} from './FloatingButton';
30
+ import {Image} from '../Image';
31
+ import {Card, Section, validateChildren} from './index';
32
+ import styles from './styles';
33
+ import {HeaderType} from './types';
40
34
 
35
+ export interface ScreenProps extends ViewProps {
36
+ children: React.ReactNode;
41
37
  /**
42
- * automatic margin content if use header transparent
38
+ * Optional. Navigation object for handling navigation actions.
43
39
  */
44
- if (headerTransparent) {
45
- animatedValue.current = new Animated.Value(0);
46
- marginHeader = marginHeader ?? useHeaderHeight();
47
- if (useExtendedHeader) {
48
- headerBackground = theme.assets?.headerBackground;
49
- }
50
- }
40
+ navigation?: Navigation;
51
41
 
52
- useEffect(() => {
53
- let title = {};
54
- if (useExtendedHeader) {
55
- title = {headerTitle: HeaderTitle};
56
- }
57
- navigation?.setOptions({
58
- animatedValue: animatedValue.current,
59
- headerTransparent,
60
- ...title,
61
- });
62
- }, [useExtendedHeader, useAnimatedHeader]);
42
+ /**
43
+ * Optional. If `true`, enable keyboard avoiding view for the screen.
44
+ */
45
+ enableKeyboardAvoidingView?: boolean;
63
46
 
64
47
  /**
65
- * animated for header stack when used bottom tab
48
+ * Optional. If `true`, the screen content is scrollable.
66
49
  */
67
- useEffect(() => {
68
- const current: any = navigation;
69
- if (headerTransparent) {
70
- return current?.addListener?.('focus', () => {
71
- const stackNavigation = new Navigation(current?.getParent(), theme);
72
- stackNavigation?.setOptions({
73
- animatedValue: animatedValue.current,
74
- headerTransparent: true,
75
- });
76
- });
77
- }
78
- }, [useAnimatedHeader, useExtendedHeader, navigation]);
50
+ scrollable?: boolean;
79
51
 
80
52
  /**
81
- * animated when use scroll && animated value
53
+ * Optional. Set type of header.
82
54
  */
83
- if (scrollable) {
84
- Component = Animated.ScrollView;
85
- if (useAnimatedHeader) {
86
- opacity = animatedValue.current?.interpolate({
87
- inputRange: [0, 100],
88
- outputRange: [1, 0],
89
- extrapolate: 'clamp',
90
- });
91
- imageAnimatedStyle = {
92
- transform: [
93
- {
94
- scale: animatedValue.current?.interpolate?.({
95
- inputRange: [-300, 0, 1],
96
- outputRange: [1.75, 1, 1],
97
- extrapolate: 'clamp',
98
- }),
99
- },
100
- ],
101
- };
102
- handleScroll = Animated.event(
103
- [
55
+ headerType?: HeaderType;
56
+
57
+ /**
58
+ * Optional. Props for the animated component or bool used top navigation animated.
59
+ */
60
+ animatedHeader?: AnimatedHeader;
61
+
62
+ /**
63
+ * Optional. Props for the underlying ScrollView component when `scrollable` is `true`.
64
+ */
65
+ scrollViewProps?: ScrollViewProps;
66
+
67
+ /**
68
+ * Optional. ReactNode representing the header component of the screen.
69
+ */
70
+ headerComponent?: ReactNode;
71
+
72
+ /**
73
+ * Optional. ReactNode representing the footer component of the screen.
74
+ */
75
+ footerComponent?: ReactNode;
76
+
77
+ /**
78
+ * Optional. Background color of the screen.
79
+ */
80
+ backgroundColor?: string;
81
+
82
+ /**
83
+ * Optional. layout card offset overlap header banner.
84
+ */
85
+ layoutOffset?: -8 | -24 | -56;
86
+
87
+ /**
88
+ * Optional. Props for the floating action button.
89
+ */
90
+ floatingButtonProps?: Omit<FloatingButtonProps, 'animatedValue' | 'bottom'>;
91
+
92
+ /**
93
+ * Optional. If `true`, the screen content is using grid layout by span.
94
+ */
95
+ useGridLayout?: boolean;
96
+ }
97
+
98
+ const Screen = forwardRef(
99
+ (
100
+ {
101
+ children,
102
+ enableKeyboardAvoidingView = false,
103
+ scrollable = false,
104
+ navigation,
105
+ animatedHeader,
106
+ scrollViewProps,
107
+ headerComponent: Header,
108
+ footerComponent: Footer,
109
+ layoutOffset = -56,
110
+ backgroundColor,
111
+ headerType = 'default',
112
+ floatingButtonProps,
113
+ useGridLayout = true,
114
+ }: ScreenProps,
115
+ ref,
116
+ ) => {
117
+ const animatedValue = useRef<Animated.Value>(new Animated.Value(0));
118
+ const {theme} = useContext(ApplicationContext);
119
+ const insets = useSafeAreaInsets();
120
+ const heightHeader = useHeaderHeight();
121
+ const currentTint = useRef(Colors.black_01);
122
+ const isTab = navigation?.instance?.getState?.()?.type == 'tab';
123
+
124
+ let styleAnimatedHeader: NavigationOptions;
125
+ let handleScroll;
126
+ let headerBackground: string | undefined = undefined;
127
+ let Component: any = View;
128
+ let keyboardVerticalOffset = heightHeader - 20;
129
+
130
+ if (headerType == 'extended' || animatedHeader) {
131
+ keyboardVerticalOffset = -20;
132
+ }
133
+
134
+ if (headerType == 'extended') {
135
+ headerBackground = theme.assets?.headerBackground;
136
+ }
137
+
138
+ useEffect(() => {
139
+ if (animatedHeader) {
140
+ styleAnimatedHeader = {
141
+ headerTransparent: true,
142
+ headerBackground: (props: any) => (
143
+ <HeaderBackground
144
+ {...props}
145
+ animatedValue={animatedValue.current}
146
+ />
147
+ ),
148
+ headerTitle: (props: any) => (
149
+ <HeaderTitle {...props} animatedValue={animatedValue.current} />
150
+ ),
151
+ };
152
+ if (animatedHeader.type == 'surface') {
153
+ styleAnimatedHeader = {
154
+ headerTransparent: true,
155
+ headerBackground: (props: any) => (
156
+ <HeaderBackground
157
+ {...props}
158
+ image={null}
159
+ backgroundColor={theme.colors.background.surface}
160
+ useBorder={true}
161
+ animatedValue={animatedValue.current}
162
+ />
163
+ ),
164
+ };
165
+ }
166
+ navigation?.setOptions(styleAnimatedHeader);
167
+ }
168
+ }, [animatedHeader]);
169
+
170
+ useEffect(() => {
171
+ if (!animatedHeader) {
172
+ let headerOptions: NavigationOptions;
173
+ switch (headerType) {
174
+ case 'none':
175
+ headerOptions = {
176
+ headerTransparent: true,
177
+ headerBackground: () => null,
178
+ headerShown: false,
179
+ };
180
+ break;
181
+
182
+ case 'surface':
183
+ headerOptions = {
184
+ headerTransparent: false,
185
+ headerShown: true,
186
+ headerTintColor: theme.colors.text.default,
187
+ headerBackground: (props: any) => (
188
+ <HeaderBackground
189
+ {...props}
190
+ image={null}
191
+ backgroundColor={theme.colors.background.surface}
192
+ useBorder={true}
193
+ />
194
+ ),
195
+ headerTitle: (props: any) => <HeaderTitle {...props} />,
196
+ };
197
+ break;
198
+
199
+ case 'extended':
200
+ headerOptions = {
201
+ headerShown: true,
202
+ headerTransparent: true,
203
+ headerTintColor: Colors.black_01,
204
+ headerBackground: () => null,
205
+ headerTitle: (props: any) => <HeaderTitle {...props} />,
206
+ };
207
+ break;
208
+
209
+ default:
210
+ headerOptions = {
211
+ headerTransparent: false,
212
+ headerShown: true,
213
+ headerTintColor: Colors.black_01,
214
+ headerBackground: (props: any) => <HeaderBackground {...props} />,
215
+ };
216
+ }
217
+ navigation?.setOptions(headerOptions);
218
+ }
219
+ }, [headerType]);
220
+
221
+ /**
222
+ * animated when use scroll && animated value
223
+ */
224
+ if (scrollable) {
225
+ Component = Animated.ScrollView;
226
+ handleScroll = scrollViewProps?.onScroll;
227
+ if (animatedHeader || floatingButtonProps) {
228
+ handleScroll = Animated.event(
229
+ [
230
+ {
231
+ nativeEvent: {
232
+ contentOffset: {y: animatedValue.current as Animated.Value},
233
+ },
234
+ },
235
+ ],
104
236
  {
105
- nativeEvent: {
106
- contentOffset: {y: animatedValue.current as Animated.Value},
237
+ useNativeDriver: true,
238
+ listener: (e: NativeSyntheticEvent<NativeScrollEvent>) => {
239
+ if (animatedHeader?.type == 'surface') {
240
+ const offsetY = e.nativeEvent.contentOffset.y;
241
+ let color = Colors.black_01;
242
+ if (offsetY > 50) {
243
+ color = theme.colors.text.default;
244
+ }
245
+ if (color != currentTint.current) {
246
+ currentTint.current = color;
247
+ navigation?.setOptions({
248
+ headerTintColor: color,
249
+ });
250
+ }
251
+ }
107
252
  },
108
253
  },
109
- ],
110
- {useNativeDriver: true},
111
- );
254
+ );
255
+ }
112
256
  }
113
- }
114
257
 
115
- /**
116
- * build content for screen
117
- */
118
- const renderContent = () => {
119
- const results = validateChildren(children, [Section, Card]);
120
- if (Array.isArray(results)) {
121
- return results.map((item, index) => {
122
- const space = item.props?.useMargin === false ? 0 : Spacing.M;
258
+ /**
259
+ * render top navigation banner
260
+ */
261
+ const renderHeader = () => {
262
+ if (typeof animatedHeader?.component === 'function') {
263
+ return animatedHeader?.component({
264
+ animatedValue: animatedValue.current,
265
+ });
266
+ }
267
+ };
268
+
269
+ /**
270
+ * build content for screen
271
+ */
272
+ const renderContent = (children: any): any => {
273
+ const results = validateChildren(children, [Section, Card, undefined]);
274
+ if (Array.isArray(results)) {
275
+ return results.map((item, index) => {
276
+ const space = item?.props?.useMargin === false ? 0 : Spacing.M;
277
+ if (item?.type == Fragment) {
278
+ return renderContent(item?.props?.children);
279
+ }
280
+ if (item) {
281
+ return (
282
+ <View
283
+ key={`ScreenItem${index}`}
284
+ style={{
285
+ marginTop: space,
286
+ flex: item.props?.expanded ? 1 : undefined,
287
+ }}>
288
+ {item}
289
+ </View>
290
+ );
291
+ }
292
+ });
293
+ } else {
294
+ const item: any = children;
295
+ const space = item?.props?.useMargin === false ? 0 : Spacing.M;
296
+ if (item?.type == Fragment) {
297
+ return renderContent(item?.props?.children);
298
+ }
123
299
  return (
124
300
  <View
125
- key={`ScreenItem${index}`}
301
+ key={`ScreenItem`}
126
302
  style={{
127
303
  marginTop: space,
128
- flex: item.props?.expanded ? 1 : undefined,
304
+ flex: item?.props?.expanded ? 1 : undefined,
129
305
  }}>
130
- {item}
306
+ {children}
131
307
  </View>
132
308
  );
133
- });
134
- }
135
- return results;
136
- };
137
-
138
- return (
139
- <View style={Styles.flex} accessibilityLabel={`ScreenContainer`}>
140
- <View
141
- style={{
142
- position: 'absolute',
143
- maxHeight: 215,
144
- width: '100%',
145
- overflow: 'hidden',
146
- }}>
309
+ }
310
+ };
311
+
312
+ return (
313
+ <View style={[Styles.flex, {backgroundColor}]}>
147
314
  {!!headerBackground && (
148
- <Animated.Image
149
- source={{
150
- uri: headerBackground,
151
- }}
152
- style={{
153
- opacity: opacity ?? 1,
154
- aspectRatio: 1.75,
155
- ...imageAnimatedStyle,
156
- }}
157
- />
315
+ <>
316
+ <Image
317
+ source={{
318
+ uri: headerBackground,
319
+ }}
320
+ style={styles.extendedHeader}
321
+ />
322
+ <View style={{height: heightHeader}} />
323
+ </>
158
324
  )}
325
+ <KeyboardAvoidingView
326
+ style={Styles.flex}
327
+ enabled={enableKeyboardAvoidingView}
328
+ keyboardVerticalOffset={keyboardVerticalOffset}
329
+ behavior={Platform.select({
330
+ ios: 'padding',
331
+ android: undefined,
332
+ })}>
333
+ {Header}
334
+
335
+ <Component
336
+ {...scrollViewProps}
337
+ ref={ref}
338
+ showsVerticalScrollIndicator={false}
339
+ onScroll={handleScroll}
340
+ style={Styles.flex}>
341
+ <View
342
+ style={[styles.screenBanner, {maxHeight: 210 + layoutOffset}]}>
343
+ {renderHeader()}
344
+ </View>
345
+ {useGridLayout ? renderContent(children) : children}
346
+ </Component>
347
+
348
+ {floatingButtonProps && (
349
+ <View>
350
+ <FloatingButton
351
+ {...floatingButtonProps}
352
+ animatedValue={animatedValue.current}
353
+ bottom={
354
+ Footer || isTab ? 12 : Math.min(insets.bottom, 21) + Spacing.S
355
+ }
356
+ />
357
+ </View>
358
+ )}
359
+
360
+ {Footer && (
361
+ <View
362
+ style={[
363
+ styles.shadow,
364
+ {
365
+ paddingBottom: Math.min(insets.bottom, 21) + Spacing.S,
366
+ backgroundColor: theme.colors.background.surface,
367
+ },
368
+ ]}>
369
+ <Section>{Footer}</Section>
370
+ </View>
371
+ )}
372
+ </KeyboardAvoidingView>
159
373
  </View>
160
- <KeyboardAvoidingView
161
- style={Styles.flex}
162
- enabled={enableKeyboardAvoidingView}
163
- behavior={Platform.select({
164
- ios: 'padding',
165
- android: undefined,
166
- })}>
167
- <Component
168
- {...scrollViewProps}
169
- onScroll={handleScroll}
170
- style={[Styles.flex, {marginTop: marginHeader}]}>
171
- {renderContent()}
172
- </Component>
173
- {Footer && (
174
- <View
175
- style={{
176
- paddingTop: Spacing.S,
177
- paddingBottom: insets.bottom + Spacing.S,
178
- backgroundColor: theme.colors.background.surface,
179
- }}>
180
- <Section>{Footer}</Section>
181
- </View>
182
- )}
183
- </KeyboardAvoidingView>
184
- </View>
185
- );
186
- };
374
+ );
375
+ },
376
+ );
187
377
 
188
378
  export default Screen;
@@ -1,16 +1,41 @@
1
- import React from 'react';
2
- import {Dimensions, View} from 'react-native';
1
+ import React, {Fragment, useContext} from 'react';
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
- import {GRIDVIEW} from '../Consts';
7
6
  import Item from './Item';
7
+ import {ApplicationContext} from '../Application';
8
+ import styles from './styles';
9
+ import {Image} from '../Image';
10
+ import ItemList from './ItemList';
11
+
12
+ export interface SectionProps extends ViewProps {
13
+ /**
14
+ * Optional. If `true`, the Section component will be displayed in an expanded state.
15
+ * Defaults to `false` if not provided.
16
+ */
17
+ expanded?: boolean;
18
+
19
+ /**
20
+ * Optional. If `true`, margin will be applied to the Section component.
21
+ * Defaults to `false` if not provided.
22
+ */
23
+ useMargin?: boolean;
24
+
25
+ /**
26
+ * Optional. Background image for the Section component.
27
+ */
28
+ backgroundImage?: string;
29
+ }
8
30
 
9
31
  const Section: React.FC<SectionProps> = ({
10
32
  children,
11
33
  useMargin = true,
12
- backgroundColor,
34
+ backgroundImage,
35
+ style,
36
+ ...props
13
37
  }) => {
38
+ const {showGrid} = useContext(ApplicationContext);
14
39
  const {numberOfColumns} = useGridSystem();
15
40
 
16
41
  const gutterSize = 12;
@@ -26,7 +51,6 @@ const Section: React.FC<SectionProps> = ({
26
51
  const gridContext: GridContextProps = {
27
52
  numberOfColumns,
28
53
  gutterSize,
29
- margin,
30
54
  sizePerSpan,
31
55
  getSizeSpan: span => {
32
56
  return span * sizePerSpan + (span - 1) * gutterSize;
@@ -37,20 +61,7 @@ const Section: React.FC<SectionProps> = ({
37
61
  * render overlay only dev mode
38
62
  */
39
63
  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
- );
64
+ return <View pointerEvents={'none'} style={styles.boxGridSection} />;
54
65
  };
55
66
 
56
67
  /**
@@ -96,8 +107,9 @@ const Section: React.FC<SectionProps> = ({
96
107
  if (Array.isArray(children)) {
97
108
  let cursor = 0;
98
109
  let rows: any[] = [];
99
- for (let i = 0; i < children.length; ++i) {
100
- 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];
101
113
  const totalSpan = rows
102
114
  .concat([item])
103
115
  .map(i => i.props?.widthSpan)
@@ -113,30 +125,50 @@ const Section: React.FC<SectionProps> = ({
113
125
  rows = [item];
114
126
  }
115
127
 
116
- if (i == children.length - 1) {
128
+ if (i == arrayChild.length - 1) {
117
129
  cursor += 1;
118
130
  element.push(addRowView(rows, cursor, true));
119
131
  }
120
132
  }
121
133
  } else {
122
134
  element.push(children);
135
+ if (children?.type == Fragment) {
136
+ return renderView(children?.props.children);
137
+ }
123
138
  }
124
139
  return element;
125
140
  };
126
141
 
127
142
  return (
128
- <GridContext.Provider value={gridContext}>
143
+ <GridContext.Provider
144
+ value={{
145
+ numberOfColumns,
146
+ gutterSize,
147
+ sizePerSpan,
148
+ getSizeSpan: span => {
149
+ return span * sizePerSpan + (span - 1) * gutterSize;
150
+ },
151
+ }}>
129
152
  <View
130
- accessibilityLabel={`Section`}
131
- style={{
132
- width: widthSection,
133
- marginHorizontal: gridContext.margin,
134
- flexDirection: 'row',
135
- flexWrap: 'wrap',
136
- backgroundColor: backgroundColor,
137
- }}>
138
- {renderView(validateChildren(children, [Item]))}
139
- {GRIDVIEW && renderOverlay()}
153
+ {...props}
154
+ style={[
155
+ style,
156
+ styles.protectedStyle,
157
+ {
158
+ width: widthSection,
159
+ marginHorizontal: margin,
160
+ flexDirection: 'row',
161
+ flexWrap: 'wrap',
162
+ },
163
+ ]}>
164
+ {!!backgroundImage && (
165
+ <Image
166
+ source={{uri: backgroundImage}}
167
+ style={styles.imageBackground}
168
+ />
169
+ )}
170
+ {renderView(validateChildren(children, [Item, ItemList]))}
171
+ {showGrid && renderOverlay()}
140
172
  </View>
141
173
  </GridContext.Provider>
142
174
  );