@devgateway/dvz-ui-react 1.6.11 → 1.6.13

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.
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _={REACT_APP_WP_API:process.env.VITE_REACT_APP_WP_API??"/wp/wp-json",REACT_APP_API_ROOT:process.env.VITE_REACT_APP_API_ROOT??null,GA_CODE:process.env.VITE_REACT_APP_GA_CODE??"",DEFAULT_LOCALE:process.env.VITE_REACT_APP_DEFAULT_LOCALE??"en"};exports.Config=_;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const _={REACT_APP_WP_API:process.env.VITE_REACT_APP_WP_API??"/wp/wp-json",REACT_APP_API_ROOT:process.env.VITE_REACT_APP_API_ROOT??null,GA_CODE:process.env.VITE_REACT_APP_GA_CODE??"",DEFAULT_LOCALE:process.env.VITE_REACT_APP_DEFAULT_LOCALE??"en",INTERNAL_GA_TOKEN:process.env.VITE_INTERNAL_GA_TOKEN??""};exports.Config=_;
@@ -1 +1 @@
1
- "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),u=require("@devgateway/wp-react-lib"),p=require("semantic-ui-react"),r=require("pure-react-carousel"),x=s=>{let o=0;const{posts:t,height:i,interval:l,autoSwitch:a}=s;return e.jsxs(r.CarouselProvider,{interval:l,isPlaying:a,totalSlides:t.length,naturalSlideHeight:i,children:[e.jsx(r.Slider,{style:{height:`${i}px`},trayTag:"ul",children:t.map(n=>e.jsx(r.Slide,{index:o++,tag:"li",children:e.jsx(u.PostIntro,{post:n,fluid:!0})}))}),e.jsx(r.DotGroup,{})]})},j=s=>{const{"data-type":o,"data-taxonomy":t,"data-categories":i,"data-items":l,"data-height":a,"data-auto-switch":n="false","data-interval":c=1e4,editing:d,parent:h,unique:g}=s;return e.jsx(p.Container,{style:{height:`${a}px`},className:`viz post carousel ${d?"editing":""}`,fluid:!0,children:e.jsx(u.PostProvider,{type:o,taxonomy:t,categories:i,store:"carousel_"+h+"_"+g,page:1,perPage:l,children:e.jsx(u.PostConsumer,{children:e.jsx(x,{height:a,interval:c,autoSwitch:n=="true"})})})})};exports.default=j;
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const e=require("react/jsx-runtime"),u=require("@devgateway/wp-react-lib"),p=require("semantic-ui-react"),i=require("pure-react-carousel"),x=r=>{let s=0;const{posts:t,height:o,interval:l,autoSwitch:a}=r;return e.jsxs(i.CarouselProvider,{interval:l,isPlaying:a,totalSlides:t.length,naturalSlideHeight:o,children:[e.jsx(i.Slider,{trayTag:"ul",children:t.map(n=>e.jsx(i.Slide,{index:s++,tag:"li",children:e.jsx(u.PostIntro,{post:n,fluid:!0})}))}),e.jsx(i.DotGroup,{})]})},j=r=>{const{"data-type":s,"data-taxonomy":t,"data-categories":o,"data-items":l,"data-height":a,"data-auto-switch":n="false","data-interval":c=1e4,editing:d,parent:h,unique:g}=r;return e.jsx(p.Container,{style:{height:`${a}px`},className:`viz post carousel ${d?"editing":""}`,fluid:!0,children:e.jsx(u.PostProvider,{type:s,taxonomy:t,categories:o,store:"carousel_"+h+"_"+g,page:1,perPage:l,children:e.jsx(u.PostConsumer,{children:e.jsx(x,{height:a,interval:c,autoSwitch:n=="true"})})})})};exports.default=j;
package/dist/cjs/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./embeddable/index.js"),a=require("./conf/index.js"),s=require("./layout/ResponsiveContainer.js"),u=require("./layout/ScrollTop.js"),c=require("./layout/containers/PreviewPageContainer.js"),l=require("./layout/containers/PreviewTypeContainer.js"),d=require("./layout/containers/SlugContainer.js"),p=require("./layout/containers/SlugPostContainer.js"),m=require("./layout/Customizer.js"),q=require("./layout/Layout.js"),C=require("./layout/PreviewComponent.js"),g=require("./layout/Favicon.js"),S=require("./layout/SSRFavicon.js"),T=require("./layout/Loading.js"),P=require("./layout/CustomSemanticSearch.js"),f=require("./layout/Header.js"),h=require("./layout/SearchControl.js"),v=require("./layout/LangSwitcher.js"),y=require("./layout/Footer.js"),A=require("./layout/ClassicHeader.js"),I=require("./layout/FlexWrapDetector.js"),H=require("./layout/FloatingMenuHeader.js"),w=require("./tracker/withGoogleAnalytics.js"),R=require("./redux/store.js"),i=require("./redux/hooks.js"),o=require("./lib/react-intl-redux/index.js"),x=require("./lib/redux-immutable/index.js"),F=require("./translations/en.json.js"),M=require("./translations/fr.json.js"),O=require("./translations/af.json.js"),E=require("./translations/am.json.js"),L=require("./countries.js"),t=require("./utils/data.js"),n=require("./utils/AppMedia.js"),e=require("./utils/semanticUtils.js"),N=require("./lib/react-intl-redux/providers/Provider.js"),U=require("./lib/react-intl-redux/providers/IntlProvider.js");exports.components=r.components;exports.customizer=r.customizer;exports.getComponentByNameIgnoreCase=r.getComponentByNameIgnoreCase;exports.reducers=r.reducers;exports.Config=a.Config;exports.ResponsiveContainer=s.default;exports.ScrollToTop=u.default;exports.PreviewPageContainer=c.default;exports.PreviewTypeContainer=l.default;exports.SlugContainer=d.default;exports.SlugPostContainer=p.default;exports.CustomizerWrapper=m.CustomizerWrapper;exports.RootLayout=q.default;exports.PreviewComponent=C.default;exports.Favicon=g.default;exports.SSRFavicon=S.default;exports.Loading=T.default;exports.CustomSemanticSearch=P.default;exports.Header=f.default;exports.SearchControl=h.default;exports.LangSwitcher=v.default;exports.Footer=y.default;exports.ClassicHeader=A.default;exports.FlexWrapDetector=I.default;exports.FloatingMenuHeader=H.default;exports.withTracker=w.withTracker;exports.store=R.store;exports.useAppDispatch=i.useAppDispatch;exports.useAppSelector=i.useAppSelector;exports.UPDATE=o.UPDATE;exports.initialState=o.initialState;exports.intlReducer=o.intlReducer;exports.updateIntl=o.updateIntl;exports.combineReducers=x.combineReducers;exports.englishTranslations=F;exports.frenchTranslations=M;exports.afrikaansTranslations=O;exports.amharicTranslations=E;exports.COUNTRY_OPTIONS=L.COUNTRY_OPTIONS;exports.decodeHtmlEntitiesToHtml=t.decodeHtmlEntitiesToHtml;exports.decodeHtmlEntitiesToText=t.decodeHtmlEntitiesToText;exports.stringToArray=t.stringToArray;exports.toBoolean=t.toBoolean;exports.toNumber=t.toNumber;exports.uriStringToArray=t.uriStringToArray;exports.Media=n.Media;exports.MediaContextProvider=n.MediaContextProvider;exports.mediaStyle=n.mediaStyle;exports.getUnhandledProps=e.getUnhandledProps;exports.htmlImageProps=e.htmlImageProps;exports.htmlInputAttrs=e.htmlInputAttrs;exports.htmlInputEvents=e.htmlInputEvents;exports.htmlInputProps=e.htmlInputProps;exports.partitionHTMLProps=e.partitionHTMLProps;exports.useKeyOnly=e.useKeyOnly;exports.useValueAndKey=e.useValueAndKey;exports.Provider=N.default;exports.IntlProvider=U.default;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./embeddable/index.js"),s=require("./conf/index.js"),u=require("./layout/ResponsiveContainer.js"),l=require("./layout/ScrollTop.js"),c=require("./layout/containers/PreviewPageContainer.js"),d=require("./layout/containers/PreviewTypeContainer.js"),p=require("./layout/containers/SlugContainer.js"),f=require("./layout/containers/SlugPostContainer.js"),m=require("./layout/Customizer.js"),T=require("./layout/Layout.js"),q=require("./layout/PreviewComponent.js"),C=require("./layout/Favicon.js"),g=require("./layout/SSRFavicon.js"),S=require("./layout/Loading.js"),P=require("./layout/CustomSemanticSearch.js"),h=require("./layout/Header.js"),I=require("./layout/SearchControl.js"),v=require("./layout/LangSwitcher.js"),y=require("./layout/Footer.js"),A=require("./layout/ClassicHeader.js"),H=require("./layout/FlexWrapDetector.js"),w=require("./layout/FloatingMenuHeader.js"),R=require("./tracker/withGoogleAnalytics.js"),n=require("./tracker/internalTrafficUtils.js"),k=require("./tracker/InternalTrafficToggle.js"),x=require("./redux/store.js"),a=require("./redux/hooks.js"),o=require("./lib/react-intl-redux/index.js"),E=require("./lib/redux-immutable/index.js"),F=require("./translations/en.json.js"),M=require("./translations/fr.json.js"),O=require("./translations/af.json.js"),b=require("./translations/am.json.js"),L=require("./countries.js"),r=require("./utils/data.js"),i=require("./utils/AppMedia.js"),e=require("./utils/semanticUtils.js"),N=require("./lib/react-intl-redux/providers/Provider.js"),U=require("./lib/react-intl-redux/providers/IntlProvider.js");exports.components=t.components;exports.customizer=t.customizer;exports.getComponentByNameIgnoreCase=t.getComponentByNameIgnoreCase;exports.reducers=t.reducers;exports.Config=s.Config;exports.ResponsiveContainer=u.default;exports.ScrollToTop=l.default;exports.PreviewPageContainer=c.default;exports.PreviewTypeContainer=d.default;exports.SlugContainer=p.default;exports.SlugPostContainer=f.default;exports.CustomizerWrapper=m.CustomizerWrapper;exports.RootLayout=T.default;exports.PreviewComponent=q.default;exports.Favicon=C.default;exports.SSRFavicon=g.default;exports.Loading=S.default;exports.CustomSemanticSearch=P.default;exports.Header=h.default;exports.SearchControl=I.default;exports.LangSwitcher=v.default;exports.Footer=y.default;exports.ClassicHeader=A.default;exports.FlexWrapDetector=H.default;exports.FloatingMenuHeader=w.default;exports.withTracker=R.withTracker;exports.clearInternalTrafficCookie=n.clearInternalTrafficCookie;exports.isInternalTrafficEnabled=n.isInternalTrafficEnabled;exports.setInternalTrafficCookie=n.setInternalTrafficCookie;exports.validateToken=n.validateToken;exports.InternalTrafficToggle=k.default;exports.store=x.store;exports.useAppDispatch=a.useAppDispatch;exports.useAppSelector=a.useAppSelector;exports.UPDATE=o.UPDATE;exports.initialState=o.initialState;exports.intlReducer=o.intlReducer;exports.updateIntl=o.updateIntl;exports.combineReducers=E.combineReducers;exports.englishTranslations=F;exports.frenchTranslations=M;exports.afrikaansTranslations=O;exports.amharicTranslations=b;exports.COUNTRY_OPTIONS=L.COUNTRY_OPTIONS;exports.decodeHtmlEntitiesToHtml=r.decodeHtmlEntitiesToHtml;exports.decodeHtmlEntitiesToText=r.decodeHtmlEntitiesToText;exports.stringToArray=r.stringToArray;exports.toBoolean=r.toBoolean;exports.toNumber=r.toNumber;exports.uriStringToArray=r.uriStringToArray;exports.Media=i.Media;exports.MediaContextProvider=i.MediaContextProvider;exports.mediaStyle=i.mediaStyle;exports.getUnhandledProps=e.getUnhandledProps;exports.htmlImageProps=e.htmlImageProps;exports.htmlInputAttrs=e.htmlInputAttrs;exports.htmlInputEvents=e.htmlInputEvents;exports.htmlInputProps=e.htmlInputProps;exports.partitionHTMLProps=e.partitionHTMLProps;exports.useKeyOnly=e.useKeyOnly;exports.useValueAndKey=e.useValueAndKey;exports.Provider=N.default;exports.IntlProvider=U.default;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),l=require("react"),f=require("react-router"),g=require("./internalTrafficUtils.js"),x=({token:c})=>{const[a]=f.useSearchParams(),d=f.useNavigate(),[e,s]=l.useState("validating"),[u,n]=l.useState("Processing...");l.useEffect(()=>{const o=a.get("enable"),v=a.get("k");if(!g.validateToken(v,c)){s("error"),n("Invalid or missing token. Access denied."),console.error("Invalid token provided for internal traffic toggle");return}if(o!=="0"&&o!=="1"){s("error"),n("Invalid enable parameter. Use ?enable=0 or ?enable=1"),console.error("Invalid enable parameter:",o);return}try{const r=o==="1";g.setInternalTrafficCookie(r),s("success"),n(r?"✓ Internal traffic enabled. GA4 events will be tagged as internal.":"✓ Internal traffic disabled. GA4 events will be tagged as external."),console.log(`Internal traffic ${r?"enabled":"disabled"} successfully`),setTimeout(()=>{d("/")},3e3)}catch(r){s("error"),n(`Error: ${r instanceof Error?r.message:"Unknown error"}`),console.error("Error setting internal traffic cookie:",r)}},[a,c,d]);const b={display:"flex",justifyContent:"center",alignItems:"center",minHeight:"100vh",fontFamily:'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'},i={textAlign:"center",padding:"2rem",borderRadius:"8px",boxShadow:"0 2px 8px rgba(0, 0, 0, 0.1)",maxWidth:"500px"},m=e==="success"?{...i,backgroundColor:"#f0f9ff",borderLeft:"4px solid #10b981"}:e==="error"?{...i,backgroundColor:"#fef2f2",borderLeft:"4px solid #ef4444"}:{...i,backgroundColor:"#f3f4f6",borderLeft:"4px solid #3b82f6"},p={fontSize:"1.5rem",fontWeight:"600",margin:"0 0 1rem 0",color:e==="success"?"#059669":e==="error"?"#dc2626":"#1f2937"},y={fontSize:"1rem",margin:"1rem 0",color:e==="success"?"#047857":e==="error"?"#991b1b":"#374151",lineHeight:"1.5"},S={fontSize:"0.875rem",color:"#6b7280",marginTop:"1.5rem",fontStyle:"italic"};return t.jsx("div",{style:b,children:t.jsxs("div",{style:m,children:[t.jsx("h1",{style:p,children:e==="success"?"Success":e==="error"?"Error":"Processing"}),t.jsx("p",{style:y,children:u}),e==="success"&&t.jsx("p",{style:S,children:"Redirecting to home page in 3 seconds..."})]})})};exports.default=x;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./withGoogleAnalytics.js");exports.withTracker=e.withTracker;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("./withGoogleAnalytics.js"),e=require("./internalTrafficUtils.js"),a=require("./InternalTrafficToggle.js");exports.withTracker=r.withTracker;exports.clearInternalTrafficCookie=e.clearInternalTrafficCookie;exports.isInternalTrafficEnabled=e.isInternalTrafficEnabled;exports.setInternalTrafficCookie=e.setInternalTrafficCookie;exports.validateToken=e.validateToken;exports.InternalTrafficToggle=a.default;
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o="_ga_internal_traffic",i=365*24*60*60,c=e=>{if(typeof document>"u")return;const t=e?"1":"0",n="/";document.cookie=`${o}=${t}; max-age=${i}; path=${n}; SameSite=Lax`,console.log(`Internal traffic cookie ${e?"enabled":"disabled"}`)},r=()=>{if(typeof document>"u")return!1;const e=document.cookie.split(";");for(const t of e){const[n,a]=t.trim().split("=");if(n===o)return a==="1"}return!1},f=()=>{typeof document>"u"||(document.cookie=`${o}=; max-age=0; path=/; SameSite=Lax`,console.log("Internal traffic cookie cleared"))},l=(e,t)=>e?e===t:!1;exports.clearInternalTrafficCookie=f;exports.isInternalTrafficEnabled=r;exports.setInternalTrafficCookie=c;exports.validateToken=l;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("react/jsx-runtime"),c=require("react"),i=require("react-ga4"),g=require("react-router"),C=require("../conf/index.js"),l=require("@devgateway/wp-react-lib"),d=(r,p={})=>a=>{var n;const e=c.useContext(l.SettingsContext)??{},t=((n=e==null?void 0:e.data)==null?void 0:n.google_analytics_code)??C.Config.GA_CODE;console.log("gaCode",t);const o=g.useLocation();return i.initialize(t??"#REACT_APP_GA_CODE#"),c.useEffect(()=>{if(t){const s=o.pathname;i.send({hitType:"pageview",page:s})}},[o.pathname]),u.jsx(r,{...a})};exports.withTracker=d;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const d=require("react/jsx-runtime"),t=require("react"),s=require("react-ga4"),p=require("react-router"),g=require("../conf/index.js"),C=require("@devgateway/wp-react-lib"),_=require("./internalTrafficUtils.js"),u=t.useRef(new Set),A=(f,R={})=>l=>{var c;const n=t.useContext(C.SettingsContext)??{},e=((c=n==null?void 0:n.data)==null?void 0:c.google_analytics_code)??g.Config.GA_CODE,r=p.useLocation(),i=t.useRef(!1);return t.useEffect(()=>{e&&e!=="#REACT_APP_GA_CODE#"&&!i.current&&(u.current.has(e)||(s.initialize(e),u.current.add(e),console.log("GA initialized with code:",e)),i.current=!0)},[e]),t.useEffect(()=>{if(e&&e!=="#REACT_APP_GA_CODE#"&&i.current){const o=r.pathname,a=_.isInternalTrafficEnabled()?"internal":"external";s.send({hitType:"pageview",page:o,traffic_type:a}),console.log("GA pageview sent:",{page:o,traffic_type:a})}},[r.pathname,e]),d.jsx(f,{...l})};exports.withTracker=A;
@@ -2,7 +2,8 @@ const _ = {
2
2
  REACT_APP_WP_API: process.env.VITE_REACT_APP_WP_API ?? "/wp/wp-json",
3
3
  REACT_APP_API_ROOT: process.env.VITE_REACT_APP_API_ROOT ?? null,
4
4
  GA_CODE: process.env.VITE_REACT_APP_GA_CODE ?? "",
5
- DEFAULT_LOCALE: process.env.VITE_REACT_APP_DEFAULT_LOCALE ?? "en"
5
+ DEFAULT_LOCALE: process.env.VITE_REACT_APP_DEFAULT_LOCALE ?? "en",
6
+ INTERNAL_GA_TOKEN: process.env.VITE_INTERNAL_GA_TOKEN ?? ""
6
7
  };
