@levo-so/react 0.1.32 → 0.1.34

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.
Files changed (45) hide show
  1. package/dist/{CheckboxWidget-Dedx-7Wy.js → CheckboxWidget-BrVNbP0R.js} +1 -1
  2. package/dist/{CollectionFormBuilder-BPzVyGLq.js → CollectionFormBuilder-CkD8uVKZ.js} +18 -18
  3. package/dist/{CurrencyWidget-CW3cMoYn.js → CurrencyWidget-D_q2AYWu.js} +1 -1
  4. package/dist/{DateTimeWidget-eKbj2Q86.js → DateTimeWidget-CsuCisSs.js} +1 -1
  5. package/dist/{DefaultFormVariant-DGecA_SF.js → DefaultFormVariant-rv38sBOZ.js} +2 -2
  6. package/dist/{DropdownWidget-DJ6rBFE0.js → DropdownWidget-CsTQ0Ojo.js} +1 -1
  7. package/dist/{EmailWidget-Bx3LTBSb.js → EmailWidget-Did2OUyB.js} +1 -1
  8. package/dist/{FormCaptcha-BVawlT6h.js → FormCaptcha-C_DxR2za.js} +2 -2
  9. package/dist/{GeocoderWidget-C_8wJijA.js → GeocoderWidget-CyzcaWxa.js} +9 -9
  10. package/dist/{MultiGeocoderWidget-0uUFNNoH.js → MultiGeocoderWidget-DgwiZ330.js} +2 -2
  11. package/dist/{MultiTextWidget-BluGgZVP.js → MultiTextWidget-Dic46WBU.js} +1 -1
  12. package/dist/{PhoneWidget-Mm6DmCsK.js → PhoneWidget-DKH-Wzgz.js} +1 -1
  13. package/dist/{RadioWidget-BkYAbg4o.js → RadioWidget-CTgWKCg2.js} +1 -1
  14. package/dist/{RichTextWidget-CbyT-y1E.js → RichTextWidget-C30H7mVF.js} +1 -1
  15. package/dist/{StepsFormVariant-Bk_rc3R7.js → StepsFormVariant-myT97AwJ.js} +2 -2
  16. package/dist/{SwitchWidget-DeCIh2Vm.js → SwitchWidget-BS-rmHiq.js} +1 -1
  17. package/dist/{TextWidget-Di_db2UE.js → TextWidget-aNB-0vc-.js} +1 -1
  18. package/dist/{TextareaWidget-CZqLQQAK.js → TextareaWidget-CEH-97Oj.js} +1 -1
  19. package/dist/{ToggleCheckboxWidget-Dynr-C0Y.js → ToggleCheckboxWidget-C0buyS29.js} +1 -1
  20. package/dist/{URLWidget-BvQvn0aZ.js → URLWidget-DrZlRAD7.js} +2 -2
  21. package/dist/{UploadWidget-mRgEWRVS.js → UploadWidget-Bw7urh-7.js} +2 -2
  22. package/dist/audience/components/page.d.ts.map +1 -1
  23. package/dist/audience/hooks/useDownloadSpeed.d.ts +3 -0
  24. package/dist/audience/hooks/useDownloadSpeed.d.ts.map +1 -0
  25. package/dist/audience/hooks/usePerformanceMetrics.d.ts +11 -5
  26. package/dist/audience/hooks/usePerformanceMetrics.d.ts.map +1 -1
  27. package/dist/audience/hooks/useScrollBehavior.d.ts +9 -0
  28. package/dist/audience/hooks/useScrollBehavior.d.ts.map +1 -0
  29. package/dist/audience/hooks/useTextSelection.d.ts +3 -0
  30. package/dist/audience/hooks/useTextSelection.d.ts.map +1 -0
  31. package/dist/audience/index.js +1 -1
  32. package/dist/audience/utils/autocapture.d.ts.map +1 -1
  33. package/dist/collection/index.js +1 -1
  34. package/dist/index.css +1 -1
  35. package/dist/index.js +9 -9
  36. package/dist/membership/index.js +1 -1
  37. package/dist/page-BaAkHGtG.js +562 -0
  38. package/dist/providers/LevoProvider.d.ts.map +1 -1
  39. package/dist/providers/index.d.ts +2 -0
  40. package/dist/providers/index.js +169 -0
  41. package/package.json +8 -4
  42. package/dist/LevoProvider-BAZy7_tP.js +0 -223
  43. package/dist/audience/hooks/useScrollDepth.d.ts +0 -6
  44. package/dist/audience/hooks/useScrollDepth.d.ts.map +0 -1
  45. package/dist/page-BjcgPmsH.js +0 -478
