@levo-so/react 0.1.24 → 0.1.25

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;AAMnD,eAAO,MAAM,gBAAgB,EAAE,KAAK,CAAC,EAAE,CAAC;IACtC,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,UAAU,CAAC,EAAE,aAAa,CAAC,UAAU,CAAC;CACvC,CA4FA,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,CAuGA,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const useCurrentTab: () => string | null;
2
+ export default useCurrentTab;
3
+ //# sourceMappingURL=useCurrentTab.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCurrentTab.d.ts","sourceRoot":"","sources":["../../../src/audience/hooks/useCurrentTab.tsx"],"names":[],"mappings":"AAOA,QAAA,MAAM,aAAa,QAAO,MAAM,GAAG,IAsDlC,CAAC;AAEF,eAAe,aAAa,CAAC"}
@@ -0,0 +1,3 @@
1
+ declare const useOpenTabs: () => number;
2
+ export default useOpenTabs;
3
+ //# sourceMappingURL=useOpenTabs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useOpenTabs.d.ts","sourceRoot":"","sources":["../../../src/audience/hooks/useOpenTabs.tsx"],"names":[],"mappings":"AAMA,QAAA,MAAM,WAAW,QAAO,MAuCvB,CAAC;AAEF,eAAe,WAAW,CAAC"}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useScrollDepth.d.ts","sourceRoot":"","sources":["../../../src/audience/hooks/useScrollDepth.tsx"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,cAAc,cAwC1B,CAAC"}
@@ -1,4 +1,4 @@
1
- import { L as e, a, b as n } from "../page-sR2SWtb2.js";
1
+ import { L as e, a, b as n } from "../page-nOk3Od6l.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-sR2SWtb2.js";
2
+ import { L as t, a as r, b as l } from "./page-nOk3Od6l.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-C9clUECd.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-BnrQ9e_i.js";
@@ -0,0 +1,230 @@
1
+ "use client";
2
+ import { j as H } from "./jsx-runtime-B6kdoens.js";
3
+ import { useEffect as u, useState as h } from "react";
4
+ import { useInView as G } from "react-intersection-observer";
5
+ import { u as j } from "./LevoProvider-BAZy7_tP.js";
6
+ import { usePageLifecycle as F, LifecycleState as O } from "use-page-lifecycle";
7
+ const Le = ({ id: e, properties: r = {} }) => {
8
+ const { audience: t } = j(), { ref: n, inView: o } = G({
9
+ triggerOnce: !0
10
+ });
11
+ return u(() => {
12
+ t != null && t.instance && o && (t == null || t.track("block.view", {
13
+ ...r,
14
+ resource: "block",
15
+ identifier: e
16
+ }));
17
+ }, [o]), /* @__PURE__ */ H.jsx("div", { ref: n, style: { height: "0px" } });
18
+ }, Ie = ({ event: e, properties: r }) => {
19
+ const { audience: t } = j();
20
+ return u(() => {
21
+ t != null && t.instance && (t == null || t.track(e, r));
22
+ }, [t == null ? void 0 : t.instance, e, r]), null;
23
+ };
24
+ function I(e) {
25
+ var r = typeof e;
26
+ return e != null && (r == "object" || r == "function");
27
+ }
28
+ var Y = typeof global == "object" && global && global.Object === Object && global, J = typeof self == "object" && self && self.Object === Object && self, U = Y || J || Function("return this")(), E = function() {
29
+ return U.Date.now();
30
+ }, K = /\s/;
31
+ function V(e) {
32
+ for (var r = e.length; r-- && K.test(e.charAt(r)); )
33
+ ;
34
+ return r;
35
+ }
36
+ var z = /^\s+/;
37
+ function X(e) {
38
+ return e && e.slice(0, V(e) + 1).replace(z, "");
39
+ }
40
+ var w = U.Symbol, B = Object.prototype, Z = B.hasOwnProperty, q = B.toString, b = w ? w.toStringTag : void 0;
41
+ function Q(e) {
42
+ var r = Z.call(e, b), t = e[b];
43
+ try {
44
+ e[b] = void 0;
45
+ var n = !0;
46
+ } catch {
47
+ }
48
+ var o = q.call(e);
49
+ return n && (r ? e[b] = t : delete e[b]), o;
50
+ }
51
+ var ee = Object.prototype, te = ee.toString;
52
+ function ne(e) {
53
+ return te.call(e);
54
+ }
55
+ var re = "[object Null]", oe = "[object Undefined]", N = w ? w.toStringTag : void 0;
56
+ function ie(e) {
57
+ return e == null ? e === void 0 ? oe : re : N && N in Object(e) ? Q(e) : ne(e);
58
+ }
59
+ function se(e) {
60
+ return e != null && typeof e == "object";
61
+ }
62
+ var ae = "[object Symbol]";
63
+ function ce(e) {
64
+ return typeof e == "symbol" || se(e) && ie(e) == ae;
65
+ }
66
+ var R = NaN, fe = /^[-+]0x[0-9a-f]+$/i, le = /^0b[01]+$/i, ue = /^0o[0-7]+$/i, de = parseInt;
67
+ function C(e) {
68
+ if (typeof e == "number")
69
+ return e;
70
+ if (ce(e))
71
+ return R;
72
+ if (I(e)) {
73
+ var r = typeof e.valueOf == "function" ? e.valueOf() : e;
74
+ e = I(r) ? r + "" : r;
75
+ }
76
+ if (typeof e != "string")
77
+ return e === 0 ? e : +e;
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) ? R : +e;
81
+ }
82
+ var ge = "Expected a function", me = Math.max, be = Math.min;
83
+ function pe(e, r, t) {
84
+ var n, o, i, f, a, c, l = 0, k = !1, g = !1, v = !0;
85
+ if (typeof e != "function")
86
+ throw new TypeError(ge);
87
+ r = C(r) || 0, I(t) && (k = !!t.leading, g = "maxWait" in t, i = g ? me(C(t.maxWait) || 0, r) : i, v = "trailing" in t ? !!t.trailing : v);
88
+ function S(s) {
89
+ var d = n, m = o;
90
+ return n = o = void 0, l = s, f = e.apply(m, d), f;
91
+ }
92
+ function $(s) {
93
+ return l = s, a = setTimeout(T, r), k ? S(s) : f;
94
+ }
95
+ function P(s) {
96
+ var d = s - c, m = s - l, A = r - d;
97
+ return g ? be(A, i - m) : A;
98
+ }
99
+ function x(s) {
100
+ var d = s - c, m = s - l;
101
+ return c === void 0 || d >= r || d < 0 || g && m >= i;
102
+ }
103
+ function T() {
104
+ var s = E();
105
+ if (x(s))
106
+ return _(s);
107
+ a = setTimeout(T, P(s));
108
+ }
109
+ function _(s) {
110
+ return a = void 0, v && n ? S(s) : (n = o = void 0, f);
111
+ }
112
+ function W() {
113
+ a !== void 0 && clearTimeout(a), l = 0, n = c = o = a = void 0;
114
+ }
115
+ function M() {
116
+ return a === void 0 ? f : _(E());
117
+ }
118
+ function y() {
119
+ var s = E(), d = x(s);
120
+ if (n = arguments, o = this, c = s, d) {
121
+ if (a === void 0)
122
+ return $(c);
123
+ if (g)
124
+ return clearTimeout(a), a = setTimeout(T, r), S(c);
125
+ }
126
+ return a === void 0 && (a = setTimeout(T, r)), f;
127
+ }
128
+ return y.cancel = W, y.flush = M, y;
129
+ }
130
+ const he = () => {
131
+ const [e, r] = h(0), [t, n] = h(0), o = pe((i) => {
132
+ n(i), r(i);
133
+ }, 250);
134
+ return u(() => {
135
+ const i = () => {
136
+ const f = window.scrollY, a = document.documentElement.scrollHeight, c = window.innerHeight, l = Math.round(
137
+ f / (a - c) * 100
138
+ );
139
+ l % 10 === 0 && l > t && o(l);
140
+ };
141
+ return window.addEventListener("scroll", i), () => window.removeEventListener("scroll", i);
142
+ }, [t]), e;
143
+ }, p = "lv_insights_ot", Te = () => {
144
+ const [e, r] = h(0);
145
+ return u(() => {
146
+ const t = Number(localStorage.getItem(p)) || 0;
147
+ r(t), localStorage.setItem(p, (t + 1).toString());
148
+ const n = (i) => {
149
+ i.key === p && r(Number(i.newValue) || 0);
150
+ };
151
+ window.addEventListener("storage", n);
152
+ const o = () => {
153
+ const i = Number(localStorage.getItem(p)) || 0;
154
+ i > 0 && localStorage.setItem(p, (i - 1).toString());
155
+ };
156
+ return window.addEventListener("beforeunload", o), () => {
157
+ window.removeEventListener("storage", n), window.removeEventListener("beforeunload", o);
158
+ };
159
+ }, []), e;
160
+ }, D = "lv_insights_ct", L = "lv_insights_at", we = () => {
161
+ const [e, r] = h(null);
162
+ return u(() => {
163
+ let t = sessionStorage.getItem(D);
164
+ const n = JSON.parse(
165
+ localStorage.getItem(L) || "[]"
166
+ );
167
+ t && n.includes(t) && (t = null), t || (t = `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`, sessionStorage.setItem(D, t)), n.includes(t) || (n.push(t), localStorage.setItem(
168
+ L,
169
+ JSON.stringify(n)
170
+ )), r(t);
171
+ const o = () => {
172
+ const i = n.filter(
173
+ (f) => f !== t
174
+ );
175
+ localStorage.setItem(
176
+ L,
177
+ JSON.stringify(i)
178
+ );
179
+ };
180
+ return window.addEventListener("beforeunload", o), () => {
181
+ window.removeEventListener("beforeunload", o);
182
+ };
183
+ }, []), e;
184
+ }, je = ({ id: e, properties: r = {} }) => {
185
+ const { client: t, audience: n } = j(), [o, i] = h(), f = he(), a = typeof window < "u" ? window.location.href : void 0;
186
+ Te(), we(), u(() => {
187
+ a && i(a);
188
+ }, [a]), u(() => {
189
+ n != null && n.instance && f > 0 && n.track("page.scroll", {
190
+ resource: "page",
191
+ identifier: e,
192
+ percent: f
193
+ });
194
+ }, [n == null ? void 0 : n.instance, f, e]), u(() => {
195
+ const l = () => {
196
+ n == null || n.bounce({
197
+ resource: "page",
198
+ identifier: e
199
+ });
200
+ };
201
+ return window && window.addEventListener("beforeunload", l), () => {
202
+ window && window.removeEventListener("beforeunload", l);
203
+ };
204
+ }, [n, e]);
205
+ const [c] = F();
206
+ return u(() => {
207
+ (c === O.TERMINATED || c === O.HIDDEN || c === O.FROZEN) && (n == null || n.bounce({
208
+ resource: "page",
209
+ identifier: e,
210
+ state: c
211
+ }));
212
+ }, [c, n, e]), u(() => {
213
+ (() => {
214
+ t != null && t.insightsUrl && t.workspace && o && (n != null && n.instance ? n.instance.page({
215
+ resource: "page",
216
+ identifier: e
217
+ }) : n == null || n.initiate({
218
+ ...r,
219
+ id: e
220
+ }));
221
+ })();
222
+ }, [t == null ? void 0 : t.insightsUrl, t == null ? void 0 : t.workspace, o]), (!(t != null && t.insightsUrl) || !t.workspace || !t.workspace.startsWith("W")) && console.error(
223
+ "[@levo-so/audience] The utility could not be initialized, due to missing workspace, or endpoint for insights."
224
+ ), null;
225
+ };
226
+ export {
227
+ Le as L,
228
+ Ie as a,
229
+ je as b
230
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/react",
3
- "version": "0.1.24",
3
+ "version": "0.1.25",
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.24"
19
+ "@levo-so/core": "0.1.25"
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
+ "@levo/tw-config": "0.0.0",
94
94
  "@levo/ts-config": "0.0.0",
95
- "@levo/tw-config": "0.0.0"
95
+ "@levo/eslint-config": "0.0.0"
96
96
  },
