@momo-kits/foundation 0.168.1-beta.39 → 0.168.1-beta.40

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 (153) hide show
  1. package/Application/BottomSheet.tsx +398 -86
  2. package/Application/BottomTab/BottomTabBar.tsx +275 -215
  3. package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
  4. package/Application/BottomTab/DuoBarCompression.tsx +28 -14
  5. package/Application/BottomTab/DuoTabBar.tsx +540 -32
  6. package/Application/BottomTab/TabBarIcon.tsx +72 -146
  7. package/Application/BottomTab/index.tsx +353 -89
  8. package/Application/BottomTab/useLiquidSelection.ts +374 -0
  9. package/Application/Components/BackgroundImageView.tsx +0 -4
  10. package/Application/Components/DuoGlassBackground.tsx +5 -7
  11. package/Application/Components/HeaderAnimated.tsx +13 -41
  12. package/Application/Components/HeaderBackground.tsx +3 -20
  13. package/Application/Components/HeaderExtendHeader.tsx +46 -66
  14. package/Application/Components/HeaderLeft.tsx +18 -5
  15. package/Application/Components/HeaderRight.tsx +529 -8
  16. package/Application/Components/HeaderTitle.tsx +579 -16
  17. package/Application/Components/NavigationButton.tsx +11 -18
  18. package/Application/Components/SearchHeader.tsx +18 -38
  19. package/Application/Localize.ts +0 -7
  20. package/Application/ModalScreen.tsx +18 -41
  21. package/Application/Navigation.ts +17 -15
  22. package/Application/NavigationContainer.tsx +21 -23
  23. package/Application/Navigator.ts +48 -20
  24. package/Application/ScaleSizeProvider.tsx +6 -13
  25. package/Application/StackScreen.tsx +172 -27
  26. package/Application/TooltipPortal.tsx +5 -12
  27. package/Application/WidgetContainer.tsx +7 -20
  28. package/Application/device.ts +52 -0
  29. package/Application/index.ts +1 -23
  30. package/Application/types.ts +242 -17
  31. package/Application/utils.tsx +493 -0
  32. package/Badge/Badge.tsx +0 -5
  33. package/Badge/BadgeDot.tsx +0 -1
  34. package/Badge/BadgeDotAnimation.tsx +7 -15
  35. package/Badge/BadgeRibbon.tsx +39 -47
  36. package/Badge/Shape.tsx +0 -2
  37. package/Badge/styles.ts +0 -2
  38. package/Badge/types.ts +2 -2
  39. package/Button/index.tsx +152 -21
  40. package/Button/styles.ts +1 -1
  41. package/CheckBox/index.tsx +6 -5
  42. package/Consts/theme.ts +10 -10
  43. package/Context/index.ts +1 -5
  44. package/Divider/DashDivider.tsx +11 -11
  45. package/Divider/index.tsx +7 -21
  46. package/FoundationList/index.tsx +0 -4
  47. package/Icon/index.tsx +6 -6
  48. package/Icon/types.ts +1 -1
  49. package/IconButton/index.tsx +12 -4
  50. package/Image/index.tsx +7 -9
  51. package/Input/Input.tsx +12 -10
  52. package/Input/InputDropDown.tsx +13 -10
  53. package/Input/InputMoney.tsx +152 -45
  54. package/Input/InputOTP.tsx +34 -36
  55. package/Input/InputPhoneNumber.tsx +5 -8
  56. package/Input/InputSearch.tsx +111 -19
  57. package/Input/InputTextArea.tsx +5 -5
  58. package/Input/SystemTextInput.tsx +2 -7
  59. package/Input/TextTyping.tsx +0 -4
  60. package/Input/common.tsx +17 -31
  61. package/Input/index.tsx +21 -24
  62. package/Input/styles.ts +5 -25
  63. package/Input/utils.ts +12 -14
  64. package/Layout/Card.tsx +4 -7
  65. package/Layout/FloatingButton.tsx +21 -26
  66. package/Layout/Item.tsx +2 -6
  67. package/Layout/ItemList.tsx +7 -9
  68. package/Layout/ItemSectionList.tsx +1 -2
  69. package/Layout/ReservedRegions.tsx +17 -34
  70. package/Layout/Screen.tsx +696 -122
  71. package/Layout/Section.tsx +7 -9
  72. package/Layout/TrackingScope.tsx +0 -1
  73. package/Layout/index.ts +4 -10
  74. package/Layout/styles.ts +0 -2
  75. package/Layout/types.ts +4 -2
  76. package/Layout/utils.ts +181 -40
  77. package/Loader/DotLoader.tsx +3 -11
  78. package/Loader/Loader.tsx +0 -4
  79. package/Loader/ProgressBar.tsx +6 -3
  80. package/Loader/Spinner.tsx +3 -11
  81. package/Loader/styles.ts +0 -4
  82. package/Loader/utils.ts +7 -11
  83. package/Pagination/Dot.tsx +0 -4
  84. package/Pagination/PaginationDot.tsx +0 -1
  85. package/Pagination/PaginationNumber.tsx +3 -5
  86. package/Pagination/PaginationScroll.tsx +0 -5
  87. package/Pagination/PaginationWhiteDot.tsx +0 -1
  88. package/Pagination/index.tsx +0 -4
  89. package/Pagination/types.ts +2 -2
  90. package/Popup/PopupNotify.tsx +102 -94
  91. package/Popup/PopupPromotion.tsx +11 -9
  92. package/Popup/types.ts +4 -11
  93. package/Popup/utils.ts +18 -50
  94. package/Radio/index.tsx +10 -6
  95. package/Radio/styles.ts +0 -6
  96. package/Skeleton/index.tsx +9 -9
  97. package/Skeleton/styles.ts +0 -1
  98. package/Switch/index.tsx +0 -1
  99. package/Tag/index.tsx +4 -8
  100. package/Tag/types.ts +3 -3
  101. package/Text/index.tsx +5 -25
  102. package/Text/styles.ts +1 -1
  103. package/Text/types.ts +6 -1
  104. package/Text/utils.ts +4 -20
  105. package/Title/index.tsx +40 -42
  106. package/Title/styles.ts +0 -6
  107. package/ViewBoundary/index.tsx +2 -4
  108. package/index.ts +6 -0
  109. package/package.json +1 -2
  110. package/Application/BottomSheet.hooks.ts +0 -195
  111. package/Application/BottomSheet.parts.tsx +0 -157
  112. package/Application/BottomSheet.styles.ts +0 -43
  113. package/Application/BottomTab/ActiveIndicator.tsx +0 -91
  114. package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
  115. package/Application/BottomTab/BottomTabInset.tsx +0 -18
  116. package/Application/BottomTab/CurvedContainer.tsx +0 -155
  117. package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
  118. package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
  119. package/Application/BottomTab/TabScreen.tsx +0 -160
  120. package/Application/BottomTab/metrics.ts +0 -164
  121. package/Application/BottomTab/tabItems.ts +0 -46
  122. package/Application/BottomTab/usePressLift.ts +0 -32
  123. package/Application/Components/HeaderRight.styles.ts +0 -146
  124. package/Application/Components/HeaderTitle.shared.ts +0 -44
  125. package/Application/Components/HeaderTitle.styles.ts +0 -125
  126. package/Application/Components/HeaderToolkitAction.tsx +0 -180
  127. package/Application/Components/SwipeBackHaptic.tsx +0 -95
  128. package/Application/Components/TitleJourney.tsx +0 -110
  129. package/Application/Components/TitleLocation.tsx +0 -73
  130. package/Application/Components/TitleUser.tsx +0 -304
  131. package/Application/Components/useToolkitActions.tsx +0 -218
  132. package/Application/ModalIconButton.tsx +0 -66
  133. package/Application/StackScreen.tracking.ts +0 -143
  134. package/Application/headerLayout.ts +0 -158
  135. package/Application/hooks.ts +0 -137
  136. package/Application/modalLayout.ts +0 -176
  137. package/Application/navigationOptions.tsx +0 -212
  138. package/Application/types.header.ts +0 -121
  139. package/Application/types.tabs.ts +0 -48
  140. package/Application/types.theme.ts +0 -87
  141. package/Application/utils.ts +0 -107
  142. package/Button/utils.ts +0 -133
  143. package/Input/InputMoneyView.tsx +0 -194
  144. package/Input/SearchTextTyping.tsx +0 -108
  145. package/Input/moneyUtils.ts +0 -23
  146. package/Layout/layoutMetrics.ts +0 -58
  147. package/Layout/layoutTypes.ts +0 -86
  148. package/Layout/screenContent.tsx +0 -92
  149. package/Layout/screenFooter.tsx +0 -63
  150. package/Layout/screenHeader.tsx +0 -321
  151. package/Layout/screenQuickReturn.tsx +0 -64
  152. package/Layout/screenScroll.ts +0 -107
  153. package/Layout/screenTypes.ts +0 -143
