@logora/debate 0.4.81 → 0.4.83

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,102 +1,104 @@
1
1
  import { jsx as v, Fragment as E } from "react/jsx-runtime";
2
- import { useState as L, useEffect as _ } from "react";
2
+ import { useState as L, useEffect as A } from "react";
3
3
  import { useConfig as O } from "../../data/config_provider/useConfig.js";
4
4
  import { useAuthInterceptor as k } from "../use_auth/useAuthInterceptor.js";
5
5
  import { authTokenHandler as I } from "../use_auth/authTokenHandler.js";
6
6
  import { useAuthActions as S } from "../use_auth/useAuthActions.js";
7
- import { useAuthRequired as q } from "../../hooks/use_auth_required/useAuthRequired.js";
8
- import { AuthProviderFactory as F } from "../providers/AuthProviderFactory.js";
9
- import { OnboardingModal as J } from "../../user/onboarding_modal/OnboardingModal.js";
10
- import { saveOnboardingBeforeLogin as M } from "../../user/onboarding_modal/useOnboarding.js";
11
- import { httpClient as h } from "../../data/axios_client/httpClient.js";
12
- const T = (t) => {
13
- const e = t.replace(/-/g, "+").replace(/_/g, "/"), s = e.padEnd(e.length + (4 - e.length % 4) % 4, "=");
14
- return atob(s);
15
- }, j = (t) => {
16
- if (!t || typeof t != "string")
7
+ import { useAuthRequired as T } from "../../hooks/use_auth_required/useAuthRequired.js";
8
+ import { AuthProviderFactory as q } from "../providers/AuthProviderFactory.js";
9
+ import { OnboardingModal as B } from "../../user/onboarding_modal/OnboardingModal.js";
10
+ import { saveOnboardingBeforeLogin as D } from "../../user/onboarding_modal/useOnboarding.js";
11
+ import { httpClient as d } from "../../data/axios_client/httpClient.js";
12
+ const F = (e) => {
13
+ const t = e.replace(/-/g, "+").replace(/_/g, "/"), a = t.padEnd(t.length + (4 - t.length % 4) % 4, "=");
14
+ return new TextDecoder().decode(Uint8Array.from(atob(a), (r) => r.charCodeAt(0)));
15
+ }, J = (e) => {
16
+ if (!e || typeof e != "string")
17
17
  return null;
18
- const e = t.split(".");
19
- if (e.length < 2)
18
+ const t = e.split(".");
19
+ if (t.length < 2)
20
20
  return null;
21
21
  try {
22
- return JSON.parse(T(e[1]));
22
+ return JSON.parse(F(t[1]));
23
23
  } catch {
24
24
  return null;
25
25
  }
26
- }, z = (t, e) => {
27
- if (!t || typeof t != "object")
26
+ }, M = (e, t) => {
27
+ if (!e || typeof e != "object")
28
28
  return {};
29
- const s = e || {}, a = (u) => {
30
- const r = s[u];
31
- return typeof r == "string" && r.length > 0 ? r.split(".").reduce((o, l) => o == null ? o : o[l], t) : t[u];
29
+ const a = t || {}, r = (u) => {
30
+ const o = a[u];
31
+ return typeof o == "string" && o.length > 0 ? o.split(".").reduce((n, l) => n == null ? n : n[l], e) : e[u];
32
32
  };
33
33
  return {
34
- first_name: a("first_name"),
35
- last_name: a("last_name"),
36
- image_url: a("image_url")
34
+ first_name: r("first_name"),
35
+ last_name: r("last_name"),
36
+ image_url: r("image_url")
37
37
  };
38
- }, X = ({ authUrl: t, authType: e, provider: s, assertion: a }) => {
39
- const u = "logora_user_token", r = O();
40
- k(h, t, u);
41
- const o = z(
42
- j(a),
43
- r.auth?.userProfileMapping
44
- ), [l, f] = L(!1), { getToken: A, removeToken: b } = I(
45
- h,
46
- t,
38
+ }, X = ({ authUrl: e, authType: t, provider: a, assertion: r }) => {
39
+ const u = "logora_user_token", o = O();
40
+ k(d, e, u);
41
+ const n = M(
42
+ J(r),
43
+ o.auth?.userProfileMapping
44
+ ), [l, c] = L(!1), { getToken: _, removeToken: C } = I(
45
+ d,
46
+ e,
47
47
  u
48
- ), { loginUser: g, logoutUser: P, fetchUser: C } = S(
49
- h,
50
- t,
48
+ ), { loginUser: f, logoutUser: b, fetchUser: P } = S(
49
+ d,
50
+ e,
51
51
  u
52
- ), d = q();
53
- _(() => {
54
- c();
55
- }, []), _(() => {
52
+ ), g = T();
53
+ A(() => {
54
+ m();
55
+ }, []), A(() => {
56
56
  if (typeof window < "u")
57
- return window.addEventListener("logora:authentication:require", d), window.addEventListener("logora:authentication:refresh", c), () => {
58
- window.removeEventListener("logora:authentication:require", d), window.removeEventListener("logora:authentication:refresh", c);
57
+ return window.addEventListener("logora:authentication:require", g), window.addEventListener("logora:authentication:refresh", m), () => {
58
+ window.removeEventListener("logora:authentication:require", g), window.removeEventListener("logora:authentication:refresh", m);
59
59
  };
60
60
  }, []);
61
- const c = () => {
62
- const n = w(), i = A();
63
- if (i) {
64
- const m = i.session_id;
65
- n.isSameUser(m) ? C() : (b(), p(n));
61
+ const m = () => {
62
+ const i = w(), s = _();
63
+ if (s) {
64
+ const h = s.session_id;
65
+ i.isSameUser(h) ? P() : (C(), p(i));
66
66
  } else
67
- p(n);
68
- }, p = (n) => {
69
- if (n.shouldInitAuth()) {
70
- const i = n.getAuthorizationParams();
71
- if (i) {
72
- if (e !== "social" && e !== "oauth2_server" && r.auth?.showOnboardingBeforeLogin === !0) {
73
- f(!0);
67
+ p(i);
68
+ }, p = (i) => {
69
+ if (i.shouldInitAuth()) {
70
+ const s = i.getAuthorizationParams();
71
+ if (s) {
72
+ if (t !== "social" && t !== "oauth2_server" && o.auth?.showOnboardingBeforeLogin === !0) {
73
+ c(!0);
74
74
  return;
75
75
  }
76
- g(i);
76
+ f(s);
77
77
  }
78
78
  } else
79
- P();
80
- }, U = (n, i) => {
79
+ b();
80
+ }, U = (i, s) => {
81
81
  const y = w().getAuthorizationParams();
82
- M(r.shortname, i), f(!1), g(y);
83
- }, w = () => F.create(e, s, a);
82
+ D(o.shortname, s), c(!1), f(y);
83
+ }, w = () => q.create(t, a, r);
84
84
  return /* @__PURE__ */ v(E, { children: l && /* @__PURE__ */ v(
85
- J,
85
+ B,
86
86
  {
87
87
  pendingAuth: !0,
88
88
  onConsentConfirmed: U,
89
- showTerms: r.auth?.hideCgu !== !0,
90
- showEmailConsent: r.auth?.showEmailConsent,
91
- initialFirstName: o.first_name,
92
- initialLastName: o.last_name,
93
- initialImageUrl: o.image_url,
94
- termsUrl: r.provider?.cguUrl || "https://www.logora.com/blog-posts/cgu",
95
- privacyUrl: r.provider?.privacyUrl || "https://www.logora.com/blog-posts/privacy-policy"
89
+ showCloseButton: o.auth?.allowCloseOnboardingBeforeLogin === !0,
90
+ onClose: () => c(!1),
91
+ showTerms: o.auth?.hideCgu !== !0,
92
+ showEmailConsent: o.auth?.showEmailConsent,
93
+ initialFirstName: n.first_name,
94
+ initialLastName: n.last_name,
95
+ initialImageUrl: n.image_url,
96
+ termsUrl: o.provider?.cguUrl || "https://www.logora.com/blog-posts/cgu",
97
+ privacyUrl: o.provider?.privacyUrl || "https://www.logora.com/blog-posts/privacy-policy"
96
98
  }
97
99
  ) });
98
100
  };
99
101
  export {
100
102
  X as AuthInitializer,
101
- j as decodeJwtPayload
103
+ J as decodeJwtPayload
102
104
  };
@@ -1,45 +1,46 @@
1
- import { jsx as l, jsxs as s } from "react/jsx-runtime";
1
+ import { jsx as l, jsxs as i } from "react/jsx-runtime";
2
2
  import r from "classnames";
3
- import { useRef as g, useEffect as b } from "react";
4
- import { useIntl as C } from "react-intl";
3
+ import { useRef as b, useEffect as C } from "react";
4
+ import { useIntl as M } from "react-intl";
5
5
  import e from "./Modal.module.scss.js";
6
- import { useModal as M } from "./useModal.js";
7
- import { Icon as x } from "../../icons/icon/Icon.js";
8
- const D = ({
6
+ import { useModal as x } from "./useModal.js";
7
+ import { Icon as E } from "../../icons/icon/Icon.js";
8
+ const I = ({
9
9
  title: t,
10
- showCloseButton: i = !1,
11
- fullScreen: c,
12
- children: m,
13
- disableClickOutside: f = !1,
14
- ...u
10
+ showCloseButton: c = !1,
11
+ fullScreen: m,
12
+ children: f,
13
+ disableClickOutside: u = !1,
14
+ onClose: a = null,
15
+ ...h
15
16
  }) => {
16
- const a = g(), h = C(), { hideModal: d } = M();
17
- b(() => {
18
- const o = a.current;
17
+ const n = b(), w = M(), { hideModal: v } = x();
18
+ C(() => {
19
+ const o = n.current;
19
20
  if (!o) return;
20
- const n = window.scrollY, p = document.documentElement.style.overflow, y = document.body.style.overflow;
21
- return document.documentElement.style.overflow = "hidden", document.body.style.overflow = "hidden", o.open || o.showModal(), o.focus(), window.scrollTo(0, n), () => {
22
- document.documentElement.style.overflow = p, document.body.style.overflow = y, o.open && o.close(), window.scrollTo(0, n);
21
+ const s = window.scrollY, y = document.documentElement.style.overflow, g = document.body.style.overflow;
22
+ return document.documentElement.style.overflow = "hidden", document.body.style.overflow = "hidden", o.open || o.showModal(), o.focus(), window.scrollTo(0, s), () => {
23
+ document.documentElement.style.overflow = y, document.body.style.overflow = g, o.open && o.close(), window.scrollTo(0, s);
23
24
  };
24
25
  }, []);
25
- const w = (o) => {
26
- f || o.currentTarget === o.target && d();
27
- }, v = () => {
28
- d();
26
+ const p = (o) => {
27
+ u || o.currentTarget === o.target && d();
28
+ }, d = () => {
29
+ a ? a() : v();
29
30
  };
30
31
  return /* @__PURE__ */ l(
31
32
  "dialog",
32
33
  {
33
- ref: a,
34
+ ref: n,
34
35
  className: r(e.modalDialog, {
35
- [e.modalDialogFullScreen]: c
36
+ [e.modalDialogFullScreen]: m
36
37
  }),
37
38
  "aria-labelledby": t ? "modal-title" : void 0,
38
- onClick: w,
39
- onClose: v,
40
- ...u,
41
- children: /* @__PURE__ */ s("div", { className: r(e.modalContainer), children: [
42
- /* @__PURE__ */ s(
39
+ onClick: p,
40
+ onClose: d,
41
+ ...h,
42
+ children: /* @__PURE__ */ i("div", { className: r(e.modalContainer), children: [
43
+ /* @__PURE__ */ i(
43
44
  "div",
44
45
  {
45
46
  className: r(e.modalHeader, {
@@ -47,19 +48,19 @@ const D = ({
47
48
  }),
48
49
  children: [
49
50
  t && /* @__PURE__ */ l("div", { id: "modal-title", children: t }),
50
- i && /* @__PURE__ */ l(
51
+ c && /* @__PURE__ */ l(
51
52
  "button",
52
53
  {
53
54
  type: "button",
54
55
  className: e.modalExitButton,
55
56
  onClick: d,
56
- "aria-label": h.formatMessage({
57
+ "aria-label": w.formatMessage({
57
58
  id: "dialog.modal.aria_label",
58
59
  defaultMessage: "Close dialog"
59
60
  }),
60
61
  "data-testid": "close-button",
61
62
  children: /* @__PURE__ */ l(
62
- x,
63
+ E,
63
64
  {
64
65
  name: "close",
65
66
  height: 18,
@@ -73,11 +74,11 @@ const D = ({
73
74
  ]
74
75
  }
75
76
  ),
76
- /* @__PURE__ */ l("div", { className: e.modalContent, children: m })
77
+ /* @__PURE__ */ l("div", { className: e.modalContent, children: f })
77
78
  ] })
78
79
  }
79
80
  );
80
81
  };
81
82
  export {
82
- D as Modal
83
+ I as Modal
83
84
  };
@@ -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
  };
@@ -1,72 +1,74 @@
1
1
  import { jsx as a, jsxs as d, Fragment as S } from "react/jsx-runtime";
2
2
  import { useState as l } from "react";
3
- import { useIntl as re, FormattedMessage as ie } from "react-intl";
3
+ import { useIntl as le, FormattedMessage as oe } from "react-intl";
4
4
  import s from "./OnboardingModal.module.scss.js";
5
- import { useAuth as le } from "../../auth/use_auth/useAuth.js";
6
- import { useDataProvider as oe } from "../../data/data_provider/useDataProvider.js";
7
- import { useConfig as ne } from "../../data/config_provider/useConfig.js";
8
- import { useResponsive as de } from "../../hooks/use_responsive/useResponsive.js";
9
- import { useFormValidation as ce } from "../../forms/use_form_validation/useFormValidation.js";
10
- import { useModal as me } from "../../dialog/modal/useModal.js";
11
- import { Modal as ue } from "../../dialog/modal/Modal.js";
12
- import { Loader as fe } from "../../progress/loader/Loader.js";
13
- import { AvatarSelector as pe } from "../avatar_selector/AvatarSelector.js";
14
- import { Icon as ge } from "../../icons/icon/Icon.js";
5
+ import { useAuth as ne } from "../../auth/use_auth/useAuth.js";
6
+ import { useDataProvider as de } from "../../data/data_provider/useDataProvider.js";
7
+ import { useConfig as ce } from "../../data/config_provider/useConfig.js";
8
+ import { useResponsive as me } from "../../hooks/use_responsive/useResponsive.js";
9
+ import { useFormValidation as ue } from "../../forms/use_form_validation/useFormValidation.js";
10
+ import { useModal as fe } from "../../dialog/modal/useModal.js";
11
+ import { Modal as pe } from "../../dialog/modal/Modal.js";
12
+ import { Loader as ge } from "../../progress/loader/Loader.js";
13
+ import { AvatarSelector as _e } from "../avatar_selector/AvatarSelector.js";
14
+ import { Icon as he } from "../../icons/icon/Icon.js";
15
15
  import { Button as F } from "../../action/button/Button.js";
16
- import { TextInput as B } from "../../input/text_input/TextInput.js";
17
- import { Select as _e } from "../../input/select/Select.js";
18
- import { Toggle as D } from "../../input/toggle/Toggle.js";
19
- const Le = ({
20
- termsUrl: L,
21
- privacyUrl: A,
16
+ import { TextInput as D } from "../../input/text_input/TextInput.js";
17
+ import { Select as ve } from "../../input/select/Select.js";
18
+ import { Toggle as L } from "../../input/toggle/Toggle.js";
19
+ const je = ({
20
+ termsUrl: A,
21
+ privacyUrl: B,
22
22
  showEmailConsent: y = !1,
23
23
  showTerms: g = !1,
24
24
  pendingAuth: n = !1,
25
- onConsentConfirmed: C = null,
25
+ onConsentConfirmed: x = null,
26
26
  initialFirstName: j = "",
27
27
  initialLastName: $ = "",
28
- initialImageUrl: x = null
28
+ initialImageUrl: C = null,
29
+ showCloseButton: R = !1,
30
+ onClose: q = null
29
31
  }) => {
30
- const o = le(), R = oe(), r = re(), i = ne(), q = [...Array(i.avatars?.maxFileName || 0).keys()].map(
32
+ const o = ne(), E = de(), r = le(), i = ce(), z = [...Array(i.avatars?.maxFileName || 0).keys()].map(
31
33
  (e) => `${i.avatars?.baseUrl}/${e + 1}.${i.avatars?.fileExtension}`
32
- ), [m, E] = l(
34
+ ), [m, T] = l(
33
35
  j || o.currentUser.first_name || ""
34
- ), [_, z] = l(
36
+ ), [_, V] = l(
35
37
  o.currentUser.description || ""
36
- ), [u, T] = l(
38
+ ), [u, W] = l(
37
39
  $ || o.currentUser.last_name || ""
38
- ), [h, V] = l(o.currentUser.language), [W, v] = l(!1), [b, k] = l(
39
- x || o.currentUser.image_url
40
- ), [f, G] = l(x || null), H = [m, u].filter(Boolean).join(" ") || o.currentUser?.full_name, [P, w] = l(!1), [J, K] = l(!1), { isMobile: I } = de(), { errors: c, validate: Q } = ce(), { hideModal: O } = me(), [M, X] = l(!1), [N, Y] = l(!1), Z = (e) => {
40
+ ), [h, G] = l(o.currentUser.language), [H, v] = l(!1), [b, k] = l(
41
+ C || o.currentUser.image_url
42
+ ), [f, J] = l(C || null), K = [m, u].filter(Boolean).join(" ") || o.currentUser?.full_name, [P, w] = l(!1), [Q, X] = l(!1), { isMobile: I } = me(), { errors: c, validate: Y } = ue(), { hideModal: O } = fe(), [M, Z] = l(!1), [N, ee] = l(!1), ae = (e) => {
41
43
  const t = new FileReader();
42
44
  t.onloadend = () => {
43
45
  k(t.result);
44
46
  }, t.readAsDataURL(e);
45
- }, ee = [
47
+ }, te = [
46
48
  { first_name: ["required", null] },
47
49
  { first_name: ["minChar", 2] },
48
50
  { last_name: ["required", null] },
49
51
  { last_name: ["minChar", 2] },
50
52
  ...n ? [] : [{ language: ["required", null] }],
51
53
  ...g ? [{ accepts_terms: ["enforceValue", !0] }] : []
52
- ], ae = (e) => {
54
+ ], se = (e) => {
53
55
  e.preventDefault();
54
56
  const t = {};
55
- if (m && (t.first_name = m), u && (t.last_name = u), h && (t.language = h), f && P && (t.image = n ? b : f), f && !P && (t.origin_image_url = f), _ && (t.description = _), y && (t.accepts_provider_email = N), g && (t.accepts_terms = M), t.is_onboarded = !0, Q(t, ee)) {
56
- K(!0);
57
+ if (m && (t.first_name = m), u && (t.last_name = u), h && (t.language = h), f && P && (t.image = n ? b : f), f && !P && (t.origin_image_url = f), _ && (t.description = _), y && (t.accepts_provider_email = N), g && (t.accepts_terms = M), t.is_onboarded = !0, Y(t, te)) {
58
+ X(!0);
57
59
  const U = new FormData();
58
- Object.entries(t).forEach(([p, se]) => {
59
- U.append(p, se);
60
- }), n && C ? C(U, t) : R.update("users", o.currentUser.slug, U).then((p) => {
60
+ Object.entries(t).forEach(([p, ie]) => {
61
+ U.append(p, ie);
62
+ }), n && x ? x(U, t) : E.update("users", o.currentUser.slug, U).then((p) => {
61
63
  p.data.success && o.setCurrentUser(p.data.data.resource), O();
62
64
  });
63
65
  }
64
- }, te = (e) => {
66
+ }, re = (e) => {
65
67
  const t = /^(https?|ftp):\/\/[^\s/$.?#].[^\s]*$/i;
66
- G(e), v(!1), t.test(e) ? (k(e), w(!1)) : (w(!0), Z(e));
68
+ J(e), v(!1), t.test(e) ? (k(e), w(!1)) : (w(!0), ae(e));
67
69
  };
68
70
  return /* @__PURE__ */ a(
69
- ue,
71
+ pe,
70
72
  {
71
73
  "data-vid": "update_user_info_modal",
72
74
  title: n ? r.formatMessage({
@@ -81,15 +83,16 @@ const Le = ({
81
83
  minWidth: I ? "unset" : "500px",
82
84
  maxWidth: "800px"
83
85
  },
84
- showCloseButton: !1,
86
+ showCloseButton: R,
87
+ onClose: q,
85
88
  disableClickOutside: !0,
86
- children: J ? /* @__PURE__ */ a(fe, {}) : W ? /* @__PURE__ */ d(S, { children: [
89
+ children: Q ? /* @__PURE__ */ a(ge, {}) : H ? /* @__PURE__ */ d(S, { children: [
87
90
  /* @__PURE__ */ a(
88
- pe,
91
+ _e,
89
92
  {
90
- onChooseAvatar: te,
91
- avatarUrlList: q,
92
- userName: H,
93
+ onChooseAvatar: re,
94
+ avatarUrlList: z,
95
+ userName: K,
93
96
  allowUserImage: i.avatars?.allowUserImage
94
97
  }
95
98
  ),
@@ -118,7 +121,7 @@ const Le = ({
118
121
  })
119
122
  }
120
123
  ) : /* @__PURE__ */ a("div", { className: s.userPictureUpload, children: /* @__PURE__ */ a(
121
- ge,
124
+ he,
122
125
  {
123
126
  name: "camera",
124
127
  height: 20,
@@ -146,7 +149,7 @@ const Le = ({
146
149
  /* @__PURE__ */ d("div", { className: s.inputsContainer, children: [
147
150
  /* @__PURE__ */ d("div", { className: s.nameContainer, children: [
148
151
  /* @__PURE__ */ a("div", { className: s.updateProfileInput, children: /* @__PURE__ */ a(
149
- B,
152
+ D,
150
153
  {
151
154
  type: "text",
152
155
  name: "first_name",
@@ -158,7 +161,7 @@ const Le = ({
158
161
  id: "auth_signup_form_first_name_placeholder",
159
162
  defaultMessage: "First name"
160
163
  }),
161
- onChange: (e) => i.actions?.disableOnboardingNameUpdate === !0 ? null : E(e.target.value),
164
+ onChange: (e) => i.actions?.disableOnboardingNameUpdate === !0 ? null : T(e.target.value),
162
165
  value: m,
163
166
  error: !!c.first_name,
164
167
  message: c.first_name,
@@ -167,7 +170,7 @@ const Le = ({
167
170
  }
168
171
  ) }),
169
172
  /* @__PURE__ */ a("div", { className: s.updateProfileInput, children: /* @__PURE__ */ a(
170
- B,
173
+ D,
171
174
  {
172
175
  type: "text",
173
176
  name: "last_name",
@@ -179,7 +182,7 @@ const Le = ({
179
182
  id: "auth_signup_form_last_name_placeholder",
180
183
  defaultMessage: "Last name"
181
184
  }),
182
- onChange: (e) => i.actions?.disableOnboardingNameUpdate === !0 ? null : T(e.target.value),
185
+ onChange: (e) => i.actions?.disableOnboardingNameUpdate === !0 ? null : W(e.target.value),
183
186
  value: u,
184
187
  error: !!c.last_name,
185
188
  message: c.last_name,
@@ -193,7 +196,7 @@ const Le = ({
193
196
  defaultMessage: "last name"
194
197
  }) }),
195
198
  !n && i.translation?.translationMethods && Object.keys(i.translation.translationMethods).length > 0 && /* @__PURE__ */ a(
196
- _e,
199
+ ve,
197
200
  {
198
201
  selectClassName: s.langSelect,
199
202
  options: Object.keys(
@@ -204,7 +207,7 @@ const Le = ({
204
207
  text: `${e.toUpperCase()}`
205
208
  })),
206
209
  defaultOption: h,
207
- onChange: (e) => V(e.value)
210
+ onChange: (e) => G(e.value)
208
211
  }
209
212
  ),
210
213
  !n && /* @__PURE__ */ a("div", { className: s.userDescription, children: /* @__PURE__ */ a(
@@ -216,7 +219,7 @@ const Le = ({
216
219
  defaultMessage: "Describe yourself in a few words"
217
220
  }),
218
221
  value: _,
219
- onChange: (e) => z(e.target.value),
222
+ onChange: (e) => V(e.target.value),
220
223
  maxLength: 500,
221
224
  "data-testid": "description"
222
225
  }
@@ -224,14 +227,14 @@ const Le = ({
224
227
  ] })
225
228
  ] }),
226
229
  g && /* @__PURE__ */ a("div", { className: s.toggle, children: /* @__PURE__ */ a(
227
- D,
230
+ L,
228
231
  {
229
232
  type: "checkbox",
230
233
  name: "accepts_terms",
231
234
  style: { fontSize: 18 },
232
235
  checked: M,
233
236
  label: /* @__PURE__ */ a(
234
- ie,
237
+ oe,
235
238
  {
236
239
  id: "modal.update_user_info_modal.accepts_terms",
237
240
  defaultMessage: "I declare I have read the <var1>General Conditions of Use</var1> and the <var2>Privacy policy</var2> of the debate space and accept them.",
@@ -241,7 +244,7 @@ const Le = ({
241
244
  {
242
245
  className: s.cgu,
243
246
  target: "_blank",
244
- href: L,
247
+ href: A,
245
248
  rel: "noreferrer",
246
249
  children: e
247
250
  }
@@ -251,7 +254,7 @@ const Le = ({
251
254
  {
252
255
  className: s.cgu,
253
256
  target: "_blank",
254
- href: A,
257
+ href: B,
255
258
  rel: "noreferrer",
256
259
  children: e
257
260
  }
@@ -259,13 +262,13 @@ const Le = ({
259
262
  }
260
263
  }
261
264
  ),
262
- onInputChanged: (e) => X(!M),
265
+ onInputChanged: (e) => Z(!M),
263
266
  message: c.accepts_terms,
264
267
  "data-testid": "accepts-terms-input"
265
268
  }
266
269
  ) }),
267
270
  y && /* @__PURE__ */ a("div", { className: s.toggle, children: /* @__PURE__ */ a(
268
- D,
271
+ L,
269
272
  {
270
273
  type: "checkbox",
271
274
  name: "accepts_provider_email",
@@ -278,7 +281,7 @@ const Le = ({
278
281
  },
279
282
  { provider: i.provider?.companyName }
280
283
  ),
281
- onInputChanged: (e) => Y(!N),
284
+ onInputChanged: (e) => ee(!N),
282
285
  "data-testid": "accepts-email-input"
283
286
  }
284
287
  ) }),
@@ -287,7 +290,7 @@ const Le = ({
287
290
  {
288
291
  "data-testid": "save-button",
289
292
  "data-tid": "action_save_profile",
290
- onClick: (e) => ae(e),
293
+ onClick: (e) => se(e),
291
294
  children: r.formatMessage({
292
295
  id: "user.user_edit.save",
293
296
  defaultMessage: "Save"
@@ -299,5 +302,5 @@ const Le = ({
299
302
  );
300
303
  };
301
304
  export {
302
- Le as OnboardingModal
305
+ je as OnboardingModal
303
306
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.81",
3
+ "version": "0.4.83",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",