@momo-kits/foundation 0.81.43 → 0.88.1-beta.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.
@@ -1,4 +1,4 @@
1
- import React, {FC, useContext} from 'react';
1
+ import React, {forwardRef, useContext} from 'react';
2
2
  import {FlatList, FlatListProps, View} from 'react-native';
3
3
  import Item, {SpanNumber} from './Item';
4
4
  import {GridContext} from './index';
@@ -11,39 +11,45 @@ export interface ItemListProps extends FlatListProps<any> {
11
11
  widthSpan?: SpanNumber;
12
12
  }
13
13
 
14
- const ItemList: FC<ItemListProps> = ({
15
- renderItem,
16
- widthSpan,
17
- style,
18
- contentContainerStyle,
19
- ...props
20
- }) => {
21
- const {gutterSize, numberOfColumns} = useContext(GridContext);
22
- const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
23
- const numColumns = Math.floor(numberOfColumns / widthItem);
24
- const indexBegin = props?.data?.map((_i, index) => index * numColumns);
25
- const _renderItem = (item: any) => {
26
- if (indexBegin?.includes(item?.index)) {
27
- return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
28
- }
14
+ const ItemList = forwardRef(
15
+ (
16
+ {
17
+ renderItem,
18
+ widthSpan,
19
+ style,
20
+ contentContainerStyle,
21
+ ...props
22
+ }: ItemListProps,
23
+ ref,
24
+ ) => {
25
+ const {gutterSize, numberOfColumns} = useContext(GridContext);
26
+ const widthItem = (widthSpan ?? numberOfColumns) as SpanNumber;
27
+ const numColumns = Math.floor(numberOfColumns / widthItem);
28
+ const indexBegin = props?.data?.map((_i, index) => index * numColumns);
29
+ const _renderItem = (item: any) => {
30
+ if (indexBegin?.includes(item?.index)) {
31
+ return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
32
+ }
33
+ return (
34
+ <View style={{paddingLeft: gutterSize}}>
35
+ <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>
36
+ </View>
37
+ );
38
+ };
39
+
29
40
  return (
30
- <View style={{paddingLeft: gutterSize}}>
31
- <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>
32
- </View>
41
+ <FlatList
42
+ ref={ref as React.RefObject<FlatList>}
43
+ {...props}
44
+ numColumns={numColumns}
45
+ renderItem={_renderItem}
46
+ horizontal={false}
47
+ ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
48
+ style={[style, styles.protectedStyle]}
49
+ contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
50
+ />
33
51
  );
34
- };
35
-
36
- return (
37
- <FlatList
38
- {...props}
39
- numColumns={numColumns}
40
- renderItem={_renderItem}
41
- horizontal={false}
42
- ItemSeparatorComponent={() => <View style={{height: gutterSize}} />}
43
- style={[style, styles.protectedStyle]}
44
- contentContainerStyle={[contentContainerStyle, styles.protectedStyle]}
45
- />
46
- );
47
- };
52
+ },
53
+ );
48
54
 
49
55
  export default ItemList;
