Skip to content
Merged
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
1 change: 1 addition & 0 deletions src/CONST/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,7 @@ const CONST = {
ASCII_CAPABLE: 'ascii-capable',
NUMBER_PAD: 'number-pad',
DECIMAL_PAD: 'decimal-pad',
NUMBERS_AND_PUNCTUATION: 'numbers-and-punctuation',
},

INPUT_MODE: {
Expand Down
7 changes: 5 additions & 2 deletions src/components/AmountWithoutCurrencyInput.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import React, {useCallback, useMemo} from 'react';
import type {ForwardedRef} from 'react';
import useLocalize from '@hooks/useLocalize';
import getAmountInputKeyboard from '@libs/getAmountInputKeyboard';
import {replaceAllDigits, replaceCommasWithPeriod, stripSpacesFromAmount} from '@libs/MoneyRequestUtils';
import CONST from '@src/CONST';
import TextInput from './TextInput';
import type {BaseTextInputProps, BaseTextInputRef} from './TextInput/BaseTextInput/types';

Expand Down Expand Up @@ -57,6 +57,8 @@ function AmountWithoutCurrencyInput(
},
];

const {keyboardType, inputMode} = getAmountInputKeyboard(shouldAllowNegative);

return (
<TextInput
inputID={inputID}
Expand All @@ -67,7 +69,8 @@ function AmountWithoutCurrencyInput(
accessibilityLabel={accessibilityLabel}
role={role}
ref={ref}
keyboardType={!shouldAllowNegative ? CONST.KEYBOARD_TYPE.DECIMAL_PAD : undefined}
keyboardType={keyboardType}
inputMode={inputMode}
type="mask"
mask={shouldAllowNegative ? `[~][99999999]${separator}[09]` : `[09999999]${separator}[09]`}
customNotations={customMask}
Expand Down
11 changes: 11 additions & 0 deletions src/libs/getAmountInputKeyboard/index.android.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CONST from '@src/CONST';
import type GetAmountInputKeyboard from './type';

const getAmountInputKeyboard: GetAmountInputKeyboard = () => {
return {
keyboardType: CONST.KEYBOARD_TYPE.DECIMAL_PAD,
inputMode: CONST.INPUT_MODE.DECIMAL,
};
};

export default getAmountInputKeyboard;
11 changes: 11 additions & 0 deletions src/libs/getAmountInputKeyboard/index.desktop.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CONST from '@src/CONST';
import type GetAmountInputKeyboard from './type';

const getAmountInputKeyboard: GetAmountInputKeyboard = () => {
return {
keyboardType: CONST.KEYBOARD_TYPE.DECIMAL_PAD,
inputMode: CONST.INPUT_MODE.DECIMAL,
};
};

export default getAmountInputKeyboard;
11 changes: 11 additions & 0 deletions src/libs/getAmountInputKeyboard/index.ios.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import CONST from '@src/CONST';
import type GetAmountInputKeyboard from './type';

const getAmountInputKeyboard: GetAmountInputKeyboard = (shouldAllowNegative = false) => {
return {
keyboardType: shouldAllowNegative ? CONST.KEYBOARD_TYPE.NUMBERS_AND_PUNCTUATION : CONST.KEYBOARD_TYPE.DECIMAL_PAD,
inputMode: shouldAllowNegative ? undefined : CONST.INPUT_MODE.DECIMAL,
};
};

export default getAmountInputKeyboard;
12 changes: 12 additions & 0 deletions src/libs/getAmountInputKeyboard/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {isMobileIOS} from '@libs/Browser';
import CONST from '@src/CONST';
import type GetAmountInputKeyboard from './type';

const getAmountInputKeyboard: GetAmountInputKeyboard = (shouldAllowNegative = false) => {
return {
keyboardType: isMobileIOS() && shouldAllowNegative ? CONST.KEYBOARD_TYPE.NUMBERS_AND_PUNCTUATION : CONST.KEYBOARD_TYPE.DECIMAL_PAD,
inputMode: isMobileIOS() && shouldAllowNegative ? undefined : CONST.INPUT_MODE.DECIMAL,
};
};

export default getAmountInputKeyboard;
9 changes: 9 additions & 0 deletions src/libs/getAmountInputKeyboard/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type {ValueOf} from 'type-fest';
import type CONST from '@src/CONST';

type GetAmountInputKeyboard = (shouldAllowNegative?: boolean) => {
keyboardType: ValueOf<typeof CONST.KEYBOARD_TYPE> | undefined;
inputMode: ValueOf<typeof CONST.INPUT_MODE> | undefined;
};

export default GetAmountInputKeyboard;
Loading