@purr-core/components.authenticator 0.0.9 → 0.0.10
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/package.json +4 -2
- package/dist/_base-routes.d.ts +0 -1
- package/dist/_components.d.ts +0 -4
- package/dist/_types.d.ts +0 -9
- package/dist/index.cjs +0 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -24
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@purr-core/components.authenticator",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.10",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"react": "*",
|
|
26
26
|
"react-dom": "*",
|
|
27
27
|
"react-router-dom": "*",
|
|
28
|
-
"@purr-core/hooks.block": "0.0.
|
|
28
|
+
"@purr-core/hooks.block": "0.0.10"
|
|
29
29
|
},
|
|
30
30
|
"author": "@DinhThienPhuc",
|
|
31
31
|
"license": "ISC",
|
|
@@ -34,6 +34,8 @@
|
|
|
34
34
|
"scripts": {
|
|
35
35
|
"dev": "vite build --watch",
|
|
36
36
|
"build": "tsc && vite build",
|
|
37
|
+
"build:vite": "tsc && vite build",
|
|
38
|
+
"build:tsup": "tsup",
|
|
37
39
|
"lint": "eslint . --ext ts,tsx --max-warnings 0"
|
|
38
40
|
}
|
|
39
41
|
}
|
package/dist/_base-routes.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const BASE_ROUTES: Record<string, string>;
|
package/dist/_components.d.ts
DELETED
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { default as React } from 'react';
|
|
2
|
-
import { IAuthenticatorProps } from './_types';
|
|
3
|
-
|
|
4
|
-
export declare const Authenticator: ({ children, isAuthenticated, extendRoutes, routeToGoWhenUnauthenticated, routeToGoWhenAuthenticated, }: IAuthenticatorProps) => string | number | bigint | boolean | Iterable<React.ReactNode> | Promise<string | number | bigint | boolean | React.ReactPortal | React.ReactElement<unknown, string | React.JSXElementConstructor<any>> | Iterable<React.ReactNode> | null | undefined> | React.JSX.Element | null | undefined;
|
package/dist/_types.d.ts
DELETED
package/dist/index.cjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const r=require("react/jsx-runtime"),t=require("react-router-dom"),O=require("@purr-core/hooks.block"),n={HOME:"/",NOT_FOUND:"*",LOGIN:"/login"},N=({children:u,isAuthenticated:o=!1,extendRoutes:c,routeToGoWhenUnauthenticated:s,routeToGoWhenAuthenticated:a})=>{const i=t.useLocation(),e=O(()=>({...n,...c}));return o&&i.pathname===e.LOGIN?a?r.jsx(t.Navigate,{to:a}):r.jsx(t.Navigate,{to:e.HOME}):!o&&i.pathname!==e.LOGIN?s?r.jsx(t.Navigate,{to:s}):r.jsx(t.Navigate,{to:e.LOGIN}):u};exports.Authenticator=N;exports.BASE_ROUTES=n;
|
package/dist/index.d.ts
DELETED
package/dist/index.js
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { jsx as r } from "react/jsx-runtime";
|
|
2
|
-
import { useLocation as N, Navigate as t } from "react-router-dom";
|
|
3
|
-
import a from "@purr-core/hooks.block";
|
|
4
|
-
const p = {
|
|
5
|
-
HOME: "/",
|
|
6
|
-
NOT_FOUND: "*",
|
|
7
|
-
LOGIN: "/login"
|
|
8
|
-
}, l = ({
|
|
9
|
-
children: m,
|
|
10
|
-
isAuthenticated: n = !1,
|
|
11
|
-
extendRoutes: s,
|
|
12
|
-
routeToGoWhenUnauthenticated: O,
|
|
13
|
-
routeToGoWhenAuthenticated: f
|
|
14
|
-
}) => {
|
|
15
|
-
const i = N(), o = a(() => ({
|
|
16
|
-
...p,
|
|
17
|
-
...s
|
|
18
|
-
}));
|
|
19
|
-
return n && i.pathname === o.LOGIN ? f ? /* @__PURE__ */ r(t, { to: f }) : /* @__PURE__ */ r(t, { to: o.HOME }) : !n && i.pathname !== o.LOGIN ? O ? /* @__PURE__ */ r(t, { to: O }) : /* @__PURE__ */ r(t, { to: o.LOGIN }) : m;
|
|
20
|
-
};
|
|
21
|
-
export {
|
|
22
|
-
l as Authenticator,
|
|
23
|
-
p as BASE_ROUTES
|
|
24
|
-
};
|