2017-10-12 00:01:37 +03:00
|
|
|
import * as React from 'react';
|
|
|
|
import { ExampleValue, FieldLabel } from '../../common-elements/fields';
|
|
|
|
|
|
|
|
export interface EnumValuesProps {
|
|
|
|
values: string[];
|
|
|
|
type: string;
|
|
|
|
}
|
|
|
|
|
|
|
|
export class EnumValues extends React.PureComponent<EnumValuesProps> {
|
|
|
|
render() {
|
|
|
|
const { values, type } = this.props;
|
2018-01-22 21:30:53 +03:00
|
|
|
if (!values.length) {
|
|
|
|
return null;
|
|
|
|
}
|
2017-10-12 00:01:37 +03:00
|
|
|
|
|
|
|
return (
|
|
|
|
<div>
|
2018-06-26 18:56:28 +03:00
|
|
|
<FieldLabel>
|
|
|
|
{type === 'array' ? 'Items' : ''} {values.length === 1 ? 'Value' : 'Enum'}:
|
2019-05-12 22:07:50 +03:00
|
|
|
</FieldLabel>{' '}
|
2017-10-12 00:01:37 +03:00
|
|
|
{values.map((value, idx) => (
|
2019-05-12 22:07:50 +03:00
|
|
|
<ExampleValue key={idx}>
|
|
|
|
{JSON.stringify(value)}
|
|
|
|
</ExampleValue>
|
2017-10-12 00:01:37 +03:00
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|