// Copyright 2017-2026 @pezkuwi/react-params authors & contributors // SPDX-License-Identifier: Apache-2.0 import type { Props } from '../types.js'; import React, { useCallback, useState } from 'react'; // circular dep :( import InputBalance from '@pezkuwi/react-components/InputBalance'; import { BN } from '@pezkuwi/util'; import Bare from './Bare.js'; function Balance ({ className = '', defaultValue: { value }, isDisabled, isError, label, onChange, onEnter, onEscape, withLabel }: Props): React.ReactElement { const [isValid, setIsValid] = useState(false); const [defaultValue] = useState(() => new BN((value as BN || '0').toString()).toString(10)); const _onChange = useCallback( (value?: BN): void => { const isValid = !isError && !!value; onChange && onChange({ isValid, value }); setIsValid(isValid); }, [isError, onChange] ); return ( ); } export default React.memo(Balance); export { Balance };