Skip to content

Commit d416d6c

Browse files
Merge pull request Expensify#65197 from dominictb/feat/64366
feat: create the NumberWithUnitForm
2 parents 0020ebc + 4d414a2 commit d416d6c

39 files changed

Lines changed: 876 additions & 784 deletions

.storybook/preview.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ import HTMLEngineProvider from '@src/components/HTMLEngineProvider';
1010
import {LocaleContextProvider} from '@src/components/LocaleContextProvider';
1111
import {EnvironmentProvider} from '@src/components/withEnvironment';
1212
import {KeyboardStateProvider} from '@src/components/withKeyboardState';
13+
import CONST from '@src/CONST';
14+
import IntlStore from '@src/languages/IntlStore';
1315
import ONYXKEYS from '@src/ONYXKEYS';
1416
import './fonts.css';
1517

@@ -20,6 +22,8 @@ Onyx.init({
2022
},
2123
});
2224

25+
IntlStore.load(CONST.LOCALES.EN);
26+
2327
const decorators = [
2428
(Story: React.ElementType) => (
2529
<ComposeProviders

src/CONST/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4991,6 +4991,10 @@ const CONST = {
49914991
FLAG_SEVERITY_ASSAULT: 'assault',
49924992
},
49934993
EMOJI_PICKER_TEXT_INPUT_SIZES: 152,
4994+
TEXT_INPUT_SYMBOL_POSITION: {
4995+
PREFIX: 'prefix',
4996+
SUFFIX: 'suffix',
4997+
},
49944998
QR: {
49954999
DEFAULT_LOGO_SIZE_RATIO: 0.25,
49965000
DEFAULT_LOGO_MARGIN_RATIO: 0.02,

src/components/AmountForm.tsx

Lines changed: 48 additions & 279 deletions
Large diffs are not rendered by default.

src/components/AmountPicker/AmountSelectorModal.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import {useFocusEffect} from '@react-navigation/native';
22
import React, {useCallback, useRef, useState} from 'react';
33
import {View} from 'react-native';
4-
import AmountForm from '@components/AmountForm';
54
import Button from '@components/Button';
65
import HeaderWithBackButton from '@components/HeaderWithBackButton';
76
import Modal from '@components/Modal';
7+
import NumberWithSymbolForm from '@components/NumberWithSymbolForm';
88
import ScreenWrapper from '@components/ScreenWrapper';
99
import ScrollView from '@components/ScrollView';
1010
import type {BaseTextInputRef} from '@components/TextInput/BaseTextInput/types';
@@ -65,7 +65,7 @@ function AmountSelectorModal({value, description = '', onValueSelected, isVisibl
6565
addBottomSafeAreaPadding
6666
>
6767
<View style={styles.flex1}>
68-
<AmountForm
68+
<NumberWithSymbolForm
6969
// eslint-disable-next-line react/jsx-props-no-spreading
7070
{...rest}
7171
value={currentValue}

src/components/AmountPicker/types.ts

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import type {AmountFormProps} from '@components/AmountForm';
21
import type {MenuItemBaseProps} from '@components/MenuItem';
2+
import type {NumberWithSymbolFormProps} from '@components/NumberWithSymbolForm';
33

44
type AmountSelectorModalProps = {
55
/** Whether the modal is visible */
@@ -13,7 +13,11 @@ type AmountSelectorModalProps = {
1313

1414
/** Function to call when the user closes the modal */
1515
onClose: () => void;
16-
} & Pick<MenuItemBaseProps, 'description'>;
16+
} & Pick<MenuItemBaseProps, 'description'> &
17+
Pick<
18+
NumberWithSymbolFormProps,
19+
'decimals' | 'maxLength' | 'symbol' | 'symbolPosition' | 'isSymbolPressable' | 'style' | 'containerStyle' | 'touchableInputWrapperStyle' | 'autoGrowExtraSpace' | 'autoGrowMarginSide'
20+
>;
1721

1822
type AmountPickerProps = {
1923
/** Item to display */
@@ -34,6 +38,9 @@ type AmountPickerProps = {
3438
/** Whether to show the tooltip text */
3539
shouldShowTooltips?: boolean;
3640
} & Pick<MenuItemBaseProps, 'rightLabel' | 'description'> &
37-
AmountFormProps;
41+
Pick<
42+
NumberWithSymbolFormProps,
43+
'decimals' | 'maxLength' | 'symbol' | 'symbolPosition' | 'isSymbolPressable' | 'style' | 'containerStyle' | 'touchableInputWrapperStyle' | 'autoGrowExtraSpace' | 'autoGrowMarginSide'
44+
>;
3845

3946
export type {AmountSelectorModalProps, AmountPickerProps};

src/components/Form/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import type CountrySelector from '@components/CountrySelector';
1212
import type CurrencySelector from '@components/CurrencySelector';
1313
import type DatePicker from '@components/DatePicker';
1414
import type EmojiPickerButtonDropdown from '@components/EmojiPicker/EmojiPickerButtonDropdown';
15+
import type NumberWithSymbolForm from '@components/NumberWithSymbolForm';
1516
import type PercentageForm from '@components/PercentageForm';
1617
import type Picker from '@components/Picker';
1718
import type PushRowWithModal from '@components/PushRowWithModal';
@@ -52,6 +53,7 @@ type ValidInputs =
5253
| typeof CountrySelector
5354
| typeof CurrencySelector
5455
| typeof AmountForm
56+
| typeof NumberWithSymbolForm
5557
| typeof PercentageForm
5658
| typeof BusinessTypePicker
5759
| typeof DimensionTypeSelector

0 commit comments

Comments
 (0)