@logora/debate 0.4.79 → 0.4.81
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,26 +1,26 @@
|
|
|
1
|
-
import { jsxs as U, jsx as
|
|
1
|
+
import { jsxs as U, jsx as u, Fragment as Qe } from "react/jsx-runtime";
|
|
2
2
|
import Ue from "@rooks/use-previous";
|
|
3
3
|
import $e from "classnames";
|
|
4
|
-
import
|
|
5
|
-
import { useIntl as
|
|
6
|
-
import { useLocation as
|
|
4
|
+
import Ie, { useState as c, useEffect as p } from "react";
|
|
5
|
+
import { useIntl as We } from "react-intl";
|
|
6
|
+
import { useLocation as ze } from "react-router";
|
|
7
7
|
import l 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
|
|
8
|
+
import { ActionBar as Ge } from "./action_bar/ActionBar.js";
|
|
9
|
+
import { useList as Pe } from "../list_provider/useList.js";
|
|
10
|
+
import { useDataProvider as Ve } from "../../data/data_provider/useDataProvider.js";
|
|
11
|
+
import { useResponsive as Xe } from "../../hooks/use_responsive/useResponsive.js";
|
|
12
|
+
import { useData as Ye } from "../../data/data_provider/useData.js";
|
|
13
13
|
import { uniqueBy as x } from "../../util/unique_by/uniqueBy.js";
|
|
14
|
-
import { Pagination as
|
|
15
|
-
import { StandardErrorBoundary as
|
|
14
|
+
import { Pagination as Ze } from "../pagination/Pagination.js";
|
|
15
|
+
import { StandardErrorBoundary as He } from "../../error/standard_error_boundary/StandardErrorBoundary.js";
|
|
16
16
|
const ct = ({
|
|
17
|
-
query:
|
|
17
|
+
query: b,
|
|
18
18
|
sortOptions: o,
|
|
19
|
-
sort:
|
|
19
|
+
sort: w,
|
|
20
20
|
filters: m,
|
|
21
21
|
tagList: ne,
|
|
22
22
|
pinnedTagList: ae,
|
|
23
|
-
currentPage:
|
|
23
|
+
currentPage: M,
|
|
24
24
|
resource: A,
|
|
25
25
|
currentListId: a,
|
|
26
26
|
withToken: le,
|
|
@@ -28,52 +28,52 @@ const ct = ({
|
|
|
28
28
|
perPageParam: ie = "per_page",
|
|
29
29
|
pageParam: oe = "page",
|
|
30
30
|
sortParam: me = "sort",
|
|
31
|
-
queryParam:
|
|
32
|
-
tagParam:
|
|
31
|
+
queryParam: re = "query",
|
|
32
|
+
tagParam: de = "tag_id",
|
|
33
33
|
totalHeaderParam: D = "total",
|
|
34
34
|
onUpdateTotal: $,
|
|
35
|
-
onElementsLoad:
|
|
36
|
-
transformData:
|
|
35
|
+
onElementsLoad: R,
|
|
36
|
+
transformData: I,
|
|
37
37
|
uniqueIdKey: S = "id",
|
|
38
38
|
children: fe,
|
|
39
39
|
resourcePropName: ce,
|
|
40
|
-
loadingComponent:
|
|
41
|
-
searchBar:
|
|
42
|
-
title:
|
|
40
|
+
loadingComponent: W,
|
|
41
|
+
searchBar: ge = !1,
|
|
42
|
+
title: ue,
|
|
43
43
|
subtitle: Ee,
|
|
44
44
|
showDebateConsultationSubtitle: he = !1,
|
|
45
|
-
emptyListComponent:
|
|
46
|
-
emptyText:
|
|
47
|
-
display:
|
|
48
|
-
elementsPerLine:
|
|
45
|
+
emptyListComponent: z,
|
|
46
|
+
emptyText: G,
|
|
47
|
+
display: P,
|
|
48
|
+
elementsPerLine: V,
|
|
49
49
|
indexLayout: pe = !1,
|
|
50
50
|
gap: ve = "1em",
|
|
51
51
|
withPagination: Se = !0,
|
|
52
|
-
numberElements:
|
|
52
|
+
numberElements: X,
|
|
53
53
|
countless: ye,
|
|
54
|
-
onElementClick:
|
|
55
|
-
withUrlParams:
|
|
56
|
-
onLoadNewPage:
|
|
54
|
+
onElementClick: Ne,
|
|
55
|
+
withUrlParams: be = !1,
|
|
56
|
+
onLoadNewPage: Y
|
|
57
57
|
}) => {
|
|
58
|
-
const J =
|
|
58
|
+
const J = We(), t = Pe(), Z = Ve(), H = ze(), { isMobile: K, isTablet: we, isDesktop: L } = Xe(), r = new URLSearchParams(H.search), [k, E] = c(!1), [Me, Re] = c(!1), [d, y] = Ye(a, []), [O, ke] = c(
|
|
59
59
|
d?.length || 0
|
|
60
|
-
), [h, j] =
|
|
61
|
-
|
|
62
|
-
), Te = () => o && o[0].type === "sort" && o[0].value ||
|
|
60
|
+
), [h, j] = c(M || 1), [N, B] = c(b || null), [C, q] = c(
|
|
61
|
+
r.get("tagId") ? Number.parseInt(r.get("tagId"), 10) : null
|
|
62
|
+
), [Ce, ee] = c(null), Te = () => o && o[0].type === "sort" && o[0].value || w || "", Fe = () => {
|
|
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] =
|
|
66
|
-
|
|
67
|
-
if (
|
|
68
|
-
F(
|
|
69
|
-
for (const e of
|
|
65
|
+
}, [T, F] = c(Te()), [Q, _] = c(Fe()), te = Ue(m);
|
|
66
|
+
M && M !== h && j(M), b !== void 0 && b !== N && B(b), w !== void 0 && w !== T && F(w), te && JSON.stringify(m) !== JSON.stringify(te) && JSON.stringify(m) !== JSON.stringify(Q) && _(m), p(() => {
|
|
67
|
+
if (r.get("tagId") && q(Number.parseInt(r.get("tagId"))), r.get("search") && B(r.get("search")), r.get("sort")) {
|
|
68
|
+
F(r.get("sort"));
|
|
69
|
+
for (const e of r.values()) {
|
|
70
70
|
o?.map((s) => {
|
|
71
71
|
s.value === e && ee(s.name);
|
|
72
72
|
});
|
|
73
73
|
break;
|
|
74
74
|
}
|
|
75
75
|
}
|
|
76
|
-
for (const e of
|
|
76
|
+
for (const e of r.keys()) {
|
|
77
77
|
o?.map((s) => {
|
|
78
78
|
s.name === e && (_({
|
|
79
79
|
...m,
|
|
@@ -82,12 +82,12 @@ const ct = ({
|
|
|
82
82
|
});
|
|
83
83
|
break;
|
|
84
84
|
}
|
|
85
|
-
}, [
|
|
85
|
+
}, [H.search]), p(() => {
|
|
86
86
|
A ? (j(1), y([]), E(!0), se(1)) : E(!1);
|
|
87
87
|
}, [
|
|
88
88
|
T,
|
|
89
89
|
Q,
|
|
90
|
-
|
|
90
|
+
N,
|
|
91
91
|
A,
|
|
92
92
|
C,
|
|
93
93
|
v
|
|
@@ -109,7 +109,7 @@ const ct = ({
|
|
|
109
109
|
if (s.length > 0) {
|
|
110
110
|
De(s);
|
|
111
111
|
const i = e.filter(
|
|
112
|
-
(
|
|
112
|
+
(f) => !d.some((g) => g.id === f.id)
|
|
113
113
|
), n = { ...t.updateElements };
|
|
114
114
|
i.length > 0 ? n[a] = i : delete n[a], t.setUpdateElements(n);
|
|
115
115
|
}
|
|
@@ -128,41 +128,41 @@ const ct = ({
|
|
|
128
128
|
[e.name]: e.value
|
|
129
129
|
})) : (F(e.value), _(m ? { ...m } : {}));
|
|
130
130
|
}, xe = () => {
|
|
131
|
-
typeof
|
|
131
|
+
typeof Y == "function" && Y() !== null || j(h + 1);
|
|
132
132
|
}, se = (e) => {
|
|
133
|
-
const s = le ?
|
|
134
|
-
if ((e - 1) * v <= (
|
|
133
|
+
const s = le ? Z.getListWithToken : Z.getList;
|
|
134
|
+
if ((e - 1) * v <= (X || O) || e === 1) {
|
|
135
135
|
const i = {
|
|
136
136
|
[oe]: e,
|
|
137
137
|
[ie]: v,
|
|
138
|
-
...T && !
|
|
139
|
-
...
|
|
138
|
+
...T && !N && { [me]: T },
|
|
139
|
+
...N && { [re]: N },
|
|
140
140
|
...ye === !0 && { countless: !0 },
|
|
141
141
|
...Q,
|
|
142
|
-
...C && { [
|
|
142
|
+
...C && { [de]: C }
|
|
143
143
|
};
|
|
144
144
|
s(A, i).then((n) => {
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
Number.parseInt(
|
|
148
|
-
), $ && $(
|
|
149
|
-
let
|
|
150
|
-
|
|
145
|
+
const f = n.headers;
|
|
146
|
+
f && D in f && (ke(
|
|
147
|
+
Number.parseInt(f[D || "total"], 10)
|
|
148
|
+
), $ && $(f[D || "total"]));
|
|
149
|
+
let g = n?.data?.data;
|
|
150
|
+
R && R(g), I && (g = g.filter(I)), t.addElements && a in t.addElements && t.addElements[a].length > 0 && (g = [...t.addElements[a], g]), Le(g), E(!1);
|
|
151
151
|
}).catch((n) => {
|
|
152
|
-
console.error(n), n?.response?.status !== 404 &&
|
|
152
|
+
console.error(n), n?.response?.status !== 404 && Re(!0), E(!1);
|
|
153
153
|
});
|
|
154
154
|
} else
|
|
155
155
|
E(!1);
|
|
156
156
|
}, Ae = (e) => {
|
|
157
157
|
y(
|
|
158
158
|
(s) => x([...e, ...s], S || "id")
|
|
159
|
-
),
|
|
159
|
+
), R && R(e);
|
|
160
160
|
}, De = (e) => {
|
|
161
161
|
y((s) => {
|
|
162
162
|
let i = s;
|
|
163
163
|
return e.forEach(
|
|
164
164
|
(n) => i = i.map(
|
|
165
|
-
(
|
|
165
|
+
(f) => f.id === n.id ? n : f
|
|
166
166
|
)
|
|
167
167
|
), x(i, S || "id");
|
|
168
168
|
});
|
|
@@ -175,20 +175,20 @@ const ct = ({
|
|
|
175
175
|
y(
|
|
176
176
|
(s) => x([...s, ...e], S || "id")
|
|
177
177
|
);
|
|
178
|
-
}, je = (e, s) => e !== void 0 ? /* @__PURE__ */
|
|
178
|
+
}, je = (e, s) => e !== void 0 ? /* @__PURE__ */ u(
|
|
179
179
|
"li",
|
|
180
180
|
{
|
|
181
181
|
className: l.paginatedListItem,
|
|
182
182
|
"data-testid": "list-item",
|
|
183
|
-
onClick:
|
|
184
|
-
children: /* @__PURE__ */
|
|
183
|
+
onClick: Ne,
|
|
184
|
+
children: /* @__PURE__ */ u(He, { hideMessage: !0, children: Ie.cloneElement(fe, {
|
|
185
185
|
index: s,
|
|
186
186
|
[ce]: e
|
|
187
187
|
}) })
|
|
188
188
|
},
|
|
189
189
|
`${e[S || "id"]}_${e.updated_at || e.content}`
|
|
190
|
-
) : null, Be = (e) =>
|
|
191
|
-
if (
|
|
190
|
+
) : null, Be = (e) => W ? /* @__PURE__ */ u("li", { className: l.paginatedListItem, children: W }, e) : null;
|
|
191
|
+
if (Me)
|
|
192
192
|
throw new Error(
|
|
193
193
|
J.formatMessage({
|
|
194
194
|
id: "error.list",
|
|
@@ -196,25 +196,25 @@ const ct = ({
|
|
|
196
196
|
})
|
|
197
197
|
);
|
|
198
198
|
return /* @__PURE__ */ U("div", { className: l.listContainer, children: [
|
|
199
|
-
/* @__PURE__ */
|
|
200
|
-
|
|
199
|
+
/* @__PURE__ */ u(
|
|
200
|
+
Ge,
|
|
201
201
|
{
|
|
202
|
-
title:
|
|
202
|
+
title: ue,
|
|
203
203
|
subtitle: Ee,
|
|
204
204
|
showDebateConsultationSubtitle: he,
|
|
205
205
|
sortOptions: o,
|
|
206
206
|
defaultSelectOption: Ce,
|
|
207
|
-
searchBar:
|
|
207
|
+
searchBar: ge,
|
|
208
208
|
tagList: ne,
|
|
209
209
|
pinnedTagList: ae,
|
|
210
210
|
activeTagId: C,
|
|
211
211
|
onSearch: (e) => B(e),
|
|
212
212
|
onSortChange: _e,
|
|
213
213
|
onTagChange: (e) => q(e),
|
|
214
|
-
withUrlParams:
|
|
214
|
+
withUrlParams: be
|
|
215
215
|
}
|
|
216
216
|
),
|
|
217
|
-
!k && d.length === 0 ?
|
|
217
|
+
!k && d.length === 0 ? z ? /* @__PURE__ */ u("div", { className: l.emptyListElement, children: z }) : /* @__PURE__ */ u("div", { className: l.emptyList, children: G || J.formatMessage({
|
|
218
218
|
id: "info.emptyList",
|
|
219
219
|
defaultMessage: "No items for now."
|
|
220
220
|
}) }) : /* @__PURE__ */ U(Qe, { children: [
|
|
@@ -223,13 +223,13 @@ const ct = ({
|
|
|
223
223
|
{
|
|
224
224
|
className: $e(l.paginatedList, {
|
|
225
225
|
[l.paginatedListIsTablet]: !K && !L,
|
|
226
|
-
[l.centeredList]:
|
|
227
|
-
[l.column]:
|
|
228
|
-
[l.twoElementsPerLine]:
|
|
229
|
-
[l.oneElementPerLine]:
|
|
226
|
+
[l.centeredList]: P === "column",
|
|
227
|
+
[l.column]: P === "column",
|
|
228
|
+
[l.twoElementsPerLine]: V === 2,
|
|
229
|
+
[l.oneElementPerLine]: V === 1,
|
|
230
230
|
[l.indexLayoutList]: pe,
|
|
231
231
|
[l.listIsDesktop]: L,
|
|
232
|
-
[l.listIsTablet]:
|
|
232
|
+
[l.listIsTablet]: we && !L,
|
|
233
233
|
[l.listIsMobile]: K
|
|
234
234
|
}),
|
|
235
235
|
style: { gap: ve },
|
|
@@ -239,8 +239,8 @@ const ct = ({
|
|
|
239
239
|
]
|
|
240
240
|
}
|
|
241
241
|
),
|
|
242
|
-
!k && Se !== !1 && /* @__PURE__ */
|
|
243
|
-
|
|
242
|
+
!k && Se !== !1 && /* @__PURE__ */ u(
|
|
243
|
+
Ze,
|
|
244
244
|
{
|
|
245
245
|
buttonText: J.formatMessage({
|
|
246
246
|
id: "action.see_more",
|
|
@@ -248,7 +248,7 @@ const ct = ({
|
|
|
248
248
|
}),
|
|
249
249
|
currentPage: h,
|
|
250
250
|
perPage: v,
|
|
251
|
-
totalElements:
|
|
251
|
+
totalElements: X || O,
|
|
252
252
|
onLoad: xe,
|
|
253
253
|
isLoading: k,
|
|
254
254
|
hideLoader: !0,
|
|
@@ -10,23 +10,21 @@ import { Select as Z } from "../../../input/select/Select.js";
|
|
|
10
10
|
import { Icon as b } from "../../../icons/icon/Icon.js";
|
|
11
11
|
import { Tag as U } from "../../../tag/tag/Tag.js";
|
|
12
12
|
const de = ({
|
|
13
|
-
title:
|
|
13
|
+
title: m,
|
|
14
14
|
subtitle: w,
|
|
15
15
|
showDebateConsultationSubtitle: k = !1,
|
|
16
16
|
sortOptions: n,
|
|
17
17
|
defaultSelectOption: x,
|
|
18
18
|
searchBar: o = !1,
|
|
19
|
-
tagList:
|
|
19
|
+
tagList: f,
|
|
20
20
|
pinnedTagList: h = [],
|
|
21
|
-
activeTagId:
|
|
22
|
-
withUrlParams:
|
|
21
|
+
activeTagId: g,
|
|
22
|
+
withUrlParams: u = !1,
|
|
23
23
|
onSearch: $,
|
|
24
24
|
onSortChange: L,
|
|
25
25
|
onTagChange: H
|
|
26
26
|
}) => {
|
|
27
|
-
const B = Q(), M = V(), { isMobile: q } = X(), [j, z] = v(!1), s = G(null), [
|
|
28
|
-
typeof window < "u" ? window.location.search : M.search
|
|
29
|
-
), S = Array.isArray(m) ? m : m?.data || [], C = [
|
|
27
|
+
const B = Q(), M = V(), { isMobile: q } = X(), [j, z] = v(!1), s = G(null), [A, P] = v(!1), [y, W] = v(!1), a = new URLSearchParams(M.search), S = Array.isArray(f) ? f : f?.data || [], C = [
|
|
30
28
|
...new Set(
|
|
31
29
|
(Array.isArray(h) ? h : [h]).filter(Boolean).map(String)
|
|
32
30
|
)
|
|
@@ -54,7 +52,7 @@ const de = ({
|
|
|
54
52
|
behavior: "smooth"
|
|
55
53
|
}), setTimeout(i, 300);
|
|
56
54
|
}, _ = (e) => {
|
|
57
|
-
if (
|
|
55
|
+
if (u) {
|
|
58
56
|
for (const l of a.keys())
|
|
59
57
|
n.map((c) => {
|
|
60
58
|
c.name === l && a.delete(l);
|
|
@@ -66,11 +64,11 @@ const de = ({
|
|
|
66
64
|
}
|
|
67
65
|
L(e);
|
|
68
66
|
}, D = (e) => {
|
|
69
|
-
|
|
67
|
+
u && (e.id === g ? a.delete("tagId") : a.set("tagId", e.id)), H(e.id === g ? null : e.id);
|
|
70
68
|
}, E = (e) => {
|
|
71
|
-
|
|
69
|
+
u && (e ? a.set("search", e) : a.delete("search")), $(e), z(e !== "");
|
|
72
70
|
}, F = (e) => {
|
|
73
|
-
const l =
|
|
71
|
+
const l = g === e.id;
|
|
74
72
|
return /* @__PURE__ */ r(
|
|
75
73
|
"div",
|
|
76
74
|
{
|
|
@@ -88,7 +86,7 @@ const de = ({
|
|
|
88
86
|
e.id
|
|
89
87
|
);
|
|
90
88
|
};
|
|
91
|
-
return /* @__PURE__ */ r(T, { children: (
|
|
89
|
+
return /* @__PURE__ */ r(T, { children: (m || n || o) && /* @__PURE__ */ d(T, { children: [
|
|
92
90
|
/* @__PURE__ */ d(
|
|
93
91
|
"div",
|
|
94
92
|
{
|
|
@@ -96,7 +94,7 @@ const de = ({
|
|
|
96
94
|
[t.listHeaderOneItem]: !o || !n
|
|
97
95
|
}),
|
|
98
96
|
children: [
|
|
99
|
-
|
|
97
|
+
m && /* @__PURE__ */ r("div", { className: t.listTitle, children: m }),
|
|
100
98
|
(n || o) && /* @__PURE__ */ d(
|
|
101
99
|
"div",
|
|
102
100
|
{
|
|
@@ -138,10 +136,10 @@ const de = ({
|
|
|
138
136
|
"button",
|
|
139
137
|
{
|
|
140
138
|
type: "button",
|
|
141
|
-
className: `${t.arrow} ${t.arrowLeft} ${
|
|
139
|
+
className: `${t.arrow} ${t.arrowLeft} ${A ? "" : t.arrowHidden}`,
|
|
142
140
|
onClick: (e) => I("left", e),
|
|
143
141
|
"aria-label": "Tag précédent",
|
|
144
|
-
tabIndex:
|
|
142
|
+
tabIndex: A ? 0 : -1,
|
|
145
143
|
children: /* @__PURE__ */ r(b, { name: "lightArrow", height: 24, width: 24 })
|
|
146
144
|
}
|
|
147
145
|
),
|
|
@@ -158,10 +156,10 @@ const de = ({
|
|
|
158
156
|
"button",
|
|
159
157
|
{
|
|
160
158
|
type: "button",
|
|
161
|
-
className: `${t.arrow} ${t.arrowRight} ${
|
|
159
|
+
className: `${t.arrow} ${t.arrowRight} ${y ? "" : t.arrowHidden}`,
|
|
162
160
|
onClick: (e) => I("right", e),
|
|
163
161
|
"aria-label": "Tag suivant",
|
|
164
|
-
tabIndex:
|
|
162
|
+
tabIndex: y ? 0 : -1,
|
|
165
163
|
children: /* @__PURE__ */ r(b, { name: "lightArrow", height: 24, width: 24 })
|
|
166
164
|
}
|
|
167
165
|
)
|