@logora/debate 0.4.72 → 0.4.73

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.
@@ -1,6 +1,6 @@
1
1
  import { jsxs as C, jsx as s } from "react/jsx-runtime";
2
- import Ye from "@rooks/use-sessionstorage-state";
3
- import { useRef as ke, useState as c, useEffect as p, Suspense as Re, lazy as je } from "react";
2
+ import We from "@rooks/use-sessionstorage-state";
3
+ import { useRef as Ye, useState as c, useEffect as p, Suspense as Re, lazy as je } from "react";
4
4
  import { useIntl as ze, FormattedMessage as he } from "react-intl";
5
5
  import { useLocation as Oe } from "react-router";
6
6
  import x from "classnames";
@@ -51,12 +51,12 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
51
51
  inputContent: B,
52
52
  setInputContent: te,
53
53
  setInputRichContent: Ie
54
- } = He(), { isLoggedIn: S, currentUser: u } = Qe(), { errors: E, validate: $ } = Xe(), { isMobile: m } = Ze(), xe = Oe(), ne = ke(null), [V, q] = c([]), [D, U] = c(""), [ae, W] = c(null), [d, b] = c(null), [se, ie] = c(null), [oe, re] = c(!1), [I, ue] = c(!1), [A, de] = c({}), [Ne, Y] = c(!1), [f, ye] = Ye(
54
+ } = He(), { isLoggedIn: S, currentUser: u } = Qe(), { errors: E, validate: $ } = Xe(), { isMobile: m } = Ze(), xe = Oe(), ne = Ye(null), [V, k] = c([]), [q, D] = c(""), [ae, U] = c(null), [d, b] = c(null), [se, ie] = c(null), [oe, re] = c(!1), [I, ue] = c(!1), [A, de] = c({}), [Ne, W] = c(!1), [f, ye] = We(
55
55
  "userSide",
56
56
  {}
57
57
  ), [g, Te] = c(
58
58
  !S && v?.actions?.disableInputForVisitor
59
- ), k = et(), { showModal: Le } = tt(), { toast: R } = nt() || {}, le = new URLSearchParams(
59
+ ), Y = et(), { showModal: Le } = tt(), { toast: R } = nt() || {}, le = new URLSearchParams(
60
60
  typeof window < "u" ? window.location.search : xe.search
61
61
  );
62
62
  p(() => {
@@ -69,13 +69,13 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
69
69
  let e = null;
70
70
  typeof window < "u" && (e = le.get("positionId")), w && w != a[2]?.id && a?.find((t) => t.id === w) ? b(w) : e && e != a[2]?.id ? b(e) : f && f.groupId == _ && f.positionId != a[2]?.id && b(f.positionId);
71
71
  }, [w]), p(() => {
72
- Q && Y(!0);
72
+ Q && W(!0);
73
73
  }, [Q]), p(() => {
74
- P && (z(), Y(!0), L());
74
+ P && (z(), W(!0), L());
75
75
  }, [P]), p(() => {
76
76
  if (typeof window < "u") {
77
77
  const e = be || le.get("initArgument");
78
- (e === !0 || e === "true") && (Y(!0), L(), De());
78
+ (e === !0 || e === "true") && (W(!0), L(), qe());
79
79
  }
80
80
  }, []), p(() => {
81
81
  Z && (L(), ee(!1));
@@ -83,11 +83,11 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
83
83
  B?.id && (Fe(B), ee(!0));
84
84
  }, [B]);
85
85
  const Fe = (e) => {
86
- de(e), ue(!0), q(e.sources), U(e.content), W(e.rich_content), ie(e.id), L(), b(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ie(e.rich_content) : te(e.content);
86
+ de(e), ue(!0), k(e.sources), D(e.content), U(e.rich_content), ie(e.id), L(), b(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ie(e.rich_content) : te(e.content);
87
87
  }, L = () => {
88
- ne.current.scrollIntoView(!1);
88
+ ne.current.scrollIntoView({ behavior: "smooth", block: "center" });
89
89
  }, me = () => {
90
- U(""), W(null), de({}), ie(null), q([]), Se(!0), te(null);
90
+ D(""), U(null), de({}), ie(null), k([]), Se(!0), te(null);
91
91
  }, Pe = (e) => {
92
92
  b(e), ge(e);
93
93
  }, Be = () => {
@@ -108,11 +108,11 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
108
108
  ) })