@@ -0,0 +1,169 @@
1
+ "use client";
2
+ var g = Object.defineProperty;
3
+ var m = (t, e, s) => e in t ? g(t, e, { enumerable: !0, configurable: !0, writable: !0, value: s }) : t[e] = s;
4
+ var o = (t, e, s) => m(t, typeof e != "symbol" ? e + "" : e, s);
5
+ import { j as d } from "../jsx-runtime-B6kdoens.js";
6
+ import v from "wretch";
7
+ import { createContext as w, useState as c, useContext as p } from "react";
8
+ var u = class {
9
+ constructor(t) {
10
+ o(this, "client");
11
+ this.client = t;
12
+ }
13
+ }, y = class {
14
+ constructor(t = {}) {
15
+ o(this, "logApiUrl", "https://public-api.levo.so");
16
+ o(this, "logs", []);
17
+ o(this, "activeFlush", Promise.resolve());
18
+ o(this, "nextFlush", setTimeout(() => {
19
+ }, 0));
20
+ o(this, "lastFlush", /* @__PURE__ */ new Date());
21
+ o(this, "sendLogs", async (t) => {
22
+ const e = `${this.logApiUrl}/v1/apm/logs/json`, s = () => v().url(e).post(t).res().catch((n) => console.error(n));
23
+ try {
24
+ if (typeof fetch > "u")
25
+ throw new Error("fetch is not defined");
26
+ if (typeof window < "u" && navigator.sendBeacon)
27
+ try {
28
+ if (!navigator.sendBeacon.bind(navigator)(e, JSON.stringify(t)))
29
+ return s();
30
+ } catch {
31
+ return s();
32
+ }
33
+ else
34
+ return s();
35
+ } catch (n) {
36
+ console.warn(`Failed to send logs to server: ${n}`), this.logs = [...this.logs, ...t];
37
+ }
38
+ });
39
+ o(this, "ingest", (t) => {
40
+ if (!this.logApiUrl) return;
41
+ const e = Array.isArray(t) ? t : [t];
42
+ this.logs.push(e), this.logs.length >= 50 || this.lastFlush.getTime() < Date.now() - 1500 ? (clearTimeout(this.nextFlush), this.activeFlush = this.flush()) : (clearTimeout(this.nextFlush), this.nextFlush = setTimeout(() => {
43
+ this.activeFlush = this.flush();
44
+ }, 1500));
45
+ });
46
+ o(this, "flush", async () => {
47
+ const t = this.logs.splice(0, this.logs.length);
48
+ if (clearTimeout(this.nextFlush), await this.activeFlush, t.length === 0) {
49
+ this.lastFlush = /* @__PURE__ */ new Date();
50
+ return;
51
+ }
52
+ try {
53
+ await this.sendLogs(t);
54
+ } catch (e) {
55
+ console.log("error sending logs", e);
56
+ } finally {
57
+ this.lastFlush = /* @__PURE__ */ new Date();
58
+ }
59
+ });
60
+ t != null && t.logApiUrl && (this.logApiUrl = t == null ? void 0 : t.logApiUrl);
61
+ }
62
+ }, h = typeof window < "u", x = (t) => {
63
+ switch (t) {
64
+ case 0:
65
+ return "log";
66
+ case 1:
67
+ return "info";
68
+ case 2:
69
+ return "warn";
70
+ case 3:
71
+ return "error";
72
+ default:
73
+ return "log";
74
+ }
75
+ }, F = class extends u {
76
+ constructor(e, s = {}, n = {}) {
77
+ super(e);
78
+ o(this, "logLevel", 0);
79
+ o(this, "enableRemote", !1);
80
+ o(this, "batch");
81
+ o(this, "context");
82
+ o(this, "debug", (...e) => {
83
+ this.log(0, e);
84
+ });
85
+ o(this, "info", (...e) => {
86
+ this.log(1, e);
87
+ });
88
+ o(this, "warn", (...e) => {
89
+ this.log(2, e);
90
+ });
91
+ o(this, "error", (...e) => {
92
+ this.log(3, e);
93
+ });
94
+ o(this, "log", (e, s) => {
95
+ const n = Array.isArray(s) ? s : [s];
96
+ if (e < this.logLevel)
97
+ return;
98
+ if (this.enableRemote && e === 3) {
99
+ const { content: i = {}, message: l } = this.format(n);
100
+ if (l) {
101
+ const a = {
102
+ timestamp: (/* @__PURE__ */ new Date()).toISOString(),
103
+ level: "error",
104
+ workspace: this.client.workspace,
105
+ appName: this.client.appName,
106
+ isBrowser: h,
107
+ ...this.context,
108
+ message: l,
109
+ content: i
110
+ };
111
+ h && (a.hostname = window.location.hostname, a.pathname = window.location.pathname, a.url = window.location.href, a.page_title = window.document.title, a.userAgent = window.navigator.userAgent), this.batch.ingest(a);
112
+ }
113
+ }
114
+ const r = x(e);
115
+ console[r](...n);
116
+ });
117
+ this.batch = new y(s), this.context = n, this.logLevel = (s == null ? void 0 : s.level) ?? (this.client.NODE_ENV !== "development" ? 1 : 0), this.enableRemote = (s == null ? void 0 : s.enableRemote) ?? this.client.NODE_ENV !== "development";
118
+ }
119
+ format(e) {
120
+ let s = "";
121
+ const n = e.map((r) => {
122
+ let i = "";
123
+ const l = !s;
124
+ return typeof r == "string" ? (i = r, l && (s = r)) : r instanceof Error ? (i = {
125
+ message: r.message,
126
+ name: r.name,
127
+ stack: r.stack
128
+ }, l && (s = r.message)) : typeof r == "object" ? i = r : (i = String(r), l && (s = String(r))), i;
129
+ }).filter(Boolean);
130
+ return !s && n.length > 0 && (s = "Default message (Check content for details)"), (n == null ? void 0 : n.length) === 1 && n[0] === s ? { message: s, content: {} } : {
131
+ message: s,
132
+ content: n
133
+ };
134
+ }
135
+ }, L = class extends u {
136
+ constructor() {
137
+ super(...arguments);
138
+ o(this, "mediaBulkUpload", (e, s = {}) => this.client.fetch.url("/v1/assets/media/bulk").options(s).post(e).json());
139
+ o(this, "getAllMedia", async (e = {}) => await this.client.fetch.url("/v1/assets/media/query").post(e).json());
140
+ }
141
+ };
142
+ const f = w(null), N = ({
143
+ children: t,
144
+ client: e,
145
+ ...s
146
+ }) => {
147
+ const [n] = c(new F(e)), [r] = c(new L(e));
148
+ return /* @__PURE__ */ d.jsx(
149
+ f.Provider,
150
+ {
151
+ value: {
152
+ client: e,
153
+ media: r,
154
+ logger: n,
155
+ ...s
156
+ },
157
+ children: t
158
+ }
159
+ );
160
+ }, j = () => {
161
+ const t = p(f);
162
+ if (!t)
163
+ throw new Error("useLevo must be used within LevoProvider");
164
+ return t;
165
+ };
166
+ export {
167
+ N as LevoProvider,
168
+ j as useLevo
169
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@levo-so/react",
3
- "version": "0.1.32",
3
+ "version": "0.1.34",
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.32"
19
+ "@levo-so/core": "0.1.34"
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/ts-config": "0.0.0",
93
+ "@levo/eslint-config": "0.0.0",
94
94
  "@levo/tw-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",
@@ -123,6 +123,10 @@
123
123
  "./utils": {
124
124
  "types": "./dist/utils/index.d.ts",
125
125
  "default": "./dist/utils/index.js"
126
+ },
127
+ "./provider": {
128
+ "types": "./dist/providers/index.d.ts",
129
+ "default": "./dist/providers/index.js"
126
130
  }
127
131
  },
