@ichaingo/with-login 1.4.156

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.
package/README.md ADDED
@@ -0,0 +1,7 @@
1
+ # @ichaingo/with-login
2
+
3
+ This library was generated with [Nx](https://nx.dev).
4
+
5
+ ## Running unit tests
6
+
7
+ Run `nx test @ichaingo/with-login` to execute the unit tests via [Vitest](https://vitest.dev/).
@@ -0,0 +1,7 @@
1
+ interface WithLoginProps extends React.PropsWithChildren, React.HTMLAttributes<any> {
2
+ children: React.ReactNode;
3
+ onClick: () => void;
4
+ }
5
+ export default function WithLogin({ children, onClick, ...rest }: WithLoginProps): import("react/jsx-runtime").JSX.Element;
6
+ export {};
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAOA,UAAU,cAAe,SAAQ,KAAK,CAAC,iBAAiB,EAAE,KAAK,CAAC,cAAc,CAAC,GAAG,CAAC;IACjF,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,CAAC,OAAO,UAAU,SAAS,CAAC,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,IAAI,EAAE,EAAE,cAAc,2CAmF/E"}
package/dist/index.js ADDED
@@ -0,0 +1,76 @@
1
+ 'use client';
2
+ import { jsxs as m, Fragment as x, jsx as o } from "react/jsx-runtime";
3
+ import { useState as i, useEffect as f } from "react";
4
+ import { createPortal as y } from "react-dom";
5
+ import { useLocale as v } from "next-intl";
6
+ import { twMerge as t } from "tailwind-merge";
7
+ import { useTheme as N } from "@ichaingo/next-themes";
8
+ function _({ children: d, onClick: T, ...u }) {
9
+ const [e, a] = i(!1), p = v(), { resolvedTheme: n } = N(), [r, g] = i(!1), [l, s] = i(!1);
10
+ f(() => {
11
+ g(!0);
12
+ }, []);
13
+ const c = r && n ? n : "light", h = `${process.env.NEXT_PUBLIC_AUTH_URL}/${p}/login?mode=dialog&theme=${c}`, L = () => {
14
+ a(!0), s(!1);
15
+ }, b = () => a(!1);
16
+ f(() => {
17
+ e && r && s(!1);
18
+ }, [n, e, r]);
19
+ const w = () => {
20
+ s(!0);
21
+ };
22
+ return /* @__PURE__ */ m(x, { children: [
23
+ /* @__PURE__ */ o("div", { onClick: L, style: { cursor: "pointer" }, ...u, children: d }),
24
+ e && y(
25
+ /* @__PURE__ */ m(
26
+ "div",
27
+ {
28
+ className: t(
29
+ "fixed w-0 h-9 bg-[rgba(0,0,0,0.7)] z-1000",
30
+ e && "top-0 left-0 w-full h-full"
31
+ ),
32
+ children: [
33
+ /* @__PURE__ */ o(
34
+ "div",
35
+ {
36
+ className: t(
37
+ "absolute inset-0 transition-opacity duration-300",
38
+ l ? "opacity-0 pointer-events-none" : "opacity-100 z-30"
39
+ )
40
+ }
41
+ ),
42
+ /* @__PURE__ */ o(
43
+ "iframe",
44
+ {
45
+ src: h,
46
+ className: t(
47
+ "w-full h-full border-none relative z-10 transition-opacity duration-300",
48
+ l ? "opacity-100" : "opacity-0"
49
+ ),
50
+ title: "Login",
51
+ onLoad: w,
52
+ sandbox: "allow-scripts allow-forms allow-same-origin"
53
+ },
54
+ `login-iframe-${c}`
55
+ ),
56
+ /* @__PURE__ */ o(
57
+ "button",
58
+ {
59
+ onClick: b,
60
+ className: t(
61
+ "absolute top-2 right-2 bg-transparent border-none text-2xl cursor-pointer z-20",
62
+ "text-white"
63
+ ),
64
+ children: "×"
65
+ }
66
+ )
67
+ ]
68
+ }
69
+ ),
70
+ document.body
71
+ )
72
+ ] });
73
+ }
74
+ export {
75
+ _ as default
76
+ };
package/package.json ADDED
@@ -0,0 +1,31 @@
1
+ {
2
+ "name": "@ichaingo/with-login",
3
+ "version": "1.4.156",
4
+ "type": "module",
5
+ "main": "./dist/index.js",
6
+ "module": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ "./package.json": "./package.json",
10
+ ".": {
11
+ "types": "./dist/index.d.ts",
12
+ "import": "./dist/index.js",
13
+ "default": "./dist/index.js"
14
+ }
15
+ },
16
+ "files": [
17
+ "dist",
18
+ "!**/*.tsbuildinfo"
19
+ ],
20
+ "peerDependencies": {
21
+ "tailwind-merge": "^2.5.5",
22
+ "@ichaingo/next-themes": "^0.4.11",
23
+ "next-intl": "^4.3.4",
24
+ "next": "^15.1.6",
25
+ "js-cookie": "^3.0.5"
26
+ },
27
+ "devDependencies": {
28
+ "rollup-plugin-preserve-use-client": "^1.0.0",
29
+ "@types/js-cookie": "^3.0.6"
30
+ }
31
+ }