109
109
  );
110
110
  }, Ee = () => {
111
- S ? se ? qe() : !a || a?.length === 0 || !y?.find((e) => e?.id === d) && d || j && r ? ge(r && j && a[0]?.id) : Be() : k({ loginAction: "argument" });
111
+ S ? se ? ke() : !a || a?.length === 0 || !y?.find((e) => e?.id === d) && d || j && r ? ge(r && j && a[0]?.id) : Be() : Y({ loginAction: "argument" });
112
112
  }, $e = (e, t) => {
113
- g ? k({ loginAction: "argument" }) : (U(e), W(t), $({ content: e }, [{ content: ["url", null] }]));
113
+ g ? Y({ loginAction: "argument" }) : (D(e), U(t), $({ content: e }, [{ content: ["url", null] }]));
114
114
  }, Ve = (e) => {
115
- q(e);
115
+ k(e);
116
116
  }, fe = [
117
117
  { content: ["length", 3] },
118
118
  { content: ["required", null] },
@@ -120,7 +120,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
120
120
  ...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
121
121
  ], ge = (e) => {
122
122
  const t = e || d, l = {
123
- content: D,
123
+ content: q,
124
124
  rich_content: ae,
125
125
  group_id: _,
126
126
  ...J && { group_type: J },
@@ -152,8 +152,8 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
152
152
  const h = i.data.data.resource;
153
153
  let F = N;
154
154
  t && !m && (F = `argumentList${h.position.id}`), K?.(
155
- D,
156
- a.find((We) => We.id === t) || null
155
+ q,
156
+ a.find((Ue) => Ue.id === t) || null
157
157
  ), T.add(F, [h]), R(
158
158
  o.formatMessage({
159
159
  id: "alert.argument_create",
@@ -179,9 +179,9 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
179
179
  );
180
180
  }
181
181
  }));
182
- }, qe = () => {
182
+ }, ke = () => {
183
183
  const e = {
184
- content: D,
184
+ content: q,
185
185
  rich_content: ae,
186
186
  source_ids: V?.map((t) => t.id),
187
187
  ...d && { position_id: d }
@@ -204,7 +204,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
204
204
  }), me();
205
205
  }
206
206
  });
