@kelet-ai/feedback-ui 1.1.4 → 1.2.0

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.
@@ -270,7 +270,7 @@ React keys must be passed directly to JSX without using spread:
270
270
  return a();
271
271
  }
272
272
  };
273
- var M, j = {}, H = E.react_stack_bottom_frame.bind(
273
+ var M, j = {}, K = E.react_stack_bottom_frame.bind(
274
274
  E,
275
275
  d
276
276
  )(), J = w(r(d)), re = {};
@@ -283,7 +283,7 @@ React keys must be passed directly to JSX without using spread:
283
283
  !1,
284
284
  S,
285
285
  W,
286
- $ ? Error("react-stack-top-frame") : H,
286
+ $ ? Error("react-stack-top-frame") : K,
287
287
  $ ? w(r(a)) : J
288
288
  );
289
289
  }, G.jsxs = function(a, C, D, S, W) {
@@ -295,7 +295,7 @@ React keys must be passed directly to JSX without using spread:
295
295
  !0,
296
296
  S,
297
297
  W,
298
- $ ? Error("react-stack-top-frame") : H,
298
+ $ ? Error("react-stack-top-frame") : K,
299
299
  $ ? w(r(a)) : J
300
300
  );
301
301
  };
@@ -365,18 +365,18 @@ function qe() {
365
365
  function ze() {
366
366
  return Z ? Date.now() - Z.timestamp > 1e4 ? (Z = null, null) : { ...Z } : null;
367
367
  }
368
- const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
368
+ const ae = Pe(null), Ye = "https://api.kelet.ai", wt = () => {
369
369
  const t = le(ae);
370
370
  if (!t)
371
371
  throw new Error("useKelet must be used within a KeletProvider");
372
372
  return t;
373
- }, Te = () => {
373
+ }, Ke = () => {
374
374
  const t = le(ae);
375
375
  return t ? t.feedback : (console.warn(
376
376
  "No FeedbackHandler found: defaultFeedbackHandler is not possible since there's no KeletProvider wrapping this call, and handler not provided"
377
377
  ), async () => {
378
378
  });
379
- }, wt = ({ apiKey: t, project: e, baseUrl: n, children: r }) => {
379
+ }, Te = Ke, kt = ({ apiKey: t, project: e, baseUrl: n, children: r }) => {
380
380
  ce(() => {
381
381
  qe();
382
382
  }, []);
@@ -533,8 +533,8 @@ const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
533
533
  if (w) {
534
534
  const M = w.querySelectorAll(
535
535
  'button, textarea, input, select, a[href], [tabindex]:not([tabindex="-1"])'
536
- ), j = M[0], H = M[M.length - 1];
537
- g.shiftKey && document.activeElement === j ? (g.preventDefault(), H?.focus()) : !g.shiftKey && document.activeElement === H && (g.preventDefault(), j?.focus());
536
+ ), j = M[0], K = M[M.length - 1];
537
+ g.shiftKey && document.activeElement === j ? (g.preventDefault(), K?.focus()) : !g.shiftKey && document.activeElement === K && (g.preventDefault(), j?.focus());
538
538
  }
539
539
  }
540
540
  },
@@ -563,7 +563,7 @@ const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
563
563
  trace_id: f
564
564
  };
565
565
  return /* @__PURE__ */ F.jsx(_e.Provider, { value: y, children: t });
566
- }, Ke = ({
566
+ }, Ue = ({
567
567
  asChild: t,
568
568
  children: e,
569
569
  onClick: n,
@@ -590,7 +590,7 @@ const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
590
590
  );
591
591
  }
592
592
  return /* @__PURE__ */ F.jsx("button", { ...c, children: typeof e == "function" ? e({ isSelected: h }) : e });
593
- }, Ue = ({
593
+ }, Je = ({
594
594
  asChild: t,
595
595
  children: e,
596
596
  onClick: n,
@@ -628,7 +628,7 @@ const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
628
628
  return p;
629
629
  }
630
630
  return /* @__PURE__ */ F.jsx("button", { ...E, children: typeof e == "function" ? e({ isSelected: x }) : e });
631
- }, Je = ({ asChild: t, children: e, ...n }) => {
631
+ }, Be = ({ asChild: t, children: e, ...n }) => {
632
632
  const { showPopover: r, handleKeyDown: o, popoverId: d, triggerId: f } = ne();
633
633
  if (!r)
634
634
  return null;
@@ -652,7 +652,7 @@ const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
652
652
  /* @__PURE__ */ F.jsx("div", { id: `${d}-description`, className: "sr-only", children: "Provide additional feedback for your downvote" }),
653
653
  e
654
654
  ] });
