@hexdspace/react 0.0.19 → 0.0.21
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/dist/css/component.css +0 -1
- package/dist/css/primitive.css +10 -10
- package/dist/css/semantic.css +6 -6
- package/dist/index.d.ts +6 -3
- package/dist/index.js +28 -8
- package/package.json +1 -1
package/dist/css/component.css
CHANGED
package/dist/css/primitive.css
CHANGED
|
@@ -32,16 +32,16 @@
|
|
|
32
32
|
--ink-100: oklch(0.16 0.025 258);
|
|
33
33
|
|
|
34
34
|
/* Accent */
|
|
35
|
-
--accent-10:
|
|
36
|
-
--accent-20:
|
|
37
|
-
--accent-30:
|
|
38
|
-
--accent-40:
|
|
39
|
-
--accent-50:
|
|
40
|
-
--accent-60:
|
|
41
|
-
--accent-70:
|
|
42
|
-
--accent-80:
|
|
43
|
-
--accent-90:
|
|
44
|
-
--accent-100: oklch(0.
|
|
35
|
+
--accent-10: oklch(0.900 0.020 120);
|
|
36
|
+
--accent-20: oklch(0.870 0.025 120);
|
|
37
|
+
--accent-30: oklch(0.855 0.028 120);
|
|
38
|
+
--accent-40: oklch(0.845 0.030 120);
|
|
39
|
+
--accent-50: oklch(0.8428 0.030 120);
|
|
40
|
+
--accent-60: oklch(0.780 0.045 120);
|
|
41
|
+
--accent-70: oklch(0.680 0.060 120);
|
|
42
|
+
--accent-80: oklch(0.580 0.070 120);
|
|
43
|
+
--accent-90: oklch(0.500 0.065 120);
|
|
44
|
+
--accent-100: oklch(0.430 0.055 120);
|
|
45
45
|
|
|
46
46
|
/* Brand ramp */
|
|
47
47
|
--brand-10: oklch(0.97 0.020 250);
|
package/dist/css/semantic.css
CHANGED
|
@@ -88,8 +88,8 @@
|
|
|
88
88
|
--border: var(--ink-40);
|
|
89
89
|
--divider: color-mix(in oklab, var(--border), transparent 40%);
|
|
90
90
|
|
|
91
|
-
--brand: var(--brand-
|
|
92
|
-
--brand-strong: var(--brand-
|
|
91
|
+
--brand: var(--brand-50);
|
|
92
|
+
--brand-strong: var(--brand-40);
|
|
93
93
|
|
|
94
94
|
--accent: var(--accent-70);
|
|
95
95
|
--accent-strong: var(--accent-60);
|
|
@@ -99,10 +99,10 @@
|
|
|
99
99
|
--focus: var(--brand);
|
|
100
100
|
--focus-ring: 0 0 0 3px color-mix(in oklab, var(--focus), transparent 60%);
|
|
101
101
|
|
|
102
|
-
--info: var(--info-
|
|
103
|
-
--success: var(--success-
|
|
104
|
-
--warning: var(--warning-
|
|
105
|
-
--danger: var(--danger-
|
|
102
|
+
--info: var(--info-60);
|
|
103
|
+
--success: var(--success-60);
|
|
104
|
+
--warning: var(--warning-60);
|
|
105
|
+
--danger: var(--danger-60);
|
|
106
106
|
|
|
107
107
|
--surface-hover: color-mix(in oklab, var(--surface-1), white 6%);
|
|
108
108
|
--surface-active: color-mix(in oklab, var(--surface-1), white 8%);
|
package/dist/index.d.ts
CHANGED
|
@@ -307,7 +307,7 @@ type AuthState = {
|
|
|
307
307
|
declare function useAuth(): AuthState;
|
|
308
308
|
|
|
309
309
|
declare function useAuthActions(): {
|
|
310
|
-
login: (email: string, password: string) =>
|
|
310
|
+
login: (email: string, password: string) => Promise<Result<Error, User>>;
|
|
311
311
|
logout: () => void;
|
|
312
312
|
register: (email: string, password: string) => Promise<Result<Error, {
|
|
313
313
|
message: string;
|
|
@@ -363,15 +363,18 @@ type RequireAuthProps = {
|
|
|
363
363
|
guarded?: ReactNode;
|
|
364
364
|
loadingPlaceholder?: ReactNode;
|
|
365
365
|
errorPlaceholder?: ReactNode;
|
|
366
|
+
unauthenticatedRedirectTo?: string;
|
|
367
|
+
unauthenticatedPlaceholder?: ReactNode;
|
|
366
368
|
};
|
|
367
369
|
type RedirectIfAuthedProps = {
|
|
368
370
|
redirectTo?: string;
|
|
369
371
|
loadingPlaceholder?: ReactNode;
|
|
370
372
|
nonAuthedPlaceholder?: ReactNode;
|
|
371
373
|
errorPlaceholder?: ReactNode;
|
|
374
|
+
authenticatedPlaceholder?: ReactNode;
|
|
372
375
|
};
|
|
373
|
-
declare function RequireAuth({ guarded, loadingPlaceholder, errorPlaceholder }: RequireAuthProps): react_jsx_runtime.JSX.Element;
|
|
374
|
-
declare function RedirectIfAuthed({ redirectTo, loadingPlaceholder, nonAuthedPlaceholder, errorPlaceholder }: RedirectIfAuthedProps): react_jsx_runtime.JSX.Element;
|
|
376
|
+
declare function RequireAuth({ guarded, loadingPlaceholder, errorPlaceholder, unauthenticatedRedirectTo, unauthenticatedPlaceholder }: RequireAuthProps): react_jsx_runtime.JSX.Element;
|
|
377
|
+
declare function RedirectIfAuthed({ redirectTo, loadingPlaceholder, nonAuthedPlaceholder, errorPlaceholder, authenticatedPlaceholder }: RedirectIfAuthedProps): react_jsx_runtime.JSX.Element;
|
|
375
378
|
|
|
376
379
|
type AuthFixtures = {
|
|
377
380
|
meError?: HttpError;
|
package/dist/index.js
CHANGED
|
@@ -835,11 +835,11 @@ function useAuthDispatch() {
|
|
|
835
835
|
function useAuthActions() {
|
|
836
836
|
const dispatch = useAuthDispatch();
|
|
837
837
|
const authController2 = useAuthController();
|
|
838
|
-
const login = useCallback2((email, password) => {
|
|
838
|
+
const login = useCallback2(async (email, password) => {
|
|
839
839
|
dispatch({ type: "REQUEST" });
|
|
840
|
-
authController2.login(email, password)
|
|
841
|
-
|
|
842
|
-
|
|
840
|
+
const res = await authController2.login(email, password);
|
|
841
|
+
dispatchLoginResult(res, dispatch);
|
|
842
|
+
return res;
|
|
843
843
|
}, [dispatch, authController2]);
|
|
844
844
|
const logout = useCallback2(() => {
|
|
845
845
|
authController2.logout().then(() => dispatch({ type: "LOGOUT" }));
|
|
@@ -912,7 +912,13 @@ var AuthFormInputField = ({ id, label, type, value, onChange, placeholder, class
|
|
|
912
912
|
// src/feature/auth/interface/web/react/auth-route-guards.tsx
|
|
913
913
|
import { Navigate, Outlet, useLocation } from "react-router-dom";
|
|
914
914
|
import { Fragment, jsx as jsx6 } from "react/jsx-runtime";
|
|
915
|
-
function RequireAuth({
|
|
915
|
+
function RequireAuth({
|
|
916
|
+
guarded,
|
|
917
|
+
loadingPlaceholder,
|
|
918
|
+
errorPlaceholder,
|
|
919
|
+
unauthenticatedRedirectTo,
|
|
920
|
+
unauthenticatedPlaceholder
|
|
921
|
+
}) {
|
|
916
922
|
const auth = useAuth();
|
|
917
923
|
const location = useLocation();
|
|
918
924
|
if (auth.status === "loading") {
|
|
@@ -922,11 +928,20 @@ function RequireAuth({ guarded, loadingPlaceholder, errorPlaceholder }) {
|
|
|
922
928
|
return /* @__PURE__ */ jsx6(Fragment, { children: errorPlaceholder ?? loadingPlaceholder ?? null });
|
|
923
929
|
}
|
|
924
930
|
if (auth.status === "unauthenticated") {
|
|
925
|
-
|
|
931
|
+
if (unauthenticatedRedirectTo) {
|
|
932
|
+
return /* @__PURE__ */ jsx6(Navigate, { to: unauthenticatedRedirectTo, replace: true, state: { from: location } });
|
|
933
|
+
}
|
|
934
|
+
return /* @__PURE__ */ jsx6(Fragment, { children: unauthenticatedPlaceholder ?? null });
|
|
926
935
|
}
|
|
927
936
|
return guarded ? /* @__PURE__ */ jsx6(Fragment, { children: guarded }) : /* @__PURE__ */ jsx6(Outlet, {});
|
|
928
937
|
}
|
|
929
|
-
function RedirectIfAuthed({
|
|
938
|
+
function RedirectIfAuthed({
|
|
939
|
+
redirectTo,
|
|
940
|
+
loadingPlaceholder,
|
|
941
|
+
nonAuthedPlaceholder,
|
|
942
|
+
errorPlaceholder,
|
|
943
|
+
authenticatedPlaceholder
|
|
944
|
+
}) {
|
|
930
945
|
const auth = useAuth();
|
|
931
946
|
if (auth.status === "loading") {
|
|
932
947
|
return /* @__PURE__ */ jsx6(Fragment, { children: loadingPlaceholder ?? null });
|
|
@@ -934,7 +949,12 @@ function RedirectIfAuthed({ redirectTo, loadingPlaceholder, nonAuthedPlaceholder
|
|
|
934
949
|
if (auth.status === "error") {
|
|
935
950
|
return /* @__PURE__ */ jsx6(Fragment, { children: errorPlaceholder ?? loadingPlaceholder ?? null });
|
|
936
951
|
}
|
|
937
|
-
if (auth.status === "authenticated")
|
|
952
|
+
if (auth.status === "authenticated") {
|
|
953
|
+
if (redirectTo) {
|
|
954
|
+
return /* @__PURE__ */ jsx6(Navigate, { to: redirectTo, replace: true });
|
|
955
|
+
}
|
|
956
|
+
return /* @__PURE__ */ jsx6(Fragment, { children: authenticatedPlaceholder ?? null });
|
|
957
|
+
}
|
|
938
958
|
return nonAuthedPlaceholder ? /* @__PURE__ */ jsx6(Fragment, { children: nonAuthedPlaceholder }) : /* @__PURE__ */ jsx6(Outlet, {});
|
|
939
959
|
}
|
|
940
960
|
|