Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 0 additions & 72 deletions src/components/AmountWithoutCurrencyForm.tsx

This file was deleted.

8 changes: 6 additions & 2 deletions src/components/AmountWithoutCurrencyInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ function AmountWithoutCurrencyInput(
[onInputChange],
);

const positiveMask = [`[09999999]${separator}[09]`];
const positiveAndNegativeMask = [`[09999999]${separator}[09]`, `-[09999999]${separator}[09]`];

return (
<TextInput
inputID={inputID}
Expand All @@ -58,8 +61,9 @@ function AmountWithoutCurrencyInput(
keyboardType={!shouldAllowNegative ? CONST.KEYBOARD_TYPE.DECIMAL_PAD : undefined}
type="mask"
mask={`[09999999]${separator}[09]`}
allowedKeys="0123456789.,"
validationRegex={'^(?!.*[.,].*[.,])\\d{0,8}(?:[.,]\\d{0,2})?$'}
allowedKeys="0123456789.,-"
validationRegex={'^-?(?!.*[.,].*[.,])\\d{0,8}(?:[.,]\\d{0,2})?$'}
affinityFormat={shouldAllowNegative ? positiveAndNegativeMask : positiveMask}
// On android autoCapitalize="words" is necessary when keyboardType="decimal-pad" or inputMode="decimal" to prevent input lag.
// See https://github.com/Expensify/App/issues/51868 for more information
autoCapitalize="words"
Expand Down
3 changes: 3 additions & 0 deletions src/components/TextInput/BaseTextInput/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,9 @@ type CustomBaseTextInputProps = {
/** The mask of the masked input */
mask?: MaskedTextInputOwnProps['mask'];

/** The list of masks to be applied for the input */
affinityFormat?: MaskedTextInputOwnProps['affinityFormat'];

/** A set of permitted characters for the input */
allowedKeys?: MaskedTextInputOwnProps['allowedKeys'];

Expand Down
4 changes: 2 additions & 2 deletions src/pages/workspace/perDiem/EditPerDiemAmountPage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React, {useCallback} from 'react';
import {useOnyx} from 'react-native-onyx';
import AmountWithoutCurrencyForm from '@components/AmountWithoutCurrencyForm';
import FormProvider from '@components/Form/FormProvider';
import InputWrapper from '@components/Form/InputWrapper';
import type {FormInputErrors, FormOnyxValues} from '@components/Form/types';
Expand All @@ -22,6 +21,7 @@ import ROUTES from '@src/ROUTES';
import type SCREENS from '@src/SCREENS';
import INPUT_IDS from '@src/types/form/WorkspacePerDiemForm';
import {isEmptyObject} from '@src/types/utils/EmptyObject';
import AmountWithoutCurrencyInput from '@components/AmountWithoutCurrencyInput';

type EditPerDiemAmountPageProps = PlatformStackScreenProps<SettingsNavigatorParamList, typeof SCREENS.WORKSPACE.PER_DIEM_EDIT_AMOUNT>;

Expand Down Expand Up @@ -98,7 +98,7 @@ function EditPerDiemAmountPage({route}: EditPerDiemAmountPageProps) {
>
<InputWrapper
ref={inputCallbackRef}
InputComponent={AmountWithoutCurrencyForm}
InputComponent={AmountWithoutCurrencyInput}
defaultValue={defaultAmount}
label={translate('workspace.perDiem.amount')}
accessibilityLabel={translate('workspace.perDiem.amount')}
Expand Down