ublo-lib 1.34.3 → 1.34.5

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,6 +1,6 @@
1
1
  declare const _default: React.MemoExoticComponent<typeof Carousel>;
2
2
  export default _default;
3
- declare function Carousel({ delay, fade, controls, dots, thumbnails, alwaysShowControls, allowDragOnDesktop, children, onChange, }: {
3
+ declare function Carousel({ delay, fade, controls, dots, thumbnails, alwaysShowControls, allowDragOnDesktop, children, onChange, currentSlide, }: {
4
4
  delay?: number;
5
5
  fade?: boolean;
6
6
  controls: any;
@@ -10,6 +10,7 @@ declare function Carousel({ delay, fade, controls, dots, thumbnails, alwaysShowC
10
10
  allowDragOnDesktop: any;
11
11
  children: any;
12
12
  onChange: any;
13
+ currentSlide: any;
13
14
  }): import("react/jsx-runtime").JSX.Element;
14
15
  import * as React from "react";
15
16
  //# sourceMappingURL=carousel.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["../../../src/common/components/carousel.js"],"names":[],"mappings":";;AAUA;;;;;;;;;;4CA4SC;uBAtTsB,OAAO"}
1
+ {"version":3,"file":"carousel.d.ts","sourceRoot":"","sources":["../../../src/common/components/carousel.js"],"names":[],"mappings":";;AAUA;;;;;;;;;;;4CAmTC;uBA7TsB,OAAO"}
@@ -6,11 +6,11 @@ import * as Icons from "dt-design-system/es/icons";
6
6
  const TARGETS = "section[data-class]";
7
7
  const UNDRAGGABLE_TAGS = "img, a, button";
8
8
  export default React.memo(Carousel);
9
- function Carousel({ delay = 4000, fade = false, controls, dots, thumbnails, alwaysShowControls, allowDragOnDesktop, children, onChange, }) {
9
+ function Carousel({ delay = 4000, fade = false, controls, dots, thumbnails, alwaysShowControls, allowDragOnDesktop, children, onChange, currentSlide, }) {
10
10
  const carouselRef = React.useRef();
11
11
  const { cmsMode, lang, path } = useUbloContext();
12
12
  const [sections, setSections] = React.useState([]);
13
- const [current, setCurrent] = React.useState(0);
13
+ const [current, setCurrent] = React.useState(currentSlide ?? 0);
14
14
  const [touchStartPosition, setTouchStartPosition] = React.useState();
15
15
  const [dragging, setDragging] = React.useState(0);
16
16
  const editing = cmsMode === "editing";
@@ -120,6 +120,11 @@ function Carousel({ delay = 4000, fade = false, controls, dots, thumbnails, alwa
120
120
  const sections = getSections();
121
121
  setSections(sections);
122
122
  }, [getSections]);
123
+ React.useEffect(() => {
124
+ if (!delay && currentSlide !== undefined) {
125
+ setCurrent(currentSlide);
126
+ }
127
+ }, [currentSlide, delay]);
123
128
  React.useEffect(() => {
124
129
  const zone = carouselRef.current?.querySelector(".cms");
125
130
  if (zone) {
@@ -1 +1 @@
1
- {"version":3,"file":"week-selector.d.ts","sourceRoot":"","sources":["../../../../src/common/components/week-selector/week-selector.tsx"],"names":[],"mappings":"AAUA,KAAK,KAAK,GAAG;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;CAC3C,CAAC;AAKF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,cAAc,EACd,OAAO,GACR,EAAE,KAAK,2CAkNP"}
1
+ {"version":3,"file":"week-selector.d.ts","sourceRoot":"","sources":["../../../../src/common/components/week-selector/week-selector.tsx"],"names":[],"mappings":"AAWA,KAAK,KAAK,GAAG;IACX,WAAW,EAAE,MAAM,CAAC;IACpB,cAAc,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,WAAW,GAAG,SAAS,GAAG,MAAM,CAAC;CAC3C,CAAC;AAOF,MAAM,CAAC,OAAO,UAAU,YAAY,CAAC,EACnC,WAAW,EACX,cAAc,EACd,OAAO,GACR,EAAE,KAAK,2CAoPP"}
@@ -3,6 +3,7 @@ import * as React from "react";
3
3
  import classNames from "classnames";
4
4
  import { motion } from "framer-motion";
5
5
  import getConfig from "next/config";
6
+ import Tooltip from "dt-design-system/es/tooltip";
6
7
  import Button from "dt-design-system/es/button";
7
8
  import Select from "dt-design-system/es/select";
8
9
  import * as Icons from "dt-design-system/es/icons";
@@ -10,12 +11,14 @@ import * as Weeks from "./services/weeks";
10
11
  import styles from "./week-selector.module.css";
11
12
  const { publicRuntimeConfig } = getConfig();
12
13
  const { start, end } = publicRuntimeConfig.season;
14
+ const MINIMIZED_STORAGE_KEY = "week-selector-minimized";
13
15
  export default function WeekSelector({ displayDate, setDisplayDate, cmsMode, }) {
14
16
  const constraintsRef = React.useRef(null);
15
17
  const scrollingAreaRef = React.useRef(null);
16
18
  const [yearOffset, setYearOffset] = React.useState(0);
17
19
  const [allowDrag, setAllowDrag] = React.useState(false);
18
20
  const [dragging, setDragging] = React.useState(false);
21
+ const [minimized, setMinimized] = React.useState(false);
19
22
  const christmasWeek = Weeks.getChristmasWeek(end, yearOffset);
20
23
  const christmasWeekYear = React.useRef(christmasWeek.getFullYear());
21
24
  React.useEffect(() => {
@@ -31,8 +34,20 @@ export default function WeekSelector({ displayDate, setDisplayDate, cmsMode, })
31
34
  }
32
35
  }
33
36
  }, [cmsMode, displayDate, scrollingAreaRef]);
37
+ React.useEffect(() => {
38
+ const minimized = window.localStorage.getItem(MINIMIZED_STORAGE_KEY);
39
+ setMinimized(minimized === "true");
40
+ }, []);
34
41
  if (cmsMode !== "connected")
35
42
  return null;
43
+ const minimize = () => {
44
+ setMinimized(true);
45
+ window.localStorage.setItem(MINIMIZED_STORAGE_KEY, "true");
46
+ };
47
+ const maximize = () => {
48
+ setMinimized(false);
49
+ window.localStorage.removeItem(MINIMIZED_STORAGE_KEY);
50
+ };
36
51
  const enableDrag = () => {
37
52
  setAllowDrag(true);
38
53
  };
@@ -76,6 +91,9 @@ export default function WeekSelector({ displayDate, setDisplayDate, cmsMode, })
76
91
  const classes = classNames(styles.selector, {
77
92
  [styles.dragging]: dragging,
78
93
  });
94
+ if (minimized) {
95
+ return (_jsx(Tooltip, { content: "Afficher le s\u00E9lecteur de date", contentProps: { side: "right" }, children: _jsx(Button, { className: styles.minimizedButton, onClick: maximize, children: _jsx(Icons.Calendar, {}) }) }));
96
+ }
79
97
  return (_jsx("div", { ref: constraintsRef, className: classes, children: _jsxs(motion.div, { animate: {
80
98
  boxShadow: "var(--ds-shadow-200, 0 5px 10px rgba(0, 0, 0, 0.12))",
81
99
  }, dragMomentum: false, drag: allowDrag, dragConstraints: constraintsRef, className: styles.container, whileDrag: {
@@ -86,7 +104,7 @@ export default function WeekSelector({ displayDate, setDisplayDate, cmsMode, })
86
104
  day: "2-digit",
87
105
  month: "2-digit",
88
106
  year: "numeric",
89
- }) }), _jsx(Select, { className: styles.seasonSelect, label: "Saison", options: seasons, value: yearOffset, onValueChange: (value) => setYearOffset(Number(value)), compact: true })] }), _jsxs("div", { className: styles.inner, children: [_jsx("div", { ref: scrollingAreaRef, className: styles.items, children: weeks.map((week) => {
107
+ }) }), _jsx(Select, { className: styles.seasonSelect, label: "Saison", options: seasons, value: yearOffset, onValueChange: (value) => setYearOffset(Number(value)), compact: true }), _jsx(Tooltip, { content: "R\u00E9duire", children: _jsx(Button, { variant: "transparent", onClick: minimize, children: _jsx(Icons.MinusSquare, {}) }) })] }), _jsxs("div", { className: styles.inner, children: [_jsx("div", { ref: scrollingAreaRef, className: styles.items, children: weeks.map((week) => {
90
108
  const prevDate = Weeks.weekToDate(week - 1, end, yearOffset);
91
109
  const currDate = Weeks.weekToDate(week, end, yearOffset);
92
110
  const nextDate = Weeks.weekToDate(week + 1, end, yearOffset);
@@ -1,3 +1,14 @@
1
+ .minimizedButton {
2
+ --ds-button-padding: 14px;
3
+ --ds-button-radius: 0 var(--ds-radius-400, 20px) var(--ds-radius-400, 20px) 0;
4
+ --ds-button-shadow: var(--ds-shadow-200, 0 5px 10px rgba(0, 0, 0, 0.12));
5
+
6
+ position: fixed;
7
+ left: 0;
8
+ bottom: 150px;
9
+ z-index: 1000;
10
+ }
11
+
1
12
  .selector {
2
13
  position: fixed;
3
14
  top: 0;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.34.3",
3
+ "version": "1.34.5",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.8.5",
6
6
  "leaflet": "^1.9.1",