@logora/debate 0.3.99 → 0.3.101

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,302 +1,308 @@
1
- import { jsx as o, jsxs as l, Fragment as h } from "react/jsx-runtime";
2
- import B from "classnames";
3
- import { useState as f, useEffect as le, useCallback as ne, Suspense as de, lazy as ce } from "react";
4
- import { useIntl as pe } from "react-intl";
1
+ import { jsx as o, jsxs as l, Fragment as f } from "react/jsx-runtime";
2
+ import F from "classnames";
3
+ import { useState as y, useEffect as P, useCallback as pe, Suspense as ue, lazy as me } from "react";
4
+ import { useIntl as he } from "react-intl";
5
5
  import s from "./Argument.module.scss.js";
6
- import { ReplyFooter as me } from "./ReplyFooter.js";
7
- import { useRichContent as ue } from "./useRichContent.js";
8
- import { useAuth as he } from "../../auth/use_auth/useAuth.js";
9
- import { useConfig as fe } from "../../data/config_provider/useConfig.js";
10
- import { useList as ye } from "../../list/list_provider/useList.js";
11
- import { useTranslatedContent as D } from "../../translation/translated_content/useTranslatedContent.js";
12
- import { SourceListItem as _e } from "../../source/source_list_item/SourceListItem.js";
13
- import { HashScroll as ge } from "../../tools/hash_scroll/HashScroll.js";
14
- import { ContentHeader as be } from "../../user_content/content_header/ContentHeader.js";
15
- import { Icon as E } from "../../icons/icon/Icon.js";
16
- import { ReadMore as Me } from "../../text/read_more/ReadMore.js";
17
- import { TranslationButton as ve } from "../../translation/translation_button/TranslationButton.js";
18
- import { ContentFooter as Ie } from "../../user_content/content_footer/ContentFooter.js";
19
- import { VoteButton as Ce } from "../../vote/vote_button/VoteButton.js";
20
- import { VotePaginatedList as Se } from "../../list/paginated_list/VotePaginatedList.js";
21
- import { UserContentSkeleton as Re } from "../../skeleton/user_content_skeleton/UserContentSkeleton.js";
22
- import { Button as Te } from "../../action/button/Button.js";
23
- const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({ default: e.ArgumentInput }))), F = (e) => e?.replace(/ /g, " "), we = ({
6
+ import { ReplyFooter as fe } from "./ReplyFooter.js";
7
+ import { useRichContent as ye } from "./useRichContent.js";
8
+ import { useAuth as _e } from "../../auth/use_auth/useAuth.js";
9
+ import { useConfig as ge } from "../../data/config_provider/useConfig.js";
10
+ import { useList as be } from "../../list/list_provider/useList.js";
11
+ import { useTranslatedContent as j } from "../../translation/translated_content/useTranslatedContent.js";
12
+ import { SourceListItem as Me } from "../../source/source_list_item/SourceListItem.js";
13
+ import { HashScroll as Ie } from "../../tools/hash_scroll/HashScroll.js";
14
+ import { ContentHeader as Ce } from "../../user_content/content_header/ContentHeader.js";
15
+ import { Icon as G } from "../../icons/icon/Icon.js";
16
+ import { ReadMore as ve } from "../../text/read_more/ReadMore.js";
17
+ import { TranslationButton as Se } from "../../translation/translation_button/TranslationButton.js";
18
+ import { ContentFooter as Re } from "../../user_content/content_footer/ContentFooter.js";
19
+ import { VoteButton as Te } from "../../vote/vote_button/VoteButton.js";
20
+ import { VotePaginatedList as Ne } from "../../list/paginated_list/VotePaginatedList.js";
21
+ import { UserContentSkeleton as we } from "../../skeleton/user_content_skeleton/UserContentSkeleton.js";
22
+ import { Button as Ae } from "../../action/button/Button.js";
23
+ const xe = me(() => import("../../input/argument_input/index.js").then((e) => ({ default: e.ArgumentInput }))), H = (e) => e?.replace(/ /g, " "), Le = ({
24
24
  argument: e,
25
25
  argumentReplies: n,
26
- nestingLevel: y = 0,
27
- maxNestingLevel: I = 2,
28
- groupType: C,
29
- groupName: S,
30
- positions: _ = [],
31
- disableLinks: P = !1,
32
- parentArgument: d,
33
- flashParent: j,
34
- expandable: G,
35
- disabled: g = !1,
36
- hideFooter: R = !1,
37
- hideReplies: T,
38
- vote: H,
39
- fixedContentHeight: V = !1,
40
- enableEdition: z = !0,
41
- enableDeletion: O = !0,
42
- deleteListId: Y,
43
- showModerationFeedback: q,
44
- lineCount: J = 5,
45
- replyRedirectUrl: K,
46
- hideContent: Q = !1
26
+ nestingLevel: _ = 0,
27
+ maxNestingLevel: T = 2,
28
+ groupType: N,
29
+ groupName: w,
30
+ positions: g = [],
31
+ disableLinks: V = !1,
32
+ parentArgument: c,
33
+ flashParent: z,
34
+ expandable: O,
35
+ disabled: b = !1,
36
+ hideFooter: A = !1,
37
+ hideReplies: x,
38
+ vote: Y,
39
+ fixedContentHeight: q = !1,
40
+ enableEdition: J = !0,
41
+ enableDeletion: K = !0,
42
+ deleteListId: Q,
43
+ showModerationFeedback: W,
44
+ lineCount: X = 5,
45
+ replyRedirectUrl: Z,
46
+ hideContent: ee = !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 = he(), { isLoggedIn: te, currentUser: p } = _e(), L = p?.moderation_status === "banned", i = ge(), M = be(), [u, I] = y(!1), [oe, $] = y(!1), [se, re] = y(!1), k = ye(e), [m, C] = y(), h = j(
49
49
  e.content,
50
50
  e.language,
51
51
  "content",
52
52
  e.translation_entries
53
- ), oe = D(
53
+ ), ie = j(
54
54
  e.position?.name,
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;
59
- le(() => {
60
- n !== void 0 && ae();
61
- }, [n]);
62
- const se = (t) => {
63
- if (M === t) {
64
- const $ = document.getElementById(t);
65
- $ && $.scrollIntoView({ behavior: "smooth" }), w(!0);
58
+ ), v = `argument_${e.id}`, S = e.position && g?.map((t) => t.id).indexOf(e.position.id) + 1;
59
+ P(() => {
60
+ n !== void 0 && de();
61
+ }, [n]), P(() => {
62
+ const t = `argument_${e.id}_reply_list`, r = M.updateElements?.[t];
63
+ r?.length && C((d) => d?.length ? d.map((R) => {
64
+ const D = r.find((ce) => ce.id === R.id);
65
+ return D ? { ...R, ...D } : R;
66
+ }) : d);
67
+ }, [M.updateElements, e.id]);
68
+ const ae = (t) => {
69
+ if (v === t) {
70
+ const d = document.getElementById(t);
71
+ d && d.scrollIntoView({ behavior: "smooth" }), $(!0);
66
72
  }
67
- }, L = () => {
68
- te((t) => !t);
69
- }, k = () => {
70
- b((t) => !t), x([]);
71
- }, re = (t) => {
72
- if (!m?.find((a) => a.id === t.id))
73
+ }, U = () => {
74
+ re((t) => !t);
75
+ }, B = () => {
76
+ I((t) => !t), C([]);
77
+ }, le = (t) => {
78
+ if (!m?.find((r) => r.id === t.id))
73
79
  return t;
74
- }, ie = ne((t, a) => /* @__PURE__ */ o(
75
- _e,
80
+ }, ne = pe((t, r) => /* @__PURE__ */ o(
81
+ Me,
76
82
  {
77
83
  publisher: t.publisher,
78
84
  url: t.source_url,
79
85
  title: t.title,
80
- index: a
86
+ index: r
81
87
  },
82
- a
83
- ), []), ae = () => {
88
+ r
89
+ ), []), de = () => {
84
90
  if (n && Array.isArray(n)) {
85
91
  const t = n.filter(
86
- (a) => a.reply_to_id === e.id
92
+ (r) => r.reply_to_id === e.id
87
93
  );
88
- t.length > 0 && (x(t), b(!0));
94
+ t.length > 0 && (C(t), I(!0));
89
95
  }
90
- }, U = (t = null) => /* @__PURE__ */ o(
91
- Ae,
96
+ }, E = (t = null) => /* @__PURE__ */ o(
97
+ $e,
92
98
  {
93
99
  ...t ? { argument: t } : {},
94
- nestingLevel: y + 1,
95
- maxNestingLevel: I,
96
- disabled: g,
97
- groupName: S,
98
- groupType: C,
99
- positions: _,
100
+ nestingLevel: _ + 1,
101
+ maxNestingLevel: T,
102
+ disabled: b,
103
+ groupName: w,
104
+ groupType: N,
105
+ positions: g,
100
106
  argumentReplies: n,
101
107
  parentArgument: e,
102
- flashParent: (a) => se(`argument_${a}`)
108
+ flashParent: (r) => ae(`argument_${r}`)
103
109
  }
104
110
  );
105
- return /* @__PURE__ */ l(ge, { elementId: M, onScroll: () => w(!0), children: [
111
+ return /* @__PURE__ */ l(Ie, { elementId: v, onScroll: () => $(!0), children: [
106
112
  /* @__PURE__ */ l(
107
113
  "div",
108
114
  {
109
- className: B(
115
+ className: F(
110
116
  s.argument,
111
117
  {
112
- [s.flash]: Z,
118
+ [s.flash]: oe,
113
119
  [s.argumentReply]: e.is_reply === !0
114
120
  },
115
- s[`level-${y}`],
116
- s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && v}`]
121
+ s[`level-${_}`],
122
+ s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && S}`]
117
123
  ),
118
- id: M,
124
+ id: v,
119
125
  children: [
120
126
  /* @__PURE__ */ o(
121
- be,
127
+ Ce,
122
128
  {
123
129
  selectedContent: e.is_selected,
124
130
  author: e.author,
125
- tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : oe.translatedContent,
131
+ tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : ie.translatedContent,
126
132
  date: e.created_at,
127
- tagClassName: s[`headerPosition-${v}`],
128
- disableLinks: P,
133
+ tagClassName: s[`headerPosition-${S}`],
134
+ disableLinks: V,
129
135
  isDeleted: e.is_deleted,
130
- showModerationFeedback: q ?? (e.status === "rejected" && r.moderation?.showFeedback === !0),
136
+ showModerationFeedback: W ?? (e.status === "rejected" && i.moderation?.showFeedback === !0),
131
137
  moderationReason: e.moderation_entry?.moderation_reason,
132
138
  moderationNotes: e.moderation_entry?.moderator_notes,
133
- moderationPolicyUrl: r.provider?.userGuideUrl
139
+ moderationPolicyUrl: i.provider?.userGuideUrl
134
140
  }
135
141
  ),
136
- e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
142
+ e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: a.formatMessage({
137
143
  id: "info.deleted_by_user",
138
144
  defaultMessage: "Content deleted by the user"
139
- }) }) : Q ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
145
+ }) }) : ee ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: a.formatMessage({
140
146
  id: "argument.argument.content_deleted",
141
147
  defaultMessage: "This content has been removed."
142
- }) }) : /* @__PURE__ */ l(h, { children: [
148
+ }) }) : /* @__PURE__ */ l(f, { children: [
143
149
  /* @__PURE__ */ l(
144
150
  "div",
145
151
  {
146
- className: B(s.argumentBody, {
147
- [s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? V : !1
152
+ className: F(s.argumentBody, {
153
+ [s.fixedHeight]: i?.layout?.showAllArgumentInEmbed !== !0 ? q : !1
148
154
  }),
149
155
  children: [
150
- e.is_reply && d && /* @__PURE__ */ l(
156
+ e.is_reply && c && /* @__PURE__ */ l(
151
157
  "div",
152
158
  {
153
159
  className: s.replyTo,
154
- onClick: () => j(d.id),
160
+ onClick: () => z(c.id),
155
161
  children: [
156
- i.formatMessage({
162
+ a.formatMessage({
157
163
  id: "info.replying_to",
158
164
  defaultMessage: "Replying to"
159
165
  }),
160
166
  /* @__PURE__ */ l("span", { className: s.replyingTo, children: [
161
- d.is_deleted ? i.formatMessage({
167
+ c.is_deleted ? a.formatMessage({
162
168
  id: "info.deleted",
163
169
  defaultMessage: "Deleted"
164
- }) : d.author.full_name,
165
- /* @__PURE__ */ o(E, { name: "chat", height: 16 })
170
+ }) : c.author.full_name,
171
+ /* @__PURE__ */ o(G, { name: "chat", height: 16 })
166
172
  ] })
167
173
  ]
168
174
  }
169
175
  ),
170
176
  /* @__PURE__ */ o(
171
- Me,
177
+ ve,
172
178
  {
173
- content: /* @__PURE__ */ l(h, { children: [
174
- e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: i.formatMessage({
179
+ content: /* @__PURE__ */ l(f, { children: [
180
+ e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: a.formatMessage({
175
181
  id: "argument.argument.updated",
176
182
  defaultMessage: "Updated argument"
177
183
  }) }),
178
- A && !u.isTranslated ? /* @__PURE__ */ o(
184
+ k && !h.isTranslated ? /* @__PURE__ */ o(
179
185
  "div",
180
186
  {
181
187
  className: s.argumentContent,
182
- dangerouslySetInnerHTML: { __html: F(A) }
188
+ dangerouslySetInnerHTML: { __html: H(k) }
183
189
  }
184
- ) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: F(u.translatedContent) }),
185
- u.isTranslated && /* @__PURE__ */ o(
186
- ve,
190
+ ) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: H(h.translatedContent) }),
191
+ h.isTranslated && /* @__PURE__ */ o(
192
+ Se,
187
193
  {
188
194
  language: e.language,
189
- callback: () => u.toggleContent()
195
+ callback: () => h.toggleContent()
190
196
  }
191
197
  )
192
198
  ] }),
193
- lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ? J : void 0,
194
- readMoreText: i.formatMessage({
199
+ lineCount: i?.layout?.showAllArgumentInEmbed !== !0 ? X : void 0,
200
+ readMoreText: a.formatMessage({
195
201
  id: "action.read_more",
196
202
  defaultMessage: "Read more"
197
203
  }),
198
- readLessText: i.formatMessage({
204
+ readLessText: a.formatMessage({
199
205
  id: "action.read_less",
200
206
  defaultMessage: "Read less"
201
207
  }),
202
- expandable: r?.layout?.showAllArgumentInEmbed !== !0 ? G : !1,
208
+ expandable: i?.layout?.showAllArgumentInEmbed !== !0 ? O : !1,
203
209
  readMoreClassName: e.is_reply ? s.replyStyle : s.argumentStyle
204
210
  }
205
211
  )
206
212
  ]
207
213
  }
208
214
  ),
209
- e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(ie) })
215
+ e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(ne) })
210
216
  ] }),
211
- !R && !e.is_deleted && /* @__PURE__ */ o(
212
- Ie,
217
+ !A && !e.is_deleted && /* @__PURE__ */ o(
218
+ Re,
213
219
  {
214
220
  resource: e,
215
- disabled: g || e.status === "rejected" || !W && r?.actions?.disableInputForVisitor === !0 || N,
221
+ disabled: b || e.status === "rejected" || !te && i?.actions?.disableInputForVisitor === !0 || L,
216
222
  reportType: "Message",
217
- softDelete: r.actions?.softDelete,
223
+ softDelete: i.actions?.softDelete,
218
224
  deleteType: "messages",
219
- deleteListId: Y,
220
- enableReply: y <= I || c.role === "editor" || c.role === "moderator",
221
- handleReplyTo: L,
222
- replyRedirectUrl: K,
225
+ deleteListId: Q,
226
+ enableReply: _ <= T || p.role === "editor" || p.role === "moderator",
227
+ handleReplyTo: U,
228
+ replyRedirectUrl: Z,
223
229
  shareUrl: `https://app.logora.fr/share/a/${e.id}`,
224
- shareTitle: i.formatMessage({
230
+ shareTitle: a.formatMessage({
225
231
  id: "share.argument.title",
226
232
  defaultMessage: "Share a debate"
227
233
  }),
228
- shareText: i.formatMessage({
234
+ shareText: a.formatMessage({
229
235
  id: "share.argument.text",
230
236
  defaultMessage: "This argument may interest you"
231
237
  }),
232
- shareCode: `<iframe src="https://cdn.logora.com/embed.html?shortname=${r.shortname}&id=${e.id}&resource=argument" frameborder="0" width="100%" height="275px" scrolling="no"></iframe>`,
233
- showShareCode: r?.actions?.hideCodeShare !== !0,
238
+ shareCode: `<iframe src="https://cdn.logora.com/embed.html?shortname=${i.shortname}&id=${e.id}&resource=argument" frameborder="0" width="100%" height="275px" scrolling="no"></iframe>`,
239
+ showShareCode: i?.actions?.hideCodeShare !== !0,
234
240
  showShareText: !0,
235
- showShareButton: r?.actions?.hideShareButton !== !0,
241
+ showShareButton: i?.actions?.hideShareButton !== !0,
236
242
  enableReport: !(e.score === 100 && e.manual_score),
237
- enableEdition: z,
238
- enableDeletion: O,
243
+ enableEdition: J,
244
+ enableDeletion: K,
239
245
  children: /* @__PURE__ */ o(
240
- Ce,
246
+ Te,
241
247
  {
242
248
  voteableType: "Message",
243
249
  voteableId: e.id,
244
250
  totalUpvote: e.upvotes,
245
251
  totalDownvote: 0,
246
- activeClassName: s[`voteButtonPosition-${v}`],
247
- disabled: e.status === "rejected" || c?.id === e?.author?.id || N
252
+ activeClassName: s[`voteButtonPosition-${S}`],
253
+ disabled: e.status === "rejected" || p?.id === e?.author?.id || L
248
254
  }
249
255
  )
250
256
  }
251
257
  ),
252
- !R && !T && /* @__PURE__ */ o(
253
- me,
258
+ !A && !x && /* @__PURE__ */ o(
259
+ fe,
254
260
  {
255
261
  numberReplies: e.number_replies,
256
262
  repliesAuthors: e.replies_authors,
257
- expandReplies: p,
258
- onToggleReplies: k,
263
+ expandReplies: u,
264
+ onToggleReplies: B,
259
265
  isReply: e.is_reply
260
266
  }
261
267
  )
262
268
  ]
263
269
  }
264
270
  ),
265
- !T && /* @__PURE__ */ l(h, { children: [
266
- ee && /* @__PURE__ */ o(de, { fallback: null, children: /* @__PURE__ */ o(
267
- Ne,
271
+ !x && /* @__PURE__ */ l(f, { children: [
272
+ se && /* @__PURE__ */ o(ue, { fallback: null, children: /* @__PURE__ */ o(
273
+ xe,
268
274
  {
269
275
  groupId: e.group_id,
270
- groupType: C,
271
- groupName: S,
272
- positions: _,
276
+ groupType: N,
277
+ groupName: w,
278
+ positions: g,
273
279
  parentId: e.id,
274
- positionId: H?.position_id,
275
- disabled: g,
276
- hideSourceAction: r?.actions?.disableUserSources || !1,
280
+ positionId: Y?.position_id,
281
+ disabled: b,
282
+ hideSourceAction: i?.actions?.disableUserSources || !1,
277
283
  onSubmit: (t) => {
278
- const a = `argument_${e.id}_reply_list`;
279
- X.add(a, [t]), L(), b(!0);
284
+ const r = `argument_${e.id}_reply_list`;
285
+ M.add(r, [t]), U(), I(!0);
280
286
  },
281
287
  isReply: !0,
282
288
  autoFocus: !0,
283
289
  avatarSize: 40,
284
- placeholder: i.formatMessage({
290
+ placeholder: a.formatMessage({
285
291
  id: "input.reply_input.your_answer",
286
292
  defaultMessage: "Your answer"
287
293
  }),
288
- userGuideUrl: r?.provider?.userGuideUrl,
289
- hideUserGuideLink: r?.provider?.hideUserGuideLink
294
+ userGuideUrl: i?.provider?.userGuideUrl,
295
+ hideUserGuideLink: i?.provider?.hideUserGuideLink
290
296
  },
291
297
  `Reply${e.id}`
292
298
  ) }),
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(
295
- Se,
299
+ m?.length > 0 && u && /* @__PURE__ */ o("div", { className: s.repliesList, children: m.map((t) => E(t)) }),
300
+ u && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
301
+ Ne,
296
302
  {
297
303
  voteableType: "Message",
298
304
  currentListId: `argument_${e.id}_reply_list`,
299
- loadingComponent: /* @__PURE__ */ o(Re, {}),
305
+ loadingComponent: /* @__PURE__ */ o(we, {}),
300
306
  resource: "messages",
301
307
  sort: "+created_at",
302
308
  filters: {
@@ -307,18 +313,18 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
307
313
  perPage: 5,
308
314
  display: "column",
309
315
  resourcePropName: "argument",
310
- emptyListComponent: /* @__PURE__ */ o(h, {}),
311
- transformData: (t) => re(t),
312
- children: U(e)
316
+ emptyListComponent: /* @__PURE__ */ o(f, {}),
317
+ transformData: (t) => le(t),
318
+ children: E(e)
313
319
  }
314
320
  ) }),
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(
316
- Te,
321
+ m?.length > 0 && !u && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
322
+ Ae,
317
323
  {
318
324
  role: "link",
319
- rightIcon: /* @__PURE__ */ o(E, { name: "lightArrow", height: 10, width: 10 }),
320
- handleClick: k,
321
- children: i.formatMessage({
325
+ rightIcon: /* @__PURE__ */ o(G, { name: "lightArrow", height: 10, width: 10 }),
326
+ handleClick: B,
327
+ children: a.formatMessage({
322
328
  id: "argument.argument.see_more",
323
329
  defaultMessage: "See more"
324
330
  })
@@ -326,8 +332,8 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
326
332
  ) }) })
327
333
  ] })
328
334
  ] });
329
- }, Ae = we;
335
+ }, $e = Le;
330
336
  export {
331
- we as Argument,
332
- Ae as ArgumentContainer
337
+ Le as Argument,
338
+ $e as ArgumentContainer
333
339
  };
@@ -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.99",
3
+ "version": "0.3.101",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",