-
Notifications
You must be signed in to change notification settings - Fork 2
/
App.js
111 lines (101 loc) · 2.96 KB
/
App.js
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
import React, { useState, useCallback } from 'react';
import 'devextreme/dist/css/dx.common.css';
import 'devextreme/dist/css/dx.light.css';
import './App.css'
import Form, {
SimpleItem,
GroupItem,
ButtonItem,
TabbedItem,
Tab,
TabPanelOptions,
NumericRule,
EmailRule,
ButtonOptions
} from 'devextreme-react/form';
import { CheckBox } from 'devextreme-react/check-box';
import 'devextreme-react/text-area';
const employee = {
name: 'John Heart',
position: 'CEO',
hireDate: new Date(2012, 4, 13),
officeNumber: 901,
phone: '+1(213) 555-9392',
skype: 'jheart_DX_skype',
email: 'jheart@dx-email.com',
notes: 'John has been in the Audio/Video industry since 1990.'
};
const App = () => {
const handleSubmit = React.useCallback((e) => {
setTimeout(() => {
alert("Submitted");
}, 1000);
e.preventDefault();
}, []);
const [isFormReadOnly, setisFormReadOnly] = useState(false);
const onCheckBoxValueChanged = useCallback((e) => {
setisFormReadOnly(e.value);
}, []);
return (
<div id="app-container">
<form action="/employee-page" onSubmit={handleSubmit}>
<Form
id="form"
formData={employee}
readOnly={isFormReadOnly}
labelLocation="top"
showColonAfterLabel={false}>
<GroupItem
colCount={2}>
<GroupItem caption="Employee">
<SimpleItem dataField="name" isRequired={true} />
<SimpleItem dataField="position" />
<SimpleItem dataField="hireDate" />
<SimpleItem dataField="officeNumber">
<NumericRule
message="This field should contain a number"
/>
</SimpleItem>
</GroupItem>
<GroupItem caption="Personal Information">
<TabbedItem>
<TabPanelOptions
height={260}
/>
<Tab title="Contacts">
<SimpleItem dataField="phone" />
<SimpleItem dataField="skype" />
<SimpleItem dataField="email">
<EmailRule
message="This is not a valid Email"
/>
</SimpleItem>
</Tab>
<Tab title="Note">
<SimpleItem
dataField="notes"
editorType="dxTextArea"
/>
</Tab>
</TabbedItem>
</GroupItem>
</GroupItem>
<ButtonItem
horizontalAlignment="center">
<ButtonOptions
text="Submit the Form"
useSubmitBehavior={true}
/>
</ButtonItem>
</Form>
</form>
<CheckBox
id="check-box"
text="Enable read-only mode"
value={isFormReadOnly}
onValueChanged={onCheckBoxValueChanged}
/>
</div>
);
}
export default App;