ublo-lib 1.44.5 → 1.44.7
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"weeks.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/period-picker/weeks.js"],"names":[],"mappings":";AAWA,+
|
|
1
|
+
{"version":3,"file":"weeks.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/period-picker/weeks.js"],"names":[],"mappings":";AAWA,+EAoCG;uBA/CoB,OAAO"}
|
|
@@ -9,30 +9,33 @@ import css from "./weeks.module.css";
|
|
|
9
9
|
const { publicRuntimeConfig } = getConfig();
|
|
10
10
|
const { periods } = publicRuntimeConfig.season || {};
|
|
11
11
|
const Weeks = React.forwardRef(({ weeks, lang, ...props }, ref) => {
|
|
12
|
-
React.useEffect(() => {
|
|
13
|
-
const bar = ref.current;
|
|
14
|
-
if (props.selected === undefined || !bar)
|
|
15
|
-
return;
|
|
16
|
-
const selectedItem = bar.querySelector(`.${css.itemSelected}`);
|
|
17
|
-
if (!selectedItem)
|
|
18
|
-
return;
|
|
19
|
-
const { clientWidth, offsetLeft } = selectedItem;
|
|
20
|
-
bar.scrollLeft = offsetLeft - clientWidth * 1.5;
|
|
21
|
-
}, [props.selected, ref]);
|
|
22
12
|
const classes = classNames(css.weeks, {
|
|
23
13
|
[css.withPeriods]: periods,
|
|
24
14
|
});
|
|
25
|
-
return (_jsxs(_Fragment, { children: [_jsx("div", {
|
|
15
|
+
return (_jsxs(_Fragment, { children: [_jsx("div", { className: classes, children: weeks.map((week) => (_jsx(Week, { lang: lang, week: week, ...props }, week))) }), periods && (_jsxs("div", { className: css.nomenclature, children: [periods.high?.length > 0 && (_jsxs("div", { className: css.period, "data-period": "high", children: [_jsx("div", { className: css.pill }), Messages.get(lang, "high-period")] })), periods.medium?.length > 0 && (_jsxs("div", { className: css.period, "data-period": "medium", children: [_jsx("div", { className: css.pill }), Messages.get(lang, "medium-period")] })), periods.low?.length > 0 && (_jsxs("div", { className: css.period, "data-period": "low", children: [_jsx("div", { className: css.pill }), Messages.get(lang, "low-period")] }))] }))] }));
|
|
26
16
|
});
|
|
27
17
|
Weeks.displayName = "Weeks";
|
|
28
18
|
export default Weeks;
|
|
29
19
|
function Week({ lang, week, beginWeek, endWeek, selected, select, forceSeasonSwitch, openExtendedPicker, hidePastDates, }) {
|
|
20
|
+
const ref = React.useRef(null);
|
|
30
21
|
const now = new Date();
|
|
31
22
|
const prevDate = Dates.weekToDate(week - 1, endWeek, forceSeasonSwitch);
|
|
32
23
|
const currDate = Dates.weekToDate(week, endWeek, forceSeasonSwitch);
|
|
33
24
|
const nextDate = Dates.weekToDate(week + 1, endWeek, forceSeasonSwitch);
|
|
34
25
|
const isSelected = selected === week;
|
|
35
26
|
const isPast = now.getTime() > nextDate.getTime();
|
|
27
|
+
React.useEffect(() => {
|
|
28
|
+
window.requestAnimationFrame(() => {
|
|
29
|
+
const item = ref.current;
|
|
30
|
+
if (item) {
|
|
31
|
+
if (selectedItem) {
|
|
32
|
+
const bar = item.parentElement;
|
|
33
|
+
const { clientWidth, offsetLeft } = item;
|
|
34
|
+
bar.scrollLeft = offsetLeft - clientWidth * 1.5;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
});
|
|
38
|
+
}, [isSelected]);
|
|
36
39
|
if (hidePastDates && isPast)
|
|
37
40
|
return null;
|
|
38
41
|
const isFirst = week === beginWeek;
|
|
@@ -58,5 +61,5 @@ function Week({ lang, week, beginWeek, endWeek, selected, select, forceSeasonSwi
|
|
|
58
61
|
select(week);
|
|
59
62
|
openExtendedPicker();
|
|
60
63
|
};
|
|
61
|
-
return (_jsxs("div", { className: weekClasses, children: [_jsx(Button, { className: css.button, onClick: selectWeek, "aria-label": `${Dates.weekToLongDate(week)} - ${Dates.weekToLongDate(week + 1)}`, disabled: isPast }), _jsxs("div", { className: css.date, children: [_jsx("div", { className: css.dateFrom, children: Dates.formatShort(currDate) }), isLast && (_jsx("div", { className: css.dateTo, children: Dates.formatShort(nextDate) }))] }), showMonth && (_jsxs("span", { className: css.month, children: [formattedMonth, " ", showYear && _jsx("b", { className: css.year, children: currYear })] }))] }));
|
|
64
|
+
return (_jsxs("div", { ref: ref, className: weekClasses, children: [_jsx(Button, { className: css.button, onClick: selectWeek, "aria-label": `${Dates.weekToLongDate(week)} - ${Dates.weekToLongDate(week + 1)}`, disabled: isPast }), _jsxs("div", { className: css.date, children: [_jsx("div", { className: css.dateFrom, children: Dates.formatShort(currDate) }), isLast && (_jsx("div", { className: css.dateTo, children: Dates.formatShort(nextDate) }))] }), showMonth && (_jsxs("span", { className: css.month, children: [formattedMonth, " ", showYear && _jsx("b", { className: css.year, children: currYear })] }))] }));
|
|
62
65
|
}
|