@logora/debate 0.3.46 → 0.3.48

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,5 +1,5 @@
1
1
  import { jsx as o, jsxs as l, Fragment as h } from "react/jsx-runtime";
2
- import B from "classnames";
2
+ import $ from "classnames";
3
3
  import { useState as f, useEffect as ie, useCallback as ae, Suspense as le, lazy as ne } from "react";
4
4
  import { useIntl as de } from "react-intl";
5
5
  import s from "./Argument.module.scss.js";
@@ -7,30 +7,30 @@ import { ReplyFooter as ce } from "./ReplyFooter.js";
7
7
  import { useRichContent as pe } from "./useRichContent.js";
8
8
  import { useAuth as me } from "../../auth/use_auth/useAuth.js";
9
9
  import { useConfig as ue } from "../../data/config_provider/useConfig.js";
10
- import { useTranslatedContent as $ } from "../../translation/translated_content/useTranslatedContent.js";
10
+ import { useTranslatedContent as B } from "../../translation/translated_content/useTranslatedContent.js";
11
11
  import { SourceListItem as he } from "../../source/source_list_item/SourceListItem.js";
12
12
  import { HashScroll as fe } from "../../tools/hash_scroll/HashScroll.js";
13
13
  import { ContentHeader as ye } from "../../user_content/content_header/ContentHeader.js";
14
14
  import { Icon as D } from "../../icons/icon/Icon.js";
15
- import { ReadMore as ge } from "../../text/read_more/ReadMore.js";
16
- import { TranslationButton as _e } from "../../translation/translation_button/TranslationButton.js";
15
+ import { ReadMore as _e } from "../../text/read_more/ReadMore.js";
16
+ import { TranslationButton as ge } from "../../translation/translation_button/TranslationButton.js";
17
17
  import { ContentFooter as be } from "../../user_content/content_footer/ContentFooter.js";
18
18
  import { VoteButton as Me } from "../../vote/vote_button/VoteButton.js";
19
19
  import { VotePaginatedList as ve } from "../../list/paginated_list/VotePaginatedList.js";
