mirror of
https://github.com/Unleash/unleash.git
synced 2025-09-28 17:55:15 +02:00
* fix: add initial interface * feat: create separate components * feat: implement constraints for existing strategies * feat: add searchfield * fix: reset values on context change * fix: key issue with duplicate values * fix: increase auto hide duration of errors * fix: types * feat: resolve inputs * fix: add date input * fix: add filter * fix: create strategy * fix: remove unused deps * feat: validation * fix: type setError * feat: handle currentTime based on client spec * fix: date field * feat: api validation * fix: refactor * fix: refactor * feat: add compact * fix: remove unused code * feat: mobile optimisations * fix: remove coalescing operator for constraint * fix: clone deep * fix: move parseDate * fix: lift state up for value setting on dates * fix: rename values * fix: change type to interface * fix: lazy initialise values * fix: create operator type * fix: update naming * fix: naming * fix: aria hidden * fix: remove optional operator * fix: rename new constraints * fix: setup flag * fix: refactor date check to date-fns * fix: use date-fns for validation * fix: detach validators from state * refactor: move resolve input to it's own component * fix: remove unused imports * fix: change values container to overflow auto * fix: update placeholder * fix: update import * fix: backwards compatability * fix: hide paragraphs if not active * fix: update path * fix: update strategy text
53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import Input from 'component/common/Input/Input';
|
|
import { makeStyles } from '@material-ui/core/styles';
|
|
import { ConstraintFormHeader } from '../ConstraintFormHeader/ConstraintFormHeader';
|
|
|
|
interface ISingleValueProps {
|
|
setValue: (value: string) => void;
|
|
value?: string;
|
|
type: string;
|
|
error: string;
|
|
setError: React.Dispatch<React.SetStateAction<string>>;
|
|
}
|
|
|
|
const useStyles = makeStyles(theme => ({
|
|
singleValueContainer: { maxWidth: '300px', marginTop: '-1rem' },
|
|
singleValueInput: {
|
|
width: '100%',
|
|
margin: '1rem 0',
|
|
},
|
|
}));
|
|
|
|
export const SingleValue = ({
|
|
setValue,
|
|
value,
|
|
type,
|
|
error,
|
|
setError,
|
|
}: ISingleValueProps) => {
|
|
const styles = useStyles();
|
|
return (
|
|
<>
|
|
<ConstraintFormHeader>
|
|
Add a single {type.toLowerCase()} value
|
|
</ConstraintFormHeader>
|
|
<div className={styles.singleValueContainer}>
|
|
<Input
|
|
label={type}
|
|
name="value"
|
|
value={value || ''}
|
|
onChange={e => {
|
|
setError('');
|
|
setValue(e.target.value.trim());
|
|
}}
|
|
onFocus={() => setError('')}
|
|
placeholder={`Enter a single ${type} value`}
|
|
className={styles.singleValueInput}
|
|
error={Boolean(error)}
|
|
errorText={error}
|
|
/>
|
|
</div>
|
|
</>
|
|
);
|
|
};
|