ublo-lib 1.6.27 → 1.7.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.
Files changed (65) hide show
  1. package/es/common/components/admin-links/admin-links.d.ts +12 -0
  2. package/es/common/components/admin-links/admin-links.d.ts.map +1 -0
  3. package/es/common/components/admin-links/admin-links.js +50 -95
  4. package/es/common/components/admin-links/index.d.ts +3 -0
  5. package/es/common/components/admin-links/index.d.ts.map +1 -0
  6. package/es/common/components/admin-links/index.js +1 -1
  7. package/es/common/components/scrolling-carousel/index.d.ts +3 -0
  8. package/es/common/components/scrolling-carousel/index.d.ts.map +1 -0
  9. package/es/common/components/scrolling-carousel/index.js +1 -1
  10. package/es/common/components/scrolling-carousel/scrolling-carousel.d.ts +8 -0
  11. package/es/common/components/scrolling-carousel/scrolling-carousel.d.ts.map +1 -0
  12. package/es/common/components/scrolling-carousel/scrolling-carousel.js +57 -84
  13. package/es/common/components/tabbed-zones.d.ts +13 -0
  14. package/es/common/components/tabbed-zones.d.ts.map +1 -0
  15. package/es/common/components/tabbed-zones.js +47 -102
  16. package/es/common/hooks/use-faq.d.ts +3 -0
  17. package/es/common/hooks/use-faq.d.ts.map +1 -0
  18. package/es/common/hooks/use-faq.js +36 -37
  19. package/es/common/hooks/use-in-view.d.ts +5 -0
  20. package/es/common/hooks/use-in-view.d.ts.map +1 -0
  21. package/es/common/hooks/use-in-view.js +62 -59
  22. package/es/common/hooks/use-scroll-direction.d.ts +11 -0
  23. package/es/common/hooks/use-scroll-direction.d.ts.map +1 -0
  24. package/es/common/hooks/use-scroll-direction.js +32 -33
  25. package/es/common/hooks/use-stay.d.ts +4 -0
  26. package/es/common/hooks/use-stay.d.ts.map +1 -0
  27. package/es/common/hooks/use-stay.js +14 -25
  28. package/es/common/hooks/use-sticky.d.ts +4 -0
  29. package/es/common/hooks/use-sticky.d.ts.map +1 -0
  30. package/es/common/hooks/use-sticky.js +35 -31
  31. package/es/common/hooks/use-tunnel.d.ts +6 -0
  32. package/es/common/hooks/use-tunnel.d.ts.map +1 -0
  33. package/es/common/hooks/use-tunnel.js +36 -43
  34. package/es/common/hooks/use-window-sizes.d.ts +7 -0
  35. package/es/common/hooks/use-window-sizes.d.ts.map +1 -0
  36. package/es/common/hooks/use-window-sizes.js +28 -27
  37. package/es/common/utils/cookies.d.ts +2 -0
  38. package/es/common/utils/cookies.d.ts.map +1 -0
  39. package/es/common/utils/cookies.js +11 -10
  40. package/es/common/utils/copy.d.ts +2 -0
  41. package/es/common/utils/copy.d.ts.map +1 -0
  42. package/es/common/utils/copy.js +11 -11
  43. package/es/common/utils/dates.d.ts +2 -0
  44. package/es/common/utils/dates.d.ts.map +1 -0
  45. package/es/common/utils/dates.js +10 -8
  46. package/es/common/utils/elements.d.ts +3 -0
  47. package/es/common/utils/elements.d.ts.map +1 -0
  48. package/es/common/utils/elements.js +7 -7
  49. package/es/common/utils/events.d.ts +4 -0
  50. package/es/common/utils/events.d.ts.map +1 -0
  51. package/es/common/utils/events.js +19 -21
  52. package/es/common/utils/file-manager.d.ts +13 -0
  53. package/es/common/utils/file-manager.d.ts.map +1 -0
  54. package/es/common/utils/file-manager.js +10 -12
  55. package/es/common/utils/load-js.d.ts +2 -0
  56. package/es/common/utils/load-js.d.ts.map +1 -0
  57. package/es/common/utils/load-js.js +11 -10
  58. package/es/common/utils/msem-widget.d.ts +8 -0
  59. package/es/common/utils/msem-widget.d.ts.map +1 -0
  60. package/es/common/utils/msem-widget.js +9 -11
  61. package/es/common/utils/url-parameters.d.ts +2 -0
  62. package/es/common/utils/url-parameters.d.ts.map +1 -0
  63. package/es/common/utils/url-parameters.js +7 -11
  64. package/es/esf/components/period-picker/period-picker.module.css +1 -1
  65. package/package.json +1 -1