package/Input/common.tsx CHANGED
@@ -35,7 +35,6 @@ type TrailingProps = {
35
35
 
36
36
  export const MAX_LENGTH = 300;
37
37
 
38
- /** Border color by state; priority is disabled > error > focused > default. */
39
38
  export const getBorderColor = (
40
39
  theme: Theme,
41
40
  focused: boolean,
@@ -59,10 +58,6 @@ export const getBorderColor = (
59
58
  return { borderColor };
60
59
  };
61
60
 
62
- /**
63
- * Container style for `size`; multiline uses `height` as minHeight so the
64
- * field can grow with its content.
65
- */
66
61
  export const getSizeStyle = (
67
62
  size?: 'small' | 'large',
68
63
  multiline: boolean = false,
@@ -73,14 +68,13 @@ export const getSizeStyle = (
73
68
  scaleStyle = { height };
74
69
  }
75
70
 
76
- if (multiline) {
71
+ if (multiline)
77
72
  return [
78
73
  styles.multilineContainer,
79
74
  {
80
75
  minHeight: height,
81
76
  },
82
77
  ];
83
- }
84
78
 
85
79
  if (size === 'small') {
86
80
  return [styles.smallContainer, scaleStyle];
@@ -88,10 +82,6 @@ export const getSizeStyle = (
88
82
  return [styles.container, scaleStyle];
89
83
  };
90
84
 
91
- /**
92
- * Error or hint row under an input (error wins); with neither, `errorSpacing`
93
- * keeps an empty row so the layout doesn't jump when an error appears.
94
- */
95
85
  export const ErrorView: FC<{
96
86
  errorMessage?: string;
97
87
  errorSpacing?: boolean;
@@ -105,34 +95,34 @@ export const ErrorView: FC<{
105
95
  const scaledIconSize = useScaleSize(16);
106
96
 
107
97
  if (errorMessage || hintText) {
108
- const messageColor = errorMessage ? errorColor : hintColor;
109
- const messageType = errorMessage ? 'error' : 'hint';
110
98
  return (
111
99
  <View style={styles.errorView}>
112
100
  <View style={styles.errorIcon}>
113
- <Icon color={messageColor} source="ic_error" size={scaledIconSize} />
101
+ <Icon
102
+ color={errorMessage ? errorColor : hintColor}
103
+ source="ic_error"
104
+ size={scaledIconSize}
105
+ />
114
106
  </View>
115
107
  <Text
116
- accessibilityLabel={`${componentId}|${messageType}-text`}
108
+ accessibilityLabel={`${componentId}|${
109
+ errorMessage ? 'error' : 'hint'
110
+ }-text`}
117
111
  style={Styles.flex}
118
- color={messageColor}
112
+ color={errorMessage ? errorColor : hintColor}
119
113
  typography={'description_default_regular'}
120
114
  >
121
- {errorMessage ?? hintTextDefault}
115
+ {errorMessage || hintTextDefault}
122
116
  </Text>
123
117
  </View>
124
118
  );
125
119
  }
126
120
  if (errorSpacing) {
127
- return <View style={[styles.errorView, styles.errorSpacing]} />;
121
+ return <View style={[styles.errorView, { height: 18 }]} />;
128
122
  }
129
123
  return <View />;
130
124
  };
131
125
 
132
- /**
133
- * Floating label on the input's top border with a required `*` and an
134
- * optional pressable icon; renders nothing without `floatingValue`.
135
- */
136
126
  export const FloatingView: FC<FloatingViewProps> = ({
137
127
  floatingValue,
138
128
  floatingIconColor,
@@ -157,9 +147,9 @@ export const FloatingView: FC<FloatingViewProps> = ({
157
147
  <View
158
148
  style={[
159
149
  styles.floatingView,
160
- styles.floatingViewLayer,
161
150
  {
162
151
  backgroundColor: theme.colors.background.surface,
152
+ zIndex: 10,
163
153
  top: -scaledTop,
164
154
  },
165
155
  style,
@@ -201,10 +191,6 @@ export const FloatingView: FC<FloatingViewProps> = ({
201
191
  return null;
202
192
  };
203
193
 
204
- /**
205
- * Trailing slot: spinner while `loading`, an icon when `icon` is a known icon
206
- * name or URL, otherwise `icon` as a text action (first 15 chars).
207
- */
208
194
  export const RenderTrailing: FC<TrailingProps> = ({
209
195
  loading,
210
196
  color,
@@ -218,16 +204,16 @@ export const RenderTrailing: FC<TrailingProps> = ({
218
204
  }
219
205
 
220
206
  if (icon) {
221
- const isIconName = !!(IconSources as any)?.[icon]?.uri;
222
- const isIcon = isIconName || icon.includes('http');
223
- const renderIconTouchable = (content: ReactNode) => {
207
+ const isIcon =
208
+ (IconSources as any)?.[icon as string]?.uri || icon?.includes('http');
209
+ const renderIconTouchable = (icon: ReactNode) => {
224
210
  return (
225
211
  <TouchableOpacity
226
212
  accessibilityLabel={`${componentId}|trailing-touch`}
227
213
  onPress={onPressIcon}
228
214
  style={styles.icon}
229
215
  >
230
- {content}
216
+ {icon}
231
217
  </TouchableOpacity>
232
218
  );
233
219
  };
package/Input/index.tsx CHANGED
@@ -36,7 +36,7 @@ export interface InputProps extends TextInputProps {
36
36
  errorMessage?: string;
37
37
 
38
38
  /**
39
- * Optional. Trailing icon name or URL; any other string is shown as a text action.
39
+ * Optional. Represents the name or key of the icon to be displayed in the Input component.
40
40
  */
41
41
  trailing?: string;
42
42
 
@@ -69,18 +69,19 @@ export interface InputProps extends TextInputProps {
69
69
  required?: boolean;
70
70
 
71
71
  /**
72
- * Optional. If `true`, keeps an empty error row when there is no error or hint.
72
+ * Optional. If `true`,
73
+ * include spacing when Input not have error message.
73
74
  * Defaults to `false` if not provided.
74
75
  */
75
76
  errorSpacing?: boolean;
76
77
 
77
78
  /**
78
- * Optional. If `true`, shows a loading spinner in place of the trailing icon.
79
+ * If true, the icon of input will use be show indicator loading.
79
80
  */
80
81
  loading?: boolean;
81
82
 
82
83
  /**
83
- * Optional. Represents the leading icon in the Input component.
84
+ * Optional. Represents the leading icon in the Input component.
84
85
  */
85
86
  leadingIcon?: string;
86
87
 
@@ -110,13 +111,12 @@ export interface InputProps extends TextInputProps {
110
111
  hintText?: string;
111
112
 
112
113
  /**
113
- * Optional. Callback function to be called when the floating icon is pressed.
114
+ * Optional. Represents the style of the Input component.
114
115
  */
115
116
  onPressFloatingIcon?: () => void;
116
117
 
117
118
  /**
118
- * Optional. If `true`, shows a clear icon while focused with a value.
119
- * Defaults to `true` if not provided.
119
+ * Optional. Represents the style of the Input component.
120
120
  */
121
121
  showClearIcon?: boolean;
122
122
  }
@@ -137,12 +137,12 @@ export interface InputSearchProps extends TextInputProps {
137
137
 
138
138
  /**
139
139
  * Optional. If `true`, the text on the search button will be displayed.
140
- * Defaults to `true` if not provided.
140
+ * Defaults to `false` if not provided.
141
141
  */
142
142
  showButtonText?: boolean;
143
143
 
144
144
  /**
145
- * Optional. Callback function to be called when the search button is pressed.
145
+ * Optional. Represents the value for the floating title in the InputSearch component.
146
146
  */
147
147
  onPressButtonText?: () => void;
148
148
 
@@ -180,7 +180,7 @@ export interface InputSearchProps extends TextInputProps {
180
180
  onPressTrailing?: () => void;
181
181
 
182
182
  /**
183
- * Optional. Background color of the search field. Defaults to the surface color.
183
+ * Optional. If `true`, the user won't be able to interact with the Input component.
184
184
  */
185
185
  backgroundColor?: string;
186
186
 
@@ -195,13 +195,8 @@ export interface InputSearchProps extends TextInputProps {
195
195
  typingData?: string[];
196
196
 
197
197
  /**
198
- * Optional. `header` is the 32pt field with a 20pt search icon that sits in the
199
- * navigation header. Defaults to `default`, the 36pt field for content.
200
- */
201
- size?: 'default' | 'header';
202
-
203
- /**
204
- * Optional. Called when the field is pressed while showing `typingData`.
198
+ * Optional. Represents the callback function to be called when the search button is pressed.
199
+ * @param e
205
200
  */
206
201
  onPress?: (e: GestureResponderEvent) => void;
207
202
  }
@@ -264,7 +259,7 @@ export interface InputDropDownProps extends TouchableOpacityProps {
264
259
  placeholder?: string;
265
260
 
266
261
  /**
267
- * Optional. If `true`, the value wraps to multiple lines and the chevron aligns to the top.
262
+ * Optional. Represents the data for the dropdown.
268
263
  */
269
264
  multiline?: boolean;
270
265
 
@@ -308,18 +303,19 @@ export interface InputDropDownProps extends TouchableOpacityProps {
308
303
  required?: boolean;
309
304
 
310
305
  /**
311
- * Optional. If `true`, keeps an empty error row when there is no error or hint.
306
+ * Optional. If `true`,
307
+ * include spacing when Input not have error message.
312
308
  * Defaults to `false` if not provided.
313
309
  */
314
310
  errorSpacing?: boolean;
315
311
 
316
312
  /**
317
- * Optional. If `true`, shows a loading spinner in place of the trailing icon.
313
+ * If true, the icon of input will use be show indicator loading.
318
314
  */
319
315
  loading?: boolean;
320
316
 
321
317
  /**
322
- * Optional. Represents the leading icon in the Input component.
318
+ * Optional. Represents the leading icon in the Input component.
323
319
  */
324
320
  leadingIcon?: string;
325
321
 
@@ -344,14 +340,15 @@ export interface InputDropDownProps extends TouchableOpacityProps {
344
340
  hintText?: string;
345
341
 
346
342
  /**
347
- * Optional. Callback function to be called when the floating icon is pressed.
343
+ * Optional. Represents the style of the Input component.
348
344
  */
349
345
  onPressFloatingIcon?: () => void;
350
346
  }
351
347
 
352
348
  export interface InputPhoneNumberProps extends InputProps {
353
349
  /**
354
- * Optional. Currently unused: the displayed prefix is always `+84`.
350
+ * Optional. Represents the country code to be displayed in the InputPhoneNumber component.
351
+ * It should be in the format of a string, e.g., "+1" for the United States.
355
352
  */
356
353
  countryCode?: string;
357
354
  }
@@ -373,4 +370,4 @@ export {
373
370
  InputPhoneNumber,
374
371
  };
375
372
 
376
- export { checkValidPhoneNumber };
373
+ export {checkValidPhoneNumber};
package/Input/styles.ts CHANGED
@@ -2,6 +2,7 @@ import { Platform, StyleSheet } from 'react-native';
2
2
  import { Colors, Radius, Spacing } from '../Consts';
3
3
 
4
4
  export default StyleSheet.create({
5
+ //input style
5
6
  input: {
6
7
  flex: 1,
7
8
  paddingLeft: Spacing.M,
@@ -64,6 +65,7 @@ export default StyleSheet.create({
64
65
  marginTop: Spacing.S,
65
66
  },
66
67
 
68
+ //text area style
67
69
  textAreaView: {
68
70
  flex: 1,
69
71
  },
@@ -92,6 +94,7 @@ export default StyleSheet.create({
92
94
  marginBottom: Spacing.XS,
93
95
  },
94
96
 
97
+ //searchInput
95
98
  searchInputWrapper: {
96
99
  flexDirection: 'row',
97
100
  borderRadius: Radius.XL,
@@ -133,6 +136,7 @@ export default StyleSheet.create({
133
136
  ios: 36,
134
137
  }),
135
138
  },
139
+ //OTP
136
140
  otpWrapper: {
137
141
  width: '100%',
138
142
  marginTop: Spacing.M,
@@ -179,6 +183,7 @@ export default StyleSheet.create({
179
183
  opacity: 0.02,
180
184
  letterSpacing: Spacing.XXL,
181
185
  },
186
+ //DropDown
182
187
  inputDropDownWrapper: {
183
188
  flexDirection: 'row',
184
189
  marginTop: Spacing.S,
@@ -222,29 +227,4 @@ export default StyleSheet.create({
222
227
  paddingRight: Spacing.XXS,
223
228
  paddingVertical: 0,
224
229
  },
225
- inputField: {
226
- flex: 1,
227
- paddingLeft: Spacing.M,
228
- height: '100%',
229
- },
230
- secureTextSmall: { fontSize: 18 },
231
- secureTextLarge: { fontSize: 22 },
232
- iconViewDropDownMultiline: {
233
- alignItems: 'flex-start',
234
- paddingTop: Spacing.M,
235
- },
236
- iconViewDropDownSingle: {
237
- alignItems: 'center',
238
- paddingTop: 0,
239
- },
240
- otpCursor: { width: 1 },
241
- searchInputTyping: { justifyContent: 'center' },
242
- textAreaInput: {
243
- width: '100%',
244
- flex: 1,
245
- paddingRight: Spacing.XS,
246
- paddingVertical: Spacing.XS,
247
- },
248
- errorSpacing: { height: 18 },
249
- floatingViewLayer: { zIndex: 10 },
250
230
  });
package/Input/utils.ts CHANGED
@@ -1,9 +1,5 @@
1
1
  import { Localize } from '../Application';
2
2
 
3
- /**
4
- * Formats a number Vietnamese-style (`.` thousands, `,` decimals) with
5
- * `currency` appended; 0, NaN or a falsy value gives `0<currency>`.
6
- */
7
3
  const formatNumberToMoney = (number: number, currency = '') => {
8
4
  if (!number || isNaN(number) || Number(number) === 0) {
9
5
  return `0${currency}`;
@@ -45,10 +41,6 @@ const formatNumberToMoney = (number: number, currency = '') => {
45
41
  return isNegative ? `-${result}${currency}` : `${result}${currency}`;
46
42
  };
47
43
 
48
- /**
49
- * Parses a formatted money string back to a number by stripping
50
- * `currencyUnit`, separators, `đ` and spaces; unparsable text gives 0.
51
- */
52
44
  const formatMoneyToNumber = (money: string, currencyUnit: string) => {
53
45
  if (money && money.length > 0) {
54
46
  const moneyString = money
@@ -67,20 +59,26 @@ const formatMoneyToNumber = (money: string, currencyUnit: string) => {
67
59
  return Number(money);
68
60
  };
69
61
 
62
+ // --- PHONE VALIDATION ---
70
63
  function formatPhoneNumber(phone: string): string {
71
64
  return phone.replace(/\D/g, '');
72
65
  }
73
66
 
74
- /**
75
- * Keeps the digits of `phone` (prepending the `0` a 9-char local number lacks)
76
- * and returns a localized error when empty or not 10-11 digits.
77
- */
78
67
  function checkValidPhoneNumber(phone: string): {
79
68
  phoneFormatted: string;
80
69
  error?: string;
81
70
  } {
82
- const isMissingLeadingZero = phone.length === 9 && /^[1-9]/.test(phone);
83
- const phoneNumber = isMissingLeadingZero ? `0${phone}` : phone;
71
+ let phoneNumber = phone;
72
+
73
+ // if not starting with 0 and has 9 digits => prepend 0
74
+ if (
75
+ phoneNumber.length > 0 &&
76
+ phoneNumber[0] !== '0' &&
77
+ /^\d$/.test(phoneNumber[0]) &&
78
+ phoneNumber.length === 9
79
+ ) {
80
+ phoneNumber = '0' + phoneNumber;
81
+ }
84
82
 
85
83
  const phoneFormatted = formatPhoneNumber(phoneNumber);
86
84
  const localize = new Localize({ vi: {}, en: {} });
package/Layout/Card.tsx CHANGED
@@ -20,10 +20,6 @@ export interface CardProps extends ViewProps {
20
20
  useShadow?: boolean;
21
21
  }
22
22
 
23
- /**
24
- * Surface card across the content width minus 12pt margins, with its own grid for child
25
- * Items; optional background image and light shadow.
26
- */
27
23
  const Card: React.FC<CardProps> = ({
28
24
  children,
29
25
  style,
@@ -38,9 +34,10 @@ const Card: React.FC<CardProps> = ({
38
34
  const gutterSize = 8;
39
35
  const margin = 12;
40
36
  const widthSection = contentWidth - margin * 2;
41
- const innerWidth = widthSection - margin * 2;
42
- const columnsWidth = innerWidth - gutterSize * (numberOfColumns - 1);
43
- const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
37
+ let sizePerSpan =
38
+ (widthSection - margin * 2 - gutterSize * (numberOfColumns - 1)) /
39
+ numberOfColumns -
40
+ 1 / numberOfColumns;
44
41
 
45
42
  const gridContext: GridContextProps = {
46
43
  numberOfColumns,
@@ -13,11 +13,12 @@ import Animated, {
13
13
  } from 'react-native-reanimated';
14
14
  import { scheduleOnRN } from 'react-native-worklets';
15
15
  import { ApplicationContext } from '../Context';
16
- import { Colors } from '../Consts';
17
16
  import { Icon } from '../Icon';
18
17
  import { useScaleSize, exportFontFamily } from '../Text';
19
- import { type AnimatedCompatValue } from '../Application/utils';
20
- import { useNormalizedSharedValue } from '../Application/hooks';
18
+ import {
19
+ AnimatedCompatValue,
20
+ useNormalizedSharedValue,
21
+ } from '../Application/utils';
21
22
 
22
23
  export interface FloatingButtonProps {
23
24
  label?: string;
@@ -31,10 +32,6 @@ export interface FloatingButtonProps {
31
32
  renderComponent?: () => React.ReactNode;
32
33
  }
33
34
 
34
- /**
35
- * Floating action button above the screen bottom. With a label and a scroll value it
36
- * shrinks to its icon while scrolling down and expands again on scroll up.
37
- */
38
35
  export const FloatingButton: React.FC<FloatingButtonProps> = ({
39
36
  renderComponent,
40
37
  label = '',
@@ -121,9 +118,11 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
121
118
  onLayout={handleLayout}
122
119
  style={[
123
120
  styles.container,
124
- position === 'right' && styles.alignRight,
125
- position === 'center' ? styles.alignCenter : styles.alignEnd,
126
- { bottom },
121
+ {
122
+ right: position === 'right' ? 12 : undefined,
123
+ alignSelf: position === 'center' ? 'center' : 'flex-end',
124
+ bottom,
125
+ },
127
126
  ]}
128
127
  >
129
128
  {renderComponent()}
@@ -136,14 +135,20 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
136
135
  onLayout={handleLayout}
137
136
  style={[
138
137
  styles.container,
139
- position === 'right' && styles.alignRight,
140
- position === 'center' ? styles.alignCenter : styles.alignEnd,
141
- size === 'small' ? styles.small : styles.large,
142
- { backgroundColor: theme.colors.primary, bottom },
138
+ {
139
+ right: position === 'right' ? 12 : undefined,
140
+ alignSelf: position === 'center' ? 'center' : 'flex-end',
141
+ height: size === 'small' ? 36 : 48,
142
+ backgroundColor: theme.colors.primary,
143
+ bottom,
144
+ },
143
145
  containerStyle,
144
146
  ]}
145
147
  >
146
- <TouchableOpacity style={styles.content} onPress={onPress}>
148
+ <TouchableOpacity
149
+ style={{ flexDirection: 'row', alignItems: 'center' }}
150
+ onPress={onPress}
151
+ >
147
152
  <Icon
148
153
  source={icon}
149
154
  size={size === 'small' ? 12 : 24}
@@ -154,10 +159,10 @@ export const FloatingButton: React.FC<FloatingButtonProps> = ({
154
159
  allowFontScaling={false}
155
160
  style={[
156
161
  styles.label,
157
- styles.labelText,
158
162
  {
159
163
  fontSize: scaledFontSize,
160
164
  lineHeight: scaledLineHeight,
165
+ color: 'white',
161
166
  fontFamily: labelFontFamily,
162
167
  },
163
168
  labelStyle,
@@ -186,14 +191,4 @@ const styles = StyleSheet.create({
186
191
  label: {
187
192
  marginLeft: 8,
188
193
  },
189
- alignRight: { right: 12 },
190
- alignCenter: { alignSelf: 'center' },
191
- alignEnd: { alignSelf: 'flex-end' },
192
- small: { height: 36 },
193
- large: { height: 48 },
194
- content: {
195
- flexDirection: 'row',
196
- alignItems: 'center',
197
- },
198
- labelText: { color: Colors.black_01 },
199
194
  });
package/Layout/Item.tsx CHANGED
@@ -7,20 +7,16 @@ import { SpanNumber } from './types';
7
7
 
8
8
  export interface ItemProps extends ViewProps {
9
9
  /**
10
- * Width in grid columns (1-12). Defaults to the full row.
10
+ * Represents the width of the Card component in terms of span numbers (1-12).
11
11
  */
12
12
  widthSpan?: SpanNumber;
13
13
 
14
14
  /**
15
- * Optional. Height in grid spans (1-12). Unset keeps the content height.
15
+ * Optional. Represents the height of the Card component in terms of span numbers (1-12).
16
16
  */
17
17
  heightSpan?: SpanNumber;
18
18
  }
19
19
 
20
- /**
21
- * Grid cell sized from the enclosing GridContext; outlined when the mini app turns on
22
- * the baseline debug feature.
23
- */
24
20
  const Item: React.FC<ItemProps> = ({
25
21
  widthSpan,
26
22
  heightSpan,
@@ -7,16 +7,12 @@ import { SpanNumber } from './types';
7
7
 
8
8
  export interface ItemListProps extends FlatListProps<any> {
9
9
  /**
10
- * Width of each item in grid columns (1-12). Defaults to the full row.
10
+ * Represents the width of the Card component in terms of span numbers (1-12).
11
11
  */
12
12
  widthSpan?: SpanNumber;
13
13
  data: any[];
14
14
  }
15
15
 
16
- /**
17
- * FlatList on the grid: `widthSpan` sets how many items share a row, and every item but
18
- * the first of a row gets the gutter on its left.
19
- */
20
16
  const ItemList = forwardRef(
21
17
  (
22
18
  {
@@ -34,9 +30,6 @@ const ItemList = forwardRef(
34
30
  const indexBegin = props?.data?.map(
35
31
  (_i: any, index: number) => index * numColumns,
36
32
  );
37
- const defaultKeyExtractor = (item: any, index: number) => {
38
- return (item?.id ?? item?.key ?? index).toString();
39
- };
40
33
  const _renderItem = (item: any) => {
41
34
  if (indexBegin?.includes(item?.index)) {
42
35
  return <Item widthSpan={widthItem}>{renderItem?.(item)}</Item>;
@@ -53,7 +46,12 @@ const ItemList = forwardRef(
53
46
  ref={ref as React.RefObject<FlatList>}
54
47
  {...props}
55
48
  key={`ItemList-${numColumns}`}
56
- keyExtractor={(props as any)?.keyExtractor ?? defaultKeyExtractor}
49
+ keyExtractor={
50
+ // prefer caller's keyExtractor; fallback to common id/key/index
51
+ (props as any)?.keyExtractor ??
52
+ ((item: any, index: number) =>
53
+ (item?.id ?? item?.key ?? index).toString())
54
+ }
57
55
  numColumns={numColumns}
58
56
  renderItem={_renderItem}
59
57
  horizontal={false}
@@ -7,12 +7,11 @@ import { SpanNumber } from './types';
7
7
 
8
8
  export interface ItemSectionListProps extends SectionListProps<any> {
9
9
  /**
10
- * Width of each item in grid columns (1-12). Defaults to the full row.
10
+ * Represents the width of the Card component in terms of span numbers (1-12).
11
11
  */
12
12
  widthSpan?: SpanNumber;
13
13
  }
14
14
 
15
- /** SectionList whose items sit on the grid, `widthSpan` columns wide, a gutter apart. */
16
15
  const ItemSectionList: FC<ItemSectionListProps> = ({
17
16
  renderItem,
18
17
  widthSpan,