@tekibo/feedpulse-sdk 0.4.1 → 0.5.1

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.
package/dist/react.mjs CHANGED
@@ -1,67 +1,67 @@
1
- import te, { createContext as ne, useRef as oe, useEffect as ae, useContext as se, useState as y } from "react";
2
- import { FeedPulseTracker as le } from "./index.mjs";
3
- var S = { exports: {} }, v = {};
4
- var z;
5
- function ie() {
6
- if (z) return v;
7
- z = 1;
8
- var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), f = /* @__PURE__ */ Symbol.for("react.fragment");
9
- function s(d, n, i) {
10
- var c = null;
11
- if (i !== void 0 && (c = "" + i), n.key !== void 0 && (c = "" + n.key), "key" in n) {
12
- i = {};
13
- for (var m in n)
14
- m !== "key" && (i[m] = n[m]);
15
- } else i = n;
16
- return n = i.ref, {
1
+ import ie, { useState as h, useEffect as N, useCallback as J, createContext as le, useRef as M, useContext as ce } from "react";
2
+ import { CookieManager as B, FeedPulseTracker as ue } from "./index.mjs";
3
+ var j = { exports: {} }, _ = {};
4
+ var $;
5
+ function de() {
6
+ if ($) return _;
7
+ $ = 1;
8
+ var u = /* @__PURE__ */ Symbol.for("react.transitional.element"), k = /* @__PURE__ */ Symbol.for("react.fragment");
9
+ function a(m, i, s) {
10
+ var p = null;
11
+ if (s !== void 0 && (p = "" + s), i.key !== void 0 && (p = "" + i.key), "key" in i) {
12
+ s = {};
13
+ for (var g in i)
14
+ g !== "key" && (s[g] = i[g]);
15
+ } else s = i;
16
+ return i = s.ref, {
17
17
  $$typeof: u,
18
- type: d,
19
- key: c,
20
- ref: n !== void 0 ? n : null,
21
- props: i
18
+ type: m,
19
+ key: p,
20
+ ref: i !== void 0 ? i : null,
21
+ props: s
22
22
  };
23
23
  }
24
- return v.Fragment = f, v.jsx = s, v.jsxs = s, v;
24
+ return _.Fragment = k, _.jsx = a, _.jsxs = a, _;
25
25
  }
26
- var x = {};
27
- var D;
28
- function ue() {
29
- return D || (D = 1, process.env.NODE_ENV !== "production" && (function() {
26
+ var R = {};
27
+ var L;
28
+ function fe() {
29
+ return L || (L = 1, process.env.NODE_ENV !== "production" && (function() {
30
30
  function u(e) {
31
31
  if (e == null) return null;
32
32
  if (typeof e == "function")
33
- return e.$$typeof === K ? null : e.displayName || e.name || null;
33
+ return e.$$typeof === oe ? null : e.displayName || e.name || null;
34
34
  if (typeof e == "string") return e;
35
35
  switch (e) {
36
- case j:
36
+ case T:
37
37
  return "Fragment";
38
- case J:
38
+ case H:
39
39
  return "Profiler";
40
- case q:
40
+ case X:
41
41
  return "StrictMode";
42
- case B:
42
+ case ee:
43
43
  return "Suspense";
44
- case H:
44
+ case re:
45
45
  return "SuspenseList";
46
- case Q:
46
+ case ne:
47
47
  return "Activity";
48
48
  }
49
49
  if (typeof e == "object")
50
50
  switch (typeof e.tag == "number" && console.error(
51
51
  "Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
52
52
  ), e.$$typeof) {
53
- case U:
54
- return "Portal";
55
53
  case G:
54
+ return "Portal";
55
+ case Q:
56
56
  return e.displayName || "Context";
57
- case V:
57
+ case Z:
58
58
  return (e._context.displayName || "Context") + ".Consumer";
59
- case X:
59
+ case K:
60
60
  var r = e.render;
61
61
  return e = e.displayName, e || (e = r.displayName || r.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
62
- case Z:
62
+ case te:
63
63
  return r = e.displayName || null, r !== null ? r : u(e.type) || "Memo";
64
- case w:
64
+ case S:
65
65
  r = e._payload, e = e._init;
66
66
  try {
67
67
  return u(e(r));
@@ -70,29 +70,29 @@ function ue() {
70
70
  }
71
71
  return null;
72
72
  }
73
- function f(e) {
73
+ function k(e) {
74
74
  return "" + e;
75
75
  }
76
- function s(e) {
76
+ function a(e) {
77
77
  try {
78
- f(e);
78
+ k(e);
79
79
  var r = !1;
80
80
  } catch {
81
81
  r = !0;
82
82
  }
83
83
  if (r) {
84
84
  r = console;
85
- var t = r.error, o = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
- return t.call(
85
+ var o = r.error, l = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
86
+ return o.call(
87
87
  r,
88
88
  "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
89
- o
90
- ), f(e);
89
+ l
90
+ ), k(e);
91
91
  }
92
92
  }
93
- function d(e) {
94
- if (e === j) return "<>";
95
- if (typeof e == "object" && e !== null && e.$$typeof === w)
93
+ function m(e) {
94
+ if (e === T) return "<>";
95
+ if (typeof e == "object" && e !== null && e.$$typeof === S)
96
96
  return "<...>";
97
97
  try {
98
98
  var r = u(e);
@@ -101,49 +101,49 @@ function ue() {
101
101
  return "<...>";
102
102
  }
103
103
  }
104
- function n() {
105
- var e = P.A;
104
+ function i() {
105
+ var e = A.A;
106
106
  return e === null ? null : e.getOwner();
107
107
  }
108
- function i() {
108
+ function s() {
109
109
  return Error("react-stack-top-frame");
110
110
  }
111
- function c(e) {
112
- if (N.call(e, "key")) {
111
+ function p(e) {
112
+ if (D.call(e, "key")) {
113
113
  var r = Object.getOwnPropertyDescriptor(e, "key").get;
114
114
  if (r && r.isReactWarning) return !1;
115
115
  }
116
116
  return e.key !== void 0;
117
117
  }
118
- function m(e, r) {
119
- function t() {
118
+ function g(e, r) {
119
+ function o() {
120
120
  F || (F = !0, console.error(
121
121
  "%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
122
122
  r
123
123
  ));
124
124
  }
125
- t.isReactWarning = !0, Object.defineProperty(e, "key", {
126
- get: t,
125
+ o.isReactWarning = !0, Object.defineProperty(e, "key", {
126
+ get: o,
127
127
  configurable: !0
128
128
  });
129
129
  }
130
- function _() {
130
+ function x() {
131
131
  var e = u(this.type);
132
- return Y[e] || (Y[e] = !0, console.error(
132
+ return I[e] || (I[e] = !0, console.error(
133
133
  "Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
134
134
  )), e = this.props.ref, e !== void 0 ? e : null;
135
135
  }
136
- function g(e, r, t, o, h, A) {
137
- var a = t.ref;
136
+ function y(e, r, o, l, w, P) {
137
+ var c = o.ref;
138
138
  return e = {
139
- $$typeof: b,
139
+ $$typeof: v,
140
140
  type: e,
141
141
  key: r,
142
- props: t,
143
- _owner: o
144
- }, (a !== void 0 ? a : null) !== null ? Object.defineProperty(e, "ref", {
142
+ props: o,
143
+ _owner: l
144
+ }, (c !== void 0 ? c : null) !== null ? Object.defineProperty(e, "ref", {
145
145
  enumerable: !1,
146
- get: _
146
+ get: x
147
147
  }) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
148
148
  configurable: !1,
149
149
  enumerable: !1,
@@ -158,164 +158,238 @@ function ue() {
158
158
  configurable: !1,
159
159
  enumerable: !1,
160
160
  writable: !0,
161
- value: h
161
+ value: w
162
162
  }), Object.defineProperty(e, "_debugTask", {
163
163
  configurable: !1,
164
164
  enumerable: !1,
165
165
  writable: !0,
166
- value: A
166
+ value: P
167
167
  }), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
168
168
  }
169
- function k(e, r, t, o, h, A) {
170
- var a = r.children;
171
- if (a !== void 0)
172
- if (o)
173
- if (ee(a)) {
174
- for (o = 0; o < a.length; o++)
175
- R(a[o]);
176
- Object.freeze && Object.freeze(a);
169
+ function n(e, r, o, l, w, P) {
170
+ var c = r.children;
171
+ if (c !== void 0)
172
+ if (l)
173
+ if (ae(c)) {
174
+ for (l = 0; l < c.length; l++)
175
+ d(c[l]);
176
+ Object.freeze && Object.freeze(c);
177
177
  } else
178
178
  console.error(
179
179
  "React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead."
180
180
  );
181
- else R(a);
182
- if (N.call(r, "key")) {
183
- a = u(e);
184
- var E = Object.keys(r).filter(function(re) {
185
- return re !== "key";
181
+ else d(c);
182
+ if (D.call(r, "key")) {
183
+ c = u(e);
184
+ var E = Object.keys(r).filter(function(se) {
185
+ return se !== "key";
186
186
  });
187
- o = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", W[a + o] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
187
+ l = 0 < E.length ? "{key: someKey, " + E.join(": ..., ") + ": ...}" : "{key: someKey}", Y[c + l] || (E = 0 < E.length ? "{" + E.join(": ..., ") + ": ...}" : "{}", console.error(
188
188
  `A props object containing a "key" prop is being spread into JSX:
189
189
  let props = %s;
190
190
  <%s {...props} />
191
191
  React keys must be passed directly to JSX without using spread:
192
192
  let props = %s;
193
193
  <%s key={someKey} {...props} />`,
194
- o,
195
- a,
194
+ l,
195
+ c,
196
196
  E,
197
- a
198
- ), W[a + o] = !0);
197
+ c
198
+ ), Y[c + l] = !0);
199
199
  }
200
- if (a = null, t !== void 0 && (s(t), a = "" + t), c(r) && (s(r.key), a = "" + r.key), "key" in r) {
201
- t = {};
202
- for (var C in r)
203
- C !== "key" && (t[C] = r[C]);
204
- } else t = r;
205
- return a && m(
206
- t,
200
+ if (c = null, o !== void 0 && (a(o), c = "" + o), p(r) && (a(r.key), c = "" + r.key), "key" in r) {
201
+ o = {};
202
+ for (var O in r)
203
+ O !== "key" && (o[O] = r[O]);
204
+ } else o = r;
205
+ return c && g(
206
+ o,
207
207
  typeof e == "function" ? e.displayName || e.name || "Unknown" : e
208
- ), g(
208
+ ), y(
209
209
  e,
210
- a,
211
- t,
212
- n(),
213
- h,
214
- A
210
+ c,
211
+ o,
212
+ i(),
213
+ w,
214
+ P
215
215
  );
216
216
  }
217
- function R(e) {
218
- T(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === w && (e._payload.status === "fulfilled" ? T(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
217
+ function d(e) {
218
+ b(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === S && (e._payload.status === "fulfilled" ? b(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
219
219
  }
220
- function T(e) {
221
- return typeof e == "object" && e !== null && e.$$typeof === b;
220
+ function b(e) {
221
+ return typeof e == "object" && e !== null && e.$$typeof === v;
222
222
  }
223
- var p = te, b = /* @__PURE__ */ Symbol.for("react.transitional.element"), U = /* @__PURE__ */ Symbol.for("react.portal"), j = /* @__PURE__ */ Symbol.for("react.fragment"), q = /* @__PURE__ */ Symbol.for("react.strict_mode"), J = /* @__PURE__ */ Symbol.for("react.profiler"), V = /* @__PURE__ */ Symbol.for("react.consumer"), G = /* @__PURE__ */ Symbol.for("react.context"), X = /* @__PURE__ */ Symbol.for("react.forward_ref"), B = /* @__PURE__ */ Symbol.for("react.suspense"), H = /* @__PURE__ */ Symbol.for("react.suspense_list"), Z = /* @__PURE__ */ Symbol.for("react.memo"), w = /* @__PURE__ */ Symbol.for("react.lazy"), Q = /* @__PURE__ */ Symbol.for("react.activity"), K = /* @__PURE__ */ Symbol.for("react.client.reference"), P = p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, N = Object.prototype.hasOwnProperty, ee = Array.isArray, O = console.createTask ? console.createTask : function() {
223
+ var f = ie, v = /* @__PURE__ */ Symbol.for("react.transitional.element"), G = /* @__PURE__ */ Symbol.for("react.portal"), T = /* @__PURE__ */ Symbol.for("react.fragment"), X = /* @__PURE__ */ Symbol.for("react.strict_mode"), H = /* @__PURE__ */ Symbol.for("react.profiler"), Z = /* @__PURE__ */ Symbol.for("react.consumer"), Q = /* @__PURE__ */ Symbol.for("react.context"), K = /* @__PURE__ */ Symbol.for("react.forward_ref"), ee = /* @__PURE__ */ Symbol.for("react.suspense"), re = /* @__PURE__ */ Symbol.for("react.suspense_list"), te = /* @__PURE__ */ Symbol.for("react.memo"), S = /* @__PURE__ */ Symbol.for("react.lazy"), ne = /* @__PURE__ */ Symbol.for("react.activity"), oe = /* @__PURE__ */ Symbol.for("react.client.reference"), A = f.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, D = Object.prototype.hasOwnProperty, ae = Array.isArray, C = console.createTask ? console.createTask : function() {
224
224
  return null;
225
225
  };
226
- p = {
226
+ f = {
227
227
  react_stack_bottom_frame: function(e) {
228
228
  return e();
229
229
  }
230
230
  };
231
- var F, Y = {}, I = p.react_stack_bottom_frame.bind(
232
- p,
233
- i
234
- )(), $ = O(d(i)), W = {};
235
- x.Fragment = j, x.jsx = function(e, r, t) {
236
- var o = 1e4 > P.recentlyCreatedOwnerStacks++;
237
- return k(
231
+ var F, I = {}, z = f.react_stack_bottom_frame.bind(
232
+ f,
233
+ s
234
+ )(), W = C(m(s)), Y = {};
235
+ R.Fragment = T, R.jsx = function(e, r, o) {
236
+ var l = 1e4 > A.recentlyCreatedOwnerStacks++;
237
+ return n(
238
238
  e,
239
239
  r,
240
- t,
240
+ o,
241
241
  !1,
242
- o ? Error("react-stack-top-frame") : I,
243
- o ? O(d(e)) : $
242
+ l ? Error("react-stack-top-frame") : z,
243
+ l ? C(m(e)) : W
244
244
  );
245
- }, x.jsxs = function(e, r, t) {
246
- var o = 1e4 > P.recentlyCreatedOwnerStacks++;
247
- return k(
245
+ }, R.jsxs = function(e, r, o) {
246
+ var l = 1e4 > A.recentlyCreatedOwnerStacks++;
247
+ return n(
248
248
  e,
249
249
  r,
250
- t,
250
+ o,
251
251
  !0,
252
- o ? Error("react-stack-top-frame") : I,
253
- o ? O(d(e)) : $
252
+ l ? Error("react-stack-top-frame") : z,
253
+ l ? C(m(e)) : W
254
254
  );
255
255
  };
256
- })()), x;
256
+ })()), R;
257
257
  }
258
- var M;
259
- function ce() {
260
- return M || (M = 1, process.env.NODE_ENV === "production" ? S.exports = ie() : S.exports = ue()), S.exports;
258
+ var U;
259
+ function pe() {
260
+ return U || (U = 1, process.env.NODE_ENV === "production" ? j.exports = de() : j.exports = fe()), j.exports;
261
+ }
262
+ var t = pe();
263
+ const V = new B();
264
+ function me({ onConsent: u }) {
265
+ const [k, a] = h(!1), [m, i] = h(!1), [s, p] = h(!1), [g, x] = h(!1);
266
+ N(() => {
267
+ const f = V.getConsent();
268
+ a(!f || V.isConsentExpired()), f && (p(f.analytics), x(f.marketing));
269
+ }, []);
270
+ const y = () => {
271
+ u({ analytics: !0, marketing: !0, action: "accept_all" }), a(!1);
272
+ }, n = () => {
273
+ u({ analytics: !1, marketing: !1, action: "reject_all" }), a(!1);
274
+ }, d = () => {
275
+ u({ analytics: s, marketing: g, action: "custom" }), a(!1);
276
+ }, b = J(() => {
277
+ u({ analytics: !1, marketing: !1, action: "withdraw" }), p(!1), x(!1), a(!0);
278
+ }, [u]);
279
+ return N(() => {
280
+ const f = () => {
281
+ a(!0), i(!0);
282
+ };
283
+ return window.addEventListener("feedpulse:open-consent", f), window.addEventListener("feedpulse:withdraw-consent", b), () => {
284
+ window.removeEventListener("feedpulse:open-consent", f), window.removeEventListener("feedpulse:withdraw-consent", b);
285
+ };
286
+ }, [b]), k ? /* @__PURE__ */ t.jsx("div", { style: { position: "fixed", bottom: 0, left: 0, right: 0, zIndex: 99999, background: "#1a1a1a", color: "#fff", padding: "20px 24px", borderTop: "1px solid #333", fontFamily: "sans-serif" }, children: /* @__PURE__ */ t.jsxs("div", { style: { maxWidth: 900, margin: "0 auto" }, children: [
287
+ /* @__PURE__ */ t.jsxs("p", { style: { margin: "0 0 12px", fontSize: 14, lineHeight: 1.5 }, children: [
288
+ "We use cookies to improve reliability and understand usage.",
289
+ " ",
290
+ /* @__PURE__ */ t.jsx("a", { href: "/privacy", style: { color: "#818cf8" }, children: "Privacy Policy" })
291
+ ] }),
292
+ m && /* @__PURE__ */ t.jsxs("div", { style: { marginBottom: 12, fontSize: 13 }, children: [
293
+ /* @__PURE__ */ t.jsxs("label", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 6, opacity: 0.75 }, children: [
294
+ /* @__PURE__ */ t.jsx("input", { type: "checkbox", checked: !0, disabled: !0 }),
295
+ "Necessary (always on)"
296
+ ] }),
297
+ /* @__PURE__ */ t.jsxs("label", { style: { display: "flex", alignItems: "center", gap: 8, marginBottom: 6 }, children: [
298
+ /* @__PURE__ */ t.jsx("input", { type: "checkbox", checked: s, onChange: (f) => p(f.target.checked) }),
299
+ "Analytics"
300
+ ] }),
301
+ /* @__PURE__ */ t.jsxs("label", { style: { display: "flex", alignItems: "center", gap: 8 }, children: [
302
+ /* @__PURE__ */ t.jsx("input", { type: "checkbox", checked: g, onChange: (f) => x(f.target.checked) }),
303
+ "Marketing"
304
+ ] })
305
+ ] }),
306
+ /* @__PURE__ */ t.jsxs("div", { style: { display: "flex", gap: 8, flexWrap: "wrap", alignItems: "center" }, children: [
307
+ /* @__PURE__ */ t.jsx("button", { type: "button", style: { width: 130, padding: "9px 12px", background: "#4f46e5", color: "#fff", border: "1px solid #4f46e5", borderRadius: 6, fontSize: 13, fontWeight: 600, cursor: "pointer" }, onClick: y, children: "Accept All" }),
308
+ /* @__PURE__ */ t.jsx("button", { type: "button", style: { width: 130, padding: "9px 12px", background: "transparent", color: "#fff", border: "1px solid #555", borderRadius: 6, fontSize: 13, fontWeight: 600, cursor: "pointer" }, onClick: n, children: "Reject All" }),
309
+ /* @__PURE__ */ t.jsx("button", { type: "button", style: { padding: "9px 16px", background: "transparent", color: "#aaa", border: "1px solid #333", borderRadius: 6, fontSize: 13, cursor: "pointer" }, onClick: () => m ? d() : i(!0), children: m ? "Save Preferences" : "Customize" })
310
+ ] })
311
+ ] }) }) : null;
261
312
  }
262
- var l = ce();
263
- const L = ne({ tracker: null });
264
- function be({
313
+ const q = le({ tracker: null });
314
+ function ke({
265
315
  apiKey: u,
266
- endpoint: f,
267
- debug: s,
268
- children: d
316
+ endpoint: k,
317
+ debug: a,
318
+ consentRequired: m = !0,
319
+ children: i
269
320
  }) {
270
- const n = oe(null);
271
- return ae(() => (n.current = new le({ apiKey: u, endpoint: f, debug: s }), n.current.init(), () => n.current?.destroy()), [u, f, s]), /* @__PURE__ */ l.jsx(L.Provider, { value: { tracker: n.current }, children: d });
321
+ const s = M(null), p = M(new B()), [g, x] = h(null), y = J((n) => {
322
+ const d = p.current, b = d.setConsent({
323
+ analytics: n.analytics,
324
+ marketing: n.marketing,
325
+ version: "1.0"
326
+ });
327
+ n.analytics || d.clearAnalyticsCookies(), s.current?.updateCookieData(d.getAllData(n.analytics)), s.current?.track("consent", "__consent__", {
328
+ analytics: n.analytics,
329
+ marketing: n.marketing,
330
+ action: n.action,
331
+ userAgent: navigator.userAgent,
332
+ version: b.version
333
+ });
334
+ }, []);
335
+ return N(() => {
336
+ const n = new ue({ apiKey: u, endpoint: k, debug: a });
337
+ s.current = n, x(n);
338
+ const d = p.current, b = d.getConsent();
339
+ return m ? b && !d.isConsentExpired() ? n.updateCookieData(d.getAllData(b.analytics)) : n.updateCookieData(d.getAllData(!1)) : (d.setConsent({ analytics: !0, marketing: !0, version: "1.0" }), n.updateCookieData(d.getAllData(!0))), n.init(), () => {
340
+ n.destroy(), s.current = null, x(null);
341
+ };
342
+ }, [u, k, a, m]), /* @__PURE__ */ t.jsxs(q.Provider, { value: { tracker: g }, children: [
343
+ i,
344
+ m && /* @__PURE__ */ t.jsx(me, { onConsent: y })
345
+ ] });
272
346
  }
273
- function fe() {
274
- return se(L);
347
+ function ge() {
348
+ return ce(q);
275
349
  }
276
- function pe({ id: u, placeholder: f, position: s = "bottom-right" }) {
277
- const { tracker: d } = fe(), [n, i] = y(s === "inline"), [c, m] = y(null), [_, g] = y(""), [k, R] = y(!1), T = () => {
278
- !c && !_.trim() || (d?.trackFeedback(u ?? null, c, _ || null), R(!0), setTimeout(() => {
279
- i(s === "inline"), R(!1), m(null), g("");
350
+ function he({ id: u, placeholder: k, position: a = "bottom-right" }) {
351
+ const { tracker: m } = ge(), [i, s] = h(a === "inline"), [p, g] = h(null), [x, y] = h(""), [n, d] = h(!1), b = () => {
352
+ !p && !x.trim() || (m?.trackFeedback(u ?? null, p, x || null), d(!0), setTimeout(() => {
353
+ s(a === "inline"), d(!1), g(null), y("");
280
354
  }, 2e3));
281
- }, p = s !== "inline" ? { position: "fixed", bottom: 24, [s === "bottom-right" ? "right" : "left"]: 24, zIndex: 9999 } : {};
282
- return /* @__PURE__ */ l.jsxs("div", { style: p, children: [
283
- s !== "inline" && /* @__PURE__ */ l.jsx(
355
+ }, f = a !== "inline" ? { position: "fixed", bottom: 24, [a === "bottom-right" ? "right" : "left"]: 24, zIndex: 9999 } : {};
356
+ return /* @__PURE__ */ t.jsxs("div", { style: f, children: [
357
+ a !== "inline" && /* @__PURE__ */ t.jsx(
284
358
  "button",
285
359
  {
286
- onClick: () => i(!n),
360
+ onClick: () => s(!i),
287
361
  style: { background: "#6366f1", color: "#fff", border: "none", borderRadius: "50%", width: 48, height: 48, fontSize: 20, cursor: "pointer" },
288
362
  children: "💬"
289
363
  }
290
364
  ),
291
- n && /* @__PURE__ */ l.jsx("div", { style: { background: "#fff", border: "1px solid #e5e7eb", borderRadius: 12, padding: 16, width: 280, boxShadow: "0 10px 25px rgba(0,0,0,0.15)" }, children: k ? /* @__PURE__ */ l.jsxs("div", { style: { textAlign: "center", padding: 16 }, children: [
292
- /* @__PURE__ */ l.jsx("p", { style: { fontSize: 28, margin: 0 }, children: "🎉" }),
293
- /* @__PURE__ */ l.jsx("p", { style: { margin: "8px 0 0", fontWeight: 600 }, children: "Thanks for your feedback!" })
294
- ] }) : /* @__PURE__ */ l.jsxs(l.Fragment, { children: [
295
- /* @__PURE__ */ l.jsx("p", { style: { margin: "0 0 12px", fontWeight: 600 }, children: f ?? "How was your experience?" }),
296
- /* @__PURE__ */ l.jsx("div", { style: { display: "flex", gap: 6, marginBottom: 12 }, children: [1, 2, 3, 4, 5].map((b) => /* @__PURE__ */ l.jsx(
365
+ i && /* @__PURE__ */ t.jsx("div", { style: { background: "#fff", border: "1px solid #e5e7eb", borderRadius: 12, padding: 16, width: 280, boxShadow: "0 10px 25px rgba(0,0,0,0.15)" }, children: n ? /* @__PURE__ */ t.jsxs("div", { style: { textAlign: "center", padding: 16 }, children: [
366
+ /* @__PURE__ */ t.jsx("p", { style: { fontSize: 28, margin: 0 }, children: "🎉" }),
367
+ /* @__PURE__ */ t.jsx("p", { style: { margin: "8px 0 0", fontWeight: 600 }, children: "Thanks for your feedback!" })
368
+ ] }) : /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
369
+ /* @__PURE__ */ t.jsx("p", { style: { margin: "0 0 12px", fontWeight: 600 }, children: k ?? "How was your experience?" }),
370
+ /* @__PURE__ */ t.jsx("div", { style: { display: "flex", gap: 6, marginBottom: 12 }, children: [1, 2, 3, 4, 5].map((v) => /* @__PURE__ */ t.jsx(
297
371
  "button",
298
372
  {
299
- onClick: () => m(b),
300
- style: { background: "none", border: "none", cursor: "pointer", fontSize: 24, opacity: c !== null && b <= c ? 1 : 0.3 },
373
+ onClick: () => g(v),
374
+ style: { background: "none", border: "none", cursor: "pointer", fontSize: 24, opacity: p !== null && v <= p ? 1 : 0.3 },
301
375
  children: "⭐"
302
376
  },
303
- b
377
+ v
304
378
  )) }),
305
- /* @__PURE__ */ l.jsx(
379
+ /* @__PURE__ */ t.jsx(
306
380
  "textarea",
307
381
  {
308
- value: _,
309
- onChange: (b) => g(b.target.value),
382
+ value: x,
383
+ onChange: (v) => y(v.target.value),
310
384
  placeholder: "Tell us more (optional)...",
311
385
  rows: 3,
312
386
  style: { width: "100%", padding: 8, border: "1px solid #d1d5db", borderRadius: 8, resize: "none", fontSize: 14 }
313
387
  }
314
388
  ),
315
- /* @__PURE__ */ l.jsx(
389
+ /* @__PURE__ */ t.jsx(
316
390
  "button",
317
391
  {
318
- onClick: T,
392
+ onClick: b,
319
393
  style: { marginTop: 10, width: "100%", background: "#6366f1", color: "#fff", border: "none", borderRadius: 8, padding: 10, fontWeight: 600, cursor: "pointer" },
320
394
  children: "Submit Feedback"
321
395
  }
@@ -324,7 +398,8 @@ function pe({ id: u, placeholder: f, position: s = "bottom-right" }) {
324
398
  ] });
325
399
  }
326
400
  export {
327
- be as FeedPulseProvider,
328
- pe as FeedPulseWidget,
329
- fe as useFeedPulse
401
+ me as ConsentBanner,
402
+ ke as FeedPulseProvider,
403
+ he as FeedPulseWidget,
404
+ ge as useFeedPulse
330
405
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tekibo/feedpulse-sdk",
3
- "version": "0.4.1",
3
+ "version": "0.5.1",
4
4
  "description": "Embeddable analytics and feedback SDK for FeedPulse",
5
5
  "exports": {
6
6
  ".": {
@@ -38,7 +38,11 @@
38
38
  "optional": true
39
39
  }
40
40
  },
41
+ "dependencies": {
42
+ "js-cookie": "^3.0.5"
43
+ },
41
44
  "devDependencies": {
45
+ "@types/js-cookie": "^3.0.6",
42
46
  "@vitejs/plugin-react": "^4.7.0",
43
47
  "@vitejs/plugin-vue": "^6.0.1",
44
48
  "react": "^19.1.1",