@logora/debate 0.4.81 → 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.
|
@@ -1,96 +1,105 @@
|
|
|
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
|
|
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
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:
|
|
19
|
+
tagList: h,
|
|
20
|
+
pinnedTagList: f = [],
|
|
21
21
|
activeTagId: g,
|
|
22
22
|
withUrlParams: u = !1,
|
|
23
|
-
onSearch:
|
|
24
|
-
onSortChange:
|
|
25
|
-
onTagChange:
|
|
23
|
+
onSearch: H,
|
|
24
|
+
onSortChange: B,
|
|
25
|
+
onTagChange: M
|
|
26
26
|
}) => {
|
|
27
|
-
const
|
|
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 = [
|
|
28
28
|
...new Set(
|
|
29
|
-
(Array.isArray(
|
|
29
|
+
(Array.isArray(f) ? f : [f]).filter(Boolean).map(String)
|
|
30
30
|
)
|
|
31
|
-
],
|
|
32
|
-
...
|
|
33
|
-
...
|
|
34
|
-
] : [], 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(() => {
|
|
35
35
|
const e = s.current;
|
|
36
|
-
e && (
|
|
36
|
+
e && (_(e.scrollLeft > 1), D(e.scrollLeft + e.clientWidth < e.scrollWidth - 1));
|
|
37
37
|
}, []);
|
|
38
|
-
|
|
38
|
+
U(() => {
|
|
39
39
|
i();
|
|
40
40
|
const e = s.current;
|
|
41
41
|
if (!e) return;
|
|
42
|
-
const
|
|
43
|
-
return
|
|
44
|
-
}, [
|
|
45
|
-
const
|
|
46
|
-
|
|
42
|
+
const a = new ResizeObserver(i);
|
|
43
|
+
return a.observe(e), () => a.disconnect();
|
|
44
|
+
}, [S, i]);
|
|
45
|
+
const T = (e, a) => {
|
|
46
|
+
a.stopPropagation();
|
|
47
47
|
const c = s.current;
|
|
48
48
|
if (!c) return;
|
|
49
|
-
const
|
|
49
|
+
const R = 200;
|
|
50
50
|
c.scrollBy({
|
|
51
|
-
left: e === "left" ? -
|
|
51
|
+
left: e === "left" ? -R : R,
|
|
52
52
|
behavior: "smooth"
|
|
53
53
|
}), setTimeout(i, 300);
|
|
54
|
-
},
|
|
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) => {
|
|
55
64
|
if (u) {
|
|
56
|
-
for (const
|
|
65
|
+
for (const a of l.keys())
|
|
57
66
|
n.map((c) => {
|
|
58
|
-
c.name ===
|
|
67
|
+
c.name === a && l.delete(a);
|
|
59
68
|
});
|
|
60
|
-
|
|
69
|
+
l.delete("sort"), l.set(
|
|
61
70
|
e.type === "filter" ? e.name : "sort",
|
|
62
71
|
e.value
|
|
63
|
-
);
|
|
72
|
+
), v();
|
|
64
73
|
}
|
|
65
|
-
|
|
66
|
-
}, D = (e) => {
|
|
67
|
-
u && (e.id === g ? a.delete("tagId") : a.set("tagId", e.id)), H(e.id === g ? null : e.id);
|
|
68
|
-
}, E = (e) => {
|
|
69
|
-
u && (e ? a.set("search", e) : a.delete("search")), $(e), z(e !== "");
|
|
74
|
+
B(e);
|
|
70
75
|
}, F = (e) => {
|
|
71
|
-
|
|
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;
|
|
72
81
|
return /* @__PURE__ */ r(
|
|
73
82
|
"div",
|
|
74
83
|
{
|
|
75
84
|
className: t.tagItem,
|
|
76
|
-
onClick: () =>
|
|
85
|
+
onClick: () => F(e),
|
|
77
86
|
children: /* @__PURE__ */ r(
|
|
78
|
-
|
|
87
|
+
ee,
|
|
79
88
|
{
|
|
80
89
|
text: e.display_name,
|
|
81
|
-
active:
|
|
82
|
-
rightIcon:
|
|
90
|
+
active: a,
|
|
91
|
+
rightIcon: a && /* @__PURE__ */ r(y, { name: "close", height: 10, width: 10 })
|
|
83
92
|
}
|
|
84
93
|
)
|
|
85
94
|
},
|
|
86
95
|
e.id
|
|
87
96
|
);
|
|
88
97
|
};
|
|
89
|
-
return /* @__PURE__ */ r(
|
|
98
|
+
return /* @__PURE__ */ r(k, { children: (m || n || o) && /* @__PURE__ */ d(k, { children: [
|
|
90
99
|
/* @__PURE__ */ d(
|
|
91
100
|
"div",
|
|
92
101
|
{
|
|
93
|
-
className:
|
|
102
|
+
className: x(t.listHeader, {
|
|
94
103
|
[t.listHeaderOneItem]: !o || !n
|
|
95
104
|
}),
|
|
96
105
|
children: [
|
|
@@ -98,15 +107,15 @@ const de = ({
|
|
|
98
107
|
(n || o) && /* @__PURE__ */ d(
|
|
99
108
|
"div",
|
|
100
109
|
{
|
|
101
|
-
className:
|
|
110
|
+
className: x(t.rightBar, {
|
|
102
111
|
[t.rightBarOneItem]: !o || !n
|
|
103
112
|
}),
|
|
104
113
|
children: [
|
|
105
114
|
o ? /* @__PURE__ */ r("div", { className: t.search, children: /* @__PURE__ */ r(
|
|
106
|
-
|
|
115
|
+
q,
|
|
107
116
|
{
|
|
108
|
-
onSearchSubmit:
|
|
109
|
-
placeholder:
|
|
117
|
+
onSearchSubmit: G,
|
|
118
|
+
placeholder: P.formatMessage({
|
|
110
119
|
id: "info.search_mobile",
|
|
111
120
|
defaultMessage: "Search"
|
|
112
121
|
}),
|
|
@@ -114,13 +123,13 @@ const de = ({
|
|
|
114
123
|
}
|
|
115
124
|
) }) : null,
|
|
116
125
|
n ? /* @__PURE__ */ r(
|
|
117
|
-
|
|
126
|
+
O,
|
|
118
127
|
{
|
|
119
|
-
onChange:
|
|
128
|
+
onChange: E,
|
|
120
129
|
options: n,
|
|
121
|
-
defaultOption:
|
|
130
|
+
defaultOption: L,
|
|
122
131
|
horizontalPosition: "right",
|
|
123
|
-
disabled:
|
|
132
|
+
disabled: z,
|
|
124
133
|
className: t.select
|
|
125
134
|
}
|
|
126
135
|
) : null
|
|
@@ -130,17 +139,17 @@ const de = ({
|
|
|
130
139
|
]
|
|
131
140
|
}
|
|
132
141
|
),
|
|
133
|
-
|
|
134
|
-
|
|
142
|
+
$ && w && /* @__PURE__ */ r("div", { className: t.listSubtitle, children: w }),
|
|
143
|
+
S.length > 0 && /* @__PURE__ */ d("div", { className: t.tagSection, children: [
|
|
135
144
|
/* @__PURE__ */ r(
|
|
136
145
|
"button",
|
|
137
146
|
{
|
|
138
147
|
type: "button",
|
|
139
|
-
className: `${t.arrow} ${t.arrowLeft} ${
|
|
140
|
-
onClick: (e) =>
|
|
148
|
+
className: `${t.arrow} ${t.arrowLeft} ${N ? "" : t.arrowHidden}`,
|
|
149
|
+
onClick: (e) => T("left", e),
|
|
141
150
|
"aria-label": "Tag précédent",
|
|
142
|
-
tabIndex:
|
|
143
|
-
children: /* @__PURE__ */ r(
|
|
151
|
+
tabIndex: N ? 0 : -1,
|
|
152
|
+
children: /* @__PURE__ */ r(y, { name: "lightArrow", height: 24, width: 24 })
|
|
144
153
|
}
|
|
145
154
|
),
|
|
146
155
|
/* @__PURE__ */ r(
|
|
@@ -149,23 +158,23 @@ const de = ({
|
|
|
149
158
|
ref: s,
|
|
150
159
|
className: t.tagList,
|
|
151
160
|
onScroll: i,
|
|
152
|
-
children:
|
|
161
|
+
children: S.map(J)
|
|
153
162
|
}
|
|
154
163
|
),
|
|
155
164
|
/* @__PURE__ */ r(
|
|
156
165
|
"button",
|
|
157
166
|
{
|
|
158
167
|
type: "button",
|
|
159
|
-
className: `${t.arrow} ${t.arrowRight} ${
|
|
160
|
-
onClick: (e) =>
|
|
168
|
+
className: `${t.arrow} ${t.arrowRight} ${C ? "" : t.arrowHidden}`,
|
|
169
|
+
onClick: (e) => T("right", e),
|
|
161
170
|
"aria-label": "Tag suivant",
|
|
162
|
-
tabIndex:
|
|
163
|
-
children: /* @__PURE__ */ r(
|
|
171
|
+
tabIndex: C ? 0 : -1,
|
|
172
|
+
children: /* @__PURE__ */ r(y, { name: "lightArrow", height: 24, width: 24 })
|
|
164
173
|
}
|
|
165
174
|
)
|
|
166
175
|
] })
|
|
167
176
|
] }) });
|
|
168
177
|
};
|
|
169
178
|
export {
|
|
170
|
-
|
|
179
|
+
fe as ActionBar
|
|
171
180
|
};
|