Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade to react-number-format v5 #1781

Merged
merged 2 commits into from
Oct 4, 2022
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
5 changes: 5 additions & 0 deletions .changeset/young-grapes-work.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@sumup/circuit-ui': major
---

Upgraded to `react-number-format` version 5. This could be a breaking change if you were relying on internal `react-number-format` props. Refer to the `react-number-format` [migration guide](https://s-yadav.github.io/react-number-format/docs/migration/) for details. Any explicit typings will also need to be updated.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import { ChangeEvent, createRef, useState } from 'react';
import NumberFormat from 'react-number-format';
import { NumericFormatProps } from 'react-number-format';

import {
create,
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('CurrencyInput', () => {
* Should accept a working ref
*/
it('should accept a working ref', () => {
const tref = createRef<NumberFormat<InputProps>>();
const tref = createRef<NumericFormatProps<InputProps>>();
const { container } = render(
<CurrencyInput
locale="de-DE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

import { Ref, forwardRef } from 'react';
import { resolveCurrencyFormat } from '@sumup/intl';
import NumberFormat from 'react-number-format';
import { NumericFormat, NumericFormatProps } from 'react-number-format';

import styled from '../../styles/styled';
import Input from '../Input';
Expand Down Expand Up @@ -47,7 +47,7 @@ export interface CurrencyInputProps
/**
* The ref to the HTML DOM element.
*/
ref?: Ref<NumberFormat<InputProps>>;
ref?: Ref<NumericFormatProps<InputProps>>;
/**
* The value of the input element.
*/
Expand Down Expand Up @@ -118,8 +118,8 @@ export const CurrencyInput = forwardRef(
: undefined;

return (
<NumberFormat
// NumberFormat props
<NumericFormat
// react-number-format props
thousandSeparator={groupDelimiter}
decimalSeparator={
maximumFractionDigits > 0 ? decimalDelimiter : DUMMY_DELIMITER
Expand Down
6 changes: 3 additions & 3 deletions packages/circuit-ui/components/DateInput/DateInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/

import { forwardRef, useState, useEffect } from 'react';
import NumberFormat from 'react-number-format';
import { PatternFormat } from 'react-number-format';

import styled from '../../styles/styled';
import { Input, InputProps } from '../Input/Input';
Expand Down Expand Up @@ -65,8 +65,8 @@ export const DateInput = forwardRef(
// TODO: Fallback explainer, with enforced format
if (!supportsDate) {
return (
<NumberFormat
// NumberFormat props
<PatternFormat
// react-number-format props
placeholder={placeholder}
format="####-##-##"
mask={['y', 'y', 'y', 'y', 'm', 'm', 'd', 'd']}
Expand Down
2 changes: 1 addition & 1 deletion packages/circuit-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
"prop-types": "^15.7.2",
"react-dates": "^21.2.0",
"react-modal": "^3.15.1",
"react-number-format": "^4.9.4",
"react-number-format": "^5.0.1",
"use-latest": "^1.2.1",
"use-previous": "^1.1.0",
"yargs": "^17.4.1"
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -15274,10 +15274,10 @@ react-moment-proptypes@^1.6.0:
dependencies:
moment ">=1.6.0"

react-number-format@^4.9.4:
version "4.9.4"
resolved "https://registry.yarnpkg.com/react-number-format/-/react-number-format-4.9.4.tgz#013ae526000e676e491763ce14da66fb330a9bd8"
integrity sha512-Gq20Z3ugqPLFgeaidnx5on9cNpbQZntPN3QgNAL/WJrNNlQnNznY0LCx7g8xtssmRBw0/hw+SCqw6zAcajooiA==
react-number-format@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/react-number-format/-/react-number-format-5.0.1.tgz#23a3a693c978c7be328fa9c00dee5135111ca32b"
integrity sha512-Tyv5Ygb77ZbC5vUNNAfXwE+zQKaN0LsTo7GwjudU/MckXa7beVAlFddq7QQnGobEglyq+4zsBltKvM9HMQD0GA==
dependencies:
prop-types "^15.7.2"

Expand Down