@becklyn/next 1.0.1

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 (152) hide show
  1. package/LICENSE +21 -0
  2. package/dist/cjs/contentful/imageLoader.d.ts +7 -0
  3. package/dist/cjs/contentful/imageLoader.d.ts.map +1 -0
  4. package/dist/cjs/contentful/imageLoader.js +24 -0
  5. package/dist/cjs/contentful/inspector.d.ts +33 -0
  6. package/dist/cjs/contentful/inspector.d.ts.map +1 -0
  7. package/dist/cjs/contentful/inspector.js +44 -0
  8. package/dist/cjs/format/phone.d.ts +2 -0
  9. package/dist/cjs/format/phone.d.ts.map +1 -0
  10. package/dist/cjs/format/phone.js +10 -0
  11. package/dist/cjs/lib/click.d.ts +5 -0
  12. package/dist/cjs/lib/click.d.ts.map +1 -0
  13. package/dist/cjs/lib/click.js +18 -0
  14. package/dist/cjs/lib/dropdown.d.ts +29 -0
  15. package/dist/cjs/lib/dropdown.d.ts.map +1 -0
  16. package/dist/cjs/lib/dropdown.js +88 -0
  17. package/dist/cjs/lib/escape.d.ts +3 -0
  18. package/dist/cjs/lib/escape.d.ts.map +1 -0
  19. package/dist/cjs/lib/escape.js +17 -0
  20. package/dist/cjs/lib/focusTrap.d.ts +12 -0
  21. package/dist/cjs/lib/focusTrap.d.ts.map +1 -0
  22. package/dist/cjs/lib/focusTrap.js +73 -0
  23. package/dist/cjs/lib/geo.d.ts +3 -0
  24. package/dist/cjs/lib/geo.d.ts.map +1 -0
  25. package/dist/cjs/lib/geo.js +32 -0
  26. package/dist/cjs/lib/intersection.d.ts +10 -0
  27. package/dist/cjs/lib/intersection.d.ts.map +1 -0
  28. package/dist/cjs/lib/intersection.js +27 -0
  29. package/dist/cjs/lib/isMounted.d.ts +2 -0
  30. package/dist/cjs/lib/isMounted.d.ts.map +1 -0
  31. package/dist/cjs/lib/isMounted.js +12 -0
  32. package/dist/cjs/lib/slider.d.ts +23 -0
  33. package/dist/cjs/lib/slider.d.ts.map +1 -0
  34. package/dist/cjs/lib/slider.js +129 -0
  35. package/dist/cjs/lib/staticContent.d.ts +4 -0
  36. package/dist/cjs/lib/staticContent.d.ts.map +1 -0
  37. package/dist/cjs/lib/staticContent.js +19 -0
  38. package/dist/cjs/lib/typeChecks.d.ts +8 -0
  39. package/dist/cjs/lib/typeChecks.d.ts.map +1 -0
  40. package/dist/cjs/lib/typeChecks.js +19 -0
  41. package/dist/cjs/mock/block.d.ts +3 -0
  42. package/dist/cjs/mock/block.d.ts.map +1 -0
  43. package/dist/cjs/mock/block.js +5 -0
  44. package/dist/cjs/rte/generators.d.ts +12 -0
  45. package/dist/cjs/rte/generators.d.ts.map +1 -0
  46. package/dist/cjs/rte/generators.js +87 -0
  47. package/dist/cjs/rte/index.d.ts +14 -0
  48. package/dist/cjs/rte/index.d.ts.map +1 -0
  49. package/dist/cjs/rte/index.js +32 -0
  50. package/dist/cjs/structuredData/index.d.ts +7 -0
  51. package/dist/cjs/structuredData/index.d.ts.map +1 -0
  52. package/dist/cjs/structuredData/index.js +12 -0
  53. package/dist/cjs/tracking/cookiebot/index.d.ts +22 -0
  54. package/dist/cjs/tracking/cookiebot/index.d.ts.map +1 -0
  55. package/dist/cjs/tracking/cookiebot/index.js +99 -0
  56. package/dist/cjs/tracking/cookiebot/types.d.ts +47 -0
  57. package/dist/cjs/tracking/cookiebot/types.d.ts.map +1 -0
  58. package/dist/cjs/tracking/cookiebot/types.js +2 -0
  59. package/dist/cjs/tracking/gtm/index.d.ts +17 -0
  60. package/dist/cjs/tracking/gtm/index.d.ts.map +1 -0
  61. package/dist/cjs/tracking/gtm/index.js +115 -0
  62. package/dist/cjs/tracking/gtm/types.d.ts +19 -0
  63. package/dist/cjs/tracking/gtm/types.d.ts.map +1 -0
  64. package/dist/cjs/tracking/gtm/types.js +2 -0
  65. package/dist/cjs/tracking/index.d.ts +8 -0
  66. package/dist/cjs/tracking/index.d.ts.map +1 -0
  67. package/dist/cjs/tracking/index.js +10 -0
  68. package/dist/cjs/types/block.d.ts +4 -0
  69. package/dist/cjs/types/block.d.ts.map +1 -0
  70. package/dist/cjs/types/block.js +2 -0
  71. package/dist/cjs/types/preview.d.ts +8 -0
  72. package/dist/cjs/types/preview.d.ts.map +1 -0
  73. package/dist/cjs/types/preview.js +2 -0
  74. package/dist/cjs/types/style.d.ts +7 -0
  75. package/dist/cjs/types/style.d.ts.map +1 -0
  76. package/dist/cjs/types/style.js +2 -0
  77. package/dist/es/contentful/imageLoader.d.ts +7 -0
  78. package/dist/es/contentful/imageLoader.d.ts.map +1 -0
  79. package/dist/es/contentful/imageLoader.js +24 -0
  80. package/dist/es/contentful/inspector.d.ts +33 -0
  81. package/dist/es/contentful/inspector.d.ts.map +1 -0
  82. package/dist/es/contentful/inspector.js +37 -0
  83. package/dist/es/format/phone.d.ts +2 -0
  84. package/dist/es/format/phone.d.ts.map +1 -0
  85. package/dist/es/format/phone.js +10 -0
  86. package/dist/es/lib/click.d.ts +5 -0
  87. package/dist/es/lib/click.d.ts.map +1 -0
  88. package/dist/es/lib/click.js +18 -0
  89. package/dist/es/lib/dropdown.d.ts +29 -0
  90. package/dist/es/lib/dropdown.d.ts.map +1 -0
  91. package/dist/es/lib/dropdown.js +79 -0
  92. package/dist/es/lib/escape.d.ts +3 -0
  93. package/dist/es/lib/escape.d.ts.map +1 -0
  94. package/dist/es/lib/escape.js +17 -0
  95. package/dist/es/lib/focusTrap.d.ts +12 -0
  96. package/dist/es/lib/focusTrap.d.ts.map +1 -0
  97. package/dist/es/lib/focusTrap.js +64 -0
  98. package/dist/es/lib/geo.d.ts +3 -0
  99. package/dist/es/lib/geo.d.ts.map +1 -0
  100. package/dist/es/lib/geo.js +23 -0
  101. package/dist/es/lib/intersection.d.ts +10 -0
  102. package/dist/es/lib/intersection.d.ts.map +1 -0
  103. package/dist/es/lib/intersection.js +27 -0
  104. package/dist/es/lib/isMounted.d.ts +2 -0
  105. package/dist/es/lib/isMounted.d.ts.map +1 -0
  106. package/dist/es/lib/isMounted.js +12 -0
  107. package/dist/es/lib/slider.d.ts +23 -0
  108. package/dist/es/lib/slider.d.ts.map +1 -0
  109. package/dist/es/lib/slider.js +123 -0
  110. package/dist/es/lib/staticContent.d.ts +4 -0
  111. package/dist/es/lib/staticContent.d.ts.map +1 -0
  112. package/dist/es/lib/staticContent.js +18 -0
  113. package/dist/es/lib/typeChecks.d.ts +8 -0
  114. package/dist/es/lib/typeChecks.d.ts.map +1 -0
  115. package/dist/es/lib/typeChecks.js +19 -0
  116. package/dist/es/mock/block.d.ts +3 -0
  117. package/dist/es/mock/block.d.ts.map +1 -0
  118. package/dist/es/mock/block.js +10 -0
  119. package/dist/es/rte/generators.d.ts +12 -0
  120. package/dist/es/rte/generators.d.ts.map +1 -0
  121. package/dist/es/rte/generators.js +87 -0
  122. package/dist/es/rte/index.d.ts +14 -0
  123. package/dist/es/rte/index.d.ts.map +1 -0
  124. package/dist/es/rte/index.js +20 -0
  125. package/dist/es/structuredData/index.d.ts +7 -0
  126. package/dist/es/structuredData/index.d.ts.map +1 -0
  127. package/dist/es/structuredData/index.js +15 -0
  128. package/dist/es/tracking/cookiebot/index.d.ts +22 -0
  129. package/dist/es/tracking/cookiebot/index.d.ts.map +1 -0
  130. package/dist/es/tracking/cookiebot/index.js +95 -0
  131. package/dist/es/tracking/cookiebot/types.d.ts +47 -0
  132. package/dist/es/tracking/cookiebot/types.d.ts.map +1 -0
  133. package/dist/es/tracking/cookiebot/types.js +2 -0
  134. package/dist/es/tracking/gtm/index.d.ts +17 -0
  135. package/dist/es/tracking/gtm/index.d.ts.map +1 -0
  136. package/dist/es/tracking/gtm/index.js +114 -0
  137. package/dist/es/tracking/gtm/types.d.ts +19 -0
  138. package/dist/es/tracking/gtm/types.d.ts.map +1 -0
  139. package/dist/es/tracking/gtm/types.js +2 -0
  140. package/dist/es/tracking/index.d.ts +8 -0
  141. package/dist/es/tracking/index.d.ts.map +1 -0
  142. package/dist/es/tracking/index.js +10 -0
  143. package/dist/es/types/block.d.ts +4 -0
  144. package/dist/es/types/block.d.ts.map +1 -0
  145. package/dist/es/types/block.js +2 -0
  146. package/dist/es/types/preview.d.ts +8 -0
  147. package/dist/es/types/preview.d.ts.map +1 -0
  148. package/dist/es/types/preview.js +2 -0
  149. package/dist/es/types/style.d.ts +7 -0
  150. package/dist/es/types/style.d.ts.map +1 -0
  151. package/dist/es/types/style.js +2 -0
  152. package/package.json +47 -0
