@mission-studio/puck 1.0.3 → 1.0.5

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.
@@ -0,0 +1,67 @@
1
+ // hooks/useGtmEvent.ts
2
+ function useGtmEvent() {
3
+ return (eventName, data) => {
4
+ if (typeof window === "undefined") return;
5
+ if (typeof window.gtag === "function") {
6
+ window.gtag("event", eventName, data || {});
7
+ }
8
+ };
9
+ }
10
+
11
+ // hooks/useUtmParams.ts
12
+ import { useEffect, useState } from "react";
13
+ function useUtmParams() {
14
+ const [utmParams, setUtmParams] = useState({});
15
+ useEffect(() => {
16
+ if (typeof window === "undefined") return;
17
+ const urlParams = new URLSearchParams(window.location.search);
18
+ const source = urlParams.get("utm_source");
19
+ const medium = urlParams.get("utm_medium");
20
+ const campaign = urlParams.get("utm_campaign");
21
+ const content = urlParams.get("utm_content");
22
+ const term = urlParams.get("utm_term");
23
+ const params = {};
24
+ if (source) {
25
+ params.source = source;
26
+ sessionStorage.setItem("utm_source", source);
27
+ } else {
28
+ const stored = sessionStorage.getItem("utm_source");
29
+ if (stored) params.source = stored;
30
+ }
31
+ if (medium) {
32
+ params.medium = medium;
33
+ sessionStorage.setItem("utm_medium", medium);
34
+ } else {
35
+ const stored = sessionStorage.getItem("utm_medium");
36
+ if (stored) params.medium = stored;
37
+ }
38
+ if (campaign) {
39
+ params.campaign = campaign;
40
+ sessionStorage.setItem("utm_campaign", campaign);
41
+ } else {
42
+ const stored = sessionStorage.getItem("utm_campaign");
43
+ if (stored) params.campaign = stored;
44
+ }
45
+ if (content) {
46
+ params.content = content;
47
+ sessionStorage.setItem("utm_content", content);
48
+ } else {
49
+ const stored = sessionStorage.getItem("utm_content");
50
+ if (stored) params.content = stored;
51
+ }
52
+ if (term) {
53
+ params.term = term;
54
+ sessionStorage.setItem("utm_term", term);
55
+ } else {
56
+ const stored = sessionStorage.getItem("utm_term");
57
+ if (stored) params.term = stored;
58
+ }
59
+ setUtmParams(params);
60
+ }, []);
61
+ return utmParams;
62
+ }
63
+
64
+ export {
65
+ useGtmEvent,
66
+ useUtmParams
67
+ };
@@ -5,6 +5,9 @@ import {
5
5
  useEntries,
6
6
  useTheme
7
7
  } from "./chunk-TTKY3YGP.mjs";
8
+ import {
9
+ useUtmParams
10
+ } from "./chunk-QSWQDR6M.mjs";
8
11
 
9
12
  // components/page/Heading.tsx
10
13
  import { jsx } from "react/jsx-runtime";
