@simpleapps-com/augur-web 0.2.13 → 0.2.15
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/financing-widget.cjs +47 -0
- package/dist/financing-widget.cjs.map +1 -0
- package/dist/financing-widget.d.cts +45 -0
- package/dist/financing-widget.d.ts +45 -0
- package/dist/financing-widget.js +47 -0
- package/dist/financing-widget.js.map +1 -0
- package/dist/form-select.cjs +2 -2
- package/dist/form-select.cjs.map +1 -1
- package/dist/form-select.js +3 -3
- package/dist/form-textarea.cjs +2 -2
- package/dist/form-textarea.js +3 -3
- package/dist/gtm.cjs +145 -0
- package/dist/gtm.cjs.map +1 -0
- package/dist/gtm.d.cts +89 -0
- package/dist/gtm.d.ts +89 -0
- package/dist/gtm.js +145 -0
- package/dist/gtm.js.map +1 -0
- package/dist/price.cjs +72 -0
- package/dist/price.cjs.map +1 -0
- package/dist/price.d.cts +42 -0
- package/dist/price.d.ts +42 -0
- package/dist/price.js +72 -0
- package/dist/price.js.map +1 -0
- package/dist/session-replay.cjs +59 -0
- package/dist/session-replay.cjs.map +1 -0
- package/dist/session-replay.d.cts +44 -0
- package/dist/session-replay.d.ts +44 -0
- package/dist/session-replay.js +59 -0
- package/dist/session-replay.js.map +1 -0
- package/package.json +22 -2
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/financing-widget.tsx
|
|
5
|
+
var _react = require('react');
|
|
6
|
+
function injectTimePayment(vendorCode, onLoad) {
|
|
7
|
+
if (typeof document === "undefined") return;
|
|
8
|
+
if (document.getElementById("financing-script")) return;
|
|
9
|
+
const script = document.createElement("script");
|
|
10
|
+
script.id = "financing-script";
|
|
11
|
+
script.src = `https://app.timepayment.com/js/apply-button.js?vendor=${encodeURIComponent(vendorCode)}`;
|
|
12
|
+
script.async = true;
|
|
13
|
+
script.defer = true;
|
|
14
|
+
if (onLoad) {
|
|
15
|
+
script.onload = onLoad;
|
|
16
|
+
}
|
|
17
|
+
document.head.appendChild(script);
|
|
18
|
+
}
|
|
19
|
+
var injectors = {
|
|
20
|
+
timepayment: injectTimePayment
|
|
21
|
+
};
|
|
22
|
+
function FinancingWidget({
|
|
23
|
+
provider,
|
|
24
|
+
vendorCode,
|
|
25
|
+
disabled = false,
|
|
26
|
+
onLoad
|
|
27
|
+
}) {
|
|
28
|
+
const injectedRef = _react.useRef.call(void 0, false);
|
|
29
|
+
const stableOnLoad = _react.useCallback.call(void 0, () => {
|
|
30
|
+
_optionalChain([onLoad, 'optionalCall', _ => _()]);
|
|
31
|
+
}, [onLoad]);
|
|
32
|
+
_react.useEffect.call(void 0, () => {
|
|
33
|
+
if (disabled || injectedRef.current) return;
|
|
34
|
+
injectedRef.current = true;
|
|
35
|
+
const inject = injectors[provider];
|
|
36
|
+
if (typeof requestIdleCallback === "function") {
|
|
37
|
+
requestIdleCallback(() => inject(vendorCode, stableOnLoad));
|
|
38
|
+
} else {
|
|
39
|
+
setTimeout(() => inject(vendorCode, stableOnLoad), 0);
|
|
40
|
+
}
|
|
41
|
+
}, [provider, vendorCode, disabled, stableOnLoad]);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
exports.FinancingWidget = FinancingWidget;
|
|
47
|
+
//# sourceMappingURL=financing-widget.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/financing-widget.cjs","../src/financing-widget.tsx"],"names":[],"mappings":"AAAA,ylBAAY;AACZ,YAAY;AACZ;AACA;ACDA,8BAA+C;AAyC/C,SAAS,iBAAA,CACP,UAAA,EACA,MAAA,EACM;AACN,EAAA,GAAA,CAAI,OAAO,SAAA,IAAa,WAAA,EAAa,MAAA;AACrC,EAAA,GAAA,CAAI,QAAA,CAAS,cAAA,CAAe,kBAAkB,CAAA,EAAG,MAAA;AAEjD,EAAA,MAAM,OAAA,EAAS,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA;AAC9C,EAAA,MAAA,CAAO,GAAA,EAAK,kBAAA;AACZ,EAAA,MAAA,CAAO,IAAA,EAAM,CAAA,sDAAA,EAAyD,kBAAA,CAAmB,UAAU,CAAC,CAAA,CAAA;AACrF,EAAA;AACA,EAAA;AACH,EAAA;AACM,IAAA;AAClB,EAAA;AACgC,EAAA;AAClC;AAKI;AACW,EAAA;AACf;AAyBgC;AAC9B,EAAA;AACA,EAAA;AACW,EAAA;AACX,EAAA;AACuB;AACS,EAAA;AAEO,EAAA;AAC5B,oBAAA;AACA,EAAA;AAEK,EAAA;AACuB,IAAA;AACf,IAAA;AAEW,IAAA;AAGc,IAAA;AACa,MAAA;AACrD,IAAA;AAC+C,MAAA;AACtD,IAAA;AAC+C,EAAA;AAE1C,EAAA;AACT;AD3EuG;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/financing-widget.cjs","sourcesContent":[null,"\"use client\";\n\nimport { useEffect, useRef, useCallback } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Supported financing providers. */\nexport type FinancingProvider = \"timepayment\";\n\nexport interface FinancingWidgetProps {\n /** Financing provider. */\n provider: FinancingProvider;\n /** Vendor/merchant code from the provider. */\n vendorCode: string;\n /** Disable loading. Default: false. */\n disabled?: boolean;\n /** Called when the financing script has loaded. */\n onLoad?: () => void;\n}\n\nexport interface UseFinancingResult {\n /** Whether the financing script has loaded. */\n isLoaded: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Globals\n// ---------------------------------------------------------------------------\n\ndeclare global {\n interface Window {\n TimePayment?: {\n apply: (vendorCode: string) => void;\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Script injectors\n// ---------------------------------------------------------------------------\n\nfunction injectTimePayment(\n vendorCode: string,\n onLoad?: () => void,\n): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(\"financing-script\")) return;\n\n const script = document.createElement(\"script\");\n script.id = \"financing-script\";\n script.src = `https://app.timepayment.com/js/apply-button.js?vendor=${encodeURIComponent(vendorCode)}`;\n script.async = true;\n script.defer = true;\n if (onLoad) {\n script.onload = onLoad;\n }\n document.head.appendChild(script);\n}\n\nconst injectors: Record<\n FinancingProvider,\n (vendorCode: string, onLoad?: () => void) => void\n> = {\n timepayment: injectTimePayment,\n};\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\n/**\n * Loads a financing widget script on the pages where it's needed.\n * Renders nothing — this is a side-effect-only leaf component.\n *\n * Place this on product or checkout pages, NOT in the global layout.\n *\n * @example\n * ```tsx\n * // On a product page\n * <FinancingWidget provider=\"timepayment\" vendorCode=\"PVD5P\" />\n *\n * // With load callback\n * <FinancingWidget\n * provider=\"timepayment\"\n * vendorCode=\"PVD5P\"\n * onLoad={() => console.log(\"Financing ready\")}\n * />\n * ```\n */\nexport function FinancingWidget({\n provider,\n vendorCode,\n disabled = false,\n onLoad,\n}: FinancingWidgetProps) {\n const injectedRef = useRef(false);\n\n const stableOnLoad = useCallback(() => {\n onLoad?.();\n }, [onLoad]);\n\n useEffect(() => {\n if (disabled || injectedRef.current) return;\n injectedRef.current = true;\n\n const inject = injectors[provider];\n\n // Load during idle time\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => inject(vendorCode, stableOnLoad));\n } else {\n setTimeout(() => inject(vendorCode, stableOnLoad), 0);\n }\n }, [provider, vendorCode, disabled, stableOnLoad]);\n\n return null;\n}\n"]}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Supported financing providers. */
|
|
2
|
+
type FinancingProvider = "timepayment";
|
|
3
|
+
interface FinancingWidgetProps {
|
|
4
|
+
/** Financing provider. */
|
|
5
|
+
provider: FinancingProvider;
|
|
6
|
+
/** Vendor/merchant code from the provider. */
|
|
7
|
+
vendorCode: string;
|
|
8
|
+
/** Disable loading. Default: false. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Called when the financing script has loaded. */
|
|
11
|
+
onLoad?: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface UseFinancingResult {
|
|
14
|
+
/** Whether the financing script has loaded. */
|
|
15
|
+
isLoaded: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
TimePayment?: {
|
|
20
|
+
apply: (vendorCode: string) => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Loads a financing widget script on the pages where it's needed.
|
|
26
|
+
* Renders nothing — this is a side-effect-only leaf component.
|
|
27
|
+
*
|
|
28
|
+
* Place this on product or checkout pages, NOT in the global layout.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // On a product page
|
|
33
|
+
* <FinancingWidget provider="timepayment" vendorCode="PVD5P" />
|
|
34
|
+
*
|
|
35
|
+
* // With load callback
|
|
36
|
+
* <FinancingWidget
|
|
37
|
+
* provider="timepayment"
|
|
38
|
+
* vendorCode="PVD5P"
|
|
39
|
+
* onLoad={() => console.log("Financing ready")}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function FinancingWidget({ provider, vendorCode, disabled, onLoad, }: FinancingWidgetProps): null;
|
|
44
|
+
|
|
45
|
+
export { type FinancingProvider, FinancingWidget, type FinancingWidgetProps, type UseFinancingResult };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Supported financing providers. */
|
|
2
|
+
type FinancingProvider = "timepayment";
|
|
3
|
+
interface FinancingWidgetProps {
|
|
4
|
+
/** Financing provider. */
|
|
5
|
+
provider: FinancingProvider;
|
|
6
|
+
/** Vendor/merchant code from the provider. */
|
|
7
|
+
vendorCode: string;
|
|
8
|
+
/** Disable loading. Default: false. */
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
/** Called when the financing script has loaded. */
|
|
11
|
+
onLoad?: () => void;
|
|
12
|
+
}
|
|
13
|
+
interface UseFinancingResult {
|
|
14
|
+
/** Whether the financing script has loaded. */
|
|
15
|
+
isLoaded: boolean;
|
|
16
|
+
}
|
|
17
|
+
declare global {
|
|
18
|
+
interface Window {
|
|
19
|
+
TimePayment?: {
|
|
20
|
+
apply: (vendorCode: string) => void;
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Loads a financing widget script on the pages where it's needed.
|
|
26
|
+
* Renders nothing — this is a side-effect-only leaf component.
|
|
27
|
+
*
|
|
28
|
+
* Place this on product or checkout pages, NOT in the global layout.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```tsx
|
|
32
|
+
* // On a product page
|
|
33
|
+
* <FinancingWidget provider="timepayment" vendorCode="PVD5P" />
|
|
34
|
+
*
|
|
35
|
+
* // With load callback
|
|
36
|
+
* <FinancingWidget
|
|
37
|
+
* provider="timepayment"
|
|
38
|
+
* vendorCode="PVD5P"
|
|
39
|
+
* onLoad={() => console.log("Financing ready")}
|
|
40
|
+
* />
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
declare function FinancingWidget({ provider, vendorCode, disabled, onLoad, }: FinancingWidgetProps): null;
|
|
44
|
+
|
|
45
|
+
export { type FinancingProvider, FinancingWidget, type FinancingWidgetProps, type UseFinancingResult };
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/financing-widget.tsx
|
|
5
|
+
import { useEffect, useRef, useCallback } from "react";
|
|
6
|
+
function injectTimePayment(vendorCode, onLoad) {
|
|
7
|
+
if (typeof document === "undefined") return;
|
|
8
|
+
if (document.getElementById("financing-script")) return;
|
|
9
|
+
const script = document.createElement("script");
|
|
10
|
+
script.id = "financing-script";
|
|
11
|
+
script.src = `https://app.timepayment.com/js/apply-button.js?vendor=${encodeURIComponent(vendorCode)}`;
|
|
12
|
+
script.async = true;
|
|
13
|
+
script.defer = true;
|
|
14
|
+
if (onLoad) {
|
|
15
|
+
script.onload = onLoad;
|
|
16
|
+
}
|
|
17
|
+
document.head.appendChild(script);
|
|
18
|
+
}
|
|
19
|
+
var injectors = {
|
|
20
|
+
timepayment: injectTimePayment
|
|
21
|
+
};
|
|
22
|
+
function FinancingWidget({
|
|
23
|
+
provider,
|
|
24
|
+
vendorCode,
|
|
25
|
+
disabled = false,
|
|
26
|
+
onLoad
|
|
27
|
+
}) {
|
|
28
|
+
const injectedRef = useRef(false);
|
|
29
|
+
const stableOnLoad = useCallback(() => {
|
|
30
|
+
onLoad?.();
|
|
31
|
+
}, [onLoad]);
|
|
32
|
+
useEffect(() => {
|
|
33
|
+
if (disabled || injectedRef.current) return;
|
|
34
|
+
injectedRef.current = true;
|
|
35
|
+
const inject = injectors[provider];
|
|
36
|
+
if (typeof requestIdleCallback === "function") {
|
|
37
|
+
requestIdleCallback(() => inject(vendorCode, stableOnLoad));
|
|
38
|
+
} else {
|
|
39
|
+
setTimeout(() => inject(vendorCode, stableOnLoad), 0);
|
|
40
|
+
}
|
|
41
|
+
}, [provider, vendorCode, disabled, stableOnLoad]);
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
export {
|
|
45
|
+
FinancingWidget
|
|
46
|
+
};
|
|
47
|
+
//# sourceMappingURL=financing-widget.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/financing-widget.tsx"],"sourcesContent":["\"use client\";\n\nimport { useEffect, useRef, useCallback } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Supported financing providers. */\nexport type FinancingProvider = \"timepayment\";\n\nexport interface FinancingWidgetProps {\n /** Financing provider. */\n provider: FinancingProvider;\n /** Vendor/merchant code from the provider. */\n vendorCode: string;\n /** Disable loading. Default: false. */\n disabled?: boolean;\n /** Called when the financing script has loaded. */\n onLoad?: () => void;\n}\n\nexport interface UseFinancingResult {\n /** Whether the financing script has loaded. */\n isLoaded: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Globals\n// ---------------------------------------------------------------------------\n\ndeclare global {\n interface Window {\n TimePayment?: {\n apply: (vendorCode: string) => void;\n };\n }\n}\n\n// ---------------------------------------------------------------------------\n// Script injectors\n// ---------------------------------------------------------------------------\n\nfunction injectTimePayment(\n vendorCode: string,\n onLoad?: () => void,\n): void {\n if (typeof document === \"undefined\") return;\n if (document.getElementById(\"financing-script\")) return;\n\n const script = document.createElement(\"script\");\n script.id = \"financing-script\";\n script.src = `https://app.timepayment.com/js/apply-button.js?vendor=${encodeURIComponent(vendorCode)}`;\n script.async = true;\n script.defer = true;\n if (onLoad) {\n script.onload = onLoad;\n }\n document.head.appendChild(script);\n}\n\nconst injectors: Record<\n FinancingProvider,\n (vendorCode: string, onLoad?: () => void) => void\n> = {\n timepayment: injectTimePayment,\n};\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\n/**\n * Loads a financing widget script on the pages where it's needed.\n * Renders nothing — this is a side-effect-only leaf component.\n *\n * Place this on product or checkout pages, NOT in the global layout.\n *\n * @example\n * ```tsx\n * // On a product page\n * <FinancingWidget provider=\"timepayment\" vendorCode=\"PVD5P\" />\n *\n * // With load callback\n * <FinancingWidget\n * provider=\"timepayment\"\n * vendorCode=\"PVD5P\"\n * onLoad={() => console.log(\"Financing ready\")}\n * />\n * ```\n */\nexport function FinancingWidget({\n provider,\n vendorCode,\n disabled = false,\n onLoad,\n}: FinancingWidgetProps) {\n const injectedRef = useRef(false);\n\n const stableOnLoad = useCallback(() => {\n onLoad?.();\n }, [onLoad]);\n\n useEffect(() => {\n if (disabled || injectedRef.current) return;\n injectedRef.current = true;\n\n const inject = injectors[provider];\n\n // Load during idle time\n if (typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => inject(vendorCode, stableOnLoad));\n } else {\n setTimeout(() => inject(vendorCode, stableOnLoad), 0);\n }\n }, [provider, vendorCode, disabled, stableOnLoad]);\n\n return null;\n}\n"],"mappings":";;;;AAEA,SAAS,WAAW,QAAQ,mBAAmB;AAyC/C,SAAS,kBACP,YACA,QACM;AACN,MAAI,OAAO,aAAa,YAAa;AACrC,MAAI,SAAS,eAAe,kBAAkB,EAAG;AAEjD,QAAM,SAAS,SAAS,cAAc,QAAQ;AAC9C,SAAO,KAAK;AACZ,SAAO,MAAM,yDAAyD,mBAAmB,UAAU,CAAC;AACpG,SAAO,QAAQ;AACf,SAAO,QAAQ;AACf,MAAI,QAAQ;AACV,WAAO,SAAS;AAAA,EAClB;AACA,WAAS,KAAK,YAAY,MAAM;AAClC;AAEA,IAAM,YAGF;AAAA,EACF,aAAa;AACf;AAyBO,SAAS,gBAAgB;AAAA,EAC9B;AAAA,EACA;AAAA,EACA,WAAW;AAAA,EACX;AACF,GAAyB;AACvB,QAAM,cAAc,OAAO,KAAK;AAEhC,QAAM,eAAe,YAAY,MAAM;AACrC,aAAS;AAAA,EACX,GAAG,CAAC,MAAM,CAAC;AAEX,YAAU,MAAM;AACd,QAAI,YAAY,YAAY,QAAS;AACrC,gBAAY,UAAU;AAEtB,UAAM,SAAS,UAAU,QAAQ;AAGjC,QAAI,OAAO,wBAAwB,YAAY;AAC7C,0BAAoB,MAAM,OAAO,YAAY,YAAY,CAAC;AAAA,IAC5D,OAAO;AACL,iBAAW,MAAM,OAAO,YAAY,YAAY,GAAG,CAAC;AAAA,IACtD;AAAA,EACF,GAAG,CAAC,UAAU,YAAY,UAAU,YAAY,CAAC;AAEjD,SAAO;AACT;","names":[]}
|
package/dist/form-select.cjs
CHANGED
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
+
var _chunkVMOQCPK5cjs = require('./chunk-VMOQCPK5.cjs');
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
|
|
9
|
-
var _chunkQ6H6D3ANcjs = require('./chunk-Q6H6D3AN.cjs');
|
|
10
10
|
|
|
11
11
|
|
|
12
|
-
var
|
|
12
|
+
var _chunkQ6H6D3ANcjs = require('./chunk-Q6H6D3AN.cjs');
|
|
13
13
|
require('./chunk-CK53LO3J.cjs');
|
|
14
14
|
|
|
15
15
|
// src/form-select.tsx
|
package/dist/form-select.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/form-select.cjs","../src/form-select.tsx"],"names":[],"mappings":"AAAA,uWAAY;AACZ,YAAY;AACZ;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/form-select.cjs","../src/form-select.tsx"],"names":[],"mappings":"AAAA,uWAAY;AACZ,YAAY;AACZ;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACA;ACZA,2EAAuB;AACvB,sDAAmB;AA+CX,+CAAA;AAxBR,IAAM,WAAA,EAAmB,KAAA,CAAA,UAAA;AAAA,EACvB,CACE;AAAA,IACE,KAAA;AAAA,IACA,KAAA;AAAA,IACA,QAAA;AAAA,IACA,IAAA;AAAA,IACA,KAAA;AAAA,IACA,aAAA;AAAA,IACA,OAAA;AAAA,IACA,WAAA;AAAA,IACA,SAAA;AAAA,IACA;AAAA,EACF,CAAA,EACA,GAAA,EAAA,GACG;AACH,IAAA,uBACE,6BAAA;AAAA,MAAC,2BAAA;AAAA,MAAA;AAAA,QACC,KAAA;AAAA,QACA,OAAA,EAAS,IAAA;AAAA,QACT,QAAA;AAAA,QACA,KAAA;AAAA,QACA,SAAA,EAAW,qBAAA,SAAY,CAAA;AAAA,QAEvB,QAAA,kBAAA,8BAAA;AAAA,UAAC,wBAAA;AAAA,UAAA;AAAA,YACC,IAAA;AAAA,YACA,KAAA;AAAA,YACA,aAAA;AAAA,YACA,QAAA;AAAA,YAEA,QAAA,EAAA;AAAA,8BAAA,6BAAA,+BAAC,EAAA,EAAc,GAAA,EAAU,EAAA,EAAI,IAAA,EAC3B,QAAA,kBAAA,6BAAA,6BAAC,EAAA,EAAY,YAAA,CAA0B,EAAA,CACzC,CAAA;AAAA,8BACA,6BAAA,+BAAC,EAAA,EACE,QAAA,EAAA,OAAA,CAAQ,GAAA,CAAI,CAAC,MAAA,EAAA,mBACZ,6BAAA,4BAAC,EAAA,EAA8B,KAAA,EAAO,MAAA,CAAO,KAAA,EAC1C,QAAA,EAAA,MAAA,CAAO,MAAA,CAAA,EADO,MAAA,CAAO,KAExB,CACD,EAAA,CACH;AAAA,YAAA;AAAA,UAAA;AAAA,QACF;AAAA,MAAA;AAAA,IACF,CAAA;AAAA,EAEJ;AACF,CAAA;AACA,UAAA,CAAW,YAAA,EAAc,YAAA;ADdzB;AACE;AACF,gCAAC","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/form-select.cjs","sourcesContent":[null,"\"use client\";\n\nimport * as React from \"react\";\nimport { cn } from \"@simpleapps-com/augur-utils/web\";\nimport { FormField } from \"./form-field\";\nimport {\n Select,\n SelectTrigger,\n SelectValue,\n SelectContent,\n SelectItem,\n} from \"./select\";\n\nexport interface FormSelectProps {\n label: string;\n error?: string;\n required?: boolean;\n name: string;\n value?: string;\n onValueChange?: (value: string) => void;\n options: { label: string; value: string }[];\n placeholder?: string;\n className?: string;\n disabled?: boolean;\n}\n\nconst FormSelect = React.forwardRef<HTMLButtonElement, FormSelectProps>(\n (\n {\n label,\n error,\n required,\n name,\n value,\n onValueChange,\n options,\n placeholder,\n className,\n disabled,\n },\n ref,\n ) => {\n return (\n <FormField\n label={label}\n htmlFor={name}\n required={required}\n error={error}\n className={cn(className)}\n >\n <Select\n name={name}\n value={value}\n onValueChange={onValueChange}\n disabled={disabled}\n >\n <SelectTrigger ref={ref} id={name}>\n <SelectValue placeholder={placeholder} />\n </SelectTrigger>\n <SelectContent>\n {options.map((option) => (\n <SelectItem key={option.value} value={option.value}>\n {option.label}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </FormField>\n );\n },\n);\nFormSelect.displayName = \"FormSelect\";\n\nexport { FormSelect };\n"]}
|
package/dist/form-select.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
+
import {
|
|
4
|
+
FormField
|
|
5
|
+
} from "./chunk-GPDD67CJ.js";
|
|
3
6
|
import {
|
|
4
7
|
Select,
|
|
5
8
|
SelectContent,
|
|
@@ -7,9 +10,6 @@ import {
|
|
|
7
10
|
SelectTrigger,
|
|
8
11
|
SelectValue
|
|
9
12
|
} from "./chunk-ND6U4UQQ.js";
|
|
10
|
-
import {
|
|
11
|
-
FormField
|
|
12
|
-
} from "./chunk-GPDD67CJ.js";
|
|
13
13
|
import "./chunk-FHS7SJEQ.js";
|
|
14
14
|
|
|
15
15
|
// src/form-select.tsx
|
package/dist/form-textarea.cjs
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"use client";
|
|
3
3
|
|
|
4
4
|
|
|
5
|
-
var
|
|
5
|
+
var _chunkVMOQCPK5cjs = require('./chunk-VMOQCPK5.cjs');
|
|
6
6
|
|
|
7
7
|
|
|
8
|
-
var
|
|
8
|
+
var _chunk3RVGVJDIcjs = require('./chunk-3RVGVJDI.cjs');
|
|
9
9
|
require('./chunk-CK53LO3J.cjs');
|
|
10
10
|
|
|
11
11
|
// src/form-textarea.tsx
|
package/dist/form-textarea.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use client";
|
|
2
2
|
"use client";
|
|
3
|
-
import {
|
|
4
|
-
Textarea
|
|
5
|
-
} from "./chunk-DZ6HBEMA.js";
|
|
6
3
|
import {
|
|
7
4
|
FormField
|
|
8
5
|
} from "./chunk-GPDD67CJ.js";
|
|
6
|
+
import {
|
|
7
|
+
Textarea
|
|
8
|
+
} from "./chunk-DZ6HBEMA.js";
|
|
9
9
|
import "./chunk-FHS7SJEQ.js";
|
|
10
10
|
|
|
11
11
|
// src/form-textarea.tsx
|
package/dist/gtm.cjs
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});"use client";
|
|
2
|
+
"use client";
|
|
3
|
+
|
|
4
|
+
// src/gtm.tsx
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
var _react = require('react');
|
|
13
|
+
var _jsxruntime = require('react/jsx-runtime');
|
|
14
|
+
var AnalyticsContext = _react.createContext.call(void 0, null);
|
|
15
|
+
function getDataLayer() {
|
|
16
|
+
if (typeof window === "undefined") return [];
|
|
17
|
+
if (!window.dataLayer) window.dataLayer = [];
|
|
18
|
+
return window.dataLayer;
|
|
19
|
+
}
|
|
20
|
+
function injectGtmScript(gtmId, strategy) {
|
|
21
|
+
if (typeof document === "undefined") return;
|
|
22
|
+
if (document.getElementById("gtm-script")) return;
|
|
23
|
+
const dataLayer = getDataLayer();
|
|
24
|
+
dataLayer.push({ "gtm.start": (/* @__PURE__ */ new Date()).getTime(), event: "gtm.js" });
|
|
25
|
+
const script = document.createElement("script");
|
|
26
|
+
script.id = "gtm-script";
|
|
27
|
+
script.src = `https://www.googletagmanager.com/gtm.js?id=${encodeURIComponent(gtmId)}`;
|
|
28
|
+
if (strategy === "lazyOnload") {
|
|
29
|
+
script.async = true;
|
|
30
|
+
script.defer = true;
|
|
31
|
+
} else {
|
|
32
|
+
script.async = true;
|
|
33
|
+
}
|
|
34
|
+
document.head.appendChild(script);
|
|
35
|
+
}
|
|
36
|
+
function AnalyticsProvider({
|
|
37
|
+
gtmId,
|
|
38
|
+
strategy = "afterInteractive",
|
|
39
|
+
consentRequired = false,
|
|
40
|
+
debug = false,
|
|
41
|
+
children
|
|
42
|
+
}) {
|
|
43
|
+
const [hasConsent, setHasConsent] = _react.useState.call(void 0, !consentRequired);
|
|
44
|
+
const [isLoaded, setIsLoaded] = _react.useState.call(void 0, false);
|
|
45
|
+
const injectedRef = _react.useRef.call(void 0, false);
|
|
46
|
+
const loadGtm = _react.useCallback.call(void 0, () => {
|
|
47
|
+
if (injectedRef.current) return;
|
|
48
|
+
injectedRef.current = true;
|
|
49
|
+
if (strategy === "lazyOnload" && typeof requestIdleCallback === "function") {
|
|
50
|
+
requestIdleCallback(() => {
|
|
51
|
+
injectGtmScript(gtmId, strategy);
|
|
52
|
+
setIsLoaded(true);
|
|
53
|
+
});
|
|
54
|
+
} else if (strategy === "afterInteractive") {
|
|
55
|
+
setTimeout(() => {
|
|
56
|
+
injectGtmScript(gtmId, strategy);
|
|
57
|
+
setIsLoaded(true);
|
|
58
|
+
}, 0);
|
|
59
|
+
} else {
|
|
60
|
+
injectGtmScript(gtmId, strategy);
|
|
61
|
+
setIsLoaded(true);
|
|
62
|
+
}
|
|
63
|
+
}, [gtmId, strategy]);
|
|
64
|
+
if (hasConsent && !injectedRef.current && typeof window !== "undefined") {
|
|
65
|
+
loadGtm();
|
|
66
|
+
}
|
|
67
|
+
const trackEvent = _react.useCallback.call(void 0,
|
|
68
|
+
(event, params) => {
|
|
69
|
+
const entry = { event, ...params };
|
|
70
|
+
if (debug) {
|
|
71
|
+
console.log("[Analytics]", entry);
|
|
72
|
+
}
|
|
73
|
+
getDataLayer().push(entry);
|
|
74
|
+
},
|
|
75
|
+
[debug]
|
|
76
|
+
);
|
|
77
|
+
const trackEcommerceEvent = _react.useCallback.call(void 0,
|
|
78
|
+
(event, params) => {
|
|
79
|
+
getDataLayer().push({ ecommerce: null });
|
|
80
|
+
const entry = { event, ecommerce: params };
|
|
81
|
+
if (debug) {
|
|
82
|
+
console.log("[Analytics ecommerce]", entry);
|
|
83
|
+
}
|
|
84
|
+
getDataLayer().push(entry);
|
|
85
|
+
},
|
|
86
|
+
[debug]
|
|
87
|
+
);
|
|
88
|
+
const grantConsent = _react.useCallback.call(void 0, () => {
|
|
89
|
+
setHasConsent(true);
|
|
90
|
+
loadGtm();
|
|
91
|
+
}, [loadGtm]);
|
|
92
|
+
const revokeConsent = _react.useCallback.call(void 0, () => {
|
|
93
|
+
setHasConsent(false);
|
|
94
|
+
}, []);
|
|
95
|
+
const value = _react.useMemo.call(void 0,
|
|
96
|
+
() => ({
|
|
97
|
+
trackEvent,
|
|
98
|
+
trackEcommerceEvent,
|
|
99
|
+
grantConsent,
|
|
100
|
+
revokeConsent,
|
|
101
|
+
hasConsent,
|
|
102
|
+
isLoaded
|
|
103
|
+
}),
|
|
104
|
+
[
|
|
105
|
+
trackEvent,
|
|
106
|
+
trackEcommerceEvent,
|
|
107
|
+
grantConsent,
|
|
108
|
+
revokeConsent,
|
|
109
|
+
hasConsent,
|
|
110
|
+
isLoaded
|
|
111
|
+
]
|
|
112
|
+
);
|
|
113
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, AnalyticsContext.Provider, { value, children });
|
|
114
|
+
}
|
|
115
|
+
function useAnalytics() {
|
|
116
|
+
const context = _react.useContext.call(void 0, AnalyticsContext);
|
|
117
|
+
if (!context) {
|
|
118
|
+
throw new Error("useAnalytics must be used within an <AnalyticsProvider>");
|
|
119
|
+
}
|
|
120
|
+
return context;
|
|
121
|
+
}
|
|
122
|
+
function AnalyticsNoscript({ gtmId }) {
|
|
123
|
+
return /* @__PURE__ */ _jsxruntime.jsx.call(void 0, "noscript", { children: /* @__PURE__ */ _jsxruntime.jsx.call(void 0,
|
|
124
|
+
"iframe",
|
|
125
|
+
{
|
|
126
|
+
src: `https://www.googletagmanager.com/ns.html?id=${encodeURIComponent(gtmId)}`,
|
|
127
|
+
height: "0",
|
|
128
|
+
width: "0",
|
|
129
|
+
style: { display: "none", visibility: "hidden" },
|
|
130
|
+
title: "Google Tag Manager"
|
|
131
|
+
}
|
|
132
|
+
) });
|
|
133
|
+
}
|
|
134
|
+
var GtmProvider = AnalyticsProvider;
|
|
135
|
+
var useGtm = useAnalytics;
|
|
136
|
+
var GtmNoscript = AnalyticsNoscript;
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
|
|
144
|
+
exports.AnalyticsNoscript = AnalyticsNoscript; exports.AnalyticsProvider = AnalyticsProvider; exports.GtmNoscript = GtmNoscript; exports.GtmProvider = GtmProvider; exports.useAnalytics = useAnalytics; exports.useGtm = useGtm;
|
|
145
|
+
//# sourceMappingURL=gtm.cjs.map
|
package/dist/gtm.cjs.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/gtm.cjs","../src/gtm.tsx"],"names":[],"mappings":"AAAA,qFAAY;AACZ,YAAY;AACZ;AACA;ACDA;AACE;AACA;AACA;AACA;AACA;AACA;AAAA,8BACK;AA8NH,+CAAA;AA3IJ,IAAM,iBAAA,EAAmB,kCAAA,IAAgD,CAAA;AAYzE,SAAS,YAAA,CAAA,EAA0C;AACjD,EAAA,GAAA,CAAI,OAAO,OAAA,IAAW,WAAA,EAAa,OAAO,CAAC,CAAA;AAC3C,EAAA,GAAA,CAAI,CAAC,MAAA,CAAO,SAAA,EAAW,MAAA,CAAO,UAAA,EAAY,CAAC,CAAA;AAC3C,EAAA,OAAO,MAAA,CAAO,SAAA;AAChB;AAEA,SAAS,eAAA,CACP,KAAA,EACA,QAAA,EACM;AACN,EAAA,GAAA,CAAI,OAAO,SAAA,IAAa,WAAA,EAAa,MAAA;AAGrC,EAAA,GAAA,CAAI,QAAA,CAAS,cAAA,CAAe,YAAY,CAAA,EAAG,MAAA;AAE3C,EAAA,MAAM,UAAA,EAAY,YAAA,CAAa,CAAA;AAC/B,EAAA,SAAA,CAAU,IAAA,CAAK,EAAE,WAAA,EAAA,iBAAa,IAAI,IAAA,CAAK,CAAA,CAAA,CAAE,OAAA,CAAQ,CAAA,EAAG,KAAA,EAAO,SAAS,CAAC,CAAA;AAErE,EAAA,MAAM,OAAA,EAAS,QAAA,CAAS,aAAA,CAAc,QAAQ,CAAA;AAC9C,EAAA,MAAA,CAAO,GAAA,EAAK,YAAA;AACZ,EAAA,MAAA,CAAO,IAAA,EAAM,CAAA,2CAAA,EAA8C,kBAAA,CAAmB,KAAK,CAAC,CAAA,CAAA;AAErD,EAAA;AACd,IAAA;AACA,IAAA;AACV,EAAA;AAEU,IAAA;AACjB,EAAA;AAEgC,EAAA;AAClC;AAMkC;AAChC,EAAA;AACW,EAAA;AACO,EAAA;AACV,EAAA;AACR,EAAA;AACyB;AACoC,EAAA;AACf,EAAA;AACd,EAAA;AAEE,EAAA;AACP,IAAA;AACH,IAAA;AAEsD,IAAA;AAChD,MAAA;AACO,QAAA;AACf,QAAA;AACjB,MAAA;AACyC,IAAA;AAEzB,MAAA;AACgB,QAAA;AACf,QAAA;AACd,MAAA;AACC,IAAA;AAC0B,MAAA;AACf,MAAA;AAClB,IAAA;AACkB,EAAA;AAGqD,EAAA;AAC/D,IAAA;AACV,EAAA;AAEmB,EAAA;AACoC,IAAA;AAClB,MAAA;AACtB,MAAA;AACuB,QAAA;AAClC,MAAA;AACyB,MAAA;AAC3B,IAAA;AACM,IAAA;AACR,EAAA;AAE4B,EAAA;AAC0B,IAAA;AAEX,MAAA;AACE,MAAA;AAC9B,MAAA;AACiC,QAAA;AAC5C,MAAA;AACyB,MAAA;AAC3B,IAAA;AACM,IAAA;AACR,EAAA;AAEuC,EAAA;AACnB,IAAA;AACV,IAAA;AACE,EAAA;AAE4B,EAAA;AACnB,IAAA;AAChB,EAAA;AAES,EAAA;AACL,IAAA;AACL,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACA,IAAA;AACE,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACA,MAAA;AACF,IAAA;AACF,EAAA;AAKE,EAAA;AAEJ;AAMsD;AACT,EAAA;AAC7B,EAAA;AAC6D,IAAA;AAC3E,EAAA;AACO,EAAA;AACT;AAWqE;AAG/D,EAAA;AAAC,IAAA;AAAA,IAAA;AAC8E,MAAA;AACtE,MAAA;AACD,MAAA;AACyC,MAAA;AACzC,MAAA;AAAA,IAAA;AAEV,EAAA;AAEJ;AAsB2B;AAEL;AAEK;ADhK4D;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/augur-packages/augur-packages/packages/augur-web/dist/gtm.cjs","sourcesContent":[null,"\"use client\";\n\nimport {\n createContext,\n useCallback,\n useContext,\n useMemo,\n useRef,\n useState,\n} from \"react\";\nimport type { ReactNode } from \"react\";\n\n// ---------------------------------------------------------------------------\n// Types\n// ---------------------------------------------------------------------------\n\n/** Script loading strategy. */\nexport type AnalyticsStrategy = \"default\" | \"afterInteractive\" | \"lazyOnload\";\n\n/** GA4 standard e-commerce event names. */\nexport type EcommerceEvent =\n | \"view_item\"\n | \"view_item_list\"\n | \"select_item\"\n | \"add_to_cart\"\n | \"remove_from_cart\"\n | \"view_cart\"\n | \"begin_checkout\"\n | \"add_shipping_info\"\n | \"add_payment_info\"\n | \"purchase\"\n | \"refund\";\n\n/** GA4 e-commerce item shape. */\nexport interface EcommerceItem {\n item_id: string;\n item_name?: string;\n item_brand?: string;\n item_category?: string;\n item_variant?: string;\n price?: number;\n quantity?: number;\n index?: number;\n [key: string]: unknown;\n}\n\n/** Parameters for e-commerce events. */\nexport interface EcommerceParams {\n currency?: string;\n value?: number;\n items?: EcommerceItem[];\n transaction_id?: string;\n shipping?: number;\n tax?: number;\n coupon?: string;\n [key: string]: unknown;\n}\n\nexport interface AnalyticsProviderProps {\n /** GTM container ID (e.g. \"GTM-XXXXX\"). */\n gtmId: string;\n /** Script loading strategy. Default: \"afterInteractive\". */\n strategy?: AnalyticsStrategy;\n /** Delay GTM loading until consent is granted. Default: false. */\n consentRequired?: boolean;\n /** Log dataLayer pushes to console. Default: false. */\n debug?: boolean;\n children: ReactNode;\n}\n\nexport interface AnalyticsContextValue {\n /** Push a custom event to the dataLayer. */\n trackEvent: (event: string, params?: Record<string, unknown>) => void;\n /** Push a GA4 e-commerce event to the dataLayer. */\n trackEcommerceEvent: (\n event: EcommerceEvent,\n params: EcommerceParams,\n ) => void;\n /** Grant consent — loads GTM if consentRequired was true. */\n grantConsent: () => void;\n /** Revoke consent. Does not unload GTM (scripts can't be unloaded). */\n revokeConsent: () => void;\n /** Whether consent has been granted. */\n hasConsent: boolean;\n /** Whether the GTM script has been injected. */\n isLoaded: boolean;\n}\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\nconst AnalyticsContext = createContext<AnalyticsContextValue | null>(null);\n\n// ---------------------------------------------------------------------------\n// Helpers\n// ---------------------------------------------------------------------------\n\ndeclare global {\n interface Window {\n dataLayer?: Record<string, unknown>[];\n }\n}\n\nfunction getDataLayer(): Record<string, unknown>[] {\n if (typeof window === \"undefined\") return [];\n if (!window.dataLayer) window.dataLayer = [];\n return window.dataLayer;\n}\n\nfunction injectGtmScript(\n gtmId: string,\n strategy: AnalyticsStrategy,\n): void {\n if (typeof document === \"undefined\") return;\n\n // Prevent double-injection\n if (document.getElementById(\"gtm-script\")) return;\n\n const dataLayer = getDataLayer();\n dataLayer.push({ \"gtm.start\": new Date().getTime(), event: \"gtm.js\" });\n\n const script = document.createElement(\"script\");\n script.id = \"gtm-script\";\n script.src = `https://www.googletagmanager.com/gtm.js?id=${encodeURIComponent(gtmId)}`;\n\n if (strategy === \"lazyOnload\") {\n script.async = true;\n script.defer = true;\n } else {\n // \"default\" and \"afterInteractive\"\n script.async = true;\n }\n\n document.head.appendChild(script);\n}\n\n// ---------------------------------------------------------------------------\n// Provider\n// ---------------------------------------------------------------------------\n\nexport function AnalyticsProvider({\n gtmId,\n strategy = \"afterInteractive\",\n consentRequired = false,\n debug = false,\n children,\n}: AnalyticsProviderProps) {\n const [hasConsent, setHasConsent] = useState(!consentRequired);\n const [isLoaded, setIsLoaded] = useState(false);\n const injectedRef = useRef(false);\n\n const loadGtm = useCallback(() => {\n if (injectedRef.current) return;\n injectedRef.current = true;\n\n if (strategy === \"lazyOnload\" && typeof requestIdleCallback === \"function\") {\n requestIdleCallback(() => {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n });\n } else if (strategy === \"afterInteractive\") {\n // Defer to after hydration\n setTimeout(() => {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n }, 0);\n } else {\n injectGtmScript(gtmId, strategy);\n setIsLoaded(true);\n }\n }, [gtmId, strategy]);\n\n // Auto-load when consent is not required or already granted\n if (hasConsent && !injectedRef.current && typeof window !== \"undefined\") {\n loadGtm();\n }\n\n const trackEvent = useCallback(\n (event: string, params?: Record<string, unknown>) => {\n const entry = { event, ...params };\n if (debug) {\n console.log(\"[Analytics]\", entry);\n }\n getDataLayer().push(entry);\n },\n [debug],\n );\n\n const trackEcommerceEvent = useCallback(\n (event: EcommerceEvent, params: EcommerceParams) => {\n // Clear previous ecommerce data per GA4 best practices\n getDataLayer().push({ ecommerce: null });\n const entry = { event, ecommerce: params };\n if (debug) {\n console.log(\"[Analytics ecommerce]\", entry);\n }\n getDataLayer().push(entry);\n },\n [debug],\n );\n\n const grantConsent = useCallback(() => {\n setHasConsent(true);\n loadGtm();\n }, [loadGtm]);\n\n const revokeConsent = useCallback(() => {\n setHasConsent(false);\n }, []);\n\n const value = useMemo<AnalyticsContextValue>(\n () => ({\n trackEvent,\n trackEcommerceEvent,\n grantConsent,\n revokeConsent,\n hasConsent,\n isLoaded,\n }),\n [\n trackEvent,\n trackEcommerceEvent,\n grantConsent,\n revokeConsent,\n hasConsent,\n isLoaded,\n ],\n );\n\n return (\n <AnalyticsContext.Provider value={value}>\n {children}\n </AnalyticsContext.Provider>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Hook\n// ---------------------------------------------------------------------------\n\nexport function useAnalytics(): AnalyticsContextValue {\n const context = useContext(AnalyticsContext);\n if (!context) {\n throw new Error(\"useAnalytics must be used within an <AnalyticsProvider>\");\n }\n return context;\n}\n\n// ---------------------------------------------------------------------------\n// Noscript\n// ---------------------------------------------------------------------------\n\nexport interface AnalyticsNoscriptProps {\n /** GTM container ID (must match AnalyticsProvider). */\n gtmId: string;\n}\n\nexport function AnalyticsNoscript({ gtmId }: AnalyticsNoscriptProps) {\n return (\n <noscript>\n <iframe\n src={`https://www.googletagmanager.com/ns.html?id=${encodeURIComponent(gtmId)}`}\n height=\"0\"\n width=\"0\"\n style={{ display: \"none\", visibility: \"hidden\" }}\n title=\"Google Tag Manager\"\n />\n </noscript>\n );\n}\n\n// ---------------------------------------------------------------------------\n// Backward-compatible aliases (from #59 GtmProvider)\n// ---------------------------------------------------------------------------\n\n/** @deprecated Use `AnalyticsStrategy` instead. */\nexport type GtmStrategy = AnalyticsStrategy;\n/** @deprecated Use `EcommerceEvent` instead. */\nexport type GtmEcommerceEvent = EcommerceEvent;\n/** @deprecated Use `EcommerceItem` instead. */\nexport type GtmItem = EcommerceItem;\n/** @deprecated Use `EcommerceParams` instead. */\nexport type GtmEcommerceParams = EcommerceParams;\n/** @deprecated Use `AnalyticsProviderProps` instead. */\nexport type GtmProviderProps = AnalyticsProviderProps;\n/** @deprecated Use `AnalyticsContextValue` instead. */\nexport type GtmContextValue = AnalyticsContextValue;\n/** @deprecated Use `AnalyticsNoscriptProps` instead. */\nexport type GtmNoscriptProps = AnalyticsNoscriptProps;\n\n/** @deprecated Use `AnalyticsProvider` instead. */\nexport const GtmProvider = AnalyticsProvider;\n/** @deprecated Use `useAnalytics` instead. */\nexport const useGtm = useAnalytics;\n/** @deprecated Use `AnalyticsNoscript` instead. */\nexport const GtmNoscript = AnalyticsNoscript;\n"]}
|
package/dist/gtm.d.cts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Script loading strategy. */
|
|
5
|
+
type AnalyticsStrategy = "default" | "afterInteractive" | "lazyOnload";
|
|
6
|
+
/** GA4 standard e-commerce event names. */
|
|
7
|
+
type EcommerceEvent = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "begin_checkout" | "add_shipping_info" | "add_payment_info" | "purchase" | "refund";
|
|
8
|
+
/** GA4 e-commerce item shape. */
|
|
9
|
+
interface EcommerceItem {
|
|
10
|
+
item_id: string;
|
|
11
|
+
item_name?: string;
|
|
12
|
+
item_brand?: string;
|
|
13
|
+
item_category?: string;
|
|
14
|
+
item_variant?: string;
|
|
15
|
+
price?: number;
|
|
16
|
+
quantity?: number;
|
|
17
|
+
index?: number;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** Parameters for e-commerce events. */
|
|
21
|
+
interface EcommerceParams {
|
|
22
|
+
currency?: string;
|
|
23
|
+
value?: number;
|
|
24
|
+
items?: EcommerceItem[];
|
|
25
|
+
transaction_id?: string;
|
|
26
|
+
shipping?: number;
|
|
27
|
+
tax?: number;
|
|
28
|
+
coupon?: string;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
interface AnalyticsProviderProps {
|
|
32
|
+
/** GTM container ID (e.g. "GTM-XXXXX"). */
|
|
33
|
+
gtmId: string;
|
|
34
|
+
/** Script loading strategy. Default: "afterInteractive". */
|
|
35
|
+
strategy?: AnalyticsStrategy;
|
|
36
|
+
/** Delay GTM loading until consent is granted. Default: false. */
|
|
37
|
+
consentRequired?: boolean;
|
|
38
|
+
/** Log dataLayer pushes to console. Default: false. */
|
|
39
|
+
debug?: boolean;
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
interface AnalyticsContextValue {
|
|
43
|
+
/** Push a custom event to the dataLayer. */
|
|
44
|
+
trackEvent: (event: string, params?: Record<string, unknown>) => void;
|
|
45
|
+
/** Push a GA4 e-commerce event to the dataLayer. */
|
|
46
|
+
trackEcommerceEvent: (event: EcommerceEvent, params: EcommerceParams) => void;
|
|
47
|
+
/** Grant consent — loads GTM if consentRequired was true. */
|
|
48
|
+
grantConsent: () => void;
|
|
49
|
+
/** Revoke consent. Does not unload GTM (scripts can't be unloaded). */
|
|
50
|
+
revokeConsent: () => void;
|
|
51
|
+
/** Whether consent has been granted. */
|
|
52
|
+
hasConsent: boolean;
|
|
53
|
+
/** Whether the GTM script has been injected. */
|
|
54
|
+
isLoaded: boolean;
|
|
55
|
+
}
|
|
56
|
+
declare global {
|
|
57
|
+
interface Window {
|
|
58
|
+
dataLayer?: Record<string, unknown>[];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
declare function AnalyticsProvider({ gtmId, strategy, consentRequired, debug, children, }: AnalyticsProviderProps): react_jsx_runtime.JSX.Element;
|
|
62
|
+
declare function useAnalytics(): AnalyticsContextValue;
|
|
63
|
+
interface AnalyticsNoscriptProps {
|
|
64
|
+
/** GTM container ID (must match AnalyticsProvider). */
|
|
65
|
+
gtmId: string;
|
|
66
|
+
}
|
|
67
|
+
declare function AnalyticsNoscript({ gtmId }: AnalyticsNoscriptProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
/** @deprecated Use `AnalyticsStrategy` instead. */
|
|
69
|
+
type GtmStrategy = AnalyticsStrategy;
|
|
70
|
+
/** @deprecated Use `EcommerceEvent` instead. */
|
|
71
|
+
type GtmEcommerceEvent = EcommerceEvent;
|
|
72
|
+
/** @deprecated Use `EcommerceItem` instead. */
|
|
73
|
+
type GtmItem = EcommerceItem;
|
|
74
|
+
/** @deprecated Use `EcommerceParams` instead. */
|
|
75
|
+
type GtmEcommerceParams = EcommerceParams;
|
|
76
|
+
/** @deprecated Use `AnalyticsProviderProps` instead. */
|
|
77
|
+
type GtmProviderProps = AnalyticsProviderProps;
|
|
78
|
+
/** @deprecated Use `AnalyticsContextValue` instead. */
|
|
79
|
+
type GtmContextValue = AnalyticsContextValue;
|
|
80
|
+
/** @deprecated Use `AnalyticsNoscriptProps` instead. */
|
|
81
|
+
type GtmNoscriptProps = AnalyticsNoscriptProps;
|
|
82
|
+
/** @deprecated Use `AnalyticsProvider` instead. */
|
|
83
|
+
declare const GtmProvider: typeof AnalyticsProvider;
|
|
84
|
+
/** @deprecated Use `useAnalytics` instead. */
|
|
85
|
+
declare const useGtm: typeof useAnalytics;
|
|
86
|
+
/** @deprecated Use `AnalyticsNoscript` instead. */
|
|
87
|
+
declare const GtmNoscript: typeof AnalyticsNoscript;
|
|
88
|
+
|
|
89
|
+
export { type AnalyticsContextValue, AnalyticsNoscript, type AnalyticsNoscriptProps, AnalyticsProvider, type AnalyticsProviderProps, type AnalyticsStrategy, type EcommerceEvent, type EcommerceItem, type EcommerceParams, type GtmContextValue, type GtmEcommerceEvent, type GtmEcommerceParams, type GtmItem, GtmNoscript, type GtmNoscriptProps, GtmProvider, type GtmProviderProps, type GtmStrategy, useAnalytics, useGtm };
|
package/dist/gtm.d.ts
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
3
|
+
|
|
4
|
+
/** Script loading strategy. */
|
|
5
|
+
type AnalyticsStrategy = "default" | "afterInteractive" | "lazyOnload";
|
|
6
|
+
/** GA4 standard e-commerce event names. */
|
|
7
|
+
type EcommerceEvent = "view_item" | "view_item_list" | "select_item" | "add_to_cart" | "remove_from_cart" | "view_cart" | "begin_checkout" | "add_shipping_info" | "add_payment_info" | "purchase" | "refund";
|
|
8
|
+
/** GA4 e-commerce item shape. */
|
|
9
|
+
interface EcommerceItem {
|
|
10
|
+
item_id: string;
|
|
11
|
+
item_name?: string;
|
|
12
|
+
item_brand?: string;
|
|
13
|
+
item_category?: string;
|
|
14
|
+
item_variant?: string;
|
|
15
|
+
price?: number;
|
|
16
|
+
quantity?: number;
|
|
17
|
+
index?: number;
|
|
18
|
+
[key: string]: unknown;
|
|
19
|
+
}
|
|
20
|
+
/** Parameters for e-commerce events. */
|
|
21
|
+
interface EcommerceParams {
|
|
22
|
+
currency?: string;
|
|
23
|
+
value?: number;
|
|
24
|
+
items?: EcommerceItem[];
|
|
25
|
+
transaction_id?: string;
|
|
26
|
+
shipping?: number;
|
|
27
|
+
tax?: number;
|
|
28
|
+
coupon?: string;
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
interface AnalyticsProviderProps {
|
|
32
|
+
/** GTM container ID (e.g. "GTM-XXXXX"). */
|
|
33
|
+
gtmId: string;
|
|
34
|
+
/** Script loading strategy. Default: "afterInteractive". */
|
|
35
|
+
strategy?: AnalyticsStrategy;
|
|
36
|
+
/** Delay GTM loading until consent is granted. Default: false. */
|
|
37
|
+
consentRequired?: boolean;
|
|
38
|
+
/** Log dataLayer pushes to console. Default: false. */
|
|
39
|
+
debug?: boolean;
|
|
40
|
+
children: ReactNode;
|
|
41
|
+
}
|
|
42
|
+
interface AnalyticsContextValue {
|
|
43
|
+
/** Push a custom event to the dataLayer. */
|
|
44
|
+
trackEvent: (event: string, params?: Record<string, unknown>) => void;
|
|
45
|
+
/** Push a GA4 e-commerce event to the dataLayer. */
|
|
46
|
+
trackEcommerceEvent: (event: EcommerceEvent, params: EcommerceParams) => void;
|
|
47
|
+
/** Grant consent — loads GTM if consentRequired was true. */
|
|
48
|
+
grantConsent: () => void;
|
|
49
|
+
/** Revoke consent. Does not unload GTM (scripts can't be unloaded). */
|
|
50
|
+
revokeConsent: () => void;
|
|
51
|
+
/** Whether consent has been granted. */
|
|
52
|
+
hasConsent: boolean;
|
|
53
|
+
/** Whether the GTM script has been injected. */
|
|
54
|
+
isLoaded: boolean;
|
|
55
|
+
}
|
|
56
|
+
declare global {
|
|
57
|
+
interface Window {
|
|
58
|
+
dataLayer?: Record<string, unknown>[];
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
declare function AnalyticsProvider({ gtmId, strategy, consentRequired, debug, children, }: AnalyticsProviderProps): react_jsx_runtime.JSX.Element;
|
|
62
|
+
declare function useAnalytics(): AnalyticsContextValue;
|
|
63
|
+
interface AnalyticsNoscriptProps {
|
|
64
|
+
/** GTM container ID (must match AnalyticsProvider). */
|
|
65
|
+
gtmId: string;
|
|
66
|
+
}
|
|
67
|
+
declare function AnalyticsNoscript({ gtmId }: AnalyticsNoscriptProps): react_jsx_runtime.JSX.Element;
|
|
68
|
+
/** @deprecated Use `AnalyticsStrategy` instead. */
|
|
69
|
+
type GtmStrategy = AnalyticsStrategy;
|
|
70
|
+
/** @deprecated Use `EcommerceEvent` instead. */
|
|
71
|
+
type GtmEcommerceEvent = EcommerceEvent;
|
|
72
|
+
/** @deprecated Use `EcommerceItem` instead. */
|
|
73
|
+
type GtmItem = EcommerceItem;
|
|
74
|
+
/** @deprecated Use `EcommerceParams` instead. */
|
|
75
|
+
type GtmEcommerceParams = EcommerceParams;
|
|
76
|
+
/** @deprecated Use `AnalyticsProviderProps` instead. */
|
|
77
|
+
type GtmProviderProps = AnalyticsProviderProps;
|
|
78
|
+
/** @deprecated Use `AnalyticsContextValue` instead. */
|
|
79
|
+
type GtmContextValue = AnalyticsContextValue;
|
|
80
|
+
/** @deprecated Use `AnalyticsNoscriptProps` instead. */
|
|
81
|
+
type GtmNoscriptProps = AnalyticsNoscriptProps;
|
|
82
|
+
/** @deprecated Use `AnalyticsProvider` instead. */
|
|
83
|
+
declare const GtmProvider: typeof AnalyticsProvider;
|
|
84
|
+
/** @deprecated Use `useAnalytics` instead. */
|
|
85
|
+
declare const useGtm: typeof useAnalytics;
|
|
86
|
+
/** @deprecated Use `AnalyticsNoscript` instead. */
|
|
87
|
+
declare const GtmNoscript: typeof AnalyticsNoscript;
|
|
88
|
+
|
|
89
|
+
export { type AnalyticsContextValue, AnalyticsNoscript, type AnalyticsNoscriptProps, AnalyticsProvider, type AnalyticsProviderProps, type AnalyticsStrategy, type EcommerceEvent, type EcommerceItem, type EcommerceParams, type GtmContextValue, type GtmEcommerceEvent, type GtmEcommerceParams, type GtmItem, GtmNoscript, type GtmNoscriptProps, GtmProvider, type GtmProviderProps, type GtmStrategy, useAnalytics, useGtm };
|