@logora/debate 0.4.15 → 0.4.17

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,309 +1,321 @@
1
- import { jsx as o, jsxs as l, Fragment as f } from "react/jsx-runtime";
2
- import B from "classnames";
3
- import { useState as y, useEffect as le, useCallback as ne, Suspense as de, lazy as ce } from "react";
4
- import { useIntl as pe } from "react-intl";
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 = ({
1
+ import { jsx as s, jsxs as n, Fragment as y } from "react/jsx-runtime";
2
+ import P from "classnames";
3
+ import { useState as _, useEffect as j, useCallback as me, Suspense as he, lazy as fe } from "react";
4
+ import { useIntl as ye } from "react-intl";
5
+ import o from "./Argument.module.scss.js";
6
+ import { ReplyFooter as _e } from "./ReplyFooter.js";
7
+ import { useRichContent as ge } from "./useRichContent.js";
8
+ import { useAuth as be } from "../../auth/use_auth/useAuth.js";
9
+ import { useConfig as Me } from "../../data/config_provider/useConfig.js";
10
+ import { useList as Ie } from "../../list/list_provider/useList.js";
11
+ import { useTranslatedContent as G } from "../../translation/translated_content/useTranslatedContent.js";
12
+ import { SourceListItem as Ce } from "../../source/source_list_item/SourceListItem.js";
13
+ import { HashScroll as ve } from "../../tools/hash_scroll/HashScroll.js";
14
+ import { ContentHeader as Se } from "../../user_content/content_header/ContentHeader.js";
15
+ import { Icon as H } from "../../icons/icon/Icon.js";
16
+ import { ReadMore as Re } from "../../text/read_more/ReadMore.js";
17
+ import { TranslationButton as Te } from "../../translation/translation_button/TranslationButton.js";
18
+ import { ContentFooter as Ne } from "../../user_content/content_footer/ContentFooter.js";
19
+ import { VoteButton as we } from "../../vote/vote_button/VoteButton.js";
20
+ import { VotePaginatedList as xe } from "../../list/paginated_list/VotePaginatedList.js";
21
+ import { UserContentSkeleton as Ae } from "../../skeleton/user_content_skeleton/UserContentSkeleton.js";
22
+ import { Button as Le } from "../../action/button/Button.js";
23
+ const Ue = fe(() => import("../../input/argument_input/index.js").then((e) => ({ default: e.ArgumentInput }))), V = (e) => e?.replace(/ /g, " "), $e = ({
24
24
  argument: e,
25
- argumentReplies: n,
26
- nestingLevel: _ = 0,
27
- maxNestingLevel: S = 2,
28
- groupType: R,
29
- groupName: T,
30
- positions: g = [],
31
- disableLinks: P = !1,
25
+ argumentReplies: d,
26
+ nestingLevel: g = 0,
27
+ maxNestingLevel: T = 2,
28
+ groupType: N,
29
+ groupName: w,
30
+ positions: b = [],
31
+ disableLinks: z = !1,
32
32
  parentArgument: c,
33
- flashParent: j,
34
- expandable: G,
35
- disabled: b = !1,
36
- hideFooter: N = !1,
37
- hideReplies: w,
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
33
+ flashParent: O,
34
+ expandable: Y,
35
+ disabled: M = !1,
36
+ hideFooter: x = !1,
37
+ hideReplies: A,
38
+ vote: q,
39
+ fixedContentHeight: J = !1,
40
+ enableEdition: K = !0,
41
+ enableDeletion: Q = !0,
42
+ deleteListId: W,
43
+ showModerationFeedback: X,
44
+ lineCount: Z = 5,
45
+ replyRedirectUrl: ee,
46
+ hideContent: te = !1
47
47
  }) => {
48
- const a = pe(), { isLoggedIn: W, currentUser: p } = he(), A = p?.moderation_status === "banned", r = fe(), X = ye(), [m, M] = y(!1), [Z, x] = y(!1), [ee, te] = y(!1), L = ue(e), [u, v] = y(), h = D(
48
+ const l = ye(), { isLoggedIn: se, currentUser: p } = be(), L = p?.moderation_status === "banned", i = Me(), I = Ie(), [u, C] = _(!1), [oe, U] = _(!1), [re, ie] = _(!1), $ = ge(e), [m, h] = _(), f = G(
49
49
  e.content,
50
50
  e.language,
51
51
  "content",
52
52
  e.translation_entries
53
- ), oe = D(
53
+ ), ae = G(
54
54
  e.position?.name,
55
55
  e.position?.language,
56
56
  "name",
57
57
  e.position?.translation_entries
58
- ), I = `argument_${e.id}`, C = e.position && g?.map((t) => t.id).indexOf(e.position.id) + 1;
59
- le(() => {
60
- n !== void 0 && ae();
61
- }, [n]);
62
- const se = (t) => {
63
- if (I === t) {
64
- const d = document.getElementById(t);
65
- d && d.scrollIntoView({ behavior: "smooth" }), x(!0);
58
+ ), v = `argument_${e.id}`, S = e.position && b?.map((t) => t.id).indexOf(e.position.id) + 1;
59
+ j(() => {
60
+ d !== void 0 && ce();
61
+ }, [d]), j(() => {
62
+ const t = `argument_${e.id}_reply_list`, r = I.updateElements?.[t];
63
+ r?.length > 0 && h((a) => {
64
+ if (!a || a.length === 0)
65
+ return a;
66
+ let D = !1;
67
+ const pe = a.map((R) => {
68
+ const F = r.find((ue) => ue.id === R.id);
69
+ return F ? (D = !0, { ...R, ...F }) : R;
70
+ });
71
+ return D ? pe : a;
72
+ });
73
+ }, [I.updateElements, e.id]);
74
+ const le = (t) => {
75
+ if (v === t) {
76
+ const a = document.getElementById(t);
77
+ a && a.scrollIntoView({ behavior: "smooth" }), U(!0);
66
78
  }
67
- }, U = () => {
68
- te((t) => !t);
69
79
  }, k = () => {
70
- M((t) => !t), v([]);
71
- }, re = (t) => {
72
- if (!u?.find((i) => i.id === t.id))
80
+ ie((t) => !t);
81
+ }, B = () => {
82
+ C((t) => !t), h([]);
83
+ }, ne = (t) => {
84
+ if (!m?.find((r) => r.id === t.id))
73
85
  return t;
74
- }, ie = ne((t, i) => /* @__PURE__ */ o(
75
- _e,
86
+ }, de = me((t, r) => /* @__PURE__ */ s(
87
+ Ce,
76
88
  {
77
89
  publisher: t.publisher,
78
90
  url: t.source_url,
79
91
  title: t.title,
80
- index: i
92
+ index: r
81
93
  },
82
- i
83
- ), []), ae = () => {
84
- if (n && Array.isArray(n)) {
85
- const t = n.filter(
86
- (i) => i.reply_to_id === e.id
94
+ r
95
+ ), []), ce = () => {
96
+ if (d && Array.isArray(d)) {
97
+ const t = d.filter(
98
+ (r) => r.reply_to_id === e.id
87
99
  );
88
- t.length > 0 && (v(t), M(!0));
100
+ t.length > 0 && (h(t), C(!0));
89
101
  }
90
- }, $ = (t = null) => /* @__PURE__ */ o(
91
- Ae,
102
+ }, E = (t = null) => /* @__PURE__ */ s(
103
+ ke,
92
104
  {
93
105
  ...t ? { argument: t } : {},
94
- nestingLevel: _ + 1,
95
- maxNestingLevel: S,
96
- disabled: b,
97
- groupName: T,
98
- groupType: R,
99
- positions: g,
100
- argumentReplies: n,
106
+ nestingLevel: g + 1,
107
+ maxNestingLevel: T,
108
+ disabled: M,
109
+ groupName: w,
110
+ groupType: N,
111
+ positions: b,
112
+ argumentReplies: d,
101
113
  parentArgument: e,
102
- flashParent: (i) => se(`argument_${i}`)
114
+ flashParent: (r) => le(`argument_${r}`)
103
115
  }
104
116
  );
105
- return /* @__PURE__ */ l(ge, { elementId: I, onScroll: () => x(!0), children: [
106
- /* @__PURE__ */ l(
117
+ return /* @__PURE__ */ n(ve, { elementId: v, onScroll: () => U(!0), children: [
118
+ /* @__PURE__ */ n(
107
119
  "div",
108
120
  {
109
- className: B(
110
- s.argument,
121
+ className: P(
122
+ o.argument,
111
123
  {
112
- [s.flash]: Z,
113
- [s.argumentReply]: e.is_reply === !0
124
+ [o.flash]: oe,
125
+ [o.argumentReply]: e.is_reply === !0
114
126
  },
115
- s[`level-${_}`],
116
- s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && C}`]
127
+ o[`level-${g}`],
128
+ o[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && S}`]
117
129
  ),
118
- id: I,
130
+ id: v,
119
131
  children: [
120
- /* @__PURE__ */ o(
121
- be,
132
+ /* @__PURE__ */ s(
133
+ Se,
122
134
  {
123
135
  selectedContent: e.is_selected,
124
136
  author: e.author,
125
- tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : oe.translatedContent,
137
+ tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : ae.translatedContent,
126
138
  date: e.created_at,
127
- tagClassName: s[`headerPosition-${C}`],
128
- disableLinks: P,
139
+ tagClassName: o[`headerPosition-${S}`],
140
+ disableLinks: z,
129
141
  isDeleted: e.is_deleted,
130
- showModerationFeedback: q ?? (e.status === "rejected" && r.moderation?.showFeedback === !0),
142
+ showModerationFeedback: X ?? (e.status === "rejected" && i.moderation?.showFeedback === !0),
131
143
  moderationReason: e.moderation_entry?.moderation_reason,
132
144
  moderationNotes: e.moderation_entry?.moderator_notes,
133
- moderationPolicyUrl: r.provider?.userGuideUrl
145
+ moderationPolicyUrl: i.provider?.userGuideUrl
134
146
  }
135
147
  ),
136
- e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: a.formatMessage({
148
+ e.is_deleted ? /* @__PURE__ */ s("div", { className: o.argumentDeletedBody, children: l.formatMessage({
137
149
  id: "info.deleted_by_user",
138
150
  defaultMessage: "Content deleted by the user"
139
- }) }) : Q ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: a.formatMessage({
151
+ }) }) : te ? /* @__PURE__ */ s("div", { className: o.argumentDeletedBody, children: l.formatMessage({
140
152
  id: "argument.argument.content_deleted",
141
153
  defaultMessage: "This content has been removed."
142
- }) }) : /* @__PURE__ */ l(f, { children: [
143
- /* @__PURE__ */ l(
154
+ }) }) : /* @__PURE__ */ n(y, { children: [
155
+ /* @__PURE__ */ n(
144
156
  "div",
145
157
  {
146
- className: B(s.argumentBody, {
147
- [s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? V : !1
158
+ className: P(o.argumentBody, {
159
+ [o.fixedHeight]: i?.layout?.showAllArgumentInEmbed !== !0 ? J : !1
148
160
  }),
149
161
  children: [
150
- e.is_reply && c && /* @__PURE__ */ l(
162
+ e.is_reply && c && /* @__PURE__ */ n(
151
163
  "div",
152
164
  {
153
- className: s.replyTo,
154
- onClick: () => j(c.id),
165
+ className: o.replyTo,
166
+ onClick: () => O(c.id),
155
167
  children: [
156
- a.formatMessage({
168
+ l.formatMessage({
157
169
  id: "info.replying_to",
158
170
  defaultMessage: "Replying to"
159
171
  }),
160
- /* @__PURE__ */ l("span", { className: s.replyingTo, children: [
161
- c.is_deleted ? a.formatMessage({
172
+ /* @__PURE__ */ n("span", { className: o.replyingTo, children: [
173
+ c.is_deleted ? l.formatMessage({
162
174
  id: "info.deleted",
163
175
  defaultMessage: "Deleted"
164
176
  }) : c.author.full_name,
165
- /* @__PURE__ */ o(E, { name: "chat", height: 16 })
177
+ /* @__PURE__ */ s(H, { name: "chat", height: 16 })
166
178
  ] })
167
179
  ]
168
180
  }
169
181
  ),
170
- /* @__PURE__ */ o(
171
- Me,
182
+ /* @__PURE__ */ s(
183
+ Re,
172
184
  {
173
- content: /* @__PURE__ */ l(f, { children: [
174
- e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: a.formatMessage({
185
+ content: /* @__PURE__ */ n(y, { children: [
186
+ e.is_edited && /* @__PURE__ */ s("div", { className: o.edited, children: l.formatMessage({
175
187
  id: "argument.argument.updated",
176
188
  defaultMessage: "Updated argument"
177
189
  }) }),
178
- L && !h.isTranslated ? /* @__PURE__ */ o(
190
+ $ && !f.isTranslated ? /* @__PURE__ */ s(
179
191
  "div",
180
192
  {
181
- className: s.argumentContent,
182
- dangerouslySetInnerHTML: { __html: F(L) }
193
+ className: o.argumentContent,
194
+ dangerouslySetInnerHTML: { __html: V($) }
183
195
  }
184
- ) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: F(h.translatedContent) }),
185
- h.isTranslated && /* @__PURE__ */ o(
186
- ve,
196
+ ) : /* @__PURE__ */ s("div", { className: o.argumentContent, children: V(f.translatedContent) }),
197
+ f.isTranslated && /* @__PURE__ */ s(
198
+ Te,
187
199
  {
188
200
  language: e.language,
189
- callback: () => h.toggleContent()
201
+ callback: () => f.toggleContent()
190
202
  }
191
203
  )
192
204
  ] }),
193
- lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ? J : void 0,
194
- readMoreText: a.formatMessage({
205
+ lineCount: i?.layout?.showAllArgumentInEmbed !== !0 ? Z : void 0,
206
+ readMoreText: l.formatMessage({
195
207
  id: "action.read_more",
196
208
  defaultMessage: "Read more"
197
209
  }),
198
- readLessText: a.formatMessage({
210
+ readLessText: l.formatMessage({
199
211
  id: "action.read_less",
200
212
  defaultMessage: "Read less"
201
213
  }),
202
- expandable: r?.layout?.showAllArgumentInEmbed !== !0 ? G : !1,
203
- readMoreClassName: e.is_reply ? s.replyStyle : s.argumentStyle
214
+ expandable: i?.layout?.showAllArgumentInEmbed !== !0 ? Y : !1,
215
+ readMoreClassName: e.is_reply ? o.replyStyle : o.argumentStyle
204
216
  }
205
217
  )
206
218
  ]
207
219
  }
208
220
  ),
209
- e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(ie) })
221
+ e.sources?.length > 0 && /* @__PURE__ */ s("div", { className: o.argumentSourcesList, children: e.sources.map(de) })
210
222
  ] }),
211
- !N && !e.is_deleted && /* @__PURE__ */ o(
212
- Ie,
223
+ !x && !e.is_deleted && /* @__PURE__ */ s(
224
+ Ne,
213
225
  {
214
226
  resource: e,
215
- disabled: b || e.status === "rejected" || !W && r?.actions?.disableInputForVisitor === !0 || A,
227
+ disabled: M || e.status === "rejected" || !se && i?.actions?.disableInputForVisitor === !0 || L,
216
228
  reportType: "Message",
217
- softDelete: r.actions?.softDelete,
229
+ softDelete: i.actions?.softDelete,
218
230
  deleteType: "messages",
219
- deleteListId: Y,
220
- enableReply: _ <= S || p.role === "editor" || p.role === "moderator",
221
- handleReplyTo: U,
222
- replyRedirectUrl: K,
231
+ deleteListId: W,
232
+ enableReply: g <= T || p.role === "editor" || p.role === "moderator",
233
+ handleReplyTo: k,
234
+ replyRedirectUrl: ee,
223
235
  shareUrl: `https://app.logora.fr/share/a/${e.id}`,
224
- shareTitle: a.formatMessage({
236
+ shareTitle: l.formatMessage({
225
237
  id: "share.argument.title",
226
238
  defaultMessage: "Share a debate"
227
239
  }),
228
- shareText: a.formatMessage({
240
+ shareText: l.formatMessage({
229
241
  id: "share.argument.text",
230
242
  defaultMessage: "This argument may interest you"
231
243
  }),
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,
244
+ 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>`,
245
+ showShareCode: i?.actions?.hideCodeShare !== !0,
234
246
  showShareText: !0,
235
- showShareButton: r?.actions?.hideShareButton !== !0,
247
+ showShareButton: i?.actions?.hideShareButton !== !0,
236
248
  enableReport: !(e.score === 100 && e.manual_score),
237
- enableEdition: z,
238
- enableDeletion: O,
239
- children: /* @__PURE__ */ o(
240
- Ce,
249
+ enableEdition: K,
250
+ enableDeletion: Q,
251
+ children: /* @__PURE__ */ s(
252
+ we,
241
253
  {
242
254
  voteableType: "Message",
243
255
  voteableId: e.id,
244
256
  totalUpvote: e.upvotes,
245
257
  totalDownvote: 0,
246
- activeClassName: s[`voteButtonPosition-${C}`],
247
- disabled: e.status === "rejected" || p?.id === e?.author?.id || A
258
+ activeClassName: o[`voteButtonPosition-${S}`],
259
+ disabled: e.status === "rejected" || p?.id === e?.author?.id || L
248
260
  }
249
261
  )
250
262
  }
251
263
  ),
252
- !N && !w && /* @__PURE__ */ o(
253
- me,
264
+ !x && !A && /* @__PURE__ */ s(
265
+ _e,
254
266
  {
255
267
  numberReplies: e.number_replies,
256
268
  repliesAuthors: e.replies_authors,
257
- expandReplies: m,
258
- onToggleReplies: k,
269
+ expandReplies: u,
270
+ onToggleReplies: B,
259
271
  isReply: e.is_reply
260
272
  }
261
273
  )
262
274
  ]
263
275
  }
264
276
  ),
265
- !w && /* @__PURE__ */ l(f, { children: [
266
- ee && /* @__PURE__ */ o(de, { fallback: null, children: /* @__PURE__ */ o(
267
- Ne,
277
+ !A && /* @__PURE__ */ n(y, { children: [
278
+ re && /* @__PURE__ */ s(he, { fallback: null, children: /* @__PURE__ */ s(
279
+ Ue,
268
280
  {
269
281
  groupId: e.group_id,
270
- groupType: R,
271
- groupName: T,
272
- positions: g,
282
+ groupType: N,
283
+ groupName: w,
284
+ positions: b,
273
285
  parentId: e.id,
274
- positionId: H?.position_id,
275
- disabled: b,
276
- hideSourceAction: r?.actions?.disableUserSources || !1,
286
+ positionId: q?.position_id,
287
+ disabled: M,
288
+ hideSourceAction: i?.actions?.disableUserSources || !1,
277
289
  onSubmit: (t) => {
278
- const i = `argument_${e.id}_reply_list`;
279
- X.add(i, [t]), U(), M(!0);
290
+ const r = `argument_${e.id}_reply_list`;
291
+ I.add(r, [t]), k(), C(!0);
280
292
  },
281
293
  onUpdate: (t) => {
282
- v(
283
- (i) => i?.map(
284
- (d) => d.id === t.id ? { ...d, ...t } : d
294
+ h(
295
+ (r) => r?.map(
296
+ (a) => a.id === t.id ? { ...a, ...t } : a
285
297
  )
286
298
  );
287
299
  },
288
300
  isReply: !0,
289
301
  autoFocus: !0,
290
302
  avatarSize: 40,
291
- placeholder: a.formatMessage({
303
+ placeholder: l.formatMessage({
292
304
  id: "input.reply_input.your_answer",
293
305
  defaultMessage: "Your answer"
294
306
  }),
295
- userGuideUrl: r?.provider?.userGuideUrl,
296
- hideUserGuideLink: r?.provider?.hideUserGuideLink
307
+ userGuideUrl: i?.provider?.userGuideUrl,
308
+ hideUserGuideLink: i?.provider?.hideUserGuideLink
297
309
  },
298
310
  `Reply${e.id}`
299
311
  ) }),
300
- u?.length > 0 && m && /* @__PURE__ */ o("div", { className: s.repliesList, children: u.map((t) => $(t)) }),
301
- m && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
302
- Se,
312
+ m?.length > 0 && u && /* @__PURE__ */ s("div", { className: o.repliesList, children: m.map((t) => E(t)) }),
313
+ u && /* @__PURE__ */ s("div", { className: o.repliesList, children: /* @__PURE__ */ s(
314
+ xe,
303
315
  {
304
316
  voteableType: "Message",
305
317
  currentListId: `argument_${e.id}_reply_list`,
306
- loadingComponent: /* @__PURE__ */ o(Re, {}),
318
+ loadingComponent: /* @__PURE__ */ s(Ae, {}),
307
319
  resource: "messages",
308
320
  sort: "+created_at",
309
321
  filters: {
@@ -314,18 +326,18 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
314
326
  perPage: 5,
315
327
  display: "column",
316
328
  resourcePropName: "argument",
317
- emptyListComponent: /* @__PURE__ */ o(f, {}),
318
- transformData: (t) => re(t),
319
- children: $(e)
329
+ emptyListComponent: /* @__PURE__ */ s(y, {}),
330
+ transformData: (t) => ne(t),
331
+ children: E(e)
320
332
  }
321
333
  ) }),
322
- u?.length > 0 && !m && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
323
- Te,
334
+ m?.length > 0 && !u && /* @__PURE__ */ s("div", { className: o.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ s("div", { className: o.readMoreLink, children: /* @__PURE__ */ s(
335
+ Le,
324
336
  {
325
337
  role: "link",
326
- rightIcon: /* @__PURE__ */ o(E, { name: "lightArrow", height: 10, width: 10 }),
327
- handleClick: k,
328
- children: a.formatMessage({
338
+ rightIcon: /* @__PURE__ */ s(H, { name: "lightArrow", height: 10, width: 10 }),
339
+ handleClick: B,
340
+ children: l.formatMessage({
329
341
  id: "argument.argument.see_more",
330
342
  defaultMessage: "See more"
331
343
  })
@@ -333,8 +345,8 @@ const Ne = ce(() => import("../../input/argument_input/index.js").then((e) => ({
333
345
  ) }) })
334
346
  ] })
335
347
  ] });
336
- }, Ae = we;
348
+ }, ke = $e;
337
349
  export {
338
- we as Argument,
339
- Ae as ArgumentContainer
350
+ $e as Argument,
351
+ ke as ArgumentContainer
340
352
  };
@@ -1,16 +1,18 @@
1
- import { useState as r, useEffect as i } from "react";
2
- import { lexicalToHtml as s } from "../../input/text_editor/lexicalToHtml.js";
1
+ import { useState as l, useEffect as s } from "react";
2
+ import { lexicalToHtml as i } from "../../input/text_editor/lexicalToHtml.js";
3
3
  const f = (t) => {
4
- const [e, n] = r(null);
5
- return i(() => {
4
+ const [n, e] = l(null);
5
+ return s(() => {
6
6
  if (t.rich_content && t.is_deleted != !0) {
7
7
  const o = JSON.parse(t.rich_content);
8
8
  if (o.hasOwnProperty("root")) {
9
- const c = s(o);
10
- n(c);
11
- }
12
- }
13
- }, [t.rich_content]), e;
9
+ const c = i(o);
10
+ e(c);
11
+ } else
12
+ e(null);
13
+ } else
14
+ e(null);
15
+ }, [t.rich_content, t.is_deleted]), n;
14
16
  };
15
17
  export {
16
18
  f as useRichContent
@@ -1,63 +1,63 @@
1
- import { jsx as f, Fragment as I } from "react/jsx-runtime";
2
- import { useState as E, useEffect as l } from "react";
3
- import { useConfig as O } from "../../data/config_provider/useConfig.js";
4
- import { useDataProvider as q } from "../../data/data_provider/useDataProvider.js";
5
- import { useAuthInterceptor as L } from "../use_auth/useAuthInterceptor.js";
1
+ import { jsx as l, Fragment as y } from "react/jsx-runtime";
2
+ import { useState as I, useEffect as g } from "react";
3
+ import { useConfig as L } from "../../data/config_provider/useConfig.js";
4
+ import { useDataProvider as O } from "../../data/data_provider/useDataProvider.js";
5
+ import { useAuthInterceptor as q } from "../use_auth/useAuthInterceptor.js";
6
6
  import { authTokenHandler as S } from "../use_auth/authTokenHandler.js";
7
7
  import { useAuthActions as T } from "../use_auth/useAuthActions.js";
8
8
  import { useAuthRequired as _ } from "../../hooks/use_auth_required/useAuthRequired.js";
9
9
  import { useAuth as z } from "../use_auth/useAuth.js";
10
10
  import { AuthProviderFactory as M } from "../providers/AuthProviderFactory.js";
11
11
  import { OnboardingModal as j } from "../../user/onboarding_modal/OnboardingModal.js";
12
- import { httpClient as a } from "../../data/axios_client/httpClient.js";
13
- const X = ({ authUrl: n, authType: i, provider: g, assertion: p }) => {
14
- const s = "logora_user_token", e = O(), w = q();
15
- L(a, n, s);
16
- const [v, u] = E(!1), { getToken: A, removeToken: C } = S(
17
- a,
12
+ import { httpClient as u } from "../../data/axios_client/httpClient.js";
13
+ const X = ({ authUrl: n, authType: i, provider: p, assertion: w }) => {
14
+ const s = "logora_user_token", e = L(), v = O();
15
+ q(u, n, s);
16
+ const [A, c] = I(!1), { getToken: C, removeToken: P } = S(
17
+ u,
18
18
  n,
19
19
  s
20
- ), { loginUser: c, logoutUser: P, fetchUser: b } = T(
21
- a,
20
+ ), { loginUser: m, logoutUser: b, fetchUser: k } = T(
21
+ u,
22
22
  n,
23
23
  s
24
- ), m = _(), { setIsLoggingIn: x, currentUser: k } = z();
25
- l(() => {
26
- U();
27
- }, []), l(() => {
24
+ ), h = _(), { setIsLoggingIn: x, currentUser: E } = z();
25
+ g(() => {
26
+ a();
27
+ }, []), g(() => {
28
28
  if (typeof window < "u")
29
- return window.addEventListener("logora:authentication:require", m), () => {
30
- window.removeEventListener("logora:authentication:require", m);
29
+ return window.addEventListener("logora:authentication:require", h), window.addEventListener("logora:authentication:refresh", a), () => {
30
+ window.removeEventListener("logora:authentication:require", h), window.removeEventListener("logora:authentication:refresh", a);
31
31
  };
32
32
  }, []);
33
- const U = () => {
34
- const o = d(), t = A();
33
+ const a = () => {
34
+ const o = f(), t = C();
35
35
  if (t) {
36
36
  const r = t.session_id;
37
- o.isSameUser(r) ? b() : (C(), h(o));
37
+ o.isSameUser(r) ? k() : (P(), d(o));
38
38
  } else
39
- h(o);
40
- }, h = (o) => {
39
+ d(o);
40
+ }, d = (o) => {
41
41
  if (o.shouldInitAuth()) {
42
42
  const t = o.getAuthorizationParams();
43
43
  if (t) {
44
44
  if (i !== "social" && i !== "oauth2_server" && e.auth?.showOnboardingBeforeLogin === !0) {
45
- u(!0);
45
+ c(!0);
46
46
  return;
47
47
  }
48
- c(t);
48
+ m(t);
49
49
  }
50
50
  } else
51
- P();
52
- }, y = async (o) => {
53
- const r = d().getAuthorizationParams();
54
- await c(r), await w.update("users", k.slug, o), u(!1);
55
- }, d = () => M.create(i, g, p);
56
- return /* @__PURE__ */ f(I, { children: v && /* @__PURE__ */ f(
51
+ b();
52
+ }, U = async (o) => {
53
+ const r = f().getAuthorizationParams();
54
+ await m(r), await v.update("users", E.slug, o), c(!1);
55
+ }, f = () => M.create(i, p, w);
56
+ return /* @__PURE__ */ l(y, { children: A && /* @__PURE__ */ l(
57
57
  j,
58
58
  {
59
59
  pendingAuth: !0,
60
- onConsentConfirmed: y,
60
+ onConsentConfirmed: U,
61
61
  showTerms: e.auth?.hideCgu !== !0,
62
62
  showEmailConsent: e.auth?.showEmailConsent,
63
63
  termsUrl: e.provider?.cguUrl || "https://www.logora.com/blog-posts/cgu",
@@ -1,6 +1,6 @@
1
- import { jsxs as U, jsx as g, Fragment as Qe } from "react/jsx-runtime";
2
- import Ue from "@rooks/use-previous";
3
- import $e from "classnames";
1
+ import { jsxs as Q, jsx as g, Fragment as $e } from "react/jsx-runtime";
2
+ import Qe from "@rooks/use-previous";
3
+ import Ue from "classnames";
4
4
  import We, { useState as f, useEffect as p } from "react";
5
5
  import { useIntl as ze } from "react-intl";
6
6
  import { useLocation as Ge } from "react-router";
@@ -18,7 +18,7 @@ const ct = ({
18
18
  sortOptions: o,
19
19
  sort: M,
20
20
  filters: m,
21
- tagList: ne,
21
+ tagList: se,
22
22
  pinnedTagList: ae,
23
23
  currentPage: R,
24
24
  resource: A,
@@ -31,8 +31,8 @@ const ct = ({
31
31
  queryParam: de = "query",
32
32
  tagParam: re = "tag_id",
33
33
  totalHeaderParam: D = "total",
34
- onUpdateTotal: $,
35
- onElementsLoad: b,
34
+ onUpdateTotal: U,
35
+ onElementsLoad: _,
36
36
  transformData: W,
37
37
  uniqueIdKey: S = "id",
38
38
  children: fe,
@@ -55,44 +55,44 @@ const ct = ({
55
55
  withUrlParams: Ne = !1,
56
56
  onLoadNewPage: Z
57
57
  }) => {
58
- const J = ze(), t = Ve(), H = Xe(), I = Ge(), { isMobile: K, isTablet: Me, isDesktop: L } = Ye(), [k, E] = f(!1), [Re, be] = f(!1), [d, y] = Ze(a, []), [O, ke] = f(
58
+ const J = ze(), t = Ve(), H = Xe(), I = Ge(), { isMobile: K, isTablet: Me, isDesktop: L } = Ye(), [b, E] = f(!1), [Re, _e] = f(!1), [d, y] = Ze(a, []), [O, be] = f(
59
59
  d?.length || 0
60
- ), [h, j] = f(R || 1), [w, B] = f(N || null), [C, q] = f(null), [Ce, ee] = f(null), c = new URLSearchParams(
60
+ ), [h, j] = f(R || 1), [w, B] = f(N || null), [k, q] = f(null), [ke, ee] = f(null), c = new URLSearchParams(
61
61
  typeof window < "u" ? window.location.search : I.search
62
- ), Te = () => o && o[0].type === "sort" && o[0].value || M || "", Fe = () => {
62
+ ), Ce = () => o && o[0].type === "sort" && o[0].value || M || "", Te = () => {
63
63
  let e = {};
64
64
  return o && o[0].type === "filter" && (e[o[0].name] = o[0].value), m && (e = Object.assign({}, e, m)), e;
65
- }, [T, F] = f(Te()), [Q, _] = f(Fe()), te = Ue(m);
66
- R && R !== h && j(R), N !== void 0 && N !== w && B(N), M !== void 0 && M !== T && F(M), te && JSON.stringify(m) !== JSON.stringify(te) && JSON.stringify(m) !== JSON.stringify(Q) && _(m), p(() => {
65
+ }, [C, T] = f(Ce()), [$, F] = f(Te()), te = Qe(m);
66
+ R && R !== h && j(R), N !== void 0 && N !== w && B(N), M !== void 0 && M !== C && T(M), te && JSON.stringify(m) !== JSON.stringify(te) && JSON.stringify(m) !== JSON.stringify($) && F(m), p(() => {
67
67
  if (c.get("tagId") && q(Number.parseInt(c.get("tagId"))), c.get("search") && B(c.get("search")), c.get("sort")) {
68
- F(c.get("sort"));
68
+ T(c.get("sort"));
69
69
  for (const e of c.values()) {
70
- o?.map((s) => {
71
- s.value === e && ee(s.name);
70
+ o?.map((n) => {
71
+ n.value === e && ee(n.name);
72
72
  });
73
73
  break;
74
74
  }
75
75
  }
76
76
  for (const e of c.keys()) {
77
- o?.map((s) => {
78
- s.name === e && (_({
77
+ o?.map((n) => {
78
+ n.name === e && (F({
79
79
  ...m,
80
- [s.name]: s.value
81
- }), ee(s.name));
80
+ [n.name]: n.value
81
+ }), ee(n.name));
82
82
  });
83
83
  break;
84
84
  }
85
85
  }, [I.search]), p(() => {
86
- A ? (j(1), y([]), E(!0), se(1)) : E(!1);
86
+ A ? (j(1), y([]), E(!0), ne(1)) : E(!1);
87
87
  }, [
88
- T,
89
- Q,
88
+ C,
89
+ $,
90
90
  w,
91
91
  A,
92
- C,
92
+ k,
93
93
  v
94
94
  ]), p(() => {
95
- h > 1 && (E(!0), se(h));
95
+ h > 1 && (E(!0), ne(h));
96
96
  }, [h]), p(() => {
97
97
  if (t.addElements && a in t.addElements && t.addElements[a].length > 0) {
98
98
  Ae(t.addElements[a]);
@@ -103,15 +103,15 @@ const ct = ({
103
103
  if (t.updateElements && a in t.updateElements) {
104
104
  const e = t.updateElements[a];
105
105
  if (e.length > 0) {
106
- const s = e.filter(
107
- (i) => d.some((n) => n.id === i.id)
106
+ const n = e.filter(
107
+ (i) => d.some((s) => s.id === i.id)
108
108
  );
109
- if (s.length > 0) {
110
- De(s);
109
+ if (n.length > 0) {
110
+ De(n);
111
111
  const i = e.filter(
112
112
  (r) => !d.some((u) => u.id === r.id)
113
- ), n = { ...t.updateElements };
114
- i.length > 0 ? n[a] = i : delete n[a], t.setUpdateElements(n);
113
+ ), s = { ...t.updateElements };
114
+ i.length > 0 ? s[a] = i : delete s[a], t.setUpdateElements(s);
115
115
  }
116
116
  }
117
117
  }
@@ -122,71 +122,71 @@ const ct = ({
122
122
  delete e[a], t.setRemoveElements(e);
123
123
  }
124
124
  }, [t.removeElements, d]);
125
- const _e = (e) => {
126
- e.type === "filter" ? (F(""), _({
125
+ const Fe = (e) => {
126
+ e.type === "filter" ? (T(""), F({
127
127
  ...m,
128
128
  [e.name]: e.value
129
- })) : (F(e.value), _(m ? { ...m } : {}));
129
+ })) : (T(e.value), F(m ? { ...m } : {}));
130
130
  }, xe = () => {
131
131
  typeof Z == "function" && Z() !== null || j(h + 1);
132
- }, se = (e) => {
133
- const s = le ? H.getListWithToken : H.getList;
132
+ }, ne = (e) => {
133
+ const n = le ? H.getListWithToken : H.getList;
134
134
  if ((e - 1) * v <= (Y || O) || e === 1) {
135
135
  const i = {
136
136
  [oe]: e,
137
137
  [ie]: v,
138
- ...T && !w && { [me]: T },
138
+ ...C && !w && { [me]: C },
139
139
  ...w && { [de]: w },
140
140
  ...ye === !0 && { countless: !0 },
141
- ...Q,
142
- ...C && { [re]: C }
141
+ ...$,
142
+ ...k && { [re]: k }
143
143
  };
144
- s(A, i).then((n) => {
145
- const r = n.headers;
146
- r && D in r && (ke(
144
+ n(A, i).then((s) => {
145
+ const r = s.headers;
146
+ r && D in r && (be(
147
147
  Number.parseInt(r[D || "total"], 10)
148
- ), $ && $(r[D || "total"]));
149
- let u = n?.data?.data;
150
- b && b(u), W && (u = u.filter(W)), t.addElements && a in t.addElements && t.addElements[a].length > 0 && (u = [...t.addElements[a], u]), Le(u), E(!1);
151
- }).catch((n) => {
152
- console.error(n), n?.response?.status !== 404 && be(!0), E(!1);
148
+ ), U && U(r[D || "total"]));
149
+ let u = s?.data?.data;
150
+ _ && _(u), W && (u = u.filter(W)), t.addElements && a in t.addElements && t.addElements[a].length > 0 && (u = [...t.addElements[a], u]), Le(u), E(!1);
151
+ }).catch((s) => {
152
+ console.error(s), s?.response?.status !== 404 && _e(!0), E(!1);
153
153
  });
154
154
  } else
155
155
  E(!1);
156
156
  }, Ae = (e) => {
157
157
  y(
158
- (s) => x([...e, ...s], S || "id")
159
- ), b && b(e);
158
+ (n) => x([...e, ...n], S || "id")
159
+ ), _ && _(e);
160
160
  }, De = (e) => {
161
- y((s) => {
162
- let i = s;
161
+ y((n) => {
162
+ let i = n;
163
163
  return e.forEach(
164
- (n) => i = i.map(
165
- (r) => r.id === n.id ? n : r
164
+ (s) => i = i.map(
165
+ (r) => r.id === s.id ? s : r
166
166
  )
167
167
  ), x(i, S || "id");
168
168
  });
169
169
  }, Je = (e) => {
170
- const s = e.map((n) => n.id), i = d.filter(
171
- (n) => s.indexOf(n.id) === -1
170
+ const n = e.map((s) => s.id), i = d.filter(
171
+ (s) => n.indexOf(s.id) === -1
172
172
  );
173
173
  y(x(i, S || "id"));
174
174
  }, Le = (e) => {
175
175
  y(
176
- (s) => x([...s, ...e], S || "id")
176
+ (n) => x([...n, ...e], S || "id")
177
177
  );
178
- }, je = (e, s) => e !== void 0 ? /* @__PURE__ */ g(
178
+ }, je = (e, n) => e !== void 0 ? /* @__PURE__ */ g(
179
179
  "li",
180
180
  {
181
181
  className: l.paginatedListItem,
182
182
  "data-testid": "list-item",
183
183
  onClick: we,
184
184
  children: /* @__PURE__ */ g(Ie, { hideMessage: !0, children: We.cloneElement(fe, {
185
- index: s,
185
+ index: n,
186
186
  [ce]: e
187
187
  }) })
188
188
  },
189
- `${e[S || "id"]}_${e.updated_at || e.content}`
189
+ `${e[S || "id"]}_${e.updated_at || ""}_${e.rich_content || e.content || ""}`
190
190
  ) : null, Be = (e) => z ? /* @__PURE__ */ g("li", { className: l.paginatedListItem, children: z }, e) : null;
191
191
  if (Re)
192
192
  throw new Error(
@@ -195,7 +195,7 @@ const ct = ({
195
195
  defaultMessage: "Error when loading content."
196
196
  })
197
197
  );
198
- return /* @__PURE__ */ U("div", { className: l.listContainer, children: [
198
+ return /* @__PURE__ */ Q("div", { className: l.listContainer, children: [
199
199
  /* @__PURE__ */ g(
200
200
  Pe,
201
201
  {
@@ -203,25 +203,25 @@ const ct = ({
203
203
  subtitle: Ee,
204
204
  showDebateConsultationSubtitle: he,
205
205
  sortOptions: o,
206
- defaultSelectOption: Ce,
206
+ defaultSelectOption: ke,
207
207
  searchBar: ue,
208
- tagList: ne,
208
+ tagList: se,
209
209
  pinnedTagList: ae,
210
- activeTagId: C,
210
+ activeTagId: k,
211
211
  onSearch: (e) => B(e),
212
- onSortChange: _e,
212
+ onSortChange: Fe,
213
213
  onTagChange: (e) => q(e),
214
214
  withUrlParams: Ne
215
215
  }
216
216
  ),
217
- !k && d.length === 0 ? G ? /* @__PURE__ */ g("div", { className: l.emptyListElement, children: G }) : /* @__PURE__ */ g("div", { className: l.emptyList, children: P || J.formatMessage({
217
+ !b && d.length === 0 ? G ? /* @__PURE__ */ g("div", { className: l.emptyListElement, children: G }) : /* @__PURE__ */ g("div", { className: l.emptyList, children: P || J.formatMessage({
218
218
  id: "info.emptyList",
219
219
  defaultMessage: "No items for now."
220
- }) }) : /* @__PURE__ */ U(Qe, { children: [
221
- /* @__PURE__ */ U(
220
+ }) }) : /* @__PURE__ */ Q($e, { children: [
221
+ /* @__PURE__ */ Q(
222
222
  "ul",
223
223
  {
224
- className: $e(l.paginatedList, {
224
+ className: Ue(l.paginatedList, {
225
225
  [l.paginatedListIsTablet]: !K && !L,
226
226
  [l.centeredList]: V === "column",
227
227
  [l.column]: V === "column",
@@ -235,11 +235,11 @@ const ct = ({
235
235
  style: { gap: ve },
236
236
  children: [
237
237
  d.map(je),
238
- k ? Array(v).fill().map((e, s) => s).map(Be) : null
238
+ b ? Array(v).fill().map((e, n) => n).map(Be) : null
239
239
  ]
240
240
  }
241
241
  ),
242
- !k && Se !== !1 && /* @__PURE__ */ g(
242
+ !b && Se !== !1 && /* @__PURE__ */ g(
243
243
  He,
244
244
  {
245
245
  buttonText: J.formatMessage({
@@ -250,7 +250,7 @@ const ct = ({
250
250
  perPage: v,
251
251
  totalElements: Y || O,
252
252
  onLoad: xe,
253
- isLoading: k,
253
+ isLoading: b,
254
254
  hideLoader: !0,
255
255
  "data-tid": "list_read_more"
256
256
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.15",
3
+ "version": "0.4.17",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",