@sok-brand-sites/common-frontend-components 0.0.1-security → 1.643.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of @sok-brand-sites/common-frontend-components might be problematic. Click here for more details.
- package/LICENSE +21 -0
- package/README.md +31 -3
- package/dist/_virtual/_tslib.js +234 -0
- package/dist/assets/icons/Icons.js +118 -0
- package/dist/assets/logos/logos.js +19 -0
- package/dist/components/Accordion/Accordion.js +36 -0
- package/dist/components/Accordion/Accordion.styles.js +75 -0
- package/dist/components/AnimationWrapper/AnimationWrapper.js +35 -0
- package/dist/components/AnimationWrapper/AnimationWrapper.styles.js +26 -0
- package/dist/components/BlockGenerator/BlockContent.js +139 -0
- package/dist/components/BlockGenerator/BlockGenerator.js +62 -0
- package/dist/components/BlockGenerator/BlockGenerator.styles.js +44 -0
- package/dist/components/Button/Button.js +49 -0
- package/dist/components/Button/Button.styles.js +46 -0
- package/dist/components/Card/Card.js +79 -0
- package/dist/components/Card/Card.styles.js +137 -0
- package/dist/components/Carousel/Carousel.js +153 -0
- package/dist/components/Carousel/Carousel.styles.js +261 -0
- package/dist/components/CarouselNarrow/CarouselNarrow.js +120 -0
- package/dist/components/CarouselNarrow/CarouselNarrow.styles.js +281 -0
- package/dist/components/Column/Column.js +31 -0
- package/dist/components/Column/Column.styles.js +34 -0
- package/dist/components/Columns/Columns.js +38 -0
- package/dist/components/Columns/Columns.styles.js +21 -0
- package/dist/components/Embed/Embed.js +54 -0
- package/dist/components/Embed/Embed.styles.js +12 -0
- package/dist/components/Footer/Footer.js +63 -0
- package/dist/components/Footer/Footer.styles.js +67 -0
- package/dist/components/FormBuilder/FormBuilder.js +364 -0
- package/dist/components/FormBuilder/FormBuilder.styles.js +224 -0
- package/dist/components/FormBuilder/FormBuilderCheckboxes.js +39 -0
- package/dist/components/FormBuilder/FormBuilderInput.js +29 -0
- package/dist/components/FormBuilder/FormBuilderParagraph.js +15 -0
- package/dist/components/FormBuilder/FormBuilderSelect.js +39 -0
- package/dist/components/FormBuilder/FormBuilderTextAreaInput.js +29 -0
- package/dist/components/FormBuilder/utiles.js +13 -0
- package/dist/components/FullBgHero/FullBgHero.js +93 -0
- package/dist/components/FullBgHero/FullBgHero.styles.js +180 -0
- package/dist/components/GlobalStyle/GlobalStyle.js +285 -0
- package/dist/components/Header/Header.js +290 -0
- package/dist/components/Header/Header.styles.js +314 -0
- package/dist/components/Heading/Heading.js +29 -0
- package/dist/components/Heading/Heading.styles.js +21 -0
- package/dist/components/Hero/Hero.js +76 -0
- package/dist/components/Hero/Hero.styles.js +128 -0
- package/dist/components/IconLinks/IconLinks.js +118 -0
- package/dist/components/IconLinks/IconLinks.styles.js +259 -0
- package/dist/components/ImageCarousel/ImageCarousel.js +102 -0
- package/dist/components/ImageCarousel/ImageCarousel.styles.js +96 -0
- package/dist/components/LanguageSelector/LanguageSelector.js +72 -0
- package/dist/components/LanguageSelector/LanguageSelector.styles.js +72 -0
- package/dist/components/Layout/Layout.js +15 -0
- package/dist/components/Layout/Layout.styles.js +8 -0
- package/dist/components/List/List.js +25 -0
- package/dist/components/List/List.styles.js +11 -0
- package/dist/components/MarginWrapper/MarginWrapper.js +17 -0
- package/dist/components/MarginWrapper/MarginWrapper.styles.js +38 -0
- package/dist/components/OverlayCards/OverlayCard/OverlayCard.js +132 -0
- package/dist/components/OverlayCards/OverlayCard/OverlayCard.styles.js +133 -0
- package/dist/components/OverlayCards/OverlayCards.js +46 -0
- package/dist/components/OverlayCards/OverlayCards.styles.js +14 -0
- package/dist/components/OverlayCards/OverlayCards.types.js +9 -0
- package/dist/components/Paragraph/Paragraph.js +29 -0
- package/dist/components/Paragraph/Paragraph.styles.js +14 -0
- package/dist/components/PlaceOfBusiness/ContactInformation/ContactInformation.js +45 -0
- package/dist/components/PlaceOfBusiness/ContactInformation/ContactInformation.styles.js +37 -0
- package/dist/components/PlaceOfBusiness/LogoTitle/LogoTitle.js +16 -0
- package/dist/components/PlaceOfBusiness/LogoTitle/LogoTitle.styles.js +44 -0
- package/dist/components/PlaceOfBusiness/OpenToday/OpenToday.js +43 -0
- package/dist/components/PlaceOfBusiness/OpenToday/OpenToday.styles.js +63 -0
- package/dist/components/PlaceOfBusiness/OpeningHours/OpeningHours.js +77 -0
- package/dist/components/PlaceOfBusiness/OpeningHours/OpeningHours.styles.js +68 -0
- package/dist/components/PlaceOfBusiness/PlaceOfBusinessInfo/PlaceOfBusinessInfo.js +125 -0
- package/dist/components/PlaceOfBusiness/PlaceOfBusinessInfo/PlaceOfBusinessInfo.styles.js +32 -0
- package/dist/components/PlaceOfBusiness/PlaceOfBusinessListItem/PlaceOfBusinessListItem.js +85 -0
- package/dist/components/PlaceOfBusiness/PlaceOfBusinessListItem/PlaceOfBusinessListItem.styles.js +134 -0
- package/dist/components/PlaceOfBusiness/PlaceOfBusinessSearch/PlaceOfBusinessSearch.js +142 -0
- package/dist/components/PlaceOfBusiness/PlaceOfBusinessSearch/PlaceOfBusinessSearch.styles.js +43 -0
- package/dist/components/PlaceOfBusiness/Services/Services.js +30 -0
- package/dist/components/PlaceOfBusiness/Services/Services.styles.js +61 -0
- package/dist/components/PlaceOfBusiness/utils.js +177 -0
- package/dist/components/Promotion/Promotion.js +66 -0
- package/dist/components/Promotion/Promotion.styles.js +124 -0
- package/dist/components/RestrictedWidthContainer/RestrictedWidthContainer.js +63 -0
- package/dist/components/Seo/Seo.js +58 -0
- package/dist/components/SideBySide/SideBySide.js +81 -0
- package/dist/components/SideBySide/SideBySide.styles.js +179 -0
- package/dist/components/SocialMediaLinks/SocialMediaLinks.js +28 -0
- package/dist/components/SocialMediaLinks/SocialMediaLinks.styles.js +22 -0
- package/dist/components/SubHero/SubHero.js +22 -0
- package/dist/components/SubHero/SubHero.styles.js +52 -0
- package/dist/components/Table/Table.js +23 -0
- package/dist/components/Table/Table.styles.js +121 -0
- package/dist/components/Table/WpTable.styles.js +5 -0
- package/dist/components/constants.js +34 -0
- package/dist/components/utils.js +160 -0
- package/dist/fonts/Agrandir/Agrandir-Bold.woff.js +2 -0
- package/dist/fonts/Agrandir/Agrandir-Bold.woff2.js +2 -0
- package/dist/fonts/Agrandir/Agrandir-Light.woff.js +2 -0
- package/dist/fonts/Agrandir/Agrandir-Light.woff2.js +2 -0
- package/dist/fonts/Agrandir/index.js +16 -0
- package/dist/fonts/Brule/Brule-Bold.woff.js +2 -0
- package/dist/fonts/Brule/Brule-Bold.woff2.js +2 -0
- package/dist/fonts/Brule/Brule-Medium.woff.js +2 -0
- package/dist/fonts/Brule/Brule-Medium.woff2.js +2 -0
- package/dist/fonts/Brule/Brule-Regular.woff.js +2 -0
- package/dist/fonts/Brule/Brule-Regular.woff2.js +2 -0
- package/dist/fonts/Brule/index.js +18 -0
- package/dist/fonts/Domaine/Domaine-Text-Medium.woff.js +2 -0
- package/dist/fonts/Domaine/Domaine-Text-Medium.woff2.js +2 -0
- package/dist/fonts/Domaine/index.js +14 -0
- package/dist/fonts/FranklinGothic/FranklinGothic-LT-Com-Bk.woff.js +2 -0
- package/dist/fonts/FranklinGothic/FranklinGothic-LT-Com-Bk.woff2.js +2 -0
- package/dist/fonts/FranklinGothic/FranklinGothic-LT-Com-DmCn.woff.js +2 -0
- package/dist/fonts/FranklinGothic/FranklinGothic-LT-Com-DmCn.woff2.js +2 -0
- package/dist/fonts/FranklinGothic/FranklinGothic-LT-Com-MdCn.woff.js +2 -0
- package/dist/fonts/FranklinGothic/FranklinGothic-LT-Com-MdCn.woff2.js +2 -0
- package/dist/fonts/FranklinGothic/index.js +18 -0
- package/dist/fonts/MinionPro/MinionPro-Regular.woff.js +2 -0
- package/dist/fonts/MinionPro/MinionPro-Regular.woff2.js +2 -0
- package/dist/fonts/MinionPro/index.js +14 -0
- package/dist/fonts/Montserrat/Montserrat-Bold.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Bold.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-BoldItalic.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-BoldItalic.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-ExtraBold.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-ExtraBold.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-ExtraBoldItalic.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-ExtraBoldItalic.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Italic.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Italic.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Light.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Light.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-LightItalic.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-LightItalic.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Medium.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Medium.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-MediumItalic.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-MediumItalic.woff2.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Regular.woff.js +2 -0
- package/dist/fonts/Montserrat/Montserrat-Regular.woff2.js +2 -0
- package/dist/fonts/Montserrat/index.js +90 -0
- package/dist/fonts/SBonus/SBonusUX-BoldItalic.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-BoldItalic.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-ExtraboldItalic.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-ExtraboldItalic.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-LightItalic.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-LightItalic.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-MediumItalic.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-MediumItalic.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-RegularItalic.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUX-RegularItalic.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Bold.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Bold.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Extrabold.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Extrabold.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Light.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Light.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Medium.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Medium.woff2.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Regular.woff.js +2 -0
- package/dist/fonts/SBonus/SBonusUXWEB-Regular.woff2.js +2 -0
- package/dist/fonts/SBonus/index.js +95 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-Bold.woff.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-Bold.woff2.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-Light.woff.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-Light.woff2.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-Medium.woff.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-Medium.woff2.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-Regular.woff.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-Regular.woff2.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-SemiBold.woff.js +2 -0
- package/dist/fonts/SBonusDisplay/SBonusDisplay-SemiBold.woff2.js +2 -0
- package/dist/fonts/SBonusDisplay/index.js +22 -0
- package/dist/fonts/SuomiGrumpy/SuomiGrumpy-Black.woff.js +2 -0
- package/dist/fonts/SuomiGrumpy/SuomiGrumpy-Black.woff2.js +2 -0
- package/dist/fonts/SuomiGrumpy/index.js +14 -0
- package/dist/fonts/utils.js +5 -0
- package/dist/hooks/useElementRect.js +65 -0
- package/dist/hooks/windowsize.js +31 -0
- package/dist/locales/constants.js +6 -0
- package/dist/locales/translations.json.js +153 -0
- package/dist/styles/media.js +40 -0
- package/dist/themes/neutral/breakpoints.js +11 -0
- package/dist/themes/neutral/colors.js +3 -0
- package/dist/themes/neutral/components.js +940 -0
- package/dist/themes/neutral/fonts.js +7 -0
- package/dist/themes/neutral/index.js +10 -0
- package/dist/themes/neutral/spacings.js +21 -0
- package/dist/themes/ravintolakonseptit/breakpoints.js +11 -0
- package/dist/themes/ravintolakonseptit/colors.js +17 -0
- package/dist/themes/ravintolakonseptit/components.js +936 -0
- package/dist/themes/ravintolakonseptit/fonts.js +5 -0
- package/dist/themes/ravintolakonseptit/index.js +10 -0
- package/dist/themes/ravintolakonseptit/spacings.js +21 -0
- package/dist/themes/sokos/breakpoints.js +11 -0
- package/dist/themes/sokos/colors.js +3 -0
- package/dist/themes/sokos/components.js +936 -0
- package/dist/themes/sokos/index.js +10 -0
- package/dist/themes/sokospalvelut/breakpoints.js +11 -0
- package/dist/themes/sokospalvelut/colors.js +3 -0
- package/dist/themes/sokospalvelut/components.js +936 -0
- package/dist/themes/sokospalvelut/fonts.js +11 -0
- package/dist/themes/sokospalvelut/index.js +10 -0
- package/dist/themes/theme.types.js +12 -0
- package/dist/themes/tykkimakiresort/colors.js +35 -0
- package/dist/themes/tykkimakiresort/components.js +936 -0
- package/dist/themes/tykkimakiresort/fonts.js +7 -0
- package/dist/themes/tykkimakiresort/index.js +10 -0
- package/package.json +33 -3
- package/scripts/build.js +132 -0
@@ -0,0 +1,364 @@
|
|
1
|
+
import { __assign, __read, __awaiter, __generator } from '../../_virtual/_tslib.js';
|
2
|
+
import { jsx, jsxs } from 'react/jsx-runtime';
|
3
|
+
import React, { useState, useRef, useEffect } from 'react';
|
4
|
+
import { ButtonShape } from '@sok/design-system';
|
5
|
+
import { getThemeComponents, scrollIntoViewIfNeeded } from '../utils.js';
|
6
|
+
import FormBuilderInput from './FormBuilderInput.js';
|
7
|
+
import FormBuilderTextAreaInput from './FormBuilderTextAreaInput.js';
|
8
|
+
import FormBuilderSelect from './FormBuilderSelect.js';
|
9
|
+
import FormBuilderParagraph from './FormBuilderParagraph.js';
|
10
|
+
import FormBuilderCheckboxes from './FormBuilderCheckboxes.js';
|
11
|
+
import { GoogleReCaptchaProvider, useGoogleReCaptcha } from 'react-google-recaptcha-v3';
|
12
|
+
import { MainContainer, SubmitResultContainer, SectionTitle, StyledButton } from './FormBuilder.styles.js';
|
13
|
+
import { Formik, Form } from 'formik';
|
14
|
+
import { string, array, object } from 'yup';
|
15
|
+
/*
|
16
|
+
TODO:
|
17
|
+
Maybe rename better FormBuilder / FormBuilderMain
|
18
|
+
|
19
|
+
*/
|
20
|
+
// let submitSchema:SectionsTypes
|
21
|
+
|
22
|
+
var createValidationSchema = function createValidationSchema(_a) {
|
23
|
+
var sections = _a.sections,
|
24
|
+
initialValues = _a.initialValues; // Have to do a deep copy instead of shallow copy with Object.assign / spread operator
|
25
|
+
// to not mutate initialValues on line 42
|
26
|
+
|
27
|
+
var submitSchema = JSON.parse(JSON.stringify(initialValues));
|
28
|
+
var validationFunc = {
|
29
|
+
input: string(),
|
30
|
+
textarea: string(),
|
31
|
+
select: string(),
|
32
|
+
checkbox: array()
|
33
|
+
};
|
34
|
+
sections.forEach(function (section, sectionId) {
|
35
|
+
if (section.formFields) {
|
36
|
+
delete submitSchema[sectionId].sendToSecondaryEmail;
|
37
|
+
section.formFields.forEach(function (field) {
|
38
|
+
var _a, _b;
|
39
|
+
|
40
|
+
if (field.type !== 'paragraph') {
|
41
|
+
var validationObj = void 0;
|
42
|
+
|
43
|
+
if (field.type !== 'checkbox') {
|
44
|
+
validationObj = field.required ? validationFunc[field.type].required('Tämä kenttä pitää täyttää') : validationFunc[field.type];
|
45
|
+
} else {
|
46
|
+
validationObj = field.required ? validationFunc[field.type].min(1, 'valitse vähintään yksi vaihtoehto') : validationFunc[field.type];
|
47
|
+
}
|
48
|
+
|
49
|
+
submitSchema = __assign(__assign({}, submitSchema), (_a = {}, _a[sectionId] = __assign(__assign({}, submitSchema[sectionId]), {
|
50
|
+
fields: __assign(__assign({}, submitSchema[sectionId].fields), (_b = {}, _b[field.label] = validationObj, _b))
|
51
|
+
}), _a));
|
52
|
+
}
|
53
|
+
});
|
54
|
+
}
|
55
|
+
});
|
56
|
+
Object.keys(submitSchema).forEach(function (key) {
|
57
|
+
return submitSchema[key].fields = object().shape(submitSchema[key].fields);
|
58
|
+
});
|
59
|
+
Object.keys(submitSchema).forEach(function (key) {
|
60
|
+
return submitSchema[key] = object().shape(submitSchema[key]);
|
61
|
+
});
|
62
|
+
return object().shape(submitSchema);
|
63
|
+
};
|
64
|
+
|
65
|
+
var FormBuilderMain = function FormBuilderMain(_a) {
|
66
|
+
var sections = _a.sections,
|
67
|
+
formTitle = _a.formTitle,
|
68
|
+
endpoint = _a.endpoint,
|
69
|
+
successMessage = _a.successMessage,
|
70
|
+
errorMessage = _a.errorMessage,
|
71
|
+
anchor = _a.anchor;
|
72
|
+
|
73
|
+
var _b = __read(useState(false), 2),
|
74
|
+
isSubmitSuccess = _b[0],
|
75
|
+
setIsSubmitSuccess = _b[1];
|
76
|
+
|
77
|
+
var _c = __read(useState(false), 2),
|
78
|
+
showSubmitResult = _c[0],
|
79
|
+
setShowSubmitResult = _c[1];
|
80
|
+
|
81
|
+
var _d = __read(useState(false), 2),
|
82
|
+
disableSubmitButton = _d[0],
|
83
|
+
setDisableSubmitButton = _d[1];
|
84
|
+
|
85
|
+
var executeRecaptcha = useGoogleReCaptcha().executeRecaptcha;
|
86
|
+
var ref = useRef();
|
87
|
+
useEffect(function () {
|
88
|
+
// set up the mutation observer
|
89
|
+
var grecaptchaObserver = new MutationObserver(function (mutations, observer) {
|
90
|
+
var elements = document.getElementsByClassName('grecaptcha-badge');
|
91
|
+
|
92
|
+
if (elements.length > 0) {
|
93
|
+
ref.current.appendChild(elements[0]);
|
94
|
+
observer.disconnect(); // stop observing
|
95
|
+
|
96
|
+
return;
|
97
|
+
}
|
98
|
+
}); // start observing
|
99
|
+
|
100
|
+
grecaptchaObserver.observe(document, {
|
101
|
+
childList: true,
|
102
|
+
subtree: true
|
103
|
+
});
|
104
|
+
}, []); // Initial fields and empty values
|
105
|
+
|
106
|
+
var initialValues = sections.reduce(function (obj, section, i) {
|
107
|
+
if (section.formFields) {
|
108
|
+
obj[i] = section.formFields.reduce(function (obj, field) {
|
109
|
+
// Skip paragraphs
|
110
|
+
if (field.type === 'paragraph') return obj;
|
111
|
+
|
112
|
+
if (field.type === 'checkbox') {
|
113
|
+
obj['fields'][field.label || ''] = [];
|
114
|
+
} else {
|
115
|
+
obj['fields'][field.label || ''] = '';
|
116
|
+
}
|
117
|
+
|
118
|
+
return obj;
|
119
|
+
}, {
|
120
|
+
fields: {},
|
121
|
+
sendToSecondaryEmail: section.sendToSecondaryEmail || false
|
122
|
+
});
|
123
|
+
return obj;
|
124
|
+
}
|
125
|
+
|
126
|
+
return {};
|
127
|
+
}, {}); // create validation scheme
|
128
|
+
|
129
|
+
var submitScheme = createValidationSchema({
|
130
|
+
sections: sections,
|
131
|
+
initialValues: initialValues
|
132
|
+
});
|
133
|
+
|
134
|
+
var submit = function submit(values) {
|
135
|
+
return __awaiter(void 0, void 0, void 0, function () {
|
136
|
+
var token, options, response;
|
137
|
+
return __generator(this, function (_a) {
|
138
|
+
switch (_a.label) {
|
139
|
+
case 0:
|
140
|
+
// Do not submit empty form
|
141
|
+
if (JSON.stringify(initialValues) === JSON.stringify(values)) {
|
142
|
+
return [2
|
143
|
+
/*return*/
|
144
|
+
];
|
145
|
+
}
|
146
|
+
|
147
|
+
setDisableSubmitButton(true);
|
148
|
+
_a.label = 1;
|
149
|
+
|
150
|
+
case 1:
|
151
|
+
_a.trys.push([1, 5,, 6]);
|
152
|
+
|
153
|
+
token = '';
|
154
|
+
if (!executeRecaptcha) return [3
|
155
|
+
/*break*/
|
156
|
+
, 3];
|
157
|
+
return [4
|
158
|
+
/*yield*/
|
159
|
+
, executeRecaptcha()];
|
160
|
+
|
161
|
+
case 2:
|
162
|
+
token = _a.sent();
|
163
|
+
_a.label = 3;
|
164
|
+
|
165
|
+
case 3:
|
166
|
+
options = {
|
167
|
+
method: 'POST',
|
168
|
+
headers: {
|
169
|
+
'Content-Type': 'application/json'
|
170
|
+
},
|
171
|
+
body: JSON.stringify({
|
172
|
+
token: token,
|
173
|
+
form: values,
|
174
|
+
title: formTitle,
|
175
|
+
time: new Date().toLocaleString('fi-FI')
|
176
|
+
})
|
177
|
+
};
|
178
|
+
return [4
|
179
|
+
/*yield*/
|
180
|
+
, fetch("https://" + endpoint, options)];
|
181
|
+
|
182
|
+
case 4:
|
183
|
+
response = _a.sent();
|
184
|
+
|
185
|
+
if ((response === null || response === void 0 ? void 0 : response.status) === 200) {
|
186
|
+
setIsSubmitSuccess(true);
|
187
|
+
setShowSubmitResult(true);
|
188
|
+
scrollIntoViewIfNeeded(ref.current);
|
189
|
+
return [2
|
190
|
+
/*return*/
|
191
|
+
, true];
|
192
|
+
} // Failure returns no response data due to cors error currently
|
193
|
+
// so this code is currently never reached. Will go to catch block.
|
194
|
+
// To-do: fix cors issues when error occurs in the endpoint.
|
195
|
+
|
196
|
+
|
197
|
+
setIsSubmitSuccess(false);
|
198
|
+
setShowSubmitResult(true);
|
199
|
+
setDisableSubmitButton(false);
|
200
|
+
scrollIntoViewIfNeeded(ref.current);
|
201
|
+
return [2
|
202
|
+
/*return*/
|
203
|
+
, false];
|
204
|
+
|
205
|
+
case 5:
|
206
|
+
_a.sent();
|
207
|
+
|
208
|
+
setIsSubmitSuccess(false);
|
209
|
+
setShowSubmitResult(true);
|
210
|
+
setDisableSubmitButton(false);
|
211
|
+
scrollIntoViewIfNeeded(ref.current);
|
212
|
+
return [2
|
213
|
+
/*return*/
|
214
|
+
, false];
|
215
|
+
|
216
|
+
case 6:
|
217
|
+
return [2
|
218
|
+
/*return*/
|
219
|
+
];
|
220
|
+
}
|
221
|
+
});
|
222
|
+
});
|
223
|
+
};
|
224
|
+
|
225
|
+
return jsxs(MainContainer, __assign({
|
226
|
+
ref: ref,
|
227
|
+
id: anchor,
|
228
|
+
reCaptchaPosition: 500
|
229
|
+
}, {
|
230
|
+
children: [showSubmitResult && jsxs(SubmitResultContainer, __assign({
|
231
|
+
isSubmitSuccess: isSubmitSuccess
|
232
|
+
}, {
|
233
|
+
children: [isSubmitSuccess && jsx("div", {
|
234
|
+
dangerouslySetInnerHTML: {
|
235
|
+
__html: successMessage
|
236
|
+
}
|
237
|
+
}, void 0), !isSubmitSuccess && jsx("div", {
|
238
|
+
dangerouslySetInnerHTML: {
|
239
|
+
__html: errorMessage
|
240
|
+
}
|
241
|
+
}, void 0)]
|
242
|
+
}), void 0), jsx(Formik, __assign({
|
243
|
+
initialValues: initialValues,
|
244
|
+
validationSchema: submitScheme,
|
245
|
+
onSubmit: function onSubmit(values, actions) {
|
246
|
+
submit(values).then(function (isSuccess) {
|
247
|
+
if (isSuccess) {
|
248
|
+
actions.resetForm();
|
249
|
+
}
|
250
|
+
});
|
251
|
+
}
|
252
|
+
}, {
|
253
|
+
children: function children(_a) {
|
254
|
+
var errors = _a.errors,
|
255
|
+
handleChange = _a.handleChange,
|
256
|
+
isValid = _a.isValid,
|
257
|
+
touched = _a.touched;
|
258
|
+
var isValidForSubmit = false;
|
259
|
+
|
260
|
+
if (Object.keys(touched).length === 0 && Object.keys(errors).length === 0) {
|
261
|
+
isValidForSubmit = false;
|
262
|
+
}
|
263
|
+
|
264
|
+
if (Object.keys(touched).length > 0 && Object.keys(errors).length === 0) {
|
265
|
+
isValidForSubmit = isValid;
|
266
|
+
}
|
267
|
+
|
268
|
+
return jsxs(Form, {
|
269
|
+
children: [sections.map(function (section, sectionId) {
|
270
|
+
return jsxs(React.Fragment, {
|
271
|
+
children: [jsx(SectionTitle, {
|
272
|
+
children: section.title
|
273
|
+
}, void 0), section.formFields && section.formFields.map(function (field, i) {
|
274
|
+
switch (field.type) {
|
275
|
+
case 'paragraph':
|
276
|
+
return jsx(FormBuilderParagraph, {
|
277
|
+
text: field.text
|
278
|
+
}, i);
|
279
|
+
|
280
|
+
case 'input':
|
281
|
+
return jsx(FormBuilderInput, {
|
282
|
+
label: field.label,
|
283
|
+
name: sectionId + ".fields." + field.label,
|
284
|
+
required: field.required,
|
285
|
+
errors: errors,
|
286
|
+
touched: touched,
|
287
|
+
onChange: handleChange
|
288
|
+
}, i);
|
289
|
+
|
290
|
+
case 'textarea':
|
291
|
+
return jsx(FormBuilderTextAreaInput, {
|
292
|
+
label: field.label,
|
293
|
+
name: sectionId + ".fields." + field.label,
|
294
|
+
required: field.required,
|
295
|
+
touched: touched,
|
296
|
+
errors: errors
|
297
|
+
}, i);
|
298
|
+
|
299
|
+
case 'select':
|
300
|
+
return jsx(FormBuilderSelect, {
|
301
|
+
label: field.label,
|
302
|
+
options: field.options,
|
303
|
+
placeholder: 'Valitse',
|
304
|
+
name: sectionId + ".fields." + field.label,
|
305
|
+
required: field.required,
|
306
|
+
touched: touched,
|
307
|
+
errors: errors
|
308
|
+
}, i);
|
309
|
+
|
310
|
+
case 'checkbox':
|
311
|
+
return jsx(FormBuilderCheckboxes, {
|
312
|
+
label: field.label,
|
313
|
+
options: field.options,
|
314
|
+
name: sectionId + ".fields." + field.label,
|
315
|
+
required: field.required,
|
316
|
+
touched: touched,
|
317
|
+
errors: errors
|
318
|
+
}, i);
|
319
|
+
|
320
|
+
default:
|
321
|
+
return null;
|
322
|
+
}
|
323
|
+
})]
|
324
|
+
}, sectionId);
|
325
|
+
}), jsx(StyledButton, {
|
326
|
+
htmlType: "submit",
|
327
|
+
text: 'Lähetä',
|
328
|
+
shape: ButtonShape.ROUND,
|
329
|
+
disabled: disableSubmitButton || !isValidForSubmit
|
330
|
+
}, void 0)]
|
331
|
+
}, void 0);
|
332
|
+
}
|
333
|
+
}), void 0)]
|
334
|
+
}), void 0);
|
335
|
+
};
|
336
|
+
|
337
|
+
var FormBuilder = function FormBuilder(_a) {
|
338
|
+
var sections = _a.sections,
|
339
|
+
formTitle = _a.formTitle,
|
340
|
+
endpoint = _a.endpoint,
|
341
|
+
successMessage = _a.successMessage,
|
342
|
+
errorMessage = _a.errorMessage,
|
343
|
+
anchor = _a.anchor;
|
344
|
+
return jsx(GoogleReCaptchaProvider, __assign({
|
345
|
+
useRecaptchaNet: true,
|
346
|
+
reCaptchaKey: getThemeComponents().formBuilder.reCaptchaSiteKey,
|
347
|
+
scriptProps: {
|
348
|
+
async: true,
|
349
|
+
defer: true,
|
350
|
+
appendTo: 'body'
|
351
|
+
}
|
352
|
+
}, {
|
353
|
+
children: jsx(FormBuilderMain, {
|
354
|
+
formTitle: formTitle,
|
355
|
+
endpoint: endpoint,
|
356
|
+
successMessage: successMessage,
|
357
|
+
errorMessage: errorMessage,
|
358
|
+
sections: sections,
|
359
|
+
anchor: anchor
|
360
|
+
}, void 0)
|
361
|
+
}), void 0);
|
362
|
+
};
|
363
|
+
|
364
|
+
export { FormBuilder, FormBuilder as default };
|
@@ -0,0 +1,224 @@
|
|
1
|
+
import { __makeTemplateObject } from '../../_virtual/_tslib.js';
|
2
|
+
import styled from 'styled-components';
|
3
|
+
import { Input, TextAreaInput, Select, Button } from '@sok/design-system';
|
4
|
+
import media from '../../styles/media.js';
|
5
|
+
var MainContainer = styled.div.withConfig({
|
6
|
+
displayName: "FormBuilderstyles__MainContainer",
|
7
|
+
componentId: "sc-1k0y8i1-0"
|
8
|
+
})(templateObject_1 || (templateObject_1 = __makeTemplateObject(["\n width: 100%;\n display: flex;\n flex-direction: column;\n font-family: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n\n label {\n margin-right: ", ";\n }\n\n .grecaptcha-badge {\n position: unset !important;\n align-self: flex-end;\n width: 70px !important;\n margin-top: -60px;\n transition: all 0.3s ease !important;\n :hover {\n width: 256px !important;\n }\n }\n"], ["\n width: 100%;\n display: flex;\n flex-direction: column;\n font-family: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n\n label {\n margin-right: ", ";\n }\n\n .grecaptcha-badge {\n position: unset !important;\n align-self: flex-end;\n width: 70px !important;\n margin-top: -60px;\n transition: all 0.3s ease !important;\n :hover {\n width: 256px !important;\n }\n }\n"])), function (_a) {
|
9
|
+
var theme = _a.theme;
|
10
|
+
return theme.components.formBuilder.fontFamily;
|
11
|
+
}, function (_a) {
|
12
|
+
var theme = _a.theme;
|
13
|
+
return theme.components.formBuilder.fontWeight;
|
14
|
+
}, function (_a) {
|
15
|
+
var theme = _a.theme;
|
16
|
+
return theme.components.formBuilder.fontSizes.mobile.fontSize;
|
17
|
+
}, function (_a) {
|
18
|
+
var theme = _a.theme;
|
19
|
+
return theme.components.formBuilder.fontSizes.mobile.lineHeight;
|
20
|
+
}, function (_a) {
|
21
|
+
var theme = _a.theme;
|
22
|
+
return theme.spacings.spacing16;
|
23
|
+
});
|
24
|
+
var SubmitResultContainer = styled.div.withConfig({
|
25
|
+
displayName: "FormBuilderstyles__SubmitResultContainer",
|
26
|
+
componentId: "sc-1k0y8i1-1"
|
27
|
+
})(templateObject_4 || (templateObject_4 = __makeTemplateObject(["\n margin-bottom: ", ";\n padding: ", ";\n\n background-color: ", ";\n\n font-family: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n\n p,\n li,\n ul {\n color: ", ";\n }\n\n ", "\n\n ", "\n"], ["\n margin-bottom: ", ";\n padding: ", ";\n\n background-color: ", ";\n\n font-family: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n\n p,\n li,\n ul {\n color: ", ";\n }\n\n ", "\n\n ", "\n"])), function (_a) {
|
28
|
+
var theme = _a.theme;
|
29
|
+
return "" + theme.spacings.spacing32;
|
30
|
+
}, function (_a) {
|
31
|
+
var theme = _a.theme;
|
32
|
+
return "" + theme.spacings.spacing32;
|
33
|
+
}, function (_a) {
|
34
|
+
var theme = _a.theme,
|
35
|
+
isSubmitSuccess = _a.isSubmitSuccess;
|
36
|
+
return isSubmitSuccess ? theme.components.formBuilder.submitResult.color.success.background : theme.components.formBuilder.submitResult.color.error.background;
|
37
|
+
}, function (_a) {
|
38
|
+
var theme = _a.theme;
|
39
|
+
return theme.components.formBuilder.submitResult.fontFamily;
|
40
|
+
}, function (_a) {
|
41
|
+
var theme = _a.theme;
|
42
|
+
return theme.components.formBuilder.submitResult.fontWeight;
|
43
|
+
}, function (_a) {
|
44
|
+
var theme = _a.theme;
|
45
|
+
return theme.components.formBuilder.submitResult.fontSizes.mobile.fontSize;
|
46
|
+
}, function (_a) {
|
47
|
+
var theme = _a.theme;
|
48
|
+
return theme.components.formBuilder.submitResult.fontSizes.mobile.lineHeight;
|
49
|
+
}, function (_a) {
|
50
|
+
var theme = _a.theme,
|
51
|
+
isSubmitSuccess = _a.isSubmitSuccess;
|
52
|
+
return isSubmitSuccess ? theme.components.formBuilder.submitResult.color.success.text : theme.components.formBuilder.submitResult.color.error.text;
|
53
|
+
}, media.tablet(templateObject_2 || (templateObject_2 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n "])), function (_a) {
|
54
|
+
var theme = _a.theme;
|
55
|
+
return theme.components.formBuilder.submitResult.fontWeight;
|
56
|
+
}, function (_a) {
|
57
|
+
var theme = _a.theme;
|
58
|
+
return theme.components.formBuilder.submitResult.fontSizes.tablet.fontSize;
|
59
|
+
}, function (_a) {
|
60
|
+
var theme = _a.theme;
|
61
|
+
return theme.components.formBuilder.submitResult.fontSizes.tablet.lineHeight;
|
62
|
+
}), media.desktop(templateObject_3 || (templateObject_3 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n "])), function (_a) {
|
63
|
+
var theme = _a.theme;
|
64
|
+
return theme.components.formBuilder.submitResult.fontWeight;
|
65
|
+
}, function (_a) {
|
66
|
+
var theme = _a.theme;
|
67
|
+
return theme.components.formBuilder.submitResult.fontSizes.desktop.fontSize;
|
68
|
+
}, function (_a) {
|
69
|
+
var theme = _a.theme;
|
70
|
+
return theme.components.formBuilder.submitResult.fontSizes.desktop.lineHeight;
|
71
|
+
}));
|
72
|
+
var SectionTitle = styled.div.withConfig({
|
73
|
+
displayName: "FormBuilderstyles__SectionTitle",
|
74
|
+
componentId: "sc-1k0y8i1-2"
|
75
|
+
})(templateObject_7 || (templateObject_7 = __makeTemplateObject(["\n font-family: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n text-transform: ", ";\n margin-bottom: ", ";\n\n ", "\n\n ", "\n"], ["\n font-family: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n color: ", ";\n text-transform: ", ";\n margin-bottom: ", ";\n\n ", "\n\n ", "\n"])), function (_a) {
|
76
|
+
var theme = _a.theme;
|
77
|
+
return theme.components.formBuilder.section.title.fontFamily;
|
78
|
+
}, function (_a) {
|
79
|
+
var theme = _a.theme;
|
80
|
+
return theme.components.formBuilder.section.title.fontWeight;
|
81
|
+
}, function (_a) {
|
82
|
+
var theme = _a.theme;
|
83
|
+
return theme.components.formBuilder.section.title.fontSizes.mobile.fontSize;
|
84
|
+
}, function (_a) {
|
85
|
+
var theme = _a.theme;
|
86
|
+
return theme.components.formBuilder.section.title.fontSizes.mobile.lineHeight;
|
87
|
+
}, function (_a) {
|
88
|
+
var theme = _a.theme;
|
89
|
+
return theme.components.formBuilder.section.title.color;
|
90
|
+
}, function (_a) {
|
91
|
+
var theme = _a.theme;
|
92
|
+
return theme.components.formBuilder.section.title.textTransform;
|
93
|
+
}, function (_a) {
|
94
|
+
var theme = _a.theme;
|
95
|
+
return theme.spacings.spacing32;
|
96
|
+
}, media.tablet(templateObject_5 || (templateObject_5 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n "])), function (_a) {
|
97
|
+
var theme = _a.theme;
|
98
|
+
return theme.components.formBuilder.section.title.fontWeight;
|
99
|
+
}, function (_a) {
|
100
|
+
var theme = _a.theme;
|
101
|
+
return theme.components.formBuilder.section.title.fontSizes.tablet.fontSize;
|
102
|
+
}, function (_a) {
|
103
|
+
var theme = _a.theme;
|
104
|
+
return theme.components.formBuilder.section.title.fontSizes.tablet.lineHeight;
|
105
|
+
}), media.desktop(templateObject_6 || (templateObject_6 = __makeTemplateObject(["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n "], ["\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n "])), function (_a) {
|
106
|
+
var theme = _a.theme;
|
107
|
+
return theme.components.formBuilder.section.title.fontWeight;
|
108
|
+
}, function (_a) {
|
109
|
+
var theme = _a.theme;
|
110
|
+
return theme.components.formBuilder.section.title.fontSizes.desktop.fontSize;
|
111
|
+
}, function (_a) {
|
112
|
+
var theme = _a.theme;
|
113
|
+
return theme.components.formBuilder.section.title.fontSizes.desktop.lineHeight;
|
114
|
+
}));
|
115
|
+
var SectionContainer = styled.div.withConfig({
|
116
|
+
displayName: "FormBuilderstyles__SectionContainer",
|
117
|
+
componentId: "sc-1k0y8i1-3"
|
118
|
+
})(templateObject_8 || (templateObject_8 = __makeTemplateObject(["\n display: flex;\n flex-direction: column;\n margin-bottom: ", ";\n"], ["\n display: flex;\n flex-direction: column;\n margin-bottom: ", ";\n"])), function (_a) {
|
119
|
+
var theme = _a.theme;
|
120
|
+
return theme.spacings.spacing32;
|
121
|
+
});
|
122
|
+
var ParagraphContainer = styled.div.withConfig({
|
123
|
+
displayName: "FormBuilderstyles__ParagraphContainer",
|
124
|
+
componentId: "sc-1k0y8i1-4"
|
125
|
+
})(templateObject_9 || (templateObject_9 = __makeTemplateObject(["\n p,\n ol,\n ul {\n margin-top: 0;\n margin-bottom: ", ";\n }\n\n *:last-child {\n margin-bottom: 0;\n }\n"], ["\n p,\n ol,\n ul {\n margin-top: 0;\n margin-bottom: ", ";\n }\n\n *:last-child {\n margin-bottom: 0;\n }\n"])), function (_a) {
|
126
|
+
var theme = _a.theme;
|
127
|
+
return theme.spacings.spacing16;
|
128
|
+
});
|
129
|
+
var Label = styled.label.withConfig({
|
130
|
+
displayName: "FormBuilderstyles__Label",
|
131
|
+
componentId: "sc-1k0y8i1-5"
|
132
|
+
})(templateObject_10 || (templateObject_10 = __makeTemplateObject(["\n font-weight: ", ";\n margin-bottom: ", ";\n"], ["\n font-weight: ", ";\n margin-bottom: ", ";\n"])), function (_a) {
|
133
|
+
var theme = _a.theme;
|
134
|
+
return theme.components.formBuilder.section.label.fontWeight;
|
135
|
+
}, function (_a) {
|
136
|
+
var theme = _a.theme;
|
137
|
+
return theme.spacings.spacing16;
|
138
|
+
});
|
139
|
+
var LabelError = styled.label.withConfig({
|
140
|
+
displayName: "FormBuilderstyles__LabelError",
|
141
|
+
componentId: "sc-1k0y8i1-6"
|
142
|
+
})(templateObject_13 || (templateObject_13 = __makeTemplateObject(["\n margin: 0;\n font-weight: ", ";\n font-size: ", ";\n color: ", ";\n height: ", ";\n margin-top: ", ";\n\n ", "\n\n ", "\n"], ["\n margin: 0;\n font-weight: ", ";\n font-size: ", ";\n color: ", ";\n height: ", ";\n margin-top: ", ";\n\n ", "\n\n ", "\n"])), function (_a) {
|
143
|
+
var theme = _a.theme;
|
144
|
+
return theme.components.formBuilder.section.labelError.fontWeight;
|
145
|
+
}, function (_a) {
|
146
|
+
var theme = _a.theme;
|
147
|
+
return theme.components.formBuilder.section.labelError.fontSizes.mobile.fontSize;
|
148
|
+
}, function (_a) {
|
149
|
+
var theme = _a.theme;
|
150
|
+
return theme.components.formBuilder.section.labelError.color;
|
151
|
+
}, function (_a) {
|
152
|
+
var theme = _a.theme;
|
153
|
+
return theme.components.formBuilder.section.labelError.fontSizes.mobile.fontSize;
|
154
|
+
}, function (_a) {
|
155
|
+
var theme = _a.theme;
|
156
|
+
return theme.spacings.spacing8;
|
157
|
+
}, media.tablet(templateObject_11 || (templateObject_11 = __makeTemplateObject(["\n font-size: ", ";\n "], ["\n font-size: ", ";\n "])), function (_a) {
|
158
|
+
var theme = _a.theme;
|
159
|
+
return theme.components.formBuilder.section.labelError.fontSizes.tablet.fontSize;
|
160
|
+
}), media.desktop(templateObject_12 || (templateObject_12 = __makeTemplateObject(["\n font-size: ", ";\n "], ["\n font-size: ", ";\n "])), function (_a) {
|
161
|
+
var theme = _a.theme;
|
162
|
+
return theme.components.formBuilder.section.labelError.fontSizes.desktop.fontSize;
|
163
|
+
}));
|
164
|
+
var InputContainer = styled(Input).withConfig({
|
165
|
+
displayName: "FormBuilderstyles__InputContainer",
|
166
|
+
componentId: "sc-1k0y8i1-7"
|
167
|
+
})(templateObject_14 || (templateObject_14 = __makeTemplateObject(["\n height: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n"], ["\n height: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n"])), function (_a) {
|
168
|
+
var theme = _a.theme;
|
169
|
+
return theme.spacings.spacing48;
|
170
|
+
}, function (_a) {
|
171
|
+
var theme = _a.theme;
|
172
|
+
return theme.components.formBuilder.section.input.fontWeight;
|
173
|
+
}, function (_a) {
|
174
|
+
var theme = _a.theme;
|
175
|
+
return theme.components.formBuilder.section.input.fontSizes.mobile.fontSize;
|
176
|
+
}, function (_a) {
|
177
|
+
var theme = _a.theme;
|
178
|
+
return theme.components.formBuilder.section.input.fontSizes.mobile.lineHeight;
|
179
|
+
});
|
180
|
+
var TextAreaInputContainer = styled(TextAreaInput).withConfig({
|
181
|
+
displayName: "FormBuilderstyles__TextAreaInputContainer",
|
182
|
+
componentId: "sc-1k0y8i1-8"
|
183
|
+
})(templateObject_15 || (templateObject_15 = __makeTemplateObject(["\n height: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n"], ["\n height: ", ";\n font-weight: ", ";\n font-size: ", ";\n line-height: ", ";\n"])), function (_a) {
|
184
|
+
var theme = _a.theme;
|
185
|
+
return theme.spacings.spacing48;
|
186
|
+
}, function (_a) {
|
187
|
+
var theme = _a.theme;
|
188
|
+
return theme.components.formBuilder.section.textAreaInput.fontWeight;
|
189
|
+
}, function (_a) {
|
190
|
+
var theme = _a.theme;
|
191
|
+
return theme.components.formBuilder.section.textAreaInput.fontSizes.mobile.fontSize;
|
192
|
+
}, function (_a) {
|
193
|
+
var theme = _a.theme;
|
194
|
+
return theme.components.formBuilder.section.textAreaInput.fontSizes.mobile.lineHeight;
|
195
|
+
});
|
196
|
+
var CheckItemContainer = styled.div.withConfig({
|
197
|
+
displayName: "FormBuilderstyles__CheckItemContainer",
|
198
|
+
componentId: "sc-1k0y8i1-9"
|
199
|
+
})(templateObject_16 || (templateObject_16 = __makeTemplateObject(["\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-start;\n gap: ", ";\n margin-top: ", ";\n\n .ant-checkbox-wrapper {\n margin: 0;\n word-break: break-all;\n }\n"], ["\n display: flex;\n flex-wrap: wrap;\n justify-content: flex-start;\n gap: ", ";\n margin-top: ", ";\n\n .ant-checkbox-wrapper {\n margin: 0;\n word-break: break-all;\n }\n"])), function (_a) {
|
200
|
+
var theme = _a.theme;
|
201
|
+
return theme.spacings.spacing8;
|
202
|
+
}, function (_a) {
|
203
|
+
var theme = _a.theme;
|
204
|
+
return theme.spacings.spacing16;
|
205
|
+
});
|
206
|
+
var SelectContainer = styled(Select).withConfig({
|
207
|
+
displayName: "FormBuilderstyles__SelectContainer",
|
208
|
+
componentId: "sc-1k0y8i1-10"
|
209
|
+
})(templateObject_17 || (templateObject_17 = __makeTemplateObject(["\n margin-top: ", ";\n width: fit-content;\n min-width: 280px;\n"], ["\n margin-top: ", ";\n width: fit-content;\n min-width: 280px;\n"])), function (_a) {
|
210
|
+
var theme = _a.theme;
|
211
|
+
return theme.spacings.spacing16;
|
212
|
+
});
|
213
|
+
var StyledButton = styled(Button).withConfig({
|
214
|
+
displayName: "FormBuilderstyles__StyledButton",
|
215
|
+
componentId: "sc-1k0y8i1-11"
|
216
|
+
})(templateObject_18 || (templateObject_18 = __makeTemplateObject(["\n display: block;\n margin-top: ", ";\n width: ", ";\n"], ["\n display: block;\n margin-top: ", ";\n width: ", ";\n"])), function (_a) {
|
217
|
+
var theme = _a.theme;
|
218
|
+
return theme.spacings.spacing16;
|
219
|
+
}, function (_a) {
|
220
|
+
var theme = _a.theme;
|
221
|
+
return theme.spacings.spacing112;
|
222
|
+
});
|
223
|
+
var templateObject_1, templateObject_2, templateObject_3, templateObject_4, templateObject_5, templateObject_6, templateObject_7, templateObject_8, templateObject_9, templateObject_10, templateObject_11, templateObject_12, templateObject_13, templateObject_14, templateObject_15, templateObject_16, templateObject_17, templateObject_18;
|
224
|
+
export { CheckItemContainer, InputContainer, Label, LabelError, MainContainer, ParagraphContainer, SectionContainer, SectionTitle, SelectContainer, StyledButton, SubmitResultContainer, TextAreaInputContainer };
|
@@ -0,0 +1,39 @@
|
|
1
|
+
import { __rest, __read, __assign } from '../../_virtual/_tslib.js';
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
3
|
+
import { SectionContainer, Label, CheckItemContainer, LabelError } from './FormBuilder.styles.js';
|
4
|
+
import { Checkbox, CheckboxSize } from '@sok/design-system';
|
5
|
+
import { useField } from 'formik';
|
6
|
+
import { getErrorMsg } from './utiles.js';
|
7
|
+
|
8
|
+
var FormBuilderCheckboxes = function FormBuilderCheckboxes(_a) {
|
9
|
+
var label = _a.label,
|
10
|
+
props = __rest(_a, ["label"]);
|
11
|
+
|
12
|
+
var _b = __read(useField(props), 1),
|
13
|
+
field = _b[0];
|
14
|
+
|
15
|
+
var _c = getErrorMsg(field.name, props.errors, props.touched),
|
16
|
+
errorMsg = _c.errorMsg,
|
17
|
+
isTouched = _c.isTouched;
|
18
|
+
|
19
|
+
return jsxs(SectionContainer, {
|
20
|
+
children: [jsxs(Label, {
|
21
|
+
children: [label, props.required ? '*' : '']
|
22
|
+
}, void 0), jsx(CheckItemContainer, {
|
23
|
+
children: props.options && props.options.map(function (option, i) {
|
24
|
+
return jsx(Checkbox, __assign({
|
25
|
+
size: CheckboxSize.SMALL
|
26
|
+
}, field, {
|
27
|
+
value: option.value,
|
28
|
+
checked: field.value.includes(option.value)
|
29
|
+
}, {
|
30
|
+
children: option.value
|
31
|
+
}), i);
|
32
|
+
})
|
33
|
+
}, void 0), jsx(LabelError, {
|
34
|
+
children: isTouched ? errorMsg : ''
|
35
|
+
}, void 0)]
|
36
|
+
}, void 0);
|
37
|
+
};
|
38
|
+
|
39
|
+
export { FormBuilderCheckboxes as default };
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import { __rest, __read, __assign } from '../../_virtual/_tslib.js';
|
2
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
3
|
+
import { SectionContainer, Label, InputContainer, LabelError } from './FormBuilder.styles.js';
|
4
|
+
import { useField } from 'formik';
|
5
|
+
import { getErrorMsg } from './utiles.js';
|
6
|
+
|
7
|
+
var FormBuilderInput = function FormBuilderInput(_a) {
|
8
|
+
var label = _a.label,
|
9
|
+
props = __rest(_a, ["label"]);
|
10
|
+
|
11
|
+
var _b = __read(useField(props), 1),
|
12
|
+
field = _b[0];
|
13
|
+
|
14
|
+
var _c = getErrorMsg(field.name, props.errors, props.touched),
|
15
|
+
errorMsg = _c.errorMsg,
|
16
|
+
isTouched = _c.isTouched;
|
17
|
+
|
18
|
+
return jsxs(SectionContainer, {
|
19
|
+
children: [jsxs(Label, __assign({
|
20
|
+
htmlFor: props.id || props.name
|
21
|
+
}, {
|
22
|
+
children: [label, props.required ? '*' : '']
|
23
|
+
}), void 0), jsx(InputContainer, __assign({}, field), void 0), jsx(LabelError, {
|
24
|
+
children: isTouched ? errorMsg : ''
|
25
|
+
}, void 0)]
|
26
|
+
}, void 0);
|
27
|
+
};
|
28
|
+
|
29
|
+
export { FormBuilderInput as default };
|
@@ -0,0 +1,15 @@
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
2
|
+
import { SectionContainer, ParagraphContainer } from './FormBuilder.styles.js';
|
3
|
+
|
4
|
+
var FormBuilderParagraph = function FormBuilderParagraph(_a) {
|
5
|
+
var text = _a.text;
|
6
|
+
return jsx(SectionContainer, {
|
7
|
+
children: jsx(ParagraphContainer, {
|
8
|
+
dangerouslySetInnerHTML: {
|
9
|
+
__html: text || ''
|
10
|
+
}
|
11
|
+
}, void 0)
|
12
|
+
}, void 0);
|
13
|
+
};
|
14
|
+
|
15
|
+
export { FormBuilderParagraph as default };
|