@logora/debate 0.4.80 → 0.4.82
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.
|
@@ -14,9 +14,9 @@ import { uniqueBy as x } from "../../util/unique_by/uniqueBy.js";
|
|
|
14
14
|
import { Pagination as Ze } from "../pagination/Pagination.js";
|
|
15
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,
|
|
@@ -28,8 +28,8 @@ 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
35
|
onElementsLoad: R,
|
|
@@ -51,31 +51,29 @@ const ct = ({
|
|
|
51
51
|
withPagination: Se = !0,
|
|
52
52
|
numberElements: X,
|
|
53
53
|
countless: ye,
|
|
54
|
-
onElementClick:
|
|
55
|
-
withUrlParams:
|
|
54
|
+
onElementClick: Ne,
|
|
55
|
+
withUrlParams: be = !1,
|
|
56
56
|
onLoadNewPage: Y
|
|
57
57
|
}) => {
|
|
58
|
-
const J = We(), t = Pe(), Z = Ve(), H = ze(), { isMobile: K, isTablet:
|
|
59
|
-
|
|
60
|
-
), [
|
|
61
|
-
r
|
|
62
|
-
), [
|
|
63
|
-
d.get("tagId") ? Number.parseInt(d.get("tagId"), 10) : null
|
|
64
|
-
), [Ce, ee] = c(null), Te = () => o && o[0].type === "sort" && o[0].value || b || "", Fe = () => {
|
|
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
|
+
d?.length || 0
|
|
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 = () => {
|
|
65
63
|
let e = {};
|
|
66
64
|
return o && o[0].type === "filter" && (e[o[0].name] = o[0].value), m && (e = Object.assign({}, e, m)), e;
|
|
67
65
|
}, [T, F] = c(Te()), [Q, _] = c(Fe()), te = Ue(m);
|
|
68
|
-
M && M !== h && j(M),
|
|
69
|
-
if (
|
|
70
|
-
F(
|
|
71
|
-
for (const e of
|
|
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()) {
|
|
72
70
|
o?.map((s) => {
|
|
73
71
|
s.value === e && ee(s.name);
|
|
74
72
|
});
|
|
75
73
|
break;
|
|
76
74
|
}
|
|
77
75
|
}
|
|
78
|
-
for (const e of
|
|
76
|
+
for (const e of r.keys()) {
|
|
79
77
|
o?.map((s) => {
|
|
80
78
|
s.name === e && (_({
|
|
81
79
|
...m,
|
|
@@ -89,7 +87,7 @@ const ct = ({
|
|
|
89
87
|
}, [
|
|
90
88
|
T,
|
|
91
89
|
Q,
|
|
92
|
-
|
|
90
|
+
N,
|
|
93
91
|
A,
|
|
94
92
|
C,
|
|
95
93
|
v
|
|
@@ -106,24 +104,24 @@ const ct = ({
|
|
|
106
104
|
const e = t.updateElements[a];
|
|
107
105
|
if (e.length > 0) {
|
|
108
106
|
const s = e.filter(
|
|
109
|
-
(i) =>
|
|
107
|
+
(i) => d.some((n) => n.id === i.id)
|
|
110
108
|
);
|
|
111
109
|
if (s.length > 0) {
|
|
112
110
|
De(s);
|
|
113
111
|
const i = e.filter(
|
|
114
|
-
(f) => !
|
|
112
|
+
(f) => !d.some((g) => g.id === f.id)
|
|
115
113
|
), n = { ...t.updateElements };
|
|
116
114
|
i.length > 0 ? n[a] = i : delete n[a], t.setUpdateElements(n);
|
|
117
115
|
}
|
|
118
116
|
}
|
|
119
117
|
}
|
|
120
|
-
}, [t.updateElements,
|
|
121
|
-
if (t.removeElements && a in t.removeElements && t.removeElements[a].length > 0 &&
|
|
118
|
+
}, [t.updateElements, d]), p(() => {
|
|
119
|
+
if (t.removeElements && a in t.removeElements && t.removeElements[a].length > 0 && d.length > 0) {
|
|
122
120
|
Je(t.removeElements[a]);
|
|
123
121
|
const e = { ...t.removeElements };
|
|
124
122
|
delete e[a], t.setRemoveElements(e);
|
|
125
123
|
}
|
|
126
|
-
}, [t.removeElements,
|
|
124
|
+
}, [t.removeElements, d]);
|
|
127
125
|
const _e = (e) => {
|
|
128
126
|
e.type === "filter" ? (F(""), _({
|
|
129
127
|
...m,
|
|
@@ -137,11 +135,11 @@ const ct = ({
|
|
|
137
135
|
const i = {
|
|
138
136
|
[oe]: e,
|
|
139
137
|
[ie]: v,
|
|
140
|
-
...T && !
|
|
141
|
-
...
|
|
138
|
+
...T && !N && { [me]: T },
|
|
139
|
+
...N && { [re]: N },
|
|
142
140
|
...ye === !0 && { countless: !0 },
|
|
143
141
|
...Q,
|
|
144
|
-
...C && { [
|
|
142
|
+
...C && { [de]: C }
|
|
145
143
|
};
|
|
146
144
|
s(A, i).then((n) => {
|
|
147
145
|
const f = n.headers;
|
|
@@ -169,7 +167,7 @@ const ct = ({
|
|
|
169
167
|
), x(i, S || "id");
|
|
170
168
|
});
|
|
171
169
|
}, Je = (e) => {
|
|
172
|
-
const s = e.map((n) => n.id), i =
|
|
170
|
+
const s = e.map((n) => n.id), i = d.filter(
|
|
173
171
|
(n) => s.indexOf(n.id) === -1
|
|
174
172
|
);
|
|
175
173
|
y(x(i, S || "id"));
|
|
@@ -182,7 +180,7 @@ const ct = ({
|
|
|
182
180
|
{
|
|
183
181
|
className: l.paginatedListItem,
|
|
184
182
|
"data-testid": "list-item",
|
|
185
|
-
onClick:
|
|
183
|
+
onClick: Ne,
|
|
186
184
|
children: /* @__PURE__ */ u(He, { hideMessage: !0, children: Ie.cloneElement(fe, {
|
|
187
185
|
index: s,
|
|
188
186
|
[ce]: e
|
|
@@ -213,10 +211,10 @@ const ct = ({
|
|
|
213
211
|
onSearch: (e) => B(e),
|
|
214
212
|
onSortChange: _e,
|
|
215
213
|
onTagChange: (e) => q(e),
|
|
216
|
-
withUrlParams:
|
|
214
|
+
withUrlParams: be
|
|
217
215
|
}
|
|
218
216
|
),
|
|
219
|
-
!k &&
|
|
217
|
+
!k && d.length === 0 ? z ? /* @__PURE__ */ u("div", { className: l.emptyListElement, children: z }) : /* @__PURE__ */ u("div", { className: l.emptyList, children: G || J.formatMessage({
|
|
220
218
|
id: "info.emptyList",
|
|
221
219
|
defaultMessage: "No items for now."
|
|
222
220
|
}) }) : /* @__PURE__ */ U(Qe, { children: [
|
|
@@ -231,12 +229,12 @@ const ct = ({
|
|
|
231
229
|
[l.oneElementPerLine]: V === 1,
|
|
232
230
|
[l.indexLayoutList]: pe,
|
|
233
231
|
[l.listIsDesktop]: L,
|
|
234
|
-
[l.listIsTablet]:
|
|
232
|
+
[l.listIsTablet]: we && !L,
|
|
235
233
|
[l.listIsMobile]: K
|
|
236
234
|
}),
|
|
237
235
|
style: { gap: ve },
|
|
238
236
|
children: [
|
|
239
|
-
|
|
237
|
+
d.map(je),
|
|
240
238
|
k ? Array(v).fill().map((e, s) => s).map(Be) : null
|
|
241
239
|
]
|
|
242
240
|
}
|
|
@@ -1,114 +1,121 @@
|
|
|
1
|
-
import { jsx as r, Fragment as
|
|
2
|
-
import
|
|
3
|
-
import { useState as
|
|
4
|
-
import { useIntl as
|
|
5
|
-
import { useLocation as
|
|
1
|
+
import { jsx as r, Fragment as k, jsxs as d } from "react/jsx-runtime";
|
|
2
|
+
import x from "classnames";
|
|
3
|
+
import { useState as b, useRef as K, useCallback as Q, useEffect as U } from "react";
|
|
4
|
+
import { useIntl as V } from "react-intl";
|
|
5
|
+
import { useLocation as X, useNavigate as Y } from "react-router";
|
|
6
6
|
import t from "./ActionBar.module.scss.js";
|
|
7
|
-
import { useResponsive as
|
|
8
|
-
import { SearchInput as
|
|
9
|
-
import { Select as
|
|
10
|
-
import { Icon as
|
|
11
|
-
import { Tag as
|
|
12
|
-
const
|
|
13
|
-
title:
|
|
7
|
+
import { useResponsive as Z } from "../../../hooks/use_responsive/useResponsive.js";
|
|
8
|
+
import { SearchInput as q } from "../../../input/search_input/SearchInput.js";
|
|
9
|
+
import { Select as O } from "../../../input/select/Select.js";
|
|
10
|
+
import { Icon as y } from "../../../icons/icon/Icon.js";
|
|
11
|
+
import { Tag as ee } from "../../../tag/tag/Tag.js";
|
|
12
|
+
const fe = ({
|
|
13
|
+
title: m,
|
|
14
14
|
subtitle: w,
|
|
15
|
-
showDebateConsultationSubtitle:
|
|
15
|
+
showDebateConsultationSubtitle: $ = !1,
|
|
16
16
|
sortOptions: n,
|
|
17
|
-
defaultSelectOption:
|
|
17
|
+
defaultSelectOption: L,
|
|
18
18
|
searchBar: o = !1,
|
|
19
|
-
tagList:
|
|
20
|
-
pinnedTagList:
|
|
21
|
-
activeTagId:
|
|
22
|
-
withUrlParams:
|
|
23
|
-
onSearch:
|
|
24
|
-
onSortChange:
|
|
25
|
-
onTagChange:
|
|
19
|
+
tagList: h,
|
|
20
|
+
pinnedTagList: f = [],
|
|
21
|
+
activeTagId: g,
|
|
22
|
+
withUrlParams: u = !1,
|
|
23
|
+
onSearch: H,
|
|
24
|
+
onSortChange: B,
|
|
25
|
+
onTagChange: M
|
|
26
26
|
}) => {
|
|
27
|
-
const
|
|
28
|
-
typeof window < "u" ? window.location.search : M.search
|
|
29
|
-
), S = Array.isArray(m) ? m : m?.data || [], C = [
|
|
27
|
+
const P = V(), A = X(), j = Y(), { isMobile: te } = Z(), [z, W] = b(!1), s = K(null), [N, _] = b(!1), [C, D] = b(!1), l = new URLSearchParams(A.search), p = Array.isArray(h) ? h : h?.data || [], I = [
|
|
30
28
|
...new Set(
|
|
31
|
-
(Array.isArray(
|
|
29
|
+
(Array.isArray(f) ? f : [f]).filter(Boolean).map(String)
|
|
32
30
|
)
|
|
33
|
-
],
|
|
34
|
-
...
|
|
35
|
-
...
|
|
36
|
-
] : [], i =
|
|
31
|
+
], S = p.length > 0 ? [
|
|
32
|
+
...I.map((e) => p.find((a) => String(a.id) === e)).filter(Boolean),
|
|
33
|
+
...p.filter((e) => !I.includes(String(e.id)))
|
|
34
|
+
] : [], i = Q(() => {
|
|
37
35
|
const e = s.current;
|
|
38
|
-
e && (
|
|
36
|
+
e && (_(e.scrollLeft > 1), D(e.scrollLeft + e.clientWidth < e.scrollWidth - 1));
|
|
39
37
|
}, []);
|
|
40
|
-
|
|
38
|
+
U(() => {
|
|
41
39
|
i();
|
|
42
40
|
const e = s.current;
|
|
43
41
|
if (!e) return;
|
|
44
|
-
const
|
|
45
|
-
return
|
|
46
|
-
}, [
|
|
47
|
-
const
|
|
48
|
-
|
|
42
|
+
const a = new ResizeObserver(i);
|
|
43
|
+
return a.observe(e), () => a.disconnect();
|
|
44
|
+
}, [S, i]);
|
|
45
|
+
const T = (e, a) => {
|
|
46
|
+
a.stopPropagation();
|
|
49
47
|
const c = s.current;
|
|
50
48
|
if (!c) return;
|
|
51
|
-
const
|
|
49
|
+
const R = 200;
|
|
52
50
|
c.scrollBy({
|
|
53
|
-
left: e === "left" ? -
|
|
51
|
+
left: e === "left" ? -R : R,
|
|
54
52
|
behavior: "smooth"
|
|
55
53
|
}), setTimeout(i, 300);
|
|
56
|
-
},
|
|
57
|
-
|
|
58
|
-
|
|
54
|
+
}, v = () => {
|
|
55
|
+
const e = l.toString();
|
|
56
|
+
j(
|
|
57
|
+
{
|
|
58
|
+
pathname: A.pathname,
|
|
59
|
+
search: e ? `?${e}` : ""
|
|
60
|
+
},
|
|
61
|
+
{ replace: !0 }
|
|
62
|
+
);
|
|
63
|
+
}, E = (e) => {
|
|
64
|
+
if (u) {
|
|
65
|
+
for (const a of l.keys())
|
|
59
66
|
n.map((c) => {
|
|
60
|
-
c.name ===
|
|
67
|
+
c.name === a && l.delete(a);
|
|
61
68
|
});
|
|
62
|
-
|
|
69
|
+
l.delete("sort"), l.set(
|
|
63
70
|
e.type === "filter" ? e.name : "sort",
|
|
64
71
|
e.value
|
|
65
|
-
);
|
|
72
|
+
), v();
|
|
66
73
|
}
|
|
67
|
-
|
|
68
|
-
}, D = (e) => {
|
|
69
|
-
g && (e.id === u ? a.delete("tagId") : a.set("tagId", e.id)), H(e.id === u ? null : e.id);
|
|
70
|
-
}, E = (e) => {
|
|
71
|
-
g && (e ? a.set("search", e) : a.delete("search")), $(e), z(e !== "");
|
|
74
|
+
B(e);
|
|
72
75
|
}, F = (e) => {
|
|
73
|
-
|
|
76
|
+
u && (e.id === g ? l.delete("tagId") : l.set("tagId", e.id), v()), M(e.id === g ? null : e.id);
|
|
77
|
+
}, G = (e) => {
|
|
78
|
+
u && (e ? l.set("search", e) : l.delete("search"), v()), H(e), W(e !== "");
|
|
79
|
+
}, J = (e) => {
|
|
80
|
+
const a = g === e.id;
|
|
74
81
|
return /* @__PURE__ */ r(
|
|
75
82
|
"div",
|
|
76
83
|
{
|
|
77
84
|
className: t.tagItem,
|
|
78
|
-
onClick: () =>
|
|
85
|
+
onClick: () => F(e),
|
|
79
86
|
children: /* @__PURE__ */ r(
|
|
80
|
-
|
|
87
|
+
ee,
|
|
81
88
|
{
|
|
82
89
|
text: e.display_name,
|
|
83
|
-
active:
|
|
84
|
-
rightIcon:
|
|
90
|
+
active: a,
|
|
91
|
+
rightIcon: a && /* @__PURE__ */ r(y, { name: "close", height: 10, width: 10 })
|
|
85
92
|
}
|
|
86
93
|
)
|
|
87
94
|
},
|
|
88
95
|
e.id
|
|
89
96
|
);
|
|
90
97
|
};
|
|
91
|
-
return /* @__PURE__ */ r(
|
|
98
|
+
return /* @__PURE__ */ r(k, { children: (m || n || o) && /* @__PURE__ */ d(k, { children: [
|
|
92
99
|
/* @__PURE__ */ d(
|
|
93
100
|
"div",
|
|
94
101
|
{
|
|
95
|
-
className:
|
|
102
|
+
className: x(t.listHeader, {
|
|
96
103
|
[t.listHeaderOneItem]: !o || !n
|
|
97
104
|
}),
|
|
98
105
|
children: [
|
|
99
|
-
|
|
106
|
+
m && /* @__PURE__ */ r("div", { className: t.listTitle, children: m }),
|
|
100
107
|
(n || o) && /* @__PURE__ */ d(
|
|
101
108
|
"div",
|
|
102
109
|
{
|
|
103
|
-
className:
|
|
110
|
+
className: x(t.rightBar, {
|
|
104
111
|
[t.rightBarOneItem]: !o || !n
|
|
105
112
|
}),
|
|
106
113
|
children: [
|
|
107
114
|
o ? /* @__PURE__ */ r("div", { className: t.search, children: /* @__PURE__ */ r(
|
|
108
|
-
|
|
115
|
+
q,
|
|
109
116
|
{
|
|
110
|
-
onSearchSubmit:
|
|
111
|
-
placeholder:
|
|
117
|
+
onSearchSubmit: G,
|
|
118
|
+
placeholder: P.formatMessage({
|
|
112
119
|
id: "info.search_mobile",
|
|
113
120
|
defaultMessage: "Search"
|
|
114
121
|
}),
|
|
@@ -116,13 +123,13 @@ const de = ({
|
|
|
116
123
|
}
|
|
117
124
|
) }) : null,
|
|
118
125
|
n ? /* @__PURE__ */ r(
|
|
119
|
-
|
|
126
|
+
O,
|
|
120
127
|
{
|
|
121
|
-
onChange:
|
|
128
|
+
onChange: E,
|
|
122
129
|
options: n,
|
|
123
|
-
defaultOption:
|
|
130
|
+
defaultOption: L,
|
|
124
131
|
horizontalPosition: "right",
|
|
125
|
-
disabled:
|
|
132
|
+
disabled: z,
|
|
126
133
|
className: t.select
|
|
127
134
|
}
|
|
128
135
|
) : null
|
|
@@ -132,17 +139,17 @@ const de = ({
|
|
|
132
139
|
]
|
|
133
140
|
}
|
|
134
141
|
),
|
|
135
|
-
|
|
136
|
-
|
|
142
|
+
$ && w && /* @__PURE__ */ r("div", { className: t.listSubtitle, children: w }),
|
|
143
|
+
S.length > 0 && /* @__PURE__ */ d("div", { className: t.tagSection, children: [
|
|
137
144
|
/* @__PURE__ */ r(
|
|
138
145
|
"button",
|
|
139
146
|
{
|
|
140
147
|
type: "button",
|
|
141
|
-
className: `${t.arrow} ${t.arrowLeft} ${
|
|
142
|
-
onClick: (e) =>
|
|
148
|
+
className: `${t.arrow} ${t.arrowLeft} ${N ? "" : t.arrowHidden}`,
|
|
149
|
+
onClick: (e) => T("left", e),
|
|
143
150
|
"aria-label": "Tag précédent",
|
|
144
|
-
tabIndex:
|
|
145
|
-
children: /* @__PURE__ */ r(
|
|
151
|
+
tabIndex: N ? 0 : -1,
|
|
152
|
+
children: /* @__PURE__ */ r(y, { name: "lightArrow", height: 24, width: 24 })
|
|
146
153
|
}
|
|
147
154
|
),
|
|
148
155
|
/* @__PURE__ */ r(
|
|
@@ -151,23 +158,23 @@ const de = ({
|
|
|
151
158
|
ref: s,
|
|
152
159
|
className: t.tagList,
|
|
153
160
|
onScroll: i,
|
|
154
|
-
children:
|
|
161
|
+
children: S.map(J)
|
|
155
162
|
}
|
|
156
163
|
),
|
|
157
164
|
/* @__PURE__ */ r(
|
|
158
165
|
"button",
|
|
159
166
|
{
|
|
160
167
|
type: "button",
|
|
161
|
-
className: `${t.arrow} ${t.arrowRight} ${
|
|
162
|
-
onClick: (e) =>
|
|
168
|
+
className: `${t.arrow} ${t.arrowRight} ${C ? "" : t.arrowHidden}`,
|
|
169
|
+
onClick: (e) => T("right", e),
|
|
163
170
|
"aria-label": "Tag suivant",
|
|
164
|
-
tabIndex:
|
|
165
|
-
children: /* @__PURE__ */ r(
|
|
171
|
+
tabIndex: C ? 0 : -1,
|
|
172
|
+
children: /* @__PURE__ */ r(y, { name: "lightArrow", height: 24, width: 24 })
|
|
166
173
|
}
|
|
167
174
|
)
|
|
168
175
|
] })
|
|
169
176
|
] }) });
|
|
170
177
|
};
|
|
171
178
|
export {
|
|
172
|
-
|
|
179
|
+
fe as ActionBar
|
|
173
180
|
};
|