@logora/debate 0.3.57 → 0.3.59
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,7 +1,7 @@
|
|
|
1
1
|
import { jsxs as _, jsx as o } from "react/jsx-runtime";
|
|
2
2
|
import $e from "@rooks/use-sessionstorage-state";
|
|
3
3
|
import { useRef as qe, useState as c, useEffect as M, Suspense as De, lazy as We } from "react";
|
|
4
|
-
import { useIntl as Ye, FormattedMessage as
|
|
4
|
+
import { useIntl as Ye, FormattedMessage as me } from "react-intl";
|
|
5
5
|
import { useLocation as ke } from "react-router";
|
|
6
6
|
import I from "classnames";
|
|
7
7
|
import n from "./ArgumentInput.module.scss.js";
|
|
@@ -22,39 +22,39 @@ import { TextEditor as nt } from "../text_editor/TextEditor.js";
|
|
|
22
22
|
import { Icon as at } from "../../icons/icon/Icon.js";
|
|
23
23
|
const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ default: v.SideModal }))), Nt = ({
|
|
24
24
|
argumentListId: v,
|
|
25
|
-
avatarSize:
|
|
25
|
+
avatarSize: ge = 48,
|
|
26
26
|
disabled: z = !1,
|
|
27
27
|
positions: a = [],
|
|
28
28
|
disabledPositions: S = [],
|
|
29
29
|
groupId: A,
|
|
30
|
-
groupName:
|
|
30
|
+
groupName: fe,
|
|
31
31
|
groupType: O,
|
|
32
|
-
hideSourceAction:
|
|
32
|
+
hideSourceAction: he = !1,
|
|
33
33
|
isReply: u = !1,
|
|
34
34
|
onSubmit: J,
|
|
35
35
|
parentId: F,
|
|
36
|
-
placeholder:
|
|
36
|
+
placeholder: pe,
|
|
37
37
|
positionId: b,
|
|
38
|
-
focusOnInit:
|
|
38
|
+
focusOnInit: _e = !1,
|
|
39
39
|
activeOnInit: P = !1,
|
|
40
40
|
userGuideUrl: K,
|
|
41
|
-
hideUserGuideLink:
|
|
42
|
-
hideCharCount:
|
|
43
|
-
disableAutoActivate:
|
|
41
|
+
hideUserGuideLink: Me = !1,
|
|
42
|
+
hideCharCount: ve = !1,
|
|
43
|
+
disableAutoActivate: Ae = !1
|
|
44
44
|
}) => {
|
|
45
45
|
const r = Ye(), G = Re(), x = je(), h = ze(), {
|
|
46
46
|
focus: H,
|
|
47
47
|
setFocus: N,
|
|
48
|
-
setReset:
|
|
48
|
+
setReset: be,
|
|
49
49
|
inputContent: B,
|
|
50
|
-
setInputContent:
|
|
50
|
+
setInputContent: Q,
|
|
51
51
|
setInputRichContent: Ce
|
|
52
|
-
} = Oe(), { isLoggedIn: C, currentUser: d } = Je(), { errors: E, validate: V } = Ke(), { isMobile: m } = Ge(), we = ke(),
|
|
52
|
+
} = Oe(), { isLoggedIn: C, currentUser: d } = Je(), { errors: E, validate: V } = Ke(), { isMobile: m } = Ge(), we = ke(), X = qe(null), [U, $] = c([]), [q, D] = c(""), [Z, W] = c(null), [l, p] = c(null), [ee, te] = c(null), [ne, ae] = c(!1), [w, oe] = c(!1), [y, ie] = c({}), [g, Ie] = $e(
|
|
53
53
|
"userSide",
|
|
54
54
|
{}
|
|
55
55
|
), [f, Se] = c(
|
|
56
56
|
!C && h?.actions?.disableInputForVisitor
|
|
57
|
-
), Y = He(), { showModal: xe } = Qe(), { toast: k } = Xe() || {},
|
|
57
|
+
), Y = He(), { showModal: xe } = Qe(), { toast: k } = Xe() || {}, se = new URLSearchParams(
|
|
58
58
|
typeof window < "u" ? window.location.search : we.search
|
|
59
59
|
);
|
|
60
60
|
M(() => {
|
|
@@ -62,30 +62,30 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
62
62
|
!C && h?.actions?.disableInputForVisitor
|
|
63
63
|
);
|
|
64
64
|
}, [C, h]);
|
|
65
|
-
const R = d?.role === "editor" || d?.role === "moderator",
|
|
65
|
+
const R = d?.role === "editor" || d?.role === "moderator", re = d?.moderation_status === "banned";
|
|
66
66
|
M(() => {
|
|
67
67
|
let e = null;
|
|
68
|
-
typeof window < "u" && (e =
|
|
68
|
+
typeof window < "u" && (e = se.get("positionId")), b && b != a[2]?.id && a?.find((t) => t.id === b) ? p(b) : e && e != a[2]?.id ? p(e) : g && g.groupId == A && g.positionId != a[2]?.id && p(g.positionId);
|
|
69
69
|
}, [b]), M(() => {
|
|
70
70
|
P && (j(), N(!0));
|
|
71
71
|
}, [P]), M(() => {
|
|
72
72
|
if (typeof window < "u") {
|
|
73
|
-
const e =
|
|
73
|
+
const e = _e || se.get("initArgument");
|
|
74
74
|
(e === !0 || e === "true") && (N(!0), Ee());
|
|
75
75
|
}
|
|
76
76
|
}, []), M(() => {
|
|
77
|
-
H && (
|
|
77
|
+
H && (ue(), N(!1));
|
|
78
78
|
}, [H]), M(() => {
|
|
79
79
|
B?.id && (Ne(B), N(!0));
|
|
80
80
|
}, [B]);
|
|
81
81
|
const Ne = (e) => {
|
|
82
|
-
|
|
83
|
-
}, re = () => {
|
|
84
|
-
Q.current.scrollIntoView(!1);
|
|
82
|
+
ie(e), oe(!0), $(e.sources), D(e.content), W(e.rich_content), te(e.id), ue(), p(e.position?.id), JSON.parse(e.rich_content).hasOwnProperty("root") ? Ce(e.rich_content) : Q(e.content);
|
|
85
83
|
}, ue = () => {
|
|
86
|
-
|
|
84
|
+
X.current.scrollIntoView(!1);
|
|
85
|
+
}, de = () => {
|
|
86
|
+
D(""), W(null), ie({}), te(null), $([]), be(!0), Q(null);
|
|
87
87
|
}, ye = (e) => {
|
|
88
|
-
p(e),
|
|
88
|
+
p(e), ce(e);
|
|
89
89
|
}, Te = () => {
|
|
90
90
|
xe(
|
|
91
91
|
/* @__PURE__ */ o(De, { fallback: null, children: /* @__PURE__ */ o(
|
|
@@ -97,27 +97,27 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
97
97
|
}),
|
|
98
98
|
onChooseSide: ye,
|
|
99
99
|
positions: a,
|
|
100
|
-
title:
|
|
100
|
+
title: fe,
|
|
101
101
|
disabledPositions: !u && S,
|
|
102
102
|
isNeutral: g && g.groupId == A && g.positionId === a[2]?.id
|
|
103
103
|
}
|
|
104
104
|
) })
|
|
105
105
|
);
|
|
106
106
|
}, Le = () => {
|
|
107
|
-
C ?
|
|
107
|
+
C ? ee ? Be() : !a || a?.length === 0 || !S?.find((e) => e?.id === l) && l || R && u ? ce(u && R && a[0]?.id) : Te() : Y({ loginAction: "argument" });
|
|
108
108
|
}, Fe = (e, t) => {
|
|
109
109
|
f ? Y({ loginAction: "argument" }) : (D(e), W(t), V({ content: e }, [{ content: ["url", null] }]));
|
|
110
110
|
}, Pe = (e) => {
|
|
111
111
|
$(e);
|
|
112
|
-
},
|
|
112
|
+
}, le = [
|
|
113
113
|
{ content: ["length", 3] },
|
|
114
114
|
{ content: ["required", null] },
|
|
115
115
|
{ content: ["url", null] },
|
|
116
116
|
...!a || a?.length === 0 ? [] : [{ position_id: ["required", null] }]
|
|
117
|
-
],
|
|
117
|
+
], ce = (e) => {
|
|
118
118
|
const t = e || l, s = {
|
|
119
119
|
content: q,
|
|
120
|
-
rich_content:
|
|
120
|
+
rich_content: Z,
|
|
121
121
|
group_id: A,
|
|
122
122
|
...O && { group_type: O },
|
|
123
123
|
...t && { position_id: t },
|
|
@@ -125,10 +125,10 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
125
125
|
message_id: F || null,
|
|
126
126
|
source_ids: U?.map((i) => i.id)
|
|
127
127
|
};
|
|
128
|
-
V(s,
|
|
128
|
+
V(s, le) && (t && a && a.map((i) => i.id).includes(t) && Ie({
|
|
129
129
|
groupId: A,
|
|
130
130
|
positionId: t
|
|
131
|
-
}),
|
|
131
|
+
}), de(), G.create("messages", s).then((i) => {
|
|
132
132
|
if (i.data.success) {
|
|
133
133
|
if (F)
|
|
134
134
|
J(i.data.data.resource), k(
|
|
@@ -178,11 +178,11 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
178
178
|
}, Be = () => {
|
|
179
179
|
const e = {
|
|
180
180
|
content: q,
|
|
181
|
-
rich_content:
|
|
181
|
+
rich_content: Z,
|
|
182
182
|
source_ids: U?.map((t) => t.id),
|
|
183
183
|
...l && { position_id: l }
|
|
184
184
|
};
|
|
185
|
-
V(e,
|
|
185
|
+
V(e, le) && G.update("messages", ee, e).then((t) => {
|
|
186
186
|
if (t.data.success) {
|
|
187
187
|
const s = t.data.data.resource;
|
|
188
188
|
console.log("[updateArgument] réponse API:", s), console.log("[updateArgument] editElement:", y), console.log("[updateArgument] argumentListId prop:", v);
|
|
@@ -194,19 +194,19 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
194
194
|
x.update(i, [s]);
|
|
195
195
|
k(r.formatMessage({ id: "alert.argument_modify" }), {
|
|
196
196
|
type: "success"
|
|
197
|
-
}),
|
|
197
|
+
}), de();
|
|
198
198
|
}
|
|
199
199
|
});
|
|
200
200
|
}, Ee = () => {
|
|
201
|
-
if (!
|
|
202
|
-
|
|
201
|
+
if (!ne) {
|
|
202
|
+
ae(!0);
|
|
203
203
|
const e = setTimeout(() => {
|
|
204
|
-
|
|
204
|
+
ae(!1);
|
|
205
205
|
}, 2e3);
|
|
206
206
|
return () => clearTimeout(e);
|
|
207
207
|
}
|
|
208
208
|
}, j = () => {
|
|
209
|
-
f ? Y({ loginAction: "argument" }) :
|
|
209
|
+
f ? Y({ loginAction: "argument" }) : oe(!0);
|
|
210
210
|
}, Ve = () => {
|
|
211
211
|
const e = S.find(
|
|
212
212
|
(t) => t.id === l
|
|
@@ -221,7 +221,7 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
221
221
|
);
|
|
222
222
|
};
|
|
223
223
|
return /* @__PURE__ */ _("div", { className: n.inputContainer, children: [
|
|
224
|
-
z && /* @__PURE__ */ o("div", { className: n.disabledInputMask, children:
|
|
224
|
+
z && /* @__PURE__ */ o("div", { className: n.disabledInputMask, children: re ? r.formatMessage({
|
|
225
225
|
id: "input.argument_input.user_banned",
|
|
226
226
|
defaultMessage: "You are banned from the debate space."
|
|
227
227
|
}) : r.formatMessage({
|
|
@@ -232,10 +232,10 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
232
232
|
"div",
|
|
233
233
|
{
|
|
234
234
|
className: I(n.argumentInput, {
|
|
235
|
-
[n.flash]:
|
|
235
|
+
[n.flash]: ne,
|
|
236
236
|
[n.replyInputContainer]: u
|
|
237
237
|
}),
|
|
238
|
-
children: /* @__PURE__ */ o("div", { "data-tid": "action_add_argument", ref:
|
|
238
|
+
children: /* @__PURE__ */ o("div", { "data-tid": "action_add_argument", ref: X, children: /* @__PURE__ */ _("div", { className: n.argumentInputBox, children: [
|
|
239
239
|
a.length > 0 && C && (!u || !R) && /* @__PURE__ */ _("div", { className: n.userPosition, children: [
|
|
240
240
|
/* @__PURE__ */ o("div", { children: r.formatMessage({
|
|
241
241
|
id: "input.position",
|
|
@@ -271,7 +271,7 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
271
271
|
{
|
|
272
272
|
avatarUrl: d.image_url,
|
|
273
273
|
userName: d.full_name,
|
|
274
|
-
size:
|
|
274
|
+
size: ge
|
|
275
275
|
}
|
|
276
276
|
) : /* @__PURE__ */ o(
|
|
277
277
|
tt,
|
|
@@ -302,26 +302,26 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
302
302
|
handleSourcesChange: (e) => {
|
|
303
303
|
Pe(e);
|
|
304
304
|
},
|
|
305
|
-
placeholder:
|
|
305
|
+
placeholder: pe,
|
|
306
306
|
"aria-label": r.formatMessage({
|
|
307
307
|
id: "input.argument_input.aria_label",
|
|
308
308
|
defaultMessage: "Message input field"
|
|
309
309
|
}),
|
|
310
310
|
onSubmit: Le,
|
|
311
311
|
sources: U,
|
|
312
|
-
hideSourceAction:
|
|
312
|
+
hideSourceAction: he || f,
|
|
313
313
|
uid: `Argument${A}`,
|
|
314
314
|
onActivation: j,
|
|
315
315
|
showStylesControls: w,
|
|
316
|
-
disabled: z || f ||
|
|
316
|
+
disabled: z || f || re,
|
|
317
317
|
maxLength: f ? !1 : h?.actions?.argumentMaxLength,
|
|
318
318
|
disableRichText: h?.actions?.disableRichText || f,
|
|
319
319
|
shortBar: u,
|
|
320
320
|
hideSubmit: f,
|
|
321
321
|
allowedDomains: h?.allowed_sources,
|
|
322
322
|
active: P,
|
|
323
|
-
hideCharCount:
|
|
324
|
-
disableAutoActivate:
|
|
323
|
+
hideCharCount: ve,
|
|
324
|
+
disableAutoActivate: Ae
|
|
325
325
|
}
|
|
326
326
|
),
|
|
327
327
|
E?.content && /* @__PURE__ */ o("div", { className: n.argumentInputWarning, children: E && Object.values(E).map((e, t) => /* @__PURE__ */ o("div", { children: e }, t)) }),
|
|
@@ -348,8 +348,8 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
348
348
|
]
|
|
349
349
|
}
|
|
350
350
|
),
|
|
351
|
-
w && K && !
|
|
352
|
-
|
|
351
|
+
w && K && !Me && /* @__PURE__ */ o("div", { className: n.guideMessage, children: /* @__PURE__ */ o(
|
|
352
|
+
me,
|
|
353
353
|
{
|
|
354
354
|
id: "alert.guide_message",
|
|
355
355
|
defaultMessage: "Contributions must comply with our {userCharter}.",
|
|
@@ -362,7 +362,7 @@ const ot = We(() => import("../../modal/side_modal/index.js").then((v) => ({ def
|
|
|
362
362
|
target: "_blank",
|
|
363
363
|
rel: "noreferrer",
|
|
364
364
|
children: /* @__PURE__ */ o(
|
|
365
|
-
|
|
365
|
+
me,
|
|
366
366
|
{
|
|
367
367
|
id: "alert.user_charter",
|
|
368
368
|
defaultMessage: "user charter"
|
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import { jsxs as
|
|
1
|
+
import { jsxs as $, jsx as c, Fragment as je } from "react/jsx-runtime";
|
|
2
2
|
import Be from "@rooks/use-previous";
|
|
3
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 $e } from "react-intl";
|
|
6
|
+
import { useLocation as Pe } from "react-router";
|
|
7
7
|
import a from "./PaginatedList.module.scss.js";
|
|
8
|
-
import { ActionBar as
|
|
9
|
-
import { useList as
|
|
10
|
-
import { useDataProvider as
|
|
11
|
-
import { useResponsive as
|
|
12
|
-
import { useData as
|
|
13
|
-
import { uniqueBy as
|
|
14
|
-
import { Pagination as
|
|
15
|
-
import { StandardErrorBoundary as
|
|
16
|
-
const
|
|
8
|
+
import { ActionBar as Ue } from "./action_bar/ActionBar.js";
|
|
9
|
+
import { useList as We } from "../list_provider/useList.js";
|
|
10
|
+
import { useDataProvider as ze } from "../../data/data_provider/useDataProvider.js";
|
|
11
|
+
import { useResponsive as Ge } from "../../hooks/use_responsive/useResponsive.js";
|
|
12
|
+
import { useData as Ve } from "../../data/data_provider/useData.js";
|
|
13
|
+
import { uniqueBy as x } from "../../util/unique_by/uniqueBy.js";
|
|
14
|
+
import { Pagination as Xe } from "../pagination/Pagination.js";
|
|
15
|
+
import { StandardErrorBoundary as Ye } from "../../error/standard_error_boundary/StandardErrorBoundary.js";
|
|
16
|
+
const dt = ({
|
|
17
17
|
query: w,
|
|
18
18
|
sortOptions: i,
|
|
19
19
|
sort: N,
|
|
20
20
|
filters: o,
|
|
21
21
|
tagList: ne,
|
|
22
22
|
currentPage: M,
|
|
23
|
-
resource:
|
|
23
|
+
resource: A,
|
|
24
24
|
currentListId: n,
|
|
25
25
|
withToken: ae,
|
|
26
26
|
perPage: p,
|
|
@@ -28,51 +28,51 @@ const rt = ({
|
|
|
28
28
|
pageParam: ie = "page",
|
|
29
29
|
sortParam: oe = "sort",
|
|
30
30
|
queryParam: me = "query",
|
|
31
|
-
tagParam:
|
|
31
|
+
tagParam: de = "tag_id",
|
|
32
32
|
totalHeaderParam: D = "total",
|
|
33
|
-
onUpdateTotal:
|
|
33
|
+
onUpdateTotal: P,
|
|
34
34
|
onElementsLoad: R,
|
|
35
|
-
transformData:
|
|
35
|
+
transformData: U,
|
|
36
36
|
uniqueIdKey: v = "id",
|
|
37
|
-
children:
|
|
37
|
+
children: re,
|
|
38
38
|
resourcePropName: fe,
|
|
39
|
-
loadingComponent:
|
|
39
|
+
loadingComponent: W,
|
|
40
40
|
searchBar: ce = !1,
|
|
41
41
|
title: ue,
|
|
42
|
-
emptyListComponent:
|
|
43
|
-
emptyText:
|
|
44
|
-
display:
|
|
45
|
-
elementsPerLine:
|
|
42
|
+
emptyListComponent: z,
|
|
43
|
+
emptyText: G,
|
|
44
|
+
display: V,
|
|
45
|
+
elementsPerLine: X,
|
|
46
46
|
indexLayout: Ee = !1,
|
|
47
47
|
gap: ge = "1em",
|
|
48
48
|
withPagination: he = !0,
|
|
49
|
-
numberElements:
|
|
49
|
+
numberElements: Y,
|
|
50
50
|
countless: pe,
|
|
51
51
|
onElementClick: ve,
|
|
52
52
|
withUrlParams: Se = !1,
|
|
53
|
-
onLoadNewPage:
|
|
53
|
+
onLoadNewPage: Z
|
|
54
54
|
}) => {
|
|
55
|
-
const J =
|
|
55
|
+
const J = $e(), t = We(), H = ze(), I = Pe(), { isMobile: K, isTablet: ye, isDesktop: j } = Ge(), [b, u] = m(!1), [we, Ne] = m(!1), [k, S] = Ve(n, []), [O, Me] = m(
|
|
56
56
|
k?.length || 0
|
|
57
|
-
), [E, B] = m(M || 1), [y, L] = m(w || null), [C, q] = m(null), [Re, ee] = m(null),
|
|
57
|
+
), [E, B] = m(M || 1), [y, L] = m(w || null), [C, q] = m(null), [Re, ee] = m(null), d = 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,
|
|
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) &&
|
|
64
|
-
if (
|
|
65
|
-
T(
|
|
66
|
-
for (const e of
|
|
62
|
+
}, [F, T] = m(be()), [Q, _] = 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) && _(o), h(() => {
|
|
64
|
+
if (d.get("tagId") && q(Number.parseInt(d.get("tagId"))), d.get("search") && L(d.get("search")), d.get("sort")) {
|
|
65
|
+
T(d.get("sort"));
|
|
66
|
+
for (const e of d.values()) {
|
|
67
67
|
i?.map((s) => {
|
|
68
68
|
s.value === e && ee(s.name);
|
|
69
69
|
});
|
|
70
70
|
break;
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
for (const e of
|
|
73
|
+
for (const e of d.keys()) {
|
|
74
74
|
i?.map((s) => {
|
|
75
|
-
s.name === e && (
|
|
75
|
+
s.name === e && (_({
|
|
76
76
|
...o,
|
|
77
77
|
[s.name]: s.value
|
|
78
78
|
}), ee(s.name));
|
|
@@ -80,12 +80,12 @@ const rt = ({
|
|
|
80
80
|
break;
|
|
81
81
|
}
|
|
82
82
|
}, [I.search]), h(() => {
|
|
83
|
-
|
|
83
|
+
A ? (B(1), S([]), u(!0), se(1)) : u(!1);
|
|
84
84
|
}, [
|
|
85
85
|
F,
|
|
86
86
|
Q,
|
|
87
87
|
y,
|
|
88
|
-
|
|
88
|
+
A,
|
|
89
89
|
C,
|
|
90
90
|
p
|
|
91
91
|
]), h(() => {
|
|
@@ -98,43 +98,43 @@ const rt = ({
|
|
|
98
98
|
}
|
|
99
99
|
}, [t.addElements]), h(() => {
|
|
100
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
|
+
_e(t.updateElements[n]);
|
|
102
102
|
const e = t.updateElements;
|
|
103
103
|
delete e[n], t.setUpdateElements(e);
|
|
104
104
|
}
|
|
105
105
|
}, [t.updateElements]), h(() => {
|
|
106
106
|
if (t.removeElements && n in t.removeElements && t.removeElements[n].length > 0) {
|
|
107
|
-
|
|
107
|
+
xe(t.removeElements[n]);
|
|
108
108
|
const e = t.removeElements;
|
|
109
109
|
delete e[n], t.setRemoveElements(e);
|
|
110
110
|
}
|
|
111
111
|
}, [t.removeElements]);
|
|
112
112
|
const Ce = (e) => {
|
|
113
|
-
e.type === "filter" ? (T(""),
|
|
113
|
+
e.type === "filter" ? (T(""), _({
|
|
114
114
|
...o,
|
|
115
115
|
[e.name]: e.value
|
|
116
|
-
})) : (T(e.value),
|
|
116
|
+
})) : (T(e.value), _(o ? { ...o } : {}));
|
|
117
117
|
}, Fe = () => {
|
|
118
|
-
typeof
|
|
118
|
+
typeof Z == "function" && Z() !== null || B(E + 1);
|
|
119
119
|
}, se = (e) => {
|
|
120
120
|
const s = ae ? H.getListWithToken : H.getList;
|
|
121
|
-
if ((e - 1) * p <= (
|
|
122
|
-
const
|
|
121
|
+
if ((e - 1) * p <= (Y || O) || e === 1) {
|
|
122
|
+
const r = {
|
|
123
123
|
[ie]: e,
|
|
124
124
|
[le]: p,
|
|
125
125
|
...F && !y && { [oe]: F },
|
|
126
126
|
...y && { [me]: y },
|
|
127
127
|
...pe === !0 && { countless: !0 },
|
|
128
128
|
...Q,
|
|
129
|
-
...C && { [
|
|
129
|
+
...C && { [de]: C }
|
|
130
130
|
};
|
|
131
|
-
s(
|
|
131
|
+
s(A, r).then((l) => {
|
|
132
132
|
const f = l.headers;
|
|
133
133
|
f && D in f && (Me(
|
|
134
134
|
Number.parseInt(f[D || "total"], 10)
|
|
135
|
-
),
|
|
135
|
+
), P && P(f[D || "total"]));
|
|
136
136
|
let g = l?.data?.data;
|
|
137
|
-
R && R(g),
|
|
137
|
+
R && R(g), U && (g = g.filter(U)), t.addElements && n in t.addElements && t.addElements[n].length > 0 && (g = [...t.addElements[n], g]), Ae(g), u(!1);
|
|
138
138
|
}).catch((l) => {
|
|
139
139
|
console.error(l), l?.response?.status !== 404 && Ne(!0), u(!1);
|
|
140
140
|
});
|
|
@@ -142,25 +142,25 @@ const rt = ({
|
|
|
142
142
|
u(!1);
|
|
143
143
|
}, Te = (e) => {
|
|
144
144
|
S(
|
|
145
|
-
(s) =>
|
|
145
|
+
(s) => x([...e, ...s], v || "id")
|
|
146
146
|
), R && R(e);
|
|
147
|
-
},
|
|
147
|
+
}, _e = (e) => {
|
|
148
148
|
S((s) => {
|
|
149
|
-
let
|
|
149
|
+
let r = s;
|
|
150
150
|
return e.forEach(
|
|
151
|
-
(l) =>
|
|
151
|
+
(l) => r = r.map(
|
|
152
152
|
(f) => f.id === l.id ? l : f
|
|
153
153
|
)
|
|
154
|
-
),
|
|
154
|
+
), x(r, v || "id");
|
|
155
155
|
});
|
|
156
|
-
},
|
|
157
|
-
const s = e.map((l) => l.id),
|
|
156
|
+
}, xe = (e) => {
|
|
157
|
+
const s = e.map((l) => l.id), r = k.filter(
|
|
158
158
|
(l) => s.indexOf(l.id) === -1
|
|
159
159
|
);
|
|
160
|
-
S(
|
|
161
|
-
},
|
|
160
|
+
S(x(r, v || "id"));
|
|
161
|
+
}, Ae = (e) => {
|
|
162
162
|
S(
|
|
163
|
-
(s) =>
|
|
163
|
+
(s) => x([...s, ...e], v || "id")
|
|
164
164
|
);
|
|
165
165
|
}, De = (e, s) => e !== void 0 ? /* @__PURE__ */ c(
|
|
166
166
|
"li",
|
|
@@ -168,13 +168,13 @@ const rt = ({
|
|
|
168
168
|
className: a.paginatedListItem,
|
|
169
169
|
"data-testid": "list-item",
|
|
170
170
|
onClick: ve,
|
|
171
|
-
children: /* @__PURE__ */ c(
|
|
171
|
+
children: /* @__PURE__ */ c(Ye, { hideMessage: !0, children: Qe.cloneElement(re, {
|
|
172
172
|
index: s,
|
|
173
173
|
[fe]: e
|
|
174
174
|
}) })
|
|
175
175
|
},
|
|
176
|
-
e[v || "id"]
|
|
177
|
-
) : null, Je = (e) =>
|
|
176
|
+
`${e[v || "id"]}_${e.updated_at || e.content}`
|
|
177
|
+
) : null, Je = (e) => W ? /* @__PURE__ */ c("li", { className: a.paginatedListItem, children: W }, 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__ */ $("div", { className: a.listContainer, children: [
|
|
186
186
|
/* @__PURE__ */ c(
|
|
187
|
-
|
|
187
|
+
Ue,
|
|
188
188
|
{
|
|
189
189
|
title: ue,
|
|
190
190
|
sortOptions: i,
|
|
@@ -198,19 +198,19 @@ const rt = ({
|
|
|
198
198
|
withUrlParams: Se
|
|
199
199
|
}
|
|
200
200
|
),
|
|
201
|
-
!b && k.length === 0 ?
|
|
201
|
+
!b && k.length === 0 ? z ? /* @__PURE__ */ c("div", { className: a.emptyListElement, children: z }) : /* @__PURE__ */ c("div", { className: a.emptyList, children: G || J.formatMessage({
|
|
202
202
|
id: "info.emptyList",
|
|
203
203
|
defaultMessage: "No items for now."
|
|
204
|
-
}) }) : /* @__PURE__ */
|
|
205
|
-
/* @__PURE__ */
|
|
204
|
+
}) }) : /* @__PURE__ */ $(je, { children: [
|
|
205
|
+
/* @__PURE__ */ $(
|
|
206
206
|
"ul",
|
|
207
207
|
{
|
|
208
208
|
className: Le(a.paginatedList, {
|
|
209
209
|
[a.paginatedListIsTablet]: !K && !j,
|
|
210
|
-
[a.centeredList]:
|
|
211
|
-
[a.column]:
|
|
212
|
-
[a.twoElementsPerLine]:
|
|
213
|
-
[a.oneElementPerLine]:
|
|
210
|
+
[a.centeredList]: V === "column",
|
|
211
|
+
[a.column]: V === "column",
|
|
212
|
+
[a.twoElementsPerLine]: X === 2,
|
|
213
|
+
[a.oneElementPerLine]: X === 1,
|
|
214
214
|
[a.indexLayoutList]: Ee,
|
|
215
215
|
[a.listIsDesktop]: j,
|
|
216
216
|
[a.listIsTablet]: ye && !j,
|
|
@@ -224,7 +224,7 @@ const rt = ({
|
|
|
224
224
|
}
|
|
225
225
|
),
|
|
226
226
|
!b && he !== !1 && /* @__PURE__ */ c(
|
|
227
|
-
|
|
227
|
+
Xe,
|
|
228
228
|
{
|
|
229
229
|
buttonText: J.formatMessage({
|
|
230
230
|
id: "action.see_more",
|
|
@@ -232,7 +232,7 @@ const rt = ({
|
|
|
232
232
|
}),
|
|
233
233
|
currentPage: E,
|
|
234
234
|
perPage: p,
|
|
235
|
-
totalElements:
|
|
235
|
+
totalElements: Y || O,
|
|
236
236
|
onLoad: Fe,
|
|
237
237
|
isLoading: b,
|
|
238
238
|
hideLoader: !0,
|
|
@@ -243,5 +243,5 @@ const rt = ({
|
|
|
243
243
|
] });
|
|
244
244
|
};
|
|
245
245
|
export {
|
|
246
|
-
|
|
246
|
+
dt as PaginatedList
|
|
247
247
|
};
|