1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from 'react';
6 import { isRequiredInput, FloatArrayCommandInputParameter } from '~/models/workflow';
7 import { Field } from 'redux-form';
8 import { ERROR_MESSAGE } from '~/validators/require';
9 import { GenericInputProps, GenericInput } from '~/views/run-process-panel/inputs/generic-input';
10 import { ChipsInput } from '~/components/chips-input/chips-input';
11 import { createSelector } from 'reselect';
12 import { FloatInput } from '~/components/float-input/float-input';
14 export interface FloatArrayInputProps {
15 input: FloatArrayCommandInputParameter;
17 export const FloatArrayInput = ({ input }: FloatArrayInputProps) =>
21 component={FloatArrayInputComponent}
22 validate={validationSelector(input)} />;
25 const validationSelector = createSelector(
27 isRequired => isRequired
32 const required = (value: string[]) =>
37 const FloatArrayInputComponent = (props: GenericInputProps) =>
39 component={InputComponent}
42 class InputComponent extends React.PureComponent<GenericInputProps>{
44 const { commandInput, input, meta } = this.props;
46 deletable={!commandInput.disabled}
47 orderable={!commandInput.disabled}
48 disabled={commandInput.disabled}
50 onChange={this.handleChange}
51 createNewValue={parseFloat}
52 inputComponent={FloatInput}
58 handleChange = (values: {}[]) => {
59 const { input, meta } = this.props;
63 input.onChange(values);