@@ -160,61 +163,6 @@ function Paragraph({
160
163
 
161
164
  // components/page/Button.tsx
162
165
  import { sendGTMEvent } from "@next/third-parties/google";
163
-
164
- // hooks/useUtmParams.ts
165
- import { useEffect, useState } from "react";
166
- function useUtmParams() {
167
- const [utmParams, setUtmParams] = useState({});
168
- useEffect(() => {
169
- if (typeof window === "undefined") return;
170
- const urlParams = new URLSearchParams(window.location.search);
171
- const source = urlParams.get("utm_source");
172
- const medium = urlParams.get("utm_medium");
173
- const campaign = urlParams.get("utm_campaign");
174
- const content = urlParams.get("utm_content");
175
- const term = urlParams.get("utm_term");
176
- const params = {};
177
- if (source) {
178
- params.source = source;
179
- sessionStorage.setItem("utm_source", source);
180
- } else {
181
- const stored = sessionStorage.getItem("utm_source");
182
- if (stored) params.source = stored;
183
- }
184
- if (medium) {
185
- params.medium = medium;
186
- sessionStorage.setItem("utm_medium", medium);
187
- } else {
188
- const stored = sessionStorage.getItem("utm_medium");
189
- if (stored) params.medium = stored;
190
- }
191
- if (campaign) {
192
- params.campaign = campaign;
193
- sessionStorage.setItem("utm_campaign", campaign);
194
- } else {
195
- const stored = sessionStorage.getItem("utm_campaign");
196
- if (stored) params.campaign = stored;
197
- }
198
- if (content) {
199
- params.content = content;
200
- sessionStorage.setItem("utm_content", content);
201
- } else {
202
- const stored = sessionStorage.getItem("utm_content");
203
- if (stored) params.content = stored;
204
- }
205
- if (term) {
206
- params.term = term;
207
- sessionStorage.setItem("utm_term", term);
208
- } else {
209
- const stored = sessionStorage.getItem("utm_term");
210
- if (stored) params.term = stored;
211
- }
212
- setUtmParams(params);
213
- }, []);
214
- return utmParams;
215
- }
216
-
217
- // components/page/Button.tsx
218
166
  import { jsx as jsx3 } from "react/jsx-runtime";
219
167
  var sizeStyles = {
220
168
  sm: { padding: "8px 16px", fontSize: "0.875rem" },
@@ -263,12 +211,14 @@ function Button({
263
211
  return "Button";
264
212
  })();
265
213
  const handleClick = () => {
214
+ const sessionId = typeof window !== "undefined" ? sessionStorage.getItem("session_id") : null;
266
215
  sendGTMEvent({
267
216
  event: "button_click",
268
217
  value: {
269
218
  text: resolvedText,
270
219
  href: href || void 0,
271
220
  variant,
221
+ session_id: sessionId,
272
222
  ...utm
273
223
  }
274
224
  });
@@ -484,7 +434,7 @@ function Image({
484
434
  }
485
435
 
486
436
  // components/page/ImageCarousel.tsx
487
- import { useState as useState2 } from "react";
437
+ import { useState } from "react";
488
438
  import { sendGTMEvent as sendGTMEvent2 } from "@next/third-parties/google";
489
439
  import { Fragment, jsx as jsx5, jsxs as jsxs2 } from "react/jsx-runtime";
490
440
  var aspectRatioMap2 = {
@@ -512,7 +462,7 @@ function ImageCarousel({
512
462
  dotColor,
513
463
  id
514
464
  }) {
515
- const [currentIndex, setCurrentIndex] = useState2(0);
465
+ const [currentIndex, setCurrentIndex] = useState(0);
516
466
  const { resolveColor: resolveColor2 } = useTheme();
517
467
  const utm = useUtmParams();
518
468
  const resolvedArrowColor = (() => {
@@ -1728,7 +1678,7 @@ function Footer({
1728
1678
  }
1729
1679
 
1730
1680
  // components/page/Topbar.tsx
1731
- import { useState as useState3 } from "react";
1681
+ import { useState as useState2 } from "react";
1732
1682
  import Link from "next/link";
1733
1683
  import { Menu, X } from "lucide-react";
1734
1684
  import { sendGTMEvent as sendGTMEvent4 } from "@next/third-parties/google";
@@ -1743,7 +1693,7 @@ function Topbar({
1743
1693
  puck
1744
1694
  }) {
1745
1695
  const DropZone = puck?.renderDropZone;
1746
- const [mobileMenuOpen, setMobileMenuOpen] = useState3(false);
1696
+ const [mobileMenuOpen, setMobileMenuOpen] = useState2(false);
1747
1697
  const utm = useUtmParams();
1748
1698
  const handleNavClick = (item) => {
1749
1699
  sendGTMEvent4({
@@ -1860,7 +1810,7 @@ function Topbar({
1860
1810
  }
1861
1811
 
1862
1812
  // components/page/Popup.tsx
1863
- import { useState as useState4 } from "react";
1813
+ import { useState as useState3 } from "react";
1864
1814
  import { icons as icons4, X as X2 } from "lucide-react";
1865
1815
  import { sendGTMEvent as sendGTMEvent5 } from "@next/third-parties/google";
1866
1816
  import { Fragment as Fragment2, jsx as jsx20, jsxs as jsxs9 } from "react/jsx-runtime";
@@ -1891,7 +1841,7 @@ function Popup({
1891
1841
  textLink = false,
1892
1842
  puck
1893
1843
  }) {
1894
- const [isOpen, setIsOpen] = useState4(false);
1844
+ const [isOpen, setIsOpen] = useState3(false);
1895
1845
  const utm = useUtmParams();
1896
1846
  const handleOpen = () => {
1897
1847
  setIsOpen(true);
@@ -397,12 +397,14 @@ function Button({
397
397
  return "Button";
398
398
  })();
399
399
  const handleClick = () => {
400
+ const sessionId = typeof window !== "undefined" ? sessionStorage.getItem("session_id") : null;
400
401
  (0, import_google.sendGTMEvent)({
401
402
  event: "button_click",
402
403
  value: {
403
404
  text: resolvedText,
404
405
  href: href || void 0,
405
406
  variant,
407
+ session_id: sessionId,
406
408
  ...utm
407
409
  }
408
410
  });
@@ -29,8 +29,9 @@ import {
29
29
  Topbar,
30
30
  VideoEmbed,
31
31
  availableIcons
32
- } from "./chunk-F47J7QDM.mjs";
32
+ } from "./chunk-R7TH6TWG.mjs";
33
33
  import "./chunk-TTKY3YGP.mjs";
34
+ import "./chunk-QSWQDR6M.mjs";
34
35
 
35
36
  // config.tsx
36
37
  import { jsx } from "react/jsx-runtime";
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Hook to send events to Google Tag Manager
3
+ * Assumes GTM is initialized in the parent app via @next/third-parties/google
4
+ * @example
5
+ * const sendEvent = useGtmEvent();
6
+ * sendEvent('button_click', { text: 'Sign Up', href: '/signup' });
7
+ */
8
+ declare function useGtmEvent(): (eventName: string, data?: Record<string, any>) => void;
9
+ declare global {
10
+ interface Window {
11
+ gtag?: (...args: any[]) => void;
12
+ }
13
+ }
14
+
15
+ /**
16
+ * UTM parameter object
17
+ */
18
+ interface UtmParams {
19
+ source?: string;
20
+ medium?: string;
21
+ campaign?: string;
22
+ content?: string;
23
+ term?: string;
24
+ }
25
+ /**
26
+ * Hook to capture and persist UTM parameters from URL
27
+ * Stores in sessionStorage so they persist across navigation
28
+ * @returns Current UTM parameters
29
+ */
30
+ declare function useUtmParams(): UtmParams;
31
+
32
+ export { type UtmParams, useGtmEvent, useUtmParams };
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Hook to send events to Google Tag Manager
3
+ * Assumes GTM is initialized in the parent app via @next/third-parties/google
4
+ * @example
5
+ * const sendEvent = useGtmEvent();
6
+ * sendEvent('button_click', { text: 'Sign Up', href: '/signup' });
7
+ */
8
+ declare function useGtmEvent(): (eventName: string, data?: Record<string, any>) => void;
9
+ declare global {
10
+ interface Window {
11
+ gtag?: (...args: any[]) => void;
12
+ }
13
+ }
14
+
15
+ /**
16
+ * UTM parameter object
17
+ */
18
+ interface UtmParams {
19
+ source?: string;
20
+ medium?: string;
21
+ campaign?: string;
22
+ content?: string;
23
+ term?: string;
24
+ }
25
+ /**
26
+ * Hook to capture and persist UTM parameters from URL
27
+ * Stores in sessionStorage so they persist across navigation
28
+ * @returns Current UTM parameters
29
+ */
30
+ declare function useUtmParams(): UtmParams;
31
+
32
+ export { type UtmParams, useGtmEvent, useUtmParams };
@@ -0,0 +1,94 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // hooks/index.ts
21
+ var hooks_exports = {};
22
+ __export(hooks_exports, {
23
+ useGtmEvent: () => useGtmEvent,
24
+ useUtmParams: () => useUtmParams
25
+ });
26
+ module.exports = __toCommonJS(hooks_exports);
27
+
28
+ // hooks/useGtmEvent.ts
29
+ function useGtmEvent() {
30
+ return (eventName, data) => {
31
+ if (typeof window === "undefined") return;
32
+ if (typeof window.gtag === "function") {
33
+ window.gtag("event", eventName, data || {});
34
+ }
35
+ };
36
+ }
37
+
38
+ // hooks/useUtmParams.ts
39
+ var import_react = require("react");
40
+ function useUtmParams() {
41
+ const [utmParams, setUtmParams] = (0, import_react.useState)({});
42
+ (0, import_react.useEffect)(() => {
43
+ if (typeof window === "undefined") return;
44
+ const urlParams = new URLSearchParams(window.location.search);
45
+ const source = urlParams.get("utm_source");
46
+ const medium = urlParams.get("utm_medium");
47
+ const campaign = urlParams.get("utm_campaign");
48
+ const content = urlParams.get("utm_content");
49
+ const term = urlParams.get("utm_term");
50
+ const params = {};
51
+ if (source) {
52
+ params.source = source;
53
+ sessionStorage.setItem("utm_source", source);
54
+ } else {
55
+ const stored = sessionStorage.getItem("utm_source");
56
+ if (stored) params.source = stored;
57
+ }
58
+ if (medium) {
59
+ params.medium = medium;
60
+ sessionStorage.setItem("utm_medium", medium);
61
+ } else {
62
+ const stored = sessionStorage.getItem("utm_medium");
63
+ if (stored) params.medium = stored;
64
+ }
65
+ if (campaign) {
66
+ params.campaign = campaign;
67
+ sessionStorage.setItem("utm_campaign", campaign);
68
+ } else {
69
+ const stored = sessionStorage.getItem("utm_campaign");
70
+ if (stored) params.campaign = stored;
71
+ }
72
+ if (content) {
73
+ params.content = content;
74
+ sessionStorage.setItem("utm_content", content);
75
+ } else {
76
+ const stored = sessionStorage.getItem("utm_content");
77
+ if (stored) params.content = stored;
78
+ }
79
+ if (term) {
80
+ params.term = term;
81
+ sessionStorage.setItem("utm_term", term);
82
+ } else {
83
+ const stored = sessionStorage.getItem("utm_term");
84
+ if (stored) params.term = stored;
85
+ }
86
+ setUtmParams(params);
87
+ }, []);
88
+ return utmParams;
89
+ }
90
+ // Annotate the CommonJS export names for ESM import in node:
91
+ 0 && (module.exports = {
92
+ useGtmEvent,
93
+ useUtmParams
94
+ });
@@ -0,0 +1,8 @@
1
+ import {
2
+ useGtmEvent,
3
+ useUtmParams
4
+ } from "../chunk-QSWQDR6M.mjs";
5
+ export {
6
+ useGtmEvent,
7
+ useUtmParams
8
+ };
package/dist/index.js CHANGED
@@ -437,12 +437,14 @@ function Button({
437
437
  return "Button";
438
438
  })();
439
439
  const handleClick = () => {
440
+ const sessionId = typeof window !== "undefined" ? sessionStorage.getItem("session_id") : null;
440
441
  (0, import_google.sendGTMEvent)({
441
442
  event: "button_click",
442
443
  value: {
443
444
  text: resolvedText,
444
445
  href: href || void 0,
445
446
  variant,
447
+ session_id: sessionId,
446
448
  ...utm
447
449
  }
448
450
  });
package/dist/index.mjs CHANGED
@@ -20,7 +20,7 @@ import {
20
20
  Topbar,
21
21
  VideoEmbed,
22
22
  availableIcons
23
- } from "./chunk-F47J7QDM.mjs";
23
+ } from "./chunk-R7TH6TWG.mjs";
24
24
  import {
25
25
  allColorPresets,
26
26
  neutralColors
@@ -41,6 +41,7 @@ import {
41
41
  spacingScale,
42
42
  useTheme
43
43
  } from "./chunk-TTKY3YGP.mjs";
44
+ import "./chunk-QSWQDR6M.mjs";
44
45
  export {
45
46
  Button,
46
47
  Card,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mission-studio/puck",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "A collection of puck components and configurations for internal use at Mission Studio.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,6 +37,11 @@
37
37
  "import": "./dist/config-entry.mjs",
38
38
  "require": "./dist/config-entry.js"
39
39
  },
40
+ "./hooks": {
41
+ "types": "./dist/hooks/index.d.ts",
42
+ "import": "./dist/hooks/index.mjs",
43
+ "require": "./dist/hooks/index.js"
44
+ },
40
45
  "./styles.css": "./dist/styles.css"
41
46
  },
42
47
  "scripts": {