@logora/debate 0.3.100 → 0.3.102

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
- import { jsx as o, jsxs as l, Fragment as h } from "react/jsx-runtime";
1
+ import { jsx as o, jsxs as l, Fragment as f } from "react/jsx-runtime";
2
2
  import B from "classnames";
3
- import { useState as f, useEffect as le, useCallback as ne, Suspense as de, lazy as ce } from "react";
3
+ import { useState as y, useEffect as le, useCallback as ne, Suspense as de, lazy as ce } from "react";
4
4
  import { useIntl as pe } from "react-intl";
5
5
  import s from "./Argument.module.scss.js";
6
6
  import { ReplyFooter as me } from "./ReplyFooter.js";
@@ -23,18 +23,18 @@ import { Button as Te } from "../../action/button/Button.js";
23
23
  const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({ default: e.ArgumentInput }))), F = (e) => e?.replace(/ /g, " "), we = ({
24
24
  argument: e,
25
25
  argumentReplies: n,
26
- nestingLevel: y = 0,
27
- maxNestingLevel: I = 2,
28
- groupType: C,
29
- groupName: S,
30
- positions: _ = [],
26
+ nestingLevel: _ = 0,
27
+ maxNestingLevel: S = 2,
28
+ groupType: R,
29
+ groupName: T,
30
+ positions: g = [],
31
31
  disableLinks: P = !1,
32
- parentArgument: d,
32
+ parentArgument: c,
33
33
  flashParent: j,
34
34
  expandable: G,
35
- disabled: g = !1,
36
- hideFooter: R = !1,
37
- hideReplies: T,
35
+ disabled: b = !1,
36
+ hideFooter: N = !1,
37
+ hideReplies: w,
38
38
  vote: H,
39
39
  fixedContentHeight: V = !1,
40
40
  enableEdition: z = !0,
@@ -45,7 +45,7 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
45
45
  replyRedirectUrl: K,
46
46
  hideContent: Q = !1
47
47
  }) => {
48
- const i = pe(), { isLoggedIn: W, currentUser: c } = he(), N = c?.moderation_status === "banned", r = fe(), X = ye(), [p, b] = f(!1), [Z, w] = f(!1), [ee, te] = f(!1), A = ue(e), [m, x] = f(), u = D(
48
+ const a = pe(), { isLoggedIn: W, currentUser: p } = he(), A = p?.moderation_status === "banned", r = fe(), X = ye(), [m, M] = y(!1), [Z, x] = y(!1), [ee, te] = y(!1), L = ue(e), [u, v] = y(), h = D(
49
49
  e.content,
50
50
  e.language,
51
51
  "content",
@@ -55,54 +55,54 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
55
55
  e.position?.language,
56
56
  "name",
57
57
  e.position?.translation_entries
58
- ), M = `argument_${e.id}`, v = e.position && _?.map((t) => t.id).indexOf(e.position.id) + 1;
58
+ ), I = `argument_${e.id}`, C = e.position && g?.map((t) => t.id).indexOf(e.position.id) + 1;
59
59
  le(() => {
60
60
  n !== void 0 && ae();
61
61
  }, [n]);
62
62
  const se = (t) => {
63
- if (M === t) {
64
- const $ = document.getElementById(t);
65
- $ && $.scrollIntoView({ behavior: "smooth" }), w(!0);
63
+ if (I === t) {
64
+ const d = document.getElementById(t);
65
+ d && d.scrollIntoView({ behavior: "smooth" }), x(!0);
66
66
  }
67
- }, L = () => {
67
+ }, U = () => {
68
68
  te((t) => !t);
69
69
  }, k = () => {
70
- b((t) => !t), x([]);
70
+ M((t) => !t), v([]);
71
71
  }, re = (t) => {
72
- if (!m?.find((a) => a.id === t.id))
72
+ if (!u?.find((i) => i.id === t.id))
73
73
  return t;
74
- }, ie = ne((t, a) => /* @__PURE__ */ o(
74
+ }, ie = ne((t, i) => /* @__PURE__ */ o(
75
75
  _e,
76
76
  {
77
77
  publisher: t.publisher,
78
78
  url: t.source_url,
79
79
  title: t.title,
80
- index: a
80
+ index: i
81
81
  },
82
- a
82
+ i
83
83
  ), []), ae = () => {
84
84
  if (n && Array.isArray(n)) {
85
85
  const t = n.filter(
86
- (a) => a.reply_to_id === e.id
86
+ (i) => i.reply_to_id === e.id
87
87
  );
88
- t.length > 0 && (x(t), b(!0));
88
+ t.length > 0 && (v(t), M(!0));
89
89
  }
90
- }, U = (t = null) => /* @__PURE__ */ o(
90
+ }, $ = (t = null) => /* @__PURE__ */ o(
91
91
  Ae,
92
92
  {
93
93
  ...t ? { argument: t } : {},
94
- nestingLevel: y + 1,
95
- maxNestingLevel: I,
96
- disabled: g,
97
- groupName: S,
98
- groupType: C,
99
- positions: _,
94
+ nestingLevel: _ + 1,
95
+ maxNestingLevel: S,
96
+ disabled: b,
97
+ groupName: T,
98
+ groupType: R,
99
+ positions: g,
100
100
  argumentReplies: n,
101
101
  parentArgument: e,
102
- flashParent: (a) => se(`argument_${a}`)
102
+ flashParent: (i) => se(`argument_${i}`)
103
103
  }
104
104
  );
105
- return /* @__PURE__ */ l(ge, { elementId: M, onScroll: () => w(!0), children: [
105
+ return /* @__PURE__ */ l(ge, { elementId: I, onScroll: () => x(!0), children: [
106
106
  /* @__PURE__ */ l(
107
107
  "div",
108
108
  {
@@ -112,10 +112,10 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
112
112
  [s.flash]: Z,
113
113
  [s.argumentReply]: e.is_reply === !0
114
114
  },
115
- s[`level-${y}`],
116
- s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && v}`]
115
+ s[`level-${_}`],
116
+ s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && C}`]
117
117
  ),
118
- id: M,
118
+ id: I,
119
119
  children: [
120
120
  /* @__PURE__ */ o(
121
121
  be,
@@ -124,7 +124,7 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
124
124
  author: e.author,
125
125
  tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : oe.translatedContent,
126
126
  date: e.created_at,
127
- tagClassName: s[`headerPosition-${v}`],
127
+ tagClassName: s[`headerPosition-${C}`],
128
128
  disableLinks: P,
129
129
  isDeleted: e.is_deleted,
130
130
  showModerationFeedback: q ?? (e.status === "rejected" && r.moderation?.showFeedback === !0),
@@ -133,13 +133,13 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
133
133
  moderationPolicyUrl: r.provider?.userGuideUrl
134
134
  }
135
135
  ),
136
- e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
136
+ e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: a.formatMessage({
137
137
  id: "info.deleted_by_user",
138
138
  defaultMessage: "Content deleted by the user"
139
- }) }) : Q ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
139
+ }) }) : Q ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: a.formatMessage({
140
140
  id: "argument.argument.content_deleted",
141
141
  defaultMessage: "This content has been removed."
142
- }) }) : /* @__PURE__ */ l(h, { children: [
142
+ }) }) : /* @__PURE__ */ l(f, { children: [
143
143
  /* @__PURE__ */ l(
144
144
  "div",
145
145
  {
@@ -147,21 +147,21 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
147
147
  [s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? V : !1
148
148
  }),
149
149
  children: [
150
- e.is_reply && d && /* @__PURE__ */ l(
150
+ e.is_reply && c && /* @__PURE__ */ l(
151
151
  "div",
152
152
  {
153
153
  className: s.replyTo,
154
- onClick: () => j(d.id),
154
+ onClick: () => j(c.id),
155
155
  children: [
156
- i.formatMessage({
156
+ a.formatMessage({
157
157
  id: "info.replying_to",
158
158
  defaultMessage: "Replying to"
159
159
  }),
160
160
  /* @__PURE__ */ l("span", { className: s.replyingTo, children: [
161
- d.is_deleted ? i.formatMessage({
161
+ c.is_deleted ? a.formatMessage({
162
162
  id: "info.deleted",
163
163
  defaultMessage: "Deleted"
164
- }) : d.author.full_name,
164
+ }) : c.author.full_name,
165
165
  /* @__PURE__ */ o(E, { name: "chat", height: 16 })
166
166
  ] })
167
167
  ]
@@ -170,32 +170,32 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
170
170
  /* @__PURE__ */ o(
171
171
  Me,
172
172
  {
173
- content: /* @__PURE__ */ l(h, { children: [
174
- e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: i.formatMessage({
173
+ content: /* @__PURE__ */ l(f, { children: [
174
+ e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: a.formatMessage({
175
175
  id: "argument.argument.updated",
176
176
  defaultMessage: "Updated argument"
177
177
  }) }),
178
- A && !u.isTranslated ? /* @__PURE__ */ o(
178
+ L && !h.isTranslated ? /* @__PURE__ */ o(
179
179
  "div",
180
180
  {
181
181
  className: s.argumentContent,
182
- dangerouslySetInnerHTML: { __html: F(A) }
182
+ dangerouslySetInnerHTML: { __html: F(L) }
183
183
  }
184
- ) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: F(u.translatedContent) }),
185
- u.isTranslated && /* @__PURE__ */ o(
184
+ ) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: F(h.translatedContent) }),
185
+ h.isTranslated && /* @__PURE__ */ o(
186
186
  ve,
187
187
  {
188
188
  language: e.language,
189
- callback: () => u.toggleContent()
189
+ callback: () => h.toggleContent()
190
190
  }
191
191
  )
192
192
  ] }),
193
193
  lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ? J : void 0,
194
- readMoreText: i.formatMessage({
194
+ readMoreText: a.formatMessage({
195
195
  id: "action.read_more",
196
196
  defaultMessage: "Read more"
197
197
  }),
198
- readLessText: i.formatMessage({
198
+ readLessText: a.formatMessage({
199
199
  id: "action.read_less",
200
200
  defaultMessage: "Read less"
201
201
  }),
@@ -208,24 +208,24 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
208
208
  ),
209
209
  e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(ie) })
210
210
  ] }),
211
- !R && !e.is_deleted && /* @__PURE__ */ o(
211
+ !N && !e.is_deleted && /* @__PURE__ */ o(
212
212
  Ie,
213
213
  {
214
214
  resource: e,
215
- disabled: g || e.status === "rejected" || !W && r?.actions?.disableInputForVisitor === !0 || N,
215
+ disabled: b || e.status === "rejected" || !W && r?.actions?.disableInputForVisitor === !0 || A,
216
216
  reportType: "Message",
217
217
  softDelete: r.actions?.softDelete,
218
218
  deleteType: "messages",
219
219
  deleteListId: Y,
220
- enableReply: y <= I || c.role === "editor" || c.role === "moderator",
221
- handleReplyTo: L,
220
+ enableReply: _ <= S || p.role === "editor" || p.role === "moderator",
221
+ handleReplyTo: U,
222
222
  replyRedirectUrl: K,
223
223
  shareUrl: `https://app.logora.fr/share/a/${e.id}`,
224
- shareTitle: i.formatMessage({
224
+ shareTitle: a.formatMessage({
225
225
  id: "share.argument.title",
226
226
  defaultMessage: "Share a debate"
227
227
  }),
228
- shareText: i.formatMessage({
228
+ shareText: a.formatMessage({
229
229
  id: "share.argument.text",
230
230
  defaultMessage: "This argument may interest you"
231
231
  }),
@@ -243,18 +243,18 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
243
243
  voteableId: e.id,
244
244
  totalUpvote: e.upvotes,
245
245
  totalDownvote: 0,
246
- activeClassName: s[`voteButtonPosition-${v}`],
247
- disabled: e.status === "rejected" || c?.id === e?.author?.id || N
246
+ activeClassName: s[`voteButtonPosition-${C}`],
247
+ disabled: e.status === "rejected" || p?.id === e?.author?.id || A
248
248
  }
249
249
  )
250
250
  }
251
251
  ),
252
- !R && !T && /* @__PURE__ */ o(
252
+ !N && !w && /* @__PURE__ */ o(
253
253
  me,
254
254
  {
255
255
  numberReplies: e.number_replies,
256
256
  repliesAuthors: e.replies_authors,
257
- expandReplies: p,
257
+ expandReplies: m,
258
258
  onToggleReplies: k,
259
259
  isReply: e.is_reply
260
260
  }
@@ -262,26 +262,33 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
262
262
  ]
263
263
  }
264
264
  ),
265
- !T && /* @__PURE__ */ l(h, { children: [
265
+ !w && /* @__PURE__ */ l(f, { children: [
266
266
  ee && /* @__PURE__ */ o(de, { fallback: null, children: /* @__PURE__ */ o(
267
267
  Ne,
268
268
  {
269
269
  groupId: e.group_id,
270
- groupType: C,
271
- groupName: S,
272
- positions: _,
270
+ groupType: R,
271
+ groupName: T,
272
+ positions: g,
273
273
  parentId: e.id,
274
274
  positionId: H?.position_id,
275
- disabled: g,
275
+ disabled: b,
276
276
  hideSourceAction: r?.actions?.disableUserSources || !1,
277
277
  onSubmit: (t) => {
278
- const a = `argument_${e.id}_reply_list`;
279
- X.add(a, [t]), L(), b(!0);
278
+ const i = `argument_${e.id}_reply_list`;
279
+ X.add(i, [t]), U(), M(!0);
280
+ },
281
+ onUpdate: (t) => {
282
+ v(
283
+ (i) => i?.map(
284
+ (d) => d.id === t.id ? { ...d, ...t } : d
285
+ )
286
+ );
280
287
  },
281
288
  isReply: !0,
282
289
  autoFocus: !0,
283
290
  avatarSize: 40,
284
- placeholder: i.formatMessage({
291
+ placeholder: a.formatMessage({
285
292
  id: "input.reply_input.your_answer",
286
293
  defaultMessage: "Your answer"
287
294
  }),
@@ -290,8 +297,8 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
290
297
  },
291
298
  `Reply${e.id}`
292
299
  ) }),
293
- m?.length > 0 && p && /* @__PURE__ */ o("div", { className: s.repliesList, children: m.map((t) => U(t)) }),
294
- p && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
300
+ u?.length > 0 && m && /* @__PURE__ */ o("div", { className: s.repliesList, children: u.map((t) => $(t)) }),
301
+ m && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
295
302
  Se,
296
303
  {
297
304
  voteableType: "Message",
@@ -307,18 +314,18 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
307
314
  perPage: 5,
308
315
  display: "column",
309
316
  resourcePropName: "argument",
310
- emptyListComponent: /* @__PURE__ */ o(h, {}),
317
+ emptyListComponent: /* @__PURE__ */ o(f, {}),
311
318
  transformData: (t) => re(t),
312
- children: U(e)
319
+ children: $(e)
313
320
  }
314
321
  ) }),
315
- m?.length > 0 && !p && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
322
+ u?.length > 0 && !m && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
316
323
  Te,
317
324
  {
318
325
  role: "link",
319
326
  rightIcon: /* @__PURE__ */ o(E, { name: "lightArrow", height: 10, width: 10 }),
320
327
  handleClick: k,
321
- children: i.formatMessage({
328
+ children: a.formatMessage({
322
329
  id: "argument.argument.see_more",
323
330
  defaultMessage: "See more"
324
331
  })
@@ -1,137 +1,138 @@
1
1
  import { jsxs as v, jsx as s } from "react/jsx-runtime";
2
- import We from "@rooks/use-sessionstorage-state";
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
- import { useLocation as ze } from "react-router";
2
+ import Ye from "@rooks/use-sessionstorage-state";
3
+ import { useRef as ke, useState as c, useEffect as p, Suspense as je, lazy as Re } from "react";
4
+ import { useIntl as ze, FormattedMessage as he } from "react-intl";
5
+ import { useLocation as Oe } from "react-router";
6
6
  import S from "classnames";
7
7
  import n from "./ArgumentInput.module.scss.js";
8
- import { useDataProvider as Oe } from "../../data/data_provider/useDataProvider.js";
9
- import { useList as Je } from "../../list/list_provider/useList.js";
10
- import { useConfig as Ke } from "../../data/config_provider/useConfig.js";
11
- import { useInput as Ge } from "../input_provider/useInput.js";
12
- import { useAuth as He } from "../../auth/use_auth/useAuth.js";
13
- import { useFormValidation as Qe } from "../../forms/use_form_validation/useFormValidation.js";
14
- import { useResponsive as Xe } from "../../hooks/use_responsive/useResponsive.js";
15
- import { useAuthRequired as Ze } from "../../hooks/use_auth_required/useAuthRequired.js";
16
- import { useModal as et } from "../../dialog/modal/useModal.js";
17
- import { useToast as tt } from "../../dialog/toast_provider/useToast.js";
18
- import { TogglePosition as nt } from "../toggle_position/TogglePosition.js";
19
- import { Avatar as at } from "../../user/avatar/Avatar.js";
20
- import { AuthorBox as st } from "../../user/author_box/AuthorBox.js";
21
- import { TextEditor as it } from "../text_editor/TextEditor.js";
22
- import { Icon as ot } from "../../icons/icon/Icon.js";
23
- const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ default: x.SideModal }))), Lt = ({
8
+ import { useDataProvider as Je } from "../../data/data_provider/useDataProvider.js";
9
+ import { useList as Ke } from "../../list/list_provider/useList.js";
10
+ import { useConfig as Ge } from "../../data/config_provider/useConfig.js";
11
+ import { useInput as He } from "../input_provider/useInput.js";
12
+ import { useAuth as Qe } from "../../auth/use_auth/useAuth.js";
13
+ import { useFormValidation as Xe } from "../../forms/use_form_validation/useFormValidation.js";
14
+ import { useResponsive as Ze } from "../../hooks/use_responsive/useResponsive.js";
15
+ import { useAuthRequired as et } from "../../hooks/use_auth_required/useAuthRequired.js";
16
+ import { useModal as tt } from "../../dialog/modal/useModal.js";
17
+ import { useToast as nt } from "../../dialog/toast_provider/useToast.js";
18
+ import { TogglePosition as at } from "../toggle_position/TogglePosition.js";
19
+ import { Avatar as st } from "../../user/avatar/Avatar.js";
20
+ import { AuthorBox as it } from "../../user/author_box/AuthorBox.js";
21
+ import { TextEditor as ot } from "../text_editor/TextEditor.js";
22
+ import { Icon as rt } from "../../icons/icon/Icon.js";
23
+ const ut = Re(() => import("../../modal/side_modal/index.js").then((x) => ({ default: x.SideModal }))), Ft = ({
24
24
  argumentListId: x,
25
- avatarSize: he = 48,
25
+ avatarSize: pe = 48,
26
26
  disabled: O = !1,
27
27
  positions: a = [],
28
28
  disabledPositions: N = [],
29
29
  groupId: b,
30
- groupName: pe,
30
+ groupName: _e,
31
31
  groupType: J,
32
- hideSourceAction: _e = !1,
32
+ hideSourceAction: Me = !1,
33
33
  isReply: r = !1,
34
34
  onSubmit: K,
35
+ onUpdate: G,
35
36
  parentId: T,
36
- placeholder: Me,
37
+ placeholder: ve,
37
38
  positionId: A,
38
- focusOnInit: ve = !1,
39
+ focusOnInit: be = !1,
39
40
  activeOnInit: P = !1,
40
- userGuideUrl: G,
41
- hideUserGuideLink: be = !1,
42
- hideCharCount: Ae = !1,
43
- disableAutoActivate: Ce = !1,
44
- autoFocus: H = !1
41
+ userGuideUrl: H,
42
+ hideUserGuideLink: Ae = !1,
43
+ hideCharCount: Ce = !1,
44
+ disableAutoActivate: we = !1,
45
+ autoFocus: Q = !1
45
46
  }) => {
46
- const o = Re(), Q = Oe(), y = Je(), _ = Ke(), {
47
- focus: X,
48
- setFocus: Z,
49
- setReset: we,
47
+ const o = ze(), X = Je(), y = Ke(), _ = Ge(), {
48
+ focus: Z,
49
+ setFocus: ee,
50
+ setReset: Ie,
50
51
  inputContent: B,
51
- setInputContent: ee,
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, 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(
52
+ setInputContent: te,
53
+ setInputRichContent: Se
54
+ } = He(), { isLoggedIn: C, currentUser: u } = Qe(), { errors: E, validate: V } = Xe(), { isMobile: m } = Ze(), xe = Oe(), ne = ke(null), [$, q] = c([]), [D, U] = c(""), [ae, W] = c(null), [d, M] = c(null), [se, ie] = c(null), [oe, re] = c(!1), [w, ue] = c(!1), [I, de] = c({}), [Ne, Y] = c(!1), [f, Te] = Ye(
54
55
  "userSide",
55
56
  {}
56
- ), [g, Te] = l(
57
+ ), [g, ye] = c(
57
58
  !C && _?.actions?.disableInputForVisitor
58
- ), k = Ze(), { showModal: ye } = et(), { toast: j } = tt() || {}, de = new URLSearchParams(
59
- typeof window < "u" ? window.location.search : Se.search
59
+ ), k = et(), { showModal: Le } = tt(), { toast: j } = nt() || {}, le = new URLSearchParams(
60
+ typeof window < "u" ? window.location.search : xe.search
60
61
  );
61
62
  p(() => {
62
- Te(
63
+ ye(
63
64
  !C && _?.actions?.disableInputForVisitor
64
65
  );
65
66
  }, [C, _]);
66
- const R = u?.role === "editor" || u?.role === "moderator", le = u?.moderation_status === "banned";
67
+ const R = u?.role === "editor" || u?.role === "moderator", ce = u?.moderation_status === "banned";
67
68
  p(() => {
68
69
  let e = null;
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
+ typeof window < "u" && (e = le.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
71
  }, [A]), p(() => {
71
- H && Y(!0);
72
- }, [H]), p(() => {
72
+ Q && Y(!0);
73
+ }, [Q]), p(() => {
73
74
  P && (z(), Y(!0), L());
74
75
  }, [P]), p(() => {
75
76
  if (typeof window < "u") {
76
- const e = ve || de.get("initArgument");
77
- (e === !0 || e === "true") && (Y(!0), L(), $e());
77
+ const e = be || le.get("initArgument");
78
+ (e === !0 || e === "true") && (Y(!0), L(), De());
78
79
  }
79
80
  }, []), p(() => {
80
- X && (L(), Z(!1));
81
- }, [X]), p(() => {
82
- B?.id && (Le(B), Z(!0));
81
+ Z && (L(), ee(!1));
82
+ }, [Z]), p(() => {
83
+ B?.id && (Fe(B), ee(!0));
83
84
  }, [B]);
84
- const Le = (e) => {
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);
85
+ const Fe = (e) => {
86
+ de(e), ue(!0), q(e.sources), U(e.content), W(e.rich_content), ie(e.id), L(), M(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Se(e.rich_content) : te(e.content);
86
87
  }, L = () => {
87
- te.current.scrollIntoView(!1);
88
- }, ce = () => {
89
- D(""), W(null), ue({}), se(null), $([]), we(!0), ee(null);
90
- }, Fe = (e) => {
91
- M(e), fe(e);
92
- }, Pe = () => {
93
- ye(
94
- /* @__PURE__ */ s(ke, { fallback: null, children: /* @__PURE__ */ s(
95
- rt,
88
+ ne.current.scrollIntoView(!1);
89
+ }, me = () => {
90
+ U(""), W(null), de({}), ie(null), q([]), Ie(!0), te(null);
91
+ }, Pe = (e) => {
92
+ M(e), ge(e);
93
+ }, Be = () => {
94
+ Le(
95
+ /* @__PURE__ */ s(je, { fallback: null, children: /* @__PURE__ */ s(
96
+ ut,
96
97
  {
97
98
  modalTitle: o.formatMessage({
98
99
  id: "modal.side_modal.modal_title",
99
100
  defaultMessage: "Choose your side"
100
101
  }),
101
- onChooseSide: Fe,
102
+ onChooseSide: Pe,
102
103
  positions: a,
103
- title: pe,
104
+ title: _e,
104
105
  disabledPositions: !r && N,
105
106
  isNeutral: f && f.groupId == b && f.positionId === a[2]?.id
106
107
  }
107
108
  ) })
108
109
  );
109
- }, Be = () => {
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
- }, Ee = (e, t) => {
112
- g ? k({ loginAction: "argument" }) : (D(e), W(t), V({ content: e }, [{ content: ["url", null] }]));
113
- }, Ve = (e) => {
114
- $(e);
115
- }, me = [
110
+ }, Ee = () => {
111
+ C ? se ? qe() : !a || a?.length === 0 || !N?.find((e) => e?.id === d) && d || R && r ? ge(r && R && a[0]?.id) : Be() : k({ loginAction: "argument" });
112
+ }, Ve = (e, t) => {
113
+ g ? k({ loginAction: "argument" }) : (U(e), W(t), V({ content: e }, [{ content: ["url", null] }]));
114
+ }, $e = (e) => {
115
+ q(e);
116
+ }, fe = [
116
117
  { content: ["length", 3] },
117
118
  { content: ["required", null] },
118
119
  { content: ["url", null] },
119
120
  ...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
120
- ], fe = (e) => {
121
- const t = e || d, c = {
122
- content: q,
123
- rich_content: ne,
121
+ ], ge = (e) => {
122
+ const t = e || d, l = {
123
+ content: D,
124
+ rich_content: ae,
124
125
  group_id: b,
125
126
  ...J && { group_type: J },
126
127
  ...t && { position_id: t },
127
128
  is_reply: !!T,
128
129
  message_id: T || null,
129
- source_ids: U?.map((i) => i.id)
130
+ source_ids: $?.map((i) => i.id)
130
131
  };
131
- V(c, me) && (t && a && a.map((i) => i.id).includes(t) && Ne({
132
+ V(l, fe) && (t && a && a.map((i) => i.id).includes(t) && Te({
132
133
  groupId: b,
133
134
  positionId: t
134
- }), ce(), Q.create("messages", c).then((i) => {
135
+ }), me(), X.create("messages", l).then((i) => {
135
136
  if (i.data.success) {
136
137
  if (T)
137
138
  K(i.data.data.resource), j(
@@ -151,8 +152,8 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
151
152
  const h = i.data.data.resource;
152
153
  let F = x;
153
154
  t && !m && (F = `argumentList${h.position.id}`), K?.(
154
- q,
155
- a.find((De) => De.id === t) || null
155
+ D,
156
+ a.find((We) => We.id === t) || null
156
157
  ), y.add(F, [h]), j(
157
158
  o.formatMessage({
158
159
  id: "alert.argument_create",
@@ -178,42 +179,42 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
178
179
  );
179
180
  }
180
181
  }));
181
- }, Ue = () => {
182
+ }, qe = () => {
182
183
  const e = {
183
- content: q,
184
- rich_content: ne,
185
- source_ids: U?.map((t) => t.id),
184
+ content: D,
185
+ rich_content: ae,
186
+ source_ids: $?.map((t) => t.id),
186
187
  ...d && { position_id: d }
187
188
  };
188
- V(e, me) && Q.update("messages", ae, e).then((t) => {
189
+ V(e, fe) && X.update("messages", se, e).then((t) => {
189
190
  if (t.data.success) {
190
- const c = t.data.data.resource;
191
+ const l = t.data.data.resource;
191
192
  let i = x;
192
193
  if (I?.is_reply || r) {
193
194
  const h = I?.message_id || T;
194
195
  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]);
196
+ } else d && !m && (i = `argumentList${l.position?.id}`);
197
+ if (!I?.is_reply && I?.position?.id != l.position?.id && !m) {
198
+ const h = `argumentList${I.position.id}`, F = `argumentList${l.position.id}`;
199
+ y.remove(h, [l]), y.add(F, [l]);
199
200
  } else
200
- y.update(i, [c]);
201
- j(o.formatMessage({ id: "alert.argument_modify" }), {
201
+ y.update(i, [l]);
202
+ G && G(l), j(o.formatMessage({ id: "alert.argument_modify" }), {
202
203
  type: "success"
203
- }), ce();
204
+ }), me();
204
205
  }
205
206
  });
206
- }, $e = () => {
207
- if (!ie) {
208
- oe(!0);
207
+ }, De = () => {
208
+ if (!oe) {
209
+ re(!0);
209
210
  const e = setTimeout(() => {
210
- oe(!1);
211
+ re(!1);
211
212
  }, 2e3);
212
213
  return () => clearTimeout(e);
213
214
  }
214
215
  }, z = () => {
215
- g ? k({ loginAction: "argument" }) : re(!0);
216
- }, qe = () => {
216
+ g ? k({ loginAction: "argument" }) : ue(!0);
217
+ }, Ue = () => {
217
218
  const e = N.find(
218
219
  (t) => t.id === d
219
220
  );
@@ -227,7 +228,7 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
227
228
  );
228
229
  };
229
230
  return /* @__PURE__ */ v("div", { className: n.inputContainer, children: [
230
- O && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: le ? o.formatMessage({
231
+ O && /* @__PURE__ */ s("div", { className: n.disabledInputMask, children: ce ? o.formatMessage({
231
232
  id: "input.argument_input.user_banned",
232
233
  defaultMessage: "You are banned from the debate space."
233
234
  }) : o.formatMessage({
@@ -238,17 +239,17 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
238
239
  "div",
239
240
  {
240
241
  className: S(n.argumentInput, {
241
- [n.flash]: ie,
242
+ [n.flash]: oe,
242
243
  [n.replyInputContainer]: r
243
244
  }),
244
- children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: te, children: /* @__PURE__ */ v("div", { className: n.argumentInputBox, children: [
245
+ children: /* @__PURE__ */ s("div", { "data-tid": "action_add_argument", ref: ne, children: /* @__PURE__ */ v("div", { className: n.argumentInputBox, children: [
245
246
  a.length > 0 && C && (!r || !R) && /* @__PURE__ */ v("div", { className: n.userPosition, children: [
246
247
  /* @__PURE__ */ s("div", { children: o.formatMessage({
247
248
  id: "input.position",
248
249
  defaultMessage: "Your position"
249
250
  }) }),
250
251
  /* @__PURE__ */ s(
251
- nt,
252
+ at,
252
253
  {
253
254
  activeLabel: d === a[0].id ? 0 : d === a[1].id ? 1 : null,
254
255
  firstLabel: a[0],
@@ -273,14 +274,14 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
273
274
  [n.argumentAuthorContainerActivated]: !m && w || r
274
275
  }),
275
276
  children: !m && w || r ? /* @__PURE__ */ s(
276
- at,
277
+ st,
277
278
  {
278
279
  avatarUrl: u.image_url,
279
280
  userName: u.full_name,
280
- size: he
281
+ size: pe
281
282
  }
282
283
  ) : /* @__PURE__ */ s(
283
- st,
284
+ it,
284
285
  {
285
286
  fullName: u?.full_name || o.formatMessage({ id: "default_author.full_name" }),
286
287
  avatarUrl: u?.image_url,
@@ -300,35 +301,35 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
300
301
  }),
301
302
  children: [
302
303
  /* @__PURE__ */ s(
303
- it,
304
+ ot,
304
305
  {
305
306
  handleChange: (e, t) => {
306
- Ee(e, t);
307
+ Ve(e, t);
307
308
  },
308
309
  handleSourcesChange: (e) => {
309
- Ve(e);
310
+ $e(e);
310
311
  },
311
- placeholder: Me,
312
+ placeholder: ve,
312
313
  "aria-label": o.formatMessage({
313
314
  id: "input.argument_input.aria_label",
314
315
  defaultMessage: "Message input field"
315
316
  }),
316
- onSubmit: Be,
317
- sources: U,
318
- hideSourceAction: _e || g,
317
+ onSubmit: Ee,
318
+ sources: $,
319
+ hideSourceAction: Me || g,
319
320
  uid: `Argument${b}`,
320
321
  onActivation: z,
321
322
  showStylesControls: w,
322
- disabled: O || g || le,
323
+ disabled: O || g || ce,
323
324
  maxLength: g ? !1 : _?.actions?.argumentMaxLength,
324
325
  disableRichText: _?.actions?.disableRichText || g,
325
326
  shortBar: r,
326
327
  hideSubmit: g,
327
328
  allowedDomains: _?.allowed_sources,
328
329
  active: P,
329
- autoFocus: xe,
330
- hideCharCount: Ae,
331
- disableAutoActivate: Ce
330
+ autoFocus: Ne,
331
+ hideCharCount: Ce,
332
+ disableAutoActivate: we
332
333
  }
333
334
  ),
334
335
  E?.content && /* @__PURE__ */ s("div", { className: n.argumentInputWarning, children: E && Object.values(E).map((e, t) => /* @__PURE__ */ s("div", { children: e }, t)) }),
@@ -343,7 +344,7 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
343
344
  ),
344
345
  children: [
345
346
  /* @__PURE__ */ s(
346
- ot,
347
+ rt,
347
348
  {
348
349
  name: "announcement",
349
350
  className: n.warningIcon,
@@ -351,12 +352,12 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
351
352
  width: 20
352
353
  }
353
354
  ),
354
- /* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: qe() })
355
+ /* @__PURE__ */ s("div", { className: n.argumentInputWarningText, children: Ue() })
355
356
  ]
356
357
  }
357
358
  ),
358
- w && G && !be && /* @__PURE__ */ s("div", { className: n.guideMessage, children: /* @__PURE__ */ s(
359
- ge,
359
+ w && H && !Ae && /* @__PURE__ */ s("div", { className: n.guideMessage, children: /* @__PURE__ */ s(
360
+ he,
360
361
  {
361
362
  id: "alert.guide_message",
362
363
  defaultMessage: "Contributions must comply with our {userCharter}.",
@@ -365,11 +366,11 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
365
366
  "a",
366
367
  {
367
368
  className: n.guideMessage,
368
- href: G,
369
+ href: H,
369
370
  target: "_blank",
370
371
  rel: "noreferrer",
371
372
  children: /* @__PURE__ */ s(
372
- ge,
373
+ he,
373
374
  {
374
375
  id: "alert.user_charter",
375
376
  defaultMessage: "user charter"
@@ -392,5 +393,5 @@ const rt = je(() => import("../../modal/side_modal/index.js").then((x) => ({ def
392
393
  ] });
393
394
  };
394
395
  export {
395
- Lt as ArgumentInput
396
+ Ft as ArgumentInput
396
397
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.3.100",
3
+ "version": "0.3.102",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",