Skip to content

Commit 74bde2a

Browse files
Ruben van LeeuwenDutchBen
authored andcommitted
947: Update imports
1 parent b522c57 commit 74bde2a

File tree

1 file changed

+146
-0
lines changed

1 file changed

+146
-0
lines changed

pages/example-form.tsx

Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
import React from 'react';
2+
3+
import { useRouter } from 'next/router';
4+
5+
import { EuiSpacer } from '@elastic/eui';
6+
import { WfoUserInputForm } from '@orchestrator-ui/orchestrator-ui-components';
7+
import type { InputForm } from '@orchestrator-ui/orchestrator-ui-components';
8+
9+
export function ExampleFormPage() {
10+
const router = useRouter();
11+
12+
const submit = (userInput: { [index: string]: unknown }) => {
13+
// eslint-disable-next-line no-console
14+
console.log(userInput);
15+
alert('See console for submitted form data');
16+
return Promise.resolve();
17+
};
18+
19+
const cancel = () => {
20+
alert('the form is cancelled');
21+
};
22+
23+
const formDefinition = {
24+
additionalProperties: false,
25+
$defs: {
26+
listItem: {
27+
properties: {
28+
listItemText: {
29+
type: 'string',
30+
title: 'List item text',
31+
},
32+
listItemNumber: {
33+
type: 'number',
34+
title: 'List item number',
35+
},
36+
},
37+
title: 'List item',
38+
type: 'object',
39+
},
40+
additionalProperties: false,
41+
},
42+
properties: {
43+
textField: {
44+
default: 'default value',
45+
title: 'Text field',
46+
type: 'string',
47+
},
48+
longText: {
49+
format: 'long',
50+
title: 'Long text field',
51+
type: 'string',
52+
},
53+
number: {
54+
title: 'Number field',
55+
type: 'number',
56+
},
57+
boolean: {
58+
title: 'Boolean field',
59+
type: 'boolean',
60+
},
61+
label: {
62+
title: '-- Label followed by a divider --',
63+
type: 'string',
64+
format: 'label',
65+
},
66+
divider: {
67+
type: 'string',
68+
format: 'divider',
69+
},
70+
selectField: {
71+
title: 'Select field',
72+
enum: ['option1', 'option2', 'option3'],
73+
},
74+
radioField: {
75+
title: 'Radio field',
76+
enum: ['option1', 'option2', 'option3'],
77+
checkboxes: true,
78+
},
79+
acceptField: {
80+
title: 'Accept field',
81+
type: 'string',
82+
format: 'accept',
83+
},
84+
timestampField: {
85+
default: new Date().getTime(),
86+
format: 'timestamp',
87+
title: 'Timestamp field',
88+
type: 'number',
89+
uniforms: {
90+
dateFormat: 'DD-MMM-YYYY HH:mm z',
91+
locale: 'nl-nl',
92+
max: null,
93+
min: 1715860884,
94+
showTimeSelect: true,
95+
timeFormat: 'HH:mm',
96+
},
97+
},
98+
listField: {
99+
default: [],
100+
items: {
101+
$ref: '#/$defs/listItem',
102+
},
103+
title: 'List field',
104+
type: 'array',
105+
minCount: 1,
106+
},
107+
summaryField: {
108+
type: 'string',
109+
format: 'summary',
110+
data: {
111+
headers: ['Header 1', 'Header 2'],
112+
labels: ['Label 1', 'Label 2'],
113+
columns: [
114+
['Column 1 - Row 1', 'Column 1 - Row 2'],
115+
['Column 2 - Row 1', 'Column 2 - Row 2'],
116+
],
117+
},
118+
},
119+
customerField: {
120+
type: 'string',
121+
format: 'customerId',
122+
},
123+
},
124+
title: 'Example form',
125+
type: 'object',
126+
};
127+
128+
return (
129+
<>
130+
<WfoUserInputForm
131+
key={'key'}
132+
router={router}
133+
stepUserInput={formDefinition as InputForm}
134+
validSubmit={submit}
135+
hasNext={false}
136+
hasPrev={false}
137+
cancel={cancel}
138+
previous={cancel}
139+
userInput={[]}
140+
/>
141+
<EuiSpacer />
142+
</>
143+
);
144+
}
145+
146+
export default ExampleFormPage;

0 commit comments

Comments
 (0)