ublo-lib 1.47.52 → 1.47.54

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":"information.d.ts","sourceRoot":"","sources":["../../../../src/common/components/information/information.tsx"],"names":[],"mappings":"AAkBA,KAAK,KAAK,GAAG;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,MAAiB,EACjB,IAAgB,EAChB,cAAc,EACd,IAAc,EACd,SAAS,EACT,eAAe,GAChB,EAAE,KAAK,2CAuKP"}
1
+ {"version":3,"file":"information.d.ts","sourceRoot":"","sources":["../../../../src/common/components/information/information.tsx"],"names":[],"mappings":"AAmBA,KAAK,KAAK,GAAG;IACX,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,WAAW,CAAC,EAClC,MAAiB,EACjB,IAAgB,EAChB,cAAc,EACd,IAAc,EACd,SAAS,EACT,eAAe,GAChB,EAAE,KAAK,2CA0KP"}
@@ -14,6 +14,7 @@ import ArrowUpIcon from "dt-design-system/es/icons/arrow-up";
14
14
  import CrossIcon from "dt-design-system/es/icons/cross";
15
15
  import i18n from "./i18n.json";
16
16
  import styles from "./information.module.css";
17
+ import useSeasonChoice from "./use-season-choice";
17
18
  const STORAGE_KEY = "information_viewed";
18
19
  export default function Information({ source = "/popup", zone = "content", preventOpening, mode = "popup", className, buttonClassName, }) {
19
20
  const ref = React.useRef(null);
@@ -26,6 +27,7 @@ export default function Information({ source = "/popup", zone = "content", preve
26
27
  const { ubloApi, site } = config;
27
28
  const isPopin = mode === "popin";
28
29
  const isOpened = isPopin ? !minimized && Boolean(content) : Boolean(content);
30
+ useSeasonChoice(close, content, isPopin);
29
31
  const maximize = () => {
30
32
  sessionStorage.setItem(STORAGE_KEY, "true");
31
33
  setMaximized(true);
@@ -45,10 +47,10 @@ export default function Information({ source = "/popup", zone = "content", preve
45
47
  setMaximized(false);
46
48
  checkOverflow();
47
49
  };
48
- const close = () => {
50
+ function close() {
49
51
  sessionStorage.setItem(STORAGE_KEY, "true");
50
52
  setContent(undefined);
51
- };
53
+ }
52
54
  const checkOverflow = React.useCallback(() => {
53
55
  window.requestAnimationFrame(() => {
54
56
  const inner = document.querySelector(`.${styles.inner}`);
@@ -0,0 +1,2 @@
1
+ export default function useSeasonChoice(callback: any, content: any, isPopin: any): void;
2
+ //# sourceMappingURL=use-season-choice.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-season-choice.d.ts","sourceRoot":"","sources":["../../../../src/common/components/information/use-season-choice.js"],"names":[],"mappings":"AAOA,yFA2DC"}
@@ -0,0 +1,47 @@
1
+ import * as React from "react";
2
+ const SELECTOR = ".season-choice__block--winter";
3
+ export default function useSeasonChoice(callback, content, isPopin) {
4
+ React.useEffect(() => {
5
+ if (isPopin || !content)
6
+ return;
7
+ let winterElement = null;
8
+ let observer = null;
9
+ const attachListener = () => {
10
+ if (winterElement)
11
+ return true;
12
+ const winter = document.querySelector(SELECTOR);
13
+ if (winter) {
14
+ winterElement = winter;
15
+ winter.addEventListener("click", callback);
16
+ return true;
17
+ }
18
+ return false;
19
+ };
20
+ if (attachListener()) {
21
+ return () => {
22
+ if (winterElement) {
23
+ winterElement.removeEventListener("click", callback);
24
+ }
25
+ };
26
+ }
27
+ observer = new MutationObserver((mutations) => {
28
+ const hasRelevantChanges = mutations.some((mutation) => mutation.type === "childList" && mutation.addedNodes.length > 0);
29
+ if (hasRelevantChanges && attachListener()) {
30
+ observer.disconnect();
31
+ observer = null;
32
+ }
33
+ });
34
+ observer.observe(document.body, {
35
+ childList: true,
36
+ subtree: true,
37
+ });
38
+ return () => {
39
+ if (observer) {
40
+ observer.disconnect();
41
+ }
42
+ if (winterElement) {
43
+ winterElement.removeEventListener("click", callback);
44
+ }
45
+ };
46
+ }, [content, callback, isPopin]);
47
+ }
@@ -1 +1 @@
1
- {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/instructors-book/sheet.js"],"names":[],"mappings":"AAgBA;;;;;;4CAsLC"}
1
+ {"version":3,"file":"sheet.d.ts","sourceRoot":"","sources":["../../../../src/esf/components/instructors-book/sheet.js"],"names":[],"mappings":"AAgBA;;;;;;4CA8LC"}
@@ -19,14 +19,20 @@ export default function Sheet({ instructor, popup, formFields, formSendFunction,
19
19
  const { lang, path } = useUbloContext();
20
20
  const [loading, setLoading] = React.useState(true);
21
21
  const [picture, setPicture] = React.useState(photo);
22
- const mediaQueryPrint = window?.matchMedia("print");
22
+ const mediaQueryPrint = typeof window !== "undefined" ? window.matchMedia("print") : undefined;
23
23
  const [isPrinting, setIsPrinting] = React.useState(mediaQueryPrint?.matches);
24
24
  React.useEffect(() => {
25
25
  const listener = (e) => {
26
26
  setIsPrinting(e.matches);
27
27
  };
28
- mediaQueryPrint?.addEventListener("change", listener);
29
- return () => mediaQueryPrint.removeEventListener("change", listener);
28
+ if (mediaQueryPrint) {
29
+ mediaQueryPrint?.addEventListener("change", listener);
30
+ }
31
+ return () => {
32
+ if (mediaQueryPrint) {
33
+ mediaQueryPrint.removeEventListener("change", listener);
34
+ }
35
+ };
30
36
  }, [mediaQueryPrint]);
31
37
  const prefixLang = lang === "fr" ? "fr" : "en";
32
38
  const stopLoading = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.47.52",
3
+ "version": "1.47.54",
4
4
  "peerDependencies": {
5
5
  "classnames": "^2.5.1",
6
6
  "dt-design-system": "^3.12.0",