@nemme/js-sdk 0.2.1 → 0.2.2

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
@@ -2,7 +2,7 @@ var Dt = Object.defineProperty;
2
2
  var At = (i, e, t) => e in i ? Dt(i, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : i[e] = t;
3
3
  var v = (i, e, t) => At(i, typeof e != "symbol" ? e + "" : e, t);
4
4
  import * as p from "react";
5
- import ct, { createContext as Oe, useContext as dt, useCallback as U, useState as ne, useRef as ut, useEffect as ue, useMemo as Vt, createElement as be } from "react";
5
+ import ct, { createContext as Oe, useContext as dt, useCallback as z, useState as ne, useRef as ut, useEffect as ue, useMemo as Vt, createElement as be } from "react";
6
6
  import It from "react-dom";
7
7
  var le = {}, Fe;
8
8
  function Ht() {
@@ -41,14 +41,14 @@ const qt = (i, e, t, n) => {
41
41
  t.forEach((r) => {
42
42
  i.options.ns.indexOf(r) < 0 && i.options.ns.push(r);
43
43
  }), i.loadLanguages(e, ht(i, n));
44
- }, zt = (i, e, t = {}) => !e.languages || !e.languages.length ? (we(e, "NO_LANGUAGES", "i18n.languages were undefined or empty", {
44
+ }, Ut = (i, e, t = {}) => !e.languages || !e.languages.length ? (we(e, "NO_LANGUAGES", "i18n.languages were undefined or empty", {
45
45
  languages: e.languages
46
46
  }), !0) : e.hasLoadedNamespace(i, {
47
47
  lng: t.lng,
48
48
  precheck: (n, r) => {
49
49
  if (t.bindI18n && t.bindI18n.indexOf("languageChanging") > -1 && n.services.backendConnector.backend && n.isLanguageChangingTo && !r(n.isLanguageChangingTo, i)) return !1;
50
50
  }
51
- }), K = (i) => typeof i == "string", Ut = (i) => typeof i == "object" && i !== null, Kt = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g, _t = {
51
+ }), K = (i) => typeof i == "string", zt = (i) => typeof i == "object" && i !== null, Kt = /&(?:amp|#38|lt|#60|gt|#62|apos|#39|quot|#34|nbsp|#160|copy|#169|reg|#174|hellip|#8230|#x2F|#47);/g, _t = {
52
52
  "&amp;": "&",
53
53
  "&#38;": "&",
54
54
  "&lt;": "<",
@@ -113,7 +113,7 @@ const tn = (i, e) => {
113
113
  return ue(() => {
114
114
  t.current = i;
115
115
  }, [i, e]), t.current;
116
- }, pt = (i, e, t, n) => i.getFixedT(e, t, n), nn = (i, e, t, n) => U(pt(i, e, t, n), [i, e, t, n]), Pe = (i, e = {}) => {
116
+ }, pt = (i, e, t, n) => i.getFixedT(e, t, n), nn = (i, e, t, n) => z(pt(i, e, t, n), [i, e, t, n]), Pe = (i, e = {}) => {
117
117
  var P, N, V, j;
118
118
  const {
119
119
  i18n: t
@@ -123,7 +123,7 @@ const tn = (i, e) => {
123
123
  } = dt(gt) || {}, s = t || n || Xt();
124
124
  if (s && !s.reportNamespaces && (s.reportNamespaces = new en()), !s) {
125
125
  we(s, "NO_I18NEXT_INSTANCE", "useTranslation: You will need to pass in an i18next instance by using initReactI18next");
126
- const O = (k, T) => K(T) ? T : Ut(T) && K(T.defaultValue) ? T.defaultValue : Array.isArray(k) ? k[k.length - 1] : k, E = [O, {}, !1];
126
+ const O = (k, T) => K(T) ? T : zt(T) && K(T.defaultValue) ? T.defaultValue : Array.isArray(k) ? k[k.length - 1] : k, E = [O, {}, !1];
127
127
  return E.t = O, E.i18n = {}, E.ready = !1, E;
128
128
  }
129
129
  (P = s.options.react) != null && P.wait && we(s, "DEPRECATED_OPTION", "useTranslation: It seems you are still using the old wait option, you may migrate to the new useSuspense behaviour.");
@@ -137,7 +137,7 @@ const tn = (i, e) => {
137
137
  } = a;
138
138
  let l = r || ((N = s.options) == null ? void 0 : N.defaultNS);
139
139
  l = K(l) ? [l] : l || ["translation"], (j = (V = s.reportNamespaces).addUsedNamespaces) == null || j.call(V, l);
140
- const d = (s.isInitialized || s.initializedStoreOnce) && l.every((O) => zt(O, s, a)), u = nn(s, e.lng || null, a.nsMode === "fallback" ? l : l[0], c), h = () => u, f = () => pt(s, e.lng || null, a.nsMode === "fallback" ? l : l[0], c), [g, y] = ne(h);
140
+ const d = (s.isInitialized || s.initializedStoreOnce) && l.every((O) => Ut(O, s, a)), u = nn(s, e.lng || null, a.nsMode === "fallback" ? l : l[0], c), h = () => u, f = () => pt(s, e.lng || null, a.nsMode === "fallback" ? l : l[0], c), [g, y] = ne(h);
141
141
  let b = l.join();
142
142
  e.lng && (b = `${e.lng}${b}`);
143
143
  const w = tn(b), S = ut(!0);
@@ -315,7 +315,7 @@ const on = ({ step: i, form: e, formState: t, onDismiss: n, onNextStep: r, onPre
315
315
  responses: {},
316
316
  currentStep: 0,
317
317
  startedAt: /* @__PURE__ */ new Date()
318
- }), o = U((u, h) => {
318
+ }), o = z((u, h) => {
319
319
  a((f) => ({
320
320
  ...f,
321
321
  responses: {
@@ -323,12 +323,12 @@ const on = ({ step: i, form: e, formState: t, onDismiss: n, onNextStep: r, onPre
323
323
  [u]: h
324
324
  }
325
325
  }));
326
- }, []), c = U((u) => {
326
+ }, []), c = z((u) => {
327
327
  a((h) => ({
328
328
  ...h,
329
329
  currentStep: u
330
330
  }));
331
- }, []), l = U(() => {
331
+ }, []), l = z(() => {
332
332
  if (s.currentStep < r)
333
333
  c(s.currentStep + 1);
334
334
  else {
@@ -338,7 +338,7 @@ const on = ({ step: i, form: e, formState: t, onDismiss: n, onNextStep: r, onPre
338
338
  };
339
339
  t(u);
340
340
  }
341
- }, [s, r, c, t]), d = U(() => {
341
+ }, [s, r, c, t]), d = z(() => {
342
342
  s.currentStep > 0 && c(s.currentStep - 1);
343
343
  }, [s.currentStep, c]);
344
344
  return /* @__PURE__ */ m.jsx("div", { className: "flex flex-col justify-center items-center absolute inset-0 bg-overlay-background-default-light dark:bg-overlay-background-default-dark", children: /* @__PURE__ */ m.jsx(
@@ -1288,7 +1288,7 @@ function qn(i) {
1288
1288
  return { value: a, rest: o };
1289
1289
  };
1290
1290
  }
1291
- const zn = /^(\d+)(th|st|nd|rd)?/i, Un = /\d+/i, Kn = {
1291
+ const Un = /^(\d+)(th|st|nd|rd)?/i, zn = /\d+/i, Kn = {
1292
1292
  narrow: /^(b|a)/i,
1293
1293
  abbreviated: /^(b\.?\s?c\.?|b\.?\s?c\.?\s?e\.?|a\.?\s?d\.?|c\.?\s?e\.?)/i,
1294
1294
  wide: /^(before christ|before common era|anno domini|common era)/i
@@ -1357,8 +1357,8 @@ const zn = /^(\d+)(th|st|nd|rd)?/i, Un = /\d+/i, Kn = {
1357
1357
  }
1358
1358
  }, tr = {
1359
1359
  ordinalNumber: qn({
1360
- matchPattern: zn,
1361
- parsePattern: Un,
1360
+ matchPattern: Un,
1361
+ parsePattern: zn,
1362
1362
  valueCallback: (i) => parseInt(i, 10)
1363
1363
  }),
1364
1364
  era: ee({
@@ -1446,21 +1446,21 @@ const rr = {
1446
1446
  i = n, e = r;
1447
1447
  });
1448
1448
  return t.resolve = i, t.reject = e, t;
1449
- }, ze = (i) => i == null ? "" : "" + i, lr = (i, e, t) => {
1449
+ }, Ue = (i) => i == null ? "" : "" + i, lr = (i, e, t) => {
1450
1450
  i.forEach((n) => {
1451
1451
  e[n] && (t[n] = e[n]);
1452
1452
  });
1453
- }, cr = /###/g, Ue = (i) => i && i.indexOf("###") > -1 ? i.replace(cr, ".") : i, Ke = (i) => !i || x(i), re = (i, e, t) => {
1453
+ }, cr = /###/g, ze = (i) => i && i.indexOf("###") > -1 ? i.replace(cr, ".") : i, Ke = (i) => !i || x(i), re = (i, e, t) => {
1454
1454
  const n = x(e) ? e.split(".") : e;
1455
1455
  let r = 0;
1456
1456
  for (; r < n.length - 1; ) {
1457
1457
  if (Ke(i)) return {};
1458
- const s = Ue(n[r]);
1458
+ const s = ze(n[r]);
1459
1459
  !i[s] && t && (i[s] = new t()), Object.prototype.hasOwnProperty.call(i, s) ? i = i[s] : i = {}, ++r;
1460
1460
  }
1461
1461
  return Ke(i) ? {} : {
1462
1462
  obj: i,
1463
- k: Ue(n[r])
1463
+ k: ze(n[r])
1464
1464
  };
1465
1465
  }, _e = (i, e, t) => {
1466
1466
  const {
@@ -1852,14 +1852,14 @@ class fe extends pe {
1852
1852
  for (let $ = 0; $ < oe.length; $++)
1853
1853
  J.push(oe[$]);
1854
1854
  else this.options.saveMissingTo === "all" ? J = this.languageUtils.toResolveHierarchy(r.lng || this.language) : J.push(r.lng || this.language);
1855
- const $e = ($, z, G) => {
1855
+ const $e = ($, U, G) => {
1856
1856
  var Re;
1857
1857
  const Te = N && G !== g ? G : D;
1858
- this.options.missingKeyHandler ? this.options.missingKeyHandler($, l, z, Te, I, r) : (Re = this.backendConnector) != null && Re.saveMissing && this.backendConnector.saveMissing($, l, z, Te, I, r), this.emit("missingKey", $, l, z, g);
1858
+ this.options.missingKeyHandler ? this.options.missingKeyHandler($, l, U, Te, I, r) : (Re = this.backendConnector) != null && Re.saveMissing && this.backendConnector.saveMissing($, l, U, Te, I, r), this.emit("missingKey", $, l, U, g);
1859
1859
  };
1860
1860
  this.options.saveMissing && (this.options.saveMissingPlurals && P ? J.forEach(($) => {
1861
- const z = this.pluralResolver.getSuffixes($, r);
1862
- O && r[`defaultValue${this.options.pluralSeparator}zero`] && z.indexOf(`${this.options.pluralSeparator}zero`) < 0 && z.push(`${this.options.pluralSeparator}zero`), z.forEach((G) => {
1861
+ const U = this.pluralResolver.getSuffixes($, r);
1862
+ O && r[`defaultValue${this.options.pluralSeparator}zero`] && U.indexOf(`${this.options.pluralSeparator}zero`) < 0 && U.push(`${this.options.pluralSeparator}zero`), U.forEach((G) => {
1863
1863
  $e([$], o + G, r[`defaultValue${G}`] || E);
1864
1864
  });
1865
1865
  }) : $e(J, o, E));
@@ -2186,7 +2186,7 @@ class kr {
2186
2186
  continue;
2187
2187
  } else
2188
2188
  this.logger.warn(`missed to pass in variable ${y} for interpolating ${e}`), a = "";
2189
- else !x(a) && !this.useRawValueToEscape && (a = ze(a));
2189
+ else !x(a) && !this.useRawValueToEscape && (a = Ue(a));
2190
2190
  const b = g.safeValue(a);
2191
2191
  if (e = e.replace(s[0], b), u ? (g.regex.lastIndex += a.length, g.regex.lastIndex -= s[0].length) : g.regex.lastIndex = 0, o++, o >= this.maxReplaces)
2192
2192
  break;
@@ -2220,7 +2220,7 @@ class kr {
2220
2220
  }, a = a.replace && !x(a.replace) ? a.replace : a, a.applyPostProcessor = !1, delete a.defaultValue;
2221
2221
  const l = /{.*}/.test(r[1]) ? r[1].lastIndexOf("}") + 1 : r[1].indexOf(this.formatSeparator);
2222
2222
  if (l !== -1 && (c = r[1].slice(l).split(this.formatSeparator).map((d) => d.trim()).filter(Boolean), r[1] = r[1].slice(0, l)), s = t(o.call(this, r[1].trim(), a), a), s && r[0] === e && !x(s)) return s;
2223
- x(s) || (s = ze(s)), s || (this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`), s = ""), c.length && (s = c.reduce((d, u) => this.format(d, u, n.lng, {
2223
+ x(s) || (s = Ue(s)), s || (this.logger.warn(`missed to resolve ${r[1]} for nesting ${e}`), s = ""), c.length && (s = c.reduce((d, u) => this.format(d, u, n.lng, {
2224
2224
  ...n,
2225
2225
  interpolationkey: r[1].trim()
2226
2226
  }), s.trim())), e = e.replace(r[0], s), this.regexp.lastIndex = 0;
@@ -3062,7 +3062,7 @@ try {
3062
3062
  }
3063
3063
  const Ct = ["querystring", "cookie", "localStorage", "sessionStorage", "navigator", "htmlTag"];
3064
3064
  Nt || Ct.splice(1, 1);
3065
- const zr = () => ({
3065
+ const Ur = () => ({
3066
3066
  order: Ct,
3067
3067
  lookupQuerystring: "lng",
3068
3068
  lookupCookie: "i18next",
@@ -3084,7 +3084,7 @@ class jt {
3084
3084
  let e = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
3085
3085
  languageUtils: {}
3086
3086
  }, t = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {}, n = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
3087
- this.services = e, this.options = $r(t, this.options || {}, zr()), typeof this.options.convertDetectedLanguage == "string" && this.options.convertDetectedLanguage.indexOf("15897") > -1 && (this.options.convertDetectedLanguage = (r) => r.replace("-", "_")), this.options.lookupFromUrlIndex && (this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex), this.i18nOptions = n, this.addDetector(Fr), this.addDetector(Mr), this.addDetector(Ar), this.addDetector(Vr), this.addDetector(Ir), this.addDetector(Hr), this.addDetector(Br), this.addDetector(qr), this.addDetector(Dr);
3087
+ this.services = e, this.options = $r(t, this.options || {}, Ur()), typeof this.options.convertDetectedLanguage == "string" && this.options.convertDetectedLanguage.indexOf("15897") > -1 && (this.options.convertDetectedLanguage = (r) => r.replace("-", "_")), this.options.lookupFromUrlIndex && (this.options.lookupFromPathIndex = this.options.lookupFromUrlIndex), this.i18nOptions = n, this.addDetector(Fr), this.addDetector(Mr), this.addDetector(Ar), this.addDetector(Vr), this.addDetector(Ir), this.addDetector(Hr), this.addDetector(Br), this.addDetector(qr), this.addDetector(Dr);
3088
3088
  }
3089
3089
  addDetector(e) {
3090
3090
  return this.detectors[e.name] = e, this;
@@ -3109,8 +3109,8 @@ jt.type = "languageDetector";
3109
3109
  const $t = {
3110
3110
  apiBaseUrl: "https://api.nemme.io",
3111
3111
  debug: !1
3112
- }, Ur = "Previous", Kr = "Next", _r = {
3113
- Previous: Ur,
3112
+ }, zr = "Previous", Kr = "Next", _r = {
3113
+ Previous: zr,
3114
3114
  Next: Kr,
3115
3115
  "Type your answer here": "Type your answer here",
3116
3116
  "Max {{maxCharacters}} characters": "Max {{maxCharacters}} characters"
@@ -3682,13 +3682,13 @@ const Rt = (i) => new Ce(i), Ft = Oe(void 0), ai = ({
3682
3682
  throw new Error("useNemmeContext must be used within a NemmeProvider");
3683
3683
  return i;
3684
3684
  }, oi = () => {
3685
- const { client: i, isInitialized: e, error: t } = Qr(), n = U(async (s) => {
3685
+ const { client: i, isInitialized: e, error: t } = Qr(), n = z(async (s) => {
3686
3686
  if (!i || !e) {
3687
3687
  console.warn("Nemme client not initialized");
3688
3688
  return;
3689
3689
  }
3690
3690
  return i.track(s);
3691
- }, [i, e]), r = U(async () => {
3691
+ }, [i, e]), r = z(async () => {
3692
3692
  if (!i || !e) {
3693
3693
  console.warn("Nemme client not initialized");
3694
3694
  return;