@logora/debate 0.4.111 → 0.4.112

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,50 +1,44 @@
1
- import { jsx as t, Fragment as C } from "react/jsx-runtime";
1
+ import { jsx as t, Fragment as _ } from "react/jsx-runtime";
2
2
  import { useState as h, useEffect as m } from "react";
3
- import E from "./AuthModal.module.scss.js";
4
- import { useConfig as P } from "../../data/config_provider/useConfig.js";
5
- import { useModal as T } from "../../dialog/modal/useModal.js";
6
- import { useAuth as L } from "../use_auth/useAuth.js";
7
- import { useAuthActions as R } from "../use_auth/useAuthActions.js";
8
- import { httpClient as B } from "../../data/http_client/httpClient.js";
9
- import { Modal as M } from "../../dialog/modal/Modal.js";
10
- import { Loader as O } from "../../progress/loader/Loader.js";
11
- import { SocialAuthForm as b } from "../social_auth_form/SocialAuthForm.js";
12
- import { SSOForm as N } from "../sso_form/SSOForm.js";
13
- import { AuthProviderFactory as S } from "../providers/AuthProviderFactory.js";
14
- const V = ({
15
- onHideModal: s = null,
16
- title: c,
17
- text: p,
18
- buttonLabel: d,
19
- url: g
20
- }) => {
21
- const o = P(), { hideModal: f } = T(), { isLoggedIn: l, authError: r } = L(), [A, n] = h(!1), [e, U] = h(null), { loginUser: v } = R(
22
- B,
3
+ import w from "./AuthModal.module.scss.js";
4
+ import { useConfig as I } from "../../data/config_provider/useConfig.js";
5
+ import { useModal as y } from "../../dialog/modal/useModal.js";
6
+ import { useAuth as C } from "../use_auth/useAuth.js";
7
+ import { useAuthActions as E } from "../use_auth/useAuthActions.js";
8
+ import { httpClient as P } from "../../data/http_client/httpClient.js";
9
+ import { Modal as T } from "../../dialog/modal/Modal.js";
10
+ import { Loader as R } from "../../progress/loader/Loader.js";
11
+ import { SocialAuthForm as B } from "../social_auth_form/SocialAuthForm.js";
12
+ import { SSOForm as L } from "../sso_form/SSOForm.js";
13
+ import { AuthProviderFactory as M } from "../providers/AuthProviderFactory.js";
14
+ const $ = ({ onHideModal: s = null }) => {
15
+ const o = I(), { hideModal: c } = y(), { isLoggedIn: l, authError: r } = C(), [p, n] = h(!1), [e, d] = h(null), { loginUser: g } = E(
16
+ P,
23
17
  process.env.API_AUTH_URL,
24
18
  "logora_user_token"
25
19
  );
26
20
  m(() => {
27
- l && _();
21
+ l && f();
28
22
  }, [l]), m(() => {
29
23
  e && r && n(!1);
30
24
  }, [e, r]);
31
- const _ = () => {
32
- f(), s && s();
33
- }, w = (i, a, u) => {
34
- U(u), n(!0), I(i, a);
35
- }, I = (i, a) => {
36
- const y = S.create(
25
+ const f = () => {
26
+ c(), s && s();
27
+ }, A = (i, a, u) => {
28
+ d(u), n(!0), U(i, a);
29
+ }, U = (i, a) => {
30
+ const v = M.create(
37
31
  o.auth?.type,
38
32
  o.shortname,
39
33
  i,
40
34
  a
41
35
  ).getAuthorizationParams();
42
- v(y);
36
+ g(v);
43
37
  };
44
- return /* @__PURE__ */ t(M, { "data-vid": "login_modal", children: /* @__PURE__ */ t("div", { className: E.loginModalBody, children: A ? /* @__PURE__ */ t(O, {}) : /* @__PURE__ */ t(C, { children: o.auth.type === "form" || o.auth.type === "social" ? /* @__PURE__ */ t(
45
- b,
38
+ return /* @__PURE__ */ t(T, { "data-vid": "login_modal", children: /* @__PURE__ */ t("div", { className: w.loginModalBody, children: p ? /* @__PURE__ */ t(R, {}) : /* @__PURE__ */ t(_, { children: o.auth.type === "form" || o.auth.type === "social" ? /* @__PURE__ */ t(
39
+ B,
46
40
  {
47
- onSubmit: w,
41
+ onSubmit: A,
48
42
  error: r,
49
43
  lastStep: e,
50
44
  facebookClientId: process.env.FACEBOOK_CLIENT_ID,
@@ -57,7 +51,7 @@ const V = ({
57
51
  privacyUrl: o.provider?.privacyUrl || "https://www.logora.com/blog-posts/privacy-policy"
58
52
  }
59
53
  ) : /* @__PURE__ */ t(
60
- N,
54
+ L,
61
55
  {
62
56
  authType: o.auth.type,
63
57
  error: r && e === "OAUTH2",
@@ -66,10 +60,7 @@ const V = ({
66
60
  scope: o.auth.scope,
67
61
  logoUrl: o.logo_url,
68
62
  loginUrl: o.auth.login_url,
69
- signupUrl: g || o.auth.registration_url || o.auth.login_url,
70
- title: c,
71
- subtitle: p,
72
- signupLabel: d,
63
+ signupUrl: o.auth.registration_url || o.auth.login_url,
73
64
  termsUrl: o.provider?.cguUrl || "https://www.logora.com/blog-posts/cgu",
74
65
  redirectParameter: o.auth.redirectParameter,
75
66
  trackingParameters: o.auth.trackingParameters,
@@ -83,5 +74,5 @@ const V = ({
83
74
  ) }) }) });
84
75
  };
85
76
  export {
86
- V as AuthModal
77
+ $ as AuthModal
87
78
  };
@@ -1,16 +1,16 @@
1
1
  import { jsxs as n, jsx as e, Fragment as m } from "react/jsx-runtime";
2
- import z from "classnames";
2
+ import G from "classnames";
3
3
  import "react";
4
- import { useIntl as H, FormattedMessage as w } from "react-intl";
5
- import { useLocation as K } from "react-router";
4
+ import { useIntl as D, FormattedMessage as w } from "react-intl";
5
+ import { useLocation as Y } from "react-router";
6
6
  import a from "./SSOForm.module.scss.js";
7
- import { useSessionStorageState as V } from "../../hooks/use_session_storage_state/useSessionStorageState.js";
8
- import { Icon as W } from "../../icons/icon/Icon.js";
9
- import { Button as $ } from "../../action/button/Button.js";
10
- import { Toggle as q } from "../../input/toggle/Toggle.js";
11
- import { EMAIL_CONSENT_STORAGE_KEY as J } from "../use_auth/useAuthActions.js";
12
- import { utf8ToBase64url as Q } from "../use_auth/base64.js";
13
- const de = ({
7
+ import { useSessionStorageState as z } from "../../hooks/use_session_storage_state/useSessionStorageState.js";
8
+ import { Icon as H } from "../../icons/icon/Icon.js";
9
+ import { Button as K } from "../../action/button/Button.js";
10
+ import { Toggle as V } from "../../input/toggle/Toggle.js";
11
+ import { EMAIL_CONSENT_STORAGE_KEY as W } from "../use_auth/useAuthActions.js";
12
+ import { utf8ToBase64url as $ } from "../use_auth/base64.js";
13
+ const ie = ({
14
14
  authType: v,
15
15
  providerName: c,
16
16
  loginUrl: M,
@@ -27,44 +27,41 @@ const de = ({
27
27
  showEmailConsent: g = !1,
28
28
  showTerms: L = !1,
29
29
  hideBelowButton: x = !1,
30
- error: R = !1,
31
- title: T,
32
- subtitle: A,
33
- signupLabel: C
30
+ error: R = !1
34
31
  }) => {
35
- const [h, B] = g ? V(J, !1) : [!1, () => {
36
- }], o = H(), d = K(), O = (t) => {
32
+ const [h, T] = g ? z(W, !1) : [!1, () => {
33
+ }], o = D(), d = Y(), A = (t) => {
37
34
  if (typeof window < "u") {
38
- const s = t === "CURRENT_LOCATION" ? window.location : t, i = new URL(s, window.location.origin), l = i.searchParams, G = new URLSearchParams(d.search);
35
+ const s = t === "CURRENT_LOCATION" ? window.location : t, i = new URL(s, window.location.origin), l = i.searchParams, E = new URLSearchParams(d.search);
39
36
  l.has("code") && l.delete("code"), f && l.append(f, window.location.toString());
40
- for (const [_, D] of Object.entries(P)) {
41
- let r = D;
37
+ for (const [_, F] of Object.entries(P)) {
38
+ let r = F;
42
39
  if (r) {
43
- const Y = d.pathname.slice(
40
+ const j = d.pathname.slice(
44
41
  0,
45
42
  d.pathname.lastIndexOf("/")
46
43
  );
47
44
  r = r.replace(
48
45
  "{{UTM_CAMPAIGN}}",
49
- G.get("utm_campaign")
46
+ E.get("utm_campaign")
50
47
  ), r = r.replace(
51
48
  "{{CURRENT_PATH}}",
52
- decodeURIComponent(Y)
49
+ decodeURIComponent(j)
53
50
  );
54
51
  }
55
- _ === "metadata" && r && (r = Q(r)), l.append(_, r);
52
+ _ === "metadata" && r && (r = $(r)), l.append(_, r);
56
53
  }
57
54
  return i.search = l.toString(), i.toString();
58
55
  }
59
56
  return "";
60
- }, E = (t) => {
57
+ }, C = (t) => {
61
58
  const s = new URL(t);
62
59
  if (s.searchParams.delete("code"), s.searchParams.append("client_id", S), s.searchParams.append("redirect_uri", y), s.searchParams.append("scope", I), s.searchParams.append("response_type", "code"), typeof window < "u") {
63
60
  const i = new URL(window.location.href);
64
61
  i.searchParams.delete("code"), s.searchParams.append("state", window.btoa(i.toString()));
65
62
  }
66
63
  return s.href;
67
- }, p = (t) => v === "oauth2_server" ? E(t) : O(t), F = p(M), j = p(b);
64
+ }, p = (t) => v === "oauth2_server" ? C(t) : A(t), B = p(M), O = p(b);
68
65
  return /* @__PURE__ */ n("div", { className: a.ssoForm, children: [
69
66
  /* @__PURE__ */ e("div", { className: a.logo, children: u ? /* @__PURE__ */ e(
70
67
  "img",
@@ -76,7 +73,7 @@ const de = ({
76
73
  alt: `Logo ${c}`
77
74
  }
78
75
  ) : /* @__PURE__ */ e(
79
- W,
76
+ H,
80
77
  {
81
78
  name: "next",
82
79
  "aria-hidden": "true",
@@ -87,13 +84,13 @@ const de = ({
87
84
  ) }),
88
85
  /* @__PURE__ */ n("div", { className: a.mainText, children: [
89
86
  /* @__PURE__ */ n("div", { className: a.title, children: [
90
- T || o.formatMessage({
87
+ o.formatMessage({
91
88
  id: "auth.sso_form.title",
92
89
  defaultMessage: "Debate now !"
93
90
  }),
94
91
  /* @__PURE__ */ e("br", {})
95
92
  ] }),
96
- A || o.formatMessage(
93
+ o.formatMessage(
97
94
  {
98
95
  id: "auth.sso_form.subtitle",
99
96
  defaultMessage: "Sign up right now and receive alerts by email."
@@ -103,15 +100,15 @@ const de = ({
103
100
  ] }),
104
101
  U ? null : /* @__PURE__ */ n(m, { children: [
105
102
  /* @__PURE__ */ e(
106
- $,
103
+ K,
107
104
  {
108
105
  "data-tid": "link_signup",
109
106
  "data-testid": "signup-button",
110
107
  className: a.loginButton,
111
- to: j,
108
+ to: O,
112
109
  external: !0,
113
110
  border: !1,
114
- children: C || o.formatMessage({
111
+ children: o.formatMessage({
115
112
  id: "auth.sso_form.signup",
116
113
  defaultMessage: "Sign up"
117
114
  })
@@ -130,7 +127,7 @@ const de = ({
130
127
  "data-testid": "signin-link",
131
128
  "data-tid": "link_login",
132
129
  rel: "nofollow",
133
- href: F,
130
+ href: B,
134
131
  children: o.formatMessage({
135
132
  id: "auth.sso_form.signin",
136
133
  defaultMessage: "Sign in"
@@ -138,8 +135,8 @@ const de = ({
138
135
  }
139
136
  )
140
137
  ] }),
141
- g ? /* @__PURE__ */ e("div", { className: z(a.switchBox), children: /* @__PURE__ */ e(
142
- q,
138
+ g ? /* @__PURE__ */ e("div", { className: G(a.switchBox), children: /* @__PURE__ */ e(
139
+ V,
143
140
  {
144
141
  type: "checkbox",
145
142
  name: "accepts_provider_email",
@@ -152,7 +149,7 @@ const de = ({
152
149
  },
153
150
  { variable: c }
154
151
  ),
155
- onInputChanged: (t) => B(!h),
152
+ onInputChanged: (t) => T(!h),
156
153
  "data-testid": "accepts-email-input"
157
154
  }
158
155
  ) }) : null,
@@ -193,5 +190,5 @@ const de = ({
193
190
  ] });
194
191
  };
195
192
  export {
196
- de as SSOForm
193
+ ie as SSOForm
197
194
  };
@@ -1,17 +1,17 @@
1
1
  import { jsx as n } from "react/jsx-runtime";
2
- import { createContext as f, useContext as i, Suspense as s, lazy as l } from "react";
2
+ import { createContext as f, useContext as i, Suspense as u, lazy as s } from "react";
3
3
  import { ConfigContext as c } from "../../data/config_provider/ConfigProvider.js";
4
4
  import { useModal as h } from "../../dialog/modal/useModal.js";
5
5
  import { useAuth as m } from "../../auth/use_auth/useAuth.js";
6
- const p = l(() => import("../../auth/auth_modal/index.js").then((t) => ({ default: t.AuthModal }))), w = l(() => import("../../auth/subscription_modal/index.js").then((t) => ({ default: t.SubscriptionModal }))), d = f(null), b = () => {
7
- const { config: t } = i(c), o = i(d), { isLoggedIn: r, currentUser: e } = m() || {};
6
+ const p = s(() => import("../../auth/auth_modal/index.js").then((t) => ({ default: t.AuthModal }))), w = s(() => import("../../auth/subscription_modal/index.js").then((t) => ({ default: t.SubscriptionModal }))), l = f(null), b = () => {
7
+ const { config: t } = i(c), o = i(l), { isLoggedIn: r, currentUser: e } = m() || {};
8
8
  return !!(r && o && t?.[o]?.subscribersOnly === !0 && e?.is_subscriber !== !0);
9
9
  }, R = () => {
10
- const { config: t } = i(c), o = i(d), r = b(), { showModal: e } = h(), u = o ? t?.[o] : null;
10
+ const { config: t } = i(c), o = i(l), r = b(), { showModal: e } = h(), d = o ? t?.[o] : null;
11
11
  return (a = {}) => {
12
12
  if (r) {
13
13
  e(
14
- /* @__PURE__ */ n(s, { fallback: null, children: /* @__PURE__ */ n(w, { ...u?.subscriptionModal }) })
14
+ /* @__PURE__ */ n(u, { fallback: null, children: /* @__PURE__ */ n(w, { ...d?.subscriptionModal }) })
15
15
  );
16
16
  return;
17
17
  }
@@ -24,12 +24,12 @@ const p = l(() => import("../../auth/auth_modal/index.js").then((t) => ({ defaul
24
24
  detail: { redirectUrl: window.location.href }
25
25
  })
26
26
  )), t?.auth?.disableLoginModal !== !0 && e(
27
- /* @__PURE__ */ n(s, { fallback: null, children: /* @__PURE__ */ n(p, { ...u?.loginModal, ...a }) })
27
+ /* @__PURE__ */ n(u, { fallback: null, children: /* @__PURE__ */ n(p, { ...a }) })
28
28
  );
29
29
  };
30
30
  };
31
31
  export {
32
- d as ModuleContext,
32
+ l as ModuleContext,
33
33
  R as useAuthRequired,
34
34
  b as useSubscriptionRequired
35
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@logora/debate",
3
- "version": "0.4.111",
3
+ "version": "0.4.112",
4
4
  "type": "module",
5
5
  "license": "AGPL-3.0",
6
6
  "description": "Design system of @Logora made with React",