Skip to content

Commit

Permalink
feat(synapse-interface): numerical input format (#3101)
Browse files Browse the repository at this point in the history
* numerical input formatter

* Adds inputMode numeric to auto popup numeric keypad on mobile

---------

Co-authored-by: abtestingalpha <[email protected]>
  • Loading branch information
bigboydiamonds and abtestingalpha authored Sep 6, 2024
1 parent 79d980c commit 98c9194
Show file tree
Hide file tree
Showing 3 changed files with 696 additions and 21 deletions.
22 changes: 13 additions & 9 deletions packages/synapse-interface/components/ui/AmountInput.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import React, { useState, useEffect, useCallback } from 'react'
import { debounce } from 'lodash'
import LoadingDots from './tailwind/LoadingDots'
import React, { useCallback } from 'react'
import { NumericFormat } from 'react-number-format'
import { joinClassNames } from '@/utils/joinClassNames'
import LoadingDots from './tailwind/LoadingDots'

interface AmountInputTypes {
inputRef?: React.RefObject<HTMLInputElement>
Expand Down Expand Up @@ -44,19 +45,22 @@ export function AmountInput({
{isLoading ? (
<LoadingDots className="opacity-50" />
) : (
<input
ref={inputRef}
pattern={disabled ? '[0-9.]+' : '^[0-9]*[.,]?[0-9]*$'}
<NumericFormat
inputMode="numeric"
getInputRef={inputRef}
placeholder="0.0000"
value={showValue}
pattern={disabled ? '[0-9.]+' : '^[0-9]+([.,]?[0-9]+)?$'}
disabled={disabled}
readOnly={disabled}
className={joinClassNames(inputClassNames)}
placeholder="0.0000"
onChange={handleInputChange}
value={showValue}
className={joinClassNames(inputClassNames)}
name="inputRow"
autoComplete="off"
minLength={1}
maxLength={79}
autoComplete="off"
thousandSeparator={true}
allowNegative={false}
/>
)}
</>
Expand Down
1 change: 1 addition & 0 deletions packages/synapse-interface/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@
"react-ga": "^3.3.1",
"react-hot-toast": "^2.4.0",
"react-input-slider": "^6.0.1",
"react-number-format": "^5.4.1",
"react-redux": "^8.1.0",
"redux-persist": "^6.0.0",
"swr": "1.3.0",
Expand Down
Loading

0 comments on commit 98c9194

Please sign in to comment.