* Bumps w/ eslint * Additional * Additional * Additional * Additional * Remove style props * Additional * Additional * Additional * Additional (< 100) * eslint passes, tsc next * tsc fixes * Update deps * Update i18n
52 lines
1.5 KiB
TypeScript
52 lines
1.5 KiB
TypeScript
// Copyright 2017-2020 @polkadot/app-extrinsics authors & contributors
|
|
// This software may be modified and distributed under the terms
|
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
|
|
|
import { SubmittableExtrinsic, SubmittableExtrinsicFunction } from '@polkadot/api/types';
|
|
import { RawParamOnChange, RawParamOnEnter, RawParamOnEscape } from '@polkadot/react-params/types';
|
|
import { BareProps } from '../types';
|
|
|
|
import React, { useCallback } from 'react';
|
|
|
|
import BaseExtrinsic from '../Extrinsic';
|
|
|
|
interface Props extends BareProps {
|
|
defaultValue: SubmittableExtrinsicFunction<'promise'>;
|
|
isDisabled?: boolean;
|
|
isError?: boolean;
|
|
isPrivate: boolean;
|
|
label: React.ReactNode;
|
|
onChange?: RawParamOnChange;
|
|
onEnter?: RawParamOnEnter;
|
|
onEscape?: RawParamOnEscape;
|
|
withLabel?: boolean;
|
|
}
|
|
|
|
function ExtrinsicDisplay ({ className = '', defaultValue, isDisabled, isError, isPrivate, label, onChange, onEnter, onEscape, withLabel }: Props): React.ReactElement<Props> {
|
|
const _onChange = useCallback(
|
|
(method?: SubmittableExtrinsic<'promise'>): void =>
|
|
onChange && onChange({
|
|
isValid: !!method,
|
|
value: method
|
|
}),
|
|
[onChange]
|
|
);
|
|
|
|
return (
|
|
<BaseExtrinsic
|
|
className={className}
|
|
defaultValue={defaultValue}
|
|
isDisabled={isDisabled}
|
|
isError={isError}
|
|
isPrivate={isPrivate}
|
|
label={label}
|
|
onChange={_onChange}
|
|
onEnter={onEnter}
|
|
onEscape={onEscape}
|
|
withLabel={withLabel}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default React.memo(ExtrinsicDisplay);
|