207
- }, De = () => {
207
+ }, qe = () => {
208
208
  if (!oe) {
209
209
  re(!0);
210
210
  const e = setTimeout(() => {
@@ -213,8 +213,8 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
213
213
  return () => clearTimeout(e);
214
214
  }
215
215
  }, z = () => {
216
- g ? k({ loginAction: "argument" }) : ue(!0);
217
- }, Ue = () => {
216
+ g ? Y({ loginAction: "argument" }) : ue(!0);
217
+ }, De = () => {
218
218
  const e = y.find(
219
219
  (t) => t.id === d
220
220
  );
@@ -352,7 +352,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
352
352
  width: 20
353
353
  }
354
354
  ),
355
- /* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: Ue() })
355
+ /* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: De() })
356
356
  ]
357
357
  }
358
358
  ),
@@ -1,18 +1,18 @@
1
1
  import { useLexicalComposerContext as u } from "@lexical/react/LexicalComposerContext";
2
- import { useRef as c, useEffect as s } from "react";
3
- import { useInput as f } from "../../input_provider/useInput.js";
4
- const E = ({ autoFocus: t = !1 }) => {
5
- const [o] = u(), { focus: e } = f(), r = c(!1);
6
- return s(() => {
7
- e && o.focus(() => {
8
- o.getRootElement().focus();
2
+ import { useRef as c, useEffect as n } from "react";
3
+ import { useInput as l } from "../../input_provider/useInput.js";
4
+ const p = ({ autoFocus: o = !1 }) => {
5
+ const [e] = u(), { focus: t } = l(), r = c(!1);
6
+ return n(() => {
7
+ t && e.focus(() => {
8
+ e.getRootElement().focus({ preventScroll: !0 });
9
9
  });
10
- }, [e, o]), s(() => {
11
- t && !r.current && (r.current = !0, o.focus(() => {
12
- o.getRootElement().focus();
10
+ }, [t, e]), n(() => {
11
+ o && !r.current && (r.current = !0, e.focus(() => {
12
+ e.getRootElement().focus({ preventScroll: !0 });
13
13
  }));
14
- }, [t, o]), null;
14
+ }, [o, e]), null;
15
15
  };
16
16
  export {
17
- E as FocusPlugin
17
+ p as FocusPlugin
18
18
  };
@@ -21,25 +21,25 @@ const ve = ({
21
21
  userGuideUrl: d,
22
22
  hideUserGuideLink: N = !1
23
23
  }) => {
24
- const o = K(), C = Q(), x = W(), { toast: T } = X() || {}, { isLoggedIn: y } = Z(), { focus: f, setFocus: q } = $(), { errors: p, validate: F } = G(), [h, E] = l(!0), [Y, v] = l(!1), [i, a] = l(""), [S, A, R] = z("userSuggestion", {}), V = b(null), u = b(null), j = U();
24
+ const o = K(), C = Q(), x = W(), { toast: T } = X() || {}, { isLoggedIn: y } = Z(), { focus: f, setFocus: q } = $(), { errors: p, validate: F } = G(), [h, E] = l(!0), [Y, v] = l(!1), [i, a] = l(""), [S, k, A] = z("userSuggestion", {}), R = b(null), u = b(null), V = U();
25
25
  c(() => {
26
26
  S?.suggestion && a(S.suggestion);
27
27
  }, []), c(() => {
28
28
  if (h) {
29
29
  const s = setInterval(() => {
30
- i?.length > 0 && A({
30
+ i?.length > 0 && k({
31
31
  suggestion: i
32
32
  });
33
33
  }, 1e3);
34
34
  return () => clearInterval(s);
35
35
  }
36
36
  }, [h, i]), c(() => {
37
- f && (k(), w(), O(), q(!1));
37
+ f && (j(), w(), O(), q(!1));
38
38
  }, [f]);
39
- const k = () => {
40
- u.current.scrollIntoView({ behavior: "smooth" });
39
+ const j = () => {
40
+ u.current.scrollIntoView({ behavior: "smooth", block: "center" });
41
41
  }, w = () => {
42
- u.current.focus();
42
+ u.current.focus({ preventScroll: !0 });
43
43
  }, O = () => {
44
44
  if (!Y) {
45
45
  v(!0);
@@ -49,7 +49,7 @@ const ve = ({
49
49
  return () => clearTimeout(s);
50
50
  }
51
51
  }, L = () => {
52
- a(""), R();
52
+ a(""), A();
53
53
  }, B = () => {
54
54
  if (y) {
55
55
  const s = {
@@ -80,13 +80,13 @@ const ve = ({
80
80
  }
81
81
  }));
82
82
  } else
83
- j({});
83
+ V({});
84
84
  };
85
85
  return /* @__PURE__ */ e(
86
86
  "div",
87
87
  {
88
88
  className: t.suggestionInputContainer,
89
- ref: V,
89
+ ref: R,
90
90
  children: /* @__PURE__ */ g(P, { children: [
91
91
  /* @__PURE__ */ g("div", { className: H(t.suggestionInputItem), children: [
92
92
  /* @__PURE__ */ e("div", { className: t.suggestionInputTitle, children: /* @__PURE__ */ e(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.72",
3
+ "version": "0.4.73",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",