@logora/debate 0.4.110 → 0.4.111

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