@@ -107,8 +107,9 @@ const Section: React.FC<SectionProps> = ({
107
107
  if (Array.isArray(children)) {
108
108
  let cursor = 0;
109
109
  let rows: any[] = [];
110
- for (let i = 0; i < children.length; ++i) {
111
- 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];
112
113
  const totalSpan = rows
113
114
  .concat([item])
114
115
  .map(i => i.props?.widthSpan)
@@ -124,7 +125,7 @@ const Section: React.FC<SectionProps> = ({
124
125
  rows = [item];
125
126
  }
126
127
 
127
- if (i == children.length - 1) {
128
+ if (i == arrayChild.length - 1) {
128
129
  cursor += 1;
129
130
  element.push(addRowView(rows, cursor, true));
130
131
  }
@@ -13,7 +13,7 @@ const PaginationNumber: FC<ChildPaginationProps> = ({
13
13
  return (
14
14
  <View style={[style, styles.row]}>
15
15
  <View style={styles.paginationNumberContainer}>
16
- <Text color={Colors.black_01} typography={'label_default'}>{`${
16
+ <Text color={Colors.black_01} typography={'label_default_medium'}>{`${
17
17
  activeIndex + 1
18
18
  }/${dataLength}`}</Text>
19
19
  </View>
@@ -192,12 +192,12 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
192
192
  ]}>
193
193
  {!!image && <Image source={{uri: image}} style={styles.image} />}
194
194
  <View style={styles.content}>
195
- <Text typography={'title_xs'} numberOfLines={1}>
195
+ <Text typography={'header_default_bold'} numberOfLines={1}>
196
196
  {title}
197
197
  </Text>
198
198
  <Description style={[styles.description, descriptionStyle]}>
199
199
  <Text
200
- typography={'paragraph_default'}
200
+ typography={'body_default_regular'}
201
201
  onTextLayout={({nativeEvent: {lines}}) => {
202
202
  const enableScroll = lines.length > 3;
203
203
  if (enableScroll != scrollContent) {
@@ -210,7 +210,7 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
210
210
  {!!error && (
211
211
  <View style={styles.information}>
212
212
  <Text
213
- typography={'description_xs'}
213
+ typography={'description_xs_regular'}
214
214
  color={theme.colors.text.hint}
215
215
  numberOfLines={1}>
216
216
  {translate?.('errorCode')}
package/Radio/index.tsx CHANGED
@@ -7,6 +7,10 @@ import styles from './styles';
7
7
  import {ApplicationContext} from '../Application';
8
8
  import {Spacing} from '../Consts';
9
9
 
10
+ const {
11
+ ScreenContext,
12
+ } = require('react-native/Libraries/Components/ScreenContext');
13
+
10
14
  const Radio: FC<RadioProps> = ({
11
15
  value,
12
16
  groupValue,
@@ -37,28 +41,38 @@ const Radio: FC<RadioProps> = ({
37
41
  };
38
42
  }
39
43
 
44
+ const screenInfo = useContext<any>(ScreenContext);
45
+
40
46
  return (
41
- <TouchableOpacity
42
- accessibilityLabel={`Radio/${label}/${value}`}
43
- onPress={onChange}
44
- disabled={disabled}
45
- style={[
46
- style,
47
- {
48
- flexDirection: 'row',
49
- alignItems: 'center',
47
+ <ScreenContext.Provider
48
+ value={{
49
+ ...screenInfo,
50
+ componentName: 'Radio',
51
+ params: {
52
+ value,
50
53
  },
51
- ]}>
52
- <View
54
+ }}>
55
+ <TouchableOpacity
56
+ onPress={onChange}
57
+ disabled={disabled}
53
58
  style={[
54
- styles.radio,
55
- checkBoxStyle,
56
- disabledStyle,
57
- {marginRight: label ? Spacing.XS : 0},
58
- ]}
59
- />
60
- {!!label && <Text typography={'description_default'}>{label}</Text>}
61
- </TouchableOpacity>
59
+ style,
60
+ {
61
+ flexDirection: 'row',
62
+ alignItems: 'center',
63
+ },
64
+ ]}>
65
+ <View
66
+ style={[
67
+ styles.radio,
68
+ checkBoxStyle,
69
+ disabledStyle,
70
+ {marginRight: label ? Spacing.XS : 0},
71
+ ]}
72
+ />
73
+ {!!label && <Text typography={'body_default_regular'}>{label}</Text>}
74
+ </TouchableOpacity>
75
+ </ScreenContext.Provider>
62
76
  );
63
77
  };
64
78
 
package/Switch/index.tsx CHANGED
@@ -1,13 +1,18 @@
1
- import React, {FC} from 'react';
1
+ import React, {FC, useContext} from 'react';
2
2
  import {TouchableOpacity, View} from 'react-native';
3
3
  import {SwitchProps} from './types';
4
4
  import styles from './styles';
5
5
  import {Colors} from '../Consts';
6
6
 
7
+ const {
8
+ ScreenContext,
9
+ } = require('react-native/Libraries/Components/ScreenContext');
10
+
7
11
  const Switch: FC<SwitchProps> = props => {
8
12
  const {value, onChange, disabled, style} = props;
9
13
  const circleBackgroundColor = value ? Colors.black_01 : Colors.black_03;
10
14
  const circleAlign = value ? 'flex-end' : 'flex-start';
15
+ const screenInfo = useContext<any>(ScreenContext);
11
16
 
12
17
  let backgroundColor = value ? Colors.green_03 : Colors.black_07;
13
18
  if (disabled) {
@@ -15,19 +20,27 @@ const Switch: FC<SwitchProps> = props => {
15
20
  }
16
21
 
17
22
  return (
18
- <TouchableOpacity
19
- accessibilityLabel={'Switch'}
20
- disabled={disabled}
21
- onPress={() => onChange?.(!value)}
22
- style={[
23
- style,
24
- styles.container,
25
- {backgroundColor, alignItems: circleAlign},
26
- ]}>
27
- <View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
28
- <View style={[styles.circleSmall, {backgroundColor}]} />
29
- </View>
30
- </TouchableOpacity>
23
+ <ScreenContext.Provider
24
+ value={{
25
+ ...screenInfo,
26
+ componentName: 'Switch',
27
+ params: {
28
+ value,
29
+ },
30
+ }}>
31
+ <TouchableOpacity
32
+ disabled={disabled}
33
+ onPress={() => onChange?.(!value)}
34
+ style={[
35
+ style,
36
+ styles.container,
37
+ {backgroundColor, alignItems: circleAlign},
38
+ ]}>
39
+ <View style={[styles.circle, {backgroundColor: circleBackgroundColor}]}>
40
+ <View style={[styles.circleSmall, {backgroundColor}]} />
41
+ </View>
42
+ </TouchableOpacity>
43
+ </ScreenContext.Provider>
31
44
  );
32
45
  };
33
46
 
package/Tag/index.tsx CHANGED
@@ -71,7 +71,7 @@ const Tag: FC<TagProps> = ({
71
71
  color={labelColor}
72
72
  />
73
73
  )}
74
- <Text color={labelColor} typography={'label_s'}>
74
+ <Text color={labelColor} typography={'label_s_medium'}>
75
75
  {label}
76
76
  </Text>
77
77
  </View>
package/Text/index.tsx CHANGED
@@ -84,6 +84,7 @@ const Text: React.FC<TextProps> = ({
84
84
  }
85
85
 
86
86
  return {
87
+ ...typoStyle,
87
88
  fontFamily,
88
89
  fontSize: scaleSize(fontSize),
89
90
  lineHeight: scaleSize(lineHeight),
@@ -104,7 +105,7 @@ const Text: React.FC<TextProps> = ({
104
105
  };
105
106
 
106
107
  Text.defaultProps = {
107
- typography: 'paragraph_default',
108
+ typography: 'body_default_regular',
108
109
  };
109
110
 
110
111
  export {Text, scaleSize};
package/Text/styles.ts CHANGED
@@ -1,4 +1,42 @@
1
1
  export default {
2
+ headline_default_bold: {fontSize: 24, lineHeight: 32, fontWeight: '700'},
3
+ header_m_bold: {fontSize: 18, lineHeight: 28, fontWeight: '700'},
4
+ header_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
5
+ header_s_semibold: {fontSize: 14, lineHeight: 20, fontWeight: '600'},
6
+ header_xs_semibold: {fontSize: 12, lineHeight: 16, fontWeight: '600'},
7
+ body_default_regular: {fontSize: 14, lineHeight: 20, fontWeight: '400'},
8
+ body_regularstrikethrought: {
9
+ fontSize: 14,
10
+ lineHeight: 20,
11
+ fontWeight: '400',
12
+ textDecorationLine: 'line-through',
13
+ },
14
+ description_default_regular: {
15
+ fontSize: 12,
16
+ lineHeight: 16,
17
+ fontWeight: '400',
18
+ },
19
+ description_default_regularstrikethrought: {
20
+ fontSize: 12,
21
+ lineHeight: 16,
22
+ fontWeight: '400',
23
+ textDecorationLine: 'line-through',
24
+ },
25
+ description_xs_regular: {fontSize: 10, lineHeight: 14, fontWeight: '400'},
26
+ description_xs_regularstrikethrought: {
27
+ fontSize: 10,
28
+ lineHeight: 14,
29
+ fontWeight: '400',
30
+ textDecorationLine: 'line-through',
31
+ },
32
+ label_default_medium: {fontSize: 14, lineHeight: 20, fontWeight: '500'},
33
+ label_s_medium: {fontSize: 12, lineHeight: 16, fontWeight: '500'},
34
+ label_xs_medium: {fontSize: 10, lineHeight: 14, fontWeight: '500'},
35
+ action_default_bold: {fontSize: 16, lineHeight: 22, fontWeight: '700'},
36
+ action_s_bold: {fontSize: 14, lineHeight: 20, fontWeight: '700'},
37
+ action_xs_bold: {fontSize: 12, lineHeight: 16, fontWeight: '700'},
38
+ action_xxs_bold: {fontSize: 10, lineHeight: 14, fontWeight: '700'},
39
+ /**non-support**/
2
40
  headline_default: {
3
41
  fontSize: 28,
4
42
  lineHeight: 34,
package/Text/types.ts CHANGED
@@ -14,27 +14,21 @@ export type TypographyWeight = {
14
14
  };
15
15
 
16
16
  export type Typography =
17
- | 'headline_default'
18
- | 'headline_s'
19
- | 'headline_l'
20
- | 'headline_xl'
21
- | 'title_default'
22
- | 'title_xs'
23
- | 'title_s'
24
- | 'header_default'
25
- | 'header_xs'
26
- | 'header_s'
27
- | 'paragraph_default'
28
- | 'paragraph_bold'
29
- | 'paragraph_italic'
30
- | 'description_default'
31
- | 'description_xs'
32
- | 'description_s'
33
- | 'label_default'
34
- | 'label_xxs'
35
- | 'label_xs'
36
- | 'label_s'
37
- | 'action_default'
38
- | 'action_xxs'
39
- | 'action_xs'
40
- | 'action_s';
17
+ | 'headline_default_bold'
18
+ | 'header_m_bold'
19
+ | 'header_default_bold'
20
+ | 'header_s_semibold'
21
+ | 'header_xs_semibold'
22
+ | 'body_default_regular'
23
+ | 'body_regularstrikethrought'
24
+ | 'description_default_regular'
25
+ | 'description_default_regularstrikethrought'
26
+ | 'description_xs_regular'
27
+ | 'description_xs_regularstrikethrought'
28
+ | 'label_default_medium'
29
+ | 'label_s_medium'
30
+ | 'label_xs_medium'
31
+ | 'action_default_bold'
32
+ | 'action_s_bold'
33
+ | 'action_xs_bold'
34
+ | 'action_xxs_bold';
package/Title/index.tsx CHANGED
@@ -39,7 +39,7 @@ const Title: FC<TitleProps> = ({
39
39
  const renderAction = () => {
40
40
  return !!actionTitle && titleFlex ? (
41
41
  <TouchableOpacity onPress={onPressAction}>
42
- <Text typography={'action_s'} color={theme.colors.primary}>
42
+ <Text typography={'action_s_bold'} color={theme.colors.primary}>
43
43
  {actionTitle}
44
44
  </Text>
45
45
  </TouchableOpacity>
@@ -116,7 +116,7 @@ const Title: FC<TitleProps> = ({
116
116
  {!!description && type !== 'screen' && (
117
117
  <Text
118
118
  numberOfLines={1}
119
- typography={'description_s'}
119
+ typography={'description_default_regular'}
120
120
  color={theme.colors.text.secondary}>
121
121
  {description}
122
122
  </Text>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.81.43",
3
+ "version": "0.88.1-beta.3",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {
package/verify.js CHANGED
@@ -27,8 +27,9 @@ try {
27
27
  }
28
28
 
29
29
  if (
30
- miniInfo?.name !== '@momo-platform/momo-core' &&
31
- miniInfo?.resolutions?.['@momo-platform/momo-core'] !== packageInfo?.version
30
+ miniInfo?.dependencies?.['@momo-platform/momo-core'] &&
31
+ miniInfo?.dependencies?.['@momo-platform/momo-core'] !==
32
+ packageInfo?.version
32
33
  ) {
33
34
  console.error(
34
35
  `Package ${packageInfo.name} version: ${packageInfo.version} require install resolutions @momo-platform/momo-core ${packageInfo.version}`,