@momo-kits/foundation 0.169.18-beta.3 → 0.169.19-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. package/Application/BottomSheet.parts.tsx +4 -4
  2. package/Application/BottomSheet.tsx +8 -18
  3. package/Application/BottomTab/BottomTabBar.styles.ts +1 -1
  4. package/Application/BottomTab/DuoTabBar.styles.ts +1 -1
  5. package/Application/BottomTab/TabBarIcon.tsx +1 -1
  6. package/Application/Components/HeaderAnimated.tsx +33 -9
  7. package/Application/Components/HeaderExtendHeader.tsx +28 -18
  8. package/Application/Components/SearchHeader.tsx +7 -5
  9. package/Application/ModalIconButton.tsx +13 -15
  10. package/Application/ModalScreen.tsx +15 -6
  11. package/Application/StackScreen.tsx +6 -2
  12. package/Application/TooltipPortal.tsx +3 -3
  13. package/Application/__tests__/headerLayout.test.ts +113 -0
  14. package/Application/headerLayout.ts +114 -30
  15. package/Application/hooks.ts +1 -1
  16. package/Application/modalLayout.ts +43 -11
  17. package/Application/types.header.ts +7 -1
  18. package/Button/index.tsx +2 -2
  19. package/Divider/DashDivider.tsx +2 -2
  20. package/Divider/index.tsx +3 -3
  21. package/FoundationList/index.tsx +1 -1
  22. package/Icon/types.ts +1 -2
  23. package/Image/index.tsx +62 -7
  24. package/Image/styles.ts +2 -0
  25. package/Image/types.ts +9 -1
  26. package/Input/CountryCodeView.tsx +18 -2
  27. package/Input/ErrorView.tsx +1 -1
  28. package/Input/Input.tsx +2 -2
  29. package/Input/InputMoney.tsx +7 -2
  30. package/Input/InputMoneyView.tsx +8 -16
  31. package/Input/InputOTP.tsx +2 -2
  32. package/Input/InputPhoneNumber.tsx +2 -2
  33. package/Input/InputSearch.tsx +2 -2
  34. package/Input/InputTextArea.tsx +2 -2
  35. package/Input/SearchTextTyping.tsx +2 -2
  36. package/Input/SystemTextInput.tsx +2 -1
  37. package/Input/TextTyping.tsx +7 -2
  38. package/Input/index.tsx +2 -1
  39. package/Layout/Screen.tsx +13 -16
  40. package/Layout/Section.tsx +3 -14
  41. package/Layout/layoutMetrics.ts +2 -2
  42. package/Layout/screenContent.tsx +4 -10
  43. package/Layout/screenFooter.tsx +22 -273
  44. package/Layout/screenHeader.tsx +26 -31
  45. package/Layout/screenTypes.ts +4 -27
  46. package/Layout/styles.ts +0 -10
  47. package/Layout/types.ts +0 -12
  48. package/Layout/useHeaderBarOptions.ts +54 -0
  49. package/Pagination/types.ts +6 -2
  50. package/package.json +28 -26
  51. package/Layout/__tests__/screenFooter.test.ts +0 -142
@@ -7,7 +7,12 @@ import React, {
7
7
  useRef,
8
8
  useState,
9
9
  } from 'react';
10
- import { Platform, TextInput, TextInputFocusEvent, View } from 'react-native';
10
+ import {
11
+ Platform,
12
+ TextInputFocusEvent,
13
+ View,
14
+ type TextInputInstance,
15
+ } from 'react-native';
11
16
  import { useComponentId } from '../Application';
12
17
  import { ComponentContext, MiniAppContext } from '../Context';
13
18
  import { ErrorView } from './ErrorView';
