@metricshift/react 1.0.1 → 1.0.3

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/index.esm.js CHANGED
@@ -1,4 +1,4 @@
1
- import $e, { useState as $, useRef as ze, useEffect as Me, createContext as br, useContext as gr } from "react";
1
+ import $e, { useState as $, useRef as Ae, useEffect as Me, createContext as br, useContext as gr } from "react";
2
2
  var ve = { exports: {} }, J = {};
3
3
  /**
4
4
  * @license React
@@ -13,17 +13,17 @@ var We;
13
13
  function xr() {
14
14
  if (We) return J;
15
15
  We = 1;
16
- var d = $e, k = Symbol.for("react.element"), O = Symbol.for("react.fragment"), f = Object.prototype.hasOwnProperty, p = d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
16
+ var d = $e, _ = Symbol.for("react.element"), O = Symbol.for("react.fragment"), f = Object.prototype.hasOwnProperty, p = d.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, o = { key: !0, ref: !0, __self: !0, __source: !0 };
17
17
  function F(E, b, T) {
18
- var y, R = {}, v = null, z = null;
19
- T !== void 0 && (v = "" + T), b.key !== void 0 && (v = "" + b.key), b.ref !== void 0 && (z = b.ref);
18
+ var y, R = {}, v = null, A = null;
19
+ T !== void 0 && (v = "" + T), b.key !== void 0 && (v = "" + b.key), b.ref !== void 0 && (A = b.ref);
20
20
  for (y in b) f.call(b, y) && !o.hasOwnProperty(y) && (R[y] = b[y]);
21
21
  if (E && E.defaultProps) for (y in b = E.defaultProps, b) R[y] === void 0 && (R[y] = b[y]);
22
- return { $$typeof: k, type: E, key: v, ref: z, props: R, _owner: p.current };
22
+ return { $$typeof: _, type: E, key: v, ref: A, props: R, _owner: p.current };
23
23
  }
24
24
  return J.Fragment = O, J.jsx = F, J.jsxs = F, J;
25
25
  }
26
- var K = {};
26
+ var H = {};
27
27
  /**
28
28
  * @license React
29
29
  * react-jsx-runtime.development.js
@@ -36,7 +36,7 @@ var K = {};
36
36
  var Ye;
37
37
  function yr() {
38
38
  return Ye || (Ye = 1, process.env.NODE_ENV !== "production" && function() {
39
- var d = $e, k = Symbol.for("react.element"), O = Symbol.for("react.portal"), f = Symbol.for("react.fragment"), p = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), F = Symbol.for("react.provider"), E = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), y = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), v = Symbol.for("react.lazy"), z = Symbol.for("react.offscreen"), D = Symbol.iterator, C = "@@iterator";
39
+ var d = $e, _ = Symbol.for("react.element"), O = Symbol.for("react.portal"), f = Symbol.for("react.fragment"), p = Symbol.for("react.strict_mode"), o = Symbol.for("react.profiler"), F = Symbol.for("react.provider"), E = Symbol.for("react.context"), b = Symbol.for("react.forward_ref"), T = Symbol.for("react.suspense"), y = Symbol.for("react.suspense_list"), R = Symbol.for("react.memo"), v = Symbol.for("react.lazy"), A = Symbol.for("react.offscreen"), D = Symbol.iterator, C = "@@iterator";
40
40
  function B(e) {
41
41
  if (e === null || typeof e != "object")
42
42
  return null;
@@ -61,10 +61,10 @@ function yr() {
61
61
  c.unshift("Warning: " + r), Function.prototype.apply.call(console[e], console, c);
62
62
  }
63
63
  }
64
- var i = !1, j = !1, H = !1, re = !1, te = !1, G;
64
+ var i = !1, j = !1, K = !1, re = !1, te = !1, G;
65
65
  G = Symbol.for("react.module.reference");
66
66
  function ne(e) {
67
- return !!(typeof e == "string" || typeof e == "function" || e === f || e === o || te || e === p || e === T || e === y || re || e === z || i || j || H || typeof e == "object" && e !== null && (e.$$typeof === v || e.$$typeof === R || e.$$typeof === F || e.$$typeof === E || e.$$typeof === b || // This needs to include all possible module reference object
67
+ return !!(typeof e == "string" || typeof e == "function" || e === f || e === o || te || e === p || e === T || e === y || re || e === A || i || j || K || typeof e == "object" && e !== null && (e.$$typeof === v || e.$$typeof === R || e.$$typeof === F || e.$$typeof === E || e.$$typeof === b || // This needs to include all possible module reference object
68
68
  // types supported by any Flight configuration anywhere since
69
69
  // we don't know which Flight build this will end up being used
70
70
  // with.
@@ -125,7 +125,7 @@ function yr() {
125
125
  }
126
126
  return null;
127
127
  }
128
- var A = Object.assign, g = 0, M, W, be, ge, xe, ye, he;
128
+ var z = Object.assign, g = 0, M, W, be, ge, xe, ye, he;
129
129
  function me() {
130
130
  }
131
131
  me.__reactDisabledLog = !0;
@@ -161,25 +161,25 @@ function yr() {
161
161
  writable: !0
162
162
  };
163
163
  Object.defineProperties(console, {
164
- log: A({}, e, {
164
+ log: z({}, e, {
165
165
  value: M
166
166
  }),
167
- info: A({}, e, {
167
+ info: z({}, e, {
168
168
  value: W
169
169
  }),
170
- warn: A({}, e, {
170
+ warn: z({}, e, {
171
171
  value: be
172
172
  }),
173
- error: A({}, e, {
173
+ error: z({}, e, {
174
174
  value: ge
175
175
  }),
176
- group: A({}, e, {
176
+ group: z({}, e, {
177
177
  value: xe
178
178
  }),
179
- groupCollapsed: A({}, e, {
179
+ groupCollapsed: z({}, e, {
180
180
  value: ye
181
181
  }),
182
- groupEnd: A({}, e, {
182
+ groupEnd: z({}, e, {
183
183
  value: he
184
184
  })
185
185
  });
@@ -232,29 +232,29 @@ function yr() {
232
232
  }), typeof Reflect == "object" && Reflect.construct) {
233
233
  try {
234
234
  Reflect.construct(l, []);
235
- } catch (_) {
236
- a = _;
235
+ } catch (k) {
236
+ a = k;
237
237
  }
238
238
  Reflect.construct(e, [], l);
239
239
  } else {
240
240
  try {
241
241
  l.call();
242
- } catch (_) {
243
- a = _;
242
+ } catch (k) {
243
+ a = k;
244
244
  }
245
245
  e.call(l.prototype);
246
246
  }
247
247
  } else {
248
248
  try {
249
249
  throw Error();
250
- } catch (_) {
251
- a = _;
250
+ } catch (k) {
251
+ a = k;
252
252
  }
253
253
  e();
254
254
  }
255
- } catch (_) {
256
- if (_ && a && typeof _.stack == "string") {
257
- for (var s = _.stack.split(`
255
+ } catch (k) {
256
+ if (k && a && typeof k.stack == "string") {
257
+ for (var s = k.stack.split(`
258
258
  `), S = a.stack.split(`
259
259
  `), x = s.length - 1, m = S.length - 1; x >= 1 && m >= 0 && s[x] !== S[m]; )
260
260
  m--;
@@ -340,11 +340,11 @@ function yr() {
340
340
  }
341
341
  }
342
342
  }
343
- var Ke = Array.isArray;
343
+ var He = Array.isArray;
344
344
  function le(e) {
345
- return Ke(e);
345
+ return He(e);
346
346
  }
347
- function He(e) {
347
+ function Ke(e) {
348
348
  {
349
349
  var r = typeof Symbol == "function" && Symbol.toStringTag, t = r && e[Symbol.toStringTag] || e.constructor.name || "Object";
350
350
  return t;
@@ -352,17 +352,17 @@ function yr() {
352
352
  }
353
353
  function Ge(e) {
354
354
  try {
355
- return _e(e), !1;
355
+ return ke(e), !1;
356
356
  } catch {
357
357
  return !0;
358
358
  }
359
359
  }
360
- function _e(e) {
360
+ function ke(e) {
361
361
  return "" + e;
362
362
  }
363
- function ke(e) {
363
+ function _e(e) {
364
364
  if (Ge(e))
365
- return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", He(e)), _e(e);
365
+ return h("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.", Ke(e)), ke(e);
366
366
  }
367
367
  var je = P.ReactCurrentOwner, Xe = {
368
368
  key: !0,
@@ -414,7 +414,7 @@ function yr() {
414
414
  var nr = function(e, r, t, a, u, c, l) {
415
415
  var s = {
416
416
  // This tag allows us to uniquely identify this as a React Element
417
- $$typeof: k,
417
+ $$typeof: _,
418
418
  // Built-in properties that belong on the element
419
419
  type: e,
420
420
  key: r,
@@ -443,7 +443,7 @@ function yr() {
443
443
  function ar(e, r, t, a, u) {
444
444
  {
445
445
  var c, l = {}, s = null, S = null;
446
- t !== void 0 && (ke(t), s = "" + t), Ze(r) && (ke(r.key), s = "" + r.key), Qe(r) && (S = r.ref, er(r, u));
446
+ t !== void 0 && (_e(t), s = "" + t), Ze(r) && (_e(r.key), s = "" + r.key), Qe(r) && (S = r.ref, er(r, u));
447
447
  for (c in r)
448
448
  q.call(r, c) && !Xe.hasOwnProperty(c) && (l[c] = r[c]);
449
449
  if (e && e.defaultProps) {
@@ -469,7 +469,7 @@ function yr() {
469
469
  var ce;
470
470
  ce = !1;
471
471
  function fe(e) {
472
- return typeof e == "object" && e !== null && e.$$typeof === k;
472
+ return typeof e == "object" && e !== null && e.$$typeof === _;
473
473
  }
474
474
  function Pe() {
475
475
  {
@@ -569,7 +569,7 @@ Check the top-level render call using <` + t + ">.");
569
569
  }
570
570
  }
571
571
  var De = {};
572
- function Ae(e, r, t, a, u, c) {
572
+ function ze(e, r, t, a, u, c) {
573
573
  {
574
574
  var l = ne(e);
575
575
  if (!l) {
@@ -578,7 +578,7 @@ Check the top-level render call using <` + t + ">.");
578
578
  var S = or();
579
579
  S ? s += S : s += Pe();
580
580
  var x;
581
- e === null ? x = "null" : le(e) ? x = "array" : e !== void 0 && e.$$typeof === k ? (x = "<" + (I(e.type) || "Unknown") + " />", s = " Did you accidentally export a JSX literal instead of a component?") : x = typeof e, h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", x, s);
581
+ e === null ? x = "null" : le(e) ? x = "array" : e !== void 0 && e.$$typeof === _ ? (x = "<" + (I(e.type) || "Unknown") + " />", s = " Did you accidentally export a JSX literal instead of a component?") : x = typeof e, h("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s", x, s);
582
582
  }
583
583
  var m = ar(e, r, t, u, c);
584
584
  if (m == null)
@@ -597,11 +597,11 @@ Check the top-level render call using <` + t + ">.");
597
597
  Ie(w, e);
598
598
  }
599
599
  if (q.call(r, "key")) {
600
- var Y = I(e), _ = Object.keys(r).filter(function(vr) {
600
+ var Y = I(e), k = Object.keys(r).filter(function(vr) {
601
601
  return vr !== "key";
602
- }), de = _.length > 0 ? "{key: someKey, " + _.join(": ..., ") + ": ...}" : "{key: someKey}";
602
+ }), de = k.length > 0 ? "{key: someKey, " + k.join(": ..., ") + ": ...}" : "{key: someKey}";
603
603
  if (!De[Y + de]) {
604
- var pr = _.length > 0 ? "{" + _.join(": ..., ") + ": ...}" : "{}";
604
+ var pr = k.length > 0 ? "{" + k.join(": ..., ") + ": ...}" : "{}";
605
605
  h(`A props object containing a "key" prop is being spread into JSX:
606
606
  let props = %s;
607
607
  <%s {...props} />
@@ -614,20 +614,20 @@ React keys must be passed directly to JSX without using spread:
614
614
  }
615
615
  }
616
616
  function ur(e, r, t) {
617
- return Ae(e, r, t, !0);
617
+ return ze(e, r, t, !0);
618
618
  }
619
619
  function cr(e, r, t) {
620
- return Ae(e, r, t, !1);
620
+ return ze(e, r, t, !1);
621
621
  }
622
622
  var fr = cr, dr = ur;
623
- K.Fragment = f, K.jsx = fr, K.jsxs = dr;
624
- }()), K;
623
+ H.Fragment = f, H.jsx = fr, H.jsxs = dr;
624
+ }()), H;
625
625
  }
626
626
  process.env.NODE_ENV === "production" ? ve.exports = xr() : ve.exports = yr();
627
627
  var n = ve.exports;
628
628
  const hr = ({
629
629
  isOpen: d,
630
- onClose: k,
630
+ onClose: _,
631
631
  onSubmit: O
632
632
  }) => {
633
633
  const [f, p] = $({
@@ -636,7 +636,7 @@ const hr = ({
636
636
  feedbackType: "general",
637
637
  userEmail: "",
638
638
  userName: ""
639
- }), [o, F] = $(!1), [E, b] = $("idle"), [T, y] = $(""), [R, v] = $(!1), z = ze(null), D = ze(null);
639
+ }), [o, F] = $(!1), [E, b] = $("idle"), [T, y] = $(""), [R, v] = $(!1), A = Ae(null), D = Ae(null);
640
640
  Me(() => (d ? (v(!0), document.body.style.overflow = "hidden", setTimeout(() => {
641
641
  var i;
642
642
  (i = D.current) == null || i.focus();
@@ -652,7 +652,7 @@ const hr = ({
652
652
  }, [d, o]);
653
653
  const C = () => {
654
654
  v(!1), setTimeout(() => {
655
- k(), setTimeout(() => {
655
+ _(), setTimeout(() => {
656
656
  p({
657
657
  text: "",
658
658
  rating: void 0,
@@ -719,7 +719,7 @@ const hr = ({
719
719
  children: /* @__PURE__ */ n.jsxs(
720
720
  "div",
721
721
  {
722
- ref: z,
722
+ ref: A,
723
723
  style: L,
724
724
  onClick: (i) => i.stopPropagation(),
725
725
  children: [
@@ -1047,16 +1047,16 @@ const hr = ({
1047
1047
  }
1048
1048
  );
1049
1049
  };
1050
- async function mr(d, k, O) {
1050
+ async function mr(d, _, O) {
1051
1051
  const f = {
1052
1052
  "Content-Type": "application/json"
1053
1053
  };
1054
- O && (f["X-API-Key"] = O);
1054
+ O && (f.Authorization = `Bearer ${O}`);
1055
1055
  try {
1056
1056
  const p = await fetch(`${d}/api/feedback`, {
1057
1057
  method: "POST",
1058
1058
  headers: f,
1059
- body: JSON.stringify(k)
1059
+ body: JSON.stringify(_)
1060
1060
  });
1061
1061
  if (!p.ok) {
1062
1062
  const o = await p.json().catch(() => ({}));
@@ -1069,8 +1069,8 @@ async function mr(d, k, O) {
1069
1069
  }
1070
1070
  const Rr = ({
1071
1071
  projectId: d,
1072
- apiKey: k,
1073
- apiUrl: O = "http://localhost:3000",
1072
+ apiKey: _,
1073
+ apiUrl: O = "https://metricshift-sdk-be-production.up.railway.app",
1074
1074
  buttonText: f = "Feedback",
1075
1075
  showIcon: p = !0,
1076
1076
  position: o = "bottom-right",
@@ -1081,13 +1081,13 @@ const Rr = ({
1081
1081
  customStyles: y,
1082
1082
  customClassName: R = "",
1083
1083
  disabled: v = !1,
1084
- autoOpen: z = !1,
1084
+ autoOpen: A = !1,
1085
1085
  onOpen: D,
1086
1086
  onClose: C,
1087
1087
  onSuccess: B,
1088
1088
  onError: P
1089
1089
  }) => {
1090
- const [h, L] = $(z), [i, j] = $(!1), H = () => {
1090
+ const [h, L] = $(A), [i, j] = $(!1), K = () => {
1091
1091
  v || (L(!0), D == null || D());
1092
1092
  }, re = () => {
1093
1093
  L(!1), C == null || C();
@@ -1103,7 +1103,7 @@ const Rr = ({
1103
1103
  user_email: g.userEmail,
1104
1104
  user_name: g.userName,
1105
1105
  feedback_type: g.feedbackType
1106
- }, W = await mr(O, M, k);
1106
+ }, W = await mr(O, M, _);
1107
1107
  B && (W != null && W.id) && B(W.id);
1108
1108
  } catch (M) {
1109
1109
  throw P && M instanceof Error && P(M), M;
@@ -1155,7 +1155,7 @@ const Rr = ({
1155
1155
  transform: i && !v ? "translateY(-2px)" : "translateY(0)",
1156
1156
  outline: "none",
1157
1157
  ...y
1158
- }, A = {
1158
+ }, z = {
1159
1159
  fontSize: V.iconSize,
1160
1160
  lineHeight: 1,
1161
1161
  display: "flex",
@@ -1165,7 +1165,7 @@ const Rr = ({
1165
1165
  /* @__PURE__ */ n.jsxs(
1166
1166
  "button",
1167
1167
  {
1168
- onClick: H,
1168
+ onClick: K,
1169
1169
  onMouseEnter: () => !v && j(!0),
1170
1170
  onMouseLeave: () => !v && j(!1),
1171
1171
  disabled: v,
@@ -1177,10 +1177,10 @@ const Rr = ({
1177
1177
  role: "button",
1178
1178
  tabIndex: v ? -1 : 0,
1179
1179
  onKeyDown: (g) => {
1180
- !v && (g.key === "Enter" || g.key === " ") && (g.preventDefault(), H());
1180
+ !v && (g.key === "Enter" || g.key === " ") && (g.preventDefault(), K());
1181
1181
  },
1182
1182
  children: [
1183
- p && /* @__PURE__ */ n.jsx("span", { style: A, "aria-hidden": "true", children: "💬" }),
1183
+ p && /* @__PURE__ */ n.jsx("span", { style: z, "aria-hidden": "true", children: "💬" }),
1184
1184
  /* @__PURE__ */ n.jsx("span", { children: f })
1185
1185
  ]
1186
1186
  }
@@ -1199,12 +1199,12 @@ const Rr = ({
1199
1199
  if (!d)
1200
1200
  throw new Error("useMetricShift must be used within MetricShiftProvider");
1201
1201
  return d;
1202
- }, _r = ({
1202
+ }, kr = ({
1203
1203
  config: d,
1204
- children: k
1205
- }) => /* @__PURE__ */ n.jsx(Be.Provider, { value: d, children: k });
1204
+ children: _
1205
+ }) => /* @__PURE__ */ n.jsx(Be.Provider, { value: d, children: _ });
1206
1206
  let pe = null;
1207
- const kr = {
1207
+ const _r = {
1208
1208
  /**
1209
1209
  * Initialize the MetricShift SDK
1210
1210
  * @param config - SDK configuration
@@ -1226,8 +1226,8 @@ const kr = {
1226
1226
  export {
1227
1227
  Rr as FeedbackButton,
1228
1228
  hr as FeedbackModal,
1229
- kr as MetricShift,
1230
- _r as MetricShiftProvider,
1229
+ _r as MetricShift,
1230
+ kr as MetricShiftProvider,
1231
1231
  mr as submitFeedback,
1232
1232
  Sr as useMetricShift
1233
1233
  };