@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 T, jsxs as d } from "react/jsx-runtime";
2
- import R from "classnames";
3
- import { useState as v, useRef as G, useCallback as J, useEffect as K } from "react";
4
- import { useIntl as Q } from "react-intl";
5
- import { useLocation as V } from "react-router";
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 X } from "../../../hooks/use_responsive/useResponsive.js";
8
- import { SearchInput as Y } from "../../../input/search_input/SearchInput.js";
9
- import { Select as Z } from "../../../input/select/Select.js";
10
- import { Icon as b } from "../../../icons/icon/Icon.js";
11
- import { Tag as U } from "../../../tag/tag/Tag.js";
12
- const de = ({
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: k = !1,
15
+ showDebateConsultationSubtitle: $ = !1,
16
16
  sortOptions: n,
17
- defaultSelectOption: x,
17
+ defaultSelectOption: L,
18
18
  searchBar: o = !1,
19
- tagList: f,
20
- pinnedTagList: h = [],
19
+ tagList: h,
20
+ pinnedTagList: f = [],
21
21
  activeTagId: g,
22
22
  withUrlParams: u = !1,
23
- onSearch: $,
24
- onSortChange: L,
25
- onTagChange: H
23
+ onSearch: H,
24
+ onSortChange: B,
25
+ onTagChange: M
26
26
  }) => {
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 = [
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(h) ? h : [h]).filter(Boolean).map(String)
29
+ (Array.isArray(f) ? f : [f]).filter(Boolean).map(String)
30
30
  )
31
- ], p = S.length > 0 ? [
32
- ...C.map((e) => S.find((l) => String(l.id) === e)).filter(Boolean),
33
- ...S.filter((e) => !C.includes(String(e.id)))
34
- ] : [], i = J(() => {
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 && (P(e.scrollLeft > 1), W(e.scrollLeft + e.clientWidth < e.scrollWidth - 1));
36
+ e && (_(e.scrollLeft > 1), D(e.scrollLeft + e.clientWidth < e.scrollWidth - 1));
37
37
  }, []);
38
- K(() => {
38
+ U(() => {
39
39
  i();
40
40
  const e = s.current;
41
41
  if (!e) return;
42
- const l = new ResizeObserver(i);
43
- return l.observe(e), () => l.disconnect();
44
- }, [p, i]);
45
- const I = (e, l) => {
46
- l.stopPropagation();
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 N = 200;
49
+ const R = 200;
50
50
  c.scrollBy({
51
- left: e === "left" ? -N : N,
51
+ left: e === "left" ? -R : R,
52
52
  behavior: "smooth"
53
53
  }), setTimeout(i, 300);
54
- }, _ = (e) => {
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 l of a.keys())
65
+ for (const a of l.keys())
57
66
  n.map((c) => {
58
- c.name === l && a.delete(l);
67
+ c.name === a && l.delete(a);
59
68
  });
60
- a.delete("sort"), a.set(
69
+ l.delete("sort"), l.set(
61
70
  e.type === "filter" ? e.name : "sort",
62
71
  e.value
63
- );
72
+ ), v();
64
73
  }
65
- L(e);
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
- const l = g === e.id;
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: () => D(e),
85
+ onClick: () => F(e),
77
86
  children: /* @__PURE__ */ r(
78
- U,
87
+ ee,
79
88
  {
80
89
  text: e.display_name,
81
- active: l,
82
- rightIcon: l && /* @__PURE__ */ r(b, { name: "close", height: 10, width: 10 })
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(T, { children: (m || n || o) && /* @__PURE__ */ d(T, { children: [
98
+ return /* @__PURE__ */ r(k, { children: (m || n || o) && /* @__PURE__ */ d(k, { children: [
90
99
  /* @__PURE__ */ d(
91
100
  "div",
92
101
  {
93
- className: R(t.listHeader, {
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: R(t.rightBar, {
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
- Y,
115
+ q,
107
116
  {
108
- onSearchSubmit: E,
109
- placeholder: B.formatMessage({
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
- Z,
126
+ O,
118
127
  {
119
- onChange: _,
128
+ onChange: E,
120
129
  options: n,
121
- defaultOption: x,
130
+ defaultOption: L,
122
131
  horizontalPosition: "right",
123
- disabled: j,
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
- k && w && /* @__PURE__ */ r("div", { className: t.listSubtitle, children: w }),
134
- p.length > 0 && /* @__PURE__ */ d("div", { className: t.tagSection, children: [
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} ${A ? "" : t.arrowHidden}`,
140
- onClick: (e) => I("left", 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: A ? 0 : -1,
143
- children: /* @__PURE__ */ r(b, { name: "lightArrow", height: 24, width: 24 })
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: p.map(F)
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} ${y ? "" : t.arrowHidden}`,
160
- onClick: (e) => I("right", e),
168
+ className: `${t.arrow} ${t.arrowRight} ${C ? "" : t.arrowHidden}`,
169
+ onClick: (e) => T("right", e),
161
170
  "aria-label": "Tag suivant",
162
- tabIndex: y ? 0 : -1,
163
- children: /* @__PURE__ */ r(b, { name: "lightArrow", height: 24, width: 24 })
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
- de as ActionBar
179
+ fe as ActionBar
171
180
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.81",
3
+ "version": "0.4.82",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",