-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Expand file tree
/
Copy pathArrayItemDetails.tsx
More file actions
43 lines (39 loc) 路 1.24 KB
/
Copy pathArrayItemDetails.tsx
File metadata and controls
43 lines (39 loc) 路 1.24 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import * as React from 'react';
import { TypeFormat, TypePrefix } from '../../common-elements/fields';
import { ConstraintsView } from './FieldConstraints';
import { Pattern } from './Pattern';
import { SchemaModel } from '../../services';
import styled from '../../styled-components';
import { OptionsContext } from '../OptionsProvider';
export function ArrayItemDetails({ schema }: { schema: SchemaModel }) {
const { hideSchemaPattern } = React.useContext(OptionsContext);
if (
!schema ||
((!schema?.pattern || hideSchemaPattern) &&
!schema.items &&
!schema.displayFormat &&
!schema.constraints?.length) // return null for cases where all constraints are empty
) {
return null;
}
if (schema.type === 'string' && schema.pattern) {
return (
<Wrapper>
[<Pattern schema={schema} />]
</Wrapper>
);
}
return (
<Wrapper>
[ items
{schema.displayFormat && <TypeFormat> <{schema.displayFormat} ></TypeFormat>}
<ConstraintsView constraints={schema.constraints} />
<Pattern schema={schema} />
{schema.items && <ArrayItemDetails schema={schema.items} />} ]
</Wrapper>
);
}
const Wrapper = styled(TypePrefix)`
margin: 0 5px;
vertical-align: text-top;
`;