655
- }, Be = ({ asChild: t, value: e, onChange: n, ...r }) => {
655
+ }, Ve = ({ asChild: t, value: e, onChange: n, ...r }) => {
656
656
  const {
657
657
  feedbackText: o,
658
658
  handleTextareaChange: d,
@@ -674,7 +674,7 @@ const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
674
674
  r.children,
675
675
  te(h, r.children.props)
676
676
  ) : /* @__PURE__ */ F.jsx("textarea", { ...h });
677
- }, Ve = ({
677
+ }, Ge = ({
678
678
  asChild: t,
679
679
  children: e,
680
680
  onClick: n,
@@ -703,21 +703,21 @@ const ae = Pe(null), Ye = "https://api.kelet.ai", gt = () => {
703
703
  e,
704
704
  !c && /* @__PURE__ */ F.jsx("span", { id: "submit-help", className: "sr-only", children: "This will close the dialog without submitting feedback" })
705
705
  ] });
706
- }, kt = {
706
+ }, Et = {
707
707
  Root: He,
708
- UpvoteButton: Ke,
709
- DownvoteButton: Ue,
710
- Popover: Je,
711
- Textarea: Be,
712
- SubmitButton: Ve
708
+ UpvoteButton: Ue,
709
+ DownvoteButton: Je,
710
+ Popover: Be,
711
+ Textarea: Ve,
712
+ SubmitButton: Ge
713
713
  };
