ublo-lib 1.30.11 → 1.31.1
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/esf/components/account-button/account-button.module.css +6 -0
- package/es/esf/components/period-picker/controls.js +10 -8
- package/es/esf/components/period-picker/date-display.js +3 -4
- package/es/esf/components/period-picker/days.js +51 -51
- package/es/esf/components/period-picker/extended-stay-picker.js +3 -4
- package/es/esf/components/period-picker/messages.js +58 -7
- package/es/esf/components/period-picker/period-picker.js +3 -4
- package/es/esf/components/period-picker/period-picker.module.css +2 -2
- package/es/esf/components/period-picker/popup.js +3 -4
- package/es/esf/components/period-picker/services/dates.js +24 -22
- package/es/esf/components/period-picker/services/events.js +2 -2
- package/es/esf/components/period-picker/services/stay.js +4 -4
- package/es/esf/components/period-picker/title.js +3 -4
- package/es/esf/components/period-picker/title.module.css +1 -2
- package/es/esf/components/period-picker/warning.js +3 -4
- package/es/esf/components/period-picker/weeks.js +70 -35
- package/es/esf/components/period-picker/weeks.module.css +61 -4
- package/package.json +1 -1
- package/es/esf/components/period-picker/services/utils.js +0 -0
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import Button from "dt-design-system/es/button";
|
|
2
3
|
import * as Icons from "dt-design-system/es/icons";
|
|
3
4
|
import css from "./controls.module.css";
|
|
4
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
5
6
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
6
7
|
const LEFT = 0;
|
|
7
8
|
const RIGHT = 1;
|
|
8
|
-
|
|
9
|
+
export default function Controls({
|
|
9
10
|
barRef,
|
|
10
11
|
distance
|
|
11
|
-
})
|
|
12
|
+
}) {
|
|
12
13
|
const scrollTo = direction => () => {
|
|
13
14
|
const bar = barRef.current;
|
|
14
15
|
if (!bar) return;
|
|
@@ -22,21 +23,22 @@ const Controls = ({
|
|
|
22
23
|
};
|
|
23
24
|
return _jsxs("div", {
|
|
24
25
|
className: css.controls,
|
|
25
|
-
children: [_jsx(
|
|
26
|
+
children: [_jsx(Button, {
|
|
27
|
+
variant: "transparent",
|
|
26
28
|
className: css.control,
|
|
27
29
|
onClick: scrollTo(LEFT),
|
|
28
30
|
"aria-label": "Previous",
|
|
29
|
-
children: _jsx(Icons.
|
|
31
|
+
children: _jsx(Icons.ArrowLeft, {
|
|
30
32
|
className: css.icon
|
|
31
33
|
})
|
|
32
|
-
}), _jsx(
|
|
34
|
+
}), _jsx(Button, {
|
|
35
|
+
variant: "transparent",
|
|
33
36
|
className: css.control,
|
|
34
37
|
onClick: scrollTo(RIGHT),
|
|
35
38
|
"aria-label": "Next",
|
|
36
|
-
children: _jsx(Icons.
|
|
39
|
+
children: _jsx(Icons.ArrowRight, {
|
|
37
40
|
className: css.icon
|
|
38
41
|
})
|
|
39
42
|
})]
|
|
40
43
|
});
|
|
41
|
-
}
|
|
42
|
-
export default Controls;
|
|
44
|
+
}
|
|
@@ -8,9 +8,9 @@ import * as Motions from "./services/motions";
|
|
|
8
8
|
import css from "./date-display.module.css";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
|
|
11
|
+
export default function DateDisplay({
|
|
12
12
|
className
|
|
13
|
-
})
|
|
13
|
+
}) {
|
|
14
14
|
const [stay, setStay] = React.useState();
|
|
15
15
|
const {
|
|
16
16
|
lang,
|
|
@@ -64,5 +64,4 @@ const DateDisplay = ({
|
|
|
64
64
|
}, `${word}-${index}`))
|
|
65
65
|
})]
|
|
66
66
|
});
|
|
67
|
-
}
|
|
68
|
-
export default DateDisplay;
|
|
67
|
+
}
|
|
@@ -5,14 +5,62 @@ import * as Dates from "./services/dates";
|
|
|
5
5
|
import css from "./days.module.css";
|
|
6
6
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
7
7
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
8
|
-
const
|
|
8
|
+
const Days = React.forwardRef(({
|
|
9
|
+
lang,
|
|
10
|
+
fullStay,
|
|
11
|
+
interval,
|
|
12
|
+
onChange
|
|
13
|
+
}, ref) => {
|
|
14
|
+
const [firstSelected, setFirstSelected] = React.useState();
|
|
15
|
+
const updateSelection = day => e => {
|
|
16
|
+
e.stopPropagation();
|
|
17
|
+
if (firstSelected) {
|
|
18
|
+
const isBefore = firstSelected.getTime() > day.getTime();
|
|
19
|
+
const range = {
|
|
20
|
+
from: Dates.format(isBefore ? day : firstSelected),
|
|
21
|
+
to: Dates.format(isBefore ? firstSelected : day)
|
|
22
|
+
};
|
|
23
|
+
Stay.update(range);
|
|
24
|
+
if (typeof onChange === "function") {
|
|
25
|
+
onChange(range);
|
|
26
|
+
}
|
|
27
|
+
cancelSelection();
|
|
28
|
+
} else {
|
|
29
|
+
setFirstSelected(day);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
const cancelSelection = () => {
|
|
33
|
+
setFirstSelected(undefined);
|
|
34
|
+
};
|
|
35
|
+
React.useEffect(() => {
|
|
36
|
+
window.addEventListener("click", cancelSelection);
|
|
37
|
+
return () => {
|
|
38
|
+
window.removeEventListener("click", cancelSelection);
|
|
39
|
+
};
|
|
40
|
+
}, []);
|
|
41
|
+
return _jsx("div", {
|
|
42
|
+
ref: ref,
|
|
43
|
+
className: css.days,
|
|
44
|
+
children: interval.map((day, i) => _jsx(Day, {
|
|
45
|
+
index: i,
|
|
46
|
+
lang: lang,
|
|
47
|
+
day: day,
|
|
48
|
+
fullStay: fullStay,
|
|
49
|
+
firstSelected: firstSelected,
|
|
50
|
+
updateSelection: updateSelection
|
|
51
|
+
}, day))
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
Days.displayName = "Days";
|
|
55
|
+
export default Days;
|
|
56
|
+
function Day({
|
|
9
57
|
lang,
|
|
10
58
|
index,
|
|
11
59
|
day,
|
|
12
60
|
fullStay,
|
|
13
61
|
firstSelected,
|
|
14
62
|
updateSelection
|
|
15
|
-
})
|
|
63
|
+
}) {
|
|
16
64
|
const locale = Dates.locales[lang] || Dates.locales.en;
|
|
17
65
|
const isFirstDayOfStay = day.getTime() === fullStay[0]?.getTime();
|
|
18
66
|
const isLastDayOfStay = day.getTime() === fullStay[fullStay.length - 1].getTime();
|
|
@@ -60,52 +108,4 @@ const Day = ({
|
|
|
60
108
|
children: formatedMonth
|
|
61
109
|
})]
|
|
62
110
|
});
|
|
63
|
-
}
|
|
64
|
-
const Days = React.forwardRef(({
|
|
65
|
-
lang,
|
|
66
|
-
fullStay,
|
|
67
|
-
interval,
|
|
68
|
-
onChange
|
|
69
|
-
}, ref) => {
|
|
70
|
-
const [firstSelected, setFirstSelected] = React.useState();
|
|
71
|
-
const updateSelection = day => e => {
|
|
72
|
-
e.stopPropagation();
|
|
73
|
-
if (firstSelected) {
|
|
74
|
-
const isBefore = firstSelected.getTime() > day.getTime();
|
|
75
|
-
const range = {
|
|
76
|
-
from: Dates.format(isBefore ? day : firstSelected),
|
|
77
|
-
to: Dates.format(isBefore ? firstSelected : day)
|
|
78
|
-
};
|
|
79
|
-
Stay.update(range);
|
|
80
|
-
if (typeof onChange === "function") {
|
|
81
|
-
onChange(range);
|
|
82
|
-
}
|
|
83
|
-
cancelSelection();
|
|
84
|
-
} else {
|
|
85
|
-
setFirstSelected(day);
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
const cancelSelection = () => {
|
|
89
|
-
setFirstSelected(undefined);
|
|
90
|
-
};
|
|
91
|
-
React.useEffect(() => {
|
|
92
|
-
window.addEventListener("click", cancelSelection);
|
|
93
|
-
return () => {
|
|
94
|
-
window.removeEventListener("click", cancelSelection);
|
|
95
|
-
};
|
|
96
|
-
}, []);
|
|
97
|
-
return _jsx("div", {
|
|
98
|
-
ref: ref,
|
|
99
|
-
className: css.days,
|
|
100
|
-
children: interval.map((day, i) => _jsx(Day, {
|
|
101
|
-
index: i,
|
|
102
|
-
lang: lang,
|
|
103
|
-
day: day,
|
|
104
|
-
fullStay: fullStay,
|
|
105
|
-
firstSelected: firstSelected,
|
|
106
|
-
updateSelection: updateSelection
|
|
107
|
-
}, day))
|
|
108
|
-
});
|
|
109
|
-
});
|
|
110
|
-
Days.displayName = "Days";
|
|
111
|
-
export default Days;
|
|
111
|
+
}
|
|
@@ -8,7 +8,7 @@ import * as Messages from "./messages";
|
|
|
8
8
|
import css from "./extended-stay-picker.module.css";
|
|
9
9
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
10
10
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
|
-
|
|
11
|
+
export default function ExtendedStayPicker({
|
|
12
12
|
lang,
|
|
13
13
|
stay,
|
|
14
14
|
extend,
|
|
@@ -18,7 +18,7 @@ const ExtendedStayPicker = ({
|
|
|
18
18
|
opened,
|
|
19
19
|
setExtendedOpened,
|
|
20
20
|
onChange
|
|
21
|
-
})
|
|
21
|
+
}) {
|
|
22
22
|
const barRef = React.useRef();
|
|
23
23
|
const startDate = Dates.weekToDate(week, endWeek, forceSeasonSwitch);
|
|
24
24
|
const endDate = Dates.weekToDate(week + 1, endWeek, forceSeasonSwitch);
|
|
@@ -53,5 +53,4 @@ const ExtendedStayPicker = ({
|
|
|
53
53
|
})]
|
|
54
54
|
})
|
|
55
55
|
});
|
|
56
|
-
}
|
|
57
|
-
export default ExtendedStayPicker;
|
|
56
|
+
}
|
|
@@ -8,10 +8,13 @@ const messages = {
|
|
|
8
8
|
"update-period": "Choisir une autre plage de dates",
|
|
9
9
|
offers: "Les offres pour la période du",
|
|
10
10
|
to: "au",
|
|
11
|
-
"extended-title": "Vous pouvez ajuster vos dates de séjour"
|
|
11
|
+
"extended-title": "Vous pouvez ajuster vos dates de séjour",
|
|
12
|
+
"low-period": "Basse saison",
|
|
13
|
+
"medium-period": "Saison",
|
|
14
|
+
"high-period": "Haute saison"
|
|
12
15
|
},
|
|
13
16
|
en: {
|
|
14
|
-
title: "<
|
|
17
|
+
title: "<b>When</b> are you coming?",
|
|
15
18
|
"selected-title": "You are coming from",
|
|
16
19
|
warn: "Warning, if you change your dates of stay, products in your cart will be removed",
|
|
17
20
|
ok: "Confirm",
|
|
@@ -19,10 +22,55 @@ const messages = {
|
|
|
19
22
|
"update-period": "Update your stay",
|
|
20
23
|
offers: "Offers for the period from",
|
|
21
24
|
to: "to",
|
|
22
|
-
"extended-title": "You are coming more precisely"
|
|
25
|
+
"extended-title": "You are coming more precisely",
|
|
26
|
+
"low-period": "Low season",
|
|
27
|
+
"medium-period": "Season",
|
|
28
|
+
"high-period": "High season"
|
|
29
|
+
},
|
|
30
|
+
es: {
|
|
31
|
+
title: "<b>¿Cuándo</b> vienes?",
|
|
32
|
+
"selected-title": "Vienes de",
|
|
33
|
+
warn: "Advertencia, si cambias tus fechas de estancia, se vaciará tu carrito",
|
|
34
|
+
ok: "Confirmar",
|
|
35
|
+
cancel: "Cancelar",
|
|
36
|
+
"update-period": "Actualizar tu estancia",
|
|
37
|
+
offers: "Ofertas para el periodo del",
|
|
38
|
+
to: "al",
|
|
39
|
+
"extended-title": "Vienes más precisamente",
|
|
40
|
+
"low-period": "Temporada baja",
|
|
41
|
+
"medium-period": "Temporada",
|
|
42
|
+
"high-period": "Temporada alta"
|
|
43
|
+
},
|
|
44
|
+
ca: {
|
|
45
|
+
title: "<b>Quan</b> vens?",
|
|
46
|
+
"selected-title": "Vens de",
|
|
47
|
+
warn: "Atenció, si canvies les teves dates d'estada, s'esborrarà el teu carretó",
|
|
48
|
+
ok: "Confirmar",
|
|
49
|
+
cancel: "Cancel·lar",
|
|
50
|
+
"update-period": "Actualitzar la teva estada",
|
|
51
|
+
offers: "Ofertes per al període del",
|
|
52
|
+
to: "al",
|
|
53
|
+
"extended-title": "Vens més precisament",
|
|
54
|
+
"low-period": "Temporada baixa",
|
|
55
|
+
"medium-period": "Temporada",
|
|
56
|
+
"high-period": "Temporada alta"
|
|
57
|
+
},
|
|
58
|
+
it: {
|
|
59
|
+
title: "<b>Quando</b> vieni?",
|
|
60
|
+
"selected-title": "Vieni da",
|
|
61
|
+
warn: "Attenzione, se modifichi le date del tuo soggiorno, il tuo carrello sarà svuotato",
|
|
62
|
+
ok: "Confermare",
|
|
63
|
+
cancel: "Annullare",
|
|
64
|
+
"update-period": "Aggiorna il tuo soggiorno",
|
|
65
|
+
offers: "Offerte per il periodo dal",
|
|
66
|
+
to: "al",
|
|
67
|
+
"extended-title": "Vieni più precisamente",
|
|
68
|
+
"low-period": "Bassa stagione",
|
|
69
|
+
"medium-period": "Stagione",
|
|
70
|
+
"high-period": "Alta stagione"
|
|
23
71
|
},
|
|
24
72
|
nl: {
|
|
25
|
-
title: "<
|
|
73
|
+
title: "<b>Wanneer</b> kom je?",
|
|
26
74
|
"selected-title": "Je komt van",
|
|
27
75
|
warn: "Waarschuwing, als u uw verblijfsdata wijzigt, wordt uw winkelwagentje gewist",
|
|
28
76
|
ok: "Aanpassen",
|
|
@@ -30,10 +78,13 @@ const messages = {
|
|
|
30
78
|
"update-period": "Update je verblijf",
|
|
31
79
|
offers: "Aanbiedingen voor de periode van",
|
|
32
80
|
to: "tot",
|
|
33
|
-
"extended-title": "Je komt precies"
|
|
81
|
+
"extended-title": "Je komt precies",
|
|
82
|
+
"low-period": "Laagseizoen",
|
|
83
|
+
"medium-period": "Seizoen",
|
|
84
|
+
"high-period": "Hoogseizoen"
|
|
34
85
|
}
|
|
35
86
|
};
|
|
36
|
-
export
|
|
87
|
+
export function get(lang, message) {
|
|
37
88
|
const locale = !messages[lang] ? "en" : lang;
|
|
38
89
|
return messages[locale][message];
|
|
39
|
-
}
|
|
90
|
+
}
|
|
@@ -27,13 +27,13 @@ const {
|
|
|
27
27
|
} = publicRuntimeConfig.season;
|
|
28
28
|
const WEEK_STORAGE = "stayWeek";
|
|
29
29
|
const EXTEND_STAY_PICKER_APPEARANCE_DELAY = 1000;
|
|
30
|
-
|
|
30
|
+
export default function PeriodPicker({
|
|
31
31
|
setClosed = undefined,
|
|
32
32
|
force = false,
|
|
33
33
|
onChange = undefined,
|
|
34
34
|
isPopup = false,
|
|
35
35
|
ubloContext = {}
|
|
36
|
-
})
|
|
36
|
+
}) {
|
|
37
37
|
const ref = React.useRef();
|
|
38
38
|
const {
|
|
39
39
|
lang,
|
|
@@ -200,5 +200,4 @@ const PeriodPicker = ({
|
|
|
200
200
|
onChange: onChange
|
|
201
201
|
})]
|
|
202
202
|
});
|
|
203
|
-
}
|
|
204
|
-
export default React.memo(PeriodPicker);
|
|
203
|
+
}
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
position: relative;
|
|
42
42
|
display: flex;
|
|
43
43
|
flex-direction: column;
|
|
44
|
-
gap:
|
|
44
|
+
gap: 14px;
|
|
45
45
|
padding: 32px 0;
|
|
46
46
|
}
|
|
47
47
|
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
justify-content: center;
|
|
60
60
|
align-items: center;
|
|
61
61
|
gap: 12px;
|
|
62
|
-
margin: 0 auto;
|
|
62
|
+
margin: 0 auto 22px auto;
|
|
63
63
|
padding: 0 10px;
|
|
64
64
|
text-align: center;
|
|
65
65
|
}
|
|
@@ -5,13 +5,13 @@ import PeriodPicker from "./period-picker";
|
|
|
5
5
|
import * as Motions from "./services/motions";
|
|
6
6
|
import css from "./popup.module.css";
|
|
7
7
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
|
-
|
|
8
|
+
export default function Popup({
|
|
9
9
|
mustFilterSections,
|
|
10
10
|
showDialog,
|
|
11
11
|
opened,
|
|
12
12
|
onChange,
|
|
13
13
|
selectAndClose
|
|
14
|
-
})
|
|
14
|
+
}) {
|
|
15
15
|
const [ready, setReady] = React.useState(false);
|
|
16
16
|
React.useEffect(() => {
|
|
17
17
|
setReady(true);
|
|
@@ -36,5 +36,4 @@ const Popup = ({
|
|
|
36
36
|
})
|
|
37
37
|
})
|
|
38
38
|
}), document.body);
|
|
39
|
-
}
|
|
40
|
-
export default Popup;
|
|
39
|
+
}
|
|
@@ -3,34 +3,34 @@ export const locales = {
|
|
|
3
3
|
en: "en-UK",
|
|
4
4
|
nl: "nl-NL"
|
|
5
5
|
};
|
|
6
|
-
export
|
|
6
|
+
export function padStart(value, count, pad) {
|
|
7
7
|
let str = String(value);
|
|
8
8
|
while (str.length < count) {
|
|
9
9
|
str = pad + str;
|
|
10
10
|
}
|
|
11
11
|
return str;
|
|
12
|
-
}
|
|
13
|
-
|
|
12
|
+
}
|
|
13
|
+
function createDate(...args) {
|
|
14
14
|
const ref = new Date(...args);
|
|
15
15
|
const yy = ref.getFullYear();
|
|
16
16
|
const mm = padStart(ref.getMonth() + 1, 2, 0);
|
|
17
17
|
const dd = padStart(ref.getDate(), 2, 0);
|
|
18
18
|
const str = `${yy}-${mm}-${dd}`;
|
|
19
19
|
return new Date(str);
|
|
20
|
-
}
|
|
21
|
-
|
|
20
|
+
}
|
|
21
|
+
function getPrevSaturday(date) {
|
|
22
22
|
const clone = createDate(date);
|
|
23
23
|
const day = 1 + clone.getDay();
|
|
24
24
|
const prevSaturday = clone.getDate() - day % 7;
|
|
25
25
|
clone.setDate(prevSaturday);
|
|
26
26
|
return clone;
|
|
27
|
-
}
|
|
28
|
-
|
|
27
|
+
}
|
|
28
|
+
function addDays(date, days) {
|
|
29
29
|
const clone = createDate(date);
|
|
30
30
|
clone.setDate(clone.getDate() + days);
|
|
31
31
|
return clone;
|
|
32
|
-
}
|
|
33
|
-
|
|
32
|
+
}
|
|
33
|
+
function christmasWeek(endWeek, forceSeasonSwitch) {
|
|
34
34
|
const now = createDate();
|
|
35
35
|
const year = now.getFullYear();
|
|
36
36
|
const month = now.getMonth();
|
|
@@ -41,29 +41,31 @@ const christmasWeek = (endWeek, forceSeasonSwitch) => {
|
|
|
41
41
|
const nextChristmas = createDate(lastChristmasYear + 1, 11, 25);
|
|
42
42
|
const dateSeasonEnd = addDays(getPrevSaturday(lastChristmas), endWeek * 7);
|
|
43
43
|
return getPrevSaturday(now <= dateSeasonEnd ? lastChristmas : nextChristmas);
|
|
44
|
-
}
|
|
45
|
-
export
|
|
46
|
-
|
|
44
|
+
}
|
|
45
|
+
export function weekToDate(week, endWeek, forceSeasonSwitch) {
|
|
46
|
+
return addDays(christmasWeek(endWeek, forceSeasonSwitch), week * 7);
|
|
47
|
+
}
|
|
48
|
+
export function formatShort(date) {
|
|
47
49
|
const dd = padStart(date.getDate(), 2, 0);
|
|
48
50
|
return dd;
|
|
49
|
-
}
|
|
50
|
-
export
|
|
51
|
+
}
|
|
52
|
+
export function weekToLongDate(week, endWeek, forceSeasonSwitch) {
|
|
51
53
|
const date = weekToDate(week, endWeek, forceSeasonSwitch);
|
|
52
54
|
const dd = padStart(date.getDate(), 2, 0);
|
|
53
55
|
const mm = padStart(date.getMonth() + 1, 2, 0);
|
|
54
56
|
const yy = date.getFullYear();
|
|
55
57
|
return `${dd}/${mm}/${yy}`;
|
|
56
|
-
}
|
|
57
|
-
export
|
|
58
|
+
}
|
|
59
|
+
export function format(date) {
|
|
58
60
|
const dd = padStart(date.getDate(), 2, 0);
|
|
59
61
|
const mm = padStart(date.getMonth() + 1, 2, 0);
|
|
60
62
|
const yy = date.getFullYear();
|
|
61
63
|
return `${yy}-${mm}-${dd}`;
|
|
62
|
-
}
|
|
63
|
-
export
|
|
64
|
+
}
|
|
65
|
+
export function getInterval(startDate, endDate, pad = {
|
|
64
66
|
before: 0,
|
|
65
67
|
after: 0
|
|
66
|
-
})
|
|
68
|
+
}) {
|
|
67
69
|
const dates = [];
|
|
68
70
|
const addDays = function (days) {
|
|
69
71
|
const date = new Date(this.valueOf());
|
|
@@ -77,12 +79,12 @@ export const getInterval = (startDate, endDate, pad = {
|
|
|
77
79
|
currentDate = addDays.call(currentDate, 1);
|
|
78
80
|
}
|
|
79
81
|
return dates;
|
|
80
|
-
}
|
|
81
|
-
export
|
|
82
|
+
}
|
|
83
|
+
export function buildWeeks(start, end) {
|
|
82
84
|
const length = end - start;
|
|
83
85
|
const array = [];
|
|
84
86
|
for (let i = 0; i < length; i++) {
|
|
85
87
|
array.push(start + i);
|
|
86
88
|
}
|
|
87
89
|
return array;
|
|
88
|
-
}
|
|
90
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import * as Events from "./events";
|
|
2
2
|
import * as Dates from "./dates";
|
|
3
3
|
import * as Messages from "../messages";
|
|
4
|
-
export
|
|
4
|
+
export function update(stay) {
|
|
5
5
|
window.sessionStorage.setItem("stay", JSON.stringify(stay));
|
|
6
6
|
Events.fire(window, "msem-stay-changed", stay);
|
|
7
|
-
}
|
|
8
|
-
export
|
|
7
|
+
}
|
|
8
|
+
export function formatStay(lang, stay) {
|
|
9
9
|
const locale = Dates.locales[lang] || Dates.locales.en;
|
|
10
10
|
const from = new Date(stay.from);
|
|
11
11
|
const to = new Date(stay.to);
|
|
@@ -24,4 +24,4 @@ export const formatStay = (lang, stay) => {
|
|
|
24
24
|
if (isOneDayStay) return `${toDay} ${toMonthLabel}`;
|
|
25
25
|
const dates = `${fromDay} ${fromMonthLabel}${Messages.get(lang, "to")} ${toDay} ${toMonthLabel}`;
|
|
26
26
|
return dates;
|
|
27
|
-
}
|
|
27
|
+
}
|
|
@@ -4,10 +4,10 @@ import * as Stay from "./services/stay";
|
|
|
4
4
|
import css from "./title.module.css";
|
|
5
5
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
6
6
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
7
|
-
|
|
7
|
+
export default function Title({
|
|
8
8
|
lang,
|
|
9
9
|
stay
|
|
10
|
-
})
|
|
10
|
+
}) {
|
|
11
11
|
if (!stay) {
|
|
12
12
|
return _jsx("div", {
|
|
13
13
|
className: css.title,
|
|
@@ -23,5 +23,4 @@ const Title = ({
|
|
|
23
23
|
children: formatedStay
|
|
24
24
|
})]
|
|
25
25
|
});
|
|
26
|
-
}
|
|
27
|
-
export default Title;
|
|
26
|
+
}
|
|
@@ -7,13 +7,13 @@ import * as Motions from "./services/motions";
|
|
|
7
7
|
import css from "./warning.module.css";
|
|
8
8
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
9
9
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
10
|
-
|
|
10
|
+
export default function Warning({
|
|
11
11
|
lang,
|
|
12
12
|
warn,
|
|
13
13
|
setWarn,
|
|
14
14
|
selectWeek,
|
|
15
15
|
chosenWeek
|
|
16
|
-
})
|
|
16
|
+
}) {
|
|
17
17
|
const cancel = () => {
|
|
18
18
|
setWarn(false);
|
|
19
19
|
};
|
|
@@ -47,5 +47,4 @@ const Warning = ({
|
|
|
47
47
|
})]
|
|
48
48
|
})
|
|
49
49
|
});
|
|
50
|
-
}
|
|
51
|
-
export default Warning;
|
|
50
|
+
}
|
|
@@ -1,12 +1,72 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import classNames from "classnames";
|
|
3
|
+
import getConfig from "next/config";
|
|
3
4
|
import { LayoutGroup, motion } from "framer-motion";
|
|
5
|
+
import Button from "dt-design-system/es/button";
|
|
4
6
|
import * as Icons from "dt-design-system/es/icons";
|
|
5
|
-
import css from "./weeks.module.css";
|
|
6
7
|
import * as Dates from "./services/dates";
|
|
8
|
+
import * as Messages from "./messages";
|
|
9
|
+
import css from "./weeks.module.css";
|
|
7
10
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
8
11
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
9
|
-
const
|
|
12
|
+
const {
|
|
13
|
+
publicRuntimeConfig
|
|
14
|
+
} = getConfig();
|
|
15
|
+
const {
|
|
16
|
+
periods
|
|
17
|
+
} = publicRuntimeConfig.season;
|
|
18
|
+
const Weeks = React.forwardRef(({
|
|
19
|
+
weeks,
|
|
20
|
+
lang,
|
|
21
|
+
...props
|
|
22
|
+
}, ref) => {
|
|
23
|
+
React.useEffect(() => {
|
|
24
|
+
const bar = ref.current;
|
|
25
|
+
if (props.selected === undefined || !bar) return;
|
|
26
|
+
const selectedItem = bar.querySelector(`.${css.itemSelected}`);
|
|
27
|
+
if (!selectedItem) return;
|
|
28
|
+
const {
|
|
29
|
+
clientWidth,
|
|
30
|
+
offsetLeft
|
|
31
|
+
} = selectedItem;
|
|
32
|
+
bar.scrollLeft = offsetLeft - clientWidth * 1.5;
|
|
33
|
+
}, [props.selected, ref]);
|
|
34
|
+
return _jsxs(LayoutGroup, {
|
|
35
|
+
children: [_jsx("div", {
|
|
36
|
+
ref: ref,
|
|
37
|
+
className: css.weeks,
|
|
38
|
+
children: weeks.map(week => _jsx(Week, {
|
|
39
|
+
lang: lang,
|
|
40
|
+
week: week,
|
|
41
|
+
...props
|
|
42
|
+
}, week))
|
|
43
|
+
}), periods && _jsxs("div", {
|
|
44
|
+
className: css.nomenclature,
|
|
45
|
+
children: [periods.high?.length > 0 && _jsxs("div", {
|
|
46
|
+
className: css.period,
|
|
47
|
+
"data-period": "high",
|
|
48
|
+
children: [_jsx("div", {
|
|
49
|
+
className: css.pill
|
|
50
|
+
}), Messages.get(lang, "high-period")]
|
|
51
|
+
}), periods.medium?.length > 0 && _jsxs("div", {
|
|
52
|
+
className: css.period,
|
|
53
|
+
"data-period": "medium",
|
|
54
|
+
children: [_jsx("div", {
|
|
55
|
+
className: css.pill
|
|
56
|
+
}), Messages.get(lang, "medium-period")]
|
|
57
|
+
}), periods.low?.length > 0 && _jsxs("div", {
|
|
58
|
+
className: css.period,
|
|
59
|
+
"data-period": "low",
|
|
60
|
+
children: [_jsx("div", {
|
|
61
|
+
className: css.pill
|
|
62
|
+
}), Messages.get(lang, "low-period")]
|
|
63
|
+
})]
|
|
64
|
+
})]
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
Weeks.displayName = "Weeks";
|
|
68
|
+
export default Weeks;
|
|
69
|
+
function Week({
|
|
10
70
|
lang,
|
|
11
71
|
week,
|
|
12
72
|
beginWeek,
|
|
@@ -16,7 +76,7 @@ const Week = ({
|
|
|
16
76
|
forceSeasonSwitch,
|
|
17
77
|
openExtendedPicker,
|
|
18
78
|
isPopup
|
|
19
|
-
})
|
|
79
|
+
}) {
|
|
20
80
|
const [checkVisible, setCheckVisible] = React.useState(false);
|
|
21
81
|
const [checkTimeout, setCheckTimeout] = React.useState();
|
|
22
82
|
const now = new Date();
|
|
@@ -40,8 +100,11 @@ const Week = ({
|
|
|
40
100
|
month: "short"
|
|
41
101
|
});
|
|
42
102
|
const weekClasses = classNames(css.item, {
|
|
43
|
-
[css.
|
|
44
|
-
[css.
|
|
103
|
+
[css.selected]: isSelected,
|
|
104
|
+
[css.past]: isPast,
|
|
105
|
+
[css.highPeriod]: periods?.high?.includes(week),
|
|
106
|
+
[css.mediumPeriod]: periods?.medium?.includes(week),
|
|
107
|
+
[css.lowPeriod]: periods?.low?.includes(week)
|
|
45
108
|
});
|
|
46
109
|
const selectWeek = () => {
|
|
47
110
|
select(week);
|
|
@@ -55,7 +118,7 @@ const Week = ({
|
|
|
55
118
|
const layoutId = isPopup ? "current-popup" : "current";
|
|
56
119
|
return _jsxs("div", {
|
|
57
120
|
className: weekClasses,
|
|
58
|
-
children: [_jsxs(
|
|
121
|
+
children: [_jsxs(Button, {
|
|
59
122
|
className: css.button,
|
|
60
123
|
onClick: selectWeek,
|
|
61
124
|
"aria-label": `${Dates.weekToLongDate(week)} - ${Dates.weekToLongDate(week + 1)}`,
|
|
@@ -83,32 +146,4 @@ const Week = ({
|
|
|
83
146
|
})]
|
|
84
147
|
})]
|
|
85
148
|
});
|
|
86
|
-
}
|
|
87
|
-
const Weeks = React.forwardRef(({
|
|
88
|
-
weeks,
|
|
89
|
-
...props
|
|
90
|
-
}, ref) => {
|
|
91
|
-
React.useEffect(() => {
|
|
92
|
-
const bar = ref.current;
|
|
93
|
-
if (props.selected === undefined || !bar) return;
|
|
94
|
-
const selectedItem = bar.querySelector(`.${css.itemSelected}`);
|
|
95
|
-
if (!selectedItem) return;
|
|
96
|
-
const {
|
|
97
|
-
clientWidth,
|
|
98
|
-
offsetLeft
|
|
99
|
-
} = selectedItem;
|
|
100
|
-
bar.scrollLeft = offsetLeft - clientWidth * 1.5;
|
|
101
|
-
}, [props.selected, ref]);
|
|
102
|
-
return _jsx(LayoutGroup, {
|
|
103
|
-
children: _jsx("div", {
|
|
104
|
-
ref: ref,
|
|
105
|
-
className: css.weeks,
|
|
106
|
-
children: weeks.map(week => _jsx(Week, {
|
|
107
|
-
week: week,
|
|
108
|
-
...props
|
|
109
|
-
}, week))
|
|
110
|
-
})
|
|
111
|
-
});
|
|
112
|
-
});
|
|
113
|
-
Weeks.displayName = "Weeks";
|
|
114
|
-
export default Weeks;
|
|
149
|
+
}
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
.weeks,
|
|
2
|
+
.nomenclature {
|
|
3
|
+
--high-period: #ff858c;
|
|
4
|
+
--medium-period: #f7d4a7;
|
|
5
|
+
--low-period: #9deebb;
|
|
6
|
+
}
|
|
7
|
+
|
|
1
8
|
.weeks {
|
|
2
9
|
--gap: 2px;
|
|
3
10
|
--item-height: 36px;
|
|
@@ -47,7 +54,19 @@
|
|
|
47
54
|
flex-direction: column;
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
.
|
|
57
|
+
.highPeriod {
|
|
58
|
+
--button-bg-color: var(--high-period);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
.mediumPeriod {
|
|
62
|
+
--button-bg-color: var(--medium-period);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.lowPeriod {
|
|
66
|
+
--button-bg-color: var(--low-period);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.past {
|
|
51
70
|
--button-bg-color: var(--ds-grey-200, #efefef);
|
|
52
71
|
|
|
53
72
|
cursor: not-allowed;
|
|
@@ -84,14 +103,15 @@
|
|
|
84
103
|
border-radius: 0 var(--item-height) var(--item-height) 0;
|
|
85
104
|
}
|
|
86
105
|
|
|
87
|
-
.
|
|
106
|
+
.selected {
|
|
88
107
|
z-index: 1;
|
|
89
108
|
}
|
|
90
109
|
|
|
91
|
-
.button {
|
|
110
|
+
button.button {
|
|
92
111
|
position: relative;
|
|
93
112
|
width: 100%;
|
|
94
113
|
height: var(--item-height);
|
|
114
|
+
padding: 0;
|
|
95
115
|
background-color: var(--button-bg-color);
|
|
96
116
|
border-radius: inherit;
|
|
97
117
|
cursor: pointer;
|
|
@@ -189,6 +209,43 @@
|
|
|
189
209
|
flex-direction: column;
|
|
190
210
|
margin-top: 6px;
|
|
191
211
|
font-size: 11px;
|
|
192
|
-
text-transform:
|
|
212
|
+
text-transform: capitalize;
|
|
193
213
|
transform: translateX(calc(0px - (var(--item-width)) / 5));
|
|
194
214
|
}
|
|
215
|
+
|
|
216
|
+
.nomenclature {
|
|
217
|
+
display: flex;
|
|
218
|
+
flex-wrap: wrap;
|
|
219
|
+
justify-content: center;
|
|
220
|
+
gap: 10px 22px;
|
|
221
|
+
padding: 0 10px;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
.period {
|
|
225
|
+
flex: 0 0 auto;
|
|
226
|
+
display: flex;
|
|
227
|
+
align-items: center;
|
|
228
|
+
gap: 9px;
|
|
229
|
+
font-size: 14px;
|
|
230
|
+
white-space: nowrap;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
.period[data-period="high"] {
|
|
234
|
+
--pill-color: var(--high-period);
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
.period[data-period="medium"] {
|
|
238
|
+
--pill-color: var(--medium-period);
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
.period[data-period="low"] {
|
|
242
|
+
--pill-color: var(--low-period);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
.pill {
|
|
246
|
+
flex: 0 0 10px;
|
|
247
|
+
width: 10px;
|
|
248
|
+
height: 10px;
|
|
249
|
+
border-radius: 50%;
|
|
250
|
+
background-color: var(--pill-color);
|
|
251
|
+
}
|
package/package.json
CHANGED
|
File without changes
|