@@ -0,0 +1,12 @@
1
+ /// <reference types="react" />
2
+ declare type Link = {
3
+ name: string;
4
+ onClick: string | (() => void);
5
+ target?: string;
6
+ };
7
+ declare type Props = {
8
+ customLinks?: Record<string, Link>;
9
+ };
10
+ declare const AdminLinks: ({ customLinks }: Props) => JSX.Element;
11
+ export default AdminLinks;
12
+ //# sourceMappingURL=admin-links.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin-links.d.ts","sourceRoot":"","sources":["../../../../src/common/components/admin-links/admin-links.tsx"],"names":[],"mappings":";AAMA,aAAK,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,aAAK,KAAK,GAAG;IACX,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;CACpC,CAAC;AAeF,QAAA,MAAM,UAAU,oBAAqB,KAAK,gBA0EzC,CAAC;AAEF,eAAe,UAAU,CAAC"}
@@ -1,102 +1,57 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
1
2
  import * as React from "react";
2
3
  import { useUbloContext } from "ublo/with-ublo";
3
4
  import { loadFileManager } from "../../utils/file-manager";
4
5
  import styles from "./admin-links.module.css";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { jsxs as _jsxs } from "react/jsx-runtime";
7
- import { Fragment as _Fragment } from "react/jsx-runtime";
8
6
  const ToggleIcon = () => {
9
- return _jsx("svg", {
10
- viewBox: "0 0 24 24",
11
- width: "24",
12
- height: "24",
13
- className: styles.toggleIcon,
14
- children: _jsx("path", {
15
- d: "M19.44 12.99l-.01.02c.04-.33.08-.67.08-1.01 0-.34-.03-.66-.07-.99l.01.02 2.44-1.92-2.43-4.22-2.87 1.16.01.01c-.52-.4-1.09-.74-1.71-1h.01L14.44 2H9.57l-.44 3.07h.01c-.62.26-1.19.6-1.71 1l.01-.01-2.88-1.17-2.44 4.22 2.44 1.92.01-.02c-.04.33-.07.65-.07.99 0 .34.03.68.08 1.01l-.01-.02-2.1 1.65-.33.26 2.43 4.2 2.88-1.15-.02-.04c.53.41 1.1.75 1.73 1.01h-.03L9.58 22h4.85s.03-.18.06-.42l.38-2.65h-.01c.62-.26 1.2-.6 1.73-1.01l-.02.04 2.88 1.15 2.43-4.2s-.14-.12-.33-.26l-2.11-1.66zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z"
16
- })
17
- });
7
+ return (_jsx("svg", { viewBox: "0 0 24 24", width: "24", height: "24", className: styles.toggleIcon, children: _jsx("path", { d: "M19.44 12.99l-.01.02c.04-.33.08-.67.08-1.01 0-.34-.03-.66-.07-.99l.01.02 2.44-1.92-2.43-4.22-2.87 1.16.01.01c-.52-.4-1.09-.74-1.71-1h.01L14.44 2H9.57l-.44 3.07h.01c-.62.26-1.19.6-1.71 1l.01-.01-2.88-1.17-2.44 4.22 2.44 1.92.01-.02c-.04.33-.07.65-.07.99 0 .34.03.68.08 1.01l-.01-.02-2.1 1.65-.33.26 2.43 4.2 2.88-1.15-.02-.04c.53.41 1.1.75 1.73 1.01h-.03L9.58 22h4.85s.03-.18.06-.42l.38-2.65h-.01c.62-.26 1.2-.6 1.73-1.01l-.02.04 2.88 1.15 2.43-4.2s-.14-.12-.33-.26l-2.11-1.66zM12 15.5c-1.93 0-3.5-1.57-3.5-3.5s1.57-3.5 3.5-3.5 3.5 1.57 3.5 3.5-1.57 3.5-3.5 3.5z" }) }));
18
8
  };