97
97
  "main": "./dist/index.js",
98
98
  "module": "./dist/index.js",
@@ -1 +0,0 @@
1
- {"version":3,"file":"useScrollDepth.d.ts","sourceRoot":"","sources":["../../../src/audience/components/useScrollDepth.tsx"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,cAAc,cAwC1B,CAAC"}
@@ -1,189 +0,0 @@
1
- "use client";
2
- import { j as B } from "./jsx-runtime-B6kdoens.js";
3
- import { useEffect as d, useState as j } from "react";
4
- import { useInView as C } from "react-intersection-observer";
5
- import { u as O } from "./LevoProvider-BAZy7_tP.js";
6
- import { usePageLifecycle as H, LifecycleState as I } from "use-page-lifecycle";
7
- const we = ({ id: e, properties: r = {} }) => {
8
- const { audience: t } = O(), { ref: n, inView: s } = C({
9
- triggerOnce: !0
10
- });
11
- return d(() => {
12
- t != null && t.instance && s && (t == null || t.track("block.view", {
13
- ...r,
14
- resource: "block",
15
- identifier: e
16
- }));
17
- }, [s]), /* @__PURE__ */ B.jsx("div", { ref: n, style: { height: "0px" } });
18
- }, Te = ({ event: e, properties: r }) => {
19
- const { audience: t } = O();
20
- return d(() => {
21
- t != null && t.instance && (t == null || t.track(e, r));
22
- }, [t == null ? void 0 : t.instance, e, r]), null;
23
- };
24
- function S(e) {
25
- var r = typeof e;
26
- return e != null && (r == "object" || r == "function");
27
- }
28
- var F = typeof global == "object" && global && global.Object === Object && global, G = typeof self == "object" && self && self.Object === Object && self, W = F || G || Function("return this")(), T = function() {
29
- return W.Date.now();
30
- }, V = /\s/;
31
- function _(e) {
32
- for (var r = e.length; r-- && V.test(e.charAt(r)); )
33
- ;
34
- return r;
35
- }
36
- var z = /^\s+/;
37
- function X(e) {
38
- return e && e.slice(0, _(e) + 1).replace(z, "");
39
- }
40
- var h = W.Symbol, D = Object.prototype, Y = D.hasOwnProperty, Z = D.toString, p = h ? h.toStringTag : void 0;
41
- function q(e) {
42
- var r = Y.call(e, p), t = e[p];
43
- try {
44
- e[p] = void 0;
45
- var n = !0;
46
- } catch {
47
- }
48
- var s = Z.call(e);
49
- return n && (r ? e[p] = t : delete e[p]), s;
50
- }
51
- var J = Object.prototype, K = J.toString;
52
- function Q(e) {
53
- return K.call(e);
54
- }
55
- var ee = "[object Null]", te = "[object Undefined]", A = h ? h.toStringTag : void 0;
56
- function ne(e) {
57
- return e == null ? e === void 0 ? te : ee : A && A in Object(e) ? q(e) : Q(e);
58
- }
59
- function re(e) {
60
- return e != null && typeof e == "object";
61
- }
62
- var ie = "[object Symbol]";
63
- function oe(e) {
64
- return typeof e == "symbol" || re(e) && ne(e) == ie;
65
- }
66
- var P = NaN, se = /^[-+]0x[0-9a-f]+$/i, ce = /^0b[01]+$/i, ae = /^0o[0-7]+$/i, fe = parseInt;
67
- function R(e) {
68
- if (typeof e == "number")
69
- return e;
70
- if (oe(e))
71
- return P;
72
- if (S(e)) {
73
- var r = typeof e.valueOf == "function" ? e.valueOf() : e;
74
- e = S(r) ? r + "" : r;
75
- }
76
- if (typeof e != "string")
77
- return e === 0 ? e : +e;
78
- e = X(e);
79
- var t = ce.test(e);
80
- return t || ae.test(e) ? fe(e.slice(2), t ? 2 : 8) : se.test(e) ? P : +e;
81
- }
82
- var le = "Expected a function", ue = Math.max, de = Math.min;
83
- function ge(e, r, t) {
84
- var n, s, a, l, i, c, f = 0, k = !1, g = !1, v = !0;
85
- if (typeof e != "function")
86
- throw new TypeError(le);
87
- r = R(r) || 0, S(t) && (k = !!t.leading, g = "maxWait" in t, a = g ? ue(R(t.maxWait) || 0, r) : a, v = "trailing" in t ? !!t.trailing : v);
88
- function y(o) {
89
- var u = n, m = s;
90
- return n = s = void 0, f = o, l = e.apply(m, u), l;
91
- }
92
- function N(o) {
93
- return f = o, i = setTimeout(b, r), k ? y(o) : l;
94
- }
95
- function U(o) {
96
- var u = o - c, m = o - f, x = r - u;
97
- return g ? de(x, a - m) : x;
98
- }
99
- function E(o) {
100
- var u = o - c, m = o - f;
101
- return c === void 0 || u >= r || u < 0 || g && m >= a;
102
- }
103
- function b() {
104
- var o = T();
105
- if (E(o))
106
- return L(o);
107
- i = setTimeout(b, U(o));
108
- }
109
- function L(o) {
110
- return i = void 0, v && n ? y(o) : (n = s = void 0, l);
111
- }
112
- function $() {
113
- i !== void 0 && clearTimeout(i), f = 0, n = c = s = i = void 0;
114
- }
115
- function M() {
116
- return i === void 0 ? l : L(T());
117
- }
118
- function w() {
119
- var o = T(), u = E(o);
120
- if (n = arguments, s = this, c = o, u) {
121
- if (i === void 0)
122
- return N(c);
123
- if (g)
124
- return clearTimeout(i), i = setTimeout(b, r), y(c);
125
- }
126
- return i === void 0 && (i = setTimeout(b, r)), l;
127
- }
128
- return w.cancel = $, w.flush = M, w;
129
- }
130
- const me = () => {
131
- const [e, r] = j(0), [t, n] = j(0), s = ge((a) => {
132
- n(a), r(a);
133
- }, 250);
134
- return d(() => {
135
- const a = () => {
136
- const l = window.scrollY, i = document.documentElement.scrollHeight, c = window.innerHeight, f = Math.round(
137
- l / (i - c) * 100
138
- );
139
- f % 10 === 0 && f > t && s(f);
140
- };
141
- return window.addEventListener("scroll", a), () => window.removeEventListener("scroll", a);
142
- }, [t]), e;
143
- }, je = ({ id: e, properties: r = {} }) => {
144
- const { client: t, audience: n } = O(), [s, a] = j(), l = me(), i = typeof window < "u" ? window.location.href : void 0;
145
- d(() => {
146
- i && a(i);
147
- }, [i]), d(() => {
148
- n != null && n.instance && n.track("page.scroll", {
149
- resource: "page",
150
- identifier: e,
151
- percent: l
152
- });
153
- }, [n == null ? void 0 : n.instance, l, e]), d(() => {
154
- const f = () => {
155
- n == null || n.bounce({
156
- resource: "page",
157
- identifier: e
158
- });
159
- };
160
- return window && window.addEventListener("beforeunload", f), () => {
161
- window && window.removeEventListener("beforeunload", f);
162
- };
163
- }, [i, n, e]);
164
- const [c] = H();
165
- return d(() => {
166
- (c === I.TERMINATED || c === I.FROZEN) && (n == null || n.bounce({
167
- resource: "page",
168
- identifier: e,
169
- state: c
170
- }));
171
- }, [c, n, e]), d(() => {
172
- (() => {
173
- t != null && t.insightsUrl && t.workspace && s && (n != null && n.instance ? n.instance.page({
174
- resource: "page",
175
- identifier: e
176
- }) : n == null || n.initiate({
177
- ...r,
178
- id: e
179
- }));
180
- })();
181
- }, [t == null ? void 0 : t.insightsUrl, t == null ? void 0 : t.workspace, s]), (!(t != null && t.insightsUrl) || !t.workspace || !t.workspace.startsWith("W")) && console.error(
182
- "[@levo-so/audience] The utility could not be initialized, due to missing workspace, or endpoint for insights."
183
- ), null;
184
- };
185
- export {
186
- we as L,
187
- Te as a,
188
- je as b
189
- };