ublo-lib 1.48.2 → 1.48.3
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":"config.d.ts","sourceRoot":"","sources":["../../../../../src/future/components/msem-package/components/config.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AAIvC,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;IACrB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../../../src/future/components/msem-package/components/config.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,OAAO,KAAK,KAAK,KAAK,MAAM,UAAU,CAAC;AAIvC,KAAK,KAAK,GAAG;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,KAAK,CAAC,MAAM,CAAC;IACrB,SAAS,EAAE,KAAK,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC;CAC/D,CAAC;AAEF,MAAM,CAAC,OAAO,UAAU,MAAM,CAAC,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,EAAE,EAAE,KAAK,2CAsDpE"}
|
|
@@ -5,10 +5,16 @@ import Zone from "ublo/zone";
|
|
|
5
5
|
import styles from "./config.module.css";
|
|
6
6
|
export default function Config({ idPrefix, config, setConfig }) {
|
|
7
7
|
const ref = React.useRef(null);
|
|
8
|
-
const { menuPath } = useUbloContext();
|
|
9
|
-
const
|
|
8
|
+
const { menuPath, lang, path } = useUbloContext();
|
|
9
|
+
const initializedRef = React.useRef(false);
|
|
10
|
+
const prevRouteRef = React.useRef(`/${lang}${path}`);
|
|
10
11
|
React.useEffect(() => {
|
|
11
|
-
|
|
12
|
+
const route = `/${lang}${path}`;
|
|
13
|
+
if (route !== prevRouteRef.current) {
|
|
14
|
+
prevRouteRef.current = route;
|
|
15
|
+
initializedRef.current = false;
|
|
16
|
+
}
|
|
17
|
+
if (!initializedRef.current) {
|
|
12
18
|
const container = ref.current;
|
|
13
19
|
let script = container?.querySelector("script");
|
|
14
20
|
if (!script) {
|
|
@@ -16,27 +22,27 @@ export default function Config({ idPrefix, config, setConfig }) {
|
|
|
16
22
|
type: "application/json",
|
|
17
23
|
innerHTML: "{}",
|
|
18
24
|
});
|
|
19
|
-
container
|
|
25
|
+
container?.appendChild(script);
|
|
20
26
|
}
|
|
21
27
|
const storedConfig = script.textContent;
|
|
22
28
|
if (storedConfig) {
|
|
23
|
-
const
|
|
29
|
+
const parsed = JSON.parse(storedConfig);
|
|
24
30
|
setConfig({
|
|
25
|
-
...
|
|
26
|
-
id:
|
|
31
|
+
...parsed,
|
|
32
|
+
id: parsed.id || `${idPrefix}-${menuPath?.id}`,
|
|
27
33
|
});
|
|
28
34
|
}
|
|
29
|
-
|
|
35
|
+
initializedRef.current = true;
|
|
30
36
|
}
|
|
31
|
-
}, [
|
|
37
|
+
}, [lang, path, setConfig, idPrefix, menuPath?.id]);
|
|
32
38
|
React.useEffect(() => {
|
|
33
39
|
const container = ref.current;
|
|
34
|
-
if (
|
|
40
|
+
if (initializedRef.current && container) {
|
|
35
41
|
const script = container.querySelector("script");
|
|
36
42
|
if (script) {
|
|
37
43
|
script.textContent = JSON.stringify(config);
|
|
38
44
|
}
|
|
39
45
|
}
|
|
40
|
-
}, [config
|
|
46
|
+
}, [config]);
|
|
41
47
|
return (_jsx(Zone, { ref: ref, id: "package-config", className: styles.zone, readOnly: true }));
|
|
42
48
|
}
|