umwd-components 0.1.69 → 0.1.70
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/ContactForm.js +19 -7
- package/dist/cjs/components/Page.js +6 -0
- package/dist/cjs/components/TextImageSection.js +1 -1
- package/dist/esm/components/ContactForm.js +20 -8
- package/dist/esm/components/Page.js +6 -0
- package/dist/esm/components/TextImageSection.js +1 -1
- package/package.json +1 -1
- package/src/components/ContactForm.tsx +149 -0
- package/src/components/Page.js +4 -0
- package/src/components/TextImageSection.tsx +1 -1
- package/src/index.js +1 -1
- package/src/stories/Page.stories.js +5 -0
- package/src/components/ContactForm.js +0 -131
|
@@ -10,11 +10,18 @@
|
|
|
10
10
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
11
|
|
|
12
12
|
var React = require('react');
|
|
13
|
-
require('prop-types');
|
|
14
13
|
var material = require('@mui/material');
|
|
15
14
|
var isEmail = require('validator/lib/isEmail');
|
|
16
15
|
|
|
17
16
|
function ContactForm(_ref) {
|
|
17
|
+
let {
|
|
18
|
+
data
|
|
19
|
+
} = _ref;
|
|
20
|
+
const {
|
|
21
|
+
id,
|
|
22
|
+
title,
|
|
23
|
+
maxWidth = "lg"
|
|
24
|
+
} = data;
|
|
18
25
|
const [formValues, setFormValues] = React.useState({
|
|
19
26
|
name: "",
|
|
20
27
|
email: "",
|
|
@@ -23,10 +30,7 @@ function ContactForm(_ref) {
|
|
|
23
30
|
});
|
|
24
31
|
const [formErrors, setFormErrors] = React.useState({});
|
|
25
32
|
const handleBlur = e => {
|
|
26
|
-
console.log(e.target.id);
|
|
27
|
-
console.log(e.target.value);
|
|
28
33
|
const errors = validate(formValues);
|
|
29
|
-
console.log(errors);
|
|
30
34
|
setFormErrors({
|
|
31
35
|
...formErrors,
|
|
32
36
|
[e.target.id]: errors[e.target.id]
|
|
@@ -69,7 +73,16 @@ function ContactForm(_ref) {
|
|
|
69
73
|
console.log("errors from validate", errors);
|
|
70
74
|
return errors;
|
|
71
75
|
};
|
|
72
|
-
return /*#__PURE__*/React.createElement(material.
|
|
76
|
+
return /*#__PURE__*/React.createElement(material.Container, {
|
|
77
|
+
maxWidth: maxWidth,
|
|
78
|
+
sx: {
|
|
79
|
+
my: 1
|
|
80
|
+
}
|
|
81
|
+
}, /*#__PURE__*/React.createElement(material.Paper, {
|
|
82
|
+
sx: {
|
|
83
|
+
p: 2
|
|
84
|
+
}
|
|
85
|
+
}, /*#__PURE__*/React.createElement(material.Stack, {
|
|
73
86
|
spacing: 2
|
|
74
87
|
}, /*#__PURE__*/React.createElement(material.Typography, {
|
|
75
88
|
variant: "h6",
|
|
@@ -127,8 +140,7 @@ function ContactForm(_ref) {
|
|
|
127
140
|
variant: "contained",
|
|
128
141
|
color: "primary",
|
|
129
142
|
onClick: handleSendCallback
|
|
130
|
-
}, "Send")));
|
|
143
|
+
}, "Send")))));
|
|
131
144
|
}
|
|
132
|
-
ContactForm.propTypes = {};
|
|
133
145
|
|
|
134
146
|
exports.default = ContactForm;
|
|
@@ -16,6 +16,7 @@ var HeroSection = require('./HeroSection.js');
|
|
|
16
16
|
var FeaturesSection = require('./FeaturesSection.js');
|
|
17
17
|
var IconSection = require('./IconSection.js');
|
|
18
18
|
var material = require('@mui/material');
|
|
19
|
+
var ContactForm = require('./ContactForm.js');
|
|
19
20
|
|
|
20
21
|
function blockRenderer(block) {
|
|
21
22
|
switch (block.__component) {
|
|
@@ -29,6 +30,11 @@ function blockRenderer(block) {
|
|
|
29
30
|
key: block.id,
|
|
30
31
|
data: block
|
|
31
32
|
});
|
|
33
|
+
case "layout.contact-section":
|
|
34
|
+
return /*#__PURE__*/React.createElement(ContactForm.default, {
|
|
35
|
+
key: block.id,
|
|
36
|
+
data: block
|
|
37
|
+
});
|
|
32
38
|
case "layout.text-image-section":
|
|
33
39
|
return /*#__PURE__*/React.createElement(TextImageSection.default, {
|
|
34
40
|
key: block.id,
|
|
@@ -6,11 +6,18 @@
|
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
8
|
import React from 'react';
|
|
9
|
-
import '
|
|
10
|
-
import { Stack, Typography, TextField, Button } from '@mui/material';
|
|
9
|
+
import { Container, Paper, Stack, Typography, TextField, Button } from '@mui/material';
|
|
11
10
|
import isEmail from 'validator/lib/isEmail';
|
|
12
11
|
|
|
13
12
|
function ContactForm(_ref) {
|
|
13
|
+
let {
|
|
14
|
+
data
|
|
15
|
+
} = _ref;
|
|
16
|
+
const {
|
|
17
|
+
id,
|
|
18
|
+
title,
|
|
19
|
+
maxWidth = "lg"
|
|
20
|
+
} = data;
|
|
14
21
|
const [formValues, setFormValues] = React.useState({
|
|
15
22
|
name: "",
|
|
16
23
|
email: "",
|
|
@@ -19,10 +26,7 @@ function ContactForm(_ref) {
|
|
|
19
26
|
});
|
|
20
27
|
const [formErrors, setFormErrors] = React.useState({});
|
|
21
28
|
const handleBlur = e => {
|
|
22
|
-
console.log(e.target.id);
|
|
23
|
-
console.log(e.target.value);
|
|
24
29
|
const errors = validate(formValues);
|
|
25
|
-
console.log(errors);
|
|
26
30
|
setFormErrors({
|
|
27
31
|
...formErrors,
|
|
28
32
|
[e.target.id]: errors[e.target.id]
|
|
@@ -65,7 +69,16 @@ function ContactForm(_ref) {
|
|
|
65
69
|
console.log("errors from validate", errors);
|
|
66
70
|
return errors;
|
|
67
71
|
};
|
|
68
|
-
return /*#__PURE__*/React.createElement(
|
|
72
|
+
return /*#__PURE__*/React.createElement(Container, {
|
|
73
|
+
maxWidth: maxWidth,
|
|
74
|
+
sx: {
|
|
75
|
+
my: 1
|
|
76
|
+
}
|
|
77
|
+
}, /*#__PURE__*/React.createElement(Paper, {
|
|
78
|
+
sx: {
|
|
79
|
+
p: 2
|
|
80
|
+
}
|
|
81
|
+
}, /*#__PURE__*/React.createElement(Stack, {
|
|
69
82
|
spacing: 2
|
|
70
83
|
}, /*#__PURE__*/React.createElement(Typography, {
|
|
71
84
|
variant: "h6",
|
|
@@ -123,8 +136,7 @@ function ContactForm(_ref) {
|
|
|
123
136
|
variant: "contained",
|
|
124
137
|
color: "primary",
|
|
125
138
|
onClick: handleSendCallback
|
|
126
|
-
}, "Send")));
|
|
139
|
+
}, "Send")))));
|
|
127
140
|
}
|
|
128
|
-
ContactForm.propTypes = {};
|
|
129
141
|
|
|
130
142
|
export { ContactForm as default };
|
|
@@ -12,6 +12,7 @@ import { HeroSection } from './HeroSection.js';
|
|
|
12
12
|
import { FeatureSection } from './FeaturesSection.js';
|
|
13
13
|
import { IconSection } from './IconSection.js';
|
|
14
14
|
import { Box } from '@mui/material';
|
|
15
|
+
import ContactForm from './ContactForm.js';
|
|
15
16
|
|
|
16
17
|
function blockRenderer(block) {
|
|
17
18
|
switch (block.__component) {
|
|
@@ -25,6 +26,11 @@ function blockRenderer(block) {
|
|
|
25
26
|
key: block.id,
|
|
26
27
|
data: block
|
|
27
28
|
});
|
|
29
|
+
case "layout.contact-section":
|
|
30
|
+
return /*#__PURE__*/React.createElement(ContactForm, {
|
|
31
|
+
key: block.id,
|
|
32
|
+
data: block
|
|
33
|
+
});
|
|
28
34
|
case "layout.text-image-section":
|
|
29
35
|
return /*#__PURE__*/React.createElement(TextImageSection, {
|
|
30
36
|
key: block.id,
|
package/package.json
CHANGED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React from "react";
|
|
4
|
+
import {
|
|
5
|
+
Container,
|
|
6
|
+
Paper,
|
|
7
|
+
TextField,
|
|
8
|
+
Typography,
|
|
9
|
+
Stack,
|
|
10
|
+
Button,
|
|
11
|
+
} from "@mui/material";
|
|
12
|
+
import isEmail from "validator/lib/isEmail";
|
|
13
|
+
|
|
14
|
+
interface ContactFormProps {
|
|
15
|
+
id: number;
|
|
16
|
+
title: string;
|
|
17
|
+
maxWidth: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
function ContactForm({ data }: { readonly data: ContactFormProps }) {
|
|
21
|
+
const { id, title, maxWidth = "lg" } = data;
|
|
22
|
+
|
|
23
|
+
const [formValues, setFormValues] = React.useState({
|
|
24
|
+
name: "",
|
|
25
|
+
email: "",
|
|
26
|
+
subject: "",
|
|
27
|
+
message: "",
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const [formErrors, setFormErrors] = React.useState({});
|
|
31
|
+
|
|
32
|
+
const handleBlur = (e: Event) => {
|
|
33
|
+
const errors = validate(formValues);
|
|
34
|
+
setFormErrors({ ...formErrors, [e.target.id]: errors[e.target.id] });
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const handleChange = (e: Event) => {
|
|
38
|
+
const { id, value } = e.target;
|
|
39
|
+
setFormValues({ ...formValues, [id]: value });
|
|
40
|
+
console.log("formValues", formValues);
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
const handleClear = () => {
|
|
44
|
+
setFormValues({});
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const handleSendCallback = () => {
|
|
48
|
+
console.log("Send callback");
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const validate = (values) => {
|
|
52
|
+
console.log("values from validate", values);
|
|
53
|
+
let errors = {};
|
|
54
|
+
|
|
55
|
+
if (values.name === "") {
|
|
56
|
+
errors.name = "Name is required";
|
|
57
|
+
}
|
|
58
|
+
if (values.email === "") {
|
|
59
|
+
errors.email = "Email is required";
|
|
60
|
+
} else if (!isEmail(values.email)) {
|
|
61
|
+
errors.email = "Invalid email";
|
|
62
|
+
}
|
|
63
|
+
if (values.subject === "") {
|
|
64
|
+
errors.subject = "Subject is required";
|
|
65
|
+
}
|
|
66
|
+
if (values.message === "") {
|
|
67
|
+
errors.message = "Message is required";
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
console.log("errors from validate", errors);
|
|
71
|
+
|
|
72
|
+
return errors;
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
return (
|
|
76
|
+
<Container maxWidth={maxWidth} sx={{ my: 1 }}>
|
|
77
|
+
<Paper sx={{ p: 2 }}>
|
|
78
|
+
<Stack spacing={2}>
|
|
79
|
+
<Typography variant="h6" align="center">
|
|
80
|
+
Write us
|
|
81
|
+
</Typography>
|
|
82
|
+
<Typography variant="body1" align="center">
|
|
83
|
+
We're open for any suggestion or just to have a chat
|
|
84
|
+
</Typography>
|
|
85
|
+
<TextField
|
|
86
|
+
id="name"
|
|
87
|
+
label="Name"
|
|
88
|
+
value={formValues.name}
|
|
89
|
+
variant="outlined"
|
|
90
|
+
onBlur={(e) => handleBlur(e)}
|
|
91
|
+
onChange={(e) => handleChange(e)}
|
|
92
|
+
error={formErrors.name != undefined ? true : false}
|
|
93
|
+
helperText={formErrors.name}
|
|
94
|
+
/>
|
|
95
|
+
<TextField
|
|
96
|
+
id="email"
|
|
97
|
+
label="Email"
|
|
98
|
+
value={formValues.email}
|
|
99
|
+
variant="outlined"
|
|
100
|
+
onBlur={handleBlur}
|
|
101
|
+
onChange={handleChange}
|
|
102
|
+
error={formErrors.email != undefined ? true : false}
|
|
103
|
+
helperText={formErrors.email}
|
|
104
|
+
/>
|
|
105
|
+
<TextField
|
|
106
|
+
id="subject"
|
|
107
|
+
label="Subject"
|
|
108
|
+
value={formValues.subject}
|
|
109
|
+
variant="outlined"
|
|
110
|
+
onBlur={handleBlur}
|
|
111
|
+
onChange={handleChange}
|
|
112
|
+
error={formErrors.subject != undefined}
|
|
113
|
+
helperText={formErrors.subject}
|
|
114
|
+
/>
|
|
115
|
+
<TextField
|
|
116
|
+
id="message"
|
|
117
|
+
label="Message"
|
|
118
|
+
value={formValues.message}
|
|
119
|
+
variant="outlined"
|
|
120
|
+
multiline
|
|
121
|
+
minRows={5}
|
|
122
|
+
onBlur={handleBlur}
|
|
123
|
+
onChange={handleChange}
|
|
124
|
+
error={formErrors.message != undefined}
|
|
125
|
+
helperText={formErrors.message}
|
|
126
|
+
/>
|
|
127
|
+
<Stack direction={"row"} spacing={2} justifyContent={"end"}>
|
|
128
|
+
<Button
|
|
129
|
+
variant="outlined"
|
|
130
|
+
color="primary"
|
|
131
|
+
onClick={() => handleClear}
|
|
132
|
+
>
|
|
133
|
+
Clear
|
|
134
|
+
</Button>
|
|
135
|
+
<Button
|
|
136
|
+
variant="contained"
|
|
137
|
+
color="primary"
|
|
138
|
+
onClick={handleSendCallback}
|
|
139
|
+
>
|
|
140
|
+
Send
|
|
141
|
+
</Button>
|
|
142
|
+
</Stack>
|
|
143
|
+
</Stack>
|
|
144
|
+
</Paper>
|
|
145
|
+
</Container>
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export default ContactForm;
|
package/src/components/Page.js
CHANGED
|
@@ -7,6 +7,7 @@ import { HeroSection } from "./HeroSection.tsx";
|
|
|
7
7
|
import { FeatureSection } from "./FeaturesSection.tsx";
|
|
8
8
|
import { IconSection } from "./IconSection.tsx";
|
|
9
9
|
import { Box } from "@mui/material";
|
|
10
|
+
import ContactForm from "./ContactForm.tsx";
|
|
10
11
|
|
|
11
12
|
function blockRenderer(block) {
|
|
12
13
|
switch (block.__component) {
|
|
@@ -14,10 +15,13 @@ function blockRenderer(block) {
|
|
|
14
15
|
return <HeroSection key={block.id} data={block} />;
|
|
15
16
|
case "layout.features-section":
|
|
16
17
|
return <FeatureSection key={block.id} data={block} />;
|
|
18
|
+
case "layout.contact-section":
|
|
19
|
+
return <ContactForm key={block.id} data={block} />;
|
|
17
20
|
case "layout.text-image-section":
|
|
18
21
|
return <TextImageSection key={block.id} data={block} />;
|
|
19
22
|
case "layout.icon-section":
|
|
20
23
|
return <IconSection key={block.id} data={block} />;
|
|
24
|
+
|
|
21
25
|
default:
|
|
22
26
|
return null;
|
|
23
27
|
}
|
|
@@ -24,7 +24,7 @@ interface TextImageSectionProps {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
function TextImageSection({ data }: Readonly<TextImageSectionProps>) {
|
|
27
|
-
const { title, text, image, reverse = false, maxWidth } = data;
|
|
27
|
+
const { title, text, image, reverse = false, maxWidth = "lg" } = data;
|
|
28
28
|
|
|
29
29
|
/* TODO Text_content should deal with linebreaks,
|
|
30
30
|
reading up upon mui-markdown docs is advised */
|
package/src/index.js
CHANGED
|
@@ -10,6 +10,6 @@ export { default as NavBar } from "./components/NavBar";
|
|
|
10
10
|
export { default as TextImageSection } from "./components/TextImageSection.tsx";
|
|
11
11
|
export { default as Page } from "./components/Page";
|
|
12
12
|
export { default as Footer } from "./components/Footer";
|
|
13
|
-
export { default as ContactForm } from "./components/ContactForm";
|
|
13
|
+
export { default as ContactForm } from "./components/ContactForm.tsx";
|
|
14
14
|
export { default as WebsitePlaceholder } from "./components/WebsitePlaceholder";
|
|
15
15
|
export { default as BulletList } from "./components/BulletList";
|
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import React from "react";
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
import { TextField, Typography, Stack, Button } from "@mui/material";
|
|
6
|
-
import isEmail from "validator/lib/isEmail";
|
|
7
|
-
|
|
8
|
-
function ContactForm({ ...args }) {
|
|
9
|
-
const [formValues, setFormValues] = React.useState({
|
|
10
|
-
name: "",
|
|
11
|
-
email: "",
|
|
12
|
-
subject: "",
|
|
13
|
-
message: "",
|
|
14
|
-
});
|
|
15
|
-
const [formErrors, setFormErrors] = React.useState({});
|
|
16
|
-
|
|
17
|
-
const handleBlur = (e) => {
|
|
18
|
-
console.log(e.target.id);
|
|
19
|
-
console.log(e.target.value);
|
|
20
|
-
const errors = validate(formValues);
|
|
21
|
-
console.log(errors);
|
|
22
|
-
setFormErrors({ ...formErrors, [e.target.id]: errors[e.target.id] });
|
|
23
|
-
};
|
|
24
|
-
|
|
25
|
-
const handleChange = (e) => {
|
|
26
|
-
const { id, value } = e.target;
|
|
27
|
-
setFormValues({ ...formValues, [id]: value });
|
|
28
|
-
console.log("formValues", formValues);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
const handleClear = () => {
|
|
32
|
-
setFormValues({});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
const handleSendCallback = () => {
|
|
36
|
-
console.log("Send callback");
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const validate = (values) => {
|
|
40
|
-
console.log("values from validate", values);
|
|
41
|
-
let errors = {};
|
|
42
|
-
|
|
43
|
-
if (values.name === "") {
|
|
44
|
-
errors.name = "Name is required";
|
|
45
|
-
}
|
|
46
|
-
if (values.email === "") {
|
|
47
|
-
errors.email = "Email is required";
|
|
48
|
-
} else if (!isEmail(values.email)) {
|
|
49
|
-
errors.email = "Invalid email";
|
|
50
|
-
}
|
|
51
|
-
if (values.subject === "") {
|
|
52
|
-
errors.subject = "Subject is required";
|
|
53
|
-
}
|
|
54
|
-
if (values.message === "") {
|
|
55
|
-
errors.message = "Message is required";
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
console.log("errors from validate", errors);
|
|
59
|
-
|
|
60
|
-
return errors;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
return (
|
|
64
|
-
<Stack spacing={2}>
|
|
65
|
-
<Typography variant="h6" align="center">
|
|
66
|
-
Write us
|
|
67
|
-
</Typography>
|
|
68
|
-
<Typography variant="body1" align="center">
|
|
69
|
-
We're open for any suggestion or just to have a chat
|
|
70
|
-
</Typography>
|
|
71
|
-
<TextField
|
|
72
|
-
id="name"
|
|
73
|
-
label="Name"
|
|
74
|
-
value={formValues.name}
|
|
75
|
-
variant="outlined"
|
|
76
|
-
onBlur={(e) => handleBlur(e)}
|
|
77
|
-
onChange={(e) => handleChange(e)}
|
|
78
|
-
error={formErrors.name != undefined ? true : false}
|
|
79
|
-
helperText={formErrors.name}
|
|
80
|
-
/>
|
|
81
|
-
<TextField
|
|
82
|
-
id="email"
|
|
83
|
-
label="Email"
|
|
84
|
-
value={formValues.email}
|
|
85
|
-
variant="outlined"
|
|
86
|
-
onBlur={handleBlur}
|
|
87
|
-
onChange={handleChange}
|
|
88
|
-
error={formErrors.email != undefined ? true : false}
|
|
89
|
-
helperText={formErrors.email}
|
|
90
|
-
/>
|
|
91
|
-
<TextField
|
|
92
|
-
id="subject"
|
|
93
|
-
label="Subject"
|
|
94
|
-
value={formValues.subject}
|
|
95
|
-
variant="outlined"
|
|
96
|
-
onBlur={handleBlur}
|
|
97
|
-
onChange={handleChange}
|
|
98
|
-
error={formErrors.subject != undefined}
|
|
99
|
-
helperText={formErrors.subject}
|
|
100
|
-
/>
|
|
101
|
-
<TextField
|
|
102
|
-
id="message"
|
|
103
|
-
label="Message"
|
|
104
|
-
value={formValues.message}
|
|
105
|
-
variant="outlined"
|
|
106
|
-
multiline
|
|
107
|
-
minRows={5}
|
|
108
|
-
onBlur={handleBlur}
|
|
109
|
-
onChange={handleChange}
|
|
110
|
-
error={formErrors.message != undefined}
|
|
111
|
-
helperText={formErrors.message}
|
|
112
|
-
/>
|
|
113
|
-
<Stack direction={"row"} spacing={2} justifyContent={"end"}>
|
|
114
|
-
<Button variant="outlined" color="primary" onClick={() => handleClear}>
|
|
115
|
-
Clear
|
|
116
|
-
</Button>
|
|
117
|
-
<Button
|
|
118
|
-
variant="contained"
|
|
119
|
-
color="primary"
|
|
120
|
-
onClick={handleSendCallback}
|
|
121
|
-
>
|
|
122
|
-
Send
|
|
123
|
-
</Button>
|
|
124
|
-
</Stack>
|
|
125
|
-
</Stack>
|
|
126
|
-
);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
ContactForm.propTypes = {};
|
|
130
|
-
|
|
131
|
-
export default ContactForm;
|