19
- const AdminLinks = ({
20
- customLinks
21
- }) => {
22
- const {
23
- lang,
24
- cmsMode,
25
- config
26
- } = useUbloContext();
27
- const [open, setOpen] = React.useState(false);
28
- const hasLangPrefix = config.langPrefix.links;
29
- const {
30
- plausibleLink
31
- } = config;
32
- const links = {
33
- msemAdmin: {
34
- name: "Administration MseM",
35
- onClick: "https://admin.mon-sejour-en-montagne.com/",
36
- target: "_blank"
37
- },
38
- tutoriels: {
39
- name: "Tutoriels",
40
- onClick: "http://esf-tutoriels.valraiso.net/",
41
- target: "_blank"
42
- },
43
- popup: {
44
- name: "Popup",
45
- onClick: hasLangPrefix ? `/${lang.concat("/popup")}` : "/popup"
46
- },
47
- fileManager: {
48
- name: "Photothèque",
49
- onClick: loadFileManager
50
- },
51
- plausible: {
52
- name: "Statistiques",
53
- onClick: plausibleLink,
54
- target: "_blank"
55
- },
56
- ...customLinks
57
- };
58
- return _jsx("div", {
59
- className: styles.root,
60
- children: cmsMode && _jsxs(_Fragment, {
61
- children: [_jsx("div", {
62
- className: styles.toggle,
63
- onClick: () => setOpen(!open),
64
- children: _jsx(ToggleIcon, {})
65
- }), open && _jsxs("div", {
66
- className: styles.links,
67
- children: [_jsx("div", {
68
- className: styles.linksTitle,
69
- children: "Liens utiles"
70
- }), Object.keys(links).map((key, i) => {
71
- const link = links[key];
72
- if (!link) return;
73
- const {
74
- name,
75
- onClick,
76
- target
77
- } = link;
78
- const isHrefValid = typeof onClick === "string" && onClick !== "";
79
- const isFunction = typeof onClick === "function";
80
- if (!isHrefValid && !isFunction) {
81
- return null;
82
- }
83
- const Tag = isHrefValid ? "a" : "button";
84
- const anchorProps = {
85
- href: onClick,
86
- target
87
- };
88
- const buttonProps = {
89
- onClick
90
- };
91
- const props = isFunction ? buttonProps : anchorProps;
92
- return _jsx(Tag, {
93
- className: styles.link,
94
- ...props,
95
- children: name
96
- }, i);
97
- })]
98
- })]
99
- })
100
- });
9
+ const AdminLinks = ({ customLinks }) => {
10
+ const { lang, cmsMode, config } = useUbloContext();
11
+ const [open, setOpen] = React.useState(false);
12
+ const hasLangPrefix = config.langPrefix.links;
13
+ const { plausibleLink } = config;
14
+ const links = {
15
+ msemAdmin: {
16
+ name: "Administration MseM",
17
+ onClick: "https://admin.mon-sejour-en-montagne.com/",
18
+ target: "_blank",
19
+ },
20
+ tutoriels: {
21
+ name: "Tutoriels",
22
+ onClick: "http://esf-tutoriels.valraiso.net/",
23
+ target: "_blank",
24
+ },
25
+ popup: {
26
+ name: "Popup",
27
+ onClick: hasLangPrefix ? `/${lang.concat("/popup")}` : "/popup",
28
+ },
29
+ fileManager: {
30
+ name: "Photothèque",
31
+ onClick: loadFileManager,
32
+ },
33
+ plausible: {
34
+ name: "Statistiques",
35
+ onClick: plausibleLink,
36
+ target: "_blank",
37
+ },
38
+ ...customLinks,
39
+ };
40
+ return (_jsx("div", { className: styles.root, children: cmsMode && (_jsxs(_Fragment, { children: [_jsx("div", { className: styles.toggle, onClick: () => setOpen(!open), children: _jsx(ToggleIcon, {}) }), open && (_jsxs("div", { className: styles.links, children: [_jsx("div", { className: styles.linksTitle, children: "Liens utiles" }), Object.keys(links).map((key, i) => {
41
+ const link = links[key];
42
+ if (!link)
43
+ return;
44
+ const { name, onClick, target } = link;
45
+ const isHrefValid = typeof onClick === "string" && onClick !== "";
46
+ const isFunction = typeof onClick === "function";
47
+ if (!isHrefValid && !isFunction) {
48
+ return null;
49
+ }
50
+ const Tag = isHrefValid ? "a" : "button";
51
+ const anchorProps = { href: onClick, target };
52
+ const buttonProps = { onClick };
53
+ const props = isFunction ? buttonProps : anchorProps;
54
+ return (_jsx(Tag, { className: styles.link, ...props, children: name }, i));
55
+ })] }))] })) }));
101
56
  };
102
- export default AdminLinks;
57
+ export default AdminLinks;
@@ -0,0 +1,3 @@
1
+ import AdminLinks from "./admin-links";
2
+ export default AdminLinks;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/components/admin-links/index.tsx"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,eAAe,CAAC;AAEvC,eAAe,UAAU,CAAC"}
@@ -1,2 +1,2 @@
1
1
  import AdminLinks from "./admin-links";
