@momo-kits/foundation 0.152.1-beta.7 → 0.152.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.
@@ -330,6 +330,40 @@ const BottomTab: React.FC<BottomTabProps> = ({
330
330
  {tabs.map((item, index) => {
331
331
  const isNum = !isNaN(parseInt(`${item?.badgeLabel}`, 10));
332
332
  const isDot = typeof item?.badgeLabel === 'string' && !item?.badgeLabel;
333
+ const isNumZero = isNum && Number(item.badgeLabel) === 0;
334
+
335
+ let badgeLabel = item?.badgeLabel;
336
+ if (isNumZero) {
337
+ badgeLabel = undefined;
338
+ }
339
+
340
+ let badgeStyle: {
341
+ marginRight: number;
342
+ top: number;
343
+ backgroundColor: string;
344
+ width?: number;
345
+ } = {
346
+ marginRight: -8,
347
+ top: -4,
348
+ backgroundColor: Colors.orange_03,
349
+ };
350
+
351
+ if (isNum) {
352
+ badgeStyle = {
353
+ marginRight: -4,
354
+ top: -4,
355
+ backgroundColor: Colors.red_03,
356
+ };
357
+ }
358
+ if (isDot) {
359
+ badgeStyle = {
360
+ marginRight: -2,
361
+ top: -2,
362
+ backgroundColor: Colors.orange_03,
363
+ width: 12,
364
+ };
365
+ }
366
+
333
367
  return (
334
368
  <Tab.Screen
335
369
  key={`BottomTab-${item.name}`}
@@ -358,20 +392,19 @@ const BottomTab: React.FC<BottomTabProps> = ({
358
392
  },
359
393
  styles.tabStyle,
360
394
  ],
361
- tabBarBadge: item?.badgeLabel,
362
- tabBarBadgeStyle: {
363
- borderColor: 'white',
364
- borderWidth: 2,
365
- fontSize: 10,
366
- lineHeight: 14,
367
- fontWeight: 'bold',
368
- alignSelf: 'center',
369
- fontFamily: exportFontFamily('bold'),
370
- marginRight: isDot ? -2 : isNum ? -4 : -8,
371
- top: isDot ? -2 : -4,
372
- backgroundColor: isNum ? Colors.red_03 : Colors.orange_03,
373
- width: isDot ? 12 : undefined,
374
- },
395
+ tabBarBadge: badgeLabel,
396
+ tabBarBadgeStyle: [
397
+ {
398
+ borderColor: 'white',
399
+ borderWidth: 2,
400
+ fontSize: 10,
401
+ lineHeight: 14,
402
+ fontWeight: 'bold',
403
+ alignSelf: 'center',
404
+ fontFamily: exportFontFamily('bold'),
405
+ },
406
+ badgeStyle,
407
+ ],
375
408
  tabBarIcon: ({ color }) => (
376
409
  <Icon source={item.icon} color={color} size={28} />
377
410
  ),
@@ -40,6 +40,7 @@ const NavigationContainer: React.FC<NavigationContainerProps> = ({
40
40
  enableHapticDialog: true,
41
41
  enableForceFoundationList: false,
42
42
  enableHapticBottomTab: true,
43
+ scaleSizeMaxRate: 1.5,
43
44
  },
44
45
  }) => {
45
46
  const context = useContext<any>(MiniAppContext);
@@ -0,0 +1,16 @@
1
+ import React, { FC } from 'react';
2
+ import { ScaleSizeContext } from '../Context';
3
+ import { ScaleSizeProviderProps } from './types';
4
+
5
+ const ScaleSizeProvider: FC<ScaleSizeProviderProps> = ({
6
+ scaleSizeMaxRate,
7
+ children,
8
+ }) => {
9
+ return (
10
+ <ScaleSizeContext.Provider value={{ scaleSizeMaxRate }}>
11
+ {children}
12
+ </ScaleSizeContext.Provider>
13
+ );
14
+ };
15
+
16
+ export default ScaleSizeProvider;
@@ -16,6 +16,7 @@ export * from './Components/SearchHeader';
16
16
  import { exportHeaderTitle, setAutomationID, useComponentId } from './utils';
17
17
  import Navigation from './Navigation';
18
18
  import Navigator from './Navigator';
19
+ import ScaleSizeProvider from './ScaleSizeProvider';
19
20
 
20
21
  export {
21
22
  NavigationContainer,
@@ -27,4 +28,5 @@ export {
27
28
  Navigation,
28
29
  Navigator,
29
30
  exportHeaderTitle,
31
+ ScaleSizeProvider,
30
32
  };
@@ -106,6 +106,11 @@ export type Theme = {
106
106
  };
107
107
  };
108
108
 
109
+ export type ScaleSizeProviderProps = {
110
+ scaleSizeMaxRate?: number;
111
+ children: ViewProps['children'];
112
+ };
113
+
109
114
  export type Context = {
110
115
  [key: string]: any;
111
116
  theme: Theme;
@@ -151,7 +156,7 @@ export type NavigationContainerProps = {
151
156
  maxApi: any;
152
157
  initialParams?: any;
153
158
  localize: LocalizeProps;
154
- features: FeaturesFlag;
159
+ features?: FeaturesFlag;
155
160
  };
156
161
 
157
162
  export type WidgetContainerProps = {
package/Context/index.ts CHANGED
@@ -9,6 +9,9 @@ const MiniAppContext = (Platform as any).MiniAppContext ?? Context;
9
9
  const ScreenContext = (Platform as any).ScreenContext ?? Context;
10
10
  const ComponentContext = (Platform as any).ComponentContext ?? Context;
11
11
  const SkeletonContext = createContext({ loading: false });
12
+ const ScaleSizeContext = createContext<{ scaleSizeMaxRate?: number }>({
13
+ scaleSizeMaxRate: undefined,
14
+ });
12
15
  const TrackingScopeContext = createContext<{ scopeName?: string }>({
13
16
  scopeName: undefined,
14
17
  });
@@ -20,4 +23,5 @@ export {
20
23
  ComponentContext,
21
24
  SkeletonContext,
22
25
  TrackingScopeContext,
26
+ ScaleSizeContext,
23
27
  };
@@ -26,6 +26,7 @@ import {
26
26
  import { InputTextAreaProps } from './index';
27
27
  import styles from './styles';
28
28
  import SystemTextInput from './SystemTextInput';
29
+ import { useComponentId } from '../Application';
29
30
 
30
31
  const InputTextArea = forwardRef(
31
32
  (
@@ -51,6 +52,14 @@ const InputTextArea = forwardRef(
51
52
  }: InputTextAreaProps,
52
53
  ref,
53
54
  ) => {
55
+
56
+ const componentName = 'InputTextArea';
57
+
58
+
59
+ const { componentId } = useComponentId(
60
+ `${componentName}/${placeholder}`,
61
+ props.accessibilityLabel,
62
+ );
54
63
  const { theme } = useContext(ApplicationContext);
55
64
  const [focused, setFocused] = useState(false);
56
65
  const [inputValue, setInputValue] = useState(defaultValue ?? '');
@@ -129,12 +138,18 @@ const InputTextArea = forwardRef(
129
138
  disabled={disabled}
130
139
  floatingIcon={floatingIcon}
131
140
  required={required}
141
+ componentId={componentId}
132
142
  />
133
143
  <View style={styles.rowArea}>
134
144
  <View style={styles.textAreaView}>
135
145
  <SystemTextInput
136
146
  {...props}
137
147
  ref={inputRef}
148
+ accessibilityLabel={`${componentId}`}
149
+ accessibilityState={{
150
+ disabled: disabled,
151
+ ...props.accessibilityState,
152
+ }}
138
153
  editable={!disabled}
139
154
  textAlignVertical="top"
140
155
  allowFontScaling={false}
@@ -160,11 +175,13 @@ const InputTextArea = forwardRef(
160
175
  <TouchableOpacity
161
176
  style={styles.iconWrapper}
162
177
  onPress={onClearText}
178
+ accessibilityLabel={`${componentId}|clear-icon-touch`}
163
179
  >
164
180
  <Icon
165
181
  source="24_navigation_close_circle_full"
166
182
  size={16}
167
183
  color={theme.colors.text.hint}
184
+ accessibilityLabel={`${componentId}|clear-icon`}
168
185
  />
169
186
  </TouchableOpacity>
170
187
  )}
package/Text/utils.ts CHANGED
@@ -1,31 +1,64 @@
1
- import {Dimensions, PixelRatio} from 'react-native';
1
+ import { Dimensions, PixelRatio } from 'react-native';
2
+ import { useContext } from 'react';
3
+ import { MiniAppContext, ScaleSizeContext } from '../Context';
2
4
 
3
5
  const deviceWidth = Dimensions.get('window').width;
4
6
  const DEFAULT_SCREEN_SIZE = 375;
5
7
  const MAX_FONT_SCALE = 1.5;
6
8
  const MAX_DEVICE_SCALE = 5;
7
9
 
10
+ const useScaleSize = (size: number) => {
11
+ const context = useContext<any>(MiniAppContext);
12
+ const scaleSizeContext = useContext<any>(ScaleSizeContext);
13
+ const fontScale = PixelRatio.getFontScale();
14
+ const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
15
+ const maxScaleRate =
16
+ scaleSizeContext?.scaleSizeMaxRate ||
17
+ context?.features?.scaleSizeMaxRate ||
18
+ MAX_FONT_SCALE;
19
+
20
+ let fontSizeDeviceScale = size;
21
+ let fontSizeOSScale = size;
22
+
23
+ if (deviceScale > 1) {
24
+ fontSizeDeviceScale = Math.min(
25
+ fontSizeDeviceScale * deviceScale,
26
+ fontSizeDeviceScale + maxScaleRate,
27
+ );
28
+ }
29
+
30
+ if (fontScale > 1) {
31
+ fontSizeOSScale = Math.min(
32
+ fontSizeOSScale * fontScale,
33
+ fontSizeOSScale * maxScaleRate,
34
+ );
35
+ }
36
+
37
+ return Math.max(fontSizeDeviceScale, fontSizeOSScale);
38
+ };
39
+
8
40
  const scaleSize = (size: number) => {
9
41
  const fontScale = PixelRatio.getFontScale();
10
42
  const deviceScale = deviceWidth / DEFAULT_SCREEN_SIZE;
43
+
11
44
  let fontSizeDeviceScale = size;
12
45
  let fontSizeOSScale = size;
13
46
 
14
47
  if (deviceScale > 1) {
15
48
  fontSizeDeviceScale = Math.min(
16
49
  fontSizeDeviceScale * deviceScale,
17
- fontSizeDeviceScale + MAX_DEVICE_SCALE
50
+ fontSizeDeviceScale + MAX_DEVICE_SCALE,
18
51
  );
19
52
  }
20
53
 
21
54
  if (fontScale > 1) {
22
55
  fontSizeOSScale = Math.min(
23
56
  fontSizeOSScale * fontScale,
24
- fontSizeOSScale * MAX_FONT_SCALE
57
+ fontSizeOSScale * MAX_FONT_SCALE,
25
58
  );
26
59
  }
27
60
 
28
61
  return Math.max(fontSizeDeviceScale, fontSizeOSScale);
29
62
  };
30
63
 
31
- export {scaleSize};
64
+ export { scaleSize, useScaleSize };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.152.1-beta.7",
3
+ "version": "0.152.3",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},
package/publish.sh CHANGED
@@ -6,12 +6,8 @@ if [ "$1" == "stable" ]; then
6
6
  npm version patch
7
7
  npm publish --tag stable --access=public
8
8
  elif [ "$1" == "latest" ]; then
9
- npm version $(npm view @momo-kits/foundation@latest version)
10
- npm version prerelease --preid=rc
11
9
  npm publish --tag latest --access=public
12
10
  elif [ "$1" == "beta" ]; then
13
- npm version $(npm view @momo-kits/foundation@beta version)
14
- npm version prerelease --preid=beta
15
11
  npm publish --tag beta --access=public
16
12
  else
17
13
  npm publish --tag alpha --access=public