@logora/debate 0.3.60 → 0.3.62

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 h } from "react/jsx-runtime";
2
+ import B from "classnames";
3
+ import { useState as f, 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,
27
- 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
25
+ nestingLevel: y = 0,
26
+ maxNestingLevel: C = 2,
27
+ groupType: S,
28
+ groupName: R,
29
+ positions: _ = [],
30
+ disableLinks: F = !1,
31
+ parentArgument: d,
32
+ flashParent: j,
33
+ expandable: G,
34
+ disabled: g = !1,
35
+ hideFooter: T = !1,
36
+ hideReplies: N,
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: c } = ue(), w = c?.moderation_status === "banned", r = he(), [p, b] = f(!1), [X, A] = f(!1), [Z, ee] = f(!1), x = me(e), [m, M] = f(), u = 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
+ ), v = `argument_${e.id}`, I = e.position && _?.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 (v === t) {
63
+ const $ = document.getElementById(t);
64
+ $ && $.scrollIntoView({ behavior: "smooth" }), A(!0);
78
65
  }
79
- }, E = () => {
80
- re((t) => !t);
81
- }, U = () => {
82
- v((t) => !t), h([]);
83
- }, le = (t) => {
84
- if (!d?.find((a) => a.id === t.id))
66
+ }, L = () => {
67
+ ee((t) => !t);
68
+ }, k = () => {
69
+ b((t) => !t), M([]);
70
+ }, se = (t) => {
71
+ if (!m?.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
- t.length > 0 && (h(t), v(!0));
87
+ t.length > 0 && (M(t), b(!0));
101
88
  }
102
- }, B = (t = null) => /* @__PURE__ */ s(
103
- $e,
89
+ }, U = (t = null) => /* @__PURE__ */ o(
90
+ Ne,
104
91
  {
105
92
  ...t ? { argument: t } : {},
106
- nestingLevel: b + 1,
107
- maxNestingLevel: S,
108
- disabled: I,
109
- groupName: N,
110
- groupType: T,
111
- positions: M,
93
+ nestingLevel: y + 1,
94
+ maxNestingLevel: C,
95
+ disabled: g,
96
+ groupName: R,
97
+ groupType: S,
98
+ positions: _,
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: v, onScroll: () => A(!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-${y}`],
115
+ s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && I}`]
129
116
  ),
130
- id: C,
117
+ id: v,
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-${I}`],
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(h, { 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 && d && /* @__PURE__ */ l(
163
150
  "div",
164
151
  {
165
- className: o.replyTo,
166
- onClick: () => z(p.id),
152
+ className: s.replyTo,
153
+ onClick: () => j(d.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
+ d.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
+ }) : d.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(h, { 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
+ x && !u.isTranslated ? /* @__PURE__ */ o(
191
178
  "div",
192
179
  {
193
- className: o.argumentContent,
194
- dangerouslySetInnerHTML: { __html: H($) }
180
+ className: s.argumentContent,
181
+ dangerouslySetInnerHTML: { __html: P(x) }
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(u.translatedContent) }),
184
+ u.isTranslated && /* @__PURE__ */ o(
185
+ be,
199
186
  {
200
187
  language: e.language,
201
- callback: () => y.toggleContent()
188
+ callback: () => u.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
+ !T && !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: g || e.status === "rejected" || !W && r?.actions?.disableInputForVisitor === !0 || w,
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: y <= C || c.role === "editor" || c.role === "moderator",
220
+ handleReplyTo: L,
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,49 @@ 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-${I}`],
246
+ disabled: e.status === "rejected" || c?.id === e?.author?.id || w
260
247
  }
261
248
  )
262
249
  }
263
250
  ),
264
- !w && !A && /* @__PURE__ */ s(
265
- fe,
251
+ !T && !N && /* @__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: p,
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
+ !N && /* @__PURE__ */ l(h, { 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: S,
270
+ groupName: R,
271
+ positions: _,
285
272
  parentId: e.id,
286
- positionId: Y?.position_id,
287
- disabled: I,
273
+ positionId: H?.position_id,
274
+ disabled: g,
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
+ L(), M([t]), b(!0);
292
279
  },
293
280
  isReply: !0,
294
281
  avatarSize: 40,
@@ -301,13 +288,13 @@ const xe = ue(() => import("../../input/argument_input/index.js").then((e) => ({
301
288
  },
302
289
  `Reply${e.id}`
303
290
  ) }),
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,
291
+ m?.length > 0 && p && /* @__PURE__ */ o("div", { className: s.repliesList, children: m.map((t) => U(t)) }),
292
+ p && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
293
+ Ie,
307
294
  {
308
295
  voteableType: "Message",
309
296
  currentListId: `argument_${e.id}_reply_list`,
310
- loadingComponent: /* @__PURE__ */ s(we, {}),
297
+ loadingComponent: /* @__PURE__ */ o(Ce, {}),
311
298
  resource: "messages",
312
299
  sort: "+created_at",
313
300
  filters: {
@@ -318,17 +305,17 @@ const xe = ue(() => import("../../input/argument_input/index.js").then((e) => ({
318
305
  perPage: 5,
319
306
  display: "column",
320
307
  resourcePropName: "argument",
321
- emptyListComponent: /* @__PURE__ */ s(_, {}),
322
- transformData: (t) => le(t),
323
- children: B(e)
308
+ emptyListComponent: /* @__PURE__ */ o(h, {}),
309
+ transformData: (t) => se(t),
310
+ children: U(e)
324
311
  }
325
312
  ) }),
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,
313
+ m?.length > 0 && !p && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
314
+ Se,
328
315
  {
329
316
  role: "link",
330
- rightIcon: /* @__PURE__ */ s(G, { name: "lightArrow", height: 10, width: 10 }),
331
- handleClick: U,
317
+ rightIcon: /* @__PURE__ */ o(E, { name: "lightArrow", height: 10, width: 10 }),
318
+ handleClick: k,
332
319
  children: i.formatMessage({
333
320
  id: "argument.argument.see_more",
334
321
  defaultMessage: "See more"
@@ -337,8 +324,8 @@ const xe = ue(() => import("../../input/argument_input/index.js").then((e) => ({
337
324
  ) }) })
338
325
  ] })
339
326
  ] });
340
- }, $e = Le;
327
+ }, Ne = Te;
341
328
  export {
342
- Le as Argument,
343
- $e as ArgumentContainer
329
+ Te as Argument,
330
+ Ne as ArgumentContainer
344
331
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.3.60",
3
+ "version": "0.3.62",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",