-
-
Notifications
You must be signed in to change notification settings - Fork 112
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
feat: add percent input component #2473
feat: add percent input component #2473
Conversation
Features
Bug Fixes
Contributorsyvmunayev, LeandroTorresSicilia Commit-Lint commandsYou can trigger Commit-Lint actions by commenting on this PR:
|
@@ -1,6 +1,10 @@ | |||
import { useMemo } from 'react'; | |||
import { getSeparator } from '../helpers'; | |||
|
|||
export default function useDecimalSeparator(locale, options) { | |||
return useMemo(() => getSeparator(locale, 'decimal', options), [locale, options]); | |||
export default function useDecimalSeparator({ locale, style, currency }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
@@ -1,6 +1,10 @@ | |||
import { useMemo } from 'react'; | |||
import { getSeparator } from '../helpers'; | |||
|
|||
export default function useGroupSeparator(locale, options) { | |||
return useMemo(() => getSeparator(locale, 'group', options), [locale, options]); | |||
export default function useGroupSeparator({ locale, style, currency }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
import formatPercent from './helpers/formatPercent'; | ||
import { normalizeValue } from './helpers'; | ||
|
||
const PercentInput = forwardRef((props, ref) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PercentInput
has 150 lines of code (exceeds 25 allowed). Consider refactoring.
import { normalizeValue } from './helpers'; | ||
|
||
const PercentInput = forwardRef((props, ref) => { | ||
const { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 3 locations. Consider refactoring.
|
||
const isReadOnly = !!(!disabled && readOnly); | ||
|
||
useImperativeHandle(ref, () => ({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 16 locations. Consider refactoring.
Visit the preview URL for this PR (updated for commit 763a19a): https://react-rainbow--pr2473-feat-add-percent-inp-cb3ietsi.web.app (expires Wed, 19 Oct 2022 04:04:13 GMT) 🔥 via Firebase Hosting GitHub Action 🌎 |
onFocus(event); | ||
}; | ||
|
||
return ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar blocks of code found in 2 locations. Consider refactoring.
inputRef.current.setSelectionRange(cursor, cursor); | ||
}, [cursor]); | ||
|
||
const handleChange = event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Identical blocks of code found in 2 locations. Consider refactoring.
inputRef.current.setSelectionRange(cursor, cursor); | ||
}, [cursor]); | ||
|
||
const handleChange = event => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function handleChange
has 29 lines of code (exceeds 25 allowed). Consider refactoring.
import formatPercent from './helpers/formatPercent'; | ||
import { normalizeValue } from './helpers'; | ||
|
||
const PercentInput = forwardRef((props, ref) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function PercentInput
has a Cognitive Complexity of 11 (exceeds 5 allowed). Consider refactoring.
@@ -0,0 +1,19 @@ | |||
import formatInteger from '../../CurrencyInput/helpers/formatInteger'; | |||
|
|||
export default function normalizeValue({ value, locale, decimalSeparator, options }) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function normalizeValue
has a Cognitive Complexity of 6 (exceeds 5 allowed). Consider refactoring.
Code Climate has analyzed commit 763a19a and detected 14 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
fix: #2472
Changes proposed in this PR:
feat: add percent input component
fix: using minimumIntegerDigits={5} write 23567 then remove numbers, the cursor move its position in an unexpected way
fix: improve doc, it mention things about number and percent formating
I have followed (at least) the PR section of the contributing guide.
@nexxtway/react-rainbow