ublo-lib 1.0.31 → 1.0.32
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/es/common/components/admin-links/admin-links.module.css +1 -1
- package/es/common/components/cookie-consent/cookie-consent.module.css +3 -3
- package/es/common/components/custom-contact-form/attachment.module.css +5 -5
- package/es/common/components/custom-contact-form/custom-contact-form.module.css +4 -4
- package/es/common/components/custom-contact-form/field.module.css +1 -1
- package/es/common/components/date-picker/calendar.module.css +2 -2
- package/es/common/components/date-picker/date-picker.module.css +2 -2
- package/es/common/components/date-picker/helper.module.css +2 -2
- package/es/common/components/date-picker/modes.module.css +2 -2
- package/es/common/components/date-picker/month.module.css +2 -2
- package/es/common/components/video-player/player.module.css +1 -1
- package/es/esf/components/booking-form/booking-form.js +79 -0
- package/es/esf/components/booking-form/booking-form.module.css +41 -0
- package/es/esf/components/booking-form/data.js +6 -0
- package/es/esf/components/booking-form/field.js +67 -91
- package/es/esf/components/booking-form/field.module.css +3 -0
- package/es/esf/components/booking-form/hooks/use-custom-fields.js +2 -2
- package/es/esf/components/booking-form/hooks/use-stay.js +9 -6
- package/es/esf/components/booking-form/index.js +1 -77
- package/es/esf/components/booking-form/lesson.js +11 -9
- package/es/esf/components/booking-form/lesson.module.css +46 -0
- package/es/esf/components/booking-form/lessons.js +13 -17
- package/es/esf/components/booking-form/lessons.module.css +40 -0
- package/es/esf/components/booking-form/personal-data.js +13 -18
- package/es/esf/components/booking-form/personal-data.module.css +30 -0
- package/es/esf/components/booking-form/progress-bar.js +6 -5
- package/es/esf/components/booking-form/progress-bar.module.css +55 -0
- package/es/esf/components/booking-form/steps.js +11 -11
- package/es/esf/components/booking-form/steps.module.css +4 -0
- package/es/esf/components/booking-form/summary.js +41 -29
- package/es/esf/components/booking-form/summary.module.css +54 -0
- package/es/esf/components/booking-form/utils.js +2 -2
- package/es/esf/components/loyal-customers/components/student-form.module.css +1 -1
- package/es/esf/components/loyal-customers/loyal-customers.module.css +1 -1
- package/es/lbm/components/msem-linker/msem-linker.module.css +1 -1
- package/package.json +1 -1
- package/es/esf/components/booking-form/icons.js +0 -50
- package/es/esf/components/booking-form/response.js +0 -42
|
@@ -8,8 +8,8 @@
|
|
|
8
8
|
flex-direction: column;
|
|
9
9
|
gap: 20px;
|
|
10
10
|
padding: 46px 15px;
|
|
11
|
-
color: var(--ds-grey-000, #
|
|
12
|
-
background-color: var(--ds-grey-700, #
|
|
11
|
+
color: var(--ds-grey-000, #fff);
|
|
12
|
+
background-color: var(--ds-grey-700, #232324);
|
|
13
13
|
z-index: 20;
|
|
14
14
|
overflow: auto;
|
|
15
15
|
scrollbar-width: thin;
|
|
@@ -99,5 +99,5 @@
|
|
|
99
99
|
}
|
|
100
100
|
|
|
101
101
|
.buttons button:last-of-type {
|
|
102
|
-
background-color: var(--ds-grey-600, #
|
|
102
|
+
background-color: var(--ds-grey-600, #383838);
|
|
103
103
|
}
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
position: relative;
|
|
25
25
|
min-height: 130px;
|
|
26
26
|
padding: 8px 10px;
|
|
27
|
-
color: var(--ds-grey-700, #
|
|
27
|
+
color: var(--ds-grey-700, #232324);
|
|
28
28
|
font-size: 16px;
|
|
29
29
|
font-family: inherit;
|
|
30
30
|
background-color: var(--ds-grey-100, #f5f5f5);
|
|
@@ -69,14 +69,14 @@
|
|
|
69
69
|
height: 44px;
|
|
70
70
|
width: 44px;
|
|
71
71
|
padding: 6px;
|
|
72
|
-
fill: var(--ds-grey-700, #
|
|
72
|
+
fill: var(--ds-grey-700, #232324);
|
|
73
73
|
background-color: #fff;
|
|
74
74
|
border-radius: var(--ds-radius-100, 3px);
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
.itemName {
|
|
78
78
|
margin-top: 6px;
|
|
79
|
-
color: var(--ds-grey-700, #
|
|
79
|
+
color: var(--ds-grey-700, #232324);
|
|
80
80
|
font-size: 14px;
|
|
81
81
|
cursor: text;
|
|
82
82
|
word-break: break-all;
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
flex-direction: column;
|
|
112
112
|
align-items: center;
|
|
113
113
|
justify-content: center;
|
|
114
|
-
color: var(--ds-grey-700, #
|
|
114
|
+
color: var(--ds-grey-700, #232324);
|
|
115
115
|
font-size: 15px;
|
|
116
116
|
font-style: italic;
|
|
117
117
|
text-align: center;
|
|
@@ -192,7 +192,7 @@
|
|
|
192
192
|
|
|
193
193
|
.helper {
|
|
194
194
|
margin-top: 6px;
|
|
195
|
-
color: var(--ds-grey-700, #
|
|
195
|
+
color: var(--ds-grey-700, #232324);
|
|
196
196
|
font-size: 11px;
|
|
197
197
|
text-transform: uppercase;
|
|
198
198
|
letter-spacing: 1px;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.title {
|
|
10
|
-
color: var(--ds-grey-700, #
|
|
10
|
+
color: var(--ds-grey-700, #232324);
|
|
11
11
|
font-size: 18px;
|
|
12
12
|
line-height: 1.2em;
|
|
13
13
|
text-transform: uppercase;
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
|
|
48
48
|
.message {
|
|
49
49
|
font-size: 14px;
|
|
50
|
-
color: var(--ds-grey-700, #
|
|
50
|
+
color: var(--ds-grey-700, #232324);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
@media (min-width: 480px) {
|
|
@@ -88,7 +88,7 @@
|
|
|
88
88
|
width: 30px;
|
|
89
89
|
height: 30px;
|
|
90
90
|
margin-bottom: 20px;
|
|
91
|
-
fill: var(--ds-grey-700, #
|
|
91
|
+
fill: var(--ds-grey-700, #232324);
|
|
92
92
|
animation: icon-loading-spin 1280ms
|
|
93
93
|
var(--ds-transition-easing, cubic-bezier(0.4, 0, 0.2, 1)) infinite;
|
|
94
94
|
}
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
|
|
102
102
|
.sendingMessage {
|
|
103
103
|
max-width: 420px;
|
|
104
|
-
color: var(--ds-grey-700, #
|
|
104
|
+
color: var(--ds-grey-700, #232324);
|
|
105
105
|
font-size: 12px;
|
|
106
106
|
text-align: center;
|
|
107
107
|
}
|
|
@@ -81,7 +81,7 @@ button.submit {
|
|
|
81
81
|
}
|
|
82
82
|
|
|
83
83
|
.confirmDateChangeMessage {
|
|
84
|
-
color: var(--ds-grey-700, #
|
|
84
|
+
color: var(--ds-grey-700, #232324);
|
|
85
85
|
font-size: 13px;
|
|
86
86
|
}
|
|
87
87
|
|
|
@@ -111,7 +111,7 @@ button.submit {
|
|
|
111
111
|
font-weight: 700;
|
|
112
112
|
text-align: center;
|
|
113
113
|
text-transform: uppercase;
|
|
114
|
-
background-color: var(--ds-grey-700, #
|
|
114
|
+
background-color: var(--ds-grey-700, #232324);
|
|
115
115
|
border: 0;
|
|
116
116
|
border-radius: var(--ds-radius-100, 3px);
|
|
117
117
|
cursor: pointer;
|
|
@@ -57,7 +57,7 @@ div.popup {
|
|
|
57
57
|
}
|
|
58
58
|
|
|
59
59
|
.specialRuleTitle {
|
|
60
|
-
color: var(--ds-grey-700, #
|
|
60
|
+
color: var(--ds-grey-700, #232324);
|
|
61
61
|
font-size: 13px;
|
|
62
62
|
font-weight: 700;
|
|
63
63
|
}
|
|
@@ -75,7 +75,7 @@ div.popup {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
.specialRuleMessage {
|
|
78
|
-
color: var(--ds-grey-700, #
|
|
78
|
+
color: var(--ds-grey-700, #232324);
|
|
79
79
|
font-size: 13px;
|
|
80
80
|
}
|
|
81
81
|
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
align-items: center;
|
|
31
31
|
justify-content: center;
|
|
32
32
|
padding: 10px;
|
|
33
|
-
color: var(--ds-grey-600, #
|
|
33
|
+
color: var(--ds-grey-600, #383838);
|
|
34
34
|
font-size: 14px;
|
|
35
35
|
text-transform: uppercase;
|
|
36
36
|
border-radius: var(--ds-radius-100, 3px);
|
|
@@ -77,5 +77,5 @@
|
|
|
77
77
|
.helperRemove > svg {
|
|
78
78
|
width: 18px;
|
|
79
79
|
height: 18px;
|
|
80
|
-
fill: var(--ds-grey-700, #
|
|
80
|
+
fill: var(--ds-grey-700, #232324);
|
|
81
81
|
}
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
align-items: center;
|
|
23
23
|
text-align: left;
|
|
24
24
|
padding: 20px 35px 20px 25px;
|
|
25
|
-
color: var(--ds-grey-600, #
|
|
25
|
+
color: var(--ds-grey-600, #383838);
|
|
26
26
|
font-size: 16px;
|
|
27
27
|
background-color: var(--ds-grey-100, #f5f5f5);
|
|
28
28
|
border-radius: var(--ds-radius-100, 3px);
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
.inner > span {
|
|
82
|
-
color: var(--ds-grey-600, #
|
|
82
|
+
color: var(--ds-grey-600, #383838);
|
|
83
83
|
font-size: 19px;
|
|
84
84
|
white-space: nowrap;
|
|
85
85
|
font-weight: 700;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
.title {
|
|
7
7
|
margin-bottom: 10px;
|
|
8
|
-
color: var(--ds-grey-600, #
|
|
8
|
+
color: var(--ds-grey-600, #383838);
|
|
9
9
|
font-size: 15px;
|
|
10
10
|
font-weight: 700;
|
|
11
11
|
text-transform: uppercase;
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
.day {
|
|
31
|
-
color: var(--ds-grey-400, #
|
|
31
|
+
color: var(--ds-grey-400, #bbbbbb);
|
|
32
32
|
font-size: 11px;
|
|
33
33
|
text-align: center;
|
|
34
34
|
font-weight: 700;
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import * as React from "react";
|
|
2
|
+
import { SnackbarProvider } from "dt-design-system/es/snackbar";
|
|
3
|
+
import ProgressBar from "./progress-bar";
|
|
4
|
+
import Steps from "./steps";
|
|
5
|
+
import useCustomFields from "./hooks/use-custom-fields";
|
|
6
|
+
import { FIELDS, STEPS } from "./data";
|
|
7
|
+
import css from "./booking-form.module.css";
|
|
8
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
|
+
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
+
|
|
11
|
+
const BookingFormWithSnackbar = props => {
|
|
12
|
+
return _jsx(SnackbarProvider, {
|
|
13
|
+
children: _jsx(BookingForm, { ...props
|
|
14
|
+
})
|
|
15
|
+
});
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const BookingForm = ({
|
|
19
|
+
lang,
|
|
20
|
+
resort,
|
|
21
|
+
channel = "ESF",
|
|
22
|
+
merchant,
|
|
23
|
+
integration = false,
|
|
24
|
+
uat = false,
|
|
25
|
+
noInitialScroll
|
|
26
|
+
}) => {
|
|
27
|
+
const ref = React.useRef();
|
|
28
|
+
const [fields, setFields] = React.useState(FIELDS);
|
|
29
|
+
const [step, setStep] = React.useState(STEPS.LESSONS);
|
|
30
|
+
const [lessons, setLessons] = React.useState([]);
|
|
31
|
+
const [personalData, setPersonalData] = React.useState({});
|
|
32
|
+
|
|
33
|
+
const _lang = lang === "fr" ? "fr" : "en";
|
|
34
|
+
|
|
35
|
+
const clearForm = () => {
|
|
36
|
+
setStep(STEPS.LESSONS);
|
|
37
|
+
setLessons([]);
|
|
38
|
+
setPersonalData({});
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
React.useEffect(() => {
|
|
42
|
+
const bookinForm = ref.current;
|
|
43
|
+
if (noInitialScroll || !bookinForm) return;
|
|
44
|
+
bookinForm.scrollIntoView(true);
|
|
45
|
+
}, [noInitialScroll, step]);
|
|
46
|
+
useCustomFields(FIELDS, setFields);
|
|
47
|
+
return _jsxs("div", {
|
|
48
|
+
className: css.root,
|
|
49
|
+
children: [_jsx("div", {
|
|
50
|
+
ref: ref,
|
|
51
|
+
className: css.anchor
|
|
52
|
+
}), _jsxs("div", {
|
|
53
|
+
className: css.inner,
|
|
54
|
+
children: [_jsx(ProgressBar, {
|
|
55
|
+
lang: _lang,
|
|
56
|
+
step: step
|
|
57
|
+
}), _jsx(Steps, {
|
|
58
|
+
lang: lang,
|
|
59
|
+
step: step,
|
|
60
|
+
setStep: setStep,
|
|
61
|
+
fields: fields,
|
|
62
|
+
lessons: lessons,
|
|
63
|
+
setLessons: setLessons,
|
|
64
|
+
personalData: personalData,
|
|
65
|
+
setPersonalData: setPersonalData,
|
|
66
|
+
clearForm: clearForm,
|
|
67
|
+
config: {
|
|
68
|
+
channel,
|
|
69
|
+
resort,
|
|
70
|
+
merchant,
|
|
71
|
+
integration,
|
|
72
|
+
uat
|
|
73
|
+
}
|
|
74
|
+
})]
|
|
75
|
+
})]
|
|
76
|
+
});
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
export default BookingFormWithSnackbar;
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
.root {
|
|
2
|
+
position: relative;
|
|
3
|
+
width: 100%;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.root hr {
|
|
7
|
+
width: 100%;
|
|
8
|
+
height: 2px;
|
|
9
|
+
display: block;
|
|
10
|
+
background-color: var(--ds-grey-100, #f5f5f5);
|
|
11
|
+
border: 0;
|
|
12
|
+
border-radius: 2px;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.anchor {
|
|
16
|
+
position: absolute;
|
|
17
|
+
bottom: 0;
|
|
18
|
+
left: 0;
|
|
19
|
+
height: calc(100% + 180px);
|
|
20
|
+
width: 100%;
|
|
21
|
+
pointer-events: none;
|
|
22
|
+
touch-action: none;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
.inner {
|
|
26
|
+
width: 800px;
|
|
27
|
+
max-width: 100%;
|
|
28
|
+
display: flex;
|
|
29
|
+
flex-direction: column;
|
|
30
|
+
gap: 46px;
|
|
31
|
+
margin: 30px auto;
|
|
32
|
+
padding: 25px 10px;
|
|
33
|
+
background-color: var(--ds-grey-000, #ffffff);
|
|
34
|
+
border-radius: var(--ds-radius-100, 6px);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
@media (min-width: 580px) {
|
|
38
|
+
.inner {
|
|
39
|
+
padding: 25px;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -136,6 +136,7 @@ const data = {
|
|
|
136
136
|
required: true
|
|
137
137
|
},
|
|
138
138
|
lastName: {
|
|
139
|
+
icon: "User",
|
|
139
140
|
type: "text",
|
|
140
141
|
label: {
|
|
141
142
|
fr: "Nom",
|
|
@@ -144,6 +145,7 @@ const data = {
|
|
|
144
145
|
required: true
|
|
145
146
|
},
|
|
146
147
|
firstName: {
|
|
148
|
+
icon: "User",
|
|
147
149
|
type: "text",
|
|
148
150
|
label: {
|
|
149
151
|
fr: "Prénom",
|
|
@@ -152,6 +154,7 @@ const data = {
|
|
|
152
154
|
required: true
|
|
153
155
|
},
|
|
154
156
|
email: {
|
|
157
|
+
icon: "AtSign",
|
|
155
158
|
type: "email",
|
|
156
159
|
label: {
|
|
157
160
|
fr: "Email",
|
|
@@ -160,6 +163,7 @@ const data = {
|
|
|
160
163
|
required: true
|
|
161
164
|
},
|
|
162
165
|
phone: {
|
|
166
|
+
icon: "Smartphone",
|
|
163
167
|
type: "phone",
|
|
164
168
|
label: {
|
|
165
169
|
fr: "Téléphone",
|
|
@@ -168,6 +172,7 @@ const data = {
|
|
|
168
172
|
required: true
|
|
169
173
|
},
|
|
170
174
|
paymentMethod: {
|
|
175
|
+
icon: "CreditCard",
|
|
171
176
|
type: "select",
|
|
172
177
|
label: {
|
|
173
178
|
fr: "Moyen de paiment",
|
|
@@ -185,6 +190,7 @@ const data = {
|
|
|
185
190
|
fr: "Commentaire",
|
|
186
191
|
en: "Comment"
|
|
187
192
|
},
|
|
193
|
+
fullWidth: true,
|
|
188
194
|
required: false
|
|
189
195
|
}
|
|
190
196
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import Input from "dt-design-system/es/input";
|
|
3
|
+
import Select from "dt-design-system/es/select";
|
|
4
|
+
import Textarea from "dt-design-system/es/textarea";
|
|
4
5
|
import { message } from "./messages";
|
|
5
6
|
import { validate } from "./utils";
|
|
7
|
+
import css from "./field.module.css";
|
|
6
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
|
-
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
8
|
-
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
9
|
|
|
10
10
|
const getFieldLabel = (lang, label, required) => {
|
|
11
11
|
if (required) return label;
|
|
@@ -13,65 +13,77 @@ const getFieldLabel = (lang, label, required) => {
|
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
const getTag = type => {
|
|
16
|
-
if (type === "textarea") return
|
|
17
|
-
if (type === "select") return
|
|
18
|
-
return
|
|
16
|
+
if (type === "textarea") return Textarea;
|
|
17
|
+
if (type === "select") return Select;
|
|
18
|
+
return Input;
|
|
19
19
|
};
|
|
20
20
|
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
value:
|
|
25
|
-
|
|
26
|
-
required: required ? true : undefined
|
|
27
|
-
};
|
|
28
|
-
const inputProps = {
|
|
29
|
-
type
|
|
30
|
-
};
|
|
31
|
-
if (type === "textarea" || type === "select") return commonProps;
|
|
32
|
-
return { ...commonProps,
|
|
33
|
-
...inputProps
|
|
21
|
+
const getOptions = (lang, options) => {
|
|
22
|
+
const emptyOption = {
|
|
23
|
+
label: message(lang, "select"),
|
|
24
|
+
value: "",
|
|
25
|
+
disabled: true
|
|
34
26
|
};
|
|
27
|
+
const formatedOptions = options[lang].map(option => {
|
|
28
|
+
const isTitle = option[0] === "-" && option[1] === "-";
|
|
29
|
+
return {
|
|
30
|
+
label: option,
|
|
31
|
+
value: option,
|
|
32
|
+
disabled: isTitle
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
return [emptyOption, ...formatedOptions];
|
|
35
36
|
};
|
|
36
37
|
|
|
37
|
-
const
|
|
38
|
+
const Field = ({
|
|
38
39
|
lang,
|
|
39
|
-
|
|
40
|
+
index,
|
|
41
|
+
name,
|
|
42
|
+
field,
|
|
43
|
+
data,
|
|
44
|
+
setData
|
|
40
45
|
}) => {
|
|
41
|
-
if (!options) return null;
|
|
42
|
-
return _jsxs(_Fragment, {
|
|
43
|
-
children: [_jsx("option", {
|
|
44
|
-
value: "",
|
|
45
|
-
disabled: true,
|
|
46
|
-
children: message(lang, "select")
|
|
47
|
-
}), options[lang].map(option => {
|
|
48
|
-
const isTitle = option[0] === "-" && option[1] === "-";
|
|
49
|
-
return _jsx("option", {
|
|
50
|
-
value: option,
|
|
51
|
-
disabled: isTitle ? true : undefined,
|
|
52
|
-
children: option
|
|
53
|
-
}, option);
|
|
54
|
-
})]
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
const renderField = (lang, index, name, field, data, setData, setActivated, setValid, isArray) => {
|
|
59
46
|
const {
|
|
60
47
|
type,
|
|
48
|
+
icon,
|
|
49
|
+
label,
|
|
61
50
|
options,
|
|
51
|
+
required,
|
|
62
52
|
placeholder,
|
|
63
|
-
|
|
53
|
+
fullWidth,
|
|
54
|
+
hidden
|
|
64
55
|
} = field;
|
|
56
|
+
const isArray = Array.isArray(data);
|
|
57
|
+
const [activated, setActivated] = React.useState(false);
|
|
58
|
+
const [valid, setValid] = React.useState(validate(type, isArray ? data[index][name].value : data[name].value));
|
|
59
|
+
const isTitle = type === "title";
|
|
60
|
+
if (hidden) return null;
|
|
61
|
+
if (isTitle) return _jsx("div", {
|
|
62
|
+
children: label[lang]
|
|
63
|
+
});
|
|
64
|
+
const fieldLabel = getFieldLabel(lang, label[lang], required);
|
|
65
|
+
const isValid = activated && valid;
|
|
66
|
+
const commonProps = {
|
|
67
|
+
icon,
|
|
68
|
+
className: fullWidth ? css.fieldFullWidth : undefined,
|
|
69
|
+
label: fieldLabel,
|
|
70
|
+
value: isArray ? data[index][name].value : data[name].value,
|
|
71
|
+
placeholder: placeholder ? placeholder[lang] : undefined,
|
|
72
|
+
required: required ? true : undefined,
|
|
73
|
+
valid: isValid
|
|
74
|
+
};
|
|
75
|
+
const inputProps = {
|
|
76
|
+
type
|
|
77
|
+
};
|
|
65
78
|
const Tag = getTag(type);
|
|
66
|
-
const props =
|
|
79
|
+
const props = type === "textarea" || type === "select" ? commonProps : { ...commonProps,
|
|
80
|
+
...inputProps
|
|
81
|
+
};
|
|
67
82
|
|
|
68
|
-
const onChange =
|
|
69
|
-
const newValue = e.target.value;
|
|
83
|
+
const onChange = newValue => {
|
|
70
84
|
const newData = isArray ? [...data] : { ...data
|
|
71
85
|
};
|
|
72
86
|
isArray ? newData[index][name].value = newValue : newData[name].value = newValue;
|
|
73
|
-
setData(newData);
|
|
74
|
-
setActivated(true);
|
|
75
87
|
|
|
76
88
|
if (!required) {
|
|
77
89
|
setValid(true);
|
|
@@ -81,60 +93,24 @@ const renderField = (lang, index, name, field, data, setData, setActivated, setV
|
|
|
81
93
|
isArray ? newData[index][name].validator = isValid : newData[name].validator = isValid;
|
|
82
94
|
setValid(validate(type, newValue));
|
|
83
95
|
}
|
|
96
|
+
|
|
97
|
+
setData(newData);
|
|
98
|
+
setActivated(true);
|
|
84
99
|
};
|
|
85
100
|
|
|
86
|
-
if (
|
|
101
|
+
if (type === "select") {
|
|
102
|
+
const selectOptions = getOptions(lang, options);
|
|
87
103
|
return _jsx(Tag, {
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
lang: lang,
|
|
92
|
-
options: options
|
|
93
|
-
})
|
|
104
|
+
onValueChange: onChange,
|
|
105
|
+
options: selectOptions,
|
|
106
|
+
...props
|
|
94
107
|
});
|
|
95
108
|
} else {
|
|
96
109
|
return _jsx(Tag, {
|
|
97
|
-
|
|
110
|
+
onValueChange: onChange,
|
|
98
111
|
...props
|
|
99
112
|
});
|
|
100
113
|
}
|
|
101
114
|
};
|
|
102
115
|
|
|
103
|
-
const Field = ({
|
|
104
|
-
lang,
|
|
105
|
-
index,
|
|
106
|
-
name,
|
|
107
|
-
field,
|
|
108
|
-
data,
|
|
109
|
-
setData
|
|
110
|
-
}) => {
|
|
111
|
-
const {
|
|
112
|
-
type,
|
|
113
|
-
label,
|
|
114
|
-
required,
|
|
115
|
-
hidden
|
|
116
|
-
} = field;
|
|
117
|
-
const isArray = Array.isArray(data);
|
|
118
|
-
const [activated, setActivated] = useState(false);
|
|
119
|
-
const [valid, setValid] = useState(validate(type, isArray ? data[index][name].value : data[name].value));
|
|
120
|
-
const isTitle = type === "title";
|
|
121
|
-
if (hidden) return null;
|
|
122
|
-
const classes = classnames(`field field--${type}`, {
|
|
123
|
-
"field--invalid": !valid && activated,
|
|
124
|
-
"field--valid": valid
|
|
125
|
-
});
|
|
126
|
-
if (isTitle) return _jsx("div", {
|
|
127
|
-
className: classes,
|
|
128
|
-
children: label[lang]
|
|
129
|
-
});
|
|
130
|
-
const fieldLabel = getFieldLabel(lang, label[lang], required);
|
|
131
|
-
return _jsx("div", {
|
|
132
|
-
className: classes,
|
|
133
|
-
children: _jsxs("label", {
|
|
134
|
-
className: "field__label",
|
|
135
|
-
children: [fieldLabel, renderField(lang, index, name, field, data, setData, setActivated, setValid, isArray)]
|
|
136
|
-
})
|
|
137
|
-
});
|
|
138
|
-
};
|
|
139
|
-
|
|
140
116
|
export default Field;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
import { mergeDeep } from "../utils";
|
|
3
3
|
|
|
4
4
|
const useCustomFields = (fields, setFields) => {
|
|
@@ -6,7 +6,7 @@ const useCustomFields = (fields, setFields) => {
|
|
|
6
6
|
groupLessons,
|
|
7
7
|
data
|
|
8
8
|
} = fields;
|
|
9
|
-
useEffect(() => {
|
|
9
|
+
React.useEffect(() => {
|
|
10
10
|
window.BFCustomFields = window.BFCustomFields || {};
|
|
11
11
|
window.BFCustomFields.fields = window.BFCustomFields.fields || {};
|
|
12
12
|
window.BFCustomFields.data = window.BFCustomFields.data || {};
|
|
@@ -1,12 +1,15 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as React from "react";
|
|
2
2
|
|
|
3
3
|
const useStay = () => {
|
|
4
|
-
const [stay, setStay] = useState();
|
|
5
|
-
useEffect(() => {
|
|
6
|
-
const
|
|
7
|
-
|
|
4
|
+
const [stay, setStay] = React.useState();
|
|
5
|
+
React.useEffect(() => {
|
|
6
|
+
const storedStay = window.sessionStorage.getItem("stay");
|
|
7
|
+
|
|
8
|
+
if (storedStay) {
|
|
9
|
+
setStay(JSON.parse(storedStay));
|
|
10
|
+
}
|
|
8
11
|
}, []);
|
|
9
|
-
return
|
|
12
|
+
return stay;
|
|
10
13
|
};
|
|
11
14
|
|
|
12
15
|
export default useStay;
|