20
- import { UserContentSkeleton as Ce } from "../../skeleton/user_content_skeleton/UserContentSkeleton.js";
21
- import { Button as Ie } from "../../action/button/Button.js";
20
+ import { UserContentSkeleton as Ie } from "../../skeleton/user_content_skeleton/UserContentSkeleton.js";
21
+ import { Button as Ce } from "../../action/button/Button.js";
22
22
  const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({ default: e.ArgumentInput }))), E = (e) => e?.replace(/ /g, " "), Re = ({
23
23
  argument: e,
24
24
  argumentReplies: n,
25
25
  nestingLevel: y = 0,
26
- groupType: I,
26
+ groupType: C,
27
27
  groupName: S,
28
- positions: g = [],
28
+ positions: _ = [],
29
29
  disableLinks: P = !1,
30
30
  parentArgument: d,
31
31
  flashParent: F,
32
32
  expandable: j,
33
- disabled: _ = !1,
33
+ disabled: g = !1,
34
34
  hideFooter: R = !1,
35
35
  hideReplies: T,
36
36
  vote: G,
@@ -43,17 +43,17 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
43
43
  replyRedirectUrl: J,
44
44
  hideContent: K = !1
45
45
  }) => {
46
- const i = de(), { isLoggedIn: Q, currentUser: c } = me(), N = c?.moderation_status === "banned", r = ue(), [p, b] = f(!1), [W, w] = f(!1), [X, Z] = f(!1), x = pe(e), [m, M] = f(), u = $(
46
+ const i = de(), { isLoggedIn: Q, currentUser: c } = me(), N = c?.moderation_status === "banned", r = ue(), [p, b] = f(!1), [W, w] = f(!1), [X, Z] = f(!1), x = pe(e), [m, M] = f(), u = B(
47
47
  e.content,
48
48
  e.language,
49
49
  "content",
50
50
  e.translation_entries
51
- ), ee = $(
51
+ ), ee = B(
52
52
  e.position?.name,
53
53
  e.position?.language,
54
54
  "name",
55
55
  e.position?.translation_entries
56
- ), v = `argument_${e.id}`, C = e.position && g?.map((t) => t.id).indexOf(e.position.id) + 1;
56
+ ), v = `argument_${e.id}`, I = e.position && _?.map((t) => t.id).indexOf(e.position.id) + 1;
57
57
  ie(() => {
58
58
  n !== void 0 && re();
59
59
  }, [n]);
@@ -90,10 +90,10 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
90
90
  {
91
91
  ...t ? { argument: t } : {},
92
92
  nestingLevel: y + 1,
93
- disabled: _,
93
+ disabled: g,
94
94
  groupName: S,
95
- groupType: I,
96
- positions: g,
95
+ groupType: C,
96
+ positions: _,
97
97
  argumentReplies: n,
98
98
  parentArgument: e,
99
99
  flashParent: (a) => te(`argument_${a}`)
@@ -103,14 +103,14 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
103
103
  /* @__PURE__ */ l(
104
104
  "div",
105
105
  {
106
- className: B(
106
+ className: $(
107
107
  s.argument,
108
108
  {
109
109
  [s.flash]: W,
110
110
  [s.argumentReply]: e.is_reply === !0
111
111
  },
112
112
  s[`level-${y}`],
113
- s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && C}`]
113
+ s[`position-${!(e.author.role === "editor" || e.author.role === "moderator") && I}`]
114
114
  ),
115
115
  id: v,
116
116
  children: [
@@ -121,7 +121,7 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
121
121
  author: e.author,
122
122
  tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : ee.translatedContent,
123
123
  date: e.created_at,
124
- tagClassName: s[`headerPosition-${C}`],
124
+ tagClassName: s[`headerPosition-${I}`],
125
125
  disableLinks: P,
126
126
  isDeleted: e.is_deleted,
127
127
  showModerationFeedback: Y ?? (e.status === "rejected" && r.moderation?.showFeedback === !0),
@@ -140,7 +140,7 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
140
140
  /* @__PURE__ */ l(
141
141
  "div",
142
142
  {
143
- className: B(s.argumentBody, {
143
+ className: $(s.argumentBody, {
144
144
  [s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? H : !1
145
145
  }),
146
146
  children: [
@@ -165,7 +165,7 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
165
165
  }
166
166
  ),
167
167
  /* @__PURE__ */ o(
168
- ge,
168
+ _e,
169
169
  {
170
170
  content: /* @__PURE__ */ l(h, { children: [
171
171
  e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: i.formatMessage({
@@ -180,7 +180,7 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
180
180
  }
181
181
  ) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: E(u.translatedContent) }),
182
182
  u.isTranslated && /* @__PURE__ */ o(
183
- _e,
183
+ ge,
184
184
  {
185
185
  language: e.language,
186
186
  callback: () => u.toggleContent()
@@ -209,7 +209,7 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
209
209
  be,
210
210
  {
211
211
  resource: e,
212
- disabled: _ || e.status === "rejected" || !Q && r?.actions?.disableInputForVisitor === !0 || N,
212
+ disabled: g || e.status === "rejected" || !Q && r?.actions?.disableInputForVisitor === !0 || N,
213
213
  reportType: "Message",
214
214
  softDelete: r.actions?.softDelete,
215
215
  deleteType: "messages",
@@ -240,7 +240,7 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
240
240
  voteableId: e.id,
241
241
  totalUpvote: e.upvotes,
242
242
  totalDownvote: 0,
243
- activeClassName: s[`voteButtonPosition-${C}`],
243
+ activeClassName: s[`voteButtonPosition-${I}`],
244
244
  disabled: e.status === "rejected" || c?.id === e?.author?.id || N
245
245
  }
246
246
  )
@@ -264,13 +264,14 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
264
264
  Se,
265
265
  {
266
266
  groupId: e.group_id,
267
- groupType: I,
267
+ groupType: C,
268
268
  groupName: S,
269
- positions: g,
269
+ positions: _,
270
270
  parentId: e.id,
271
271
  positionId: G?.position_id,
272
- disabled: _,
272
+ disabled: g,
273
273
  hideSourceAction: r?.actions?.disableUserSources || !1,
274
+ argumentListId: `argument_${e.id}_reply_list`,
274
275
  onSubmit: (t) => {
275
276
  A(), M([t]), b(!0);
276
277
  },
@@ -291,7 +292,7 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
291
292
  {
292
293
  voteableType: "Message",
293
294
  currentListId: `argument_${e.id}_reply_list`,
294
- loadingComponent: /* @__PURE__ */ o(Ce, {}),
295
+ loadingComponent: /* @__PURE__ */ o(Ie, {}),
295
296
  resource: "messages",
296
297
  sort: "+created_at",
297
298
  filters: {
@@ -308,7 +309,7 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
308
309
  }
309
310
  ) }),
310
311
  m?.length > 0 && !p && /* @__PURE__ */ o("div", { className: s.repliesList, children: e.number_replies > 1 && /* @__PURE__ */ o("div", { className: s.readMoreLink, children: /* @__PURE__ */ o(
311
- Ie,
312
+ Ce,
312
313
  {
313
314
  role: "link",
314
315
  rightIcon: /* @__PURE__ */ o(D, { name: "lightArrow", height: 10, width: 10 }),
@@ -1,7 +1,7 @@
1
- import { jsxs as U, jsx as d, Fragment as Le } from "react/jsx-runtime";
1
+ import { jsxs as U, jsx as c, Fragment as Le } from "react/jsx-runtime";
2
2
  import je from "@rooks/use-previous";
3
3
  import Be from "classnames";
4
- import Qe, { useState as m, useEffect as g } from "react";
4
+ import Qe, { useState as m, useEffect as h } from "react";
5
5
  import { useIntl as Ue } from "react-intl";
6
6
  import { useLocation as We } from "react-router";
7
7
  import a from "./PaginatedList.module.scss.js";
@@ -23,7 +23,7 @@ const rt = ({
23
23
  resource: _,
24
24
  currentListId: n,
25
25
  withToken: ae,
26
- perPage: h,
26
+ perPage: p,
27
27
  perPageParam: le = "per_page",
28
28
  pageParam: ie = "page",
29
29
  sortParam: oe = "sort",
@@ -33,7 +33,7 @@ const rt = ({
33
33
  onUpdateTotal: W,
34
34
  onElementsLoad: R,
35
35
  transformData: z,
36
- uniqueIdKey: p = "id",
36
+ uniqueIdKey: v = "id",
37
37
  children: de,
38
38
  resourcePropName: fe,
39
39
  loadingComponent: G,
@@ -52,17 +52,17 @@ const rt = ({
52
52
  withUrlParams: Se = !1,
53
53
  onLoadNewPage: $
54
54
  }) => {
55
- const J = Ue(), t = Ge(), H = Pe(), I = We(), { isMobile: K, isTablet: ye, isDesktop: L } = Ve(), [b, f] = m(!1), [we, Ne] = m(!1), [v, S] = Xe(n, []), [O, Me] = m(
56
- v?.length || 0
57
- ), [c, j] = m(M || 1), [y, B] = m(w || null), [k, q] = m(null), [Re, ee] = m(null), r = new URLSearchParams(
55
+ const J = Ue(), t = Ge(), H = Pe(), I = We(), { isMobile: K, isTablet: ye, isDesktop: L } = Ve(), [b, u] = m(!1), [we, Ne] = m(!1), [k, S] = Xe(n, []), [O, Me] = m(
56
+ k?.length || 0
57
+ ), [E, j] = m(M || 1), [y, B] = m(w || null), [C, q] = m(null), [Re, ee] = m(null), r = new URLSearchParams(
58
58
  typeof window < "u" ? window.location.search : I.search
59
59
  ), be = () => i && i[0].type === "sort" && i[0].value || N || "", ke = () => {
60
60
  let e = {};
61
61
  return i && i[0].type === "filter" && (e[i[0].name] = i[0].value), o && (e = Object.assign({}, e, o)), e;
62
- }, [C, F] = m(be()), [Q, T] = m(ke()), te = je(o);
63
- M && M !== c && j(M), w !== void 0 && w !== y && B(w), N !== void 0 && N !== C && F(N), te && JSON.stringify(o) !== JSON.stringify(te) && JSON.stringify(o) !== JSON.stringify(Q) && T(o), g(() => {
62
+ }, [F, T] = m(be()), [Q, x] = m(ke()), te = je(o);
63
+ M && M !== E && j(M), w !== void 0 && w !== y && B(w), N !== void 0 && N !== F && T(N), te && JSON.stringify(o) !== JSON.stringify(te) && JSON.stringify(o) !== JSON.stringify(Q) && x(o), h(() => {
64
64
  if (r.get("tagId") && q(Number.parseInt(r.get("tagId"))), r.get("search") && B(r.get("search")), r.get("sort")) {
65
- F(r.get("sort"));
65
+ T(r.get("sort"));
66
66
  for (const e of r.values()) {
67
67
  i?.map((s) => {
68
68
  s.value === e && ee(s.name);
@@ -72,37 +72,37 @@ const rt = ({
72
72
  }
73
73
  for (const e of r.keys()) {
74
74
  i?.map((s) => {
75
- s.name === e && (T({
75
+ s.name === e && (x({
76
76
  ...o,
77
77
  [s.name]: s.value
78
78
  }), ee(s.name));
79
79
  });
80
80
  break;
81
81
  }
82
- }, [I.search]), g(() => {
83
- _ ? (j(1), S([]), f(!0), se(1)) : f(!1);
82
+ }, [I.search]), h(() => {
83
+ _ ? (j(1), S([]), u(!0), se(1)) : u(!1);
84
84
  }, [
85
- C,
85
+ F,
86
86
  Q,
87
87
  y,
88
88
  _,
89
- k,
90
- h
91
- ]), g(() => {
92
- c > 1 && (f(!0), se(c));
93
- }, [c]), g(() => {
89
+ C,
90
+ p
91
+ ]), h(() => {
92
+ E > 1 && (u(!0), se(E));
93
+ }, [E]), h(() => {
94
94
  if (t.addElements && n in t.addElements && t.addElements[n].length > 0) {
95
95
  Te(t.addElements[n]);
96
96
  const e = t.addElements;
97
97
  delete e[n], t.setAddElements(e);
98
98
  }
99
- }, [t.addElements]), g(() => {
99
+ }, [t.addElements]), h(() => {
100
100
  if (t.updateElements && n in t.updateElements && t.updateElements[n].length > 0) {
101
101
  xe(t.updateElements[n]);
102
102
  const e = t.updateElements;
103
103
  delete e[n], t.setUpdateElements(e);
104
104
  }
105
- }, [t.updateElements]), g(() => {
105
+ }, [t.updateElements]), h(() => {
106
106
  if (t.removeElements && n in t.removeElements && t.removeElements[n].length > 0) {
107
107
  Ae(t.removeElements[n]);
108
108
  const e = t.removeElements;
@@ -110,69 +110,71 @@ const rt = ({
110
110
  }
111
111
  }, [t.removeElements]);
112
112
  const Ce = (e) => {
113
- e.type === "filter" ? (F(""), T({
113
+ e.type === "filter" ? (T(""), x({
114
114
  ...o,
115
115
  [e.name]: e.value
116
- })) : (F(e.value), T(o ? { ...o } : {}));
116
+ })) : (T(e.value), x(o ? { ...o } : {}));
117
117
  }, Fe = () => {
118
- typeof $ == "function" && $() !== null || j(c + 1);
118
+ typeof $ == "function" && $() !== null || j(E + 1);
119
119
  }, se = (e) => {
120
120
  const s = ae ? H.getListWithToken : H.getList;
121
- if ((e - 1) * h <= (Z || O) || e === 1) {
122
- const u = {
121
+ if ((e - 1) * p <= (Z || O) || e === 1) {
122
+ const d = {
123
123
  [ie]: e,
124
- [le]: h,
125
- ...C && !y && { [oe]: C },
124
+ [le]: p,
125
+ ...F && !y && { [oe]: F },
126
126
  ...y && { [me]: y },
127
127
  ...pe === !0 && { countless: !0 },
128
128
  ...Q,
129
- ...k && { [re]: k }
129
+ ...C && { [re]: C }
130
130
  };
131
- s(_, u).then((l) => {
132
- const x = l.headers;
133
- x && D in x && (Me(
134
- Number.parseInt(x[D || "total"], 10)
135
- ), W && W(x[D || "total"]));
136
- let E = l?.data?.data;
137
- R && R(E), z && (E = E.filter(z)), t.addElements && n in t.addElements && t.addElements[n].length > 0 && (E = [...t.addElements[n], E]), _e(E), f(!1);
131
+ s(_, d).then((l) => {
132
+ const f = l.headers;
133
+ f && D in f && (Me(
134
+ Number.parseInt(f[D || "total"], 10)
135
+ ), W && W(f[D || "total"]));
136
+ let g = l?.data?.data;
137
+ R && R(g), z && (g = g.filter(z)), t.addElements && n in t.addElements && t.addElements[n].length > 0 && (g = [...t.addElements[n], g]), _e(g), u(!1);
138
138
  }).catch((l) => {
139
- console.error(l), l?.response?.status !== 404 && Ne(!0), f(!1);
139
+ console.error(l), l?.response?.status !== 404 && Ne(!0), u(!1);
140
140
  });
141
141
  } else
142
- f(!1);
142
+ u(!1);
143
143
  }, Te = (e) => {
144
144
  S(
145
- (s) => A([...e, ...s], p || "id")
145
+ (s) => A([...e, ...s], v || "id")
146
146
  ), R && R(e);
147
147
  }, xe = (e) => {
148
- let s = v;
149
- e.forEach(
150
- (u) => s = s.map(
151
- (l) => l.id === u.id ? u : l
152
- )
153
- ), S(A(s, p || "id"));
148
+ S((s) => {
149
+ let d = s;
150
+ return e.forEach(
151
+ (l) => d = d.map(
152
+ (f) => f.id === l.id ? l : f
153
+ )
154
+ ), A(d, v || "id");
155
+ });
154
156
  }, Ae = (e) => {
155
- const s = e.map((l) => l.id), u = v.filter(
157
+ const s = e.map((l) => l.id), d = k.filter(
156
158
  (l) => s.indexOf(l.id) === -1
157
159
  );
158
- S(A(u, p || "id"));
160
+ S(A(d, v || "id"));
159
161
  }, _e = (e) => {
160
162
  S(
161
- (s) => A([...s, ...e], p || "id")
163
+ (s) => A([...s, ...e], v || "id")
162
164
  );
163
- }, De = (e, s) => e !== void 0 ? /* @__PURE__ */ d(
165
+ }, De = (e, s) => e !== void 0 ? /* @__PURE__ */ c(
164
166
  "li",
165
167
  {
166
168
  className: a.paginatedListItem,
167
169
  "data-testid": "list-item",
168
170
  onClick: ve,
169
- children: /* @__PURE__ */ d(Ze, { hideMessage: !0, children: Qe.cloneElement(de, {
171
+ children: /* @__PURE__ */ c(Ze, { hideMessage: !0, children: Qe.cloneElement(de, {
170
172
  index: s,
171
173
  [fe]: e
172
174
  }) })
173
175
  },
174
- e[p || "id"]
175
- ) : null, Je = (e) => G ? /* @__PURE__ */ d("li", { className: a.paginatedListItem, children: G }, e) : null;
176
+ e[v || "id"]
177
+ ) : null, Je = (e) => G ? /* @__PURE__ */ c("li", { className: a.paginatedListItem, children: G }, e) : null;
176
178
  if (we)
177
179
  throw new Error(
178
180
  J.formatMessage({
@@ -181,7 +183,7 @@ const rt = ({
181
183
  })
182
184
  );
183
185
  return /* @__PURE__ */ U("div", { className: a.listContainer, children: [
184
- /* @__PURE__ */ d(
186
+ /* @__PURE__ */ c(
185
187
  ze,
186
188
  {
187
189
  title: ue,
@@ -189,14 +191,14 @@ const rt = ({
189
191
  defaultSelectOption: Re,
190
192
  searchBar: ce,
191
193
  tagList: ne,
192
- activeTagId: k,
194
+ activeTagId: C,
193
195
  onSearch: (e) => B(e),
194
196
  onSortChange: Ce,
195
197
  onTagChange: (e) => q(e),
196
198
  withUrlParams: Se
197
199
  }
198
200
  ),
199
- !b && v.length === 0 ? P ? /* @__PURE__ */ d("div", { className: a.emptyListElement, children: P }) : /* @__PURE__ */ d("div", { className: a.emptyList, children: V || J.formatMessage({
201
+ !b && k.length === 0 ? P ? /* @__PURE__ */ c("div", { className: a.emptyListElement, children: P }) : /* @__PURE__ */ c("div", { className: a.emptyList, children: V || J.formatMessage({
200
202
  id: "info.emptyList",
201
203
  defaultMessage: "No items for now."
202
204
  }) }) : /* @__PURE__ */ U(Le, { children: [
@@ -216,20 +218,20 @@ const rt = ({
216
218
  }),
217
219
  style: { gap: ge },
218
220
  children: [
219
- v.map(De),
220
- b ? Array(h).fill().map((e, s) => s).map(Je) : null
221
+ k.map(De),
222
+ b ? Array(p).fill().map((e, s) => s).map(Je) : null
221
223
  ]
222
224
  }
223
225
  ),
224
- !b && he !== !1 && /* @__PURE__ */ d(
226
+ !b && he !== !1 && /* @__PURE__ */ c(
225
227
  Ye,
226
228
  {
227
229
  buttonText: J.formatMessage({
228
230
  id: "action.see_more",
229
231
  defaultMessage: "See more"
230
232
  }),
231
- currentPage: c,
232
- perPage: h,
233
+ currentPage: E,
234
+ perPage: p,
233
235
  totalElements: Z || O,
234
236
  onLoad: Fe,
235
237
  isLoading: b,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.3.46",
3
+ "version": "0.3.48",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",