2
- export default AdminLinks;
2
+ export default AdminLinks;
@@ -0,0 +1,3 @@
1
+ import ScrollingCarousel from "./scrolling-carousel";
2
+ export default ScrollingCarousel;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/common/components/scrolling-carousel/index.tsx"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;AAErD,eAAe,iBAAiB,CAAC"}
@@ -1,2 +1,2 @@
1
1
  import ScrollingCarousel from "./scrolling-carousel";
2
- export default ScrollingCarousel;
2
+ export default ScrollingCarousel;
@@ -0,0 +1,8 @@
1
+ import * as React from "react";
2
+ declare type Props = {
3
+ className?: string;
4
+ children: React.ReactNode;
5
+ };
6
+ declare const ScrollingCarousel: ({ className, children }: Props) => JSX.Element;
7
+ export default ScrollingCarousel;
8
+ //# sourceMappingURL=scrolling-carousel.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scrolling-carousel.d.ts","sourceRoot":"","sources":["../../../../src/common/components/scrolling-carousel/scrolling-carousel.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAS/B,aAAK,KAAK,GAAG;IACX,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;CAC3B,CAAC;AAKF,QAAA,MAAM,iBAAiB,4BAA6B,KAAK,gBAiGxD,CAAC;AAEF,eAAe,iBAAiB,CAAC"}
@@ -1,92 +1,65 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import * as React from "react";
2
3
  import classnames from "classnames";
3
4
  import Button from "dt-design-system/es/button";
4
5
  import * as Icons from "dt-design-system/es/icons";
5
- import useWindowSizes from "ublo-lib/es/common/hooks/use-window-sizes";
6
+ import useWindowSizes from "../../hooks/use-window-sizes";
6
7
  import css from "./scrolling-carousel.module.css";
7
- import { jsx as _jsx } from "react/jsx-runtime";
8
- import { jsxs as _jsxs } from "react/jsx-runtime";
9
8
  const PREV = 0;
10
9
  const NEXT = 1;
