@constructor-io/constructorio-ui-quizzes 1.17.14 → 1.17.15
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/constructorio-ui-quizzes-bundled.js +8 -8
- package/lib/cjs/components/ShareResultsModal/EmailField.js +9 -1
- package/lib/cjs/version.js +1 -1
- package/lib/mjs/components/ShareResultsModal/EmailField.js +9 -1
- package/lib/mjs/version.js +1 -1
- package/lib/styles.css +4 -0
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -8,6 +8,7 @@ const Toaster_1 = tslib_1.__importDefault(require("./Toaster"));
|
|
|
8
8
|
function EmailField({ onSubmit }) {
|
|
9
9
|
const [formError, setFormError] = (0, react_1.useState)(null);
|
|
10
10
|
const [isSubmitted, setIsSubmitted] = (0, react_1.useState)(false);
|
|
11
|
+
const [isInProgress, setIsInProgress] = (0, react_1.useState)(false);
|
|
11
12
|
const [email, setEmail] = (0, react_1.useState)('');
|
|
12
13
|
const [showNotification, setShowNotification] = react_1.default.useState(false);
|
|
13
14
|
const validate = () => {
|
|
@@ -20,10 +21,16 @@ function EmailField({ onSubmit }) {
|
|
|
20
21
|
};
|
|
21
22
|
const handleSubmit = (e) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
22
23
|
e.preventDefault();
|
|
24
|
+
setIsSubmitted(false);
|
|
25
|
+
if (isInProgress) {
|
|
26
|
+
return;
|
|
27
|
+
}
|
|
28
|
+
setShowNotification(false);
|
|
23
29
|
const isValid = validate();
|
|
24
30
|
if (!isValid)
|
|
25
31
|
return;
|
|
26
32
|
try {
|
|
33
|
+
setIsInProgress(true);
|
|
27
34
|
yield onSubmit(email);
|
|
28
35
|
setIsSubmitted(true);
|
|
29
36
|
}
|
|
@@ -33,6 +40,7 @@ function EmailField({ onSubmit }) {
|
|
|
33
40
|
message: 'Sorry, there was an error sending. Please try again.',
|
|
34
41
|
});
|
|
35
42
|
}
|
|
43
|
+
setIsInProgress(false);
|
|
36
44
|
});
|
|
37
45
|
const onCloseToaster = () => {
|
|
38
46
|
setShowNotification(false);
|
|
@@ -51,7 +59,7 @@ function EmailField({ onSubmit }) {
|
|
|
51
59
|
react_1.default.createElement("div", { className: 'cio-share-results-email-input-group' },
|
|
52
60
|
react_1.default.createElement("input", { className: `cio-share-results-email-input ${formError ? 'cio-share-results-email-input--error' : ''}`, onChange: (e) => setEmail(e.target.value), placeholder: 'Enter an email address to receive and share the results' }),
|
|
53
61
|
(formError === null || formError === void 0 ? void 0 : formError.type) === 'validate' && (react_1.default.createElement("div", { className: 'cio-share-results-email-input-error-message' }, formError.message))),
|
|
54
|
-
react_1.default.createElement("button", { className:
|
|
62
|
+
react_1.default.createElement("button", { className: `cio-share-results-share-button ${isInProgress ? 'disabled' : ''}`, type: 'submit' }, "Send"))),
|
|
55
63
|
showNotification && (react_1.default.createElement(Toaster_1.default, { icon: isSubmitted ? CheckMarkCircleSVG_1.default : AlertCircleSVG_1.default, message: isSubmitted ? 'Email sent' : formError === null || formError === void 0 ? void 0 : formError.message, onCloseToaster: onCloseToaster }))));
|
|
56
64
|
}
|
|
57
65
|
exports.default = EmailField;
|
package/lib/cjs/version.js
CHANGED
|
@@ -5,6 +5,7 @@ import Toaster from './Toaster';
|
|
|
5
5
|
export default function EmailField({ onSubmit }) {
|
|
6
6
|
const [formError, setFormError] = useState(null);
|
|
7
7
|
const [isSubmitted, setIsSubmitted] = useState(false);
|
|
8
|
+
const [isInProgress, setIsInProgress] = useState(false);
|
|
8
9
|
const [email, setEmail] = useState('');
|
|
9
10
|
const [showNotification, setShowNotification] = React.useState(false);
|
|
10
11
|
const validate = () => {
|
|
@@ -17,10 +18,16 @@ export default function EmailField({ onSubmit }) {
|
|
|
17
18
|
};
|
|
18
19
|
const handleSubmit = async (e) => {
|
|
19
20
|
e.preventDefault();
|
|
21
|
+
setIsSubmitted(false);
|
|
22
|
+
if (isInProgress) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
setShowNotification(false);
|
|
20
26
|
const isValid = validate();
|
|
21
27
|
if (!isValid)
|
|
22
28
|
return;
|
|
23
29
|
try {
|
|
30
|
+
setIsInProgress(true);
|
|
24
31
|
await onSubmit(email);
|
|
25
32
|
setIsSubmitted(true);
|
|
26
33
|
}
|
|
@@ -30,6 +37,7 @@ export default function EmailField({ onSubmit }) {
|
|
|
30
37
|
message: 'Sorry, there was an error sending. Please try again.',
|
|
31
38
|
});
|
|
32
39
|
}
|
|
40
|
+
setIsInProgress(false);
|
|
33
41
|
};
|
|
34
42
|
const onCloseToaster = () => {
|
|
35
43
|
setShowNotification(false);
|
|
@@ -48,6 +56,6 @@ export default function EmailField({ onSubmit }) {
|
|
|
48
56
|
React.createElement("div", { className: 'cio-share-results-email-input-group' },
|
|
49
57
|
React.createElement("input", { className: `cio-share-results-email-input ${formError ? 'cio-share-results-email-input--error' : ''}`, onChange: (e) => setEmail(e.target.value), placeholder: 'Enter an email address to receive and share the results' }),
|
|
50
58
|
formError?.type === 'validate' && (React.createElement("div", { className: 'cio-share-results-email-input-error-message' }, formError.message))),
|
|
51
|
-
React.createElement("button", { className:
|
|
59
|
+
React.createElement("button", { className: `cio-share-results-share-button ${isInProgress ? 'disabled' : ''}`, type: 'submit' }, "Send"))),
|
|
52
60
|
showNotification && (React.createElement(Toaster, { icon: isSubmitted ? CheckMarkCircleSVG : AlertCircleSVG, message: isSubmitted ? 'Email sent' : formError?.message, onCloseToaster: onCloseToaster }))));
|
|
53
61
|
}
|
package/lib/mjs/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default '1.17.
|
|
1
|
+
export default '1.17.15';
|
package/lib/styles.css
CHANGED
|
@@ -1012,6 +1012,10 @@
|
|
|
1012
1012
|
.cio-quiz .cio-share-results-share-button:focus {
|
|
1013
1013
|
outline: 3px solid var(--primary-color-variant-100);
|
|
1014
1014
|
}
|
|
1015
|
+
.cio-quiz .cio-share-results-share-button.disabled {
|
|
1016
|
+
background: var(--gray-dust-200);
|
|
1017
|
+
border: 2px solid var(--gray-dust-200);
|
|
1018
|
+
}
|
|
1015
1019
|
|
|
1016
1020
|
.cio-quiz .cio-share-results-notification {
|
|
1017
1021
|
width: 100%;
|
package/lib/types/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
declare const _default: "1.17.
|
|
1
|
+
declare const _default: "1.17.15";
|
|
2
2
|
export default _default;
|
package/package.json
CHANGED