@logora/debate 0.4.72 → 0.4.74

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 je, lazy as Re } 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";
@@ -20,7 +20,7 @@ import { Avatar as st } from "../../user/avatar/Avatar.js";
20
20
  import { AuthorBox as it } from "../../user/author_box/AuthorBox.js";
21
21
  import { TextEditor as ot } from "../text_editor/TextEditor.js";
22
22
  import { Icon as rt } from "../../icons/icon/Icon.js";
23
- const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ default: N.SideModal }))), Ft = ({
23
+ const ut = Re(() => import("../../modal/side_modal/index.js").then((N) => ({ default: N.SideModal }))), Ft = ({
24
24
  argumentListId: N,
25
25
  avatarSize: pe = 48,
26
26
  disabled: O = !1,
@@ -30,7 +30,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
30
30
  groupName: _e,
31
31
  groupType: J,
32
32
  hideSourceAction: Me = !1,
33
- isReply: r = !1,
33
+ isReply: o = !1,
34
34
  onSubmit: K,
35
35
  onUpdate: G,
36
36
  parentId: M,
@@ -44,19 +44,19 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
44
44
  disableAutoActivate: we = !1,
45
45
  autoFocus: Q = !1
46
46
  }) => {
47
- const o = ze(), X = Je(), T = Ke(), v = Ge(), {
47
+ const r = ze(), X = Je(), T = Ke(), v = Ge(), {
48
48
  focus: Z,
49
49
  setFocus: ee,
50
50
  setReset: Se,
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: j } = nt() || {}, le = new URLSearchParams(
60
60
  typeof window < "u" ? window.location.search : xe.search
61
61
  );
62
62
  p(() => {
@@ -64,55 +64,55 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
64
64
  !S && v?.actions?.disableInputForVisitor
65
65
  );
66
66
  }, [S, v]);
67
- const j = u?.role === "editor" || u?.role === "moderator", ce = u?.moderation_status === "banned";
67
+ const R = u?.role === "editor" || u?.role === "moderator", ce = u?.moderation_status === "banned";
68
68
  p(() => {
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));
82
82
  }, [Z]), p(() => {
83
- B?.id && (Fe(B), ee(!0));
83
+ B?.id && !o && (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 = () => {
94
94
  Le(
95
- /* @__PURE__ */ s(Re, { fallback: null, children: /* @__PURE__ */ s(
95
+ /* @__PURE__ */ s(je, { fallback: null, children: /* @__PURE__ */ s(
96
96
  ut,
97
97
  {
98
- modalTitle: o.formatMessage({
98
+ modalTitle: r.formatMessage({
99
99
  id: "modal.side_modal.modal_title",
100
100
  defaultMessage: "Choose your side"
101
101
  }),
102
102
  onChooseSide: Pe,
103
103
  positions: a,
104
104
  title: _e,
105
- disabledPositions: !r && y,
105
+ disabledPositions: !o && y,
106
106
  isNeutral: f && f.groupId == _ && f.positionId === a[2]?.id
107
107
  }
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 || R && o ? ge(o && R && 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 },
@@ -135,14 +135,14 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
135
135
  }), me(), X.create("messages", l).then((i) => {
136
136
  if (i.data.success) {
137
137
  if (M)
138
- K(i.data.data.resource), R(
139
- o.formatMessage({
138
+ K(i.data.data.resource), j(
139
+ r.formatMessage({
140
140
  id: "alert.argument_create",
141
141
  defaultMessage: "Your contribution has been sent !"
142
142
  }),
143
143
  {
144
144
  type: "success",
145
- points: o.formatMessage({
145
+ points: r.formatMessage({
146
146
  id: "alert.reply_gain",
147
147
  defaultMessage: " "
148
148
  })
@@ -152,16 +152,16 @@ 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
157
- ), T.add(F, [h]), R(
158
- o.formatMessage({
155
+ q,
156
+ a.find((Ue) => Ue.id === t) || null
157
+ ), T.add(F, [h]), j(
158
+ r.formatMessage({
159
159
  id: "alert.argument_create",
160
160
  defaultMessage: "Your contribution has been sent !"
161
161
  }),
162
162
  {
163
163
  type: "success",
164
- points: o.formatMessage({
164
+ points: r.formatMessage({
165
165
  id: "alert.argument_create_gain",
166
166
  defaultMessage: "Up to 10 eloquence points"
167
167
  }),
@@ -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 }
@@ -190,7 +190,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
190
190
  if (t.data.success) {
191
191
  const l = t.data.data.resource;
192
192
  let i = N;
193
- if (A?.is_reply || r) {
193
+ if (A?.is_reply || o) {
194
194
  const h = A?.message_id || A?.reply_to_id || M;
195
195
  h && (i = `argument_${h}_reply_list`);
196
196
  } else d && !m && (i = `argumentList${l.position?.id}`);
@@ -199,12 +199,12 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
199
199
  T.remove(h, [l]), T.add(F, [l]);
200
200
  } else
201
201
  T.update(i, [l]);
202
- G && G(l), R(o.formatMessage({ id: "alert.argument_modify" }), {
202
+ G && G(l), j(r.formatMessage({ id: "alert.argument_modify" }), {
203
203
  type: "success"
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,13 +213,13 @@ 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
  );
221
221
  if (e)
222
- return o.formatMessage(
222
+ return r.formatMessage(
223
223
  {
224
224
  id: "info.argument_side_limit",
225
225
  defaultMessage: "You have reached the argument limit (10) for position {position}."
@@ -228,10 +228,10 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
228
228
  );
229
229
  };
230
230
  return /* @__PURE__ */ C("div", { className: n.inputContainer, children: [
231
- O && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ce ? o.formatMessage({
231
+ O && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ce ? r.formatMessage({
232
232
  id: "input.argument_input.user_banned",
233
233
  defaultMessage: "You are banned from the debate space."
234
- }) : o.formatMessage({
234
+ }) : r.formatMessage({
235
235
  id: "info.debate_is_inactive",
236
236
  defaultMessage: "Debate is closed"
237
237
  }) }),
@@ -240,11 +240,11 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
240
240
  {
241
241
  className: x(n.argumentInput, {
242
242
  [n.flash]: oe,
243
- [n.replyInputContainer]: r
243
+ [n.replyInputContainer]: o
244
244
  }),
245
245
  children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: ne, children: /* @__PURE__ */ C("div", { className: n.argumentInputBox, children: [
246
- a.length > 0 && S && (!r || !j) && /* @__PURE__ */ C("div", { className: n.userPosition, children: [
247
- /* @__PURE__ */ s("div", { children: o.formatMessage({
246
+ a.length > 0 && S && (!o || !R) && /* @__PURE__ */ C("div", { className: n.userPosition, children: [
247
+ /* @__PURE__ */ s("div", { children: r.formatMessage({
248
248
  id: "input.position",
249
249
  defaultMessage: "Your position"
250
250
  }) }),
@@ -263,7 +263,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
263
263
  {
264
264
  className: x(n.argumentTextInputBox, {
265
265
  [n.argumentTextInputBoxisTablet]: !m,
266
- [n.replyEditorRow]: r
266
+ [n.replyEditorRow]: o
267
267
  }),
268
268
  children: [
269
269
  /* @__PURE__ */ s(
@@ -271,9 +271,9 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
271
271
  {
272
272
  className: x(n.argumentAuthorContainer, {
273
273
  [n.argumentAuthorContainerMobile]: m,
274
- [n.argumentAuthorContainerActivated]: !m && I || r
274
+ [n.argumentAuthorContainerActivated]: !m && I || o
275
275
  }),
276
- children: !m && I || r ? /* @__PURE__ */ s(
276
+ children: !m && I || o ? /* @__PURE__ */ s(
277
277
  st,
278
278
  {
279
279
  avatarUrl: u.image_url,
@@ -283,7 +283,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
283
283
  ) : /* @__PURE__ */ s(
284
284
  it,
285
285
  {
286
- fullName: u?.full_name || o.formatMessage({ id: "default_author.full_name" }),
286
+ fullName: u?.full_name || r.formatMessage({ id: "default_author.full_name" }),
287
287
  avatarUrl: u?.image_url,
288
288
  points: u?.points || 0,
289
289
  slug: u?.hash_id
@@ -297,7 +297,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
297
297
  onClick: z,
298
298
  "data-testid": "argument-input",
299
299
  className: x(n.textEditorBox, {
300
- [n.replyTextEditorBox]: r
300
+ [n.replyTextEditorBox]: o
301
301
  }),
302
302
  children: [
303
303
  /* @__PURE__ */ s(
@@ -310,7 +310,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
310
310
  Ve(e);
311
311
  },
312
312
  placeholder: ve,
313
- "aria-label": o.formatMessage({
313
+ "aria-label": r.formatMessage({
314
314
  id: "input.argument_input.aria_label",
315
315
  defaultMessage: "Message input field"
316
316
  }),
@@ -323,7 +323,7 @@ const ut = je(() => import("../../modal/side_modal/index.js").then((N) => ({ def
323
323
  disabled: O || g || ce,
324
324
  maxLength: g ? !1 : v?.actions?.argumentMaxLength,
325
325
  disableRichText: v?.actions?.disableRichText || g,
326
- shortBar: r,
326
+ shortBar: o,
327
327
  hideSubmit: g,
328
328
  allowedDomains: v?.allowed_sources,
329
329
  active: P,
@@ -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.74",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",