11
- const ScrollingCarousel = ({
12
- className,
13
- children
14
- }) => {
15
- const ref = React.useRef(null);
16
- const zoneRef = React.useRef(null);
17
- const [overflow, setOverflow] = React.useState(false);
18
- const [controls, setControls] = React.useState({
19
- prevDisabled: false,
20
- nextDisabled: false
21
- });
22
- const {
23
- width
24
- } = useWindowSizes();
25
- const slideTo = direction => () => {
26
- const inner = ref.current;
27
- const firstSection = zoneRef.current?.querySelector("section:not([data-hidden], [hidden])");
28
- if (firstSection) {
29
- const scrollDistance = firstSection.clientWidth;
30
- if (direction === PREV) {
31
- inner.scrollLeft -= scrollDistance;
32
- }
33
- if (direction === NEXT) {
34
- inner.scrollLeft += scrollDistance;
35
- }
36
- }
37
- };
38
- const refreshControls = React.useCallback(() => {
39
- const inner = ref.current;
40
- const zone = zoneRef.current;
41
- if (zone) {
42
- setOverflow(inner.clientWidth < zone.clientWidth);
43
- setControls({
44
- prevDisabled: inner.scrollLeft === 0,
45
- nextDisabled: inner.scrollLeft === Math.round(inner.scrollWidth) - Math.round(inner.clientWidth)
46
- });
47
- }
48
- }, []);
49
- React.useEffect(() => {
50
- refreshControls();
51
- }, [refreshControls]);
52
- React.useEffect(() => {
53
- const inner = ref.current;
54
- inner.scrollLeft = 0;
55
- }, [width]);
56
- const classes = classnames(css.carousel, className);
57
- return _jsxs("div", {
58
- className: classes,
59
- children: [overflow && _jsxs("div", {
60
- className: css.controls,
61
- "data-controls": "",
62
- children: [_jsx(Button, {
63
- className: css.control,
64
- variant: "link",
65
- onClick: slideTo(PREV),
66
- disabled: controls.prevDisabled,
67
- "data-control": "prev",
68
- children: _jsx(Icons.ChevronLeft, {
69
- className: css.controlIcon
70
- })
71
- }), _jsx(Button, {
72
- className: css.control,
73
- variant: "link",
74
- onClick: slideTo(NEXT),
75
- disabled: controls.nextDisabled,
76
- "data-control": "next",
77
- children: _jsx(Icons.ChevronRight, {
78
- className: css.controlIcon
79
- })
80
- })]
81
- }), _jsx("div", {
82
- className: css.inner,
83
- ref: ref,
84
- onScroll: refreshControls,
85
- "data-inner": "",
86
- children: React.cloneElement(children, {
87
- ref: zoneRef
88
- })
89
- })]
90
- });
10
+ const ScrollingCarousel = ({ className, children }) => {
11
+ const ref = React.useRef(null);
12
+ const zoneRef = React.useRef(null);
13
+ const [overflow, setOverflow] = React.useState(false);
14
+ const [controls, setControls] = React.useState({
15
+ prevDisabled: false,
16
+ nextDisabled: false,
17
+ });
18
+ const { width } = useWindowSizes();
19
+ const slideTo = (direction) => () => {
20
+ const zone = zoneRef.current;
21
+ const inner = ref.current;
22
+ if (zone && inner) {
23
+ const zoneContainer = zone;
24
+ const innerContainer = inner;
25
+ const firstSection = zoneContainer.querySelector("section:not([data-hidden], [hidden])");
26
+ if (firstSection) {
27
+ const scrollDistance = firstSection.clientWidth;
28
+ if (direction === PREV) {
29
+ innerContainer.scrollLeft -= scrollDistance;
30
+ }
31
+ if (direction === NEXT) {
32
+ innerContainer.scrollLeft += scrollDistance;
33
+ }
34
+ }
35
+ }
36
+ };
37
+ const refreshControls = React.useCallback(() => {
38
+ const zone = zoneRef.current;
39
+ const inner = ref.current;
40
+ if (zone && inner) {
41
+ const zoneContainer = zone;
42
+ const innerContainer = inner;
43
+ setOverflow(innerContainer.clientWidth < zoneContainer.clientWidth);
44
+ setControls({
45
+ prevDisabled: innerContainer.scrollLeft === 0,
46
+ nextDisabled: innerContainer.scrollLeft ===
47
+ Math.round(innerContainer.scrollWidth) -
48
+ Math.round(innerContainer.clientWidth),
49
+ });
50
+ }
51
+ }, []);
52
+ React.useEffect(() => {
53
+ refreshControls();
54
+ }, [refreshControls]);
55
+ React.useEffect(() => {
56
+ const inner = ref.current;
57
+ if (inner) {
58
+ const innerContainer = inner;
59
+ innerContainer.scrollLeft = 0;
60
+ }
61
+ }, [width]);
62
+ const classes = classnames(css.carousel, className);
63
+ return (_jsxs("div", { className: classes, children: [overflow && (_jsxs("div", { className: css.controls, "data-controls": "", children: [_jsx(Button, { className: css.control, variant: "link", onClick: slideTo(PREV), disabled: controls.prevDisabled, "data-control": "prev", children: _jsx(Icons.ChevronLeft, { className: css.controlIcon }) }), _jsx(Button, { className: css.control, variant: "link", onClick: slideTo(NEXT), disabled: controls.nextDisabled, "data-control": "next", children: _jsx(Icons.ChevronRight, { className: css.controlIcon }) })] })), _jsx("div", { className: css.inner, ref: ref, onScroll: refreshControls, "data-inner": "", children: React.cloneElement(children, { ref: zoneRef }) })] }));
91
64
  };
92
- export default ScrollingCarousel;
65
+ export default ScrollingCarousel;
@@ -0,0 +1,13 @@
1
+ /// <reference types="react" />
2
+ declare type Tab = {
3
+ subs: number | null;
4
+ };
5
+ declare type Props = {
6
+ current?: number;
7
+ currentSub?: number;
8
+ tabs?: Tab[];
9
+ zonesProps: Record<string, unknown>;
10
+ };
11
+ declare const TabbedZones: ({ current, currentSub, tabs, zonesProps, }: Props) => JSX.Element;
12
+ export default TabbedZones;
13
+ //# sourceMappingURL=tabbed-zones.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tabbed-zones.d.ts","sourceRoot":"","sources":["../../../src/common/components/tabbed-zones.tsx"],"names":[],"mappings":";AAIA,aAAK,GAAG,GAAG;IACT,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;CACrB,CAAC;AAEF,aAAK,KAAK,GAAG;IACX,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;IACb,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACrC,CAAC;AAIF,QAAA,MAAM,WAAW,+CAKd,KAAK,gBAmHP,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -1,106 +1,51 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
2
  import * as React from "react";
2
- import { useState } from "react";
3
3
  import classnames from "classnames";
4
4
  import Zone from "ublo/zone";
5
- import { jsx as _jsx } from "react/jsx-runtime";
6
- import { jsxs as _jsxs } from "react/jsx-runtime";
7
- const defaultTabs = [{
8
- subs: null
9
- }, {
10
- subs: 2
11
- }];
12
- const defaultZonesProps = {};
13
- const TabbedZones = ({
14
- current = 0,
15
- currentSub = 0,
16
- tabs = defaultTabs,
17
- zonesProps = defaultZonesProps
18
- }) => {
19
- const [currentTab, setCurrentTab] = useState(current);
20
- const [currentSubTab, setCurrentSubTab] = useState(currentSub);
21
- return _jsxs("div", {
22
- className: "tabbed-zones",
23
- children: [_jsx("div", {
24
- className: "tabbed-zones__tabs",
25
- children: tabs.map((_, i) => {
26
- const onClick = () => {
27
- setCurrentTab(i);
28
- setCurrentSubTab(0);
29
- };
30
- const classes = classnames(`tabbed-zones__tab tabbed-zones__tab--${i}`, {
31
- "tabbed-zones__tab--current": i === currentTab
32
- });
33
- return _jsx("div", {
34
- className: classes,
35
- onClick: onClick,
36
- children: _jsx(Zone, {
37
- id: `tabbed-zones-tab-${i}`,
38
- section: "rich-text",
39
- maxSections: "1",
40
- tooltip: "Aide: Titre onglet"
41
- })
42
- }, i);
43
- })
44
- }), tabs.map((tab, i) => {
45
- if (!tab.subs) return null;
46
- const length = [...new Array(tab.subs)];
47
- const classes = classnames(`tabbed-zones__sub-tabs tabbed-zones__sub-tabs--${i}`, {
48
- "tabbed-zones__sub-tabs--current": i === currentTab
49
- });
50
- return _jsx("div", {
51
- className: classes,
52
- children: length.map((_, j) => {
53
- const onClick = () => setCurrentSubTab(j);
54
- const classes = classnames(`tabbed-zones__sub-tab tabbed-zones__sub-tab--${i}-${j}`, {
55
- "tabbed-zones__sub-tab--current": i === currentTab && j === currentSubTab
56
- });
57
- return _jsx("div", {
58
- className: classes,
59
- onClick: onClick,
60
- children: _jsx(Zone, {
61
- id: `tabbed-zones-sub-tab-${i}-${j}`,
62
- section: "rich-text",
63
- maxSections: "1",
64
- tooltip: "Aide: Titre onglet",
65
- ...zonesProps
66
- })
67
- }, j);
68
- })
69
- }, i);
70
- }), _jsxs("div", {
71
- className: "tabbed-zones__zones",
72
- children: [tabs.map((tab, i) => {
73
- const classes = classnames(`tabbed-zones__zone tabbed-zones__zone--${i}`, {
74
- "tabbed-zones__zone--current": i === currentTab
75
- });
76
- if (tab.subs) return null;
77
- return _jsx("div", {
78
- className: classes,
79
- children: _jsx(Zone, {
80
- id: `tabbed-zone-${i}`,
81
- tooltip: "Zone d'edition : Contenu onglet",
82
- ...zonesProps
83
- })
84
- }, i);
85
- }), tabs.map((tab, i) => {
86
- if (!tab.subs) return null;
87
- const length = [...new Array(tab.subs)];
88
- return length.map((_, j) => {
89
- const classes = classnames(`tabbed-zones__zone tabbed-zones__zone--${i}-${j}`, {
90
- "tabbed-zones__zone--current": i === currentTab && j === currentSubTab
91
- });
92
- return _jsx("div", {
93
- className: classes,
94
- children: _jsx(Zone, {
95
- id: `tabbed-zone-offers-${i}-${j}`,
96
- className: "tabbed-zone-offers",
97
- tooltip: "Zone d'edition : Contenu et blocs produit",
98
- ...zonesProps
99
- })
100
- }, j);
101
- });
102
- })]
103
- })]
104
- });
5
+ const defaultTabs = [{ subs: null }, { subs: 2 }];
6
+ const TabbedZones = ({ current = 0, currentSub = 0, tabs = defaultTabs, zonesProps = {}, }) => {
7
+ const [currentTab, setCurrentTab] = React.useState(current);
8
+ const [currentSubTab, setCurrentSubTab] = React.useState(currentSub);
9
+ return (_jsxs("div", { className: "tabbed-zones", children: [_jsx("div", { className: "tabbed-zones__tabs", children: tabs.map((_, i) => {
10
+ const updateCurrentTab = () => {
11
+ setCurrentTab(i);
12
+ setCurrentSubTab(0);
13
+ };
14
+ const classes = classnames("tabbed-zones__tab", `tabbed-zones__tab--${i}`, {
15
+ "tabbed-zones__tab--current": i === currentTab,
16
+ });
17
+ return (_jsx("div", { className: classes, onClick: updateCurrentTab, children: _jsx(Zone, { id: `tabbed-zones-tab-${i}`, section: "rich-text", maxSections: "1", tooltip: "Zone d'edition: Titre onglet" }) }, i));
18
+ }) }), tabs.map((tab, i) => {
19
+ if (!tab.subs)
20
+ return null;
21
+ const length = [...new Array(tab.subs)];
22
+ const classes = classnames("tabbed-zones__sub-tabs", `tabbed-zones__sub-tabs--${i}`, {
23
+ "tabbed-zones__sub-tabs--current": i === currentTab,
24
+ });
25
+ return (_jsx("div", { className: classes, children: length.map((_, j) => {
26
+ const updateCurrentTab = () => setCurrentSubTab(j);
27
+ const classes = classnames("tabbed-zones__sub-tab", `tabbed-zones__sub-tab--${i}-${j}`, {
28
+ "tabbed-zones__sub-tab--current": i === currentTab && j === currentSubTab,
29
+ });
30
+ return (_jsx("div", { className: classes, onClick: updateCurrentTab, children: _jsx(Zone, { id: `tabbed-zones-sub-tab-${i}-${j}`, section: "rich-text", maxSections: "1", tooltip: "Zone d'edition: Titre onglet", ...zonesProps }) }, j));
31
+ }) }, i));
32
+ }), _jsxs("div", { className: "tabbed-zones__zones", children: [tabs.map((tab, i) => {
33
+ const classes = classnames("tabbed-zones__zone", `tabbed-zones__zone--${i}`, {
34
+ "tabbed-zones__zone--current": i === currentTab,
35
+ });
36
+ if (tab.subs)
37
+ return null;
38
+ return (_jsx("div", { className: classes, children: _jsx(Zone, { id: `tabbed-zone-${i}`, tooltip: "Zone d'edition : Contenu onglet", ...zonesProps }) }, i));
39
+ }), tabs.map((tab, i) => {
40
+ if (!tab.subs)
41
+ return null;
42
+ const length = [...new Array(tab.subs)];
43
+ return length.map((_, j) => {
44
+ const classes = classnames("tabbed-zones__zone", `tabbed-zones__zone--${i}-${j}`, {
45
+ "tabbed-zones__zone--current": i === currentTab && j === currentSubTab,
46
+ });
47
+ return (_jsx("div", { className: classes, children: _jsx(Zone, { id: `tabbed-zone-offers-${i}-${j}`, className: "tabbed-zone-offers", tooltip: "Zone d'edition : Contenu et blocs produit", ...zonesProps }) }, j));
48
+ });
49
+ })] })] }));
105
50
  };
106
- export default TabbedZones;
51
+ export default TabbedZones;
@@ -0,0 +1,3 @@
1
+ declare const useFaq: (selector: string | undefined, refresh: string) => void;
2
+ export default useFaq;
3
+ //# sourceMappingURL=use-faq.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-faq.d.ts","sourceRoot":"","sources":["../../../src/common/hooks/use-faq.ts"],"names":[],"mappings":"AAKA,QAAA,MAAM,MAAM,0CAA8C,MAAM,SA4C/D,CAAC;AAEF,eAAe,MAAM,CAAC"}
@@ -1,41 +1,40 @@
1
1
  import * as React from "react";
2
2
  import { useUbloContext } from "ublo/with-ublo";
3
- const buildClass = className => `${className}--opened`;
3
+ const buildClass = (className) => `${className}--opened`;
4
4
  const useFaq = (selector = ".faq-block", refresh) => {
5
- const [blocks, setBlocks] = React.useState([]);
6
- const {
7
- cmsMode
8
- } = useUbloContext();
9
- const clicked = React.useCallback((clickedBlock, blocks) => () => {
10
- if (cmsMode) return;
11
- const openedClass = buildClass(clickedBlock.classList[0]);
12
- blocks.forEach(block => {
13
- const {
14
- classList
15
- } = block;
16
- block !== clickedBlock || block.classList.contains(openedClass) ? classList.remove(openedClass) : classList.add(openedClass);
17
- });
18
- }, [cmsMode]);
19
- const init = React.useCallback((block, blocks) => {
20
- block.clicked = clicked(block, blocks);
21
- block.addEventListener("click", block.clicked);
22
- }, [clicked]);
23
- const cleanup = React.useCallback(block => {
24
- block.removeEventListener("click", block.clicked);
25
- const openedClass = buildClass(block.classList[0]);
26
- block.classList.remove(openedClass);
27
- }, []);
28
- React.useEffect(() => {
29
- if (cmsMode === undefined) {
30
- setTimeout(() => {
31
- const blocks = Array.from(document.querySelectorAll(selector));
32
- setBlocks(blocks);
33
- });
34
- }
35
- }, [cmsMode, selector, refresh]);
36
- React.useEffect(() => {
37
- blocks.forEach(block => init(block, blocks));
38
- return () => blocks.forEach(cleanup);
39
- }, [blocks, cleanup, init]);
5
+ const [blocks, setBlocks] = React.useState([]);
6
+ const { cmsMode } = useUbloContext();
7
+ const clicked = React.useCallback((clickedBlock, blocks) => () => {
8
+ if (cmsMode)
9
+ return;
10
+ const openedClass = buildClass(clickedBlock.classList[0]);
11
+ blocks.forEach((block) => {
12
+ const { classList } = block;
13
+ block !== clickedBlock || block.classList.contains(openedClass)
14
+ ? classList.remove(openedClass)
15
+ : classList.add(openedClass);
16
+ });
17
+ }, [cmsMode]);
18
+ const init = React.useCallback((block, blocks) => {
19
+ block.clicked = clicked(block, blocks);
20
+ block.addEventListener("click", block.clicked);
21
+ }, [clicked]);
22
+ const cleanup = React.useCallback((block) => {
23
+ block.removeEventListener("click", block.clicked);
24
+ const openedClass = buildClass(block.classList[0]);
25
+ block.classList.remove(openedClass);
26
+ }, []);
27
+ React.useEffect(() => {
28
+ if (cmsMode === undefined) {
29
+ setTimeout(() => {
30
+ const blocks = Array.from(document.querySelectorAll(selector));
31
+ setBlocks(blocks);
32
+ });
33
+ }
34
+ }, [cmsMode, selector, refresh]);
35
+ React.useEffect(() => {
36
+ blocks.forEach((block) => init(block, blocks));
37
+ return () => blocks.forEach(cleanup);
38
+ }, [blocks, cleanup, init]);
40
39
  };
41
- export default useFaq;
40
+ export default useFaq;
@@ -0,0 +1,5 @@
1
+ import * as React from "react";
2
+ declare type CmsMode = "connected" | "info" | "editing";
3
+ declare const useInView: (ref: React.MutableRefObject<HTMLElement>, cmsMode: CmsMode, targetedClass: string, repeat?: boolean, intersectionValue?: number) => void;
4
+ export default useInView;
5
+ //# sourceMappingURL=use-in-view.d.ts.map