@@ -0,0 +1,115 @@
1
+ "use client";
2
+ "use strict";
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ exports.useDataEventForwarder = exports.useLazyDataLayer = exports.useDataLayer = exports.withGtm = exports.useGtm = exports.GtmProvider = 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
+ const Context = (0, react_1.createContext)({});
12
+ const GtmProvider = ({ hasConsent, onBeforeGtmSetup, onAfterGtmSetup, children, }) => {
13
+ (0, exports.useDataEventForwarder)(hasConsent);
14
+ (0, react_1.useEffect)(() => {
15
+ if (onBeforeGtmSetup) {
16
+ onBeforeGtmSetup();
17
+ }
18
+ window.dataLayer = window.dataLayer || [];
19
+ window.gtag = window.gtag || ((...arg) => window.dataLayer.push(arg));
20
+ if (onAfterGtmSetup) {
21
+ onAfterGtmSetup();
22
+ }
23
+ // eslint-disable-next-line react-hooks/exhaustive-deps
24
+ }, []);
25
+ return ((0, jsx_runtime_1.jsxs)(Context.Provider, { value: { hasConsent }, children: [hasConsent && ((0, jsx_runtime_1.jsx)(script_1.default, { id: "google-tag-manager", "data-cookieconsent": "marketing", children: `
26
+ (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
27
+ new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
28
+ j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
29
+ 'https://dt.visit-bw.com/dt.js?id='+i+dl;f.parentNode.insertBefore(j,f);
30
+ })(window,document,'script','dataLayer','${process.env.NEXT_PUBLIC_GTM_ID}');
31
+ ` })), children] }));
32
+ };
33
+ exports.GtmProvider = GtmProvider;
34
+ const useGtm = () => (0, react_1.useContext)(Context);
35
+ exports.useGtm = useGtm;
36
+ const withGtm = (Component) => {
37
+ return (props) => ((0, jsx_runtime_1.jsx)(exports.GtmProvider, Object.assign({}, props, { children: (0, jsx_runtime_1.jsx)(Component, Object.assign({}, props)) })));
38
+ };
39
+ exports.withGtm = withGtm;
40
+ const useDataLayer = (input, deps = []) => {
41
+ const hasConsent = (0, exports.useGtm)();
42
+ (0, react_1.useEffect)(() => {
43
+ if (!hasConsent) {
44
+ return;
45
+ }
46
+ const data = typeof input === "function" ? input() : input;
47
+ if (!data) {
48
+ return;
49
+ }
50
+ if (window.dataLayer) {
51
+ window.dataLayer.push(data);
52
+ }
53
+ else {
54
+ window.dataLayer = [data];
55
+ }
56
+ // eslint-disable-next-line react-hooks/exhaustive-deps
57
+ }, [hasConsent, input, ...deps]);
58
+ };
59
+ exports.useDataLayer = useDataLayer;
60
+ const useLazyDataLayer = () => {
61
+ const { hasConsent } = (0, exports.useGtm)();
62
+ return (input) => {
63
+ if (!hasConsent || !input) {
64
+ return;
65
+ }
66
+ const data = typeof input === "function" ? input() : input;
67
+ if (window.dataLayer) {
68
+ window.dataLayer.push(data);
69
+ }
70
+ else {
71
+ window.dataLayer = [data];
72
+ }
73
+ };
74
+ };
75
+ exports.useLazyDataLayer = useLazyDataLayer;
76
+ const useDataEventForwarder = (hasConsent) => {
77
+ (0, react_1.useLayoutEffect)(() => {
78
+ const captureDataEvent = (event) => {
79
+ var _a;
80
+ if (!hasConsent) {
81
+ return;
82
+ }
83
+ const target = event.target;
84
+ if (!target) {
85
+ return;
86
+ }
87
+ const element = target.closest("*[data-event]");
88
+ if (!element) {
89
+ return;
90
+ }
91
+ const dataEvent = (_a = element.getAttribute("data-event")) !== null && _a !== void 0 ? _a : undefined;
92
+ const classList = element.classList ? element.classList.toString() : undefined;
93
+ const className = element.className;
94
+ const text = "innerText" in element ? element.innerText : undefined;
95
+ const data = {
96
+ event: "websiteClick",
97
+ dataEvent,
98
+ classList,
99
+ className,
100
+ text,
101
+ };
102
+ if (window.dataLayer) {
103
+ window.dataLayer.push(data);
104
+ }
105
+ else {
106
+ window.dataLayer = [data];
107
+ }
108
+ };
109
+ document.addEventListener("click", captureDataEvent);
110
+ return () => {
111
+ document.removeEventListener("click", captureDataEvent);
112
+ };
113
+ }, [hasConsent]);
114
+ };
115
+ exports.useDataEventForwarder = useDataEventForwarder;
@@ -0,0 +1,19 @@
1
+ export type DataLayer = unknown[] | undefined;
2
+ export type DataLayerData = (() => Record<string, string | number | undefined> | null) | Record<string, string | number | undefined> | null;
3
+ export type Gtag = (event: string, name: string, payload: {
4
+ ad_personalization: "granted" | "denied";
5
+ ad_storage: "granted" | "denied";
6
+ ad_user_data: "granted" | "denied";
7
+ analytics_storage: "granted" | "denied";
8
+ functionality_storage: "granted" | "denied";
9
+ personalization_storage: "granted" | "denied";
10
+ security_storage: "granted" | "denied";
11
+ wait_for_update: number;
12
+ } | null | boolean) => void;
13
+ declare global {
14
+ interface Window {
15
+ dataLayer?: DataLayer;
16
+ gtag?: Gtag;
17
+ }
18
+ }
19
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../tracking/gtm/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,SAAS,GAAG,OAAO,EAAE,GAAG,SAAS,CAAC;AAE9C,MAAM,MAAM,aAAa,GACnB,CAAC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG,IAAI,CAAC,GAC1D,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAC3C,IAAI,CAAC;AAEX,MAAM,MAAM,IAAI,GAAG,CACf,KAAK,EAAE,MAAM,EACb,IAAI,EAAE,MAAM,EACZ,OAAO,EACD;IACI,kBAAkB,EAAE,SAAS,GAAG,QAAQ,CAAC;IACzC,UAAU,EAAE,SAAS,GAAG,QAAQ,CAAC;IACjC,YAAY,EAAE,SAAS,GAAG,QAAQ,CAAC;IACnC,iBAAiB,EAAE,SAAS,GAAG,QAAQ,CAAC;IACxC,qBAAqB,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC5C,uBAAuB,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC9C,gBAAgB,EAAE,SAAS,GAAG,QAAQ,CAAC;IACvC,eAAe,EAAE,MAAM,CAAC;CAC3B,GACD,IAAI,GACJ,OAAO,KACZ,IAAI,CAAC;AAEV,OAAO,CAAC,MAAM,CAAC;IACX,UAAU,MAAM;QACZ,SAAS,CAAC,EAAE,SAAS,CAAC;QACtB,IAAI,CAAC,EAAE,IAAI,CAAC;KACf;CACJ"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export declare const TRACKING: {
2
+ LOGO: string;
3
+ FOOTER: string;
4
+ HEADER: string;
5
+ BUTTON: string;
6
+ MENU: string;
7
+ };
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../tracking/index.tsx"],"names":[],"mappings":"AAAA,eAAO,MAAM,QAAQ;;;;;;CAMpB,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TRACKING = void 0;
4
+ exports.TRACKING = {
5
+ LOGO: "ga-logo",
6
+ FOOTER: "ga-footer",
7
+ HEADER: "ga-header",
8
+ BUTTON: "ga-button",
9
+ MENU: "ga-menu",
10
+ };
@@ -0,0 +1,4 @@
1
+ import { Inspectable } from "./preview";
2
+ export type BlockProps = Inspectable;
3
+ export type Block<B = object> = B & BlockProps;
4
+ //# sourceMappingURL=block.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"block.d.ts","sourceRoot":"","sources":["../../../types/block.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAExC,MAAM,MAAM,UAAU,GAAG,WAAW,CAAC;AAErC,MAAM,MAAM,KAAK,CAAC,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,UAAU,CAAC"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,8 @@
1
+ export interface Previewable {
2
+ draftMode?: boolean;
3
+ }
4
+ export interface Inspectable extends Previewable {
5
+ entryId: string;
6
+ locale: string;
7
+ }
8
+ //# sourceMappingURL=preview.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"preview.d.ts","sourceRoot":"","sources":["../../../types/preview.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,WAAW;IACxB,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,WAAY,SAAQ,WAAW;IAC5C,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;CAClB"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ export interface StyledProps {
2
+ className?: string;
3
+ }
4
+ export type PropsWithClassName<P = object> = P & {
5
+ className?: string;
6
+ };
7
+ //# sourceMappingURL=style.d.ts.map
@@ -0,0 +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"}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1,7 @@
1
+ import { ImageLoaderProps as ImageLoaderProps_ } from "next/image";
2
+ export type ImageLoaderFormat = "webp" | "jpeg" | "png";
3
+ export interface ImageLoaderProps extends ImageLoaderProps_ {
4
+ format?: ImageLoaderFormat;
5
+ }
6
+ export declare const imageLoader: ({ src, width, quality, format }: ImageLoaderProps) => string;
7
+ //# sourceMappingURL=imageLoader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"imageLoader.d.ts","sourceRoot":"","sources":["../../../contentful/imageLoader.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,IAAI,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEnE,MAAM,MAAM,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,CAAC;AAExD,MAAM,WAAW,gBAAiB,SAAQ,iBAAiB;IACvD,MAAM,CAAC,EAAE,iBAAiB,CAAC;CAC9B;AAED,eAAO,MAAM,WAAW,GAAI,iCAA0C,gBAAgB,WAoBrF,CAAC"}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.imageLoader = void 0;
4
+ const imageLoader = ({ src, width, quality, format = "webp" }) => {
5
+ let url = src;
6
+ if (!src.startsWith("https")) {
7
+ if (src.startsWith("http")) {
8
+ url = "https" + url.slice(4);
9
+ }
10
+ else {
11
+ url = `https:${src}`;
12
+ }
13
+ }
14
+ switch (true) {
15
+ case src.includes("ctfassets"):
16
+ case src.includes("contentful"):
17
+ return `${url}?w=${width}&q=${quality || 96}&fm=${format === "jpeg" ? "jpg" : format}`;
18
+ case src.includes("mein.toubiz.de"):
19
+ return `${url}?width=${width}&quality=${quality || 96}&format=image/${format}`;
20
+ default:
21
+ return src;
22
+ }
23
+ };
24
+ exports.imageLoader = imageLoader;
@@ -0,0 +1,33 @@
1
+ export interface InspectableItem {
2
+ entryId?: string;
3
+ draftMode?: boolean;
4
+ locale?: string;
5
+ }
6
+ export interface InspectableField extends Partial<InspectableItem> {
7
+ fieldId?: string;
8
+ assetId?: string;
9
+ }
10
+ interface InspectorProps {
11
+ entryId?: string;
12
+ fieldId?: string;
13
+ assetId?: string;
14
+ draftMode?: boolean;
15
+ locale?: string;
16
+ }
17
+ export declare const getInspectorProps: <T extends InspectorProps>(data: T) => {
18
+ entryId?: undefined;
19
+ fieldId?: undefined;
20
+ assetId?: undefined;
21
+ draftMode?: undefined;
22
+ locale?: undefined;
23
+ } | {
24
+ entryId: string | undefined;
25
+ fieldId: string | undefined;
26
+ assetId: string | undefined;
27
+ draftMode: boolean | undefined;
28
+ locale: string | undefined;
29
+ };
30
+ export declare const removeInspectorProps: <T extends InspectorProps>(data: T) => {};
31
+ export declare const inspector: (data: InspectableField) => Record<string, string | undefined>;
32
+ export {};
33
+ //# sourceMappingURL=inspector.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inspector.d.ts","sourceRoot":"","sources":["../../../contentful/inspector.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,eAAe;IAC5B,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,gBAAiB,SAAQ,OAAO,CAAC,eAAe,CAAC;IAC9D,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,cAAc;IACpB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,iBAAiB,GAAI,CAAC,SAAS,cAAc,EAAE,MAAM,CAAC;;;;;;;;;;;;CAOlE,CAAC;AAEF,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,cAAc,EAAE,MAAM,CAAC,OAQrE,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,MAAM,gBAAgB,KAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAkBnF,CAAC"}
@@ -0,0 +1,37 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.inspector = exports.removeInspectorProps = exports.getInspectorProps = void 0;
4
+ const getInspectorProps = (data) => {
5
+ if (!data) {
6
+ return {};
7
+ }
8
+ const { entryId, fieldId, assetId, draftMode, locale } = data;
9
+ return { entryId, fieldId, assetId, draftMode, locale };
10
+ };
11
+ exports.getInspectorProps = getInspectorProps;
12
+ const removeInspectorProps = (data) => {
13
+ if (!data) {
14
+ return {};
15
+ }
16
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
17
+ const { entryId, fieldId, assetId, draftMode, locale, ...props } = data;
18
+ return props;
19
+ };
20
+ exports.removeInspectorProps = removeInspectorProps;
21
+ const inspector = (data) => {
22
+ if (!data) {
23
+ return {};
24
+ }
25
+ const { entryId, fieldId, assetId, draftMode, locale } = data;
26
+ if (!draftMode || !entryId || (!fieldId && !assetId)) {
27
+ return {};
28
+ }
29
+ return {
30
+ ...(fieldId
31
+ ? { "data-contentful-field-id": fieldId }
32
+ : { "data-contentful-asset-id": assetId }),
33
+ "data-contentful-entry-id": entryId,
34
+ "data-contentful-locale": locale,
35
+ };
36
+ };
37
+ exports.inspector = inspector;
@@ -0,0 +1,2 @@
1
+ export declare const formatPhone: (phone: string | number) => string | number;
2
+ //# sourceMappingURL=phone.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"phone.d.ts","sourceRoot":"","sources":["../../../format/phone.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,WAAW,GAAI,OAAO,MAAM,GAAG,MAAM,oBAMjD,CAAC"}
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.formatPhone = void 0;
4
+ const formatPhone = (phone) => {
5
+ if (typeof phone === "number") {
6
+ return phone;
7
+ }
8
+ return phone.replace(/[ -/)(]/g, "").replace("+49", "0049");
9
+ };
10
+ exports.formatPhone = formatPhone;
@@ -0,0 +1,5 @@
1
+ export interface ClickOutsideOptions {
2
+ callback: (event: MouseEvent) => void;
3
+ }
4
+ export declare const useClickOutside: <T extends HTMLElement>({ callback }: ClickOutsideOptions) => import("react").MutableRefObject<T | null>;
5
+ //# sourceMappingURL=click.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"click.d.ts","sourceRoot":"","sources":["../../../lib/click.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,mBAAmB;IAChC,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,KAAK,IAAI,CAAC;CACzC;AAED,eAAO,MAAM,eAAe,GAAI,CAAC,SAAS,WAAW,EAAE,cAAc,mBAAmB,+CAevF,CAAC"}
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useClickOutside = void 0;
4
+ const react_1 = require("react");
5
+ const useClickOutside = ({ callback }) => {
6
+ const ref = (0, react_1.useRef)(null);
7
+ (0, react_1.useEffect)(() => {
8
+ const handleClickOutside = (event) => {
9
+ if (ref.current && !ref.current.contains(event.target)) {
10
+ callback(event);
11
+ }
12
+ };
13
+ document.addEventListener("mousedown", handleClickOutside);
14
+ return () => document.removeEventListener("mousedown", handleClickOutside);
15
+ });
16
+ return ref;
17
+ };
18
+ exports.useClickOutside = useClickOutside;
@@ -0,0 +1,29 @@
1
+ import { Dispatch, SetStateAction } from "react";
2
+ import { Options } from "@popperjs/core";
3
+ interface DropdownOptions extends Partial<Options> {
4
+ isOpen?: boolean;
5
+ setIsOpen?: Dispatch<SetStateAction<boolean>>;
6
+ onClose?: () => void;
7
+ }
8
+ export declare const useDropdown: ({ isOpen: externalIsOpen, setIsOpen: externalSetIsOpen, onClose, ...options }: DropdownOptions) => {
9
+ styles: {
10
+ [key: string]: React.CSSProperties;
11
+ };
12
+ attributes: {
13
+ [key: string]: {
14
+ [key: string]: string;
15
+ } | undefined;
16
+ };
17
+ state: import("@popperjs/core").State | null;
18
+ update: import("@popperjs/core").Instance["update"] | null;
19
+ forceUpdate: import("@popperjs/core").Instance["forceUpdate"] | null;
20
+ isOpen: boolean;
21
+ setIsOpen: Dispatch<SetStateAction<boolean>>;
22
+ clickOutsideRef: import("react").MutableRefObject<HTMLElement | null>;
23
+ referenceElement: HTMLElement | null;
24
+ popperElement: HTMLElement | null;
25
+ setReferenceElement: Dispatch<SetStateAction<HTMLElement | null>>;
26
+ setPopperElement: Dispatch<SetStateAction<HTMLElement | null>>;
27
+ };
28
+ export {};
29
+ //# sourceMappingURL=dropdown.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dropdown.d.ts","sourceRoot":"","sources":["../../../lib/dropdown.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAAuB,MAAM,OAAO,CAAC;AAEtE,OAAO,EAAE,OAAO,EAAE,MAAM,gBAAgB,CAAC;AAKzC,UAAU,eAAgB,SAAQ,OAAO,CAAC,OAAO,CAAC;IAC9C,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,SAAS,CAAC,EAAE,QAAQ,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,CAAC;IAC9C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;CACxB;AAED,eAAO,MAAM,WAAW,GAAI,+EAKzB,eAAe;;uBAoEsD,MAEhE,aAAK;;;;;;;;;;;;;;;;;CAyBZ,CAAC"}
@@ -0,0 +1,79 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useDropdown = void 0;
4
+ const react_1 = require("react");
5
+ const react_popper_1 = require("react-popper");
6
+ const click_1 = require("./click");
7
+ const escape_1 = require("./escape");
8
+ const focusTrap_1 = require("./focusTrap");
9
+ const useDropdown = ({ isOpen: externalIsOpen, setIsOpen: externalSetIsOpen, onClose, ...options }) => {
10
+ const [internalIsOpen, internalSetIsOpen] = (0, react_1.useState)(false);
11
+ const [referenceElement, setReferenceElement] = (0, react_1.useState)(null);
12
+ const [popperElement, setPopperElement] = (0, react_1.useState)(null);
13
+ const [, { update }] = (0, focusTrap_1.useTrapFocus)(popperElement);
14
+ const isOpen = externalIsOpen !== undefined ? externalIsOpen : internalIsOpen;
15
+ const setIsOpen = externalSetIsOpen !== undefined ? externalSetIsOpen : internalSetIsOpen;
16
+ const clickOutsideRef = (0, click_1.useClickOutside)({
17
+ callback: e => {
18
+ if (popperElement && popperElement.contains(e.target)) {
19
+ return;
20
+ }
21
+ handleClose();
22
+ },
23
+ });
24
+ const popper = (0, react_popper_1.usePopper)(referenceElement, popperElement, options);
25
+ const { forceUpdate } = popper;
26
+ (0, escape_1.useEscapeListener)(e => {
27
+ if (!isOpen || !referenceElement) {
28
+ return;
29
+ }
30
+ if (!referenceElement.contains(e.target) &&
31
+ !e.target.contains(popperElement)) {
32
+ return;
33
+ }
34
+ handleClose();
35
+ }, [referenceElement, popperElement, isOpen]);
36
+ (0, react_1.useEffect)(() => {
37
+ if (!referenceElement) {
38
+ return;
39
+ }
40
+ const observer = new ResizeObserver(() => {
41
+ if (!forceUpdate) {
42
+ return;
43
+ }
44
+ forceUpdate();
45
+ });
46
+ observer.observe(referenceElement);
47
+ return () => observer.disconnect();
48
+ }, [referenceElement, forceUpdate]);
49
+ (0, react_1.useEffect)(() => {
50
+ if (!popperElement) {
51
+ return;
52
+ }
53
+ const observer = new MutationObserver(() => {
54
+ update();
55
+ });
56
+ observer.observe(popperElement, { subtree: true, attributes: true });
57
+ return () => observer.disconnect();
58
+ }, [popperElement, update]);
59
+ const handleClose = () => {
60
+ if (!isOpen) {
61
+ return;
62
+ }
63
+ setIsOpen(false);
64
+ if (onClose) {
65
+ onClose();
66
+ }
67
+ };
68
+ return {
69
+ isOpen,
70
+ setIsOpen,
71
+ clickOutsideRef,
72
+ referenceElement,
73
+ popperElement,
74
+ setReferenceElement,
75
+ setPopperElement,
76
+ ...popper,
77
+ };
78
+ };
79
+ exports.useDropdown = useDropdown;
@@ -0,0 +1,3 @@
1
+ import { DependencyList } from "react";
2
+ export declare const useEscapeListener: (callback: (e: KeyboardEvent) => void, deps?: DependencyList) => void;
3
+ //# sourceMappingURL=escape.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"escape.d.ts","sourceRoot":"","sources":["../../../lib/escape.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAa,MAAM,OAAO,CAAC;AAElD,eAAO,MAAM,iBAAiB,GAAI,UAAU,CAAC,CAAC,EAAE,aAAa,KAAK,IAAI,EAAE,OAAO,cAAc,SAY5F,CAAC"}
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useEscapeListener = void 0;
4
+ const react_1 = require("react");
5
+ const useEscapeListener = (callback, deps) => {
6
+ (0, react_1.useEffect)(() => {
7
+ const onKeyDown = (e) => {
8
+ if (e.key === "Escape") {
9
+ callback(e);
10
+ }
11
+ };
12
+ document.addEventListener("keydown", onKeyDown);
13
+ return () => document.removeEventListener("keydown", onKeyDown);
14
+ // eslint-disable-next-line react-hooks/exhaustive-deps
15
+ }, deps);
16
+ };
17
+ exports.useEscapeListener = useEscapeListener;
@@ -0,0 +1,12 @@
1
+ import { MutableRefObject } from "react";
2
+ export declare const checkCanFocusTrap: (container: (HTMLElement | SVGElement)[]) => Promise<void>;
3
+ export declare 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\"])";
4
+ type UseTrapFocus<T> = [
5
+ MutableRefObject<T | null>,
6
+ {
7
+ update: () => void;
8
+ }
9
+ ];
10
+ export declare const useTrapFocus: <T extends HTMLElement>(container?: T | null) => UseTrapFocus<T>;
11
+ export {};
12
+ //# sourceMappingURL=focusTrap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"focusTrap.d.ts","sourceRoot":"","sources":["../../../lib/focusTrap.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAA4C,MAAM,OAAO,CAAC;AAEnF,eAAO,MAAM,iBAAiB,GAAU,WAAW,CAAC,WAAW,GAAG,UAAU,CAAC,EAAE,kBAa9E,CAAC;AAEF,eAAO,MAAM,kBAAkB,kMACwJ,CAAC;AAExL,KAAK,YAAY,CAAC,CAAC,IAAI;IACnB,gBAAgB,CAAC,CAAC,GAAG,IAAI,CAAC;IAC1B;QACI,MAAM,EAAE,MAAM,IAAI,CAAC;KACtB;CACJ,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,CAAC,SAAS,WAAW,EAAE,YAAY,CAAC,GAAG,IAAI,KAAG,YAAY,CAAC,CAAC,CAyDxF,CAAC"}
@@ -0,0 +1,64 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useTrapFocus = exports.FOCUSABLE_ELEMENTS = exports.checkCanFocusTrap = void 0;
4
+ const react_1 = require("react");
5
+ const checkCanFocusTrap = async (container) => {
6
+ const results = container.map(element => {
7
+ return new Promise(resolve => {
8
+ const interval = setInterval(() => {
9
+ if (getComputedStyle(element).visibility !== "hidden") {
10
+ resolve();
11
+ clearInterval(interval);
12
+ }
13
+ }, 5);
14
+ });
15
+ });
16
+ await Promise.all(results);
17
+ };
18
+ exports.checkCanFocusTrap = checkCanFocusTrap;
19
+ exports.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"])';
20
+ const useTrapFocus = (container) => {
21
+ const ref = (0, react_1.useRef)(null);
22
+ const [nodes, setNodes] = (0, react_1.useState)(null);
23
+ const update = (0, react_1.useCallback)(() => {
24
+ const el = ref.current || container;
25
+ if (!el) {
26
+ return;
27
+ }
28
+ setNodes(Array.from(el.querySelectorAll(exports.FOCUSABLE_ELEMENTS)));
29
+ }, [container]);
30
+ (0, react_1.useEffect)(() => {
31
+ const el = ref.current || container;
32
+ if (!el) {
33
+ return;
34
+ }
35
+ update();
36
+ }, [container, update]);
37
+ (0, react_1.useEffect)(() => {
38
+ const el = ref.current || container;
39
+ if (!el || !nodes) {
40
+ return;
41
+ }
42
+ const firstFocusableElement = nodes[0];
43
+ const lastFocusableElement = nodes[nodes.length - 1];
44
+ const onKeyDown = (e) => {
45
+ const isTabPressed = e.key === "Tab" || e.keyCode === 9;
46
+ if (!isTabPressed) {
47
+ return;
48
+ }
49
+ if (e.shiftKey && document.activeElement === firstFocusableElement) {
50
+ lastFocusableElement.focus();
51
+ e.preventDefault();
52
+ }
53
+ else if (document.activeElement === lastFocusableElement) {
54
+ firstFocusableElement.focus();
55
+ e.preventDefault();
56
+ }
57
+ };
58
+ el.focus();
59
+ document.addEventListener("keydown", onKeyDown);
60
+ return () => document.removeEventListener("keydown", onKeyDown);
61
+ }, [container, nodes]);
62
+ return [ref, { update }];
63
+ };
64
+ exports.useTrapFocus = useTrapFocus;
@@ -0,0 +1,3 @@
1
+ export declare const getGeoLocation: () => Promise<GeolocationPosition | undefined>;
2
+ export declare const useGeoLocation: () => readonly [() => Promise<GeolocationPosition | undefined>, GeolocationPosition | undefined];
3
+ //# sourceMappingURL=geo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geo.d.ts","sourceRoot":"","sources":["../../../lib/geo.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,cAAc,QAAa,OAAO,CAAC,mBAAmB,GAAG,SAAS,CAM9E,CAAC;AAEF,eAAO,MAAM,cAAc,kGAU1B,CAAC"}
@@ -0,0 +1,23 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useGeoLocation = exports.getGeoLocation = void 0;
5
+ const react_1 = require("react");
6
+ const getGeoLocation = async () => {
7
+ if (navigator && "geolocation" in navigator) {
8
+ return new Promise((resolve, reject) => {
9
+ navigator.geolocation.getCurrentPosition(resolve, reject);
10
+ });
11
+ }
12
+ };
13
+ exports.getGeoLocation = getGeoLocation;
14
+ const useGeoLocation = () => {
15
+ const [location, setLocation] = (0, react_1.useState)();
16
+ const onClick = async () => {
17
+ const l = await (0, exports.getGeoLocation)();
18
+ setLocation(l);
19
+ return l;
20
+ };
21
+ return [onClick, location];
22
+ };
23
+ exports.useGeoLocation = useGeoLocation;
@@ -0,0 +1,10 @@
1
+ export interface UseIntersectionProps {
2
+ ref: React.MutableRefObject<HTMLElement | null>;
3
+ defaultValue?: boolean;
4
+ callback?: (entry: IntersectionObserverEntry, isVisible: boolean) => void;
5
+ filter?: (entry: IntersectionObserverEntry) => boolean;
6
+ dependencies?: React.DependencyList[] | null;
7
+ options?: IntersectionObserverInit;
8
+ }
9
+ export declare const useIntersection: ({ ref, defaultValue, callback, filter, options, dependencies, }: UseIntersectionProps) => boolean;
10
+ //# sourceMappingURL=intersection.d.ts.map