@logora/debate 0.3.60 → 0.3.61

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