ghost-portal/packages/react-components/src/InputConsts/SelectKey.tsx
Jaco Greeff e6ca2db884
Rename ui-* -> react-* (#1495)
* Rename ui-* -> react-*

* Rename actual folders

* react-app -> react-components

* CSS links
2019-08-12 13:12:05 +02:00

57 lines
1.4 KiB
TypeScript

// Copyright 2017-2019 @polkadot/react-components 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 { ApiProps } from '@polkadot/react-api/types';
import { DropdownOptions } from '../util/types';
import { BareProps } from '../types';
import { ConstValueBase } from './types';
import React from 'react';
import { withApi } from '@polkadot/react-api';
import Dropdown from '../Dropdown';
import { classes } from '../util';
type Props = ApiProps & BareProps & {
isError?: boolean;
onChange: (value: ConstValueBase) => void;
options: DropdownOptions;
value: ConstValueBase;
};
class SelectKey extends React.PureComponent<Props> {
public render (): React.ReactNode {
const { className, isError, onChange, options, style, value } = this.props;
if (!options.length) {
return null;
}
return (
<Dropdown
className={classes('ui--DropdownLinked-Items', className)}
isError={isError}
onChange={onChange}
options={options}
style={style}
transform={this.transform}
value={value.method}
withLabel={false}
/>
);
}
private transform = (method: string): ConstValueBase => {
const { value } = this.props;
const section = value.section;
return {
method,
section
};
}
}
export default withApi(SelectKey);