ublo-lib 1.39.25 → 1.39.26
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/admin-links/admin-links.d.ts.map +1 -1
- package/es/common/components/admin-links/admin-links.js +22 -5
- package/es/common/components/admin-links/admin-links.module.css +30 -0
- package/es/common/hooks/use-account.d.ts +2 -1
- package/es/common/hooks/use-account.d.ts.map +1 -1
- package/es/common/hooks/use-account.js +9 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-links.d.ts","sourceRoot":"","sources":["../../../../src/common/components/admin-links/admin-links.tsx"],"names":[],"mappings":"AAMA,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACpC,CAAC;AAeF,QAAA,MAAM,UAAU,oBAAqB,KAAK,
|
|
1
|
+
{"version":3,"file":"admin-links.d.ts","sourceRoot":"","sources":["../../../../src/common/components/admin-links/admin-links.tsx"],"names":[],"mappings":"AAMA,KAAK,IAAI,GAAG;IACV,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAC/B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,KAAK,KAAK,GAAG;IACX,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACpC,CAAC;AAeF,QAAA,MAAM,UAAU,oBAAqB,KAAK,4CA2GzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
1
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import * as React from "react";
|
|
3
3
|
import { useUbloContext } from "ublo/with-ublo";
|
|
4
4
|
import { loadFileManager } from "../../utils/file-manager";
|
|
@@ -9,6 +9,7 @@ const ToggleIcon = () => {
|
|
|
9
9
|
const AdminLinks = ({ customLinks }) => {
|
|
10
10
|
const { lang, cmsMode, config } = useUbloContext();
|
|
11
11
|
const [open, setOpen] = React.useState(false);
|
|
12
|
+
const [subsOpen, setSubsOpen] = React.useState(false);
|
|
12
13
|
const hasLangPrefix = config.langPrefix.links;
|
|
13
14
|
const { plausibleLink } = config;
|
|
14
15
|
const links = {
|
|
@@ -39,11 +40,20 @@ const AdminLinks = ({ customLinks }) => {
|
|
|
39
40
|
},
|
|
40
41
|
...customLinks,
|
|
41
42
|
};
|
|
42
|
-
|
|
43
|
+
const handlePopups = () => {
|
|
44
|
+
if (open) {
|
|
45
|
+
setSubsOpen(false);
|
|
46
|
+
setOpen(false);
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
setOpen(true);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
return (_jsx("div", { className: styles.root, children: cmsMode && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.toggle, onClick: handlePopups, children: _jsx(ToggleIcon, {}) }), open && (_jsxs("div", { className: styles.links, children: [_jsx("div", { className: styles.linksTitle, children: "Liens utiles" }), Object.keys(links).map((key, i) => {
|
|
43
53
|
const link = links[key];
|
|
44
54
|
if (!link)
|
|
45
55
|
return null;
|
|
46
|
-
const { name, onClick, target } = link;
|
|
56
|
+
const { name, onClick, target, subs } = link;
|
|
47
57
|
const isHrefValid = typeof onClick === "string" && onClick !== "";
|
|
48
58
|
const isFunction = typeof onClick === "function";
|
|
49
59
|
if (!isHrefValid && !isFunction) {
|
|
@@ -51,9 +61,16 @@ const AdminLinks = ({ customLinks }) => {
|
|
|
51
61
|
}
|
|
52
62
|
const Tag = isHrefValid ? "a" : "button";
|
|
53
63
|
const anchorProps = { href: onClick, target };
|
|
54
|
-
const buttonProps = {
|
|
64
|
+
const buttonProps = {
|
|
65
|
+
onClick: subs
|
|
66
|
+
? () => setSubsOpen((prevState) => !prevState)
|
|
67
|
+
: onClick,
|
|
68
|
+
};
|
|
55
69
|
const props = isFunction ? buttonProps : anchorProps;
|
|
56
|
-
return (_jsx(Tag, { className: styles.link, ...props, children: name }, i))
|
|
70
|
+
return (_jsxs(_Fragment, { children: [_jsx(Tag, { className: styles.link, ...props, children: name }, i), subs && (_jsx("div", { className: styles.subsLinks, "data-opened": subsOpen, children: subs.map((sub, j) => {
|
|
71
|
+
const { name, path } = sub;
|
|
72
|
+
return (_jsx("a", { className: styles.link, href: path, children: name }, j));
|
|
73
|
+
}) }))] }));
|
|
57
74
|
})] }))] })) }));
|
|
58
75
|
};
|
|
59
76
|
export default AdminLinks;
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
position: absolute;
|
|
37
37
|
bottom: 30px;
|
|
38
38
|
left: 0;
|
|
39
|
+
width: 175px;
|
|
39
40
|
max-width: 90vw;
|
|
40
41
|
display: flex;
|
|
41
42
|
flex-direction: column;
|
|
@@ -56,6 +57,35 @@
|
|
|
56
57
|
var(--ublo-transition-easing, cubic-bezier(0.4, 0, 0.2, 1));
|
|
57
58
|
}
|
|
58
59
|
|
|
60
|
+
.subsLinks {
|
|
61
|
+
position: absolute;
|
|
62
|
+
top: 20px;
|
|
63
|
+
left: 180px;
|
|
64
|
+
max-width: 90vw;
|
|
65
|
+
max-height: 150px;
|
|
66
|
+
overflow-y: auto;
|
|
67
|
+
display: flex;
|
|
68
|
+
flex-direction: column;
|
|
69
|
+
padding: 16px;
|
|
70
|
+
color: var(--ublo-grey-800, #000);
|
|
71
|
+
background: var(--ublo-grey-000, #fff);
|
|
72
|
+
border-radius: var(--ublo-radius-300, 15px);
|
|
73
|
+
box-shadow: var(--ublo-shadow-300, 0 5px 10px rgba(0, 0, 0, 0.24));
|
|
74
|
+
transform: scaleX(0.95);
|
|
75
|
+
transform-origin: left;
|
|
76
|
+
opacity: 0;
|
|
77
|
+
pointer-events: none;
|
|
78
|
+
transition: transform 240ms
|
|
79
|
+
var(--ublo-transition-easing, cubic-bezier(0.4, 0, 0.2, 1)),
|
|
80
|
+
opacity 240ms var(--ublo-transition-easing, cubic-bezier(0.4, 0, 0.2, 1));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
.subsLinks[data-opened="true"] {
|
|
84
|
+
transform: scaleX(1);
|
|
85
|
+
opacity: 1;
|
|
86
|
+
pointer-events: all;
|
|
87
|
+
}
|
|
88
|
+
|
|
59
89
|
@keyframes admin-links-appearance {
|
|
60
90
|
0% {
|
|
61
91
|
opacity: 0;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
type Props = {
|
|
2
2
|
channel?: string;
|
|
3
3
|
integration?: boolean;
|
|
4
|
+
cartPath?: string;
|
|
4
5
|
};
|
|
5
|
-
export default function useAccount({ channel, integration, }?: Props): void;
|
|
6
|
+
export default function useAccount({ channel, integration, cartPath, }?: Props): void;
|
|
6
7
|
export {};
|
|
7
8
|
//# sourceMappingURL=use-account.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-account.d.ts","sourceRoot":"","sources":["../../../src/common/hooks/use-account.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"use-account.d.ts","sourceRoot":"","sources":["../../../src/common/hooks/use-account.ts"],"names":[],"mappings":"AAMA,KAAK,KAAK,GAAG;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAMF,MAAM,CAAC,OAAO,UAAU,UAAU,CAAC,EACjC,OAAe,EACf,WAAW,EACX,QAAQ,GACT,GAAE,KAAU,QAyBZ"}
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
|
+
import getConfig from "next/config";
|
|
2
3
|
import { useUbloContext } from "ublo/with-ublo";
|
|
3
4
|
import * as Plausible from "../components/plausible";
|
|
4
5
|
import { loadJS } from "../utils/load-js";
|
|
5
|
-
|
|
6
|
+
const { publicRuntimeConfig } = getConfig();
|
|
7
|
+
const { langPrefix, resort } = publicRuntimeConfig;
|
|
8
|
+
const hasLangPrefix = langPrefix.links;
|
|
9
|
+
export default function useAccount({ channel = "ESF", integration, cartPath, } = {}) {
|
|
6
10
|
const { lang } = useUbloContext();
|
|
7
11
|
const widgetLang = React.useMemo(() => (lang === "fr" ? "fr" : "en"), [lang]);
|
|
12
|
+
const cartUrl = React.useMemo(() => (hasLangPrefix ? `/${lang.concat(cartPath)}` : cartPath), [cartPath, lang]);
|
|
8
13
|
React.useEffect(() => {
|
|
9
14
|
const startAccount = async () => {
|
|
10
15
|
await loadWidgetMseM(integration);
|
|
@@ -14,11 +19,13 @@ export default function useAccount({ channel = "ESF", integration, } = {}) {
|
|
|
14
19
|
channel,
|
|
15
20
|
groundedTo: "#msem-account",
|
|
16
21
|
analytics: Plausible.callback,
|
|
22
|
+
resort,
|
|
23
|
+
cartUrl,
|
|
17
24
|
});
|
|
18
25
|
});
|
|
19
26
|
};
|
|
20
27
|
startAccount();
|
|
21
|
-
}, [channel, integration, widgetLang]);
|
|
28
|
+
}, [cartUrl, channel, integration, widgetLang]);
|
|
22
29
|
}
|
|
23
30
|
async function loadWidgetMseM(integration) {
|
|
24
31
|
const source = integration
|