@levo-so/react 0.1.26 → 0.1.27

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
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/audience/components/page.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAOnD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC;CACvC,CAsKA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../src/audience/components/page.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAOnD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC;CACvC,CAuLA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -1,4 +1,4 @@
1
- import { L as e, a, b as n } from "../page-D-1JUzts.js";
1
+ import { L as e, a, b as n } from "../page-DgYcBSCH.js";
2
2
  export {
3
3
  e as LevoInsightsBlock,
4
4
  a as LevoInsightsComponent,
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { L as s, u as o } from "./LevoProvider-BAZy7_tP.js";
2
- import { L as t, a as r, b as l } from "./page-D-1JUzts.js";
2
+ import { L as t, a as r, b as l } from "./page-DgYcBSCH.js";
3
3
  import { C as m, F as p, x as d, y as g, m as T, r as f, j as u, n as c, e as x, b, c as D, f as y, g as F, d as v, k as h, o as L, i as M, a as E, w as P, t as B, p as C, h as O, s as V, u as j, v as I, l as S, q as K } from "./CollectionFormBuilder-DxViQE0w.js";
4
4
  import { LevoOAuth as U } from "./membership/index.js";
5
5
  import { B as H, D as N, j as q, e as w, i as z, g as A, f as R, c as G, a as J, h as Q, d as X, k as Y, S as Z, T as _, n as $, l as aa, m as ea, b as sa } from "./Spinner-CDMNP44S.js";
@@ -1,6 +1,6 @@
1
1
  "use client";
2
2
  import { j as W } from "./jsx-runtime-B6kdoens.js";
3
- import { useEffect as d, useState as E } from "react";
3
+ import { useEffect as g, useState as E } from "react";
4
4
  import { useInView as G } from "react-intersection-observer";
5
5
  import { u as _ } from "./LevoProvider-BAZy7_tP.js";
6
6
  import { usePageLifecycle as F, LifecycleState as k } from "use-page-lifecycle";
@@ -8,7 +8,7 @@ const Oe = ({ id: e, properties: r = {} }) => {
8
8
  const { audience: t } = _(), { ref: n, inView: o } = G({
9
9
  triggerOnce: !0
10
10
  });
11
- return d(() => {
11
+ return g(() => {
12
12
  t != null && t.instance && o && (t == null || t.track("block.view", {
13
13
  ...r,
14
14
  resource: "block",
@@ -17,11 +17,11 @@ const Oe = ({ id: e, properties: r = {} }) => {
17
17
  }, [o]), /* @__PURE__ */ W.jsx("div", { ref: n, style: { height: "0px" } });
18
18
  }, Ie = ({ event: e, properties: r }) => {
19
19
  const { audience: t } = _();
20
- return d(() => {
20
+ return g(() => {
21
21
  t != null && t.instance && (t == null || t.track(e, r));
22
22
  }, [t == null ? void 0 : t.instance, e, r]), null;
23
23
  };
24
- function A(e) {
24
+ function x(e) {
25
25
  var r = typeof e;
26
26
  return e != null && (r == "object" || r == "function");
27
27
  }
@@ -37,7 +37,7 @@ var z = /^\s+/;
37
37
  function X(e) {
38
38
  return e && e.slice(0, V(e) + 1).replace(z, "");
39
39
  }
40
- var O = $.Symbol, H = Object.prototype, Z = H.hasOwnProperty, q = H.toString, S = O ? O.toStringTag : void 0;
40
+ var L = $.Symbol, H = Object.prototype, Z = H.hasOwnProperty, q = H.toString, S = L ? L.toStringTag : void 0;
41
41
  function Q(e) {
42
42
  var r = Z.call(e, S), t = e[S];
43
43
  try {
@@ -52,7 +52,7 @@ var ee = Object.prototype, te = ee.toString;
52
52
  function ne(e) {
53
53
  return te.call(e);
54
54
  }
55
- var re = "[object Null]", oe = "[object Undefined]", R = O ? O.toStringTag : void 0;
55
+ var re = "[object Null]", oe = "[object Undefined]", R = L ? L.toStringTag : void 0;
56
56
  function ie(e) {
57
57
  return e == null ? e === void 0 ? oe : re : R && R in Object(e) ? Q(e) : ne(e);
58
58
  }
@@ -63,67 +63,67 @@ var ae = "[object Symbol]";
63
63
  function ce(e) {
64
64
  return typeof e == "symbol" || se(e) && ie(e) == ae;
65
65
  }
66
- var D = NaN, fe = /^[-+]0x[0-9a-f]+$/i, le = /^0b[01]+$/i, ue = /^0o[0-7]+$/i, de = parseInt;
66
+ var D = NaN, le = /^[-+]0x[0-9a-f]+$/i, fe = /^0b[01]+$/i, ue = /^0o[0-7]+$/i, de = parseInt;
67
67
  function U(e) {
68
68
  if (typeof e == "number")
69
69
  return e;
70
70
  if (ce(e))
71
71
  return D;
72
- if (A(e)) {
72
+ if (x(e)) {
73
73
  var r = typeof e.valueOf == "function" ? e.valueOf() : e;
74
- e = A(r) ? r + "" : r;
74
+ e = x(r) ? r + "" : r;
75
75
  }
76
76
  if (typeof e != "string")
77
77
  return e === 0 ? e : +e;
78
78
  e = X(e);
79
- var t = le.test(e);
80
- return t || ue.test(e) ? de(e.slice(2), t ? 2 : 8) : fe.test(e) ? D : +e;
79
+ var t = fe.test(e);
80
+ return t || ue.test(e) ? de(e.slice(2), t ? 2 : 8) : le.test(e) ? D : +e;
81
81
  }
82
82
  var ge = "Expected a function", me = Math.max, be = Math.min;
83
83
  function he(e, r, t) {
84
- var n, o, i, f, a, c, l = 0, m = !1, b = !1, T = !0;
84
+ var n, o, i, f, a, l, u = 0, b = !1, h = !1, v = !0;
85
85
  if (typeof e != "function")
86
86
  throw new TypeError(ge);
87
- r = U(r) || 0, A(t) && (m = !!t.leading, b = "maxWait" in t, i = b ? me(U(t.maxWait) || 0, r) : i, T = "trailing" in t ? !!t.trailing : T);
88
- function g(s) {
89
- var h = n, w = o;
90
- return n = o = void 0, l = s, f = e.apply(w, h), f;
87
+ r = U(r) || 0, x(t) && (b = !!t.leading, h = "maxWait" in t, i = h ? me(U(t.maxWait) || 0, r) : i, v = "trailing" in t ? !!t.trailing : v);
88
+ function d(s) {
89
+ var p = n, w = o;
90
+ return n = o = void 0, u = s, f = e.apply(w, p), f;
91
91
  }
92
- function p(s) {
93
- return l = s, a = setTimeout(L, r), m ? g(s) : f;
92
+ function T(s) {
93
+ return u = s, a = setTimeout(c, r), b ? d(s) : f;
94
94
  }
95
- function v(s) {
96
- var h = s - c, w = s - l, N = r - h;
97
- return b ? be(N, i - w) : N;
95
+ function O(s) {
96
+ var p = s - l, w = s - u, N = r - p;
97
+ return h ? be(N, i - w) : N;
98
98
  }
99
- function u(s) {
100
- var h = s - c, w = s - l;
101
- return c === void 0 || h >= r || h < 0 || b && w >= i;
99
+ function m(s) {
100
+ var p = s - l, w = s - u;
101
+ return l === void 0 || p >= r || p < 0 || h && w >= i;
102
102
  }
103
- function L() {
103
+ function c() {
104
104
  var s = j();
105
- if (u(s))
105
+ if (m(s))
106
106
  return C(s);
107
- a = setTimeout(L, v(s));
107
+ a = setTimeout(c, O(s));
108
108
  }
109
109
  function C(s) {
110
- return a = void 0, T && n ? g(s) : (n = o = void 0, f);
110
+ return a = void 0, v && n ? d(s) : (n = o = void 0, f);
111
111
  }
112
112
  function M() {
113
- a !== void 0 && clearTimeout(a), l = 0, n = c = o = a = void 0;
113
+ a !== void 0 && clearTimeout(a), u = 0, n = l = o = a = void 0;
114
114
  }
115
115
  function P() {
116
116
  return a === void 0 ? f : C(j());
117
117
  }
118
118
  function I() {
119
- var s = j(), h = u(s);
120
- if (n = arguments, o = this, c = s, h) {
119
+ var s = j(), p = m(s);
120
+ if (n = arguments, o = this, l = s, p) {
121
121
  if (a === void 0)
122
- return p(c);
123
- if (b)
124
- return clearTimeout(a), a = setTimeout(L, r), g(c);
122
+ return T(l);
123
+ if (h)
124
+ return clearTimeout(a), a = setTimeout(c, r), d(l);
125
125
  }
126
- return a === void 0 && (a = setTimeout(L, r)), f;
126
+ return a === void 0 && (a = setTimeout(c, r)), f;
127
127
  }
128
128
  return I.cancel = M, I.flush = P, I;
129
129
  }
@@ -131,18 +131,18 @@ const pe = () => {
131
131
  const [e, r] = E(0), [t, n] = E(0), o = he((i) => {
132
132
  n(i), r(i);
133
133
  }, 250);
134
- return d(() => {
134
+ return g(() => {
135
135
  const i = () => {
136
- const f = window.scrollY, a = document.documentElement.scrollHeight, c = window.innerHeight, l = Math.round(
137
- f / (a - c) * 100
136
+ const f = window.scrollY, a = document.documentElement.scrollHeight, l = window.innerHeight, u = Math.round(
137
+ f / (a - l) * 100
138
138
  );
139
- l % 10 === 0 && l > t && o(l);
139
+ u % 10 === 0 && u > t && o(u);
140
140
  };
141
141
  return window.addEventListener("scroll", i), () => window.removeEventListener("scroll", i);
142
142
  }, [t]), e;
143
143
  }, y = "lv_insights_ot", Te = () => {
144
144
  const [e, r] = E(0);
145
- return d(() => {
145
+ return g(() => {
146
146
  const t = Number(localStorage.getItem(y)) || 0;
147
147
  r(t), localStorage.setItem(y, (t + 1).toString());
148
148
  const n = (i) => {
@@ -157,15 +157,15 @@ const pe = () => {
157
157
  window.removeEventListener("storage", n), window.removeEventListener("beforeunload", o);
158
158
  };
159
159
  }, []), e;
160
- }, B = "lv_insights_ct", x = "lv_insights_at", ve = () => {
160
+ }, B = "lv_insights_ct", A = "lv_insights_at", ve = () => {
161
161
  const [e, r] = E(null);
162
- return d(() => {
162
+ return g(() => {
163
163
  let t = sessionStorage.getItem(B);
164
164
  const n = JSON.parse(
165
- localStorage.getItem(x) || "[]"
165
+ localStorage.getItem(A) || "[]"
166
166
  );
167
167
  t && n.includes(t) && (t = null), t || (t = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(B, t)), n.includes(t) || (n.push(t), localStorage.setItem(
168
- x,
168
+ A,
169
169
  JSON.stringify(n)
170
170
  )), r(t);
171
171
  const o = () => {
@@ -173,7 +173,7 @@ const pe = () => {
173
173
  (f) => f !== t
174
174
  );
175
175
  localStorage.setItem(
176
- x,
176
+ A,
177
177
  JSON.stringify(i)
178
178
  );
179
179
  };
@@ -183,33 +183,33 @@ const pe = () => {
183
183
  }, []), e;
184
184
  }, ke = ({ id: e, properties: r = {} }) => {
185
185
  const { client: t, audience: n } = _(), [o, i] = E(), f = pe(), a = typeof window < "u" ? window.location.href : void 0;
186
- Te(), ve(), d(() => {
186
+ Te(), ve(), g(() => {
187
187
  a && i(a);
188
- }, [a]), d(() => {
188
+ }, [a]), g(() => {
189
189
  n != null && n.instance && f > 0 && n.track("page.scroll", {
190
190
  resource: "page",
191
191
  identifier: e,
192
192
  percent: f
193
193
  });
194
- }, [n == null ? void 0 : n.instance, f, e]), d(() => {
195
- const m = () => {
196
- n == null || n.bounce({
194
+ }, [n == null ? void 0 : n.instance, f, e]), g(() => {
195
+ const b = () => {
196
+ n == null || n.track("page.bounce", {
197
197
  resource: "page",
198
198
  identifier: e
199
199
  });
200
200
  };
201
- return window && window.addEventListener("beforeunload", m), () => {
202
- window && window.removeEventListener("beforeunload", m);
201
+ return window && window.addEventListener("beforeunload", b), () => {
202
+ window && window.removeEventListener("beforeunload", b);
203
203
  };
204
204
  }, [n, e]);
205
- const [c] = F();
206
- d(() => {
207
- (c === k.TERMINATED || c === k.HIDDEN || c === k.FROZEN) && (n == null || n.bounce({
205
+ const [l] = F();
206
+ g(() => {
207
+ (l === k.TERMINATED || l === k.HIDDEN || l === k.FROZEN) && (n == null || n.track("page.bounce", {
208
208
  resource: "page",
209
209
  identifier: e,
210
- state: c
210
+ state: l
211
211
  }));
212
- }, [c, n, e]), d(() => {
212
+ }, [l, n, e]), g(() => {
213
213
  (() => {
214
214
  t != null && t.insightsUrl && t.workspace && o && (n != null && n.instance ? n.instance.page({
215
215
  resource: "page",
@@ -220,42 +220,47 @@ const pe = () => {
220
220
  }));
221
221
  })();
222
222
  }, [t == null ? void 0 : t.insightsUrl, t == null ? void 0 : t.workspace, o]);
223
- let l = !1;
224
- return d(() => {
225
- const m = (b) => {
226
- if (l)
223
+ let u = !1;
224
+ return g(() => {
225
+ const b = (h) => {
226
+ if (u)
227
227
  return;
228
- if (l = !0, b.target instanceof HTMLElement) {
229
- const g = b.target;
230
- let p = "";
228
+ if (u = !0, h.target instanceof HTMLElement) {
229
+ const d = h.target;
230
+ let T = "";
231
231
  try {
232
- if (p = g == null ? void 0 : g.getAttribute("href"), !p) {
233
- let v = 0, u = g.parentNode;
234
- for (; u && v < 10; ) {
235
- if (u != null && u.getAttribute("href")) {
236
- p = u == null ? void 0 : u.getAttribute("href");
232
+ if (T = d == null ? void 0 : d.getAttribute("href"), !T) {
233
+ let m = 0, c = d.parentNode;
234
+ for (; c && m < 10; ) {
235
+ if (c != null && c.getAttribute("href")) {
236
+ T = c == null ? void 0 : c.getAttribute("href");
237
237
  break;
238
238
  }
239
- u = u.parentNode, v++;
239
+ c = c.parentNode, m++;
240
240
  }
241
241
  }
242
242
  } catch {
243
243
  }
244
+ const O = Array.from(d.attributes).reduce(
245
+ (m, c) => (["class"].includes(c.name) || (m[c.name] = c.value), m),
246
+ {}
247
+ );
244
248
  n == null || n.track("page.click", {
245
- element: g.tagName,
246
- text: g.innerText,
247
- href: p || void 0
249
+ element: d.tagName,
250
+ text: d.innerText,
251
+ href: T || void 0,
252
+ attributes: O
248
253
  });
249
254
  }
250
- const T = setTimeout(() => {
251
- l = !1;
255
+ const v = setTimeout(() => {
256
+ u = !1;
252
257
  }, 0);
253
258
  return () => {
254
- clearTimeout(T);
259
+ clearTimeout(v);
255
260
  };
256
261
  };
257
- return document.addEventListener("click", m), () => {
258
- document.removeEventListener("click", m);
262
+ return document.addEventListener("click", b), () => {
263
+ document.removeEventListener("click", b);
259
264
  };
260
265
  }, [n]), (!(t != null && t.insightsUrl) || !t.workspace || !t.workspace.startsWith("W")) && console.error(
261
266
  "[@levo-so/audience] The utility could not be initialized, due to missing workspace, or endpoint for insights."
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/react",
3
- "version": "0.1.26",
3
+ "version": "0.1.27",
4
4
  "author": "Levo Engineering <devs@theinternetfolks.com>",
5
5
  "description": "Levo suite for React based applications",
6
6
  "type": "module",
@@ -16,7 +16,7 @@
16
16
  "peerDependencies": {
17
17
  "react": ">=18",
18
18
  "react-dom": ">=18",
19
- "@levo-so/core": "0.1.26"
19
+ "@levo-so/core": "0.1.27"
20
20
  },
21
21
  "dependencies": {
22
22
  "@radix-ui/react-checkbox": "1.1.1",
@@ -90,9 +90,9 @@
90
90
  "typescript": "5.5.4",
91
91
  "vite": "5.4.3",
92
92
  "vite-plugin-dts": "4.1.0",
93
+ "@levo/eslint-config": "0.0.0",
93
94
  "@levo/tw-config": "0.0.0",
94
- "@levo/ts-config": "0.0.0",
95
- "@levo/eslint-config": "0.0.0"
95
+ "@levo/ts-config": "0.0.0"
96
96
  },
97
97
  "main": "./dist/index.js",
98
98
  "module": "./dist/index.js",