@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 g, Fragment as Qe } from "react/jsx-runtime";
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 We, { useState as f, useEffect as p } from "react";
5
- import { useIntl as ze } from "react-intl";
6
- import { useLocation as Ge } from "react-router";
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 Pe } from "./action_bar/ActionBar.js";
9
- import { useList as Ve } from "../list_provider/useList.js";
10
- import { useDataProvider as Xe } from "../../data/data_provider/useDataProvider.js";
11
- import { useResponsive as Ye } from "../../hooks/use_responsive/useResponsive.js";
12
- import { useData as Ze } from "../../data/data_provider/useData.js";
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 He } from "../pagination/Pagination.js";
15
- import { StandardErrorBoundary as Ie } from "../../error/standard_error_boundary/StandardErrorBoundary.js";
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: N,
17
+ query: b,
18
18
  sortOptions: o,
19
- sort: M,
19
+ sort: w,
20
20
  filters: m,
21
21
  tagList: ne,
22
22
  pinnedTagList: ae,
23
- currentPage: R,
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: de = "query",
32
- tagParam: re = "tag_id",
31
+ queryParam: re = "query",
32
+ tagParam: de = "tag_id",
33
33
  totalHeaderParam: D = "total",
34
34
  onUpdateTotal: $,
35
- onElementsLoad: b,
36
- transformData: W,
35
+ onElementsLoad: R,
36
+ transformData: I,
37
37
  uniqueIdKey: S = "id",
38
38
  children: fe,
39
39
  resourcePropName: ce,
40
- loadingComponent: z,
41
- searchBar: ue = !1,
42
- title: ge,
40
+ loadingComponent: W,
41
+ searchBar: ge = !1,
42
+ title: ue,
43
43
  subtitle: Ee,
44
44
  showDebateConsultationSubtitle: he = !1,
45
- emptyListComponent: G,
46
- emptyText: P,
47
- display: V,
48
- elementsPerLine: X,
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: Y,
52
+ numberElements: X,
53
53
  countless: ye,
54
- onElementClick: we,
55
- withUrlParams: Ne = !1,
56
- onLoadNewPage: Z
54
+ onElementClick: Ne,
55
+ withUrlParams: be = !1,
56
+ onLoadNewPage: Y
57
57
  }) => {
58
- const J = ze(), t = Ve(), H = Xe(), I = Ge(), { isMobile: K, isTablet: Me, isDesktop: L } = Ye(), [k, E] = f(!1), [Re, be] = f(!1), [d, y] = Ze(a, []), [O, ke] = f(
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] = f(R || 1), [w, B] = f(N || null), [C, q] = f(null), [Ce, ee] = f(null), c = new URLSearchParams(
61
- typeof window < "u" ? window.location.search : I.search
62
- ), Te = () => o && o[0].type === "sort" && o[0].value || M || "", Fe = () => {
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] = f(Te()), [Q, _] = f(Fe()), te = Ue(m);
66
- R && R !== h && j(R), N !== void 0 && N !== w && B(N), M !== void 0 && M !== T && F(M), te && JSON.stringify(m) !== JSON.stringify(te) && JSON.stringify(m) !== JSON.stringify(Q) && _(m), p(() => {
67
- if (c.get("tagId") && q(Number.parseInt(c.get("tagId"))), c.get("search") && B(c.get("search")), c.get("sort")) {
68
- F(c.get("sort"));
69
- for (const e of c.values()) {
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 c.keys()) {
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
- }, [I.search]), p(() => {
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
- w,
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
- (r) => !d.some((u) => u.id === r.id)
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 Z == "function" && Z() !== null || j(h + 1);
131
+ typeof Y == "function" && Y() !== null || j(h + 1);
132
132
  }, se = (e) => {
133
- const s = le ? H.getListWithToken : H.getList;
134
- if ((e - 1) * v <= (Y || O) || e === 1) {
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 && !w && { [me]: T },
139
- ...w && { [de]: w },
138
+ ...T && !N && { [me]: T },
139
+ ...N && { [re]: N },
140
140
  ...ye === !0 && { countless: !0 },
141
141
  ...Q,
142
- ...C && { [re]: C }
142
+ ...C && { [de]: C }
143
143
  };
144
144
  s(A, i).then((n) => {
145
- const r = n.headers;
146
- r && D in r && (ke(
147
- Number.parseInt(r[D || "total"], 10)
148
- ), $ && $(r[D || "total"]));
149
- let u = n?.data?.data;
150
- b && b(u), W && (u = u.filter(W)), t.addElements && a in t.addElements && t.addElements[a].length > 0 && (u = [...t.addElements[a], u]), Le(u), E(!1);
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 && be(!0), E(!1);
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
- ), b && b(e);
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
- (r) => r.id === n.id ? n : r
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__ */ g(
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: we,
184
- children: /* @__PURE__ */ g(Ie, { hideMessage: !0, children: We.cloneElement(fe, {
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) => z ? /* @__PURE__ */ g("li", { className: l.paginatedListItem, children: z }, e) : null;
191
- if (Re)
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__ */ g(
200
- Pe,
199
+ /* @__PURE__ */ u(
200
+ Ge,
201
201
  {
202
- title: ge,
202
+ title: ue,
203
203
  subtitle: Ee,
204
204
  showDebateConsultationSubtitle: he,
205
205
  sortOptions: o,
206
206
  defaultSelectOption: Ce,
207
- searchBar: ue,
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: Ne
214
+ withUrlParams: be
215
215
  }
216
216
  ),
217
- !k && d.length === 0 ? G ? /* @__PURE__ */ g("div", { className: l.emptyListElement, children: G }) : /* @__PURE__ */ g("div", { className: l.emptyList, children: P || J.formatMessage({
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]: V === "column",
227
- [l.column]: V === "column",
228
- [l.twoElementsPerLine]: X === 2,
229
- [l.oneElementPerLine]: X === 1,
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]: Me && !L,
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__ */ g(
243
- He,
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: Y || O,
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: f,
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: m,
19
+ tagList: f,
20
20
  pinnedTagList: h = [],
21
- activeTagId: u,
22
- withUrlParams: g = !1,
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), [y, P] = v(!1), [A, W] = v(!1), a = new URLSearchParams(
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 (g) {
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
- g && (e.id === u ? a.delete("tagId") : a.set("tagId", e.id)), H(e.id === u ? null : e.id);
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
- g && (e ? a.set("search", e) : a.delete("search")), $(e), z(e !== "");
69
+ u && (e ? a.set("search", e) : a.delete("search")), $(e), z(e !== "");
72
70
  }, F = (e) => {
73
- const l = u === e.id;
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: (f || n || o) && /* @__PURE__ */ d(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
- f && /* @__PURE__ */ r("div", { className: t.listTitle, children: f }),
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} ${y ? "" : t.arrowHidden}`,
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: y ? 0 : -1,
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} ${A ? "" : t.arrowHidden}`,
159
+ className: `${t.arrow} ${t.arrowRight} ${y ? "" : t.arrowHidden}`,
162
160
  onClick: (e) => I("right", e),
163
161
  "aria-label": "Tag suivant",
164
- tabIndex: A ? 0 : -1,
162
+ tabIndex: y ? 0 : -1,
165
163
  children: /* @__PURE__ */ r(b, { name: "lightArrow", height: 24, width: 24 })
166
164
  }
167
165
  )
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.79",
3
+ "version": "0.4.81",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",