ublo-lib 1.27.5 → 1.28.0

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.
@@ -0,0 +1,2 @@
1
+ import Information from "./information";
2
+ export default Information;
@@ -0,0 +1,57 @@
1
+ import * as React from "react";
2
+ import Router from "next/router";
3
+ import { useUbloContext } from "ublo/with-ublo";
4
+ import { fetchZone, fetchMenus } from "ublo/fetcher";
5
+ import Dialog from "dt-design-system/es/dialog";
6
+ import styles from "./information.module.css";
7
+ import { jsx as _jsx } from "react/jsx-runtime";
8
+ const STORAGE_KEY = "information_viewed";
9
+ export default function Information({
10
+ source = "/popup",
11
+ zone = "content",
12
+ preventOpening
13
+ }) {
14
+ const [content, setContent] = React.useState();
15
+ const {
16
+ config,
17
+ lang
18
+ } = useUbloContext();
19
+ const {
20
+ ubloApi,
21
+ site
22
+ } = config;
23
+ const close = React.useCallback(() => {
24
+ sessionStorage.setItem(STORAGE_KEY, "true");
25
+ setContent(undefined);
26
+ }, []);
27
+ const getContent = React.useCallback(async () => {
28
+ const menus = await fetchMenus(ubloApi, site, lang, source, 1, true);
29
+ if (menus.length === 1) {
30
+ const content = await fetchZone(ubloApi, site, lang, source, zone);
31
+ if (!content) return;
32
+ setContent(content);
33
+ }
34
+ }, [lang, site, source, ubloApi, zone]);
35
+ React.useEffect(() => {
36
+ const alreadySeen = sessionStorage.getItem(STORAGE_KEY) || sessionStorage.getItem("cms_token");
37
+ if (!preventOpening && !alreadySeen) {
38
+ getContent();
39
+ }
40
+ }, [getContent, preventOpening]);
41
+ Router.ready(() => {
42
+ Router.events.on("routeChangeComplete", () => {
43
+ close();
44
+ });
45
+ });
46
+ return _jsx(Dialog, {
47
+ className: styles.information,
48
+ close: close,
49
+ isOpened: !!content,
50
+ children: _jsx("div", {
51
+ className: styles.inner,
52
+ dangerouslySetInnerHTML: {
53
+ __html: content
54
+ }
55
+ })
56
+ });
57
+ }
@@ -0,0 +1,9 @@
1
+ .information {
2
+ @media (min-width: 700px) {
3
+ width: 700px;
4
+ }
5
+ }
6
+
7
+ .inner {
8
+ padding: 26px;
9
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ublo-lib",
3
- "version": "1.27.5",
3
+ "version": "1.28.0",
4
4
  "peerDependencies": {
5
5
  "dt-design-system": "^3.8.3",
6
6
  "leaflet": "^1.9.1",