128
132
  "scripts": {
@@ -1,223 +0,0 @@
1
- "use client";
2
- var j = Object.defineProperty;
3
- var D = (l, o, t) => o in l ? j(l, o, { enumerable: !0, configurable: !0, writable: !0, value: t }) : l[o] = t;
4
- var p = (l, o, t) => D(l, typeof o != "symbol" ? o + "" : o, t);
5
- import { j as B } from "./jsx-runtime-B6kdoens.js";
6
- import k from "wretch";
7
- import { createContext as G, useContext as W } from "react";
8
- var q = typeof globalThis < "u" ? globalThis : typeof window < "u" ? window : typeof global < "u" ? global : typeof self < "u" ? self : {};
9
- function z(l) {
10
- return l && l.__esModule && Object.prototype.hasOwnProperty.call(l, "default") ? l.default : l;
11
- }
12
- var T = class {
13
- constructor(l) {
14
- p(this, "client");
15
- this.client = l;
16
- }
17
- }, F = { exports: {} };
18
- (function(l) {
19
- (function(o, t) {
20
- l.exports ? l.exports = t() : o.log = t();
21
- })(q, function() {
22
- var o = function() {
23
- }, t = "undefined", L = typeof window !== t && typeof window.navigator !== t && /Trident\/|MSIE /.test(window.navigator.userAgent), g = [
24
- "trace",
25
- "debug",
26
- "info",
27
- "warn",
28
- "error"
29
- ], f = {}, a = null;
30
- function b(n, i) {
31
- var e = n[i];
32
- if (typeof e.bind == "function")
33
- return e.bind(n);
34
- try {
35
- return Function.prototype.bind.call(e, n);
36
- } catch {
37
- return function() {
38
- return Function.prototype.apply.apply(e, [n, arguments]);
39
- };
40
- }
41
- }
42
- function S() {
43
- console.log && (console.log.apply ? console.log.apply(console, arguments) : Function.prototype.apply.apply(console.log, [console, arguments])), console.trace && console.trace();
44
- }
45
- function U(n) {
46
- return n === "debug" && (n = "log"), typeof console === t ? !1 : n === "trace" && L ? S : console[n] !== void 0 ? b(console, n) : console.log !== void 0 ? b(console, "log") : o;
47
- }
48
- function d() {
49
- for (var n = this.getLevel(), i = 0; i < g.length; i++) {
50
- var e = g[i];
51
- this[e] = i < n ? o : this.methodFactory(e, n, this.name);
52
- }
53
- if (this.log = this.debug, typeof console === t && n < this.levels.SILENT)
54
- return "No console available for logging";
55
- }
56
- function A(n) {
57
- return function() {
58
- typeof console !== t && (d.call(this), this[n].apply(this, arguments));
59
- };
60
- }
61
- function M(n, i, e) {
62
- return U(n) || A.apply(this, arguments);
63
- }
64
- function E(n, i) {
65
- var e = this, y, m, c, u = "loglevel";
66
- typeof n == "string" ? u += ":" + n : typeof n == "symbol" && (u = void 0);
67
- function O(r) {
68
- var s = (g[r] || "silent").toUpperCase();
69
- if (!(typeof window === t || !u)) {
70
- try {
71
- window.localStorage[u] = s;
72
- return;
73
- } catch {
74
- }
75
- try {
76
- window.document.cookie = encodeURIComponent(u) + "=" + s + ";";
77
- } catch {
78
- }
79
- }
80
- }
81
- function C() {
82
- var r;
83
- if (!(typeof window === t || !u)) {
84
- try {
85
- r = window.localStorage[u];
86
- } catch {
87
- }
88
- if (typeof r === t)
89
- try {
90
- var s = window.document.cookie, h = encodeURIComponent(u), I = s.indexOf(h + "=");
91
- I !== -1 && (r = /^([^;]+)/.exec(
92
- s.slice(I + h.length + 1)
93
- )[1]);
94
- } catch {
95
- }
96
- return e.levels[r] === void 0 && (r = void 0), r;
97
- }
98
- }
99
- function P() {
100
- if (!(typeof window === t || !u)) {
101
- try {
102
- window.localStorage.removeItem(u);
103
- } catch {
104
- }
105
- try {
106
- window.document.cookie = encodeURIComponent(u) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
107
- } catch {
108
- }
109
- }
110
- }
111
- function v(r) {
112
- var s = r;
113
- if (typeof s == "string" && e.levels[s.toUpperCase()] !== void 0 && (s = e.levels[s.toUpperCase()]), typeof s == "number" && s >= 0 && s <= e.levels.SILENT)
114
- return s;
115
- throw new TypeError("log.setLevel() called with invalid level: " + r);
116
- }
117
- e.name = n, e.levels = {
118
- TRACE: 0,
119
- DEBUG: 1,
120
- INFO: 2,
121
- WARN: 3,
122
- ERROR: 4,
123
- SILENT: 5
124
- }, e.methodFactory = i || M, e.getLevel = function() {
125
- return c ?? m ?? y;
126
- }, e.setLevel = function(r, s) {
127
- return c = v(r), s !== !1 && O(c), d.call(e);
128
- }, e.setDefaultLevel = function(r) {
129
- m = v(r), C() || e.setLevel(r, !1);
130
- }, e.resetLevel = function() {
131
- c = null, P(), d.call(e);
132
- }, e.enableAll = function(r) {
133
- e.setLevel(e.levels.TRACE, r);
134
- }, e.disableAll = function(r) {
135
- e.setLevel(e.levels.SILENT, r);
136
- }, e.rebuild = function() {
137
- if (a !== e && (y = v(a.getLevel())), d.call(e), a === e)
138
- for (var r in f)
139
- f[r].rebuild();
140
- }, y = v(
141
- a ? a.getLevel() : "WARN"
142
- );
143
- var x = C();
144
- x != null && (c = v(x)), d.call(e);
145
- }
146
- a = new E(), a.getLogger = function(i) {
147
- if (typeof i != "symbol" && typeof i != "string" || i === "")
148
- throw new TypeError("You must supply a name when creating a logger.");
149
- var e = f[i];
150
- return e || (e = f[i] = new E(
151
- i,
152
- a.methodFactory
153
- )), e;
154
- };
155
- var N = typeof window !== t ? window.log : void 0;
156
- return a.noConflict = function() {
157
- return typeof window !== t && window.log === a && (window.log = N), a;
158
- }, a.getLoggers = function() {
159
- return f;
160
- }, a.default = a, a;
161
- });
162
- })(F);
163
- var J = F.exports;
164
- const w = /* @__PURE__ */ z(J);
165
- var K = class extends T {
166
- constructor(o) {
167
- super(o);
168
- p(this, "logger", w);
169
- w.setLevel(
170
- this.client.NODE_ENV === "production" ? w.levels.INFO : w.levels.DEBUG
171
- ), w.methodFactory = (t) => (L, g = {}) => {
172
- k().url(`${this.client.apiUrl}/v1/apm/logs/json`).post({
173
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
174
- level: t,
175
- message: L,
176
- ...g
177
- }).res().catch((f) => console.error(f));
178
- };
179
- }
180
- error(...o) {
181
- return this.logger.error(...o);
182
- }
183
- log(...o) {
184
- return this.logger.debug(...o);
185
- }
186
- info(...o) {
187
- return this.logger.info(...o);
188
- }
189
- warn(...o) {
190
- return this.logger.warn(...o);
191
- }
192
- }, V = class extends T {
193
- constructor() {
194
- super(...arguments);
195
- p(this, "mediaBulkUpload", (o, t = {}) => this.client.fetch.url("/v1/assets/media/bulk").options(t).post(o).json());
196
- p(this, "getAllMedia", async (o = {}) => await this.client.fetch.url("/v1/assets/media/query").post(o).json());
197
- }
198
- };
199
- const R = G(null), X = ({
200
- children: l,
201
- client: o,
202
- ...t
203
- }) => /* @__PURE__ */ B.jsx(
204
- R.Provider,
205
- {
206
- value: {
207
- client: o,
208
- media: new V(o),
209
- logger: new K(o),
210
- ...t
211
- },
212
- children: l
213
- }
214
- ), Z = () => {
215
- const l = W(R);
216
- if (!l)
217
- throw new Error("useLevo must be used within LevoProvider");
218
- return l;
219
- };
220
- export {
221
- X as L,
222
- Z as u
223
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * A custom React hook to track scroll depth.
3
- * @returns {number} The current scroll depth as a percentage.
4
- */
5
- export declare const useScrollDepth: () => number;
6
- //# sourceMappingURL=useScrollDepth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"useScrollDepth.d.ts","sourceRoot":"","sources":["../../../src/audience/hooks/useScrollDepth.tsx"],"names":[],"mappings":"AAKA;;;GAGG;AACH,eAAO,MAAM,cAAc,cAwC1B,CAAC"}