@logora/debate 0.3.98 → 0.3.100

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,9 +1,9 @@
1
1
  import { jsxs as v, jsx as s } from "react/jsx-runtime";
2
2
  import We from "@rooks/use-sessionstorage-state";
3
- import { useRef as Ye, useState as l, useEffect as h, Suspense as ke, lazy as Re } from "react";
4
- import { useIntl as je, FormattedMessage as ge } from "react-intl";
3
+ import { useRef as Ye, useState as l, useEffect as p, Suspense as ke, lazy as je } from "react";
4
+ import { useIntl as Re, FormattedMessage as ge } from "react-intl";
5
5
  import { useLocation as ze } from "react-router";
6
- import I from "classnames";
6
+ import S from "classnames";
7
7
  import n from "./ArgumentInput.module.scss.js";
8
8
  import { useDataProvider as Oe } from "../../data/data_provider/useDataProvider.js";
9
9
  import { useList as Je } from "../../list/list_provider/useList.js";
@@ -20,19 +20,19 @@ import { Avatar as at } from "../../user/avatar/Avatar.js";
20
20
  import { AuthorBox as st } from "../../user/author_box/AuthorBox.js";
21
21
  import { TextEditor as it } from "../text_editor/TextEditor.js";
22
22
  import { Icon as ot } from "../../icons/icon/Icon.js";