@@ -56,7 +61,7 @@ const InputMoney = forwardRef(
56
61
  const [displayValue, setDisplayValue] = useState('');
57
62
  const [numericValue, setNumericValue] = useState('');
58
63
  const [lastDisplayValue, setLastDisplayValue] = useState('');
59
- const inputRef = useRef<TextInput>(null);
64
+ const inputRef = useRef<TextInputInstance>(null);
60
65
  const caretDigitsAfter = useRef<number | undefined>(undefined);
61
66
  const lastRawText = useRef('');
62
67
  const [caretSelection, setCaretSelection] = useState<{
@@ -2,11 +2,11 @@ import React, { RefObject, useContext } from 'react';
2
2
  import {
3
3
  Pressable,
4
4
  Text,
5
- TextInput,
6
5
  TextInputFocusEvent,
7
6
  TextInputProps,
8
7
  TouchableOpacity,
9
8
  View,
9
+ type TextInputInstance,
10
10
  } from 'react-native';
11
11
  import { ApplicationContext } from '../Context';
12
12
  import { Icon } from '../Icon';
@@ -43,7 +43,7 @@ type InputMoneyViewProps = Pick<
43
43
  componentId: string;
44
44
  displayValue: string;
45
45
  caretSelection?: { start: number; end: number };
46
- inputRef: RefObject<TextInput | null>;
46
+ inputRef: RefObject<TextInputInstance | null>;
47
47
  focusAtEnd: () => void;
48
48
  onClearText: () => void;
49
49
  onChangeText: (text: string) => void;
@@ -53,8 +53,8 @@ type InputMoneyViewProps = Pick<
53
53
  };
54
54
 
55
55
  /**
56
- * Presentational body of InputMoney: bordered field, currency suffix (kept
57
- * after a placeholder that ends with it) and the clear/trailing icons.
56
+ * Presentational body of InputMoney: bordered field, currency suffix (shown
57
+ * once there is a value) and the clear/trailing icons.
58
58
  */
59
59
  export const InputMoneyView = ({
60
60
  size,
@@ -101,13 +101,8 @@ export const InputMoneyView = ({
101
101
  fontSize: scaledFontSize,
102
102
  fontFamily: inputFontFamily,
103
103
  };
104
- const hasCurrencyInPlaceholder = placeholder.endsWith(currency);
105
- const shouldShowCurrency = !!displayValue || hasCurrencyInPlaceholder;
104
+ const hasValue = displayValue.length > 0;
106
105
  const shouldShowClearIcon = !!(showClearIcon && focused && displayValue);
107
- let inputPlaceholder = placeholder;
108
- if (hasCurrencyInPlaceholder) {
109
- inputPlaceholder = placeholder.slice(0, -currency.length);
110
- }
111
106
  return (
112
107
  <View
113
108
  style={[
@@ -148,18 +143,15 @@ export const InputMoneyView = ({
148
143
  onChangeText={onChangeText}
149
144
  onFocus={onFocus}
150
145
  onBlur={onBlur}
151
- placeholder={inputPlaceholder}
146
+ placeholder={placeholder}
152
147
  selectionColor={theme.colors.primary}
153
148
  placeholderTextColor={placeholderColor}
154
149
  keyboardType={'numeric'}
155
150
  maxLength={undefined}
156
151
  />
157
- {shouldShowCurrency && (
152
+ {hasValue && (
158
153
  <Text
159
- style={[
160
- textStyle,
161
- { color: displayValue ? textColor : placeholderColor },
162
- ]}
154
+ style={[textStyle, { color: textColor }]}
163
155
  allowFontScaling={false}
164
156
  >
165
157
  {currency}
@@ -9,10 +9,10 @@ import React, {
9
9
  } from 'react';
10
10
  import {
11
11
  PixelRatio,
12
- TextInput,
13
12
  TextInputFocusEvent,
14
13
  TouchableOpacity,
15
14
  View,
15
+ type TextInputInstance,
16
16
  } from 'react-native';
17
17
  import Animated, {
18
18
  cancelAnimation,
@@ -116,7 +116,7 @@ const InputOTP = forwardRef(
116
116
  ) => {
117
117
  const [value, setValue] = useState('');
118
118
  const [isFocused, setIsFocused] = useState(false);
119
- const inputRef = useRef<TextInput | null>(null);
119
+ const inputRef = useRef<TextInputInstance | null>(null);
120
120
  const { theme } = useContext(ApplicationContext);
121
121
  const context = useContext<any>(MiniAppContext);
122
122
 
@@ -6,10 +6,10 @@ import React, {
6
6
  useState,
7
7
  } from 'react';
8
8
  import {
9
- TextInput,
10
9
  TextInputFocusEvent,
11
10
  TouchableOpacity,
12
11
  View,
12
+ type TextInputInstance,
13
13
  } from 'react-native';
14
14
  import { useComponentId } from '../Application';
15
15
  import {
@@ -79,7 +79,7 @@ const InputPhoneNumber = forwardRef(
79
79
  const [isFocused, setIsFocused] = useState(false);
80
80
  const [internalText, setInternalText] = useState(defaultValue || '');
81
81
  const hasValue = value !== undefined ? !!value : !!internalText;
82
- const inputRef = useRef<TextInput | null>(null);
82
+ const inputRef = useRef<TextInputInstance | null>(null);
83
83
  const componentName = 'InputPhoneNumber';
84
84
 
85
85
  const showBaseLineDebug = context?.features?.showBaseLineDebug ?? false;
@@ -7,10 +7,10 @@ import React, {
7
7
  useState,
8
8
  } from 'react';
9
9
  import {
10
- TextInput,
11
10
  TextInputFocusEvent,
12
11
  TouchableOpacity,
13
12
  View,
13
+ type TextInputInstance,
14
14
  } from 'react-native';
15
15
  import { useComponentId } from '../Application';
16
16
  import { HeaderBarMetrics } from '../Application/headerLayout';
@@ -76,7 +76,7 @@ const InputSearch: ForwardRefRenderFunction<InputRef, InputSearchProps> = (
76
76
  const [internalText, setInternalText] = useState(defaultValue || '');
77
77
  const currentValue = value !== undefined ? value : internalText;
78
78
  const hasValue = !!currentValue;
79
- const inputRef = useRef<TextInput | null>(null);
79
+ const inputRef = useRef<TextInputInstance | null>(null);
80
80
 
81
81
  const componentName = 'InputSearch';
82
82
 
@@ -7,10 +7,10 @@ import React, {
7
7
  useState,
8
8
  } from 'react';
9
9
  import {
10
- TextInput,
11
10
  TextInputFocusEvent,
12
11
  TouchableOpacity,
13
12
  View,
13
+ type TextInputInstance,
14
14
  } from 'react-native';
15
15
  import { setAutomationID, useComponentId } from '../Application';
16
16
  import { ApplicationContext, MiniAppContext } from '../Context';
@@ -70,7 +70,7 @@ const InputTextArea = forwardRef(
70
70
  const inputFontFamily = exportFontFamily('regular');
71
71
  const [isFocused, setIsFocused] = useState(false);
72
72
  const [inputValue, setInputValue] = useState(defaultValue ?? '');
73
- const inputRef = useRef<TextInput | null>(null);
73
+ const inputRef = useRef<TextInputInstance | null>(null);
74
74
 
75
75
  useEffect(() => {
76
76
  setInputValue(value ?? '');
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import React, { FC, useEffect, useRef } from 'react';
3
- import { TextInput } from 'react-native';
3
+ import { TextInput, type TextInputInstance } from 'react-native';
4
4
  import { useScaleSize, exportFontFamily } from '../Text';
5
5
  import styles from './styles';
6
6
 
@@ -13,7 +13,7 @@ export const TextTyping: FC<any> = ({
13
13
  timeDelayEnd = 2000,
14
14
  timeDelayNextChar = 20,
15
15
  }) => {
16
- const textRef = useRef<TextInput>(null);
16
+ const textRef = useRef<TextInputInstance>(null);
17
17
  const scaledFontSize = useScaleSize(12);
18
18
  const typingFontFamily = exportFontFamily('regular');
19
19
 
@@ -4,11 +4,12 @@ import {
4
4
  TextInput,
5
5
  TextInputProps,
6
6
  TouchableOpacity,
7
+ type TextInputInstance,
7
8
  } from 'react-native';
8
9
  import { Styles } from '../Consts';
9
10
 
10
11
  interface SystemTextInputProps extends TextInputProps {
11
- ref?: React.RefObject<TextInput | null>;
12
+ ref?: React.RefObject<TextInputInstance | null>;
12
13
  }
13
14
 
14
15
  /**
@@ -1,6 +1,11 @@
1
1
  /* eslint-disable react-hooks/exhaustive-deps */
2
2
  import React, { FC, memo, useEffect, useRef } from 'react';
3
- import { Platform, TextInput, TextStyle } from 'react-native';
3
+ import {
4
+ Platform,
5
+ TextInput,
6
+ TextStyle,
7
+ type TextInputInstance,
8
+ } from 'react-native';
4
9
  import { Colors } from '../Consts';
5
10
  import { useScaleSize, exportFontFamily } from '../Text';
6
11
 
@@ -21,7 +26,7 @@ const TextTyping: FC<TextTypingProps> = ({
21
26
  timeDelayNextChar = 20,
22
27
  inputStyle = {},
23
28
  }) => {
24
- const textRef = useRef<TextInput>(null);
29
+ const textRef = useRef<TextInputInstance>(null);
25
30
  const scaledFontSize = useScaleSize(12);
26
31
  const inputFontFamily = exportFontFamily('regular');
27
32
 
package/Input/index.tsx CHANGED
@@ -364,7 +364,8 @@ export interface InputPhoneNumberProps extends InputProps {
364
364
 
365
365
  /**
366
366
  * Optional. Called when the flag or dial code is pressed (e.g. to pick a country),
367
- * which then reads as a button. Ignored while `disabled` or `editable={false}`.
367
+ * which then reads as a button with a chevron after the code. Ignored while
368
+ * `disabled` or `editable={false}`.
368
369
  */
369
370
  onPressLeadingIcon?: () => void;
370
371
  }
package/Layout/Screen.tsx CHANGED
@@ -28,14 +28,11 @@ import { useScreenLayout } from './utils';
28
28
  import { HeaderExtendHeader } from '../Application';
29
29
  import { DuoScrollGradient } from '../Application/Components/DuoGlassBackground';
30
30
  import { BottomTabInsetContext } from '../Application/BottomTab/BottomTabInset';
31
- import { ScreenProps } from './screenTypes';
31
+ import { useHeaderLayout } from '../Application/headerLayout';
32
+ import { ANIMATED_BANNER_HEIGHT, ScreenProps } from './screenTypes';
32
33
  import { renderAnimatedHeader, renderContent } from './screenContent';
33
34
  import { createScrollHandlers } from './screenScroll';
34
- import {
35
- renderFooterSpacer,
36
- ScreenFooter,
37
- useFooterLayout,
38
- } from './screenFooter';
35
+ import { ScreenFooter } from './screenFooter';
39
36
  import { useScreenHeader } from './screenHeader';
40
37
  import { useScreenQuickReturn } from './screenQuickReturn';
41
38
 
@@ -57,9 +54,6 @@ const Screen = forwardRef(
57
54
  headerComponent: Header,
58
55
  footerComponent: Footer,
59
56
  marginFooter = true,
60
- footerStyle,
61
- footerSeparator,
62
- footerHasImageBackground: hasImageFooter,
63
57
  layoutOffset = -56,
64
58
  headerRightWidth,
65
59
  backgroundColor,
@@ -85,7 +79,9 @@ const Screen = forwardRef(
85
79
  const insets = useSafeAreaInsets();
86
80
  const frame = useSafeAreaFrame();
87
81
  const heightHeader = useHeaderHeight();
88
- const footerLayout = useFooterLayout(layout, footerStyle, hasImageFooter);
82
+ const { bannerScale } = useHeaderLayout(contentLayout);
83
+ // the banner grows with its image on wide windows, the content keeps its overlap
84
+ const bannerBottom = ANIMATED_BANNER_HEIGHT * bannerScale + layoutOffset;
89
85
 
90
86
  const animatedValue = useRef<Animated.Value>(
91
87
  customAnimatedValue ?? new Animated.Value(0),
@@ -152,7 +148,7 @@ const Screen = forwardRef(
152
148
  useShadowHeader,
153
149
  gradientColor,
154
150
  headerBackground,
155
- layoutOffset,
151
+ bannerBottom,
156
152
  contentLayout,
157
153
  });
158
154
 
@@ -203,7 +199,7 @@ const Screen = forwardRef(
203
199
 
204
200
  let floatingButtonBottom = bottomInset + Spacing.S;
205
201
  if (Footer) {
206
- floatingButtonBottom = 12 + footerLayout.overlap;
202
+ floatingButtonBottom = 12;
207
203
  } else if (isTab) {
208
204
  floatingButtonBottom = 12 + duoTabInset;
209
205
  }
@@ -287,13 +283,12 @@ const Screen = forwardRef(
287
283
  >
288
284
  {renderAnimatedHeader(
289
285
  animatedHeader,
290
- layoutOffset,
286
+ bannerBottom,
291
287
  animatedValue.current,
292
288
  sharedValue,
293
289
  )}
294
290
 
295
291
  {useGridLayout ? renderContent(children, layout) : children}
296
- {renderFooterSpacer(footerLayout.overlap)}
297
292
  </Component>
298
293
 
299
294
  {floatingButtonProps && (
@@ -315,11 +310,13 @@ const Screen = forwardRef(
315
310
  <ScreenFooter
316
311
  footer={Footer}
317
312
  marginFooter={marginFooter}
318
- layout={footerLayout}
319
- separator={footerSeparator}
313
+ insetLeft={layout.insetLeft}
314
+ insetRight={layout.insetRight}
315
+ hasContentInset={hasContentInset}
320
316
  isTab={isTab}
321
317
  duoTabInset={duoTabInset}
322
318
  bottomInset={bottomInset}
319
+ surfaceColor={theme.colors.background.surface}
323
320
  />
324
321
  )}
325
322
  </KeyboardAvoidingView>
@@ -24,22 +24,16 @@ export interface SectionProps extends ViewProps {
24
24
  * Optional. Background image for the Section component.
25
25
  */
26
26
  backgroundImage?: string;
27
-
28
- /**
29
- * Optional. Caps the row width, side margins excluded; a capped row is centered.
30
- */
31
- maxWidth?: number;
32
27
  }
33
28
 
34
29
  /**
35
- * Content-wide grid row (12 or 24 columns) with optional side margins, capped by
36
- * `maxWidth`; child Items size themselves from its GridContext.
30
+ * Content-wide grid row (12 or 24 columns) with optional side margins; child Items size
31
+ * themselves from its GridContext.
37
32
  */
38
33
  const Section: React.FC<SectionProps> = ({
39
34
  children,
40
35
  useMargin = true,
41
36
  backgroundImage,
42
- maxWidth,
43
37
  style,
44
38
  ...props
45
39
  }) => {
@@ -51,11 +45,7 @@ const Section: React.FC<SectionProps> = ({
51
45
  if (useMargin) {
52
46
  margin = 12;
53
47
  }
54
- const isCapped = maxWidth !== undefined;
55
- let widthSection = contentWidth - margin * 2;
56
- if (isCapped) {
57
- widthSection = Math.min(widthSection, maxWidth);
58
- }
48
+ const widthSection = contentWidth - margin * 2;
59
49
 
60
50
  const columnsWidth = widthSection - gutterSize * (numberOfColumns - 1);
61
51
  const sizePerSpan = columnsWidth / numberOfColumns - 1 / numberOfColumns;
@@ -78,7 +68,6 @@ const Section: React.FC<SectionProps> = ({
78
68
  style,
79
69
  styles.protectedStyle,
80
70
  styles.rowWrap,
81
- isCapped && styles.centered,
82
71
  {
83
72
  width: widthSection,
84
73
  marginHorizontal: margin,
@@ -1,7 +1,7 @@
1
1
  /** Header geometry. */
2
2
  export const HeaderMetrics = {
3
- /** Navigation bar row below the status bar. */
4
- barHeight: 52,
3
+ /** Navigation bar row below the status bar; a search row is taller (searchBarHeight). */
4
+ barHeight: 48,
5
5
  /** Header never shorter than this on iPhone (landscape, iPhone Duo). */
6
6
  iPhoneMinHeight: 72,
7
7
  /** A smaller top inset means the status bar is not on the top edge. */
@@ -3,7 +3,6 @@ import { Animated, View } from 'react-native';
3
3
  import { Spacing } from '../Consts';
4
4
  import styles from './styles';
5
5
  import { validateChildren } from './utils';
6
- import { ANIMATED_BANNER_HEIGHT } from './screenTypes';
7
6
  import { AnimatedHeader } from '../Application/types';
8
7
 
9
8
  type ContentInset = { insetLeft: number; insetRight: number };
@@ -65,23 +64,18 @@ export const renderContent = (content: any, layout: ContentInset): any => {
65
64
  };
66
65
 
67
66
  /**
68
- * Animated banner from `animatedHeader.component`, clipped to the banner height plus
69
- * `layoutOffset`. Nothing without a component.
67
+ * Animated banner from `animatedHeader.component`, clipped at `bannerBottom` (banner
68
+ * height plus `layoutOffset`). Nothing without a component.
70
69
  */
71
70
  export const renderAnimatedHeader = (
72
71
  animatedHeader: AnimatedHeader | undefined,
73
- layoutOffset: number,
72
+ bannerBottom: number,
74
73
  animatedValue: Animated.Value,
75
74
  sharedValue: any,
76
75
  ) => {
77
76
  if (typeof animatedHeader?.component === 'function') {
78
77
  return (
79
- <View
80
- style={[
81
- styles.screenBanner,
82
- { maxHeight: ANIMATED_BANNER_HEIGHT + layoutOffset },
83
- ]}
84
- >
78
+ <View style={[styles.screenBanner, { maxHeight: bannerBottom }]}>
85
79
  {animatedHeader?.component({
86
80
  animatedValue,
87
81
  sharedValue,