7
8
  export {
8
9
  _ as Config
@@ -1,52 +1,52 @@
1
1
  import { jsx as t, jsxs as c } from "react/jsx-runtime";
2
2
  import { PostProvider as p, PostConsumer as g, PostIntro as m } from "@devgateway/wp-react-lib";
3
3
  import { Container as f } from "semantic-ui-react";
4
- import { CarouselProvider as x, Slider as y, Slide as P, DotGroup as S } from "pure-react-carousel";
5
- const v = (r) => {
6
- let o = 0;
7
- const { posts: e, height: a, interval: s, autoSwitch: i } = r;
4
+ import { CarouselProvider as P, Slider as x, Slide as y, DotGroup as S } from "pure-react-carousel";
5
+ const v = (i) => {
6
+ let r = 0;
7
+ const { posts: e, height: o, interval: s, autoSwitch: a } = i;
8
8
  return (
9
9
  // @ts-ignore
10
10
  /* @__PURE__ */ c(
11
- x,
11
+ P,
12
12
  {
13
13
  interval: s,
14
- isPlaying: i,
14
+ isPlaying: a,
15
15
  totalSlides: e.length,
16
- naturalSlideHeight: a,
16
+ naturalSlideHeight: o,
17
17
  children: [
18
- /* @__PURE__ */ t(y, { style: { height: `${a}px` }, trayTag: "ul", children: e.map((l) => /* @__PURE__ */ t(P, { index: o++, tag: "li", children: /* @__PURE__ */ t(m, { post: l, fluid: !0 }) })) }),
18
+ /* @__PURE__ */ t(x, { trayTag: "ul", children: e.map((l) => /* @__PURE__ */ t(y, { index: r++, tag: "li", children: /* @__PURE__ */ t(m, { post: l, fluid: !0 }) })) }),
19
19
  /* @__PURE__ */ t(S, {})
20
20
  ]
21
21
  }
22
22
  )
23
23
  );
24
- }, _ = (r) => {
24
+ }, $ = (i) => {
25
25
  const {
26
- "data-type": o,
26
+ "data-type": r,
27
27
  "data-taxonomy": e,
28
- "data-categories": a,
28
+ "data-categories": o,
29
29
  "data-items": s,
30
- "data-height": i,
30
+ "data-height": a,
31
31
  "data-auto-switch": l = "false",
32
32
  "data-interval": n = 1e4,
33
33
  editing: d,
34
34
  parent: u,
35
35
  unique: h
36
- } = r;
37
- return /* @__PURE__ */ t(f, { style: { height: `${i}px` }, className: `viz post carousel ${d ? "editing" : ""}`, fluid: !0, children: /* @__PURE__ */ t(
36
+ } = i;
37
+ return /* @__PURE__ */ t(f, { style: { height: `${a}px` }, className: `viz post carousel ${d ? "editing" : ""}`, fluid: !0, children: /* @__PURE__ */ t(
38
38
  p,
39
39
  {
40
- type: o,
40
+ type: r,
41
41
  taxonomy: e,
42
- categories: a,
42
+ categories: o,
43
43
  store: "carousel_" + u + "_" + h,
44
44
  page: 1,
45
45
  perPage: s,
46
- children: /* @__PURE__ */ t(g, { children: /* @__PURE__ */ t(v, { height: i, interval: n, autoSwitch: l == "true" }) })
46
+ children: /* @__PURE__ */ t(g, { children: /* @__PURE__ */ t(v, { height: a, interval: n, autoSwitch: l == "true" }) })
47
47
  }
48
48
  ) });
49
49
  };
50
50
  export {
51
- _ as default
51
+ $ as default
52
52
  };
package/dist/esm/index.js CHANGED
@@ -1,18 +1,18 @@
1
- import { components as p, customizer as f, getComponentByNameIgnoreCase as m, reducers as n } from "./embeddable/index.js";
1
+ import { components as n, customizer as s, getComponentByNameIgnoreCase as p, reducers as m } from "./embeddable/index.js";
2
2
  import { Config as l } from "./conf/index.js";
3
3
  import { default as u } from "./layout/ResponsiveContainer.js";
4
4
  import { default as c } from "./layout/ScrollTop.js";
5
5
  import { default as C } from "./layout/containers/PreviewPageContainer.js";
6
6
  import { default as P } from "./layout/containers/PreviewTypeContainer.js";
7
7
  import { default as h } from "./layout/containers/SlugContainer.js";
8
- import { default as y } from "./layout/containers/SlugPostContainer.js";
8
+ import { default as v } from "./layout/containers/SlugPostContainer.js";
9
9
  import { CustomizerWrapper as A } from "./layout/Customizer.js";
10
10
  import { default as R } from "./layout/Layout.js";
11
- import { default as F } from "./layout/PreviewComponent.js";
12
- import { default as L } from "./layout/Favicon.js";
13
- import { default as N } from "./layout/SSRFavicon.js";
14
- import { default as D } from "./layout/Loading.js";
15
- import { default as b } from "./layout/CustomSemanticSearch.js";
11
+ import { default as w } from "./layout/PreviewComponent.js";
12
+ import { default as F } from "./layout/Favicon.js";
13
+ import { default as M } from "./layout/SSRFavicon.js";
14
+ import { default as O } from "./layout/Loading.js";
15
+ import { default as D } from "./layout/CustomSemanticSearch.js";
16
16
  import { default as z } from "./layout/Header.js";
17
17
  import { default as K } from "./layout/SearchControl.js";
18
18
  import { default as V } from "./layout/LangSwitcher.js";
@@ -21,77 +21,84 @@ import { default as q } from "./layout/ClassicHeader.js";
21
21
  import { default as J } from "./layout/FlexWrapDetector.js";
22
22
  import { default as X } from "./layout/FloatingMenuHeader.js";
23
23
  import { withTracker as $ } from "./tracker/withGoogleAnalytics.js";
24
- import { store as re } from "./redux/store.js";
25
- import { useAppDispatch as te, useAppSelector as ae } from "./redux/hooks.js";
26
- import { UPDATE as pe, initialState as fe, intlReducer as me, updateIntl as ne } from "./lib/react-intl-redux/index.js";
27
- import { combineReducers as le } from "./lib/redux-immutable/index.js";
24
+ import { clearInternalTrafficCookie as re, isInternalTrafficEnabled as oe, setInternalTrafficCookie as te, validateToken as ae } from "./tracker/internalTrafficUtils.js";
25
+ import { default as ne } from "./tracker/InternalTrafficToggle.js";
26
+ import { store as pe } from "./redux/store.js";
27
+ import { useAppDispatch as ie, useAppSelector as le } from "./redux/hooks.js";
28
+ import { UPDATE as ue, initialState as xe, intlReducer as ce, updateIntl as Te } from "./lib/react-intl-redux/index.js";
29
+ import { combineReducers as ge } from "./lib/redux-immutable/index.js";
28
30
  import * as e from "./translations/en.json.js";
29
31
  import * as r from "./translations/fr.json.js";
30
32
  import * as o from "./translations/af.json.js";
31
33
  import * as t from "./translations/am.json.js";
32
- import { COUNTRY_OPTIONS as ue } from "./countries.js";
33
- import { decodeHtmlEntitiesToHtml as ce, decodeHtmlEntitiesToText as Te, stringToArray as Ce, toBoolean as ge, toNumber as Pe, uriStringToArray as Se } from "./utils/data.js";
34
- import { Media as ve, MediaContextProvider as ye, mediaStyle as Ie } from "./utils/AppMedia.js";
35
- import { getUnhandledProps as He, htmlImageProps as Re, htmlInputAttrs as we, htmlInputEvents as Fe, htmlInputProps as Ee, partitionHTMLProps as Le, useKeyOnly as Me, useValueAndKey as Ne } from "./utils/semanticUtils.js";
36
- import { default as De } from "./lib/react-intl-redux/providers/Provider.js";
37
- import { default as be } from "./lib/react-intl-redux/providers/IntlProvider.js";
34
+ import { COUNTRY_OPTIONS as Se } from "./countries.js";
35
+ import { decodeHtmlEntitiesToHtml as Ie, decodeHtmlEntitiesToText as ve, stringToArray as ye, toBoolean as Ae, toNumber as He, uriStringToArray as Re } from "./utils/data.js";
36
+ import { Media as we, MediaContextProvider as Ee, mediaStyle as Fe } from "./utils/AppMedia.js";
37
+ import { getUnhandledProps as Me, htmlImageProps as Ne, htmlInputAttrs as Oe, htmlInputEvents as be, htmlInputProps as De, partitionHTMLProps as Ue, useKeyOnly as ze, useValueAndKey as Be } from "./utils/semanticUtils.js";
38
+ import { default as We } from "./lib/react-intl-redux/providers/Provider.js";
39
+ import { default as Ye } from "./lib/react-intl-redux/providers/IntlProvider.js";
38
40
  export {
39
- ue as COUNTRY_OPTIONS,
41
+ Se as COUNTRY_OPTIONS,
40
42
  q as ClassicHeader,
41
43
  l as Config,
42
- b as CustomSemanticSearch,
44
+ D as CustomSemanticSearch,
43
45
  A as CustomizerWrapper,
44
- L as Favicon,
46
+ F as Favicon,
45
47
  J as FlexWrapDetector,
46
48
  X as FloatingMenuHeader,
47
49
  _ as Footer,
48
50
  z as Header,
49
- be as IntlProvider,
51
+ ne as InternalTrafficToggle,
52
+ Ye as IntlProvider,
50
53
  V as LangSwitcher,
51
- D as Loading,
52
- ve as Media,
53
- ye as MediaContextProvider,
54
- F as PreviewComponent,
54
+ O as Loading,
55
+ we as Media,
56
+ Ee as MediaContextProvider,
57
+ w as PreviewComponent,
55
58
  C as PreviewPageContainer,
56
59
  P as PreviewTypeContainer,
57
- De as Provider,
60
+ We as Provider,
58
61
  u as ResponsiveContainer,
59
62
  R as RootLayout,
60
- N as SSRFavicon,
63
+ M as SSRFavicon,
61
64
  c as ScrollToTop,
62
65
  K as SearchControl,
63
66
  h as SlugContainer,
64
- y as SlugPostContainer,
65
- pe as UPDATE,
67
+ v as SlugPostContainer,
68
+ ue as UPDATE,
66
69
  o as afrikaansTranslations,
67
70
  t as amharicTranslations,
68
- le as combineReducers,
69
- p as components,
70
- f as customizer,
71
- ce as decodeHtmlEntitiesToHtml,
72
- Te as decodeHtmlEntitiesToText,
71
+ re as clearInternalTrafficCookie,
72
+ ge as combineReducers,
73
+ n as components,
74
+ s as customizer,
75
+ Ie as decodeHtmlEntitiesToHtml,
76
+ ve as decodeHtmlEntitiesToText,
73
77
  e as englishTranslations,
74
78
  r as frenchTranslations,
75
- m as getComponentByNameIgnoreCase,
76
- He as getUnhandledProps,
77
- Re as htmlImageProps,
78
- we as htmlInputAttrs,
79
- Fe as htmlInputEvents,
80
- Ee as htmlInputProps,
81
- fe as initialState,
82
- me as intlReducer,
83
- Ie as mediaStyle,
84
- Le as partitionHTMLProps,
85
- n as reducers,
86
- re as store,
87
- Ce as stringToArray,
88
- ge as toBoolean,
89
- Pe as toNumber,
90
- ne as updateIntl,
91
- Se as uriStringToArray,
92
- te as useAppDispatch,
93
- ae as useAppSelector,
94
- Me as useKeyOnly,
95
- Ne as useValueAndKey,
79
+ p as getComponentByNameIgnoreCase,
80
+ Me as getUnhandledProps,
81
+ Ne as htmlImageProps,
82
+ Oe as htmlInputAttrs,
83
+ be as htmlInputEvents,
84
+ De as htmlInputProps,
85
+ xe as initialState,
86
+ ce as intlReducer,
87
+ oe as isInternalTrafficEnabled,
88
+ Fe as mediaStyle,
89
+ Ue as partitionHTMLProps,
90
+ m as reducers,
91
+ te as setInternalTrafficCookie,
92
+ pe as store,
93
+ ye as stringToArray,
94
+ Ae as toBoolean,
95
+ He as toNumber,
96
+ Te as updateIntl,
97
+ Re as uriStringToArray,
98
+ ie as useAppDispatch,
99
+ le as useAppSelector,
100
+ ze as useKeyOnly,
101
+ Be as useValueAndKey,
102
+ ae as validateToken,
96
103
  $ as withTracker
97
104
  };
@@ -0,0 +1,76 @@
1
+ import { jsx as n, jsxs as u } from "react/jsx-runtime";
2
+ import { useState as d, useEffect as p } from "react";
3
+ import { useSearchParams as y, useNavigate as S } from "react-router";
4
+ import { validateToken as h, setInternalTrafficCookie as v } from "./internalTrafficUtils.js";
5
+ const w = ({ token: l }) => {
6
+ const [a] = y(), c = S(), [e, s] = d("validating"), [f, t] = d("Processing...");
7
+ p(() => {
8
+ const o = a.get("enable"), b = a.get("k");
9
+ if (!h(b, l)) {
10
+ s("error"), t("Invalid or missing token. Access denied."), console.error("Invalid token provided for internal traffic toggle");
11
+ return;
12
+ }
13
+ if (o !== "0" && o !== "1") {
14
+ s("error"), t("Invalid enable parameter. Use ?enable=0 or ?enable=1"), console.error("Invalid enable parameter:", o);
15
+ return;
16
+ }
17
+ try {
18
+ const r = o === "1";
19
+ v(r), s("success"), t(
20
+ r ? "✓ Internal traffic enabled. GA4 events will be tagged as internal." : "✓ Internal traffic disabled. GA4 events will be tagged as external."
21
+ ), console.log(`Internal traffic ${r ? "enabled" : "disabled"} successfully`), setTimeout(() => {
22
+ c("/");
23
+ }, 3e3);
24
+ } catch (r) {
25
+ s("error"), t(`Error: ${r instanceof Error ? r.message : "Unknown error"}`), console.error("Error setting internal traffic cookie:", r);
26
+ }
27
+ }, [a, l, c]);
28
+ const g = {
29
+ display: "flex",
30
+ justifyContent: "center",
31
+ alignItems: "center",
32
+ minHeight: "100vh",
33
+ fontFamily: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif'
34
+ }, i = {
35
+ textAlign: "center",
36
+ padding: "2rem",
37
+ borderRadius: "8px",
38
+ boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)",
39
+ maxWidth: "500px"
40
+ }, m = e === "success" ? {
41
+ ...i,
42
+ backgroundColor: "#f0f9ff",
43
+ borderLeft: "4px solid #10b981"
44
+ } : e === "error" ? {
45
+ ...i,
46
+ backgroundColor: "#fef2f2",
47
+ borderLeft: "4px solid #ef4444"
48
+ } : {
49
+ ...i,
50
+ backgroundColor: "#f3f4f6",
51
+ borderLeft: "4px solid #3b82f6"
52
+ };
53
+ return /* @__PURE__ */ n("div", { style: g, children: /* @__PURE__ */ u("div", { style: m, children: [
54
+ /* @__PURE__ */ n("h1", { style: {
55
+ fontSize: "1.5rem",
56
+ fontWeight: "600",
57
+ margin: "0 0 1rem 0",
58
+ color: e === "success" ? "#059669" : e === "error" ? "#dc2626" : "#1f2937"
59
+ }, children: e === "success" ? "Success" : e === "error" ? "Error" : "Processing" }),
60
+ /* @__PURE__ */ n("p", { style: {
61
+ fontSize: "1rem",
62
+ margin: "1rem 0",
63
+ color: e === "success" ? "#047857" : e === "error" ? "#991b1b" : "#374151",
64
+ lineHeight: "1.5"
65
+ }, children: f }),
66
+ e === "success" && /* @__PURE__ */ n("p", { style: {
67
+ fontSize: "0.875rem",
68
+ color: "#6b7280",
69
+ marginTop: "1.5rem",
70
+ fontStyle: "italic"
71
+ }, children: "Redirecting to home page in 3 seconds..." })
72
+ ] }) });
73
+ };
74
+ export {
75
+ w as default
76
+ };
@@ -1,4 +1,11 @@
1
- import { withTracker as o } from "./withGoogleAnalytics.js";
1
+ import { withTracker as a } from "./withGoogleAnalytics.js";
2
+ import { clearInternalTrafficCookie as o, isInternalTrafficEnabled as t, setInternalTrafficCookie as n, validateToken as i } from "./internalTrafficUtils.js";
3
+ import { default as T } from "./InternalTrafficToggle.js";
2
4
  export {
3
- o as withTracker
5
+ T as InternalTrafficToggle,
6
+ o as clearInternalTrafficCookie,
7
+ t as isInternalTrafficEnabled,
8
+ n as setInternalTrafficCookie,
9
+ i as validateToken,
10
+ a as withTracker
4
11
  };
@@ -0,0 +1,23 @@
1
+ const o = "_ga_internal_traffic";
2
+ const c = (e) => {
3
+ if (typeof document > "u") return;
4
+ const t = e ? "1" : "0", n = "/";
5
+ document.cookie = `${o}=${t}; max-age=31536000; path=${n}; SameSite=Lax`, console.log(`Internal traffic cookie ${e ? "enabled" : "disabled"}`);
6
+ }, i = () => {
7
+ if (typeof document > "u") return !1;
8
+ const e = document.cookie.split(";");
9
+ for (const t of e) {
10
+ const [n, a] = t.trim().split("=");
11
+ if (n === o)
12
+ return a === "1";
13
+ }
14
+ return !1;
15
+ }, r = () => {
16
+ typeof document > "u" || (document.cookie = `${o}=; max-age=0; path=/; SameSite=Lax`, console.log("Internal traffic cookie cleared"));
17
+ }, f = (e, t) => e ? e === t : !1;
18
+ export {
19
+ r as clearInternalTrafficCookie,
20
+ i as isInternalTrafficEnabled,
21
+ c as setInternalTrafficCookie,
22
+ f as validateToken
23
+ };
@@ -1,21 +1,26 @@
1
- import { jsx as m } from "react/jsx-runtime";
2
- import p, { useEffect as s } from "react";
3
- import i from "react-ga4";
4
- import { useLocation as f } from "react-router";
5
- import { Config as C } from "../conf/index.js";
6
- import { SettingsContext as g } from "@devgateway/wp-react-lib";
7
- const O = (r, l = {}) => (a) => {
1
+ import { jsx as u } from "react/jsx-runtime";
2
+ import C, { useRef as p, useEffect as c } from "react";
3
+ import f from "react-ga4";
4
+ import { useLocation as _ } from "react-router";
5
+ import { Config as d } from "../conf/index.js";
6
+ import { SettingsContext as A } from "@devgateway/wp-react-lib";
7
+ import { isInternalTrafficEnabled as g } from "./internalTrafficUtils.js";
8
+ const s = p(/* @__PURE__ */ new Set()), z = (l, h = {}) => (m) => {
8
9
  var n;
9
- const o = p.useContext(g) ?? {}, t = ((n = o == null ? void 0 : o.data) == null ? void 0 : n.google_analytics_code) ?? C.GA_CODE;
10
- console.log("gaCode", t);
11
- const e = f();
12
- return i.initialize(t ?? "#REACT_APP_GA_CODE#"), s(() => {
13
- if (t) {
14
- const c = e.pathname;
15
- i.send({ hitType: "pageview", page: c });
10
+ const e = C.useContext(A) ?? {}, t = ((n = e == null ? void 0 : e.data) == null ? void 0 : n.google_analytics_code) ?? d.GA_CODE, i = _(), o = p(!1);
11
+ return c(() => {
12
+ t && t !== "#REACT_APP_GA_CODE#" && !o.current && (s.current.has(t) || (f.initialize(t), s.current.add(t), console.log("GA initialized with code:", t)), o.current = !0);
13
+ }, [t]), c(() => {
14
+ if (t && t !== "#REACT_APP_GA_CODE#" && o.current) {
15
+ const r = i.pathname, a = g() ? "internal" : "external";
16
+ f.send({
17
+ hitType: "pageview",
18
+ page: r,
19
+ traffic_type: a
20
+ }), console.log("GA pageview sent:", { page: r, traffic_type: a });
16
21
  }
17
- }, [e.pathname]), /* @__PURE__ */ m(r, { ...a });
22
+ }, [i.pathname, t]), /* @__PURE__ */ u(l, { ...m });
18
23
  };
19
24
  export {
20
- O as withTracker
25
+ z as withTracker
21
26
  };
@@ -3,4 +3,5 @@ export declare const Config: {
3
3
  REACT_APP_API_ROOT: any;
4
4
  GA_CODE: any;
5
5
  DEFAULT_LOCALE: any;
6
+ INTERNAL_GA_TOKEN: any;
6
7
  };
@@ -0,0 +1,6 @@
1
+ import { default as React } from 'react';
2
+ interface InternalTrafficToggleProps {
3
+ token: string;
4
+ }
5
+ declare const InternalTrafficToggle: React.FC<InternalTrafficToggleProps>;
6
+ export default InternalTrafficToggle;
@@ -1 +1,3 @@
1
1
  export * from './withGoogleAnalytics';
2
+ export * from './internalTrafficUtils';
3
+ export { default as InternalTrafficToggle } from './InternalTrafficToggle';
@@ -0,0 +1,24 @@
1
+ /**
2
+ * Utility functions for managing internal traffic detection via first-party cookies
3
+ */
4
+ /**
5
+ * Set a first-party cookie to mark this session as internal traffic
6
+ * @param enable - Whether to enable (true) or disable (false) internal traffic tracking
7
+ */
8
+ export declare const setInternalTrafficCookie: (enable: boolean) => void;
9
+ /**
10
+ * Check if internal traffic cookie is enabled
11
+ * @returns true if the internal traffic cookie is set to '1', false otherwise
12
+ */
13
+ export declare const isInternalTrafficEnabled: () => boolean;
14
+ /**
15
+ * Clear the internal traffic cookie
16
+ */
17
+ export declare const clearInternalTrafficCookie: () => void;
18
+ /**
19
+ * Validate the token against the expected value
20
+ * @param providedToken - The token from query params
21
+ * @param expectedToken - The expected token from environment
22
+ * @returns true if tokens match, false otherwise
23
+ */
24
+ export declare const validateToken: (providedToken: string | null, expectedToken: string) => boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@devgateway/dvz-ui-react",
3
- "version": "1.6.11",
3
+ "version": "1.6.13",
4
4
  "main": "dist/cjs/index.js",
5
5
  "module": "dist/esm/index.js",
6
6
  "types": "dist/types/index.d.ts",