@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
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Becklyn Studios
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -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,44 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.inspector = exports.removeInspectorProps = exports.getInspectorProps = void 0;
15
+ const getInspectorProps = (data) => {
16
+ if (!data) {
17
+ return {};
18
+ }
19
+ const { entryId, fieldId, assetId, draftMode, locale } = data;
20
+ return { entryId, fieldId, assetId, draftMode, locale };
21
+ };
22
+ exports.getInspectorProps = getInspectorProps;
23
+ const removeInspectorProps = (data) => {
24
+ if (!data) {
25
+ return {};
26
+ }
27
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
+ const { entryId, fieldId, assetId, draftMode, locale } = data, props = __rest(data, ["entryId", "fieldId", "assetId", "draftMode", "locale"]);
29
+ return props;
30
+ };
31
+ exports.removeInspectorProps = removeInspectorProps;
32
+ const inspector = (data) => {
33
+ if (!data) {
34
+ return {};
35
+ }
36
+ const { entryId, fieldId, assetId, draftMode, locale } = data;
37
+ if (!draftMode || !entryId || (!fieldId && !assetId)) {
38
+ return {};
39
+ }
40
+ return Object.assign(Object.assign({}, (fieldId
41
+ ? { "data-contentful-field-id": fieldId }
42
+ : { "data-contentful-asset-id": assetId })), { "data-contentful-entry-id": entryId, "data-contentful-locale": locale });
43
+ };
44
+ 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,88 @@
1
+ "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.useDropdown = void 0;
15
+ const react_1 = require("react");
16
+ const react_popper_1 = require("react-popper");
17
+ const click_1 = require("./click");
18
+ const escape_1 = require("./escape");
19
+ const focusTrap_1 = require("./focusTrap");
20
+ const useDropdown = (_a) => {
21
+ var { isOpen: externalIsOpen, setIsOpen: externalSetIsOpen, onClose } = _a, options = __rest(_a, ["isOpen", "setIsOpen", "onClose"]);
22
+ const [internalIsOpen, internalSetIsOpen] = (0, react_1.useState)(false);
23
+ const [referenceElement, setReferenceElement] = (0, react_1.useState)(null);
24
+ const [popperElement, setPopperElement] = (0, react_1.useState)(null);
25
+ const [, { update }] = (0, focusTrap_1.useTrapFocus)(popperElement);
26
+ const isOpen = externalIsOpen !== undefined ? externalIsOpen : internalIsOpen;
27
+ const setIsOpen = externalSetIsOpen !== undefined ? externalSetIsOpen : internalSetIsOpen;
28
+ const clickOutsideRef = (0, click_1.useClickOutside)({
29
+ callback: e => {
30
+ if (popperElement && popperElement.contains(e.target)) {
31
+ return;
32
+ }
33
+ handleClose();
34
+ },
35
+ });
36
+ const popper = (0, react_popper_1.usePopper)(referenceElement, popperElement, options);
37
+ const { forceUpdate } = popper;
38
+ (0, escape_1.useEscapeListener)(e => {
39
+ if (!isOpen || !referenceElement) {
40
+ return;
41
+ }
42
+ if (!referenceElement.contains(e.target) &&
43
+ !e.target.contains(popperElement)) {
44
+ return;
45
+ }
46
+ handleClose();
47
+ }, [referenceElement, popperElement, isOpen]);
48
+ (0, react_1.useEffect)(() => {
49
+ if (!referenceElement) {
50
+ return;
51
+ }
52
+ const observer = new ResizeObserver(() => {
53
+ if (!forceUpdate) {
54
+ return;
55
+ }
56
+ forceUpdate();
57
+ });
58
+ observer.observe(referenceElement);
59
+ return () => observer.disconnect();
60
+ }, [referenceElement, forceUpdate]);
61
+ (0, react_1.useEffect)(() => {
62
+ if (!popperElement) {
63
+ return;
64
+ }
65
+ const observer = new MutationObserver(() => {
66
+ update();
67
+ });
68
+ observer.observe(popperElement, { subtree: true, attributes: true });
69
+ return () => observer.disconnect();
70
+ }, [popperElement, update]);
71
+ const handleClose = () => {
72
+ if (!isOpen) {
73
+ return;
74
+ }
75
+ setIsOpen(false);
76
+ if (onClose) {
77
+ onClose();
78
+ }
79
+ };
80
+ return Object.assign({ isOpen,
81
+ setIsOpen,
82
+ clickOutsideRef,
83
+ referenceElement,
84
+ popperElement,
85
+ setReferenceElement,
86
+ setPopperElement }, popper);
87
+ };
88
+ 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,73 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.useTrapFocus = exports.FOCUSABLE_ELEMENTS = exports.checkCanFocusTrap = void 0;
13
+ const react_1 = require("react");
14
+ const checkCanFocusTrap = (container) => __awaiter(void 0, void 0, void 0, function* () {
15
+ const results = container.map(element => {
16
+ return new Promise(resolve => {
17
+ const interval = setInterval(() => {
18
+ if (getComputedStyle(element).visibility !== "hidden") {
19
+ resolve();
20
+ clearInterval(interval);
21
+ }
22
+ }, 5);
23
+ });
24
+ });
25
+ yield Promise.all(results);
26
+ });
27
+ exports.checkCanFocusTrap = checkCanFocusTrap;
28
+ 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"])';
29
+ const useTrapFocus = (container) => {
30
+ const ref = (0, react_1.useRef)(null);
31
+ const [nodes, setNodes] = (0, react_1.useState)(null);
32
+ const update = (0, react_1.useCallback)(() => {
33
+ const el = ref.current || container;
34
+ if (!el) {
35
+ return;
36
+ }
37
+ setNodes(Array.from(el.querySelectorAll(exports.FOCUSABLE_ELEMENTS)));
38
+ }, [container]);
39
+ (0, react_1.useEffect)(() => {
40
+ const el = ref.current || container;
41
+ if (!el) {
42
+ return;
43
+ }
44
+ update();
45
+ }, [container, update]);
46
+ (0, react_1.useEffect)(() => {
47
+ const el = ref.current || container;
48
+ if (!el || !nodes) {
49
+ return;
50
+ }
51
+ const firstFocusableElement = nodes[0];
52
+ const lastFocusableElement = nodes[nodes.length - 1];
53
+ const onKeyDown = (e) => {
54
+ const isTabPressed = e.key === "Tab" || e.keyCode === 9;
55
+ if (!isTabPressed) {
56
+ return;
57
+ }
58
+ if (e.shiftKey && document.activeElement === firstFocusableElement) {
59
+ lastFocusableElement.focus();
60
+ e.preventDefault();
61
+ }
62
+ else if (document.activeElement === lastFocusableElement) {
63
+ firstFocusableElement.focus();
64
+ e.preventDefault();
65
+ }
66
+ };
67
+ el.focus();
68
+ document.addEventListener("keydown", onKeyDown);
69
+ return () => document.removeEventListener("keydown", onKeyDown);
70
+ }, [container, nodes]);
71
+ return [ref, { update }];
72
+ };
73
+ 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,32 @@
1
+ "use client";
2
+ "use strict";
3
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
+ return new (P || (P = Promise))(function (resolve, reject) {
6
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
7
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
8
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
9
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
10
+ });
11
+ };
12
+ Object.defineProperty(exports, "__esModule", { value: true });
13
+ exports.useGeoLocation = exports.getGeoLocation = void 0;
14
+ const react_1 = require("react");
15
+ const getGeoLocation = () => __awaiter(void 0, void 0, void 0, function* () {
16
+ if (navigator && "geolocation" in navigator) {
17
+ return new Promise((resolve, reject) => {
18
+ navigator.geolocation.getCurrentPosition(resolve, reject);
19
+ });
20
+ }
21
+ });
22
+ exports.getGeoLocation = getGeoLocation;
23
+ const useGeoLocation = () => {
24
+ const [location, setLocation] = (0, react_1.useState)();
25
+ const onClick = () => __awaiter(void 0, void 0, void 0, function* () {
26
+ const l = yield (0, exports.getGeoLocation)();
27
+ setLocation(l);
28
+ return l;
29
+ });
30
+ return [onClick, location];
31
+ };
32
+ 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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"intersection.d.ts","sourceRoot":"","sources":["../../../lib/intersection.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,oBAAoB;IACjC,GAAG,EAAE,KAAK,CAAC,gBAAgB,CAAC,WAAW,GAAG,IAAI,CAAC,CAAC;IAChD,YAAY,CAAC,EAAE,OAAO,CAAC;IACvB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,EAAE,SAAS,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1E,MAAM,CAAC,EAAE,CAAC,KAAK,EAAE,yBAAyB,KAAK,OAAO,CAAC;IACvD,YAAY,CAAC,EAAE,KAAK,CAAC,cAAc,EAAE,GAAG,IAAI,CAAC;IAC7C,OAAO,CAAC,EAAE,wBAAwB,CAAC;CACtC;AAED,eAAO,MAAM,eAAe,GAAI,iEAO7B,oBAAoB,YAwBtB,CAAC"}
@@ -0,0 +1,27 @@
1
+ "use client";
2
+ "use strict";
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.useIntersection = void 0;
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);
8
+ const { current } = ref;
9
+ (0, react_1.useEffect)(() => {
10
+ const observer = new IntersectionObserver(entries => {
11
+ entries.forEach(entry => {
12
+ const isVisible = filter ? filter(entry) : entry.isIntersecting;
13
+ setVisible(isVisible);
14
+ if (callback) {
15
+ callback(entry, isVisible);
16
+ }
17
+ });
18
+ }, options);
19
+ if (ref.current) {
20
+ observer.observe(ref.current);
21
+ }
22
+ return () => observer.disconnect();
23
+ // eslint-disable-next-line react-hooks/exhaustive-deps
24
+ }, [current, ...(dependencies !== null && dependencies !== void 0 ? dependencies : [])]);
25
+ return visible;
26
+ };
27
+ exports.useIntersection = useIntersection;
@@ -0,0 +1,2 @@
1
+ export declare const useIsMounted: () => boolean;
2
+ //# sourceMappingURL=isMounted.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isMounted.d.ts","sourceRoot":"","sources":["../../../lib/isMounted.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,YAAY,eAQxB,CAAC"}
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.useIsMounted = void 0;
4
+ const react_1 = require("react");
5
+ const useIsMounted = () => {
6
+ const [isMounted, setIsMounted] = (0, react_1.useState)(false);
7
+ (0, react_1.useEffect)(() => {
8
+ setIsMounted(true);
9
+ }, []);
10
+ return isMounted;
11
+ };
12
+ exports.useIsMounted = useIsMounted;
@@ -0,0 +1,23 @@
1
+ import { Dispatch, SetStateAction } from "react";
2
+ import { Container, KeenSliderInstance, KeenSliderOptions, TrackDetails } from "keen-slider";
3
+ export interface SliderOptions extends KeenSliderOptions {
4
+ shouldObserverMutations?: boolean;
5
+ shouldAutoDisable?: boolean;
6
+ }
7
+ export type SlideResult = [
8
+ Dispatch<SetStateAction<Container | null>>,
9
+ {
10
+ slider: KeenSliderInstance | null;
11
+ activeIndex: number;
12
+ isDisabled: boolean;
13
+ isMounted: boolean;
14
+ isActiveIndex: (index: number) => boolean;
15
+ details: TrackDetails | null;
16
+ options: SliderOptions | null;
17
+ next: () => void;
18
+ prev: () => void;
19
+ moveToIdx: (index: number) => void;
20
+ }
21
+ ];
22
+ export declare const useSlider: ({ shouldObserverMutations, shouldAutoDisable, ...opt }?: SliderOptions) => SlideResult;
23
+ //# sourceMappingURL=slider.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"slider.d.ts","sourceRoot":"","sources":["../../../lib/slider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,cAAc,EAA4C,MAAM,OAAO,CAAC;AAC3F,OAAmB,EACf,SAAS,EACT,kBAAkB,EAClB,iBAAiB,EAEjB,YAAY,EACf,MAAM,aAAa,CAAC;AAErB,MAAM,WAAW,aAAc,SAAQ,iBAAiB;IACpD,uBAAuB,CAAC,EAAE,OAAO,CAAC;IAClC,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,MAAM,WAAW,GAAG;IACtB,QAAQ,CAAC,cAAc,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;IAC1C;QACI,MAAM,EAAE,kBAAkB,GAAG,IAAI,CAAC;QAClC,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,OAAO,CAAC;QACpB,SAAS,EAAE,OAAO,CAAC;QACnB,aAAa,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC;QAC1C,OAAO,EAAE,YAAY,GAAG,IAAI,CAAC;QAC7B,OAAO,EAAE,aAAa,GAAG,IAAI,CAAC;QAC9B,IAAI,EAAE,MAAM,IAAI,CAAC;QACjB,IAAI,EAAE,MAAM,IAAI,CAAC;QACjB,SAAS,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;KACtC;CACJ,CAAC;AAEF,eAAO,MAAM,SAAS,GAAI,yDAIvB,aAAkB,KAAG,WAwFvB,CAAC"}