-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.tsx
93 lines (83 loc) · 2.47 KB
/
App.tsx
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
import { JsonForms } from "@jsonforms/react";
import _ from "lodash";
import React from "react";
import { View } from "react-native";
import { RNCells, RNRenderers } from "./jsonforms";
const initialData = {};
interface State {
data: typeof initialData | any;
errors: [];
}
export default class App extends React.Component<unknown, State> {
constructor(props) {
super(props);
this.state = { data: {}, errors: [] };
}
private onChange({ errors, data }) {
this.setState({ data, errors });
}
private customizer(objValue: string, srcValue: string) {
if (_.isArray(objValue)) {
return _.cloneDeep(objValue).concat(_.cloneDeep(srcValue));
}
return undefined;
}
public render() {
const schema = _.mergeWith(
{},
{
type: "object",
properties: {
chronic: {
title: "chronisch",
type: "string",
enum: ["ja", "nein"],
},
},
},
this.customizer,
);
const uiSchemas = [
{
type: "Category",
elements: [
{
type: "Group",
label: "Chronisch",
elements: [
{
type: "Control",
scope: "#/properties/chronic",
options: {
format: "radio",
},
},
],
},
],
},
];
const uiSchema = {
type: "Categorization",
label: "Fragen",
elements: [...uiSchemas],
options: {
variant: "navigation",
showNavButtons: true,
},
};
const height = !this.state.errors.length ? "90%" : "100%";
return (
<View style={{ height }}>
<JsonForms
schema={schema}
uischema={uiSchema}
data={this.state.data}
renderers={RNRenderers}
cells={RNCells}
onChange={this.onChange.bind(this)}
/>
</View>
);
}
}