@ichaingo/with-login 1.4.30 → 1.4.31

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 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAOhE,eAAO,MAAM,OAAO,eAEnB,CAAC;AAEF,MAAM,WAAW,cAAc;IAE7B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IAEjB,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IACxD,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,cAAc,CA2HzC;AAED,UAAU,cACR,SAAQ,KAAK,CAAC,iBAAiB,EAC7B,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,2CAS9D;AAED,eAAe,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAEA,OAAO,KAA2C,MAAM,OAAO,CAAC;AAOhE,eAAO,MAAM,OAAO,eAEnB,CAAC;AAEF,MAAM,WAAW,cAAc;IAE7B,MAAM,EAAE,OAAO,CAAC;IAChB,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,YAAY,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IACtC,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,OAAO,CAAC;IACtB,gBAAgB,EAAE,MAAM,IAAI,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;IAEjB,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,CAAC,CAAC;IACxD,UAAU,EAAE,KAAK,CAAC,EAAE,CAAC;CACtB;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,cAAc,CAiHzC;AAED,UAAU,cACR,SAAQ,KAAK,CAAC,iBAAiB,EAC7B,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC;IAC3B,QAAQ,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC5B;AAED;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,2CAS9D;AAED,eAAe,SAAS,CAAC"}
package/dist/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  'use client';
2
- import { jsx as u, jsxs as w, Fragment as T } from "react/jsx-runtime";
3
- import { useState as x, useEffect as L, useCallback as f } from "react";
4
- import { createPortal as j } from "react-dom";
2
+ import { jsx as d, jsxs as x, Fragment as j } from "react/jsx-runtime";
3
+ import { useState as h, useEffect as w, useCallback as f } from "react";
4
+ import { createPortal as k } from "react-dom";
5
5
  import { useLocale as R } from "next-intl";
6
- import { twMerge as m } from "tailwind-merge";
7
- import { useTheme as b } from "@ichaingo/next-themes";
6
+ import { twMerge as L } from "tailwind-merge";
7
+ import { useTheme as B } from "@ichaingo/next-themes";
8
8
  /*! js-cookie v3.0.5 | MIT */
