@becklyn/next 4.3.0 → 4.4.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.
- package/dist/cjs/types/style.d.ts +5 -0
- package/dist/cjs/types/style.d.ts.map +1 -1
- package/dist/es/contentful/imageLoader.js +1 -5
- package/dist/es/contentful/inspector.js +18 -24
- package/dist/es/error/ErrorBoundary.js +2 -6
- package/dist/es/format/phone.js +1 -5
- package/dist/es/lib/click.js +4 -8
- package/dist/es/lib/debounce.js +1 -5
- package/dist/es/lib/escape.js +3 -7
- package/dist/es/lib/fetcher.js +1 -5
- package/dist/es/lib/focusTrap.js +10 -15
- package/dist/es/lib/geo.js +5 -10
- package/dist/es/lib/intersection.js +4 -8
- package/dist/es/lib/isMounted.js +7 -12
- package/dist/es/lib/shortcut.js +3 -7
- package/dist/es/lib/sleep.js +1 -5
- package/dist/es/lib/slider.js +11 -18
- package/dist/es/lib/staticContent.js +5 -9
- package/dist/es/lib/typeChecks.js +5 -13
- package/dist/es/lib/useDebounce.js +5 -9
- package/dist/es/lib/useInterval.js +7 -11
- package/dist/es/lib/useIsDocumentHidden.js +4 -8
- package/dist/es/lib/useMediaQuery.js +5 -9
- package/dist/es/lib/useScrollAway.js +3 -7
- package/dist/es/lib/useTimeout.js +6 -10
- package/dist/es/mock/block.js +1 -5
- package/dist/es/rte/generators.js +18 -30
- package/dist/es/rte/index.js +7 -11
- package/dist/es/structuredData/index.js +3 -7
- package/dist/es/tracking/cookiebot/index.js +17 -26
- package/dist/es/tracking/cookiebot/types.js +1 -2
- package/dist/es/tracking/gtm/index.js +18 -30
- package/dist/es/tracking/gtm/types.js +1 -2
- package/dist/es/tracking/index.js +1 -4
- package/dist/es/types/block.js +1 -2
- package/dist/es/types/prettify.js +1 -2
- package/dist/es/types/preview.js +1 -2
- package/dist/es/types/structuredData.js +1 -2
- package/dist/es/types/style.d.ts +5 -0
- package/dist/es/types/style.d.ts.map +1 -1
- package/dist/es/types/style.js +1 -2
- package/package.json +1 -1
- package/scss/story/story.scss +34 -0
|
@@ -4,4 +4,9 @@ export interface StyledProps {
|
|
|
4
4
|
export type PropsWithClassName<P = object> = P & {
|
|
5
5
|
className?: string;
|
|
6
6
|
};
|
|
7
|
+
export type PropsWithClassNames<K extends string, P = object> = P & {
|
|
8
|
+
classNames?: {
|
|
9
|
+
[Key in K]?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
7
12
|
//# sourceMappingURL=style.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../types/style.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../types/style.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG;IAChE,UAAU,CAAC,EAAE;SACR,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM;KACtB,CAAC;CACL,CAAC"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
"
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.imageLoader = void 0;
|
|
4
|
-
const imageLoader = ({ src, width, quality, format = "webp" }) => {
|
|
1
|
+
export const imageLoader = ({ src, width, quality, format = "webp" }) => {
|
|
5
2
|
let url = src;
|
|
6
3
|
if (!src.startsWith("https")) {
|
|
7
4
|
if (src.startsWith("http")) {
|
|
@@ -21,4 +18,3 @@ const imageLoader = ({ src, width, quality, format = "webp" }) => {
|
|
|
21
18
|
return src;
|
|
22
19
|
}
|
|
23
20
|
};
|
|
24
|
-
exports.imageLoader = imageLoader;
|
|
@@ -1,34 +1,30 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
entryId: zod_1.z.string().optional(),
|
|
7
|
-
draftMode: zod_1.z.boolean().optional(),
|
|
8
|
-
locale: zod_1.z.string().optional(),
|
|
1
|
+
import { z } from "zod";
|
|
2
|
+
export const InspectableItemSchema = z.object({
|
|
3
|
+
entryId: z.string().optional(),
|
|
4
|
+
draftMode: z.boolean().optional(),
|
|
5
|
+
locale: z.string().optional(),
|
|
9
6
|
});
|
|
10
|
-
|
|
7
|
+
export const InspectableFieldSchema = z
|
|
11
8
|
.object({
|
|
12
|
-
fieldId:
|
|
13
|
-
assetId:
|
|
9
|
+
fieldId: z.string().optional(),
|
|
10
|
+
assetId: z.string().optional(),
|
|
14
11
|
})
|
|
15
|
-
.extend(
|
|
16
|
-
|
|
17
|
-
entryId:
|
|
18
|
-
draftMode:
|
|
19
|
-
locale:
|
|
20
|
-
fieldId:
|
|
21
|
-
assetId:
|
|
12
|
+
.extend(InspectableItemSchema.shape);
|
|
13
|
+
export const InspectorPropsSchema = z.object({
|
|
14
|
+
entryId: z.string().optional(),
|
|
15
|
+
draftMode: z.boolean().optional(),
|
|
16
|
+
locale: z.string().optional(),
|
|
17
|
+
fieldId: z.string().optional(),
|
|
18
|
+
assetId: z.string().optional(),
|
|
22
19
|
});
|
|
23
|
-
const getInspectorProps = (data) => {
|
|
20
|
+
export const getInspectorProps = (data) => {
|
|
24
21
|
if (!data) {
|
|
25
22
|
return {};
|
|
26
23
|
}
|
|
27
24
|
const { entryId, fieldId, assetId, draftMode, locale } = data;
|
|
28
25
|
return { entryId, fieldId, assetId, draftMode, locale };
|
|
29
26
|
};
|
|
30
|
-
|
|
31
|
-
const removeInspectorProps = (data) => {
|
|
27
|
+
export const removeInspectorProps = (data) => {
|
|
32
28
|
if (!data) {
|
|
33
29
|
return {};
|
|
34
30
|
}
|
|
@@ -36,8 +32,7 @@ const removeInspectorProps = (data) => {
|
|
|
36
32
|
const { entryId, fieldId, assetId, draftMode, locale, ...props } = data;
|
|
37
33
|
return props;
|
|
38
34
|
};
|
|
39
|
-
|
|
40
|
-
const inspector = (data) => {
|
|
35
|
+
export const inspector = (data) => {
|
|
41
36
|
if (!data) {
|
|
42
37
|
return {};
|
|
43
38
|
}
|
|
@@ -53,4 +48,3 @@ const inspector = (data) => {
|
|
|
53
48
|
"data-contentful-locale": locale,
|
|
54
49
|
};
|
|
55
50
|
};
|
|
56
|
-
exports.inspector = inspector;
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.ErrorBoundary = void 0;
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
class ErrorBoundary extends react_1.Component {
|
|
2
|
+
import { Component } from "react";
|
|
3
|
+
export class ErrorBoundary extends Component {
|
|
7
4
|
constructor(props) {
|
|
8
5
|
super(props);
|
|
9
6
|
this.state = { hasError: false };
|
|
@@ -18,4 +15,3 @@ class ErrorBoundary extends react_1.Component {
|
|
|
18
15
|
return this.props.children;
|
|
19
16
|
}
|
|
20
17
|
}
|
|
21
|
-
exports.ErrorBoundary = ErrorBoundary;
|
package/dist/es/format/phone.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatPhone = void 0;
|
|
4
|
-
const formatPhone = (phone) => {
|
|
1
|
+
export const formatPhone = (phone) => {
|
|
5
2
|
if (typeof phone === "number") {
|
|
6
3
|
return phone;
|
|
7
4
|
}
|
|
8
5
|
return phone.replace(/[-/)( ]/g, "").replace("+49", "0049");
|
|
9
6
|
};
|
|
10
|
-
exports.formatPhone = formatPhone;
|
package/dist/es/lib/click.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const useClickOutside = ({ callback }) => {
|
|
6
|
-
const ref = (0, react_1.useRef)(null);
|
|
7
|
-
(0, react_1.useEffect)(() => {
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
export const useClickOutside = ({ callback }) => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
useEffect(() => {
|
|
8
5
|
const handleClickOutside = (event) => {
|
|
9
6
|
if (ref.current && !ref.current.contains(event.target)) {
|
|
10
7
|
callback(event);
|
|
@@ -15,4 +12,3 @@ const useClickOutside = ({ callback }) => {
|
|
|
15
12
|
});
|
|
16
13
|
return ref;
|
|
17
14
|
};
|
|
18
|
-
exports.useClickOutside = useClickOutside;
|
package/dist/es/lib/debounce.js
CHANGED
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.debounce = void 0;
|
|
4
|
-
const debounce = (func, wait) => {
|
|
1
|
+
export const debounce = (func, wait) => {
|
|
5
2
|
let timeout = null;
|
|
6
3
|
return () => {
|
|
7
4
|
if (timeout) {
|
|
@@ -10,4 +7,3 @@ const debounce = (func, wait) => {
|
|
|
10
7
|
timeout = setTimeout(func, wait);
|
|
11
8
|
};
|
|
12
9
|
};
|
|
13
|
-
exports.debounce = debounce;
|
package/dist/es/lib/escape.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useEscapeListener = (callback, deps, capture = false) => {
|
|
6
|
-
(0, react_1.useEffect)(() => {
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export const useEscapeListener = (callback, deps, capture = false) => {
|
|
3
|
+
useEffect(() => {
|
|
7
4
|
const onKeyDown = (e) => {
|
|
8
5
|
if (e.key === "Escape") {
|
|
9
6
|
callback(e);
|
|
@@ -15,4 +12,3 @@ const useEscapeListener = (callback, deps, capture = false) => {
|
|
|
15
12
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
16
13
|
deps ? [...deps, capture] : undefined);
|
|
17
14
|
};
|
|
18
|
-
exports.useEscapeListener = useEscapeListener;
|
package/dist/es/lib/fetcher.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetcher = void 0;
|
|
4
|
-
const fetcher = (...args) => fetch(...args).then(res => res.json());
|
|
5
|
-
exports.fetcher = fetcher;
|
|
1
|
+
export const fetcher = (...args) => fetch(...args).then(res => res.json());
|
package/dist/es/lib/focusTrap.js
CHANGED
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.useTrapFocus = exports.FOCUSABLE_ELEMENTS = exports.checkCanFocusTrap = void 0;
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const checkCanFocusTrap = async (container) => {
|
|
1
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
2
|
+
export const checkCanFocusTrap = async (container) => {
|
|
6
3
|
const results = container.map(element => {
|
|
7
4
|
return new Promise(resolve => {
|
|
8
5
|
const interval = setInterval(() => {
|
|
@@ -15,19 +12,18 @@ const checkCanFocusTrap = async (container) => {
|
|
|
15
12
|
});
|
|
16
13
|
await Promise.all(results);
|
|
17
14
|
};
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
const
|
|
22
|
-
const
|
|
23
|
-
const update = (0, react_1.useCallback)(() => {
|
|
15
|
+
export const FOCUSABLE_ELEMENTS = 'button:not([tabindex="-1"]), [href]:not([tabindex="-1"]), input:not([tabindex="-1"]), select:not([tabindex="-1"]), textarea:not([tabindex="-1"]), [tabindex]:not([tabindex="-1"])';
|
|
16
|
+
export const useTrapFocus = (container) => {
|
|
17
|
+
const ref = useRef(null);
|
|
18
|
+
const [nodes, setNodes] = useState(null);
|
|
19
|
+
const update = useCallback(() => {
|
|
24
20
|
const el = ref.current || container;
|
|
25
21
|
if (!el) {
|
|
26
22
|
return;
|
|
27
23
|
}
|
|
28
|
-
setNodes(Array.from(el.querySelectorAll(
|
|
24
|
+
setNodes(Array.from(el.querySelectorAll(FOCUSABLE_ELEMENTS)));
|
|
29
25
|
}, [container]);
|
|
30
|
-
|
|
26
|
+
useEffect(() => {
|
|
31
27
|
const el = ref.current || container;
|
|
32
28
|
if (!el) {
|
|
33
29
|
return;
|
|
@@ -35,7 +31,7 @@ const useTrapFocus = (container) => {
|
|
|
35
31
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
36
32
|
update();
|
|
37
33
|
}, [container, update]);
|
|
38
|
-
|
|
34
|
+
useEffect(() => {
|
|
39
35
|
const el = ref.current || container;
|
|
40
36
|
if (!el || !nodes) {
|
|
41
37
|
return;
|
|
@@ -62,4 +58,3 @@ const useTrapFocus = (container) => {
|
|
|
62
58
|
}, [container, nodes]);
|
|
63
59
|
return [ref, { update }];
|
|
64
60
|
};
|
|
65
|
-
exports.useTrapFocus = useTrapFocus;
|
package/dist/es/lib/geo.js
CHANGED
|
@@ -1,23 +1,18 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.useGeoLocation = exports.getGeoLocation = void 0;
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const getGeoLocation = async () => {
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
export const getGeoLocation = async () => {
|
|
7
4
|
if (navigator && "geolocation" in navigator) {
|
|
8
5
|
return new Promise((resolve, reject) => {
|
|
9
6
|
navigator.geolocation.getCurrentPosition(resolve, reject);
|
|
10
7
|
});
|
|
11
8
|
}
|
|
12
9
|
};
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
const [location, setLocation] = (0, react_1.useState)();
|
|
10
|
+
export const useGeoLocation = () => {
|
|
11
|
+
const [location, setLocation] = useState();
|
|
16
12
|
const onClick = async () => {
|
|
17
|
-
const l = await
|
|
13
|
+
const l = await getGeoLocation();
|
|
18
14
|
setLocation(l);
|
|
19
15
|
return l;
|
|
20
16
|
};
|
|
21
17
|
return [onClick, location];
|
|
22
18
|
};
|
|
23
|
-
exports.useGeoLocation = useGeoLocation;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const useIntersection = ({ ref, defaultValue = false, callback, filter, options, dependencies, }) => {
|
|
7
|
-
const [visible, setVisible] = (0, react_1.useState)(defaultValue);
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
export const useIntersection = ({ ref, defaultValue = false, callback, filter, options, dependencies, }) => {
|
|
4
|
+
const [visible, setVisible] = useState(defaultValue);
|
|
8
5
|
const { current } = ref;
|
|
9
|
-
|
|
6
|
+
useEffect(() => {
|
|
10
7
|
const observer = new IntersectionObserver(entries => {
|
|
11
8
|
entries.forEach(entry => {
|
|
12
9
|
const isVisible = filter ? filter(entry) : entry.isIntersecting;
|
|
@@ -24,4 +21,3 @@ const useIntersection = ({ ref, defaultValue = false, callback, filter, options,
|
|
|
24
21
|
}, [current, ...(dependencies ?? [])]);
|
|
25
22
|
return visible;
|
|
26
23
|
};
|
|
27
|
-
exports.useIntersection = useIntersection;
|
package/dist/es/lib/isMounted.js
CHANGED
|
@@ -1,22 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const useIsMounted = () => {
|
|
6
|
-
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
7
|
-
(0, react_1.useEffect)(() => {
|
|
1
|
+
import { useEffect, useLayoutEffect, useState } from "react";
|
|
2
|
+
export const useIsMounted = () => {
|
|
3
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
4
|
+
useEffect(() => {
|
|
8
5
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
9
6
|
setIsMounted(true);
|
|
10
7
|
}, []);
|
|
11
8
|
return isMounted;
|
|
12
9
|
};
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
10
|
+
export const useIsLayoutMounted = () => {
|
|
11
|
+
const [isLayoutMounted, setIsLayoutMounted] = useState(false);
|
|
12
|
+
useLayoutEffect(() => {
|
|
17
13
|
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
18
14
|
setIsLayoutMounted(true);
|
|
19
15
|
}, []);
|
|
20
16
|
return isLayoutMounted;
|
|
21
17
|
};
|
|
22
|
-
exports.useIsLayoutMounted = useIsLayoutMounted;
|
package/dist/es/lib/shortcut.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const react_1 = require("react");
|
|
5
|
-
const useShortcut = (key, callback, deps) => {
|
|
6
|
-
(0, react_1.useEffect)(() => {
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
export const useShortcut = (key, callback, deps) => {
|
|
3
|
+
useEffect(() => {
|
|
7
4
|
const onKeyDown = (e) => {
|
|
8
5
|
let input = "";
|
|
9
6
|
if (e.metaKey) {
|
|
@@ -28,4 +25,3 @@ const useShortcut = (key, callback, deps) => {
|
|
|
28
25
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
29
26
|
}, deps);
|
|
30
27
|
};
|
|
31
|
-
exports.useShortcut = useShortcut;
|
package/dist/es/lib/sleep.js
CHANGED
|
@@ -1,5 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.sleep = void 0;
|
|
4
|
-
const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
5
|
-
exports.sleep = sleep;
|
|
1
|
+
export const sleep = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
package/dist/es/lib/slider.js
CHANGED
|
@@ -1,23 +1,17 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const [ref, setRef] = (0, react_1.useState)(null);
|
|
12
|
-
const [details, setDetails] = (0, react_1.useState)(null);
|
|
13
|
-
const [options, setOptions] = (0, react_1.useState)(null);
|
|
14
|
-
const [isMounted, setIsMounted] = (0, react_1.useState)(false);
|
|
15
|
-
const sliderRef = (0, react_1.useRef)(null);
|
|
16
|
-
(0, react_1.useEffect)(() => {
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from "react";
|
|
3
|
+
import KeenSlider from "keen-slider";
|
|
4
|
+
export const useSlider = ({ shouldObserverMutations, shouldAutoDisable, ...opt } = {}) => {
|
|
5
|
+
const [ref, setRef] = useState(null);
|
|
6
|
+
const [details, setDetails] = useState(null);
|
|
7
|
+
const [options, setOptions] = useState(null);
|
|
8
|
+
const [isMounted, setIsMounted] = useState(false);
|
|
9
|
+
const sliderRef = useRef(null);
|
|
10
|
+
useEffect(() => {
|
|
17
11
|
if (!ref) {
|
|
18
12
|
return;
|
|
19
13
|
}
|
|
20
|
-
sliderRef.current = new
|
|
14
|
+
sliderRef.current = new KeenSlider(ref, {
|
|
21
15
|
rubberband: false,
|
|
22
16
|
created: handleDetails,
|
|
23
17
|
slideChanged: handleDetails,
|
|
@@ -37,7 +31,7 @@ const useSlider = ({ shouldObserverMutations, shouldAutoDisable, ...opt } = {})
|
|
|
37
31
|
};
|
|
38
32
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
39
33
|
}, [ref]);
|
|
40
|
-
const isActiveIndex =
|
|
34
|
+
const isActiveIndex = useCallback((index) => index === details?.rel, [details]);
|
|
41
35
|
const handleDetails = (ref) => {
|
|
42
36
|
const details = ref.track.details;
|
|
43
37
|
setIsMounted(true);
|
|
@@ -77,7 +71,6 @@ const useSlider = ({ shouldObserverMutations, shouldAutoDisable, ...opt } = {})
|
|
|
77
71
|
},
|
|
78
72
|
];
|
|
79
73
|
};
|
|
80
|
-
exports.useSlider = useSlider;
|
|
81
74
|
const MutationPlugin = slider => {
|
|
82
75
|
const observer = new MutationObserver(() => {
|
|
83
76
|
slider.update(slider.options);
|
|
@@ -1,11 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
const ref = (0, react_1.useRef)(null);
|
|
7
|
-
const [render, setRender] = (0, react_1.useState)(typeof window === "undefined");
|
|
8
|
-
(0, react_1.useEffect)(() => {
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
export const useStaticContent = () => {
|
|
3
|
+
const ref = useRef(null);
|
|
4
|
+
const [render, setRender] = useState(typeof window === "undefined");
|
|
5
|
+
useEffect(() => {
|
|
9
6
|
// check if the innerHTML is empty as client side navigation
|
|
10
7
|
// need to render the component without server-side backup
|
|
11
8
|
const isEmpty = ref.current?.innerHTML === "";
|
|
@@ -16,4 +13,3 @@ const useStaticContent = () => {
|
|
|
16
13
|
}, []);
|
|
17
14
|
return [render, ref];
|
|
18
15
|
};
|
|
19
|
-
exports.useStaticContent = useStaticContent;
|
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ensureArray = exports.first = exports.isDefined = exports.isObject = exports.isString = void 0;
|
|
4
|
-
const isString = (value) => {
|
|
1
|
+
export const isString = (value) => {
|
|
5
2
|
return typeof value === "string";
|
|
6
3
|
};
|
|
7
|
-
|
|
8
|
-
const isObject = (value) => {
|
|
4
|
+
export const isObject = (value) => {
|
|
9
5
|
return typeof value === "object" && !Array.isArray(value);
|
|
10
6
|
};
|
|
11
|
-
|
|
12
|
-
const isDefined = (value) => {
|
|
7
|
+
export const isDefined = (value) => {
|
|
13
8
|
return value !== undefined && value !== null;
|
|
14
9
|
};
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
exports.first = first;
|
|
18
|
-
const ensureArray = (value) => value ? (Array.isArray(value) ? value : [value]) : [];
|
|
19
|
-
exports.ensureArray = ensureArray;
|
|
10
|
+
export const first = (value) => value ? (Array.isArray(value) ? value.at(0) : value) : undefined;
|
|
11
|
+
export const ensureArray = (value) => value ? (Array.isArray(value) ? value : [value]) : [];
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
|
|
7
|
-
const useDebounce = (fn, ms, deps) => {
|
|
8
|
-
const bounce = (0, react_1.useMemo)(() => (0, debounce_1.debounce)(fn, ms), [fn, ms]);
|
|
9
|
-
(0, react_1.useEffect)(() => (deps && Array.isArray(deps) ? bounce() : bounce()), [deps, bounce]);
|
|
2
|
+
import { useEffect, useMemo } from "react";
|
|
3
|
+
import { debounce } from "./debounce";
|
|
4
|
+
export const useDebounce = (fn, ms, deps) => {
|
|
5
|
+
const bounce = useMemo(() => debounce(fn, ms), [fn, ms]);
|
|
6
|
+
useEffect(() => (deps && Array.isArray(deps) ? bounce() : bounce()), [deps, bounce]);
|
|
10
7
|
};
|
|
11
|
-
exports.useDebounce = useDebounce;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const intervalRef = (0, react_1.useRef)(null);
|
|
8
|
-
const executions = (0, react_1.useRef)(0);
|
|
9
|
-
const startInterval = (0, react_1.useCallback)(() => {
|
|
2
|
+
import { useCallback, useEffect, useRef } from "react";
|
|
3
|
+
export const useInterval = (callback, interval, maxExecutions) => {
|
|
4
|
+
const intervalRef = useRef(null);
|
|
5
|
+
const executions = useRef(0);
|
|
6
|
+
const startInterval = useCallback(() => {
|
|
10
7
|
if (intervalRef.current) {
|
|
11
8
|
clearInterval(intervalRef.current);
|
|
12
9
|
}
|
|
@@ -22,13 +19,13 @@ const useInterval = (callback, interval, maxExecutions) => {
|
|
|
22
19
|
}
|
|
23
20
|
}, interval);
|
|
24
21
|
}, [callback, interval, maxExecutions]);
|
|
25
|
-
const cancelInterval =
|
|
22
|
+
const cancelInterval = useCallback(() => {
|
|
26
23
|
if (intervalRef.current) {
|
|
27
24
|
clearInterval(intervalRef.current);
|
|
28
25
|
intervalRef.current = null;
|
|
29
26
|
}
|
|
30
27
|
}, []);
|
|
31
|
-
|
|
28
|
+
useEffect(() => {
|
|
32
29
|
return () => {
|
|
33
30
|
if (intervalRef.current) {
|
|
34
31
|
clearInterval(intervalRef.current);
|
|
@@ -37,4 +34,3 @@ const useInterval = (callback, interval, maxExecutions) => {
|
|
|
37
34
|
}, []);
|
|
38
35
|
return { startInterval, cancelInterval };
|
|
39
36
|
};
|
|
40
|
-
exports.useInterval = useInterval;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const useIsDocumentHidden = () => {
|
|
6
|
-
const [isDocumentHidden, setIsDocumentHidden] = (0, react_1.useState)(document.hidden);
|
|
7
|
-
(0, react_1.useEffect)(() => {
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
export const useIsDocumentHidden = () => {
|
|
3
|
+
const [isDocumentHidden, setIsDocumentHidden] = useState(document.hidden);
|
|
4
|
+
useEffect(() => {
|
|
8
5
|
const handleVisibilityChange = () => setIsDocumentHidden(document.hidden);
|
|
9
6
|
document.addEventListener("visibilitychange", handleVisibilityChange);
|
|
10
7
|
return () => document.removeEventListener("visibilitychange", handleVisibilityChange);
|
|
11
8
|
}, []);
|
|
12
9
|
return isDocumentHidden;
|
|
13
10
|
};
|
|
14
|
-
exports.useIsDocumentHidden = useIsDocumentHidden;
|
|
@@ -1,18 +1,15 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
exports.useMediaQuery = void 0;
|
|
5
|
-
const react_1 = require("react");
|
|
2
|
+
import { useEffect, useRef, useState } from "react";
|
|
6
3
|
/**
|
|
7
4
|
* Hook to track media query state
|
|
8
5
|
* @param query - The media query string (e.g., "(min-width: 1024px)")
|
|
9
6
|
* @returns boolean indicating if the media query matches
|
|
10
7
|
*/
|
|
11
|
-
const useMediaQuery = (query) => {
|
|
8
|
+
export const useMediaQuery = (query) => {
|
|
12
9
|
// Default to false for SSR to prevent hydration mismatch
|
|
13
|
-
const [matches, setMatches] =
|
|
14
|
-
const currentMatches =
|
|
15
|
-
|
|
10
|
+
const [matches, setMatches] = useState(false);
|
|
11
|
+
const currentMatches = useRef(matches);
|
|
12
|
+
useEffect(() => {
|
|
16
13
|
// Only run on client side
|
|
17
14
|
if (typeof window === "undefined") {
|
|
18
15
|
return;
|
|
@@ -39,4 +36,3 @@ const useMediaQuery = (query) => {
|
|
|
39
36
|
}, [query]);
|
|
40
37
|
return matches;
|
|
41
38
|
};
|
|
42
|
-
exports.useMediaQuery = useMediaQuery;
|
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const useScrollAway = (elementId, options) => {
|
|
7
|
-
(0, react_1.useEffect)(() => {
|
|
2
|
+
import { useEffect } from "react";
|
|
3
|
+
export const useScrollAway = (elementId, options) => {
|
|
4
|
+
useEffect(() => {
|
|
8
5
|
if (typeof document === "undefined") {
|
|
9
6
|
return;
|
|
10
7
|
}
|
|
@@ -44,4 +41,3 @@ const useScrollAway = (elementId, options) => {
|
|
|
44
41
|
return () => targetElement.removeEventListener("scroll", handleScroll);
|
|
45
42
|
}, [elementId, options]);
|
|
46
43
|
};
|
|
47
|
-
exports.useScrollAway = useScrollAway;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const timeoutRef = (0, react_1.useRef)(null);
|
|
8
|
-
const executions = (0, react_1.useRef)(0);
|
|
9
|
-
const startTimeout = (0, react_1.useCallback)(() => {
|
|
2
|
+
import { useCallback, useRef } from "react";
|
|
3
|
+
export const useTimeout = (callback, duration, maxExecutions) => {
|
|
4
|
+
const timeoutRef = useRef(null);
|
|
5
|
+
const executions = useRef(0);
|
|
6
|
+
const startTimeout = useCallback(() => {
|
|
10
7
|
if (undefined !== maxExecutions && maxExecutions <= executions.current) {
|
|
11
8
|
return;
|
|
12
9
|
}
|
|
@@ -16,7 +13,7 @@ const useTimeout = (callback, duration, maxExecutions) => {
|
|
|
16
13
|
}, duration);
|
|
17
14
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
18
15
|
}, []);
|
|
19
|
-
const cancelTimeout =
|
|
16
|
+
const cancelTimeout = useCallback(() => {
|
|
20
17
|
if (timeoutRef.current) {
|
|
21
18
|
clearTimeout(timeoutRef.current);
|
|
22
19
|
timeoutRef.current = null;
|
|
@@ -24,4 +21,3 @@ const useTimeout = (callback, duration, maxExecutions) => {
|
|
|
24
21
|
}, []);
|
|
25
22
|
return { startTimeout, cancelTimeout };
|
|
26
23
|
};
|
|
27
|
-
exports.useTimeout = useTimeout;
|
package/dist/es/mock/block.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mockBlock = void 0;
|
|
4
|
-
const mockBlock = (overwrite) => ({
|
|
1
|
+
export const mockBlock = (overwrite) => ({
|
|
5
2
|
entryId: "123",
|
|
6
3
|
locale: "de",
|
|
7
4
|
draftMode: false,
|
|
8
5
|
...overwrite,
|
|
9
6
|
});
|
|
10
|
-
exports.mockBlock = mockBlock;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.generateRte = exports.generateRteData = exports.generateRteNewline = exports.generateRteAsset = exports.generateRteEmbed = exports.generateRteParagraph = exports.generateRteHeadline = exports.generateRteLink = exports.generateRteText = void 0;
|
|
4
|
-
const rich_text_types_1 = require("@contentful/rich-text-types");
|
|
5
|
-
const generateRteText = (text, marks = []) => {
|
|
1
|
+
import { BLOCKS, INLINES, } from "@contentful/rich-text-types";
|
|
2
|
+
export const generateRteText = (text, marks = []) => {
|
|
6
3
|
return {
|
|
7
4
|
data: {},
|
|
8
5
|
marks,
|
|
@@ -10,36 +7,32 @@ const generateRteText = (text, marks = []) => {
|
|
|
10
7
|
nodeType: "text",
|
|
11
8
|
};
|
|
12
9
|
};
|
|
13
|
-
|
|
14
|
-
const generateRteLink = (text, url) => {
|
|
10
|
+
export const generateRteLink = (text, url) => {
|
|
15
11
|
return {
|
|
16
12
|
data: {
|
|
17
13
|
uri: url,
|
|
18
14
|
},
|
|
19
|
-
content: [
|
|
20
|
-
nodeType:
|
|
15
|
+
content: [generateRteText(text)],
|
|
16
|
+
nodeType: INLINES.HYPERLINK,
|
|
21
17
|
};
|
|
22
18
|
};
|
|
23
|
-
|
|
24
|
-
const generateRteHeadline = (text, marks = []) => {
|
|
19
|
+
export const generateRteHeadline = (text, marks = []) => {
|
|
25
20
|
return {
|
|
26
21
|
data: {},
|
|
27
|
-
content: [
|
|
28
|
-
nodeType:
|
|
22
|
+
content: [generateRteText(text, marks)],
|
|
23
|
+
nodeType: BLOCKS.HEADING_3,
|
|
29
24
|
};
|
|
30
25
|
};
|
|
31
|
-
|
|
32
|
-
const generateRteParagraph = (children) => {
|
|
26
|
+
export const generateRteParagraph = (children) => {
|
|
33
27
|
return {
|
|
34
28
|
content: children,
|
|
35
29
|
data: {},
|
|
36
|
-
nodeType:
|
|
30
|
+
nodeType: BLOCKS.PARAGRAPH,
|
|
37
31
|
};
|
|
38
32
|
};
|
|
39
|
-
|
|
40
|
-
const generateRteEmbed = (id) => {
|
|
33
|
+
export const generateRteEmbed = (id) => {
|
|
41
34
|
return {
|
|
42
|
-
nodeType:
|
|
35
|
+
nodeType: BLOCKS.EMBEDDED_ENTRY,
|
|
43
36
|
data: {
|
|
44
37
|
target: {
|
|
45
38
|
sys: {
|
|
@@ -52,10 +45,9 @@ const generateRteEmbed = (id) => {
|
|
|
52
45
|
content: [],
|
|
53
46
|
};
|
|
54
47
|
};
|
|
55
|
-
|
|
56
|
-
const generateRteAsset = (id) => {
|
|
48
|
+
export const generateRteAsset = (id) => {
|
|
57
49
|
return {
|
|
58
|
-
nodeType:
|
|
50
|
+
nodeType: BLOCKS.EMBEDDED_ASSET,
|
|
59
51
|
data: {
|
|
60
52
|
target: {
|
|
61
53
|
sys: {
|
|
@@ -68,20 +60,16 @@ const generateRteAsset = (id) => {
|
|
|
68
60
|
content: [],
|
|
69
61
|
};
|
|
70
62
|
};
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
exports.generateRteNewline = generateRteNewline;
|
|
74
|
-
const generateRteData = (children) => {
|
|
63
|
+
export const generateRteNewline = () => generateRteParagraph([generateRteText("")]);
|
|
64
|
+
export const generateRteData = (children) => {
|
|
75
65
|
return {
|
|
76
66
|
content: children,
|
|
77
67
|
data: {},
|
|
78
|
-
nodeType:
|
|
68
|
+
nodeType: BLOCKS.DOCUMENT,
|
|
79
69
|
};
|
|
80
70
|
};
|
|
81
|
-
|
|
82
|
-
const generateRte = (json) => {
|
|
71
|
+
export const generateRte = (json) => {
|
|
83
72
|
return {
|
|
84
73
|
json,
|
|
85
74
|
};
|
|
86
75
|
};
|
|
87
|
-
exports.generateRte = generateRte;
|
package/dist/es/rte/index.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const rich_text_react_renderer_1 = require("@contentful/rich-text-react-renderer");
|
|
6
|
-
const typeChecks_1 = require("../lib/typeChecks");
|
|
7
|
-
const Rte = ({ data, options, ...props }) => {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { documentToReactComponents } from "@contentful/rich-text-react-renderer";
|
|
3
|
+
import { isString } from "../lib/typeChecks";
|
|
4
|
+
export const Rte = ({ data, options, ...props }) => {
|
|
8
5
|
if (!data) {
|
|
9
6
|
return null;
|
|
10
7
|
}
|
|
@@ -12,9 +9,8 @@ const Rte = ({ data, options, ...props }) => {
|
|
|
12
9
|
if (!json) {
|
|
13
10
|
return null;
|
|
14
11
|
}
|
|
15
|
-
if (
|
|
16
|
-
return (
|
|
12
|
+
if (isString(json)) {
|
|
13
|
+
return _jsx("div", { ...props, children: json });
|
|
17
14
|
}
|
|
18
|
-
return (
|
|
15
|
+
return _jsx("div", { ...props, children: documentToReactComponents(json, options) });
|
|
19
16
|
};
|
|
20
|
-
exports.Rte = Rte;
|
|
@@ -1,8 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.StructuredData = void 0;
|
|
4
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
-
const StructuredData = ({ data }) => {
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
export const StructuredData = ({ data }) => {
|
|
6
3
|
if (!data) {
|
|
7
4
|
return null;
|
|
8
5
|
}
|
|
@@ -10,6 +7,5 @@ const StructuredData = ({ data }) => {
|
|
|
10
7
|
"@context": "https://schema.org",
|
|
11
8
|
...data,
|
|
12
9
|
};
|
|
13
|
-
return ((
|
|
10
|
+
return (_jsx("script", { type: "application/ld+json", dangerouslySetInnerHTML: { __html: JSON.stringify(structuredData) } }));
|
|
14
11
|
};
|
|
15
|
-
exports.StructuredData = StructuredData;
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.withCookiebot = exports.useCookiebot = exports.CookiebotProvider = exports.CookiebotProviderContext = void 0;
|
|
8
|
-
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
9
|
-
const react_1 = require("react");
|
|
10
|
-
const script_1 = __importDefault(require("next/script"));
|
|
11
|
-
exports.CookiebotProviderContext = (0, react_1.createContext)({});
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useState } from "react";
|
|
4
|
+
import Script from "next/script";
|
|
5
|
+
export const CookiebotProviderContext = createContext({});
|
|
12
6
|
const closeWidget = () => {
|
|
13
7
|
if (typeof window !== "undefined") {
|
|
14
8
|
window?.Cookiebot?.hide();
|
|
@@ -19,13 +13,13 @@ const openWidget = () => {
|
|
|
19
13
|
window?.Cookiebot?.show();
|
|
20
14
|
}
|
|
21
15
|
};
|
|
22
|
-
const CookiebotProvider = ({ locale, cookieBotId, children, }) => {
|
|
23
|
-
const [consentUpdate, setConsentUpdate] =
|
|
24
|
-
const [isAccepted, setIsAccepted] =
|
|
25
|
-
const [isConsentAnswered, setIsConsentAnswered] =
|
|
26
|
-
const [isLoaded, setIsLoaded] =
|
|
27
|
-
const [isOpened, setIsOpened] =
|
|
28
|
-
const [consent, setConsent] =
|
|
16
|
+
export const CookiebotProvider = ({ locale, cookieBotId, children, }) => {
|
|
17
|
+
const [consentUpdate, setConsentUpdate] = useState(0);
|
|
18
|
+
const [isAccepted, setIsAccepted] = useState(false);
|
|
19
|
+
const [isConsentAnswered, setIsConsentAnswered] = useState(false);
|
|
20
|
+
const [isLoaded, setIsLoaded] = useState(false);
|
|
21
|
+
const [isOpened, setIsOpened] = useState(false);
|
|
22
|
+
const [consent, setConsent] = useState({
|
|
29
23
|
necessary: false,
|
|
30
24
|
preferences: false,
|
|
31
25
|
statistics: false,
|
|
@@ -33,7 +27,7 @@ const CookiebotProvider = ({ locale, cookieBotId, children, }) => {
|
|
|
33
27
|
method: null,
|
|
34
28
|
});
|
|
35
29
|
const checkConsent = (key) => isAccepted && isLoaded && !!consent[key];
|
|
36
|
-
|
|
30
|
+
useEffect(() => {
|
|
37
31
|
const openedInitHandler = () => { };
|
|
38
32
|
const tagsExecutedHandler = () => { };
|
|
39
33
|
const openedHandler = () => {
|
|
@@ -74,7 +68,7 @@ const CookiebotProvider = ({ locale, cookieBotId, children, }) => {
|
|
|
74
68
|
window.removeEventListener("CookiebotOnTagsExecuted", tagsExecutedHandler);
|
|
75
69
|
};
|
|
76
70
|
}, []);
|
|
77
|
-
return ((
|
|
71
|
+
return (_jsxs(CookiebotProviderContext.Provider, { value: {
|
|
78
72
|
openWidget,
|
|
79
73
|
closeWidget,
|
|
80
74
|
isLoaded,
|
|
@@ -84,12 +78,9 @@ const CookiebotProvider = ({ locale, cookieBotId, children, }) => {
|
|
|
84
78
|
checkConsent,
|
|
85
79
|
consent,
|
|
86
80
|
consentUpdate,
|
|
87
|
-
}, children: [(
|
|
81
|
+
}, children: [_jsx(Script, { id: "Cookiebot", "data-culture": locale.toUpperCase(), src: `https://consent.cookiebot.com/uc.js?cbid=${cookieBotId}` }), children] }));
|
|
88
82
|
};
|
|
89
|
-
|
|
90
|
-
const
|
|
91
|
-
|
|
92
|
-
const withCookiebot = (Component) => {
|
|
93
|
-
return (props) => ((0, jsx_runtime_1.jsx)(exports.CookiebotProvider, { ...props, children: (0, jsx_runtime_1.jsx)(Component, { ...props }) }));
|
|
83
|
+
export const useCookiebot = () => useContext(CookiebotProviderContext);
|
|
84
|
+
export const withCookiebot = (Component) => {
|
|
85
|
+
return (props) => (_jsx(CookiebotProvider, { ...props, children: _jsx(Component, { ...props }) }));
|
|
94
86
|
};
|
|
95
|
-
exports.withCookiebot = withCookiebot;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
};
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
const react_1 = require("react");
|
|
10
|
-
const script_1 = __importDefault(require("next/script"));
|
|
11
|
-
const Context = (0, react_1.createContext)({});
|
|
12
|
-
const GtmProvider = ({ hasConsent, onBeforeGtmSetup, onAfterGtmSetup, gtmDomain, gtmId, children, }) => {
|
|
13
|
-
(0, exports.useDataEventForwarder)(hasConsent);
|
|
14
|
-
(0, react_1.useEffect)(() => {
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useEffect, useLayoutEffect, } from "react";
|
|
4
|
+
import Script from "next/script";
|
|
5
|
+
const Context = createContext({});
|
|
6
|
+
export const GtmProvider = ({ hasConsent, onBeforeGtmSetup, onAfterGtmSetup, gtmDomain, gtmId, children, }) => {
|
|
7
|
+
useDataEventForwarder(hasConsent);
|
|
8
|
+
useEffect(() => {
|
|
15
9
|
if (onBeforeGtmSetup) {
|
|
16
10
|
onBeforeGtmSetup();
|
|
17
11
|
}
|
|
@@ -22,7 +16,7 @@ const GtmProvider = ({ hasConsent, onBeforeGtmSetup, onAfterGtmSetup, gtmDomain,
|
|
|
22
16
|
}
|
|
23
17
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
24
18
|
}, []);
|
|
25
|
-
return ((
|
|
19
|
+
return (_jsxs(Context.Provider, { value: { hasConsent }, children: [hasConsent && (_jsx(Script, { id: "google-tag-manager", "data-cookieconsent": "marketing", children: `
|
|
26
20
|
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
|
|
27
21
|
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
|
|
28
22
|
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
|
|
@@ -30,16 +24,13 @@ const GtmProvider = ({ hasConsent, onBeforeGtmSetup, onAfterGtmSetup, gtmDomain,
|
|
|
30
24
|
})(window,document,'script','dataLayer','${gtmId}');
|
|
31
25
|
` })), children] }));
|
|
32
26
|
};
|
|
33
|
-
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
const withGtm = (Component) => {
|
|
37
|
-
return (props) => ((0, jsx_runtime_1.jsx)(exports.GtmProvider, { ...props, children: (0, jsx_runtime_1.jsx)(Component, { ...props }) }));
|
|
27
|
+
export const useGtm = () => useContext(Context);
|
|
28
|
+
export const withGtm = (Component) => {
|
|
29
|
+
return (props) => (_jsx(GtmProvider, { ...props, children: _jsx(Component, { ...props }) }));
|
|
38
30
|
};
|
|
39
|
-
|
|
40
|
-
const
|
|
41
|
-
|
|
42
|
-
(0, react_1.useEffect)(() => {
|
|
31
|
+
export const useDataLayer = (input, deps = []) => {
|
|
32
|
+
const hasConsent = useGtm();
|
|
33
|
+
useEffect(() => {
|
|
43
34
|
if (!hasConsent) {
|
|
44
35
|
return;
|
|
45
36
|
}
|
|
@@ -56,9 +47,8 @@ const useDataLayer = (input, deps = []) => {
|
|
|
56
47
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
48
|
}, [hasConsent, input, ...deps]);
|
|
58
49
|
};
|
|
59
|
-
|
|
60
|
-
const
|
|
61
|
-
const { hasConsent } = (0, exports.useGtm)();
|
|
50
|
+
export const useLazyDataLayer = () => {
|
|
51
|
+
const { hasConsent } = useGtm();
|
|
62
52
|
return (input) => {
|
|
63
53
|
if (!hasConsent || !input) {
|
|
64
54
|
return;
|
|
@@ -72,9 +62,8 @@ const useLazyDataLayer = () => {
|
|
|
72
62
|
}
|
|
73
63
|
};
|
|
74
64
|
};
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
(0, react_1.useLayoutEffect)(() => {
|
|
65
|
+
export const useDataEventForwarder = (hasConsent) => {
|
|
66
|
+
useLayoutEffect(() => {
|
|
78
67
|
const captureDataEvent = (event) => {
|
|
79
68
|
if (!hasConsent) {
|
|
80
69
|
return;
|
|
@@ -111,4 +100,3 @@ const useDataEventForwarder = (hasConsent) => {
|
|
|
111
100
|
};
|
|
112
101
|
}, [hasConsent]);
|
|
113
102
|
};
|
|
114
|
-
exports.useDataEventForwarder = useDataEventForwarder;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/es/types/block.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/es/types/preview.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/dist/es/types/style.d.ts
CHANGED
|
@@ -4,4 +4,9 @@ export interface StyledProps {
|
|
|
4
4
|
export type PropsWithClassName<P = object> = P & {
|
|
5
5
|
className?: string;
|
|
6
6
|
};
|
|
7
|
+
export type PropsWithClassNames<K extends string, P = object> = P & {
|
|
8
|
+
classNames?: {
|
|
9
|
+
[Key in K]?: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
7
12
|
//# sourceMappingURL=style.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../types/style.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"style.d.ts","sourceRoot":"","sources":["../../../types/style.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACtB;AAED,MAAM,MAAM,kBAAkB,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExE,MAAM,MAAM,mBAAmB,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG;IAChE,UAAU,CAAC,EAAE;SACR,GAAG,IAAI,CAAC,CAAC,CAAC,EAAE,MAAM;KACtB,CAAC;CACL,CAAC"}
|
package/dist/es/types/style.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
.story-container {
|
|
2
|
+
position: relative;
|
|
3
|
+
margin: 0 auto;
|
|
4
|
+
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
|
|
5
|
+
padding: 2rem;
|
|
6
|
+
width: 400px;
|
|
7
|
+
border-radius: 30px;
|
|
8
|
+
|
|
9
|
+
&.large {
|
|
10
|
+
width: 800px;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
&.flex {
|
|
14
|
+
display: flex;
|
|
15
|
+
gap: 4px;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
&.flex-column {
|
|
19
|
+
flex-direction: column;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
&.full-height {
|
|
23
|
+
height: 100vh;
|
|
24
|
+
overflow-y: auto;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
&.full-width {
|
|
28
|
+
width: 100%;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
&.no-padding {
|
|
32
|
+
padding: 0;
|
|
33
|
+
}
|
|
34
|
+
}
|