@logora/debate 0.3.52 → 0.3.53

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.
@@ -3,7 +3,7 @@ import $e from "@rooks/use-sessionstorage-state";
3
3
  import { useRef as qe, useState as c, useEffect as M, Suspense as De, lazy as We } from "react";
4
4
  import { useIntl as Ye, FormattedMessage as ce } from "react-intl";
5
5
  import { useLocation as ke } from "react-router";
6
- import S from "classnames";
6
+ import x from "classnames";
7
7
  import n from "./ArgumentInput.module.scss.js";
8
8
  import { useDataProvider as Re } from "../../data/data_provider/useDataProvider.js";
9
9
  import { useList as je } from "../../list/list_provider/useList.js";
@@ -20,8 +20,8 @@ import { Avatar as et } from "../../user/avatar/Avatar.js";
20
20
  import { AuthorBox as tt } from "../../user/author_box/AuthorBox.js";
21
21
  import { TextEditor as nt } from "../text_editor/TextEditor.js";
22
22
  import { Icon as at } from "../../icons/icon/Icon.js";
23
- const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ default: x.SideModal }))), Nt = ({
24
- argumentListId: x,
23
+ const st = We(() => import("../../modal/side_modal/index.js").then((y) => ({ default: y.SideModal }))), yt = ({
24
+ argumentListId: y,
25
25
  avatarSize: me = 48,
26
26
  disabled: z = !1,
27
27
  positions: a = [],
@@ -32,7 +32,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
32
32
  hideSourceAction: fe = !1,
33
33
  isReply: d = !1,
34
34
  onSubmit: J,
35
- parentId: y,
35
+ parentId: T,
36
36
  placeholder: he,
37
37
  positionId: A,
38
38
  focusOnInit: pe = !1,
@@ -42,19 +42,19 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
42
42
  hideCharCount: Me = !1,
43
43
  disableAutoActivate: ve = !1
44
44
  }) => {
45
- const r = Ye(), G = Re(), T = je(), h = ze(), {
45
+ const r = Ye(), G = Re(), L = je(), h = ze(), {
46
46
  focus: H,
47
- setFocus: L,
47
+ setFocus: F,
48
48
  setReset: Ae,
49
- inputContent: B,
49
+ inputContent: E,
50
50
  setInputContent: be,
51
51
  setInputRichContent: we
52
- } = Oe(), { isLoggedIn: b, currentUser: u } = Je(), { errors: E, validate: V } = Ke(), { isMobile: m } = Ge(), Ce = ke(), Q = qe(null), [U, $] = c([]), [q, D] = c(""), [X, W] = c(null), [l, p] = c(null), [Z, ee] = c(null), [te, ne] = c(!1), [w, ae] = c(!1), [F, se] = c({}), [g, Ie] = $e(
52
+ } = Oe(), { isLoggedIn: b, currentUser: u } = Je(), { errors: B, validate: V } = Ke(), { isMobile: m } = Ge(), Ce = ke(), Q = qe(null), [U, $] = c([]), [q, D] = c(""), [X, W] = c(null), [l, p] = c(null), [Z, ee] = c(null), [te, ne] = c(!1), [w, ae] = c(!1), [C, se] = c({}), [g, Ie] = $e(
53
53
  "userSide",
54
54
  {}
55
55
  ), [f, Se] = c(
56
56
  !b && h?.actions?.disableInputForVisitor
57
- ), Y = He(), { showModal: xe } = Qe(), { toast: k } = Xe() || {}, ie = new URLSearchParams(
57
+ ), Y = He(), { showModal: xe } = Qe(), { toast: k } = Xe() || {}, oe = new URLSearchParams(
58
58
  typeof window < "u" ? window.location.search : Ce.search
59
59
  );
60
60
  M(() => {
@@ -62,29 +62,29 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
62
62
  !b && h?.actions?.disableInputForVisitor
63
63
  );
64
64
  }, [b, h]);
65
- const R = u?.role === "editor" || u?.role === "moderator", oe = u?.moderation_status === "banned";
65
+ const R = u?.role === "editor" || u?.role === "moderator", ie = u?.moderation_status === "banned";
66
66
  M(() => {
67
67
  let e = null;
68
- typeof window < "u" && (e = ie.get("positionId")), A && A != a[2]?.id && a?.find((t) => t.id === A) ? p(A) : e && e != a[2]?.id ? p(e) : g && g.groupId == v && g.positionId != a[2]?.id && p(g.positionId);
68
+ typeof window < "u" && (e = oe.get("positionId")), A && A != a[2]?.id && a?.find((t) => t.id === A) ? p(A) : e && e != a[2]?.id ? p(e) : g && g.groupId == v && g.positionId != a[2]?.id && p(g.positionId);
69
69
  }, [A]), M(() => {
70
- P && (j(), L(!0));
70
+ P && (j(), F(!0));
71
71
  }, [P]), M(() => {
72
72
  if (typeof window < "u") {
73
- const e = pe || ie.get("initArgument");
74
- (e === !0 || e === "true") && (L(!0), Ee());
73
+ const e = pe || oe.get("initArgument");
74
+ (e === !0 || e === "true") && (F(!0), Be());
75
75
  }
76
76
  }, []), M(() => {
77
- H && (re(), L(!1));
77
+ H && (re(), F(!1));
78
78
  }, [H]), M(() => {
79
- B?.id && (Ne(B), L(!0));
80
- }, [B]);
81
- const Ne = (e) => {
79
+ E?.id && (ye(E), F(!0));
80
+ }, [E]);
81
+ const ye = (e) => {
82
82
  se(e), ae(!0), $(e.sources), D(e.content), W(e.rich_content), ee(e.id), re(), p(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? we(e.rich_content) : be(e.content);
83
83
  }, re = () => {
84
84
  Q.current.scrollIntoView(!1);
85
85
  }, de = () => {
86
86
  D(""), W(null), se({}), ee(null), $([]), Ae(!0);
87
- }, ye = (e) => {
87
+ }, Ne = (e) => {
88
88
  p(e), le(e);
89
89
  }, Te = () => {
90
90
  xe(
@@ -95,7 +95,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
95
95
  id: "modal.side_modal.modal_title",
96
96
  defaultMessage: "Choose your side"
97
97
  }),
98
- onChooseSide: ye,
98
+ onChooseSide: Ne,
99
99
  positions: a,
100
100
  title: ge,
101
101
  disabledPositions: !d && N,
@@ -104,7 +104,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
104
104
  ) })
