diff --git a/packages/page-accounts/src/modals/IdentityMain.tsx b/packages/page-accounts/src/modals/IdentityMain.tsx index 0ac34ab6b1..b747f36ab3 100644 --- a/packages/page-accounts/src/modals/IdentityMain.tsx +++ b/packages/page-accounts/src/modals/IdentityMain.tsx @@ -5,7 +5,6 @@ import type { Data, Option } from '@polkadot/types'; import type { Registration } from '@polkadot/types/interfaces'; import React, { useEffect, useState } from 'react'; -import styled from 'styled-components'; import { Input, InputBalance, Modal, Toggle, TxButton } from '@polkadot/react-components'; import { getAddressMeta } from '@polkadot/react-components/util'; @@ -20,12 +19,6 @@ interface Props { onClose: () => void; } -interface WrapProps { - children: React.ReactNode; - onChange: (isChecked: boolean) => void; - value: boolean; -} - interface ValueState { info: Record; okAll: boolean; @@ -46,22 +39,6 @@ function setData (data: Data, setActive: null | ((isActive: boolean) => void), s } } -function WrapToggle ({ children, onChange, value }: WrapProps): React.ReactElement { - const { t } = useTranslation(); - - return ( -
- {children} - ('include field')} - onChange={onChange} - value={value} - /> -
- ); -} - function checkValue (hasValue: boolean, value: string | null | undefined, minLength: number, includes: string[], excludes: string[], starting: string[], notStarting: string[] = WHITESPACE, notEnding: string[] = WHITESPACE): boolean { return !hasValue || ( !!value && @@ -143,7 +120,7 @@ function IdentityMain ({ address, className = '', onClose }: Props): React.React }, [hasEmail, hasLegal, hasRiot, hasTwitter, hasWeb, valDisplay, valEmail, valLegal, valRiot, valTwitter, valWeb]); return ( - ('Register identity')} onClose={onClose} @@ -158,75 +135,85 @@ function IdentityMain ({ address, className = '', onClose }: Props): React.React placeholder={t('My On-Chain Name')} value={valDisplay} /> - - ('legal name')} - maxLength={32} - onChange={setValLegal} - placeholder={t('Full Legal Name')} - value={hasLegal ? valLegal : ''} - /> - - - ('email')} - maxLength={32} - onChange={setValEmail} - placeholder={t('somebody@example.com')} - value={hasEmail ? valEmail : ''} - /> - - - ('web')} - maxLength={32} - onChange={setValWeb} - placeholder={t('https://example.com')} - value={hasWeb ? valWeb : ''} - /> - - - ('twitter')} - onChange={setValTwitter} - placeholder={t('@YourTwitterName')} - value={hasTwitter ? valTwitter : ''} - /> - - - ('riot name')} - maxLength={32} - onChange={setValRiot} - placeholder={t('@yourname:matrix.org')} - value={hasRiot ? valRiot : ''} - /> - + ('legal name')} + labelExtra={ + ('include field')} + onChange={setHasLegal} + value={hasLegal} + /> + } + maxLength={32} + onChange={setValLegal} + placeholder={t('Full Legal Name')} + value={hasLegal ? valLegal : ''} + /> + ('email')} + labelExtra={ + ('include field')} + onChange={setHasEmail} + value={hasEmail} + /> + } + maxLength={32} + onChange={setValEmail} + placeholder={t('somebody@example.com')} + value={hasEmail ? valEmail : ''} + /> + ('web')} + labelExtra={ + ('include field')} + onChange={setHasWeb} + value={hasWeb} + /> + } + maxLength={32} + onChange={setValWeb} + placeholder={t('https://example.com')} + value={hasWeb ? valWeb : ''} + /> + ('twitter')} + labelExtra={ + ('include field')} + onChange={setHasTwitter} + value={hasTwitter} + /> + } + onChange={setValTwitter} + placeholder={t('@YourTwitterName')} + value={hasTwitter ? valTwitter : ''} + /> + ('riot name')} + labelExtra={ + ('include field')} + onChange={setHasRiot} + value={hasRiot} + /> + } + maxLength={32} + onChange={setValRiot} + placeholder={t('@yourname:matrix.org')} + value={hasRiot ? valRiot : ''} + /> - + ); } -const StyledModal = styled(Modal)` - .toggle-Wrap { - position: relative; - } -`; - export default React.memo(IdentityMain); diff --git a/packages/page-contracts/src/Contracts/Deploy.tsx b/packages/page-contracts/src/Contracts/Deploy.tsx index 3a425affad..085e310d97 100644 --- a/packages/page-contracts/src/Contracts/Deploy.tsx +++ b/packages/page-contracts/src/Contracts/Deploy.tsx @@ -180,17 +180,17 @@ function Deploy ({ codeHash, constructorIndex = 0, onClose, setConstructorIndex ('unique deployment salt')} + labelExtra={ + ('use deployment salt')} + onChange={setWithSalt} + value={withSalt} + /> + } onChange={setSalt} placeholder={t('0x prefixed hex, e.g. 0x1234 or ascii data')} value={withSalt ? salt : t('')} - > - ('use deployment salt')} - onChange={setWithSalt} - value={withSalt} - /> - + /> diff --git a/packages/page-contracts/src/shared/InputMegaGas.tsx b/packages/page-contracts/src/shared/InputMegaGas.tsx index 4726e814af..3f3a73d4ea 100644 --- a/packages/page-contracts/src/shared/InputMegaGas.tsx +++ b/packages/page-contracts/src/shared/InputMegaGas.tsx @@ -52,12 +52,8 @@ function InputMegaGas ({ className, estimatedWeight, isCall, weight: { execution ? t('max gas allowed (M, {{estimatedMg}} estimated)', { replace: { estimatedMg: estimatedMg.toString() } }) : t('max gas allowed (M)') } - onChange={isDisabled ? undefined : setMegaGas} - value={isDisabled ? undefined : ((isCall && withEstimate) ? BN_ZERO : megaGas)} - > - {(estimatedWeight || isCall) && ( + labelExtra={(estimatedWeight || isCall) && ( ('max read gas') @@ -67,7 +63,9 @@ function InputMegaGas ({ className, estimatedWeight, isCall, weight: { execution value={withEstimate} /> )} - + onChange={isDisabled ? undefined : setMegaGas} + value={isDisabled ? undefined : ((isCall && withEstimate) ? BN_ZERO : megaGas)} + />
{t('{{executionTime}}s execution time', { replace: { executionTime: executionTime.toFixed(3) } })}{', '} {t('{{percentage}}% of block weight', { replace: { percentage: percentage.toFixed(2) } })} diff --git a/packages/page-staking/src/Actions/Account/Unbond.tsx b/packages/page-staking/src/Actions/Account/Unbond.tsx index 9579c76c42..d20009688f 100644 --- a/packages/page-staking/src/Actions/Account/Unbond.tsx +++ b/packages/page-staking/src/Actions/Account/Unbond.tsx @@ -7,9 +7,10 @@ import type { BN } from '@polkadot/util'; import React, { useState } from 'react'; import styled from 'styled-components'; -import { InputAddress, InputBalance, Modal, Static, Toggle, TxButton } from '@polkadot/react-components'; +import { InputAddress, InputBalance, Modal, Static, TxButton } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; -import { BlockToTime } from '@polkadot/react-query'; +import { BlockToTime, FormatBalance } from '@polkadot/react-query'; +import { BN_ZERO } from '@polkadot/util'; import { useTranslation } from '../../translate'; import useUnbondDuration from '../useUnbondDuration'; @@ -27,7 +28,6 @@ function Unbond ({ controllerId, onClose, stakingLedger, stashId }: Props): Reac const bondedBlocks = useUnbondDuration(); const [maxBalance] = useState(() => stakingLedger?.active?.unwrap() || null); const [maxUnbond, setMaxUnbond] = useState(); - const [withMax, setWithMax] = useState(false); return ( ('unbond amount')} + labelExtra={ + {t('bonded')}} + value={maxBalance} + /> + } maxValue={maxBalance} onChange={setMaxUnbond} withMax - > - ('all bonded')} - onChange={setWithMax} - value={withMax} - /> - + /> {bondedBlocks?.gtn(0) && ( ('on-chain bonding duration')} @@ -79,10 +76,10 @@ function Unbond ({ controllerId, onClose, stakingLedger, stashId }: Props): Reac ('Unbond')} onStart={onClose} - params={[withMax ? maxBalance : maxUnbond]} + params={[maxUnbond]} tx={api.tx.staking.unbond} /> diff --git a/packages/page-staking/src/Actions/Pool/Unbond.tsx b/packages/page-staking/src/Actions/Pool/Unbond.tsx index 8c147c1c74..58976f73a9 100644 --- a/packages/page-staking/src/Actions/Pool/Unbond.tsx +++ b/packages/page-staking/src/Actions/Pool/Unbond.tsx @@ -5,7 +5,7 @@ import type { BN } from '@polkadot/util'; import React, { useState } from 'react'; -import { InputBalance, Modal, Static, Toggle, TxButton } from '@polkadot/react-components'; +import { InputBalance, Modal, Static, TxButton } from '@polkadot/react-components'; import { useApi } from '@polkadot/react-hooks'; import { BlockToTime, FormatBalance } from '@polkadot/react-query'; @@ -25,7 +25,6 @@ function Unbond ({ className, controllerId, maxUnbond, onClose, poolId }: Props) const { t } = useTranslation(); const { api } = useApi(); const [amount, setAmount] = useState(); - const [withMax, setWithMax] = useState(false); const bondedBlocks = useUnbondDuration(); const isAmountError = !amount || !maxUnbond || amount.gt(maxUnbond); @@ -46,9 +45,7 @@ function Unbond ({ className, controllerId, maxUnbond, onClose, poolId }: Props) ('amount to unbond')} labelExtra={ - ('all bonded')} - onChange={setWithMax} - value={withMax} - /> - + /> {bondedBlocks?.gtn(0) && ( ('on-chain bonding duration')} @@ -80,10 +70,10 @@ function Unbond ({ className, controllerId, maxUnbond, onClose, poolId }: Props) ('Unbond')} onStart={onClose} - params={[controllerId, withMax ? maxUnbond : amount]} + params={[controllerId, amount]} tx={api.tx.nominationPools.unbond} /> diff --git a/packages/page-storage/src/Selection/Modules.tsx b/packages/page-storage/src/Selection/Modules.tsx index 8e35ddefec..b53c39f3b3 100644 --- a/packages/page-storage/src/Selection/Modules.tsx +++ b/packages/page-storage/src/Selection/Modules.tsx @@ -21,7 +21,7 @@ import { compactStripLength, isHex, isNull, isUndefined, u8aToHex } from '@polka import { useTranslation } from '../translate'; -type ParamsType = { type: TypeDefExt }[]; +type ParamsType = { name?: string, type: TypeDefExt }[]; interface KeyState { defaultValues: RawParams | undefined | null; @@ -61,16 +61,18 @@ function expandParams (registry: Registry, st: StorageEntryTypeLatest, isIterabl } return types.map((str, index) => { + let name: string | undefined; let type: TypeDefExt; if (isIterable && index === (types.length - 1)) { + // name = 'entryKey'; type = getTypeDef(`Option<${str}>`); type.withOptionActive = true; } else { type = getTypeDef(str); } - return { type }; + return { name, type }; }); } diff --git a/packages/page-sudo/src/Sudo.tsx b/packages/page-sudo/src/Sudo.tsx index 3d57586e0f..8961a351af 100644 --- a/packages/page-sudo/src/Sudo.tsx +++ b/packages/page-sudo/src/Sudo.tsx @@ -50,17 +50,17 @@ function Sudo ({ className, isMine, sudoKey }: Props): React.ReactElement isError={weight.eq(BN_ZERO)} isZeroable={false} label={t('unchecked weight for this call')} + labelExtra={ + ('with weight override')} + onChange={toggleWithWeight} + value={withWeight} + /> + } onChange={_onChangeWeight} value={weight} - > - ('with weight override')} - onChange={toggleWithWeight} - value={withWeight} - /> - + /> )} { +function InputFile ({ accept, className = '', clearContent, isDisabled, isError = false, isFull, label, labelExtra, onChange, placeholder, withEllipsis, withLabel }: InputFileProps): React.ReactElement { const { t } = useTranslation(); const dropRef = createRef(); const [file, setFile] = useState(); @@ -123,6 +124,7 @@ function InputFile ({ accept, className = '', clearContent, isDisabled, isError diff --git a/packages/react-components/src/Labelled.tsx b/packages/react-components/src/Labelled.tsx index 24ef173e0d..2e83197099 100644 --- a/packages/react-components/src/Labelled.tsx +++ b/packages/react-components/src/Labelled.tsx @@ -102,15 +102,27 @@ export default React.memo(styled(Labelled)` &.isOuter { margin: 0.25rem 0; + + .labelExtra { + top: -0.125rem; + // right: 0; + } } .labelExtra { color: var(--color-label); font-size: var(--font-size-label); font-weight: var(--font-weight-label); + position: absolute; right: 1.25rem; text-align: right; text-transform: var(--text-transform-label); + top: 0.75rem; + z-index: 1; + + > .ui--Toggle > label { + padding-right: 0 !important; + } } > .ui--Labelled-content { diff --git a/packages/react-components/src/Toggle.tsx b/packages/react-components/src/Toggle.tsx index 60a66487ed..ccce3f9c57 100644 --- a/packages/react-components/src/Toggle.tsx +++ b/packages/react-components/src/Toggle.tsx @@ -7,7 +7,6 @@ import styled from 'styled-components'; interface Props { className?: string; isDisabled?: boolean; - isOverlay?: boolean; isRadio?: boolean; label: React.ReactNode; onChange?: (isChecked: boolean) => void; @@ -15,7 +14,7 @@ interface Props { value?: boolean; } -function Toggle ({ className = '', isDisabled, isOverlay, isRadio, label, onChange, preventDefault, value }: Props): React.ReactElement { +function Toggle ({ className = '', isDisabled, isRadio, label, onChange, preventDefault, value }: Props): React.ReactElement { const _onClick = useCallback( (event: React.MouseEvent): void => { if (!isDisabled) { @@ -31,20 +30,20 @@ function Toggle ({ className = '', isDisabled, isOverlay, isRadio, label, onChan ); return ( -
{label && }
-
+ ); } -export default React.memo(styled(Toggle)` +const StyledDiv = styled.div` > label { display: inline-block; - margin: 0 0.5rem; + margin: 0 0.5rem !important; } > label, @@ -100,10 +99,6 @@ export default React.memo(styled(Toggle)` width: 1.5rem; } } +`; - &.isOverlay { - bottom: 1.375rem; - position: absolute; - right: 3.5rem; - } -`); +export default React.memo(Toggle); diff --git a/packages/react-params/src/Param/Account.tsx b/packages/react-params/src/Param/Account.tsx index df4e55cc94..25c1ea0f47 100644 --- a/packages/react-params/src/Param/Account.tsx +++ b/packages/react-params/src/Param/Account.tsx @@ -27,7 +27,7 @@ function isValidAddress (value?: string | null): boolean { } function Account (props: Props): React.ReactElement { - const { className = '', defaultValue: { value }, isDisabled, isError, isInOption, label, onChange, type, withLabel } = props; + const { className = '', defaultValue: { value }, isDisabled, isError, label, onChange, type, withLabel } = props; const [defaultValue] = useState(() => (value as string)?.toString()); const _onChange = useCallback( @@ -51,7 +51,6 @@ function Account (props: Props): React.ReactElement { { +function Base ({ children, className = '', isOuter, label, labelExtra, size = 'full', withLabel }: Props): React.ReactElement { return ( diff --git a/packages/react-params/src/Param/BaseBytes.tsx b/packages/react-params/src/Param/BaseBytes.tsx index 963e12441d..7cf094c3ce 100644 --- a/packages/react-params/src/Param/BaseBytes.tsx +++ b/packages/react-params/src/Param/BaseBytes.tsx @@ -20,8 +20,8 @@ interface Props { defaultValue: RawParam; isDisabled?: boolean; isError?: boolean; - isInOption?: boolean; label?: React.ReactNode; + labelExtra?: React.ReactNode; length?: number; name?: string; onChange?: RawParamOnChange; @@ -67,7 +67,7 @@ function convertInput (value: string): [boolean, boolean, Uint8Array] { : [value === '0x', false, new Uint8Array([])]; } -function BaseBytes ({ asHex, children, className = '', defaultValue: { value }, isDisabled, isError, label, length = -1, onChange, onEnter, onEscape, size = 'full', validate = defaultValidate, withCopy, withLabel, withLength }: Props): React.ReactElement { +function BaseBytes ({ asHex, children, className = '', defaultValue: { value }, isDisabled, isError, label, labelExtra, length = -1, onChange, onEnter, onEscape, size = 'full', validate = defaultValidate, withCopy, withLabel, withLength }: Props): React.ReactElement { const { t } = useTranslation(); const [defaultValue] = useState( (): string | undefined => { @@ -122,6 +122,7 @@ function BaseBytes ({ asHex, children, className = '', defaultValue: { value }, isDisabled={isDisabled} isError={isError || !isValid} label={label} + labelExtra={labelExtra} onChange={_onChange} onEnter={onEnter} onEscape={onEscape} diff --git a/packages/react-params/src/Param/BasicAccountIdBase.tsx b/packages/react-params/src/Param/BasicAccountIdBase.tsx index fb32a32a24..ba3db7641b 100644 --- a/packages/react-params/src/Param/BasicAccountIdBase.tsx +++ b/packages/react-params/src/Param/BasicAccountIdBase.tsx @@ -33,7 +33,7 @@ function isValidAddress (value: string | null | undefined, isEthereum: boolean): } function BasicAccountIdBase (props: Props): React.ReactElement { - const { bytesLength, className = '', defaultValue: { value }, isDisabled, isError, isInOption, label, onChange, withLabel } = props; + const { bytesLength, className = '', defaultValue: { value }, isDisabled, isError, label, onChange, withLabel } = props; const [defaultValue] = useState(() => (value as string)?.toString()); const _onChange = useCallback( @@ -52,7 +52,6 @@ function BasicAccountIdBase (props: Props): React.ReactElement { className='full' defaultValue={defaultValue} forceIconType={bytesLength === 20 ? 'ethereum' : 'substrate'} - hideAddress={isInOption} isDisabled={isDisabled} isError={isError} isInput diff --git a/packages/react-params/src/Param/Bytes.tsx b/packages/react-params/src/Param/Bytes.tsx index b4c6d0e2b3..26dfe168e5 100644 --- a/packages/react-params/src/Param/Bytes.tsx +++ b/packages/react-params/src/Param/Bytes.tsx @@ -12,7 +12,7 @@ import { useTranslation } from '../translate'; import BaseBytes from './BaseBytes'; import File from './File'; -function Bytes ({ className = '', defaultValue, isDisabled, isError, isInOption, label, name, onChange, onEnter, onEscape, type, withLabel }: Props): React.ReactElement { +function Bytes ({ className = '', defaultValue, isDisabled, isError, label, name, onChange, onEnter, onEscape, type, withLabel }: Props): React.ReactElement { const { t } = useTranslation(); const [isValid, setIsValid] = useState(false); const [isFileDrop, setFileInput] = useState(false); @@ -31,6 +31,14 @@ function Bytes ({ className = '', defaultValue, isDisabled, isError, isInOption, [onChange] ); + const toggleLabel = !isDisabled && ( + ('file upload')} + onChange={setFileInput} + value={isFileDrop} + /> + ); + return (
{!isDisabled && isFileDrop @@ -39,6 +47,7 @@ function Bytes ({ className = '', defaultValue, isDisabled, isError, isInOption, isDisabled={isDisabled} isError={isError || !isValid} label={label} + labelExtra={toggleLabel} onChange={_onChangeFile} withLabel={withLabel} /> @@ -48,8 +57,8 @@ function Bytes ({ className = '', defaultValue, isDisabled, isError, isInOption, defaultValue={defaultValue} isDisabled={isDisabled} isError={isError} - isInOption={isInOption} label={label} + labelExtra={toggleLabel} length={-1} name={name} onChange={onChange} @@ -61,14 +70,7 @@ function Bytes ({ className = '', defaultValue, isDisabled, isError, isInOption, /> ) } - {!isDisabled && !isInOption && ( - ('file upload')} - onChange={setFileInput} - value={isFileDrop} - /> - )} + {}
); } diff --git a/packages/react-params/src/Param/File.tsx b/packages/react-params/src/Param/File.tsx index 92b8b96838..9a4e1ff0c4 100644 --- a/packages/react-params/src/Param/File.tsx +++ b/packages/react-params/src/Param/File.tsx @@ -13,18 +13,20 @@ interface Props { isDisabled?: boolean; isError?: boolean; label?: React.ReactNode; + labelExtra?: React.ReactNode; onChange?: (contents: Uint8Array) => void; placeholder?: string; withLabel?: boolean; } -function File ({ className = '', isDisabled, isError = false, label, onChange, placeholder, withLabel }: Props): React.ReactElement { +function File ({ className = '', isDisabled, isError = false, label, labelExtra, onChange, placeholder, withLabel }: Props): React.ReactElement { return ( { +function Hash256 ({ className = '', defaultValue, isDisabled, isError, label, name, onChange, onEnter, onEscape, registry, type, withLabel }: Props): React.ReactElement { const { t } = useTranslation(); const [isFileDrop, setFileInput] = useState(false); const [placeholder, setPlaceholder] = useState(null); @@ -38,6 +38,14 @@ function Hash256 ({ className = '', defaultValue, isDisabled, isError, isInOptio [setFileInput, setPlaceholder] ); + const toggleLabel = !isDisabled && ( + ('hash a file')} + onChange={_setFileInput} + value={isFileDrop} + /> + ); + return (
{!isDisabled && isFileDrop @@ -46,6 +54,7 @@ function Hash256 ({ className = '', defaultValue, isDisabled, isError, isInOptio isDisabled={isDisabled} isError={isError} label={label} + labelExtra={toggleLabel} onChange={_onChangeFile} placeholder={placeholder || undefined} withLabel={withLabel} @@ -58,6 +67,7 @@ function Hash256 ({ className = '', defaultValue, isDisabled, isError, isInOptio isDisabled={isDisabled} isError={isError} label={label} + labelExtra={toggleLabel} length={32} name={name} onChange={onChange} @@ -67,15 +77,8 @@ function Hash256 ({ className = '', defaultValue, isDisabled, isError, isInOptio withCopy={isDisabled} withLabel={withLabel} /> - )} - {!isDisabled && !isInOption && ( - ('hash a file')} - onChange={_setFileInput} - value={isFileDrop} - /> - )} + ) + }
); } diff --git a/packages/react-params/src/Param/Option.tsx b/packages/react-params/src/Param/Option.tsx index 4ffa7566f4..e01ce57a21 100644 --- a/packages/react-params/src/Param/Option.tsx +++ b/packages/react-params/src/Param/Option.tsx @@ -10,15 +10,19 @@ import { Toggle } from '@polkadot/react-components'; import { Option } from '@polkadot/types'; import { isU8a, u8aConcat } from '@polkadot/util'; +import Holder from '../Holder'; import { useTranslation } from '../translate'; +import Base from './Base'; import Param from './index'; +import Static from './Static'; const DEF_VALUE = { isValid: true, value: undefined }; const OPT_PREFIX = new Uint8Array([1]); -function OptionDisplay ({ className = '', defaultValue: _defaultValue, isDisabled, name, onChange, onEnter, onEscape, registry, type: { sub, withOptionActive } }: Props): React.ReactElement { +function OptionDisplay ({ className = '', defaultValue: _defaultValue, isDisabled, label, onChange, onEnter, onEscape, registry, type: { sub, withOptionActive }, withLabel }: Props): React.ReactElement { const { t } = useTranslation(); const [isActive, setIsActive] = useState(() => withOptionActive || !!(_defaultValue && _defaultValue.value instanceof Option && _defaultValue.value.isSome) || false); + const [defaultValue] = useState( () => isActive || isDisabled ? _defaultValue && ( @@ -48,29 +52,43 @@ function OptionDisplay ({ className = '', defaultValue: _defaultValue, isDisable return (
- ('include option')} + onChange={setIsActive} + value={isActive} + /> + )} + withLabel={withLabel} /> - {!isDisabled && ( - ('include option')} - onChange={setIsActive} - value={isActive} - /> - )} + +
+ {isActive + ? ( + + ) + : ( + + ) + } +
+
); } diff --git a/packages/react-params/src/Param/Static.tsx b/packages/react-params/src/Param/Static.tsx index 0a6f7b4a81..5fb640ad96 100644 --- a/packages/react-params/src/Param/Static.tsx +++ b/packages/react-params/src/Param/Static.tsx @@ -19,11 +19,12 @@ interface Props { childrenPre?: React.ReactNode; className?: string; defaultValue: RawParam; + isOptional?: boolean; label?: React.ReactNode; withLabel?: boolean; } -function StaticParam ({ asHex, children, childrenPre, className = '', defaultValue, label }: Props): React.ReactElement { +function StaticParam ({ asHex, children, childrenPre, className = '', defaultValue, isOptional, label }: Props): React.ReactElement { const { t } = useTranslation(); const value = useMemo( @@ -45,7 +46,7 @@ function StaticParam ({ asHex, children, childrenPre, className = '', defaultVal {value || t('')}} + value={
{value || (isOptional ? <>  : t(''))}
} /> {children} diff --git a/packages/react-params/src/Param/index.tsx b/packages/react-params/src/Param/index.tsx index 29dc831862..63fc70cfa1 100644 --- a/packages/react-params/src/Param/index.tsx +++ b/packages/react-params/src/Param/index.tsx @@ -22,7 +22,7 @@ function formatJSON (input: string): string { .replace(/^{_alias: {.*}, /, '{'); } -function Param ({ className = '', defaultValue, isDisabled, isError, isInOption, isOptional, name, onChange, onEnter, onEscape, overrides, registry, type }: Props): React.ReactElement | null { +function Param ({ className = '', defaultValue, isDisabled, isError, isOptional, name, onChange, onEnter, onEscape, overrides, registry, type }: Props): React.ReactElement | null { const Component = useMemo( () => findComponent(registry, type, overrides), [registry, type, overrides] @@ -37,11 +37,11 @@ function Param ({ className = '', defaultValue, isDisabled, isError, isInOption, ? getTypeDef(registry.createType(type.type).toRawType()) : type ); - const fmtType = formatJSON(`${isDisabled && isInOption ? 'Option<' : ''}${inner}${isDisabled && isInOption ? '>' : ''}`); + const fmtType = formatJSON(inner); return `${isUndefined(name) ? '' : `${name}: `}${fmtType}${type.typeName && !fmtType.includes(type.typeName) ? ` (${type.typeName})` : ''}`; }, - [isDisabled, isInOption, name, registry, type] + [name, registry, type] ); if (!Component) { @@ -52,7 +52,8 @@ function Param ({ className = '', defaultValue, isDisabled, isError, isInOption, ? ( ) : ( @@ -61,7 +62,6 @@ function Param ({ className = '', defaultValue, isDisabled, isError, isInOption, defaultValue={defaultValue} isDisabled={isDisabled} isError={isError} - isInOption={isInOption} key={`${name || 'unknown'}:${label}`} label={label} name={name} diff --git a/packages/react-signer/src/Password.tsx b/packages/react-signer/src/Password.tsx index 60bd7354d8..928e5f9d07 100644 --- a/packages/react-signer/src/Password.tsx +++ b/packages/react-signer/src/Password.tsx @@ -56,18 +56,18 @@ function Unlock ({ address, className, error, onChange, onEnter, tabIndex }: Pro autoFocus isError={!!error} label={t('unlock account with password')} + labelExtra={ + ('unlock for {{expiry}} min', { replace: { expiry: UNLOCK_MINS } })} + onChange={setIsUnlockCached} + value={isUnlockCached} + /> + } onChange={setPassword} onEnter={onEnter} tabIndex={tabIndex} value={password} - > - ('unlock for {{expiry}} min', { replace: { expiry: UNLOCK_MINS } })} - onChange={setIsUnlockCached} - value={isUnlockCached} - /> - + /> ); }