@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
@@ -5,10 +5,6 @@ import PaginationDot from './PaginationDot';
5
5
  import PaginationNumber from './PaginationNumber';
6
6
  import PaginationScroll from './PaginationScroll';
7
7
 
8
- /**
9
- * Page indicator: `type` picks plain dots, dots on a dark pill or an `n/total`
10
- * counter. `PaginationScroll` is the separate scroll-indicator variant.
11
- */
12
8
  const Pagination: FC<PaginationProps> = props => {
13
9
  const {type} = props;
14
10
 
@@ -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
 
@@ -1,28 +1,19 @@
1
1
  import React, { useContext, useRef, useState } from 'react';
2
- import { ScrollView, StyleSheet, View } from 'react-native';
2
+ import { ScrollView, StyleSheet, TouchableOpacity, View } from 'react-native';
3
3
  import { ApplicationContext, MiniAppContext } from '../Context';
4
4
  import { Button } from '../Button';
5
- import { Colors, Spacing, Styles } from '../Consts';
5
+ import { Colors, Radius, Spacing, Styles } from '../Consts';
6
+ import { Icon } from '../Icon';
6
7
  import { Image } from '../Image';
7
8
  import { Text, useScaleSize } from '../Text';
8
9
  import { PopupNotifyProps } from './types';
9
10
  import { scheduleOnRN } from 'react-native-worklets';
10
- import { useModalLayout } from '../Application/modalLayout';
11
- import { ModalIconButton } from '../Application/ModalIconButton';
12
- import { splitHighlightText } from './utils';
11
+ import { getPopupRadius, usePopupMaxHeight, usePopupWidth } from './utils';
13
12
 
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
13
  const PopupNotify: React.FC<PopupNotifyProps> = ({
22
14
  image,
23
15
  title = 'Title',
24
16
  description = 'Description',
25
- highlightText,
26
17
  error,
27
18
  secondary,
28
19
  primary,
@@ -33,23 +24,24 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
33
24
  const context = useContext<any>(MiniAppContext);
34
25
  const { theme, navigator, translate } = useContext(ApplicationContext);
35
26
  const [scrollContent, setScrollContent] = useState(false);
36
- const { isFoldable, popup } = useModalLayout();
37
- const { width: popupWidth, maxHeight, radius } = popup;
27
+ const popupWidth = usePopupWidth();
28
+ const maxHeight = usePopupMaxHeight();
29
+ const radius = getPopupRadius();
38
30
  const scaledMaxHeight = useScaleSize(172);
39
31
 
40
32
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
41
33
  const closeAction = useRef('touch_outside');
42
34
  let descriptionStyle = {};
43
35
  let Description: any = View;
44
- if (isFoldable) {
45
- // foldables cap the popup height, the description takes what is left
46
- Description = ScrollView;
47
- descriptionStyle = styles.shrink;
48
- } else if (scrollContent) {
36
+ if (scrollContent) {
49
37
  Description = ScrollView;
50
38
  descriptionStyle = { maxHeight: scaledMaxHeight };
51
39
  }
52
40
 
41
+ /**
42
+ * on action popup
43
+ * @param callback
44
+ */
53
45
  const onAction = (callback?: () => void) => {
54
46
  if (typeof onRequestClose === 'function') {
55
47
  onRequestClose?.(callback);
@@ -59,6 +51,9 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
59
51
  }
60
52
  };
61
53
 
54
+ /**
55
+ * build main action of popup
56
+ */
62
57
  const buildAction = () => {
63
58
  const renderRow = () => {
64
59
  return (
@@ -126,13 +121,10 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
126
121
  };
127
122
 
128
123
  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) {
124
+ if (
125
+ secondary?.title &&
126
+ (secondary.title.length > 12 || primary.title.length > 12)
127
+ ) {
136
128
  return renderColumn();
137
129
  }
138
130
  return renderRow();
@@ -143,79 +135,76 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
143
135
  return renderColumn();
144
136
  };
145
137
 
146
- /** Highlighted keywords use weight 600 but keep the body size and line height. */
147
- const renderDescription = (text: string) => {
148
- const segments = splitHighlightText(text, highlightText);
149
- if (!segments) {
150
- return text;
151
- }
152
- return segments.map((segment, index) => {
153
- if (segment.highlight) {
154
- return (
155
- <Text key={index} typography={'header_s_semibold'}>
156
- {segment.text}
157
- </Text>
158
- );
159
- }
160
- return segment.text;
161
- });
162
- };
163
-
138
+ /**
139
+ * build close action
140
+ */
164
141
  const buildCloseIcon = () => {
165
- if (typeof onIconClose !== 'function') {
166
- return null;
142
+ if (typeof onIconClose === 'function') {
143
+ return (
144
+ <TouchableOpacity
145
+ accessibilityLabel={'ic_popup_close'}
146
+ style={styles.iconCloseContainer}
147
+ onPress={() => {
148
+ closeAction.current = 'icon_close';
149
+ onAction(onIconClose);
150
+ }}
151
+ >
152
+ <View
153
+ style={[
154
+ styles.iconClose,
155
+ {
156
+ backgroundColor: theme.colors.text.default,
157
+ borderColor: theme.colors.background.surface,
158
+ },
159
+ ]}
160
+ >
161
+ <Icon
162
+ source="navigation_close"
163
+ color={theme.colors.background.surface}
164
+ size={14}
165
+ />
166
+ </View>
167
+ </TouchableOpacity>
168
+ );
167
169
  }
168
- return (
169
- <ModalIconButton
170
- icon="navigation_close"
171
- accessibilityLabel={'ic_popup_close'}
172
- style={styles.iconClose}
173
- onPress={() => {
174
- closeAction.current = 'icon_close';
175
- onAction(onIconClose);
176
- }}
177
- />
178
- );
179
170
  };
180
171
 
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
172
  const body = (
204
173
  <>
205
174
  {!!image && (
206
- <Image source={{ uri: image }} style={styles.image} />
175
+ <Image
176
+ source={{ uri: image }}
177
+ style={[
178
+ styles.image,
179
+ { borderTopLeftRadius: radius, borderTopRightRadius: radius },
180
+ ]}
181
+ />
207
182
  )}
208
- <View style={[styles.content, isFoldable && styles.shrink]}>
183
+ <View style={styles.content}>
209
184
  <Text
210
185
  typography={'header_default_bold'}
211
- numberOfLines={2}
186
+ numberOfLines={3}
212
187
  accessibilityLabel={'title_popup_notify'}
213
- style={titleStyle}
214
188
  >
215
189
  {title}
216
190
  </Text>
217
191
  <Description style={[styles.description, descriptionStyle]}>
218
- {descriptionContent}
192
+ {typeof description === 'string' ? (
193
+ <Text
194
+ accessibilityLabel={'description_popup_notify'}
195
+ typography={'body_default_regular'}
196
+ onTextLayout={({ nativeEvent: { lines } }) => {
197
+ const enableScroll = lines.length > 8.5;
198
+ if (enableScroll !== scrollContent) {
199
+ setScrollContent(enableScroll);
200
+ }
201
+ }}
202
+ >
203
+ {description}
204
+ </Text>
205
+ ) : (
206
+ description
207
+ )}
219
208
  </Description>
220
209
  {!!error && (
221
210
  <View style={styles.information}>
@@ -244,11 +233,23 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
244
233
  width: popupWidth,
245
234
  maxHeight,
246
235
  },
247
- styles.card,
248
236
  showBaseLineDebug && styles.debugBaseLine,
249
237
  ]}
250
238
  >
251
- {body}
239
+ {maxHeight === undefined ? (
240
+ body
241
+ ) : (
242
+ // scrolls when iPhone Duo landscape is too short; actions stay visible
243
+ <ScrollView
244
+ style={[
245
+ styles.body,
246
+ { borderTopLeftRadius: radius, borderTopRightRadius: radius },
247
+ ]}
248
+ bounces={false}
249
+ >
250
+ {body}
251
+ </ScrollView>
252
+ )}
252
253
  <View style={styles.contentAction}>{buildAction()}</View>
253
254
  {buildCloseIcon()}
254
255
  </View>
@@ -257,12 +258,11 @@ const PopupNotify: React.FC<PopupNotifyProps> = ({
257
258
 
258
259
  const styles = StyleSheet.create({
259
260
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
260
- // clips the image and content to the card radius
261
- card: { overflow: 'hidden' },
262
261
  image: {
263
262
  aspectRatio: 1.7777,
263
+ overflow: 'hidden',
264
264
  },
265
- shrink: { flexShrink: 1 },
265
+ body: { flexShrink: 1, overflow: 'hidden' },
266
266
  content: { padding: Spacing.XL },
267
267
  description: {
268
268
  marginTop: Spacing.S,
@@ -278,11 +278,19 @@ const styles = StyleSheet.create({
278
278
  width: Spacing.S,
279
279
  height: Spacing.S,
280
280
  },
281
- titleClearClose: { paddingRight: Spacing.XL },
282
- iconClose: {
281
+ iconCloseContainer: {
283
282
  position: 'absolute',
284
- top: Spacing.M,
285
- right: Spacing.M,
283
+ top: -Spacing.M,
284
+ right: -Spacing.M,
285
+ padding: Spacing.XS,
286
+ },
287
+ iconClose: {
288
+ width: 20,
289
+ height: 20,
290
+ alignItems: 'center',
291
+ justifyContent: 'center',
292
+ borderRadius: Radius.M,
293
+ borderWidth: 2,
286
294
  },
287
295
  });
288
296
 
@@ -5,17 +5,13 @@ import { ApplicationContext, MiniAppContext } from '../Context';
5
5
  import { Image } from '../Image';
6
6
  import { Colors, Radius, Spacing } from '../Consts';
7
7
  import { Icon } from '../Icon';
8
- import { useModalLayout } from '../Application/modalLayout';
8
+ import { usePopupMaxHeight, usePopupWidth } from './utils';
9
9
 
10
10
  const ASPECT_RATIO = 0.72;
11
11
  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,
@@ -24,10 +20,9 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
24
20
  }) => {
25
21
  const context = useContext<any>(MiniAppContext);
26
22
  const { theme, navigator } = useContext(ApplicationContext);
27
- const {
28
- popup: { width: popupWidth, maxHeight },
29
- } = useModalLayout();
30
- // fit the portrait image by height when a foldable leaves too little room
23
+ const popupWidth = usePopupWidth();
24
+ const maxHeight = usePopupMaxHeight();
25
+ // fit the portrait image by height when iPhone Duo leaves too little room
31
26
  let imageWidth = popupWidth;
32
27
  if (maxHeight !== undefined) {
33
28
  const heightFitWidth = (maxHeight - CLOSE_ROW_HEIGHT) * ASPECT_RATIO;
@@ -37,6 +32,10 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
37
32
 
38
33
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
39
34
 
35
+ /**
36
+ * on action popup
37
+ * @param callback
38
+ */
40
39
  const onAction = (callback?: () => void) => {
41
40
  if (typeof onRequestClose === 'function') {
42
41
  onRequestClose?.(callback);
@@ -46,6 +45,9 @@ const PopupPromotion: React.FC<PopupPromotionProps> = ({
46
45
  }
47
46
  };
48
47
 
48
+ /**
49
+ * build close action
50
+ */
49
51
  const buildCloseIcon = () => {
50
52
  return (
51
53
  <View style={styles.iconCloseContainer}>
package/Popup/types.ts CHANGED
@@ -20,13 +20,6 @@ export type PopupNotifyProps = {
20
20
  */
21
21
  description?: string | React.ReactNode;
22
22
 
23
- /**
24
- * `highlightText`: Optional. List of words/phrases within `description` to be rendered in semibold.
25
- * Only applies when `description` is a string. Matching is whole-word and case-sensitive;
26
- * every occurrence of each string is highlighted.
27
- */
28
- highlightText?: string[];
29
-
30
23
  /**
31
24
  * `error`: Optional. Represents additional error text to be displayed in the PopupNotify component.
32
25
  */
@@ -56,7 +49,7 @@ export type PopupNotifyProps = {
56
49
  onIconClose?: () => void;
57
50
 
58
51
  /**
59
- * `onRequestClose`: Optional. Closes the modal, then runs `callback`. ModalScreen injects it; without it the popup uses `navigator.pop()`.
52
+ * onRequestClose on request close for modal
60
53
  */
61
54
  onRequestClose?: (callback?: () => void) => void;
62
55
  };
@@ -73,17 +66,17 @@ export type PopupPromotionProps = {
73
66
  image: string;
74
67
 
75
68
  /**
76
- * `onIconClose`: Optional. A callback function that is called after the popup closes from the close icon.
69
+ * `onClose`: Optional. A callback function that is called when the PopupPromotion component is closed.
77
70
  */
78
71
  onIconClose?: () => void;
79
72
 
80
73
  /**
81
- * `onActionClick`: Optional. A callback function that is called after the popup closes from an image tap.
74
+ * `onActionClick`: Optional. A callback function that is called when the PopupPromotion component is closed.
82
75
  */
83
76
  onActionClick?: () => void;
84
77
 
85
78
  /**
86
- * `onRequestClose`: Optional. Closes the modal, then runs `callback`. ModalScreen injects it; without it the popup uses `navigator.pop()`.
79
+ * onRequestClose on request close for modal
87
80
  */
88
81
  onRequestClose?: (callback?: () => void) => void;
89
82
  };
package/Popup/utils.ts CHANGED
@@ -1,58 +1,26 @@
1
- type HighlightSegment = { text: string; highlight: boolean };
1
+ import { Dimensions, useWindowDimensions } from 'react-native';
2
+ import { useSafeAreaInsets } from 'react-native-safe-area-context';
3
+ import { Radius, Spacing } from '../Consts';
4
+ import { getDuoModalBounds, isIPhoneDuo } from '../Application/device';
2
5
 
3
- /**
4
- * True for cased-script letters, digits and `_`; caseless scripts (CJK, Thai)
5
- * count as word breaks.
6
- */
7
- const isWordChar = (char?: string) => {
8
- if (!char) {
9
- return false;
6
+ const usePopupWidth = () => {
7
+ const insets = useSafeAreaInsets();
8
+ const { width, height } = useWindowDimensions();
9
+ if (!isIPhoneDuo()) {
10
+ return Dimensions.get('window').width - Spacing.XL * 2;
10
11
  }
11
- const isLetter = char.toLowerCase() !== char.toUpperCase();
12
- return isLetter || /[0-9_]/.test(char);
12
+ return getDuoModalBounds(insets, width, height).maxWidth;
13
13
  };
14
14
 
15
- /**
16
- * Split `text` into plain/highlighted segments (same matching as Information `highlightText`):
17
- * whole-word, case-sensitive, every occurrence, longest keyword first.
18
- * Returns `undefined` when there is nothing to highlight.
19
- */
20
- const splitHighlightText = (
21
- text: string,
22
- highlightText?: string[],
23
- ): HighlightSegment[] | undefined => {
24
- const keywords = highlightText?.filter(keyword => {
25
- if (typeof keyword !== 'string') {
26
- return false;
27
- }
28
- return keyword.length > 0;
29
- });
30
- if (!keywords?.length) {
15
+ const usePopupMaxHeight = () => {
16
+ const insets = useSafeAreaInsets();
17
+ const { width, height } = useWindowDimensions();
18
+ if (!isIPhoneDuo()) {
31
19
  return undefined;
32
20
  }
33
- const pattern = [...keywords]
34
- .sort((a, b) => b.length - a.length)
35
- .map(keyword => keyword.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'))
36
- .join('|');
37
- const regex = new RegExp(pattern, 'g');
38
- const segments: HighlightSegment[] = [];
39
- let lastIndex = 0;
40
- let match;
41
- while ((match = regex.exec(text))) {
42
- const start = match.index;
43
- const end = start + match[0].length;
44
- if (isWordChar(text[start - 1]) || isWordChar(text[end])) {
45
- regex.lastIndex = start + 1;
46
- continue;
47
- }
48
- if (start > lastIndex) {
49
- segments.push({ text: text.slice(lastIndex, start), highlight: false });
50
- }
51
- segments.push({ text: match[0], highlight: true });
52
- lastIndex = end;
53
- }
54
- segments.push({ text: text.slice(lastIndex), highlight: false });
55
- return segments;
21
+ return getDuoModalBounds(insets, width, height).maxHeight;
56
22
  };
57
23
 
58
- export { splitHighlightText };
24
+ const getPopupRadius = () => (isIPhoneDuo() ? Radius.XL : Radius.L);
25
+
26
+ export { usePopupWidth, usePopupMaxHeight, getPopupRadius };
package/Radio/index.tsx CHANGED
@@ -10,11 +10,8 @@ import {
10
10
  ComponentContext,
11
11
  MiniAppContext,
12
12
  } from '../Context';
13
+ import { Spacing } from '../Consts';
13
14
 
14
- /**
15
- * Radio button, selected when `value === groupValue`. `onChange` is called on
16
- * press without arguments; the parent updates `groupValue`.
17
- */
18
15
  const Radio: FC<RadioProps> = ({
19
16
  value,
20
17
  groupValue,
@@ -70,7 +67,14 @@ const Radio: FC<RadioProps> = ({
70
67
  {...props}
71
68
  disabled={disabled}
72
69
  onPress={onChange}
73
- style={[style, styles.row, showBaseLineDebug && styles.debugBaseLine]}
70
+ style={[
71
+ style,
72
+ {
73
+ flexDirection: 'row',
74
+ alignItems: 'center',
75
+ },
76
+ showBaseLineDebug && styles.debugBaseLine,
77
+ ]}
74
78
  accessibilityState={{
75
79
  checked: selected,
76
80
  disabled: disabled as boolean,
@@ -83,7 +87,7 @@ const Radio: FC<RadioProps> = ({
83
87
  styles.radio,
84
88
  checkBoxStyle,
85
89
  disabledStyle,
86
- label ? styles.radioWithLabel : styles.radioNoLabel,
90
+ { marginRight: label ? Spacing.S : 0 },
87
91
  ]}
88
92
  />
89
93
  {!!label && (
package/Radio/styles.ts CHANGED
@@ -11,11 +11,5 @@ export default StyleSheet.create({
11
11
  radioText: {
12
12
  marginRight: Spacing.M,
13
13
  },
14
- row: {
15
- flexDirection: 'row',
16
- alignItems: 'center',
17
- },
18
- radioWithLabel: { marginRight: Spacing.S },
19
- radioNoLabel: { marginRight: 0 },
20
14
  debugBaseLine: { borderWidth: 1, borderColor: Colors.green_06 },
21
15
  });
@@ -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);
@@ -69,7 +65,15 @@ const Skeleton: React.FC<SkeletonTypes> = ({ style }) => {
69
65
  onLayout={e => onLayout(e.nativeEvent.layout.width)}
70
66
  style={[Styles.flex, { backgroundColor: PRIMARY_COLOR }]}
71
67
  >
72
- <Animated.View style={[styles.shimmer, shimmerStyle]}>
68
+ <Animated.View
69
+ style={[
70
+ {
71
+ width: '60%',
72
+ height: '100%',
73
+ },
74
+ shimmerStyle,
75
+ ]}
76
+ >
73
77
  <LinearGradient
74
78
  style={[StyleSheet.absoluteFill]}
75
79
  colors={shimmerColors}
@@ -88,10 +92,6 @@ const Skeleton: React.FC<SkeletonTypes> = ({ style }) => {
88
92
  );
89
93
  };
90
94
 
91
- /**
92
- * Shares `loading` with descendants (e.g. `Image` shows a skeleton) and animates
93
- * the layout change when it flips.
94
- */
95
95
  const SkeletonProvider: React.FC<{ loading: boolean; children: any }> = ({
96
96
  loading = true,
97
97
  children,
@@ -2,5 +2,4 @@ import {StyleSheet} from 'react-native';
2
2
 
3
3
  export default StyleSheet.create({
4
4
  container: {overflow: 'hidden', width: '100%', height: '100%'},
5
- shimmer: {width: '60%', height: '100%'},
6
5
  });
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,8 +72,8 @@ 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.
80
- const validateCustomColor = (hex: string) => {
75
+ //Check if custom color is [color]_03 (only check in dev mode)
76
+ const validateCustomColor = (color: string) => {
81
77
  if (__DEV__) {
82
78
  const colorCore: { [key: string]: string } = Colors;
83
79
  const primaryColors = Object.keys(Colors)
@@ -86,8 +82,8 @@ const Tag: FC<TagProps> = ({
86
82
  return colorCore[i];
87
83
  }
88
84
  })
89
- .filter(item => item);
90
- return primaryColors.includes(hex);
85
+ .filter(color => color);
86
+ return primaryColors.includes(color);
91
87
  }
92
88
  return true;
93
89
  };
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