* Create app-storage structure * Split shared components into ui-react-app * Cleanup @flow issues * Rename apps classes * Split with ui-react-app operational * Import es semantic-ui * Selection section/key split into 2 * Basic storage queries (no-params) in-place * Upgrades * No-param queries operational * Default values operational (dropdown) * Additional cleanups, constrolled value * @flow updates * @flow fixes * Move Params to ui-react-app (future-use in app-storage) * Fix final @flow issues * Query removal * Cleanups * Update README * Upgrades * Fixup cached components * Bump @polkadot/rx-react * Simple explorer animations * Additional (final) cleanups
58 lines
1.3 KiB
JavaScript
58 lines
1.3 KiB
JavaScript
// Copyright 2017-2018 Jaco Greeff
|
|
// This software may be modified and distributed under the terms
|
|
// of the ISC license. See the LICENSE file for details.
|
|
// @flow
|
|
|
|
import type { BareProps } from './types';
|
|
|
|
import React from 'react';
|
|
import Dropdown from 'semantic-ui-react/dist/es/modules/Dropdown';
|
|
import Label from 'semantic-ui-react/dist/es/elements/Label';
|
|
|
|
type Props = BareProps & {
|
|
defaultValue?: string,
|
|
isError?: boolean,
|
|
label?: string,
|
|
// flowlint-next-line unclear-type:off
|
|
onChange?: (event: SyntheticEvent<*>, value: any) => void,
|
|
subject?: rxjs$Subject<*>,
|
|
// flowlint-next-line unclear-type:off
|
|
transform?: (value: any) => any
|
|
};
|
|
|
|
export default function RxDropdown (props: Props): React$Node {
|
|
const onChange = (event: SyntheticEvent<*>, { value }): void => {
|
|
const _value = props.transform
|
|
? props.transform(value)
|
|
: value;
|
|
|
|
if (props.subject) {
|
|
props.subject.next(_value);
|
|
}
|
|
|
|
if (props.onChange) {
|
|
props.onChange(event, _value);
|
|
}
|
|
};
|
|
|
|
const _props = {...props};
|
|
|
|
delete _props.isError;
|
|
delete _props.label;
|
|
delete _props.transform;
|
|
|
|
return [
|
|
<Label key='label'>
|
|
{props.label || ''}
|
|
</Label>,
|
|
<Dropdown
|
|
key='dropdown'
|
|
selection
|
|
{..._props}
|
|
className={props.className}
|
|
error={props.isError}
|
|
onChange={onChange}
|
|
/>
|
|
];
|
|
}
|