@momo-kits/foundation 0.169.6 → 0.169.7-beta.10
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.hooks.ts +8 -8
- package/Application/BottomSheet.parts.tsx +34 -44
- package/Application/BottomSheet.tsx +37 -40
- package/Application/BottomTab/ActiveIndicator.tsx +14 -15
- package/Application/BottomTab/BottomTabBar.tsx +62 -49
- package/Application/BottomTab/BottomTabInset.tsx +4 -8
- package/Application/BottomTab/CurvedContainer.tsx +12 -14
- package/Application/BottomTab/CustomBottomTabItem.tsx +13 -13
- package/Application/BottomTab/DuoBarCompression.tsx +19 -13
- package/Application/BottomTab/DuoRailTabBar.tsx +24 -20
- package/Application/BottomTab/DuoTabBar.tsx +10 -8
- package/Application/BottomTab/TabBarIcon.tsx +29 -15
- package/Application/BottomTab/TabScreen.tsx +5 -1
- package/Application/BottomTab/index.tsx +30 -33
- package/Application/BottomTab/metrics.ts +23 -23
- package/Application/BottomTab/tabItems.ts +1 -1
- package/Application/BottomTab/usePressLift.ts +2 -2
- package/Application/Components/BackgroundImageView.tsx +0 -4
- package/Application/Components/DuoGlassBackground.tsx +4 -5
- package/Application/Components/HeaderAnimated.tsx +0 -4
- package/Application/Components/HeaderBackground.tsx +0 -4
- package/Application/Components/HeaderExtendHeader.tsx +10 -11
- package/Application/Components/HeaderLeft.tsx +1 -2
- package/Application/Components/HeaderRight.tsx +1 -2
- package/Application/Components/HeaderTitle.shared.ts +9 -11
- package/Application/Components/HeaderTitle.tsx +3 -4
- package/Application/Components/HeaderToolkitAction.tsx +20 -17
- package/Application/Components/NavigationButton.tsx +1 -2
- package/Application/Components/SearchHeader.tsx +10 -17
- package/Application/Components/TitleJourney.tsx +2 -2
- package/Application/Components/TitleLocation.tsx +2 -2
- package/Application/Components/TitleUser.tsx +2 -2
- package/Application/Components/useToolkitActions.tsx +32 -17
- package/Application/KitAdoption/AdoptionBadge.tsx +119 -0
- package/Application/KitAdoption/AdoptionProbe.tsx +166 -0
- package/Application/KitAdoption/AdoptionStore.ts +80 -0
- package/Application/KitAdoption/Authorship/utils.ts +137 -0
- package/Application/KitAdoption/Slots/utils.ts +68 -0
- package/Application/KitAdoption/constants.ts +120 -0
- package/Application/KitAdoption/index.ts +12 -0
- package/Application/KitAdoption/styles.ts +55 -0
- package/Application/KitAdoption/types.ts +61 -0
- package/Application/KitAdoption/utils.ts +376 -0
- package/Application/Localize.ts +0 -7
- package/Application/ModalScreen.tsx +10 -10
- package/Application/Navigation.ts +16 -14
- package/Application/NavigationContainer.tsx +18 -19
- package/Application/Navigator.ts +48 -20
- package/Application/ScaleSizeProvider.tsx +6 -13
- package/Application/StackScreen.tracking.ts +33 -11
- package/Application/StackScreen.tsx +54 -10
- package/Application/TooltipPortal.tsx +5 -12
- package/Application/WidgetContainer.tsx +4 -10
- package/Application/__tests__/KitAdoption.integration.test.tsx +253 -0
- package/Application/__tests__/KitAdoption.test.ts +283 -0
- package/Application/__tests__/KitAdoptionAuthorship.test.ts +132 -0
- package/Application/__tests__/KitAdoptionStore.test.ts +110 -0
- package/Application/__tests__/KitAdoptionStructural.test.ts +193 -0
- package/Application/__tests__/modalLayout.test.ts +128 -0
- package/Application/modalLayout.ts +14 -13
- package/Application/navigationOptions.tsx +17 -21
- package/Badge/Badge.tsx +0 -5
- package/Badge/BadgeDot.tsx +0 -1
- package/Badge/BadgeDotAnimation.tsx +7 -15
- package/Badge/BadgeRibbon.tsx +38 -46
- package/Badge/Shape.tsx +0 -2
- package/Badge/types.ts +2 -2
- package/Button/index.tsx +16 -5
- package/Button/utils.ts +15 -9
- package/CheckBox/index.tsx +0 -4
- package/Consts/theme.ts +10 -10
- package/Context/index.ts +1 -5
- package/Divider/DashDivider.tsx +0 -1
- package/Divider/index.tsx +0 -4
- 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 +9 -8
- package/Input/InputDropDown.tsx +12 -10
- package/Input/InputMoney.tsx +8 -12
- package/Input/InputMoneyView.tsx +7 -14
- package/Input/InputOTP.tsx +33 -35
- package/Input/InputPhoneNumber.tsx +9 -8
- package/Input/InputSearch.tsx +6 -4
- package/Input/InputTextArea.tsx +0 -4
- package/Input/SearchTextTyping.tsx +0 -4
- package/Input/SystemTextInput.tsx +2 -7
- package/Input/TextTyping.tsx +0 -4
- package/Input/common.tsx +12 -26
- package/Input/index.tsx +20 -17
- package/Input/moneyUtils.ts +4 -10
- package/Input/styles.ts +5 -0
- package/Input/utils.ts +12 -14
- package/Layout/Card.tsx +13 -16
- package/Layout/FloatingButton.tsx +0 -4
- package/Layout/Item.tsx +2 -6
- package/Layout/ItemList.tsx +7 -9
- package/Layout/ItemSectionList.tsx +1 -2
- package/Layout/ReservedRegions.tsx +25 -25
- package/Layout/Screen.tsx +58 -56
- package/Layout/Section.tsx +13 -17
- package/Layout/TrackingScope.tsx +0 -1
- package/Layout/constants.ts +19 -0
- package/Layout/screenContent.tsx +2 -4
- package/Layout/screenFooter.tsx +18 -28
- package/Layout/screenHeader.tsx +31 -34
- package/Layout/screenQuickReturn.tsx +20 -17
- package/Layout/screenScroll.ts +7 -4
- package/Layout/screenTypes.ts +2 -3
- package/Layout/types.ts +41 -3
- package/Layout/useGridSystem.ts +49 -0
- package/Layout/utils.ts +37 -38
- package/Loader/DotLoader.tsx +0 -4
- package/Loader/Loader.tsx +0 -4
- package/Loader/ProgressBar.tsx +0 -1
- package/Loader/Spinner.tsx +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 +48 -44
- package/Popup/PopupPromotion.tsx +7 -4
- package/Popup/types.ts +4 -4
- package/Popup/utils.ts +0 -4
- package/Radio/index.tsx +0 -4
- package/Skeleton/index.tsx +0 -8
- package/Switch/index.tsx +0 -1
- package/Tag/index.tsx +1 -5
- package/Tag/types.ts +3 -3
- package/Text/index.tsx +3 -14
- package/Text/styles.ts +1 -1
- package/Text/types.ts +6 -1
- package/Text/utils.ts +4 -20
- package/Title/index.tsx +32 -41
- package/ViewBoundary/index.tsx +2 -4
- package/index.ts +6 -0
- package/package.json +1 -1
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
|
@@ -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
|
-
|
|
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) {
|
|
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
|
-
/**
|
|
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
|
|
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={
|
|
197
|
+
numberOfLines={3}
|
|
212
198
|
accessibilityLabel={'title_popup_notify'}
|
|
213
|
-
|
|
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
|
-
{
|
|
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 },
|
package/Popup/PopupPromotion.tsx
CHANGED
|
@@ -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
|
-
*
|
|
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
|
-
* `
|
|
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
|
|
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
|
-
*
|
|
86
|
+
* onRequestClose on request close for modal
|
|
87
87
|
*/
|
|
88
88
|
onRequestClose?: (callback?: () => void) => void;
|
|
89
89
|
};
|
package/Popup/utils.ts
CHANGED
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,
|
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);
|
|
@@ -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
|
-
//
|
|
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 '
|
|
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
|
|
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
|
-
//
|
|
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
|
-
|
|
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
|
-
|
|
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,28 +6,16 @@ const DEFAULT_SCREEN_SIZE = 375;
|
|
|
6
6
|
const MAX_FONT_SCALE = 1.5;
|
|
7
7
|
const MAX_DEVICE_SCALE = 5;
|
|
8
8
|
|
|
9
|
-
type MiniAppScale = {
|
|
10
|
-
scaleSizeMaxRate?: number;
|
|
11
|
-
fontScale?: { useOSScaleRate?: boolean; userScaleRate?: number };
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Scales `size` by screen width (+5 max) and OS font scale (max `scaleRate`,
|
|
16
|
-
* else the ScaleSizeProvider rate, else 1.5), taking the larger, or by the mini
|
|
17
|
-
* app `fontScale.userScaleRate`; a provider rate caps both at `size × rate`.
|
|
18
|
-
*/
|
|
19
9
|
const useScaleSize = (size: number, scaleRate?: number) => {
|
|
20
10
|
const { width } = useWindowDimensions();
|
|
21
|
-
const context = useContext<
|
|
22
|
-
const scaleSizeMaxRate = context?.scaleSizeMaxRate;
|
|
23
|
-
const maxSize = scaleSizeMaxRate ? size * scaleSizeMaxRate : Infinity;
|
|
11
|
+
const context = useContext<any>(MiniAppContext);
|
|
24
12
|
if (context?.fontScale?.useOSScaleRate === false) {
|
|
25
|
-
return
|
|
13
|
+
return size * (context.fontScale.userScaleRate ?? 1);
|
|
26
14
|
}
|
|
27
15
|
const fontScale = PixelRatio.getFontScale();
|
|
28
16
|
const deviceScale = width / DEFAULT_SCREEN_SIZE;
|
|
29
17
|
|
|
30
|
-
const maxScaleRate = scaleRate ??
|
|
18
|
+
const maxScaleRate = scaleRate ?? MAX_FONT_SCALE;
|
|
31
19
|
|
|
32
20
|
let fontSizeDeviceScale = size;
|
|
33
21
|
let fontSizeOSScale = size;
|
|
@@ -46,13 +34,9 @@ const useScaleSize = (size: number, scaleRate?: number) => {
|
|
|
46
34
|
);
|
|
47
35
|
}
|
|
48
36
|
|
|
49
|
-
return Math.
|
|
37
|
+
return Math.max(fontSizeDeviceScale, fontSizeOSScale);
|
|
50
38
|
};
|
|
51
39
|
|
|
52
|
-
/**
|
|
53
|
-
* Non-hook `useScaleSize` with the default cap and no mini app rate, for use
|
|
54
|
-
* outside render. Reads the window width at call time, so it misses resizes.
|
|
55
|
-
*/
|
|
56
40
|
const scaleSize = (size: number) => {
|
|
57
41
|
const fontScale = PixelRatio.getFontScale();
|
|
58
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
|
-
{
|
|
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
|
};
|
package/ViewBoundary/index.tsx
CHANGED
|
@@ -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';
|