@momo-kits/foundation 0.169.5 → 0.169.6-beta.1

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 (127) hide show
  1. package/Application/BottomSheet.hooks.ts +8 -8
  2. package/Application/BottomSheet.parts.tsx +34 -44
  3. package/Application/BottomSheet.tsx +26 -35
  4. package/Application/BottomTab/ActiveIndicator.tsx +14 -15
  5. package/Application/BottomTab/BottomTabBar.styles.ts +18 -1
  6. package/Application/BottomTab/BottomTabBar.tsx +40 -63
  7. package/Application/BottomTab/BottomTabInset.tsx +4 -8
  8. package/Application/BottomTab/CurvedContainer.tsx +20 -16
  9. package/Application/BottomTab/CustomBottomTabItem.tsx +13 -16
  10. package/Application/BottomTab/DuoBarCompression.tsx +19 -13
  11. package/Application/BottomTab/DuoRailTabBar.tsx +13 -17
  12. package/Application/BottomTab/DuoTabBar.tsx +24 -12
  13. package/Application/BottomTab/TabBarIcon.tsx +8 -13
  14. package/Application/BottomTab/TabScreen.tsx +5 -1
  15. package/Application/BottomTab/index.tsx +30 -38
  16. package/Application/BottomTab/metrics.ts +46 -24
  17. package/Application/BottomTab/tabItems.ts +1 -1
  18. package/Application/BottomTab/usePressLift.ts +2 -2
  19. package/Application/Components/BackgroundImageView.tsx +0 -4
  20. package/Application/Components/DuoGlassBackground.tsx +4 -5
  21. package/Application/Components/HeaderAnimated.tsx +0 -4
  22. package/Application/Components/HeaderBackground.tsx +0 -4
  23. package/Application/Components/HeaderExtendHeader.tsx +10 -11
  24. package/Application/Components/HeaderLeft.tsx +1 -2
  25. package/Application/Components/HeaderRight.tsx +1 -2
  26. package/Application/Components/HeaderTitle.shared.ts +9 -11
  27. package/Application/Components/HeaderTitle.tsx +3 -4
  28. package/Application/Components/HeaderToolkitAction.tsx +20 -17
  29. package/Application/Components/NavigationButton.tsx +1 -2
  30. package/Application/Components/SearchHeader.tsx +10 -17
  31. package/Application/Components/TitleJourney.tsx +2 -2
  32. package/Application/Components/TitleLocation.tsx +2 -2
  33. package/Application/Components/TitleUser.tsx +2 -2
  34. package/Application/Components/useToolkitActions.tsx +32 -17
  35. package/Application/Localize.ts +0 -7
  36. package/Application/ModalScreen.tsx +3 -9
  37. package/Application/Navigation.ts +16 -14
  38. package/Application/NavigationContainer.tsx +16 -19
  39. package/Application/Navigator.ts +48 -20
  40. package/Application/StackScreen.tracking.ts +26 -11
  41. package/Application/StackScreen.tsx +35 -8
  42. package/Application/TooltipPortal.tsx +5 -12
  43. package/Application/WidgetContainer.tsx +4 -10
  44. package/Application/__tests__/modalLayout.test.ts +128 -0
  45. package/Application/modalLayout.ts +14 -13
  46. package/Application/navigationOptions.tsx +17 -21
  47. package/Application/types.tabs.ts +0 -1
  48. package/Badge/Badge.tsx +0 -5
  49. package/Badge/BadgeDot.tsx +0 -1
  50. package/Badge/BadgeDotAnimation.tsx +7 -15
  51. package/Badge/BadgeRibbon.tsx +38 -46
  52. package/Badge/Shape.tsx +0 -2
  53. package/Badge/types.ts +2 -2
  54. package/Button/index.tsx +16 -5
  55. package/Button/utils.ts +15 -9
  56. package/CheckBox/index.tsx +0 -4
  57. package/Consts/theme.ts +10 -10
  58. package/Context/index.ts +0 -1
  59. package/Divider/DashDivider.tsx +0 -1
  60. package/Divider/index.tsx +0 -4
  61. package/FoundationList/index.tsx +0 -4
  62. package/Icon/index.tsx +6 -6
  63. package/Icon/types.ts +1 -1
  64. package/IconButton/index.tsx +12 -4
  65. package/Image/index.tsx +7 -9
  66. package/Input/Input.tsx +9 -8
  67. package/Input/InputDropDown.tsx +12 -10
  68. package/Input/InputMoney.tsx +8 -12
  69. package/Input/InputMoneyView.tsx +7 -14
  70. package/Input/InputOTP.tsx +33 -35
  71. package/Input/InputPhoneNumber.tsx +9 -8
  72. package/Input/InputSearch.tsx +6 -4
  73. package/Input/InputTextArea.tsx +0 -4
  74. package/Input/SearchTextTyping.tsx +0 -4
  75. package/Input/SystemTextInput.tsx +2 -7
  76. package/Input/TextTyping.tsx +0 -4
  77. package/Input/common.tsx +12 -26
  78. package/Input/index.tsx +20 -17
  79. package/Input/moneyUtils.ts +4 -10
  80. package/Input/styles.ts +5 -0
  81. package/Input/utils.ts +12 -14
  82. package/Layout/Card.tsx +4 -7
  83. package/Layout/FloatingButton.tsx +0 -4
  84. package/Layout/Item.tsx +2 -6
  85. package/Layout/ItemList.tsx +7 -9
  86. package/Layout/ItemSectionList.tsx +1 -2
  87. package/Layout/ReservedRegions.tsx +25 -25
  88. package/Layout/Screen.tsx +58 -56
  89. package/Layout/Section.tsx +5 -8
  90. package/Layout/TrackingScope.tsx +0 -1
  91. package/Layout/screenContent.tsx +2 -4
  92. package/Layout/screenFooter.tsx +18 -28
  93. package/Layout/screenHeader.tsx +31 -34
  94. package/Layout/screenQuickReturn.tsx +20 -17
  95. package/Layout/screenScroll.ts +7 -4
  96. package/Layout/screenTypes.ts +2 -3
  97. package/Layout/types.ts +4 -2
  98. package/Layout/utils.ts +37 -31
  99. package/Loader/DotLoader.tsx +0 -4
  100. package/Loader/Loader.tsx +0 -4
  101. package/Loader/ProgressBar.tsx +0 -1
  102. package/Loader/Spinner.tsx +0 -4
  103. package/Loader/utils.ts +7 -11
  104. package/Pagination/Dot.tsx +0 -4
  105. package/Pagination/PaginationDot.tsx +0 -1
  106. package/Pagination/PaginationNumber.tsx +3 -5
  107. package/Pagination/PaginationScroll.tsx +0 -5
  108. package/Pagination/PaginationWhiteDot.tsx +0 -1
  109. package/Pagination/index.tsx +0 -4
  110. package/Pagination/types.ts +2 -2
  111. package/Popup/PopupNotify.tsx +48 -44
  112. package/Popup/PopupPromotion.tsx +7 -4
  113. package/Popup/types.ts +4 -4
  114. package/Popup/utils.ts +0 -4
  115. package/Radio/index.tsx +0 -4
  116. package/Skeleton/index.tsx +0 -8
  117. package/Switch/index.tsx +0 -1
  118. package/Tag/index.tsx +1 -5
  119. package/Tag/types.ts +3 -3
  120. package/Text/index.tsx +3 -14
  121. package/Text/styles.ts +1 -1
  122. package/Text/types.ts +6 -1
  123. package/Text/utils.ts +0 -9
  124. package/Title/index.tsx +32 -41
  125. package/ViewBoundary/index.tsx +2 -4
  126. package/index.ts +6 -0
  127. package/package.json +1 -1