714
- var se = { exports: {} }, Ge = se.exports, ve;
715
- function Xe() {
714
+ var se = { exports: {} }, Xe = se.exports, ve;
715
+ function Ze() {
716
716
  return ve || (ve = 1, function(t, e) {
717
717
  (function(n, r) {
718
718
  var o = r(n);
719
719
  t.exports = o;
720
- })(Ge, function(n) {
720
+ })(Xe, function(n) {
721
721
  var r = ["N", "E", "A", "D"];
722
722
  function o(i, u) {
723
723
  i.super_ = u, i.prototype = Object.create(u.prototype, {
@@ -821,8 +821,8 @@ function Xe() {
821
821
  if (v.prefilter && v.prefilter(j, g))
822
822
  return;
823
823
  if (v.normalize) {
824
- var H = v.normalize(j, g, i, u);
825
- H && (i = H[0], u = H[1]);
824
+ var K = v.normalize(j, g, i, u);
825
+ K && (i = K[0], u = K[1]);
826
826
  }
827
827
  }
828
828
  }
@@ -1049,8 +1049,8 @@ function Xe() {
1049
1049
  });
1050
1050
  }(se)), se.exports;
1051
1051
  }
1052
- var Ce = Xe();
1053
- class Ze {
1052
+ var Ce = Ze();
1053
+ class Qe {
1054
1054
  diff(e, n, r = {}) {
1055
1055
  let o;
1056
1056
  typeof r == "function" ? (o = r, r = {}) : "callback" in r && (o = r.callback);
@@ -1181,9 +1181,9 @@ class Ze {
1181
1181
  return o;
1182
1182
  }
1183
1183
  }
1184
- class Qe extends Ze {
1184
+ class et extends Qe {
1185
1185
  constructor() {
1186
- super(...arguments), this.tokenize = tt;
1186
+ super(...arguments), this.tokenize = nt;
1187
1187
  }
1188
1188
  equals(e, n, r) {
1189
1189
  return r.ignoreWhitespace ? ((!r.newlineIsToken || !e.includes(`
@@ -1193,11 +1193,11 @@ class Qe extends Ze {
1193
1193
  `) && (n = n.slice(0, -1))), super.equals(e, n, r);
1194
1194
  }
1195
1195
  }
1196
- const et = new Qe();
1196
+ const tt = new et();
1197
1197
  function ye(t, e, n) {
1198
- return et.diff(t, e, n);
1198
+ return tt.diff(t, e, n);
1199
1199
  }
1200
- function tt(t, e) {
1200
+ function nt(t, e) {
1201
1201
  e.stripTrailingCr && (t = t.replace(/\r\n/g, `
1202
1202
  `));
1203
1203
  const n = [], r = t.split(/(\n|\r\n)/);
@@ -1234,7 +1234,7 @@ function ge(t, e, n, r, o, d, f) {
1234
1234
  const E = [];
1235
1235
  let x = 0, p = 0, k = [], O = 1, A = 1;
1236
1236
  for (let m = 0; m < b.length; m++) {
1237
- const T = b[m], R = T.lines || rt(T.value);
1237
+ const T = b[m], R = T.lines || ot(T.value);
1238
1238
  if (T.lines = R, T.added || T.removed) {
1239
1239
  if (!x) {
1240
1240
  const _ = b[m - 1];
@@ -1293,7 +1293,7 @@ function fe(t) {
1293
1293
  `) + `
1294
1294
  `;
1295
1295
  }
1296
- function nt(t, e, n, r, o, d, f) {
1296
+ function rt(t, e, n, r, o, d, f) {
1297
1297
  if (typeof f == "function" && (f = { callback: f }), f?.callback) {
1298
1298
  const { callback: l } = f;
1299
1299
  ge(t, e, n, r, o, d, Object.assign(Object.assign({}, f), { callback: (c) => {
@@ -1304,7 +1304,7 @@ function nt(t, e, n, r, o, d, f) {
1304
1304
  return l ? fe(l) : void 0;
1305
1305
  }
1306
1306
  }
1307
- function rt(t) {
1307
+ function ot(t) {
1308
1308
  const e = t.endsWith(`
1309
1309
  `), n = t.split(`
1310
1310
  `).map((r) => r + `
@@ -1312,20 +1312,20 @@ function rt(t) {
1312
1312
  return e ? n.pop() : n.push(n.pop().slice(0, -1)), n;
1313
1313
  }
1314
1314
  var ie = { exports: {} };
1315
- const K = new Uint32Array(65536), ot = (t, e) => {
1315
+ const H = new Uint32Array(65536), it = (t, e) => {
1316
1316
  const n = t.length, r = e.length, o = 1 << n - 1;
1317
1317
  let d = -1, f = 0, l = n, c = n;
1318
1318
  for (; c--; )
1319
- K[t.charCodeAt(c)] |= 1 << c;
1319
+ H[t.charCodeAt(c)] |= 1 << c;
1320
1320
  for (c = 0; c < r; c++) {
1321
- let h = K[e.charCodeAt(c)];
1321
+ let h = H[e.charCodeAt(c)];
1322
1322
  const b = h | f;
1323
1323
  h |= (h & d) + d ^ d, f |= ~(h | d), d &= h, f & o && l++, d & o && l--, f = f << 1 | 1, d = d << 1 | ~(b | f), f &= b;
1324
1324
  }
1325
1325
  for (c = n; c--; )
1326
- K[t.charCodeAt(c)] = 0;
1326
+ H[t.charCodeAt(c)] = 0;
1327
1327
  return l;
1328
- }, it = (t, e) => {
1328
+ }, st = (t, e) => {
1329
1329
  const n = e.length, r = t.length, o = [], d = [], f = Math.ceil(n / 32), l = Math.ceil(r / 32);
1330
1330
  for (let p = 0; p < f; p++)
1331
1331
  d[p] = -1, o[p] = 0;
@@ -1334,48 +1334,48 @@ const K = new Uint32Array(65536), ot = (t, e) => {
1334
1334
  let p = 0, k = -1;
1335
1335
  const O = c * 32, A = Math.min(32, r) + O;
1336
1336
  for (let m = O; m < A; m++)
1337
- K[t.charCodeAt(m)] |= 1 << m;
1337
+ H[t.charCodeAt(m)] |= 1 << m;
1338
1338
  for (let m = 0; m < n; m++) {
1339
- const T = K[e.charCodeAt(m)], R = d[m / 32 | 0] >>> m & 1, _ = o[m / 32 | 0] >>> m & 1, N = T | p, I = ((T | _) & k) + k ^ k | T | _;
1339
+ const T = H[e.charCodeAt(m)], R = d[m / 32 | 0] >>> m & 1, _ = o[m / 32 | 0] >>> m & 1, N = T | p, I = ((T | _) & k) + k ^ k | T | _;
1340
1340
  let i = p | ~(I | k), u = k & I;
1341
1341
  i >>> 31 ^ R && (d[m / 32 | 0] ^= 1 << m), u >>> 31 ^ _ && (o[m / 32 | 0] ^= 1 << m), i = i << 1 | R, u = u << 1 | _, k = u | ~(N | i), p = i & N;
1342
1342
  }
1343
1343
  for (let m = O; m < A; m++)
1344
- K[t.charCodeAt(m)] = 0;
1344
+ H[t.charCodeAt(m)] = 0;
1345
1345
  }
1346
1346
  let h = 0, b = -1;
1347
1347
  const P = c * 32, E = Math.min(32, r - P) + P;
1348
1348
  for (let p = P; p < E; p++)
1349
- K[t.charCodeAt(p)] |= 1 << p;
1349
+ H[t.charCodeAt(p)] |= 1 << p;
1350
1350
  let x = r;
1351
1351
  for (let p = 0; p < n; p++) {
1352
- const k = K[e.charCodeAt(p)], O = d[p / 32 | 0] >>> p & 1, A = o[p / 32 | 0] >>> p & 1, m = k | h, T = ((k | A) & b) + b ^ b | k | A;
1352
+ const k = H[e.charCodeAt(p)], O = d[p / 32 | 0] >>> p & 1, A = o[p / 32 | 0] >>> p & 1, m = k | h, T = ((k | A) & b) + b ^ b | k | A;
1353
1353
  let R = h | ~(T | b), _ = b & T;
1354
1354
  x += R >>> r - 1 & 1, x -= _ >>> r - 1 & 1, R >>> 31 ^ O && (d[p / 32 | 0] ^= 1 << p), _ >>> 31 ^ A && (o[p / 32 | 0] ^= 1 << p), R = R << 1 | O, _ = _ << 1 | A, b = _ | ~(m | R), h = R & m;
1355
1355
  }
1356
1356
  for (let p = P; p < E; p++)
1357
- K[t.charCodeAt(p)] = 0;
1357
+ H[t.charCodeAt(p)] = 0;
1358
1358
  return x;
1359
1359
  }, Oe = (t, e) => {
1360
1360
  if (t.length < e.length) {
1361
1361
  const n = e;
1362
1362
  e = t, t = n;
1363
1363
  }
1364
- return e.length === 0 ? t.length : t.length <= 32 ? ot(t, e) : it(t, e);
1365
- }, st = (t, e) => {
1364
+ return e.length === 0 ? t.length : t.length <= 32 ? it(t, e) : st(t, e);
1365
+ }, at = (t, e) => {
1366
1366
  let n = 1 / 0, r = 0;
1367
1367
  for (let o = 0; o < e.length; o++) {
1368
1368
  const d = Oe(t, e[o]);
1369
1369
  d < n && (n = d, r = o);
1370
1370
  }
1371
1371
  return e[r];
1372
- }, at = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1372
+ }, lt = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
1373
1373
  __proto__: null,
1374
- closest: st,
1374
+ closest: at,
1375
1375
  distance: Oe
1376
- }, Symbol.toStringTag, { value: "Module" })), lt = /* @__PURE__ */ Se(at);
1376
+ }, Symbol.toStringTag, { value: "Module" })), ut = /* @__PURE__ */ Se(lt);
1377
1377
  var we;
1378
- function ut() {
1378
+ function ft() {
1379
1379
  return we || (we = 1, function(t, e) {
1380
1380
  (function() {
1381
1381
  var n;
@@ -1384,7 +1384,7 @@ function ut() {
1384
1384
  } catch {
1385
1385
  console.log("Collator could not be initialized and wouldn't be used");
1386
1386
  }
1387
- var r = lt, o = [], d = [], f = {
1387
+ var r = ut, o = [], d = [], f = {
1388
1388
  /**
1389
1389
  * Calculate levenshtein distance of the two strings.
1390
1390
  *
@@ -1419,22 +1419,22 @@ function ut() {
1419
1419
  })();
1420
1420
  }(ie, ie.exports)), ie.exports;
1421
1421
  }
1422
- var ft = ut();
1423
- const ct = /* @__PURE__ */ je(ft);
1424
- function dt(t, e, n = "git", r = 1) {
1422
+ var ct = ft();
1423
+ const dt = /* @__PURE__ */ je(ct);
1424
+ function pt(t, e, n = "git", r = 1) {
1425
1425
  switch (n) {
1426
1426
  case "git":
1427
1427
  return ke(t, e, r);
1428
1428
  case "object":
1429
- return pt(t, e);
1430
- case "json":
1431
1429
  return ht(t, e);
1430
+ case "json":
1431
+ return mt(t, e);
1432
1432
  default:
1433
1433
  return ke(t, e, r);
1434
1434
  }
1435
1435
  }
1436
1436
  function ke(t, e, n = 1) {
1437
- const r = xe(t), o = xe(e), l = nt(
1437
+ const r = xe(t), o = xe(e), l = rt(
1438
1438
  /* oldFilename */
1439
1439
  "",
1440
1440
  /* newFilename */
@@ -1454,11 +1454,11 @@ function ke(t, e, n = 1) {
1454
1454
  return l.join(`
1455
1455
  `);
1456
1456
  }
1457
- function pt(t, e) {
1457
+ function ht(t, e) {
1458
1458
  const n = Ce.diff(t, e) || [];
1459
1459
  return JSON.stringify(n, null, 2);
1460
1460
  }
1461
- function ht(t, e) {
1461
+ function mt(t, e) {
1462
1462
  return JSON.stringify(
1463
1463
  {
1464
1464
  before: t,
@@ -1468,13 +1468,13 @@ function ht(t, e) {
1468
1468
  2
1469
1469
  );
1470
1470
  }
1471
- function mt(t, e) {
1472
- return typeof t == "string" && typeof e == "string" ? Re(t, e) : typeof t == "number" && typeof e == "number" ? Ae(t, e) : bt(t, e);
1471
+ function bt(t, e) {
1472
+ return typeof t == "string" && typeof e == "string" ? Re(t, e) : typeof t == "number" && typeof e == "number" ? Ae(t, e) : vt(t, e);
1473
1473
  }
1474
1474
  function Re(t, e) {
1475
1475
  if (t === e) return 0;
1476
1476
  if (t.length === 0 || e.length === 0) return 1;
1477
- const n = ct.get(t, e), r = Math.max(t.length, e.length);
1477
+ const n = dt.get(t, e), r = Math.max(t.length, e.length);
1478
1478
  return n / r;
1479
1479
  }
1480
1480
  function Ae(t, e) {
@@ -1483,7 +1483,7 @@ function Ae(t, e) {
1483
1483
  const n = Math.abs(e - t), r = Math.max(Math.abs(t), Math.abs(e));
1484
1484
  return Math.min(n / r, 1);
1485
1485
  }
1486
- function bt(t, e) {
1486
+ function vt(t, e) {
1487
1487
  if (t === e) return 0;
1488
1488
  const n = Ce.diff(t, e) || [];
1489
1489
  if (n.length === 0) return 0;
@@ -1540,7 +1540,7 @@ function xe(t) {
1540
1540
  return String(t);
1541
1541
  }
1542
1542
  }
1543
- function vt(t, e, n) {
1543
+ function yt(t, e, n) {
1544
1544
  const r = Te(), o = n?.onFeedback || r, d = n?.debounceMs ?? 3e3, f = n?.diffType ?? "git", l = n?.compareWith, c = n?.default_trigger_name ?? "auto_state_change", h = n?.ignoreInitialNullish ?? !0, b = Y(t), P = Y(!0), E = Y(t), x = Y(t == null), p = Y(
1545
1545
  t != null
1546
1546
  // != null catches both null and undefined
@@ -1548,7 +1548,7 @@ function vt(t, e, n) {
1548
1548
  !(h && t == null)
1549
1549
  ), O = Y(null), A = Y(void 0), m = q(
1550
1550
  (R, _, N) => {
1551
- const I = mt(R, _), i = dt(R, _, f), u = typeof n?.score == "function" ? n.score(R, _, I) : n?.score ?? (I > 0.5 ? 0 : 1), s = typeof e == "function" ? e(_) : e;
1551
+ const I = bt(R, _), i = pt(R, _, f), u = typeof n?.score == "function" ? n.score(R, _, I) : n?.score ?? (I > 0.5 ? 0 : 1), s = typeof e == "function" ? e(_) : e;
1552
1552
  o({
1553
1553
  session_id: s,
1554
1554
  kind: "edit",
@@ -1618,8 +1618,8 @@ function vt(t, e, n) {
1618
1618
  notifyChange: T
1619
1619
  };
1620
1620
  }
1621
- function Et(t, e, n) {
1622
- const [r, o] = X(t), { notifyChange: d } = vt(r, e, n), f = q(
1621
+ function xt(t, e, n) {
1622
+ const [r, o] = X(t), { notifyChange: d } = yt(r, e, n), f = q(
1623
1623
  (l, c) => {
1624
1624
  d(c), o((h) => typeof l == "function" ? l(h) : l);
1625
1625
  },
@@ -1629,10 +1629,11 @@ function Et(t, e, n) {
1629
1629
  }
1630
1630
  export {
1631
1631
  ae as KeletContext,
1632
- wt as KeletProvider,
1633
- kt as VoteFeedback,
1632
+ kt as KeletProvider,
1633
+ Et as VoteFeedback,
1634
1634
  Te as useDefaultFeedbackHandler,
1635
- Et as useFeedbackState,
1636
- gt as useKelet
1635
+ xt as useFeedbackState,
1636
+ wt as useKelet,
1637
+ Ke as useKeletSignal
1637
1638
  };
1638
1639
  //# sourceMappingURL=feedback-ui.es.min.js.map