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.
@@ -29,7 +29,7 @@ const CookieConsent = ({
29
29
  setMounted(true);
30
30
 
31
31
  if (!isEnabled) {
32
- updateConsent(false);
32
+ updateConsent(true);
33
33
  }
34
34
  }
35
35
  }, [isEnabled, mounted]);
@@ -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 "./index.module.css";
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
- onSubmit,
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
- setPresets?.(undefined);
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: [formTitle && _jsx("div", {
125
+ children: [title && _jsx("div", {
129
126
  className: styles.title,
130
- children: formTitle
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 && allowPresetsReset && _jsx(Button, {
141
+ children: [presets?.allowReset && _jsx(Button, {
145
142
  className: styles.resetButton,
146
143
  disabled: sending,
147
144
  onClick: resetForm,
@@ -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" || type === "select") {
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
@@ -17,6 +17,7 @@ const messages = {
17
17
  rooms: "Chambres",
18
18
  nbRooms: "Nombre de chambres",
19
19
  roomType: "Type de chambre",
20
+ activities: "Activités",
20
21
  domains: "Domaines",
21
22
  durations: "Durées",
22
23
  skiers: "Personnes",
@@ -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: [filters?.domains?.length > 1 && _jsx(MutlipleSelect, {
378
+ children: [filteredDomains.length > 0 && _jsx(MutlipleSelect, {
328
379
  placeholder: "Selectionnez une ou plusieurs options",
329
380
  label: messages.domains,
330
- options: filters.domains,
381
+ options: filteredDomains,
331
382
  values: selectedDomains,
332
383
  onChange: updateFilter("domains")
333
- }), data.domains?.length > 0 && filteredDurations?.length > 1 && _jsx(MutlipleSelect, {
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", {
@@ -100,6 +100,7 @@
100
100
  var(--cms-primary-color, #004cc2)
101
101
  )
102
102
  );
103
+ font-family: "Open Sans", sans-serif;
103
104
  border-radius: var(--cms-radius-300, 15px);
104
105
  pointer-events: none;
105
106
  touch-action: none;
package/package.json CHANGED
@@ -1,10 +1,11 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.0.21",
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",