@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.
- package/Application/BottomSheet.tsx +398 -86
- package/Application/BottomTab/BottomTabBar.tsx +275 -215
- package/Application/BottomTab/CustomBottomTabItem.tsx +107 -131
- package/Application/BottomTab/DuoBarCompression.tsx +28 -14
- package/Application/BottomTab/DuoTabBar.tsx +540 -32
- package/Application/BottomTab/TabBarIcon.tsx +72 -146
- package/Application/BottomTab/index.tsx +353 -89
- package/Application/BottomTab/useLiquidSelection.ts +374 -0
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +5 -7
- package/Application/Components/HeaderAnimated.tsx +13 -41
- package/Application/Components/HeaderBackground.tsx +3 -20
- package/Application/Components/HeaderExtendHeader.tsx +46 -66
- package/Application/Components/HeaderLeft.tsx +18 -5
- package/Application/Components/HeaderRight.tsx +529 -8
- package/Application/Components/HeaderTitle.tsx +579 -16
- package/Application/Components/NavigationButton.tsx +11 -18
- package/Application/Components/SearchHeader.tsx +18 -38
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +18 -41
- package/Application/Navigation.ts +17 -15
- package/Application/NavigationContainer.tsx +21 -23
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tsx +172 -27
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +7 -20
- package/Application/device.ts +52 -0
- package/Application/index.ts +1 -23
- package/Application/types.ts +242 -17
- package/Application/utils.tsx +493 -0
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +39 -47
- package/Badge/Shape.tsx +0 -2
- package/Badge/styles.ts +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +152 -21
- package/Button/styles.ts +1 -1
- package/CheckBox/index.tsx +6 -5
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +11 -11
- package/Divider/index.tsx +7 -21
- package/FoundationList/index.tsx +0 -4
- package/Icon/index.tsx +6 -6
- package/Icon/types.ts +1 -1
- package/IconButton/index.tsx +12 -4
- package/Image/index.tsx +7 -9
- package/Input/Input.tsx +12 -10
- package/Input/InputDropDown.tsx +13 -10
- package/Input/InputMoney.tsx +152 -45
- package/Input/InputOTP.tsx +34 -36
- package/Input/InputPhoneNumber.tsx +5 -8
- package/Input/InputSearch.tsx +111 -19
- package/Input/InputTextArea.tsx +5 -5
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +17 -31
- package/Input/index.tsx +21 -24
- package/Input/styles.ts +5 -25
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +4 -7
- package/Layout/FloatingButton.tsx +21 -26
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +17 -34
- package/Layout/Screen.tsx +696 -122
- package/Layout/Section.tsx +7 -9
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/index.ts +4 -10
- package/Layout/styles.ts +0 -2
- package/Layout/types.ts +4 -2
- package/Layout/utils.ts +181 -40
- package/Loader/DotLoader.tsx +3 -11
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +6 -3
- package/Loader/Spinner.tsx +3 -11
- package/Loader/styles.ts +0 -4
- package/Loader/utils.ts +7 -11
- package/Pagination/Dot.tsx +0 -4
- package/Pagination/PaginationDot.tsx +0 -1
- package/Pagination/PaginationNumber.tsx +3 -5
- package/Pagination/PaginationScroll.tsx +0 -5
- package/Pagination/PaginationWhiteDot.tsx +0 -1
- package/Pagination/index.tsx +0 -4
- package/Pagination/types.ts +2 -2
- package/Popup/PopupNotify.tsx +102 -94
- package/Popup/PopupPromotion.tsx +11 -9
- package/Popup/types.ts +4 -11
- package/Popup/utils.ts +18 -50
- package/Radio/index.tsx +10 -6
- package/Radio/styles.ts +0 -6
- package/Skeleton/index.tsx +9 -9
- package/Skeleton/styles.ts +0 -1
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +4 -8
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +5 -25
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +40 -42
- package/Title/styles.ts +0 -6
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -2
- package/Application/BottomSheet.hooks.ts +0 -195
- package/Application/BottomSheet.parts.tsx +0 -157
- package/Application/BottomSheet.styles.ts +0 -43
- package/Application/BottomTab/ActiveIndicator.tsx +0 -91
- package/Application/BottomTab/BottomTabBar.styles.ts +0 -65
- package/Application/BottomTab/BottomTabInset.tsx +0 -18
- package/Application/BottomTab/CurvedContainer.tsx +0 -155
- package/Application/BottomTab/DuoRailTabBar.tsx +0 -223
- package/Application/BottomTab/DuoTabBar.styles.ts +0 -81
- package/Application/BottomTab/TabScreen.tsx +0 -160
- package/Application/BottomTab/metrics.ts +0 -164
- package/Application/BottomTab/tabItems.ts +0 -46
- package/Application/BottomTab/usePressLift.ts +0 -32
- package/Application/Components/HeaderRight.styles.ts +0 -146
- package/Application/Components/HeaderTitle.shared.ts +0 -44
- package/Application/Components/HeaderTitle.styles.ts +0 -125
- package/Application/Components/HeaderToolkitAction.tsx +0 -180
- package/Application/Components/SwipeBackHaptic.tsx +0 -95
- package/Application/Components/TitleJourney.tsx +0 -110
- package/Application/Components/TitleLocation.tsx +0 -73
- package/Application/Components/TitleUser.tsx +0 -304
- package/Application/Components/useToolkitActions.tsx +0 -218
- package/Application/ModalIconButton.tsx +0 -66
- package/Application/StackScreen.tracking.ts +0 -143
- package/Application/headerLayout.ts +0 -158
- package/Application/hooks.ts +0 -137
- package/Application/modalLayout.ts +0 -176
- package/Application/navigationOptions.tsx +0 -212
- package/Application/types.header.ts +0 -121
- package/Application/types.tabs.ts +0 -48
- package/Application/types.theme.ts +0 -87
- package/Application/utils.ts +0 -107
- package/Button/utils.ts +0 -133
- package/Input/InputMoneyView.tsx +0 -194
- package/Input/SearchTextTyping.tsx +0 -108
- package/Input/moneyUtils.ts +0 -23
- package/Layout/layoutMetrics.ts +0 -58
- package/Layout/layoutTypes.ts +0 -86
- package/Layout/screenContent.tsx +0 -92
- package/Layout/screenFooter.tsx +0 -63
- package/Layout/screenHeader.tsx +0 -321
- package/Layout/screenQuickReturn.tsx +0 -64
- package/Layout/screenScroll.ts +0 -107
- package/Layout/screenTypes.ts +0 -143
package/Pagination/index.tsx
CHANGED
|
@@ -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
|
|
package/Pagination/types.ts
CHANGED
|
@@ -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
|
|
8
|
+
* - 'black_white': Represents a pagination that have black background.
|
|
9
9
|
* - 'number': Represents a style where pages are represented by numbers.
|
|
10
|
-
* - 'scroll':
|
|
10
|
+
* - 'scroll': Represents a scrollable style.
|
|
11
11
|
*/
|
|
12
12
|
type?: 'default' | 'black_white' | 'number' | 'scroll';
|
|
13
13
|
|
package/Popup/PopupNotify.tsx
CHANGED
|
@@ -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 {
|
|
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
|
|
37
|
-
const
|
|
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 (
|
|
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
|
-
|
|
130
|
-
|
|
131
|
-
|
|
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
|
-
/**
|
|
147
|
-
|
|
148
|
-
|
|
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
|
|
166
|
-
return
|
|
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
|
|
175
|
+
<Image
|
|
176
|
+
source={{ uri: image }}
|
|
177
|
+
style={[
|
|
178
|
+
styles.image,
|
|
179
|
+
{ borderTopLeftRadius: radius, borderTopRightRadius: radius },
|
|
180
|
+
]}
|
|
181
|
+
/>
|
|
207
182
|
)}
|
|
208
|
-
<View style={
|
|
183
|
+
<View style={styles.content}>
|
|
209
184
|
<Text
|
|
210
185
|
typography={'header_default_bold'}
|
|
211
|
-
numberOfLines={
|
|
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
|
-
{
|
|
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
|
-
{
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -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 {
|
|
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
|
-
|
|
29
|
-
|
|
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
|
-
*
|
|
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
|
-
* `
|
|
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
|
|
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
|
-
*
|
|
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
|
-
|
|
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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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
|
-
|
|
12
|
-
return isLetter || /[0-9_]/.test(char);
|
|
12
|
+
return getDuoModalBounds(insets, width, height).maxWidth;
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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={[
|
|
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 ?
|
|
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
|
});
|
package/Skeleton/index.tsx
CHANGED
|
@@ -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
|
|
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,
|
package/Skeleton/styles.ts
CHANGED
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
|
-
//
|
|
80
|
-
const validateCustomColor = (
|
|
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(
|
|
90
|
-
return primaryColors.includes(
|
|
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 '
|
|
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.
|
|
33
|
-
*
|
|
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
|
|