Skip to content

Commit

Permalink
Upgraded react-number-format to 5.4.1 (#2462)
Browse files Browse the repository at this point in the history
  • Loading branch information
ChiaMineJP authored Aug 28, 2024
1 parent b2c5131 commit 59bcd47
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 29 deletions.
17 changes: 7 additions & 10 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,11 @@
"lodash": "4.17.21",
"match-sorter": "6.3.1",
"moment": "2.30.1",
"qs": "6.12.1",
"overlayscrollbars": "1.13.3",
"overlayscrollbars-react": "0.3.0",
"qs": "6.12.1",
"react-dropzone": "14.2.3",
"react-number-format": "4.9.1",
"react-number-format": "5.4.1",
"react-redux": "8.1.2",
"react-scroll-to-bottom": "4.2.0",
"react-teleporter": "3.1.0",
Expand Down
15 changes: 9 additions & 6 deletions packages/core/src/components/Amount/NumberFormatCustom.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React, { forwardRef } from 'react';
import NumberFormat from 'react-number-format';
import { NumericFormat, type OnValueChange } from 'react-number-format';

interface NumberFormatCustomProps {
onChange: (event: { target: { name: string; value: string } }) => void;
Expand All @@ -9,18 +9,21 @@ interface NumberFormatCustomProps {
function NumberFormatCustom(props: NumberFormatCustomProps, ref: any) {
const { onChange, ...other } = props;

function handleChange(values: any) {
onChange(values.value);
}
const handleChange: OnValueChange = React.useCallback(
(values) => {
onChange(values.value);
},
[onChange],
);

return (
<NumberFormat
<NumericFormat
{...other}
getInputRef={ref}
onValueChange={handleChange}
thousandSeparator
allowNegative={false}
isNumericString
valueIsNumericString
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,27 +1,30 @@
import React, { forwardRef } from 'react';
import NumberFormat from 'react-number-format';
import { NumericFormat, type OnValueChange } from 'react-number-format';

interface NumberFormatCustomProps {
inputRef: (instance: NumberFormat | null) => void;
inputRef: (instance: typeof NumericFormat | null) => void;
onChange: (event: { target: { name: string; value: string } }) => void;
name: string;
}

function NumberFormatCustom(props: NumberFormatCustomProps) {
const { inputRef, onChange, ...other } = props;

function handleChange(values: Object) {
onChange(values.value);
}
const handleChange: OnValueChange = React.useCallback(
(values) => {
onChange(values.value);
},
[onChange],
);

return (
<NumberFormat
<NumericFormat
{...other}
getInputRef={inputRef}
onValueChange={handleChange}
thousandSeparator
allowNegative={false}
isNumericString
valueIsNumericString
/>
);
}
Expand Down
2 changes: 1 addition & 1 deletion packages/gui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
"react-dropzone": "14.2.3",
"react-hook-form": "7.45.4",
"react-hotkeys-hook": "4.5.0",
"react-number-format": "4.9.1",
"react-number-format": "5.4.1",
"react-redux": "8.1.2",
"react-router": "6.15.0",
"react-router-dom": "6.15.0",
Expand Down
6 changes: 3 additions & 3 deletions packages/gui/src/components/offers/OfferExchangeRate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@ import { Flex } from '@chia-network/core';
import { ImportExport } from '@mui/icons-material';
import { InputAdornment, TextField, Typography } from '@mui/material';
import React, { useMemo, useState } from 'react';
import NumberFormat from 'react-number-format';
import { NumericFormat } from 'react-number-format';

import { AssetIdMapEntry } from '../../hooks/useAssetIdName';

interface OfferExchangeRateNumberFormatProps {
inputRef: (instance: NumberFormat | null) => void;
inputRef: (instance: typeof NumericFormat | null) => void;
name: string;
}

function OfferExchangeRateNumberFormat(props: OfferExchangeRateNumberFormatProps) {
const { inputRef, ...other } = props;

return <NumberFormat {...other} getInputRef={inputRef} allowNegative={false} isNumericString />;
return <NumericFormat {...other} getInputRef={inputRef} allowNegative={false} valueIsNumericString />;
}

type Props = {
Expand Down

0 comments on commit 59bcd47

Please sign in to comment.