9
- function h(e) {
10
- for (var t = 1; t < arguments.length; t++) {
11
- var i = arguments[t];
12
- for (var a in i)
13
- e[a] = i[a];
9
+ function g(e) {
10
+ for (var r = 1; r < arguments.length; r++) {
11
+ var t = arguments[r];
12
+ for (var a in t)
13
+ e[a] = t[a];
14
14
  }
15
15
  return e;
16
16
  }
17
- var z = {
17
+ var O = {
18
18
  read: function(e) {
19
19
  return e[0] === '"' && (e = e.slice(1, -1)), e.replace(/(%[\dA-F]{2})+/gi, decodeURIComponent);
20
20
  },
@@ -25,23 +25,23 @@ var z = {
25
25
  );
26
26
  }
27
27
  };
28
- function C(e, t) {
29
- function i(o, c, n) {
28
+ function C(e, r) {
29
+ function t(o, c, n) {
30
30
  if (!(typeof document > "u")) {
31
- n = h({}, t, n), typeof n.expires == "number" && (n.expires = new Date(Date.now() + n.expires * 864e5)), n.expires && (n.expires = n.expires.toUTCString()), o = encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
31
+ n = g({}, r, n), typeof n.expires == "number" && (n.expires = new Date(Date.now() + n.expires * 864e5)), n.expires && (n.expires = n.expires.toUTCString()), o = encodeURIComponent(o).replace(/%(2[346B]|5E|60|7C)/g, decodeURIComponent).replace(/[()]/g, escape);
32
32
  var s = "";
33
- for (var r in n)
34
- n[r] && (s += "; " + r, n[r] !== !0 && (s += "=" + n[r].split(";")[0]));
33
+ for (var i in n)
34
+ n[i] && (s += "; " + i, n[i] !== !0 && (s += "=" + n[i].split(";")[0]));
35
35
  return document.cookie = o + "=" + e.write(c, o) + s;
36
36
  }
37
37
  }
38
38
  function a(o) {
39
39
  if (!(typeof document > "u" || arguments.length && !o)) {
40
40
  for (var c = document.cookie ? document.cookie.split("; ") : [], n = {}, s = 0; s < c.length; s++) {
41
- var r = c[s].split("="), d = r.slice(1).join("=");
41
+ var i = c[s].split("="), u = i.slice(1).join("=");
42
42
  try {
43
- var l = decodeURIComponent(r[0]);
44
- if (n[l] = e.read(d, l), o === l)
43
+ var l = decodeURIComponent(i[0]);
44
+ if (n[l] = e.read(u, l), o === l)
45
45
  break;
46
46
  } catch {
47
47
  }
@@ -51,75 +51,75 @@ function C(e, t) {
51
51
  }
52
52
  return Object.create(
53
53
  {
54
- set: i,
54
+ set: t,
55
55
  get: a,
56
56
  remove: function(o, c) {
57
- i(
57
+ t(
58
58
  o,
59
59
  "",
60
- h({}, c, {
60
+ g({}, c, {
61
61
  expires: -1
62
62
  })
63
63
  );
64
64
  },
65
65
  withAttributes: function(o) {
66
- return C(this.converter, h({}, this.attributes, o));
66
+ return C(this.converter, g({}, this.attributes, o));
67
67
  },
68
68
  withConverter: function(o) {
69
- return C(h({}, this.converter, o), this.attributes);
69
+ return C(g({}, this.converter, o), this.attributes);
70
70
  }
71
71
  },
72
72
  {
73
- attributes: { value: Object.freeze(t) },
73
+ attributes: { value: Object.freeze(r) },
74
74
  converter: { value: Object.freeze(e) }
75
75
  }
76
76
  );
77
77
  }
78
- var B = C(z, { path: "/" });
79
- const $ = () => !!B.get("id_token");
80
- function O() {
81
- const [e, t] = x(!1), [i, a] = x(!1), [o, c] = x(!1), n = R(), { resolvedTheme: s } = b();
82
- L(() => {
78
+ var z = C(O, { path: "/" });
79
+ const b = () => !!z.get("id_token");
80
+ function A() {
81
+ const [e, r] = h(!1), [t, a] = h(!1), [o, c] = h(!1), n = R(), { resolvedTheme: s } = B();
82
+ w(() => {
83
83
  a(!0);
84
84
  }, []);
85
- const r = i && s ? s : "light", d = `${process.env.NEXT_PUBLIC_AUTH_URL}/${n}/login?mode=dialog&theme=${r}`, l = f(() => {
86
- t(!0), c(!1);
87
- }, []), p = f(() => {
88
- t(!1);
89
- }, []), y = f((g) => {
90
- t(g), g && c(!1);
85
+ const i = t && s ? s : "light", u = `${process.env.NEXT_PUBLIC_AUTH_URL}/${n}/login?mode=dialog&theme=${i}`, l = f(() => {
86
+ r(!0), c(!1);
87
+ }, []), m = f(() => {
88
+ r(!1);
89
+ }, []), y = f((p) => {
90
+ r(p), p && c(!1);
91
91
  }, []);
92
- L(() => {
93
- e && i && c(!1);
94
- }, [s, e, i]);
92
+ w(() => {
93
+ e && t && c(!1);
94
+ }, [s, e, t]);
95
95
  const v = f(() => {
96
96
  c(!0);
97
97
  }, []), U = f(
98
- ({ children: g, ...k }) => /* @__PURE__ */ u("div", { onClick: l, style: { cursor: "pointer" }, ...k, children: g }),
98
+ ({ children: p, ...T }) => /* @__PURE__ */ d("div", { onClick: l, style: { cursor: "pointer" }, ...T, children: p }),
99
99
  [l]
100
- ), I = f(() => e ? j(
101
- /* @__PURE__ */ w(
100
+ ), I = f(() => e ? k(
101
+ /* @__PURE__ */ x(
102
102
  "div",
103
103
  {
104
- className: m(
104
+ className: L(
105
105
  "fixed w-0 h-9 bg-[rgba(0,0,0,0.7)] z-1000",
106
106
  e && "top-0 left-0 w-full h-full"
107
107
  ),
108
108
  children: [
109
- /* @__PURE__ */ u(
109
+ /* @__PURE__ */ d(
110
110
  "div",
111
111
  {
112
- className: m(
112
+ className: L(
113
113
  "absolute inset-0 transition-opacity duration-300",
114
114
  o ? "opacity-0 pointer-events-none" : "opacity-100 z-30"
115
115
  )
116
116
  }
117
117
  ),
118
- /* @__PURE__ */ u(
118
+ /* @__PURE__ */ d(
119
119
  "iframe",
120
120
  {
121
- src: d,
122
- className: m(
121
+ src: u,
122
+ className: L(
123
123
  "w-full h-full border-none relative z-10 transition-opacity duration-300",
124
124
  o ? "opacity-100" : "opacity-0"
125
125
  ),
@@ -127,55 +127,44 @@ function O() {
127
127
  onLoad: v,
128
128
  sandbox: "allow-scripts allow-forms allow-same-origin"
129
129
  },
130
- `login-iframe-${r}`
131
- ),
132
- /* @__PURE__ */ u(
133
- "button",
134
- {
135
- onClick: p,
136
- className: m(
137
- "absolute top-2 right-2 bg-transparent border-none text-2xl cursor-pointer z-20",
138
- r === "dark" ? "text-white" : "text-gray-800"
139
- ),
140
- children: "×"
141
- }
130
+ `login-iframe-${i}`
142
131
  )
143
132
  ]
144
133
  }
145
134
  ),
146
135
  document.body
147
136
  ) : null, [
148
- p,
149
- r,
137
+ m,
138
+ i,
150
139
  v,
151
140
  o,
152
141
  e,
153
- d
142
+ u
154
143
  ]);
155
144
  return {
156
145
  isOpen: e,
157
146
  openLogin: l,
158
- closeLogin: p,
147
+ closeLogin: m,
159
148
  setLoginOpen: y,
160
- loginUrl: d,
161
- currentTheme: r,
149
+ loginUrl: u,
150
+ currentTheme: i,
162
151
  iframeLoaded: o,
163
152
  handleIframeLoad: v,
164
- mounted: i,
153
+ mounted: t,
165
154
  Trigger: U,
166
155
  LoginModal: I
167
156
  };
168
157
  }
169
- function N({ children: e, ...t }) {
170
- const { Trigger: i, LoginModal: a } = O();
171
- return /* @__PURE__ */ w(T, { children: [
172
- e && /* @__PURE__ */ u(i, { ...t, children: e }),
173
- /* @__PURE__ */ u(a, {})
158
+ function P({ children: e, ...r }) {
159
+ const { Trigger: t, LoginModal: a } = A();
160
+ return /* @__PURE__ */ x(j, { children: [
161
+ e && /* @__PURE__ */ d(t, { ...r, children: e }),
162
+ /* @__PURE__ */ d(a, {})
174
163
  ] });
175
164
  }
176
165
  export {
177
- N as WithLogin,
178
- N as default,
179
- $ as isLogin,
180
- O as useLogin
166
+ P as WithLogin,
167
+ P as default,
168
+ b as isLogin,
169
+ A as useLogin
181
170
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ichaingo/with-login",
3
- "version": "1.4.30",
3
+ "version": "1.4.31",
4
4
  "type": "module",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",