@@ -5,9 +5,9 @@ export type PaginationProps = {
5
5
  /**
6
6
  * Optional. Defines the visual style of the Pagination component.
7
7
  * - 'default': Represents the default style.
8
- * - 'black_white': Represents dots on a translucent dark background.
8
+ * - 'black_white': Represents a pagination that have black background.
9
9
  * - 'number': Represents a style where pages are represented by numbers.
10
- * - 'scroll': Rendered as 'default'; use `PaginationScroll` instead.
10
+ * - 'scroll': Represents a scrollable style.
11
11
  */
12
12
  type?: 'default' | 'black_white' | 'number' | 'scroll';
13
13
 
@@ -11,13 +11,6 @@ import { useModalLayout } from '../Application/modalLayout';
11
11
  import { ModalIconButton } from '../Application/ModalIconButton';
12
12
  import { splitHighlightText } from './utils';
13
13
 
14
- const MAX_ROW_TITLE_LENGTH = 12;
15
-
16
- /**
17
- * Notify popup body: optional image, title, description, error code and one or
18
- * two actions. Actions close via `onRequestClose` if given, else pop the modal
19
- * and then run the callback.
20
- */
21
14
  const PopupNotify: React.FC<PopupNotifyProps> = ({
22
15
  image,
23
16
  title = 'Title',
@@ -50,6 +43,10 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
50
43
  descriptionStyle = { maxHeight: scaledMaxHeight };
51
44
  }
52
45
 
46
+ /**
47
+ * on action popup
48
+ * @param callback
49
+ */
53
50
  const onAction = (callback?: () => void) => {
54
51
  if (typeof onRequestClose === 'function') {
55
52
  onRequestClose?.(callback);
@@ -59,6 +56,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
59
56
  }
60
57
  };
61
58
 
59
+ /**
60
+ * build main action of popup
61
+ */
62
62
  const buildAction = () => {
63
63
  const renderRow = () => {
64
64
  return (
@@ -126,13 +126,10 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
126
126
  };
127
127
 
128
128
  if (buttonDirection === 'auto') {
129
- const secondaryTitle = secondary?.title;
130
- if (!secondaryTitle) {
131
- return renderRow();
132
- }
133
- const isLongSecondary = secondaryTitle.length > MAX_ROW_TITLE_LENGTH;
134
- const isLongPrimary = primary.title.length > MAX_ROW_TITLE_LENGTH;
135
- if (isLongSecondary || isLongPrimary) {
129
+ if (
130
+ secondary?.title &&
131
+ (secondary.title.length > 12 || primary.title.length > 12)
132
+ ) {
136
133
  return renderColumn();
137
134
  }
138
135
  return renderRow();
@@ -143,7 +140,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
143
140
  return renderColumn();
144
141
  };
145
142
 
146
- /** Highlighted keywords use weight 600 but keep the body size and line height. */
143
+ /**
144
+ * build description text, highlighted keywords keep size/lineHeight and use weight 600
145
+ */
147
146
  const renderDescription = (text: string) => {
148
147
  const segments = splitHighlightText(text, highlightText);
149
148
  if (!segments) {
@@ -161,6 +160,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
161
160
  });
162
161
  };
163
162
 
163
+ /**
164
+ * build close action
165
+ */
164
166
  const buildCloseIcon = () => {
165
167
  if (typeof onIconClose !== 'function') {
166
168
  return null;
@@ -178,44 +180,48 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
178
180
  );
179
181
  };
180
182
 
181
- const hasCloseIcon = typeof onIconClose === 'function';
182
- // keeps the title clear of the close button on a text only popup
183
- const titleStyle = !image && hasCloseIcon && styles.titleClearClose;
184
-
185
- let descriptionContent: React.ReactNode = description;
186
- if (typeof description === 'string') {
187
- descriptionContent = (
188
- <Text
189
- accessibilityLabel={'description_popup_notify'}
190
- typography={'body_default_regular'}
191
- onTextLayout={({ nativeEvent: { lines } }) => {
192
- const enableScroll = lines.length > 8.5;
193
- if (enableScroll !== scrollContent) {
194
- setScrollContent(enableScroll);
195
- }
196
- }}
197
- >
198
- {renderDescription(description)}
199
- </Text>
200
- );
201
- }
202
-
203
183
  const body = (
204
184
  <>
205
185
  {!!image && (
206
- <Image source={{ uri: image }} style={styles.image} />
186
+ <Image
187
+ source={{ uri: image }}
188
+ style={[
189
+ styles.image,
190
+ { borderTopLeftRadius: radius, borderTopRightRadius: radius },
191
+ ]}
192
+ />
207
193
  )}
208
194
  <View style={[styles.content, isFoldable && styles.shrink]}>
209
195
  <Text
210
196
  typography={'header_default_bold'}
211
- numberOfLines={2}
197
+ numberOfLines={3}
212
198
  accessibilityLabel={'title_popup_notify'}
213
- style={titleStyle}
199
+ // keeps the title clear of the close button on a text only popup
200
+ style={
201
+ !image &&
202
+ typeof onIconClose === 'function' &&
203
+ styles.titleClearClose
204
+ }
214
205
  >
215
206
  {title}
216
207
  </Text>
217
208
  <Description style={[styles.description, descriptionStyle]}>
218
- {descriptionContent}
209
+ {typeof description === 'string' ? (
210
+ <Text
211
+ accessibilityLabel={'description_popup_notify'}
212
+ typography={'body_default_regular'}
213
+ onTextLayout={({ nativeEvent: { lines } }) => {
214
+ const enableScroll = lines.length > 8.5;
215
+ if (enableScroll !== scrollContent) {
216
+ setScrollContent(enableScroll);
217
+ }
218
+ }}
219
+ >
220
+ {renderDescription(description)}
221
+ </Text>
222
+ ) : (
223
+ description
224
+ )}
219
225
  </Description>
220
226
  {!!error && (
221
227
  <View style={styles.information}>
@@ -244,7 +250,6 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
244
250
  width: popupWidth,
245
251
  maxHeight,
246
252
  },
247
- styles.card,
248
253
  showBaseLineDebug && styles.debugBaseLine,
249
254
  ]}
250
255
  >
@@ -257,10 +262,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
257
262
 
258
263
  const styles = StyleSheet.create({
259
264
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
260
- // clips the image and content to the card radius
261
- card: { overflow: 'hidden' },
262
265
  image: {
263
266
  aspectRatio: 1.7777,
267
+ overflow: 'hidden',
264
268
  },
265
269
  shrink: { flexShrink: 1 },
266
270
  content: { padding: Spacing.XL },
@@ -12,10 +12,6 @@ const ICON_CLOSE_SIZE = 20;
12
12
  // close button row under the image: marginTop + vertical padding + icon
13
13
  const CLOSE_ROW_HEIGHT = Spacing.S * 3 + ICON_CLOSE_SIZE;
14
14
 
15
- /**
16
- * Promotion popup body: a tappable portrait image with a close button under it.
17
- * Both close the popup first, then call `onActionClick` / `onIconClose`.
18
- */
19
15
  const PopupPromotion: React.FC<PopupPromotionProps> = ({
20
16
  image,
21
17
  onIconClose,
@@ -37,6 +33,10 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
37
33
 
38
34
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
39
35
 
36
+ /**
37
+ * on action popup
38
+ * @param callback
39
+ */
40
40
  const onAction = (callback?: () => void) => {
41
41
  if (typeof onRequestClose === 'function') {
42
42
  onRequestClose?.(callback);
@@ -46,6 +46,9 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
46
46
  }
47
47
  };
48
48
 
49
+ /**
50
+ * build close action
51
+ */
49
52
  const buildCloseIcon = () => {
50
53
  return (
51
54
  <View style={styles.iconCloseContainer}>
package/Popup/types.ts CHANGED
@@ -56,7 +56,7 @@ export type PopupNotifyProps = {
56
56
  onIconClose?: () => void;
57
57
 
58
58
  /**
59
- * `onRequestClose`: Optional. Closes the modal, then runs `callback`. ModalScreen injects it; without it the popup uses `navigator.pop()`.
59
+ * onRequestClose on request close for modal
60
60
  */
61
61
  onRequestClose?: (callback?: () => void) => void;
62
62
  };
@@ -73,17 +73,17 @@ export type PopupPromotionProps = {
73
73
  image: string;
74
74
 
75
75
  /**
76
- * `onIconClose`: Optional. A callback function that is called after the popup closes from the close icon.
76
+ * `onClose`: Optional. A callback function that is called when the PopupPromotion component is closed.
77
77
  */
78
78
  onIconClose?: () => void;
79
79
 
80
80
  /**
81
- * `onActionClick`: Optional. A callback function that is called after the popup closes from an image tap.
81
+ * `onActionClick`: Optional. A callback function that is called when the PopupPromotion component is closed.
82
82
  */
83
83
  onActionClick?: () => void;
84
84
 
85
85
  /**
86
- * `onRequestClose`: Optional. Closes the modal, then runs `callback`. ModalScreen injects it; without it the popup uses `navigator.pop()`.
86
+ * onRequestClose on request close for modal
87
87
  */
88
88
  onRequestClose?: (callback?: () => void) => void;
89
89
  };
package/Popup/utils.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  type HighlightSegment = { text: string; highlight: boolean };
2
2
 
3
- /**
4
- * True for cased-script letters, digits and `_`; caseless scripts (CJK, Thai)
5
- * count as word breaks.
6
- */
7
3
  const isWordChar = (char?: string) => {
8
4
  if (!char) {
9
5
  return false;
package/Radio/index.tsx CHANGED
@@ -11,10 +11,6 @@ import {
11
11
  MiniAppContext,
12
12
  } from '../Context';
13
13
 
14
- /**
15
- * Radio button, selected when `value === groupValue`. `onChange` is called on
16
- * press without arguments; the parent updates `groupValue`.
17
- */
18
14
  const Radio: FC<RadioProps> = ({
19
15
  value,
20
16
  groupValue,
@@ -21,10 +21,6 @@ import { Colors, Styles } from '../Consts';
21
21
  import styles from './styles';
22
22
  import { ScreenContext, SkeletonContext } from '../Context';
23
23
 
24
- /**
25
- * Shimmering placeholder that fills its parent. Reports loading to the screen
26
- * context while mounted.
27
- */
28
24
  const Skeleton: React.FC<SkeletonTypes> = ({ style }) => {
29
25
  const screen = useContext<any>(ScreenContext);
30
26
  const [width, setWidth] = useState(0);
@@ -88,10 +84,6 @@ const Skeleton: React.FC<SkeletonTypes> = ({ style }) => {
88
84
  );
89
85
  };
90
86
 
91
- /**
92
- * Shares `loading` with descendants (e.g. `Image` shows a skeleton) and animates
93
- * the layout change when it flips.
94
- */
95
87
  const SkeletonProvider: React.FC<{ loading: boolean; children: any }> = ({
96
88
  loading = true,
97
89
  children,
package/Switch/index.tsx CHANGED
@@ -6,7 +6,6 @@ import { Colors } from '../Consts';
6
6
  import { useComponentId } from '../Application';
7
7
  import { ComponentContext, MiniAppContext } from '../Context';
8
8
 
9
- /** On/off toggle; `onChange` receives the negated `value`. */
10
9
  const Switch: FC<SwitchProps> = ({
11
10
  value = false,
12
11
  onChange,
package/Tag/index.tsx CHANGED
@@ -25,10 +25,6 @@ const textColor = {
25
25
  grey: Colors.black_12,
26
26
  };
27
27
 
28
- /**
29
- * Small status label with an optional leading icon. `customColor` replaces the
30
- * palette color and turns the text white.
31
- */
32
28
  const Tag: FC<TagProps> = ({
33
29
  label = 'Label',
34
30
  icon,
@@ -76,7 +72,7 @@ const Tag: FC<TagProps> = ({
76
72
  `${componentName}/${label}`,
77
73
  accessibilityLabel,
78
74
  );
79
- // Dev builds only accept `Colors.*_03` as customColor; release accepts any.
75
+ //Check if custom color is [color]_03 (only check in dev mode)
80
76
  const validateCustomColor = (hex: string) => {
81
77
  if (__DEV__) {
82
78
  const colorCore: { [key: string]: string } = Colors;
package/Tag/types.ts CHANGED
@@ -8,7 +8,7 @@ export type TagProps = {
8
8
 
9
9
  /**
10
10
  * `size`: Optional. Defines the size of the Tag component.
11
- * Defaults to 'large' if not provided.
11
+ * Defaults to 'medium' if not provided.
12
12
  */
13
13
  size?: 'medium' | 'large';
14
14
 
@@ -29,8 +29,8 @@ export type TagProps = {
29
29
  style?: ViewStyle;
30
30
 
31
31
  /**
32
- * `customColor`: Optional. Custom background color; the label turns white.
33
- * Dev builds ignore values other than the `Colors.*_03` tokens.
32
+ * `customColor`: Optional. Represents a custom color string (e.g., hex, rgb, rgba, etc.)
33
+ * that can be applied to the Tag component.
34
34
  */
35
35
  customColor?: string;
36
36
 
package/Text/index.tsx CHANGED
@@ -111,10 +111,6 @@ const deprecatedValues: Typography[] = [
111
111
  'action_s',
112
112
  ];
113
113
 
114
- /**
115
- * Text style of a typography token with sizes scaled by `useScaleSize` and the
116
- * font file name for its weight. Calls hooks, so it only runs during render.
117
- */
118
114
  const TypoStyles = (typo: Typography, newFontFamily?: string) => {
119
115
  const { theme } = useContext(ApplicationContext);
120
116
  const styleSheet: {
@@ -162,7 +158,9 @@ const TypoStyles = (typo: Typography, newFontFamily?: string) => {
162
158
  fontSize: useScaleSize(fontSize),
163
159
  lineHeight: useScaleSize(lineHeight),
164
160
  fontStyle,
165
- // Weight is in fontFamily; fontWeight >= 700 makes Android seek a missing <family>_bold.ttf.
161
+ // fontFamily da mang san weight. Tren Android, ReactFontManager doi
162
+ // `fonts/<family>_bold.ttf` khi fontWeight >= 700; file do khong ton tai nen
163
+ // font se roi ve font he thong. Bo fontWeight de Android dung dung file.
166
164
  fontWeight: undefined,
167
165
  };
168
166
  };
@@ -171,11 +169,6 @@ const skeletonStyles = StyleSheet.create({
171
169
  overlay: { position: 'absolute' },
172
170
  });
173
171
 
174
- /**
175
- * Design-system text: renders a `typography` token in the theme font with
176
- * scaled sizes and OS font scaling off. Warns on deprecated tokens and shows a
177
- * skeleton overlay while a SkeletonContext is loading.
178
- */
179
172
  const Text: React.FC<TextProps> = ({
180
173
  typography = 'body_default_regular',
181
174
  color,
@@ -235,10 +228,6 @@ const Text: React.FC<TextProps> = ({
235
228
  );
236
229
  };
237
230
 
238
- /**
239
- * Theme font family for a loose weight name ('bold', 'semibold', 'regular').
240
- * The `typography` argument is ignored; it calls hooks, so use it during render.
241
- */
242
231
  const exportFontFamily = (
243
232
  fontWeight: string,
244
233
  typography?: Typography,
package/Text/styles.ts CHANGED
@@ -39,7 +39,7 @@ export default {
39
39
  action_s_bold: { fontSize: 14, lineHeight: 20, fontWeight: '700' },
40
40
  action_xs_bold: { fontSize: 12, lineHeight: 18, fontWeight: '700' },
41
41
  action_xxs_bold: { fontSize: 10, lineHeight: 14, fontWeight: '700' },
42
- // Legacy tokens kept for old callers; not in the current type scale.
42
+ /**non-support**/
43
43
  headline_default: {
44
44
  fontSize: 28,
45
45
  lineHeight: 34,
package/Text/types.ts CHANGED
@@ -14,7 +14,9 @@ export type TypographyWeight = {
14
14
  };
15
15
 
16
16
  export type Typography =
17
- // Deprecated up to 'action_s': Text warns at runtime when one is used.
17
+ /**
18
+ * @deprecated
19
+ **/
18
20
  | 'headline_default'
19
21
  | 'headline_l'
20
22
  | 'headline_xl'
@@ -27,6 +29,9 @@ export type Typography =
27
29
  | 'paragraph_italic'
28
30
  | 'label_xxs'
29
31
  | 'action_s'
32
+ /**
33
+ * end
34
+ **/
30
35
  | 'headline_l_bold'
31
36
  | 'headline_default_bold'
32
37
  | 'header_m_bold'
package/Text/utils.ts CHANGED
@@ -6,11 +6,6 @@ const DEFAULT_SCREEN_SIZE = 375;
6
6
  const MAX_FONT_SCALE = 1.5;
7
7
  const MAX_DEVICE_SCALE = 5;
8
8
 
9
- /**
10
- * Scales `size` by screen width (at most +5) and OS font scale (at most
11
- * `scaleRate`, default 1.5), taking the larger; a mini app can opt out of the
12
- * OS rate and use its own `fontScale.userScaleRate` instead.
13
- */
14
9
  const useScaleSize = (size: number, scaleRate?: number) => {
15
10
  const { width } = useWindowDimensions();
16
11
  const context = useContext<any>(MiniAppContext);
@@ -42,10 +37,6 @@ const useScaleSize = (size: number, scaleRate?: number) => {
42
37
  return Math.max(fontSizeDeviceScale, fontSizeOSScale);
43
38
  };
44
39
 
45
- /**
46
- * Non-hook `useScaleSize` with the default cap and no mini app rate, for use
47
- * outside render. Reads the window width at call time, so it misses resizes.
48
- */
49
40
  const scaleSize = (size: number) => {
50
41
  const fontScale = PixelRatio.getFontScale();
51
42
  const deviceScale = Dimensions.get('window').width / DEFAULT_SCREEN_SIZE;
package/Title/index.tsx CHANGED
@@ -15,11 +15,6 @@ import styles from './styles';
15
15
  import { TitleProps } from './types';
16
16
  import { Typography } from '../Text/types';
17
17
 
18
- /**
19
- * Section or card heading with optional icon, badge, description, trailing
20
- * chevron and right action (chevron, or a text button when `buttonTitle` is
21
- * set). `textOnly` renders the title text alone.
22
- */
23
18
  const Title: FC<TitleProps> = ({
24
19
  accessibilityLabel,
25
20
  title = 'Title',
@@ -48,6 +43,7 @@ const Title: FC<TitleProps> = ({
48
43
 
49
44
  const size18 = useScaleSize(18);
50
45
  const size22 = useScaleSize(22);
46
+ // Dynamic styles using useScaleSize hook
51
47
  const dynamicStyles = {
52
48
  card_small: {
53
49
  fontSize: useScaleSize(14),
@@ -208,44 +204,39 @@ const Title: FC<TitleProps> = ({
208
204
 
209
205
  const lineHeight = styleSheet[typography].lineHeight;
210
206
 
211
- let action = (
212
- <TouchableOpacity
213
- onPress={onPressRightAction}
214
- style={[
215
- styles.iconRight,
216
- {
217
- backgroundColor: theme.colors.primary + '0F',
218
- },
219
- ]}
220
- accessibilityLabel={componentId + '|label-right-action-touch'}
221
- >
222
- <Icon
223
- source={'arrow_chevron_right_small'}
224
- size={size22}
225
- color={theme.colors.primary}
226
- />
227
- </TouchableOpacity>
228
- );
229
- if (buttonTitle) {
230
- action = (
231
- <TouchableOpacity
232
- onPress={onPressRightAction}
233
- accessibilityLabel={componentId + '|label-right-action-touch'}
234
- >
235
- <Text
236
- color={theme.colors.primary}
237
- typography={buttonTypo}
238
- accessibilityLabel={componentId + '|label-right-action-text'}
239
- >
240
- {buttonTitle}
241
- </Text>
242
- </TouchableOpacity>
243
- );
244
- }
245
-
246
207
  return (
247
208
  <View style={[styles.actionRightView, { height: lineHeight }]}>
248
- {action}
209
+ {!buttonTitle ? (
210
+ <TouchableOpacity
211
+ onPress={onPressRightAction}
212
+ style={[
213
+ styles.iconRight,
214
+ {
215
+ backgroundColor: theme.colors.primary + '0F',
216
+ },
217
+ ]}
218
+ accessibilityLabel={componentId + '|label-right-action-touch'}
219
+ >
220
+ <Icon
221
+ source={'arrow_chevron_right_small'}
222
+ size={size22}
223
+ color={theme.colors.primary}
224
+ />
225
+ </TouchableOpacity>
226
+ ) : (
227
+ <TouchableOpacity
228
+ onPress={onPressRightAction}
229
+ accessibilityLabel={componentId + '|label-right-action-touch'}
230
+ >
231
+ <Text
232
+ color={theme.colors.primary}
233
+ typography={buttonTypo}
234
+ accessibilityLabel={componentId + '|label-right-action-text'}
235
+ >
236
+ {buttonTitle}
237
+ </Text>
238
+ </TouchableOpacity>
239
+ )}
249
240
  </View>
250
241
  );
251
242
  };
@@ -14,10 +14,6 @@ interface ViewBoundaryState {
14
14
  error: Error | null;
15
15
  }
16
16
 
17
- /**
18
- * Error boundary: renders `fallback` (or nothing) after a render error and
19
- * reports it to native `MiniAppModule.onJSBoundaryCrash` when available.
20
- */
21
17
  class ViewBoundary extends React.Component<
22
18
  ViewBoundaryProps,
23
19
  ViewBoundaryState
@@ -37,6 +33,7 @@ class ViewBoundary extends React.Component<
37
33
  this.props.onError?.(error, errorInfo);
38
34
 
39
35
  const context = (this as any).context ?? {};
36
+ // check exist native module method onJSBoundaryCrash
40
37
  const nativeMethod = NativeModules?.MiniAppModule?.onJSBoundaryCrash;
41
38
  if (typeof nativeMethod === 'function') {
42
39
  try {
@@ -52,6 +49,7 @@ class ViewBoundary extends React.Component<
52
49
  componentStack: errorInfo?.componentStack?.substring(0, 500) ?? '',
53
50
  },
54
51
  });
52
+ console.info('[ViewBoundary] onJSBoundaryCrash success!');
55
53
  } catch (_e) {
56
54
  console.warn('[ViewBoundary] onJSBoundaryCrash failed:', _e);
57
55
  }
package/index.ts CHANGED
@@ -1,8 +1,14 @@
1
+ /**
2
+ * native export
3
+ */
1
4
  import { TouchableOpacity } from 'react-native';
2
5
 
3
6
  export * from 'react-native-linear-gradient';
4
7
  export * from 'react-native-safe-area-context';
5
8
 
9
+ /**
10
+ * foundation component
11
+ */
6
12
  export * from './Consts';
7
13
  export * from './Context';
8
14
  export * from './Layout';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/foundation",
3
- "version": "0.169.5",
3
+ "version": "0.169.6-beta.1",
4
4
  "description": "React Native Component Kits",
5
5
  "main": "index.ts",
6
6
  "scripts": {},