@logora/debate 0.3.54 → 0.3.56
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,76 +1,77 @@
|
|
|
1
1
|
import { jsx as o, jsxs as l, Fragment as h } from "react/jsx-runtime";
|
|
2
|
-
import
|
|
3
|
-
import { useState as f, useEffect as
|
|
4
|
-
import { useIntl as
|
|
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
5
|
import s from "./Argument.module.scss.js";
|
|
6
|
-
import { ReplyFooter as
|
|
7
|
-
import { useRichContent as
|
|
8
|
-
import { useAuth as
|
|
9
|
-
import { useConfig as
|
|
10
|
-
import { useTranslatedContent as
|
|
11
|
-
import { SourceListItem as
|
|
12
|
-
import { HashScroll as
|
|
13
|
-
import { ContentHeader as
|
|
14
|
-
import { Icon as
|
|
15
|
-
import { ReadMore as
|
|
16
|
-
import { TranslationButton as
|
|
17
|
-
import { ContentFooter as
|
|
18
|
-
import { VoteButton as
|
|
19
|
-
import { VotePaginatedList as
|
|
20
|
-
import { UserContentSkeleton as
|
|
21
|
-
import { Button as
|
|
22
|
-
const
|
|
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 = ({
|
|
23
23
|
argument: e,
|
|
24
24
|
argumentReplies: n,
|
|
25
25
|
nestingLevel: y = 0,
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
maxNestingLevel: C = 2,
|
|
27
|
+
groupType: S,
|
|
28
|
+
groupName: R,
|
|
28
29
|
positions: _ = [],
|
|
29
|
-
disableLinks:
|
|
30
|
+
disableLinks: F = !1,
|
|
30
31
|
parentArgument: d,
|
|
31
|
-
flashParent:
|
|
32
|
-
expandable:
|
|
32
|
+
flashParent: j,
|
|
33
|
+
expandable: G,
|
|
33
34
|
disabled: g = !1,
|
|
34
|
-
hideFooter:
|
|
35
|
-
hideReplies:
|
|
36
|
-
vote:
|
|
37
|
-
fixedContentHeight:
|
|
38
|
-
enableEdition:
|
|
39
|
-
enableDeletion:
|
|
40
|
-
deleteListId:
|
|
41
|
-
showModerationFeedback:
|
|
42
|
-
lineCount:
|
|
43
|
-
replyRedirectUrl:
|
|
44
|
-
hideContent:
|
|
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
|
|
45
46
|
}) => {
|
|
46
|
-
const i =
|
|
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(
|
|
47
48
|
e.content,
|
|
48
49
|
e.language,
|
|
49
50
|
"content",
|
|
50
51
|
e.translation_entries
|
|
51
|
-
),
|
|
52
|
+
), te = D(
|
|
52
53
|
e.position?.name,
|
|
53
54
|
e.position?.language,
|
|
54
55
|
"name",
|
|
55
56
|
e.position?.translation_entries
|
|
56
57
|
), v = `argument_${e.id}`, I = e.position && _?.map((t) => t.id).indexOf(e.position.id) + 1;
|
|
57
|
-
|
|
58
|
-
n !== void 0 &&
|
|
58
|
+
ae(() => {
|
|
59
|
+
n !== void 0 && ie();
|
|
59
60
|
}, [n]);
|
|
60
|
-
const
|
|
61
|
+
const oe = (t) => {
|
|
61
62
|
if (v === t) {
|
|
62
|
-
const
|
|
63
|
-
|
|
63
|
+
const $ = document.getElementById(t);
|
|
64
|
+
$ && $.scrollIntoView({ behavior: "smooth" }), A(!0);
|
|
64
65
|
}
|
|
65
|
-
}, A = () => {
|
|
66
|
-
Z((t) => !t);
|
|
67
66
|
}, L = () => {
|
|
67
|
+
ee((t) => !t);
|
|
68
|
+
}, k = () => {
|
|
68
69
|
b((t) => !t), M([]);
|
|
69
|
-
},
|
|
70
|
+
}, se = (t) => {
|
|
70
71
|
if (!m?.find((a) => a.id === t.id))
|
|
71
72
|
return t;
|
|
72
|
-
},
|
|
73
|
-
|
|
73
|
+
}, re = le((t, a) => /* @__PURE__ */ o(
|
|
74
|
+
fe,
|
|
74
75
|
{
|
|
75
76
|
publisher: t.publisher,
|
|
76
77
|
url: t.source_url,
|
|
@@ -78,35 +79,36 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
78
79
|
index: a
|
|
79
80
|
},
|
|
80
81
|
a
|
|
81
|
-
), []),
|
|
82
|
+
), []), ie = () => {
|
|
82
83
|
if (n && Array.isArray(n)) {
|
|
83
84
|
const t = n.filter(
|
|
84
85
|
(a) => a.reply_to_id === e.id
|
|
85
86
|
);
|
|
86
87
|
t.length > 0 && (M(t), b(!0));
|
|
87
88
|
}
|
|
88
|
-
},
|
|
89
|
-
|
|
89
|
+
}, U = (t = null) => /* @__PURE__ */ o(
|
|
90
|
+
Ne,
|
|
90
91
|
{
|
|
91
92
|
...t ? { argument: t } : {},
|
|
92
93
|
nestingLevel: y + 1,
|
|
94
|
+
maxNestingLevel: C,
|
|
93
95
|
disabled: g,
|
|
94
|
-
groupName:
|
|
95
|
-
groupType:
|
|
96
|
+
groupName: R,
|
|
97
|
+
groupType: S,
|
|
96
98
|
positions: _,
|
|
97
99
|
argumentReplies: n,
|
|
98
100
|
parentArgument: e,
|
|
99
|
-
flashParent: (a) =>
|
|
101
|
+
flashParent: (a) => oe(`argument_${a}`)
|
|
100
102
|
}
|
|
101
103
|
);
|
|
102
|
-
return /* @__PURE__ */ l(
|
|
104
|
+
return /* @__PURE__ */ l(ye, { elementId: v, onScroll: () => A(!0), children: [
|
|
103
105
|
/* @__PURE__ */ l(
|
|
104
106
|
"div",
|
|
105
107
|
{
|
|
106
|
-
className:
|
|
108
|
+
className: B(
|
|
107
109
|
s.argument,
|
|
108
110
|
{
|
|
109
|
-
[s.flash]:
|
|
111
|
+
[s.flash]: X,
|
|
110
112
|
[s.argumentReply]: e.is_reply === !0
|
|
111
113
|
},
|
|
112
114
|
s[`level-${y}`],
|
|
@@ -115,16 +117,16 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
115
117
|
id: v,
|
|
116
118
|
children: [
|
|
117
119
|
/* @__PURE__ */ o(
|
|
118
|
-
|
|
120
|
+
_e,
|
|
119
121
|
{
|
|
120
122
|
selectedContent: e.is_selected,
|
|
121
123
|
author: e.author,
|
|
122
|
-
tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null :
|
|
124
|
+
tag: (e.author.role === "editor" || e.author.role === "moderator") && e.is_reply ? null : te.translatedContent,
|
|
123
125
|
date: e.created_at,
|
|
124
126
|
tagClassName: s[`headerPosition-${I}`],
|
|
125
|
-
disableLinks:
|
|
127
|
+
disableLinks: F,
|
|
126
128
|
isDeleted: e.is_deleted,
|
|
127
|
-
showModerationFeedback:
|
|
129
|
+
showModerationFeedback: q ?? (e.status === "rejected" && r.moderation?.showFeedback === !0),
|
|
128
130
|
moderationReason: e.moderation_entry?.moderation_reason,
|
|
129
131
|
moderationNotes: e.moderation_entry?.moderator_notes,
|
|
130
132
|
moderationPolicyUrl: r.provider?.userGuideUrl
|
|
@@ -133,22 +135,22 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
133
135
|
e.is_deleted ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
|
|
134
136
|
id: "info.deleted_by_user",
|
|
135
137
|
defaultMessage: "Content deleted by the user"
|
|
136
|
-
}) }) :
|
|
138
|
+
}) }) : Q ? /* @__PURE__ */ o("div", { className: s.argumentDeletedBody, children: i.formatMessage({
|
|
137
139
|
id: "argument.argument.content_deleted",
|
|
138
140
|
defaultMessage: "This content has been removed."
|
|
139
141
|
}) }) : /* @__PURE__ */ l(h, { children: [
|
|
140
142
|
/* @__PURE__ */ l(
|
|
141
143
|
"div",
|
|
142
144
|
{
|
|
143
|
-
className:
|
|
144
|
-
[s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ?
|
|
145
|
+
className: B(s.argumentBody, {
|
|
146
|
+
[s.fixedHeight]: r?.layout?.showAllArgumentInEmbed !== !0 ? V : !1
|
|
145
147
|
}),
|
|
146
148
|
children: [
|
|
147
149
|
e.is_reply && d && /* @__PURE__ */ l(
|
|
148
150
|
"div",
|
|
149
151
|
{
|
|
150
152
|
className: s.replyTo,
|
|
151
|
-
onClick: () =>
|
|
153
|
+
onClick: () => j(d.id),
|
|
152
154
|
children: [
|
|
153
155
|
i.formatMessage({
|
|
154
156
|
id: "info.replying_to",
|
|
@@ -159,13 +161,13 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
159
161
|
id: "info.deleted",
|
|
160
162
|
defaultMessage: "Deleted"
|
|
161
163
|
}) : d.author.full_name,
|
|
162
|
-
/* @__PURE__ */ o(
|
|
164
|
+
/* @__PURE__ */ o(E, { name: "chat", height: 16 })
|
|
163
165
|
] })
|
|
164
166
|
]
|
|
165
167
|
}
|
|
166
168
|
),
|
|
167
169
|
/* @__PURE__ */ o(
|
|
168
|
-
|
|
170
|
+
ge,
|
|
169
171
|
{
|
|
170
172
|
content: /* @__PURE__ */ l(h, { children: [
|
|
171
173
|
e.is_edited && /* @__PURE__ */ o("div", { className: s.edited, children: i.formatMessage({
|
|
@@ -176,18 +178,18 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
176
178
|
"div",
|
|
177
179
|
{
|
|
178
180
|
className: s.argumentContent,
|
|
179
|
-
dangerouslySetInnerHTML: { __html:
|
|
181
|
+
dangerouslySetInnerHTML: { __html: P(x) }
|
|
180
182
|
}
|
|
181
|
-
) : /* @__PURE__ */ o("div", { className: s.argumentContent, children:
|
|
183
|
+
) : /* @__PURE__ */ o("div", { className: s.argumentContent, children: P(u.translatedContent) }),
|
|
182
184
|
u.isTranslated && /* @__PURE__ */ o(
|
|
183
|
-
|
|
185
|
+
be,
|
|
184
186
|
{
|
|
185
187
|
language: e.language,
|
|
186
188
|
callback: () => u.toggleContent()
|
|
187
189
|
}
|
|
188
190
|
)
|
|
189
191
|
] }),
|
|
190
|
-
lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ?
|
|
192
|
+
lineCount: r?.layout?.showAllArgumentInEmbed !== !0 ? J : void 0,
|
|
191
193
|
readMoreText: i.formatMessage({
|
|
192
194
|
id: "action.read_more",
|
|
193
195
|
defaultMessage: "Read more"
|
|
@@ -196,27 +198,27 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
196
198
|
id: "action.read_less",
|
|
197
199
|
defaultMessage: "Read less"
|
|
198
200
|
}),
|
|
199
|
-
expandable: r?.layout?.showAllArgumentInEmbed !== !0 ?
|
|
201
|
+
expandable: r?.layout?.showAllArgumentInEmbed !== !0 ? G : !1,
|
|
200
202
|
readMoreClassName: e.is_reply ? s.replyStyle : s.argumentStyle
|
|
201
203
|
}
|
|
202
204
|
)
|
|
203
205
|
]
|
|
204
206
|
}
|
|
205
207
|
),
|
|
206
|
-
e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(
|
|
208
|
+
e.sources?.length > 0 && /* @__PURE__ */ o("div", { className: s.argumentSourcesList, children: e.sources.map(re) })
|
|
207
209
|
] }),
|
|
208
|
-
!
|
|
209
|
-
|
|
210
|
+
!T && !e.is_deleted && /* @__PURE__ */ o(
|
|
211
|
+
Me,
|
|
210
212
|
{
|
|
211
213
|
resource: e,
|
|
212
|
-
disabled: g || e.status === "rejected" || !
|
|
214
|
+
disabled: g || e.status === "rejected" || !W && r?.actions?.disableInputForVisitor === !0 || w,
|
|
213
215
|
reportType: "Message",
|
|
214
216
|
softDelete: r.actions?.softDelete,
|
|
215
217
|
deleteType: "messages",
|
|
216
|
-
deleteListId:
|
|
217
|
-
enableReply: y <=
|
|
218
|
-
handleReplyTo:
|
|
219
|
-
replyRedirectUrl:
|
|
218
|
+
deleteListId: Y,
|
|
219
|
+
enableReply: y <= C || c.role === "editor" || c.role === "moderator",
|
|
220
|
+
handleReplyTo: L,
|
|
221
|
+
replyRedirectUrl: K,
|
|
220
222
|
shareUrl: `https://app.logora.fr/share/a/${e.id}`,
|
|
221
223
|
shareTitle: i.formatMessage({
|
|
222
224
|
id: "share.argument.title",
|
|
@@ -231,49 +233,49 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
231
233
|
showShareText: !0,
|
|
232
234
|
showShareButton: r?.actions?.hideShareButton !== !0,
|
|
233
235
|
enableReport: !(e.score === 100 && e.manual_score),
|
|
234
|
-
enableEdition:
|
|
235
|
-
enableDeletion:
|
|
236
|
+
enableEdition: z,
|
|
237
|
+
enableDeletion: O,
|
|
236
238
|
children: /* @__PURE__ */ o(
|
|
237
|
-
|
|
239
|
+
ve,
|
|
238
240
|
{
|
|
239
241
|
voteableType: "Message",
|
|
240
242
|
voteableId: e.id,
|
|
241
243
|
totalUpvote: e.upvotes,
|
|
242
244
|
totalDownvote: 0,
|
|
243
245
|
activeClassName: s[`voteButtonPosition-${I}`],
|
|
244
|
-
disabled: e.status === "rejected" || c?.id === e?.author?.id ||
|
|
246
|
+
disabled: e.status === "rejected" || c?.id === e?.author?.id || w
|
|
245
247
|
}
|
|
246
248
|
)
|
|
247
249
|
}
|
|
248
250
|
),
|
|
249
|
-
!
|
|
250
|
-
|
|
251
|
+
!T && !N && /* @__PURE__ */ o(
|
|
252
|
+
pe,
|
|
251
253
|
{
|
|
252
254
|
numberReplies: e.number_replies,
|
|
253
255
|
repliesAuthors: e.replies_authors,
|
|
254
256
|
expandReplies: p,
|
|
255
|
-
onToggleReplies:
|
|
257
|
+
onToggleReplies: k,
|
|
256
258
|
isReply: e.is_reply
|
|
257
259
|
}
|
|
258
260
|
)
|
|
259
261
|
]
|
|
260
262
|
}
|
|
261
263
|
),
|
|
262
|
-
!
|
|
263
|
-
|
|
264
|
-
|
|
264
|
+
!N && /* @__PURE__ */ l(h, { children: [
|
|
265
|
+
Z && /* @__PURE__ */ o(ne, { fallback: null, children: /* @__PURE__ */ o(
|
|
266
|
+
Re,
|
|
265
267
|
{
|
|
266
268
|
groupId: e.group_id,
|
|
267
|
-
groupType:
|
|
268
|
-
groupName:
|
|
269
|
+
groupType: S,
|
|
270
|
+
groupName: R,
|
|
269
271
|
positions: _,
|
|
270
272
|
parentId: e.id,
|
|
271
|
-
positionId:
|
|
273
|
+
positionId: H?.position_id,
|
|
272
274
|
disabled: g,
|
|
273
275
|
hideSourceAction: r?.actions?.disableUserSources || !1,
|
|
274
276
|
argumentListId: `argument_${e.id}_reply_list`,
|
|
275
277
|
onSubmit: (t) => {
|
|
276
|
-
|
|
278
|
+
L(), M([t]), b(!0);
|
|
277
279
|
},
|
|
278
280
|
isReply: !0,
|
|
279
281
|
avatarSize: 40,
|
|
@@ -286,13 +288,13 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
286
288
|
},
|
|
287
289
|
`Reply${e.id}`
|
|
288
290
|
) }),
|
|
289
|
-
m?.length > 0 && p && /* @__PURE__ */ o("div", { className: s.repliesList, children: m.map((t) =>
|
|
291
|
+
m?.length > 0 && p && /* @__PURE__ */ o("div", { className: s.repliesList, children: m.map((t) => U(t)) }),
|
|
290
292
|
p && /* @__PURE__ */ o("div", { className: s.repliesList, children: /* @__PURE__ */ o(
|
|
291
|
-
|
|
293
|
+
Ie,
|
|
292
294
|
{
|
|
293
295
|
voteableType: "Message",
|
|
294
296
|
currentListId: `argument_${e.id}_reply_list`,
|
|
295
|
-
loadingComponent: /* @__PURE__ */ o(
|
|
297
|
+
loadingComponent: /* @__PURE__ */ o(Ce, {}),
|
|
296
298
|
resource: "messages",
|
|
297
299
|
sort: "+created_at",
|
|
298
300
|
filters: {
|
|
@@ -304,16 +306,16 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
304
306
|
display: "column",
|
|
305
307
|
resourcePropName: "argument",
|
|
306
308
|
emptyListComponent: /* @__PURE__ */ o(h, {}),
|
|
307
|
-
transformData: (t) =>
|
|
308
|
-
children:
|
|
309
|
+
transformData: (t) => se(t),
|
|
310
|
+
children: U(e)
|
|
309
311
|
}
|
|
310
312
|
) }),
|
|
311
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(
|
|
312
|
-
|
|
314
|
+
Se,
|
|
313
315
|
{
|
|
314
316
|
role: "link",
|
|
315
|
-
rightIcon: /* @__PURE__ */ o(
|
|
316
|
-
handleClick:
|
|
317
|
+
rightIcon: /* @__PURE__ */ o(E, { name: "lightArrow", height: 10, width: 10 }),
|
|
318
|
+
handleClick: k,
|
|
317
319
|
children: i.formatMessage({
|
|
318
320
|
id: "argument.argument.see_more",
|
|
319
321
|
defaultMessage: "See more"
|
|
@@ -322,8 +324,8 @@ const Se = ne(() => import("../../input/argument_input/index.js").then((e) => ({
|
|
|
322
324
|
) }) })
|
|
323
325
|
] })
|
|
324
326
|
] });
|
|
325
|
-
},
|
|
327
|
+
}, Ne = Te;
|
|
326
328
|
export {
|
|
327
|
-
|
|
328
|
-
|
|
329
|
+
Te as Argument,
|
|
330
|
+
Ne as ArgumentContainer
|
|
329
331
|
};
|
|
@@ -186,7 +186,7 @@ const it = We(() => import("../../modal/side_modal/index.js").then((I) => ({ def
|
|
|
186
186
|
if (t.data.success) {
|
|
187
187
|
const r = t.data.data.resource;
|
|
188
188
|
let s = I;
|
|
189
|
-
if (r.is_reply ? s = `argument_${r.reply_to_id || W?.reply_to_id}_reply_list` : l && !m && (s = `argumentList${r.position?.id}`), W?.position?.id != r.position?.id && !m && !r.is_reply) {
|
|
189
|
+
if (r.is_reply ? s = `argument_${r.reply_to_id || W?.reply_to_id}_reply_list` : l && !m && (s = `argumentList${r.position?.id}`), console.log("[updateArgument] listId:", s), W?.position?.id != r.position?.id && !m && !r.is_reply) {
|
|
190
190
|
const y = `argumentList${W.position.id}`, T = `argumentList${r.position.id}`;
|
|
191
191
|
x.remove(y, [r]), x.add(T, [r]);
|
|
192
192
|
} else
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import
|
|
3
|
-
import
|
|
1
|
+
import { jsxs as P, jsx as c, Fragment as je } from "react/jsx-runtime";
|
|
2
|
+
import Be from "@rooks/use-previous";
|
|
3
|
+
import Le from "classnames";
|
|
4
4
|
import Qe, { useState as m, useEffect as h } from "react";
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import { useLocation as
|
|
5
|
+
import { useIntl as Pe } from "react-intl";
|
|
6
|
+
import { useLocation as Ue } from "react-router";
|
|
7
7
|
import a from "./PaginatedList.module.scss.js";
|
|
8
|
-
import { ActionBar as
|
|
9
|
-
import { useList as
|
|
10
|
-
import { useDataProvider as
|
|
8
|
+
import { ActionBar as We } from "./action_bar/ActionBar.js";
|
|
9
|
+
import { useList as ze } from "../list_provider/useList.js";
|
|
10
|
+
import { useDataProvider as Ge } from "../../data/data_provider/useDataProvider.js";
|
|
11
11
|
import { useResponsive as Ve } from "../../hooks/use_responsive/useResponsive.js";
|
|
12
12
|
import { useData as Xe } from "../../data/data_provider/useData.js";
|
|
13
13
|
import { uniqueBy as A } from "../../util/unique_by/uniqueBy.js";
|
|
@@ -30,16 +30,16 @@ const rt = ({
|
|
|
30
30
|
queryParam: me = "query",
|
|
31
31
|
tagParam: re = "tag_id",
|
|
32
32
|
totalHeaderParam: D = "total",
|
|
33
|
-
onUpdateTotal:
|
|
33
|
+
onUpdateTotal: U,
|
|
34
34
|
onElementsLoad: R,
|
|
35
|
-
transformData:
|
|
35
|
+
transformData: W,
|
|
36
36
|
uniqueIdKey: v = "id",
|
|
37
37
|
children: de,
|
|
38
38
|
resourcePropName: fe,
|
|
39
|
-
loadingComponent:
|
|
39
|
+
loadingComponent: z,
|
|
40
40
|
searchBar: ce = !1,
|
|
41
41
|
title: ue,
|
|
42
|
-
emptyListComponent:
|
|
42
|
+
emptyListComponent: G,
|
|
43
43
|
emptyText: V,
|
|
44
44
|
display: X,
|
|
45
45
|
elementsPerLine: Y,
|
|
@@ -52,16 +52,16 @@ const rt = ({
|
|
|
52
52
|
withUrlParams: Se = !1,
|
|
53
53
|
onLoadNewPage: $
|
|
54
54
|
}) => {
|
|
55
|
-
const J =
|
|
55
|
+
const J = Pe(), t = ze(), H = Ge(), I = Ue(), { isMobile: K, isTablet: ye, isDesktop: j } = Ve(), [b, u] = m(!1), [we, Ne] = m(!1), [k, S] = Xe(n, []), [O, Me] = m(
|
|
56
56
|
k?.length || 0
|
|
57
|
-
), [E,
|
|
57
|
+
), [E, B] = m(M || 1), [y, L] = 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
|
-
}, [F, T] = m(be()), [Q, x] = m(ke()), te =
|
|
63
|
-
M && M !== E &&
|
|
64
|
-
if (r.get("tagId") && q(Number.parseInt(r.get("tagId"))), r.get("search") &&
|
|
62
|
+
}, [F, T] = m(be()), [Q, x] = m(ke()), te = Be(o);
|
|
63
|
+
M && M !== E && B(M), w !== void 0 && w !== y && L(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
|
+
if (r.get("tagId") && q(Number.parseInt(r.get("tagId"))), r.get("search") && L(r.get("search")), r.get("sort")) {
|
|
65
65
|
T(r.get("sort"));
|
|
66
66
|
for (const e of r.values()) {
|
|
67
67
|
i?.map((s) => {
|
|
@@ -80,7 +80,7 @@ const rt = ({
|
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
}, [I.search]), h(() => {
|
|
83
|
-
_ ? (
|
|
83
|
+
_ ? (B(1), S([]), u(!0), se(1)) : u(!1);
|
|
84
84
|
}, [
|
|
85
85
|
F,
|
|
86
86
|
Q,
|
|
@@ -97,7 +97,7 @@ const rt = ({
|
|
|
97
97
|
delete e[n], t.setAddElements(e);
|
|
98
98
|
}
|
|
99
99
|
}, [t.addElements]), h(() => {
|
|
100
|
-
if (t.updateElements && n in t.updateElements && t.updateElements[n].length > 0) {
|
|
100
|
+
if (t.updateElements && n in t.updateElements && (console.log("[PaginatedList] update received for listId:", n, t.updateElements[n]), 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);
|
|
@@ -115,7 +115,7 @@ const rt = ({
|
|
|
115
115
|
[e.name]: e.value
|
|
116
116
|
})) : (T(e.value), x(o ? { ...o } : {}));
|
|
117
117
|
}, Fe = () => {
|
|
118
|
-
typeof $ == "function" && $() !== null ||
|
|
118
|
+
typeof $ == "function" && $() !== null || B(E + 1);
|
|
119
119
|
}, se = (e) => {
|
|
120
120
|
const s = ae ? H.getListWithToken : H.getList;
|
|
121
121
|
if ((e - 1) * p <= (Z || O) || e === 1) {
|
|
@@ -132,9 +132,9 @@ const rt = ({
|
|
|
132
132
|
const f = l.headers;
|
|
133
133
|
f && D in f && (Me(
|
|
134
134
|
Number.parseInt(f[D || "total"], 10)
|
|
135
|
-
),
|
|
135
|
+
), U && U(f[D || "total"]));
|
|
136
136
|
let g = l?.data?.data;
|
|
137
|
-
R && R(g),
|
|
137
|
+
R && R(g), W && (g = g.filter(W)), 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
139
|
console.error(l), l?.response?.status !== 404 && Ne(!0), u(!1);
|
|
140
140
|
});
|
|
@@ -174,7 +174,7 @@ const rt = ({
|
|
|
174
174
|
}) })
|
|
175
175
|
},
|
|
176
176
|
e[v || "id"]
|
|
177
|
-
) : null, Je = (e) =>
|
|
177
|
+
) : null, Je = (e) => z ? /* @__PURE__ */ c("li", { className: a.paginatedListItem, children: z }, e) : null;
|
|
178
178
|
if (we)
|
|
179
179
|
throw new Error(
|
|
180
180
|
J.formatMessage({
|
|
@@ -182,9 +182,9 @@ const rt = ({
|
|
|
182
182
|
defaultMessage: "Error when loading content."
|
|
183
183
|
})
|
|
184
184
|
);
|
|
185
|
-
return /* @__PURE__ */
|
|
185
|
+
return /* @__PURE__ */ P("div", { className: a.listContainer, children: [
|
|
186
186
|
/* @__PURE__ */ c(
|
|
187
|
-
|
|
187
|
+
We,
|
|
188
188
|
{
|
|
189
189
|
title: ue,
|
|
190
190
|
sortOptions: i,
|
|
@@ -192,28 +192,28 @@ const rt = ({
|
|
|
192
192
|
searchBar: ce,
|
|
193
193
|
tagList: ne,
|
|
194
194
|
activeTagId: C,
|
|
195
|
-
onSearch: (e) =>
|
|
195
|
+
onSearch: (e) => L(e),
|
|
196
196
|
onSortChange: Ce,
|
|
197
197
|
onTagChange: (e) => q(e),
|
|
198
198
|
withUrlParams: Se
|
|
199
199
|
}
|
|
200
200
|
),
|
|
201
|
-
!b && k.length === 0 ?
|
|
201
|
+
!b && k.length === 0 ? G ? /* @__PURE__ */ c("div", { className: a.emptyListElement, children: G }) : /* @__PURE__ */ c("div", { className: a.emptyList, children: V || J.formatMessage({
|
|
202
202
|
id: "info.emptyList",
|
|
203
203
|
defaultMessage: "No items for now."
|
|
204
|
-
}) }) : /* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */
|
|
204
|
+
}) }) : /* @__PURE__ */ P(je, { children: [
|
|
205
|
+
/* @__PURE__ */ P(
|
|
206
206
|
"ul",
|
|
207
207
|
{
|
|
208
|
-
className:
|
|
209
|
-
[a.paginatedListIsTablet]: !K && !
|
|
208
|
+
className: Le(a.paginatedList, {
|
|
209
|
+
[a.paginatedListIsTablet]: !K && !j,
|
|
210
210
|
[a.centeredList]: X === "column",
|
|
211
211
|
[a.column]: X === "column",
|
|
212
212
|
[a.twoElementsPerLine]: Y === 2,
|
|
213
213
|
[a.oneElementPerLine]: Y === 1,
|
|
214
214
|
[a.indexLayoutList]: Ee,
|
|
215
|
-
[a.listIsDesktop]:
|
|
216
|
-
[a.listIsTablet]: ye && !
|
|
215
|
+
[a.listIsDesktop]: j,
|
|
216
|
+
[a.listIsTablet]: ye && !j,
|
|
217
217
|
[a.listIsMobile]: K
|
|
218
218
|
}),
|
|
219
219
|
style: { gap: ge },
|