mirror of
https://github.com/Redocly/redoc.git
synced 2025-11-07 19:27:31 +03:00
26 lines
632 B
TypeScript
26 lines
632 B
TypeScript
import * as React from 'react';
|
|
import { ExampleValue, FieldLabel } from '../../common-elements/fields';
|
|
|
|
export interface FieldDetailProps {
|
|
value?: any;
|
|
label: string;
|
|
raw?: boolean;
|
|
}
|
|
|
|
function FieldDetailComponent({ value, label, raw }: FieldDetailProps) {
|
|
if (value === undefined) {
|
|
return null;
|
|
}
|
|
|
|
const stringifyValue = raw ? String(value) : JSON.stringify(value);
|
|
|
|
return (
|
|
<div>
|
|
<FieldLabel> {label} </FieldLabel>{' '}
|
|
<ExampleValue className="field-example">{stringifyValue}</ExampleValue>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export const FieldDetail = React.memo<FieldDetailProps>(FieldDetailComponent);
|