23
- const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ default: S.SideModal }))), Lt = ({
24
- argumentListId: S,
23
+ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ default: x.SideModal }))), Lt = ({
24
+ argumentListId: x,
25
25
  avatarSize: he = 48,
26
26
  disabled: O = !1,
27
27
  positions: a = [],
28
- disabledPositions: x = [],
28
+ disabledPositions: N = [],
29
29
  groupId: b,
30
30
  groupName: pe,
31
31
  groupType: J,
32
32
  hideSourceAction: _e = !1,
33
33
  isReply: r = !1,
34
34
  onSubmit: K,
35
- parentId: F,
35
+ parentId: T,
36
36
  placeholder: Me,
37
37
  positionId: A,
38
38
  focusOnInit: ve = !1,
@@ -43,52 +43,52 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
43
43
  disableAutoActivate: Ce = !1,
44
44
  autoFocus: H = !1
45
45
  }) => {
46
- const o = je(), Q = Oe(), N = Je(), p = Ke(), {
46
+ const o = Re(), Q = Oe(), y = Je(), _ = Ke(), {
47
47
  focus: X,
48
48
  setFocus: Z,
49
49
  setReset: we,
50
50
  inputContent: B,
51
51
  setInputContent: ee,
52
52
  setInputRichContent: Ie
53
- } = Ge(), { isLoggedIn: C, currentUser: u } = He(), { errors: E, validate: V } = Qe(), { isMobile: m } = Xe(), Se = ze(), te = Ye(null), [U, $] = l([]), [q, D] = l(""), [ne, W] = l(null), [d, _] = l(null), [ae, se] = l(null), [ie, oe] = l(!1), [w, re] = l(!1), [M, ue] = l({}), [xe, Y] = l(!1), [f, Ne] = We(
53
+ } = Ge(), { isLoggedIn: C, currentUser: u } = He(), { errors: E, validate: V } = Qe(), { isMobile: m } = Xe(), Se = ze(), te = Ye(null), [U, $] = l([]), [q, D] = l(""), [ne, W] = l(null), [d, M] = l(null), [ae, se] = l(null), [ie, oe] = l(!1), [w, re] = l(!1), [I, ue] = l({}), [xe, Y] = l(!1), [f, Ne] = We(
54
54
  "userSide",
55
55
  {}
56
56
  ), [g, Te] = l(
57
- !C && p?.actions?.disableInputForVisitor
58
- ), k = Ze(), { showModal: ye } = et(), { toast: R } = tt() || {}, de = new URLSearchParams(
57
+ !C && _?.actions?.disableInputForVisitor
58
+ ), k = Ze(), { showModal: ye } = et(), { toast: j } = tt() || {}, de = new URLSearchParams(
59
59
  typeof window < "u" ? window.location.search : Se.search
60
60
  );
61
- h(() => {
61
+ p(() => {
62
62
  Te(
63
- !C && p?.actions?.disableInputForVisitor
63
+ !C && _?.actions?.disableInputForVisitor
64
64
  );
65
- }, [C, p]);
66
- const j = u?.role === "editor" || u?.role === "moderator", le = u?.moderation_status === "banned";
67
- h(() => {
65
+ }, [C, _]);
66
+ const R = u?.role === "editor" || u?.role === "moderator", le = u?.moderation_status === "banned";
67
+ p(() => {
68
68
  let e = null;
69
- typeof window < "u" && (e = de.get("positionId")), A && A != a[2]?.id && a?.find((t) => t.id === A) ? _(A) : e && e != a[2]?.id ? _(e) : f && f.groupId == b && f.positionId != a[2]?.id && _(f.positionId);
70
- }, [A]), h(() => {
69
+ typeof window < "u" && (e = de.get("positionId")), A && A != a[2]?.id && a?.find((t) => t.id === A) ? M(A) : e && e != a[2]?.id ? M(e) : f && f.groupId == b && f.positionId != a[2]?.id && M(f.positionId);
70
+ }, [A]), p(() => {
71
71
  H && Y(!0);
72
- }, [H]), h(() => {
73
- P && (z(), Y(!0), T());
74
- }, [P]), h(() => {
72
+ }, [H]), p(() => {
73
+ P && (z(), Y(!0), L());
74
+ }, [P]), p(() => {
75
75
  if (typeof window < "u") {
76
76
  const e = ve || de.get("initArgument");
77
- (e === !0 || e === "true") && (Y(!0), T(), $e());
77
+ (e === !0 || e === "true") && (Y(!0), L(), $e());
78
78
  }
79
- }, []), h(() => {
80
- X && (T(), Z(!1));
81
- }, [X]), h(() => {
79
+ }, []), p(() => {
80
+ X && (L(), Z(!1));
81
+ }, [X]), p(() => {
82
82
  B?.id && (Le(B), Z(!0));
83
83
  }, [B]);
84
84
  const Le = (e) => {
85
- ue(e), re(!0), $(e.sources), D(e.content), W(e.rich_content), se(e.id), T(), _(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ie(e.rich_content) : ee(e.content);
86
- }, T = () => {
85
+ ue(e), re(!0), $(e.sources), D(e.content), W(e.rich_content), se(e.id), L(), M(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ie(e.rich_content) : ee(e.content);
86
+ }, L = () => {
87
87
  te.current.scrollIntoView(!1);
88
88
  }, ce = () => {
89
89
  D(""), W(null), ue({}), se(null), $([]), we(!0), ee(null);
90
90
  }, Fe = (e) => {
91
- _(e), fe(e);
91
+ M(e), fe(e);
92
92
  }, Pe = () => {
93
93
  ye(
94
94
  /* @__PURE__ */ s(ke, { fallback: null, children: /* @__PURE__ */ s(
@@ -101,13 +101,13 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
101
101
  onChooseSide: Fe,
102
102
  positions: a,
103
103
  title: pe,
104
- disabledPositions: !r && x,
104
+ disabledPositions: !r && N,
105
105
  isNeutral: f && f.groupId == b && f.positionId === a[2]?.id
106
106
  }
107
107
  ) })
108
108
  );
109
109
  }, Be = () => {
110
- C ? ae ? Ue() : !a || a?.length === 0 || !x?.find((e) => e?.id === d) && d || j && r ? fe(r && j && a[0]?.id) : Pe() : k({ loginAction: "argument" });
110
+ C ? ae ? Ue() : !a || a?.length === 0 || !N?.find((e) => e?.id === d) && d || R && r ? fe(r && R && a[0]?.id) : Pe() : k({ loginAction: "argument" });
111
111
  }, Ee = (e, t) => {
112
112
  g ? k({ loginAction: "argument" }) : (D(e), W(t), V({ content: e }, [{ content: ["url", null] }]));
113
113
  }, Ve = (e) => {
@@ -124,8 +124,8 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
124
124
  group_id: b,
125
125
  ...J && { group_type: J },
126
126
  ...t && { position_id: t },
127
- is_reply: !!F,
128
- message_id: F || null,
127
+ is_reply: !!T,
128
+ message_id: T || null,
129
129
  source_ids: U?.map((i) => i.id)
130
130
  };
131
131
  V(c, me) && (t && a && a.map((i) => i.id).includes(t) && Ne({
@@ -133,8 +133,8 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
133
133
  positionId: t
134
134
  }), ce(), Q.create("messages", c).then((i) => {
135
135
  if (i.data.success) {
136
- if (F)
137
- K(i.data.data.resource), R(
136
+ if (T)
137
+ K(i.data.data.resource), j(
138
138
  o.formatMessage({
139
139
  id: "alert.argument_create",
140
140
  defaultMessage: "Your contribution has been sent !"
@@ -148,12 +148,12 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
148
148
  }
149
149
  );
150
150
  else {
151
- const y = i.data.data.resource;
152
- let L = S;
153
- t && !m && (L = `argumentList${y.position.id}`), K?.(
151
+ const h = i.data.data.resource;
152
+ let F = x;
153
+ t && !m && (F = `argumentList${h.position.id}`), K?.(
154
154
  q,
155
155
  a.find((De) => De.id === t) || null
156
- ), N.add(L, [y]), R(
156
+ ), y.add(F, [h]), j(
157
157
  o.formatMessage({
158
158
  id: "alert.argument_create",
159
159
  defaultMessage: "Your contribution has been sent !"
@@ -188,13 +188,17 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
188
188
  V(e, me) && Q.update("messages", ae, e).then((t) => {
189
189
  if (t.data.success) {
190
190
  const c = t.data.data.resource;
191
- let i = S;
192
- if (M?.is_reply && M?.message_id ? i = `argument_${M.message_id}_reply_list` : d && !m && (i = `argumentList${c.position?.id}`), !M?.is_reply && M?.position?.id != c.position?.id && !m) {
193
- const y = `argumentList${M.position.id}`, L = `argumentList${c.position.id}`;
194
- N.remove(y, [c]), N.add(L, [c]);
191
+ let i = x;
192
+ if (I?.is_reply || r) {
193
+ const h = I?.message_id || T;
194
+ h && (i = `argument_${h}_reply_list`);
195
+ } else d && !m && (i = `argumentList${c.position?.id}`);
196
+ if (!I?.is_reply && I?.position?.id != c.position?.id && !m) {
197
+ const h = `argumentList${I.position.id}`, F = `argumentList${c.position.id}`;
198
+ y.remove(h, [c]), y.add(F, [c]);
195
199
  } else
196
- N.update(i, [c]);
197
- R(o.formatMessage({ id: "alert.argument_modify" }), {
200
+ y.update(i, [c]);
201
+ j(o.formatMessage({ id: "alert.argument_modify" }), {
198
202
  type: "success"
199
203
  }), ce();
200
204
  }
@@ -210,7 +214,7 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
210
214
  }, z = () => {
211
215
  g ? k({ loginAction: "argument" }) : re(!0);
212
216
  }, qe = () => {
213
- const e = x.find(
217
+ const e = N.find(
214
218
  (t) => t.id === d
215
219
  );
216
220
  if (e)
@@ -233,12 +237,12 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
233
237
  /* @__PURE__ */ s(
234
238
  "div",
235
239
  {
236
- className: I(n.argumentInput, {
240
+ className: S(n.argumentInput, {
237
241
  [n.flash]: ie,
238
242
  [n.replyInputContainer]: r
239
243
  }),
240
244
  children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: te, children: /* @__PURE__ */ v("div", { className: n.argumentInputBox, children: [
241
- a.length > 0 && C && (!r || !j) && /* @__PURE__ */ v("div", { className: n.userPosition, children: [
245
+ a.length > 0 && C && (!r || !R) && /* @__PURE__ */ v("div", { className: n.userPosition, children: [
242
246
  /* @__PURE__ */ s("div", { children: o.formatMessage({
243
247
  id: "input.position",
244
248
  defaultMessage: "Your position"
@@ -249,14 +253,14 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
249
253
  activeLabel: d === a[0].id ? 0 : d === a[1].id ? 1 : null,
250
254
  firstLabel: a[0],
251
255
  secondLabel: a[1],
252
- onChange: (e) => _(a[e].id)
256
+ onChange: (e) => M(a[e].id)
253
257
  }
254
258
  )
255
259
  ] }),
256
260
  /* @__PURE__ */ v(
257
261
  "div",
258
262
  {
259
- className: I(n.argumentTextInputBox, {
263
+ className: S(n.argumentTextInputBox, {
260
264
  [n.argumentTextInputBoxisTablet]: !m,
261
265
  [n.replyEditorRow]: r
262
266
  }),
@@ -264,7 +268,7 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
264
268
  /* @__PURE__ */ s(
265
269
  "div",
266
270
  {
267
- className: I(n.argumentAuthorContainer, {
271
+ className: S(n.argumentAuthorContainer, {
268
272
  [n.argumentAuthorContainerMobile]: m,
269
273
  [n.argumentAuthorContainerActivated]: !m && w || r
270
274
  }),
@@ -291,7 +295,7 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
291
295
  {
292
296
  onClick: z,
293
297
  "data-testid": "argument-input",
294
- className: I(n.textEditorBox, {
298
+ className: S(n.textEditorBox, {
295
299
  [n.replyTextEditorBox]: r
296
300
  }),
297
301
  children: [
@@ -316,11 +320,11 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
316
320
  onActivation: z,
317
321
  showStylesControls: w,
318
322
  disabled: O || g || le,
319
- maxLength: g ? !1 : p?.actions?.argumentMaxLength,
320
- disableRichText: p?.actions?.disableRichText || g,
323
+ maxLength: g ? !1 : _?.actions?.argumentMaxLength,
324
+ disableRichText: _?.actions?.disableRichText || g,
321
325
  shortBar: r,
322
326
  hideSubmit: g,
323
- allowedDomains: p?.allowed_sources,
327
+ allowedDomains: _?.allowed_sources,
324
328
  active: P,
325
329
  autoFocus: xe,
326
330
  hideCharCount: Ae,
@@ -328,12 +332,12 @@ const rt = Re(() => import("../../modal/side_modal/index.js").then((S) => ({ def
328
332
  }
329
333
  ),
330
334
  E?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: E && Object.values(E).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
331
- w && x?.find(
335
+ w && N?.find(
332
336
  (e) => e.id === d
333
337
  ) && /* @__PURE__ */ v(
334
338
  "div",
335
339
  {
336
- className: I(
340
+ className: S(
337
341
  n.argumentInputWarning,
338
342
  n.disabledPositionWarning
339
343
  ),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.3.98",
3
+ "version": "0.3.100",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",