105
105
  );
106
106
  }, Le = () => {
107
- b ? Z ? Be() : !a || a?.length === 0 || !N?.find((e) => e?.id === l) && l || R && d ? le(d && R && a[0]?.id) : Te() : Y({ loginAction: "argument" });
107
+ b ? Z ? Ee() : !a || a?.length === 0 || !N?.find((e) => e?.id === l) && l || R && d ? le(d && R && a[0]?.id) : Te() : Y({ loginAction: "argument" });
108
108
  }, Fe = (e, t) => {
109
109
  f ? Y({ loginAction: "argument" }) : (D(e), W(t), V({ content: e }, [{ content: ["url", null] }]));
110
110
  }, Pe = (e) => {
@@ -115,23 +115,23 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
115
115
  { content: ["url", null] },
116
116
  ...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
117
117
  ], le = (e) => {
118
- const t = e || l, i = {
118
+ const t = e || l, o = {
119
119
  content: q,
120
120
  rich_content: X,
121
121
  group_id: v,
122
122
  ...O && { group_type: O },
123
123
  ...t && { position_id: t },
124
- is_reply: !!y,
125
- message_id: y || null,
126
- source_ids: U?.map((o) => o.id)
124
+ is_reply: !!T,
125
+ message_id: T || null,
126
+ source_ids: U?.map((i) => i.id)
127
127
  };
128
- V(i, ue) && (t && a && a.map((o) => o.id).includes(t) && Ie({
128
+ V(o, ue) && (t && a && a.map((i) => i.id).includes(t) && Ie({
129
129
  groupId: v,
130
130
  positionId: t
131
- }), de(), G.create("messages", i).then((o) => {
132
- if (o.data.success) {
133
- if (y)
134
- J(o.data.data.resource), k(
131
+ }), de(), G.create("messages", o).then((i) => {
132
+ if (i.data.success) {
133
+ if (T)
134
+ J(i.data.data.resource), k(
135
135
  r.formatMessage({
136
136
  id: "alert.argument_create",
137
137
  defaultMessage: "Your contribution has been sent !"
@@ -145,12 +145,12 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
145
145
  }
146
146
  );
147
147
  else {
148
- const C = o.data.data.resource;
149
- let I = x;
150
- t && !m && (I = `argumentList${C.position.id}`), J?.(
148
+ const I = i.data.data.resource;
149
+ let S = y;
150
+ t && !m && (S = `argumentList${I.position.id}`), J?.(
151
151
  q,
152
152
  a.find((Ue) => Ue.id === t) || null
153
- ), T.add(I, [C]), k(
153
+ ), L.add(S, [I]), k(
154
154
  r.formatMessage({
155
155
  id: "alert.argument_create",
156
156
  defaultMessage: "Your contribution has been sent !"
@@ -169,13 +169,13 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
169
169
  typeof window < "u" && window.dispatchEvent(
170
170
  new CustomEvent("logora:user_content:created", {
171
171
  detail: {
172
- content: o.data.data?.resource
172
+ content: i.data.data?.resource
173
173
  }
174
174
  })
175
175
  );
176
176
  }
177
177
  }));
178
- }, Be = () => {
178
+ }, Ee = () => {
179
179
  const e = {
180
180
  content: q,
181
181
  rich_content: X,
@@ -184,19 +184,19 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
184
184
  };
185
185
  V(e, ue) && G.update("messages", Z, e).then((t) => {
186
186
  if (t.data.success) {
187
- const i = t.data.data.resource;
188
- let o = x;
189
- if (console.log("[updateArgument] API response:", i), console.log("[updateArgument] is_reply:", i.is_reply, "| message_id:", i.message_id, "| editElement.message_id:", F?.message_id, "| parentId prop:", y), i.is_reply ? o = `argument_${i.message_id || F?.message_id}_reply_list` : l && !m && (o = `argumentList${i.position?.id}`), console.log("[updateArgument] listId used for update:", o), F?.position?.id != i.position?.id && !m && !i.is_reply) {
190
- const C = `argumentList${F.position.id}`, I = `argumentList${i.position.id}`;
191
- console.log("[updateArgument] position changed, moving from", C, "to", I), T.remove(C, [i]), T.add(I, [i]);
187
+ const o = t.data.data.resource;
188
+ let i = y;
189
+ if (console.log("[updateArgument] API response:", o), console.log("[updateArgument] editElement complet:", C), console.log("[updateArgument] is_reply:", o.is_reply, "| message_id:", o.message_id, "| editElement.message_id:", C?.message_id, "| parentId prop:", T), o.is_reply ? i = `argument_${o.reply_to_id || C?.reply_to_id}_reply_list` : l && !m && (i = `argumentList${o.position?.id}`), console.log("[updateArgument] listId used for update:", i), C?.position?.id != o.position?.id && !m && !o.is_reply) {
190
+ const I = `argumentList${C.position.id}`, S = `argumentList${o.position.id}`;
191
+ console.log("[updateArgument] position changed, moving from", I, "to", S), L.remove(I, [o]), L.add(S, [o]);
192
192
  } else
193
- console.log("[updateArgument] calling list.update with listId:", o), T.update(o, [i]);
193
+ console.log("[updateArgument] calling list.update with listId:", i), L.update(i, [o]);
194
194
  k(r.formatMessage({ id: "alert.argument_modify" }), {
195
195
  type: "success"
196
196
  }), de();
197
197
  }
198
198
  });
199
- }, Ee = () => {
199
+ }, Be = () => {
200
200
  if (!te) {
201
201
  ne(!0);
202
202
  const e = setTimeout(() => {
@@ -220,7 +220,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
220
220
  );
221
221
  };
222
222
  return /* @__PURE__ */ _("div", { className: n.inputContainer, children: [
223
- z && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: oe ? r.formatMessage({
223
+ z && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ie ? r.formatMessage({
224
224
  id: "input.argument_input.user_banned",
225
225
  defaultMessage: "You are banned from the debate space."
226
226
  }) : r.formatMessage({
@@ -230,7 +230,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
230
230
  /* @__PURE__ */ s(
231
231
  "div",
232
232
  {
233
- className: S(n.argumentInput, {
233
+ className: x(n.argumentInput, {
234
234
  [n.flash]: te,
235
235
  [n.replyInputContainer]: d
236
236
  }),
@@ -253,7 +253,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
253
253
  /* @__PURE__ */ _(
254
254
  "div",
255
255
  {
256
- className: S(n.argumentTextInputBox, {
256
+ className: x(n.argumentTextInputBox, {
257
257
  [n.argumentTextInputBoxisTablet]: !m,
258
258
  [n.replyEditorRow]: d
259
259
  }),
@@ -261,7 +261,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
261
261
  /* @__PURE__ */ s(
262
262
  "div",
263
263
  {
264
- className: S(n.argumentAuthorContainer, {
264
+ className: x(n.argumentAuthorContainer, {
265
265
  [n.argumentAuthorContainerMobile]: m,
266
266
  [n.argumentAuthorContainerActivated]: !m && w || d
267
267
  }),
@@ -288,7 +288,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
288
288
  {
289
289
  onClick: j,
290
290
  "data-testid": "argument-input",
291
- className: S(n.textEditorBox, {
291
+ className: x(n.textEditorBox, {
292
292
  [n.replyTextEditorBox]: d
293
293
  }),
294
294
  children: [
@@ -312,7 +312,7 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
312
312
  uid: `Argument${v}`,
313
313
  onActivation: j,
314
314
  showStylesControls: w,
315
- disabled: z || f || oe,
315
+ disabled: z || f || ie,
316
316
  maxLength: f ? !1 : h?.actions?.argumentMaxLength,
317
317
  disableRichText: h?.actions?.disableRichText || f,
318
318
  shortBar: d,
@@ -323,13 +323,13 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
323
323
  disableAutoActivate: ve
324
324
  }
325
325
  ),
326
- E?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: E && Object.values(E).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
326
+ B?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: B && Object.values(B).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
327
327
  w && N?.find(
328
328
  (e) => e.id === l
329
329
  ) && /* @__PURE__ */ _(
330
330
  "div",
331
331
  {
332
- className: S(
332
+ className: x(
333
333
  n.argumentInputWarning,
334
334
  n.disabledPositionWarning
335
335
  ),
@@ -384,5 +384,5 @@ const st = We(() => import("../../modal/side_modal/index.js").then((x) => ({ def
384
384
  ] });
385
385
  };
386
386
  export {
387
- Nt as ArgumentInput
387
+ yt as ArgumentInput
388
388
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.3.52",
3
+ "version": "0.3.53",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",