ublo-lib 1.0.21 → 1.0.24
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/cookie-consent/cookie-consent.js +1 -1
- package/es/common/components/custom-contact-form/custom-contact-form.js +16 -19
- package/es/common/components/custom-contact-form/{index.module.css → custom-contact-form.module.css} +0 -0
- package/es/common/components/custom-contact-form/field.js +10 -3
- package/es/lbm/components/msem-linker/editor/messages.js +1 -0
- package/es/lbm/components/msem-linker/editor/ski-pass.js +66 -14
- package/es/lbm/components/msem-linker/msem-linker.module.css +1 -0
- package/package.json +4 -2
|
@@ -7,7 +7,7 @@ import Button from "dt-design-system/es/button";
|
|
|
7
7
|
import * as Messages from "./messages";
|
|
8
8
|
import * as Icons from "./icons";
|
|
9
9
|
import * as DTIcons from "dt-design-system/es/icons";
|
|
10
|
-
import styles from "./
|
|
10
|
+
import styles from "./custom-contact-form.module.css";
|
|
11
11
|
import { getInitialFormState, getSettings, send } from "./utils";
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
13
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
@@ -20,20 +20,17 @@ const CustomContactFormWithSnackbar = props => {
|
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
const CustomContactForm = ({
|
|
23
|
-
formTitle,
|
|
24
|
-
fields,
|
|
25
23
|
kind,
|
|
26
|
-
|
|
24
|
+
title,
|
|
25
|
+
fields,
|
|
27
26
|
presets,
|
|
28
|
-
setPresets,
|
|
29
|
-
allowPresetsReset,
|
|
30
|
-
subjectPrefix,
|
|
31
|
-
subjectSuffix,
|
|
32
27
|
className,
|
|
33
28
|
innerClassName,
|
|
29
|
+
subject,
|
|
30
|
+
onSubmit,
|
|
34
31
|
customSend
|
|
35
32
|
}) => {
|
|
36
|
-
const [data, setData] = React.useState(getInitialFormState(fields, presets));
|
|
33
|
+
const [data, setData] = React.useState(getInitialFormState(fields, presets?.values));
|
|
37
34
|
const [sending, setSending] = React.useState(false);
|
|
38
35
|
const [ready, setReady] = React.useState(false);
|
|
39
36
|
const [settings, setSettings] = React.useState();
|
|
@@ -57,8 +54,8 @@ const CustomContactForm = ({
|
|
|
57
54
|
site,
|
|
58
55
|
data,
|
|
59
56
|
fields,
|
|
60
|
-
subjectPrefix,
|
|
61
|
-
subjectSuffix
|
|
57
|
+
subjectPrefix: subject?.prefix,
|
|
58
|
+
subjectSuffix: subject?.suffix
|
|
62
59
|
});
|
|
63
60
|
|
|
64
61
|
if (error) {
|
|
@@ -84,7 +81,7 @@ const CustomContactForm = ({
|
|
|
84
81
|
};
|
|
85
82
|
|
|
86
83
|
const resetForm = () => {
|
|
87
|
-
|
|
84
|
+
presets.setter?.(undefined);
|
|
88
85
|
setData(getInitialFormState(fields));
|
|
89
86
|
};
|
|
90
87
|
|
|
@@ -104,8 +101,8 @@ const CustomContactForm = ({
|
|
|
104
101
|
}
|
|
105
102
|
}, [ready, settings, site]);
|
|
106
103
|
React.useEffect(() => {
|
|
107
|
-
setData(getInitialFormState(fields, presets));
|
|
108
|
-
}, [fields, presets]);
|
|
104
|
+
setData(getInitialFormState(fields, presets.values));
|
|
105
|
+
}, [fields, presets?.values]);
|
|
109
106
|
const classes = classnames(styles.root, {
|
|
110
107
|
[className]: className
|
|
111
108
|
});
|
|
@@ -122,12 +119,12 @@ const CustomContactForm = ({
|
|
|
122
119
|
});
|
|
123
120
|
}
|
|
124
121
|
|
|
125
|
-
const formKey = presets ? JSON.stringify(presets) : undefined;
|
|
122
|
+
const formKey = presets ? JSON.stringify(presets.values) : undefined;
|
|
126
123
|
return _jsxs("div", {
|
|
127
124
|
className: classes,
|
|
128
|
-
children: [
|
|
125
|
+
children: [title && _jsx("div", {
|
|
129
126
|
className: styles.title,
|
|
130
|
-
children:
|
|
127
|
+
children: title
|
|
131
128
|
}), _jsx("div", {
|
|
132
129
|
className: innerClasses,
|
|
133
130
|
children: Object.keys(fields).map(key => _jsx(Field, {
|
|
@@ -137,11 +134,11 @@ const CustomContactForm = ({
|
|
|
137
134
|
data: data,
|
|
138
135
|
setData: setData,
|
|
139
136
|
settings: settings,
|
|
140
|
-
presets: presets
|
|
137
|
+
presets: presets?.values
|
|
141
138
|
}, key))
|
|
142
139
|
}, formKey), _jsxs("div", {
|
|
143
140
|
className: styles.bottom,
|
|
144
|
-
children: [presets &&
|
|
141
|
+
children: [presets?.allowReset && _jsx(Button, {
|
|
145
142
|
className: styles.resetButton,
|
|
146
143
|
disabled: sending,
|
|
147
144
|
onClick: resetForm,
|
package/es/common/components/custom-contact-form/{index.module.css → custom-contact-form.module.css}
RENAMED
|
File without changes
|
|
@@ -38,11 +38,18 @@ const getProps = (type, name, className, data, required, placeholder, autoSizing
|
|
|
38
38
|
className,
|
|
39
39
|
value: data[name].value,
|
|
40
40
|
placeholder,
|
|
41
|
-
required
|
|
42
|
-
autoSizing
|
|
41
|
+
required
|
|
43
42
|
};
|
|
44
43
|
|
|
45
|
-
if (type === "textarea"
|
|
44
|
+
if (type === "textarea") {
|
|
45
|
+
return {
|
|
46
|
+
onValueChange: onChange,
|
|
47
|
+
autoSizing,
|
|
48
|
+
...commonProps
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (type === "select") {
|
|
46
53
|
return {
|
|
47
54
|
onValueChange: onChange,
|
|
48
55
|
...commonProps
|
|
@@ -14,6 +14,16 @@ import styles from "./ski-pass.module.css";
|
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
16
|
import { Fragment as _Fragment } from "react/jsx-runtime";
|
|
17
|
+
const ACTIVITIES_LABELS = {
|
|
18
|
+
piscine: "Piscine",
|
|
19
|
+
patinoire: "Patinoire",
|
|
20
|
+
vtt: "VTT",
|
|
21
|
+
ski: "Ski",
|
|
22
|
+
"acces-pieton": "Accès piéton",
|
|
23
|
+
"bouee-neige": "Bouée sur neige",
|
|
24
|
+
"ski-activite": "Ski + Activités",
|
|
25
|
+
luge: "Luge sur rails"
|
|
26
|
+
};
|
|
17
27
|
const DEFAULT_DATA = {
|
|
18
28
|
stayFrom: "",
|
|
19
29
|
stayTo: "",
|
|
@@ -30,6 +40,7 @@ const getDefaultData = config => {
|
|
|
30
40
|
stay,
|
|
31
41
|
skiers,
|
|
32
42
|
firstSkiDate,
|
|
43
|
+
activities,
|
|
33
44
|
domains,
|
|
34
45
|
durations
|
|
35
46
|
} = config.presets;
|
|
@@ -38,6 +49,7 @@ const getDefaultData = config => {
|
|
|
38
49
|
stayTo: stay?.to || DEFAULT_DATA.stayTo,
|
|
39
50
|
skiers: skiers || DEFAULT_DATA.skiers,
|
|
40
51
|
firstSkiDate: firstSkiDate || DEFAULT_DATA.firstSkiDate,
|
|
52
|
+
activities: activities || DEFAULT_DATA.activities,
|
|
41
53
|
domains: domains || DEFAULT_DATA.domains,
|
|
42
54
|
durations: durations || DEFAULT_DATA.durations
|
|
43
55
|
};
|
|
@@ -81,6 +93,47 @@ const SkiPass = ({
|
|
|
81
93
|
value: catalog,
|
|
82
94
|
label: catalog
|
|
83
95
|
}))];
|
|
96
|
+
const activities = [...new Set(filters?.domains?.reduce((acc, domain) => {
|
|
97
|
+
const {
|
|
98
|
+
tags
|
|
99
|
+
} = domain;
|
|
100
|
+
if (!tags?.length) return acc;
|
|
101
|
+
const formatedTags = tags.filter(tag => {
|
|
102
|
+
return Object.keys(ACTIVITIES_LABELS).includes(tag) && !acc.some(item => item.value === tag);
|
|
103
|
+
}).map(tag => {
|
|
104
|
+
return {
|
|
105
|
+
value: tag,
|
|
106
|
+
label: ACTIVITIES_LABELS[tag] || tag
|
|
107
|
+
};
|
|
108
|
+
});
|
|
109
|
+
return [...acc, ...formatedTags];
|
|
110
|
+
}, []))];
|
|
111
|
+
const selectedActivities = data.activities.map(activity => activities.find(a => a.value === activity));
|
|
112
|
+
const selectedActivitiesCodes = activities.reduce((acc, activity) => {
|
|
113
|
+
const {
|
|
114
|
+
value
|
|
115
|
+
} = activity;
|
|
116
|
+
return data.activities?.includes(value) ? [...new Set([...acc, value])] : acc;
|
|
117
|
+
}, []);
|
|
118
|
+
const filteredDomains = selectedActivitiesCodes?.length > 0 ? filters.domains?.filter(domain => {
|
|
119
|
+
return domain.tags?.some(tag => {
|
|
120
|
+
return selectedActivitiesCodes.includes(tag);
|
|
121
|
+
});
|
|
122
|
+
}) : filters?.domains;
|
|
123
|
+
const selectedDomainsIds = filters?.domains.reduce((acc, domain) => {
|
|
124
|
+
const {
|
|
125
|
+
code,
|
|
126
|
+
catalogIds
|
|
127
|
+
} = domain;
|
|
128
|
+
return data.domains.includes(code) ? [...new Set([...acc, ...catalogIds])] : acc;
|
|
129
|
+
}, []);
|
|
130
|
+
const filteredDurations = selectedActivitiesCodes?.length > 0 ? filters.durations?.filter(duration => {
|
|
131
|
+
return duration.tags?.some(tag => {
|
|
132
|
+
return selectedActivitiesCodes.includes(tag) || duration.catalogIds.some(id => selectedDomainsIds.includes(id));
|
|
133
|
+
});
|
|
134
|
+
}) : filters?.durations;
|
|
135
|
+
const selectedDomains = data.domains.map(domain => filters?.domains?.find(d => d.value === domain));
|
|
136
|
+
const selectedDurations = data.durations.map(domain => filters?.durations?.find(d => d.value === domain));
|
|
84
137
|
|
|
85
138
|
const updateField = field => value => {
|
|
86
139
|
const isFrom = field === "stayFrom";
|
|
@@ -195,12 +248,14 @@ const SkiPass = ({
|
|
|
195
248
|
to: stayTo
|
|
196
249
|
} : undefined;
|
|
197
250
|
const skiers = data.skiers?.length > 0 ? data.skiers : undefined;
|
|
251
|
+
const activities = data.activities.length > 0 ? data.activities : undefined;
|
|
198
252
|
const domains = data.domains.length > 0 ? data.domains : undefined;
|
|
199
253
|
const durations = data.durations.length > 0 ? data.durations : undefined;
|
|
200
254
|
const presets = {
|
|
201
255
|
stay,
|
|
202
256
|
skiers,
|
|
203
257
|
firstSkiDate,
|
|
258
|
+
activities,
|
|
204
259
|
domains,
|
|
205
260
|
durations
|
|
206
261
|
};
|
|
@@ -250,16 +305,6 @@ const SkiPass = ({
|
|
|
250
305
|
}));
|
|
251
306
|
};
|
|
252
307
|
|
|
253
|
-
const selectedDomainsIds = filters?.domains.reduce((acc, domain) => {
|
|
254
|
-
const {
|
|
255
|
-
code,
|
|
256
|
-
catalogIds
|
|
257
|
-
} = domain;
|
|
258
|
-
return data.domains.includes(code) ? [...new Set([...acc, ...catalogIds])] : acc;
|
|
259
|
-
}, []);
|
|
260
|
-
const filteredDurations = selectedDomainsIds?.length > 0 ? filters?.durations?.filter(duration => duration.catalogIds.some(id => selectedDomainsIds.includes(id))) : filters?.durations;
|
|
261
|
-
const selectedDomains = data.domains.map(domain => filters?.domains?.find(d => d.value === domain));
|
|
262
|
-
const selectedDurations = data.durations.map(domain => filters?.durations?.find(d => d.value === domain));
|
|
263
308
|
return _jsxs("div", {
|
|
264
309
|
className: styles.skiPass,
|
|
265
310
|
children: [_jsx("div", {
|
|
@@ -322,20 +367,27 @@ const SkiPass = ({
|
|
|
322
367
|
}), _jsx("div", {
|
|
323
368
|
className: styles.label,
|
|
324
369
|
children: messages.filters
|
|
370
|
+
}), activities.length > 1 && _jsx(MutlipleSelect, {
|
|
371
|
+
placeholder: "Selectionnez une ou plusieurs options",
|
|
372
|
+
label: messages.activities,
|
|
373
|
+
options: activities,
|
|
374
|
+
values: selectedActivities,
|
|
375
|
+
onChange: updateFilter("activities")
|
|
325
376
|
}), _jsxs("div", {
|
|
326
377
|
className: styles.row,
|
|
327
|
-
children: [
|
|
378
|
+
children: [filteredDomains.length > 0 && _jsx(MutlipleSelect, {
|
|
328
379
|
placeholder: "Selectionnez une ou plusieurs options",
|
|
329
380
|
label: messages.domains,
|
|
330
|
-
options:
|
|
381
|
+
options: filteredDomains,
|
|
331
382
|
values: selectedDomains,
|
|
332
383
|
onChange: updateFilter("domains")
|
|
333
|
-
}),
|
|
384
|
+
}), filteredDurations.length > 0 && _jsx(MutlipleSelect, {
|
|
334
385
|
placeholder: "Selectionnez une ou plusieurs options",
|
|
335
386
|
label: messages.durations,
|
|
336
387
|
options: filteredDurations,
|
|
337
388
|
values: selectedDurations,
|
|
338
|
-
onChange: updateFilter("durations")
|
|
389
|
+
onChange: updateFilter("durations"),
|
|
390
|
+
disabled: data.domains?.length === 0
|
|
339
391
|
})]
|
|
340
392
|
}), widgetUrl && _jsxs(_Fragment, {
|
|
341
393
|
children: [_jsx("div", {
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ublo-lib",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"peerDependencies": {
|
|
5
|
+
"dt-design-system": "^2.0.0",
|
|
6
|
+
"next": "^12.0.0",
|
|
5
7
|
"react": "^18.2.0",
|
|
6
8
|
"react-dom": "^18.2.0",
|
|
7
|
-
"dt-design-system": "^2.0.0",
|
|
8
9
|
"ublo": "^2.0.0"
|
|
9
10
|
},
|
|
10
11
|
"dependencies": {
|
|
@@ -31,6 +32,7 @@
|
|
|
31
32
|
"eslint-plugin-promise": "^6.0.1",
|
|
32
33
|
"eslint-plugin-react": "^7.31.7",
|
|
33
34
|
"eslint-plugin-react-hooks": "^4.6.0",
|
|
35
|
+
"next": "^12.0.0",
|
|
34
36
|
"react": "^18.2.0",
|
|
35
37
|
"react-dom": "^18.2.0",
|
|
36
38
|
"react-scripts": "5.0.1",
|