REDROOM
PHP 8.2.30
Path:
Logout
Edit File
Size: 2.62 KB
Close
/home/byroehnu/easepaybiz.easetack.com/node_modules/react-currency-input-field/src/components/utils/cleanValue.ts
Text
Base64
import { parseAbbrValue } from './parseAbbrValue'; import { removeSeparators } from './removeSeparators'; import { removeInvalidChars } from './removeInvalidChars'; import { escapeRegExp } from './escapeRegExp'; import { CurrencyInputProps } from '../CurrencyInputProps'; export type CleanValueOptions = Pick< CurrencyInputProps, | 'decimalSeparator' | 'groupSeparator' | 'allowDecimals' | 'decimalsLimit' | 'allowNegativeValue' | 'disableAbbreviations' | 'prefix' | 'transformRawValue' > & { value: string }; /** * Remove prefix, separators and extra decimals from value */ export const cleanValue = ({ value, groupSeparator = ',', decimalSeparator = '.', allowDecimals = true, decimalsLimit = 2, allowNegativeValue = true, disableAbbreviations = false, prefix = '', transformRawValue = (rawValue) => rawValue, }: CleanValueOptions): string => { const transformedValue = transformRawValue(value); if (transformedValue === '-') { return transformedValue; } const abbreviations = disableAbbreviations ? [] : ['k', 'm', 'b']; const reg = new RegExp(`((^|\\D)-\\d)|(-${escapeRegExp(prefix)})`); const isNegative = reg.test(transformedValue); // Is there a digit before the prefix? eg. 1$ const [prefixWithValue, preValue] = RegExp(`(\\d+)-?${escapeRegExp(prefix)}`).exec(value) || []; const withoutPrefix = prefix ? prefixWithValue ? transformedValue.replace(prefixWithValue, '').concat(preValue) : transformedValue.replace(prefix, '') : transformedValue; const withoutSeparators = removeSeparators(withoutPrefix, groupSeparator); const withoutInvalidChars = removeInvalidChars(withoutSeparators, [ groupSeparator, decimalSeparator, ...abbreviations, ]); let valueOnly = withoutInvalidChars; if (!disableAbbreviations) { // disallow letter without number if ( abbreviations.some( (letter) => letter === withoutInvalidChars.toLowerCase().replace(decimalSeparator, '') ) ) { return ''; } const parsed = parseAbbrValue(withoutInvalidChars, decimalSeparator); if (parsed) { valueOnly = String(parsed); } } const includeNegative = isNegative && allowNegativeValue ? '-' : ''; if (decimalSeparator && valueOnly.includes(decimalSeparator)) { const [int, decimals] = withoutInvalidChars.split(decimalSeparator); const trimmedDecimals = decimalsLimit && decimals ? decimals.slice(0, decimalsLimit) : decimals; const includeDecimals = allowDecimals ? `${decimalSeparator}${trimmedDecimals}` : ''; return `${includeNegative}${int}${includeDecimals}`; } return `${includeNegative}${valueOnly}`; };
Save
Close
Exit & Reset
Text mode: syntax highlighting auto-detects file type.
Directory Contents
Dirs: 1 × Files: 15
Delete Selected
Select All
Select None
Sort:
Name
Size
Modified
Enable drag-to-move
Name
Size
Perms
Modified
Actions
__tests__
DIR
-
drwxr-xr-x
2026-03-14 01:49:06
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
.htaccess
127 B
lr--r--r--
2026-03-14 01:49:06
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
addSeparators.ts
195 B
lrw-r--r--
2026-03-05 00:20:02
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
cleanValue.ts
2.62 KB
lrw-r--r--
2026-03-05 00:20:06
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
escapeRegExp.ts
295 B
lrw-r--r--
2026-03-05 00:20:10
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
fixedDecimalValue.ts
946 B
lrw-r--r--
2026-03-05 00:20:11
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
formatValue.ts
5.26 KB
lrw-r--r--
2026-03-05 00:20:12
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
getLocaleConfig.ts
1.25 KB
lrw-r--r--
2026-03-05 00:20:13
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
getSuffix.ts
475 B
lrw-r--r--
2026-03-05 00:20:13
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
index.ts
258 B
lrw-r--r--
2026-03-05 00:20:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
isNumber.ts
84 B
lrw-r--r--
2026-03-05 00:20:14
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
padTrimValue.ts
718 B
lrw-r--r--
2026-03-05 00:20:15
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
parseAbbrValue.ts
1.15 KB
lrw-r--r--
2026-03-05 00:20:15
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
removeInvalidChars.ts
320 B
lrw-r--r--
2026-03-05 00:20:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
removeSeparators.ts
280 B
lrw-r--r--
2026-03-05 00:20:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
repositionCursor.ts
1.41 KB
lrw-r--r--
2026-03-05 00:20:16
Edit
Download
Rename
Chmod
Change Date
Delete
OK
Cancel
recursive
OK
Cancel
recursive
OK
Cancel
Zip Selected
If ZipArchive is unavailable, a
.tar
will be created (no compression).