mirror of
https://github.com/Unleash/unleash.git
synced 2025-02-23 00:22:19 +01:00
refactor: improve constraint values form (#790)
* refactor: preserve white-space in constraint values * refactor: deduplicate constraint values
This commit is contained in:
parent
e4b0cf1c11
commit
fa72952098
@ -30,5 +30,8 @@ export const useStyles = makeStyles(theme => ({
|
||||
column: {
|
||||
flexDirection: 'column',
|
||||
},
|
||||
values: { marginLeft: '1.5rem' },
|
||||
values: {
|
||||
marginLeft: '1.5rem',
|
||||
whiteSpace: 'pre-wrap',
|
||||
},
|
||||
}));
|
||||
|
@ -127,6 +127,9 @@ export const useStyles = makeStyles(theme => ({
|
||||
chip: {
|
||||
margin: '0 0.5rem 0.5rem 0',
|
||||
},
|
||||
chipValue: {
|
||||
whiteSpace: 'pre',
|
||||
},
|
||||
headerActions: {
|
||||
marginLeft: 'auto',
|
||||
[theme.breakpoints.down(660)]: {
|
||||
|
@ -14,7 +14,12 @@ interface IFreeTextInputProps {
|
||||
}
|
||||
|
||||
const useStyles = makeStyles(theme => ({
|
||||
valueChip: { margin: '0 0.5rem 0.5rem 0' },
|
||||
valueChip: {
|
||||
margin: '0 0.5rem 0.5rem 0',
|
||||
},
|
||||
chipValue: {
|
||||
whiteSpace: 'pre',
|
||||
},
|
||||
inputContainer: {
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
@ -74,9 +79,9 @@ export const FreeTextInput = ({
|
||||
.split(',')
|
||||
.filter(values => values)
|
||||
.map(value => value.trim());
|
||||
setValues([...values, ...newValues]);
|
||||
setValues(uniqueValues([...values, ...newValues]));
|
||||
} else {
|
||||
setValues([...values, inputValues.trim()]);
|
||||
setValues(uniqueValues([...values, inputValues.trim()]));
|
||||
}
|
||||
|
||||
setInputValues('');
|
||||
@ -145,6 +150,7 @@ const ConstraintValueChips = ({
|
||||
text={value}
|
||||
maxLength={35}
|
||||
maxWidth="100"
|
||||
className={styles.chipValue}
|
||||
/>
|
||||
}
|
||||
key={`${value}-${index}`}
|
||||
@ -156,3 +162,7 @@ const ConstraintValueChips = ({
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const uniqueValues = <T,>(values: T[]): T[] => {
|
||||
return Array.from(new Set(values));
|
||||
};
|
||||
|
@ -106,6 +106,7 @@ const MultipleValues = ({ values }: IMultipleValuesProps) => {
|
||||
maxWidth="200"
|
||||
text={value}
|
||||
maxLength={25}
|
||||
className={styles.chipValue}
|
||||
/>
|
||||
}
|
||||
className={styles.chip}
|
||||
|
Loading…
Reference in New Issue
Block a user