ublo-lib 1.47.52 → 1.47.53
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/common/components/information/information.d.ts.map +1 -1
- package/es/common/components/information/information.js +4 -2
- package/es/common/components/information/use-season-choice.d.ts +2 -0
- package/es/common/components/information/use-season-choice.d.ts.map +1 -0
- package/es/common/components/information/use-season-choice.js +47 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"information.d.ts","sourceRoot":"","sources":["../../../../src/common/components/information/information.tsx"],"names":[],"mappings":"
|
|
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
|
-
|
|
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 @@
|
|
|
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
|
+
}
|