mirror of
https://github.com/pezkuwichain/pezkuwi-apps.git
synced 2026-11-28 08:29:55 +00:00
feat: initial Pezkuwi Apps rebrand from polkadot-apps
Rebranded terminology: - Polkadot → Pezkuwi - Kusama → Dicle - Westend → Zagros - Rococo → PezkuwiChain - Substrate → Bizinikiwi - parachain → teyrchain Custom logos with Kurdistan brand colors (#e6007a → #86e62a): - bizinikiwi-hexagon.svg - sora-bizinikiwi.svg - hezscanner.svg - heztreasury.svg - pezkuwiscan.svg - pezkuwistats.svg - pezkuwiassembly.svg - pezkuwiholic.svg
This commit is contained in:
commit
d21bfb1320
5867 files changed
+329019
No files matched your search
@@ -0,0 +1,86 @@
|
||||
// Copyright 2017-2025 @pezkuwi/react-params authors & contributors
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import type { BitLength } from '@pezkuwi/react-components/types';
|
||||
import type { Registry, TypeDef } from '@pezkuwi/types/types';
|
||||
import type { BN } from '@pezkuwi/util';
|
||||
import type { Props } from '../types.js';
|
||||
|
||||
import React, { useCallback, useMemo } from 'react';
|
||||
|
||||
import { Input, InputNumber } from '@pezkuwi/react-components';
|
||||
import { bnToBn, formatNumber, isUndefined } from '@pezkuwi/util';
|
||||
|
||||
import Bare from './Bare.js';
|
||||
|
||||
function getBitLength (registry: Registry, { type }: TypeDef): BitLength {
|
||||
try {
|
||||
return registry.createType(type as 'u32').bitLength() as BitLength;
|
||||
} catch {
|
||||
return 32;
|
||||
}
|
||||
}
|
||||
|
||||
function Amount ({ className = '', defaultValue: { value }, isDisabled, isError, label, onChange, onEnter, registry, type, withLabel }: Props): React.ReactElement<Props> {
|
||||
const isSigned = useMemo(
|
||||
// Allow signed inputs for i{8, 16, 32, 64, 128, ...} types
|
||||
() => /^i\d*$/.test(type.type),
|
||||
[type]
|
||||
);
|
||||
|
||||
const defaultValue = useMemo(
|
||||
() => isDisabled
|
||||
? value instanceof registry.createClass('AccountIndex')
|
||||
? value.toString()
|
||||
: formatNumber(value as number)
|
||||
: bnToBn((value as number) || 0).toString(),
|
||||
[isDisabled, registry, value]
|
||||
);
|
||||
|
||||
const bitLength = useMemo(
|
||||
() => getBitLength(registry, type),
|
||||
[registry, type]
|
||||
);
|
||||
|
||||
const _onChange = useCallback(
|
||||
(value?: BN) =>
|
||||
onChange && onChange({
|
||||
isValid: !isUndefined(value),
|
||||
value
|
||||
}),
|
||||
[onChange]
|
||||
);
|
||||
|
||||
return (
|
||||
<Bare className={className}>
|
||||
{isDisabled
|
||||
? (
|
||||
<Input
|
||||
className='full'
|
||||
defaultValue={defaultValue}
|
||||
isDisabled
|
||||
label={label}
|
||||
withEllipsis
|
||||
withLabel={withLabel}
|
||||
/>
|
||||
)
|
||||
: (
|
||||
<InputNumber
|
||||
bitLength={bitLength}
|
||||
className='full'
|
||||
defaultValue={defaultValue}
|
||||
isError={isError}
|
||||
isSigned={isSigned}
|
||||
isZeroable
|
||||
label={label}
|
||||
onChange={_onChange}
|
||||
onEnter={onEnter}
|
||||
withLabel={withLabel}
|
||||
/>
|
||||
)
|
||||
}
|
||||
</Bare>
|
||||
);
|
||||
}
|
||||
|
||||
export default React.memo(Amount);
|
||||
Reference in new issue
Block a user